tinybase 8.1.0-beta.0 → 8.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/@types/_internal/ui/index.d.ts +0 -0
  2. package/@types/_internal/ui/with-schemas/index.d.ts +47 -0
  3. package/@types/_internal/ui-react/with-schemas/index.d.ts +9 -31
  4. package/@types/omni/index.d.ts +0 -3
  5. package/@types/omni/with-schemas/index.d.ts +0 -3
  6. package/@types/ui-react/with-schemas/index.d.ts +10 -8
  7. package/@types/ui-react-dom/with-schemas/index.d.ts +6 -4
  8. package/@types/ui-svelte/index.d.ts +3484 -0
  9. package/@types/ui-svelte/with-schemas/index.d.ts +3628 -0
  10. package/checkpoints/index.js +4 -1
  11. package/checkpoints/with-schemas/index.js +4 -1
  12. package/common/index.js +4 -1
  13. package/common/with-schemas/index.js +4 -1
  14. package/index.js +4 -1
  15. package/indexes/index.js +4 -1
  16. package/indexes/with-schemas/index.js +4 -1
  17. package/mergeable-store/index.js +4 -1
  18. package/mergeable-store/with-schemas/index.js +4 -1
  19. package/metrics/index.js +4 -1
  20. package/metrics/with-schemas/index.js +4 -1
  21. package/min/omni/index.js +1 -1
  22. package/min/omni/index.js.gz +0 -0
  23. package/min/omni/with-schemas/index.js +1 -1
  24. package/min/omni/with-schemas/index.js.gz +0 -0
  25. package/min/ui-react/index.js +1 -1
  26. package/min/ui-react/index.js.gz +0 -0
  27. package/min/ui-react/with-schemas/index.js +1 -1
  28. package/min/ui-react/with-schemas/index.js.gz +0 -0
  29. package/min/ui-svelte/index.js +1 -0
  30. package/min/ui-svelte/index.js.gz +0 -0
  31. package/min/ui-svelte/with-schemas/index.js +1 -0
  32. package/min/ui-svelte/with-schemas/index.js.gz +0 -0
  33. package/omni/index.js +11 -4739
  34. package/omni/with-schemas/index.js +11 -4739
  35. package/package.json +47 -7
  36. package/persisters/index.js +4 -1
  37. package/persisters/persister-automerge/index.js +4 -1
  38. package/persisters/persister-automerge/with-schemas/index.js +4 -1
  39. package/persisters/persister-browser/index.js +4 -1
  40. package/persisters/persister-browser/with-schemas/index.js +4 -1
  41. package/persisters/persister-cr-sqlite-wasm/index.js +4 -1
  42. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +4 -1
  43. package/persisters/persister-durable-object-sql-storage/index.js +4 -1
  44. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +4 -1
  45. package/persisters/persister-durable-object-storage/index.js +4 -1
  46. package/persisters/persister-durable-object-storage/with-schemas/index.js +4 -1
  47. package/persisters/persister-electric-sql/index.js +4 -1
  48. package/persisters/persister-electric-sql/with-schemas/index.js +4 -1
  49. package/persisters/persister-expo-sqlite/index.js +4 -1
  50. package/persisters/persister-expo-sqlite/with-schemas/index.js +4 -1
  51. package/persisters/persister-file/index.js +4 -1
  52. package/persisters/persister-file/with-schemas/index.js +4 -1
  53. package/persisters/persister-indexed-db/index.js +4 -1
  54. package/persisters/persister-indexed-db/with-schemas/index.js +4 -1
  55. package/persisters/persister-libsql/index.js +4 -1
  56. package/persisters/persister-libsql/with-schemas/index.js +4 -1
  57. package/persisters/persister-partykit-client/index.js +4 -1
  58. package/persisters/persister-partykit-client/with-schemas/index.js +4 -1
  59. package/persisters/persister-partykit-server/index.js +4 -1
  60. package/persisters/persister-partykit-server/with-schemas/index.js +4 -1
  61. package/persisters/persister-pglite/index.js +4 -1
  62. package/persisters/persister-pglite/with-schemas/index.js +4 -1
  63. package/persisters/persister-postgres/index.js +4 -1
  64. package/persisters/persister-postgres/with-schemas/index.js +4 -1
  65. package/persisters/persister-powersync/index.js +4 -1
  66. package/persisters/persister-powersync/with-schemas/index.js +4 -1
  67. package/persisters/persister-react-native-mmkv/index.js +4 -1
  68. package/persisters/persister-react-native-mmkv/with-schemas/index.js +4 -1
  69. package/persisters/persister-react-native-sqlite/index.js +4 -1
  70. package/persisters/persister-react-native-sqlite/with-schemas/index.js +4 -1
  71. package/persisters/persister-remote/index.js +4 -1
  72. package/persisters/persister-remote/with-schemas/index.js +4 -1
  73. package/persisters/persister-sqlite-bun/index.js +4 -1
  74. package/persisters/persister-sqlite-bun/with-schemas/index.js +4 -1
  75. package/persisters/persister-sqlite-wasm/index.js +4 -1
  76. package/persisters/persister-sqlite-wasm/with-schemas/index.js +4 -1
  77. package/persisters/persister-sqlite3/index.js +4 -1
  78. package/persisters/persister-sqlite3/with-schemas/index.js +4 -1
  79. package/persisters/persister-yjs/index.js +4 -1
  80. package/persisters/persister-yjs/with-schemas/index.js +4 -1
  81. package/persisters/with-schemas/index.js +4 -1
  82. package/queries/index.js +4 -1
  83. package/queries/with-schemas/index.js +4 -1
  84. package/readme.md +14 -14
  85. package/relationships/index.js +4 -1
  86. package/relationships/with-schemas/index.js +4 -1
  87. package/releases.md +70 -44
  88. package/schematizers/index.js +4 -1
  89. package/schematizers/schematizer-arktype/index.js +4 -1
  90. package/schematizers/schematizer-arktype/with-schemas/index.js +4 -1
  91. package/schematizers/schematizer-effect/index.js +4 -1
  92. package/schematizers/schematizer-effect/with-schemas/index.js +4 -1
  93. package/schematizers/schematizer-typebox/index.js +4 -1
  94. package/schematizers/schematizer-typebox/with-schemas/index.js +4 -1
  95. package/schematizers/schematizer-valibot/index.js +4 -1
  96. package/schematizers/schematizer-valibot/with-schemas/index.js +4 -1
  97. package/schematizers/schematizer-yup/index.js +4 -1
  98. package/schematizers/schematizer-yup/with-schemas/index.js +4 -1
  99. package/schematizers/schematizer-zod/index.js +4 -1
  100. package/schematizers/schematizer-zod/with-schemas/index.js +4 -1
  101. package/schematizers/with-schemas/index.js +4 -1
  102. package/store/index.js +4 -1
  103. package/store/with-schemas/index.js +4 -1
  104. package/synchronizers/index.js +4 -1
  105. package/synchronizers/synchronizer-broadcast-channel/index.js +4 -1
  106. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +4 -1
  107. package/synchronizers/synchronizer-local/index.js +4 -1
  108. package/synchronizers/synchronizer-local/with-schemas/index.js +4 -1
  109. package/synchronizers/synchronizer-ws-client/index.js +4 -1
  110. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +4 -1
  111. package/synchronizers/synchronizer-ws-server/index.js +4 -1
  112. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -1
  113. package/synchronizers/synchronizer-ws-server-durable-object/index.js +4 -1
  114. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +4 -1
  115. package/synchronizers/synchronizer-ws-server-simple/index.js +4 -1
  116. package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +4 -1
  117. package/synchronizers/with-schemas/index.js +4 -1
  118. package/ui-react/index.js +100 -100
  119. package/ui-react/with-schemas/index.js +100 -100
  120. package/ui-react-dom/index.js +4 -1
  121. package/ui-react-dom/with-schemas/index.js +4 -1
  122. package/ui-react-inspector/index.js +4 -1
  123. package/ui-react-inspector/with-schemas/index.js +4 -1
  124. package/ui-svelte/index.js +2684 -0
  125. package/ui-svelte/with-schemas/index.js +2684 -0
  126. package/with-schemas/index.js +4 -1
package/omni/index.js CHANGED
@@ -2,8 +2,6 @@ import {DurableObject} from 'cloudflare:workers';
2
2
  import {addDatabaseChangeListener} from 'expo-sqlite';
3
3
  import {existsSync, watch, writeFileSync} from 'fs';
4
4
  import {readFile, writeFile} from 'fs/promises';
5
- import React from 'react';
6
- import {Fragment, jsx, jsxs} from 'react/jsx-runtime';
7
5
  import {Map as Map$1} from 'yjs';
8
6
 
9
7
  const getTypeOf = (thing) => typeof thing;
@@ -34,7 +32,6 @@ const SET = 'set';
34
32
  const ADD = 'add';
35
33
  const DEL = 'del';
36
34
  const HAS = 'Has';
37
- const _HAS = 'has';
38
35
  const IDS = 'Ids';
39
36
  const TABLE$1 = 'Table';
40
37
  const TABLES = TABLE$1 + 's';
@@ -49,24 +46,9 @@ const VALUE = 'Value';
49
46
  const VALUES = VALUE + 's';
50
47
  const VALUE_IDS = VALUE + IDS;
51
48
  const TRANSACTION = 'Transaction';
52
- const PARTIAL = 'Partial';
53
- const FINISH = 'Finish';
54
- const STATUS = 'Status';
55
- const METRIC = 'Metric';
56
- const INDEX = 'Index';
57
- const SLICE = 'Slice';
58
- const RELATIONSHIP = 'Relationship';
59
- const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
60
- const LOCAL = 'Local';
61
- const LINKED = 'Linked';
62
- const QUERY = 'Query';
63
- const CHECKPOINT = 'Checkpoint';
64
- const CURRENT_TARGET = 'currentTarget';
65
- const _VALUE = 'value';
66
49
  const OPEN = 'open';
67
50
  const MESSAGE = 'message';
68
51
  const ERROR = 'error';
69
- const EXTRA = 'extra';
70
52
  const T = 't';
71
53
  const V = 'v';
72
54
  const UNDEFINED = '\uFFFC';
@@ -82,7 +64,10 @@ const strReplace = (str, searchValue, replaceValue) =>
82
64
 
83
65
  const promise = Promise;
84
66
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
85
- predicate(value) ? otherwise?.() : then(value);
67
+ predicate(value)
68
+ ? /* istanbul ignore next */
69
+ otherwise?.()
70
+ : then(value);
86
71
  const GLOBAL = globalThis;
87
72
  const WINDOW = GLOBAL.window;
88
73
  const THOUSAND = 1e3;
@@ -114,21 +99,12 @@ const size = (arrayOrString) => arrayOrString.length;
114
99
  const test = (regex, subject) => regex.test(subject);
115
100
  const getUndefined = () => void 0;
116
101
  const noop = () => {};
117
- const getArg = (value) => value;
118
102
  const promiseNew = (resolver) => new promise(resolver);
119
103
  const promiseAll = async (promises) => promise.all(promises);
120
104
  const structuredClone = GLOBAL.structuredClone;
121
105
  const errorNew = (message) => {
122
106
  throw new Error(message);
123
107
  };
124
- const tryReturn = (tryF, catchReturn) => {
125
- try {
126
- return tryF();
127
- } catch {
128
- /* istanbul ignore next */
129
- return catchReturn;
130
- }
131
- };
132
108
  const tryCatch = async (action, then1, then2) => {
133
109
  try {
134
110
  return await action();
@@ -138,8 +114,6 @@ const tryCatch = async (action, then1, then2) => {
138
114
  }
139
115
  };
140
116
 
141
- const arrayNew = (size2, cb) =>
142
- arrayMap(new Array(size2).fill(0), (_, index) => cb(index));
143
117
  const arrayHas = (array, value) => array.includes(value);
144
118
  const arrayEvery = (array, cb) => array.every(cb);
145
119
  const arrayIsEqual = (array1, array2) =>
@@ -167,7 +141,6 @@ const arrayPush = (array, ...values) => array.push(...values);
167
141
  const arrayPop = (array) => array.pop();
168
142
  const arrayUnshift = (array, ...values) => array.unshift(...values);
169
143
  const arrayShift = (array) => array.shift();
170
- const arrayWith = (array, index, value) => array.with(index, value);
171
144
 
172
145
  const collSizeN = (collSizer) => (coll) =>
173
146
  arrayReduce(collValues(coll), (total, coll2) => total + collSizer(coll2), 0);
@@ -869,7 +842,7 @@ const getRandomValues = GLOBAL.crypto
869
842
  ? (array) => GLOBAL.crypto.getRandomValues(array)
870
843
  : /* istanbul ignore next */
871
844
  (array) => arrayMap(array, () => mathFloor(math.random() * 256));
872
- const getUniqueId$1 = (length = 16) =>
845
+ const getUniqueId = (length = 16) =>
873
846
  arrayReduce(
874
847
  getRandomValues(new Uint8Array(length)),
875
848
  (uniqueId, number) => uniqueId + encode(number),
@@ -960,7 +933,7 @@ const getHlcFunctions = (uniqueId, getNow = Date.now) => {
960
933
  let lastLogicalTime = 0;
961
934
  let lastCounter = -1;
962
935
  const thisClientId = ifNotUndefined(uniqueId, getClientIdFromUniqueId, () =>
963
- getUniqueId$1(5),
936
+ getUniqueId(5),
964
937
  );
965
938
  const getNextHlc = () => {
966
939
  seenHlc();
@@ -1258,25 +1231,6 @@ const encodeIfJson = (value) =>
1258
1231
  const isEncodedJson = (value) => isString(value) && value[0] == JSON_PREFIX;
1259
1232
  const decodeIfJson = (raw, _id, encoded) =>
1260
1233
  !encoded && isEncodedJson(raw) ? jsonParse(slice(raw, 1)) : raw;
1261
- const getTypeCase = (
1262
- type,
1263
- stringCase,
1264
- numberCase,
1265
- booleanCase,
1266
- objectCase,
1267
- arrayCase,
1268
- ) =>
1269
- type == STRING
1270
- ? stringCase
1271
- : type == NUMBER
1272
- ? numberCase
1273
- : type == BOOLEAN
1274
- ? booleanCase
1275
- : type == OBJECT
1276
- ? objectCase
1277
- : type == ARRAY
1278
- ? arrayCase
1279
- : null;
1280
1234
 
1281
1235
  const stampClone = ([value, hlc]) => stampNew(value, hlc);
1282
1236
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -7120,7 +7074,7 @@ const createCustomSynchronizer = (
7120
7074
  let sends = 0;
7121
7075
  let receives = 0;
7122
7076
  const pendingRequests = mapNew();
7123
- const getTransactionId = () => getUniqueId$1(11);
7077
+ const getTransactionId = () => getUniqueId(11);
7124
7078
  const sendImpl = (toClientId, requestId, message, body) => {
7125
7079
  sends++;
7126
7080
  onSend?.(toClientId, requestId, message, body);
@@ -7128,7 +7082,7 @@ const createCustomSynchronizer = (
7128
7082
  };
7129
7083
  const request = async (toClientId, message, body, transactionId) =>
7130
7084
  promiseNew((resolve, reject) => {
7131
- const requestId = transactionId + DOT + getUniqueId$1(4);
7085
+ const requestId = transactionId + DOT + getUniqueId(4);
7132
7086
  const timeout = startTimeout(() => {
7133
7087
  collDel(pendingRequests, requestId);
7134
7088
  reject(
@@ -7331,7 +7285,7 @@ const createBroadcastChannelSynchronizer = (
7331
7285
  onReceive,
7332
7286
  onIgnoredError,
7333
7287
  ) => {
7334
- const clientId = getUniqueId$1();
7288
+ const clientId = getUniqueId();
7335
7289
  const channel = new BroadcastChannel(channelName);
7336
7290
  const send = (toClientId, requestId, message, body) =>
7337
7291
  channel.postMessage([clientId, toClientId, requestId, message, body]);
@@ -7361,7 +7315,7 @@ const createBroadcastChannelSynchronizer = (
7361
7315
 
7362
7316
  const clients = mapNew();
7363
7317
  const createLocalSynchronizer = (store, onSend, onReceive, onIgnoredError) => {
7364
- const clientId = getUniqueId$1();
7318
+ const clientId = getUniqueId();
7365
7319
  const send = (toClientId, requestId, message, body) =>
7366
7320
  startTimeout(() =>
7367
7321
  isNull(toClientId)
@@ -7777,4490 +7731,9 @@ const createWsServer = (
7777
7731
  return objFreeze(wsServer);
7778
7732
  };
7779
7733
 
7780
- const {
7781
- PureComponent,
7782
- createContext,
7783
- useCallback,
7784
- useContext,
7785
- useEffect,
7786
- useLayoutEffect,
7787
- useMemo,
7788
- useRef,
7789
- useState,
7790
- useSyncExternalStore,
7791
- } = React;
7792
- const getProps = (getProps2, ...ids) =>
7793
- isUndefined(getProps2) ? {} : getProps2(...ids);
7794
- const getRelationshipsStoreTableIds = (relationships, relationshipId) => [
7795
- relationships,
7796
- relationships?.getStore(),
7797
- relationships?.getLocalTableId(relationshipId),
7798
- relationships?.getRemoteTableId(relationshipId),
7799
- ];
7800
- const getIndexStoreTableId = (indexes, indexId) => [
7801
- indexes,
7802
- indexes?.getStore(),
7803
- indexes?.getTableId(indexId),
7804
- ];
7805
-
7806
- const TINYBASE_CONTEXT = TINYBASE + '_uirc';
7807
- const Context = GLOBAL[TINYBASE_CONTEXT]
7808
- ? /* istanbul ignore next */
7809
- GLOBAL[TINYBASE_CONTEXT]
7810
- : (GLOBAL[TINYBASE_CONTEXT] = createContext([]));
7811
- const useThing = (id, offset) => {
7812
- const contextValue = useContext(Context);
7813
- return isUndefined(id)
7814
- ? contextValue[offset * 2]
7815
- : isString(id)
7816
- ? objGet(contextValue[offset * 2 + 1], id)
7817
- : id;
7818
- };
7819
- const useThings = (offset) => ({...useContext(Context)[offset * 2 + 1]});
7820
- const useThingOrThingById = (thingOrThingId, offset) => {
7821
- const thing = useThing(thingOrThingId, offset);
7822
- return isUndefined(thingOrThingId) || isString(thingOrThingId)
7823
- ? thing
7824
- : thingOrThingId;
7825
- };
7826
- const useProvideThing = (thingId, thing, offset) => {
7827
- const {16: addExtraThingById, 17: delExtraThingById} = useContext(Context);
7828
- useEffect(() => {
7829
- addExtraThingById?.(offset, thingId, thing);
7830
- return () => delExtraThingById?.(offset, thingId);
7831
- }, [addExtraThingById, thingId, thing, offset, delExtraThingById]);
7832
- };
7833
- const useThingIds = (offset) =>
7834
- objIds(useContext(Context)[offset * 2 + 1] ?? {});
7835
-
7836
- const OFFSET_STORE = 0;
7837
- const OFFSET_METRICS = 1;
7838
- const OFFSET_INDEXES = 2;
7839
- const OFFSET_RELATIONSHIPS = 3;
7840
- const OFFSET_QUERIES = 4;
7841
- const OFFSET_CHECKPOINTS = 5;
7842
- const OFFSET_PERSISTER = 6;
7843
- const OFFSET_SYNCHRONIZER = 7;
7844
- const mergeParentThings = (
7845
- offset,
7846
- parentValue,
7847
- defaultThing,
7848
- thingsById,
7849
- extraThingsById,
7850
- ) => [
7851
- defaultThing ?? parentValue[offset * 2],
7852
- {
7853
- ...parentValue[offset * 2 + 1],
7854
- ...thingsById,
7855
- ...extraThingsById[offset],
7856
- },
7857
- ];
7858
- const Provider = ({
7859
- store,
7860
- storesById,
7861
- metrics,
7862
- metricsById,
7863
- indexes,
7864
- indexesById,
7865
- relationships,
7866
- relationshipsById,
7867
- queries,
7868
- queriesById,
7869
- checkpoints,
7870
- checkpointsById,
7871
- persister,
7872
- persistersById,
7873
- synchronizer,
7874
- synchronizersById,
7875
- children,
7876
- }) => {
7877
- const parentValue = useContext(Context);
7878
- const [extraThingsById, setExtraThingsById] = useState(() =>
7879
- arrayNew(8, () => ({})),
7880
- );
7881
- const addExtraThingById = useCallback(
7882
- (thingOffset, id, thing) =>
7883
- setExtraThingsById((extraThingsById2) =>
7884
- objGet(extraThingsById2[thingOffset], id) == thing
7885
- ? extraThingsById2
7886
- : arrayWith(extraThingsById2, thingOffset, {
7887
- ...extraThingsById2[thingOffset],
7888
- [id]: thing,
7889
- }),
7890
- ),
7891
- [],
7892
- );
7893
- const delExtraThingById = useCallback(
7894
- (thingOffset, id) =>
7895
- setExtraThingsById((extraThingsById2) =>
7896
- !objHas(extraThingsById2[thingOffset], id)
7897
- ? extraThingsById2
7898
- : arrayWith(
7899
- extraThingsById2,
7900
- thingOffset,
7901
- objDel(extraThingsById2[thingOffset], id),
7902
- ),
7903
- ),
7904
- [],
7905
- );
7906
- return /* @__PURE__ */ jsx(Context.Provider, {
7907
- value: useMemo(
7908
- () => [
7909
- ...mergeParentThings(
7910
- OFFSET_STORE,
7911
- parentValue,
7912
- store,
7913
- storesById,
7914
- extraThingsById,
7915
- ),
7916
- ...mergeParentThings(
7917
- OFFSET_METRICS,
7918
- parentValue,
7919
- metrics,
7920
- metricsById,
7921
- extraThingsById,
7922
- ),
7923
- ...mergeParentThings(
7924
- OFFSET_INDEXES,
7925
- parentValue,
7926
- indexes,
7927
- indexesById,
7928
- extraThingsById,
7929
- ),
7930
- ...mergeParentThings(
7931
- OFFSET_RELATIONSHIPS,
7932
- parentValue,
7933
- relationships,
7934
- relationshipsById,
7935
- extraThingsById,
7936
- ),
7937
- ...mergeParentThings(
7938
- OFFSET_QUERIES,
7939
- parentValue,
7940
- queries,
7941
- queriesById,
7942
- extraThingsById,
7943
- ),
7944
- ...mergeParentThings(
7945
- OFFSET_CHECKPOINTS,
7946
- parentValue,
7947
- checkpoints,
7948
- checkpointsById,
7949
- extraThingsById,
7950
- ),
7951
- ...mergeParentThings(
7952
- OFFSET_PERSISTER,
7953
- parentValue,
7954
- persister,
7955
- persistersById,
7956
- extraThingsById,
7957
- ),
7958
- ...mergeParentThings(
7959
- OFFSET_SYNCHRONIZER,
7960
- parentValue,
7961
- synchronizer,
7962
- synchronizersById,
7963
- extraThingsById,
7964
- ),
7965
- addExtraThingById,
7966
- delExtraThingById,
7967
- ],
7968
- [
7969
- extraThingsById,
7970
- store,
7971
- storesById,
7972
- metrics,
7973
- metricsById,
7974
- indexes,
7975
- indexesById,
7976
- relationships,
7977
- relationshipsById,
7978
- queries,
7979
- queriesById,
7980
- checkpoints,
7981
- checkpointsById,
7982
- persister,
7983
- persistersById,
7984
- synchronizer,
7985
- synchronizersById,
7986
- parentValue,
7987
- addExtraThingById,
7988
- delExtraThingById,
7989
- ],
7990
- ),
7991
- children,
7992
- });
7993
- };
7994
-
7995
- const EMPTY_ARRAY = [];
7996
- const DEFAULTS = [
7997
- {},
7998
- [],
7999
- [EMPTY_ARRAY, void 0, EMPTY_ARRAY],
8000
- {},
8001
- void 0,
8002
- void 0,
8003
- false,
8004
- 0,
8005
- ];
8006
- const IS_EQUALS = [
8007
- objIsEqual,
8008
- arrayIsEqual,
8009
- (
8010
- [backwardIds1, currentId1, forwardIds1],
8011
- [backwardIds2, currentId2, forwardIds2],
8012
- ) =>
8013
- currentId1 === currentId2 &&
8014
- arrayIsEqual(backwardIds1, backwardIds2) &&
8015
- arrayIsEqual(forwardIds1, forwardIds2),
8016
- (paramValues1, paramValues2) =>
8017
- objIsEqual(paramValues1, paramValues2, arrayOrValueEqual),
8018
- arrayOrValueEqual,
8019
- (thing1, thing2) =>
8020
- thing1 === thing2 ||
8021
- ((isObject(thing1) || isArray(thing1)) &&
8022
- jsonString(thing1) === jsonString(thing2)),
8023
- ];
8024
- const isEqual = (thing1, thing2) => thing1 === thing2;
8025
- const useCreate = (store, create, createDeps = EMPTY_ARRAY) => {
8026
- const [, rerender] = useState();
8027
- const [thing, setThing] = useState();
8028
- useEffect(
8029
- () => {
8030
- const newThing = store ? create(store) : void 0;
8031
- setThing(newThing);
8032
- rerender([]);
8033
- return newThing?.destroy;
8034
- },
8035
- // eslint-disable-next-line react-hooks/exhaustive-deps
8036
- [store, ...createDeps],
8037
- );
8038
- return thing;
8039
- };
8040
- const addAndDelListener = (thing, listenable, ...args) => {
8041
- const listenerId = thing?.[ADD + listenable + LISTENER]?.(...args);
8042
- return () => thing?.delListener?.(listenerId);
8043
- };
8044
- const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
8045
- const lastResult = useRef(DEFAULTS[returnType]);
8046
- const getResult = useCallback(
8047
- () => {
8048
- const nextResult =
8049
- thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
8050
- ...args,
8051
- ) ?? DEFAULTS[returnType];
8052
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
8053
- ? (lastResult.current = nextResult)
8054
- : lastResult.current;
8055
- },
8056
- /* eslint-disable-next-line react-hooks/exhaustive-deps */
8057
- [thing, returnType, listenable, ...args],
8058
- );
8059
- const subscribe = useCallback(
8060
- (listener) =>
8061
- addAndDelListener(
8062
- thing,
8063
- (returnType == 6 /* Boolean */ ? HAS : EMPTY_STRING) + listenable,
8064
- ...args,
8065
- listener,
8066
- ),
8067
- /* eslint-disable-next-line react-hooks/exhaustive-deps */
8068
- [thing, returnType, listenable, ...args],
8069
- );
8070
- return useSyncExternalStore(subscribe, getResult, getResult);
8071
- };
8072
- const useListener = (
8073
- listenable,
8074
- thing,
8075
- listener,
8076
- listenerDeps = EMPTY_ARRAY,
8077
- preArgs = EMPTY_ARRAY,
8078
- ...postArgs
8079
- ) =>
8080
- useLayoutEffect(
8081
- () =>
8082
- addAndDelListener(thing, listenable, ...preArgs, listener, ...postArgs),
8083
- // eslint-disable-next-line react-hooks/exhaustive-deps
8084
- [thing, listenable, ...preArgs, ...listenerDeps, ...postArgs],
8085
- );
8086
- const useSetCallback = (
8087
- storeOrQueries,
8088
- settable,
8089
- get,
8090
- getDeps = EMPTY_ARRAY,
8091
- then = getUndefined,
8092
- thenDeps = EMPTY_ARRAY,
8093
- methodPrefix,
8094
- ...args
8095
- ) =>
8096
- useCallback(
8097
- (parameter) =>
8098
- ifNotUndefined(storeOrQueries, (obj) =>
8099
- ifNotUndefined(get(parameter, obj), (thing) =>
8100
- then(
8101
- obj[methodPrefix + settable](
8102
- ...argsOrGetArgs(args, obj, parameter),
8103
- thing,
8104
- ),
8105
- thing,
8106
- ),
8107
- ),
8108
- ),
8109
- /* eslint-disable react-hooks/exhaustive-deps */
8110
- [
8111
- storeOrQueries,
8112
- settable,
8113
- ...getDeps,
8114
- ...thenDeps,
8115
- methodPrefix,
8116
- ...nonFunctionDeps(args),
8117
- ],
8118
- /* eslint-enable react-hooks/exhaustive-deps */
8119
- );
8120
- const useStoreSetCallback = (
8121
- storeOrStoreId,
8122
- settable,
8123
- get,
8124
- getDeps,
8125
- then,
8126
- thenDeps,
8127
- ...args
8128
- ) =>
8129
- useSetCallback(
8130
- useStoreOrStoreById(storeOrStoreId),
8131
- settable,
8132
- get,
8133
- getDeps,
8134
- then,
8135
- thenDeps,
8136
- SET,
8137
- ...args,
8138
- );
8139
- const useQueriesSetCallback = (
8140
- queriesOrQueriesId,
8141
- settable,
8142
- get,
8143
- getDeps,
8144
- then,
8145
- thenDeps,
8146
- ...args
8147
- ) =>
8148
- useSetCallback(
8149
- useQueriesOrQueriesById(queriesOrQueriesId),
8150
- settable,
8151
- get,
8152
- getDeps,
8153
- then,
8154
- thenDeps,
8155
- EMPTY_STRING,
8156
- ...args,
8157
- );
8158
- const argsOrGetArgs = (args, store, parameter) =>
8159
- arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
8160
- const nonFunctionDeps = (args) => arrayFilter(args, (arg) => !isFunction(arg));
8161
- const useDel = (
8162
- storeOrStoreId,
8163
- deletable,
8164
- then = getUndefined,
8165
- thenDeps = EMPTY_ARRAY,
8166
- ...args
8167
- ) => {
8168
- const store = useStoreOrStoreById(storeOrStoreId);
8169
- return useCallback(
8170
- (parameter) =>
8171
- then(store?.[DEL + deletable](...argsOrGetArgs(args, store, parameter))),
8172
- // eslint-disable-next-line react-hooks/exhaustive-deps
8173
- [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
8174
- );
8175
- };
8176
- const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
8177
- const checkpoints = useCheckpointsOrCheckpointsById(
8178
- checkpointsOrCheckpointsId,
8179
- );
8180
- return useCallback(
8181
- () => checkpoints?.[action](arg),
8182
- [checkpoints, action, arg],
8183
- );
8184
- };
8185
- const useSortedRowIdsImpl = (
8186
- tableId,
8187
- cellId,
8188
- descending,
8189
- offset,
8190
- limit,
8191
- storeOrStoreId,
8192
- ) =>
8193
- useListenable(
8194
- SORTED_ROW_IDS,
8195
- useStoreOrStoreById(storeOrStoreId),
8196
- 1 /* Array */,
8197
- [tableId, cellId, descending, offset, limit],
8198
- );
8199
- const useSortedRowIdsListenerImpl = (
8200
- tableId,
8201
- cellId,
8202
- descending,
8203
- offset,
8204
- limit,
8205
- listener,
8206
- listenerDeps,
8207
- mutator,
8208
- storeOrStoreId,
8209
- ) =>
8210
- useListener(
8211
- SORTED_ROW_IDS,
8212
- useStoreOrStoreById(storeOrStoreId),
8213
- listener,
8214
- listenerDeps,
8215
- [tableId, cellId, descending, offset, limit],
8216
- mutator,
8217
- );
8218
- const useCreateStore = (create, createDeps = EMPTY_ARRAY) =>
8219
- useMemo(create, createDeps);
8220
- const useStoreIds = () => useThingIds(OFFSET_STORE);
8221
- const useStore = (id) => useThing(id, OFFSET_STORE);
8222
- const useStores = () => useThings(OFFSET_STORE);
8223
- const useStoreOrStoreById = (storeOrStoreId) =>
8224
- useThingOrThingById(storeOrStoreId, OFFSET_STORE);
8225
- const useProvideStore = (storeId, store) =>
8226
- useProvideThing(storeId, store, OFFSET_STORE);
8227
- const useCreateMergeableStore = (create, createDeps = EMPTY_ARRAY) =>
8228
- useMemo(create, createDeps);
8229
- const useHasTables = (storeOrStoreId) =>
8230
- useListenable(
8231
- TABLES,
8232
- useStoreOrStoreById(storeOrStoreId),
8233
- 6 /* Boolean */,
8234
- [],
8235
- );
8236
- const useTables = (storeOrStoreId) =>
8237
- useListenable(TABLES, useStoreOrStoreById(storeOrStoreId), 0 /* Object */);
8238
- const useTablesState = (storeOrStoreId) => [
8239
- useTables(storeOrStoreId),
8240
- useSetTablesCallback(getArg, [], storeOrStoreId),
8241
- ];
8242
- const useTableIds = (storeOrStoreId) =>
8243
- useListenable(TABLE_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */);
8244
- const useHasTable = (tableId, storeOrStoreId) =>
8245
- useListenable(TABLE$1, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
8246
- tableId,
8247
- ]);
8248
- const useTable = (tableId, storeOrStoreId) =>
8249
- useListenable(TABLE$1, useStoreOrStoreById(storeOrStoreId), 0 /* Object */, [
8250
- tableId,
8251
- ]);
8252
- const useTableState = (tableId, storeOrStoreId) => [
8253
- useTable(tableId, storeOrStoreId),
8254
- useSetTableCallback(tableId, getArg, [], storeOrStoreId),
8255
- ];
8256
- const useTableCellIds = (tableId, storeOrStoreId) =>
8257
- useListenable(
8258
- TABLE$1 + CELL_IDS,
8259
- useStoreOrStoreById(storeOrStoreId),
8260
- 1 /* Array */,
8261
- [tableId],
8262
- );
8263
- const useHasTableCell = (tableId, cellId, storeOrStoreId) =>
8264
- useListenable(
8265
- TABLE$1 + CELL,
8266
- useStoreOrStoreById(storeOrStoreId),
8267
- 6 /* Boolean */,
8268
- [tableId, cellId],
8269
- );
8270
- const useRowCount = (tableId, storeOrStoreId) =>
8271
- useListenable(
8272
- ROW_COUNT,
8273
- useStoreOrStoreById(storeOrStoreId),
8274
- 7 /* Number */,
8275
- [tableId],
8276
- );
8277
- const useRowIds = (tableId, storeOrStoreId) =>
8278
- useListenable(ROW_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */, [
8279
- tableId,
8280
- ]);
8281
- const useSortedRowIds = (
8282
- tableIdOrArgs,
8283
- cellIdOrStoreOrStoreId,
8284
- descending,
8285
- offset,
8286
- limit,
8287
- storeOrStoreId,
8288
- ) =>
8289
- useSortedRowIdsImpl(
8290
- ...(isObject(tableIdOrArgs)
8291
- ? [
8292
- tableIdOrArgs.tableId,
8293
- tableIdOrArgs.cellId,
8294
- tableIdOrArgs.descending ?? false,
8295
- tableIdOrArgs.offset ?? 0,
8296
- tableIdOrArgs.limit,
8297
- cellIdOrStoreOrStoreId,
8298
- ]
8299
- : [
8300
- tableIdOrArgs,
8301
- cellIdOrStoreOrStoreId,
8302
- descending,
8303
- offset,
8304
- limit,
8305
- storeOrStoreId,
8306
- ]),
8307
- );
8308
- const useHasRow = (tableId, rowId, storeOrStoreId) =>
8309
- useListenable(ROW, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
8310
- tableId,
8311
- rowId,
8312
- ]);
8313
- const useRow = (tableId, rowId, storeOrStoreId) =>
8314
- useListenable(ROW, useStoreOrStoreById(storeOrStoreId), 0 /* Object */, [
8315
- tableId,
8316
- rowId,
8317
- ]);
8318
- const useRowState = (tableId, rowId, storeOrStoreId) => [
8319
- useRow(tableId, rowId, storeOrStoreId),
8320
- useSetRowCallback(tableId, rowId, getArg, [], storeOrStoreId),
8321
- ];
8322
- const useCellIds = (tableId, rowId, storeOrStoreId) =>
8323
- useListenable(CELL_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */, [
8324
- tableId,
8325
- rowId,
8326
- ]);
8327
- const useHasCell = (tableId, rowId, cellId, storeOrStoreId) =>
8328
- useListenable(CELL, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
8329
- tableId,
8330
- rowId,
8331
- cellId,
8332
- ]);
8333
- const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
8334
- useListenable(
8335
- CELL,
8336
- useStoreOrStoreById(storeOrStoreId),
8337
- 5 /* CellOrValue */,
8338
- [tableId, rowId, cellId],
8339
- );
8340
- const useCellState = (tableId, rowId, cellId, storeOrStoreId) => [
8341
- useCell(tableId, rowId, cellId, storeOrStoreId),
8342
- useSetCellCallback(tableId, rowId, cellId, getArg, [], storeOrStoreId),
8343
- ];
8344
- const useHasValues = (storeOrStoreId) =>
8345
- useListenable(
8346
- VALUES,
8347
- useStoreOrStoreById(storeOrStoreId),
8348
- 6 /* Boolean */,
8349
- [],
8350
- );
8351
- const useValues = (storeOrStoreId) =>
8352
- useListenable(VALUES, useStoreOrStoreById(storeOrStoreId), 0 /* Object */);
8353
- const useValuesState = (storeOrStoreId) => [
8354
- useValues(storeOrStoreId),
8355
- useSetValuesCallback(getArg, [], storeOrStoreId),
8356
- ];
8357
- const useValueIds = (storeOrStoreId) =>
8358
- useListenable(VALUE_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */);
8359
- const useHasValue = (valueId, storeOrStoreId) =>
8360
- useListenable(VALUE, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
8361
- valueId,
8362
- ]);
8363
- const useValue = (valueId, storeOrStoreId) =>
8364
- useListenable(
8365
- VALUE,
8366
- useStoreOrStoreById(storeOrStoreId),
8367
- 5 /* CellOrValue */,
8368
- [valueId],
8369
- );
8370
- const useValueState = (valueId, storeOrStoreId) => [
8371
- useValue(valueId, storeOrStoreId),
8372
- useSetValueCallback(valueId, getArg, [], storeOrStoreId),
8373
- ];
8374
- const useSetTablesCallback = (
8375
- getTables,
8376
- getTablesDeps,
8377
- storeOrStoreId,
8378
- then,
8379
- thenDeps,
8380
- ) =>
8381
- useStoreSetCallback(
8382
- storeOrStoreId,
8383
- TABLES,
8384
- getTables,
8385
- getTablesDeps,
8386
- then,
8387
- thenDeps,
8388
- );
8389
- const useSetTableCallback = (
8390
- tableId,
8391
- getTable,
8392
- getTableDeps,
8393
- storeOrStoreId,
8394
- then,
8395
- thenDeps,
8396
- ) =>
8397
- useStoreSetCallback(
8398
- storeOrStoreId,
8399
- TABLE$1,
8400
- getTable,
8401
- getTableDeps,
8402
- then,
8403
- thenDeps,
8404
- tableId,
8405
- );
8406
- const useSetRowCallback = (
8407
- tableId,
8408
- rowId,
8409
- getRow,
8410
- getRowDeps,
8411
- storeOrStoreId,
8412
- then,
8413
- thenDeps,
8414
- ) =>
8415
- useStoreSetCallback(
8416
- storeOrStoreId,
8417
- ROW,
8418
- getRow,
8419
- getRowDeps,
8420
- then,
8421
- thenDeps,
8422
- tableId,
8423
- rowId,
8424
- );
8425
- const useAddRowCallback = (
8426
- tableId,
8427
- getRow,
8428
- getRowDeps = EMPTY_ARRAY,
8429
- storeOrStoreId,
8430
- then = getUndefined,
8431
- thenDeps = EMPTY_ARRAY,
8432
- reuseRowIds = true,
8433
- ) => {
8434
- const store = useStoreOrStoreById(storeOrStoreId);
8435
- return useCallback(
8436
- (parameter) =>
8437
- ifNotUndefined(store, (store2) =>
8438
- ifNotUndefined(getRow(parameter, store2), (row) =>
8439
- then(
8440
- store2.addRow(
8441
- isFunction(tableId) ? tableId(parameter, store2) : tableId,
8442
- row,
8443
- reuseRowIds,
8444
- ),
8445
- store2,
8446
- row,
8447
- ),
8448
- ),
8449
- ),
8450
- // eslint-disable-next-line react-hooks/exhaustive-deps
8451
- [store, tableId, ...getRowDeps, ...thenDeps, reuseRowIds],
8452
- );
8453
- };
8454
- const useSetPartialRowCallback = (
8455
- tableId,
8456
- rowId,
8457
- getPartialRow,
8458
- getPartialRowDeps,
8459
- storeOrStoreId,
8460
- then,
8461
- thenDeps,
8462
- ) =>
8463
- useStoreSetCallback(
8464
- storeOrStoreId,
8465
- PARTIAL + ROW,
8466
- getPartialRow,
8467
- getPartialRowDeps,
8468
- then,
8469
- thenDeps,
8470
- tableId,
8471
- rowId,
8472
- );
8473
- const useSetCellCallback = (
8474
- tableId,
8475
- rowId,
8476
- cellId,
8477
- getCell,
8478
- getCellDeps,
8479
- storeOrStoreId,
8480
- then,
8481
- thenDeps,
8482
- ) =>
8483
- useStoreSetCallback(
8484
- storeOrStoreId,
8485
- CELL,
8486
- getCell,
8487
- getCellDeps,
8488
- then,
8489
- thenDeps,
8490
- tableId,
8491
- rowId,
8492
- cellId,
8493
- );
8494
- const useSetValuesCallback = (
8495
- getValues,
8496
- getValuesDeps,
8497
- storeOrStoreId,
8498
- then,
8499
- thenDeps,
8500
- ) =>
8501
- useStoreSetCallback(
8502
- storeOrStoreId,
8503
- VALUES,
8504
- getValues,
8505
- getValuesDeps,
8506
- then,
8507
- thenDeps,
8508
- );
8509
- const useSetPartialValuesCallback = (
8510
- getPartialValues,
8511
- getPartialValuesDeps,
8512
- storeOrStoreId,
8513
- then,
8514
- thenDeps,
8515
- ) =>
8516
- useStoreSetCallback(
8517
- storeOrStoreId,
8518
- PARTIAL + VALUES,
8519
- getPartialValues,
8520
- getPartialValuesDeps,
8521
- then,
8522
- thenDeps,
8523
- );
8524
- const useSetValueCallback = (
8525
- valueId,
8526
- getValue,
8527
- getValueDeps,
8528
- storeOrStoreId,
8529
- then,
8530
- thenDeps,
8531
- ) =>
8532
- useStoreSetCallback(
8533
- storeOrStoreId,
8534
- VALUE,
8535
- getValue,
8536
- getValueDeps,
8537
- then,
8538
- thenDeps,
8539
- valueId,
8540
- );
8541
- const useDelTablesCallback = (storeOrStoreId, then, thenDeps) =>
8542
- useDel(storeOrStoreId, TABLES, then, thenDeps);
8543
- const useDelTableCallback = (tableId, storeOrStoreId, then, thenDeps) =>
8544
- useDel(storeOrStoreId, TABLE$1, then, thenDeps, tableId);
8545
- const useDelRowCallback = (tableId, rowId, storeOrStoreId, then, thenDeps) =>
8546
- useDel(storeOrStoreId, ROW, then, thenDeps, tableId, rowId);
8547
- const useDelCellCallback = (
8548
- tableId,
8549
- rowId,
8550
- cellId,
8551
- forceDel,
8552
- storeOrStoreId,
8553
- then,
8554
- thenDeps,
8555
- ) =>
8556
- useDel(
8557
- storeOrStoreId,
8558
- CELL,
8559
- then,
8560
- thenDeps,
8561
- tableId,
8562
- rowId,
8563
- cellId,
8564
- forceDel,
8565
- );
8566
- const useDelValuesCallback = (storeOrStoreId, then, thenDeps) =>
8567
- useDel(storeOrStoreId, VALUES, then, thenDeps);
8568
- const useDelValueCallback = (valueId, storeOrStoreId, then, thenDeps) =>
8569
- useDel(storeOrStoreId, VALUE, then, thenDeps, valueId);
8570
- const useHasTablesListener = (
8571
- listener,
8572
- listenerDeps,
8573
- mutator,
8574
- storeOrStoreId,
8575
- ) =>
8576
- useListener(
8577
- HAS + TABLES,
8578
- useStoreOrStoreById(storeOrStoreId),
8579
- listener,
8580
- listenerDeps,
8581
- [],
8582
- mutator,
8583
- );
8584
- const useTablesListener = (listener, listenerDeps, mutator, storeOrStoreId) =>
8585
- useListener(
8586
- TABLES,
8587
- useStoreOrStoreById(storeOrStoreId),
8588
- listener,
8589
- listenerDeps,
8590
- EMPTY_ARRAY,
8591
- mutator,
8592
- );
8593
- const useTableIdsListener = (listener, listenerDeps, mutator, storeOrStoreId) =>
8594
- useListener(
8595
- TABLE_IDS,
8596
- useStoreOrStoreById(storeOrStoreId),
8597
- listener,
8598
- listenerDeps,
8599
- EMPTY_ARRAY,
8600
- mutator,
8601
- );
8602
- const useHasTableListener = (
8603
- tableId,
8604
- listener,
8605
- listenerDeps,
8606
- mutator,
8607
- storeOrStoreId,
8608
- ) =>
8609
- useListener(
8610
- HAS + TABLE$1,
8611
- useStoreOrStoreById(storeOrStoreId),
8612
- listener,
8613
- listenerDeps,
8614
- [tableId],
8615
- mutator,
8616
- );
8617
- const useTableListener = (
8618
- tableId,
8619
- listener,
8620
- listenerDeps,
8621
- mutator,
8622
- storeOrStoreId,
8623
- ) =>
8624
- useListener(
8625
- TABLE$1,
8626
- useStoreOrStoreById(storeOrStoreId),
8627
- listener,
8628
- listenerDeps,
8629
- [tableId],
8630
- mutator,
8631
- );
8632
- const useTableCellIdsListener = (
8633
- tableId,
8634
- listener,
8635
- listenerDeps,
8636
- mutator,
8637
- storeOrStoreId,
8638
- ) =>
8639
- useListener(
8640
- TABLE$1 + CELL_IDS,
8641
- useStoreOrStoreById(storeOrStoreId),
8642
- listener,
8643
- listenerDeps,
8644
- [tableId],
8645
- mutator,
8646
- );
8647
- const useHasTableCellListener = (
8648
- tableId,
8649
- cellId,
8650
- listener,
8651
- listenerDeps,
8652
- mutator,
8653
- storeOrStoreId,
8654
- ) =>
8655
- useListener(
8656
- HAS + TABLE$1 + CELL,
8657
- useStoreOrStoreById(storeOrStoreId),
8658
- listener,
8659
- listenerDeps,
8660
- [tableId, cellId],
8661
- mutator,
8662
- );
8663
- const useRowCountListener = (
8664
- tableId,
8665
- listener,
8666
- listenerDeps,
8667
- mutator,
8668
- storeOrStoreId,
8669
- ) =>
8670
- useListener(
8671
- ROW_COUNT,
8672
- useStoreOrStoreById(storeOrStoreId),
8673
- listener,
8674
- listenerDeps,
8675
- [tableId],
8676
- mutator,
8677
- );
8678
- const useRowIdsListener = (
8679
- tableId,
8680
- listener,
8681
- listenerDeps,
8682
- mutator,
8683
- storeOrStoreId,
8684
- ) =>
8685
- useListener(
8686
- ROW_IDS,
8687
- useStoreOrStoreById(storeOrStoreId),
8688
- listener,
8689
- listenerDeps,
8690
- [tableId],
8691
- mutator,
8692
- );
8693
- const useSortedRowIdsListener = (
8694
- tableIdOrArgs,
8695
- cellIdOrListener,
8696
- descendingOrListenerDeps,
8697
- offsetOrMutator,
8698
- limitOrStoreOrStoreId,
8699
- listener,
8700
- listenerDeps,
8701
- mutator,
8702
- storeOrStoreId,
8703
- ) =>
8704
- useSortedRowIdsListenerImpl(
8705
- ...(isObject(tableIdOrArgs)
8706
- ? [
8707
- tableIdOrArgs.tableId,
8708
- tableIdOrArgs.cellId,
8709
- tableIdOrArgs.descending ?? false,
8710
- tableIdOrArgs.offset ?? 0,
8711
- tableIdOrArgs.limit,
8712
- cellIdOrListener,
8713
- descendingOrListenerDeps,
8714
- offsetOrMutator,
8715
- limitOrStoreOrStoreId,
8716
- ]
8717
- : [
8718
- tableIdOrArgs,
8719
- cellIdOrListener,
8720
- descendingOrListenerDeps,
8721
- offsetOrMutator,
8722
- limitOrStoreOrStoreId,
8723
- listener,
8724
- listenerDeps,
8725
- mutator,
8726
- storeOrStoreId,
8727
- ]),
8728
- );
8729
- const useHasRowListener = (
8730
- tableId,
8731
- rowId,
8732
- listener,
8733
- listenerDeps,
8734
- mutator,
8735
- storeOrStoreId,
8736
- ) =>
8737
- useListener(
8738
- HAS + ROW,
8739
- useStoreOrStoreById(storeOrStoreId),
8740
- listener,
8741
- listenerDeps,
8742
- [tableId, rowId],
8743
- mutator,
8744
- );
8745
- const useRowListener = (
8746
- tableId,
8747
- rowId,
8748
- listener,
8749
- listenerDeps,
8750
- mutator,
8751
- storeOrStoreId,
8752
- ) =>
8753
- useListener(
8754
- ROW,
8755
- useStoreOrStoreById(storeOrStoreId),
8756
- listener,
8757
- listenerDeps,
8758
- [tableId, rowId],
8759
- mutator,
8760
- );
8761
- const useCellIdsListener = (
8762
- tableId,
8763
- rowId,
8764
- listener,
8765
- listenerDeps,
8766
- mutator,
8767
- storeOrStoreId,
8768
- ) =>
8769
- useListener(
8770
- CELL_IDS,
8771
- useStoreOrStoreById(storeOrStoreId),
8772
- listener,
8773
- listenerDeps,
8774
- [tableId, rowId],
8775
- mutator,
8776
- );
8777
- const useHasCellListener = (
8778
- tableId,
8779
- rowId,
8780
- cellId,
8781
- listener,
8782
- listenerDeps,
8783
- mutator,
8784
- storeOrStoreId,
8785
- ) =>
8786
- useListener(
8787
- HAS + CELL,
8788
- useStoreOrStoreById(storeOrStoreId),
8789
- listener,
8790
- listenerDeps,
8791
- [tableId, rowId, cellId],
8792
- mutator,
8793
- );
8794
- const useCellListener = (
8795
- tableId,
8796
- rowId,
8797
- cellId,
8798
- listener,
8799
- listenerDeps,
8800
- mutator,
8801
- storeOrStoreId,
8802
- ) =>
8803
- useListener(
8804
- CELL,
8805
- useStoreOrStoreById(storeOrStoreId),
8806
- listener,
8807
- listenerDeps,
8808
- [tableId, rowId, cellId],
8809
- mutator,
8810
- );
8811
- const useHasValuesListener = (
8812
- listener,
8813
- listenerDeps,
8814
- mutator,
8815
- storeOrStoreId,
8816
- ) =>
8817
- useListener(
8818
- HAS + VALUES,
8819
- useStoreOrStoreById(storeOrStoreId),
8820
- listener,
8821
- listenerDeps,
8822
- [],
8823
- mutator,
8824
- );
8825
- const useValuesListener = (listener, listenerDeps, mutator, storeOrStoreId) =>
8826
- useListener(
8827
- VALUES,
8828
- useStoreOrStoreById(storeOrStoreId),
8829
- listener,
8830
- listenerDeps,
8831
- EMPTY_ARRAY,
8832
- mutator,
8833
- );
8834
- const useValueIdsListener = (listener, listenerDeps, mutator, storeOrStoreId) =>
8835
- useListener(
8836
- VALUE_IDS,
8837
- useStoreOrStoreById(storeOrStoreId),
8838
- listener,
8839
- listenerDeps,
8840
- EMPTY_ARRAY,
8841
- mutator,
8842
- );
8843
- const useHasValueListener = (
8844
- valueId,
8845
- listener,
8846
- listenerDeps,
8847
- mutator,
8848
- storeOrStoreId,
8849
- ) =>
8850
- useListener(
8851
- HAS + VALUE,
8852
- useStoreOrStoreById(storeOrStoreId),
8853
- listener,
8854
- listenerDeps,
8855
- [valueId],
8856
- mutator,
8857
- );
8858
- const useValueListener = (
8859
- valueId,
8860
- listener,
8861
- listenerDeps,
8862
- mutator,
8863
- storeOrStoreId,
8864
- ) =>
8865
- useListener(
8866
- VALUE,
8867
- useStoreOrStoreById(storeOrStoreId),
8868
- listener,
8869
- listenerDeps,
8870
- [valueId],
8871
- mutator,
8872
- );
8873
- const useStartTransactionListener = (listener, listenerDeps, storeOrStoreId) =>
8874
- useListener(
8875
- 'Start' + TRANSACTION,
8876
- useStoreOrStoreById(storeOrStoreId),
8877
- listener,
8878
- listenerDeps,
8879
- );
8880
- const useWillFinishTransactionListener = (
8881
- listener,
8882
- listenerDeps,
8883
- storeOrStoreId,
8884
- ) =>
8885
- useListener(
8886
- 'Will' + FINISH + TRANSACTION,
8887
- useStoreOrStoreById(storeOrStoreId),
8888
- listener,
8889
- listenerDeps,
8890
- );
8891
- const useDidFinishTransactionListener = (
8892
- listener,
8893
- listenerDeps,
8894
- storeOrStoreId,
8895
- ) =>
8896
- useListener(
8897
- 'Did' + FINISH + TRANSACTION,
8898
- useStoreOrStoreById(storeOrStoreId),
8899
- listener,
8900
- listenerDeps,
8901
- );
8902
- const useCreateMetrics = (store, create, createDeps) =>
8903
- useCreate(store, create, createDeps);
8904
- const useMetricsIds = () => useThingIds(OFFSET_METRICS);
8905
- const useMetrics = (id) => useThing(id, OFFSET_METRICS);
8906
- const useMetricsOrMetricsById = (metricsOrMetricsId) =>
8907
- useThingOrThingById(metricsOrMetricsId, OFFSET_METRICS);
8908
- const useProvideMetrics = (metricsId, metrics) =>
8909
- useProvideThing(metricsId, metrics, OFFSET_METRICS);
8910
- const useMetricIds = (metricsOrMetricsId) =>
8911
- useListenable(
8912
- METRIC + IDS,
8913
- useMetricsOrMetricsById(metricsOrMetricsId),
8914
- 1 /* Array */,
8915
- );
8916
- const useMetric = (metricId, metricsOrMetricsId) =>
8917
- useListenable(
8918
- METRIC,
8919
- useMetricsOrMetricsById(metricsOrMetricsId),
8920
- 5 /* CellOrValue */,
8921
- [metricId],
8922
- );
8923
- const useMetricListener = (
8924
- metricId,
8925
- listener,
8926
- listenerDeps,
8927
- metricsOrMetricsId,
8928
- ) =>
8929
- useListener(
8930
- METRIC,
8931
- useMetricsOrMetricsById(metricsOrMetricsId),
8932
- listener,
8933
- listenerDeps,
8934
- [metricId],
8935
- );
8936
- const useCreateIndexes = (store, create, createDeps) =>
8937
- useCreate(store, create, createDeps);
8938
- const useIndexesIds = () => useThingIds(OFFSET_INDEXES);
8939
- const useIndexes = (id) => useThing(id, OFFSET_INDEXES);
8940
- const useIndexesOrIndexesById = (indexesOrIndexesId) =>
8941
- useThingOrThingById(indexesOrIndexesId, OFFSET_INDEXES);
8942
- const useProvideIndexes = (indexesId, indexes) =>
8943
- useProvideThing(indexesId, indexes, OFFSET_INDEXES);
8944
- const useSliceIds = (indexId, indexesOrIndexesId) =>
8945
- useListenable(
8946
- SLICE + IDS,
8947
- useIndexesOrIndexesById(indexesOrIndexesId),
8948
- 1 /* Array */,
8949
- [indexId],
8950
- );
8951
- const useIndexIds = (indexesOrIndexesId) =>
8952
- useListenable(
8953
- INDEX + IDS,
8954
- useIndexesOrIndexesById(indexesOrIndexesId),
8955
- 1 /* Array */,
8956
- );
8957
- const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
8958
- useListenable(
8959
- SLICE + ROW_IDS,
8960
- useIndexesOrIndexesById(indexesOrIndexesId),
8961
- 1 /* Array */,
8962
- [indexId, sliceId],
8963
- );
8964
- const useSliceIdsListener = (
8965
- indexId,
8966
- listener,
8967
- listenerDeps,
8968
- indexesOrIndexesId,
8969
- ) =>
8970
- useListener(
8971
- SLICE + IDS,
8972
- useIndexesOrIndexesById(indexesOrIndexesId),
8973
- listener,
8974
- listenerDeps,
8975
- [indexId],
8976
- );
8977
- const useSliceRowIdsListener = (
8978
- indexId,
8979
- sliceId,
8980
- listener,
8981
- listenerDeps,
8982
- indexesOrIndexesId,
8983
- ) =>
8984
- useListener(
8985
- SLICE + ROW_IDS,
8986
- useIndexesOrIndexesById(indexesOrIndexesId),
8987
- listener,
8988
- listenerDeps,
8989
- [indexId, sliceId],
8990
- );
8991
- const useCreateRelationships = (store, create, createDeps) =>
8992
- useCreate(store, create, createDeps);
8993
- const useRelationshipsIds = () => useThingIds(OFFSET_RELATIONSHIPS);
8994
- const useRelationships = (id) => useThing(id, OFFSET_RELATIONSHIPS);
8995
- const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
8996
- useThingOrThingById(relationshipsOrRelationshipsId, OFFSET_RELATIONSHIPS);
8997
- const useProvideRelationships = (relationshipsId, relationships) =>
8998
- useProvideThing(relationshipsId, relationships, OFFSET_RELATIONSHIPS);
8999
- const useRelationshipIds = (relationshipsOrRelationshipsId) =>
9000
- useListenable(
9001
- RELATIONSHIP + IDS,
9002
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9003
- 1 /* Array */,
9004
- );
9005
- const useRemoteRowId = (
9006
- relationshipId,
9007
- localRowId,
9008
- relationshipsOrRelationshipsId,
9009
- ) =>
9010
- useListenable(
9011
- REMOTE_ROW_ID,
9012
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9013
- 5 /* CellOrValue */,
9014
- [relationshipId, localRowId],
9015
- );
9016
- const useLocalRowIds = (
9017
- relationshipId,
9018
- remoteRowId,
9019
- relationshipsOrRelationshipsId,
9020
- ) =>
9021
- useListenable(
9022
- LOCAL + ROW_IDS,
9023
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9024
- 1 /* Array */,
9025
- [relationshipId, remoteRowId],
9026
- );
9027
- const useLinkedRowIds = (
9028
- relationshipId,
9029
- firstRowId,
9030
- relationshipsOrRelationshipsId,
9031
- ) =>
9032
- useListenable(
9033
- LINKED + ROW_IDS,
9034
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9035
- 1 /* Array */,
9036
- [relationshipId, firstRowId],
9037
- );
9038
- const useRemoteRowIdListener = (
9039
- relationshipId,
9040
- localRowId,
9041
- listener,
9042
- listenerDeps,
9043
- relationshipsOrRelationshipsId,
9044
- ) =>
9045
- useListener(
9046
- REMOTE_ROW_ID,
9047
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9048
- listener,
9049
- listenerDeps,
9050
- [relationshipId, localRowId],
9051
- );
9052
- const useLocalRowIdsListener = (
9053
- relationshipId,
9054
- remoteRowId,
9055
- listener,
9056
- listenerDeps,
9057
- relationshipsOrRelationshipsId,
9058
- ) =>
9059
- useListener(
9060
- LOCAL + ROW_IDS,
9061
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9062
- listener,
9063
- listenerDeps,
9064
- [relationshipId, remoteRowId],
9065
- );
9066
- const useLinkedRowIdsListener = (
9067
- relationshipId,
9068
- firstRowId,
9069
- listener,
9070
- listenerDeps,
9071
- relationshipsOrRelationshipsId,
9072
- ) =>
9073
- useListener(
9074
- LINKED + ROW_IDS,
9075
- useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
9076
- listener,
9077
- listenerDeps,
9078
- [relationshipId, firstRowId],
9079
- );
9080
- const useCreateQueries = (store, create, createDeps) =>
9081
- useCreate(store, create, createDeps);
9082
- const useQueriesIds = () => useThingIds(OFFSET_QUERIES);
9083
- const useQueries = (id) => useThing(id, OFFSET_QUERIES);
9084
- const useQueriesOrQueriesById = (queriesOrQueriesId) =>
9085
- useThingOrThingById(queriesOrQueriesId, OFFSET_QUERIES);
9086
- const useProvideQueries = (queriesId, queries) =>
9087
- useProvideThing(queriesId, queries, OFFSET_QUERIES);
9088
- const useQueryIds = (queriesOrQueriesId) =>
9089
- useListenable(
9090
- QUERY + IDS,
9091
- useQueriesOrQueriesById(queriesOrQueriesId),
9092
- 1 /* Array */,
9093
- );
9094
- const useResultTable = (queryId, queriesOrQueriesId) =>
9095
- useListenable(
9096
- RESULT + TABLE$1,
9097
- useQueriesOrQueriesById(queriesOrQueriesId),
9098
- 0 /* Object */,
9099
- [queryId],
9100
- );
9101
- const useResultTableCellIds = (queryId, queriesOrQueriesId) =>
9102
- useListenable(
9103
- RESULT + TABLE$1 + CELL_IDS,
9104
- useQueriesOrQueriesById(queriesOrQueriesId),
9105
- 1 /* Array */,
9106
- [queryId],
9107
- );
9108
- const useResultRowCount = (queryId, queriesOrQueriesId) =>
9109
- useListenable(
9110
- RESULT + ROW_COUNT,
9111
- useQueriesOrQueriesById(queriesOrQueriesId),
9112
- 7 /* Number */,
9113
- [queryId],
9114
- );
9115
- const useResultRowIds = (queryId, queriesOrQueriesId) =>
9116
- useListenable(
9117
- RESULT + ROW_IDS,
9118
- useQueriesOrQueriesById(queriesOrQueriesId),
9119
- 1 /* Array */,
9120
- [queryId],
9121
- );
9122
- const useResultSortedRowIds = (
9123
- queryId,
9124
- cellId,
9125
- descending,
9126
- offset = 0,
9127
- limit,
9128
- queriesOrQueriesId,
9129
- ) =>
9130
- useListenable(
9131
- RESULT + SORTED_ROW_IDS,
9132
- useQueriesOrQueriesById(queriesOrQueriesId),
9133
- 1 /* Array */,
9134
- [queryId, cellId, descending, offset, limit],
9135
- );
9136
- const useResultRow = (queryId, rowId, queriesOrQueriesId) =>
9137
- useListenable(
9138
- RESULT + ROW,
9139
- useQueriesOrQueriesById(queriesOrQueriesId),
9140
- 0 /* Object */,
9141
- [queryId, rowId],
9142
- );
9143
- const useResultCellIds = (queryId, rowId, queriesOrQueriesId) =>
9144
- useListenable(
9145
- RESULT + CELL_IDS,
9146
- useQueriesOrQueriesById(queriesOrQueriesId),
9147
- 1 /* Array */,
9148
- [queryId, rowId],
9149
- );
9150
- const useResultCell = (queryId, rowId, cellId, queriesOrQueriesId) =>
9151
- useListenable(
9152
- RESULT + CELL,
9153
- useQueriesOrQueriesById(queriesOrQueriesId),
9154
- 5 /* CellOrValue */,
9155
- [queryId, rowId, cellId],
9156
- );
9157
- const useResultTableListener = (
9158
- queryId,
9159
- listener,
9160
- listenerDeps,
9161
- queriesOrQueriesId,
9162
- ) =>
9163
- useListener(
9164
- RESULT + TABLE$1,
9165
- useQueriesOrQueriesById(queriesOrQueriesId),
9166
- listener,
9167
- listenerDeps,
9168
- [queryId],
9169
- );
9170
- const useResultTableCellIdsListener = (
9171
- queryId,
9172
- listener,
9173
- listenerDeps,
9174
- queriesOrQueriesId,
9175
- ) =>
9176
- useListener(
9177
- RESULT + TABLE$1 + CELL_IDS,
9178
- useQueriesOrQueriesById(queriesOrQueriesId),
9179
- listener,
9180
- listenerDeps,
9181
- [queryId],
9182
- );
9183
- const useResultRowCountListener = (
9184
- queryId,
9185
- listener,
9186
- listenerDeps,
9187
- queriesOrQueriesId,
9188
- ) =>
9189
- useListener(
9190
- RESULT + ROW_COUNT,
9191
- useQueriesOrQueriesById(queriesOrQueriesId),
9192
- listener,
9193
- listenerDeps,
9194
- [queryId],
9195
- );
9196
- const useResultRowIdsListener = (
9197
- queryId,
9198
- listener,
9199
- listenerDeps,
9200
- queriesOrQueriesId,
9201
- ) =>
9202
- useListener(
9203
- RESULT + ROW_IDS,
9204
- useQueriesOrQueriesById(queriesOrQueriesId),
9205
- listener,
9206
- listenerDeps,
9207
- [queryId],
9208
- );
9209
- const useResultSortedRowIdsListener = (
9210
- queryId,
9211
- cellId,
9212
- descending,
9213
- offset,
9214
- limit,
9215
- listener,
9216
- listenerDeps,
9217
- queriesOrQueriesId,
9218
- ) =>
9219
- useListener(
9220
- RESULT + SORTED_ROW_IDS,
9221
- useQueriesOrQueriesById(queriesOrQueriesId),
9222
- listener,
9223
- listenerDeps,
9224
- [queryId, cellId, descending, offset, limit],
9225
- );
9226
- const useResultRowListener = (
9227
- queryId,
9228
- rowId,
9229
- listener,
9230
- listenerDeps,
9231
- queriesOrQueriesId,
9232
- ) =>
9233
- useListener(
9234
- RESULT + ROW,
9235
- useQueriesOrQueriesById(queriesOrQueriesId),
9236
- listener,
9237
- listenerDeps,
9238
- [queryId, rowId],
9239
- );
9240
- const useResultCellIdsListener = (
9241
- queryId,
9242
- rowId,
9243
- listener,
9244
- listenerDeps,
9245
- queriesOrQueriesId,
9246
- ) =>
9247
- useListener(
9248
- RESULT + CELL_IDS,
9249
- useQueriesOrQueriesById(queriesOrQueriesId),
9250
- listener,
9251
- listenerDeps,
9252
- [queryId, rowId],
9253
- );
9254
- const useResultCellListener = (
9255
- queryId,
9256
- rowId,
9257
- cellId,
9258
- listener,
9259
- listenerDeps,
9260
- queriesOrQueriesId,
9261
- ) =>
9262
- useListener(
9263
- RESULT + CELL,
9264
- useQueriesOrQueriesById(queriesOrQueriesId),
9265
- listener,
9266
- listenerDeps,
9267
- [queryId, rowId, cellId],
9268
- );
9269
- const useParamValues = (queryId, queriesOrQueriesId) =>
9270
- useListenable(
9271
- 'ParamValues',
9272
- useQueriesOrQueriesById(queriesOrQueriesId),
9273
- 3 /* ParamValues */,
9274
- [queryId],
9275
- );
9276
- const useParamValuesState = (queryId, queriesOrQueriesId) => [
9277
- useParamValues(queryId, queriesOrQueriesId),
9278
- useSetParamValuesCallback(queryId, getArg, [], queriesOrQueriesId),
9279
- ];
9280
- const useParamValue = (queryId, paramId, queriesOrQueriesId) =>
9281
- useListenable(
9282
- 'ParamValue',
9283
- useQueriesOrQueriesById(queriesOrQueriesId),
9284
- 4 /* ParamValue */,
9285
- [queryId, paramId],
9286
- );
9287
- const useParamValueState = (queryId, paramId, queriesOrQueriesId) => [
9288
- useParamValue(queryId, paramId, queriesOrQueriesId),
9289
- useSetParamValueCallback(queryId, paramId, getArg, [], queriesOrQueriesId),
9290
- ];
9291
- const useParamValuesListener = (
9292
- queryId,
9293
- listener,
9294
- listenerDeps,
9295
- queriesOrQueriesId,
9296
- ) =>
9297
- useListener(
9298
- 'ParamValues',
9299
- useQueriesOrQueriesById(queriesOrQueriesId),
9300
- listener,
9301
- listenerDeps,
9302
- [queryId],
9303
- );
9304
- const useParamValueListener = (
9305
- queryId,
9306
- paramId,
9307
- listener,
9308
- listenerDeps,
9309
- queriesOrQueriesId,
9310
- ) =>
9311
- useListener(
9312
- 'ParamValue',
9313
- useQueriesOrQueriesById(queriesOrQueriesId),
9314
- listener,
9315
- listenerDeps,
9316
- [queryId, paramId],
9317
- );
9318
- const useSetParamValueCallback = (
9319
- queryId,
9320
- paramId,
9321
- getParamValue,
9322
- getParamValueDeps,
9323
- queriesOrQueriesId,
9324
- then,
9325
- thenDeps,
9326
- ) =>
9327
- useQueriesSetCallback(
9328
- queriesOrQueriesId,
9329
- 'setParamValue',
9330
- getParamValue,
9331
- getParamValueDeps,
9332
- then,
9333
- thenDeps,
9334
- queryId,
9335
- paramId,
9336
- );
9337
- const useSetParamValuesCallback = (
9338
- queryId,
9339
- getParamValues,
9340
- getParamValuesDeps,
9341
- queriesOrQueriesId,
9342
- then,
9343
- thenDeps,
9344
- ) =>
9345
- useQueriesSetCallback(
9346
- queriesOrQueriesId,
9347
- 'setParamValues',
9348
- getParamValues,
9349
- getParamValuesDeps,
9350
- then,
9351
- thenDeps,
9352
- queryId,
9353
- );
9354
- const useCreateCheckpoints = (store, create, createDeps) =>
9355
- useCreate(store, create, createDeps);
9356
- const useCheckpointsIds = () => useThingIds(OFFSET_CHECKPOINTS);
9357
- const useCheckpoints = (id) => useThing(id, OFFSET_CHECKPOINTS);
9358
- const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
9359
- useThingOrThingById(checkpointsOrCheckpointsId, OFFSET_CHECKPOINTS);
9360
- const useProvideCheckpoints = (checkpointsId, checkpoints) =>
9361
- useProvideThing(checkpointsId, checkpoints, OFFSET_CHECKPOINTS);
9362
- const useCheckpointIds = (checkpointsOrCheckpointsId) =>
9363
- useListenable(
9364
- CHECKPOINT + IDS,
9365
- useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
9366
- 2 /* Checkpoints */,
9367
- );
9368
- const useCheckpoint = (checkpointId, checkpointsOrCheckpointsId) =>
9369
- useListenable(
9370
- CHECKPOINT,
9371
- useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
9372
- 5 /* CellOrValue */,
9373
- [checkpointId],
9374
- );
9375
- const useSetCheckpointCallback = (
9376
- getCheckpoint = getUndefined,
9377
- getCheckpointDeps = EMPTY_ARRAY,
9378
- checkpointsOrCheckpointsId,
9379
- then = getUndefined,
9380
- thenDeps = EMPTY_ARRAY,
9381
- ) => {
9382
- const checkpoints = useCheckpointsOrCheckpointsById(
9383
- checkpointsOrCheckpointsId,
9384
- );
9385
- return useCallback(
9386
- (parameter) =>
9387
- ifNotUndefined(checkpoints, (checkpoints2) => {
9388
- const label = getCheckpoint(parameter);
9389
- then(checkpoints2.addCheckpoint(label), checkpoints2, label);
9390
- }),
9391
- // eslint-disable-next-line react-hooks/exhaustive-deps
9392
- [checkpoints, ...getCheckpointDeps, ...thenDeps],
9393
- );
9394
- };
9395
- const useGoBackwardCallback = (checkpointsOrCheckpointsId) =>
9396
- useCheckpointAction(checkpointsOrCheckpointsId, 'goBackward');
9397
- const useGoForwardCallback = (checkpointsOrCheckpointsId) =>
9398
- useCheckpointAction(checkpointsOrCheckpointsId, 'goForward');
9399
- const useGoToCallback = (
9400
- getCheckpointId,
9401
- getCheckpointIdDeps = EMPTY_ARRAY,
9402
- checkpointsOrCheckpointsId,
9403
- then = getUndefined,
9404
- thenDeps = EMPTY_ARRAY,
9405
- ) => {
9406
- const checkpoints = useCheckpointsOrCheckpointsById(
9407
- checkpointsOrCheckpointsId,
9408
- );
9409
- return useCallback(
9410
- (parameter) =>
9411
- ifNotUndefined(checkpoints, (checkpoints2) =>
9412
- ifNotUndefined(getCheckpointId(parameter), (checkpointId) =>
9413
- then(checkpoints2.goTo(checkpointId), checkpointId),
9414
- ),
9415
- ),
9416
- // eslint-disable-next-line react-hooks/exhaustive-deps
9417
- [checkpoints, ...getCheckpointIdDeps, ...thenDeps],
9418
- );
9419
- };
9420
- const useUndoInformation = (checkpointsOrCheckpointsId) => {
9421
- const checkpoints = useCheckpointsOrCheckpointsById(
9422
- checkpointsOrCheckpointsId,
9423
- );
9424
- const [backwardIds, currentId] = useCheckpointIds(checkpoints);
9425
- return [
9426
- !arrayIsEmpty(backwardIds),
9427
- useGoBackwardCallback(checkpoints),
9428
- currentId,
9429
- ifNotUndefined(currentId, (id) => checkpoints?.getCheckpoint(id)) ??
9430
- EMPTY_STRING,
9431
- ];
9432
- };
9433
- const useRedoInformation = (checkpointsOrCheckpointsId) => {
9434
- const checkpoints = useCheckpointsOrCheckpointsById(
9435
- checkpointsOrCheckpointsId,
9436
- );
9437
- const [, , [forwardId]] = useCheckpointIds(checkpoints);
9438
- return [
9439
- !isUndefined(forwardId),
9440
- useGoForwardCallback(checkpoints),
9441
- forwardId,
9442
- ifNotUndefined(forwardId, (id) => checkpoints?.getCheckpoint(id)) ??
9443
- EMPTY_STRING,
9444
- ];
9445
- };
9446
- const useCheckpointIdsListener = (
9447
- listener,
9448
- listenerDeps,
9449
- checkpointsOrCheckpointsId,
9450
- ) =>
9451
- useListener(
9452
- CHECKPOINT + IDS,
9453
- useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
9454
- listener,
9455
- listenerDeps,
9456
- );
9457
- const useCheckpointListener = (
9458
- checkpointId,
9459
- listener,
9460
- listenerDeps,
9461
- checkpointsOrCheckpointsId,
9462
- ) =>
9463
- useListener(
9464
- CHECKPOINT,
9465
- useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
9466
- listener,
9467
- listenerDeps,
9468
- [checkpointId],
9469
- );
9470
- const useCreatePersister = (
9471
- store,
9472
- create,
9473
- createDeps = EMPTY_ARRAY,
9474
- then,
9475
- thenDeps = EMPTY_ARRAY,
9476
- destroy,
9477
- destroyDeps = EMPTY_ARRAY,
9478
- ) => {
9479
- const [, rerender] = useState();
9480
- const [persister, setPersister] = useState();
9481
- useEffect(
9482
- () => {
9483
- (async () => {
9484
- const persister2 = store ? await create(store) : void 0;
9485
- setPersister(persister2);
9486
- if (persister2 && then) {
9487
- (async () => {
9488
- await then(persister2);
9489
- rerender([]);
9490
- })();
9491
- }
9492
- })();
9493
- },
9494
- // eslint-disable-next-line react-hooks/exhaustive-deps
9495
- [store, ...createDeps, ...thenDeps],
9496
- );
9497
- useEffect(
9498
- () => () => {
9499
- if (persister) {
9500
- persister.destroy();
9501
- destroy?.(persister);
9502
- }
9503
- },
9504
- // eslint-disable-next-line react-hooks/exhaustive-deps
9505
- [persister, ...destroyDeps],
9506
- );
9507
- return persister;
9508
- };
9509
- const usePersisterIds = () => useThingIds(OFFSET_PERSISTER);
9510
- const usePersister = (id) => useThing(id, OFFSET_PERSISTER);
9511
- const usePersisterOrPersisterById = (persisterOrPersisterId) =>
9512
- useThingOrThingById(persisterOrPersisterId, OFFSET_PERSISTER);
9513
- const useProvidePersister = (persisterId, persister) =>
9514
- useProvideThing(persisterId, persister, OFFSET_PERSISTER);
9515
- const usePersisterStatus = (persisterOrPersisterId) =>
9516
- useListenable(
9517
- STATUS,
9518
- usePersisterOrPersisterById(persisterOrPersisterId),
9519
- 7 /* Number */,
9520
- [],
9521
- );
9522
- const usePersisterStatusListener = (
9523
- listener,
9524
- listenerDeps,
9525
- persisterOrPersisterId,
9526
- ) =>
9527
- useListener(
9528
- STATUS,
9529
- usePersisterOrPersisterById(persisterOrPersisterId),
9530
- listener,
9531
- listenerDeps,
9532
- [],
9533
- );
9534
- const useCreateSynchronizer = (
9535
- store,
9536
- create,
9537
- createDeps = EMPTY_ARRAY,
9538
- destroy,
9539
- destroyDeps = EMPTY_ARRAY,
9540
- ) => {
9541
- const [synchronizer, setSynchronizer] = useState();
9542
- useEffect(
9543
- () => {
9544
- (async () => {
9545
- const synchronizer2 = store ? await create(store) : void 0;
9546
- setSynchronizer(synchronizer2);
9547
- })();
9548
- },
9549
- // eslint-disable-next-line react-hooks/exhaustive-deps
9550
- [store, ...createDeps],
9551
- );
9552
- useEffect(
9553
- () => () => {
9554
- if (synchronizer) {
9555
- synchronizer.destroy();
9556
- destroy?.(synchronizer);
9557
- }
9558
- },
9559
- // eslint-disable-next-line react-hooks/exhaustive-deps
9560
- [synchronizer, ...destroyDeps],
9561
- );
9562
- return synchronizer;
9563
- };
9564
- const useSynchronizerIds = () => useThingIds(OFFSET_SYNCHRONIZER);
9565
- const useSynchronizer = (id) => useThing(id, OFFSET_SYNCHRONIZER);
9566
- const useSynchronizerOrSynchronizerById = (synchronizerOrSynchronizerId) =>
9567
- useThingOrThingById(synchronizerOrSynchronizerId, OFFSET_SYNCHRONIZER);
9568
- const useProvideSynchronizer = (persisterId, persister) =>
9569
- useProvideThing(persisterId, persister, OFFSET_SYNCHRONIZER);
9570
- const useSynchronizerStatus = (synchronizerOrSynchronizerId) =>
9571
- useListenable(
9572
- STATUS,
9573
- useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
9574
- 7 /* Number */,
9575
- [],
9576
- );
9577
- const useSynchronizerStatusListener = (
9578
- listener,
9579
- listenerDeps,
9580
- synchronizerOrSynchronizerId,
9581
- ) =>
9582
- useListener(
9583
- STATUS,
9584
- useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
9585
- listener,
9586
- listenerDeps,
9587
- [],
9588
- );
9589
-
9590
- const useStoreCellComponentProps = (store, tableId) =>
9591
- useMemo(() => ({store, tableId}), [store, tableId]);
9592
- const useQueriesCellComponentProps = (queries, queryId) =>
9593
- useMemo(() => ({queries, queryId}), [queries, queryId]);
9594
- const useCallbackOrUndefined = (callback, deps, test) => {
9595
- const returnCallback = useCallback(callback, deps);
9596
- return test ? returnCallback : void 0;
9597
- };
9598
- const useParams = (...args) =>
9599
- useMemo(
9600
- () => args,
9601
- // eslint-disable-next-line react-hooks/exhaustive-deps
9602
- args,
9603
- );
9604
- const useCells = (defaultCellIds, customCells, defaultCellComponent) =>
9605
- useMemo(() => {
9606
- const cellIds = customCells ?? defaultCellIds;
9607
- return objMap(
9608
- isArray(cellIds)
9609
- ? objNew(arrayMap(cellIds, (cellId) => [cellId, cellId]))
9610
- : cellIds,
9611
- (labelOrCustomCell, cellId) => ({
9612
- ...{label: cellId, component: defaultCellComponent},
9613
- ...(isString(labelOrCustomCell)
9614
- ? {label: labelOrCustomCell}
9615
- : labelOrCustomCell),
9616
- }),
9617
- );
9618
- }, [customCells, defaultCellComponent, defaultCellIds]);
9619
-
9620
- const UP_ARROW = '\u2191';
9621
- const DOWN_ARROW = '\u2193';
9622
- const EDITABLE = 'editable';
9623
- const extraRowCells = (extraRowCells2 = [], extraRowCellProps, after = 0) =>
9624
- arrayMap(extraRowCells2, ({component: Component}, index) =>
9625
- /* @__PURE__ */ jsx(
9626
- 'td',
9627
- {
9628
- className: EXTRA,
9629
- children: /* @__PURE__ */ jsx(Component, {...extraRowCellProps}),
9630
- },
9631
- extraKey(index, after),
9632
- ),
9633
- );
9634
- const extraKey = (index, after) => (after ? '>' : '<') + index;
9635
- const extraHeaders = (extraCells = [], after = 0) =>
9636
- arrayMap(extraCells, ({label}, index) =>
9637
- /* @__PURE__ */ jsx(
9638
- 'th',
9639
- {className: EXTRA, children: label},
9640
- extraKey(index, after),
9641
- ),
9642
- );
9643
-
9644
- const HtmlHeaderCell = ({
9645
- cellId,
9646
- sort: [sortCellId, sortDescending],
9647
- label = cellId ?? EMPTY_STRING,
9648
- onClick,
9649
- }) =>
9650
- /* @__PURE__ */ jsxs('th', {
9651
- onClick: useCallbackOrUndefined(
9652
- () => onClick?.(cellId),
9653
- [onClick, cellId],
9654
- onClick,
9655
- ),
9656
- className:
9657
- isUndefined(sortDescending) || sortCellId != cellId
9658
- ? void 0
9659
- : `sorted ${sortDescending ? 'de' : 'a'}scending`,
9660
- children: [
9661
- isUndefined(sortDescending) || sortCellId != cellId
9662
- ? null
9663
- : (sortDescending ? DOWN_ARROW : UP_ARROW) + ' ',
9664
- label,
9665
- ],
9666
- });
9667
- const HtmlTable = ({
9668
- className,
9669
- headerRow,
9670
- idColumn,
9671
- params: [
9672
- cells,
9673
- cellComponentProps,
9674
- rowIds,
9675
- extraCellsBefore,
9676
- extraCellsAfter,
9677
- sortAndOffset,
9678
- handleSort,
9679
- paginatorComponent,
9680
- ],
9681
- }) =>
9682
- /* @__PURE__ */ jsxs('table', {
9683
- className,
9684
- children: [
9685
- paginatorComponent
9686
- ? /* @__PURE__ */ jsx('caption', {children: paginatorComponent})
9687
- : null,
9688
- headerRow === false
9689
- ? null
9690
- : /* @__PURE__ */ jsx('thead', {
9691
- children: /* @__PURE__ */ jsxs('tr', {
9692
- children: [
9693
- extraHeaders(extraCellsBefore),
9694
- idColumn === false
9695
- ? null
9696
- : /* @__PURE__ */ jsx(HtmlHeaderCell, {
9697
- sort: sortAndOffset ?? [],
9698
- label: 'Id',
9699
- onClick: handleSort,
9700
- }),
9701
- objToArray(cells, ({label}, cellId) =>
9702
- /* @__PURE__ */ jsx(
9703
- HtmlHeaderCell,
9704
- {
9705
- cellId,
9706
- label,
9707
- sort: sortAndOffset ?? [],
9708
- onClick: handleSort,
9709
- },
9710
- cellId,
9711
- ),
9712
- ),
9713
- extraHeaders(extraCellsAfter, 1),
9714
- ],
9715
- }),
9716
- }),
9717
- /* @__PURE__ */ jsx('tbody', {
9718
- children: arrayMap(rowIds, (rowId) => {
9719
- const rowProps = {...cellComponentProps, rowId};
9720
- return /* @__PURE__ */ jsxs(
9721
- 'tr',
9722
- {
9723
- children: [
9724
- extraRowCells(extraCellsBefore, rowProps),
9725
- isFalse(idColumn)
9726
- ? null
9727
- : /* @__PURE__ */ jsx('th', {title: rowId, children: rowId}),
9728
- objToArray(
9729
- cells,
9730
- ({component: CellView, getComponentProps}, cellId) =>
9731
- /* @__PURE__ */ jsx(
9732
- 'td',
9733
- {
9734
- children: /* @__PURE__ */ jsx(CellView, {
9735
- ...getProps(getComponentProps, rowId, cellId),
9736
- ...rowProps,
9737
- cellId,
9738
- }),
9739
- },
9740
- cellId,
9741
- ),
9742
- ),
9743
- extraRowCells(extraCellsAfter, rowProps, 1),
9744
- ],
9745
- },
9746
- rowId,
9747
- );
9748
- }),
9749
- }),
9750
- ],
9751
- });
9752
- const EditableThing = ({
9753
- thing,
9754
- onThingChange,
9755
- className,
9756
- hasSchema,
9757
- showType = true,
9758
- }) => {
9759
- const [thingType, setThingType] = useState();
9760
- const [currentThing, setCurrentThing] = useState();
9761
- const [stringThing, setStringThing] = useState();
9762
- const [numberThing, setNumberThing] = useState();
9763
- const [booleanThing, setBooleanThing] = useState();
9764
- const [objectThing, setObjectThing] = useState('{}');
9765
- const [arrayThing, setArrayThing] = useState('[]');
9766
- const [objectClassName, setObjectClassName] = useState('');
9767
- const [arrayClassName, setArrayClassName] = useState('');
9768
- if (currentThing !== thing) {
9769
- setThingType(getCellOrValueType(thing));
9770
- setCurrentThing(thing);
9771
- if (isObject(thing)) {
9772
- setObjectThing(jsonString(thing));
9773
- } else if (isArray(thing)) {
9774
- setArrayThing(jsonString(thing));
9775
- } else {
9776
- setStringThing(String(thing));
9777
- setNumberThing(Number(thing) || 0);
9778
- setBooleanThing(Boolean(thing));
9779
- }
9780
- }
9781
- const handleThingChange = useCallback(
9782
- (thing2, setTypedThing) => {
9783
- setTypedThing(thing2);
9784
- setCurrentThing(thing2);
9785
- onThingChange(thing2);
9786
- },
9787
- [onThingChange],
9788
- );
9789
- const handleJsonThingChange = useCallback(
9790
- (value, setTypedThing, isThing, setTypedClassName) => {
9791
- setTypedThing(value);
9792
- try {
9793
- const object = jsonParse(value);
9794
- if (isThing(object)) {
9795
- setCurrentThing(object);
9796
- onThingChange(object);
9797
- setTypedClassName('');
9798
- }
9799
- } catch {
9800
- setTypedClassName('invalid');
9801
- }
9802
- },
9803
- [onThingChange],
9804
- );
9805
- const handleTypeChange = useCallback(() => {
9806
- if (!hasSchema?.()) {
9807
- const nextType = getTypeCase(
9808
- thingType,
9809
- NUMBER,
9810
- BOOLEAN,
9811
- OBJECT,
9812
- ARRAY,
9813
- STRING,
9814
- );
9815
- const thing2 = getTypeCase(
9816
- nextType,
9817
- stringThing,
9818
- numberThing,
9819
- booleanThing,
9820
- tryReturn(() => jsonParse(objectThing), {}),
9821
- tryReturn(() => jsonParse(arrayThing), []),
9822
- );
9823
- setThingType(nextType);
9824
- setCurrentThing(thing2);
9825
- onThingChange(thing2);
9826
- }
9827
- }, [
9828
- hasSchema,
9829
- onThingChange,
9830
- stringThing,
9831
- numberThing,
9832
- booleanThing,
9833
- objectThing,
9834
- arrayThing,
9835
- thingType,
9836
- ]);
9837
- const widget = getTypeCase(
9838
- thingType,
9839
- /* @__PURE__ */ jsx(
9840
- 'input',
9841
- {
9842
- value: stringThing,
9843
- onChange: useCallback(
9844
- (event) =>
9845
- handleThingChange(
9846
- String(event[CURRENT_TARGET][_VALUE]),
9847
- setStringThing,
9848
- ),
9849
- [handleThingChange],
9850
- ),
9851
- },
9852
- thingType,
9853
- ),
9854
- /* @__PURE__ */ jsx(
9855
- 'input',
9856
- {
9857
- type: 'number',
9858
- value: numberThing,
9859
- onChange: useCallback(
9860
- (event) =>
9861
- handleThingChange(
9862
- Number(event[CURRENT_TARGET][_VALUE] || 0),
9863
- setNumberThing,
9864
- ),
9865
- [handleThingChange],
9866
- ),
9867
- },
9868
- thingType,
9869
- ),
9870
- /* @__PURE__ */ jsx(
9871
- 'input',
9872
- {
9873
- type: 'checkbox',
9874
- checked: booleanThing,
9875
- onChange: useCallback(
9876
- (event) =>
9877
- handleThingChange(
9878
- Boolean(event[CURRENT_TARGET].checked),
9879
- setBooleanThing,
9880
- ),
9881
- [handleThingChange],
9882
- ),
9883
- },
9884
- thingType,
9885
- ),
9886
- /* @__PURE__ */ jsx(
9887
- 'input',
9888
- {
9889
- value: objectThing,
9890
- className: objectClassName,
9891
- onChange: useCallback(
9892
- (event) =>
9893
- handleJsonThingChange(
9894
- event[CURRENT_TARGET][_VALUE],
9895
- setObjectThing,
9896
- isObject,
9897
- setObjectClassName,
9898
- ),
9899
- [handleJsonThingChange],
9900
- ),
9901
- },
9902
- thingType,
9903
- ),
9904
- /* @__PURE__ */ jsx(
9905
- 'input',
9906
- {
9907
- value: arrayThing,
9908
- className: arrayClassName,
9909
- onChange: useCallback(
9910
- (event) =>
9911
- handleJsonThingChange(
9912
- event[CURRENT_TARGET][_VALUE],
9913
- setArrayThing,
9914
- isArray,
9915
- setArrayClassName,
9916
- ),
9917
- [handleJsonThingChange],
9918
- ),
9919
- },
9920
- thingType,
9921
- ),
9922
- );
9923
- return /* @__PURE__ */ jsxs('div', {
9924
- className,
9925
- children: [
9926
- showType && widget
9927
- ? /* @__PURE__ */ jsx('button', {
9928
- title: thingType,
9929
- className: thingType,
9930
- onClick: handleTypeChange,
9931
- children: thingType,
9932
- })
9933
- : null,
9934
- widget,
9935
- ],
9936
- });
9937
- };
9938
-
9939
- const EditableCellView = ({
9940
- tableId,
9941
- rowId,
9942
- cellId,
9943
- store,
9944
- className,
9945
- showType,
9946
- }) => {
9947
- const [cell, setCell] = useCellState(tableId, rowId, cellId, store);
9948
- return /* @__PURE__ */ jsx(EditableThing, {
9949
- thing: cell,
9950
- onThingChange: setCell,
9951
- className: className ?? EDITABLE + CELL,
9952
- showType,
9953
- hasSchema: useStoreOrStoreById(store)?.hasTablesSchema,
9954
- });
9955
- };
9956
-
9957
- const EditableValueView = ({valueId, store, className, showType}) => {
9958
- const [value, setValue] = useValueState(valueId, store);
9959
- return /* @__PURE__ */ jsx(EditableThing, {
9960
- thing: value,
9961
- onThingChange: setValue,
9962
- className: className ?? EDITABLE + VALUE,
9963
- showType,
9964
- hasSchema: useStoreOrStoreById(store)?.hasValuesSchema,
9965
- });
9966
- };
9967
-
9968
- const wrap = (children, separator, encloseWithId, id) => {
9969
- const separated =
9970
- isUndefined(separator) || !isArray(children)
9971
- ? children
9972
- : arrayMap(children, (child, c) => (c > 0 ? [separator, child] : child));
9973
- return encloseWithId ? [id, ':{', separated, '}'] : separated;
9974
- };
9975
-
9976
- const CheckpointView = ({checkpoints, checkpointId, debugIds}) =>
9977
- wrap(
9978
- useCheckpoint(checkpointId, checkpoints) ?? EMPTY_STRING,
9979
- void 0,
9980
- debugIds,
9981
- checkpointId,
9982
- );
9983
-
9984
- const ResultCellView = ({queryId, rowId, cellId, queries, debugIds}) =>
9985
- wrap(
9986
- EMPTY_STRING +
9987
- (useResultCell(queryId, rowId, cellId, queries) ?? EMPTY_STRING),
9988
- void 0,
9989
- debugIds,
9990
- cellId,
9991
- );
9992
-
9993
- const ResultRowView = ({
9994
- queryId,
9995
- rowId,
9996
- queries,
9997
- resultCellComponent: ResultCell = ResultCellView,
9998
- getResultCellComponentProps,
9999
- separator,
10000
- debugIds,
10001
- }) =>
10002
- wrap(
10003
- arrayMap(useResultCellIds(queryId, rowId, queries), (cellId) =>
10004
- /* @__PURE__ */ jsx(
10005
- ResultCell,
10006
- {
10007
- ...getProps(getResultCellComponentProps, cellId),
10008
- queryId,
10009
- rowId,
10010
- cellId,
10011
- queries,
10012
- debugIds,
10013
- },
10014
- cellId,
10015
- ),
10016
- ),
10017
- separator,
10018
- debugIds,
10019
- rowId,
10020
- );
10021
-
10022
- const CellView = ({tableId, rowId, cellId, store, debugIds}) =>
10023
- wrap(
10024
- EMPTY_STRING + (useCell(tableId, rowId, cellId, store) ?? EMPTY_STRING),
10025
- void 0,
10026
- debugIds,
10027
- cellId,
10028
- );
10029
-
10030
- const useCustomOrDefaultCellIds = (customCellIds, tableId, rowId, store) => {
10031
- const defaultCellIds = useCellIds(tableId, rowId, store);
10032
- return customCellIds ?? defaultCellIds;
10033
- };
10034
-
10035
- const RowView = ({
10036
- tableId,
10037
- rowId,
10038
- store,
10039
- cellComponent: Cell = CellView,
10040
- getCellComponentProps,
10041
- customCellIds,
10042
- separator,
10043
- debugIds,
10044
- }) =>
10045
- wrap(
10046
- arrayMap(
10047
- useCustomOrDefaultCellIds(customCellIds, tableId, rowId, store),
10048
- (cellId) =>
10049
- /* @__PURE__ */ jsx(
10050
- Cell,
10051
- {
10052
- ...getProps(getCellComponentProps, cellId),
10053
- tableId,
10054
- rowId,
10055
- cellId,
10056
- store,
10057
- debugIds,
10058
- },
10059
- cellId,
10060
- ),
10061
- ),
10062
- separator,
10063
- debugIds,
10064
- rowId,
10065
- );
10066
-
10067
- const tableView = (
10068
- {
10069
- tableId,
10070
- store,
10071
- rowComponent: Row = RowView,
10072
- getRowComponentProps,
10073
- customCellIds,
10074
- separator,
10075
- debugIds,
10076
- },
10077
- rowIds,
10078
- ) =>
10079
- wrap(
10080
- arrayMap(rowIds, (rowId) =>
10081
- /* @__PURE__ */ jsx(
10082
- Row,
10083
- {
10084
- ...getProps(getRowComponentProps, rowId),
10085
- tableId,
10086
- rowId,
10087
- customCellIds,
10088
- store,
10089
- debugIds,
10090
- },
10091
- rowId,
10092
- ),
10093
- ),
10094
- separator,
10095
- debugIds,
10096
- tableId,
10097
- );
10098
- const resultTableView = (
10099
- {
10100
- queryId,
10101
- queries,
10102
- resultRowComponent: ResultRow = ResultRowView,
10103
- getResultRowComponentProps,
10104
- separator,
10105
- debugIds,
10106
- },
10107
- rowIds,
10108
- ) =>
10109
- wrap(
10110
- arrayMap(rowIds, (rowId) =>
10111
- /* @__PURE__ */ jsx(
10112
- ResultRow,
10113
- {
10114
- ...getProps(getResultRowComponentProps, rowId),
10115
- queryId,
10116
- rowId,
10117
- queries,
10118
- debugIds,
10119
- },
10120
- rowId,
10121
- ),
10122
- ),
10123
- separator,
10124
- debugIds,
10125
- queryId,
10126
- );
10127
- const useComponentPerRow = (
10128
- {
10129
- relationshipId,
10130
- relationships,
10131
- rowComponent: Row = RowView,
10132
- getRowComponentProps,
10133
- separator,
10134
- debugIds,
10135
- },
10136
- getRowIdsHook,
10137
- rowId,
10138
- ) => {
10139
- const [resolvedRelationships, store, localTableId] =
10140
- getRelationshipsStoreTableIds(
10141
- useRelationshipsOrRelationshipsById(relationships),
10142
- relationshipId,
10143
- );
10144
- const rowIds = getRowIdsHook(relationshipId, rowId, resolvedRelationships);
10145
- return wrap(
10146
- arrayMap(rowIds, (rowId2) =>
10147
- /* @__PURE__ */ jsx(
10148
- Row,
10149
- {
10150
- ...getProps(getRowComponentProps, rowId2),
10151
- tableId: localTableId,
10152
- rowId: rowId2,
10153
- store,
10154
- debugIds,
10155
- },
10156
- rowId2,
10157
- ),
10158
- ),
10159
- separator,
10160
- debugIds,
10161
- rowId,
10162
- );
10163
- };
10164
- const getUseCheckpointView =
10165
- (getCheckpoints) =>
10166
- ({
10167
- checkpoints,
10168
- checkpointComponent: Checkpoint = CheckpointView,
10169
- getCheckpointComponentProps,
10170
- separator,
10171
- debugIds,
10172
- }) => {
10173
- const resolvedCheckpoints = useCheckpointsOrCheckpointsById(checkpoints);
10174
- return wrap(
10175
- arrayMap(
10176
- getCheckpoints(useCheckpointIds(resolvedCheckpoints)),
10177
- (checkpointId) =>
10178
- /* @__PURE__ */ jsx(
10179
- Checkpoint,
10180
- {
10181
- ...getProps(getCheckpointComponentProps, checkpointId),
10182
- checkpoints: resolvedCheckpoints,
10183
- checkpointId,
10184
- debugIds,
10185
- },
10186
- checkpointId,
10187
- ),
10188
- ),
10189
- separator,
10190
- );
10191
- };
10192
-
10193
- const BackwardCheckpointsView = getUseCheckpointView(
10194
- (checkpointIds) => checkpointIds[0],
10195
- );
10196
-
10197
- const CurrentCheckpointView = getUseCheckpointView((checkpointIds) =>
10198
- isUndefined(checkpointIds[1]) ? [] : [checkpointIds[1]],
10199
- );
10200
-
10201
- const ForwardCheckpointsView = getUseCheckpointView(
10202
- (checkpointIds) => checkpointIds[2],
10203
- );
10204
-
10205
- const SliceView$1 = ({
10206
- indexId,
10207
- sliceId,
10208
- indexes,
10209
- rowComponent: Row = RowView,
10210
- getRowComponentProps,
10211
- separator,
10212
- debugIds,
10213
- }) => {
10214
- const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
10215
- useIndexesOrIndexesById(indexes),
10216
- indexId,
10217
- );
10218
- const rowIds = useSliceRowIds(indexId, sliceId, resolvedIndexes);
10219
- return wrap(
10220
- arrayMap(rowIds, (rowId) =>
10221
- /* @__PURE__ */ jsx(
10222
- Row,
10223
- {
10224
- ...getProps(getRowComponentProps, rowId),
10225
- tableId,
10226
- rowId,
10227
- store,
10228
- debugIds,
10229
- },
10230
- rowId,
10231
- ),
10232
- ),
10233
- separator,
10234
- debugIds,
10235
- sliceId,
10236
- );
10237
- };
10238
-
10239
- const IndexView$1 = ({
10240
- indexId,
10241
- indexes,
10242
- sliceComponent: Slice = SliceView$1,
10243
- getSliceComponentProps,
10244
- separator,
10245
- debugIds,
10246
- }) =>
10247
- wrap(
10248
- arrayMap(useSliceIds(indexId, indexes), (sliceId) =>
10249
- /* @__PURE__ */ jsx(
10250
- Slice,
10251
- {
10252
- ...getProps(getSliceComponentProps, sliceId),
10253
- indexId,
10254
- sliceId,
10255
- indexes,
10256
- debugIds,
10257
- },
10258
- sliceId,
10259
- ),
10260
- ),
10261
- separator,
10262
- debugIds,
10263
- indexId,
10264
- );
10265
-
10266
- const LinkedRowsView = (props) =>
10267
- useComponentPerRow(props, useLinkedRowIds, props.firstRowId);
10268
-
10269
- const LocalRowsView = (props) =>
10270
- useComponentPerRow(props, useLocalRowIds, props.remoteRowId);
10271
-
10272
- const MetricView = ({metricId, metrics, debugIds}) =>
10273
- wrap(
10274
- useMetric(metricId, metrics) ?? EMPTY_STRING,
10275
- void 0,
10276
- debugIds,
10277
- metricId,
10278
- );
10279
-
10280
- const RemoteRowView = ({
10281
- relationshipId,
10282
- localRowId,
10283
- relationships,
10284
- rowComponent: Row = RowView,
10285
- getRowComponentProps,
10286
- debugIds,
10287
- }) => {
10288
- const [resolvedRelationships, store, , remoteTableId] =
10289
- getRelationshipsStoreTableIds(
10290
- useRelationshipsOrRelationshipsById(relationships),
10291
- relationshipId,
10292
- );
10293
- const rowId = useRemoteRowId(
10294
- relationshipId,
10295
- localRowId,
10296
- resolvedRelationships,
10297
- );
10298
- return wrap(
10299
- isUndefined(remoteTableId) || isUndefined(rowId)
10300
- ? null
10301
- : /* @__PURE__ */ jsx(
10302
- Row,
10303
- {
10304
- ...getProps(getRowComponentProps, rowId),
10305
- tableId: remoteTableId,
10306
- rowId,
10307
- store,
10308
- debugIds,
10309
- },
10310
- rowId,
10311
- ),
10312
- void 0,
10313
- debugIds,
10314
- localRowId,
10315
- );
10316
- };
10317
-
10318
- const ResultSortedTableView = ({cellId, descending, offset, limit, ...props}) =>
10319
- resultTableView(
10320
- props,
10321
- useResultSortedRowIds(
10322
- props.queryId,
10323
- cellId,
10324
- descending,
10325
- offset,
10326
- limit,
10327
- props.queries,
10328
- ),
10329
- );
10330
-
10331
- const ResultTableView = (props) =>
10332
- resultTableView(props, useResultRowIds(props.queryId, props.queries));
10333
-
10334
- const SortedTableView = ({cellId, descending, offset, limit, ...props}) =>
10335
- tableView(
10336
- props,
10337
- useSortedRowIds(
10338
- props.tableId,
10339
- cellId,
10340
- descending,
10341
- offset,
10342
- limit,
10343
- props.store,
10344
- ),
10345
- );
10346
-
10347
- const TableView$1 = (props) =>
10348
- tableView(props, useRowIds(props.tableId, props.store));
10349
-
10350
- const TablesView$1 = ({
10351
- store,
10352
- tableComponent: Table = TableView$1,
10353
- getTableComponentProps,
10354
- separator,
10355
- debugIds,
10356
- }) =>
10357
- wrap(
10358
- arrayMap(useTableIds(store), (tableId) =>
10359
- /* @__PURE__ */ jsx(
10360
- Table,
10361
- {
10362
- ...getProps(getTableComponentProps, tableId),
10363
- tableId,
10364
- store,
10365
- debugIds,
10366
- },
10367
- tableId,
10368
- ),
10369
- ),
10370
- separator,
10371
- );
10372
-
10373
- const ValueView = ({valueId, store, debugIds}) =>
10374
- wrap(
10375
- EMPTY_STRING + (useValue(valueId, store) ?? EMPTY_STRING),
10376
- void 0,
10377
- debugIds,
10378
- valueId,
10379
- );
10380
-
10381
- const ValuesView$1 = ({
10382
- store,
10383
- valueComponent: Value = ValueView,
10384
- getValueComponentProps,
10385
- separator,
10386
- debugIds,
10387
- }) =>
10388
- wrap(
10389
- arrayMap(useValueIds(store), (valueId) =>
10390
- /* @__PURE__ */ jsx(
10391
- Value,
10392
- {
10393
- ...getProps(getValueComponentProps, valueId),
10394
- valueId,
10395
- store,
10396
- debugIds,
10397
- },
10398
- valueId,
10399
- ),
10400
- ),
10401
- separator,
10402
- );
10403
-
10404
- const useDottedCellIds = (tableId, store) =>
10405
- arrayMap(useTableCellIds(tableId, store), (cellId) => tableId + DOT + cellId);
10406
- const RelationshipInHtmlRow = ({
10407
- localRowId,
10408
- params: [
10409
- idColumn,
10410
- cells,
10411
- localTableId,
10412
- remoteTableId,
10413
- relationshipId,
10414
- relationships,
10415
- store,
10416
- extraCellsBefore,
10417
- extraCellsAfter,
10418
- ],
10419
- }) => {
10420
- const remoteRowId = useRemoteRowId(relationshipId, localRowId, relationships);
10421
- const rowProps = {
10422
- tableId: localTableId ?? '',
10423
- rowId: localRowId,
10424
- store,
10425
- };
10426
- return /* @__PURE__ */ jsxs('tr', {
10427
- children: [
10428
- extraRowCells(extraCellsBefore, rowProps),
10429
- isFalse(idColumn)
10430
- ? null
10431
- : /* @__PURE__ */ jsxs(Fragment, {
10432
- children: [
10433
- /* @__PURE__ */ jsx('th', {
10434
- title: localRowId,
10435
- children: localRowId,
10436
- }),
10437
- /* @__PURE__ */ jsx('th', {
10438
- title: remoteRowId,
10439
- children: remoteRowId,
10440
- }),
10441
- ],
10442
- }),
10443
- objToArray(
10444
- cells,
10445
- ({component: CellView2, getComponentProps}, compoundCellId) => {
10446
- const [tableId, cellId] = strSplit(compoundCellId, DOT, 2);
10447
- const rowId =
10448
- tableId === localTableId
10449
- ? localRowId
10450
- : tableId === remoteTableId
10451
- ? remoteRowId
10452
- : void 0;
10453
- return isUndefined(rowId)
10454
- ? null
10455
- : /* @__PURE__ */ jsx(
10456
- 'td',
10457
- {
10458
- children: /* @__PURE__ */ jsx(CellView2, {
10459
- ...getProps(getComponentProps, rowId, cellId),
10460
- store,
10461
- tableId,
10462
- rowId,
10463
- cellId,
10464
- }),
10465
- },
10466
- compoundCellId,
10467
- );
10468
- },
10469
- ),
10470
- extraRowCells(extraCellsAfter, rowProps, 1),
10471
- ],
10472
- });
10473
- };
10474
- const RelationshipInHtmlTable = ({
10475
- relationshipId,
10476
- relationships,
10477
- editable,
10478
- customCells,
10479
- extraCellsBefore,
10480
- extraCellsAfter,
10481
- className,
10482
- headerRow,
10483
- idColumn = true,
10484
- }) => {
10485
- const [resolvedRelationships, store, localTableId, remoteTableId] =
10486
- getRelationshipsStoreTableIds(
10487
- useRelationshipsOrRelationshipsById(relationships),
10488
- relationshipId,
10489
- );
10490
- const cells = useCells(
10491
- [
10492
- ...useDottedCellIds(localTableId, store),
10493
- ...useDottedCellIds(remoteTableId, store),
10494
- ],
10495
- customCells,
10496
- editable ? EditableCellView : CellView,
10497
- );
10498
- const params = useParams(
10499
- idColumn,
10500
- cells,
10501
- localTableId,
10502
- remoteTableId,
10503
- relationshipId,
10504
- resolvedRelationships,
10505
- store,
10506
- extraCellsBefore,
10507
- extraCellsAfter,
10508
- );
10509
- return /* @__PURE__ */ jsxs('table', {
10510
- className,
10511
- children: [
10512
- isFalse(headerRow)
10513
- ? null
10514
- : /* @__PURE__ */ jsx('thead', {
10515
- children: /* @__PURE__ */ jsxs('tr', {
10516
- children: [
10517
- extraHeaders(extraCellsBefore),
10518
- isFalse(idColumn)
10519
- ? null
10520
- : /* @__PURE__ */ jsxs(Fragment, {
10521
- children: [
10522
- /* @__PURE__ */ jsxs('th', {
10523
- children: [localTableId, '.Id'],
10524
- }),
10525
- /* @__PURE__ */ jsxs('th', {
10526
- children: [remoteTableId, '.Id'],
10527
- }),
10528
- ],
10529
- }),
10530
- objToArray(cells, ({label}, cellId) =>
10531
- /* @__PURE__ */ jsx('th', {children: label}, cellId),
10532
- ),
10533
- extraHeaders(extraCellsAfter, 1),
10534
- ],
10535
- }),
10536
- }),
10537
- /* @__PURE__ */ jsx('tbody', {
10538
- children: arrayMap(useRowIds(localTableId, store), (localRowId) =>
10539
- /* @__PURE__ */ jsx(
10540
- RelationshipInHtmlRow,
10541
- {
10542
- localRowId,
10543
- params,
10544
- },
10545
- localRowId,
10546
- ),
10547
- ),
10548
- }),
10549
- ],
10550
- });
10551
- };
10552
-
10553
- const LEFT_ARROW = '\u2190';
10554
- const RIGHT_ARROW = '\u2192';
10555
- const useSortingAndPagination = (
10556
- cellId,
10557
- descending = false,
10558
- sortOnClick,
10559
- offset = 0,
10560
- limit,
10561
- total,
10562
- paginator,
10563
- onChange,
10564
- ) => {
10565
- const [[currentCellId, currentDescending, currentOffset], setState] =
10566
- useState([cellId, descending, offset]);
10567
- const setStateAndChange = useCallback(
10568
- (sortAndOffset) => {
10569
- setState(sortAndOffset);
10570
- onChange?.(sortAndOffset);
10571
- },
10572
- [onChange],
10573
- );
10574
- const handleSort = useCallbackOrUndefined(
10575
- (cellId2) =>
10576
- setStateAndChange([
10577
- cellId2,
10578
- cellId2 == currentCellId ? !currentDescending : false,
10579
- currentOffset,
10580
- ]),
10581
- [setStateAndChange, currentCellId, currentDescending, currentOffset],
10582
- sortOnClick,
10583
- );
10584
- const handleChangeOffset = useCallback(
10585
- (offset2) => setStateAndChange([currentCellId, currentDescending, offset2]),
10586
- [setStateAndChange, currentCellId, currentDescending],
10587
- );
10588
- const PaginatorComponent = isTrue(paginator)
10589
- ? SortedTablePaginator
10590
- : paginator;
10591
- return [
10592
- [currentCellId, currentDescending, currentOffset],
10593
- handleSort,
10594
- useMemo(
10595
- () =>
10596
- isFalse(paginator)
10597
- ? null
10598
- : /* @__PURE__ */ jsx(PaginatorComponent, {
10599
- offset: currentOffset,
10600
- limit,
10601
- total,
10602
- onChange: handleChangeOffset,
10603
- }),
10604
- [
10605
- paginator,
10606
- PaginatorComponent,
10607
- currentOffset,
10608
- limit,
10609
- total,
10610
- handleChangeOffset,
10611
- ],
10612
- ),
10613
- ];
10614
- };
10615
- const SortedTablePaginator = ({
10616
- onChange,
10617
- total,
10618
- offset = 0,
10619
- limit = total,
10620
- singular = 'row',
10621
- plural = singular + 's',
10622
- }) => {
10623
- if (offset > total || offset < 0) {
10624
- offset = 0;
10625
- onChange(0);
10626
- }
10627
- const handlePrevClick = useCallbackOrUndefined(
10628
- () => onChange(offset - limit),
10629
- [onChange, offset, limit],
10630
- offset > 0,
10631
- );
10632
- const handleNextClick = useCallbackOrUndefined(
10633
- () => onChange(offset + limit),
10634
- [onChange, offset, limit],
10635
- offset + limit < total,
10636
- );
10637
- return /* @__PURE__ */ jsxs(Fragment, {
10638
- children: [
10639
- total > limit &&
10640
- /* @__PURE__ */ jsxs(Fragment, {
10641
- children: [
10642
- /* @__PURE__ */ jsx('button', {
10643
- className: 'previous',
10644
- disabled: offset == 0,
10645
- onClick: handlePrevClick,
10646
- children: LEFT_ARROW,
10647
- }),
10648
- /* @__PURE__ */ jsx('button', {
10649
- className: 'next',
10650
- disabled: offset + limit >= total,
10651
- onClick: handleNextClick,
10652
- children: RIGHT_ARROW,
10653
- }),
10654
- offset + 1,
10655
- ' to ',
10656
- mathMin(total, offset + limit),
10657
- ' of ',
10658
- ],
10659
- }),
10660
- total,
10661
- ' ',
10662
- total != 1 ? plural : singular,
10663
- ],
10664
- });
10665
- };
10666
-
10667
- const ResultSortedTableInHtmlTable = ({
10668
- queryId,
10669
- cellId,
10670
- descending,
10671
- offset,
10672
- limit,
10673
- queries,
10674
- sortOnClick,
10675
- paginator = false,
10676
- customCells,
10677
- extraCellsBefore,
10678
- extraCellsAfter,
10679
- onChange,
10680
- ...props
10681
- }) => {
10682
- const [sortAndOffset, handleSort, paginatorComponent] =
10683
- useSortingAndPagination(
10684
- cellId,
10685
- descending,
10686
- sortOnClick,
10687
- offset,
10688
- limit,
10689
- useResultRowCount(queryId, queries),
10690
- paginator,
10691
- onChange,
10692
- );
10693
- return /* @__PURE__ */ jsx(HtmlTable, {
10694
- ...props,
10695
- params: useParams(
10696
- useCells(
10697
- useResultTableCellIds(queryId, queries),
10698
- customCells,
10699
- ResultCellView,
10700
- ),
10701
- useQueriesCellComponentProps(queries, queryId),
10702
- useResultSortedRowIds(queryId, ...sortAndOffset, limit, queries),
10703
- extraCellsBefore,
10704
- extraCellsAfter,
10705
- sortAndOffset,
10706
- handleSort,
10707
- paginatorComponent,
10708
- ),
10709
- });
10710
- };
10711
-
10712
- const ResultTableInHtmlTable = ({
10713
- queryId,
10714
- queries,
10715
- customCells,
10716
- extraCellsBefore,
10717
- extraCellsAfter,
10718
- ...props
10719
- }) =>
10720
- /* @__PURE__ */ jsx(HtmlTable, {
10721
- ...props,
10722
- params: useParams(
10723
- useCells(
10724
- useResultTableCellIds(queryId, queries),
10725
- customCells,
10726
- ResultCellView,
10727
- ),
10728
- useQueriesCellComponentProps(queries, queryId),
10729
- useResultRowIds(queryId, queries),
10730
- extraCellsBefore,
10731
- extraCellsAfter,
10732
- ),
10733
- });
10734
-
10735
- const SliceInHtmlTable = ({
10736
- indexId,
10737
- sliceId,
10738
- indexes,
10739
- editable,
10740
- customCells,
10741
- extraCellsBefore,
10742
- extraCellsAfter,
10743
- ...props
10744
- }) => {
10745
- const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
10746
- useIndexesOrIndexesById(indexes),
10747
- indexId,
10748
- );
10749
- return /* @__PURE__ */ jsx(HtmlTable, {
10750
- ...props,
10751
- params: useParams(
10752
- useCells(
10753
- useTableCellIds(tableId, store),
10754
- customCells,
10755
- editable ? EditableCellView : CellView,
10756
- ),
10757
- useStoreCellComponentProps(store, tableId),
10758
- useSliceRowIds(indexId, sliceId, resolvedIndexes),
10759
- extraCellsBefore,
10760
- extraCellsAfter,
10761
- ),
10762
- });
10763
- };
10764
-
10765
- const SortedTableInHtmlTable = ({
10766
- tableId,
10767
- cellId,
10768
- descending,
10769
- offset,
10770
- limit,
10771
- store,
10772
- editable,
10773
- sortOnClick,
10774
- paginator = false,
10775
- onChange,
10776
- customCells,
10777
- extraCellsBefore,
10778
- extraCellsAfter,
10779
- ...props
10780
- }) => {
10781
- const [sortAndOffset, handleSort, paginatorComponent] =
10782
- useSortingAndPagination(
10783
- cellId,
10784
- descending,
10785
- sortOnClick,
10786
- offset,
10787
- limit,
10788
- useRowCount(tableId, store),
10789
- paginator,
10790
- onChange,
10791
- );
10792
- return /* @__PURE__ */ jsx(HtmlTable, {
10793
- ...props,
10794
- params: useParams(
10795
- useCells(
10796
- useTableCellIds(tableId, store),
10797
- customCells,
10798
- editable ? EditableCellView : CellView,
10799
- ),
10800
- useStoreCellComponentProps(store, tableId),
10801
- useSortedRowIds(tableId, ...sortAndOffset, limit, store),
10802
- extraCellsBefore,
10803
- extraCellsAfter,
10804
- sortAndOffset,
10805
- handleSort,
10806
- paginatorComponent,
10807
- ),
10808
- });
10809
- };
10810
-
10811
- const TableInHtmlTable = ({
10812
- tableId,
10813
- store,
10814
- editable,
10815
- customCells,
10816
- extraCellsBefore,
10817
- extraCellsAfter,
10818
- ...props
10819
- }) =>
10820
- /* @__PURE__ */ jsx(HtmlTable, {
10821
- ...props,
10822
- params: useParams(
10823
- useCells(
10824
- useTableCellIds(tableId, store),
10825
- customCells,
10826
- editable ? EditableCellView : CellView,
10827
- ),
10828
- useStoreCellComponentProps(store, tableId),
10829
- useRowIds(tableId, store),
10830
- extraCellsBefore,
10831
- extraCellsAfter,
10832
- ),
10833
- });
10834
-
10835
- const extraValueCells = (
10836
- extraValueCells2 = [],
10837
- extraValueCellProps,
10838
- after = 0,
10839
- ) =>
10840
- arrayMap(extraValueCells2, ({component: Component}, index) =>
10841
- /* @__PURE__ */ jsx(
10842
- 'td',
10843
- {
10844
- className: EXTRA,
10845
- children: /* @__PURE__ */ jsx(Component, {...extraValueCellProps}),
10846
- },
10847
- extraKey(index, after),
10848
- ),
10849
- );
10850
- const ValuesInHtmlTable = ({
10851
- store,
10852
- editable = false,
10853
- valueComponent: Value = editable ? EditableValueView : ValueView,
10854
- getValueComponentProps,
10855
- extraCellsBefore,
10856
- extraCellsAfter,
10857
- className,
10858
- headerRow,
10859
- idColumn,
10860
- }) =>
10861
- /* @__PURE__ */ jsxs('table', {
10862
- className,
10863
- children: [
10864
- headerRow === false
10865
- ? null
10866
- : /* @__PURE__ */ jsx('thead', {
10867
- children: /* @__PURE__ */ jsxs('tr', {
10868
- children: [
10869
- extraHeaders(extraCellsBefore),
10870
- idColumn === false
10871
- ? null
10872
- : /* @__PURE__ */ jsx('th', {children: 'Id'}),
10873
- /* @__PURE__ */ jsx('th', {children: VALUE}),
10874
- extraHeaders(extraCellsAfter, 1),
10875
- ],
10876
- }),
10877
- }),
10878
- /* @__PURE__ */ jsx('tbody', {
10879
- children: arrayMap(useValueIds(store), (valueId) => {
10880
- const valueProps = {valueId, store};
10881
- return /* @__PURE__ */ jsxs(
10882
- 'tr',
10883
- {
10884
- children: [
10885
- extraValueCells(extraCellsBefore, valueProps),
10886
- isFalse(idColumn)
10887
- ? null
10888
- : /* @__PURE__ */ jsx('th', {
10889
- title: valueId,
10890
- children: valueId,
10891
- }),
10892
- /* @__PURE__ */ jsx('td', {
10893
- children: /* @__PURE__ */ jsx(Value, {
10894
- ...getProps(getValueComponentProps, valueId),
10895
- ...valueProps,
10896
- }),
10897
- }),
10898
- extraValueCells(extraCellsAfter, valueProps, 1),
10899
- ],
10900
- },
10901
- valueId,
10902
- );
10903
- }),
10904
- }),
10905
- ],
10906
- });
10907
-
10908
- const UNIQUE_ID = 'tinybaseInspector';
10909
- const TITLE = 'TinyBase Inspector';
10910
- const POSITIONS = ['left', 'top', 'bottom', 'right', 'full'];
10911
- const STATE_TABLE = 'state';
10912
- const SORT_CELL = 'sort';
10913
- const OPEN_CELL = 'open';
10914
- const POSITION_VALUE = 'position';
10915
- const OPEN_VALUE = OPEN_CELL;
10916
- const EDITABLE_CELL = 'editable';
10917
- const getUniqueId = (...args) => jsonStringWithMap(args);
10918
- const sortedIdsMap = (ids, callback) => arrayMap(arraySort([...ids]), callback);
10919
- const useEditable = (uniqueId, s) => [
10920
- !!useCell(STATE_TABLE, uniqueId, EDITABLE_CELL, s),
10921
- useCallback(
10922
- (event) => {
10923
- s.setCell(STATE_TABLE, uniqueId, EDITABLE_CELL, (editable) => !editable);
10924
- event.preventDefault();
10925
- },
10926
- [s, uniqueId],
10927
- ),
10928
- ];
10929
-
10930
- const Nub = ({s}) => {
10931
- const position = useValue(POSITION_VALUE, s) ?? 1;
10932
- const handleOpen = useSetValueCallback(OPEN_VALUE, () => true, [], s);
10933
- return useValue(OPEN_VALUE, s)
10934
- ? null
10935
- : /* @__PURE__ */ jsx('img', {
10936
- onClick: handleOpen,
10937
- title: TITLE,
10938
- 'data-position': position,
10939
- });
10940
- };
10941
-
10942
- const Details = ({uniqueId, title, editable, handleEditable, children, s}) => {
10943
- const open = !!useCell(STATE_TABLE, uniqueId, OPEN_CELL, s);
10944
- const handleToggle = useSetCellCallback(
10945
- STATE_TABLE,
10946
- uniqueId,
10947
- OPEN_CELL,
10948
- (event) => event[CURRENT_TARGET].open,
10949
- [],
10950
- s,
10951
- );
10952
- return /* @__PURE__ */ jsxs('details', {
10953
- open,
10954
- onToggle: handleToggle,
10955
- children: [
10956
- /* @__PURE__ */ jsxs('summary', {
10957
- children: [
10958
- /* @__PURE__ */ jsx('span', {children: title}),
10959
- handleEditable
10960
- ? /* @__PURE__ */ jsx('img', {
10961
- onClick: handleEditable,
10962
- className: editable ? 'done' : 'edit',
10963
- title: editable ? 'Done editing' : 'Edit',
10964
- })
10965
- : null,
10966
- ],
10967
- }),
10968
- /* @__PURE__ */ jsx('div', {children}),
10969
- ],
10970
- });
10971
- };
10972
-
10973
- const IndexView = ({indexes, indexesId, indexId, s}) =>
10974
- /* @__PURE__ */ jsx(Details, {
10975
- uniqueId: getUniqueId('i', indexesId, indexId),
10976
- title: 'Index: ' + indexId,
10977
- s,
10978
- children: arrayMap(useSliceIds(indexId, indexes), (sliceId) =>
10979
- /* @__PURE__ */ jsx(
10980
- SliceView,
10981
- {
10982
- indexes,
10983
- indexesId,
10984
- indexId,
10985
- sliceId,
10986
- s,
10987
- },
10988
- sliceId,
10989
- ),
10990
- ),
10991
- });
10992
- const SliceView = ({indexes, indexesId, indexId, sliceId, s}) => {
10993
- const uniqueId = getUniqueId('i', indexesId, indexId, sliceId);
10994
- const [editable, handleEditable] = useEditable(uniqueId, s);
10995
- return /* @__PURE__ */ jsx(Details, {
10996
- uniqueId,
10997
- title: 'Slice: ' + sliceId,
10998
- editable,
10999
- handleEditable,
11000
- s,
11001
- children: /* @__PURE__ */ jsx(SliceInHtmlTable, {
11002
- sliceId,
11003
- indexId,
11004
- indexes,
11005
- editable,
11006
- }),
11007
- });
11008
- };
11009
- const IndexesView = ({indexesId, s}) => {
11010
- const indexes = useIndexes(indexesId);
11011
- const indexIds = useIndexIds(indexes);
11012
- return isUndefined(indexes)
11013
- ? null
11014
- : /* @__PURE__ */ jsx(Details, {
11015
- uniqueId: getUniqueId('i', indexesId),
11016
- title: 'Indexes: ' + (indexesId ?? DEFAULT),
11017
- s,
11018
- children: arrayIsEmpty(indexIds)
11019
- ? 'No indexes defined'
11020
- : sortedIdsMap(indexIds, (indexId) =>
11021
- /* @__PURE__ */ jsx(
11022
- IndexView,
11023
- {
11024
- indexes,
11025
- indexesId,
11026
- indexId,
11027
- s,
11028
- },
11029
- indexId,
11030
- ),
11031
- ),
11032
- });
11033
- };
11034
-
11035
- const MetricRow = ({metrics, metricId}) =>
11036
- /* @__PURE__ */ jsxs('tr', {
11037
- children: [
11038
- /* @__PURE__ */ jsx('th', {title: metricId, children: metricId}),
11039
- /* @__PURE__ */ jsx('td', {children: metrics?.getTableId(metricId)}),
11040
- /* @__PURE__ */ jsx('td', {children: useMetric(metricId, metrics)}),
11041
- ],
11042
- });
11043
- const MetricsView = ({metricsId, s}) => {
11044
- const metrics = useMetrics(metricsId);
11045
- const metricIds = useMetricIds(metrics);
11046
- return isUndefined(metrics)
11047
- ? null
11048
- : /* @__PURE__ */ jsx(Details, {
11049
- uniqueId: getUniqueId('m', metricsId),
11050
- title: 'Metrics: ' + (metricsId ?? DEFAULT),
11051
- s,
11052
- children: arrayIsEmpty(metricIds)
11053
- ? 'No metrics defined'
11054
- : /* @__PURE__ */ jsxs('table', {
11055
- children: [
11056
- /* @__PURE__ */ jsxs('thead', {
11057
- children: [
11058
- /* @__PURE__ */ jsx('th', {children: 'Metric Id'}),
11059
- /* @__PURE__ */ jsx('th', {children: 'Table Id'}),
11060
- /* @__PURE__ */ jsx('th', {children: 'Metric'}),
11061
- ],
11062
- }),
11063
- /* @__PURE__ */ jsx('tbody', {
11064
- children: arrayMap(metricIds, (metricId) =>
11065
- /* @__PURE__ */ jsx(
11066
- MetricRow,
11067
- {metrics, metricId},
11068
- metricId,
11069
- ),
11070
- ),
11071
- }),
11072
- ],
11073
- }),
11074
- });
11075
- };
11076
-
11077
- const QueryView = ({queries, queriesId, queryId, s}) => {
11078
- const uniqueId = getUniqueId('q', queriesId, queryId);
11079
- const [cellId, descending, offset] = jsonParse(
11080
- useCell(STATE_TABLE, uniqueId, SORT_CELL, s) ?? '[]',
11081
- );
11082
- const handleChange = useSetCellCallback(
11083
- STATE_TABLE,
11084
- uniqueId,
11085
- SORT_CELL,
11086
- jsonStringWithMap,
11087
- [],
11088
- s,
11089
- );
11090
- return /* @__PURE__ */ jsx(Details, {
11091
- uniqueId,
11092
- title: 'Query: ' + queryId,
11093
- s,
11094
- children: /* @__PURE__ */ jsx(ResultSortedTableInHtmlTable, {
11095
- queryId,
11096
- queries,
11097
- cellId,
11098
- descending,
11099
- offset,
11100
- limit: 10,
11101
- paginator: true,
11102
- sortOnClick: true,
11103
- onChange: handleChange,
11104
- }),
11105
- });
11106
- };
11107
- const QueriesView = ({queriesId, s}) => {
11108
- const queries = useQueries(queriesId);
11109
- const queryIds = useQueryIds(queries);
11110
- return isUndefined(queries)
11111
- ? null
11112
- : /* @__PURE__ */ jsx(Details, {
11113
- uniqueId: getUniqueId('q', queriesId),
11114
- title: 'Queries: ' + (queriesId ?? DEFAULT),
11115
- s,
11116
- children: arrayIsEmpty(queryIds)
11117
- ? 'No queries defined'
11118
- : sortedIdsMap(queryIds, (queryId) =>
11119
- /* @__PURE__ */ jsx(
11120
- QueryView,
11121
- {
11122
- queries,
11123
- queriesId,
11124
- queryId,
11125
- s,
11126
- },
11127
- queryId,
11128
- ),
11129
- ),
11130
- });
11131
- };
11132
-
11133
- const RelationshipView = ({
11134
- relationships,
11135
- relationshipsId,
11136
- relationshipId,
11137
- s,
11138
- }) => {
11139
- const uniqueId = getUniqueId('r', relationshipsId, relationshipId);
11140
- const [editable, handleEditable] = useEditable(uniqueId, s);
11141
- return /* @__PURE__ */ jsx(Details, {
11142
- uniqueId,
11143
- title: 'Relationship: ' + relationshipId,
11144
- editable,
11145
- handleEditable,
11146
- s,
11147
- children: /* @__PURE__ */ jsx(RelationshipInHtmlTable, {
11148
- relationshipId,
11149
- relationships,
11150
- editable,
11151
- }),
11152
- });
11153
- };
11154
- const RelationshipsView = ({relationshipsId, s}) => {
11155
- const relationships = useRelationships(relationshipsId);
11156
- const relationshipIds = useRelationshipIds(relationships);
11157
- return isUndefined(relationships)
11158
- ? null
11159
- : /* @__PURE__ */ jsx(Details, {
11160
- uniqueId: getUniqueId('r', relationshipsId),
11161
- title: 'Relationships: ' + (relationshipsId ?? DEFAULT),
11162
- s,
11163
- children: arrayIsEmpty(relationshipIds)
11164
- ? 'No relationships defined'
11165
- : sortedIdsMap(relationshipIds, (relationshipId) =>
11166
- /* @__PURE__ */ jsx(
11167
- RelationshipView,
11168
- {
11169
- relationships,
11170
- relationshipsId,
11171
- relationshipId,
11172
- s,
11173
- },
11174
- relationshipId,
11175
- ),
11176
- ),
11177
- });
11178
- };
11179
-
11180
- const getNewIdFromSuggestedId = (suggestedId, has) => {
11181
- let newId;
11182
- let suffix = 0;
11183
- while (
11184
- has(
11185
- (newId =
11186
- suggestedId +
11187
- (suffix > 0 ? ' (copy' + (suffix > 1 ? ' ' + suffix : '') + ')' : '')),
11188
- )
11189
- ) {
11190
- suffix++;
11191
- }
11192
- return newId;
11193
- };
11194
- const ConfirmableActions = ({actions, ...props}) => {
11195
- const [confirming, setConfirming] = useState();
11196
- const handleDone = useCallback(() => setConfirming(void 0), []);
11197
- useEffect(() => {
11198
- if (!isUndefined(confirming)) {
11199
- const handleKeyDown = (e) => {
11200
- if (!isUndefined(confirming) && e.key === 'Escape') {
11201
- e.preventDefault();
11202
- handleDone();
11203
- }
11204
- };
11205
- document.addEventListener('keydown', handleKeyDown);
11206
- return () => document.removeEventListener('keydown', handleKeyDown);
11207
- }
11208
- }, [confirming, handleDone]);
11209
- if (!isUndefined(confirming)) {
11210
- const [, , Component] = actions[confirming];
11211
- return /* @__PURE__ */ jsxs(Fragment, {
11212
- children: [
11213
- /* @__PURE__ */ jsx(Component, {onDone: handleDone, ...props}),
11214
- /* @__PURE__ */ jsx('img', {
11215
- onClick: handleDone,
11216
- title: 'Cancel',
11217
- className: 'cancel',
11218
- }),
11219
- ],
11220
- });
11221
- } else {
11222
- return actions.map(([icon, title], index) =>
11223
- /* @__PURE__ */ jsx(
11224
- 'img',
11225
- {
11226
- title,
11227
- className: icon,
11228
- onClick: () => setConfirming(index),
11229
- },
11230
- index,
11231
- ),
11232
- );
11233
- }
11234
- };
11235
- const NewId = ({onDone, suggestedId, has, set, prompt = 'New Id'}) => {
11236
- const [newId, setNewId] = useState(suggestedId);
11237
- const [newIdOk, setNewIdOk] = useState(true);
11238
- const [previousSuggestedId, setPreviousSuggestedNewId] =
11239
- useState(suggestedId);
11240
- const handleNewIdChange = (e) => {
11241
- setNewId(e.target.value);
11242
- setNewIdOk(!has(e.target.value));
11243
- };
11244
- const handleClick = useCallback(() => {
11245
- if (has(newId)) {
11246
- setNewIdOk(false);
11247
- } else {
11248
- set(newId);
11249
- onDone();
11250
- }
11251
- }, [onDone, setNewIdOk, has, set, newId]);
11252
- const handleKeyDown = useCallback(
11253
- (e) => {
11254
- if (e.key === 'Enter') {
11255
- e.preventDefault();
11256
- handleClick();
11257
- }
11258
- },
11259
- [handleClick],
11260
- );
11261
- if (suggestedId != previousSuggestedId) {
11262
- setNewId(suggestedId);
11263
- setPreviousSuggestedNewId(suggestedId);
11264
- }
11265
- return /* @__PURE__ */ jsxs(Fragment, {
11266
- children: [
11267
- prompt + ': ',
11268
- /* @__PURE__ */ jsx('input', {
11269
- type: 'text',
11270
- value: newId,
11271
- onChange: handleNewIdChange,
11272
- onKeyDown: handleKeyDown,
11273
- autoFocus: true,
11274
- }),
11275
- ' ',
11276
- /* @__PURE__ */ jsx('img', {
11277
- onClick: handleClick,
11278
- title: newIdOk ? 'Confirm' : 'Id already exists',
11279
- className: newIdOk ? 'ok' : 'okDis',
11280
- }),
11281
- ],
11282
- });
11283
- };
11284
- const Delete = ({onClick, prompt = 'Delete'}) => {
11285
- const handleKeyDown = useCallback(
11286
- (e) => {
11287
- if (e.key === 'Enter') {
11288
- e.preventDefault();
11289
- onClick();
11290
- }
11291
- },
11292
- [onClick],
11293
- );
11294
- useEffect(() => {
11295
- document.addEventListener('keydown', handleKeyDown);
11296
- return () => document.removeEventListener('keydown', handleKeyDown);
11297
- }, [handleKeyDown]);
11298
- return /* @__PURE__ */ jsxs(Fragment, {
11299
- children: [
11300
- prompt,
11301
- '? ',
11302
- /* @__PURE__ */ jsx('img', {onClick, title: 'Confirm', className: 'ok'}),
11303
- ],
11304
- });
11305
- };
11306
- const Actions = ({left, right}) =>
11307
- /* @__PURE__ */ jsxs('div', {
11308
- className: 'actions',
11309
- children: [
11310
- /* @__PURE__ */ jsx('div', {children: left}),
11311
- /* @__PURE__ */ jsx('div', {children: right}),
11312
- ],
11313
- });
11314
-
11315
- const useHasTableCallback = (storeOrStoreId) => {
11316
- const store = useStoreOrStoreById(storeOrStoreId);
11317
- return useCallback((tableId) => store?.hasTable(tableId) ?? false, [store]);
11318
- };
11319
- const AddTable = ({onDone, store}) => {
11320
- const has = useHasTableCallback(store);
11321
- return /* @__PURE__ */ jsx(NewId, {
11322
- onDone,
11323
- suggestedId: getNewIdFromSuggestedId('table', has),
11324
- has,
11325
- set: useSetTableCallback(
11326
- (newId) => newId,
11327
- () => ({row: {cell: ''}}),
11328
- [],
11329
- store,
11330
- ),
11331
- prompt: 'Add table',
11332
- });
11333
- };
11334
- const DeleteTables = ({onDone, store}) =>
11335
- /* @__PURE__ */ jsx(Delete, {
11336
- onClick: useDelTablesCallback(store, onDone),
11337
- prompt: 'Delete all tables',
11338
- });
11339
- const TablesActions = ({store}) =>
11340
- /* @__PURE__ */ jsx(Actions, {
11341
- left: /* @__PURE__ */ jsx(ConfirmableActions, {
11342
- actions: [['add', 'Add table', AddTable]],
11343
- store,
11344
- }),
11345
- right: useHasTables(store)
11346
- ? /* @__PURE__ */ jsx(ConfirmableActions, {
11347
- actions: [['delete', 'Delete all tables', DeleteTables]],
11348
- store,
11349
- })
11350
- : null,
11351
- });
11352
- const AddRow = ({onDone, tableId, store}) => {
11353
- const has = useHasRowCallback(store, tableId);
11354
- return /* @__PURE__ */ jsx(NewId, {
11355
- onDone,
11356
- suggestedId: getNewIdFromSuggestedId('row', has),
11357
- has,
11358
- set: useSetRowCallback(
11359
- tableId,
11360
- (newId) => newId,
11361
- (_, store2) =>
11362
- objNew(
11363
- arrayMap(store2.getTableCellIds(tableId), (cellId) => [cellId, '']),
11364
- ),
11365
- ),
11366
- prompt: 'Add row',
11367
- });
11368
- };
11369
- const CloneTable = ({onDone, tableId, store: storeOrStoreId}) => {
11370
- const store = useStoreOrStoreById(storeOrStoreId);
11371
- const has = useHasTableCallback(store);
11372
- return /* @__PURE__ */ jsx(NewId, {
11373
- onDone,
11374
- suggestedId: getNewIdFromSuggestedId(tableId, has),
11375
- has,
11376
- set: useSetTableCallback(
11377
- (tableId2) => tableId2,
11378
- (_, store2) => store2.getTable(tableId),
11379
- ),
11380
- prompt: 'Clone table to',
11381
- });
11382
- };
11383
- const DeleteTable = ({onDone, tableId, store}) =>
11384
- /* @__PURE__ */ jsx(Delete, {
11385
- onClick: useDelTableCallback(tableId, store, onDone),
11386
- prompt: 'Delete table',
11387
- });
11388
- const TableActions1 = ({tableId, store}) =>
11389
- /* @__PURE__ */ jsx(ConfirmableActions, {
11390
- actions: [['add', 'Add row', AddRow]],
11391
- store,
11392
- tableId,
11393
- });
11394
- const TableActions2 = ({tableId, store}) =>
11395
- /* @__PURE__ */ jsx(ConfirmableActions, {
11396
- actions: [
11397
- ['clone', 'Clone table', CloneTable],
11398
- ['delete', 'Delete table', DeleteTable],
11399
- ],
11400
- store,
11401
- tableId,
11402
- });
11403
- const useHasRowCallback = (storeOrStoreId, tableId) => {
11404
- const store = useStoreOrStoreById(storeOrStoreId);
11405
- return useCallback(
11406
- (rowId) => store?.hasRow(tableId, rowId) ?? false,
11407
- [store, tableId],
11408
- );
11409
- };
11410
- const AddCell = ({onDone, tableId, rowId, store: storeOrStoreId}) => {
11411
- const store = useStoreOrStoreById(storeOrStoreId);
11412
- const has = useCallback(
11413
- (cellId) => store.hasCell(tableId, rowId, cellId),
11414
- [store, tableId, rowId],
11415
- );
11416
- return /* @__PURE__ */ jsx(NewId, {
11417
- onDone,
11418
- suggestedId: getNewIdFromSuggestedId('cell', has),
11419
- has,
11420
- set: useSetCellCallback(
11421
- tableId,
11422
- rowId,
11423
- (newId) => newId,
11424
- () => '',
11425
- [],
11426
- store,
11427
- ),
11428
- prompt: 'Add cell',
11429
- });
11430
- };
11431
- const CloneRow = ({onDone, tableId, rowId, store: storeOrStoreId}) => {
11432
- const store = useStoreOrStoreById(storeOrStoreId);
11433
- const has = useHasRowCallback(store, tableId);
11434
- return /* @__PURE__ */ jsx(NewId, {
11435
- onDone,
11436
- suggestedId: getNewIdFromSuggestedId(rowId, has),
11437
- has,
11438
- set: useSetRowCallback(
11439
- tableId,
11440
- (newId) => newId,
11441
- (_, store2) => store2.getRow(tableId, rowId),
11442
- [rowId],
11443
- ),
11444
- prompt: 'Clone row to',
11445
- });
11446
- };
11447
- const DeleteRow = ({onDone, tableId, rowId, store}) =>
11448
- /* @__PURE__ */ jsx(Delete, {
11449
- onClick: useDelRowCallback(tableId, rowId, store, onDone),
11450
- prompt: 'Delete row',
11451
- });
11452
- const RowActions = ({tableId, rowId, store}) =>
11453
- /* @__PURE__ */ jsx(ConfirmableActions, {
11454
- actions: [
11455
- ['add', 'Add cell', AddCell],
11456
- ['clone', 'Clone row', CloneRow],
11457
- ['delete', 'Delete row', DeleteRow],
11458
- ],
11459
- store,
11460
- tableId,
11461
- rowId,
11462
- });
11463
- const CellDelete = ({onDone, tableId, rowId, cellId, store}) =>
11464
- /* @__PURE__ */ jsx(Delete, {
11465
- onClick: useDelCellCallback(tableId, rowId, cellId, true, store, onDone),
11466
- prompt: 'Delete cell',
11467
- });
11468
- const CellActions = ({tableId, rowId, cellId, store}) =>
11469
- /* @__PURE__ */ jsx(ConfirmableActions, {
11470
- actions: [['delete', 'Delete cell', CellDelete]],
11471
- store,
11472
- tableId,
11473
- rowId,
11474
- cellId,
11475
- });
11476
-
11477
- const rowActions = [{label: '', component: RowActions}];
11478
- const EditableCellViewWithActions = (props) =>
11479
- /* @__PURE__ */ jsxs(Fragment, {
11480
- children: [
11481
- /* @__PURE__ */ jsx(EditableCellView, {...props}),
11482
- useHasCell(props.tableId, props.rowId, props.cellId, props.store) &&
11483
- /* @__PURE__ */ jsx(CellActions, {...props}),
11484
- ],
11485
- });
11486
- const TableView = ({tableId, store, storeId, s}) => {
11487
- const uniqueId = getUniqueId('t', storeId, tableId);
11488
- const [cellId, descending, offset] = jsonParse(
11489
- useCell(STATE_TABLE, uniqueId, SORT_CELL, s) ?? '[]',
11490
- );
11491
- const handleChange = useSetCellCallback(
11492
- STATE_TABLE,
11493
- uniqueId,
11494
- SORT_CELL,
11495
- jsonStringWithMap,
11496
- [],
11497
- s,
11498
- );
11499
- const [editable, handleEditable] = useEditable(uniqueId, s);
11500
- const CellComponent = editable ? EditableCellViewWithActions : CellView;
11501
- return /* @__PURE__ */ jsxs(Details, {
11502
- uniqueId,
11503
- title: TABLE$1 + ': ' + tableId,
11504
- editable,
11505
- handleEditable,
11506
- s,
11507
- children: [
11508
- /* @__PURE__ */ jsx(SortedTableInHtmlTable, {
11509
- tableId,
11510
- store,
11511
- cellId,
11512
- descending,
11513
- offset,
11514
- limit: 10,
11515
- paginator: true,
11516
- sortOnClick: true,
11517
- onChange: handleChange,
11518
- editable,
11519
- extraCellsAfter: editable ? rowActions : [],
11520
- customCells: objNew(
11521
- arrayMap(useTableCellIds(tableId, store), (cellId2) => [
11522
- cellId2,
11523
- {label: cellId2, component: CellComponent},
11524
- ]),
11525
- ),
11526
- }),
11527
- editable
11528
- ? /* @__PURE__ */ jsxs('div', {
11529
- className: 'actions',
11530
- children: [
11531
- /* @__PURE__ */ jsx('div', {
11532
- children: /* @__PURE__ */ jsx(TableActions1, {tableId, store}),
11533
- }),
11534
- /* @__PURE__ */ jsx('div', {
11535
- children: /* @__PURE__ */ jsx(TableActions2, {tableId, store}),
11536
- }),
11537
- ],
11538
- })
11539
- : null,
11540
- ],
11541
- });
11542
- };
11543
- const TablesView = ({store, storeId, s}) => {
11544
- const uniqueId = getUniqueId('ts', storeId);
11545
- const [editable, handleEditable] = useEditable(uniqueId, s);
11546
- const tableIds = useTableIds(store);
11547
- return /* @__PURE__ */ jsxs(Details, {
11548
- uniqueId,
11549
- title: TABLES,
11550
- editable,
11551
- handleEditable,
11552
- s,
11553
- children: [
11554
- arrayIsEmpty(tableIds)
11555
- ? /* @__PURE__ */ jsx('caption', {children: 'No tables.'})
11556
- : sortedIdsMap(tableIds, (tableId) =>
11557
- /* @__PURE__ */ jsx(
11558
- TableView,
11559
- {
11560
- store,
11561
- storeId,
11562
- tableId,
11563
- s,
11564
- },
11565
- tableId,
11566
- ),
11567
- ),
11568
- editable ? /* @__PURE__ */ jsx(TablesActions, {store}) : null,
11569
- ],
11570
- });
11571
- };
11572
-
11573
- const useHasValueCallback = (storeOrStoreId) => {
11574
- const store = useStoreOrStoreById(storeOrStoreId);
11575
- return useCallback((valueId) => store?.hasValue(valueId) ?? false, [store]);
11576
- };
11577
- const AddValue = ({onDone, store}) => {
11578
- const has = useHasValueCallback(store);
11579
- return /* @__PURE__ */ jsx(NewId, {
11580
- onDone,
11581
- suggestedId: getNewIdFromSuggestedId('value', has),
11582
- has,
11583
- set: useSetValueCallback(
11584
- (newId) => newId,
11585
- () => '',
11586
- [],
11587
- store,
11588
- ),
11589
- prompt: 'Add value',
11590
- });
11591
- };
11592
- const DeleteValues = ({onDone, store}) =>
11593
- /* @__PURE__ */ jsx(Delete, {
11594
- onClick: useDelValuesCallback(store, onDone),
11595
- prompt: 'Delete all values',
11596
- });
11597
- const ValuesActions = ({store}) =>
11598
- /* @__PURE__ */ jsx(Actions, {
11599
- left: /* @__PURE__ */ jsx(ConfirmableActions, {
11600
- actions: [['add', 'Add value', AddValue]],
11601
- store,
11602
- }),
11603
- right: useHasValues(store)
11604
- ? /* @__PURE__ */ jsx(ConfirmableActions, {
11605
- actions: [['delete', 'Delete all values', DeleteValues]],
11606
- store,
11607
- })
11608
- : null,
11609
- });
11610
- const CloneValue = ({onDone, valueId, store}) => {
11611
- const has = useHasValueCallback(store);
11612
- return /* @__PURE__ */ jsx(NewId, {
11613
- onDone,
11614
- suggestedId: getNewIdFromSuggestedId(valueId, has),
11615
- has,
11616
- set: useSetValueCallback(
11617
- (newId) => newId,
11618
- (_, store2) => store2.getValue(valueId) ?? '',
11619
- [valueId],
11620
- store,
11621
- ),
11622
- prompt: 'Clone value to',
11623
- });
11624
- };
11625
- const DeleteValue = ({onDone, valueId, store}) =>
11626
- /* @__PURE__ */ jsx(Delete, {
11627
- onClick: useDelValueCallback(valueId, store, onDone),
11628
- prompt: 'Delete value',
11629
- });
11630
- const ValueActions = ({valueId, store}) =>
11631
- /* @__PURE__ */ jsx(ConfirmableActions, {
11632
- actions: [
11633
- ['clone', 'Clone value', CloneValue],
11634
- ['delete', 'Delete value', DeleteValue],
11635
- ],
11636
- store,
11637
- valueId,
11638
- });
11639
-
11640
- const valueActions = [{label: '', component: ValueActions}];
11641
- const ValuesView = ({store, storeId, s}) => {
11642
- const uniqueId = getUniqueId('v', storeId);
11643
- const [editable, handleEditable] = useEditable(uniqueId, s);
11644
- return /* @__PURE__ */ jsxs(Details, {
11645
- uniqueId,
11646
- title: VALUES,
11647
- editable,
11648
- handleEditable,
11649
- s,
11650
- children: [
11651
- arrayIsEmpty(useValueIds(store))
11652
- ? /* @__PURE__ */ jsx('caption', {children: 'No values.'})
11653
- : /* @__PURE__ */ jsx(ValuesInHtmlTable, {
11654
- store,
11655
- editable,
11656
- extraCellsAfter: editable ? valueActions : [],
11657
- }),
11658
- editable ? /* @__PURE__ */ jsx(ValuesActions, {store}) : null,
11659
- ],
11660
- });
11661
- };
11662
-
11663
- const StoreView = ({storeId, s}) => {
11664
- const store = useStore(storeId);
11665
- return isUndefined(store)
11666
- ? null
11667
- : /* @__PURE__ */ jsxs(Details, {
11668
- uniqueId: getUniqueId('s', storeId),
11669
- title:
11670
- (store.isMergeable() ? 'Mergeable' : '') +
11671
- 'Store: ' +
11672
- (storeId ?? DEFAULT),
11673
- s,
11674
- children: [
11675
- /* @__PURE__ */ jsx(ValuesView, {storeId, store, s}),
11676
- /* @__PURE__ */ jsx(TablesView, {storeId, store, s}),
11677
- ],
11678
- });
11679
- };
11680
-
11681
- const Body = ({s}) => {
11682
- const articleRef = useRef(null);
11683
- const idleCallbackRef = useRef(0);
11684
- const [scrolled, setScrolled] = useState(false);
11685
- const {scrollLeft, scrollTop} = useValues(s);
11686
- useLayoutEffect(() => {
11687
- const article = articleRef.current;
11688
- if (article && !scrolled) {
11689
- const observer = new MutationObserver(() => {
11690
- if (
11691
- article.scrollWidth >= mathFloor(scrollLeft) + article.clientWidth &&
11692
- article.scrollHeight >= mathFloor(scrollTop) + article.clientHeight
11693
- ) {
11694
- article.scrollTo(scrollLeft, scrollTop);
11695
- }
11696
- });
11697
- observer.observe(article, {childList: true, subtree: true});
11698
- return () => observer.disconnect();
11699
- }
11700
- }, [scrolled, scrollLeft, scrollTop]);
11701
- const handleScroll = useCallback(
11702
- (event) => {
11703
- const {scrollLeft: scrollLeft2, scrollTop: scrollTop2} =
11704
- event[CURRENT_TARGET];
11705
- cancelIdleCallback(idleCallbackRef.current);
11706
- idleCallbackRef.current = requestIdleCallback(() => {
11707
- setScrolled(true);
11708
- s.setPartialValues({scrollLeft: scrollLeft2, scrollTop: scrollTop2});
11709
- });
11710
- },
11711
- [s],
11712
- );
11713
- const store = useStore();
11714
- const storeIds = useStoreIds();
11715
- const metrics = useMetrics();
11716
- const metricsIds = useMetricsIds();
11717
- const indexes = useIndexes();
11718
- const indexesIds = useIndexesIds();
11719
- const relationships = useRelationships();
11720
- const relationshipsIds = useRelationshipsIds();
11721
- const queries = useQueries();
11722
- const queriesIds = useQueriesIds();
11723
- return isUndefined(store) &&
11724
- arrayIsEmpty(storeIds) &&
11725
- isUndefined(metrics) &&
11726
- arrayIsEmpty(metricsIds) &&
11727
- isUndefined(indexes) &&
11728
- arrayIsEmpty(indexesIds) &&
11729
- isUndefined(relationships) &&
11730
- arrayIsEmpty(relationshipsIds) &&
11731
- isUndefined(queries) &&
11732
- arrayIsEmpty(queriesIds)
11733
- ? /* @__PURE__ */ jsx('span', {
11734
- className: 'warn',
11735
- children:
11736
- 'There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component.',
11737
- })
11738
- : /* @__PURE__ */ jsxs('article', {
11739
- ref: articleRef,
11740
- onScroll: handleScroll,
11741
- children: [
11742
- /* @__PURE__ */ jsx(StoreView, {s}),
11743
- arrayMap(storeIds, (storeId) =>
11744
- /* @__PURE__ */ jsx(StoreView, {storeId, s}, storeId),
11745
- ),
11746
- /* @__PURE__ */ jsx(MetricsView, {s}),
11747
- arrayMap(metricsIds, (metricsId) =>
11748
- /* @__PURE__ */ jsx(MetricsView, {metricsId, s}, metricsId),
11749
- ),
11750
- /* @__PURE__ */ jsx(IndexesView, {s}),
11751
- arrayMap(indexesIds, (indexesId) =>
11752
- /* @__PURE__ */ jsx(IndexesView, {indexesId, s}, indexesId),
11753
- ),
11754
- /* @__PURE__ */ jsx(RelationshipsView, {s}),
11755
- arrayMap(relationshipsIds, (relationshipsId) =>
11756
- /* @__PURE__ */ jsx(
11757
- RelationshipsView,
11758
- {
11759
- relationshipsId,
11760
- s,
11761
- },
11762
- relationshipsId,
11763
- ),
11764
- ),
11765
- /* @__PURE__ */ jsx(QueriesView, {s}),
11766
- arrayMap(queriesIds, (queriesId) =>
11767
- /* @__PURE__ */ jsx(QueriesView, {queriesId, s}, queriesId),
11768
- ),
11769
- ],
11770
- });
11771
- };
11772
-
11773
- class ErrorBoundary extends PureComponent {
11774
- constructor(props) {
11775
- super(props);
11776
- this.state = {e: 0};
11777
- }
11778
- static getDerivedStateFromError() {
11779
- return {e: 1};
11780
- }
11781
- // eslint-disable-next-line react/no-arrow-function-lifecycle
11782
- componentDidCatch = (error, info) =>
11783
- // eslint-disable-next-line no-console
11784
- console.error(error, info.componentStack);
11785
- render() {
11786
- return this.state.e
11787
- ? /* @__PURE__ */ jsx('span', {
11788
- className: 'warn',
11789
- children: 'Inspector error: please see console for details.',
11790
- })
11791
- : this.props.children;
11792
- }
11793
- }
11794
-
11795
- const Header = ({s}) => {
11796
- const position = useValue(POSITION_VALUE, s) ?? 1;
11797
- const handleClick = () => open('https://tinybase.org', '_blank');
11798
- const handleClose = useSetValueCallback(OPEN_VALUE, () => false, [], s);
11799
- const handleDock = useSetValueCallback(
11800
- POSITION_VALUE,
11801
- (event) => Number(event[CURRENT_TARGET].dataset.id),
11802
- [],
11803
- s,
11804
- );
11805
- return /* @__PURE__ */ jsxs('header', {
11806
- children: [
11807
- /* @__PURE__ */ jsx('img', {
11808
- className: 'flat',
11809
- title: TITLE,
11810
- onClick: handleClick,
11811
- }),
11812
- /* @__PURE__ */ jsx('span', {children: TITLE}),
11813
- arrayMap(POSITIONS, (name, p) =>
11814
- p == position
11815
- ? null
11816
- : /* @__PURE__ */ jsx(
11817
- 'img',
11818
- {
11819
- onClick: handleDock,
11820
- 'data-id': p,
11821
- title: 'Dock to ' + name,
11822
- },
11823
- p,
11824
- ),
11825
- ),
11826
- /* @__PURE__ */ jsx('img', {
11827
- className: 'flat',
11828
- onClick: handleClose,
11829
- title: 'Close',
11830
- }),
11831
- ],
11832
- });
11833
- };
11834
-
11835
- const Panel = ({s}) => {
11836
- const position = useValue(POSITION_VALUE, s) ?? 1;
11837
- return useValue(OPEN_VALUE, s)
11838
- ? /* @__PURE__ */ jsxs('main', {
11839
- 'data-position': position,
11840
- children: [
11841
- /* @__PURE__ */ jsx(Header, {s}),
11842
- /* @__PURE__ */ jsx(ErrorBoundary, {
11843
- children: /* @__PURE__ */ jsx(Body, {s}),
11844
- }),
11845
- ],
11846
- })
11847
- : null;
11848
- };
11849
-
11850
- var img =
11851
- "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";
11852
-
11853
- const PRE_CSS = 'url("';
11854
- const POST_CSS = '")';
11855
- const getCssSvg = (path, color = 'white') => ({
11856
- content:
11857
- PRE_CSS +
11858
- `data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960' fill='${color}'><path d='${path}' /></svg>` +
11859
- POST_CSS,
11860
- });
11861
- const VERTICAL_THIN = 'v560h120v-560h-120Z';
11862
- const VERTICAL_THICK = 'v560h360v-560h-360Z';
11863
- const HORIZONTAL_THIN = 'v120h560v-120h-560Z';
11864
- const HORIZONTAL_THICK = 'v360h560v-360h-560Z';
11865
- const LOGO_SVG = {content: PRE_CSS + img + POST_CSS};
11866
- const POSITIONS_SVG = arrayMap(
11867
- [
11868
- `M200-760${VERTICAL_THIN} M400-760${VERTICAL_THICK}`,
11869
- `M200-760${HORIZONTAL_THIN} M200-560${HORIZONTAL_THICK}`,
11870
- `M200-760${HORIZONTAL_THICK} M200-320${HORIZONTAL_THIN}`,
11871
- `M200-760${VERTICAL_THICK} M640-760${VERTICAL_THIN}`,
11872
- ],
11873
- (path) =>
11874
- getCssSvg(
11875
- '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' +
11876
- path,
11877
- ),
11878
- );
11879
- arrayPush(
11880
- POSITIONS_SVG,
11881
- getCssSvg(
11882
- 'M120-120v-200h80v120h120v80H120Zm520 0v-80h120v-120h80v200H640ZM120-640v-200h200v80H200v120h-80Zm640 0v-120H640v-80h200v200h-80Z',
11883
- ),
11884
- );
11885
- const CLOSE_SVG = getCssSvg(
11886
- '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',
11887
- );
11888
- const EDIT_SVG = getCssSvg(
11889
- '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',
11890
- );
11891
- const DONE_SVG = getCssSvg(
11892
- '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',
11893
- );
11894
- const ADD_SVG = getCssSvg(
11895
- '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',
11896
- );
11897
- const CLONE_SVG = getCssSvg(
11898
- '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',
11899
- );
11900
- const DELETE_SVG = getCssSvg(
11901
- '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',
11902
- );
11903
- const OK_SVG = getCssSvg(
11904
- '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',
11905
- 'rgb(127,255,127)',
11906
- );
11907
- const OK_SVG_DISABLED = getCssSvg(
11908
- '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',
11909
- 'rgb(255,255,127)',
11910
- );
11911
- const CANCEL_SVG = getCssSvg(
11912
- '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',
11913
- 'rgb(255,127,127)',
11914
- );
11915
- const DOWN_SVG = getCssSvg(
11916
- 'M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z',
11917
- );
11918
- const RIGHT_SVG = getCssSvg(
11919
- 'M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z',
11920
- );
11921
-
11922
- const SCROLLBAR = '*::-webkit-scrollbar';
11923
- const BACKGROUND = 'background';
11924
- const WIDTH = 'width';
11925
- const MAX_WIDTH = 'max-' + WIDTH;
11926
- const MIN_WIDTH = 'min-' + WIDTH;
11927
- const HEIGHT = 'height';
11928
- const BORDER = 'border';
11929
- const BORDER_RADIUS = BORDER + '-radius';
11930
- const PADDING = 'padding';
11931
- const MARGIN = 'margin';
11932
- const MARGIN_RIGHT = MARGIN + '-right';
11933
- const TOP = 'top';
11934
- const BOTTOM = 'bottom';
11935
- const LEFT = 'left';
11936
- const RIGHT = 'right';
11937
- const COLOR = 'color';
11938
- const POSITION = 'position';
11939
- const BOX_SHADOW = 'box-shadow';
11940
- const FONT_SIZE = 'font-size';
11941
- const DISPLAY = 'display';
11942
- const OVERFLOW = 'overflow';
11943
- const CURSOR = 'cursor';
11944
- const VERTICAL_ALIGN = 'vertical-align';
11945
- const TEXT_ALIGN = 'text-align';
11946
- const JUSTIFY_CONTENT = 'justify-content';
11947
- const FIXED = 'fixed';
11948
- const REVERT = 'revert';
11949
- const UNSET = 'unset';
11950
- const NONE = 'none';
11951
- const FLEX = 'flex';
11952
- const POINTER = 'pointer';
11953
- const AUTO = 'auto';
11954
- const HIDDEN = 'hidden';
11955
- const NOWRAP = 'nowrap';
11956
- const oklch = (lPercent, remainder = '% 0.01 ' + cssVar('hue')) =>
11957
- `oklch(${lPercent}${remainder})`;
11958
- const cssVar = (name) => `var(--${name})`;
11959
- const rem = (...rems) => `${rems.join('rem ')}rem`;
11960
- const px = (...pxs) => `${pxs.join('px ')}px`;
11961
- const vw = (vw2 = 100) => `${vw2}vw`;
11962
- const vh = (vh2 = 100) => `${vh2}vh`;
11963
- const APP_STYLESHEET = arrayJoin(
11964
- objToArray(
11965
- {
11966
- '': {
11967
- all: 'initial',
11968
- [FONT_SIZE]: rem(0.75),
11969
- [POSITION]: FIXED,
11970
- 'font-family': 'inter,sans-serif',
11971
- 'z-index': 999999,
11972
- '--bg': oklch(20),
11973
- '--bg2': oklch(15),
11974
- '--bg3': oklch(25),
11975
- '--bg4': oklch(30),
11976
- '--fg': oklch(85),
11977
- '--fg2': oklch(60),
11978
- ['--' + BORDER]: px(1) + ' solid ' + cssVar('bg4'),
11979
- ['--' + BOX_SHADOW]: px(0, 1, 2, 0) + ' #0007',
11980
- },
11981
- '*': {all: REVERT},
11982
- '*::before': {all: REVERT},
11983
- '*::after': {all: REVERT},
11984
- [SCROLLBAR]: {[WIDTH]: rem(0.5), [HEIGHT]: rem(0.5)},
11985
- [SCROLLBAR + '-thumb']: {[BACKGROUND]: cssVar('bg4')},
11986
- [SCROLLBAR + '-thumb:hover']: {[BACKGROUND]: cssVar('bg4')},
11987
- [SCROLLBAR + '-corner']: {[BACKGROUND]: NONE},
11988
- [SCROLLBAR + '-track']: {[BACKGROUND]: NONE},
11989
- img: {
11990
- [WIDTH]: rem(0.8),
11991
- [HEIGHT]: rem(0.8),
11992
- [VERTICAL_ALIGN]: 'text-' + BOTTOM,
11993
- [CURSOR]: POINTER,
11994
- [MARGIN]: px(-2.5, 2, -2.5, 0),
11995
- [PADDING]: px(2),
11996
- [BORDER]: cssVar(BORDER),
11997
- [BACKGROUND]: cssVar('bg3'),
11998
- [BOX_SHADOW]: cssVar(BOX_SHADOW),
11999
- [BORDER_RADIUS]: rem(0.25),
12000
- },
12001
- 'img.flat': {[BORDER]: NONE, [BACKGROUND]: NONE, [BOX_SHADOW]: NONE},
12002
- // Nub
12003
- '>img': {
12004
- [PADDING]: rem(0.25),
12005
- [BOTTOM]: 0,
12006
- [RIGHT]: 0,
12007
- [POSITION]: FIXED,
12008
- [HEIGHT]: UNSET,
12009
- [MARGIN]: 0,
12010
- ...LOGO_SVG,
12011
- },
12012
- ...objNew(
12013
- arrayMap(
12014
- [
12015
- {[BOTTOM]: 0, [LEFT]: 0},
12016
- {[TOP]: 0, [RIGHT]: 0},
12017
- ],
12018
- (css, p) => [`>img[data-position='${p}']`, css],
12019
- ),
12020
- ),
12021
- // Panel
12022
- main: {
12023
- [DISPLAY]: FLEX,
12024
- [COLOR]: cssVar('fg'),
12025
- [BACKGROUND]: cssVar('bg'),
12026
- [OVERFLOW]: HIDDEN,
12027
- [POSITION]: FIXED,
12028
- [BOX_SHADOW]: cssVar(BOX_SHADOW),
12029
- 'flex-direction': 'column',
12030
- },
12031
- ...objNew(
12032
- arrayMap(
12033
- [
12034
- {
12035
- [BOTTOM]: 0,
12036
- [LEFT]: 0,
12037
- [WIDTH]: vw(35),
12038
- [HEIGHT]: vh(),
12039
- [BORDER + '-' + RIGHT]: cssVar(BORDER),
12040
- },
12041
- {
12042
- [TOP]: 0,
12043
- [RIGHT]: 0,
12044
- [WIDTH]: vw(),
12045
- [HEIGHT]: vh(30),
12046
- [BORDER + '-' + BOTTOM]: cssVar(BORDER),
12047
- },
12048
- {
12049
- [BOTTOM]: 0,
12050
- [LEFT]: 0,
12051
- [WIDTH]: vw(),
12052
- [HEIGHT]: vh(30),
12053
- [BORDER + '-' + TOP]: cssVar(BORDER),
12054
- },
12055
- {
12056
- [TOP]: 0,
12057
- [RIGHT]: 0,
12058
- [WIDTH]: vw(35),
12059
- [HEIGHT]: vh(),
12060
- [BORDER + '-' + LEFT]: cssVar(BORDER),
12061
- },
12062
- {[TOP]: 0, [RIGHT]: 0, [WIDTH]: vw(), [HEIGHT]: vh()},
12063
- ],
12064
- (css, p) => [`main[data-position='${p}']`, css],
12065
- ),
12066
- ),
12067
- // Header
12068
- header: {
12069
- [DISPLAY]: FLEX,
12070
- [PADDING]: rem(0.5),
12071
- [BOX_SHADOW]: cssVar(BOX_SHADOW),
12072
- [BACKGROUND]: oklch(30, '% 0.008 var(--hue) / .5'),
12073
- [WIDTH]: 'calc(100% - .5rem)',
12074
- [POSITION]: 'absolute',
12075
- [BORDER + '-' + BOTTOM]: cssVar(BORDER),
12076
- 'align-items': 'center',
12077
- 'backdrop-filter': 'blur(4px)',
12078
- },
12079
- 'header>img:nth-of-type(1)': {
12080
- [HEIGHT]: rem(1),
12081
- [WIDTH]: rem(1),
12082
- ...LOGO_SVG,
12083
- },
12084
- 'header>img:nth-of-type(6)': CLOSE_SVG,
12085
- ...objNew(
12086
- arrayMap(POSITIONS_SVG, (SVG, p) => [
12087
- `header>img[data-id='${p}']`,
12088
- SVG,
12089
- ]),
12090
- ),
12091
- 'header>span': {
12092
- [OVERFLOW]: HIDDEN,
12093
- [FLEX]: 1,
12094
- 'font-weight': 800,
12095
- 'white-space': NOWRAP,
12096
- 'text-overflow': 'ellipsis',
12097
- },
12098
- // Body
12099
- article: {[OVERFLOW]: AUTO, [FLEX]: 1, [PADDING + '-' + TOP]: rem(2)},
12100
- details: {
12101
- [MARGIN]: rem(0.5),
12102
- [BORDER]: cssVar(BORDER),
12103
- [BORDER_RADIUS]: rem(0.25),
12104
- },
12105
- summary: {
12106
- [BACKGROUND]: cssVar('bg3'),
12107
- [MARGIN]: px(-1),
12108
- [BORDER]: cssVar(BORDER),
12109
- [PADDING]: rem(0.25, 0.125),
12110
- [DISPLAY]: FLEX,
12111
- [BORDER_RADIUS]: rem(0.25),
12112
- 'user-select': NONE,
12113
- [JUSTIFY_CONTENT]: 'space-between',
12114
- 'align-items': 'center',
12115
- },
12116
- 'summary>span::before': {
12117
- [DISPLAY]: 'inline-block',
12118
- [VERTICAL_ALIGN]: 'sub',
12119
- [MARGIN]: px(2),
12120
- [WIDTH]: rem(1),
12121
- [HEIGHT]: rem(1),
12122
- ...RIGHT_SVG,
12123
- },
12124
- 'details[open]>summary': {
12125
- 'border-bottom-left-radius': 0,
12126
- 'border-bottom-right-radius': 0,
12127
- [MARGIN + '-' + BOTTOM]: 0,
12128
- },
12129
- 'details[open]>summary>span::before': DOWN_SVG,
12130
- 'details>summary img': {[DISPLAY]: NONE},
12131
- 'details[open]>summary img': {
12132
- [DISPLAY]: UNSET,
12133
- [MARGIN + '-' + LEFT]: rem(0.25),
12134
- },
12135
- 'details>div': {[OVERFLOW]: AUTO},
12136
- caption: {
12137
- [COLOR]: cssVar('fg2'),
12138
- [PADDING]: rem(0.25, 0.5),
12139
- [TEXT_ALIGN]: LEFT,
12140
- 'white-space': NOWRAP,
12141
- },
12142
- 'caption button': {
12143
- [WIDTH]: rem(1.5),
12144
- [BORDER]: NONE,
12145
- [BACKGROUND]: NONE,
12146
- [COLOR]: cssVar('fg'),
12147
- [PADDING]: 0,
12148
- [CURSOR]: POINTER,
12149
- },
12150
- 'caption button[disabled]': {[COLOR]: cssVar('fg2')},
12151
- '.actions': {
12152
- [PADDING]: rem(0.75, 0.5),
12153
- [MARGIN]: 0,
12154
- [DISPLAY]: FLEX,
12155
- [BORDER + '-' + TOP]: cssVar(BORDER),
12156
- [JUSTIFY_CONTENT]: 'space-between',
12157
- },
12158
- // tables
12159
- table: {
12160
- [MIN_WIDTH]: '100%',
12161
- 'border-collapse': 'collapse',
12162
- 'table-layout': FIXED,
12163
- },
12164
- thead: {[BACKGROUND]: cssVar('bg')},
12165
- [`th,#${UNIQUE_ID} td`]: {
12166
- [OVERFLOW]: HIDDEN,
12167
- [PADDING]: rem(0.25, 0.5),
12168
- [MAX_WIDTH]: rem(20),
12169
- [BORDER]: cssVar(BORDER),
12170
- 'text-overflow': 'ellipsis',
12171
- 'white-space': NOWRAP,
12172
- 'border-width': px(1, 0, 0),
12173
- [TEXT_ALIGN]: LEFT,
12174
- },
12175
- 'th:first-child': {
12176
- [WIDTH]: rem(3),
12177
- [MIN_WIDTH]: rem(3),
12178
- [MAX_WIDTH]: rem(3),
12179
- },
12180
- 'th.sorted': {[BACKGROUND]: cssVar('bg3')},
12181
- 'td.extra': {[TEXT_ALIGN]: RIGHT},
12182
- 'tbody button': {
12183
- [BACKGROUND]: NONE,
12184
- [BORDER]: NONE,
12185
- [FONT_SIZE]: 0,
12186
- [WIDTH]: rem(0.8),
12187
- [HEIGHT]: rem(0.8),
12188
- [COLOR]: cssVar('fg2'),
12189
- [MARGIN]: rem(0, 0.25, 0, -0.25),
12190
- 'line-height': rem(0.8),
12191
- },
12192
- 'tbody button:first-letter': {[FONT_SIZE]: rem(0.8)},
12193
- input: {
12194
- [BACKGROUND]: cssVar('bg2'),
12195
- [COLOR]: UNSET,
12196
- [PADDING]: px(4),
12197
- [BORDER]: 0,
12198
- [MARGIN]: px(-4, 0),
12199
- [FONT_SIZE]: UNSET,
12200
- [MAX_WIDTH]: rem(6),
12201
- },
12202
- 'input:focus': {'outline-width': 0},
12203
- 'input[type="number"]': {[WIDTH]: rem(3)},
12204
- 'input[type="checkbox"]': {[VERTICAL_ALIGN]: px(-2)},
12205
- '.editableCell': {[DISPLAY]: 'inline-block', [MARGIN_RIGHT]: px(2)},
12206
- 'button.next': {[MARGIN_RIGHT]: rem(0.5)},
12207
- 'img.edit': EDIT_SVG,
12208
- 'img.done': DONE_SVG,
12209
- 'img.add': ADD_SVG,
12210
- 'img.clone': CLONE_SVG,
12211
- 'img.delete': DELETE_SVG,
12212
- 'img.ok': OK_SVG,
12213
- 'img.okDis': OK_SVG_DISABLED,
12214
- 'img.cancel': CANCEL_SVG,
12215
- 'span.warn': {[MARGIN]: rem(2, 0.25), [COLOR]: '#d81b60'},
12216
- },
12217
- (style, selector) =>
12218
- `#${UNIQUE_ID} ${selector}{${arrayJoin(
12219
- objToArray(style, (value, property) => `${property}:${value};`),
12220
- )}}`,
12221
- ),
12222
- );
12223
-
12224
- const Inspector = ({position = 'right', open = false, hue = 270}) => {
12225
- const s = useCreateStore(createStore);
12226
- const index = POSITIONS.indexOf(position);
12227
- useCreatePersister(
12228
- s,
12229
- (s2) => createSessionPersister(s2, UNIQUE_ID),
12230
- void 0,
12231
- async (persister) => {
12232
- await persister.load([
12233
- {},
12234
- {
12235
- position: index == -1 ? 1 : index,
12236
- open: !!open,
12237
- },
12238
- ]);
12239
- await persister.startAutoSave();
12240
- },
12241
- );
12242
- return /* @__PURE__ */ jsxs(Fragment, {
12243
- children: [
12244
- /* @__PURE__ */ jsxs('aside', {
12245
- id: UNIQUE_ID,
12246
- children: [
12247
- /* @__PURE__ */ jsx(Nub, {s}),
12248
- /* @__PURE__ */ jsx(Panel, {s}),
12249
- ],
12250
- }),
12251
- /* @__PURE__ */ jsxs('style', {
12252
- children: [`#${UNIQUE_ID}{--hue:${hue}}`, APP_STYLESHEET],
12253
- }),
12254
- ],
12255
- });
12256
- };
12257
-
12258
7734
  export {
12259
7735
  addOrRemoveHash,
12260
- BackwardCheckpointsView,
12261
7736
  broadcastChanges,
12262
- CellView,
12263
- CheckpointView,
12264
7737
  createAutomergePersister,
12265
7738
  createBroadcastChannelSynchronizer,
12266
7739
  createCheckpoints,
@@ -12300,11 +7773,7 @@ export {
12300
7773
  createWsServerSimple,
12301
7774
  createWsSynchronizer,
12302
7775
  createYjsPersister,
12303
- CurrentCheckpointView,
12304
7776
  defaultSorter,
12305
- EditableCellView,
12306
- EditableValueView,
12307
- ForwardCheckpointsView,
12308
7777
  getCellHash,
12309
7778
  getCellInRowHash,
12310
7779
  getHash,
@@ -12314,214 +7783,17 @@ export {
12314
7783
  getTableHash,
12315
7784
  getTableInTablesHash,
12316
7785
  getTablesHash,
12317
- getUniqueId$1 as getUniqueId,
7786
+ getUniqueId,
12318
7787
  getValueHash,
12319
7788
  getValueInValuesHash,
12320
7789
  getValuesHash,
12321
7790
  getWsServerDurableObjectFetch,
12322
7791
  hasStoreInStorage,
12323
- IndexView$1 as IndexView,
12324
- Inspector,
12325
- LinkedRowsView,
12326
7792
  loadStoreFromStorage,
12327
- LocalRowsView,
12328
7793
  Message,
12329
- MetricView,
12330
7794
  objectStoreMatch,
12331
- OFFSET_CHECKPOINTS,
12332
- OFFSET_INDEXES,
12333
- OFFSET_METRICS,
12334
- OFFSET_PERSISTER,
12335
- OFFSET_QUERIES,
12336
- OFFSET_RELATIONSHIPS,
12337
- OFFSET_STORE,
12338
- OFFSET_SYNCHRONIZER,
12339
7795
  Persists,
12340
- Provider,
12341
- RelationshipInHtmlRow,
12342
- RelationshipInHtmlTable,
12343
- RemoteRowView,
12344
- ResultCellView,
12345
- ResultRowView,
12346
- ResultSortedTableInHtmlTable,
12347
- ResultSortedTableView,
12348
- ResultTableInHtmlTable,
12349
- ResultTableView,
12350
- RowView,
12351
- SliceInHtmlTable,
12352
- SliceView$1 as SliceView,
12353
- SortedTableInHtmlTable,
12354
- SortedTablePaginator,
12355
- SortedTableView,
12356
7796
  Status,
12357
- TableInHtmlTable,
12358
- TablesView$1 as TablesView,
12359
- TableView$1 as TableView,
12360
7797
  TinyBasePartyKitServer,
12361
- useAddRowCallback,
12362
- useCell,
12363
- useCellIds,
12364
- useCellIdsListener,
12365
- useCellListener,
12366
- useCellState,
12367
- useCheckpoint,
12368
- useCheckpointIds,
12369
- useCheckpointIdsListener,
12370
- useCheckpointListener,
12371
- useCheckpoints,
12372
- useCheckpointsIds,
12373
- useCheckpointsOrCheckpointsById,
12374
- useCreateCheckpoints,
12375
- useCreateIndexes,
12376
- useCreateMergeableStore,
12377
- useCreateMetrics,
12378
- useCreatePersister,
12379
- useCreateQueries,
12380
- useCreateRelationships,
12381
- useCreateStore,
12382
- useCreateSynchronizer,
12383
- useDelCellCallback,
12384
- useDelRowCallback,
12385
- useDelTableCallback,
12386
- useDelTablesCallback,
12387
- useDelValueCallback,
12388
- useDelValuesCallback,
12389
- useDidFinishTransactionListener,
12390
- useGoBackwardCallback,
12391
- useGoForwardCallback,
12392
- useGoToCallback,
12393
- useHasCell,
12394
- useHasCellListener,
12395
- useHasRow,
12396
- useHasRowListener,
12397
- useHasTable,
12398
- useHasTableCell,
12399
- useHasTableCellListener,
12400
- useHasTableListener,
12401
- useHasTables,
12402
- useHasTablesListener,
12403
- useHasValue,
12404
- useHasValueListener,
12405
- useHasValues,
12406
- useHasValuesListener,
12407
- useIndexes,
12408
- useIndexesIds,
12409
- useIndexesOrIndexesById,
12410
- useIndexIds,
12411
- useLinkedRowIds,
12412
- useLinkedRowIdsListener,
12413
- useLocalRowIds,
12414
- useLocalRowIdsListener,
12415
- useMetric,
12416
- useMetricIds,
12417
- useMetricListener,
12418
- useMetrics,
12419
- useMetricsIds,
12420
- useMetricsOrMetricsById,
12421
- useParamValue,
12422
- useParamValueListener,
12423
- useParamValues,
12424
- useParamValuesListener,
12425
- useParamValuesState,
12426
- useParamValueState,
12427
- usePersister,
12428
- usePersisterIds,
12429
- usePersisterOrPersisterById,
12430
- usePersisterStatus,
12431
- usePersisterStatusListener,
12432
- useProvideCheckpoints,
12433
- useProvideIndexes,
12434
- useProvideMetrics,
12435
- useProvidePersister,
12436
- useProvideQueries,
12437
- useProvideRelationships,
12438
- useProvideStore,
12439
- useProvideSynchronizer,
12440
- useQueries,
12441
- useQueriesIds,
12442
- useQueriesOrQueriesById,
12443
- useQueryIds,
12444
- useRedoInformation,
12445
- useRelationshipIds,
12446
- useRelationships,
12447
- useRelationshipsIds,
12448
- useRelationshipsOrRelationshipsById,
12449
- useRemoteRowId,
12450
- useRemoteRowIdListener,
12451
- useResultCell,
12452
- useResultCellIds,
12453
- useResultCellIdsListener,
12454
- useResultCellListener,
12455
- useResultRow,
12456
- useResultRowCount,
12457
- useResultRowCountListener,
12458
- useResultRowIds,
12459
- useResultRowIdsListener,
12460
- useResultRowListener,
12461
- useResultSortedRowIds,
12462
- useResultSortedRowIdsListener,
12463
- useResultTable,
12464
- useResultTableCellIds,
12465
- useResultTableCellIdsListener,
12466
- useResultTableListener,
12467
- useRow,
12468
- useRowCount,
12469
- useRowCountListener,
12470
- useRowIds,
12471
- useRowIdsListener,
12472
- useRowListener,
12473
- useRowState,
12474
- useSetCellCallback,
12475
- useSetCheckpointCallback,
12476
- useSetParamValueCallback,
12477
- useSetParamValuesCallback,
12478
- useSetPartialRowCallback,
12479
- useSetPartialValuesCallback,
12480
- useSetRowCallback,
12481
- useSetTableCallback,
12482
- useSetTablesCallback,
12483
- useSetValueCallback,
12484
- useSetValuesCallback,
12485
- useSliceIds,
12486
- useSliceIdsListener,
12487
- useSliceRowIds,
12488
- useSliceRowIdsListener,
12489
- useSortedRowIds,
12490
- useSortedRowIdsListener,
12491
- useSortedRowIdsListenerImpl,
12492
- useSortingAndPagination,
12493
- useStartTransactionListener,
12494
- useStore,
12495
- useStoreIds,
12496
- useStoreOrStoreById,
12497
- useStores,
12498
- useSynchronizer,
12499
- useSynchronizerIds,
12500
- useSynchronizerOrSynchronizerById,
12501
- useSynchronizerStatus,
12502
- useSynchronizerStatusListener,
12503
- useTable,
12504
- useTableCellIds,
12505
- useTableCellIdsListener,
12506
- useTableIds,
12507
- useTableIdsListener,
12508
- useTableListener,
12509
- useTables,
12510
- useTablesListener,
12511
- useTablesState,
12512
- useTableState,
12513
- useUndoInformation,
12514
- useValue,
12515
- useValueIds,
12516
- useValueIdsListener,
12517
- useValueListener,
12518
- useValues,
12519
- useValuesListener,
12520
- useValuesState,
12521
- useValueState,
12522
- useWillFinishTransactionListener,
12523
- ValuesInHtmlTable,
12524
- ValuesView$1 as ValuesView,
12525
- ValueView,
12526
7798
  WsServerDurableObject,
12527
7799
  };