@panneau/fields 5.0.0-alpha.5 → 5.0.0-alpha.7

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 (137) hide show
  1. package/README.md +34 -0
  2. package/dist/boolean/BooleanField.js +78 -17
  3. package/dist/boolean/BooleanField.js.map +1 -1
  4. package/dist/color/ColorField.js.map +1 -1
  5. package/dist/date/DateField.js.map +1 -1
  6. package/dist/datetime/DateTimeField.js +107 -20
  7. package/dist/datetime/DateTimeField.js.map +1 -1
  8. package/dist/duration/DurationField.css +11 -0
  9. package/dist/duration/DurationField.d.ts +26 -0
  10. package/dist/duration/DurationField.d.ts.map +1 -0
  11. package/dist/duration/DurationField.js +214 -0
  12. package/dist/duration/DurationField.js.map +1 -0
  13. package/dist/duration/DurationField.module.js +12 -0
  14. package/dist/duration/DurationField.module.js.map +1 -0
  15. package/dist/duration/index.d.ts +2 -0
  16. package/dist/duration/index.d.ts.map +1 -0
  17. package/dist/duration/index.js +1 -0
  18. package/dist/email/EmailField.js.map +1 -1
  19. package/dist/embed/EmbedField.css +60 -0
  20. package/dist/embed/EmbedField.d.ts +20 -0
  21. package/dist/embed/EmbedField.d.ts.map +1 -0
  22. package/dist/embed/EmbedField.js +246 -0
  23. package/dist/embed/EmbedField.js.map +1 -0
  24. package/dist/embed/EmbedField.module.js +22 -0
  25. package/dist/embed/EmbedField.module.js.map +1 -0
  26. package/dist/embed/index.d.ts +3 -0
  27. package/dist/embed/index.d.ts.map +1 -0
  28. package/dist/embed/index.js +3 -0
  29. package/dist/file/FileField.d.ts.map +1 -1
  30. package/dist/file/FileField.js +167 -77
  31. package/dist/file/FileField.js.map +1 -1
  32. package/dist/group/GroupField.js.map +1 -1
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -1
  36. package/dist/json/JsonField.css +7 -0
  37. package/dist/json/JsonField.d.ts +22 -0
  38. package/dist/json/JsonField.d.ts.map +1 -0
  39. package/dist/json/JsonField.js +207 -0
  40. package/dist/json/JsonField.js.map +1 -0
  41. package/dist/json/JsonField.module.js +8 -0
  42. package/dist/json/JsonField.module.js.map +1 -0
  43. package/dist/json/index.d.ts +2 -0
  44. package/dist/json/index.d.ts.map +1 -0
  45. package/dist/json/index.js +1 -0
  46. package/dist/locales/index.js.map +1 -1
  47. package/dist/localized/LocalizedField.js.map +1 -1
  48. package/dist/location/LocationField.css +54 -0
  49. package/dist/location/LocationField.d.ts +31 -0
  50. package/dist/location/LocationField.d.ts.map +1 -0
  51. package/dist/location/LocationField.js +563 -0
  52. package/dist/location/LocationField.js.map +1 -0
  53. package/dist/location/LocationField.module.js +22 -0
  54. package/dist/location/LocationField.module.js.map +1 -0
  55. package/dist/location/LocationMap.d.ts +25 -0
  56. package/dist/location/LocationMap.d.ts.map +1 -0
  57. package/dist/location/LocationMap.js +205 -0
  58. package/dist/location/LocationMap.js.map +1 -0
  59. package/dist/location/index.d.ts +5 -0
  60. package/dist/location/index.d.ts.map +1 -0
  61. package/dist/location/index.js +4 -0
  62. package/dist/location/leafletCss.d.ts +2 -0
  63. package/dist/location/leafletCss.d.ts.map +1 -0
  64. package/dist/location/leafletCss.js +6 -0
  65. package/dist/location/leafletCss.js.map +1 -0
  66. package/dist/location/nominatim.d.ts +17 -0
  67. package/dist/location/nominatim.d.ts.map +1 -0
  68. package/dist/location/nominatim.js +50 -0
  69. package/dist/location/nominatim.js.map +1 -0
  70. package/dist/location/types.d.ts +40 -0
  71. package/dist/location/types.d.ts.map +1 -0
  72. package/dist/missing/MissingField.d.ts +3 -2
  73. package/dist/missing/MissingField.d.ts.map +1 -1
  74. package/dist/missing/MissingField.js +3 -2
  75. package/dist/missing/MissingField.js.map +1 -1
  76. package/dist/number/NumberField.js.map +1 -1
  77. package/dist/range/RangeField.d.ts +22 -0
  78. package/dist/range/RangeField.d.ts.map +1 -0
  79. package/dist/range/RangeField.js +203 -0
  80. package/dist/range/RangeField.js.map +1 -0
  81. package/dist/range/index.d.ts +2 -0
  82. package/dist/range/index.d.ts.map +1 -0
  83. package/dist/range/index.js +1 -0
  84. package/dist/relation/RelationField.js +485 -145
  85. package/dist/relation/RelationField.js.map +1 -1
  86. package/dist/repeater/RepeaterField.js +118 -34
  87. package/dist/repeater/RepeaterField.js.map +1 -1
  88. package/dist/select/SelectField.js.map +1 -1
  89. package/dist/shared/DefinitionField.js.map +1 -1
  90. package/dist/shared/builtIn.d.ts +1 -0
  91. package/dist/shared/builtIn.d.ts.map +1 -1
  92. package/dist/shared/builtIn.js +16 -1
  93. package/dist/shared/builtIn.js.map +1 -1
  94. package/dist/shared/check.js.map +1 -1
  95. package/dist/shared/context.d.ts +13 -3
  96. package/dist/shared/context.d.ts.map +1 -1
  97. package/dist/shared/context.js +27 -19
  98. package/dist/shared/context.js.map +1 -1
  99. package/dist/shared/cx.js.map +1 -1
  100. package/dist/shared/dates.js.map +1 -1
  101. package/dist/shared/embed.d.ts +19 -0
  102. package/dist/shared/embed.d.ts.map +1 -0
  103. package/dist/shared/embed.js +14 -0
  104. package/dist/shared/embed.js.map +1 -0
  105. package/dist/shared/entry.js.map +1 -1
  106. package/dist/shared/relation.js.map +1 -1
  107. package/dist/slug/SlugField.d.ts.map +1 -1
  108. package/dist/slug/SlugField.js +184 -36
  109. package/dist/slug/SlugField.js.map +1 -1
  110. package/dist/tags/TagsField.d.ts +17 -0
  111. package/dist/tags/TagsField.d.ts.map +1 -0
  112. package/dist/tags/TagsField.js +120 -0
  113. package/dist/tags/TagsField.js.map +1 -0
  114. package/dist/tags/index.d.ts +2 -0
  115. package/dist/tags/index.d.ts.map +1 -0
  116. package/dist/tags/index.js +1 -0
  117. package/dist/tel/TelField.d.ts +11 -0
  118. package/dist/tel/TelField.d.ts.map +1 -0
  119. package/dist/tel/TelField.js +87 -0
  120. package/dist/tel/TelField.js.map +1 -0
  121. package/dist/tel/index.d.ts +2 -0
  122. package/dist/tel/index.d.ts.map +1 -0
  123. package/dist/tel/index.js +1 -0
  124. package/dist/text/TextField.js.map +1 -1
  125. package/dist/textarea/TextAreaField.js.map +1 -1
  126. package/dist/time/TimeField.js +64 -10
  127. package/dist/time/TimeField.js.map +1 -1
  128. package/dist/upload/FilePicker.js +107 -24
  129. package/dist/upload/FilePicker.js.map +1 -1
  130. package/dist/upload/UploadList.js.map +1 -1
  131. package/dist/upload/files.js.map +1 -1
  132. package/dist/upload/useRejectionMessage.js.map +1 -1
  133. package/dist/upload/useUploads.js.map +1 -1
  134. package/dist/uppy/uploader.js.map +1 -1
  135. package/dist/url/UrlField.js +69 -14
  136. package/dist/url/UrlField.js.map +1 -1
  137. package/package.json +41 -4
@@ -3,14 +3,21 @@ import { TextFieldEntry } from "../text/TextField.js";
3
3
  import { ColorFieldEntry } from "../color/ColorField.js";
4
4
  import { DateFieldEntry } from "../date/DateField.js";
5
5
  import { DateTimeFieldEntry } from "../datetime/DateTimeField.js";
6
+ import { DurationFieldEntry } from "../duration/DurationField.js";
6
7
  import { EmailFieldEntry } from "../email/EmailField.js";
8
+ import { EmbedFieldEntry } from "../embed/EmbedField.js";
7
9
  import { FileFieldEntry } from "../file/FileField.js";
8
10
  import { GroupFieldEntry } from "../group/GroupField.js";
11
+ import { JsonFieldEntry } from "../json/JsonField.js";
12
+ import { LocationFieldEntry } from "../location/LocationField.js";
9
13
  import { NumberFieldEntry } from "../number/NumberField.js";
14
+ import { RangeFieldEntry } from "../range/RangeField.js";
10
15
  import { RelationFieldEntry } from "../relation/RelationField.js";
11
16
  import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
12
17
  import { SelectFieldEntry } from "../select/SelectField.js";
13
18
  import { SlugFieldEntry } from "../slug/SlugField.js";
19
+ import { TagsFieldEntry } from "../tags/TagsField.js";
20
+ import { TelFieldEntry } from "../tel/TelField.js";
14
21
  import { TextAreaFieldEntry } from "../textarea/TextAreaField.js";
15
22
  import { TimeFieldEntry } from "../time/TimeField.js";
16
23
  import { UrlFieldEntry } from "../url/UrlField.js";
@@ -20,6 +27,7 @@ import { fr } from "@panneau/intl";
20
27
  * The entries of the built-in field types. `richtext` and `media` come with their plugins
21
28
  * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.
22
29
  * `file` uploads through the upload source of the fields context, or gives the files themselves.
30
+ * `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.
23
31
  */
24
32
  var builtInFields = {
25
33
  text: TextFieldEntry,
@@ -37,7 +45,14 @@ var builtInFields = {
37
45
  file: FileFieldEntry,
38
46
  relation: RelationFieldEntry,
39
47
  group: GroupFieldEntry,
40
- repeater: RepeaterFieldEntry
48
+ repeater: RepeaterFieldEntry,
49
+ tel: TelFieldEntry,
50
+ range: RangeFieldEntry,
51
+ duration: DurationFieldEntry,
52
+ json: JsonFieldEntry,
53
+ tags: TagsFieldEntry,
54
+ embed: EmbedFieldEntry,
55
+ location: LocationFieldEntry
41
56
  };
42
57
  /**
43
58
  * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of
@@ -1 +1 @@
1
- {"version":3,"file":"builtIn.js","names":[],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,gBAAsD;CAC/D,MAAM;CACN,UAAU;CACV,QAAQ;CACR,SAAS;CACT,MAAM;CACN,UAAU;CACV,MAAM;CACN,QAAQ;CACR,OAAO;CACP,KAAK;CACL,OAAO;CACP,MAAM;CACN,MAAM;CACN,UAAU;CACV,OAAO;CACP,UAAU;AACd;;;;;;AAOA,IAAa,eAIT;CACA,IAAI;CACJ,QAAQ;CACR,SAAS,EAAE,GAAG;AAClB"}
1
+ {"version":3,"file":"builtIn.js","names":["fr","BooleanFieldEntry","ColorFieldEntry","DateFieldEntry","DateTimeFieldEntry","DurationFieldEntry","EmailFieldEntry","EmbedFieldEntry","FileFieldEntry","GroupFieldEntry","JsonFieldEntry","LocationFieldEntry","NumberFieldEntry","RangeFieldEntry","RelationFieldEntry","RepeaterFieldEntry","SelectFieldEntry","SlugFieldEntry","TagsFieldEntry","TelFieldEntry","TextFieldEntry","TextAreaFieldEntry","TimeFieldEntry","UrlFieldEntry","FieldEntry","builtInFields","Readonly","Record","text","textarea","number","boolean","date","datetime","time","select","email","url","color","slug","file","relation","group","repeater","tel","range","duration","json","tags","embed","location","fieldsPlugin","id","fields","locales"],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { DurationFieldEntry } from '../duration/DurationField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { EmbedFieldEntry } from '../embed/EmbedField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { JsonFieldEntry } from '../json/JsonField';\nimport { LocationFieldEntry } from '../location/LocationField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RangeFieldEntry } from '../range/RangeField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TagsFieldEntry } from '../tags/TagsField';\nimport { TelFieldEntry } from '../tel/TelField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n * `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n tel: TelFieldEntry,\n range: RangeFieldEntry,\n duration: DurationFieldEntry,\n json: JsonFieldEntry,\n tags: TagsFieldEntry,\n embed: EmbedFieldEntry,\n location: LocationFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAayB,gBAAsD;CAC/DG,MAAMR;CACNS,UAAUR;CACVS,QAAQlB;CACRmB,SAAS9B;CACT+B,MAAM7B;CACN8B,UAAU7B;CACV8B,MAAMZ;CACNa,QAAQnB;CACRoB,OAAO9B;CACP+B,KAAKd;CACLe,OAAOpC;CACPqC,MAAMtB;CACNuB,MAAMhC;CACNiC,UAAU3B;CACV4B,OAAOjC;CACPkC,UAAU5B;CACV6B,KAAKzB;CACL0B,OAAOhC;CACPiC,UAAUzC;CACV0C,MAAMrC;CACNsC,MAAM9B;CACN+B,OAAO1C;CACP2C,UAAUvC;AACd;;;;;;AAOA,IAAawC,eAIT;CACAC,IAAI;CACJC,QAAQ5B;CACR6B,SAAS,EAAEtD,GAAG;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","names":[],"sources":["../../src/shared/check.ts"],"sourcesContent":["import type { FieldCheckRequest, FieldCheckResponse } from '@panneau/protocol';\n\n/**\n * Where fields with `check` check their value as it is typed: whether a slug is available, and\n * its URL. The value's locale and the form's values come with each check.\n */\nexport interface FieldCheckSource {\n check(\n field: string,\n request: { value: string; locale?: string; values?: Record<string, unknown> },\n options: { signal: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/** What `createFieldCheckSource()` needs from an adapter: the `checkField()` of `@panneau/data`. */\nexport interface FieldCheckAdapter {\n checkField?(\n resource: string,\n field: string,\n request: FieldCheckRequest,\n options?: { signal?: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/**\n * The check source of a form of a resource, through an adapter (`POST\n * /resources/{resource}/fields/{field}/check`): `id` is the item being edited, or null when\n * creating one. Null when the adapter can't check.\n */\nexport function createFieldCheckSource(\n adapter: FieldCheckAdapter,\n resource: string,\n id: string | null = null,\n): FieldCheckSource | null {\n const { checkField } = adapter;\n if (checkField === undefined) {\n return null;\n }\n return {\n check: (field, request, { signal }) =>\n checkField.call(adapter, resource, field, { ...request, id }, { signal }),\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,uBACZ,SACA,UACA,KAAoB,MACG;CACvB,MAAM,EAAE,eAAe;CACvB,IAAI,eAAe,KAAA,GACf,OAAO;CAEX,OAAO,EACH,QAAQ,OAAO,SAAS,EAAE,aACtB,WAAW,KAAK,SAAS,UAAU,OAAO;EAAE,GAAG;EAAS;CAAG,GAAG,EAAE,OAAO,CAAC,EAChF;AACJ"}
1
+ {"version":3,"file":"check.js","names":["FieldCheckRequest","FieldCheckResponse","FieldCheckSource","check","field","request","value","locale","values","Record","options","signal","AbortSignal","Promise","FieldCheckAdapter","checkField","resource","createFieldCheckSource","adapter","id","undefined","call"],"sources":["../../src/shared/check.ts"],"sourcesContent":["import type { FieldCheckRequest, FieldCheckResponse } from '@panneau/protocol';\n\n/**\n * Where fields with `check` check their value as it is typed: whether a slug is available, and\n * its URL. The value's locale and the form's values come with each check.\n */\nexport interface FieldCheckSource {\n check(\n field: string,\n request: { value: string; locale?: string; values?: Record<string, unknown> },\n options: { signal: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/** What `createFieldCheckSource()` needs from an adapter: the `checkField()` of `@panneau/data`. */\nexport interface FieldCheckAdapter {\n checkField?(\n resource: string,\n field: string,\n request: FieldCheckRequest,\n options?: { signal?: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/**\n * The check source of a form of a resource, through an adapter (`POST\n * /resources/{resource}/fields/{field}/check`): `id` is the item being edited, or null when\n * creating one. Null when the adapter can't check.\n */\nexport function createFieldCheckSource(\n adapter: FieldCheckAdapter,\n resource: string,\n id: string | null = null,\n): FieldCheckSource | null {\n const { checkField } = adapter;\n if (checkField === undefined) {\n return null;\n }\n return {\n check: (field, request, { signal }) =>\n checkField.call(adapter, resource, field, { ...request, id }, { signal }),\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAgBiB,uBACZC,SACAF,UACAG,KAAoB,MACG;CACvB,MAAM,EAAEJ,eAAeG;CACvB,IAAIH,eAAeK,KAAAA,GACf,OAAO;CAEX,OAAO,EACHjB,QAAQC,OAAOC,SAAS,EAAEM,aACtBI,WAAWM,KAAKH,SAASF,UAAUZ,OAAO;EAAE,GAAGC;EAASc;CAAG,GAAG,EAAER,OAAO,CAAC,EAChF;AACJ"}
@@ -1,7 +1,9 @@
1
1
  import { type ComponentType, type ReactNode } from 'react';
2
2
  import type { Field } from '@panneau/protocol';
3
+ import type { MapsConfig } from '../location/types';
3
4
  import type { UploadSource } from '../upload/types';
4
5
  import type { FieldCheckSource } from './check';
6
+ import type { EmbedSource } from './embed';
5
7
  import type { RelationSource } from './relation';
6
8
  import type { FieldEntry } from './types';
7
9
  /** What a binding gives a field: its value, handlers and errors at a path. */
@@ -41,6 +43,10 @@ export interface FieldsContextValue {
41
43
  uploadSource: UploadSource | null;
42
44
  /** Where fields with `check` check their value, such as a slug's availability. */
43
45
  checkSource: FieldCheckSource | null;
46
+ /** Where `embed` fields get what a URL embeds. Without one, they keep the URL alone. */
47
+ embedSource: EmbedSource | null;
48
+ /** The tiles and the address search of `location` fields. */
49
+ maps: MapsConfig | null;
44
50
  binding: FieldBinding | null;
45
51
  }
46
52
  /** The fields context of the closest `FieldsProvider`. */
@@ -54,15 +60,19 @@ export interface FieldsProviderProps {
54
60
  uploadSource?: UploadSource | null;
55
61
  /** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */
56
62
  checkSource?: FieldCheckSource | null;
63
+ /** `createEmbedSource(adapter)`. */
64
+ embedSource?: EmbedSource | null;
65
+ /** The tiles and the address search of `location` fields. */
66
+ maps?: MapsConfig | null;
57
67
  binding?: FieldBinding | null;
58
68
  children?: ReactNode;
59
69
  }
60
70
  /**
61
71
  * Provides what fields rendered from a definition need: the components of each type, the locales
62
- * of localized values, a relation source, an upload source, a check source and a binding. Values not given come from the parent
63
- * provider.
72
+ * of localized values, the sources of relations, uploads, checks and embeds, the maps of
73
+ * locations, and a binding. Values not given come from the parent provider.
64
74
  */
65
- export declare function FieldsProvider({ components, locales, relationSource, uploadSource, checkSource, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
75
+ export declare function FieldsProvider({ components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
66
76
  /** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
67
77
  export declare function getParentPath(path: string): string;
68
78
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/shared/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,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C;IAC5B,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,yFAAyF;IACzF,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,gFAAgF;IAChF,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,oCAAoC;IACpC,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC3B,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,IAAI,EACJ,OAAO,EACP,QAAQ,GACX,EAAE,mBAAmB,+BAcrB;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD"}
@@ -8,6 +8,8 @@ var FieldsContext = createContext({
8
8
  relationSource: null,
9
9
  uploadSource: null,
10
10
  checkSource: null,
11
+ embedSource: null,
12
+ maps: null,
11
13
  binding: null
12
14
  });
13
15
  /** The fields context of the closest `FieldsProvider`. */
@@ -16,12 +18,12 @@ function useFieldsContext() {
16
18
  }
17
19
  /**
18
20
  * Provides what fields rendered from a definition need: the components of each type, the locales
19
- * of localized values, a relation source, an upload source, a check source and a binding. Values not given come from the parent
20
- * provider.
21
+ * of localized values, the sources of relations, uploads, checks and embeds, the maps of
22
+ * locations, and a binding. Values not given come from the parent provider.
21
23
  */
22
24
  function FieldsProvider(t0) {
23
- const $ = c(13);
24
- const { components, locales, relationSource, uploadSource, checkSource, binding, children } = t0;
25
+ const $ = c(15);
26
+ const { components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children } = t0;
25
27
  const parent = use(FieldsContext);
26
28
  let t1;
27
29
  if ($[0] !== components || $[1] !== parent.components) {
@@ -37,16 +39,20 @@ function FieldsProvider(t0) {
37
39
  const t3 = relationSource === void 0 ? parent.relationSource : relationSource;
38
40
  const t4 = uploadSource === void 0 ? parent.uploadSource : uploadSource;
39
41
  const t5 = checkSource === void 0 ? parent.checkSource : checkSource;
40
- const t6 = binding === void 0 ? parent.binding : binding;
41
- let t7;
42
- if ($[3] !== t1 || $[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== t5 || $[8] !== t6) {
43
- t7 = {
42
+ const t6 = embedSource === void 0 ? parent.embedSource : embedSource;
43
+ const t7 = maps === void 0 ? parent.maps : maps;
44
+ const t8 = binding === void 0 ? parent.binding : binding;
45
+ let t9;
46
+ if ($[3] !== t1 || $[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== t5 || $[8] !== t6 || $[9] !== t7 || $[10] !== t8) {
47
+ t9 = {
44
48
  components: t1,
45
49
  locales: t2,
46
50
  relationSource: t3,
47
51
  uploadSource: t4,
48
52
  checkSource: t5,
49
- binding: t6
53
+ embedSource: t6,
54
+ maps: t7,
55
+ binding: t8
50
56
  };
51
57
  $[3] = t1;
52
58
  $[4] = t2;
@@ -55,19 +61,21 @@ function FieldsProvider(t0) {
55
61
  $[7] = t5;
56
62
  $[8] = t6;
57
63
  $[9] = t7;
58
- } else t7 = $[9];
59
- const value = t7;
60
- let t8;
61
- if ($[10] !== children || $[11] !== value) {
62
- t8 = /* @__PURE__ */ jsx(FieldsContext, {
64
+ $[10] = t8;
65
+ $[11] = t9;
66
+ } else t9 = $[11];
67
+ const value = t9;
68
+ let t10;
69
+ if ($[12] !== children || $[13] !== value) {
70
+ t10 = /* @__PURE__ */ jsx(FieldsContext, {
63
71
  value,
64
72
  children
65
73
  });
66
- $[10] = children;
67
- $[11] = value;
68
- $[12] = t8;
69
- } else t8 = $[12];
70
- return t8;
74
+ $[12] = children;
75
+ $[13] = value;
76
+ $[14] = t10;
77
+ } else t10 = $[14];
78
+ return t10;
71
79
  }
72
80
  /** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
73
81
  function getParentPath(path) {
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["value","children","_c"],"sources":["../../src/shared/context.tsx"],"sourcesContent":["import { type ComponentType, type ReactNode, createContext, use } from 'react';\n\nimport type { Field } from '@panneau/protocol';\n\nimport type { UploadSource } from '../upload/types';\nimport type { FieldCheckSource } from './check';\nimport type { RelationSource } from './relation';\nimport type { FieldEntry } from './types';\n\n/** What a binding gives a field: its value, handlers and errors at a path. */\nexport interface BoundFieldProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n}\n\n/** Props of a binding: it decides whether a field shows, and where its value comes from. */\nexport interface FieldBindingProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** Dot path of the object the field belongs to: `''` at the top, `blocks.2` in a block. */\n parentPath: string;\n /** Renders the field with its bound value. */\n render: (bound: BoundFieldProps) => ReactNode;\n}\n\n/**\n * Binds nested fields (in groups, blocks and localized values) to a store by path, instead of the\n * value and `onChange` of their parent. `@panneau/forms` binds them to its form state, so that\n * every value is set, validated and shown in error by its own path.\n */\nexport type FieldBinding = ComponentType<FieldBindingProps>;\n\nexport interface FieldsContextValue {\n /** Registry entries, by field type, over the built-in ones. */\n components: Readonly<Record<string, FieldEntry>>;\n /** Locales of localized values, in order. */\n locales: readonly string[];\n /** Where relation fields search for items. */\n relationSource: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Without one, they give the\n * files themselves.\n */\n uploadSource: UploadSource | null;\n /** Where fields with `check` check their value, such as a slug's availability. */\n checkSource: FieldCheckSource | null;\n binding: FieldBinding | null;\n}\n\nconst FieldsContext = createContext<FieldsContextValue>({\n components: {},\n locales: [],\n relationSource: null,\n uploadSource: null,\n checkSource: null,\n binding: null,\n});\n\n/** The fields context of the closest `FieldsProvider`. */\nexport function useFieldsContext(): FieldsContextValue {\n return use(FieldsContext);\n}\n\nexport interface FieldsProviderProps {\n /** Registry entries by type, added over those of a parent provider. */\n components?: Readonly<Record<string, FieldEntry>>;\n locales?: readonly string[];\n relationSource?: RelationSource | null;\n /** Make it once, outside of render: fields make an uploader for each source they get. */\n uploadSource?: UploadSource | null;\n /** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */\n checkSource?: FieldCheckSource | null;\n binding?: FieldBinding | null;\n children?: ReactNode;\n}\n\n/**\n * Provides what fields rendered from a definition need: the components of each type, the locales\n * of localized values, a relation source, an upload source, a check source and a binding. Values not given come from the parent\n * provider.\n */\nexport function FieldsProvider({\n components,\n locales,\n relationSource,\n uploadSource,\n checkSource,\n binding,\n children,\n}: FieldsProviderProps) {\n const parent = use(FieldsContext);\n const value: FieldsContextValue = {\n components:\n components !== undefined ? { ...parent.components, ...components } : parent.components,\n locales: locales ?? parent.locales,\n relationSource: relationSource === undefined ? parent.relationSource : relationSource,\n uploadSource: uploadSource === undefined ? parent.uploadSource : uploadSource,\n checkSource: checkSource === undefined ? parent.checkSource : checkSource,\n binding: binding === undefined ? parent.binding : binding,\n };\n return <FieldsContext value={value}>{children}</FieldsContext>;\n}\n\n/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */\nexport function getParentPath(path: string): string {\n const index = path.lastIndexOf('.');\n return index === -1 ? '' : path.slice(0, index);\n}\n"],"mappings":";;;;AAoDA,IAAM,gBAAgB,cAAkC;CACpD,YAAY,CAAC;CACb,SAAS,CAAA;CACT,gBAAgB;CAChB,cAAc;CACd,aAAa;CACb,SAAS;AACb,CAAC;;AAGD,SAAgB,mBAAuC;CACnD,OAAO,IAAI,aAAa;AAC5B;;;;;;AAoBA,SAAO,eAAA,IAAA;CAAA,MAAA,IAAAE,EAAA,EAAA;CAAwB,MAAA,EAAA,YAAA,SAAA,gBAAA,cAAA,aAAA,SAAA,aAAA;CAS3B,MAAA,SAAe,IAAI,aAAa;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,cAAA,EAAA,OAAA,OAAA,YAAA;EAG1B,KAAA,eAAe,KAAA,IAAf;GAAA,GAAgC,OAAM;GAAW,GAAK;EAA+B,IAAhB,OAAM;EAAW,EAAA,KAAA;EAAA,EAAA,KAAA,OAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CACjF,MAAA,KAAA,WAAW,OAAM;CACV,MAAA,KAAA,mBAAmB,KAAA,IAAY,OAAM,iBAArC;CACF,MAAA,KAAA,iBAAiB,KAAA,IAAY,OAAM,eAAnC;CACD,MAAA,KAAA,gBAAgB,KAAA,IAAY,OAAM,cAAlC;CACJ,MAAA,KAAA,YAAY,KAAA,IAAY,OAAM,UAA9B;CAAgD,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA,EAAA,OAAA,MAAA,EAAA,OAAA,MAAA,EAAA,OAAA,MAAA,EAAA,OAAA,MAAA,EAAA,OAAA,IAAA;EAP3B,KAAA;GAAA,YAE1B;GAAsF,SACjF;GAAyB,gBAClB;GAAqE,cACvE;GAA+D,aAChE;GAA4D,SAChE;EACb;EAAC,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CARD,MAAA,QAAkC;CAQhC,IAAA;CAAA,IAAA,EAAA,QAAA,YAAA,EAAA,QAAA,OAAA;EACK,KAAA,oBAAC,eAAD;GAAsB;GAAQ;EAAhB,CAAA;EAAyC,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAAvD;AAAuD;;AAIlE,SAAgB,cAAc,MAAsB;CAChD,MAAM,QAAQ,KAAK,YAAY,GAAG;CAClC,OAAO,UAAU,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK;AAClD"}
1
+ {"version":3,"file":"context.js","names":["ComponentType","ReactNode","createContext","use","Field","MapsConfig","UploadSource","FieldCheckSource","EmbedSource","RelationSource","FieldEntry","BoundFieldProps","value","onChange","onBlur","errors","FieldBindingProps","field","path","parentPath","render","bound","FieldBinding","FieldsContextValue","components","Readonly","Record","locales","relationSource","uploadSource","checkSource","embedSource","maps","binding","FieldsContext","useFieldsContext","FieldsProviderProps","children","FieldsProvider","t0","$","_c","parent","t1","undefined","t2","t3","t4","t5","t6","t7","t8","t9","t10","getParentPath","index","lastIndexOf","slice","_c"],"sources":["../../src/shared/context.tsx"],"sourcesContent":["import { type ComponentType, type ReactNode, createContext, use } from 'react';\n\nimport type { Field } from '@panneau/protocol';\n\nimport type { MapsConfig } from '../location/types';\nimport type { UploadSource } from '../upload/types';\nimport type { FieldCheckSource } from './check';\nimport type { EmbedSource } from './embed';\nimport type { RelationSource } from './relation';\nimport type { FieldEntry } from './types';\n\n/** What a binding gives a field: its value, handlers and errors at a path. */\nexport interface BoundFieldProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n}\n\n/** Props of a binding: it decides whether a field shows, and where its value comes from. */\nexport interface FieldBindingProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** Dot path of the object the field belongs to: `''` at the top, `blocks.2` in a block. */\n parentPath: string;\n /** Renders the field with its bound value. */\n render: (bound: BoundFieldProps) => ReactNode;\n}\n\n/**\n * Binds nested fields (in groups, blocks and localized values) to a store by path, instead of the\n * value and `onChange` of their parent. `@panneau/forms` binds them to its form state, so that\n * every value is set, validated and shown in error by its own path.\n */\nexport type FieldBinding = ComponentType<FieldBindingProps>;\n\nexport interface FieldsContextValue {\n /** Registry entries, by field type, over the built-in ones. */\n components: Readonly<Record<string, FieldEntry>>;\n /** Locales of localized values, in order. */\n locales: readonly string[];\n /** Where relation fields search for items. */\n relationSource: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Without one, they give the\n * files themselves.\n */\n uploadSource: UploadSource | null;\n /** Where fields with `check` check their value, such as a slug's availability. */\n checkSource: FieldCheckSource | null;\n /** Where `embed` fields get what a URL embeds. Without one, they keep the URL alone. */\n embedSource: EmbedSource | null;\n /** The tiles and the address search of `location` fields. */\n maps: MapsConfig | null;\n binding: FieldBinding | null;\n}\n\nconst FieldsContext = createContext<FieldsContextValue>({\n components: {},\n locales: [],\n relationSource: null,\n uploadSource: null,\n checkSource: null,\n embedSource: null,\n maps: null,\n binding: null,\n});\n\n/** The fields context of the closest `FieldsProvider`. */\nexport function useFieldsContext(): FieldsContextValue {\n return use(FieldsContext);\n}\n\nexport interface FieldsProviderProps {\n /** Registry entries by type, added over those of a parent provider. */\n components?: Readonly<Record<string, FieldEntry>>;\n locales?: readonly string[];\n relationSource?: RelationSource | null;\n /** Make it once, outside of render: fields make an uploader for each source they get. */\n uploadSource?: UploadSource | null;\n /** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */\n checkSource?: FieldCheckSource | null;\n /** `createEmbedSource(adapter)`. */\n embedSource?: EmbedSource | null;\n /** The tiles and the address search of `location` fields. */\n maps?: MapsConfig | null;\n binding?: FieldBinding | null;\n children?: ReactNode;\n}\n\n/**\n * Provides what fields rendered from a definition need: the components of each type, the locales\n * of localized values, the sources of relations, uploads, checks and embeds, the maps of\n * locations, and a binding. Values not given come from the parent provider.\n */\nexport function FieldsProvider({\n components,\n locales,\n relationSource,\n uploadSource,\n checkSource,\n embedSource,\n maps,\n binding,\n children,\n}: FieldsProviderProps) {\n const parent = use(FieldsContext);\n const value: FieldsContextValue = {\n components:\n components !== undefined ? { ...parent.components, ...components } : parent.components,\n locales: locales ?? parent.locales,\n relationSource: relationSource === undefined ? parent.relationSource : relationSource,\n uploadSource: uploadSource === undefined ? parent.uploadSource : uploadSource,\n checkSource: checkSource === undefined ? parent.checkSource : checkSource,\n embedSource: embedSource === undefined ? parent.embedSource : embedSource,\n maps: maps === undefined ? parent.maps : maps,\n binding: binding === undefined ? parent.binding : binding,\n };\n return <FieldsContext value={value}>{children}</FieldsContext>;\n}\n\n/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */\nexport function getParentPath(path: string): string {\n const index = path.lastIndexOf('.');\n return index === -1 ? '' : path.slice(0, index);\n}\n"],"mappings":";;;;AA0DA,IAAMkC,gBAAgBhC,cAAkC;CACpDsB,YAAY,CAAC;CACbG,SAAS,CAAA;CACTC,gBAAgB;CAChBC,cAAc;CACdC,aAAa;CACbC,aAAa;CACbC,MAAM;CACNC,SAAS;AACb,CAAC;;AAGD,SAAgBE,mBAAuC;CACnD,OAAOhC,IAAI+B,aAAa;AAC5B;;;;;;AAwBA,SAAOI,eAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAwB,MAAA,EAAAjB,YAAAG,SAAAC,gBAAAC,cAAAC,aAAAC,aAAAC,MAAAC,SAAAI,aAAAE;CAW3B,MAAAG,SAAevC,IAAI+B,aAAa;CAAE,IAAAS;CAAA,IAAAH,EAAA,OAAAhB,cAAAgB,EAAA,OAAAE,OAAAlB,YAAA;EAG1BmB,KAAAnB,eAAeoB,KAAAA,IAAf;GAAA,GAAgCF,OAAMlB;GAAW,GAAKA;EAA+B,IAAhBkB,OAAMlB;EAAWgB,EAAA,KAAAhB;EAAAgB,EAAA,KAAAE,OAAAlB;EAAAgB,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CACjF,MAAAK,KAAAlB,WAAWe,OAAMf;CACV,MAAAmB,KAAAlB,mBAAmBgB,KAAAA,IAAYF,OAAMd,iBAArCA;CACF,MAAAmB,KAAAlB,iBAAiBe,KAAAA,IAAYF,OAAMb,eAAnCA;CACD,MAAAmB,KAAAlB,gBAAgBc,KAAAA,IAAYF,OAAMZ,cAAlCA;CACA,MAAAmB,KAAAlB,gBAAgBa,KAAAA,IAAYF,OAAMX,cAAlCA;CACP,MAAAmB,KAAAlB,SAASY,KAAAA,IAAYF,OAAMV,OAA3BA;CACG,MAAAmB,KAAAlB,YAAYW,KAAAA,IAAYF,OAAMT,UAA9BA;CAAgD,IAAAmB;CAAA,IAAAZ,EAAA,OAAAG,MAAAH,EAAA,OAAAK,MAAAL,EAAA,OAAAM,MAAAN,EAAA,OAAAO,MAAAP,EAAA,OAAAQ,MAAAR,EAAA,OAAAS,MAAAT,EAAA,OAAAU,MAAAV,EAAA,QAAAW,IAAA;EAT3BC,KAAA;GAAA5B,YAE1BmB;GAAsFhB,SACjFkB;GAAyBjB,gBAClBkB;GAAqEjB,cACvEkB;GAA+DjB,aAChEkB;GAA4DjB,aAC5DkB;GAA4DjB,MACnEkB;GAAuCjB,SACpCkB;EACb;EAACX,EAAA,KAAAG;EAAAH,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;EAAAT,EAAA,KAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAVD,MAAA5B,QAAkCwC;CAUhC,IAAAC;CAAA,IAAAb,EAAA,QAAAH,YAAAG,EAAA,QAAA5B,OAAA;EACKyC,MAAA,oBAAC,eAAD;GAAsBzC;GAAQyB;EAAhB,CAAA;EAAyCG,EAAA,MAAAH;EAAAG,EAAA,MAAA5B;EAAA4B,EAAA,MAAAa;CAAA,OAAAA,MAAAb,EAAA;CAAA,OAAvDa;AAAuD;;AAIlE,SAAgBC,cAAcpC,MAAsB;CAChD,MAAMqC,QAAQrC,KAAKsC,YAAY,GAAG;CAClC,OAAOD,UAAU,KAAK,KAAKrC,KAAKuC,MAAM,GAAGF,KAAK;AAClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"cx.js","names":[],"sources":["../../src/shared/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,SAAgB,GAAG,GAAG,YAA2D;CAC7E,OAAO,WAAW,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AAC9C"}
1
+ {"version":3,"file":"cx.js","names":["cx","classNames","filter","Boolean","join"],"sources":["../../src/shared/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,SAAgBA,GAAG,GAAGC,YAA2D;CAC7E,OAAOA,WAAWC,OAAOC,OAAO,CAAC,CAACC,KAAK,GAAG;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"dates.js","names":[],"sources":["../../src/shared/dates.ts"],"sourcesContent":["import {\n type CalendarDate,\n type CalendarDateTime,\n type Time,\n type ZonedDateTime,\n getLocalTimeZone,\n parseAbsolute,\n parseDate,\n parseDateTime,\n parseTime,\n} from '@internationalized/date';\n\n/** `2026-10-15`, or the date of a date-time. */\nexport function toCalendarDate(value: string | null | undefined): CalendarDate | null {\n const match = value?.match(/^(\\d{4}-\\d{2}-\\d{2})/);\n if (match?.[1] === undefined) {\n return null;\n }\n try {\n return parseDate(match[1]);\n } catch {\n return null;\n }\n}\n\nconst OFFSET = /(?:Z|[+-]\\d{2}:?\\d{2})$/i;\n\n/**\n * A date-time: with an offset or `Z` (`2026-10-15T13:30:00Z`), in the given time zone; without one\n * (`2026-10-15 09:30:00`), as is.\n */\nexport function toDateTime(\n value: string | null | undefined,\n timeZone: string = getLocalTimeZone(),\n): ZonedDateTime | CalendarDateTime | null {\n if (value === null || value === undefined || value.trim() === '') {\n return null;\n }\n const iso = value.trim().replace(' ', 'T');\n try {\n return OFFSET.test(iso) ? parseAbsolute(iso, timeZone) : parseDateTime(iso);\n } catch {\n return null;\n }\n}\n\n/** Writes a date-time: in UTC (`…Z`) when it has a time zone, without an offset otherwise. */\nexport function fromDateTime(value: ZonedDateTime | CalendarDateTime): string {\n return 'timeZone' in value\n ? value.toAbsoluteString().replace(/\\.000Z$/, 'Z')\n : value.toString();\n}\n\n/** `09:30` or `09:30:15`. */\nexport function toTime(value: string | null | undefined): Time | null {\n if (value === null || value === undefined || !/^\\d{1,2}:\\d{2}(:\\d{2})?/.test(value)) {\n return null;\n }\n try {\n return parseTime(value.length < 5 ? `0${value}` : value);\n } catch {\n return null;\n }\n}\n\n/** Writes a time as `HH:mm`, or `HH:mm:ss` with seconds. */\nexport function fromTime(\n value: Pick<Time, 'hour' | 'minute' | 'second'>,\n withSeconds = false,\n): string {\n const pad = (part: number) => String(part).padStart(2, '0');\n const time = `${pad(value.hour)}:${pad(value.minute)}`;\n return withSeconds ? `${time}:${pad(value.second)}` : time;\n}\n"],"mappings":";;;AAaA,SAAgB,eAAe,OAAuD;CAClF,MAAM,QAAQ,OAAO,MAAM,sBAAsB;CACjD,IAAI,QAAQ,OAAO,KAAA,GACf,OAAO;CAEX,IAAI;EACA,OAAO,UAAU,MAAM,EAAE;CAC7B,QAAQ;EACJ,OAAO;CACX;AACJ;AAEA,IAAM,SAAS;;;;;AAMf,SAAgB,WACZ,OACA,WAAmB,iBAAiB,GACG;CACvC,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,MAAM,KAAK,MAAM,IAC1D,OAAO;CAEX,MAAM,MAAM,MAAM,KAAK,CAAC,CAAC,QAAQ,KAAK,GAAG;CACzC,IAAI;EACA,OAAO,OAAO,KAAK,GAAG,IAAI,cAAc,KAAK,QAAQ,IAAI,cAAc,GAAG;CAC9E,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAgB,aAAa,OAAiD;CAC1E,OAAO,cAAc,QACf,MAAM,iBAAiB,CAAC,CAAC,QAAQ,WAAW,GAAG,IAC/C,MAAM,SAAS;AACzB;;AAGA,SAAgB,OAAO,OAA+C;CAClE,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,CAAC,0BAA0B,KAAK,KAAK,GAC9E,OAAO;CAEX,IAAI;EACA,OAAO,UAAU,MAAM,SAAS,IAAI,IAAI,UAAU,KAAK;CAC3D,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAgB,SACZ,OACA,cAAc,OACR;CACN,MAAM,OAAO,SAAiB,OAAO,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;CAC1D,MAAM,OAAO,GAAG,IAAI,MAAM,IAAI,EAAC,GAAI,IAAI,MAAM,MAAM;CACnD,OAAO,cAAc,GAAG,KAAI,GAAI,IAAI,MAAM,MAAM,MAAM;AAC1D"}
1
+ {"version":3,"file":"dates.js","names":["CalendarDate","CalendarDateTime","Time","ZonedDateTime","getLocalTimeZone","parseAbsolute","parseDate","parseDateTime","parseTime","toCalendarDate","value","match","undefined","OFFSET","toDateTime","timeZone","trim","iso","replace","test","fromDateTime","toAbsoluteString","toString","toTime","length","fromTime","Pick","withSeconds","pad","part","String","padStart","time","hour","minute","second"],"sources":["../../src/shared/dates.ts"],"sourcesContent":["import {\n type CalendarDate,\n type CalendarDateTime,\n type Time,\n type ZonedDateTime,\n getLocalTimeZone,\n parseAbsolute,\n parseDate,\n parseDateTime,\n parseTime,\n} from '@internationalized/date';\n\n/** `2026-10-15`, or the date of a date-time. */\nexport function toCalendarDate(value: string | null | undefined): CalendarDate | null {\n const match = value?.match(/^(\\d{4}-\\d{2}-\\d{2})/);\n if (match?.[1] === undefined) {\n return null;\n }\n try {\n return parseDate(match[1]);\n } catch {\n return null;\n }\n}\n\nconst OFFSET = /(?:Z|[+-]\\d{2}:?\\d{2})$/i;\n\n/**\n * A date-time: with an offset or `Z` (`2026-10-15T13:30:00Z`), in the given time zone; without one\n * (`2026-10-15 09:30:00`), as is.\n */\nexport function toDateTime(\n value: string | null | undefined,\n timeZone: string = getLocalTimeZone(),\n): ZonedDateTime | CalendarDateTime | null {\n if (value === null || value === undefined || value.trim() === '') {\n return null;\n }\n const iso = value.trim().replace(' ', 'T');\n try {\n return OFFSET.test(iso) ? parseAbsolute(iso, timeZone) : parseDateTime(iso);\n } catch {\n return null;\n }\n}\n\n/** Writes a date-time: in UTC (`…Z`) when it has a time zone, without an offset otherwise. */\nexport function fromDateTime(value: ZonedDateTime | CalendarDateTime): string {\n return 'timeZone' in value\n ? value.toAbsoluteString().replace(/\\.000Z$/, 'Z')\n : value.toString();\n}\n\n/** `09:30` or `09:30:15`. */\nexport function toTime(value: string | null | undefined): Time | null {\n if (value === null || value === undefined || !/^\\d{1,2}:\\d{2}(:\\d{2})?/.test(value)) {\n return null;\n }\n try {\n return parseTime(value.length < 5 ? `0${value}` : value);\n } catch {\n return null;\n }\n}\n\n/** Writes a time as `HH:mm`, or `HH:mm:ss` with seconds. */\nexport function fromTime(\n value: Pick<Time, 'hour' | 'minute' | 'second'>,\n withSeconds = false,\n): string {\n const pad = (part: number) => String(part).padStart(2, '0');\n const time = `${pad(value.hour)}:${pad(value.minute)}`;\n return withSeconds ? `${time}:${pad(value.second)}` : time;\n}\n"],"mappings":";;;AAaA,SAAgBS,eAAeC,OAAuD;CAClF,MAAMC,QAAQD,OAAOC,MAAM,sBAAsB;CACjD,IAAIA,QAAQ,OAAOC,KAAAA,GACf,OAAO;CAEX,IAAI;EACA,OAAON,UAAUK,MAAM,EAAE;CAC7B,QAAQ;EACJ,OAAO;CACX;AACJ;AAEA,IAAME,SAAS;;;;;AAMf,SAAgBC,WACZJ,OACAK,WAAmBX,iBAAiB,GACG;CACvC,IAAIM,UAAU,QAAQA,UAAUE,KAAAA,KAAaF,MAAMM,KAAK,MAAM,IAC1D,OAAO;CAEX,MAAMC,MAAMP,MAAMM,KAAK,CAAC,CAACE,QAAQ,KAAK,GAAG;CACzC,IAAI;EACA,OAAOL,OAAOM,KAAKF,GAAG,IAAIZ,cAAcY,KAAKF,QAAQ,IAAIR,cAAcU,GAAG;CAC9E,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAgBG,aAAaV,OAAiD;CAC1E,OAAO,cAAcA,QACfA,MAAMW,iBAAiB,CAAC,CAACH,QAAQ,WAAW,GAAG,IAC/CR,MAAMY,SAAS;AACzB;;AAGA,SAAgBC,OAAOb,OAA+C;CAClE,IAAIA,UAAU,QAAQA,UAAUE,KAAAA,KAAa,CAAC,0BAA0BO,KAAKT,KAAK,GAC9E,OAAO;CAEX,IAAI;EACA,OAAOF,UAAUE,MAAMc,SAAS,IAAI,IAAId,UAAUA,KAAK;CAC3D,QAAQ;EACJ,OAAO;CACX;AACJ;;AAGA,SAAgBe,SACZf,OACAiB,cAAc,OACR;CACN,MAAMC,OAAOC,SAAiBC,OAAOD,IAAI,CAAC,CAACE,SAAS,GAAG,GAAG;CAC1D,MAAMC,OAAO,GAAGJ,IAAIlB,MAAMuB,IAAI,EAAC,GAAIL,IAAIlB,MAAMwB,MAAM;CACnD,OAAOP,cAAc,GAAGK,KAAI,GAAIJ,IAAIlB,MAAMyB,MAAM,MAAMH;AAC1D"}
@@ -0,0 +1,19 @@
1
+ import type { EmbedValue } from '@panneau/protocol';
2
+ /** Where `embed` fields get what a URL embeds: the backend, from the provider's oEmbed. */
3
+ export interface EmbedSource {
4
+ resolve(url: string, options: {
5
+ signal: AbortSignal;
6
+ }): Promise<EmbedValue>;
7
+ }
8
+ /** What `createEmbedSource()` needs from an adapter: the `resolveEmbed()` of `@panneau/data`. */
9
+ export interface EmbedAdapter {
10
+ resolveEmbed?(url: string, options?: {
11
+ signal?: AbortSignal;
12
+ }): Promise<EmbedValue>;
13
+ }
14
+ /**
15
+ * The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve
16
+ * embeds: `embed` fields then keep the URL alone.
17
+ */
18
+ export declare function createEmbedSource(adapter: EmbedAdapter): EmbedSource | null;
19
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/shared/embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IACxB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/E;AAED,iGAAiG;AACjG,MAAM,WAAW,YAAY;IACzB,YAAY,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,GAAG,IAAI,CAM3E"}
@@ -0,0 +1,14 @@
1
+ //#region src/shared/embed.ts
2
+ /**
3
+ * The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve
4
+ * embeds: `embed` fields then keep the URL alone.
5
+ */
6
+ function createEmbedSource(adapter) {
7
+ const { resolveEmbed } = adapter;
8
+ if (resolveEmbed === void 0) return null;
9
+ return { resolve: (url, { signal }) => resolveEmbed.call(adapter, url, { signal }) };
10
+ }
11
+ //#endregion
12
+ export { createEmbedSource };
13
+
14
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.js","names":["EmbedValue","EmbedSource","resolve","url","options","signal","AbortSignal","Promise","EmbedAdapter","resolveEmbed","createEmbedSource","adapter","undefined","call"],"sources":["../../src/shared/embed.ts"],"sourcesContent":["import type { EmbedValue } from '@panneau/protocol';\n\n/** Where `embed` fields get what a URL embeds: the backend, from the provider's oEmbed. */\nexport interface EmbedSource {\n resolve(url: string, options: { signal: AbortSignal }): Promise<EmbedValue>;\n}\n\n/** What `createEmbedSource()` needs from an adapter: the `resolveEmbed()` of `@panneau/data`. */\nexport interface EmbedAdapter {\n resolveEmbed?(url: string, options?: { signal?: AbortSignal }): Promise<EmbedValue>;\n}\n\n/**\n * The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve\n * embeds: `embed` fields then keep the URL alone.\n */\nexport function createEmbedSource(adapter: EmbedAdapter): EmbedSource | null {\n const { resolveEmbed } = adapter;\n if (resolveEmbed === undefined) {\n return null;\n }\n return { resolve: (url, { signal }) => resolveEmbed.call(adapter, url, { signal }) };\n}\n"],"mappings":";;;;;AAgBA,SAAgBU,kBAAkBC,SAA2C;CACzE,MAAM,EAAEF,iBAAiBE;CACzB,IAAIF,iBAAiBG,KAAAA,GACjB,OAAO;CAEX,OAAO,EAAEV,UAAUC,KAAK,EAAEE,aAAaI,aAAaI,KAAKF,SAASR,KAAK,EAAEE,OAAO,CAAC,EAAE;AACvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","names":[],"sources":["../../src/shared/entry.ts"],"sourcesContent":["import type { Field, Rule } from '@panneau/protocol';\n\nimport type { FieldEntryProps, FieldProps } from './types';\n\n/** The rule of a field with this name, if any. */\nexport function findRule(field: Field, rule: Rule['rule']): Rule | undefined {\n return field.rules?.find((candidate) => candidate.rule === rule);\n}\n\n/** The number of a `min` or `max` rule of a field, if any. */\nexport function getRuleNumber(field: Field, rule: 'min' | 'max'): number | undefined {\n const found = findRule(field, rule);\n return found !== undefined && 'value' in found && typeof found.value === 'number'\n ? found.value\n : undefined;\n}\n\n/** Whether a field has the `required` rule. */\nexport function isRequired(field: Field): boolean {\n return findRule(field, 'required') !== undefined;\n}\n\n/** A setting of a field (`settings.<name>`), when it has the expected type. */\nexport function getSetting<T>(field: Field, name: string, guard: (value: unknown) => value is T) {\n const value = field.settings?.[name];\n return guard(value) ? value : undefined;\n}\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value);\n\n/**\n * The props that every field takes, from a registry entry's props: label (the field's name\n * without one), help, required mark, read-only, errors and handlers. Plugins use it to write their\n * own entries.\n */\nexport function getFieldProps(\n props: FieldEntryProps,\n): Omit<FieldProps<never>, 'value' | 'onChange'> & { placeholder?: string } {\n const { field } = props;\n return {\n name: props.path,\n // A field always has a label: its name when the definition gives none.\n label: field.label ?? field.name,\n description: field.help,\n ...(field.placeholder !== undefined ? { placeholder: field.placeholder } : {}),\n required: isRequired(field),\n readOnly: props.readOnly === true || field.readOnly === true,\n disabled: props.disabled === true,\n errors: props.errors ?? [],\n ...(props.onBlur !== undefined ? { onBlur: props.onBlur } : {}),\n ...(props.className !== undefined ? { className: props.className } : {}),\n };\n}\n\n/** The value as a string, or `null`. */\nexport function asString(value: unknown): string | null {\n return typeof value === 'string' ? value : null;\n}\n\n/** The accepted MIME types of a field that takes files: its `accept`, or its `accept` rule. */\nexport function getAccept(field: Field): string[] | null {\n if (field.accept !== undefined && field.accept.length > 0) {\n return field.accept;\n }\n const rule = findRule(field, 'accept');\n return rule !== undefined && 'value' in rule && Array.isArray(rule.value)\n ? rule.value.filter(isString)\n : null;\n}\n\n/** The largest file of a field, in bytes: its `maxSize` rule. */\nexport function getMaxSize(field: Field): number | null {\n const rule = findRule(field, 'maxSize');\n return rule !== undefined && 'value' in rule && isNumber(rule.value) ? rule.value : null;\n}\n"],"mappings":";;AAKA,SAAgB,SAAS,OAAc,MAAsC;CACzE,OAAO,MAAM,OAAO,MAAM,cAAc,UAAU,SAAS,IAAI;AACnE;;AAGA,SAAgB,cAAc,OAAc,MAAyC;CACjF,MAAM,QAAQ,SAAS,OAAO,IAAI;CAClC,OAAO,UAAU,KAAA,KAAa,WAAW,SAAS,OAAO,MAAM,UAAU,WACnE,MAAM,QACN,KAAA;AACV;;AAGA,SAAgB,WAAW,OAAuB;CAC9C,OAAO,SAAS,OAAO,UAAU,MAAM,KAAA;AAC3C;;AAGA,SAAgB,WAAc,OAAc,MAAc,OAAuC;CAC7F,MAAM,QAAQ,MAAM,WAAW;CAC/B,OAAO,MAAM,KAAK,IAAI,QAAQ,KAAA;AAClC;AAEA,IAAa,YAAY,UAAoC,OAAO,UAAU;AAC9E,IAAa,YAAY,UACrB,OAAO,UAAU,YAAY,CAAC,OAAO,MAAM,KAAK;;;;;;AAOpD,SAAgB,cACZ,OACwE;CACxE,MAAM,EAAE,UAAU;CAClB,OAAO;EACH,MAAM,MAAM;EAEZ,OAAO,MAAM,SAAS,MAAM;EAC5B,aAAa,MAAM;EACnB,GAAI,MAAM,gBAAgB,KAAA,IAAY,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;EAC5E,UAAU,WAAW,KAAK;EAC1B,UAAU,MAAM,aAAa,QAAQ,MAAM,aAAa;EACxD,UAAU,MAAM,aAAa;EAC7B,QAAQ,MAAM,UAAU,CAAA;EACxB,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;EAC7D,GAAI,MAAM,cAAc,KAAA,IAAY,EAAE,WAAW,MAAM,UAAU,IAAI,CAAC;CAC1E;AACJ;;AAQA,SAAgB,UAAU,OAA+B;CACrD,IAAI,MAAM,WAAW,KAAA,KAAa,MAAM,OAAO,SAAS,GACpD,OAAO,MAAM;CAEjB,MAAM,OAAO,SAAS,OAAO,QAAQ;CACrC,OAAO,SAAS,KAAA,KAAa,WAAW,QAAQ,MAAM,QAAQ,KAAK,KAAK,IAClE,KAAK,MAAM,OAAO,QAAQ,IAC1B;AACV;;AAGA,SAAgB,WAAW,OAA6B;CACpD,MAAM,OAAO,SAAS,OAAO,SAAS;CACtC,OAAO,SAAS,KAAA,KAAa,WAAW,QAAQ,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ;AACxF"}
1
+ {"version":3,"file":"entry.js","names":["Field","Rule","FieldEntryProps","FieldProps","findRule","field","rule","rules","find","candidate","getRuleNumber","found","undefined","value","isRequired","getSetting","name","guard","T","settings","isString","isNumber","Number","isNaN","getFieldProps","props","Omit","placeholder","path","label","description","help","required","readOnly","disabled","errors","onBlur","className","asString","getAccept","accept","length","Array","isArray","filter","getMaxSize"],"sources":["../../src/shared/entry.ts"],"sourcesContent":["import type { Field, Rule } from '@panneau/protocol';\n\nimport type { FieldEntryProps, FieldProps } from './types';\n\n/** The rule of a field with this name, if any. */\nexport function findRule(field: Field, rule: Rule['rule']): Rule | undefined {\n return field.rules?.find((candidate) => candidate.rule === rule);\n}\n\n/** The number of a `min` or `max` rule of a field, if any. */\nexport function getRuleNumber(field: Field, rule: 'min' | 'max'): number | undefined {\n const found = findRule(field, rule);\n return found !== undefined && 'value' in found && typeof found.value === 'number'\n ? found.value\n : undefined;\n}\n\n/** Whether a field has the `required` rule. */\nexport function isRequired(field: Field): boolean {\n return findRule(field, 'required') !== undefined;\n}\n\n/** A setting of a field (`settings.<name>`), when it has the expected type. */\nexport function getSetting<T>(field: Field, name: string, guard: (value: unknown) => value is T) {\n const value = field.settings?.[name];\n return guard(value) ? value : undefined;\n}\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value);\n\n/**\n * The props that every field takes, from a registry entry's props: label (the field's name\n * without one), help, required mark, read-only, errors and handlers. Plugins use it to write their\n * own entries.\n */\nexport function getFieldProps(\n props: FieldEntryProps,\n): Omit<FieldProps<never>, 'value' | 'onChange'> & { placeholder?: string } {\n const { field } = props;\n return {\n name: props.path,\n // A field always has a label: its name when the definition gives none.\n label: field.label ?? field.name,\n description: field.help,\n ...(field.placeholder !== undefined ? { placeholder: field.placeholder } : {}),\n required: isRequired(field),\n readOnly: props.readOnly === true || field.readOnly === true,\n disabled: props.disabled === true,\n errors: props.errors ?? [],\n ...(props.onBlur !== undefined ? { onBlur: props.onBlur } : {}),\n ...(props.className !== undefined ? { className: props.className } : {}),\n };\n}\n\n/** The value as a string, or `null`. */\nexport function asString(value: unknown): string | null {\n return typeof value === 'string' ? value : null;\n}\n\n/** The accepted MIME types of a field that takes files: its `accept`, or its `accept` rule. */\nexport function getAccept(field: Field): string[] | null {\n if (field.accept !== undefined && field.accept.length > 0) {\n return field.accept;\n }\n const rule = findRule(field, 'accept');\n return rule !== undefined && 'value' in rule && Array.isArray(rule.value)\n ? rule.value.filter(isString)\n : null;\n}\n\n/** The largest file of a field, in bytes: its `maxSize` rule. */\nexport function getMaxSize(field: Field): number | null {\n const rule = findRule(field, 'maxSize');\n return rule !== undefined && 'value' in rule && isNumber(rule.value) ? rule.value : null;\n}\n"],"mappings":";;AAKA,SA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WAAW5B,KAAAA,KAAaP,MAAMmC,OAAOC,SAAS,GACpD,OAAOpC,MAAMmC;CAEjB,MAAMlC,OAAOF,SAASC,OAAO,QAAQ;CACrC,OAAOC,SAASM,KAAAA,KAAa,WAAWN,QAAQoC,MAAMC,QAAQrC,KAAKO,KAAK,IAClEP,KAAKO,MAAM+B,OAAOxB,QAAQ,IAC1B;AACV;;AAGA,SAAgByB,WAAWxC,OAA6B;CACpD,MAAMC,OAAOF,SAASC,OAAO,SAAS;CACtC,OAAOC,SAASM,KAAAA,KAAa,WAAWN,QAAQe,SAASf,KAAKO,KAAK,IAAIP,KAAKO,QAAQ;AACxF"}
@@ -1 +1 @@
1
- {"version":3,"file":"relation.js","names":["id","active","reference","_c"],"sources":["../../src/shared/relation.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { Definition, Item, ListQuery } from '@panneau/protocol';\n\n/** A related item: its id, and a label to show it. The value of a relation field. */\nexport interface RelationReference {\n id: string;\n label: string;\n}\n\n/** Where relation fields search for items. */\nexport interface RelationSource {\n /** Items of a resource that match a text, for the picker. */\n search(\n resource: string,\n query: string,\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * The references of items by id, for values that are only ids (`\"12\"`, `[\"12\", \"13\"]`), as a\n * product's own API gives them. In any order; ids it doesn't find are left out, and keep their\n * id as label. Without it, fields show the ids.\n */\n resolve?(\n resource: string,\n ids: readonly string[],\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * Creates an item from the text typed in the picker, which offers \"Create “…”\" when this\n * method exists. It can open a dialog, and resolves with the reference of the new item, or with\n * `null` when nothing was created.\n */\n create?(resource: string, text: string): Promise<RelationReference | null>;\n /** Whether `create()` can create items of a resource. Defaults to true. */\n canCreate?(resource: string): boolean;\n}\n\n/** What `createRelationSource()` needs from an adapter: the `list()`, `get()` and `create()` of `@panneau/data`. */\nexport interface RelationListAdapter {\n list(\n resource: string,\n query?: ListQuery,\n options?: { signal?: AbortSignal },\n ): Promise<{ data: Item[] }>;\n /** One item, for `resolve()`. Without it, the source doesn't resolve ids. */\n get?(resource: string, id: string, options?: { signal?: AbortSignal }): Promise<Item>;\n /** Creates an item, for `create()`. */\n create?(resource: string, values: Record<string, unknown>): Promise<Item>;\n}\n\nexport interface RelationSourceOptions {\n /** The definition, for the field that titles the items of each resource (`itemTitle`). */\n definition?: (Pick<Definition, 'resources'> & Partial<Pick<Definition, 'locales'>>) | null;\n /** Items per search. Defaults to 20. */\n perPage?: number;\n /** The label of an item, when `itemTitle` isn't enough. */\n getLabel?: (item: Item, resource: string) => string;\n /**\n * Lets the picker create items, with the adapter's `create()`. `true` sets the typed text as the\n * value of the resource's `itemTitle` field (in every locale of the definition when it is\n * localized), on the resources that allow `create`. A function gives the values of the new item\n * instead, or `null` for a resource where items can't be created.\n */\n create?: boolean | ((text: string, resource: string) => Record<string, unknown> | null);\n}\n\nfunction labelOf(value: unknown, locale?: string): string | null {\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value);\n }\n if (value !== null && typeof value === 'object') {\n const localized = value as Record<string, unknown>;\n const first =\n (locale !== undefined ? localized[locale] : undefined) ?? Object.values(localized)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * A relation source over an adapter, such as the `DataAdapter` of `@panneau/data`: a search is a\n * list query with `q`, ids are resolved with `get()`, and, with the `create` option, items are\n * created with `create()`. Labels come from the resource's `itemTitle`.\n */\nexport function createRelationSource(\n adapter: RelationListAdapter,\n { definition = null, perPage = 20, getLabel, create }: RelationSourceOptions = {},\n): RelationSource {\n const resourceOf = (resource: string) =>\n definition?.resources.find((candidate) => candidate.id === resource);\n const toReference = (item: Item, resource: string): RelationReference => {\n const titleField = resourceOf(resource)?.itemTitle;\n return {\n id: item.id,\n label:\n getLabel?.(item, resource) ??\n (titleField !== undefined ? labelOf(item[titleField]) : null) ??\n item.id,\n };\n };\n const valuesOf = (text: string, resource: string): Record<string, unknown> | null => {\n if (typeof create === 'function') {\n return create(text, resource);\n }\n const definitionResource = resourceOf(resource);\n const titleField = definitionResource?.itemTitle;\n if (definitionResource === undefined || titleField === undefined) {\n return null;\n }\n const field = definitionResource.fields.find((candidate) => candidate.name === titleField);\n const locales = definition?.locales ?? [];\n return {\n [titleField]:\n field?.localized === true && locales.length > 0\n ? Object.fromEntries(locales.map((locale) => [locale, text]))\n : text,\n };\n };\n const source: RelationSource = {\n async search(resource, query, { signal }) {\n const response = await adapter.list(\n resource,\n { page: 1, perPage, ...(query !== '' ? { q: query } : {}) },\n { signal },\n );\n return response.data.map((item) => toReference(item, resource));\n },\n };\n const { get, create: createItem } = adapter;\n if (get !== undefined) {\n source.resolve = async (resource, ids, { signal }) => {\n const results = await Promise.allSettled(\n ids.map((id) => get.call(adapter, resource, id, { signal })),\n );\n return results.flatMap((result) =>\n result.status === 'fulfilled' ? [toReference(result.value, resource)] : [],\n );\n };\n }\n if (create !== undefined && create !== false && createItem !== undefined) {\n source.canCreate = (resource) =>\n resourceOf(resource)?.abilities?.create !== false && valuesOf('', resource) !== null;\n source.create = async (resource, text) => {\n const values = valuesOf(text, resource);\n if (values === null) {\n return null;\n }\n return toReference(await createItem.call(adapter, resource, values), resource);\n };\n }\n return source;\n}\n\n/** Reads relation values: references, ids, or lists of them. */\nexport function toReferences(value: unknown): RelationReference[] {\n const list = Array.isArray(value)\n ? value\n : value === null || value === undefined\n ? []\n : [value];\n return list.flatMap((entry: unknown) => {\n if (typeof entry === 'string' || typeof entry === 'number') {\n return [{ id: String(entry), label: String(entry) }];\n }\n if (entry !== null && typeof entry === 'object' && 'id' in entry) {\n const { id, label } = entry as { id: unknown; label?: unknown };\n if (typeof id === 'string' || typeof id === 'number') {\n return [{ id: String(id), label: typeof label === 'string' ? label : String(id) }];\n }\n }\n return [];\n });\n}\n\ninterface ResolvedLabels {\n /** Labels by resource and id: `null` for ids that the source didn't find. */\n labels: Map<string, string | null>;\n /** Requests in flight, so that fields with the same ids share one. */\n pending: Map<string, Promise<void>>;\n}\n\nconst resolved = new WeakMap<RelationSource, ResolvedLabels>();\n\nfunction resolvedOf(source: RelationSource): ResolvedLabels {\n let entry = resolved.get(source);\n if (entry === undefined) {\n entry = { labels: new Map(), pending: new Map() };\n resolved.set(source, entry);\n }\n return entry;\n}\n\nconst keyOf = (resource: string, id: string) => `${resource}\\u0000${id}`;\n\n/** Resolves the ids that no request has resolved or is resolving yet, and waits for all of them. */\nfunction resolveIds(source: RelationSource, resource: string, ids: readonly string[]) {\n const { labels, pending } = resolvedOf(source);\n const fresh = ids.filter((id) => !pending.has(keyOf(resource, id)));\n if (fresh.length > 0 && source.resolve !== undefined) {\n // Shared by every field that asks for these ids: it isn't aborted when one unmounts.\n const request = source\n .resolve(resource, fresh, { signal: new AbortController().signal })\n .then(\n (found) => {\n fresh.forEach((id) =>\n labels.set(\n keyOf(resource, id),\n found.find((candidate) => candidate.id === id)?.label ?? null,\n ),\n );\n },\n () => {\n // Tried again the next time a field shows these ids.\n fresh.forEach((id) => pending.delete(keyOf(resource, id)));\n },\n );\n fresh.forEach((id) => pending.set(keyOf(resource, id), request));\n }\n return Promise.all(ids.map((id) => pending.get(keyOf(resource, id))));\n}\n\n/**\n * Relation references with the labels of plain ids: references whose label is their id (from\n * `\"12\"`) are resolved with the source's `resolve()`, once per source, resource and id. They keep\n * their id as label until then, or when the source doesn't find them.\n */\nexport function useRelationReferences(\n source: RelationSource | null,\n resource: string,\n references: readonly RelationReference[],\n): RelationReference[] {\n const cache = source !== null ? resolvedOf(source).labels : null;\n const [labels, setLabels] = useState<Readonly<Record<string, string>>>({});\n const label = (id: string): string | undefined =>\n labels[keyOf(resource, id)] ?? cache?.get(keyOf(resource, id)) ?? undefined;\n const missing =\n source?.resolve !== undefined && cache !== null\n ? references\n .filter((reference) => reference.label === reference.id)\n .map((reference) => reference.id)\n .filter((id) => !cache.has(keyOf(resource, id)))\n : [];\n const missingKey = missing.join('\\u0000');\n\n useEffect(() => {\n const ids = missingKey === '' ? [] : missingKey.split('\\u0000');\n if (source === null || cache === null || ids.length === 0) {\n return undefined;\n }\n let active = true;\n void resolveIds(source, resource, ids).then(() => {\n if (!active) {\n return;\n }\n const next: Record<string, string> = {};\n ids.forEach((id) => {\n const found = cache.get(keyOf(resource, id));\n if (typeof found === 'string') {\n next[keyOf(resource, id)] = found;\n }\n });\n setLabels((current) => ({ ...current, ...next }));\n });\n return () => {\n active = false;\n };\n }, [source, cache, resource, missingKey]);\n\n return references.map((reference) =>\n reference.label === reference.id\n ? { id: reference.id, label: label(reference.id) ?? reference.id }\n : reference,\n );\n}\n"],"mappings":";;;AAmEA,SAAS,QAAQ,OAAgB,QAAgC;CAC7D,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAC9C,OAAO,OAAO,KAAK;CAEvB,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC7C,MAAM,YAAY;EAClB,MAAM,SACD,WAAW,KAAA,IAAY,UAAU,UAAU,KAAA,MAAc,OAAO,OAAO,SAAS,CAAC,CAAC;EACvF,OAAO,OAAO,UAAU,WAAW,QAAQ;CAC/C;CACA,OAAO;AACX;;;;;;AAOA,SAAgB,qBACZ,SACA,EAAE,aAAa,MAAM,UAAU,IAAI,UAAU,WAAkC,CAAC,GAClE;CACd,MAAM,cAAc,aAChB,YAAY,UAAU,MAAM,cAAc,UAAU,OAAO,QAAQ;CACvE,MAAM,eAAe,MAAY,aAAwC;EACrE,MAAM,aAAa,WAAW,QAAQ,CAAC,EAAE;EACzC,OAAO;GACH,IAAI,KAAK;GACT,OACI,WAAW,MAAM,QAAQ,MACxB,eAAe,KAAA,IAAY,QAAQ,KAAK,WAAW,IAAI,SACxD,KAAK;EACb;CACJ;CACA,MAAM,YAAY,MAAc,aAAqD;EACjF,IAAI,OAAO,WAAW,YAClB,OAAO,OAAO,MAAM,QAAQ;EAEhC,MAAM,qBAAqB,WAAW,QAAQ;EAC9C,MAAM,aAAa,oBAAoB;EACvC,IAAI,uBAAuB,KAAA,KAAa,eAAe,KAAA,GACnD,O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M,UAAUA,IAAE,CAAC;IAC3C,IAAI,OAAO,UAAU,UACjB,KAAK,MAAM,UAAUA,IAAE,KAAK;GAC/B,CACJ;GACD,WAAU,aAAc;IAAA,GAAK;IAAO,GAAK;GAAK,EAAE;EAAC,CACpD;EAAC,aACK;GACH,SAASC;EAAH;CACT,GACF;EAAC;EAAQ;EAAO;EAAU;CAAU,CAAC;CAAC,OAElC,WAAU,KAAK,gBAClBC,YAAS,UAAWA,YAAS,KAA7B;EAAA,IACYA,YAAS;EAAG,OAAS,MAAMA,YAAS,EAAmB,KAAXA,YAAS;CACnD,IAFd,WAGJ;AAAC;AA9CE,SAAA,OAAA,aAAA;CAAA,OAa+BA,YAAS;AAAG;AAb3C,SAAA,MAAA,WAAA;CAAA,OAYkC,UAAS,UAAW,UAAS;AAAG"}
1
+ {"version":3,"file":"relation.js","names":["useEffect","useState","Definition","Item","ListQuery","RelationReference","id","label","RelationSource","search","resource","query","options","signal","AbortSignal","Promise","resolve","ids","create","text","canCreate","RelationListAdapter","list","data","get","values","Record","RelationSourceOptions","definition","Pick","Partial","perPage","getLabel","item","labelOf","value","locale","String","localized","first","undefined","Object","createRelationSource","adapter","resourceOf","resources","find","candidate","toReference","titleField","itemTitle","valuesOf","definitionResource","field","fields","name","locales","length","fromEntries","map","source","response","page","q","createItem","results","allSettled","call","flatMap","result","status","abilities","toReferences","Array","isArray","entry","ResolvedLabels","labels","Map","pending","resolved","WeakMap","resolvedOf","set","keyOf","resolveIds","fresh","filter","has","request","AbortController","then","found","forEach","delete","all","useRelationReferences","references","$","_c","cache","t0","Symbol","for","setLabels","missing","_temp","_temp2","id_0","missingKey","join","split","active","next","id_1","current","reference_1","reference","reference_0","_c"],"sources":["../../src/shared/relation.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { Definition, Item, ListQuery } from '@panneau/protocol';\n\n/** A related item: its id, and a label to show it. The value of a relation field. */\nexport interface RelationReference {\n id: string;\n label: string;\n}\n\n/** Where relation fields search for items. */\nexport interface RelationSource {\n /** Items of a resource that match a text, for the picker. */\n search(\n resource: string,\n query: string,\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * The references of items by id, for values that are only ids (`\"12\"`, `[\"12\", \"13\"]`), as a\n * product's own API gives them. In any order; ids it doesn't find are left out, and keep their\n * id as label. Without it, fields show the ids.\n */\n resolve?(\n resource: string,\n ids: readonly string[],\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * Creates an item from the text typed in the picker, which offers \"Create “…”\" when this\n * method exists. It can open a dialog, and resolves with the reference of the new item, or with\n * `null` when nothing was created.\n */\n create?(resource: string, text: string): Promise<RelationReference | null>;\n /** Whether `create()` can create items of a resource. Defaults to true. */\n canCreate?(resource: string): boolean;\n}\n\n/** What `createRelationSource()` needs from an adapter: the `list()`, `get()` and `create()` of `@panneau/data`. */\nexport interface RelationListAdapter {\n list(\n resource: string,\n query?: ListQuery,\n options?: { signal?: AbortSignal },\n ): Promise<{ data: Item[] }>;\n /** One item, for `resolve()`. Without it, the source doesn't resolve ids. */\n get?(resource: string, id: string, options?: { signal?: AbortSignal }): Promise<Item>;\n /** Creates an item, for `create()`. */\n create?(resource: string, values: Record<string, unknown>): Promise<Item>;\n}\n\nexport interface RelationSourceOptions {\n /** The definition, for the field that titles the items of each resource (`itemTitle`). */\n definition?: (Pick<Definition, 'resources'> & Partial<Pick<Definition, 'locales'>>) | null;\n /** Items per search. Defaults to 20. */\n perPage?: number;\n /** The label of an item, when `itemTitle` isn't enough. */\n getLabel?: (item: Item, resource: string) => string;\n /**\n * Lets the picker create items, with the adapter's `create()`. `true` sets the typed text as the\n * value of the resource's `itemTitle` field (in every locale of the definition when it is\n * localized), on the resources that allow `create`. A function gives the values of the new item\n * instead, or `null` for a resource where items can't be created.\n */\n create?: boolean | ((text: string, resource: string) => Record<string, unknown> | null);\n}\n\nfunction labelOf(value: unknown, locale?: string): string | null {\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value);\n }\n if (value !== null && typeof value === 'object') {\n const localized = value as Record<string, unknown>;\n const first =\n (locale !== undefined ? localized[locale] : undefined) ?? Object.values(localized)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * A relation source over an adapter, such as the `DataAdapter` of `@panneau/data`: a search is a\n * list query with `q`, ids are resolved with `get()`, and, with the `create` option, items are\n * created with `create()`. Labels come from the resource's `itemTitle`.\n */\nexport function createRelationSource(\n adapter: RelationListAdapter,\n { definition = null, perPage = 20, getLabel, create }: RelationSourceOptions = {},\n): RelationSource {\n const resourceOf = (resource: string) =>\n definition?.resources.find((candidate) => candidate.id === resource);\n const toReference = (item: Item, resource: string): RelationReference => {\n const titleField = resourceOf(resource)?.itemTitle;\n return {\n id: item.id,\n label:\n getLabel?.(item, resource) ??\n (titleField !== undefined ? labelOf(item[titleField]) : null) ??\n item.id,\n };\n };\n const valuesOf = (text: string, resource: string): Record<string, unknown> | null => {\n if (typeof create === 'function') {\n return create(text, resource);\n }\n const definitionResource = resourceOf(resource);\n const titleField = definitionResource?.itemTitle;\n if (definitionResource === undefined || titleField === undefined) {\n return null;\n }\n const field = definitionResource.fields.find((candidate) => candidate.name === titleField);\n const locales = definition?.locales ?? [];\n return {\n [titleField]:\n field?.localized === true && locales.length > 0\n ? Object.fromEntries(locales.map((locale) => [locale, text]))\n : text,\n };\n };\n const source: RelationSource = {\n async search(resource, query, { signal }) {\n const response = await adapter.list(\n resource,\n { page: 1, perPage, ...(query !== '' ? { q: query } : {}) },\n { signal },\n );\n return response.data.map((item) => toReference(item, resource));\n },\n };\n const { get, create: createItem } = adapter;\n if (get !== undefined) {\n source.resolve = async (resource, ids, { signal }) => {\n const results = await Promise.allSettled(\n ids.map((id) => get.call(adapter, resource, id, { signal })),\n );\n return results.flatMap((result) =>\n result.status === 'fulfilled' ? [toReference(result.value, resource)] : [],\n );\n };\n }\n if (create !== undefined && create !== false && createItem !== undefined) {\n source.canCreate = (resource) =>\n resourceOf(resource)?.abilities?.create !== false && valuesOf('', resource) !== null;\n source.create = async (resource, text) => {\n const values = valuesOf(text, resource);\n if (values === null) {\n return null;\n }\n return toReference(await createItem.call(adapter, resource, values), resource);\n };\n }\n return source;\n}\n\n/** Reads relation values: references, ids, or lists of them. */\nexport function toReferences(value: unknown): RelationReference[] {\n const list = Array.isArray(value)\n ? value\n : value === null || value === undefined\n ? []\n : [value];\n return list.flatMap((entry: unknown) => {\n if (typeof entry === 'string' || typeof entry === 'number') {\n return [{ id: String(entry), label: String(entry) }];\n }\n if (entry !== null && typeof entry === 'object' && 'id' in entry) {\n const { id, label } = entry as { id: unknown; label?: unknown };\n if (typeof id === 'string' || typeof id === 'number') {\n return [{ id: String(id), label: typeof label === 'string' ? label : String(id) }];\n }\n }\n return [];\n });\n}\n\ninterface ResolvedLabels {\n /** Labels by resource and id: `null` for ids that the source didn't find. */\n labels: Map<string, string | null>;\n /** Requests in flight, so that fields with the same ids share one. */\n pending: Map<string, Promise<void>>;\n}\n\nconst resolved = new WeakMap<RelationSource, ResolvedLabels>();\n\nfunction resolvedOf(source: RelationSource): ResolvedLabels {\n let entry = resolved.get(source);\n if (entry === undefined) {\n entry = { labels: new Map(), pending: new Map() };\n resolved.set(source, entry);\n }\n return entry;\n}\n\nconst keyOf = (resource: string, id: string) => `${resource}\\u0000${id}`;\n\n/** Resolves the ids that no request has resolved or is resolving yet, and waits for all of them. */\nfunction resolveIds(source: RelationSource, resource: string, ids: readonly string[]) {\n const { labels, pending } = resolvedOf(source);\n const fresh = ids.filter((id) => !pending.has(keyOf(resource, id)));\n if (fresh.length > 0 && source.resolve !== undefined) {\n // Shared by every field that asks for these ids: it isn't aborted when one unmounts.\n const request = source\n .resolve(resource, fresh, { signal: new AbortController().signal })\n .then(\n (found) => {\n fresh.forEach((id) =>\n labels.set(\n keyOf(resource, id),\n found.find((candidate) => candidate.id === id)?.label ?? null,\n ),\n );\n },\n () => {\n // Tried again the next time a field shows these ids.\n fresh.forEach((id) => pending.delete(keyOf(resource, id)));\n },\n );\n fresh.forEach((id) => pending.set(keyOf(resource, id), request));\n }\n return Promise.all(ids.map((id) => pending.get(keyOf(resource, id))));\n}\n\n/**\n * Relation references with the labels of plain ids: references whose label is their id (from\n * `\"12\"`) are resolved with the source's `resolve()`, once per source, resource and id. They keep\n * their id as label until then, or when the source doesn't find them.\n */\nexport function useRelationReferences(\n source: RelationSource | null,\n resource: string,\n references: readonly RelationReference[],\n): RelationReference[] {\n const cache = source !== null ? resolvedOf(source).labels : null;\n const [labels, setLabels] = useState<Readonly<Record<string, string>>>({});\n const label = (id: string): string | undefined =>\n labels[keyOf(resource, id)] ?? cache?.get(keyOf(resource, id)) ?? undefined;\n const missing =\n source?.resolve !== undefined && cache !== null\n ? references\n .filter((reference) => reference.label === reference.id)\n .map((reference) => reference.id)\n .filter((id) => !cache.has(keyOf(resource, id)))\n : [];\n const missingKey = missing.join('\\u0000');\n\n useEffect(() => {\n const ids = missingKey === '' ? [] : missingKey.split('\\u0000');\n if (source === null || cache === null || ids.length === 0) {\n return undefined;\n }\n let active = true;\n void resolveIds(source, resource, ids).then(() => {\n if (!active) {\n return;\n }\n const next: Record<string, string> = {};\n ids.forEach((id) => {\n const found = cache.get(keyOf(resource, id));\n if (typeof found === 'string') {\n next[keyOf(resource, id)] = found;\n }\n });\n setLabels((current) => ({ ...current, ...next }));\n });\n return () => {\n active = false;\n };\n }, [source, cache, resource, missingKey]);\n\n return references.map((reference) =>\n reference.label === reference.id\n ? { id: reference.id, label: label(reference.id) ?? reference.id }\n : reference,\n );\n}\n"],"mappings":";;;AAmEA,SAASkC,QAAQC,OAAgBC,QAAgC;CAC7D,IAAI,OAAOD,UAAU,YAAY,OAAOA,UAAU,UAC9C,OAAOE,OAAOF,KAAK;CAEvB,IAAIA,UAAU,QAAQ,OAAOA,UAAU,UAAU;EAC7C,MAAMG,YAAYH;EAClB,MAAMI,SACDH,WAAWI,KAAAA,IAAYF,UAAUF,UAAUI,KAAAA,MAAcC,OAAOhB,OAAOa,SAAS,CAAC,C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