@phis/ui 0.5.6 → 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 (26) hide show
  1. package/components/controls/phi-background-control.d.ts +9 -1
  2. package/components/controls/phi-background-control.js +66 -20
  3. package/components/widgets/config/background-pattern-live.d.ts +25 -0
  4. package/components/widgets/config/background-pattern-live.js +50 -0
  5. package/components/widgets/shared/markdown-body-client.d.ts +4 -1
  6. package/components/widgets/shared/markdown-body-client.js +3 -3
  7. package/components/widgets/shared/markdown-image-vocabulary.d.ts +19 -6
  8. package/components/widgets/shared/markdown-image-vocabulary.js +34 -9
  9. package/components/widgets/shared/markdown-render.d.ts +2 -1
  10. package/components/widgets/shared/markdown-render.js +4 -1
  11. package/package.json +1 -1
  12. package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -1
  13. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +8 -0
  14. package/plugins/runtime-modules/core/widgets/card/config.d.ts +10 -0
  15. package/plugins/runtime-modules/core/widgets/card/config.js +1 -0
  16. package/plugins/runtime-modules/core/widgets/description/config.d.ts +10 -0
  17. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +10 -0
  18. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +10 -0
  19. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -1
  20. package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -1
  21. package/plugins/runtime-modules/core/widgets/result/config.d.ts +10 -0
  22. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +10 -0
  23. package/plugins/runtime-modules/core/widgets/table/config.d.ts +34 -0
  24. package/styles/controls.css +30 -5
  25. package/types/cms-plugins.d.ts +8 -0
  26. package/types/core-widget-placements.d.ts +2 -1
@@ -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
+ }
@@ -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
  }
@@ -3,7 +3,7 @@ import type { PhiCmsResolvedContent } from "../../../types/cms";
3
3
  import type { PhiMarkdownTocHeading } from "../../../types/markdown";
4
4
  import type { PhiMarkdownBlock } from "./markdown-body-client";
5
5
  import type { PhiMarkdownImageFloat } from "../../../types/core-widget-placements";
6
- import { type PhiMarkdownImageAspectRatio } from "./markdown-image-vocabulary";
6
+ import { type PhiMarkdownImageAspectRatio, type PhiMarkdownImageFloatWidth } from "./markdown-image-vocabulary";
7
7
  /**
8
8
  * Where Markdown comes from and how it is turned into blocks: inline text, a stored content field, or a
9
9
  * document fetched by URL, translated or not, with heading ids under a prefix of its own.
@@ -37,6 +37,7 @@ export type PhiMarkdownSourceConfig = {
37
37
  /** What every picture in the text does, unless its own address says otherwise (`markdown-image-vocabulary.ts`). */
38
38
  imageAspectRatio?: PhiMarkdownImageAspectRatio;
39
39
  imageFloat?: PhiMarkdownImageFloat;
40
+ imageFloatWidth?: PhiMarkdownImageFloatWidth;
40
41
  };
41
42
  export type MarkdownRenderData = {
42
43
  blocks: PhiMarkdownBlock[];
@@ -5,7 +5,7 @@ import remarkGfm from "remark-gfm";
5
5
  import { trBulk, trBulkForLocale } from "../../../server-helpers/translate";
6
6
  import { resolvePhiImagePresentation } from "../../media/image-presentation";
7
7
  import { isPhiMediaSvgContentType } from "../../../constants/media";
8
- import { readPhiMarkdownImageAddress, resolvePhiMarkdownImageAspectRatioCss, resolvePhiMarkdownImageAspectRatioValue, } from "./markdown-image-vocabulary";
8
+ import { readPhiMarkdownImageAddress, resolvePhiMarkdownImageAspectRatioCss, resolvePhiMarkdownImageAspectRatioValue, PHI_MARKDOWN_IMAGE_FLOAT_WIDTH_DEFAULT, } from "./markdown-image-vocabulary";
9
9
  import { resolvePhiCodeLanguage, tokenizePhiCode } from "./markdown-code-tokens";
10
10
  import { readPhiInternalReference } from "../../../types/references";
11
11
  import { resolvePhiWidgetInternalReferences } from "../helpers/internal-reference-resolver.server";
@@ -155,6 +155,7 @@ async function projectInternalMarkdownNodes(tree, runtime) {
155
155
  asset,
156
156
  ...(address.aspectRatio ? { aspectRatio: address.aspectRatio } : {}),
157
157
  ...(address.float ? { float: address.float } : {}),
158
+ ...(address.floatWidth ? { floatWidth: address.floatWidth } : {}),
158
159
  });
159
160
  return [{ ...node, url: src, children }];
160
161
  }
@@ -215,6 +216,7 @@ function buildMarkdownFigure(image, source, defaults) {
215
216
  optimizable: !isPhiMediaSvgContentType(asset.contentType),
216
217
  aspectRatio: resolvePhiMarkdownImageAspectRatioCss(aspectRatio),
217
218
  float: source.float ?? defaults.float ?? "none",
219
+ floatWidth: source.floatWidth ?? defaults.floatWidth ?? PHI_MARKDOWN_IMAGE_FLOAT_WIDTH_DEFAULT,
218
220
  };
219
221
  }
220
222
  function mapInlineNodes(nodes) {
@@ -488,6 +490,7 @@ export async function resolveMarkdownRenderData(config, runtime) {
488
490
  : null, runtime, config?.extent ?? "document", config?.headingOffset ?? 0, {
489
491
  ...(config?.imageAspectRatio ? { aspectRatio: config.imageAspectRatio } : {}),
490
492
  ...(config?.imageFloat ? { float: config.imageFloat } : {}),
493
+ ...(config?.imageFloatWidth ? { floatWidth: config.imageFloatWidth } : {}),
491
494
  });
492
495
  }
493
496
  async function resolveMarkdownRenderDataFromSource(markdown, translate, headingIdPrefix, sourceLocale, sourceMode = "inline", sourceUrl = null, runtime, extent = "document", headingOffset = 0, imageDefaults = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
- import type { PhiBackgroundControlProps } from "../../../../components/controls/phi-background-control";
2
+ import { type PhiBackgroundControlProps } from "../../../../components/controls/phi-background-control";
3
3
  import type { PhiCmsConfigField, PhiRuntimeModuleDataProviderDescriptor } from "../../../../types/cms-plugins";
4
4
  import type { PhiCalendarAdapterDescriptor } from "../../../../types/calendar";
5
5
  import type { PhiVideoProviderDescriptor } from "../../../../types/video";
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Fragment, useMemo, useState } from "react";
4
+ import { PhiBackgroundControl } from "../../../../components/controls/phi-background-control";
4
5
  import { readPhiDotPath } from "../../../../helpers/dot-path";
5
6
  import { PhiCheckboxGroupControl } from "../../../../components/controls/phi-checkbox-group-control";
6
7
  import { PhiDividerControl } from "../../../../components/controls/phi-divider-control";
@@ -730,6 +731,13 @@ function renderPhiInspectorConfigFieldBody({ field, value, defaultValue, config,
730
731
  // A box inside a Widget has no layer of its own to blur.
731
732
  backgroundFilters: ["glass", "haze", "clear"], backgroundLabels: backgroundLabels, borderLabels: borderLabels, colorPickerLabels: colorPickerLabels, renderMediaPicker: renderMediaPicker, onChange: (nextValue) => onChange?.({ [field.key]: nextValue }) }));
732
733
  }
734
+ /*
735
+ * The Control names its own section ("Overlay", from the Background labels), so the field adds no label
736
+ * above it. The Base is not edited here and is passed as `none`; a cleared Overlay removes the key.
737
+ */
738
+ if (field.type === "background-overlay") {
739
+ return (_jsx(PhiFlexControl, { vertical: true, style: { width: "100%", minWidth: 0 }, children: _jsx(PhiBackgroundControl, { mode: "control", base: false, disabled: disabled || !onChange, value: { base: { kind: "none" }, overlay: (value ?? null) }, labels: backgroundLabels, colorPickerLabels: colorPickerLabels, renderMediaPicker: renderMediaPicker, onChange: (next) => onChange?.({ [field.key]: next?.overlay ?? undefined }) }) }, field.key));
740
+ }
733
741
  if (field.type === "icon") {
734
742
  const iconValue = typeof value === "string"
735
743
  ? value
@@ -486,6 +486,16 @@ export declare const PHI_CARD_WIDGET_DEFINITION: {
486
486
  editorPlacement?: "inspector" | "geometry" | "toolbar";
487
487
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
488
488
  heading?: string;
489
+ } & {
490
+ type: "background-overlay";
491
+ }) | ({
492
+ key: string;
493
+ label: string;
494
+ description?: string;
495
+ required?: boolean;
496
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
497
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
498
+ heading?: string;
489
499
  } & {
490
500
  type: "grid-placement" | "column-count";
491
501
  section?: string;
@@ -227,6 +227,7 @@ export const PHI_CARD_WIDGET_DEFINITION = {
227
227
  step: 5,
228
228
  suffix: "%",
229
229
  },
230
+ { key: "imageOverlay", type: "background-overlay", label: "Overlay" },
230
231
  /* The icon and where it stands, under one divider: what else an icon will need goes here as well. */
231
232
  { key: "icon", type: "icon", heading: "Icon", label: "Icon" },
232
233
  {
@@ -336,6 +336,16 @@ export declare const PHI_DESCRIPTION_WIDGET_DEFINITION: {
336
336
  editorPlacement?: "inspector" | "geometry" | "toolbar";
337
337
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
338
338
  heading?: string;
339
+ } & {
340
+ type: "background-overlay";
341
+ }) | ({
342
+ key: string;
343
+ label: string;
344
+ description?: string;
345
+ required?: boolean;
346
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
347
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
348
+ heading?: string;
339
349
  } & {
340
350
  type: "grid-placement" | "column-count";
341
351
  section?: string;
@@ -379,6 +379,16 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
379
379
  editorPlacement?: "inspector" | "geometry" | "toolbar";
380
380
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
381
381
  heading?: string;
382
+ } & {
383
+ type: "background-overlay";
384
+ }) | ({
385
+ key: string;
386
+ label: string;
387
+ description?: string;
388
+ required?: boolean;
389
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
390
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
391
+ heading?: string;
382
392
  } & {
383
393
  type: "grid-placement" | "column-count";
384
394
  section?: string;
@@ -349,6 +349,16 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
349
349
  editorPlacement?: "inspector" | "geometry" | "toolbar";
350
350
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
351
351
  heading?: string;
352
+ } & {
353
+ type: "background-overlay";
354
+ }) | ({
355
+ key: string;
356
+ label: string;
357
+ description?: string;
358
+ required?: boolean;
359
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
360
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
361
+ heading?: string;
352
362
  } & {
353
363
  type: "grid-placement" | "column-count";
354
364
  section?: string;
@@ -1,6 +1,6 @@
1
1
  import type { PhiMarkdownImageFloat, PhiMarkdownTextAlign } from "../../../../../types/core-widget-placements";
2
2
  import { type PhiMarkdownFoldSections } from "../../../../../components/widgets/shared/markdown-sections";
3
- import { type PhiMarkdownImageAspectRatio } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
3
+ import { type PhiMarkdownImageAspectRatio, type PhiMarkdownImageFloatWidth } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
4
4
  import { type PhiSpacingScaleKey } from "../../../../../components/widgets/config/spacing-options";
5
5
  import type { PhiCmsResolvedContent } from "../../../../../types/cms";
6
6
  import { type PhiBulletListStyle } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
@@ -25,6 +25,11 @@ export type PhiCmsMarkdownWidgetConfig = PhiCmsWidgetConfigBase & {
25
25
  textAlign?: PhiMarkdownTextAlign;
26
26
  /** Pictures stand at this edge and the text flows past them; absent, a picture is a line of its own. */
27
27
  imageFloat?: PhiMarkdownImageFloat;
28
+ /**
29
+ * The step of the line every floated picture takes (`markdown-image-vocabulary.ts`); absent is `large`,
30
+ * text and picture in the golden ratio. A picture's own address may say otherwise (`width=small`).
31
+ */
32
+ imageFloatWidth?: PhiMarkdownImageFloatWidth;
28
33
  /**
29
34
  * How tall every Media picture standing on its own in the text is (`markdown-image-vocabulary.ts`);
30
35
  * absent is `auto`, the picture's own proportion. A picture's own address may say otherwise.
@@ -396,6 +401,16 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
396
401
  editorPlacement?: "inspector" | "geometry" | "toolbar";
397
402
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
398
403
  heading?: string;
404
+ } & {
405
+ type: "background-overlay";
406
+ }) | ({
407
+ key: string;
408
+ label: string;
409
+ description?: string;
410
+ required?: boolean;
411
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
412
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
413
+ heading?: string;
399
414
  } & {
400
415
  type: "grid-placement" | "column-count";
401
416
  section?: string;
@@ -1,6 +1,6 @@
1
1
  import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
2
2
  import { readPhiMarkdownFoldSections, } from "../../../../../components/widgets/shared/markdown-sections";
3
- import { readPhiMarkdownImageAspectRatio, } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
3
+ import { readPhiMarkdownImageAspectRatio, readPhiMarkdownImageFloatWidth, } from "../../../../../components/widgets/shared/markdown-image-vocabulary";
4
4
  import { PHI_SPACING_SCALE_KEYS } from "../../../../../components/widgets/config/spacing-options";
5
5
  import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
6
6
  import { buildPhiBulletListFields, PHI_BULLET_LIST_DEFAULT_STYLE, readPhiBulletListStyle, } from "../../../../../components/widgets/shared/bullet-list-vocabulary";
@@ -53,6 +53,7 @@ export function parsePhiCmsMarkdownWidgetConfig(config) {
53
53
  revalidateSeconds: readNumber(config.revalidateSeconds),
54
54
  textAlign: readMarkdownTextAlign(config.textAlign),
55
55
  imageFloat: readMarkdownImageFloat(config.imageFloat),
56
+ imageFloatWidth: readPhiMarkdownImageFloatWidth(config.imageFloatWidth),
56
57
  imageAspectRatio: readPhiMarkdownImageAspectRatio(config.imageAspectRatio),
57
58
  foldSections: readPhiMarkdownFoldSections(config.foldSections),
58
59
  faqStructuredData: readBoolean(config.faqStructuredData),
@@ -171,6 +172,22 @@ export const PHI_MARKDOWN_WIDGET_DEFINITION = {
171
172
  emptyOption: { value: "none", label: "None" },
172
173
  options: PHI_MARKDOWN_IMAGE_FLOAT_OPTIONS,
173
174
  },
175
+ /*
176
+ * Fixed steps of the line, never a measure: a floated picture takes this share and the text the rest.
177
+ * `large` is the default and stores nothing. A single picture says its own in its address (`width=small`).
178
+ * Shown without a float as well: a picture may float by its own address and takes this step then.
179
+ */
180
+ {
181
+ key: "imageFloatWidth",
182
+ type: "choice",
183
+ label: "Image Width",
184
+ emptyOption: { value: "large", label: "Large (golden)" },
185
+ options: [
186
+ { value: "small", label: "Small" },
187
+ { value: "medium", label: "Medium" },
188
+ { value: "xlarge", label: "Extra large" },
189
+ ],
190
+ },
174
191
  /*
175
192
  * Every picture standing on its own takes this box; one that needs another says so in its own address
176
193
  * (`phis:asset/12?ratio=16:9`, and `float=start|end|none` beside it). Automatic is the picture's own.
@@ -344,6 +344,16 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
344
344
  editorPlacement?: "inspector" | "geometry" | "toolbar";
345
345
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
346
346
  heading?: string;
347
+ } & {
348
+ type: "background-overlay";
349
+ }) | ({
350
+ key: string;
351
+ label: string;
352
+ description?: string;
353
+ required?: boolean;
354
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
355
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
356
+ heading?: string;
347
357
  } & {
348
358
  type: "grid-placement" | "column-count";
349
359
  section?: string;
@@ -354,6 +354,16 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
354
354
  editorPlacement?: "inspector" | "geometry" | "toolbar";
355
355
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
356
356
  heading?: string;
357
+ } & {
358
+ type: "background-overlay";
359
+ }) | ({
360
+ key: string;
361
+ label: string;
362
+ description?: string;
363
+ required?: boolean;
364
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
365
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
366
+ heading?: string;
357
367
  } & {
358
368
  type: "grid-placement" | "column-count";
359
369
  section?: string;
@@ -370,6 +370,16 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
370
370
  editorPlacement?: "inspector" | "geometry" | "toolbar";
371
371
  visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
372
372
  heading?: string;
373
+ } & {
374
+ type: "background-overlay";
375
+ }) | ({
376
+ key: string;
377
+ label: string;
378
+ description?: string;
379
+ required?: boolean;
380
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
381
+ visibleWhen?: import("../../../../../types").PhiCmsConfigFieldVisibilityRule | readonly import("../../../../../types").PhiCmsConfigFieldVisibilityRule[];
382
+ heading?: string;
373
383
  } & {
374
384
  type: "grid-placement" | "column-count";
375
385
  section?: string;
@@ -717,6 +727,18 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
717
727
  heading?: string;
718
728
  type: "surface";
719
729
  tone?: false;
730
+ } | {
731
+ visibleWhen: {
732
+ field: string;
733
+ notEquals: string;
734
+ };
735
+ key: string;
736
+ label: string;
737
+ description?: string;
738
+ required?: boolean;
739
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
740
+ heading?: string;
741
+ type: "background-overlay";
720
742
  } | {
721
743
  visibleWhen: {
722
744
  field: string;
@@ -1097,6 +1119,18 @@ export declare const PHI_TABLE_WIDGET_DEFINITION: {
1097
1119
  heading?: string;
1098
1120
  type: "surface";
1099
1121
  tone?: false;
1122
+ } | {
1123
+ visibleWhen: {
1124
+ field: string;
1125
+ equals: boolean;
1126
+ };
1127
+ key: string;
1128
+ label: string;
1129
+ description?: string;
1130
+ required?: boolean;
1131
+ editorPlacement?: "inspector" | "geometry" | "toolbar";
1132
+ heading?: string;
1133
+ type: "background-overlay";
1100
1134
  } | {
1101
1135
  visibleWhen: {
1102
1136
  field: string;
@@ -773,7 +773,32 @@ h5.phi-typography, .phi-typography h5 {
773
773
  .phi-markdown-body {
774
774
  /* The gap between picture and text, on the Phi scale (`PHI_SPACE.md`), not Ant Design's margins. */
775
775
  --phi-markdown-float-gap: var(--phi-padding-md, 34px);
776
- --phi-markdown-float-width: calc((100% - var(--phi-markdown-float-gap)) / 2.618034);
776
+ /*
777
+ * The step of the line a floated picture takes (`PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS`): the divisor is a power
778
+ * of φ -- φ⁴, φ³, φ² and φ. Without a word it is φ², the golden share above. The Widget sets it for all
779
+ * its pictures on the body, a figure for itself; the width is written out where it is used, because a
780
+ * custom property holding the whole `calc()` would be settled on the body and never see a figure's step.
781
+ */
782
+ --phi-markdown-float-divisor: 2.618034;
783
+ }
784
+
785
+ .phi-markdown-body--float-width-small,
786
+ .phi-markdown-figure--width-small {
787
+ --phi-markdown-float-divisor: 6.854102;
788
+ }
789
+
790
+ .phi-markdown-body--float-width-medium,
791
+ .phi-markdown-figure--width-medium {
792
+ --phi-markdown-float-divisor: 4.236068;
793
+ }
794
+
795
+ .phi-markdown-figure--width-large {
796
+ --phi-markdown-float-divisor: 2.618034;
797
+ }
798
+
799
+ .phi-markdown-body--float-width-xlarge,
800
+ .phi-markdown-figure--width-xlarge {
801
+ --phi-markdown-float-divisor: 1.618034;
777
802
  }
778
803
 
779
804
  .phi-markdown-body :is(img):not(:where(.phi-markdown-figure *)) {
@@ -789,13 +814,13 @@ h5.phi-typography, .phi-typography h5 {
789
814
  @container (min-width: 560px) {
790
815
  .phi-markdown-body--float-start :is(img):not(:where(.phi-markdown-figure *)) {
791
816
  float: inline-start;
792
- width: var(--phi-markdown-float-width);
817
+ width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
793
818
  margin-inline-end: var(--phi-markdown-float-gap);
794
819
  }
795
820
 
796
821
  .phi-markdown-body--float-end :is(img):not(:where(.phi-markdown-figure *)) {
797
822
  float: inline-end;
798
- width: var(--phi-markdown-float-width);
823
+ width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
799
824
  margin-inline-start: var(--phi-markdown-float-gap);
800
825
  }
801
826
  }
@@ -819,13 +844,13 @@ h5.phi-typography, .phi-typography h5 {
819
844
  @container (min-width: 560px) {
820
845
  .phi-markdown-figure--float-start {
821
846
  float: inline-start;
822
- width: var(--phi-markdown-float-width);
847
+ width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
823
848
  margin-inline-end: var(--phi-markdown-float-gap);
824
849
  }
825
850
 
826
851
  .phi-markdown-figure--float-end {
827
852
  float: inline-end;
828
- width: var(--phi-markdown-float-width);
853
+ width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
829
854
  margin-inline-start: var(--phi-markdown-float-gap);
830
855
  }
831
856
  }
@@ -315,6 +315,14 @@ export type PhiCmsConfigField = (PhiCmsConfigFieldBase & {
315
315
  type: "surface";
316
316
  /** Whether the mode is offered; left out, it is. */
317
317
  tone?: false;
318
+ }) | (PhiCmsConfigFieldBase & {
319
+ /**
320
+ * A Background Overlay (`PhiBackgroundOverlay`, `components/widgets/config/background.ts`) edited
321
+ * alone, for a Widget that draws one over something of its own, such as the Card over its picture.
322
+ * `key` holds the Overlay; absent or `null` is no Overlay, and choosing "none" removes the key.
323
+ * The Inspector shows the Background Control's Overlay section only (`base={false}`).
324
+ */
325
+ type: "background-overlay";
318
326
  }) | (PhiCmsConfigFieldBase & {
319
327
  type: "grid-placement" | "column-count";
320
328
  section?: string;
@@ -1,5 +1,5 @@
1
1
  import type { PhiBulletListEntry, PhiBulletListStyle } from "../components/widgets/shared/bullet-list-vocabulary";
2
- import type { PhiMarkdownImageAspectRatio } from "../components/widgets/shared/markdown-image-vocabulary";
2
+ import type { PhiMarkdownImageAspectRatio, PhiMarkdownImageFloatWidth } from "../components/widgets/shared/markdown-image-vocabulary";
3
3
  import type { PhiMarkdownFoldSections } from "../components/widgets/shared/markdown-sections";
4
4
  import type { PhiLetterSpacingStep, PhiTextTransform } from "../components/widgets/config/text-case-vocabulary";
5
5
  import type { PhiRenderableBlockBase } from "./renderable-block";
@@ -68,6 +68,7 @@ export type PhiMarkdownWidgetPlacement = PhiWidgetPlacementBase & {
68
68
  revalidateSeconds?: number;
69
69
  textAlign?: PhiMarkdownTextAlign;
70
70
  imageFloat?: PhiMarkdownImageFloat;
71
+ imageFloatWidth?: PhiMarkdownImageFloatWidth;
71
72
  imageAspectRatio?: PhiMarkdownImageAspectRatio;
72
73
  foldSections?: PhiMarkdownFoldSections;
73
74
  faqStructuredData?: boolean;