@phis/ui 0.7.8 → 0.8.0
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-address-control.d.ts +23 -0
- package/components/controls/phi-address-control.js +43 -0
- package/components/controls/phi-color-control.d.ts +3 -1
- package/components/controls/phi-color-control.js +2 -2
- package/components/controls/phi-country-select-control.d.ts +22 -0
- package/components/controls/phi-country-select-control.js +16 -0
- package/components/controls/phi-dialog-control.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.js +5 -3
- package/components/controls/phi-drawer-control.d.ts +7 -5
- package/components/controls/phi-float-button-control.d.ts +8 -1
- package/components/controls/phi-float-button-control.js +19 -3
- package/components/controls/phi-form-control.js +52 -8
- package/components/controls/phi-modal-control-adapter.d.ts +1 -1
- package/components/controls/phi-modal-control-adapter.js +14 -37
- package/components/controls/phi-modal-control.d.ts +5 -5
- package/components/controls/phi-options-provider.d.ts +1 -0
- package/components/controls/phi-options-provider.js +1 -0
- package/components/controls/phi-overlay-control-contract.d.ts +52 -17
- package/components/controls/phi-overlay-control-contract.js +55 -30
- package/components/controls/phi-reveal-once-dialog-control.d.ts +21 -0
- package/components/controls/phi-reveal-once-dialog-control.js +52 -0
- package/components/controls/phi-reveal-once-dialog-labels.d.ts +10 -0
- package/components/controls/phi-reveal-once-dialog-labels.js +5 -0
- package/components/forms/flags-field.d.ts +22 -0
- package/components/forms/flags-field.js +58 -0
- package/components/forms/form-option-flags.d.ts +20 -0
- package/components/forms/form-option-flags.js +38 -0
- package/components/forms/form-provider-contract.d.ts +23 -0
- package/components/forms/form-provider-contract.js +36 -0
- package/components/forms/form-provider-registry.d.ts +5 -1
- package/components/forms/shared-form-provider-registry.js +13 -0
- package/components/forms/structured-field-labels.d.ts +24 -0
- package/components/forms/structured-field-labels.js +43 -0
- package/components/forms/structured-form-field-controls.d.ts +12 -0
- package/components/forms/structured-form-field-controls.js +65 -0
- package/components/overlays/phi-overlay-container-client.js +2 -2
- package/components/regions/phi-cms-region-shell.js +2 -2
- package/components/regions/presets/content-entry-editor-page-tree.js +12 -3
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +6 -2
- package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
- package/components/root/phi-root-theme-resolver.js +3 -0
- package/components/shell/phi-antd-icon.d.ts +1 -8
- package/components/shell/phi-antd-icon.js +1 -227
- package/components/shell/phi-icon-names.d.ts +19 -0
- package/components/shell/phi-icon-names.js +264 -0
- package/components/shell/phi-icon.d.ts +2 -11
- package/components/shell/phi-icon.js +4 -32
- package/components/widgets/client/shared/phi-command-buttons.d.ts +13 -2
- package/components/widgets/client/shared/phi-command-buttons.js +10 -4
- package/components/widgets/client/shared/phi-rendered-value.js +27 -3
- package/components/widgets/client/shared/phi-table-provider-refusal.d.ts +13 -0
- package/components/widgets/client/shared/phi-table-provider-refusal.js +13 -0
- package/components/widgets/config/background.d.ts +3 -2
- package/components/widgets/config/choice-shared.d.ts +10 -1
- package/components/widgets/config/choice-shared.js +8 -2
- package/components/widgets/label-sets/admin-locales.js +1 -1
- package/components/widgets/label-sets/admin-users.d.ts +2 -5
- package/components/widgets/label-sets/admin-users.js +4 -10
- package/components/widgets/label-sets/effects.js +2 -4
- package/components/widgets/label-sets/profile.d.ts +13 -0
- package/components/widgets/label-sets/profile.js +28 -0
- package/components/widgets/label-sets/search-results.js +2 -4
- package/components/widgets/label-sets/table.js +9 -0
- package/components/widgets/label-types/effects.d.ts +3 -2
- package/components/widgets/label-types/effects.js +1 -2
- package/components/widgets/label-types/search-results.d.ts +2 -2
- package/components/widgets/label-types/search-results.js +1 -2
- package/components/widgets/label-types/table.d.ts +3 -0
- package/components/widgets/label-types/table.js +2 -0
- package/components/widgets/server/builder-chrome.d.ts +4 -1
- package/components/widgets/server/builder-chrome.js +2 -2
- package/components/widgets/shared/markdown-body-client.d.ts +26 -0
- package/components/widgets/shared/markdown-body-client.js +31 -1
- package/components/widgets/shared/markdown-render.d.ts +10 -2
- package/components/widgets/shared/markdown-render.js +35 -13
- package/constants/countries.d.ts +9 -0
- package/constants/countries.js +28 -0
- package/constants/customer-file.d.ts +25 -0
- package/constants/customer-file.js +26 -0
- package/constants/record-field-kinds.d.ts +15 -0
- package/constants/record-field-kinds.js +13 -0
- package/constants/runtime-module-ownership.js +12 -0
- package/constants/runtime-render-client-types.d.ts +5 -0
- package/constants/runtime-render-client-types.js +5 -0
- package/{plugins/runtime-modules/threads/controller/address.js → constants/threads-controller-address.js} +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +2 -0
- package/gateway/form-handler-request.d.ts +22 -0
- package/gateway/form-handler-request.js +40 -0
- package/gateway/label-set.d.ts +15 -2
- package/gateway/label-set.js +60 -22
- package/gateway/site-form-route.js +11 -2
- package/helpers/address-field.d.ts +43 -0
- package/helpers/address-field.js +68 -0
- package/helpers/cms-dialog.d.ts +5 -20
- package/helpers/cms-dialog.js +8 -13
- package/helpers/cms-page-catalog.d.ts +10 -0
- package/helpers/cms-page-catalog.js +19 -0
- package/helpers/cms-preset-nodes.d.ts +4 -4
- package/helpers/cms-preset-nodes.js +1 -1
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/country-names.d.ts +12 -0
- package/helpers/country-names.js +14 -0
- package/helpers/phi-metadata.d.ts +33 -1
- package/helpers/phi-metadata.js +62 -1
- package/helpers/preset-table-check.d.ts +34 -0
- package/helpers/preset-table-check.js +124 -0
- package/helpers/preset-text-source-check.d.ts +4 -1
- package/helpers/preset-text-source-check.js +6 -1
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +30 -5
- package/helpers/public-route-claims.d.ts +9 -1
- package/helpers/public-route-claims.js +23 -3
- package/helpers/record-fields.d.ts +1 -5
- package/helpers/record-fields.js +15 -6
- package/helpers/route-address-check.d.ts +22 -2
- package/helpers/route-address-check.js +29 -8
- package/helpers/site-address-row.d.ts +23 -0
- package/helpers/site-address-row.js +36 -0
- package/helpers/surface-style.d.ts +8 -1
- package/helpers/surface-style.js +12 -2
- package/helpers/thread-inbox-row.d.ts +20 -0
- package/helpers/thread-inbox-row.js +26 -0
- package/helpers/translation-format.d.ts +26 -0
- package/helpers/translation-format.js +31 -0
- package/module-labels.d.ts +1 -1
- package/module-labels.js +1 -1
- package/module-page-check.d.ts +1 -0
- package/module-page-check.js +1 -0
- package/module-records.d.ts +2 -2
- package/module-records.js +1 -0
- package/next/area-route.js +34 -1
- package/next/root-route.js +4 -5
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/customer-file-access.d.ts +11 -0
- package/plugins/runtime-modules/accounting/customer-file-access.js +12 -0
- package/plugins/runtime-modules/accounting/data-providers.js +1 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +11 -0
- package/plugins/runtime-modules/accounting/ids.js +23 -0
- package/plugins/runtime-modules/accounting/presets.js +32 -5
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +66 -0
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +122 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +2 -2
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +26 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +381 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +4 -0
- package/plugins/runtime-modules/app/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/app/client-data-providers.js +9 -0
- package/plugins/runtime-modules/app/data-providers.d.ts +98 -0
- package/plugins/runtime-modules/app/data-providers.js +80 -0
- package/plugins/runtime-modules/app/definition.d.ts +131 -0
- package/plugins/runtime-modules/app/definition.js +2 -0
- package/plugins/runtime-modules/app/forms.d.ts +46 -1
- package/plugins/runtime-modules/app/forms.js +195 -1
- package/plugins/runtime-modules/app/ids.d.ts +7 -0
- package/plugins/runtime-modules/app/ids.js +8 -0
- package/plugins/runtime-modules/app/module.d.ts +131 -0
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +135 -0
- package/plugins/runtime-modules/app/services/addresses-table.js +101 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +17 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +179 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +62 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +108 -0
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +27 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +1 -0
- package/plugins/runtime-modules/app/trees/profile-label-set.js +3 -0
- package/plugins/runtime-modules/asset/presets.d.ts +4 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -2
- package/plugins/runtime-modules/auth/widgets/logout/client.d.ts +1 -1
- package/plugins/runtime-modules/auth/widgets/logout/client.js +2 -2
- package/plugins/runtime-modules/auth/widgets/security/client.d.ts +5 -1
- package/plugins/runtime-modules/auth/widgets/security/client.js +12 -10
- package/plugins/runtime-modules/avatar/overlay-tree.server.js +1 -1
- package/plugins/runtime-modules/blog/presets.d.ts +4 -0
- package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +2 -1
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -2
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.d.ts +23 -0
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.js +38 -0
- package/plugins/runtime-modules/builder/clients/mode-switch.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/mode-switch.js +2 -15
- package/plugins/runtime-modules/builder/clients/pages-workspace.js +2 -0
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +2 -1
- package/plugins/runtime-modules/builder/controller/draft-status-controller.js +28 -1
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +5 -0
- package/plugins/runtime-modules/builder/page-presets.server.d.ts +7 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +10 -1
- package/plugins/runtime-modules/builder/persistence.js +4 -0
- package/plugins/runtime-modules/builder/public-route-collisions.js +8 -3
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +33 -6
- package/plugins/runtime-modules/builder/widgets/chrome/config.d.ts +6 -4
- package/plugins/runtime-modules/builder/widgets/chrome/config.js +11 -1
- package/plugins/runtime-modules/builder/widgets/inspector-header/authoring.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/mode-switch/plugin.js +1 -1
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +2 -2
- package/plugins/runtime-modules/client-manifests/app.js +3 -0
- package/plugins/runtime-modules/client-manifests/builder.js +10 -0
- package/plugins/runtime-modules/content-entry-routes.d.ts +4 -0
- package/plugins/runtime-modules/contracts.js +31 -1
- package/plugins/runtime-modules/core/definition.d.ts +23 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +23 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +0 -17
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +2 -23
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/client.js +3 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +316 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.js +4 -4
- package/plugins/runtime-modules/core/widgets/dimension/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/client.js +4 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +326 -3
- package/plugins/runtime-modules/core/widgets/float-button/config.js +5 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/length/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
- package/plugins/runtime-modules/core/widgets/markdown/server.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/markdown/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.d.ts +12 -0
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.js +68 -0
- package/plugins/runtime-modules/core/widgets/number-input/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +2 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +20 -5
- package/plugins/runtime-modules/core/widgets/table/config.js +6 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.d.ts +17 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.js +33 -0
- package/plugins/runtime-modules/dashboard/trees/dashboard-cards-page-tree.js +3 -1
- package/plugins/runtime-modules/descriptor-compiler.d.ts +19 -3
- package/plugins/runtime-modules/descriptor-compiler.js +44 -16
- package/plugins/runtime-modules/editor/presets.d.ts +4 -0
- package/plugins/runtime-modules/editor/trees/phi-default-editor-releases-page-tree.js +3 -1
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/localization/presets.d.ts +4 -0
- package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -1
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +4 -2
- package/plugins/runtime-modules/news/presets.d.ts +4 -0
- package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +6 -2
- package/plugins/runtime-modules/resolver.js +17 -0
- package/plugins/runtime-modules/revisions/controller/client.js +13 -11
- package/plugins/runtime-modules/revisions/controller/draft-context-target.d.ts +25 -0
- package/plugins/runtime-modules/revisions/controller/draft-context-target.js +33 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +4 -0
- package/plugins/runtime-modules/revisions/services/table.js +13 -4
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -1
- package/plugins/runtime-modules/search/widgets/search-results/client.js +4 -2
- package/plugins/runtime-modules/theme/presets.d.ts +4 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +76 -4
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +3 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +2 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +19 -7
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/definition.js +1 -1
- package/plugins/runtime-modules/threads/data-providers.d.ts +115 -2
- package/plugins/runtime-modules/threads/data-providers.js +85 -0
- package/plugins/runtime-modules/threads/definition.d.ts +115 -2
- package/plugins/runtime-modules/threads/definition.js +1 -1
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +3 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +192 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.js +164 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +5 -3
- package/plugins/runtime-modules/user-management/client-data-providers.js +5 -0
- package/plugins/runtime-modules/user-management/data-providers.d.ts +159 -0
- package/plugins/runtime-modules/user-management/data-providers.js +101 -3
- package/plugins/runtime-modules/user-management/definition.d.ts +159 -0
- package/plugins/runtime-modules/user-management/ids.d.ts +9 -0
- package/plugins/runtime-modules/user-management/ids.js +9 -0
- package/plugins/runtime-modules/user-management/presets.js +17 -1
- package/plugins/runtime-modules/user-management/services/users-access-table.d.ts +378 -0
- package/plugins/runtime-modules/user-management/services/users-access-table.js +132 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +86 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +118 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.d.ts +20 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +166 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +19 -18
- package/server-helpers/cms-page-record.d.ts +9 -1
- package/server-helpers/cms-page-record.js +11 -1
- package/server-helpers/cms-request.js +8 -5
- package/server-helpers/link-preview-image.d.ts +30 -0
- package/server-helpers/link-preview-image.js +57 -0
- package/server-helpers/search-text.js +3 -0
- package/server-helpers.d.ts +1 -1
- package/server-helpers.js +1 -1
- package/styles/shell.css +30 -6
- package/theme/phi-theme-composition.js +9 -0
- package/theme/phi-theme-inverse-ground.d.ts +39 -0
- package/theme/phi-theme-inverse-ground.js +103 -0
- package/theme/phi-theme-tokens.d.ts +2 -1
- package/theme/phi-theme-tokens.js +2 -0
- package/types/cms-module-descriptors.d.ts +14 -0
- package/types/cms-overlay.d.ts +13 -6
- package/types/cms-overlay.js +6 -22
- package/types/cms-plugins.d.ts +14 -2
- package/types/cms.d.ts +10 -0
- package/types/core-widget-placements.d.ts +3 -3
- package/types/link-preview.d.ts +19 -0
- package/types/link-preview.js +19 -0
- package/types/record-provider.d.ts +22 -1
- package/types/site-theme.d.ts +27 -0
- package/types/table-embed.d.ts +48 -0
- package/types/table-embed.js +1 -0
- package/types/table-widget.d.ts +14 -0
- package/types/widget-runtime.d.ts +3 -0
- package/types.d.ts +1 -0
- /package/{plugins/runtime-modules/threads/controller/address.d.ts → constants/threads-controller-address.d.ts} +0 -0
|
@@ -5,3 +5,16 @@
|
|
|
5
5
|
export const PHI_RECORD_FIELD_KINDS = [
|
|
6
6
|
"text", "markdown", "picture", "pictures", "list", "tag", "date", "number", "money", "link",
|
|
7
7
|
];
|
|
8
|
+
/**
|
|
9
|
+
* The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
|
|
10
|
+
* page's language (`formatPhiRecordFieldText`, `helpers/record-fields.ts`).
|
|
11
|
+
*/
|
|
12
|
+
export const PHI_RECORD_TEXT_FIELD_KINDS = ["text", "number", "date", "money"];
|
|
13
|
+
/**
|
|
14
|
+
* Bits of a `markdown` field's `flags` (`PhiRecordMarkdown`). `Translated`: the text already is in the
|
|
15
|
+
* page's language, a person's translation, and is drawn as written; without it the text is source text in
|
|
16
|
+
* its `sourceLocale`, and the Markdown Widget translates it (TRANSLATIONS.md, "The Markdown unit format").
|
|
17
|
+
*/
|
|
18
|
+
export const PhiRecordMarkdownFlag = { Translated: 1 << 0 };
|
|
19
|
+
/** Every bit `PhiRecordMarkdownFlag` names; `flags` with any other bit make no markdown field. */
|
|
20
|
+
export const PHI_RECORD_MARKDOWN_KNOWN_FLAGS = PhiRecordMarkdownFlag.Translated;
|
|
@@ -50,6 +50,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
50
50
|
"form-field/media-asset": ["asset", "media-asset"],
|
|
51
51
|
"form-field/media-assets": ["asset", "media-assets"],
|
|
52
52
|
"form-field/money": ["core", "money"],
|
|
53
|
+
"form-field/country": ["core", "country"],
|
|
54
|
+
"form-field/address": ["core", "address"],
|
|
55
|
+
"form-field/flags": ["core", "flags"],
|
|
53
56
|
"form-field/multi-select": ["core", "multi-select"],
|
|
54
57
|
"form-field/number": ["core", "number"],
|
|
55
58
|
"form-field/password": ["core", "password"],
|
|
@@ -68,6 +71,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
68
71
|
"form-field/url": ["core", "url"],
|
|
69
72
|
"form-handler/admin-settings-general": ["admin", "settings-general"],
|
|
70
73
|
"form-handler/app-profile-name": ["app", "profile-name"],
|
|
74
|
+
"form-handler/app-profile-phone": ["app", "profile-phone"],
|
|
75
|
+
"form-handler/app-address-create": ["app", "address-create"],
|
|
76
|
+
"form-handler/app-address-edit": ["app", "address-edit"],
|
|
71
77
|
"form-handler/app-profile-locale": ["app", "profile-locale"],
|
|
72
78
|
"form-handler/app-profile-newsletter": ["app", "profile-newsletter"],
|
|
73
79
|
"form-handler/app-profile-theme": ["app", "profile-theme"],
|
|
@@ -122,6 +128,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
122
128
|
"form-validation/url": ["core", "url"],
|
|
123
129
|
"forms/admin/settings-general": ["admin", "settings-general"],
|
|
124
130
|
"forms/app/profile-name": ["app", "profile-name"],
|
|
131
|
+
"forms/app/profile-phone": ["app", "profile-phone"],
|
|
132
|
+
"forms/app/address-create": ["app", "address-create"],
|
|
133
|
+
"forms/app/address-edit": ["app", "address-edit"],
|
|
125
134
|
"forms/app/profile-locale": ["app", "profile-locale"],
|
|
126
135
|
"forms/app/profile-newsletter": ["app", "profile-newsletter"],
|
|
127
136
|
"forms/app/profile-theme": ["app", "profile-theme"],
|
|
@@ -203,6 +212,8 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
203
212
|
"options/theme-presets": ["theme", "presets"],
|
|
204
213
|
"options/translation-contexts": ["localization", "translation-contexts"],
|
|
205
214
|
"tables/auth-installations": ["auth", "installations"],
|
|
215
|
+
"tables/threads-customer-file": ["threads", "customer-file"],
|
|
216
|
+
"tables/app-addresses": ["app", "addresses"],
|
|
206
217
|
"signals/auth-workflow-state": ["auth", "workflow-state"],
|
|
207
218
|
"signals/background-config": ["core", "background-config"],
|
|
208
219
|
"signals/border-config": ["core", "border-config"],
|
|
@@ -276,6 +287,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
276
287
|
"tables/revisions": ["revisions", "revisions"],
|
|
277
288
|
"tables/thread-inbox": ["core", "thread-inbox"],
|
|
278
289
|
"tables/user-management": ["user-management", "user-management"],
|
|
290
|
+
"tables/user-management-users-access": ["user-management", "users-access"],
|
|
279
291
|
"trees/builder-page-source": ["builder", "page-source"],
|
|
280
292
|
// Video providers the Video Module ships. An add-on contributes its own under its own package.
|
|
281
293
|
"video-providers/vimeo": ["video", "vimeo"],
|
|
@@ -5,6 +5,11 @@ export declare const PhiRuntimeRenderClientType: {
|
|
|
5
5
|
readonly AuthWorkflow: "@phis/ui/modules/auth/controller/default#workflow";
|
|
6
6
|
readonly AccountPreview: `${string}#preview`;
|
|
7
7
|
readonly BuilderModeSwitch: `${string}#builder-mode`;
|
|
8
|
+
readonly BuilderBrandThemeControls: "@phis/ui/modules/theme/widgets/brand-controls#theme";
|
|
9
|
+
readonly BuilderBrandThemePreview: "@phis/ui/modules/theme/widgets/brand-controls#preview";
|
|
10
|
+
readonly BuilderBrandStyleControls: "@phis/ui/modules/theme/widgets/brand-controls#style";
|
|
11
|
+
readonly BuilderBrandBackgroundControls: "@phis/ui/modules/theme/widgets/brand-controls#background";
|
|
12
|
+
readonly BuilderBrandIdentityControls: "@phis/ui/modules/theme/widgets/brand-controls#identity";
|
|
8
13
|
readonly SearchStandalone: "@phis/ui/controls/search";
|
|
9
14
|
readonly SidebarNavigationPreview: `${string}#preview`;
|
|
10
15
|
readonly BaseLayout: "@phis/ui/modules/core/layouts/base#client";
|
|
@@ -7,6 +7,11 @@ export const PhiRuntimeRenderClientType = {
|
|
|
7
7
|
AuthWorkflow: "@phis/ui/modules/auth/controller/default#workflow",
|
|
8
8
|
AccountPreview: `${PhiCmsWidgetType.Account}#preview`,
|
|
9
9
|
BuilderModeSwitch: `${PhiCmsWidgetType.Switch}#builder-mode`,
|
|
10
|
+
BuilderBrandThemeControls: "@phis/ui/modules/theme/widgets/brand-controls#theme",
|
|
11
|
+
BuilderBrandThemePreview: "@phis/ui/modules/theme/widgets/brand-controls#preview",
|
|
12
|
+
BuilderBrandStyleControls: "@phis/ui/modules/theme/widgets/brand-controls#style",
|
|
13
|
+
BuilderBrandBackgroundControls: "@phis/ui/modules/theme/widgets/brand-controls#background",
|
|
14
|
+
BuilderBrandIdentityControls: "@phis/ui/modules/theme/widgets/brand-controls#identity",
|
|
10
15
|
SearchStandalone: "@phis/ui/controls/search",
|
|
11
16
|
SidebarNavigationPreview: `${PhiCmsWidgetType.SidebarNavigation}#preview`,
|
|
12
17
|
BaseLayout: `${PHI_CMS_LAYOUT_PLUGIN_KEYS.core}/base#client`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PHI_SHARED_PACKAGE_NAME, createPhiControllerSignalAddress } from "
|
|
1
|
+
import { PHI_SHARED_PACKAGE_NAME, createPhiControllerSignalAddress } from "../types/signals";
|
|
2
2
|
export const PHI_THREADS_CONTROLLER_PLUGIN_KEY = `${PHI_SHARED_PACKAGE_NAME}/modules/threads/controller`;
|
|
3
3
|
export const PHI_THREADS_CONTROLLER_KEY = "default";
|
|
4
4
|
export const PHI_THREADS_CONTROLLER_TYPE = `${PHI_THREADS_CONTROLLER_PLUGIN_KEY}/${PHI_THREADS_CONTROLLER_KEY}`;
|
package/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { buildPhiCmsWidgetNamespacedTypeKey, splitPhiCmsWidgetNamespacedTypeKey,
|
|
|
5
5
|
export * from "./constants/cms-plugin-categories";
|
|
6
6
|
export * from "./constants/runtime-module-categories";
|
|
7
7
|
export { PHI_THREAD_LIBRARY_DATA_PROVIDER_KEYS } from "./constants/thread-library-provider-keys";
|
|
8
|
+
export { PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS, PHI_CUSTOMER_FILE_RESOURCE_KEYS, PHI_CUSTOMER_FILE_SUBJECT_PARAM, } from "./constants/customer-file";
|
|
8
9
|
export { PHIS_AREA_HEADER, PHIS_FORM_RELAY_HEADER, PHIS_REQUEST_PATH_HEADER, PHIS_REQUEST_SEARCH_HEADER, PHIS_SITE_KEY_HEADER, PHIS_TOKEN_HEADER, } from "./constants/http-headers";
|
|
9
10
|
export { buildPhiFontSubsetDeliveryUrl, buildPhiImageAssetVariantDeliveryUrl, buildPhiMediaAssetContentDeliveryUrl, isPhiMediaAssetOriginalOptimizable, isPhiMediaAssetPublic, isPhiMediaSvgContentType, normalizePhiImageAssetVariantKey, normalizePhiMediaKind, PhiImageAssetVariantKey, PhiImageAssetVariantKeyName, type PhiImageAssetVariantSpec, type PhiMediaAssetFlag, PhiMediaAssetFlags, PhiMediaDeliveryPolicy, PhiMediaFolderFlags, PhiMediaKind, PhiMediaLifecycleStatus, resolvePhiImageAssetVariantKeyName, resolvePhiImageAssetVariantSpec, resolvePhiMediaKindFromContentType, } from "./constants/media";
|
|
10
11
|
export * from "./constants/support";
|
package/constants.js
CHANGED
|
@@ -6,6 +6,8 @@ export * from "./constants/cms-plugin-categories";
|
|
|
6
6
|
export * from "./constants/runtime-module-categories";
|
|
7
7
|
// The conversations a viewer is in, for every Module that lists its own kind of them (`fixedFilters`).
|
|
8
8
|
export { PHI_THREAD_LIBRARY_DATA_PROVIDER_KEYS } from "./constants/thread-library-provider-keys";
|
|
9
|
+
// Staff's customer file on one member, for a Module's own file Page over the same Core route (THREADS.md, 10).
|
|
10
|
+
export { PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS, PHI_CUSTOMER_FILE_RESOURCE_KEYS, PHI_CUSTOMER_FILE_SUBJECT_PARAM, } from "./constants/customer-file";
|
|
9
11
|
export { PHIS_AREA_HEADER, PHIS_FORM_RELAY_HEADER, PHIS_REQUEST_PATH_HEADER, PHIS_REQUEST_SEARCH_HEADER, PHIS_SITE_KEY_HEADER, PHIS_TOKEN_HEADER, } from "./constants/http-headers";
|
|
10
12
|
export { buildPhiFontSubsetDeliveryUrl, buildPhiImageAssetVariantDeliveryUrl, buildPhiMediaAssetContentDeliveryUrl, isPhiMediaAssetOriginalOptimizable, isPhiMediaAssetPublic, isPhiMediaSvgContentType, normalizePhiImageAssetVariantKey, normalizePhiMediaKind, PhiImageAssetVariantKey, PhiImageAssetVariantKeyName, PhiMediaAssetFlags, PhiMediaDeliveryPolicy, PhiMediaFolderFlags, PhiMediaKind, PhiMediaLifecycleStatus, resolvePhiImageAssetVariantKeyName, resolvePhiImageAssetVariantSpec, resolvePhiMediaKindFromContentType, } from "./constants/media";
|
|
11
13
|
export * from "./constants/support";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The field keys a handler's `upstreamPath` names as `{key}` segments, in order. */
|
|
2
|
+
export declare function readPhiFormHandlerPathKeys(upstreamPath: string): string[];
|
|
3
|
+
/**
|
|
4
|
+
* Why a handler's `upstreamPath` cannot be filled, or null: a field named in two `{key}` segments would
|
|
5
|
+
* leave the relay two places for one value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readPhiFormHandlerPathError(upstreamPath: string | null): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The request a relayed submit makes (FORMS.md, "Request shape"): the path's `{key}` segments filled with
|
|
10
|
+
* those fields' values, percent-encoded, and those fields left out of the body, which is every other value
|
|
11
|
+
* as the Form holds it. A path value that is empty or no text or number refuses the submit: an address
|
|
12
|
+
* without it is another route.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shapePhiFormHandlerRequest(input: {
|
|
15
|
+
upstreamPath: string;
|
|
16
|
+
values: unknown;
|
|
17
|
+
}): {
|
|
18
|
+
path: string;
|
|
19
|
+
body: Record<string, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isPhiRecord } from "../helpers/is-record";
|
|
2
|
+
const PATH_PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9_]*)\}/gu;
|
|
3
|
+
/** The field keys a handler's `upstreamPath` names as `{key}` segments, in order. */
|
|
4
|
+
export function readPhiFormHandlerPathKeys(upstreamPath) {
|
|
5
|
+
return [...upstreamPath.matchAll(PATH_PLACEHOLDER)].map((match) => match[1]);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Why a handler's `upstreamPath` cannot be filled, or null: a field named in two `{key}` segments would
|
|
9
|
+
* leave the relay two places for one value.
|
|
10
|
+
*/
|
|
11
|
+
export function readPhiFormHandlerPathError(upstreamPath) {
|
|
12
|
+
const named = new Set();
|
|
13
|
+
for (const key of upstreamPath ? readPhiFormHandlerPathKeys(upstreamPath) : []) {
|
|
14
|
+
if (named.has(key))
|
|
15
|
+
return `field "${key}" is named more than once`;
|
|
16
|
+
named.add(key);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The request a relayed submit makes (FORMS.md, "Request shape"): the path's `{key}` segments filled with
|
|
22
|
+
* those fields' values, percent-encoded, and those fields left out of the body, which is every other value
|
|
23
|
+
* as the Form holds it. A path value that is empty or no text or number refuses the submit: an address
|
|
24
|
+
* without it is another route.
|
|
25
|
+
*/
|
|
26
|
+
export function shapePhiFormHandlerRequest(input) {
|
|
27
|
+
const values = isPhiRecord(input.values) ? { ...input.values } : {};
|
|
28
|
+
let missing = null;
|
|
29
|
+
const path = input.upstreamPath.replace(PATH_PLACEHOLDER, (_segment, key) => {
|
|
30
|
+
const value = values[key];
|
|
31
|
+
delete values[key];
|
|
32
|
+
const text = typeof value === "number" && Number.isFinite(value) ? String(value) : typeof value === "string" ? value.trim() : "";
|
|
33
|
+
if (!text)
|
|
34
|
+
missing ??= key;
|
|
35
|
+
return encodeURIComponent(text);
|
|
36
|
+
});
|
|
37
|
+
if (missing)
|
|
38
|
+
return { error: `The form has no value for "${missing}", which the address of its handler needs.` };
|
|
39
|
+
return { path, body: values };
|
|
40
|
+
}
|
package/gateway/label-set.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { type PhiGlobalTranslatorOptions } from "./tr";
|
|
3
|
+
import { type PhiCountLabel } from "../helpers/translation-format";
|
|
3
4
|
import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
4
5
|
/**
|
|
5
6
|
* One label, and optionally the register it is written in.
|
|
@@ -12,6 +13,16 @@ import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
|
12
13
|
export type PhiLabelSetEntry = string | {
|
|
13
14
|
text: string;
|
|
14
15
|
ctx: string;
|
|
16
|
+
} | PhiLabelSetCountEntry;
|
|
17
|
+
/**
|
|
18
|
+
* A label that says a count: one template per plural category, `other` required (TRANSLATIONS.md,
|
|
19
|
+
* "Count labels"). It reads back as a `PhiCountLabel` and is formatted with `formatPhiCountLabel`, never
|
|
20
|
+
* by a Widget's own `count === 1` branch. `ctx` names its register as a `{ text, ctx }` entry does;
|
|
21
|
+
* absent, it takes the set's.
|
|
22
|
+
*/
|
|
23
|
+
export type PhiLabelSetCountEntry = {
|
|
24
|
+
count: PhiCountLabel;
|
|
25
|
+
ctx?: string;
|
|
15
26
|
};
|
|
16
27
|
export type PhiLabelSetLabels = Record<string, PhiLabelSetEntry>;
|
|
17
28
|
/**
|
|
@@ -21,9 +32,11 @@ export type PhiLabelSetLabels = Record<string, PhiLabelSetEntry>;
|
|
|
21
32
|
* thing in the width of the text itself. Any other register is still written as the plain object.
|
|
22
33
|
*/
|
|
23
34
|
export declare function definePhiMessageLabel(text: string): PhiLabelSetEntry;
|
|
24
|
-
/**
|
|
35
|
+
/** A count label, `{ one: "%1 page", other: "%1 pages" }`, in the set's register unless `ctx` names another. */
|
|
36
|
+
export declare function definePhiCountLabel(count: PhiCountLabel, ctx?: string): PhiLabelSetCountEntry;
|
|
37
|
+
/** What a set reads as once translated: the same keys, plain text, and a count label for a count label. */
|
|
25
38
|
export type PhiLabelSetTexts<TLabels extends PhiLabelSetLabels> = {
|
|
26
|
-
[K in keyof TLabels]: string;
|
|
39
|
+
[K in keyof TLabels]: TLabels[K] extends PhiLabelSetCountEntry ? PhiCountLabel : string;
|
|
27
40
|
};
|
|
28
41
|
export type PhiLabelSetDefinition<TLabels extends PhiLabelSetLabels> = {
|
|
29
42
|
key: string;
|
package/gateway/label-set.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { createGlobalTranslator, PHI_TR_CTX_WEB_UI_MESSAGE, } from "./tr";
|
|
3
3
|
import { PHI_CANONICAL_SOURCE_LOCALE, isPhiLocaleReadableAsSource, resolvePhiTranslationLocale, } from "../helpers/locale";
|
|
4
|
+
import { PHI_PLURAL_CATEGORIES, } from "../helpers/translation-format";
|
|
4
5
|
import { resolvePhiRuntimeModuleSourceLocale } from "../types/runtime-module-locale";
|
|
5
6
|
/**
|
|
6
7
|
* One label that is a sentence rather than a caption, in a set that is otherwise captions.
|
|
@@ -11,10 +12,48 @@ import { resolvePhiRuntimeModuleSourceLocale } from "../types/runtime-module-loc
|
|
|
11
12
|
export function definePhiMessageLabel(text) {
|
|
12
13
|
return { text, ctx: PHI_TR_CTX_WEB_UI_MESSAGE };
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/** A count label, `{ one: "%1 page", other: "%1 pages" }`, in the set's register unless `ctx` names another. */
|
|
16
|
+
export function definePhiCountLabel(count, ctx) {
|
|
17
|
+
return ctx === undefined ? { count } : { count, ctx };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The register a count label's category is translated in: the label's own, saying which form it is. The
|
|
21
|
+
* category belongs to the translation's identity because English often writes two forms alike -- "%1
|
|
22
|
+
* configured" is `one` and `other` both -- where a translator's language does not; under the bare register
|
|
23
|
+
* they would be one message with one answer. It also tells the translator which form to write.
|
|
24
|
+
*/
|
|
25
|
+
function readCountCategoryContext(ctx, category) {
|
|
26
|
+
return `${ctx}, plural category ${category}`;
|
|
27
|
+
}
|
|
28
|
+
function readLabelSetUnits(key, entry, setContext) {
|
|
29
|
+
if (typeof entry === "string") {
|
|
30
|
+
return [{ key, category: null, text: entry, ctx: setContext }];
|
|
31
|
+
}
|
|
32
|
+
if ("count" in entry) {
|
|
33
|
+
const ctx = entry.ctx ?? setContext;
|
|
34
|
+
return PHI_PLURAL_CATEGORIES.flatMap((category) => {
|
|
35
|
+
const text = entry.count[category];
|
|
36
|
+
return text === undefined
|
|
37
|
+
? []
|
|
38
|
+
: [{ key, category, text, ctx: readCountCategoryContext(ctx, category) }];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return [{ key, category: null, text: entry.text, ctx: entry.ctx }];
|
|
42
|
+
}
|
|
43
|
+
/** The units read back into the set's shape: a label's text, or a count label's categories. */
|
|
44
|
+
function assembleLabelSetTexts(units, readText) {
|
|
45
|
+
const labels = {};
|
|
46
|
+
units.forEach((unit, index) => {
|
|
47
|
+
const text = readText(unit, index);
|
|
48
|
+
if (unit.category === null) {
|
|
49
|
+
labels[unit.key] = text;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const count = (labels[unit.key] ?? {});
|
|
53
|
+
count[unit.category] = text;
|
|
54
|
+
labels[unit.key] = count;
|
|
55
|
+
});
|
|
56
|
+
return labels;
|
|
18
57
|
}
|
|
19
58
|
export function definePhiLabelSet(definition) {
|
|
20
59
|
return definition;
|
|
@@ -34,34 +73,33 @@ export function definePhiRuntimeModuleLabelSet(moduleDefinition, definition) {
|
|
|
34
73
|
export async function getPhiLabelSet(options, definition) {
|
|
35
74
|
const sourceLocale = resolvePhiTranslationLocale(definition.sourceLocale ?? options.sourceLocale ?? PHI_CANONICAL_SOURCE_LOCALE);
|
|
36
75
|
const targetLocale = resolvePhiTranslationLocale(options.locale);
|
|
37
|
-
const
|
|
38
|
-
.
|
|
76
|
+
const units = Object.entries(definition.labels)
|
|
77
|
+
.flatMap(([key, value]) => readLabelSetUnits(key, value, definition.ctx));
|
|
39
78
|
if (isPhiLocaleReadableAsSource(targetLocale, sourceLocale)) {
|
|
40
|
-
|
|
41
|
-
return labels;
|
|
79
|
+
return assembleLabelSetTexts(units, (unit) => unit.text);
|
|
42
80
|
}
|
|
43
81
|
/*
|
|
44
82
|
* One request per register rather than one per label: a set is nearly all one register, so this is
|
|
45
83
|
* the same single batch it always was plus one more for the handful of entries that are a sentence
|
|
46
|
-
* rather than a caption
|
|
84
|
+
* rather than a caption, and one per plural category a count label states. The batches run together,
|
|
85
|
+
* and each keeps its own translation identity; each answer goes back to its unit by position.
|
|
47
86
|
*/
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const group =
|
|
51
|
-
group.push(
|
|
52
|
-
|
|
53
|
-
}
|
|
87
|
+
const unitsByContext = new Map();
|
|
88
|
+
units.forEach((unit, index) => {
|
|
89
|
+
const group = unitsByContext.get(unit.ctx) ?? [];
|
|
90
|
+
group.push(index);
|
|
91
|
+
unitsByContext.set(unit.ctx, group);
|
|
92
|
+
});
|
|
54
93
|
const translator = createGlobalTranslator({ ...options, sourceLocale });
|
|
55
|
-
const
|
|
56
|
-
await Promise.all([...
|
|
57
|
-
const translated = await translator.trBulk(group.map((
|
|
94
|
+
const translatedByUnit = [];
|
|
95
|
+
await Promise.all([...unitsByContext].map(async ([context, group]) => {
|
|
96
|
+
const translated = await translator.trBulk(group.map((index) => units[index].text), context);
|
|
58
97
|
if (translated.length !== group.length) {
|
|
59
98
|
throw new Error(`Label set length mismatch for "${definition.key}".`);
|
|
60
99
|
}
|
|
61
|
-
group.forEach((
|
|
62
|
-
|
|
100
|
+
group.forEach((unitIndex, index) => {
|
|
101
|
+
translatedByUnit[unitIndex] = translated[index];
|
|
63
102
|
});
|
|
64
103
|
}));
|
|
65
|
-
|
|
66
|
-
return labels;
|
|
104
|
+
return assembleLabelSetTexts(units, (unit, index) => translatedByUnit[index] ?? unit.text);
|
|
67
105
|
}
|
|
@@ -2,6 +2,7 @@ import { buildPhiFormSubmitRouteFromHandlerProvider, resolvePhiFormSubmitTarget,
|
|
|
2
2
|
import { resolvePhiServerFormHandler } from "./form-handler-resolution";
|
|
3
3
|
import { PHIS_FORM_RELAY_HEADER, PHIS_SITE_KEY_HEADER } from "../constants/http-headers";
|
|
4
4
|
import { isPhiRecord } from "../helpers/is-record";
|
|
5
|
+
import { shapePhiFormHandlerRequest } from "./form-handler-request";
|
|
5
6
|
const PHI_SITE_SESSION_COOKIE_NAME = "phis_session";
|
|
6
7
|
const PHI_AUTH_LINK_COOKIE_NAME = "phis_auth_link";
|
|
7
8
|
/** Core's double-submit pair: the cookie `/api/auth/csrf` sets and the header that repeats it. */
|
|
@@ -264,10 +265,18 @@ export function buildPhiSiteFormRouteHandlers({ upstreamBaseUrl, buildHeaders, t
|
|
|
264
265
|
proxyHeaders.set(PHI_CSRF_HEADER_NAME, csrfToken);
|
|
265
266
|
appendCookieHeader(proxyHeaders, `${PHI_CSRF_COOKIE_NAME}=${csrfToken}`);
|
|
266
267
|
}
|
|
267
|
-
|
|
268
|
+
// The values as the handler's route takes them: its path's `{key}` segments filled.
|
|
269
|
+
const shaped = shapePhiFormHandlerRequest({
|
|
270
|
+
upstreamPath: target.upstreamPath ?? "",
|
|
271
|
+
values: body.values,
|
|
272
|
+
});
|
|
273
|
+
if ("error" in shaped) {
|
|
274
|
+
return toJsonResponse({ ok: false, error: shaped.error }, 400);
|
|
275
|
+
}
|
|
276
|
+
const upstreamResponse = await fetch(`${upstreamBaseUrl}${shaped.path}`, {
|
|
268
277
|
method: descriptor.method,
|
|
269
278
|
headers: headersToPlainObject(proxyHeaders),
|
|
270
|
-
body: JSON.stringify(body
|
|
279
|
+
body: JSON.stringify(shaped.body),
|
|
271
280
|
cache: "no-store",
|
|
272
281
|
signal: AbortSignal.timeout(timeoutMs),
|
|
273
282
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PhisSiteAddressInput } from "@phis/contracts/users";
|
|
2
|
+
/** The parts of an address a person writes (`PhisSiteAddressInput`), in the order the `address` field asks them. */
|
|
3
|
+
export declare const PHI_ADDRESS_PARTS: readonly ["name", "companyName", "line1", "line2", "postalCode", "city", "region", "country"];
|
|
4
|
+
export type PhiAddressPart = (typeof PHI_ADDRESS_PARTS)[number];
|
|
5
|
+
/** The parts Core refuses an address without (phis-server `readPhisSiteAddressInput`). */
|
|
6
|
+
export declare const PHI_ADDRESS_REQUIRED_PARTS: readonly ["name", "line1", "city", "country"];
|
|
7
|
+
/** The widths of `phis.site_addresses` Core holds each text part to; the country is a code. */
|
|
8
|
+
export declare const PHI_ADDRESS_PART_MAX_LENGTHS: {
|
|
9
|
+
readonly companyName: 256;
|
|
10
|
+
readonly name: 256;
|
|
11
|
+
readonly line1: 256;
|
|
12
|
+
readonly line2: 256;
|
|
13
|
+
readonly postalCode: 32;
|
|
14
|
+
readonly city: 128;
|
|
15
|
+
readonly region: 128;
|
|
16
|
+
};
|
|
17
|
+
type PhiAddressTextPart = keyof typeof PHI_ADDRESS_PART_MAX_LENGTHS;
|
|
18
|
+
/**
|
|
19
|
+
* The `address` field's value as a Form holds it: every part of `PhisSiteAddressInput`, an empty optional
|
|
20
|
+
* part `null`, an empty required part `""`. Read leniently -- it is what somebody is typing -- and never
|
|
21
|
+
* thrown on; whether it can be sent is `findPhiAddressProblems`'s answer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readPhiAddressFieldValue(value: unknown): PhisSiteAddressInput;
|
|
24
|
+
/** The value a part change makes: the part written, an empty optional part `null` again. */
|
|
25
|
+
export declare function writePhiAddressFieldPart(value: PhisSiteAddressInput, part: PhiAddressPart, next: string | null): PhisSiteAddressInput;
|
|
26
|
+
export type PhiAddressProblem = {
|
|
27
|
+
part: PhiAddressPart;
|
|
28
|
+
kind: "required";
|
|
29
|
+
} | {
|
|
30
|
+
part: PhiAddressTextPart;
|
|
31
|
+
kind: "tooLong";
|
|
32
|
+
max: number;
|
|
33
|
+
} | {
|
|
34
|
+
part: "country";
|
|
35
|
+
kind: "country";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* What keeps the address from being one Core takes, part by part in the field's order: a required part
|
|
39
|
+
* empty (after trimming, as Core trims), a part longer than its column, a country that is no ISO 3166-1
|
|
40
|
+
* alpha-2 code.
|
|
41
|
+
*/
|
|
42
|
+
export declare function findPhiAddressProblems(value: PhisSiteAddressInput): PhiAddressProblem[];
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { readPhiCountryCode } from "../constants/countries";
|
|
2
|
+
import { isPhiRecord } from "./is-record";
|
|
3
|
+
/** The parts of an address a person writes (`PhisSiteAddressInput`), in the order the `address` field asks them. */
|
|
4
|
+
export const PHI_ADDRESS_PARTS = ["name", "companyName", "line1", "line2", "postalCode", "city", "region", "country"];
|
|
5
|
+
/** The parts Core refuses an address without (phis-server `readPhisSiteAddressInput`). */
|
|
6
|
+
export const PHI_ADDRESS_REQUIRED_PARTS = ["name", "line1", "city", "country"];
|
|
7
|
+
/** The widths of `phis.site_addresses` Core holds each text part to; the country is a code. */
|
|
8
|
+
export const PHI_ADDRESS_PART_MAX_LENGTHS = {
|
|
9
|
+
companyName: 256,
|
|
10
|
+
name: 256,
|
|
11
|
+
line1: 256,
|
|
12
|
+
line2: 256,
|
|
13
|
+
postalCode: 32,
|
|
14
|
+
city: 128,
|
|
15
|
+
region: 128,
|
|
16
|
+
};
|
|
17
|
+
const OPTIONAL_PARTS = new Set(["companyName", "line2", "postalCode", "region"]);
|
|
18
|
+
/**
|
|
19
|
+
* The `address` field's value as a Form holds it: every part of `PhisSiteAddressInput`, an empty optional
|
|
20
|
+
* part `null`, an empty required part `""`. Read leniently -- it is what somebody is typing -- and never
|
|
21
|
+
* thrown on; whether it can be sent is `findPhiAddressProblems`'s answer.
|
|
22
|
+
*/
|
|
23
|
+
export function readPhiAddressFieldValue(value) {
|
|
24
|
+
const record = isPhiRecord(value) ? value : {};
|
|
25
|
+
const part = (key) => {
|
|
26
|
+
const raw = typeof record[key] === "string" ? record[key] : "";
|
|
27
|
+
return OPTIONAL_PARTS.has(key) && !raw ? null : raw;
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
name: part("name") ?? "",
|
|
31
|
+
companyName: part("companyName"),
|
|
32
|
+
line1: part("line1") ?? "",
|
|
33
|
+
line2: part("line2"),
|
|
34
|
+
postalCode: part("postalCode"),
|
|
35
|
+
city: part("city") ?? "",
|
|
36
|
+
region: part("region"),
|
|
37
|
+
country: part("country") ?? "",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The value a part change makes: the part written, an empty optional part `null` again. */
|
|
41
|
+
export function writePhiAddressFieldPart(value, part, next) {
|
|
42
|
+
const text = next ?? "";
|
|
43
|
+
return { ...value, [part]: OPTIONAL_PARTS.has(part) && !text ? null : text };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What keeps the address from being one Core takes, part by part in the field's order: a required part
|
|
47
|
+
* empty (after trimming, as Core trims), a part longer than its column, a country that is no ISO 3166-1
|
|
48
|
+
* alpha-2 code.
|
|
49
|
+
*/
|
|
50
|
+
export function findPhiAddressProblems(value) {
|
|
51
|
+
const problems = [];
|
|
52
|
+
for (const part of PHI_ADDRESS_PARTS) {
|
|
53
|
+
const text = (value[part] ?? "").trim();
|
|
54
|
+
if (PHI_ADDRESS_REQUIRED_PARTS.includes(part) && !text) {
|
|
55
|
+
problems.push({ part, kind: "required" });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (part === "country") {
|
|
59
|
+
if (!readPhiCountryCode(text))
|
|
60
|
+
problems.push({ part, kind: "country" });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const max = PHI_ADDRESS_PART_MAX_LENGTHS[part];
|
|
64
|
+
if (text.length > max)
|
|
65
|
+
problems.push({ part, kind: "tooLong", max });
|
|
66
|
+
}
|
|
67
|
+
return problems;
|
|
68
|
+
}
|
package/helpers/cms-dialog.d.ts
CHANGED
|
@@ -42,13 +42,10 @@ export declare const PHI_DIALOG_COMMANDS_CONFIG: {
|
|
|
42
42
|
/**
|
|
43
43
|
* A dialog's width where it names none and its Form needs two columns: the reading measure, which is also
|
|
44
44
|
* where a Form's own cap lies, so a Form fills the dialog it opens in. A wider one -- a table, a preview
|
|
45
|
-
* -- says so, and takes its width from the same sequence (`PHI_LAYOUT`).
|
|
45
|
+
* -- says so, and takes its width from the same sequence (`PHI_LAYOUT`). A dialog states it as
|
|
46
|
+
* `size: { width: PHI_DIALOG_WIDTH }`.
|
|
46
47
|
*/
|
|
47
|
-
export declare const PHI_DIALOG_WIDTH:
|
|
48
|
-
readonly compact: "calc(100vw - 32px)";
|
|
49
|
-
readonly medium: 610;
|
|
50
|
-
readonly wide: 610;
|
|
51
|
-
};
|
|
48
|
+
export declare const PHI_DIALOG_WIDTH: 610;
|
|
52
49
|
/**
|
|
53
50
|
* A dialog's width where its Form stands in one column.
|
|
54
51
|
*
|
|
@@ -58,11 +55,7 @@ export declare const PHI_DIALOG_WIDTH: {
|
|
|
58
55
|
* (`PHI_FORM_RESPONSIVE_MIN_WIDTH.medium`, the same 377), and the Form stands inside the body's inset.
|
|
59
56
|
* So it is that measure plus the inset on both sides -- the Theme's `base` step, whatever it is set to.
|
|
60
57
|
*/
|
|
61
|
-
export declare const PHI_DIALOG_WIDTH_SINGLE_COLUMN:
|
|
62
|
-
readonly compact: "calc(100vw - 32px)";
|
|
63
|
-
readonly medium: "calc(377px + 2 * var(--phi-padding))";
|
|
64
|
-
readonly wide: "calc(377px + 2 * var(--phi-padding))";
|
|
65
|
-
};
|
|
58
|
+
export declare const PHI_DIALOG_WIDTH_SINGLE_COLUMN: string;
|
|
66
59
|
/**
|
|
67
60
|
* Whether a Form stands in one column wherever it can stand in two.
|
|
68
61
|
*
|
|
@@ -75,12 +68,4 @@ export declare const PHI_DIALOG_WIDTH_SINGLE_COLUMN: {
|
|
|
75
68
|
*/
|
|
76
69
|
export declare function isPhiFormSingleColumn(descriptor: PhiFormDescriptor): boolean;
|
|
77
70
|
/** The width a dialog takes for the Form in its body: `PHI_DIALOG_WIDTH_SINGLE_COLUMN` or `PHI_DIALOG_WIDTH`. */
|
|
78
|
-
export declare function resolvePhiDialogFormWidth(descriptor: PhiFormDescriptor):
|
|
79
|
-
readonly compact: "calc(100vw - 32px)";
|
|
80
|
-
readonly medium: 610;
|
|
81
|
-
readonly wide: 610;
|
|
82
|
-
} | {
|
|
83
|
-
readonly compact: "calc(100vw - 32px)";
|
|
84
|
-
readonly medium: "calc(377px + 2 * var(--phi-padding))";
|
|
85
|
-
readonly wide: "calc(377px + 2 * var(--phi-padding))";
|
|
86
|
-
};
|
|
71
|
+
export declare function resolvePhiDialogFormWidth(descriptor: PhiFormDescriptor): number | string;
|
package/helpers/cms-dialog.js
CHANGED
|
@@ -20,8 +20,10 @@ import { PHI_LAYOUT } from "../theme/phi-tokens";
|
|
|
20
20
|
* - The actions are one compact group, labelled, at the medium size: a dialog asks one question and its
|
|
21
21
|
* answers belong together.
|
|
22
22
|
* - The width is as wide as its Form needs: the reading measure for a Form of two columns, the narrowest
|
|
23
|
-
* width that keeps a Form's labels beside its fields for one of one column
|
|
24
|
-
*
|
|
23
|
+
* width that keeps a Form's labels beside its fields for one of one column. A table or an editor states
|
|
24
|
+
* a wider one. It is the width of the Overlay's `size`, a block's length (OVERLAYS.md, "Presentation config"),
|
|
25
|
+
* and the Modal holds it inside the viewport itself, so a phone gets the full width less the gutter
|
|
26
|
+
* without a second value.
|
|
25
27
|
*/
|
|
26
28
|
/** The body Layout's config: a vertical Flex with the `panel` creation preset under it. */
|
|
27
29
|
export const PHI_DIALOG_BODY_CONFIG = {
|
|
@@ -44,13 +46,10 @@ export const PHI_DIALOG_COMMANDS_CONFIG = {
|
|
|
44
46
|
/**
|
|
45
47
|
* A dialog's width where it names none and its Form needs two columns: the reading measure, which is also
|
|
46
48
|
* where a Form's own cap lies, so a Form fills the dialog it opens in. A wider one -- a table, a preview
|
|
47
|
-
* -- says so, and takes its width from the same sequence (`PHI_LAYOUT`).
|
|
49
|
+
* -- says so, and takes its width from the same sequence (`PHI_LAYOUT`). A dialog states it as
|
|
50
|
+
* `size: { width: PHI_DIALOG_WIDTH }`.
|
|
48
51
|
*/
|
|
49
|
-
export const PHI_DIALOG_WIDTH =
|
|
50
|
-
compact: "calc(100vw - 32px)",
|
|
51
|
-
medium: PHI_LAYOUT.contentMax,
|
|
52
|
-
wide: PHI_LAYOUT.contentMax,
|
|
53
|
-
};
|
|
52
|
+
export const PHI_DIALOG_WIDTH = PHI_LAYOUT.contentMax;
|
|
54
53
|
/**
|
|
55
54
|
* A dialog's width where its Form stands in one column.
|
|
56
55
|
*
|
|
@@ -60,11 +59,7 @@ export const PHI_DIALOG_WIDTH = {
|
|
|
60
59
|
* (`PHI_FORM_RESPONSIVE_MIN_WIDTH.medium`, the same 377), and the Form stands inside the body's inset.
|
|
61
60
|
* So it is that measure plus the inset on both sides -- the Theme's `base` step, whatever it is set to.
|
|
62
61
|
*/
|
|
63
|
-
export const PHI_DIALOG_WIDTH_SINGLE_COLUMN = {
|
|
64
|
-
compact: PHI_DIALOG_WIDTH.compact,
|
|
65
|
-
medium: `calc(${PHI_LAYOUT.contentMaxNarrow}px + 2 * ${PHI_DIALOG_BODY_CONFIG.padding})`,
|
|
66
|
-
wide: `calc(${PHI_LAYOUT.contentMaxNarrow}px + 2 * ${PHI_DIALOG_BODY_CONFIG.padding})`,
|
|
67
|
-
};
|
|
62
|
+
export const PHI_DIALOG_WIDTH_SINGLE_COLUMN = `calc(${PHI_LAYOUT.contentMaxNarrow}px + 2 * ${PHI_DIALOG_BODY_CONFIG.padding})`;
|
|
68
63
|
/** The widths at which a Form's labels stand beside its fields, and so the ones that have columns. */
|
|
69
64
|
const PHI_DIALOG_FORM_COLUMN_MODES = ["medium", "wide"];
|
|
70
65
|
/**
|
|
@@ -90,6 +90,16 @@ export declare function resolvePhiBuilderCatalogPathForCatalog(area: PhiBuilderP
|
|
|
90
90
|
* matched against the storage path or nothing outside Public would ever be found.
|
|
91
91
|
*/
|
|
92
92
|
export declare function findPhiBuilderPageKeyFromStoragePath(area: PhiBuilderPageCatalogArea, path: string, pages: readonly PhiPresetPageNode[]): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* The key of the Module Page a preset identity names, wherever its path stands now.
|
|
95
|
+
*
|
|
96
|
+
* A Module Page is stored and addressed by `ownerModuleId` + `presetKey`, never by path: a revision scope
|
|
97
|
+
* of one carries no path at all, so looking it up by path finds nothing.
|
|
98
|
+
*/
|
|
99
|
+
export declare function findPhiBuilderPageKeyFromPresetSource(source: {
|
|
100
|
+
ownerModuleId: string;
|
|
101
|
+
presetKey: string;
|
|
102
|
+
}, pages: readonly PhiPresetPageNode[]): string | null;
|
|
93
103
|
export declare function resolvePhiBuilderPageKeyFromCatalogPath(area: PhiBuilderPageCatalogArea, path: string, pages: readonly PhiPresetPageNode[]): string;
|
|
94
104
|
export type PhiBuilderPersistedPageCatalogEntry = {
|
|
95
105
|
id: number;
|
|
@@ -218,6 +218,25 @@ export function findPhiBuilderPageKeyFromStoragePath(area, path, pages) {
|
|
|
218
218
|
};
|
|
219
219
|
return visit(pages);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* The key of the Module Page a preset identity names, wherever its path stands now.
|
|
223
|
+
*
|
|
224
|
+
* A Module Page is stored and addressed by `ownerModuleId` + `presetKey`, never by path: a revision scope
|
|
225
|
+
* of one carries no path at all, so looking it up by path finds nothing.
|
|
226
|
+
*/
|
|
227
|
+
export function findPhiBuilderPageKeyFromPresetSource(source, pages) {
|
|
228
|
+
for (const node of pages) {
|
|
229
|
+
if (node.sourcePreset?.ownerModuleId === source.ownerModuleId &&
|
|
230
|
+
node.sourcePreset.presetKey === source.presetKey) {
|
|
231
|
+
return node.key;
|
|
232
|
+
}
|
|
233
|
+
const childKey = node.children ? findPhiBuilderPageKeyFromPresetSource(source, node.children) : null;
|
|
234
|
+
if (childKey) {
|
|
235
|
+
return childKey;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
221
240
|
export function resolvePhiBuilderPageKeyFromCatalogPath(area, path, pages) {
|
|
222
241
|
const normalizedPath = normalizePhiBuilderCmsCatalogPath(path);
|
|
223
242
|
const visit = (nodes) => {
|
|
@@ -67,16 +67,16 @@ export type PhiCmsPresetOverlayInput = {
|
|
|
67
67
|
* What it decides is what differs between dialogs: its ids, its title and wiring, what extra the body
|
|
68
68
|
* Layout carries (a form's label column, say), and its buttons. How the body and the actions look is the
|
|
69
69
|
* one answer every dialog shares (`helpers/cms-dialog.ts`), so it is not an input. Nor is the width, as
|
|
70
|
-
* long as the dialog can see the Form it holds: given `body.form`,
|
|
71
|
-
* (`resolvePhiDialogFormWidth`); given none, `PHI_DIALOG_WIDTH`. A
|
|
72
|
-
* own, for a table or an editor that needs more.
|
|
70
|
+
* long as the dialog can see the Form it holds: given `body.form`, its `size` takes the width that Form
|
|
71
|
+
* needs (`resolvePhiDialogFormWidth`); given none, `PHI_DIALOG_WIDTH`. A `size` in `config` is the
|
|
72
|
+
* caller's own, for a table or an editor that needs more, and replaces the pair whole.
|
|
73
73
|
*/
|
|
74
74
|
export type PhiCmsPresetDialogInput = {
|
|
75
75
|
id: PhiCmsInstanceId;
|
|
76
76
|
bodyLayoutNodeId: PhiCmsInstanceId;
|
|
77
77
|
sortOrder: number;
|
|
78
78
|
label: string | null;
|
|
79
|
-
/** The Overlay's config: title, mount and close policy, open action, routes. `
|
|
79
|
+
/** The Overlay's config: title, mount and close policy, open action, routes. `size` follows `body.form`. */
|
|
80
80
|
config: Record<string, unknown>;
|
|
81
81
|
headerLayoutNodeId?: PhiCmsInstanceId | null;
|
|
82
82
|
/**
|