@10x-media/fields 0.1.0-beta.9 → 4.0.0-alpha.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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -3
  3. package/dist/fields/color/client/ColorInput.js +17 -6
  4. package/dist/fields/color/client/ColorInput.js.map +1 -1
  5. package/dist/fields/color/client/ColorPickerPanel.js +18 -12
  6. package/dist/fields/color/client/ColorPickerPanel.js.map +1 -1
  7. package/dist/fields/color/client/colorField.css +131 -178
  8. package/dist/fields/color/client/icons.js +17 -24
  9. package/dist/fields/color/client/icons.js.map +1 -1
  10. package/dist/fields/color/colorField.js +5 -3
  11. package/dist/fields/color/colorField.js.map +1 -1
  12. package/dist/fields/color/server/colorCell.css +8 -9
  13. package/dist/fields/encrypted/components/EncryptedInput.js +44 -26
  14. package/dist/fields/encrypted/components/EncryptedInput.js.map +1 -1
  15. package/dist/fields/encrypted/components/EncryptedTextarea.js +29 -29
  16. package/dist/fields/encrypted/components/EncryptedTextarea.js.map +1 -1
  17. package/dist/fields/encrypted/components/EyeToggle.js +14 -35
  18. package/dist/fields/encrypted/components/EyeToggle.js.map +1 -1
  19. package/dist/fields/encrypted/components/ProtectedField.css +107 -159
  20. package/dist/fields/encrypted/components/ProtectedField.js +6 -2
  21. package/dist/fields/encrypted/components/ProtectedField.js.map +1 -1
  22. package/dist/fields/encrypted/components/RichTextRevealGate.js +3 -3
  23. package/dist/fields/encrypted/components/RichTextRevealGate.js.map +1 -1
  24. package/dist/fields/encrypted/components/WriteOnlyActions.js +58 -53
  25. package/dist/fields/encrypted/components/WriteOnlyActions.js.map +1 -1
  26. package/dist/fields/encrypted/components/WriteOnlyField.js +39 -21
  27. package/dist/fields/encrypted/components/WriteOnlyField.js.map +1 -1
  28. package/dist/fields/encrypted/components/facsimiles.js +70 -79
  29. package/dist/fields/encrypted/components/facsimiles.js.map +1 -1
  30. package/dist/fields/encrypted/components/placement.js.map +1 -1
  31. package/dist/fields/encrypted/encryptedField.js +25 -12
  32. package/dist/fields/encrypted/encryptedField.js.map +1 -1
  33. package/dist/fields/encrypted/{typescriptSchema.js → jsonSchema.js} +4 -4
  34. package/dist/fields/encrypted/jsonSchema.js.map +1 -0
  35. package/dist/fields/encrypted/queryRewrite.js +20 -0
  36. package/dist/fields/encrypted/queryRewrite.js.map +1 -1
  37. package/dist/fields/encrypted/validators.js +1 -1
  38. package/dist/fields/encrypted/validators.js.map +1 -1
  39. package/dist/fields/icon/adapters/tabler/generated/nodes.js +1 -1
  40. package/dist/fields/icon/adapters/tabler/generated/nodes.js.map +1 -1
  41. package/dist/fields/icon/client/IconDrawerContent.js +8 -6
  42. package/dist/fields/icon/client/IconDrawerContent.js.map +1 -1
  43. package/dist/fields/icon/client/IconFieldClient.js +15 -37
  44. package/dist/fields/icon/client/IconFieldClient.js.map +1 -1
  45. package/dist/fields/icon/client/icon-field.css +137 -233
  46. package/dist/fields/icon/codegen/sources/tabler.js +25 -6
  47. package/dist/fields/icon/codegen/sources/tabler.js.map +1 -1
  48. package/dist/fields/icon/layers/upload.js +3 -0
  49. package/dist/fields/icon/layers/upload.js.map +1 -1
  50. package/dist/fields/icon/react/createIcon.js +4 -4
  51. package/dist/fields/icon/react/createIcon.js.map +1 -1
  52. package/dist/fields/measurement/client/MeasurementInput.js +18 -32
  53. package/dist/fields/measurement/client/MeasurementInput.js.map +1 -1
  54. package/dist/fields/measurement/client/measurementField.css +58 -105
  55. package/dist/fields/measurement/server/getUserUnits.js +2 -1
  56. package/dist/fields/measurement/server/getUserUnits.js.map +1 -1
  57. package/dist/fields/phoneNumber/client/CountryPicker.js +14 -9
  58. package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -1
  59. package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +1 -1
  60. package/dist/fields/phoneNumber/client/PhoneNumberField.js +22 -4
  61. package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -1
  62. package/dist/fields/phoneNumber/client/phoneNumberField.css +109 -142
  63. package/dist/fields/phoneNumber/phoneNumberField.js +1 -1
  64. package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -1
  65. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +2 -1
  66. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -1
  67. package/dist/index.d.ts +3 -2
  68. package/dist/index.js +5 -4
  69. package/dist/index.js.map +1 -1
  70. package/dist/plugin/companionSelect.d.ts +12 -0
  71. package/dist/plugin/companionSelect.js +107 -0
  72. package/dist/plugin/companionSelect.js.map +1 -0
  73. package/package.json +15 -15
  74. package/dist/fields/encrypted/typescriptSchema.js.map +0 -1
@@ -1,110 +1,78 @@
1
- /* Mirrors Payload's formInput mixin (packages/ui/src/scss/vars.scss) so the composite
2
- row reads as one native text input; focus rides :focus-within.
3
- Dimensions are static px on purpose: Payload compiles scss base() to literal px
4
- (native inputs stay 40px tall at every breakpoint), while the runtime --base var
5
- is rem-based and shrinks with the responsive html font-size. */
6
- .fields-phone__container {
1
+ .fields-phone > .field-type__wrap {
7
2
  display: flex;
8
- align-items: center;
9
- gap: 6px;
10
- width: 100%;
11
- height: 40px;
12
- padding: 0 8px 0 4px;
13
- border: 1px solid var(--theme-elevation-150);
14
- border-radius: var(--style-radius-s);
15
- background: var(--theme-input-bg);
16
- color: var(--theme-elevation-800);
17
- font-family: var(--font-body);
18
- font-size: 1rem;
19
- box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
20
- transition-property: border, box-shadow, background-color;
21
- transition-duration: 100ms, 100ms, 500ms;
22
- transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
23
- }
24
-
25
- .fields-phone__container:hover {
26
- border-color: var(--theme-elevation-250);
27
- box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.2);
28
- }
29
-
30
- .fields-phone__container:focus-within {
31
- border-color: var(--theme-elevation-400);
32
- outline: 0;
33
- }
34
-
35
- html[data-theme="light"] .fields-phone.error .fields-phone__container {
36
- background-color: var(--theme-error-50);
37
- border-color: var(--theme-error-500);
3
+ flex-direction: column;
4
+ gap: var(--spacer-2);
38
5
  }
39
6
 
40
- html[data-theme="dark"] .fields-phone.error .fields-phone__container {
41
- background-color: var(--theme-error-100);
42
- border-color: var(--theme-error-400);
7
+ /* Payload's .form-input-group (on the same element) owns the border, background, radius,
8
+ height and the hover, focus, error and disabled states; this only lays out the row. */
9
+ .fields-phone__container {
10
+ align-items: center;
11
+ gap: var(--spacer-1-5);
12
+ padding-inline: var(--spacer-1);
13
+ color: var(--field-color-text);
14
+ font-family: var(--font-body);
15
+ font-size: var(--text-body-medium-font-size);
16
+ font-weight: var(--text-body-medium-font-weight);
17
+ line-height: var(--text-body-medium-line-height);
43
18
  }
44
19
 
45
- html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
46
- border-color: var(--theme-error-500);
20
+ /* Native read-only inputs are disabled inputs on v4, so the row takes the disabled look.
21
+ A read-only input still takes focus here; Payload's .form-input:read-only:focus answers
22
+ that with the hover border, and so does this. */
23
+ .fields-phone.read-only .fields-phone__container {
24
+ border-color: var(--field-color-border-disabled);
25
+ background: var(--field-color-bg-disabled);
26
+ color: var(--field-color-text-disabled);
47
27
  }
48
28
 
49
- .fields-phone.read-only .fields-phone__container,
50
- .fields-phone.read-only .fields-phone__container:hover {
51
- border-color: var(--theme-elevation-150);
52
- background: var(--theme-elevation-100);
53
- color: var(--theme-elevation-400);
54
- box-shadow: none;
29
+ .fields-phone.read-only .fields-phone__container:focus-within {
30
+ border-color: var(--field-color-border-hover);
55
31
  }
56
32
 
57
33
  /* Popup's own root. The trigger is inset rather than stretched, so its hover fill clears the
58
- container's border by the same 4px on the left, top and bottom instead of bleeding into it. */
34
+ container's border by the same 4px at the start, top and bottom instead of bleeding into it. */
59
35
  .fields-phone__picker {
60
36
  display: flex;
37
+ flex-shrink: 0;
61
38
  align-self: center;
62
39
  }
63
40
 
64
- /* 10px of padding puts the flag on the 15px text column every native input starts at. */
41
+ /* With the container's 4px, 4px of padding puts the flag on the text column every native
42
+ input starts at. Payload's .popup-button paints the hover and pressed fills. */
65
43
  .fields-phone__trigger {
66
- display: inline-flex;
67
44
  flex-shrink: 0;
68
45
  align-items: center;
69
- gap: 4px;
70
- height: 30px;
71
- padding: 0 10px;
72
- border: 0;
73
- border-radius: var(--style-radius-s);
74
- background: transparent;
75
- color: var(--theme-elevation-500);
76
- cursor: pointer;
46
+ gap: var(--spacer-1);
47
+ height: var(--spacer-4);
48
+ padding-inline: var(--spacer-1);
49
+ color: var(--color-icon-secondary);
77
50
  }
78
51
 
79
- .fields-phone__trigger:hover {
80
- background: var(--theme-elevation-100);
81
- color: var(--theme-elevation-800);
52
+ .fields-phone__trigger:not(.popup-button--disabled):hover {
53
+ color: var(--color-icon);
82
54
  }
83
55
 
84
56
  .fields-phone__trigger:focus-visible {
85
57
  outline: var(--accessibility-outline);
86
58
  }
87
59
 
88
- .fields-phone__trigger:disabled {
89
- background: transparent;
90
- cursor: not-allowed;
91
- }
92
-
93
60
  .fields-phone__caret {
94
61
  display: flex;
95
62
  flex-shrink: 0;
96
63
  align-items: center;
97
64
  justify-content: center;
98
- width: 12px;
99
- height: 12px;
100
65
  }
101
66
 
102
67
  .fields-phone__code {
103
- color: var(--theme-elevation-800);
104
- font-size: 0.85rem;
68
+ color: var(--field-color-text);
105
69
  white-space: nowrap;
106
70
  }
107
71
 
72
+ .fields-phone.read-only .fields-phone__code {
73
+ color: inherit;
74
+ }
75
+
108
76
  /* A calling code is LTR wherever it is shown: under an RTL page the leading + is a neutral and
109
77
  bidi reorders "+49" to "49+". The UA stylesheet does the same for input[type="tel"]. */
110
78
  .fields-phone__prefix {
@@ -114,26 +82,18 @@ html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
114
82
  white-space: nowrap;
115
83
  }
116
84
 
117
- /* Chrome-less: the container owns the border, background and focus ring */
85
+ /* Chrome-less: the container owns the border, background and focus state */
118
86
  .fields-phone__input {
119
87
  flex: 1;
88
+ align-self: stretch;
120
89
  min-width: 0;
121
- height: 100%;
122
- padding: 0;
123
- border: 0;
124
- background: transparent;
125
90
  color: inherit;
126
- font-family: var(--font-body);
127
- font-size: 1rem;
128
- line-height: 20px;
129
91
  outline: 0;
130
92
  -webkit-appearance: none;
131
93
  }
132
94
 
133
95
  .fields-phone__input::placeholder {
134
- color: var(--theme-elevation-400);
135
- font-weight: normal;
136
- font-size: 1rem;
96
+ color: var(--field-color-placeholder);
137
97
  }
138
98
 
139
99
  /* Matches the native select's clear indicator: bare icon, no button chrome */
@@ -141,15 +101,15 @@ html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
141
101
  display: flex;
142
102
  flex-shrink: 0;
143
103
  align-items: center;
144
- padding: 0;
145
- border: 0;
146
- background: transparent;
147
- color: var(--theme-elevation-500);
104
+ justify-content: center;
105
+ min-width: var(--spacer-4);
106
+ min-height: var(--spacer-4);
107
+ color: var(--color-icon-secondary);
148
108
  cursor: pointer;
149
109
  }
150
110
 
151
111
  .fields-phone__clear:hover {
152
- color: var(--theme-elevation-800);
112
+ color: var(--color-icon);
153
113
  }
154
114
 
155
115
  .fields-phone__clear:focus-visible {
@@ -161,7 +121,7 @@ html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
161
121
  flex-shrink: 0;
162
122
  width: 20px;
163
123
  height: 15px;
164
- border-radius: 1px;
124
+ border-radius: var(--radius-small);
165
125
  object-fit: cover;
166
126
  }
167
127
 
@@ -183,102 +143,104 @@ html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
183
143
  border-width: 0;
184
144
  }
185
145
 
186
- /* Payload portals popup content to document.body, and caps that scroll container at
187
- calc(var(--base) * 10); a country list is taller than that and would be clipped behind
188
- a hidden scrollbar. The panel already bounds its own height, so the outer cap comes off
189
- entirely rather than being kept in step with it by arithmetic. */
146
+ /* Payload portals popup content to document.body and caps that scroll container at
147
+ min(320px, 100vh - 16px); on a short viewport the cap would clip the list behind a hidden
148
+ scrollbar while the search scrolls away with it. The panel already bounds its own height,
149
+ so the outer cap comes off entirely rather than being kept in step with it by arithmetic. */
190
150
  .popup__scroll-container:has(> .fields-phone__panel) {
191
151
  max-height: none;
192
152
  }
193
153
 
194
- /* The gap matches Popup's own content padding, so the search clears the panel edge by the
195
- same 10px on all four sides. */
154
+ /* Laid out as Payload's Combobox: a search above a separator, then the list. */
196
155
  .fields-phone__panel {
197
156
  display: flex;
198
157
  flex-direction: column;
199
- gap: 10px;
158
+ gap: var(--spacer-2);
200
159
  width: 260px;
201
160
  }
202
161
 
203
- /* Native input size: Payload's scale carries nothing smaller than 40px at 1rem */
204
162
  .fields-phone__search {
205
163
  display: flex;
206
164
  flex-shrink: 0;
207
165
  align-items: center;
208
- gap: 6px;
209
- height: 40px;
210
- padding: 0 8px;
211
- border: 1px solid var(--theme-elevation-150);
212
- border-radius: var(--style-radius-s);
213
- background: var(--theme-input-bg);
166
+ gap: var(--spacer-1);
167
+ margin-inline: var(--spacer-2);
168
+ padding-inline: var(--spacer-1) var(--spacer-2);
169
+ border-radius: var(--button-radius);
170
+ background: var(--color-bg-secondary);
214
171
  }
215
172
 
216
173
  .fields-phone__search:focus-within {
217
- border-color: var(--theme-elevation-400);
174
+ background: var(--color-bg-secondary-hover);
218
175
  }
219
176
 
220
177
  .fields-phone__search-icon {
221
178
  display: flex;
222
179
  flex-shrink: 0;
223
- width: 14px;
224
- height: 14px;
225
- color: var(--theme-elevation-400);
180
+ color: var(--color-icon-secondary);
181
+ }
182
+
183
+ .fields-phone__search-icon svg {
184
+ width: var(--spacer-4);
185
+ height: var(--spacer-4);
226
186
  }
227
187
 
228
188
  .fields-phone__search-input {
229
189
  flex: 1;
230
190
  min-width: 0;
231
- border: 0;
232
- background: transparent;
233
- color: inherit;
234
- font-family: var(--font-body);
235
- font-size: 1rem;
191
+ padding-block: var(--spacer-1);
192
+ color: var(--color-text);
193
+ font-size: var(--text-body-medium-font-size);
194
+ line-height: var(--text-body-medium-line-height);
236
195
  outline: 0;
237
196
  }
238
197
 
239
198
  .fields-phone__search-input::placeholder {
240
- color: var(--theme-elevation-400);
199
+ color: var(--color-text-tertiary);
241
200
  }
242
201
 
243
- /* max-height comes from the component, off the same row height the virtualizer measures with. */
202
+ /* max-height comes from the component, off the same row height the virtualizer measures with,
203
+ so the separator above the rows sits outside the box it caps. Payload's .popup-button-list
204
+ (on the same element) supplies the inline padding. */
244
205
  .fields-phone__list {
206
+ display: block;
207
+ box-sizing: content-box;
208
+ padding-block-start: var(--spacer-2);
209
+ border-block-start: var(--stroke-width-small) solid var(--color-border);
245
210
  overflow-y: auto;
246
211
  }
247
212
 
213
+ /* The heading reads as Payload's .popup-list-group-label; the empty row is the divider
214
+ between the priority countries and the rest, drawn as .popup-divider. */
248
215
  .fields-phone__group {
249
216
  display: flex;
250
217
  align-items: center;
251
- padding: 0 8px;
252
- border-top: 1px solid var(--theme-elevation-100);
253
- /* elevation-500 fails 4.5:1 at this font size against the panel background */
254
- color: var(--theme-elevation-700);
255
- font-size: 0.7rem;
256
- letter-spacing: 0.06em;
257
- text-transform: uppercase;
218
+ padding-inline: var(--spacer-1);
219
+ color: var(--color-text-secondary);
220
+ font-size: var(--text-body-medium-font-size);
221
+ line-height: var(--text-body-medium-line-height);
258
222
  }
259
223
 
260
- .fields-phone__option {
261
- display: flex;
262
- align-items: center;
263
- gap: 8px;
264
- padding: 0 8px;
265
- border: 0;
266
- border-radius: var(--style-radius-s);
267
- background: transparent;
268
- color: var(--theme-elevation-800);
269
- font-family: var(--font-body);
270
- font-size: 0.9rem;
271
- text-align: left;
272
- cursor: pointer;
224
+ .fields-phone__group:empty::before {
225
+ content: "";
226
+ flex: 1;
227
+ height: var(--stroke-width-small);
228
+ background: var(--color-border);
273
229
  }
274
230
 
275
- .fields-phone__option:hover,
276
- .fields-phone__option[data-active="true"] {
277
- background: var(--theme-elevation-100);
231
+ /* Payload's .popup-button-list__button (on the same element) supplies the item type, radius,
232
+ hover and selected fills. data-active is the keyboard cursor and reads as hover, but only
233
+ while the pointer is off the list, so hover and cursor never paint two rows at once. */
234
+ .fields-phone__option {
235
+ align-items: center;
236
+ gap: var(--spacer-2);
237
+ padding-inline: var(--spacer-1);
238
+ text-align: start;
278
239
  }
279
240
 
280
- .fields-phone__option[aria-selected="true"] {
281
- background: var(--theme-elevation-150);
241
+ .fields-phone__list:not(:hover) .fields-phone__option[data-active="true"] {
242
+ background-color: var(--popup-item-bg-hover, var(--color-bg-selected-strong));
243
+ color: var(--popup-item-color-hover, var(--color-text-onselected-strong));
282
244
  }
283
245
 
284
246
  .fields-phone__option-name {
@@ -292,14 +254,19 @@ html[data-theme="dark"] .fields-phone.error .fields-phone__container:hover {
292
254
  .fields-phone__option-code {
293
255
  flex-shrink: 0;
294
256
  direction: ltr;
295
- /* elevation-500 fails 4.5:1 at this font size against the panel background */
296
- color: var(--theme-elevation-700);
257
+ color: var(--color-text-secondary);
297
258
  font-variant-numeric: tabular-nums;
298
259
  }
299
260
 
261
+ .fields-phone__option:is(:hover, [aria-selected="true"]) .fields-phone__option-code,
262
+ .fields-phone__list:not(:hover)
263
+ .fields-phone__option[data-active="true"]
264
+ .fields-phone__option-code {
265
+ color: inherit;
266
+ }
267
+
300
268
  .fields-phone__empty {
301
- padding: 12px 8px;
302
- color: var(--theme-elevation-700);
303
- font-size: 0.9rem;
269
+ padding: var(--spacer-2-5) var(--spacer-2);
270
+ color: var(--color-text-secondary);
304
271
  text-align: center;
305
272
  }
@@ -27,7 +27,7 @@ const DERIVED = [
27
27
  const derivedFrom = (parsed) => Object.fromEntries(DERIVED.map((key) => [key, parsed[key]]));
28
28
  /** Stored and derived alike stay out of the list, so the group reads as one column. */
29
29
  const subfield = (name, extra = {}) => ({
30
- admin: { disableListColumn: true },
30
+ admin: { disabled: { column: true } },
31
31
  name,
32
32
  type: "text",
33
33
  ...extra
@@ -1 +1 @@
1
- {"version":3,"file":"phoneNumberField.js","names":[],"sources":["../../../src/fields/phoneNumber/phoneNumberField.ts"],"sourcesContent":["import type { FieldHook, GroupField, TextField, Validate } from 'payload'\nimport { keys } from '../../translations/keys'\nimport { asTranslate } from '../../translations/server'\nimport { isKnownCountry } from './engine/countries'\nimport { loadMetadata, type PhoneMetadata } from './engine/metadata'\nimport { type CountryCode, checkPhone, type ParsedPhone, parsePhone } from './engine/phone'\nimport {\n\ttype AnyPhoneNumberFieldOptions,\n\tPHONE_CUSTOM_KEY,\n\ttype PhoneNumberE164FieldOptions,\n\ttype PhoneNumberFieldOptions,\n\ttype ResolvablePhoneFieldOptions,\n\ttype ResolvedPhoneOptions,\n} from './options'\nimport { resolvePhoneOptionsSafe } from './server/resolvePhoneOptionsSafe'\n\nconst assertCountries = (opts: {\n\tcountries: readonly CountryCode[] | undefined\n\tdefaultCountry: CountryCode | undefined\n\tname: string\n}): void => {\n\tconst { countries, defaultCountry, name } = opts\n\tfor (const code of countries ?? []) {\n\t\tif (!isKnownCountry(code)) {\n\t\t\tthrow new Error(\n\t\t\t\t`phoneNumberField(${name}): countries entry \"${code}\" is not a supported country`\n\t\t\t)\n\t\t}\n\t}\n\tif (defaultCountry === undefined) return\n\tif (!isKnownCountry(defaultCountry)) {\n\t\tthrow new Error(\n\t\t\t`phoneNumberField(${name}): defaultCountry \"${defaultCountry}\" is not a supported country`\n\t\t)\n\t}\n\tif (countries !== undefined && !countries.includes(defaultCountry)) {\n\t\tthrow new Error(\n\t\t\t`phoneNumberField(${name}): defaultCountry \"${defaultCountry}\" is not in countries`\n\t\t)\n\t}\n}\n\n/**\n * The values the read hook derives, driving both the group's schema and the hook itself: a\n * name the group has no field for would otherwise be written and silently stripped.\n */\nconst DERIVED = [\n\t'national',\n\t'international',\n\t'callingCode',\n\t'uri',\n\t'type',\n] as const satisfies readonly (keyof ParsedPhone)[]\n\ntype DerivedPhone = Pick<ParsedPhone, (typeof DERIVED)[number]>\n\nconst derivedFrom = (parsed: ParsedPhone): DerivedPhone =>\n\tObject.fromEntries(DERIVED.map((key) => [key, parsed[key]])) as DerivedPhone\n\n/** Stored and derived alike stay out of the list, so the group reads as one column. */\nconst subfield = (name: string, extra: { virtual?: true } = {}): TextField => ({\n\tadmin: { disableListColumn: true },\n\tname,\n\ttype: 'text',\n\t...extra,\n})\n\n/** Both storage shapes render through the same pair, so neither path can drift from it. */\nconst phoneComponents = (fieldLayer: ResolvablePhoneFieldOptions) => ({\n\tCell: {\n\t\tclientProps: { phoneOptions: fieldLayer },\n\t\tpath: '@10x-media/fields/rsc#PhoneNumberCellServer',\n\t},\n\tField: {\n\t\tclientProps: { phoneOptions: fieldLayer },\n\t\tpath: '@10x-media/fields/rsc#PhoneNumberFieldServer',\n\t},\n})\n\n/** Configuration errors return a message rather than throw: writes must fail either way. */\nconst mobileMetadataMismatch = (name: string): string =>\n\t`phoneNumberField(${name}): validation \"mobile\" requires metadata \"max\" or \"mobile\", but this install is configured \"min\"`\n\nconst buildDerivedHook =\n\t(fieldLayer: ResolvablePhoneFieldOptions): FieldHook =>\n\tasync ({ req, value }) => {\n\t\tconst stored = (value ?? {}) as { country?: CountryCode; number?: string }\n\t\tif (typeof stored.number !== 'string' || stored.number === '') return value\n\t\tconst resolved = resolvePhoneOptionsSafe({ fieldOptions: fieldLayer, payload: req.payload })\n\t\t// A throwing afterRead fails the whole request, so one unloadable chunk would take down\n\t\t// every read of the collection; degrading costs the derived values on this field alone.\n\t\tlet metadata: PhoneMetadata\n\t\ttry {\n\t\t\tmetadata = await loadMetadata(resolved.metadata)\n\t\t} catch (error) {\n\t\t\treq.payload.logger.error(\n\t\t\t\t{ err: error },\n\t\t\t\t'[fields] phoneNumber metadata failed to load for a derived read'\n\t\t\t)\n\t\t\treturn value\n\t\t}\n\t\tconst parsed = parsePhone(stored.number, { defaultCountry: stored.country, metadata })\n\t\tif (!parsed) return value\n\t\t// Persisted keys spread first: this hook enriches the group, it never rewrites it.\n\t\treturn { ...stored, ...derivedFrom(parsed) }\n\t}\n\n/** How one storage shape yields the number to check and the country to read it under. */\ntype PhoneInputReader = (\n\tvalue: unknown,\n\tresolved: ResolvedPhoneOptions\n) => { country: CountryCode | undefined; raw: string }\n\n/** Object storage keeps the country beside the number, so the stored row speaks for itself. */\nconst readStoredPhone: PhoneInputReader = (value) => {\n\tconst stored = (value ?? {}) as { country?: CountryCode; number?: string }\n\treturn { country: stored.country, raw: typeof stored.number === 'string' ? stored.number : '' }\n}\n\n/** e164 storage has no country of its own, so a national number needs the resolved default. */\nconst readE164Phone: PhoneInputReader = (value, resolved) => ({\n\tcountry: resolved.defaultCountry,\n\traw: typeof value === 'string' ? value : '',\n})\n\nconst buildValidate =\n\t(opts: {\n\t\tfieldLayer: ResolvablePhoneFieldOptions\n\t\tname: string\n\t\tread: PhoneInputReader\n\t\trequired: boolean\n\t}): Validate =>\n\tasync (value, args) => {\n\t\tconst resolved = resolvePhoneOptionsSafe({\n\t\t\tfieldOptions: opts.fieldLayer,\n\t\t\tpayload: args.req.payload,\n\t\t})\n\t\tconst { country, raw } = opts.read(value, resolved)\n\t\tconst check = checkPhone(raw, resolved.validation, {\n\t\t\tdefaultCountry: country,\n\t\t\tmetadata: await loadMetadata(resolved.metadata),\n\t\t})\n\t\tif (check === 'empty') {\n\t\t\treturn opts.required ? asTranslate(args.req.t)(keys.phoneRequired) : true\n\t\t}\n\t\tif (check === 'notMobile') {\n\t\t\tif (resolved.validation === 'mobile' && resolved.metadata === 'min') {\n\t\t\t\treturn mobileMetadataMismatch(opts.name)\n\t\t\t}\n\t\t\treturn asTranslate(args.req.t)(keys.phoneNotMobile)\n\t\t}\n\t\tif (check === 'invalid') return asTranslate(args.req.t)(keys.invalidPhoneNumber)\n\t\treturn true\n\t}\n\n/**\n * Group of `number` + `country`, plus a derived-on-read `national`/`international`/\n * `callingCode`/`uri`/`type`. Spread a preset for `e164` storage via `storage: 'e164'`,\n * which trades the country/derived subfields for a single text field holding the raw string.\n */\nexport function phoneNumberField(options: PhoneNumberE164FieldOptions): TextField\nexport function phoneNumberField(options: PhoneNumberFieldOptions): GroupField\nexport function phoneNumberField(options: AnyPhoneNumberFieldOptions): GroupField | TextField {\n\tconst {\n\t\tname,\n\t\tlabel,\n\t\trequired,\n\t\tlocalized,\n\t\tindex,\n\t\tdefaultCountry,\n\t\tcountries,\n\t\tpriorityCountries,\n\t\tpriorityCountriesLabel,\n\t\tvalidation,\n\t\tflags,\n\t\tcellFormat,\n\t\tisClearable,\n\t} = options\n\n\tassertCountries({ countries, defaultCountry, name })\n\n\t// The field's own options, exactly as written, with no defaults applied: registry\n\t// defaults are only visible at request time, via resolvePhoneOptionsSafe below.\n\tconst fieldLayer: ResolvablePhoneFieldOptions = {\n\t\t...(cellFormat !== undefined ? { cellFormat } : {}),\n\t\t...(countries !== undefined ? { countries } : {}),\n\t\t...(defaultCountry !== undefined ? { defaultCountry } : {}),\n\t\t...(flags !== undefined ? { flags } : {}),\n\t\t...(isClearable !== undefined ? { isClearable } : {}),\n\t\t...(priorityCountries !== undefined ? { priorityCountries } : {}),\n\t\t...(priorityCountriesLabel !== undefined ? { priorityCountriesLabel } : {}),\n\t\t...(options.storage !== undefined ? { storage: options.storage } : {}),\n\t\t...(validation !== undefined ? { validation } : {}),\n\t}\n\n\tif (options.storage === 'e164') {\n\t\tconst base: TextField = {\n\t\t\tname,\n\t\t\ttype: 'text',\n\t\t\t...(label !== undefined ? { label } : {}),\n\t\t\t...(required !== undefined ? { required } : {}),\n\t\t\t...(localized !== undefined ? { localized } : {}),\n\t\t\t...(index !== undefined ? { index } : {}),\n\t\t\tadmin: { components: phoneComponents(fieldLayer) },\n\t\t\tcustom: { [PHONE_CUSTOM_KEY]: fieldLayer },\n\t\t\tvalidate: buildValidate({\n\t\t\t\tfieldLayer,\n\t\t\t\tname,\n\t\t\t\tread: readE164Phone,\n\t\t\t\trequired: required ?? false,\n\t\t\t}),\n\t\t}\n\t\treturn typeof options.overrides === 'function' ? options.overrides({ field: base }) : base\n\t}\n\n\tconst base: GroupField = {\n\t\tname,\n\t\ttype: 'group',\n\t\t...(label !== undefined ? { label } : {}),\n\t\t...(required !== undefined ? { required } : {}),\n\t\t...(localized !== undefined ? { localized } : {}),\n\t\t...(index !== undefined ? { index } : {}),\n\t\tadmin: { components: phoneComponents(fieldLayer) },\n\t\tcustom: { [PHONE_CUSTOM_KEY]: fieldLayer },\n\t\tfields: [\n\t\t\tsubfield('number'),\n\t\t\tsubfield('country'),\n\t\t\t...DERIVED.map((name) => subfield(name, { virtual: true })),\n\t\t],\n\t\thooks: { afterRead: [buildDerivedHook(fieldLayer)] },\n\t\tvalidate: buildValidate({\n\t\t\tfieldLayer,\n\t\t\tname,\n\t\t\tread: readStoredPhone,\n\t\t\trequired: required ?? false,\n\t\t}),\n\t}\n\n\treturn typeof options.overrides === 'function' ? options.overrides({ field: base }) : base\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,mBAAmB,SAIb;CACX,MAAM,EAAE,WAAW,gBAAgB,SAAS;CAC5C,KAAK,MAAM,QAAQ,aAAa,CAAC,GAChC,IAAI,CAAC,eAAe,IAAI,GACvB,MAAM,IAAI,MACT,oBAAoB,KAAK,sBAAsB,KAAK,6BACrD;CAGF,IAAI,mBAAmB,KAAA,GAAW;CAClC,IAAI,CAAC,eAAe,cAAc,GACjC,MAAM,IAAI,MACT,oBAAoB,KAAK,qBAAqB,eAAe,6BAC9D;CAED,IAAI,cAAc,KAAA,KAAa,CAAC,UAAU,SAAS,cAAc,GAChE,MAAM,IAAI,MACT,oBAAoB,KAAK,qBAAqB,eAAe,sBAC9D;AAEF;;;;;AAMA,MAAM,UAAU;CACf;CACA;CACA;CACA;CACA;AACD;AAIA,MAAM,eAAe,WACpB,OAAO,YAAY,QAAQ,KAAK,QAAQ,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;;AAG5D,MAAM,YAAY,MAAc,QAA4B,CAAC,OAAkB;CAC9E,OAAO,EAAE,mBAAmB,KAAK;CACjC;CACA,MAAM;CACN,GAAG;AACJ;;AAGA,MAAM,mBAAmB,gBAA6C;CACrE,MAAM;EACL,aAAa,EAAE,cAAc,WAAW;EACxC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,CAAC;GAC/C,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;GACvC,OAAO,EAAE,YAAY,gBAAgB,UAAU,EAAE;GACjD,QAAQ,GAAG,mBAAmB,WAAW;GACzC,UAAU,cAAc;IACvB;IACA;IACA,MAAM;IACN,UAAU,YAAY;GACvB,CAAC;EACF;EACA,OAAO,OAAO,QAAQ,cAAc,aAAa,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC,IAAI;CACvF;CAEA,MAAM,OAAmB;EACxB;EACA,MAAM;EACN,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;EACvC,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;EACvC,OAAO,EAAE,YAAY,gBAAgB,UAAU,EAAE;EACjD,QAAQ,GAAG,mBAAmB,WAAW;EACzC,QAAQ;GACP,SAAS,QAAQ;GACjB,SAAS,SAAS;GAClB,GAAG,QAAQ,KAAK,SAAS,SAAS,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC;EAC3D;EACA,OAAO,EAAE,WAAW,CAAC,iBAAiB,UAAU,CAAC,EAAE;EACnD,UAAU,cAAc;GACvB;GACA;GACA,MAAM;GACN,UAAU,YAAY;EACvB,CAAC;CACF;CAEA,OAAO,OAAO,QAAQ,cAAc,aAAa,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC,IAAI;AACvF"}
1
+ {"version":3,"file":"phoneNumberField.js","names":[],"sources":["../../../src/fields/phoneNumber/phoneNumberField.ts"],"sourcesContent":["import type { FieldHook, GroupField, TextField, Validate } from 'payload'\nimport { keys } from '../../translations/keys'\nimport { asTranslate } from '../../translations/server'\nimport { isKnownCountry } from './engine/countries'\nimport { loadMetadata, type PhoneMetadata } from './engine/metadata'\nimport { type CountryCode, checkPhone, type ParsedPhone, parsePhone } from './engine/phone'\nimport {\n\ttype AnyPhoneNumberFieldOptions,\n\tPHONE_CUSTOM_KEY,\n\ttype PhoneNumberE164FieldOptions,\n\ttype PhoneNumberFieldOptions,\n\ttype ResolvablePhoneFieldOptions,\n\ttype ResolvedPhoneOptions,\n} from './options'\nimport { resolvePhoneOptionsSafe } from './server/resolvePhoneOptionsSafe'\n\nconst assertCountries = (opts: {\n\tcountries: readonly CountryCode[] | undefined\n\tdefaultCountry: CountryCode | undefined\n\tname: string\n}): void => {\n\tconst { countries, defaultCountry, name } = opts\n\tfor (const code of countries ?? []) {\n\t\tif (!isKnownCountry(code)) {\n\t\t\tthrow new Error(\n\t\t\t\t`phoneNumberField(${name}): countries entry \"${code}\" is not a supported country`\n\t\t\t)\n\t\t}\n\t}\n\tif (defaultCountry === undefined) return\n\tif (!isKnownCountry(defaultCountry)) {\n\t\tthrow new Error(\n\t\t\t`phoneNumberField(${name}): defaultCountry \"${defaultCountry}\" is not a supported country`\n\t\t)\n\t}\n\tif (countries !== undefined && !countries.includes(defaultCountry)) {\n\t\tthrow new Error(\n\t\t\t`phoneNumberField(${name}): defaultCountry \"${defaultCountry}\" is not in countries`\n\t\t)\n\t}\n}\n\n/**\n * The values the read hook derives, driving both the group's schema and the hook itself: a\n * name the group has no field for would otherwise be written and silently stripped.\n */\nconst DERIVED = [\n\t'national',\n\t'international',\n\t'callingCode',\n\t'uri',\n\t'type',\n] as const satisfies readonly (keyof ParsedPhone)[]\n\ntype DerivedPhone = Pick<ParsedPhone, (typeof DERIVED)[number]>\n\nconst derivedFrom = (parsed: ParsedPhone): DerivedPhone =>\n\tObject.fromEntries(DERIVED.map((key) => [key, parsed[key]])) as DerivedPhone\n\n/** Stored and derived alike stay out of the list, so the group reads as one column. */\nconst subfield = (name: string, extra: { virtual?: true } = {}): TextField => ({\n\tadmin: { disabled: { column: true } },\n\tname,\n\ttype: 'text',\n\t...extra,\n})\n\n/** Both storage shapes render through the same pair, so neither path can drift from it. */\nconst phoneComponents = (fieldLayer: ResolvablePhoneFieldOptions) => ({\n\tCell: {\n\t\tclientProps: { phoneOptions: fieldLayer },\n\t\tpath: '@10x-media/fields/rsc#PhoneNumberCellServer',\n\t},\n\tField: {\n\t\tclientProps: { phoneOptions: fieldLayer },\n\t\tpath: '@10x-media/fields/rsc#PhoneNumberFieldServer',\n\t},\n})\n\n/** Configuration errors return a message rather than throw: writes must fail either way. */\nconst mobileMetadataMismatch = (name: string): string =>\n\t`phoneNumberField(${name}): validation \"mobile\" requires metadata \"max\" or \"mobile\", but this install is configured \"min\"`\n\nconst buildDerivedHook =\n\t(fieldLayer: ResolvablePhoneFieldOptions): FieldHook =>\n\tasync ({ req, value }) => {\n\t\tconst stored = (value ?? {}) as { country?: CountryCode; number?: string }\n\t\tif (typeof stored.number !== 'string' || stored.number === '') return value\n\t\tconst resolved = resolvePhoneOptionsSafe({ fieldOptions: fieldLayer, payload: req.payload })\n\t\t// A throwing afterRead fails the whole request, so one unloadable chunk would take down\n\t\t// every read of the collection; degrading costs the derived values on this field alone.\n\t\tlet metadata: PhoneMetadata\n\t\ttry {\n\t\t\tmetadata = await loadMetadata(resolved.metadata)\n\t\t} catch (error) {\n\t\t\treq.payload.logger.error(\n\t\t\t\t{ err: error },\n\t\t\t\t'[fields] phoneNumber metadata failed to load for a derived read'\n\t\t\t)\n\t\t\treturn value\n\t\t}\n\t\tconst parsed = parsePhone(stored.number, { defaultCountry: stored.country, metadata })\n\t\tif (!parsed) return value\n\t\t// Persisted keys spread first: this hook enriches the group, it never rewrites it.\n\t\treturn { ...stored, ...derivedFrom(parsed) }\n\t}\n\n/** How one storage shape yields the number to check and the country to read it under. */\ntype PhoneInputReader = (\n\tvalue: unknown,\n\tresolved: ResolvedPhoneOptions\n) => { country: CountryCode | undefined; raw: string }\n\n/** Object storage keeps the country beside the number, so the stored row speaks for itself. */\nconst readStoredPhone: PhoneInputReader = (value) => {\n\tconst stored = (value ?? {}) as { country?: CountryCode; number?: string }\n\treturn { country: stored.country, raw: typeof stored.number === 'string' ? stored.number : '' }\n}\n\n/** e164 storage has no country of its own, so a national number needs the resolved default. */\nconst readE164Phone: PhoneInputReader = (value, resolved) => ({\n\tcountry: resolved.defaultCountry,\n\traw: typeof value === 'string' ? value : '',\n})\n\nconst buildValidate =\n\t(opts: {\n\t\tfieldLayer: ResolvablePhoneFieldOptions\n\t\tname: string\n\t\tread: PhoneInputReader\n\t\trequired: boolean\n\t}): Validate =>\n\tasync (value, args) => {\n\t\tconst resolved = resolvePhoneOptionsSafe({\n\t\t\tfieldOptions: opts.fieldLayer,\n\t\t\tpayload: args.req.payload,\n\t\t})\n\t\tconst { country, raw } = opts.read(value, resolved)\n\t\tconst check = checkPhone(raw, resolved.validation, {\n\t\t\tdefaultCountry: country,\n\t\t\tmetadata: await loadMetadata(resolved.metadata),\n\t\t})\n\t\tif (check === 'empty') {\n\t\t\treturn opts.required ? asTranslate(args.req.t)(keys.phoneRequired) : true\n\t\t}\n\t\tif (check === 'notMobile') {\n\t\t\tif (resolved.validation === 'mobile' && resolved.metadata === 'min') {\n\t\t\t\treturn mobileMetadataMismatch(opts.name)\n\t\t\t}\n\t\t\treturn asTranslate(args.req.t)(keys.phoneNotMobile)\n\t\t}\n\t\tif (check === 'invalid') return asTranslate(args.req.t)(keys.invalidPhoneNumber)\n\t\treturn true\n\t}\n\n/**\n * Group of `number` + `country`, plus a derived-on-read `national`/`international`/\n * `callingCode`/`uri`/`type`. Spread a preset for `e164` storage via `storage: 'e164'`,\n * which trades the country/derived subfields for a single text field holding the raw string.\n */\nexport function phoneNumberField(options: PhoneNumberE164FieldOptions): TextField\nexport function phoneNumberField(options: PhoneNumberFieldOptions): GroupField\nexport function phoneNumberField(options: AnyPhoneNumberFieldOptions): GroupField | TextField {\n\tconst {\n\t\tname,\n\t\tlabel,\n\t\trequired,\n\t\tlocalized,\n\t\tindex,\n\t\tdefaultCountry,\n\t\tcountries,\n\t\tpriorityCountries,\n\t\tpriorityCountriesLabel,\n\t\tvalidation,\n\t\tflags,\n\t\tcellFormat,\n\t\tisClearable,\n\t} = options\n\n\tassertCountries({ countries, defaultCountry, name })\n\n\t// The field's own options, exactly as written, with no defaults applied: registry\n\t// defaults are only visible at request time, via resolvePhoneOptionsSafe below.\n\tconst fieldLayer: ResolvablePhoneFieldOptions = {\n\t\t...(cellFormat !== undefined ? { cellFormat } : {}),\n\t\t...(countries !== undefined ? { countries } : {}),\n\t\t...(defaultCountry !== undefined ? { defaultCountry } : {}),\n\t\t...(flags !== undefined ? { flags } : {}),\n\t\t...(isClearable !== undefined ? { isClearable } : {}),\n\t\t...(priorityCountries !== undefined ? { priorityCountries } : {}),\n\t\t...(priorityCountriesLabel !== undefined ? { priorityCountriesLabel } : {}),\n\t\t...(options.storage !== undefined ? { storage: options.storage } : {}),\n\t\t...(validation !== undefined ? { validation } : {}),\n\t}\n\n\tif (options.storage === 'e164') {\n\t\tconst base: TextField = {\n\t\t\tname,\n\t\t\ttype: 'text',\n\t\t\t...(label !== undefined ? { label } : {}),\n\t\t\t...(required !== undefined ? { required } : {}),\n\t\t\t...(localized !== undefined ? { localized } : {}),\n\t\t\t...(index !== undefined ? { index } : {}),\n\t\t\tadmin: { components: phoneComponents(fieldLayer) },\n\t\t\tcustom: { [PHONE_CUSTOM_KEY]: fieldLayer },\n\t\t\tvalidate: buildValidate({\n\t\t\t\tfieldLayer,\n\t\t\t\tname,\n\t\t\t\tread: readE164Phone,\n\t\t\t\trequired: required ?? false,\n\t\t\t}),\n\t\t}\n\t\treturn typeof options.overrides === 'function' ? options.overrides({ field: base }) : base\n\t}\n\n\tconst base: GroupField = {\n\t\tname,\n\t\ttype: 'group',\n\t\t...(label !== undefined ? { label } : {}),\n\t\t...(required !== undefined ? { required } : {}),\n\t\t...(localized !== undefined ? { localized } : {}),\n\t\t...(index !== undefined ? { index } : {}),\n\t\tadmin: { components: phoneComponents(fieldLayer) },\n\t\tcustom: { [PHONE_CUSTOM_KEY]: fieldLayer },\n\t\tfields: [\n\t\t\tsubfield('number'),\n\t\t\tsubfield('country'),\n\t\t\t...DERIVED.map((name) => subfield(name, { virtual: true })),\n\t\t],\n\t\thooks: { afterRead: [buildDerivedHook(fieldLayer)] },\n\t\tvalidate: buildValidate({\n\t\t\tfieldLayer,\n\t\t\tname,\n\t\t\tread: readStoredPhone,\n\t\t\trequired: required ?? false,\n\t\t}),\n\t}\n\n\treturn typeof options.overrides === 'function' ? options.overrides({ field: base }) : base\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,mBAAmB,SAIb;CACX,MAAM,EAAE,WAAW,gBAAgB,SAAS;CAC5C,KAAK,MAAM,QAAQ,aAAa,CAAC,GAChC,IAAI,CAAC,eAAe,IAAI,GACvB,MAAM,IAAI,MACT,oBAAoB,KAAK,sBAAsB,KAAK,6BACrD;CAGF,IAAI,mBAAmB,KAAA,GAAW;CAClC,IAAI,CAAC,eAAe,cAAc,GACjC,MAAM,IAAI,MACT,oBAAoB,KAAK,qBAAqB,eAAe,6BAC9D;CAED,IAAI,cAAc,KAAA,KAAa,CAAC,UAAU,SAAS,cAAc,GAChE,MAAM,IAAI,MACT,oBAAoB,KAAK,qBAAqB,eAAe,sBAC9D;AAEF;;;;;AAMA,MAAM,UAAU;CACf;CACA;CACA;CACA;CACA;AACD;AAIA,MAAM,eAAe,WACpB,OAAO,YAAY,QAAQ,KAAK,QAAQ,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;;AAG5D,MAAM,YAAY,MAAc,QAA4B,CAAC,OAAkB;CAC9E,OAAO,EAAE,UAAU,EAAE,QAAQ,KAAK,EAAE;CACpC;CACA,MAAM;CACN,GAAG;AACJ;;AAGA,MAAM,mBAAmB,gBAA6C;CACrE,MAAM;EACL,aAAa,EAAE,cAAc,WAAW;EACxC,MAAM;CACP;CACA,OAAO;EACN,aAAa,EAAE,cAAc,WAAW;EACxC,MAAM;CACP;AACD;;AAGA,MAAM,0BAA0B,SAC/B,oBAAoB,KAAK;AAE1B,MAAM,oBACJ,eACD,OAAO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UAAU,cAAc;IACvB;IACA;IACA,MAAM;IACN,UAAU,YAAY;GACvB,CAAC;EACF;EACA,OAAO,OAAO,QAAQ,cAAc,aAAa,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC,IAAI;CACvF;CAEA,MAAM,OAAmB;EACxB;EACA,MAAM;EACN,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;EACvC,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C,GAAI,UAAU,KAAA,IAAY,EAAE,MAAM,IAAI,CAAC;EACvC,OAAO,EAAE,YAAY,gBAAgB,UAAU,EAAE;EACjD,QAAQ,GAAG,mBAAmB,WAAW;EACzC,QAAQ;GACP,SAAS,QAAQ;GACjB,SAAS,SAAS;GAClB,GAAG,QAAQ,KAAK,SAAS,SAAS,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC;EAC3D;EACA,OAAO,EAAE,WAAW,CAAC,iBAAiB,UAAU,CAAC,EAAE;EACnD,UAAU,cAAc;GACvB;GACA;GACA,MAAM;GACN,UAAU,YAAY;EACvB,CAAC;CACF;CAEA,OAAO,OAAO,QAAQ,cAAc,aAAa,QAAQ,UAAU,EAAE,OAAO,KAAK,CAAC,IAAI;AACvF"}
@@ -57,7 +57,8 @@ const PhoneNumberCellServer = async (props) => {
57
57
  style: {
58
58
  alignItems: "center",
59
59
  display: "inline-flex",
60
- gap: 6
60
+ gap: "var(--spacer-1-5)",
61
+ verticalAlign: "top"
61
62
  },
62
63
  children: [renderFlag({
63
64
  apiRoute: payload.config.routes.api,
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumberCellServer.js","names":[],"sources":["../../../../src/fields/phoneNumber/server/PhoneNumberCellServer.tsx"],"sourcesContent":["import type { ClientField, DefaultServerCellComponentProps } from 'payload'\nimport { emojiFlag } from '../engine/countries'\nimport { loadMetadata } from '../engine/metadata'\nimport { type CountryCode, type ParsedPhone, type PhoneFormat, parsePhone } from '../engine/phone'\nimport { countryFlagSrc, type PhoneFlagMode, type ResolvablePhoneFieldOptions } from '../options'\nimport { readPhoneOptions } from './readPhoneOptions'\nimport { resolvePhoneOptionsSafe } from './resolvePhoneOptionsSafe'\n\ntype PhoneNumberCellRawValue = { country?: string; number?: string } | null | string | undefined\n\ntype PhoneNumberCellServerComponentProps = {\n\tphoneOptions?: ResolvablePhoneFieldOptions\n} & DefaultServerCellComponentProps<ClientField, PhoneNumberCellRawValue>\n\nconst formatText = (parsed: null | ParsedPhone, raw: string, format: PhoneFormat): string => {\n\tif (!parsed) return raw\n\tif (format === 'e164') return parsed.e164\n\treturn format === 'national' ? parsed.national : parsed.international\n}\n\nconst renderFlag = (args: {\n\tcode: CountryCode | undefined\n\tflags: PhoneFlagMode\n\tserverURL: string\n\tapiRoute: string\n}) => {\n\tconst { apiRoute, code, flags, serverURL } = args\n\tif (flags === 'none' || code === undefined) return null\n\tif (flags === 'emoji') return <span aria-hidden=\"true\">{emojiFlag(code)}</span>\n\treturn (\n\t\t<img\n\t\t\talt=\"\"\n\t\t\taria-hidden=\"true\"\n\t\t\theight={15}\n\t\t\tsrc={countryFlagSrc(serverURL, apiRoute, code)}\n\t\t\twidth={20}\n\t\t/>\n\t)\n}\n\n/**\n * Formats entirely server-side: unlike measurement's cell, phone has no viewer\n * preference to react to, so this ships zero client JS for the list column.\n */\nexport const PhoneNumberCellServer = async (props: PhoneNumberCellServerComponentProps) => {\n\tconst { cellData, field, payload } = props\n\tconst phoneOptions = readPhoneOptions({\n\t\tcomponent: 'PhoneNumberCellServer',\n\t\tfield,\n\t\tpropOptions: props.phoneOptions,\n\t})\n\tconst resolved = resolvePhoneOptionsSafe({ fieldOptions: phoneOptions, payload })\n\n\tconst raw = typeof cellData === 'string' ? cellData : (cellData?.number ?? '')\n\tif (raw === '') return null\n\n\tconst storedCountry =\n\t\ttypeof cellData === 'object' && cellData?.country\n\t\t\t? (cellData.country as CountryCode)\n\t\t\t: undefined\n\t// An async server component that throws has no error boundary of its own here; a rejected\n\t// chunk degrades this one cell to the raw value instead of failing the whole list page.\n\tlet parsed: ParsedPhone | null = null\n\ttry {\n\t\tconst metadata = await loadMetadata(resolved.metadata)\n\t\tparsed = parsePhone(raw, { defaultCountry: storedCountry, metadata })\n\t} catch (error) {\n\t\tpayload.logger.error(\n\t\t\t{ err: error },\n\t\t\t'[fields] phoneNumber metadata failed to load for a list cell'\n\t\t)\n\t}\n\tconst country = parsed?.country ?? storedCountry\n\n\treturn (\n\t\t<span style={{ alignItems: 'center', display: 'inline-flex', gap: 6 }}>\n\t\t\t{renderFlag({\n\t\t\t\tapiRoute: payload.config.routes.api,\n\t\t\t\tcode: country,\n\t\t\t\tflags: resolved.flags,\n\t\t\t\tserverURL: payload.config.serverURL,\n\t\t\t})}\n\t\t\t<span>{formatText(parsed, raw, resolved.cellFormat)}</span>\n\t\t</span>\n\t)\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,cAAc,QAA4B,KAAa,WAAgC;CAC5F,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,WAAW,QAAQ,OAAO,OAAO;CACrC,OAAO,WAAW,aAAa,OAAO,WAAW,OAAO;AACzD;AAEA,MAAM,cAAc,SAKd;CACL,MAAM,EAAE,UAAU,MAAM,OAAO,cAAc;CAC7C,IAAI,UAAU,UAAU,SAAS,KAAA,GAAW,OAAO;CACnD,IAAI,UAAU,SAAS,OAAO,oBAAC,QAAD;EAAM,eAAY;YAAQ,UAAU,IAAI;CAAQ,CAAA;CAC9E,OACC,oBAAC,OAAD;EACC,KAAI;EACJ,eAAY;EACZ,QAAQ;EACR,KAAK,eAAe,WAAW,UAAU,IAAI;EAC7C,OAAO;CACP,CAAA;AAEH;;;;;AAMA,MAAa,wBAAwB,OAAO,UAA+C;CAC1F,MAAM,EAAE,UAAU,OAAO,YAAY;CAMrC,MAAM,WAAW,wBAAwB;EAAE,cALtB,iBAAiB;GACrC,WAAW;GACX;GACA,aAAa,MAAM;EACpB,CACoE;EAAG;CAAQ,CAAC;CAEhF,MAAM,MAAM,OAAO,aAAa,WAAW,WAAY,UAAU,UAAU;CAC3E,IAAI,QAAQ,IAAI,OAAO;CAEvB,MAAM,gBACL,OAAO,aAAa,YAAY,UAAU,UACtC,SAAS,UACV,KAAA;CAGJ,IAAI,SAA6B;CACjC,IAAI;EAEH,SAAS,WAAW,KAAK;GAAE,gBAAgB;GAAe,UAAA,MADnC,aAAa,SAAS,QAAQ;EACc,CAAC;CACrE,SAAS,OAAO;EACf,QAAQ,OAAO,MACd,EAAE,KAAK,MAAM,GACb,8DACD;CACD;CACA,MAAM,UAAU,QAAQ,WAAW;CAEnC,OACC,qBAAC,QAAD;EAAM,OAAO;GAAE,YAAY;GAAU,SAAS;GAAe,KAAK;EAAE;YAApE,CACE,WAAW;GACX,UAAU,QAAQ,OAAO,OAAO;GAChC,MAAM;GACN,OAAO,SAAS;GAChB,WAAW,QAAQ,OAAO;EAC3B,CAAC,GACD,oBAAC,QAAD,EAAA,UAAO,WAAW,QAAQ,KAAK,SAAS,UAAU,EAAQ,CAAA,CACrD;;AAER"}
1
+ {"version":3,"file":"PhoneNumberCellServer.js","names":[],"sources":["../../../../src/fields/phoneNumber/server/PhoneNumberCellServer.tsx"],"sourcesContent":["import type { ClientField, DefaultServerCellComponentProps } from 'payload'\nimport { emojiFlag } from '../engine/countries'\nimport { loadMetadata } from '../engine/metadata'\nimport { type CountryCode, type ParsedPhone, type PhoneFormat, parsePhone } from '../engine/phone'\nimport { countryFlagSrc, type PhoneFlagMode, type ResolvablePhoneFieldOptions } from '../options'\nimport { readPhoneOptions } from './readPhoneOptions'\nimport { resolvePhoneOptionsSafe } from './resolvePhoneOptionsSafe'\n\ntype PhoneNumberCellRawValue = { country?: string; number?: string } | null | string | undefined\n\ntype PhoneNumberCellServerComponentProps = {\n\tphoneOptions?: ResolvablePhoneFieldOptions\n} & DefaultServerCellComponentProps<ClientField, PhoneNumberCellRawValue>\n\nconst formatText = (parsed: null | ParsedPhone, raw: string, format: PhoneFormat): string => {\n\tif (!parsed) return raw\n\tif (format === 'e164') return parsed.e164\n\treturn format === 'national' ? parsed.national : parsed.international\n}\n\nconst renderFlag = (args: {\n\tcode: CountryCode | undefined\n\tflags: PhoneFlagMode\n\tserverURL: string\n\tapiRoute: string\n}) => {\n\tconst { apiRoute, code, flags, serverURL } = args\n\tif (flags === 'none' || code === undefined) return null\n\tif (flags === 'emoji') return <span aria-hidden=\"true\">{emojiFlag(code)}</span>\n\treturn (\n\t\t<img\n\t\t\talt=\"\"\n\t\t\taria-hidden=\"true\"\n\t\t\theight={15}\n\t\t\tsrc={countryFlagSrc(serverURL, apiRoute, code)}\n\t\t\twidth={20}\n\t\t/>\n\t)\n}\n\n/**\n * Formats entirely server-side: unlike measurement's cell, phone has no viewer\n * preference to react to, so this ships zero client JS for the list column.\n */\nexport const PhoneNumberCellServer = async (props: PhoneNumberCellServerComponentProps) => {\n\tconst { cellData, field, payload } = props\n\tconst phoneOptions = readPhoneOptions({\n\t\tcomponent: 'PhoneNumberCellServer',\n\t\tfield,\n\t\tpropOptions: props.phoneOptions,\n\t})\n\tconst resolved = resolvePhoneOptionsSafe({ fieldOptions: phoneOptions, payload })\n\n\tconst raw = typeof cellData === 'string' ? cellData : (cellData?.number ?? '')\n\tif (raw === '') return null\n\n\tconst storedCountry =\n\t\ttypeof cellData === 'object' && cellData?.country\n\t\t\t? (cellData.country as CountryCode)\n\t\t\t: undefined\n\t// An async server component that throws has no error boundary of its own here; a rejected\n\t// chunk degrades this one cell to the raw value instead of failing the whole list page.\n\tlet parsed: ParsedPhone | null = null\n\ttry {\n\t\tconst metadata = await loadMetadata(resolved.metadata)\n\t\tparsed = parsePhone(raw, { defaultCountry: storedCountry, metadata })\n\t} catch (error) {\n\t\tpayload.logger.error(\n\t\t\t{ err: error },\n\t\t\t'[fields] phoneNumber metadata failed to load for a list cell'\n\t\t)\n\t}\n\tconst country = parsed?.country ?? storedCountry\n\n\treturn (\n\t\t// An inline-flex box takes its baseline from the flag, which lifts the number above the\n\t\t// row's other cells; aligning the box to the line top keeps the text on their line.\n\t\t<span\n\t\t\tstyle={{\n\t\t\t\talignItems: 'center',\n\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\tgap: 'var(--spacer-1-5)',\n\t\t\t\tverticalAlign: 'top',\n\t\t\t}}\n\t\t>\n\t\t\t{renderFlag({\n\t\t\t\tapiRoute: payload.config.routes.api,\n\t\t\t\tcode: country,\n\t\t\t\tflags: resolved.flags,\n\t\t\t\tserverURL: payload.config.serverURL,\n\t\t\t})}\n\t\t\t<span>{formatText(parsed, raw, resolved.cellFormat)}</span>\n\t\t</span>\n\t)\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,cAAc,QAA4B,KAAa,WAAgC;CAC5F,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,WAAW,QAAQ,OAAO,OAAO;CACrC,OAAO,WAAW,aAAa,OAAO,WAAW,OAAO;AACzD;AAEA,MAAM,cAAc,SAKd;CACL,MAAM,EAAE,UAAU,MAAM,OAAO,cAAc;CAC7C,IAAI,UAAU,UAAU,SAAS,KAAA,GAAW,OAAO;CACnD,IAAI,UAAU,SAAS,OAAO,oBAAC,QAAD;EAAM,eAAY;YAAQ,UAAU,IAAI;CAAQ,CAAA;CAC9E,OACC,oBAAC,OAAD;EACC,KAAI;EACJ,eAAY;EACZ,QAAQ;EACR,KAAK,eAAe,WAAW,UAAU,IAAI;EAC7C,OAAO;CACP,CAAA;AAEH;;;;;AAMA,MAAa,wBAAwB,OAAO,UAA+C;CAC1F,MAAM,EAAE,UAAU,OAAO,YAAY;CAMrC,MAAM,WAAW,wBAAwB;EAAE,cALtB,iBAAiB;GACrC,WAAW;GACX;GACA,aAAa,MAAM;EACpB,CACoE;EAAG;CAAQ,CAAC;CAEhF,MAAM,MAAM,OAAO,aAAa,WAAW,WAAY,UAAU,UAAU;CAC3E,IAAI,QAAQ,IAAI,OAAO;CAEvB,MAAM,gBACL,OAAO,aAAa,YAAY,UAAU,UACtC,SAAS,UACV,KAAA;CAGJ,IAAI,SAA6B;CACjC,IAAI;EAEH,SAAS,WAAW,KAAK;GAAE,gBAAgB;GAAe,UAAA,MADnC,aAAa,SAAS,QAAQ;EACc,CAAC;CACrE,SAAS,OAAO;EACf,QAAQ,OAAO,MACd,EAAE,KAAK,MAAM,GACb,8DACD;CACD;CACA,MAAM,UAAU,QAAQ,WAAW;CAEnC,OAGC,qBAAC,QAAD;EACC,OAAO;GACN,YAAY;GACZ,SAAS;GACT,KAAK;GACL,eAAe;EAChB;YAND,CAQE,WAAW;GACX,UAAU,QAAQ,OAAO,OAAO;GAChC,MAAM;GACN,OAAO,SAAS;GAChB,WAAW,QAAQ,OAAO;EAC3B,CAAC,GACD,oBAAC,QAAD,EAAA,UAAO,WAAW,QAAQ,KAAK,SAAS,UAAU,EAAQ,CAAA,CACrD;;AAER"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ColorFormat, ColorGlobalConfig, ColorPreset, DecryptFailurePolicy, EncryptedGlobalConfig, FieldsPluginRegistry, FieldsResolverArgs, IconAdapter, IconCanvas, IconGlobalConfig, IconLayer, IconLayerCache, IconLayerContext, IconManifest, IconMeta, IconRenderStrategy, KeysConfig, MeasurementDefaultUnitsResolver, MeasurementGlobalConfig, PhoneNumberGlobalConfig } from "./types.js";
2
2
  import { TranslationsOption } from "./translations/index.js";
3
+ import { withCompanionSelect } from "./plugin/companionSelect.js";
3
4
  import { getFieldsRegistry } from "./plugin/registry.js";
4
5
 
5
6
  //#region src/index.d.ts
@@ -28,7 +29,7 @@ declare module 'payload' {
28
29
  }
29
30
  }
30
31
  /**
31
- * Fields plugin for Payload v3. Registers translations and writes global field
32
+ * Fields plugin for Payload. Registers translations and writes global field
32
33
  * defaults to `config.custom['@10x-media/fields']` for factories, hooks, and
33
34
  * server components to read at runtime via `getFieldsRegistry`. Every field
34
35
  * factory also works without this plugin; per-field options always override
@@ -37,5 +38,5 @@ declare module 'payload' {
37
38
  */
38
39
  declare const fields: (options: FieldsPluginOptions) => import("payload").Plugin;
39
40
  //#endregion
40
- export { type ColorFormat, type ColorGlobalConfig, type ColorPreset, type DecryptFailurePolicy, type EncryptedGlobalConfig, FieldsPluginOptions, type FieldsPluginOptions as PluginOptions, type FieldsPluginRegistry, type FieldsResolverArgs, type IconAdapter, type IconCanvas, type IconGlobalConfig, type IconLayer, type IconLayerCache, type IconLayerContext, type IconManifest, type IconMeta, type IconRenderStrategy, type KeysConfig, type MeasurementDefaultUnitsResolver, type MeasurementGlobalConfig, type PhoneNumberGlobalConfig, fields, getFieldsRegistry };
41
+ export { type ColorFormat, type ColorGlobalConfig, type ColorPreset, type DecryptFailurePolicy, type EncryptedGlobalConfig, FieldsPluginOptions, type FieldsPluginOptions as PluginOptions, type FieldsPluginRegistry, type FieldsResolverArgs, type IconAdapter, type IconCanvas, type IconGlobalConfig, type IconLayer, type IconLayerCache, type IconLayerContext, type IconManifest, type IconMeta, type IconRenderStrategy, type KeysConfig, type MeasurementDefaultUnitsResolver, type MeasurementGlobalConfig, type PhoneNumberGlobalConfig, fields, getFieldsRegistry, withCompanionSelect };
41
42
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { validateEncryptedBoot } from "./fields/encrypted/boot.js";
2
+ import { withCompanionSelect } from "./plugin/companionSelect.js";
2
3
  import { getFieldsRegistry, setFieldsRegistry } from "./plugin/registry.js";
3
4
  import { withEncryptedQueryRewrite, withEncryptedResponseStrip } from "./fields/encrypted/queryRewrite.js";
4
5
  import { registerIcon } from "./fields/icon/plugin.js";
@@ -33,7 +34,7 @@ const normalizeRegistry = (options) => {
33
34
  return registry;
34
35
  };
35
36
  /**
36
- * Fields plugin for Payload v3. Registers translations and writes global field
37
+ * Fields plugin for Payload. Registers translations and writes global field
37
38
  * defaults to `config.custom['@10x-media/fields']` for factories, hooks, and
38
39
  * server components to read at runtime via `getFieldsRegistry`. Every field
39
40
  * factory also works without this plugin; per-field options always override
@@ -42,7 +43,7 @@ const normalizeRegistry = (options) => {
42
43
  */
43
44
  const fields = definePlugin({
44
45
  slug: "@10x-media/fields",
45
- plugin: ({ config, plugins: _plugins, ...options }) => {
46
+ plugin: ({ config, options = {} }) => {
46
47
  if (options.disabled === true) return config;
47
48
  registerTranslations(config, options.translations);
48
49
  setFieldsRegistry(config, normalizeRegistry(options));
@@ -59,7 +60,7 @@ const fields = definePlugin({
59
60
  method: "get",
60
61
  path: FLAGS_ENDPOINT_PATH
61
62
  }];
62
- config.collections = (config.collections ?? []).map(withEncryptedQueryRewrite);
63
+ config.collections = (config.collections ?? []).map((collection) => withCompanionSelect(withEncryptedQueryRewrite(collection)));
63
64
  config.globals = (config.globals ?? []).map(withEncryptedResponseStrip);
64
65
  const priorOnInit = config.onInit;
65
66
  config.onInit = async (payload) => {
@@ -70,6 +71,6 @@ const fields = definePlugin({
70
71
  }
71
72
  });
72
73
  //#endregion
73
- export { fields, getFieldsRegistry };
74
+ export { fields, getFieldsRegistry, withCompanionSelect };
74
75
 
75
76
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin } from 'payload'\n\nimport { validateEncryptedBoot } from './fields/encrypted/boot'\nimport {\n\twithEncryptedQueryRewrite,\n\twithEncryptedResponseStrip,\n} from './fields/encrypted/queryRewrite'\nimport { registerIcon } from './fields/icon/plugin'\nimport { resolvePrecision } from './fields/measurement/engine/precision'\nimport { isKnownCountry } from './fields/phoneNumber/engine/countries'\nimport { isMetadataSet } from './fields/phoneNumber/engine/metadata'\nimport { FLAGS_ENDPOINT_PATH, makeFlagsHandler } from './fields/phoneNumber/server/flagsEndpoint'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { setFieldsRegistry } from './plugin/registry'\nimport type { TranslationsOption } from './translations'\nimport type {\n\tColorGlobalConfig,\n\tEncryptedGlobalConfig,\n\tFieldsPluginRegistry,\n\tIconGlobalConfig,\n\tMeasurementGlobalConfig,\n\tPhoneNumberGlobalConfig,\n} from './types'\n\nexport type FieldsPluginOptions = {\n\t/**\n\t * Disable the plugin entirely (incoming config returned untouched).\n\t * Useful for opting out per environment without removing the plugin call.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/fields/i18n`. Values win over\n\t * the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Global defaults for colorField(). Per-field options always win. */\n\tcolor?: ColorGlobalConfig\n\t/** Global defaults for iconField(). Per-field options always win. */\n\ticon?: IconGlobalConfig\n\t/** Global defaults for encryptedField(). Per-field options always win. */\n\tencrypted?: EncryptedGlobalConfig\n\t/** Global defaults for measurementField(). Per-field options always win. */\n\tmeasurement?: MeasurementGlobalConfig\n\t/** Global defaults for phoneNumberField(). Per-field options always win. */\n\tphoneNumber?: PhoneNumberGlobalConfig\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/fields': FieldsPluginOptions\n\t}\n}\n\nconst normalizeRegistry = (options: FieldsPluginOptions): FieldsPluginRegistry => {\n\tconst registry: FieldsPluginRegistry = {}\n\tif (options.color) {\n\t\tregistry.color = options.color\n\t}\n\t// registry.icon is owned solely by registerIcon, which validates adapter\n\t// slugs and the default library before writing the normalized slice.\n\tif (options.encrypted) {\n\t\tregistry.encrypted = options.encrypted\n\t}\n\tif (options.measurement) {\n\t\t// Fails fast at plugin build, before any field's beforeValidate hook can run\n\t\t// against it, instead of throwing on every write once the app is live.\n\t\tif (options.measurement.precision !== undefined) {\n\t\t\ttry {\n\t\t\t\tresolvePrecision([options.measurement.precision])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`fields plugin: measurement.precision is invalid: ${(error as Error).message}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tregistry.measurement = options.measurement\n\t}\n\tif (options.phoneNumber) {\n\t\tconst { countries, defaultCountry, metadata, validation } = options.phoneNumber\n\t\tfor (const code of countries ?? []) {\n\t\t\tif (!isKnownCountry(code)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`fields plugin: phoneNumber.countries entry \"${code}\" is not a supported country.`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (defaultCountry !== undefined && !isKnownCountry(defaultCountry)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.defaultCountry \"${defaultCountry}\" is not a supported country.`\n\t\t\t)\n\t\t}\n\t\tif (metadata !== undefined && !isMetadataSet(metadata)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.metadata \"${metadata}\" must be \"max\", \"min\", or \"mobile\".`\n\t\t\t)\n\t\t}\n\t\tif (validation === 'mobile' && metadata === 'min') {\n\t\t\tthrow new Error(\n\t\t\t\t\"fields plugin: phoneNumber.validation 'mobile' needs metadata 'max' or 'mobile'; 'min' carries no number types.\"\n\t\t\t)\n\t\t}\n\t\tif (defaultCountry && countries && !countries.includes(defaultCountry)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.defaultCountry \"${defaultCountry}\" is not in phoneNumber.countries.`\n\t\t\t)\n\t\t}\n\t\tregistry.phoneNumber = options.phoneNumber\n\t}\n\treturn registry\n}\n\n/**\n * Fields plugin for Payload v3. Registers translations and writes global field\n * defaults to `config.custom['@10x-media/fields']` for factories, hooks, and\n * server components to read at runtime via `getFieldsRegistry`. Every field\n * factory also works without this plugin; per-field options always override\n * these defaults. Authored with `definePlugin` so sibling plugins can detect\n * it by slug.\n */\nexport const fields = definePlugin<FieldsPluginOptions>({\n\tslug: '@10x-media/fields',\n\tplugin: ({ config, plugins: _plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tsetFieldsRegistry(config, normalizeRegistry(options))\n\t\t// Sole owner of registry.icon: validates adapters + default library and\n\t\t// registers their client components in admin.dependencies. A no-op when no\n\t\t// adapters are configured, leaving registry.icon unset.\n\t\tregisterIcon(config, options.icon)\n\t\tconfig.admin = config.admin ?? {}\n\t\tconfig.admin.components = config.admin.components ?? {}\n\t\tconfig.admin.components.providers = config.admin.components.providers ?? []\n\t\tconfig.admin.components.providers.push({\n\t\t\tclientProps: { persist: options.measurement?.persistPreferences !== false },\n\t\t\tpath: '@10x-media/fields/client#MeasurementUnitsProvider',\n\t\t})\n\t\t// Gated on serveFlags, not the resolved `flags` value: flags is per-field and\n\t\t// unknown until fields exist, so a field overriding to 'svg' would break under a gated install.\n\t\tif (options.phoneNumber?.serveFlags !== false) {\n\t\t\tconfig.endpoints = [\n\t\t\t\t...(config.endpoints ?? []),\n\t\t\t\t{ handler: makeFlagsHandler(), method: 'get', path: FLAGS_ENDPOINT_PATH },\n\t\t\t]\n\t\t}\n\t\t// Transparently rewrite equals/in on queryable encrypted fields to their\n\t\t// blind-index siblings; a no-op for collections that have none. Globals\n\t\t// take no where, so they get the response strip alone.\n\t\tconfig.collections = (config.collections ?? []).map(withEncryptedQueryRewrite)\n\t\tconfig.globals = (config.globals ?? []).map(withEncryptedResponseStrip)\n\t\t// Validate encrypted key material at boot, before any prior onInit runs, so\n\t\t// missing secrets or broken providers fail fast instead of on first write.\n\t\tconst priorOnInit = config.onInit\n\t\tconfig.onInit = async (payload) => {\n\t\t\tawait validateEncryptedBoot(payload, options.encrypted?.keys)\n\t\t\tawait priorOnInit?.(payload)\n\t\t}\n\t\treturn config\n\t},\n})\n\nexport { getFieldsRegistry } from './plugin/registry'\nexport type {\n\tColorFormat,\n\tColorGlobalConfig,\n\tColorPreset,\n\tDecryptFailurePolicy,\n\tEncryptedGlobalConfig,\n\tFieldsPluginRegistry,\n\tFieldsResolverArgs,\n\tIconAdapter,\n\tIconCanvas,\n\tIconGlobalConfig,\n\tIconLayer,\n\tIconLayerCache,\n\tIconLayerContext,\n\tIconManifest,\n\tIconMeta,\n\tIconRenderStrategy,\n\tKeysConfig,\n\tMeasurementDefaultUnitsResolver,\n\tMeasurementGlobalConfig,\n\tPhoneNumberGlobalConfig,\n} from './types'\nexport type { FieldsPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;AAuDA,MAAM,qBAAqB,YAAuD;CACjF,MAAM,WAAiC,CAAC;CACxC,IAAI,QAAQ,OACX,SAAS,QAAQ,QAAQ;CAI1B,IAAI,QAAQ,WACX,SAAS,YAAY,QAAQ;CAE9B,IAAI,QAAQ,aAAa;EAGxB,IAAI,QAAQ,YAAY,cAAc,KAAA,GACrC,IAAI;GACH,iBAAiB,CAAC,QAAQ,YAAY,SAAS,CAAC;EACjD,SAAS,OAAO;GACf,MAAM,IAAI,MACT,oDAAqD,MAAgB,SACtE;EACD;EAED,SAAS,cAAc,QAAQ;CAChC;CACA,IAAI,QAAQ,aAAa;EACxB,MAAM,EAAE,WAAW,gBAAgB,UAAU,eAAe,QAAQ;EACpE,KAAK,MAAM,QAAQ,aAAa,CAAC,GAChC,IAAI,CAAC,eAAe,IAAI,GACvB,MAAM,IAAI,MACT,+CAA+C,KAAK,8BACrD;EAGF,IAAI,mBAAmB,KAAA,KAAa,CAAC,eAAe,cAAc,GACjE,MAAM,IAAI,MACT,8CAA8C,eAAe,8BAC9D;EAED,IAAI,aAAa,KAAA,KAAa,CAAC,cAAc,QAAQ,GACpD,MAAM,IAAI,MACT,wCAAwC,SAAS,qCAClD;EAED,IAAI,eAAe,YAAY,aAAa,OAC3C,MAAM,IAAI,MACT,iHACD;EAED,IAAI,kBAAkB,aAAa,CAAC,UAAU,SAAS,cAAc,GACpE,MAAM,IAAI,MACT,8CAA8C,eAAe,mCAC9D;EAED,SAAS,cAAc,QAAQ;CAChC;CACA,OAAO;AACR;;;;;;;;;AAUA,MAAa,SAAS,aAAkC;CACvD,MAAM;CACN,SAAS,EAAE,QAAQ,SAAS,UAAU,GAAG,cAAsB;EAC9D,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,kBAAkB,QAAQ,kBAAkB,OAAO,CAAC;EAIpD,aAAa,QAAQ,QAAQ,IAAI;EACjC,OAAO,QAAQ,OAAO,SAAS,CAAC;EAChC,OAAO,MAAM,aAAa,OAAO,MAAM,cAAc,CAAC;EACtD,OAAO,MAAM,WAAW,YAAY,OAAO,MAAM,WAAW,aAAa,CAAC;EAC1E,OAAO,MAAM,WAAW,UAAU,KAAK;GACtC,aAAa,EAAE,SAAS,QAAQ,aAAa,uBAAuB,MAAM;GAC1E,MAAM;EACP,CAAC;EAGD,IAAI,QAAQ,aAAa,eAAe,OACvC,OAAO,YAAY,CAClB,GAAI,OAAO,aAAa,CAAC,GACzB;GAAE,SAAS,iBAAiB;GAAG,QAAQ;GAAO,MAAM;EAAoB,CACzE;EAKD,OAAO,eAAe,OAAO,eAAe,CAAC,GAAG,IAAI,yBAAyB;EAC7E,OAAO,WAAW,OAAO,WAAW,CAAC,GAAG,IAAI,0BAA0B;EAGtE,MAAM,cAAc,OAAO;EAC3B,OAAO,SAAS,OAAO,YAAY;GAClC,MAAM,sBAAsB,SAAS,QAAQ,WAAW,IAAI;GAC5D,MAAM,cAAc,OAAO;EAC5B;EACA,OAAO;CACR;AACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin } from 'payload'\n\nimport { validateEncryptedBoot } from './fields/encrypted/boot'\nimport {\n\twithEncryptedQueryRewrite,\n\twithEncryptedResponseStrip,\n} from './fields/encrypted/queryRewrite'\nimport { registerIcon } from './fields/icon/plugin'\nimport { resolvePrecision } from './fields/measurement/engine/precision'\nimport { isKnownCountry } from './fields/phoneNumber/engine/countries'\nimport { isMetadataSet } from './fields/phoneNumber/engine/metadata'\nimport { FLAGS_ENDPOINT_PATH, makeFlagsHandler } from './fields/phoneNumber/server/flagsEndpoint'\nimport { withCompanionSelect } from './plugin/companionSelect'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { setFieldsRegistry } from './plugin/registry'\nimport type { TranslationsOption } from './translations'\nimport type {\n\tColorGlobalConfig,\n\tEncryptedGlobalConfig,\n\tFieldsPluginRegistry,\n\tIconGlobalConfig,\n\tMeasurementGlobalConfig,\n\tPhoneNumberGlobalConfig,\n} from './types'\n\nexport type FieldsPluginOptions = {\n\t/**\n\t * Disable the plugin entirely (incoming config returned untouched).\n\t * Useful for opting out per environment without removing the plugin call.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/fields/i18n`. Values win over\n\t * the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Global defaults for colorField(). Per-field options always win. */\n\tcolor?: ColorGlobalConfig\n\t/** Global defaults for iconField(). Per-field options always win. */\n\ticon?: IconGlobalConfig\n\t/** Global defaults for encryptedField(). Per-field options always win. */\n\tencrypted?: EncryptedGlobalConfig\n\t/** Global defaults for measurementField(). Per-field options always win. */\n\tmeasurement?: MeasurementGlobalConfig\n\t/** Global defaults for phoneNumberField(). Per-field options always win. */\n\tphoneNumber?: PhoneNumberGlobalConfig\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/fields': FieldsPluginOptions\n\t}\n}\n\nconst normalizeRegistry = (options: FieldsPluginOptions): FieldsPluginRegistry => {\n\tconst registry: FieldsPluginRegistry = {}\n\tif (options.color) {\n\t\tregistry.color = options.color\n\t}\n\t// registry.icon is owned solely by registerIcon, which validates adapter\n\t// slugs and the default library before writing the normalized slice.\n\tif (options.encrypted) {\n\t\tregistry.encrypted = options.encrypted\n\t}\n\tif (options.measurement) {\n\t\t// Fails fast at plugin build, before any field's beforeValidate hook can run\n\t\t// against it, instead of throwing on every write once the app is live.\n\t\tif (options.measurement.precision !== undefined) {\n\t\t\ttry {\n\t\t\t\tresolvePrecision([options.measurement.precision])\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`fields plugin: measurement.precision is invalid: ${(error as Error).message}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tregistry.measurement = options.measurement\n\t}\n\tif (options.phoneNumber) {\n\t\tconst { countries, defaultCountry, metadata, validation } = options.phoneNumber\n\t\tfor (const code of countries ?? []) {\n\t\t\tif (!isKnownCountry(code)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`fields plugin: phoneNumber.countries entry \"${code}\" is not a supported country.`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (defaultCountry !== undefined && !isKnownCountry(defaultCountry)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.defaultCountry \"${defaultCountry}\" is not a supported country.`\n\t\t\t)\n\t\t}\n\t\tif (metadata !== undefined && !isMetadataSet(metadata)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.metadata \"${metadata}\" must be \"max\", \"min\", or \"mobile\".`\n\t\t\t)\n\t\t}\n\t\tif (validation === 'mobile' && metadata === 'min') {\n\t\t\tthrow new Error(\n\t\t\t\t\"fields plugin: phoneNumber.validation 'mobile' needs metadata 'max' or 'mobile'; 'min' carries no number types.\"\n\t\t\t)\n\t\t}\n\t\tif (defaultCountry && countries && !countries.includes(defaultCountry)) {\n\t\t\tthrow new Error(\n\t\t\t\t`fields plugin: phoneNumber.defaultCountry \"${defaultCountry}\" is not in phoneNumber.countries.`\n\t\t\t)\n\t\t}\n\t\tregistry.phoneNumber = options.phoneNumber\n\t}\n\treturn registry\n}\n\n/**\n * Fields plugin for Payload. Registers translations and writes global field\n * defaults to `config.custom['@10x-media/fields']` for factories, hooks, and\n * server components to read at runtime via `getFieldsRegistry`. Every field\n * factory also works without this plugin; per-field options always override\n * these defaults. Authored with `definePlugin` so sibling plugins can detect\n * it by slug.\n */\nexport const fields = definePlugin<FieldsPluginOptions>({\n\tslug: '@10x-media/fields',\n\t// Payload passes `options` as undefined when the plugin is registered without any.\n\tplugin: ({ config, options = {} }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tsetFieldsRegistry(config, normalizeRegistry(options))\n\t\t// Sole owner of registry.icon: validates adapters + default library and\n\t\t// registers their client components in admin.dependencies. A no-op when no\n\t\t// adapters are configured, leaving registry.icon unset.\n\t\tregisterIcon(config, options.icon)\n\t\tconfig.admin = config.admin ?? {}\n\t\tconfig.admin.components = config.admin.components ?? {}\n\t\tconfig.admin.components.providers = config.admin.components.providers ?? []\n\t\tconfig.admin.components.providers.push({\n\t\t\tclientProps: { persist: options.measurement?.persistPreferences !== false },\n\t\t\tpath: '@10x-media/fields/client#MeasurementUnitsProvider',\n\t\t})\n\t\t// Gated on serveFlags, not the resolved `flags` value: flags is per-field and\n\t\t// unknown until fields exist, so a field overriding to 'svg' would break under a gated install.\n\t\tif (options.phoneNumber?.serveFlags !== false) {\n\t\t\tconfig.endpoints = [\n\t\t\t\t...(config.endpoints ?? []),\n\t\t\t\t{ handler: makeFlagsHandler(), method: 'get', path: FLAGS_ENDPOINT_PATH },\n\t\t\t]\n\t\t}\n\t\t// Transparently rewrite equals/in on queryable encrypted fields to their\n\t\t// blind-index siblings; a no-op for collections that have none. Globals\n\t\t// take no where, so they get the response strip alone.\n\t\tconfig.collections = (config.collections ?? []).map((collection) =>\n\t\t\twithCompanionSelect(withEncryptedQueryRewrite(collection))\n\t\t)\n\t\tconfig.globals = (config.globals ?? []).map(withEncryptedResponseStrip)\n\t\t// Validate encrypted key material at boot, before any prior onInit runs, so\n\t\t// missing secrets or broken providers fail fast instead of on first write.\n\t\tconst priorOnInit = config.onInit\n\t\tconfig.onInit = async (payload) => {\n\t\t\tawait validateEncryptedBoot(payload, options.encrypted?.keys)\n\t\t\tawait priorOnInit?.(payload)\n\t\t}\n\t\treturn config\n\t},\n})\n\nexport { withCompanionSelect } from './plugin/companionSelect'\nexport { getFieldsRegistry } from './plugin/registry'\nexport type {\n\tColorFormat,\n\tColorGlobalConfig,\n\tColorPreset,\n\tDecryptFailurePolicy,\n\tEncryptedGlobalConfig,\n\tFieldsPluginRegistry,\n\tFieldsResolverArgs,\n\tIconAdapter,\n\tIconCanvas,\n\tIconGlobalConfig,\n\tIconLayer,\n\tIconLayerCache,\n\tIconLayerContext,\n\tIconManifest,\n\tIconMeta,\n\tIconRenderStrategy,\n\tKeysConfig,\n\tMeasurementDefaultUnitsResolver,\n\tMeasurementGlobalConfig,\n\tPhoneNumberGlobalConfig,\n} from './types'\nexport type { FieldsPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;AAwDA,MAAM,qBAAqB,YAAuD;CACjF,MAAM,WAAiC,CAAC;CACxC,IAAI,QAAQ,OACX,SAAS,QAAQ,QAAQ;CAI1B,IAAI,QAAQ,WACX,SAAS,YAAY,QAAQ;CAE9B,IAAI,QAAQ,aAAa;EAGxB,IAAI,QAAQ,YAAY,cAAc,KAAA,GACrC,IAAI;GACH,iBAAiB,CAAC,QAAQ,YAAY,SAAS,CAAC;EACjD,SAAS,OAAO;GACf,MAAM,IAAI,MACT,oDAAqD,MAAgB,SACtE;EACD;EAED,SAAS,cAAc,QAAQ;CAChC;CACA,IAAI,QAAQ,aAAa;EACxB,MAAM,EAAE,WAAW,gBAAgB,UAAU,eAAe,QAAQ;EACpE,KAAK,MAAM,QAAQ,aAAa,CAAC,GAChC,IAAI,CAAC,eAAe,IAAI,GACvB,MAAM,IAAI,MACT,+CAA+C,KAAK,8BACrD;EAGF,IAAI,mBAAmB,KAAA,KAAa,CAAC,eAAe,cAAc,GACjE,MAAM,IAAI,MACT,8CAA8C,eAAe,8BAC9D;EAED,IAAI,aAAa,KAAA,KAAa,CAAC,cAAc,QAAQ,GACpD,MAAM,IAAI,MACT,wCAAwC,SAAS,qCACl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ts
4
+ /**
5
+ * Selects the companions marked with `withCompanions` whenever their field is selected. The
6
+ * fields() plugin applies this to every collection; call it directly only when using the field
7
+ * factories without the plugin.
8
+ */
9
+ declare const withCompanionSelect: (collection: CollectionConfig) => CollectionConfig;
10
+ //#endregion
11
+ export { withCompanionSelect };
12
+ //# sourceMappingURL=companionSelect.d.ts.map