@payloadcms/ui 3.0.0-beta.134 → 3.0.0-beta.135

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 (112) hide show
  1. package/dist/assets/payload-favicon-dark.png +0 -0
  2. package/dist/assets/payload-favicon-light.png +0 -0
  3. package/dist/assets/payload-favicon.svg +4 -4
  4. package/dist/assets/payload-logo-dark.svg +1 -23
  5. package/dist/assets/payload-logo-light.svg +1 -23
  6. package/dist/assets/static-og-image.png +0 -0
  7. package/dist/elements/RenderServerComponent/index.d.ts +0 -6
  8. package/dist/elements/RenderServerComponent/index.d.ts.map +1 -1
  9. package/dist/elements/RenderServerComponent/index.js +1 -24
  10. package/dist/elements/RenderServerComponent/index.js.map +1 -1
  11. package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js +1 -1
  12. package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js.map +1 -1
  13. package/dist/exports/client/index.js +22 -22
  14. package/dist/exports/client/index.js.map +4 -4
  15. package/dist/exports/shared/index.d.ts +1 -0
  16. package/dist/exports/shared/index.d.ts.map +1 -1
  17. package/dist/exports/shared/index.js +2 -2
  18. package/dist/exports/shared/index.js.map +4 -4
  19. package/dist/fields/Checkbox/index.d.ts.map +1 -1
  20. package/dist/fields/Checkbox/index.js +71 -183
  21. package/dist/fields/Checkbox/index.js.map +1 -1
  22. package/dist/fields/Code/index.d.ts.map +1 -1
  23. package/dist/fields/Code/index.js +68 -170
  24. package/dist/fields/Code/index.js.map +1 -1
  25. package/dist/fields/Collapsible/index.d.ts.map +1 -1
  26. package/dist/fields/Collapsible/index.js +100 -207
  27. package/dist/fields/Collapsible/index.js.map +1 -1
  28. package/dist/fields/DateTime/index.d.ts.map +1 -1
  29. package/dist/fields/DateTime/index.js +72 -162
  30. package/dist/fields/DateTime/index.js.map +1 -1
  31. package/dist/fields/Email/index.d.ts.map +1 -1
  32. package/dist/fields/Email/index.js +72 -161
  33. package/dist/fields/Email/index.js.map +1 -1
  34. package/dist/fields/Group/index.d.ts.map +1 -1
  35. package/dist/fields/Group/index.js +64 -152
  36. package/dist/fields/Group/index.js.map +1 -1
  37. package/dist/fields/JSON/index.d.ts.map +1 -1
  38. package/dist/fields/JSON/index.js +7 -10
  39. package/dist/fields/JSON/index.js.map +1 -1
  40. package/dist/fields/Join/index.d.ts.map +1 -1
  41. package/dist/fields/Join/index.js +0 -1
  42. package/dist/fields/Join/index.js.map +1 -1
  43. package/dist/fields/Number/index.d.ts.map +1 -1
  44. package/dist/fields/Number/index.js +143 -275
  45. package/dist/fields/Number/index.js.map +1 -1
  46. package/dist/fields/Password/index.d.ts.map +1 -1
  47. package/dist/fields/Password/index.js +79 -166
  48. package/dist/fields/Password/index.js.map +1 -1
  49. package/dist/fields/Point/index.d.ts.map +1 -1
  50. package/dist/fields/Point/index.js +110 -235
  51. package/dist/fields/Point/index.js.map +1 -1
  52. package/dist/fields/RadioGroup/index.d.ts.map +1 -1
  53. package/dist/fields/RadioGroup/index.js +93 -209
  54. package/dist/fields/RadioGroup/index.js.map +1 -1
  55. package/dist/fields/Relationship/index.d.ts.map +1 -1
  56. package/dist/fields/Relationship/index.js +7 -10
  57. package/dist/fields/Relationship/index.js.map +1 -1
  58. package/dist/fields/Select/Input.d.ts +0 -1
  59. package/dist/fields/Select/Input.d.ts.map +1 -1
  60. package/dist/fields/Select/Input.js +45 -50
  61. package/dist/fields/Select/Input.js.map +1 -1
  62. package/dist/fields/Select/index.d.ts.map +1 -1
  63. package/dist/fields/Select/index.js +7 -7
  64. package/dist/fields/Select/index.js.map +1 -1
  65. package/dist/fields/Text/Input.d.ts.map +1 -1
  66. package/dist/fields/Text/Input.js +31 -36
  67. package/dist/fields/Text/Input.js.map +1 -1
  68. package/dist/fields/Text/index.d.ts +1 -1
  69. package/dist/fields/Text/index.d.ts.map +1 -1
  70. package/dist/fields/Text/index.js +93 -171
  71. package/dist/fields/Text/index.js.map +1 -1
  72. package/dist/fields/Text/types.d.ts +0 -1
  73. package/dist/fields/Text/types.d.ts.map +1 -1
  74. package/dist/fields/Text/types.js.map +1 -1
  75. package/dist/fields/Textarea/Input.d.ts.map +1 -1
  76. package/dist/fields/Textarea/Input.js +26 -31
  77. package/dist/fields/Textarea/Input.js.map +1 -1
  78. package/dist/fields/Textarea/index.d.ts.map +1 -1
  79. package/dist/fields/Textarea/index.js +62 -112
  80. package/dist/fields/Textarea/index.js.map +1 -1
  81. package/dist/fields/Textarea/types.d.ts +0 -1
  82. package/dist/fields/Textarea/types.d.ts.map +1 -1
  83. package/dist/fields/Textarea/types.js.map +1 -1
  84. package/dist/fields/Upload/Input.d.ts +0 -1
  85. package/dist/fields/Upload/Input.d.ts.map +1 -1
  86. package/dist/fields/Upload/Input.js +41 -46
  87. package/dist/fields/Upload/Input.js.map +1 -1
  88. package/dist/fields/Upload/index.d.ts.map +1 -1
  89. package/dist/fields/Upload/index.js +63 -135
  90. package/dist/fields/Upload/index.js.map +1 -1
  91. package/dist/fields/mergeFieldStyles.d.ts +3 -0
  92. package/dist/fields/mergeFieldStyles.d.ts.map +1 -0
  93. package/dist/fields/mergeFieldStyles.js +13 -0
  94. package/dist/fields/mergeFieldStyles.js.map +1 -0
  95. package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
  96. package/dist/forms/fieldSchemasToFormState/renderField.js +10 -8
  97. package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
  98. package/dist/graphics/Icon/index.d.ts.map +1 -1
  99. package/dist/graphics/Icon/index.js +2 -2
  100. package/dist/graphics/Icon/index.js.map +1 -1
  101. package/dist/graphics/Logo/index.d.ts.map +1 -1
  102. package/dist/graphics/Logo/index.js +30 -21
  103. package/dist/graphics/Logo/index.js.map +1 -1
  104. package/dist/utilities/buildFormState.d.ts +0 -4
  105. package/dist/utilities/buildFormState.d.ts.map +1 -1
  106. package/dist/utilities/buildFormState.js +1 -15
  107. package/dist/utilities/buildFormState.js.map +1 -1
  108. package/dist/utilities/buildTableState.d.ts +2 -1
  109. package/dist/utilities/buildTableState.d.ts.map +1 -1
  110. package/dist/utilities/buildTableState.js +6 -3
  111. package/dist/utilities/buildTableState.js.map +1 -1
  112. package/package.json +5 -5
@@ -1,9 +1,8 @@
1
1
  'use client';
2
2
 
3
- import { c as _c } from "react/compiler-runtime";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
4
  import { getTranslation } from '@payloadcms/translations';
6
- import React from 'react';
5
+ import React, { useMemo } from 'react';
7
6
  import { useCollapsible } from '../../elements/Collapsible/provider.js';
8
7
  import { ErrorPill } from '../../elements/ErrorPill/index.js';
9
8
  import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
@@ -14,42 +13,31 @@ import { RenderFields } from '../../forms/RenderFields/index.js';
14
13
  import { useField } from '../../forms/useField/index.js';
15
14
  import { withCondition } from '../../forms/withCondition/index.js';
16
15
  import { useTranslation } from '../../providers/Translation/index.js';
16
+ import { mergeFieldStyles } from '../mergeFieldStyles.js';
17
17
  import { useRow } from '../Row/provider.js';
18
18
  import { fieldBaseClass } from '../shared/index.js';
19
- import { useTabs } from '../Tabs/provider.js';
20
19
  import './index.scss';
20
+ import { useTabs } from '../Tabs/provider.js';
21
21
  import { GroupProvider, useGroup } from './provider.js';
22
22
  const baseClass = 'group-field';
23
23
  export const GroupFieldComponent = props => {
24
- const $ = _c(36);
25
24
  const {
26
- field: t0,
25
+ field,
26
+ field: {
27
+ name,
28
+ admin: {
29
+ className,
30
+ description,
31
+ hideGutter
32
+ } = {},
33
+ fields,
34
+ label
35
+ },
27
36
  path,
28
37
  permissions,
29
38
  readOnly,
30
39
  schemaPath: schemaPathFromProps
31
40
  } = props;
32
- const {
33
- name,
34
- admin: t1,
35
- fields,
36
- label
37
- } = t0;
38
- let t2;
39
- if ($[0] !== t1) {
40
- t2 = t1 === undefined ? {} : t1;
41
- $[0] = t1;
42
- $[1] = t2;
43
- } else {
44
- t2 = $[1];
45
- }
46
- const {
47
- className,
48
- description,
49
- hideGutter,
50
- style,
51
- width
52
- } = t2;
53
41
  const schemaPath = schemaPathFromProps ?? name;
54
42
  const {
55
43
  i18n
@@ -60,141 +48,65 @@ export const GroupFieldComponent = props => {
60
48
  const isWithinGroup = useGroup();
61
49
  const isWithinRow = useRow();
62
50
  const isWithinTab = useTabs();
63
- let t3;
64
- if ($[2] !== path) {
65
- t3 = {
66
- path
67
- };
68
- $[2] = path;
69
- $[3] = t3;
70
- } else {
71
- t3 = $[3];
72
- }
73
51
  const {
74
- customComponents: t4,
52
+ customComponents: {
53
+ Description,
54
+ Label
55
+ } = {},
75
56
  errorPaths
76
- } = useField(t3);
77
- let t5;
78
- if ($[4] !== t4) {
79
- t5 = t4 === undefined ? {} : t4;
80
- $[4] = t4;
81
- $[5] = t5;
82
- } else {
83
- t5 = $[5];
84
- }
85
- const {
86
- Description,
87
- Label
88
- } = t5;
57
+ } = useField({
58
+ path
59
+ });
89
60
  const submitted = useFormSubmitted();
90
61
  const errorCount = errorPaths.length;
91
62
  const fieldHasErrors = submitted && errorCount > 0;
92
63
  const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow);
93
- const t6 = isTopLevel && `${baseClass}--top-level`;
94
- const t7 = isWithinCollapsible && `${baseClass}--within-collapsible`;
95
- const t8 = isWithinGroup && `${baseClass}--within-group`;
96
- const t9 = isWithinRow && `${baseClass}--within-row`;
97
- const t10 = isWithinTab && `${baseClass}--within-tab`;
98
- const t11 = !hideGutter && isWithinGroup && `${baseClass}--gutter`;
99
- const t12 = fieldHasErrors && `${baseClass}--has-error`;
100
- let t13;
101
- if ($[6] !== t6 || $[7] !== t7 || $[8] !== t8 || $[9] !== t9 || $[10] !== t10 || $[11] !== t11 || $[12] !== t12 || $[13] !== className) {
102
- t13 = [fieldBaseClass, baseClass, t6, t7, t8, t9, t10, t11, t12, className].filter(Boolean);
103
- $[6] = t6;
104
- $[7] = t7;
105
- $[8] = t8;
106
- $[9] = t9;
107
- $[10] = t10;
108
- $[11] = t11;
109
- $[12] = t12;
110
- $[13] = className;
111
- $[14] = t13;
112
- } else {
113
- t13 = $[14];
114
- }
115
- const t14 = t13.join(" ");
116
- const t15 = `field-${path?.replace(/\./g, "__")}`;
117
- let t16;
118
- if ($[15] !== style || $[16] !== width || $[17] !== Label || $[18] !== Description || $[19] !== label || $[20] !== i18n || $[21] !== path || $[22] !== description || $[23] !== fieldHasErrors || $[24] !== errorCount || $[25] !== permissions || $[26] !== fields || $[27] !== schemaPath || $[28] !== readOnly || $[29] !== t14 || $[30] !== t15) {
119
- let t17;
120
- if ($[32] !== fieldHasErrors || $[33] !== errorCount || $[34] !== i18n) {
121
- t17 = fieldHasErrors && _jsx(ErrorPill, {
122
- count: errorCount,
123
- i18n,
124
- withMessage: true
125
- });
126
- $[32] = fieldHasErrors;
127
- $[33] = errorCount;
128
- $[34] = i18n;
129
- $[35] = t17;
130
- } else {
131
- t17 = $[35];
132
- }
133
- t16 = _jsx("div", {
134
- className: t14,
135
- id: t15,
136
- style: {
137
- ...style,
138
- width
139
- },
140
- children: _jsx(GroupProvider, {
141
- children: _jsxs("div", {
142
- className: `${baseClass}__wrap`,
143
- children: [_jsxs("div", {
144
- className: `${baseClass}__header`,
145
- children: [Boolean(Label || Description || label) && _jsxs("header", {
146
- children: [_jsx(RenderCustomComponent, {
147
- CustomComponent: Label,
148
- Fallback: _jsx("h3", {
149
- className: `${baseClass}__title`,
150
- children: _jsx(FieldLabel, {
151
- label: getTranslation(label, i18n),
152
- localized: false,
153
- path,
154
- required: false
155
- })
156
- })
157
- }), _jsx(RenderCustomComponent, {
158
- CustomComponent: Description,
159
- Fallback: _jsx(FieldDescription, {
160
- description,
161
- path
64
+ const styles = useMemo(() => mergeFieldStyles(field), [field]);
65
+ return /*#__PURE__*/_jsx("div", {
66
+ className: [fieldBaseClass, baseClass, isTopLevel && `${baseClass}--top-level`, isWithinCollapsible && `${baseClass}--within-collapsible`, isWithinGroup && `${baseClass}--within-group`, isWithinRow && `${baseClass}--within-row`, isWithinTab && `${baseClass}--within-tab`, !hideGutter && isWithinGroup && `${baseClass}--gutter`, fieldHasErrors && `${baseClass}--has-error`, className].filter(Boolean).join(' '),
67
+ id: `field-${path?.replace(/\./g, '__')}`,
68
+ style: styles,
69
+ children: /*#__PURE__*/_jsx(GroupProvider, {
70
+ children: /*#__PURE__*/_jsxs("div", {
71
+ className: `${baseClass}__wrap`,
72
+ children: [/*#__PURE__*/_jsxs("div", {
73
+ className: `${baseClass}__header`,
74
+ children: [Boolean(Label || Description || label) && /*#__PURE__*/_jsxs("header", {
75
+ children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
76
+ CustomComponent: Label,
77
+ Fallback: /*#__PURE__*/_jsx("h3", {
78
+ className: `${baseClass}__title`,
79
+ children: /*#__PURE__*/_jsx(FieldLabel, {
80
+ label: getTranslation(label, i18n),
81
+ localized: false,
82
+ path: path,
83
+ required: false
162
84
  })
163
- })]
164
- }), t17]
165
- }), _jsx(RenderFields, {
166
- fields,
167
- margins: "small",
168
- parentIndexPath: "",
169
- parentPath: path,
170
- parentSchemaPath: schemaPath,
171
- permissions: permissions === true ? permissions : permissions?.fields,
172
- readOnly
85
+ })
86
+ }), /*#__PURE__*/_jsx(RenderCustomComponent, {
87
+ CustomComponent: Description,
88
+ Fallback: /*#__PURE__*/_jsx(FieldDescription, {
89
+ description: description,
90
+ path: path
91
+ })
92
+ })]
93
+ }), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
94
+ count: errorCount,
95
+ i18n: i18n,
96
+ withMessage: true
173
97
  })]
174
- })
98
+ }), /*#__PURE__*/_jsx(RenderFields, {
99
+ fields: fields,
100
+ margins: "small",
101
+ parentIndexPath: "",
102
+ parentPath: path,
103
+ parentSchemaPath: schemaPath,
104
+ permissions: permissions === true ? permissions : permissions?.fields,
105
+ readOnly: readOnly
106
+ })]
175
107
  })
176
- });
177
- $[15] = style;
178
- $[16] = width;
179
- $[17] = Label;
180
- $[18] = Description;
181
- $[19] = label;
182
- $[20] = i18n;
183
- $[21] = path;
184
- $[22] = description;
185
- $[23] = fieldHasErrors;
186
- $[24] = errorCount;
187
- $[25] = permissions;
188
- $[26] = fields;
189
- $[27] = schemaPath;
190
- $[28] = readOnly;
191
- $[29] = t14;
192
- $[30] = t15;
193
- $[31] = t16;
194
- } else {
195
- t16 = $[31];
196
- }
197
- return t16;
108
+ })
109
+ });
198
110
  };
199
111
  export { GroupProvider, useGroup };
200
112
  export const GroupField = withCondition(GroupFieldComponent);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useCollapsible","ErrorPill","RenderCustomComponent","FieldDescription","FieldLabel","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","useRow","fieldBaseClass","useTabs","GroupProvider","useGroup","baseClass","GroupFieldComponent","props","$","field","t0","path","permissions","readOnly","schemaPath","schemaPathFromProps","name","admin","t1","fields","label","t2","undefined","className","description","hideGutter","style","width","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","t3","customComponents","t4","errorPaths","t5","Description","Label","submitted","errorCount","length","fieldHasErrors","isTopLevel","t6","t7","t8","t9","t10","t11","t12","t13","filter","Boolean","t14","join","t15","replace","t16","t17","_jsx","count","withMessage","id","children","_jsxs","CustomComponent","Fallback","localized","required","margins","parentIndexPath","parentPath","parentSchemaPath","GroupField"],"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport type { GroupFieldClientComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useFormSubmitted } from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport const GroupFieldComponent: GroupFieldClientComponent = (props) => {\n const {\n field: {\n name,\n admin: { className, description, hideGutter, style, width } = {},\n fields,\n label,\n },\n path,\n permissions,\n readOnly,\n schemaPath: schemaPathFromProps,\n } = props\n const schemaPath = schemaPathFromProps ?? name\n\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { customComponents: { Description, Label } = {}, errorPaths } = useField({ path })\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {Boolean(Label || Description || label) && (\n <header>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <h3 className={`${baseClass}__title`}>\n <FieldLabel\n label={getTranslation(label, i18n)}\n localized={false}\n path={path}\n required={false}\n />\n </h3>\n }\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fields={fields}\n margins=\"small\"\n parentIndexPath=\"\"\n parentPath={path}\n parentSchemaPath={schemaPath}\n permissions={permissions === true ? permissions : permissions?.fields}\n readOnly={readOnly}\n />\n </div>\n </GroupProvider>\n </div>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(GroupFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,cAAc,QAAQ;AAC/B,SAASC,OAAO,QAAQ;AACxB,OAAO;AACP,SAASC,aAAa,EAAEC,QAAQ,QAAQ;AAExC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,mBAAA,GAAiDC,KAAA;EAAA,MAAAC,CAAA,GAAArB,EAAA;EAC5D;IAAAsB,KAAA,EAAAC,EAAA;IAAAC,IAAA;IAAAC,WAAA;IAAAC,QAAA;IAAAC,UAAA,EAAAC;EAAA,IAWIR,KAAA;EAVK;IAAAS,IAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,MAAA;IAAAC;EAAA,IAAAV,EAKN;EAAA,IAAAW,EAAA;EAAA,IAAAb,CAAA,QAAAU,EAAA;IAHQG,EAAA,GAAAH,EAAyD,KAAAI,SAAA,QAAzDJ,EAAyD;IAAAV,CAAA,MAAAU,EAAA;IAAAV,CAAA,M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,QAAA,EAClCJ,IAAA,CAAAnE,UAAA;oBAAA0B,KAAA,EACShC,cAAA,CAAegC,KAAA,EAAOQ,IAAA;oBAAAyC,SAAA;oBAAA1D,IAAA;oBAAA2D,QAAA;kBAAA,C;;kBAQrCT,IAAA,CAAArE,qBAAA;gBAAA2E,eAAA,EACmB7B,WAAA;gBAAA8B,QAAA,EACPP,IAAA,CAAApE,gBAAA;kBAAA+B,WAAA;kBAAAb;gBAAA,C;;gBAIfiD,G;cAEHC,IAAA,CAAAjE,YAAA;YAAAuB,MAAA;YAAAoD,OAAA,EAEU;YAAAC,eAAA,EACQ;YAAAC,UAAA,EACJ9D,IAAA;YAAA+D,gBAAA,EACM5D,UAAA;YAAAF,WAAA,EACLA,WAAA,SAAgB,GAAOA,WAAA,GAAcA,WAAA,EAAAO,MAAa;YAAAN;UAAA,C;;;;;;;;;;;;;;;;;;;;;;;;SArDvE8C,G;CA4DJ;AAEA,SAASxD,aAAa,EAAEC,QAAQ;AAEhC,OAAO,MAAMuE,UAAA,GAAa7E,aAAA,CAAcQ,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","React","useMemo","useCollapsible","ErrorPill","RenderCustomComponent","FieldDescription","FieldLabel","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","mergeFieldStyles","useRow","fieldBaseClass","useTabs","GroupProvider","useGroup","baseClass","GroupFieldComponent","props","field","name","admin","className","description","hideGutter","fields","label","path","permissions","readOnly","schemaPath","schemaPathFromProps","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","customComponents","Description","Label","errorPaths","submitted","errorCount","length","fieldHasErrors","isTopLevel","styles","_jsx","filter","Boolean","join","id","replace","style","_jsxs","CustomComponent","Fallback","localized","required","count","withMessage","margins","parentIndexPath","parentPath","parentSchemaPath","GroupField"],"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport type { GroupFieldClientComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useMemo } from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useFormSubmitted } from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { useRow } from '../Row/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { useTabs } from '../Tabs/provider.js'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport const GroupFieldComponent: GroupFieldClientComponent = (props) => {\n const {\n field,\n field: { name, admin: { className, description, hideGutter } = {}, fields, label },\n path,\n permissions,\n readOnly,\n schemaPath: schemaPathFromProps,\n } = props\n const schemaPath = schemaPathFromProps ?? name\n\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { customComponents: { Description, Label } = {}, errorPaths } = useField({ path })\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {Boolean(Label || Description || label) && (\n <header>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <h3 className={`${baseClass}__title`}>\n <FieldLabel\n label={getTranslation(label, i18n)}\n localized={false}\n path={path}\n required={false}\n />\n </h3>\n }\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fields={fields}\n margins=\"small\"\n parentIndexPath=\"\"\n parentPath={path}\n parentSchemaPath={schemaPath}\n permissions={permissions === true ? permissions : permissions?.fields}\n readOnly={readOnly}\n />\n </div>\n </GroupProvider>\n </div>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(GroupFieldComponent)\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,QAAQ;AACvB,SAASC,cAAc,QAAQ;AAC/B,OAAO;AACP,SAASC,OAAO,QAAQ;AACxB,SAASC,aAAa,EAAEC,QAAQ,QAAQ;AAExC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,mBAAA,GAAkDC,KAAA;EAC7D,MAAM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aA,WAAA,KAAgB,OAAOA,WAAA,GAAcA,WAAA,EAAaH,MAAA;UAC/DI,QAAA,EAAUA;;;;;AAMtB;AAEA,SAASf,aAAa,EAAEC,QAAQ;AAEhC,OAAO,MAAMkD,UAAA,GAAazD,aAAA,CAAcS,mBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAU/D,OAAO,cAAc,CAAA;AA6IrB,eAAO,MAAM,SAAS;;;;;+EAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAUxE,OAAO,cAAc,CAAA;AA6IrB,eAAO,MAAM,SAAS;;;;;+EAAoC,CAAA"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import React, { useCallback, useEffect, useState } from 'react';
4
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import { CodeEditor } from '../../elements/CodeEditor/index.js';
6
6
  import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
7
7
  import { useField } from '../../forms/useField/index.js';
@@ -9,20 +9,19 @@ import { withCondition } from '../../forms/withCondition/index.js';
9
9
  import { FieldDescription } from '../FieldDescription/index.js';
10
10
  import { FieldError } from '../FieldError/index.js';
11
11
  import { FieldLabel } from '../FieldLabel/index.js';
12
- import { fieldBaseClass } from '../shared/index.js';
12
+ import { mergeFieldStyles } from '../mergeFieldStyles.js';
13
13
  import './index.scss';
14
+ import { fieldBaseClass } from '../shared/index.js';
14
15
  const baseClass = 'json-field';
15
16
  const JSONFieldComponent = props => {
16
17
  const {
18
+ field,
17
19
  field: {
18
- name,
19
20
  admin: {
20
21
  className,
21
22
  description,
22
23
  editorOptions,
23
- maxHeight,
24
- style,
25
- width
24
+ maxHeight
26
25
  } = {},
27
26
  jsonSchema,
28
27
  label,
@@ -95,12 +94,10 @@ const JSONFieldComponent = props => {
95
94
  setStringValue(value_0 || initialValue ? JSON.stringify(value_0 ? value_0 : initialValue, null, 2) : '');
96
95
  setHasLoadedValue(true);
97
96
  }, [initialValue, value_0, hasLoadedValue]);
97
+ const styles = useMemo(() => mergeFieldStyles(field), [field]);
98
98
  return /*#__PURE__*/_jsxs("div", {
99
99
  className: [fieldBaseClass, baseClass, className, showError && 'error', readOnly && 'read-only'].filter(Boolean).join(' '),
100
- style: {
101
- ...style,
102
- width
103
- },
100
+ style: styles,
104
101
  children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
105
102
  CustomComponent: Label,
106
103
  Fallback: /*#__PURE__*/_jsx(FieldLabel, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","fieldBaseClass","baseClass","JSONFieldComponent","props","field","name","admin","className","description","editorOptions","maxHeight","style","width","jsonSchema","label","localized","required","path","readOnly","validate","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","initialValue","setValue","showError","handleMount","editor","monaco","existingSchemas","languages","json","jsonDefaults","diagnosticsOptions","schemas","modelUri","Uri","parse","uri","model","createModel","JSON","stringify","setDiagnosticsOptions","enableSchemaRequest","setModel","handleChange","val","undefined","e","_jsxs","filter","Boolean","join","_jsx","CustomComponent","Fallback","message","defaultLanguage","onChange","onMount","JSONField"],"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nconst JSONFieldComponent: JSONFieldClientComponent = (props) => {\n const {\n field: {\n name,\n admin: { className, description, editorOptions, maxHeight, style, width } = {},\n jsonSchema,\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, jsonError, required })\n }\n },\n [validate, required, jsonError],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n initialValue,\n setValue,\n showError,\n value,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const handleMount = useCallback(\n (editor, monaco) => {\n if (!jsonSchema) {\n return\n }\n\n const existingSchemas = monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []\n const modelUri = monaco.Uri.parse(jsonSchema.uri)\n\n const model = monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', modelUri)\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [...existingSchemas, jsonSchema],\n validate: true,\n })\n\n editor.setModel(model)\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly) {\n return\n }\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue || value === undefined) {\n return\n }\n\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError message={jsonError} path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n maxHeight={maxHeight}\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={readOnly}\n value={stringValue}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAExD,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAA,EAAO;MACLC,IAAI;MACJC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAa;QAAEC,SAAS;QAAEC,KAAK;QAAEC;MAAK,CAAE,GAAG,CAAC,CAAC;MAC9EC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAI;IAC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SAAA,EAAWA,SAAA;QAAWE,IAAA,EAAMA,IAAA;QAAMD,QAAA,EAAUA;;qBAG1E8C,KAAA,CAAC;MAAIvD,SAAA,EAAW,GAAGP,cAAA,QAAsB;8BACvCkE,IAAA,CAACxE,qBAAA;QACCyE,eAAA,EAAiBlC,KAAA;QACjBmC,QAAA,eAAUF,IAAA,CAACpE,UAAA;UAAWuE,OAAA,EAAS/C,SAAA;UAAWL,IAAA,EAAMA,IAAA;UAAMoB,SAAA,EAAWA;;UAElEN,WAAA,E,aACDmC,IAAA,CAACzE,UAAA;QACC6E,eAAA,EAAgB;QAChB5D,SAAA,EAAWA,SAAA;QACX6D,QAAA,EAAUb,YAAA;QACVc,OAAA,EAASlC,WAAA;QACTV,OAAA,EAASnB,aAAA;QACTS,QAAA,EAAUA,QAAA;QACVS,KAAA,EAAOP;UAERU,UAAA;qBAEHoC,IAAA,CAACxE,qBAAA;MACCyE,eAAA,EAAiBnC,WAAA;MACjBoC,QAAA,eAAUF,IAAA,CAACrE,gBAAA;QAAiBW,WAAA,EAAaA,WAAA;QAAaS,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAMwD,SAAA,GAAY7E,aAAA,CAAcM,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","baseClass","JSONFieldComponent","props","field","admin","className","description","editorOptions","maxHeight","jsonSchema","label","localized","required","path","readOnly","validate","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","initialValue","setValue","showError","handleMount","editor","monaco","existingSchemas","languages","json","jsonDefaults","diagnosticsOptions","schemas","modelUri","Uri","parse","uri","model","createModel","JSON","stringify","setDiagnosticsOptions","enableSchemaRequest","setModel","handleChange","val","undefined","e","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","message","defaultLanguage","onChange","onMount","JSONField"],"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\n\nconst baseClass = 'json-field'\n\nconst JSONFieldComponent: JSONFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, maxHeight } = {},\n jsonSchema,\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, jsonError, required })\n }\n },\n [validate, required, jsonError],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n initialValue,\n setValue,\n showError,\n value,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const handleMount = useCallback(\n (editor, monaco) => {\n if (!jsonSchema) {\n return\n }\n\n const existingSchemas = monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []\n const modelUri = monaco.Uri.parse(jsonSchema.uri)\n\n const model = monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', modelUri)\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [...existingSchemas, jsonSchema],\n validate: true,\n })\n\n editor.setModel(model)\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly) {\n return\n }\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue || value === undefined) {\n return\n }\n\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError message={jsonError} path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n maxHeight={maxHeight}\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={readOnly}\n value={stringValue}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QA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,MAAMS,gBAAA,CAAiBK,KAAA,GAAQ,CAACA,KAAA,CAAM;EAE7D,oBACEwD,KAAA,CAAC;IACCtD,SAAA,EAAW,CACTN,cAAA,EACAC,SAAA,EACAK,SAAA,EACA4B,SAAA,IAAa,SACbnB,QAAA,IAAY,YACb,CACE8C,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;IACRC,KAAA,EAAOL,MAAA;4BAEPM,IAAA,CAACxE,qBAAA;MACCyE,eAAA,EAAiBnC,KAAA;MACjBoC,QAAA,eACEF,IAAA,CAACnE,UAAA;QAAWa,KAAA,EAAOA,KAAA;QAAOC,SAAA,EAAWA,SAAA;QAAWE,IAAA,EAAMA,IAAA;QAAMD,QAAA,EAAUA;;qBAG1E+C,KAAA,CAAC;MAAItD,SAAA,EAAW,GAAGN,cAAA,QAAsB;8BACvCiE,IAAA,CAACxE,qBAAA;QACCyE,eAAA,EAAiBpC,KAAA;QACjBqC,QAAA,eAAUF,IAAA,CAACpE,UAAA;UAAWuE,OAAA,EAASjD,SAAA;UAAWL,IAAA,EAAMA,IAAA;UAAMoB,SAAA,EAAWA;;UAElEN,WAAA,E,aACDqC,IAAA,CAACzE,UAAA;QACC6E,eAAA,EAAgB;QAChB5D,SAAA,EAAWA,SAAA;QACX6D,QAAA,EAAUf,YAAA;QACVgB,OAAA,EAASpC,WAAA;QACTV,OAAA,EAASjB,aAAA;QACTO,QAAA,EAAUA,QAAA;QACVS,KAAA,EAAOP;UAERU,UAAA;qBAEHsC,IAAA,CAACxE,qBAAA;MACCyE,eAAA,EAAiBrC,WAAA;MACjBsC,QAAA,eAAUF,IAAA,CAACrE,gBAAA;QAAiBW,WAAA,EAAaA,WAAA;QAAaO,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM0D,SAAA,GAAY7E,aAAA,CAAcO,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAkD,MAAM,SAAS,CAAA;AAE9F,OAAO,KAAkB,MAAM,OAAO,CAAA;AA6EtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAkD,MAAM,SAAS,CAAA;AAE9F,OAAO,KAAkB,MAAM,OAAO,CAAA;AA4EtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
@@ -12,7 +12,6 @@ const JoinFieldComponent = props => {
12
12
  const {
13
13
  field,
14
14
  field: {
15
- name,
16
15
  admin: {
17
16
  allowCreate
18
17
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useMemo","RelationshipTable","useField","withCondition","useDocumentInfo","FieldLabel","fieldBaseClass","JoinFieldComponent","props","field","name","admin","allowCreate","collection","label","localized","on","required","path","id","docID","customComponents","AfterInput","BeforeInput","Label","value","filterOptions","where","equals","and","_jsxs","className","filter","Boolean","join","_jsx","disableTable","initialData","docs","initialDrawerData","style","margin","relationTo","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type { JoinFieldClient, JoinFieldClientComponent, PaginatedDocs, Where } from 'payload'\n\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n name,\n admin: { allowCreate },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID } = useDocumentInfo()\n\n const { customComponents: { AfterInput, BeforeInput, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n const where = {\n [on]: {\n equals: docID,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, on, field.where])\n\n return (\n <div className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}>\n {BeforeInput}\n <RelationshipTable\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={{\n [on]: docID,\n }}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n {AfterInput}\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,IAAI;MACJC,KAAA,EAAO;QAAEC;MAAW,CAAE;MACtBC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC,EAAE;MACFC;IAAQ,CACT;IACDC;EAAI,CACL,GAAGV,KAAA;EAEJ,MAAM;IAAEW,EAAA,EAAIC;EAAK,CAAE,GAAGhB,eAAA;EAEtB,MAAM;IAAEiB,gBAAA,EAAkB;MAAEC,UAAU;MAAEC,WAAW;MAAEC;IAAK,CAAE,GAAG,CAAC,CAAC;IAAEC;EAAK,CAAE,GACxEvB,QAAA,CAAwB;IACtBgB;EACF;EAEF,MAAMQ,aAAA,GAA8B1B,OAAA,CAAQ;IAC1C,IAAI,CAACoB,KAAA,EAAO;MACV,OAAO;IACT;IAEA,MAAMO,KAAA,GAAQ;MACZ,CAACX,EAAA,GAAK;QACJY,MAAA,EAAQR;MACV;IACF;IAEA,IAAIX,KAAA,CAAMkB,KAAK,EAAE;MACf,OAAO;QACLE,GAAA,EAAK,CAACF,KAAA,EAAOlB,KAAA,CAAMkB,KAAK;MAC1B;IACF;IAEA,OAAOA,KAAA;EACT,GAAG,CAACP,KAAA,EAAOJ,EAAA,EAAIP,KAAA,CAAMkB,KAAK,CAAC;EAE3B,oBACEG,KAAA,CAAC;IAAIC,SAAA,EAAW,CAACzB,cAAA,EAAgB,OAAO,CAAC0B,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;eAC3DX,WAAA,E,aACDY,IAAA,CAAClC,iBAAA;MACCW,WAAA,EAAa,OAAOQ,KAAA,KAAU,eAAeR,WAAA;MAC7CwB,YAAA,EAAcV,aAAA,KAAkB;MAChCjB,KAAA,EAAOA,KAAA;MACPiB,aAAA,EAAeA,aAAA;MACfW,WAAA,EAAajB,KAAA,IAASK,KAAA,GAAQA,KAAA,GAAS;QAAEa,IAAA,EAAM;MAAG;MAClDC,iBAAA,EAAmB;QACjB,CAACvB,EAAA,GAAKI;MACR;MACAI,KAAA,eACEW,IAAA,CAAC;QAAGK,KAAA,EAAO;UAAEC,MAAA,EAAQ;QAAE;kBACpBjB,KAAA,iBACCW,IAAA,CAAC9B,UAAA;UAAWS,KAAA,EAAOA,KAAA;UAAOC,SAAA,EAAWA,SAAA;UAAWG,IAAA,EAAMA,IAAA;UAAMD,QAAA,EAAUA;;;MAI5EyB,UAAA,EAAY7B;QAEbS,UAAA;;AAGP;AAEA,OAAO,MAAMqB,SAAA,GAAYxC,aAAA,CAAcI,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useMemo","RelationshipTable","useField","withCondition","useDocumentInfo","FieldLabel","fieldBaseClass","JoinFieldComponent","props","field","admin","allowCreate","collection","label","localized","on","required","path","id","docID","customComponents","AfterInput","BeforeInput","Label","value","filterOptions","where","equals","and","_jsxs","className","filter","Boolean","join","_jsx","disableTable","initialData","docs","initialDrawerData","style","margin","relationTo","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type { JoinFieldClient, JoinFieldClientComponent, PaginatedDocs, Where } from 'payload'\n\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID } = useDocumentInfo()\n\n const { customComponents: { AfterInput, BeforeInput, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n const where = {\n [on]: {\n equals: docID,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, on, field.where])\n\n return (\n <div className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}>\n {BeforeInput}\n <RelationshipTable\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={{\n [on]: docID,\n }}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n {AfterInput}\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAI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V,aAAA,KAAkB;MAChChB,KAAA,EAAOA,KAAA;MACPgB,aAAA,EAAeA,aAAA;MACfW,WAAA,EAAajB,KAAA,IAASK,KAAA,GAAQA,KAAA,GAAS;QAAEa,IAAA,EAAM;MAAG;MAClDC,iBAAA,EAAmB;QACjB,CAACvB,EAAA,GAAKI;MACR;MACAI,KAAA,eACEW,IAAA,CAAC;QAAGK,KAAA,EAAO;UAAEC,MAAA,EAAQ;QAAE;kBACpBjB,KAAA,iBACCW,IAAA,CAAC7B,UAAA;UAAWQ,KAAA,EAAOA,KAAA;UAAOC,SAAA,EAAWA,SAAA;UAAWG,IAAA,EAAMA,IAAA;UAAMD,QAAA,EAAUA;;;MAI5EyB,UAAA,EAAY7B;QAEbS,UAAA;;AAGP;AAEA,OAAO,MAAMqB,SAAA,GAAYvC,aAAA,CAAcI,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAa/D,OAAO,cAAc,CAAA;AAgMrB,eAAO,MAAM,WAAW;;;;;;+EAAsC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAaxE,OAAO,cAAc,CAAA;AA8LrB,eAAO,MAAM,WAAW;;;;;;+EAAsC,CAAA"}