@phis/ui 0.5.3 → 0.5.4

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 (144) hide show
  1. package/components/controls/phi-cascader-control.d.ts +9 -1
  2. package/components/controls/phi-cascader-control.js +25 -3
  3. package/components/controls/phi-money-control.d.ts +39 -0
  4. package/components/controls/phi-money-control.js +34 -0
  5. package/components/controls/phi-number-control.d.ts +6 -1
  6. package/components/controls/phi-number-control.js +3 -3
  7. package/components/controls/phi-options-provider.d.ts +7 -0
  8. package/components/controls/phi-options-provider.js +11 -0
  9. package/components/forms/extended-form-field-controls.d.ts +1 -0
  10. package/components/forms/extended-form-field-controls.js +23 -1
  11. package/components/forms/form-descriptor-runtime-client.js +13 -0
  12. package/components/forms/form-provider-contract.d.ts +43 -0
  13. package/components/forms/form-provider-contract.js +40 -0
  14. package/components/forms/money-field.d.ts +27 -0
  15. package/components/forms/money-field.js +78 -0
  16. package/components/forms/shared-form-provider-registry.js +4 -0
  17. package/components/media/phi-media-picker-binding.js +6 -1
  18. package/components/media/phi-site-font-assets.js +6 -1
  19. package/components/motion/phi-sequence-run.d.ts +14 -1
  20. package/components/motion/phi-sequence-run.js +22 -3
  21. package/components/motion/phi-sequence-viewport.js +3 -1
  22. package/components/regions/presets/content-entry-editor-page-tree.js +3 -1
  23. package/components/tables/client/phi-table-binding.js +16 -3
  24. package/components/trees/client/phi-tree-binding.js +6 -2
  25. package/components/widgets/client/shared/phi-collection-view-binding.js +10 -2
  26. package/components/widgets/client/shared/phi-rendered-value.d.ts +9 -1
  27. package/components/widgets/client/shared/phi-rendered-value.js +20 -1
  28. package/components/widgets/config/choice-shared.d.ts +2 -2
  29. package/components/widgets/label-sets/gallery.js +6 -0
  30. package/components/widgets/label-sets/interval.d.ts +4 -0
  31. package/components/widgets/label-sets/interval.js +31 -0
  32. package/components/widgets/label-sets/record.js +6 -1
  33. package/components/widgets/label-sets/slot-upload.d.ts +4 -0
  34. package/components/widgets/label-sets/slot-upload.js +36 -0
  35. package/components/widgets/label-sets/table.js +6 -1
  36. package/components/widgets/label-types/gallery.d.ts +7 -0
  37. package/components/widgets/label-types/gallery.js +6 -0
  38. package/components/widgets/label-types/interval.d.ts +16 -0
  39. package/components/widgets/label-types/interval.js +21 -0
  40. package/components/widgets/label-types/record.d.ts +3 -0
  41. package/components/widgets/label-types/record.js +2 -0
  42. package/components/widgets/label-types/slot-upload.d.ts +24 -0
  43. package/components/widgets/label-types/slot-upload.js +16 -0
  44. package/components/widgets/label-types/table.d.ts +3 -0
  45. package/components/widgets/label-types/table.js +2 -0
  46. package/constants/record-field-kinds.d.ts +1 -1
  47. package/constants/record-field-kinds.js +1 -1
  48. package/constants/runtime-module-ownership.js +1 -0
  49. package/controls.d.ts +7 -0
  50. package/controls.js +4 -0
  51. package/helpers/cms-dialog.d.ts +39 -3
  52. package/helpers/cms-dialog.js +46 -4
  53. package/helpers/cms-page-catalog.d.ts +8 -0
  54. package/helpers/cms-page-catalog.js +18 -2
  55. package/helpers/cms-preset-nodes.d.ts +13 -3
  56. package/helpers/cms-preset-nodes.js +3 -2
  57. package/helpers/money-amount.d.ts +48 -0
  58. package/helpers/money-amount.js +131 -0
  59. package/helpers/page-layout-check.js +15 -2
  60. package/helpers/record-fields.d.ts +18 -5
  61. package/helpers/record-fields.js +38 -13
  62. package/module-records.d.ts +6 -3
  63. package/module-records.js +4 -2
  64. package/package.json +2 -2
  65. package/plugins/runtime-modules/accounting/module.d.ts +1 -1
  66. package/plugins/runtime-modules/app/module.d.ts +1 -1
  67. package/plugins/runtime-modules/asset/services/collection.js +1 -0
  68. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -2
  69. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +3 -0
  70. package/plugins/runtime-modules/builder/offered-page-catalog.js +3 -3
  71. package/plugins/runtime-modules/builder/options-providers.js +7 -0
  72. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -3
  73. package/plugins/runtime-modules/contracts.d.ts +1 -1
  74. package/plugins/runtime-modules/core/definition.d.ts +43 -0
  75. package/plugins/runtime-modules/core/form-providers.d.ts +43 -0
  76. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +6 -3
  77. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +6 -5
  78. package/plugins/runtime-modules/core/widgets/breadcrumb/plugin.js +1 -1
  79. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +9 -1
  80. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +29 -3
  81. package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
  82. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +3 -3
  83. package/plugins/runtime-modules/core/widgets/cascader/client.js +1 -1
  84. package/plugins/runtime-modules/core/widgets/cascader/config.d.ts +8 -2
  85. package/plugins/runtime-modules/core/widgets/cascader/config.js +22 -0
  86. package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +1 -1
  87. package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
  88. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
  89. package/plugins/runtime-modules/core/widgets/gallery/authoring.js +12 -3
  90. package/plugins/runtime-modules/core/widgets/gallery/client.js +10 -1
  91. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -1
  92. package/plugins/runtime-modules/core/widgets/gallery/config.js +8 -0
  93. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +1 -1
  94. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
  95. package/plugins/runtime-modules/core/widgets/multi-select/config.d.ts +1 -1
  96. package/plugins/runtime-modules/core/widgets/record/client.js +8 -2
  97. package/plugins/runtime-modules/core/widgets/record/config.js +4 -0
  98. package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
  99. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +1 -1
  100. package/plugins/runtime-modules/core/widgets/select-box/config.d.ts +1 -1
  101. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -1
  102. package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +1 -1
  103. package/plugins/runtime-modules/core/widgets/slot-upload/authoring.js +2 -1
  104. package/plugins/runtime-modules/core/widgets/slot-upload/client.d.ts +3 -1
  105. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +45 -24
  106. package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +12 -4
  107. package/plugins/runtime-modules/core/widgets/slot-upload/config.js +18 -1
  108. package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +4 -2
  109. package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +9 -3
  110. package/plugins/runtime-modules/core/widgets/slot-upload/server.js +17 -3
  111. package/plugins/runtime-modules/core/widgets/steps/config.d.ts +1 -1
  112. package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
  113. package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
  114. package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
  115. package/plugins/runtime-modules/descriptor-compiler.d.ts +11 -1
  116. package/plugins/runtime-modules/descriptor-compiler.js +49 -8
  117. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  118. package/plugins/runtime-modules/groups/forms.d.ts +18 -0
  119. package/plugins/runtime-modules/groups/forms.js +2 -2
  120. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +6 -4
  121. package/plugins/runtime-modules/public/module.d.ts +1 -1
  122. package/plugins/runtime-modules/resolver.js +5 -0
  123. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
  124. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +4 -2
  125. package/plugins/runtime-modules/user-management/controller/client.js +6 -1
  126. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +3 -3
  127. package/runtime-render-client.d.ts +1 -1
  128. package/runtime-render-client.js +2 -1
  129. package/server-helpers/cms-page-record.d.ts +2 -2
  130. package/server-helpers/cms-page-record.js +15 -5
  131. package/server-helpers/record-fields.d.ts +1 -1
  132. package/server-helpers/record-fields.js +1 -2
  133. package/server-helpers/record-samples.d.ts +4 -4
  134. package/server-helpers/record-samples.js +10 -2
  135. package/types/cms-module-descriptors.d.ts +3 -0
  136. package/types/cms-plugins.d.ts +8 -0
  137. package/types/collection-provider.d.ts +7 -0
  138. package/types/core-widget-placements.d.ts +32 -0
  139. package/types/record-provider.d.ts +19 -3
  140. package/types/table-widget.d.ts +33 -1
  141. package/types/table-widget.js +1 -0
  142. package/types/tree-widget.d.ts +7 -0
  143. package/types/widget-runtime.d.ts +1 -1
  144. package/types.d.ts +1 -0
@@ -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;
@@ -11,7 +11,7 @@ import { PHI_SIGNAL_VALUE_SCHEMAS, createPhiSignalAddress, } from "../../../type
11
11
  import { PHI_CONTENT_ENTRY_SOURCE_LOCALE_PLACEHOLDER_CONFIG_KEY } from "../../forms/content-entry-forms";
12
12
  import { PHI_CONTENT_ENTRY_CURATION_NONE_CONFIG_KEYS } from "../../forms/content-entry-curation-config";
13
13
  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";
14
+ import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH_SINGLE_COLUMN, } from "../../../helpers/cms-dialog";
15
15
  /**
16
16
  * The node keys of an editor Page. They make its instance ids together with the Module and the preset
17
17
  * key, so they are part of every stored placement and do not change.
@@ -88,6 +88,8 @@ function buildEntryDialogNodes(nodes, input) {
88
88
  label: `${input.routePrefix} ${input.key} modal`,
89
89
  config: {
90
90
  title: input.title,
91
+ // Every Form of an entry is one column (helpers/cms-dialog.ts).
92
+ width: PHI_DIALOG_WIDTH_SINGLE_COLUMN,
91
93
  mountPolicy: "remount",
92
94
  /*
93
95
  * `immediate`: there is nobody to ask. `request` exists so a Controller can refuse while a save
@@ -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,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,7 +20,7 @@ export declare function buildPhiChoiceControlOptionFields(editorPlacement?: "ins
20
20
  key: string;
21
21
  type: "collection";
22
22
  label: string;
23
- editorPlacement: "toolbar" | "inspector";
23
+ editorPlacement: "inspector" | "toolbar";
24
24
  itemKeyField: string;
25
25
  itemLabelField: string;
26
26
  defaultItem: {
@@ -68,7 +68,7 @@ export declare const PHI_CHOICE_CONTROL_OPTION_FIELDS: ({
68
68
  key: string;
69
69
  type: "collection";
70
70
  label: string;
71
- editorPlacement: "toolbar" | "inspector";
71
+ editorPlacement: "inspector" | "toolbar";
72
72
  itemKeyField: string;
73
73
  itemLabelField: string;
74
74
  defaultItem: {
@@ -14,6 +14,9 @@ const PHI_GALLERY_WIDGET_LABEL_SET = definePhiLabelSet({
14
14
  region: PHI_GALLERY_WIDGET_DEFAULT_LABELS.region,
15
15
  pages: definePhiMessageLabel(PHI_GALLERY_WIDGET_DEFAULT_LABELS.pages),
16
16
  unavailable: definePhiMessageLabel(PHI_GALLERY_WIDGET_DEFAULT_LABELS.unavailable),
17
+ canvas_folder: definePhiMessageLabel(PHI_GALLERY_WIDGET_DEFAULT_LABELS.canvasFolder),
18
+ canvas_no_folder: definePhiMessageLabel(PHI_GALLERY_WIDGET_DEFAULT_LABELS.canvasNoFolder),
19
+ canvas_record_field: definePhiMessageLabel(PHI_GALLERY_WIDGET_DEFAULT_LABELS.canvasRecordField),
17
20
  },
18
21
  });
19
22
  export async function getPhiGalleryWidgetLabels(options) {
@@ -27,5 +30,8 @@ export async function getPhiGalleryWidgetLabels(options) {
27
30
  region: labels.region,
28
31
  pages: labels.pages,
29
32
  unavailable: labels.unavailable,
33
+ canvasFolder: labels.canvas_folder,
34
+ canvasNoFolder: labels.canvas_no_folder,
35
+ canvasRecordField: labels.canvas_record_field,
30
36
  };
31
37
  }
@@ -0,0 +1,4 @@
1
+ import "server-only";
2
+ import { type PhiGlobalTranslatorOptions } from "../../../gateway/tr";
3
+ import { type PhiIntervalLabels } from "../label-types/interval";
4
+ export declare function getPhiIntervalLabels(options: PhiGlobalTranslatorOptions): Promise<PhiIntervalLabels>;
@@ -0,0 +1,31 @@
1
+ import "server-only";
2
+ import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
3
+ import { definePhiLabelSet, getPhiLabelSet } from "../../../gateway/label-set";
4
+ import { PHI_INTERVAL_DEFAULT_LABELS } from "../label-types/interval";
5
+ /**
6
+ * The words of the `interval` value renderer. One set, not one per Widget, so that a Table and a record
7
+ * of the same rows say "every 3 months" the same way and a translator says it once.
8
+ */
9
+ const PHI_INTERVAL_LABEL_SET = definePhiLabelSet({
10
+ key: "value:interval",
11
+ ctx: PHI_TR_CTX_WEB_UI_LABEL,
12
+ labels: {
13
+ day_one: PHI_INTERVAL_DEFAULT_LABELS.day.one,
14
+ day_many: PHI_INTERVAL_DEFAULT_LABELS.day.many,
15
+ week_one: PHI_INTERVAL_DEFAULT_LABELS.week.one,
16
+ week_many: PHI_INTERVAL_DEFAULT_LABELS.week.many,
17
+ month_one: PHI_INTERVAL_DEFAULT_LABELS.month.one,
18
+ month_many: PHI_INTERVAL_DEFAULT_LABELS.month.many,
19
+ year_one: PHI_INTERVAL_DEFAULT_LABELS.year.one,
20
+ year_many: PHI_INTERVAL_DEFAULT_LABELS.year.many,
21
+ },
22
+ });
23
+ export async function getPhiIntervalLabels(options) {
24
+ const labels = await getPhiLabelSet(options, PHI_INTERVAL_LABEL_SET);
25
+ return {
26
+ day: { one: labels.day_one, many: labels.day_many },
27
+ week: { one: labels.week_one, many: labels.week_many },
28
+ month: { one: labels.month_one, many: labels.month_many },
29
+ year: { one: labels.year_one, many: labels.year_many },
30
+ };
31
+ }
@@ -1,6 +1,7 @@
1
1
  import "server-only";
2
2
  import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
3
3
  import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
4
+ import { getPhiIntervalLabels } from "./interval";
4
5
  const PHI_RECORD_WIDGET_LABEL_SET = definePhiLabelSet({
5
6
  key: "widget:record",
6
7
  ctx: PHI_TR_CTX_WEB_UI_LABEL,
@@ -13,11 +14,15 @@ const PHI_RECORD_WIDGET_LABEL_SET = definePhiLabelSet({
13
14
  },
14
15
  });
15
16
  export async function getPhiRecordWidgetLabels(options) {
16
- const labels = await getPhiLabelSet(options, PHI_RECORD_WIDGET_LABEL_SET);
17
+ const [labels, interval] = await Promise.all([
18
+ getPhiLabelSet(options, PHI_RECORD_WIDGET_LABEL_SET),
19
+ getPhiIntervalLabels(options),
20
+ ]);
17
21
  return {
18
22
  empty: labels.empty,
19
23
  missingBinding: labels.missing_binding,
20
24
  recordReadUnsupported: labels.record_read_unsupported,
21
25
  loadFailed: labels.load_failed,
26
+ interval,
22
27
  };
23
28
  }
@@ -0,0 +1,4 @@
1
+ import "server-only";
2
+ import { type PhiGlobalTranslatorOptions } from "../../../gateway/tr";
3
+ import { type PhiSlotUploadWidgetLabels } from "../label-types/slot-upload";
4
+ export declare function getPhiSlotUploadWidgetLabels(options: PhiGlobalTranslatorOptions): Promise<PhiSlotUploadWidgetLabels>;
@@ -0,0 +1,36 @@
1
+ import "server-only";
2
+ import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
3
+ import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
4
+ import { PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS, } from "../label-types/slot-upload";
5
+ const DEFAULTS = PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS;
6
+ const PHI_SLOT_UPLOAD_WIDGET_LABEL_SET = definePhiLabelSet({
7
+ key: "widget:slot-upload",
8
+ ctx: PHI_TR_CTX_WEB_UI_LABEL,
9
+ labels: {
10
+ choose: DEFAULTS.choose,
11
+ remove: DEFAULTS.remove,
12
+ unconfigured: definePhiMessageLabel(DEFAULTS.unconfigured),
13
+ no_row: definePhiMessageLabel(DEFAULTS.noRow),
14
+ empty: definePhiMessageLabel(DEFAULTS.empty),
15
+ file_title: definePhiMessageLabel(DEFAULTS.fileTitle),
16
+ slot_missing: definePhiMessageLabel(DEFAULTS.slotMissing),
17
+ server_answered: definePhiMessageLabel(DEFAULTS.serverAnswered),
18
+ unreachable: definePhiMessageLabel(DEFAULTS.unreachable),
19
+ remove_failed: definePhiMessageLabel(DEFAULTS.removeFailed),
20
+ },
21
+ });
22
+ export async function getPhiSlotUploadWidgetLabels(options) {
23
+ const labels = await getPhiLabelSet(options, PHI_SLOT_UPLOAD_WIDGET_LABEL_SET);
24
+ return {
25
+ unconfigured: labels.unconfigured,
26
+ noRow: labels.no_row,
27
+ choose: labels.choose,
28
+ empty: labels.empty,
29
+ remove: labels.remove,
30
+ fileTitle: labels.file_title,
31
+ slotMissing: labels.slot_missing,
32
+ serverAnswered: labels.server_answered,
33
+ unreachable: labels.unreachable,
34
+ removeFailed: labels.remove_failed,
35
+ };
36
+ }
@@ -1,6 +1,7 @@
1
1
  import "server-only";
2
2
  import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
3
3
  import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
4
+ import { getPhiIntervalLabels } from "./interval";
4
5
  const PHI_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
5
6
  key: "widget:table",
6
7
  ctx: PHI_TR_CTX_WEB_UI_LABEL,
@@ -27,7 +28,10 @@ const PHI_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
27
28
  },
28
29
  });
29
30
  export async function getPhiTableWidgetLabels(options) {
30
- const labels = await getPhiLabelSet(options, PHI_TABLE_WIDGET_LABEL_SET);
31
+ const [labels, interval] = await Promise.all([
32
+ getPhiLabelSet(options, PHI_TABLE_WIDGET_LABEL_SET),
33
+ getPhiIntervalLabels(options),
34
+ ]);
31
35
  return {
32
36
  search: labels.search,
33
37
  reset: labels.reset,
@@ -47,5 +51,6 @@ export async function getPhiTableWidgetLabels(options) {
47
51
  dragRow: labels.drag_row,
48
52
  moveRowUp: labels.move_row_up,
49
53
  moveRowDown: labels.move_row_down,
54
+ interval,
50
55
  };
51
56
  }
@@ -1,5 +1,12 @@
1
1
  import type { PhiSequenceControlLabels } from "./sequence";
2
2
  export type PhiGalleryWidgetLabels = PhiSequenceControlLabels & {
3
3
  unavailable: string;
4
+ /** The Builder canvas's hint under a Gallery whose Folder is chosen. */
5
+ canvasFolder: string;
6
+ /** The Builder canvas's hint under a Gallery whose Folder is not chosen yet. */
7
+ canvasNoFolder: string;
8
+ /** The Builder canvas's hint under a Gallery bound to a field of the page record, `%1` the field. */
9
+ canvasRecordField: string;
4
10
  };
5
11
  export declare const PHI_GALLERY_WIDGET_DEFAULT_LABELS: PhiGalleryWidgetLabels;
12
+ export declare function formatPhiGalleryWidgetLabel(template: string, value: string): string;
@@ -7,4 +7,10 @@ export const PHI_GALLERY_WIDGET_DEFAULT_LABELS = {
7
7
  region: "Pictures",
8
8
  pages: "Choose pictures",
9
9
  unavailable: "The pictures could not be read.",
10
+ canvasFolder: "The public pictures of the chosen media folder, read when the page is drawn.",
11
+ canvasNoFolder: "No folder chosen yet. Pick one in the inspector; its public pictures are read when the page is drawn.",
12
+ canvasRecordField: 'The pictures of the page record\'s field "%1", read when the page is drawn.',
10
13
  };
14
+ export function formatPhiGalleryWidgetLabel(template, value) {
15
+ return template.replace("%1", value);
16
+ }
@@ -0,0 +1,16 @@
1
+ import type { PhiIntervalUnit, PhiIntervalValue } from "../../../types/table-widget";
2
+ /**
3
+ * How Core says a period, per unit: for one of it ("per month") and for several, with `%1` for the
4
+ * count ("every %1 months"). Words from a Label Set rather than `Intl`'s unit names, because `Intl`
5
+ * says "3 months" -- a length -- where a price needs "every 3 months", and a translator can reach a
6
+ * Label Set where nobody can reach `Intl`.
7
+ */
8
+ export type PhiIntervalLabels = Readonly<Record<PhiIntervalUnit, {
9
+ one: string;
10
+ many: string;
11
+ }>>;
12
+ export declare const PHI_INTERVAL_DEFAULT_LABELS: PhiIntervalLabels;
13
+ /** `value` as a period, or `null` where it is not one: a known unit and a whole count of one or more. */
14
+ export declare function readPhiIntervalValue(value: unknown): PhiIntervalValue | null;
15
+ /** A period in Core's words: `{ unit: "month", count: 1 }` is "per month", `count: 3` "every 3 months". */
16
+ export declare function formatPhiInterval(value: PhiIntervalValue, labels: PhiIntervalLabels): string;
@@ -0,0 +1,21 @@
1
+ export const PHI_INTERVAL_DEFAULT_LABELS = {
2
+ day: { one: "per day", many: "every %1 days" },
3
+ week: { one: "per week", many: "every %1 weeks" },
4
+ month: { one: "per month", many: "every %1 months" },
5
+ year: { one: "per year", many: "every %1 years" },
6
+ };
7
+ const PHI_INTERVAL_UNITS = ["day", "week", "month", "year"];
8
+ /** `value` as a period, or `null` where it is not one: a known unit and a whole count of one or more. */
9
+ export function readPhiIntervalValue(value) {
10
+ if (typeof value !== "object" || value === null || Array.isArray(value))
11
+ return null;
12
+ const { unit, count } = value;
13
+ return typeof unit === "string" && PHI_INTERVAL_UNITS.includes(unit) && Number.isSafeInteger(count) && count >= 1
14
+ ? { unit: unit, count: count }
15
+ : null;
16
+ }
17
+ /** A period in Core's words: `{ unit: "month", count: 1 }` is "per month", `count: 3` "every 3 months". */
18
+ export function formatPhiInterval(value, labels) {
19
+ const words = labels[value.unit];
20
+ return value.count === 1 ? words.one : words.many.replace("%1", String(value.count));
21
+ }
@@ -1,8 +1,11 @@
1
+ import { type PhiIntervalLabels } from "./interval";
1
2
  export type PhiRecordWidgetLabels = {
2
3
  empty: string;
3
4
  missingBinding: string;
4
5
  recordReadUnsupported: string;
5
6
  loadFailed: string;
7
+ /** The words of the `interval` renderer, from their own Label Set. */
8
+ interval: PhiIntervalLabels;
6
9
  };
7
10
  export declare const PHI_RECORD_WIDGET_DEFAULT_LABELS: PhiRecordWidgetLabels;
8
11
  export declare function formatPhiRecordWidgetLabel(template: string, value: string | number): string;
@@ -1,8 +1,10 @@
1
+ import { PHI_INTERVAL_DEFAULT_LABELS } from "./interval";
1
2
  export const PHI_RECORD_WIDGET_DEFAULT_LABELS = {
2
3
  empty: "Open a row to read it here.",
3
4
  missingBinding: "Record provider binding is missing.",
4
5
  recordReadUnsupported: 'Table resource "%1" does not offer single records.',
5
6
  loadFailed: "The record could not be loaded.",
7
+ interval: PHI_INTERVAL_DEFAULT_LABELS,
6
8
  };
7
9
  export function formatPhiRecordWidgetLabel(template, value) {
8
10
  return template.replace("%1", String(value));