@mindlogic-ai/logician-ui 5.0.0-alpha.7 → 5.0.0-alpha.9
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/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +10 -2
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.mjs +10 -2
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Form/FormSection/CollapsibleFormSection.js +1 -0
- package/dist/components/Form/FormSection/CollapsibleFormSection.js.map +1 -1
- package/dist/components/Form/FormSection/CollapsibleFormSection.mjs +1 -0
- package/dist/components/Form/FormSection/CollapsibleFormSection.mjs.map +1 -1
- package/dist/hooks/useLanguage.d.ts +5 -0
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useLanguage.js +7 -3
- package/dist/hooks/useLanguage.js.map +1 -1
- package/dist/hooks/useLanguage.mjs +7 -4
- package/dist/hooks/useLanguage.mjs.map +1 -1
- package/dist/hooks/useTranslate.d.ts.map +1 -1
- package/dist/hooks/useTranslate.js +8 -5
- package/dist/hooks/useTranslate.js.map +1 -1
- package/dist/hooks/useTranslate.mjs +8 -5
- package/dist/hooks/useTranslate.mjs.map +1 -1
- package/dist/translations/Defaults.translations.json.js +9 -0
- package/dist/translations/Defaults.translations.json.js.map +1 -1
- package/dist/translations/Defaults.translations.json.mjs +9 -1
- package/dist/translations/Defaults.translations.json.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/BottomSheet/BottomSheet.test.tsx +2 -1
- package/src/components/Button/Button.tsx +15 -2
- package/src/hooks/useLanguage.ts +8 -3
- package/src/hooks/useTranslate.test.tsx +46 -0
- package/src/hooks/useTranslate.ts +7 -5
- package/src/translations/Defaults.translations.json +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAA8B,MAAM,gBAAgB,CAAC;AA0K5E,eAAO,MAAM,MAAM,gEAA0C,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var react = require('@chakra-ui/react');
|
|
7
|
+
var useTranslate = require('../../hooks/useTranslate.js');
|
|
7
8
|
var focusRing = require('../../utils/focusRing.js');
|
|
8
9
|
var mergeCss = require('../../utils/mergeCss.js');
|
|
9
10
|
var polymorphic = require('../../types/polymorphic.js');
|
|
@@ -31,7 +32,14 @@ const ButtonImpl = React.forwardRef(({ variant: variantProp, isDestructive: isDe
|
|
|
31
32
|
// 4.x callers (untyped JS, `as any`) can still hand us `colorPalette` and
|
|
32
33
|
// an old variant name. Strip it so it never reaches Chakra's own recipe,
|
|
33
34
|
// and map the pair onto a 5.0 role — see `Button.legacy.ts`.
|
|
34
|
-
const { colorPalette: legacyPalette, ...rest } = restWithLegacy;
|
|
35
|
+
const { colorPalette: legacyPalette, loadingText: loadingTextProp, ...rest } = restWithLegacy;
|
|
36
|
+
// A busy button says what it is doing: 처리 중 unless the call site names
|
|
37
|
+
// the verb (저장 중). `loadingText={null}` opts out — spinner only, and the
|
|
38
|
+
// button keeps its width.
|
|
39
|
+
const translate = useTranslate.useTranslate();
|
|
40
|
+
const loadingText = loadingTextProp === undefined
|
|
41
|
+
? translate('processing')
|
|
42
|
+
: (loadingTextProp ?? undefined);
|
|
35
43
|
let variant = variantProp ?? 'subtle';
|
|
36
44
|
let isDestructive = isDestructiveProp;
|
|
37
45
|
if (Button_legacy.isLegacyButtonProps('button', legacyPalette, variantProp)) {
|
|
@@ -104,7 +112,7 @@ const ButtonImpl = React.forwardRef(({ variant: variantProp, isDestructive: isDe
|
|
|
104
112
|
// Two clocks on one element — the press is faster than the colour
|
|
105
113
|
// change — so the shorthand is written out and only the reduced-motion
|
|
106
114
|
// guard comes from the vocabulary.
|
|
107
|
-
transition: Button_styles.buttonTransition, animationStyle: "composite", ref: ref, "data-variant": variant, "data-destructive": isDestructive || undefined, ...rest,
|
|
115
|
+
transition: Button_styles.buttonTransition, animationStyle: "composite", ref: ref, "data-variant": variant, "data-destructive": isDestructive || undefined, loadingText: loadingText, ...rest,
|
|
108
116
|
// The `action` icon rule lives in `css` (a nested selector cannot be a
|
|
109
117
|
// style prop); merged so a call site's `css` adds to it.
|
|
110
118
|
css: mergeCss.mergeCss(base.css, cssProp), children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":[null],"names":["forwardRef","isLegacyButtonProps","resolveLegacyButtonVariant","warnLegacyButtonProps","getButtonStyles","_jsx","ChakraButton","mergeCss","focusRing","buttonTransition","polymorphic"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":[null],"names":["forwardRef","useTranslate","isLegacyButtonProps","resolveLegacyButtonVariant","warnLegacyButtonProps","getButtonStyles","_jsx","ChakraButton","mergeCss","focusRing","buttonTransition","polymorphic"],"mappings":";;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;AAgBG;AACH,MAAM,UAAU,GAAGA,gBAAU,CAC3B,CACE,EACE,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,iBAAiB,GAAG,KAAK,EACxC,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,YAAY,EACvB,GAAG,EAAE,OAAO,EACZ,GAAG,cAAc,EAClB,EACD,GAAG,KACD;;;;AAIF,IAAA,MAAM,EACJ,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,eAAe,EAC5B,GAAG,IAAI,EACR,GAAG,cAAoE;;;;A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AC,KAAK,EAChB,UAAU,EAAC,UAAU,EACrB,IAAI,EAAE,IAAI,EACV,YAAY,EAAC,IAAI,EAAA,GACb,MAAM;;;;;;;;AAQV,QAAA,MAAM,EAAEC,iBAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,OAAO,EAAEA,iBAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;;;;;;AAM7C,QAAA,SAAS,EAAEA,iBAAQ,CACjB,WAAW,IAAI,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,SAAS;;;QAGpD,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,GAAG,UAAU,GAAG,aAAa,EAAE,EACrD,YAAY,CACb,KACGC,mBAAS,EACb,MAAM,EAAC,SAAS;;;AAGhB,QAAA,KAAK,EAAC,GAAG;;;;QAIT,UAAU,EAAEC,8BAAgB,EAC5B,cAAc,EAAC,WAAW,EAC1B,GAAG,EAAE,GAAG,kBACM,OAAO,EAAA,kBAAA,EACH,aAAa,IAAI,SAAS,EAC5C,WAAW,EAAE,WAAW,EAAA,GACpB,IAAI;;;AAGR,QAAA,GAAG,EAAEF,iBAAQ,CAAC,IAAI,CAAC,GAAoC,EAAE,OAAO,CAAC,EAAA,QAAA,EAEhE,QAAQ,EAAA,CACI;AAEnB,CAAC,CACF;AAED;;;;;;AAMG;AACH,UAAU,CAAC,WAAW,GAAG,QAAQ;MAEpB,MAAM,GAAGG,uBAAW,CAAiB,UAAU;;;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { Button as Button$1 } from '@chakra-ui/react';
|
|
5
|
+
import { useTranslate } from '../../hooks/useTranslate.mjs';
|
|
5
6
|
import { focusRing } from '../../utils/focusRing.mjs';
|
|
6
7
|
import { mergeCss } from '../../utils/mergeCss.mjs';
|
|
7
8
|
import { polymorphic } from '../../types/polymorphic.mjs';
|
|
@@ -29,7 +30,14 @@ const ButtonImpl = forwardRef(({ variant: variantProp, isDestructive: isDestruct
|
|
|
29
30
|
// 4.x callers (untyped JS, `as any`) can still hand us `colorPalette` and
|
|
30
31
|
// an old variant name. Strip it so it never reaches Chakra's own recipe,
|
|
31
32
|
// and map the pair onto a 5.0 role — see `Button.legacy.ts`.
|
|
32
|
-
const { colorPalette: legacyPalette, ...rest } = restWithLegacy;
|
|
33
|
+
const { colorPalette: legacyPalette, loadingText: loadingTextProp, ...rest } = restWithLegacy;
|
|
34
|
+
// A busy button says what it is doing: 처리 중 unless the call site names
|
|
35
|
+
// the verb (저장 중). `loadingText={null}` opts out — spinner only, and the
|
|
36
|
+
// button keeps its width.
|
|
37
|
+
const translate = useTranslate();
|
|
38
|
+
const loadingText = loadingTextProp === undefined
|
|
39
|
+
? translate('processing')
|
|
40
|
+
: (loadingTextProp ?? undefined);
|
|
33
41
|
let variant = variantProp ?? 'subtle';
|
|
34
42
|
let isDestructive = isDestructiveProp;
|
|
35
43
|
if (isLegacyButtonProps('button', legacyPalette, variantProp)) {
|
|
@@ -102,7 +110,7 @@ const ButtonImpl = forwardRef(({ variant: variantProp, isDestructive: isDestruct
|
|
|
102
110
|
// Two clocks on one element — the press is faster than the colour
|
|
103
111
|
// change — so the shorthand is written out and only the reduced-motion
|
|
104
112
|
// guard comes from the vocabulary.
|
|
105
|
-
transition: buttonTransition, animationStyle: "composite", ref: ref, "data-variant": variant, "data-destructive": isDestructive || undefined, ...rest,
|
|
113
|
+
transition: buttonTransition, animationStyle: "composite", ref: ref, "data-variant": variant, "data-destructive": isDestructive || undefined, loadingText: loadingText, ...rest,
|
|
106
114
|
// The `action` icon rule lives in `css` (a nested selector cannot be a
|
|
107
115
|
// style prop); merged so a call site's `css` adds to it.
|
|
108
116
|
css: mergeCss(base.css, cssProp), children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":[null],"names":["_jsx","ChakraButton"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":[null],"names":["_jsx","ChakraButton"],"mappings":";;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;AAgBG;AACH,MAAM,UAAU,GAAG,UAAU,CAC3B,CACE,EACE,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,iBAAiB,GAAG,KAAK,EACxC,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,YAAY,EACvB,GAAG,EAAE,OAAO,EACZ,GAAG,cAAc,EAClB,EACD,GAAG,KACD;;;;AAIF,IAAA,MAAM,EACJ,YAAY,EAAE,aAAa,EAC3B,WAAW,EAAE,eAAe,EAC5B,GAAG,IAAI,EACR,GAAG,cAAoE;;;;AAIxE,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;AAChC,IAAA,MAAM,WAAW,GACf,eAAe,KAAK;AAClB,UAAE,SAAS,CAAC,YAAY;AACxB,WAAG,eAAe,IAAI,SAAS,CAAC;AAEpC,IAAA,IAAI,OAAO,GAAkB,WAAW,IAAI,QAAQ;IACpD,IAAI,aAAa,GAAG,iBAAiB;IACrC,IAAI,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE;QAC7D,MAAM,QAAQ,GAAG,0BAA0B,CACzC,QAAQ,EACR,aAAa,EACb,WAAW,CACZ;QACD,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,CAAC;AACrE,QAAA,OAAO,GAAG,QAAQ,CAAC,OAAO;AAC1B,QAAA,aAAa,GAAG,aAAa,IAAI,QAAQ,CAAC,aAAa;IACzD;IAEA,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC;;;IAIpD,MAAM,MAAM,GAAG;AACb,UAAE;AACE,YAAA,GAAG,I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;AAGR,QAAA,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAoC,EAAE,OAAO,CAAC,EAAA,QAAA,EAEhE,QAAQ,EAAA,CACI;AAEnB,CAAC,CACF;AAED;;;;;;AAMG;AACH,UAAU,CAAC,WAAW,GAAG,QAAQ;MAEpB,MAAM,GAAG,WAAW,CAAiB,UAAU;;;;"}
|
|
@@ -34,6 +34,7 @@ require('../../Badge/Badge.js');
|
|
|
34
34
|
require('../../Workflow/canvas/NodeShell/NodeShell.styles.js');
|
|
35
35
|
require('../../Workflow/graphObserver.js');
|
|
36
36
|
require('@dagrejs/dagre');
|
|
37
|
+
require('../../../hooks/useLanguage.js');
|
|
37
38
|
require('../../Workflow/canvas/Canvas/Canvas.js');
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleFormSection.js","sources":["../../../../src/components/Form/FormSection/CollapsibleFormSection.tsx"],"sourcesContent":[null],"names":["_jsx","CollapsibleSection","VStack"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollapsibleFormSection.js","sources":["../../../../src/components/Form/FormSection/CollapsibleFormSection.tsx"],"sourcesContent":[null],"names":["_jsx","CollapsibleSection","VStack"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;AAIG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,KAAK,EACL,MAAM,EACN,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,KAAK,EAChB,GAAG,GAAG,CAAC,EACP,QAAQ,GACoB,MAC5BA,cAAA,CAACC,qCAAkB,EAAA,EACjB,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,eAAe,EAAE,WAAW,EAC5B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EAAA,QAAA,EAEpBD,eAACE,YAAM,EAAA,EAAC,KAAK,EAAC,SAAS,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAC,MAAM,EAAA,QAAA,EACvC,QAAQ,EAAA,CACF,EAAA,CACU;;;;"}
|
|
@@ -32,6 +32,7 @@ import '../../Badge/Badge.mjs';
|
|
|
32
32
|
import '../../Workflow/canvas/NodeShell/NodeShell.styles.mjs';
|
|
33
33
|
import '../../Workflow/graphObserver.mjs';
|
|
34
34
|
import '@dagrejs/dagre';
|
|
35
|
+
import '../../../hooks/useLanguage.mjs';
|
|
35
36
|
import '../../Workflow/canvas/Canvas/Canvas.mjs';
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleFormSection.mjs","sources":["../../../../src/components/Form/FormSection/CollapsibleFormSection.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollapsibleFormSection.mjs","sources":["../../../../src/components/Form/FormSection/CollapsibleFormSection.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;AAIG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,KAAK,EACL,MAAM,EACN,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,KAAK,EAChB,GAAG,GAAG,CAAC,EACP,QAAQ,GACoB,MAC5BA,GAAA,CAAC,kBAAkB,EAAA,EACjB,KAAK,EAAE,KAAK,IAAI,EAAE,EAClB,eAAe,EAAE,WAAW,EAC5B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EAAA,QAAA,EAEpBA,IAAC,MAAM,EAAA,EAAC,KAAK,EAAC,SAAS,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAC,MAAM,EAAA,QAAA,EACvC,QAAQ,EAAA,CACF,EAAA,CACU;;;;"}
|
|
@@ -2,6 +2,11 @@ import type { SupportedLanguage } from '@/components/MonthPicker/constants';
|
|
|
2
2
|
export interface LanguageContextValue {
|
|
3
3
|
language: SupportedLanguage;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* The value seen outside any `LogicianProvider`. Exported so `useTranslate`
|
|
7
|
+
* can tell "no provider" (keep Korean) from a provider set to `en`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NO_PROVIDER_LANGUAGE: LanguageContextValue;
|
|
5
10
|
export declare const LanguageContext: import("react").Context<LanguageContextValue>;
|
|
6
11
|
export declare const useLanguage: () => LanguageContextValue;
|
|
7
12
|
export default useLanguage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../src/hooks/useLanguage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,eAAO,MAAM,eAAe,+
|
|
1
|
+
{"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../src/hooks/useLanguage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,oBAAyC,CAAC;AAE7E,eAAO,MAAM,eAAe,+CAC+B,CAAC;AAE5D,eAAO,MAAM,WAAW,4BAAoC,CAAC;AAE7D,eAAe,WAAW,CAAC"}
|
|
@@ -5,12 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The value seen outside any `LogicianProvider`. Exported so `useTranslate`
|
|
10
|
+
* can tell "no provider" (keep Korean) from a provider set to `en`.
|
|
11
|
+
*/
|
|
12
|
+
const NO_PROVIDER_LANGUAGE = { language: 'en' };
|
|
13
|
+
const LanguageContext = React.createContext(NO_PROVIDER_LANGUAGE);
|
|
11
14
|
const useLanguage = () => React.useContext(LanguageContext);
|
|
12
15
|
|
|
13
16
|
exports.LanguageContext = LanguageContext;
|
|
17
|
+
exports.NO_PROVIDER_LANGUAGE = NO_PROVIDER_LANGUAGE;
|
|
14
18
|
exports.default = useLanguage;
|
|
15
19
|
exports.useLanguage = useLanguage;
|
|
16
20
|
//# sourceMappingURL=useLanguage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguage.js","sources":["../../src/hooks/useLanguage.ts"],"sourcesContent":[null],"names":["createContext","useContext"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"useLanguage.js","sources":["../../src/hooks/useLanguage.ts"],"sourcesContent":[null],"names":["createContext","useContext"],"mappings":";;;;;;;AAUA;;;AAGG;MACU,oBAAoB,GAAyB,EAAE,QAAQ,EAAE,IAAI;MAE7D,eAAe,GAC1BA,mBAAa,CAAuB,oBAAoB;AAEnD,MAAM,WAAW,GAAG,MAAMC,gBAAU,CAAC,eAAe;;;;;;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The value seen outside any `LogicianProvider`. Exported so `useTranslate`
|
|
6
|
+
* can tell "no provider" (keep Korean) from a provider set to `en`.
|
|
7
|
+
*/
|
|
8
|
+
const NO_PROVIDER_LANGUAGE = { language: 'en' };
|
|
9
|
+
const LanguageContext = createContext(NO_PROVIDER_LANGUAGE);
|
|
7
10
|
const useLanguage = () => useContext(LanguageContext);
|
|
8
11
|
|
|
9
|
-
export { LanguageContext, useLanguage as default, useLanguage };
|
|
12
|
+
export { LanguageContext, NO_PROVIDER_LANGUAGE, useLanguage as default, useLanguage };
|
|
10
13
|
//# sourceMappingURL=useLanguage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguage.mjs","sources":["../../src/hooks/useLanguage.ts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"useLanguage.mjs","sources":["../../src/hooks/useLanguage.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAUA;;;AAGG;MACU,oBAAoB,GAAyB,EAAE,QAAQ,EAAE,IAAI;MAE7D,eAAe,GAC1B,aAAa,CAAuB,oBAAoB;AAEnD,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,eAAe;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslate.d.ts","sourceRoot":"","sources":["../../src/hooks/useTranslate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTranslate.d.ts","sourceRoot":"","sources":["../../src/hooks/useTranslate.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,YAAY,GAAI,iBAAiB,WAQpC,MAAM,cAAc;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,mBASnD,CAAC"}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var Defaults_translations = require('../translations/Defaults.translations.json.js');
|
|
6
6
|
var formatTextForMarkdown = require('../utils/formatTextForMarkdown.js');
|
|
7
|
+
var useLanguage = require('./useLanguage.js');
|
|
7
8
|
|
|
9
|
+
const DEFAULT_LOCALE = 'ko';
|
|
8
10
|
// Given a block of text and variables, replaces instances of the provided variables in the text
|
|
9
11
|
const replaceVariables = (text, variables) => {
|
|
10
12
|
if (!variables)
|
|
@@ -31,13 +33,14 @@ const replaceVariables = (text, variables) => {
|
|
|
31
33
|
? parts.join('')
|
|
32
34
|
: parts;
|
|
33
35
|
};
|
|
34
|
-
const getLanguage = () => {
|
|
35
|
-
return 'ko';
|
|
36
|
-
};
|
|
37
36
|
const useTranslate = (translations = {}) => {
|
|
38
|
-
|
|
37
|
+
// Follow `LogicianProvider`'s `language`, the same one the date pickers
|
|
38
|
+
// read. Outside a provider there is nothing to follow, so the library keeps
|
|
39
|
+
// its historical Korean.
|
|
40
|
+
const context = useLanguage.useLanguage();
|
|
41
|
+
const userLanguage = context === useLanguage.NO_PROVIDER_LANGUAGE ? DEFAULT_LOCALE : context.language;
|
|
39
42
|
return React.useCallback((key, variables) => {
|
|
40
|
-
const locale = userLanguage;
|
|
43
|
+
const locale = userLanguage ?? DEFAULT_LOCALE;
|
|
41
44
|
const translation = { ...Defaults_translations.default, ...translations }[key]?.[locale] ?? key;
|
|
42
45
|
const finalRes = replaceVariables(translation, variables);
|
|
43
46
|
return finalRes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslate.js","sources":["../../src/hooks/useTranslate.ts"],"sourcesContent":[null],"names":["formatForMarkdown","useCallback","defaultTranslations"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTranslate.js","sources":["../../src/hooks/useTranslate.ts"],"sourcesContent":[null],"names":["formatForMarkdown","useLanguage","NO_PROVIDER_LANGUAGE","useCallback","defaultTranslations"],"mappings":";;;;;;;;AAOA,MAAM,cAAc,GAAG,IAAI;AAE3B;AACA,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,SAAkC,KAAI;AAC5E,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAOA,uCAAiB,CAAC,IAAI,CAAC;IAE9C,MAAM,KAAK,GAAG,aAAa;IAE3B,MAAM,aAAa,GAAa,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;IACvD,MAAM,SAAS,GAAkB,EAAE;IACnC,IAAI,SAAS,GAAG,CAAC;AACjB,IAAA,aAAa,CAAC,OAAO,CAAC,CAAC,YAAoB,KAAI;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;;AAE3C,QAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAA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ACH;;;;"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import defaultTranslations from '../translations/Defaults.translations.json.mjs';
|
|
4
4
|
import { formatForMarkdown } from '../utils/formatTextForMarkdown.mjs';
|
|
5
|
+
import { useLanguage, NO_PROVIDER_LANGUAGE } from './useLanguage.mjs';
|
|
5
6
|
|
|
7
|
+
const DEFAULT_LOCALE = 'ko';
|
|
6
8
|
// Given a block of text and variables, replaces instances of the provided variables in the text
|
|
7
9
|
const replaceVariables = (text, variables) => {
|
|
8
10
|
if (!variables)
|
|
@@ -29,13 +31,14 @@ const replaceVariables = (text, variables) => {
|
|
|
29
31
|
? parts.join('')
|
|
30
32
|
: parts;
|
|
31
33
|
};
|
|
32
|
-
const getLanguage = () => {
|
|
33
|
-
return 'ko';
|
|
34
|
-
};
|
|
35
34
|
const useTranslate = (translations = {}) => {
|
|
36
|
-
|
|
35
|
+
// Follow `LogicianProvider`'s `language`, the same one the date pickers
|
|
36
|
+
// read. Outside a provider there is nothing to follow, so the library keeps
|
|
37
|
+
// its historical Korean.
|
|
38
|
+
const context = useLanguage();
|
|
39
|
+
const userLanguage = context === NO_PROVIDER_LANGUAGE ? DEFAULT_LOCALE : context.language;
|
|
37
40
|
return useCallback((key, variables) => {
|
|
38
|
-
const locale = userLanguage;
|
|
41
|
+
const locale = userLanguage ?? DEFAULT_LOCALE;
|
|
39
42
|
const translation = { ...defaultTranslations, ...translations }[key]?.[locale] ?? key;
|
|
40
43
|
const finalRes = replaceVariables(translation, variables);
|
|
41
44
|
return finalRes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslate.mjs","sources":["../../src/hooks/useTranslate.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTranslate.mjs","sources":["../../src/hooks/useTranslate.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAOA,MAAM,cAAc,GAAG,IAAI;AAE3B;AACA,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AE;AAC7B,IAAA,MAAM,YAAY,GAChB,OAAO,KAAK,oBAAoB,GAAG,cAAc,GAAG,OAAO,CAAC,QAAQ;AACtE,IAAA,OAAO,WAAW,CAChB,CAAC,GAAW,EAAE,SAAkC,KAAI;AAClD,QAAA,MAAM,MAAM,GAAI,YAAuB,IAAI,cAAc;AACzD,QAAA,MAAM,WAAW,GACf,EAAE,GAAG,mBAAmB,EAAE,GAAG,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG;QACnE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAC;AACzD,QAAA,OAAO,QAAQ;AACjB,IAAA,CAAC,EACD,CAAC,YAAY,EAAE,YAAY,CAAC,CAC7B;AACH;;;;"}
|
|
@@ -220,6 +220,13 @@ var downloading = {
|
|
|
220
220
|
ja: "ダウンロード中",
|
|
221
221
|
es: "Descargando"
|
|
222
222
|
};
|
|
223
|
+
var processing = {
|
|
224
|
+
ko: "처리 중",
|
|
225
|
+
en: "Processing",
|
|
226
|
+
zh: "处理中",
|
|
227
|
+
ja: "処理中",
|
|
228
|
+
es: "Procesando"
|
|
229
|
+
};
|
|
223
230
|
var deleting = {
|
|
224
231
|
ko: "삭제 중",
|
|
225
232
|
en: "Deleting",
|
|
@@ -273,6 +280,7 @@ var defaultTranslations = {
|
|
|
273
280
|
es: "Eliminar"
|
|
274
281
|
},
|
|
275
282
|
downloading: downloading,
|
|
283
|
+
processing: processing,
|
|
276
284
|
deleting: deleting,
|
|
277
285
|
close: close
|
|
278
286
|
};
|
|
@@ -301,6 +309,7 @@ exports.page = page;
|
|
|
301
309
|
exports.pagination_items_per_page = pagination_items_per_page;
|
|
302
310
|
exports.pagination_range_text = pagination_range_text;
|
|
303
311
|
exports.previous = previous;
|
|
312
|
+
exports.processing = processing;
|
|
304
313
|
exports.refresh_page = refresh_page;
|
|
305
314
|
exports.see_less = see_less;
|
|
306
315
|
exports.see_more = see_more;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Defaults.translations.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Defaults.translations.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -216,6 +216,13 @@ var downloading = {
|
|
|
216
216
|
ja: "ダウンロード中",
|
|
217
217
|
es: "Descargando"
|
|
218
218
|
};
|
|
219
|
+
var processing = {
|
|
220
|
+
ko: "처리 중",
|
|
221
|
+
en: "Processing",
|
|
222
|
+
zh: "处理中",
|
|
223
|
+
ja: "処理中",
|
|
224
|
+
es: "Procesando"
|
|
225
|
+
};
|
|
219
226
|
var deleting = {
|
|
220
227
|
ko: "삭제 중",
|
|
221
228
|
en: "Deleting",
|
|
@@ -269,9 +276,10 @@ var defaultTranslations = {
|
|
|
269
276
|
es: "Eliminar"
|
|
270
277
|
},
|
|
271
278
|
downloading: downloading,
|
|
279
|
+
processing: processing,
|
|
272
280
|
deleting: deleting,
|
|
273
281
|
close: close
|
|
274
282
|
};
|
|
275
283
|
|
|
276
|
-
export { anonymous, clear, close, component, copied, copy, copy_error_details, defaultTranslations as default, deleting, download, downloading, error_boundary_default_message, error_boundary_subtitle, error_boundary_title, error_details_copied, error_id, get_started, go_next_page_button, month_range_placeholder, next, page, pagination_items_per_page, pagination_range_text, previous, refresh_page, see_less, see_more, support_help_text, support_information, time, try_again, unknown, upload_your_file, user_id };
|
|
284
|
+
export { anonymous, clear, close, component, copied, copy, copy_error_details, defaultTranslations as default, deleting, download, downloading, error_boundary_default_message, error_boundary_subtitle, error_boundary_title, error_details_copied, error_id, get_started, go_next_page_button, month_range_placeholder, next, page, pagination_items_per_page, pagination_range_text, previous, processing, refresh_page, see_less, see_more, support_help_text, support_information, time, try_again, unknown, upload_your_file, user_id };
|
|
277
285
|
//# sourceMappingURL=Defaults.translations.json.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Defaults.translations.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Defaults.translations.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -29,7 +29,8 @@ beforeAll(() => {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
const Sheet = (props: Partial<BottomSheetProps>) => (
|
|
32
|
-
|
|
32
|
+
// Korean copy, so the built-in close label is 닫기 (it follows `language`).
|
|
33
|
+
<LogicianProvider language="ko">
|
|
33
34
|
<BottomSheet {...props}>
|
|
34
35
|
<BottomSheetContent data-testid="content">
|
|
35
36
|
<BottomSheetHeader>노드 추가</BottomSheetHeader>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { Button as ChakraButton, SystemStyleObject } from '@chakra-ui/react';
|
|
3
3
|
|
|
4
|
+
import { useTranslate } from '@/hooks/useTranslate';
|
|
4
5
|
import { focusRing } from '@/utils/focusRing';
|
|
5
6
|
import { mergeCss } from '@/utils/mergeCss';
|
|
6
7
|
|
|
@@ -49,8 +50,19 @@ const ButtonImpl = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
49
50
|
// 4.x callers (untyped JS, `as any`) can still hand us `colorPalette` and
|
|
50
51
|
// an old variant name. Strip it so it never reaches Chakra's own recipe,
|
|
51
52
|
// and map the pair onto a 5.0 role — see `Button.legacy.ts`.
|
|
52
|
-
const {
|
|
53
|
-
|
|
53
|
+
const {
|
|
54
|
+
colorPalette: legacyPalette,
|
|
55
|
+
loadingText: loadingTextProp,
|
|
56
|
+
...rest
|
|
57
|
+
} = restWithLegacy as typeof restWithLegacy & { colorPalette?: unknown };
|
|
58
|
+
// A busy button says what it is doing: 처리 중 unless the call site names
|
|
59
|
+
// the verb (저장 중). `loadingText={null}` opts out — spinner only, and the
|
|
60
|
+
// button keeps its width.
|
|
61
|
+
const translate = useTranslate();
|
|
62
|
+
const loadingText =
|
|
63
|
+
loadingTextProp === undefined
|
|
64
|
+
? translate('processing')
|
|
65
|
+
: (loadingTextProp ?? undefined);
|
|
54
66
|
|
|
55
67
|
let variant: ButtonVariant = variantProp ?? 'subtle';
|
|
56
68
|
let isDestructive = isDestructiveProp;
|
|
@@ -149,6 +161,7 @@ const ButtonImpl = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
149
161
|
ref={ref}
|
|
150
162
|
data-variant={variant}
|
|
151
163
|
data-destructive={isDestructive || undefined}
|
|
164
|
+
loadingText={loadingText}
|
|
152
165
|
{...rest}
|
|
153
166
|
// The `action` icon rule lives in `css` (a nested selector cannot be a
|
|
154
167
|
// style prop); merged so a call site's `css` adds to it.
|
package/src/hooks/useLanguage.ts
CHANGED
|
@@ -8,9 +8,14 @@ export interface LanguageContextValue {
|
|
|
8
8
|
language: SupportedLanguage;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The value seen outside any `LogicianProvider`. Exported so `useTranslate`
|
|
13
|
+
* can tell "no provider" (keep Korean) from a provider set to `en`.
|
|
14
|
+
*/
|
|
15
|
+
export const NO_PROVIDER_LANGUAGE: LanguageContextValue = { language: 'en' };
|
|
16
|
+
|
|
17
|
+
export const LanguageContext =
|
|
18
|
+
createContext<LanguageContextValue>(NO_PROVIDER_LANGUAGE);
|
|
14
19
|
|
|
15
20
|
export const useLanguage = () => useContext(LanguageContext);
|
|
16
21
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChakraProvider } from '@chakra-ui/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { beforeAll, describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { Button } from '@/components/Button';
|
|
6
|
+
import { LogicianProvider } from '@/components/LogicianProvider';
|
|
7
|
+
import { system } from '@/theme';
|
|
8
|
+
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
// LogicianProvider's color-mode machinery calls it on mount; jsdom has none.
|
|
11
|
+
window.matchMedia = ((query: string) => ({
|
|
12
|
+
matches: false,
|
|
13
|
+
media: query,
|
|
14
|
+
onchange: null,
|
|
15
|
+
addListener: () => {},
|
|
16
|
+
removeListener: () => {},
|
|
17
|
+
addEventListener: () => {},
|
|
18
|
+
removeEventListener: () => {},
|
|
19
|
+
dispatchEvent: () => false,
|
|
20
|
+
})) as unknown as typeof window.matchMedia;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Read through Button's 처리 중 default, the string an app sees most.
|
|
24
|
+
describe('useTranslate follows LogicianProvider language', () => {
|
|
25
|
+
it('stays Korean outside a provider', () => {
|
|
26
|
+
render(
|
|
27
|
+
<ChakraProvider value={system}>
|
|
28
|
+
<Button loading>x</Button>
|
|
29
|
+
</ChakraProvider>
|
|
30
|
+
);
|
|
31
|
+
expect(screen.getByRole('button')).toHaveTextContent('처리 중');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it.each([
|
|
35
|
+
['ko', '처리 중'],
|
|
36
|
+
['en', 'Processing'],
|
|
37
|
+
['ja', '処理中'],
|
|
38
|
+
] as const)('renders %s', (language, text) => {
|
|
39
|
+
render(
|
|
40
|
+
<LogicianProvider language={language} loadFonts={false}>
|
|
41
|
+
<Button loading>x</Button>
|
|
42
|
+
</LogicianProvider>
|
|
43
|
+
);
|
|
44
|
+
expect(screen.getByRole('button')).toHaveTextContent(text);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -3,6 +3,7 @@ import { useCallback } from 'react';
|
|
|
3
3
|
|
|
4
4
|
import defaultTranslations from '../translations/Defaults.translations.json';
|
|
5
5
|
import { formatForMarkdown } from '../utils/formatTextForMarkdown';
|
|
6
|
+
import { NO_PROVIDER_LANGUAGE, useLanguage } from './useLanguage';
|
|
6
7
|
|
|
7
8
|
const DEFAULT_LOCALE = 'ko';
|
|
8
9
|
|
|
@@ -38,12 +39,13 @@ const replaceVariables = (text: string, variables?: { [key: string]: any }) => {
|
|
|
38
39
|
: parts;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
const getLanguage = () => {
|
|
42
|
-
return 'ko';
|
|
43
|
-
};
|
|
44
|
-
|
|
45
42
|
export const useTranslate = (translations = {}) => {
|
|
46
|
-
|
|
43
|
+
// Follow `LogicianProvider`'s `language`, the same one the date pickers
|
|
44
|
+
// read. Outside a provider there is nothing to follow, so the library keeps
|
|
45
|
+
// its historical Korean.
|
|
46
|
+
const context = useLanguage();
|
|
47
|
+
const userLanguage =
|
|
48
|
+
context === NO_PROVIDER_LANGUAGE ? DEFAULT_LOCALE : context.language;
|
|
47
49
|
return useCallback(
|
|
48
50
|
(key: string, variables?: { [key: string]: any }) => {
|
|
49
51
|
const locale = (userLanguage as string) ?? DEFAULT_LOCALE;
|