@phis/ui 0.4.23 → 0.5.1
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/controls/phi-background-control.js +1 -1
- package/components/controls/phi-breadcrumb-control.d.ts +2 -0
- package/components/controls/phi-button-control.d.ts +7 -1
- package/components/media/media-asset-typed-fields.d.ts +10 -0
- package/components/media/media-asset-typed-fields.js +19 -0
- package/components/media/media-settings-labels.d.ts +33 -0
- package/components/media/media-settings-labels.js +62 -0
- package/components/media/media-upload-flow.d.ts +19 -0
- package/components/media/media-upload-flow.js +38 -0
- package/components/media/phi-asset-focal-rect-widget.js +2 -2
- package/components/media/phi-asset-folder-control.js +1 -1
- package/components/media/phi-image-inspector-widget.js +1 -1
- package/components/media/phi-image-preview-data.js +5 -4
- package/components/media/phi-site-font-assets.js +2 -5
- package/components/media/use-authoring-asset-details.js +0 -1
- package/components/regions/presets/content-entry-editor-page-tree.js +1 -1
- package/components/regions/presets/navigation-redirect.d.ts +2 -2
- package/components/regions/presets/navigation-redirect.js +3 -3
- package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
- package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
- package/components/shell/phi-antd-icon.d.ts +4 -0
- package/components/shell/phi-antd-icon.js +8 -0
- package/components/shell/phi-icon.d.ts +18 -0
- package/components/shell/phi-icon.js +50 -3
- package/components/widgets/client/shared/phi-button-icons.d.ts +7 -0
- package/components/widgets/client/shared/phi-button-icons.js +15 -67
- package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
- package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
- package/components/widgets/label-sets/builder-modules.js +6 -0
- package/components/widgets/label-types/builder-modules.d.ts +4 -0
- package/components/widgets/label-types/builder-modules.js +3 -0
- package/components/widgets/label-types/common-controls.js +12 -12
- package/constants/runtime-module-ownership.js +4 -0
- package/gateway/internal-references.d.ts +5 -0
- package/gateway/internal-references.js +12 -12
- package/gateway/site-media-settings.d.ts +2 -0
- package/gateway/site-media-settings.js +6 -1
- package/gateway/site-media-storage-reader.d.ts +19 -0
- package/gateway/site-media-storage-reader.js +24 -0
- package/helpers/cms-navigation-catalog.d.ts +2 -0
- package/helpers/cms-navigation-catalog.js +1 -0
- package/helpers/cms-page-catalog.d.ts +12 -0
- package/helpers/cms-page-catalog.js +5 -0
- package/helpers/phi-seo.d.ts +16 -2
- package/helpers/phi-seo.js +54 -11
- package/helpers/public-route-claims.d.ts +4 -0
- package/helpers/public-route-claims.js +1 -1
- package/next/seo-routes.d.ts +1 -1
- package/next/seo-routes.js +23 -5
- package/package.json +1 -1
- package/plugins/runtime-modules/accounting/presets.d.ts +10 -1
- package/plugins/runtime-modules/accounting/presets.js +25 -8
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.d.ts +6 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.js +53 -0
- package/plugins/runtime-modules/area-definitions.d.ts +123 -12
- package/plugins/runtime-modules/area-definitions.js +28 -0
- package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
- package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
- package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
- package/plugins/runtime-modules/asset/data-providers.js +56 -0
- package/plugins/runtime-modules/asset/definition.d.ts +38 -2
- package/plugins/runtime-modules/asset/definition.js +2 -1
- package/plugins/runtime-modules/asset/ids.d.ts +4 -0
- package/plugins/runtime-modules/asset/ids.js +4 -0
- package/plugins/runtime-modules/asset/server.js +2 -1
- package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
- package/plugins/runtime-modules/asset/services/options.js +38 -0
- package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
- package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
- package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
- package/plugins/runtime-modules/asset/settings-forms.js +117 -1
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +1 -1
- package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
- package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
- package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
- package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
- package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
- package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
- package/plugins/runtime-modules/builder/data-providers.js +1 -0
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
- package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
- package/plugins/runtime-modules/builder/options-providers.js +2 -2
- package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
- package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
- package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
- package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
- package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
- package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +2 -2
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +16 -4
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
- package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
- package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
- package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
- package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
- package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
- package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
- package/plugins/runtime-modules/descriptor-compiler.js +33 -8
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +1 -1
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +1 -1
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +1 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +1 -1
- package/server-helpers/cms-review-params.d.ts +25 -0
- package/server-helpers/cms-review-params.js +54 -0
- package/server-helpers/cms-review.d.ts +1 -25
- package/server-helpers/cms-review.js +2 -54
- package/styles/controls.css +11 -0
- package/types/cms-module-descriptors.d.ts +33 -3
- package/types/media.d.ts +6 -2
- package/types/table-widget.d.ts +11 -0
- package/types.d.ts +1 -1
|
@@ -508,7 +508,7 @@ export function PhiBackgroundControl({ value, config, disabled = false, mode = "
|
|
|
508
508
|
deliveryUrl: asset.deliveryUrl ?? null,
|
|
509
509
|
deliveryRevision: asset.deliveryRevision ?? null,
|
|
510
510
|
variantVersion: asset.variantVersion ?? null,
|
|
511
|
-
focalRect: normalizeMediaFocalRect(asset.
|
|
511
|
+
focalRect: normalizeMediaFocalRect(asset.focalRect ?? null),
|
|
512
512
|
width: asset.width ?? null,
|
|
513
513
|
height: asset.height ?? null,
|
|
514
514
|
};
|
|
@@ -2,6 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
export type PhiBreadcrumbControlItem = {
|
|
3
3
|
key?: string;
|
|
4
4
|
title: ReactNode;
|
|
5
|
+
/** Where the item leads; an item without one is text. */
|
|
6
|
+
href?: string;
|
|
5
7
|
};
|
|
6
8
|
export type PhiBreadcrumbControlProps = {
|
|
7
9
|
items: readonly PhiBreadcrumbControlItem[];
|
|
@@ -44,7 +44,13 @@ export type PhiButtonControlProps = {
|
|
|
44
44
|
*/
|
|
45
45
|
external?: boolean;
|
|
46
46
|
tooltip?: ReactNode;
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The icon, as an element. A name is resolved before it gets here -- `resolvePhiButtonIcon` for a
|
|
49
|
+
* Widget's configured name, `PhiIcon` otherwise -- because a control draws and resolves nothing: resolving
|
|
50
|
+
* here put the icon resolver and the whole name list into every page with a Button, the error pages among
|
|
51
|
+
* them. A string is refused by the type, so a name can never be drawn as text.
|
|
52
|
+
*/
|
|
53
|
+
icon?: Exclude<ReactNode, string>;
|
|
48
54
|
type?: PhiButtonType;
|
|
49
55
|
/** A round button is what an icon on its own wants, over a picture or in a toolbar. */
|
|
50
56
|
shape?: ButtonProps["shape"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PhiConfigReader } from "../widgets/config/strict-config-reader";
|
|
2
|
+
import type { PhiFontMetrics } from "../../types/media";
|
|
3
|
+
import type { MediaFocalRect } from "./focal-rect";
|
|
4
|
+
/**
|
|
5
|
+
* The entries of an Asset's stored `meta` a client acts on, as the server sends them: typed fields, never
|
|
6
|
+
* `meta` itself. One reader for every response that carries them -- the management tile and detail as much
|
|
7
|
+
* as the public reference projection -- so the three cannot disagree about what a focal rectangle is.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readPhiMediaFocalRectField(reader: PhiConfigReader): MediaFocalRect | null;
|
|
10
|
+
export declare function readPhiMediaFontField(reader: PhiConfigReader): PhiFontMetrics | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readPhiFontMetricsFields } from "./media-font-metrics";
|
|
2
|
+
import { requirePhiField } from "../widgets/config/strict-config-reader";
|
|
3
|
+
/**
|
|
4
|
+
* The entries of an Asset's stored `meta` a client acts on, as the server sends them: typed fields, never
|
|
5
|
+
* `meta` itself. One reader for every response that carries them -- the management tile and detail as much
|
|
6
|
+
* as the public reference projection -- so the three cannot disagree about what a focal rectangle is.
|
|
7
|
+
*/
|
|
8
|
+
export function readPhiMediaFocalRectField(reader) {
|
|
9
|
+
return reader.object("focalRect", (rect) => {
|
|
10
|
+
const fraction = (key) => {
|
|
11
|
+
const value = requirePhiField(rect, key, "a number from 0 to 1", rect.number);
|
|
12
|
+
return value >= 0 && value <= 1 ? value : rect.fail(key, "a number from 0 to 1");
|
|
13
|
+
};
|
|
14
|
+
return { x: fraction("x"), y: fraction("y"), width: fraction("width"), height: fraction("height") };
|
|
15
|
+
}) ?? null;
|
|
16
|
+
}
|
|
17
|
+
export function readPhiMediaFontField(reader) {
|
|
18
|
+
return reader.object("font", readPhiFontMetricsFields) ?? null;
|
|
19
|
+
}
|
|
@@ -39,5 +39,38 @@ export declare function getPhiMediaSettingsPageLabels(options: PhiGlobalTranslat
|
|
|
39
39
|
title: string;
|
|
40
40
|
empty: string;
|
|
41
41
|
};
|
|
42
|
+
storage: {
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
siteSpace: string;
|
|
46
|
+
siteSpaceHint: string;
|
|
47
|
+
siteSpaceRequired: string;
|
|
48
|
+
defaultUser: string;
|
|
49
|
+
defaultUserHint: string;
|
|
50
|
+
defaultGroup: string;
|
|
51
|
+
defaultGroupHint: string;
|
|
52
|
+
local: string;
|
|
53
|
+
allowed: string;
|
|
54
|
+
allowedHint: string;
|
|
55
|
+
all: string;
|
|
56
|
+
disabled: string;
|
|
57
|
+
disabledHint: string;
|
|
58
|
+
none: string;
|
|
59
|
+
};
|
|
60
|
+
spaces: {
|
|
61
|
+
title: string;
|
|
62
|
+
description: string;
|
|
63
|
+
userTable: string;
|
|
64
|
+
groupTable: string;
|
|
65
|
+
owner: string;
|
|
66
|
+
email: string;
|
|
67
|
+
profile: string;
|
|
68
|
+
quota: string;
|
|
69
|
+
quotaHint: string;
|
|
70
|
+
effective: string;
|
|
71
|
+
used: string;
|
|
72
|
+
search: string;
|
|
73
|
+
empty: string;
|
|
74
|
+
};
|
|
42
75
|
submitLabel: string;
|
|
43
76
|
}>;
|
|
@@ -35,6 +35,35 @@ const PHI_MEDIA_SETTINGS_PAGE_LABEL_SET = definePhiLabelSet({
|
|
|
35
35
|
addon_spaces_title: "Add-on stores",
|
|
36
36
|
addon_spaces_empty: definePhiMessageLabel("No Add-on holds files on this site."),
|
|
37
37
|
submit_label: "Save",
|
|
38
|
+
storage_title: "Storage",
|
|
39
|
+
storage_description: definePhiMessageLabel("Where this site's Spaces write new uploads. The storage profiles themselves are created by the operator; changing where a Space writes moves no files."),
|
|
40
|
+
storage_site_space_label: "Site Space",
|
|
41
|
+
storage_site_space_hint: definePhiMessageLabel("Where uploads into the site's own media go."),
|
|
42
|
+
storage_site_space_required: definePhiMessageLabel("Choose where the site's own media is stored."),
|
|
43
|
+
storage_default_user_label: "New User Spaces",
|
|
44
|
+
storage_default_user_hint: definePhiMessageLabel("Where a User Space created from now on writes. Existing User Spaces keep theirs."),
|
|
45
|
+
storage_default_group_label: "New Group Spaces",
|
|
46
|
+
storage_default_group_hint: definePhiMessageLabel("Where a Group Space created from now on writes. Existing Group Spaces keep theirs."),
|
|
47
|
+
storage_local_placeholder: "Local storage",
|
|
48
|
+
storage_allowed_label: "Offered profiles",
|
|
49
|
+
storage_allowed_hint: definePhiMessageLabel("The storage profiles a Space may be pointed at. Empty offers every profile."),
|
|
50
|
+
storage_all_placeholder: "All profiles",
|
|
51
|
+
storage_disabled_label: "Paused profiles",
|
|
52
|
+
storage_disabled_hint: definePhiMessageLabel("A paused profile still delivers what it holds but takes no new uploads."),
|
|
53
|
+
storage_none_placeholder: "None",
|
|
54
|
+
spaces_title: "Spaces",
|
|
55
|
+
spaces_description: definePhiMessageLabel("The User and Group Spaces that exist, with the storage profile each writes to and its own quota. A Space without a quota of its own follows the site default; changing its profile moves no files."),
|
|
56
|
+
spaces_user_table: "User Spaces",
|
|
57
|
+
spaces_group_table: "Group Spaces",
|
|
58
|
+
spaces_owner: "Owner",
|
|
59
|
+
spaces_email: "Email",
|
|
60
|
+
spaces_profile: "Storage profile",
|
|
61
|
+
spaces_quota: "Own quota",
|
|
62
|
+
spaces_quota_hint: definePhiMessageLabel("Empty follows the site default for this kind of Space."),
|
|
63
|
+
spaces_effective: "Applies",
|
|
64
|
+
spaces_used: "Used",
|
|
65
|
+
spaces_search: "Search",
|
|
66
|
+
spaces_empty: definePhiMessageLabel("No Space of this kind exists yet."),
|
|
38
67
|
},
|
|
39
68
|
});
|
|
40
69
|
export async function getPhiMediaSettingsPageLabels(options) {
|
|
@@ -78,6 +107,39 @@ export async function getPhiMediaSettingsPageLabels(options) {
|
|
|
78
107
|
title: labels.addon_spaces_title,
|
|
79
108
|
empty: labels.addon_spaces_empty,
|
|
80
109
|
},
|
|
110
|
+
storage: {
|
|
111
|
+
title: labels.storage_title,
|
|
112
|
+
description: labels.storage_description,
|
|
113
|
+
siteSpace: labels.storage_site_space_label,
|
|
114
|
+
siteSpaceHint: labels.storage_site_space_hint,
|
|
115
|
+
siteSpaceRequired: labels.storage_site_space_required,
|
|
116
|
+
defaultUser: labels.storage_default_user_label,
|
|
117
|
+
defaultUserHint: labels.storage_default_user_hint,
|
|
118
|
+
defaultGroup: labels.storage_default_group_label,
|
|
119
|
+
defaultGroupHint: labels.storage_default_group_hint,
|
|
120
|
+
local: labels.storage_local_placeholder,
|
|
121
|
+
allowed: labels.storage_allowed_label,
|
|
122
|
+
allowedHint: labels.storage_allowed_hint,
|
|
123
|
+
all: labels.storage_all_placeholder,
|
|
124
|
+
disabled: labels.storage_disabled_label,
|
|
125
|
+
disabledHint: labels.storage_disabled_hint,
|
|
126
|
+
none: labels.storage_none_placeholder,
|
|
127
|
+
},
|
|
128
|
+
spaces: {
|
|
129
|
+
title: labels.spaces_title,
|
|
130
|
+
description: labels.spaces_description,
|
|
131
|
+
userTable: labels.spaces_user_table,
|
|
132
|
+
groupTable: labels.spaces_group_table,
|
|
133
|
+
owner: labels.spaces_owner,
|
|
134
|
+
email: labels.spaces_email,
|
|
135
|
+
profile: labels.spaces_profile,
|
|
136
|
+
quota: labels.spaces_quota,
|
|
137
|
+
quotaHint: labels.spaces_quota_hint,
|
|
138
|
+
effective: labels.spaces_effective,
|
|
139
|
+
used: labels.spaces_used,
|
|
140
|
+
search: labels.spaces_search,
|
|
141
|
+
empty: labels.spaces_empty,
|
|
142
|
+
},
|
|
81
143
|
submitLabel: labels.submit_label,
|
|
82
144
|
};
|
|
83
145
|
}
|
|
@@ -138,7 +138,26 @@ type PhiMediaUploadInitSession = {
|
|
|
138
138
|
uploaded: readonly PhiMediaUploadStoredPart[];
|
|
139
139
|
/** Whether this session was taken over rather than opened, which only the Server can say. */
|
|
140
140
|
resumed: boolean;
|
|
141
|
+
/** Null where the Server asked for none: every plan but one sent in parts. */
|
|
142
|
+
heartbeat: PhiMediaUploadHeartbeat | null;
|
|
141
143
|
};
|
|
144
|
+
type PhiMediaUploadHeartbeat = {
|
|
145
|
+
url: string;
|
|
146
|
+
intervalMs: number;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Says, every so often, that this page is still sending the parts of this body.
|
|
150
|
+
*
|
|
151
|
+
* The beacon on `pagehide` covers a reload or a closed tab; a crashed tab, a killed browser or a power cut
|
|
152
|
+
* send nothing at all, and their session would sit as if a page were still writing into it. The Server tells
|
|
153
|
+
* the two apart by this: a session whose beat has lapsed may be continued by the next attempt at the same
|
|
154
|
+
* file, one that is still beating must not be. A 404 means the session is no longer being delivered
|
|
155
|
+
* (finalized, swept, taken over), and beating on would renew nothing. Failures are otherwise ignored: a
|
|
156
|
+
* missed beat costs at most a later continuation, never this upload.
|
|
157
|
+
*
|
|
158
|
+
* Returns the way to stop.
|
|
159
|
+
*/
|
|
160
|
+
export declare function keepPhiMediaUploadHeartbeat(heartbeat: PhiMediaUploadHeartbeat | null): () => void;
|
|
142
161
|
/**
|
|
143
162
|
* What a Client may say about a body it could not deliver.
|
|
144
163
|
*
|
|
@@ -101,6 +101,40 @@ function bindPhiMediaUploadAbort(signal, abort) {
|
|
|
101
101
|
signal.addEventListener("abort", abort, { once: true });
|
|
102
102
|
return () => signal.removeEventListener("abort", abort);
|
|
103
103
|
}
|
|
104
|
+
function readPhiMediaUploadHeartbeat(value) {
|
|
105
|
+
const url = value?.url;
|
|
106
|
+
const intervalMs = value?.intervalMs;
|
|
107
|
+
// A floor, so a Server that misstated the interval cannot turn this into a request loop.
|
|
108
|
+
return typeof url === "string" && url && typeof intervalMs === "number" && intervalMs >= 1_000
|
|
109
|
+
? { url, intervalMs }
|
|
110
|
+
: null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Says, every so often, that this page is still sending the parts of this body.
|
|
114
|
+
*
|
|
115
|
+
* The beacon on `pagehide` covers a reload or a closed tab; a crashed tab, a killed browser or a power cut
|
|
116
|
+
* send nothing at all, and their session would sit as if a page were still writing into it. The Server tells
|
|
117
|
+
* the two apart by this: a session whose beat has lapsed may be continued by the next attempt at the same
|
|
118
|
+
* file, one that is still beating must not be. A 404 means the session is no longer being delivered
|
|
119
|
+
* (finalized, swept, taken over), and beating on would renew nothing. Failures are otherwise ignored: a
|
|
120
|
+
* missed beat costs at most a later continuation, never this upload.
|
|
121
|
+
*
|
|
122
|
+
* Returns the way to stop.
|
|
123
|
+
*/
|
|
124
|
+
export function keepPhiMediaUploadHeartbeat(heartbeat) {
|
|
125
|
+
if (!heartbeat || typeof window === "undefined") {
|
|
126
|
+
return () => { };
|
|
127
|
+
}
|
|
128
|
+
const timer = window.setInterval(() => {
|
|
129
|
+
void fetch(heartbeat.url, { method: "POST", credentials: "same-origin" })
|
|
130
|
+
.then((response) => {
|
|
131
|
+
if (response.status === 404)
|
|
132
|
+
window.clearInterval(timer);
|
|
133
|
+
})
|
|
134
|
+
.catch(() => undefined);
|
|
135
|
+
}, heartbeat.intervalMs);
|
|
136
|
+
return () => window.clearInterval(timer);
|
|
137
|
+
}
|
|
104
138
|
/**
|
|
105
139
|
* What a Client may say about a body it could not deliver.
|
|
106
140
|
*
|
|
@@ -341,6 +375,7 @@ export async function initPhiMediaUploadSession(file, options, signal) {
|
|
|
341
375
|
expiresAt: payload.expiresAt,
|
|
342
376
|
uploaded,
|
|
343
377
|
resumed: payload.resumed === true,
|
|
378
|
+
heartbeat: payload.plan.kind === "multipart-put" ? readPhiMediaUploadHeartbeat(payload.heartbeat) : null,
|
|
344
379
|
};
|
|
345
380
|
}
|
|
346
381
|
/**
|
|
@@ -637,6 +672,7 @@ async function readPhiMediaUploadCancellation(run, signal) {
|
|
|
637
672
|
export async function runPhiMediaUploadSession(file, onProgress, options, signal) {
|
|
638
673
|
const init = await readPhiMediaUploadCancellation(() => initPhiMediaUploadSession(file, options, signal), signal);
|
|
639
674
|
const standDown = reportPhiMediaUploadAbandonmentOnLeaving(init.reportUrl, init.plan);
|
|
675
|
+
const stopBeating = keepPhiMediaUploadHeartbeat(init.heartbeat);
|
|
640
676
|
let upload;
|
|
641
677
|
try {
|
|
642
678
|
upload = await uploadPhiMediaUploadBody(init.plan, file, onProgress, init.uploaded, signal);
|
|
@@ -644,6 +680,7 @@ export async function runPhiMediaUploadSession(file, onProgress, options, signal
|
|
|
644
680
|
throwIfPhiMediaUploadAborted(signal);
|
|
645
681
|
}
|
|
646
682
|
catch (uploadError) {
|
|
683
|
+
stopBeating();
|
|
647
684
|
standDown();
|
|
648
685
|
// The Server cannot see this leg, so it is told rather than left to infer it from an expiry.
|
|
649
686
|
await reportPhiMediaUploadFailure(init.reportUrl, readPhiMediaUploadFailureReason(uploadError), uploadError instanceof Error ? uploadError.message : null);
|
|
@@ -659,6 +696,7 @@ export async function runPhiMediaUploadSession(file, onProgress, options, signal
|
|
|
659
696
|
* body that has already arrived. What this gives up is the sliver where somebody leaves after the body
|
|
660
697
|
* landed and before finalize was sent, and expiry already answers for that.
|
|
661
698
|
*/
|
|
699
|
+
stopBeating();
|
|
662
700
|
standDown();
|
|
663
701
|
const finalize = await finalizePhiMediaUploadSession(init.finalizeUrl, upload.completion);
|
|
664
702
|
return {
|
|
@@ -56,7 +56,7 @@ export function PhiAssetFocalRectWidget({ config, }) {
|
|
|
56
56
|
return _jsx(PhiAssetFocalRectEditor, { asset: asset, config: config }, asset?.id ?? "");
|
|
57
57
|
}
|
|
58
58
|
function PhiAssetFocalRectEditor({ asset, config, }) {
|
|
59
|
-
const currentRect = useMemo(() => normalizeMediaFocalRect(asset?.
|
|
59
|
+
const currentRect = useMemo(() => normalizeMediaFocalRect(asset?.focalRect), [asset?.focalRect]);
|
|
60
60
|
const [draft, setDraft] = useState(() => currentRect ?? createDefaultFocalRect());
|
|
61
61
|
const originalRef = useRef(currentRect);
|
|
62
62
|
const interactionRef = useRef(null);
|
|
@@ -131,7 +131,7 @@ function PhiAssetFocalRectEditor({ asset, config, }) {
|
|
|
131
131
|
const next = normalizeMediaFocalRect(draft);
|
|
132
132
|
updatePhiImagePreviewAsset(PHI_ASSET_CONTROLLER_STORE_KEY, asset.id, (current) => ({
|
|
133
133
|
...current,
|
|
134
|
-
|
|
134
|
+
focalRect: next,
|
|
135
135
|
}));
|
|
136
136
|
/*
|
|
137
137
|
* The rectangle, and not a field: which field it lands in is written on the route
|
|
@@ -5,7 +5,7 @@ import { PhiCascaderControl } from "../controls/phi-cascader-control";
|
|
|
5
5
|
import { PhiToolbarControl } from "../controls/phi-toolbar-control";
|
|
6
6
|
import { resolvePhiButtonIcon } from "../widgets/client/shared/phi-button-icons";
|
|
7
7
|
export function PhiAssetFolderControl({ value, options, placeholder, createLabel, showCreate = false, createDisabled = false, lock = null, allowClear = true, size, style, onChange, onCreate, }) {
|
|
8
|
-
const create = showCreate && onCreate ? (_jsx(PhiButtonControl, { ariaLabel: createLabel, tooltip: createLabel, icon: resolvePhiButtonIcon("
|
|
8
|
+
const create = showCreate && onCreate ? (_jsx(PhiButtonControl, { ariaLabel: createLabel, tooltip: createLabel, icon: resolvePhiButtonIcon("plus"), type: "primary", size: size, disabled: createDisabled, onClick: onCreate })) : null;
|
|
9
9
|
/*
|
|
10
10
|
* Drawn as the state it is in: a closed lock on a locked Folder, an open one on an unlocked one, and
|
|
11
11
|
* the tooltip names what pressing it does.
|
|
@@ -16,7 +16,7 @@ export function PhiAssetConfigWidget({ config, labels, sitePublicUrl }) {
|
|
|
16
16
|
valueType: "none",
|
|
17
17
|
typeKey: "image-inspector-focal-rect",
|
|
18
18
|
});
|
|
19
|
-
return selectedAsset ? (_jsx(PhiAssetInspectorSection, { section: config?.section ?? "preview", asset: selectedAsset, selectedVariantKey: state.selectedVariantKey, sitePublicUrl: sitePublicUrl, labels: labels, focalRect: normalizeMediaFocalRect(selectedAsset.
|
|
19
|
+
return selectedAsset ? (_jsx(PhiAssetInspectorSection, { section: config?.section ?? "preview", asset: selectedAsset, selectedVariantKey: state.selectedVariantKey, sitePublicUrl: sitePublicUrl, labels: labels, focalRect: normalizeMediaFocalRect(selectedAsset.focalRect), onVariantKeyChange: (nextVariantKey) => {
|
|
20
20
|
setPhiImagePreviewSelection(PHI_ASSET_CONTROLLER_STORE_KEY, selectedAsset.id, nextVariantKey ?? null, selectedAssetTile);
|
|
21
21
|
}, onFocalRectOpen: () => focalRectSignals.emitCapability("focalRectOpen", null) })) : null;
|
|
22
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PHI_MEDIA_SPACE_KINDS } from "@phis/contracts/media";
|
|
2
|
+
import { readPhiMediaFocalRectField, readPhiMediaFontField } from "./media-asset-typed-fields";
|
|
2
3
|
import { PhiImageAssetVariantKey, PhiMediaKind, resolvePhiMediaKindFromContentType } from "../../constants/media";
|
|
3
4
|
import { createPhiResponseReader, requirePhiField, } from "../widgets/config/strict-config-reader";
|
|
4
5
|
/*
|
|
@@ -95,7 +96,8 @@ function readPhiMediaAssetFields(reader) {
|
|
|
95
96
|
blurDataUrl: nullableString(reader, "blurDataUrl"),
|
|
96
97
|
thumbnailUrl: nullableString(reader, "thumbnailUrl"),
|
|
97
98
|
previewUrl: nullableString(reader, "previewUrl"),
|
|
98
|
-
|
|
99
|
+
focalRect: readPhiMediaFocalRectField(reader),
|
|
100
|
+
font: readPhiMediaFontField(reader),
|
|
99
101
|
title: nullableString(reader, "title"),
|
|
100
102
|
altText: nullableString(reader, "altText"),
|
|
101
103
|
lifecycleStatus: requiredInteger(reader, "lifecycleStatus"),
|
|
@@ -134,7 +136,6 @@ export function readPhiMediaPagination(value, source = PHI_MEDIA_LISTING) {
|
|
|
134
136
|
export function readPhiMediaAssetTiles(value, source = PHI_MEDIA_LISTING) {
|
|
135
137
|
return createPhiResponseReader({ assets: value }, source).list("assets", (reader) => {
|
|
136
138
|
const variantVersion = reader.integer("variantVersion");
|
|
137
|
-
const meta = reader.value("meta", "an object", (entry) => (isPlainRecord(entry) ? entry : undefined));
|
|
138
139
|
const blurDataUrl = reader.string("blurDataUrl");
|
|
139
140
|
const folder = reader.object("folder", (folderReader) => ({
|
|
140
141
|
id: requiredInteger(folderReader, "id"),
|
|
@@ -164,7 +165,8 @@ export function readPhiMediaAssetTiles(value, source = PHI_MEDIA_LISTING) {
|
|
|
164
165
|
deliveryRevision: requiredInteger(reader, "deliveryRevision"),
|
|
165
166
|
presentationFlags: requiredInteger(reader, "presentationFlags"),
|
|
166
167
|
...(blurDataUrl === undefined ? {} : { blurDataUrl }),
|
|
167
|
-
|
|
168
|
+
focalRect: readPhiMediaFocalRectField(reader),
|
|
169
|
+
font: readPhiMediaFontField(reader),
|
|
168
170
|
folder: folder ?? null,
|
|
169
171
|
};
|
|
170
172
|
}) ?? [];
|
|
@@ -238,7 +240,6 @@ export function normalizePhiImagePreviewSelectionAsset(tile) {
|
|
|
238
240
|
...rest,
|
|
239
241
|
kind: tile.kind,
|
|
240
242
|
blurDataUrl: tile.blurDataUrl ?? null,
|
|
241
|
-
meta: tile.meta ?? null,
|
|
242
243
|
folder: null,
|
|
243
244
|
variants: null,
|
|
244
245
|
};
|
|
@@ -4,9 +4,7 @@ import { PhiMediaKind } from "../../constants/media";
|
|
|
4
4
|
import { createPhiAssetUri } from "../../types/references";
|
|
5
5
|
import { usePhiCollectionProvider } from "../widgets/client/shared/phi-collection-provider";
|
|
6
6
|
import { PHI_ASSET_COLLECTION_DATA_SOURCE } from "./asset-collection-runtime";
|
|
7
|
-
import { readPhiFontMetricsFields } from "./media-font-metrics";
|
|
8
7
|
import { readPhiMediaAssetTiles } from "./phi-image-preview-data";
|
|
9
|
-
import { createPhiResponseReader } from "../widgets/config/strict-config-reader";
|
|
10
8
|
/**
|
|
11
9
|
* The typefaces a Site owns, as something a font slot can be set to.
|
|
12
10
|
*
|
|
@@ -21,9 +19,8 @@ import { createPhiResponseReader } from "../widgets/config/strict-config-reader"
|
|
|
21
19
|
/** Enough for any Site's own lettering; a ceiling rather than a page size. */
|
|
22
20
|
const PHI_SITE_FONT_ASSET_LIMIT = 100;
|
|
23
21
|
function readFontAssetMetrics(asset) {
|
|
24
|
-
//
|
|
25
|
-
return
|
|
26
|
-
.object("font", readPhiFontMetricsFields) ?? null;
|
|
22
|
+
// Read off the tile already: the management projection carries the metrics as a typed field.
|
|
23
|
+
return asset.font;
|
|
27
24
|
}
|
|
28
25
|
function readFontAssetLabel(asset) {
|
|
29
26
|
const family = readFontAssetMetrics(asset)?.familyName;
|
|
@@ -50,7 +50,6 @@ export function usePhiAuthoringAssetDetails(assetId) {
|
|
|
50
50
|
return {
|
|
51
51
|
...currentAssetTile,
|
|
52
52
|
blurDataUrl: currentAssetTile.blurDataUrl ?? null,
|
|
53
|
-
meta: currentAssetTile.meta ?? null,
|
|
54
53
|
folder: fetchedAsset?.folder ?? null,
|
|
55
54
|
variants: keepFetchedVariants ? fetchedAsset?.variants ?? null : null,
|
|
56
55
|
};
|
|
@@ -187,7 +187,7 @@ function buildEntryDialogNodes(nodes, input) {
|
|
|
187
187
|
* follows from that and is not stated -- a compact group does not wrap.
|
|
188
188
|
*/
|
|
189
189
|
buttons: [
|
|
190
|
-
{ key: "cancel", emits: [{ capabilityId: "close", value: null }], label: input.cancelLabel, icon: "
|
|
190
|
+
{ key: "cancel", emits: [{ capabilityId: "close", value: null }], label: input.cancelLabel, icon: "close" },
|
|
191
191
|
{ key: "save", emits: [{ capabilityId: "submit", value: null }], label: input.saveLabel, variant: "primary", icon: "save" },
|
|
192
192
|
],
|
|
193
193
|
signalRoutes: {
|
|
@@ -12,8 +12,8 @@ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../../types/cms"
|
|
|
12
12
|
/**
|
|
13
13
|
* The first place a navigation subtree actually goes.
|
|
14
14
|
*
|
|
15
|
-
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and an
|
|
16
|
-
* address is
|
|
15
|
+
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and neither an
|
|
16
|
+
* external address nor another Area's root is a place in the Area. Neither is the path the redirecting page itself answers: an Area root whose sidebar still carries an item pointing
|
|
17
17
|
* at "/" would forward to itself forever, which is the whole reason `skipPath` exists.
|
|
18
18
|
*/
|
|
19
19
|
export declare function findFirstPhiCmsNavigationLinkPath(items: readonly PhiCmsResolvedNavigationItem[], skipPath?: string): string | null;
|
|
@@ -12,13 +12,13 @@ import { readPhiCmsNavigationTargetPath } from "../../../helpers/navigation-targ
|
|
|
12
12
|
/**
|
|
13
13
|
* The first place a navigation subtree actually goes.
|
|
14
14
|
*
|
|
15
|
-
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and an
|
|
16
|
-
* address is
|
|
15
|
+
* An Overlay opener is not a destination, so it can never be what a redirect lands on, and neither an
|
|
16
|
+
* external address nor another Area's root is a place in the Area. Neither is the path the redirecting page itself answers: an Area root whose sidebar still carries an item pointing
|
|
17
17
|
* at "/" would forward to itself forever, which is the whole reason `skipPath` exists.
|
|
18
18
|
*/
|
|
19
19
|
export function findFirstPhiCmsNavigationLinkPath(items, skipPath) {
|
|
20
20
|
for (const item of items) {
|
|
21
|
-
const path = item.target?.kind === "custom" && item.target.external === true
|
|
21
|
+
const path = (item.target?.kind === "custom" && item.target.external === true) || item.target?.kind === "area"
|
|
22
22
|
? null
|
|
23
23
|
: readPhiCmsNavigationTargetPath(item.target);
|
|
24
24
|
if (item.kind === "link" && path && path !== skipPath) {
|
|
@@ -78,7 +78,8 @@ export function buildPhiAreaShellHeaderNodes({ nodes, runtime, labelPrefix, ids,
|
|
|
78
78
|
slotIndex: PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX.Middle,
|
|
79
79
|
sortOrder: 0,
|
|
80
80
|
label: "Page title",
|
|
81
|
-
|
|
81
|
+
/* A caption in the bar: the Page's heading is the Page's. */
|
|
82
|
+
config: { display: "label" },
|
|
82
83
|
}),
|
|
83
84
|
nodes.widget({
|
|
84
85
|
typeKey: "account",
|
|
@@ -308,7 +308,7 @@ export function buildPhiSettingsPageShellTree({ page, ownerModuleId, presetKey,
|
|
|
308
308
|
key: "cancel",
|
|
309
309
|
emits: [{ capabilityId: "close", value: null }],
|
|
310
310
|
...(overlay.cancelLabel ? { label: overlay.cancelLabel } : { action: "cancel" }),
|
|
311
|
-
icon: "
|
|
311
|
+
icon: "close",
|
|
312
312
|
},
|
|
313
313
|
{
|
|
314
314
|
key: "submit",
|
|
@@ -9,6 +9,7 @@ declare const PHI_ANTD_ICON_LOADERS: {
|
|
|
9
9
|
readonly AppstoreOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/AppstoreOutlined")>;
|
|
10
10
|
readonly ArrowDownOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/ArrowDownOutlined")>;
|
|
11
11
|
readonly ArrowUpOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/ArrowUpOutlined")>;
|
|
12
|
+
readonly AuditOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/AuditOutlined")>;
|
|
12
13
|
readonly AudioTwoTone: () => Promise<typeof import("@ant-design/icons/es/icons/AudioTwoTone")>;
|
|
13
14
|
readonly BgColorsOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/BgColorsOutlined")>;
|
|
14
15
|
readonly BlockOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/BlockOutlined")>;
|
|
@@ -60,6 +61,7 @@ declare const PHI_ANTD_ICON_LOADERS: {
|
|
|
60
61
|
readonly LayoutOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LayoutOutlined")>;
|
|
61
62
|
readonly LeftOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LeftOutlined")>;
|
|
62
63
|
readonly LinkOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LinkOutlined")>;
|
|
64
|
+
readonly LoginOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LoginOutlined")>;
|
|
63
65
|
readonly LockOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LockOutlined")>;
|
|
64
66
|
readonly LogoutOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/LogoutOutlined")>;
|
|
65
67
|
readonly MailOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/MailOutlined")>;
|
|
@@ -76,6 +78,8 @@ declare const PHI_ANTD_ICON_LOADERS: {
|
|
|
76
78
|
readonly PauseCircleOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/PauseCircleOutlined")>;
|
|
77
79
|
readonly PlayCircleFilled: () => Promise<typeof import("@ant-design/icons-svg/es/asn/PlayCircleFilled")>;
|
|
78
80
|
readonly PlayCircleOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/PlayCircleOutlined")>;
|
|
81
|
+
readonly PlusCircleOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/PlusCircleOutlined")>;
|
|
82
|
+
readonly OrderedListOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/OrderedListOutlined")>;
|
|
79
83
|
readonly PlusOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/PlusOutlined")>;
|
|
80
84
|
readonly ProfileOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/ProfileOutlined")>;
|
|
81
85
|
readonly QuestionCircleOutlined: () => Promise<typeof import("@ant-design/icons-svg/es/asn/QuestionCircleOutlined")>;
|
|
@@ -30,6 +30,7 @@ const PHI_ANTD_ICON_LOADERS = {
|
|
|
30
30
|
AppstoreOutlined: () => import("@ant-design/icons-svg/es/asn/AppstoreOutlined"),
|
|
31
31
|
ArrowDownOutlined: () => import("@ant-design/icons-svg/es/asn/ArrowDownOutlined"),
|
|
32
32
|
ArrowUpOutlined: () => import("@ant-design/icons-svg/es/asn/ArrowUpOutlined"),
|
|
33
|
+
AuditOutlined: () => import("@ant-design/icons-svg/es/asn/AuditOutlined"),
|
|
33
34
|
AudioTwoTone: () => import("@ant-design/icons/es/icons/AudioTwoTone"),
|
|
34
35
|
BgColorsOutlined: () => import("@ant-design/icons-svg/es/asn/BgColorsOutlined"),
|
|
35
36
|
BlockOutlined: () => import("@ant-design/icons-svg/es/asn/BlockOutlined"),
|
|
@@ -81,6 +82,7 @@ const PHI_ANTD_ICON_LOADERS = {
|
|
|
81
82
|
LayoutOutlined: () => import("@ant-design/icons-svg/es/asn/LayoutOutlined"),
|
|
82
83
|
LeftOutlined: () => import("@ant-design/icons-svg/es/asn/LeftOutlined"),
|
|
83
84
|
LinkOutlined: () => import("@ant-design/icons-svg/es/asn/LinkOutlined"),
|
|
85
|
+
LoginOutlined: () => import("@ant-design/icons-svg/es/asn/LoginOutlined"),
|
|
84
86
|
LockOutlined: () => import("@ant-design/icons-svg/es/asn/LockOutlined"),
|
|
85
87
|
LogoutOutlined: () => import("@ant-design/icons-svg/es/asn/LogoutOutlined"),
|
|
86
88
|
MailOutlined: () => import("@ant-design/icons-svg/es/asn/MailOutlined"),
|
|
@@ -97,6 +99,8 @@ const PHI_ANTD_ICON_LOADERS = {
|
|
|
97
99
|
PauseCircleOutlined: () => import("@ant-design/icons-svg/es/asn/PauseCircleOutlined"),
|
|
98
100
|
PlayCircleFilled: () => import("@ant-design/icons-svg/es/asn/PlayCircleFilled"),
|
|
99
101
|
PlayCircleOutlined: () => import("@ant-design/icons-svg/es/asn/PlayCircleOutlined"),
|
|
102
|
+
PlusCircleOutlined: () => import("@ant-design/icons-svg/es/asn/PlusCircleOutlined"),
|
|
103
|
+
OrderedListOutlined: () => import("@ant-design/icons-svg/es/asn/OrderedListOutlined"),
|
|
100
104
|
PlusOutlined: () => import("@ant-design/icons-svg/es/asn/PlusOutlined"),
|
|
101
105
|
ProfileOutlined: () => import("@ant-design/icons-svg/es/asn/ProfileOutlined"),
|
|
102
106
|
QuestionCircleOutlined: () => import("@ant-design/icons-svg/es/asn/QuestionCircleOutlined"),
|
|
@@ -275,6 +279,7 @@ export const PHI_ANTD_ICON_NAMES = {
|
|
|
275
279
|
"arrow-down-outlined": "ArrowDownOutlined",
|
|
276
280
|
"arrow-up": "ArrowUpOutlined",
|
|
277
281
|
"arrow-up-outlined": "ArrowUpOutlined",
|
|
282
|
+
"audit": "AuditOutlined",
|
|
278
283
|
"audio-two-tone": "AudioTwoTone",
|
|
279
284
|
"bg-colors": "BgColorsOutlined",
|
|
280
285
|
"bg-colors-outlined": "BgColorsOutlined",
|
|
@@ -326,6 +331,9 @@ export const PHI_ANTD_ICON_NAMES = {
|
|
|
326
331
|
"share-alt-outlined": "ShareAltOutlined",
|
|
327
332
|
sun: "SunOutlined",
|
|
328
333
|
"sun-outlined": "SunOutlined",
|
|
334
|
+
"ordered-list-outlined": "OrderedListOutlined",
|
|
335
|
+
"login": "LoginOutlined",
|
|
336
|
+
"plus-circle-outlined": "PlusCircleOutlined",
|
|
329
337
|
"unordered-list": "UnorderedListOutlined",
|
|
330
338
|
"unordered-list-outlined": "UnorderedListOutlined",
|
|
331
339
|
up: "UpOutlined",
|
|
@@ -8,5 +8,23 @@ type PhiIconProps = {
|
|
|
8
8
|
name?: string;
|
|
9
9
|
size?: number | string;
|
|
10
10
|
} & PhiAntdIconPresentation;
|
|
11
|
+
/**
|
|
12
|
+
* Whether `PhiIcon` draws something for `name`: the one rule every icon name in this house follows.
|
|
13
|
+
*
|
|
14
|
+
* A name without a prefix is an Ant Design icon from `PHI_ANTD_ICON_NAMES` and means the same as
|
|
15
|
+
* `antd:<name>`. One name per icon, and the same name in a Button, a Table action, a Command Toolbar and a
|
|
16
|
+
* preset: there are no aliases (`add`, `cancel`, `trash`) beside it, and case counts. `module:`,
|
|
17
|
+
* `iconify:`, `asset:` and the Builder's motif namespaces are drawn by their own owners, which say for
|
|
18
|
+
* themselves whether the name exists, so here they count as known.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isPhiIconNameKnown(name: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Says once per name that it names no icon, where somebody reads it.
|
|
23
|
+
*
|
|
24
|
+
* An unknown name draws nothing -- no word, no placeholder -- so without this a typo is a blank nobody
|
|
25
|
+
* notices. Rendered on the server the warning lands in the Site service's journal, in the browser in its
|
|
26
|
+
* console. `validate-preset-icon-vocabulary` catches the same mistake in a preset before it ships.
|
|
27
|
+
*/
|
|
28
|
+
export declare function reportPhiUnknownIconName(name: string): void;
|
|
11
29
|
export declare function PhiIcon({ name, size, ...presentation }: PhiIconProps): import("react").JSX.Element | null;
|
|
12
30
|
export {};
|
|
@@ -28,14 +28,57 @@ function renderIconFallback(size) {
|
|
|
28
28
|
height: size,
|
|
29
29
|
} }));
|
|
30
30
|
}
|
|
31
|
+
function isPhiBuilderIconNamespace(namespace) {
|
|
32
|
+
return namespace.endsWith("/layouts") || namespace.endsWith("/widgets");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether `PhiIcon` draws something for `name`: the one rule every icon name in this house follows.
|
|
36
|
+
*
|
|
37
|
+
* A name without a prefix is an Ant Design icon from `PHI_ANTD_ICON_NAMES` and means the same as
|
|
38
|
+
* `antd:<name>`. One name per icon, and the same name in a Button, a Table action, a Command Toolbar and a
|
|
39
|
+
* preset: there are no aliases (`add`, `cancel`, `trash`) beside it, and case counts. `module:`,
|
|
40
|
+
* `iconify:`, `asset:` and the Builder's motif namespaces are drawn by their own owners, which say for
|
|
41
|
+
* themselves whether the name exists, so here they count as known.
|
|
42
|
+
*/
|
|
43
|
+
export function isPhiIconNameKnown(name) {
|
|
44
|
+
const [namespace, ...rest] = name.split(":");
|
|
45
|
+
const value = rest.join(":");
|
|
46
|
+
if (!value)
|
|
47
|
+
return Object.hasOwn(PHI_ANTD_ICON_NAMES, name);
|
|
48
|
+
if (isPhiBuilderIconNamespace(namespace))
|
|
49
|
+
return true;
|
|
50
|
+
switch (namespace) {
|
|
51
|
+
case PHI_MODULE_ICON_NAMESPACE:
|
|
52
|
+
case "iconify":
|
|
53
|
+
case "asset":
|
|
54
|
+
return true;
|
|
55
|
+
case "antd":
|
|
56
|
+
return Object.hasOwn(PHI_ANTD_ICON_NAMES, value);
|
|
57
|
+
default:
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const reportedUnknownIconNames = new Set();
|
|
62
|
+
/**
|
|
63
|
+
* Says once per name that it names no icon, where somebody reads it.
|
|
64
|
+
*
|
|
65
|
+
* An unknown name draws nothing -- no word, no placeholder -- so without this a typo is a blank nobody
|
|
66
|
+
* notices. Rendered on the server the warning lands in the Site service's journal, in the browser in its
|
|
67
|
+
* console. `validate-preset-icon-vocabulary` catches the same mistake in a preset before it ships.
|
|
68
|
+
*/
|
|
69
|
+
export function reportPhiUnknownIconName(name) {
|
|
70
|
+
if (reportedUnknownIconNames.has(name))
|
|
71
|
+
return;
|
|
72
|
+
reportedUnknownIconNames.add(name);
|
|
73
|
+
console.warn(`[phi-icon] "${name}" names no icon and draws nothing. Use a name from PHI_ANTD_ICON_NAMES `
|
|
74
|
+
+ "(components/shell/phi-antd-icon.tsx), with or without `antd:`, or a `module:`, `iconify:` or `asset:` name.");
|
|
75
|
+
}
|
|
31
76
|
function renderAntdIcon(key, size, presentation) {
|
|
32
77
|
const icon = PHI_ANTD_ICON_NAMES[key];
|
|
33
78
|
return icon ? _jsx(PhiAntdIcon, { icon: icon, size: size, ...presentation }) : null;
|
|
34
79
|
}
|
|
35
80
|
function renderBuilderIcon(namespace, motif, size) {
|
|
36
|
-
|
|
37
|
-
const isWidgetNamespace = namespace.endsWith("/widgets");
|
|
38
|
-
if (!isLayoutNamespace && !isWidgetNamespace) {
|
|
81
|
+
if (!isPhiBuilderIconNamespace(namespace)) {
|
|
39
82
|
return null;
|
|
40
83
|
}
|
|
41
84
|
return (_jsx(Suspense, { fallback: renderIconFallback(size), children: _jsx(LazyPhiBuilderMotifIcon, { namespace: namespace, motif: motif, size: size }) }));
|
|
@@ -74,6 +117,10 @@ export function PhiIcon({ name, size = 16, ...presentation }) {
|
|
|
74
117
|
if (!name) {
|
|
75
118
|
return null;
|
|
76
119
|
}
|
|
120
|
+
if (!isPhiIconNameKnown(name)) {
|
|
121
|
+
reportPhiUnknownIconName(name);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
77
124
|
const resolvedSize = size === "inherit" ? "1em" : size;
|
|
78
125
|
const [namespace, ...rest] = name.split(":");
|
|
79
126
|
const value = rest.join(":");
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The icon a Button, a Table action or a Command Toolbar names, or null where the name draws nothing.
|
|
4
|
+
*
|
|
5
|
+
* The same rule as `PhiIcon` (`isPhiIconNameKnown`): a short name is the Ant Design icon of that name,
|
|
6
|
+
* one name per icon. Null rather than an empty element, because a Table falls back to the action's label
|
|
7
|
+
* where its icon does not resolve and asks this to find out.
|
|
8
|
+
*/
|
|
2
9
|
export declare function resolvePhiButtonIcon(icon: string | null | undefined): ReactNode;
|