@phis/ui 0.4.21 → 0.4.22
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.
- package/components/cms/phi-cms-layout-renderer.js +1 -1
- package/components/controls/phi-brand-control.d.ts +4 -1
- package/components/controls/phi-brand-control.js +10 -6
- package/components/controls/phi-cascader-control.js +6 -1
- package/components/controls/phi-geometry-control.d.ts +33 -1
- package/components/controls/phi-geometry-control.js +87 -29
- package/components/controls/phi-series-chart-control.js +4 -2
- package/components/forms/form-provider-contract.d.ts +1 -0
- package/components/forms/form-provider-contract.js +1 -0
- package/components/forms/upload-form-control.js +1 -0
- package/components/layouts/clients/phi-flex-layout-client.js +23 -5
- package/components/layouts/clients/phi-grid-layout-client.js +20 -10
- package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
- package/components/layouts/clients/phi-layout-anchored-overlay.js +9 -2
- package/components/layouts/clients/phi-three-column-layout-client.js +7 -4
- package/components/layouts/layout-definitions.d.ts +16 -16
- package/components/layouts/layout-definitions.js +8 -8
- package/components/layouts/phi-base-layout.js +13 -9
- package/components/layouts/phi-layout-contract.d.ts +12 -2
- package/components/layouts/phi-layout-contract.js +30 -7
- package/components/layouts/phi-masonry-layout.d.ts +6 -0
- package/components/layouts/phi-masonry-layout.js +13 -3
- package/components/layouts/plugins/masonry-layout-plugin.js +2 -1
- package/components/media/asset-collection-runtime.d.ts +1 -6
- package/components/media/asset-collection-runtime.js +2 -93
- package/components/media/label-sets/media.js +12 -0
- package/components/media/media-folder-lock.d.ts +19 -0
- package/components/media/media-folder-lock.js +40 -0
- package/components/media/media-folder-options.d.ts +14 -2
- package/components/media/media-folder-options.js +17 -5
- package/components/media/media-widget-labels.d.ts +9 -0
- package/components/media/media-widget-labels.js +6 -0
- package/components/media/phi-area-upload-widget.js +1 -0
- package/components/media/phi-asset-folder-control.d.ts +14 -1
- package/components/media/phi-asset-folder-control.js +11 -4
- package/components/media/phi-image-preview-store.d.ts +0 -4
- package/components/media/phi-image-preview-store.js +0 -10
- package/components/media/phi-media-picker-binding.d.ts +7 -2
- package/components/media/phi-media-upload.d.ts +2 -0
- package/components/media/phi-media-upload.js +3 -0
- package/components/regions/clients/cms-region-container-client.d.ts +3 -1
- package/components/regions/clients/cms-region-container-client.js +4 -3
- package/components/regions/phi-cms-region-container.d.ts +3 -1
- package/components/regions/phi-cms-region-container.js +3 -2
- package/components/regions/phi-cms-region-shell.d.ts +9 -1
- package/components/regions/phi-cms-region-shell.js +3 -1
- package/components/regions/phi-cms-region-static.d.ts +3 -1
- package/components/regions/phi-cms-region-static.js +3 -2
- package/components/regions/presets/navigation-redirect.d.ts +2 -2
- package/components/regions/presets/navigation-redirect.js +5 -3
- package/components/shell/phi-antd-icon.d.ts +2 -0
- package/components/shell/phi-antd-icon.js +6 -0
- package/components/widgets/label-sets/geometry.js +10 -0
- package/components/widgets/label-types/geometry.d.ts +7 -0
- package/components/widgets/label-types/geometry.js +6 -0
- package/helpers/block-geometry-profiles.d.ts +67 -0
- package/helpers/block-geometry-profiles.js +105 -0
- package/helpers/cms-navigation-catalog.js +4 -2
- package/helpers/renderable-block-effects.js +16 -0
- package/package.json +1 -1
- package/plugins/runtime/phi-slot-child-frame-view.js +14 -4
- package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +42 -2
- package/plugins/runtime/slot-size-policy.d.ts +15 -0
- package/plugins/runtime/slot-size-policy.js +29 -0
- package/plugins/runtime-modules/asset/data-providers.js +3 -0
- package/plugins/runtime-modules/asset/services/collection.js +34 -0
- package/plugins/runtime-modules/asset/services/options.js +19 -2
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +9 -0
- package/plugins/runtime-modules/auth/trees/phi-auth-runtime-page-tree.js +21 -17
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/client.js +2 -0
- package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
- package/plugins/runtime-modules/builder/render-root-node-preview.server.js +2 -1
- package/plugins/runtime-modules/builder/services/navigation-table.js +3 -2
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +7 -1
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +8 -2
- package/plugins/runtime-modules/core/messaging/data-providers.js +23 -0
- package/plugins/runtime-modules/core/messaging/labels.d.ts +2 -0
- package/plugins/runtime-modules/core/messaging/labels.js +8 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +32 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +31 -16
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +52 -6
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +8 -2
- package/plugins/runtime-modules/descriptor-compiler.js +45 -2
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +8 -14
- package/plugins/runtime-modules/search/widgets/search-box/client.d.ts +2 -1
- package/plugins/runtime-modules/search/widgets/search-box/client.js +28 -6
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +19 -2
- package/plugins/runtime-modules/threads/labels.d.ts +6 -0
- package/plugins/runtime-modules/threads/labels.js +16 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +24 -1
- package/styles/layout.css +101 -0
- package/styles/root.css +2 -1
- package/types/cms-config.d.ts +5 -1
- package/types/cms-config.js +1 -0
- package/types/cms-module-descriptors.d.ts +17 -0
- package/types/renderable-block.d.ts +5 -0
- package/types/site-theme.d.ts +9 -1
- package/types.d.ts +1 -1
|
@@ -16,6 +16,13 @@ export type PhiGeometryWidgetLabels = {
|
|
|
16
16
|
maxSize: string;
|
|
17
17
|
zIndex: string;
|
|
18
18
|
viewport: string;
|
|
19
|
+
profile: string;
|
|
20
|
+
};
|
|
21
|
+
/** The rooms a size may name a value for, narrow first (design/RESPONSIVE_BLOCK_GEOMETRY.md). */
|
|
22
|
+
profiles: {
|
|
23
|
+
compact: string;
|
|
24
|
+
medium: string;
|
|
25
|
+
wide: string;
|
|
19
26
|
};
|
|
20
27
|
viewport: {
|
|
21
28
|
compact: string;
|
|
@@ -16,6 +16,12 @@ export const PHI_GEOMETRY_WIDGET_DEFAULT_LABELS = {
|
|
|
16
16
|
maxSize: "Max size",
|
|
17
17
|
zIndex: "z-index",
|
|
18
18
|
viewport: "Viewport",
|
|
19
|
+
profile: "Room",
|
|
20
|
+
},
|
|
21
|
+
profiles: {
|
|
22
|
+
compact: "< 377",
|
|
23
|
+
medium: "≥ 377",
|
|
24
|
+
wide: "≥ 610",
|
|
19
25
|
},
|
|
20
26
|
viewport: {
|
|
21
27
|
compact: "Compact",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { PhiResolvedBlockGeometry, PhiResolvedBlockLength } from "../types/renderable-block-geometry";
|
|
3
|
+
/**
|
|
4
|
+
* Where a block's geometry switches profile: one pair for every block (design/RESPONSIVE_BLOCK_GEOMETRY.md).
|
|
5
|
+
*
|
|
6
|
+
* A container query cannot read a custom property in its condition, so the widths stand literally in
|
|
7
|
+
* `styles/layout.css` and one rule serves every block -- the Grid's pair, so `compact | medium | wide`
|
|
8
|
+
* means one thing across the tree. `validate-container-breakpoint-contracts.ts` holds the literals to
|
|
9
|
+
* these numbers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PHI_BLOCK_GEOMETRY_RESPONSIVE_MIN_WIDTH: {
|
|
12
|
+
readonly medium: 144 | 233 | 377 | 610 | 987;
|
|
13
|
+
readonly wide: 144 | 233 | 377 | 610 | 987;
|
|
14
|
+
};
|
|
15
|
+
/** The six declarations a block may hand to its container's queries, as CSS spells them. */
|
|
16
|
+
export type PhiBlockProfileDeclaration = "width" | "height" | "min-width" | "min-height" | "max-width" | "max-height";
|
|
17
|
+
/** The attribute a box carries for the declarations it hands to CSS, space-separated. */
|
|
18
|
+
export declare const PHI_BLOCK_PROFILED_ATTRIBUTE = "data-phi-block-profiled";
|
|
19
|
+
/**
|
|
20
|
+
* What the box a block is drawn on says where a profile says nothing, and how it writes a maximum.
|
|
21
|
+
*
|
|
22
|
+
* The frame and a Layout's own inner box answer silence differently -- the frame never grows past its
|
|
23
|
+
* slot, the inner box states no maximum of its own -- so each passes its own answers, the ones it
|
|
24
|
+
* writes inline for a block that names no profile.
|
|
25
|
+
*/
|
|
26
|
+
export type PhiBlockProfileBox = {
|
|
27
|
+
unstated: Record<PhiBlockProfileDeclaration, string>;
|
|
28
|
+
/** A stated inline maximum as the box writes it; the frame caps one at the slot. */
|
|
29
|
+
inlineMaximum?: (maximum: PhiResolvedBlockLength) => string;
|
|
30
|
+
};
|
|
31
|
+
export type PhiBlockProfileStyle = {
|
|
32
|
+
/** The declarations the box hands to the stylesheet; it writes none of them inline. */
|
|
33
|
+
declarations: readonly PhiBlockProfileDeclaration[];
|
|
34
|
+
attributes: {
|
|
35
|
+
[PHI_BLOCK_PROFILED_ATTRIBUTE]?: string;
|
|
36
|
+
};
|
|
37
|
+
/** `--phi-block-<declaration>`, `-medium` and `-wide`, all three for every declaration handed over. */
|
|
38
|
+
properties: Record<string, string>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The profile answers as the stylesheet reads them (LAYOUTING.md, "Block geometry per profile").
|
|
42
|
+
*
|
|
43
|
+
* **An axis is written inline or in CSS, never both**: an inline style beats every `@container` rule.
|
|
44
|
+
* So a declaration whose three answers differ is left out of the inline style and written as three
|
|
45
|
+
* custom properties, and the rules in `styles/layout.css` choose by the room the block is offered. A
|
|
46
|
+
* declaration that answers the same at every profile stays inline, and a block that names no profile
|
|
47
|
+
* hands nothing over and pays nothing.
|
|
48
|
+
*
|
|
49
|
+
* All three properties are written for a declaration handed over, the silent ones with the box's own
|
|
50
|
+
* answer: custom properties inherit, so a property left unwritten would read whatever an enclosing
|
|
51
|
+
* block wrote for its own geometry.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolvePhiBlockProfileStyle(geometry: PhiResolvedBlockGeometry, box: PhiBlockProfileBox): PhiBlockProfileStyle;
|
|
54
|
+
/** The inline style without the declarations handed to the stylesheet. */
|
|
55
|
+
export declare function omitPhiBlockProfiledDeclarations(style: CSSProperties, declarations: readonly PhiBlockProfileDeclaration[]): CSSProperties;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a block asks the room it is offered a question, which is what makes that room a container.
|
|
58
|
+
*
|
|
59
|
+
* The box offering the room is a `phi-slot` size container only where the block standing in it names a
|
|
60
|
+
* profile; containment is not free (design/RESPONSIVE_BLOCK_GEOMETRY.md, "What it costs elsewhere"),
|
|
61
|
+
* and a page that names no profile stays byte for byte what it was.
|
|
62
|
+
*/
|
|
63
|
+
export declare function phiBlockGeometryQueriesRoom(geometry: PhiResolvedBlockGeometry): boolean;
|
|
64
|
+
/** The attribute that declares the `phi-slot` container, on the box that offers a profiled block its room. */
|
|
65
|
+
export declare function phiSlotContainerAttributes(queriesRoom: boolean): {
|
|
66
|
+
"data-phi-slot-container": string | undefined;
|
|
67
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PHI_CONTAINER_BREAKPOINT_COL3, PHI_CONTAINER_BREAKPOINT_CONTENT, } from "../theme/phi-container-breakpoints";
|
|
2
|
+
/**
|
|
3
|
+
* Where a block's geometry switches profile: one pair for every block (design/RESPONSIVE_BLOCK_GEOMETRY.md).
|
|
4
|
+
*
|
|
5
|
+
* A container query cannot read a custom property in its condition, so the widths stand literally in
|
|
6
|
+
* `styles/layout.css` and one rule serves every block -- the Grid's pair, so `compact | medium | wide`
|
|
7
|
+
* means one thing across the tree. `validate-container-breakpoint-contracts.ts` holds the literals to
|
|
8
|
+
* these numbers.
|
|
9
|
+
*/
|
|
10
|
+
export const PHI_BLOCK_GEOMETRY_RESPONSIVE_MIN_WIDTH = {
|
|
11
|
+
medium: PHI_CONTAINER_BREAKPOINT_COL3,
|
|
12
|
+
wide: PHI_CONTAINER_BREAKPOINT_CONTENT,
|
|
13
|
+
};
|
|
14
|
+
const PHI_BLOCK_PROFILE_ENTRIES = [
|
|
15
|
+
{ declaration: "width", key: "width", axis: "inline", part: "size" },
|
|
16
|
+
{ declaration: "height", key: "height", axis: "block", part: "size" },
|
|
17
|
+
{ declaration: "min-width", key: "minWidth", axis: "inline", part: "min" },
|
|
18
|
+
{ declaration: "min-height", key: "minHeight", axis: "block", part: "min" },
|
|
19
|
+
{ declaration: "max-width", key: "maxWidth", axis: "inline", part: "max" },
|
|
20
|
+
{ declaration: "max-height", key: "maxHeight", axis: "block", part: "max" },
|
|
21
|
+
];
|
|
22
|
+
/** The attribute a box carries for the declarations it hands to CSS, space-separated. */
|
|
23
|
+
export const PHI_BLOCK_PROFILED_ATTRIBUTE = "data-phi-block-profiled";
|
|
24
|
+
/** The attribute a box that offers a profiled block its room carries; `styles/layout.css` makes it the `phi-slot` container. */
|
|
25
|
+
const PHI_SLOT_CONTAINER_ATTRIBUTE = "data-phi-slot-container";
|
|
26
|
+
const PHI_EMPTY_BLOCK_PROFILE_STYLE = {
|
|
27
|
+
declarations: [],
|
|
28
|
+
attributes: {},
|
|
29
|
+
properties: {},
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The profile answers as the stylesheet reads them (LAYOUTING.md, "Block geometry per profile").
|
|
33
|
+
*
|
|
34
|
+
* **An axis is written inline or in CSS, never both**: an inline style beats every `@container` rule.
|
|
35
|
+
* So a declaration whose three answers differ is left out of the inline style and written as three
|
|
36
|
+
* custom properties, and the rules in `styles/layout.css` choose by the room the block is offered. A
|
|
37
|
+
* declaration that answers the same at every profile stays inline, and a block that names no profile
|
|
38
|
+
* hands nothing over and pays nothing.
|
|
39
|
+
*
|
|
40
|
+
* All three properties are written for a declaration handed over, the silent ones with the box's own
|
|
41
|
+
* answer: custom properties inherit, so a property left unwritten would read whatever an enclosing
|
|
42
|
+
* block wrote for its own geometry.
|
|
43
|
+
*/
|
|
44
|
+
export function resolvePhiBlockProfileStyle(geometry, box) {
|
|
45
|
+
if (geometry.profiles == null) {
|
|
46
|
+
return PHI_EMPTY_BLOCK_PROFILE_STYLE;
|
|
47
|
+
}
|
|
48
|
+
const answers = [
|
|
49
|
+
{ inline: geometry.inline, block: geometry.block },
|
|
50
|
+
geometry.profiles.medium,
|
|
51
|
+
geometry.profiles.wide,
|
|
52
|
+
];
|
|
53
|
+
const declarations = [];
|
|
54
|
+
const properties = {};
|
|
55
|
+
for (const entry of PHI_BLOCK_PROFILE_ENTRIES) {
|
|
56
|
+
const [compact, medium, wide] = answers.map((answer) => {
|
|
57
|
+
const length = answer[entry.axis][entry.part];
|
|
58
|
+
if (length == null) {
|
|
59
|
+
return box.unstated[entry.declaration];
|
|
60
|
+
}
|
|
61
|
+
return entry.declaration === "max-width" && box.inlineMaximum ? box.inlineMaximum(length) : length.css;
|
|
62
|
+
});
|
|
63
|
+
if (compact === medium && medium === wide) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
declarations.push(entry.declaration);
|
|
67
|
+
properties[`--phi-block-${entry.declaration}`] = compact;
|
|
68
|
+
properties[`--phi-block-${entry.declaration}-medium`] = medium;
|
|
69
|
+
properties[`--phi-block-${entry.declaration}-wide`] = wide;
|
|
70
|
+
}
|
|
71
|
+
return declarations.length === 0
|
|
72
|
+
? PHI_EMPTY_BLOCK_PROFILE_STYLE
|
|
73
|
+
: {
|
|
74
|
+
declarations,
|
|
75
|
+
attributes: { [PHI_BLOCK_PROFILED_ATTRIBUTE]: declarations.join(" ") },
|
|
76
|
+
properties,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The inline style without the declarations handed to the stylesheet. */
|
|
80
|
+
export function omitPhiBlockProfiledDeclarations(style, declarations) {
|
|
81
|
+
if (declarations.length === 0) {
|
|
82
|
+
return style;
|
|
83
|
+
}
|
|
84
|
+
const next = { ...style };
|
|
85
|
+
for (const entry of PHI_BLOCK_PROFILE_ENTRIES) {
|
|
86
|
+
if (declarations.includes(entry.declaration)) {
|
|
87
|
+
delete next[entry.key];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return next;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether a block asks the room it is offered a question, which is what makes that room a container.
|
|
94
|
+
*
|
|
95
|
+
* The box offering the room is a `phi-slot` size container only where the block standing in it names a
|
|
96
|
+
* profile; containment is not free (design/RESPONSIVE_BLOCK_GEOMETRY.md, "What it costs elsewhere"),
|
|
97
|
+
* and a page that names no profile stays byte for byte what it was.
|
|
98
|
+
*/
|
|
99
|
+
export function phiBlockGeometryQueriesRoom(geometry) {
|
|
100
|
+
return geometry.profiles != null;
|
|
101
|
+
}
|
|
102
|
+
/** The attribute that declares the `phi-slot` container, on the box that offers a profiled block its room. */
|
|
103
|
+
export function phiSlotContainerAttributes(queriesRoom) {
|
|
104
|
+
return { [PHI_SLOT_CONTAINER_ATTRIBUTE]: queriesRoom ? "true" : undefined };
|
|
105
|
+
}
|
|
@@ -49,6 +49,8 @@ export function getPhiBuilderNavigationDefaultScopeKey(area, family) {
|
|
|
49
49
|
function materializeNavigationItem(item, tombstones, customItems, overrides) {
|
|
50
50
|
const customItem = customItems.get(item.id);
|
|
51
51
|
const customTarget = customItem?.target;
|
|
52
|
+
// A Site's stored external link and a Module's external entry resolve to the same target.
|
|
53
|
+
const externalTarget = item.target?.kind === "custom" && item.target.external === true ? item.target : null;
|
|
52
54
|
const folder = item.kind === "container" ? customItem?.folder ?? overrides.get(item.id)?.folder : undefined;
|
|
53
55
|
return {
|
|
54
56
|
id: item.id,
|
|
@@ -68,8 +70,8 @@ function materializeNavigationItem(item, tombstones, customItems, overrides) {
|
|
|
68
70
|
...(item.target?.kind === "module"
|
|
69
71
|
? { targetPreset: { ownerModuleId: item.target.ownerModuleId, presetKey: item.target.presetKey } }
|
|
70
72
|
: {}),
|
|
71
|
-
...(customTarget?.kind === "external" ? { external: true } : {}),
|
|
72
|
-
...(customItem?.newTab === true ? { newTab: true } : {}),
|
|
73
|
+
...(customTarget?.kind === "external" || externalTarget ? { external: true } : {}),
|
|
74
|
+
...(customItem?.newTab === true || externalTarget?.newTab === true ? { newTab: true } : {}),
|
|
73
75
|
hidden: tombstones.has(item.id),
|
|
74
76
|
...(folder ? { folder } : {}),
|
|
75
77
|
children: item.children.map((child) => materializeNavigationItem(child, tombstones, customItems, overrides)),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { mergeRenderableBlockDefaults } from "./renderable-block-serialization";
|
|
2
2
|
import { PHI_RENDERABLE_BLOCK_DEFAULT_TRANSITION } from "./renderable-block-defaults";
|
|
3
|
+
/** A last frame that leaves the Block where it stands: no shift, no turn, no scale. */
|
|
4
|
+
const PHI_RESTING_TRANSFORM = /^(translate3d\(0, 0, 0\)|scale\(1\)|rotate[XYZ]?\(0deg\))$/;
|
|
3
5
|
function resolveCssDistance(value, fallback) {
|
|
4
6
|
const resolved = value ?? fallback;
|
|
5
7
|
return typeof resolved === "number" ? `${resolved}px` : resolved;
|
|
@@ -106,6 +108,7 @@ export function resolveRenderableBlockEffectsStyle(config) {
|
|
|
106
108
|
const style = {};
|
|
107
109
|
let transformIndex = 0;
|
|
108
110
|
let opacityIndex = 0;
|
|
111
|
+
let endsAtRest = true;
|
|
109
112
|
for (const transition of transitions) {
|
|
110
113
|
const step = resolveTransitionStep(transition);
|
|
111
114
|
if (step.kind === "none") {
|
|
@@ -122,6 +125,8 @@ export function resolveRenderableBlockEffectsStyle(config) {
|
|
|
122
125
|
animationCompositions.push("replace");
|
|
123
126
|
style[`--phi-effects-opacity-${cappedIndex}-from`] = String((step.fromOpacity ?? 1) * finalOpacity);
|
|
124
127
|
style[`--phi-effects-opacity-${cappedIndex}-to`] = String((step.toOpacity ?? 1) * finalOpacity);
|
|
128
|
+
if ((step.toOpacity ?? 1) !== 1)
|
|
129
|
+
endsAtRest = false;
|
|
125
130
|
}
|
|
126
131
|
if (step.kind === "transform") {
|
|
127
132
|
const index = transformIndex;
|
|
@@ -132,11 +137,22 @@ export function resolveRenderableBlockEffectsStyle(config) {
|
|
|
132
137
|
const perspective = step.perspectivePx ? `perspective(${step.perspectivePx}px)` : "";
|
|
133
138
|
style[`--phi-effects-transform-${cappedIndex}-from`] = [perspective, step.fromTransform].filter(Boolean).join(" ") || "none";
|
|
134
139
|
style[`--phi-effects-transform-${cappedIndex}-to`] = [perspective, step.toTransform].filter(Boolean).join(" ") || "none";
|
|
140
|
+
if (step.toTransform && !PHI_RESTING_TRANSFORM.test(step.toTransform))
|
|
141
|
+
endsAtRest = false;
|
|
135
142
|
}
|
|
136
143
|
transformOrigin = step.origin ?? transformOrigin;
|
|
137
144
|
perspectivePx = step.perspectivePx ?? perspectivePx;
|
|
138
145
|
}
|
|
139
146
|
if (animationNames.length > 0) {
|
|
147
|
+
/*
|
|
148
|
+
* An entrance that ends where the Block stands anyway lets go of it when it is done: it holds only its
|
|
149
|
+
* first frame, for the wait before it starts. One held after its end keeps adding its last frame to the
|
|
150
|
+
* Block's transform, and Firefox runs such a held transform animation on its compositor against the
|
|
151
|
+
* transform the Block had when the animation began -- under a viewport effect that was the flat one,
|
|
152
|
+
* so the picture flipped between flat and turned on every scroll. An exit keeps its last frame.
|
|
153
|
+
*/
|
|
154
|
+
if (endsAtRest)
|
|
155
|
+
style["--phi-effects-animation-fill"] = "backwards";
|
|
140
156
|
style["--phi-effects-animation-name"] = animationNames.join(", ");
|
|
141
157
|
style["--phi-effects-animation-duration"] = animationDurations.join(", ");
|
|
142
158
|
style["--phi-effects-animation-delay"] = animationDelays.join(", ");
|
package/package.json
CHANGED
|
@@ -4,9 +4,10 @@ import { resolvePhiSurfaceStyle } from "../../helpers/surface-style";
|
|
|
4
4
|
import { PHI_LAYOUT_SURFACE_RADIUS } from "../../components/layouts/phi-layout-contract";
|
|
5
5
|
import { PhiSurfaceGroundLayer } from "../../components/surface/phi-surface-ground";
|
|
6
6
|
import { PhiSurfaceTone } from "../../components/surface/phi-surface-tone";
|
|
7
|
-
import { buildPhiSlotChildClassName, buildPhiSlotChildDataAttributes, resolvePhiEffectiveSlotSizePolicy, resolvePhiSlotChildBaseStyle, resolvePhiSlotChildExplicitAxes, resolvePhiSlotChildSizeConstraints, resolvePhiSlotChildSizeStyle, resolvePhiSlotSizePolicy, } from "./slot-size-policy";
|
|
7
|
+
import { buildPhiSlotChildClassName, buildPhiSlotChildDataAttributes, resolvePhiEffectiveSlotSizePolicy, resolvePhiSlotChildBaseStyle, resolvePhiSlotChildExplicitAxes, resolvePhiSlotChildProfileStyle, resolvePhiSlotChildSizeConstraints, resolvePhiSlotChildSizeStyle, resolvePhiSlotSizePolicy, } from "./slot-size-policy";
|
|
8
8
|
import { resolvePhiRenderableBlockGeometry } from "../../types/renderable-block-geometry";
|
|
9
9
|
import { joinPhiClassNames } from "../../helpers/class-names";
|
|
10
|
+
import { omitPhiBlockProfiledDeclarations } from "../../helpers/block-geometry-profiles";
|
|
10
11
|
export function requiresPhiSlotChildEffectsObserver(config, disableEffects = false) {
|
|
11
12
|
if (disableEffects) {
|
|
12
13
|
return false;
|
|
@@ -40,16 +41,25 @@ export function PhiSlotChildFrameView({ kind, slotSizePolicy, surfacePolicy, blo
|
|
|
40
41
|
const effectsAttributes = disableEffects
|
|
41
42
|
? undefined
|
|
42
43
|
: resolveRenderableBlockEffectsAttributes(resolvedConfig);
|
|
44
|
+
/*
|
|
45
|
+
* A declaration that names a value per profile is the stylesheet's, not the inline style's: the frame
|
|
46
|
+
* writes the three answers as custom properties and `styles/layout.css` picks one by the room the
|
|
47
|
+
* nearest `phi-slot` container offers (LAYOUTING.md, "Block geometry per profile").
|
|
48
|
+
*/
|
|
49
|
+
const profile = resolvePhiSlotChildProfileStyle(geometry, policy);
|
|
43
50
|
const surface = kind === "widget" && surfacePolicy === "frame"
|
|
44
51
|
? resolvePhiSurfaceStyle(resolvedConfig.surface, { cornerFallback: PHI_LAYOUT_SURFACE_RADIUS })
|
|
45
52
|
: null;
|
|
46
|
-
return (_jsxs("div", { ref: anchorRef, hidden: resolvedVisibility === "hidden", className: joinPhiClassNames(buildPhiSlotChildClassName(policy), className, resolvedConfig.className, surface?.className), "data-phi-slot-child-frame": "true", "data-phi-renderable-block": "true", "data-phi-slot-child-kind": kind, "data-phi-block-id": blockId ?? undefined, "data-phi-signal-receiver": receiver ?? undefined, "data-phi-block-render-mode": resolvedConfig.renderMode, "data-phi-block-visibility": resolvedVisibility, "data-phi-viewport-flags": resolvedConfig.viewportFlags || undefined, "data-phi-block-enabled": resolvedEnabled ? "true" : "false", "data-phi-debug-scaffold": resolvedConfig.debugMode ? "on" : undefined, "data-phi-builder-widget-title": builderWidgetTitle?.trim() || undefined, "data-phi-builder-widget-selected": builderWidgetSelected ? "true" : undefined, "data-phi-builder-popup-open": builderWidgetPopupOpen ? "true" : undefined, ...effectsAttributes, "data-phi-effects-state": effectsState ?? effectsAttributes?.["data-phi-effects-state"], ...buildPhiSlotChildDataAttributes(policy, {
|
|
53
|
+
return (_jsxs("div", { ref: anchorRef, hidden: resolvedVisibility === "hidden", className: joinPhiClassNames(buildPhiSlotChildClassName(policy), className, resolvedConfig.className, surface?.className), "data-phi-slot-child-frame": "true", "data-phi-renderable-block": "true", "data-phi-slot-child-kind": kind, "data-phi-block-id": blockId ?? undefined, "data-phi-signal-receiver": receiver ?? undefined, "data-phi-block-render-mode": resolvedConfig.renderMode, "data-phi-block-visibility": resolvedVisibility, "data-phi-viewport-flags": resolvedConfig.viewportFlags || undefined, "data-phi-block-enabled": resolvedEnabled ? "true" : "false", "data-phi-debug-scaffold": resolvedConfig.debugMode ? "on" : undefined, "data-phi-builder-widget-title": builderWidgetTitle?.trim() || undefined, "data-phi-builder-widget-selected": builderWidgetSelected ? "true" : undefined, "data-phi-builder-popup-open": builderWidgetPopupOpen ? "true" : undefined, ...effectsAttributes, "data-phi-effects-state": effectsState ?? effectsAttributes?.["data-phi-effects-state"], ...profile.attributes, ...buildPhiSlotChildDataAttributes(policy, {
|
|
47
54
|
explicitInlineSize: resolvedExplicitInlineSize,
|
|
48
55
|
explicitBlockSize: resolvedExplicitBlockSize,
|
|
49
56
|
...resolvePhiSlotChildSizeConstraints(geometry),
|
|
50
57
|
}), style: {
|
|
51
|
-
...
|
|
52
|
-
|
|
58
|
+
...omitPhiBlockProfiledDeclarations({
|
|
59
|
+
...resolvePhiSlotChildBaseStyle(policy),
|
|
60
|
+
...resolvePhiSlotChildSizeStyle(geometry, policy),
|
|
61
|
+
}, profile.declarations),
|
|
62
|
+
...profile.properties,
|
|
53
63
|
...surface?.style,
|
|
54
64
|
...(resolvedConfig.zIndex == null ? {} : { zIndex: resolvedConfig.zIndex }),
|
|
55
65
|
...(resolvedConfig.opacity == null ? {} : { opacity: resolvedConfig.opacity }),
|
|
@@ -5,8 +5,13 @@ import { PHI_RENDERABLE_BLOCK_DEFAULT_VIEWPORT_EFFECT } from "../../helpers/rend
|
|
|
5
5
|
function resolveRangePoint(point, rect, viewportWidth, viewportHeight, axis) {
|
|
6
6
|
const viewportSize = axis === "x" ? viewportWidth : viewportHeight;
|
|
7
7
|
const targetSize = axis === "x" ? rect.width : rect.height;
|
|
8
|
+
/*
|
|
9
|
+
* A number is a share of the viewport along the axis, where the block's leading edge stands: 0 the top
|
|
10
|
+
* (or left) edge, 1 the bottom (or right) -- the same 0..1 the config reader keeps it to. It was taken
|
|
11
|
+
* as pixels here, so every number landed within a pixel of the top and the effect became a switch.
|
|
12
|
+
*/
|
|
8
13
|
if (typeof point === "number" && Number.isFinite(point)) {
|
|
9
|
-
return point;
|
|
14
|
+
return point * viewportSize;
|
|
10
15
|
}
|
|
11
16
|
if (point === "center") {
|
|
12
17
|
return viewportSize / 2 - targetSize / 2;
|
|
@@ -45,8 +50,34 @@ function formatViewportEffectValue(value, unit) {
|
|
|
45
50
|
}
|
|
46
51
|
return `${value}${unit ?? PHI_RENDERABLE_BLOCK_DEFAULT_VIEWPORT_EFFECT.unit ?? "px"}`;
|
|
47
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Where the block lies in the viewport as laid out, before its own transform.
|
|
55
|
+
*
|
|
56
|
+
* The effect moves, turns and scales the block, so its drawn box is a product of the last answer: a turn
|
|
57
|
+
* seen in perspective makes the box taller, which moves its top, which moves the progress, which moves
|
|
58
|
+
* the turn. Measured that way the block swung between two states on every scroll -- plainly so in Firefox
|
|
59
|
+
* on a strongly turned picture. The layout box is what the scroll alone moves. Transforms of ancestors
|
|
60
|
+
* are not undone; a viewport effect inside a transformed parent is measured as laid out there.
|
|
61
|
+
*/
|
|
62
|
+
function readViewportLayoutRect(target) {
|
|
63
|
+
let left = 0;
|
|
64
|
+
let top = 0;
|
|
65
|
+
for (let node = target; node; node = node.offsetParent) {
|
|
66
|
+
left += node.offsetLeft;
|
|
67
|
+
top += node.offsetTop;
|
|
68
|
+
if (!node.offsetParent && getComputedStyle(node).position === "fixed") {
|
|
69
|
+
return new DOMRect(left, top, target.offsetWidth, target.offsetHeight);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Scrolled boxes between the block and the page move it as the window's scroll does.
|
|
73
|
+
for (let node = target.parentElement; node && node !== document.body && node !== document.documentElement; node = node.parentElement) {
|
|
74
|
+
left -= node.scrollLeft;
|
|
75
|
+
top -= node.scrollTop;
|
|
76
|
+
}
|
|
77
|
+
return new DOMRect(left - window.scrollX, top - window.scrollY, target.offsetWidth, target.offsetHeight);
|
|
78
|
+
}
|
|
48
79
|
function resolveViewportEffectValues(effects, target) {
|
|
49
|
-
const rect = target
|
|
80
|
+
const rect = readViewportLayoutRect(target);
|
|
50
81
|
const viewportWidth = window.innerWidth;
|
|
51
82
|
const viewportHeight = window.innerHeight;
|
|
52
83
|
const values = {
|
|
@@ -166,13 +197,22 @@ export function PhiSlotChildViewportEffectsObserver({ effects, }) {
|
|
|
166
197
|
}
|
|
167
198
|
}, { rootMargin: "50% 50% 50% 50%", threshold: 0 });
|
|
168
199
|
const handleScrollOrResize = () => scheduleUpdate();
|
|
200
|
+
/*
|
|
201
|
+
* The block's own size moves its range: an image that arrives after the first measure gives the block
|
|
202
|
+
* its height only then. Without a second measure the effect kept the value it worked out against the
|
|
203
|
+
* empty box until the first scroll -- in Firefox, where images arrive after the first frame, the
|
|
204
|
+
* picture stood in a later state and jumped on the first scroll away from the top.
|
|
205
|
+
*/
|
|
206
|
+
const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(scheduleUpdate);
|
|
169
207
|
target.style.setProperty("--phi-effects-viewport-scale", "1");
|
|
170
208
|
observer.observe(target);
|
|
209
|
+
resizeObserver?.observe(target);
|
|
171
210
|
window.addEventListener("scroll", handleScrollOrResize, { passive: true });
|
|
172
211
|
window.addEventListener("resize", handleScrollOrResize);
|
|
173
212
|
scheduleUpdate();
|
|
174
213
|
return () => {
|
|
175
214
|
observer.disconnect();
|
|
215
|
+
resizeObserver?.disconnect();
|
|
176
216
|
window.removeEventListener("scroll", handleScrollOrResize);
|
|
177
217
|
window.removeEventListener("resize", handleScrollOrResize);
|
|
178
218
|
if (frameId != null) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import type { PhiSlotAxisSizePolicy, PhiSlotSizePolicy, PhiNormalizedSlotSizePolicy } from "../../types";
|
|
3
3
|
import { type PhiRenderableBlockGeometryInput, type PhiResolvedBlockGeometry } from "../../types/renderable-block-geometry";
|
|
4
|
+
import { type PhiBlockProfileStyle } from "../../helpers/block-geometry-profiles";
|
|
4
5
|
export type PhiSlotChildKind = "widget" | "layout";
|
|
5
6
|
export type PhiSlotChildSizing = {
|
|
6
7
|
policy: PhiNormalizedSlotSizePolicy;
|
|
@@ -10,6 +11,11 @@ export type PhiSlotChildSizing = {
|
|
|
10
11
|
minBlockSize?: CSSProperties["minHeight"];
|
|
11
12
|
maxInlineSize?: CSSProperties["maxWidth"];
|
|
12
13
|
maxBlockSize?: CSSProperties["maxHeight"];
|
|
14
|
+
/**
|
|
15
|
+
* The child names a value per profile, so the box that offers it room has to be the `phi-slot`
|
|
16
|
+
* container its queries ask (design/RESPONSIVE_BLOCK_GEOMETRY.md, "Only where it is needed").
|
|
17
|
+
*/
|
|
18
|
+
queriesRoom: boolean;
|
|
13
19
|
};
|
|
14
20
|
export declare function resolvePhiSlotSizePolicy(policy: PhiSlotSizePolicy | null | undefined, kind: PhiSlotChildKind): PhiNormalizedSlotSizePolicy;
|
|
15
21
|
export declare function resolvePhiSlotChildExplicitAxes(geometry: PhiResolvedBlockGeometry): {
|
|
@@ -80,3 +86,12 @@ export declare function buildPhiSlotChildDataAttributes(policy: PhiNormalizedSlo
|
|
|
80
86
|
export declare function resolvePhiSlotChildSizing(child: ReactNode, fallbackKind?: PhiSlotChildKind): PhiSlotChildSizing;
|
|
81
87
|
export declare function resolvePhiSlotChildBaseStyle(policy: PhiNormalizedSlotSizePolicy): CSSProperties;
|
|
82
88
|
export declare function resolvePhiSlotChildSizeStyle(geometry: PhiResolvedBlockGeometry, policy: PhiNormalizedSlotSizePolicy): CSSProperties;
|
|
89
|
+
/**
|
|
90
|
+
* The frame's profile answers, handed to the stylesheet (`helpers/block-geometry-profiles.ts`).
|
|
91
|
+
*
|
|
92
|
+
* The cap rule applies per profile by the same test as the base answer: an absolute inline maximum is
|
|
93
|
+
* capped at the slot unless the child is `intrinsic`. A declaration handed over is left out of the
|
|
94
|
+
* frame's inline style -- base style included -- because an inline declaration beats every
|
|
95
|
+
* `@container` rule.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolvePhiSlotChildProfileStyle(geometry: PhiResolvedBlockGeometry, policy: PhiNormalizedSlotSizePolicy): PhiBlockProfileStyle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isValidElement } from "react";
|
|
2
2
|
import { PHI_SLOT_BLOCK_PLACEMENT_MARGIN_STYLE, PHI_SLOT_INLINE_PLACEMENT_MARGIN_STYLE, } from "../../components/layouts/phi-layout-contract";
|
|
3
3
|
import { resolvePhiRenderableBlockGeometry, } from "../../types/renderable-block-geometry";
|
|
4
|
+
import { PHI_BLOCK_PROFILED_ATTRIBUTE, phiBlockGeometryQueriesRoom, resolvePhiBlockProfileStyle, } from "../../helpers/block-geometry-profiles";
|
|
4
5
|
/*
|
|
5
6
|
* What a child sizes like when nothing says otherwise.
|
|
6
7
|
*
|
|
@@ -129,6 +130,7 @@ export function resolvePhiSlotChildSizingForConfig(kind, slotSizePolicy, config)
|
|
|
129
130
|
policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(slotSizePolicy, kind), explicit),
|
|
130
131
|
...explicit,
|
|
131
132
|
...resolvePhiSlotChildSizeConstraints(geometry),
|
|
133
|
+
queriesRoom: phiBlockGeometryQueriesRoom(geometry),
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
136
|
export function buildPhiSlotChildClassName(policy) {
|
|
@@ -162,6 +164,7 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
|
|
|
162
164
|
policy: resolvePhiSlotSizePolicy(undefined, fallbackKind),
|
|
163
165
|
explicitInlineSize: false,
|
|
164
166
|
explicitBlockSize: false,
|
|
167
|
+
queriesRoom: false,
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
const props = child.props;
|
|
@@ -177,6 +180,7 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
|
|
|
177
180
|
* stretched what the frame had sized.
|
|
178
181
|
*/
|
|
179
182
|
const configExplicit = resolvePhiSlotChildExplicitAxes(configGeometry);
|
|
183
|
+
const queriesRoom = phiBlockGeometryQueriesRoom(configGeometry) || typeof props[PHI_BLOCK_PROFILED_ATTRIBUTE] === "string";
|
|
180
184
|
if (props.slotSizePolicy != null || props.kind != null) {
|
|
181
185
|
const resolvedKind = props.kind === "widget" || props.kind === "layout"
|
|
182
186
|
? props.kind
|
|
@@ -193,6 +197,7 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
|
|
|
193
197
|
policy: resolvePhiEffectiveSlotSizePolicy(resolvePhiSlotSizePolicy(props.slotSizePolicy, resolvedKind), explicit),
|
|
194
198
|
...explicit,
|
|
195
199
|
...configConstraints,
|
|
200
|
+
queriesRoom,
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
const policy = resolvePhiSlotSizePolicy({
|
|
@@ -215,6 +220,7 @@ export function resolvePhiSlotChildSizing(child, fallbackKind = "widget") {
|
|
|
215
220
|
// Idempotent: an element that already wrote the effective policy into its attributes says the same again.
|
|
216
221
|
policy: resolvePhiEffectiveSlotSizePolicy(policy, explicit),
|
|
217
222
|
...explicit,
|
|
223
|
+
queriesRoom,
|
|
218
224
|
minInlineSize: configConstraints.minInlineSize ??
|
|
219
225
|
(typeof props["data-phi-slot-min-inline-size"] === "string"
|
|
220
226
|
? props["data-phi-slot-min-inline-size"]
|
|
@@ -320,3 +326,26 @@ export function resolvePhiSlotChildSizeStyle(geometry, policy) {
|
|
|
320
326
|
...(geometry.block.max == null ? {} : { maxHeight: geometry.block.max.css }),
|
|
321
327
|
};
|
|
322
328
|
}
|
|
329
|
+
/** What the frame writes where a profile states nothing: its own base style for a block without geometry. */
|
|
330
|
+
const PHI_SLOT_CHILD_UNSTATED_PROFILE_VALUES = {
|
|
331
|
+
width: "auto",
|
|
332
|
+
height: "auto",
|
|
333
|
+
"min-width": "0",
|
|
334
|
+
"min-height": "0",
|
|
335
|
+
"max-width": "100%",
|
|
336
|
+
"max-height": "100%",
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* The frame's profile answers, handed to the stylesheet (`helpers/block-geometry-profiles.ts`).
|
|
340
|
+
*
|
|
341
|
+
* The cap rule applies per profile by the same test as the base answer: an absolute inline maximum is
|
|
342
|
+
* capped at the slot unless the child is `intrinsic`. A declaration handed over is left out of the
|
|
343
|
+
* frame's inline style -- base style included -- because an inline declaration beats every
|
|
344
|
+
* `@container` rule.
|
|
345
|
+
*/
|
|
346
|
+
export function resolvePhiSlotChildProfileStyle(geometry, policy) {
|
|
347
|
+
return resolvePhiBlockProfileStyle(geometry, {
|
|
348
|
+
unstated: PHI_SLOT_CHILD_UNSTATED_PROFILE_VALUES,
|
|
349
|
+
inlineMaximum: (maximum) => resolvePhiSlotChildInlineMaximum(maximum, policy.inline) ?? maximum.css,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
@@ -95,6 +95,9 @@ export const PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
95
95
|
},
|
|
96
96
|
actions: [
|
|
97
97
|
{ key: "createFolder", title: "Create folder", scope: "resource" },
|
|
98
|
+
// The Folder the listing is filtered to; Core refuses every change to what a locked one holds.
|
|
99
|
+
{ key: "lockFolder", title: "Lock folder", scope: "resource" },
|
|
100
|
+
{ key: "unlockFolder", title: "Unlock folder", scope: "resource" },
|
|
98
101
|
{ key: "upload", title: "Upload", scope: "resource", panelKey: "upload" },
|
|
99
102
|
{ key: "refresh", title: "Reload", scope: "resource" },
|
|
100
103
|
{ key: "update", title: "Update", scope: "item" },
|
|
@@ -4,6 +4,7 @@ import { PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY } from "../../../../constants/media
|
|
|
4
4
|
import { createPhiCollectionProviderClient } from "../../../../components/widgets/client/shared/phi-collection-provider";
|
|
5
5
|
import { buildPhiMediaRequestHeaders } from "../../../../components/media/phi-media-request-headers";
|
|
6
6
|
import { readPhiImagePreviewResponse } from "../../../../components/media/phi-image-preview-data";
|
|
7
|
+
import { PHI_MEDIA_FOLDER_LOCKED_CODE, PhiMediaFolderLockedError, writePhiMediaFolderLock, } from "../../../../components/media/media-folder-lock";
|
|
7
8
|
function readFilter(query, key) {
|
|
8
9
|
return query.filters?.[key];
|
|
9
10
|
}
|
|
@@ -103,8 +104,19 @@ function readAssetId(value) {
|
|
|
103
104
|
}
|
|
104
105
|
return assetId;
|
|
105
106
|
}
|
|
107
|
+
function readFolderId(value) {
|
|
108
|
+
const folderId = typeof value === "number" ? value : Number(value);
|
|
109
|
+
if (!Number.isInteger(folderId) || folderId <= 0) {
|
|
110
|
+
throw new Error("Folder action requires a positive folder id.");
|
|
111
|
+
}
|
|
112
|
+
return folderId;
|
|
113
|
+
}
|
|
106
114
|
async function readMutationResponse(response) {
|
|
107
115
|
const payload = await response.json().catch(() => null);
|
|
116
|
+
// Core's word for a write a locked Folder refuses, kept as a code so the surface reads it in its own.
|
|
117
|
+
if (payload?.error === PHI_MEDIA_FOLDER_LOCKED_CODE) {
|
|
118
|
+
throw new PhiMediaFolderLockedError(payload.message);
|
|
119
|
+
}
|
|
108
120
|
if (!response.ok || !payload) {
|
|
109
121
|
throw new Error(payload?.message ?? payload?.error ?? `Media request failed with status ${response.status}.`);
|
|
110
122
|
}
|
|
@@ -140,6 +152,28 @@ async function runMediaCollectionAction(request) {
|
|
|
140
152
|
}));
|
|
141
153
|
actionItem = payload.asset ?? null;
|
|
142
154
|
}
|
|
155
|
+
else if (request.actionKey === "lockFolder" || request.actionKey === "unlockFolder") {
|
|
156
|
+
/*
|
|
157
|
+
* The lock is one bit of the Folder's flags, and the flags are written whole: the Folder's current
|
|
158
|
+
* flags come with the action, so the other bits are kept as they are. The Space is the one the
|
|
159
|
+
* listing reads, because a Folder belongs to the Space it was listed from.
|
|
160
|
+
*/
|
|
161
|
+
const folderId = readFolderId(request.itemKey);
|
|
162
|
+
const flags = typeof request.item?.flags === "number" ? request.item.flags : 0;
|
|
163
|
+
const spaceId = request.query?.filters?.spaceId;
|
|
164
|
+
const search = typeof spaceId === "string" && spaceId ? `?${new URLSearchParams({ spaceId }).toString()}` : "";
|
|
165
|
+
await readMutationResponse(await fetch(`/api/site/media/folders/${folderId}${search}`, {
|
|
166
|
+
method: "PATCH",
|
|
167
|
+
headers: buildPhiMediaRequestHeaders({
|
|
168
|
+
Accept: "application/json",
|
|
169
|
+
"Content-Type": "application/json",
|
|
170
|
+
}),
|
|
171
|
+
cache: "no-store",
|
|
172
|
+
credentials: "include",
|
|
173
|
+
signal: request.signal,
|
|
174
|
+
body: JSON.stringify({ flags: writePhiMediaFolderLock(flags, request.actionKey === "lockFolder") }),
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
143
177
|
else if (request.actionKey !== "refresh") {
|
|
144
178
|
throw new Error(`Unsupported Asset collection action "${request.actionKey}".`);
|
|
145
179
|
}
|
|
@@ -6,6 +6,7 @@ import { readPhiMediaFolders } from "../../../../components/media/phi-image-prev
|
|
|
6
6
|
import { PHI_ASSET_CONTROLLER_STORE_KEY } from "../../../../components/media/asset-controller-signals";
|
|
7
7
|
import { phiImagePreviewStore } from "../../../../components/media/phi-image-preview-store";
|
|
8
8
|
import { buildPhiMediaFolderCascaderOptions, buildPhiMediaFolderNamesById, buildPhiMediaFolderValueById, } from "../../../../components/media/media-folder-options";
|
|
9
|
+
import { isPhiMediaFolderLocked } from "../../../../components/media/media-folder-lock";
|
|
9
10
|
export const PhiMediaFoldersOptionsProviderClient = createPhiControlOptionsProviderClient({
|
|
10
11
|
key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaFolders,
|
|
11
12
|
subscribe: (listener) => phiImagePreviewStore.subscribe(PHI_ASSET_CONTROLLER_STORE_KEY, listener),
|
|
@@ -19,7 +20,15 @@ export const PhiMediaFoldersOptionsProviderClient = createPhiControlOptionsProvi
|
|
|
19
20
|
return {
|
|
20
21
|
options: [
|
|
21
22
|
...configuredOptions,
|
|
22
|
-
|
|
23
|
+
/*
|
|
24
|
+
* The Asset's Folder, chosen in its metadata: a locked Folder takes nothing in, so it is not
|
|
25
|
+
* offered as a destination. The one the Asset already stands in stays readable as the value.
|
|
26
|
+
*/
|
|
27
|
+
...state.folders.map((folder) => ({
|
|
28
|
+
value: String(folder.id),
|
|
29
|
+
label: namePath(folder.id),
|
|
30
|
+
...(isPhiMediaFolderLocked(folder) ? { icon: "lock", disabled: true } : {}),
|
|
31
|
+
})),
|
|
23
32
|
],
|
|
24
33
|
value: state.folderId == null ? undefined : String(state.folderId),
|
|
25
34
|
};
|
|
@@ -32,7 +41,15 @@ export const PhiMediaFoldersOptionsProviderClient = createPhiControlOptionsProvi
|
|
|
32
41
|
return {
|
|
33
42
|
options: [
|
|
34
43
|
...configuredOptions,
|
|
35
|
-
|
|
44
|
+
/*
|
|
45
|
+
* A parent for a new Folder. A locked one is marked rather than disabled: a disabled row in a
|
|
46
|
+
* cascader cannot be opened, and the Folders below a locked one still take new ones.
|
|
47
|
+
*/
|
|
48
|
+
...state.folders.map((folder) => ({
|
|
49
|
+
value: namePath(folder.id),
|
|
50
|
+
label: folder.name,
|
|
51
|
+
...(isPhiMediaFolderLocked(folder) ? { icon: "lock" } : {}),
|
|
52
|
+
})),
|
|
36
53
|
],
|
|
37
54
|
value: namePath(state.folderId),
|
|
38
55
|
};
|
|
@@ -415,7 +415,16 @@ export async function buildPhiDefaultBuilderMediaPageTree({ page, runtime, }) {
|
|
|
415
415
|
control: "cascader",
|
|
416
416
|
placeholder: mediaLabels?.tool.folderLabel ?? "Folder",
|
|
417
417
|
width: 168,
|
|
418
|
+
/*
|
|
419
|
+
* The lock of the chosen Folder, beside the cascader that chose it. Its label is the
|
|
420
|
+
* Widget's own (lock or unlock, by the Folder's state); naming it here only places it.
|
|
421
|
+
*/
|
|
418
422
|
actions: [{
|
|
423
|
+
key: "lockFolder",
|
|
424
|
+
label: mediaLabels?.tool.lockFolderLabel ?? "Lock folder",
|
|
425
|
+
icon: "antd:lock",
|
|
426
|
+
display: "icon",
|
|
427
|
+
}, {
|
|
419
428
|
key: "createFolder",
|
|
420
429
|
label: mediaLabels?.tool.createFolderLabel ?? "Create folder",
|
|
421
430
|
description: mediaLabels?.tool.createFolderLabel ?? "Create folder",
|