react-semaphor 0.1.507 → 0.1.509
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/DATA_APP_SDK.md +56 -0
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +194 -172
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/appearance-runtime/index.cjs +1 -1
- package/dist/appearance-runtime/index.js +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +279 -250
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +3 -3
- package/dist/chunks/appearance-context-DzqCdhB4.cjs +1 -0
- package/dist/chunks/{appearance-context-XviHOhWJ.js → appearance-context-VJdrKi7r.js} +2 -1
- package/dist/chunks/{appearance-runtime-provider-D0xVQWnH.js → appearance-runtime-provider-CC4HT2Gi.js} +2 -2
- package/dist/chunks/{appearance-runtime-provider-Ca8rxO86.cjs → appearance-runtime-provider-D5pkvgE4.cjs} +1 -1
- package/dist/chunks/calculated-field-identity-BiTGmnST.cjs +1 -0
- package/dist/chunks/calculated-field-identity-CJL54uFx.js +1373 -0
- package/dist/chunks/{constants-NUleP4DY.js → card-config-utils-Bq1enstT.js} +260 -260
- package/dist/chunks/card-config-utils-CMO4_zVs.cjs +1 -0
- package/dist/chunks/{dashboard-briefing-launcher-DXTpU85p.js → dashboard-briefing-launcher-B5AQu-Vb.js} +12 -12
- package/dist/chunks/{dashboard-briefing-launcher-C8nDSDnV.cjs → dashboard-briefing-launcher-BoXFrqq0.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-CyL0yimg.js → dashboard-controls-CKKkSXEX.js} +16 -14
- package/dist/chunks/dashboard-controls-gUVkQm8o.cjs +52 -0
- package/dist/chunks/dashboard-json-B7fSi6_b.cjs +1 -0
- package/dist/chunks/{dashboard-json-5Jr3RudV.js → dashboard-json-CAJJquVx.js} +9 -9
- package/dist/chunks/edit-dashboard-visual-AZetLUv1.cjs +172 -0
- package/dist/chunks/{edit-dashboard-visual-C7X-um9g.js → edit-dashboard-visual-DCnbqRRn.js} +1986 -1990
- package/dist/chunks/{editor-action-buttons-CcDm8nA5.cjs → editor-action-buttons-CBQsVYdt.cjs} +2 -2
- package/dist/chunks/{editor-action-buttons-C5Wja_J4.js → editor-action-buttons-DDA5JGwO.js} +6 -6
- package/dist/chunks/field-aggregations-DUb0NU6c.js +1229 -0
- package/dist/chunks/field-aggregations-jSi77h9Z.cjs +1 -0
- package/dist/chunks/{field-dependencies-DVl2p1Nm.js → field-dependencies-Cl97kkHy.js} +30 -34
- package/dist/chunks/{field-dependencies-r_U0CGQ-.cjs → field-dependencies-DIab72rQ.cjs} +1 -1
- package/dist/chunks/{index-BVr4fcCB.js → index-0pdaQ9e1.js} +5 -5
- package/dist/chunks/{index-De2QNsqV.js → index-CL2lvhwk.js} +47783 -46019
- package/dist/chunks/{index-C9KXfCkC.js → index-CLIro-EG.js} +3 -0
- package/dist/chunks/index-Cx3qmRUB.cjs +1 -0
- package/dist/chunks/{index-BlYf8gNa.cjs → index-DhlVxvyI.cjs} +1 -1
- package/dist/chunks/index-DkEAikW8.cjs +1420 -0
- package/dist/chunks/{matrix-card-DACDwdTq.js → matrix-card-CnKQpnsj.js} +1 -1
- package/dist/chunks/{matrix-card-CRXcmAjp.cjs → matrix-card-U4c72doZ.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-ClQzIk7E.js → matrix-control-sources-CRRdP03Q.js} +165 -134
- package/dist/chunks/matrix-control-sources-FjxGIbqk.cjs +1 -0
- package/dist/chunks/{matrix-formatter-7GLTcBuy.cjs → matrix-formatter-CveLJo6S.cjs} +1 -1
- package/dist/chunks/{matrix-formatter-xsq7n_e6.js → matrix-formatter-ZVS5QOuq.js} +2 -2
- package/dist/chunks/matrix-member-presentation-CFHjdrxT.cjs +1 -0
- package/dist/chunks/matrix-member-presentation-CzGZJd3a.js +182 -0
- package/dist/chunks/matrix-operation-contract-DoiWTUbT.cjs +1 -0
- package/dist/chunks/matrix-operation-contract-xL8IhFzp.js +1802 -0
- package/dist/chunks/{pivot-header-presentation-3wqWChFd.cjs → pivot-header-presentation-Cxz8-06f.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-D44ODZGn.js → pivot-header-presentation-DVylCBHB.js} +2 -2
- package/dist/chunks/{pivot-result-lifecycle-DZ0ZSMoM.cjs → pivot-result-lifecycle-BiERyXnS.cjs} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-BSmqVkVG.js → pivot-result-lifecycle-CmjpW7qG.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-xADifRXs.js → report-preferences-dialog-Bv2VIOKc.js} +4 -4
- package/dist/chunks/report-preferences-dialog-Wg9g9fIj.cjs +1 -0
- package/dist/chunks/{search-BHsQIWBV.js → selection-reducer-B94WgZ9V.js} +55 -11
- package/dist/chunks/selection-reducer-CGKKsaPa.cjs +26 -0
- package/dist/chunks/{semantic-format-BhIL1PXP.cjs → semantic-format-BzH69TRq.cjs} +1 -1
- package/dist/chunks/{semantic-format-C3amkGmY.js → semantic-format-CBlRO8Aw.js} +1 -1
- package/dist/chunks/{switch-DHGiC0aU.js → switch-CD4uGTZI.js} +7450 -7694
- package/dist/chunks/switch-iC1x2dcE.cjs +134 -0
- package/dist/chunks/token-types-Ahh5u4iT.cjs +1 -0
- package/dist/chunks/token-types-CPde8_LG.js +8 -0
- package/dist/chunks/{update-policy-Cc9h57pA.cjs → update-policy-COjFudhl.cjs} +1 -1
- package/dist/chunks/{update-policy-eTcz52jO.js → update-policy-D9q1Tz8k.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +734 -622
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +3 -3
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +94 -92
- package/dist/data-app-codegen-node/index.js +337 -333
- package/dist/data-app-sdk/index.cjs +9 -9
- package/dist/data-app-sdk/index.js +1091 -969
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +104 -96
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/format-utils/index.cjs +1 -1
- package/dist/format-utils/index.js +8 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/brand-studio/brand-studio-draft.d.ts +3 -1
- package/dist/types/components/dashboard/card-selection-pill.d.ts +5 -0
- package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
- package/dist/types/components/dashboard/drill-breadcrumb.d.ts +1 -0
- package/dist/types/components/dashboard/drill-navigation-controls.d.ts +3 -3
- package/dist/types/components/interactions/applied-filters-display.d.ts +6 -1
- package/dist/types/components/interactions/click-to-filter-review-dialog.d.ts +21 -0
- package/dist/types/components/interactions/dashboard-drill-host.d.ts +13 -0
- package/dist/types/components/interactions/filter-badge-tooltip.d.ts +4 -4
- package/dist/types/components/interactions/insight-modal.d.ts +4 -14
- package/dist/types/components/interactions/insight-viewer.d.ts +7 -19
- package/dist/types/components/interactions/interactions-sheet.d.ts +6 -0
- package/dist/types/components/interactions/panels/click-to-filter-panel.d.ts +20 -0
- package/dist/types/components/interactions/reusable/interaction-selection-popover.d.ts +2 -2
- package/dist/types/components/interactions/sheet/action-editor.d.ts +17 -0
- package/dist/types/components/interactions/sheet/action-meta.d.ts +45 -0
- package/dist/types/components/interactions/sheet/action-picker.d.ts +7 -0
- package/dist/types/components/interactions/sheet/click-outcome-preview.d.ts +10 -0
- package/dist/types/components/interactions/sheet/interactions-home.d.ts +28 -0
- package/dist/types/components/interactions/sheet/sheet-parts.d.ts +37 -0
- package/dist/types/components/surfboard/filter/dashboard-filter-mapping-panel.d.ts +28 -1
- package/dist/types/components/surfboard/filter/selection-chip.d.ts +11 -0
- package/dist/types/components/surfboard/filter/selection-filter-section.d.ts +4 -0
- package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +3 -0
- package/dist/types/components/ui/resizable.d.ts +1 -1
- package/dist/types/components/visual/matrix-table/matrix-interaction-actions.d.ts +24 -3
- package/dist/types/components/visual/matrix-table/matrix-selection-click.d.ts +6 -0
- package/dist/types/components/visual/matrix-table/matrix-window-viewer.d.ts +1 -1
- package/dist/types/data-app-sdk/adapters.d.ts +3 -2
- package/dist/types/data-app-sdk/builders.d.ts +2 -1
- package/dist/types/data-app-sdk/contracts.d.ts +44 -2
- package/dist/types/data-app-sdk/index.d.ts +1 -0
- package/dist/types/data-app-sdk/query-request.d.ts +7 -2
- package/dist/types/data-app-sdk/selection.d.ts +2 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +24 -23
- package/dist/types/lib/appearance/types.d.ts +3 -1
- package/dist/types/lib/briefings/briefing-attachment-model.d.ts +0 -2
- package/dist/types/lib/contexts/interactions-popover-context.d.ts +1 -8
- package/dist/types/lib/dashboard/click-to-filter-card-references.d.ts +23 -0
- package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +16 -2
- package/dist/types/lib/dashboard-inputs/build-selection-dashboard-inputs.d.ts +31 -0
- package/dist/types/lib/dashboard-inputs/click-to-filter-emitted-fields.d.ts +17 -0
- package/dist/types/lib/dashboard-inputs/click-to-filter-mapping-draft.d.ts +99 -0
- package/dist/types/lib/dashboard-inputs/click-to-filter-sheet-reach.d.ts +12 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +18 -1
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +4 -1
- package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +10 -0
- package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +8 -1
- package/dist/types/lib/dashboard-inputs/index.d.ts +1 -0
- package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +18 -7
- package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +5 -2
- package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +77 -0
- package/dist/types/lib/dashboard-inputs/selection-targets.d.ts +26 -0
- package/dist/types/lib/dashboard-inputs/transient-input-context.d.ts +102 -0
- package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +50 -0
- package/dist/types/lib/dashboard-navigation/describe-carried-context.d.ts +11 -0
- package/dist/types/lib/dashboard-navigation/index.d.ts +1 -0
- package/dist/types/lib/dashboard-navigation/navigation-state.d.ts +120 -0
- package/dist/types/lib/dashboard-navigation/run-one-off-drill.d.ts +11 -0
- package/dist/types/lib/dashboard-navigation/use-transient-contexts.d.ts +17 -0
- package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +48 -0
- package/dist/types/lib/dashboard-view-state/drill-path.d.ts +20 -0
- package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
- package/dist/types/lib/download-pdf.d.ts +0 -3
- package/dist/types/lib/formatters/metric-formatting.d.ts +1 -1
- package/dist/types/lib/hooks/ai/dashboard-context.d.ts +15 -8
- package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +10 -2
- package/dist/types/lib/hooks/interactions/{use-event-engine.d.ts → use-drill-actions.d.ts} +28 -7
- package/dist/types/lib/hooks/selection/use-active-selections.d.ts +15 -0
- package/dist/types/lib/hooks/selection/use-click-to-filter-mapping-draft.d.ts +20 -0
- package/dist/types/lib/hooks/selection/use-selection-click.d.ts +34 -0
- package/dist/types/lib/hooks/selection/use-selection-gestures.d.ts +38 -0
- package/dist/types/lib/hooks/selection/use-table-row-selection.d.ts +46 -0
- package/dist/types/lib/hooks/use-dashboard-card.d.ts +0 -2
- package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +18 -0
- package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +0 -1
- package/dist/types/lib/hooks/use-dashboard.d.ts +1 -3
- package/dist/types/lib/hooks/use-interactions-popover.d.ts +1 -8
- package/dist/types/lib/hooks/use-resolved-card-config.d.ts +6 -0
- package/dist/types/lib/interactions/click-outcome.d.ts +25 -0
- package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +3 -1
- package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +1 -1
- package/dist/types/lib/interactions/get-click-context-from-table.d.ts +7 -0
- package/dist/types/lib/interactions/interaction-utils.d.ts +17 -1
- package/dist/types/lib/matrix-table/build-matrix-drill-to-detail.d.ts +15 -0
- package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +14 -3
- package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +0 -3
- package/dist/types/lib/matrix-table/matrix-runtime.d.ts +0 -4
- package/dist/types/lib/matrix-table/{use-matrix-selection.d.ts → use-matrix-cell-focus.d.ts} +13 -17
- package/dist/types/lib/matrix-table/use-matrix.d.ts +0 -1
- package/dist/types/lib/query-context/build-card-query-context.d.ts +19 -8
- package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -3
- package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +12 -4
- package/dist/types/lib/query-context/compile-selection-filters.d.ts +5 -0
- package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +46 -0
- package/dist/types/lib/query-context/filter-group-utils.d.ts +3 -0
- package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +29 -0
- package/dist/types/lib/selection/click-to-filter-authoring-support.d.ts +9 -0
- package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
- package/dist/types/lib/selection/selection-labels.d.ts +3 -0
- package/dist/types/lib/selection/selection-notices.d.ts +9 -0
- package/dist/types/lib/selection/selection-reducer.d.ts +46 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +62 -17
- package/dist/types/lib/stores/editor-store.d.ts +1 -2
- package/dist/types/lib/stores/index.d.ts +0 -2
- package/dist/types/lib/types/common-types.d.ts +60 -6
- package/dist/types/lib/types/explorer-types.d.ts +1 -22
- package/dist/types/lib/types/interaction-types.d.ts +6 -198
- package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +21 -12
- package/dist/types/lib/utils/card-utils.d.ts +11 -0
- package/dist/types/lib/utils/date-hierarchy-utils.d.ts +3 -1
- package/dist/types/lib/utils/drag-and-drop-utils.d.ts +1 -1
- package/dist/types/lib/utils/interaction-icons.d.ts +1 -1
- package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +32 -32
- package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
- package/dist/types/shared/analytics-protocol/selection-contract.d.ts +100 -0
- package/dist/types/shared/analytics-protocol/selection-filter-compiler.d.ts +12 -0
- package/dist/types/shared/dashboard-authoring/apply-group-by-override.d.ts +19 -0
- package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +88 -0
- package/dist/types/shared/dashboard-authoring/contracts.d.ts +8 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
- package/dist/types/shared/dashboard-authoring/linked-click-to-filter-overrides.d.ts +32 -0
- package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
- package/package.json +1 -1
- package/src/data-app-sdk/README.md +58 -1
- package/dist/chunks/appearance-context-tNjvTJj3.cjs +0 -1
- package/dist/chunks/calculated-field-identity-BTpUqfEu.js +0 -1276
- package/dist/chunks/calculated-field-identity-rMuXuzEY.cjs +0 -1
- package/dist/chunks/constants-vtu7_IUo.cjs +0 -1
- package/dist/chunks/dashboard-controls-DlxeddZN.cjs +0 -52
- package/dist/chunks/dashboard-json-DhS4yJfc.cjs +0 -1
- package/dist/chunks/edit-dashboard-visual-X3OCnivL.cjs +0 -172
- package/dist/chunks/field-aggregations-BU_3gHKR.js +0 -957
- package/dist/chunks/field-aggregations-CDCamEsQ.cjs +0 -1
- package/dist/chunks/index-C8XCKzB6.cjs +0 -1
- package/dist/chunks/index-DSa6RSdg.cjs +0 -1417
- package/dist/chunks/matrix-control-sources-CeC5EMyq.cjs +0 -1
- package/dist/chunks/matrix-member-presentation-E2B4k3ws.cjs +0 -1
- package/dist/chunks/matrix-member-presentation-qiHxv67e.js +0 -105
- package/dist/chunks/matrix-operation-contract-Cqy4EW2H.js +0 -1638
- package/dist/chunks/matrix-operation-contract-D9dLX-Wr.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-7Vsc_fsG.cjs +0 -1
- package/dist/chunks/search-BqqhaMx9.cjs +0 -26
- package/dist/chunks/switch-BytP6QY8.cjs +0 -139
- package/dist/types/components/interactions/configuration-popover.d.ts +0 -1
- package/dist/types/components/interactions/interaction-card.d.ts +0 -59
- package/dist/types/components/interactions/interaction-event-handler.d.ts +0 -11
- package/dist/types/components/interactions/interactions-list.d.ts +0 -50
- package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +0 -24
- package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +0 -24
- package/dist/types/components/interactions/selectors/action-selector.d.ts +0 -31
- package/dist/types/components/interactions/selectors/trigger-selector.d.ts +0 -38
- package/dist/types/components/surfboard/filter/click-filter-section.d.ts +0 -5
- package/dist/types/lib/interactions/build-interaction-event.d.ts +0 -25
- package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +0 -10
- package/dist/types/lib/interactions/execute-interaction-event.d.ts +0 -80
- package/dist/types/lib/interactions/field-utils.d.ts +0 -11
- package/dist/types/lib/interactions/handle-chart-click.d.ts +0 -75
- package/dist/types/lib/interactions/linked-interaction-utils.d.ts +0 -14
- package/dist/types/lib/interactions/source-card-filter-utils.d.ts +0 -9
- package/dist/types/lib/matrix-table/matrix-clipboard.d.ts +0 -45
- package/dist/types/lib/matrix-table/matrix-selection.d.ts +0 -20
- package/dist/types/lib/stores/drill-actions.d.ts +0 -139
- package/dist/types/lib/stores/interaction-store.d.ts +0 -113
- package/dist/types/lib/stores/pointer-interaction-store.d.ts +0 -18
|
@@ -16,6 +16,8 @@ export * from './fixtures.js';
|
|
|
16
16
|
export * from './metric-comparison.js';
|
|
17
17
|
export * from './dashboard-date-comparison-definition.js';
|
|
18
18
|
export * from './dashboard-input-contract.js';
|
|
19
|
+
export * from './selection-contract.js';
|
|
20
|
+
export * from './selection-filter-compiler.js';
|
|
19
21
|
export * from './temporal-context.js';
|
|
20
22
|
export * from './temporal-bucket-contract.js';
|
|
21
23
|
export * from './raw-temporal-contract.js';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SemaphorFieldRef, SemaphorSourceRef, TemporalBucketMetadata } from './contracts.js';
|
|
3
|
+
/**
|
|
4
|
+
* A selection is what a viewer picked by clicking marks, rows, or members on
|
|
5
|
+
* one card. It is a dashboard input value: other cards narrow to it the same
|
|
6
|
+
* way they narrow to a toolbar filter. The protocol owns these shapes so the
|
|
7
|
+
* dashboard runtime, the Data App SDK, and the server share one contract.
|
|
8
|
+
*/
|
|
9
|
+
export type SelectionFieldSource = Extract<SemaphorSourceRef, {
|
|
10
|
+
kind: 'semantic' | 'physical';
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* A source-qualified field. Structurally identical to the persisted dashboard
|
|
14
|
+
* filter target field; declared here so the protocol does not depend on
|
|
15
|
+
* dashboard authoring.
|
|
16
|
+
*/
|
|
17
|
+
export type SelectionField = {
|
|
18
|
+
name: string;
|
|
19
|
+
source: SelectionFieldSource;
|
|
20
|
+
dataType: 'string' | 'number' | 'boolean' | 'date' | 'datetime';
|
|
21
|
+
/** Physical column when it differs from the semantic name. */
|
|
22
|
+
sourceField?: string;
|
|
23
|
+
};
|
|
24
|
+
/** One field condition from a click, grounded on the source card's own executable source. */
|
|
25
|
+
export type SelectionCondition = {
|
|
26
|
+
field: SelectionField;
|
|
27
|
+
operator: '=' | 'isNull';
|
|
28
|
+
value: string | number | null;
|
|
29
|
+
/** Display only; never identity, never SQL. */
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Present when the value is a canonical grouped-temporal scalar. */
|
|
32
|
+
temporalBucket?: TemporalBucketMetadata;
|
|
33
|
+
};
|
|
34
|
+
/** One selected item. Conditions are AND-ed. */
|
|
35
|
+
export type SelectionTuple = {
|
|
36
|
+
conditions: SelectionCondition[];
|
|
37
|
+
};
|
|
38
|
+
/** Runtime value of a selection input. Tuples are OR-ed. */
|
|
39
|
+
export type SelectionInputValue = {
|
|
40
|
+
kind: 'selection';
|
|
41
|
+
sourceCardId: string;
|
|
42
|
+
/** 1..SELECTION_LIMIT. An empty selection clears the slot instead of storing []. */
|
|
43
|
+
tuples: SelectionTuple[];
|
|
44
|
+
};
|
|
45
|
+
/** One source-owned analytical selection transported outside dashboard state. */
|
|
46
|
+
export type AnalyticsSelectionCondition = {
|
|
47
|
+
field: SemaphorFieldRef;
|
|
48
|
+
operator: '=' | 'isNull';
|
|
49
|
+
value: string | number | null;
|
|
50
|
+
temporalBucket?: TemporalBucketMetadata;
|
|
51
|
+
};
|
|
52
|
+
export type AnalyticsSelectionTuple = {
|
|
53
|
+
conditions: AnalyticsSelectionCondition[];
|
|
54
|
+
};
|
|
55
|
+
export type AnalyticsSelection = {
|
|
56
|
+
id: string;
|
|
57
|
+
tuples: AnalyticsSelectionTuple[];
|
|
58
|
+
};
|
|
59
|
+
/** Enforced by the schema and by the selection reducer. */
|
|
60
|
+
export declare const SELECTION_LIMIT = 100;
|
|
61
|
+
/**
|
|
62
|
+
* Stable identity of a clicked field across sessions and saves. It is
|
|
63
|
+
* persisted in chosen columns and bound mappings, so the source part is the
|
|
64
|
+
* protocol's dataset identity. Connection and label changes never affect it;
|
|
65
|
+
* a display-name change is also stable when the semantic source has datasetId.
|
|
66
|
+
*/
|
|
67
|
+
export declare function selectionFieldKey(field: SelectionField): string;
|
|
68
|
+
export declare function selectionInputId(sourceCardId: string): string;
|
|
69
|
+
export declare function isSelectionInputId(inputId: string): boolean;
|
|
70
|
+
export declare function sourceCardIdFromSelectionInputId(inputId: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Identity of a temporal bucket's meaning. Every calendar member that changes
|
|
73
|
+
* which instants a bucket value covers is part of it: the same "Q1" under two
|
|
74
|
+
* fiscal calendars is two different selections.
|
|
75
|
+
*/
|
|
76
|
+
export declare function temporalBucketIdentityKey(bucket: TemporalBucketMetadata | undefined): string;
|
|
77
|
+
/** Identity of one condition: field, operator, value and bucket meaning. Labels excluded. */
|
|
78
|
+
export declare function selectionConditionKey(condition: SelectionCondition): string;
|
|
79
|
+
/** Stable, order-insensitive identity of a tuple. Labels are display only and excluded. */
|
|
80
|
+
export declare function selectionTupleKey(tuple: SelectionTuple): string;
|
|
81
|
+
/** Stable, display-metadata-insensitive identity for a transported condition. */
|
|
82
|
+
export declare function analyticsSelectionConditionKey(condition: AnalyticsSelectionCondition): string;
|
|
83
|
+
/** Stable, order-insensitive identity for one transported tuple. */
|
|
84
|
+
export declare function analyticsSelectionTupleKey(tuple: AnalyticsSelectionTuple): string;
|
|
85
|
+
/**
|
|
86
|
+
* Canonical request snapshot. Selection, tuple, and condition order do not
|
|
87
|
+
* change query identity; labels and other display metadata remain untouched.
|
|
88
|
+
*/
|
|
89
|
+
export declare function canonicalizeAnalyticsSelections(selections: readonly AnalyticsSelection[]): AnalyticsSelection[];
|
|
90
|
+
/** Order-insensitive over conditions; ignores labels. */
|
|
91
|
+
export declare function sameSelectionTuple(a: SelectionTuple, b: SelectionTuple): boolean;
|
|
92
|
+
/** "West · Enterprise". Uses the display label when the click supplied one. */
|
|
93
|
+
export declare function selectionTupleLabel(tuple: SelectionTuple): string;
|
|
94
|
+
export declare const selectionFieldSchema: z.ZodType<SelectionField>;
|
|
95
|
+
export declare const selectionConditionSchema: z.ZodType<SelectionCondition>;
|
|
96
|
+
export declare const selectionTupleSchema: z.ZodType<SelectionTuple>;
|
|
97
|
+
export declare const selectionInputValueSchema: z.ZodType<SelectionInputValue>;
|
|
98
|
+
export declare const analyticsSelectionConditionSchema: z.ZodType<AnalyticsSelectionCondition>;
|
|
99
|
+
export declare const analyticsSelectionTupleSchema: z.ZodType<AnalyticsSelectionTuple>;
|
|
100
|
+
export declare const analyticsSelectionSchema: z.ZodType<AnalyticsSelection>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FilterCondition, FilterGroup } from '../../lib/types/explorer-types.js';
|
|
2
|
+
/** One source selection already projected into executable filter conditions. */
|
|
3
|
+
export type SelectionFilterSource = {
|
|
4
|
+
sourceCardId: string;
|
|
5
|
+
tuples: Array<{
|
|
6
|
+
conditions: FilterCondition[];
|
|
7
|
+
}>;
|
|
8
|
+
};
|
|
9
|
+
/** AND across sources, OR across tuples per source, AND within each tuple. */
|
|
10
|
+
export declare function compileSelectionFilterGroup(sources: SelectionFilterSource[]): FilterGroup | undefined;
|
|
11
|
+
/** Stable and order-insensitive across sources, tuples and conditions. */
|
|
12
|
+
export declare function selectionFilterGroupKey(sources: SelectionFilterSource[]): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CardConfig, GroupByField } from '../../lib/types/explorer-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* What happens to a card's sorts when its grouping is replaced at runtime.
|
|
4
|
+
*
|
|
5
|
+
* - `dropUnrelatedSorts`: a field-selector control swaps the grouping for an
|
|
6
|
+
* unrelated field, so only sorts on the new grouping or on a metric survive.
|
|
7
|
+
* - `retargetDimensionSort`: a drill walks down from the grouping, so a sort on
|
|
8
|
+
* the old grouping follows the viewer to the new field and keeps its
|
|
9
|
+
* direction. Every other sort is kept.
|
|
10
|
+
*/
|
|
11
|
+
export type GroupBySortPolicy = 'dropUnrelatedSorts' | 'retargetDimensionSort';
|
|
12
|
+
/**
|
|
13
|
+
* Replaces a card's grouping with one field. The single transform behind the
|
|
14
|
+
* `config_field_selector` control binding and the drill path, so neither can
|
|
15
|
+
* produce an ORDER BY the other would not.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyGroupByOverride(cardConfig: CardConfig, groupByField: GroupByField, options: {
|
|
18
|
+
sortPolicy: GroupBySortPolicy;
|
|
19
|
+
}): CardConfig;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SelectionField } from '../analytics-protocol/selection-contract.js';
|
|
3
|
+
import { DashboardInputScope, TCard } from '../../lib/types/common-types.js';
|
|
4
|
+
import { Field } from '../../lib/types/explorer-types.js';
|
|
5
|
+
import { buildDashboardCardSourceIndex, DashboardCardFilterSourceInventory } from './dashboard-card-source-index.js';
|
|
6
|
+
import { DashboardFilterTarget } from './dashboard-filter-mapping-types.js';
|
|
7
|
+
/** Which fields a click on this card carries. */
|
|
8
|
+
export type ClickToFilterFieldsRule =
|
|
9
|
+
/** Table: every dimension column on the row. Matrix: the full path. Chart: every dimension of the clicked mark. */
|
|
10
|
+
{
|
|
11
|
+
kind: 'wholeRow';
|
|
12
|
+
}
|
|
13
|
+
/** Table only: the dimension column that was clicked. */
|
|
14
|
+
| {
|
|
15
|
+
kind: 'clickedCell';
|
|
16
|
+
}
|
|
17
|
+
/** Stable keys from `selectionFieldKey`; explorer field ids are not stable. */
|
|
18
|
+
| {
|
|
19
|
+
kind: 'chosenColumns';
|
|
20
|
+
clickedFieldKeys: string[];
|
|
21
|
+
};
|
|
22
|
+
/** Matrix only: which parts of the grid start a selection. */
|
|
23
|
+
export type ClickToFilterMatrixSources = {
|
|
24
|
+
rowMembers: boolean;
|
|
25
|
+
columnMembers: boolean;
|
|
26
|
+
cells: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Sparse per-target overrides. Automatic matches are never written. */
|
|
29
|
+
export type ClickToFilterCardMapping = {
|
|
30
|
+
kind: 'bound';
|
|
31
|
+
/** Target card. */
|
|
32
|
+
cardId: string;
|
|
33
|
+
clickedFieldKey: string;
|
|
34
|
+
/** Same target shape toolbar filter mappings persist. */
|
|
35
|
+
target: DashboardFilterTarget;
|
|
36
|
+
}
|
|
37
|
+
/** "Not applied": this target never receives this source's clicks. */
|
|
38
|
+
| {
|
|
39
|
+
kind: 'excluded';
|
|
40
|
+
cardId: string;
|
|
41
|
+
};
|
|
42
|
+
export type ClickToFilterSettings = {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
fields: ClickToFilterFieldsRule;
|
|
45
|
+
/** Cmd/Ctrl toggle and Shift range allowed. */
|
|
46
|
+
multipleSelection: boolean;
|
|
47
|
+
/** 'auto' shows checkboxes on coarse pointers only. */
|
|
48
|
+
selectionCheckboxes: 'auto' | 'always' | 'never';
|
|
49
|
+
/** matrixTable only; absent means all three true. */
|
|
50
|
+
matrixSources?: ClickToFilterMatrixSources;
|
|
51
|
+
/** Which cards may receive clicks. */
|
|
52
|
+
targets: DashboardInputScope;
|
|
53
|
+
cardMappings: ClickToFilterCardMapping[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Instance-level overrides for a linked library visual. `null` means cleared
|
|
57
|
+
* on this instance. The helpers that build and apply these arrive with the
|
|
58
|
+
* authoring phase; the persisted shape is declared here with the settings.
|
|
59
|
+
*/
|
|
60
|
+
export type LinkedClickToFilterOverrides = {
|
|
61
|
+
targets?: DashboardInputScope | null;
|
|
62
|
+
cardMappings?: ClickToFilterCardMapping[] | null;
|
|
63
|
+
};
|
|
64
|
+
export type ClickToFilterDashboardDefault = 'on' | 'off';
|
|
65
|
+
export declare function defaultClickToFilterSettings(card: Pick<TCard, 'type'>, dashboardDefault: ClickToFilterDashboardDefault): ClickToFilterSettings;
|
|
66
|
+
/**
|
|
67
|
+
* Grounds an explorer field on one of the card's own executable sources.
|
|
68
|
+
* A field that carries catalog identity must match an executable source. A
|
|
69
|
+
* field without it is grounded by its entity, or by the card's single source.
|
|
70
|
+
* Calculated fields and unknown data types cannot be grounded.
|
|
71
|
+
*/
|
|
72
|
+
export declare function selectionFieldFromExplorerField(field: Field, sourceIndex: DashboardCardFilterSourceInventory): SelectionField | undefined;
|
|
73
|
+
/** The source-index members ground a legacy attribute trigger to a stable field key. */
|
|
74
|
+
type NormalizableCard = Pick<TCard, 'type' | 'clickToFilter' | 'interactionConfig'> & Parameters<typeof buildDashboardCardSourceIndex>[0];
|
|
75
|
+
/**
|
|
76
|
+
* Effective settings for a card. If `card.clickToFilter` is absent, derives
|
|
77
|
+
* them from legacy `interactionConfig.interactions` entries with mode
|
|
78
|
+
* 'clickFilter': trigger type 'attribute' becomes chosenColumns of that field,
|
|
79
|
+
* 'metric' (or no trigger) becomes wholeRow, `applyToCardIds` becomes card
|
|
80
|
+
* targets, and `excludeCardIds` become excluded mappings. A legacy entry means
|
|
81
|
+
* the author turned the behavior on, so the result is enabled regardless of
|
|
82
|
+
* the dashboard default. Pure; never writes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function normalizeClickToFilterSettings(card: NormalizableCard, dashboardDefault: ClickToFilterDashboardDefault): ClickToFilterSettings;
|
|
85
|
+
export declare const clickToFilterSettingsSchema: z.ZodType<ClickToFilterSettings>;
|
|
86
|
+
export declare const respondsToSelectionsSchema: z.ZodBoolean;
|
|
87
|
+
export declare const linkedClickToFilterOverridesSchema: z.ZodType<LinkedClickToFilterOverrides>;
|
|
88
|
+
export {};
|
|
@@ -18,6 +18,10 @@ export type DashboardPlanCard = {
|
|
|
18
18
|
section?: string;
|
|
19
19
|
analyticsIntent?: SemaphorAnalyticsIntent;
|
|
20
20
|
text?: string;
|
|
21
|
+
/** Canonical click-to-filter settings. Legacy interactionConfig payloads are not accepted. */
|
|
22
|
+
clickToFilter?: TCard['clickToFilter'];
|
|
23
|
+
/** Whether this card accepts selections from other cards. */
|
|
24
|
+
respondsToSelections?: TCard['respondsToSelections'];
|
|
21
25
|
};
|
|
22
26
|
export type DashboardPlanSheet = {
|
|
23
27
|
id: string;
|
|
@@ -117,6 +121,10 @@ export type DashboardChangeOperation = {
|
|
|
117
121
|
cardId: string;
|
|
118
122
|
title: string;
|
|
119
123
|
description?: string;
|
|
124
|
+
} | {
|
|
125
|
+
kind: 'updateCardSelectionSettings';
|
|
126
|
+
cardId: string;
|
|
127
|
+
card: Pick<DashboardPlanCard, 'clickToFilter' | 'respondsToSelections'>;
|
|
120
128
|
} | {
|
|
121
129
|
kind: 'reorderCards';
|
|
122
130
|
cardIds: string[];
|
|
@@ -17,6 +17,9 @@ export * from './dashboard-filter-sql-target.js';
|
|
|
17
17
|
export * from './dashboard-filter-mapping-contract.js';
|
|
18
18
|
export * from './dashboard-filter-value-compatibility.js';
|
|
19
19
|
export * from './card-reference-remapping.js';
|
|
20
|
+
export * from './apply-group-by-override.js';
|
|
21
|
+
export * from './click-to-filter-settings.js';
|
|
22
|
+
export * from './linked-click-to-filter-overrides.js';
|
|
20
23
|
export * from './matrix-definition.js';
|
|
21
24
|
export * from './matrix-authoring.js';
|
|
22
25
|
export * from './field-aggregations.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TCard } from '../../lib/types/common-types.js';
|
|
2
|
+
import { ClickToFilterSettings, LinkedClickToFilterOverrides } from './click-to-filter-settings.js';
|
|
3
|
+
type IdMapping = {
|
|
4
|
+
cardIds?: Record<string, string>;
|
|
5
|
+
sheetIds?: Record<string, string>;
|
|
6
|
+
sectionIds?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
/** Rewrites every card and sheet id the settings hold. The one walker for these references. */
|
|
9
|
+
export declare function remapClickToFilterReferences(settings: ClickToFilterSettings, mapping: IdMapping): ClickToFilterSettings;
|
|
10
|
+
/** The same rewrite for an instance's overrides; `undefined` and `null` pass through. */
|
|
11
|
+
export declare function remapLinkedClickToFilterOverrides(overrides: LinkedClickToFilterOverrides, mapping: IdMapping): LinkedClickToFilterOverrides;
|
|
12
|
+
/** `undefined` keeps the library value; `null` clears it on this instance. */
|
|
13
|
+
export declare function applyLinkedClickToFilterOverrides(settings: ClickToFilterSettings, overrides: LinkedClickToFilterOverrides | undefined): ClickToFilterSettings;
|
|
14
|
+
/**
|
|
15
|
+
* What this instance changed relative to the library settings, already
|
|
16
|
+
* remapped to the instance's ids. Undefined when nothing differs, so an
|
|
17
|
+
* instance that follows its library carries no override.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildLinkedClickToFilterOverrides(instanceSettings: ClickToFilterSettings, remappedLibrarySettings: ClickToFilterSettings): LinkedClickToFilterOverrides | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The settings a library save may contain: the edited behavior, with the
|
|
22
|
+
* library's own targeting untouched. Instance targeting is saved as overrides.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripInstanceTargetsForLibrarySave(settings: ClickToFilterSettings, librarySettings: ClickToFilterSettings | undefined): ClickToFilterSettings;
|
|
25
|
+
/**
|
|
26
|
+
* Reads the per-interaction overrides linked cards saved before click to
|
|
27
|
+
* filter became a card setting, with the legacy normalizer's semantics: the
|
|
28
|
+
* union of the inclusive lists is the target set, and a card is excluded only
|
|
29
|
+
* when every open entry excludes it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeLegacyLinkedTargetOverrides(card: Pick<TCard, 'linkedInteractionTargetOverrides'>): LinkedClickToFilterOverrides | undefined;
|
|
32
|
+
export {};
|
|
@@ -91,13 +91,13 @@ export declare const matrixBatchResponseSchema: z.ZodDiscriminatedUnion<"kind",
|
|
|
91
91
|
}, "strip", z.ZodTypeAny, {
|
|
92
92
|
kind: "committed";
|
|
93
93
|
sequence: number;
|
|
94
|
-
deadlineAt: number;
|
|
95
94
|
done: boolean;
|
|
95
|
+
deadlineAt: number;
|
|
96
96
|
}, {
|
|
97
97
|
kind: "committed";
|
|
98
98
|
sequence: number;
|
|
99
|
-
deadlineAt: number;
|
|
100
99
|
done: boolean;
|
|
100
|
+
deadlineAt: number;
|
|
101
101
|
}>]>;
|
|
102
102
|
/** Count the complete JSON envelope in UTF-8, including escaping and transport fields. */
|
|
103
103
|
export declare function assertMatrixBatchResponseSize(value: unknown): void;
|
|
@@ -116,8 +116,8 @@ export declare function parseMatrixBatchResponse(value: unknown, input: MatrixBa
|
|
|
116
116
|
} | {
|
|
117
117
|
kind: "committed";
|
|
118
118
|
sequence: number;
|
|
119
|
-
deadlineAt: number;
|
|
120
119
|
done: boolean;
|
|
120
|
+
deadlineAt: number;
|
|
121
121
|
};
|
|
122
122
|
export declare const matrixManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
123
123
|
acquisition: z.ZodLiteral<"continuation">;
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
semaphor,
|
|
14
14
|
useClearInvalidSemaphorInputValue,
|
|
15
15
|
useSemaphorInputs,
|
|
16
|
+
useSemaphorSelection,
|
|
16
17
|
useSemaphorQuery,
|
|
17
18
|
} from "react-semaphor/data-app-sdk";
|
|
18
19
|
|
|
@@ -118,7 +119,8 @@ Important state fields:
|
|
|
118
119
|
- `isEmpty`: successful query returned no meaningful rows/options/cells/value.
|
|
119
120
|
- `isPartial`: execution status, coverage, diagnostic feedback, or row-limit
|
|
120
121
|
metadata says the result is incomplete.
|
|
121
|
-
- `isFiltered`: one or more active filter inputs were applied to
|
|
122
|
+
- `isFiltered`: one or more active filter inputs or selections were applied to
|
|
123
|
+
the query.
|
|
122
124
|
- `isStale`: previous successful data is being shown while newer inputs load.
|
|
123
125
|
- `isValidated`: validation metadata is present.
|
|
124
126
|
|
|
@@ -184,6 +186,61 @@ const revenueBySegment = semaphor.records({
|
|
|
184
186
|
const result = useSemaphorQuery(revenueBySegment);
|
|
185
187
|
```
|
|
186
188
|
|
|
189
|
+
## Click Selection
|
|
190
|
+
|
|
191
|
+
Create one selection input per source chart. Keep it separate from scalar filter
|
|
192
|
+
and control inputs, pass its handle through the `selections` query option, and
|
|
193
|
+
render its removable chips in the app.
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
const segmentSelection = semaphor.selection({
|
|
197
|
+
id: "segment-chart-selection",
|
|
198
|
+
label: "Segment chart selection",
|
|
199
|
+
fields: [segment],
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
function SegmentDashboard() {
|
|
203
|
+
const selection = useSemaphorSelection(segmentSelection);
|
|
204
|
+
const chartResult = useSemaphorQuery(revenueBySegment);
|
|
205
|
+
const detailResult = useSemaphorQuery(revenueBySegment, {
|
|
206
|
+
selections: [selection],
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const enterprise = {
|
|
210
|
+
conditions: [
|
|
211
|
+
{ field: segment, operator: "=" as const, value: "Enterprise" },
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<>
|
|
217
|
+
<SegmentChart result={chartResult} selection={selection} />
|
|
218
|
+
<button onClick={() => selection.select(enterprise, { kind: "toggle" })}>
|
|
219
|
+
Enterprise
|
|
220
|
+
</button>
|
|
221
|
+
{selection.tuples.map((tuple) => (
|
|
222
|
+
<button
|
|
223
|
+
key={JSON.stringify(tuple)}
|
|
224
|
+
onClick={() => selection.select(tuple, { kind: "toggle" })}
|
|
225
|
+
>
|
|
226
|
+
{tuple.conditions.map((condition) => String(condition.value)).join(" · ")} ×
|
|
227
|
+
</button>
|
|
228
|
+
))}
|
|
229
|
+
<RecordsTable result={detailResult} />
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The source chart query deliberately omits its own selection handle, so selected
|
|
236
|
+
marks stay visible. Pass the handle to every query that should respond.
|
|
237
|
+
|
|
238
|
+
A tuple combines its conditions with AND. Multiple tuples combine with OR, so
|
|
239
|
+
`(region = West AND segment = Enterprise) OR (region = East AND segment = SMB)`
|
|
240
|
+
stays grouped. The shared reducer caps a selection at 100 distinct tuples and
|
|
241
|
+
returns `limitReached`; show that outcome beside the chips. Selection handles
|
|
242
|
+
have no `toAnalyticsInput()` method and never belong in `inputs`.
|
|
243
|
+
|
|
187
244
|
## Row Access
|
|
188
245
|
|
|
189
246
|
Read rows with `columns[].key`; display `columns[].label`.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const C=require("react"),g=require("./color-CyB5o13F.cjs"),d=require("./index-C8XCKzB6.cjs"),E={background:"--semaphor-background",foreground:"--semaphor-foreground",muted:"--semaphor-muted",mutedForeground:"--semaphor-muted-foreground",border:"--semaphor-border",input:"--semaphor-input",primary:"--semaphor-primary",primaryForeground:"--semaphor-primary-foreground",accent:"--semaphor-accent",accentForeground:"--semaphor-accent-foreground",card:"--semaphor-card",cardForeground:"--semaphor-card-foreground",positive:"--semaphor-positive",negative:"--semaphor-negative",warning:"--semaphor-warning",info:"--semaphor-info",destructive:"--semaphor-destructive",destructiveForeground:"--semaphor-destructive-foreground"},k={light:{"--semaphor-code-string":"158 64% 22%","--semaphor-code-number":"158 64% 22%","--semaphor-code-boolean":"158 64% 22%","--semaphor-code-fn":"217 91% 40%","--semaphor-code-keyword":"263 70% 42%"},dark:{"--semaphor-code-string":"158 64% 52%","--semaphor-code-number":"158 64% 52%","--semaphor-code-boolean":"158 64% 52%","--semaphor-code-fn":"213 94% 68%","--semaphor-code-keyword":"264 89% 74%"}};function _(e){var a,c,s,u,f,p,h,i;const o=e.defaults??d.SEMAPHOR_DEFAULT_APPEARANCE_SPEC,n=e.mode??x(e.spec.mode,e.systemMode),r=e.spec.schemes[n]??o.schemes[n],m=((a=r.tokens)==null?void 0:a.color)??{},t={...k[n]};for(const[l,R]of Object.entries(E)){const A=m[l];if(!A)continue;const F=g.compileColorToHslTriplet(A);if(!F)throw new Error(`Invalid compiled appearance color for ${l}`);t[R]=F}return T(t,(c=r.tokens)==null?void 0:c.radius),O(t,(s=r.tokens)==null?void 0:s.typography),{mode:n,scheme:r,cssVariables:t,colorValues:m,chartPalette:((f=(u=r.components)==null?void 0:u.chart)==null?void 0:f.palette)??((h=(p=o.schemes[n].components)==null?void 0:p.chart)==null?void 0:h.palette)??d.SEMAPHOR_DEFAULT_CHART_PALETTE,table:(i=r.components)==null?void 0:i.table}}function O(e,o){o!=null&&o.fontFamily&&(e["--semaphor-font-family"]=o.fontFamily),o!=null&&o.headingFontFamily&&(e["--semaphor-heading-font-family"]=o.headingFontFamily),o!=null&&o.monoFontFamily&&(e["--semaphor-mono-font-family"]=o.monoFontFamily),(o==null?void 0:o.baseFontSize)!==void 0&&(e["--semaphor-font-size"]=`${o.baseFontSize}px`)}function T(e,o){e["--semaphor-brand"]=e["--semaphor-primary"]??e["--semaphor-foreground"],e["--semaphor-secondary"]=e["--semaphor-accent"]??e["--semaphor-muted"],e["--semaphor-secondary-foreground"]=e["--semaphor-accent-foreground"]??e["--semaphor-foreground"],e["--semaphor-popover"]=e["--semaphor-card"]??e["--semaphor-background"],e["--semaphor-popover-foreground"]=e["--semaphor-card-foreground"]??e["--semaphor-foreground"],e["--semaphor-ring"]=e["--semaphor-primary"]??e["--semaphor-foreground"];const n=S((o==null?void 0:o.control)??5),r=S((o==null?void 0:o.card)??(o==null?void 0:o.control)??5);e["--semaphor-radius"]=n,e["--semaphor-control-radius"]=n,e["--semaphor-card-radius"]=r}function S(e){return`${Number((e/16).toFixed(4))}rem`}function x(e,o="light"){return e==="system"?o:e}const z=_({spec:d.resolveAppearance(),mode:"light"}),v=C.createContext(P("semaphor-default-appearance",z));function L(){return C.useContext(v)}function P(e,o){return{instanceId:e,compiledAppearance:o,scopeProps:M(e,o),portalSnapshot:{instanceId:e,compiledAppearance:o}}}function M(e,o){return{className:o.mode,style:w(o),"data-semaphor-theme":o.mode,"data-semaphor-appearance-instance":e}}function w(e){var t,a;const o={colorScheme:e.mode};e.cssVariables["--semaphor-font-family"]&&(o.fontFamily="var(--semaphor-font-family)");const r=(t=e.scheme.tokens)==null?void 0:t.typography,m=(a=d.SEMAPHOR_DEFAULT_APPEARANCE_SPEC.schemes[e.mode].tokens)==null?void 0:a.typography;(r==null?void 0:r.baseFontSize)!==void 0&&r.baseFontSize!==(m==null?void 0:m.baseFontSize)&&(o.fontSize=r.baseFontSize);for(const[c,s]of Object.entries(e.cssVariables))o[c]=s;return o}exports.APPEARANCE_COLOR_CSS_VARS=E;exports.AppearanceContext=v;exports.compileAppearance=_;exports.createAppearanceContextValue=P;exports.useAppearance=L;
|