smarthr-ui 76.0.0 → 76.1.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/esm/_virtual/index.js +4 -4
- package/esm/_virtual/index2.js +4 -4
- package/esm/_virtual/index3.js +4 -4
- package/esm/components/Combobox/MultiCombobox/MultiCombobox.js +1 -1
- package/esm/components/Combobox/SingleCombobox/SingleCombobox.js +1 -1
- package/esm/components/Combobox/helper.js +1 -1
- package/esm/components/Combobox/useOptions.js +1 -1
- package/esm/components/Dropdown/DropdownMenuButton/DropdownMenuButton.js +1 -1
- package/esm/components/Dropdown/FilterDropdown/FilterDropdown.js +1 -1
- package/esm/components/FormControl/FormControl.js +1 -1
- package/esm/components/TextLink/TextLink.d.ts +21 -0
- package/esm/components/TextLink/TextLink.js +3 -0
- package/esm/components/TextLink/TextLink.js.map +1 -1
- package/esm/components/Tooltip/Tooltip.js +1 -1
- package/esm/intl/IntlProvider.d.ts +5 -3
- package/esm/intl/IntlProvider.js +5 -3
- package/esm/intl/IntlProvider.js.map +1 -1
- package/esm/intl/localeMap.d.ts +1 -0
- package/esm/intl/localeMap.js +49 -4
- package/esm/intl/localeMap.js.map +1 -1
- package/esm/intl/locales/index.d.ts +3 -3
- package/esm/intl/locales/index.js +3 -3
- package/esm/libs/lodash.js +2 -2
- package/lib/components/TextLink/TextLink.d.ts +21 -0
- package/lib/components/TextLink/TextLink.js +3 -0
- package/lib/components/TextLink/TextLink.js.map +1 -1
- package/lib/intl/IntlProvider.d.ts +5 -3
- package/lib/intl/IntlProvider.js +4 -2
- package/lib/intl/IntlProvider.js.map +1 -1
- package/lib/intl/localeMap.d.ts +1 -0
- package/lib/intl/localeMap.js +50 -4
- package/lib/intl/localeMap.js.map +1 -1
- package/lib/intl/locales/index.d.ts +3 -3
- package/lib/intl/locales/index.js +7 -7
- package/lib/intl/locales/index.js.map +1 -1
- package/package.json +1 -1
package/esm/_virtual/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireReactInnertext } from './../vendor/.pnpm/react-innertext@1.1.5_@types_react@18.3.23_react@19.1.1/vendor/react-innertext/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var reactInnertextExports = requireReactInnertext();
|
|
5
|
+
var innerText = /*@__PURE__*/getDefaultExportFromCjs(reactInnertextExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { innerText as default };
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/esm/_virtual/index2.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireLodash_merge } from './../vendor/.pnpm/lodash.merge@4.6.2/vendor/lodash.merge/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var lodash_mergeExports = requireLodash_merge();
|
|
5
|
+
var _merge = /*@__PURE__*/getDefaultExportFromCjs(lodash_mergeExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { _merge as default };
|
|
8
8
|
//# sourceMappingURL=index2.js.map
|
package/esm/_virtual/index3.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireLodash_range } from './../vendor/.pnpm/lodash.range@3.2.0/vendor/lodash.range/index.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var lodash_rangeExports = requireLodash_range();
|
|
5
|
+
var _range = /*@__PURE__*/getDefaultExportFromCjs(lodash_rangeExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { _range as default };
|
|
8
8
|
//# sourceMappingURL=index3.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo, useRef, useState, useCallback, useImperativeHandle, useEffect, useId } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useOuterClick } from '../../../hooks/useOuterClick.js';
|
|
7
7
|
import '../../../intl/IntlProvider.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useRef, useState, useImperativeHandle, useCallback, useMemo, useEffect } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useClick } from '../../../hooks/useClick.js';
|
|
7
7
|
import { useDecorators } from '../../../hooks/useDecorators.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useId, useMemo } from 'react';
|
|
2
|
-
import innerText from '../../_virtual/
|
|
2
|
+
import innerText from '../../_virtual/index.js';
|
|
3
3
|
import { areItemsEqual, convertMatchableString } from './helper.js';
|
|
4
4
|
|
|
5
5
|
const defaultIsItemSelected = (targetItem, selectedItems) => selectedItems.some((item) => areItemsEqual(item, targetItem));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useContext, useMemo, useRef, Children, isValidElement, Fragment, cloneElement } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { DropdownContext, Dropdown } from '../Dropdown.js';
|
|
7
7
|
import { DropdownTrigger } from '../DropdownTrigger.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import innerText from '../../../_virtual/
|
|
4
|
+
import innerText from '../../../_virtual/index.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useDecorators } from '../../../hooks/useDecorators.js';
|
|
7
7
|
import { useResponseStatus } from '../../../hooks/useResponseStatus.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { memo, useMemo, useId, useRef, Fragment as Fragment$1, createElement, useEffect } from 'react';
|
|
3
3
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import innerText from '../../_virtual/
|
|
4
|
+
import innerText from '../../_virtual/index.js';
|
|
5
5
|
import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { FaCircleExclamationIcon } from '../Icon/Icon.js';
|
|
7
7
|
import '../Icon/generateIcon.js';
|
|
@@ -15,6 +15,9 @@ type Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {
|
|
|
15
15
|
type TextLinkComponent = <T extends ElementType = 'a'>(props: Props<T> & ElementProps<T> & ElementRefProps<T>) => ReturnType<FC>;
|
|
16
16
|
declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
17
17
|
size: {
|
|
18
|
+
XS: {
|
|
19
|
+
anchor: string;
|
|
20
|
+
};
|
|
18
21
|
S: {
|
|
19
22
|
anchor: string;
|
|
20
23
|
};
|
|
@@ -28,6 +31,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
28
31
|
suffixWrapper: string;
|
|
29
32
|
}, undefined, import("tailwind-variants/dist/config.js").TVConfig<{
|
|
30
33
|
size: {
|
|
34
|
+
XS: {
|
|
35
|
+
anchor: string;
|
|
36
|
+
};
|
|
31
37
|
S: {
|
|
32
38
|
anchor: string;
|
|
33
39
|
};
|
|
@@ -37,6 +43,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
37
43
|
};
|
|
38
44
|
}, {
|
|
39
45
|
size: {
|
|
46
|
+
XS: {
|
|
47
|
+
anchor: string;
|
|
48
|
+
};
|
|
40
49
|
S: {
|
|
41
50
|
anchor: string;
|
|
42
51
|
};
|
|
@@ -46,6 +55,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
46
55
|
};
|
|
47
56
|
}>, {
|
|
48
57
|
size: {
|
|
58
|
+
XS: {
|
|
59
|
+
anchor: string;
|
|
60
|
+
};
|
|
49
61
|
S: {
|
|
50
62
|
anchor: string;
|
|
51
63
|
};
|
|
@@ -59,6 +71,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
59
71
|
suffixWrapper: string;
|
|
60
72
|
}, import("tailwind-variants").TVReturnType<{
|
|
61
73
|
size: {
|
|
74
|
+
XS: {
|
|
75
|
+
anchor: string;
|
|
76
|
+
};
|
|
62
77
|
S: {
|
|
63
78
|
anchor: string;
|
|
64
79
|
};
|
|
@@ -72,6 +87,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
72
87
|
suffixWrapper: string;
|
|
73
88
|
}, undefined, import("tailwind-variants/dist/config.js").TVConfig<{
|
|
74
89
|
size: {
|
|
90
|
+
XS: {
|
|
91
|
+
anchor: string;
|
|
92
|
+
};
|
|
75
93
|
S: {
|
|
76
94
|
anchor: string;
|
|
77
95
|
};
|
|
@@ -81,6 +99,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
81
99
|
};
|
|
82
100
|
}, {
|
|
83
101
|
size: {
|
|
102
|
+
XS: {
|
|
103
|
+
anchor: string;
|
|
104
|
+
};
|
|
84
105
|
S: {
|
|
85
106
|
anchor: string;
|
|
86
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLink.js","sources":["../../../src/components/TextLink/TextLink.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from './OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;AAsCA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;AAC1C,SAAA;AACD,QAAA,aAAa,EAAE,8BAA8B;AAC7C,QAAA,aAAa,EAAE,8BAA8B;AAC9C,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,CAAC,EAAE;AACD,gBAAA,MAAM,EAAE,aAAa;AACtB,aAAA;AACD,YAAA,CAAC,EAAE;AACD,gBAAA,MAAM,EAAE,eAAe;AACxB,aAAA;AACF,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AACF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE;AACrE,MAAM,sBAAsB,GAAG,aAAa,EAAE;AAC9C,MAAM,sBAAsB,GAAG,aAAa,EAAE;AAE9C,MAAM,cAAc,GAAsB,UAAU,CAClD,CACE,EACE,SAAS,EACT,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,MAAM,EACmC,EAC9C,GAAuB,KACrB;AACF,IAAA,MAAM,MAAM,GAAG,SAAS,IAAI,GAAG;AAC/B,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAK;QAChC,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,EAAE;YAC/C,OAAOC,GAAA,CAAC,gBAAgB,EAAA,EAAA,CAAG;QAC7B;AAEA,QAAA,OAAO,MAAM;AACf,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpB,IAAA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SAAS,EAAE,sBAAsB,EAAA,QAAA,EAAG,YAAY,EAAA,CAAQ,CAAA,EAAA,CACxE;AAEb,CAAC,CACF;MAEY,QAAQ,GAAG,IAAI,CAAC,cAAc;;;;"}
|
|
1
|
+
{"version":3,"file":"TextLink.js","sources":["../../../src/components/TextLink/TextLink.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from './OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;AAsCA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;AAC1C,SAAA;AACD,QAAA,aAAa,EAAE,8BAA8B;AAC7C,QAAA,aAAa,EAAE,8BAA8B;AAC9C,KAAA;AACD,IAAA,QA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M,KAAK,QAAQ,GAAG,qBAAqB,GAAG,GAAG,CAAC,EAC9E,CAAC,GAAG,EAAE,MAAM,CAAC,CACd;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAErF,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;QACjC,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,SAAS;QAClB;QAEA,IAAI,IAAI,EAAE;AACR,YAAA,OAAO,OAAO;QAChB;QAEA,OAAO,CAAC,CAAa,KAAI;YACvB,CAAC,CAAC,cAAc,EAAE;YAClB,OAAO,CAAC,CAAC,CAAC;AACZ,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEnB,QACEC,IAAA,CAAC,MAAM,EAAA,EAAA,GACD,MAAM,EACV,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,eAAe,EAAA,QAAA,EAAA,CAEzB,MAAM,IAAID,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,sBAAsB,EAAA,QAAA,EAAG,MAAM,EAAA,CAAQ,EAClE,QAAQ,EACR,YAAY,IAAIA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,sBAAsB,EAAA,QAAA,EAAG,YAAY,EAAA,CAAQ,CAAA,EAAA,CACxE;AAEb,CAAC,CACF;MAEY,QAAQ,GAAG,IAAI,CAAC,cAAc;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo, useState, useRef, useId, useSyncExternalStore, useCallback, cloneElement } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import innerText from '../../_virtual/
|
|
5
|
+
import innerText from '../../_virtual/index.js';
|
|
6
6
|
import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.17_ts-node@10.9.2_@swc_core@1.13.2_@types_node@20.19.9_typescript@5.8.3__/vendor/tailwind-variants/dist/index.js';
|
|
7
7
|
import { useEnhancedEffect } from '../../hooks/useEnhancedEffect.js';
|
|
8
8
|
import { VisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText.js';
|
|
@@ -2,9 +2,11 @@ import { type FC, type PropsWithChildren } from 'react';
|
|
|
2
2
|
import { type Locale } from './localeMap';
|
|
3
3
|
declare const allLocaleKeys: Locale[];
|
|
4
4
|
type Props<AvailableLocales extends Locale[] = typeof allLocaleKeys> = PropsWithChildren<{
|
|
5
|
-
locale:
|
|
6
|
-
availableLocales?:
|
|
5
|
+
locale: string;
|
|
6
|
+
availableLocales?: string[];
|
|
7
|
+
_not_used_locale?: AvailableLocales[number];
|
|
8
|
+
_not_used_availableLocales?: AvailableLocales;
|
|
7
9
|
}>;
|
|
8
|
-
export declare const useAvailableLocales: () => ("pt" | "ja" | "
|
|
10
|
+
export declare const useAvailableLocales: () => ("pt" | "ja" | "en-us" | "id-id" | "vi" | "ko" | "zh-cn" | "zh-tw" | "ja-easy")[];
|
|
9
11
|
export declare const IntlProvider: <AvailableLocales extends Locale[] = typeof allLocaleKeys>({ availableLocales, locale, children, }: Props<AvailableLocales>) => ReturnType<FC>;
|
|
10
12
|
export {};
|
package/esm/intl/IntlProvider.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext, useMemo } from 'react';
|
|
4
4
|
import { IntlContext, IntlProvider as IntlProvider$1 } from 'react-intl';
|
|
5
|
-
import { localeMap } from './localeMap.js';
|
|
5
|
+
import { localeMap, convertLang } from './localeMap.js';
|
|
6
6
|
import * as intl_locales_index from './locales/index.js';
|
|
7
7
|
|
|
8
8
|
// Object.keys は常に string[] を返却するが、locales は実行時に変更されないため、as 型キャストを使用することは自明に安全なので使用している
|
|
@@ -10,10 +10,12 @@ const allLocaleKeys = Object.keys(localeMap);
|
|
|
10
10
|
const AvailableLocalesContext = createContext(allLocaleKeys);
|
|
11
11
|
const useAvailableLocales = () => useContext(AvailableLocalesContext);
|
|
12
12
|
const IntlProvider = ({ availableLocales, locale, children, }) => {
|
|
13
|
+
const convertedLocale = convertLang(locale);
|
|
14
|
+
const convertedAvailableLocales = availableLocales?.map(convertLang);
|
|
13
15
|
// プロダクト側でIntlProviderを使っている場合、プロダクト側のmessagesとマージして提供するためにContextから取得している
|
|
14
16
|
const intl = useContext(IntlContext);
|
|
15
|
-
const actualMessages = useMemo(() => ({ ...intl?.messages, ...intl_locales_index[
|
|
16
|
-
return (jsx(AvailableLocalesContext.Provider, { value:
|
|
17
|
+
const actualMessages = useMemo(() => ({ ...intl?.messages, ...intl_locales_index[convertedLocale] }), [intl, convertedLocale]);
|
|
18
|
+
return (jsx(AvailableLocalesContext.Provider, { value: convertedAvailableLocales ?? allLocaleKeys, children: jsx(IntlProvider$1, { locale: convertedLocale, messages: actualMessages, children: children }) }));
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export { IntlProvider, useAvailableLocales };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.js","sources":["../../src/intl/IntlProvider.tsx"],"sourcesContent":["'use client'\n\nimport { type FC, type PropsWithChildren, createContext, useContext, useMemo } from 'react'\nimport { IntlContext, IntlProvider as ReactIntlProvider } from 'react-intl'\n\nimport { type Locale, localeMap } from './localeMap'\nimport * as locales from './locales'\n\n// Object.keys は常に string[] を返却するが、locales は実行時に変更されないため、as 型キャストを使用することは自明に安全なので使用している\nconst allLocaleKeys = Object.keys(localeMap) as Locale[]\n\ntype Props<AvailableLocales extends Locale[] = typeof allLocaleKeys> = PropsWithChildren<{\n locale: AvailableLocales[number]\n
|
|
1
|
+
{"version":3,"file":"IntlProvider.js","sources":["../../src/intl/IntlProvider.tsx"],"sourcesContent":["'use client'\n\nimport { type FC, type PropsWithChildren, createContext, useContext, useMemo } from 'react'\nimport { IntlContext, IntlProvider as ReactIntlProvider } from 'react-intl'\n\nimport { type Locale, convertLang, localeMap } from './localeMap'\nimport * as locales from './locales'\n\n// Object.keys は常に string[] を返却するが、locales は実行時に変更されないため、as 型キャストを使用することは自明に安全なので使用している\nconst allLocaleKeys = Object.keys(localeMap) as Locale[]\n\ntype Props<AvailableLocales extends Locale[] = typeof allLocaleKeys> = PropsWithChildren<{\n locale: string\n availableLocales?: string[]\n // ↑ プロダクト側と smarthr-ui の言語コードの揺れに対応するため、一旦 string, string[] で受け取れるようにする\n // ↓ 本来は AvailableLocales[number], AvailableLocales で受け取りたいが、プロダクトと smarthr-ui での言語コード統一が終わるまで使えない\n _not_used_locale?: AvailableLocales[number]\n _not_used_availableLocales?: AvailableLocales\n}>\n\nconst AvailableLocalesContext = createContext<Locale[]>(allLocaleKeys)\n\nexport const useAvailableLocales = () => useContext(AvailableLocalesContext)\n\nexport const IntlProvider = <AvailableLocales extends Locale[] = typeof allLocaleKeys>({\n availableLocales,\n locale,\n children,\n}: Props<AvailableLocales>): ReturnType<FC> => {\n const convertedLocale = convertLang(locale)\n const convertedAvailableLocales = availableLocales?.map(convertLang)\n\n // プロダクト側でIntlProviderを使っている場合、プロダクト側のmessagesとマージして提供するためにContextから取得している\n const intl = useContext(IntlContext)\n const actualMessages = useMemo(\n () => ({ ...intl?.messages, ...locales[convertedLocale] }),\n [intl, convertedLocale],\n )\n\n return (\n <AvailableLocalesContext.Provider value={convertedAvailableLocales ?? allLocaleKeys}>\n <ReactIntlProvider locale={convertedLocale} messages={actualMessages}>\n {children}\n </ReactIntlProvider>\n </AvailableLocalesContext.Provider>\n )\n}\n"],"names":[],"mappings":";;;;;;;AAQA;AACA;AAWA;AAEO;AAEA;AAKL;;;AAIA;AACA;;AAYF;;"}
|
package/esm/intl/localeMap.d.ts
CHANGED
package/esm/intl/localeMap.js
CHANGED
|
@@ -1,14 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
localeMap は LanguageSwitcher で言語切替をするためにも使用されます。そのため、このオブジェクトの並び順が言語切替 UI の並び順にも反映されます。
|
|
3
|
+
配置ロジック(新しい言語追加時の判断軸)
|
|
4
|
+
・認知負荷を減らす:利用頻度を考慮し、ユーザーが直感的に探せるようにする。
|
|
5
|
+
・見栄えを考慮:アルファベット系・漢字系といった系統を意識して並べ、視覚的にも整理する。
|
|
6
|
+
|
|
7
|
+
下記の設計を基準にすれば、新しい言語を追加する際も既存の分類に沿って挿入するだけで済み、秩序を維持できる。
|
|
8
|
+
1. 日本語:デフォルト言語のため、常に最上位。
|
|
9
|
+
2. 英語:i18n文脈における事実上のデフォルト言語として、常に第二位。
|
|
10
|
+
3. 他のアルファベット系言語(インドネシア語、ポルトガル語、ベトナム語):常に中央に配置し、アルファベット順で整列。
|
|
11
|
+
4. 韓国語:アルファベット系と漢字系の橋渡し(トランジション)として配置。
|
|
12
|
+
5. 中国語(簡体字・繁体字):ユーザー数が多く安定している漢字系言語であるため、常に後半にまとめて配置。
|
|
13
|
+
6. やさしい日本語:日本語の派生であり、補助的な言語という位置づけを示すため、常に最後に配置。
|
|
14
|
+
*/
|
|
1
15
|
const localeMap = {
|
|
2
16
|
ja: '日本語',
|
|
3
|
-
'ja-easy': 'やさしい日本語',
|
|
4
17
|
'en-us': 'English',
|
|
5
|
-
|
|
18
|
+
'id-id': 'Bahasa Indonesia',
|
|
6
19
|
pt: 'Português',
|
|
7
20
|
vi: 'Tiếng Việt',
|
|
21
|
+
ko: '한국어',
|
|
8
22
|
'zh-cn': '简体中文',
|
|
9
23
|
'zh-tw': '繁體中文',
|
|
10
|
-
'
|
|
24
|
+
'ja-easy': 'やさしい日本語',
|
|
25
|
+
};
|
|
26
|
+
// 渡される言語の揺れを許容して smarthr-ui で使っている言語コードに変換する
|
|
27
|
+
const convertLang = (rawLang) => {
|
|
28
|
+
const lang = rawLang.toLowerCase().replace(/_/g, '-');
|
|
29
|
+
// 日本語とやさしい日本語の対応
|
|
30
|
+
if (lang.startsWith('ja')) {
|
|
31
|
+
if (lang.includes('-easy')) {
|
|
32
|
+
return 'ja-easy';
|
|
33
|
+
}
|
|
34
|
+
return 'ja';
|
|
35
|
+
}
|
|
36
|
+
// 简体中文と繁體中文
|
|
37
|
+
if (lang.startsWith('zh')) {
|
|
38
|
+
const regionOrScript = lang.split('-')[1] ?? '';
|
|
39
|
+
if (['tw', 'hant'].includes(regionOrScript)) {
|
|
40
|
+
return 'zh-tw';
|
|
41
|
+
}
|
|
42
|
+
return 'zh-cn';
|
|
43
|
+
}
|
|
44
|
+
if (lang.startsWith('en'))
|
|
45
|
+
return 'en-us'; // 英語
|
|
46
|
+
if (lang.startsWith('pt'))
|
|
47
|
+
return 'pt'; // ポルトガル語
|
|
48
|
+
if (lang.startsWith('vi'))
|
|
49
|
+
return 'vi'; // ベトナム語
|
|
50
|
+
if (lang.startsWith('ko'))
|
|
51
|
+
return 'ko'; // 韓国語
|
|
52
|
+
if (lang.startsWith('id'))
|
|
53
|
+
return 'id-id'; // インドネシア語
|
|
54
|
+
// 何にも一致しない場合はフォールバックとして 'ja' を返す
|
|
55
|
+
return 'ja';
|
|
11
56
|
};
|
|
12
57
|
|
|
13
|
-
export { localeMap };
|
|
58
|
+
export { convertLang, localeMap };
|
|
14
59
|
//# sourceMappingURL=localeMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMap.js","sources":["../../src/intl/localeMap.ts"],"sourcesContent":["import type * as locales from './locales'\n\nexport type Locale = keyof typeof locales\n\nexport const localeMap: Record<Locale, string> = {\n ja: '日本語',\n '
|
|
1
|
+
{"version":3,"file":"localeMap.js","sources":["../../src/intl/localeMap.ts"],"sourcesContent":["import type * as locales from './locales'\n\nexport type Locale = keyof typeof locales\n\n/*\n localeMap は LanguageSwitcher で言語切替をするためにも使用されます。そのため、このオブジェクトの並び順が言語切替 UI の並び順にも反映されます。\n 配置ロジック(新しい言語追加時の判断軸)\n ・認知負荷を減らす:利用頻度を考慮し、ユーザーが直感的に探せるようにする。\n ・見栄えを考慮:アルファベット系・漢字系といった系統を意識して並べ、視覚的にも整理する。\n\n 下記の設計を基準にすれば、新しい言語を追加する際も既存の分類に沿って挿入するだけで済み、秩序を維持できる。\n 1. 日本語:デフォルト言語のため、常に最上位。\n 2. 英語:i18n文脈における事実上のデフォルト言語として、常に第二位。\n 3. 他のアルファベット系言語(インドネシア語、ポルトガル語、ベトナム語):常に中央に配置し、アルファベット順で整列。\n 4. 韓国語:アルファベット系と漢字系の橋渡し(トランジション)として配置。\n 5. 中国語(簡体字・繁体字):ユーザー数が多く安定している漢字系言語であるため、常に後半にまとめて配置。\n 6. やさしい日本語:日本語の派生であり、補助的な言語という位置づけを示すため、常に最後に配置。\n*/\nexport const localeMap: Record<Locale, string> = {\n ja: '日本語',\n 'en-us': 'English',\n 'id-id': 'Bahasa Indonesia',\n pt: 'Português',\n vi: 'Tiếng Việt',\n ko: '한국어',\n 'zh-cn': '简体中文',\n 'zh-tw': '繁體中文',\n 'ja-easy': 'やさしい日本語',\n}\n\n// 渡される言語の揺れを許容して smarthr-ui で使っている言語コードに変換する\nexport const convertLang = (rawLang: string): keyof typeof locales => {\n const lang = rawLang.toLowerCase().replace(/_/g, '-')\n\n // 日本語とやさしい日本語の対応\n if (lang.startsWith('ja')) {\n if (lang.includes('-easy')) {\n return 'ja-easy'\n }\n\n return 'ja'\n }\n\n // 简体中文と繁體中文\n if (lang.startsWith('zh')) {\n const regionOrScript = lang.split('-')[1] ?? ''\n\n if (['tw', 'hant'].includes(regionOrScript)) {\n return 'zh-tw'\n }\n\n return 'zh-cn'\n }\n\n if (lang.startsWith('en')) return 'en-us' // 英語\n if (lang.startsWith('pt')) return 'pt' // ポルトガル語\n if (lang.startsWith('vi')) return 'vi' // ベトナム語\n if (lang.startsWith('ko')) return 'ko' // 韓国語\n if (lang.startsWith('id')) return 'id-id' // インドネシア語\n\n // 何にも一致しない場合はフォールバックとして 'ja' を返す\n return 'ja'\n}\n"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;AAaE;AACK,MAAM,SAAS,GAA2B;AAC/C,IAAA,EAAE,EAAE,KAAK;AACT,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,kBAAkB;AAC3B,IAAA,EAAE,EAAE,WAAW;AACf,IAAA,EAAE,EAAE,YAAY;AAChB,IAAA,EAAE,EAAE,KAAK;AACT,IAAA,OAAO,EAAE,MAAM;AACf,IAAA,OAAO,EAAE,MAAM;AACf,IAAA,SAAS,EAAE,SAAS;;AAGtB;AACO,MAAM,WAAW,GAAG,CAAC,OAAe,KAA0B;AACnE,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;;AAGrD,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AACzB,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AAC1B,YAAA,OAAO,SAAS;QAClB;AAEA,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AACzB,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;QAE/C,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;AAC3C,YAAA,OAAO,OAAO;QAChB;AAEA,QAAA,OAAO,OAAO;IAChB;AAEA,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAA;AACzC,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;AACtC,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;AACtC,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;AACtC,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAA;;AAGzC,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { locale as ja } from './ja';
|
|
2
|
-
export { locale as 'ja-easy' } from './ja_easy';
|
|
3
2
|
export { locale as 'en-us' } from './en_us';
|
|
4
|
-
export { locale as
|
|
3
|
+
export { locale as 'id-id' } from './id_id';
|
|
5
4
|
export { locale as pt } from './pt_br';
|
|
6
5
|
export { locale as vi } from './vi_vn';
|
|
6
|
+
export { locale as ko } from './ko_kr';
|
|
7
7
|
export { locale as 'zh-cn' } from './zh_hans_cn';
|
|
8
8
|
export { locale as 'zh-tw' } from './zh_hant_tw';
|
|
9
|
-
export { locale as '
|
|
9
|
+
export { locale as 'ja-easy' } from './ja_easy';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { locale as ja } from './ja.js';
|
|
2
|
-
export { locale as "ja-easy" } from './ja_easy.js';
|
|
3
2
|
export { locale as "en-us" } from './en_us.js';
|
|
4
|
-
export { locale as
|
|
3
|
+
export { locale as "id-id" } from './id_id.js';
|
|
5
4
|
export { locale as pt } from './pt_br.js';
|
|
6
5
|
export { locale as vi } from './vi_vn.js';
|
|
6
|
+
export { locale as ko } from './ko_kr.js';
|
|
7
7
|
export { locale as "zh-cn" } from './zh_hans_cn.js';
|
|
8
8
|
export { locale as "zh-tw" } from './zh_hant_tw.js';
|
|
9
|
-
export { locale as "
|
|
9
|
+
export { locale as "ja-easy" } from './ja_easy.js';
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/esm/libs/lodash.js
CHANGED
|
@@ -15,6 +15,9 @@ type Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {
|
|
|
15
15
|
type TextLinkComponent = <T extends ElementType = 'a'>(props: Props<T> & ElementProps<T> & ElementRefProps<T>) => ReturnType<FC>;
|
|
16
16
|
declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
17
17
|
size: {
|
|
18
|
+
XS: {
|
|
19
|
+
anchor: string;
|
|
20
|
+
};
|
|
18
21
|
S: {
|
|
19
22
|
anchor: string;
|
|
20
23
|
};
|
|
@@ -28,6 +31,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
28
31
|
suffixWrapper: string;
|
|
29
32
|
}, undefined, import("tailwind-variants/dist/config").TVConfig<{
|
|
30
33
|
size: {
|
|
34
|
+
XS: {
|
|
35
|
+
anchor: string;
|
|
36
|
+
};
|
|
31
37
|
S: {
|
|
32
38
|
anchor: string;
|
|
33
39
|
};
|
|
@@ -37,6 +43,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
37
43
|
};
|
|
38
44
|
}, {
|
|
39
45
|
size: {
|
|
46
|
+
XS: {
|
|
47
|
+
anchor: string;
|
|
48
|
+
};
|
|
40
49
|
S: {
|
|
41
50
|
anchor: string;
|
|
42
51
|
};
|
|
@@ -46,6 +55,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
46
55
|
};
|
|
47
56
|
}>, {
|
|
48
57
|
size: {
|
|
58
|
+
XS: {
|
|
59
|
+
anchor: string;
|
|
60
|
+
};
|
|
49
61
|
S: {
|
|
50
62
|
anchor: string;
|
|
51
63
|
};
|
|
@@ -59,6 +71,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
59
71
|
suffixWrapper: string;
|
|
60
72
|
}, import("tailwind-variants").TVReturnType<{
|
|
61
73
|
size: {
|
|
74
|
+
XS: {
|
|
75
|
+
anchor: string;
|
|
76
|
+
};
|
|
62
77
|
S: {
|
|
63
78
|
anchor: string;
|
|
64
79
|
};
|
|
@@ -72,6 +87,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
72
87
|
suffixWrapper: string;
|
|
73
88
|
}, undefined, import("tailwind-variants/dist/config").TVConfig<{
|
|
74
89
|
size: {
|
|
90
|
+
XS: {
|
|
91
|
+
anchor: string;
|
|
92
|
+
};
|
|
75
93
|
S: {
|
|
76
94
|
anchor: string;
|
|
77
95
|
};
|
|
@@ -81,6 +99,9 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
|
|
|
81
99
|
};
|
|
82
100
|
}, {
|
|
83
101
|
size: {
|
|
102
|
+
XS: {
|
|
103
|
+
anchor: string;
|
|
104
|
+
};
|
|
84
105
|
S: {
|
|
85
106
|
anchor: string;
|
|
86
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLink.js","sourceRoot":"","sources":["../../../src/components/TextLink/TextLink.tsx"],"names":[],"mappings":";;;;AAAA,iCAWc;AACd,yDAAyD;AAEzD,yDAAqD;AAwBrD,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,KAAK,EAAE;QACL,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;SAC1C;QACD,aAAa,EAAE,8BAA8B;QAC7C,aAAa,EAAE,8BAA8B;KAC9C;IACD,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,CAAC,EAAE;gBACD,MAAM,EAAE,aAAa;aACtB;YACD,CAAC,EAAE;gBACD,MAAM,EAAE,eAAe;aACxB;SACF;KACF;CACF,CAAC,CAAA;AACF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE,CAAA;AACrE,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAC9C,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAE9C,MAAM,cAAc,GAAsB,IAAA,kBAAU,EAClD,CACE,EACE,SAAS,EACT,IAAI,EACJ,M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AAO,OAAO,CAAA;QAChB,CAAC;QAED,OAAO,CAAC,CAAa,EAAE,EAAE;YACvB,CAAC,CAAC,cAAc,EAAE,CAAA;YAClB,OAAO,CAAC,CAAC,CAAC,CAAA;QACZ,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IAEnB,OAAO,CACL,wBAAC,MAAM,OACD,MAAM,EACV,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,eAAe,aAEzB,MAAM,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,MAAM,GAAQ,EAClE,QAAQ,EACR,YAAY,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,YAAY,GAAQ,IACxE,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAEY,QAAA,QAAQ,GAAG,IAAA,YAAI,EAAC,cAAc,CAA0B,CAAA","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from './OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"]}
|
|
1
|
+
{"version":3,"file":"TextLink.js","sourceRoot":"","sources":["../../../src/components/TextLink/TextLink.tsx"],"names":[],"mappings":";;;;AAAA,iCAWc;AACd,yDAAyD;AAEzD,yDAAqD;AAwBrD,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,KAAK,EAAE;QACL,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;SAC1C;QACD,aAAa,EAAE,8BAA8B;QAC7C,aAAa,EAAE,8BAA8B;KAC9C;IACD,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,MAAM,EAAE,aAAa;aACtB;YACD,CAAC,EAAE;gBACD,MAAM,EAAE,aAAa;aACtB;YACD,CAAC,EAAE;gBACD,MAAM,EAAE,eAAe;aACxB;SACF;KACF;CACF,CAAC,CAAA;AACF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE,CAAA;AACrE,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAC9C,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAE9C,MAAM,cAAc,GAAsB,IAAA,kBAAU,EAClD,CACE,EACE,SAAS,EACT,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,MAAM,EACmC,EAC9C,GAAuB,EACvB,EAAE;IACF,MAAM,MAAM,GAAG,SAAS,IAAI,GAAG,CAAA;IAC/B,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAChD,OAAO,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AAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,eAAe,aAEzB,MAAM,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,MAAM,GAAQ,EAClE,QAAQ,EACR,YAAY,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,YAAY,GAAQ,IACxE,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAEY,QAAA,QAAQ,GAAG,IAAA,YAAI,EAAC,cAAc,CAA0B,CAAA","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from './OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"]}
|
|
@@ -2,9 +2,11 @@ import { type FC, type PropsWithChildren } from 'react';
|
|
|
2
2
|
import { type Locale } from './localeMap';
|
|
3
3
|
declare const allLocaleKeys: Locale[];
|
|
4
4
|
type Props<AvailableLocales extends Locale[] = typeof allLocaleKeys> = PropsWithChildren<{
|
|
5
|
-
locale:
|
|
6
|
-
availableLocales?:
|
|
5
|
+
locale: string;
|
|
6
|
+
availableLocales?: string[];
|
|
7
|
+
_not_used_locale?: AvailableLocales[number];
|
|
8
|
+
_not_used_availableLocales?: AvailableLocales;
|
|
7
9
|
}>;
|
|
8
|
-
export declare const useAvailableLocales: () => ("pt" | "ja" | "
|
|
10
|
+
export declare const useAvailableLocales: () => ("pt" | "ja" | "en-us" | "id-id" | "vi" | "ko" | "zh-cn" | "zh-tw" | "ja-easy")[];
|
|
9
11
|
export declare const IntlProvider: <AvailableLocales extends Locale[] = typeof allLocaleKeys>({ availableLocales, locale, children, }: Props<AvailableLocales>) => ReturnType<FC>;
|
|
10
12
|
export {};
|
package/lib/intl/IntlProvider.js
CHANGED
|
@@ -46,10 +46,12 @@ const AvailableLocalesContext = (0, react_1.createContext)(allLocaleKeys);
|
|
|
46
46
|
const useAvailableLocales = () => (0, react_1.useContext)(AvailableLocalesContext);
|
|
47
47
|
exports.useAvailableLocales = useAvailableLocales;
|
|
48
48
|
const IntlProvider = ({ availableLocales, locale, children, }) => {
|
|
49
|
+
const convertedLocale = (0, localeMap_1.convertLang)(locale);
|
|
50
|
+
const convertedAvailableLocales = availableLocales?.map(localeMap_1.convertLang);
|
|
49
51
|
// プロダクト側でIntlProviderを使っている場合、プロダクト側のmessagesとマージして提供するためにContextから取得している
|
|
50
52
|
const intl = (0, react_1.useContext)(react_intl_1.IntlContext);
|
|
51
|
-
const actualMessages = (0, react_1.useMemo)(() => ({ ...intl?.messages, ...locales[
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(AvailableLocalesContext.Provider, { value:
|
|
53
|
+
const actualMessages = (0, react_1.useMemo)(() => ({ ...intl?.messages, ...locales[convertedLocale] }), [intl, convertedLocale]);
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(AvailableLocalesContext.Provider, { value: convertedAvailableLocales ?? allLocaleKeys, children: (0, jsx_runtime_1.jsx)(react_intl_1.IntlProvider, { locale: convertedLocale, messages: actualMessages, children: children }) }));
|
|
53
55
|
};
|
|
54
56
|
exports.IntlProvider = IntlProvider;
|
|
55
57
|
//# sourceMappingURL=IntlProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../src/intl/IntlProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,iCAA2F;AAC3F,2CAA2E;AAE3E,
|
|
1
|
+
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../src/intl/IntlProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEZ,iCAA2F;AAC3F,2CAA2E;AAE3E,2CAAiE;AACjE,mDAAoC;AAEpC,uFAAuF;AACvF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAS,CAAa,CAAA;AAWxD,MAAM,uBAAuB,GAAG,IAAA,qBAAa,EAAW,aAAa,CAAC,CAAA;AAE/D,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAA,kBAAU,EAAC,uBAAuB,CAAC,CAAA;AAA/D,QAAA,mBAAmB,uBAA4C;AAErE,MAAM,YAAY,GAAG,CAA2D,EACrF,gBAAgB,EAChB,MAAM,EACN,QAAQ,GACgB,EAAkB,EAAE;IAC5C,MAAM,eAAe,GAAG,IAAA,uBAAW,EAAC,MAAM,CAAC,CAAA;IAC3C,MAAM,yBAAyB,GAAG,gBAAgB,EAAE,GAAG,CAAC,uBAAW,CAAC,CAAA;IAEpE,0EAA0E;IAC1E,MAAM,IAAI,GAAG,IAAA,kBAAU,EAAC,wBAAW,CAAC,CAAA;IACpC,MAAM,cAAc,GAAG,IAAA,eAAO,EAC5B,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,EAC1D,CAAC,IAAI,EAAE,eAAe,CAAC,CACxB,CAAA;IAED,OAAO,CACL,uBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,yBAAyB,IAAI,aAAa,YACjF,uBAAC,yBAAiB,IAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,YACjE,QAAQ,GACS,GACa,CACpC,CAAA;AACH,CAAC,CAAA;AAtBY,QAAA,YAAY,gBAsBxB","sourcesContent":["'use client'\n\nimport { type FC, type PropsWithChildren, createContext, useContext, useMemo } from 'react'\nimport { IntlContext, IntlProvider as ReactIntlProvider } from 'react-intl'\n\nimport { type Locale, convertLang, localeMap } from './localeMap'\nimport * as locales from './locales'\n\n// Object.keys は常に string[] を返却するが、locales は実行時に変更されないため、as 型キャストを使用することは自明に安全なので使用している\nconst allLocaleKeys = Object.keys(localeMap) as Locale[]\n\ntype Props<AvailableLocales extends Locale[] = typeof allLocaleKeys> = PropsWithChildren<{\n locale: string\n availableLocales?: string[]\n // ↑ プロダクト側と smarthr-ui の言語コードの揺れに対応するため、一旦 string, string[] で受け取れるようにする\n // ↓ 本来は AvailableLocales[number], AvailableLocales で受け取りたいが、プロダクトと smarthr-ui での言語コード統一が終わるまで使えない\n _not_used_locale?: AvailableLocales[number]\n _not_used_availableLocales?: AvailableLocales\n}>\n\nconst AvailableLocalesContext = createContext<Locale[]>(allLocaleKeys)\n\nexport const useAvailableLocales = () => useContext(AvailableLocalesContext)\n\nexport const IntlProvider = <AvailableLocales extends Locale[] = typeof allLocaleKeys>({\n availableLocales,\n locale,\n children,\n}: Props<AvailableLocales>): ReturnType<FC> => {\n const convertedLocale = convertLang(locale)\n const convertedAvailableLocales = availableLocales?.map(convertLang)\n\n // プロダクト側でIntlProviderを使っている場合、プロダクト側のmessagesとマージして提供するためにContextから取得している\n const intl = useContext(IntlContext)\n const actualMessages = useMemo(\n () => ({ ...intl?.messages, ...locales[convertedLocale] }),\n [intl, convertedLocale],\n )\n\n return (\n <AvailableLocalesContext.Provider value={convertedAvailableLocales ?? allLocaleKeys}>\n <ReactIntlProvider locale={convertedLocale} messages={actualMessages}>\n {children}\n </ReactIntlProvider>\n </AvailableLocalesContext.Provider>\n )\n}\n"]}
|
package/lib/intl/localeMap.d.ts
CHANGED
package/lib/intl/localeMap.js
CHANGED
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localeMap = void 0;
|
|
3
|
+
exports.convertLang = exports.localeMap = void 0;
|
|
4
|
+
/*
|
|
5
|
+
localeMap は LanguageSwitcher で言語切替をするためにも使用されます。そのため、このオブジェクトの並び順が言語切替 UI の並び順にも反映されます。
|
|
6
|
+
配置ロジック(新しい言語追加時の判断軸)
|
|
7
|
+
・認知負荷を減らす:利用頻度を考慮し、ユーザーが直感的に探せるようにする。
|
|
8
|
+
・見栄えを考慮:アルファベット系・漢字系といった系統を意識して並べ、視覚的にも整理する。
|
|
9
|
+
|
|
10
|
+
下記の設計を基準にすれば、新しい言語を追加する際も既存の分類に沿って挿入するだけで済み、秩序を維持できる。
|
|
11
|
+
1. 日本語:デフォルト言語のため、常に最上位。
|
|
12
|
+
2. 英語:i18n文脈における事実上のデフォルト言語として、常に第二位。
|
|
13
|
+
3. 他のアルファベット系言語(インドネシア語、ポルトガル語、ベトナム語):常に中央に配置し、アルファベット順で整列。
|
|
14
|
+
4. 韓国語:アルファベット系と漢字系の橋渡し(トランジション)として配置。
|
|
15
|
+
5. 中国語(簡体字・繁体字):ユーザー数が多く安定している漢字系言語であるため、常に後半にまとめて配置。
|
|
16
|
+
6. やさしい日本語:日本語の派生であり、補助的な言語という位置づけを示すため、常に最後に配置。
|
|
17
|
+
*/
|
|
4
18
|
exports.localeMap = {
|
|
5
19
|
ja: '日本語',
|
|
6
|
-
'ja-easy': 'やさしい日本語',
|
|
7
20
|
'en-us': 'English',
|
|
8
|
-
|
|
21
|
+
'id-id': 'Bahasa Indonesia',
|
|
9
22
|
pt: 'Português',
|
|
10
23
|
vi: 'Tiếng Việt',
|
|
24
|
+
ko: '한국어',
|
|
11
25
|
'zh-cn': '简体中文',
|
|
12
26
|
'zh-tw': '繁體中文',
|
|
13
|
-
'
|
|
27
|
+
'ja-easy': 'やさしい日本語',
|
|
28
|
+
};
|
|
29
|
+
// 渡される言語の揺れを許容して smarthr-ui で使っている言語コードに変換する
|
|
30
|
+
const convertLang = (rawLang) => {
|
|
31
|
+
const lang = rawLang.toLowerCase().replace(/_/g, '-');
|
|
32
|
+
// 日本語とやさしい日本語の対応
|
|
33
|
+
if (lang.startsWith('ja')) {
|
|
34
|
+
if (lang.includes('-easy')) {
|
|
35
|
+
return 'ja-easy';
|
|
36
|
+
}
|
|
37
|
+
return 'ja';
|
|
38
|
+
}
|
|
39
|
+
// 简体中文と繁體中文
|
|
40
|
+
if (lang.startsWith('zh')) {
|
|
41
|
+
const regionOrScript = lang.split('-')[1] ?? '';
|
|
42
|
+
if (['tw', 'hant'].includes(regionOrScript)) {
|
|
43
|
+
return 'zh-tw';
|
|
44
|
+
}
|
|
45
|
+
return 'zh-cn';
|
|
46
|
+
}
|
|
47
|
+
if (lang.startsWith('en'))
|
|
48
|
+
return 'en-us'; // 英語
|
|
49
|
+
if (lang.startsWith('pt'))
|
|
50
|
+
return 'pt'; // ポルトガル語
|
|
51
|
+
if (lang.startsWith('vi'))
|
|
52
|
+
return 'vi'; // ベトナム語
|
|
53
|
+
if (lang.startsWith('ko'))
|
|
54
|
+
return 'ko'; // 韓国語
|
|
55
|
+
if (lang.startsWith('id'))
|
|
56
|
+
return 'id-id'; // インドネシア語
|
|
57
|
+
// 何にも一致しない場合はフォールバックとして 'ja' を返す
|
|
58
|
+
return 'ja';
|
|
14
59
|
};
|
|
60
|
+
exports.convertLang = convertLang;
|
|
15
61
|
//# sourceMappingURL=localeMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMap.js","sourceRoot":"","sources":["../../src/intl/localeMap.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"localeMap.js","sourceRoot":"","sources":["../../src/intl/localeMap.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;EAaE;AACW,QAAA,SAAS,GAA2B;IAC/C,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,kBAAkB;IAC3B,EAAE,EAAE,WAAW;IACf,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,SAAS;CACrB,CAAA;AAED,6CAA6C;AACtC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAwB,EAAE;IACnE,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAErD,iBAAiB;IACjB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;IACZ,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QAE/C,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC5C,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAA,CAAC,KAAK;IAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA,CAAC,SAAS;IAChD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA,CAAC,QAAQ;IAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA,CAAC,MAAM;IAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAA,CAAC,UAAU;IAEpD,iCAAiC;IACjC,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AA/BY,QAAA,WAAW,eA+BvB","sourcesContent":["import type * as locales from './locales'\n\nexport type Locale = keyof typeof locales\n\n/*\n localeMap は LanguageSwitcher で言語切替をするためにも使用されます。そのため、このオブジェクトの並び順が言語切替 UI の並び順にも反映されます。\n 配置ロジック(新しい言語追加時の判断軸)\n ・認知負荷を減らす:利用頻度を考慮し、ユーザーが直感的に探せるようにする。\n ・見栄えを考慮:アルファベット系・漢字系といった系統を意識して並べ、視覚的にも整理する。\n\n 下記の設計を基準にすれば、新しい言語を追加する際も既存の分類に沿って挿入するだけで済み、秩序を維持できる。\n 1. 日本語:デフォルト言語のため、常に最上位。\n 2. 英語:i18n文脈における事実上のデフォルト言語として、常に第二位。\n 3. 他のアルファベット系言語(インドネシア語、ポルトガル語、ベトナム語):常に中央に配置し、アルファベット順で整列。\n 4. 韓国語:アルファベット系と漢字系の橋渡し(トランジション)として配置。\n 5. 中国語(簡体字・繁体字):ユーザー数が多く安定している漢字系言語であるため、常に後半にまとめて配置。\n 6. やさしい日本語:日本語の派生であり、補助的な言語という位置づけを示すため、常に最後に配置。\n*/\nexport const localeMap: Record<Locale, string> = {\n ja: '日本語',\n 'en-us': 'English',\n 'id-id': 'Bahasa Indonesia',\n pt: 'Português',\n vi: 'Tiếng Việt',\n ko: '한국어',\n 'zh-cn': '简体中文',\n 'zh-tw': '繁體中文',\n 'ja-easy': 'やさしい日本語',\n}\n\n// 渡される言語の揺れを許容して smarthr-ui で使っている言語コードに変換する\nexport const convertLang = (rawLang: string): keyof typeof locales => {\n const lang = rawLang.toLowerCase().replace(/_/g, '-')\n\n // 日本語とやさしい日本語の対応\n if (lang.startsWith('ja')) {\n if (lang.includes('-easy')) {\n return 'ja-easy'\n }\n\n return 'ja'\n }\n\n // 简体中文と繁體中文\n if (lang.startsWith('zh')) {\n const regionOrScript = lang.split('-')[1] ?? ''\n\n if (['tw', 'hant'].includes(regionOrScript)) {\n return 'zh-tw'\n }\n\n return 'zh-cn'\n }\n\n if (lang.startsWith('en')) return 'en-us' // 英語\n if (lang.startsWith('pt')) return 'pt' // ポルトガル語\n if (lang.startsWith('vi')) return 'vi' // ベトナム語\n if (lang.startsWith('ko')) return 'ko' // 韓国語\n if (lang.startsWith('id')) return 'id-id' // インドネシア語\n\n // 何にも一致しない場合はフォールバックとして 'ja' を返す\n return 'ja'\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { locale as ja } from './ja';
|
|
2
|
-
export { locale as 'ja-easy' } from './ja_easy';
|
|
3
2
|
export { locale as 'en-us' } from './en_us';
|
|
4
|
-
export { locale as
|
|
3
|
+
export { locale as 'id-id' } from './id_id';
|
|
5
4
|
export { locale as pt } from './pt_br';
|
|
6
5
|
export { locale as vi } from './vi_vn';
|
|
6
|
+
export { locale as ko } from './ko_kr';
|
|
7
7
|
export { locale as 'zh-cn' } from './zh_hans_cn';
|
|
8
8
|
export { locale as 'zh-tw' } from './zh_hant_tw';
|
|
9
|
-
export { locale as '
|
|
9
|
+
export { locale as 'ja-easy' } from './ja_easy';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports["
|
|
3
|
+
exports["ja-easy"] = exports["zh-tw"] = exports["zh-cn"] = exports.ko = exports.vi = exports.pt = exports["id-id"] = exports["en-us"] = exports.ja = void 0;
|
|
4
4
|
var ja_1 = require("./ja");
|
|
5
5
|
Object.defineProperty(exports, "ja", { enumerable: true, get: function () { return ja_1.locale; } });
|
|
6
|
-
var ja_easy_1 = require("./ja_easy");
|
|
7
|
-
Object.defineProperty(exports, "ja-easy", { enumerable: true, get: function () { return ja_easy_1.locale; } });
|
|
8
6
|
var en_us_1 = require("./en_us");
|
|
9
7
|
Object.defineProperty(exports, "en-us", { enumerable: true, get: function () { return en_us_1.locale; } });
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "
|
|
8
|
+
var id_id_1 = require("./id_id");
|
|
9
|
+
Object.defineProperty(exports, "id-id", { enumerable: true, get: function () { return id_id_1.locale; } });
|
|
12
10
|
var pt_br_1 = require("./pt_br");
|
|
13
11
|
Object.defineProperty(exports, "pt", { enumerable: true, get: function () { return pt_br_1.locale; } });
|
|
14
12
|
var vi_vn_1 = require("./vi_vn");
|
|
15
13
|
Object.defineProperty(exports, "vi", { enumerable: true, get: function () { return vi_vn_1.locale; } });
|
|
14
|
+
var ko_kr_1 = require("./ko_kr");
|
|
15
|
+
Object.defineProperty(exports, "ko", { enumerable: true, get: function () { return ko_kr_1.locale; } });
|
|
16
16
|
var zh_hans_cn_1 = require("./zh_hans_cn");
|
|
17
17
|
Object.defineProperty(exports, "zh-cn", { enumerable: true, get: function () { return zh_hans_cn_1.locale; } });
|
|
18
18
|
var zh_hant_tw_1 = require("./zh_hant_tw");
|
|
19
19
|
Object.defineProperty(exports, "zh-tw", { enumerable: true, get: function () { return zh_hant_tw_1.locale; } });
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "
|
|
20
|
+
var ja_easy_1 = require("./ja_easy");
|
|
21
|
+
Object.defineProperty(exports, "ja-easy", { enumerable: true, get: function () { return ja_easy_1.locale; } });
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/intl/locales/index.ts"],"names":[],"mappings":";;;AAAA,2BAAmC;AAA1B,wFAAA,MAAM,OAAM;AACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/intl/locales/index.ts"],"names":[],"mappings":";;;AAAA,2BAAmC;AAA1B,wFAAA,MAAM,OAAM;AACrB,iCAA2C;AAAlC,8FAAA,MAAM,OAAW;AAC1B,iCAA2C;AAAlC,8FAAA,MAAM,OAAW;AAC1B,iCAAsC;AAA7B,2FAAA,MAAM,OAAM;AACrB,iCAAsC;AAA7B,2FAAA,MAAM,OAAM;AACrB,iCAAsC;AAA7B,2FAAA,MAAM,OAAM;AACrB,2CAAgD;AAAvC,mGAAA,MAAM,OAAW;AAC1B,2CAAgD;AAAvC,mGAAA,MAAM,OAAW;AAC1B,qCAA+C;AAAtC,kGAAA,MAAM,OAAa","sourcesContent":["export { locale as ja } from './ja'\nexport { locale as 'en-us' } from './en_us'\nexport { locale as 'id-id' } from './id_id'\nexport { locale as pt } from './pt_br'\nexport { locale as vi } from './vi_vn'\nexport { locale as ko } from './ko_kr'\nexport { locale as 'zh-cn' } from './zh_hans_cn'\nexport { locale as 'zh-tw' } from './zh_hant_tw'\nexport { locale as 'ja-easy' } from './ja_easy'\n"]}
|