@sentropic/dataviz-svelte 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/adapter.d.ts +39 -0
  2. package/dist/adapter.d.ts.map +1 -0
  3. package/dist/adapter.js +39 -0
  4. package/dist/index.d.ts +32 -36
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +21 -38
  7. package/dist/lib/CrossfilteredBarChart.svelte +80 -0
  8. package/dist/lib/CrossfilteredBarChart.svelte.d.ts +32 -0
  9. package/dist/lib/CrossfilteredBarChart.svelte.d.ts.map +1 -0
  10. package/dist/lib/DashboardFilterBar.svelte +51 -0
  11. package/dist/lib/DashboardFilterBar.svelte.d.ts +14 -0
  12. package/dist/lib/DashboardFilterBar.svelte.d.ts.map +1 -0
  13. package/dist/lib/DrillBarChart.svelte +83 -0
  14. package/dist/lib/DrillBarChart.svelte.d.ts +23 -0
  15. package/dist/lib/DrillBarChart.svelte.d.ts.map +1 -0
  16. package/dist/lib/DrillBreadcrumb.svelte +57 -0
  17. package/dist/lib/DrillBreadcrumb.svelte.d.ts +18 -0
  18. package/dist/lib/DrillBreadcrumb.svelte.d.ts.map +1 -0
  19. package/dist/lib/ExportMenu.svelte +74 -0
  20. package/dist/lib/ExportMenu.svelte.d.ts +23 -0
  21. package/dist/lib/ExportMenu.svelte.d.ts.map +1 -0
  22. package/dist/lib/FieldPane.svelte +38 -0
  23. package/dist/lib/FieldPane.svelte.d.ts +14 -0
  24. package/dist/lib/FieldPane.svelte.d.ts.map +1 -0
  25. package/dist/lib/KpiCardGroup.svelte +63 -0
  26. package/dist/lib/KpiCardGroup.svelte.d.ts +17 -0
  27. package/dist/lib/KpiCardGroup.svelte.d.ts.map +1 -0
  28. package/dist/lib/PivotDataTable.svelte +62 -0
  29. package/dist/lib/PivotDataTable.svelte.d.ts +15 -0
  30. package/dist/lib/PivotDataTable.svelte.d.ts.map +1 -0
  31. package/dist/lib/RecordsTable.svelte +53 -0
  32. package/dist/lib/RecordsTable.svelte.d.ts +17 -0
  33. package/dist/lib/RecordsTable.svelte.d.ts.map +1 -0
  34. package/dist/lib/SelectionLegend.svelte +42 -0
  35. package/dist/lib/SelectionLegend.svelte.d.ts +14 -0
  36. package/dist/lib/SelectionLegend.svelte.d.ts.map +1 -0
  37. package/dist/lib/SmallMultiples.svelte +81 -0
  38. package/dist/lib/SmallMultiples.svelte.d.ts +25 -0
  39. package/dist/lib/SmallMultiples.svelte.d.ts.map +1 -0
  40. package/dist/lib/TopNFilter.svelte +51 -0
  41. package/dist/lib/TopNFilter.svelte.d.ts +18 -0
  42. package/dist/lib/TopNFilter.svelte.d.ts.map +1 -0
  43. package/dist/lib/ValueSlicer.svelte +59 -0
  44. package/dist/lib/ValueSlicer.svelte.d.ts +15 -0
  45. package/dist/lib/ValueSlicer.svelte.d.ts.map +1 -0
  46. package/package.json +21 -9
  47. package/dist/index.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Svelte 5 adapter for the framework-agnostic dataviz-core store. It bridges the
3
+ * core's `getState`/`subscribe` contract onto Svelte's `Readable` store contract
4
+ * so the dashboard state can be consumed with `$store` syntax. All presentation
5
+ * comes from `@sentropic/design-system-svelte`; this module only wires state.
6
+ */
7
+ import { type DashboardState, type DashboardStore, type DashboardStoreConfig } from '@sentropic/dataviz-core';
8
+ export * from '@sentropic/dataviz-core';
9
+ export type { BarChartTone } from '@sentropic/design-system-svelte';
10
+ export type { TenantTheme } from '@sentropic/design-system-themes';
11
+ /** Minimal Svelte `Readable` contract (avoids a hard dep on `svelte/store`). */
12
+ export interface SvelteReadable<T> {
13
+ subscribe(run: (value: T) => void): () => void;
14
+ }
15
+ /**
16
+ * Wrap a core {@link DashboardStore} as a Svelte `Readable<DashboardState>`.
17
+ *
18
+ * Following the Svelte store contract, `subscribe(run)` calls `run` immediately
19
+ * with the current state, then again after every core notification, and returns
20
+ * an unsubscribe function.
21
+ */
22
+ export declare function toSvelteStore(store: DashboardStore): SvelteReadable<DashboardState>;
23
+ /** Result of {@link createDashboard}: the core store plus its Svelte view. */
24
+ export interface SvelteDashboard {
25
+ /** The underlying core store (use its mutators: setFilter, toggleSelection…). */
26
+ store: DashboardStore;
27
+ /** Svelte-readable snapshot, usable with `$state` in a component. */
28
+ state: SvelteReadable<DashboardState>;
29
+ }
30
+ /**
31
+ * Create a dashboard store and its Svelte-readable view in one call.
32
+ */
33
+ export declare function createDashboard(config: DashboardStoreConfig): SvelteDashboard;
34
+ /**
35
+ * Canonical adapter hook (parity with React/Vue `useDashboard`).
36
+ * Returns the Svelte-readable state for a given core store.
37
+ */
38
+ export declare function useDashboard(store: DashboardStore): SvelteReadable<DashboardState>;
39
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AAIxC,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,gFAAgF;AAChF,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAChD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,CAQnF;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,KAAK,EAAE,cAAc,CAAC;IACtB,qEAAqE;IACrE,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,eAAe,CAG7E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,CAElF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Svelte 5 adapter for the framework-agnostic dataviz-core store. It bridges the
3
+ * core's `getState`/`subscribe` contract onto Svelte's `Readable` store contract
4
+ * so the dashboard state can be consumed with `$store` syntax. All presentation
5
+ * comes from `@sentropic/design-system-svelte`; this module only wires state.
6
+ */
7
+ import { createDashboardStore, } from '@sentropic/dataviz-core';
8
+ // Re-export the full core surface so consumers need a single import.
9
+ export * from '@sentropic/dataviz-core';
10
+ /**
11
+ * Wrap a core {@link DashboardStore} as a Svelte `Readable<DashboardState>`.
12
+ *
13
+ * Following the Svelte store contract, `subscribe(run)` calls `run` immediately
14
+ * with the current state, then again after every core notification, and returns
15
+ * an unsubscribe function.
16
+ */
17
+ export function toSvelteStore(store) {
18
+ return {
19
+ subscribe(run) {
20
+ run(store.getState());
21
+ const off = store.subscribe(() => run(store.getState()));
22
+ return off;
23
+ },
24
+ };
25
+ }
26
+ /**
27
+ * Create a dashboard store and its Svelte-readable view in one call.
28
+ */
29
+ export function createDashboard(config) {
30
+ const store = createDashboardStore(config);
31
+ return { store, state: toSvelteStore(store) };
32
+ }
33
+ /**
34
+ * Canonical adapter hook (parity with React/Vue `useDashboard`).
35
+ * Returns the Svelte-readable state for a given core store.
36
+ */
37
+ export function useDashboard(store) {
38
+ return toSvelteStore(store);
39
+ }
package/dist/index.d.ts CHANGED
@@ -1,41 +1,37 @@
1
1
  /**
2
2
  * @sentropic/dataviz-svelte
3
3
  *
4
- * Svelte 5 adapter for the framework-agnostic dataviz-core store. It bridges the
5
- * core's `getState`/`subscribe` contract onto Svelte's `Readable` store contract
6
- * so the dashboard state can be consumed with `$store` syntax. All presentation
7
- * comes from `@sentropic/design-system-svelte`; this package only wires state.
4
+ * Svelte 5 adapter + dashboard components for @sentropic/dataviz-core, built on
5
+ * @sentropic/design-system-svelte. The adapter wires the core's observable store
6
+ * onto Svelte reactivity; the components compose design-system presentational
7
+ * pieces and bind them to the shared dashboard state. No presentation is
8
+ * authored here — it all comes from the design system.
8
9
  */
9
- import { type DashboardState, type DashboardStore, type DashboardStoreConfig } from '@sentropic/dataviz-core';
10
- export * from '@sentropic/dataviz-core';
11
- export type { BarChartTone } from '@sentropic/design-system-svelte';
12
- export type { TenantTheme } from '@sentropic/design-system-themes';
13
- /** Minimal Svelte `Readable` contract (avoids a hard dep on `svelte/store`). */
14
- export interface SvelteReadable<T> {
15
- subscribe(run: (value: T) => void): () => void;
16
- }
17
- /**
18
- * Wrap a core {@link DashboardStore} as a Svelte `Readable<DashboardState>`.
19
- *
20
- * Following the Svelte store contract, `subscribe(run)` calls `run` immediately
21
- * with the current state, then again after every core notification, and returns
22
- * an unsubscribe function.
23
- */
24
- export declare function toSvelteStore(store: DashboardStore): SvelteReadable<DashboardState>;
25
- /** Result of {@link createDashboard}: the core store plus its Svelte view. */
26
- export interface SvelteDashboard {
27
- /** The underlying core store (use its mutators: setFilter, toggleSelection…). */
28
- store: DashboardStore;
29
- /** Svelte-readable snapshot, usable with `$state` in a component. */
30
- state: SvelteReadable<DashboardState>;
31
- }
32
- /**
33
- * Create a dashboard store and its Svelte-readable view in one call.
34
- */
35
- export declare function createDashboard(config: DashboardStoreConfig): SvelteDashboard;
36
- /**
37
- * Canonical adapter hook (parity with React/Vue `useDashboard`).
38
- * Returns the Svelte-readable state for a given core store.
39
- */
40
- export declare function useDashboard(store: DashboardStore): SvelteReadable<DashboardState>;
10
+ export * from './adapter.js';
11
+ export { default as DashboardFilterBar } from './lib/DashboardFilterBar.svelte';
12
+ export type { DashboardFilterBarProps } from './lib/DashboardFilterBar.svelte';
13
+ export { default as SelectionLegend } from './lib/SelectionLegend.svelte';
14
+ export type { SelectionLegendProps } from './lib/SelectionLegend.svelte';
15
+ export { default as CrossfilteredBarChart } from './lib/CrossfilteredBarChart.svelte';
16
+ export type { CrossfilteredBarChartProps } from './lib/CrossfilteredBarChart.svelte';
17
+ export { default as SmallMultiples } from './lib/SmallMultiples.svelte';
18
+ export type { SmallMultiplesProps } from './lib/SmallMultiples.svelte';
19
+ export { default as FieldPane } from './lib/FieldPane.svelte';
20
+ export type { FieldPaneProps } from './lib/FieldPane.svelte';
21
+ export { default as PivotDataTable } from './lib/PivotDataTable.svelte';
22
+ export type { PivotDataTableProps } from './lib/PivotDataTable.svelte';
23
+ export { default as KpiCardGroup } from './lib/KpiCardGroup.svelte';
24
+ export type { KpiCardGroupProps } from './lib/KpiCardGroup.svelte';
25
+ export { default as RecordsTable } from './lib/RecordsTable.svelte';
26
+ export type { RecordsTableProps } from './lib/RecordsTable.svelte';
27
+ export { default as DrillBarChart } from './lib/DrillBarChart.svelte';
28
+ export type { DrillBarChartProps } from './lib/DrillBarChart.svelte';
29
+ export { default as DrillBreadcrumb } from './lib/DrillBreadcrumb.svelte';
30
+ export type { DrillBreadcrumbProps } from './lib/DrillBreadcrumb.svelte';
31
+ export { default as TopNFilter } from './lib/TopNFilter.svelte';
32
+ export type { TopNFilterProps } from './lib/TopNFilter.svelte';
33
+ export { default as ValueSlicer } from './lib/ValueSlicer.svelte';
34
+ export type { ValueSlicerProps } from './lib/ValueSlicer.svelte';
35
+ export { default as ExportMenu, rowsToCsv } from './lib/ExportMenu.svelte';
36
+ export type { ExportMenuProps } from './lib/ExportMenu.svelte';
41
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,cAAc,yBAAyB,CAAC;AAIxC,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,gFAAgF;AAChF,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAChD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,CAQnF;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,KAAK,EAAE,cAAc,CAAC;IACtB,qEAAqE;IACrE,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,eAAe,CAG7E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,CAElF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AACtF,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,42 +1,25 @@
1
1
  /**
2
2
  * @sentropic/dataviz-svelte
3
3
  *
4
- * Svelte 5 adapter for the framework-agnostic dataviz-core store. It bridges the
5
- * core's `getState`/`subscribe` contract onto Svelte's `Readable` store contract
6
- * so the dashboard state can be consumed with `$store` syntax. All presentation
7
- * comes from `@sentropic/design-system-svelte`; this package only wires state.
4
+ * Svelte 5 adapter + dashboard components for @sentropic/dataviz-core, built on
5
+ * @sentropic/design-system-svelte. The adapter wires the core's observable store
6
+ * onto Svelte reactivity; the components compose design-system presentational
7
+ * pieces and bind them to the shared dashboard state. No presentation is
8
+ * authored here — it all comes from the design system.
8
9
  */
9
- import { createDashboardStore, } from '@sentropic/dataviz-core';
10
- // Re-export the full core surface so consumers need a single import.
11
- export * from '@sentropic/dataviz-core';
12
- /**
13
- * Wrap a core {@link DashboardStore} as a Svelte `Readable<DashboardState>`.
14
- *
15
- * Following the Svelte store contract, `subscribe(run)` calls `run` immediately
16
- * with the current state, then again after every core notification, and returns
17
- * an unsubscribe function.
18
- */
19
- export function toSvelteStore(store) {
20
- return {
21
- subscribe(run) {
22
- run(store.getState());
23
- const off = store.subscribe(() => run(store.getState()));
24
- return off;
25
- },
26
- };
27
- }
28
- /**
29
- * Create a dashboard store and its Svelte-readable view in one call.
30
- */
31
- export function createDashboard(config) {
32
- const store = createDashboardStore(config);
33
- return { store, state: toSvelteStore(store) };
34
- }
35
- /**
36
- * Canonical adapter hook (parity with React/Vue `useDashboard`).
37
- * Returns the Svelte-readable state for a given core store.
38
- */
39
- export function useDashboard(store) {
40
- return toSvelteStore(store);
41
- }
42
- //# sourceMappingURL=index.js.map
10
+ // Adapter + full core surface re-export (incl. the core's `describeFilterSpec`).
11
+ export * from './adapter.js';
12
+ // Dashboard components (state consumers built on the design system).
13
+ export { default as DashboardFilterBar } from './lib/DashboardFilterBar.svelte';
14
+ export { default as SelectionLegend } from './lib/SelectionLegend.svelte';
15
+ export { default as CrossfilteredBarChart } from './lib/CrossfilteredBarChart.svelte';
16
+ export { default as SmallMultiples } from './lib/SmallMultiples.svelte';
17
+ export { default as FieldPane } from './lib/FieldPane.svelte';
18
+ export { default as PivotDataTable } from './lib/PivotDataTable.svelte';
19
+ export { default as KpiCardGroup } from './lib/KpiCardGroup.svelte';
20
+ export { default as RecordsTable } from './lib/RecordsTable.svelte';
21
+ export { default as DrillBarChart } from './lib/DrillBarChart.svelte';
22
+ export { default as DrillBreadcrumb } from './lib/DrillBreadcrumb.svelte';
23
+ export { default as TopNFilter } from './lib/TopNFilter.svelte';
24
+ export { default as ValueSlicer } from './lib/ValueSlicer.svelte';
25
+ export { default as ExportMenu, rowsToCsv } from './lib/ExportMenu.svelte';
@@ -0,0 +1,80 @@
1
+ <script lang="ts" module>
2
+ import type { DashboardStore } from '@sentropic/dataviz-core';
3
+ import type { BarChartTone } from '@sentropic/design-system-svelte';
4
+
5
+ export type CrossfilteredBarChartProps = {
6
+ /** The dashboard store to bind to. */
7
+ store: DashboardStore;
8
+ /** This chart's view id in the cross-filter graph. */
9
+ viewId: string;
10
+ /** Dimension id to group rows by (one bar per distinct value). */
11
+ dimension: string;
12
+ /** Measure id to aggregate into each bar's value. */
13
+ measure: string;
14
+ /** Accessible label of the chart (required by the design-system BarChart). */
15
+ label: string;
16
+ /** Bar colour tone from the design system. */
17
+ tone?: BarChartTone;
18
+ /**
19
+ * When true (default) clicking a bar toggles this view's selection
20
+ * (brushing input → `store.toggleSelection`); selected bars are highlighted.
21
+ * Set false for an output-only facet.
22
+ */
23
+ selectable?: boolean;
24
+ /** Fixed value-axis domain `[min, max]` for a shared scale across facets. */
25
+ domain?: [number, number];
26
+ orientation?: 'vertical' | 'horizontal';
27
+ width?: number;
28
+ height?: number;
29
+ class?: string;
30
+ };
31
+ </script>
32
+
33
+ <script lang="ts">
34
+ import { BarChart, type BarChartDatum } from '@sentropic/design-system-svelte';
35
+ import { findDimension, findMeasure, groupAggregate } from '@sentropic/dataviz-core';
36
+ import { useDashboard } from '../adapter.js';
37
+
38
+ let {
39
+ store,
40
+ viewId,
41
+ dimension,
42
+ measure,
43
+ label,
44
+ tone,
45
+ selectable = true,
46
+ domain,
47
+ orientation = 'vertical',
48
+ width,
49
+ height,
50
+ class: className,
51
+ }: CrossfilteredBarChartProps = $props();
52
+
53
+ // `$dash` establishes the reactive dependency so the chart re-aggregates on
54
+ // every store mutation; the rows visible to this view come from the core
55
+ // cross-filter scope.
56
+ const dash = $derived(useDashboard(store));
57
+ const data = $derived.by((): BarChartDatum[] => {
58
+ void $dash;
59
+ const dim = findDimension(store.model, dimension);
60
+ const m = findMeasure(store.model, measure);
61
+ if (!dim || !m) return [];
62
+ const rows = store.applyCrossfilter(viewId);
63
+ return groupAggregate(rows, dimension, m).map(({ key, value }) =>
64
+ tone ? { label: key, value, tone } : { label: key, value },
65
+ );
66
+ });
67
+ const selectedKeys = $derived($dash.selections[viewId] ?? []);
68
+ </script>
69
+
70
+ <BarChart
71
+ {data}
72
+ {label}
73
+ {orientation}
74
+ {width}
75
+ {height}
76
+ {domain}
77
+ class={className}
78
+ selectedKeys={selectable ? selectedKeys : []}
79
+ onSelect={selectable ? (key) => store.toggleSelection(viewId, key) : undefined}
80
+ />
@@ -0,0 +1,32 @@
1
+ import type { DashboardStore } from '@sentropic/dataviz-core';
2
+ import type { BarChartTone } from '@sentropic/design-system-svelte';
3
+ export type CrossfilteredBarChartProps = {
4
+ /** The dashboard store to bind to. */
5
+ store: DashboardStore;
6
+ /** This chart's view id in the cross-filter graph. */
7
+ viewId: string;
8
+ /** Dimension id to group rows by (one bar per distinct value). */
9
+ dimension: string;
10
+ /** Measure id to aggregate into each bar's value. */
11
+ measure: string;
12
+ /** Accessible label of the chart (required by the design-system BarChart). */
13
+ label: string;
14
+ /** Bar colour tone from the design system. */
15
+ tone?: BarChartTone;
16
+ /**
17
+ * When true (default) clicking a bar toggles this view's selection
18
+ * (brushing input → `store.toggleSelection`); selected bars are highlighted.
19
+ * Set false for an output-only facet.
20
+ */
21
+ selectable?: boolean;
22
+ /** Fixed value-axis domain `[min, max]` for a shared scale across facets. */
23
+ domain?: [number, number];
24
+ orientation?: 'vertical' | 'horizontal';
25
+ width?: number;
26
+ height?: number;
27
+ class?: string;
28
+ };
29
+ declare const CrossfilteredBarChart: import("svelte").Component<CrossfilteredBarChartProps, {}, "">;
30
+ type CrossfilteredBarChart = ReturnType<typeof CrossfilteredBarChart>;
31
+ export default CrossfilteredBarChart;
32
+ //# sourceMappingURL=CrossfilteredBarChart.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CrossfilteredBarChart.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/CrossfilteredBarChart.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,MAAM,0BAA0B,GAAG;IACvC,sCAAsC;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkDJ,QAAA,MAAM,qBAAqB,gEAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,51 @@
1
+ <script lang="ts" module>
2
+ import type { DashboardStore } from '@sentropic/dataviz-core';
3
+
4
+ export type DashboardFilterBarProps = {
5
+ /** The dashboard store to bind to. */
6
+ store: DashboardStore;
7
+ /** Aria-label of the filter group. */
8
+ label?: string;
9
+ /** Label of the "clear all" button (design-system default otherwise). */
10
+ clearAllLabel?: string;
11
+ class?: string;
12
+ };
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ import { FilterBar, FilterPill } from '@sentropic/design-system-svelte';
17
+ import { findDimension, describeFilterSpec } from '@sentropic/dataviz-core';
18
+ import { useDashboard } from '../adapter.js';
19
+
20
+ let {
21
+ store,
22
+ label = 'Filtres actifs',
23
+ clearAllLabel,
24
+ class: className,
25
+ }: DashboardFilterBarProps = $props();
26
+
27
+ // `store` is read inside `$derived` (a reactive context) so the readable is
28
+ // re-created if the prop changes; `$dash` auto-subscribes (SSR-safe).
29
+ const dash = $derived(useDashboard(store));
30
+ const entries = $derived(Object.entries($dash.filters));
31
+ </script>
32
+
33
+ <FilterBar
34
+ {label}
35
+ {clearAllLabel}
36
+ class={className}
37
+ onClearAll={entries.length > 0
38
+ ? () => {
39
+ for (const id of Object.keys($dash.filters)) store.clearFilter(id);
40
+ }
41
+ : undefined}
42
+ >
43
+ {#each entries as [dimensionId, spec] (dimensionId)}
44
+ {@const dimension = findDimension(store.model, dimensionId)}
45
+ <FilterPill
46
+ field={dimension?.label ?? dimensionId}
47
+ value={describeFilterSpec(spec, dimension)}
48
+ onRemove={() => store.clearFilter(dimensionId)}
49
+ />
50
+ {/each}
51
+ </FilterBar>
@@ -0,0 +1,14 @@
1
+ import type { DashboardStore } from '@sentropic/dataviz-core';
2
+ export type DashboardFilterBarProps = {
3
+ /** The dashboard store to bind to. */
4
+ store: DashboardStore;
5
+ /** Aria-label of the filter group. */
6
+ label?: string;
7
+ /** Label of the "clear all" button (design-system default otherwise). */
8
+ clearAllLabel?: string;
9
+ class?: string;
10
+ };
11
+ declare const DashboardFilterBar: import("svelte").Component<DashboardFilterBarProps, {}, "">;
12
+ type DashboardFilterBar = ReturnType<typeof DashboardFilterBar>;
13
+ export default DashboardFilterBar;
14
+ //# sourceMappingURL=DashboardFilterBar.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardFilterBar.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/DashboardFilterBar.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG;IACpC,sCAAsC;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAwCJ,QAAA,MAAM,kBAAkB,6DAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,83 @@
1
+ <script lang="ts" module>
2
+ import type { DashboardStore } from '@sentropic/dataviz-core';
3
+ import type { BarChartTone } from '@sentropic/design-system-svelte';
4
+
5
+ export type DrillBarChartProps = {
6
+ /** The dashboard store to bind to. */
7
+ store: DashboardStore;
8
+ /** This view's id (drill state + cross-filter scope live under it). */
9
+ viewId: string;
10
+ /** Ordered dimension hierarchy; bars group by the current drill level. */
11
+ hierarchy: string[];
12
+ /** Measure id aggregated into each bar's value. */
13
+ measure: string;
14
+ /** Accessible label of the chart. */
15
+ label: string;
16
+ tone?: BarChartTone;
17
+ orientation?: 'vertical' | 'horizontal';
18
+ width?: number;
19
+ height?: number;
20
+ class?: string;
21
+ };
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import { BarChart, type BarChartDatum } from '@sentropic/design-system-svelte';
26
+ import { findMeasure, groupAggregate } from '@sentropic/dataviz-core';
27
+ import { useDashboard } from '../adapter.js';
28
+
29
+ let {
30
+ store,
31
+ viewId,
32
+ hierarchy,
33
+ measure,
34
+ label,
35
+ tone,
36
+ orientation = 'vertical',
37
+ width,
38
+ height,
39
+ class: className,
40
+ }: DrillBarChartProps = $props();
41
+
42
+ const dash = $derived(useDashboard(store));
43
+ // Current depth = length of the drill path, capped at the deepest level.
44
+ const level = $derived(
45
+ Math.min(($dash.drill[viewId] ?? []).length, Math.max(hierarchy.length - 1, 0)),
46
+ );
47
+ const currentDim = $derived(hierarchy[level]);
48
+ const canDrill = $derived(level < hierarchy.length - 1);
49
+
50
+ const data = $derived.by((): BarChartDatum[] => {
51
+ void $dash;
52
+ const m = findMeasure(store.model, measure);
53
+ if (!m || !currentDim) return [];
54
+ return groupAggregate(store.applyCrossfilter(viewId), currentDim, m).map(({ key, value }) =>
55
+ tone ? { label: key, value, tone } : { label: key, value },
56
+ );
57
+ });
58
+
59
+ const selectedKeys = $derived($dash.selections[viewId] ?? []);
60
+
61
+ // Clicking a bar drills one level deeper (filter the clicked value, push the
62
+ // next hierarchy dimension as group-by). At the deepest level there is nowhere
63
+ // to drill, so a click toggles this view's selection (brushing) instead.
64
+ function onSelect(key: string) {
65
+ if (canDrill) {
66
+ store.setFilter(currentDim, { kind: 'include', values: [key] });
67
+ store.drillDown(viewId, hierarchy[level + 1]);
68
+ } else {
69
+ store.toggleSelection(viewId, key);
70
+ }
71
+ }
72
+ </script>
73
+
74
+ <BarChart
75
+ {data}
76
+ {label}
77
+ {orientation}
78
+ {width}
79
+ {height}
80
+ class={className}
81
+ selectedKeys={canDrill ? [] : selectedKeys}
82
+ {onSelect}
83
+ />
@@ -0,0 +1,23 @@
1
+ import type { DashboardStore } from '@sentropic/dataviz-core';
2
+ import type { BarChartTone } from '@sentropic/design-system-svelte';
3
+ export type DrillBarChartProps = {
4
+ /** The dashboard store to bind to. */
5
+ store: DashboardStore;
6
+ /** This view's id (drill state + cross-filter scope live under it). */
7
+ viewId: string;
8
+ /** Ordered dimension hierarchy; bars group by the current drill level. */
9
+ hierarchy: string[];
10
+ /** Measure id aggregated into each bar's value. */
11
+ measure: string;
12
+ /** Accessible label of the chart. */
13
+ label: string;
14
+ tone?: BarChartTone;
15
+ orientation?: 'vertical' | 'horizontal';
16
+ width?: number;
17
+ height?: number;
18
+ class?: string;
19
+ };
20
+ declare const DrillBarChart: import("svelte").Component<DrillBarChartProps, {}, "">;
21
+ type DrillBarChart = ReturnType<typeof DrillBarChart>;
22
+ export default DrillBarChart;
23
+ //# sourceMappingURL=DrillBarChart.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrillBarChart.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/DrillBarChart.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sCAAsC;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA+DJ,QAAA,MAAM,aAAa,wDAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,57 @@
1
+ <script lang="ts" module>
2
+ import type { DashboardStore } from '@sentropic/dataviz-core';
3
+
4
+ export type DrillBreadcrumbProps = {
5
+ /** The dashboard store to bind to. */
6
+ store: DashboardStore;
7
+ /** This view's id (must match the DrillBarChart it accompanies). */
8
+ viewId: string;
9
+ /** The same ordered dimension hierarchy used by the DrillBarChart. */
10
+ hierarchy: string[];
11
+ /** Aria-label of the breadcrumb trail. */
12
+ label?: string;
13
+ /** Label of the "go up one level" button. */
14
+ backLabel?: string;
15
+ class?: string;
16
+ };
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import { Breadcrumb, Button, Inline } from '@sentropic/design-system-svelte';
21
+ import { findDimension } from '@sentropic/dataviz-core';
22
+ import { useDashboard } from '../adapter.js';
23
+
24
+ let {
25
+ store,
26
+ viewId,
27
+ hierarchy,
28
+ label = 'Chemin de drill',
29
+ backLabel = 'Remonter',
30
+ class: className,
31
+ }: DrillBreadcrumbProps = $props();
32
+
33
+ const dash = $derived(useDashboard(store));
34
+ const path = $derived($dash.drill[viewId] ?? []);
35
+ const dimLabel = (id: string) => findDimension(store.model, id)?.label ?? id;
36
+ const items = $derived(
37
+ hierarchy
38
+ .slice(0, path.length + 1)
39
+ .map((dim, i) => ({ label: dimLabel(dim), current: i === path.length })),
40
+ );
41
+
42
+ // Going up pops the drill path and clears the value-filter that was applied
43
+ // when drilling away from the level we are returning to (see DrillBarChart).
44
+ function back() {
45
+ const p = store.getState().drill[viewId] ?? [];
46
+ if (p.length === 0) return;
47
+ store.drillUp(viewId);
48
+ store.clearFilter(hierarchy[p.length - 1]);
49
+ }
50
+ </script>
51
+
52
+ <Inline gap={2} class={className}>
53
+ <Breadcrumb {items} {label} />
54
+ {#if path.length > 0}
55
+ <Button variant="ghost" onclick={back}>{backLabel}</Button>
56
+ {/if}
57
+ </Inline>
@@ -0,0 +1,18 @@
1
+ import type { DashboardStore } from '@sentropic/dataviz-core';
2
+ export type DrillBreadcrumbProps = {
3
+ /** The dashboard store to bind to. */
4
+ store: DashboardStore;
5
+ /** This view's id (must match the DrillBarChart it accompanies). */
6
+ viewId: string;
7
+ /** The same ordered dimension hierarchy used by the DrillBarChart. */
8
+ hierarchy: string[];
9
+ /** Aria-label of the breadcrumb trail. */
10
+ label?: string;
11
+ /** Label of the "go up one level" button. */
12
+ backLabel?: string;
13
+ class?: string;
14
+ };
15
+ declare const DrillBreadcrumb: import("svelte").Component<DrillBreadcrumbProps, {}, "">;
16
+ type DrillBreadcrumb = ReturnType<typeof DrillBreadcrumb>;
17
+ export default DrillBreadcrumb;
18
+ //# sourceMappingURL=DrillBreadcrumb.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrillBreadcrumb.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/DrillBreadcrumb.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,sCAAsC;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAmDJ,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}