tinybase 8.5.0-beta.0 → 8.5.0-beta.2

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 (137) hide show
  1. package/@types/ui-react-dom-charts/index.d.ts +387 -0
  2. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +476 -0
  3. package/common/index.js +3 -2
  4. package/common/with-schemas/index.js +3 -2
  5. package/index.js +5 -3
  6. package/mergeable-store/index.js +5 -3
  7. package/mergeable-store/with-schemas/index.js +5 -3
  8. package/metrics/index.js +1 -1
  9. package/metrics/with-schemas/index.js +1 -1
  10. package/min/common/index.js +1 -1
  11. package/min/common/index.js.gz +0 -0
  12. package/min/common/with-schemas/index.js +1 -1
  13. package/min/common/with-schemas/index.js.gz +0 -0
  14. package/min/index.js +1 -1
  15. package/min/index.js.gz +0 -0
  16. package/min/mergeable-store/index.js +1 -1
  17. package/min/mergeable-store/index.js.gz +0 -0
  18. package/min/mergeable-store/with-schemas/index.js +1 -1
  19. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  20. package/min/omni/index.js +1 -1
  21. package/min/omni/index.js.gz +0 -0
  22. package/min/omni/with-schemas/index.js +1 -1
  23. package/min/omni/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-partykit-server/index.js +1 -1
  29. package/min/persisters/persister-partykit-server/index.js.gz +0 -0
  30. package/min/persisters/persister-partykit-server/with-schemas/index.js +1 -1
  31. package/min/persisters/persister-partykit-server/with-schemas/index.js.gz +0 -0
  32. package/min/queries/index.js +1 -1
  33. package/min/queries/index.js.gz +0 -0
  34. package/min/queries/with-schemas/index.js +1 -1
  35. package/min/queries/with-schemas/index.js.gz +0 -0
  36. package/min/synchronizers/index.js +1 -1
  37. package/min/synchronizers/index.js.gz +0 -0
  38. package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
  39. package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  40. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
  41. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  42. package/min/synchronizers/synchronizer-local/index.js +1 -1
  43. package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
  44. package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  45. package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
  46. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  47. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  48. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  49. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  50. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  51. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  52. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  53. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  54. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  55. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
  56. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  57. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
  58. package/min/synchronizers/with-schemas/index.js +1 -1
  59. package/min/synchronizers/with-schemas/index.js.gz +0 -0
  60. package/min/ui-react/index.js +1 -1
  61. package/min/ui-react/index.js.gz +0 -0
  62. package/min/ui-react/with-schemas/index.js +1 -1
  63. package/min/ui-react/with-schemas/index.js.gz +0 -0
  64. package/min/ui-react-dom/index.js +1 -1
  65. package/min/ui-react-dom/index.js.gz +0 -0
  66. package/min/ui-react-dom/with-schemas/index.js +1 -1
  67. package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
  68. package/min/ui-react-dom-charts/index.js +1 -0
  69. package/min/ui-react-dom-charts/index.js.gz +0 -0
  70. package/min/ui-react-dom-charts/with-schemas/index.js +1 -0
  71. package/min/ui-react-dom-charts/with-schemas/index.js.gz +0 -0
  72. package/min/ui-react-inspector/index.js +1 -1
  73. package/min/ui-react-inspector/index.js.gz +0 -0
  74. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  75. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  76. package/min/ui-solid-dom/index.js +1 -1
  77. package/min/ui-solid-dom/index.js.gz +0 -0
  78. package/min/ui-solid-dom/with-schemas/index.js +1 -1
  79. package/min/ui-solid-dom/with-schemas/index.js.gz +0 -0
  80. package/min/ui-solid-inspector/index.js +1 -1
  81. package/min/ui-solid-inspector/index.js.gz +0 -0
  82. package/min/ui-solid-inspector/with-schemas/index.js +1 -1
  83. package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
  84. package/min/ui-svelte-dom/index.js +1 -1
  85. package/min/ui-svelte-dom/index.js.gz +0 -0
  86. package/min/ui-svelte-dom/with-schemas/index.js +1 -1
  87. package/min/ui-svelte-dom/with-schemas/index.js.gz +0 -0
  88. package/min/ui-svelte-inspector/index.js +1 -1
  89. package/min/ui-svelte-inspector/index.js.gz +0 -0
  90. package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
  91. package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
  92. package/min/with-schemas/index.js +1 -1
  93. package/min/with-schemas/index.js.gz +0 -0
  94. package/omni/index.js +7 -4
  95. package/omni/with-schemas/index.js +7 -4
  96. package/package.json +53 -17
  97. package/persisters/persister-durable-object-sql-storage/index.js +13 -11
  98. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +13 -11
  99. package/persisters/persister-partykit-client/index.js +2 -1
  100. package/persisters/persister-partykit-client/with-schemas/index.js +2 -1
  101. package/persisters/persister-partykit-server/index.js +2 -1
  102. package/persisters/persister-partykit-server/with-schemas/index.js +2 -1
  103. package/queries/index.js +1 -1
  104. package/queries/with-schemas/index.js +1 -1
  105. package/readme.md +14 -14
  106. package/releases.md +124 -61
  107. package/synchronizers/index.js +3 -2
  108. package/synchronizers/synchronizer-broadcast-channel/index.js +3 -2
  109. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +3 -2
  110. package/synchronizers/synchronizer-local/index.js +3 -2
  111. package/synchronizers/synchronizer-local/with-schemas/index.js +3 -2
  112. package/synchronizers/synchronizer-ws-client/index.js +3 -2
  113. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +3 -2
  114. package/synchronizers/synchronizer-ws-server/index.js +3 -2
  115. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +3 -2
  116. package/synchronizers/synchronizer-ws-server-durable-object/index.js +3 -2
  117. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +3 -2
  118. package/synchronizers/with-schemas/index.js +3 -2
  119. package/ui-react/index.js +3 -0
  120. package/ui-react/with-schemas/index.js +3 -0
  121. package/ui-react-dom/index.js +18 -12
  122. package/ui-react-dom/with-schemas/index.js +18 -12
  123. package/ui-react-dom-charts/index.js +1783 -0
  124. package/ui-react-dom-charts/with-schemas/index.js +1783 -0
  125. package/ui-react-inspector/index.js +29 -20
  126. package/ui-react-inspector/with-schemas/index.js +29 -20
  127. package/ui-solid-dom/index.js +10 -7
  128. package/ui-solid-dom/with-schemas/index.js +10 -7
  129. package/ui-solid-inspector/index.js +16 -10
  130. package/ui-solid-inspector/with-schemas/index.js +16 -10
  131. package/ui-svelte/index.js +5 -5
  132. package/ui-svelte/with-schemas/index.js +5 -5
  133. package/ui-svelte-dom/index.js +162 -164
  134. package/ui-svelte-dom/with-schemas/index.js +162 -164
  135. package/ui-svelte-inspector/index.js +192 -196
  136. package/ui-svelte-inspector/with-schemas/index.js +192 -196
  137. package/with-schemas/index.js +5 -3
@@ -0,0 +1,387 @@
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
4
+ * objects.
5
+ *
6
+ * The components in this module use the react-dom module and so are not
7
+ * appropriate for environments like React Native (although those in the
8
+ * lower-level ui-react module are).
9
+ *
10
+ * For a full list of SVG class names that can be styled with CSS, see the
11
+ * Using Charts guide.
12
+ * @packageDocumentation
13
+ * @module ui-react-dom-charts
14
+ * @since v8.5.0
15
+ */
16
+ import type {ReactNode} from 'react';
17
+ import type {Id} from '../common/index.d.ts';
18
+ import type {
19
+ ComponentReturnType,
20
+ QueriesOrQueriesId,
21
+ StoreOrStoreId,
22
+ } from '../ui-react/index.d.ts';
23
+
24
+ /**
25
+ * The ChartProps type describes the props that are used to configure the
26
+ * chart element that renders a chart.
27
+ * @category Configuration
28
+ * @since v8.5.0
29
+ */
30
+ export type ChartProps = {
31
+ /**
32
+ * An optional string that will be used as the class attribute of the chart's
33
+ * SVG element. This can be used as the root selector for styling chart
34
+ * internals, as shown in the Using Charts guide.
35
+ * @category Prop
36
+ * @since v8.5.0
37
+ */
38
+ readonly className?: string;
39
+ };
40
+
41
+ /**
42
+ * The ChartTableSourceProps type describes the props that bind a chart to a
43
+ * Table in a Store.
44
+ * @category Configuration
45
+ * @since v8.5.0
46
+ */
47
+ export type ChartTableSourceProps = {
48
+ /**
49
+ * The Id of the Table in the Store to chart.
50
+ * @category Prop
51
+ * @since v8.5.0
52
+ */
53
+ readonly tableId: Id;
54
+ /**
55
+ * The Store to chart, or the Id of a Store that is registered with the
56
+ * Provider component.
57
+ * @category Prop
58
+ * @since v8.5.0
59
+ */
60
+ readonly store?: StoreOrStoreId;
61
+ /**
62
+ * This prop is not used when binding a chart to a Table.
63
+ * @category Prop
64
+ * @since v8.5.0
65
+ */
66
+ readonly queryId?: never;
67
+ /**
68
+ * This prop is not used when binding a chart to a Table.
69
+ * @category Prop
70
+ * @since v8.5.0
71
+ */
72
+ readonly queries?: never;
73
+ };
74
+
75
+ /**
76
+ * The ChartQuerySourceProps type describes the props that bind a chart to a
77
+ * Query in a Queries object.
78
+ * @category Configuration
79
+ * @since v8.5.0
80
+ */
81
+ export type ChartQuerySourceProps = {
82
+ /**
83
+ * The Id of the query in the Queries object to chart.
84
+ * @category Prop
85
+ * @since v8.5.0
86
+ */
87
+ readonly queryId: Id;
88
+ /**
89
+ * The Queries object to chart, or the Id of a Queries object that is
90
+ * registered with the Provider component.
91
+ * @category Prop
92
+ * @since v8.5.0
93
+ */
94
+ readonly queries?: QueriesOrQueriesId;
95
+ /**
96
+ * This prop is not used when binding a chart to a Query.
97
+ * @category Prop
98
+ * @since v8.5.0
99
+ */
100
+ readonly tableId?: never;
101
+ /**
102
+ * This prop is not used when binding a chart to a Query.
103
+ * @category Prop
104
+ * @since v8.5.0
105
+ */
106
+ readonly store?: never;
107
+ };
108
+
109
+ /**
110
+ * The ChartBindingProps type describes the props that bind a LineChart or
111
+ * BarChart component to Cell values in TinyBase data. An x Cell value can be a
112
+ * finite number, string, or boolean. A y Cell value must be a finite number.
113
+ * @category Configuration
114
+ * @since v8.5.0
115
+ */
116
+ export type ChartBindingProps = {
117
+ /**
118
+ * The Id of the Cell that provides each data point's x value. Finite numbers
119
+ * can be used as continuous x values in line charts, while strings and
120
+ * booleans are used as category values. Boolean category labels are rendered
121
+ * as `true` and `false`.
122
+ * @category Prop
123
+ * @since v8.5.0
124
+ */
125
+ readonly xCellId: Id;
126
+ /**
127
+ * The Id of the Cell that provides each data point's y value. Only finite
128
+ * numbers are charted; rows with missing, non-numeric, or non-finite y values
129
+ * are ignored.
130
+ * @category Prop
131
+ * @since v8.5.0
132
+ */
133
+ readonly yCellId: Id;
134
+ /**
135
+ * The Id of the Cell used to sort the charted rows.
136
+ * @category Prop
137
+ * @since v8.5.0
138
+ */
139
+ readonly sortCellId?: Id;
140
+ /**
141
+ * Whether the charted rows should be sorted in descending order.
142
+ * @category Prop
143
+ * @since v8.5.0
144
+ */
145
+ readonly descending?: boolean;
146
+ /**
147
+ * The number of sorted rows to skip before charting.
148
+ * @category Prop
149
+ * @since v8.5.0
150
+ */
151
+ readonly offset?: number;
152
+ /**
153
+ * The maximum number of sorted rows to chart.
154
+ * @category Prop
155
+ * @since v8.5.0
156
+ */
157
+ readonly limit?: number;
158
+ };
159
+
160
+ /**
161
+ * The ChartSeriesProps type describes the props that bind a chart series to
162
+ * Cell values in TinyBase data. An x Cell value can be a finite number,
163
+ * string, or boolean. A y Cell value must be a finite number.
164
+ * @category Configuration
165
+ * @since v8.5.0
166
+ */
167
+ export type ChartSeriesProps = {
168
+ /**
169
+ * An optional string that will be added to the class attribute of the series'
170
+ * SVG group element.
171
+ * @category Prop
172
+ * @since v8.5.0
173
+ */
174
+ readonly className?: string;
175
+ /**
176
+ * The Id of the Cell that provides each data point's x value. Finite numbers
177
+ * can be used as continuous x values in line series, while strings and
178
+ * booleans are used as category values. Boolean category labels are rendered
179
+ * as `true` and `false`.
180
+ * @category Prop
181
+ * @since v8.5.0
182
+ */
183
+ readonly xCellId: Id;
184
+ /**
185
+ * The Id of the Cell that provides each data point's y value. Only finite
186
+ * numbers are charted; rows with missing, non-numeric, or non-finite y values
187
+ * are ignored.
188
+ * @category Prop
189
+ * @since v8.5.0
190
+ */
191
+ readonly yCellId: Id;
192
+ /**
193
+ * An optional label to use for the series in axis titles and tooltips,
194
+ * defaulting to the y Cell Id.
195
+ * @category Prop
196
+ * @since v8.5.0
197
+ */
198
+ readonly label?: string;
199
+ /**
200
+ * The Id of the Cell used to sort the charted rows.
201
+ * @category Prop
202
+ * @since v8.5.0
203
+ */
204
+ readonly sortCellId?: Id;
205
+ /**
206
+ * Whether the charted rows should be sorted in descending order.
207
+ * @category Prop
208
+ * @since v8.5.0
209
+ */
210
+ readonly descending?: boolean;
211
+ /**
212
+ * The number of sorted rows to skip before charting.
213
+ * @category Prop
214
+ * @since v8.5.0
215
+ */
216
+ readonly offset?: number;
217
+ /**
218
+ * The maximum number of sorted rows to chart.
219
+ * @category Prop
220
+ * @since v8.5.0
221
+ */
222
+ readonly limit?: number;
223
+ };
224
+
225
+ /**
226
+ * The CartesianChart component renders a chart frame and provides TinyBase
227
+ * source and layout context to child LineSeries and BarSeries components.
228
+ *
229
+ * The series children declare their own xCellId and yCellId bindings.
230
+ * @category Store components
231
+ * @since v8.5.0
232
+ * @example
233
+ * This example creates a Store and renders two LineSeries components in a
234
+ * CartesianChart.
235
+ *
236
+ * ```jsx
237
+ * import React from 'react';
238
+ * import {createRoot} from 'react-dom/client';
239
+ * import {createStore} from 'tinybase';
240
+ * import {CartesianChart, LineSeries} from 'tinybase/ui-react-dom-charts';
241
+ *
242
+ * const store = createStore().setTable('pets', {
243
+ * hamsters: {order: 1, sold: 12, returned: 1},
244
+ * rabbits: {order: 2, sold: 9, returned: 2},
245
+ * });
246
+ * const App = () => (
247
+ * <CartesianChart store={store} tableId="pets">
248
+ * <LineSeries
249
+ * className="sold"
250
+ * label="Sold pets"
251
+ * xCellId="order"
252
+ * yCellId="sold"
253
+ * />
254
+ * <LineSeries
255
+ * className="returned"
256
+ * label="Returned pets"
257
+ * xCellId="order"
258
+ * yCellId="returned"
259
+ * />
260
+ * </CartesianChart>
261
+ * );
262
+ * const app = document.createElement('div');
263
+ * createRoot(app).render(<App />); // !act
264
+ * console.log(app.firstChild?.nodeName.toLowerCase());
265
+ * // -> 'svg'
266
+ * ```
267
+ */
268
+ export function CartesianChart(
269
+ props: (ChartTableSourceProps | ChartQuerySourceProps) &
270
+ ChartProps & {readonly children?: ReactNode},
271
+ ): ComponentReturnType;
272
+
273
+ /**
274
+ * The LineSeries component renders a line series in a CartesianChart
275
+ * component. If every x value in every series is a finite number, the x axis is
276
+ * rendered as a continuous numeric scale. If any x value is a string or
277
+ * boolean, the x axis is rendered categorically. When sortCellId is omitted,
278
+ * rows are sorted by xCellId.
279
+ * @category Store components
280
+ * @since v8.5.0
281
+ */
282
+ export function LineSeries(props: ChartSeriesProps): ComponentReturnType;
283
+
284
+ /**
285
+ * The BarSeries component renders a bar series in a CartesianChart component.
286
+ * Its x values are always rendered categorically, even when they are finite
287
+ * numbers. Boolean category labels are rendered as `true` and `false`.
288
+ * @category Store components
289
+ * @since v8.5.0
290
+ */
291
+ export function BarSeries(props: ChartSeriesProps): ComponentReturnType;
292
+
293
+ /**
294
+ * The LineChart component renders a line chart from TinyBase data. If every x
295
+ * value is a finite number, the x axis is rendered as a continuous numeric
296
+ * scale. If any x value is a string or boolean, the x axis is rendered
297
+ * categorically. When sortCellId is omitted, rows are sorted by xCellId.
298
+ * @category Store components
299
+ * @since v8.5.0
300
+ * @example
301
+ * This example creates a Provider context into which a default Store is
302
+ * provided. The LineChart component then renders an SVG chart from Cells in the
303
+ * `pets` Table.
304
+ *
305
+ * ```jsx
306
+ * import React from 'react';
307
+ * import {createRoot} from 'react-dom/client';
308
+ * import {createStore} from 'tinybase';
309
+ * import {Provider} from 'tinybase/ui-react';
310
+ * import {LineChart} from 'tinybase/ui-react-dom-charts';
311
+ *
312
+ * const App = ({store}) => (
313
+ * <Provider store={store}>
314
+ * <LineChart
315
+ * tableId="pets"
316
+ * xCellId="order"
317
+ * yCellId="sold"
318
+ * className="sales"
319
+ * />
320
+ * </Provider>
321
+ * );
322
+ *
323
+ * const store = createStore().setTable('pets', {
324
+ * hamsters: {order: 1, sold: 12},
325
+ * rabbits: {order: 2, sold: 9},
326
+ * });
327
+ * const app = document.createElement('div');
328
+ * createRoot(app).render(<App store={store} />); // !act
329
+ * console.log(app.firstChild?.nodeName.toLowerCase());
330
+ * // -> 'svg'
331
+ * console.log(app.firstChild?.getAttribute('class'));
332
+ * // -> 'sales'
333
+ * ```
334
+ */
335
+ export function LineChart(
336
+ props: (ChartTableSourceProps | ChartQuerySourceProps) &
337
+ ChartBindingProps &
338
+ ChartProps,
339
+ ): ComponentReturnType;
340
+
341
+ /**
342
+ * The BarChart component renders a bar chart from TinyBase data. Its x values
343
+ * are always rendered categorically, even when they are finite numbers. Boolean
344
+ * category labels are rendered as `true` and `false`.
345
+ * @category Store components
346
+ * @since v8.5.0
347
+ * @example
348
+ * This example creates a Queries object and provides it through Provider
349
+ * context. The BarChart component then renders an SVG chart from Cells in the
350
+ * `bySpecies` query.
351
+ *
352
+ * ```jsx
353
+ * import React from 'react';
354
+ * import {createRoot} from 'react-dom/client';
355
+ * import {createQueries, createStore} from 'tinybase';
356
+ * import {Provider} from 'tinybase/ui-react';
357
+ * import {BarChart} from 'tinybase/ui-react-dom-charts';
358
+ *
359
+ * const App = ({queries}) => (
360
+ * <Provider queries={queries}>
361
+ * <BarChart queryId="bySpecies" xCellId="species" yCellId="sold" />
362
+ * </Provider>
363
+ * );
364
+ *
365
+ * const store = createStore().setTable('pets', {
366
+ * hamsters: {species: 'hamster', sold: 12},
367
+ * rabbits: {species: 'rabbit', sold: 9},
368
+ * });
369
+ * const queries = createQueries(store).setQueryDefinition(
370
+ * 'bySpecies',
371
+ * 'pets',
372
+ * ({select}) => {
373
+ * select('species');
374
+ * select('sold');
375
+ * },
376
+ * );
377
+ * const app = document.createElement('div');
378
+ * createRoot(app).render(<App queries={queries} />); // !act
379
+ * console.log(app.firstChild?.nodeName.toLowerCase());
380
+ * // -> 'svg'
381
+ * ```
382
+ */
383
+ export function BarChart(
384
+ props: (ChartTableSourceProps | ChartQuerySourceProps) &
385
+ ChartBindingProps &
386
+ ChartProps,
387
+ ): ComponentReturnType;