@phis/ui 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/components/cms/phi-cms-layout-renderer.js +15 -7
  2. package/components/cms/phi-cms-render-diagnostic-client.d.ts +3 -1
  3. package/components/cms/phi-cms-render-diagnostic-client.js +4 -3
  4. package/components/cms/phi-cms-render-diagnostic.d.ts +8 -2
  5. package/components/cms/phi-cms-render-diagnostic.js +12 -2
  6. package/components/cms/phi-cms-render-error-boundary.d.ts +2 -0
  7. package/components/cms/phi-cms-render-error-boundary.js +1 -1
  8. package/components/cms/phi-cms-root-layout.js +3 -1
  9. package/components/controls/phi-media-picker-control.d.ts +9 -0
  10. package/components/controls/phi-media-picker-control.js +1 -1
  11. package/components/controls/phi-popover-control.js +4 -1
  12. package/components/controls/phi-table-control.d.ts +7 -1
  13. package/components/controls/phi-table-control.js +23 -8
  14. package/components/forms/form-descriptor-field-check.d.ts +18 -0
  15. package/components/forms/form-descriptor-field-check.js +41 -0
  16. package/components/forms/form-descriptor-runtime-client.js +11 -10
  17. package/components/forms/form-record-source.d.ts +38 -0
  18. package/components/forms/form-record-source.js +48 -0
  19. package/components/forms/shared-form-descriptors.d.ts +0 -34
  20. package/components/forms/shared-form-descriptors.js +0 -6
  21. package/components/forms/shared-form-ids.d.ts +1 -1
  22. package/components/forms/shared-form-ids.js +1 -1
  23. package/components/media/media-settings-labels.d.ts +1 -0
  24. package/components/media/media-settings-labels.js +2 -0
  25. package/components/media/phi-media-picker-binding.d.ts +41 -33
  26. package/components/media/phi-media-picker-binding.js +2 -1
  27. package/components/media/use-media-library-add-picker.d.ts +33 -32
  28. package/components/overlays/phi-overlay-container-client.js +11 -9
  29. package/components/regions/presets/phi-settings-page-shell-tree.d.ts +7 -0
  30. package/components/regions/presets/phi-settings-page-shell-tree.js +3 -3
  31. package/components/shell/phi-icon-names.d.ts +3 -0
  32. package/components/shell/phi-icon-names.js +3 -0
  33. package/components/shell/phi-icon.d.ts +5 -7
  34. package/components/shell/phi-icon.js +8 -21
  35. package/components/tables/client/phi-table-binding-params.d.ts +24 -0
  36. package/components/tables/client/phi-table-binding-params.js +39 -0
  37. package/components/tables/client/phi-table-binding.d.ts +1 -3
  38. package/components/tables/client/phi-table-binding.js +5 -9
  39. package/components/widgets/client/shared/phi-button-icons.d.ts +6 -4
  40. package/components/widgets/client/shared/phi-button-icons.js +8 -12
  41. package/components/widgets/client/shared/phi-collection-binding-params.d.ts +8 -0
  42. package/components/widgets/client/shared/phi-collection-binding-params.js +13 -0
  43. package/components/widgets/client/shared/phi-collection-provider.d.ts +11 -1
  44. package/components/widgets/client/shared/phi-collection-provider.js +5 -0
  45. package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
  46. package/components/widgets/client/shared/phi-command-buttons.d.ts +16 -0
  47. package/components/widgets/client/shared/phi-command-buttons.js +9 -1
  48. package/components/widgets/label-sets/admin-users.d.ts +1 -0
  49. package/components/widgets/label-sets/admin-users.js +2 -0
  50. package/components/widgets/label-sets/builder-modules.js +4 -0
  51. package/components/widgets/label-sets/profile.d.ts +0 -16
  52. package/components/widgets/label-sets/profile.js +0 -37
  53. package/components/widgets/label-sets/registration.d.ts +0 -1
  54. package/components/widgets/label-sets/registration.js +0 -2
  55. package/components/widgets/label-sets/revisions.js +2 -0
  56. package/components/widgets/label-sets/signals.js +2 -0
  57. package/components/widgets/label-types/builder-modules.d.ts +4 -0
  58. package/components/widgets/label-types/builder-modules.js +2 -0
  59. package/components/widgets/label-types/revisions.d.ts +2 -0
  60. package/components/widgets/label-types/revisions.js +2 -1
  61. package/components/widgets/label-types/signals.d.ts +2 -0
  62. package/components/widgets/label-types/signals.js +1 -0
  63. package/components/widgets/shared/widget-failure-audience.d.ts +7 -0
  64. package/components/widgets/shared/widget-failure-audience.js +21 -0
  65. package/components/widgets/shared/widget-failure-client.js +5 -2
  66. package/components/widgets/shared/widget-failure-notice-client.d.ts +6 -0
  67. package/components/widgets/shared/widget-failure-notice-client.js +10 -0
  68. package/components/widgets/shared/widget-failure-notice.d.ts +6 -0
  69. package/components/widgets/shared/widget-failure-notice.js +17 -0
  70. package/components/widgets/shared/widget-failure-staff.d.ts +3 -0
  71. package/components/widgets/shared/widget-failure-staff.js +18 -0
  72. package/components/widgets/shared/widget-failure.d.ts +9 -6
  73. package/components/widgets/shared/widget-failure.js +0 -9
  74. package/components/widgets/shared/widget-failure.server.d.ts +4 -2
  75. package/components/widgets/shared/widget-failure.server.js +8 -3
  76. package/constants/customer-file.d.ts +12 -3
  77. package/constants/customer-file.js +12 -3
  78. package/constants/runtime-module-ownership.js +4 -3
  79. package/constants/site-address.d.ts +9 -0
  80. package/constants/site-address.js +10 -0
  81. package/constants/table-loading.d.ts +14 -0
  82. package/constants/table-loading.js +14 -0
  83. package/constants.d.ts +2 -1
  84. package/constants.js +3 -1
  85. package/gateway/site-cms-write-validation.js +19 -3
  86. package/helpers/announced-action.d.ts +17 -0
  87. package/helpers/announced-action.js +29 -0
  88. package/helpers/phi-metadata.d.ts +0 -8
  89. package/helpers/phi-metadata.js +1 -10
  90. package/helpers/phi-site-description.d.ts +11 -0
  91. package/helpers/phi-site-description.js +13 -0
  92. package/helpers/preset-form-check.d.ts +14 -0
  93. package/helpers/preset-form-check.js +12 -0
  94. package/helpers/preset-table-check.d.ts +19 -15
  95. package/helpers/preset-table-check.js +33 -39
  96. package/helpers/record-widget-binding.d.ts +10 -0
  97. package/helpers/record-widget-binding.js +35 -0
  98. package/helpers/record-widget.d.ts +1 -10
  99. package/helpers/record-widget.js +4 -33
  100. package/helpers/table-widget-binding.d.ts +12 -0
  101. package/helpers/table-widget-binding.js +296 -0
  102. package/helpers/tree-widget-binding.d.ts +19 -0
  103. package/helpers/tree-widget-binding.js +72 -0
  104. package/helpers/typed-confirmation.d.ts +9 -0
  105. package/helpers/typed-confirmation.js +13 -0
  106. package/helpers/widget-binding-check.d.ts +22 -0
  107. package/helpers/widget-binding-check.js +91 -0
  108. package/module-page-check.d.ts +2 -0
  109. package/module-page-check.js +2 -0
  110. package/next/root-route.js +2 -1
  111. package/package.json +1 -1
  112. package/plugins/runtime-modules/accounting/ids.d.ts +7 -4
  113. package/plugins/runtime-modules/accounting/ids.js +14 -3
  114. package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +21 -9
  115. package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +29 -15
  116. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +11 -8
  117. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +206 -137
  118. package/plugins/runtime-modules/app/client-data-providers.js +1 -1
  119. package/plugins/runtime-modules/app/data-providers.d.ts +14 -69
  120. package/plugins/runtime-modules/app/data-providers.js +19 -54
  121. package/plugins/runtime-modules/app/definition.d.ts +8 -80
  122. package/plugins/runtime-modules/app/forms.d.ts +1 -16
  123. package/plugins/runtime-modules/app/forms.js +0 -59
  124. package/plugins/runtime-modules/app/ids.d.ts +2 -1
  125. package/plugins/runtime-modules/app/ids.js +3 -2
  126. package/plugins/runtime-modules/app/module.d.ts +8 -80
  127. package/plugins/runtime-modules/app/services/addresses-collection.d.ts +59 -0
  128. package/plugins/runtime-modules/app/services/{addresses-table.js → addresses-collection.js} +23 -19
  129. package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +10 -6
  130. package/plugins/runtime-modules/app/trees/account-addresses-panel.js +37 -73
  131. package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +0 -5
  132. package/plugins/runtime-modules/app/trees/addresses-label-set.js +2 -6
  133. package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.d.ts +1 -2
  134. package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +1 -17
  135. package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +0 -2
  136. package/plugins/runtime-modules/app/trees/profile-label-set.js +2 -14
  137. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +5 -0
  138. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +16 -6
  139. package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -1
  140. package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -1
  141. package/plugins/runtime-modules/builder/controller/signal-wiring-controller.js +5 -1
  142. package/plugins/runtime-modules/builder/signal-wiring-options.js +9 -2
  143. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +5 -0
  144. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -1
  145. package/plugins/runtime-modules/client-manifests/common.js +6 -0
  146. package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
  147. package/plugins/runtime-modules/core/widgets/collection-view/client.js +5 -2
  148. package/plugins/runtime-modules/core/widgets/collection-view/config.js +8 -0
  149. package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.d.ts +55 -0
  150. package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +173 -0
  151. package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.d.ts +48 -0
  152. package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.js +67 -0
  153. package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +1 -1
  154. package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
  155. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
  156. package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +1 -1
  157. package/plugins/runtime-modules/core/widgets/form/config.d.ts +1 -1
  158. package/plugins/runtime-modules/core/widgets/form/config.js +14 -1
  159. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -1
  160. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
  161. package/plugins/runtime-modules/core/widgets/record/client.js +2 -6
  162. package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
  163. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -1
  164. package/plugins/runtime-modules/core/widgets/table/client.js +30 -48
  165. package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
  166. package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
  167. package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +2 -2
  168. package/plugins/runtime-modules/core/widgets/thread-conversation/config.d.ts +6 -2
  169. package/plugins/runtime-modules/core/widgets/thread-conversation/config.js +6 -1
  170. package/plugins/runtime-modules/core/widgets/thread-widget-config.d.ts +10 -0
  171. package/plugins/runtime-modules/core/widgets/thread-widget-config.js +6 -0
  172. package/plugins/runtime-modules/core/widgets/tree/client.js +6 -6
  173. package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.d.ts +2 -0
  174. package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.js +2 -0
  175. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +5 -0
  176. package/plugins/runtime-modules/revisions/controller/binding.d.ts +37 -0
  177. package/plugins/runtime-modules/revisions/controller/binding.js +75 -0
  178. package/plugins/runtime-modules/revisions/controller/client.d.ts +5 -0
  179. package/plugins/runtime-modules/revisions/controller/client.js +74 -50
  180. package/plugins/runtime-modules/revisions/controller/definition.d.ts +5 -0
  181. package/plugins/runtime-modules/revisions/controller/definition.js +10 -0
  182. package/plugins/runtime-modules/revisions/forms.js +1 -1
  183. package/plugins/runtime-modules/revisions/page-ids.d.ts +1 -1
  184. package/plugins/runtime-modules/revisions/page-ids.js +4 -1
  185. package/plugins/runtime-modules/revisions/services/options.js +14 -4
  186. package/plugins/runtime-modules/revisions/services/table.js +41 -21
  187. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +76 -3
  188. package/plugins/runtime-modules/theme/controller/runtime.js +14 -2
  189. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +39 -13
  190. package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
  191. package/plugins/runtime-modules/threads/controller/client.js +62 -2
  192. package/plugins/runtime-modules/threads/controller/definition.js +48 -0
  193. package/plugins/runtime-modules/threads/data-providers.d.ts +22 -37
  194. package/plugins/runtime-modules/threads/data-providers.js +35 -24
  195. package/plugins/runtime-modules/threads/definition.d.ts +22 -37
  196. package/plugins/runtime-modules/threads/ids.d.ts +2 -0
  197. package/plugins/runtime-modules/threads/ids.js +2 -0
  198. package/plugins/runtime-modules/threads/services/customer-file-addresses.d.ts +30 -0
  199. package/plugins/runtime-modules/threads/services/customer-file-addresses.js +59 -0
  200. package/plugins/runtime-modules/threads/services/customer-file-read.d.ts +22 -0
  201. package/plugins/runtime-modules/threads/services/customer-file-read.js +101 -0
  202. package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +14 -80
  203. package/plugins/runtime-modules/threads/services/customer-file-table.js +27 -112
  204. package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +4 -0
  205. package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +4 -0
  206. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +15 -0
  207. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -0
  208. package/server-helpers/runtime.js +0 -1
  209. package/styles/controls.css +4 -2
  210. package/styles/layout.css +7 -0
  211. package/theme/phi-antd-token-resolver.d.ts +8 -0
  212. package/theme/phi-antd-token-resolver.js +10 -0
  213. package/theme/phi-theme-color.d.ts +19 -0
  214. package/theme/phi-theme-color.js +42 -0
  215. package/theme/phi-theme-gradients.js +4 -22
  216. package/theme/phi-theme-palette-defaults.d.ts +16 -0
  217. package/theme/phi-theme-palette-defaults.js +103 -0
  218. package/types/cms-plugins.d.ts +6 -1
  219. package/types/collection-provider.d.ts +27 -0
  220. package/types/collection-signal-values.d.ts +2 -0
  221. package/types/collection-signal-values.js +23 -0
  222. package/types/collection-view-widget.d.ts +9 -0
  223. package/types/core-widget-placements.d.ts +6 -0
  224. package/types/signals.d.ts +2 -0
  225. package/types/signals.js +2 -0
  226. package/types/table-widget.d.ts +15 -1
  227. package/types/table-widget.js +0 -282
  228. package/types/tree-widget.d.ts +0 -1
  229. package/types/tree-widget.js +0 -60
  230. package/types/widget-runtime.d.ts +0 -1
  231. package/types.d.ts +1 -1
  232. package/types.js +1 -1
  233. package/plugins/runtime-modules/app/services/addresses-table.d.ts +0 -135
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { createElement, useCallback, useEffect, useMemo } from "react";
2
+ import { createElement, useCallback, useEffect, useMemo, useRef } from "react";
3
3
  import { useRouter } from "next/navigation";
4
4
  import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../types/signals";
5
5
  import { readPhiTableBindingParamsSignalValue } from "../../../../types/table-signal-values";
@@ -9,14 +9,13 @@ import { usePhiSignalDispatcher, usePhiSignalListener } from "../../../../compon
9
9
  import { dispatchPhiSignalCapability } from "../../../../components/runtime/runtime-signal-identity";
10
10
  import { usePhiApplicationFeedback } from "../../../../components/runtime/use-phi-application-feedback";
11
11
  import { getPhiWorkspaceCatalogSnapshot, usePhiWorkspaceCatalogValue, } from "../../../../components/workspace/catalog-store";
12
- import { PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM, PHI_BUILDER_PAGE_SEARCH_PARAM, PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM, PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, PHI_BUILDER_THEME_KEY_SEARCH_PARAM, normalizePhiBuilderAreaSearchParam, normalizePhiBuilderPageSearchParam, normalizePhiBuilderRevisionsKindSearchParam, } from "../../../../helpers/cms-scope-search-params";
13
- import { resolvePhiBuilderRevisionPagePath, } from "../types";
14
- import { resolvePhiBuilderActivePageCatalog, resolvePhiBuilderActivePageKey, } from "../../../../helpers/cms-page-catalog";
12
+ import { PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM, PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, normalizePhiBuilderRevisionsKindSearchParam, } from "../../../../helpers/cms-scope-search-params";
13
+ import { isPhiRevisionsCatalogReady, readPhiRevisionsAddressKind, readPhiRevisionsTableBinding, resolvePhiRevisionsControllerBinding, } from "./binding";
15
14
  import { PHI_REVISIONS_RUNTIME_CONTROLLER_DEFINITION, } from "../controller/definition";
16
15
  import { resolvePhiRevisionsDraftContextTarget } from "./draft-context-target";
17
- import { resolvePhiBuilderRevisionNavScopeKey } from "../../../../helpers/cms-navigation-scope-key";
18
16
  import { deleteCmsDraft } from "../../../../helpers/cms-draft-delete";
19
17
  import { isPhiRecord } from "../../../../helpers/is-record";
18
+ import { matchesPhiTypedConfirmation } from "../../../../helpers/typed-confirmation";
20
19
  import { usePhiPathname } from "../../../../components/runtime/use-phi-pathname";
21
20
  function PhiRevisionsControllerMount({ address, config, }) {
22
21
  const dispatchSignal = usePhiSignalDispatcher();
@@ -51,33 +50,39 @@ function PhiRevisionsControllerMount({ address, config, }) {
51
50
  const modulePresetPagesByArea = usePhiWorkspaceCatalogValue((state) => state.modulePresetPagesByArea);
52
51
  const customPages = usePhiWorkspaceCatalogValue((state) => state.customPages);
53
52
  const persistedPageCatalogByArea = usePhiWorkspaceCatalogValue((state) => state.persistedPageCatalogByArea);
53
+ const catalogHydrated = usePhiWorkspaceCatalogValue((state) => state.catalogHydrated);
54
+ const pageCatalogHydratedByArea = usePhiWorkspaceCatalogValue((state) => state.pageCatalogHydratedByArea);
55
+ /*
56
+ * The scope the address names, handed to the Table once the catalog stands for that address.
57
+ *
58
+ * Before, it was resolved on the catalog's first answer, which names the default Area (`public`)
59
+ * until the Builder has read the address: a Module Page of the App was handed as a Public Page,
60
+ * then again as the App's, each a history read. The catalog changes many times more while the
61
+ * Builder opens, and after every Page action, and each change hands the scope again; the Table
62
+ * takes the same scope as no change (`updateBindingParams`), so only another scope is read.
63
+ */
64
+ /*
65
+ * The last scope handed, to know it when the Table hands it back: the Table announces every change
66
+ * of its binding, this Controller's own among them, and written into the address the scope that was
67
+ * read off the address (or the open Page standing in for it) is one more fetch of the Page for nothing.
68
+ */
69
+ const handedBindingKey = useRef(null);
70
+ const handBinding = useCallback((binding, correlationId) => {
71
+ handedBindingKey.current = JSON.stringify(binding);
72
+ emitCapability("bindingParamsChange", { params: binding }, correlationId);
73
+ }, [emitCapability]);
54
74
  useEffect(() => {
55
- const state = getPhiWorkspaceCatalogSnapshot();
56
- const pages = resolvePhiBuilderActivePageCatalog(state.area, state.modulePresetPagesByArea, state.customPages, state.persistedPageCatalogByArea);
57
- const search = new URLSearchParams(window.location.search);
58
- const pageKey = resolvePhiBuilderActivePageKey(normalizePhiBuilderPageSearchParam(search.get(PHI_BUILDER_PAGE_SEARCH_PARAM)) ?? state.pageKey, pages);
59
- if (!pageKey)
60
- return;
61
- const kind = normalizePhiBuilderRevisionsKindSearchParam(search.get(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM)) ?? "area";
62
- const requestedScope = search.get(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM)?.trim() ?? "";
63
- const scopeKey = kind === "page"
64
- ? requestedScope.startsWith("/")
65
- ? requestedScope
66
- : resolvePhiBuilderRevisionPagePath(state.area, pageKey, pages)
67
- : kind === "navigation"
68
- ? requestedScope.includes(":")
69
- ? requestedScope
70
- : resolvePhiBuilderRevisionNavScopeKey(state.area, search.get(PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM))
71
- : kind === "theme"
72
- ? requestedScope || search.get(PHI_BUILDER_THEME_KEY_SEARCH_PARAM) || "default"
73
- : normalizePhiBuilderAreaSearchParam(requestedScope) ?? state.area;
74
- emitCapability("bindingParamsChange", { params: { area: state.area, kind, scopeKey } });
75
+ const binding = resolvePhiRevisionsControllerBinding(getPhiWorkspaceCatalogSnapshot(), new URLSearchParams(window.location.search));
76
+ if (binding)
77
+ handBinding(binding);
75
78
  }, [
76
79
  builderArea,
77
80
  builderPageKey,
81
+ catalogHydrated,
78
82
  customPages,
79
- emitCapability,
83
+ handBinding,
80
84
  modulePresetPagesByArea,
85
+ pageCatalogHydratedByArea,
81
86
  persistedPageCatalogByArea,
82
87
  ]);
83
88
  /*
@@ -119,10 +124,16 @@ function PhiRevisionsControllerMount({ address, config, }) {
119
124
  signal.action === "change" &&
120
125
  isPhiBuilderAreaKey(signal.value)) {
121
126
  const search = new URLSearchParams(window.location.search);
122
- const kind = normalizePhiBuilderRevisionsKindSearchParam(search.get(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM)) ?? "area";
123
- if (kind !== "area")
127
+ /*
128
+ * Not before the catalog stands for the address: the Area select says which Area it shows when it
129
+ * mounts, which is the catalog's default until the Builder has read the address -- the App's
130
+ * Revisions read the Public Area's history first.
131
+ */
132
+ if (readPhiRevisionsAddressKind(search) !== "area" ||
133
+ !isPhiRevisionsCatalogReady(getPhiWorkspaceCatalogSnapshot(), search)) {
124
134
  return;
125
- emitCapability("bindingParamsChange", { params: { kind: "area", scopeKey: signal.value } }, signal.correlationId);
135
+ }
136
+ handBinding({ area: signal.value, kind: "area", scopeKey: signal.value }, signal.correlationId);
126
137
  return;
127
138
  }
128
139
  if (signal.receiver !== address)
@@ -138,15 +149,26 @@ function PhiRevisionsControllerMount({ address, config, }) {
138
149
  */
139
150
  const area = getPhiWorkspaceCatalogSnapshot().area;
140
151
  emitCapability("deleteAreaWarning", `The structure this Site stored for ${area} is cleared -- its Shell, drafts and published alike. What is live changes at once, the shell's preset takes the Area back, and no revision is left to restore it from. It cannot be undone. The Module selection is kept.`, signal.correlationId);
152
+ emitCapability("deleteAreaKey", area, signal.correlationId);
153
+ emitCapability("deleteAreaConfirmEnabled", false, signal.correlationId);
141
154
  emitCapability("deleteAreaOpen", null, signal.correlationId);
142
155
  return;
143
156
  }
157
+ /*
158
+ * The key as it is typed: the confirm button wakes the moment it matches and sleeps again when it
159
+ * no longer does, so pressing it is never answered with "that is not the key".
160
+ */
161
+ if (signal.channel === "deleteAreaTyped" && signal.action === "change") {
162
+ const payload = isPhiRecord(signal.value) ? signal.value : null;
163
+ const values = isPhiRecord(payload?.values) ? payload.values : null;
164
+ emitCapability("deleteAreaConfirmEnabled", matchesPhiTypedConfirmation(values?.areaKey, getPhiWorkspaceCatalogSnapshot().area), signal.correlationId);
165
+ return;
166
+ }
144
167
  if (signal.channel === "formValues" && signal.action === "change") {
145
168
  const payload = isPhiRecord(signal.value) ? signal.value : null;
146
169
  const values = isPhiRecord(payload?.values) ? payload.values : null;
147
- const typed = typeof values?.areaKey === "string" ? values.areaKey.trim() : "";
148
170
  const area = getPhiWorkspaceCatalogSnapshot().area;
149
- if (typed !== area) {
171
+ if (!matchesPhiTypedConfirmation(values?.areaKey, area)) {
150
172
  // The Overlay stays open: what is wrong is the answer, not the question.
151
173
  showMessage({ level: "error", content: "That is not the Area key." }, { correlationId: signal.correlationId });
152
174
  return;
@@ -155,31 +177,33 @@ function PhiRevisionsControllerMount({ address, config, }) {
155
177
  return;
156
178
  }
157
179
  if (signal.channel === "bindingParams" && signal.action === "change") {
158
- const binding = readPhiTableBindingParamsSignalValue(signal.value);
159
- const kind = normalizePhiBuilderRevisionsKindSearchParam(binding?.params.kind);
160
- const scopeKey = typeof binding?.params.scopeKey === "string"
161
- ? binding.params.scopeKey.trim()
162
- : "";
163
- if (!kind || !pathname)
180
+ /*
181
+ * A whole scope only. The Table's kind select answers before its scope select does, and the kind
182
+ * beside the scope of the kind before it names nothing; written into the address it was a
183
+ * navigation, and the scope's answer a second one.
184
+ */
185
+ const binding = readPhiRevisionsTableBinding({
186
+ area: getPhiWorkspaceCatalogSnapshot().area,
187
+ ...readPhiTableBindingParamsSignalValue(signal.value)?.params,
188
+ });
189
+ if (!binding || !pathname || JSON.stringify(binding) === handedBindingKey.current)
164
190
  return;
191
+ const { kind, scopeKey } = binding;
165
192
  const search = new URLSearchParams(window.location.search);
166
193
  const currentKind = normalizePhiBuilderRevisionsKindSearchParam(search.get(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM));
167
- if (kind === "area" &&
168
- isPhiBuilderAreaKey(scopeKey) &&
169
- (currentKind == null || currentKind === "area")) {
194
+ /*
195
+ * An Area's history is not written into the address beyond its kind, and an absent kind is the
196
+ * Area: nothing to navigate to. Asked to write `revisionKind=area` the Controller fetched the Page
197
+ * anew for an address that meant the same.
198
+ */
199
+ if (kind === "area" && (currentKind == null || currentKind === "area")) {
170
200
  return;
171
201
  }
172
202
  search.set(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM, kind);
173
- if (kind === "area" && isPhiBuilderAreaKey(scopeKey)) {
203
+ if (kind === "area") {
174
204
  search.delete(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM);
175
205
  }
176
- else if (kind === "page" && scopeKey.startsWith("/")) {
177
- search.set(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, scopeKey);
178
- }
179
- else if (kind === "navigation" && scopeKey.includes(":")) {
180
- search.set(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, scopeKey);
181
- }
182
- else if (kind === "theme" && scopeKey) {
206
+ else {
183
207
  search.set(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, scopeKey);
184
208
  }
185
209
  /*
@@ -226,9 +250,9 @@ function PhiRevisionsControllerMount({ address, config, }) {
226
250
  else if (key === "deleteSelected")
227
251
  showMessage({ level: "success", content: `Deleted ${String(action?.deletedCount ?? 0)} revisions.` }, { correlationId: signal.correlationId });
228
252
  }
229
- }, [address, deleteAreaShell, emitCapability, pathname, reportDraftStatus, router, showMessage]), {
253
+ }, [address, deleteAreaShell, emitCapability, handBinding, pathname, reportDraftStatus, router, showMessage]), {
230
254
  scopes: ["area", "page"],
231
- channels: ["areaSelection", "bindingParams", "command", "formValues", "mutation"],
255
+ channels: ["areaSelection", "bindingParams", "command", "deleteAreaTyped", "formValues", "mutation"],
232
256
  },
233
257
  /*
234
258
  * The address this listener answers for.
@@ -26,6 +26,11 @@ export declare const PHI_REVISIONS_RUNTIME_CONTROLLER_DEFINITION: {
26
26
  action: "change";
27
27
  valueType: "string";
28
28
  valueSchema?: undefined;
29
+ } | {
30
+ id: string;
31
+ action: "change";
32
+ valueType: "boolean";
33
+ valueSchema?: undefined;
29
34
  } | {
30
35
  id: string;
31
36
  action: "activate";
@@ -23,6 +23,9 @@ export const PHI_REVISIONS_RUNTIME_CONTROLLER_DEFINITION = {
23
23
  valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.revisionsDraftStatus,
24
24
  },
25
25
  { id: "deleteAreaWarning", action: "change", valueType: "string" },
26
+ /* The Area key the dialog shows to be typed, and its confirm button, awake only while it matches. */
27
+ { id: "deleteAreaKey", action: "change", valueType: "string" },
28
+ { id: "deleteAreaConfirmEnabled", action: "change", valueType: "boolean" },
26
29
  { id: "deleteAreaOpen", action: "activate", valueType: "none" },
27
30
  { id: "deleteAreaClose", action: "close", valueType: "none" },
28
31
  /* The history is out of date once an Area is cleared: every revision it listed is gone. */
@@ -62,6 +65,13 @@ export const PHI_REVISIONS_RUNTIME_CONTROLLER_DEFINITION = {
62
65
  action: "change",
63
66
  valueType: "json",
64
67
  valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.formValues,
68
+ }, {
69
+ /* The same Form's values while the key is typed (`valuesChange`), for the confirm button. */
70
+ id: "deleteAreaTyped",
71
+ channel: "deleteAreaTyped",
72
+ action: "change",
73
+ valueType: "json",
74
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.formValues,
65
75
  }],
66
76
  },
67
77
  defaultConfig: { signalRoutes: null },
@@ -31,7 +31,7 @@ const PHI_REVISIONS_DELETE_AREA_FORM_DESCRIPTOR = {
31
31
  {
32
32
  key: "areaKey",
33
33
  fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.text,
34
- label: label("areaKey", "Type the Area key to confirm"),
34
+ label: label("areaKey", "Area key"),
35
35
  validation: [{
36
36
  providerKey: PHI_FORM_VALIDATION_PROVIDER_KEYS.required,
37
37
  message: label("areaKeyRequired", "Write the Area key out to confirm."),
@@ -6,4 +6,4 @@ export declare const PHI_REVISIONS_TABLE_WIDGET_ID: import("@phis/contracts/cms"
6
6
  /** The Revisions page's one irreversible command: deleting an Area's own shell. */
7
7
  export declare const PHI_REVISIONS_DELETE_AREA_OVERLAY_IDS: Readonly<Record<"overlayDeleteArea", import("@phis/contracts/cms").PhiCmsInstanceId>>;
8
8
  export declare const PHI_REVISIONS_DELETE_AREA_LAYOUT_IDS: Readonly<Record<"deleteAreaBody" | "deleteAreaFooter", import("@phis/contracts/cms").PhiCmsInstanceId>>;
9
- export declare const PHI_REVISIONS_DELETE_AREA_WIDGET_IDS: Readonly<Record<"deleteAreaWarning" | "deleteAreaSurvives" | "deleteAreaForm" | "deleteAreaCommands", import("@phis/contracts/cms").PhiCmsInstanceId>>;
9
+ export declare const PHI_REVISIONS_DELETE_AREA_WIDGET_IDS: Readonly<Record<"deleteAreaWarning" | "deleteAreaKey" | "deleteAreaSurvives" | "deleteAreaTypeToConfirm" | "deleteAreaForm" | "deleteAreaCommands", import("@phis/contracts/cms").PhiCmsInstanceId>>;
@@ -25,4 +25,7 @@ export const PHI_REVISIONS_TABLE_WIDGET_ID = createPhiPresetCmsInstanceId({
25
25
  /** The Revisions page's one irreversible command: deleting an Area's own shell. */
26
26
  export const PHI_REVISIONS_DELETE_AREA_OVERLAY_IDS = createPhiPresetCmsInstanceIdMap(PHI_REVISIONS_PAGE_DIALOG_ID_CONTEXT, ["overlayDeleteArea"]);
27
27
  export const PHI_REVISIONS_DELETE_AREA_LAYOUT_IDS = createPhiPresetCmsInstanceIdMap(PHI_REVISIONS_PAGE_DIALOG_ID_CONTEXT, ["deleteAreaBody", "deleteAreaFooter"]);
28
- export const PHI_REVISIONS_DELETE_AREA_WIDGET_IDS = createPhiPresetCmsInstanceIdMap(PHI_REVISIONS_PAGE_DIALOG_ID_CONTEXT, ["deleteAreaWarning", "deleteAreaSurvives", "deleteAreaForm", "deleteAreaCommands"]);
28
+ export const PHI_REVISIONS_DELETE_AREA_WIDGET_IDS = createPhiPresetCmsInstanceIdMap(PHI_REVISIONS_PAGE_DIALOG_ID_CONTEXT, [
29
+ "deleteAreaWarning", "deleteAreaSurvives", "deleteAreaTypeToConfirm", "deleteAreaKey", "deleteAreaForm",
30
+ "deleteAreaCommands",
31
+ ]);
@@ -5,6 +5,7 @@ import { resolvePhiBuilderActivePageCatalog, } from "../../../../helpers/cms-pag
5
5
  import { phiWorkspaceCatalogStore, PHI_WORKSPACE_CATALOG_SCOPE, } from "../../../../components/workspace/catalog-store";
6
6
  import { PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, } from "../../../../helpers/cms-scope-search-params";
7
7
  import { resolvePhiBuilderRevisionPagePath } from "../types";
8
+ import { isPhiRevisionsCatalogReady, readPhiRevisionsAddressKind } from "../controller/binding";
8
9
  import { createPhiControlOptionsProviderClient, readPhiControlOptionsProviderParam, readPhiControlOptionsProviderSourceValue, } from "../../../../components/controls/phi-options-provider";
9
10
  function readSnapshot(context) {
10
11
  return context.snapshot;
@@ -26,6 +27,17 @@ function resolveKind(context) {
26
27
  function resolveOptions(context) {
27
28
  const snapshot = readSnapshot(context);
28
29
  const mode = readPhiControlOptionsProviderParam(context.optionsProvider, "mode");
30
+ const search = typeof window === "undefined" ? null : new URLSearchParams(window.location.search);
31
+ /*
32
+ * Nothing to offer until the catalog stands for the address, as the Controller hands no scope before
33
+ * then (`resolvePhiRevisionsControllerBinding`). A select that answers a value is set to it, and
34
+ * the Table hands the value on: the kind select answered `area` whatever the address said, before the
35
+ * Controller had said `page`, and the Controller wrote the Area's history into the address -- a
36
+ * Module Page's Revisions opened on the Area's.
37
+ */
38
+ if (!search || !isPhiRevisionsCatalogReady(snapshot, search)) {
39
+ return { options: [] };
40
+ }
29
41
  if (mode === "kind") {
30
42
  return {
31
43
  options: [
@@ -34,7 +46,7 @@ function resolveOptions(context) {
34
46
  { value: "navigation", label: "Navigation" },
35
47
  { value: "theme", label: "Theme" },
36
48
  ],
37
- value: "area",
49
+ value: readPhiRevisionsAddressKind(search),
38
50
  };
39
51
  }
40
52
  const area = snapshot.area;
@@ -42,9 +54,7 @@ function resolveOptions(context) {
42
54
  const currentValue = typeof context.sourceConfig?.scopeKey === "string"
43
55
  ? context.sourceConfig.scopeKey
44
56
  : null;
45
- const requestedScope = typeof window === "undefined"
46
- ? null
47
- : new URLSearchParams(window.location.search).get(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM);
57
+ const requestedScope = search.get(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM);
48
58
  if (kind === "area") {
49
59
  return {
50
60
  options: [...PHI_BUILDER_AREA_OPTIONS],
@@ -2,14 +2,15 @@
2
2
  import { PHI_REVISIONS_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
3
3
  import { deleteCmsDraft } from "../../../../helpers/cms-draft-delete";
4
4
  import { readNumber } from "../../../../components/widgets/config/parser-primitives";
5
- import { isPhiBuilderAreaKey, isPhiCmsAreaKey } from "../../../../constants/cms-areas";
5
+ import { isPhiCmsAreaKey } from "../../../../constants/cms-areas";
6
6
  import { hasPhiCmsPresetUpdate } from "../../../../plugins/runtime-modules/preset-version";
7
7
  import { PhiTableProviderError, } from "../../../../types/table-widget";
8
8
  import { createPhiTableProviderClient } from "../../../../components/widgets/client/shared/phi-table-provider";
9
9
  import { PHI_REVISIONS_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "../../../../plugins/runtime-modules/revisions/data-providers";
10
10
  import { getPhiWorkspaceCatalogSnapshot, } from "../../../../components/workspace/catalog-store";
11
11
  import { resolvePhiBuilderActivePageCatalog, findPhiBuilderPageKeyFromStoragePath, resolvePhiBuilderActivePageKey, resolvePhiBuilderPageKeyFromCatalogPath, } from "../../../../helpers/cms-page-catalog";
12
- import { PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM, PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM, PHI_BUILDER_THEME_KEY_SEARCH_PARAM, normalizePhiBuilderRevisionsKindSearchParam, } from "../../../../helpers/cms-scope-search-params";
12
+ import { PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM, PHI_BUILDER_THEME_KEY_SEARCH_PARAM, } from "../../../../helpers/cms-scope-search-params";
13
+ import { readPhiRevisionsTableBinding } from "../controller/binding";
13
14
  import { resolvePhiBuilderRevisionPagePath, resolvePhiBuilderRevisionScope, } from "../types";
14
15
  import { resolvePhiBuilderRevisionNavScopeKey } from "../../../../helpers/cms-navigation-scope-key";
15
16
  import { isPhiRecord } from "../../../../helpers/is-record";
@@ -40,6 +41,15 @@ function readRevisionScope(value) {
40
41
  sourcePreset,
41
42
  };
42
43
  }
44
+ /**
45
+ * What a request asks about, or null while it asks about nothing yet.
46
+ *
47
+ * The Table mounts with its labels alone; the scope is the Revisions Controller's to hand, once the
48
+ * workspace catalog stands for the address (`resolvePhiRevisionsControllerBinding`). This read used to
49
+ * make one up meanwhile, from the address and whatever the catalog held -- the default Area's, before
50
+ * the Builder had read the address -- and the Table asked for that history, then for the one handed a
51
+ * moment later: two reads on every open, and a Module Page of the App asked for as a Public Page.
52
+ */
43
53
  function readParams(value) {
44
54
  if (!isPhiRecord(value) || !isPhiRecord(value.labels) || typeof value.locale !== "string"
45
55
  || typeof value.timeZone !== "string") {
@@ -47,20 +57,14 @@ function readParams(value) {
47
57
  }
48
58
  const locale = value.locale;
49
59
  const timeZone = value.timeZone;
50
- if (!isPhiRecord(value.scope) && typeof window !== "undefined") {
60
+ if (!isPhiRecord(value.scope)) {
61
+ const binding = readPhiRevisionsTableBinding(value);
62
+ if (!binding || typeof window === "undefined")
63
+ return null;
64
+ const { kind, scopeKey: configuredScopeKey } = binding;
51
65
  const state = getPhiWorkspaceCatalogSnapshot();
52
66
  const search = new URLSearchParams(window.location.search);
53
- const kind = normalizePhiBuilderRevisionsKindSearchParam(value.kind) ??
54
- normalizePhiBuilderRevisionsKindSearchParam(search.get(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM)) ??
55
- "area";
56
- const configuredScopeKey = typeof value.scopeKey === "string" && value.scopeKey.trim()
57
- ? value.scopeKey.trim()
58
- : search.get(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM)?.trim() ?? "";
59
- const scopeArea = kind === "area"
60
- ? isPhiBuilderAreaKey(configuredScopeKey)
61
- ? configuredScopeKey
62
- : state.area
63
- : state.area;
67
+ const scopeArea = kind === "area" ? configuredScopeKey : binding.area;
64
68
  const pages = resolvePhiBuilderActivePageCatalog(scopeArea, state.modulePresetPagesByArea, state.customPages, state.persistedPageCatalogByArea);
65
69
  const activePageKey = resolvePhiBuilderActivePageKey(scopeArea === state.area ? state.pageKey : null, pages);
66
70
  /*
@@ -68,10 +72,8 @@ function readParams(value) {
68
72
  *
69
73
  * Three of them never read one: `resolvePhiBuilderRevisionScope` takes the area, the nav key or the
70
74
  * theme key and leaves the page alone, so demanding one made an Area whose pages all come from
71
- * Modules unable to show the revisions it does have. And the fourth reaches this before anything is
72
- * loaded: opening `/builder/revisions` directly means the page catalog is still empty, which is a
73
- * moment rather than a fault. A page scope without a page asks for nothing and shows nothing, and
74
- * fills in as soon as there is one.
75
+ * Modules unable to show the revisions it does have. A page scope whose Page the catalog does not
76
+ * hold asks for nothing and shows nothing.
75
77
  */
76
78
  /*
77
79
  * The Page a page scope names, by the address it answers on: the Page Select, the Controller and the
@@ -80,14 +82,14 @@ function readParams(value) {
80
82
  * `/dashboard`) was found nowhere, read as a Site Page of that path and asked for by a path its row
81
83
  * does not have -- so its history was empty and "Reset to preset" had no preset to name.
82
84
  */
83
- const pageKey = kind === "page" && configuredScopeKey.startsWith("/")
85
+ const pageKey = kind === "page"
84
86
  ? findPhiBuilderPageKeyFromStoragePath(scopeArea, configuredScopeKey, pages)
85
87
  ?? resolvePhiBuilderPageKeyFromCatalogPath(scopeArea, configuredScopeKey, pages)
86
88
  : activePageKey ?? "";
87
- const navScopeKey = kind === "navigation" && configuredScopeKey
89
+ const navScopeKey = kind === "navigation"
88
90
  ? resolvePhiBuilderRevisionNavScopeKey(scopeArea, configuredScopeKey)
89
91
  : resolvePhiBuilderRevisionNavScopeKey(scopeArea, search.get(PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM));
90
- const themeKey = kind === "theme" && configuredScopeKey
92
+ const themeKey = kind === "theme"
91
93
  ? configuredScopeKey
92
94
  : search.get(PHI_BUILDER_THEME_KEY_SEARCH_PARAM) ?? "default";
93
95
  const scope = resolvePhiBuilderRevisionScope(kind, scopeArea, pageKey, pages, navScopeKey, themeKey, state.areaPresetSourcesByArea[scopeArea] ?? null);
@@ -398,11 +400,26 @@ function buildTableData(params, result) {
398
400
  },
399
401
  };
400
402
  }
403
+ /**
404
+ * Answers once there is a question: a request without a scope stays open, the Table showing that it
405
+ * loads, until the scope handed to it replaces the request -- which aborts it. Answered empty instead,
406
+ * the Table drew "no revisions" between its skeleton and the history.
407
+ */
408
+ function untilAborted(signal) {
409
+ return new Promise((_, reject) => {
410
+ if (signal.aborted)
411
+ reject(signal.reason);
412
+ else
413
+ signal.addEventListener("abort", () => reject(signal.reason), { once: true });
414
+ });
415
+ }
401
416
  async function queryRevisions(request) {
402
417
  if (request.resourceKey !== "history") {
403
418
  throw new PhiTableProviderError("resource-not-found", `Unknown Revisions resource "${request.resourceKey}".`);
404
419
  }
405
420
  const params = readParams(request.params);
421
+ if (!params)
422
+ return untilAborted(request.signal);
406
423
  return buildTableData(params, await loadRevisionHistory(params.scope, request.signal));
407
424
  }
408
425
  function readRevisionId(value) {
@@ -420,6 +437,9 @@ async function mutateRevision(request) {
420
437
  throw new PhiTableProviderError("resource-not-found", `Unknown Revisions resource "${request.resourceKey}".`);
421
438
  }
422
439
  const params = readParams(request.params);
440
+ if (!params) {
441
+ throw new Error("Choose what to show the history of first.");
442
+ }
423
443
  if (request.actionKey === "resetPage") {
424
444
  /*
425
445
  * Not a revision act: the override these revisions belong to goes as a whole, and the Module's preset
@@ -4,7 +4,7 @@ import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constan
4
4
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
5
5
  import { resolvePhiShellHeaderHeight } from "../../../../helpers/shell-region-style";
6
6
  import { readPhiServerApiCredentials } from "../../../../helpers/phis-server-credentials";
7
- import { PHI_SIGNAL_VALUE_SCHEMAS, createPhiSignalAddress, } from "../../../../types";
7
+ import { PHI_SIGNAL_VALUE_SCHEMAS, createPhiSignalAddress, createPhiSignalSubcontrolAddress, } from "../../../../types";
8
8
  import { PHI_SPACE } from "../../../../theme/antd-css-var-contract";
9
9
  import { getPhiBuilderChromeWidgetLabels } from "../../../../components/widgets/label-sets/builder-chrome";
10
10
  import { getPhiBuilderRevisionsWidgetLabels } from "../../../../components/widgets/label-sets/revisions";
@@ -40,6 +40,8 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
40
40
  getPhiBuilderRevisionsWidgetLabels(credentials),
41
41
  ]);
42
42
  const deleteAreaOverlay = createPhiSignalAddress("cms", PHI_REVISIONS_DELETE_AREA_OVERLAY_IDS.overlayDeleteArea);
43
+ // The dialog's confirm button, which stays greyed out until the Area key is typed.
44
+ const deleteAreaConfirm = createPhiSignalSubcontrolAddress("cms", PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaCommands, "confirm");
43
45
  return {
44
46
  page: nodes.page(),
45
47
  pageMeta: {
@@ -77,6 +79,24 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
77
79
  valueType: "string",
78
80
  receiver: createPhiSignalAddress("cms", PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaWarning),
79
81
  },
82
+ {
83
+ routeKey: "builder-revisions-controller-delete-area-key",
84
+ capabilityId: "deleteAreaKey",
85
+ scope: "area",
86
+ channel: "text",
87
+ action: "change",
88
+ valueType: "string",
89
+ receiver: createPhiSignalAddress("cms", PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaKey),
90
+ },
91
+ {
92
+ routeKey: "builder-revisions-controller-delete-area-confirm-enabled",
93
+ capabilityId: "deleteAreaConfirmEnabled",
94
+ scope: "page",
95
+ channel: "enabled",
96
+ action: "change",
97
+ valueType: "boolean",
98
+ receiver: deleteAreaConfirm,
99
+ },
80
100
  { routeKey: "builder-revisions-controller-delete-area-open", capabilityId: "deleteAreaOpen", scope: "area", channel: "dialog", action: "activate", valueType: "none", receiver: deleteAreaOverlay },
81
101
  { routeKey: "builder-revisions-controller-delete-area-close", capabilityId: "deleteAreaClose", scope: "area", channel: "dialog", action: "close", valueType: "none", receiver: deleteAreaOverlay },
82
102
  { routeKey: "builder-revisions-controller-history-reload", capabilityId: "historyReload", scope: "page", channel: "reload", action: "activate", valueType: "none", receiver: createPhiSignalAddress("cms", PHI_REVISIONS_TABLE_WIDGET_ID) },
@@ -294,12 +314,41 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
294
314
  tone: "secondary",
295
315
  },
296
316
  }),
317
+ /*
318
+ * The exact word to type, shown rather than described: asked for "the Area key", nobody knew its
319
+ * spelling or its case. The key stands on a line of its own in code type, where it is read at a
320
+ * glance and selected with one double click; the Controller writes it in as the dialog opens, as
321
+ * it does the warning, and the comparison takes it in any case (`matchesPhiTypedConfirmation`).
322
+ */
297
323
  nodes.widget({
298
- typeKey: "form",
299
- id: PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaForm,
324
+ typeKey: "simple-text",
325
+ /* Label set text, translated already; a second pass would hand the translator a non-source text. */
326
+ flags: PhiCmsFlags.NoTranslate,
327
+ id: PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaTypeToConfirm,
300
328
  parentLayoutNodeId: PHI_REVISIONS_DELETE_AREA_LAYOUT_IDS.deleteAreaBody,
301
329
  slotIndex: PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS[2].slotIndex,
302
330
  sortOrder: 2,
331
+ label: "Builder delete area type to confirm",
332
+ config: { text: revisionsLabels.deleteArea.typeToConfirm },
333
+ }),
334
+ nodes.widget({
335
+ typeKey: "simple-text",
336
+ // A key, never words to translate.
337
+ flags: PhiCmsFlags.NoTranslate,
338
+ id: PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaKey,
339
+ parentLayoutNodeId: PHI_REVISIONS_DELETE_AREA_LAYOUT_IDS.deleteAreaBody,
340
+ slotIndex: PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS[3].slotIndex,
341
+ sortOrder: 3,
342
+ label: "Builder delete area key",
343
+ // Never empty, for the same reason as the warning; the Controller's key replaces it.
344
+ config: { text: "area", marks: ["bold", "code"], fontSize: "lg" },
345
+ }),
346
+ nodes.widget({
347
+ typeKey: "form",
348
+ id: PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaForm,
349
+ parentLayoutNodeId: PHI_REVISIONS_DELETE_AREA_LAYOUT_IDS.deleteAreaBody,
350
+ slotIndex: PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS[4].slotIndex,
351
+ sortOrder: 4,
303
352
  label: "Builder delete area form",
304
353
  config: {
305
354
  formId: PHI_REVISIONS_FORM_IDS.deleteArea,
@@ -321,6 +370,17 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
321
370
  valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.formValues,
322
371
  receiver: createPhiRevisionsControllerAddress(),
323
372
  },
373
+ // The key while it is typed, so the confirm button wakes the moment it matches.
374
+ {
375
+ routeKey: "builder-delete-area-typed",
376
+ capabilityId: "valuesChange",
377
+ scope: "area",
378
+ channel: "deleteAreaTyped",
379
+ action: "change",
380
+ valueType: "json",
381
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.formValues,
382
+ receiver: createPhiRevisionsControllerAddress(),
383
+ },
324
384
  ],
325
385
  /*
326
386
  * The footer's confirm button sends `submit` here. A route on the sender alone delivers
@@ -365,6 +425,8 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
365
425
  emits: [{ capabilityId: "submit", value: null }],
366
426
  label: revisionsLabels.deleteArea.confirm,
367
427
  danger: true,
428
+ // Until the Area key is typed; the Controller switches it on (`deleteAreaConfirmEnabled`).
429
+ disabled: true,
368
430
  },
369
431
  ],
370
432
  signalRoutes: {
@@ -388,6 +450,17 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
388
450
  receiver: createPhiSignalAddress("cms", PHI_REVISIONS_DELETE_AREA_WIDGET_IDS.deleteAreaForm),
389
451
  },
390
452
  ],
453
+ listens: [
454
+ {
455
+ routeKey: "builder-delete-area-confirm-enabled",
456
+ capabilityId: "enabled",
457
+ scope: "page",
458
+ channel: "enabled",
459
+ action: "change",
460
+ valueType: "boolean",
461
+ receiver: deleteAreaConfirm,
462
+ },
463
+ ],
391
464
  },
392
465
  },
393
466
  }),
@@ -13,7 +13,19 @@ import { materializePhiThemeBrandLogo, materializePhiThemeBrandSignet, materiali
13
13
  import { buildPhiSiteThemeSelectOptions, createPhiSiteThemeSelectionValue, createPhiThemeDerivation, ensurePhiThemeDerivation, readPhiSiteThemeSelectionState, resolvePhiThemeSelectionValue, } from "../../../../theme/phi-theme-selection";
14
14
  import { dispatchPhiSignalCapability } from "../../../../components/runtime/runtime-signal-identity";
15
15
  import { formatPhiHistoryMoveMessage, formatPhiHistoryTooltip, } from "../../../../components/widgets/label-types/history";
16
- import { phiThemeHistory, resolvePhiThemeHistoryAction, DEFAULT_THEME_KEY, resolveThemeKey, normalizeTheme, resolveInitialTheme, resolveThemePayloadPreset, applyThemePreset, resetThemeToPreset, buildThemeReviewHref, createInitialBrandThemeState, isSameThemePayload, mergeThemeSetChoice, } from "../brand-theme-model";
16
+ import { phiThemeHistory, resolvePhiThemeHistoryAction, DEFAULT_THEME_KEY, resolveThemeKey, normalizeTheme, resolveInitialTheme, resolveThemePayloadPreset, applyThemePreset, resetThemeToPreset, buildThemeReviewHref, createInitialBrandThemeState, isSameThemePayload, mergeThemeSetChoice, omitThemeFields, } from "../brand-theme-model";
17
+ import { omitPhiThemePaletteDefaults } from "../../../../theme/phi-theme-palette-defaults";
18
+ /*
19
+ * The colours a draft states as the Theme gives them anyway are not stored: they are no decision, and
20
+ * kept they would read as one wherever the record is read. Dropped ahead of the save's takeover of
21
+ * Module blocks, which copies a Module's palette in whole again; a core palette is then simply followed.
22
+ */
23
+ function omitThemePaletteDefaults(theme, presets) {
24
+ if (!theme.palette)
25
+ return theme;
26
+ const palette = omitPhiThemePaletteDefaults(resolveThemePayloadPreset(theme, presets), theme.palette, theme.style?.token ?? {});
27
+ return Object.keys(palette).length > 0 ? { ...theme, palette } : omitThemeFields(theme, "palette");
28
+ }
17
29
  /*
18
30
  * `correlationId` is the exchange this state belongs to: the command that saved, published or reset,
19
31
  * or the draft another Widget asked the Controller to take. It is absent only where the Controller
@@ -323,7 +335,7 @@ export function PhiThemeControllerRuntime({ runtime, config, setOptions, history
323
335
  themeKey,
324
336
  ]);
325
337
  async function saveTheme(draftTheme = stateRef.current.draft, options) {
326
- let nextTheme = ensurePhiThemeDerivation(draftTheme);
338
+ let nextTheme = omitThemePaletteDefaults(ensurePhiThemeDerivation(draftTheme), themePresets);
327
339
  setSaving(true);
328
340
  try {
329
341
  const current = stateRef.current;