@lunejs/admin-ui 0.2.0 → 0.2.1

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 (39) hide show
  1. package/dist/lib/api/codegen/graphql.d.ts +1 -0
  2. package/dist/lib/api/codegen/graphql.js +8 -8
  3. package/dist/lib/custom-fields/components/details/is-list/custom-field-is-list.js +6 -4
  4. package/dist/lib/custom-fields/components/details/use-form/form-schema.d.ts +1 -0
  5. package/dist/lib/custom-fields/components/details/use-form/form-schema.js +4 -3
  6. package/dist/lib/custom-fields/components/fields/custom-field.js +44 -36
  7. package/dist/lib/custom-fields/components/fields/rich-text.d.ts +8 -0
  8. package/dist/lib/custom-fields/components/fields/rich-text.js +17 -0
  9. package/dist/lib/custom-fields/components/fields/shared/primitive.d.ts +2 -1
  10. package/dist/lib/custom-fields/components/fields/shared/primitive.js +67 -61
  11. package/dist/lib/custom-fields/utils/custom-field.utils.js +63 -51
  12. package/dist/lib/translate/components/form/translate-form-row-data.d.ts +2 -1
  13. package/dist/lib/translate/components/form/translate-form-row-data.js +51 -19
  14. package/dist/lib/translate/components/form/translate-rich-text.d.ts +8 -0
  15. package/dist/lib/translate/components/form/translate-rich-text.js +65 -0
  16. package/dist/lib/translate/components/product-form/custom-fields/translate-product-custom-fields.js +95 -63
  17. package/dist/lib/translate/components/product-form/translate-product-form.js +19 -18
  18. package/dist/node_modules/@tiptap/core/dist/index.js +876 -872
  19. package/dist/node_modules/@tiptap/extensions/dist/index.js +288 -0
  20. package/dist/node_modules/@tiptap/react/dist/index.js +35 -34
  21. package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
  22. package/dist/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
  23. package/dist/node_modules/lucide-react/dist/esm/icons/layout-list.js +13 -0
  24. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
  25. package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
  26. package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
  27. package/dist/node_modules/rope-sequence/dist/index.js +100 -0
  28. package/dist/shared/components/rich-editor/rich-editor.d.ts +3 -1
  29. package/dist/shared/components/rich-editor/rich-editor.js +40 -36
  30. package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.js +10 -9
  31. package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.js +1 -0
  32. package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.js +1 -0
  33. package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.js +5 -4
  34. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.js +8 -7
  35. package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.js +1 -0
  36. package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.js +9 -8
  37. package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.js +7 -6
  38. package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.js +3 -2
  39. package/package.json +1 -1
@@ -4,64 +4,76 @@ import u from "../../../node_modules/lucide-react/dist/esm/icons/boxes.js";
4
4
  import s from "../../../node_modules/lucide-react/dist/esm/icons/package.js";
5
5
  import p from "../../../node_modules/lucide-react/dist/esm/icons/pipette.js";
6
6
  import f from "../../../node_modules/lucide-react/dist/esm/icons/calendar.js";
7
- import C from "../../../node_modules/lucide-react/dist/esm/icons/toggle-left.js";
8
- import b from "../../../node_modules/lucide-react/dist/esm/icons/image.js";
7
+ import b from "../../../node_modules/lucide-react/dist/esm/icons/toggle-left.js";
8
+ import C from "../../../node_modules/lucide-react/dist/esm/icons/image.js";
9
9
  import g from "../../../node_modules/lucide-react/dist/esm/icons/dollar-sign.js";
10
- import a from "../../../node_modules/lucide-react/dist/esm/icons/hash.js";
10
+ import c from "../../../node_modules/lucide-react/dist/esm/icons/hash.js";
11
+ import T from "../../../node_modules/lucide-react/dist/esm/icons/layout-list.js";
11
12
  import d from "../../../node_modules/lucide-react/dist/esm/icons/earth.js";
12
- import T from "../../../node_modules/lucide-react/dist/esm/icons/text.js";
13
- import v from "../../../node_modules/lucide-react/dist/esm/icons/type.js";
14
- import x from "../../../node_modules/lucide-react/dist/esm/icons/shopping-cart.js";
15
- import D from "../../../node_modules/lucide-react/dist/esm/icons/user.js";
16
- class o {
17
- constructor(n, i) {
18
- this.title = n, this.icon = i;
13
+ import x from "../../../node_modules/lucide-react/dist/esm/icons/text.js";
14
+ import R from "../../../node_modules/lucide-react/dist/esm/icons/type.js";
15
+ import v from "../../../node_modules/lucide-react/dist/esm/icons/shopping-cart.js";
16
+ import w from "../../../node_modules/lucide-react/dist/esm/icons/user.js";
17
+ class t {
18
+ constructor(i, n) {
19
+ this.title = i, this.icon = n;
19
20
  }
20
21
  }
21
- const w = {
22
+ const D = {
22
23
  // Text
23
- [e.SingleLineText]: new o("Single line text", v),
24
- [e.MultiLineText]: new o("Multi line text", T),
25
- [e.Url]: new o("URL", d),
24
+ [e.SingleLineText]: new t("Single line text", R),
25
+ [e.MultiLineText]: new t("Multi line text", x),
26
+ [e.Url]: new t("URL", d),
27
+ [e.RichText]: new t("Rich text", T),
26
28
  // Number
27
- [e.Integer]: new o("Integer", a),
28
- [e.Decimal]: new o("Decimal", a),
29
- [e.Money]: new o("Money", g),
29
+ [e.Integer]: new t("Integer", c),
30
+ [e.Decimal]: new t("Decimal", c),
31
+ [e.Money]: new t("Money", g),
30
32
  // Media
31
- [e.Image]: new o("Image", b),
33
+ [e.Image]: new t("Image", C),
32
34
  // Other
33
- [e.Boolean]: new o("Boolean", C),
34
- [e.Date]: new o("Date", f),
35
- [e.Color]: new o("Color", p),
35
+ [e.Boolean]: new t("Boolean", b),
36
+ [e.Date]: new t("Date", f),
37
+ [e.Color]: new t("Color", p),
36
38
  // Reference
37
- [e.ProductReference]: new o("Product", s),
38
- [e.CollectionReference]: new o("Collection", u),
39
- [e.CustomObjectReference]: new o("Custom object", m),
40
- customer: new o("Customer", D),
41
- order: new o("Order", x)
42
- }, N = (t) => ({
39
+ [e.ProductReference]: new t("Product", s),
40
+ [e.CollectionReference]: new t("Collection", u),
41
+ [e.CustomObjectReference]: new t("Custom object", m),
42
+ customer: new t("Customer", w),
43
+ order: new t("Order", v)
44
+ }, _ = (l) => ({
43
45
  [r.Product]: "Product",
44
46
  [r.Collection]: "Collection",
45
47
  [r.CustomObject]: "Custom object",
46
48
  [r.OptionValue]: "Option value"
47
- })[t], l = (t) => w[t], V = (t) => [e.SingleLineText, e.MultiLineText].includes(t), _ = [
49
+ })[l], o = (l) => D[l], G = (l) => [
50
+ e.SingleLineText,
51
+ e.MultiLineText,
52
+ e.RichText,
53
+ e.Url
54
+ ].includes(l), $ = [
48
55
  {
49
56
  label: "Text",
50
57
  items: [
51
58
  {
52
59
  label: "Single line text",
53
60
  value: e.SingleLineText,
54
- icon: l(e.SingleLineText).icon
61
+ icon: o(e.SingleLineText).icon
55
62
  },
56
63
  {
57
64
  label: "Multi line text",
58
65
  value: e.MultiLineText,
59
- icon: l(e.MultiLineText).icon
66
+ icon: o(e.MultiLineText).icon
60
67
  },
61
68
  {
62
- label: l(e.Url).title,
69
+ label: o(e.RichText).title,
70
+ value: e.RichText,
71
+ icon: o(e.RichText).icon
72
+ },
73
+ {
74
+ label: o(e.Url).title,
63
75
  value: e.Url,
64
- icon: l(e.Url).icon
76
+ icon: o(e.Url).icon
65
77
  }
66
78
  ]
67
79
  },
@@ -71,17 +83,17 @@ const w = {
71
83
  {
72
84
  label: "Integer",
73
85
  value: e.Integer,
74
- icon: l(e.Integer).icon
86
+ icon: o(e.Integer).icon
75
87
  },
76
88
  {
77
89
  label: "Decimal",
78
90
  value: e.Decimal,
79
- icon: l(e.Decimal).icon
91
+ icon: o(e.Decimal).icon
80
92
  },
81
93
  {
82
94
  label: "Money",
83
95
  value: e.Money,
84
- icon: l(e.Money).icon
96
+ icon: o(e.Money).icon
85
97
  }
86
98
  ]
87
99
  },
@@ -91,7 +103,7 @@ const w = {
91
103
  {
92
104
  label: "Image",
93
105
  value: e.Image,
94
- icon: l(e.Image).icon
106
+ icon: o(e.Image).icon
95
107
  }
96
108
  ]
97
109
  },
@@ -101,17 +113,17 @@ const w = {
101
113
  {
102
114
  label: "Product",
103
115
  value: e.ProductReference,
104
- icon: l(e.ProductReference).icon
116
+ icon: o(e.ProductReference).icon
105
117
  },
106
118
  {
107
119
  label: "Collection",
108
120
  value: e.CollectionReference,
109
- icon: l(e.CollectionReference).icon
121
+ icon: o(e.CollectionReference).icon
110
122
  },
111
123
  {
112
124
  label: "Custom object",
113
125
  value: e.CustomObjectReference,
114
- icon: l(e.CustomObjectReference).icon
126
+ icon: o(e.CustomObjectReference).icon
115
127
  }
116
128
  ]
117
129
  },
@@ -121,28 +133,28 @@ const w = {
121
133
  {
122
134
  label: "Boolean",
123
135
  value: e.Boolean,
124
- icon: l(e.Boolean).icon
136
+ icon: o(e.Boolean).icon
125
137
  },
126
138
  {
127
139
  label: "Date",
128
140
  value: e.Date,
129
- icon: l(e.Date).icon
141
+ icon: o(e.Date).icon
130
142
  },
131
143
  {
132
- label: l(e.Color).title,
144
+ label: o(e.Color).title,
133
145
  value: e.Color,
134
- icon: l(e.Color).icon
146
+ icon: o(e.Color).icon
135
147
  }
136
148
  ]
137
149
  }
138
- ], G = (t, n) => {
139
- const i = t.values.find((c) => c.field.id === n.displayField?.id);
140
- return i ? i.value : `${n.name}#${t.slug.toUpperCase()}`;
150
+ ], k = (l, i) => {
151
+ const n = l.values.find((a) => a.field.id === i.displayField?.id);
152
+ return n ? n.value : `${i.name}#${l.slug.toUpperCase()}`;
141
153
  };
142
154
  export {
143
- _ as CUSTOM_FIELD_TYPE_GROUPS,
144
- l as getCustomFieldTypeData,
145
- G as getDisplayFieldValue,
146
- N as getEntityName,
147
- V as isTranslatable
155
+ $ as CUSTOM_FIELD_TYPE_GROUPS,
156
+ o as getCustomFieldTypeData,
157
+ k as getDisplayFieldValue,
158
+ _ as getEntityName,
159
+ G as isTranslatable
148
160
  };
@@ -1,5 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
- export declare const TranslateFormRowData: ({ children, field, reference, className }: Props) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TranslateFormRowData: ({ children, field, reference, richText, className }: Props) => import("react/jsx-runtime").JSX.Element;
3
3
  type Props = PropsWithChildren & {
4
4
  className?: string | {
5
5
  row?: string;
@@ -8,5 +8,6 @@ type Props = PropsWithChildren & {
8
8
  };
9
9
  field: string | null | undefined;
10
10
  reference: string | null | undefined;
11
+ richText?: boolean;
11
12
  };
12
13
  export {};
@@ -1,7 +1,7 @@
1
- import { jsxs as n, Fragment as a, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as a, Fragment as s, jsx as r } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-accordion/dist/index.js";
4
- import { cn as l } from "../../../../packages/lune-ui/dist/lib/utils.js";
4
+ import { cn as p } from "../../../../packages/lune-ui/dist/lib/utils.js";
5
5
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js";
6
6
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-avatar/dist/index.js";
7
7
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-separator/dist/index.js";
@@ -24,7 +24,7 @@ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-radio-gro
24
24
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-select/dist/index.js";
25
25
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-dialog/dist/index.js";
26
26
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-switch/dist/index.js";
27
- import { TableRow as d } from "../../../../packages/lune-ui/dist/components/table.js";
27
+ import { TableRow as u } from "../../../../packages/lune-ui/dist/components/table.js";
28
28
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tabs/dist/index.js";
29
29
  import "../../../../packages/lune-ui/dist/components/theme-provider.js";
30
30
  import "../../../../packages/lune-ui/dist/node_modules/sonner/dist/index.js";
@@ -32,37 +32,69 @@ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-toggle/di
32
32
  import "../../../../packages/lune-ui/dist/components/toggle-group.js";
33
33
  import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tooltip/dist/index.js";
34
34
  import "../../../../packages/lune-ui/dist/form/form.js";
35
- import { TranslateFormCell as o } from "./translate-form-cell.js";
36
- import { TranslateFormRow as p } from "./translate-form-row.js";
37
- const V = ({ children: e, field: i, reference: m, className: t }) => /* @__PURE__ */ n(a, { children: [
38
- /* @__PURE__ */ n(
39
- d,
35
+ import { RichEditor as l } from "../../../../shared/components/rich-editor/rich-editor.js";
36
+ import { TranslateFormCell as i } from "./translate-form-cell.js";
37
+ import { TranslateFormRow as e } from "./translate-form-row.js";
38
+ const X = ({
39
+ children: n,
40
+ field: m,
41
+ reference: o,
42
+ richText: d,
43
+ className: t
44
+ }) => /* @__PURE__ */ a(s, { children: [
45
+ /* @__PURE__ */ a(
46
+ u,
40
47
  {
41
- className: l(
48
+ className: p(
42
49
  "bg-transparent! hidden lg:table-row",
43
50
  typeof t == "string" ? t : t?.row
44
51
  ),
45
52
  children: [
46
- /* @__PURE__ */ r(o, { children: i }),
47
- /* @__PURE__ */ r(
48
- o,
53
+ /* @__PURE__ */ r(i, { children: m }),
54
+ d ? /* @__PURE__ */ r(
55
+ i,
49
56
  {
50
- className: l(
57
+ isDisabled: !0,
58
+ className: p(
59
+ typeof t == "string" ? void 0 : t?.referenceCell,
60
+ "text-muted-foreground p-0"
61
+ ),
62
+ children: /* @__PURE__ */ r(
63
+ l,
64
+ {
65
+ disabled: !0,
66
+ className: "rounded-none [&_.tiptap]:max-h-48 ring-0! border-none! [&_.rich-editor-content]:text-muted-foreground!",
67
+ defaultValue: o ?? ""
68
+ }
69
+ )
70
+ }
71
+ ) : /* @__PURE__ */ r(
72
+ i,
73
+ {
74
+ className: p(
51
75
  typeof t == "string" ? void 0 : t?.referenceCell,
52
76
  "text-muted-foreground"
53
77
  ),
54
78
  isDisabled: !0,
55
- children: m
79
+ children: o
56
80
  }
57
81
  ),
58
- e
82
+ n
59
83
  ]
60
84
  }
61
85
  ),
62
- i && /* @__PURE__ */ r(p, { className: "lg:hidden", children: /* @__PURE__ */ r(o, { children: i }) }),
63
- m && /* @__PURE__ */ r(p, { className: "lg:hidden", children: /* @__PURE__ */ r(o, { isDisabled: !0, className: "text-muted-foreground", children: m }) }),
64
- /* @__PURE__ */ r(p, { className: "lg:hidden", children: e })
86
+ m && /* @__PURE__ */ r(e, { className: "lg:hidden", children: /* @__PURE__ */ r(i, { children: m }) }),
87
+ o && !d && /* @__PURE__ */ r(e, { className: "lg:hidden", children: /* @__PURE__ */ r(i, { isDisabled: !0, className: "text-muted-foreground", children: o }) }),
88
+ o && d && /* @__PURE__ */ r(e, { className: "lg:hidden", children: /* @__PURE__ */ r(i, { isDisabled: !0, className: "text-muted-foreground p-0", children: /* @__PURE__ */ r(
89
+ l,
90
+ {
91
+ disabled: !0,
92
+ className: "rounded-none [&_.tiptap]:max-h-48 ring-0! border-none! [&_.rich-editor-content]:text-muted-foreground!",
93
+ defaultValue: o ?? ""
94
+ }
95
+ ) }) }),
96
+ /* @__PURE__ */ r(e, { className: "lg:hidden", children: n })
65
97
  ] });
66
98
  export {
67
- V as TranslateFormRowData
99
+ X as TranslateFormRowData
68
100
  };
@@ -0,0 +1,8 @@
1
+ export declare const TranslateRichText: ({ onChange, defaultValue, label, className }: Props) => import("react/jsx-runtime").JSX.Element;
2
+ type Props = {
3
+ className?: string;
4
+ label?: string;
5
+ defaultValue?: string;
6
+ onChange: (html: string) => void;
7
+ };
8
+ export {};
@@ -0,0 +1,65 @@
1
+ import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
+ import { useId as l } from "react";
3
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-accordion/dist/index.js";
4
+ import { cn as s } from "../../../../packages/lune-ui/dist/lib/utils.js";
5
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js";
6
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-avatar/dist/index.js";
7
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-separator/dist/index.js";
8
+ import "../../../../packages/lune-ui/dist/node_modules/react-day-picker/dist/esm/UI.js";
9
+ import "../../../../packages/lune-ui/dist/node_modules/react-day-picker/dist/esm/classes/DateLib.js";
10
+ import "../../../../packages/lune-ui/dist/node_modules/react-day-picker/dist/esm/useDayPicker.js";
11
+ import "../../../../packages/lune-ui/dist/node_modules/@date-fns/tz/date/mini.js";
12
+ import "../../../../packages/lune-ui/dist/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js";
13
+ import "../../../../packages/lune-ui/dist/node_modules/react-day-picker/dist/esm/locale/en-US.js";
14
+ import "../../../../packages/lune-ui/dist/components/chart.js";
15
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-checkbox/dist/index.js";
16
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-collapsible/dist/index.js";
17
+ import "../../../../packages/lune-ui/dist/node_modules/cmdk/dist/index.js";
18
+ import "../../../../packages/lune-ui/dist/components/dialog.js";
19
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js";
20
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-label/dist/index.js";
21
+ import "../../../../packages/lune-ui/dist/components/phone-input.js";
22
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-popover/dist/index.js";
23
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-radio-group/dist/index.js";
24
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-select/dist/index.js";
25
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-dialog/dist/index.js";
26
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-switch/dist/index.js";
27
+ import { TableCell as a } from "../../../../packages/lune-ui/dist/components/table.js";
28
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tabs/dist/index.js";
29
+ import "../../../../packages/lune-ui/dist/components/theme-provider.js";
30
+ import "../../../../packages/lune-ui/dist/node_modules/sonner/dist/index.js";
31
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-toggle/dist/index.js";
32
+ import "../../../../packages/lune-ui/dist/components/toggle-group.js";
33
+ import "../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tooltip/dist/index.js";
34
+ import "../../../../packages/lune-ui/dist/form/form.js";
35
+ import { RichEditor as n } from "../../../../shared/components/rich-editor/rich-editor.js";
36
+ const S = ({ onChange: i, defaultValue: m, label: r, className: p }) => {
37
+ const t = l();
38
+ return /* @__PURE__ */ e(
39
+ a,
40
+ {
41
+ onClick: () => {
42
+ document.getElementById(t)?.focus();
43
+ },
44
+ className: s(
45
+ "cursor-text align-top h-full p-0 [&:has(textarea:focus-visible)]:ring-primary/50 [&:has(textarea:focus-visible)]:ring-[1px]",
46
+ r && "flex flex-col gap-1 w-full lg:table-cell",
47
+ p
48
+ ),
49
+ children: [
50
+ r && /* @__PURE__ */ o("label", { className: "pl-4 pt-4 text-muted-foreground lg:hidden", htmlFor: t, children: r }),
51
+ /* @__PURE__ */ o(
52
+ n,
53
+ {
54
+ className: "rounded-none [&_.tiptap]:max-h-48 ring-0! border-none!",
55
+ defaultValue: m,
56
+ onChange: i
57
+ }
58
+ )
59
+ ]
60
+ }
61
+ );
62
+ };
63
+ export {
64
+ S as TranslateRichText
65
+ };
@@ -1,8 +1,8 @@
1
- import { jsx as i, Fragment as b } from "react/jsx-runtime";
2
- import { isLast as e, isFirst as f } from "../../../../../packages/lune-common/dist/index.js";
1
+ import { jsx as s, Fragment as V, jsxs as b } from "react/jsx-runtime";
2
+ import { isLast as r, isFirst as T } from "../../../../../packages/lune-common/dist/index.js";
3
3
  import "react";
4
4
  import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-accordion/dist/index.js";
5
- import { cn as a } from "../../../../../packages/lune-ui/dist/lib/utils.js";
5
+ import { cn as l } from "../../../../../packages/lune-ui/dist/lib/utils.js";
6
6
  import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js";
7
7
  import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-avatar/dist/index.js";
8
8
  import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-separator/dist/index.js";
@@ -32,88 +32,120 @@ import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-toggle
32
32
  import "../../../../../packages/lune-ui/dist/components/toggle-group.js";
33
33
  import "../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tooltip/dist/index.js";
34
34
  import "../../../../../packages/lune-ui/dist/form/form.js";
35
- import { useWatch as h } from "../../../../../node_modules/react-hook-form/dist/index.esm.js";
36
- import { CustomFieldType as V } from "../../../../api/codegen/graphql.js";
37
- import { isTranslatable as T } from "../../../../custom-fields/utils/custom-field.utils.js";
38
- import { TranslateFormRowData as u } from "../../form/translate-form-row-data.js";
39
- import { TranslateInput as c } from "../../form/translate-input.js";
40
- import { TranslateTextarea as v } from "../../form/translate-textarea.js";
41
- import { useTranslateProductFormContext as C } from "../use-form/use-translate-product-form.js";
42
- const pt = ({ product: d }) => {
43
- const o = C(), n = h({ defaultValue: o.formState.defaultValues }), s = d.customFieldEntries.filter(
44
- (t) => T(t.definition.type)
35
+ import { useWatch as f } from "../../../../../node_modules/react-hook-form/dist/index.esm.js";
36
+ import { CustomFieldType as m } from "../../../../api/codegen/graphql.js";
37
+ import { isTranslatable as v } from "../../../../custom-fields/utils/custom-field.utils.js";
38
+ import { TranslateFormRowData as d } from "../../form/translate-form-row-data.js";
39
+ import { TranslateInput as p } from "../../form/translate-input.js";
40
+ import { TranslateRichText as y } from "../../form/translate-rich-text.js";
41
+ import { TranslateTextarea as C } from "../../form/translate-textarea.js";
42
+ import { useTranslateProductFormContext as E } from "../use-form/use-translate-product-form.js";
43
+ const dt = ({ product: g }) => {
44
+ const i = E(), a = f({ defaultValue: i.formState.defaultValues }), n = g.customFieldEntries.filter(
45
+ (t) => v(t.definition.type)
45
46
  );
46
- return /* @__PURE__ */ i(b, { children: s.map(
47
- (t, l) => t.definition.isList ? t.value.map((m, r) => /* @__PURE__ */ i(
48
- u,
47
+ return /* @__PURE__ */ s(V, { children: n.map(
48
+ (t, u) => t.definition.isList ? t.value.map((o, e) => /* @__PURE__ */ s(
49
+ d,
49
50
  {
50
- field: f(r) ? t.definition.name : "",
51
- reference: m,
51
+ field: T(e) ? t.definition.name : "",
52
+ reference: o,
52
53
  className: {
53
- row: a(
54
- !e(r, t.value) && "border-0!",
55
- e(r, t.value) && e(l, s) && "border-0!"
54
+ row: l(
55
+ !r(e, t.value) && "border-0!",
56
+ r(e, t.value) && r(u, n) && "border-0!"
56
57
  ),
57
- referenceCell: a(!e(r, t.value) && "border-b")
58
+ referenceCell: l(!r(e, t.value) && "border-b")
58
59
  },
59
- children: /* @__PURE__ */ i(
60
- c,
60
+ children: /* @__PURE__ */ s(
61
+ p,
61
62
  {
62
- defaultValue: n.customFields?.[t.id][r],
63
- className: a(
64
- !e(r, t.value) && "border-b",
65
- e(r, t.value) && e(l, s) && "ring-0! lg:[&:has(input:focus-visible)]:ring-primary/50! lg:[&:has(input:focus-visible)]:ring-[1px]!"
63
+ defaultValue: a.customFields?.[t.id][e],
64
+ className: l(
65
+ !r(e, t.value) && "border-b",
66
+ r(e, t.value) && r(u, n) && "ring-0! lg:[&:has(input:focus-visible)]:ring-primary/50! lg:[&:has(input:focus-visible)]:ring-[1px]!"
66
67
  ),
67
68
  label: "English",
68
- onChange: (g) => {
69
- const F = g.target.value, p = o.getValues("customFields")[t.id];
70
- p[r] = F, o.setValue("customFields", {
71
- ...o.getValues("customFields"),
72
- [t.id]: p
69
+ onChange: (F) => {
70
+ const h = F.target.value, c = i.getValues("customFields")[t.id];
71
+ c[e] = h, i.setValue("customFields", {
72
+ ...i.getValues("customFields"),
73
+ [t.id]: c
73
74
  });
74
75
  }
75
76
  }
76
77
  )
77
78
  },
78
- t.definition.id + r
79
- )) : /* @__PURE__ */ i(
80
- u,
79
+ t.definition.id + e
80
+ )) : /* @__PURE__ */ b(
81
+ d,
81
82
  {
83
+ richText: t.definition.type === m.RichText,
82
84
  field: t.definition.name,
83
85
  reference: t.value,
84
- className: a(e(l, s) && "border-b-0"),
85
- children: t.definition.type === V.SingleLineText ? /* @__PURE__ */ i(
86
- c,
87
- {
88
- defaultValue: n.customFields?.[t.id],
89
- label: "English",
90
- onChange: (m) => {
91
- const r = m.target.value;
92
- o.setValue("customFields", {
93
- ...o.getValues("customFields"),
94
- [t.id]: r
95
- });
86
+ className: l(r(u, n) && "border-b-0"),
87
+ children: [
88
+ t.definition.type === m.SingleLineText && /* @__PURE__ */ s(
89
+ p,
90
+ {
91
+ defaultValue: a.customFields?.[t.id],
92
+ label: "English",
93
+ onChange: (o) => {
94
+ const e = o.target.value;
95
+ i.setValue("customFields", {
96
+ ...i.getValues("customFields"),
97
+ [t.id]: e
98
+ });
99
+ }
96
100
  }
97
- }
98
- ) : /* @__PURE__ */ i(
99
- v,
100
- {
101
- defaultValue: n.customFields?.[t.id],
102
- label: "English",
103
- onChange: (m) => {
104
- const r = m.target.value;
105
- o.setValue("customFields", {
106
- ...o.getValues("customFields"),
107
- [t.id]: r
108
- });
101
+ ),
102
+ t.definition.type === m.MultiLineText && /* @__PURE__ */ s(
103
+ C,
104
+ {
105
+ defaultValue: a.customFields?.[t.id],
106
+ label: "English",
107
+ onChange: (o) => {
108
+ const e = o.target.value;
109
+ i.setValue("customFields", {
110
+ ...i.getValues("customFields"),
111
+ [t.id]: e
112
+ });
113
+ }
109
114
  }
110
- }
111
- )
115
+ ),
116
+ t.definition.type === m.RichText && /* @__PURE__ */ s(
117
+ y,
118
+ {
119
+ defaultValue: a.customFields?.[t.id],
120
+ label: "English",
121
+ onChange: (o) => {
122
+ i.setValue("customFields", {
123
+ ...i.getValues("customFields"),
124
+ [t.id]: o
125
+ });
126
+ }
127
+ }
128
+ ),
129
+ t.definition.type === m.Url && /* @__PURE__ */ s(
130
+ p,
131
+ {
132
+ defaultValue: a.customFields?.[t.id],
133
+ label: "English",
134
+ onChange: (o) => {
135
+ const e = o.target.value;
136
+ i.setValue("customFields", {
137
+ ...i.getValues("customFields"),
138
+ [t.id]: e
139
+ });
140
+ }
141
+ }
142
+ )
143
+ ]
112
144
  },
113
145
  t.definition.id
114
146
  )
115
147
  ) });
116
148
  };
117
149
  export {
118
- pt as TranslateProductCustomField
150
+ dt as TranslateProductCustomField
119
151
  };