@intlayer/design-system 4.0.4 → 4.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/dist/.vite/manifest.json +10 -10
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
- package/dist/components/Button/Button.cjs +9 -9
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.mjs +9 -9
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +4 -3
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +1 -0
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +4 -3
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +29 -11
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts +1 -0
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +31 -13
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs +32 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.cjs.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts +4 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs +32 -0
- package/dist/components/DictionaryEditor/validDictionaryChangeButtons.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +43 -14
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +46 -17
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +32 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +4 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +32 -0
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +5 -4
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +5 -4
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +4 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +4 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +45 -18
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +1 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +47 -20
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +32 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +4 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +32 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.cjs +1 -1
- package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs.map +1 -1
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs +2 -2
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs +2 -2
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +3 -2
- package/dist/hooks/intlayerAPIHooks.cjs +11 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +4 -0
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +12 -2
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.d.ts.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +4 -0
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/index-Ai6eeqZH.js +702 -0
- package/dist/index-Ai6eeqZH.js.map +1 -0
- package/dist/index-B1nU1-65.cjs +690 -0
- package/dist/index-B1nU1-65.cjs.map +1 -0
- package/dist/index-BIyA5LAs.js +691 -0
- package/dist/index-BIyA5LAs.js.map +1 -0
- package/dist/index-BbqOa6BU.cjs +701 -0
- package/dist/index-BbqOa6BU.cjs.map +1 -0
- package/dist/index-BqZwP4Lr.js +691 -0
- package/dist/index-BqZwP4Lr.js.map +1 -0
- package/dist/index-Buecpjbh.cjs +690 -0
- package/dist/index-Buecpjbh.cjs.map +1 -0
- package/dist/index-CDEJjmId.js +694 -0
- package/dist/index-CDEJjmId.js.map +1 -0
- package/dist/index-CTAyk6RY.cjs +693 -0
- package/dist/index-CTAyk6RY.cjs.map +1 -0
- package/dist/index-CVC2sfEj.js +693 -0
- package/dist/index-CVC2sfEj.js.map +1 -0
- package/dist/index-CVz0RdK6.js +691 -0
- package/dist/index-CVz0RdK6.js.map +1 -0
- package/dist/index-CjF2ksU7.cjs +693 -0
- package/dist/index-CjF2ksU7.cjs.map +1 -0
- package/dist/index-CuQs5759.cjs +692 -0
- package/dist/index-CuQs5759.cjs.map +1 -0
- package/dist/index-D_MDocy7.cjs +690 -0
- package/dist/index-D_MDocy7.cjs.map +1 -0
- package/dist/index-Djo2Jnua.cjs +693 -0
- package/dist/index-Djo2Jnua.cjs.map +1 -0
- package/dist/index-LFTthFne.js +694 -0
- package/dist/index-LFTthFne.js.map +1 -0
- package/dist/index-xZoGTokf.js +694 -0
- package/dist/index-xZoGTokf.js.map +1 -0
- package/dist/tailwind.config.cjs.map +1 -1
- package/dist/tailwind.config.mjs.map +1 -1
- package/dist/tailwind.css +1 -1
- package/package.json +18 -18
package/dist/.vite/manifest.json
CHANGED
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"src/components/Form/FormLabel.tsx"
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
|
-
"_index-
|
|
55
|
-
"file": "index-
|
|
54
|
+
"_index-Ai6eeqZH.js": {
|
|
55
|
+
"file": "index-Ai6eeqZH.js",
|
|
56
56
|
"name": "index"
|
|
57
57
|
},
|
|
58
58
|
"_index-B-adg6xa.js": {
|
|
@@ -65,6 +65,10 @@
|
|
|
65
65
|
"src/components/DictionaryEditor/NodeWrapper/StringWrapper.tsx"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
+
"_index-BbqOa6BU.cjs": {
|
|
69
|
+
"file": "index-BbqOa6BU.cjs",
|
|
70
|
+
"name": "index"
|
|
71
|
+
},
|
|
68
72
|
"_index-Cg-S9ry9.cjs": {
|
|
69
73
|
"file": "index-Cg-S9ry9.cjs",
|
|
70
74
|
"name": "index",
|
|
@@ -91,10 +95,6 @@
|
|
|
91
95
|
"src/hooks/useScrollBlockage/useScrollBlockageStore.ts"
|
|
92
96
|
]
|
|
93
97
|
},
|
|
94
|
-
"_index-f8_VC6c8.cjs": {
|
|
95
|
-
"file": "index-f8_VC6c8.cjs",
|
|
96
|
-
"name": "index"
|
|
97
|
-
},
|
|
98
98
|
"_jsx-runtime-CgFM7lM3.cjs": {
|
|
99
99
|
"file": "jsx-runtime-CgFM7lM3.cjs",
|
|
100
100
|
"name": "jsx-runtime"
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
"isEntry": true,
|
|
244
244
|
"imports": [
|
|
245
245
|
"_jsx-runtime-CgFM7lM3.cjs",
|
|
246
|
-
"_index-
|
|
246
|
+
"_index-BbqOa6BU.cjs",
|
|
247
247
|
"src/components/Button/Button.tsx",
|
|
248
248
|
"src/components/Auth/ExternalsLoginButtons/assets/GithubLogo.tsx",
|
|
249
249
|
"src/components/Auth/ExternalsLoginButtons/assets/GoogleLogo.tsx",
|
|
@@ -798,7 +798,7 @@
|
|
|
798
798
|
"imports": [
|
|
799
799
|
"_jsx-runtime-CgFM7lM3.cjs",
|
|
800
800
|
"src/hooks/intlayerAPIHooks.ts",
|
|
801
|
-
"_index-
|
|
801
|
+
"_index-BbqOa6BU.cjs",
|
|
802
802
|
"src/components/Button/Button.tsx",
|
|
803
803
|
"src/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.ts",
|
|
804
804
|
"src/components/Form/FormBase.tsx",
|
|
@@ -852,7 +852,7 @@
|
|
|
852
852
|
"src/hooks/useScrollBlockage/useScrollBlockageStore.ts",
|
|
853
853
|
"src/hooks/useAsync/useAsyncStateStore.tsx",
|
|
854
854
|
"src/hooks/intlayerAPIHooks.ts",
|
|
855
|
-
"_index-
|
|
855
|
+
"_index-BbqOa6BU.cjs",
|
|
856
856
|
"src/components/Button/Button.tsx",
|
|
857
857
|
"src/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.ts",
|
|
858
858
|
"src/components/Form/FormBase.tsx",
|
|
@@ -1058,7 +1058,7 @@
|
|
|
1058
1058
|
"src/hooks/useAsync/useAsyncStateStore.tsx",
|
|
1059
1059
|
"src/hooks/intlayerAPIHooks.ts",
|
|
1060
1060
|
"src/hooks/useGetAllDictionaries.tsx",
|
|
1061
|
-
"_index-
|
|
1061
|
+
"_index-BbqOa6BU.cjs",
|
|
1062
1062
|
"src/components/Button/Button.tsx",
|
|
1063
1063
|
"src/components/Auth/ExternalsLoginButtons/externalsLoginButtons.content.ts",
|
|
1064
1064
|
"src/components/Form/FormBase.tsx",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("../../../jsx-runtime-CgFM7lM3.cjs");
|
|
5
5
|
const reactIntlayer = require("react-intlayer");
|
|
6
|
-
const index = require("../../../index-
|
|
6
|
+
const index = require("../../../index-BbqOa6BU.cjs");
|
|
7
7
|
require("@intlayer/config/client");
|
|
8
8
|
const components_Button_Button = require("../../Button/Button.cjs");
|
|
9
9
|
const components_Auth_ExternalsLoginButtons_assets_GithubLogo = require("./assets/GithubLogo.cjs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
|
|
3
3
|
import { useDictionary } from "react-intlayer";
|
|
4
|
-
import { i as intlayerAPI } from "../../../index-
|
|
4
|
+
import { i as intlayerAPI } from "../../../index-Ai6eeqZH.js";
|
|
5
5
|
import "@intlayer/config/client";
|
|
6
6
|
import { Button } from "../../Button/Button.mjs";
|
|
7
7
|
import { GithubLogo } from "./assets/GithubLogo.mjs";
|
|
@@ -11,10 +11,10 @@ const buttonIconVariants = classVarianceAuthority.cva("", {
|
|
|
11
11
|
md: "size-4 absolute top-1/2 -translate-y-1/2",
|
|
12
12
|
lg: "size-5 absolute top-1/2 -translate-y-1/2",
|
|
13
13
|
xl: "size-6 absolute top-1/2 -translate-y-1/2",
|
|
14
|
-
"icon-sm": "size-
|
|
15
|
-
"icon-md": "size-
|
|
16
|
-
"icon-lg": "size-
|
|
17
|
-
"icon-xl": "size-
|
|
14
|
+
"icon-sm": "size-3",
|
|
15
|
+
"icon-md": "size-4",
|
|
16
|
+
"icon-lg": "size-5",
|
|
17
|
+
"icon-xl": "size-6"
|
|
18
18
|
},
|
|
19
19
|
position: {
|
|
20
20
|
left: "left-3",
|
|
@@ -34,10 +34,10 @@ const buttonVariants = classVarianceAuthority.cva(
|
|
|
34
34
|
md: "min-h-8 px-6 max-md:py-2 text-sm",
|
|
35
35
|
lg: "min-h-10 px-8 max-md:py-3 text-base",
|
|
36
36
|
xl: "min-h-11 px-10 max-md:py-4 text-lg",
|
|
37
|
-
"icon-sm": "p-
|
|
38
|
-
"icon-md": "p-1",
|
|
39
|
-
"icon-lg": "p-
|
|
40
|
-
"icon-xl": "p-
|
|
37
|
+
"icon-sm": "p-1",
|
|
38
|
+
"icon-md": "p-1.5",
|
|
39
|
+
"icon-lg": "p-2",
|
|
40
|
+
"icon-xl": "p-3"
|
|
41
41
|
},
|
|
42
42
|
variant: {
|
|
43
43
|
default: "rounded-lg text-text-opposite dark:text-text-opposite-dark",
|
|
@@ -80,7 +80,7 @@ const buttonVariants = classVarianceAuthority.cva(
|
|
|
80
80
|
false: ""
|
|
81
81
|
},
|
|
82
82
|
hasIconRight: {
|
|
83
|
-
true: "pr-
|
|
83
|
+
true: "pr-8",
|
|
84
84
|
false: ""
|
|
85
85
|
}
|
|
86
86
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n forwardRef,\n type ButtonHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { Loader } from '../Loader';\n\nconst buttonIconVariants = cva('', {\n variants: {\n size: {\n sm: 'size-3 absolute top-1/2 -translate-y-1/2',\n md: 'size-4 absolute top-1/2 -translate-y-1/2',\n lg: 'size-5 absolute top-1/2 -translate-y-1/2',\n xl: 'size-6 absolute top-1/2 -translate-y-1/2',\n 'icon-sm': 'size-6 p-1',\n 'icon-md': 'size-7 p-1',\n 'icon-lg': 'size-9 p-1',\n 'icon-xl': 'size-10 p-1',\n },\n position: {\n left: 'left-3',\n right: 'right-3',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nconst buttonVariants = cva(\n 'relative truncate whitespace-nowrap font-medium transition focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n size: {\n sm: 'min-h-7 px-3 max-md:py-1 text-xs',\n md: 'min-h-8 px-6 max-md:py-2 text-sm',\n lg: 'min-h-10 px-8 max-md:py-3 text-base',\n xl: 'min-h-11 px-10 max-md:py-4 text-lg',\n 'icon-sm': 'p-0.5',\n 'icon-md': 'p-1',\n 'icon-lg': 'p-1.5',\n 'icon-xl': 'p-2',\n },\n variant: {\n default: 'rounded-lg text-text-opposite dark:text-text-opposite-dark',\n none: 'border-none bg-opacity-0 text-inherit hover:bg-opacity-0 dark:bg-opacity-0 dark:text-inherit dark:hover:bg-opacity-0',\n outline:\n 'rounded-lg border-[1.5px] bg-opacity-0 hover:bg-opacity-30 dark:bg-opacity-0',\n link: 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent hover:underline dark:bg-transparent hover:dark:bg-transparent',\n 'invisible-link':\n 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent dark:bg-transparent hover:dark:bg-transparent',\n hoverable:\n 'rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10 aria-[current]:bg-opacity-5 dark:border-none dark:bg-opacity-0 dark:hover:bg-opacity-10',\n input: [\n 'w-full select-text resize-none rounded-xl border-2 bg-input-background text-sm text-input-text shadow-none outline-0 transition-all dark:bg-input-background-dark dark:text-input-text-dark',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none] dark:border-input-border-dark dark:hover:border-input-border-hover-dark dark:focus:border-input-border-focus',\n 'aria-[invalid=true]:border-error dark:aria-[invalid=true]:border-error-dark',\n 'disabled:opacity-50',\n ],\n },\n color: {\n primary:\n 'border-primary bg-primary text-primary hover:bg-primary-500 dark:border-primary-dark dark:bg-primary-dark dark:text-primary-dark hover:dark:bg-primary-300',\n secondary:\n 'border-secondary bg-secondary text-secondary hover:bg-secondary-300 dark:border-secondary-dark dark:bg-secondary-dark dark:text-secondary-dark hover:dark:bg-secondary-100',\n destructive:\n 'border-destructive bg-destructive text-destructive hover:bg-destructive-500 dark:border-destructive-dark dark:bg-destructive-dark hover:dark:bg-destructive-200',\n neutral:\n 'border-neutral bg-neutral text-neutral hover:bg-neutral-600 dark:border-neutral-dark dark:bg-neutral-dark dark:text-neutral-dark hover:dark:bg-neutral-400',\n light: 'border-white bg-white text-white hover:bg-neutral-500',\n dark: 'border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900 dark:hover:bg-neutral-700',\n text: 'border-text bg-text text-text hover:opacity-80 dark:border-text-dark dark:bg-text-dark dark:text-text-dark',\n 'text-inverse':\n 'border-text-dark dark:border-text bg-text-dark dark:bg-text text-text-dark dark:text-text hover:opacity-80',\n error:\n 'border-error bg-error text-error hover:bg-error-500 dark:border-error-dark dark:bg-error-dark dark:text-error-dark hover:dark:bg-error-300',\n success:\n 'border-success bg-success text-success hover:bg-success-500 dark:border-success-dark dark:bg-success-dark dark:text-success-dark hover:dark:bg-success-300',\n custom: '',\n },\n\n textAlign: {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n },\n\n isFullWidth: {\n true: 'w-full',\n false: '',\n },\n\n hasIconLeft: {\n true: 'pl-12',\n false: '',\n },\n hasIconRight: {\n true: 'pr-12',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n color: 'primary',\n textAlign: 'center',\n isFullWidth: false,\n hasIconRight: false,\n hasIconLeft: false,\n },\n }\n);\n\nexport type ButtonProps = DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n> &\n VariantProps<typeof buttonVariants> & {\n /**\n * Optional icon to be displayed on the button\n */\n label: string;\n Icon?: FC | LucideIcon;\n IconRight?: FC | LucideIcon;\n iconClassName?: string;\n isLoading?: boolean;\n isActive?: boolean;\n isFullWidth?: boolean;\n };\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant,\n size,\n color,\n children,\n Icon,\n IconRight,\n iconClassName,\n isLoading,\n isActive,\n isFullWidth = false,\n textAlign,\n disabled,\n label,\n className,\n type = 'button',\n ...props\n },\n ref\n ) => {\n const isLink = variant === 'link' || variant === 'invisible-link';\n\n return (\n <button\n ref={ref}\n disabled={isLoading || disabled}\n aria-current={isActive ? 'page' : undefined}\n aria-label={label}\n aria-busy={isLoading}\n role={isLink ? 'link' : undefined}\n type={type}\n className={buttonVariants({\n variant,\n size,\n color,\n isFullWidth,\n textAlign: textAlign ?? (IconRight ? 'left' : 'center'),\n hasIconLeft: Boolean(\n typeof children !== 'undefined' &&\n (typeof Icon !== 'undefined' || typeof isLoading !== 'undefined')\n ),\n hasIconRight: Boolean(\n typeof children !== 'undefined' && typeof IconRight !== 'undefined'\n ),\n className,\n })}\n {...props}\n >\n {Icon && !isLoading && (\n <Icon\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n />\n )}\n\n <Loader\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n isLoading={isLoading ?? false}\n />\n\n {children}\n\n {IconRight && (\n <IconRight\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'right',\n })}\n />\n )}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n"],"names":["cva","forwardRef","jsxs","jsx","Loader"],"mappings":";;;;;;AAUA,MAAM,qBAAqBA,2BAAI,IAAI;AAAA,EACjC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC;AAED,MAAM,iBAAiBA,uBAAA;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,MACb;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SACE;AAAA,QACF,MAAM;AAAA,QACN,kBACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;A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AAS;AAAA,UAC9C,aAAa;AAAA,YACX,OAAO,aAAa,gBACjB,OAAO,SAAS,eAAe,OAAO,cAAc;AAAA,UACzD;AAAA,UACA,cAAc;AAAA,YACZ,OAAO,aAAa,eAAe,OAAO,cAAc;AAAA,UAC1D;AAAA,UACA;AAAA,QAAA,CACD;AAAA,QACA,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,QAAQ,CAAC,aACRC,2BAAA,kBAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cACX,CAAA;AAAA,YAAA;AAAA,UACH;AAAA,UAGFA,2BAAA,kBAAA;AAAA,YAACC,wBAAA;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cAAA,CACX;AAAA,cACD,WAAW,aAAa;AAAA,YAAA;AAAA,UAC1B;AAAA,UAEC;AAAA,UAEA,aACCD,2BAAA,kBAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cACX,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;AAEA,OAAO,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Button.cjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n forwardRef,\n type ButtonHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { Loader } from '../Loader';\n\nconst buttonIconVariants = cva('', {\n variants: {\n size: {\n sm: 'size-3 absolute top-1/2 -translate-y-1/2',\n md: 'size-4 absolute top-1/2 -translate-y-1/2',\n lg: 'size-5 absolute top-1/2 -translate-y-1/2',\n xl: 'size-6 absolute top-1/2 -translate-y-1/2',\n 'icon-sm': 'size-3',\n 'icon-md': 'size-4',\n 'icon-lg': 'size-5',\n 'icon-xl': 'size-6',\n },\n position: {\n left: 'left-3',\n right: 'right-3',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nconst buttonVariants = cva(\n 'relative truncate whitespace-nowrap font-medium transition focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n size: {\n sm: 'min-h-7 px-3 max-md:py-1 text-xs',\n md: 'min-h-8 px-6 max-md:py-2 text-sm',\n lg: 'min-h-10 px-8 max-md:py-3 text-base',\n xl: 'min-h-11 px-10 max-md:py-4 text-lg',\n 'icon-sm': 'p-1',\n 'icon-md': 'p-1.5',\n 'icon-lg': 'p-2',\n 'icon-xl': 'p-3',\n },\n variant: {\n default: 'rounded-lg text-text-opposite dark:text-text-opposite-dark',\n none: 'border-none bg-opacity-0 text-inherit hover:bg-opacity-0 dark:bg-opacity-0 dark:text-inherit dark:hover:bg-opacity-0',\n outline:\n 'rounded-lg border-[1.5px] bg-opacity-0 hover:bg-opacity-30 dark:bg-opacity-0',\n link: 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent hover:underline dark:bg-transparent hover:dark:bg-transparent',\n 'invisible-link':\n 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent dark:bg-transparent hover:dark:bg-transparent',\n hoverable:\n 'rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10 aria-[current]:bg-opacity-5 dark:border-none dark:bg-opacity-0 dark:hover:bg-opacity-10',\n input: [\n 'w-full select-text resize-none rounded-xl border-2 bg-input-background text-sm text-input-text shadow-none outline-0 transition-all dark:bg-input-background-dark dark:text-input-text-dark',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none] dark:border-input-border-dark dark:hover:border-input-border-hover-dark dark:focus:border-input-border-focus',\n 'aria-[invalid=true]:border-error dark:aria-[invalid=true]:border-error-dark',\n 'disabled:opacity-50',\n ],\n },\n color: {\n primary:\n 'border-primary bg-primary text-primary hover:bg-primary-500 dark:border-primary-dark dark:bg-primary-dark dark:text-primary-dark hover:dark:bg-primary-300',\n secondary:\n 'border-secondary bg-secondary text-secondary hover:bg-secondary-300 dark:border-secondary-dark dark:bg-secondary-dark dark:text-secondary-dark hover:dark:bg-secondary-100',\n destructive:\n 'border-destructive bg-destructive text-destructive hover:bg-destructive-500 dark:border-destructive-dark dark:bg-destructive-dark hover:dark:bg-destructive-200',\n neutral:\n 'border-neutral bg-neutral text-neutral hover:bg-neutral-600 dark:border-neutral-dark dark:bg-neutral-dark dark:text-neutral-dark hover:dark:bg-neutral-400',\n light: 'border-white bg-white text-white hover:bg-neutral-500',\n dark: 'border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900 dark:hover:bg-neutral-700',\n text: 'border-text bg-text text-text hover:opacity-80 dark:border-text-dark dark:bg-text-dark dark:text-text-dark',\n 'text-inverse':\n 'border-text-dark dark:border-text bg-text-dark dark:bg-text text-text-dark dark:text-text hover:opacity-80',\n error:\n 'border-error bg-error text-error hover:bg-error-500 dark:border-error-dark dark:bg-error-dark dark:text-error-dark hover:dark:bg-error-300',\n success:\n 'border-success bg-success text-success hover:bg-success-500 dark:border-success-dark dark:bg-success-dark dark:text-success-dark hover:dark:bg-success-300',\n custom: '',\n },\n\n textAlign: {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n },\n\n isFullWidth: {\n true: 'w-full',\n false: '',\n },\n\n hasIconLeft: {\n true: 'pl-12',\n false: '',\n },\n hasIconRight: {\n true: 'pr-8',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n color: 'primary',\n textAlign: 'center',\n isFullWidth: false,\n hasIconRight: false,\n hasIconLeft: false,\n },\n }\n);\n\nexport type ButtonProps = DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n> &\n VariantProps<typeof buttonVariants> & {\n /**\n * Optional icon to be displayed on the button\n */\n label: string;\n Icon?: FC | LucideIcon;\n IconRight?: FC | LucideIcon;\n iconClassName?: string;\n isLoading?: boolean;\n isActive?: boolean;\n isFullWidth?: boolean;\n };\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant,\n size,\n color,\n children,\n Icon,\n IconRight,\n iconClassName,\n isLoading,\n isActive,\n isFullWidth = false,\n textAlign,\n disabled,\n label,\n className,\n type = 'button',\n ...props\n },\n ref\n ) => {\n const isLink = variant === 'link' || variant === 'invisible-link';\n\n return (\n <button\n ref={ref}\n disabled={isLoading || disabled}\n aria-current={isActive ? 'page' : undefined}\n aria-label={label}\n aria-busy={isLoading}\n role={isLink ? 'link' : undefined}\n type={type}\n className={buttonVariants({\n variant,\n size,\n color,\n isFullWidth,\n textAlign: textAlign ?? (IconRight ? 'left' : 'center'),\n hasIconLeft: Boolean(\n typeof children !== 'undefined' &&\n (typeof Icon !== 'undefined' || typeof isLoading !== 'undefined')\n ),\n hasIconRight: Boolean(\n typeof children !== 'undefined' && typeof IconRight !== 'undefined'\n ),\n className,\n })}\n {...props}\n >\n {Icon && !isLoading && (\n <Icon\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n />\n )}\n\n <Loader\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n isLoading={isLoading ?? false}\n />\n\n {children}\n\n {IconRight && (\n <IconRight\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'right',\n })}\n />\n )}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n"],"names":["cva","forwardRef","jsxs","jsx","Loader"],"mappings":";;;;;;AAUA,MAAM,qBAAqBA,2BAAI,IAAI;AAAA,EACjC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,WAAW;AAAA,MACX,WAA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1B;AAAA,UAEC;AAAA,UAEA,aACCD,2BAAA,kBAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cACX,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;AAEA,OAAO,cAAc;;"}
|
|
@@ -9,10 +9,10 @@ const buttonIconVariants = cva("", {
|
|
|
9
9
|
md: "size-4 absolute top-1/2 -translate-y-1/2",
|
|
10
10
|
lg: "size-5 absolute top-1/2 -translate-y-1/2",
|
|
11
11
|
xl: "size-6 absolute top-1/2 -translate-y-1/2",
|
|
12
|
-
"icon-sm": "size-
|
|
13
|
-
"icon-md": "size-
|
|
14
|
-
"icon-lg": "size-
|
|
15
|
-
"icon-xl": "size-
|
|
12
|
+
"icon-sm": "size-3",
|
|
13
|
+
"icon-md": "size-4",
|
|
14
|
+
"icon-lg": "size-5",
|
|
15
|
+
"icon-xl": "size-6"
|
|
16
16
|
},
|
|
17
17
|
position: {
|
|
18
18
|
left: "left-3",
|
|
@@ -32,10 +32,10 @@ const buttonVariants = cva(
|
|
|
32
32
|
md: "min-h-8 px-6 max-md:py-2 text-sm",
|
|
33
33
|
lg: "min-h-10 px-8 max-md:py-3 text-base",
|
|
34
34
|
xl: "min-h-11 px-10 max-md:py-4 text-lg",
|
|
35
|
-
"icon-sm": "p-
|
|
36
|
-
"icon-md": "p-1",
|
|
37
|
-
"icon-lg": "p-
|
|
38
|
-
"icon-xl": "p-
|
|
35
|
+
"icon-sm": "p-1",
|
|
36
|
+
"icon-md": "p-1.5",
|
|
37
|
+
"icon-lg": "p-2",
|
|
38
|
+
"icon-xl": "p-3"
|
|
39
39
|
},
|
|
40
40
|
variant: {
|
|
41
41
|
default: "rounded-lg text-text-opposite dark:text-text-opposite-dark",
|
|
@@ -78,7 +78,7 @@ const buttonVariants = cva(
|
|
|
78
78
|
false: ""
|
|
79
79
|
},
|
|
80
80
|
hasIconRight: {
|
|
81
|
-
true: "pr-
|
|
81
|
+
true: "pr-8",
|
|
82
82
|
false: ""
|
|
83
83
|
}
|
|
84
84
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n forwardRef,\n type ButtonHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { Loader } from '../Loader';\n\nconst buttonIconVariants = cva('', {\n variants: {\n size: {\n sm: 'size-3 absolute top-1/2 -translate-y-1/2',\n md: 'size-4 absolute top-1/2 -translate-y-1/2',\n lg: 'size-5 absolute top-1/2 -translate-y-1/2',\n xl: 'size-6 absolute top-1/2 -translate-y-1/2',\n 'icon-sm': 'size-6 p-1',\n 'icon-md': 'size-7 p-1',\n 'icon-lg': 'size-9 p-1',\n 'icon-xl': 'size-10 p-1',\n },\n position: {\n left: 'left-3',\n right: 'right-3',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nconst buttonVariants = cva(\n 'relative truncate whitespace-nowrap font-medium transition focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n size: {\n sm: 'min-h-7 px-3 max-md:py-1 text-xs',\n md: 'min-h-8 px-6 max-md:py-2 text-sm',\n lg: 'min-h-10 px-8 max-md:py-3 text-base',\n xl: 'min-h-11 px-10 max-md:py-4 text-lg',\n 'icon-sm': 'p-0.5',\n 'icon-md': 'p-1',\n 'icon-lg': 'p-1.5',\n 'icon-xl': 'p-2',\n },\n variant: {\n default: 'rounded-lg text-text-opposite dark:text-text-opposite-dark',\n none: 'border-none bg-opacity-0 text-inherit hover:bg-opacity-0 dark:bg-opacity-0 dark:text-inherit dark:hover:bg-opacity-0',\n outline:\n 'rounded-lg border-[1.5px] bg-opacity-0 hover:bg-opacity-30 dark:bg-opacity-0',\n link: 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent hover:underline dark:bg-transparent hover:dark:bg-transparent',\n 'invisible-link':\n 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent dark:bg-transparent hover:dark:bg-transparent',\n hoverable:\n 'rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10 aria-[current]:bg-opacity-5 dark:border-none dark:bg-opacity-0 dark:hover:bg-opacity-10',\n input: [\n 'w-full select-text resize-none rounded-xl border-2 bg-input-background text-sm text-input-text shadow-none outline-0 transition-all dark:bg-input-background-dark dark:text-input-text-dark',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none] dark:border-input-border-dark dark:hover:border-input-border-hover-dark dark:focus:border-input-border-focus',\n 'aria-[invalid=true]:border-error dark:aria-[invalid=true]:border-error-dark',\n 'disabled:opacity-50',\n ],\n },\n color: {\n primary:\n 'border-primary bg-primary text-primary hover:bg-primary-500 dark:border-primary-dark dark:bg-primary-dark dark:text-primary-dark hover:dark:bg-primary-300',\n secondary:\n 'border-secondary bg-secondary text-secondary hover:bg-secondary-300 dark:border-secondary-dark dark:bg-secondary-dark dark:text-secondary-dark hover:dark:bg-secondary-100',\n destructive:\n 'border-destructive bg-destructive text-destructive hover:bg-destructive-500 dark:border-destructive-dark dark:bg-destructive-dark hover:dark:bg-destructive-200',\n neutral:\n 'border-neutral bg-neutral text-neutral hover:bg-neutral-600 dark:border-neutral-dark dark:bg-neutral-dark dark:text-neutral-dark hover:dark:bg-neutral-400',\n light: 'border-white bg-white text-white hover:bg-neutral-500',\n dark: 'border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900 dark:hover:bg-neutral-700',\n text: 'border-text bg-text text-text hover:opacity-80 dark:border-text-dark dark:bg-text-dark dark:text-text-dark',\n 'text-inverse':\n 'border-text-dark dark:border-text bg-text-dark dark:bg-text text-text-dark dark:text-text hover:opacity-80',\n error:\n 'border-error bg-error text-error hover:bg-error-500 dark:border-error-dark dark:bg-error-dark dark:text-error-dark hover:dark:bg-error-300',\n success:\n 'border-success bg-success text-success hover:bg-success-500 dark:border-success-dark dark:bg-success-dark dark:text-success-dark hover:dark:bg-success-300',\n custom: '',\n },\n\n textAlign: {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n },\n\n isFullWidth: {\n true: 'w-full',\n false: '',\n },\n\n hasIconLeft: {\n true: 'pl-12',\n false: '',\n },\n hasIconRight: {\n true: 'pr-12',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n color: 'primary',\n textAlign: 'center',\n isFullWidth: false,\n hasIconRight: false,\n hasIconLeft: false,\n },\n }\n);\n\nexport type ButtonProps = DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n> &\n VariantProps<typeof buttonVariants> & {\n /**\n * Optional icon to be displayed on the button\n */\n label: string;\n Icon?: FC | LucideIcon;\n IconRight?: FC | LucideIcon;\n iconClassName?: string;\n isLoading?: boolean;\n isActive?: boolean;\n isFullWidth?: boolean;\n };\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant,\n size,\n color,\n children,\n Icon,\n IconRight,\n iconClassName,\n isLoading,\n isActive,\n isFullWidth = false,\n textAlign,\n disabled,\n label,\n className,\n type = 'button',\n ...props\n },\n ref\n ) => {\n const isLink = variant === 'link' || variant === 'invisible-link';\n\n return (\n <button\n ref={ref}\n disabled={isLoading || disabled}\n aria-current={isActive ? 'page' : undefined}\n aria-label={label}\n aria-busy={isLoading}\n role={isLink ? 'link' : undefined}\n type={type}\n className={buttonVariants({\n variant,\n size,\n color,\n isFullWidth,\n textAlign: textAlign ?? (IconRight ? 'left' : 'center'),\n hasIconLeft: Boolean(\n typeof children !== 'undefined' &&\n (typeof Icon !== 'undefined' || typeof isLoading !== 'undefined')\n ),\n hasIconRight: Boolean(\n typeof children !== 'undefined' && typeof IconRight !== 'undefined'\n ),\n className,\n })}\n {...props}\n >\n {Icon && !isLoading && (\n <Icon\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n />\n )}\n\n <Loader\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n isLoading={isLoading ?? false}\n />\n\n {children}\n\n {IconRight && (\n <IconRight\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'right',\n })}\n />\n )}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n"],"names":["jsxs","jsx"],"mappings":";;;;AAUA,MAAM,qBAAqB,IAAI,IAAI;AAAA,EACjC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC;AAED,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,MACb;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,QACT,MAAM;AAAA,QACN,SACE;AAAA,QACF,MAAM;AAAA,QACN,kBACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAAA,MACA,OAAO;AAAA,QACL,SACE;AAAA,QACF,WACE;AAAA,QACF,aACE;AAAA,QACF,SACE;AAAA,QACF,OAAO;AAAA,QACP,MA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Z,OAAO,aAAa,eAAe,OAAO,cAAc;AAAA,UAC1D;AAAA,UACA;AAAA,QAAA,CACD;AAAA,QACA,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,QAAQ,CAAC,aACRC,kCAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cACX,CAAA;AAAA,YAAA;AAAA,UACH;AAAA,UAGFA,kCAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cAAA,CACX;AAAA,cACD,WAAW,aAAa;AAAA,YAAA;AAAA,UAC1B;AAAA,UAEC;AAAA,UAEA,aACCA,kCAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,mBAAmB;AAAA,gBAC5B;AAAA,gBACA,WAAW;AAAA,gBACX,UAAU;AAAA,cACX,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AAAA,EAAA;AAGN;AAEA,OAAO,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n forwardRef,\n type ButtonHTMLAttributes,\n type DetailedHTMLProps,\n type FC,\n} from 'react';\nimport { Loader } from '../Loader';\n\nconst buttonIconVariants = cva('', {\n variants: {\n size: {\n sm: 'size-3 absolute top-1/2 -translate-y-1/2',\n md: 'size-4 absolute top-1/2 -translate-y-1/2',\n lg: 'size-5 absolute top-1/2 -translate-y-1/2',\n xl: 'size-6 absolute top-1/2 -translate-y-1/2',\n 'icon-sm': 'size-3',\n 'icon-md': 'size-4',\n 'icon-lg': 'size-5',\n 'icon-xl': 'size-6',\n },\n position: {\n left: 'left-3',\n right: 'right-3',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nconst buttonVariants = cva(\n 'relative truncate whitespace-nowrap font-medium transition focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n size: {\n sm: 'min-h-7 px-3 max-md:py-1 text-xs',\n md: 'min-h-8 px-6 max-md:py-2 text-sm',\n lg: 'min-h-10 px-8 max-md:py-3 text-base',\n xl: 'min-h-11 px-10 max-md:py-4 text-lg',\n 'icon-sm': 'p-1',\n 'icon-md': 'p-1.5',\n 'icon-lg': 'p-2',\n 'icon-xl': 'p-3',\n },\n variant: {\n default: 'rounded-lg text-text-opposite dark:text-text-opposite-dark',\n none: 'border-none bg-opacity-0 text-inherit hover:bg-opacity-0 dark:bg-opacity-0 dark:text-inherit dark:hover:bg-opacity-0',\n outline:\n 'rounded-lg border-[1.5px] bg-opacity-0 hover:bg-opacity-30 dark:bg-opacity-0',\n link: 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent hover:underline dark:bg-transparent hover:dark:bg-transparent',\n 'invisible-link':\n 'h-auto justify-start border-inherit bg-transparent px-1 underline-offset-4 hover:bg-transparent dark:bg-transparent hover:dark:bg-transparent',\n hoverable:\n 'rounded-lg border-none bg-opacity-0 transition hover:bg-opacity-10 aria-[current]:bg-opacity-5 dark:border-none dark:bg-opacity-0 dark:hover:bg-opacity-10',\n input: [\n 'w-full select-text resize-none rounded-xl border-2 bg-input-background text-sm text-input-text shadow-none outline-0 transition-all dark:bg-input-background-dark dark:text-input-text-dark',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none] dark:border-input-border-dark dark:hover:border-input-border-hover-dark dark:focus:border-input-border-focus',\n 'aria-[invalid=true]:border-error dark:aria-[invalid=true]:border-error-dark',\n 'disabled:opacity-50',\n ],\n },\n color: {\n primary:\n 'border-primary bg-primary text-primary hover:bg-primary-500 dark:border-primary-dark dark:bg-primary-dark dark:text-primary-dark hover:dark:bg-primary-300',\n secondary:\n 'border-secondary bg-secondary text-secondary hover:bg-secondary-300 dark:border-secondary-dark dark:bg-secondary-dark dark:text-secondary-dark hover:dark:bg-secondary-100',\n destructive:\n 'border-destructive bg-destructive text-destructive hover:bg-destructive-500 dark:border-destructive-dark dark:bg-destructive-dark hover:dark:bg-destructive-200',\n neutral:\n 'border-neutral bg-neutral text-neutral hover:bg-neutral-600 dark:border-neutral-dark dark:bg-neutral-dark dark:text-neutral-dark hover:dark:bg-neutral-400',\n light: 'border-white bg-white text-white hover:bg-neutral-500',\n dark: 'border-neutral-800 bg-neutral-800 text-neutral-800 hover:bg-neutral-900 dark:hover:bg-neutral-700',\n text: 'border-text bg-text text-text hover:opacity-80 dark:border-text-dark dark:bg-text-dark dark:text-text-dark',\n 'text-inverse':\n 'border-text-dark dark:border-text bg-text-dark dark:bg-text text-text-dark dark:text-text hover:opacity-80',\n error:\n 'border-error bg-error text-error hover:bg-error-500 dark:border-error-dark dark:bg-error-dark dark:text-error-dark hover:dark:bg-error-300',\n success:\n 'border-success bg-success text-success hover:bg-success-500 dark:border-success-dark dark:bg-success-dark dark:text-success-dark hover:dark:bg-success-300',\n custom: '',\n },\n\n textAlign: {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n },\n\n isFullWidth: {\n true: 'w-full',\n false: '',\n },\n\n hasIconLeft: {\n true: 'pl-12',\n false: '',\n },\n hasIconRight: {\n true: 'pr-8',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n color: 'primary',\n textAlign: 'center',\n isFullWidth: false,\n hasIconRight: false,\n hasIconLeft: false,\n },\n }\n);\n\nexport type ButtonProps = DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n> &\n VariantProps<typeof buttonVariants> & {\n /**\n * Optional icon to be displayed on the button\n */\n label: string;\n Icon?: FC | LucideIcon;\n IconRight?: FC | LucideIcon;\n iconClassName?: string;\n isLoading?: boolean;\n isActive?: boolean;\n isFullWidth?: boolean;\n };\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n variant,\n size,\n color,\n children,\n Icon,\n IconRight,\n iconClassName,\n isLoading,\n isActive,\n isFullWidth = false,\n textAlign,\n disabled,\n label,\n className,\n type = 'button',\n ...props\n },\n ref\n ) => {\n const isLink = variant === 'link' || variant === 'invisible-link';\n\n return (\n <button\n ref={ref}\n disabled={isLoading || disabled}\n aria-current={isActive ? 'page' : undefined}\n aria-label={label}\n aria-busy={isLoading}\n role={isLink ? 'link' : undefined}\n type={type}\n className={buttonVariants({\n variant,\n size,\n color,\n isFullWidth,\n textAlign: textAlign ?? (IconRight ? 'left' : 'center'),\n hasIconLeft: Boolean(\n typeof children !== 'undefined' &&\n (typeof Icon !== 'undefined' || typeof isLoading !== 'undefined')\n ),\n hasIconRight: Boolean(\n typeof children !== 'undefined' && typeof IconRight !== 'undefined'\n ),\n className,\n })}\n {...props}\n >\n {Icon && !isLoading && (\n <Icon\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n />\n )}\n\n <Loader\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'left',\n })}\n isLoading={isLoading ?? false}\n />\n\n {children}\n\n {IconRight && (\n <IconRight\n className={buttonIconVariants({\n size,\n className: iconClassName,\n position: 'right',\n })}\n />\n )}\n </button>\n );\n }\n);\n\nButton.displayName = 'Button';\n"],"names":["jsxs","jsx"],"mappings":";;;;AAUA,MAAM,qBAAqB,IAAI,IAAI;AAAA,EACjC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AA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;AAAA,EAAA;AAGN;AAEA,OAAO,cAAc;"}
|
|
@@ -8,6 +8,7 @@ const components_DictionaryEditor_NodeWrapper_ArrayWrapper = require("../../inde
|
|
|
8
8
|
const components_DictionaryEditor_ValidDictionaryChangeButtons = require("./ValidDictionaryChangeButtons.cjs");
|
|
9
9
|
const DictionaryEditor = ({
|
|
10
10
|
dictionary,
|
|
11
|
+
mode,
|
|
11
12
|
...props
|
|
12
13
|
}) => {
|
|
13
14
|
const { editedContent, addEditedContent } = editorReact.useEditedContent();
|
|
@@ -20,9 +21,9 @@ const DictionaryEditor = ({
|
|
|
20
21
|
...props,
|
|
21
22
|
keyPath: [],
|
|
22
23
|
key: JSON.stringify(
|
|
23
|
-
(editedContent[dictionary.key] ?? dictionary).content
|
|
24
|
+
(editedContent?.[dictionary.key] ?? dictionary).content
|
|
24
25
|
),
|
|
25
|
-
editedContent: editedContent[dictionary.key]?.content,
|
|
26
|
+
editedContent: editedContent?.[dictionary.key]?.content,
|
|
26
27
|
focusedKeyPath,
|
|
27
28
|
section: dictionary.content,
|
|
28
29
|
onContentChange: (content) => {
|
|
@@ -31,7 +32,7 @@ const DictionaryEditor = ({
|
|
|
31
32
|
onFocusKeyPath: setFocusedContentKeyPath
|
|
32
33
|
}
|
|
33
34
|
) }),
|
|
34
|
-
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(components_DictionaryEditor_ValidDictionaryChangeButtons.ValidDictionaryChangeButtons, { dictionary })
|
|
35
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(components_DictionaryEditor_ValidDictionaryChangeButtons.ValidDictionaryChangeButtons, { dictionary, mode })
|
|
35
36
|
] });
|
|
36
37
|
};
|
|
37
38
|
exports.DictionaryEditor = DictionaryEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryEditor.cjs","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\nimport { ValidDictionaryChangeButtons } from './ValidDictionaryChangeButtons';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locales;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n\n return (\n <div className=\"flex h-full flex-col justify-between gap-2\">\n <div>\n <NodeWrapper\n {...props}\n keyPath={[]}\n key={JSON.stringify(\n (editedContent[dictionary.key] ?? dictionary).content\n )}\n editedContent={editedContent[dictionary.key]?.content}\n focusedKeyPath={focusedKeyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(dictionary.key, content.newValue, content.keyPath);\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n <ValidDictionaryChangeButtons dictionary={dictionary} />\n </div>\n );\n};\n"],"names":["useEditedContent","useFocusDictionary","jsxs","jsx","createElement","NodeWrapper","ValidDictionaryChangeButtons"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"DictionaryEditor.cjs","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\nimport { ValidDictionaryChangeButtons } from './ValidDictionaryChangeButtons';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locales;\n mode: 'local' | 'remote';\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n mode,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n\n return (\n <div className=\"flex h-full flex-col justify-between gap-2\">\n <div>\n <NodeWrapper\n {...props}\n keyPath={[]}\n key={JSON.stringify(\n (editedContent?.[dictionary.key] ?? dictionary).content\n )}\n editedContent={editedContent?.[dictionary.key]?.content}\n focusedKeyPath={focusedKeyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(dictionary.key, content.newValue, content.keyPath);\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n <ValidDictionaryChangeButtons dictionary={dictionary} mode={mode} />\n </div>\n );\n};\n"],"names":["useEditedContent","useFocusDictionary","jsxs","jsx","createElement","NodeWrapper","ValidDictionaryChangeButtons"],"mappings":";;;;;;;;AAgBO,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,eAAe,iBAAiB,IAAIA,6BAAiB;AAC7D,QAAM,EAAE,gBAAgB,yBAAyB,IAAIC,+BAAmB;AAExE,QAAM,iBAAiB,gBAAgB;AAGrC,SAAAC,2BAAA,kBAAA,KAAC,OAAI,EAAA,WAAU,8CACb,UAAA;AAAA,IAAAC,iDAAC,OACC,EAAA,UAAAC,2BAAA;AAAA,MAACC,qDAAA;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ,SAAS,CAAC;AAAA,QACV,KAAK,KAAK;AAAA,WACP,gBAAgB,WAAW,GAAG,KAAK,YAAY;AAAA,QAClD;AAAA,QACA,eAAe,gBAAgB,WAAW,GAAG,GAAG;AAAA,QAChD;AAAA,QACA,SAAS,WAAW;AAAA,QACpB,iBAAiB,CAAC,YAAY;AAC5B,2BAAiB,WAAW,KAAK,QAAQ,UAAU,QAAQ,OAAO;AAAA,QACpE;AAAA,QACA,gBAAgB;AAAA,MAAA;AAAA,IAAA,GAEpB;AAAA,IACAF,2BAAAA,kBAAAA,IAACG,yDAA6B,8BAAA,EAAA,YAAwB,KAAY,CAAA;AAAA,EAAA,GACpE;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"DictionaryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA+BtD,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { N as NodeWrapper } from "../../index-B-adg6xa.js";
|
|
|
6
6
|
import { ValidDictionaryChangeButtons } from "./ValidDictionaryChangeButtons.mjs";
|
|
7
7
|
const DictionaryEditor = ({
|
|
8
8
|
dictionary,
|
|
9
|
+
mode,
|
|
9
10
|
...props
|
|
10
11
|
}) => {
|
|
11
12
|
const { editedContent, addEditedContent } = useEditedContent();
|
|
@@ -18,9 +19,9 @@ const DictionaryEditor = ({
|
|
|
18
19
|
...props,
|
|
19
20
|
keyPath: [],
|
|
20
21
|
key: JSON.stringify(
|
|
21
|
-
(editedContent[dictionary.key] ?? dictionary).content
|
|
22
|
+
(editedContent?.[dictionary.key] ?? dictionary).content
|
|
22
23
|
),
|
|
23
|
-
editedContent: editedContent[dictionary.key]?.content,
|
|
24
|
+
editedContent: editedContent?.[dictionary.key]?.content,
|
|
24
25
|
focusedKeyPath,
|
|
25
26
|
section: dictionary.content,
|
|
26
27
|
onContentChange: (content) => {
|
|
@@ -29,7 +30,7 @@ const DictionaryEditor = ({
|
|
|
29
30
|
onFocusKeyPath: setFocusedContentKeyPath
|
|
30
31
|
}
|
|
31
32
|
) }),
|
|
32
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ValidDictionaryChangeButtons, { dictionary })
|
|
33
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ValidDictionaryChangeButtons, { dictionary, mode })
|
|
33
34
|
] });
|
|
34
35
|
};
|
|
35
36
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryEditor.mjs","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\nimport { ValidDictionaryChangeButtons } from './ValidDictionaryChangeButtons';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locales;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n\n return (\n <div className=\"flex h-full flex-col justify-between gap-2\">\n <div>\n <NodeWrapper\n {...props}\n keyPath={[]}\n key={JSON.stringify(\n (editedContent[dictionary.key] ?? dictionary).content\n )}\n editedContent={editedContent[dictionary.key]?.content}\n focusedKeyPath={focusedKeyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(dictionary.key, content.newValue, content.keyPath);\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n <ValidDictionaryChangeButtons dictionary={dictionary} />\n </div>\n );\n};\n"],"names":["jsxs","jsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"DictionaryEditor.mjs","sources":["../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { Dictionary, KeyPath } from '@intlayer/core';\nimport { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\nimport { ValidDictionaryChangeButtons } from './ValidDictionaryChangeButtons';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locales;\n mode: 'local' | 'remote';\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n mode,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n\n return (\n <div className=\"flex h-full flex-col justify-between gap-2\">\n <div>\n <NodeWrapper\n {...props}\n keyPath={[]}\n key={JSON.stringify(\n (editedContent?.[dictionary.key] ?? dictionary).content\n )}\n editedContent={editedContent?.[dictionary.key]?.content}\n focusedKeyPath={focusedKeyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(dictionary.key, content.newValue, content.keyPath);\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n <ValidDictionaryChangeButtons dictionary={dictionary} mode={mode} />\n </div>\n );\n};\n"],"names":["jsxs","jsx"],"mappings":";;;;;;AAgBO,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,eAAe,iBAAiB,IAAI,iBAAiB;AAC7D,QAAM,EAAE,gBAAgB,yBAAyB,IAAI,mBAAmB;AAExE,QAAM,iBAAiB,gBAAgB;AAGrC,SAAAA,kCAAA,KAAC,OAAI,EAAA,WAAU,8CACb,UAAA;AAAA,IAAAC,sCAAC,OACC,EAAA,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ,SAAS,CAAC;AAAA,QACV,KAAK,KAAK;AAAA,WACP,gBAAgB,WAAW,GAAG,KAAK,YAAY;AAAA,QAClD;AAAA,QACA,eAAe,gBAAgB,WAAW,GAAG,GAAG;AAAA,QAChD;AAAA,QACA,SAAS,WAAW;AAAA,QACpB,iBAAiB,CAAC,YAAY;AAC5B,2BAAiB,WAAW,KAAK,QAAQ,UAAU,QAAQ,OAAO;AAAA,QACpE;AAAA,QACA,gBAAgB;AAAA,MAAA;AAAA,IAAA,GAEpB;AAAA,IACAA,kCAAAA,IAAC,8BAA6B,EAAA,YAAwB,KAAY,CAAA;AAAA,EAAA,GACpE;AAEJ;"}
|
|
@@ -15,18 +15,17 @@ require("../Form/FormField.cjs");
|
|
|
15
15
|
const components_Form_layout_FormItemLayout = require("../../Form-CSMiPnjC.cjs");
|
|
16
16
|
const components_DictionaryEditor_validDictionaryChangeButtons_content = require("./validDictionaryChangeButtons.content.cjs");
|
|
17
17
|
const components_DictionaryEditor_validDictionaryChangeButtonsSchema = require("./validDictionaryChangeButtonsSchema.cjs");
|
|
18
|
-
const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
18
|
+
const ValidDictionaryChangeButtons = ({ dictionary, mode }) => {
|
|
19
19
|
const ValidDictionaryChangeButtonsSchemaSchema = components_DictionaryEditor_validDictionaryChangeButtonsSchema.getValidDictionaryChangeButtonsSchemaSchema();
|
|
20
|
-
const { resetButton, saveButton, publishButton } = reactIntlayer.useDictionary(
|
|
21
|
-
|
|
22
|
-
);
|
|
20
|
+
const { resetButton, saveButton, publishButton, downloadButton } = reactIntlayer.useDictionary(components_DictionaryEditor_validDictionaryChangeButtons_content.validDictionaryChangeButtonsContent);
|
|
21
|
+
const { writeDictionary } = hooks_intlayerAPIHooks.useWriteDictionary();
|
|
23
22
|
const { pushDictionaries } = hooks_intlayerAPIHooks.usePushDictionaries();
|
|
24
23
|
const { editedContent, restoreEditedContent } = editorReact.useEditedContent();
|
|
25
24
|
const { form, isSubmitting } = components_Form_FormBase.useForm(
|
|
26
25
|
ValidDictionaryChangeButtonsSchemaSchema
|
|
27
26
|
);
|
|
28
27
|
const editedDictionary = require$$0.useMemo(
|
|
29
|
-
() => editedContent[dictionary.key],
|
|
28
|
+
() => editedContent?.[dictionary.key],
|
|
30
29
|
[editedContent, dictionary.key]
|
|
31
30
|
);
|
|
32
31
|
const isEdited = require$$0.useMemo(
|
|
@@ -38,12 +37,19 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
38
37
|
[dictionary]
|
|
39
38
|
);
|
|
40
39
|
const onSubmitSuccess = async () => {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (mode === "remote") {
|
|
41
|
+
await pushDictionaries([
|
|
42
|
+
{
|
|
43
|
+
...dictionary,
|
|
44
|
+
...editedContent?.[dictionary.key]
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
} else {
|
|
48
|
+
await writeDictionary({
|
|
43
49
|
...dictionary,
|
|
44
|
-
...editedContent[dictionary.key]
|
|
45
|
-
}
|
|
46
|
-
|
|
50
|
+
...editedContent?.[dictionary.key]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
47
53
|
};
|
|
48
54
|
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
|
|
49
55
|
components_Form_layout_FormItemLayout.Form,
|
|
@@ -69,7 +75,7 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
69
75
|
children: resetButton.text
|
|
70
76
|
}
|
|
71
77
|
),
|
|
72
|
-
isLocalDictionary ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
78
|
+
mode === "remote" ? isLocalDictionary ? /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
73
79
|
components_Form_layout_FormItemLayout.Form.Button,
|
|
74
80
|
{
|
|
75
81
|
type: "submit",
|
|
@@ -93,6 +99,18 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
93
99
|
isLoading: isSubmitting,
|
|
94
100
|
children: saveButton.text
|
|
95
101
|
}
|
|
102
|
+
) : /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
103
|
+
components_Form_layout_FormItemLayout.Form.Button,
|
|
104
|
+
{
|
|
105
|
+
type: "submit",
|
|
106
|
+
label: downloadButton.label,
|
|
107
|
+
disabled: !isEdited || isSubmitting,
|
|
108
|
+
Icon: lucideReact.Download,
|
|
109
|
+
color: "text",
|
|
110
|
+
isFullWidth: true,
|
|
111
|
+
isLoading: isSubmitting,
|
|
112
|
+
children: downloadButton.text
|
|
113
|
+
}
|
|
96
114
|
)
|
|
97
115
|
]
|
|
98
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidDictionaryChangeButtons.cjs","sources":["../../../src/components/DictionaryEditor/ValidDictionaryChangeButtons.tsx"],"sourcesContent":["'use client';\n\nimport { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { ArrowUpFromLine, RotateCcw, Save } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries } from '../../hooks';\nimport { Form, useForm } from '../Form';\nimport { validDictionaryChangeButtonsContent } from './validDictionaryChangeButtons.content';\nimport { getValidDictionaryChangeButtonsSchemaSchema } from './validDictionaryChangeButtonsSchema';\n\ntype ValidDictionaryChangeButtonsProps = {\n dictionary: Dictionary;\n};\n\nexport const ValidDictionaryChangeButtons: FC<\n ValidDictionaryChangeButtonsProps\n> = ({ dictionary }) => {\n const ValidDictionaryChangeButtonsSchemaSchema =\n getValidDictionaryChangeButtonsSchemaSchema();\n\n const { resetButton, saveButton, publishButton }
|
|
1
|
+
{"version":3,"file":"ValidDictionaryChangeButtons.cjs","sources":["../../../src/components/DictionaryEditor/ValidDictionaryChangeButtons.tsx"],"sourcesContent":["'use client';\n\nimport { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../hooks';\nimport { Form, useForm } from '../Form';\nimport { validDictionaryChangeButtonsContent } from './validDictionaryChangeButtons.content';\nimport { getValidDictionaryChangeButtonsSchemaSchema } from './validDictionaryChangeButtonsSchema';\n\ntype ValidDictionaryChangeButtonsProps = {\n dictionary: Dictionary;\n mode: 'local' | 'remote';\n};\n\nexport const ValidDictionaryChangeButtons: FC<\n ValidDictionaryChangeButtonsProps\n> = ({ dictionary, mode }) => {\n const ValidDictionaryChangeButtonsSchemaSchema =\n getValidDictionaryChangeButtonsSchemaSchema();\n\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(validDictionaryChangeButtonsContent);\n\n const { writeDictionary } = useWriteDictionary();\n const { pushDictionaries } = usePushDictionaries();\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { form, isSubmitting } = useForm(\n ValidDictionaryChangeButtonsSchemaSchema\n );\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary?.content) !==\n JSON.stringify(dictionary?.content),\n [editedDictionary, dictionary]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const onSubmitSuccess = async () => {\n if (mode === 'remote') {\n await pushDictionaries([\n {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n },\n ]);\n } else {\n await writeDictionary({\n ...dictionary,\n ...editedContent?.[dictionary.key],\n });\n }\n };\n\n return (\n <div className=\"mb-4\">\n <Form\n className=\"flex w-full flex-row flex-wrap justify-end gap-3\"\n {...form}\n schema={ValidDictionaryChangeButtonsSchemaSchema}\n onSubmitSuccess={onSubmitSuccess}\n >\n {isEdited && (\n <Form.Button\n type=\"button\"\n label={resetButton.label}\n disabled={!isEdited || isSubmitting}\n className=\"ml-auto\"\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n isFullWidth\n isLoading={isSubmitting}\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode === 'remote' ? (\n isLocalDictionary ? (\n <Form.Button\n type=\"submit\"\n label={publishButton.label}\n disabled={!isEdited || isSubmitting}\n Icon={ArrowUpFromLine}\n color=\"text\"\n isFullWidth\n isLoading={isSubmitting}\n >\n {publishButton.text}\n </Form.Button>\n ) : (\n isEdited && (\n <Form.Button\n type=\"submit\"\n label={saveButton.label}\n disabled={!isEdited || isSubmitting}\n Icon={Save}\n color=\"text\"\n isFullWidth\n isLoading={isSubmitting}\n >\n {saveButton.text}\n </Form.Button>\n )\n )\n ) : (\n <Form.Button\n type=\"submit\"\n label={downloadButton.label}\n disabled={!isEdited || isSubmitting}\n Icon={Download}\n color=\"text\"\n isFullWidth\n isLoading={isSubmitting}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n </Form>\n </div>\n );\n};\n"],"names":["getValidDictionaryChangeButtonsSchemaSchema","useDictionary","validDictionaryChangeButtonsContent","useWriteDictionary","usePushDictionaries","useEditedContent","useForm","useMemo","jsx","jsxs","Form","RotateCcw","ArrowUpFromLine","Save","Download"],"mappings":";;;;;;;;;;;;;;;;;AAmBO,MAAM,+BAET,CAAC,EAAE,YAAY,WAAW;AAC5B,QAAM,2CACJA,+DAAAA,4CAA4C;AAE9C,QAAM,EAAE,aAAa,YAAY,eAAe,eAAe,IAC7DC,4BAAcC,oGAAmC;AAE7C,QAAA,EAAE,gBAAgB,IAAIC,0CAAmB;AACzC,QAAA,EAAE,iBAAiB,IAAIC,2CAAoB;AAEjD,QAAM,EAAE,eAAe,qBAAqB,IAAIC,6BAAiB;AAC3D,QAAA,EAAE,MAAM,aAAA,IAAiBC,yBAAA;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,mBAAmBC,WAAA;AAAA,IACvB,MAAM,gBAAgB,WAAW,GAAG;AAAA,IACpC,CAAC,eAAe,WAAW,GAAG;AAAA,EAChC;AAEA,QAAM,WAAWA,WAAA;AAAA,IACf,MACE,oBACA,KAAK,UAAU,kBAAkB,OAAO,MACtC,KAAK,UAAU,YAAY,OAAO;AAAA,IACtC,CAAC,kBAAkB,UAAU;AAAA,EAC/B;AAEA,QAAM,oBAAoBA,WAAA;AAAA,IACxB,MAAM,OAAQ,YAAkC,QAAQ;AAAA,IACxD,CAAC,UAAU;AAAA,EACb;AAEA,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AY;AAAA,YACvB,MAAMG,YAAA;AAAA,YACN,OAAM;AAAA,YACN,aAAW;AAAA,YACX,WAAW;AAAA,YAEV,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA,IAKlBL,2BAAA,kBAAA;AAAA,UAACE,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,MAAK;AAAA,YACL,OAAO,eAAe;AAAA,YACtB,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMI,YAAA;AAAA,YACN,OAAM;AAAA,YACN,aAAW;AAAA,YACX,WAAW;AAAA,YAEV,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ;;"}
|
|
@@ -2,6 +2,7 @@ import { Dictionary } from '@intlayer/core';
|
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
type ValidDictionaryChangeButtonsProps = {
|
|
4
4
|
dictionary: Dictionary;
|
|
5
|
+
mode: 'local' | 'remote';
|
|
5
6
|
};
|
|
6
7
|
export declare const ValidDictionaryChangeButtons: FC<ValidDictionaryChangeButtonsProps>;
|
|
7
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidDictionaryChangeButtons.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryEditor/ValidDictionaryChangeButtons.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQzC,KAAK,iCAAiC,GAAG;IACvC,UAAU,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ValidDictionaryChangeButtons.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryEditor/ValidDictionaryChangeButtons.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQzC,KAAK,iCAAiC,GAAG;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,EAAE,CAC3C,iCAAiC,CAsHlC,CAAC"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as jsxRuntimeExports } from "../../jsx-runtime-DQkoUcjV.js";
|
|
3
3
|
import { useEditedContent } from "@intlayer/editor-react";
|
|
4
|
-
import { RotateCcw, ArrowUpFromLine, Save } from "lucide-react";
|
|
4
|
+
import { RotateCcw, ArrowUpFromLine, Save, Download } from "lucide-react";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { useDictionary } from "react-intlayer";
|
|
7
7
|
import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
8
8
|
import "../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
9
|
-
import { usePushDictionaries } from "../../hooks/intlayerAPIHooks.mjs";
|
|
9
|
+
import { useWriteDictionary, usePushDictionaries } from "../../hooks/intlayerAPIHooks.mjs";
|
|
10
10
|
import "deepmerge";
|
|
11
11
|
import { useForm } from "../Form/FormBase.mjs";
|
|
12
12
|
import "../Form/FormField.mjs";
|
|
13
13
|
import { F as Form } from "../../Form-DlqjTz3u.js";
|
|
14
14
|
import { validDictionaryChangeButtonsContent } from "./validDictionaryChangeButtons.content.mjs";
|
|
15
15
|
import { getValidDictionaryChangeButtonsSchemaSchema } from "./validDictionaryChangeButtonsSchema.mjs";
|
|
16
|
-
const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
16
|
+
const ValidDictionaryChangeButtons = ({ dictionary, mode }) => {
|
|
17
17
|
const ValidDictionaryChangeButtonsSchemaSchema = getValidDictionaryChangeButtonsSchemaSchema();
|
|
18
|
-
const { resetButton, saveButton, publishButton } = useDictionary(
|
|
19
|
-
|
|
20
|
-
);
|
|
18
|
+
const { resetButton, saveButton, publishButton, downloadButton } = useDictionary(validDictionaryChangeButtonsContent);
|
|
19
|
+
const { writeDictionary } = useWriteDictionary();
|
|
21
20
|
const { pushDictionaries } = usePushDictionaries();
|
|
22
21
|
const { editedContent, restoreEditedContent } = useEditedContent();
|
|
23
22
|
const { form, isSubmitting } = useForm(
|
|
24
23
|
ValidDictionaryChangeButtonsSchemaSchema
|
|
25
24
|
);
|
|
26
25
|
const editedDictionary = useMemo(
|
|
27
|
-
() => editedContent[dictionary.key],
|
|
26
|
+
() => editedContent?.[dictionary.key],
|
|
28
27
|
[editedContent, dictionary.key]
|
|
29
28
|
);
|
|
30
29
|
const isEdited = useMemo(
|
|
@@ -36,12 +35,19 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
36
35
|
[dictionary]
|
|
37
36
|
);
|
|
38
37
|
const onSubmitSuccess = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (mode === "remote") {
|
|
39
|
+
await pushDictionaries([
|
|
40
|
+
{
|
|
41
|
+
...dictionary,
|
|
42
|
+
...editedContent?.[dictionary.key]
|
|
43
|
+
}
|
|
44
|
+
]);
|
|
45
|
+
} else {
|
|
46
|
+
await writeDictionary({
|
|
41
47
|
...dictionary,
|
|
42
|
-
...editedContent[dictionary.key]
|
|
43
|
-
}
|
|
44
|
-
|
|
48
|
+
...editedContent?.[dictionary.key]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
45
51
|
};
|
|
46
52
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
47
53
|
Form,
|
|
@@ -67,7 +73,7 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
67
73
|
children: resetButton.text
|
|
68
74
|
}
|
|
69
75
|
),
|
|
70
|
-
isLocalDictionary ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
76
|
+
mode === "remote" ? isLocalDictionary ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
71
77
|
Form.Button,
|
|
72
78
|
{
|
|
73
79
|
type: "submit",
|
|
@@ -91,6 +97,18 @@ const ValidDictionaryChangeButtons = ({ dictionary }) => {
|
|
|
91
97
|
isLoading: isSubmitting,
|
|
92
98
|
children: saveButton.text
|
|
93
99
|
}
|
|
100
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
101
|
+
Form.Button,
|
|
102
|
+
{
|
|
103
|
+
type: "submit",
|
|
104
|
+
label: downloadButton.label,
|
|
105
|
+
disabled: !isEdited || isSubmitting,
|
|
106
|
+
Icon: Download,
|
|
107
|
+
color: "text",
|
|
108
|
+
isFullWidth: true,
|
|
109
|
+
isLoading: isSubmitting,
|
|
110
|
+
children: downloadButton.text
|
|
111
|
+
}
|
|
94
112
|
)
|
|
95
113
|
]
|
|
96
114
|
}
|