@phis/ui 0.7.8 → 0.8.0

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 (311) hide show
  1. package/components/controls/phi-address-control.d.ts +23 -0
  2. package/components/controls/phi-address-control.js +43 -0
  3. package/components/controls/phi-color-control.d.ts +3 -1
  4. package/components/controls/phi-color-control.js +2 -2
  5. package/components/controls/phi-country-select-control.d.ts +22 -0
  6. package/components/controls/phi-country-select-control.js +16 -0
  7. package/components/controls/phi-dialog-control.d.ts +1 -1
  8. package/components/controls/phi-drawer-control-adapter.d.ts +1 -1
  9. package/components/controls/phi-drawer-control-adapter.js +5 -3
  10. package/components/controls/phi-drawer-control.d.ts +7 -5
  11. package/components/controls/phi-float-button-control.d.ts +8 -1
  12. package/components/controls/phi-float-button-control.js +19 -3
  13. package/components/controls/phi-form-control.js +52 -8
  14. package/components/controls/phi-modal-control-adapter.d.ts +1 -1
  15. package/components/controls/phi-modal-control-adapter.js +14 -37
  16. package/components/controls/phi-modal-control.d.ts +5 -5
  17. package/components/controls/phi-options-provider.d.ts +1 -0
  18. package/components/controls/phi-options-provider.js +1 -0
  19. package/components/controls/phi-overlay-control-contract.d.ts +52 -17
  20. package/components/controls/phi-overlay-control-contract.js +55 -30
  21. package/components/controls/phi-reveal-once-dialog-control.d.ts +21 -0
  22. package/components/controls/phi-reveal-once-dialog-control.js +52 -0
  23. package/components/controls/phi-reveal-once-dialog-labels.d.ts +10 -0
  24. package/components/controls/phi-reveal-once-dialog-labels.js +5 -0
  25. package/components/forms/flags-field.d.ts +22 -0
  26. package/components/forms/flags-field.js +58 -0
  27. package/components/forms/form-option-flags.d.ts +20 -0
  28. package/components/forms/form-option-flags.js +38 -0
  29. package/components/forms/form-provider-contract.d.ts +23 -0
  30. package/components/forms/form-provider-contract.js +36 -0
  31. package/components/forms/form-provider-registry.d.ts +5 -1
  32. package/components/forms/shared-form-provider-registry.js +13 -0
  33. package/components/forms/structured-field-labels.d.ts +24 -0
  34. package/components/forms/structured-field-labels.js +43 -0
  35. package/components/forms/structured-form-field-controls.d.ts +12 -0
  36. package/components/forms/structured-form-field-controls.js +65 -0
  37. package/components/overlays/phi-overlay-container-client.js +2 -2
  38. package/components/regions/phi-cms-region-shell.js +2 -2
  39. package/components/regions/presets/content-entry-editor-page-tree.js +12 -3
  40. package/components/regions/presets/phi-settings-page-shell-tree.d.ts +6 -2
  41. package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
  42. package/components/root/phi-root-theme-resolver.js +3 -0
  43. package/components/shell/phi-antd-icon.d.ts +1 -8
  44. package/components/shell/phi-antd-icon.js +1 -227
  45. package/components/shell/phi-icon-names.d.ts +19 -0
  46. package/components/shell/phi-icon-names.js +264 -0
  47. package/components/shell/phi-icon.d.ts +2 -11
  48. package/components/shell/phi-icon.js +4 -32
  49. package/components/widgets/client/shared/phi-command-buttons.d.ts +13 -2
  50. package/components/widgets/client/shared/phi-command-buttons.js +10 -4
  51. package/components/widgets/client/shared/phi-rendered-value.js +27 -3
  52. package/components/widgets/client/shared/phi-table-provider-refusal.d.ts +13 -0
  53. package/components/widgets/client/shared/phi-table-provider-refusal.js +13 -0
  54. package/components/widgets/config/background.d.ts +3 -2
  55. package/components/widgets/config/choice-shared.d.ts +10 -1
  56. package/components/widgets/config/choice-shared.js +8 -2
  57. package/components/widgets/label-sets/admin-locales.js +1 -1
  58. package/components/widgets/label-sets/admin-users.d.ts +2 -5
  59. package/components/widgets/label-sets/admin-users.js +4 -10
  60. package/components/widgets/label-sets/effects.js +2 -4
  61. package/components/widgets/label-sets/profile.d.ts +13 -0
  62. package/components/widgets/label-sets/profile.js +28 -0
  63. package/components/widgets/label-sets/search-results.js +2 -4
  64. package/components/widgets/label-sets/table.js +9 -0
  65. package/components/widgets/label-types/effects.d.ts +3 -2
  66. package/components/widgets/label-types/effects.js +1 -2
  67. package/components/widgets/label-types/search-results.d.ts +2 -2
  68. package/components/widgets/label-types/search-results.js +1 -2
  69. package/components/widgets/label-types/table.d.ts +3 -0
  70. package/components/widgets/label-types/table.js +2 -0
  71. package/components/widgets/server/builder-chrome.d.ts +4 -1
  72. package/components/widgets/server/builder-chrome.js +2 -2
  73. package/components/widgets/shared/markdown-body-client.d.ts +26 -0
  74. package/components/widgets/shared/markdown-body-client.js +31 -1
  75. package/components/widgets/shared/markdown-render.d.ts +10 -2
  76. package/components/widgets/shared/markdown-render.js +35 -13
  77. package/constants/countries.d.ts +9 -0
  78. package/constants/countries.js +28 -0
  79. package/constants/customer-file.d.ts +25 -0
  80. package/constants/customer-file.js +26 -0
  81. package/constants/record-field-kinds.d.ts +15 -0
  82. package/constants/record-field-kinds.js +13 -0
  83. package/constants/runtime-module-ownership.js +12 -0
  84. package/constants/runtime-render-client-types.d.ts +5 -0
  85. package/constants/runtime-render-client-types.js +5 -0
  86. package/{plugins/runtime-modules/threads/controller/address.js → constants/threads-controller-address.js} +1 -1
  87. package/constants.d.ts +1 -0
  88. package/constants.js +2 -0
  89. package/gateway/form-handler-request.d.ts +22 -0
  90. package/gateway/form-handler-request.js +40 -0
  91. package/gateway/label-set.d.ts +15 -2
  92. package/gateway/label-set.js +60 -22
  93. package/gateway/site-form-route.js +11 -2
  94. package/helpers/address-field.d.ts +43 -0
  95. package/helpers/address-field.js +68 -0
  96. package/helpers/cms-dialog.d.ts +5 -20
  97. package/helpers/cms-dialog.js +8 -13
  98. package/helpers/cms-page-catalog.d.ts +10 -0
  99. package/helpers/cms-page-catalog.js +19 -0
  100. package/helpers/cms-preset-nodes.d.ts +4 -4
  101. package/helpers/cms-preset-nodes.js +1 -1
  102. package/helpers/cms-region-keys.d.ts +1 -1
  103. package/helpers/country-names.d.ts +12 -0
  104. package/helpers/country-names.js +14 -0
  105. package/helpers/phi-metadata.d.ts +33 -1
  106. package/helpers/phi-metadata.js +62 -1
  107. package/helpers/preset-table-check.d.ts +34 -0
  108. package/helpers/preset-table-check.js +124 -0
  109. package/helpers/preset-text-source-check.d.ts +4 -1
  110. package/helpers/preset-text-source-check.js +6 -1
  111. package/helpers/preset-tree-contract-check.d.ts +3 -2
  112. package/helpers/preset-tree-contract-check.js +30 -5
  113. package/helpers/public-route-claims.d.ts +9 -1
  114. package/helpers/public-route-claims.js +23 -3
  115. package/helpers/record-fields.d.ts +1 -5
  116. package/helpers/record-fields.js +15 -6
  117. package/helpers/route-address-check.d.ts +22 -2
  118. package/helpers/route-address-check.js +29 -8
  119. package/helpers/site-address-row.d.ts +23 -0
  120. package/helpers/site-address-row.js +36 -0
  121. package/helpers/surface-style.d.ts +8 -1
  122. package/helpers/surface-style.js +12 -2
  123. package/helpers/thread-inbox-row.d.ts +20 -0
  124. package/helpers/thread-inbox-row.js +26 -0
  125. package/helpers/translation-format.d.ts +26 -0
  126. package/helpers/translation-format.js +31 -0
  127. package/module-labels.d.ts +1 -1
  128. package/module-labels.js +1 -1
  129. package/module-page-check.d.ts +1 -0
  130. package/module-page-check.js +1 -0
  131. package/module-records.d.ts +2 -2
  132. package/module-records.js +1 -0
  133. package/next/area-route.js +34 -1
  134. package/next/root-route.js +4 -5
  135. package/package.json +2 -2
  136. package/plugins/runtime-modules/accounting/customer-file-access.d.ts +11 -0
  137. package/plugins/runtime-modules/accounting/customer-file-access.js +12 -0
  138. package/plugins/runtime-modules/accounting/data-providers.js +1 -1
  139. package/plugins/runtime-modules/accounting/ids.d.ts +11 -0
  140. package/plugins/runtime-modules/accounting/ids.js +23 -0
  141. package/plugins/runtime-modules/accounting/presets.js +32 -5
  142. package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +66 -0
  143. package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +122 -0
  144. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +2 -2
  145. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +26 -0
  146. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +381 -0
  147. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +4 -0
  148. package/plugins/runtime-modules/app/client-data-providers.d.ts +7 -0
  149. package/plugins/runtime-modules/app/client-data-providers.js +9 -0
  150. package/plugins/runtime-modules/app/data-providers.d.ts +98 -0
  151. package/plugins/runtime-modules/app/data-providers.js +80 -0
  152. package/plugins/runtime-modules/app/definition.d.ts +131 -0
  153. package/plugins/runtime-modules/app/definition.js +2 -0
  154. package/plugins/runtime-modules/app/forms.d.ts +46 -1
  155. package/plugins/runtime-modules/app/forms.js +195 -1
  156. package/plugins/runtime-modules/app/ids.d.ts +7 -0
  157. package/plugins/runtime-modules/app/ids.js +8 -0
  158. package/plugins/runtime-modules/app/module.d.ts +131 -0
  159. package/plugins/runtime-modules/app/services/addresses-table.d.ts +135 -0
  160. package/plugins/runtime-modules/app/services/addresses-table.js +101 -0
  161. package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +17 -0
  162. package/plugins/runtime-modules/app/trees/account-addresses-panel.js +179 -0
  163. package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +62 -0
  164. package/plugins/runtime-modules/app/trees/addresses-label-set.js +108 -0
  165. package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +27 -2
  166. package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +1 -0
  167. package/plugins/runtime-modules/app/trees/profile-label-set.js +3 -0
  168. package/plugins/runtime-modules/asset/presets.d.ts +4 -0
  169. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +4 -2
  170. package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +4 -2
  171. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -2
  172. package/plugins/runtime-modules/auth/widgets/logout/client.d.ts +1 -1
  173. package/plugins/runtime-modules/auth/widgets/logout/client.js +2 -2
  174. package/plugins/runtime-modules/auth/widgets/security/client.d.ts +5 -1
  175. package/plugins/runtime-modules/auth/widgets/security/client.js +12 -10
  176. package/plugins/runtime-modules/avatar/overlay-tree.server.js +1 -1
  177. package/plugins/runtime-modules/blog/presets.d.ts +4 -0
  178. package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +2 -1
  179. package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -2
  180. package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.d.ts +23 -0
  181. package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.js +38 -0
  182. package/plugins/runtime-modules/builder/clients/mode-switch.d.ts +4 -1
  183. package/plugins/runtime-modules/builder/clients/mode-switch.js +2 -15
  184. package/plugins/runtime-modules/builder/clients/pages-workspace.js +2 -0
  185. package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +2 -1
  186. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +28 -1
  187. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +5 -0
  188. package/plugins/runtime-modules/builder/page-presets.server.d.ts +7 -0
  189. package/plugins/runtime-modules/builder/page-presets.server.js +10 -1
  190. package/plugins/runtime-modules/builder/persistence.js +4 -0
  191. package/plugins/runtime-modules/builder/public-route-collisions.js +8 -3
  192. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -1
  193. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +33 -6
  194. package/plugins/runtime-modules/builder/widgets/chrome/config.d.ts +6 -4
  195. package/plugins/runtime-modules/builder/widgets/chrome/config.js +11 -1
  196. package/plugins/runtime-modules/builder/widgets/inspector-header/authoring.d.ts +2 -2
  197. package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.d.ts +2 -2
  198. package/plugins/runtime-modules/builder/widgets/mode-switch/plugin.js +1 -1
  199. package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +2 -2
  200. package/plugins/runtime-modules/client-manifests/app.js +3 -0
  201. package/plugins/runtime-modules/client-manifests/builder.js +10 -0
  202. package/plugins/runtime-modules/content-entry-routes.d.ts +4 -0
  203. package/plugins/runtime-modules/contracts.js +31 -1
  204. package/plugins/runtime-modules/core/definition.d.ts +23 -0
  205. package/plugins/runtime-modules/core/form-providers.d.ts +23 -0
  206. package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +0 -17
  207. package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +2 -23
  208. package/plugins/runtime-modules/core/widgets/card/config.d.ts +0 -1
  209. package/plugins/runtime-modules/core/widgets/card/config.js +0 -1
  210. package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
  211. package/plugins/runtime-modules/core/widgets/command-toolbar/client.js +3 -0
  212. package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +316 -1
  213. package/plugins/runtime-modules/core/widgets/command-toolbar/config.js +4 -4
  214. package/plugins/runtime-modules/core/widgets/dimension/config.d.ts +1 -1
  215. package/plugins/runtime-modules/core/widgets/float-button/client.js +4 -1
  216. package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +326 -3
  217. package/plugins/runtime-modules/core/widgets/float-button/config.js +5 -2
  218. package/plugins/runtime-modules/core/widgets/header-navigation/client.js +1 -1
  219. package/plugins/runtime-modules/core/widgets/length/config.d.ts +1 -1
  220. package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
  221. package/plugins/runtime-modules/core/widgets/markdown/server.d.ts +6 -2
  222. package/plugins/runtime-modules/core/widgets/markdown/server.js +2 -2
  223. package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.d.ts +12 -0
  224. package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.js +68 -0
  225. package/plugins/runtime-modules/core/widgets/number-input/config.d.ts +1 -1
  226. package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -1
  227. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +2 -1
  228. package/plugins/runtime-modules/core/widgets/table/client.js +20 -5
  229. package/plugins/runtime-modules/core/widgets/table/config.js +6 -0
  230. package/plugins/runtime-modules/core/widgets/table/reader-query.d.ts +17 -0
  231. package/plugins/runtime-modules/core/widgets/table/reader-query.js +33 -0
  232. package/plugins/runtime-modules/dashboard/trees/dashboard-cards-page-tree.js +3 -1
  233. package/plugins/runtime-modules/descriptor-compiler.d.ts +19 -3
  234. package/plugins/runtime-modules/descriptor-compiler.js +44 -16
  235. package/plugins/runtime-modules/editor/presets.d.ts +4 -0
  236. package/plugins/runtime-modules/editor/trees/phi-default-editor-releases-page-tree.js +3 -1
  237. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +5 -1
  238. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +5 -1
  239. package/plugins/runtime-modules/localization/presets.d.ts +4 -0
  240. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -1
  241. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +4 -2
  242. package/plugins/runtime-modules/news/presets.d.ts +4 -0
  243. package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +6 -2
  244. package/plugins/runtime-modules/resolver.js +17 -0
  245. package/plugins/runtime-modules/revisions/controller/client.js +13 -11
  246. package/plugins/runtime-modules/revisions/controller/draft-context-target.d.ts +25 -0
  247. package/plugins/runtime-modules/revisions/controller/draft-context-target.js +33 -0
  248. package/plugins/runtime-modules/revisions/presets.d.ts +4 -0
  249. package/plugins/runtime-modules/revisions/services/table.js +13 -4
  250. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -1
  251. package/plugins/runtime-modules/search/widgets/search-results/client.js +4 -2
  252. package/plugins/runtime-modules/theme/presets.d.ts +4 -0
  253. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +76 -4
  254. package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +3 -2
  255. package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +2 -2
  256. package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +19 -7
  257. package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
  258. package/plugins/runtime-modules/threads/controller/definition.js +1 -1
  259. package/plugins/runtime-modules/threads/data-providers.d.ts +115 -2
  260. package/plugins/runtime-modules/threads/data-providers.js +85 -0
  261. package/plugins/runtime-modules/threads/definition.d.ts +115 -2
  262. package/plugins/runtime-modules/threads/definition.js +1 -1
  263. package/plugins/runtime-modules/threads/ids.d.ts +2 -0
  264. package/plugins/runtime-modules/threads/ids.js +3 -0
  265. package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +192 -0
  266. package/plugins/runtime-modules/threads/services/customer-file-table.js +164 -0
  267. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +5 -3
  268. package/plugins/runtime-modules/user-management/client-data-providers.js +5 -0
  269. package/plugins/runtime-modules/user-management/data-providers.d.ts +159 -0
  270. package/plugins/runtime-modules/user-management/data-providers.js +101 -3
  271. package/plugins/runtime-modules/user-management/definition.d.ts +159 -0
  272. package/plugins/runtime-modules/user-management/ids.d.ts +9 -0
  273. package/plugins/runtime-modules/user-management/ids.js +9 -0
  274. package/plugins/runtime-modules/user-management/presets.js +17 -1
  275. package/plugins/runtime-modules/user-management/services/users-access-table.d.ts +378 -0
  276. package/plugins/runtime-modules/user-management/services/users-access-table.js +132 -0
  277. package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +86 -0
  278. package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +118 -0
  279. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.d.ts +20 -0
  280. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +166 -0
  281. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +19 -18
  282. package/server-helpers/cms-page-record.d.ts +9 -1
  283. package/server-helpers/cms-page-record.js +11 -1
  284. package/server-helpers/cms-request.js +8 -5
  285. package/server-helpers/link-preview-image.d.ts +30 -0
  286. package/server-helpers/link-preview-image.js +57 -0
  287. package/server-helpers/search-text.js +3 -0
  288. package/server-helpers.d.ts +1 -1
  289. package/server-helpers.js +1 -1
  290. package/styles/shell.css +30 -6
  291. package/theme/phi-theme-composition.js +9 -0
  292. package/theme/phi-theme-inverse-ground.d.ts +39 -0
  293. package/theme/phi-theme-inverse-ground.js +103 -0
  294. package/theme/phi-theme-tokens.d.ts +2 -1
  295. package/theme/phi-theme-tokens.js +2 -0
  296. package/types/cms-module-descriptors.d.ts +14 -0
  297. package/types/cms-overlay.d.ts +13 -6
  298. package/types/cms-overlay.js +6 -22
  299. package/types/cms-plugins.d.ts +14 -2
  300. package/types/cms.d.ts +10 -0
  301. package/types/core-widget-placements.d.ts +3 -3
  302. package/types/link-preview.d.ts +19 -0
  303. package/types/link-preview.js +19 -0
  304. package/types/record-provider.d.ts +22 -1
  305. package/types/site-theme.d.ts +27 -0
  306. package/types/table-embed.d.ts +48 -0
  307. package/types/table-embed.js +1 -0
  308. package/types/table-widget.d.ts +14 -0
  309. package/types/widget-runtime.d.ts +3 -0
  310. package/types.d.ts +1 -0
  311. /package/{plugins/runtime-modules/threads/controller/address.d.ts → constants/threads-controller-address.d.ts} +0 -0
@@ -0,0 +1,23 @@
1
+ import type { PhisSiteAddressInput } from "@phis/contracts/users";
2
+ import { type PhiAddressPart } from "../../helpers/address-field";
3
+ export type PhiAddressControlLabels = Record<PhiAddressPart, string>;
4
+ export type PhiAddressControlProps = {
5
+ /** The id of the first part's input, so a label outside the control can name it. */
6
+ id?: string;
7
+ value: PhisSiteAddressInput;
8
+ labels: PhiAddressControlLabels;
9
+ /** A sentence per part that is wrong, shown under it. */
10
+ errors?: Partial<Record<PhiAddressPart, string>>;
11
+ disabled?: boolean;
12
+ readOnly?: boolean;
13
+ onChange?: (next: PhisSiteAddressInput) => void;
14
+ /** A part was left, so whoever validates may now say what is wrong with it. */
15
+ onPartBlur?: (part: PhiAddressPart) => void;
16
+ };
17
+ /**
18
+ * One postal address in the shape Core writes (`PhisSiteAddressInput`): name, company, two street lines,
19
+ * postal code and city, region and the country -- chosen with `PhiCountrySelectControl`. Each part has its
20
+ * label above it and its sentence under it when it is wrong; required parts carry the marker. The value is
21
+ * the whole address, an empty optional part `null`.
22
+ */
23
+ export declare function PhiAddressControl({ id, value, labels, errors, disabled, readOnly, onChange, onPartBlur, }: PhiAddressControlProps): import("react").JSX.Element;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ import { PHI_ADDRESS_PART_MAX_LENGTHS, PHI_ADDRESS_REQUIRED_PARTS, writePhiAddressFieldPart, } from "../../helpers/address-field";
5
+ import { usePhiConfig } from "../root/phi-config-provider";
6
+ import { PhiCountrySelectControl } from "./phi-country-select-control";
7
+ import { PhiTextControl } from "./phi-text-control";
8
+ const AUTOCOMPLETE = {
9
+ name: "name",
10
+ companyName: "organization",
11
+ line1: "address-line1",
12
+ line2: "address-line2",
13
+ postalCode: "postal-code",
14
+ city: "address-level2",
15
+ region: "address-level1",
16
+ };
17
+ /* Two parts share a row where they are short: postal code beside city, region beside country. */
18
+ const ROWS = [
19
+ ["name"],
20
+ ["companyName"],
21
+ ["line1"],
22
+ ["line2"],
23
+ ["postalCode", "city"],
24
+ ["region", "country"],
25
+ ];
26
+ /**
27
+ * One postal address in the shape Core writes (`PhisSiteAddressInput`): name, company, two street lines,
28
+ * postal code and city, region and the country -- chosen with `PhiCountrySelectControl`. Each part has its
29
+ * label above it and its sentence under it when it is wrong; required parts carry the marker. The value is
30
+ * the whole address, an empty optional part `null`.
31
+ */
32
+ export function PhiAddressControl({ id, value, labels, errors, disabled, readOnly, onChange, onPartBlur, }) {
33
+ const { token } = usePhiConfig();
34
+ const ownId = useId();
35
+ const partId = (part) => (part === "name" && id ? id : `${ownId}-${part}`);
36
+ const write = (part, next) => onChange?.(writePhiAddressFieldPart(value, part, next));
37
+ const renderPart = (part) => {
38
+ const required = PHI_ADDRESS_REQUIRED_PARTS.includes(part);
39
+ const error = errors?.[part];
40
+ return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingXXS, minWidth: 0 }, children: [_jsxs("label", { htmlFor: partId(part), style: { color: token.colorTextHeading, fontSize: token.fontSizeSM }, children: [required ? _jsx("span", { "aria-hidden": true, style: { color: token.colorError, marginInlineEnd: "0.25em" }, children: "*" }) : null, labels[part]] }), part === "country" ? (_jsx(PhiCountrySelectControl, { id: partId(part), value: value.country, disabled: disabled, readOnly: readOnly, onBlur: () => onPartBlur?.(part), onChange: (next) => write(part, next) })) : (_jsx(PhiTextControl, { id: partId(part), value: value[part] ?? "", disabled: disabled, readOnly: readOnly, autoComplete: AUTOCOMPLETE[part], maxLength: PHI_ADDRESS_PART_MAX_LENGTHS[part], onBlur: () => onPartBlur?.(part), onChange: (next) => write(part, next) })), error ? (_jsx("span", { role: "alert", style: { color: token.colorError, fontSize: token.fontSizeSM }, children: error })) : null] }, part));
41
+ };
42
+ return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%", minWidth: 0 }, children: ROWS.map((row) => row.length === 1 ? renderPart(row[0]) : (_jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(10rem, 1fr))", gap: token.paddingSM }, children: row.map(renderPart) }, row.join("-")))) }));
43
+ }
@@ -20,6 +20,8 @@ export type PhiColorControlProps = PhiPickerTransactionCallbacks<string | null>
20
20
  defaultValue?: string;
21
21
  disabled?: boolean;
22
22
  allowClear?: boolean;
23
+ /** Offer no transparency: the alpha slider is gone and a picked colour with alpha is made opaque. */
24
+ disabledAlpha?: boolean;
23
25
  mode?: PhiColorPickerMode;
24
26
  open?: boolean;
25
27
  showText?: boolean;
@@ -33,4 +35,4 @@ export type PhiColorControlProps = PhiPickerTransactionCallbacks<string | null>
33
35
  renderPanel?: (panel: ReactNode) => ReactNode;
34
36
  onClear?: () => void;
35
37
  };
36
- export declare function PhiColorControl({ value, defaultValue, disabled, allowClear, mode, open, showText, trigger, placement, size, children, presets, getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }: PhiColorControlProps): import("react").JSX.Element;
38
+ export declare function PhiColorControl({ value, defaultValue, disabled, allowClear, disabledAlpha, mode, open, showText, trigger, placement, size, children, presets, getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }: PhiColorControlProps): import("react").JSX.Element;
@@ -56,7 +56,7 @@ function resolveCssValue(nextValue, fallbackCss) {
56
56
  function resolveAntdMode(mode) {
57
57
  return mode === "both" ? ["single", "gradient"] : mode;
58
58
  }
59
- export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabled, allowClear, mode = "single", open, showText, trigger, placement = "auto", size, children, presets = [], getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }) {
59
+ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabled, allowClear, disabledAlpha, mode = "single", open, showText, trigger, placement = "auto", size, children, presets = [], getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }) {
60
60
  const { token } = theme.useToken();
61
61
  const picker = usePhiImmediatePicker({
62
62
  value,
@@ -93,7 +93,7 @@ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabl
93
93
  colors: [...preset.colors],
94
94
  defaultOpen: preset.defaultOpen,
95
95
  }));
96
- return (_jsx(ColorPicker, { mode: resolveAntdMode(mode), value: resolveAntdColorValue(resolvePhiColorReferences(picker.value, references), defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
96
+ return (_jsx(ColorPicker, { mode: resolveAntdMode(mode), value: resolveAntdColorValue(resolvePhiColorReferences(picker.value, references), defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, disabledAlpha: disabledAlpha, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
97
97
  root: {
98
98
  display: "inline-flex",
99
99
  alignItems: "center",
@@ -0,0 +1,22 @@
1
+ import { type CSSProperties } from "react";
2
+ import type { PhiControlSize } from "../../types/control";
3
+ export type PhiCountrySelectControlProps = {
4
+ id?: string;
5
+ /** An ISO 3166-1 alpha-2 code, uppercase; anything else shows as no choice. */
6
+ value?: string | null;
7
+ placeholder?: string;
8
+ ariaLabel?: string;
9
+ disabled?: boolean;
10
+ readOnly?: boolean;
11
+ allowClear?: boolean;
12
+ size?: PhiControlSize;
13
+ style?: CSSProperties;
14
+ onBlur?: () => void;
15
+ onChange: (code: string | null) => void;
16
+ };
17
+ /**
18
+ * A country chosen from ISO 3166-1, by name in the page's language: the Select Control with every code
19
+ * of `PHI_ISO_3166_ALPHA2_CODES` named through `Intl.DisplayNames` and sorted as the language sorts,
20
+ * searchable by name and by code. What it holds is the code.
21
+ */
22
+ export declare function PhiCountrySelectControl({ id, value, placeholder, ariaLabel, disabled, readOnly, allowClear, size, style, onBlur, onChange, }: PhiCountrySelectControlProps): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { listPhiCountryOptions } from "../../helpers/country-names";
5
+ import { usePhiIntlLocale } from "../root/phi-intl-locale";
6
+ import { PhiSelectControl } from "./phi-select-control";
7
+ /**
8
+ * A country chosen from ISO 3166-1, by name in the page's language: the Select Control with every code
9
+ * of `PHI_ISO_3166_ALPHA2_CODES` named through `Intl.DisplayNames` and sorted as the language sorts,
10
+ * searchable by name and by code. What it holds is the code.
11
+ */
12
+ export function PhiCountrySelectControl({ id, value, placeholder, ariaLabel, disabled, readOnly, allowClear, size, style, onBlur, onChange, }) {
13
+ const locale = usePhiIntlLocale();
14
+ const options = useMemo(() => listPhiCountryOptions(locale), [locale]);
15
+ return (_jsx(PhiSelectControl, { id: id, value: value && options.some((option) => option.value === value) ? value : undefined, placeholder: placeholder, ariaLabel: ariaLabel, disabled: disabled, readOnly: readOnly, allowClear: allowClear, size: size, options: options, style: style ?? { width: "100%" }, onBlur: onBlur, onChange: (next) => onChange(typeof next === "string" && next ? next : null) }));
16
+ }
@@ -74,7 +74,7 @@ export type PhiDialogControlProps = {
74
74
  presentation?: "modal" | "drawer";
75
75
  /** The edge a Drawer comes from. */
76
76
  placement?: PhiDrawerControlProps["placement"];
77
- /** A Drawer's width (or height, from the top or bottom). */
77
+ /** A Drawer's size, a block's pair: its `width`, or its `height` from the top or bottom. */
78
78
  size?: PhiDrawerControlProps["size"];
79
79
  onDismiss?: (source: PhiOverlayCloseSource) => void;
80
80
  afterOpenChange?: (open: boolean) => void;
@@ -1,2 +1,2 @@
1
1
  import type { PhiDrawerControlProps } from "./phi-drawer-control";
2
- export declare function PhiDrawerControlAdapter({ open, title, header, body, footer, closable, keyboard, mask, mountPolicy, placement, size, maxSize, resizable, push, zIndex, containerStyle, onDismiss, afterOpenChange, panelRef, }: PhiDrawerControlProps): import("react").JSX.Element;
2
+ export declare function PhiDrawerControlAdapter({ open, title, header, body, footer, closable, keyboard, mask, mountPolicy, placement, size, minSize, maxSize, resizable, push, zIndex, containerStyle, onDismiss, afterOpenChange, panelRef, }: PhiDrawerControlProps): import("react").JSX.Element;
@@ -6,21 +6,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  */
7
7
  import { Drawer } from "antd";
8
8
  import { PHI_FONT_SIZE, PHI_SPACE } from "../../theme/antd-css-var-contract";
9
- import { PHI_OVERLAY_DEFAULT_MASK, resolvePhiOverlayDismissSource, resolvePhiOverlayMaskPresentation, } from "./phi-overlay-control-contract";
9
+ import { PHI_OVERLAY_DEFAULT_MASK, resolvePhiDrawerGeometry, resolvePhiOverlayDismissSource, resolvePhiOverlayMaskPresentation, } from "./phi-overlay-control-contract";
10
10
  import { usePhiHydrated } from "../state/use-phi-hydrated";
11
11
  const PHI_DRAWER_HEADER_MIN_BLOCK_SIZE = `calc(var(--phi-control-height) + ${PHI_SPACE.xs} + ${PHI_SPACE.xs})`;
12
12
  /** Where a title starts when the close button stands before it: past the button, not beneath it. */
13
13
  const PHI_DRAWER_TITLE_AFTER_CLOSE = `calc(${PHI_SPACE.sm} + var(--phi-control-height) + ${PHI_SPACE.xs})`;
14
- export function PhiDrawerControlAdapter({ open, title, header, body, footer, closable = true, keyboard = true, mask = PHI_OVERLAY_DEFAULT_MASK, mountPolicy = "remount", placement = "right", size, maxSize, resizable = false, push = false, zIndex, containerStyle, onDismiss, afterOpenChange, panelRef, }) {
14
+ export function PhiDrawerControlAdapter({ open, title, header, body, footer, closable = true, keyboard = true, mask = PHI_OVERLAY_DEFAULT_MASK, mountPolicy = "remount", placement = "right", size, minSize, maxSize, resizable = false, push = false, zIndex, containerStyle, onDismiss, afterOpenChange, panelRef, }) {
15
15
  const hydrated = usePhiHydrated();
16
16
  const resolvedMask = resolvePhiOverlayMaskPresentation(mask);
17
+ const geometry = resolvePhiDrawerGeometry({ size, minSize, maxSize, placement });
17
18
  const closeAtInlineStart = placement === "right";
18
19
  // A drawer with nothing to say in its header draws none: no title, no header content, no close button.
19
20
  const hasHeaderContent = header != null || title != null;
20
21
  const hasHeader = hasHeaderContent || closable;
21
22
  const titleInset = closable && closeAtInlineStart ? PHI_DRAWER_TITLE_AFTER_CLOSE : PHI_SPACE.lg;
22
23
  const renderedTitle = hasHeaderContent ? (_jsxs("div", { style: { display: "grid", minBlockSize: PHI_DRAWER_HEADER_MIN_BLOCK_SIZE, minWidth: 0, position: "relative", width: "100%" }, children: [header, title == null ? null : (_jsx("div", { style: { insetInlineStart: titleInset, minWidth: 0, position: "absolute", top: "50%", transform: "translateY(-50%)", zIndex: 1 }, children: title }))] })) : null;
23
- return (_jsx(Drawer, { open: open, title: renderedTitle, closable: closable ? { placement: closeAtInlineStart ? "start" : "end" } : false, keyboard: keyboard, mask: resolvedMask.adapterMask, destroyOnHidden: mountPolicy === "remount", forceRender: hydrated && mountPolicy === "eager", placement: placement, size: size, maxSize: maxSize, resizable: resizable, push: push, zIndex: zIndex, footer: footer ?? null, focusable: { trap: true, focusTriggerAfterClose: true }, styles: {
24
+ return (_jsx(Drawer, { open: open, title: renderedTitle, closable: closable ? { placement: closeAtInlineStart ? "start" : "end" } : false, keyboard: keyboard, mask: resolvedMask.adapterMask, destroyOnHidden: mountPolicy === "remount", forceRender: hydrated && mountPolicy === "eager", placement: placement, size: geometry.size, maxSize: geometry.resizeMaxSize, resizable: resizable, push: push, zIndex: zIndex, footer: footer ?? null, focusable: { trap: true, focusTriggerAfterClose: true }, styles: {
24
25
  mask: resolvedMask.maskStyle,
25
26
  wrapper: {
26
27
  /*
@@ -31,6 +32,7 @@ export function PhiDrawerControlAdapter({ open, title, header, body, footer, clo
31
32
  */
32
33
  background: "var(--phi-color-bg-elevated)",
33
34
  ...containerStyle,
35
+ ...geometry.style,
34
36
  padding: 0,
35
37
  },
36
38
  section: {
@@ -1,9 +1,11 @@
1
- import type { PhiCmsOverlayConfig, PhiCmsOverlaySize, PhiOverlayPushBehaviour } from "../../types/cms-overlay";
2
- import type { PhiOverlayControlCommonProps } from "./phi-overlay-control-contract";
3
- export type PhiDrawerControlProps = PhiOverlayControlCommonProps & {
1
+ import type { PhiCmsOverlayConfig, PhiOverlayPushBehaviour } from "../../types/cms-overlay";
2
+ import type { PhiOverlayControlCommonProps, PhiOverlayControlGeometryProps } from "./phi-overlay-control-contract";
3
+ /**
4
+ * `size`, `minSize` and `maxSize` are the block's pairs; the Drawer draws the axis it opens along
5
+ * (`resolvePhiDrawerGeometry`).
6
+ */
7
+ export type PhiDrawerControlProps = PhiOverlayControlCommonProps & PhiOverlayControlGeometryProps & {
4
8
  placement?: PhiCmsOverlayConfig["placement"];
5
- size?: PhiCmsOverlaySize;
6
- maxSize?: number;
7
9
  resizable?: boolean;
8
10
  push?: PhiOverlayPushBehaviour;
9
11
  zIndex?: number;
@@ -1,5 +1,11 @@
1
1
  import type { PhiToolbarControlItem } from "./phi-toolbar-control";
2
2
  export type PhiFloatButtonControlPlacement = "bottom-end" | "bottom-start" | "top-end" | "top-start";
3
+ /**
4
+ * How large the buttons are. A Float Button is drawn at the large control height by Ant Design; that is
5
+ * `medium` here, and `small` steps one down the Theme's control heights. The ladder has no step above
6
+ * it, so there is no `large`.
7
+ */
8
+ export type PhiFloatButtonControlSize = "small" | "medium";
3
9
  export type PhiFloatButtonControlGroup = {
4
10
  /** How the group opens. Left out, it is always open: every button stands in the corner. */
5
11
  trigger?: "click" | "hover";
@@ -24,6 +30,7 @@ export type PhiFloatButtonControlProps = {
24
30
  * floating over the editor could neither be seen in its slot nor selected there.
25
31
  */
26
32
  inPlace?: boolean;
33
+ size?: PhiFloatButtonControlSize;
27
34
  disabled?: boolean;
28
35
  onActivate?: (key: string) => void;
29
36
  };
@@ -36,4 +43,4 @@ export type PhiFloatButtonControlProps = {
36
43
  * on a Float Button and are not imitated: `danger`, and `loading`, which disables the button instead of
37
44
  * spinning.
38
45
  */
39
- export declare function PhiFloatButtonControl({ items, placement, offset, shape, group, inPlace, disabled, onActivate, }: PhiFloatButtonControlProps): import("react").JSX.Element | null;
46
+ export declare function PhiFloatButtonControl({ items, placement, offset, shape, group, inPlace, size, disabled, onActivate, }: PhiFloatButtonControlProps): import("react").JSX.Element | null;
@@ -5,6 +5,21 @@ import { createPortal } from "react-dom";
5
5
  import { FloatButton } from "antd";
6
6
  import { PhiIcon } from "../shell/phi-icon";
7
7
  import { usePhiHydrated } from "../state/use-phi-hydrated";
8
+ import { PHI_CONTROL } from "../../theme/antd-css-var-contract";
9
+ /*
10
+ * Ant Design sizes the button by its own variable (`--ant-float-btn-size`, under the component prefix, as
11
+ * the Select's are) and opens a group's list from the trigger by the same length plus the padding.
12
+ */
13
+ function resolveSizeStyle(size) {
14
+ if (size !== "small")
15
+ return undefined;
16
+ return { "--ant-float-btn-size": PHI_CONTROL.md };
17
+ }
18
+ function resolveGroupSizeStyle(size) {
19
+ if (size !== "small")
20
+ return undefined;
21
+ return { "--ant-float-btn-list-trigger-offset": `calc(${PHI_CONTROL.md} + var(--phi-padding))` };
22
+ }
8
23
  /**
9
24
  * Where a fixed button is drawn: on `document.body`, outside every box of the page.
10
25
  *
@@ -47,7 +62,8 @@ function resolveCornerStyle(placement, offset, inPlace) {
47
62
  * on a Float Button and are not imitated: `danger`, and `loading`, which disables the button instead of
48
63
  * spinning.
49
64
  */
50
- export function PhiFloatButtonControl({ items, placement = "bottom-end", offset, shape = "circle", group, inPlace = false, disabled, onActivate, }) {
65
+ export function PhiFloatButtonControl({ items, placement = "bottom-end", offset, shape = "circle", group, inPlace = false, size, disabled, onActivate, }) {
66
+ const sizeStyle = resolveSizeStyle(size);
51
67
  const visibleItems = items.filter((item) => item.visible !== false);
52
68
  if (visibleItems.length === 0) {
53
69
  return null;
@@ -65,9 +81,9 @@ export function PhiFloatButtonControl({ items, placement = "bottom-end", offset,
65
81
  }
66
82
  : undefined,
67
83
  /* A single button carries the corner itself; inside a group, the group does. */
68
- style: visibleItems.length === 1 && index === 0 ? cornerStyle : undefined, onClick: item.readOnly || !onActivate ? undefined : () => onActivate(item.key) }, item.key));
84
+ style: visibleItems.length === 1 && index === 0 ? { ...cornerStyle, ...sizeStyle } : sizeStyle, onClick: item.readOnly || !onActivate ? undefined : () => onActivate(item.key) }, item.key));
69
85
  });
70
- const placed = buttons.length === 1 ? buttons[0] : (_jsx(FloatButton.Group, { trigger: group?.trigger, icon: group?.icon ? _jsx(PhiIcon, { name: group.icon, size: "inherit" }) : undefined, placement: group?.direction ?? (placement.startsWith("top") ? "bottom" : "top"), shape: shape, style: cornerStyle, children: buttons }));
86
+ const placed = buttons.length === 1 ? buttons[0] : (_jsx(FloatButton.Group, { trigger: group?.trigger, icon: group?.icon ? _jsx(PhiIcon, { name: group.icon, size: "inherit" }) : undefined, placement: group?.direction ?? (placement.startsWith("top") ? "bottom" : "top"), shape: shape, style: { ...cornerStyle, ...resolveGroupSizeStyle(size) }, children: buttons }));
71
87
  /* In place it stays in its slot, where the Builder's canvas can show and select it. */
72
88
  return inPlace ? placed : _jsx(PhiFloatButtonPortal, { children: placed });
73
89
  }
@@ -10,6 +10,7 @@ import { PhiDescriptionHint } from "./phi-description-tooltip-icon";
10
10
  import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_FIELD_UNAVAILABLE_DEFAULT_LABEL, PHI_FORM_FIELD_UNAVAILABLE_LABEL_KEY, PHI_FORM_VALIDATION_PROVIDER_KEYS, } from "../forms/form-provider-contract";
11
11
  import { phiFormCellOpensColumn, phiFormControlGridColumn, phiFormFieldFollowsLayoutColumns, phiFormLabelGridColumn, resolvePhiFormGridPlacement, resolvePhiFormLayout, PHI_FORM_RESPONSIVE_MODES, resolvePhiFormText, shouldPhiFormSubmitOnKeyDown, } from "../forms/form-descriptor-contract";
12
12
  import { readPhiMoneyFieldCurrencyFieldKey } from "../forms/money-field-currency-key";
13
+ import { collectFormOptionFlagFieldKeys, resolveFormChosenOptionFlags, } from "../forms/form-option-flags";
13
14
  import { PHI_SHARED_FORM_PROVIDER_REGISTRY } from "../forms/shared-form-provider-registry";
14
15
  import { resolvePhiControlOptionsDependencies, usePhiControlOptionsProvider, } from "./phi-options-provider";
15
16
  /** The id Ant Design gives a Form Item's control: the form's name and the field's key, joined by `_`. */
@@ -83,7 +84,7 @@ function pickPhiFormWatchedValues(values, keys) {
83
84
  }
84
85
  return picked;
85
86
  }
86
- function PhiResolvedFormFieldControl({ id, provider, field, label, description, labels, formConfig, placeholder, disabled, readOnly, value, checked, onChange, formContext, formValues, mediaLimits, }) {
87
+ function PhiResolvedFormFieldControl({ id, provider, field, label, description, labels, formConfig, placeholder, disabled, readOnly, value, checked, onChange, formContext, formValues, mediaLimits, onChosenOptionFlags, }) {
87
88
  const staticOptions = useMemo(() => field.options?.map((option) => ({
88
89
  ...option,
89
90
  label: resolvePhiFormText(option.label, labels, formConfig),
@@ -139,6 +140,13 @@ function PhiResolvedFormFieldControl({ id, provider, field, label, description,
139
140
  if (value != null && value !== "")
140
141
  onChange?.(undefined);
141
142
  }, [onChange, requiredDependencyKey, value]);
143
+ const chosenOptionFlags = onChosenOptionFlags
144
+ ? resolveFormChosenOptionFlags(resolvedOptions.options, value)
145
+ : undefined;
146
+ useEffect(() => {
147
+ onChosenOptionFlags?.(chosenOptionFlags);
148
+ }, [chosenOptionFlags, onChosenOptionFlags]);
149
+ useEffect(() => () => onChosenOptionFlags?.(undefined), [onChosenOptionFlags]);
142
150
  const Control = provider.Control;
143
151
  const controlLabel = field.controlLabel
144
152
  ? resolvePhiFormText(field.controlLabel, labels, formConfig)
@@ -250,8 +258,10 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
250
258
  async function submit(values) {
251
259
  const holds = [...submitHoldsRef.current];
252
260
  if (holds.length > 0) {
253
- form.setFields(holds.map(([name, reason]) => ({ name, errors: [reason] })));
254
- onValidationFailed?.({ valid: false, errors: Object.fromEntries(holds.map(([name, reason]) => [name, [reason]])) });
261
+ form.setFields(holds.flatMap(([name, { reason, onRefused }]) => onRefused ? [] : [{ name, errors: [reason] }]));
262
+ for (const [, { onRefused }] of holds)
263
+ onRefused?.();
264
+ onValidationFailed?.({ valid: false, errors: Object.fromEntries(holds.map(([name, { reason }]) => [name, [reason]])) });
255
265
  return;
256
266
  }
257
267
  setSubmitting(true);
@@ -301,20 +311,52 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
301
311
  const selectWatchedFormValues = useCallback((values) => pickPhiFormWatchedValues(values, watchedFormKeys), [watchedFormKeys]);
302
312
  const watchedFormValues = Form.useWatch(selectWatchedFormValues, { form, preserve: true });
303
313
  const formValues = useMemo(() => watchedFormValues ?? pickPhiFormWatchedValues(resolvedInitialValues, watchedFormKeys), [resolvedInitialValues, watchedFormKeys, watchedFormValues]);
314
+ /*
315
+ * What an `optionFlag` condition reads: the flags of the option chosen in each field one of them names.
316
+ * Written-out options are known here and answered during the render, the server's included; a
317
+ * Provider's are known only to the field that resolved them, which reports them once it has.
318
+ */
319
+ const optionFlagFieldKeys = useMemo(() => collectFormOptionFlagFieldKeys(descriptor.fields), [descriptor.fields]);
320
+ const [reportedOptionFlags, setReportedOptionFlags] = useState({});
321
+ const optionFlagReporters = useMemo(() => new Map([...optionFlagFieldKeys].map((key) => [
322
+ key,
323
+ (flags) => setReportedOptionFlags((current) => {
324
+ if (current[key] === flags)
325
+ return current;
326
+ const next = { ...current };
327
+ if (flags === undefined)
328
+ delete next[key];
329
+ else
330
+ next[key] = flags;
331
+ return next;
332
+ }),
333
+ ])), [optionFlagFieldKeys]);
334
+ const formOptionFlags = useMemo(() => {
335
+ const flags = {};
336
+ for (const key of optionFlagFieldKeys) {
337
+ const field = descriptor.fields.find((entry) => entry.key === key);
338
+ const chosen = field?.optionsProvider
339
+ ? reportedOptionFlags[key]
340
+ : resolveFormChosenOptionFlags(field?.options, formValues[key]);
341
+ if (chosen !== undefined)
342
+ flags[key] = chosen;
343
+ }
344
+ return flags;
345
+ }, [descriptor.fields, formValues, optionFlagFieldKeys, reportedOptionFlags]);
304
346
  const fieldFormContext = useMemo(() => ({
305
347
  getValues: () => form.getFieldsValue(true),
306
- holdSubmit: (fieldKey, reason) => {
348
+ holdSubmit: (fieldKey, reason, onRefused) => {
307
349
  const holds = submitHoldsRef.current;
308
350
  const held = holds.get(fieldKey);
309
351
  if (reason == null) {
310
352
  holds.delete(fieldKey);
311
353
  // The sentence a refused submit left on the field goes with the hold; any other error stays.
312
- if (held != null && form.getFieldError(fieldKey).includes(held)) {
354
+ if (held != null && form.getFieldError(fieldKey).includes(held.reason)) {
313
355
  form.setFields([{ name: fieldKey, errors: [] }]);
314
356
  }
315
357
  return;
316
358
  }
317
- holds.set(fieldKey, reason);
359
+ holds.set(fieldKey, onRefused ? { reason, onRefused } : { reason });
318
360
  },
319
361
  setValues: (values) => {
320
362
  form.setFields(Object.entries(values).map(([name, value]) => ({ name, value, touched: true })));
@@ -335,8 +377,9 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
335
377
  !field.visibleWhen ||
336
378
  evaluatePhiRuntimeConditionExpression(field.visibleWhen, {
337
379
  form: formValues,
380
+ formOptionFlags,
338
381
  controllers: conditionControllerStates,
339
- }) === "matched"), [activeRegistry, conditionControllerStates, descriptor.fields, formValues]);
382
+ }) === "matched"), [activeRegistry, conditionControllerStates, descriptor.fields, formOptionFlags, formValues]);
340
383
  /*
341
384
  * Where every part of every field lies, at each of the three widths, worked out before anything is
342
385
  * drawn. Labels and controls are direct children of the form's grid and name their own row and
@@ -488,6 +531,7 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
488
531
  const fieldDisabled = field.disabledWhen
489
532
  ? evaluatePhiRuntimeConditionExpression(field.disabledWhen, {
490
533
  form: formValues,
534
+ formOptionFlags,
491
535
  controllers: conditionControllerStates,
492
536
  })
493
537
  : "not-matched";
@@ -529,6 +573,6 @@ export const PhiFormControl = forwardRef(function PhiFormControl({ descriptor, r
529
573
  ...resolveHoneypotStyle(provider.presentation),
530
574
  }, children: _jsx(Form.Item, { name: field.key, messageVariables: { label: labelText ?? field.key }, hidden: hidden, valuePropName: provider.valuePropName, dependencies: dependencies, required: required, rules: resolvedRules.length === 0 ? undefined : resolvedRules, style: { marginBottom: 0 }, children: _jsx(PhiResolvedFormFieldControl, { provider: provider, field: field, label: providerLabel, description: providerDescription, labels: labels, formConfig: formConfig, placeholder: field.placeholder
531
575
  ? resolvePhiFormText(field.placeholder, labels, formConfig)
532
- : undefined, disabled: disabled || submitting || readOnly || field.config?.disabled === true || fieldDisabled !== "not-matched", readOnly: readOnly, formContext: fieldFormContext, formValues: formValues, mediaLimits: mediaLimits }) }) })] }, field.key));
576
+ : undefined, disabled: disabled || submitting || readOnly || field.config?.disabled === true || fieldDisabled !== "not-matched", readOnly: readOnly, formContext: fieldFormContext, formValues: formValues, mediaLimits: mediaLimits, onChosenOptionFlags: field.optionsProvider ? optionFlagReporters.get(field.key) : undefined }) }) })] }, field.key));
533
577
  }) }) }));
534
578
  });
@@ -1,2 +1,2 @@
1
1
  import type { PhiModalControlProps } from "./phi-modal-control";
2
- export declare function PhiModalControlAdapter({ open, title, header, body, footer, closable, keyboard, mask, mountPolicy, centered, controlSize, size, width, rootClassName, containerStyle, onDismiss, afterOpenChange, panelRef, }: PhiModalControlProps): import("react").JSX.Element;
2
+ export declare function PhiModalControlAdapter({ open, title, header, body, footer, closable, keyboard, mask, mountPolicy, centered, controlSize, size, minSize, maxSize, toldSize, rootClassName, containerStyle, onDismiss, afterOpenChange, panelRef, }: PhiModalControlProps): import("react").JSX.Element;
@@ -5,38 +5,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  * Everything Ant Design's Modal brings -- the dialog, its motion and focus trap -- is paid by the pages
6
6
  * that open one, not by every page that could.
7
7
  */
8
- import { useEffect, useRef, useSyncExternalStore } from "react";
8
+ import { useEffect, useRef } from "react";
9
9
  import { Modal } from "antd";
10
10
  import { PHI_CONTROL, PHI_SPACE } from "../../theme/antd-css-var-contract";
11
11
  import { resolvePhiMotionDurationMs } from "../../helpers/motion";
12
12
  import { usePhiConfig } from "../root/phi-config-provider";
13
- import { PHI_MODAL_RESPONSIVE_MIN_WIDTH, PHI_OVERLAY_DEFAULT_MASK, resolvePhiModalResponsiveMode, resolvePhiModalWidth, resolvePhiOverlayDismissSource, resolvePhiOverlayMaskPresentation, } from "./phi-overlay-control-contract";
13
+ import { PHI_OVERLAY_DEFAULT_MASK, resolvePhiModalGeometry, resolvePhiOverlayDismissSource, resolvePhiOverlayMaskPresentation, } from "./phi-overlay-control-contract";
14
14
  import { usePhiHydrated } from "../state/use-phi-hydrated";
15
- const PHI_MODAL_MODE_QUERIES = [
16
- `(min-width: ${PHI_MODAL_RESPONSIVE_MIN_WIDTH.medium}px)`,
17
- `(min-width: ${PHI_MODAL_RESPONSIVE_MIN_WIDTH.wide}px)`,
18
- ];
19
- /** The viewport crosses one of the Modal's two thresholds far less often than it resizes. */
20
- function subscribeModalMode(onChange) {
21
- const queries = PHI_MODAL_MODE_QUERIES.map((query) => window.matchMedia(query));
22
- for (const query of queries)
23
- query.addEventListener("change", onChange);
24
- return () => {
25
- for (const query of queries)
26
- query.removeEventListener("change", onChange);
27
- };
28
- }
29
- function readModalMode() {
30
- return resolvePhiModalResponsiveMode(window.innerWidth);
31
- }
32
- function readServerModalMode() {
33
- return "compact";
34
- }
35
- const PHI_MODAL_WIDTH_BY_CONTROL_SIZE = {
36
- small: 520,
37
- medium: 720,
38
- large: 960,
39
- };
40
15
  /** What a dialog opens on: the first thing to type into or choose from, never a button or a hint. */
41
16
  const PHI_MODAL_FIRST_FIELD_SELECTOR = [
42
17
  "input:not([type=hidden]):not(:disabled)",
@@ -56,10 +31,11 @@ const PHI_MODAL_TAB_STOP_SELECTOR = [
56
31
  /** About a second: a Form that loads its descriptor late still gets the focus, a slower one does not. */
57
32
  const PHI_MODAL_FIRST_FIELD_MAX_FRAMES = 60;
58
33
  const PHI_MODAL_HEADER_MIN_BLOCK_SIZE = `calc(${PHI_CONTROL.md} + ${PHI_SPACE.xs} + ${PHI_SPACE.xs})`;
59
- export function PhiModalControlAdapter({ open, title, header, body, footer, closable = true, keyboard = true, mask = PHI_OVERLAY_DEFAULT_MASK, mountPolicy = "remount", centered = false, controlSize, size, width, rootClassName, containerStyle, onDismiss, afterOpenChange, panelRef, }) {
34
+ export function PhiModalControlAdapter({ open, title, header, body, footer, closable = true, keyboard = true, mask = PHI_OVERLAY_DEFAULT_MASK, mountPolicy = "remount", centered = false, controlSize, size, minSize, maxSize, toldSize, rootClassName, containerStyle, onDismiss, afterOpenChange, panelRef, }) {
60
35
  const { token } = usePhiConfig();
61
36
  const hydrated = usePhiHydrated();
62
- const mode = useSyncExternalStore(subscribeModalMode, readModalMode, readServerModalMode);
37
+ const geometry = resolvePhiModalGeometry({ size, minSize, maxSize, toldSize, controlSize });
38
+ const blockSize = geometry.blockSize;
63
39
  const bodyMeasureRef = useRef(null);
64
40
  const bodyContentRef = useRef(null);
65
41
  const dialogRef = useRef(null);
@@ -67,7 +43,7 @@ export function PhiModalControlAdapter({ open, title, header, body, footer, clos
67
43
  useEffect(() => {
68
44
  const bodyMeasure = bodyMeasureRef.current;
69
45
  const bodyContent = bodyContentRef.current;
70
- if (!open || !bodyMeasure || !bodyContent || size?.height != null || typeof ResizeObserver === "undefined") {
46
+ if (!open || !bodyMeasure || !bodyContent || blockSize != null || typeof ResizeObserver === "undefined") {
71
47
  return undefined;
72
48
  }
73
49
  let targetBlockSize = bodyContent.getBoundingClientRect().height;
@@ -105,7 +81,7 @@ export function PhiModalControlAdapter({ open, title, header, body, footer, clos
105
81
  resizeAnimationRef.current?.cancel();
106
82
  resizeAnimationRef.current = null;
107
83
  };
108
- }, [open, size?.height, token.motionDurationMid, token.motionEaseInOut]);
84
+ }, [open, blockSize, token.motionDurationMid, token.motionEaseInOut]);
109
85
  /*
110
86
  * Ant Design's lock moves the focus to the first focusable element, which is the close button, so a
111
87
  * dialog with a Form could not be typed into until Tab was pressed. The field may mount a few frames
@@ -156,11 +132,11 @@ export function PhiModalControlAdapter({ open, title, header, body, footer, clos
156
132
  transform: "translateY(-50%)",
157
133
  zIndex: 1,
158
134
  }, children: title }))] }));
159
- const resolvedWidth = size?.width ?? resolvePhiModalWidth(width, controlSize == null ? undefined : PHI_MODAL_WIDTH_BY_CONTROL_SIZE[controlSize], mode);
160
135
  // The wrapper covers the viewport; letting the pointer through means opening it, not just the mask.
161
136
  const passesOutsidePointer = !resolvedMask.capturesOutsidePointer;
162
- return (_jsx(Modal, { open: open, title: renderedTitle, closable: closable, keyboard: keyboard, mask: resolvedMask.adapterMask, destroyOnHidden: mountPolicy === "remount", forceRender: hydrated && mountPolicy === "eager", centered: centered, width: resolvedWidth, style: {
163
- maxWidth: `calc(100vw - ${PHI_SPACE.base} - ${PHI_SPACE.base})`,
137
+ return (_jsx(Modal, { open: open, title: renderedTitle, closable: closable, keyboard: keyboard, mask: resolvedMask.adapterMask, destroyOnHidden: mountPolicy === "remount", forceRender: hydrated && mountPolicy === "eager", centered: centered, width: geometry.width, style: {
138
+ ...(geometry.minWidth == null ? null : { minWidth: geometry.minWidth }),
139
+ maxWidth: geometry.maxWidth,
164
140
  transition: `width ${token.motionDurationMid} ${token.motionEaseInOut}`,
165
141
  }, rootClassName: rootClassName, footer: footer ?? null, focusable: { trap: true, focusTriggerAfterClose: true }, styles: {
166
142
  mask: resolvedMask.maskStyle,
@@ -170,8 +146,9 @@ export function PhiModalControlAdapter({ open, title, header, body, footer, clos
170
146
  display: "flex",
171
147
  flexDirection: "column",
172
148
  gap: 0,
173
- ...(size?.height == null ? {} : { blockSize: size.height }),
174
- maxBlockSize: `calc(100dvh - ${PHI_SPACE.lg} - ${PHI_SPACE.lg})`,
149
+ ...(blockSize == null ? {} : { blockSize }),
150
+ ...(geometry.minBlockSize == null ? {} : { minBlockSize: geometry.minBlockSize }),
151
+ maxBlockSize: geometry.maxBlockSize,
175
152
  overflow: "hidden",
176
153
  ...containerStyle,
177
154
  padding: 0,
@@ -220,6 +197,6 @@ export function PhiModalControlAdapter({ open, title, header, body, footer, clos
220
197
  minWidth: 0,
221
198
  overflow: "hidden",
222
199
  width: "100%",
223
- ...(size?.height == null ? {} : { minBlockSize: "100%" }),
200
+ ...(blockSize == null ? {} : { minBlockSize: "100%" }),
224
201
  }, children: _jsx("div", { ref: bodyContentRef, "data-phi-modal-body-content": "true", style: { minWidth: 0, width: "100%" }, children: body }) }) }));
225
202
  }
@@ -1,12 +1,12 @@
1
1
  import type { PhiControlSize } from "../../types/control";
2
2
  import type { PhiRenderableBlockSize } from "../../types/renderable-block";
3
- import type { PhiModalWidth, PhiOverlayControlCommonProps } from "./phi-overlay-control-contract";
4
- export type PhiModalControlProps = PhiOverlayControlCommonProps & {
3
+ import type { PhiOverlayControlCommonProps, PhiOverlayControlGeometryProps } from "./phi-overlay-control-contract";
4
+ export type PhiModalControlProps = PhiOverlayControlCommonProps & PhiOverlayControlGeometryProps & {
5
5
  centered?: boolean;
6
+ /** The width step where `size` names no width (`PHI_MODAL_WIDTH_BY_CONTROL_SIZE`). */
6
7
  controlSize?: PhiControlSize;
7
- size?: PhiRenderableBlockSize | null;
8
- /** One width, or one per responsive mode on the container scale (`PHI_MODAL_RESPONSIVE_MIN_WIDTH`). */
9
- width?: PhiModalWidth;
8
+ /** What a `size` Signal told the open Modal; each axis it names stands over the stated `size`. */
9
+ toldSize?: PhiRenderableBlockSize | null;
10
10
  rootClassName?: string;
11
11
  };
12
12
  /**
@@ -128,6 +128,7 @@ export declare function usePhiControlOptionsProvider<TValue extends string | num
128
128
  description?: string;
129
129
  icon?: string;
130
130
  parentValue?: TValue;
131
+ flags?: number;
131
132
  }[] | null;
132
133
  optionsProvider?: PhiControlOptionsProviderConfig | null;
133
134
  sourceConfig?: Record<string, unknown> | null;
@@ -46,6 +46,7 @@ function normalizeStaticOptions(options) {
46
46
  description: option.description,
47
47
  icon: option.icon,
48
48
  parentValue: option.parentValue,
49
+ flags: option.flags,
49
50
  }));
50
51
  }
51
52
  /**