@sentropic/dataviz-svelte 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CrossfilteredBarChart.svelte +80 -0
- package/dist/CrossfilteredBarChart.svelte.d.ts +32 -0
- package/dist/CrossfilteredBarChart.svelte.d.ts.map +1 -0
- package/dist/CrossfilteredBarChart.test.js +63 -0
- package/dist/DashboardFilterBar.svelte +51 -0
- package/dist/DashboardFilterBar.svelte.d.ts +14 -0
- package/dist/DashboardFilterBar.svelte.d.ts.map +1 -0
- package/dist/DashboardFilterBar.test.js +59 -0
- package/dist/DrillBarChart.svelte +83 -0
- package/dist/DrillBarChart.svelte.d.ts +23 -0
- package/dist/DrillBarChart.svelte.d.ts.map +1 -0
- package/dist/DrillBarChart.test.js +52 -0
- package/dist/DrillBreadcrumb.svelte +57 -0
- package/dist/DrillBreadcrumb.svelte.d.ts +18 -0
- package/dist/DrillBreadcrumb.svelte.d.ts.map +1 -0
- package/dist/DrillBreadcrumb.test.js +37 -0
- package/dist/FieldPane.svelte +38 -0
- package/dist/FieldPane.svelte.d.ts +14 -0
- package/dist/FieldPane.svelte.d.ts.map +1 -0
- package/dist/FieldPane.test.js +36 -0
- package/dist/KpiCardGroup.svelte +63 -0
- package/dist/KpiCardGroup.svelte.d.ts +17 -0
- package/dist/KpiCardGroup.svelte.d.ts.map +1 -0
- package/dist/KpiCardGroup.test.js +33 -0
- package/dist/PivotDataTable.svelte +62 -0
- package/dist/PivotDataTable.svelte.d.ts +15 -0
- package/dist/PivotDataTable.svelte.d.ts.map +1 -0
- package/dist/PivotDataTable.test.js +37 -0
- package/dist/RecordsTable.svelte +53 -0
- package/dist/RecordsTable.svelte.d.ts +17 -0
- package/dist/RecordsTable.svelte.d.ts.map +1 -0
- package/dist/RecordsTable.test.js +43 -0
- package/dist/SelectionLegend.svelte +42 -0
- package/dist/SelectionLegend.svelte.d.ts +14 -0
- package/dist/SelectionLegend.svelte.d.ts.map +1 -0
- package/dist/SelectionLegend.test.js +47 -0
- package/dist/SmallMultiples.svelte +81 -0
- package/dist/SmallMultiples.svelte.d.ts +25 -0
- package/dist/SmallMultiples.svelte.d.ts.map +1 -0
- package/dist/SmallMultiples.test.js +47 -0
- package/package.json +21 -9
- package/dist/index.d.ts +0 -41
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -42
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { render } from '@testing-library/svelte';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import { createDashboardStore } from '@sentropic/dataviz-core';
|
|
4
|
+
import SmallMultiples from './SmallMultiples.svelte';
|
|
5
|
+
const model = {
|
|
6
|
+
dimensions: [
|
|
7
|
+
{ id: 'region', label: 'Région', type: 'discrete' },
|
|
8
|
+
{ id: 'product', label: 'Produit', type: 'discrete' },
|
|
9
|
+
],
|
|
10
|
+
measures: [{ id: 'sales', label: 'Ventes', aggregation: 'sum' }],
|
|
11
|
+
};
|
|
12
|
+
const data = [
|
|
13
|
+
{ region: 'Nord', product: 'A', sales: 10 },
|
|
14
|
+
{ region: 'Nord', product: 'B', sales: 5 },
|
|
15
|
+
{ region: 'Sud', product: 'A', sales: 20 },
|
|
16
|
+
];
|
|
17
|
+
const newStore = () => createDashboardStore({ model, data });
|
|
18
|
+
const base = { viewId: 'sm', facetBy: 'region', dimension: 'product', measure: 'sales', label: 'Ventes par produit' };
|
|
19
|
+
describe('SmallMultiples', () => {
|
|
20
|
+
it('renders the facet group with its aria-label', () => {
|
|
21
|
+
const { getByRole } = render(SmallMultiples, { props: { store: newStore(), ...base } });
|
|
22
|
+
expect(getByRole('group', { name: 'Ventes par produit' })).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
it('renders one facet chart per distinct facetBy value, labelled by facet', () => {
|
|
25
|
+
const { getAllByRole } = render(SmallMultiples, { props: { store: newStore(), ...base } });
|
|
26
|
+
const charts = getAllByRole('img');
|
|
27
|
+
expect(charts).toHaveLength(2);
|
|
28
|
+
expect(charts.map((c) => c.getAttribute('aria-label'))).toEqual([
|
|
29
|
+
'Ventes par produit — Nord',
|
|
30
|
+
'Ventes par produit — Sud',
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
it('shares one value domain across facets (the Nord facet shows the global max 20)', () => {
|
|
34
|
+
const { container } = render(SmallMultiples, { props: { store: newStore(), ...base } });
|
|
35
|
+
const charts = container.querySelectorAll('.st-barChart');
|
|
36
|
+
expect(charts).toHaveLength(2);
|
|
37
|
+
const nordTicks = Array.from(charts[0].querySelectorAll('.st-barChart__tickLabel')).map((t) => t.textContent?.trim());
|
|
38
|
+
// Without a shared domain the Nord facet (own max 10) would top out at 10.
|
|
39
|
+
expect(nordTicks).toContain('20');
|
|
40
|
+
});
|
|
41
|
+
it('renders no facets when the facet dimension is unknown', () => {
|
|
42
|
+
const { container } = render(SmallMultiples, {
|
|
43
|
+
props: { store: newStore(), ...base, facetBy: 'nope' },
|
|
44
|
+
});
|
|
45
|
+
expect(container.querySelectorAll('.st-barChart')).toHaveLength(0);
|
|
46
|
+
});
|
|
47
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/dataviz-svelte",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Svelte 5 adapter for @sentropic/dataviz-core, built on @sentropic/design-system-svelte.",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Svelte 5 adapter + dashboard components for @sentropic/dataviz-core, built on @sentropic/design-system-svelte.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -12,28 +12,40 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
|
+
"svelte": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
15
17
|
"exports": {
|
|
16
18
|
".": {
|
|
19
|
+
"svelte": "./dist/index.js",
|
|
17
20
|
"types": "./dist/index.d.ts",
|
|
18
21
|
"import": "./dist/index.js"
|
|
19
22
|
}
|
|
20
23
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"**/*.css"
|
|
26
|
+
],
|
|
24
27
|
"scripts": {
|
|
25
|
-
"build": "
|
|
26
|
-
"check": "
|
|
28
|
+
"build": "svelte-package",
|
|
29
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
27
30
|
"test": "vitest run src"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@sentropic/dataviz-core": "0.
|
|
31
|
-
"@sentropic/design-system-svelte": "0.
|
|
33
|
+
"@sentropic/dataviz-core": "0.2.0",
|
|
34
|
+
"@sentropic/design-system-svelte": "0.23.0",
|
|
32
35
|
"@sentropic/design-system-themes": "0.11.0"
|
|
33
36
|
},
|
|
34
37
|
"peerDependencies": {
|
|
35
38
|
"svelte": "^5"
|
|
36
39
|
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@sveltejs/package": "^2.5.8",
|
|
42
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
43
|
+
"@testing-library/svelte": "^5.3.1",
|
|
44
|
+
"svelte": "^5.56.2",
|
|
45
|
+
"svelte-check": "^4.0.0",
|
|
46
|
+
"vite": "^8.0.16",
|
|
47
|
+
"vitest": "^4.1.5"
|
|
48
|
+
},
|
|
37
49
|
"publishConfig": {
|
|
38
50
|
"access": "public"
|
|
39
51
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sentropic/dataviz-svelte
|
|
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.
|
|
8
|
-
*/
|
|
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>;
|
|
41
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sentropic/dataviz-svelte
|
|
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.
|
|
8
|
-
*/
|
|
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
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,GAIrB,MAAM,yBAAyB,CAAC;AAEjC,qEAAqE;AACrE,cAAc,yBAAyB,CAAC;AAaxC;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,OAAO;QACL,SAAS,CAAC,GAAoC;YAC5C,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACtB,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC;AAUD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAA4B;IAC1D,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqB;IAChD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|