@appsemble/preact
Advanced tools
Comparing version 0.13.12 to 0.13.13
import { BootstrapParams } from '@appsemble/sdk'; | ||
import { IntlMessageFormat } from 'intl-messageformat'; | ||
import { ComponentType, VNode } from 'preact'; | ||
import { ComponentType } from 'preact'; | ||
export interface BlockProps extends BootstrapParams { | ||
@@ -9,5 +8,2 @@ /** | ||
ready: () => void; | ||
messages: { | ||
[id: string]: IntlMessageFormat; | ||
}; | ||
} | ||
@@ -18,12 +14,7 @@ /** | ||
* @param Component - The Preact component to mount. | ||
* @param messages - Translatable messages to serve (deprecated). | ||
* | ||
* @returns A promise which gets resolved if the component calls `ready()`. | ||
*/ | ||
export declare function mount(Component: ComponentType<BlockProps>, messages?: { | ||
[id: string]: string; | ||
}): (params: BootstrapParams) => Promise<void>; | ||
export declare function bootstrap(Component: ComponentType<BlockProps>, messages?: { | ||
[id: string]: string; | ||
}): void; | ||
export declare function mount(Component: ComponentType<BlockProps>): (params: BootstrapParams) => Promise<void>; | ||
export declare function bootstrap(Component: ComponentType<BlockProps>): void; | ||
/** | ||
@@ -40,8 +31,1 @@ * A HOC which passes the Appsemble block values to he wrapped Preact component. | ||
export declare function useBlock(): BlockProps; | ||
export interface FormattedMessageProps { | ||
id: string; | ||
values?: { | ||
[key: string]: number | string | ((str: string) => VNode); | ||
}; | ||
} | ||
export declare function FormattedMessage({ id, values }: FormattedMessageProps): VNode; |
import { bootstrap as sdkBootstrap } from '@appsemble/sdk'; | ||
import { IntlMessageFormat } from 'intl-messageformat'; | ||
import { createContext, Fragment, h, render } from 'preact'; | ||
import { createContext, h, render } from 'preact'; | ||
import { useContext } from 'preact/hooks'; | ||
@@ -10,7 +9,6 @@ const Context = createContext(null); | ||
* @param Component - The Preact component to mount. | ||
* @param messages - Translatable messages to serve (deprecated). | ||
* | ||
* @returns A promise which gets resolved if the component calls `ready()`. | ||
*/ | ||
export function mount(Component, messages) { | ||
export function mount(Component) { | ||
return (params) => new Promise((ready) => { | ||
@@ -20,8 +18,2 @@ const props = { | ||
ready, | ||
messages: messages | ||
? Object.entries(messages).reduce((acc, [key, message]) => { | ||
acc[key] = new IntlMessageFormat(message); | ||
return acc; | ||
}, {}) | ||
: {}, | ||
}; | ||
@@ -34,4 +26,4 @@ const component = (h(Context.Provider, { value: props }, | ||
} | ||
export function bootstrap(Component, messages) { | ||
sdkBootstrap(mount(Component, messages)); | ||
export function bootstrap(Component) { | ||
sdkBootstrap(mount(Component)); | ||
} | ||
@@ -53,13 +45,2 @@ /** | ||
} | ||
export function FormattedMessage({ id, values }) { | ||
const { messages } = useBlock(); | ||
if (!Object.hasOwnProperty.call(messages, id)) { | ||
return h(Fragment, null, | ||
"Untranslated message ID: ", | ||
id); | ||
} | ||
const formattedMessage = messages[id].format(values); | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
return h(Fragment, null, formattedMessage); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@appsemble/preact", | ||
"version": "0.13.12", | ||
"version": "0.13.13", | ||
"description": "Build your own blocks using Preact", | ||
@@ -36,9 +36,6 @@ "keywords": [ | ||
}, | ||
"dependencies": { | ||
"intl-messageformat": "^9.3.6" | ||
}, | ||
"peerDependencies": { | ||
"@appsemble/sdk": "0.13.12", | ||
"@appsemble/sdk": "0.13.13", | ||
"preact": "^10.0.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
2
5062
69
+ Added@appsemble/sdk@0.13.13(transitive)
- Removedintl-messageformat@^9.3.6
- Removed@appsemble/sdk@0.13.12(transitive)
- Removed@formatjs/ecma402-abstract@1.11.4(transitive)
- Removed@formatjs/fast-memoize@1.2.1(transitive)
- Removed@formatjs/icu-messageformat-parser@2.1.0(transitive)
- Removed@formatjs/icu-skeleton-parser@1.3.6(transitive)
- Removed@formatjs/intl-localematcher@0.2.25(transitive)
- Removedintl-messageformat@9.13.0(transitive)
- Removedtslib@2.8.0(transitive)