@pixerate/editor-svelte 0.46.0 → 0.48.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.
@@ -10,6 +10,9 @@
10
10
  import {
11
11
  CHART_COLOR_SCHEMES,
12
12
  CHART_CURVES,
13
+ CHART_ERROR_BAR_DIRECTIONS,
14
+ CHART_ERROR_BAR_LABELS,
15
+ CHART_ERROR_BAR_TYPES,
13
16
  CHART_LABEL_POSITIONS,
14
17
  CHART_LAYOUT_PRESETS,
15
18
  CHART_LEGEND_POSITIONS,
@@ -22,14 +25,21 @@
22
25
  CHART_TYPES,
23
26
  checkChartColors,
24
27
  chartColorInputValue,
28
+ chartErrorBarsOfType,
25
29
  chartFamily,
26
30
  chartSeriesColor,
27
31
  chartSeriesType,
28
32
  chartSupportsTrendlines,
29
33
  chartTrendlineName,
34
+ defaultChartErrorBarValue,
35
+ formatChartAmountList,
30
36
  isCartesianChart,
37
+ parseChartAmountList,
31
38
  type ChartAxis,
32
39
  type ChartController,
40
+ type ChartErrorBars,
41
+ type ChartErrorBarType,
42
+ type ChartSeries,
33
43
  type ChartLabelPosition,
34
44
  type ChartMarker,
35
45
  type ChartNumberFormat,
@@ -66,6 +76,8 @@
66
76
  const currentScheme = $derived(CHART_COLOR_SCHEMES.find((c) => c.palette.join() === spec.palette.join())?.id ?? '');
67
77
  const seriesIndex = $derived(selectedSeries ? spec.series.findIndex((s) => s.id === selectedSeries.id) : -1);
68
78
  const horizontal = $derived(spec.orientation === 'horizontal');
79
+ // Log and reversed axes and error bars are drawn by the bar / line / area / scatter layouts.
80
+ const scales = $derived(family === 'cartesian' || family === 'xy');
69
81
  const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
70
82
  const stackingLabels: Record<string, string> = { none: 'None', stacked: 'Stacked', percent: '100%' };
71
83
 
@@ -85,6 +97,17 @@
85
97
  else delete format.code;
86
98
  return setAxis(axis, { format }).ok;
87
99
  }
100
+ const setBars = (series: ChartSeries, which: 'errorBars' | 'xErrorBars', next: ChartErrorBars | null) => controller.updateSeries(series.id, { [which]: next });
101
+ const patchBars = (series: ChartSeries, which: 'errorBars' | 'xErrorBars', patch: Partial<ChartErrorBars>) => {
102
+ const bars = series[which];
103
+ return bars ? setBars(series, which, { ...bars, ...patch }).ok : false;
104
+ };
105
+ function commitMinus(series: ChartSeries, which: 'errorBars' | 'xErrorBars', text: string) {
106
+ const next = { ...series[which]! };
107
+ if (text.trim()) next.minus = parseChartAmountList(text) as ChartErrorBars['minus'];
108
+ else delete next.minus;
109
+ return setBars(series, which, next).ok;
110
+ }
88
111
  const side = (axis: 'x' | 'y' | 'y2') => (axis === 'x' ? (horizontal ? 'left' : 'bottom') : axis === 'y2' ? (horizontal ? 'top' : 'right') : horizontal ? 'bottom' : 'left');
89
112
  </script>
90
113
 
@@ -95,6 +118,67 @@
95
118
  </label>
96
119
  {/snippet}
97
120
 
121
+ {#snippet errorBarFields(series: ChartSeries, which: 'errorBars' | 'xErrorBars')}
122
+ {@const bars = series[which]}
123
+ {@const key = `series.${which}`}
124
+ {@const id = `${idPrefix}-${which}`}
125
+ <div class="space-y-1.5" data-section={which === 'errorBars' ? 'error-bars' : 'x-error-bars'}>
126
+ <div class="flex items-center gap-2">
127
+ <label for="{id}-type" class="{chartLabelClass} w-20 shrink-0">{which === 'errorBars' ? 'Error bars' : 'X error bars'}</label>
128
+ <select
129
+ id="{id}-type"
130
+ class={chartInputClass}
131
+ value={bars?.type ?? ''}
132
+ data-option="{key}.type"
133
+ onchange={(e) => setBars(series, which, chartErrorBarsOfType(e.currentTarget.value as ChartErrorBarType | '', bars, which === 'xErrorBars' ? (series.x ?? []) : series.values))}
134
+ >
135
+ <option value="">None</option>
136
+ {#each CHART_ERROR_BAR_TYPES as t (t)}
137
+ <option value={t}>{CHART_ERROR_BAR_LABELS[t]}</option>
138
+ {/each}
139
+ </select>
140
+ </div>
141
+ {#if bars && (bars.type === 'fixed' || bars.type === 'percent' || bars.type === 'stddev')}
142
+ <div class="flex items-center gap-2">
143
+ <label for="{id}-value" class="{chartLabelClass} w-20 shrink-0">{bars.type === 'percent' ? 'Percent' : bars.type === 'stddev' ? 'Deviations' : 'Amount'}</label>
144
+ <div class="min-w-0 flex-1">
145
+ <ChartCommitInput id="{id}-value" value={String(bars.value ?? defaultChartErrorBarValue(bars.type))} inputmode="decimal" data-option="{key}.value" oncommit={(text) => patchBars(series, which, { value: text.trim() === '' ? undefined : Number(text) })} />
146
+ </div>
147
+ </div>
148
+ {/if}
149
+ {#if bars?.type === 'custom'}
150
+ <div class="flex items-center gap-2">
151
+ <label for="{id}-plus" class="{chartLabelClass} w-20 shrink-0">Plus</label>
152
+ <div class="min-w-0 flex-1">
153
+ <ChartCommitInput id="{id}-plus" value={formatChartAmountList(bars.plus)} placeholder="1, 2, -, 0.5" data-option="{key}.plus" oncommit={(text) => patchBars(series, which, { plus: parseChartAmountList(text) as ChartErrorBars['plus'] })} />
154
+ </div>
155
+ </div>
156
+ <div class="flex items-center gap-2">
157
+ <label for="{id}-minus" class="{chartLabelClass} w-20 shrink-0">Minus</label>
158
+ <div class="min-w-0 flex-1">
159
+ <ChartCommitInput id="{id}-minus" value={formatChartAmountList(bars.minus)} placeholder="Same as plus" data-option="{key}.minus" oncommit={(text) => commitMinus(series, which, text)} />
160
+ </div>
161
+ </div>
162
+ {/if}
163
+ {#if bars}
164
+ <div class="flex items-center gap-2">
165
+ <select
166
+ class="{chartInputClass} flex-1"
167
+ aria-label="Error bar direction"
168
+ value={bars.direction ?? 'both'}
169
+ data-option="{key}.direction"
170
+ onchange={(e) => patchBars(series, which, { direction: e.currentTarget.value as ChartErrorBars['direction'] })}
171
+ >
172
+ {#each CHART_ERROR_BAR_DIRECTIONS as d (d)}
173
+ <option value={d}>{d === 'both' ? 'Both ways' : d === 'plus' ? 'Plus only' : 'Minus only'}</option>
174
+ {/each}
175
+ </select>
176
+ {@render toggle('Caps', `${key}.cap`, bars.cap !== false, (cap) => patchBars(series, which, { cap }))}
177
+ </div>
178
+ {/if}
179
+ </div>
180
+ {/snippet}
181
+
98
182
  {#snippet axisSection(axis: 'x' | 'y' | 'y2', value: ChartAxis, numeric: boolean)}
99
183
  {@const key = keyOf(axis)}
100
184
  {@const valueAxis = axis !== 'x' || numeric}
@@ -117,14 +201,30 @@
117
201
  {#if axis === 'x' && !numeric}
118
202
  {@render toggle('Dates', 'xAxis.kind', value.kind === 'date', (dates) => setAxis('x', { kind: dates ? 'date' : undefined } as Partial<ChartAxis>))}
119
203
  {/if}
204
+ {#if scales}
205
+ {@render toggle('Reverse', `${key}.reverse`, !!value.reverse, (reverse) => setAxis(axis, { reverse }))}
206
+ {/if}
207
+ {#if scales && valueAxis}
208
+ {@render toggle('Log scale', `${key}.scale`, value.scale === 'log', (log) => setAxis(axis, { scale: log ? 'log' : 'linear' }))}
209
+ {/if}
120
210
  </div>
121
- {#if valueAxis}
211
+ {#if scales && valueAxis && value.scale === 'log'}
212
+ <div class="flex items-center gap-2">
213
+ <label for="{idPrefix}-{axis}-log-base" class="{chartLabelClass} w-20 shrink-0">Log base</label>
214
+ <div class="min-w-0 flex-1">
215
+ <ChartCommitInput id="{idPrefix}-{axis}-log-base" value={String(value.logBase ?? 10)} inputmode="decimal" data-option="{key}.logBase" oncommit={(text) => setAxis(axis, { logBase: text.trim() === '' ? undefined : Number(text) }).ok} />
216
+ </div>
217
+ </div>
218
+ {/if}
219
+ {#if valueAxis && value.scale !== 'log'}
122
220
  <div class="flex items-center gap-2">
123
221
  <label for="{idPrefix}-{axis}-step" class="{chartLabelClass} w-20 shrink-0">Step</label>
124
222
  <div class="min-w-0 flex-1">
125
223
  <ChartCommitInput id="{idPrefix}-{axis}-step" value={value.step === null ? '' : String(value.step)} placeholder="Auto" inputmode="decimal" data-option="{key}.step" oncommit={commitNumber(axis, 'step')} />
126
224
  </div>
127
225
  </div>
226
+ {/if}
227
+ {#if valueAxis}
128
228
  <div class="flex items-center gap-2">
129
229
  <span class="{chartLabelClass} w-20 shrink-0">Min / max</span>
130
230
  <div class="flex min-w-0 flex-1 gap-1">
@@ -428,6 +528,12 @@
428
528
  </select>
429
529
  </div>
430
530
  {/if}
531
+ {#if scales}
532
+ {@render errorBarFields(series, 'errorBars')}
533
+ {/if}
534
+ {#if family === 'xy'}
535
+ {@render errorBarFields(series, 'xErrorBars')}
536
+ {/if}
431
537
  {#if chartSupportsTrendlines(spec.type, spec.stacking)}
432
538
  <div class="space-y-1" data-section="trendlines">
433
539
  {#each series.trendlines ?? [] as t, i (i)}
@@ -1 +1 @@
1
- {"version":3,"file":"ChartInspector.svelte.d.ts","sourceRoot":"","sources":["../../src/chart/ChartInspector.svelte.ts"],"names":[],"mappings":"AAOE,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAG7G,OAAO,EAsBH,KAAK,eAAe,EAMrB,MAAM,wBAAwB,CAAC;AAMhC,UAAU,KAAK;IACb,UAAU,EAAE,eAAe,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC5C,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoWH,QAAA,MAAM,cAAc,2CAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"ChartInspector.svelte.d.ts","sourceRoot":"","sources":["../../src/chart/ChartInspector.svelte.ts"],"names":[],"mappings":"AAOE,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAG7G,OAAO,EA6BH,KAAK,eAAe,EASrB,MAAM,wBAAwB,CAAC;AAMhC,UAAU,KAAK;IACb,UAAU,EAAE,eAAe,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC5C,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwbH,QAAA,MAAM,cAAc,2CAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ToolRegistry } from "@pixerate/editor/tools";
2
- import { ChartController, ChartDirector, ChartPresence, type ChartScene, type ChartToolProviderOptions, type ChartActionResult, type ChartCommandOptions, type ChartControllerOptions, type ChartSelection, type ChartSpecPatch, type ChartState, type ChartType } from "@pixerate/editor/chart";
2
+ import { ChartController, ChartDirector, ChartPresence, type OfficeChartToolProviderOptions, type ChartScene, type ChartToolProviderOptions, type ChartActionResult, type ChartCommandOptions, type ChartControllerOptions, type ChartSelection, type ChartSpecPatch, type ChartState, type ChartType } from "@pixerate/editor/chart";
3
3
  export interface SvelteChartEditor {
4
4
  readonly controller: ChartController;
5
5
  /** The controller's state (reactive). */
@@ -46,6 +46,12 @@ export type ChartToolProviderHookOptions = Omit<ChartToolProviderOptions, "raste
46
46
  * browser, `render_chart { format: "png" }` works out of the box (`createChartRasterizer`).
47
47
  */
48
48
  export declare function useChartToolProvider(registry: ToolRegistry | null | undefined | (() => ToolRegistry | null | undefined), controller: ChartController, options?: ChartToolProviderHookOptions): void;
49
+ /**
50
+ * Registers the Office-file chart tools (`createOfficeChartToolProvider`: `list_file_charts`,
51
+ * `get_file_chart`, and `load_file_chart` with a `controller`) for the lifetime of the calling
52
+ * component. Pass a getter to follow a changing registry.
53
+ */
54
+ export declare function useOfficeChartToolProvider(registry: ToolRegistry | null | undefined | (() => ToolRegistry | null | undefined), options?: OfficeChartToolProviderOptions): void;
49
55
  /**
50
56
  * A `ChartPresence` and `ChartDirector` for a chart: pass `presence` and `sceneRef` to
51
57
  * `ChartCanvas`, and `director` to `useChartToolProvider` so agent edits are acted out with a
@@ -1 +1 @@
1
- {"version":3,"file":"createChartEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/chart/createChartEditor.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,aAAa,EACb,aAAa,EAKb,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB,CAAC;IACjD,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,iBAAiB,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAAC;IAC7E,MAAM,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/C,IAAI,IAAI,IAAI,CAAC;IACb,IAAI,IAAI,IAAI,CAAC;IACb,yCAAyC;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,mBAAmB,GAAE,eA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AAC1E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,SAAS,CAAC,EAC/F,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAMN;AAED,0HAA0H;AAC1H,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC,GAAG,KAAK,CAAA;CAAE,CAAC;AAEvJ;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC,EACnF,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,4BAAiC,GACzC,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC,EACnF,OAAO,GAAE,8BAAmC,GAC3C,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO;;;;iBAC9G,UAAU,GAAG,IAAI;;EAK7C"}
@@ -1,5 +1,5 @@
1
1
  import { untrack } from "svelte";
2
- import { ChartController, ChartDirector, ChartPresence, createChartCommands, createChartRasterizer, createChartToolProvider, layoutChart, } from "@pixerate/editor/chart";
2
+ import { ChartController, ChartDirector, ChartPresence, createChartCommands, createChartRasterizer, createChartToolProvider, createOfficeChartToolProvider, layoutChart, } from "@pixerate/editor/chart";
3
3
  /**
4
4
  * Svelte 5 rune: subscribes to a `ChartController` (or creates one from options) and
5
5
  * exposes its state reactively with bound actions.
@@ -73,6 +73,19 @@ export function useChartToolProvider(registry, controller, options = {}) {
73
73
  return target.register(createChartToolProvider(controller, { ...rest, rasterize: rasterize === false ? undefined : (rasterize ?? createChartRasterizer()) }));
74
74
  });
75
75
  }
76
+ /**
77
+ * Registers the Office-file chart tools (`createOfficeChartToolProvider`: `list_file_charts`,
78
+ * `get_file_chart`, and `load_file_chart` with a `controller`) for the lifetime of the calling
79
+ * component. Pass a getter to follow a changing registry.
80
+ */
81
+ export function useOfficeChartToolProvider(registry, options = {}) {
82
+ $effect(() => {
83
+ const target = typeof registry === "function" ? registry() : registry;
84
+ if (!target)
85
+ return;
86
+ return target.register(createOfficeChartToolProvider(untrack(() => options)));
87
+ });
88
+ }
76
89
  /**
77
90
  * A `ChartPresence` and `ChartDirector` for a chart: pass `presence` and `sceneRef` to
78
91
  * `ChartCanvas`, and `director` to `useChartToolProvider` so agent edits are acted out with a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -115,7 +115,7 @@
115
115
  "@tiptap/extension-bubble-menu": "^2.11.5",
116
116
  "@tiptap/extension-placeholder": "^2.11.5",
117
117
  "@tiptap/starter-kit": "^2.11.5",
118
- "@pixerate/editor": "0.51.0"
118
+ "@pixerate/editor": "0.53.0"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "@dagrejs/dagre": "^1.1.4",