@phis/ui 0.5.5 → 0.5.7

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 (64) hide show
  1. package/components/controls/phi-anchor-nav-control.js +18 -1
  2. package/components/controls/phi-background-control.d.ts +9 -1
  3. package/components/controls/phi-background-control.js +66 -20
  4. package/components/widgets/config/background-pattern-live.d.ts +25 -0
  5. package/components/widgets/config/background-pattern-live.js +50 -0
  6. package/components/widgets/shared/card-body-client.d.ts +6 -2
  7. package/components/widgets/shared/card-body-client.js +27 -20
  8. package/components/widgets/shared/card-vocabulary.d.ts +7 -0
  9. package/components/widgets/shared/card-vocabulary.js +6 -0
  10. package/components/widgets/shared/markdown-body-client.d.ts +4 -1
  11. package/components/widgets/shared/markdown-body-client.js +10 -5
  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/module-identity.d.ts +8 -0
  17. package/constants/module-identity.js +13 -0
  18. package/gateway/server-module-media.d.ts +12 -0
  19. package/gateway/server-module-media.js +83 -0
  20. package/helpers/cms-navigation-catalog.js +4 -1
  21. package/helpers/cms-page-catalog.d.ts +7 -0
  22. package/helpers/cms-preset-page-tree.js +16 -1
  23. package/helpers/module-media-check.d.ts +23 -0
  24. package/helpers/module-media-check.js +32 -0
  25. package/helpers/module-media.d.ts +7 -0
  26. package/helpers/module-media.js +15 -0
  27. package/helpers/route-address-check.d.ts +35 -0
  28. package/helpers/route-address-check.js +28 -0
  29. package/module-page-check.d.ts +2 -0
  30. package/module-page-check.js +2 -0
  31. package/package.json +1 -1
  32. package/plugins/runtime-modules/builder/area-shell-presets.server.js +2 -0
  33. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -1
  34. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +8 -0
  35. package/plugins/runtime-modules/builder/navigation-folder-drop.js +2 -1
  36. package/plugins/runtime-modules/builder/options-providers.js +7 -1
  37. package/plugins/runtime-modules/builder/page-presets.server.js +2 -0
  38. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +9 -2
  39. package/plugins/runtime-modules/core/widgets/card/config.d.ts +17 -1
  40. package/plugins/runtime-modules/core/widgets/card/config.js +20 -2
  41. package/plugins/runtime-modules/core/widgets/card/editor.js +2 -0
  42. package/plugins/runtime-modules/core/widgets/card/server.js +2 -0
  43. package/plugins/runtime-modules/core/widgets/description/config.d.ts +10 -0
  44. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +10 -0
  45. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +10 -0
  46. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -1
  47. package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -1
  48. package/plugins/runtime-modules/core/widgets/result/config.d.ts +10 -0
  49. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +10 -0
  50. package/plugins/runtime-modules/core/widgets/table/config.d.ts +34 -0
  51. package/plugins/runtime-modules/descriptor-compiler.d.ts +23 -3
  52. package/plugins/runtime-modules/descriptor-compiler.js +107 -12
  53. package/server-helpers/cms-area.js +9 -1
  54. package/server-helpers/cms-request.js +15 -2
  55. package/server-helpers/cms-root.js +2 -0
  56. package/server-helpers/module-folder-targets.d.ts +7 -0
  57. package/server-helpers/module-folder-targets.js +15 -0
  58. package/styles/controls.css +30 -5
  59. package/types/cms-module-descriptors.d.ts +24 -0
  60. package/types/cms-plugins.d.ts +8 -0
  61. package/types/core-widget-placements.d.ts +2 -1
  62. package/types/module-media.d.ts +31 -0
  63. package/types/module-media.js +11 -0
  64. package/types.d.ts +1 -0
@@ -1,6 +1,23 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Anchor } from "antd";
4
+ /**
5
+ * Tells the page about a jump the way a link to `#id` would.
6
+ *
7
+ * Ant Design scrolls to the place itself and writes the address with `history.pushState`, which fires no
8
+ * `hashchange` -- so whatever opens on its fragment (a folded section, `markdown-body-client.tsx`) never
9
+ * heard of the jump and the reader landed on a closed question. Sent once the address is written, after
10
+ * the click. It is not the browser's event (`isTrusted` is false): a listener reads that the scroll is
11
+ * this Control's and leaves it alone.
12
+ */
13
+ function announcePhiInPageJump(oldURL) {
14
+ queueMicrotask(() => {
15
+ const newURL = window.location.href;
16
+ if (newURL !== oldURL) {
17
+ window.dispatchEvent(new HashChangeEvent("hashchange", { oldURL, newURL }));
18
+ }
19
+ });
20
+ }
4
21
  /**
5
22
  * Links to places on the same page, with the one currently in view marked.
6
23
  *
@@ -8,7 +25,7 @@ import { Anchor } from "antd";
8
25
  * page, the shape a table of contents takes. It stays where it is drawn and never pins itself.
9
26
  */
10
27
  export function PhiAnchorNavControl({ items, offsetTop = 0, style }) {
11
- return (_jsx(Anchor, { affix: false, offsetTop: offsetTop, items: [...items], className: "phi-anchor-nav-control",
28
+ return (_jsx(Anchor, { affix: false, offsetTop: offsetTop, items: [...items], onClick: () => announcePhiInPageJump(window.location.href), className: "phi-anchor-nav-control",
12
29
  // As wide as its slot and no wider: Ant Design sizes the list to its longest title, which in a
13
30
  // narrow sider ran past the edge. Within the slot a long title ends in an ellipsis, Ant Design's own.
14
31
  style: { maxWidth: "100%", minWidth: 0, ...style } }));
@@ -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,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
+ }
@@ -7,8 +7,8 @@ import type { PhiImagePresentation } from "../../media/image-presentation";
7
7
  import type { PhiClientBlockBaseProps } from "../../../types";
8
8
  import type { PhiSurface } from "../../../types/surface";
9
9
  import type { PhiSignalRouteSet } from "../../../types/signals";
10
- import type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody } from "./card-vocabulary";
11
- export type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody, } from "./card-vocabulary";
10
+ import type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardIconSize, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody } from "./card-vocabulary";
11
+ export type { PhiCardBadgeStyle, PhiCardBillingPeriod, PhiCardHeadingLevel, PhiCardHoverEffect, PhiCardIconPlacement, PhiCardIconSize, PhiCardTextAlign, PhiCardTextSlot, PhiCardVariant, PhiCardWidgetBody, } from "./card-vocabulary";
12
12
  export type PhiCardWidgetClientLabels = {
13
13
  eyebrow?: string;
14
14
  /**
@@ -62,6 +62,10 @@ export type PhiCardWidgetClientConfig = {
62
62
  /** The icon's colour and its ground; absent, the Theme's. */
63
63
  iconColor?: string;
64
64
  iconBackground?: string;
65
+ /** How large the icon is drawn; absent is `default`. */
66
+ iconSize?: PhiCardIconSize;
67
+ /** `false` draws the icon without its ground; absent is framed, as a card always drew it. */
68
+ iconFramed?: boolean;
65
69
  textAlign?: PhiCardTextAlign;
66
70
  headingLevel?: PhiCardHeadingLevel;
67
71
  /** Where the whole card leads, already resolved to an address. */
@@ -56,8 +56,7 @@ const PHI_CARD_VARIANT_METRICS = {
56
56
  h4: { fontSize: token.fontSizeHeading4, lineHeight: token.lineHeightHeading4 },
57
57
  },
58
58
  descriptionSize: token.fontSizeLG,
59
- iconSize: 24,
60
- topIconSize: 40,
59
+ iconSizes: { default: { inline: 24, top: 40 }, large: { inline: 40, top: 64 }, xlarge: { inline: 64, top: 96 } },
61
60
  buttonSize: "medium",
62
61
  }),
63
62
  compact: (token) => ({
@@ -69,8 +68,7 @@ const PHI_CARD_VARIANT_METRICS = {
69
68
  h4: { fontSize: token.fontSizeHeading5, lineHeight: token.lineHeightHeading5 },
70
69
  },
71
70
  descriptionSize: token.fontSize,
72
- iconSize: 20,
73
- topIconSize: 32,
71
+ iconSizes: { default: { inline: 20, top: 32 }, large: { inline: 24, top: 40 }, xlarge: { inline: 40, top: 64 } },
74
72
  buttonSize: "small",
75
73
  // A strip rather than a poster, so the words stay the larger part of a compact card.
76
74
  mediaAspectRatio: "2 / 1",
@@ -145,9 +143,11 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
145
143
  const variant = config?.variant ?? "default";
146
144
  const body = config?.body ?? "text";
147
145
  const metrics = (PHI_CARD_VARIANT_METRICS[variant] ?? PHI_CARD_VARIANT_METRICS.default)(token);
148
- const { inset, gap, headingType, descriptionSize, iconSize, topIconSize, buttonSize } = metrics;
146
+ const { inset, gap, headingType, descriptionSize, buttonSize } = metrics;
149
147
  const textAlign = metrics.arrangement?.textAlign ?? config?.textAlign ?? "start";
150
148
  const headingLevel = config?.headingLevel ?? "h3";
149
+ const { inline: iconSize, top: topIconSize } = metrics.iconSizes[config?.iconSize ?? "default"];
150
+ const iconFramed = config?.iconFramed !== false;
151
151
  const iconPlacement = metrics.arrangement?.iconPlacement ?? config?.iconPlacement ?? "inline";
152
152
  const highlight = overrides.highlight ?? config?.highlight === true;
153
153
  const href = config?.href;
@@ -202,13 +202,17 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
202
202
  /*
203
203
  * The icon's colours as custom properties, which `.phi-card__icon` paints (`styles/layout.css`): the
204
204
  * `icon` hover effect turns them round, and a colour stated inline could not be turned by a rule.
205
+ * An icon without its ground takes no part in that: it has no ground to turn the colours onto, so it
206
+ * carries no `phi-card__icon` class and states its colour directly, which no hover rule reaches.
205
207
  */
206
- const iconColours = (color, background) => ({
207
- "--phi-card-icon-color": color,
208
- "--phi-card-icon-background": background,
209
- /* The mark's colour once the `icon` effect turns them round: a ground it can be read on. */
210
- "--phi-card-icon-hover-color": config?.iconBackground ?? PHI_COLOR.bgContainer,
211
- });
208
+ const iconColours = (color, background) => (iconFramed
209
+ ? {
210
+ "--phi-card-icon-color": color,
211
+ "--phi-card-icon-background": background,
212
+ /* The mark's colour once the `icon` effect turns them round: a ground it can be read on. */
213
+ "--phi-card-icon-hover-color": config?.iconBackground ?? PHI_COLOR.bgContainer,
214
+ }
215
+ : { color });
212
216
  /*
213
217
  * The corner of the icon's ground: the Theme's Control shape at the large size, scaled from a large
214
218
  * Control's height to the ground's side. So `square` draws a square, `pill` a circle -- half the large
@@ -217,15 +221,16 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
217
221
  */
218
222
  const iconCorner = (side) => `calc(var(--phi-control-radius-lg, ${token.borderRadiusLG}px) * ${side / token.controlHeightLG})`;
219
223
  /* The framed box an icon before the title stands in. */
220
- const inlineIconFrame = iconSize + 16;
221
- const iconMark = (size, framed) => iconName ? (_jsx("span", { "aria-hidden": "true", className: "phi-card__icon", style: {
224
+ const inlineIconFrame = iconFramed ? iconSize + 16 : iconSize;
225
+ const topIconFrame = iconFramed ? topIconSize + 24 : topIconSize;
226
+ const iconMark = (size, framed) => iconName ? (_jsx("span", { "aria-hidden": "true", className: iconFramed ? "phi-card__icon" : undefined, style: {
222
227
  display: "inline-flex",
223
228
  flex: "none",
224
229
  alignItems: "center",
225
230
  justifyContent: "center",
226
231
  width: framed,
227
232
  height: framed,
228
- borderRadius: iconCorner(framed),
233
+ ...(iconFramed ? { borderRadius: iconCorner(framed) } : {}),
229
234
  ...iconColours(config?.iconColor ?? (highlight ? PHI_COLOR.primary : PHI_COLOR.textSecondary), config?.iconBackground ?? PHI_COLOR.fillQuaternary),
230
235
  }, children: _jsx(PhiIcon, { name: iconName, size: size }) })) : null;
231
236
  /*
@@ -285,6 +290,8 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
285
290
  position: "relative",
286
291
  aspectRatio: config?.mediaAspectRatio ?? metrics.mediaAspectRatio ?? resolveMediaAspectRatio(image.presentation),
287
292
  overflow: "hidden",
293
+ // The icon stands in the picture's middle: a picture shorter than its box would clip it.
294
+ ...(iconAtTop && iconName ? { minHeight: topIconFrame } : {}),
288
295
  }, children: [_jsx(PhiImageControl, { presentation: image.presentation, source: image.source, alt: image.alt, blurDataUrl: image.blurDataUrl, optimizable: image.optimizable, sizes: PHI_CARD_IMAGE_SIZES, style: { width: "100%", height: "100%" }, imageStyle: {
289
296
  width: "100%",
290
297
  height: "100%",
@@ -294,7 +301,7 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
294
301
  position: "absolute",
295
302
  inset: 0,
296
303
  pointerEvents: "none",
297
- } })) : null, iconAtTop && iconName ? (_jsx("span", { "aria-hidden": "true", className: "phi-card__icon", style: {
304
+ } })) : null, iconAtTop && iconName ? (_jsx("span", { "aria-hidden": "true", className: iconFramed ? "phi-card__icon" : undefined, style: {
298
305
  position: "absolute",
299
306
  insetInlineStart: markSide === "start" ? inset : markSide === "end" ? undefined : "50%",
300
307
  insetInlineEnd: markSide === "end" ? inset : undefined,
@@ -303,12 +310,12 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
303
310
  display: "inline-flex",
304
311
  alignItems: "center",
305
312
  justifyContent: "center",
306
- width: topIconSize + 24,
307
- height: topIconSize + 24,
308
- borderRadius: iconCorner(topIconSize + 24),
313
+ width: topIconFrame,
314
+ height: topIconFrame,
315
+ ...(iconFramed ? { borderRadius: iconCorner(topIconFrame) } : {}),
309
316
  // A ground of its own, so the mark reads on a bright picture and on a dark one alike.
310
317
  ...iconColours(config?.iconColor ?? (highlight ? PHI_COLOR.primary : PHI_COLOR.text), config?.iconBackground ?? `color-mix(in srgb, ${PHI_COLOR.bgContainer} 88%, transparent)`),
311
- boxShadow: token.boxShadowTertiary,
318
+ ...(iconFramed ? { boxShadow: token.boxShadowTertiary } : {}),
312
319
  }, children: _jsx(PhiIcon, { name: iconName, size: topIconSize }) })) : null, eyebrowOnMedia && eyebrow != null ? (_jsx(PhiTypographyControl, { type: "secondary", style: {
313
320
  ...eyebrowType,
314
321
  position: "absolute",
@@ -363,7 +370,7 @@ export function PhiCardWidgetClient({ labels: placedLabels, config, binding, lis
363
370
  : {}),
364
371
  }
365
372
  : {}), ...(renderText ? { style: { pointerEvents: "auto", minWidth: "6em" } } : {}), children: badge })) : null;
366
- const words = (_jsxs("div", { style: { display: "grid", gap, padding: footAction ? 0 : inset, justifyItems }, children: [iconAtTop && iconName && !image ? (_jsx("div", { style: { justifySelf: markSide === "center" ? "center" : markSide === "end" ? "end" : "start" }, children: iconMark(topIconSize, topIconSize + 24) })) : null, eyebrow != null && !eyebrowOnMedia && !labels.eyebrowEnd ? (_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary, ...slotWidth }, children: eyebrow })) : null, labels.eyebrowEnd && !eyebrowOnMedia ? (_jsxs(PhiFlexControl, { justify: "space-between", align: "baseline", wrap: true, gap: PHI_SPACE.xs, style: { justifySelf: "stretch", minWidth: 0 }, children: [_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary }, children: eyebrow ?? "" }), _jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: PHI_COLOR.textTertiary }, children: labels.eyebrowEnd })] })) : null, headingRow, body === "stat" ? figure : null, body === "series" ? (_jsxs(_Fragment, { children: [labels.value || binding?.error || binding?.loading === true || overrides.loading === true ? figure : null, list != null && !binding?.error && binding?.loading !== true && overrides.loading !== true ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null] })) : null, body === "list" && list != null ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null, description != null ? (_jsx(PhiTypographyControl, { presentation: "paragraph", style: {
373
+ const words = (_jsxs("div", { style: { display: "grid", gap, padding: footAction ? 0 : inset, justifyItems }, children: [iconAtTop && iconName && !image ? (_jsx("div", { style: { justifySelf: markSide === "center" ? "center" : markSide === "end" ? "end" : "start" }, children: iconMark(topIconSize, topIconFrame) })) : null, eyebrow != null && !eyebrowOnMedia && !labels.eyebrowEnd ? (_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary, ...slotWidth }, children: eyebrow })) : null, labels.eyebrowEnd && !eyebrowOnMedia ? (_jsxs(PhiFlexControl, { justify: "space-between", align: "baseline", wrap: true, gap: PHI_SPACE.xs, style: { justifySelf: "stretch", minWidth: 0 }, children: [_jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: highlight ? PHI_COLOR.primary : PHI_COLOR.textTertiary }, children: eyebrow ?? "" }), _jsx(PhiTypographyControl, { type: "secondary", style: { ...eyebrowType, color: PHI_COLOR.textTertiary }, children: labels.eyebrowEnd })] })) : null, headingRow, body === "stat" ? figure : null, body === "series" ? (_jsxs(_Fragment, { children: [labels.value || binding?.error || binding?.loading === true || overrides.loading === true ? figure : null, list != null && !binding?.error && binding?.loading !== true && overrides.loading !== true ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null] })) : null, body === "list" && list != null ? (_jsx("div", { style: { justifySelf: "stretch", minWidth: 0 }, children: list })) : null, description != null ? (_jsx(PhiTypographyControl, { presentation: "paragraph", style: {
367
374
  marginBottom: 0,
368
375
  color: PHI_COLOR.textSecondary,
369
376
  fontSize: descriptionSize,
@@ -53,6 +53,13 @@ export type PhiCardBadgeStyle = (typeof PHI_CARD_BADGE_STYLES)[number];
53
53
  */
54
54
  export declare const PHI_CARD_ICON_PLACEMENTS: readonly ["inline", "top", "top-center", "top-end"];
55
55
  export type PhiCardIconPlacement = (typeof PHI_CARD_ICON_PLACEMENTS)[number];
56
+ /**
57
+ * How large the icon is drawn: fixed steps, no pixel entry, so every card of a Site stands on the same few
58
+ * sizes and the variant's table (`PHI_CARD_VARIANT_METRICS`) decides what each step is for its placement.
59
+ * Absent is `default`, which is what a card drew before the steps existed.
60
+ */
61
+ export declare const PHI_CARD_ICON_SIZES: readonly ["default", "large", "xlarge"];
62
+ export type PhiCardIconSize = (typeof PHI_CARD_ICON_SIZES)[number];
56
63
  /**
57
64
  * How a card that leads somewhere answers the pointer; a card without a link has none. A list, so a
58
65
  * further effect is an entry and a rule in `styles/layout.css`, not another flag. `lift` raises the card, `zoom` enlarges its picture, `icon`
@@ -39,6 +39,12 @@ export const PHI_CARD_BADGE_STYLES = ["none", "corner", "tag", "ribbon"];
39
39
  * picture. Logical like the text alignment: `top` is the left in a left-to-right page.
40
40
  */
41
41
  export const PHI_CARD_ICON_PLACEMENTS = ["inline", "top", "top-center", "top-end"];
42
+ /**
43
+ * How large the icon is drawn: fixed steps, no pixel entry, so every card of a Site stands on the same few
44
+ * sizes and the variant's table (`PHI_CARD_VARIANT_METRICS`) decides what each step is for its placement.
45
+ * Absent is `default`, which is what a card drew before the steps existed.
46
+ */
47
+ export const PHI_CARD_ICON_SIZES = ["default", "large", "xlarge"];
42
48
  /**
43
49
  * How a card that leads somewhere answers the pointer; a card without a link has none. A list, so a
44
50
  * further effect is an entry and a rule in `styles/layout.css`, not another flag. `lift` raises the card, `zoom` enlarges its picture, `icon`
@@ -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.
@@ -230,12 +230,14 @@ export function PhiMarkdownWidgetClient({ config, labels }) {
230
230
  * The sections that fold: each heading is a header, what follows it the body. Every answer is drawn even
231
231
  * while folded, so a search engine and the browser's own find read the whole text. A heading keeps its id,
232
232
  * so the table of contents and a link to `#that-question` reach it -- and a link to it opens it, on arrival
233
- * and whenever the address's fragment changes.
233
+ * and whenever the address's fragment changes. The table of contents announces its jumps as a fragment
234
+ * change of its own (`phi-anchor-nav-control.tsx`) and scrolls there itself, with the Header's offset;
235
+ * only on arrival and on the browser's own change is the heading scrolled to here.
234
236
  */
235
237
  function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
236
238
  const [openKeys, setOpenKeys] = useState([]);
237
239
  useEffect(() => {
238
- const openFromAddress = () => {
240
+ const openFromAddress = (event) => {
239
241
  const id = decodeURIComponent(window.location.hash.slice(1));
240
242
  if (!id)
241
243
  return;
@@ -243,6 +245,9 @@ function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
243
245
  if (!section)
244
246
  return;
245
247
  setOpenKeys((current) => accordion ? [section.heading.id] : [...new Set([...current, section.heading.id])]);
248
+ // A change the page sent itself comes with its own scroll (the table of contents').
249
+ if (event && !event.isTrusted)
250
+ return;
246
251
  window.requestAnimationFrame(() => document.getElementById(id)?.scrollIntoView({ block: "start" }));
247
252
  };
248
253
  openFromAddress();
@@ -268,5 +273,5 @@ function PhiMarkdownFoldedSections({ sections, accordion, renderBody, }) {
268
273
  function PhiMarkdownFigureBlock({ figure }) {
269
274
  const { presentation } = figure;
270
275
  const ownRatio = presentation.width && presentation.height ? `${presentation.width} / ${presentation.height}` : undefined;
271
- 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%" } }) }) }));
272
277
  }