em-kit 0.1.0 → 0.1.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.
- package/README.md +41 -103
- package/dist/build.js +2 -2
- package/dist/chunks/{pies.utils-CneQQ7wE.js → pies.utils-CMMo-SlI.js} +2 -3
- package/dist/chunks/pies.utils-CMMo-SlI.js.map +1 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/pies.utils-CneQQ7wE.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,126 +4,64 @@ Finished React chart, KPI and table components by [Embeddable](https://embeddabl
|
|
|
4
4
|
|
|
5
5
|
EmKit is Embeddable’s chart components as a standalone React library: you bring the data. Inside Embeddable the same components are called Remarkable Pro. [Embeddable](https://embeddable.com) adds the data layer, multi-tenant security and self-serve dashboards for your customers.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Commands
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm run sync # fetch and regenerate src/generated from remarkable-pro origin/main, then the exports and props reference
|
|
13
|
-
npm run exports # regenerate src/components.generated.ts from the component manifest
|
|
14
|
-
npm run types:check # drift alarm: fails if upstream starts using an Embeddable API the shim lacks
|
|
15
|
-
npm run test # smoke tests: every exported component × every data state × en/de
|
|
16
|
-
npm run check # all three
|
|
17
|
-
npm run dev # docs site on http://localhost:5310
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Build the site
|
|
7
|
+
## Install
|
|
21
8
|
|
|
22
9
|
```bash
|
|
23
|
-
npm
|
|
24
|
-
npm run site:check # the same, then asserts every page (one h1, title, canonical, Markdown link, install command)
|
|
25
|
-
npm run site:preview # serves dist-site/ on http://localhost:5311 (404.html with a 404 status for unknown paths)
|
|
10
|
+
npm install em-kit
|
|
26
11
|
```
|
|
27
12
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
The host must serve `dist-site/404.html` with a 404 status for unknown paths (Netlify and Cloudflare Pages do this on their own). Playgrounds (`/docs/components/<slug>/playground[/<preset>]`) are rendered in the browser, so also serve `404.html` for them (`_redirects` rewrites them to it with a 200), and the page script then draws the playground. The pages load with `createRoot`, which replaces the prerendered HTML; `hydrateRoot` reports text mismatches (React error 418) on every page today.
|
|
31
|
-
|
|
32
|
-
## Docs site (`site/`)
|
|
33
|
-
|
|
34
|
-
A landing page, the docs (shadcn-style: sidebar, page, "On this page", ⌘K search), the chart gallery with a playground per chart, and the examples. Path-routed (`site/router.ts`), so every page has a real URL: `/`, `/docs/<guide>`, `/docs/components`, `/docs/components/<id>`, `/charts`, `/charts/<id>[/<preset>]` (playground), `/examples`, `/examples/ai-chat`. Old `#/…` links and aliases rewrite to their canonical path on load. The host must serve `index.html` for unknown paths (Vite does in dev).
|
|
13
|
+
React 19.1.1 or later is the only peer dependency. There is no stylesheet to import. The package is ESM only.
|
|
35
14
|
|
|
36
|
-
|
|
15
|
+
## Quick start
|
|
37
16
|
|
|
38
|
-
|
|
39
|
-
|---|---|
|
|
40
|
-
| `site/docs/guides.ts` | Every guide page as blocks (headings, Markdown prose, code, live demos), including "Why EmKit" and its comparison with a raw chart library. |
|
|
41
|
-
| `site/docs/components.ts` | Per component, derived from the registry and generated props: its examples (presets, an "Other" bucket where supported, loading/empty/error), what it does for you, and its Markdown. |
|
|
42
|
-
| `site/docs/nav.ts` | The sidebar and the ⌘K search index. |
|
|
43
|
-
| `site/pages/DocPage.tsx`, `ComponentDocPage.tsx`, `ComponentsIndex.tsx` | The guide, component and components-index pages. |
|
|
17
|
+
Wrap your app in `ChartsProvider` once, then describe your data and render a chart.
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
| `site/config.ts` | Brand and package name. Rename here. |
|
|
48
|
-
| `site/catalog/registry.tsx` | One entry per chart: the props it takes and which toggles it exposes. The live preview and the Code tab are both generated from `props(ctx)`, so they can't drift apart. |
|
|
49
|
-
| `site/catalog/build.ts` | Turns an entry and the current settings into render props and a copy-pasteable snippet. |
|
|
50
|
-
| `site/catalog/datasets.ts` | Three seeded sample datasets (SaaS, web, retail), re-aggregated per granularity like a real query. |
|
|
51
|
-
| `site/catalog/themes.ts` | Theme presets (Default, Ocean, Forest, Midnight) and languages. |
|
|
52
|
-
| `site/generated/props.ts` | Every public component's props, extracted from the types by `scripts/props.mjs` (runs with `npm run sync`). Chart pages turn it into live controls: scalar props get inputs that update the preview and the generated code together, data-bound props and handlers show as chips. `site/catalog/propNotes.ts` holds the hand-written one-liner per prop name, shown on hover. |
|
|
53
|
-
| `site/pages/` | Landing, Gallery, ChartPage (the playground: preview, code, data, props and event log), the docs pages above, Examples (one tab per complete app). |
|
|
54
|
-
| `site/components/HeroShowcase.tsx` | The landing page's one visual: the same components on a live dashboard and in an AI chat, fed by one `useLiveSeries` stream. A nested `ChartsProvider` scopes a single-hue colour ramp to both, so a value is the same colour on either surface. |
|
|
55
|
-
| `site/components/DemoDashboard.tsx` | The dashboard example: five components cross-filtered by one donut click, with a granularity switcher and a controlled table. `site/pages/Examples.tsx` shows the standalone version of this source; keep the two in step. |
|
|
56
|
-
| `site/components/ChatDemo.tsx`, `SpecPlayground.tsx` | The AI chat example: the mock chat (click → intent → next chart) and the paste-a-spec playground. |
|
|
57
|
-
| `site/catalog/aiSnippets.ts` | The single source for every AI code sample on the site. |
|
|
58
|
-
| `site/catalog/benefits.ts` | The full benefit list on the landing page (ten groups, the last full-width for AI chat). Each point says what the library does, not what you still supply, and no point repeats another anywhere on the page. Counts (design tokens, AI chart kinds) are computed from the code. |
|
|
19
|
+
```tsx
|
|
20
|
+
import { BarChart, ChartsProvider, dimension, measure, results } from 'em-kit';
|
|
59
21
|
|
|
60
|
-
|
|
22
|
+
const region = dimension({ name: 'region', title: 'Region' });
|
|
23
|
+
const revenue = measure({ name: 'revenue', title: 'Revenue' });
|
|
61
24
|
|
|
62
|
-
|
|
25
|
+
// One row per bar. Each key is the `name` of a field above.
|
|
26
|
+
const rows = [
|
|
27
|
+
{ region: 'North America', revenue: 48200 },
|
|
28
|
+
{ region: 'Europe', revenue: 39500 },
|
|
29
|
+
{ region: 'Asia Pacific', revenue: 27800 },
|
|
30
|
+
];
|
|
63
31
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
32
|
+
export default function App() {
|
|
33
|
+
return (
|
|
34
|
+
<ChartsProvider>
|
|
35
|
+
<div style={{ height: 360 }}>
|
|
36
|
+
<BarChart title="Revenue by region" dimension={region} measures={[revenue]} results={results(rows)} />
|
|
37
|
+
</div>
|
|
38
|
+
</ChartsProvider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
71
42
|
|
|
72
|
-
|
|
43
|
+
A chart fills its container, so give the container a height. In Next.js, put the provider and each chart in a file that starts with `'use client'`.
|
|
73
44
|
|
|
74
|
-
##
|
|
45
|
+
## What you get
|
|
75
46
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
| `src/runtime/react.ts` | hand-written | Replaces `@embeddable.com/react`: theme context + `useTheme`. |
|
|
82
|
-
| `src/ChartsProvider.tsx` | hand-written | Merges theme overrides onto the default theme, injects CSS variables and fonts (what Embeddable's lifecycle hook does). |
|
|
83
|
-
| `src/TableScrollable.tsx` | hand-written | Wraps the generated scrollable table: a `resetKey` prop replaces the Embeddable `dataset` prop as the "query changed, reset paging" signal, and a `heightMode` prop replaces Embeddable's dashboard layout (`'auto'` grows the card to fit every row). |
|
|
84
|
-
| `src/data.ts` | hand-written | `dimension()`, `measure()`, `results()` helpers for building props. |
|
|
85
|
-
| `src/spec.ts` | hand-written | `ChartSpec`: the JSON-serializable chart spec an LLM tool call returns (23 chart kinds, including the KPI-tab and comparison lines and the labelled donut). |
|
|
86
|
-
| `src/ChartFromSpec.tsx` | hand-written | Renders a `ChartSpec` with the real components: normalizes dates/keys/types, falls back to a table or the error card, `chrome: card\|plain\|bare`, emits `ChartIntent`s on clicks, streams via `loading` + growing rows. |
|
|
87
|
-
| `src/intents.ts` | hand-written | `ChartIntent` + `intentToPrompt()`: chart clicks as one-line follow-up prompts. |
|
|
88
|
-
| `src/ai/` | hand-written + generated | `renderChartTool` / `renderChartToolOpenAI` tool definitions, `chartGuidance` prompt snippet, and the JSON Schemas (`spec.schema.generated.ts`, regenerated by `scripts/props.mjs`). Shown live on the docs site at `#/ai`. |
|
|
89
|
-
| `src/build/` | hand-written | `em-kit/build`: the toolkit for custom charts (theme and i18n, `getThemeFormatter`, `useFillGaps`, colours and tokens, `ChartCard`, the Chart.js primitives and the Pro data/option builders), under the upstream names. Curated: nothing is re-exported wholesale. Worked example live on the docs site at `#/docs` → "Build your own chart". |
|
|
90
|
-
| `src/fieldInputs.ts`, `src/fieldInputs.generated.*` | hand-written + generated | `FieldInputs`: every per-field option a chart reads from a field's `inputs`, extracted from remarkable-pro's chart definitions by `scripts/extract-field-inputs.mjs` during sync. |
|
|
91
|
-
| `scripts/components.manifest.mjs` | hand-written | Every upstream component and its fate: exported (under which name), wrapped, or skipped (and why). |
|
|
92
|
-
| `src/components.generated.ts`, `src/componentDefaults.generated.ts` | `scripts/exports.mjs` | One export per manifest component under its standalone name, with its Embeddable builder defaults applied (see below): the upstream `Pro` suffix is dropped (`BarChartDefaultPro` → `BarChart`, `KpiChartNumberPro` → `KpiNumber`, …). |
|
|
93
|
-
| `src/index.ts` | hand-written | Public API (v1: charts, KPIs, tables): the generated component exports plus providers, helpers, wrappers and the AI spec. |
|
|
47
|
+
- Bar, line, pie, funnel, scatter and heat-map charts, KPIs and tables, each in a card with loading, empty and error states.
|
|
48
|
+
- Controls: date range pickers, selects and filter builders.
|
|
49
|
+
- Theming with CSS variables, translations, number and date formatting, and CSV, XLSX and PNG export.
|
|
50
|
+
- `em-kit/ai`: a tool definition and JSON schema so a model can return a chart for `<ChartFromSpec>` to render.
|
|
51
|
+
- `em-kit/build`: the pieces the built-in charts are made from, for building your own.
|
|
94
52
|
|
|
95
|
-
|
|
53
|
+
## Docs
|
|
96
54
|
|
|
97
|
-
|
|
55
|
+
- [Quick start](https://emkit.embeddable.com/docs/quick-start)
|
|
56
|
+
- [Components](https://emkit.embeddable.com/docs/components), each with a live example and its props
|
|
57
|
+
- [Theming](https://emkit.embeddable.com/docs/theming)
|
|
58
|
+
- [Troubleshooting](https://emkit.embeddable.com/docs/troubleshooting)
|
|
59
|
+
- For coding agents: [llms.txt](https://emkit.embeddable.com/llms.txt)
|
|
98
60
|
|
|
99
|
-
##
|
|
61
|
+
## Contributing
|
|
100
62
|
|
|
101
|
-
|
|
102
|
-
- `dimension`/`measure`: `name` is the row key. `type` is a native type (`string | number | time | boolean`); numbers are only formatted when `type` is `number`.
|
|
103
|
-
- Display options go on `inputs`, e.g. `prefix`, `suffix`, `decimalPlaces`, `displayName`, `displayNullAs`.
|
|
104
|
-
- Time values are ISO strings without a zone: `YYYY-MM-DDTHH:mm:ss.sss`. A time dimension's value goes under its `name`. Only a time `groupBy` on a stacked or grouped bar chart, or a scatter or bubble chart's point or group field, is read from `name.granularity` (Cube returns both).
|
|
105
|
-
- Tables are controlled: pass `state`/`setState` from `useState`, then slice and sort your data from `state.page`, `state.pageSize`, `state.sort`.
|
|
106
|
-
- `TableScrollable` (default `heightMode: 'fixed'`) accumulates pages as the user scrolls: serve pages of `TABLE_SCROLLABLE_SIZE` rows (fewer means no more data), and change `resetKey` whenever the query behind the rows changes so it resets to the first page. With `heightMode: 'auto'` the card grows to fit: pass every row at once (up to your own cap) with `results.total`, and the table says when rows were left out.
|
|
63
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Report problems at [github.com/embeddable-hq/em-kit/issues](https://github.com/embeddable-hq/em-kit/issues).
|
|
107
64
|
|
|
108
65
|
## Licence
|
|
109
66
|
|
|
110
|
-
MIT,
|
|
111
|
-
|
|
112
|
-
## Todo
|
|
113
|
-
|
|
114
|
-
- [ ] **Publish as EmKit, last.** Name decided 2026-11-17: **EmKit**, npm package `em-kit` (free on npm that day), docs at **emkit.embeddable.com**. Build everything first; packaging and publishing come at the end.
|
|
115
|
-
- [ ] **Localise percentages everywhere** (low impact, later). Six places format percentages by hand (`toFixed` + `%`), so German shows `12.5%` instead of `12,5 %`: remarkable-ui `KpiChartChange.tsx` (PR [remarkable-ui#445](https://github.com/embeddable-hq/remarkable-ui/pull/445) adds `percentageFormatter`), `PivotTable.utils.ts`, `funnel.utils.ts`; remarkable-pro `charts.utils.ts` (pie/donut labels as %), `LineChartComparisonWithKpiTabsPro.utils.tsx`, `FunnelChartPro.utils.ts`. Fix: one `themeFormatter.percent(value, decimals)` in remarkable-pro (Intl, theme locale), used directly in the three Pro spots and passed as `percentageFormatter` to the three ui ones. ~half a day.
|
|
116
|
-
|
|
117
|
-
## Open findings
|
|
118
|
-
|
|
119
|
-
Resolved: the `embeddable` sessionStorage key (rewritten to `emkit` at sync), the `__embeddableVariableMeta` payload field (dead code, removed with `Value`), the `TableScrollable` dataset prop (wrapped with `resetKey`), the `Pro` suffix (dropped from the public API), missing tests (smoke suite in `tests/`), and the gallery gap (every exported component now has a gallery entry).
|
|
120
|
-
|
|
121
|
-
1. No library build or publish step yet (tsup/Vite library mode + CSS modules + SVG assets).
|
|
122
|
-
2. CSS tokens are page-global. `theme.styles` goes on `:root`, so nested providers can't use different styles. JS theme settings (`theme.charts` options, colour maps, i18n) do scope correctly to a nested provider, which is how the hero dashboard gets its own palette. This is by design upstream; use one set of CSS tokens per page.
|
|
123
|
-
3. Percentages aren't localised. The KPI change shows `+7.4%` in German, which should be `+7,4%`.
|
|
124
|
-
4. `hideMenu` hides the whole card header, title included, not just the menu. By design upstream; `ChartFromSpec`'s `chrome="plain"` keeps the title and drops only the menu.
|
|
125
|
-
5. The granularity picker needs `inputs.showGranularityDropdown: true` on the time dimension, an Embeddable builder input that isn't obvious from the props.
|
|
126
|
-
6. UI language (`theme.i18n.language`) and number/date locale (`theme.formatter.locale`) are set separately. That's flexible, but the provider should probably offer a single `locale` shortcut.
|
|
127
|
-
7. `TableScrollable` shows the first page twice in dev under React StrictMode: the append effect in the generated component (`src/generated/.../TableScrollable/index.tsx`, the `[rows]` effect) re-runs on StrictMode's double mount after `firstLoadPending` has already flipped, so the mount page is appended again. Production builds are unaffected. Fix upstream (guard with a last-processed-rows ref) and resync.
|
|
128
|
-
8. `src/i18n/fr.ts` (French) is hand-written in this repo, not synced. Keep its keys in step with the upstream `en`/`de` bundles, or better, contribute it upstream.
|
|
129
|
-
9. Y-axis labels clip their first character when a locale widens numbers (French `$7 000` shows as `7 000`).
|
|
67
|
+
MIT, copyright Embeddable.com.
|
package/dist/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './styles.js';
|
|
2
|
-
import { u as useTheme } from "./chunks/pies.utils-
|
|
3
|
-
import { B, C, D, E, K, L, P, a, d, g, b, c, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t, v, w, x, y, z, A, F, G } from "./chunks/pies.utils-
|
|
2
|
+
import { u as useTheme } from "./chunks/pies.utils-CMMo-SlI.js";
|
|
3
|
+
import { B, C, D, E, K, L, P, a, d, g, b, c, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t, v, w, x, y, z, A, F, G } from "./chunks/pies.utils-CMMo-SlI.js";
|
|
4
4
|
import { default as default2 } from "i18next";
|
|
5
5
|
const getDimensionWithGranularity = (dimension, granularity) => {
|
|
6
6
|
const currentGranularity = granularity ?? dimension.inputs?.granularity;
|
|
@@ -42,8 +42,7 @@ const i18nSetup = (theme) => {
|
|
|
42
42
|
resources: theme.i18n.translations,
|
|
43
43
|
interpolation: {
|
|
44
44
|
escapeValue: false
|
|
45
|
-
}
|
|
46
|
-
showSupportNotice: false
|
|
45
|
+
}
|
|
47
46
|
});
|
|
48
47
|
};
|
|
49
48
|
const resolveI18nString = (value2, args) => {
|
|
@@ -7897,4 +7896,4 @@ export {
|
|
|
7897
7896
|
groupTailAsOther as y,
|
|
7898
7897
|
i18nSetup as z
|
|
7899
7898
|
};
|
|
7900
|
-
//# sourceMappingURL=pies.utils-
|
|
7899
|
+
//# sourceMappingURL=pies.utils-CMMo-SlI.js.map
|