@10x-media/fields 0.1.0-beta.6 → 0.1.0-beta.8

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 (151) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -21
  3. package/README.md +3 -1
  4. package/dist/exports/client.d.ts +7 -1
  5. package/dist/exports/client.js +7 -1
  6. package/dist/exports/measurement-utils.d.ts +9 -0
  7. package/dist/exports/measurement-utils.js +8 -0
  8. package/dist/exports/measurement.d.ts +11 -0
  9. package/dist/exports/measurement.js +10 -0
  10. package/dist/exports/phone-utils.d.ts +4 -0
  11. package/dist/exports/phone-utils.js +4 -0
  12. package/dist/exports/phone.d.ts +6 -0
  13. package/dist/exports/phone.js +3 -0
  14. package/dist/exports/rsc.d.ts +5 -1
  15. package/dist/exports/rsc.js +5 -1
  16. package/dist/exports/types.d.ts +3 -2
  17. package/dist/fields/icon/client/icon-field.css +4 -2
  18. package/dist/fields/icon/rsc/IconFieldServer.js +1 -1
  19. package/dist/fields/icon/rsc/IconFieldServer.js.map +1 -1
  20. package/dist/fields/icon/rsc/IconLibrarySelectServer.js +1 -1
  21. package/dist/fields/icon/rsc/IconLibrarySelectServer.js.map +1 -1
  22. package/dist/fields/icon/shared/iconLabel.js +1 -1
  23. package/dist/fields/icon/shared/iconLabel.js.map +1 -1
  24. package/dist/fields/measurement/client/MeasurementCell.d.ts +18 -0
  25. package/dist/fields/measurement/client/MeasurementCell.js +47 -0
  26. package/dist/fields/measurement/client/MeasurementCell.js.map +1 -0
  27. package/dist/fields/measurement/client/MeasurementField.d.ts +11 -0
  28. package/dist/fields/measurement/client/MeasurementField.js +386 -0
  29. package/dist/fields/measurement/client/MeasurementField.js.map +1 -0
  30. package/dist/fields/measurement/client/MeasurementUnitsProvider.d.ts +24 -0
  31. package/dist/fields/measurement/client/MeasurementUnitsProvider.js +61 -0
  32. package/dist/fields/measurement/client/MeasurementUnitsProvider.js.map +1 -0
  33. package/dist/fields/measurement/client/editModel.js +115 -0
  34. package/dist/fields/measurement/client/editModel.js.map +1 -0
  35. package/dist/fields/measurement/client/measurementCell.css +4 -0
  36. package/dist/fields/measurement/client/measurementField.css +215 -0
  37. package/dist/fields/measurement/engine/convert.d.ts +8 -0
  38. package/dist/fields/measurement/engine/convert.js +21 -0
  39. package/dist/fields/measurement/engine/convert.js.map +1 -0
  40. package/dist/fields/measurement/engine/format.d.ts +37 -0
  41. package/dist/fields/measurement/engine/format.js +156 -0
  42. package/dist/fields/measurement/engine/format.js.map +1 -0
  43. package/dist/fields/measurement/engine/locale.d.ts +25 -0
  44. package/dist/fields/measurement/engine/locale.js +79 -0
  45. package/dist/fields/measurement/engine/locale.js.map +1 -0
  46. package/dist/fields/measurement/engine/precision.d.ts +34 -0
  47. package/dist/fields/measurement/engine/precision.js +63 -0
  48. package/dist/fields/measurement/engine/precision.js.map +1 -0
  49. package/dist/fields/measurement/engine/registry.d.ts +55 -0
  50. package/dist/fields/measurement/engine/registry.js +117 -0
  51. package/dist/fields/measurement/engine/registry.js.map +1 -0
  52. package/dist/fields/measurement/engine/units.d.ts +178 -0
  53. package/dist/fields/measurement/engine/units.js +198 -0
  54. package/dist/fields/measurement/engine/units.js.map +1 -0
  55. package/dist/fields/measurement/measurementField.d.ts +17 -0
  56. package/dist/fields/measurement/measurementField.js +139 -0
  57. package/dist/fields/measurement/measurementField.js.map +1 -0
  58. package/dist/fields/measurement/options.d.ts +76 -0
  59. package/dist/fields/measurement/options.js +9 -0
  60. package/dist/fields/measurement/options.js.map +1 -0
  61. package/dist/fields/measurement/presets.d.ts +117 -0
  62. package/dist/fields/measurement/presets.js +136 -0
  63. package/dist/fields/measurement/presets.js.map +1 -0
  64. package/dist/fields/measurement/server/MeasurementCellServer.d.ts +21 -0
  65. package/dist/fields/measurement/server/MeasurementCellServer.js +53 -0
  66. package/dist/fields/measurement/server/MeasurementCellServer.js.map +1 -0
  67. package/dist/fields/measurement/server/MeasurementFieldServer.d.ts +16 -0
  68. package/dist/fields/measurement/server/MeasurementFieldServer.js +45 -0
  69. package/dist/fields/measurement/server/MeasurementFieldServer.js.map +1 -0
  70. package/dist/fields/measurement/server/getUserUnits.js +39 -0
  71. package/dist/fields/measurement/server/getUserUnits.js.map +1 -0
  72. package/dist/fields/measurement/server/resolvePrecisionSafe.js +24 -0
  73. package/dist/fields/measurement/server/resolvePrecisionSafe.js.map +1 -0
  74. package/dist/fields/measurement/server/resolveRegistryDefault.js +26 -0
  75. package/dist/fields/measurement/server/resolveRegistryDefault.js.map +1 -0
  76. package/dist/fields/phoneNumber/client/CountryFlag.d.ts +16 -0
  77. package/dist/fields/phoneNumber/client/CountryFlag.js +40 -0
  78. package/dist/fields/phoneNumber/client/CountryFlag.js.map +1 -0
  79. package/dist/fields/phoneNumber/client/CountryPicker.d.ts +21 -0
  80. package/dist/fields/phoneNumber/client/CountryPicker.js +255 -0
  81. package/dist/fields/phoneNumber/client/CountryPicker.js.map +1 -0
  82. package/dist/fields/phoneNumber/client/PhoneNumberField.d.ts +26 -0
  83. package/dist/fields/phoneNumber/client/PhoneNumberField.js +318 -0
  84. package/dist/fields/phoneNumber/client/PhoneNumberField.js.map +1 -0
  85. package/dist/fields/phoneNumber/client/editModel.js +86 -0
  86. package/dist/fields/phoneNumber/client/editModel.js.map +1 -0
  87. package/dist/fields/phoneNumber/client/phoneNumberField.css +305 -0
  88. package/dist/fields/phoneNumber/engine/countries.d.ts +36 -0
  89. package/dist/fields/phoneNumber/engine/countries.js +68 -0
  90. package/dist/fields/phoneNumber/engine/countries.js.map +1 -0
  91. package/dist/fields/phoneNumber/engine/draft.d.ts +13 -0
  92. package/dist/fields/phoneNumber/engine/draft.js +72 -0
  93. package/dist/fields/phoneNumber/engine/draft.js.map +1 -0
  94. package/dist/fields/phoneNumber/engine/metadata.d.ts +11 -0
  95. package/dist/fields/phoneNumber/engine/metadata.js +32 -0
  96. package/dist/fields/phoneNumber/engine/metadata.js.map +1 -0
  97. package/dist/fields/phoneNumber/engine/phone.d.ts +37 -0
  98. package/dist/fields/phoneNumber/engine/phone.js +59 -0
  99. package/dist/fields/phoneNumber/engine/phone.js.map +1 -0
  100. package/dist/fields/phoneNumber/options.d.ts +72 -0
  101. package/dist/fields/phoneNumber/options.js +37 -0
  102. package/dist/fields/phoneNumber/options.js.map +1 -0
  103. package/dist/fields/phoneNumber/phoneNumberField.d.ts +14 -0
  104. package/dist/fields/phoneNumber/phoneNumberField.js +167 -0
  105. package/dist/fields/phoneNumber/phoneNumberField.js.map +1 -0
  106. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.d.ts +19 -0
  107. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js +73 -0
  108. package/dist/fields/phoneNumber/server/PhoneNumberCellServer.js.map +1 -0
  109. package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.d.ts +16 -0
  110. package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.js +57 -0
  111. package/dist/fields/phoneNumber/server/PhoneNumberFieldServer.js.map +1 -0
  112. package/dist/fields/phoneNumber/server/flagsEndpoint.js +51 -0
  113. package/dist/fields/phoneNumber/server/flagsEndpoint.js.map +1 -0
  114. package/dist/fields/phoneNumber/server/readPhoneOptions.js +18 -0
  115. package/dist/fields/phoneNumber/server/readPhoneOptions.js.map +1 -0
  116. package/dist/fields/phoneNumber/server/resolvePhoneOptionsSafe.js +33 -0
  117. package/dist/fields/phoneNumber/server/resolvePhoneOptionsSafe.js.map +1 -0
  118. package/dist/index.d.ts +5 -3
  119. package/dist/index.js +33 -0
  120. package/dist/index.js.map +1 -1
  121. package/dist/translations/ar.js +12 -1
  122. package/dist/translations/ar.js.map +1 -1
  123. package/dist/translations/de.js +12 -1
  124. package/dist/translations/de.js.map +1 -1
  125. package/dist/translations/en.js +12 -1
  126. package/dist/translations/en.js.map +1 -1
  127. package/dist/translations/es.js +12 -1
  128. package/dist/translations/es.js.map +1 -1
  129. package/dist/translations/fr.js +12 -1
  130. package/dist/translations/fr.js.map +1 -1
  131. package/dist/translations/id.js +12 -1
  132. package/dist/translations/id.js.map +1 -1
  133. package/dist/translations/keys.d.ts +11 -0
  134. package/dist/translations/keys.js +12 -1
  135. package/dist/translations/keys.js.map +1 -1
  136. package/dist/translations/ko.js +12 -1
  137. package/dist/translations/ko.js.map +1 -1
  138. package/dist/translations/pt.js +12 -1
  139. package/dist/translations/pt.js.map +1 -1
  140. package/dist/translations/ru.js +12 -1
  141. package/dist/translations/ru.js.map +1 -1
  142. package/dist/translations/uk.js +12 -1
  143. package/dist/translations/uk.js.map +1 -1
  144. package/dist/translations/zh.js +12 -1
  145. package/dist/translations/zh.js.map +1 -1
  146. package/dist/types.d.ts +41 -1
  147. package/dist/utils/resolveStaticLabel.js +13 -0
  148. package/dist/utils/resolveStaticLabel.js.map +1 -0
  149. package/package.json +27 -5
  150. package/dist/fields/icon/shared/resolveStaticLabel.js +0 -16
  151. package/dist/fields/icon/shared/resolveStaticLabel.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @10x-media/fields
2
2
 
3
+ ## 0.1.0-beta.8
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `phoneNumberField()`: an international phone number field with a searchable country picker, live as-you-type formatting, and validation and metadata sized to the install via `libphonenumber-js`.
8
+
9
+ - Two storage shapes: `storage: 'object'` (default) is a `group` of `number` + `country`, plus five `virtual: true` subfields (`national`, `international`, `callingCode`, `uri`, `type`) recomputed on every read by a single `afterRead` hook; `storage: 'e164'` is a plain `text` field holding the E.164 string alone. Virtual subfields can't be queried or sorted; filter and sort on `number` or `country` instead.
10
+ - Three validation modes (`'possible'`, `'valid'`, `'mobile'`) and three metadata sets (`'max'`, `'min'`, `'mobile'`) trading bundle size for classification detail. `validation: 'mobile'` needs metadata `'max'` or `'mobile'`; pairing it with `'min'` is rejected as a configuration error rather than silently failing every number, at plugin build time when set on the plugin and at validation time when set on a field.
11
+ - Country handling: `countries` scopes the picker without restricting what parses, validates, and saves; `priorityCountries` pins a subset above the alphabetized rest, optionally headed by `priorityCountriesLabel` (a string or per-locale map; no label means no heading, only the picker's own group divider); `defaultCountry` seeds the picker and calling-code prefix.
12
+ - Flag artwork: `flags: 'svg'` (default) serves real country flags from a new, unauthenticated `/10x-fields/flags/:code` endpoint; `'emoji'` draws a Unicode regional-indicator pair instead (renders as two separate letters on Windows, which ships no flag emoji font); `'none'` shows the ISO code. `fields({ phoneNumber: { serveFlags: false } })` skips mounting the endpoint. `@10x-media/fields/phone` exports `countryFlagSrc(serverURL, apiRoute, code)` so a frontend can build the same URL without hand-rolling its lowercasing and `.svg` suffix.
13
+ - `fields({ phoneNumber: {...} })` sets install-wide defaults (`defaultCountry`, `countries`, `priorityCountries`, `priorityCountriesLabel`, `validation`, `flags`, `cellFormat`, `metadata`, `serveFlags`); a field's own option always wins.
14
+ - `@10x-media/fields/phone/utils` exports the parsing, formatting, and validation engine standalone for frontend use (`parsePhone`, `formatPhone`, `phoneUri`, `detectCountry`, `salvagePhone`, `checkPhone`, `formatAsYouType`, `countryOptions`, `callingCodeFor`, `emojiFlag`, `isKnownCountry`, `isSupported`, `loadMetadata`).
15
+
16
+ Additive: new phone number field family; no changes to any existing field, option, export, or storage shape.
17
+
18
+ ## 0.1.0-beta.7
19
+
20
+ ### Minor Changes
21
+
22
+ - Add `measurementField()`: a number field storing a canonical value in one storage unit while each admin edits and reads in their own preferred unit. Eight presets ship built in (body weight, person height, distance, mass, length, volume, temperature, speed) as spreadable option bundles, or declare `storageUnit`/`units`/`preferenceKey` directly for anything else; units are constrained only by dimension, and generics narrow those options to the storage unit's dimension when it's a literal. Compound entry (feet and inches, stone and pounds) stays display-only.
23
+
24
+ - Display unit resolves per viewer: a payload-preferences pick keyed by `preferenceKey` (shipped presets keep their own bucket, free-form fields default to the storage unit's dimension) that follows the viewer across devices and flips every field sharing that key at once, then the field's own `fallbackUnit`, then the plugin's `fields({ measurement: { defaultUnits } })`, then the field's `localeDefaults`, then a per-dimension locale-default table (vendored CLDR data for US/Liberia and UK/Myanmar imperial units, metric everywhere else), then the field's first unit.
25
+ - Custom units and dimensions: serializable linear or affine unit definitions (`custom: { units, dimensions }`) travel with the field's client props, so a frontend can rebuild the same engine with `createEngine(custom)`. A unit with no `Intl.NumberFormat` identifier (`intlUnit: null`) formats as a plain decimal plus its short label.
26
+ - The editable input's round-trip behavior is controlled by `precision` (see below); readable mode's default draft policy repaints at display digits, exact mode's faithful draft policy shows the shortest string that round-trips to the exact stored value.
27
+ - The unit affordance is now the value's adjacent chip, doubling as the popup trigger, rather than a separate far-right badge.
28
+ - The stored value is a plain number column: native sort, filter, and group-by, and zero-migration adoption on an existing numeric column by matching `storageUnit` to what's already there.
29
+ - `min`/`max` are expressed in the storage unit and enforced by Payload's native number validation; the edit view shows bounds converted to the display unit.
30
+ - `@10x-media/fields/measurement/utils` exports the conversion and formatting engine (`convert`, `formatMeasurement`, `decompose`/`compose`, `resolveDisplayUnit`, `systemForLocale`, `createEngine`, `unitLabel`, `unitsOfDimension`, `UNITS`) standalone for frontend use.
31
+ - The list view's cell is now a server component too, so `fields({ measurement: { defaultUnits } })` reaches list cells the same way it reaches the edit view; `defaultUnits` also accepts a per-request resolver function for tenant-aware policy, called with `req` undefined from cells since Payload's cell components carry no request.
32
+ - `fields({ measurement: { persistPreferences: false } })` makes the unit preference provider session-only, for kiosk or shared-account admins: it skips both the read on mount and every write.
33
+
34
+ `precision` controls how a value round-trips between storage and the edit view, via two modes and four knobs. Pass a bare `'readable' | 'exact'`, or a `{ mode?, storage?, entry?, draft?, display? }` object to override individual knobs on top of a mode's defaults. `storage` (integer 0-12, default 6) is the fraction digits kept in the storage unit, applied to every write path including the REST and Local API; it is the same universal granularity contract regardless of mode, and can deliberately break entered-unit round-tripping while healing import noise. `entry` (`'quantize'` default in readable mode, `'free'` in exact mode) rounds a typed value at its own display digits, in the unit it was typed in, before converting. `draft` (`'display'` in readable, `'faithful'` in exact) controls whether a saved value repaints straight at display digits or escalates digits until it round-trips exactly. `display` is the per-unit fraction-digit map the field's old top-level `precision` option used to be, now nested here. A field's own `precision` wins over `fields({ measurement: { precision } })`, which wins over the engine default (`readable`, `storage: 6`); merging is per knob, and `display` merges per unit key. A dirty guard backs readable mode's WYSIWYG contract: only an input the viewer actually typed into ever commits its displayed value, so an untouched compound part, or a field re-rendered after a display-unit switch, always commits the exact value already on disk.
35
+
36
+ Additive: new measurement field family; no changes to existing families or stored data. Precision defaults (`readable`, `storage: 6`) reproduce this changeset's originally shipped behavior for every knob except two: the draft-repaint default, which now truncates to display digits instead of always showing a faithful full-precision draft, and the entry default, which now quantizes a typed value at its own display digits instead of always keeping it free; both are new in this same unreleased change, so nothing published has to migrate.
37
+
38
+ ### Patch Changes
39
+
40
+ - Fix icon drawer rail and footer text contrast to WCAG AA (elevation-600 to elevation-700). The drawer axe scan now waits for the grid to settle before analyzing, which is what surfaced the miss; the search test gains the same wait, removing a load-dependent flake.
41
+
42
+ Behavioral: the rail and footer text in the icon picker render one elevation step darker (lighter in dark mode). No API changes.
43
+
3
44
  ## 0.1.0-beta.6
4
45
 
5
46
  ### Minor Changes
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 10x Media GmbH
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 10x Media GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @10x-media/fields
4
4
 
5
- Reusable fields for Payload v3 that look and behave native: a full color picker in a constant-height row, a searchable icon picker over pluggable icon libraries, and encrypted fields with key rotation and opt-in exact-match querying. Built from `@payloadcms/ui` primitives on Payload design tokens, indistinguishable from Payload's own fields.
5
+ Reusable fields for Payload v3 that look and behave native: a full color picker in a constant-height row, a searchable icon picker over pluggable icon libraries, encrypted fields with key rotation and opt-in exact-match querying, and a unit-aware measurement field. Built from `@payloadcms/ui` primitives on Payload design tokens, indistinguishable from Payload's own fields.
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@10x-media/fields?style=flat-square)](https://www.npmjs.com/package/@10x-media/fields)
8
8
 
@@ -13,6 +13,7 @@ Part of the [@10x-media Payload plugins](https://github.com/10x-media/payload-pl
13
13
  - **Color field**: saturation/hue/alpha picker, eyedropper, preset palettes (static or resolved from your data), any CSS color as input, one configured stored format (`hex`/`rgb`/`hsl`/`oklch`), and an opt-in linked mode that stores preset references so palette changes propagate everywhere.
14
14
  - **Icon field**: drawer browser with search, category rail, and keyboard navigation; Lucide, Radix, and Tabler adapters first-party; `defineIconAdapter()` plus codegen for any other library; per-icon lazy loading so no icon dataset ever enters an eager bundle; client and RSC frontend renderers; library-supplied labels for sets keyed by code; and layered libraries composing a package with a Payload upload collection editors can add to, each layer declaring its own render strategy and caching.
15
15
  - **Encrypted fields**: AES-256-GCM with authenticated field binding, for twelve field types including `richText` and `point`; zero-config keys derived from `PAYLOAD_SECRET` or explicit multi-key config with async providers and online rotation; opt-in blind-index querying (`equals`/`in`/`unique`); masked admin UX with reveal toggle.
16
+ - **Measurement field**: a plain `number` column storing one canonical unit while each viewer edits and reads in their own preferred unit; eight ready-made presets (body weight, height, distance, mass, length, volume, temperature, speed) or free-form `storageUnit`/`units`/`preferenceKey` for anything else, plus serializable custom units and dimensions; per-bucket preference follows the viewer across devices, falls back through field and plugin defaults to browser-locale detection, then metric; compound entry for feet-and-inches and stone-and-pounds; zero-migration adoption on existing numeric columns.
16
17
  - **Native by construction**: 40px rows, Payload tokens, full `admin` prop contract, typed translations, function-form `overrides` on every factory.
17
18
  - **Isolated bundles**: each family behind its own subpath export, isolation asserted on the built output in CI.
18
19
  - **Plugin optional**: every factory works standalone; the `fields()` plugin adds app-wide defaults that per-field options override.
@@ -57,6 +58,7 @@ Full documentation at [docs.10xmedia.de](https://docs.10xmedia.de/fields):
57
58
  - [Icon field](https://docs.10xmedia.de/fields/icon)
58
59
  - [Encrypted fields](https://docs.10xmedia.de/fields/encrypted)
59
60
  - [Key management](https://docs.10xmedia.de/fields/encrypted/key-management)
61
+ - [Measurement field](https://docs.10xmedia.de/fields/measurement)
60
62
  - [Building your own](https://docs.10xmedia.de/fields/building-your-own)
61
63
 
62
64
  ## License
@@ -4,4 +4,10 @@ import { ProtectedField } from "../fields/encrypted/components/ProtectedField.js
4
4
  import { RichTextRevealGate } from "../fields/encrypted/components/RichTextRevealGate.js";
5
5
  import { IconField } from "../fields/icon/client/IconFieldClient.js";
6
6
  import { IconLibrarySelect } from "../fields/icon/client/IconLibrarySelect.js";
7
- export { ColorField, type ColorFieldProps, ColorPickerPanel, IconField, IconLibrarySelect, ProtectedField, RichTextRevealGate };
7
+ import { MeasurementCell, MeasurementCellProps } from "../fields/measurement/client/MeasurementCell.js";
8
+ import { MeasurementField, MeasurementFieldProps } from "../fields/measurement/client/MeasurementField.js";
9
+ import { MeasurementUnitsProvider, useMeasurementUnits } from "../fields/measurement/client/MeasurementUnitsProvider.js";
10
+ import { CountryFlag, CountryFlagProps } from "../fields/phoneNumber/client/CountryFlag.js";
11
+ import { CountryOptionGroups, CountryPicker, CountryPickerProps } from "../fields/phoneNumber/client/CountryPicker.js";
12
+ import { PhoneNumberField, PhoneNumberFieldProps } from "../fields/phoneNumber/client/PhoneNumberField.js";
13
+ export { ColorField, type ColorFieldProps, ColorPickerPanel, CountryFlag, type CountryFlagProps, type CountryOptionGroups, CountryPicker, type CountryPickerProps, IconField, IconLibrarySelect, MeasurementCell, type MeasurementCellProps, MeasurementField, type MeasurementFieldProps, MeasurementUnitsProvider, PhoneNumberField, type PhoneNumberFieldProps, ProtectedField, RichTextRevealGate, useMeasurementUnits };
@@ -5,4 +5,10 @@ import { ProtectedField } from "../fields/encrypted/components/ProtectedField.js
5
5
  import { RichTextRevealGate } from "../fields/encrypted/components/RichTextRevealGate.js";
6
6
  import { IconField } from "../fields/icon/client/IconFieldClient.js";
7
7
  import { IconLibrarySelect } from "../fields/icon/client/IconLibrarySelect.js";
8
- export { ColorField, ColorPickerPanel, IconField, IconLibrarySelect, ProtectedField, RichTextRevealGate };
8
+ import { MeasurementUnitsProvider, useMeasurementUnits } from "../fields/measurement/client/MeasurementUnitsProvider.js";
9
+ import { MeasurementCell } from "../fields/measurement/client/MeasurementCell.js";
10
+ import { MeasurementField } from "../fields/measurement/client/MeasurementField.js";
11
+ import { CountryFlag } from "../fields/phoneNumber/client/CountryFlag.js";
12
+ import { CountryPicker } from "../fields/phoneNumber/client/CountryPicker.js";
13
+ import { PhoneNumberField } from "../fields/phoneNumber/client/PhoneNumberField.js";
14
+ export { ColorField, ColorPickerPanel, CountryFlag, CountryPicker, IconField, IconLibrarySelect, MeasurementCell, MeasurementField, MeasurementUnitsProvider, PhoneNumberField, ProtectedField, RichTextRevealGate, useMeasurementUnits };
@@ -0,0 +1,9 @@
1
+ import { MeasurementPrecision, PrecisionMode, ResolvedPrecision, resolvePrecision } from "../fields/measurement/engine/precision.js";
2
+ import { COMPOUNDS, CompoundUnitId, CoreDimension, DISPLAY_PRECISION, DimOf, Dimension, MeasurementUnitId, STORAGE_FRACTION_DIGITS, ScalarOfDimension, ScalarUnitId, UNITS, UnitId, UnitOfDimension, dimensionOf, isCompoundUnit, isScalarUnit, precisionFor, unitsOfDimension } from "../fields/measurement/engine/units.js";
3
+ import { DIMENSION_LOCALE_DEFAULTS, MeasurementSystem, resolveDisplayUnit, systemForLocale } from "../fields/measurement/engine/locale.js";
4
+ import { FormatMeasurementOptions, LocalizedLabel, compose, decompose, formatMeasurement, resolveLocalizedLabel, unitLabel } from "../fields/measurement/engine/format.js";
5
+ import { CustomDimensionDef, CustomUnitDef, EngineFormatMeasurementOptions, MeasurementCustomConfig, MeasurementEngine, createEngine, defaultEngine } from "../fields/measurement/engine/registry.js";
6
+ import { AnyMeasurementFieldOptions, MeasurementPrecisionFor } from "../fields/measurement/options.js";
7
+ import { convert, roundTo } from "../fields/measurement/engine/convert.js";
8
+ import { MeasurementPreset, MeasurementUsage, presets } from "../fields/measurement/presets.js";
9
+ export { type AnyMeasurementFieldOptions, COMPOUNDS, type CompoundUnitId, type CoreDimension, type CustomDimensionDef, type CustomUnitDef, DIMENSION_LOCALE_DEFAULTS, DISPLAY_PRECISION, type DimOf, type Dimension, type EngineFormatMeasurementOptions, type FormatMeasurementOptions, type LocalizedLabel, type MeasurementCustomConfig, type MeasurementEngine, type MeasurementPrecision, type MeasurementPrecisionFor, type MeasurementPreset, type MeasurementSystem, type MeasurementUnitId, type MeasurementUsage, type PrecisionMode, type ResolvedPrecision, STORAGE_FRACTION_DIGITS, type ScalarOfDimension, type ScalarUnitId, UNITS, type UnitId, type UnitOfDimension, compose, convert, createEngine, decompose, defaultEngine, dimensionOf, formatMeasurement, isCompoundUnit, isScalarUnit, precisionFor, presets, resolveDisplayUnit, resolveLocalizedLabel, resolvePrecision, roundTo, systemForLocale, unitLabel, unitsOfDimension };
@@ -0,0 +1,8 @@
1
+ import { COMPOUNDS, DISPLAY_PRECISION, STORAGE_FRACTION_DIGITS, UNITS, dimensionOf, isCompoundUnit, isScalarUnit, precisionFor, unitsOfDimension } from "../fields/measurement/engine/units.js";
2
+ import { resolvePrecision } from "../fields/measurement/engine/precision.js";
3
+ import { DIMENSION_LOCALE_DEFAULTS, resolveDisplayUnit, systemForLocale } from "../fields/measurement/engine/locale.js";
4
+ import { convert, roundTo } from "../fields/measurement/engine/convert.js";
5
+ import { compose, decompose, formatMeasurement, resolveLocalizedLabel, unitLabel } from "../fields/measurement/engine/format.js";
6
+ import { createEngine, defaultEngine } from "../fields/measurement/engine/registry.js";
7
+ import { presets } from "../fields/measurement/presets.js";
8
+ export { COMPOUNDS, DIMENSION_LOCALE_DEFAULTS, DISPLAY_PRECISION, STORAGE_FRACTION_DIGITS, UNITS, compose, convert, createEngine, decompose, defaultEngine, dimensionOf, formatMeasurement, isCompoundUnit, isScalarUnit, precisionFor, presets, resolveDisplayUnit, resolveLocalizedLabel, resolvePrecision, roundTo, systemForLocale, unitLabel, unitsOfDimension };
@@ -0,0 +1,11 @@
1
+ import { MeasurementPrecision, PrecisionMode, ResolvedPrecision, resolvePrecision } from "../fields/measurement/engine/precision.js";
2
+ import { COMPOUNDS, CompoundUnitId, CoreDimension, DISPLAY_PRECISION, DimOf, Dimension, MeasurementUnitId, STORAGE_FRACTION_DIGITS, ScalarOfDimension, ScalarUnitId, UNITS, UnitId, UnitOfDimension, dimensionOf, isCompoundUnit, isScalarUnit, precisionFor, unitsOfDimension } from "../fields/measurement/engine/units.js";
3
+ import { MeasurementDefaultUnitsResolver, MeasurementGlobalConfig } from "../types.js";
4
+ import { DIMENSION_LOCALE_DEFAULTS, MeasurementSystem, resolveDisplayUnit, systemForLocale } from "../fields/measurement/engine/locale.js";
5
+ import { FormatMeasurementOptions, LocalizedLabel, compose, decompose, formatMeasurement, resolveLocalizedLabel, unitLabel } from "../fields/measurement/engine/format.js";
6
+ import { CustomDimensionDef, CustomUnitDef, EngineFormatMeasurementOptions, MeasurementCustomConfig, MeasurementEngine, createEngine, defaultEngine } from "../fields/measurement/engine/registry.js";
7
+ import { AnyMeasurementFieldOptions, MEASUREMENT_PREFERENCE_KEY, MeasurementClientOptions, MeasurementCustomFieldOptions, MeasurementFieldOptions, MeasurementPrecisionFor, MeasurementResolvedClientOptions, MeasurementUnitsPreference } from "../fields/measurement/options.js";
8
+ import { convert, roundTo } from "../fields/measurement/engine/convert.js";
9
+ import { MeasurementPreset, MeasurementUsage, presets } from "../fields/measurement/presets.js";
10
+ import { measurementField } from "../fields/measurement/measurementField.js";
11
+ export { type AnyMeasurementFieldOptions, COMPOUNDS, type CompoundUnitId, type CoreDimension, type CustomDimensionDef, type CustomUnitDef, DIMENSION_LOCALE_DEFAULTS, DISPLAY_PRECISION, type DimOf, type Dimension, type EngineFormatMeasurementOptions, type FormatMeasurementOptions, type LocalizedLabel, MEASUREMENT_PREFERENCE_KEY, type MeasurementClientOptions, type MeasurementCustomConfig, type MeasurementCustomFieldOptions, type MeasurementDefaultUnitsResolver, type MeasurementEngine, type MeasurementFieldOptions, type MeasurementGlobalConfig, type MeasurementPrecision, type MeasurementPrecisionFor, type MeasurementPreset, type MeasurementResolvedClientOptions, type MeasurementSystem, type MeasurementUnitId, type MeasurementUnitsPreference, type MeasurementUsage, type PrecisionMode, type ResolvedPrecision, STORAGE_FRACTION_DIGITS, type ScalarOfDimension, type ScalarUnitId, UNITS, type UnitId, type UnitOfDimension, compose, convert, createEngine, decompose, defaultEngine, dimensionOf, formatMeasurement, isCompoundUnit, isScalarUnit, measurementField, precisionFor, presets, resolveDisplayUnit, resolveLocalizedLabel, resolvePrecision, roundTo, systemForLocale, unitLabel, unitsOfDimension };
@@ -0,0 +1,10 @@
1
+ import { COMPOUNDS, DISPLAY_PRECISION, STORAGE_FRACTION_DIGITS, UNITS, dimensionOf, isCompoundUnit, isScalarUnit, precisionFor, unitsOfDimension } from "../fields/measurement/engine/units.js";
2
+ import { resolvePrecision } from "../fields/measurement/engine/precision.js";
3
+ import { DIMENSION_LOCALE_DEFAULTS, resolveDisplayUnit, systemForLocale } from "../fields/measurement/engine/locale.js";
4
+ import { convert, roundTo } from "../fields/measurement/engine/convert.js";
5
+ import { compose, decompose, formatMeasurement, resolveLocalizedLabel, unitLabel } from "../fields/measurement/engine/format.js";
6
+ import { createEngine, defaultEngine } from "../fields/measurement/engine/registry.js";
7
+ import { MEASUREMENT_PREFERENCE_KEY } from "../fields/measurement/options.js";
8
+ import { measurementField } from "../fields/measurement/measurementField.js";
9
+ import { presets } from "../fields/measurement/presets.js";
10
+ export { COMPOUNDS, DIMENSION_LOCALE_DEFAULTS, DISPLAY_PRECISION, MEASUREMENT_PREFERENCE_KEY, STORAGE_FRACTION_DIGITS, UNITS, compose, convert, createEngine, decompose, defaultEngine, dimensionOf, formatMeasurement, isCompoundUnit, isScalarUnit, measurementField, precisionFor, presets, resolveDisplayUnit, resolveLocalizedLabel, resolvePrecision, roundTo, systemForLocale, unitLabel, unitsOfDimension };
@@ -0,0 +1,4 @@
1
+ import { DEFAULT_METADATA_SET, MetadataSet, PhoneMetadata, loadMetadata } from "../fields/phoneNumber/engine/metadata.js";
2
+ import { CountryCode, ParsedPhone, PhoneCheck, PhoneFormat, PhoneOptions, PhoneValidationMode, checkPhone, detectCountry, formatAsYouType, formatPhone, parsePhone, phoneUri, salvagePhone } from "../fields/phoneNumber/engine/phone.js";
3
+ import { CountryOption, KNOWN_COUNTRY_CODES, callingCodeFor, countryOptions, emojiFlag, isKnownCountry, isSupported } from "../fields/phoneNumber/engine/countries.js";
4
+ export { type CountryCode, type CountryOption, DEFAULT_METADATA_SET, KNOWN_COUNTRY_CODES, type MetadataSet, type ParsedPhone, type PhoneCheck, type PhoneFormat, type PhoneMetadata, type PhoneOptions, type PhoneValidationMode, callingCodeFor, checkPhone, countryOptions, detectCountry, emojiFlag, formatAsYouType, formatPhone, isKnownCountry, isSupported, loadMetadata, parsePhone, phoneUri, salvagePhone };
@@ -0,0 +1,4 @@
1
+ import { KNOWN_COUNTRY_CODES, callingCodeFor, countryOptions, emojiFlag, isKnownCountry, isSupported } from "../fields/phoneNumber/engine/countries.js";
2
+ import { DEFAULT_METADATA_SET, loadMetadata } from "../fields/phoneNumber/engine/metadata.js";
3
+ import { checkPhone, detectCountry, formatAsYouType, formatPhone, parsePhone, phoneUri, salvagePhone } from "../fields/phoneNumber/engine/phone.js";
4
+ export { DEFAULT_METADATA_SET, KNOWN_COUNTRY_CODES, callingCodeFor, checkPhone, countryOptions, detectCountry, emojiFlag, formatAsYouType, formatPhone, isKnownCountry, isSupported, loadMetadata, parsePhone, phoneUri, salvagePhone };
@@ -0,0 +1,6 @@
1
+ import { MetadataSet } from "../fields/phoneNumber/engine/metadata.js";
2
+ import { CountryCode, PhoneFormat, PhoneValidationMode } from "../fields/phoneNumber/engine/phone.js";
3
+ import { AnyPhoneNumberFieldOptions, FLAGS_PATH, PHONE_CUSTOM_KEY, PhoneFlagMode, PhoneNumberE164FieldOptions, PhoneNumberFieldOptions, PhoneStorageMode, ResolvablePhoneFieldOptions, ResolvedPhoneOptions, countryFlagSrc } from "../fields/phoneNumber/options.js";
4
+ import { PhoneNumberGlobalConfig } from "../types.js";
5
+ import { phoneNumberField } from "../fields/phoneNumber/phoneNumberField.js";
6
+ export { type AnyPhoneNumberFieldOptions, type CountryCode, FLAGS_PATH, type MetadataSet, PHONE_CUSTOM_KEY, type PhoneFlagMode, type PhoneFormat, type PhoneNumberE164FieldOptions, type PhoneNumberFieldOptions, type PhoneNumberGlobalConfig, type PhoneStorageMode, type PhoneValidationMode, type ResolvablePhoneFieldOptions, type ResolvedPhoneOptions, countryFlagSrc, phoneNumberField };
@@ -0,0 +1,3 @@
1
+ import { FLAGS_PATH, PHONE_CUSTOM_KEY, countryFlagSrc } from "../fields/phoneNumber/options.js";
2
+ import { phoneNumberField } from "../fields/phoneNumber/phoneNumberField.js";
3
+ export { FLAGS_PATH, PHONE_CUSTOM_KEY, countryFlagSrc, phoneNumberField };
@@ -7,4 +7,8 @@ import { ProtectedRichText } from "../fields/encrypted/components/ProtectedRichT
7
7
  import { IconCell } from "../fields/icon/rsc/IconCell.js";
8
8
  import { IconFieldServer } from "../fields/icon/rsc/IconFieldServer.js";
9
9
  import { IconLibrarySelectServer } from "../fields/icon/rsc/IconLibrarySelectServer.js";
10
- export { ColorCell, ColorFieldServer, type FieldsPluginRegistry, IconCell, IconFieldServer, IconLibrarySelectServer, ProtectedCell, ProtectedRichText, createRscIcon };
10
+ import { MeasurementCellServer } from "../fields/measurement/server/MeasurementCellServer.js";
11
+ import { MeasurementFieldServer } from "../fields/measurement/server/MeasurementFieldServer.js";
12
+ import { PhoneNumberCellServer } from "../fields/phoneNumber/server/PhoneNumberCellServer.js";
13
+ import { PhoneNumberFieldServer } from "../fields/phoneNumber/server/PhoneNumberFieldServer.js";
14
+ export { ColorCell, ColorFieldServer, type FieldsPluginRegistry, IconCell, IconFieldServer, IconLibrarySelectServer, MeasurementCellServer, MeasurementFieldServer, PhoneNumberCellServer, PhoneNumberFieldServer, ProtectedCell, ProtectedRichText, createRscIcon };
@@ -6,4 +6,8 @@ import { createRscIcon } from "../fields/icon/react/createRscIcon.js";
6
6
  import { IconCell } from "../fields/icon/rsc/IconCell.js";
7
7
  import { IconFieldServer } from "../fields/icon/rsc/IconFieldServer.js";
8
8
  import { IconLibrarySelectServer } from "../fields/icon/rsc/IconLibrarySelectServer.js";
9
- export { ColorCell, ColorFieldServer, IconCell, IconFieldServer, IconLibrarySelectServer, ProtectedCell, ProtectedRichText, createRscIcon };
9
+ import { MeasurementCellServer } from "../fields/measurement/server/MeasurementCellServer.js";
10
+ import { MeasurementFieldServer } from "../fields/measurement/server/MeasurementFieldServer.js";
11
+ import { PhoneNumberCellServer } from "../fields/phoneNumber/server/PhoneNumberCellServer.js";
12
+ import { PhoneNumberFieldServer } from "../fields/phoneNumber/server/PhoneNumberFieldServer.js";
13
+ export { ColorCell, ColorFieldServer, IconCell, IconFieldServer, IconLibrarySelectServer, MeasurementCellServer, MeasurementFieldServer, PhoneNumberCellServer, PhoneNumberFieldServer, ProtectedCell, ProtectedRichText, createRscIcon };
@@ -1,4 +1,5 @@
1
- import { ColorFormat, ColorGlobalConfig, ColorPreset, DecryptFailurePolicy, EncryptedGlobalConfig, FieldsPluginRegistry, FieldsResolverArgs, IconAdapter, IconGlobalConfig, IconManifest, IconMeta, IconNode, IconNodeMap, KeysConfig } from "../types.js";
1
+ import { AnyPhoneNumberFieldOptions, PhoneFlagMode, PhoneNumberE164FieldOptions, PhoneNumberFieldOptions, PhoneStorageMode, ResolvablePhoneFieldOptions, ResolvedPhoneOptions } from "../fields/phoneNumber/options.js";
2
+ import { ColorFormat, ColorGlobalConfig, ColorPreset, DecryptFailurePolicy, EncryptedGlobalConfig, FieldsPluginRegistry, FieldsResolverArgs, IconAdapter, IconGlobalConfig, IconManifest, IconMeta, IconNode, IconNodeMap, KeysConfig, PhoneNumberGlobalConfig } from "../types.js";
2
3
  import { ColorFieldClientOptions, ColorFieldOptions, ColorLinkedOptions, ColorPresetsResolver, ColorPresetsSource, ResolvedColorPreset } from "../fields/color/options.js";
3
4
  import { FieldsPluginOptions } from "../index.js";
4
- export type { ColorFieldClientOptions, ColorFieldOptions, ColorFormat, ColorGlobalConfig, ColorLinkedOptions, ColorPreset, ColorPresetsResolver, ColorPresetsSource, DecryptFailurePolicy, EncryptedGlobalConfig, FieldsPluginOptions, FieldsPluginRegistry, FieldsResolverArgs, IconAdapter, IconGlobalConfig, IconManifest, IconMeta, IconNode, IconNodeMap, KeysConfig, ResolvedColorPreset };
5
+ export type { AnyPhoneNumberFieldOptions, ColorFieldClientOptions, ColorFieldOptions, ColorFormat, ColorGlobalConfig, ColorLinkedOptions, ColorPreset, ColorPresetsResolver, ColorPresetsSource, DecryptFailurePolicy, EncryptedGlobalConfig, FieldsPluginOptions, FieldsPluginRegistry, FieldsResolverArgs, IconAdapter, IconGlobalConfig, IconManifest, IconMeta, IconNode, IconNodeMap, KeysConfig, PhoneFlagMode, PhoneNumberE164FieldOptions, PhoneNumberFieldOptions, PhoneNumberGlobalConfig, PhoneStorageMode, ResolvablePhoneFieldOptions, ResolvedColorPreset, ResolvedPhoneOptions };
@@ -408,7 +408,8 @@ html[data-theme="dark"] .tenx-icon-drawer__banner {
408
408
  background: transparent;
409
409
  border: none;
410
410
  border-radius: var(--style-radius-s);
411
- color: var(--theme-elevation-600);
411
+ /* 700, not 600: the small rail label needs 4.5:1 on the drawer background */
412
+ color: var(--theme-elevation-700);
412
413
  font-family: inherit;
413
414
  font-size: 0.875rem;
414
415
  text-align: left;
@@ -527,6 +528,7 @@ html[data-theme="dark"] .tenx-icon-drawer__banner {
527
528
  padding-top: calc(var(--base) * 0.5);
528
529
  background: var(--theme-bg);
529
530
  border-top: 1px solid var(--theme-elevation-100);
530
- color: var(--theme-elevation-600);
531
+ /* 700, not 600: the small counter needs 4.5:1 on the drawer background */
532
+ color: var(--theme-elevation-700);
531
533
  font-size: 0.75rem;
532
534
  }
@@ -1,6 +1,6 @@
1
1
  import { getFieldsRegistry } from "../../../plugin/registry.js";
2
2
  import { resolveAvailableLibraries, unionAlwaysAvailable } from "../server/availability.js";
3
- import { resolveStaticLabel } from "../shared/resolveStaticLabel.js";
3
+ import { resolveStaticLabel } from "../../../utils/resolveStaticLabel.js";
4
4
  import { resolveIconValue } from "../shared/value.js";
5
5
  import { IconField } from "../client/IconFieldClient.js";
6
6
  import { resolveIconMeta } from "../server/resolveIconMeta.js";
@@ -1 +1 @@
1
- {"version":3,"file":"IconFieldServer.js","names":[],"sources":["../../../../src/fields/icon/rsc/IconFieldServer.tsx"],"sourcesContent":["import type { TextFieldServerProps } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\nimport type { ReactNode } from 'react'\nimport { getFieldsRegistry } from '../../../plugin/registry'\nimport type { IconAdapter, IconAvailabilityResolver } from '../../../types'\nimport { IconField } from '../client/IconFieldClient'\nimport { resolveAvailableLibraries, unionAlwaysAvailable } from '../server/availability'\nimport { resolveIconMeta } from '../server/resolveIconMeta'\nimport type { AdapterComponentsEntry } from '../shared/adapterComponents'\nimport { resolveStaticLabel } from '../shared/resolveStaticLabel'\nimport { resolveIconValue } from '../shared/value'\n\ntype IconFieldServerExtraProps = {\n\tadapters?: IconAdapter[]\n\talwaysAvailable?: string[]\n\tdefaultLibrary?: string\n\tresolveAvailable?: IconAvailabilityResolver\n\tshowTextInput?: boolean\n}\n\ntype ServerProps = IconFieldServerExtraProps & TextFieldServerProps\n\n/**\n * Resolves adapters (inline beats registry), availability (memoized per request,\n * fails open), and adapter client components from the importMap, then renders the\n * client field with those component references as props. A missing importMap entry\n * degrades to no glyph for that library rather than throwing, so the edit view\n * never 500s over a mis-registered adapter.\n */\nexport const IconFieldServer = async (props: ServerProps): Promise<ReactNode> => {\n\tconst {\n\t\tclientField,\n\t\tdata,\n\t\ti18n,\n\t\tpath,\n\t\tpayload,\n\t\tpermissions,\n\t\treadOnly,\n\t\treq,\n\t\tschemaPath,\n\t\tsiblingData,\n\t} = props\n\tconst registryIcon = getFieldsRegistry(payload.config)?.icon\n\tconst adapters = props.adapters ?? registryIcon?.adapters ?? []\n\tconst defaultLibrary =\n\t\tprops.defaultLibrary ?? registryIcon?.defaultLibrary ?? adapters[0]?.slug ?? ''\n\tconst resolver = props.resolveAvailable ?? registryIcon?.resolveAvailable\n\tconst alwaysAvailable = unionAlwaysAvailable(props.alwaysAvailable, registryIcon?.alwaysAvailable)\n\n\tconst available = await resolveAvailableLibraries({\n\t\tadapters,\n\t\talwaysAvailable,\n\t\tdata: data as Record<string, unknown> | undefined,\n\t\treq,\n\t\tresolver,\n\t\tsiblingData: siblingData as Record<string, unknown> | undefined,\n\t})\n\n\tconst adapterComponents: Record<string, AdapterComponentsEntry> = {}\n\tfor (const adapter of adapters) {\n\t\tconst Icon = getFromImportMap<AdapterComponentsEntry['Icon']>({\n\t\t\timportMap: payload.importMap,\n\t\t\tPayloadComponent: adapter.Icon,\n\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\tsilent: true,\n\t\t})\n\t\tconst Assets = getFromImportMap<AdapterComponentsEntry['Assets']>({\n\t\t\timportMap: payload.importMap,\n\t\t\tPayloadComponent: adapter.Assets,\n\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\tsilent: true,\n\t\t})\n\t\t// Optional: libraries with bulk node-data (lucide, tabler) resolve a Nodes\n\t\t// loader so the drawer renders glyphs inline; radix omits it and falls back\n\t\t// to the per-icon Icon component.\n\t\tconst Nodes = adapter.Nodes\n\t\t\t? getFromImportMap<NonNullable<AdapterComponentsEntry['Nodes']>>({\n\t\t\t\t\timportMap: payload.importMap,\n\t\t\t\t\tPayloadComponent: adapter.Nodes,\n\t\t\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\t\t\tsilent: true,\n\t\t\t\t})\n\t\t\t: undefined\n\t\tif (Icon && Assets)\n\t\t\tadapterComponents[adapter.slug] = { Assets, canvas: adapter.canvas, Icon, Nodes }\n\t}\n\n\t// The trigger renders from a stored value alone, so a library-supplied label has to\n\t// arrive with it. A miss is not an error here: an unknown or removed icon still\n\t// renders, falling back to the name-derived label exactly as before.\n\tconst storedValue =\n\t\ttypeof siblingData?.[String(clientField.name)] === 'string'\n\t\t\t? (siblingData[String(clientField.name)] as string)\n\t\t\t: null\n\tlet selectedMeta = null\n\tif (storedValue !== null && storedValue !== '') {\n\t\tconst { library, name } = resolveIconValue(storedValue, defaultLibrary)\n\t\tconst adapter = adapters.find((candidate) => candidate.slug === library)\n\t\tif (adapter) selectedMeta = await resolveIconMeta(adapter, name, { payload, req })\n\t}\n\n\treturn (\n\t\t<IconField\n\t\t\tadapterComponents={adapterComponents}\n\t\t\tadapters={adapters.map((adapter) => ({\n\t\t\t\tlabel: resolveStaticLabel(adapter.label, i18n.language) ?? adapter.slug,\n\t\t\t\tslug: adapter.slug,\n\t\t\t}))}\n\t\t\tavailable={available}\n\t\t\tdefaultLibrary={defaultLibrary}\n\t\t\tfield={clientField}\n\t\t\tpath={path}\n\t\t\tpermissions={permissions}\n\t\t\treadOnly={readOnly}\n\t\t\tschemaPath={schemaPath}\n\t\t\tselectedMeta={selectedMeta}\n\t\t\tshowTextInput={props.showTextInput === true}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,kBAAkB,OAAO,UAA2C;CAChF,MAAM,EACL,aACA,MACA,MACA,MACA,SACA,aACA,UACA,KACA,YACA,gBACG;CACJ,MAAM,eAAe,kBAAkB,QAAQ,MAAM,GAAG;CACxD,MAAM,WAAW,MAAM,YAAY,cAAc,YAAY,CAAC;CAC9D,MAAM,iBACL,MAAM,kBAAkB,cAAc,kBAAkB,SAAS,IAAI,QAAQ;CAC9E,MAAM,WAAW,MAAM,oBAAoB,cAAc;CAGzD,MAAM,YAAY,MAAM,0BAA0B;EACjD;EACA,iBAJuB,qBAAqB,MAAM,iBAAiB,cAAc,eAInE;EACR;EACN;EACA;EACa;CACd,CAAC;CAED,MAAM,oBAA4D,CAAC;CACnE,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,OAAO,iBAAiD;GAC7D,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC;EACD,MAAM,SAAS,iBAAmD;GACjE,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC;EAID,MAAM,QAAQ,QAAQ,QACnB,iBAA+D;GAC/D,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC,IACA,KAAA;EACH,IAAI,QAAQ,QACX,kBAAkB,QAAQ,QAAQ;GAAE;GAAQ,QAAQ,QAAQ;GAAQ;GAAM;EAAM;CAClF;CAKA,MAAM,cACL,OAAO,cAAc,OAAO,YAAY,IAAI,OAAO,WAC/C,YAAY,OAAO,YAAY,IAAI,KACpC;CACJ,IAAI,eAAe;CACnB,IAAI,gBAAgB,QAAQ,gBAAgB,IAAI;EAC/C,MAAM,EAAE,SAAS,SAAS,iBAAiB,aAAa,cAAc;EACtE,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,SAAS,OAAO;EACvE,IAAI,SAAS,eAAe,MAAM,gBAAgB,SAAS,MAAM;GAAE;GAAS;EAAI,CAAC;CAClF;CAEA,OACC,oBAAC,WAAD;EACoB;EACnB,UAAU,SAAS,KAAK,aAAa;GACpC,OAAO,mBAAmB,QAAQ,OAAO,KAAK,QAAQ,KAAK,QAAQ;GACnE,MAAM,QAAQ;EACf,EAAE;EACS;EACK;EAChB,OAAO;EACD;EACO;EACH;EACE;EACE;EACd,eAAe,MAAM,kBAAkB;CACvC,CAAA;AAEH"}
1
+ {"version":3,"file":"IconFieldServer.js","names":[],"sources":["../../../../src/fields/icon/rsc/IconFieldServer.tsx"],"sourcesContent":["import type { TextFieldServerProps } from 'payload'\nimport { getFromImportMap } from 'payload/shared'\nimport type { ReactNode } from 'react'\nimport { getFieldsRegistry } from '../../../plugin/registry'\nimport type { IconAdapter, IconAvailabilityResolver } from '../../../types'\nimport { resolveStaticLabel } from '../../../utils/resolveStaticLabel'\nimport { IconField } from '../client/IconFieldClient'\nimport { resolveAvailableLibraries, unionAlwaysAvailable } from '../server/availability'\nimport { resolveIconMeta } from '../server/resolveIconMeta'\nimport type { AdapterComponentsEntry } from '../shared/adapterComponents'\nimport { resolveIconValue } from '../shared/value'\n\ntype IconFieldServerExtraProps = {\n\tadapters?: IconAdapter[]\n\talwaysAvailable?: string[]\n\tdefaultLibrary?: string\n\tresolveAvailable?: IconAvailabilityResolver\n\tshowTextInput?: boolean\n}\n\ntype ServerProps = IconFieldServerExtraProps & TextFieldServerProps\n\n/**\n * Resolves adapters (inline beats registry), availability (memoized per request,\n * fails open), and adapter client components from the importMap, then renders the\n * client field with those component references as props. A missing importMap entry\n * degrades to no glyph for that library rather than throwing, so the edit view\n * never 500s over a mis-registered adapter.\n */\nexport const IconFieldServer = async (props: ServerProps): Promise<ReactNode> => {\n\tconst {\n\t\tclientField,\n\t\tdata,\n\t\ti18n,\n\t\tpath,\n\t\tpayload,\n\t\tpermissions,\n\t\treadOnly,\n\t\treq,\n\t\tschemaPath,\n\t\tsiblingData,\n\t} = props\n\tconst registryIcon = getFieldsRegistry(payload.config)?.icon\n\tconst adapters = props.adapters ?? registryIcon?.adapters ?? []\n\tconst defaultLibrary =\n\t\tprops.defaultLibrary ?? registryIcon?.defaultLibrary ?? adapters[0]?.slug ?? ''\n\tconst resolver = props.resolveAvailable ?? registryIcon?.resolveAvailable\n\tconst alwaysAvailable = unionAlwaysAvailable(props.alwaysAvailable, registryIcon?.alwaysAvailable)\n\n\tconst available = await resolveAvailableLibraries({\n\t\tadapters,\n\t\talwaysAvailable,\n\t\tdata: data as Record<string, unknown> | undefined,\n\t\treq,\n\t\tresolver,\n\t\tsiblingData: siblingData as Record<string, unknown> | undefined,\n\t})\n\n\tconst adapterComponents: Record<string, AdapterComponentsEntry> = {}\n\tfor (const adapter of adapters) {\n\t\tconst Icon = getFromImportMap<AdapterComponentsEntry['Icon']>({\n\t\t\timportMap: payload.importMap,\n\t\t\tPayloadComponent: adapter.Icon,\n\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\tsilent: true,\n\t\t})\n\t\tconst Assets = getFromImportMap<AdapterComponentsEntry['Assets']>({\n\t\t\timportMap: payload.importMap,\n\t\t\tPayloadComponent: adapter.Assets,\n\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\tsilent: true,\n\t\t})\n\t\t// Optional: libraries with bulk node-data (lucide, tabler) resolve a Nodes\n\t\t// loader so the drawer renders glyphs inline; radix omits it and falls back\n\t\t// to the per-icon Icon component.\n\t\tconst Nodes = adapter.Nodes\n\t\t\t? getFromImportMap<NonNullable<AdapterComponentsEntry['Nodes']>>({\n\t\t\t\t\timportMap: payload.importMap,\n\t\t\t\t\tPayloadComponent: adapter.Nodes,\n\t\t\t\t\tschemaPath: `${schemaPath ?? path}.icon-adapter`,\n\t\t\t\t\tsilent: true,\n\t\t\t\t})\n\t\t\t: undefined\n\t\tif (Icon && Assets)\n\t\t\tadapterComponents[adapter.slug] = { Assets, canvas: adapter.canvas, Icon, Nodes }\n\t}\n\n\t// The trigger renders from a stored value alone, so a library-supplied label has to\n\t// arrive with it. A miss is not an error here: an unknown or removed icon still\n\t// renders, falling back to the name-derived label exactly as before.\n\tconst storedValue =\n\t\ttypeof siblingData?.[String(clientField.name)] === 'string'\n\t\t\t? (siblingData[String(clientField.name)] as string)\n\t\t\t: null\n\tlet selectedMeta = null\n\tif (storedValue !== null && storedValue !== '') {\n\t\tconst { library, name } = resolveIconValue(storedValue, defaultLibrary)\n\t\tconst adapter = adapters.find((candidate) => candidate.slug === library)\n\t\tif (adapter) selectedMeta = await resolveIconMeta(adapter, name, { payload, req })\n\t}\n\n\treturn (\n\t\t<IconField\n\t\t\tadapterComponents={adapterComponents}\n\t\t\tadapters={adapters.map((adapter) => ({\n\t\t\t\tlabel: resolveStaticLabel(adapter.label, i18n.language) ?? adapter.slug,\n\t\t\t\tslug: adapter.slug,\n\t\t\t}))}\n\t\t\tavailable={available}\n\t\t\tdefaultLibrary={defaultLibrary}\n\t\t\tfield={clientField}\n\t\t\tpath={path}\n\t\t\tpermissions={permissions}\n\t\t\treadOnly={readOnly}\n\t\t\tschemaPath={schemaPath}\n\t\t\tselectedMeta={selectedMeta}\n\t\t\tshowTextInput={props.showTextInput === true}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,kBAAkB,OAAO,UAA2C;CAChF,MAAM,EACL,aACA,MACA,MACA,MACA,SACA,aACA,UACA,KACA,YACA,gBACG;CACJ,MAAM,eAAe,kBAAkB,QAAQ,MAAM,GAAG;CACxD,MAAM,WAAW,MAAM,YAAY,cAAc,YAAY,CAAC;CAC9D,MAAM,iBACL,MAAM,kBAAkB,cAAc,kBAAkB,SAAS,IAAI,QAAQ;CAC9E,MAAM,WAAW,MAAM,oBAAoB,cAAc;CAGzD,MAAM,YAAY,MAAM,0BAA0B;EACjD;EACA,iBAJuB,qBAAqB,MAAM,iBAAiB,cAAc,eAInE;EACR;EACN;EACA;EACa;CACd,CAAC;CAED,MAAM,oBAA4D,CAAC;CACnE,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,OAAO,iBAAiD;GAC7D,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC;EACD,MAAM,SAAS,iBAAmD;GACjE,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC;EAID,MAAM,QAAQ,QAAQ,QACnB,iBAA+D;GAC/D,WAAW,QAAQ;GACnB,kBAAkB,QAAQ;GAC1B,YAAY,GAAG,cAAc,KAAK;GAClC,QAAQ;EACT,CAAC,IACA,KAAA;EACH,IAAI,QAAQ,QACX,kBAAkB,QAAQ,QAAQ;GAAE;GAAQ,QAAQ,QAAQ;GAAQ;GAAM;EAAM;CAClF;CAKA,MAAM,cACL,OAAO,cAAc,OAAO,YAAY,IAAI,OAAO,WAC/C,YAAY,OAAO,YAAY,IAAI,KACpC;CACJ,IAAI,eAAe;CACnB,IAAI,gBAAgB,QAAQ,gBAAgB,IAAI;EAC/C,MAAM,EAAE,SAAS,SAAS,iBAAiB,aAAa,cAAc;EACtE,MAAM,UAAU,SAAS,MAAM,cAAc,UAAU,SAAS,OAAO;EACvE,IAAI,SAAS,eAAe,MAAM,gBAAgB,SAAS,MAAM;GAAE;GAAS;EAAI,CAAC;CAClF;CAEA,OACC,oBAAC,WAAD;EACoB;EACnB,UAAU,SAAS,KAAK,aAAa;GACpC,OAAO,mBAAmB,QAAQ,OAAO,KAAK,QAAQ,KAAK,QAAQ;GACnE,MAAM,QAAQ;EACf,EAAE;EACS;EACK;EAChB,OAAO;EACD;EACO;EACH;EACE;EACE;EACd,eAAe,MAAM,kBAAkB;CACvC,CAAA;AAEH"}
@@ -1,4 +1,4 @@
1
- import { resolveStaticLabel } from "../shared/resolveStaticLabel.js";
1
+ import { resolveStaticLabel } from "../../../utils/resolveStaticLabel.js";
2
2
  import { IconLibrarySelect } from "../client/IconLibrarySelect.js";
3
3
  import { getIconLibraryOptions } from "../server/libraryOptions.js";
4
4
  import { jsx } from "react/jsx-runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"IconLibrarySelectServer.js","names":[],"sources":["../../../../src/fields/icon/rsc/IconLibrarySelectServer.tsx"],"sourcesContent":["import type { TextFieldServerProps } from 'payload'\nimport type { ReactNode } from 'react'\nimport type { IconAdapter } from '../../../types'\nimport { IconLibrarySelect } from '../client/IconLibrarySelect'\nimport { getIconLibraryOptions } from '../server/libraryOptions'\nimport { resolveStaticLabel } from '../shared/resolveStaticLabel'\n\ntype ServerProps = { adapters?: IconAdapter[] } & TextFieldServerProps\n\n/** Resolves selectable library options (inline beats registry) and renders the client select. */\nexport const IconLibrarySelectServer = (props: ServerProps): ReactNode => {\n\tconst { clientField, i18n, path, payload, permissions, readOnly, schemaPath } = props\n\tconst options = getIconLibraryOptions(payload.config, props.adapters).map((option) => ({\n\t\tlabel: resolveStaticLabel(option.label, i18n.language) ?? option.value,\n\t\tvalue: option.value,\n\t}))\n\treturn (\n\t\t<IconLibrarySelect\n\t\t\tfield={clientField}\n\t\t\toptions={options}\n\t\t\tpath={path}\n\t\t\tpermissions={permissions}\n\t\t\treadOnly={readOnly}\n\t\t\tschemaPath={schemaPath}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;AAUA,MAAa,2BAA2B,UAAkC;CACzE,MAAM,EAAE,aAAa,MAAM,MAAM,SAAS,aAAa,UAAU,eAAe;CAKhF,OACC,oBAAC,mBAAD;EACC,OAAO;EACP,SAPc,sBAAsB,QAAQ,QAAQ,MAAM,QAAQ,EAAE,KAAK,YAAY;GACtF,OAAO,mBAAmB,OAAO,OAAO,KAAK,QAAQ,KAAK,OAAO;GACjE,OAAO,OAAO;EACf,EAIiB;EACT;EACO;EACH;EACE;CACZ,CAAA;AAEH"}
1
+ {"version":3,"file":"IconLibrarySelectServer.js","names":[],"sources":["../../../../src/fields/icon/rsc/IconLibrarySelectServer.tsx"],"sourcesContent":["import type { TextFieldServerProps } from 'payload'\nimport type { ReactNode } from 'react'\nimport type { IconAdapter } from '../../../types'\nimport { resolveStaticLabel } from '../../../utils/resolveStaticLabel'\nimport { IconLibrarySelect } from '../client/IconLibrarySelect'\nimport { getIconLibraryOptions } from '../server/libraryOptions'\n\ntype ServerProps = { adapters?: IconAdapter[] } & TextFieldServerProps\n\n/** Resolves selectable library options (inline beats registry) and renders the client select. */\nexport const IconLibrarySelectServer = (props: ServerProps): ReactNode => {\n\tconst { clientField, i18n, path, payload, permissions, readOnly, schemaPath } = props\n\tconst options = getIconLibraryOptions(payload.config, props.adapters).map((option) => ({\n\t\tlabel: resolveStaticLabel(option.label, i18n.language) ?? option.value,\n\t\tvalue: option.value,\n\t}))\n\treturn (\n\t\t<IconLibrarySelect\n\t\t\tfield={clientField}\n\t\t\toptions={options}\n\t\t\tpath={path}\n\t\t\tpermissions={permissions}\n\t\t\treadOnly={readOnly}\n\t\t\tschemaPath={schemaPath}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;AAUA,MAAa,2BAA2B,UAAkC;CACzE,MAAM,EAAE,aAAa,MAAM,MAAM,SAAS,aAAa,UAAU,eAAe;CAKhF,OACC,oBAAC,mBAAD;EACC,OAAO;EACP,SAPc,sBAAsB,QAAQ,QAAQ,MAAM,QAAQ,EAAE,KAAK,YAAY;GACtF,OAAO,mBAAmB,OAAO,OAAO,KAAK,QAAQ,KAAK,OAAO;GACjE,OAAO,OAAO;EACf,EAIiB;EACT;EACO;EACH;EACE;CACZ,CAAA;AAEH"}
@@ -1,5 +1,5 @@
1
+ import { resolveStaticLabel } from "../../../utils/resolveStaticLabel.js";
1
2
  import { formatIconLabel } from "./formatIconLabel.js";
2
- import { resolveStaticLabel } from "./resolveStaticLabel.js";
3
3
  //#region src/fields/icon/shared/iconLabel.ts
4
4
  /**
5
5
  * Resolves the display text for one icon. A library-supplied `label` wins; otherwise
@@ -1 +1 @@
1
- {"version":3,"file":"iconLabel.js","names":[],"sources":["../../../../src/fields/icon/shared/iconLabel.ts"],"sourcesContent":["import type { IconMeta } from '../../../types'\nimport { formatIconLabel } from './formatIconLabel'\nimport { resolveStaticLabel } from './resolveStaticLabel'\n\n/** What an editor sees for one icon: its accessible name, plus the raw name where that adds information. */\nexport type IconDisplayLabel = { code?: string; label: string }\n\n/**\n * Resolves the display text for one icon. A library-supplied `label` wins; otherwise\n * the name is sentence-cased as before, so every existing manifest is unaffected.\n *\n * `code` carries the raw name for surfaces that can show it alongside the label. It is\n * the only place an editor can learn that \"Hungary\" stores as `HUN`, which they need to\n * write frontend code, and it is deliberately kept out of the accessible name: a screen\n * reader announcing \"Hungary HUN\" across 215 cells is the defect this fixes.\n */\nexport const resolveIconDisplay = (args: {\n\tlanguage: string\n\tmeta?: IconMeta | null\n\tname: string\n}): IconDisplayLabel => {\n\tconst derived = formatIconLabel(args.name)\n\tconst supplied = resolveStaticLabel(args.meta?.label, args.language)\n\tif (!supplied) return { label: derived }\n\t// A code only earns its place when the label hides it. A label matching the name, or\n\t// matching what the name would have derived anyway, tells the editor nothing new.\n\tif (supplied === args.name || supplied === derived) return { label: supplied }\n\treturn { code: args.name, label: supplied }\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,sBAAsB,SAIX;CACvB,MAAM,UAAU,gBAAgB,KAAK,IAAI;CACzC,MAAM,WAAW,mBAAmB,KAAK,MAAM,OAAO,KAAK,QAAQ;CACnE,IAAI,CAAC,UAAU,OAAO,EAAE,OAAO,QAAQ;CAGvC,IAAI,aAAa,KAAK,QAAQ,aAAa,SAAS,OAAO,EAAE,OAAO,SAAS;CAC7E,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO;CAAS;AAC3C"}
1
+ {"version":3,"file":"iconLabel.js","names":[],"sources":["../../../../src/fields/icon/shared/iconLabel.ts"],"sourcesContent":["import type { IconMeta } from '../../../types'\nimport { resolveStaticLabel } from '../../../utils/resolveStaticLabel'\nimport { formatIconLabel } from './formatIconLabel'\n\n/** What an editor sees for one icon: its accessible name, plus the raw name where that adds information. */\nexport type IconDisplayLabel = { code?: string; label: string }\n\n/**\n * Resolves the display text for one icon. A library-supplied `label` wins; otherwise\n * the name is sentence-cased as before, so every existing manifest is unaffected.\n *\n * `code` carries the raw name for surfaces that can show it alongside the label. It is\n * the only place an editor can learn that \"Hungary\" stores as `HUN`, which they need to\n * write frontend code, and it is deliberately kept out of the accessible name: a screen\n * reader announcing \"Hungary HUN\" across 215 cells is the defect this fixes.\n */\nexport const resolveIconDisplay = (args: {\n\tlanguage: string\n\tmeta?: IconMeta | null\n\tname: string\n}): IconDisplayLabel => {\n\tconst derived = formatIconLabel(args.name)\n\tconst supplied = resolveStaticLabel(args.meta?.label, args.language)\n\tif (!supplied) return { label: derived }\n\t// A code only earns its place when the label hides it. A label matching the name, or\n\t// matching what the name would have derived anyway, tells the editor nothing new.\n\tif (supplied === args.name || supplied === derived) return { label: supplied }\n\treturn { code: args.name, label: supplied }\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAa,sBAAsB,SAIX;CACvB,MAAM,UAAU,gBAAgB,KAAK,IAAI;CACzC,MAAM,WAAW,mBAAmB,KAAK,MAAM,OAAO,KAAK,QAAQ;CACnE,IAAI,CAAC,UAAU,OAAO,EAAE,OAAO,QAAQ;CAGvC,IAAI,aAAa,KAAK,QAAQ,aAAa,SAAS,OAAO,EAAE,OAAO,SAAS;CAC7E,OAAO;EAAE,MAAM,KAAK;EAAM,OAAO;CAAS;AAC3C"}
@@ -0,0 +1,18 @@
1
+ import { MeasurementResolvedClientOptions } from "../options.js";
2
+ import { ClientField, DefaultCellComponentProps } from "payload";
3
+ import React from "react";
4
+ //#region src/fields/measurement/client/MeasurementCell.d.ts
5
+ /**
6
+ * `field` and `onClick` are excluded and re-added as optional: the RSC cell only
7
+ * carries the server-sanitized Field (which serializes functions Payload attaches,
8
+ * e.g. hooks/validate), never a ClientField, and no onClick handler crosses the
9
+ * flight boundary. This cell reads neither, so both stay optional rather than forced.
10
+ */
11
+ type MeasurementCellProps = {
12
+ measurementOptions: MeasurementResolvedClientOptions;
13
+ field?: ClientField;
14
+ } & Omit<DefaultCellComponentProps, 'field' | 'onClick'>;
15
+ declare const MeasurementCell: React.FC<MeasurementCellProps>;
16
+ //#endregion
17
+ export { MeasurementCell, MeasurementCellProps };
18
+ //# sourceMappingURL=MeasurementCell.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { exactModePrecisionOverride, resolvePrecision } from "../engine/precision.js";
3
+ import { useTranslation } from "../../../translations/useTranslation.js";
4
+ import { resolveDisplayUnit, systemForLocale } from "../engine/locale.js";
5
+ import { createEngine, defaultEngine } from "../engine/registry.js";
6
+ import { useMeasurementUnits } from "./MeasurementUnitsProvider.js";
7
+ import { useEffect, useMemo, useState } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import "./measurementCell.css";
10
+ //#region src/fields/measurement/client/MeasurementCell.tsx
11
+ /** MeasurementCellServer always resolves and threads precision; this only covers a hand-authored Cell with no server wrapper. */
12
+ const DEFAULT_PRECISION = resolvePrecision([]);
13
+ const MeasurementCell = (props) => {
14
+ const { cellData, measurementOptions } = props;
15
+ const { custom, dimension, fallbackUnit, localeDefaults, precision, preferenceKey, registryDefault, storageUnit, units } = measurementOptions;
16
+ const { i18n } = useTranslation();
17
+ const context = useMeasurementUnits();
18
+ const engine = useMemo(() => custom ? createEngine(custom) : defaultEngine, [custom]);
19
+ const [system, setSystem] = useState(null);
20
+ useEffect(() => {
21
+ if (context) setSystem(systemForLocale(navigator.language));
22
+ }, [context]);
23
+ if (typeof cellData !== "number" || Number.isNaN(cellData)) return null;
24
+ const displayUnit = resolveDisplayUnit({
25
+ dimension,
26
+ fallbackUnit,
27
+ localeDefaults,
28
+ preferenceUnit: context?.units[preferenceKey] ?? null,
29
+ registryDefault,
30
+ system,
31
+ units
32
+ });
33
+ const precisionOverride = exactModePrecisionOverride(precision ?? DEFAULT_PRECISION, displayUnit);
34
+ return /* @__PURE__ */ jsx("span", {
35
+ className: "fields-measurement-cell",
36
+ children: engine.formatMeasurement(cellData, {
37
+ displayUnit,
38
+ locale: i18n.language,
39
+ precision: precisionOverride,
40
+ storageUnit
41
+ })
42
+ });
43
+ };
44
+ //#endregion
45
+ export { MeasurementCell };
46
+
47
+ //# sourceMappingURL=MeasurementCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeasurementCell.js","names":[],"sources":["../../../../src/fields/measurement/client/MeasurementCell.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, DefaultCellComponentProps } from 'payload'\nimport type React from 'react'\nimport { useEffect, useMemo, useState } from 'react'\nimport { useTranslation } from '../../../translations/useTranslation'\nimport { type MeasurementSystem, systemForLocale } from '../engine/locale'\nimport { exactModePrecisionOverride, resolvePrecision } from '../engine/precision'\nimport { createEngine, defaultEngine } from '../engine/registry'\nimport type { MeasurementResolvedClientOptions } from '../options'\nimport { resolveDisplayUnit } from './editModel'\nimport { useMeasurementUnits } from './MeasurementUnitsProvider'\nimport './measurementCell.css'\n\n/** MeasurementCellServer always resolves and threads precision; this only covers a hand-authored Cell with no server wrapper. */\nconst DEFAULT_PRECISION = resolvePrecision([])\n\n/**\n * `field` and `onClick` are excluded and re-added as optional: the RSC cell only\n * carries the server-sanitized Field (which serializes functions Payload attaches,\n * e.g. hooks/validate), never a ClientField, and no onClick handler crosses the\n * flight boundary. This cell reads neither, so both stay optional rather than forced.\n */\nexport type MeasurementCellProps = {\n\tmeasurementOptions: MeasurementResolvedClientOptions\n\tfield?: ClientField\n} & Omit<DefaultCellComponentProps, 'field' | 'onClick'>\n\nexport const MeasurementCell: React.FC<MeasurementCellProps> = (props) => {\n\tconst { cellData, measurementOptions } = props\n\tconst {\n\t\tcustom,\n\t\tdimension,\n\t\tfallbackUnit,\n\t\tlocaleDefaults,\n\t\tprecision,\n\t\tpreferenceKey,\n\t\tregistryDefault,\n\t\tstorageUnit,\n\t\tunits,\n\t} = measurementOptions\n\tconst { i18n } = useTranslation()\n\tconst context = useMeasurementUnits()\n\tconst engine = useMemo(() => (custom ? createEngine(custom) : defaultEngine), [custom])\n\tconst [system, setSystem] = useState<MeasurementSystem | null>(null)\n\t// Gated on the provider: plugin-less cells stay on the field default, not the browser locale.\n\tuseEffect(() => {\n\t\tif (context) setSystem(systemForLocale(navigator.language))\n\t}, [context])\n\n\tif (typeof cellData !== 'number' || Number.isNaN(cellData)) return null\n\n\tconst displayUnit = resolveDisplayUnit({\n\t\tdimension,\n\t\tfallbackUnit,\n\t\tlocaleDefaults,\n\t\tpreferenceUnit: context?.units[preferenceKey] ?? null,\n\t\tregistryDefault,\n\t\tsystem,\n\t\tunits,\n\t})\n\tconst resolvedPrecision = precision ?? DEFAULT_PRECISION\n\t// The override key is the unit id itself, so it works for a compound displayUnit\n\t// too: precisionFor/formatMeasurement treat that key as the compound's minor digits.\n\tconst precisionOverride = exactModePrecisionOverride(resolvedPrecision, displayUnit)\n\treturn (\n\t\t<span className=\"fields-measurement-cell\">\n\t\t\t{engine.formatMeasurement(cellData, {\n\t\t\t\tdisplayUnit,\n\t\t\t\tlocale: i18n.language,\n\t\t\t\tprecision: precisionOverride,\n\t\t\t\tstorageUnit,\n\t\t\t})}\n\t\t</span>\n\t)\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,oBAAoB,iBAAiB,CAAC,CAAC;AAa7C,MAAa,mBAAmD,UAAU;CACzE,MAAM,EAAE,UAAU,uBAAuB;CACzC,MAAM,EACL,QACA,WACA,cACA,gBACA,WACA,eACA,iBACA,aACA,UACG;CACJ,MAAM,EAAE,SAAS,eAAe;CAChC,MAAM,UAAU,oBAAoB;CACpC,MAAM,SAAS,cAAe,SAAS,aAAa,MAAM,IAAI,eAAgB,CAAC,MAAM,CAAC;CACtF,MAAM,CAAC,QAAQ,aAAa,SAAmC,IAAI;CAEnE,gBAAgB;EACf,IAAI,SAAS,UAAU,gBAAgB,UAAU,QAAQ,CAAC;CAC3D,GAAG,CAAC,OAAO,CAAC;CAEZ,IAAI,OAAO,aAAa,YAAY,OAAO,MAAM,QAAQ,GAAG,OAAO;CAEnE,MAAM,cAAc,mBAAmB;EACtC;EACA;EACA;EACA,gBAAgB,SAAS,MAAM,kBAAkB;EACjD;EACA;EACA;CACD,CAAC;CAID,MAAM,oBAAoB,2BAHA,aAAa,mBAGiC,WAAW;CACnF,OACC,oBAAC,QAAD;EAAM,WAAU;YACd,OAAO,kBAAkB,UAAU;GACnC;GACA,QAAQ,KAAK;GACb,WAAW;GACX;EACD,CAAC;CACI,CAAA;AAER"}
@@ -0,0 +1,11 @@
1
+ import { MeasurementResolvedClientOptions } from "../options.js";
2
+ import { NumberFieldClientProps } from "payload";
3
+ import React from "react";
4
+ //#region src/fields/measurement/client/MeasurementField.d.ts
5
+ type MeasurementFieldProps = {
6
+ measurementOptions: MeasurementResolvedClientOptions;
7
+ } & NumberFieldClientProps;
8
+ declare const MeasurementField: React.FC<MeasurementFieldProps>;
9
+ //#endregion
10
+ export { MeasurementField, MeasurementFieldProps };
11
+ //# sourceMappingURL=MeasurementField.d.ts.map