tinybase 8.5.0-beta.3 → 8.5.0-beta.4

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 (151) hide show
  1. package/@types/ui-react-dom-charts/index.d.ts +170 -37
  2. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +180 -41
  3. package/common/index.js +1 -1
  4. package/common/with-schemas/index.js +1 -1
  5. package/index.js +3 -2
  6. package/mergeable-store/index.js +3 -2
  7. package/mergeable-store/with-schemas/index.js +3 -2
  8. package/min/index.js +1 -1
  9. package/min/index.js.gz +0 -0
  10. package/min/mergeable-store/index.js +1 -1
  11. package/min/mergeable-store/index.js.gz +0 -0
  12. package/min/mergeable-store/with-schemas/index.js +1 -1
  13. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  14. package/min/omni/index.js +1 -1
  15. package/min/omni/index.js.gz +0 -0
  16. package/min/omni/with-schemas/index.js +1 -1
  17. package/min/omni/with-schemas/index.js.gz +0 -0
  18. package/min/persisters/index.js +1 -1
  19. package/min/persisters/index.js.gz +0 -0
  20. package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  21. package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
  22. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  23. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
  24. package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
  25. package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
  26. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  27. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
  28. package/min/persisters/persister-electric-sql/index.js +1 -1
  29. package/min/persisters/persister-electric-sql/index.js.gz +0 -0
  30. package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  31. package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
  32. package/min/persisters/persister-expo-sqlite/index.js +1 -1
  33. package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
  34. package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  35. package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
  36. package/min/persisters/persister-libsql/index.js +1 -1
  37. package/min/persisters/persister-libsql/index.js.gz +0 -0
  38. package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
  39. package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
  40. package/min/persisters/persister-pglite/index.js +1 -1
  41. package/min/persisters/persister-pglite/index.js.gz +0 -0
  42. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  43. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  44. package/min/persisters/persister-postgres/index.js +1 -1
  45. package/min/persisters/persister-postgres/index.js.gz +0 -0
  46. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  47. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  48. package/min/persisters/persister-powersync/index.js +1 -1
  49. package/min/persisters/persister-powersync/index.js.gz +0 -0
  50. package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
  51. package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
  52. package/min/persisters/persister-react-native-sqlite/index.js +1 -1
  53. package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
  54. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  55. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
  56. package/min/persisters/persister-remote/index.js +1 -1
  57. package/min/persisters/persister-remote/index.js.gz +0 -0
  58. package/min/persisters/persister-remote/with-schemas/index.js +1 -1
  59. package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
  60. package/min/persisters/persister-sqlite-bun/index.js +1 -1
  61. package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
  62. package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  63. package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
  64. package/min/persisters/persister-sqlite-wasm/index.js +1 -1
  65. package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
  66. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  67. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
  68. package/min/persisters/persister-sqlite3/index.js +1 -1
  69. package/min/persisters/persister-sqlite3/index.js.gz +0 -0
  70. package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  71. package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
  72. package/min/persisters/with-schemas/index.js +1 -1
  73. package/min/persisters/with-schemas/index.js.gz +0 -0
  74. package/min/synchronizers/index.js +1 -1
  75. package/min/synchronizers/index.js.gz +0 -0
  76. package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
  77. package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  78. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
  79. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  80. package/min/synchronizers/synchronizer-local/index.js +1 -1
  81. package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
  82. package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  83. package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
  84. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  85. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  86. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  87. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  88. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  89. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  90. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  91. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  92. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  93. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
  94. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  95. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
  96. package/min/synchronizers/with-schemas/index.js +1 -1
  97. package/min/synchronizers/with-schemas/index.js.gz +0 -0
  98. package/min/ui-react-dom-charts/index.js +1 -1
  99. package/min/ui-react-dom-charts/index.js.gz +0 -0
  100. package/min/ui-react-dom-charts/with-schemas/index.js +1 -1
  101. package/min/ui-react-dom-charts/with-schemas/index.js.gz +0 -0
  102. package/min/with-schemas/index.js +1 -1
  103. package/min/with-schemas/index.js.gz +0 -0
  104. package/omni/index.js +7 -6
  105. package/omni/with-schemas/index.js +7 -6
  106. package/package.json +3 -3
  107. package/persisters/index.js +1 -1
  108. package/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  109. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  110. package/persisters/persister-durable-object-sql-storage/index.js +1 -1
  111. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  112. package/persisters/persister-electric-sql/index.js +1 -1
  113. package/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  114. package/persisters/persister-expo-sqlite/index.js +1 -1
  115. package/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  116. package/persisters/persister-libsql/index.js +1 -1
  117. package/persisters/persister-libsql/with-schemas/index.js +1 -1
  118. package/persisters/persister-pglite/index.js +1 -1
  119. package/persisters/persister-pglite/with-schemas/index.js +1 -1
  120. package/persisters/persister-postgres/index.js +1 -1
  121. package/persisters/persister-postgres/with-schemas/index.js +1 -1
  122. package/persisters/persister-powersync/index.js +1 -1
  123. package/persisters/persister-powersync/with-schemas/index.js +1 -1
  124. package/persisters/persister-react-native-sqlite/index.js +1 -1
  125. package/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  126. package/persisters/persister-remote/index.js +3 -3
  127. package/persisters/persister-remote/with-schemas/index.js +3 -3
  128. package/persisters/persister-sqlite-bun/index.js +1 -1
  129. package/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  130. package/persisters/persister-sqlite-wasm/index.js +1 -1
  131. package/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  132. package/persisters/persister-sqlite3/index.js +1 -1
  133. package/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  134. package/persisters/with-schemas/index.js +1 -1
  135. package/readme.md +2 -2
  136. package/releases.md +2 -2
  137. package/synchronizers/index.js +2 -1
  138. package/synchronizers/synchronizer-broadcast-channel/index.js +2 -1
  139. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +2 -1
  140. package/synchronizers/synchronizer-local/index.js +2 -1
  141. package/synchronizers/synchronizer-local/with-schemas/index.js +2 -1
  142. package/synchronizers/synchronizer-ws-client/index.js +2 -1
  143. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -1
  144. package/synchronizers/synchronizer-ws-server/index.js +2 -1
  145. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +2 -1
  146. package/synchronizers/synchronizer-ws-server-durable-object/index.js +2 -1
  147. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +2 -1
  148. package/synchronizers/with-schemas/index.js +2 -1
  149. package/ui-react-dom-charts/index.js +688 -324
  150. package/ui-react-dom-charts/with-schemas/index.js +688 -324
  151. package/with-schemas/index.js +3 -2
@@ -117,9 +117,10 @@ export type QuerySourceProps = {
117
117
  export type BindingProps = {
118
118
  /**
119
119
  * The Id of the Cell that provides each data point's x value. Finite numbers
120
- * can be used as continuous x values in line charts, while strings and
121
- * booleans are used as category values. Boolean category labels are rendered
122
- * as `true` and `false`.
120
+ * can be used as continuous linear x values in line charts, ISO date strings
121
+ * can be used as time x values, and other strings and booleans are used as
122
+ * category values. Boolean category labels are rendered as `true` and
123
+ * `false`.
123
124
  * @category Prop
124
125
  * @since v8.5.0
125
126
  */
@@ -175,9 +176,10 @@ export type SeriesProps = {
175
176
  readonly className?: string;
176
177
  /**
177
178
  * The Id of the Cell that provides each data point's x value. Finite numbers
178
- * can be used as continuous x values in line series, while strings and
179
- * booleans are used as category values. Boolean category labels are rendered
180
- * as `true` and `false`.
179
+ * can be used as continuous linear x values in line series, ISO date strings
180
+ * can be used as time x values, and other strings and booleans are used as
181
+ * category values. Boolean category labels are rendered as `true` and
182
+ * `false`.
181
183
  * @category Prop
182
184
  * @since v8.5.0
183
185
  */
@@ -224,16 +226,35 @@ export type SeriesProps = {
224
226
  };
225
227
 
226
228
  /**
227
- * The XAxisProps type describes the props that configure the x axis of a
228
- * CartesianChart component.
229
- *
230
- * The x axis is inferred by default. Use an XAxis component child when you want
231
- * to override its title, numeric bounds, tick values, tick count, tick labels,
232
- * or SVG class name.
229
+ * The XAxisScale type describes how x-axis values should be interpreted:
230
+ * `auto`, `category`, `linear`, or `time`.
231
+ * @category Configuration
232
+ * @since v8.5.0
233
+ */
234
+ export type XAxisScale = 'auto' | 'category' | 'linear' | 'time';
235
+
236
+ /**
237
+ * The TimestampUnit type describes the unit used by numeric timestamp values on
238
+ * a time x axis: `millisecond` or `second`.
239
+ * @category Configuration
240
+ * @since v8.5.0
241
+ */
242
+ export type TimestampUnit = 'millisecond' | 'second';
243
+
244
+ /**
245
+ * The TimeValue type describes values that can be used for explicit bounds and
246
+ * ticks on a time x axis: numbers, ISO date strings, or Date objects.
247
+ * @category Configuration
248
+ * @since v8.5.0
249
+ */
250
+ export type TimeValue = number | string | Date;
251
+
252
+ /**
253
+ * The BaseXAxisProps type describes props shared by all x-axis configurations.
233
254
  * @category Configuration
234
255
  * @since v8.5.0
235
256
  */
236
- export type XAxisProps = {
257
+ export type BaseXAxisProps = {
237
258
  /**
238
259
  * An optional string that will be added to the class attribute of the x-axis
239
260
  * SVG group element.
@@ -249,7 +270,43 @@ export type XAxisProps = {
249
270
  */
250
271
  readonly title?: string;
251
272
  /**
252
- * An optional minimum x-axis bound for continuous numeric x values.
273
+ * An optional preferred number of ticks to render on a continuous x axis.
274
+ *
275
+ * The actual number of ticks may vary so that labels remain readable.
276
+ * @category Prop
277
+ * @since v8.5.0
278
+ */
279
+ readonly tickCount?: number;
280
+ };
281
+
282
+ /**
283
+ * The LinearXAxisProps type describes x-axis configuration for automatically
284
+ * inferred, categorical, and linear axes.
285
+ * @category Configuration
286
+ * @since v8.5.0
287
+ */
288
+ export type LinearXAxisProps = BaseXAxisProps & {
289
+ /**
290
+ * An optional scale to use for the x axis.
291
+ *
292
+ * The default `auto` scale infers linear axes from numeric line-series x
293
+ * values, time axes from ISO date strings, and category axes otherwise. Use
294
+ * `time` explicitly for numeric Unix timestamp values.
295
+ * @category Prop
296
+ * @since v8.5.0
297
+ */
298
+ readonly scale?: 'auto' | 'category' | 'linear';
299
+ /**
300
+ * The unit for numeric timestamp values on a time x axis.
301
+ *
302
+ * This prop is ignored unless the scale prop is `time`, and defaults to
303
+ * `millisecond`.
304
+ * @category Prop
305
+ * @since v8.5.0
306
+ */
307
+ readonly timestampUnit?: never;
308
+ /**
309
+ * An optional minimum x-axis bound for continuous numeric or time x values.
253
310
  *
254
311
  * This prop is ignored when the x axis is categorical.
255
312
  * @category Prop
@@ -257,7 +314,7 @@ export type XAxisProps = {
257
314
  */
258
315
  readonly min?: number;
259
316
  /**
260
- * An optional maximum x-axis bound for continuous numeric x values.
317
+ * An optional maximum x-axis bound for continuous numeric or time x values.
261
318
  *
262
319
  * This prop is ignored when the x axis is categorical.
263
320
  * @category Prop
@@ -265,7 +322,7 @@ export type XAxisProps = {
265
322
  */
266
323
  readonly max?: number;
267
324
  /**
268
- * Optional numeric tick values to use for a continuous x axis.
325
+ * Optional tick values to use for a continuous numeric or time x axis.
269
326
  *
270
327
  * This prop is ignored when the x axis is categorical.
271
328
  * @category Prop
@@ -273,24 +330,90 @@ export type XAxisProps = {
273
330
  */
274
331
  readonly ticks?: readonly number[];
275
332
  /**
276
- * An optional preferred number of ticks to render on a continuous x axis.
333
+ * An optional function for formatting x-axis tick labels.
277
334
  *
278
- * The actual number of ticks may vary so that labels remain readable.
335
+ * It receives the original tick value for category axes, the numeric tick
336
+ * value for linear axes, or a Date object for time axes. For time axes, the
337
+ * normalized epoch millisecond timestamp is provided as a second argument.
279
338
  * @category Prop
280
339
  * @since v8.5.0
281
340
  */
282
- readonly tickCount?: number;
341
+ readonly tickFormatter?: (tick: boolean | number | string) => string;
342
+ };
343
+
344
+ /**
345
+ * The TimeXAxisProps type describes x-axis configuration for time axes.
346
+ * @category Configuration
347
+ * @since v8.5.0
348
+ */
349
+ export type TimeXAxisProps = BaseXAxisProps & {
350
+ /**
351
+ * An optional scale to use for the x axis.
352
+ *
353
+ * The default `auto` scale infers linear axes from numeric line-series x
354
+ * values, time axes from ISO date strings, and category axes otherwise. Use
355
+ * `time` explicitly for numeric Unix timestamp values.
356
+ * @category Prop
357
+ * @since v8.5.0
358
+ */
359
+ readonly scale: 'time';
360
+ /**
361
+ * The unit for numeric timestamp values on a time x axis.
362
+ *
363
+ * This prop is ignored unless the scale prop is `time`, and defaults to
364
+ * `millisecond`.
365
+ * @category Prop
366
+ * @since v8.5.0
367
+ */
368
+ readonly timestampUnit?: TimestampUnit;
369
+ /**
370
+ * An optional minimum x-axis bound for continuous numeric or time x values.
371
+ *
372
+ * This prop is ignored when the x axis is categorical.
373
+ * @category Prop
374
+ * @since v8.5.0
375
+ */
376
+ readonly min?: TimeValue;
377
+ /**
378
+ * An optional maximum x-axis bound for continuous numeric or time x values.
379
+ *
380
+ * This prop is ignored when the x axis is categorical.
381
+ * @category Prop
382
+ * @since v8.5.0
383
+ */
384
+ readonly max?: TimeValue;
385
+ /**
386
+ * Optional tick values to use for a continuous numeric or time x axis.
387
+ *
388
+ * This prop is ignored when the x axis is categorical.
389
+ * @category Prop
390
+ * @since v8.5.0
391
+ */
392
+ readonly ticks?: readonly TimeValue[];
283
393
  /**
284
394
  * An optional function for formatting x-axis tick labels.
285
395
  *
286
- * It receives the original tick value, which can be a finite number, string,
287
- * or boolean.
396
+ * It receives the original tick value for category axes, the numeric tick
397
+ * value for linear axes, or a Date object for time axes. For time axes, the
398
+ * normalized epoch millisecond timestamp is provided as a second argument.
288
399
  * @category Prop
289
400
  * @since v8.5.0
290
401
  */
291
- readonly tickFormatter?: (tick: boolean | number | string) => string;
402
+ readonly tickFormatter?: (tick: Date, timestamp: number) => string;
292
403
  };
293
404
 
405
+ /**
406
+ * The XAxisProps type describes the props that configure the x axis of a
407
+ * CartesianChart component, LineChart component, or BarChart component.
408
+ *
409
+ * The x axis is inferred by default. Use an XAxis component child when you
410
+ * want to override its title, scale, continuous bounds, tick values, tick
411
+ * count, tick labels, or SVG class name.
412
+ * @category Configuration
413
+ * @since v8.5.0
414
+ */
415
+ export type XAxisProps = LinearXAxisProps | TimeXAxisProps;
416
+
294
417
  /**
295
418
  * The YAxisProps type describes the props that configure the y axis of a
296
419
  * CartesianChart component.
@@ -410,11 +533,12 @@ export function CartesianChart(
410
533
  ): ComponentReturnType;
411
534
 
412
535
  /**
413
- * The XAxis component configures the x axis of a CartesianChart component.
536
+ * The XAxis component configures the x axis of a CartesianChart component,
537
+ * LineChart component, or BarChart component.
414
538
  *
415
539
  * It is a configuration child rather than a separately rendered SVG element:
416
- * include zero or one XAxis component in a CartesianChart component's children.
417
- * If omitted, the x axis is inferred from the chart's series.
540
+ * include zero or one XAxis component in a chart's children. If omitted, the x
541
+ * axis is inferred from the chart's series.
418
542
  *
419
543
  * See the Axis Overrides (React) demo for this component in action:
420
544
  *
@@ -444,9 +568,9 @@ export function YAxis(props: YAxisProps): ComponentReturnType;
444
568
  /**
445
569
  * The LineSeries component renders a line series in a CartesianChart component.
446
570
  * If every x value in every series is a finite number, the x axis is rendered
447
- * as a continuous numeric scale. If any x value is a string or boolean, the x
448
- * axis is rendered categorically. When sortCellId is omitted, rows are sorted
449
- * by xCellId.
571
+ * as a continuous linear scale. ISO date strings are inferred as a time scale.
572
+ * Other strings and booleans are rendered categorically. When sortCellId is
573
+ * omitted, rows are sorted by xCellId.
450
574
  *
451
575
  * See the Composing Charts (React) demo for this component in action:
452
576
  *
@@ -459,8 +583,10 @@ export function LineSeries(props: SeriesProps): ComponentReturnType;
459
583
 
460
584
  /**
461
585
  * The BarSeries component renders a bar series in a CartesianChart component.
462
- * Its x values are always rendered categorically, even when they are finite
463
- * numbers. Boolean category labels are rendered as `true` and `false`.
586
+ * Its x values are rendered categorically by default, even when they are finite
587
+ * numbers. Add an XAxis component with a `linear` or `time` scale to position
588
+ * bars continuously. Boolean category labels are rendered as `true` and
589
+ * `false`.
464
590
  *
465
591
  * See the Composing Charts (React) demo for this component in action:
466
592
  *
@@ -473,9 +599,11 @@ export function BarSeries(props: SeriesProps): ComponentReturnType;
473
599
 
474
600
  /**
475
601
  * The LineChart component renders a line chart from TinyBase data. If every x
476
- * value is a finite number, the x axis is rendered as a continuous numeric
477
- * scale. If any x value is a string or boolean, the x axis is rendered
478
- * categorically. When sortCellId is omitted, rows are sorted by xCellId.
602
+ * value is a finite number, the x axis is rendered as a continuous linear
603
+ * scale. ISO date strings are inferred as a time scale. Other strings and
604
+ * booleans are rendered categorically. Add XAxis component and YAxis component
605
+ * children to override axis configuration. When sortCellId is omitted, rows are
606
+ * sorted by xCellId.
479
607
  *
480
608
  * See the <LineChart /> (React) demo for this component in action:
481
609
  *
@@ -519,13 +647,16 @@ export function BarSeries(props: SeriesProps): ComponentReturnType;
519
647
  * ```
520
648
  */
521
649
  export function LineChart(
522
- props: (TableSourceProps | QuerySourceProps) & BindingProps & ChartProps,
650
+ props: (TableSourceProps | QuerySourceProps) &
651
+ BindingProps &
652
+ ChartProps & {readonly children?: ReactNode},
523
653
  ): ComponentReturnType;
524
654
 
525
655
  /**
526
656
  * The BarChart component renders a bar chart from TinyBase data. Its x values
527
- * are always rendered categorically, even when they are finite numbers. Boolean
528
- * category labels are rendered as `true` and `false`.
657
+ * are rendered categorically by default, even when they are finite numbers. Add
658
+ * an XAxis component with a `linear` or `time` scale to position bars
659
+ * continuously. Boolean category labels are rendered as `true` and `false`.
529
660
  *
530
661
  * See the Sorting And Types (React) demo for this component in action:
531
662
  *
@@ -570,5 +701,7 @@ export function LineChart(
570
701
  * ```
571
702
  */
572
703
  export function BarChart(
573
- props: (TableSourceProps | QuerySourceProps) & BindingProps & ChartProps,
704
+ props: (TableSourceProps | QuerySourceProps) &
705
+ BindingProps &
706
+ ChartProps & {readonly children?: ReactNode},
574
707
  ): ComponentReturnType;
@@ -135,9 +135,10 @@ export type BindingProps<
135
135
  > = {
136
136
  /**
137
137
  * The Id of the Cell that provides each data point's x value. Finite numbers
138
- * can be used as continuous x values in line charts, while strings and
139
- * booleans are used as category values. Boolean category labels are rendered
140
- * as `true` and `false`.
138
+ * can be used as continuous linear x values in line charts, ISO date strings
139
+ * can be used as time x values, and other strings and booleans are used as
140
+ * category values. Boolean category labels are rendered as `true` and
141
+ * `false`.
141
142
  * @category Prop
142
143
  * @since v8.5.0
143
144
  */
@@ -193,9 +194,10 @@ export type SeriesProps<CellId extends Id = Id> = {
193
194
  readonly className?: string;
194
195
  /**
195
196
  * The Id of the Cell that provides each data point's x value. Finite numbers
196
- * can be used as continuous x values in line series, while strings and
197
- * booleans are used as category values. Boolean category labels are rendered
198
- * as `true` and `false`.
197
+ * can be used as continuous linear x values in line series, ISO date strings
198
+ * can be used as time x values, and other strings and booleans are used as
199
+ * category values. Boolean category labels are rendered as `true` and
200
+ * `false`.
199
201
  * @category Prop
200
202
  * @since v8.5.0
201
203
  */
@@ -242,16 +244,35 @@ export type SeriesProps<CellId extends Id = Id> = {
242
244
  };
243
245
 
244
246
  /**
245
- * The XAxisProps type describes the props that configure the x axis of a
246
- * CartesianChart component.
247
- *
248
- * The x axis is inferred by default. Use an XAxis component child when you want
249
- * to override its title, numeric bounds, tick values, tick count, tick labels,
250
- * or SVG class name.
247
+ * The XAxisScale type describes how x-axis values should be interpreted:
248
+ * `auto`, `category`, `linear`, or `time`.
249
+ * @category Configuration
250
+ * @since v8.5.0
251
+ */
252
+ export type XAxisScale = 'auto' | 'category' | 'linear' | 'time';
253
+
254
+ /**
255
+ * The TimestampUnit type describes the unit used by numeric timestamp values on
256
+ * a time x axis: `millisecond` or `second`.
257
+ * @category Configuration
258
+ * @since v8.5.0
259
+ */
260
+ export type TimestampUnit = 'millisecond' | 'second';
261
+
262
+ /**
263
+ * The TimeValue type describes values that can be used for explicit bounds and
264
+ * ticks on a time x axis: numbers, ISO date strings, or Date objects.
265
+ * @category Configuration
266
+ * @since v8.5.0
267
+ */
268
+ export type TimeValue = number | string | Date;
269
+
270
+ /**
271
+ * The BaseXAxisProps type describes props shared by all x-axis configurations.
251
272
  * @category Configuration
252
273
  * @since v8.5.0
253
274
  */
254
- export type XAxisProps = {
275
+ export type BaseXAxisProps = {
255
276
  /**
256
277
  * An optional string that will be added to the class attribute of the x-axis
257
278
  * SVG group element.
@@ -267,7 +288,43 @@ export type XAxisProps = {
267
288
  */
268
289
  readonly title?: string;
269
290
  /**
270
- * An optional minimum x-axis bound for continuous numeric x values.
291
+ * An optional preferred number of ticks to render on a continuous x axis.
292
+ *
293
+ * The actual number of ticks may vary so that labels remain readable.
294
+ * @category Prop
295
+ * @since v8.5.0
296
+ */
297
+ readonly tickCount?: number;
298
+ };
299
+
300
+ /**
301
+ * The LinearXAxisProps type describes x-axis configuration for automatically
302
+ * inferred, categorical, and linear axes.
303
+ * @category Configuration
304
+ * @since v8.5.0
305
+ */
306
+ export type LinearXAxisProps = BaseXAxisProps & {
307
+ /**
308
+ * An optional scale to use for the x axis.
309
+ *
310
+ * The default `auto` scale infers linear axes from numeric line-series x
311
+ * values, time axes from ISO date strings, and category axes otherwise. Use
312
+ * `time` explicitly for numeric Unix timestamp values.
313
+ * @category Prop
314
+ * @since v8.5.0
315
+ */
316
+ readonly scale?: 'auto' | 'category' | 'linear';
317
+ /**
318
+ * The unit for numeric timestamp values on a time x axis.
319
+ *
320
+ * This prop is ignored unless the scale prop is `time`, and defaults to
321
+ * `millisecond`.
322
+ * @category Prop
323
+ * @since v8.5.0
324
+ */
325
+ readonly timestampUnit?: never;
326
+ /**
327
+ * An optional minimum x-axis bound for continuous numeric or time x values.
271
328
  *
272
329
  * This prop is ignored when the x axis is categorical.
273
330
  * @category Prop
@@ -275,7 +332,7 @@ export type XAxisProps = {
275
332
  */
276
333
  readonly min?: number;
277
334
  /**
278
- * An optional maximum x-axis bound for continuous numeric x values.
335
+ * An optional maximum x-axis bound for continuous numeric or time x values.
279
336
  *
280
337
  * This prop is ignored when the x axis is categorical.
281
338
  * @category Prop
@@ -283,7 +340,7 @@ export type XAxisProps = {
283
340
  */
284
341
  readonly max?: number;
285
342
  /**
286
- * Optional numeric tick values to use for a continuous x axis.
343
+ * Optional tick values to use for a continuous numeric or time x axis.
287
344
  *
288
345
  * This prop is ignored when the x axis is categorical.
289
346
  * @category Prop
@@ -291,24 +348,90 @@ export type XAxisProps = {
291
348
  */
292
349
  readonly ticks?: readonly number[];
293
350
  /**
294
- * An optional preferred number of ticks to render on a continuous x axis.
351
+ * An optional function for formatting x-axis tick labels.
295
352
  *
296
- * The actual number of ticks may vary so that labels remain readable.
353
+ * It receives the original tick value for category axes, the numeric tick
354
+ * value for linear axes, or a Date object for time axes. For time axes, the
355
+ * normalized epoch millisecond timestamp is provided as a second argument.
297
356
  * @category Prop
298
357
  * @since v8.5.0
299
358
  */
300
- readonly tickCount?: number;
359
+ readonly tickFormatter?: (tick: boolean | number | string) => string;
360
+ };
361
+
362
+ /**
363
+ * The TimeXAxisProps type describes x-axis configuration for time axes.
364
+ * @category Configuration
365
+ * @since v8.5.0
366
+ */
367
+ export type TimeXAxisProps = BaseXAxisProps & {
368
+ /**
369
+ * An optional scale to use for the x axis.
370
+ *
371
+ * The default `auto` scale infers linear axes from numeric line-series x
372
+ * values, time axes from ISO date strings, and category axes otherwise. Use
373
+ * `time` explicitly for numeric Unix timestamp values.
374
+ * @category Prop
375
+ * @since v8.5.0
376
+ */
377
+ readonly scale: 'time';
378
+ /**
379
+ * The unit for numeric timestamp values on a time x axis.
380
+ *
381
+ * This prop is ignored unless the scale prop is `time`, and defaults to
382
+ * `millisecond`.
383
+ * @category Prop
384
+ * @since v8.5.0
385
+ */
386
+ readonly timestampUnit?: TimestampUnit;
387
+ /**
388
+ * An optional minimum x-axis bound for continuous numeric or time x values.
389
+ *
390
+ * This prop is ignored when the x axis is categorical.
391
+ * @category Prop
392
+ * @since v8.5.0
393
+ */
394
+ readonly min?: TimeValue;
395
+ /**
396
+ * An optional maximum x-axis bound for continuous numeric or time x values.
397
+ *
398
+ * This prop is ignored when the x axis is categorical.
399
+ * @category Prop
400
+ * @since v8.5.0
401
+ */
402
+ readonly max?: TimeValue;
403
+ /**
404
+ * Optional tick values to use for a continuous numeric or time x axis.
405
+ *
406
+ * This prop is ignored when the x axis is categorical.
407
+ * @category Prop
408
+ * @since v8.5.0
409
+ */
410
+ readonly ticks?: readonly TimeValue[];
301
411
  /**
302
412
  * An optional function for formatting x-axis tick labels.
303
413
  *
304
- * It receives the original tick value, which can be a finite number, string,
305
- * or boolean.
414
+ * It receives the original tick value for category axes, the numeric tick
415
+ * value for linear axes, or a Date object for time axes. For time axes, the
416
+ * normalized epoch millisecond timestamp is provided as a second argument.
306
417
  * @category Prop
307
418
  * @since v8.5.0
308
419
  */
309
- readonly tickFormatter?: (tick: boolean | number | string) => string;
420
+ readonly tickFormatter?: (tick: Date, timestamp: number) => string;
310
421
  };
311
422
 
423
+ /**
424
+ * The XAxisProps type describes the props that configure the x axis of a
425
+ * CartesianChart component, LineChart component, or BarChart component.
426
+ *
427
+ * The x axis is inferred by default. Use an XAxis component child when you
428
+ * want to override its title, scale, continuous bounds, tick values, tick
429
+ * count, tick labels, or SVG class name.
430
+ * @category Configuration
431
+ * @since v8.5.0
432
+ */
433
+ export type XAxisProps = LinearXAxisProps | TimeXAxisProps;
434
+
312
435
  /**
313
436
  * The YAxisProps type describes the props that configure the y axis of a
314
437
  * CartesianChart component.
@@ -478,11 +601,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
478
601
  };
479
602
 
480
603
  /**
481
- * The XAxis component configures the x axis of a CartesianChart component.
604
+ * The XAxis component configures the x axis of a CartesianChart component,
605
+ * LineChart component, or BarChart component.
482
606
  *
483
607
  * It is a configuration child rather than a separately rendered SVG element:
484
- * include zero or one XAxis component in a CartesianChart component's children.
485
- * If omitted, the x axis is inferred from the chart's series.
608
+ * include zero or one XAxis component in a chart's children. If omitted, the x
609
+ * axis is inferred from the chart's series.
486
610
  *
487
611
  * See the Axis Overrides (React) demo for this component in action:
488
612
  *
@@ -512,9 +636,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
512
636
  /**
513
637
  * The LineSeries component renders a line series in a CartesianChart component.
514
638
  * If every x value in every series is a finite number, the x axis is rendered
515
- * as a continuous numeric scale. If any x value is a string or boolean, the x
516
- * axis is rendered categorically. When sortCellId is omitted, rows are sorted
517
- * by xCellId.
639
+ * as a continuous linear scale. ISO date strings are inferred as a time scale.
640
+ * Other strings and booleans are rendered categorically. When sortCellId is
641
+ * omitted, rows are sorted by xCellId.
518
642
  *
519
643
  * See the Composing Charts (React) demo for this component in action:
520
644
  *
@@ -527,8 +651,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
527
651
 
528
652
  /**
529
653
  * The BarSeries component renders a bar series in a CartesianChart component.
530
- * Its x values are always rendered categorically, even when they are finite
531
- * numbers. Boolean category labels are rendered as `true` and `false`.
654
+ * Its x values are rendered categorically by default, even when they are finite
655
+ * numbers. Add an XAxis component with a `linear` or `time` scale to position
656
+ * bars continuously. Boolean category labels are rendered as `true` and
657
+ * `false`.
532
658
  *
533
659
  * See the Composing Charts (React) demo for this component in action:
534
660
  *
@@ -541,15 +667,19 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
541
667
 
542
668
  /**
543
669
  * The LineChart component renders a line chart from TinyBase data. If every x
544
- * value is a finite number, the x axis is rendered as a continuous numeric
545
- * scale. If any x value is a string or boolean, the x axis is rendered
546
- * categorically. When sortCellId is omitted, rows are sorted by xCellId.
670
+ * value is a finite number, the x axis is rendered as a continuous linear
671
+ * scale. ISO date strings are inferred as a time scale. Other strings and
672
+ * booleans are rendered categorically. Add XAxis component and YAxis component
673
+ * children to override axis configuration. When sortCellId is omitted, rows are
674
+ * sorted by xCellId.
547
675
  *
548
676
  * This has schema-based typing. The following is a simplified representation:
549
677
  *
550
678
  * ```ts override
551
679
  * LineChart(
552
- * props: (TableSourceProps | QuerySourceProps) & BindingProps & ChartProps,
680
+ * props: (TableSourceProps | QuerySourceProps) &
681
+ * BindingProps &
682
+ * ChartProps & {readonly children?: ReactNode},
553
683
  * ): ComponentReturnType;
554
684
  * ```
555
685
  *
@@ -596,20 +726,26 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
596
726
  */
597
727
  LineChart: (
598
728
  props:
599
- | (TableBindingProps<Schemas> & ChartProps)
600
- | (QuerySourceProps<Schemas> & BindingProps & ChartProps),
729
+ | (TableBindingProps<Schemas> &
730
+ ChartProps & {readonly children?: ReactNode})
731
+ | (QuerySourceProps<Schemas> &
732
+ BindingProps &
733
+ ChartProps & {readonly children?: ReactNode}),
601
734
  ) => ComponentReturnType;
602
735
 
603
736
  /**
604
737
  * The BarChart component renders a bar chart from TinyBase data. Its x values
605
- * are always rendered categorically, even when they are finite numbers. Boolean
606
- * category labels are rendered as `true` and `false`.
738
+ * are rendered categorically by default, even when they are finite numbers. Add
739
+ * an XAxis component with a `linear` or `time` scale to position bars
740
+ * continuously. Boolean category labels are rendered as `true` and `false`.
607
741
  *
608
742
  * This has schema-based typing. The following is a simplified representation:
609
743
  *
610
744
  * ```ts override
611
745
  * BarChart(
612
- * props: (TableSourceProps | QuerySourceProps) & BindingProps & ChartProps,
746
+ * props: (TableSourceProps | QuerySourceProps) &
747
+ * BindingProps &
748
+ * ChartProps & {readonly children?: ReactNode},
613
749
  * ): ComponentReturnType;
614
750
  * ```
615
751
  *
@@ -657,7 +793,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
657
793
  */
658
794
  BarChart: (
659
795
  props:
660
- | (TableBindingProps<Schemas> & ChartProps)
661
- | (QuerySourceProps<Schemas> & BindingProps & ChartProps),
796
+ | (TableBindingProps<Schemas> &
797
+ ChartProps & {readonly children?: ReactNode})
798
+ | (QuerySourceProps<Schemas> &
799
+ BindingProps &
800
+ ChartProps & {readonly children?: ReactNode}),
662
801
  ) => ComponentReturnType;
663
802
  };
package/common/index.js CHANGED
@@ -126,7 +126,7 @@ const getHlcFunctions = (uniqueId, getNow = Date.now) => {
126
126
  const seenHlc = (hlc) => {
127
127
  const previousLogicalTime = lastLogicalTime;
128
128
  const [remoteLogicalTime, remoteCounter] =
129
- isUndefined(hlc) || hlc == '' ? [0, 0] : decodeHlc(hlc);
129
+ isUndefined(hlc) || hlc == EMPTY_STRING ? [0, 0] : decodeHlc(hlc);
130
130
  lastLogicalTime = mathMax(previousLogicalTime, remoteLogicalTime, getNow());
131
131
  lastCounter =
132
132
  lastLogicalTime == previousLogicalTime
@@ -126,7 +126,7 @@ const getHlcFunctions = (uniqueId, getNow = Date.now) => {
126
126
  const seenHlc = (hlc) => {
127
127
  const previousLogicalTime = lastLogicalTime;
128
128
  const [remoteLogicalTime, remoteCounter] =
129
- isUndefined(hlc) || hlc == '' ? [0, 0] : decodeHlc(hlc);
129
+ isUndefined(hlc) || hlc == EMPTY_STRING ? [0, 0] : decodeHlc(hlc);
130
130
  lastLogicalTime = mathMax(previousLogicalTime, remoteLogicalTime, getNow());
131
131
  lastCounter =
132
132
  lastLogicalTime == previousLogicalTime