@aws-amplify/ui-react 2.12.0 → 2.13.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/esm/hooks/actions/shared/types.js +2 -0
- package/dist/esm/hooks/actions/shared/types.js.map +1 -0
- package/dist/esm/hooks/actions/shared/useTypeCastFields.js +2 -0
- package/dist/esm/hooks/actions/shared/useTypeCastFields.js.map +1 -0
- package/dist/esm/hooks/actions/useDataStoreCreateAction.js +1 -1
- package/dist/esm/hooks/actions/useDataStoreCreateAction.js.map +1 -1
- package/dist/esm/hooks/actions/useDataStoreUpdateAction.js +1 -1
- package/dist/esm/hooks/actions/useDataStoreUpdateAction.js.map +1 -1
- package/dist/esm/hooks/useBreakpointValue.js +2 -0
- package/dist/esm/hooks/useBreakpointValue.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/hooks/actions/shared/types.d.ts +27 -0
- package/dist/types/hooks/actions/shared/useTypeCastFields.d.ts +17 -0
- package/dist/types/hooks/actions/testModels/model.d.ts +25 -0
- package/dist/types/hooks/actions/testModels/schema.d.ts +2 -0
- package/dist/types/hooks/actions/useDataStoreCreateAction.d.ts +4 -7
- package/dist/types/hooks/actions/useDataStoreUpdateAction.d.ts +4 -7
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useBreakpointValue.d.ts +2 -0
- package/package.json +2 -2
package/dist/internal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@aws-amplify/auth"),a=require("@aws-amplify/core"),r=require("@aws-amplify/datastore"),i=require("@aws-amplify/storage"),s=require("./utils-92b84aab.js"),o=require("aws-amplify");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,Object.freeze(t)}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@aws-amplify/auth"),a=require("@aws-amplify/core"),r=require("@aws-amplify/datastore"),i=require("@aws-amplify/storage"),s=require("./utils-92b84aab.js"),o=require("aws-amplify");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,Object.freeze(t)}var c=d(e),u=n(t);const l=({model:e,criteria:t,pagination:a})=>{const[i,s]=c.useState({items:[],isLoading:!1,error:void 0});return c.useEffect((()=>{s({isLoading:!0,items:[]});const i=r.DataStore.observeQuery(e,t,a).subscribe((e=>s({items:e.items,isLoading:!1})),(e=>s({items:[],error:e,isLoading:!1})));if(i)return()=>i.unsubscribe()}),[]),i},f=({model:e,id:t})=>{const[a,i]=c.useState(),[s,o]=c.useState(!1),[n,d]=c.useState();return c.useEffect((()=>{o(!0),r.DataStore.query(e,t).then(i).catch(d).finally((()=>o(!1)))}),[]),{error:n,item:a,isLoading:s}};const p="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default";const h=({fields:e,modelName:t,schema:a})=>c.useMemo((()=>{if(function(e,t){return!t}(0,a))return e;let r={};return Object.keys(e).forEach((i=>{var s,o,n;switch(null===(n=null===(o=null===(s=null==a?void 0:a.models[t])||void 0===s?void 0:s.fields)||void 0===o?void 0:o[i])||void 0===n?void 0:n.type){case"AWSTimestamp":case"Float":r[i]=Number(e[i]);break;case"Boolean":r[i]=Boolean(e[i]);break;case"Int":r[i]=parseInt(e[i]);break;default:r[i]=e[i]}})),r}),[e,a,t]),v=e=>e.reduce(((e,t)=>a=>t(e(a))),(e=>e)),g=e=>{const{and:t,or:a,field:r,operator:i,operand:o}=e;if(Array.isArray(t)){const e=t.map((e=>g(e)));return t=>t.and(v(e))}if(Array.isArray(a)){const e=a.map((e=>g(e)));return t=>t.or(v(e))}return e=>s.isFunction(e[r])?e[r].call(e,i,o):e};exports.findChildOverrides=s.findChildOverrides,exports.getOverrideProps=s.getOverrideProps,exports.getOverridesFromVariants=s.getOverridesFromVariants,exports.mergeVariantsAndOverrides=s.mergeVariantsAndOverrides,exports.createDataStorePredicate=g,exports.useAuth=()=>{const[e,t]=c.useState({error:void 0,isLoading:!0,user:void 0}),r=({payload:e})=>{switch(e.event){case"signIn":return t({user:e.data,isLoading:!1});case"signOut":return t({isLoading:!1})}},i=()=>(t({isLoading:!0}),u.default.currentAuthenticatedUser().then((e=>t({user:e,isLoading:!1}))).catch((e=>t({error:e,isLoading:!1}))),a.Hub.listen("auth",r),()=>a.Hub.remove("auth",r));return c.useEffect(i,[]),Object.assign(Object.assign({},e),{fetch:i})},exports.useAuthSignOutAction=e=>()=>s.__awaiter(void 0,void 0,void 0,(function*(){try{o.Hub.dispatch("ui",{event:"actions:auth:signout:started",data:{options:e}},"actions:auth:signout",p),yield o.Auth.signOut(e),o.Hub.dispatch("ui",{event:"actions:auth:signout:finished",data:{options:e}},"actions:auth:signout",p)}catch(t){o.Hub.dispatch("ui",{event:"actions:auth:signout:finished",data:{options:e,errorMessage:s.getErrorMessage(t)}},"actions:auth:signout",p)}})),exports.useDataStoreBinding=function(e){return"record"===e.type?f(e):l(e)},exports.useDataStoreCollection=l,exports.useDataStoreCreateAction=({model:e,fields:t,schema:a})=>{const r=h({fields:t,modelName:e.name,schema:a});return()=>s.__awaiter(void 0,void 0,void 0,(function*(){try{o.Hub.dispatch("ui",{event:"actions:datastore:create:started",data:{fields:r}},"actions:datastore:create",p);const t=yield o.DataStore.save(new e(r));o.Hub.dispatch("ui",{event:"actions:datastore:create:finished",data:{fields:r,item:t}},"actions:datastore:create",p)}catch(e){o.Hub.dispatch("ui",{event:"actions:datastore:create:finished",data:{fields:r,errorMessage:s.getErrorMessage(e)}},"actions:datastore:create",p)}}))},exports.useDataStoreDeleteAction=({model:e,id:t})=>()=>s.__awaiter(void 0,void 0,void 0,(function*(){try{o.Hub.dispatch("ui",{event:"actions:datastore:delete:started",data:{id:t}},"actions:datastore:delete",p),yield o.DataStore.delete(e,t),o.Hub.dispatch("ui",{event:"actions:datastore:delete:finished",data:{id:t}},"actions:datastore:delete",p)}catch(e){o.Hub.dispatch("ui",{event:"actions:datastore:delete:finished",data:{id:t,errorMessage:s.getErrorMessage(e)}},"actions:datastore:delete",p)}})),exports.useDataStoreItem=f,exports.useDataStoreUpdateAction=({fields:e,id:t,model:a,schema:r})=>{const i=h({fields:e,modelName:a.name,schema:r});return()=>s.__awaiter(void 0,void 0,void 0,(function*(){try{o.Hub.dispatch("ui",{event:"actions:datastore:update:started",data:{fields:i,id:t}},"actions:datastore:update",p);const e=yield o.DataStore.query(a,t);if(!e)throw new Error(`Error querying datastore item by id: ${t}`);const r=yield o.DataStore.save(a.copyOf(e,(e=>{Object.assign(e,i)})));o.Hub.dispatch("ui",{event:"actions:datastore:update:finished",data:{fields:i,id:t,item:r}},"actions:datastore:update",p)}catch(e){o.Hub.dispatch("ui",{event:"actions:datastore:update:finished",data:{fields:i,id:t,errorMessage:s.getErrorMessage(e)}},"actions:datastore:update",p)}}))},exports.useNavigateAction=e=>{const{type:t,url:a,anchor:r,target:i}=e,s=c.useMemo((()=>{switch(t){case"url":return()=>{window.open(a,i||"_self","noopener noreferrer")};case"anchor":return()=>{window.location.hash=r};case"reload":return()=>{window.location.reload()};default:return()=>{console.warn('Please provide a valid navigate type. Available types are "url", "anchor" and "reload".')}}}),[r,i,t,a]);return()=>{o.Hub.dispatch("ui",{event:"actions:core:navigate:started",data:e},"actions:core:navigate",p),s(),o.Hub.dispatch("ui",{event:"actions:core:navigate:finished",data:e},"actions:core:navigate",p)}},exports.useStateMutationAction=e=>{const[t,a]=c.useState(e),r=c.useCallback((e=>{const r=t;o.Hub.dispatch("ui",{event:"actions:core:statemutation:started",data:{prevState:r,newState:e}},"actions:core:statemutation",p),a(e),o.Hub.dispatch("ui",{event:"actions:core:statemutation:finished",data:{prevState:r,newState:e}},"actions:core:statemutation",p)}),[t]);return[t,r]},exports.useStorageURL=(e,t)=>{const[a,r]=c.useState({isLoading:!0}),s=JSON.stringify(t),o=()=>{r({isLoading:!0});const a=i.Storage.get(e,t);return a.then((e=>r({url:e,isLoading:!1}))).catch((e=>r({error:e,isLoading:!1}))),()=>i.Storage.cancel(a)};return c.useEffect(o,[e,t,s]),Object.assign(Object.assign({},a),{fetch:o})};
|
|
2
2
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sources":["../src/hooks/useAuth.ts","../src/hooks/useDataStore.tsx","../src/helpers/constants.ts","../src/primitives/shared/datastore.ts","../src/hooks/actions/useAuthSignOutAction.ts","../src/hooks/actions/constants.ts","../src/hooks/actions/useDataStoreCreateAction.ts","../src/hooks/actions/useDataStoreDeleteAction.ts","../src/hooks/actions/useDataStoreUpdateAction.ts","../src/hooks/actions/useNavigateAction.ts","../src/hooks/actions/useStateMutationAction.ts","../src/hooks/useStorageURL.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["useDataStoreCollection","model","criteria","pagination","result","setResult","React","useState","items","isLoading","error","undefined","useEffect","subscription","DataStore","observeQuery","subscribe","snapshot","unsubscribe","useDataStoreItem","id","item","setItem","setLoading","setError","query","then","catch","finally","AMPLIFY_SYMBOL","Symbol","for","mergePredicates","predicates","reduce","previous","current","predicate","createDataStorePredicate","predicateObject","and","groupAnd","or","groupOr","field","operator","operand","Array","isArray","map","condition","p","isFunction","call","user","handleAuth","payload","event","data","fetch","Auth","currentAuthenticatedUser","Hub","listen","remove","
|
|
1
|
+
{"version":3,"file":"internal.js","sources":["../src/hooks/useAuth.ts","../src/hooks/useDataStore.tsx","../src/helpers/constants.ts","../src/hooks/actions/shared/useTypeCastFields.ts","../src/hooks/actions/shared/types.ts","../src/primitives/shared/datastore.ts","../src/hooks/actions/useAuthSignOutAction.ts","../src/hooks/actions/constants.ts","../src/hooks/actions/useDataStoreCreateAction.ts","../src/hooks/actions/useDataStoreDeleteAction.ts","../src/hooks/actions/useDataStoreUpdateAction.ts","../src/hooks/actions/useNavigateAction.ts","../src/hooks/actions/useStateMutationAction.ts","../src/hooks/useStorageURL.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["useDataStoreCollection","model","criteria","pagination","result","setResult","React","useState","items","isLoading","error","undefined","useEffect","subscription","DataStore","observeQuery","subscribe","snapshot","unsubscribe","useDataStoreItem","id","item","setItem","setLoading","setError","query","then","catch","finally","AMPLIFY_SYMBOL","Symbol","for","useTypeCastFields","fields","modelName","schema","useMemo","isAlreadyTyped","castFields","Object","keys","forEach","fieldName","_c","_a","models","_b","type","Number","Boolean","parseInt","mergePredicates","predicates","reduce","previous","current","predicate","createDataStorePredicate","predicateObject","and","groupAnd","or","groupOr","field","operator","operand","Array","isArray","map","condition","p","isFunction","call","user","handleAuth","payload","event","data","fetch","Auth","currentAuthenticatedUser","Hub","listen","remove","assign","options","__awaiter","dispatch","signOut","errorMessage","getErrorMessage","props","initialFields","name","save","delete","original","Error","copyOf","updated","url","anchor","target","run","window","open","location","hash","reload","console","warn","initialState","state","setState","setNewState","useCallback","newState","prevState","key","serializedOptions","JSON","stringify","promise","Storage","get","cancel"],"mappings":"kpBAsBO,MCNMA,EAAyB,EACpCC,MAAAA,EACAC,SAAAA,EACAC,WAAAA,MAEA,MAAOC,EAAQC,GAAaC,EAAMC,SAAuC,CACvEC,MAAO,GACPC,WAAW,EACXC,WAAOC,IA2BT,OAFAL,EAAMM,WAt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,MAAAA,EAAOD,WAAW,MAG3C,IAAMkH,EAAOA,QAACE,OAAOH,IAK9B,OAFApH,EAAMM,UAAUkE,EAAO,CAACwC,EAAKjC,EAASkC,IAE1BhF,OAAA6C,OAAA7C,OAAA6C,OAAA,GAAAhF,GAAQ,CAAA0E,MAAAA"}
|
package/dist/styles.css
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PersistentModel, PersistentModelConstructor, ModelInit, Schema } from '@aws-amplify/datastore';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Model's field values to types supported by
|
|
4
|
+
* Amplify UI field components. This is required
|
|
5
|
+
* because Datastore Int and Float scalar types are often
|
|
6
|
+
* entered by users in a TextField which returns a string
|
|
7
|
+
*/
|
|
8
|
+
declare type ModelFields<Type> = {
|
|
9
|
+
[Property in keyof Type]: string | number | boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare type DataStoreActionFields<Model> = ModelInit<Model> | ModelFields<ModelInit<Model>>;
|
|
12
|
+
export interface UseDataStoreActionOptions<Model extends PersistentModel> {
|
|
13
|
+
model: PersistentModelConstructor<Model>;
|
|
14
|
+
/**
|
|
15
|
+
* Pass either already converted field values based on DataStore schema,
|
|
16
|
+
* or also pass the `schema` param have string field values
|
|
17
|
+
* optimistically cast to the expected type based on the `schema`
|
|
18
|
+
*/
|
|
19
|
+
fields: DataStoreActionFields<Model>;
|
|
20
|
+
/**
|
|
21
|
+
* Used to optimistically cast fields values to the
|
|
22
|
+
* expected value types based on the `schema` provided
|
|
23
|
+
*/
|
|
24
|
+
schema?: Schema;
|
|
25
|
+
}
|
|
26
|
+
export declare function isAlreadyTyped<Model>(fields: DataStoreActionFields<Model>, schema: Schema): fields is ModelInit<Model>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ModelInit, Schema } from '@aws-amplify/datastore';
|
|
2
|
+
import { DataStoreActionFields } from './types';
|
|
3
|
+
interface UseTypeCastFieldsProps<Model> {
|
|
4
|
+
fields: DataStoreActionFields<Model>;
|
|
5
|
+
modelName: string;
|
|
6
|
+
schema: Schema;
|
|
7
|
+
}
|
|
8
|
+
declare type UseTypeCastFieldsReturn<Model> = ModelInit<Model> | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Optimistically casts field string values to types required by
|
|
11
|
+
* datastore based on the schema type
|
|
12
|
+
* @see: See https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html
|
|
13
|
+
*/
|
|
14
|
+
export declare const useTypeCastFields: <Model>({ fields, modelName, schema, }: UseTypeCastFieldsProps<Model>) => ModelInit<Model, {
|
|
15
|
+
readOnlyFields: "createdAt" | "updatedAt";
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ModelInit, MutableModel } from '@aws-amplify/datastore';
|
|
2
|
+
declare type HomeMetaData = {
|
|
3
|
+
readOnlyFields: 'createdAt' | 'updatedAt';
|
|
4
|
+
};
|
|
5
|
+
export declare class Home {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly address?: string | null;
|
|
8
|
+
readonly image_url?: string | null;
|
|
9
|
+
readonly price?: number | null;
|
|
10
|
+
readonly Rating?: number | null;
|
|
11
|
+
readonly isAvailable?: boolean | null;
|
|
12
|
+
readonly availabilityDateTime?: string | null;
|
|
13
|
+
readonly availabilityDate?: string | null;
|
|
14
|
+
readonly availabliltyTime?: string | null;
|
|
15
|
+
readonly randomJSON?: string | null;
|
|
16
|
+
readonly timestamp?: number | null;
|
|
17
|
+
readonly phone?: string | null;
|
|
18
|
+
readonly ipAddress?: string | null;
|
|
19
|
+
readonly email?: string | null;
|
|
20
|
+
readonly createdAt?: string | null;
|
|
21
|
+
readonly updatedAt?: string | null;
|
|
22
|
+
constructor(init: ModelInit<Home, HomeMetaData>);
|
|
23
|
+
static copyOf(source: Home, mutator: (draft: MutableModel<Home, HomeMetaData>) => MutableModel<Home, HomeMetaData> | void): Home;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
fields: ModelInit<Model, {
|
|
5
|
-
readOnlyFields: 'createdAt' | 'updatedAt';
|
|
6
|
-
}>;
|
|
1
|
+
import { PersistentModel } from '@aws-amplify/datastore';
|
|
2
|
+
import { UseDataStoreActionOptions } from './shared/types';
|
|
3
|
+
export interface UseDataStoreCreateActionOptions<Model extends PersistentModel> extends UseDataStoreActionOptions<Model> {
|
|
7
4
|
}
|
|
8
5
|
/**
|
|
9
6
|
* Action to Create DataStore item
|
|
@@ -11,4 +8,4 @@ export interface UseDataStoreCreateActionOptions<Model extends PersistentModel>
|
|
|
11
8
|
*/
|
|
12
9
|
export declare const useDataStoreCreateAction: <Model extends Readonly<{
|
|
13
10
|
id: string;
|
|
14
|
-
} & Record<string, any>>>({ model, fields, }: UseDataStoreCreateActionOptions<Model>) => () => Promise<void>;
|
|
11
|
+
} & Record<string, any>>>({ model, fields: initialFields, schema, }: UseDataStoreCreateActionOptions<Model>) => () => Promise<void>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PersistentModel } from '@aws-amplify/datastore';
|
|
2
|
+
import { UseDataStoreActionOptions } from './shared/types';
|
|
3
|
+
export interface UseDataStoreUpdateActionOptions<Model extends PersistentModel> extends UseDataStoreActionOptions<Model> {
|
|
4
4
|
id: string;
|
|
5
|
-
fields: ModelInit<Model, {
|
|
6
|
-
readOnlyFields: 'createdAt' | 'updatedAt';
|
|
7
|
-
}>;
|
|
8
5
|
}
|
|
9
6
|
/**
|
|
10
7
|
* Action to Update DataStore item
|
|
@@ -12,4 +9,4 @@ export interface UseDataStoreUpdateActionOptions<Model extends PersistentModel>
|
|
|
12
9
|
*/
|
|
13
10
|
export declare const useDataStoreUpdateAction: <Model extends Readonly<{
|
|
14
11
|
id: string;
|
|
15
|
-
} & Record<string, any>>>({
|
|
12
|
+
} & Record<string, any>>>({ fields: initialFields, id, model, schema, }: UseDataStoreUpdateActionOptions<Model>) => () => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"test:unit:watch": "jest --watch"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@aws-amplify/ui": "3.4.
|
|
61
|
+
"@aws-amplify/ui": "3.4.1",
|
|
62
62
|
"@aws-amplify/ui-react-v1": "npm:@aws-amplify/ui-react@1.2.9",
|
|
63
63
|
"@radix-ui/react-accordion": "0.1.6",
|
|
64
64
|
"@radix-ui/react-dropdown-menu": "0.1.6",
|