@liggi/figkit 0.5.0 → 0.6.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/viz/spec.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { z } from 'zod';
3
3
  import { sequenceShape, sequenceChecks } from './sequence-spec.js';
4
4
  import { statesShape, statesChecks } from './states-spec.js';
5
+ import { mapShape, mapChecks } from './map-spec.js';
5
6
 
6
7
  const TONE = z.enum(['accent', 'second', 'good', 'bad']);
7
8
  const label = z.string({ error: 'needs a label' }).trim().min(1, 'needs a label').max(40, 'keep labels to 40 characters');
@@ -287,11 +288,14 @@ export const SequenceSpec = z.object({ type: z.literal('sequence'), title, note:
287
288
  /** The states one thing moves through and the moves between them, with optional counts on the moves. */
288
289
  export const StatesSpec = z.object({ type: z.literal('states'), title, note: common.note, source: common.source, style: common.style, ...statesShape }).strict();
289
290
 
290
- export const Spec = z.discriminatedUnion('type', [SplitSpec, BarsSpec, EstimatesSpec, BeforeAfterSpec, DumbbellSpec, SeriesSpec, EntitiesSpec, GroupsSpec, LinesSpec, PanelsSpec, HeatmapSpec, DotsSpec, ScatterSpec, UnitsSpec, SequenceSpec, StatesSpec]);
291
- export const TYPES = { split: SplitSpec, bars: BarsSpec, estimates: EstimatesSpec, 'before-after': BeforeAfterSpec, dumbbell: DumbbellSpec, series: SeriesSpec, entities: EntitiesSpec, groups: GroupsSpec, lines: LinesSpec, panels: PanelsSpec, heatmap: HeatmapSpec, dots: DotsSpec, scatter: ScatterSpec, units: UnitsSpec, sequence: SequenceSpec, states: StatesSpec };
291
+ /** A whole system: parts grouped by subsystem and the links between them, laid out by figkit. */
292
+ export const MapSpec = z.object({ type: z.literal('map'), title, note: common.note, source: common.source, style: common.style, ...mapShape }).strict();
292
293
 
294
+ export const Spec = z.discriminatedUnion('type', [SplitSpec, BarsSpec, EstimatesSpec, BeforeAfterSpec, DumbbellSpec, SeriesSpec, EntitiesSpec, GroupsSpec, LinesSpec, PanelsSpec, HeatmapSpec, DotsSpec, ScatterSpec, UnitsSpec, SequenceSpec, StatesSpec, MapSpec]);
295
+ export const TYPES = { split: SplitSpec, bars: BarsSpec, estimates: EstimatesSpec, 'before-after': BeforeAfterSpec, dumbbell: DumbbellSpec, series: SeriesSpec, entities: EntitiesSpec, groups: GroupsSpec, lines: LinesSpec, panels: PanelsSpec, heatmap: HeatmapSpec, dots: DotsSpec, scatter: ScatterSpec, units: UnitsSpec, sequence: SequenceSpec, states: StatesSpec, map: MapSpec };
293
296
 
294
- const items = (s) => s.parts ?? s.bars ?? s.rows ?? s.records ?? s.messages ?? (s.type === 'states' ? [...s.states, ...s.moves] : null) ?? (s.type === 'scatter' ? s.points : s.type === 'dots' ? s.groups : (s.after ? [s.after] : []));
297
+
298
+ const items = (s) => s.parts ?? s.bars ?? s.rows ?? s.records ?? s.messages ?? (s.type === 'states' ? [...s.states, ...s.moves] : s.type === 'map' ? [...s.parts, ...s.links] : null) ?? (s.type === 'scatter' ? s.points : s.type === 'dots' ? s.groups : (s.after ? [s.after] : []));
295
299
  const kind = (v) => (typeof v === 'number' ? 'number' : 'date');
296
300
 
297
301
 
@@ -342,6 +346,7 @@ function linesChecks(s, at = '') {
342
346
  function crossChecks(s) {
343
347
  if (s.type === 'sequence') return sequenceChecks(s);
344
348
  if (s.type === 'states') return statesChecks(s);
349
+ if (s.type === 'map') return mapChecks(s);
345
350
  if (s.type === 'groups') return groupsChecks(s);
346
351
  if (s.type === 'lines') return linesChecks(s);
347
352
  if (s.type === 'panels') {