@phis/ui 0.5.3 → 0.5.5

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 (211) hide show
  1. package/components/cms/phi-cms-layout-renderer.js +17 -7
  2. package/components/controls/phi-cascader-control.d.ts +9 -1
  3. package/components/controls/phi-cascader-control.js +25 -3
  4. package/components/controls/phi-money-control.d.ts +39 -0
  5. package/components/controls/phi-money-control.js +34 -0
  6. package/components/controls/phi-number-control.d.ts +6 -1
  7. package/components/controls/phi-number-control.js +3 -3
  8. package/components/controls/phi-options-provider.d.ts +7 -0
  9. package/components/controls/phi-options-provider.js +11 -0
  10. package/components/forms/extended-form-field-controls.d.ts +1 -0
  11. package/components/forms/extended-form-field-controls.js +23 -1
  12. package/components/forms/form-descriptor-runtime-client.js +13 -0
  13. package/components/forms/form-provider-contract.d.ts +43 -0
  14. package/components/forms/form-provider-contract.js +40 -0
  15. package/components/forms/money-field.d.ts +27 -0
  16. package/components/forms/money-field.js +78 -0
  17. package/components/forms/shared-form-provider-registry.js +4 -0
  18. package/components/layouts/clients/phi-flex-layout-client.js +17 -2
  19. package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
  20. package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
  21. package/components/media/phi-media-picker-binding.js +6 -1
  22. package/components/media/phi-site-font-assets.js +6 -1
  23. package/components/motion/phi-sequence-run.d.ts +14 -1
  24. package/components/motion/phi-sequence-run.js +22 -3
  25. package/components/motion/phi-sequence-viewport.js +3 -1
  26. package/components/regions/presets/content-entry-editor-page-tree.js +5 -1
  27. package/components/regions/presets/content-entry-public-page-trees.js +2 -0
  28. package/components/tables/client/phi-table-binding.js +16 -3
  29. package/components/trees/client/phi-tree-binding.js +6 -2
  30. package/components/widgets/builder/stack-tabs.d.ts +2 -1
  31. package/components/widgets/builder/stack-tabs.js +18 -2
  32. package/components/widgets/client/shared/phi-collection-view-binding.js +10 -2
  33. package/components/widgets/client/shared/phi-rendered-value.d.ts +9 -1
  34. package/components/widgets/client/shared/phi-rendered-value.js +20 -1
  35. package/components/widgets/config/choice-shared.d.ts +1 -49
  36. package/components/widgets/config/choice-shared.js +0 -1
  37. package/components/widgets/config/stack-tabs.js +4 -3
  38. package/components/widgets/label-sets/gallery.js +6 -0
  39. package/components/widgets/label-sets/interval.d.ts +4 -0
  40. package/components/widgets/label-sets/interval.js +31 -0
  41. package/components/widgets/label-sets/record.js +6 -1
  42. package/components/widgets/label-sets/slot-upload.d.ts +4 -0
  43. package/components/widgets/label-sets/slot-upload.js +36 -0
  44. package/components/widgets/label-sets/table.js +6 -1
  45. package/components/widgets/label-types/gallery.d.ts +7 -0
  46. package/components/widgets/label-types/gallery.js +6 -0
  47. package/components/widgets/label-types/interval.d.ts +16 -0
  48. package/components/widgets/label-types/interval.js +21 -0
  49. package/components/widgets/label-types/record.d.ts +3 -0
  50. package/components/widgets/label-types/record.js +2 -0
  51. package/components/widgets/label-types/slot-upload.d.ts +24 -0
  52. package/components/widgets/label-types/slot-upload.js +16 -0
  53. package/components/widgets/label-types/table.d.ts +3 -0
  54. package/components/widgets/label-types/table.js +2 -0
  55. package/constants/record-field-kinds.d.ts +1 -1
  56. package/constants/record-field-kinds.js +1 -1
  57. package/constants/runtime-module-ownership.js +1 -0
  58. package/controls.d.ts +7 -0
  59. package/controls.js +4 -0
  60. package/helpers/cms-dialog.d.ts +39 -3
  61. package/helpers/cms-dialog.js +46 -4
  62. package/helpers/cms-page-catalog.d.ts +8 -0
  63. package/helpers/cms-page-catalog.js +18 -2
  64. package/helpers/cms-preset-nodes.d.ts +13 -3
  65. package/helpers/cms-preset-nodes.js +3 -2
  66. package/helpers/config-text-fields.d.ts +49 -0
  67. package/helpers/config-text-fields.js +122 -0
  68. package/helpers/money-amount.d.ts +48 -0
  69. package/helpers/money-amount.js +131 -0
  70. package/helpers/page-layout-check.js +15 -2
  71. package/helpers/preset-text-source-check.d.ts +22 -0
  72. package/helpers/preset-text-source-check.js +45 -0
  73. package/helpers/record-fields.d.ts +18 -5
  74. package/helpers/record-fields.js +38 -13
  75. package/helpers/text-source.d.ts +14 -5
  76. package/helpers/text-source.js +16 -3
  77. package/module-page-check.d.ts +1 -0
  78. package/module-page-check.js +1 -0
  79. package/module-records.d.ts +6 -3
  80. package/module-records.js +4 -2
  81. package/package.json +2 -2
  82. package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
  83. package/plugins/runtime/slot-size-policy.d.ts +8 -2
  84. package/plugins/runtime/slot-size-policy.js +51 -16
  85. package/plugins/runtime-modules/accounting/module.d.ts +1 -1
  86. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
  87. package/plugins/runtime-modules/app/module.d.ts +1 -1
  88. package/plugins/runtime-modules/asset/services/collection.js +1 -0
  89. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -2
  90. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +3 -0
  91. package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
  92. package/plugins/runtime-modules/builder/offered-page-catalog.js +3 -3
  93. package/plugins/runtime-modules/builder/options-providers.js +7 -0
  94. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
  95. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +17 -3
  96. package/plugins/runtime-modules/contracts.d.ts +1 -1
  97. package/plugins/runtime-modules/core/definition.d.ts +43 -0
  98. package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
  99. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +6 -3
  100. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +6 -5
  101. package/plugins/runtime-modules/core/widgets/breadcrumb/plugin.js +1 -1
  102. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +9 -1
  103. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +29 -3
  104. package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
  105. package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
  106. package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
  107. package/plugins/runtime-modules/core/widgets/card/config.d.ts +18 -2
  108. package/plugins/runtime-modules/core/widgets/card/config.js +16 -1
  109. package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
  110. package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
  111. package/plugins/runtime-modules/core/widgets/card/server.js +16 -28
  112. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +4 -3
  113. package/plugins/runtime-modules/core/widgets/cascader/client.js +1 -1
  114. package/plugins/runtime-modules/core/widgets/cascader/config.d.ts +8 -2
  115. package/plugins/runtime-modules/core/widgets/cascader/config.js +22 -0
  116. package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +8 -2
  117. package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
  118. package/plugins/runtime-modules/core/widgets/description/config.d.ts +2 -1
  119. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +2 -2
  120. package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
  121. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
  122. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
  123. package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
  124. package/plugins/runtime-modules/core/widgets/gallery/authoring.js +12 -3
  125. package/plugins/runtime-modules/core/widgets/gallery/client.js +10 -1
  126. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +4 -1
  127. package/plugins/runtime-modules/core/widgets/gallery/config.js +8 -0
  128. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
  129. package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
  130. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +2 -1
  131. package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
  132. package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
  133. package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
  134. package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
  135. package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
  136. package/plugins/runtime-modules/core/widgets/record/client.js +8 -2
  137. package/plugins/runtime-modules/core/widgets/record/config.js +4 -0
  138. package/plugins/runtime-modules/core/widgets/result/config.d.ts +2 -2
  139. package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
  140. package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
  141. package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
  142. package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
  143. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +1 -1
  144. package/plugins/runtime-modules/core/widgets/select-box/config.d.ts +1 -1
  145. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +2 -1
  146. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +1 -1
  147. package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
  148. package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
  149. package/plugins/runtime-modules/core/widgets/slot-upload/authoring.js +2 -1
  150. package/plugins/runtime-modules/core/widgets/slot-upload/client.d.ts +3 -1
  151. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +45 -24
  152. package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +11 -4
  153. package/plugins/runtime-modules/core/widgets/slot-upload/config.js +16 -1
  154. package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -2
  155. package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +8 -3
  156. package/plugins/runtime-modules/core/widgets/slot-upload/server.js +9 -3
  157. package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
  158. package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
  159. package/plugins/runtime-modules/core/widgets/steps/config.d.ts +8 -3
  160. package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
  161. package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
  162. package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
  163. package/plugins/runtime-modules/core/widgets/table/config.d.ts +6 -3
  164. package/plugins/runtime-modules/core/widgets/table/config.js +4 -1
  165. package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
  166. package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
  167. package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
  168. package/plugins/runtime-modules/descriptor-compiler.d.ts +11 -1
  169. package/plugins/runtime-modules/descriptor-compiler.js +49 -8
  170. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  171. package/plugins/runtime-modules/groups/forms.d.ts +18 -0
  172. package/plugins/runtime-modules/groups/forms.js +2 -2
  173. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +8 -4
  174. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
  175. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
  176. package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
  177. package/plugins/runtime-modules/page-preset-overlays.js +70 -0
  178. package/plugins/runtime-modules/public/module.d.ts +1 -1
  179. package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
  180. package/plugins/runtime-modules/resolver.js +5 -0
  181. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +5 -2
  182. package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
  183. package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
  184. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
  185. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +6 -2
  186. package/plugins/runtime-modules/user-management/controller/client.js +6 -1
  187. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -3
  188. package/runtime-render-client.d.ts +1 -1
  189. package/runtime-render-client.js +2 -1
  190. package/server-helpers/cms-page-record.d.ts +2 -2
  191. package/server-helpers/cms-page-record.js +15 -5
  192. package/server-helpers/cms-request.js +34 -12
  193. package/server-helpers/cms-widget-texts.d.ts +14 -0
  194. package/server-helpers/cms-widget-texts.js +117 -0
  195. package/server-helpers/record-fields.d.ts +1 -1
  196. package/server-helpers/record-fields.js +1 -2
  197. package/server-helpers/record-samples.d.ts +4 -4
  198. package/server-helpers/record-samples.js +10 -2
  199. package/server-helpers/search-index.js +12 -3
  200. package/styles/root.css +6 -2
  201. package/types/cms-module-descriptors.d.ts +3 -0
  202. package/types/cms-plugins.d.ts +38 -5
  203. package/types/collection-provider.d.ts +7 -0
  204. package/types/core-widget-placements.d.ts +37 -0
  205. package/types/record-provider.d.ts +19 -3
  206. package/types/slot-size-policy.d.ts +19 -2
  207. package/types/table-widget.d.ts +33 -1
  208. package/types/table-widget.js +1 -0
  209. package/types/tree-widget.d.ts +7 -0
  210. package/types/widget-runtime.d.ts +1 -1
  211. package/types.d.ts +1 -0
@@ -45,6 +45,7 @@ const PhiLazyMultiSelectFormControl = lazyPhiFormFieldControl(() => import("./ch
45
45
  const PhiLazySegmentedFormControl = lazyPhiFormFieldControl(() => import("./choice-form-field-controls").then((module) => module.PhiSegmentedFormControl));
46
46
  const PhiLazyNumberFormControl = lazyPhiFormFieldControl(() => import("./extended-form-field-controls").then((module) => module.PhiNumberFormControl));
47
47
  const PhiLazyStorageSizeFormControl = lazyPhiFormFieldControl(() => import("./extended-form-field-controls").then((module) => module.PhiStorageSizeFormControl));
48
+ const PhiLazyMoneyFormControl = lazyPhiFormFieldControl(() => import("./extended-form-field-controls").then((module) => module.PhiMoneyFormControl));
48
49
  const PhiLazySliderFormControl = lazyPhiFormFieldControl(() => import("./extended-form-field-controls").then((module) => module.PhiSliderFormControl));
49
50
  const PhiLazyCascaderFormControl = lazyPhiFormFieldControl(() => import("./extended-form-field-controls").then((module) => module.PhiCascaderFormControl));
50
51
  const PhiLazyDateTimeFormControl = lazyPhiFormFieldControl(() => import("./datetime-form-control").then((module) => module.PhiDateTimeFormControl));
@@ -156,6 +157,9 @@ export const PHI_SHARED_FORM_PROVIDER_REGISTRY = createPhiFormProviderRegistry({
156
157
  phiSharedFieldType(PHI_FORM_FIELD_PROVIDER_KEYS.linkTarget, {
157
158
  Control: PhiLazyLinkTargetFormControl,
158
159
  }),
160
+ phiSharedFieldType(PHI_FORM_FIELD_PROVIDER_KEYS.money, {
161
+ Control: PhiLazyMoneyFormControl,
162
+ }),
159
163
  ],
160
164
  validationRules: [
161
165
  phiSharedValidationRule(PHI_FORM_VALIDATION_PROVIDER_KEYS.required, {
@@ -96,6 +96,21 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
96
96
  function isRenderableSlotChild(child) {
97
97
  return child !== null && child !== undefined && child !== false;
98
98
  }
99
+ /*
100
+ * Whether a content child takes the rest of the main axis. A child does when it states `rest` and still
101
+ * fills that axis (a stated size makes the axis `fixed`). Where any does, the others that fill the main
102
+ * axis keep their content size on it, so the rest is shared among those that took it and nobody else.
103
+ */
104
+ const mainAxisHasRestTaker = slots.some((child, index) => {
105
+ if (!isRenderableSlotChild(child) || isFlexSeparatorChild(child)) {
106
+ return false;
107
+ }
108
+ if ((resolvedSlotStates[index] ?? "expanded") !== "expanded") {
109
+ return false;
110
+ }
111
+ const sizing = resolvePhiLayoutSlotChildSizing(child);
112
+ return sizing.takesRest && (resolvedVertical ? sizing.stretchesBlock : sizing.stretchesInline);
113
+ });
99
114
  const renderSlotChild = (child, index) => {
100
115
  if (isFlexSeparatorChild(child)) {
101
116
  return child;
@@ -122,7 +137,7 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
122
137
  }
123
138
  : {};
124
139
  if (resolvedVertical) {
125
- const shouldFillMainAxis = slotSizing.stretchesBlock;
140
+ const shouldFillMainAxis = slotSizing.stretchesBlock && (!mainAxisHasRestTaker || slotSizing.takesRest);
126
141
  const shouldFillCrossAxis = slotSizing.stretchesInline;
127
142
  return (_jsx("div", { className: phiLayoutSlotClassName(isAuthoringRender), "data-phi-layout-has-content": phiLayoutSlotContentMarker(isAuthoringRender, true), style: {
128
143
  flexGrow: shouldFillMainAxis ? 1 : 0,
@@ -166,7 +181,7 @@ export function PhiFlexLayout({ slots, ...layoutProps }) {
166
181
  }),
167
182
  }, children: child }, `content-${index}`));
168
183
  }
169
- const shouldFillMainAxis = slotSizing.stretchesInline;
184
+ const shouldFillMainAxis = slotSizing.stretchesInline && (!mainAxisHasRestTaker || slotSizing.takesRest);
170
185
  const shouldFillCrossAxis = slotSizing.stretchesBlock;
171
186
  const minMainSize = slotSizing.minInlineSize;
172
187
  const maxMainSize = slotSizing.maxInlineSize;
@@ -17,6 +17,8 @@ export type PhiLayoutSlotChildSizing = {
17
17
  */
18
18
  stretchesInline: boolean;
19
19
  stretchesBlock: boolean;
20
+ /** The child states `rest`; a Flex Layout also asks whether it still fills its main axis. */
21
+ takesRest: boolean;
20
22
  minInlineSize: CSSProperties["minWidth"];
21
23
  minBlockSize: CSSProperties["minHeight"];
22
24
  maxInlineSize: CSSProperties["maxWidth"];
@@ -22,6 +22,7 @@ export function resolvePhiLayoutSlotChildSizing(child) {
22
22
  hasExplicitHeight: slotSizing.explicitBlockSize,
23
23
  stretchesInline: slotSizing.policy.inline === "fill",
24
24
  stretchesBlock: slotSizing.policy.block === "fill",
25
+ takesRest: slotSizing.policy.takesRest === true,
25
26
  minInlineSize: slotSizing.minInlineSize,
26
27
  minBlockSize: slotSizing.minBlockSize,
27
28
  maxInlineSize: slotSizing.maxInlineSize,
@@ -90,6 +91,7 @@ export function PhiLayoutAnchoredOverlay({ anchor, slotRole, positionMode = "abs
90
91
  }, ...buildPhiSlotChildDataAttributes({
91
92
  inline: slotSizing.fillInline ? "fill" : "intrinsic",
92
93
  block: slotSizing.fillBlock ? "fill" : "intrinsic",
94
+ ...(slotSizing.takesRest ? { takesRest: true } : {}),
93
95
  }, {
94
96
  explicitInlineSize: slotSizing.hasExplicitWidth,
95
97
  explicitBlockSize: slotSizing.hasExplicitHeight,
@@ -4,6 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
4
4
  import { PhiImageAssetVariantKey, PhiMediaKind } from "../../constants/media";
5
5
  import { usePhiControlSignalController } from "../widgets/client/shared/phi-control-signals";
6
6
  import { usePhiCollectionProvider } from "../widgets/client/shared/phi-collection-provider";
7
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../root/phi-intl-locale";
7
8
  import { PhiMediaPickerControl } from "../controls/phi-media-picker-control";
8
9
  import { normalizePhiMediaPickerMinColumnWidth } from "../controls/phi-media-picker-control-contract";
9
10
  import { PHI_ASSET_COLLECTION_DATA_SOURCE } from "./asset-collection-runtime";
@@ -48,6 +49,8 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
48
49
  : null;
49
50
  const source = config?.dataSource ?? PHI_ASSET_COLLECTION_DATA_SOURCE;
50
51
  const { provider, bindingError } = usePhiCollectionProvider(source);
52
+ const locale = usePhiIntlLocale();
53
+ const timeZone = usePhiIntlTimeZone();
51
54
  const folderOptions = useMemo(() => buildPhiMediaFolderCascaderOptions(folders), [folders]);
52
55
  const spaceOptions = useMemo(() => buildPhiMediaSpaceOptions(spaces, labels.space), [labels.space, spaces]);
53
56
  const folderValue = useMemo(() => buildPhiMediaFolderValueById(folders, folderId), [folderId, folders]);
@@ -88,6 +91,8 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
88
91
  resourceKey: source.resourceKey,
89
92
  query,
90
93
  params: "params" in source ? source.params : undefined,
94
+ locale,
95
+ timeZone,
91
96
  signal: abortController.signal,
92
97
  });
93
98
  if (abortController.signal.aborted)
@@ -122,7 +127,7 @@ export function usePhiMediaPickerBinding({ config, labels, searchLabels, value:
122
127
  };
123
128
  void load();
124
129
  return () => abortController.abort();
125
- }, [isOpen, provider, query, refreshToken, source]);
130
+ }, [isOpen, locale, provider, query, refreshToken, source, timeZone]);
126
131
  const resolvedAssets = provider && source ? assets : [];
127
132
  const updateOpen = (next) => {
128
133
  if (controlledOpen == null)
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from "react";
3
3
  import { PhiMediaKind } from "../../constants/media";
4
4
  import { createPhiAssetUri } from "../../types/references";
5
5
  import { usePhiCollectionProvider } from "../widgets/client/shared/phi-collection-provider";
6
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../root/phi-intl-locale";
6
7
  import { PHI_ASSET_COLLECTION_DATA_SOURCE } from "./asset-collection-runtime";
7
8
  import { readPhiMediaAssetTiles } from "./phi-image-preview-data";
8
9
  /**
@@ -35,6 +36,8 @@ function readFontAssetLabel(asset) {
35
36
  */
36
37
  export function usePhiSiteFontAssets(enabled = true) {
37
38
  const { provider } = usePhiCollectionProvider(PHI_ASSET_COLLECTION_DATA_SOURCE);
39
+ const locale = usePhiIntlLocale();
40
+ const timeZone = usePhiIntlTimeZone();
38
41
  const [assets, setAssets] = useState([]);
39
42
  const [loading, setLoading] = useState(false);
40
43
  const [error, setError] = useState(null);
@@ -55,6 +58,8 @@ export function usePhiSiteFontAssets(enabled = true) {
55
58
  sortOrder: "descending",
56
59
  filters: { kind: PhiMediaKind.Font },
57
60
  },
61
+ locale,
62
+ timeZone,
58
63
  signal: abortController.signal,
59
64
  }).then((data) => {
60
65
  if (abortController.signal.aborted)
@@ -75,7 +80,7 @@ export function usePhiSiteFontAssets(enabled = true) {
75
80
  setLoading(false);
76
81
  });
77
82
  return () => abortController.abort();
78
- }, [enabled, provider]);
83
+ }, [enabled, locale, provider, timeZone]);
79
84
  const options = useMemo(() => assets
80
85
  .filter((asset) => asset.kind === PhiMediaKind.Font)
81
86
  .map((asset) => ({
@@ -3,6 +3,12 @@ import { type PhiSequenceSettings } from "../widgets/config/sequence-settings";
3
3
  import type { PhiSequenceControlLabels } from "../widgets/label-types/sequence";
4
4
  /** How many items stand in the window: never more than there are, never fewer than one. */
5
5
  export declare function resolvePhiSequenceRunSpan(visibleCount: number | undefined, itemCount: number): number;
6
+ /** One small stand-in for an item: its content, and its name for a screen reader (empty falls back to the page label). */
7
+ export type PhiSequenceThumbnail = {
8
+ key: string;
9
+ label: string;
10
+ content: ReactNode;
11
+ };
6
12
  /**
7
13
  * A run of items shown a few at a time, and the two things the browser will not do for us.
8
14
  *
@@ -18,10 +24,17 @@ export declare function resolvePhiSequenceRunSpan(visibleCount: number | undefin
18
24
  *
19
25
  * What the items are is the caller's: the Gallery's pictures, the Entries list's cards.
20
26
  */
21
- export declare function PhiSequenceRun({ items, settings, labels, itemStyle, }: {
27
+ export declare function PhiSequenceRun({ items, settings, labels, itemStyle, thumbnails, thumbnailWidth, }: {
22
28
  /** Keyed by the caller; the run neither wraps nor rekeys them. */
23
29
  items: readonly ReactNode[];
24
30
  settings: PhiSequenceSettings | undefined;
25
31
  labels: PhiSequenceControlLabels;
26
32
  itemStyle?: CSSProperties;
33
+ /**
34
+ * A row of buttons under the window, one per item, in place of the dots. Acts only while one item is
35
+ * shown at a time; the active item's is marked and a press makes its item the active one.
36
+ */
37
+ thumbnails?: readonly PhiSequenceThumbnail[];
38
+ /** A thumbnail's width in pixels. */
39
+ thumbnailWidth?: number;
27
40
  }): import("react").JSX.Element | null;
@@ -18,6 +18,10 @@ function formatPageLabel(template, from, to) {
18
18
  export function resolvePhiSequenceRunSpan(visibleCount, itemCount) {
19
19
  return Math.min(visibleCount ?? PHI_SEQUENCE_SETTINGS_DEFAULTS.visibleCount, Math.max(itemCount, 1));
20
20
  }
21
+ /** Whether the thumbnail row is drawn: only over one item at a time, and only where there is something to choose. */
22
+ function resolvePhiSequenceShowsThumbnails(thumbnails, span, itemCount) {
23
+ return thumbnails !== undefined && span === 1 && itemCount > 1;
24
+ }
21
25
  /**
22
26
  * A run of items shown a few at a time, and the two things the browser will not do for us.
23
27
  *
@@ -33,7 +37,7 @@ export function resolvePhiSequenceRunSpan(visibleCount, itemCount) {
33
37
  *
34
38
  * What the items are is the caller's: the Gallery's pictures, the Entries list's cards.
35
39
  */
36
- export function PhiSequenceRun({ items, settings, labels, itemStyle, }) {
40
+ export function PhiSequenceRun({ items, settings, labels, itemStyle, thumbnails, thumbnailWidth, }) {
37
41
  const { token } = usePhiConfig();
38
42
  const defaults = PHI_SEQUENCE_SETTINGS_DEFAULTS;
39
43
  const loop = settings?.loop ?? defaults.loop;
@@ -70,8 +74,23 @@ export function PhiSequenceRun({ items, settings, labels, itemStyle, }) {
70
74
  const atEnd = windowStart >= lastStart;
71
75
  // Two disabled arrows over a single item say nothing; the dots already know to stay away.
72
76
  const showArrows = (controls === "arrows" || controls === "both") && itemCount > span;
73
- const showDots = (controls === "dots" || controls === "both") && pageCount > 1;
74
- return (_jsxs("div", { role: "region", "aria-roledescription": "carousel", "aria-label": labels.region, style: { display: "flex", flexDirection: "column", gap: token.marginXS, width: "100%", minWidth: 0, ...gestures.style }, ...autoplay.holdHandlers, ...gestures.handlers, children: [_jsxs("div", { style: { position: "relative", minWidth: 0 }, "aria-live": autoplay.running ? "off" : "polite", children: [_jsx(PhiSequenceViewport, { items: [...items], activeIndex: activeIndex, visibleCount: span, anchor: "start", transition: settings?.transition ?? defaults.transition, ...(settings?.durationMs === undefined ? {} : { durationMs: settings.durationMs }), ...(settings?.easing === undefined ? {} : { easing: settings.easing }), lookahead: settings?.lookahead ?? defaults.lookahead, mountPolicy: settings?.mountPolicy ?? defaults.mountPolicy, gap: resolvePhiSpacingScaleValue(settings?.gap ?? defaults.gap), itemStyle: itemStyle }), showArrows ? (_jsxs(_Fragment, { children: [_jsx("div", { style: { position: "absolute", insetBlockStart: "50%", insetInlineStart: token.marginXS, transform: "translateY(-50%)" }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "left", size: "inherit" }), ariaLabel: labels.previous, shape: "circle", disabled: atStart && !loop, onClick: () => stepByHand(-1) }) }), _jsx("div", { style: { position: "absolute", insetBlockStart: "50%", insetInlineEnd: token.marginXS, transform: "translateY(-50%)" }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "right", size: "inherit" }), ariaLabel: labels.next, shape: "circle", disabled: atEnd && !loop, onClick: () => stepByHand(1) }) })] })) : null, autoplay.offered ? (_jsx("div", { style: { position: "absolute", insetBlockEnd: token.marginXS, insetInlineEnd: token.marginXS }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: autoplay.stopped ? "play-circle" : "pause-circle", size: "inherit" }), ariaLabel: autoplay.stopped ? labels.play : labels.pause, ariaPressed: autoplay.stopped, shape: "circle", onClick: autoplay.toggleStopped }) })) : null] }), showDots ? (_jsx("div", { role: "group", "aria-label": labels.pages, style: { display: "flex", justifyContent: "center", gap: token.marginXXS }, children: Array.from({ length: pageCount }, (_, page) => (_jsx("button", { type: "button", "aria-label": formatPageLabel(labels.page, (pageStarts[page] ?? 0) + 1, Math.min((pageStarts[page] ?? 0) + span, itemCount)), "aria-current": page === currentPage || undefined, onClick: () => {
77
+ const showThumbnails = resolvePhiSequenceShowsThumbnails(thumbnails, span, itemCount);
78
+ const showDots = !showThumbnails && (controls === "dots" || controls === "both") && pageCount > 1;
79
+ return (_jsxs("div", { role: "region", "aria-roledescription": "carousel", "aria-label": labels.region, style: { display: "flex", flexDirection: "column", gap: token.marginXS, width: "100%", minWidth: 0, ...gestures.style }, ...autoplay.holdHandlers, ...gestures.handlers, children: [_jsxs("div", { style: { position: "relative", minWidth: 0 }, "aria-live": autoplay.running ? "off" : "polite", children: [_jsx(PhiSequenceViewport, { items: [...items], activeIndex: activeIndex, visibleCount: span, anchor: "start", transition: settings?.transition ?? defaults.transition, ...(settings?.durationMs === undefined ? {} : { durationMs: settings.durationMs }), ...(settings?.easing === undefined ? {} : { easing: settings.easing }), lookahead: settings?.lookahead ?? defaults.lookahead, mountPolicy: settings?.mountPolicy ?? defaults.mountPolicy, gap: resolvePhiSpacingScaleValue(settings?.gap ?? defaults.gap), itemStyle: itemStyle }), showArrows ? (_jsxs(_Fragment, { children: [_jsx("div", { style: { position: "absolute", insetBlockStart: "50%", insetInlineStart: token.marginXS, transform: "translateY(-50%)" }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "left", size: "inherit" }), ariaLabel: labels.previous, shape: "circle", disabled: atStart && !loop, onClick: () => stepByHand(-1) }) }), _jsx("div", { style: { position: "absolute", insetBlockStart: "50%", insetInlineEnd: token.marginXS, transform: "translateY(-50%)" }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: "right", size: "inherit" }), ariaLabel: labels.next, shape: "circle", disabled: atEnd && !loop, onClick: () => stepByHand(1) }) })] })) : null, autoplay.offered ? (_jsx("div", { style: { position: "absolute", insetBlockEnd: token.marginXS, insetInlineEnd: token.marginXS }, children: _jsx(PhiButtonControl, { icon: _jsx(PhiIcon, { name: autoplay.stopped ? "play-circle" : "pause-circle", size: "inherit" }), ariaLabel: autoplay.stopped ? labels.play : labels.pause, ariaPressed: autoplay.stopped, shape: "circle", onClick: autoplay.toggleStopped }) })) : null] }), showThumbnails ? (_jsx("div", { role: "group", "aria-label": labels.pages, style: { display: "flex", flexWrap: "wrap", justifyContent: "center", gap: resolvePhiSpacingScaleValue("xs"), minWidth: 0 }, children: thumbnails?.map((thumbnail, index) => (_jsx("button", { type: "button", "aria-label": thumbnail.label || formatPageLabel(labels.page, index + 1, index + 1), "aria-current": index === activeIndex || undefined, "aria-pressed": index === activeIndex, onClick: () => {
80
+ setActiveIndex(index);
81
+ autoplay.restart();
82
+ }, style: {
83
+ flex: "none",
84
+ width: thumbnailWidth,
85
+ padding: 0,
86
+ cursor: "pointer",
87
+ overflow: "hidden",
88
+ background: "none",
89
+ borderRadius: token.borderRadius,
90
+ border: `${token.lineWidthBold}px solid ${index === activeIndex ? token.colorPrimary : "transparent"}`,
91
+ opacity: index === activeIndex ? 1 : 0.7,
92
+ transition: `border-color ${token.motionDurationMid}, opacity ${token.motionDurationMid}`,
93
+ }, children: thumbnail.content }, thumbnail.key))) })) : null, showDots ? (_jsx("div", { role: "group", "aria-label": labels.pages, style: { display: "flex", justifyContent: "center", gap: token.marginXXS }, children: Array.from({ length: pageCount }, (_, page) => (_jsx("button", { type: "button", "aria-label": formatPageLabel(labels.page, (pageStarts[page] ?? 0) + 1, Math.min((pageStarts[page] ?? 0) + span, itemCount)), "aria-current": page === currentPage || undefined, onClick: () => {
75
94
  setActiveIndex(pageStarts[page] ?? 0);
76
95
  autoplay.restart();
77
96
  }, style: {
@@ -80,7 +80,9 @@ export function PhiSequenceViewport({ items, activeIndex, visibleCount = 1, anch
80
80
  const slice = span === 1
81
81
  ? "100%"
82
82
  : `calc((100% - ${span - 1} * ${gapLength}) / ${span})`;
83
- const step = span === 1 ? "100%" : `calc(${slice} + ${gapLength})`;
83
+ // One place's width plus the gap after it, for one visible item as for several: the track's items stand
84
+ // that far apart, so a step of the width alone drifts a gap further off the window with every item.
85
+ const step = `calc(${slice} + ${gapLength})`;
84
86
  const mountedIndices = new Set();
85
87
  for (let index = 0; index < itemCount; index += 1) {
86
88
  const insideWindow = index >= start - lookahead && index < start + span + lookahead;
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../helpers/text-source";
1
2
  import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, } from "../../../constants/cms-layout-types";
2
3
  import { PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS } from "../../../constants/core-data-provider-keys";
3
4
  import { canPhiViewerAccess, PHI_VIEWER_ACCESS_PUBLISHING } from "../../../types/access";
@@ -11,7 +12,7 @@ import { PHI_SIGNAL_VALUE_SCHEMAS, createPhiSignalAddress, } from "../../../type
11
12
  import { PHI_CONTENT_ENTRY_SOURCE_LOCALE_PLACEHOLDER_CONFIG_KEY } from "../../forms/content-entry-forms";
12
13
  import { PHI_CONTENT_ENTRY_CURATION_NONE_CONFIG_KEYS } from "../../forms/content-entry-curation-config";
13
14
  import { PHI_SITE_LOCALES_CONFIG_KEY } from "../../forms/site-locales-config";
14
- import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG } from "../../../helpers/cms-dialog";
15
+ import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH_SINGLE_COLUMN, } from "../../../helpers/cms-dialog";
15
16
  /**
16
17
  * The node keys of an editor Page. They make its instance ids together with the Module and the preset
17
18
  * key, so they are part of every stored placement and do not change.
@@ -88,6 +89,8 @@ function buildEntryDialogNodes(nodes, input) {
88
89
  label: `${input.routePrefix} ${input.key} modal`,
89
90
  config: {
90
91
  title: input.title,
92
+ // Every Form of an entry is one column (helpers/cms-dialog.ts).
93
+ width: PHI_DIALOG_WIDTH_SINGLE_COLUMN,
91
94
  mountPolicy: "remount",
92
95
  /*
93
96
  * `immediate`: there is nobody to ask. `request` exists so a Controller can refuse while a save
@@ -180,6 +183,7 @@ function buildEntryDialogNodes(nodes, input) {
180
183
  label: `${input.routePrefix} ${input.key} commands`,
181
184
  config: {
182
185
  key: `${prefix}-commands`,
186
+ textSource: PHI_TEXT_SOURCE_PRESET,
183
187
  ...PHI_DIALOG_COMMANDS_CONFIG,
184
188
  /*
185
189
  * The two buttons as one group, the way every other overlay footer states it: they are the two
@@ -1,3 +1,4 @@
1
+ import { PHI_TEXT_SOURCE_PRESET } from "../../../helpers/text-source";
1
2
  import "server-only";
2
3
  import { notFound } from "next/navigation";
3
4
  import { createPhiPresetCmsInstanceIdMap } from "../../../types/cms-instance-id";
@@ -129,6 +130,7 @@ export async function buildPhiContentEntryDetailPageTree({ page, runtime, params
129
130
  config: {
130
131
  kind,
131
132
  source: "related",
133
+ textSource: PHI_TEXT_SOURCE_PRESET,
132
134
  relatedTo: entry,
133
135
  presentation: related.presentation,
134
136
  ...listPartsFor(related.presentation),
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
4
4
  import { PhiTableProviderError, readPhiTableProviderError, readPhiTableProviderMutationResult, readPhiTableProviderQueryResult, validatePhiTableProviderFieldValue, } from "../../../types/table-widget";
5
5
  import { mergePhiTableQueryFilters, movePhiTableBindingRows, movePhiTableBindingTreeRows, patchPhiTableBindingRows, readPhiTableRowIdentity, readPhiTableRowValue, restorePhiTableBindingRowOrder, } from "../../../helpers/table-binding";
6
6
  import { usePhiTableProvider } from "../../widgets/client/shared/phi-table-provider";
7
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../root/phi-intl-locale";
7
8
  function validateProviderSummary(resource, summary) {
8
9
  if (!summary)
9
10
  return null;
@@ -65,6 +66,12 @@ function resolvePhiTableQuery(query, externalQuery, externalSearch, expandedRowI
65
66
  }
66
67
  export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, fixedFilters, externalSearch, defaultPageSize = 20, refreshKey, preserveSelectedRowIdentities = false, initialExpandedRowIdentities = [], onData, onMutation, validateResource, }) {
67
68
  const { provider, resource, bindingError } = usePhiTableProvider(source);
69
+ /*
70
+ * The reader's language and the Site's zone go with every query, and into what decides that a query
71
+ * is new: a Provider that wrote "per month" into its rows has to write them again after a switch.
72
+ */
73
+ const locale = usePhiIntlLocale();
74
+ const timeZone = usePhiIntlTimeZone();
68
75
  const resourceError = resource ? validateResource?.(resource) ?? null : null;
69
76
  const [query, setQuery] = useState(() => ({
70
77
  page: initialQuery.page ?? 1,
@@ -239,6 +246,8 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
239
246
  resourceError,
240
247
  resolvedQueryKey,
241
248
  refreshKey,
249
+ locale,
250
+ timeZone,
242
251
  };
243
252
  return;
244
253
  }
@@ -249,9 +258,11 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
249
258
  previous.source === source &&
250
259
  previous.resourceError === resourceError &&
251
260
  previous.resolvedQueryKey === resolvedQueryKey &&
252
- previous.refreshKey === refreshKey;
261
+ previous.refreshKey === refreshKey &&
262
+ previous.locale === locale &&
263
+ previous.timeZone === timeZone;
253
264
  const background = refreshRequest.background && sameQueryInputs && rowsRef.current.length > 0;
254
- previousQueryInputs.current = { provider, resource, source, resourceError, resolvedQueryKey, refreshKey };
265
+ previousQueryInputs.current = { provider, resource, source, resourceError, resolvedQueryKey, refreshKey, locale, timeZone };
255
266
  const abortController = new AbortController();
256
267
  queueMicrotask(() => {
257
268
  if (!abortController.signal.aborted) {
@@ -265,6 +276,8 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
265
276
  resourceKey: source.resourceKey,
266
277
  query: resolvedQuery,
267
278
  params: source.params,
279
+ locale,
280
+ timeZone,
268
281
  signal: abortController.signal,
269
282
  }).then((value) => {
270
283
  const data = readPhiTableProviderQueryResult(value);
@@ -303,7 +316,7 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
303
316
  }
304
317
  });
305
318
  return () => abortController.abort();
306
- }, [applyData, expandedRowIdentities, externalQuery, externalSearch, provider, query, refreshKey, refreshRequest, resolvedQuery, resolvedQueryKey, resource, resourceError, source, stableFixedFilters]);
319
+ }, [applyData, expandedRowIdentities, externalQuery, externalSearch, locale, provider, query, refreshKey, refreshRequest, resolvedQuery, resolvedQueryKey, resource, resourceError, source, stableFixedFilters, timeZone]);
307
320
  const reload = useCallback(() => setRefreshRequest((current) => ({
308
321
  revision: current.revision + 1,
309
322
  background: false,
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { PhiTreeProviderError, readPhiTreeNodePath as readPath, readPhiTreeProviderError, readPhiTreeProviderMutationResult, readPhiTreeProviderQueryResult, } from "../../../types/tree-widget";
4
4
  import { validatePhiTableProviderFieldValue } from "../../../types/table-widget";
5
5
  import { usePhiTreeProvider } from "../../widgets/client/shared/phi-tree-provider";
6
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../root/phi-intl-locale";
6
7
  function patchNode(nodes, identityPath, identity, patch) {
7
8
  return nodes.map((node) => String(readPath(node, identityPath)) === String(identity) ? { ...node, ...patch } : node);
8
9
  }
@@ -81,6 +82,9 @@ const PHI_TREE_DEFAULT_INITIAL_QUERY = Object.freeze({});
81
82
  const PHI_TREE_DEFAULT_EXPANDED_NODE_IDENTITIES = Object.freeze([]);
82
83
  export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INITIAL_QUERY, defaultExpandedNodeIdentities = PHI_TREE_DEFAULT_EXPANDED_NODE_IDENTITIES, defaultExpandAll = false, }) {
83
84
  const { provider, resource, bindingError } = usePhiTreeProvider(source);
85
+ // Sent with every query and part of what makes one new, so a live language switch asks again.
86
+ const locale = usePhiIntlLocale();
87
+ const timeZone = usePhiIntlTimeZone();
84
88
  const [query, setQuery] = useState(initialQuery);
85
89
  const [nodes, setNodes] = useState([]);
86
90
  const nodesRef = useRef(nodes);
@@ -143,7 +147,7 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
143
147
  setQueryFailure(null);
144
148
  }
145
149
  });
146
- void provider.query({ resourceKey: source.resourceKey, query, params: source.params, signal: controller.signal })
150
+ void provider.query({ resourceKey: source.resourceKey, query, params: source.params, locale, timeZone, signal: controller.signal })
147
151
  .then((value) => {
148
152
  if (controller.signal.aborted)
149
153
  return;
@@ -174,7 +178,7 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
174
178
  }
175
179
  });
176
180
  return () => controller.abort();
177
- }, [defaultExpandAll, provider, query, refreshRevision, resource, source]);
181
+ }, [defaultExpandAll, locale, provider, query, refreshRevision, resource, source, timeZone]);
178
182
  /*
179
183
  * One change, shown before it is confirmed where the caller passes what it will look like.
180
184
  *
@@ -1,2 +1,3 @@
1
+ import type { PhiCmsBuilderWidgetPlugin } from "../../../types";
1
2
  import { type PhiCmsTabBarWidgetConfig } from "../config/stack-tabs";
2
- export declare const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN: import("../../../types").PhiCmsBuilderWidgetPlugin<PhiCmsTabBarWidgetConfig>;
3
+ export declare const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN: PhiCmsBuilderWidgetPlugin<PhiCmsTabBarWidgetConfig>;
@@ -1,6 +1,22 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createPhiCmsBuilderWidgetPlugin } from "../../../plugins/factories/widget-builder-plugin";
4
3
  import { PHI_TAB_BAR_WIDGET_DEFINITION, } from "../config/stack-tabs";
5
4
  import { PhiTabBarWidgetClient } from "../client/stack-tabs";
6
- export const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN = createPhiCmsBuilderWidgetPlugin(PHI_TAB_BAR_WIDGET_DEFINITION, ({ config }) => _jsx(PhiTabBarWidgetClient, { config: config }));
5
+ import { PhiStaticOptionsToolButton } from "./phi-static-options-picker";
6
+ export const PHI_TAB_BAR_WIDGET_BUILDER_PLUGIN = {
7
+ ...PHI_TAB_BAR_WIDGET_DEFINITION,
8
+ renderEditor: ({ config }) => _jsx(PhiTabBarWidgetClient, { config: config }),
9
+ /*
10
+ * Static options only where they are what is drawn: not while a provider answers for them, and not
11
+ * while the tabs are the followed Stack's slots.
12
+ */
13
+ renderEditorTools: ({ config, authoring }) => authoring?.updateConfig && !config.optionsProvider && config.valueMode !== "stack-slot-index" ? (_jsx(PhiStaticOptionsToolButton, { options: config.options, onApply: (options) => {
14
+ const selectedValue = config.value?.trim();
15
+ authoring.updateConfig?.({
16
+ options,
17
+ ...(!selectedValue || options.some((option) => option.value === selectedValue)
18
+ ? {}
19
+ : { value: options[0]?.value }),
20
+ });
21
+ } })) : null,
22
+ };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../root/phi-intl-locale";
3
4
  import { usePhiCollectionProvider } from "./phi-collection-provider";
4
5
  function buildInitialQuery(initialQuery, pageSize) {
5
6
  return {
@@ -11,6 +12,9 @@ function buildInitialQuery(initialQuery, pageSize) {
11
12
  }
12
13
  export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, }) {
13
14
  const { provider, resource, bindingError } = usePhiCollectionProvider(source);
15
+ // Sent with every query and part of its key, so a live language switch asks again.
16
+ const locale = usePhiIntlLocale();
17
+ const timeZone = usePhiIntlTimeZone();
14
18
  const [query, setQuery] = useState(() => buildInitialQuery(initialQuery, pageSize));
15
19
  const [data, setData] = useState(null);
16
20
  const [loading, setLoading] = useState(false);
@@ -40,8 +44,10 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
40
44
  source?.resourceKey ?? null,
41
45
  source?.params ?? null,
42
46
  query,
47
+ locale,
48
+ timeZone,
43
49
  refreshToken,
44
- ]), [query, refreshToken, source]);
50
+ ]), [locale, query, refreshToken, source, timeZone]);
45
51
  useEffect(() => {
46
52
  const nextQuery = JSON.parse(initialQueryKey);
47
53
  const timer = window.setTimeout(() => {
@@ -70,6 +76,8 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
70
76
  resourceKey: source.resourceKey,
71
77
  query,
72
78
  params: source.params,
79
+ locale,
80
+ timeZone,
73
81
  signal: abortController.signal,
74
82
  }).then((nextData) => {
75
83
  if (!isCurrent())
@@ -92,7 +100,7 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
92
100
  window.clearTimeout(loadingTimer);
93
101
  abortController.abort();
94
102
  };
95
- }, [bindingError, provider, query, requestKey, source]);
103
+ }, [bindingError, locale, provider, query, requestKey, source, timeZone]);
96
104
  const reload = useCallback(() => setRefreshToken((current) => current + 1), []);
97
105
  const activate = useCallback(async (request) => {
98
106
  if (!provider || !source || bindingError) {
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import { type PhiIntervalLabels } from "../../label-types/interval";
2
3
  import type { PhiTableTagColor, PhiTableTagVariant, PhiTableValueRenderer } from "../../../../types/table-widget";
3
4
  /**
4
5
  * How one value out of a Provider is drawn: a date as a date, an address as a link, a set of words as
@@ -17,6 +18,13 @@ export type PhiRenderedValueDefinition = {
17
18
  tagColorMap?: Readonly<Record<string, PhiTableTagColor>>;
18
19
  tagVariant?: PhiTableTagVariant;
19
20
  };
21
+ /**
22
+ * The words a renderer needs that are not in the value: Core's, from a Label Set the Widget's server
23
+ * half read in the page's language. Only `interval` has any.
24
+ */
25
+ export type PhiRenderedValueLabels = {
26
+ interval: PhiIntervalLabels;
27
+ };
20
28
  /**
21
29
  * Where the value stands, which only `json` cares about.
22
30
  *
@@ -26,4 +34,4 @@ export type PhiRenderedValueDefinition = {
26
34
  * it could not have simply called the table's renderer.
27
35
  */
28
36
  export type PhiRenderedValuePresentation = "cell" | "block";
29
- export declare function renderPhiValueContent(value: unknown, definition: PhiRenderedValueDefinition, presentation?: PhiRenderedValuePresentation): ReactNode;
37
+ export declare function renderPhiValueContent(value: unknown, definition: PhiRenderedValueDefinition, labels: PhiRenderedValueLabels, presentation?: PhiRenderedValuePresentation): ReactNode;
@@ -1,6 +1,9 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { formatPhisMoney } from "@phis/contracts/payments";
3
4
  import { formatPhiDate, formatPhiDateTime } from "../../../../helpers/format-date-time";
5
+ import { readPhiMoneyValue } from "../../../../helpers/money-amount";
6
+ import { formatPhiInterval, readPhiIntervalValue } from "../../label-types/interval";
4
7
  import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../root/phi-intl-locale";
5
8
  import { PhiFlexControl } from "../../../controls/phi-flex-control";
6
9
  import { PhiTagControl } from "../../../controls/phi-tag-control";
@@ -39,9 +42,25 @@ function PhiRenderedDate({ value, withTime }) {
39
42
  const timeZone = usePhiIntlTimeZone();
40
43
  return withTime ? formatPhiDateTime(value, locale, timeZone) : formatPhiDate(value, locale, timeZone);
41
44
  }
42
- export function renderPhiValueContent(value, definition, presentation = "cell") {
45
+ /** The reader's locale, not the server's or the browser's, and the currency's own places. */
46
+ function PhiRenderedMoney({ value }) {
47
+ return formatPhisMoney(value, usePhiIntlLocale());
48
+ }
49
+ export function renderPhiValueContent(value, definition, labels, presentation = "cell") {
43
50
  if (value == null || value === "")
44
51
  return null;
52
+ /*
53
+ * Read before anything is stringified: both are objects, and a value that is not one of them draws
54
+ * nothing rather than its JSON -- a cell that says `{"currency":"CHF"}` is no amount of money.
55
+ */
56
+ if (definition.renderer === "money") {
57
+ const money = readPhiMoneyValue(value);
58
+ return money ? _jsx(PhiRenderedMoney, { value: money }) : null;
59
+ }
60
+ if (definition.renderer === "interval") {
61
+ const interval = readPhiIntervalValue(value);
62
+ return interval ? formatPhiInterval(interval, labels.interval) : null;
63
+ }
45
64
  const normalizedValue = normalizePhiRenderedText(value);
46
65
  const displayValue = definition.valueMap?.[normalizedValue] ?? normalizedValue;
47
66
  if (definition.renderer === "email" || definition.renderer === "link") {
@@ -20,55 +20,7 @@ export declare function buildPhiChoiceControlOptionFields(editorPlacement?: "ins
20
20
  key: string;
21
21
  type: "collection";
22
22
  label: string;
23
- editorPlacement: "toolbar" | "inspector";
24
- itemKeyField: string;
25
- itemLabelField: string;
26
- defaultItem: {
27
- value: string;
28
- label: string;
29
- };
30
- addLabel: string;
31
- emptyLabel: string;
32
- itemFields: ({
33
- key: string;
34
- type: "icon";
35
- label: string;
36
- required?: undefined;
37
- } | {
38
- key: string;
39
- type: "string";
40
- label: string;
41
- required: true;
42
- } | {
43
- key: string;
44
- type: "string";
45
- label: string;
46
- required?: undefined;
47
- } | {
48
- key: string;
49
- type: "boolean";
50
- label: string;
51
- required?: undefined;
52
- })[];
53
- providerKind?: undefined;
54
- } | {
55
- key: string;
56
- type: "data-provider";
57
- providerKind: "options";
58
- label: string;
59
- editorPlacement?: undefined;
60
- itemKeyField?: undefined;
61
- itemLabelField?: undefined;
62
- defaultItem?: undefined;
63
- addLabel?: undefined;
64
- emptyLabel?: undefined;
65
- itemFields?: undefined;
66
- })[];
67
- export declare const PHI_CHOICE_CONTROL_OPTION_FIELDS: ({
68
- key: string;
69
- type: "collection";
70
- label: string;
71
- editorPlacement: "toolbar" | "inspector";
23
+ editorPlacement: "inspector" | "toolbar";
72
24
  itemKeyField: string;
73
25
  itemLabelField: string;
74
26
  defaultItem: {
@@ -26,7 +26,6 @@ export function buildPhiChoiceControlOptionFields(editorPlacement = "inspector")
26
26
  label: "Options Source",
27
27
  }];
28
28
  }
29
- export const PHI_CHOICE_CONTROL_OPTION_FIELDS = buildPhiChoiceControlOptionFields();
30
29
  export function parsePhiChoiceOptionsConfig(config) {
31
30
  const reader = createPhiConfigReader(config);
32
31
  return {
@@ -1,5 +1,5 @@
1
1
  import { createPhiConfigReader } from "./strict-config-reader";
2
- import { PHI_CHOICE_CONTROL_OPTION_FIELDS, PHI_CHOICE_CONTROL_CONFIG_FIELDS, PHI_CHOICE_CONTROL_VALUE_MODE_FIELD, parsePhiStackChoiceControlConfig, } from "./choice-shared";
2
+ import { buildPhiChoiceControlOptionFields, PHI_CHOICE_CONTROL_CONFIG_FIELDS, PHI_CHOICE_CONTROL_VALUE_MODE_FIELD, parsePhiStackChoiceControlConfig, } from "./choice-shared";
3
3
  import { createPhiCmsWidgetDefinition } from "./helpers";
4
4
  import { PHI_SELECT_CONTROL_SIGNALS } from "../signals/control-signal-capabilities";
5
5
  function parsePhiCmsTabBarWidgetConfig(config) {
@@ -14,7 +14,7 @@ export const PHI_TAB_BAR_WIDGET_DEFINITION = createPhiCmsWidgetDefinition({
14
14
  description: "Reusable tab control that emits runtime state signals and can optionally control stack slots.",
15
15
  category: "navigation",
16
16
  iconFamily: "basic",
17
- slotSizePolicy: "fill-block",
17
+ slotSizePolicy: { configField: "placement", byValue: { left: "fill-block", right: "fill-block" }, otherwise: "fill-inline" },
18
18
  runtimeSignals: {
19
19
  ...PHI_SELECT_CONTROL_SIGNALS,
20
20
  },
@@ -39,7 +39,8 @@ export const PHI_TAB_BAR_WIDGET_DEFINITION = createPhiCmsWidgetDefinition({
39
39
  { value: "right", label: "Right" },
40
40
  ],
41
41
  },
42
- ...PHI_CHOICE_CONTROL_OPTION_FIELDS,
42
+ /* Edited in the scaffold's dialog, as every choice Widget's static options are. */
43
+ ...buildPhiChoiceControlOptionFields("toolbar"),
43
44
  ...PHI_CHOICE_CONTROL_CONFIG_FIELDS,
44
45
  ],
45
46
  parseConfig: parsePhiCmsTabBarWidgetConfig,