tinybase 8.5.0-beta.2 → 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 +369 -49
  2. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +396 -70
  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 +10 -10
  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 +13 -13
  136. package/releases.md +57 -57
  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 +753 -306
  150. package/ui-react-dom-charts/with-schemas/index.js +753 -306
  151. package/with-schemas/index.js +3 -2
@@ -1,14 +1,14 @@
1
1
  /**
2
- * The ui-react-dom-charts module of the TinyBase project provides components
3
- * to make it easy to create web-based reactive charts with Store and Queries
2
+ * The ui-react-dom-charts module of the TinyBase project provides components to
3
+ * make it easy to create web-based reactive charts with Store and Queries
4
4
  * objects.
5
5
  *
6
6
  * The components in this module use the react-dom module and so are not
7
7
  * appropriate for environments like React Native (although those in the
8
8
  * lower-level ui-react module are).
9
9
  *
10
- * For a full list of SVG class names that can be styled with CSS, see the
11
- * Using Charts guide.
10
+ * For a full list of SVG class names that can be styled with CSS, see the Using
11
+ * Charts guide.
12
12
  * @packageDocumentation
13
13
  * @module ui-react-dom-charts
14
14
  * @since v8.5.0
@@ -27,8 +27,8 @@ import type {Id} from '../../common/with-schemas/index.d.ts';
27
27
  import type {OptionalSchemas} from '../../store/with-schemas/index.d.ts';
28
28
 
29
29
  /**
30
- * The ChartProps type describes the props that are used to configure the
31
- * chart element that renders a chart.
30
+ * The ChartProps type describes the props that are used to configure the chart
31
+ * element that renders a chart.
32
32
  * @category Configuration
33
33
  * @since v8.5.0
34
34
  */
@@ -44,12 +44,12 @@ export type ChartProps = {
44
44
  };
45
45
 
46
46
  /**
47
- * The ChartTableSourceProps type describes the props that bind a chart to a
47
+ * The TableSourceProps type describes the props that bind a chart to a
48
48
  * Table in a Store.
49
49
  * @category Configuration
50
50
  * @since v8.5.0
51
51
  */
52
- export type ChartTableSourceProps<
52
+ export type TableSourceProps<
53
53
  Schemas extends OptionalSchemas,
54
54
  TableIds extends TableIdFromSchema<Schemas[0]> = TableIdFromSchema<
55
55
  Schemas[0]
@@ -87,12 +87,12 @@ export type ChartTableSourceProps<
87
87
  : never;
88
88
 
89
89
  /**
90
- * The ChartQuerySourceProps type describes the props that bind a chart to a
90
+ * The QuerySourceProps type describes the props that bind a chart to a
91
91
  * Query in a Queries object.
92
92
  * @category Configuration
93
93
  * @since v8.5.0
94
94
  */
95
- export type ChartQuerySourceProps<Schemas extends OptionalSchemas> = {
95
+ export type QuerySourceProps<Schemas extends OptionalSchemas> = {
96
96
  /**
97
97
  * The Id of the query in the Queries object to chart.
98
98
  * @category Prop
@@ -121,22 +121,24 @@ export type ChartQuerySourceProps<Schemas extends OptionalSchemas> = {
121
121
  };
122
122
 
123
123
  /**
124
- * The ChartBindingProps type describes the props that bind a LineChart or
125
- * BarChart component to Cell values in TinyBase data. An x Cell value can be a
126
- * finite number, string, or boolean. A y Cell value must be a finite number.
124
+ * The BindingProps type describes the props that bind a LineChart
125
+ * component or BarChart component to Cell values in TinyBase data. An x Cell
126
+ * value can be a finite number, string, or boolean. A y Cell value must be a
127
+ * finite number.
127
128
  * @category Configuration
128
129
  * @since v8.5.0
129
130
  */
130
- export type ChartBindingProps<
131
+ export type BindingProps<
131
132
  XCellId extends Id = Id,
132
133
  YCellId extends Id = Id,
133
134
  SortCellId extends Id = XCellId,
134
135
  > = {
135
136
  /**
136
137
  * The Id of the Cell that provides each data point's x value. Finite numbers
137
- * can be used as continuous x values in line charts, while strings and
138
- * booleans are used as category values. Boolean category labels are rendered
139
- * 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`.
140
142
  * @category Prop
141
143
  * @since v8.5.0
142
144
  */
@@ -176,13 +178,13 @@ export type ChartBindingProps<
176
178
  };
177
179
 
178
180
  /**
179
- * The ChartSeriesProps type describes the props that bind a chart series to
180
- * Cell values in TinyBase data. An x Cell value can be a finite number,
181
- * string, or boolean. A y Cell value must be a finite number.
181
+ * The SeriesProps type describes the props that bind a chart series to Cell
182
+ * values in TinyBase data. An x Cell value can be a finite number, string, or
183
+ * boolean. A y Cell value must be a finite number.
182
184
  * @category Configuration
183
185
  * @since v8.5.0
184
186
  */
185
- export type ChartSeriesProps<CellId extends Id = Id> = {
187
+ export type SeriesProps<CellId extends Id = Id> = {
186
188
  /**
187
189
  * An optional string that will be added to the class attribute of the series'
188
190
  * SVG group element.
@@ -192,9 +194,10 @@ export type ChartSeriesProps<CellId extends Id = Id> = {
192
194
  readonly className?: string;
193
195
  /**
194
196
  * The Id of the Cell that provides each data point's x value. Finite numbers
195
- * can be used as continuous x values in line series, while strings and
196
- * booleans are used as category values. Boolean category labels are rendered
197
- * 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`.
198
201
  * @category Prop
199
202
  * @since v8.5.0
200
203
  */
@@ -240,6 +243,257 @@ export type ChartSeriesProps<CellId extends Id = Id> = {
240
243
  readonly limit?: number;
241
244
  };
242
245
 
246
+ /**
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.
272
+ * @category Configuration
273
+ * @since v8.5.0
274
+ */
275
+ export type BaseXAxisProps = {
276
+ /**
277
+ * An optional string that will be added to the class attribute of the x-axis
278
+ * SVG group element.
279
+ * @category Prop
280
+ * @since v8.5.0
281
+ */
282
+ readonly className?: string;
283
+ /**
284
+ * An optional title to use for the x axis, defaulting to the x Cell Id, or to
285
+ * a combined title when multiple series use different x Cell Ids.
286
+ * @category Prop
287
+ * @since v8.5.0
288
+ */
289
+ readonly title?: string;
290
+ /**
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.
328
+ *
329
+ * This prop is ignored when the x axis is categorical.
330
+ * @category Prop
331
+ * @since v8.5.0
332
+ */
333
+ readonly min?: number;
334
+ /**
335
+ * An optional maximum x-axis bound for continuous numeric or time x values.
336
+ *
337
+ * This prop is ignored when the x axis is categorical.
338
+ * @category Prop
339
+ * @since v8.5.0
340
+ */
341
+ readonly max?: number;
342
+ /**
343
+ * Optional tick values to use for a continuous numeric or time x axis.
344
+ *
345
+ * This prop is ignored when the x axis is categorical.
346
+ * @category Prop
347
+ * @since v8.5.0
348
+ */
349
+ readonly ticks?: readonly number[];
350
+ /**
351
+ * An optional function for formatting x-axis tick labels.
352
+ *
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.
356
+ * @category Prop
357
+ * @since v8.5.0
358
+ */
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[];
411
+ /**
412
+ * An optional function for formatting x-axis tick labels.
413
+ *
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.
417
+ * @category Prop
418
+ * @since v8.5.0
419
+ */
420
+ readonly tickFormatter?: (tick: Date, timestamp: number) => string;
421
+ };
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
+
435
+ /**
436
+ * The YAxisProps type describes the props that configure the y axis of a
437
+ * CartesianChart component.
438
+ *
439
+ * The y axis is inferred by default. Use a YAxis component child when you want
440
+ * to override its title, numeric bounds, tick values, tick count, tick labels,
441
+ * or SVG class name.
442
+ * @category Configuration
443
+ * @since v8.5.0
444
+ */
445
+ export type YAxisProps = {
446
+ /**
447
+ * An optional string that will be added to the class attribute of the y-axis
448
+ * SVG group element.
449
+ * @category Prop
450
+ * @since v8.5.0
451
+ */
452
+ readonly className?: string;
453
+ /**
454
+ * An optional title to use for the y axis, defaulting to the y Cell Id, y
455
+ * series label, or a combined title when multiple series use different y Cell
456
+ * Ids or labels.
457
+ * @category Prop
458
+ * @since v8.5.0
459
+ */
460
+ readonly title?: string;
461
+ /**
462
+ * An optional minimum y-axis bound.
463
+ * @category Prop
464
+ * @since v8.5.0
465
+ */
466
+ readonly min?: number;
467
+ /**
468
+ * An optional maximum y-axis bound.
469
+ * @category Prop
470
+ * @since v8.5.0
471
+ */
472
+ readonly max?: number;
473
+ /**
474
+ * Optional numeric tick values to use for the y axis.
475
+ * @category Prop
476
+ * @since v8.5.0
477
+ */
478
+ readonly ticks?: readonly number[];
479
+ /**
480
+ * An optional preferred number of ticks to render on the y axis.
481
+ *
482
+ * The actual number of ticks may vary so that labels remain readable.
483
+ * @category Prop
484
+ * @since v8.5.0
485
+ */
486
+ readonly tickCount?: number;
487
+ /**
488
+ * An optional function for formatting y-axis tick labels.
489
+ *
490
+ * It receives the numeric tick value.
491
+ * @category Prop
492
+ * @since v8.5.0
493
+ */
494
+ readonly tickFormatter?: (tick: number) => string;
495
+ };
496
+
243
497
  type NumericCellIdFromSchema<
244
498
  Schemas extends OptionalSchemas,
245
499
  TableId extends TableIdFromSchema<Schemas[0]>,
@@ -252,15 +506,15 @@ type NumericCellIdFromSchema<
252
506
  : never;
253
507
  }[CellIdFromSchema<Schemas[0], TableId>];
254
508
 
255
- type ChartTableBindingProps<
509
+ type TableBindingProps<
256
510
  Schemas extends OptionalSchemas,
257
511
  TableIds extends TableIdFromSchema<Schemas[0]> = TableIdFromSchema<
258
512
  Schemas[0]
259
513
  >,
260
514
  > = TableIds extends infer TableId
261
515
  ? TableId extends TableIdFromSchema<Schemas[0]>
262
- ? ChartTableSourceProps<Schemas, TableId> &
263
- ChartBindingProps<
516
+ ? TableSourceProps<Schemas, TableId> &
517
+ BindingProps<
264
518
  CellIdFromSchema<Schemas[0], TableId>,
265
519
  NumericCellIdFromSchema<Schemas, TableId>,
266
520
  CellIdFromSchema<Schemas[0], TableId>
@@ -277,23 +531,31 @@ type ChartTableBindingProps<
277
531
  export type WithSchemas<Schemas extends OptionalSchemas> = {
278
532
  /**
279
533
  * The CartesianChart component renders a chart frame and provides TinyBase
280
- * source and layout context to child LineSeries and BarSeries components.
534
+ * source and layout context to LineSeries component and BarSeries component
535
+ * children.
281
536
  *
282
537
  * This has schema-based typing. The following is a simplified representation:
283
538
  *
284
539
  * ```ts override
285
540
  * CartesianChart(
286
- * props: (ChartTableSourceProps | ChartQuerySourceProps) &
541
+ * props: (TableSourceProps | QuerySourceProps) &
287
542
  * ChartProps & {readonly children?: ReactNode},
288
543
  * ): ComponentReturnType;
289
544
  * ```
290
545
  *
291
- * The series children declare their own xCellId and yCellId bindings.
546
+ * See the Composing Charts (React) demo for this component in action:
547
+ *
548
+ * ![CartesianChart component example](https://beta.tinybase.org/shots/composing-charts-react-demo.png
549
+ * "CartesianChart component example")
550
+ *
551
+ * The series children declare their own xCellId and yCellId bindings. The
552
+ * optional XAxis component and YAxis component children can be used to
553
+ * configure axis titles, bounds, ticks, and tick formatting.
292
554
  * @category Store components
293
555
  * @since v8.5.0
294
556
  * @example
295
- * This example creates a Store and renders two LineSeries components in a
296
- * CartesianChart.
557
+ * This example creates a Store and renders two LineSeries component children
558
+ * in a CartesianChart component.
297
559
  *
298
560
  * ```jsx
299
561
  * import React from 'react';
@@ -329,57 +591,109 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
329
591
  */
330
592
  CartesianChart: {
331
593
  (
332
- props: ChartTableSourceProps<Schemas> &
594
+ props: TableSourceProps<Schemas> &
333
595
  ChartProps & {readonly children?: ReactNode},
334
596
  ): ComponentReturnType;
335
597
  (
336
- props: ChartQuerySourceProps<Schemas> &
598
+ props: QuerySourceProps<Schemas> &
337
599
  ChartProps & {readonly children?: ReactNode},
338
600
  ): ComponentReturnType;
339
601
  };
340
602
 
341
603
  /**
342
- * The LineSeries component renders a line series in a CartesianChart
343
- * component. If every x value in every series is a finite number, the x axis is
344
- * rendered as a continuous numeric scale. If any x value is a string or
345
- * boolean, the x axis is rendered categorically. When sortCellId is omitted,
346
- * rows are sorted by xCellId.
604
+ * The XAxis component configures the x axis of a CartesianChart component,
605
+ * LineChart component, or BarChart component.
606
+ *
607
+ * It is a configuration child rather than a separately rendered SVG element:
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.
610
+ *
611
+ * See the Axis Overrides (React) demo for this component in action:
612
+ *
613
+ * ![XAxis component example](https://beta.tinybase.org/shots/axis-overrides-react-demo.png
614
+ * "XAxis component example")
347
615
  * @category Store components
348
616
  * @since v8.5.0
349
617
  */
350
- LineSeries: (props: ChartSeriesProps) => ComponentReturnType;
618
+ XAxis: (props: XAxisProps) => ComponentReturnType;
351
619
 
352
620
  /**
353
- * The BarSeries component renders a bar series in a CartesianChart component.
354
- * Its x values are always rendered categorically, even when they are finite
355
- * numbers. Boolean category labels are rendered as `true` and `false`.
621
+ * The YAxis component configures the y axis of a CartesianChart component.
622
+ *
623
+ * It is a configuration child rather than a separately rendered SVG element:
624
+ * include zero or one YAxis component in a CartesianChart component's children.
625
+ * If omitted, the y axis is inferred from the chart's series.
626
+ *
627
+ * See the Axis Overrides (React) demo for this component in action:
628
+ *
629
+ * ![YAxis component example](https://beta.tinybase.org/shots/axis-overrides-react-demo.png
630
+ * "YAxis component example")
356
631
  * @category Store components
357
632
  * @since v8.5.0
358
633
  */
359
- BarSeries: (props: ChartSeriesProps) => ComponentReturnType;
634
+ YAxis: (props: YAxisProps) => ComponentReturnType;
360
635
 
361
636
  /**
362
- * The LineChart component renders a line chart from TinyBase data. If every x
363
- * value is a finite number, the x axis is rendered as a continuous numeric
364
- * scale. If any x value is a string or boolean, the x axis is rendered
365
- * categorically. When sortCellId is omitted, rows are sorted by xCellId.
637
+ * The LineSeries component renders a line series in a CartesianChart component.
638
+ * If every x value in every series is a finite number, the x axis is rendered
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.
642
+ *
643
+ * See the Composing Charts (React) demo for this component in action:
644
+ *
645
+ * ![LineSeries component example](https://beta.tinybase.org/shots/composing-charts-react-demo.png
646
+ * "LineSeries component example")
366
647
  * @category Store components
367
648
  * @since v8.5.0
368
- * @example
369
- * This example creates a Provider context into which a default Store is
370
- * provided. The LineChart component then renders an SVG chart from Cells in the
371
- * `pets` Table.
649
+ */
650
+ LineSeries: (props: SeriesProps) => ComponentReturnType;
651
+
652
+ /**
653
+ * The BarSeries component renders a bar series in a CartesianChart component.
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`.
658
+ *
659
+ * See the Composing Charts (React) demo for this component in action:
660
+ *
661
+ * ![BarSeries component example](https://beta.tinybase.org/shots/composing-charts-react-demo.png
662
+ * "BarSeries component example")
663
+ * @category Store components
664
+ * @since v8.5.0
665
+ */
666
+ BarSeries: (props: SeriesProps) => ComponentReturnType;
667
+
668
+ /**
669
+ * The LineChart component renders a line chart from TinyBase data. If every x
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.
372
675
  *
373
676
  * This has schema-based typing. The following is a simplified representation:
374
677
  *
375
678
  * ```ts override
376
679
  * LineChart(
377
- * props: (ChartTableSourceProps | ChartQuerySourceProps) &
378
- * ChartBindingProps &
379
- * ChartProps,
680
+ * props: (TableSourceProps | QuerySourceProps) &
681
+ * BindingProps &
682
+ * ChartProps & {readonly children?: ReactNode},
380
683
  * ): ComponentReturnType;
381
684
  * ```
382
685
  *
686
+ * See the <LineChart /> (React) demo for this component in action:
687
+ *
688
+ * ![LineChart component example](https://beta.tinybase.org/shots/basic-chart-react-demo.png "LineChart
689
+ * component example")
690
+ * @category Store components
691
+ * @since v8.5.0
692
+ * @example
693
+ * This example creates a Provider context into which a default Store is
694
+ * provided. The LineChart component then renders an SVG chart from Cells in the
695
+ * `pets` Table.
696
+ *
383
697
  * ```jsx
384
698
  * import React from 'react';
385
699
  * import {createRoot} from 'react-dom/client';
@@ -412,31 +726,40 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
412
726
  */
413
727
  LineChart: (
414
728
  props:
415
- | (ChartTableBindingProps<Schemas> & ChartProps)
416
- | (ChartQuerySourceProps<Schemas> & ChartBindingProps & ChartProps),
729
+ | (TableBindingProps<Schemas> &
730
+ ChartProps & {readonly children?: ReactNode})
731
+ | (QuerySourceProps<Schemas> &
732
+ BindingProps &
733
+ ChartProps & {readonly children?: ReactNode}),
417
734
  ) => ComponentReturnType;
418
735
 
419
736
  /**
420
737
  * The BarChart component renders a bar chart from TinyBase data. Its x values
421
- * are always rendered categorically, even when they are finite numbers. Boolean
422
- * category labels are rendered as `true` and `false`.
423
- * @category Store components
424
- * @since v8.5.0
425
- * @example
426
- * This example creates a Queries object and provides it through Provider
427
- * context. The BarChart component then renders an SVG chart from Cells in the
428
- * `bySpecies` query.
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`.
429
741
  *
430
742
  * This has schema-based typing. The following is a simplified representation:
431
743
  *
432
744
  * ```ts override
433
745
  * BarChart(
434
- * props: (ChartTableSourceProps | ChartQuerySourceProps) &
435
- * ChartBindingProps &
436
- * ChartProps,
746
+ * props: (TableSourceProps | QuerySourceProps) &
747
+ * BindingProps &
748
+ * ChartProps & {readonly children?: ReactNode},
437
749
  * ): ComponentReturnType;
438
750
  * ```
439
751
  *
752
+ * See the Sorting And Types (React) demo for this component in action:
753
+ *
754
+ * ![BarChart component example](https://beta.tinybase.org/shots/sorting-and-types-react-demo.png
755
+ * "BarChart component example")
756
+ * @category Store components
757
+ * @since v8.5.0
758
+ * @example
759
+ * This example creates a Queries object and provides it through Provider
760
+ * context. The BarChart component then renders an SVG chart from Cells in the
761
+ * `bySpecies` query.
762
+ *
440
763
  * ```jsx
441
764
  * import React from 'react';
442
765
  * import {createRoot} from 'react-dom/client';
@@ -470,7 +793,10 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
470
793
  */
471
794
  BarChart: (
472
795
  props:
473
- | (ChartTableBindingProps<Schemas> & ChartProps)
474
- | (ChartQuerySourceProps<Schemas> & ChartBindingProps & ChartProps),
796
+ | (TableBindingProps<Schemas> &
797
+ ChartProps & {readonly children?: ReactNode})
798
+ | (QuerySourceProps<Schemas> &
799
+ BindingProps &
800
+ ChartProps & {readonly children?: ReactNode}),
475
801
  ) => ComponentReturnType;
476
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
package/index.js CHANGED
@@ -875,7 +875,7 @@ const getHlcFunctions = (uniqueId, getNow = Date.now) => {
875
875
  const seenHlc = (hlc) => {
876
876
  const previousLogicalTime = lastLogicalTime;
877
877
  const [remoteLogicalTime, remoteCounter] =
878
- isUndefined(hlc) || hlc == '' ? [0, 0] : decodeHlc(hlc);
878
+ isUndefined(hlc) || hlc == EMPTY_STRING ? [0, 0] : decodeHlc(hlc);
879
879
  lastLogicalTime = mathMax(previousLogicalTime, remoteLogicalTime, getNow());
880
880
  lastCounter =
881
881
  lastLogicalTime == previousLogicalTime
@@ -1173,7 +1173,8 @@ const replaceHlcHash = (oldHlc, newHlc) =>
1173
1173
  newHlc > oldHlc ? (oldHlc ? getHash(oldHlc) : 0) ^ getHash(newHlc) : 0;
1174
1174
  const getLatestHlc = (hlc1, hlc2) =>
1175
1175
  /* istanbul ignore next */
1176
- ((hlc1 ?? '') > (hlc2 ?? '') ? hlc1 : hlc2) ?? '';
1176
+ ((hlc1 ?? EMPTY_STRING) > (hlc2 ?? EMPTY_STRING) ? hlc1 : hlc2) ??
1177
+ EMPTY_STRING;
1177
1178
  const stampUpdate = (stamp, hlc, hash) => {
1178
1179
  if (hlc > stamp[1]) {
1179
1180
  stamp[1] = hlc;