@phis/ui 0.8.1 → 0.8.3
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/README.md +9 -2
- package/components/calendar/gregory-calendar-adapter-client.js +1 -0
- package/components/controls/phi-accordion-control.d.ts +6 -0
- package/components/controls/phi-accordion-control.js +8 -13
- package/components/controls/phi-background-control.js +2 -5
- package/components/controls/phi-builder-insert-picker-control-labels.d.ts +2 -0
- package/components/controls/phi-builder-insert-picker-control-labels.js +1 -0
- package/components/controls/phi-builder-insert-picker-control.js +10 -11
- package/components/controls/phi-cascader-control.d.ts +9 -3
- package/components/controls/phi-cascader-control.js +38 -10
- package/components/controls/phi-checkbox-group-control.d.ts +3 -1
- package/components/controls/phi-checkbox-group-control.js +2 -2
- package/components/controls/phi-collapse-control.d.ts +9 -2
- package/components/controls/phi-collapse-control.js +14 -2
- package/components/controls/phi-color-control.d.ts +3 -1
- package/components/controls/phi-color-control.js +2 -2
- package/components/controls/phi-color-field-control.d.ts +6 -1
- package/components/controls/phi-color-field-control.js +2 -2
- package/components/controls/phi-confirm-control.d.ts +1 -1
- package/components/controls/phi-confirm-control.js +71 -2
- package/components/controls/phi-confirm-dialog.js +2 -1
- package/components/controls/phi-date-picker-control.js +1 -1
- package/components/controls/phi-dimension-control.d.ts +3 -1
- package/components/controls/phi-dimension-control.js +2 -2
- package/components/controls/phi-geometry-control.js +1 -1
- package/components/controls/phi-length-control.d.ts +6 -1
- package/components/controls/phi-length-control.js +3 -2
- package/components/controls/phi-multi-select-control.d.ts +6 -1
- package/components/controls/phi-multi-select-control.js +3 -3
- package/components/controls/phi-segmented-control.d.ts +6 -1
- package/components/controls/phi-segmented-control.js +3 -3
- package/components/controls/phi-switch-control.d.ts +3 -1
- package/components/controls/phi-switch-control.js +3 -3
- package/components/controls/phi-table-control.d.ts +8 -1
- package/components/controls/phi-table-control.js +11 -5
- package/components/forms/compound-form-controls.js +16 -1
- package/components/layouts/clients/phi-collapsible-layout-client.js +2 -6
- package/components/media/media-upload-flow.d.ts +62 -5
- package/components/media/media-upload-flow.js +62 -24
- package/components/media/media-widget-labels.d.ts +2 -0
- package/components/media/media-widget-labels.js +2 -0
- package/components/media/phi-area-upload-widget.d.ts +44 -1
- package/components/media/phi-area-upload-widget.js +32 -7
- package/components/media/phi-asset-inspector-section.js +19 -1
- package/components/media/phi-media-upload.d.ts +10 -3
- package/components/media/phi-media-upload.js +11 -8
- package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -0
- package/components/shell/phi-builder-icon.js +9 -1
- package/components/shell/phi-widget-icon.js +1 -0
- package/components/tables/phi-table-surface.d.ts +25 -0
- package/components/tables/phi-table-surface.js +25 -0
- package/components/widgets/builder/phi-static-rows-editor.js +4 -1
- package/components/widgets/client/html-editor-link-node.d.ts +12 -0
- package/components/widgets/client/html-editor-link-node.js +60 -0
- package/components/widgets/client/html-editor.js +10 -6
- package/components/widgets/client/shared/phi-choice-controller.d.ts +8 -1
- package/components/widgets/client/shared/phi-choice-controller.js +16 -1
- package/components/widgets/client/shared/phi-collection-view-binding.js +33 -26
- package/components/widgets/config/choice-shared.d.ts +2 -0
- package/components/widgets/config/choice-shared.js +1 -0
- package/components/widgets/config/image-variant-options.d.ts +4 -1
- package/components/widgets/config/image-variant-options.js +27 -14
- package/components/widgets/inspector-field-row.d.ts +14 -1
- package/components/widgets/inspector-field-row.js +21 -1
- package/components/widgets/label-sets/builder-chrome.js +2 -0
- package/components/widgets/label-sets/inspector.js +10 -0
- package/components/widgets/label-sets/security.js +2 -0
- package/components/widgets/label-types/inspector.d.ts +5 -0
- package/components/widgets/label-types/inspector.js +5 -0
- package/components/widgets/label-types/security.d.ts +2 -0
- package/components/widgets/signals/signal-endpoint-list.js +4 -1
- package/constants/cms-widget-types.d.ts +1 -0
- package/constants/cms-widget-types.js +3 -0
- package/constants/runtime-module-ownership.js +1 -0
- package/gateway/site-proxy.d.ts +12 -0
- package/gateway/site-proxy.js +20 -0
- package/helpers/cms-inspector-drawer.d.ts +15 -0
- package/helpers/cms-inspector-drawer.js +37 -0
- package/helpers/cms-layout-defaults.js +1 -1
- package/helpers/preset-tree-contract-check.js +56 -0
- package/helpers/text-source.js +2 -0
- package/net/phi-next-proxy.d.ts +7 -0
- package/net/phi-next-proxy.js +1 -1
- package/package.json +27 -14
- package/plugins/runtime-modules/accounting/definition.d.ts +1 -1
- package/plugins/runtime-modules/accounting/definition.js +0 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +4 -4
- package/plugins/runtime-modules/accounting/ids.js +4 -2
- package/plugins/runtime-modules/accounting/module.d.ts +1 -1
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +2 -1
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +5 -4
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +80 -38
- package/plugins/runtime-modules/admin/definition.d.ts +1 -1
- package/plugins/runtime-modules/admin/definition.js +0 -1
- package/plugins/runtime-modules/admin/module.d.ts +1 -1
- package/plugins/runtime-modules/app/definition.d.ts +1 -1
- package/plugins/runtime-modules/app/definition.js +0 -1
- package/plugins/runtime-modules/app/module.d.ts +1 -1
- package/plugins/runtime-modules/area-base-definition.d.ts +19 -1
- package/plugins/runtime-modules/area-base-definition.js +18 -0
- package/plugins/runtime-modules/area-contributions/admin.d.ts +1 -1
- package/plugins/runtime-modules/area-contributions/admin.js +2 -0
- package/plugins/runtime-modules/area-definitions.d.ts +8 -8
- package/plugins/runtime-modules/area-definitions.js +4 -3
- package/plugins/runtime-modules/area-root-route.d.ts +8 -0
- package/plugins/runtime-modules/area-root-route.js +11 -1
- package/plugins/runtime-modules/asset/labels.js +4 -0
- package/plugins/runtime-modules/asset/metadata-form.d.ts +0 -28
- package/plugins/runtime-modules/asset/metadata-form.js +6 -10
- package/plugins/runtime-modules/asset/services/options.d.ts +3 -2
- package/plugins/runtime-modules/asset/services/options.js +4 -3
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +2 -1
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +3 -3
- package/plugins/runtime-modules/auth/widgets/security/client.js +2 -2
- package/plugins/runtime-modules/avatar/addresses.d.ts +1 -1
- package/plugins/runtime-modules/builder/addresses.d.ts +1 -1
- package/plugins/runtime-modules/builder/addresses.js +1 -1
- package/plugins/runtime-modules/builder/area-settings-form.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-condition-group.d.ts +16 -0
- package/plugins/runtime-modules/builder/clients/inspector-condition-group.js +9 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +97 -10
- package/plugins/runtime-modules/builder/clients/pages-header.js +7 -6
- package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +7 -4
- package/plugins/runtime-modules/builder/definition.d.ts +1 -1
- package/plugins/runtime-modules/builder/definition.js +0 -1
- package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +10 -4
- package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -8
- package/plugins/runtime-modules/builder/page-meta-form.js +5 -2
- package/plugins/runtime-modules/builder/plugin-meta-labels.js +8 -0
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +4 -2
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +20 -13
- package/plugins/runtime-modules/builder/workspace-catalog-actions.js +8 -1
- package/plugins/runtime-modules/cdn/authoring-widgets.d.ts +3 -0
- package/plugins/runtime-modules/cdn/authoring-widgets.js +7 -0
- package/plugins/runtime-modules/cdn/authoring.d.ts +1 -0
- package/plugins/runtime-modules/cdn/authoring.js +8 -0
- package/plugins/runtime-modules/cdn/bytes.d.ts +5 -0
- package/plugins/runtime-modules/cdn/bytes.js +17 -0
- package/plugins/runtime-modules/cdn/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/cdn/client-data-providers.js +9 -0
- package/plugins/runtime-modules/cdn/data-providers.d.ts +134 -0
- package/plugins/runtime-modules/cdn/data-providers.js +117 -0
- package/plugins/runtime-modules/cdn/definition.d.ts +140 -0
- package/plugins/runtime-modules/cdn/definition.js +23 -0
- package/plugins/runtime-modules/cdn/ids.d.ts +18 -0
- package/plugins/runtime-modules/cdn/ids.js +20 -0
- package/plugins/runtime-modules/cdn/module.d.ts +131 -0
- package/plugins/runtime-modules/cdn/module.js +4 -0
- package/plugins/runtime-modules/cdn/platform.d.ts +25 -0
- package/plugins/runtime-modules/cdn/platform.js +73 -0
- package/plugins/runtime-modules/cdn/presets.d.ts +2 -0
- package/plugins/runtime-modules/cdn/presets.js +20 -0
- package/plugins/runtime-modules/cdn/server.d.ts +1 -0
- package/plugins/runtime-modules/cdn/server.js +14 -0
- package/plugins/runtime-modules/cdn/services/table.d.ts +11 -0
- package/plugins/runtime-modules/cdn/services/table.js +296 -0
- package/plugins/runtime-modules/cdn/services/upload.d.ts +20 -0
- package/plugins/runtime-modules/cdn/services/upload.js +146 -0
- package/plugins/runtime-modules/cdn/table-params.d.ts +10 -0
- package/plugins/runtime-modules/cdn/table-params.js +10 -0
- package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.d.ts +95 -0
- package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.js +156 -0
- package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.d.ts +18 -0
- package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.js +491 -0
- package/plugins/runtime-modules/cdn/widgets/upload/client.d.ts +12 -0
- package/plugins/runtime-modules/cdn/widgets/upload/client.js +138 -0
- package/plugins/runtime-modules/cdn/widgets/upload/config.d.ts +29 -0
- package/plugins/runtime-modules/cdn/widgets/upload/config.js +43 -0
- package/plugins/runtime-modules/cdn/widgets/upload/label-types.d.ts +24 -0
- package/plugins/runtime-modules/cdn/widgets/upload/label-types.js +1 -0
- package/plugins/runtime-modules/cdn/widgets/upload/labels.d.ts +4 -0
- package/plugins/runtime-modules/cdn/widgets/upload/labels.js +72 -0
- package/plugins/runtime-modules/cdn/widgets/upload/plugin.d.ts +3 -0
- package/plugins/runtime-modules/cdn/widgets/upload/plugin.js +7 -0
- package/plugins/runtime-modules/cdn/widgets/upload/server.d.ts +8 -0
- package/plugins/runtime-modules/cdn/widgets/upload/server.js +17 -0
- package/plugins/runtime-modules/cdn/widgets.d.ts +2 -0
- package/plugins/runtime-modules/cdn/widgets.js +13 -0
- package/plugins/runtime-modules/client-authoring-providers/admin.d.ts +1 -1
- package/plugins/runtime-modules/client-authoring-providers/admin.js +6 -0
- package/plugins/runtime-modules/client-manifests/admin.js +11 -1
- package/plugins/runtime-modules/core/authoring-widgets.js +2 -1
- package/plugins/runtime-modules/core/messaging/label-defaults.d.ts +49 -0
- package/plugins/runtime-modules/core/messaging/label-defaults.js +48 -0
- package/plugins/runtime-modules/core/messaging/labels.d.ts +2 -28
- package/plugins/runtime-modules/core/messaging/labels.js +52 -23
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +3 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/select-box/client.js +13 -4
- package/plugins/runtime-modules/core/widgets/select-box/config.js +1 -0
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/table/client.js +17 -8
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +1 -1143
- package/plugins/runtime-modules/core/widgets/table/config.js +144 -125
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.d.ts +2 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.js +76 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.d.ts +44 -1
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +28 -13
- package/plugins/runtime-modules/editor/definition.d.ts +1 -1
- package/plugins/runtime-modules/editor/definition.js +0 -1
- package/plugins/runtime-modules/editor/module.d.ts +1 -1
- package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +16 -8
- package/plugins/runtime-modules/public/definition.d.ts +1 -1
- package/plugins/runtime-modules/public/definition.js +0 -1
- package/plugins/runtime-modules/public/module.d.ts +1 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +109 -86
- package/plugins/runtime-modules/threads/controller/client.js +10 -12
- package/plugins/runtime-modules/threads/controller/definition.d.ts +6 -0
- package/plugins/runtime-modules/threads/controller/definition.js +17 -6
- package/styles/controls.css +49 -1
- package/styles/layout.css +3 -2
- package/types/calendar.d.ts +5 -0
- package/types/cms-plugins.d.ts +30 -10
- package/types/table-widget.d.ts +8 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import type { PhiCmsAreaUploadWidgetConfig } from "../../types/media";
|
|
2
3
|
import type { PhiMediaAssetTile } from "../../types/media";
|
|
3
4
|
import type { PhiCollectionProviderQuery } from "../../types/collection-provider";
|
|
4
5
|
import type { PhiAreaUploadWidgetLabels } from "./media-widget-labels";
|
|
6
|
+
import { type PhiMediaUploadSessionRunner, type PhiUploadPhase } from "./media-upload-flow";
|
|
5
7
|
import { type PhiMediaUploadAcceptance } from "./phi-media-upload";
|
|
6
8
|
import { type PhiImagePreviewStoreState } from "./phi-image-preview-store";
|
|
7
9
|
export type PhiAreaUploadWidgetProps = {
|
|
@@ -44,5 +46,46 @@ export type PhiAreaUploadWidgetProps = {
|
|
|
44
46
|
query: PhiCollectionProviderQuery;
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
|
-
|
|
49
|
+
/**
|
|
50
|
+
* A Module's own upload through this surface, in place of the Media library's: its fields stand in front
|
|
51
|
+
* of the file, its runner takes the file somewhere else (`runPhiUploadSession` with the Module's target),
|
|
52
|
+
* and what arrived is the Module's to show. The drop area, the file's tile with its progress, its refusal
|
|
53
|
+
* and its retry, and the stop when the surface goes away stay this surface's. The CDN page's upload is
|
|
54
|
+
* the one that asked: a file published under a name, a version and a file name the person states.
|
|
55
|
+
*
|
|
56
|
+
* A file picked here is held until the person sends it (`startLabel`), because the Module's fields may
|
|
57
|
+
* start from it -- a file name, a platform read from the extension -- and are only complete once they do.
|
|
58
|
+
* One file at a time.
|
|
59
|
+
*
|
|
60
|
+
* Not part of `PhiAreaUploadWidgetProps`, which a Site can place: a target is code, never configuration.
|
|
61
|
+
*/
|
|
62
|
+
export type PhiAreaUploadModuleTarget<TResult> = {
|
|
63
|
+
/** The Module's fields, drawn in front of the file, told which file is held and whether one is on its way. */
|
|
64
|
+
renderFields: (state: {
|
|
65
|
+
file: File | null;
|
|
66
|
+
uploading: boolean;
|
|
67
|
+
}) => ReactNode;
|
|
68
|
+
/** A file was picked, for fields that start from it. */
|
|
69
|
+
onFilePicked?: (file: File) => void;
|
|
70
|
+
/** Whether the held file may be sent: the Module's fields hold what its target needs. */
|
|
71
|
+
ready: boolean;
|
|
72
|
+
startLabel: string;
|
|
73
|
+
cancelLabel: string;
|
|
74
|
+
/** Where the file goes (`usePhiMediaUpload`'s runner); its third argument, the Media init options, is unused. */
|
|
75
|
+
runSession: (...args: Parameters<PhiMediaUploadSessionRunner>) => Promise<{
|
|
76
|
+
asset: TResult;
|
|
77
|
+
}>;
|
|
78
|
+
/** The target's own words for a refusal; null falls back to the Media refusals. */
|
|
79
|
+
readError?: (error: unknown) => string | null;
|
|
80
|
+
/** What the file's tag says while it is hashed and while the target settles it, in place of a percentage. */
|
|
81
|
+
phaseLabels?: Partial<Record<PhiUploadPhase, string>>;
|
|
82
|
+
/** The abort reason Cancel stops the upload with, for a target that tells a stop from a discard. */
|
|
83
|
+
cancelReason?: unknown;
|
|
84
|
+
/** What arrived. The surface says so as it says it for an Asset, and holds no file any more. */
|
|
85
|
+
onUploaded: (result: TResult, file: File) => void;
|
|
86
|
+
};
|
|
87
|
+
export type PhiAreaUploadBindingProps = PhiAreaUploadWidgetProps & {
|
|
88
|
+
moduleTarget?: PhiAreaUploadModuleTarget<any>;
|
|
89
|
+
};
|
|
90
|
+
export declare function PhiAreaUploadBinding({ config, labels, onUploadComplete, acceptance, showFinished, onAssetUploaded, onUploadingChange, refuseFile, siteSpaceOnly, collectionContext, moduleTarget, }: PhiAreaUploadBindingProps): import("react").JSX.Element;
|
|
48
91
|
export declare function PhiAreaUploadWidget(props: PhiAreaUploadWidgetProps): import("react").JSX.Element;
|
|
@@ -39,6 +39,7 @@ function buildUploadWallItem(asset, localId) {
|
|
|
39
39
|
height: asset.height ?? null,
|
|
40
40
|
presentationFlags: asset.presentationFlags,
|
|
41
41
|
progress: 100,
|
|
42
|
+
phase: null,
|
|
42
43
|
status: "done",
|
|
43
44
|
deleting: false,
|
|
44
45
|
error: null,
|
|
@@ -60,6 +61,7 @@ function buildPendingWallItem(item, presentationFlags) {
|
|
|
60
61
|
height: null,
|
|
61
62
|
presentationFlags,
|
|
62
63
|
progress: item.progress,
|
|
64
|
+
phase: item.phase,
|
|
63
65
|
status: item.status,
|
|
64
66
|
deleting: false,
|
|
65
67
|
error: item.error,
|
|
@@ -68,7 +70,7 @@ function buildPendingWallItem(item, presentationFlags) {
|
|
|
68
70
|
function resolveUploadWallDisplayDimensions(item) {
|
|
69
71
|
return resolvePhiMediaAssetDisplayDimensions(item);
|
|
70
72
|
}
|
|
71
|
-
export function PhiAreaUploadBinding({ config, labels, onUploadComplete, acceptance, showFinished = true, onAssetUploaded, onUploadingChange, refuseFile, siteSpaceOnly = false, collectionContext, }) {
|
|
73
|
+
export function PhiAreaUploadBinding({ config, labels, onUploadComplete, acceptance, showFinished = true, onAssetUploaded, onUploadingChange, refuseFile, siteSpaceOnly = false, collectionContext, moduleTarget, }) {
|
|
72
74
|
const { token } = usePhiConfig();
|
|
73
75
|
const { showMessage } = usePhiApplicationFeedback();
|
|
74
76
|
const uploadTileFrameSize = token.controlHeight * 3;
|
|
@@ -78,7 +80,8 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, accepta
|
|
|
78
80
|
const [uploadWall, setUploadWall] = useState([]);
|
|
79
81
|
const allowDelete = config?.allowDelete ?? true;
|
|
80
82
|
const configAccept = config?.accept?.trim() || "*/*";
|
|
81
|
-
const multiple = config?.multiple ?? true;
|
|
83
|
+
const multiple = moduleTarget ? false : config?.multiple ?? true;
|
|
84
|
+
const [heldFile, setHeldFile] = useState(null);
|
|
82
85
|
const collectionFolderId = collectionContext?.folderId ?? null;
|
|
83
86
|
const collectionPresentationFlags = collectionContext?.presentationFlags ?? null;
|
|
84
87
|
const hasCollectionContext = collectionContext != null;
|
|
@@ -154,8 +157,16 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, accepta
|
|
|
154
157
|
labels: labels.refusals,
|
|
155
158
|
...(acceptance ? { acceptance } : {}),
|
|
156
159
|
initOptions: uploadInitOptions,
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
...(moduleTarget ? { runSession: moduleTarget.runSession } : {}),
|
|
161
|
+
...(moduleTarget?.readError ? { readError: moduleTarget.readError } : {}),
|
|
162
|
+
onUploaded: (result, file) => {
|
|
163
|
+
if (moduleTarget) {
|
|
164
|
+
setHeldFile(null);
|
|
165
|
+
showUploadMessage("success", labels.uploadSuccessTemplate.replace("%1", file.name));
|
|
166
|
+
moduleTarget.onUploaded(result, file);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const uploadedTile = normalizePhiImagePreviewTile(result, []);
|
|
159
170
|
if (showFinished) {
|
|
160
171
|
setUploadWall((current) => [buildUploadWallItem(uploadedTile, `asset-${uploadedTile.id}`), ...current]);
|
|
161
172
|
}
|
|
@@ -181,7 +192,15 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, accepta
|
|
|
181
192
|
.map((item) => buildPendingWallItem(item, uploadInitOptions.presentationFlags ?? 0)),
|
|
182
193
|
...uploadWall,
|
|
183
194
|
];
|
|
184
|
-
return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [_jsx(PhiUploadDropArea, { multiple: multiple, accept: accept, title: labels.dropTitle, hint: labels.dropHint, onFile: (file) => {
|
|
195
|
+
return (_jsxs(PhiFlexControl, { vertical: true, gap: 12, style: { width: "100%" }, children: [moduleTarget ? moduleTarget.renderFields({ file: heldFile, uploading }) : null, _jsx(PhiUploadDropArea, { multiple: multiple, accept: accept, title: moduleTarget && heldFile ? heldFile.name : labels.dropTitle, hint: labels.dropHint, onFile: (file) => {
|
|
196
|
+
if (moduleTarget) {
|
|
197
|
+
// Held, not sent: the Module's fields may start from it and are complete only once they do.
|
|
198
|
+
if (uploading)
|
|
199
|
+
return;
|
|
200
|
+
setHeldFile(file);
|
|
201
|
+
moduleTarget.onFilePicked?.(file);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
185
204
|
const refusal = refuseFile?.(file, sendingRef.current) ?? null;
|
|
186
205
|
if (refusal) {
|
|
187
206
|
showUploadMessage("error", refusal);
|
|
@@ -192,7 +211,12 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, accepta
|
|
|
192
211
|
void upload.upload(file).finally(() => {
|
|
193
212
|
sendingRef.current -= 1;
|
|
194
213
|
});
|
|
195
|
-
} }),
|
|
214
|
+
} }), moduleTarget ? (_jsxs(PhiFlexControl, { justify: "flex-end", gap: 8, children: [uploading ? (_jsx(PhiButtonControl, { label: moduleTarget.cancelLabel, onClick: () => upload.cancel(moduleTarget.cancelReason) })) : null, _jsx(PhiButtonControl, { type: "primary", label: moduleTarget.startLabel, icon: _jsx(PhiIcon, { name: "upload", size: "inherit" }), loading: uploading, disabled: !heldFile || !moduleTarget.ready || uploading, onClick: () => {
|
|
215
|
+
if (!heldFile)
|
|
216
|
+
return;
|
|
217
|
+
upload.reset();
|
|
218
|
+
void upload.upload(heldFile);
|
|
219
|
+
} })] })) : null, _jsx(PhiCollectionLayoutControl, { mode: "grid", gap: token.paddingSM, minColumnWidth: uploadTileFrameSize, items: wallItems.map((item) => {
|
|
196
220
|
const displayDimensions = resolveUploadWallDisplayDimensions(item);
|
|
197
221
|
return (_jsxs("div", { style: {
|
|
198
222
|
border: resolvePhiThemeBorderLine(token.colorBorderSecondary),
|
|
@@ -249,7 +273,8 @@ export function PhiAreaUploadBinding({ config, labels, onUploadComplete, accepta
|
|
|
249
273
|
color: "#fff",
|
|
250
274
|
}, children: _jsx(PhiSpinControl, {}) })) : null] }), _jsxs(PhiFlexControl, { vertical: true, gap: 6, style: { padding: token.paddingSM }, children: [_jsx(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, children: _jsx(PhiTypographyControl, { strong: true, ellipsis: true, title: item.title ?? item.originalName, style: { minWidth: 0 }, children: item.title ?? item.originalName }) }), _jsxs(PhiFlexControl, { align: "center", justify: "space-between", gap: 8, wrap: true, children: [_jsx(PhiTypographyControl, { type: "secondary", ellipsis: true, style: { display: "block", minWidth: 0 }, children: resolvePhiMediaAssetTypeLabel(item.kind, item.contentType, item.originalName) }), allowDelete && item.assetId > 0 ? (_jsx(PhiButtonControl, { ariaLabel: labels.deleteLabel, icon: _jsx(PhiIcon, { name: "delete", size: "inherit" }), type: "text", size: "small", danger: true, onClick: () => {
|
|
251
275
|
void deleteUploadedAsset(item.localId, item.assetId);
|
|
252
|
-
} })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children:
|
|
276
|
+
} })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: true, children: [_jsx(PhiTagControl, { color: item.status === "error" ? "red" : item.status === "uploading" ? "blue" : "green", children: (item.status === "uploading" && item.phase && moduleTarget?.phaseLabels?.[item.phase])
|
|
277
|
+
|| resolvePhiUploadStatusLabel(item, labels) }), item.status === "error" && item.file ? (_jsx(PhiButtonControl, { type: "primary", size: "small", onClick: () => {
|
|
253
278
|
void upload.retry(item.localId);
|
|
254
279
|
}, label: labels.retryLabel })) : null] })] })] }, item.localId));
|
|
255
280
|
}) })] }));
|
|
@@ -14,6 +14,24 @@ import { resolvePhiImagePresentation } from "./image-presentation";
|
|
|
14
14
|
import { PhiFlexControl } from "../controls/phi-flex-control";
|
|
15
15
|
import { PhiTypographyControl } from "../controls/phi-typography-control";
|
|
16
16
|
import { PhiIcon } from "../shell/phi-icon";
|
|
17
|
+
/**
|
|
18
|
+
* The Inspector label of every variant the contracts name. Typed against the contracts' names, so a variant
|
|
19
|
+
* added there without a label here fails the typecheck instead of drawing an empty option.
|
|
20
|
+
*/
|
|
21
|
+
const PHI_ASSET_VARIANT_LABEL_KEYS = {
|
|
22
|
+
thumbnail: "thumbnailVariantLabel",
|
|
23
|
+
preview: "previewVariantLabel",
|
|
24
|
+
banner: "bannerVariantLabel",
|
|
25
|
+
header: "headerVariantLabel",
|
|
26
|
+
card: "cardVariantLabel",
|
|
27
|
+
hero: "heroVariantLabel",
|
|
28
|
+
avatar: "avatarVariantLabel",
|
|
29
|
+
logo: "logoVariantLabel",
|
|
30
|
+
landscape: "landscapeVariantLabel",
|
|
31
|
+
portrait: "portraitVariantLabel",
|
|
32
|
+
icon: "iconVariantLabel",
|
|
33
|
+
share: "shareVariantLabel",
|
|
34
|
+
};
|
|
17
35
|
function formatBytes(bytes) {
|
|
18
36
|
if (typeof bytes !== "number" || !Number.isFinite(bytes) || bytes <= 0)
|
|
19
37
|
return null;
|
|
@@ -127,7 +145,7 @@ export function PhiAssetInspectorSection({ section, asset, selectedVariantKey, s
|
|
|
127
145
|
{ value: "original", label: labels.inspector.originalVariantLabel },
|
|
128
146
|
...Object.entries(PhiImageAssetVariantKeyName).map(([value, variantName]) => ({
|
|
129
147
|
value,
|
|
130
|
-
label: labels.inspector[
|
|
148
|
+
label: labels.inspector[PHI_ASSET_VARIANT_LABEL_KEYS[variantName]],
|
|
131
149
|
})),
|
|
132
150
|
], onChange: (value) => onVariantKeyChange(value === "original" ? null : Number(value)), style: { width: "100%" } })) : null] }));
|
|
133
151
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PhiMediaKindValue } from "../../types/media";
|
|
2
2
|
import type { PhiAreaUploadWidgetLabels } from "./media-widget-labels";
|
|
3
3
|
import type { PhiMediaUploadLabels } from "./media-upload-labels";
|
|
4
|
-
import { type PhiMediaUploadSessionRunner, type PhiMediaUploadInitOptions } from "./media-upload-flow";
|
|
4
|
+
import { type PhiMediaUploadSessionRunner, type PhiMediaUploadInitOptions, type PhiUploadPhase } from "./media-upload-flow";
|
|
5
5
|
/**
|
|
6
6
|
* What a surface accepts, stated by the Module that offers it.
|
|
7
7
|
*
|
|
@@ -42,6 +42,8 @@ type PhiMediaUploadItem = {
|
|
|
42
42
|
localId: string;
|
|
43
43
|
file: File;
|
|
44
44
|
progress: number;
|
|
45
|
+
/** Where a file on its way stands (`PhiUploadPhase`); null before the session says. */
|
|
46
|
+
phase: PhiUploadPhase | null;
|
|
45
47
|
status: "uploading" | "done" | "error";
|
|
46
48
|
error: string | null;
|
|
47
49
|
assetId: number | null;
|
|
@@ -69,7 +71,7 @@ type PhiMediaUploadItem = {
|
|
|
69
71
|
* whatever would act on the incomplete value.
|
|
70
72
|
*/
|
|
71
73
|
export declare function usePhiMediaUpload<TAsset extends {
|
|
72
|
-
id
|
|
74
|
+
id?: unknown;
|
|
73
75
|
} = {
|
|
74
76
|
id: number;
|
|
75
77
|
}>(input: {
|
|
@@ -92,13 +94,18 @@ export declare function usePhiMediaUpload<TAsset extends {
|
|
|
92
94
|
*/
|
|
93
95
|
onUploaded?: (asset: TAsset, file: File) => void | Promise<void>;
|
|
94
96
|
onRejected?: (message: string, file: File) => void;
|
|
97
|
+
/**
|
|
98
|
+
* The sentence a failure is shown with, for a runner whose target words its own refusals -- Core's CDN
|
|
99
|
+
* routes answer `{ error, message }` in a person's words. Null falls back to the Media refusals.
|
|
100
|
+
*/
|
|
101
|
+
readError?: (error: unknown) => string | null;
|
|
95
102
|
}): {
|
|
96
103
|
accept: string;
|
|
97
104
|
items: readonly PhiMediaUploadItem[];
|
|
98
105
|
uploading: boolean;
|
|
99
106
|
upload: (file: File, fileInitOptions?: PhiMediaUploadInitOptions) => Promise<TAsset | null>;
|
|
100
107
|
retry: (localId: string) => Promise<TAsset | null>;
|
|
101
|
-
cancel: () => void;
|
|
108
|
+
cancel: (reason?: unknown) => void;
|
|
102
109
|
reset: () => void;
|
|
103
110
|
};
|
|
104
111
|
export {};
|
|
@@ -104,7 +104,8 @@ export function readPhiMediaUploadErrorMessage(error, labels) {
|
|
|
104
104
|
* whatever would act on the incomplete value.
|
|
105
105
|
*/
|
|
106
106
|
export function usePhiMediaUpload(input) {
|
|
107
|
-
const { labels, acceptance, initOptions, onUploaded, onRejected } = input;
|
|
107
|
+
const { labels, acceptance, initOptions, onUploaded, onRejected, readError } = input;
|
|
108
|
+
const readFailure = useCallback((error) => readError?.(error) ?? readPhiMediaUploadErrorMessage(error, labels), [labels, readError]);
|
|
108
109
|
const runSession = input.runSession
|
|
109
110
|
?? runPhiMediaUploadSession;
|
|
110
111
|
const [items, setItems] = useState([]);
|
|
@@ -138,6 +139,7 @@ export function usePhiMediaUpload(input) {
|
|
|
138
139
|
localId,
|
|
139
140
|
file,
|
|
140
141
|
progress: 0,
|
|
142
|
+
phase: null,
|
|
141
143
|
status: "uploading",
|
|
142
144
|
error: null,
|
|
143
145
|
assetId: null,
|
|
@@ -148,14 +150,14 @@ export function usePhiMediaUpload(input) {
|
|
|
148
150
|
running.current.add(controller);
|
|
149
151
|
let asset;
|
|
150
152
|
try {
|
|
151
|
-
({ asset } = await runSession(file, (progress) => patch(localId, { progress }), fileInitOptions ?? initOptions, controller.signal));
|
|
153
|
+
({ asset } = await runSession(file, (progress) => patch(localId, { progress }), fileInitOptions ?? initOptions, controller.signal, (phase) => patch(localId, { phase })));
|
|
152
154
|
}
|
|
153
155
|
catch (error) {
|
|
154
156
|
if (controller.signal.aborted || isPhiMediaUploadCancelled(error)) {
|
|
155
157
|
setItems((current) => current.filter((item) => item.localId !== localId));
|
|
156
158
|
return null;
|
|
157
159
|
}
|
|
158
|
-
const message =
|
|
160
|
+
const message = readFailure(error);
|
|
159
161
|
patch(localId, { progress: 100, status: "error", error: message });
|
|
160
162
|
onRejected?.(message, file);
|
|
161
163
|
return null;
|
|
@@ -166,27 +168,28 @@ export function usePhiMediaUpload(input) {
|
|
|
166
168
|
// Stopped while finalize was answering: the Asset exists, but nobody is waiting to enter it.
|
|
167
169
|
if (controller.signal.aborted)
|
|
168
170
|
return null;
|
|
169
|
-
patch(localId, { progress: 100, status: "done", assetId: asset.id });
|
|
171
|
+
patch(localId, { progress: 100, status: "done", assetId: typeof asset.id === "number" ? asset.id : null });
|
|
170
172
|
try {
|
|
171
173
|
await onUploaded?.(asset, file);
|
|
172
174
|
}
|
|
173
175
|
catch (error) {
|
|
174
|
-
const message =
|
|
176
|
+
const message = readFailure(error);
|
|
175
177
|
patch(localId, { status: "error", error: message });
|
|
176
178
|
onRejected?.(message, file);
|
|
177
179
|
return null;
|
|
178
180
|
}
|
|
179
181
|
return asset;
|
|
180
|
-
}, [acceptance, initOptions, labels, onRejected, onUploaded, patch, runSession]);
|
|
182
|
+
}, [acceptance, initOptions, labels, onRejected, onUploaded, patch, readFailure, runSession]);
|
|
181
183
|
const upload = useCallback((file, fileInitOptions) => run(file, undefined, fileInitOptions), [run]);
|
|
182
184
|
/** Starts a failed item's file again, in the place it had. */
|
|
183
185
|
const retry = useCallback((localId) => {
|
|
184
186
|
const failed = items.find((item) => item.localId === localId && item.status === "error");
|
|
185
187
|
return failed ? run(failed.file, localId, failed.initOptions) : Promise.resolve(null);
|
|
186
188
|
}, [items, run]);
|
|
187
|
-
|
|
189
|
+
/** Stops what is on its way; `reason` reaches the runner as the signal's (a target may read it). */
|
|
190
|
+
const cancel = useCallback((reason) => {
|
|
188
191
|
for (const controller of running.current)
|
|
189
|
-
controller.abort();
|
|
192
|
+
controller.abort(reason);
|
|
190
193
|
}, []);
|
|
191
194
|
const reset = useCallback(() => setItems([]), []);
|
|
192
195
|
const uploading = items.some((item) => item.status === "uploading");
|
|
@@ -45,6 +45,8 @@ export function buildPhiAreaShellHeaderNodes({ nodes, runtime, labelPrefix, ids,
|
|
|
45
45
|
label: `${labelPrefix} header top three column`,
|
|
46
46
|
config: {
|
|
47
47
|
balancedSides: true,
|
|
48
|
+
// Three equal columns: the page title in the middle never needs more than a third.
|
|
49
|
+
sideShare: 33,
|
|
48
50
|
contentAlign: "center",
|
|
49
51
|
paddingLeft: PHI_SPACE.base,
|
|
50
52
|
paddingRight: PHI_SPACE.base,
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { usePhiConfig } from "../root/phi-config-provider";
|
|
3
4
|
const ICON_BOX = {
|
|
4
5
|
display: "inline-flex",
|
|
5
6
|
color: "currentColor",
|
|
6
7
|
};
|
|
7
8
|
function Frame({ size, children, }) {
|
|
8
|
-
|
|
9
|
+
/*
|
|
10
|
+
* The Theme's small radius, as every small box beside it has -- the Insert picker's entries, a colour
|
|
11
|
+
* swatch. The frame is drawn in a 16-unit box, so a size in pixels converts the radius into those
|
|
12
|
+
* units and the corner is the Theme's on screen; a size in another unit cannot be converted here, and
|
|
13
|
+
* the radius stands at the icon's drawn 16px and scales with it.
|
|
14
|
+
*/
|
|
15
|
+
const themeRadius = usePhiConfig().token.borderRadiusSM;
|
|
16
|
+
const radius = typeof size === "number" && size > 0 ? (themeRadius * 16) / size : themeRadius;
|
|
9
17
|
return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", style: { ...ICON_BOX, width: size, height: size }, children: [_jsx("rect", { x: "1", y: "1", width: "14", height: "14", rx: radius, stroke: "currentColor", strokeWidth: "1" }), children] }));
|
|
10
18
|
}
|
|
11
19
|
function ContentMotif() {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PhiSurface } from "../../types/surface";
|
|
2
|
+
/**
|
|
3
|
+
* A Table's ground, in the Surface vocabulary every box uses (`types/surface.ts`, LAYOUTING.md "Surface").
|
|
4
|
+
*
|
|
5
|
+
* A Table draws the part of a Surface that a table can carry -- its ground -- and nothing else:
|
|
6
|
+
*
|
|
7
|
+
* - absent: the Table's own ground, as Ant Design draws it -- the Theme's container ground under the rows,
|
|
8
|
+
* the header and footer fills over it. The default.
|
|
9
|
+
* - `null`: "None", as the Surface switch says it -- no ground at all. The Table is its row lines on
|
|
10
|
+
* whatever it stands on: the header, the footer and a summary row paint nothing either. An inspector's
|
|
11
|
+
* Tables take this one (`PHI_INSPECTOR_TABLE_PRESENTATION`, `helpers/cms-inspector-drawer.ts`).
|
|
12
|
+
* - a Surface whose ground is one colour, with no line, no depth, no mode of its own and no ground per
|
|
13
|
+
* mode -- `PHI_SURFACE_WASH` is one. The whole Table stands on that colour, its header and footer too.
|
|
14
|
+
*
|
|
15
|
+
* A line, a shadow or a picture is a box around the Table, not the Table's ground: a Table that wants one
|
|
16
|
+
* stands in a Layout or a Widget slot that draws it. The outer frame stays `bordered` / `presentation.borders`.
|
|
17
|
+
*/
|
|
18
|
+
export type PhiTableSurface = PhiSurface | null;
|
|
19
|
+
/** Whether a stated Surface is one a Table can draw: one colour of ground and nothing else. */
|
|
20
|
+
export declare function isPhiTableSurfaceDrawable(surface: PhiSurface): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The colour a Table with a stated Surface stands on: the Surface's ground colour, or `transparent` for
|
|
23
|
+
* "None" and a Surface that paints none.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolvePhiTableSurfaceGround(surface: PhiTableSurface): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Whether a stated Surface is one a Table can draw: one colour of ground and nothing else. */
|
|
2
|
+
export function isPhiTableSurfaceDrawable(surface) {
|
|
3
|
+
if (surface.backgroundDark != null)
|
|
4
|
+
return false;
|
|
5
|
+
if (surface.tone != null && surface.tone !== "inherit")
|
|
6
|
+
return false;
|
|
7
|
+
if (surface.shadow != null && surface.shadow !== "none")
|
|
8
|
+
return false;
|
|
9
|
+
if (surface.border != null || (surface.borderSource != null && surface.borderSource !== "none"))
|
|
10
|
+
return false;
|
|
11
|
+
const background = surface.background;
|
|
12
|
+
if (background == null)
|
|
13
|
+
return true;
|
|
14
|
+
if (background.overlay != null || background.filter != null || background.motion != null)
|
|
15
|
+
return false;
|
|
16
|
+
return background.base.kind === "color" || background.base.kind === "none";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The colour a Table with a stated Surface stands on: the Surface's ground colour, or `transparent` for
|
|
20
|
+
* "None" and a Surface that paints none.
|
|
21
|
+
*/
|
|
22
|
+
export function resolvePhiTableSurfaceGround(surface) {
|
|
23
|
+
const base = surface?.background?.base;
|
|
24
|
+
return base?.kind === "color" ? base.color : "transparent";
|
|
25
|
+
}
|
|
@@ -16,6 +16,7 @@ import { PhiFlexControl } from "../../controls/phi-flex-control";
|
|
|
16
16
|
import { PhiCollectionHeaderControl } from "../../controls/phi-collection-header-control";
|
|
17
17
|
import { PhiToolbarControl } from "../../controls/phi-toolbar-control";
|
|
18
18
|
import { PHI_SPACE } from "../../../theme/antd-css-var-contract";
|
|
19
|
+
import { PHI_INSPECTOR_TABLE_CONTROL_PROPS } from "../../../helpers/cms-inspector-drawer";
|
|
19
20
|
const ROW_ID = "rowId";
|
|
20
21
|
function readRowName(row, spec) {
|
|
21
22
|
return String(row[spec.nameField] || row[spec.keyField] || "");
|
|
@@ -119,7 +120,9 @@ function PhiStaticRowsTable({ spec, providerKey, resource, disabled, }) {
|
|
|
119
120
|
* Add stands over the table, as every collection's tools do (TABLES.md, "Collection Header"): a
|
|
120
121
|
* compact toolbar on the right, `space.sm` above the table.
|
|
121
122
|
*/
|
|
122
|
-
return _jsxs(_Fragment, { children: [binding.error ? _jsx(PhiAlertControl, { level: "error", showIcon: true, title: binding.error.message }) : null, _jsxs(PhiFlexControl, { vertical: true, gap: PHI_SPACE.sm, style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiCollectionHeaderControl, { toolbar: (_jsx(PhiToolbarControl, { compact: true, size: "small", disabled: disabled, items: [{ key: "add", label: labels.add, showLabel: true, icon: _jsx(PhiIcon, { name: "plus", size: "inherit" }) }], onActivate: () => { void binding.executeAction({ kind: "action", actionKey: "add", selectedRowIdentities: [], query: binding.resolvedQuery }); } })) }), _jsx(PhiTableBindingControl
|
|
123
|
+
return _jsxs(_Fragment, { children: [binding.error ? _jsx(PhiAlertControl, { level: "error", showIcon: true, title: binding.error.message }) : null, _jsxs(PhiFlexControl, { vertical: true, gap: PHI_SPACE.sm, style: { width: "100%", minWidth: 0 }, children: [_jsx(PhiCollectionHeaderControl, { toolbar: (_jsx(PhiToolbarControl, { compact: true, size: "small", disabled: disabled, items: [{ key: "add", label: labels.add, showLabel: true, icon: _jsx(PhiIcon, { name: "plus", size: "inherit" }) }], onActivate: () => { void binding.executeAction({ kind: "action", actionKey: "add", selectedRowIdentities: [], query: binding.resolvedQuery }); } })) }), _jsx(PhiTableBindingControl
|
|
124
|
+
// An inspector's Table, in the dialog its field opens: lines only (BUILDER.md "Inspector contract").
|
|
125
|
+
, { ...PHI_INSPECTOR_TABLE_CONTROL_PROPS, rows: binding.rows, fields: binding.resource?.fields ?? [], columns: columns, rowIdentityPath: ROW_ID, columnOrder: [...spec.columns.map((column) => column.key), "actions"], sortingMode: "none", sorts: [], pagination: false, size: "small", emptyText: labels.empty, layout: { mode: "fixed", overflowX: "auto" }, loading: binding.loading, rowReordering: { enabled: !disabled, onMove: (move) => { void binding.moveRow({ kind: "row-move", ...move }); } } })] })] });
|
|
123
126
|
}
|
|
124
127
|
/** A Widget's static rows: a tool button that opens them in a dialog and hands back the applied rows. */
|
|
125
128
|
export function PhiStaticRowsToolButton({ spec, rows: storedRows, disabled = false, onApply, }) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LinkNode, type SerializedLinkNode } from "@lexical/link";
|
|
2
|
+
import { type DOMConversionMap, type LexicalNodeReplacement } from "lexical";
|
|
3
|
+
/** Keeps Page identity in authoring HTML; only the server render resolves it to an address. */
|
|
4
|
+
export declare class PhiHtmlLinkNode extends LinkNode {
|
|
5
|
+
static getType(): string;
|
|
6
|
+
static clone(node: PhiHtmlLinkNode): PhiHtmlLinkNode;
|
|
7
|
+
static importJSON(serializedNode: SerializedLinkNode): PhiHtmlLinkNode;
|
|
8
|
+
static importDOM(): DOMConversionMap;
|
|
9
|
+
sanitizeUrl(url: string): string;
|
|
10
|
+
}
|
|
11
|
+
/** Factories, commands and imports must all create the same node, including LinkNode transforms. */
|
|
12
|
+
export declare const PHI_HTML_LINK_NODE_REPLACEMENT: LexicalNodeReplacement;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LinkNode } from "@lexical/link";
|
|
2
|
+
import { $applyNodeReplacement } from "lexical";
|
|
3
|
+
import { createPhiPageUri, readPhiInternalReference } from "../../../types/references";
|
|
4
|
+
/** Keeps Page identity in authoring HTML; only the server render resolves it to an address. */
|
|
5
|
+
export class PhiHtmlLinkNode extends LinkNode {
|
|
6
|
+
static getType() {
|
|
7
|
+
return "phi-html-link";
|
|
8
|
+
}
|
|
9
|
+
static clone(node) {
|
|
10
|
+
return new PhiHtmlLinkNode(node.__url, {
|
|
11
|
+
rel: node.__rel,
|
|
12
|
+
target: node.__target,
|
|
13
|
+
title: node.__title,
|
|
14
|
+
}, node.__key);
|
|
15
|
+
}
|
|
16
|
+
static importJSON(serializedNode) {
|
|
17
|
+
return $applyNodeReplacement(new PhiHtmlLinkNode()).updateFromJSON(serializedNode);
|
|
18
|
+
}
|
|
19
|
+
static importDOM() {
|
|
20
|
+
return {
|
|
21
|
+
a: () => ({
|
|
22
|
+
priority: 2,
|
|
23
|
+
conversion: (element) => {
|
|
24
|
+
if (!(element instanceof HTMLAnchorElement))
|
|
25
|
+
return null;
|
|
26
|
+
return {
|
|
27
|
+
node: $applyNodeReplacement(new PhiHtmlLinkNode(element.getAttribute("href") ?? "", {
|
|
28
|
+
rel: element.getAttribute("rel"),
|
|
29
|
+
target: element.getAttribute("target"),
|
|
30
|
+
title: element.getAttribute("title"),
|
|
31
|
+
})),
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
sanitizeUrl(url) {
|
|
38
|
+
const reference = readPhiInternalReference(url);
|
|
39
|
+
if (reference?.kind === "page") {
|
|
40
|
+
try {
|
|
41
|
+
if (createPhiPageUri(reference.reference, reference.fragment) === url)
|
|
42
|
+
return url;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// A malformed Unicode fragment cannot be emitted by the canonical factory.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return super.sanitizeUrl(url);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Factories, commands and imports must all create the same node, including LinkNode transforms. */
|
|
52
|
+
export const PHI_HTML_LINK_NODE_REPLACEMENT = {
|
|
53
|
+
replace: LinkNode,
|
|
54
|
+
with: (node) => new PhiHtmlLinkNode(node.getURL(), {
|
|
55
|
+
rel: node.getRel(),
|
|
56
|
+
target: node.getTarget(),
|
|
57
|
+
title: node.getTitle(),
|
|
58
|
+
}),
|
|
59
|
+
withKlass: PhiHtmlLinkNode,
|
|
60
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useEffectEvent, useId, useMemo, useRef, } from "react";
|
|
4
|
-
import { $createParagraphNode, $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isRootOrShadowRoot, $insertNodes, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_LOW, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, REDO_COMMAND,
|
|
4
|
+
import { $createParagraphNode, $getRoot, $getSelection, $isElementNode, $isRangeSelection, $isRootOrShadowRoot, $insertNodes, BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_LOW, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, REDO_COMMAND, UNDO_COMMAND, getStyleObjectFromCSS, configExtension, defineExtension, } from "lexical";
|
|
5
5
|
import { $generateHtmlFromNodes, $generateNodesFromDOM } from "@lexical/html";
|
|
6
6
|
import { TOGGLE_LINK_COMMAND, $isLinkNode } from "@lexical/link";
|
|
7
7
|
import { $removeList, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode } from "@lexical/list";
|
|
@@ -23,6 +23,7 @@ import { resolvePhiWidgetFontSize } from "../helpers/font-size";
|
|
|
23
23
|
import { sanitizePhiHtmlWidgetMarkup } from "../helpers/html-content";
|
|
24
24
|
import { PHI_HTML_WIDGET_EDITOR_EMPTY_STATE, registerPhiHtmlWidgetEditorBridge, } from "../client/html-editor-bridge";
|
|
25
25
|
import { $createPhiHtmlImageNode, PhiHtmlImageNode } from "./html-editor-image-node";
|
|
26
|
+
import { PhiHtmlLinkNode, PHI_HTML_LINK_NODE_REPLACEMENT } from "./html-editor-link-node";
|
|
26
27
|
const PHI_HTML_WIDGET_PLACEHOLDER = "Write rich text...";
|
|
27
28
|
const PHI_HTML_WIDGET_EDITOR_LINE_HEIGHT = 1.7;
|
|
28
29
|
const PHI_HTML_WIDGET_EDITOR_MIN_CONTENT_HEIGHT = `${PHI_HTML_WIDGET_EDITOR_LINE_HEIGHT}em`;
|
|
@@ -356,12 +357,15 @@ function PhiHtmlWidgetEditorBridgePlugin({ blockId, }) {
|
|
|
356
357
|
editor.dispatchCommand(REDO_COMMAND, undefined);
|
|
357
358
|
},
|
|
358
359
|
});
|
|
360
|
+
/*
|
|
361
|
+
* Every commit reaches the update listener, a selection-only one included, and it reads the state
|
|
362
|
+
* just committed. `SELECTION_CHANGE_COMMAND` is no place for this: since Lexical 0.52 it runs inside
|
|
363
|
+
* the pending update, before reconciliation, where `editor.getEditorState()` is still the previous
|
|
364
|
+
* commit -- the toolbar would show the formats of the caret's last position, one move behind.
|
|
365
|
+
*/
|
|
359
366
|
return mergeRegister(editor.registerUpdateListener(() => {
|
|
360
367
|
refreshBridgeState();
|
|
361
|
-
}), editor.registerCommand(
|
|
362
|
-
refreshBridgeState();
|
|
363
|
-
return false;
|
|
364
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(CAN_UNDO_COMMAND, (canUndo) => {
|
|
368
|
+
}), editor.registerCommand(CAN_UNDO_COMMAND, (canUndo) => {
|
|
365
369
|
stateRef.current = {
|
|
366
370
|
...stateRef.current,
|
|
367
371
|
canUndo,
|
|
@@ -403,7 +407,7 @@ export function PhiHtmlWidgetEditor({ blockId, html, fontFamily, fontSize, onCha
|
|
|
403
407
|
LinkExtension,
|
|
404
408
|
ListExtension,
|
|
405
409
|
],
|
|
406
|
-
nodes: [PhiHtmlImageNode],
|
|
410
|
+
nodes: [PhiHtmlImageNode, PhiHtmlLinkNode, PHI_HTML_LINK_NODE_REPLACEMENT],
|
|
407
411
|
init(editorConfig) {
|
|
408
412
|
editorConfig.namespace = `PhiHtmlWidgetEditor:${editorId}`;
|
|
409
413
|
editorConfig.onError = (error) => {
|
|
@@ -18,10 +18,17 @@ export type PhiChoiceControllerResult = {
|
|
|
18
18
|
emitFocus: () => void;
|
|
19
19
|
emitBlur: () => void;
|
|
20
20
|
publish: (nextValue: string) => void;
|
|
21
|
+
/**
|
|
22
|
+
* What is typed into the select, for an Options Provider that searches on the server (`loadMode:
|
|
23
|
+
* "server"`, `search`); absent where the source declares no search, so the select narrows what it holds.
|
|
24
|
+
*/
|
|
25
|
+
onSearch?: (search: string) => void;
|
|
26
|
+
/** `false` where the provider's answer is already the result of the search. */
|
|
27
|
+
filterOptionsLocally: boolean;
|
|
21
28
|
};
|
|
22
29
|
export declare function usePhiChoiceController<TConfig extends PhiChoiceControlConfig>({ config, signalsEnabled, typeKey, defaultKey, sender, }: PhiChoiceControllerOptions<TConfig>): PhiChoiceControllerResult;
|
|
23
30
|
export type PhiStackChoiceControllerOptions<TConfig extends PhiStackChoiceControlConfig> = PhiChoiceControllerOptions<TConfig>;
|
|
24
|
-
export type PhiStackChoiceControllerResult = Omit<PhiChoiceControllerResult, "publish" | "options"> & {
|
|
31
|
+
export type PhiStackChoiceControllerResult = Omit<PhiChoiceControllerResult, "publish" | "options" | "onSearch" | "filterOptionsLocally"> & {
|
|
25
32
|
options: PhiControlOption[];
|
|
26
33
|
stackMode: boolean;
|
|
27
34
|
publish: (nextValue: string) => void;
|
|
@@ -19,12 +19,25 @@ function readPhiChoiceHeldValue(picked, configuredValue) {
|
|
|
19
19
|
export function usePhiChoiceController({ config, signalsEnabled = true, typeKey, defaultKey, sender, }) {
|
|
20
20
|
// A pick, held against the fallback it replaced; declared first so the provider hears it.
|
|
21
21
|
const [picked, setPicked] = useState(null);
|
|
22
|
+
/*
|
|
23
|
+
* What is typed, handed to the provider as a Form field and a Table filter hand it: the hook debounces it
|
|
24
|
+
* and holds it to the declared minimum, so a provider answering one page of a longer list -- the Site's
|
|
25
|
+
* members -- is searched by its route rather than inside the page it answered.
|
|
26
|
+
*/
|
|
27
|
+
const [searchDraft, setSearchDraft] = useState("");
|
|
22
28
|
const resolvedOptions = usePhiControlOptionsProvider({
|
|
23
29
|
options: config?.options,
|
|
24
30
|
optionsProvider: config?.optionsProvider,
|
|
31
|
+
searchDraft,
|
|
25
32
|
selectedValues: readPhiChoiceHeldValue(picked, config?.value),
|
|
26
33
|
});
|
|
27
|
-
|
|
34
|
+
/*
|
|
35
|
+
* Without a value of its own a choice holds its first option -- except a select that may be emptied
|
|
36
|
+
* (`allowClear`), which starts as it ends when cleared: with nothing chosen. A member picker that held
|
|
37
|
+
* the first member of the list showed a choice nobody made, and picking that member then changed nothing.
|
|
38
|
+
*/
|
|
39
|
+
const fallbackValue = config?.value ?? resolvedOptions.value ??
|
|
40
|
+
(config?.allowClear === true ? "" : resolvedOptions.options.at(0)?.value) ?? "";
|
|
28
41
|
const readOnly = config?.readOnly === true;
|
|
29
42
|
const value = picked?.source === fallbackValue ? picked.value : fallbackValue;
|
|
30
43
|
/*
|
|
@@ -78,6 +91,8 @@ export function usePhiChoiceController({ config, signalsEnabled = true, typeKey,
|
|
|
78
91
|
emitFocus: controlSignals.emitFocus,
|
|
79
92
|
emitBlur: controlSignals.emitBlur,
|
|
80
93
|
publish,
|
|
94
|
+
onSearch: resolvedOptions.search.enabled ? setSearchDraft : undefined,
|
|
95
|
+
filterOptionsLocally: resolvedOptions.search.filterLocally,
|
|
81
96
|
};
|
|
82
97
|
}
|
|
83
98
|
function mapPhiStackSlotsToChoiceOptions(message) {
|