@just-web/react-intl 1.0.0 → 1.1.1
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/cjs/react_intl_gizmo.d.ts +12 -7
- package/cjs/react_intl_gizmo.d.ts.map +1 -1
- package/cjs/react_intl_gizmo.js +24 -15
- package/cjs/react_intl_gizmo.js.map +1 -1
- package/esm/react_intl_gizmo.d.ts +12 -7
- package/esm/react_intl_gizmo.d.ts.map +1 -1
- package/esm/react_intl_gizmo.js +24 -15
- package/esm/react_intl_gizmo.js.map +1 -1
- package/package.json +37 -5
- package/ts/react_intl_gizmo.tsx +28 -17
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { define } from '@just-web/app';
|
|
3
3
|
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
4
|
import { type IntlShape } from 'react-intl';
|
|
5
|
-
export
|
|
5
|
+
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
6
|
+
export declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
6
7
|
react: {
|
|
7
8
|
providers: {
|
|
8
|
-
register(Component:
|
|
9
|
-
children:
|
|
9
|
+
register(Component: React.JSXElementConstructor<{
|
|
10
|
+
children: React.ReactNode;
|
|
10
11
|
}>): void;
|
|
11
|
-
values(): IterableIterator<
|
|
12
|
-
children:
|
|
12
|
+
values(): IterableIterator<React.JSXElementConstructor<{
|
|
13
|
+
children: React.ReactNode;
|
|
13
14
|
}>>;
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
|
-
},
|
|
17
|
+
}, {
|
|
18
|
+
formatjs: {
|
|
19
|
+
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
20
|
+
};
|
|
21
|
+
}>, [{
|
|
17
22
|
react_intl: {
|
|
18
23
|
intl: IntlShape;
|
|
19
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;eAkB3B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
package/cjs/react_intl_gizmo.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactIntlGizmoFn = void 0;
|
|
4
|
-
const
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
const app_1 = require("@just-web/app");
|
|
6
6
|
const formatjs_1 = require("@just-web/formatjs");
|
|
7
7
|
const react_intl_1 = require("react-intl");
|
|
8
|
-
exports.reactIntlGizmoFn = (0, app_1.define)((options)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
8
|
+
exports.reactIntlGizmoFn = (0, app_1.define)(function (options) {
|
|
9
|
+
return {
|
|
10
|
+
static: app_1.define.require().optional(),
|
|
11
|
+
async create(ctx) {
|
|
12
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
react_intl: {
|
|
16
|
+
intl: formatjs.intl
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
() => ctx.react.providers.register(({ children }) => (react_1.default.createElement(react_intl_1.RawIntlProvider, { value: formatjs.intl }, children)))
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
async function getFormatjs(ctx, options) {
|
|
25
|
+
if (ctx.formatjs)
|
|
26
|
+
return ctx.formatjs;
|
|
27
|
+
if (!options)
|
|
28
|
+
throw new Error('options is required when there is no formatjs gizmo');
|
|
29
|
+
return (await (0, app_1.incubate)().with((0, formatjs_1.formatJSGizmoFn)(options)).create()).formatjs;
|
|
30
|
+
}
|
|
22
31
|
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";;;AAAA,iCAAyB;AACzB,uCAAgD;AAChD,iDAAmG;AAEnG,2CAA4D;AAI/C,QAAA,gBAAgB,GAAG,IAAA,YAAM,EAAC,UAAsB,OAAkC;IAC9F,OAAO;QACN,MAAM,EAAE,YAAM,CAAC,OAAO,EAAc,CAAC,QAAQ,EAAiB;QAC9D,KAAK,CAAC,MAAM,CAAC,GAAwC;YACpD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAChD,OAAO;gBACN;oBACC,UAAU,EAAE;wBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;qBAChC;iBACD;gBACD,GAAG,EAAE,CACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC9C,8BAAC,4BAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAAiB,IAAG,QAAQ,CAAmB,CAChF,CAAC;aACH,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA;AAIF,KAAK,UAAU,WAAW,CAAC,GAA2B,EAAE,OAA+C;IACtG,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACpF,OAAO,CAAC,MAAM,IAAA,cAAQ,GAAE,CAAC,IAAI,CAAC,IAAA,0BAAe,EAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAA;AAC3E,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { define } from '@just-web/app';
|
|
3
3
|
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
4
|
import { type IntlShape } from 'react-intl';
|
|
5
|
-
export
|
|
5
|
+
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>;
|
|
6
|
+
export declare const reactIntlGizmoFn: <T = string>(options?: ReactIntlGizmoOptions<T> | undefined) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
6
7
|
react: {
|
|
7
8
|
providers: {
|
|
8
|
-
register(Component:
|
|
9
|
-
children:
|
|
9
|
+
register(Component: React.JSXElementConstructor<{
|
|
10
|
+
children: React.ReactNode;
|
|
10
11
|
}>): void;
|
|
11
|
-
values(): IterableIterator<
|
|
12
|
-
children:
|
|
12
|
+
values(): IterableIterator<React.JSXElementConstructor<{
|
|
13
|
+
children: React.ReactNode;
|
|
13
14
|
}>>;
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
|
-
},
|
|
17
|
+
}, {
|
|
18
|
+
formatjs: {
|
|
19
|
+
intl: import("@just-web/formatjs").IntlShape<unknown>;
|
|
20
|
+
};
|
|
21
|
+
}>, [{
|
|
17
22
|
react_intl: {
|
|
18
23
|
intl: IntlShape;
|
|
19
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;eAkB3B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
package/esm/react_intl_gizmo.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { define, incubate } from '@just-web/app';
|
|
3
3
|
import { formatJSGizmoFn } from '@just-web/formatjs';
|
|
4
4
|
import { RawIntlProvider } from 'react-intl';
|
|
5
|
-
export const reactIntlGizmoFn = define((options)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
5
|
+
export const reactIntlGizmoFn = define(function (options) {
|
|
6
|
+
return {
|
|
7
|
+
static: define.require().optional(),
|
|
8
|
+
async create(ctx) {
|
|
9
|
+
const formatjs = await getFormatjs(ctx, options);
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
react_intl: {
|
|
13
|
+
intl: formatjs.intl
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
() => ctx.react.providers.register(({ children }) => (React.createElement(RawIntlProvider, { value: formatjs.intl }, children)))
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
async function getFormatjs(ctx, options) {
|
|
22
|
+
if (ctx.formatjs)
|
|
23
|
+
return ctx.formatjs;
|
|
24
|
+
if (!options)
|
|
25
|
+
throw new Error('options is required when there is no formatjs gizmo');
|
|
26
|
+
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs;
|
|
27
|
+
}
|
|
19
28
|
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAAiD,MAAM,oBAAoB,CAAA;AAEnG,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAA;AAI5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAsB,OAAkC;IAC9F,OAAO;QACN,MAAM,EAAE,MAAM,CAAC,OAAO,EAAc,CAAC,QAAQ,EAAiB;QAC9D,KAAK,CAAC,MAAM,CAAC,GAAwC;YACpD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAChD,OAAO;gBACN;oBACC,UAAU,EAAE;wBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;qBAChC;iBACD;gBACD,GAAG,EAAE,CACJ,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC9C,oBAAC,eAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAAiB,IAAG,QAAQ,CAAmB,CAChF,CAAC;aACH,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA;AAIF,KAAK,UAAU,WAAW,CAAC,GAA2B,EAAE,OAA+C;IACtG,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAA;IACrC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACpF,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAA;AAC3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@just-web/react-intl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "react-intl gizmo for just-web applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"just-web",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"esm",
|
|
56
56
|
"testing",
|
|
57
57
|
"ts",
|
|
58
|
-
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*"
|
|
58
|
+
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*",
|
|
59
|
+
"!**/*.stories.*"
|
|
59
60
|
],
|
|
60
61
|
"dependencies": {
|
|
61
62
|
"@just-web/formatjs": "^1.0.2",
|
|
@@ -66,8 +67,33 @@
|
|
|
66
67
|
"@repobuddy/jest": "^3.3.0",
|
|
67
68
|
"@repobuddy/typescript": "^1.2.0",
|
|
68
69
|
"@size-limit/preset-small-lib": "~8.2.0",
|
|
70
|
+
"@storybook/addon-actions": "^7.0.6",
|
|
71
|
+
"@storybook/addon-backgrounds": "^7.0.6",
|
|
72
|
+
"@storybook/addon-console": "~2.0.0",
|
|
73
|
+
"@storybook/addon-docs": "^7.0.6",
|
|
74
|
+
"@storybook/addon-essentials": "^7.0.6",
|
|
75
|
+
"@storybook/addon-interactions": "^7.0.6",
|
|
76
|
+
"@storybook/addon-links": "^7.0.6",
|
|
77
|
+
"@storybook/addon-measure": "^7.0.6",
|
|
78
|
+
"@storybook/addon-outline": "^7.0.6",
|
|
79
|
+
"@storybook/addon-storysource": "^7.0.6",
|
|
80
|
+
"@storybook/addon-styling": "^1.0.1",
|
|
81
|
+
"@storybook/addons": "^7.0.6",
|
|
82
|
+
"@storybook/channel-postmessage": "^7.0.6",
|
|
83
|
+
"@storybook/channel-websocket": "^7.0.6",
|
|
84
|
+
"@storybook/client-api": "^7.0.6",
|
|
85
|
+
"@storybook/preview-web": "^7.0.6",
|
|
86
|
+
"@storybook/react": "^7.0.6",
|
|
87
|
+
"@storybook/react-vite": "7.1.0",
|
|
88
|
+
"@storybook/test-runner": "^0.11.0",
|
|
89
|
+
"@storybook/testing-library": "^0.2.0",
|
|
69
90
|
"@types/jest": "^29.5.1",
|
|
70
|
-
"@types/react": "^
|
|
91
|
+
"@types/react": "^18.0.0",
|
|
92
|
+
"@types/react-dom": "^18.0.9",
|
|
93
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
94
|
+
"@types/testing-library__jest-dom": "~5.14.5",
|
|
95
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
96
|
+
"assertron": "^11.0.1",
|
|
71
97
|
"cross-env": "^7.0.3",
|
|
72
98
|
"depcheck": "~1.4.3",
|
|
73
99
|
"jest": "^29.5.0",
|
|
@@ -75,15 +101,20 @@
|
|
|
75
101
|
"jest-watch-toggle-config-2": "^2.1.0",
|
|
76
102
|
"jest-watch-typeahead": "^2.2.2",
|
|
77
103
|
"npm-run-all": "^4.1.5",
|
|
78
|
-
"react": "^
|
|
104
|
+
"react": "^18.0.0",
|
|
105
|
+
"react-dom": "^18.0.0",
|
|
79
106
|
"repobuddy": "^1.0.1",
|
|
80
107
|
"rimraf": "~5.0.0",
|
|
108
|
+
"rollup-plugin-node-externals": "^6.0.0",
|
|
81
109
|
"size-limit": "~8.2.0",
|
|
110
|
+
"storybook": "7.1.0",
|
|
111
|
+
"storybook-dark-mode": "~3.0.0",
|
|
82
112
|
"ts-jest": "^29.1.0",
|
|
83
113
|
"tslib": "^2.5.0",
|
|
84
114
|
"type-plus": "^7.0.1",
|
|
85
115
|
"typescript": "^5.0.4",
|
|
86
|
-
"
|
|
116
|
+
"vite": "^4.3.1",
|
|
117
|
+
"@just-web/react": "^9.0.4"
|
|
87
118
|
},
|
|
88
119
|
"peerDependencies": {
|
|
89
120
|
"@just-web/react": "^9.0.0",
|
|
@@ -99,6 +130,7 @@
|
|
|
99
130
|
"depcheck": "depcheck",
|
|
100
131
|
"lint": "cross-env TIMING=1 eslint --ext=ts,tsx,js,yaml,yml .",
|
|
101
132
|
"nuke": "rimraf node_modules",
|
|
133
|
+
"sb": "storybook dev -p 6008",
|
|
102
134
|
"size": "size-limit",
|
|
103
135
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
104
136
|
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch",
|
package/ts/react_intl_gizmo.tsx
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
1
2
|
import { define, incubate } from '@just-web/app'
|
|
2
|
-
import { formatJSGizmoFn, type FormatJSGizmoOptions } from '@just-web/formatjs'
|
|
3
|
+
import { formatJSGizmoFn, type FormatJSGizmo, type FormatJSGizmoOptions } from '@just-web/formatjs'
|
|
3
4
|
import type { ReactGizmo } from '@just-web/react'
|
|
4
5
|
import { RawIntlProvider, type IntlShape } from 'react-intl'
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
20
|
-
|
|
7
|
+
export type ReactIntlGizmoOptions<T = string> = FormatJSGizmoOptions<T>
|
|
8
|
+
|
|
9
|
+
export const reactIntlGizmoFn = define(function <T = string>(options?: ReactIntlGizmoOptions<T>) {
|
|
10
|
+
return {
|
|
11
|
+
static: define.require<ReactGizmo>().optional<FormatJSGizmo>(),
|
|
12
|
+
async create(ctx: ReactGizmo & Partial<FormatJSGizmo>) {
|
|
13
|
+
const formatjs = await getFormatjs(ctx, options)
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
react_intl: {
|
|
17
|
+
intl: formatjs.intl as IntlShape
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
() =>
|
|
21
|
+
ctx.react.providers.register(({ children }) => (
|
|
22
|
+
<RawIntlProvider value={formatjs.intl as IntlShape}>{children}</RawIntlProvider>
|
|
23
|
+
))
|
|
24
|
+
]
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
|
-
})
|
|
27
|
+
})
|
|
23
28
|
|
|
24
29
|
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>
|
|
30
|
+
|
|
31
|
+
async function getFormatjs(ctx: Partial<FormatJSGizmo>, options: ReactIntlGizmoOptions<any> | undefined) {
|
|
32
|
+
if (ctx.formatjs) return ctx.formatjs
|
|
33
|
+
if (!options) throw new Error('options is required when there is no formatjs gizmo')
|
|
34
|
+
return (await incubate().with(formatJSGizmoFn(options)).create()).formatjs
|
|
35
|
+
}
|