storybook-i18n 2.0.5 → 2.0.7
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/README.md +3 -0
- package/dist/preview.d.ts +2 -9
- package/dist/preview.js +2 -2
- package/dist/preview.js.map +1 -1
- package/dist/preview.mjs +2 -2
- package/dist/preview.mjs.map +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ import type { Renderer, ProjectAnnotations } from '@storybook/types';
|
|
|
23
23
|
import i18n from 'storybook-i18n/preview';
|
|
24
24
|
import { withYourI18nDecorator } from './withYourDecorator';
|
|
25
25
|
|
|
26
|
+
// @ts-ignore
|
|
26
27
|
const i18nDecorators = i18n?.decorators || [];
|
|
27
28
|
|
|
28
29
|
const preview: ProjectAnnotations<Renderer> = {
|
|
@@ -33,6 +34,8 @@ const preview: ProjectAnnotations<Renderer> = {
|
|
|
33
34
|
export default preview;
|
|
34
35
|
```
|
|
35
36
|
|
|
37
|
+
Due to an issue with Storybook (pending resolution), you will need that `@ts-ignore` above the decorators line.
|
|
38
|
+
|
|
36
39
|
The currently selected locale is available in the `locale` global, so you can access it in a decorator using the following snippet:
|
|
37
40
|
|
|
38
41
|
```typscript
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Renderer } from '@storybook/types';
|
|
1
|
+
import { ProjectAnnotations, Renderer } from '@storybook/types';
|
|
3
2
|
|
|
4
|
-
declare const preview:
|
|
5
|
-
decorators: ((story: _storybook_types.PartialStoryFn<Renderer, _storybook_types.Args>, context: _storybook_types.StoryContext<Renderer, _storybook_types.Args>) => unknown)[];
|
|
6
|
-
globals: {
|
|
7
|
-
locale: string;
|
|
8
|
-
locales: {};
|
|
9
|
-
};
|
|
10
|
-
};
|
|
3
|
+
declare const preview: ProjectAnnotations<Renderer>;
|
|
11
4
|
|
|
12
5
|
export { preview as default };
|
package/dist/preview.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var previewApi = require('@storybook/preview-api');
|
|
4
4
|
|
|
5
|
-
var e=(r,o)=>{let[
|
|
5
|
+
var e=(r,o)=>{let[c,n]=previewApi.useGlobals();return previewApi.useEffect(()=>{let{parameters:{locale:t}}=o;t&&n({locale:t});},[]),r(o)};var l={decorators:[e],globals:{locale:"",locales:{}}},f=l;
|
|
6
6
|
|
|
7
|
-
module.exports =
|
|
7
|
+
module.exports = f;
|
|
8
8
|
//# sourceMappingURL=out.js.map
|
|
9
9
|
//# sourceMappingURL=preview.js.map
|
package/dist/preview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/withLocale.ts","../src/preview.ts"],"names":["useEffect","useGlobals","withLocale","story","context","_","updateGlobals","locale","preview","preview_default"],"mappings":"AAAA,OAAQ,aAAAA,EAAW,cAAAC,MAAiB,yBAO7B,IAAMC,EAAa,CACtBC,EACAC,IACC,CACD,GAAM,CAACC,EAAGC,CAAa,EAAIL,EAAW,EAEtC,OAAAD,EAAU,IAAM,CACZ,GAAM,CACF,WAAY,CAAC,OAAAO,CAAM,CACvB,EAAIH,EAEAG,GACAD,EAAc,CAAC,OAAAC,CAAM,CAAC,CAE9B,EAAG,CAAC,CAAC,EAEEJ,EAAMC,CAAO,CACxB,ECrBA,IAAMI,
|
|
1
|
+
{"version":3,"sources":["../src/withLocale.ts","../src/preview.ts"],"names":["useEffect","useGlobals","withLocale","story","context","_","updateGlobals","locale","preview","preview_default"],"mappings":"AAAA,OAAQ,aAAAA,EAAW,cAAAC,MAAiB,yBAO7B,IAAMC,EAAa,CACtBC,EACAC,IACC,CACD,GAAM,CAACC,EAAGC,CAAa,EAAIL,EAAW,EAEtC,OAAAD,EAAU,IAAM,CACZ,GAAM,CACF,WAAY,CAAC,OAAAO,CAAM,CACvB,EAAIH,EAEAG,GACAD,EAAc,CAAC,OAAAC,CAAM,CAAC,CAE9B,EAAG,CAAC,CAAC,EAEEJ,EAAMC,CAAO,CACxB,ECrBA,IAAMI,EAAwC,CAC1C,WAAY,CAACN,CAAU,EACvB,QAAS,CACL,OAAQ,GACR,QAAS,CAAC,CACd,CACJ,EAEOO,EAAQD","sourcesContent":["import {useEffect, useGlobals} from '@storybook/preview-api';\nimport {\n PartialStoryFn as StoryFunction,\n Renderer,\n StoryContext,\n} from '@storybook/types';\n\nexport const withLocale = (\n story: StoryFunction<Renderer>,\n context: StoryContext\n) => {\n const [_, updateGlobals] = useGlobals();\n\n useEffect(() => {\n const {\n parameters: {locale},\n } = context;\n\n if (locale) {\n updateGlobals({locale});\n }\n }, []);\n\n return story(context);\n};\n","import type {Renderer, ProjectAnnotations} from '@storybook/types';\nimport {withLocale} from './withLocale';\n\nconst preview: ProjectAnnotations<Renderer> = {\n decorators: [withLocale],\n globals: {\n locale: '',\n locales: {},\n },\n};\n\nexport default preview;\n"]}
|
package/dist/preview.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useGlobals, useEffect } from '@storybook/preview-api';
|
|
2
2
|
|
|
3
|
-
var e=(r,o)=>{let[
|
|
3
|
+
var e=(r,o)=>{let[c,n]=useGlobals();return useEffect(()=>{let{parameters:{locale:t}}=o;t&&n({locale:t});},[]),r(o)};var l={decorators:[e],globals:{locale:"",locales:{}}},f=l;
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { f as default };
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
7
7
|
//# sourceMappingURL=preview.mjs.map
|
package/dist/preview.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/withLocale.ts","../src/preview.ts"],"names":["useEffect","useGlobals","withLocale","story","context","_","updateGlobals","locale","preview","preview_default"],"mappings":"AAAA,OAAQ,aAAAA,EAAW,cAAAC,MAAiB,yBAO7B,IAAMC,EAAa,CACtBC,EACAC,IACC,CACD,GAAM,CAACC,EAAGC,CAAa,EAAIL,EAAW,EAEtC,OAAAD,EAAU,IAAM,CACZ,GAAM,CACF,WAAY,CAAC,OAAAO,CAAM,CACvB,EAAIH,EAEAG,GACAD,EAAc,CAAC,OAAAC,CAAM,CAAC,CAE9B,EAAG,CAAC,CAAC,EAEEJ,EAAMC,CAAO,CACxB,ECrBA,IAAMI,
|
|
1
|
+
{"version":3,"sources":["../src/withLocale.ts","../src/preview.ts"],"names":["useEffect","useGlobals","withLocale","story","context","_","updateGlobals","locale","preview","preview_default"],"mappings":"AAAA,OAAQ,aAAAA,EAAW,cAAAC,MAAiB,yBAO7B,IAAMC,EAAa,CACtBC,EACAC,IACC,CACD,GAAM,CAACC,EAAGC,CAAa,EAAIL,EAAW,EAEtC,OAAAD,EAAU,IAAM,CACZ,GAAM,CACF,WAAY,CAAC,OAAAO,CAAM,CACvB,EAAIH,EAEAG,GACAD,EAAc,CAAC,OAAAC,CAAM,CAAC,CAE9B,EAAG,CAAC,CAAC,EAEEJ,EAAMC,CAAO,CACxB,ECrBA,IAAMI,EAAwC,CAC1C,WAAY,CAACN,CAAU,EACvB,QAAS,CACL,OAAQ,GACR,QAAS,CAAC,CACd,CACJ,EAEOO,EAAQD","sourcesContent":["import {useEffect, useGlobals} from '@storybook/preview-api';\nimport {\n PartialStoryFn as StoryFunction,\n Renderer,\n StoryContext,\n} from '@storybook/types';\n\nexport const withLocale = (\n story: StoryFunction<Renderer>,\n context: StoryContext\n) => {\n const [_, updateGlobals] = useGlobals();\n\n useEffect(() => {\n const {\n parameters: {locale},\n } = context;\n\n if (locale) {\n updateGlobals({locale});\n }\n }, []);\n\n return story(context);\n};\n","import type {Renderer, ProjectAnnotations} from '@storybook/types';\nimport {withLocale} from './withLocale';\n\nconst preview: ProjectAnnotations<Renderer> = {\n decorators: [withLocale],\n globals: {\n locale: '',\n locales: {},\n },\n};\n\nexport default preview;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-i18n",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Tool to set the locale in Storybook for i18n",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -58,33 +58,33 @@
|
|
|
58
58
|
"build-storybook": "storybook build"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@storybook/addon-essentials": "^7.0.
|
|
62
|
-
"@storybook/addon-interactions": "^7.0.
|
|
63
|
-
"@storybook/addon-links": "^7.0.
|
|
64
|
-
"@storybook/components": "^7.0.
|
|
65
|
-
"@storybook/manager-api": "^7.0.
|
|
66
|
-
"@storybook/preview-api": "^7.0.
|
|
67
|
-
"@storybook/react": "^7.0.
|
|
68
|
-
"@storybook/react-vite": "^7.0.
|
|
69
|
-
"@storybook/react-webpack5": "^7.0.
|
|
61
|
+
"@storybook/addon-essentials": "^7.0.18",
|
|
62
|
+
"@storybook/addon-interactions": "^7.0.18",
|
|
63
|
+
"@storybook/addon-links": "^7.0.18",
|
|
64
|
+
"@storybook/components": "^7.0.18",
|
|
65
|
+
"@storybook/manager-api": "^7.0.18",
|
|
66
|
+
"@storybook/preview-api": "^7.0.18",
|
|
67
|
+
"@storybook/react": "^7.0.18",
|
|
68
|
+
"@storybook/react-vite": "^7.0.18",
|
|
69
|
+
"@storybook/react-webpack5": "^7.0.18",
|
|
70
70
|
"@storybook/testing-library": "0.1.0",
|
|
71
|
-
"@storybook/types": "^7.0.
|
|
71
|
+
"@storybook/types": "^7.0.18",
|
|
72
72
|
"@types/node": "^18.15.0",
|
|
73
73
|
"@vitejs/plugin-react": "^3.1.0",
|
|
74
|
-
"auto": "^10.
|
|
74
|
+
"auto": "^10.46.0",
|
|
75
75
|
"boxen": "^5.0.1",
|
|
76
76
|
"concurrently": "^6.2.0",
|
|
77
77
|
"dedent": "^0.7.0",
|
|
78
|
-
"prettier": "^2.
|
|
78
|
+
"prettier": "^2.8.8",
|
|
79
79
|
"prompts": "^2.4.2",
|
|
80
80
|
"prop-types": "^15.8.1",
|
|
81
81
|
"react": "^18.0.0",
|
|
82
82
|
"react-dom": "^18.0.0",
|
|
83
83
|
"rimraf": "^3.0.2",
|
|
84
|
-
"storybook": "^7.0.
|
|
84
|
+
"storybook": "^7.0.18",
|
|
85
85
|
"tsup": "^6.6.3",
|
|
86
86
|
"typescript": "^4.9.5",
|
|
87
|
-
"vite": "^4.
|
|
87
|
+
"vite": "^4.3.9",
|
|
88
88
|
"zx": "^1.14.1"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|