@grafloria/element 0.1.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.
Files changed (61) hide show
  1. package/package.json +41 -0
  2. package/src/index.d.ts +87 -0
  3. package/src/index.js +547 -0
  4. package/src/index.js.map +1 -0
  5. package/src/lib/dashboard-kit/dashboard.d.ts +345 -0
  6. package/src/lib/dashboard-kit/dashboard.js +594 -0
  7. package/src/lib/dashboard-kit/dashboard.js.map +1 -0
  8. package/src/lib/dashboard-kit/grid-binder.d.ts +277 -0
  9. package/src/lib/dashboard-kit/grid-binder.js +1635 -0
  10. package/src/lib/dashboard-kit/grid-binder.js.map +1 -0
  11. package/src/lib/dashboard-kit/grid-mapping.d.ts +141 -0
  12. package/src/lib/dashboard-kit/grid-mapping.js +176 -0
  13. package/src/lib/dashboard-kit/grid-mapping.js.map +1 -0
  14. package/src/lib/dashboard-kit/index.d.ts +5 -0
  15. package/src/lib/dashboard-kit/index.js +33 -0
  16. package/src/lib/dashboard-kit/index.js.map +1 -0
  17. package/src/lib/dashboard-kit/styles.d.ts +25 -0
  18. package/src/lib/dashboard-kit/styles.js +203 -0
  19. package/src/lib/dashboard-kit/styles.js.map +1 -0
  20. package/src/lib/dashboard-kit/widgets.d.ts +112 -0
  21. package/src/lib/dashboard-kit/widgets.js +389 -0
  22. package/src/lib/dashboard-kit/widgets.js.map +1 -0
  23. package/src/lib/diagram-kit/card.d.ts +75 -0
  24. package/src/lib/diagram-kit/card.js +209 -0
  25. package/src/lib/diagram-kit/card.js.map +1 -0
  26. package/src/lib/diagram-kit/editing.d.ts +54 -0
  27. package/src/lib/diagram-kit/editing.js +289 -0
  28. package/src/lib/diagram-kit/editing.js.map +1 -0
  29. package/src/lib/diagram-kit/er.d.ts +73 -0
  30. package/src/lib/diagram-kit/er.js +163 -0
  31. package/src/lib/diagram-kit/er.js.map +1 -0
  32. package/src/lib/diagram-kit/handles.d.ts +181 -0
  33. package/src/lib/diagram-kit/handles.js +325 -0
  34. package/src/lib/diagram-kit/handles.js.map +1 -0
  35. package/src/lib/diagram-kit/index.d.ts +8 -0
  36. package/src/lib/diagram-kit/index.js +38 -0
  37. package/src/lib/diagram-kit/index.js.map +1 -0
  38. package/src/lib/diagram-kit/rows.d.ts +53 -0
  39. package/src/lib/diagram-kit/rows.js +147 -0
  40. package/src/lib/diagram-kit/rows.js.map +1 -0
  41. package/src/lib/diagram-kit/styles.d.ts +18 -0
  42. package/src/lib/diagram-kit/styles.js +114 -0
  43. package/src/lib/diagram-kit/styles.js.map +1 -0
  44. package/src/lib/diagram-kit/uml.d.ts +59 -0
  45. package/src/lib/diagram-kit/uml.js +138 -0
  46. package/src/lib/diagram-kit/uml.js.map +1 -0
  47. package/src/lib/diagram-kit/update.d.ts +133 -0
  48. package/src/lib/diagram-kit/update.js +251 -0
  49. package/src/lib/diagram-kit/update.js.map +1 -0
  50. package/src/lib/grafloria-flow-element.d.ts +48 -0
  51. package/src/lib/grafloria-flow-element.js +271 -0
  52. package/src/lib/grafloria-flow-element.js.map +1 -0
  53. package/src/lib/grafloria.d.ts +61 -0
  54. package/src/lib/grafloria.js +72 -0
  55. package/src/lib/grafloria.js.map +1 -0
  56. package/src/lib/load.d.ts +72 -0
  57. package/src/lib/load.js +255 -0
  58. package/src/lib/load.js.map +1 -0
  59. package/src/lib/node-type-registry.d.ts +39 -0
  60. package/src/lib/node-type-registry.js +50 -0
  61. package/src/lib/node-type-registry.js.map +1 -0
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /**
3
+ * Dashboard-kit stylesheet — injected once, on first `bindDashboardGrid`.
4
+ *
5
+ * Everything is prefixed `axdb-` and scoped under `.grafloria-html-layer`, so
6
+ * binding the kit can never restyle a host's own DOM. Four jobs:
7
+ *
8
+ * - GLIDE: the reflow transition (the pattern from commit 180a27974) that
9
+ * makes displaced tiles slide to their new slot while a gesture is live.
10
+ * The kit arms `.axdb-glide` on the html layer for the WHOLE gesture, so
11
+ * every accepted moveCheck/resizeCheck animates the neighbours.
12
+ * - GHOST: the held tile is transition-EXEMPT (it must track the pointer
13
+ * 1:1), floats above everything, and dims + lifts like the prototype's
14
+ * `.tile.drag`. When a drag leaves the board (drag-out-to-remove) the
15
+ * ghost dims further as the "release deletes" affordance.
16
+ * - PLACEHOLDER: the dashed slab that always shows the exact drop result
17
+ * (the prototype's `#ph`). It JUMPS — never animates — so it is always
18
+ * truthful about the engine's current cell.
19
+ * - RESIZE HANDLE: a corner affordance INSIDE each widget card, bottom-right,
20
+ * radius-matched via `--axdb-rs-radius`, revealed on hover. The binder
21
+ * injects it into each member host and re-injects if the host repaints
22
+ * (pages own their card innerHTML).
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.DASHBOARD_KIT_STYLE_ID = void 0;
26
+ exports.ensureDashboardKitStyles = ensureDashboardKitStyles;
27
+ exports.DASHBOARD_KIT_STYLE_ID = 'grafloria-dashboard-kit-styles';
28
+ const CSS = `
29
+ /* ===== reflow glide (armed on the html layer for the whole gesture) ===== */
30
+ .grafloria-html-layer.axdb-glide > .grafloria-node-host {
31
+ transition: left .28s cubic-bezier(.2, 0, .2, 1), top .28s cubic-bezier(.2, 0, .2, 1),
32
+ width .28s cubic-bezier(.2, 0, .2, 1), height .28s cubic-bezier(.2, 0, .2, 1);
33
+ }
34
+
35
+ /* ===== the held tile: transition-exempt ghost, above everything ===== */
36
+ .grafloria-html-layer > .grafloria-node-host.axdb-ghost,
37
+ .grafloria-html-layer.axdb-glide > .grafloria-node-host.axdb-ghost {
38
+ transition: none;
39
+ z-index: 30;
40
+ opacity: .85;
41
+ cursor: grabbing;
42
+ filter: drop-shadow(0 10px 16px rgba(16, 24, 40, .3));
43
+ }
44
+ /* Outside the board: release will REMOVE — dim the ghost to say so. */
45
+ .grafloria-html-layer > .grafloria-node-host.axdb-ghost.axdb-out { opacity: .35; filter: grayscale(.6); }
46
+
47
+ /* ===== the placeholder: dashed slab, truthful, never animated ===== */
48
+ .grafloria-html-layer > .axdb-ph {
49
+ position: absolute;
50
+ border-radius: var(--axdb-rs-radius, 12px);
51
+ background: rgba(30, 34, 45, .14);
52
+ border: 2px dashed rgba(30, 34, 45, .28);
53
+ box-sizing: border-box;
54
+ pointer-events: none;
55
+ z-index: 0;
56
+ transition: none;
57
+ }
58
+ @media (prefers-color-scheme: dark) {
59
+ .grafloria-html-layer > .axdb-ph { background: rgba(220, 225, 240, .12); border-color: rgba(220, 225, 240, .3); }
60
+ }
61
+
62
+ /* ===== corner resize handle (hover-revealed, radius-matched) ===== */
63
+ .grafloria-node-host > .axdb-rs {
64
+ position: absolute;
65
+ right: 0;
66
+ bottom: 0;
67
+ width: 18px;
68
+ height: 18px;
69
+ cursor: nwse-resize;
70
+ border-right: 3px solid rgba(120, 130, 148, .55);
71
+ border-bottom: 3px solid rgba(120, 130, 148, .55);
72
+ border-bottom-right-radius: var(--axdb-rs-radius, 12px);
73
+ opacity: 0;
74
+ transition: opacity .12s;
75
+ z-index: 5;
76
+ }
77
+ .grafloria-node-host:hover > .axdb-rs { opacity: 1; }
78
+ .grafloria-node-host > .axdb-rs:hover { border-color: #3b52d9; }
79
+ /* RTL boards grow leftwards, so the grab corner mirrors with them. */
80
+ .grafloria-node-host > .axdb-rs.axdb-rs--rtl {
81
+ right: auto;
82
+ left: 0;
83
+ cursor: nesw-resize;
84
+ border-right: none;
85
+ border-left: 3px solid rgba(120, 130, 148, .55);
86
+ border-bottom-right-radius: 0;
87
+ border-bottom-left-radius: var(--axdb-rs-radius, 12px);
88
+ }
89
+
90
+ /* ===== palette drag-in chip (screen-space clone following the cursor) ===== */
91
+ .axdb-drag-chip {
92
+ position: fixed;
93
+ z-index: 9999;
94
+ pointer-events: none;
95
+ opacity: .9;
96
+ filter: drop-shadow(0 8px 14px rgba(16, 24, 40, .3));
97
+ }
98
+
99
+ /* ===========================================================================
100
+ BUILT-IN WIDGET CARDS — what widgets.ts paints when a page writes no
101
+ renderWidget. Class-prefixed (never element selectors), so this can only
102
+ ever style DOM the kit itself produced. Colours are CSS variables on the
103
+ card, so a page re-skins every built-in widget by setting them once; the
104
+ corner radius follows --axdb-rs-radius, which is also the placeholder's and
105
+ the resize handle's, so the three can never drift apart.
106
+ =========================================================================== */
107
+ .axdb-widget {
108
+ --axdb-ink: #1f2430;
109
+ --axdb-muted: #7a8496;
110
+ --axdb-grid: rgba(120, 130, 148, .22);
111
+ --axdb-card: #fff;
112
+ --axdb-line: #e7eaf1;
113
+ --axdb-soft: rgba(120, 130, 148, .14);
114
+ box-sizing: border-box;
115
+ width: 100%;
116
+ height: 100%;
117
+ display: flex;
118
+ flex-direction: column;
119
+ overflow: hidden;
120
+ padding: 13px 15px 12px;
121
+ background: var(--axdb-card);
122
+ border: 1px solid var(--axdb-line);
123
+ border-radius: var(--axdb-rs-radius, 12px);
124
+ box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .05);
125
+ font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
126
+ color: var(--axdb-ink);
127
+ }
128
+ .axdb-widget-h {
129
+ display: flex;
130
+ align-items: center;
131
+ gap: 6px;
132
+ margin-bottom: 8px;
133
+ font: 600 11px/1.3 system-ui, sans-serif;
134
+ letter-spacing: .4px;
135
+ text-transform: uppercase;
136
+ color: var(--axdb-muted);
137
+ }
138
+ .axdb-widget-b { flex: 1; min-height: 0; position: relative; }
139
+ .axdb-widget-b > svg { display: block; width: 100%; height: 100%; }
140
+ .axdb-widget-b.axdb-scroll { overflow: auto; }
141
+ /* A chart WITH a legend under it: the plot yields height, the legend keeps its
142
+ own (without this the 100%-tall svg pushes the legend out of the card). */
143
+ .axdb-widget-b.axdb-has-lg { display: flex; flex-direction: column; }
144
+ .axdb-widget-b.axdb-has-lg > svg { flex: 1; height: auto; min-height: 0; }
145
+ .axdb-widget-empty {
146
+ display: flex; align-items: center; justify-content: center; height: 100%;
147
+ font: 500 11.5px/1.3 system-ui, sans-serif; color: var(--axdb-muted); opacity: .75;
148
+ }
149
+
150
+ /* kpi: value + delta stack, the spark yields its height before they do */
151
+ .axdb-widget-b.axdb-kpi { display: flex; flex-direction: column; }
152
+ .axdb-kpi-v { font: 700 30px/1.05 system-ui, sans-serif; letter-spacing: -.02em; color: var(--axdb-ink); }
153
+ .axdb-kpi-d { margin-top: 6px; font: 600 12px/1.2 system-ui, sans-serif; }
154
+ .axdb-kpi-d span { color: var(--axdb-muted); font-weight: 500; }
155
+ .axdb-kpi-d.up { color: #12a150; }
156
+ .axdb-kpi-d.down { color: #e11d48; }
157
+ .axdb-kpi-s { margin-top: auto; height: 34px; min-height: 0; flex: 0 1 34px; }
158
+
159
+ /* donut: ring beside its legend */
160
+ .axdb-widget-b.axdb-donut { display: flex; align-items: center; gap: 10px; }
161
+ .axdb-widget-b.axdb-donut > svg { max-width: 150px; }
162
+
163
+ /* legend chips, shared by line and donut */
164
+ .axdb-lg { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 9px; }
165
+ .axdb-lg--col { flex-direction: column; flex-wrap: nowrap; gap: 6px; margin-top: 0; }
166
+ .axdb-lg i {
167
+ display: inline-flex; align-items: center; gap: 5px; font-style: normal;
168
+ font: 500 11px/1.3 system-ui, sans-serif; color: var(--axdb-muted);
169
+ }
170
+ .axdb-lg i b { width: 9px; height: 9px; border-radius: 3px; flex: none; }
171
+
172
+ /* table */
173
+ .axdb-table { width: 100%; border-collapse: collapse; font-size: 12px; color: var(--axdb-ink); }
174
+ .axdb-table th {
175
+ text-align: left; padding: 4px 8px 7px; border-bottom: 1px solid var(--axdb-line);
176
+ font: 600 10px/1.3 system-ui, sans-serif; letter-spacing: .4px; text-transform: uppercase;
177
+ color: var(--axdb-muted);
178
+ }
179
+ .axdb-table td { padding: 6px 8px; border-bottom: 1px solid var(--axdb-line); white-space: nowrap; }
180
+ .axdb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
181
+ .axdb-table tr:last-child td { border-bottom: none; }
182
+
183
+ @media (prefers-color-scheme: dark) {
184
+ .axdb-widget {
185
+ --axdb-ink: #eceef4;
186
+ --axdb-muted: #98a1b4;
187
+ --axdb-grid: rgba(150, 160, 182, .2);
188
+ --axdb-card: #1a1d25;
189
+ --axdb-line: #2b3040;
190
+ --axdb-soft: rgba(150, 160, 182, .16);
191
+ }
192
+ }
193
+ `;
194
+ /** Idempotently inject the kit stylesheet (safe to call per binder). */
195
+ function ensureDashboardKitStyles(doc = document) {
196
+ if (doc.getElementById(exports.DASHBOARD_KIT_STYLE_ID))
197
+ return;
198
+ const style = doc.createElement('style');
199
+ style.id = exports.DASHBOARD_KIT_STYLE_ID;
200
+ style.textContent = CSS;
201
+ doc.head.appendChild(style);
202
+ }
203
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../../libs/element/src/lib/dashboard-kit/styles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AA4KH,4DAMC;AAhLY,QAAA,sBAAsB,GAAG,gCAAgC,CAAC;AAEvE,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKX,CAAC;AAEF,wEAAwE;AACxE,SAAgB,wBAAwB,CAAC,MAAgB,QAAQ;IAC/D,IAAI,GAAG,CAAC,cAAc,CAAC,8BAAsB,CAAC;QAAE,OAAO;IACvD,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,GAAG,8BAAsB,CAAC;IAClC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;IACxB,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * BUILT-IN WIDGET RENDERERS — what `kind` means when you write no `renderWidget`.
3
+ *
4
+ * `dashboard({ views: [...] })` is data-first: a widget is `{ id, kind, span,
5
+ * rows, data }`. Until now `kind` was a free-form string that only meant
6
+ * something if the page supplied `renderWidget`; omitting it drew a titled
7
+ * empty frame. This module is the other half — six real renderers driven by
8
+ * the DEVELOPER'S OWN `data`, so a dashboard is useful from pure data alone:
9
+ *
10
+ * ```js
11
+ * dashboard({ widgets: [
12
+ * { id: 'rev', kind: 'kpi', span: 3, data: { label: 'Revenue', value: '$6.8M', delta: 12.4 } },
13
+ * { id: 'trend', kind: 'line', span: 8, rows: 2, data: { series: [10, 14, 12, 19] } },
14
+ * ]}); // no renderWidget, no charting library, real widgets
15
+ * ```
16
+ *
17
+ * TWO THINGS THIS DELIBERATELY IS NOT:
18
+ * - A charting library. Every mark is hand-drawn inline SVG (the same
19
+ * technique the dashboard demo uses), so the kit still adds ZERO
20
+ * dependencies and the whole file is readable.
21
+ * - A dataset. Nothing here ships sample numbers; every renderer reads the
22
+ * `data` the developer declared and degrades to an empty-state note when it
23
+ * is missing, partial or the wrong shape. A widget renderer must NEVER
24
+ * throw: it paints into a live board, mid-gesture, on every reflow.
25
+ *
26
+ * `renderWidget` remains the seam for anything richer — and it composes:
27
+ * call `defaultWidgetRenderer(widget, host)` first, then decorate the host
28
+ * (that is exactly what demos/dashboard/dashboard-builder.html does for its
29
+ * focus ring and pin marker).
30
+ */
31
+ import type { DashboardWidgetSpec } from './dashboard';
32
+ /** The signature every renderer here (and `renderWidget`) satisfies. */
33
+ export type WidgetRenderer = (widget: DashboardWidgetSpec, host: HTMLElement) => void;
34
+ /** `kind: 'kpi'` — one headline number, an optional change, an optional trend. */
35
+ export interface KpiWidgetData {
36
+ /** Small caption above the number (falls back to `widget.title`). */
37
+ label?: string;
38
+ /** The headline — pre-formatted by you, so units/currency stay yours. */
39
+ value?: string | number;
40
+ /** Signed percentage change. Positive paints up/green, negative down/red. */
41
+ delta?: number;
42
+ /** Caption after the delta (default 'vs previous'). */
43
+ deltaLabel?: string;
44
+ /** Sparkline values, oldest → newest. Fewer than 2 points draws nothing. */
45
+ spark?: number[];
46
+ }
47
+ /** One named line of a `kind: 'line'` chart. */
48
+ export interface LineSeries {
49
+ name?: string;
50
+ values: number[];
51
+ }
52
+ /** `kind: 'line'` — one or many series over a shared x axis (area + line). */
53
+ export interface LineWidgetData {
54
+ /** A bare `number[]` is the single-series shorthand. */
55
+ series?: number[] | LineSeries[];
56
+ /** X-axis tick labels, positionally matched to the values. */
57
+ labels?: string[];
58
+ }
59
+ /** `kind: 'bar'` — categorical columns. */
60
+ export interface BarWidgetData {
61
+ bars?: Array<{
62
+ label?: string;
63
+ value?: number;
64
+ }>;
65
+ }
66
+ /** `kind: 'donut'` — parts of a whole, with a legend and a centre figure. */
67
+ export interface DonutWidgetData {
68
+ slices?: Array<{
69
+ label?: string;
70
+ value?: number;
71
+ color?: string;
72
+ }>;
73
+ /** Centre figure (default: the compacted total). */
74
+ centerLabel?: string;
75
+ /** Caption under the centre figure (default 'total'). */
76
+ centerCaption?: string;
77
+ }
78
+ /** `kind: 'funnel'` — ordered stages, each bar scaled against the first. */
79
+ export interface FunnelWidgetData {
80
+ stages?: Array<{
81
+ label?: string;
82
+ value?: number;
83
+ }>;
84
+ }
85
+ /** `kind: 'table'` — plain rows. Numbers right-align on their own. */
86
+ export interface TableWidgetData {
87
+ columns?: string[];
88
+ rows?: Array<Array<string | number>>;
89
+ }
90
+ /** The kinds `defaultWidgetRenderer` knows; anything else gets the placeholder. */
91
+ export declare const BUILT_IN_WIDGET_KINDS: readonly ["kpi", "line", "bar", "donut", "funnel", "table"];
92
+ /** `{ label, value, delta?, spark? }` — headline number + change + sparkline. */
93
+ export declare const renderKpiWidget: WidgetRenderer;
94
+ /** `{ series, labels? }` — area under the first series, a line per series. */
95
+ export declare const renderLineWidget: WidgetRenderer;
96
+ /** `{ bars: [{label, value}] }` — columns, value above, category below. */
97
+ export declare const renderBarWidget: WidgetRenderer;
98
+ /** `{ slices: [{label, value, color?}], centerLabel? }` — ring + legend. */
99
+ export declare const renderDonutWidget: WidgetRenderer;
100
+ /** `{ stages: [{label, value}] }` — centred bars scaled against the first stage. */
101
+ export declare const renderFunnelWidget: WidgetRenderer;
102
+ /** `{ columns, rows }` — plain rows; numeric cells right-align themselves. */
103
+ export declare const renderTableWidget: WidgetRenderer;
104
+ /**
105
+ * Paint `widget` into `host` by its `kind` — `dashboard()`'s default
106
+ * `renderWidget`, and the composable base for your own.
107
+ *
108
+ * An unknown (or absent) kind falls back to the titled placeholder frame, so a
109
+ * board of not-yet-implemented widgets still lays out and is still testable.
110
+ * Never throws: bad data paints an empty state.
111
+ */
112
+ export declare const defaultWidgetRenderer: WidgetRenderer;