@phis/ui 0.5.6 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/components/controls/phi-amount-list-control.d.ts +69 -0
  2. package/components/controls/phi-amount-list-control.js +15 -0
  3. package/components/controls/phi-background-control.d.ts +9 -1
  4. package/components/controls/phi-background-control.js +66 -20
  5. package/components/controls/phi-button-control.js +16 -2
  6. package/components/root/phi-root-layout.d.ts +1 -0
  7. package/components/root/phi-root-layout.js +1 -0
  8. package/components/widgets/config/background-pattern-live.d.ts +25 -0
  9. package/components/widgets/config/background-pattern-live.js +50 -0
  10. package/components/widgets/shared/markdown-body-client.d.ts +4 -1
  11. package/components/widgets/shared/markdown-body-client.js +3 -3
  12. package/components/widgets/shared/markdown-image-vocabulary.d.ts +19 -6
  13. package/components/widgets/shared/markdown-image-vocabulary.js +34 -9
  14. package/components/widgets/shared/markdown-render.d.ts +2 -1
  15. package/components/widgets/shared/markdown-render.js +4 -1
  16. package/constants/media.d.ts +2 -0
  17. package/constants/media.js +2 -0
  18. package/controls.d.ts +2 -0
  19. package/controls.js +1 -0
  20. package/gateway/signet-route.d.ts +24 -0
  21. package/gateway/signet-route.js +102 -0
  22. package/gateway/site-proxy.js +14 -7
  23. package/helpers/phi-metadata.d.ts +8 -6
  24. package/helpers/phi-metadata.js +9 -2
  25. package/helpers/phi-signet-head.d.ts +25 -0
  26. package/helpers/phi-signet-head.js +41 -0
  27. package/helpers/phi-signet-paths.d.ts +16 -0
  28. package/helpers/phi-signet-paths.js +19 -0
  29. package/helpers/phi-signet.d.ts +28 -0
  30. package/helpers/phi-signet.js +59 -0
  31. package/next/root-route.js +7 -4
  32. package/next/site-proxy.js +16 -0
  33. package/package.json +3 -3
  34. package/plugins/runtime-modules/area-definitions.d.ts +24 -3
  35. package/plugins/runtime-modules/area-definitions.js +11 -3
  36. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -1
  37. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +8 -0
  38. package/plugins/runtime-modules/core/widgets/card/config.d.ts +10 -0
  39. package/plugins/runtime-modules/core/widgets/card/config.js +1 -0
  40. package/plugins/runtime-modules/core/widgets/description/config.d.ts +10 -0
  41. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +10 -0
  42. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +10 -0
  43. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -1
  44. package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -1
  45. package/plugins/runtime-modules/core/widgets/result/config.d.ts +10 -0
  46. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +10 -0
  47. package/plugins/runtime-modules/core/widgets/table/config.d.ts +34 -0
  48. package/plugins/runtime-modules/public/presets.d.ts +12 -0
  49. package/plugins/runtime-modules/public/presets.js +10 -0
  50. package/plugins/runtime-modules/public/server.js +1 -1
  51. package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.d.ts +4 -0
  52. package/plugins/runtime-modules/public/trees/phi-default-pub-privacy-page-tree.js +66 -0
  53. package/plugins/runtime-modules/public-base-page-references.d.ts +2 -1
  54. package/plugins/runtime-modules/public-base-page-references.js +2 -1
  55. package/plugins/runtime-modules/theme/controller/runtime.js +7 -2
  56. package/plugins/runtime-modules/theme/materialize-images.d.ts +16 -0
  57. package/plugins/runtime-modules/theme/materialize-images.js +37 -0
  58. package/styles/amount-list.css +142 -0
  59. package/styles/controls.css +186 -12
  60. package/styles/gradients.css +21 -20
  61. package/theme/phi-theme-blocks.d.ts +7 -6
  62. package/theme/phi-theme-composition.d.ts +19 -1
  63. package/theme/phi-theme-composition.js +15 -0
  64. package/theme/phi-theme-signet.d.ts +25 -0
  65. package/theme/phi-theme-signet.js +17 -0
  66. package/types/cms-plugins.d.ts +8 -0
  67. package/types/core-widget-placements.d.ts +2 -1
  68. package/types/site-theme.d.ts +17 -0
@@ -0,0 +1,69 @@
1
+ import type { ReactNode } from "react";
2
+ import type { PhiControlSize } from "../../types/control";
3
+ /**
4
+ * Lines and sums whose amounts stand in one column: a cart, a checkout, an order, a subscription's
5
+ * sign-up, a receipt.
6
+ *
7
+ * **It knows nothing about money.** An amount is text somebody else has already formatted, in whatever
8
+ * currency and locale the surface speaks. What this Control owns is the one thing a stack of rows cannot
9
+ * give it: every amount -- the items' and the totals' -- is in the same grid column, so their right edges
10
+ * are the same line and, with tabular digits, the figures stand digit under digit. Separate flex rows
11
+ * cannot do that; each one sizes its amount to itself.
12
+ *
13
+ * **One grid, rows through `subgrid`.** The list is a four-column grid -- media, text, controls, amount --
14
+ * and an item row and a total row are subgrids of it, so the amount column is sized by the widest amount
15
+ * of the whole list. `display: contents` would also share the columns, but it drops the row's box: no
16
+ * divider on a total, no role on a flattened element in some browsers. Rows are boxes, so `subgrid`.
17
+ *
18
+ * **Narrow is decided by the list's own width**, not the viewport's (`@container`, below 30rem): the item
19
+ * becomes two lines -- media and text, then controls and amount -- and the amount stays in the same
20
+ * column. Totals keep label left and amount right at every width. The container query needs
21
+ * `container-type: inline-size`, so the list takes the width its parent gives it (`width: 100%`) and has
22
+ * none of its own: in a shrink-to-fit parent -- an `inline-flex` or `fit-content` box -- it collapses to 0.
23
+ *
24
+ * **A list, with the sums as a description list.** The items are a `ul`: each is one thing with a name,
25
+ * free controls and an amount, and a table would need column headers that nothing here has (the
26
+ * controls cell has no name, the text cell is a title and a line). The sums are label/amount pairs, which
27
+ * is what `dl` says. The `ul` carries `role="list"` because list-style resets drop the role in Safari.
28
+ *
29
+ * **It is display, with no data source.** It sorts nothing, pages nothing and edits nothing; the
30
+ * quantity field or the remove button is whatever the surface passes as `controls`. It is not the Table
31
+ * Widget ([TABLES.md](../../TABLES.md)). It renders on the server: no state, no Ant Design, no theme hook;
32
+ * the rules are `styles/amount-list.css`.
33
+ */
34
+ export type PhiAmountListItem = {
35
+ key: string;
36
+ /** The name of the line. It wraps; it is never cut off. */
37
+ title: ReactNode;
38
+ /** A second, quieter line under the title: "2 x 12,00 CHF", "per month". */
39
+ description?: ReactNode;
40
+ /** A small picture or icon before the title. */
41
+ media?: ReactNode;
42
+ /** Whatever the line can be operated with: a quantity field, a remove button. */
43
+ controls?: ReactNode;
44
+ /** The amount, already formatted. */
45
+ amount: ReactNode;
46
+ /** Quiet, under the amount: "incl. VAT". */
47
+ amountNote?: ReactNode;
48
+ };
49
+ export type PhiAmountListTotal = {
50
+ key: string;
51
+ label: ReactNode;
52
+ /** The amount, already formatted. */
53
+ amount: ReactNode;
54
+ /** Quiet, under the label. */
55
+ note?: ReactNode;
56
+ /** `strong` is for the line that is the answer: the grand total. */
57
+ emphasis?: "normal" | "strong";
58
+ /** A rule above this line, in the Theme's line colour. */
59
+ divided?: boolean;
60
+ };
61
+ export type PhiAmountListControlProps = {
62
+ items: readonly PhiAmountListItem[];
63
+ totals?: readonly PhiAmountListTotal[];
64
+ size?: PhiControlSize;
65
+ /** Stands in place of the list when there are no items and no totals. */
66
+ emptyText?: ReactNode;
67
+ ariaLabel?: string;
68
+ };
69
+ export declare function PhiAmountListControl({ items, totals, size, emptyText, ariaLabel, }: PhiAmountListControlProps): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function PhiAmountListControl({ items, totals, size = "medium", emptyText, ariaLabel, }) {
3
+ const hasTotals = totals != null && totals.length > 0;
4
+ if (items.length === 0 && !hasTotals) {
5
+ return emptyText != null ? _jsx("div", { className: "phi-amount-list__empty", children: emptyText }) : null;
6
+ }
7
+ return (_jsxs("div", { className: `phi-amount-list phi-amount-list--${size}`, role: ariaLabel ? "group" : undefined, "aria-label": ariaLabel, children: [items.length > 0 ? (_jsx("ul", { className: "phi-amount-list__items", role: "list", children: items.map((item) => (_jsxs("li", { className: "phi-amount-list__item", role: "listitem", children: [item.media != null ? _jsx("div", { className: "phi-amount-list__media", children: item.media }) : null, _jsxs("div", { className: "phi-amount-list__text", children: [_jsx("div", { className: "phi-amount-list__title", children: item.title }), item.description != null ? (_jsx("div", { className: "phi-amount-list__description", children: item.description })) : null] }), item.controls != null ? _jsx("div", { className: "phi-amount-list__controls", children: item.controls }) : null, _jsxs("div", { className: "phi-amount-list__amount", children: [_jsx("div", { children: item.amount }), item.amountNote != null ? _jsx("div", { className: "phi-amount-list__note", children: item.amountNote }) : null] })] }, item.key))) })) : null, hasTotals ? (_jsx("dl", { className: "phi-amount-list__totals", children: totals.map((total) => {
8
+ const className = [
9
+ "phi-amount-list__total",
10
+ total.emphasis === "strong" ? "phi-amount-list__total--strong" : null,
11
+ total.divided ? "phi-amount-list__total--divided" : null,
12
+ ].filter(Boolean).join(" ");
13
+ return (_jsxs("div", { className: className, children: [_jsxs("dt", { className: "phi-amount-list__label", children: [_jsx("span", { children: total.label }), total.note != null ? _jsx("span", { className: "phi-amount-list__note", children: total.note }) : null] }), _jsx("dd", { className: "phi-amount-list__amount", children: total.amount })] }, total.key));
14
+ }) })) : null] }));
15
+ }
@@ -59,6 +59,14 @@ export type PhiBackgroundControlProps = {
59
59
  * over it, so it offers none; absent is offered.
60
60
  */
61
61
  overlay?: boolean;
62
+ /**
63
+ * Whether the Control edits the Base, the counterpart of `overlay`; absent is offered. With `false` it
64
+ * shows the Overlay section alone: no Base kind, colour, gradient, image, position, motion or Filter,
65
+ * no divider above the Overlay, and no preview (an Overlay drawn over nothing shows nothing worth
66
+ * looking at). The value's Base is passed through untouched, so the host gives it `none`. `base={false}`
67
+ * with `overlay={false}` leaves nothing to edit and renders nothing.
68
+ */
69
+ base?: boolean;
62
70
  renderMediaPicker?: (props: {
63
71
  purpose: "preview" | "field";
64
72
  value?: number | null;
@@ -80,4 +88,4 @@ export type PhiBackgroundControlProps = {
80
88
  editTransaction?: PhiBackgroundEditTransaction;
81
89
  onChange?: (value: PhiCmsBackgroundWidgetConfig) => void;
82
90
  };
83
- export declare function PhiBackgroundControl({ value, config, disabled, mode, labels, colorPickerLabels, colorPickerPlacement, motionModes, filters, imageSourceKinds, baseKinds, overlay: overlayOffered, renderMediaPicker, editTransaction, onChange, }: PhiBackgroundControlProps): import("react").JSX.Element;
91
+ export declare function PhiBackgroundControl({ value, config, disabled, mode, labels, colorPickerLabels, colorPickerPlacement, motionModes, filters, imageSourceKinds, baseKinds, overlay: overlayOffered, base: baseOffered, renderMediaPicker, editTransaction, onChange, }: PhiBackgroundControlProps): import("react").JSX.Element | null;
@@ -6,7 +6,7 @@ import { PhiFlexControl } from "./phi-flex-control";
6
6
  import { PHI_BACKGROUND_BASE_KINDS, PHI_BACKGROUND_IMAGE_SOURCE_KINDS, PHI_BACKGROUND_MOTION_MODES, PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY, PHI_BACKGROUND_PARALLAX_DEFAULT_STRENGTH, normalizePhiBackgroundWidgetConfig, phiBackgroundDirectionToDegrees, phiBackgroundSupportsFilter, readPhiBackgroundGradientCss, readPhiBackgroundPatternInkFromCss, resolvePhiBackgroundParallaxDefaultStrength, resolvePhiBackgroundWidgetStyle, serializePhiBackgroundBaseCss, serializePhiBackgroundPatternInkCss, } from "../widgets/config/background";
7
7
  import { PHI_CORE_BACKGROUND_PATTERN_PROVIDERS, resolvePhiBackgroundPatternDefaultValues, resolvePhiBackgroundPatternProvider, } from "../widgets/config/background-pattern-authoring";
8
8
  import { PHI_DEFAULT_BACKGROUND_PATTERN_KEY, } from "../widgets/config/background-pattern-contract";
9
- import { PHI_BACKGROUND_COLOR_OVERLAY_DEFAULT_INK, PHI_BACKGROUND_PATTERN_DEFAULT_INK, resolvePhiBackgroundPatternLiveLayer, } from "../widgets/config/background-pattern-live";
9
+ import { mergePhiBackgroundPatternInkEdit, resolvePhiBackgroundOverlayInk, switchPhiBackgroundPatternInkKind, withPhiBackgroundPatternInkDirection, resolvePhiBackgroundPatternLiveLayer, } from "../widgets/config/background-pattern-live";
10
10
  import { PhiImageAssetVariantKeyName } from "../../constants/media";
11
11
  import { normalizeMediaFocalRect } from "../media/focal-rect";
12
12
  import { PHI_BACKGROUND_WIDGET_DEFAULT_LABELS, } from "../widgets/label-types/background";
@@ -61,7 +61,7 @@ function toPickerValue(background) {
61
61
  function resolveStoredSolidColor(color) {
62
62
  return color;
63
63
  }
64
- export function PhiBackgroundControl({ value, config, disabled = false, mode = "control", labels = PHI_BACKGROUND_WIDGET_DEFAULT_LABELS, colorPickerLabels = PHI_COLOR_PICKER_DEFAULT_LABELS, colorPickerPlacement, motionModes = PHI_BACKGROUND_MOTION_MODES, filters = PHI_BACKGROUND_FILTERS, imageSourceKinds = PHI_BACKGROUND_IMAGE_SOURCE_KINDS, baseKinds = PHI_BACKGROUND_BASE_KINDS, overlay: overlayOffered = true, renderMediaPicker, editTransaction, onChange, }) {
64
+ export function PhiBackgroundControl({ value, config, disabled = false, mode = "control", labels = PHI_BACKGROUND_WIDGET_DEFAULT_LABELS, colorPickerLabels = PHI_COLOR_PICKER_DEFAULT_LABELS, colorPickerPlacement, motionModes = PHI_BACKGROUND_MOTION_MODES, filters = PHI_BACKGROUND_FILTERS, imageSourceKinds = PHI_BACKGROUND_IMAGE_SOURCE_KINDS, baseKinds = PHI_BACKGROUND_BASE_KINDS, overlay: overlayOffered = true, base: baseOffered = true, renderMediaPicker, editTransaction, onChange, }) {
65
65
  const { token } = theme.useToken();
66
66
  // A Theme swatch stores its role, so a ground picked from the Theme follows it and the mode.
67
67
  const colorPickerPresets = usePhiColorControlPresets({ labels: colorPickerLabels, storeThemeRoles: true });
@@ -113,6 +113,8 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
113
113
  }, [currentValue]);
114
114
  const lastColorBaseRef = useRef(currentValue.base.kind === "color" ? currentValue.base : null);
115
115
  const lastGradientBaseRef = useRef(currentValue.base.kind === "gradient" ? currentValue.base : null);
116
+ const lastColorInkRef = useRef(null);
117
+ const lastGradientInkRef = useRef(null);
116
118
  const lastImageBaseRef = useRef(currentValue.base.kind === "image" ? currentValue.base : null);
117
119
  // `strength` means something different in each travel mode, so each one keeps its own dial.
118
120
  const rememberedStrength = useRef(currentValue.motion?.mode === "parallax" && currentValue.motion.strength != null
@@ -393,6 +395,43 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
393
395
  lastImageBaseRef.current = currentValue.base;
394
396
  }
395
397
  }
398
+ const overlayInk = currentValue.overlay && currentValue.overlay.kind !== "noise"
399
+ ? resolvePhiBackgroundOverlayInk(currentValue.overlay)
400
+ : null;
401
+ const overlayInkKindOptions = [
402
+ { value: "color", label: labels.base.color },
403
+ { value: "gradient", label: labels.base.gradient },
404
+ ];
405
+ useEffect(() => {
406
+ if (overlayInk?.kind === "color")
407
+ lastColorInkRef.current = overlayInk;
408
+ if (overlayInk?.kind === "gradient")
409
+ lastGradientInkRef.current = overlayInk;
410
+ }, [overlayInk]);
411
+ function switchOverlayInkKind(kind) {
412
+ const overlay = currentValue.overlay;
413
+ if (!overlay || overlay.kind === "noise" || !overlayInk || overlayInk.kind === kind)
414
+ return;
415
+ // Remember what is being left, so the way back restores it rather than deriving it again.
416
+ if (overlayInk.kind === "color")
417
+ lastColorInkRef.current = overlayInk;
418
+ else
419
+ lastGradientInkRef.current = overlayInk;
420
+ const remembered = kind === "gradient" ? lastGradientInkRef.current : lastColorInkRef.current;
421
+ emit({
422
+ ...currentValue,
423
+ overlay: { ...overlay, ink: switchPhiBackgroundPatternInkKind(overlayInk, kind, remembered) },
424
+ });
425
+ }
426
+ function updateOverlayInkDirection(direction) {
427
+ const overlay = currentValue.overlay;
428
+ if (!overlay || overlay.kind === "noise" || !overlayInk || overlayInk.kind !== "gradient")
429
+ return;
430
+ emit({
431
+ ...currentValue,
432
+ overlay: { ...overlay, ink: withPhiBackgroundPatternInkDirection(overlayInk, direction) },
433
+ });
434
+ }
396
435
  function updateGradientDirection(direction) {
397
436
  if (currentValue.base.kind !== "gradient") {
398
437
  return;
@@ -663,18 +702,20 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
663
702
  if (mode === "preview") {
664
703
  return (_jsx(ConfigPreviewShell, { expanded: canOpenPreview, children: renderPreviewPicker() }));
665
704
  }
666
- const showPreview = mode !== "config";
705
+ if (!baseOffered && !overlayOffered)
706
+ return null;
707
+ const showPreview = mode !== "config" && baseOffered;
667
708
  /*
668
709
  * Only what can be changed is shown. One Base kind is no choice, so its Select goes; and where the
669
710
  * preview is drawn, a click on it opens the colour or gradient picker, so the second picker beside it
670
711
  * would only repeat it.
671
712
  */
672
- const soleBaseKind = baseKinds.length === 1;
713
+ const soleBaseKind = baseKinds.length === 1 || !baseOffered;
673
714
  const basePickerInPreview = soleBaseKind && showPreview;
674
715
  return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [showPreview ? (_jsx(ConfigPreviewShell, { expanded: canOpenPreview, children: renderPreviewPicker() })) : null, soleBaseKind ? null : _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingXS, width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.base }), _jsx(PhiSelectControl, { ariaLabel: labels.sections.base, disabled: isDisabled, value: currentValue.base.kind, options: baseKindOptions, style: { width: "100%" }, onChange: (next) => {
675
716
  if (next != null)
676
717
  updateBaseKind(next);
677
- } })] }), currentValue.base.kind === "image" ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%" }, children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingXS, wrap: false, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.image }), currentValue.base.sourceKind === "asset" && currentValue.base.assetId != null ? (_jsx(Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM, textAlign: "right" }, children: currentValue.base.assetId })) : null] }), _jsxs("div", { style: {
718
+ } })] }), baseOffered && currentValue.base.kind === "image" ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%" }, children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingXS, wrap: false, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.image }), currentValue.base.sourceKind === "asset" && currentValue.base.assetId != null ? (_jsx(Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM, textAlign: "right" }, children: currentValue.base.assetId })) : null] }), _jsxs("div", { style: {
678
719
  display: "grid",
679
720
  gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
680
721
  gap: token.paddingSM,
@@ -700,13 +741,16 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
700
741
  }, children: [_jsx(Select, { value: currentValue.base.position ?? "center", disabled: isDisabled, style: { width: "100%" }, options: backgroundPositionOptions, onChange: (next) => updateImageField("position", next) }), _jsx(Select, { value: currentValue.base.size ?? "cover", disabled: isDisabled, style: { width: "100%" }, options: backgroundSizeOptions, onChange: (next) => updateImageField("size", next) }), _jsx(Select, { value: currentValue.base.repeat ?? "no-repeat", disabled: isDisabled, style: { width: "100%" }, options: backgroundRepeatOptions, onChange: (next) => updateImageField("repeat", next) })] }), backgroundMotionOptions.length > 1 ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingXS, width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.motion }), _jsx(PhiSegmentedControl, { block: true, value: activeMotionMode, options: backgroundMotionOptions, disabled: isDisabled, onChange: updateMotionMode }), activeParallaxMotion ? (_jsxs(_Fragment, { children: [_jsx(Typography.Text, { children: labels.motion.strength }), _jsx(PhiSliderControl, { min: 0, max: 1, step: 0.05, ariaLabel: labels.motion.strength, value: activeParallaxMotion.strength ?? resolvePhiBackgroundParallaxDefaultStrength(activeParallaxMotion.travel), disabled: isDisabled, tooltipSuffix: "\u00D7", style: { width: "100%" }, onChange: (strength) => {
701
742
  beginSliderEdit();
702
743
  updateParallaxMotion({ strength });
703
- }, onChangeComplete: commitSliderEdit }), _jsx(Typography.Text, { children: labels.motion.direction }), _jsx(PhiSegmentedControl, { block: true, value: activeParallaxMotion.direction ?? "natural", options: backgroundMotionDirectionOptions, disabled: isDisabled, onChange: (direction) => updateParallaxMotion({ direction }) }), _jsx(Typography.Text, { children: labels.motion.travel }), _jsx(PhiSegmentedControl, { block: true, value: activeParallaxMotion.travel ?? "rate", options: backgroundMotionTravelOptions, disabled: isDisabled, onChange: (travel) => updateParallaxMotion({ travel }) })] })) : null] })) : null] })) : currentValue.base.kind === "color" || currentValue.base.kind === "gradient" ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%" }, children: [basePickerInPreview ? null : currentValue.base.kind === "color" ? (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.base.color }), _jsx(PhiColorControl, { ...colorPickerTransaction, value: currentValue.base.color, disabled: isDisabled, presets: colorPickerPresets, placement: colorPickerPlacement, onChange: (value) => {
744
+ }, onChangeComplete: commitSliderEdit }), _jsx(Typography.Text, { children: labels.motion.direction }), _jsx(PhiSegmentedControl, { block: true, value: activeParallaxMotion.direction ?? "natural", options: backgroundMotionDirectionOptions, disabled: isDisabled, onChange: (direction) => updateParallaxMotion({ direction }) }), _jsx(Typography.Text, { children: labels.motion.travel }), _jsx(PhiSegmentedControl, { block: true, value: activeParallaxMotion.travel ?? "rate", options: backgroundMotionTravelOptions, disabled: isDisabled, onChange: (travel) => updateParallaxMotion({ travel }) })] })) : null] })) : null] })) : baseOffered && (currentValue.base.kind === "color" || currentValue.base.kind === "gradient") ? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingSM, width: "100%" }, children: [basePickerInPreview ? null : currentValue.base.kind === "color" ? (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.base.color }), _jsx(PhiColorControl, { ...colorPickerTransaction, value: currentValue.base.color, disabled: isDisabled, presets: colorPickerPresets, placement: colorPickerPlacement, onChange: (value) => {
704
745
  if (value != null)
705
746
  updateBaseFromCss(value);
706
747
  } })] })) : (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.base.gradient }), _jsx(PhiColorControl, { ...colorPickerTransaction, mode: "gradient", value: derivedPickerValue, disabled: isDisabled, presets: colorPickerPresets, placement: colorPickerPlacement, onChange: (value) => {
707
748
  if (value != null)
708
749
  updateBaseFromCss(value);
709
- } })] })), currentValue.base.kind === "gradient" ? (renderDirectionEditor(labels.gradient.direction, currentValue.base.direction, updateGradientDirection)) : null] })) : null, offersOverlay ? _jsx(Divider, { dashed: true, size: "small" }) : null, offersOverlay ? _jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.overlay }), _jsx(PhiSegmentedControl, { block: true, disabled: isDisabled, value: currentValue.overlay?.kind ?? "none", options: overlayKindOptions, onChange: (next) => updateOverlayKind(next) }), currentValue.overlay ? (_jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [currentValue.overlay.kind === "pattern" ? (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.overlay.pattern }), _jsx(PhiSelectControl, { value: currentValue.overlay.patternKey, options: resolvedPatternOptions, disabled: isDisabled, style: { width: fieldControlWidth }, onChange: (patternKey) => {
750
+ } })] })), currentValue.base.kind === "gradient" ? (renderDirectionEditor(labels.gradient.direction, currentValue.base.direction, updateGradientDirection)) : null] })) : null, baseOffered && offersOverlay ? _jsx(Divider, { dashed: true, size: "small" }) : null, offersOverlay ? _jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.overlay }), _jsx(PhiSelectControl, { ariaLabel: labels.sections.overlay, disabled: isDisabled, value: currentValue.overlay?.kind ?? "none", options: overlayKindOptions, style: { width: "100%" }, onChange: (next) => {
751
+ if (next != null)
752
+ updateOverlayKind(next);
753
+ } }), currentValue.overlay ? (_jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [currentValue.overlay.kind === "pattern" ? (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.overlay.pattern }), _jsx(PhiSelectControl, { value: currentValue.overlay.patternKey, options: resolvedPatternOptions, disabled: isDisabled, style: { width: fieldControlWidth }, onChange: (patternKey) => {
710
754
  const provider = resolvePhiBackgroundPatternProvider(patternKey);
711
755
  if (!provider)
712
756
  return;
@@ -731,18 +775,20 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
731
775
  kind: "noise",
732
776
  grain,
733
777
  },
734
- }) })] })) : null, currentValue.overlay.kind === "noise" ? null : (_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.overlay.color }), _jsx(PhiColorControl, { ...colorPickerTransaction, mode: "both", value: serializePhiBackgroundPatternInkCss(currentValue.overlay.ink ?? (currentValue.overlay.kind === "color"
735
- ? PHI_BACKGROUND_COLOR_OVERLAY_DEFAULT_INK
736
- : PHI_BACKGROUND_PATTERN_DEFAULT_INK)), disabled: isDisabled, presets: colorPickerPresets, placement: colorPickerPlacement, onChange: (nextCss) => {
737
- const overlay = currentValue.overlay;
738
- const nextInk = nextCss == null ? null : readPhiBackgroundPatternInkFromCss(nextCss);
739
- if (!nextInk || !overlay || overlay.kind === "noise")
740
- return;
741
- emit({
742
- ...currentValue,
743
- overlay: { ...overlay, ink: nextInk },
744
- });
745
- } })] })), _jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.common.opacity }), _jsx(InputNumber, { min: 0, max: 1, step: 0.01, value: currentValue.overlay.opacity ?? PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY, disabled: isDisabled, onChange: (next) => emit({
778
+ }) })] })) : null, currentValue.overlay.kind === "noise" ? null : (_jsxs(_Fragment, { children: [_jsx(PhiSegmentedControl, { block: true, value: overlayInk.kind, options: overlayInkKindOptions, disabled: isDisabled, onChange: switchOverlayInkKind }), _jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.overlay.color }), _jsx(PhiColorControl, { ...colorPickerTransaction, mode: overlayInk.kind === "gradient" ? "gradient" : "single", value: serializePhiBackgroundPatternInkCss(overlayInk), disabled: isDisabled, presets: colorPickerPresets, placement: colorPickerPlacement, onChange: (nextCss) => {
779
+ const overlay = currentValue.overlay;
780
+ if (nextCss == null || !overlay || overlay.kind === "noise")
781
+ return;
782
+ const nextInk = mergePhiBackgroundPatternInkEdit(resolvePhiBackgroundOverlayInk(overlay), readPhiBackgroundPatternInkFromCss(nextCss));
783
+ if (!nextInk)
784
+ return;
785
+ emit({
786
+ ...currentValue,
787
+ overlay: { ...overlay, ink: nextInk },
788
+ });
789
+ } })] }), overlayInk.kind === "gradient"
790
+ ? renderDirectionEditor(labels.gradient.direction, overlayInk.direction, updateOverlayInkDirection)
791
+ : null] })), _jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: "wrap", children: [_jsx(Typography.Text, { children: labels.common.opacity }), _jsx(InputNumber, { min: 0, max: 1, step: 0.01, value: currentValue.overlay.opacity ?? PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY, disabled: isDisabled, onChange: (next) => emit({
746
792
  ...currentValue,
747
793
  overlay: {
748
794
  ...currentValue.overlay,
@@ -786,5 +832,5 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
786
832
  });
787
833
  }, style: { width: fieldControlWidth } })] }, field.key));
788
834
  })
789
- : null] })) : null] }) : null, filterKindOptions.length > 1 ? (_jsxs(_Fragment, { children: [_jsx(Divider, { dashed: true, size: "small" }), _jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.filter }), _jsx(PhiSegmentedControl, { block: true, disabled: isDisabled, value: activeFilterKind, options: filterKindOptions, onChange: (next) => updateFilterKind(next) })] })] })) : null] }));
835
+ : null] })) : null] }) : null, baseOffered && filterKindOptions.length > 1 ? (_jsxs(_Fragment, { children: [_jsx(Divider, { dashed: true, size: "small" }), _jsxs(PhiFlexControl, { vertical: true, gap: 8, style: { width: "100%" }, children: [_jsx(Typography.Text, { children: labels.sections.filter }), _jsx(PhiSegmentedControl, { block: true, disabled: isDisabled, value: activeFilterKind, options: filterKindOptions, onChange: (next) => updateFilterKind(next) })] })] })) : null] }));
790
836
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { lazy, Suspense } from "react";
4
- import { Button } from "antd";
4
+ import { Button, theme } from "antd";
5
5
  import { PHI_THEME_GRADIENT_CSS_VARS, } from "../../theme/phi-theme-gradients";
6
6
  import { PhiLink } from "../navigation/phi-link";
7
7
  import { PhiHoverText } from "./phi-hover-text";
@@ -12,7 +12,10 @@ import { PhiHoverText } from "./phi-hover-text";
12
12
  */
13
13
  const PhiLazyBadge = lazy(() => import("antd/es/badge"));
14
14
  const PHI_GLASS_BUTTON_FILTER = "blur(12px) saturate(140%)";
15
+ /* How far the badge centre sits outside the icon's top-right corner, in px. */
16
+ const PHI_ICON_ONLY_BADGE_OUTSET = 2;
15
17
  export function PhiButtonControl({ label, ariaLabel, ariaPressed, ariaExpanded, href, newTab, external, tooltip, icon, type = "default", shape, danger, ghost, gradient, glass, disabled, readOnly, loading, htmlType, block, size, style, badge, className, ref, onClick, }) {
18
+ const { token } = theme.useToken();
16
19
  const visibleTooltip = typeof label === "string" && typeof tooltip === "string" && label === tooltip
17
20
  ? null
18
21
  : tooltip;
@@ -50,11 +53,22 @@ export function PhiButtonControl({ label, ariaLabel, ariaPressed, ariaExpanded,
50
53
  * The colour is the Button's. A link states one, and here the Button beneath it already has.
51
54
  */
52
55
  const linked = href && !disabled && !readOnly ? (_jsx(PhiLink, { href: href, ...(external === undefined ? {} : { external }), newTab: newTab, prefetch: false, style: { display: "inline-flex", color: "inherit" }, children: button })) : button;
56
+ /*
57
+ * Ant Design centres the badge on the corner of what it wraps. Around a button with a label that is the
58
+ * button's corner, but around an icon-only button the box is far larger than the icon and the count
59
+ * floats beside it. So the count is moved in by the padding between box and icon, leaving it a little
60
+ * outside the icon's corner. Box and icon follow the Button's own size tokens: the height is
61
+ * `controlHeight*`, the icon inherits the content font size (`fontSize`, `fontSizeLG` for large).
62
+ */
63
+ const iconOnly = icon != null && (label == null || label === false || label === "");
64
+ const iconOnlyHeight = size === "small" ? token.controlHeightSM : size === "large" ? token.controlHeightLG : token.controlHeight;
65
+ const iconOnlySize = size === "large" ? token.fontSizeLG : token.fontSize;
66
+ const iconOnlyInset = Math.max(0, Math.round((iconOnlyHeight - iconOnlySize) / 2 - PHI_ICON_ONLY_BADGE_OUTSET));
53
67
  /*
54
68
  * Rendered on the Server it is complete, and hydration waits for the chunk. Mounted in the browser before
55
69
  * the chunk is there, the Button stands without its count until it arrives.
56
70
  */
57
- const badged = badge?.enabled ? (_jsx(Suspense, { fallback: linked, children: _jsx(PhiLazyBadge, { color: badge.color, count: badge.value ?? 0, overflowCount: badge.overflowCount, showZero: badge.showZero, size: "small", children: linked }) })) : linked;
71
+ const badged = badge?.enabled ? (_jsx(Suspense, { fallback: linked, children: _jsx(PhiLazyBadge, { color: badge.color, count: badge.value ?? 0, overflowCount: badge.overflowCount, showZero: badge.showZero, size: "small", offset: iconOnly && iconOnlyInset > 0 ? [-iconOnlyInset, iconOnlyInset] : undefined, children: linked }) })) : linked;
58
72
  if (!visibleTooltip)
59
73
  return badged;
60
74
  /*
@@ -5,6 +5,7 @@ import "../../styles/root.css";
5
5
  import "../../styles/layout.css";
6
6
  import "../../styles/control-shape.css";
7
7
  import "../../styles/controls.css";
8
+ import "../../styles/amount-list.css";
8
9
  import "../../styles/gradients.css";
9
10
  import type { PhiSiteConfig } from "../../types/site-config";
10
11
  import type { PhiResolvedLocale } from "../../helpers/site-locale-config";
@@ -13,6 +13,7 @@ import "../../styles/root.css";
13
13
  import "../../styles/layout.css";
14
14
  import "../../styles/control-shape.css";
15
15
  import "../../styles/controls.css";
16
+ import "../../styles/amount-list.css";
16
17
  import "../../styles/gradients.css";
17
18
  import { getResolvedSiteConfig } from "../../gateway/site-config";
18
19
  import { loadPhiAntdLocale } from "../../helpers/antd-locale";
@@ -1,3 +1,4 @@
1
+ import type { PhiBackgroundDirection } from "./background";
1
2
  import { type PhiBackgroundNoiseGrain, type PhiBackgroundPatternInk, type PhiBackgroundPatternKey, type PhiBackgroundPatternLayer, type PhiBackgroundPatternValues } from "./background-pattern-contract";
2
3
  /**
3
4
  * The rendered form of a Pattern Overlay.
@@ -31,3 +32,27 @@ export declare function resolvePhiBackgroundPatternLiveLayer(patternKey: PhiBack
31
32
  */
32
33
  export declare function resolvePhiBackgroundColorLiveLayer(ink: PhiBackgroundPatternInk, opacity: number): PhiBackgroundPatternLayer;
33
34
  export declare function resolvePhiBackgroundNoiseLiveLayer(grain: PhiBackgroundNoiseGrain, opacity: number): PhiBackgroundPatternLayer;
35
+ /**
36
+ * The ink the Inspector shows for an Overlay: the stored one, or the default of its kind when none is
37
+ * stored. An absent ink keeps meaning the default; nothing here writes one.
38
+ */
39
+ export declare function resolvePhiBackgroundOverlayInk(overlay: {
40
+ kind: "color" | "pattern";
41
+ ink?: PhiBackgroundPatternInk | null;
42
+ }): PhiBackgroundPatternInk;
43
+ /**
44
+ * The ink of the other kind, for the colour/gradient switch.
45
+ *
46
+ * `remembered` is the last ink of the wanted kind the Control held. Without one, colour to gradient fades
47
+ * the colour to `transparent` (so a wash fades instead of covering), and gradient to colour takes the
48
+ * first stop.
49
+ */
50
+ export declare function switchPhiBackgroundPatternInkKind(current: PhiBackgroundPatternInk, kind: PhiBackgroundPatternInk["kind"], remembered: PhiBackgroundPatternInk | null): PhiBackgroundPatternInk;
51
+ /** A gradient ink with another direction; its stops are untouched. A colour ink has no direction. */
52
+ export declare function withPhiBackgroundPatternInkDirection(ink: PhiBackgroundPatternInk, direction: PhiBackgroundDirection): PhiBackgroundPatternInk;
53
+ /**
54
+ * The ink a picker's CSS means, for an Overlay that holds `current`. The picker offers no direction of its
55
+ * own, so a gradient keeps the direction it had; a colour the gradient picker collapses to paints every
56
+ * stop. Returns `null` for CSS no ink can hold, and the caller keeps what it had.
57
+ */
58
+ export declare function mergePhiBackgroundPatternInkEdit(current: PhiBackgroundPatternInk, next: PhiBackgroundPatternInk | null): PhiBackgroundPatternInk | null;
@@ -181,3 +181,53 @@ export function resolvePhiBackgroundNoiseLiveLayer(grain, opacity) {
181
181
  repeats: ["repeat"],
182
182
  };
183
183
  }
184
+ /**
185
+ * The ink the Inspector shows for an Overlay: the stored one, or the default of its kind when none is
186
+ * stored. An absent ink keeps meaning the default; nothing here writes one.
187
+ */
188
+ export function resolvePhiBackgroundOverlayInk(overlay) {
189
+ return (overlay.ink ??
190
+ (overlay.kind === "color" ? PHI_BACKGROUND_COLOR_OVERLAY_DEFAULT_INK : PHI_BACKGROUND_PATTERN_DEFAULT_INK));
191
+ }
192
+ /**
193
+ * The ink of the other kind, for the colour/gradient switch.
194
+ *
195
+ * `remembered` is the last ink of the wanted kind the Control held. Without one, colour to gradient fades
196
+ * the colour to `transparent` (so a wash fades instead of covering), and gradient to colour takes the
197
+ * first stop.
198
+ */
199
+ export function switchPhiBackgroundPatternInkKind(current, kind, remembered) {
200
+ if (current.kind === kind)
201
+ return current;
202
+ if (remembered?.kind === kind)
203
+ return remembered;
204
+ if (current.kind === "color") {
205
+ return {
206
+ kind: "gradient",
207
+ direction: "to bottom",
208
+ stops: [
209
+ { color: current.color, percent: 0 },
210
+ { color: "transparent", percent: 100 },
211
+ ],
212
+ };
213
+ }
214
+ return { kind: "color", color: current.stops[0]?.color ?? "#ffffff" };
215
+ }
216
+ /** A gradient ink with another direction; its stops are untouched. A colour ink has no direction. */
217
+ export function withPhiBackgroundPatternInkDirection(ink, direction) {
218
+ return ink.kind === "gradient" ? { ...ink, direction } : ink;
219
+ }
220
+ /**
221
+ * The ink a picker's CSS means, for an Overlay that holds `current`. The picker offers no direction of its
222
+ * own, so a gradient keeps the direction it had; a colour the gradient picker collapses to paints every
223
+ * stop. Returns `null` for CSS no ink can hold, and the caller keeps what it had.
224
+ */
225
+ export function mergePhiBackgroundPatternInkEdit(current, next) {
226
+ if (!next)
227
+ return null;
228
+ if (current.kind !== "gradient")
229
+ return next;
230
+ if (next.kind === "gradient")
231
+ return { ...next, direction: current.direction };
232
+ return { ...current, stops: current.stops.map((stop) => ({ ...stop, color: next.color })) };
233
+ }
@@ -5,7 +5,7 @@ import { type PhiSpacingScaleKey } from "../config/spacing-options";
5
5
  import type { PhiMarkdownTocHeading } from "../../../types/markdown";
6
6
  import { type PhiMarkdownFoldSections } from "./markdown-sections";
7
7
  import type { PhiImagePresentation } from "../../media/image-presentation";
8
- import { type PhiMarkdownFigureFloat } from "./markdown-image-vocabulary";
8
+ import { type PhiMarkdownFigureFloat, type PhiMarkdownImageFloatWidth } from "./markdown-image-vocabulary";
9
9
  import { type PhiBulletListStyle } from "./bullet-list-vocabulary";
10
10
  export type PhiMarkdownInline = {
11
11
  kind: "text";
@@ -54,6 +54,8 @@ export type PhiMarkdownFigure = {
54
54
  /** The box as CSS (`16 / 9`) where a step was chosen; `null` is the picture's own proportion. */
55
55
  aspectRatio: string | null;
56
56
  float: PhiMarkdownFigureFloat;
57
+ /** The step of the line a floated picture takes; it says nothing while `float` is `none`. */
58
+ floatWidth: PhiMarkdownImageFloatWidth;
57
59
  };
58
60
  export type PhiMarkdownBlock = {
59
61
  kind: "heading";
@@ -112,6 +114,7 @@ export type PhiMarkdownWidgetClientProps = PhiClientBlockBaseProps<
112
114
  headings?: PhiMarkdownTocHeading[];
113
115
  textAlign?: PhiMarkdownTextAlign;
114
116
  imageFloat?: PhiMarkdownImageFloat;
117
+ imageFloatWidth?: PhiMarkdownImageFloatWidth;
115
118
  textBlockSpacingBefore?: PhiSpacingScaleKey;
116
119
  textBlockSpacingAfter?: PhiSpacingScaleKey;
117
120
  headingBlockSpacingBefore?: PhiSpacingScaleKey;
@@ -15,7 +15,7 @@ import { PhiTypographyControl } from "../../controls/phi-typography-control";
15
15
  import { PhiDividerControl } from "../../controls/phi-divider-control";
16
16
  import { PhiBulletListControl } from "../../controls/phi-bullet-list-control";
17
17
  import { resolvePhiMarkdownFoldLevel, splitPhiMarkdownSegments, } from "./markdown-sections";
18
- import { resolvePhiMarkdownFigureSizes } from "./markdown-image-vocabulary";
18
+ import { resolvePhiMarkdownFigureSizes, } from "./markdown-image-vocabulary";
19
19
  import { resolvePhiBulletListStyle, } from "./bullet-list-vocabulary";
20
20
  /*
21
21
  * A picture standing on its own and the folding sections, each its own chunk. Most texts have neither,
@@ -209,7 +209,7 @@ export function PhiMarkdownWidgetClient({ config, labels }) {
209
209
  };
210
210
  const lists = { style: resolvePhiBulletListStyle(config?.list), depth: 1 };
211
211
  return (_jsxs("div", { className: config?.imageFloat
212
- ? `phi-markdown-text phi-markdown-body phi-markdown-body--float-${config.imageFloat}`
212
+ ? `phi-markdown-text phi-markdown-body phi-markdown-body--float-${config.imageFloat}${config.imageFloatWidth ? ` phi-markdown-body--float-width-${config.imageFloatWidth}` : ""}`
213
213
  : "phi-markdown-text",
214
214
  // The text's line height for everything in it, lists included: a list entry otherwise takes the
215
215
  // browser's `normal`, and its marker centres on a line shorter than the one its words stand on.
@@ -273,5 +273,5 @@ function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
273
273
  function PhiMarkdownFigureBlock({ figure }) {
274
274
  const { presentation } = figure;
275
275
  const ownRatio = presentation.width && presentation.height ? `${presentation.width} / ${presentation.height}` : undefined;
276
- return (_jsx("figure", { className: `phi-markdown-figure phi-markdown-figure--float-${figure.float}`, children: _jsx("div", { className: "phi-markdown-figure__frame", style: { aspectRatio: figure.aspectRatio ?? ownRatio }, children: _jsx(PhiImageControl, { presentation: presentation, source: "asset", alt: figure.alt, title: figure.title, blurDataUrl: figure.blurDataUrl, optimizable: figure.optimizable, sizes: resolvePhiMarkdownFigureSizes(figure.float), style: { width: "100%", height: "100%" }, imageStyle: { width: "100%", height: "100%" } }) }) }));
276
+ return (_jsx("figure", { className: `phi-markdown-figure phi-markdown-figure--float-${figure.float} phi-markdown-figure--width-${figure.floatWidth}`, children: _jsx("div", { className: "phi-markdown-figure__frame", style: { aspectRatio: figure.aspectRatio ?? ownRatio }, children: _jsx(PhiImageControl, { presentation: presentation, source: "asset", alt: figure.alt, title: figure.title, blurDataUrl: figure.blurDataUrl, optimizable: figure.optimizable, sizes: resolvePhiMarkdownFigureSizes(figure.float, figure.floatWidth), style: { width: "100%", height: "100%" }, imageStyle: { width: "100%", height: "100%" } }) }) }));
277
277
  }
@@ -8,24 +8,37 @@ export type PhiMarkdownImageAspectRatio = (typeof PHI_MARKDOWN_IMAGE_ASPECT_RATI
8
8
  /** Where a picture stands: at an edge with the text flowing past it, or on a line of its own (`none`). */
9
9
  export declare const PHI_MARKDOWN_FIGURE_FLOATS: readonly ["start", "end", "none"];
10
10
  export type PhiMarkdownFigureFloat = (typeof PHI_MARKDOWN_FIGURE_FLOATS)[number];
11
+ /**
12
+ * How much of the line a picture beside the text takes, in fixed steps and never a measure of its own: what
13
+ * is left of the column after the gap, divided by a power of φ (`PHI_GOLDEN_RATIO`) -- `small` φ⁴ (about
14
+ * 0.15 of the column), `medium` φ³ (0.24), `large` φ² (0.38) and `xlarge` φ (0.62). `large` is what a picture
15
+ * has that says nothing: text and picture in the golden ratio. `small` is an app icon's or a portrait's
16
+ * step. It says nothing for a picture on a line of its own, which is as wide as the column; the divisors
17
+ * themselves are `styles/controls.css`.
18
+ */
19
+ export declare const PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS: readonly ["small", "medium", "large", "xlarge"];
20
+ export type PhiMarkdownImageFloatWidth = (typeof PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS)[number];
21
+ export declare const PHI_MARKDOWN_IMAGE_FLOAT_WIDTH_DEFAULT: PhiMarkdownImageFloatWidth;
22
+ export declare function readPhiMarkdownImageFloatWidth(value: unknown): PhiMarkdownImageFloatWidth | undefined;
11
23
  export declare function readPhiMarkdownImageAspectRatio(value: unknown): PhiMarkdownImageAspectRatio | undefined;
12
24
  /** A step as a number, width over height; `auto` has none -- the picture decides. */
13
25
  export declare function resolvePhiMarkdownImageAspectRatioValue(ratio: PhiMarkdownImageAspectRatio | undefined): number | null;
14
26
  /** A step as CSS writes it (`16 / 9`); `auto` has none. */
15
27
  export declare function resolvePhiMarkdownImageAspectRatioCss(ratio: PhiMarkdownImageAspectRatio | undefined): string | null;
16
28
  /**
17
- * A picture's address read apart: the reference, and what the picture says for itself. Only `ratio` and
18
- * `float` are read; anything else after the `?` is left out of the reference and ignored, so an address a
29
+ * A picture's address read apart: the reference, and what the picture says for itself. Only `ratio`,
30
+ * `float` and `width` are read; anything else after the `?` is left out of the reference and ignored, so an address a
19
31
  * later release learns more words for still names its Asset today.
20
32
  */
21
33
  export declare function readPhiMarkdownImageAddress(url: string): {
22
34
  reference: string;
23
35
  aspectRatio?: PhiMarkdownImageAspectRatio;
24
36
  float?: PhiMarkdownFigureFloat;
37
+ floatWidth?: PhiMarkdownImageFloatWidth;
25
38
  };
26
39
  /**
27
- * How wide a picture is drawn, for the image optimiser: beside the text its golden share of the column
28
- * (`styles/controls.css`, about 0.38 of a reading column of at most 1120 px), on a line of its own the
29
- * reading column's.
40
+ * How wide a picture is drawn, for the image optimiser: beside the text its step's share of the column
41
+ * (`styles/controls.css`, a reading column of at most 1120 px), on a line of its own the reading column's.
42
+ * Below 560 px a floated picture stands on its own line at full width, whatever its step.
30
43
  */
31
- export declare function resolvePhiMarkdownFigureSizes(float: PhiMarkdownFigureFloat): "(max-width: 768px) 100vw, 1120px" | "(max-width: 560px) 100vw, 440px";
44
+ export declare function resolvePhiMarkdownFigureSizes(float: PhiMarkdownFigureFloat, floatWidth?: PhiMarkdownImageFloatWidth): string;
@@ -4,8 +4,9 @@
4
4
  * reference of every route.
5
5
  *
6
6
  * Two places say it, and the nearer one wins. The Widget states what every picture in its text does -- the
7
- * Inspector's "Image proportion" and "Image Float" -- and a picture that needs something else says so in its
8
- * own address, after the Asset: `![Server](phis:asset/12?ratio=16:9&float=none)`. The address stays a
7
+ * Inspector's "Image proportion", "Image Float" and "Image Width" -- and a picture that needs something else
8
+ * says so in its own address, after the Asset: `![Server](phis:asset/12?ratio=16:9&float=none)`, or
9
+ * `![Icon](phis:asset/27?float=end&width=small)`. The address stays a
9
10
  * `phis:asset/<id>` reference for everything that reads one (the server's reference index finds the id at
10
11
  * its start), and it is plain Markdown, so a translation carries it through untouched.
11
12
  */
@@ -18,6 +19,19 @@ import { PHI_GOLDEN_RATIO } from "../../../theme/phi-tokens";
18
19
  export const PHI_MARKDOWN_IMAGE_ASPECT_RATIOS = ["auto", "phi", "3:2", "4:3", "16:9", "2:1", "1:1"];
19
20
  /** Where a picture stands: at an edge with the text flowing past it, or on a line of its own (`none`). */
20
21
  export const PHI_MARKDOWN_FIGURE_FLOATS = ["start", "end", "none"];
22
+ /**
23
+ * How much of the line a picture beside the text takes, in fixed steps and never a measure of its own: what
24
+ * is left of the column after the gap, divided by a power of φ (`PHI_GOLDEN_RATIO`) -- `small` φ⁴ (about
25
+ * 0.15 of the column), `medium` φ³ (0.24), `large` φ² (0.38) and `xlarge` φ (0.62). `large` is what a picture
26
+ * has that says nothing: text and picture in the golden ratio. `small` is an app icon's or a portrait's
27
+ * step. It says nothing for a picture on a line of its own, which is as wide as the column; the divisors
28
+ * themselves are `styles/controls.css`.
29
+ */
30
+ export const PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS = ["small", "medium", "large", "xlarge"];
31
+ export const PHI_MARKDOWN_IMAGE_FLOAT_WIDTH_DEFAULT = "large";
32
+ export function readPhiMarkdownImageFloatWidth(value) {
33
+ return PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS.find((width) => width === value);
34
+ }
21
35
  export function readPhiMarkdownImageAspectRatio(value) {
22
36
  return PHI_MARKDOWN_IMAGE_ASPECT_RATIOS.find((ratio) => ratio === value);
23
37
  }
@@ -41,8 +55,8 @@ export function resolvePhiMarkdownImageAspectRatioCss(ratio) {
41
55
  return ratio === "phi" ? `${PHI_GOLDEN_RATIO.toFixed(6)} / 1` : ratio.replace(":", " / ");
42
56
  }
43
57
  /**
44
- * A picture's address read apart: the reference, and what the picture says for itself. Only `ratio` and
45
- * `float` are read; anything else after the `?` is left out of the reference and ignored, so an address a
58
+ * A picture's address read apart: the reference, and what the picture says for itself. Only `ratio`,
59
+ * `float` and `width` are read; anything else after the `?` is left out of the reference and ignored, so an address a
46
60
  * later release learns more words for still names its Asset today.
47
61
  */
48
62
  export function readPhiMarkdownImageAddress(url) {
@@ -52,17 +66,28 @@ export function readPhiMarkdownImageAddress(url) {
52
66
  const params = new URLSearchParams(url.slice(question + 1));
53
67
  const aspectRatio = readPhiMarkdownImageAspectRatio(params.get("ratio"));
54
68
  const float = readPhiMarkdownFigureFloat(params.get("float"));
69
+ const floatWidth = readPhiMarkdownImageFloatWidth(params.get("width"));
55
70
  return {
56
71
  reference: url.slice(0, question),
57
72
  ...(aspectRatio ? { aspectRatio } : {}),
58
73
  ...(float ? { float } : {}),
74
+ ...(floatWidth ? { floatWidth } : {}),
59
75
  };
60
76
  }
77
+ /** The widest a floated picture of each step is drawn, in a reading column of 1120 px (`styles/controls.css`). */
78
+ const PHI_MARKDOWN_FLOAT_WIDTH_PIXELS = {
79
+ small: 160,
80
+ medium: 260,
81
+ large: 440,
82
+ xlarge: 680,
83
+ };
61
84
  /**
62
- * How wide a picture is drawn, for the image optimiser: beside the text its golden share of the column
63
- * (`styles/controls.css`, about 0.38 of a reading column of at most 1120 px), on a line of its own the
64
- * reading column's.
85
+ * How wide a picture is drawn, for the image optimiser: beside the text its step's share of the column
86
+ * (`styles/controls.css`, a reading column of at most 1120 px), on a line of its own the reading column's.
87
+ * Below 560 px a floated picture stands on its own line at full width, whatever its step.
65
88
  */
66
- export function resolvePhiMarkdownFigureSizes(float) {
67
- return float === "none" ? "(max-width: 768px) 100vw, 1120px" : "(max-width: 560px) 100vw, 440px";
89
+ export function resolvePhiMarkdownFigureSizes(float, floatWidth = PHI_MARKDOWN_IMAGE_FLOAT_WIDTH_DEFAULT) {
90
+ return float === "none"
91
+ ? "(max-width: 768px) 100vw, 1120px"
92
+ : `(max-width: 560px) 100vw, ${PHI_MARKDOWN_FLOAT_WIDTH_PIXELS[floatWidth]}px`;
68
93
  }