@phis/ui 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/cms/plugins.d.ts +1 -0
- package/cms/plugins.js +2 -0
- package/components/cms/phi-cms-root-layout.js +30 -1
- package/components/controls/phi-anchor-nav-control.js +4 -1
- package/components/controls/phi-background-control.d.ts +6 -1
- package/components/controls/phi-background-control.js +30 -7
- package/components/controls/phi-bullet-list-control.d.ts +7 -2
- package/components/controls/phi-bullet-list-control.js +4 -3
- package/components/controls/phi-button-control.d.ts +13 -1
- package/components/controls/phi-button-control.js +21 -3
- package/components/controls/phi-color-control.js +4 -2
- package/components/controls/phi-drawer-control-adapter.js +3 -2
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-inline-text-editor.js +7 -1
- package/components/controls/phi-length-control.js +1 -1
- package/components/controls/phi-media-asset-tile-control.js +10 -10
- package/components/controls/phi-progress-control.d.ts +10 -2
- package/components/controls/phi-progress-control.js +6 -2
- package/components/controls/phi-ribbon-control.d.ts +16 -4
- package/components/controls/phi-ribbon-control.js +14 -8
- package/components/controls/phi-ribbon-wrap-control.d.ts +32 -0
- package/components/controls/phi-ribbon-wrap-control.js +31 -0
- package/components/controls/phi-segmented-control.d.ts +4 -1
- package/components/controls/phi-segmented-control.js +13 -2
- package/components/controls/phi-select-control.js +5 -2
- package/components/controls/phi-series-chart-control.d.ts +48 -0
- package/components/controls/phi-series-chart-control.js +82 -0
- package/components/controls/phi-surface-control.d.ts +2 -0
- package/components/controls/phi-surface-control.js +16 -1
- package/components/controls/phi-switch-control.d.ts +4 -1
- package/components/controls/phi-switch-control.js +8 -2
- package/components/controls/phi-tag-control.d.ts +4 -1
- package/components/controls/phi-tag-control.js +11 -3
- package/components/controls/phi-text-control.js +57 -3
- package/components/controls/phi-tree-control.js +1 -1
- package/components/controls/phi-truncated-hover-text.d.ts +15 -0
- package/components/controls/phi-truncated-hover-text.js +25 -0
- package/components/forms/link-target-form-control.d.ts +1 -1
- package/components/forms/link-target-form-control.js +2 -45
- package/components/forms/phi-form-widget-frame.js +4 -2
- package/components/layouts/clients/phi-three-column-layout-client.js +10 -1
- package/components/layouts/phi-layout-view-model.js +10 -1
- package/components/navigation/phi-link.js +6 -1
- package/components/regions/clients/cms-region-container-client.js +16 -1
- package/components/regions/phi-cms-region-container.js +7 -0
- package/components/regions/phi-cms-region-shell.d.ts +22 -1
- package/components/regions/phi-cms-region-shell.js +131 -23
- package/components/root/phi-config-provider.d.ts +13 -0
- package/components/root/phi-config-provider.js +12 -1
- package/components/root/phi-root-background.d.ts +7 -0
- package/components/root/phi-root-background.js +20 -1
- package/components/root/phi-root-layout.d.ts +1 -0
- package/components/root/phi-root-layout.js +1 -0
- package/components/root/phi-root-theme-resolver.js +15 -1
- package/components/root/phi-shell-chrome-overlay.d.ts +18 -1
- package/components/root/phi-shell-chrome-overlay.js +26 -4
- package/components/runtime/runtime-module-context.d.ts +12 -1
- package/components/runtime/runtime-module-context.js +6 -1
- package/components/shell/phi-antd-icon.d.ts +1 -0
- package/components/shell/phi-antd-icon.js +3 -0
- package/components/shell/phi-cms-shell.d.ts +7 -1
- package/components/shell/phi-cms-shell.js +4 -2
- package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
- package/components/shell/use-phi-shell-header-bands.js +64 -0
- package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
- package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
- package/components/shell/use-phi-shell-sticky-top.js +61 -16
- package/components/surface/phi-surface-tone.d.ts +13 -0
- package/components/surface/phi-surface-tone.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -0
- package/components/tables/client/phi-table-binding.js +22 -3
- package/components/trees/client/phi-tree-binding.d.ts +1 -0
- package/components/trees/client/phi-tree-binding.js +11 -2
- package/components/widgets/client/bullet-list-entries-editor.js +7 -1
- package/components/widgets/client/html-editor.js +1 -1
- package/components/widgets/client/shared/phi-collection-provider.js +4 -3
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
- package/components/widgets/client/shared/phi-command-buttons.js +6 -2
- package/components/widgets/client/shared/use-page-reference-options.d.ts +17 -0
- package/components/widgets/client/shared/use-page-reference-options.js +57 -0
- package/components/widgets/config/background.d.ts +52 -1
- package/components/widgets/config/background.js +85 -4
- package/components/widgets/config/button-variant.d.ts +22 -4
- package/components/widgets/config/button-variant.js +24 -5
- package/components/widgets/config/common-action-field.d.ts +1 -1
- package/components/widgets/config/parser-primitives.js +4 -2
- package/components/widgets/config/theme-gradient.d.ts +11 -0
- package/components/widgets/config/theme-gradient.js +12 -0
- package/components/widgets/label-sets/background.js +4 -0
- package/components/widgets/label-sets/geometry.js +2 -0
- package/components/widgets/label-sets/inspector.js +4 -0
- package/components/widgets/label-types/background.d.ts +2 -0
- package/components/widgets/label-types/background.js +2 -0
- package/components/widgets/label-types/common-controls.js +2 -2
- package/components/widgets/label-types/geometry.d.ts +1 -0
- package/components/widgets/label-types/geometry.js +1 -0
- package/components/widgets/label-types/inspector.d.ts +4 -0
- package/components/widgets/label-types/inspector.js +2 -0
- package/components/widgets/shared/bullet-list-vocabulary.d.ts +10 -0
- package/components/widgets/shared/bullet-list-vocabulary.js +5 -2
- package/components/widgets/shared/card-body-client.d.ts +16 -3
- package/components/widgets/shared/card-body-client.js +79 -8
- package/components/widgets/shared/card-vocabulary.d.ts +12 -2
- package/components/widgets/shared/card-vocabulary.js +7 -0
- package/components/widgets/shared/collection-source-failure.d.ts +26 -0
- package/components/widgets/shared/collection-source-failure.js +42 -0
- package/components/widgets/shared/markdown-body-client.js +39 -10
- package/components/widgets/shared/markdown-render.js +16 -3
- package/components/widgets/shared/widget-failure-client.d.ts +10 -0
- package/components/widgets/shared/widget-failure-client.js +20 -0
- package/components/widgets/shared/widget-failure.d.ts +31 -0
- package/components/widgets/shared/widget-failure.js +20 -0
- package/components/widgets/shared/widget-failure.server.d.ts +9 -0
- package/components/widgets/shared/widget-failure.server.js +12 -0
- package/gateway/dashboard-card-memo.d.ts +3 -0
- package/gateway/dashboard-card-memo.js +25 -0
- package/helpers/cms-container-chrome.js +6 -1
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/layout-style.d.ts +8 -4
- package/helpers/layout-style.js +3 -2
- package/helpers/locale.d.ts +8 -0
- package/helpers/locale.js +18 -0
- package/helpers/mode-paint.d.ts +4 -0
- package/helpers/mode-paint.js +47 -0
- package/helpers/shell-region-style.js +2 -1
- package/helpers/surface-style.d.ts +12 -1
- package/helpers/surface-style.js +60 -12
- package/module-dashboard-cards.d.ts +2 -1
- package/module-dashboard-cards.js +2 -1
- package/module-records.d.ts +7 -0
- package/module-records.js +6 -0
- package/package.json +1 -1
- package/plugins/runtime-modules/area-definitions.d.ts +0 -42
- package/plugins/runtime-modules/area-definitions.js +3 -8
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +21 -2
- package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
- package/plugins/runtime-modules/builder/clients/layout-scaffold-overlays.js +10 -5
- package/plugins/runtime-modules/builder/clients/region-inspector.js +47 -2
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
- package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
- package/plugins/runtime-modules/builder/edit-scaffold-drawer.js +3 -2
- package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
- package/plugins/runtime-modules/builder/persistence.js +9 -1
- package/plugins/runtime-modules/builder/render-root-node-scaffold.js +25 -15
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +4 -0
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +15 -4
- package/plugins/runtime-modules/client-authoring-module.d.ts +8 -1
- package/plugins/runtime-modules/client-authoring-module.js +13 -3
- package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
- package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
- package/plugins/runtime-modules/core/widgets/brand/client.d.ts +12 -3
- package/plugins/runtime-modules/core/widgets/brand/client.js +3 -11
- package/plugins/runtime-modules/core/widgets/brand/home.d.ts +15 -0
- package/plugins/runtime-modules/core/widgets/brand/home.js +18 -0
- package/plugins/runtime-modules/core/widgets/brand/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/brand/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/brand/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
- package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +100 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +57 -3
- package/plugins/runtime-modules/core/widgets/card/editor.js +21 -4
- package/plugins/runtime-modules/core/widgets/card/server.js +5 -0
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
- package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
- package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
- package/plugins/runtime-modules/core/widgets/description/client.js +3 -3
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/description/editor.js +3 -2
- package/plugins/runtime-modules/core/widgets/description/server.js +3 -2
- package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
- package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/html/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +320 -2
- package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -4
- package/plugins/runtime-modules/core/widgets/markdown/editor.js +9 -1
- package/plugins/runtime-modules/core/widgets/markdown-toc/client.js +6 -1
- package/plugins/runtime-modules/core/widgets/markdown-toc/config.d.ts +14 -0
- package/plugins/runtime-modules/core/widgets/markdown-toc/config.js +14 -2
- package/plugins/runtime-modules/core/widgets/quick-links/authoring.js +7 -2
- package/plugins/runtime-modules/core/widgets/quick-links/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/quick-links/items.d.ts +0 -2
- package/plugins/runtime-modules/core/widgets/quick-links/items.js +0 -15
- package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
- package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
- package/plugins/runtime-modules/core/widgets/sidebar-navigation/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/sidebar-navigation/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/client.js +8 -3
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/simple-text/editor.js +2 -2
- package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
- package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
- package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
- package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
- package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
- package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
- package/plugins/runtime-modules/dashboard/card-rows.d.ts +3 -1
- package/plugins/runtime-modules/dashboard/card-rows.js +30 -2
- package/plugins/runtime-modules/dashboard/clients/dashboard-card-view.js +29 -7
- package/plugins/runtime-modules/dashboard/trees/phi-default-builder-dashboard-page-tree.js +5 -40
- package/plugins/runtime-modules/theme/presets.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.js +10 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +157 -22
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +5 -9
- package/runtime-data-provider-client.d.ts +2 -0
- package/runtime-data-provider-client.js +7 -0
- package/server-helpers/cms-link-targets.js +6 -0
- package/styles/controls.css +74 -7
- package/styles/gradients.css +101 -0
- package/styles/layout.css +45 -2
- package/styles/root.css +18 -0
- package/styles/shell.css +137 -0
- package/theme/phi-antd-token-resolver.js +20 -1
- package/theme/phi-button-shadow.d.ts +6 -0
- package/theme/phi-theme-gradients.d.ts +96 -0
- package/theme/phi-theme-gradients.js +245 -0
- package/theme/phi-theme-presets.d.ts +3 -0
- package/theme/phi-theme-presets.js +3 -0
- package/theme/phi-theme-tokens.d.ts +6 -2
- package/theme/phi-theme-tokens.js +15 -0
- package/theme/phi-theme.d.ts +5 -0
- package/theme/phi-theme.js +21 -0
- package/theme/phi-tokens.d.ts +16 -15
- package/theme/phi-tokens.js +16 -15
- package/types/cms-plugins.d.ts +2 -0
- package/types/cms-presets.d.ts +7 -0
- package/types/core-widget-placements.d.ts +3 -0
- package/types/dashboard-cards.d.ts +39 -4
- package/types/dashboard-cards.js +6 -0
- package/types/layout-style.d.ts +9 -8
- package/types/layout-style.js +9 -8
- package/types/site-theme.d.ts +10 -2
- package/types/surface.d.ts +4 -0
- package/types/surface.js +4 -0
- package/types.d.ts +1 -1
- package/types.js +1 -1
|
@@ -88,6 +88,15 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
88
88
|
const [queryLoading, setQueryLoading] = useState(Boolean(source));
|
|
89
89
|
const [pendingMutationTargets, setPendingMutationTargets] = useState(() => new Set());
|
|
90
90
|
const [error, setError] = useState(null);
|
|
91
|
+
/*
|
|
92
|
+
* What the last read of the source failed with, apart from `error`.
|
|
93
|
+
*
|
|
94
|
+
* `error` is also where a mutation's refusal lands, and that one the person who edited has to read. A
|
|
95
|
+
* read that failed -- or answered rows the resource cannot stand behind -- is the source's failure,
|
|
96
|
+
* which the Widget leaves to `PhiWidgetFailure`. Only the query writes it, so an edit can never make
|
|
97
|
+
* the Table disappear.
|
|
98
|
+
*/
|
|
99
|
+
const [queryFailure, setQueryFailure] = useState(null);
|
|
91
100
|
const [selectedRowIdentities, setSelectedRowIdentities] = useState([]);
|
|
92
101
|
const [expandedRowIdentities, setExpandedRowIdentities] = useState(initialExpandedRowIdentities);
|
|
93
102
|
const [refreshRequest, setRefreshRequest] = useState({ revision: 0, background: false });
|
|
@@ -131,6 +140,7 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
131
140
|
setQuery((current) => ({ ...current, page: 1, cursor: null }));
|
|
132
141
|
setQueryLoading(sourceKey !== "null");
|
|
133
142
|
setError(null);
|
|
143
|
+
setQueryFailure(null);
|
|
134
144
|
}
|
|
135
145
|
// What a render cannot reset: requests in flight and the bookkeeping kept beside state.
|
|
136
146
|
useEffect(() => {
|
|
@@ -178,7 +188,9 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
178
188
|
setHasMore(false);
|
|
179
189
|
setSummary({});
|
|
180
190
|
setQueryLoading(false);
|
|
181
|
-
|
|
191
|
+
const failure = new PhiTableProviderError("missing-row-identity", `Table Provider row is missing identity field "${resource.rowIdentityPath}".`);
|
|
192
|
+
setError(failure);
|
|
193
|
+
setQueryFailure(failure);
|
|
182
194
|
return;
|
|
183
195
|
}
|
|
184
196
|
const summaryError = validateProviderSummary(resource, data.summary);
|
|
@@ -189,7 +201,9 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
189
201
|
setHasMore(false);
|
|
190
202
|
setSummary({});
|
|
191
203
|
setQueryLoading(false);
|
|
192
|
-
|
|
204
|
+
const failure = new PhiTableProviderError("invalid-summary", summaryError);
|
|
205
|
+
setError(failure);
|
|
206
|
+
setQueryFailure(failure);
|
|
193
207
|
return;
|
|
194
208
|
}
|
|
195
209
|
rowsRef.current = data.rows;
|
|
@@ -202,6 +216,7 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
202
216
|
setSummary(data.summary ?? {});
|
|
203
217
|
setQueryLoading(false);
|
|
204
218
|
setError(null);
|
|
219
|
+
setQueryFailure(null);
|
|
205
220
|
if (!preserveSelectedRowIdentities) {
|
|
206
221
|
const available = new Set(data.rows.flatMap((row) => {
|
|
207
222
|
const identity = readPhiTableRowIdentity(row, resource.rowIdentityPath);
|
|
@@ -243,6 +258,7 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
243
258
|
if (!background)
|
|
244
259
|
setQueryLoading(true);
|
|
245
260
|
setError(null);
|
|
261
|
+
setQueryFailure(null);
|
|
246
262
|
}
|
|
247
263
|
});
|
|
248
264
|
void provider.query({
|
|
@@ -281,7 +297,9 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
281
297
|
setSummary({});
|
|
282
298
|
}
|
|
283
299
|
setQueryLoading(false);
|
|
284
|
-
|
|
300
|
+
const failure = readPhiTableProviderError(queryError);
|
|
301
|
+
setError(failure);
|
|
302
|
+
setQueryFailure(failure);
|
|
285
303
|
}
|
|
286
304
|
});
|
|
287
305
|
return () => abortController.abort();
|
|
@@ -533,6 +551,7 @@ export function usePhiTableBinding({ source, initialQuery = {}, externalQuery, f
|
|
|
533
551
|
contractError: resourceError,
|
|
534
552
|
loading: queryLoading && !bindingError && !resourceError,
|
|
535
553
|
error,
|
|
554
|
+
queryError: queryFailure,
|
|
536
555
|
query,
|
|
537
556
|
resolvedQuery,
|
|
538
557
|
setQuery,
|
|
@@ -16,6 +16,7 @@ export declare function usePhiTreeBinding({ source, initialQuery, defaultExpande
|
|
|
16
16
|
nodes: readonly TreeNode[];
|
|
17
17
|
loading: boolean;
|
|
18
18
|
error: PhiTreeProviderError | null;
|
|
19
|
+
queryError: PhiTreeProviderError | null;
|
|
19
20
|
selectedNodeIdentities: readonly PhiTreeNodeIdentity[];
|
|
20
21
|
setSelectedNodeIdentities: import("react").Dispatch<import("react").SetStateAction<readonly PhiTreeNodeIdentity[]>>;
|
|
21
22
|
checkedNodeIdentities: readonly PhiTreeNodeIdentity[];
|
|
@@ -86,6 +86,12 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
|
|
|
86
86
|
const nodesRef = useRef(nodes);
|
|
87
87
|
const [loading, setLoading] = useState(Boolean(source));
|
|
88
88
|
const [error, setError] = useState(null);
|
|
89
|
+
/*
|
|
90
|
+
* What the last read of the source failed with, apart from `error`, which also holds a refused change
|
|
91
|
+
* -- that one the person who made it has to read. A failed read is the source's failure, which the
|
|
92
|
+
* Widget leaves to `PhiWidgetFailure`; only the query writes it, so an edit cannot hide the Tree.
|
|
93
|
+
*/
|
|
94
|
+
const [queryFailure, setQueryFailure] = useState(null);
|
|
89
95
|
const [selectedNodeIdentities, setSelectedNodeIdentities] = useState([]);
|
|
90
96
|
const [checkedNodeIdentities, setCheckedNodeIdentities] = useState([]);
|
|
91
97
|
const [expandedNodeIdentities, setExpandedNodeIdentities] = useState(defaultExpandedNodeIdentities);
|
|
@@ -134,6 +140,7 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
|
|
|
134
140
|
if (!controller.signal.aborted) {
|
|
135
141
|
setLoading(true);
|
|
136
142
|
setError(null);
|
|
143
|
+
setQueryFailure(null);
|
|
137
144
|
}
|
|
138
145
|
});
|
|
139
146
|
void provider.query({ resourceKey: source.resourceKey, query, params: source.params, signal: controller.signal })
|
|
@@ -161,7 +168,9 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
|
|
|
161
168
|
if (!controller.signal.aborted) {
|
|
162
169
|
setNodes([]);
|
|
163
170
|
setLoading(false);
|
|
164
|
-
|
|
171
|
+
const failure = readPhiTreeProviderError(queryError);
|
|
172
|
+
setError(failure);
|
|
173
|
+
setQueryFailure(failure);
|
|
165
174
|
}
|
|
166
175
|
});
|
|
167
176
|
return () => controller.abort();
|
|
@@ -285,7 +294,7 @@ export function usePhiTreeBinding({ source, initialQuery = PHI_TREE_DEFAULT_INIT
|
|
|
285
294
|
return {
|
|
286
295
|
provider, resource, bindingError,
|
|
287
296
|
query, setQuery,
|
|
288
|
-
nodes, loading, error,
|
|
297
|
+
nodes, loading, error, queryError: queryFailure,
|
|
289
298
|
selectedNodeIdentities, setSelectedNodeIdentities,
|
|
290
299
|
checkedNodeIdentities, setCheckedNodeIdentities,
|
|
291
300
|
expandedNodeIdentities, setExpandedNodeIdentities,
|
|
@@ -99,5 +99,11 @@ export function PhiBulletListEntriesEditor({ entries, listStyle, onCommit, state
|
|
|
99
99
|
resize: "none",
|
|
100
100
|
color: "inherit",
|
|
101
101
|
...fieldStyle,
|
|
102
|
-
}
|
|
102
|
+
},
|
|
103
|
+
/*
|
|
104
|
+
* The text's own padding, stated: half of what the line leaves of the field's height, so the
|
|
105
|
+
* first line's middle is the marker's (`markerLineHeight` above). That is the padding the
|
|
106
|
+
* field had from Ant Design already; stated, the clear button can find the line too.
|
|
107
|
+
*/
|
|
108
|
+
inputStyle: { paddingBlock: "calc((var(--ant-control-height) - 1lh) / 2)" } })), states && onCommit ? (_entry, index) => stepState(index) : undefined) }) }));
|
|
103
109
|
}
|
|
@@ -388,7 +388,7 @@ export function PhiHtmlWidgetEditor({ blockId, html, fontFamily, fontSize, onCha
|
|
|
388
388
|
const initialHtmlRef = useRef(normalizedHtml);
|
|
389
389
|
const latestHtmlRef = useRef(normalizedHtml);
|
|
390
390
|
const resolvedFontFamily = resolvePhiWidgetFontFamily(fontFamily, fonts, token);
|
|
391
|
-
const resolvedFontSize = resolvePhiWidgetFontSize(fontSize, token, "
|
|
391
|
+
const resolvedFontSize = resolvePhiWidgetFontSize(fontSize, token, "base");
|
|
392
392
|
const editable = onChange != null;
|
|
393
393
|
useEffect(() => {
|
|
394
394
|
latestHtmlRef.current = normalizedHtml;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useCallback, useContext, useMemo, } from "react";
|
|
4
4
|
import { isPhiNamespacedRuntimeKey, isPhiRuntimeDataProviderKey, } from "../../../../types/runtime-data-provider";
|
|
5
|
+
import { PhiCollectionSourceFailureText } from "../../shared/collection-source-failure";
|
|
5
6
|
const EMPTY_COLLECTION_PROVIDER_REGISTRY = new Map();
|
|
6
7
|
const PhiCollectionProviderRegistryContext = createContext(EMPTY_COLLECTION_PROVIDER_REGISTRY);
|
|
7
8
|
export function createPhiCollectionProviderClient(registration) {
|
|
@@ -45,11 +46,11 @@ export function usePhiCollectionProvider(source) {
|
|
|
45
46
|
provider,
|
|
46
47
|
resource,
|
|
47
48
|
bindingError: !source
|
|
48
|
-
?
|
|
49
|
+
? PhiCollectionSourceFailureText.notConfigured()
|
|
49
50
|
: !provider
|
|
50
|
-
?
|
|
51
|
+
? PhiCollectionSourceFailureText.providerUnavailable(source.providerKey)
|
|
51
52
|
: !resource
|
|
52
|
-
?
|
|
53
|
+
? PhiCollectionSourceFailureText.resourceUnavailable(source.resourceKey, source.providerKey)
|
|
53
54
|
: null,
|
|
54
55
|
};
|
|
55
56
|
}
|
|
@@ -15,6 +15,15 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
|
|
|
15
15
|
const [data, setData] = useState(null);
|
|
16
16
|
const [loading, setLoading] = useState(false);
|
|
17
17
|
const [error, setError] = useState(null);
|
|
18
|
+
/*
|
|
19
|
+
* What the last read of the source failed with, apart from `error`.
|
|
20
|
+
*
|
|
21
|
+
* `error` is also where an action's refusal lands -- a delete the Provider turned down -- and that is
|
|
22
|
+
* the reader's to see. A read that failed is the source's failure, which the Widget hands to
|
|
23
|
+
* `PhiWidgetFailure` instead: nothing on a live page, the cause in the Builder. Only the query writes
|
|
24
|
+
* it, so an action can never make the Widget disappear.
|
|
25
|
+
*/
|
|
26
|
+
const [queryError, setQueryError] = useState(null);
|
|
18
27
|
const [refreshToken, setRefreshToken] = useState(0);
|
|
19
28
|
const [openPanelKey, setOpenPanelKey] = useState(null);
|
|
20
29
|
/*
|
|
@@ -39,6 +48,7 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
|
|
|
39
48
|
setQuery((current) => JSON.stringify(current) === JSON.stringify(nextQuery) ? current : nextQuery);
|
|
40
49
|
setData(null);
|
|
41
50
|
setError(null);
|
|
51
|
+
setQueryError(null);
|
|
42
52
|
setOpenPanelKey(null);
|
|
43
53
|
}, 0);
|
|
44
54
|
return () => window.clearTimeout(timer);
|
|
@@ -54,6 +64,7 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
|
|
|
54
64
|
return;
|
|
55
65
|
setLoading(true);
|
|
56
66
|
setError(null);
|
|
67
|
+
setQueryError(null);
|
|
57
68
|
}, 0);
|
|
58
69
|
void provider.query({
|
|
59
70
|
resourceKey: source.resourceKey,
|
|
@@ -65,9 +76,12 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
|
|
|
65
76
|
return;
|
|
66
77
|
setData(nextData);
|
|
67
78
|
setError(nextData.error);
|
|
79
|
+
setQueryError(nextData.error);
|
|
68
80
|
}).catch((nextError) => {
|
|
69
81
|
if (isCurrent()) {
|
|
70
|
-
|
|
82
|
+
const message = nextError instanceof Error ? nextError.message : "Collection request failed.";
|
|
83
|
+
setError(message);
|
|
84
|
+
setQueryError(message);
|
|
71
85
|
}
|
|
72
86
|
}).finally(() => {
|
|
73
87
|
// Superseded by an action is still finished loading; only a newer query takes the flag over.
|
|
@@ -114,5 +128,5 @@ export function usePhiCollectionViewBinding({ source, initialQuery, pageSize, })
|
|
|
114
128
|
reload,
|
|
115
129
|
activate,
|
|
116
130
|
}), [activate, data, error, loading, openPanelKey, query, reload]);
|
|
117
|
-
return { provider, resource, bindingError, binding };
|
|
131
|
+
return { provider, resource, bindingError, queryError, binding };
|
|
118
132
|
}
|
|
@@ -5,7 +5,7 @@ import { usePhiSignalListener } from "../../../runtime/runtime-signal-bus";
|
|
|
5
5
|
import { usePhiSignalEmitter, usePhiSignalIdentity } from "../../../runtime/runtime-signal-identity";
|
|
6
6
|
import { registerPhiSignalInstance } from "../../../runtime/runtime-signal-registry";
|
|
7
7
|
import { usePhiSignalRuntimePartition } from "../../../runtime/runtime-signal-partition";
|
|
8
|
-
import {
|
|
8
|
+
import { resolvePhiButtonVariantPresentation } from "../../config/button-variant";
|
|
9
9
|
import { resolvePhiCommonControlAction } from "./phi-common-controls";
|
|
10
10
|
import { resolvePhiButtonIcon } from "./phi-button-icons";
|
|
11
11
|
function resolveButtonSubcontrolAddress(blockId, key) {
|
|
@@ -272,7 +272,11 @@ export function usePhiCommandButtons({ buttons, signalRoutes, blockId, labels, d
|
|
|
272
272
|
label,
|
|
273
273
|
tooltip: buttonState.tooltip ?? button.tooltip,
|
|
274
274
|
showLabel: button.display == null ? undefined : button.display !== "icon",
|
|
275
|
-
|
|
275
|
+
/*
|
|
276
|
+
* A toolbar draws its buttons by primitive type alone, so a `gradient` command button stands as the
|
|
277
|
+
* primary one it is underneath and a `glass` one as the plain one.
|
|
278
|
+
*/
|
|
279
|
+
type: resolvePhiButtonVariantPresentation(action ? action.variant : button.variant).type ?? "default",
|
|
276
280
|
danger: action ? action.danger === true : button.danger === true,
|
|
277
281
|
disabled: button.disabled === true || buttonState.enabled === false,
|
|
278
282
|
readOnly: button.readOnly === true,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PhiCmsAreaKey } from "../../../../constants/cms-areas";
|
|
2
|
+
import type { PhiTreeOption } from "../../../../types/tree";
|
|
3
|
+
import type { PhiPageReferenceSelection } from "./phi-page-reference-picker";
|
|
4
|
+
type PageReferenceOptions = PhiTreeOption<PhiPageReferenceSelection>[];
|
|
5
|
+
/**
|
|
6
|
+
* The Pages of one Area a link may point at, as the tree `PhiLinkTargetControl` offers, for a surface
|
|
7
|
+
* that stands outside the Builder's own catalog: a Form's `link-target` field, the Theme's Brand.
|
|
8
|
+
*
|
|
9
|
+
* Answered by `/api/site/page-references` (`gateway/page-references-route.ts`), which merges the Area's
|
|
10
|
+
* Module Pages and Core's the way the Builder's picker does. `failed` is set when the list could not be
|
|
11
|
+
* read, so the surface can say so instead of showing an empty list that looks like a Site without Pages.
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePhiPageReferenceOptions(area: PhiCmsAreaKey, logScope: string): {
|
|
14
|
+
options: PageReferenceOptions;
|
|
15
|
+
failed: boolean;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
/*
|
|
4
|
+
* One request per Area for as long as the page lives: the create and the edit dialog offer the same
|
|
5
|
+
* Pages, and a list that changed meanwhile is a Page somebody published while this one was being written.
|
|
6
|
+
* A failed request is forgotten, so the next dialog asks again.
|
|
7
|
+
*/
|
|
8
|
+
const pageOptionsByArea = new Map();
|
|
9
|
+
function loadPageOptions(area) {
|
|
10
|
+
const cached = pageOptionsByArea.get(area);
|
|
11
|
+
if (cached)
|
|
12
|
+
return cached;
|
|
13
|
+
const request = (async () => {
|
|
14
|
+
const response = await fetch(`/api/site/page-references?area=${encodeURIComponent(area)}`, {
|
|
15
|
+
cache: "no-store",
|
|
16
|
+
credentials: "same-origin",
|
|
17
|
+
headers: { accept: "application/json" },
|
|
18
|
+
});
|
|
19
|
+
const payload = (await response.json().catch(() => null));
|
|
20
|
+
if (!response.ok || !Array.isArray(payload?.options)) {
|
|
21
|
+
throw new Error(`Page references for "${area}" answered ${response.status}.`);
|
|
22
|
+
}
|
|
23
|
+
return payload.options;
|
|
24
|
+
})();
|
|
25
|
+
pageOptionsByArea.set(area, request);
|
|
26
|
+
request.catch(() => pageOptionsByArea.delete(area));
|
|
27
|
+
return request;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The Pages of one Area a link may point at, as the tree `PhiLinkTargetControl` offers, for a surface
|
|
31
|
+
* that stands outside the Builder's own catalog: a Form's `link-target` field, the Theme's Brand.
|
|
32
|
+
*
|
|
33
|
+
* Answered by `/api/site/page-references` (`gateway/page-references-route.ts`), which merges the Area's
|
|
34
|
+
* Module Pages and Core's the way the Builder's picker does. `failed` is set when the list could not be
|
|
35
|
+
* read, so the surface can say so instead of showing an empty list that looks like a Site without Pages.
|
|
36
|
+
*/
|
|
37
|
+
export function usePhiPageReferenceOptions(area, logScope) {
|
|
38
|
+
const [options, setOptions] = useState([]);
|
|
39
|
+
const [failed, setFailed] = useState(false);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
let current = true;
|
|
42
|
+
loadPageOptions(area).then((next) => {
|
|
43
|
+
if (current) {
|
|
44
|
+
setOptions(next);
|
|
45
|
+
setFailed(false);
|
|
46
|
+
}
|
|
47
|
+
}, (error) => {
|
|
48
|
+
console.warn(`[${logScope}] Page references could not be loaded.`, { area, error });
|
|
49
|
+
if (current)
|
|
50
|
+
setFailed(true);
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
current = false;
|
|
54
|
+
};
|
|
55
|
+
}, [area, logScope]);
|
|
56
|
+
return { options, failed };
|
|
57
|
+
}
|
|
@@ -18,10 +18,43 @@ export type PhiBackgroundBaseColor = {
|
|
|
18
18
|
export type PhiBackgroundBaseNone = {
|
|
19
19
|
kind: "none";
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* The Theme's Chrome Overlay as the ground (LAYOUTING.md "Surface tone", SHELL.md "Root Background and
|
|
23
|
+
* Shell Backdrop Layers").
|
|
24
|
+
*
|
|
25
|
+
* The box paints what the Theme workspace calls the Chrome Overlay -- its colour or picture and its glass
|
|
26
|
+
* pane -- instead of a ground of its own. It carries nothing else: the Overlay is the Theme's, per mode
|
|
27
|
+
* (`root.chrome[mode]`), and the box reads the mode it stands in. A Surface `tone` is that mode, so an
|
|
28
|
+
* `inverse` Footer is the dark Overlay on a light page and the light one on a dark page. It is a stated
|
|
29
|
+
* ground: a tone does not paint its own container ground beneath it.
|
|
30
|
+
*/
|
|
31
|
+
export type PhiBackgroundBaseTheme = {
|
|
32
|
+
kind: "theme";
|
|
33
|
+
};
|
|
21
34
|
export type PhiBackgroundBaseGradient = {
|
|
22
35
|
kind: "gradient";
|
|
23
36
|
direction: PhiBackgroundDirection;
|
|
24
37
|
stops: PhiBackgroundGradientStop[];
|
|
38
|
+
/**
|
|
39
|
+
* Soft radial fields of light laid over the linear gradient, first on top: an ember in a corner, a
|
|
40
|
+
* wash of colour on one side. Stated by a Preset or an agent; the Background Control does not offer
|
|
41
|
+
* them yet, and keeps them through its edits because it changes the Base by spreading it.
|
|
42
|
+
*/
|
|
43
|
+
glows?: PhiBackgroundGradientGlow[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* One field of light: `color` at `opacity` in its centre (`x`, `y` from the box's top left), fading to
|
|
47
|
+
* nothing at `fade` percent of its radii (`width`, `height`). Lengths are CSS lengths, mostly percentages
|
|
48
|
+
* of the box.
|
|
49
|
+
*/
|
|
50
|
+
export type PhiBackgroundGradientGlow = {
|
|
51
|
+
color: string;
|
|
52
|
+
opacity?: number;
|
|
53
|
+
x: string;
|
|
54
|
+
y: string;
|
|
55
|
+
width: string;
|
|
56
|
+
height?: string;
|
|
57
|
+
fade?: number;
|
|
25
58
|
};
|
|
26
59
|
export type PhiBackgroundBaseImage = {
|
|
27
60
|
kind: "image";
|
|
@@ -50,6 +83,24 @@ export type PhiBackgroundImageSourceKind = "asset" | "url";
|
|
|
50
83
|
*/
|
|
51
84
|
export declare const PHI_BACKGROUND_IMAGE_SOURCE_KINDS: readonly PhiBackgroundImageSourceKind[];
|
|
52
85
|
export declare const PHI_BACKGROUND_BASE_KINDS: readonly PhiCmsBackgroundWidgetConfig["base"]["kind"][];
|
|
86
|
+
/**
|
|
87
|
+
* The container ground of the mode a box stands in. What a toned Surface paints where it states no
|
|
88
|
+
* ground (`PHI_SURFACE_TONE_GROUND`), and what a `theme` ground falls back to where the Theme's Overlay
|
|
89
|
+
* is not published.
|
|
90
|
+
*/
|
|
91
|
+
export declare const PHI_BACKGROUND_CONTAINER_GROUND = "var(--ant-color-bg-container)";
|
|
92
|
+
/**
|
|
93
|
+
* What a `theme` Base paints: the Shell Chrome Overlay's custom properties, the same ones the Shell's
|
|
94
|
+
* chrome panes paint from (components/shell/phi-cms-shell.tsx).
|
|
95
|
+
*
|
|
96
|
+
* The Root Layout publishes them for the page's mode, and `styles/shell.css` publishes them again under a
|
|
97
|
+
* tone's class for the tone's mode, so the box needs no colour of its own and turns with the mode switch.
|
|
98
|
+
* Outside the Root Layout -- a Modal or Drawer portalled to `<body>` -- nothing publishes them, and the box
|
|
99
|
+
* takes the container ground of its mode instead: the tone's ground, or the Overlay's own where it has no
|
|
100
|
+
* tone. Fixed attachment for the reason the Chrome Regions have it: every box is a window onto one
|
|
101
|
+
* viewport-sized painting.
|
|
102
|
+
*/
|
|
103
|
+
export declare const PHI_BACKGROUND_THEME_STYLE: Readonly<CSSProperties>;
|
|
53
104
|
export declare const PHI_BACKGROUND_MOTION_MODES: readonly PhiBackgroundMotionMode[];
|
|
54
105
|
export type PhiBackgroundMotionDirection = "natural" | "reverse";
|
|
55
106
|
/**
|
|
@@ -103,7 +154,7 @@ export type PhiBackgroundOverlay = PhiBackgroundColorOverlay | PhiBackgroundPatt
|
|
|
103
154
|
/** What an Overlay that states no opacity is painted at, shared by every kind. */
|
|
104
155
|
export declare const PHI_BACKGROUND_OVERLAY_DEFAULT_OPACITY = 0.14;
|
|
105
156
|
export type PhiCmsBackgroundWidgetConfig = {
|
|
106
|
-
base: PhiBackgroundBaseColor | PhiBackgroundBaseGradient | PhiBackgroundBaseImage | PhiBackgroundBaseNone;
|
|
157
|
+
base: PhiBackgroundBaseColor | PhiBackgroundBaseGradient | PhiBackgroundBaseImage | PhiBackgroundBaseNone | PhiBackgroundBaseTheme;
|
|
107
158
|
overlay?: PhiBackgroundOverlay | null;
|
|
108
159
|
filter?: PhiBackgroundFilter | null;
|
|
109
160
|
motion?: PhiBackgroundMotion | null;
|
|
@@ -30,7 +30,35 @@ export const PHI_BACKGROUND_BASE_KINDS = [
|
|
|
30
30
|
"color",
|
|
31
31
|
"gradient",
|
|
32
32
|
"image",
|
|
33
|
+
"theme",
|
|
33
34
|
];
|
|
35
|
+
/**
|
|
36
|
+
* The container ground of the mode a box stands in. What a toned Surface paints where it states no
|
|
37
|
+
* ground (`PHI_SURFACE_TONE_GROUND`), and what a `theme` ground falls back to where the Theme's Overlay
|
|
38
|
+
* is not published.
|
|
39
|
+
*/
|
|
40
|
+
export const PHI_BACKGROUND_CONTAINER_GROUND = "var(--ant-color-bg-container)";
|
|
41
|
+
/**
|
|
42
|
+
* What a `theme` Base paints: the Shell Chrome Overlay's custom properties, the same ones the Shell's
|
|
43
|
+
* chrome panes paint from (components/shell/phi-cms-shell.tsx).
|
|
44
|
+
*
|
|
45
|
+
* The Root Layout publishes them for the page's mode, and `styles/shell.css` publishes them again under a
|
|
46
|
+
* tone's class for the tone's mode, so the box needs no colour of its own and turns with the mode switch.
|
|
47
|
+
* Outside the Root Layout -- a Modal or Drawer portalled to `<body>` -- nothing publishes them, and the box
|
|
48
|
+
* takes the container ground of its mode instead: the tone's ground, or the Overlay's own where it has no
|
|
49
|
+
* tone. Fixed attachment for the reason the Chrome Regions have it: every box is a window onto one
|
|
50
|
+
* viewport-sized painting.
|
|
51
|
+
*/
|
|
52
|
+
export const PHI_BACKGROUND_THEME_STYLE = {
|
|
53
|
+
backgroundColor: `var(--phi-shell-chrome-color, ${PHI_BACKGROUND_CONTAINER_GROUND})`,
|
|
54
|
+
backgroundImage: "var(--phi-shell-chrome-image, none)",
|
|
55
|
+
backgroundSize: "var(--phi-shell-chrome-size, auto)",
|
|
56
|
+
backgroundPosition: "var(--phi-shell-chrome-position, 0 0)",
|
|
57
|
+
backgroundRepeat: "var(--phi-shell-chrome-repeat, repeat)",
|
|
58
|
+
backgroundAttachment: "fixed",
|
|
59
|
+
backdropFilter: "var(--phi-shell-chrome-filter, none)",
|
|
60
|
+
WebkitBackdropFilter: "var(--phi-shell-chrome-filter, none)",
|
|
61
|
+
};
|
|
34
62
|
export const PHI_BACKGROUND_MOTION_MODES = [
|
|
35
63
|
"static",
|
|
36
64
|
"fixed",
|
|
@@ -69,6 +97,46 @@ function readBackgroundDirection(value) {
|
|
|
69
97
|
}
|
|
70
98
|
return direction && /^-?\d+(\.\d+)?deg$/.test(direction) ? direction : "to right";
|
|
71
99
|
}
|
|
100
|
+
const PHI_BACKGROUND_GLOW_LENGTH = /^-?\d+(\.\d+)?(%|px|rem|em|vw|vh)$/;
|
|
101
|
+
function readBackgroundGlowLength(value) {
|
|
102
|
+
const length = typeof value === "number" && Number.isFinite(value) ? `${value}%` : readString(value)?.trim();
|
|
103
|
+
return length && PHI_BACKGROUND_GLOW_LENGTH.test(length) ? length : undefined;
|
|
104
|
+
}
|
|
105
|
+
/** The fields of light a gradient states; one that cannot be read is left out, the rest still paint. */
|
|
106
|
+
function readBackgroundGlows(value) {
|
|
107
|
+
if (!Array.isArray(value)) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const glows = value.flatMap((entry) => {
|
|
111
|
+
if (!isPhiRecord(entry))
|
|
112
|
+
return [];
|
|
113
|
+
const raw = entry;
|
|
114
|
+
const color = readString(raw.color)?.trim();
|
|
115
|
+
const x = readBackgroundGlowLength(raw.x);
|
|
116
|
+
const y = readBackgroundGlowLength(raw.y);
|
|
117
|
+
const width = readBackgroundGlowLength(raw.width);
|
|
118
|
+
if (!color || !x || !y || !width)
|
|
119
|
+
return [];
|
|
120
|
+
const height = readBackgroundGlowLength(raw.height);
|
|
121
|
+
const opacity = readNumber(raw.opacity);
|
|
122
|
+
const fade = readNumber(raw.fade);
|
|
123
|
+
return [{
|
|
124
|
+
color,
|
|
125
|
+
x,
|
|
126
|
+
y,
|
|
127
|
+
width,
|
|
128
|
+
...(height ? { height } : {}),
|
|
129
|
+
...(opacity == null ? {} : { opacity: Math.max(0, Math.min(1, opacity)) }),
|
|
130
|
+
...(fade == null ? {} : { fade: Math.max(1, Math.min(100, fade)) }),
|
|
131
|
+
}];
|
|
132
|
+
});
|
|
133
|
+
return glows.length > 0 ? glows : undefined;
|
|
134
|
+
}
|
|
135
|
+
function serializePhiBackgroundGlow(glow) {
|
|
136
|
+
const opacity = Math.round((glow.opacity ?? 1) * 1000) / 10;
|
|
137
|
+
const color = opacity >= 100 ? glow.color : `color-mix(in srgb, ${glow.color} ${opacity}%, transparent)`;
|
|
138
|
+
return `radial-gradient(${glow.width} ${glow.height ?? glow.width} at ${glow.x} ${glow.y}, ${color} 0%, transparent ${glow.fade ?? 70}%)`;
|
|
139
|
+
}
|
|
72
140
|
function readBackgroundStops(value) {
|
|
73
141
|
if (!Array.isArray(value)) {
|
|
74
142
|
return undefined;
|
|
@@ -126,7 +194,8 @@ function normalizePhiBackgroundBase(value) {
|
|
|
126
194
|
// Stops or nothing: a gradient without them has nothing to paint, and inventing white to black
|
|
127
195
|
// would put a Background on screen that nobody authored.
|
|
128
196
|
const stops = readBackgroundStops(raw.stops);
|
|
129
|
-
|
|
197
|
+
const glows = readBackgroundGlows(raw.glows);
|
|
198
|
+
return stops ? { kind, direction: readBackgroundDirection(raw.direction), stops, ...(glows ? { glows } : {}) } : null;
|
|
130
199
|
}
|
|
131
200
|
if (kind === "image") {
|
|
132
201
|
const source = readPhiMediaImageSourceConfig(raw);
|
|
@@ -145,7 +214,7 @@ function normalizePhiBackgroundBase(value) {
|
|
|
145
214
|
? { ...normalized, ...source }
|
|
146
215
|
: { ...normalized, ...source };
|
|
147
216
|
}
|
|
148
|
-
if (kind === "none")
|
|
217
|
+
if (kind === "none" || kind === "theme")
|
|
149
218
|
return { kind };
|
|
150
219
|
if (kind === "color") {
|
|
151
220
|
const color = readString(raw.color);
|
|
@@ -253,6 +322,10 @@ export function normalizePhiBackgroundWidgetConfig(config) {
|
|
|
253
322
|
}
|
|
254
323
|
const raw = config;
|
|
255
324
|
const base = normalizePhiBackgroundBase(raw.base) ?? normalizePhiBackgroundBase(raw) ?? { kind: "none" };
|
|
325
|
+
// The Theme's Overlay is the whole ground: it carries its own Overlay and pane, and takes none of the box's.
|
|
326
|
+
if (base.kind === "theme") {
|
|
327
|
+
return { base, overlay: null, filter: null, motion: null };
|
|
328
|
+
}
|
|
256
329
|
return {
|
|
257
330
|
base,
|
|
258
331
|
overlay: readBackgroundOverlay(raw.overlay),
|
|
@@ -278,10 +351,14 @@ export function readPhiBackgroundPatternInkFromCss(css) {
|
|
|
278
351
|
export function serializePhiBackgroundBaseCss(base) {
|
|
279
352
|
if (base.kind === "none")
|
|
280
353
|
return "none";
|
|
354
|
+
// Not a value a Base can be read back from: the Overlay's colour, as far as one CSS value can say it.
|
|
355
|
+
if (base.kind === "theme")
|
|
356
|
+
return String(PHI_BACKGROUND_THEME_STYLE.backgroundColor);
|
|
281
357
|
if (base.kind === "color")
|
|
282
358
|
return base.color;
|
|
283
359
|
if (base.kind === "gradient") {
|
|
284
|
-
|
|
360
|
+
const linear = `linear-gradient(${base.direction}, ${base.stops.map((stop) => `${stop.color} ${stop.percent}%`).join(", ")})`;
|
|
361
|
+
return [...(base.glows ?? []).map(serializePhiBackgroundGlow), linear].join(", ");
|
|
285
362
|
}
|
|
286
363
|
const presentation = resolvePhiBackgroundImagePresentation(base);
|
|
287
364
|
return presentation.url
|
|
@@ -320,6 +397,9 @@ function resolvePhiBackgroundOverlayLayer(overlay) {
|
|
|
320
397
|
export function resolvePhiBackgroundWidgetStyle(config) {
|
|
321
398
|
const normalized = normalizePhiBackgroundWidgetConfig(config);
|
|
322
399
|
const base = normalized.base;
|
|
400
|
+
if (base.kind === "theme") {
|
|
401
|
+
return { ...PHI_BACKGROUND_THEME_STYLE };
|
|
402
|
+
}
|
|
323
403
|
const style = {};
|
|
324
404
|
if (base.kind === "color")
|
|
325
405
|
style.backgroundColor = base.color;
|
|
@@ -397,7 +477,8 @@ export function phiBackgroundWidgetConfigPaintsGround(config) {
|
|
|
397
477
|
* nor honoured there.
|
|
398
478
|
*/
|
|
399
479
|
export function phiBackgroundBaseSupportsGlassEffect(base) {
|
|
400
|
-
|
|
480
|
+
// The Theme's Overlay brings its own pane, and a second one over it is nothing anybody asked for.
|
|
481
|
+
return base.kind !== "image" && base.kind !== "gradient" && base.kind !== "theme";
|
|
401
482
|
}
|
|
402
483
|
/**
|
|
403
484
|
* Whether `blur` has anything to soften: a picture, a gradient, or a patterned Overlay.
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import type { PhiButtonType } from "../../controls/phi-button-types";
|
|
2
|
+
import type { PhiThemeGradientKey } from "../../../theme/phi-theme-gradients";
|
|
2
3
|
/**
|
|
3
4
|
* How a button in a Widget's config stands out, in words that belong to this package.
|
|
4
5
|
*
|
|
5
6
|
* `normal` is the plain button, `primary` the one a surface leads with, `dashed` an outlined one for an
|
|
6
|
-
* optional step, `subtle` a button without a frame, `link` one that reads as a link.
|
|
7
|
-
*
|
|
7
|
+
* optional step, `subtle` a button without a frame, `link` one that reads as a link. `gradient` is filled
|
|
8
|
+
* with one of the Theme's gradient slots, `glass` a frosted pane for a button over a picture or a run.
|
|
9
|
+
* The Button Control maps them onto its primitive; a config never names the primitive's own vocabulary.
|
|
8
10
|
*/
|
|
9
|
-
export declare const PHI_BUTTON_VARIANTS: readonly ["normal", "primary", "dashed", "subtle", "link"];
|
|
11
|
+
export declare const PHI_BUTTON_VARIANTS: readonly ["normal", "primary", "dashed", "subtle", "link", "gradient", "glass"];
|
|
10
12
|
export type PhiButtonVariant = (typeof PHI_BUTTON_VARIANTS)[number];
|
|
11
13
|
export declare function readPhiButtonVariant(value: unknown): PhiButtonVariant | undefined;
|
|
12
|
-
|
|
14
|
+
/** What the Button Control is handed for a variant: its primitive type, and the run or the pane. */
|
|
15
|
+
export type PhiButtonVariantPresentation = {
|
|
16
|
+
type?: PhiButtonType;
|
|
17
|
+
gradient?: PhiThemeGradientKey;
|
|
18
|
+
glass?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A variant as the Button Control's props. The `gradient` variant takes the slot it names, the Theme's
|
|
22
|
+
* first where it names none, so choosing the variant alone already draws a run.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolvePhiButtonVariantPresentation(variant: PhiButtonVariant | undefined, gradient?: PhiThemeGradientKey): PhiButtonVariantPresentation;
|
|
13
25
|
export declare const PHI_BUTTON_VARIANT_FIELD_OPTIONS: readonly [{
|
|
14
26
|
readonly value: "normal";
|
|
15
27
|
readonly label: "Normal";
|
|
@@ -25,4 +37,10 @@ export declare const PHI_BUTTON_VARIANT_FIELD_OPTIONS: readonly [{
|
|
|
25
37
|
}, {
|
|
26
38
|
readonly value: "link";
|
|
27
39
|
readonly label: "Link";
|
|
40
|
+
}, {
|
|
41
|
+
readonly value: "gradient";
|
|
42
|
+
readonly label: "Gradient";
|
|
43
|
+
}, {
|
|
44
|
+
readonly value: "glass";
|
|
45
|
+
readonly label: "Glass";
|
|
28
46
|
}];
|