@phis/ui 0.7.4 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +5 -4
- package/components/controls/phi-options-provider.d.ts +14 -1
- package/components/controls/phi-options-provider.js +73 -2
- package/components/forms/auth-admin-settings-labels.d.ts +1 -1
- package/components/forms/auth-admin-settings-labels.js +2 -2
- package/components/forms/form-descriptor-contract.d.ts +1 -1
- package/components/forms/form-descriptor-contract.js +1 -1
- package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
- package/components/forms/form-descriptor-runtime-client.js +33 -11
- package/components/forms/form-media-limits.d.ts +12 -0
- package/components/forms/form-media-limits.js +14 -0
- package/components/forms/form-provider-registry.d.ts +8 -0
- package/components/forms/form-record-title.d.ts +14 -0
- package/components/forms/form-record-title.js +38 -0
- package/components/forms/form-widget-config.d.ts +3 -0
- package/components/forms/form-widget-config.js +2 -0
- package/components/forms/phi-form-widget.d.ts +1 -1
- package/components/forms/phi-form-widget.js +4 -0
- package/components/overlays/phi-overlay-container-client.js +8 -8
- package/components/overlays/phi-overlay-title.d.ts +7 -0
- package/components/overlays/phi-overlay-title.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +3 -1
- package/components/tables/client/phi-table-binding.js +90 -49
- package/components/tables/client/phi-table-filter-options.d.ts +27 -0
- package/components/tables/client/phi-table-filter-options.js +35 -0
- package/components/widgets/accessible-areas.d.ts +1 -1
- package/components/widgets/accessible-areas.js +1 -1
- package/components/widgets/client/shared/phi-choice-controller.js +22 -15
- package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
- package/components/widgets/client/shared/phi-rendered-value.js +49 -1
- package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
- package/components/widgets/client/shared/phi-table-provider.js +22 -0
- package/components/widgets/label-sets/admin-users.d.ts +15 -0
- package/components/widgets/label-sets/admin-users.js +31 -0
- package/constants/core-data-provider-keys.d.ts +7 -0
- package/constants/core-data-provider-keys.js +7 -0
- package/constants/phi-base-role-metadata.d.ts +2 -2
- package/constants/phi-base-role-metadata.js +1 -1
- package/constants/runtime-module-ownership.js +3 -0
- package/forms.d.ts +1 -1
- package/forms.js +1 -1
- package/gateway/capability-media-limits.d.ts +10 -0
- package/gateway/capability-media-limits.js +40 -0
- package/gateway/server-capabilities.js +4 -0
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +60 -0
- package/helpers/record-title.d.ts +7 -0
- package/helpers/record-title.js +25 -0
- package/helpers/record-widget.d.ts +15 -0
- package/helpers/record-widget.js +57 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
- package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
- package/plugins/runtime-modules/accounting/data-providers.js +127 -0
- package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
- package/plugins/runtime-modules/accounting/definition.js +5 -3
- package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
- package/plugins/runtime-modules/accounting/ids.js +27 -0
- package/plugins/runtime-modules/accounting/module.d.ts +52 -0
- package/plugins/runtime-modules/accounting/presets.js +23 -4
- package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
- package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
- package/plugins/runtime-modules/area-definitions.js +2 -2
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +11 -6
- package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
- package/plugins/runtime-modules/core/cards.js +2 -2
- package/plugins/runtime-modules/core/client-data-providers.js +5 -0
- package/plugins/runtime-modules/core/data-providers.js +14 -0
- package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
- package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
- package/plugins/runtime-modules/core/widgets/cascader/client.js +13 -12
- package/plugins/runtime-modules/core/widgets/checkbox-group/client.js +5 -4
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
- package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/multi-select/client.js +6 -4
- package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
- package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
- package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
- package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
- package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
- package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
- package/plugins/runtime-modules/groups/data-providers.js +1 -1
- package/plugins/runtime-modules/groups/definition.js +1 -1
- package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
- package/plugins/runtime-modules/groups/page-visibility.js +1 -1
- package/plugins/runtime-modules/groups/presets.js +1 -1
- package/plugins/runtime-modules/groups/services/options.js +1 -1
- package/plugins/runtime-modules/groups/services/table.js +1 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
- package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
- package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/data-providers.js +1 -0
- package/plugins/runtime-modules/user-management/forms.js +22 -0
- package/plugins/runtime-modules/user-management/presets.js +2 -2
- package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
- package/plugins/runtime-modules/user-management/services/options.js +14 -6
- package/plugins/runtime-modules/user-management/services/table.js +12 -3
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
- package/types/access.d.ts +1 -1
- package/types/access.js +7 -7
- package/types/core-widget-placements.d.ts +7 -0
- package/types/form-descriptor.d.ts +1 -1
- package/types/record-widget.d.ts +35 -0
- package/types/server-capabilities.d.ts +1 -1
- package/types/table-widget.d.ts +20 -0
- package/types/table-widget.js +44 -0
|
@@ -2,7 +2,7 @@ import { PHI_SHARED_PACKAGE_NAME } from "../../constants/package";
|
|
|
2
2
|
import { createPhiRuntimeModuleId } from "../../constants/module-identity";
|
|
3
3
|
import { createPhiCoreRuntimeControllerAddress } from "../../components/runtime/core-runtime-controller-address";
|
|
4
4
|
import { PHI_DEFAULT_PUB_AREA_PRESET_KEY } from "./preset-contracts/pub-area";
|
|
5
|
-
import { PHI_VIEWER_ACCESS_ACCOUNTING, PHI_VIEWER_ACCESS_ANYONE, PHI_VIEWER_ACCESS_AUTHENTICATED, PHI_VIEWER_ACCESS_CONTENT_EDITING,
|
|
5
|
+
import { PHI_VIEWER_ACCESS_ACCOUNTING, PHI_VIEWER_ACCESS_ANYONE, PHI_VIEWER_ACCESS_AUTHENTICATED, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_SITE_MAINTENANCE, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING, PHI_VIEWER_ACCESS_SITE_ADMIN, } from "../../types/access";
|
|
6
6
|
/*
|
|
7
7
|
* The Modules named here are named by id, as data. Importing their `ids.ts` bound every file that
|
|
8
8
|
* reads this one -- the Foundation among them -- to the Module folders at compile time (MODULES.md,
|
|
@@ -269,7 +269,7 @@ export const PHI_ADMIN_RUNTIME_AREA_DEFINITIONS = [
|
|
|
269
269
|
baseModuleId: PHI_ADMIN_RUNTIME_MODULE_ID,
|
|
270
270
|
shellPresetKey: "admin-area-preset",
|
|
271
271
|
shellProviders: "base",
|
|
272
|
-
accessPolicy:
|
|
272
|
+
accessPolicy: PHI_VIEWER_ACCESS_SITE_MAINTENANCE,
|
|
273
273
|
navigationSurfaces: [
|
|
274
274
|
{
|
|
275
275
|
navKey: "admin:sidebar",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PhiMediaAssetTile, PhiMediaKindValue } from "../../../types/media";
|
|
2
2
|
import { type PhiConfigReader } from "../../../components/widgets/config/strict-config-reader";
|
|
3
|
+
import type { PhiMediaUploadAcceptance } from "../../../components/media/phi-media-upload";
|
|
4
|
+
import type { PhiAddonMediaLimits } from "../../../types/server-capabilities";
|
|
3
5
|
export type PhiMediaAssetFieldConfig = {
|
|
4
6
|
/** Which kind of Asset the picker lists. */
|
|
5
7
|
mediaType: PhiMediaKindValue;
|
|
@@ -48,3 +50,16 @@ export declare function isPhiMediaAssetFieldSelectable(config: PhiMediaAssetFiel
|
|
|
48
50
|
* could not name reaches it unrefused.
|
|
49
51
|
*/
|
|
50
52
|
export declare function readPhiMediaAssetFieldUploadRefusal(config: PhiMediaAssetFieldConfig, asset: Pick<PhiMediaAssetTile, "kind" | "deliveryPolicy" | "lifecycleStatus">): "kind" | "notPublic" | null;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the Add-on behind the Form takes the field's kind at all (`PhiAddonMediaLimits.kinds`). A field
|
|
55
|
+
* whose kind it does not take refuses every file before it is sent, with the upload's own "type not
|
|
56
|
+
* allowed": the kind is the field's, so no file of another kind is what it was opened for either.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isPhiMediaFieldKindTaken(mediaType: PhiMediaKindValue, limits: PhiAddonMediaLimits | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* What an upload in a Media field takes: files of the field's kind, one or several, and -- where the
|
|
61
|
+
* Add-on behind the Form states one -- no larger than its `maxFileBytes`, refused before it is sent with
|
|
62
|
+
* the upload's own "too large" (`readPhiMediaUploadRejection`). Shared by `media-asset` and
|
|
63
|
+
* `media-assets`, so the two fields cannot apply one limit two ways.
|
|
64
|
+
*/
|
|
65
|
+
export declare function readPhiMediaFieldUploadAcceptance(mediaType: PhiMediaKindValue, multiple: boolean, limits: PhiAddonMediaLimits | undefined): PhiMediaUploadAcceptance;
|
|
@@ -56,3 +56,24 @@ export function readPhiMediaAssetFieldUploadRefusal(config, asset) {
|
|
|
56
56
|
return "kind";
|
|
57
57
|
return isPhiMediaAssetFieldSelectable(config, asset) ? null : "notPublic";
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether the Add-on behind the Form takes the field's kind at all (`PhiAddonMediaLimits.kinds`). A field
|
|
61
|
+
* whose kind it does not take refuses every file before it is sent, with the upload's own "type not
|
|
62
|
+
* allowed": the kind is the field's, so no file of another kind is what it was opened for either.
|
|
63
|
+
*/
|
|
64
|
+
export function isPhiMediaFieldKindTaken(mediaType, limits) {
|
|
65
|
+
return limits?.kinds == null || limits.kinds.includes(mediaType);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What an upload in a Media field takes: files of the field's kind, one or several, and -- where the
|
|
69
|
+
* Add-on behind the Form states one -- no larger than its `maxFileBytes`, refused before it is sent with
|
|
70
|
+
* the upload's own "too large" (`readPhiMediaUploadRejection`). Shared by `media-asset` and
|
|
71
|
+
* `media-assets`, so the two fields cannot apply one limit two ways.
|
|
72
|
+
*/
|
|
73
|
+
export function readPhiMediaFieldUploadAcceptance(mediaType, multiple, limits) {
|
|
74
|
+
return {
|
|
75
|
+
kinds: [mediaType],
|
|
76
|
+
multiple,
|
|
77
|
+
...(limits?.maxFileBytes != null ? { maxBytes: limits.maxFileBytes } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -16,6 +16,10 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
|
|
|
16
16
|
* or, for a `publicOnly` field, one that is not public is left in the list unchosen, and the field says
|
|
17
17
|
* why. While the file is on its way the Form's submit is held, as the upload field holds it, and closing
|
|
18
18
|
* the picker stops it.
|
|
19
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) are applied before a file is
|
|
20
|
+
* sent: one larger than its `maxFileBytes` is refused as too large, and where its `kinds` leave out the
|
|
21
|
+
* field's kind every file is refused as of a type not allowed -- the upload's own refusals, in the
|
|
22
|
+
* picker's upload words.
|
|
19
23
|
* `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
|
|
20
24
|
* Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
|
|
21
25
|
* who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
|
|
@@ -17,7 +17,7 @@ import { PHI_SEARCH_WIDGET_DEFAULT_LABELS } from "../../../components/widgets/la
|
|
|
17
17
|
import { isPhiMediaAssetPublic } from "../../../constants/media";
|
|
18
18
|
import { PHI_FORM_MEDIA_ASSET_LABEL_KEYS } from "./form-providers";
|
|
19
19
|
import { readPhiMediaFieldPickerLabels } from "./media-field-picker-labels";
|
|
20
|
-
import { isPhiMediaAssetFieldSelectable, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldUploadRefusal, readPhiMediaAssetFieldValue, } from "./media-asset-field";
|
|
20
|
+
import { isPhiMediaAssetFieldSelectable, isPhiMediaFieldKindTaken, readPhiMediaAssetFieldConfig, readPhiMediaAssetFieldUploadRefusal, readPhiMediaAssetFieldValue, readPhiMediaFieldUploadAcceptance, } from "./media-asset-field";
|
|
21
21
|
const DEFAULT_LABELS = {
|
|
22
22
|
choose: "Choose",
|
|
23
23
|
change: "Change",
|
|
@@ -42,6 +42,10 @@ const PREVIEW_SIZE = 72;
|
|
|
42
42
|
* or, for a `publicOnly` field, one that is not public is left in the list unchosen, and the field says
|
|
43
43
|
* why. While the file is on its way the Form's submit is held, as the upload field holds it, and closing
|
|
44
44
|
* the picker stops it.
|
|
45
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) are applied before a file is
|
|
46
|
+
* sent: one larger than its `maxFileBytes` is refused as too large, and where its `kinds` leave out the
|
|
47
|
+
* field's kind every file is refused as of a type not allowed -- the upload's own refusals, in the
|
|
48
|
+
* picker's upload words.
|
|
45
49
|
* `config.folderPath` names the Folder the picker opens on ("Shop Images / Products"): read in the Site
|
|
46
50
|
* Space each time it opens, without writing anything (`readPhiMediaUploadFolderPathReach`), so a reader
|
|
47
51
|
* who may only choose opens and picks without a refusal; the picker opens on the deepest Folder of the
|
|
@@ -58,7 +62,7 @@ const PREVIEW_SIZE = 72;
|
|
|
58
62
|
* field reads (`usePhiAuthoringAssetDetails`), so the preview shows what is stored. Where that read is
|
|
59
63
|
* refused, the field says so and still lets the value be changed or removed.
|
|
60
64
|
*/
|
|
61
|
-
export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, }) => {
|
|
65
|
+
export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, mediaLimits, }) => {
|
|
62
66
|
const config = useMemo(() => readPhiMediaAssetFieldConfig(field.config), [field.config]);
|
|
63
67
|
const assetId = readPhiMediaAssetFieldValue(value);
|
|
64
68
|
const asset = usePhiAuthoringAssetDetails(assetId);
|
|
@@ -70,7 +74,8 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
|
|
|
70
74
|
// picker's upload words (`readPhiMediaFieldPickerLabels`).
|
|
71
75
|
const pendingLabel = labels?.[PHI_FORM_UPLOAD_LABEL_KEYS.pending]?.trim() || PHI_MEDIA_UPLOAD_FIELD_DEFAULT_LABELS.pending;
|
|
72
76
|
const [uploadNotice, setUploadNotice] = useState(null);
|
|
73
|
-
const acceptance = useMemo(() => (
|
|
77
|
+
const acceptance = useMemo(() => readPhiMediaFieldUploadAcceptance(config.mediaType, false, mediaLimits), [config.mediaType, mediaLimits]);
|
|
78
|
+
const kindTaken = isPhiMediaFieldKindTaken(config.mediaType, mediaLimits);
|
|
74
79
|
const [uploading, setUploading] = useState(false);
|
|
75
80
|
useEffect(() => {
|
|
76
81
|
if (!formContext || !uploading)
|
|
@@ -105,12 +110,12 @@ export const PhiMediaAssetFormControl = ({ field, value, labels, disabled, readO
|
|
|
105
110
|
multiple: false,
|
|
106
111
|
allowDelete: false,
|
|
107
112
|
...(intoStartFolder ? { folderPath: openedFolderPath.join(" / ") } : {}),
|
|
108
|
-
}, labels: pickerUploadLabels, acceptance: acceptance, showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId, presentationFlags: null, query: {} }, onUploadingChange: setUploading, onAssetUploaded: (tile) => {
|
|
113
|
+
}, labels: pickerUploadLabels, acceptance: acceptance, ...(kindTaken ? {} : { refuseFile: () => pickerUploadLabels.refusals.errorTypeNotAllowed }), showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId, presentationFlags: null, query: {} }, onUploadingChange: setUploading, onAssetUploaded: (tile) => {
|
|
109
114
|
const refusal = readPhiMediaAssetFieldUploadRefusal(config, tile);
|
|
110
115
|
setUploadNotice(refusal === "kind" ? pickerUploadLabels.refusals.errorTypeNotAllowed : refusal ? notPublic : null);
|
|
111
116
|
onUploaded(refusal ? null : tile);
|
|
112
117
|
} })),
|
|
113
|
-
}), [acceptance, config, notPublic, openedFolderPath, pickerUploadLabels, uploadNotice]);
|
|
118
|
+
}), [acceptance, config, kindTaken, notPublic, openedFolderPath, pickerUploadLabels, uploadNotice]);
|
|
114
119
|
const pickerLabels = useMemo(() => ({ ...mediaLabels, picker: { ...mediaLabels.picker, triggerLabel: assetId == null ? choose : change } }), [assetId, change, choose, mediaLabels]);
|
|
115
120
|
const picker = usePhiMediaPickerBinding({
|
|
116
121
|
config: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PhiMediaCollectionItem } from "../../../types/media";
|
|
2
2
|
import { type PhiMediaAssetFieldConfig } from "./media-asset-field";
|
|
3
|
+
import type { PhiAddonMediaLimits } from "../../../types/server-capabilities";
|
|
3
4
|
export type PhiMediaAssetsFieldConfig = Pick<PhiMediaAssetFieldConfig, "mediaType" | "folderPath"> & {
|
|
4
5
|
/**
|
|
5
6
|
* The most Assets the value may hold, from 1 to `PHI_MEDIA_ASSETS_FIELD_MOST` (the default): the field
|
|
@@ -13,6 +14,13 @@ export type PhiMediaAssetsFieldConfig = Pick<PhiMediaAssetFieldConfig, "mediaTyp
|
|
|
13
14
|
* `PHI_MEDIA_ASSETS_FIELD_MOST` is a `PhiConfigError` naming the field, never a default in its place.
|
|
14
15
|
*/
|
|
15
16
|
export declare function readPhiMediaAssetsFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetsFieldConfig;
|
|
17
|
+
/**
|
|
18
|
+
* The field's config under the Media limits of the Add-on behind the Form: its own `max` stands where it
|
|
19
|
+
* is lower than the Add-on's `maxPerField`, and the Add-on's where the field's would be higher -- a field
|
|
20
|
+
* may hold fewer than the Add-on takes, never more. Everything that reads `max` (full, the refusal before
|
|
21
|
+
* a file is sent, the hold on a value beyond it, the sentence that says so) then reads the one it may hold.
|
|
22
|
+
*/
|
|
23
|
+
export declare function limitPhiMediaAssetsFieldConfig(config: PhiMediaAssetsFieldConfig, limits: PhiAddonMediaLimits | undefined): PhiMediaAssetsFieldConfig;
|
|
16
24
|
/**
|
|
17
25
|
* The Asset ids a Form value holds, in its order: a list's entries that are Asset ids (positive whole
|
|
18
26
|
* numbers, as `media-asset` reads its one), each once; anything that is not a list holds none.
|
|
@@ -16,6 +16,16 @@ export function readPhiMediaAssetsFieldConfig(config) {
|
|
|
16
16
|
: undefined) ?? PHI_MEDIA_ASSETS_FIELD_MOST,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The field's config under the Media limits of the Add-on behind the Form: its own `max` stands where it
|
|
21
|
+
* is lower than the Add-on's `maxPerField`, and the Add-on's where the field's would be higher -- a field
|
|
22
|
+
* may hold fewer than the Add-on takes, never more. Everything that reads `max` (full, the refusal before
|
|
23
|
+
* a file is sent, the hold on a value beyond it, the sentence that says so) then reads the one it may hold.
|
|
24
|
+
*/
|
|
25
|
+
export function limitPhiMediaAssetsFieldConfig(config, limits) {
|
|
26
|
+
const most = limits?.maxPerField;
|
|
27
|
+
return most != null && most < config.max ? { ...config, max: most } : config;
|
|
28
|
+
}
|
|
19
29
|
/**
|
|
20
30
|
* The Asset ids a Form value holds, in its order: a list's entries that are Asset ids (positive whole
|
|
21
31
|
* numbers, as `media-asset` reads its one), each once; anything that is not a list holds none.
|
|
@@ -20,6 +20,11 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
|
|
|
20
20
|
* offered, a file beyond it is refused before it is sent, and a value beyond it -- one that came in --
|
|
21
21
|
* holds the Form's submit with the sentence the field shows.
|
|
22
22
|
*
|
|
23
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) narrow that: its `maxPerField`
|
|
24
|
+
* is the most where `config.max` would be higher (`limitPhiMediaAssetsFieldConfig`), a file larger than its
|
|
25
|
+
* `maxFileBytes` is refused as too large before it is sent, and where its `kinds` leave out the field's kind
|
|
26
|
+
* every file is refused as of a type not allowed -- the upload's own refusals, in its upload words.
|
|
27
|
+
*
|
|
23
28
|
* The tiles are read in one request for the ids the field has no tile for yet (the Media list with `id`
|
|
24
29
|
* repeated, through the Media library's collection Provider), shown in the value's order; an id the list
|
|
25
30
|
* does not answer is an unavailable tile that can still be removed. A pick or an upload brings its tile.
|
|
@@ -20,7 +20,8 @@ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../components/root/p
|
|
|
20
20
|
import { usePhiConfig } from "../../../components/root/phi-config-provider";
|
|
21
21
|
import { PHI_FORM_MEDIA_ASSETS_LABEL_KEYS, PHI_MEDIA_ASSETS_FIELD_MOST } from "./form-providers";
|
|
22
22
|
import { readPhiMediaFieldPickerLabels } from "./media-field-picker-labels";
|
|
23
|
-
import {
|
|
23
|
+
import { isPhiMediaFieldKindTaken, readPhiMediaFieldUploadAcceptance } from "./media-asset-field";
|
|
24
|
+
import { addPhiMediaAssetsFieldIds, limitPhiMediaAssetsFieldConfig, orderPhiMediaAssetsFieldTiles, readPhiMediaAssetsFieldConfig, readPhiMediaAssetsFieldValue, } from "./media-assets-field";
|
|
24
25
|
const DEFAULT_LABELS = {
|
|
25
26
|
remove: "Remove",
|
|
26
27
|
reorder: "Drag to reorder",
|
|
@@ -49,13 +50,18 @@ const TILE_MIN_WIDTH = 102;
|
|
|
49
50
|
* offered, a file beyond it is refused before it is sent, and a value beyond it -- one that came in --
|
|
50
51
|
* holds the Form's submit with the sentence the field shows.
|
|
51
52
|
*
|
|
53
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) narrow that: its `maxPerField`
|
|
54
|
+
* is the most where `config.max` would be higher (`limitPhiMediaAssetsFieldConfig`), a file larger than its
|
|
55
|
+
* `maxFileBytes` is refused as too large before it is sent, and where its `kinds` leave out the field's kind
|
|
56
|
+
* every file is refused as of a type not allowed -- the upload's own refusals, in its upload words.
|
|
57
|
+
*
|
|
52
58
|
* The tiles are read in one request for the ids the field has no tile for yet (the Media list with `id`
|
|
53
59
|
* repeated, through the Media library's collection Provider), shown in the value's order; an id the list
|
|
54
60
|
* does not answer is an unavailable tile that can still be removed. A pick or an upload brings its tile.
|
|
55
61
|
*/
|
|
56
|
-
export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, }) => {
|
|
62
|
+
export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, mediaLimits, }) => {
|
|
57
63
|
const { token } = usePhiConfig();
|
|
58
|
-
const config = useMemo(() => readPhiMediaAssetsFieldConfig(field.config), [field.config]);
|
|
64
|
+
const config = useMemo(() => limitPhiMediaAssetsFieldConfig(readPhiMediaAssetsFieldConfig(field.config), mediaLimits), [field.config, mediaLimits]);
|
|
59
65
|
const ids = readPhiMediaAssetsFieldValue(value);
|
|
60
66
|
const locked = disabled === true || readOnly === true;
|
|
61
67
|
const full = ids.length >= config.max;
|
|
@@ -156,8 +162,11 @@ export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, read
|
|
|
156
162
|
* would overfill it sends only what fits.
|
|
157
163
|
*/
|
|
158
164
|
const [uploadFolderPath, setUploadFolderPath] = useState(null);
|
|
159
|
-
const acceptance = useMemo(() => (
|
|
160
|
-
const
|
|
165
|
+
const acceptance = useMemo(() => readPhiMediaFieldUploadAcceptance(config.mediaType, config.max > 1, mediaLimits), [config.mediaType, config.max, mediaLimits]);
|
|
166
|
+
const kindTaken = isPhiMediaFieldKindTaken(config.mediaType, mediaLimits);
|
|
167
|
+
const uploadPanel = uploadFolderPath && !locked ? (_jsx(PhiAreaUploadBinding, { labels: mediaLabels.upload, config: uploadFolderPath.length > 0 ? { folderPath: uploadFolderPath.join(" / ") } : null, acceptance: acceptance, showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId: null, folderPath: null, presentationFlags: null, query: {} }, onUploadingChange: setUploading, refuseFile: (_file, sending) => !kindTaken
|
|
168
|
+
? mediaLabels.upload.refusals.errorTypeNotAllowed
|
|
169
|
+
: readIdsNow().length + sending >= config.max ? tooMany : null, onAssetUploaded: (asset) => {
|
|
161
170
|
// Core does not know the field's kind, and a file the browser could not name reaches it unrefused.
|
|
162
171
|
if (asset.kind !== config.mediaType) {
|
|
163
172
|
setNotice(mediaLabels.upload.refusals.errorTypeNotAllowed);
|
|
@@ -166,7 +175,7 @@ export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, read
|
|
|
166
175
|
add([asset]);
|
|
167
176
|
} })) : null;
|
|
168
177
|
const shown = orderPhiMediaAssetsFieldTiles(ids, tiles, unavailableName);
|
|
169
|
-
const toolbar = locked ? null : (_jsxs(PhiToolbarControl, { compact: true,
|
|
178
|
+
const toolbar = locked ? null : (_jsxs(PhiToolbarControl, { compact: true, children: [_jsx(PhiButtonControl, { label: mediaLabels.upload.uploadToggleLabel, type: uploadFolderPath ? "primary" : "default", disabled: full && !uploadFolderPath, onClick: () => setUploadFolderPath((current) => current ? null : resolveFolderPath()) }), _jsx(PhiMediaPickerControl, { ...picker, disabled: full })] }));
|
|
170
179
|
// The Collection's own drag handles; the order dropped is the value's new order.
|
|
171
180
|
const reorder = locked || ids.length < 2 ? null : {
|
|
172
181
|
itemKeys: ids,
|
|
@@ -344,7 +344,7 @@ async function loadLabels(context) {
|
|
|
344
344
|
totpRoles: labels.totp.roles,
|
|
345
345
|
totpRolesHint: labels.totp.rolesHint,
|
|
346
346
|
role_admin: labels.roles.admin,
|
|
347
|
-
|
|
347
|
+
role_maintainer: labels.roles.maintainer,
|
|
348
348
|
role_builder: labels.roles.builder,
|
|
349
349
|
role_author: labels.roles.author,
|
|
350
350
|
role_publisher: labels.roles.publisher,
|
|
@@ -332,27 +332,32 @@ function PhiInspectorChoiceFieldControl({ field, config, value, defaultValue, di
|
|
|
332
332
|
// The Inspector's own fields declare searchability too -- the navigation pickers have said
|
|
333
333
|
// `search: { enabled: true }` for a while -- so the raw text goes to the hook here as well.
|
|
334
334
|
const [searchDraft, setSearchDraft] = useState("");
|
|
335
|
+
// What the field holds, read once for the provider and for the control below.
|
|
336
|
+
const multiple = field.mode === "multiple" || field.valueType === "string[]";
|
|
337
|
+
const emptyOptionValue = field.emptyOption?.value;
|
|
338
|
+
const selectedValues = multiple ? readInspectorChoiceMultiValue(value, defaultValue) : [];
|
|
339
|
+
const selectedValue = multiple
|
|
340
|
+
? undefined
|
|
341
|
+
: value == null
|
|
342
|
+
? emptyOptionValue ?? readInspectorChoiceSingleValue(undefined, defaultValue)
|
|
343
|
+
: readInspectorChoiceSingleValue(value, defaultValue);
|
|
335
344
|
const providerResult = usePhiControlOptionsProvider({
|
|
336
345
|
options: staticOptions,
|
|
337
346
|
optionsProvider: field.filter?.widgetType ? null : field.optionsProvider,
|
|
338
347
|
sourceConfig: field.filter?.widgetType ? null : config,
|
|
339
348
|
searchDraft,
|
|
349
|
+
selectedValues: multiple ? selectedValues : selectedValue,
|
|
340
350
|
});
|
|
341
351
|
const renderChoiceRow = (control) => renderPhiInspectorConfigFieldControl(field, _jsxs(PhiFlexControl, { vertical: true, gap: 4, style: { minWidth: 0, width: "100%" }, children: [control, providerResult.warning ? (_jsx(PhiTypographyControl, { type: "warning", children: providerResult.warning })) : null] }));
|
|
342
352
|
const resolvedOptions = useMemo(() => resolveInspectorChoiceOptions(field, widgetReferenceOptions, providerResult.options), [field, providerResult.options, widgetReferenceOptions]);
|
|
343
353
|
const cascader = useMemo(() => field.presentation === "cascader" ? buildPhiInspectorChoiceCascader(resolvedOptions) : null, [field.presentation, resolvedOptions]);
|
|
344
|
-
if (
|
|
345
|
-
const selectedValues = readInspectorChoiceMultiValue(value, defaultValue);
|
|
354
|
+
if (multiple) {
|
|
346
355
|
const options = selectedValues.reduce((items, entry) => ensureInspectorChoiceOption(items, entry), resolvedOptions);
|
|
347
356
|
return renderChoiceRow(_jsx(PhiMultiSelectControl, { value: selectedValues, options: options, placeholder: field.placeholder, allowCustom: field.allowCustom, disabled: disabled || !onChange, style: { width: "100%" }, onChange: (nextValues) => onChange?.({
|
|
348
357
|
[field.key]: nextValues,
|
|
349
358
|
...(field.patchOnChange ?? {}),
|
|
350
359
|
}) }));
|
|
351
360
|
}
|
|
352
|
-
const emptyOptionValue = field.emptyOption?.value;
|
|
353
|
-
const selectedValue = value == null
|
|
354
|
-
? emptyOptionValue ?? readInspectorChoiceSingleValue(undefined, defaultValue)
|
|
355
|
-
: readInspectorChoiceSingleValue(value, defaultValue);
|
|
356
361
|
/*
|
|
357
362
|
* The options as a hierarchy by their `parentValue`. Every level can be chosen -- a Folder that holds
|
|
358
363
|
* others is a Folder too -- and what is stored is the chosen option's own value. The empty option is
|
|
@@ -4,10 +4,14 @@ import { PHI_ACCOUNTING_RUNTIME_MODULE_CONTROLLER_CLIENT_AREA_CONTRIBUTIONS } fr
|
|
|
4
4
|
import { PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST } from "./common";
|
|
5
5
|
import { PHI_COMMON_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST } from "./common-data-providers";
|
|
6
6
|
import { extendPhiRuntimeModuleDataProviderClientManifest } from "../../../components/runtime/runtime-module-data-provider-client-manifest";
|
|
7
|
+
import { PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../accounting/client-data-providers";
|
|
7
8
|
import { PHI_DASHBOARD_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../dashboard/client-data-providers";
|
|
8
9
|
export { PHI_COMMON_RUNTIME_MODULE_CALENDAR_ADAPTER_CLIENT_MANIFEST as PHI_ACCOUNTING_RUNTIME_MODULE_CALENDAR_ADAPTER_CLIENT_MANIFEST } from "./common";
|
|
9
10
|
export { PHI_COMMON_RUNTIME_MODULE_MEDIA_SOURCE_CLIENT_MANIFEST as PHI_ACCOUNTING_RUNTIME_MODULE_MEDIA_SOURCE_CLIENT_MANIFEST } from "./common";
|
|
10
11
|
export { PHI_COMMON_RUNTIME_MODULE_UI_PROVIDER_CLIENT_MANIFEST as PHI_ACCOUNTING_RUNTIME_MODULE_UI_PROVIDER_CLIENT_MANIFEST } from "./common";
|
|
11
12
|
export const PHI_ACCOUNTING_RUNTIME_MODULE_CONTROLLER_CLIENT_MANIFEST = createPhiRuntimeModuleControllerClientManifestFromAreaContributions(PHI_ACCOUNTING_RUNTIME_MODULE_CONTROLLER_CLIENT_AREA_CONTRIBUTIONS);
|
|
12
13
|
export const PHI_ACCOUNTING_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST = PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST;
|
|
13
|
-
export const PHI_ACCOUNTING_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST = extendPhiRuntimeModuleDataProviderClientManifest(PHI_COMMON_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST,
|
|
14
|
+
export const PHI_ACCOUNTING_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST = extendPhiRuntimeModuleDataProviderClientManifest(PHI_COMMON_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST, [
|
|
15
|
+
...PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
|
|
16
|
+
...PHI_DASHBOARD_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
|
|
17
|
+
]);
|
|
@@ -8,8 +8,8 @@ import { PHI_CORE_RUNTIME_MODULE_ID } from "./ids";
|
|
|
8
8
|
* The runtime the Site itself is running in.
|
|
9
9
|
*
|
|
10
10
|
* It belongs to the platform Module rather than to Observability, and the reason is who sees it: the
|
|
11
|
-
* Admin Dashboard showed this figure to every administrator, and Observability is gated on
|
|
12
|
-
*
|
|
11
|
+
* Admin Dashboard showed this figure to every administrator, and Observability is gated on Site
|
|
12
|
+
* maintenance. Moving the card there would have taken it away from most of the people who had it, which is a
|
|
13
13
|
* change nobody asked for. What the figure is has not changed either -- the card resolves in the Site
|
|
14
14
|
* process, which is the process this uptime is of.
|
|
15
15
|
*/
|
|
@@ -33,6 +33,11 @@ export const PHI_CORE_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS = [
|
|
|
33
33
|
ownerModuleId: PHI_CORE_RUNTIME_MODULE_ID,
|
|
34
34
|
loadLive: async () => (await import("./content-entries/tags")).PhiContentEntryTagsOptionsProviderClient,
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
key: PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS.siteMembers,
|
|
38
|
+
ownerModuleId: PHI_CORE_RUNTIME_MODULE_ID,
|
|
39
|
+
loadLive: async () => (await import("./services/site-members-options")).PhiSiteMembersOptionsProviderClient,
|
|
40
|
+
},
|
|
36
41
|
{
|
|
37
42
|
key: PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS.contentEntryAuthors,
|
|
38
43
|
ownerModuleId: PHI_CORE_RUNTIME_MODULE_ID,
|
|
@@ -163,6 +163,20 @@ export const PHI_CORE_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
163
163
|
title: "Content entry tags",
|
|
164
164
|
description: "The tags one content kind's entries already carry; the field names the kind.",
|
|
165
165
|
},
|
|
166
|
+
/*
|
|
167
|
+
* The Site's members by user id, for any Module's Form that names a person (a grant on their behalf).
|
|
168
|
+
* Core's and not User Management's: that Module is the Admin Area's, and the staff who act on a member's
|
|
169
|
+
* behalf work in Accounting and Support, where only Core is sure to be active.
|
|
170
|
+
*/
|
|
171
|
+
{
|
|
172
|
+
key: PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS.siteMembers,
|
|
173
|
+
ownerModuleId: PHI_CORE_RUNTIME_MODULE_ID,
|
|
174
|
+
kind: "options",
|
|
175
|
+
executionMode: "live",
|
|
176
|
+
authoringMode: "none",
|
|
177
|
+
title: "Site members",
|
|
178
|
+
description: "The Site's members by user id, searched by name or address, for staff acting on a member's behalf.",
|
|
179
|
+
},
|
|
166
180
|
/*
|
|
167
181
|
* The offer the curation Form picks from: who may be named as an entry's author, and the categories it
|
|
168
182
|
* may be filed under. One endpoint answers both, so they read it under one load key.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Core's member picker route (phis-server `GET /api/site/members`). */
|
|
2
|
+
export declare const PHI_SITE_MEMBERS_PATH = "/api/site/members";
|
|
3
|
+
/** The one page a picker asks for: as many as the route answers at once. */
|
|
4
|
+
export declare const PHI_SITE_MEMBERS_PAGE_SIZE = 50;
|
|
5
|
+
/** The request for what is typed: the first page of the members whose name or address matches. */
|
|
6
|
+
export declare function resolvePhiSiteMembersRequestPath(search: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The options in an answer: the user id as text -- what a select holds -- and the name the person is
|
|
9
|
+
* shown under, which Core answers as `#<id>` where they have none. A row that is not a member's (no
|
|
10
|
+
* positive whole id, no name) is no option; an answer that is not `{ items }` holds none.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readPhiSiteMembersOptions(payload: unknown): {
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
/**
|
|
17
|
+
* The Site's members as a select's options, for any Module's Form that names a person by user id.
|
|
18
|
+
*
|
|
19
|
+
* The search happens where the people are: what is typed goes into the request, and the route answers
|
|
20
|
+
* the first page of the matches, so a person is findable on a Site with more members than one answer
|
|
21
|
+
* carries. A field using it declares `loadMode: "server"` and `search: { enabled: true, minChars }` on its
|
|
22
|
+
* options provider, as the Groups Module's member field does. Core decides who may ask -- the holders of
|
|
23
|
+
* the Site access `accounting` or `support` -- and a refusal is a failed load, not an empty Site.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PhiSiteMembersOptionsProviderClient: import("react").ComponentType<{
|
|
26
|
+
children: import("react").ReactNode;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createPhiControlOptionsProviderClient, } from "../../../../components/controls/phi-options-provider";
|
|
3
|
+
import { PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS } from "../../../../constants/core-data-provider-keys";
|
|
4
|
+
import { requestPhiJson } from "../../../../helpers/client-json-request";
|
|
5
|
+
import { isPhiRecord } from "../../../../helpers/is-record";
|
|
6
|
+
/** Core's member picker route (phis-server `GET /api/site/members`). */
|
|
7
|
+
export const PHI_SITE_MEMBERS_PATH = "/api/site/members";
|
|
8
|
+
/** The one page a picker asks for: as many as the route answers at once. */
|
|
9
|
+
export const PHI_SITE_MEMBERS_PAGE_SIZE = 50;
|
|
10
|
+
/** The request for what is typed: the first page of the members whose name or address matches. */
|
|
11
|
+
export function resolvePhiSiteMembersRequestPath(search) {
|
|
12
|
+
const params = new URLSearchParams({ pageSize: String(PHI_SITE_MEMBERS_PAGE_SIZE) });
|
|
13
|
+
const query = search.trim();
|
|
14
|
+
if (query)
|
|
15
|
+
params.set("q", query);
|
|
16
|
+
return `${PHI_SITE_MEMBERS_PATH}?${params}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options in an answer: the user id as text -- what a select holds -- and the name the person is
|
|
20
|
+
* shown under, which Core answers as `#<id>` where they have none. A row that is not a member's (no
|
|
21
|
+
* positive whole id, no name) is no option; an answer that is not `{ items }` holds none.
|
|
22
|
+
*/
|
|
23
|
+
export function readPhiSiteMembersOptions(payload) {
|
|
24
|
+
const items = isPhiRecord(payload) && Array.isArray(payload.items) ? payload.items : [];
|
|
25
|
+
return items.flatMap((item) => {
|
|
26
|
+
if (!isPhiRecord(item))
|
|
27
|
+
return [];
|
|
28
|
+
const { userId, displayName } = item;
|
|
29
|
+
if (typeof userId !== "number" || !Number.isSafeInteger(userId) || userId <= 0)
|
|
30
|
+
return [];
|
|
31
|
+
if (typeof displayName !== "string" || !displayName.trim())
|
|
32
|
+
return [];
|
|
33
|
+
return [{ value: String(userId), label: displayName.trim() }];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The Site's members as a select's options, for any Module's Form that names a person by user id.
|
|
38
|
+
*
|
|
39
|
+
* The search happens where the people are: what is typed goes into the request, and the route answers
|
|
40
|
+
* the first page of the matches, so a person is findable on a Site with more members than one answer
|
|
41
|
+
* carries. A field using it declares `loadMode: "server"` and `search: { enabled: true, minChars }` on its
|
|
42
|
+
* options provider, as the Groups Module's member field does. Core decides who may ask -- the holders of
|
|
43
|
+
* the Site access `accounting` or `support` -- and a refusal is a failed load, not an empty Site.
|
|
44
|
+
*/
|
|
45
|
+
export const PhiSiteMembersOptionsProviderClient = createPhiControlOptionsProviderClient({
|
|
46
|
+
key: PHI_CORE_RUNTIME_DATA_PROVIDER_KEYS.siteMembers,
|
|
47
|
+
load: async (context) => {
|
|
48
|
+
const reply = await requestPhiJson(resolvePhiSiteMembersRequestPath(context.search));
|
|
49
|
+
if (!reply.ok)
|
|
50
|
+
throw new Error("Failed to load the Site's members.");
|
|
51
|
+
return reply.payload;
|
|
52
|
+
},
|
|
53
|
+
resolveLoadKey: (context) => `core-site-members:${context.search.trim()}`,
|
|
54
|
+
resolve: (context) => ({ options: readPhiSiteMembersOptions(context.asyncData) }),
|
|
55
|
+
});
|
|
@@ -8,20 +8,21 @@ import { usePhiControlOptionsProvider } from "../../../../../components/controls
|
|
|
8
8
|
export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
|
|
9
9
|
const { token } = usePhiConfig();
|
|
10
10
|
const minWidth = token.controlHeight * 6;
|
|
11
|
+
const separator = config?.separator ?? "/";
|
|
12
|
+
const rootValue = config?.rootValue ?? "/";
|
|
13
|
+
const normalize = config?.normalize ?? "raw";
|
|
14
|
+
const normalizeFallback = (raw) => normalizePhiCascaderValue(normalizePhiCascaderValue(raw), { separator, rootValue, normalize });
|
|
15
|
+
// A pick, held against the fallback it replaced; declared first so the provider hears what is held.
|
|
16
|
+
// Without a configured value the fallback is the provider's own answer, so only a pick is told.
|
|
17
|
+
const [picked, setPicked] = useState(null);
|
|
18
|
+
const configuredValue = config?.value == null ? null : normalizeFallback(config.value);
|
|
11
19
|
const resolvedOptions = usePhiControlOptionsProvider({
|
|
12
20
|
options: config?.options,
|
|
13
21
|
optionsProvider: config?.optionsProvider,
|
|
22
|
+
selectedValues: configuredValue == null || picked?.source === configuredValue ? picked?.value : configuredValue,
|
|
14
23
|
});
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const rootValue = config?.rootValue ?? "/";
|
|
18
|
-
const normalize = config?.normalize ?? "raw";
|
|
19
|
-
const normalizedFallbackValue = normalizePhiCascaderValue(fallbackValue, { separator, rootValue, normalize });
|
|
20
|
-
const [state, setState] = useState(() => ({
|
|
21
|
-
source: normalizedFallbackValue,
|
|
22
|
-
value: normalizedFallbackValue,
|
|
23
|
-
}));
|
|
24
|
-
const value = state.source === normalizedFallbackValue ? state.value : normalizedFallbackValue;
|
|
24
|
+
const normalizedFallbackValue = normalizeFallback(config?.value ?? resolvedOptions.value);
|
|
25
|
+
const value = picked?.source === normalizedFallbackValue ? picked.value : normalizedFallbackValue;
|
|
25
26
|
const controlSignals = usePhiControlSignalController({
|
|
26
27
|
key: config?.key ?? "cascader",
|
|
27
28
|
signalRoutes: config?.signalRoutes,
|
|
@@ -31,7 +32,7 @@ export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
|
|
|
31
32
|
initialDisabled: config?.disabled === true,
|
|
32
33
|
initialReadOnly: config?.readOnly === true,
|
|
33
34
|
clearValue: config?.allowRoot === false ? normalizedFallbackValue : rootValue,
|
|
34
|
-
onSetValue: (nextValue) =>
|
|
35
|
+
onSetValue: (nextValue) => setPicked({
|
|
35
36
|
source: normalizedFallbackValue,
|
|
36
37
|
value: normalizePhiCascaderValue(nextValue, { separator, rootValue, normalize }),
|
|
37
38
|
}),
|
|
@@ -42,7 +43,7 @@ export function PhiCascaderWidget({ config, signalsEnabled = true, }) {
|
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
const normalizedNextValue = normalizePhiCascaderValue(nextValue, { separator, rootValue, normalize });
|
|
45
|
-
|
|
46
|
+
setPicked({
|
|
46
47
|
source: normalizedFallbackValue,
|
|
47
48
|
value: normalizedNextValue,
|
|
48
49
|
});
|
|
@@ -9,14 +9,15 @@ function equalValues(left, right) {
|
|
|
9
9
|
return left.length === right.length && left.every((entry, index) => entry === right[index]);
|
|
10
10
|
}
|
|
11
11
|
export function PhiCheckboxGroupWidget({ config, value: controlledValue, disabled, readOnly, signalsEnabled = true, onChange, }) {
|
|
12
|
-
const resolvedOptions = usePhiControlOptionsProvider({
|
|
13
|
-
options: config?.options,
|
|
14
|
-
optionsProvider: config?.optionsProvider,
|
|
15
|
-
});
|
|
16
12
|
const fallbackValue = useMemo(() => controlledValue ?? config?.value ?? [], [config?.value, controlledValue]);
|
|
17
13
|
const fallbackKey = fallbackValue.join("\u001f");
|
|
18
14
|
const [state, setState] = useState(() => ({ sourceKey: fallbackKey, value: fallbackValue }));
|
|
19
15
|
const value = state.sourceKey === fallbackKey ? state.value : fallbackValue;
|
|
16
|
+
const resolvedOptions = usePhiControlOptionsProvider({
|
|
17
|
+
options: config?.options,
|
|
18
|
+
optionsProvider: config?.optionsProvider,
|
|
19
|
+
selectedValues: value,
|
|
20
|
+
});
|
|
20
21
|
const controlSignals = usePhiControlSignalController({
|
|
21
22
|
key: config?.key ?? "checkbox-group",
|
|
22
23
|
signalRoutes: config?.signalRoutes,
|
|
@@ -46,6 +46,11 @@ export declare const PHI_FORM_WIDGET_DEFINITION: {
|
|
|
46
46
|
action: "reload";
|
|
47
47
|
valueType: "none";
|
|
48
48
|
valueSchema?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
id: string;
|
|
51
|
+
action: "change";
|
|
52
|
+
valueType: "string";
|
|
53
|
+
valueSchema?: undefined;
|
|
49
54
|
})[];
|
|
50
55
|
listens: ({
|
|
51
56
|
id: string;
|
|
@@ -3,6 +3,7 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
|
3
3
|
import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../../types/signals";
|
|
4
4
|
import { requirePhiRuntimeFormControllerForWidget } from "../../../../../components/forms/runtime-form-controller-requirement";
|
|
5
5
|
import { parsePhiFormWidgetConfig, } from "../../../../../components/forms/form-widget-config";
|
|
6
|
+
import { PHI_FORM_RECORD_TITLE_CAPABILITY } from "../../../../../components/forms/form-record-title";
|
|
6
7
|
import { PHI_LAYOUT } from "../../../../../theme/phi-tokens";
|
|
7
8
|
import { PHI_AUTHORING_OPTION_PROVIDER_KEYS } from "../../../../../constants/authoring-option-provider-keys";
|
|
8
9
|
export const PHI_FORM_WIDGET_DEFINITION = {
|
|
@@ -83,6 +84,8 @@ export const PHI_FORM_WIDGET_DEFINITION = {
|
|
|
83
84
|
* has to ask rather than be told.
|
|
84
85
|
*/
|
|
85
86
|
{ id: "valuesRequest", action: "reload", valueType: "none" },
|
|
87
|
+
// The title its record gives the dialog, after every read (`titleFromRecord`), for the Overlay's `title`.
|
|
88
|
+
{ id: PHI_FORM_RECORD_TITLE_CAPABILITY, action: "change", valueType: "string" },
|
|
86
89
|
],
|
|
87
90
|
listens: [
|
|
88
91
|
{ id: "submit", channel: "submit", action: "activate", valueType: "none" },
|
|
@@ -39,10 +39,6 @@ export function PhiMultiSelectWidget({ config, signalsEnabled = true, value: con
|
|
|
39
39
|
const { token } = usePhiConfig();
|
|
40
40
|
const minWidth = token.controlHeight * 5;
|
|
41
41
|
const valueType = config?.valueType ?? "enum[]";
|
|
42
|
-
const resolvedOptions = usePhiControlOptionsProvider({
|
|
43
|
-
options: config?.options,
|
|
44
|
-
optionsProvider: config?.optionsProvider,
|
|
45
|
-
});
|
|
46
42
|
const fallbackValue = useMemo(() => normalizeMultiSelectValue(controlledValue ?? config?.value ?? [], valueType), [config?.value, controlledValue, valueType]);
|
|
47
43
|
const fallbackValueKey = `${valueType}:${fallbackValue.join("\u001f")}`;
|
|
48
44
|
const [state, setState] = useState(() => ({
|
|
@@ -50,6 +46,12 @@ export function PhiMultiSelectWidget({ config, signalsEnabled = true, value: con
|
|
|
50
46
|
value: fallbackValue,
|
|
51
47
|
}));
|
|
52
48
|
const value = state.sourceKey === fallbackValueKey ? state.value : fallbackValue;
|
|
49
|
+
const resolvedOptions = usePhiControlOptionsProvider({
|
|
50
|
+
options: config?.options,
|
|
51
|
+
optionsProvider: config?.optionsProvider,
|
|
52
|
+
// As the Select is handed them, so they meet the options the way the Select's own lookup does.
|
|
53
|
+
selectedValues: valuesToSelectValues(value),
|
|
54
|
+
});
|
|
53
55
|
const maxTagCount = config?.maxTagCount === "responsive" && value.length <= 1
|
|
54
56
|
? undefined
|
|
55
57
|
: config?.maxTagCount;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type PhiTableProviderRegistration } from "../../../../../components/widgets/client/shared/phi-table-provider";
|
|
2
|
+
import type { PhiProviderResourceSource } from "../../../../../types/runtime-data-provider";
|
|
3
|
+
import type { PhiRecordWidgetAction } from "../../../../../types/record-widget";
|
|
4
|
+
import { type PhiTableProviderMutationResult, type PhiTableProviderResourceDescriptor, type PhiTableRowIdentity } from "../../../../../types/table-widget";
|
|
5
|
+
export type PhiRecordWidgetActionsInput = {
|
|
6
|
+
actions: readonly PhiRecordWidgetAction[];
|
|
7
|
+
provider: PhiTableProviderRegistration | null;
|
|
8
|
+
resource: PhiTableProviderResourceDescriptor | null;
|
|
9
|
+
source: PhiProviderResourceSource | null;
|
|
10
|
+
/** The record shown, by identity; null while none is, and nothing runs then. */
|
|
11
|
+
rowIdentity: PhiTableRowIdentity | null;
|
|
12
|
+
/** What the Provider accepted, for the Widget to say and announce. */
|
|
13
|
+
onAccepted: (result: PhiTableProviderMutationResult, action: PhiRecordWidgetAction, rowIdentity: PhiTableRowIdentity, correlationId: string | undefined) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare function usePhiRecordWidgetActions({ actions, provider, resource, source, rowIdentity, onAccepted, }: PhiRecordWidgetActionsInput): {
|
|
16
|
+
activate: (actionKey: string, correlationId?: string) => void;
|
|
17
|
+
error: string | null;
|
|
18
|
+
forget: () => void;
|
|
19
|
+
confirmDialog: import("react").JSX.Element;
|
|
20
|
+
};
|