@phis/ui 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/cms/phi-cms-layout-renderer.js +15 -7
- package/components/cms/phi-cms-render-diagnostic-client.d.ts +3 -1
- package/components/cms/phi-cms-render-diagnostic-client.js +4 -3
- package/components/cms/phi-cms-render-diagnostic.d.ts +8 -2
- package/components/cms/phi-cms-render-diagnostic.js +12 -2
- package/components/cms/phi-cms-render-error-boundary.d.ts +2 -0
- package/components/cms/phi-cms-render-error-boundary.js +1 -1
- package/components/cms/phi-cms-root-layout.js +3 -1
- package/components/controls/phi-media-picker-control.d.ts +9 -0
- package/components/controls/phi-media-picker-control.js +1 -1
- package/components/controls/phi-popover-control.js +4 -1
- package/components/controls/phi-table-control.d.ts +7 -1
- package/components/controls/phi-table-control.js +23 -8
- package/components/forms/form-descriptor-field-check.d.ts +18 -0
- package/components/forms/form-descriptor-field-check.js +41 -0
- package/components/forms/form-descriptor-runtime-client.js +11 -10
- package/components/forms/form-record-source.d.ts +38 -0
- package/components/forms/form-record-source.js +48 -0
- package/components/forms/shared-form-descriptors.d.ts +0 -34
- package/components/forms/shared-form-descriptors.js +0 -6
- package/components/forms/shared-form-ids.d.ts +1 -1
- package/components/forms/shared-form-ids.js +1 -1
- package/components/media/media-settings-labels.d.ts +1 -0
- package/components/media/media-settings-labels.js +2 -0
- package/components/media/phi-media-picker-binding.d.ts +41 -33
- package/components/media/phi-media-picker-binding.js +2 -1
- package/components/media/use-media-library-add-picker.d.ts +33 -32
- package/components/overlays/phi-overlay-container-client.js +11 -9
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +7 -0
- package/components/regions/presets/phi-settings-page-shell-tree.js +3 -3
- package/components/shell/phi-icon-names.d.ts +3 -0
- package/components/shell/phi-icon-names.js +3 -0
- package/components/shell/phi-icon.d.ts +5 -7
- package/components/shell/phi-icon.js +8 -21
- package/components/tables/client/phi-table-binding-params.d.ts +24 -0
- package/components/tables/client/phi-table-binding-params.js +39 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -3
- package/components/tables/client/phi-table-binding.js +5 -9
- package/components/widgets/client/shared/phi-button-icons.d.ts +6 -4
- package/components/widgets/client/shared/phi-button-icons.js +8 -12
- package/components/widgets/client/shared/phi-collection-binding-params.d.ts +8 -0
- package/components/widgets/client/shared/phi-collection-binding-params.js +13 -0
- package/components/widgets/client/shared/phi-collection-provider.d.ts +11 -1
- package/components/widgets/client/shared/phi-collection-provider.js +5 -0
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-command-buttons.d.ts +16 -0
- package/components/widgets/client/shared/phi-command-buttons.js +9 -1
- package/components/widgets/label-sets/admin-users.d.ts +1 -0
- package/components/widgets/label-sets/admin-users.js +2 -0
- package/components/widgets/label-sets/builder-modules.js +4 -0
- package/components/widgets/label-sets/profile.d.ts +0 -16
- package/components/widgets/label-sets/profile.js +0 -37
- package/components/widgets/label-sets/registration.d.ts +0 -1
- package/components/widgets/label-sets/registration.js +0 -2
- package/components/widgets/label-sets/revisions.js +2 -0
- package/components/widgets/label-sets/signals.js +2 -0
- package/components/widgets/label-types/builder-modules.d.ts +4 -0
- package/components/widgets/label-types/builder-modules.js +2 -0
- package/components/widgets/label-types/revisions.d.ts +2 -0
- package/components/widgets/label-types/revisions.js +2 -1
- package/components/widgets/label-types/signals.d.ts +2 -0
- package/components/widgets/label-types/signals.js +1 -0
- package/components/widgets/shared/widget-failure-audience.d.ts +7 -0
- package/components/widgets/shared/widget-failure-audience.js +21 -0
- package/components/widgets/shared/widget-failure-client.js +5 -2
- package/components/widgets/shared/widget-failure-notice-client.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice-client.js +10 -0
- package/components/widgets/shared/widget-failure-notice.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice.js +17 -0
- package/components/widgets/shared/widget-failure-staff.d.ts +3 -0
- package/components/widgets/shared/widget-failure-staff.js +18 -0
- package/components/widgets/shared/widget-failure.d.ts +9 -6
- package/components/widgets/shared/widget-failure.js +0 -9
- package/components/widgets/shared/widget-failure.server.d.ts +4 -2
- package/components/widgets/shared/widget-failure.server.js +8 -3
- package/constants/customer-file.d.ts +12 -3
- package/constants/customer-file.js +12 -3
- package/constants/runtime-module-ownership.js +4 -3
- package/constants/site-address.d.ts +9 -0
- package/constants/site-address.js +10 -0
- package/constants/table-loading.d.ts +14 -0
- package/constants/table-loading.js +14 -0
- package/constants.d.ts +2 -1
- package/constants.js +3 -1
- package/gateway/site-cms-write-validation.js +19 -3
- package/helpers/announced-action.d.ts +17 -0
- package/helpers/announced-action.js +29 -0
- package/helpers/phi-metadata.d.ts +0 -8
- package/helpers/phi-metadata.js +1 -10
- package/helpers/phi-site-description.d.ts +11 -0
- package/helpers/phi-site-description.js +13 -0
- package/helpers/preset-form-check.d.ts +14 -0
- package/helpers/preset-form-check.js +12 -0
- package/helpers/preset-table-check.d.ts +19 -15
- package/helpers/preset-table-check.js +33 -39
- package/helpers/record-widget-binding.d.ts +10 -0
- package/helpers/record-widget-binding.js +35 -0
- package/helpers/record-widget.d.ts +1 -10
- package/helpers/record-widget.js +4 -33
- package/helpers/table-widget-binding.d.ts +12 -0
- package/helpers/table-widget-binding.js +296 -0
- package/helpers/tree-widget-binding.d.ts +19 -0
- package/helpers/tree-widget-binding.js +72 -0
- package/helpers/typed-confirmation.d.ts +9 -0
- package/helpers/typed-confirmation.js +13 -0
- package/helpers/widget-binding-check.d.ts +22 -0
- package/helpers/widget-binding-check.js +91 -0
- package/module-page-check.d.ts +2 -0
- package/module-page-check.js +2 -0
- package/next/root-route.js +2 -1
- package/package.json +1 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +7 -4
- package/plugins/runtime-modules/accounting/ids.js +14 -3
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +21 -9
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +29 -15
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +11 -8
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +206 -137
- package/plugins/runtime-modules/app/client-data-providers.js +1 -1
- package/plugins/runtime-modules/app/data-providers.d.ts +14 -69
- package/plugins/runtime-modules/app/data-providers.js +19 -54
- package/plugins/runtime-modules/app/definition.d.ts +8 -80
- package/plugins/runtime-modules/app/forms.d.ts +1 -16
- package/plugins/runtime-modules/app/forms.js +0 -59
- package/plugins/runtime-modules/app/ids.d.ts +2 -1
- package/plugins/runtime-modules/app/ids.js +3 -2
- package/plugins/runtime-modules/app/module.d.ts +8 -80
- package/plugins/runtime-modules/app/services/addresses-collection.d.ts +59 -0
- package/plugins/runtime-modules/app/services/{addresses-table.js → addresses-collection.js} +23 -19
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +10 -6
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +37 -73
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +0 -5
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +2 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.d.ts +1 -2
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +1 -17
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +0 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.js +2 -14
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +5 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +16 -6
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -1
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -1
- package/plugins/runtime-modules/builder/controller/signal-wiring-controller.js +5 -1
- package/plugins/runtime-modules/builder/signal-wiring-options.js +9 -2
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +5 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -1
- package/plugins/runtime-modules/client-manifests/common.js +6 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +5 -2
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.d.ts +55 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +173 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.d.ts +48 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.js +67 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.js +14 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +30 -48
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.js +6 -1
- package/plugins/runtime-modules/core/widgets/thread-widget-config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/thread-widget-config.js +6 -0
- package/plugins/runtime-modules/core/widgets/tree/client.js +6 -6
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.d.ts +2 -0
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +5 -0
- package/plugins/runtime-modules/revisions/controller/binding.d.ts +37 -0
- package/plugins/runtime-modules/revisions/controller/binding.js +75 -0
- package/plugins/runtime-modules/revisions/controller/client.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/client.js +74 -50
- package/plugins/runtime-modules/revisions/controller/definition.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/definition.js +10 -0
- package/plugins/runtime-modules/revisions/forms.js +1 -1
- package/plugins/runtime-modules/revisions/page-ids.d.ts +1 -1
- package/plugins/runtime-modules/revisions/page-ids.js +4 -1
- package/plugins/runtime-modules/revisions/services/options.js +14 -4
- package/plugins/runtime-modules/revisions/services/table.js +41 -21
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +76 -3
- package/plugins/runtime-modules/theme/controller/runtime.js +14 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +39 -13
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/client.js +62 -2
- package/plugins/runtime-modules/threads/controller/definition.js +48 -0
- package/plugins/runtime-modules/threads/data-providers.d.ts +22 -37
- package/plugins/runtime-modules/threads/data-providers.js +35 -24
- package/plugins/runtime-modules/threads/definition.d.ts +22 -37
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +2 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.d.ts +30 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.js +59 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.d.ts +22 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.js +101 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +14 -80
- package/plugins/runtime-modules/threads/services/customer-file-table.js +27 -112
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +4 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +4 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +15 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -0
- package/server-helpers/runtime.js +0 -1
- package/styles/controls.css +4 -2
- package/styles/layout.css +7 -0
- package/theme/phi-antd-token-resolver.d.ts +8 -0
- package/theme/phi-antd-token-resolver.js +10 -0
- package/theme/phi-theme-color.d.ts +19 -0
- package/theme/phi-theme-color.js +42 -0
- package/theme/phi-theme-gradients.js +4 -22
- package/theme/phi-theme-palette-defaults.d.ts +16 -0
- package/theme/phi-theme-palette-defaults.js +103 -0
- package/types/cms-plugins.d.ts +6 -1
- package/types/collection-provider.d.ts +27 -0
- package/types/collection-signal-values.d.ts +2 -0
- package/types/collection-signal-values.js +23 -0
- package/types/collection-view-widget.d.ts +9 -0
- package/types/core-widget-placements.d.ts +6 -0
- package/types/signals.d.ts +2 -0
- package/types/signals.js +2 -0
- package/types/table-widget.d.ts +15 -1
- package/types/table-widget.js +0 -282
- package/types/tree-widget.d.ts +0 -1
- package/types/tree-widget.js +0 -60
- package/types/widget-runtime.d.ts +0 -1
- package/types.d.ts +1 -1
- package/types.js +1 -1
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +0 -135
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PhiCmsInstanceId } from "../../../../../types/cms-instance-id";
|
|
2
|
+
import type { PhiCollectionProviderResourceDescriptor, PhiCollectionViewBindingModel } from "../../../../../types/collection-provider";
|
|
3
|
+
import type { PhiCmsCollectionViewWidgetConfig } from "../../../../../types/collection-view-widget";
|
|
4
|
+
import type { PhiRenderableBlockRenderMode } from "../../../../../types/renderable-block";
|
|
5
|
+
import { type PhiSiteAddressPurpose } from "./site-address-tiles";
|
|
6
|
+
/**
|
|
7
|
+
* What the tiles say, in English, under what the placement's `presentation.labels` says in the reader's
|
|
8
|
+
* language: a Page writes its own words there, from its Label Set, group by group.
|
|
9
|
+
*/
|
|
10
|
+
export type PhiSiteAddressRendererLabels = {
|
|
11
|
+
purposes: Record<PhiSiteAddressPurpose, string>;
|
|
12
|
+
actions: {
|
|
13
|
+
edit: string;
|
|
14
|
+
remove: string;
|
|
15
|
+
defaultBilling: string;
|
|
16
|
+
defaultShipping: string;
|
|
17
|
+
select: string;
|
|
18
|
+
reload: string;
|
|
19
|
+
};
|
|
20
|
+
remove: {
|
|
21
|
+
title: string;
|
|
22
|
+
text: string;
|
|
23
|
+
ok: string;
|
|
24
|
+
cancel: string;
|
|
25
|
+
};
|
|
26
|
+
empty: string;
|
|
27
|
+
/** Said where the Provider refused an action and gave no words of its own. */
|
|
28
|
+
failed: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const PHI_SITE_ADDRESS_RENDERER_DEFAULT_LABELS: PhiSiteAddressRendererLabels;
|
|
31
|
+
/**
|
|
32
|
+
* The address renderer (`PHI_SITE_ADDRESS_ITEM_RENDERER_KEY`): a Collection's items as the addresses of a
|
|
33
|
+
* Site's book, one Card each in the View's grid (COLLECTIONS.md, "The address renderer").
|
|
34
|
+
*
|
|
35
|
+
* - **Items** in the shape `toPhiSiteAddressRow` answers (`helpers/site-address-row.ts`); `id` is the
|
|
36
|
+
* address id and the item's key. A tile names the company and the name, the parts after them a line
|
|
37
|
+
* each, the country in the reader's language, and the purposes and defaults as tags.
|
|
38
|
+
* - **Item actions** are the resource's: `edit` is announced on `actionActivate` as `{ actionKey, itemKey }`
|
|
39
|
+
* -- a record-bound Form opens on it -- and `makeDefaultBilling`, `makeDefaultShipping` and `delete` run
|
|
40
|
+
* through the Provider, `delete` after its confirmation. A resource that declares none is read-only.
|
|
41
|
+
* - **Toolbar actions** (`features.actions.toolbar`) are announced as `{ actionKey, query }`, each one the
|
|
42
|
+
* resource declares at resource scope; one it does not is the Widget's failure.
|
|
43
|
+
* - **Choosing** (`features.selection: { mode: "single" }`, prepared for the Shop's checkout) puts a
|
|
44
|
+
* Choose on every tile and says the chosen address on `selection` as `{ addressId }`.
|
|
45
|
+
* - **The Provider's own empty sentence** (`meta.emptyDescription`) stands in for the placement's where it
|
|
46
|
+
* answers no items for a reason of its own.
|
|
47
|
+
*/
|
|
48
|
+
export declare function PhiSiteAddressCollectionViewBinding({ config, binding, widgetId, renderMode, resource, }: {
|
|
49
|
+
config: PhiCmsCollectionViewWidgetConfig;
|
|
50
|
+
binding: PhiCollectionViewBindingModel;
|
|
51
|
+
labels?: unknown;
|
|
52
|
+
widgetId?: PhiCmsInstanceId | null;
|
|
53
|
+
renderMode: PhiRenderableBlockRenderMode;
|
|
54
|
+
resource?: PhiCollectionProviderResourceDescriptor | null;
|
|
55
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { isPhiRecord } from "../../../../../helpers/is-record";
|
|
5
|
+
import { createPhiSignalAddress } from "../../../../../types/signals";
|
|
6
|
+
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
7
|
+
import { PhiAlertControl } from "../../../../../components/controls/phi-alert-control";
|
|
8
|
+
import { PhiButtonControl } from "../../../../../components/controls/phi-button-control";
|
|
9
|
+
import { PhiCardControl } from "../../../../../components/controls/phi-card-control";
|
|
10
|
+
import { PhiCollectionViewControl, PhiCollectionViewSkeletonControl, } from "../../../../../components/controls/phi-collection-view-control";
|
|
11
|
+
import { PhiConfirmControl } from "../../../../../components/controls/phi-confirm-control";
|
|
12
|
+
import { PhiEmptyControl } from "../../../../../components/controls/phi-empty-control";
|
|
13
|
+
import { PhiTagControl } from "../../../../../components/controls/phi-tag-control";
|
|
14
|
+
import { PhiToolbarControl } from "../../../../../components/controls/phi-toolbar-control";
|
|
15
|
+
import { PhiTypographyControl } from "../../../../../components/controls/phi-typography-control";
|
|
16
|
+
import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
|
|
17
|
+
import { usePhiIntlLocale } from "../../../../../components/root/phi-intl-locale";
|
|
18
|
+
import { usePhiApplicationFeedback } from "../../../../../components/runtime/use-phi-application-feedback";
|
|
19
|
+
import { resolvePhiButtonIcon } from "../../../../../components/widgets/client/shared/phi-button-icons";
|
|
20
|
+
import { usePhiControlSignalController } from "../../../../../components/widgets/client/shared/phi-control-signals";
|
|
21
|
+
import { PhiWidgetFailure } from "../../../../../components/widgets/shared/widget-failure-client";
|
|
22
|
+
import { readPhiSiteAddressTile, readPhiSiteAddressToolFailure, resolvePhiSiteAddressTileActions, } from "./site-address-tiles";
|
|
23
|
+
export const PHI_SITE_ADDRESS_RENDERER_DEFAULT_LABELS = {
|
|
24
|
+
purposes: {
|
|
25
|
+
billing: "Billing",
|
|
26
|
+
shipping: "Shipping",
|
|
27
|
+
defaultBilling: "Default billing",
|
|
28
|
+
defaultShipping: "Default shipping",
|
|
29
|
+
},
|
|
30
|
+
actions: {
|
|
31
|
+
edit: "Change",
|
|
32
|
+
remove: "Remove",
|
|
33
|
+
defaultBilling: "Use for billing by default",
|
|
34
|
+
defaultShipping: "Use for shipping by default",
|
|
35
|
+
select: "Choose",
|
|
36
|
+
reload: "Reload",
|
|
37
|
+
},
|
|
38
|
+
remove: { title: "Remove this address?", text: "", ok: "Remove", cancel: "Cancel" },
|
|
39
|
+
empty: "No address yet.",
|
|
40
|
+
failed: "The address could not be changed.",
|
|
41
|
+
};
|
|
42
|
+
/** A group of the defaults with the placement's strings laid over it, key by key; anything else is left. */
|
|
43
|
+
function overlayGroup(base, override) {
|
|
44
|
+
if (!isPhiRecord(override))
|
|
45
|
+
return base;
|
|
46
|
+
const result = { ...base };
|
|
47
|
+
for (const key of Object.keys(base)) {
|
|
48
|
+
const value = override[key];
|
|
49
|
+
if (typeof value === "string")
|
|
50
|
+
result[key] = value;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function readLabels(raw) {
|
|
55
|
+
const labels = isPhiRecord(raw) ? raw : {};
|
|
56
|
+
const base = PHI_SITE_ADDRESS_RENDERER_DEFAULT_LABELS;
|
|
57
|
+
return {
|
|
58
|
+
purposes: overlayGroup(base.purposes, labels.purposes),
|
|
59
|
+
actions: overlayGroup(base.actions, labels.actions),
|
|
60
|
+
remove: overlayGroup(base.remove, labels.remove),
|
|
61
|
+
empty: typeof labels.empty === "string" ? labels.empty : base.empty,
|
|
62
|
+
failed: typeof labels.failed === "string" ? labels.failed : base.failed,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const TILE_MIN_COLUMN_WIDTH = 233;
|
|
66
|
+
const ACTION_ICONS = {
|
|
67
|
+
edit: "edit",
|
|
68
|
+
makeDefaultBilling: "antd:file-text",
|
|
69
|
+
makeDefaultShipping: "antd:shopping",
|
|
70
|
+
delete: "antd:delete",
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The address renderer (`PHI_SITE_ADDRESS_ITEM_RENDERER_KEY`): a Collection's items as the addresses of a
|
|
74
|
+
* Site's book, one Card each in the View's grid (COLLECTIONS.md, "The address renderer").
|
|
75
|
+
*
|
|
76
|
+
* - **Items** in the shape `toPhiSiteAddressRow` answers (`helpers/site-address-row.ts`); `id` is the
|
|
77
|
+
* address id and the item's key. A tile names the company and the name, the parts after them a line
|
|
78
|
+
* each, the country in the reader's language, and the purposes and defaults as tags.
|
|
79
|
+
* - **Item actions** are the resource's: `edit` is announced on `actionActivate` as `{ actionKey, itemKey }`
|
|
80
|
+
* -- a record-bound Form opens on it -- and `makeDefaultBilling`, `makeDefaultShipping` and `delete` run
|
|
81
|
+
* through the Provider, `delete` after its confirmation. A resource that declares none is read-only.
|
|
82
|
+
* - **Toolbar actions** (`features.actions.toolbar`) are announced as `{ actionKey, query }`, each one the
|
|
83
|
+
* resource declares at resource scope; one it does not is the Widget's failure.
|
|
84
|
+
* - **Choosing** (`features.selection: { mode: "single" }`, prepared for the Shop's checkout) puts a
|
|
85
|
+
* Choose on every tile and says the chosen address on `selection` as `{ addressId }`.
|
|
86
|
+
* - **The Provider's own empty sentence** (`meta.emptyDescription`) stands in for the placement's where it
|
|
87
|
+
* answers no items for a reason of its own.
|
|
88
|
+
*/
|
|
89
|
+
export function PhiSiteAddressCollectionViewBinding({ config, binding, widgetId, renderMode, resource, }) {
|
|
90
|
+
const { presentation, features } = config;
|
|
91
|
+
const { token } = usePhiConfig();
|
|
92
|
+
const locale = usePhiIntlLocale();
|
|
93
|
+
const { showMessage } = usePhiApplicationFeedback();
|
|
94
|
+
const labels = useMemo(() => readLabels(presentation.labels), [presentation.labels]);
|
|
95
|
+
const controlSize = presentation.controlSize ?? "small";
|
|
96
|
+
const selectable = features.selection?.mode === "single";
|
|
97
|
+
const toolbarActions = useMemo(() => features.actions?.toolbar ?? [], [features.actions?.toolbar]);
|
|
98
|
+
const toolFailure = readPhiSiteAddressToolFailure({
|
|
99
|
+
toolbarKeys: toolbarActions.map((action) => action.key),
|
|
100
|
+
selection: selectable,
|
|
101
|
+
resource,
|
|
102
|
+
});
|
|
103
|
+
const [pendingIds, setPendingIds] = useState([]);
|
|
104
|
+
const [chosenId, setChosenId] = useState(null);
|
|
105
|
+
const signals = usePhiControlSignalController({
|
|
106
|
+
key: "siteAddressAction",
|
|
107
|
+
sender: widgetId == null ? null : createPhiSignalAddress("cms", widgetId),
|
|
108
|
+
signalRoutes: config.signalRoutes,
|
|
109
|
+
valueType: "json",
|
|
110
|
+
typeKey: "collection-action",
|
|
111
|
+
});
|
|
112
|
+
const tiles = useMemo(() => {
|
|
113
|
+
const names = new Intl.DisplayNames([locale], { type: "region", fallback: "code" });
|
|
114
|
+
return (binding.data?.items ?? []).flatMap((item) => {
|
|
115
|
+
const tile = readPhiSiteAddressTile(item, (code) => names.of(code) ?? code);
|
|
116
|
+
return tile ? [tile] : [];
|
|
117
|
+
});
|
|
118
|
+
}, [binding.data?.items, locale]);
|
|
119
|
+
if (toolFailure) {
|
|
120
|
+
return (_jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.CollectionView, widgetId: widgetId, title: toolFailure }));
|
|
121
|
+
}
|
|
122
|
+
async function runProviderAction(tile, actionKey) {
|
|
123
|
+
setPendingIds((current) => current.includes(tile.id) ? current : [...current, tile.id]);
|
|
124
|
+
try {
|
|
125
|
+
const data = await binding.activate({ actionKey, itemKey: tile.id, query: binding.query });
|
|
126
|
+
if (data.error)
|
|
127
|
+
throw new Error(data.error);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
showMessage({
|
|
131
|
+
level: "error",
|
|
132
|
+
content: error instanceof Error && error.message ? error.message : labels.failed,
|
|
133
|
+
durationSeconds: 2.8,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
setPendingIds((current) => current.filter((id) => id !== tile.id));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function choose(tile) {
|
|
141
|
+
setChosenId(tile.id);
|
|
142
|
+
signals.emitCapability("selection", { addressId: tile.id });
|
|
143
|
+
}
|
|
144
|
+
function renderActions(tile) {
|
|
145
|
+
const pending = pendingIds.includes(tile.id);
|
|
146
|
+
const actions = resolvePhiSiteAddressTileActions(resource, tile);
|
|
147
|
+
if (actions.length === 0 && !selectable)
|
|
148
|
+
return null;
|
|
149
|
+
const label = (key) => key === "edit" ? labels.actions.edit
|
|
150
|
+
: key === "makeDefaultBilling" ? labels.actions.defaultBilling
|
|
151
|
+
: key === "makeDefaultShipping" ? labels.actions.defaultShipping
|
|
152
|
+
: labels.actions.remove;
|
|
153
|
+
return (_jsxs(PhiToolbarControl, { compact: true, size: controlSize, children: [selectable ? (_jsx(PhiButtonControl, { ariaLabel: labels.actions.select, ariaPressed: chosenId === tile.id, tooltip: labels.actions.select, icon: resolvePhiButtonIcon("check"), type: chosenId === tile.id ? "primary" : "default", size: controlSize, onClick: () => choose(tile) })) : null, actions.map((key) => key === "delete" ? (_jsx(PhiConfirmControl, { title: labels.remove.title, description: labels.remove.text || undefined, confirmLabel: labels.remove.ok, cancelLabel: labels.remove.cancel, danger: true, disabled: pending, onConfirm: () => runProviderAction(tile, key), children: _jsx(PhiButtonControl, { ariaLabel: label(key), tooltip: label(key), icon: resolvePhiButtonIcon(ACTION_ICONS[key]), danger: true, size: controlSize, disabled: pending,
|
|
154
|
+
// The confirmation reacts to the press; this only keeps the button a live one.
|
|
155
|
+
onClick: () => undefined }) }, key)) : (_jsx(PhiButtonControl, { ariaLabel: label(key), tooltip: label(key), icon: resolvePhiButtonIcon(ACTION_ICONS[key]), size: controlSize, disabled: pending, loading: pending && key !== "edit", onClick: key === "edit"
|
|
156
|
+
? () => signals.emitCapability("actionActivate", { actionKey: key, itemKey: tile.id })
|
|
157
|
+
: () => void runProviderAction(tile, key) }, key)))] }));
|
|
158
|
+
}
|
|
159
|
+
const items = tiles.map((tile) => (_jsx(PhiCardControl, { size: "small", title: tile.title, toolbar: renderActions(tile), style: selectable && chosenId === tile.id ? { borderColor: token.colorPrimary } : undefined, children: _jsxs("div", { style: { display: "flex", flexDirection: "column", gap: token.paddingXS }, children: [_jsx("div", { style: { display: "flex", flexDirection: "column" }, children: tile.lines.map((line, index) => (_jsx(PhiTypographyControl, { children: line }, `${index}-${line}`))) }), tile.purposes.length > 0 ? (_jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: token.paddingXXS }, children: tile.purposes.map((purpose) => (_jsx(PhiTagControl, { color: purpose.startsWith("default") ? "processing" : "default", children: labels.purposes[purpose] }, purpose))) })) : null] }) }, tile.id)));
|
|
160
|
+
const mode = presentation.mode;
|
|
161
|
+
const gap = presentation.gap;
|
|
162
|
+
const minColumnWidth = presentation.minColumnWidth ?? TILE_MIN_COLUMN_WIDTH;
|
|
163
|
+
const toolbar = toolbarActions.length > 0 || features.tools.reload ? (_jsxs(PhiToolbarControl, { compact: true, size: controlSize, children: [toolbarActions.map((action) => {
|
|
164
|
+
const display = action.display ?? "icon";
|
|
165
|
+
const actionLabel = action.label ?? action.key;
|
|
166
|
+
return (_jsx(PhiButtonControl, { label: display === "icon" ? undefined : actionLabel, ariaLabel: actionLabel, tooltip: action.description ?? (display === "icon" ? actionLabel : undefined), icon: display === "label" || !action.icon ? undefined : resolvePhiButtonIcon(action.icon), type: action.mode === "primary" ? "primary" : "default", danger: action.mode === "danger", size: controlSize, onClick: () => signals.emitCapability("actionActivate", { actionKey: action.key, query: binding.query }) }, action.key));
|
|
167
|
+
}), features.tools.reload ? (_jsx(PhiButtonControl, { ariaLabel: labels.actions.reload, tooltip: labels.actions.reload, icon: resolvePhiButtonIcon("reload"), size: controlSize, onClick: binding.reload })) : null] })) : null;
|
|
168
|
+
const emptyDescription = typeof binding.data?.meta?.emptyDescription === "string" && binding.data.meta.emptyDescription.trim()
|
|
169
|
+
? binding.data.meta.emptyDescription
|
|
170
|
+
: presentation.emptyDescription ?? labels.empty;
|
|
171
|
+
const body = binding.data == null ? (binding.error ? null : _jsx(PhiCollectionViewSkeletonControl, { mode: mode, gap: gap, minColumnWidth: minColumnWidth, count: 2 })) : tiles.length === 0 ? (_jsx(PhiEmptyControl, { description: emptyDescription })) : undefined;
|
|
172
|
+
return (_jsx(PhiCollectionViewControl, { title: presentation.title, description: presentation.description, toolbar: features.tools.mode === "external" ? null : toolbar, diagnostics: binding.error && binding.data != null ? _jsx(PhiAlertControl, { level: "error", title: binding.error }) : null, body: body, items: items, mode: mode, ...(gap ? { gap } : {}), minColumnWidth: minColumnWidth, pagination: null }));
|
|
173
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PhiCollectionProviderResourceDescriptor } from "../../../../../types/collection-provider";
|
|
2
|
+
/**
|
|
3
|
+
* What an address tile reads of an item and offers on it (COLLECTIONS.md, "The address renderer"), apart
|
|
4
|
+
* from drawing it. Pure and React-free, so the rules are tested as rules.
|
|
5
|
+
*/
|
|
6
|
+
/** The four marks a tile shows as tags, in this order: what the address is for, then what it is the default for. */
|
|
7
|
+
export declare const PHI_SITE_ADDRESS_PURPOSES: readonly ["billing", "shipping", "defaultBilling", "defaultShipping"];
|
|
8
|
+
export type PhiSiteAddressPurpose = (typeof PHI_SITE_ADDRESS_PURPOSES)[number];
|
|
9
|
+
/**
|
|
10
|
+
* The item actions the renderer has a control for, in the order a tile draws them. `edit` is announced
|
|
11
|
+
* on the Widget's `actionActivate` (`{ actionKey: "edit", itemKey }`) for the dialog that changes the
|
|
12
|
+
* address; the other three are the Provider's own actions, run through the Binding (`itemKey` the
|
|
13
|
+
* address id), whose answer is the collection as it now stands. `delete` asks first.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PHI_SITE_ADDRESS_ITEM_ACTIONS: readonly ["edit", "makeDefaultBilling", "makeDefaultShipping", "delete"];
|
|
16
|
+
export type PhiSiteAddressItemAction = (typeof PHI_SITE_ADDRESS_ITEM_ACTIONS)[number];
|
|
17
|
+
export type PhiSiteAddressTile = {
|
|
18
|
+
id: number;
|
|
19
|
+
/** The company where there is one, else the name: what the address is made out to. */
|
|
20
|
+
title: string;
|
|
21
|
+
/** The name under a company, then the parts after it, one per line; empty parts left out. */
|
|
22
|
+
lines: string[];
|
|
23
|
+
purposes: PhiSiteAddressPurpose[];
|
|
24
|
+
defaultBilling: boolean;
|
|
25
|
+
defaultShipping: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* One item as a tile, from the shape `toPhiSiteAddressRow` answers (`helpers/site-address-row.ts`), or
|
|
29
|
+
* null for one that is no address (no positive whole id): an item the renderer cannot name is not drawn
|
|
30
|
+
* as a tile it could act on. `countryName` names a country code in the reader's language.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readPhiSiteAddressTile(item: Readonly<Record<string, unknown>>, countryName: (code: string) => string): PhiSiteAddressTile | null;
|
|
33
|
+
/**
|
|
34
|
+
* The item actions a tile offers: those the resource declares at item scope, in the renderer's order,
|
|
35
|
+
* and of the two defaults only the one the address does not already hold. A resource that declares none
|
|
36
|
+
* -- the customer file's -- is read-only, and its tiles offer nothing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolvePhiSiteAddressTileActions(resource: Pick<PhiCollectionProviderResourceDescriptor, "actions"> | null | undefined, tile: Pick<PhiSiteAddressTile, "defaultBilling" | "defaultShipping">): PhiSiteAddressItemAction[];
|
|
39
|
+
/**
|
|
40
|
+
* Why the placement asks for a tool the resource does not offer, or null: a toolbar action the resource
|
|
41
|
+
* does not declare at resource scope, or a selection the resource announces under no schema. Said as the
|
|
42
|
+
* Widget's failure rather than drawn as a control that does nothing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readPhiSiteAddressToolFailure({ toolbarKeys, selection, resource, }: {
|
|
45
|
+
toolbarKeys: readonly string[];
|
|
46
|
+
selection: boolean;
|
|
47
|
+
resource: Pick<PhiCollectionProviderResourceDescriptor, "actions" | "resourceKey" | "selectionValueSchema"> | null | undefined;
|
|
48
|
+
}): string | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an address tile reads of an item and offers on it (COLLECTIONS.md, "The address renderer"), apart
|
|
3
|
+
* from drawing it. Pure and React-free, so the rules are tested as rules.
|
|
4
|
+
*/
|
|
5
|
+
/** The four marks a tile shows as tags, in this order: what the address is for, then what it is the default for. */
|
|
6
|
+
export const PHI_SITE_ADDRESS_PURPOSES = ["billing", "shipping", "defaultBilling", "defaultShipping"];
|
|
7
|
+
/**
|
|
8
|
+
* The item actions the renderer has a control for, in the order a tile draws them. `edit` is announced
|
|
9
|
+
* on the Widget's `actionActivate` (`{ actionKey: "edit", itemKey }`) for the dialog that changes the
|
|
10
|
+
* address; the other three are the Provider's own actions, run through the Binding (`itemKey` the
|
|
11
|
+
* address id), whose answer is the collection as it now stands. `delete` asks first.
|
|
12
|
+
*/
|
|
13
|
+
export const PHI_SITE_ADDRESS_ITEM_ACTIONS = ["edit", "makeDefaultBilling", "makeDefaultShipping", "delete"];
|
|
14
|
+
function text(value) {
|
|
15
|
+
return typeof value === "string" ? value.trim() : "";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One item as a tile, from the shape `toPhiSiteAddressRow` answers (`helpers/site-address-row.ts`), or
|
|
19
|
+
* null for one that is no address (no positive whole id): an item the renderer cannot name is not drawn
|
|
20
|
+
* as a tile it could act on. `countryName` names a country code in the reader's language.
|
|
21
|
+
*/
|
|
22
|
+
export function readPhiSiteAddressTile(item, countryName) {
|
|
23
|
+
const id = item.id;
|
|
24
|
+
if (typeof id !== "number" || !Number.isSafeInteger(id) || id <= 0)
|
|
25
|
+
return null;
|
|
26
|
+
const company = text(item.companyName);
|
|
27
|
+
const name = text(item.name);
|
|
28
|
+
const place = [text(item.postalCode), text(item.city)].filter(Boolean).join(" ");
|
|
29
|
+
const country = text(item.country);
|
|
30
|
+
const marks = Array.isArray(item.purposes) ? item.purposes : [];
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
title: company || name,
|
|
34
|
+
lines: [company ? name : "", text(item.line1), text(item.line2), place, text(item.region), country ? countryName(country) : ""]
|
|
35
|
+
.filter(Boolean),
|
|
36
|
+
purposes: PHI_SITE_ADDRESS_PURPOSES.filter((purpose) => marks.includes(purpose)),
|
|
37
|
+
defaultBilling: item.defaultBilling === true,
|
|
38
|
+
defaultShipping: item.defaultShipping === true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The item actions a tile offers: those the resource declares at item scope, in the renderer's order,
|
|
43
|
+
* and of the two defaults only the one the address does not already hold. A resource that declares none
|
|
44
|
+
* -- the customer file's -- is read-only, and its tiles offer nothing.
|
|
45
|
+
*/
|
|
46
|
+
export function resolvePhiSiteAddressTileActions(resource, tile) {
|
|
47
|
+
const declared = new Set((resource?.actions ?? []).filter((action) => action.scope === "item").map((action) => action.key));
|
|
48
|
+
return PHI_SITE_ADDRESS_ITEM_ACTIONS.filter((key) => declared.has(key) &&
|
|
49
|
+
!(key === "makeDefaultBilling" && tile.defaultBilling) &&
|
|
50
|
+
!(key === "makeDefaultShipping" && tile.defaultShipping));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Why the placement asks for a tool the resource does not offer, or null: a toolbar action the resource
|
|
54
|
+
* does not declare at resource scope, or a selection the resource announces under no schema. Said as the
|
|
55
|
+
* Widget's failure rather than drawn as a control that does nothing.
|
|
56
|
+
*/
|
|
57
|
+
export function readPhiSiteAddressToolFailure({ toolbarKeys, selection, resource, }) {
|
|
58
|
+
const declared = new Set((resource?.actions ?? []).filter((action) => action.scope === "resource").map((action) => action.key));
|
|
59
|
+
const missing = toolbarKeys.find((key) => !declared.has(key));
|
|
60
|
+
if (missing) {
|
|
61
|
+
return `The address tiles name the toolbar action "${missing}", which resource "${resource?.resourceKey ?? "unknown"}" does not declare.`;
|
|
62
|
+
}
|
|
63
|
+
if (selection && !resource?.selectionValueSchema) {
|
|
64
|
+
return `The address tiles offer a choice, and resource "${resource?.resourceKey ?? "unknown"}" announces no selection schema.`;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
@@ -116,7 +116,7 @@ export declare const PHI_COMMAND_TOOLBAR_WIDGET_DEFINITION: {
|
|
|
116
116
|
heading?: string;
|
|
117
117
|
} & {
|
|
118
118
|
type: "data-provider";
|
|
119
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
119
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
120
120
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
121
121
|
}) | ({
|
|
122
122
|
key: string;
|
|
@@ -72,7 +72,7 @@ export declare const PHI_DESCRIPTION_WIDGET_DEFINITION: {
|
|
|
72
72
|
heading?: string;
|
|
73
73
|
} & {
|
|
74
74
|
type: "data-provider";
|
|
75
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
75
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
76
76
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
77
77
|
}) | ({
|
|
78
78
|
key: string;
|
|
@@ -115,7 +115,7 @@ export declare const PHI_ENTRY_LIST_WIDGET_DEFINITION: {
|
|
|
115
115
|
heading?: string;
|
|
116
116
|
} & {
|
|
117
117
|
type: "data-provider";
|
|
118
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
118
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
119
119
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
120
120
|
}) | ({
|
|
121
121
|
key: string;
|
|
@@ -129,7 +129,7 @@ export declare const PHI_FLOAT_BUTTON_WIDGET_DEFINITION: {
|
|
|
129
129
|
heading?: string;
|
|
130
130
|
} & {
|
|
131
131
|
type: "data-provider";
|
|
132
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
132
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
133
133
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
134
134
|
}) | ({
|
|
135
135
|
key: string;
|
|
@@ -170,7 +170,7 @@ export declare const PHI_FORM_WIDGET_DEFINITION: {
|
|
|
170
170
|
} | {
|
|
171
171
|
key: string;
|
|
172
172
|
type: "data-provider";
|
|
173
|
-
providerKind: "table";
|
|
173
|
+
providerKind: ("table" | "collection")[];
|
|
174
174
|
label: string;
|
|
175
175
|
required?: undefined;
|
|
176
176
|
optionsProvider?: undefined;
|
|
@@ -97,6 +97,18 @@ export const PHI_FORM_WIDGET_DEFINITION = {
|
|
|
97
97
|
valueType: "json",
|
|
98
98
|
valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
|
|
99
99
|
},
|
|
100
|
+
/*
|
|
101
|
+
* The same open from a Collection View's item action (`{ actionKey, itemKey }`), the item's key the
|
|
102
|
+
* record's: one capability, two announcers, told apart by the schema the route carries (SIGNALS.md,
|
|
103
|
+
* inputs are unique by channel, action, value type and schema).
|
|
104
|
+
*/
|
|
105
|
+
{
|
|
106
|
+
id: "recordOpen",
|
|
107
|
+
channel: "action",
|
|
108
|
+
action: "activate",
|
|
109
|
+
valueType: "json",
|
|
110
|
+
valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.collectionAction,
|
|
111
|
+
},
|
|
100
112
|
{ id: "close", channel: "dialog", action: "close", valueType: "none" },
|
|
101
113
|
{ id: "reload", channel: "reload", action: "activate", valueType: "none" },
|
|
102
114
|
/*
|
|
@@ -164,7 +176,8 @@ export const PHI_FORM_WIDGET_DEFINITION = {
|
|
|
164
176
|
{
|
|
165
177
|
key: "source",
|
|
166
178
|
type: "data-provider",
|
|
167
|
-
|
|
179
|
+
// A Table's rows or a Collection's items, whichever resource declares `recordRead`.
|
|
180
|
+
providerKind: ["table", "collection"],
|
|
168
181
|
label: "Record source",
|
|
169
182
|
},
|
|
170
183
|
{ key: "openActionKey", type: "string", label: "Open action key" },
|
|
@@ -86,7 +86,7 @@ export declare const PHI_GALLERY_WIDGET_DEFINITION: {
|
|
|
86
86
|
heading?: string;
|
|
87
87
|
} & {
|
|
88
88
|
type: "data-provider";
|
|
89
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
89
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
90
90
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
91
91
|
}) | ({
|
|
92
92
|
key: string;
|
|
@@ -137,7 +137,7 @@ export declare const PHI_MARKDOWN_WIDGET_DEFINITION: {
|
|
|
137
137
|
heading?: string;
|
|
138
138
|
} & {
|
|
139
139
|
type: "data-provider";
|
|
140
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
140
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
141
141
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
142
142
|
}) | ({
|
|
143
143
|
key: string;
|
|
@@ -18,7 +18,6 @@ import { PHI_RECORD_WIDGET_DEFAULT_LABELS, formatPhiRecordWidgetLabel, } from ".
|
|
|
18
18
|
import { PhiWidgetFailure } from "../../../../../components/widgets/shared/widget-failure-client";
|
|
19
19
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
20
20
|
import { fillPhiRecordTitle } from "../../../../../helpers/record-title";
|
|
21
|
-
import { validatePhiRecordWidgetBinding } from "../../../../../helpers/record-widget";
|
|
22
21
|
import { readPhiTableActionSignalValue } from "../../../../../types/table-signal-values";
|
|
23
22
|
import { usePhiRecordWidgetActions } from "./actions";
|
|
24
23
|
export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAULT_LABELS, renderMode, }) {
|
|
@@ -43,8 +42,6 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
43
42
|
const emitCapability = useCallback((capabilityId, value, correlationId) => emitPhiSignalCapability(emitSignal, emitRoutes, capabilityId, value, correlationId), [emitRoutes, emitSignal]);
|
|
44
43
|
const { showMessage } = usePhiApplicationFeedback();
|
|
45
44
|
const { provider, resource, bindingError } = usePhiTableProvider(config.source);
|
|
46
|
-
// The actions measured against the resource, said where the record would stand (Table: contractError).
|
|
47
|
-
const contractError = useMemo(() => resource ? validatePhiRecordWidgetBinding(config, resource)[0] ?? null : null, [config, resource]);
|
|
48
45
|
// Sent with the read and part of what makes one new: an open record is read again after a switch.
|
|
49
46
|
const locale = usePhiIntlLocale();
|
|
50
47
|
const timeZone = usePhiIntlTimeZone();
|
|
@@ -190,9 +187,8 @@ export function PhiRecordWidgetClient({ config, labels = PHI_RECORD_WIDGET_DEFAU
|
|
|
190
187
|
* Every error here is the source's -- no binding, a resource that reads no single records, a read that
|
|
191
188
|
* failed -- and none of them is the reader's to fix, so it goes the way of every such failure.
|
|
192
189
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return _jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.Record, title: failure });
|
|
190
|
+
if (error) {
|
|
191
|
+
return _jsx(PhiWidgetFailure, { renderMode: renderMode, widgetType: PhiCmsWidgetType.Record, title: error });
|
|
196
192
|
}
|
|
197
193
|
if (!record) {
|
|
198
194
|
return _jsx(PhiEmptyControl, { description: labels.empty });
|
|
@@ -80,7 +80,7 @@ export declare const PHI_RESULT_WIDGET_DEFINITION: {
|
|
|
80
80
|
heading?: string;
|
|
81
81
|
} & {
|
|
82
82
|
type: "data-provider";
|
|
83
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
83
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
84
84
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
85
85
|
}) | ({
|
|
86
86
|
key: string;
|
|
@@ -96,7 +96,7 @@ export declare const PHI_SIMPLE_TEXT_WIDGET_DEFINITION: {
|
|
|
96
96
|
heading?: string;
|
|
97
97
|
} & {
|
|
98
98
|
type: "data-provider";
|
|
99
|
-
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind;
|
|
99
|
+
providerKind?: import("../../../../../types").PhiRuntimeDataProviderKind | readonly import("../../../../../types").PhiRuntimeDataProviderKind[];
|
|
100
100
|
providerKey?: import("@phis/contracts/controls").PhiRuntimeDataProviderKey;
|
|
101
101
|
}) | ({
|
|
102
102
|
key: string;
|