tinybase 6.5.2 → 6.6.1

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.
@@ -62,6 +62,7 @@ const _VALUE = 'value';
62
62
  const OPEN = 'open';
63
63
  const MESSAGE = 'message';
64
64
  const ERROR = 'error';
65
+ const EXTRA = 'extra';
65
66
  const T = 't';
66
67
  const V = 'v';
67
68
  const UNDEFINED = '\uFFFC';
@@ -159,7 +160,13 @@ const setOrDelCell = (store, tableId, rowId, cellId, cell) =>
159
160
  const setOrDelValue = (store, valueId, value) =>
160
161
  isUndefined(value) ? store.delValue(valueId) : store.setValue(valueId, value);
161
162
  const getTypeCase = (type, stringCase, numberCase, booleanCase) =>
162
- type == STRING ? stringCase : type == NUMBER ? numberCase : booleanCase;
163
+ type == STRING
164
+ ? stringCase
165
+ : type == NUMBER
166
+ ? numberCase
167
+ : type == BOOLEAN
168
+ ? booleanCase
169
+ : null;
163
170
 
164
171
  const collSizeN = (collSizer) => (coll) =>
165
172
  arrayReduce(collValues(coll), (total, coll2) => total + collSizer(coll2), 0);
@@ -7086,17 +7093,6 @@ const getIndexStoreTableId = (indexes, indexId) => [
7086
7093
  indexes?.getTableId(indexId),
7087
7094
  ];
7088
7095
 
7089
- var Offsets = /* @__PURE__ */ ((Offsets2) => {
7090
- Offsets2[(Offsets2['Store'] = 0)] = 'Store';
7091
- Offsets2[(Offsets2['Metrics'] = 1)] = 'Metrics';
7092
- Offsets2[(Offsets2['Indexes'] = 2)] = 'Indexes';
7093
- Offsets2[(Offsets2['Relationships'] = 3)] = 'Relationships';
7094
- Offsets2[(Offsets2['Queries'] = 4)] = 'Queries';
7095
- Offsets2[(Offsets2['Checkpoints'] = 5)] = 'Checkpoints';
7096
- Offsets2[(Offsets2['Persister'] = 6)] = 'Persister';
7097
- Offsets2[(Offsets2['Synchronizer'] = 7)] = 'Synchronizer';
7098
- return Offsets2;
7099
- })(Offsets || {});
7100
7096
  const TINYBASE_CONTEXT = TINYBASE + '_uirc';
7101
7097
  const Context = GLOBAL[TINYBASE_CONTEXT]
7102
7098
  ? /* istanbul ignore next */
@@ -7127,6 +7123,165 @@ const useProvideThing = (thingId, thing, offset) => {
7127
7123
  const useThingIds = (offset) =>
7128
7124
  objIds(useContext(Context)[offset * 2 + 1] ?? {});
7129
7125
 
7126
+ const OFFSET_STORE = 0;
7127
+ const OFFSET_METRICS = 1;
7128
+ const OFFSET_INDEXES = 2;
7129
+ const OFFSET_RELATIONSHIPS = 3;
7130
+ const OFFSET_QUERIES = 4;
7131
+ const OFFSET_CHECKPOINTS = 5;
7132
+ const OFFSET_PERSISTER = 6;
7133
+ const OFFSET_SYNCHRONIZER = 7;
7134
+ const mergeParentThings = (
7135
+ offset,
7136
+ parentValue,
7137
+ defaultThing,
7138
+ thingsById,
7139
+ extraThingsById,
7140
+ ) => [
7141
+ defaultThing ?? parentValue[offset * 2],
7142
+ {
7143
+ ...parentValue[offset * 2 + 1],
7144
+ ...thingsById,
7145
+ ...extraThingsById[offset],
7146
+ },
7147
+ ];
7148
+ const Provider = ({
7149
+ store,
7150
+ storesById,
7151
+ metrics,
7152
+ metricsById,
7153
+ indexes,
7154
+ indexesById,
7155
+ relationships,
7156
+ relationshipsById,
7157
+ queries,
7158
+ queriesById,
7159
+ checkpoints,
7160
+ checkpointsById,
7161
+ persister,
7162
+ persistersById,
7163
+ synchronizer,
7164
+ synchronizersById,
7165
+ children,
7166
+ }) => {
7167
+ const parentValue = useContext(Context);
7168
+ const [extraThingsById, setExtraThingsById] = useState(() =>
7169
+ arrayNew(8, () => ({})),
7170
+ );
7171
+ const addExtraThingById = useCallback(
7172
+ (thingOffset, id, thing) =>
7173
+ setExtraThingsById((extraThingsById2) =>
7174
+ objGet(extraThingsById2[thingOffset], id) == thing
7175
+ ? extraThingsById2
7176
+ : arrayWith(extraThingsById2, thingOffset, {
7177
+ ...extraThingsById2[thingOffset],
7178
+ [id]: thing,
7179
+ }),
7180
+ ),
7181
+ [],
7182
+ );
7183
+ const delExtraThingById = useCallback(
7184
+ (thingOffset, id) =>
7185
+ setExtraThingsById((extraThingsById2) =>
7186
+ !objHas(extraThingsById2[thingOffset], id)
7187
+ ? extraThingsById2
7188
+ : arrayWith(
7189
+ extraThingsById2,
7190
+ thingOffset,
7191
+ objDel(extraThingsById2[thingOffset], id),
7192
+ ),
7193
+ ),
7194
+ [],
7195
+ );
7196
+ return /* @__PURE__ */ jsx(Context.Provider, {
7197
+ value: useMemo(
7198
+ () => [
7199
+ ...mergeParentThings(
7200
+ OFFSET_STORE,
7201
+ parentValue,
7202
+ store,
7203
+ storesById,
7204
+ extraThingsById,
7205
+ ),
7206
+ ...mergeParentThings(
7207
+ OFFSET_METRICS,
7208
+ parentValue,
7209
+ metrics,
7210
+ metricsById,
7211
+ extraThingsById,
7212
+ ),
7213
+ ...mergeParentThings(
7214
+ OFFSET_INDEXES,
7215
+ parentValue,
7216
+ indexes,
7217
+ indexesById,
7218
+ extraThingsById,
7219
+ ),
7220
+ ...mergeParentThings(
7221
+ OFFSET_RELATIONSHIPS,
7222
+ parentValue,
7223
+ relationships,
7224
+ relationshipsById,
7225
+ extraThingsById,
7226
+ ),
7227
+ ...mergeParentThings(
7228
+ OFFSET_QUERIES,
7229
+ parentValue,
7230
+ queries,
7231
+ queriesById,
7232
+ extraThingsById,
7233
+ ),
7234
+ ...mergeParentThings(
7235
+ OFFSET_CHECKPOINTS,
7236
+ parentValue,
7237
+ checkpoints,
7238
+ checkpointsById,
7239
+ extraThingsById,
7240
+ ),
7241
+ ...mergeParentThings(
7242
+ OFFSET_PERSISTER,
7243
+ parentValue,
7244
+ persister,
7245
+ persistersById,
7246
+ extraThingsById,
7247
+ ),
7248
+ ...mergeParentThings(
7249
+ OFFSET_SYNCHRONIZER,
7250
+ parentValue,
7251
+ synchronizer,
7252
+ synchronizersById,
7253
+ extraThingsById,
7254
+ ),
7255
+ addExtraThingById,
7256
+ delExtraThingById,
7257
+ ],
7258
+ [
7259
+ extraThingsById,
7260
+ store,
7261
+ storesById,
7262
+ metrics,
7263
+ metricsById,
7264
+ indexes,
7265
+ indexesById,
7266
+ relationships,
7267
+ relationshipsById,
7268
+ queries,
7269
+ queriesById,
7270
+ checkpoints,
7271
+ checkpointsById,
7272
+ persister,
7273
+ persistersById,
7274
+ synchronizer,
7275
+ synchronizersById,
7276
+ parentValue,
7277
+ addExtraThingById,
7278
+ delExtraThingById,
7279
+ ],
7280
+ ),
7281
+ children,
7282
+ });
7283
+ };
7284
+
7130
7285
  const EMPTY_ARRAY = [];
7131
7286
  const DEFAULTS = [{}, [], [EMPTY_ARRAY, void 0, EMPTY_ARRAY], void 0, false, 0];
7132
7287
  const IS_EQUALS = [
@@ -7291,13 +7446,13 @@ const useSortedRowIdsListenerImpl = (
7291
7446
  );
7292
7447
  const useCreateStore = (create, createDeps = EMPTY_ARRAY) =>
7293
7448
  useMemo(create, createDeps);
7294
- const useStoreIds = () => useThingIds(Offsets.Store);
7295
- const useStore = (id) => useThing(id, Offsets.Store);
7296
- const useStores = () => useThings(Offsets.Store);
7449
+ const useStoreIds = () => useThingIds(OFFSET_STORE);
7450
+ const useStore = (id) => useThing(id, OFFSET_STORE);
7451
+ const useStores = () => useThings(OFFSET_STORE);
7297
7452
  const useStoreOrStoreById = (storeOrStoreId) =>
7298
- useThingOrThingById(storeOrStoreId, Offsets.Store);
7453
+ useThingOrThingById(storeOrStoreId, OFFSET_STORE);
7299
7454
  const useProvideStore = (storeId, store) =>
7300
- useProvideThing(storeId, store, Offsets.Store);
7455
+ useProvideThing(storeId, store, OFFSET_STORE);
7301
7456
  const useCreateMergeableStore = (create, createDeps = EMPTY_ARRAY) =>
7302
7457
  useMemo(create, createDeps);
7303
7458
  const useHasTables = (storeOrStoreId) =>
@@ -7951,12 +8106,12 @@ const useDidFinishTransactionListener = (
7951
8106
  );
7952
8107
  const useCreateMetrics = (store, create, createDeps) =>
7953
8108
  useCreate(store, create, createDeps);
7954
- const useMetricsIds = () => useThingIds(Offsets.Metrics);
7955
- const useMetrics = (id) => useThing(id, Offsets.Metrics);
8109
+ const useMetricsIds = () => useThingIds(OFFSET_METRICS);
8110
+ const useMetrics = (id) => useThing(id, OFFSET_METRICS);
7956
8111
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
7957
- useThingOrThingById(metricsOrMetricsId, Offsets.Metrics);
8112
+ useThingOrThingById(metricsOrMetricsId, OFFSET_METRICS);
7958
8113
  const useProvideMetrics = (metricsId, metrics) =>
7959
- useProvideThing(metricsId, metrics, Offsets.Metrics);
8114
+ useProvideThing(metricsId, metrics, OFFSET_METRICS);
7960
8115
  const useMetricIds = (metricsOrMetricsId) =>
7961
8116
  useListenable(
7962
8117
  METRIC + IDS,
@@ -7985,12 +8140,12 @@ const useMetricListener = (
7985
8140
  );
7986
8141
  const useCreateIndexes = (store, create, createDeps) =>
7987
8142
  useCreate(store, create, createDeps);
7988
- const useIndexesIds = () => useThingIds(Offsets.Indexes);
7989
- const useIndexes = (id) => useThing(id, Offsets.Indexes);
8143
+ const useIndexesIds = () => useThingIds(OFFSET_INDEXES);
8144
+ const useIndexes = (id) => useThing(id, OFFSET_INDEXES);
7990
8145
  const useIndexesOrIndexesById = (indexesOrIndexesId) =>
7991
- useThingOrThingById(indexesOrIndexesId, Offsets.Indexes);
8146
+ useThingOrThingById(indexesOrIndexesId, OFFSET_INDEXES);
7992
8147
  const useProvideIndexes = (indexesId, indexes) =>
7993
- useProvideThing(indexesId, indexes, Offsets.Indexes);
8148
+ useProvideThing(indexesId, indexes, OFFSET_INDEXES);
7994
8149
  const useSliceIds = (indexId, indexesOrIndexesId) =>
7995
8150
  useListenable(
7996
8151
  SLICE + IDS,
@@ -8040,12 +8195,12 @@ const useSliceRowIdsListener = (
8040
8195
  );
8041
8196
  const useCreateRelationships = (store, create, createDeps) =>
8042
8197
  useCreate(store, create, createDeps);
8043
- const useRelationshipsIds = () => useThingIds(Offsets.Relationships);
8044
- const useRelationships = (id) => useThing(id, Offsets.Relationships);
8198
+ const useRelationshipsIds = () => useThingIds(OFFSET_RELATIONSHIPS);
8199
+ const useRelationships = (id) => useThing(id, OFFSET_RELATIONSHIPS);
8045
8200
  const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
8046
- useThingOrThingById(relationshipsOrRelationshipsId, Offsets.Relationships);
8201
+ useThingOrThingById(relationshipsOrRelationshipsId, OFFSET_RELATIONSHIPS);
8047
8202
  const useProvideRelationships = (relationshipsId, relationships) =>
8048
- useProvideThing(relationshipsId, relationships, Offsets.Relationships);
8203
+ useProvideThing(relationshipsId, relationships, OFFSET_RELATIONSHIPS);
8049
8204
  const useRelationshipIds = (relationshipsOrRelationshipsId) =>
8050
8205
  useListenable(
8051
8206
  RELATIONSHIP + IDS,
@@ -8129,12 +8284,12 @@ const useLinkedRowIdsListener = (
8129
8284
  );
8130
8285
  const useCreateQueries = (store, create, createDeps) =>
8131
8286
  useCreate(store, create, createDeps);
8132
- const useQueriesIds = () => useThingIds(Offsets.Queries);
8133
- const useQueries = (id) => useThing(id, Offsets.Queries);
8287
+ const useQueriesIds = () => useThingIds(OFFSET_QUERIES);
8288
+ const useQueries = (id) => useThing(id, OFFSET_QUERIES);
8134
8289
  const useQueriesOrQueriesById = (queriesOrQueriesId) =>
8135
- useThingOrThingById(queriesOrQueriesId, Offsets.Queries);
8290
+ useThingOrThingById(queriesOrQueriesId, OFFSET_QUERIES);
8136
8291
  const useProvideQueries = (queriesId, queries) =>
8137
- useProvideThing(queriesId, queries, Offsets.Queries);
8292
+ useProvideThing(queriesId, queries, OFFSET_QUERIES);
8138
8293
  const useQueryIds = (queriesOrQueriesId) =>
8139
8294
  useListenable(
8140
8295
  QUERY + IDS,
@@ -8318,12 +8473,12 @@ const useResultCellListener = (
8318
8473
  );
8319
8474
  const useCreateCheckpoints = (store, create, createDeps) =>
8320
8475
  useCreate(store, create, createDeps);
8321
- const useCheckpointsIds = () => useThingIds(Offsets.Checkpoints);
8322
- const useCheckpoints = (id) => useThing(id, Offsets.Checkpoints);
8476
+ const useCheckpointsIds = () => useThingIds(OFFSET_CHECKPOINTS);
8477
+ const useCheckpoints = (id) => useThing(id, OFFSET_CHECKPOINTS);
8323
8478
  const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
8324
- useThingOrThingById(checkpointsOrCheckpointsId, Offsets.Checkpoints);
8479
+ useThingOrThingById(checkpointsOrCheckpointsId, OFFSET_CHECKPOINTS);
8325
8480
  const useProvideCheckpoints = (checkpointsId, checkpoints) =>
8326
- useProvideThing(checkpointsId, checkpoints, Offsets.Checkpoints);
8481
+ useProvideThing(checkpointsId, checkpoints, OFFSET_CHECKPOINTS);
8327
8482
  const useCheckpointIds = (checkpointsOrCheckpointsId) =>
8328
8483
  useListenable(
8329
8484
  CHECKPOINT + IDS,
@@ -8471,12 +8626,12 @@ const useCreatePersister = (
8471
8626
  );
8472
8627
  return persister;
8473
8628
  };
8474
- const usePersisterIds = () => useThingIds(Offsets.Persister);
8475
- const usePersister = (id) => useThing(id, Offsets.Persister);
8629
+ const usePersisterIds = () => useThingIds(OFFSET_PERSISTER);
8630
+ const usePersister = (id) => useThing(id, OFFSET_PERSISTER);
8476
8631
  const usePersisterOrPersisterById = (persisterOrPersisterId) =>
8477
- useThingOrThingById(persisterOrPersisterId, Offsets.Persister);
8632
+ useThingOrThingById(persisterOrPersisterId, OFFSET_PERSISTER);
8478
8633
  const useProvidePersister = (persisterId, persister) =>
8479
- useProvideThing(persisterId, persister, Offsets.Persister);
8634
+ useProvideThing(persisterId, persister, OFFSET_PERSISTER);
8480
8635
  const usePersisterStatus = (persisterOrPersisterId) =>
8481
8636
  useListenable(
8482
8637
  STATUS,
@@ -8526,12 +8681,12 @@ const useCreateSynchronizer = (
8526
8681
  );
8527
8682
  return synchronizer;
8528
8683
  };
8529
- const useSynchronizerIds = () => useThingIds(Offsets.Synchronizer);
8530
- const useSynchronizer = (id) => useThing(id, Offsets.Synchronizer);
8684
+ const useSynchronizerIds = () => useThingIds(OFFSET_SYNCHRONIZER);
8685
+ const useSynchronizer = (id) => useThing(id, OFFSET_SYNCHRONIZER);
8531
8686
  const useSynchronizerOrSynchronizerById = (synchronizerOrSynchronizerId) =>
8532
- useThingOrThingById(synchronizerOrSynchronizerId, Offsets.Synchronizer);
8687
+ useThingOrThingById(synchronizerOrSynchronizerId, OFFSET_SYNCHRONIZER);
8533
8688
  const useProvideSynchronizer = (persisterId, persister) =>
8534
- useProvideThing(persisterId, persister, Offsets.Synchronizer);
8689
+ useProvideThing(persisterId, persister, OFFSET_SYNCHRONIZER);
8535
8690
  const useSynchronizerStatus = (synchronizerOrSynchronizerId) =>
8536
8691
  useListenable(
8537
8692
  STATUS,
@@ -8552,281 +8707,314 @@ const useSynchronizerStatusListener = (
8552
8707
  [],
8553
8708
  );
8554
8709
 
8555
- const mergeParentThings = (
8556
- offset,
8557
- parentValue,
8558
- defaultThing,
8559
- thingsById,
8560
- extraThingsById,
8561
- ) => [
8562
- defaultThing ?? parentValue[offset * 2],
8563
- {
8564
- ...parentValue[offset * 2 + 1],
8565
- ...thingsById,
8566
- ...extraThingsById[offset],
8567
- },
8568
- ];
8569
- const tableView = (
8570
- {
8571
- tableId,
8572
- store,
8573
- rowComponent: Row = RowView,
8574
- getRowComponentProps,
8575
- customCellIds,
8576
- separator,
8577
- debugIds,
8578
- },
8579
- rowIds,
8580
- ) =>
8581
- wrap(
8582
- arrayMap(rowIds, (rowId) =>
8583
- /* @__PURE__ */ jsx(
8584
- Row,
8585
- {
8586
- ...getProps(getRowComponentProps, rowId),
8587
- tableId,
8588
- rowId,
8589
- customCellIds,
8590
- store,
8591
- debugIds,
8592
- },
8593
- rowId,
8594
- ),
8710
+ const useStoreCellComponentProps = (store, tableId) =>
8711
+ useMemo(() => ({store, tableId}), [store, tableId]);
8712
+ const useQueriesCellComponentProps = (queries, queryId) =>
8713
+ useMemo(() => ({queries, queryId}), [queries, queryId]);
8714
+ const useCallbackOrUndefined = (callback, deps, test) => {
8715
+ const returnCallback = useCallback(callback, deps);
8716
+ return test ? returnCallback : void 0;
8717
+ };
8718
+ const useParams = (...args) =>
8719
+ useMemo(
8720
+ () => args,
8721
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8722
+ args,
8723
+ );
8724
+ const useCells = (defaultCellIds, customCells, defaultCellComponent) =>
8725
+ useMemo(() => {
8726
+ const cellIds = customCells ?? defaultCellIds;
8727
+ return objMap(
8728
+ isArray(cellIds)
8729
+ ? objNew(arrayMap(cellIds, (cellId) => [cellId, cellId]))
8730
+ : cellIds,
8731
+ (labelOrCustomCell, cellId) => ({
8732
+ ...{label: cellId, component: defaultCellComponent},
8733
+ ...(isString(labelOrCustomCell)
8734
+ ? {label: labelOrCustomCell}
8735
+ : labelOrCustomCell),
8736
+ }),
8737
+ );
8738
+ }, [customCells, defaultCellComponent, defaultCellIds]);
8739
+
8740
+ const UP_ARROW = '\u2191';
8741
+ const DOWN_ARROW = '\u2193';
8742
+ const EDITABLE = 'editable';
8743
+ const extraRowCells = (extraRowCells2 = [], extraRowCellProps, after = 0) =>
8744
+ arrayMap(extraRowCells2, ({component: Component}, index) =>
8745
+ /* @__PURE__ */ jsx(
8746
+ 'td',
8747
+ {
8748
+ className: EXTRA,
8749
+ children: /* @__PURE__ */ jsx(Component, {...extraRowCellProps}),
8750
+ },
8751
+ extraKey(index, after),
8595
8752
  ),
8596
- separator,
8597
- debugIds,
8598
- tableId,
8599
8753
  );
8600
- const resultTableView = (
8601
- {
8602
- queryId,
8603
- queries,
8604
- resultRowComponent: ResultRow = ResultRowView,
8605
- getResultRowComponentProps,
8606
- separator,
8607
- debugIds,
8608
- },
8609
- rowIds,
8610
- ) =>
8611
- wrap(
8612
- arrayMap(rowIds, (rowId) =>
8613
- /* @__PURE__ */ jsx(
8614
- ResultRow,
8615
- {
8616
- ...getProps(getResultRowComponentProps, rowId),
8617
- queryId,
8618
- rowId,
8619
- queries,
8620
- debugIds,
8621
- },
8622
- rowId,
8623
- ),
8754
+ const extraKey = (index, after) => (after ? '>' : '<') + index;
8755
+ const extraHeaders = (extraCells = [], after = 0) =>
8756
+ arrayMap(extraCells, ({label}, index) =>
8757
+ /* @__PURE__ */ jsx(
8758
+ 'th',
8759
+ {className: EXTRA, children: label},
8760
+ extraKey(index, after),
8624
8761
  ),
8625
- separator,
8626
- debugIds,
8627
- queryId,
8628
8762
  );
8629
- const useComponentPerRow = (
8630
- {
8631
- relationshipId,
8632
- relationships,
8633
- rowComponent: Row = RowView,
8634
- getRowComponentProps,
8635
- separator,
8636
- debugIds,
8637
- },
8638
- getRowIdsHook,
8639
- rowId,
8640
- ) => {
8641
- const [resolvedRelationships, store, localTableId] =
8642
- getRelationshipsStoreTableIds(
8643
- useRelationshipsOrRelationshipsById(relationships),
8644
- relationshipId,
8645
- );
8646
- const rowIds = getRowIdsHook(relationshipId, rowId, resolvedRelationships);
8647
- return wrap(
8648
- arrayMap(rowIds, (rowId2) =>
8649
- /* @__PURE__ */ jsx(
8650
- Row,
8651
- {
8652
- ...getProps(getRowComponentProps, rowId2),
8653
- tableId: localTableId,
8654
- rowId: rowId2,
8655
- store,
8656
- debugIds,
8657
- },
8658
- rowId2,
8659
- ),
8763
+
8764
+ const HtmlHeaderCell = ({
8765
+ cellId,
8766
+ sort: [sortCellId, sortDescending],
8767
+ label = cellId ?? EMPTY_STRING,
8768
+ onClick,
8769
+ }) =>
8770
+ /* @__PURE__ */ jsxs('th', {
8771
+ onClick: useCallbackOrUndefined(
8772
+ () => onClick?.(cellId),
8773
+ [onClick, cellId],
8774
+ onClick,
8660
8775
  ),
8661
- separator,
8662
- debugIds,
8663
- rowId,
8664
- );
8665
- };
8666
- const getUseCheckpointView =
8667
- (getCheckpoints) =>
8668
- ({
8669
- checkpoints,
8670
- checkpointComponent: Checkpoint = CheckpointView,
8671
- getCheckpointComponentProps,
8672
- separator,
8673
- debugIds,
8674
- }) => {
8675
- const resolvedCheckpoints = useCheckpointsOrCheckpointsById(checkpoints);
8676
- return wrap(
8677
- arrayMap(
8678
- getCheckpoints(useCheckpointIds(resolvedCheckpoints)),
8679
- (checkpointId) =>
8680
- /* @__PURE__ */ jsx(
8681
- Checkpoint,
8776
+ className:
8777
+ isUndefined(sortDescending) || sortCellId != cellId
8778
+ ? void 0
8779
+ : `sorted ${sortDescending ? 'de' : 'a'}scending`,
8780
+ children: [
8781
+ isUndefined(sortDescending) || sortCellId != cellId
8782
+ ? null
8783
+ : (sortDescending ? DOWN_ARROW : UP_ARROW) + ' ',
8784
+ label,
8785
+ ],
8786
+ });
8787
+ const HtmlTable = ({
8788
+ className,
8789
+ headerRow,
8790
+ idColumn,
8791
+ params: [
8792
+ cells,
8793
+ cellComponentProps,
8794
+ rowIds,
8795
+ extraCellsBefore,
8796
+ extraCellsAfter,
8797
+ sortAndOffset,
8798
+ handleSort,
8799
+ paginatorComponent,
8800
+ ],
8801
+ }) =>
8802
+ /* @__PURE__ */ jsxs('table', {
8803
+ className,
8804
+ children: [
8805
+ paginatorComponent
8806
+ ? /* @__PURE__ */ jsx('caption', {children: paginatorComponent})
8807
+ : null,
8808
+ headerRow === false
8809
+ ? null
8810
+ : /* @__PURE__ */ jsx('thead', {
8811
+ children: /* @__PURE__ */ jsxs('tr', {
8812
+ children: [
8813
+ extraHeaders(extraCellsBefore),
8814
+ idColumn === false
8815
+ ? null
8816
+ : /* @__PURE__ */ jsx(HtmlHeaderCell, {
8817
+ sort: sortAndOffset ?? [],
8818
+ label: 'Id',
8819
+ onClick: handleSort,
8820
+ }),
8821
+ objToArray(cells, ({label}, cellId) =>
8822
+ /* @__PURE__ */ jsx(
8823
+ HtmlHeaderCell,
8824
+ {
8825
+ cellId,
8826
+ label,
8827
+ sort: sortAndOffset ?? [],
8828
+ onClick: handleSort,
8829
+ },
8830
+ cellId,
8831
+ ),
8832
+ ),
8833
+ extraHeaders(extraCellsAfter, 1),
8834
+ ],
8835
+ }),
8836
+ }),
8837
+ /* @__PURE__ */ jsx('tbody', {
8838
+ children: arrayMap(rowIds, (rowId) => {
8839
+ const rowProps = {...cellComponentProps, rowId};
8840
+ return /* @__PURE__ */ jsxs(
8841
+ 'tr',
8682
8842
  {
8683
- ...getProps(getCheckpointComponentProps, checkpointId),
8684
- checkpoints: resolvedCheckpoints,
8685
- checkpointId,
8686
- debugIds,
8843
+ children: [
8844
+ extraRowCells(extraCellsBefore, rowProps),
8845
+ idColumn === false
8846
+ ? null
8847
+ : /* @__PURE__ */ jsx('th', {title: rowId, children: rowId}),
8848
+ objToArray(
8849
+ cells,
8850
+ ({component: CellView, getComponentProps}, cellId) =>
8851
+ /* @__PURE__ */ jsx(
8852
+ 'td',
8853
+ {
8854
+ children: /* @__PURE__ */ jsx(CellView, {
8855
+ ...getProps(getComponentProps, rowId, cellId),
8856
+ ...rowProps,
8857
+ cellId,
8858
+ }),
8859
+ },
8860
+ cellId,
8861
+ ),
8862
+ ),
8863
+ extraRowCells(extraCellsAfter, rowProps, 1),
8864
+ ],
8687
8865
  },
8688
- checkpointId,
8689
- ),
8690
- ),
8691
- separator,
8692
- );
8693
- };
8694
- const Provider = ({
8695
- store,
8696
- storesById,
8697
- metrics,
8698
- metricsById,
8699
- indexes,
8700
- indexesById,
8701
- relationships,
8702
- relationshipsById,
8703
- queries,
8704
- queriesById,
8705
- checkpoints,
8706
- checkpointsById,
8707
- persister,
8708
- persistersById,
8709
- synchronizer,
8710
- synchronizersById,
8711
- children,
8866
+ rowId,
8867
+ );
8868
+ }),
8869
+ }),
8870
+ ],
8871
+ });
8872
+ const EditableThing = ({
8873
+ thing,
8874
+ onThingChange,
8875
+ className,
8876
+ hasSchema,
8877
+ showType = true,
8712
8878
  }) => {
8713
- const parentValue = useContext(Context);
8714
- const [extraThingsById, setExtraThingsById] = useState(() =>
8715
- arrayNew(8, () => ({})),
8716
- );
8717
- const addExtraThingById = useCallback(
8718
- (thingOffset, id, thing) =>
8719
- setExtraThingsById((extraThingsById2) =>
8720
- objGet(extraThingsById2[thingOffset], id) == thing
8721
- ? extraThingsById2
8722
- : arrayWith(extraThingsById2, thingOffset, {
8723
- ...extraThingsById2[thingOffset],
8724
- [id]: thing,
8725
- }),
8726
- ),
8727
- [],
8879
+ const [thingType, setThingType] = useState();
8880
+ const [currentThing, setCurrentThing] = useState();
8881
+ const [stringThing, setStringThing] = useState();
8882
+ const [numberThing, setNumberThing] = useState();
8883
+ const [booleanThing, setBooleanThing] = useState();
8884
+ if (currentThing !== thing) {
8885
+ setThingType(getCellOrValueType(thing));
8886
+ setCurrentThing(thing);
8887
+ setStringThing(String(thing));
8888
+ setNumberThing(Number(thing) || 0);
8889
+ setBooleanThing(Boolean(thing));
8890
+ }
8891
+ const handleThingChange = useCallback(
8892
+ (thing2, setTypedThing) => {
8893
+ setTypedThing(thing2);
8894
+ setCurrentThing(thing2);
8895
+ onThingChange(thing2);
8896
+ },
8897
+ [onThingChange],
8728
8898
  );
8729
- const delExtraThingById = useCallback(
8730
- (thingOffset, id) =>
8731
- setExtraThingsById((extraThingsById2) =>
8732
- !objHas(extraThingsById2[thingOffset], id)
8733
- ? extraThingsById2
8734
- : arrayWith(
8735
- extraThingsById2,
8736
- thingOffset,
8737
- objDel(extraThingsById2[thingOffset], id),
8899
+ const handleTypeChange = useCallback(() => {
8900
+ if (!hasSchema?.()) {
8901
+ const nextType = getTypeCase(thingType, NUMBER, BOOLEAN, STRING);
8902
+ const thing2 = getTypeCase(
8903
+ nextType,
8904
+ stringThing,
8905
+ numberThing,
8906
+ booleanThing,
8907
+ );
8908
+ setThingType(nextType);
8909
+ setCurrentThing(thing2);
8910
+ onThingChange(thing2);
8911
+ }
8912
+ }, [
8913
+ hasSchema,
8914
+ onThingChange,
8915
+ stringThing,
8916
+ numberThing,
8917
+ booleanThing,
8918
+ thingType,
8919
+ ]);
8920
+ const widget = getTypeCase(
8921
+ thingType,
8922
+ /* @__PURE__ */ jsx(
8923
+ 'input',
8924
+ {
8925
+ value: stringThing,
8926
+ onChange: useCallback(
8927
+ (event) =>
8928
+ handleThingChange(
8929
+ String(event[CURRENT_TARGET][_VALUE]),
8930
+ setStringThing,
8738
8931
  ),
8739
- ),
8740
- [],
8741
- );
8742
- return /* @__PURE__ */ jsx(Context.Provider, {
8743
- value: useMemo(
8744
- () => [
8745
- ...mergeParentThings(
8746
- 0 /* Store */,
8747
- parentValue,
8748
- store,
8749
- storesById,
8750
- extraThingsById,
8751
- ),
8752
- ...mergeParentThings(
8753
- 1 /* Metrics */,
8754
- parentValue,
8755
- metrics,
8756
- metricsById,
8757
- extraThingsById,
8758
- ),
8759
- ...mergeParentThings(
8760
- 2 /* Indexes */,
8761
- parentValue,
8762
- indexes,
8763
- indexesById,
8764
- extraThingsById,
8765
- ),
8766
- ...mergeParentThings(
8767
- 3 /* Relationships */,
8768
- parentValue,
8769
- relationships,
8770
- relationshipsById,
8771
- extraThingsById,
8772
- ),
8773
- ...mergeParentThings(
8774
- 4 /* Queries */,
8775
- parentValue,
8776
- queries,
8777
- queriesById,
8778
- extraThingsById,
8779
- ),
8780
- ...mergeParentThings(
8781
- 5 /* Checkpoints */,
8782
- parentValue,
8783
- checkpoints,
8784
- checkpointsById,
8785
- extraThingsById,
8932
+ [handleThingChange],
8786
8933
  ),
8787
- ...mergeParentThings(
8788
- 6 /* Persister */,
8789
- parentValue,
8790
- persister,
8791
- persistersById,
8792
- extraThingsById,
8934
+ },
8935
+ thingType,
8936
+ ),
8937
+ /* @__PURE__ */ jsx(
8938
+ 'input',
8939
+ {
8940
+ type: 'number',
8941
+ value: numberThing,
8942
+ onChange: useCallback(
8943
+ (event) =>
8944
+ handleThingChange(
8945
+ Number(event[CURRENT_TARGET][_VALUE] || 0),
8946
+ setNumberThing,
8947
+ ),
8948
+ [handleThingChange],
8793
8949
  ),
8794
- ...mergeParentThings(
8795
- 7 /* Synchronizer */,
8796
- parentValue,
8797
- synchronizer,
8798
- synchronizersById,
8799
- extraThingsById,
8950
+ },
8951
+ thingType,
8952
+ ),
8953
+ /* @__PURE__ */ jsx(
8954
+ 'input',
8955
+ {
8956
+ type: 'checkbox',
8957
+ checked: booleanThing,
8958
+ onChange: useCallback(
8959
+ (event) =>
8960
+ handleThingChange(
8961
+ Boolean(event[CURRENT_TARGET].checked),
8962
+ setBooleanThing,
8963
+ ),
8964
+ [handleThingChange],
8800
8965
  ),
8801
- addExtraThingById,
8802
- delExtraThingById,
8803
- ],
8804
- [
8805
- extraThingsById,
8806
- store,
8807
- storesById,
8808
- metrics,
8809
- metricsById,
8810
- indexes,
8811
- indexesById,
8812
- relationships,
8813
- relationshipsById,
8814
- queries,
8815
- queriesById,
8816
- checkpoints,
8817
- checkpointsById,
8818
- persister,
8819
- persistersById,
8820
- synchronizer,
8821
- synchronizersById,
8822
- parentValue,
8823
- addExtraThingById,
8824
- delExtraThingById,
8825
- ],
8966
+ },
8967
+ thingType,
8826
8968
  ),
8827
- children,
8969
+ );
8970
+ return /* @__PURE__ */ jsxs('div', {
8971
+ className,
8972
+ children: [
8973
+ showType && widget
8974
+ ? /* @__PURE__ */ jsx('button', {
8975
+ title: thingType,
8976
+ className: thingType,
8977
+ onClick: handleTypeChange,
8978
+ children: thingType,
8979
+ })
8980
+ : null,
8981
+ widget,
8982
+ ],
8828
8983
  });
8829
8984
  };
8985
+
8986
+ const EditableCellView = ({
8987
+ tableId,
8988
+ rowId,
8989
+ cellId,
8990
+ store,
8991
+ className,
8992
+ showType,
8993
+ }) =>
8994
+ /* @__PURE__ */ jsx(EditableThing, {
8995
+ thing: useCell(tableId, rowId, cellId, store),
8996
+ onThingChange: useSetCellCallback(
8997
+ tableId,
8998
+ rowId,
8999
+ cellId,
9000
+ (cell) => cell,
9001
+ [],
9002
+ store,
9003
+ ),
9004
+ className: className ?? EDITABLE + CELL,
9005
+ showType,
9006
+ hasSchema: useStoreOrStoreById(store)?.hasTablesSchema,
9007
+ });
9008
+
9009
+ const EditableValueView = ({valueId, store, className, showType}) =>
9010
+ /* @__PURE__ */ jsx(EditableThing, {
9011
+ thing: useValue(valueId, store),
9012
+ onThingChange: useSetValueCallback(valueId, (value) => value, [], store),
9013
+ className: className ?? EDITABLE + VALUE,
9014
+ showType,
9015
+ hasSchema: useStoreOrStoreById(store)?.hasValuesSchema,
9016
+ });
9017
+
8830
9018
  const wrap = (children, separator, encloseWithId, id) => {
8831
9019
  const separated =
8832
9020
  isUndefined(separator) || !isArray(children)
@@ -8834,10 +9022,53 @@ const wrap = (children, separator, encloseWithId, id) => {
8834
9022
  : arrayMap(children, (child, c) => (c > 0 ? [separator, child] : child));
8835
9023
  return encloseWithId ? [id, ':{', separated, '}'] : separated;
8836
9024
  };
8837
- const useCustomOrDefaultCellIds = (customCellIds, tableId, rowId, store) => {
8838
- const defaultCellIds = useCellIds(tableId, rowId, store);
8839
- return customCellIds ?? defaultCellIds;
8840
- };
9025
+
9026
+ const CheckpointView = ({checkpoints, checkpointId, debugIds}) =>
9027
+ wrap(
9028
+ useCheckpoint(checkpointId, checkpoints) ?? EMPTY_STRING,
9029
+ void 0,
9030
+ debugIds,
9031
+ checkpointId,
9032
+ );
9033
+
9034
+ const ResultCellView = ({queryId, rowId, cellId, queries, debugIds}) =>
9035
+ wrap(
9036
+ EMPTY_STRING +
9037
+ (useResultCell(queryId, rowId, cellId, queries) ?? EMPTY_STRING),
9038
+ void 0,
9039
+ debugIds,
9040
+ cellId,
9041
+ );
9042
+
9043
+ const ResultRowView = ({
9044
+ queryId,
9045
+ rowId,
9046
+ queries,
9047
+ resultCellComponent: ResultCell = ResultCellView,
9048
+ getResultCellComponentProps,
9049
+ separator,
9050
+ debugIds,
9051
+ }) =>
9052
+ wrap(
9053
+ arrayMap(useResultCellIds(queryId, rowId, queries), (cellId) =>
9054
+ /* @__PURE__ */ jsx(
9055
+ ResultCell,
9056
+ {
9057
+ ...getProps(getResultCellComponentProps, cellId),
9058
+ queryId,
9059
+ rowId,
9060
+ cellId,
9061
+ queries,
9062
+ debugIds,
9063
+ },
9064
+ cellId,
9065
+ ),
9066
+ ),
9067
+ separator,
9068
+ debugIds,
9069
+ rowId,
9070
+ );
9071
+
8841
9072
  const CellView = ({tableId, rowId, cellId, store, debugIds}) =>
8842
9073
  wrap(
8843
9074
  EMPTY_STRING + (useCell(tableId, rowId, cellId, store) ?? EMPTY_STRING),
@@ -8845,6 +9076,12 @@ const CellView = ({tableId, rowId, cellId, store, debugIds}) =>
8845
9076
  debugIds,
8846
9077
  cellId,
8847
9078
  );
9079
+
9080
+ const useCustomOrDefaultCellIds = (customCellIds, tableId, rowId, store) => {
9081
+ const defaultCellIds = useCellIds(tableId, rowId, store);
9082
+ return customCellIds ?? defaultCellIds;
9083
+ };
9084
+
8848
9085
  const RowView = ({
8849
9086
  tableId,
8850
9087
  rowId,
@@ -8876,93 +9113,20 @@ const RowView = ({
8876
9113
  debugIds,
8877
9114
  rowId,
8878
9115
  );
8879
- const TableView$1 = (props) =>
8880
- tableView(props, useRowIds(props.tableId, props.store));
8881
- const SortedTableView = ({cellId, descending, offset, limit, ...props}) =>
8882
- tableView(
8883
- props,
8884
- useSortedRowIds(
8885
- props.tableId,
8886
- cellId,
8887
- descending,
8888
- offset,
8889
- limit,
8890
- props.store,
8891
- ),
8892
- );
8893
- const TablesView = ({
8894
- store,
8895
- tableComponent: Table = TableView$1,
8896
- getTableComponentProps,
8897
- separator,
8898
- debugIds,
8899
- }) =>
8900
- wrap(
8901
- arrayMap(useTableIds(store), (tableId) =>
8902
- /* @__PURE__ */ jsx(
8903
- Table,
8904
- {
8905
- ...getProps(getTableComponentProps, tableId),
8906
- tableId,
8907
- store,
8908
- debugIds,
8909
- },
8910
- tableId,
8911
- ),
8912
- ),
9116
+
9117
+ const tableView = (
9118
+ {
9119
+ tableId,
9120
+ store,
9121
+ rowComponent: Row = RowView,
9122
+ getRowComponentProps,
9123
+ customCellIds,
8913
9124
  separator,
8914
- );
8915
- const ValueView = ({valueId, store, debugIds}) =>
8916
- wrap(
8917
- EMPTY_STRING + (useValue(valueId, store) ?? EMPTY_STRING),
8918
- void 0,
8919
9125
  debugIds,
8920
- valueId,
8921
- );
8922
- const ValuesView$1 = ({
8923
- store,
8924
- valueComponent: Value = ValueView,
8925
- getValueComponentProps,
8926
- separator,
8927
- debugIds,
8928
- }) =>
8929
- wrap(
8930
- arrayMap(useValueIds(store), (valueId) =>
8931
- /* @__PURE__ */ jsx(
8932
- Value,
8933
- {
8934
- ...getProps(getValueComponentProps, valueId),
8935
- valueId,
8936
- store,
8937
- debugIds,
8938
- },
8939
- valueId,
8940
- ),
8941
- ),
8942
- separator,
8943
- );
8944
- const MetricView = ({metricId, metrics, debugIds}) =>
9126
+ },
9127
+ rowIds,
9128
+ ) =>
8945
9129
  wrap(
8946
- useMetric(metricId, metrics) ?? EMPTY_STRING,
8947
- void 0,
8948
- debugIds,
8949
- metricId,
8950
- );
8951
- const SliceView$1 = ({
8952
- indexId,
8953
- sliceId,
8954
- indexes,
8955
- rowComponent: Row = RowView,
8956
- getRowComponentProps,
8957
- separator,
8958
- debugIds,
8959
- }) => {
8960
- const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
8961
- useIndexesOrIndexesById(indexes),
8962
- indexId,
8963
- );
8964
- const rowIds = useSliceRowIds(indexId, sliceId, resolvedIndexes);
8965
- return wrap(
8966
9130
  arrayMap(rowIds, (rowId) =>
8967
9131
  /* @__PURE__ */ jsx(
8968
9132
  Row,
@@ -8970,6 +9134,7 @@ const SliceView$1 = ({
8970
9134
  ...getProps(getRowComponentProps, rowId),
8971
9135
  tableId,
8972
9136
  rowId,
9137
+ customCellIds,
8973
9138
  store,
8974
9139
  debugIds,
8975
9140
  },
@@ -8978,340 +9143,316 @@ const SliceView$1 = ({
8978
9143
  ),
8979
9144
  separator,
8980
9145
  debugIds,
8981
- sliceId,
9146
+ tableId,
8982
9147
  );
8983
- };
8984
- const IndexView$1 = ({
8985
- indexId,
8986
- indexes,
8987
- sliceComponent: Slice = SliceView$1,
8988
- getSliceComponentProps,
8989
- separator,
8990
- debugIds,
8991
- }) =>
9148
+ const resultTableView = (
9149
+ {
9150
+ queryId,
9151
+ queries,
9152
+ resultRowComponent: ResultRow = ResultRowView,
9153
+ getResultRowComponentProps,
9154
+ separator,
9155
+ debugIds,
9156
+ },
9157
+ rowIds,
9158
+ ) =>
8992
9159
  wrap(
8993
- arrayMap(useSliceIds(indexId, indexes), (sliceId) =>
9160
+ arrayMap(rowIds, (rowId) =>
8994
9161
  /* @__PURE__ */ jsx(
8995
- Slice,
9162
+ ResultRow,
8996
9163
  {
8997
- ...getProps(getSliceComponentProps, sliceId),
8998
- indexId,
8999
- sliceId,
9000
- indexes,
9164
+ ...getProps(getResultRowComponentProps, rowId),
9165
+ queryId,
9166
+ rowId,
9167
+ queries,
9001
9168
  debugIds,
9002
9169
  },
9003
- sliceId,
9170
+ rowId,
9004
9171
  ),
9005
9172
  ),
9006
9173
  separator,
9007
9174
  debugIds,
9008
- indexId,
9175
+ queryId,
9009
9176
  );
9010
- const RemoteRowView = ({
9011
- relationshipId,
9012
- localRowId,
9013
- relationships,
9014
- rowComponent: Row = RowView,
9015
- getRowComponentProps,
9016
- debugIds,
9017
- }) => {
9018
- const [resolvedRelationships, store, , remoteTableId] =
9177
+ const useComponentPerRow = (
9178
+ {
9179
+ relationshipId,
9180
+ relationships,
9181
+ rowComponent: Row = RowView,
9182
+ getRowComponentProps,
9183
+ separator,
9184
+ debugIds,
9185
+ },
9186
+ getRowIdsHook,
9187
+ rowId,
9188
+ ) => {
9189
+ const [resolvedRelationships, store, localTableId] =
9019
9190
  getRelationshipsStoreTableIds(
9020
9191
  useRelationshipsOrRelationshipsById(relationships),
9021
9192
  relationshipId,
9022
9193
  );
9023
- const rowId = useRemoteRowId(
9024
- relationshipId,
9025
- localRowId,
9026
- resolvedRelationships,
9027
- );
9194
+ const rowIds = getRowIdsHook(relationshipId, rowId, resolvedRelationships);
9028
9195
  return wrap(
9029
- isUndefined(remoteTableId) || isUndefined(rowId)
9030
- ? null
9031
- : /* @__PURE__ */ jsx(
9032
- Row,
9033
- {
9034
- ...getProps(getRowComponentProps, rowId),
9035
- tableId: remoteTableId,
9036
- rowId,
9037
- store,
9038
- debugIds,
9039
- },
9040
- rowId,
9041
- ),
9042
- void 0,
9043
- debugIds,
9044
- localRowId,
9045
- );
9046
- };
9047
- const LocalRowsView = (props) =>
9048
- useComponentPerRow(props, useLocalRowIds, props.remoteRowId);
9049
- const LinkedRowsView = (props) =>
9050
- useComponentPerRow(props, useLinkedRowIds, props.firstRowId);
9051
- const ResultCellView = ({queryId, rowId, cellId, queries, debugIds}) =>
9052
- wrap(
9053
- EMPTY_STRING +
9054
- (useResultCell(queryId, rowId, cellId, queries) ?? EMPTY_STRING),
9055
- void 0,
9056
- debugIds,
9057
- cellId,
9058
- );
9059
- const ResultRowView = ({
9060
- queryId,
9061
- rowId,
9062
- queries,
9063
- resultCellComponent: ResultCell = ResultCellView,
9064
- getResultCellComponentProps,
9065
- separator,
9066
- debugIds,
9067
- }) =>
9068
- wrap(
9069
- arrayMap(useResultCellIds(queryId, rowId, queries), (cellId) =>
9196
+ arrayMap(rowIds, (rowId2) =>
9070
9197
  /* @__PURE__ */ jsx(
9071
- ResultCell,
9198
+ Row,
9072
9199
  {
9073
- ...getProps(getResultCellComponentProps, cellId),
9074
- queryId,
9075
- rowId,
9076
- cellId,
9077
- queries,
9200
+ ...getProps(getRowComponentProps, rowId2),
9201
+ tableId: localTableId,
9202
+ rowId: rowId2,
9203
+ store,
9078
9204
  debugIds,
9079
9205
  },
9080
- cellId,
9206
+ rowId2,
9081
9207
  ),
9082
9208
  ),
9083
9209
  separator,
9084
9210
  debugIds,
9085
9211
  rowId,
9086
9212
  );
9087
- const ResultTableView = (props) =>
9088
- resultTableView(props, useResultRowIds(props.queryId, props.queries));
9089
- const ResultSortedTableView = ({cellId, descending, offset, limit, ...props}) =>
9090
- resultTableView(
9091
- props,
9092
- useResultSortedRowIds(
9093
- props.queryId,
9094
- cellId,
9095
- descending,
9096
- offset,
9097
- limit,
9098
- props.queries,
9099
- ),
9100
- );
9101
- const CheckpointView = ({checkpoints, checkpointId, debugIds}) =>
9102
- wrap(
9103
- useCheckpoint(checkpointId, checkpoints) ?? EMPTY_STRING,
9104
- void 0,
9213
+ };
9214
+ const getUseCheckpointView =
9215
+ (getCheckpoints) =>
9216
+ ({
9217
+ checkpoints,
9218
+ checkpointComponent: Checkpoint = CheckpointView,
9219
+ getCheckpointComponentProps,
9220
+ separator,
9105
9221
  debugIds,
9106
- checkpointId,
9107
- );
9222
+ }) => {
9223
+ const resolvedCheckpoints = useCheckpointsOrCheckpointsById(checkpoints);
9224
+ return wrap(
9225
+ arrayMap(
9226
+ getCheckpoints(useCheckpointIds(resolvedCheckpoints)),
9227
+ (checkpointId) =>
9228
+ /* @__PURE__ */ jsx(
9229
+ Checkpoint,
9230
+ {
9231
+ ...getProps(getCheckpointComponentProps, checkpointId),
9232
+ checkpoints: resolvedCheckpoints,
9233
+ checkpointId,
9234
+ debugIds,
9235
+ },
9236
+ checkpointId,
9237
+ ),
9238
+ ),
9239
+ separator,
9240
+ );
9241
+ };
9242
+
9108
9243
  const BackwardCheckpointsView = getUseCheckpointView(
9109
9244
  (checkpointIds) => checkpointIds[0],
9110
9245
  );
9246
+
9111
9247
  const CurrentCheckpointView = getUseCheckpointView((checkpointIds) =>
9112
9248
  isUndefined(checkpointIds[1]) ? [] : [checkpointIds[1]],
9113
9249
  );
9250
+
9114
9251
  const ForwardCheckpointsView = getUseCheckpointView(
9115
9252
  (checkpointIds) => checkpointIds[2],
9116
9253
  );
9117
9254
 
9118
- const EDITABLE = 'editable';
9119
- const LEFT_ARROW = '\u2190';
9120
- const UP_ARROW = '\u2191';
9121
- const RIGHT_ARROW = '\u2192';
9122
- const DOWN_ARROW = '\u2193';
9123
- const useDottedCellIds = (tableId, store) =>
9124
- arrayMap(useTableCellIds(tableId, store), (cellId) => tableId + DOT + cellId);
9125
- const useCallbackOrUndefined = (callback, deps, test) => {
9126
- const returnCallback = useCallback(callback, deps);
9127
- return test ? returnCallback : void 0;
9128
- };
9129
- const useParams = (...args) =>
9130
- useMemo(
9131
- () => args,
9132
- // eslint-disable-next-line react-hooks/exhaustive-deps
9133
- args,
9134
- );
9135
- const useStoreCellComponentProps = (store, tableId) =>
9136
- useMemo(() => ({store, tableId}), [store, tableId]);
9137
- const useQueriesCellComponentProps = (queries, queryId) =>
9138
- useMemo(() => ({queries, queryId}), [queries, queryId]);
9139
- const useSortingAndPagination = (
9140
- cellId,
9141
- descending = false,
9142
- sortOnClick,
9143
- offset = 0,
9144
- limit,
9145
- total,
9146
- paginator,
9147
- onChange,
9148
- ) => {
9149
- const [[currentCellId, currentDescending, currentOffset], setState] =
9150
- useState([cellId, descending, offset]);
9151
- const setStateAndChange = useCallback(
9152
- (sortAndOffset) => {
9153
- setState(sortAndOffset);
9154
- onChange?.(sortAndOffset);
9155
- },
9156
- [onChange],
9157
- );
9158
- const handleSort = useCallbackOrUndefined(
9159
- (cellId2) =>
9160
- setStateAndChange([
9161
- cellId2,
9162
- cellId2 == currentCellId ? !currentDescending : false,
9163
- currentOffset,
9164
- ]),
9165
- [setStateAndChange, currentCellId, currentDescending, currentOffset],
9166
- sortOnClick,
9167
- );
9168
- const handleChangeOffset = useCallback(
9169
- (offset2) => setStateAndChange([currentCellId, currentDescending, offset2]),
9170
- [setStateAndChange, currentCellId, currentDescending],
9255
+ const SliceView$1 = ({
9256
+ indexId,
9257
+ sliceId,
9258
+ indexes,
9259
+ rowComponent: Row = RowView,
9260
+ getRowComponentProps,
9261
+ separator,
9262
+ debugIds,
9263
+ }) => {
9264
+ const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
9265
+ useIndexesOrIndexesById(indexes),
9266
+ indexId,
9171
9267
  );
9172
- const PaginatorComponent =
9173
- paginator === true ? SortedTablePaginator : paginator;
9174
- return [
9175
- [currentCellId, currentDescending, currentOffset],
9176
- handleSort,
9177
- useMemo(
9178
- () =>
9179
- paginator === false
9180
- ? null
9181
- : /* @__PURE__ */ jsx(PaginatorComponent, {
9182
- offset: currentOffset,
9183
- limit,
9184
- total,
9185
- onChange: handleChangeOffset,
9186
- }),
9187
- [
9188
- paginator,
9189
- PaginatorComponent,
9190
- currentOffset,
9191
- limit,
9192
- total,
9193
- handleChangeOffset,
9194
- ],
9268
+ const rowIds = useSliceRowIds(indexId, sliceId, resolvedIndexes);
9269
+ return wrap(
9270
+ arrayMap(rowIds, (rowId) =>
9271
+ /* @__PURE__ */ jsx(
9272
+ Row,
9273
+ {
9274
+ ...getProps(getRowComponentProps, rowId),
9275
+ tableId,
9276
+ rowId,
9277
+ store,
9278
+ debugIds,
9279
+ },
9280
+ rowId,
9281
+ ),
9195
9282
  ),
9196
- ];
9283
+ separator,
9284
+ debugIds,
9285
+ sliceId,
9286
+ );
9197
9287
  };
9198
- const useCells = (defaultCellIds, customCells, defaultCellComponent) =>
9199
- useMemo(() => {
9200
- const cellIds = customCells ?? defaultCellIds;
9201
- return objMap(
9202
- isArray(cellIds)
9203
- ? objNew(arrayMap(cellIds, (cellId) => [cellId, cellId]))
9204
- : cellIds,
9205
- (labelOrCustomCell, cellId) => ({
9206
- ...{label: cellId, component: defaultCellComponent},
9207
- ...(isString(labelOrCustomCell)
9208
- ? {label: labelOrCustomCell}
9209
- : labelOrCustomCell),
9210
- }),
9211
- );
9212
- }, [customCells, defaultCellComponent, defaultCellIds]);
9213
- const HtmlTable = ({
9214
- className,
9215
- headerRow,
9216
- idColumn,
9217
- params: [
9218
- cells,
9219
- cellComponentProps,
9220
- rowIds,
9221
- sortAndOffset,
9222
- handleSort,
9223
- paginatorComponent,
9224
- ],
9225
- }) =>
9226
- /* @__PURE__ */ jsxs('table', {
9227
- className,
9228
- children: [
9229
- paginatorComponent
9230
- ? /* @__PURE__ */ jsx('caption', {children: paginatorComponent})
9231
- : null,
9232
- headerRow === false
9233
- ? null
9234
- : /* @__PURE__ */ jsx('thead', {
9235
- children: /* @__PURE__ */ jsxs('tr', {
9236
- children: [
9237
- idColumn === false
9238
- ? null
9239
- : /* @__PURE__ */ jsx(HtmlHeaderCell, {
9240
- sort: sortAndOffset ?? [],
9241
- label: 'Id',
9242
- onClick: handleSort,
9243
- }),
9244
- objToArray(cells, ({label}, cellId) =>
9245
- /* @__PURE__ */ jsx(
9246
- HtmlHeaderCell,
9247
- {
9248
- cellId,
9249
- label,
9250
- sort: sortAndOffset ?? [],
9251
- onClick: handleSort,
9252
- },
9253
- cellId,
9254
- ),
9255
- ),
9256
- ],
9257
- }),
9258
- }),
9259
- /* @__PURE__ */ jsx('tbody', {
9260
- children: arrayMap(rowIds, (rowId) =>
9261
- /* @__PURE__ */ jsxs(
9262
- 'tr',
9263
- {
9264
- children: [
9265
- idColumn === false
9266
- ? null
9267
- : /* @__PURE__ */ jsx('th', {children: rowId}),
9268
- objToArray(
9269
- cells,
9270
- ({component: CellView2, getComponentProps}, cellId) =>
9271
- /* @__PURE__ */ jsx(
9272
- 'td',
9273
- {
9274
- children: /* @__PURE__ */ jsx(CellView2, {
9275
- ...getProps(getComponentProps, rowId, cellId),
9276
- ...cellComponentProps,
9277
- rowId,
9278
- cellId,
9279
- }),
9280
- },
9281
- cellId,
9282
- ),
9283
- ),
9284
- ],
9285
- },
9288
+
9289
+ const IndexView$1 = ({
9290
+ indexId,
9291
+ indexes,
9292
+ sliceComponent: Slice = SliceView$1,
9293
+ getSliceComponentProps,
9294
+ separator,
9295
+ debugIds,
9296
+ }) =>
9297
+ wrap(
9298
+ arrayMap(useSliceIds(indexId, indexes), (sliceId) =>
9299
+ /* @__PURE__ */ jsx(
9300
+ Slice,
9301
+ {
9302
+ ...getProps(getSliceComponentProps, sliceId),
9303
+ indexId,
9304
+ sliceId,
9305
+ indexes,
9306
+ debugIds,
9307
+ },
9308
+ sliceId,
9309
+ ),
9310
+ ),
9311
+ separator,
9312
+ debugIds,
9313
+ indexId,
9314
+ );
9315
+
9316
+ const LinkedRowsView = (props) =>
9317
+ useComponentPerRow(props, useLinkedRowIds, props.firstRowId);
9318
+
9319
+ const LocalRowsView = (props) =>
9320
+ useComponentPerRow(props, useLocalRowIds, props.remoteRowId);
9321
+
9322
+ const MetricView = ({metricId, metrics, debugIds}) =>
9323
+ wrap(
9324
+ useMetric(metricId, metrics) ?? EMPTY_STRING,
9325
+ void 0,
9326
+ debugIds,
9327
+ metricId,
9328
+ );
9329
+
9330
+ const RemoteRowView = ({
9331
+ relationshipId,
9332
+ localRowId,
9333
+ relationships,
9334
+ rowComponent: Row = RowView,
9335
+ getRowComponentProps,
9336
+ debugIds,
9337
+ }) => {
9338
+ const [resolvedRelationships, store, , remoteTableId] =
9339
+ getRelationshipsStoreTableIds(
9340
+ useRelationshipsOrRelationshipsById(relationships),
9341
+ relationshipId,
9342
+ );
9343
+ const rowId = useRemoteRowId(
9344
+ relationshipId,
9345
+ localRowId,
9346
+ resolvedRelationships,
9347
+ );
9348
+ return wrap(
9349
+ isUndefined(remoteTableId) || isUndefined(rowId)
9350
+ ? null
9351
+ : /* @__PURE__ */ jsx(
9352
+ Row,
9353
+ {
9354
+ ...getProps(getRowComponentProps, rowId),
9355
+ tableId: remoteTableId,
9286
9356
  rowId,
9287
- ),
9357
+ store,
9358
+ debugIds,
9359
+ },
9360
+ rowId,
9288
9361
  ),
9289
- }),
9290
- ],
9291
- });
9292
- const HtmlHeaderCell = ({
9293
- cellId,
9294
- sort: [sortCellId, sortDescending],
9295
- label = cellId ?? EMPTY_STRING,
9296
- onClick,
9362
+ void 0,
9363
+ debugIds,
9364
+ localRowId,
9365
+ );
9366
+ };
9367
+
9368
+ const ResultSortedTableView = ({cellId, descending, offset, limit, ...props}) =>
9369
+ resultTableView(
9370
+ props,
9371
+ useResultSortedRowIds(
9372
+ props.queryId,
9373
+ cellId,
9374
+ descending,
9375
+ offset,
9376
+ limit,
9377
+ props.queries,
9378
+ ),
9379
+ );
9380
+
9381
+ const ResultTableView = (props) =>
9382
+ resultTableView(props, useResultRowIds(props.queryId, props.queries));
9383
+
9384
+ const SortedTableView = ({cellId, descending, offset, limit, ...props}) =>
9385
+ tableView(
9386
+ props,
9387
+ useSortedRowIds(
9388
+ props.tableId,
9389
+ cellId,
9390
+ descending,
9391
+ offset,
9392
+ limit,
9393
+ props.store,
9394
+ ),
9395
+ );
9396
+
9397
+ const TableView$1 = (props) =>
9398
+ tableView(props, useRowIds(props.tableId, props.store));
9399
+
9400
+ const TablesView$1 = ({
9401
+ store,
9402
+ tableComponent: Table = TableView$1,
9403
+ getTableComponentProps,
9404
+ separator,
9405
+ debugIds,
9297
9406
  }) =>
9298
- /* @__PURE__ */ jsxs('th', {
9299
- onClick: useCallbackOrUndefined(
9300
- () => onClick?.(cellId),
9301
- [onClick, cellId],
9302
- onClick,
9407
+ wrap(
9408
+ arrayMap(useTableIds(store), (tableId) =>
9409
+ /* @__PURE__ */ jsx(
9410
+ Table,
9411
+ {
9412
+ ...getProps(getTableComponentProps, tableId),
9413
+ tableId,
9414
+ store,
9415
+ debugIds,
9416
+ },
9417
+ tableId,
9418
+ ),
9303
9419
  ),
9304
- className:
9305
- isUndefined(sortDescending) || sortCellId != cellId
9306
- ? void 0
9307
- : `sorted ${sortDescending ? 'de' : 'a'}scending`,
9308
- children: [
9309
- isUndefined(sortDescending) || sortCellId != cellId
9310
- ? null
9311
- : (sortDescending ? DOWN_ARROW : UP_ARROW) + ' ',
9312
- label,
9313
- ],
9314
- });
9420
+ separator,
9421
+ );
9422
+
9423
+ const ValueView = ({valueId, store, debugIds}) =>
9424
+ wrap(
9425
+ EMPTY_STRING + (useValue(valueId, store) ?? EMPTY_STRING),
9426
+ void 0,
9427
+ debugIds,
9428
+ valueId,
9429
+ );
9430
+
9431
+ const ValuesView$1 = ({
9432
+ store,
9433
+ valueComponent: Value = ValueView,
9434
+ getValueComponentProps,
9435
+ separator,
9436
+ debugIds,
9437
+ }) =>
9438
+ wrap(
9439
+ arrayMap(useValueIds(store), (valueId) =>
9440
+ /* @__PURE__ */ jsx(
9441
+ Value,
9442
+ {
9443
+ ...getProps(getValueComponentProps, valueId),
9444
+ valueId,
9445
+ store,
9446
+ debugIds,
9447
+ },
9448
+ valueId,
9449
+ ),
9450
+ ),
9451
+ separator,
9452
+ );
9453
+
9454
+ const useDottedCellIds = (tableId, store) =>
9455
+ arrayMap(useTableCellIds(tableId, store), (cellId) => tableId + DOT + cellId);
9315
9456
  const RelationshipInHtmlRow = ({
9316
9457
  localRowId,
9317
9458
  params: [
@@ -9322,17 +9463,31 @@ const RelationshipInHtmlRow = ({
9322
9463
  relationshipId,
9323
9464
  relationships,
9324
9465
  store,
9466
+ extraCellsBefore,
9467
+ extraCellsAfter,
9325
9468
  ],
9326
9469
  }) => {
9327
9470
  const remoteRowId = useRemoteRowId(relationshipId, localRowId, relationships);
9471
+ const rowProps = {
9472
+ tableId: localTableId ?? '',
9473
+ rowId: localRowId,
9474
+ store,
9475
+ };
9328
9476
  return /* @__PURE__ */ jsxs('tr', {
9329
9477
  children: [
9478
+ extraRowCells(extraCellsBefore, rowProps),
9330
9479
  idColumn === false
9331
9480
  ? null
9332
9481
  : /* @__PURE__ */ jsxs(Fragment, {
9333
9482
  children: [
9334
- /* @__PURE__ */ jsx('th', {children: localRowId}),
9335
- /* @__PURE__ */ jsx('th', {children: remoteRowId}),
9483
+ /* @__PURE__ */ jsx('th', {
9484
+ title: localRowId,
9485
+ children: localRowId,
9486
+ }),
9487
+ /* @__PURE__ */ jsx('th', {
9488
+ title: remoteRowId,
9489
+ children: remoteRowId,
9490
+ }),
9336
9491
  ],
9337
9492
  }),
9338
9493
  objToArray(
@@ -9362,145 +9517,215 @@ const RelationshipInHtmlRow = ({
9362
9517
  );
9363
9518
  },
9364
9519
  ),
9520
+ extraRowCells(extraCellsAfter, rowProps, 1),
9521
+ ],
9522
+ });
9523
+ };
9524
+ const RelationshipInHtmlTable = ({
9525
+ relationshipId,
9526
+ relationships,
9527
+ editable,
9528
+ customCells,
9529
+ extraCellsBefore,
9530
+ extraCellsAfter,
9531
+ className,
9532
+ headerRow,
9533
+ idColumn = true,
9534
+ }) => {
9535
+ const [resolvedRelationships, store, localTableId, remoteTableId] =
9536
+ getRelationshipsStoreTableIds(
9537
+ useRelationshipsOrRelationshipsById(relationships),
9538
+ relationshipId,
9539
+ );
9540
+ const cells = useCells(
9541
+ [
9542
+ ...useDottedCellIds(localTableId, store),
9543
+ ...useDottedCellIds(remoteTableId, store),
9544
+ ],
9545
+ customCells,
9546
+ editable ? EditableCellView : CellView,
9547
+ );
9548
+ const params = useParams(
9549
+ idColumn,
9550
+ cells,
9551
+ localTableId,
9552
+ remoteTableId,
9553
+ relationshipId,
9554
+ resolvedRelationships,
9555
+ store,
9556
+ extraCellsBefore,
9557
+ extraCellsAfter,
9558
+ );
9559
+ return /* @__PURE__ */ jsxs('table', {
9560
+ className,
9561
+ children: [
9562
+ headerRow === false
9563
+ ? null
9564
+ : /* @__PURE__ */ jsx('thead', {
9565
+ children: /* @__PURE__ */ jsxs('tr', {
9566
+ children: [
9567
+ extraHeaders(extraCellsBefore),
9568
+ idColumn === false
9569
+ ? null
9570
+ : /* @__PURE__ */ jsxs(Fragment, {
9571
+ children: [
9572
+ /* @__PURE__ */ jsxs('th', {
9573
+ children: [localTableId, '.Id'],
9574
+ }),
9575
+ /* @__PURE__ */ jsxs('th', {
9576
+ children: [remoteTableId, '.Id'],
9577
+ }),
9578
+ ],
9579
+ }),
9580
+ objToArray(cells, ({label}, cellId) =>
9581
+ /* @__PURE__ */ jsx('th', {children: label}, cellId),
9582
+ ),
9583
+ extraHeaders(extraCellsAfter, 1),
9584
+ ],
9585
+ }),
9586
+ }),
9587
+ /* @__PURE__ */ jsx('tbody', {
9588
+ children: arrayMap(useRowIds(localTableId, store), (localRowId) =>
9589
+ /* @__PURE__ */ jsx(
9590
+ RelationshipInHtmlRow,
9591
+ {
9592
+ localRowId,
9593
+ params,
9594
+ },
9595
+ localRowId,
9596
+ ),
9597
+ ),
9598
+ }),
9365
9599
  ],
9366
9600
  });
9367
9601
  };
9368
- const EditableThing = ({
9369
- thing,
9370
- onThingChange,
9371
- className,
9372
- hasSchema,
9373
- showType = true,
9602
+
9603
+ const LEFT_ARROW = '\u2190';
9604
+ const RIGHT_ARROW = '\u2192';
9605
+ const useSortingAndPagination = (
9606
+ cellId,
9607
+ descending = false,
9608
+ sortOnClick,
9609
+ offset = 0,
9610
+ limit,
9611
+ total,
9612
+ paginator,
9613
+ onChange,
9614
+ ) => {
9615
+ const [[currentCellId, currentDescending, currentOffset], setState] =
9616
+ useState([cellId, descending, offset]);
9617
+ const setStateAndChange = useCallback(
9618
+ (sortAndOffset) => {
9619
+ setState(sortAndOffset);
9620
+ onChange?.(sortAndOffset);
9621
+ },
9622
+ [onChange],
9623
+ );
9624
+ const handleSort = useCallbackOrUndefined(
9625
+ (cellId2) =>
9626
+ setStateAndChange([
9627
+ cellId2,
9628
+ cellId2 == currentCellId ? !currentDescending : false,
9629
+ currentOffset,
9630
+ ]),
9631
+ [setStateAndChange, currentCellId, currentDescending, currentOffset],
9632
+ sortOnClick,
9633
+ );
9634
+ const handleChangeOffset = useCallback(
9635
+ (offset2) => setStateAndChange([currentCellId, currentDescending, offset2]),
9636
+ [setStateAndChange, currentCellId, currentDescending],
9637
+ );
9638
+ const PaginatorComponent =
9639
+ paginator === true ? SortedTablePaginator : paginator;
9640
+ return [
9641
+ [currentCellId, currentDescending, currentOffset],
9642
+ handleSort,
9643
+ useMemo(
9644
+ () =>
9645
+ paginator === false
9646
+ ? null
9647
+ : /* @__PURE__ */ jsx(PaginatorComponent, {
9648
+ offset: currentOffset,
9649
+ limit,
9650
+ total,
9651
+ onChange: handleChangeOffset,
9652
+ }),
9653
+ [
9654
+ paginator,
9655
+ PaginatorComponent,
9656
+ currentOffset,
9657
+ limit,
9658
+ total,
9659
+ handleChangeOffset,
9660
+ ],
9661
+ ),
9662
+ ];
9663
+ };
9664
+ const SortedTablePaginator = ({
9665
+ onChange,
9666
+ total,
9667
+ offset = 0,
9668
+ limit = total,
9669
+ singular = 'row',
9670
+ plural = singular + 's',
9374
9671
  }) => {
9375
- const [thingType, setThingType] = useState();
9376
- const [currentThing, setCurrentThing] = useState();
9377
- const [stringThing, setStringThing] = useState();
9378
- const [numberThing, setNumberThing] = useState();
9379
- const [booleanThing, setBooleanThing] = useState();
9380
- if (currentThing !== thing) {
9381
- setThingType(getCellOrValueType(thing));
9382
- setCurrentThing(thing);
9383
- setStringThing(String(thing));
9384
- setNumberThing(Number(thing) || 0);
9385
- setBooleanThing(Boolean(thing));
9672
+ if (offset > total || offset < 0) {
9673
+ offset = 0;
9674
+ onChange(0);
9386
9675
  }
9387
- const handleThingChange = useCallback(
9388
- (thing2, setTypedThing) => {
9389
- setTypedThing(thing2);
9390
- setCurrentThing(thing2);
9391
- onThingChange(thing2);
9392
- },
9393
- [onThingChange],
9676
+ const handlePrevClick = useCallbackOrUndefined(
9677
+ () => onChange(offset - limit),
9678
+ [onChange, offset, limit],
9679
+ offset > 0,
9394
9680
  );
9395
- const handleTypeChange = useCallback(() => {
9396
- if (!hasSchema?.()) {
9397
- const nextType = getTypeCase(thingType, NUMBER, BOOLEAN, STRING);
9398
- const thing2 = getTypeCase(
9399
- nextType,
9400
- stringThing,
9401
- numberThing,
9402
- booleanThing,
9403
- );
9404
- setThingType(nextType);
9405
- setCurrentThing(thing2);
9406
- onThingChange(thing2);
9407
- }
9408
- }, [
9409
- hasSchema,
9410
- onThingChange,
9411
- stringThing,
9412
- numberThing,
9413
- booleanThing,
9414
- thingType,
9415
- ]);
9416
- return /* @__PURE__ */ jsxs('div', {
9417
- className,
9681
+ const handleNextClick = useCallbackOrUndefined(
9682
+ () => onChange(offset + limit),
9683
+ [onChange, offset, limit],
9684
+ offset + limit < total,
9685
+ );
9686
+ return /* @__PURE__ */ jsxs(Fragment, {
9418
9687
  children: [
9419
- showType
9420
- ? /* @__PURE__ */ jsx('button', {
9421
- className: thingType,
9422
- onClick: handleTypeChange,
9423
- children: thingType,
9424
- })
9425
- : null,
9426
- getTypeCase(
9427
- thingType,
9428
- /* @__PURE__ */ jsx(
9429
- 'input',
9430
- {
9431
- value: stringThing,
9432
- onChange: useCallback(
9433
- (event) =>
9434
- handleThingChange(
9435
- String(event[CURRENT_TARGET][_VALUE]),
9436
- setStringThing,
9437
- ),
9438
- [handleThingChange],
9439
- ),
9440
- },
9441
- thingType,
9442
- ),
9443
- /* @__PURE__ */ jsx(
9444
- 'input',
9445
- {
9446
- type: 'number',
9447
- value: numberThing,
9448
- onChange: useCallback(
9449
- (event) =>
9450
- handleThingChange(
9451
- Number(event[CURRENT_TARGET][_VALUE] || 0),
9452
- setNumberThing,
9453
- ),
9454
- [handleThingChange],
9455
- ),
9456
- },
9457
- thingType,
9458
- ),
9459
- /* @__PURE__ */ jsx(
9460
- 'input',
9461
- {
9462
- type: 'checkbox',
9463
- checked: booleanThing,
9464
- onChange: useCallback(
9465
- (event) =>
9466
- handleThingChange(
9467
- Boolean(event[CURRENT_TARGET].checked),
9468
- setBooleanThing,
9469
- ),
9470
- [handleThingChange],
9471
- ),
9472
- },
9473
- thingType,
9474
- ),
9475
- ),
9688
+ total > limit &&
9689
+ /* @__PURE__ */ jsxs(Fragment, {
9690
+ children: [
9691
+ /* @__PURE__ */ jsx('button', {
9692
+ className: 'previous',
9693
+ disabled: offset == 0,
9694
+ onClick: handlePrevClick,
9695
+ children: LEFT_ARROW,
9696
+ }),
9697
+ /* @__PURE__ */ jsx('button', {
9698
+ className: 'next',
9699
+ disabled: offset + limit >= total,
9700
+ onClick: handleNextClick,
9701
+ children: RIGHT_ARROW,
9702
+ }),
9703
+ offset + 1,
9704
+ ' to ',
9705
+ mathMin(total, offset + limit),
9706
+ ' of ',
9707
+ ],
9708
+ }),
9709
+ total,
9710
+ ' ',
9711
+ total != 1 ? plural : singular,
9476
9712
  ],
9477
9713
  });
9478
9714
  };
9479
- const TableInHtmlTable = ({tableId, store, editable, customCells, ...props}) =>
9480
- /* @__PURE__ */ jsx(HtmlTable, {
9481
- ...props,
9482
- params: useParams(
9483
- useCells(
9484
- useTableCellIds(tableId, store),
9485
- customCells,
9486
- editable ? EditableCellView : CellView,
9487
- ),
9488
- useStoreCellComponentProps(store, tableId),
9489
- useRowIds(tableId, store),
9490
- ),
9491
- });
9492
- const SortedTableInHtmlTable = ({
9493
- tableId,
9715
+
9716
+ const ResultSortedTableInHtmlTable = ({
9717
+ queryId,
9494
9718
  cellId,
9495
9719
  descending,
9496
9720
  offset,
9497
9721
  limit,
9498
- store,
9499
- editable,
9722
+ queries,
9500
9723
  sortOnClick,
9501
9724
  paginator = false,
9502
- onChange,
9503
9725
  customCells,
9726
+ extraCellsBefore,
9727
+ extraCellsAfter,
9728
+ onChange,
9504
9729
  ...props
9505
9730
  }) => {
9506
9731
  const [sortAndOffset, handleSort, paginatorComponent] =
@@ -9510,7 +9735,7 @@ const SortedTableInHtmlTable = ({
9510
9735
  sortOnClick,
9511
9736
  offset,
9512
9737
  limit,
9513
- useRowCount(tableId, store),
9738
+ useResultRowCount(queryId, queries),
9514
9739
  paginator,
9515
9740
  onChange,
9516
9741
  );
@@ -9518,72 +9743,52 @@ const SortedTableInHtmlTable = ({
9518
9743
  ...props,
9519
9744
  params: useParams(
9520
9745
  useCells(
9521
- useTableCellIds(tableId, store),
9746
+ useResultTableCellIds(queryId, queries),
9522
9747
  customCells,
9523
- editable ? EditableCellView : CellView,
9748
+ ResultCellView,
9524
9749
  ),
9525
- useStoreCellComponentProps(store, tableId),
9526
- useSortedRowIds(tableId, ...sortAndOffset, limit, store),
9750
+ useQueriesCellComponentProps(queries, queryId),
9751
+ useResultSortedRowIds(queryId, ...sortAndOffset, limit, queries),
9752
+ extraCellsBefore,
9753
+ extraCellsAfter,
9527
9754
  sortAndOffset,
9528
9755
  handleSort,
9529
9756
  paginatorComponent,
9530
9757
  ),
9531
9758
  });
9532
- };
9533
- const ValuesInHtmlTable = ({
9534
- store,
9535
- editable = false,
9536
- valueComponent: Value = editable ? EditableValueView : ValueView,
9537
- getValueComponentProps,
9538
- className,
9539
- headerRow,
9540
- idColumn,
9541
- }) =>
9542
- /* @__PURE__ */ jsxs('table', {
9543
- className,
9544
- children: [
9545
- headerRow === false
9546
- ? null
9547
- : /* @__PURE__ */ jsx('thead', {
9548
- children: /* @__PURE__ */ jsxs('tr', {
9549
- children: [
9550
- idColumn === false
9551
- ? null
9552
- : /* @__PURE__ */ jsx('th', {children: 'Id'}),
9553
- /* @__PURE__ */ jsx('th', {children: VALUE}),
9554
- ],
9555
- }),
9556
- }),
9557
- /* @__PURE__ */ jsx('tbody', {
9558
- children: arrayMap(useValueIds(store), (valueId) =>
9559
- /* @__PURE__ */ jsxs(
9560
- 'tr',
9561
- {
9562
- children: [
9563
- idColumn === false
9564
- ? null
9565
- : /* @__PURE__ */ jsx('th', {children: valueId}),
9566
- /* @__PURE__ */ jsx('td', {
9567
- children: /* @__PURE__ */ jsx(Value, {
9568
- ...getProps(getValueComponentProps, valueId),
9569
- valueId,
9570
- store,
9571
- }),
9572
- }),
9573
- ],
9574
- },
9575
- valueId,
9576
- ),
9577
- ),
9578
- }),
9579
- ],
9759
+ };
9760
+
9761
+ const ResultTableInHtmlTable = ({
9762
+ queryId,
9763
+ queries,
9764
+ customCells,
9765
+ extraCellsBefore,
9766
+ extraCellsAfter,
9767
+ ...props
9768
+ }) =>
9769
+ /* @__PURE__ */ jsx(HtmlTable, {
9770
+ ...props,
9771
+ params: useParams(
9772
+ useCells(
9773
+ useResultTableCellIds(queryId, queries),
9774
+ customCells,
9775
+ ResultCellView,
9776
+ ),
9777
+ useQueriesCellComponentProps(queries, queryId),
9778
+ useResultRowIds(queryId, queries),
9779
+ extraCellsBefore,
9780
+ extraCellsAfter,
9781
+ ),
9580
9782
  });
9783
+
9581
9784
  const SliceInHtmlTable = ({
9582
9785
  indexId,
9583
9786
  sliceId,
9584
9787
  indexes,
9585
9788
  editable,
9586
9789
  customCells,
9790
+ extraCellsBefore,
9791
+ extraCellsAfter,
9587
9792
  ...props
9588
9793
  }) => {
9589
9794
  const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
@@ -9600,105 +9805,26 @@ const SliceInHtmlTable = ({
9600
9805
  ),
9601
9806
  useStoreCellComponentProps(store, tableId),
9602
9807
  useSliceRowIds(indexId, sliceId, resolvedIndexes),
9808
+ extraCellsBefore,
9809
+ extraCellsAfter,
9603
9810
  ),
9604
9811
  });
9605
9812
  };
9606
- const RelationshipInHtmlTable = ({
9607
- relationshipId,
9608
- relationships,
9609
- editable,
9610
- customCells,
9611
- className,
9612
- headerRow,
9613
- idColumn = true,
9614
- }) => {
9615
- const [resolvedRelationships, store, localTableId, remoteTableId] =
9616
- getRelationshipsStoreTableIds(
9617
- useRelationshipsOrRelationshipsById(relationships),
9618
- relationshipId,
9619
- );
9620
- const cells = useCells(
9621
- [
9622
- ...useDottedCellIds(localTableId, store),
9623
- ...useDottedCellIds(remoteTableId, store),
9624
- ],
9625
- customCells,
9626
- editable ? EditableCellView : CellView,
9627
- );
9628
- const params = useParams(
9629
- idColumn,
9630
- cells,
9631
- localTableId,
9632
- remoteTableId,
9633
- relationshipId,
9634
- resolvedRelationships,
9635
- store,
9636
- );
9637
- return /* @__PURE__ */ jsxs('table', {
9638
- className,
9639
- children: [
9640
- headerRow === false
9641
- ? null
9642
- : /* @__PURE__ */ jsx('thead', {
9643
- children: /* @__PURE__ */ jsxs('tr', {
9644
- children: [
9645
- idColumn === false
9646
- ? null
9647
- : /* @__PURE__ */ jsxs(Fragment, {
9648
- children: [
9649
- /* @__PURE__ */ jsxs('th', {
9650
- children: [localTableId, '.Id'],
9651
- }),
9652
- /* @__PURE__ */ jsxs('th', {
9653
- children: [remoteTableId, '.Id'],
9654
- }),
9655
- ],
9656
- }),
9657
- objToArray(cells, ({label}, cellId) =>
9658
- /* @__PURE__ */ jsx('th', {children: label}, cellId),
9659
- ),
9660
- ],
9661
- }),
9662
- }),
9663
- /* @__PURE__ */ jsx('tbody', {
9664
- children: arrayMap(useRowIds(localTableId, store), (localRowId) =>
9665
- /* @__PURE__ */ jsx(
9666
- RelationshipInHtmlRow,
9667
- {
9668
- localRowId,
9669
- params,
9670
- },
9671
- localRowId,
9672
- ),
9673
- ),
9674
- }),
9675
- ],
9676
- });
9677
- };
9678
- const ResultTableInHtmlTable = ({queryId, queries, customCells, ...props}) =>
9679
- /* @__PURE__ */ jsx(HtmlTable, {
9680
- ...props,
9681
- params: useParams(
9682
- useCells(
9683
- useResultTableCellIds(queryId, queries),
9684
- customCells,
9685
- ResultCellView,
9686
- ),
9687
- useQueriesCellComponentProps(queries, queryId),
9688
- useResultRowIds(queryId, queries),
9689
- ),
9690
- });
9691
- const ResultSortedTableInHtmlTable = ({
9692
- queryId,
9813
+
9814
+ const SortedTableInHtmlTable = ({
9815
+ tableId,
9693
9816
  cellId,
9694
9817
  descending,
9695
9818
  offset,
9696
9819
  limit,
9697
- queries,
9820
+ store,
9821
+ editable,
9698
9822
  sortOnClick,
9699
9823
  paginator = false,
9700
- customCells,
9701
9824
  onChange,
9825
+ customCells,
9826
+ extraCellsBefore,
9827
+ extraCellsAfter,
9702
9828
  ...props
9703
9829
  }) => {
9704
9830
  const [sortAndOffset, handleSort, paginatorComponent] =
@@ -9708,7 +9834,7 @@ const ResultSortedTableInHtmlTable = ({
9708
9834
  sortOnClick,
9709
9835
  offset,
9710
9836
  limit,
9711
- useResultRowCount(queryId, queries),
9837
+ useRowCount(tableId, store),
9712
9838
  paginator,
9713
9839
  onChange,
9714
9840
  );
@@ -9716,99 +9842,117 @@ const ResultSortedTableInHtmlTable = ({
9716
9842
  ...props,
9717
9843
  params: useParams(
9718
9844
  useCells(
9719
- useResultTableCellIds(queryId, queries),
9845
+ useTableCellIds(tableId, store),
9720
9846
  customCells,
9721
- ResultCellView,
9847
+ editable ? EditableCellView : CellView,
9722
9848
  ),
9723
- useQueriesCellComponentProps(queries, queryId),
9724
- useResultSortedRowIds(queryId, ...sortAndOffset, limit, queries),
9849
+ useStoreCellComponentProps(store, tableId),
9850
+ useSortedRowIds(tableId, ...sortAndOffset, limit, store),
9851
+ extraCellsBefore,
9852
+ extraCellsAfter,
9725
9853
  sortAndOffset,
9726
9854
  handleSort,
9727
9855
  paginatorComponent,
9728
9856
  ),
9729
9857
  });
9730
9858
  };
9731
- const EditableCellView = ({
9859
+
9860
+ const TableInHtmlTable = ({
9732
9861
  tableId,
9733
- rowId,
9734
- cellId,
9735
9862
  store,
9736
- className,
9737
- showType,
9863
+ editable,
9864
+ customCells,
9865
+ extraCellsBefore,
9866
+ extraCellsAfter,
9867
+ ...props
9738
9868
  }) =>
9739
- /* @__PURE__ */ jsx(EditableThing, {
9740
- thing: useCell(tableId, rowId, cellId, store),
9741
- onThingChange: useSetCellCallback(
9742
- tableId,
9743
- rowId,
9744
- cellId,
9745
- (cell) => cell,
9746
- [],
9747
- store,
9869
+ /* @__PURE__ */ jsx(HtmlTable, {
9870
+ ...props,
9871
+ params: useParams(
9872
+ useCells(
9873
+ useTableCellIds(tableId, store),
9874
+ customCells,
9875
+ editable ? EditableCellView : CellView,
9876
+ ),
9877
+ useStoreCellComponentProps(store, tableId),
9878
+ useRowIds(tableId, store),
9879
+ extraCellsBefore,
9880
+ extraCellsAfter,
9748
9881
  ),
9749
- className: className ?? EDITABLE + CELL,
9750
- showType,
9751
- hasSchema: useStoreOrStoreById(store)?.hasTablesSchema,
9752
- });
9753
- const EditableValueView = ({valueId, store, className, showType}) =>
9754
- /* @__PURE__ */ jsx(EditableThing, {
9755
- thing: useValue(valueId, store),
9756
- onThingChange: useSetValueCallback(valueId, (value) => value, [], store),
9757
- className: className ?? EDITABLE + VALUE,
9758
- showType,
9759
- hasSchema: useStoreOrStoreById(store)?.hasValuesSchema,
9760
9882
  });
9761
- const SortedTablePaginator = ({
9762
- onChange,
9763
- total,
9764
- offset = 0,
9765
- limit = total,
9766
- singular = 'row',
9767
- plural = singular + 's',
9768
- }) => {
9769
- if (offset > total || offset < 0) {
9770
- offset = 0;
9771
- onChange(0);
9772
- }
9773
- const handlePrevClick = useCallbackOrUndefined(
9774
- () => onChange(offset - limit),
9775
- [onChange, offset, limit],
9776
- offset > 0,
9777
- );
9778
- const handleNextClick = useCallbackOrUndefined(
9779
- () => onChange(offset + limit),
9780
- [onChange, offset, limit],
9781
- offset + limit < total,
9883
+
9884
+ const extraValueCells = (
9885
+ extraValueCells2 = [],
9886
+ extraValueCellProps,
9887
+ after = 0,
9888
+ ) =>
9889
+ arrayMap(extraValueCells2, ({component: Component}, index) =>
9890
+ /* @__PURE__ */ jsx(
9891
+ 'td',
9892
+ {
9893
+ className: EXTRA,
9894
+ children: /* @__PURE__ */ jsx(Component, {...extraValueCellProps}),
9895
+ },
9896
+ extraKey(index, after),
9897
+ ),
9782
9898
  );
9783
- return /* @__PURE__ */ jsxs(Fragment, {
9899
+ const ValuesInHtmlTable = ({
9900
+ store,
9901
+ editable = false,
9902
+ valueComponent: Value = editable ? EditableValueView : ValueView,
9903
+ getValueComponentProps,
9904
+ extraCellsBefore,
9905
+ extraCellsAfter,
9906
+ className,
9907
+ headerRow,
9908
+ idColumn,
9909
+ }) =>
9910
+ /* @__PURE__ */ jsxs('table', {
9911
+ className,
9784
9912
  children: [
9785
- total > limit &&
9786
- /* @__PURE__ */ jsxs(Fragment, {
9787
- children: [
9788
- /* @__PURE__ */ jsx('button', {
9789
- className: 'previous',
9790
- disabled: offset == 0,
9791
- onClick: handlePrevClick,
9792
- children: LEFT_ARROW,
9793
- }),
9794
- /* @__PURE__ */ jsx('button', {
9795
- className: 'next',
9796
- disabled: offset + limit >= total,
9797
- onClick: handleNextClick,
9798
- children: RIGHT_ARROW,
9913
+ headerRow === false
9914
+ ? null
9915
+ : /* @__PURE__ */ jsx('thead', {
9916
+ children: /* @__PURE__ */ jsxs('tr', {
9917
+ children: [
9918
+ extraHeaders(extraCellsBefore),
9919
+ idColumn === false
9920
+ ? null
9921
+ : /* @__PURE__ */ jsx('th', {children: 'Id'}),
9922
+ /* @__PURE__ */ jsx('th', {children: VALUE}),
9923
+ extraHeaders(extraCellsAfter, 1),
9924
+ ],
9799
9925
  }),
9800
- offset + 1,
9801
- ' to ',
9802
- mathMin(total, offset + limit),
9803
- ' of ',
9804
- ],
9926
+ }),
9927
+ /* @__PURE__ */ jsx('tbody', {
9928
+ children: arrayMap(useValueIds(store), (valueId) => {
9929
+ const valueProps = {valueId, store};
9930
+ return /* @__PURE__ */ jsxs(
9931
+ 'tr',
9932
+ {
9933
+ children: [
9934
+ extraValueCells(extraCellsBefore, valueProps),
9935
+ idColumn === false
9936
+ ? null
9937
+ : /* @__PURE__ */ jsx('th', {
9938
+ title: valueId,
9939
+ children: valueId,
9940
+ }),
9941
+ /* @__PURE__ */ jsx('td', {
9942
+ children: /* @__PURE__ */ jsx(Value, {
9943
+ ...getProps(getValueComponentProps, valueId),
9944
+ ...valueProps,
9945
+ }),
9946
+ }),
9947
+ extraValueCells(extraCellsAfter, valueProps, 1),
9948
+ ],
9949
+ },
9950
+ valueId,
9951
+ );
9805
9952
  }),
9806
- total,
9807
- ' ',
9808
- total != 1 ? plural : singular,
9953
+ }),
9809
9954
  ],
9810
9955
  });
9811
- };
9812
9956
 
9813
9957
  const UNIQUE_ID = 'tinybaseInspector';
9814
9958
  const TITLE = 'TinyBase Inspector';
@@ -9842,16 +9986,9 @@ const Nub = ({s}) => {
9842
9986
  title: TITLE,
9843
9987
  'data-position': position,
9844
9988
  });
9845
- };
9846
-
9847
- const Details = ({
9848
- uniqueId,
9849
- summary,
9850
- editable,
9851
- handleEditable,
9852
- children,
9853
- s,
9854
- }) => {
9989
+ };
9990
+
9991
+ const Details = ({uniqueId, title, editable, handleEditable, children, s}) => {
9855
9992
  const open = !!useCell(STATE_TABLE, uniqueId, OPEN_CELL, s);
9856
9993
  const handleToggle = useSetCellCallback(
9857
9994
  STATE_TABLE,
@@ -9867,16 +10004,17 @@ const Details = ({
9867
10004
  children: [
9868
10005
  /* @__PURE__ */ jsxs('summary', {
9869
10006
  children: [
9870
- summary,
10007
+ /* @__PURE__ */ jsx('span', {children: title}),
9871
10008
  handleEditable
9872
10009
  ? /* @__PURE__ */ jsx('img', {
9873
10010
  onClick: handleEditable,
9874
10011
  className: editable ? 'done' : 'edit',
10012
+ title: editable ? 'Done editing' : 'Edit',
9875
10013
  })
9876
10014
  : null,
9877
10015
  ],
9878
10016
  }),
9879
- children,
10017
+ /* @__PURE__ */ jsx('div', {children}),
9880
10018
  ],
9881
10019
  });
9882
10020
  };
@@ -9884,7 +10022,7 @@ const Details = ({
9884
10022
  const IndexView = ({indexes, indexesId, indexId, s}) =>
9885
10023
  /* @__PURE__ */ jsx(Details, {
9886
10024
  uniqueId: getUniqueId('i', indexesId, indexId),
9887
- summary: 'Index: ' + indexId,
10025
+ title: 'Index: ' + indexId,
9888
10026
  s,
9889
10027
  children: arrayMap(useSliceIds(indexId, indexes), (sliceId) =>
9890
10028
  /* @__PURE__ */ jsx(
@@ -9905,7 +10043,7 @@ const SliceView = ({indexes, indexesId, indexId, sliceId, s}) => {
9905
10043
  const [editable, handleEditable] = useEditable(uniqueId, s);
9906
10044
  return /* @__PURE__ */ jsx(Details, {
9907
10045
  uniqueId,
9908
- summary: 'Slice: ' + sliceId,
10046
+ title: 'Slice: ' + sliceId,
9909
10047
  editable,
9910
10048
  handleEditable,
9911
10049
  s,
@@ -9924,7 +10062,7 @@ const IndexesView = ({indexesId, s}) => {
9924
10062
  ? null
9925
10063
  : /* @__PURE__ */ jsx(Details, {
9926
10064
  uniqueId: getUniqueId('i', indexesId),
9927
- summary: 'Indexes: ' + (indexesId ?? DEFAULT),
10065
+ title: 'Indexes: ' + (indexesId ?? DEFAULT),
9928
10066
  s,
9929
10067
  children: arrayIsEmpty(indexIds)
9930
10068
  ? 'No indexes defined'
@@ -9946,7 +10084,7 @@ const IndexesView = ({indexesId, s}) => {
9946
10084
  const MetricRow = ({metrics, metricId}) =>
9947
10085
  /* @__PURE__ */ jsxs('tr', {
9948
10086
  children: [
9949
- /* @__PURE__ */ jsx('th', {children: metricId}),
10087
+ /* @__PURE__ */ jsx('th', {title: metricId, children: metricId}),
9950
10088
  /* @__PURE__ */ jsx('td', {children: metrics?.getTableId(metricId)}),
9951
10089
  /* @__PURE__ */ jsx('td', {children: useMetric(metricId, metrics)}),
9952
10090
  ],
@@ -9958,7 +10096,7 @@ const MetricsView = ({metricsId, s}) => {
9958
10096
  ? null
9959
10097
  : /* @__PURE__ */ jsx(Details, {
9960
10098
  uniqueId: getUniqueId('m', metricsId),
9961
- summary: 'Metrics: ' + (metricsId ?? DEFAULT),
10099
+ title: 'Metrics: ' + (metricsId ?? DEFAULT),
9962
10100
  s,
9963
10101
  children: arrayIsEmpty(metricIds)
9964
10102
  ? 'No metrics defined'
@@ -10000,7 +10138,7 @@ const QueryView = ({queries, queriesId, queryId, s}) => {
10000
10138
  );
10001
10139
  return /* @__PURE__ */ jsx(Details, {
10002
10140
  uniqueId,
10003
- summary: 'Query: ' + queryId,
10141
+ title: 'Query: ' + queryId,
10004
10142
  s,
10005
10143
  children: /* @__PURE__ */ jsx(ResultSortedTableInHtmlTable, {
10006
10144
  queryId,
@@ -10022,7 +10160,7 @@ const QueriesView = ({queriesId, s}) => {
10022
10160
  ? null
10023
10161
  : /* @__PURE__ */ jsx(Details, {
10024
10162
  uniqueId: getUniqueId('q', queriesId),
10025
- summary: 'Queries: ' + (queriesId ?? DEFAULT),
10163
+ title: 'Queries: ' + (queriesId ?? DEFAULT),
10026
10164
  s,
10027
10165
  children: arrayIsEmpty(queryIds)
10028
10166
  ? 'No queries defined'
@@ -10051,7 +10189,7 @@ const RelationshipView = ({
10051
10189
  const [editable, handleEditable] = useEditable(uniqueId, s);
10052
10190
  return /* @__PURE__ */ jsx(Details, {
10053
10191
  uniqueId,
10054
- summary: 'Relationship: ' + relationshipId,
10192
+ title: 'Relationship: ' + relationshipId,
10055
10193
  editable,
10056
10194
  handleEditable,
10057
10195
  s,
@@ -10069,7 +10207,7 @@ const RelationshipsView = ({relationshipsId, s}) => {
10069
10207
  ? null
10070
10208
  : /* @__PURE__ */ jsx(Details, {
10071
10209
  uniqueId: getUniqueId('r', relationshipsId),
10072
- summary: 'Relationships: ' + (relationshipsId ?? DEFAULT),
10210
+ title: 'Relationships: ' + (relationshipsId ?? DEFAULT),
10073
10211
  s,
10074
10212
  children: arrayIsEmpty(relationshipIds)
10075
10213
  ? 'No relationships defined'
@@ -10088,6 +10226,312 @@ const RelationshipsView = ({relationshipsId, s}) => {
10088
10226
  });
10089
10227
  };
10090
10228
 
10229
+ const getNewIdFromSuggestedId = (suggestedId, has) => {
10230
+ let newId;
10231
+ let suffix = 0;
10232
+ while (
10233
+ has(
10234
+ (newId =
10235
+ suggestedId +
10236
+ (suffix > 0 ? ' (copy' + (suffix > 1 ? ' ' + suffix : '') + ')' : '')),
10237
+ )
10238
+ ) {
10239
+ suffix++;
10240
+ }
10241
+ return newId;
10242
+ };
10243
+ const ConfirmableActions = ({actions, ...props}) => {
10244
+ const [confirming, setConfirming] = useState();
10245
+ const handleDone = useCallback(() => setConfirming(null), []);
10246
+ useEffect(() => {
10247
+ if (confirming != null) {
10248
+ const handleKeyDown = (e) => {
10249
+ if (confirming != null && e.key === 'Escape') {
10250
+ e.preventDefault();
10251
+ handleDone();
10252
+ }
10253
+ };
10254
+ document.addEventListener('keydown', handleKeyDown);
10255
+ return () => document.removeEventListener('keydown', handleKeyDown);
10256
+ }
10257
+ }, [confirming, handleDone]);
10258
+ if (confirming != null) {
10259
+ const [, , Component] = actions[confirming];
10260
+ return /* @__PURE__ */ jsxs(Fragment, {
10261
+ children: [
10262
+ /* @__PURE__ */ jsx(Component, {onDone: handleDone, ...props}),
10263
+ /* @__PURE__ */ jsx('img', {
10264
+ onClick: handleDone,
10265
+ title: 'Cancel',
10266
+ className: 'cancel',
10267
+ }),
10268
+ ],
10269
+ });
10270
+ } else {
10271
+ return actions.map(([icon, title], index) =>
10272
+ /* @__PURE__ */ jsx(
10273
+ 'img',
10274
+ {
10275
+ title,
10276
+ className: icon,
10277
+ onClick: () => setConfirming(index),
10278
+ },
10279
+ index,
10280
+ ),
10281
+ );
10282
+ }
10283
+ };
10284
+ const NewId = ({onDone, suggestedId, has, set, prompt = 'New Id'}) => {
10285
+ const [newId, setNewId] = useState(suggestedId);
10286
+ const [newIdOk, setNewIdOk] = useState(true);
10287
+ const [previousSuggestedId, setPreviousSuggestedNewId] =
10288
+ useState(suggestedId);
10289
+ const handleNewIdChange = (e) => {
10290
+ setNewId(e.target.value);
10291
+ setNewIdOk(!has(e.target.value));
10292
+ };
10293
+ const handleClick = useCallback(() => {
10294
+ if (has(newId)) {
10295
+ setNewIdOk(false);
10296
+ } else {
10297
+ set(newId);
10298
+ onDone();
10299
+ }
10300
+ }, [onDone, setNewIdOk, has, set, newId]);
10301
+ const handleKeyDown = useCallback(
10302
+ (e) => {
10303
+ if (e.key === 'Enter') {
10304
+ e.preventDefault();
10305
+ handleClick();
10306
+ }
10307
+ },
10308
+ [handleClick],
10309
+ );
10310
+ if (suggestedId != previousSuggestedId) {
10311
+ setNewId(suggestedId);
10312
+ setPreviousSuggestedNewId(suggestedId);
10313
+ }
10314
+ return /* @__PURE__ */ jsxs(Fragment, {
10315
+ children: [
10316
+ prompt + ': ',
10317
+ /* @__PURE__ */ jsx('input', {
10318
+ type: 'text',
10319
+ value: newId,
10320
+ onChange: handleNewIdChange,
10321
+ onKeyDown: handleKeyDown,
10322
+ autoFocus: true,
10323
+ }),
10324
+ ' ',
10325
+ /* @__PURE__ */ jsx('img', {
10326
+ onClick: handleClick,
10327
+ title: newIdOk ? 'Confirm' : 'Id already exists',
10328
+ className: newIdOk ? 'ok' : 'okDis',
10329
+ }),
10330
+ ],
10331
+ });
10332
+ };
10333
+ const Delete = ({onClick, prompt = 'Delete'}) => {
10334
+ const handleKeyDown = useCallback(
10335
+ (e) => {
10336
+ if (e.key === 'Enter') {
10337
+ e.preventDefault();
10338
+ onClick();
10339
+ }
10340
+ },
10341
+ [onClick],
10342
+ );
10343
+ useEffect(() => {
10344
+ document.addEventListener('keydown', handleKeyDown);
10345
+ return () => document.removeEventListener('keydown', handleKeyDown);
10346
+ }, [handleKeyDown]);
10347
+ return /* @__PURE__ */ jsxs(Fragment, {
10348
+ children: [
10349
+ prompt,
10350
+ '? ',
10351
+ /* @__PURE__ */ jsx('img', {onClick, title: 'Confirm', className: 'ok'}),
10352
+ ],
10353
+ });
10354
+ };
10355
+ const Actions = ({left, right}) =>
10356
+ /* @__PURE__ */ jsxs('div', {
10357
+ className: 'actions',
10358
+ children: [
10359
+ /* @__PURE__ */ jsx('div', {children: left}),
10360
+ /* @__PURE__ */ jsx('div', {children: right}),
10361
+ ],
10362
+ });
10363
+
10364
+ const useHasTableCallback = (storeOrStoreId) => {
10365
+ const store = useStoreOrStoreById(storeOrStoreId);
10366
+ return useCallback((tableId) => store?.hasTable(tableId) ?? false, [store]);
10367
+ };
10368
+ const AddTable = ({onDone, store}) => {
10369
+ const has = useHasTableCallback(store);
10370
+ return /* @__PURE__ */ jsx(NewId, {
10371
+ onDone,
10372
+ suggestedId: getNewIdFromSuggestedId('table', has),
10373
+ has,
10374
+ set: useSetTableCallback(
10375
+ (newId) => newId,
10376
+ () => ({row: {cell: ''}}),
10377
+ [],
10378
+ store,
10379
+ ),
10380
+ prompt: 'Add table',
10381
+ });
10382
+ };
10383
+ const DeleteTables = ({onDone, store}) =>
10384
+ /* @__PURE__ */ jsx(Delete, {
10385
+ onClick: useDelTablesCallback(store, onDone),
10386
+ prompt: 'Delete all tables',
10387
+ });
10388
+ const TablesActions = ({store}) =>
10389
+ /* @__PURE__ */ jsx(Actions, {
10390
+ left: /* @__PURE__ */ jsx(ConfirmableActions, {
10391
+ actions: [['add', 'Add table', AddTable]],
10392
+ store,
10393
+ }),
10394
+ right: useHasTables(store)
10395
+ ? /* @__PURE__ */ jsx(ConfirmableActions, {
10396
+ actions: [['delete', 'Delete all tables', DeleteTables]],
10397
+ store,
10398
+ })
10399
+ : null,
10400
+ });
10401
+ const AddRow = ({onDone, tableId, store}) => {
10402
+ const has = useHasRowCallback(store, tableId);
10403
+ return /* @__PURE__ */ jsx(NewId, {
10404
+ onDone,
10405
+ suggestedId: getNewIdFromSuggestedId('row', has),
10406
+ has,
10407
+ set: useSetRowCallback(
10408
+ tableId,
10409
+ (newId) => newId,
10410
+ (_, store2) =>
10411
+ objNew(
10412
+ arrayMap(store2.getTableCellIds(tableId), (cellId) => [cellId, '']),
10413
+ ),
10414
+ ),
10415
+ prompt: 'Add row',
10416
+ });
10417
+ };
10418
+ const CloneTable = ({onDone, tableId, store: storeOrStoreId}) => {
10419
+ const store = useStoreOrStoreById(storeOrStoreId);
10420
+ const has = useHasTableCallback(store);
10421
+ return /* @__PURE__ */ jsx(NewId, {
10422
+ onDone,
10423
+ suggestedId: getNewIdFromSuggestedId(tableId, has),
10424
+ has,
10425
+ set: useSetTableCallback(
10426
+ (tableId2) => tableId2,
10427
+ (_, store2) => store2.getTable(tableId),
10428
+ ),
10429
+ prompt: 'Clone table to',
10430
+ });
10431
+ };
10432
+ const DeleteTable = ({onDone, tableId, store}) =>
10433
+ /* @__PURE__ */ jsx(Delete, {
10434
+ onClick: useDelTableCallback(tableId, store, onDone),
10435
+ prompt: 'Delete table',
10436
+ });
10437
+ const TableActions1 = ({tableId, store}) =>
10438
+ /* @__PURE__ */ jsx(ConfirmableActions, {
10439
+ actions: [['add', 'Add row', AddRow]],
10440
+ store,
10441
+ tableId,
10442
+ });
10443
+ const TableActions2 = ({tableId, store}) =>
10444
+ /* @__PURE__ */ jsx(ConfirmableActions, {
10445
+ actions: [
10446
+ ['clone', 'Clone table', CloneTable],
10447
+ ['delete', 'Delete table', DeleteTable],
10448
+ ],
10449
+ store,
10450
+ tableId,
10451
+ });
10452
+ const useHasRowCallback = (storeOrStoreId, tableId) => {
10453
+ const store = useStoreOrStoreById(storeOrStoreId);
10454
+ return useCallback(
10455
+ (rowId) => store?.hasRow(tableId, rowId) ?? false,
10456
+ [store, tableId],
10457
+ );
10458
+ };
10459
+ const AddCell = ({onDone, tableId, rowId, store: storeOrStoreId}) => {
10460
+ const store = useStoreOrStoreById(storeOrStoreId);
10461
+ const has = useCallback(
10462
+ (cellId) => store.hasCell(tableId, rowId, cellId),
10463
+ [store, tableId, rowId],
10464
+ );
10465
+ return /* @__PURE__ */ jsx(NewId, {
10466
+ onDone,
10467
+ suggestedId: getNewIdFromSuggestedId('cell', has),
10468
+ has,
10469
+ set: useSetCellCallback(
10470
+ tableId,
10471
+ rowId,
10472
+ (newId) => newId,
10473
+ () => '',
10474
+ [],
10475
+ store,
10476
+ ),
10477
+ prompt: 'Add cell',
10478
+ });
10479
+ };
10480
+ const CloneRow = ({onDone, tableId, rowId, store: storeOrStoreId}) => {
10481
+ const store = useStoreOrStoreById(storeOrStoreId);
10482
+ const has = useHasRowCallback(store, tableId);
10483
+ return /* @__PURE__ */ jsx(NewId, {
10484
+ onDone,
10485
+ suggestedId: getNewIdFromSuggestedId(rowId, has),
10486
+ has,
10487
+ set: useSetRowCallback(
10488
+ tableId,
10489
+ (newId) => newId,
10490
+ (_, store2) => store2.getRow(tableId, rowId),
10491
+ [rowId],
10492
+ ),
10493
+ prompt: 'Clone row to',
10494
+ });
10495
+ };
10496
+ const DeleteRow = ({onDone, tableId, rowId, store}) =>
10497
+ /* @__PURE__ */ jsx(Delete, {
10498
+ onClick: useDelRowCallback(tableId, rowId, store, onDone),
10499
+ prompt: 'Delete row',
10500
+ });
10501
+ const RowActions = ({tableId, rowId, store}) =>
10502
+ /* @__PURE__ */ jsx(ConfirmableActions, {
10503
+ actions: [
10504
+ ['add', 'Add cell', AddCell],
10505
+ ['clone', 'Clone row', CloneRow],
10506
+ ['delete', 'Delete row', DeleteRow],
10507
+ ],
10508
+ store,
10509
+ tableId,
10510
+ rowId,
10511
+ });
10512
+ const CellDelete = ({onDone, tableId, rowId, cellId, store}) =>
10513
+ /* @__PURE__ */ jsx(Delete, {
10514
+ onClick: useDelCellCallback(tableId, rowId, cellId, true, store, onDone),
10515
+ prompt: 'Delete cell',
10516
+ });
10517
+ const CellActions = ({tableId, rowId, cellId, store}) =>
10518
+ /* @__PURE__ */ jsx(ConfirmableActions, {
10519
+ actions: [['delete', 'Delete cell', CellDelete]],
10520
+ store,
10521
+ tableId,
10522
+ rowId,
10523
+ cellId,
10524
+ });
10525
+
10526
+ const rowActions = [{label: '', component: RowActions}];
10527
+ const EditableCellViewWithActions = (props) =>
10528
+ /* @__PURE__ */ jsxs(Fragment, {
10529
+ children: [
10530
+ /* @__PURE__ */ jsx(EditableCellView, {...props}),
10531
+ useHasCell(props.tableId, props.rowId, props.cellId, props.store) &&
10532
+ /* @__PURE__ */ jsx(CellActions, {...props}),
10533
+ ],
10534
+ });
10091
10535
  const TableView = ({tableId, store, storeId, s}) => {
10092
10536
  const uniqueId = getUniqueId('t', storeId, tableId);
10093
10537
  const [cellId, descending, offset] = jsonParse(
@@ -10102,66 +10546,183 @@ const TableView = ({tableId, store, storeId, s}) => {
10102
10546
  s,
10103
10547
  );
10104
10548
  const [editable, handleEditable] = useEditable(uniqueId, s);
10105
- return /* @__PURE__ */ jsx(Details, {
10549
+ const CellComponent = editable ? EditableCellViewWithActions : CellView;
10550
+ return /* @__PURE__ */ jsxs(Details, {
10106
10551
  uniqueId,
10107
- summary: TABLE$1 + ': ' + tableId,
10552
+ title: TABLE$1 + ': ' + tableId,
10108
10553
  editable,
10109
10554
  handleEditable,
10110
10555
  s,
10111
- children: /* @__PURE__ */ jsx(SortedTableInHtmlTable, {
10112
- tableId,
10556
+ children: [
10557
+ /* @__PURE__ */ jsx(SortedTableInHtmlTable, {
10558
+ tableId,
10559
+ store,
10560
+ cellId,
10561
+ descending,
10562
+ offset,
10563
+ limit: 10,
10564
+ paginator: true,
10565
+ sortOnClick: true,
10566
+ onChange: handleChange,
10567
+ editable,
10568
+ extraCellsAfter: editable ? rowActions : [],
10569
+ customCells: objNew(
10570
+ arrayMap(useTableCellIds(tableId, store), (cellId2) => [
10571
+ cellId2,
10572
+ {label: cellId2, component: CellComponent},
10573
+ ]),
10574
+ ),
10575
+ }),
10576
+ editable
10577
+ ? /* @__PURE__ */ jsxs('div', {
10578
+ className: 'actions',
10579
+ children: [
10580
+ /* @__PURE__ */ jsx('div', {
10581
+ children: /* @__PURE__ */ jsx(TableActions1, {tableId, store}),
10582
+ }),
10583
+ /* @__PURE__ */ jsx('div', {
10584
+ children: /* @__PURE__ */ jsx(TableActions2, {tableId, store}),
10585
+ }),
10586
+ ],
10587
+ })
10588
+ : null,
10589
+ ],
10590
+ });
10591
+ };
10592
+ const TablesView = ({store, storeId, s}) => {
10593
+ const uniqueId = getUniqueId('ts', storeId);
10594
+ const [editable, handleEditable] = useEditable(uniqueId, s);
10595
+ const tableIds = useTableIds(store);
10596
+ return /* @__PURE__ */ jsxs(Details, {
10597
+ uniqueId,
10598
+ title: TABLES,
10599
+ editable,
10600
+ handleEditable,
10601
+ s,
10602
+ children: [
10603
+ arrayIsEmpty(tableIds)
10604
+ ? /* @__PURE__ */ jsx('caption', {children: 'No tables.'})
10605
+ : sortedIdsMap(tableIds, (tableId) =>
10606
+ /* @__PURE__ */ jsx(
10607
+ TableView,
10608
+ {
10609
+ store,
10610
+ storeId,
10611
+ tableId,
10612
+ s,
10613
+ },
10614
+ tableId,
10615
+ ),
10616
+ ),
10617
+ editable ? /* @__PURE__ */ jsx(TablesActions, {store}) : null,
10618
+ ],
10619
+ });
10620
+ };
10621
+
10622
+ const useHasValueCallback = (storeOrStoreId) => {
10623
+ const store = useStoreOrStoreById(storeOrStoreId);
10624
+ return useCallback((valueId) => store?.hasValue(valueId) ?? false, [store]);
10625
+ };
10626
+ const AddValue = ({onDone, store}) => {
10627
+ const has = useHasValueCallback(store);
10628
+ return /* @__PURE__ */ jsx(NewId, {
10629
+ onDone,
10630
+ suggestedId: getNewIdFromSuggestedId('value', has),
10631
+ has,
10632
+ set: useSetValueCallback(
10633
+ (newId) => newId,
10634
+ () => '',
10635
+ [],
10636
+ store,
10637
+ ),
10638
+ prompt: 'Add value',
10639
+ });
10640
+ };
10641
+ const DeleteValues = ({onDone, store}) =>
10642
+ /* @__PURE__ */ jsx(Delete, {
10643
+ onClick: useDelValuesCallback(store, onDone),
10644
+ prompt: 'Delete all values',
10645
+ });
10646
+ const ValuesActions = ({store}) =>
10647
+ /* @__PURE__ */ jsx(Actions, {
10648
+ left: /* @__PURE__ */ jsx(ConfirmableActions, {
10649
+ actions: [['add', 'Add value', AddValue]],
10113
10650
  store,
10114
- cellId,
10115
- descending,
10116
- offset,
10117
- limit: 10,
10118
- paginator: true,
10119
- sortOnClick: true,
10120
- onChange: handleChange,
10121
- editable,
10122
10651
  }),
10652
+ right: useHasValues(store)
10653
+ ? /* @__PURE__ */ jsx(ConfirmableActions, {
10654
+ actions: [['delete', 'Delete all values', DeleteValues]],
10655
+ store,
10656
+ })
10657
+ : null,
10658
+ });
10659
+ const CloneValue = ({onDone, valueId, store}) => {
10660
+ const has = useHasValueCallback(store);
10661
+ return /* @__PURE__ */ jsx(NewId, {
10662
+ onDone,
10663
+ suggestedId: getNewIdFromSuggestedId(valueId, has),
10664
+ has,
10665
+ set: useSetValueCallback(
10666
+ (newId) => newId,
10667
+ (_, store2) => store2.getValue(valueId) ?? '',
10668
+ [valueId],
10669
+ store,
10670
+ ),
10671
+ prompt: 'Clone value to',
10123
10672
  });
10124
10673
  };
10674
+ const DeleteValue = ({onDone, valueId, store}) =>
10675
+ /* @__PURE__ */ jsx(Delete, {
10676
+ onClick: useDelValueCallback(valueId, store, onDone),
10677
+ prompt: 'Delete value',
10678
+ });
10679
+ const ValueActions = ({valueId, store}) =>
10680
+ /* @__PURE__ */ jsx(ConfirmableActions, {
10681
+ actions: [
10682
+ ['clone', 'Clone value', CloneValue],
10683
+ ['delete', 'Delete value', DeleteValue],
10684
+ ],
10685
+ store,
10686
+ valueId,
10687
+ });
10688
+
10689
+ const valueActions = [{label: '', component: ValueActions}];
10125
10690
  const ValuesView = ({store, storeId, s}) => {
10126
10691
  const uniqueId = getUniqueId('v', storeId);
10127
10692
  const [editable, handleEditable] = useEditable(uniqueId, s);
10128
- return arrayIsEmpty(useValueIds(store))
10129
- ? null
10130
- : /* @__PURE__ */ jsx(Details, {
10131
- uniqueId,
10132
- summary: VALUES,
10133
- editable,
10134
- handleEditable,
10135
- s,
10136
- children: /* @__PURE__ */ jsx(ValuesInHtmlTable, {store, editable}),
10137
- });
10693
+ return /* @__PURE__ */ jsxs(Details, {
10694
+ uniqueId,
10695
+ title: VALUES,
10696
+ editable,
10697
+ handleEditable,
10698
+ s,
10699
+ children: [
10700
+ arrayIsEmpty(useValueIds(store))
10701
+ ? /* @__PURE__ */ jsx('caption', {children: 'No values.'})
10702
+ : /* @__PURE__ */ jsx(ValuesInHtmlTable, {
10703
+ store,
10704
+ editable,
10705
+ extraCellsAfter: editable ? valueActions : [],
10706
+ }),
10707
+ editable ? /* @__PURE__ */ jsx(ValuesActions, {store}) : null,
10708
+ ],
10709
+ });
10138
10710
  };
10711
+
10139
10712
  const StoreView = ({storeId, s}) => {
10140
10713
  const store = useStore(storeId);
10141
- const tableIds = useTableIds(store);
10142
10714
  return isUndefined(store)
10143
10715
  ? null
10144
10716
  : /* @__PURE__ */ jsxs(Details, {
10145
10717
  uniqueId: getUniqueId('s', storeId),
10146
- summary:
10718
+ title:
10147
10719
  (store.isMergeable() ? 'Mergeable' : '') +
10148
10720
  'Store: ' +
10149
10721
  (storeId ?? DEFAULT),
10150
10722
  s,
10151
10723
  children: [
10152
10724
  /* @__PURE__ */ jsx(ValuesView, {storeId, store, s}),
10153
- sortedIdsMap(tableIds, (tableId) =>
10154
- /* @__PURE__ */ jsx(
10155
- TableView,
10156
- {
10157
- store,
10158
- storeId,
10159
- tableId,
10160
- s,
10161
- },
10162
- tableId,
10163
- ),
10164
- ),
10725
+ /* @__PURE__ */ jsx(TablesView, {storeId, store, s}),
10165
10726
  ],
10166
10727
  });
10167
10728
  };
@@ -10282,6 +10843,7 @@ class ErrorBoundary extends PureComponent {
10282
10843
 
10283
10844
  const Header = ({s}) => {
10284
10845
  const position = useValue(POSITION_VALUE, s) ?? 1;
10846
+ const handleClick = () => open('https://tinybase.org', '_blank');
10285
10847
  const handleClose = useSetValueCallback(OPEN_VALUE, () => false, [], s);
10286
10848
  const handleDock = useSetValueCallback(
10287
10849
  POSITION_VALUE,
@@ -10291,7 +10853,11 @@ const Header = ({s}) => {
10291
10853
  );
10292
10854
  return /* @__PURE__ */ jsxs('header', {
10293
10855
  children: [
10294
- /* @__PURE__ */ jsx('img', {title: TITLE}),
10856
+ /* @__PURE__ */ jsx('img', {
10857
+ className: 'flat',
10858
+ title: TITLE,
10859
+ onClick: handleClick,
10860
+ }),
10295
10861
  /* @__PURE__ */ jsx('span', {children: TITLE}),
10296
10862
  arrayMap(POSITIONS, (name, p) =>
10297
10863
  p == position
@@ -10306,7 +10872,11 @@ const Header = ({s}) => {
10306
10872
  p,
10307
10873
  ),
10308
10874
  ),
10309
- /* @__PURE__ */ jsx('img', {onClick: handleClose, title: 'Close'}),
10875
+ /* @__PURE__ */ jsx('img', {
10876
+ className: 'flat',
10877
+ onClick: handleClose,
10878
+ title: 'Close',
10879
+ }),
10310
10880
  ],
10311
10881
  });
10312
10882
  };
@@ -10329,70 +10899,237 @@ const Panel = ({s}) => {
10329
10899
  var img =
10330
10900
  "data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e";
10331
10901
 
10332
- const PENCIL = 'M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10';
10333
- const PRE_CSS = 'content:url("';
10902
+ const PRE_CSS = 'url("';
10334
10903
  const POST_CSS = '")';
10335
- const PRE =
10336
- PRE_CSS +
10337
- `data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>`;
10338
- const POST = `</svg>` + POST_CSS;
10339
- const LOGO_SVG = PRE_CSS + img + POST_CSS;
10904
+ const getCssSvg = (path, color = 'white') => ({
10905
+ content:
10906
+ PRE_CSS +
10907
+ `data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960' fill='${color}'><path d='${path}' /></svg>` +
10908
+ POST_CSS,
10909
+ });
10910
+ const VERTICAL_THIN = 'v560h120v-560h-120Z';
10911
+ const VERTICAL_THICK = 'v560h360v-560h-360Z';
10912
+ const HORIZONTAL_THIN = 'v120h560v-120h-560Z';
10913
+ const HORIZONTAL_THICK = 'v360h560v-360h-560Z';
10914
+ const LOGO_SVG = {content: PRE_CSS + img + POST_CSS};
10340
10915
  const POSITIONS_SVG = arrayMap(
10341
10916
  [
10342
- [20, 20, 20, 60],
10343
- [20, 20, 60, 20],
10344
- [20, 60, 60, 20],
10345
- [60, 20, 20, 60],
10346
- [30, 30, 40, 40],
10917
+ `M200-760${VERTICAL_THIN} M400-760${VERTICAL_THICK}`,
10918
+ `M200-760${HORIZONTAL_THIN} M200-560${HORIZONTAL_THICK}`,
10919
+ `M200-760${HORIZONTAL_THICK} M200-320${HORIZONTAL_THIN}`,
10920
+ `M200-760${VERTICAL_THICK} M640-760${VERTICAL_THIN}`,
10347
10921
  ],
10348
- ([x, y, w, h]) =>
10349
- PRE +
10350
- `<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${x}' y='${y}' width='${w}' height='${h}' fill='white'/>` +
10351
- POST,
10922
+ (path) =>
10923
+ getCssSvg(
10924
+ 'M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z' +
10925
+ path,
10926
+ ),
10927
+ );
10928
+ arrayPush(
10929
+ POSITIONS_SVG,
10930
+ getCssSvg(
10931
+ 'M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z',
10932
+ ),
10933
+ );
10934
+ const CLOSE_SVG = getCssSvg(
10935
+ 'm336-280-56-56 144-144-144-143 56-56 144 144 143-144 56 56-144 143 144 144-56 56-143-144-144 144Z',
10936
+ );
10937
+ const EDIT_SVG = getCssSvg(
10938
+ 'M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z',
10939
+ );
10940
+ const DONE_SVG = getCssSvg(
10941
+ 'm622-453-56-56 82-82-57-57-82 82-56-56 195-195q12-12 26.5-17.5T705-840q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L622-453ZM200-200h57l195-195-28-29-29-28-195 195v57ZM792-56 509-338 290-120H120v-169l219-219L56-792l57-57 736 736-57 57Zm-32-648-56-56 56 56Zm-169 56 57 57-57-57ZM424-424l-29-28 57 57-28-29Z',
10942
+ );
10943
+ const ADD_SVG = getCssSvg(
10944
+ 'M440-280h80v-160h160v-80H520v-160h-80v160H280v80h160v160ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z',
10945
+ );
10946
+ const CLONE_SVG = getCssSvg(
10947
+ 'M520-400h80v-120h120v-80H600v-120h-80v120H400v80h120v120ZM320-240q-33 0-56.5-23.5T240-320v-480q0-33 23.5-56.5T320-880h480q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H320Zm0-80h480v-480H320v480ZM160-80q-33 0-56.5-23.5T80-160v-560h80v560h560v80H160Zm160-720v480-480Z',
10948
+ );
10949
+ const DELETE_SVG = getCssSvg(
10950
+ 'M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z',
10951
+ );
10952
+ const OK_SVG = getCssSvg(
10953
+ 'm424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z',
10954
+ 'rgb(127,255,127)',
10955
+ );
10956
+ const OK_SVG_DISABLED = getCssSvg(
10957
+ 'm40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z',
10958
+ 'rgb(255,255,127)',
10959
+ );
10960
+ const CANCEL_SVG = getCssSvg(
10961
+ 'm336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z',
10962
+ 'rgb(255,127,127)',
10963
+ );
10964
+ const DOWN_SVG = getCssSvg(
10965
+ 'M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z',
10966
+ );
10967
+ const RIGHT_SVG = getCssSvg(
10968
+ 'M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z',
10352
10969
  );
10353
- const CLOSE_SVG = PRE + `<path d='M20 20l60 60M20 80l60-60' />` + POST;
10354
- const EDIT_SVG = PRE + `<path d='${PENCIL}' />` + POST;
10355
- const DONE_SVG = PRE + `<path d='${PENCIL}M20 20l60 60' />` + POST;
10356
10970
 
10357
10971
  const SCROLLBAR = '*::-webkit-scrollbar';
10972
+ const BACKGROUND = 'background';
10973
+ const WIDTH = 'width';
10974
+ const MAX_WIDTH = 'max-' + WIDTH;
10975
+ const MIN_WIDTH = 'min-' + WIDTH;
10976
+ const HEIGHT = 'height';
10977
+ const BORDER = 'border';
10978
+ const BORDER_RADIUS = BORDER + '-radius';
10979
+ const PADDING = 'padding';
10980
+ const MARGIN = 'margin';
10981
+ const MARGIN_RIGHT = MARGIN + '-right';
10982
+ const TOP = 'top';
10983
+ const BOTTOM = 'bottom';
10984
+ const LEFT = 'left';
10985
+ const RIGHT = 'right';
10986
+ const COLOR = 'color';
10987
+ const POSITION = 'position';
10988
+ const BOX_SHADOW = 'box-shadow';
10989
+ const FONT_SIZE = 'font-size';
10990
+ const DISPLAY = 'display';
10991
+ const OVERFLOW = 'overflow';
10992
+ const CURSOR = 'cursor';
10993
+ const VERTICAL_ALIGN = 'vertical-align';
10994
+ const TEXT_ALIGN = 'text-align';
10995
+ const JUSTIFY_CONTENT = 'justify-content';
10996
+ const FIXED = 'fixed';
10997
+ const REVERT = 'revert';
10998
+ const UNSET = 'unset';
10999
+ const NONE = 'none';
11000
+ const FLEX = 'flex';
11001
+ const POINTER = 'pointer';
11002
+ const AUTO = 'auto';
11003
+ const HIDDEN = 'hidden';
11004
+ const NOWRAP = 'nowrap';
11005
+ const oklch = (lPercent, remainder = '% 0.01 ' + cssVar('hue')) =>
11006
+ `oklch(${lPercent}${remainder})`;
11007
+ const cssVar = (name) => `var(--${name})`;
11008
+ const rem = (...rems) => `${rems.join('rem ')}rem`;
11009
+ const px = (...pxs) => `${pxs.join('px ')}px`;
11010
+ const vw = (vw2 = 100) => `${vw2}vw`;
11011
+ const vh = (vh2 = 100) => `${vh2}vh`;
10358
11012
  const APP_STYLESHEET = arrayJoin(
10359
11013
  objToArray(
10360
11014
  {
10361
- '': 'all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999',
10362
- '*': 'all:revert',
10363
- '*::before': 'all:revert',
10364
- '*::after': 'all:revert',
10365
- [SCROLLBAR]: 'width:0.5rem;height:0.5rem;',
10366
- [SCROLLBAR + '-track']: 'background:#111',
10367
- [SCROLLBAR + '-thumb']: 'background:#999;border:1px solid #111',
10368
- [SCROLLBAR + '-thumb:hover']: 'background:#fff',
10369
- [SCROLLBAR + '-corner']: 'background:#111',
10370
- img: 'width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom',
11015
+ '': {
11016
+ all: 'initial',
11017
+ [FONT_SIZE]: rem(0.75),
11018
+ [POSITION]: FIXED,
11019
+ 'font-family': 'inter,sans-serif',
11020
+ 'z-index': 999999,
11021
+ '--bg': oklch(20),
11022
+ '--bg2': oklch(15),
11023
+ '--bg3': oklch(25),
11024
+ '--bg4': oklch(30),
11025
+ '--fg': oklch(85),
11026
+ '--fg2': oklch(60),
11027
+ ['--' + BORDER]: px(1) + ' solid ' + cssVar('bg4'),
11028
+ ['--' + BOX_SHADOW]: px(0, 1, 2, 0) + ' #0007',
11029
+ },
11030
+ '*': {all: REVERT},
11031
+ '*::before': {all: REVERT},
11032
+ '*::after': {all: REVERT},
11033
+ [SCROLLBAR]: {[WIDTH]: rem(0.5), [HEIGHT]: rem(0.5)},
11034
+ [SCROLLBAR + '-thumb']: {[BACKGROUND]: cssVar('bg4')},
11035
+ [SCROLLBAR + '-thumb:hover']: {[BACKGROUND]: cssVar('bg4')},
11036
+ [SCROLLBAR + '-corner']: {[BACKGROUND]: NONE},
11037
+ [SCROLLBAR + '-track']: {[BACKGROUND]: NONE},
11038
+ img: {
11039
+ [WIDTH]: rem(0.8),
11040
+ [HEIGHT]: rem(0.8),
11041
+ [VERTICAL_ALIGN]: 'text-' + BOTTOM,
11042
+ [CURSOR]: POINTER,
11043
+ [MARGIN]: px(-2.5, 2, -2.5, 0),
11044
+ [PADDING]: px(2),
11045
+ [BORDER]: cssVar(BORDER),
11046
+ [BACKGROUND]: cssVar('bg3'),
11047
+ [BOX_SHADOW]: cssVar(BOX_SHADOW),
11048
+ [BORDER_RADIUS]: rem(0.25),
11049
+ },
11050
+ 'img.flat': {[BORDER]: NONE, [BACKGROUND]: NONE, [BOX_SHADOW]: NONE},
10371
11051
  // Nub
10372
- '>img': 'padding:0.25rem;bottom:0;right:0;position:fixed;' + LOGO_SVG,
11052
+ '>img': {
11053
+ [PADDING]: rem(0.25),
11054
+ [BOTTOM]: 0,
11055
+ [RIGHT]: 0,
11056
+ [POSITION]: FIXED,
11057
+ [HEIGHT]: UNSET,
11058
+ [MARGIN]: 0,
11059
+ ...LOGO_SVG,
11060
+ },
10373
11061
  ...objNew(
10374
- arrayMap(['bottom:0;left:0', 'top:0;right:0'], (css, p) => [
10375
- `>img[data-position='${p}']`,
10376
- css,
10377
- ]),
11062
+ arrayMap(
11063
+ [
11064
+ {[BOTTOM]: 0, [LEFT]: 0},
11065
+ {[TOP]: 0, [RIGHT]: 0},
11066
+ ],
11067
+ (css, p) => [`>img[data-position='${p}']`, css],
11068
+ ),
10378
11069
  ),
10379
11070
  // Panel
10380
- main: 'display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;',
11071
+ main: {
11072
+ [DISPLAY]: FLEX,
11073
+ [COLOR]: cssVar('fg'),
11074
+ [BACKGROUND]: cssVar('bg'),
11075
+ [OVERFLOW]: HIDDEN,
11076
+ [POSITION]: FIXED,
11077
+ [BOX_SHADOW]: cssVar(BOX_SHADOW),
11078
+ 'flex-direction': 'column',
11079
+ },
10381
11080
  ...objNew(
10382
11081
  arrayMap(
10383
11082
  [
10384
- 'bottom:0;left:0;width:35vw;height:100vh',
10385
- 'top:0;right:0;width:100vw;height:30vh',
10386
- 'bottom:0;left:0;width:100vw;height:30vh',
10387
- 'top:0;right:0;width:35vw;height:100vh',
10388
- 'top:0;right:0;width:100vw;height:100vh',
11083
+ {
11084
+ [BOTTOM]: 0,
11085
+ [LEFT]: 0,
11086
+ [WIDTH]: vw(35),
11087
+ [HEIGHT]: vh(),
11088
+ [BORDER + '-' + RIGHT]: cssVar(BORDER),
11089
+ },
11090
+ {
11091
+ [TOP]: 0,
11092
+ [RIGHT]: 0,
11093
+ [WIDTH]: vw(),
11094
+ [HEIGHT]: vh(30),
11095
+ [BORDER + '-' + BOTTOM]: cssVar(BORDER),
11096
+ },
11097
+ {
11098
+ [BOTTOM]: 0,
11099
+ [LEFT]: 0,
11100
+ [WIDTH]: vw(),
11101
+ [HEIGHT]: vh(30),
11102
+ [BORDER + '-' + TOP]: cssVar(BORDER),
11103
+ },
11104
+ {
11105
+ [TOP]: 0,
11106
+ [RIGHT]: 0,
11107
+ [WIDTH]: vw(35),
11108
+ [HEIGHT]: vh(),
11109
+ [BORDER + '-' + LEFT]: cssVar(BORDER),
11110
+ },
11111
+ {[TOP]: 0, [RIGHT]: 0, [WIDTH]: vw(), [HEIGHT]: vh()},
10389
11112
  ],
10390
11113
  (css, p) => [`main[data-position='${p}']`, css],
10391
11114
  ),
10392
11115
  ),
10393
11116
  // Header
10394
- header: 'display:flex;padding:0.25rem;background:#000;align-items:center',
10395
- 'header>img:nth-of-type(1)': LOGO_SVG,
11117
+ header: {
11118
+ [DISPLAY]: FLEX,
11119
+ [PADDING]: rem(0.5),
11120
+ [BOX_SHADOW]: cssVar(BOX_SHADOW),
11121
+ [BACKGROUND]: oklch(30, '% 0.008 var(--hue) / .5'),
11122
+ [WIDTH]: 'calc(100% - .5rem)',
11123
+ [POSITION]: 'absolute',
11124
+ [BORDER + '-' + BOTTOM]: cssVar(BORDER),
11125
+ 'align-items': 'center',
11126
+ 'backdrop-filter': 'blur(4px)',
11127
+ },
11128
+ 'header>img:nth-of-type(1)': {
11129
+ [HEIGHT]: rem(1),
11130
+ [WIDTH]: rem(1),
11131
+ ...LOGO_SVG,
11132
+ },
10396
11133
  'header>img:nth-of-type(6)': CLOSE_SVG,
10397
11134
  ...objNew(
10398
11135
  arrayMap(POSITIONS_SVG, (SVG, p) => [
@@ -10400,42 +11137,140 @@ const APP_STYLESHEET = arrayJoin(
10400
11137
  SVG,
10401
11138
  ]),
10402
11139
  ),
10403
- 'header>span':
10404
- 'flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem',
11140
+ 'header>span': {
11141
+ [OVERFLOW]: HIDDEN,
11142
+ [FLEX]: 1,
11143
+ 'font-weight': 800,
11144
+ 'white-space': NOWRAP,
11145
+ 'text-overflow': 'ellipsis',
11146
+ },
10405
11147
  // Body
10406
- article: 'padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1',
10407
- details: 'margin-left:0.75rem;width:fit-content;',
10408
- 'details img': 'display:none',
10409
- 'details[open]>summary img':
10410
- 'display:unset;background:none;margin-left:0.25rem',
10411
- 'details[open]>summary img.edit': EDIT_SVG,
10412
- 'details[open]>summary img.done': DONE_SVG,
10413
- summary:
10414
- 'margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content',
11148
+ article: {[OVERFLOW]: AUTO, [FLEX]: 1, [PADDING + '-' + TOP]: rem(2)},
11149
+ details: {
11150
+ [MARGIN]: rem(0.5),
11151
+ [BORDER]: cssVar(BORDER),
11152
+ [BORDER_RADIUS]: rem(0.25),
11153
+ },
11154
+ summary: {
11155
+ [BACKGROUND]: cssVar('bg3'),
11156
+ [MARGIN]: px(-1),
11157
+ [BORDER]: cssVar(BORDER),
11158
+ [PADDING]: rem(0.25, 0.125),
11159
+ [DISPLAY]: FLEX,
11160
+ [BORDER_RADIUS]: rem(0.25),
11161
+ 'user-select': NONE,
11162
+ [JUSTIFY_CONTENT]: 'space-between',
11163
+ 'align-items': 'center',
11164
+ },
11165
+ 'summary>span::before': {
11166
+ [DISPLAY]: 'inline-block',
11167
+ [VERTICAL_ALIGN]: 'sub',
11168
+ [MARGIN]: px(2),
11169
+ [WIDTH]: rem(1),
11170
+ [HEIGHT]: rem(1),
11171
+ ...RIGHT_SVG,
11172
+ },
11173
+ 'details[open]>summary': {
11174
+ 'border-bottom-left-radius': 0,
11175
+ 'border-bottom-right-radius': 0,
11176
+ [MARGIN + '-' + BOTTOM]: 0,
11177
+ },
11178
+ 'details[open]>summary>span::before': DOWN_SVG,
11179
+ 'details>summary img': {[DISPLAY]: NONE},
11180
+ 'details[open]>summary img': {
11181
+ [DISPLAY]: UNSET,
11182
+ [MARGIN + '-' + LEFT]: rem(0.25),
11183
+ },
11184
+ 'details>div': {[OVERFLOW]: AUTO},
11185
+ caption: {
11186
+ [COLOR]: cssVar('fg2'),
11187
+ [PADDING]: rem(0.25, 0.5),
11188
+ [TEXT_ALIGN]: LEFT,
11189
+ 'white-space': NOWRAP,
11190
+ },
11191
+ 'caption button': {
11192
+ [WIDTH]: rem(1.5),
11193
+ [BORDER]: NONE,
11194
+ [BACKGROUND]: NONE,
11195
+ [COLOR]: cssVar('fg'),
11196
+ [PADDING]: 0,
11197
+ [CURSOR]: POINTER,
11198
+ },
11199
+ 'caption button[disabled]': {[COLOR]: cssVar('fg2')},
11200
+ '.actions': {
11201
+ [PADDING]: rem(0.75, 0.5),
11202
+ [MARGIN]: 0,
11203
+ [DISPLAY]: FLEX,
11204
+ [BORDER + '-' + TOP]: cssVar(BORDER),
11205
+ [JUSTIFY_CONTENT]: 'space-between',
11206
+ },
10415
11207
  // tables
10416
- table: 'border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem',
10417
- 'table input':
10418
- 'background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0',
10419
- 'table input[type="number"]': 'width:4rem',
10420
- 'table tbody button':
10421
- 'font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111',
10422
- 'table button:first-letter': 'font-size:0.75rem',
10423
- thead: 'background:#222',
10424
- 'th:nth-of-type(1)': 'min-width:2rem;',
10425
- 'th.sorted': 'background:#000',
10426
- 'table caption': 'text-align:left;white-space:nowrap;line-height:1.25rem',
10427
- button: 'width:1.5rem;border:none;background:none;color:#fff;padding:0',
10428
- 'button[disabled]': 'color:#777',
10429
- 'button.next': 'margin-right:0.5rem',
10430
- [`th,#${UNIQUE_ID} td`]:
10431
- 'overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left',
10432
- 'span.warn': 'margin:0.25rem;color:#d81b60',
11208
+ table: {
11209
+ [MIN_WIDTH]: '100%',
11210
+ 'border-collapse': 'collapse',
11211
+ 'table-layout': FIXED,
11212
+ },
11213
+ thead: {[BACKGROUND]: cssVar('bg')},
11214
+ [`th,#${UNIQUE_ID} td`]: {
11215
+ [OVERFLOW]: HIDDEN,
11216
+ [PADDING]: rem(0.25, 0.5),
11217
+ [MAX_WIDTH]: rem(20),
11218
+ [BORDER]: cssVar(BORDER),
11219
+ 'text-overflow': 'ellipsis',
11220
+ 'white-space': NOWRAP,
11221
+ 'border-width': px(1, 0, 0),
11222
+ [TEXT_ALIGN]: LEFT,
11223
+ },
11224
+ 'th:first-child': {
11225
+ [WIDTH]: rem(3),
11226
+ [MIN_WIDTH]: rem(3),
11227
+ [MAX_WIDTH]: rem(3),
11228
+ },
11229
+ 'th.sorted': {[BACKGROUND]: cssVar('bg3')},
11230
+ 'td.extra': {[TEXT_ALIGN]: RIGHT},
11231
+ 'tbody button': {
11232
+ [BACKGROUND]: NONE,
11233
+ [BORDER]: NONE,
11234
+ [FONT_SIZE]: 0,
11235
+ [WIDTH]: rem(0.8),
11236
+ [HEIGHT]: rem(0.8),
11237
+ [COLOR]: cssVar('fg2'),
11238
+ [MARGIN]: rem(0, 0.25, 0, -0.25),
11239
+ 'line-height': rem(0.8),
11240
+ },
11241
+ 'tbody button:first-letter': {[FONT_SIZE]: rem(0.8)},
11242
+ input: {
11243
+ [BACKGROUND]: cssVar('bg2'),
11244
+ [COLOR]: UNSET,
11245
+ [PADDING]: px(4),
11246
+ [BORDER]: 0,
11247
+ [MARGIN]: px(-4, 0),
11248
+ [FONT_SIZE]: UNSET,
11249
+ [MAX_WIDTH]: rem(6),
11250
+ },
11251
+ 'input:focus': {'outline-width': 0},
11252
+ 'input[type="number"]': {[WIDTH]: rem(3)},
11253
+ 'input[type="checkbox"]': {[VERTICAL_ALIGN]: px(-2)},
11254
+ '.editableCell': {[DISPLAY]: 'inline-block', [MARGIN_RIGHT]: px(2)},
11255
+ 'button.next': {[MARGIN_RIGHT]: rem(0.5)},
11256
+ 'img.edit': EDIT_SVG,
11257
+ 'img.done': DONE_SVG,
11258
+ 'img.add': ADD_SVG,
11259
+ 'img.clone': CLONE_SVG,
11260
+ 'img.delete': DELETE_SVG,
11261
+ 'img.ok': OK_SVG,
11262
+ 'img.okDis': OK_SVG_DISABLED,
11263
+ 'img.cancel': CANCEL_SVG,
11264
+ 'span.warn': {[MARGIN]: rem(2, 0.25), [COLOR]: '#d81b60'},
10433
11265
  },
10434
- (style, selector) => (style ? `#${UNIQUE_ID} ${selector}{${style}}` : ''),
11266
+ (style, selector) =>
11267
+ `#${UNIQUE_ID} ${selector}{${arrayJoin(
11268
+ objToArray(style, (value, property) => `${property}:${value};`),
11269
+ )}}`,
10435
11270
  ),
10436
11271
  );
10437
11272
 
10438
- const Inspector = ({position = 'right', open = false}) => {
11273
+ const Inspector = ({position = 'right', open = false, hue = 270}) => {
10439
11274
  const s = useCreateStore(createStore);
10440
11275
  const index = POSITIONS.indexOf(position);
10441
11276
  useCreatePersister(
@@ -10462,7 +11297,9 @@ const Inspector = ({position = 'right', open = false}) => {
10462
11297
  /* @__PURE__ */ jsx(Panel, {s}),
10463
11298
  ],
10464
11299
  }),
10465
- /* @__PURE__ */ jsx('style', {children: APP_STYLESHEET}),
11300
+ /* @__PURE__ */ jsxs('style', {
11301
+ children: [`#${UNIQUE_ID}{--hue:${hue}}`, APP_STYLESHEET],
11302
+ }),
10466
11303
  ],
10467
11304
  });
10468
11305
  };
@@ -10538,8 +11375,17 @@ export {
10538
11375
  Message,
10539
11376
  MetricView,
10540
11377
  objectStoreMatch,
11378
+ OFFSET_CHECKPOINTS,
11379
+ OFFSET_INDEXES,
11380
+ OFFSET_METRICS,
11381
+ OFFSET_PERSISTER,
11382
+ OFFSET_QUERIES,
11383
+ OFFSET_RELATIONSHIPS,
11384
+ OFFSET_STORE,
11385
+ OFFSET_SYNCHRONIZER,
10541
11386
  Persists,
10542
11387
  Provider,
11388
+ RelationshipInHtmlRow,
10543
11389
  RelationshipInHtmlTable,
10544
11390
  RemoteRowView,
10545
11391
  ResultCellView,
@@ -10556,7 +11402,7 @@ export {
10556
11402
  SortedTableView,
10557
11403
  Status,
10558
11404
  TableInHtmlTable,
10559
- TablesView,
11405
+ TablesView$1 as TablesView,
10560
11406
  TableView$1 as TableView,
10561
11407
  TinyBasePartyKitServer,
10562
11408
  useAddRowCallback,
@@ -10680,6 +11526,7 @@ export {
10680
11526
  useSortedRowIds,
10681
11527
  useSortedRowIdsListener,
10682
11528
  useSortedRowIdsListenerImpl,
11529
+ useSortingAndPagination,
10683
11530
  useStartTransactionListener,
10684
11531
  useStore,
10685
11532
  useStoreIds,