admin-shell-messaging
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -13,3 +13,3 @@ import { CommonParams, InsertOnBreadcrumbParams } from "./types"; | ||
* // other necessary imports up here... | ||
* import { insertNewBreadcrumbLevel } from `@vtex/admin-shell-messaging` | ||
* import { insertNewBreadcrumbLevel } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -52,3 +52,3 @@ * const App = () => { | ||
* // other necessary imports up here... | ||
* import { clearBreadcrumbExtraLevels } from `@vtex/admin-shell-messaging` | ||
* import { clearBreadcrumbExtraLevels } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -55,0 +55,0 @@ * const App = () => { |
@@ -16,3 +16,3 @@ "use strict"; | ||
* // other necessary imports up here... | ||
* import { insertNewBreadcrumbLevel } from `@vtex/admin-shell-messaging` | ||
* import { insertNewBreadcrumbLevel } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -67,3 +67,3 @@ * const App = () => { | ||
* // other necessary imports up here... | ||
* import { clearBreadcrumbExtraLevels } from `@vtex/admin-shell-messaging` | ||
* import { clearBreadcrumbExtraLevels } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -70,0 +70,0 @@ * const App = () => { |
@@ -18,3 +18,3 @@ import { CommonParams } from "./types"; | ||
* // other necessary imports up here... | ||
* import { startLoading, stopLoading } from `@vtex/admin-shell-messaging` | ||
* import { startLoading, stopLoading } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -21,0 +21,0 @@ * const App = () => { |
@@ -21,3 +21,3 @@ "use strict"; | ||
* // other necessary imports up here... | ||
* import { startLoading, stopLoading } from `@vtex/admin-shell-messaging` | ||
* import { startLoading, stopLoading } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -24,0 +24,0 @@ * const App = () => { |
@@ -26,4 +26,11 @@ import { ACTION_TYPES } from "./actions"; | ||
export interface Message { | ||
/** | ||
* Format of the object returned from | ||
* any of the actions. | ||
* */ | ||
action: { | ||
type: ACTION_TYPES; | ||
/** | ||
* INSERT_BREADCRUMB_EXTRA_LEVEL action types | ||
* */ | ||
newLevelName?: string; | ||
@@ -33,2 +40,33 @@ previousLevelUrl?: string; | ||
} | ||
/** | ||
* Helper interface to be used along with | ||
* event listeners. This should be mostly used | ||
* on the admin-shell itself. | ||
* | ||
* # @example | ||
* ```jsx | ||
* // other necessary imports up here... | ||
* import { ReceivedMessage, ACTION_TYPES } from '@vtex/admin-shell-messaging' | ||
* | ||
* const App = () => { | ||
* const [isLoading, setIsLoading] = useState<ACTION_TYPES | null>() | ||
* const messageListener = ({ origin, data }: ReceivedMessage) => { | ||
* const type = data?.action.type | ||
* if (type === ACTION_TYPES.START_LOADING || type === ACTION_TYPES.STOP_LOADING) { | ||
* setIsLoading(type) | ||
* } | ||
* } | ||
* | ||
* useEffect(() => { | ||
* window.addEventListener('message', messageListener, false) | ||
* return () => | ||
* window.removeEventListener('message', messageListener, false) | ||
* }, []) | ||
* | ||
* return ( | ||
* // some ui here | ||
* ) | ||
* } | ||
* ``` | ||
* */ | ||
export interface ReceivedMessage { | ||
@@ -35,0 +73,0 @@ origin: string; |
{ | ||
"name": "admin-shell-messaging", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Admin shell Iframe messaging package", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -15,3 +15,3 @@ import { ACTIONS } from "./actions"; | ||
* // other necessary imports up here... | ||
* import { insertNewBreadcrumbLevel } from `@vtex/admin-shell-messaging` | ||
* import { insertNewBreadcrumbLevel } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -70,3 +70,3 @@ * const App = () => { | ||
* // other necessary imports up here... | ||
* import { clearBreadcrumbExtraLevels } from `@vtex/admin-shell-messaging` | ||
* import { clearBreadcrumbExtraLevels } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -73,0 +73,0 @@ * const App = () => { |
@@ -20,3 +20,3 @@ import { ACTIONS } from "./actions"; | ||
* // other necessary imports up here... | ||
* import { startLoading, stopLoading } from `@vtex/admin-shell-messaging` | ||
* import { startLoading, stopLoading } from '@vtex/admin-shell-messaging' | ||
* | ||
@@ -23,0 +23,0 @@ * const App = () => { |
@@ -29,4 +29,11 @@ import { ACTION_TYPES } from "./actions"; | ||
export interface Message { | ||
/** | ||
* Format of the object returned from | ||
* any of the actions. | ||
* */ | ||
action: { | ||
type: ACTION_TYPES; | ||
/** | ||
* INSERT_BREADCRUMB_EXTRA_LEVEL action types | ||
* */ | ||
newLevelName?: string; | ||
@@ -37,2 +44,33 @@ previousLevelUrl?: string; | ||
/** | ||
* Helper interface to be used along with | ||
* event listeners. This should be mostly used | ||
* on the admin-shell itself. | ||
* | ||
* # @example | ||
* ```jsx | ||
* // other necessary imports up here... | ||
* import { ReceivedMessage, ACTION_TYPES } from '@vtex/admin-shell-messaging' | ||
* | ||
* const App = () => { | ||
* const [isLoading, setIsLoading] = useState<ACTION_TYPES | null>() | ||
* const messageListener = ({ origin, data }: ReceivedMessage) => { | ||
* const type = data?.action.type | ||
* if (type === ACTION_TYPES.START_LOADING || type === ACTION_TYPES.STOP_LOADING) { | ||
* setIsLoading(type) | ||
* } | ||
* } | ||
* | ||
* useEffect(() => { | ||
* window.addEventListener('message', messageListener, false) | ||
* return () => | ||
* window.removeEventListener('message', messageListener, false) | ||
* }, []) | ||
* | ||
* return ( | ||
* // some ui here | ||
* ) | ||
* } | ||
* ``` | ||
* */ | ||
export interface ReceivedMessage { | ||
@@ -39,0 +77,0 @@ origin: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30871
931