@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
|
@@ -2,6 +2,8 @@ import type { CSSProperties } from "react";
|
|
|
2
2
|
import { type PhiControlSize, type PhiRenderableBlockSize } from "../../types";
|
|
3
3
|
export type PhiDimensionControlProps = {
|
|
4
4
|
value?: PhiRenderableBlockSize | null;
|
|
5
|
+
/** The accessible name of the pair; each field keeps its own, its placeholder. */
|
|
6
|
+
ariaLabel?: string;
|
|
5
7
|
disabled?: boolean;
|
|
6
8
|
readOnly?: boolean;
|
|
7
9
|
onChange?: (nextValue: PhiRenderableBlockSize | null) => void;
|
|
@@ -11,4 +13,4 @@ export type PhiDimensionControlProps = {
|
|
|
11
13
|
style?: CSSProperties;
|
|
12
14
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
13
15
|
};
|
|
14
|
-
export declare function PhiDimensionControl({ value, disabled, readOnly, onChange, widthPlaceholder, heightPlaceholder, size, style, getPopupContainer, }: PhiDimensionControlProps): import("react").JSX.Element;
|
|
16
|
+
export declare function PhiDimensionControl({ value, ariaLabel, disabled, readOnly, onChange, widthPlaceholder, heightPlaceholder, size, style, getPopupContainer, }: PhiDimensionControlProps): import("react").JSX.Element;
|
|
@@ -13,9 +13,9 @@ function resolveNextSize(currentSize, key, value) {
|
|
|
13
13
|
}
|
|
14
14
|
return nextSize;
|
|
15
15
|
}
|
|
16
|
-
export function PhiDimensionControl({ value, disabled = false, readOnly = false, onChange, widthPlaceholder = "Width", heightPlaceholder = "Height", size, style, getPopupContainer, }) {
|
|
16
|
+
export function PhiDimensionControl({ value, ariaLabel, disabled = false, readOnly = false, onChange, widthPlaceholder = "Width", heightPlaceholder = "Height", size, style, getPopupContainer, }) {
|
|
17
17
|
const currentSize = value ?? null;
|
|
18
|
-
return (_jsxs("div", { style: {
|
|
18
|
+
return (_jsxs("div", { role: "group", "aria-label": ariaLabel, style: {
|
|
19
19
|
display: "grid",
|
|
20
20
|
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
21
21
|
/*
|
|
@@ -133,7 +133,7 @@ export function PhiGeometryControl({ value, config, disabled = false, mode = "co
|
|
|
133
133
|
offsetTop: nextValue ?? 0,
|
|
134
134
|
}), style: { width: "100%", maxWidth: 120, minWidth: 0 } }))
|
|
135
135
|
: null, showSticky || showOffsetTop ? _jsx(Divider, { dashed: true, size: "small" }) : null, showProfiles
|
|
136
|
-
? renderGeometryRow(labels.fields.profile, _jsx(PhiSegmentedControl, { value: selectedProfile,
|
|
136
|
+
? renderGeometryRow(labels.fields.profile, _jsx(PhiSegmentedControl, { value: selectedProfile, block: true, options: PHI_GEOMETRY_PROFILES.map((option) => ({
|
|
137
137
|
value: option,
|
|
138
138
|
label: labels.profiles[option],
|
|
139
139
|
})), onChange: (next) => setSelectedProfile(next) }))
|
|
@@ -3,6 +3,11 @@ import { type PhiControlSize, type PhiCssLength } from "../../types";
|
|
|
3
3
|
export type PhiLengthControlProps = {
|
|
4
4
|
value?: PhiCssLength | null;
|
|
5
5
|
label?: string;
|
|
6
|
+
/**
|
|
7
|
+
* The accessible name where no visible label stands beside the field; it takes precedence over the
|
|
8
|
+
* placeholder and `label`. The unit list is named after it.
|
|
9
|
+
*/
|
|
10
|
+
ariaLabel?: string;
|
|
6
11
|
placeholder?: string;
|
|
7
12
|
min?: number;
|
|
8
13
|
max?: number;
|
|
@@ -19,4 +24,4 @@ export type PhiLengthControlProps = {
|
|
|
19
24
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
20
25
|
onChange?: (value: PhiCssLength | null) => void;
|
|
21
26
|
};
|
|
22
|
-
export declare function PhiLengthControl({ value, label, placeholder, min, max, step, precision, disabled, readOnly, size, style, getPopupContainer, onChange, }: PhiLengthControlProps): import("react").JSX.Element;
|
|
27
|
+
export declare function PhiLengthControl({ value, label, ariaLabel, placeholder, min, max, step, precision, disabled, readOnly, size, style, getPopupContainer, onChange, }: PhiLengthControlProps): import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { useState } from "react";
|
|
|
5
5
|
import { PHI_CSS_LENGTH_UNITS, readPhiCssLengthPart, serializePhiCssLength, } from "../../types";
|
|
6
6
|
import { PhiLabeledControl } from "./phi-labeled-control";
|
|
7
7
|
import { PhiCompactGroupControl } from "./phi-compact-group-control";
|
|
8
|
-
export function PhiLengthControl({ value, label, placeholder, min, max, step, precision, disabled = false, readOnly = false, size, style, getPopupContainer, onChange, }) {
|
|
8
|
+
export function PhiLengthControl({ value, label, ariaLabel, placeholder, min, max, step, precision, disabled = false, readOnly = false, size, style, getPopupContainer, onChange, }) {
|
|
9
9
|
const part = readPhiCssLengthPart(value);
|
|
10
10
|
/**
|
|
11
11
|
* A unit is only expressible together with a number, so an empty field would otherwise force the
|
|
@@ -20,7 +20,8 @@ export function PhiLengthControl({ value, label, placeholder, min, max, step, pr
|
|
|
20
20
|
* is kept shut and its change ignored instead.
|
|
21
21
|
*/
|
|
22
22
|
const controlDisabled = disabled || (!onChange && !readOnly);
|
|
23
|
-
const
|
|
23
|
+
const accessibleName = ariaLabel ?? placeholder ?? label ?? "Length";
|
|
24
|
+
const control = (_jsxs(PhiCompactGroupControl, { block: true, size: size, style: { width: "100%", minWidth: 0, ...style }, children: [_jsx(InputNumber, { "aria-label": accessibleName, controls: false, disabled: controlDisabled, readOnly: readOnly, min: min, max: max, step: step, precision: precision, placeholder: placeholder, value: part?.value ?? null, style: { flex: "1 1 0", minWidth: 0 }, onChange: (nextValue) => onChange?.(typeof nextValue === "number" ? serializePhiCssLength(nextValue, unit) : null) }), _jsx(Select, { "aria-label": `${accessibleName} unit`, disabled: controlDisabled, open: readOnly ? false : undefined, options: PHI_CSS_LENGTH_UNITS.map((option) => ({ value: option, label: option })), popupMatchSelectWidth: false, getPopupContainer: getPopupContainer, showSearch: false, suffix: null, variant: "filled", value: unit, style: { flex: "0 0 38px", width: 38 }, styles: {
|
|
24
25
|
root: { paddingInline: 4 },
|
|
25
26
|
content: { justifyContent: "center", textAlign: "center" },
|
|
26
27
|
}, onChange: (nextUnit) => {
|
|
@@ -8,6 +8,11 @@ export type PhiMultiSelectControlProps<TValue extends string | number = string>
|
|
|
8
8
|
value?: readonly TValue[];
|
|
9
9
|
label?: string;
|
|
10
10
|
description?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The accessible name where no visible label stands beside the field -- a filter in a picker's header.
|
|
13
|
+
* It takes precedence over `label`, as on `PhiSelectControl`.
|
|
14
|
+
*/
|
|
15
|
+
ariaLabel?: string;
|
|
11
16
|
placeholder?: string;
|
|
12
17
|
disabled?: boolean;
|
|
13
18
|
readOnly?: boolean;
|
|
@@ -23,4 +28,4 @@ export type PhiMultiSelectControlProps<TValue extends string | number = string>
|
|
|
23
28
|
onBlur?: () => void;
|
|
24
29
|
onChange?: (value: TValue[]) => void;
|
|
25
30
|
};
|
|
26
|
-
export declare function PhiMultiSelectControl<TValue extends string | number = string>({ id, value, label, description, placeholder, disabled, readOnly, allowCustom, allowClear, options, maxTagCount, size, variant, popupMatchSelectWidth, style, onFocus, onBlur, onChange, }: PhiMultiSelectControlProps<TValue>): import("react").JSX.Element;
|
|
31
|
+
export declare function PhiMultiSelectControl<TValue extends string | number = string>({ id, value, label, description, ariaLabel, placeholder, disabled, readOnly, allowCustom, allowClear, options, maxTagCount, size, variant, popupMatchSelectWidth, style, onFocus, onBlur, onChange, }: PhiMultiSelectControlProps<TValue>): import("react").JSX.Element;
|
|
@@ -5,8 +5,8 @@ import { Select } from "antd";
|
|
|
5
5
|
import { PhiControlOptionContent } from "./phi-control-option-content";
|
|
6
6
|
import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
|
|
7
7
|
import { groupPhiSelectOptions } from "./phi-select-control";
|
|
8
|
-
export function PhiMultiSelectControl({ id, value, label, description, placeholder, disabled, readOnly, allowCustom, allowClear, options, maxTagCount, size, variant, popupMatchSelectWidth = false, style, onFocus, onBlur, onChange, }) {
|
|
9
|
-
const { labelId, labelledBy } = usePhiControlLabel(label);
|
|
8
|
+
export function PhiMultiSelectControl({ id, value, label, description, ariaLabel, placeholder, disabled, readOnly, allowCustom, allowClear, options, maxTagCount, size, variant, popupMatchSelectWidth = false, style, onFocus, onBlur, onChange, }) {
|
|
9
|
+
const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
|
|
10
10
|
// Options that name a group are listed under its heading, as the Select lists them.
|
|
11
11
|
const selectOptions = useMemo(() => groupPhiSelectOptions(options.map((option) => ({
|
|
12
12
|
value: option.value,
|
|
@@ -16,7 +16,7 @@ export function PhiMultiSelectControl({ id, value, label, description, placehold
|
|
|
16
16
|
option,
|
|
17
17
|
disabled: option.disabled,
|
|
18
18
|
}))), [options]);
|
|
19
|
-
const control = (_jsx(Select, { id: id, "aria-labelledby": labelledBy, mode: allowCustom ? "tags" : "multiple", allowClear: allowClear, value: [...(value ?? [])], placeholder: placeholder, disabled: disabled || readOnly || !onChange, options: selectOptions, optionFilterProp: ["searchLabel", "value"], optionRender: (option) => {
|
|
19
|
+
const control = (_jsx(Select, { id: id, "aria-label": ariaLabel, "aria-labelledby": labelledBy, mode: allowCustom ? "tags" : "multiple", allowClear: allowClear, value: [...(value ?? [])], placeholder: placeholder, disabled: disabled || readOnly || !onChange, options: selectOptions, optionFilterProp: ["searchLabel", "value"], optionRender: (option) => {
|
|
20
20
|
/*
|
|
21
21
|
* With `allowCustom` the Select offers what is being typed as an option of its own, and that one
|
|
22
22
|
* carries no Phi option: it is a value nobody declared yet, drawn as the text it is.
|
|
@@ -8,6 +8,11 @@ export type PhiSegmentedControlProps<TValue extends string | number = string> =
|
|
|
8
8
|
*/
|
|
9
9
|
value?: TValue | null;
|
|
10
10
|
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The accessible name of the group where no visible label stands beside it; it takes precedence over
|
|
13
|
+
* `label`. It names the radio group, not a segment.
|
|
14
|
+
*/
|
|
15
|
+
ariaLabel?: string;
|
|
11
16
|
options: readonly PhiControlOption<TValue>[];
|
|
12
17
|
disabled?: boolean;
|
|
13
18
|
readOnly?: boolean;
|
|
@@ -19,4 +24,4 @@ export type PhiSegmentedControlProps<TValue extends string | number = string> =
|
|
|
19
24
|
onBlur?: () => void;
|
|
20
25
|
onChange?: (value: TValue) => void;
|
|
21
26
|
};
|
|
22
|
-
export declare function PhiSegmentedControl<TValue extends string | number = string>({ value, label, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }: PhiSegmentedControlProps<TValue>): import("react").JSX.Element;
|
|
27
|
+
export declare function PhiSegmentedControl<TValue extends string | number = string>({ value, label, ariaLabel, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }: PhiSegmentedControlProps<TValue>): import("react").JSX.Element;
|
|
@@ -11,10 +11,10 @@ const PHI_SEGMENT_LABEL_STYLE = {
|
|
|
11
11
|
textOverflow: "ellipsis",
|
|
12
12
|
whiteSpace: "nowrap",
|
|
13
13
|
};
|
|
14
|
-
export function PhiSegmentedControl({ value, label, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }) {
|
|
15
|
-
const { labelId, labelledBy } = usePhiControlLabel(label);
|
|
14
|
+
export function PhiSegmentedControl({ value, label, ariaLabel, options, disabled, readOnly, block, size, gradient, onFocus, onBlur, onChange, }) {
|
|
15
|
+
const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
|
|
16
16
|
const gradientVars = gradient ? PHI_THEME_GRADIENT_CSS_VARS[gradient] : null;
|
|
17
|
-
const control = (_jsx(Segmented, { "aria-labelledby": labelledBy, block: block, value: value, disabled: disabled || readOnly || !onChange, options: options.map((option) => ({
|
|
17
|
+
const control = (_jsx(Segmented, { "aria-label": ariaLabel, "aria-labelledby": labelledBy, block: block, value: value, disabled: disabled || readOnly || !onChange, options: options.map((option) => ({
|
|
18
18
|
value: option.value,
|
|
19
19
|
/*
|
|
20
20
|
* A segment too narrow for its words shows them whole in the house tooltip, and only then. A
|
|
@@ -6,6 +6,8 @@ export type PhiSwitchControlProps = {
|
|
|
6
6
|
id?: string;
|
|
7
7
|
checked?: boolean;
|
|
8
8
|
label?: ReactNode;
|
|
9
|
+
/** The accessible name where no visible label stands beside the field; it takes precedence over `label`. */
|
|
10
|
+
ariaLabel?: string;
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
readOnly?: boolean;
|
|
11
13
|
loading?: boolean;
|
|
@@ -18,4 +20,4 @@ export type PhiSwitchControlProps = {
|
|
|
18
20
|
gradient?: PhiThemeGradientKey;
|
|
19
21
|
onChange?: (checked: boolean) => void;
|
|
20
22
|
};
|
|
21
|
-
export declare function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }: PhiSwitchControlProps): import("react").JSX.Element;
|
|
23
|
+
export declare function PhiSwitchControl({ id, checked, label, ariaLabel, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }: PhiSwitchControlProps): import("react").JSX.Element;
|
|
@@ -3,9 +3,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Switch } from "antd";
|
|
4
4
|
import { PHI_THEME_GRADIENT_CSS_VARS } from "../../theme/phi-theme-gradients";
|
|
5
5
|
import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
|
|
6
|
-
export function PhiSwitchControl({ id, checked, label, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }) {
|
|
7
|
-
const { labelId, labelledBy } = usePhiControlLabel(label);
|
|
8
|
-
return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, children: _jsx(Switch, { id: id, "aria-labelledby": labelledBy, checked: checked, disabled: disabled || readOnly || !onChange, loading: loading, checkedChildren: checkedLabel, unCheckedChildren: uncheckedLabel, size: size, onChange: onChange, ...(gradient
|
|
6
|
+
export function PhiSwitchControl({ id, checked, label, ariaLabel, disabled, readOnly, loading, checkedLabel, uncheckedLabel, size, gradient, onChange, }) {
|
|
7
|
+
const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
|
|
8
|
+
return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, children: _jsx(Switch, { id: id, "aria-label": ariaLabel, "aria-labelledby": labelledBy, checked: checked, disabled: disabled || readOnly || !onChange, loading: loading, checkedChildren: checkedLabel, unCheckedChildren: uncheckedLabel, size: size, onChange: onChange, ...(gradient
|
|
9
9
|
? {
|
|
10
10
|
className: "phi-switch-gradient",
|
|
11
11
|
style: { "--phi-control-gradient": `var(${PHI_THEME_GRADIENT_CSS_VARS[gradient].paint})` },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type DragEvent, type ReactNode } from "react";
|
|
2
2
|
import type { PhiControlSize, PhiControlVariant } from "../../types/control";
|
|
3
3
|
import type { PhiCalendarAdapterKey } from "../../types/calendar";
|
|
4
|
+
import { type PhiTableSurface } from "../tables/phi-table-surface";
|
|
4
5
|
import type { PhiTableColumnEditorControl, PhiTableProviderFieldType, PhiTableRowIdentity, PhiTableSort, PhiTableColumnSizing, PhiTableLayoutConfig } from "../../types/table-widget";
|
|
5
6
|
import type { PhiControlOption } from "./phi-control-options";
|
|
6
7
|
export type PhiTableControlCellEditor = {
|
|
@@ -129,6 +130,12 @@ export type PhiTableControlProps<TRow extends Record<string, unknown>> = {
|
|
|
129
130
|
*/
|
|
130
131
|
loadingRows?: number;
|
|
131
132
|
bordered?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* The Table's ground, from the Surface vocabulary (`components/tables/phi-table-surface.ts`). Absent is
|
|
135
|
+
* the Table's own ground; `null` is none -- the rows' lines and nothing under them, header and footer
|
|
136
|
+
* included -- which is what an inspector's Table is (`PHI_INSPECTOR_TABLE_CONTROL_PROPS`).
|
|
137
|
+
*/
|
|
138
|
+
surface?: PhiTableSurface;
|
|
132
139
|
striped?: boolean;
|
|
133
140
|
showHeader?: boolean;
|
|
134
141
|
/**
|
|
@@ -155,4 +162,4 @@ export type PhiTableControlProps<TRow extends Record<string, unknown>> = {
|
|
|
155
162
|
onExternalDrop?: (event: DragEvent<HTMLDivElement>) => void;
|
|
156
163
|
};
|
|
157
164
|
export declare function readPhiTableControlValue(row: Record<string, unknown>, path: string): unknown;
|
|
158
|
-
export declare function PhiTableControl<TRow extends Record<string, unknown>>({ rows, rowIdentityPath, columns, columnOrder, sortingMode, sorts, onSortsChange, columnReordering, onColumnOrderChange, rowSelection, pagination, tree, rowReordering, editing, loading, loadingRows: loadingRowCount, bordered, striped, stickyHeader, showHeader, footer, summary, size, emptyText, layout, rowStyle, onRowActivate, onExternalRowDragOver, onExternalRowDrop, onExternalDragOver, onExternalDrop, }: PhiTableControlProps<TRow>): import("react").JSX.Element;
|
|
165
|
+
export declare function PhiTableControl<TRow extends Record<string, unknown>>({ rows, rowIdentityPath, columns, columnOrder, sortingMode, sorts, onSortsChange, columnReordering, onColumnOrderChange, rowSelection, pagination, tree, rowReordering, editing, loading, loadingRows: loadingRowCount, bordered, surface, striped, stickyHeader, showHeader, footer, summary, size, emptyText, layout, rowStyle, onRowActivate, onExternalRowDragOver, onExternalRowDrop, onExternalDragOver, onExternalDrop, }: PhiTableControlProps<TRow>): import("react").JSX.Element;
|
|
@@ -10,6 +10,7 @@ import { Children, cloneElement, createContext, isValidElement, useCallback, use
|
|
|
10
10
|
import { PHI_GREGORY_CALENDAR_ADAPTER_KEY } from "../../types/calendar-keys";
|
|
11
11
|
import { PHI_VISUAL_ANCHOR_PART_ATTRIBUTE } from "../../types/visual-anchors";
|
|
12
12
|
import { PHI_TABLE_LOADING_ROWS, PHI_TABLE_LOADING_ROWS_MAX } from "../../constants/table-loading";
|
|
13
|
+
import { resolvePhiTableSurfaceGround } from "../tables/phi-table-surface";
|
|
13
14
|
import { PhiTruncatedHoverText } from "./phi-truncated-hover-text";
|
|
14
15
|
import { PhiColorControl } from "./phi-color-control";
|
|
15
16
|
import { PhiCheckboxControl } from "./phi-checkbox-control";
|
|
@@ -379,7 +380,7 @@ const PHI_TABLE_COLUMN_TITLE_STYLE = { display: "block", minWidth: 0, overflow:
|
|
|
379
380
|
function renderPhiTableColumnTitle(title) {
|
|
380
381
|
return (_jsx(PhiTruncatedHoverText, { title: title, children: _jsx("span", { style: PHI_TABLE_COLUMN_TITLE_STYLE, children: title }) }));
|
|
381
382
|
}
|
|
382
|
-
export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, sortingMode, sorts, onSortsChange, columnReordering = false, onColumnOrderChange, rowSelection, pagination = false, tree, rowReordering, editing, loading = false, loadingRows: loadingRowCount = PHI_TABLE_LOADING_ROWS, bordered, striped = false, stickyHeader = false, showHeader, footer, summary, size, emptyText, layout, rowStyle, onRowActivate, onExternalRowDragOver, onExternalRowDrop, onExternalDragOver, onExternalDrop, }) {
|
|
383
|
+
export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, sortingMode, sorts, onSortsChange, columnReordering = false, onColumnOrderChange, rowSelection, pagination = false, tree, rowReordering, editing, loading = false, loadingRows: loadingRowCount = PHI_TABLE_LOADING_ROWS, bordered, surface, striped = false, stickyHeader = false, showHeader, footer, summary, size, emptyText, layout, rowStyle, onRowActivate, onExternalRowDragOver, onExternalRowDrop, onExternalDragOver, onExternalDrop, }) {
|
|
383
384
|
const { token } = usePhiConfig();
|
|
384
385
|
const [editingRowIdentityState, setEditingRowIdentity] = useState(null);
|
|
385
386
|
const [rowEditPatch, setRowEditPatch] = useState({});
|
|
@@ -1022,8 +1023,8 @@ export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, s
|
|
|
1022
1023
|
* Whether something of the Table's own stands at its bottom edge. A sticky-top summary does not: it
|
|
1023
1024
|
* rides above the rows and leaves the last row to end the Table.
|
|
1024
1025
|
*/
|
|
1025
|
-
const hasClosingBlock =
|
|
1026
|
-
(
|
|
1026
|
+
const hasClosingBlock = Boolean(footer) ||
|
|
1027
|
+
(!loading && summary != null && summary.placement !== "sticky-top");
|
|
1027
1028
|
const frameRef = useRef(null);
|
|
1028
1029
|
// Where the Shell's Header ends, which is where a sticky header row stops (`styles/controls.css`).
|
|
1029
1030
|
usePhiShellStickyTop({ active: stickyHeader && showHeader !== false, elementRef: frameRef });
|
|
@@ -1053,9 +1054,14 @@ export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, s
|
|
|
1053
1054
|
// No rows, nothing measured: the sticky header's fixed layout would have no widths to fix.
|
|
1054
1055
|
!loading && dataSource.length === 0 ? "phi-table-control--empty" : null,
|
|
1055
1056
|
loading ? "phi-table-control--loading" : null,
|
|
1057
|
+
surface !== undefined ? "phi-table-control--surface" : null,
|
|
1056
1058
|
]
|
|
1057
1059
|
.filter(Boolean)
|
|
1058
|
-
.join(" "), style: {
|
|
1060
|
+
.join(" "), style: {
|
|
1061
|
+
"--phi-table-striped-row-background": token.colorFillAlter,
|
|
1062
|
+
// A stated Surface is the Table's only ground (`styles/controls.css`, "A Table that states its Surface").
|
|
1063
|
+
...(surface !== undefined ? { "--phi-table-surface-ground": resolvePhiTableSurfaceGround(surface) } : {}),
|
|
1064
|
+
}, rowKey: (row) => loading
|
|
1059
1065
|
? `__phi_table_loading_${String(row[PHI_TABLE_LOADING_ROW])}`
|
|
1060
1066
|
: String(readIdentity(row, rowIdentityPath)), columns: renderedColumns, dataSource: loading ? loadingRows : dataSource, bordered: bordered, showHeader: showHeader, tableLayout: layout.mode, size: size, rowClassName: (_row, index) => striped && index % 2 === 1 ? "phi-table-control__row--striped" : "", rowSelection: loading ? loadingRowSelection : antdRowSelection, components: rowReordering?.enabled && !loading ? { body: { row: PhiTableSortableRow } } : undefined, scroll: layout.overflowX === "auto" ? { x: true } : undefined, sticky: stickyHeader && showHeader !== false ? true : undefined, pagination: pagination === false ? false : {
|
|
1061
1067
|
...{ [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "pagination" },
|
|
@@ -1077,7 +1083,7 @@ export function PhiTableControl({ rows, rowIdentityPath, columns, columnOrder, s
|
|
|
1077
1083
|
pageSizeOptions: pagination.pageSizeOptions?.map(String),
|
|
1078
1084
|
showSizeChanger: pagination.showSizeChanger,
|
|
1079
1085
|
onChange: pagination.onChange,
|
|
1080
|
-
}, footer: footer
|
|
1086
|
+
}, footer: footer ? () => (_jsx(Flex, { [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "footer", align: "center", justify: footer.align ?? "start", style: { minHeight: "1lh" }, gap: "small", wrap: true, children: loading ? null : footer.content })) : undefined, summary: summaryNode, expandable: tree && !loading ? {
|
|
1081
1087
|
childrenColumnName: "__phiTableChildren",
|
|
1082
1088
|
showExpandColumn: false,
|
|
1083
1089
|
expandedRowKeys: [...tree.expandedRowIdentities],
|
|
@@ -11,6 +11,7 @@ import { readPhiDotPath as readPath } from "../../helpers/dot-path";
|
|
|
11
11
|
import { movePhiTableBindingRows } from "../../helpers/table-binding";
|
|
12
12
|
import { PhiIcon } from "../shell/phi-icon";
|
|
13
13
|
import { readPhiFormTableFieldText as readTableFieldText } from "./table-field-text";
|
|
14
|
+
import { isPhiTableSurfaceDrawable } from "../tables/phi-table-surface";
|
|
14
15
|
function readRecords(value) {
|
|
15
16
|
return Array.isArray(value)
|
|
16
17
|
? value.filter((entry) => isPhiRecord(entry)).map((entry) => ({ ...entry }))
|
|
@@ -111,6 +112,20 @@ function applyMove(rows, identityPath, parentPath, move) {
|
|
|
111
112
|
? setPath(row, parentPath, parentIdentity)
|
|
112
113
|
: row);
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* A table field's `surface`: the Table's ground (`components/tables/phi-table-surface.ts`). Left out, the
|
|
117
|
+
* Table's own; `null`, none -- an inspector's Form says so through `PHI_INSPECTOR_TABLE_CONTROL_PROPS`.
|
|
118
|
+
* A Surface the Table cannot draw is a mistake in the descriptor and is said as one.
|
|
119
|
+
*/
|
|
120
|
+
function readTableFieldSurface(value, fieldKey) {
|
|
121
|
+
if (value === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
if (value === null)
|
|
124
|
+
return null;
|
|
125
|
+
if (isPhiRecord(value) && isPhiTableSurfaceDrawable(value))
|
|
126
|
+
return value;
|
|
127
|
+
throw new Error(`The table field "${fieldKey}" states a surface a Table cannot draw: null, or one colour of ground and nothing else.`);
|
|
128
|
+
}
|
|
114
129
|
export function PhiCompoundTableFormControl({ field, label, description, value, onChange, disabled, readOnly, formContext, labels, }) {
|
|
115
130
|
const rows = useMemo(() => readRecords(value), [value]);
|
|
116
131
|
const nextRowSequenceRef = useRef(0);
|
|
@@ -197,7 +212,7 @@ export function PhiCompoundTableFormControl({ field, label, description, value,
|
|
|
197
212
|
icon: _jsx(PhiIcon, { name: "plus", size: "inherit" }),
|
|
198
213
|
type: "primary",
|
|
199
214
|
}], compact: true, showLabels: true, size: "small", disabled: locked, onActivate: (key) => { if (key === "add")
|
|
200
|
-
appendRow(); } })) : null }), _jsx(PhiTableControl, { rows: rows, rowIdentityPath: identityPath, columns: renderedColumns, columnOrder: columnOrder, sortingMode: "none", sorts: [], bordered: config.bordered === true, striped: config.striped === true, size: "small", emptyText: emptyText, layout: layout, rowReordering: config.reorder === true && !locked ? {
|
|
215
|
+
appendRow(); } })) : null }), _jsx(PhiTableControl, { rows: rows, rowIdentityPath: identityPath, columns: renderedColumns, columnOrder: columnOrder, sortingMode: "none", sorts: [], bordered: config.bordered === true, surface: readTableFieldSurface(config.surface, field.key), stickyHeader: config.stickyHeader === true, striped: config.striped === true, size: "small", emptyText: emptyText, layout: layout, rowReordering: config.reorder === true && !locked ? {
|
|
201
216
|
enabled: true,
|
|
202
217
|
onMove: (move) => onChange?.(applyMove(rows, identityPath, typeof config.parentRowIdentityPath === "string" ? config.parentRowIdentityPath : null, move)),
|
|
203
218
|
} : undefined })] }));
|
|
@@ -6,8 +6,6 @@ import { createPhiSignalAddress } from "../../../types/signals";
|
|
|
6
6
|
import { usePhiSignalDispatcher, usePhiSignalListener } from "../../runtime/runtime-signal-bus";
|
|
7
7
|
import { usePhiSignalIdentity } from "../../runtime/runtime-signal-identity";
|
|
8
8
|
import { PhiLayoutAnchoredOverlay } from "./phi-layout-anchored-overlay";
|
|
9
|
-
import { PhiDescriptionHint } from "../../controls/phi-description-tooltip-icon";
|
|
10
|
-
import { PHI_SPACE } from "../../../theme/antd-css-var-contract";
|
|
11
9
|
import { PhiCollapseControl, } from "../../controls/phi-collapse-control";
|
|
12
10
|
import { PhiBaseLayoutSlotStateProvider, usePhiBaseLayoutSlotStates, PhiBaseLayoutSlotScope, } from "./phi-base-layout-client";
|
|
13
11
|
import { resolvePhiBaseLayoutChrome, } from "../phi-layout-view-model";
|
|
@@ -372,12 +370,10 @@ function PhiCollapsibleLayoutBody({ blockId, slots, slotKeys, slotMeta, panelMin
|
|
|
372
370
|
cursor: "text",
|
|
373
371
|
}, children: title }))
|
|
374
372
|
: title;
|
|
375
|
-
const description = slotDescriptions?.[slotIndex]?.trim();
|
|
376
373
|
return {
|
|
377
374
|
key: slotKey,
|
|
378
|
-
label
|
|
379
|
-
|
|
380
|
-
: label,
|
|
375
|
+
label,
|
|
376
|
+
description: slotDescriptions?.[slotIndex]?.trim() || undefined,
|
|
381
377
|
forceRender: isEditMode || isHiddenSlot,
|
|
382
378
|
hidden: isHiddenSlot,
|
|
383
379
|
children: childContent
|
|
@@ -107,7 +107,7 @@ export type PhiMediaUploadProgressHandler = (progress: number) => void;
|
|
|
107
107
|
* uses the Add-on's root. Making it a parameter is what lets the acceptance, the progress, the refusal
|
|
108
108
|
* and the labels stay shared instead of being written twice with the second one drifting.
|
|
109
109
|
*/
|
|
110
|
-
export type PhiMediaUploadSessionRunner = (file: File, onProgress?: PhiMediaUploadProgressHandler, options?: PhiMediaUploadInitOptions, signal?: AbortSignal) => Promise<{
|
|
110
|
+
export type PhiMediaUploadSessionRunner = (file: File, onProgress?: PhiMediaUploadProgressHandler, options?: PhiMediaUploadInitOptions, signal?: AbortSignal, onPhase?: (phase: PhiUploadPhase) => void) => Promise<{
|
|
111
111
|
asset: {
|
|
112
112
|
id: number;
|
|
113
113
|
};
|
|
@@ -141,7 +141,7 @@ type PhiMediaUploadInitSession = {
|
|
|
141
141
|
/** Null where the Server asked for none: every plan but one sent in parts. */
|
|
142
142
|
heartbeat: PhiMediaUploadHeartbeat | null;
|
|
143
143
|
};
|
|
144
|
-
type PhiMediaUploadHeartbeat = {
|
|
144
|
+
export type PhiMediaUploadHeartbeat = {
|
|
145
145
|
url: string;
|
|
146
146
|
intervalMs: number;
|
|
147
147
|
};
|
|
@@ -272,16 +272,73 @@ export declare function uploadPhiMediaUploadBody(plan: PhiMediaUploadPlan, file:
|
|
|
272
272
|
/** Parts an earlier attempt delivered, where this session was taken over rather than opened. */
|
|
273
273
|
stored?: readonly PhiMediaUploadStoredPart[],
|
|
274
274
|
/** Stops the body where it is; what is in flight is aborted and the call throws `cancelled`. */
|
|
275
|
-
signal?: AbortSignal
|
|
275
|
+
signal?: AbortSignal,
|
|
276
|
+
/** What a delivered part answers with (`PhiUploadPartReceipt`); a storage's entity tag unless said. */
|
|
277
|
+
receipt?: PhiUploadPartReceipt): Promise<PhiMediaUploadUploadResponse>;
|
|
276
278
|
/**
|
|
277
|
-
*
|
|
279
|
+
* What a delivered part of a body answers with.
|
|
280
|
+
*
|
|
281
|
+
* `etag`: the storage's entity tag, which a completion names every part by -- a part delivered to a
|
|
282
|
+
* presigned storage address, whose tag the browser has to read and hand on. `none`: nothing to hand on --
|
|
283
|
+
* a part delivered to a route of this Site's server, which completes the assembly itself and asks the
|
|
284
|
+
* storage what it holds.
|
|
285
|
+
*/
|
|
286
|
+
export type PhiUploadPartReceipt = "etag" | "none";
|
|
287
|
+
/**
|
|
288
|
+
* Where an upload stands, for a surface that says more than a percentage: the file is hashed and the
|
|
289
|
+
* session opened (`checksum`), its body travels (`transfer`, which the progress figures belong to), and
|
|
290
|
+
* the place it went settles it (`finish`) -- an Asset made, a file hashed whole and recorded.
|
|
291
|
+
*/
|
|
292
|
+
export type PhiUploadPhase = "checksum" | "transfer" | "finish";
|
|
293
|
+
/** One upload, opened by its target: how the body travels, and how its target settles or drops it. */
|
|
294
|
+
export type PhiUploadSession<TResult> = {
|
|
295
|
+
plan: PhiMediaUploadPlan;
|
|
296
|
+
/** Parts an earlier attempt delivered; the plan addresses only what is missing. */
|
|
297
|
+
uploaded: readonly PhiMediaUploadStoredPart[];
|
|
298
|
+
/** Null where the target asks for none. */
|
|
299
|
+
heartbeat: PhiMediaUploadHeartbeat | null;
|
|
300
|
+
/** What a delivered part answers with. `etag` where the target says nothing. */
|
|
301
|
+
partReceipt?: PhiUploadPartReceipt;
|
|
302
|
+
/**
|
|
303
|
+
* Called when the body starts to travel; returns the way to stop. For a target that tells its server
|
|
304
|
+
* when the page goes away mid-body (`pagehide`).
|
|
305
|
+
*/
|
|
306
|
+
watchLeaving?: () => () => void;
|
|
307
|
+
/** The body did not arrive, for whichever reason the error says: what the target does about it. */
|
|
308
|
+
abandon: (error: unknown, signal: AbortSignal | undefined) => Promise<void>;
|
|
309
|
+
/** The body arrived: the target settles it, with what the transport reported back. */
|
|
310
|
+
finish: (completion: unknown, signal: AbortSignal | undefined) => Promise<TResult>;
|
|
311
|
+
};
|
|
312
|
+
/** Where an upload goes: Core's Media routes, or another place that takes a body the same way. */
|
|
313
|
+
export type PhiUploadTarget<TResult> = {
|
|
314
|
+
/** Hashes what it needs and opens -- or takes up again -- the session for this file. */
|
|
315
|
+
open: (file: File, signal: AbortSignal | undefined) => Promise<PhiUploadSession<TResult>>;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* One file through an upload target, from chosen to settled.
|
|
319
|
+
*
|
|
320
|
+
* The sequence every upload of this package runs, whichever target it is for: open (hashing first), keep
|
|
321
|
+
* the session alive while parts travel, send the body by its plan -- the parts the target does not hold
|
|
322
|
+
* yet, several at once, each tried again after a transport failure or a `5xx` -- and settle it. `signal`
|
|
323
|
+
* stops it up to the moment `finish` begins: an open in flight is aborted, a body in flight is aborted
|
|
324
|
+
* and reported `cancelled`, and the target is told (`abandon`). Once `finish` runs it is not stopped
|
|
325
|
+
* midway -- the target is already turning the body into what it stores, and stopping would only hide the
|
|
326
|
+
* answer; `finish` itself decides whether it still waits for one.
|
|
327
|
+
*/
|
|
328
|
+
export declare function runPhiUploadSession<TResult>(target: PhiUploadTarget<TResult>, file: File, { onProgress, onPhase, signal, }?: {
|
|
329
|
+
onProgress?: PhiMediaUploadProgressHandler;
|
|
330
|
+
onPhase?: (phase: PhiUploadPhase) => void;
|
|
331
|
+
signal?: AbortSignal;
|
|
332
|
+
}): Promise<TResult>;
|
|
333
|
+
/**
|
|
334
|
+
* One file through Core's own upload routes (`runPhiUploadSession` with Core's Media target).
|
|
278
335
|
*
|
|
279
336
|
* `signal` stops it up to the moment finalize is sent: an init in flight is aborted, a body in flight is
|
|
280
337
|
* aborted and reported `cancelled`, so the Server clears up the reservation and whatever arrived. Once
|
|
281
338
|
* finalize is sent it is not stopped -- the Server is already turning the body into an Asset, and aborting
|
|
282
339
|
* the request would only hide the answer. A caller that stopped it ignores what comes back.
|
|
283
340
|
*/
|
|
284
|
-
export declare function runPhiMediaUploadSession(file: File, onProgress?: PhiMediaUploadProgressHandler, options?: PhiMediaUploadInitOptions, signal?: AbortSignal): Promise<PhiMediaUploadSessionResult>;
|
|
341
|
+
export declare function runPhiMediaUploadSession(file: File, onProgress?: PhiMediaUploadProgressHandler, options?: PhiMediaUploadInitOptions, signal?: AbortSignal, onPhase?: (phase: PhiUploadPhase) => void): Promise<PhiMediaUploadSessionResult>;
|
|
285
342
|
/**
|
|
286
343
|
* A place an Add-on's route made for a file, as `assets:v1` answered it.
|
|
287
344
|
*
|
|
@@ -504,7 +504,7 @@ export async function initPhiMediaUploadSession(file, options, signal) {
|
|
|
504
504
|
* Retried on a transport failure and on a `5xx`, and never on a `4xx`: a signature the endpoint rejected
|
|
505
505
|
* will be rejected again, and repeating it only delays saying so.
|
|
506
506
|
*/
|
|
507
|
-
async function uploadPhiMediaUploadPart(part, body, onPartProgress, signal) {
|
|
507
|
+
async function uploadPhiMediaUploadPart(part, body, onPartProgress, signal, receipt = "etag") {
|
|
508
508
|
let lastError = null;
|
|
509
509
|
for (let attempt = 1; attempt <= PHI_MEDIA_UPLOAD_PART_ATTEMPTS; attempt += 1) {
|
|
510
510
|
throwIfPhiMediaUploadAborted(signal);
|
|
@@ -529,8 +529,8 @@ async function uploadPhiMediaUploadPart(part, body, onPartProgress, signal) {
|
|
|
529
529
|
reject(new PhiMediaUploadError(`Part ${part.partNumber} was refused (${xhr.status}).`, PHI_MEDIA_UPLOAD_FAILURE_REASONS.StorageRejected, xhr.status));
|
|
530
530
|
return;
|
|
531
531
|
}
|
|
532
|
-
const eTag = (xhr.getResponseHeader("etag") ?? "").trim();
|
|
533
|
-
if (!eTag) {
|
|
532
|
+
const eTag = receipt === "etag" ? (xhr.getResponseHeader("etag") ?? "").trim() : "";
|
|
533
|
+
if (receipt === "etag" && !eTag) {
|
|
534
534
|
reject(new PhiMediaUploadError(`Part ${part.partNumber} arrived without an entity tag, so it cannot be assembled.`, PHI_MEDIA_UPLOAD_FAILURE_REASONS.ClientError, xhr.status));
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
@@ -582,7 +582,7 @@ async function uploadPhiMediaUploadPart(part, body, onPartProgress, signal) {
|
|
|
582
582
|
*/
|
|
583
583
|
async function uploadPhiMediaUploadParts(plan, file, onProgress,
|
|
584
584
|
/** What an earlier attempt already delivered, which this one neither sends nor waits for. */
|
|
585
|
-
stored = [], signal) {
|
|
585
|
+
stored = [], signal, receipt = "etag") {
|
|
586
586
|
const loadedByPart = new Map();
|
|
587
587
|
const report = () => onProgress?.(resolvePhiMediaUploadPartProgress(loadedByPart, file.size));
|
|
588
588
|
const stop = new AbortController();
|
|
@@ -616,7 +616,7 @@ stored = [], signal) {
|
|
|
616
616
|
return;
|
|
617
617
|
loadedByPart.set(part.partNumber, loadedBytes);
|
|
618
618
|
report();
|
|
619
|
-
}, stop.signal));
|
|
619
|
+
}, stop.signal, receipt));
|
|
620
620
|
}
|
|
621
621
|
catch (error) {
|
|
622
622
|
// The first failure is the one reported; the others are this one stopping them.
|
|
@@ -648,10 +648,12 @@ export async function uploadPhiMediaUploadBody(plan, file, onProgress,
|
|
|
648
648
|
/** Parts an earlier attempt delivered, where this session was taken over rather than opened. */
|
|
649
649
|
stored = [],
|
|
650
650
|
/** Stops the body where it is; what is in flight is aborted and the call throws `cancelled`. */
|
|
651
|
-
signal
|
|
651
|
+
signal,
|
|
652
|
+
/** What a delivered part answers with (`PhiUploadPartReceipt`); a storage's entity tag unless said. */
|
|
653
|
+
receipt = "etag") {
|
|
652
654
|
throwIfPhiMediaUploadAborted(signal);
|
|
653
655
|
if (plan.kind === "multipart-put") {
|
|
654
|
-
return await uploadPhiMediaUploadParts(plan, file, onProgress, stored, signal);
|
|
656
|
+
return await uploadPhiMediaUploadParts(plan, file, onProgress, stored, signal, receipt);
|
|
655
657
|
}
|
|
656
658
|
if (plan.kind !== "proxy-stream" && plan.kind !== "presigned-put") {
|
|
657
659
|
// A newer control plane issued a plan this Client cannot carry out. Saying so is the only safe
|
|
@@ -778,32 +780,36 @@ async function readPhiMediaUploadCancellation(run, signal) {
|
|
|
778
780
|
}
|
|
779
781
|
}
|
|
780
782
|
/**
|
|
781
|
-
* One file through
|
|
783
|
+
* One file through an upload target, from chosen to settled.
|
|
782
784
|
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
* the
|
|
785
|
+
* The sequence every upload of this package runs, whichever target it is for: open (hashing first), keep
|
|
786
|
+
* the session alive while parts travel, send the body by its plan -- the parts the target does not hold
|
|
787
|
+
* yet, several at once, each tried again after a transport failure or a `5xx` -- and settle it. `signal`
|
|
788
|
+
* stops it up to the moment `finish` begins: an open in flight is aborted, a body in flight is aborted
|
|
789
|
+
* and reported `cancelled`, and the target is told (`abandon`). Once `finish` runs it is not stopped
|
|
790
|
+
* midway -- the target is already turning the body into what it stores, and stopping would only hide the
|
|
791
|
+
* answer; `finish` itself decides whether it still waits for one.
|
|
787
792
|
*/
|
|
788
|
-
export async function
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
const
|
|
793
|
+
export async function runPhiUploadSession(target, file, { onProgress, onPhase, signal, } = {}) {
|
|
794
|
+
onPhase?.("checksum");
|
|
795
|
+
const session = await readPhiMediaUploadCancellation(() => target.open(file, signal), signal);
|
|
796
|
+
const standDown = session.watchLeaving?.() ?? (() => { });
|
|
797
|
+
const stopBeating = keepPhiMediaUploadHeartbeat(session.heartbeat);
|
|
798
|
+
onPhase?.("transfer");
|
|
792
799
|
let upload;
|
|
793
800
|
try {
|
|
794
|
-
upload = await uploadPhiMediaUploadBody(
|
|
795
|
-
// Stopped after the last byte and before
|
|
801
|
+
upload = await uploadPhiMediaUploadBody(session.plan, file, onProgress, session.uploaded, signal, session.partReceipt);
|
|
802
|
+
// Stopped after the last byte and before it was settled: the body is there, and nobody wants it.
|
|
796
803
|
throwIfPhiMediaUploadAborted(signal);
|
|
797
804
|
}
|
|
798
805
|
catch (uploadError) {
|
|
799
806
|
stopBeating();
|
|
800
807
|
standDown();
|
|
801
|
-
|
|
802
|
-
await reportPhiMediaUploadFailure(init.reportUrl, readPhiMediaUploadFailureReason(uploadError), uploadError instanceof Error ? uploadError.message : null);
|
|
808
|
+
await session.abandon(uploadError, signal);
|
|
803
809
|
throw uploadError;
|
|
804
810
|
}
|
|
805
811
|
/*
|
|
806
|
-
* Stood down before
|
|
812
|
+
* Stood down before settling begins, and deliberately not after it answers.
|
|
807
813
|
*
|
|
808
814
|
* Once the Server holds the finalize request it copies the staged object onto its final key and closes
|
|
809
815
|
* the session; a beacon arriving in the middle of that would be a second request racing the first for
|
|
@@ -814,12 +820,44 @@ export async function runPhiMediaUploadSession(file, onProgress, options, signal
|
|
|
814
820
|
*/
|
|
815
821
|
stopBeating();
|
|
816
822
|
standDown();
|
|
817
|
-
|
|
823
|
+
onPhase?.("finish");
|
|
824
|
+
return await session.finish(upload.completion, signal);
|
|
825
|
+
}
|
|
826
|
+
/** Core's own Media upload routes as an upload target: init, the report of a failure, and finalize. */
|
|
827
|
+
function createPhiMediaUploadTarget(options) {
|
|
818
828
|
return {
|
|
819
|
-
|
|
820
|
-
|
|
829
|
+
open: async (file, signal) => {
|
|
830
|
+
const init = await initPhiMediaUploadSession(file, options, signal);
|
|
831
|
+
return {
|
|
832
|
+
plan: init.plan,
|
|
833
|
+
uploaded: init.uploaded,
|
|
834
|
+
heartbeat: init.heartbeat,
|
|
835
|
+
watchLeaving: () => reportPhiMediaUploadAbandonmentOnLeaving(init.reportUrl, init.plan),
|
|
836
|
+
// The Server cannot see this leg, so it is told rather than left to infer it from an expiry.
|
|
837
|
+
abandon: (error) => reportPhiMediaUploadFailure(init.reportUrl, readPhiMediaUploadFailureReason(error), error instanceof Error ? error.message : null),
|
|
838
|
+
finish: async (completion) => {
|
|
839
|
+
const finalize = await finalizePhiMediaUploadSession(init.finalizeUrl, completion);
|
|
840
|
+
return { asset: finalize.asset, token: init.token };
|
|
841
|
+
},
|
|
842
|
+
};
|
|
843
|
+
},
|
|
821
844
|
};
|
|
822
845
|
}
|
|
846
|
+
/**
|
|
847
|
+
* One file through Core's own upload routes (`runPhiUploadSession` with Core's Media target).
|
|
848
|
+
*
|
|
849
|
+
* `signal` stops it up to the moment finalize is sent: an init in flight is aborted, a body in flight is
|
|
850
|
+
* aborted and reported `cancelled`, so the Server clears up the reservation and whatever arrived. Once
|
|
851
|
+
* finalize is sent it is not stopped -- the Server is already turning the body into an Asset, and aborting
|
|
852
|
+
* the request would only hide the answer. A caller that stopped it ignores what comes back.
|
|
853
|
+
*/
|
|
854
|
+
export async function runPhiMediaUploadSession(file, onProgress, options, signal, onPhase) {
|
|
855
|
+
return await runPhiUploadSession(createPhiMediaUploadTarget(options), file, {
|
|
856
|
+
...(onProgress ? { onProgress } : {}),
|
|
857
|
+
...(onPhase ? { onPhase } : {}),
|
|
858
|
+
...(signal ? { signal } : {}),
|
|
859
|
+
});
|
|
860
|
+
}
|
|
823
861
|
/**
|
|
824
862
|
* Carries out an upload an Add-on's own route reserved.
|
|
825
863
|
*
|
|
@@ -83,6 +83,8 @@ export type PhiAssetInspectorWidgetLabels = {
|
|
|
83
83
|
logoVariantLabel: string;
|
|
84
84
|
landscapeVariantLabel: string;
|
|
85
85
|
portraitVariantLabel: string;
|
|
86
|
+
iconVariantLabel: string;
|
|
87
|
+
shareVariantLabel: string;
|
|
86
88
|
publicUrlLabel: string;
|
|
87
89
|
contentTypeLabel: string;
|
|
88
90
|
originalNameLabel: string;
|
|
@@ -87,6 +87,8 @@ export const PHI_ASSET_MODULE_DEFAULT_LABELS = {
|
|
|
87
87
|
logoVariantLabel: "Logo",
|
|
88
88
|
landscapeVariantLabel: "Landscape",
|
|
89
89
|
portraitVariantLabel: "Portrait",
|
|
90
|
+
iconVariantLabel: "Icon",
|
|
91
|
+
shareVariantLabel: "Share",
|
|
90
92
|
publicUrlLabel: "Public URL",
|
|
91
93
|
contentTypeLabel: "Content type",
|
|
92
94
|
originalNameLabel: "Original name",
|