@yimingliao/cms 0.0.149 → 0.0.151
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/export/client/components/index.js +22 -10
- package/dist/export/client/shadcn/index.js +2 -0
- package/dist/src/client/interfaces/components/resources/file/file-card.js +3 -5
- package/dist/src/client/interfaces/components/resources/file/file-list.js +3 -5
- package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +3 -5
- package/dist/src/client/interfaces/components/resources/file/type-buttons.js +3 -5
- package/dist/src/client/interfaces/components/shadcn/sonner.js +32 -0
- package/dist/src/client/interfaces/components/shadcn/tabs.js +72 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +3 -0
- package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +3 -0
- package/dist/src/client/interfaces/components/ui/buttons/button.js +3 -0
- package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +3 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +3 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +3 -0
- package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +3 -0
- package/dist/src/client/interfaces/components/ui/display/array-list.js +3 -0
- package/dist/src/client/interfaces/components/ui/display/badge.js +3 -0
- package/dist/src/client/interfaces/components/ui/display/object-array-list.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +3 -0
- package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +3 -0
- package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +3 -0
- package/dist/src/client/interfaces/components/ui/form/field-body.js +3 -0
- package/dist/src/client/interfaces/components/ui/form/field.js +3 -0
- package/dist/src/client/interfaces/components/ui/i18n/display/i18n-array-display.js +56 -0
- package/dist/src/client/interfaces/components/ui/i18n/display/i18n-display.js +69 -0
- package/dist/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.js +64 -0
- package/dist/src/client/interfaces/components/ui/i18n/i18n-tabs-wrapper.js +52 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.js +164 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.js +95 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.js +104 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-input.js +93 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.js +126 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.js +94 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.js +165 -0
- package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.js +93 -0
- package/dist/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.js +17 -0
- package/dist/src/client/interfaces/components/ui/i18n/utils/get-translation-value.js +16 -0
- package/dist/src/client/interfaces/components/ui/i18n/utils/update-translations.js +14 -0
- package/dist/src/client/interfaces/components/ui/inputs/array-input.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/input.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/password-input.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/search-input.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/select.js +3 -0
- package/dist/src/client/interfaces/components/ui/inputs/textarea.js +3 -0
- package/dist/src/client/interfaces/components/ui/layouts/auth-skeleton.js +3 -0
- package/dist/src/client/interfaces/components/ui/layouts/dashboard-skeleton.js +3 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +3 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +3 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +1 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +1 -0
- package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +2 -0
- package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +3 -0
- package/dist/src/client/interfaces/pages/auth/change-password/page.js +3 -5
- package/dist/src/client/interfaces/pages/auth/email-unverified/page.js +1 -1
- package/dist/src/client/interfaces/pages/auth/forgot-password/page.js +3 -5
- package/dist/src/client/interfaces/pages/auth/layout.js +3 -4
- package/dist/src/client/interfaces/pages/auth/reset-password/page.js +3 -5
- package/dist/src/client/interfaces/pages/auth/sign-in/page.js +1 -1
- package/dist/src/client/interfaces/pages/auth/verify-email/page.js +3 -0
- package/dist/src/client/interfaces/pages/dashboard/layout.js +4 -5
- package/dist/types/export/client/components/index.d.ts +3 -1
- package/dist/types/export/client/components/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/index.d.ts +1 -1
- package/dist/types/src/client/interfaces/components/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/shadcn/index.d.ts +2 -0
- package/dist/types/src/client/interfaces/components/shadcn/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/shadcn/sonner.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/shadcn/sonner.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/shadcn/tabs.d.ts +8 -0
- package/dist/types/src/client/interfaces/components/shadcn/tabs.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/features/index.d.ts +0 -1
- package/dist/types/src/client/interfaces/components/ui/features/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-array-display.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-array-display.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-display.d.ts +12 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-display.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.d.ts +15 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/index.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/display/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/i18n-tabs-wrapper.d.ts +13 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/i18n-tabs-wrapper.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/index.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.d.ts +12 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.d.ts +14 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-input.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.d.ts +15 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/index.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/inputs/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.d.ts +7 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-translation-value.d.ts +3 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-translation-value.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/update-translations.d.ts +3 -0
- package/dist/types/src/client/interfaces/components/ui/i18n/utils/update-translations.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/ui/index.d.ts +1 -2
- package/dist/types/src/client/interfaces/components/ui/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/ui/layouts/index.d.ts +2 -2
- package/dist/types/src/client/interfaces/components/ui/layouts/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/pages/dashboard/layout.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import 'mime-types';
|
|
5
|
+
import { findTranslation } from '../../../../../../shared/translation/find-translation.js';
|
|
6
|
+
import { ensureArray } from '../../../../../../shared/utils/ensure-array.js';
|
|
7
|
+
import { ArrayList } from '../../display/array-list.js';
|
|
8
|
+
import 'ua-parser-js';
|
|
9
|
+
import 'clsx';
|
|
10
|
+
import 'tailwind-merge';
|
|
11
|
+
import 'next/navigation';
|
|
12
|
+
import '@radix-ui/react-avatar';
|
|
13
|
+
import '../../../shadcn/badge.js';
|
|
14
|
+
import '../../../shadcn/button.js';
|
|
15
|
+
import '@radix-ui/react-collapsible';
|
|
16
|
+
import '@radix-ui/react-dialog';
|
|
17
|
+
import 'lucide-react';
|
|
18
|
+
import '@radix-ui/react-dropdown-menu';
|
|
19
|
+
import '../../../shadcn/input-group.js';
|
|
20
|
+
import '@radix-ui/react-label';
|
|
21
|
+
import '@radix-ui/react-select';
|
|
22
|
+
import '@radix-ui/react-separator';
|
|
23
|
+
import '../../../shadcn/sidebar.js';
|
|
24
|
+
import 'next-themes';
|
|
25
|
+
import 'sonner';
|
|
26
|
+
import '@radix-ui/react-tabs';
|
|
27
|
+
import '@radix-ui/react-tooltip';
|
|
28
|
+
import 'next/link';
|
|
29
|
+
import '../../../../../../constants/paths/auth.js';
|
|
30
|
+
import '../../../../../../constants/paths/main.js';
|
|
31
|
+
import '../../../../../../constants/paths/resources.js';
|
|
32
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
33
|
+
import 'intor/react';
|
|
34
|
+
|
|
35
|
+
function createI18nArrayDisplay({
|
|
36
|
+
I18nTabsWrapper,
|
|
37
|
+
locales
|
|
38
|
+
}) {
|
|
39
|
+
return function I18nArrayDisplay({
|
|
40
|
+
fieldName = "",
|
|
41
|
+
translations,
|
|
42
|
+
isLoading
|
|
43
|
+
}) {
|
|
44
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
45
|
+
return /* @__PURE__ */ jsx(I18nTabsWrapper, { setCurrentLocale, children: locales.map((locale) => {
|
|
46
|
+
const translation = findTranslation(translations, locale, []);
|
|
47
|
+
const values = ensureArray(translation?.[fieldName]);
|
|
48
|
+
if (currentLocale === locale) {
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx(ArrayList, { values, isLoading }) }, locale);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}) });
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { createI18nArrayDisplay };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import 'mime-types';
|
|
5
|
+
import { findTranslation } from '../../../../../../shared/translation/find-translation.js';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
8
|
+
import 'next/navigation';
|
|
9
|
+
import 'next/link';
|
|
10
|
+
import '../../../../../../constants/paths/auth.js';
|
|
11
|
+
import '../../../../../../constants/paths/main.js';
|
|
12
|
+
import '../../../../../../constants/paths/resources.js';
|
|
13
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
14
|
+
import '@radix-ui/react-avatar';
|
|
15
|
+
import '../../../shadcn/badge.js';
|
|
16
|
+
import '../../../shadcn/button.js';
|
|
17
|
+
import '@radix-ui/react-collapsible';
|
|
18
|
+
import '@radix-ui/react-dialog';
|
|
19
|
+
import 'lucide-react';
|
|
20
|
+
import '@radix-ui/react-dropdown-menu';
|
|
21
|
+
import '../../../shadcn/input-group.js';
|
|
22
|
+
import '@radix-ui/react-label';
|
|
23
|
+
import '@radix-ui/react-select';
|
|
24
|
+
import '@radix-ui/react-separator';
|
|
25
|
+
import '../../../shadcn/sidebar.js';
|
|
26
|
+
import 'next-themes';
|
|
27
|
+
import 'sonner';
|
|
28
|
+
import '@radix-ui/react-tabs';
|
|
29
|
+
import '@radix-ui/react-tooltip';
|
|
30
|
+
import { FieldBody } from '../../form/field-body.js';
|
|
31
|
+
import 'intor/react';
|
|
32
|
+
import { HtmlDisplay } from '../../display/html-display.js';
|
|
33
|
+
|
|
34
|
+
function createI18nDisplay({
|
|
35
|
+
I18nTabsWrapper,
|
|
36
|
+
locales
|
|
37
|
+
}) {
|
|
38
|
+
return function I18nDisplay({
|
|
39
|
+
fieldName = "",
|
|
40
|
+
translations,
|
|
41
|
+
isLoading,
|
|
42
|
+
isHtml = false,
|
|
43
|
+
// For Editor using
|
|
44
|
+
className,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
48
|
+
return /* @__PURE__ */ jsx(I18nTabsWrapper, { setCurrentLocale, children: locales.map((locale) => {
|
|
49
|
+
const translation = findTranslation(translations, locale);
|
|
50
|
+
const value = translation?.[fieldName];
|
|
51
|
+
if (currentLocale === locale) {
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
FieldBody,
|
|
54
|
+
{
|
|
55
|
+
isLoading,
|
|
56
|
+
isEmpty: !value,
|
|
57
|
+
className: cn(className, "whitespace-pre-line"),
|
|
58
|
+
...props,
|
|
59
|
+
children: !isHtml ? value : /* @__PURE__ */ jsx(HtmlDisplay, { html: value })
|
|
60
|
+
},
|
|
61
|
+
locale
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}) });
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { createI18nDisplay };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import 'mime-types';
|
|
5
|
+
import { findTranslation } from '../../../../../../shared/translation/find-translation.js';
|
|
6
|
+
import { ensureArray } from '../../../../../../shared/utils/ensure-array.js';
|
|
7
|
+
import 'next/link';
|
|
8
|
+
import '../../../../../../constants/paths/auth.js';
|
|
9
|
+
import '../../../../../../constants/paths/main.js';
|
|
10
|
+
import '../../../../../../constants/paths/resources.js';
|
|
11
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
12
|
+
import 'ua-parser-js';
|
|
13
|
+
import 'clsx';
|
|
14
|
+
import 'tailwind-merge';
|
|
15
|
+
import 'next/navigation';
|
|
16
|
+
import '@radix-ui/react-avatar';
|
|
17
|
+
import '../../../shadcn/badge.js';
|
|
18
|
+
import '../../../shadcn/button.js';
|
|
19
|
+
import '@radix-ui/react-collapsible';
|
|
20
|
+
import '@radix-ui/react-dialog';
|
|
21
|
+
import 'lucide-react';
|
|
22
|
+
import '@radix-ui/react-dropdown-menu';
|
|
23
|
+
import '../../../shadcn/input-group.js';
|
|
24
|
+
import '@radix-ui/react-label';
|
|
25
|
+
import '@radix-ui/react-select';
|
|
26
|
+
import '@radix-ui/react-separator';
|
|
27
|
+
import '../../../shadcn/sidebar.js';
|
|
28
|
+
import 'next-themes';
|
|
29
|
+
import 'sonner';
|
|
30
|
+
import '@radix-ui/react-tabs';
|
|
31
|
+
import '@radix-ui/react-tooltip';
|
|
32
|
+
import 'intor/react';
|
|
33
|
+
import { ObjectArrayList } from '../../display/object-array-list.js';
|
|
34
|
+
|
|
35
|
+
function createI18nObjectArrayDisplay({
|
|
36
|
+
I18nTabsWrapper,
|
|
37
|
+
locales
|
|
38
|
+
}) {
|
|
39
|
+
return function I18nObjectArrayDisplay({
|
|
40
|
+
fieldName = "",
|
|
41
|
+
translations,
|
|
42
|
+
fields,
|
|
43
|
+
isLoading
|
|
44
|
+
}) {
|
|
45
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
46
|
+
return /* @__PURE__ */ jsx(I18nTabsWrapper, { setCurrentLocale, children: locales.map((locale) => {
|
|
47
|
+
const translation = findTranslation(translations, locale, []);
|
|
48
|
+
const items = ensureArray(translation?.[fieldName]);
|
|
49
|
+
if (currentLocale === locale) {
|
|
50
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
51
|
+
ObjectArrayList,
|
|
52
|
+
{
|
|
53
|
+
items,
|
|
54
|
+
fields: ensureArray(fields),
|
|
55
|
+
isLoading
|
|
56
|
+
}
|
|
57
|
+
) }, locale);
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}) });
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { createI18nObjectArrayDisplay };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'ua-parser-js';
|
|
4
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
5
|
+
import 'next/navigation';
|
|
6
|
+
import '@radix-ui/react-avatar';
|
|
7
|
+
import '../../shadcn/badge.js';
|
|
8
|
+
import '../../shadcn/button.js';
|
|
9
|
+
import '@radix-ui/react-collapsible';
|
|
10
|
+
import '@radix-ui/react-dialog';
|
|
11
|
+
import 'lucide-react';
|
|
12
|
+
import '@radix-ui/react-dropdown-menu';
|
|
13
|
+
import '../../shadcn/input-group.js';
|
|
14
|
+
import '@radix-ui/react-label';
|
|
15
|
+
import '@radix-ui/react-select';
|
|
16
|
+
import '@radix-ui/react-separator';
|
|
17
|
+
import '../../shadcn/sidebar.js';
|
|
18
|
+
import 'next-themes';
|
|
19
|
+
import 'sonner';
|
|
20
|
+
import { Tabs, TabsList, TabsTrigger } from '../../shadcn/tabs.js';
|
|
21
|
+
import '@radix-ui/react-tooltip';
|
|
22
|
+
|
|
23
|
+
function createI18nTabsWrapper({
|
|
24
|
+
enabled,
|
|
25
|
+
locales,
|
|
26
|
+
localeDisplay
|
|
27
|
+
}) {
|
|
28
|
+
return function I18nTabsWrapper({
|
|
29
|
+
setCurrentLocale,
|
|
30
|
+
errorLocales = [],
|
|
31
|
+
children
|
|
32
|
+
}) {
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col gap-1", children: [
|
|
34
|
+
locales.length > 1 && enabled && /* @__PURE__ */ jsx(Tabs, { defaultValue: locales[0] ?? "", className: "w-fit", children: /* @__PURE__ */ jsx(TabsList, { children: locales.map((locale) => {
|
|
35
|
+
const isError = errorLocales.includes(locale);
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
TabsTrigger,
|
|
38
|
+
{
|
|
39
|
+
value: locale,
|
|
40
|
+
onClick: () => setCurrentLocale(locale),
|
|
41
|
+
className: cn(isError && "text-destructive"),
|
|
42
|
+
children: localeDisplay[locale]
|
|
43
|
+
},
|
|
44
|
+
locale
|
|
45
|
+
);
|
|
46
|
+
}) }) }),
|
|
47
|
+
children
|
|
48
|
+
] });
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { createI18nTabsWrapper };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { CircleX, CirclePlus } from 'lucide-react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import 'ua-parser-js';
|
|
6
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
7
|
+
import 'next/navigation';
|
|
8
|
+
import '@radix-ui/react-avatar';
|
|
9
|
+
import '../../../shadcn/badge.js';
|
|
10
|
+
import '../../../shadcn/button.js';
|
|
11
|
+
import '@radix-ui/react-collapsible';
|
|
12
|
+
import '@radix-ui/react-dialog';
|
|
13
|
+
import '@radix-ui/react-dropdown-menu';
|
|
14
|
+
import '../../../shadcn/input-group.js';
|
|
15
|
+
import '@radix-ui/react-label';
|
|
16
|
+
import '@radix-ui/react-select';
|
|
17
|
+
import { Separator } from '../../../shadcn/separator.js';
|
|
18
|
+
import '../../../shadcn/sidebar.js';
|
|
19
|
+
import 'next-themes';
|
|
20
|
+
import 'sonner';
|
|
21
|
+
import '@radix-ui/react-tabs';
|
|
22
|
+
import '@radix-ui/react-tooltip';
|
|
23
|
+
import { Button } from '../../buttons/button.js';
|
|
24
|
+
import 'intor/react';
|
|
25
|
+
import { Textarea } from '../../inputs/textarea.js';
|
|
26
|
+
import { getErrorsByLocales } from '../utils/get-errors-by-locales.js';
|
|
27
|
+
import { getTranslationValue } from '../utils/get-translation-value.js';
|
|
28
|
+
import { updateTranslations } from '../utils/update-translations.js';
|
|
29
|
+
|
|
30
|
+
function createI18nArrayInput({
|
|
31
|
+
I18nTabsWrapper,
|
|
32
|
+
locales
|
|
33
|
+
}) {
|
|
34
|
+
return function I18nArrayInput({
|
|
35
|
+
translations,
|
|
36
|
+
fieldName,
|
|
37
|
+
setFormData,
|
|
38
|
+
isLoading = false,
|
|
39
|
+
isDisabled = false,
|
|
40
|
+
isResizable = false,
|
|
41
|
+
errors = [],
|
|
42
|
+
...props
|
|
43
|
+
}) {
|
|
44
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
45
|
+
const errorsByLocales = getErrorsByLocales(
|
|
46
|
+
locales,
|
|
47
|
+
errors,
|
|
48
|
+
translations,
|
|
49
|
+
fieldName
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
I18nTabsWrapper,
|
|
53
|
+
{
|
|
54
|
+
setCurrentLocale,
|
|
55
|
+
errorLocales: errorsByLocales.map((e) => e.locale),
|
|
56
|
+
children: locales.map((locale) => {
|
|
57
|
+
const rawValue = getTranslationValue(
|
|
58
|
+
translations,
|
|
59
|
+
locale,
|
|
60
|
+
fieldName
|
|
61
|
+
);
|
|
62
|
+
const values = Array.isArray(rawValue) && rawValue.length > 0 ? rawValue.map(String) : [""];
|
|
63
|
+
const errorIndexes = new Set(
|
|
64
|
+
errorsByLocales.filter((e) => e.locale === locale).map((e) => e.index).filter((i) => i !== void 0)
|
|
65
|
+
);
|
|
66
|
+
if (currentLocale === locale) {
|
|
67
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: values.map((value, index) => {
|
|
68
|
+
const isError = errorIndexes.has(index);
|
|
69
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-0 left-0 z-10 h-full", children: [
|
|
71
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-[38px] text-center text-sm opacity-50", children: Array.isArray(rawValue) && rawValue.length === 0 ? "0" : index + 1 }),
|
|
72
|
+
/* @__PURE__ */ jsx(Separator, { orientation: "vertical" })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
Textarea,
|
|
76
|
+
{
|
|
77
|
+
disabled: isDisabled,
|
|
78
|
+
placeholder: isLoading ? "" : props.placeholder,
|
|
79
|
+
value,
|
|
80
|
+
onChange: (e) => {
|
|
81
|
+
if (!setFormData || !fieldName) return;
|
|
82
|
+
const copy = [...values];
|
|
83
|
+
copy[index] = e.target.value;
|
|
84
|
+
setFormData((prev) => {
|
|
85
|
+
const updated = updateTranslations(
|
|
86
|
+
prev["translations"],
|
|
87
|
+
currentLocale,
|
|
88
|
+
fieldName,
|
|
89
|
+
copy
|
|
90
|
+
);
|
|
91
|
+
return { ...prev, translations: updated };
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
onKeyDown: (e) => {
|
|
95
|
+
if (e.key === "Enter" && !isResizable) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
isError,
|
|
100
|
+
className: cn(
|
|
101
|
+
"pr-18 pl-14",
|
|
102
|
+
!isResizable && "resize-none"
|
|
103
|
+
),
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-[3px] right-[3px] gap-1", children: [
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Button,
|
|
110
|
+
{
|
|
111
|
+
variant: "outline",
|
|
112
|
+
type: "button",
|
|
113
|
+
size: "icon-sm",
|
|
114
|
+
onClick: () => {
|
|
115
|
+
if (!setFormData || !fieldName) return;
|
|
116
|
+
const copy = values.filter((_, i) => i !== index);
|
|
117
|
+
setFormData((prev) => {
|
|
118
|
+
const updated = updateTranslations(
|
|
119
|
+
prev["translations"],
|
|
120
|
+
currentLocale,
|
|
121
|
+
fieldName,
|
|
122
|
+
copy
|
|
123
|
+
);
|
|
124
|
+
return { ...prev, translations: updated };
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ jsx(CircleX, { className: "text-destructive" })
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
Button,
|
|
132
|
+
{
|
|
133
|
+
variant: "outline",
|
|
134
|
+
type: "button",
|
|
135
|
+
size: "icon-sm",
|
|
136
|
+
onClick: () => {
|
|
137
|
+
if (!setFormData || !fieldName) return;
|
|
138
|
+
const copy = [...values];
|
|
139
|
+
copy.splice(index + 1, 0, "");
|
|
140
|
+
setFormData((prev) => {
|
|
141
|
+
const updated = updateTranslations(
|
|
142
|
+
prev["translations"],
|
|
143
|
+
currentLocale,
|
|
144
|
+
fieldName,
|
|
145
|
+
copy
|
|
146
|
+
);
|
|
147
|
+
return { ...prev, translations: updated };
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
children: /* @__PURE__ */ jsx(CirclePlus, { className: "text-success" })
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] })
|
|
154
|
+
] }, index);
|
|
155
|
+
}) }, locale);
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { createI18nArrayInput };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import 'mime-types';
|
|
5
|
+
import { datetimeToUi } from '../../../../../../shared/form/normalizers/datetime-to-ui.js';
|
|
6
|
+
import 'lucide-react';
|
|
7
|
+
import 'ua-parser-js';
|
|
8
|
+
import 'clsx';
|
|
9
|
+
import 'tailwind-merge';
|
|
10
|
+
import 'next/navigation';
|
|
11
|
+
import '@radix-ui/react-avatar';
|
|
12
|
+
import '../../../shadcn/badge.js';
|
|
13
|
+
import '../../../shadcn/button.js';
|
|
14
|
+
import '@radix-ui/react-collapsible';
|
|
15
|
+
import '@radix-ui/react-dialog';
|
|
16
|
+
import '@radix-ui/react-dropdown-menu';
|
|
17
|
+
import '../../../shadcn/input-group.js';
|
|
18
|
+
import '@radix-ui/react-label';
|
|
19
|
+
import '@radix-ui/react-select';
|
|
20
|
+
import '@radix-ui/react-separator';
|
|
21
|
+
import '../../../shadcn/sidebar.js';
|
|
22
|
+
import 'next-themes';
|
|
23
|
+
import 'sonner';
|
|
24
|
+
import '@radix-ui/react-tabs';
|
|
25
|
+
import '@radix-ui/react-tooltip';
|
|
26
|
+
import 'intor/react';
|
|
27
|
+
import { Input } from '../../inputs/input.js';
|
|
28
|
+
import { getErrorsByLocales } from '../utils/get-errors-by-locales.js';
|
|
29
|
+
import { getTranslationValue } from '../utils/get-translation-value.js';
|
|
30
|
+
import { updateTranslations } from '../utils/update-translations.js';
|
|
31
|
+
|
|
32
|
+
function createI18nDateInput({
|
|
33
|
+
I18nTabsWrapper,
|
|
34
|
+
locales
|
|
35
|
+
}) {
|
|
36
|
+
return function I18nDateInput({
|
|
37
|
+
translations,
|
|
38
|
+
fieldName,
|
|
39
|
+
setFormData,
|
|
40
|
+
isLoading,
|
|
41
|
+
isDisabled,
|
|
42
|
+
errors,
|
|
43
|
+
...props
|
|
44
|
+
}) {
|
|
45
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
46
|
+
const errorsByLocales = getErrorsByLocales(
|
|
47
|
+
locales,
|
|
48
|
+
errors,
|
|
49
|
+
translations,
|
|
50
|
+
fieldName
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
I18nTabsWrapper,
|
|
54
|
+
{
|
|
55
|
+
setCurrentLocale,
|
|
56
|
+
errorLocales: errorsByLocales.map((e) => e.locale),
|
|
57
|
+
children: locales.map((locale) => {
|
|
58
|
+
const value = getTranslationValue(
|
|
59
|
+
translations,
|
|
60
|
+
locale,
|
|
61
|
+
fieldName
|
|
62
|
+
);
|
|
63
|
+
if (currentLocale === locale) {
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
Input,
|
|
66
|
+
{
|
|
67
|
+
value: datetimeToUi(value) ?? "",
|
|
68
|
+
onChange: (e) => {
|
|
69
|
+
if (!fieldName || !setFormData) return;
|
|
70
|
+
setFormData((prev) => {
|
|
71
|
+
const updated = updateTranslations(
|
|
72
|
+
prev["translations"],
|
|
73
|
+
currentLocale,
|
|
74
|
+
fieldName,
|
|
75
|
+
e.target.value
|
|
76
|
+
);
|
|
77
|
+
return { ...prev, translations: updated };
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
isLoading,
|
|
81
|
+
isDisabled,
|
|
82
|
+
isError: errorsByLocales.some((e) => e.locale === locale),
|
|
83
|
+
...props
|
|
84
|
+
},
|
|
85
|
+
locale
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { createI18nDateInput };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import 'ua-parser-js';
|
|
5
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
6
|
+
import 'next/navigation';
|
|
7
|
+
import 'lucide-react';
|
|
8
|
+
import '@radix-ui/react-avatar';
|
|
9
|
+
import '../../../shadcn/badge.js';
|
|
10
|
+
import '../../../shadcn/button.js';
|
|
11
|
+
import '@radix-ui/react-collapsible';
|
|
12
|
+
import '@radix-ui/react-dialog';
|
|
13
|
+
import '@radix-ui/react-dropdown-menu';
|
|
14
|
+
import '../../../shadcn/input-group.js';
|
|
15
|
+
import '@radix-ui/react-label';
|
|
16
|
+
import '@radix-ui/react-select';
|
|
17
|
+
import '@radix-ui/react-separator';
|
|
18
|
+
import '../../../shadcn/sidebar.js';
|
|
19
|
+
import 'next-themes';
|
|
20
|
+
import 'sonner';
|
|
21
|
+
import '@radix-ui/react-tabs';
|
|
22
|
+
import '@radix-ui/react-tooltip';
|
|
23
|
+
import { FieldBody } from '../../form/field-body.js';
|
|
24
|
+
import 'mime-types';
|
|
25
|
+
import 'intor/react';
|
|
26
|
+
import { getErrorsByLocales } from '../utils/get-errors-by-locales.js';
|
|
27
|
+
import { getTranslationValue } from '../utils/get-translation-value.js';
|
|
28
|
+
import { updateTranslations } from '../utils/update-translations.js';
|
|
29
|
+
|
|
30
|
+
function createI18nEditor({
|
|
31
|
+
I18nTabsWrapper,
|
|
32
|
+
locales,
|
|
33
|
+
Editor
|
|
34
|
+
}) {
|
|
35
|
+
return function I18nEditor({
|
|
36
|
+
locale: cmsLocale,
|
|
37
|
+
translations,
|
|
38
|
+
fieldName,
|
|
39
|
+
setFormData,
|
|
40
|
+
isLoading = false,
|
|
41
|
+
isDisabled = false,
|
|
42
|
+
errors = [],
|
|
43
|
+
...props
|
|
44
|
+
}) {
|
|
45
|
+
const [currentLocale, setCurrentLocale] = useState(locales[0]);
|
|
46
|
+
const errorsByLocales = getErrorsByLocales(
|
|
47
|
+
locales,
|
|
48
|
+
errors,
|
|
49
|
+
translations,
|
|
50
|
+
fieldName
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
I18nTabsWrapper,
|
|
54
|
+
{
|
|
55
|
+
setCurrentLocale,
|
|
56
|
+
errorLocales: errorsByLocales.map((e) => e.locale),
|
|
57
|
+
children: locales.map((locale) => {
|
|
58
|
+
const value = getTranslationValue(
|
|
59
|
+
translations,
|
|
60
|
+
locale,
|
|
61
|
+
fieldName
|
|
62
|
+
);
|
|
63
|
+
if (currentLocale === locale) {
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
className: cn(
|
|
68
|
+
(isDisabled || isLoading) && "pointer-events-none"
|
|
69
|
+
),
|
|
70
|
+
children: isLoading ? /* @__PURE__ */ jsx(FieldBody, { isLoading: true }) : /* @__PURE__ */ jsx(
|
|
71
|
+
Editor,
|
|
72
|
+
{
|
|
73
|
+
locale: cmsLocale.startsWith("zh") ? "zh" : "en",
|
|
74
|
+
value: value ?? "",
|
|
75
|
+
onEditorChange: (value2) => {
|
|
76
|
+
if (!fieldName || !setFormData) return;
|
|
77
|
+
setFormData((prev) => {
|
|
78
|
+
const updated = updateTranslations(
|
|
79
|
+
prev["translations"],
|
|
80
|
+
locale,
|
|
81
|
+
fieldName,
|
|
82
|
+
value2
|
|
83
|
+
);
|
|
84
|
+
return { ...prev, translations: updated };
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
isLoading,
|
|
88
|
+
isDisabled,
|
|
89
|
+
isError: errorsByLocales.some((e) => e.locale === locale),
|
|
90
|
+
...props
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
locale
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { createI18nEditor };
|