@just-web/react-intl 1.0.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/LICENSE +21 -0
- package/README.md +62 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +19 -0
- package/cjs/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/react-intl.d.ts +2 -0
- package/cjs/react-intl.d.ts.map +1 -0
- package/cjs/react-intl.js +18 -0
- package/cjs/react-intl.js.map +1 -0
- package/cjs/react_intl_gizmo.d.ts +22 -0
- package/cjs/react_intl_gizmo.d.ts.map +1 -0
- package/cjs/react_intl_gizmo.js +22 -0
- package/cjs/react_intl_gizmo.js.map +1 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/react-intl.d.ts +2 -0
- package/esm/react-intl.d.ts.map +1 -0
- package/esm/react-intl.js +2 -0
- package/esm/react-intl.js.map +1 -0
- package/esm/react_intl_gizmo.d.ts +22 -0
- package/esm/react_intl_gizmo.d.ts.map +1 -0
- package/esm/react_intl_gizmo.js +19 -0
- package/esm/react_intl_gizmo.js.map +1 -0
- package/package.json +108 -0
- package/ts/index.ts +2 -0
- package/ts/react-intl.ts +1 -0
- package/ts/react_intl_gizmo.tsx +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2022 Homa Wong (unional) (homawong@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @just-web/react-intl
|
|
2
|
+
|
|
3
|
+
[![NPM version][npm-image]][npm-url]
|
|
4
|
+
[![NPM downloads][downloads-image]][downloads-url]
|
|
5
|
+
|
|
6
|
+
[@just-web/react-intl] provides [react-intl] support for [@just-web] applications.
|
|
7
|
+
|
|
8
|
+
It re-exports [react-intl] so that you can access all functionality of [react-intl] directly.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
[@just-web/react-intl] needs [@just-web/react](../react/README.md)
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
# npm
|
|
16
|
+
npm install @just-web/react-intl @just-web/react
|
|
17
|
+
|
|
18
|
+
# yarn
|
|
19
|
+
yarn add @just-web/react-intl @just-web/react
|
|
20
|
+
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm install @just-web/react-intl @just-web/react
|
|
23
|
+
|
|
24
|
+
#rush
|
|
25
|
+
rush add -p @just-web/react-intl @just-web/react
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { justApp } from '@just-web/app'
|
|
32
|
+
import { reactGizmo } from '@just-web/react'
|
|
33
|
+
import { reactIntlGizmoFn } from '@just-web/react-intl'
|
|
34
|
+
|
|
35
|
+
const app = await justApp({ name: 'your-awesome-app' })
|
|
36
|
+
.with(reactGizmo)
|
|
37
|
+
.with(reactIntlGizmoFn({ config: { locale: 'en', messages: {} } }))
|
|
38
|
+
.create()
|
|
39
|
+
|
|
40
|
+
app.react_intl.intl.formatMessage({ defaultMessage: 'hello world' })
|
|
41
|
+
|
|
42
|
+
function App() {
|
|
43
|
+
<JustAppProvider app={app}><Component/></JustAppProvider>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function Component() {
|
|
47
|
+
const intl = useIntl()
|
|
48
|
+
// or
|
|
49
|
+
// const app = useJustAppContext()
|
|
50
|
+
// const intl = app.react_intl.intl
|
|
51
|
+
|
|
52
|
+
return <div>{intl.formatMessage({ defaultMessage: 'hello world' })}</div>
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
[@just-web]: https://github.com/justland/just-web
|
|
57
|
+
[@just-web/react-intl]: https://github.com/justland/just-web/tree/main/plugins/react-intl
|
|
58
|
+
[downloads-image]: https://img.shields.io/npm/dm/@just-web/react-intl.svg?style=flat
|
|
59
|
+
[downloads-url]: https://npmjs.org/package/@just-web/react-intl
|
|
60
|
+
[npm-image]: https://img.shields.io/npm/v/@just-web/react-intl.svg?style=flat
|
|
61
|
+
[npm-url]: https://npmjs.org/package/@just-web/react-intl
|
|
62
|
+
[react-intl]: https://formatjs.io/
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./react_intl_gizmo.js"), exports);
|
|
18
|
+
__exportStar(require("./react-intl.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,kDAA+B"}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-intl.d.ts","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("react-intl"), exports);
|
|
18
|
+
//# sourceMappingURL=react-intl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-intl.js","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { define } from '@just-web/app';
|
|
3
|
+
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
|
+
import { type IntlShape } from 'react-intl';
|
|
5
|
+
export declare const reactIntlGizmoFn: (options: FormatJSGizmoOptions<string>) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
6
|
+
react: {
|
|
7
|
+
providers: {
|
|
8
|
+
register(Component: import("react").JSXElementConstructor<{
|
|
9
|
+
children: import("react").ReactNode;
|
|
10
|
+
}>): void;
|
|
11
|
+
values(): IterableIterator<import("react").JSXElementConstructor<{
|
|
12
|
+
children: import("react").ReactNode;
|
|
13
|
+
}>>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}, unknown>, [{
|
|
17
|
+
react_intl: {
|
|
18
|
+
intl: IntlShape;
|
|
19
|
+
};
|
|
20
|
+
}, () => void]>;
|
|
21
|
+
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
22
|
+
//# sourceMappingURL=react_intl_gizmo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;eAgB1B,CAAA;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactIntlGizmoFn = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const app_1 = require("@just-web/app");
|
|
6
|
+
const formatjs_1 = require("@just-web/formatjs");
|
|
7
|
+
const react_intl_1 = require("react-intl");
|
|
8
|
+
exports.reactIntlGizmoFn = (0, app_1.define)((options) => ({
|
|
9
|
+
static: app_1.define.require(),
|
|
10
|
+
async create({ react }) {
|
|
11
|
+
const { formatjs } = await (0, app_1.incubate)().with((0, formatjs_1.formatJSGizmoFn)(options)).create();
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
react_intl: {
|
|
15
|
+
intl: formatjs.intl
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
() => react.providers.register(({ children }) => ((0, jsx_runtime_1.jsx)(react_intl_1.RawIntlProvider, { value: formatjs.intl, children: children })))
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";;;;AAAA,uCAAgD;AAChD,iDAA+E;AAE/E,2CAA4D;AAE/C,QAAA,gBAAgB,GAAG,IAAA,YAAM,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,YAAM,CAAC,OAAO,EAAc;IACpC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,cAAQ,GAAE,CAAC,IAAI,CAAC,IAAA,0BAAe,EAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAC7E,OAAO;YACN;gBACC,UAAU,EAAE;oBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;iBAChC;aACD;YACD,GAAG,EAAE,CACJ,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC1C,uBAAC,4BAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAA4B,YAAG,QAAQ,GAAmB,CAC3F,CAAC;SACH,CAAA;IACF,CAAC;CACD,CAAC,CAAC,CAAA"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-intl.d.ts","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-intl.js","sourceRoot":"","sources":["../ts/react-intl.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { define } from '@just-web/app';
|
|
3
|
+
import { type FormatJSGizmoOptions } from '@just-web/formatjs';
|
|
4
|
+
import { type IntlShape } from 'react-intl';
|
|
5
|
+
export declare const reactIntlGizmoFn: (options: FormatJSGizmoOptions<string>) => import("@just-web/app").GizmoStatic<import("@just-web/app").DepBuilder<{
|
|
6
|
+
react: {
|
|
7
|
+
providers: {
|
|
8
|
+
register(Component: import("react").JSXElementConstructor<{
|
|
9
|
+
children: import("react").ReactNode;
|
|
10
|
+
}>): void;
|
|
11
|
+
values(): IterableIterator<import("react").JSXElementConstructor<{
|
|
12
|
+
children: import("react").ReactNode;
|
|
13
|
+
}>>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}, unknown>, [{
|
|
17
|
+
react_intl: {
|
|
18
|
+
intl: IntlShape;
|
|
19
|
+
};
|
|
20
|
+
}, () => void]>;
|
|
21
|
+
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>;
|
|
22
|
+
//# sourceMappingURL=react_intl_gizmo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.d.ts","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AAChD,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAE5D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;eAgB1B,CAAA;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { define, incubate } from '@just-web/app';
|
|
3
|
+
import { formatJSGizmoFn } from '@just-web/formatjs';
|
|
4
|
+
import { RawIntlProvider } from 'react-intl';
|
|
5
|
+
export const reactIntlGizmoFn = define((options) => ({
|
|
6
|
+
static: define.require(),
|
|
7
|
+
async create({ react }) {
|
|
8
|
+
const { formatjs } = await incubate().with(formatJSGizmoFn(options)).create();
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
react_intl: {
|
|
12
|
+
intl: formatjs.intl
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
() => react.providers.register(({ children }) => (_jsx(RawIntlProvider, { value: formatjs.intl, children: children })))
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
//# sourceMappingURL=react_intl_gizmo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react_intl_gizmo.js","sourceRoot":"","sources":["../ts/react_intl_gizmo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAA6B,MAAM,oBAAoB,CAAA;AAE/E,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAA;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,MAAM,CAAC,OAAO,EAAc;IACpC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QAC7E,OAAO;YACN;gBACC,UAAU,EAAE;oBACX,IAAI,EAAE,QAAQ,CAAC,IAAiB;iBAChC;aACD;YACD,GAAG,EAAE,CACJ,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC1C,KAAC,eAAe,IAAC,KAAK,EAAE,QAAQ,CAAC,IAA4B,YAAG,QAAQ,GAAmB,CAC3F,CAAC;SACH,CAAA;IACF,CAAC;CACD,CAAC,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@just-web/react-intl",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "react-intl gizmo for just-web applications",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"just-web",
|
|
7
|
+
"react-intl"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/justland/just-web-react/tree/main/libraries/react-intl",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/justland/just-web-react/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/justland/just-web-react.git",
|
|
16
|
+
"directory": "libraries/react-intl"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Homa Wong (unional)",
|
|
21
|
+
"email": "homawong@gmail.com",
|
|
22
|
+
"url": "https://github.com/unional"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./esm/index.d.ts",
|
|
30
|
+
"default": "./esm/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./cjs/index.d.ts",
|
|
34
|
+
"default": "./cjs/index.js"
|
|
35
|
+
},
|
|
36
|
+
"default": "./esm/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./testing": {
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./esm/testing/index.d.ts",
|
|
41
|
+
"default": "./esm/testing/index.js"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./cjs/testing/index.d.ts",
|
|
45
|
+
"require": "./cjs/testing/index.js"
|
|
46
|
+
},
|
|
47
|
+
"default": "./esm/testing/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"main": "./cjs/index.js",
|
|
51
|
+
"module": "./esm/index.js",
|
|
52
|
+
"types": "./cjs/index.d.ts",
|
|
53
|
+
"files": [
|
|
54
|
+
"cjs",
|
|
55
|
+
"esm",
|
|
56
|
+
"testing",
|
|
57
|
+
"ts",
|
|
58
|
+
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*"
|
|
59
|
+
],
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@just-web/formatjs": "^1.0.2",
|
|
62
|
+
"react-intl": "^6.4.2"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@just-web/app": "^7.1.5",
|
|
66
|
+
"@repobuddy/jest": "^3.3.0",
|
|
67
|
+
"@repobuddy/typescript": "^1.2.0",
|
|
68
|
+
"@size-limit/preset-small-lib": "~8.2.0",
|
|
69
|
+
"@types/jest": "^29.5.1",
|
|
70
|
+
"@types/react": "^17.0.0",
|
|
71
|
+
"cross-env": "^7.0.3",
|
|
72
|
+
"depcheck": "~1.4.3",
|
|
73
|
+
"jest": "^29.5.0",
|
|
74
|
+
"jest-watch-suspend": "^1.1.2",
|
|
75
|
+
"jest-watch-toggle-config-2": "^2.1.0",
|
|
76
|
+
"jest-watch-typeahead": "^2.2.2",
|
|
77
|
+
"npm-run-all": "^4.1.5",
|
|
78
|
+
"react": "^17.0.0",
|
|
79
|
+
"repobuddy": "^1.0.1",
|
|
80
|
+
"rimraf": "~5.0.0",
|
|
81
|
+
"size-limit": "~8.2.0",
|
|
82
|
+
"ts-jest": "^29.1.0",
|
|
83
|
+
"tslib": "^2.5.0",
|
|
84
|
+
"type-plus": "^7.0.1",
|
|
85
|
+
"typescript": "^5.0.4",
|
|
86
|
+
"@just-web/react": "^9.0.2"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"@just-web/react": "^9.0.0",
|
|
90
|
+
"react": "^16 || ^17 || ^18"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "run-p build:cjs build:esm build:tslib",
|
|
94
|
+
"build:cjs": "buddy ts build cjs",
|
|
95
|
+
"build:esm": "tsc",
|
|
96
|
+
"build:tslib": "buddy ts build tslib",
|
|
97
|
+
"clean": "rimraf cjs esm coverage tslib --glob *.tsbuildinfo",
|
|
98
|
+
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --coverage",
|
|
99
|
+
"depcheck": "depcheck",
|
|
100
|
+
"lint": "cross-env TIMING=1 eslint --ext=ts,tsx,js,yaml,yml .",
|
|
101
|
+
"nuke": "rimraf node_modules",
|
|
102
|
+
"size": "size-limit",
|
|
103
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
104
|
+
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch",
|
|
105
|
+
"w": "pnpm test:watch",
|
|
106
|
+
"verify": "npm-run-all -p build lint coverage depcheck -p size"
|
|
107
|
+
}
|
|
108
|
+
}
|
package/ts/index.ts
ADDED
package/ts/react-intl.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'react-intl'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { define, incubate } from '@just-web/app'
|
|
2
|
+
import { formatJSGizmoFn, type FormatJSGizmoOptions } from '@just-web/formatjs'
|
|
3
|
+
import type { ReactGizmo } from '@just-web/react'
|
|
4
|
+
import { RawIntlProvider, type IntlShape } from 'react-intl'
|
|
5
|
+
|
|
6
|
+
export const reactIntlGizmoFn = define((options: FormatJSGizmoOptions) => ({
|
|
7
|
+
static: define.require<ReactGizmo>(),
|
|
8
|
+
async create({ react }) {
|
|
9
|
+
const { formatjs } = await incubate().with(formatJSGizmoFn(options)).create()
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
react_intl: {
|
|
13
|
+
intl: formatjs.intl as IntlShape
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
() =>
|
|
17
|
+
react.providers.register(({ children }) => (
|
|
18
|
+
<RawIntlProvider value={formatjs.intl as unknown as IntlShape}>{children}</RawIntlProvider>
|
|
19
|
+
))
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
export type ReactIntlGizmo = define.Infer<typeof reactIntlGizmoFn>
|