@khanacademy/wonder-blocks-config 0.0.1 → 0.2.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +1 -3
- package/dist/components/wonder-blocks-config-provider.d.ts +14 -0
- package/dist/context/i18n-context.d.ts +28 -0
- package/dist/es/index.js +11 -0
- package/dist/es/strings.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +36 -0
- package/dist/strings.d.ts +22 -0
- package/dist/strings.js +8 -0
- package/package.json +28 -4
- package/index.js +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @khanacademy/wonder-blocks-config
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2e7983b: Export `defaultStringsEn` from the package entry point
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- e17fe69: Adds WonderBlocksConfigProvider for the initial set up for built in i18n support in Wonder Blocks components.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- fe03ec2: Sets up the wonder-blocks-config package
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Khan Academy
|
|
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 all
|
|
13
|
+
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 NONINFRINGEMENT. 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 THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-config
|
|
2
2
|
|
|
3
|
-
This package is
|
|
4
|
-
library. This will enable us to configure Trusted Publishing (which can't be
|
|
5
|
-
enabled until the package has been published at least once).
|
|
3
|
+
This package is for configuring Wonder Blocks.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { I18nConfig } from "../context/i18n-context";
|
|
3
|
+
type Props = React.PropsWithChildren<{
|
|
4
|
+
/**
|
|
5
|
+
* The strings for Wonder Blocks components to render, and the locale they
|
|
6
|
+
* are translated into.
|
|
7
|
+
*/
|
|
8
|
+
i18n: I18nConfig;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Configures the Wonder Blocks components rendered beneath it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function WonderBlocksConfigProvider({ children, i18n }: Props): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { WonderBlocksStrings } from "../strings";
|
|
3
|
+
/**
|
|
4
|
+
* The i18n configuration for Wonder Blocks components
|
|
5
|
+
*/
|
|
6
|
+
export type I18nConfig = {
|
|
7
|
+
/**
|
|
8
|
+
* The translated strings that Wonder Blocks components render.
|
|
9
|
+
*/
|
|
10
|
+
strings: WonderBlocksStrings;
|
|
11
|
+
/**
|
|
12
|
+
* The locale `strings` are translated into.
|
|
13
|
+
*/
|
|
14
|
+
locale: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Context for strings and locale information for Wonder Blocks components.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to English translations if not provided.
|
|
20
|
+
*/
|
|
21
|
+
export declare const WonderBlocksI18nContext: React.Context<I18nConfig>;
|
|
22
|
+
type Props = React.PropsWithChildren<I18nConfig>;
|
|
23
|
+
/**
|
|
24
|
+
* Provides i18n to Wonder Blocks components.
|
|
25
|
+
*/
|
|
26
|
+
export declare function WonderBlocksI18nContextProvider({ children, strings, locale, }: Props): React.JSX.Element;
|
|
27
|
+
export declare const useWonderBlocksI18n: () => I18nConfig;
|
|
28
|
+
export {};
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useContext, useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
const strings={iconAltOpensNewTab:{context:"Accessible name for an icon marking a link that opens in a new tab.",message:"(opens in a new tab)"}};const defaultStringsEn={iconAltOpensNewTab:strings.iconAltOpensNewTab.message};
|
|
6
|
+
|
|
7
|
+
const WonderBlocksI18nContext=React.createContext({strings:defaultStringsEn,locale:"en"});WonderBlocksI18nContext.displayName="WonderBlocksI18nContext";function WonderBlocksI18nContextProvider({children,strings,locale}){const value=useMemo(()=>({strings,locale}),[strings,locale]);return jsx(WonderBlocksI18nContext.Provider,{value:value,children:children})}const useWonderBlocksI18n=()=>useContext(WonderBlocksI18nContext);
|
|
8
|
+
|
|
9
|
+
function WonderBlocksConfigProvider({children,i18n}){const{strings,locale}=i18n;return jsx(WonderBlocksI18nContextProvider,{strings:strings,locale:locale,children:children})}
|
|
10
|
+
|
|
11
|
+
export { WonderBlocksConfigProvider, defaultStringsEn, useWonderBlocksI18n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WonderBlocksConfigProvider } from "./components/wonder-blocks-config-provider";
|
|
2
|
+
export { useWonderBlocksI18n } from "./context/i18n-context";
|
|
3
|
+
export type { I18nConfig } from "./context/i18n-context";
|
|
4
|
+
export { defaultStringsEn } from "./strings";
|
|
5
|
+
export type { WonderBlocksStrings } from "./strings";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
|
|
28
|
+
const strings={iconAltOpensNewTab:{context:"Accessible name for an icon marking a link that opens in a new tab.",message:"(opens in a new tab)"}};const defaultStringsEn={iconAltOpensNewTab:strings.iconAltOpensNewTab.message};
|
|
29
|
+
|
|
30
|
+
const WonderBlocksI18nContext=React__namespace.createContext({strings:defaultStringsEn,locale:"en"});WonderBlocksI18nContext.displayName="WonderBlocksI18nContext";function WonderBlocksI18nContextProvider({children,strings,locale}){const value=React.useMemo(()=>({strings,locale}),[strings,locale]);return jsxRuntime.jsx(WonderBlocksI18nContext.Provider,{value:value,children:children})}const useWonderBlocksI18n=()=>React.useContext(WonderBlocksI18nContext);
|
|
31
|
+
|
|
32
|
+
function WonderBlocksConfigProvider({children,i18n}){const{strings,locale}=i18n;return jsxRuntime.jsx(WonderBlocksI18nContextProvider,{strings:strings,locale:locale,children:children})}
|
|
33
|
+
|
|
34
|
+
exports.WonderBlocksConfigProvider = WonderBlocksConfigProvider;
|
|
35
|
+
exports.defaultStringsEn = defaultStringsEn;
|
|
36
|
+
exports.useWonderBlocksI18n = useWonderBlocksI18n;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The translated strings that are used to render Wonder Blocks.
|
|
3
|
+
*/
|
|
4
|
+
export type WonderBlocksStrings = {
|
|
5
|
+
iconAltOpensNewTab: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Untranslated strings used in Wonder Blocks. To be used by an external
|
|
9
|
+
* translator to produce translated strings, passed in as `WonderBlocksStrings`.
|
|
10
|
+
*
|
|
11
|
+
* !! Note: Ensure that all escape sequences are double-escaped. (e.g. `\\text` -> `\\\\text`)
|
|
12
|
+
*/
|
|
13
|
+
export declare const strings: {
|
|
14
|
+
iconAltOpensNewTab: {
|
|
15
|
+
context: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Default 'en' strings to use.
|
|
21
|
+
*/
|
|
22
|
+
export declare const defaultStringsEn: WonderBlocksStrings;
|
package/dist/strings.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const strings={iconAltOpensNewTab:{context:"Accessible name for an icon marking a link that opens in a new tab.",message:"(opens in a new tab)"}};const defaultStringsEn={iconAltOpensNewTab:strings.iconAltOpensNewTab.message};
|
|
6
|
+
|
|
7
|
+
exports.defaultStringsEn = defaultStringsEn;
|
|
8
|
+
exports.strings = strings;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-config",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Configuration for Wonder Blocks",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -14,6 +14,30 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/Khan/wonder-blocks/issues"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"module": "dist/es/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"source": "./src/index.ts",
|
|
24
|
+
"import": "./dist/es/index.js",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./strings": {
|
|
28
|
+
"types": "./dist/strings.d.ts",
|
|
29
|
+
"source": "./src/strings.ts",
|
|
30
|
+
"import": "./dist/es/strings.js",
|
|
31
|
+
"require": "./dist/strings.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": "18.2.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@khanacademy/wb-dev-build-settings": "3.3.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
42
|
+
}
|
|
19
43
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
throw new Error("Not implemented");
|