@yimingliao/cms 0.0.149 → 0.0.150

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.
Files changed (128) hide show
  1. package/dist/export/client/components/index.js +21 -10
  2. package/dist/export/client/shadcn/index.js +2 -0
  3. package/dist/src/client/interfaces/components/resources/file/file-card.js +3 -5
  4. package/dist/src/client/interfaces/components/resources/file/file-list.js +3 -5
  5. package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +3 -5
  6. package/dist/src/client/interfaces/components/resources/file/type-buttons.js +3 -5
  7. package/dist/src/client/interfaces/components/shadcn/sonner.js +32 -0
  8. package/dist/src/client/interfaces/components/shadcn/tabs.js +72 -0
  9. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +3 -0
  10. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +3 -0
  11. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +3 -0
  12. package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +3 -0
  13. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +3 -0
  14. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +3 -0
  15. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +3 -0
  16. package/dist/src/client/interfaces/components/ui/buttons/button.js +3 -0
  17. package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +3 -0
  18. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +3 -0
  19. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +3 -0
  20. package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +3 -0
  21. package/dist/src/client/interfaces/components/ui/display/array-list.js +3 -0
  22. package/dist/src/client/interfaces/components/ui/display/badge.js +3 -0
  23. package/dist/src/client/interfaces/components/ui/display/object-array-list.js +3 -0
  24. package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +3 -0
  25. package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +3 -0
  26. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +3 -0
  27. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +3 -0
  28. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +3 -0
  29. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +3 -0
  30. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +3 -0
  31. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +3 -0
  32. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +3 -0
  33. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +3 -0
  34. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +3 -0
  35. package/dist/src/client/interfaces/components/ui/form/field-body.js +3 -0
  36. package/dist/src/client/interfaces/components/ui/form/field.js +3 -0
  37. package/dist/src/client/interfaces/components/ui/i18n/display/i18n-array-display.js +56 -0
  38. package/dist/src/client/interfaces/components/ui/i18n/display/i18n-display.js +69 -0
  39. package/dist/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.js +64 -0
  40. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.js +164 -0
  41. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.js +95 -0
  42. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.js +104 -0
  43. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-input.js +93 -0
  44. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.js +126 -0
  45. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.js +94 -0
  46. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.js +165 -0
  47. package/dist/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.js +93 -0
  48. package/dist/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.js +17 -0
  49. package/dist/src/client/interfaces/components/ui/i18n/utils/get-translation-value.js +16 -0
  50. package/dist/src/client/interfaces/components/ui/i18n/utils/update-translations.js +14 -0
  51. package/dist/src/client/interfaces/components/ui/inputs/array-input.js +3 -0
  52. package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +3 -0
  53. package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +3 -0
  54. package/dist/src/client/interfaces/components/ui/inputs/input.js +3 -0
  55. package/dist/src/client/interfaces/components/ui/inputs/password-input.js +3 -0
  56. package/dist/src/client/interfaces/components/ui/inputs/search-input.js +3 -0
  57. package/dist/src/client/interfaces/components/ui/inputs/select.js +3 -0
  58. package/dist/src/client/interfaces/components/ui/inputs/textarea.js +3 -0
  59. package/dist/src/client/interfaces/components/ui/layouts/auth-skeleton.js +3 -0
  60. package/dist/src/client/interfaces/components/ui/layouts/dashboard-skeleton.js +3 -0
  61. package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +3 -0
  62. package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +3 -0
  63. package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +1 -0
  64. package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +1 -0
  65. package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +2 -0
  66. package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +3 -0
  67. package/dist/src/client/interfaces/pages/auth/change-password/page.js +3 -5
  68. package/dist/src/client/interfaces/pages/auth/email-unverified/page.js +1 -1
  69. package/dist/src/client/interfaces/pages/auth/forgot-password/page.js +3 -5
  70. package/dist/src/client/interfaces/pages/auth/layout.js +3 -4
  71. package/dist/src/client/interfaces/pages/auth/reset-password/page.js +3 -5
  72. package/dist/src/client/interfaces/pages/auth/sign-in/page.js +1 -1
  73. package/dist/src/client/interfaces/pages/auth/verify-email/page.js +3 -0
  74. package/dist/src/client/interfaces/pages/dashboard/layout.js +4 -5
  75. package/dist/types/export/client/components/index.d.ts +3 -1
  76. package/dist/types/export/client/components/index.d.ts.map +1 -1
  77. package/dist/types/src/client/interfaces/components/index.d.ts +1 -1
  78. package/dist/types/src/client/interfaces/components/index.d.ts.map +1 -1
  79. package/dist/types/src/client/interfaces/components/shadcn/index.d.ts +2 -0
  80. package/dist/types/src/client/interfaces/components/shadcn/index.d.ts.map +1 -1
  81. package/dist/types/src/client/interfaces/components/shadcn/sonner.d.ts +4 -0
  82. package/dist/types/src/client/interfaces/components/shadcn/sonner.d.ts.map +1 -0
  83. package/dist/types/src/client/interfaces/components/shadcn/tabs.d.ts +8 -0
  84. package/dist/types/src/client/interfaces/components/shadcn/tabs.d.ts.map +1 -0
  85. package/dist/types/src/client/interfaces/components/ui/features/index.d.ts +0 -1
  86. package/dist/types/src/client/interfaces/components/ui/features/index.d.ts.map +1 -1
  87. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-array-display.d.ts +9 -0
  88. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-array-display.d.ts.map +1 -0
  89. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-display.d.ts +12 -0
  90. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-display.d.ts.map +1 -0
  91. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.d.ts +15 -0
  92. package/dist/types/src/client/interfaces/components/ui/i18n/display/i18n-object-array-display.d.ts.map +1 -0
  93. package/dist/types/src/client/interfaces/components/ui/i18n/display/index.d.ts +4 -0
  94. package/dist/types/src/client/interfaces/components/ui/i18n/display/index.d.ts.map +1 -0
  95. package/dist/types/src/client/interfaces/components/ui/i18n/i18n-tabs-wrapper.d.ts +13 -0
  96. package/dist/types/src/client/interfaces/components/ui/i18n/i18n-tabs-wrapper.d.ts.map +1 -0
  97. package/dist/types/src/client/interfaces/components/ui/i18n/index.d.ts +3 -0
  98. package/dist/types/src/client/interfaces/components/ui/i18n/index.d.ts.map +1 -0
  99. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.d.ts +12 -0
  100. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-array-input.d.ts.map +1 -0
  101. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.d.ts +11 -0
  102. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-date-input.d.ts.map +1 -0
  103. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.d.ts +14 -0
  104. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-editor.d.ts.map +1 -0
  105. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-input.d.ts +11 -0
  106. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-input.d.ts.map +1 -0
  107. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.d.ts +11 -0
  108. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-json-input.d.ts.map +1 -0
  109. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.d.ts +11 -0
  110. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-number-input.d.ts.map +1 -0
  111. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.d.ts +15 -0
  112. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-object-array-input.d.ts.map +1 -0
  113. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.d.ts +11 -0
  114. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/i18n-textarea.d.ts.map +1 -0
  115. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/index.d.ts +9 -0
  116. package/dist/types/src/client/interfaces/components/ui/i18n/inputs/index.d.ts.map +1 -0
  117. package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.d.ts +7 -0
  118. package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-errors-by-locales.d.ts.map +1 -0
  119. package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-translation-value.d.ts +3 -0
  120. package/dist/types/src/client/interfaces/components/ui/i18n/utils/get-translation-value.d.ts.map +1 -0
  121. package/dist/types/src/client/interfaces/components/ui/i18n/utils/update-translations.d.ts +3 -0
  122. package/dist/types/src/client/interfaces/components/ui/i18n/utils/update-translations.d.ts.map +1 -0
  123. package/dist/types/src/client/interfaces/components/ui/index.d.ts +1 -2
  124. package/dist/types/src/client/interfaces/components/ui/index.d.ts.map +1 -1
  125. package/dist/types/src/client/interfaces/components/ui/layouts/index.d.ts +2 -2
  126. package/dist/types/src/client/interfaces/components/ui/layouts/index.d.ts.map +1 -1
  127. package/dist/types/src/client/interfaces/pages/dashboard/layout.d.ts.map +1 -1
  128. package/package.json +2 -1
@@ -0,0 +1,126 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState, useEffect } from 'react';
4
+ import 'mime-types';
5
+ import { findTranslation } from '../../../../../../shared/translation/find-translation.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 { Textarea } from '../../inputs/textarea.js';
28
+ import { getTranslationValue } from '../utils/get-translation-value.js';
29
+ import { updateTranslations } from '../utils/update-translations.js';
30
+
31
+ function createI18nJsonInput({
32
+ I18nTabsWrapper,
33
+ locales
34
+ }) {
35
+ return function I18nJsonInput({
36
+ translations,
37
+ fieldName,
38
+ setFormData,
39
+ isLoading,
40
+ isDisabled,
41
+ ...props
42
+ }) {
43
+ const [currentLocale, setCurrentLocale] = useState(locales[0]);
44
+ const [errorLocales, setErrorLocales] = useState([]);
45
+ const handleBlur = (e) => {
46
+ if (!fieldName || !setFormData) return;
47
+ let raw = e.target.value;
48
+ if (raw.trim() === "") raw = "[]";
49
+ try {
50
+ const parsed = JSON.parse(raw);
51
+ const formatted = JSON.stringify(parsed, null, 2);
52
+ setErrorLocales((prev) => prev.filter((loc) => loc !== currentLocale));
53
+ if (formatted !== raw) {
54
+ setFormData((prev) => {
55
+ const updated = updateTranslations(
56
+ prev["translations"],
57
+ currentLocale,
58
+ fieldName,
59
+ formatted
60
+ );
61
+ return { ...prev, translations: updated };
62
+ });
63
+ }
64
+ } catch {
65
+ setErrorLocales(
66
+ (prev) => prev.includes(currentLocale) ? prev : [...prev, currentLocale]
67
+ );
68
+ }
69
+ };
70
+ useEffect(() => {
71
+ if (!fieldName || !setFormData) return;
72
+ const raw = findTranslation(translations, currentLocale, "")?.[fieldName];
73
+ try {
74
+ JSON.parse(raw ?? "");
75
+ setErrorLocales((prev) => prev.filter((loc) => loc !== currentLocale));
76
+ } catch {
77
+ if (String(raw)?.trim() !== "" && !errorLocales.includes(currentLocale)) {
78
+ setErrorLocales((prev) => [...prev, currentLocale]);
79
+ }
80
+ }
81
+ }, [fieldName, setFormData, translations, currentLocale]);
82
+ return /* @__PURE__ */ jsx(
83
+ I18nTabsWrapper,
84
+ {
85
+ setCurrentLocale,
86
+ errorLocales,
87
+ children: locales.map((locale) => {
88
+ const value = getTranslationValue(
89
+ translations,
90
+ locale,
91
+ fieldName
92
+ );
93
+ if (currentLocale === locale) {
94
+ return /* @__PURE__ */ jsx(
95
+ Textarea,
96
+ {
97
+ value: value ?? "",
98
+ onChange: (e) => {
99
+ if (!fieldName || !setFormData) return;
100
+ setFormData((prev) => {
101
+ const updated = updateTranslations(
102
+ prev["translations"],
103
+ currentLocale,
104
+ fieldName,
105
+ e.target.value
106
+ );
107
+ return { ...prev, translations: updated };
108
+ });
109
+ },
110
+ isError: errorLocales.includes(currentLocale),
111
+ onBlur: handleBlur,
112
+ isLoading,
113
+ isDisabled,
114
+ ...props
115
+ },
116
+ locale
117
+ );
118
+ }
119
+ return null;
120
+ })
121
+ }
122
+ );
123
+ };
124
+ }
125
+
126
+ export { createI18nJsonInput };
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import 'lucide-react';
5
+ import 'ua-parser-js';
6
+ import 'clsx';
7
+ import 'tailwind-merge';
8
+ import 'next/navigation';
9
+ import '@radix-ui/react-avatar';
10
+ import '../../../shadcn/badge.js';
11
+ import '../../../shadcn/button.js';
12
+ import '@radix-ui/react-collapsible';
13
+ import '@radix-ui/react-dialog';
14
+ import '@radix-ui/react-dropdown-menu';
15
+ import '../../../shadcn/input-group.js';
16
+ import '@radix-ui/react-label';
17
+ import '@radix-ui/react-select';
18
+ import '@radix-ui/react-separator';
19
+ import '../../../shadcn/sidebar.js';
20
+ import 'next-themes';
21
+ import 'sonner';
22
+ import '@radix-ui/react-tabs';
23
+ import '@radix-ui/react-tooltip';
24
+ import 'intor/react';
25
+ import { Input } from '../../inputs/input.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 createI18nNumberInput({
31
+ I18nTabsWrapper,
32
+ locales
33
+ }) {
34
+ return function I18nNumberInput({
35
+ translations,
36
+ fieldName,
37
+ setFormData,
38
+ isLoading,
39
+ isDisabled,
40
+ errors,
41
+ ...props
42
+ }) {
43
+ const [currentLocale, setCurrentLocale] = useState(locales[0]);
44
+ const errorsByLocales = getErrorsByLocales(
45
+ locales,
46
+ errors,
47
+ translations,
48
+ fieldName
49
+ );
50
+ return /* @__PURE__ */ jsx(
51
+ I18nTabsWrapper,
52
+ {
53
+ setCurrentLocale,
54
+ errorLocales: errorsByLocales.map((e) => e.locale),
55
+ children: locales.map((locale) => {
56
+ const value = getTranslationValue(
57
+ translations,
58
+ locale,
59
+ fieldName
60
+ );
61
+ if (currentLocale === locale) {
62
+ return /* @__PURE__ */ jsx(
63
+ Input,
64
+ {
65
+ type: "number",
66
+ value: value ?? 0,
67
+ onChange: (e) => {
68
+ if (!fieldName || !setFormData) return;
69
+ setFormData((prev) => {
70
+ const updated = updateTranslations(
71
+ prev["translations"],
72
+ currentLocale,
73
+ fieldName,
74
+ e.target.value
75
+ );
76
+ return { ...prev, translations: updated };
77
+ });
78
+ },
79
+ isLoading,
80
+ isDisabled,
81
+ isError: errorsByLocales.some((e) => e.locale === locale),
82
+ ...props
83
+ },
84
+ locale
85
+ );
86
+ }
87
+ return null;
88
+ })
89
+ }
90
+ );
91
+ };
92
+ }
93
+
94
+ export { createI18nNumberInput };
@@ -0,0 +1,165 @@
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 createI18nObjectArrayInput({
31
+ I18nTabsWrapper,
32
+ locales
33
+ }) {
34
+ return function I18nObjectArrayInput({
35
+ translations,
36
+ fields,
37
+ fieldName,
38
+ setFormData,
39
+ isResizable = false,
40
+ errors = []
41
+ }) {
42
+ const [currentLocale, setCurrentLocale] = useState(locales[0]);
43
+ const errorsByLocales = getErrorsByLocales(
44
+ locales,
45
+ errors,
46
+ translations,
47
+ fieldName
48
+ );
49
+ return /* @__PURE__ */ jsx(
50
+ I18nTabsWrapper,
51
+ {
52
+ setCurrentLocale,
53
+ errorLocales: errorsByLocales.map((e) => e.locale),
54
+ children: locales.map((locale) => {
55
+ const rawValue = getTranslationValue(
56
+ translations,
57
+ locale,
58
+ fieldName
59
+ );
60
+ const items = Array.isArray(rawValue) && rawValue.length > 0 ? rawValue : [{}];
61
+ const errorIndexes = new Set(
62
+ errorsByLocales.filter((e) => e.locale === locale).map((e) => e.index).filter((i) => i !== void 0)
63
+ );
64
+ if (currentLocale === locale) {
65
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: items.map((item, index) => {
66
+ const isError = errorIndexes.has(index);
67
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
68
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: fields.map((field) => /* @__PURE__ */ jsxs("div", { className: "relative", children: [
69
+ /* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-0 left-0 z-10 h-full", children: [
70
+ /* @__PURE__ */ jsx("span", { className: "min-w-[38px] text-center text-sm opacity-50", children: Array.isArray(rawValue) && rawValue.length === 0 ? "0" : index + 1 }),
71
+ /* @__PURE__ */ jsx(Separator, { orientation: "vertical" })
72
+ ] }),
73
+ /* @__PURE__ */ jsx(
74
+ Textarea,
75
+ {
76
+ value: item[field.key] || "",
77
+ placeholder: field.placeholder,
78
+ isError,
79
+ onChange: (e) => {
80
+ if (!setFormData || !fieldName) return;
81
+ const copy = [...items];
82
+ copy[index] = {
83
+ ...copy[index],
84
+ [field.key]: e.target.value
85
+ };
86
+ setFormData((prev) => {
87
+ const updated = updateTranslations(
88
+ prev["translations"],
89
+ currentLocale,
90
+ fieldName,
91
+ copy
92
+ );
93
+ return { ...prev, translations: updated };
94
+ });
95
+ },
96
+ onKeyDown: (e) => {
97
+ if (e.key === "Enter" && !isResizable) {
98
+ e.preventDefault();
99
+ }
100
+ },
101
+ className: cn(
102
+ "pr-18 pl-14",
103
+ !isResizable && "resize-none"
104
+ )
105
+ }
106
+ )
107
+ ] }, field.key)) }),
108
+ /* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-[3px] right-[3px] gap-1", children: [
109
+ /* @__PURE__ */ jsx(
110
+ Button,
111
+ {
112
+ variant: "outline",
113
+ type: "button",
114
+ size: "icon-sm",
115
+ onClick: () => {
116
+ if (!setFormData || !fieldName) return;
117
+ const copy = items.filter((_, i) => i !== index);
118
+ setFormData((prev) => {
119
+ const updated = updateTranslations(
120
+ prev["translations"],
121
+ currentLocale,
122
+ fieldName,
123
+ copy
124
+ );
125
+ return { ...prev, translations: updated };
126
+ });
127
+ },
128
+ children: /* @__PURE__ */ jsx(CircleX, { className: "text-destructive" })
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsx(
132
+ Button,
133
+ {
134
+ variant: "outline",
135
+ type: "button",
136
+ size: "icon-sm",
137
+ onClick: () => {
138
+ if (!setFormData || !fieldName) return;
139
+ const copy = [...items];
140
+ copy.splice(index + 1, 0, {});
141
+ setFormData((prev) => {
142
+ const updated = updateTranslations(
143
+ prev["translations"],
144
+ currentLocale,
145
+ fieldName,
146
+ copy
147
+ );
148
+ return { ...prev, translations: updated };
149
+ });
150
+ },
151
+ children: /* @__PURE__ */ jsx(CirclePlus, { className: "text-success" })
152
+ }
153
+ )
154
+ ] })
155
+ ] }, index);
156
+ }) }, locale);
157
+ }
158
+ return null;
159
+ })
160
+ }
161
+ );
162
+ };
163
+ }
164
+
165
+ export { createI18nObjectArrayInput };
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import 'lucide-react';
5
+ import 'ua-parser-js';
6
+ import 'clsx';
7
+ import 'tailwind-merge';
8
+ import 'next/navigation';
9
+ import '@radix-ui/react-avatar';
10
+ import '../../../shadcn/badge.js';
11
+ import '../../../shadcn/button.js';
12
+ import '@radix-ui/react-collapsible';
13
+ import '@radix-ui/react-dialog';
14
+ import '@radix-ui/react-dropdown-menu';
15
+ import '../../../shadcn/input-group.js';
16
+ import '@radix-ui/react-label';
17
+ import '@radix-ui/react-select';
18
+ import '@radix-ui/react-separator';
19
+ import '../../../shadcn/sidebar.js';
20
+ import 'next-themes';
21
+ import 'sonner';
22
+ import '@radix-ui/react-tabs';
23
+ import '@radix-ui/react-tooltip';
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 createI18nTextarea({
31
+ I18nTabsWrapper,
32
+ locales
33
+ }) {
34
+ return function I18nTextarea({
35
+ translations,
36
+ fieldName,
37
+ setFormData,
38
+ isLoading,
39
+ isDisabled,
40
+ errors = [],
41
+ ...props
42
+ }) {
43
+ const [currentLocale, setCurrentLocale] = useState(locales[0]);
44
+ const errorsByLocales = getErrorsByLocales(
45
+ locales,
46
+ errors,
47
+ translations,
48
+ fieldName
49
+ );
50
+ return /* @__PURE__ */ jsx(
51
+ I18nTabsWrapper,
52
+ {
53
+ setCurrentLocale,
54
+ errorLocales: errorsByLocales.map((e) => e.locale),
55
+ children: locales.map((locale) => {
56
+ const value = getTranslationValue(
57
+ translations,
58
+ locale,
59
+ fieldName
60
+ );
61
+ if (currentLocale === locale) {
62
+ return /* @__PURE__ */ jsx(
63
+ Textarea,
64
+ {
65
+ value: value ?? "",
66
+ onChange: (e) => {
67
+ if (!fieldName || !setFormData) return;
68
+ setFormData((prev) => {
69
+ const updated = updateTranslations(
70
+ prev["translations"],
71
+ currentLocale,
72
+ fieldName,
73
+ e.target.value
74
+ );
75
+ return { ...prev, translations: updated };
76
+ });
77
+ },
78
+ isLoading,
79
+ isDisabled,
80
+ isError: errorsByLocales.some((e) => e.locale === locale),
81
+ ...props
82
+ },
83
+ locale
84
+ );
85
+ }
86
+ return null;
87
+ })
88
+ }
89
+ );
90
+ };
91
+ }
92
+
93
+ export { createI18nTextarea };
@@ -0,0 +1,17 @@
1
+ const getErrorsByLocales = (locales, errors = [], translations = [], fieldName = "") => {
2
+ const rawParts = errors.map((e) => e?.split("."));
3
+ const filteredParts = rawParts.filter(
4
+ (parts) => !!parts && parts[0] === "translations" && parts[2] === fieldName
5
+ );
6
+ const mapped = filteredParts.map(([, indexStr, ...rest]) => {
7
+ const locale = translations[Number(indexStr)]?.locale ?? "";
8
+ if (!locales.includes(locale)) return null;
9
+ const last = rest.at(1);
10
+ const index = !Number.isNaN(Number(last)) ? Number(last) : void 0;
11
+ return { locale, path: rest, index };
12
+ });
13
+ const filtered = mapped.filter((a) => !!a);
14
+ return filtered;
15
+ };
16
+
17
+ export { getErrorsByLocales };
@@ -0,0 +1,16 @@
1
+ const getTranslationValue = (translations = [], locale, fieldName = "") => {
2
+ const translation = translations.find((t) => t.locale === locale);
3
+ if (!translation) {
4
+ return null;
5
+ }
6
+ if (!(fieldName in translation)) {
7
+ return null;
8
+ }
9
+ const value = translation[fieldName];
10
+ if (value === null || value === void 0) {
11
+ return null;
12
+ }
13
+ return value;
14
+ };
15
+
16
+ export { getTranslationValue };
@@ -0,0 +1,14 @@
1
+ const updateTranslations = (translations = [], locale, fieldName, value) => {
2
+ const updatedTranslations = translations.map(
3
+ (t) => t.locale === locale ? { ...t, [fieldName]: value } : t
4
+ );
5
+ if (!translations.some((t) => t.locale === locale)) {
6
+ updatedTranslations.push({
7
+ locale,
8
+ [fieldName]: value
9
+ });
10
+ }
11
+ return updatedTranslations;
12
+ };
13
+
14
+ export { updateTranslations };
@@ -16,6 +16,9 @@ import '@radix-ui/react-label';
16
16
  import '@radix-ui/react-select';
17
17
  import { Separator } from '../../shadcn/separator.js';
18
18
  import '../../shadcn/sidebar.js';
19
+ import 'next-themes';
20
+ import 'sonner';
21
+ import '@radix-ui/react-tabs';
19
22
  import '@radix-ui/react-tooltip';
20
23
  import { Button } from '../buttons/button.js';
21
24
  import 'intor/react';
@@ -16,7 +16,10 @@ import '@radix-ui/react-label';
16
16
  import '@radix-ui/react-select';
17
17
  import '@radix-ui/react-separator';
18
18
  import '../../shadcn/sidebar.js';
19
+ import 'next-themes';
20
+ import 'sonner';
19
21
  import { Spinner } from '../../shadcn/spinner.js';
22
+ import '@radix-ui/react-tabs';
20
23
  import '@radix-ui/react-tooltip';
21
24
 
22
25
  function Checkbox({
@@ -17,6 +17,9 @@ import '@radix-ui/react-label';
17
17
  import '@radix-ui/react-select';
18
18
  import '@radix-ui/react-separator';
19
19
  import '../../../shadcn/sidebar.js';
20
+ import 'next-themes';
21
+ import 'sonner';
22
+ import '@radix-ui/react-tabs';
20
23
  import '@radix-ui/react-tooltip';
21
24
  import 'next/link';
22
25
  import '../../../../../../constants/paths/auth.js';
@@ -16,7 +16,10 @@ import '@radix-ui/react-label';
16
16
  import '@radix-ui/react-select';
17
17
  import '@radix-ui/react-separator';
18
18
  import '../../shadcn/sidebar.js';
19
+ import 'next-themes';
20
+ import 'sonner';
19
21
  import { Spinner } from '../../shadcn/spinner.js';
22
+ import '@radix-ui/react-tabs';
20
23
  import '@radix-ui/react-tooltip';
21
24
 
22
25
  function Input({
@@ -17,6 +17,9 @@ import '@radix-ui/react-label';
17
17
  import '@radix-ui/react-select';
18
18
  import '@radix-ui/react-separator';
19
19
  import '../../shadcn/sidebar.js';
20
+ import 'next-themes';
21
+ import 'sonner';
22
+ import '@radix-ui/react-tabs';
20
23
  import '@radix-ui/react-tooltip';
21
24
  import { Input } from './input.js';
22
25
 
@@ -18,7 +18,10 @@ import '@radix-ui/react-label';
18
18
  import '@radix-ui/react-select';
19
19
  import '@radix-ui/react-separator';
20
20
  import '../../shadcn/sidebar.js';
21
+ import 'next-themes';
22
+ import 'sonner';
21
23
  import { Spinner } from '../../shadcn/spinner.js';
24
+ import '@radix-ui/react-tabs';
22
25
  import '@radix-ui/react-tooltip';
23
26
  import { Input } from './input.js';
24
27
 
@@ -16,6 +16,9 @@ import '@radix-ui/react-label';
16
16
  import { SelectItem, Select as Select$1, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel } from '../../shadcn/select.js';
17
17
  import '@radix-ui/react-separator';
18
18
  import '../../shadcn/sidebar.js';
19
+ import 'next-themes';
20
+ import 'sonner';
21
+ import '@radix-ui/react-tabs';
19
22
  import '@radix-ui/react-tooltip';
20
23
 
21
24
  function Select({
@@ -17,7 +17,10 @@ import '@radix-ui/react-label';
17
17
  import '@radix-ui/react-select';
18
18
  import '@radix-ui/react-separator';
19
19
  import '../../shadcn/sidebar.js';
20
+ import 'next-themes';
21
+ import 'sonner';
20
22
  import { Spinner } from '../../shadcn/spinner.js';
23
+ import '@radix-ui/react-tabs';
21
24
  import { Textarea as Textarea$1 } from '../../shadcn/textarea.js';
22
25
  import '@radix-ui/react-tooltip';
23
26
 
@@ -17,6 +17,9 @@ import '@radix-ui/react-select';
17
17
  import '@radix-ui/react-separator';
18
18
  import '../../shadcn/sidebar.js';
19
19
  import { Skeleton } from '../../shadcn/skeleton.js';
20
+ import 'next-themes';
21
+ import 'sonner';
22
+ import '@radix-ui/react-tabs';
20
23
  import '@radix-ui/react-tooltip';
21
24
 
22
25
  function AuthSkeleton() {
@@ -19,6 +19,9 @@ import '@radix-ui/react-select';
19
19
  import '@radix-ui/react-separator';
20
20
  import { useSidebar, Sidebar, SidebarInset } from '../../shadcn/sidebar.js';
21
21
  import { Skeleton } from '../../shadcn/skeleton.js';
22
+ import 'next-themes';
23
+ import 'sonner';
24
+ import '@radix-ui/react-tabs';
22
25
  import '@radix-ui/react-tooltip';
23
26
 
24
27
  function DashboardSkeleton() {
@@ -18,6 +18,9 @@ import '@radix-ui/react-label';
18
18
  import '@radix-ui/react-select';
19
19
  import '@radix-ui/react-separator';
20
20
  import '../../../shadcn/sidebar.js';
21
+ import 'next-themes';
22
+ import 'sonner';
23
+ import '@radix-ui/react-tabs';
21
24
  import '@radix-ui/react-tooltip';
22
25
  import { Button } from '../../buttons/button.js';
23
26
  import 'intor/react';
@@ -24,7 +24,10 @@ import '@radix-ui/react-label';
24
24
  import '@radix-ui/react-select';
25
25
  import '@radix-ui/react-separator';
26
26
  import { SidebarMenu, SidebarMenuItem, SidebarMenuButton } from '../../../shadcn/sidebar.js';
27
+ import 'next-themes';
28
+ import 'sonner';
27
29
  import { Spinner } from '../../../shadcn/spinner.js';
30
+ import '@radix-ui/react-tabs';
28
31
  import '@radix-ui/react-tooltip';
29
32
  import { Button } from '../../buttons/button.js';
30
33
 
@@ -25,6 +25,7 @@ import '@radix-ui/react-label';
25
25
  import '@radix-ui/react-select';
26
26
  import { Separator } from '../../../shadcn/separator.js';
27
27
  import { useSidebar } from '../../../shadcn/sidebar.js';
28
+ import '@radix-ui/react-tabs';
28
29
  import '@radix-ui/react-tooltip';
29
30
  import { Button } from '../../buttons/button.js';
30
31
  import { NavUser } from './nav-user.js';