tinybase 7.0.0-beta.1 → 7.0.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.
- package/@types/mergeable-store/index.d.ts +1 -0
- package/@types/mergeable-store/with-schemas/index.d.ts +4 -2
- package/@types/omni/index.d.ts +2 -0
- package/@types/omni/with-schemas/index.d.ts +2 -0
- package/@types/persisters/index.d.ts +4 -0
- package/@types/persisters/persister-automerge/index.d.ts +4 -6
- package/@types/persisters/persister-automerge/with-schemas/index.d.ts +7 -8
- package/@types/persisters/persister-browser/index.d.ts +97 -6
- package/@types/persisters/persister-browser/with-schemas/index.d.ts +113 -6
- package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +2 -2
- package/@types/persisters/persister-durable-object-sql-storage/with-schemas/index.d.ts +1 -0
- package/@types/persisters/persister-durable-object-storage/index.d.ts +1 -2
- package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-expo-sqlite/index.d.ts +1 -2
- package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-file/index.d.ts +1 -2
- package/@types/persisters/persister-file/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-indexed-db/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-libsql/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-pglite/index.d.ts +2 -2
- package/@types/persisters/persister-pglite/with-schemas/index.d.ts +4 -2
- package/@types/persisters/persister-postgres/index.d.ts +1 -2
- package/@types/persisters/persister-postgres/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-powersync/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-react-native-mmkv/index.d.ts +117 -0
- package/@types/persisters/persister-react-native-mmkv/with-schemas/index.d.ts +133 -0
- package/@types/persisters/persister-react-native-sqlite/index.d.ts +180 -0
- package/@types/persisters/persister-react-native-sqlite/with-schemas/index.d.ts +203 -0
- package/@types/persisters/persister-remote/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-sqlite-bun/index.d.ts +1 -2
- package/@types/persisters/persister-sqlite-bun/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-sqlite-wasm/index.d.ts +2 -2
- package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.ts +4 -2
- package/@types/persisters/persister-sqlite3/index.d.ts +1 -2
- package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +3 -2
- package/@types/persisters/persister-yjs/with-schemas/index.d.ts +3 -2
- package/@types/persisters/with-schemas/index.d.ts +4 -0
- package/@types/queries/with-schemas/index.d.ts +4 -8
- package/@types/store/index.d.ts +13 -0
- package/@types/store/with-schemas/index.d.ts +13 -0
- package/@types/synchronizers/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.ts +3 -2
- package/@types/synchronizers/synchronizer-local/with-schemas/index.d.ts +3 -2
- package/@types/synchronizers/synchronizer-ws-client/index.d.ts +4 -2
- package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server/index.d.ts +7 -7
- package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +7 -7
- package/@types/synchronizers/synchronizer-ws-server-durable-object/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.d.ts +1 -0
- package/@types/synchronizers/synchronizer-ws-server-simple/index.d.ts +1 -1
- package/@types/synchronizers/synchronizer-ws-server-simple/with-schemas/index.d.ts +1 -1
- package/@types/synchronizers/with-schemas/index.d.ts +4 -2
- package/@types/ui-react/index.d.ts +6 -1
- package/@types/ui-react/with-schemas/index.d.ts +6 -1
- package/@types/ui-react-dom/index.d.ts +153 -20
- package/@types/ui-react-dom/with-schemas/index.d.ts +72 -20
- package/@types/ui-react-inspector/index.d.ts +8 -0
- package/@types/ui-react-inspector/with-schemas/index.d.ts +27 -1925
- package/agents.md +281 -0
- package/common/index.js +1 -1
- package/common/with-schemas/index.js +1 -1
- package/index.js +1 -1
- package/mergeable-store/index.js +1 -1
- package/mergeable-store/with-schemas/index.js +1 -1
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-automerge/index.js +1 -1
- package/min/persisters/persister-automerge/index.js.gz +0 -0
- package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-browser/index.js +1 -1
- package/min/persisters/persister-browser/index.js.gz +0 -0
- package/min/persisters/persister-browser/with-schemas/index.js +1 -1
- package/min/persisters/persister-browser/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/index.js +1 -0
- package/min/persisters/persister-react-native-mmkv/index.js.gz +0 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js +1 -0
- package/min/persisters/persister-react-native-mmkv/with-schemas/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/index.js +1 -0
- package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -0
- package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +2103 -1162
- package/omni/with-schemas/index.js +2103 -1162
- package/package.json +91 -11
- package/persisters/persister-automerge/index.js +1 -1
- package/persisters/persister-automerge/with-schemas/index.js +1 -1
- package/persisters/persister-browser/index.js +27 -1
- package/persisters/persister-browser/with-schemas/index.js +27 -1
- package/persisters/persister-react-native-mmkv/index.js +459 -0
- package/persisters/persister-react-native-mmkv/with-schemas/index.js +459 -0
- package/persisters/persister-react-native-sqlite/index.js +1189 -0
- package/persisters/persister-react-native-sqlite/with-schemas/index.js +1189 -0
- package/readme.md +8 -8
- package/releases.md +80 -30
- package/synchronizers/index.js +1 -1
- package/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
- package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
- package/synchronizers/synchronizer-local/index.js +1 -1
- package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
- package/synchronizers/synchronizer-ws-client/index.js +1 -1
- package/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
- package/synchronizers/synchronizer-ws-server/index.js +1 -1
- package/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
- package/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
- package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
- package/synchronizers/with-schemas/index.js +1 -1
- package/ui-react/index.js +397 -368
- package/ui-react/with-schemas/index.js +397 -368
- package/ui-react-dom/index.js +873 -436
- package/ui-react-dom/with-schemas/index.js +873 -436
- package/ui-react-inspector/index.js +1717 -544
- package/ui-react-inspector/with-schemas/index.js +1717 -544
- package/with-schemas/index.js +1 -1
package/ui-react-dom/index.js
CHANGED
|
@@ -1,69 +1,96 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {Fragment, jsx, jsxs} from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
CellView,
|
|
5
|
-
ResultCellView,
|
|
6
|
-
useCell,
|
|
7
|
-
useIndexesOrIndexesById,
|
|
8
|
-
useRelationshipsOrRelationshipsById,
|
|
9
|
-
useRemoteRowId,
|
|
10
|
-
useResultRowCount,
|
|
11
|
-
useResultRowIds,
|
|
12
|
-
useResultSortedRowIds,
|
|
13
|
-
useResultTableCellIds,
|
|
14
|
-
useRowCount,
|
|
15
|
-
useRowIds,
|
|
16
|
-
useSetCellCallback,
|
|
17
|
-
useSetValueCallback,
|
|
18
|
-
useSliceRowIds,
|
|
19
|
-
useSortedRowIds,
|
|
20
|
-
useStoreOrStoreById,
|
|
21
|
-
useTableCellIds,
|
|
22
|
-
useValue,
|
|
23
|
-
useValueIds,
|
|
24
|
-
ValueView,
|
|
25
|
-
} from '../ui-react/index.js';
|
|
3
|
+
import {CellView, ResultCellView, ValueView} from '../ui-react/index.js';
|
|
26
4
|
|
|
27
5
|
const getTypeOf = (thing) => typeof thing;
|
|
6
|
+
const TINYBASE = 'tinybase';
|
|
28
7
|
const EMPTY_STRING = '';
|
|
29
8
|
const DOT = '.';
|
|
30
9
|
const STRING = getTypeOf(EMPTY_STRING);
|
|
31
10
|
const BOOLEAN = getTypeOf(true);
|
|
32
11
|
const NUMBER = getTypeOf(0);
|
|
12
|
+
const FUNCTION = getTypeOf(getTypeOf);
|
|
13
|
+
const LISTENER = 'Listener';
|
|
14
|
+
const RESULT = 'Result';
|
|
15
|
+
const GET = 'get';
|
|
16
|
+
const SET = 'set';
|
|
17
|
+
const ADD = 'add';
|
|
18
|
+
const HAS = 'Has';
|
|
19
|
+
const _HAS = 'has';
|
|
20
|
+
const IDS = 'Ids';
|
|
21
|
+
const TABLE = 'Table';
|
|
22
|
+
const ROW = 'Row';
|
|
23
|
+
const ROW_COUNT = ROW + 'Count';
|
|
24
|
+
const ROW_IDS = ROW + IDS;
|
|
25
|
+
const SORTED_ROW_IDS = 'Sorted' + ROW + IDS;
|
|
33
26
|
const CELL = 'Cell';
|
|
27
|
+
const CELL_IDS = CELL + IDS;
|
|
34
28
|
const VALUE = 'Value';
|
|
29
|
+
const VALUE_IDS = VALUE + IDS;
|
|
30
|
+
const SLICE = 'Slice';
|
|
31
|
+
const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
35
32
|
const CURRENT_TARGET = 'currentTarget';
|
|
36
33
|
const _VALUE = 'value';
|
|
34
|
+
const EXTRA = 'extra';
|
|
37
35
|
const strSplit = (str, separator = EMPTY_STRING, limit) =>
|
|
38
36
|
str.split(separator, limit);
|
|
39
37
|
|
|
38
|
+
const GLOBAL = globalThis;
|
|
40
39
|
const math = Math;
|
|
41
40
|
const mathMin = math.min;
|
|
42
41
|
const isFiniteNumber = isFinite;
|
|
43
42
|
const isUndefined = (thing) => thing == void 0;
|
|
43
|
+
const ifNotUndefined = (value, then, otherwise) =>
|
|
44
|
+
isUndefined(value) ? otherwise?.() : then(value);
|
|
44
45
|
const isTypeStringOrBoolean = (type) => type == STRING || type == BOOLEAN;
|
|
45
46
|
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
47
|
+
const isFunction = (thing) => getTypeOf(thing) == FUNCTION;
|
|
46
48
|
const isArray = (thing) => Array.isArray(thing);
|
|
49
|
+
const size = (arrayOrString) => arrayOrString.length;
|
|
50
|
+
const getUndefined = () => void 0;
|
|
47
51
|
|
|
52
|
+
const arrayEvery = (array, cb) => array.every(cb);
|
|
53
|
+
const arrayIsEqual = (array1, array2) =>
|
|
54
|
+
size(array1) === size(array2) &&
|
|
55
|
+
arrayEvery(array1, (value1, index) => array2[index] === value1);
|
|
48
56
|
const arrayMap = (array, cb) => array.map(cb);
|
|
49
|
-
|
|
50
|
-
const getCellOrValueType = (cellOrValue) => {
|
|
51
|
-
const type = getTypeOf(cellOrValue);
|
|
52
|
-
return isTypeStringOrBoolean(type) ||
|
|
53
|
-
(type == NUMBER && isFiniteNumber(cellOrValue))
|
|
54
|
-
? type
|
|
55
|
-
: void 0;
|
|
56
|
-
};
|
|
57
|
-
const getTypeCase = (type, stringCase, numberCase, booleanCase) =>
|
|
58
|
-
type == STRING ? stringCase : type == NUMBER ? numberCase : booleanCase;
|
|
57
|
+
const arrayFilter = (array, cb) => array.filter(cb);
|
|
59
58
|
|
|
60
59
|
const object = Object;
|
|
60
|
+
const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
|
|
61
61
|
const objEntries = object.entries;
|
|
62
|
+
const isObject = (obj) =>
|
|
63
|
+
!isUndefined(obj) &&
|
|
64
|
+
ifNotUndefined(
|
|
65
|
+
getPrototypeOf(obj),
|
|
66
|
+
(objPrototype) =>
|
|
67
|
+
objPrototype == object.prototype ||
|
|
68
|
+
isUndefined(getPrototypeOf(objPrototype)),
|
|
69
|
+
|
|
70
|
+
/* istanbul ignore next */
|
|
71
|
+
() => true,
|
|
72
|
+
);
|
|
73
|
+
const objIds = object.keys;
|
|
62
74
|
const objNew = (entries = []) => object.fromEntries(entries);
|
|
75
|
+
const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
|
|
63
76
|
const objToArray = (obj, cb) =>
|
|
64
77
|
arrayMap(objEntries(obj), ([id, value]) => cb(value, id));
|
|
65
78
|
const objMap = (obj, cb) =>
|
|
66
79
|
objNew(objToArray(obj, (value, id) => [id, cb(value, id)]));
|
|
80
|
+
const objSize = (obj) => size(objIds(obj));
|
|
81
|
+
const objIsEqual = (obj1, obj2) => {
|
|
82
|
+
const entries1 = objEntries(obj1);
|
|
83
|
+
return (
|
|
84
|
+
size(entries1) === objSize(obj2) &&
|
|
85
|
+
arrayEvery(entries1, ([index, value1]) =>
|
|
86
|
+
isObject(value1)
|
|
87
|
+
? isObject(obj2[index])
|
|
88
|
+
? objIsEqual(obj2[index], value1)
|
|
89
|
+
: false
|
|
90
|
+
: obj2[index] === value1,
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
};
|
|
67
94
|
|
|
68
95
|
const {
|
|
69
96
|
PureComponent,
|
|
@@ -91,13 +118,302 @@ const getIndexStoreTableId = (indexes, indexId) => [
|
|
|
91
118
|
indexes?.getTableId(indexId),
|
|
92
119
|
];
|
|
93
120
|
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
121
|
+
const TINYBASE_CONTEXT = TINYBASE + '_uirc';
|
|
122
|
+
const Context = GLOBAL[TINYBASE_CONTEXT]
|
|
123
|
+
? /* istanbul ignore next */
|
|
124
|
+
GLOBAL[TINYBASE_CONTEXT]
|
|
125
|
+
: (GLOBAL[TINYBASE_CONTEXT] = createContext([]));
|
|
126
|
+
const useThing = (id, offset) => {
|
|
127
|
+
const contextValue = useContext(Context);
|
|
128
|
+
return isUndefined(id)
|
|
129
|
+
? contextValue[offset * 2]
|
|
130
|
+
: isString(id)
|
|
131
|
+
? objGet(contextValue[offset * 2 + 1], id)
|
|
132
|
+
: id;
|
|
133
|
+
};
|
|
134
|
+
const useThingOrThingById = (thingOrThingId, offset) => {
|
|
135
|
+
const thing = useThing(thingOrThingId, offset);
|
|
136
|
+
return isUndefined(thingOrThingId) || isString(thingOrThingId)
|
|
137
|
+
? thing
|
|
138
|
+
: thingOrThingId;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const OFFSET_STORE = 0;
|
|
142
|
+
const OFFSET_INDEXES = 2;
|
|
143
|
+
const OFFSET_RELATIONSHIPS = 3;
|
|
144
|
+
const OFFSET_QUERIES = 4;
|
|
145
|
+
|
|
146
|
+
const EMPTY_ARRAY = [];
|
|
147
|
+
const DEFAULTS = [{}, [], [EMPTY_ARRAY, void 0, EMPTY_ARRAY], void 0, false, 0];
|
|
148
|
+
const IS_EQUALS = [
|
|
149
|
+
objIsEqual,
|
|
150
|
+
arrayIsEqual,
|
|
151
|
+
(
|
|
152
|
+
[backwardIds1, currentId1, forwardIds1],
|
|
153
|
+
[backwardIds2, currentId2, forwardIds2],
|
|
154
|
+
) =>
|
|
155
|
+
currentId1 === currentId2 &&
|
|
156
|
+
arrayIsEqual(backwardIds1, backwardIds2) &&
|
|
157
|
+
arrayIsEqual(forwardIds1, forwardIds2),
|
|
158
|
+
];
|
|
159
|
+
const isEqual = (thing1, thing2) => thing1 === thing2;
|
|
160
|
+
const addAndDelListener = (thing, listenable, ...args) => {
|
|
161
|
+
const listenerId = thing?.[ADD + listenable + LISTENER]?.(...args);
|
|
162
|
+
return () => thing?.delListener?.(listenerId);
|
|
163
|
+
};
|
|
164
|
+
const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
|
|
165
|
+
const lastResult = useRef(DEFAULTS[returnType]);
|
|
166
|
+
const getResult = useCallback(
|
|
167
|
+
() => {
|
|
168
|
+
const nextResult =
|
|
169
|
+
thing?.[(returnType == 4 /* Boolean */ ? _HAS : GET) + listenable]?.(
|
|
170
|
+
...args,
|
|
171
|
+
) ?? DEFAULTS[returnType];
|
|
172
|
+
return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
|
|
173
|
+
? (lastResult.current = nextResult)
|
|
174
|
+
: lastResult.current;
|
|
175
|
+
},
|
|
176
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
177
|
+
[thing, returnType, listenable, ...args],
|
|
178
|
+
);
|
|
179
|
+
const subscribe = useCallback(
|
|
180
|
+
(listener) =>
|
|
181
|
+
addAndDelListener(
|
|
182
|
+
thing,
|
|
183
|
+
(returnType == 4 /* Boolean */ ? HAS : EMPTY_STRING) + listenable,
|
|
184
|
+
...args,
|
|
185
|
+
listener,
|
|
186
|
+
),
|
|
187
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
188
|
+
[thing, returnType, listenable, ...args],
|
|
189
|
+
);
|
|
190
|
+
return useSyncExternalStore(subscribe, getResult, getResult);
|
|
191
|
+
};
|
|
192
|
+
const useSetCallback = (
|
|
193
|
+
storeOrStoreId,
|
|
194
|
+
settable,
|
|
195
|
+
get,
|
|
196
|
+
getDeps = EMPTY_ARRAY,
|
|
197
|
+
then = getUndefined,
|
|
198
|
+
thenDeps = EMPTY_ARRAY,
|
|
199
|
+
...args
|
|
200
|
+
) => {
|
|
201
|
+
const store = useStoreOrStoreById(storeOrStoreId);
|
|
202
|
+
return useCallback(
|
|
203
|
+
(parameter) =>
|
|
204
|
+
ifNotUndefined(store, (store2) =>
|
|
205
|
+
ifNotUndefined(get(parameter, store2), (thing) =>
|
|
206
|
+
then(
|
|
207
|
+
store2[SET + settable](
|
|
208
|
+
...argsOrGetArgs(args, store2, parameter),
|
|
209
|
+
thing,
|
|
210
|
+
),
|
|
211
|
+
thing,
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
216
|
+
[store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
const argsOrGetArgs = (args, store, parameter) =>
|
|
220
|
+
arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
|
|
221
|
+
const nonFunctionDeps = (args) => arrayFilter(args, (arg) => !isFunction(arg));
|
|
222
|
+
const useSortedRowIdsImpl = (
|
|
223
|
+
tableId,
|
|
224
|
+
cellId,
|
|
225
|
+
descending,
|
|
226
|
+
offset,
|
|
227
|
+
limit,
|
|
228
|
+
storeOrStoreId,
|
|
229
|
+
) =>
|
|
230
|
+
useListenable(
|
|
231
|
+
SORTED_ROW_IDS,
|
|
232
|
+
useStoreOrStoreById(storeOrStoreId),
|
|
233
|
+
1 /* Array */,
|
|
234
|
+
[tableId, cellId, descending, offset, limit],
|
|
235
|
+
);
|
|
236
|
+
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
237
|
+
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
238
|
+
const useTableCellIds = (tableId, storeOrStoreId) =>
|
|
239
|
+
useListenable(
|
|
240
|
+
TABLE + CELL_IDS,
|
|
241
|
+
useStoreOrStoreById(storeOrStoreId),
|
|
242
|
+
1 /* Array */,
|
|
243
|
+
[tableId],
|
|
244
|
+
);
|
|
245
|
+
const useRowCount = (tableId, storeOrStoreId) =>
|
|
246
|
+
useListenable(
|
|
247
|
+
ROW_COUNT,
|
|
248
|
+
useStoreOrStoreById(storeOrStoreId),
|
|
249
|
+
5 /* Number */,
|
|
250
|
+
[tableId],
|
|
251
|
+
);
|
|
252
|
+
const useRowIds = (tableId, storeOrStoreId) =>
|
|
253
|
+
useListenable(ROW_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */, [
|
|
254
|
+
tableId,
|
|
255
|
+
]);
|
|
256
|
+
const useSortedRowIds = (
|
|
257
|
+
tableIdOrArgs,
|
|
258
|
+
cellIdOrStoreOrStoreId,
|
|
259
|
+
descending,
|
|
260
|
+
offset,
|
|
261
|
+
limit,
|
|
262
|
+
storeOrStoreId,
|
|
263
|
+
) =>
|
|
264
|
+
useSortedRowIdsImpl(
|
|
265
|
+
...(isObject(tableIdOrArgs)
|
|
266
|
+
? [
|
|
267
|
+
tableIdOrArgs.tableId,
|
|
268
|
+
tableIdOrArgs.cellId,
|
|
269
|
+
tableIdOrArgs.descending ?? false,
|
|
270
|
+
tableIdOrArgs.offset ?? 0,
|
|
271
|
+
tableIdOrArgs.limit,
|
|
272
|
+
cellIdOrStoreOrStoreId,
|
|
273
|
+
]
|
|
274
|
+
: [
|
|
275
|
+
tableIdOrArgs,
|
|
276
|
+
cellIdOrStoreOrStoreId,
|
|
277
|
+
descending,
|
|
278
|
+
offset,
|
|
279
|
+
limit,
|
|
280
|
+
storeOrStoreId,
|
|
281
|
+
]),
|
|
282
|
+
);
|
|
283
|
+
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
|
284
|
+
useListenable(
|
|
285
|
+
CELL,
|
|
286
|
+
useStoreOrStoreById(storeOrStoreId),
|
|
287
|
+
3 /* CellOrValue */,
|
|
288
|
+
[tableId, rowId, cellId],
|
|
289
|
+
);
|
|
290
|
+
const useValueIds = (storeOrStoreId) =>
|
|
291
|
+
useListenable(VALUE_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */);
|
|
292
|
+
const useValue = (valueId, storeOrStoreId) =>
|
|
293
|
+
useListenable(
|
|
294
|
+
VALUE,
|
|
295
|
+
useStoreOrStoreById(storeOrStoreId),
|
|
296
|
+
3 /* CellOrValue */,
|
|
297
|
+
[valueId],
|
|
298
|
+
);
|
|
299
|
+
const useSetCellCallback = (
|
|
300
|
+
tableId,
|
|
301
|
+
rowId,
|
|
302
|
+
cellId,
|
|
303
|
+
getCell,
|
|
304
|
+
getCellDeps,
|
|
305
|
+
storeOrStoreId,
|
|
306
|
+
then,
|
|
307
|
+
thenDeps,
|
|
308
|
+
) =>
|
|
309
|
+
useSetCallback(
|
|
310
|
+
storeOrStoreId,
|
|
311
|
+
CELL,
|
|
312
|
+
getCell,
|
|
313
|
+
getCellDeps,
|
|
314
|
+
then,
|
|
315
|
+
thenDeps,
|
|
316
|
+
tableId,
|
|
317
|
+
rowId,
|
|
318
|
+
cellId,
|
|
319
|
+
);
|
|
320
|
+
const useSetValueCallback = (
|
|
321
|
+
valueId,
|
|
322
|
+
getValue,
|
|
323
|
+
getValueDeps,
|
|
324
|
+
storeOrStoreId,
|
|
325
|
+
then,
|
|
326
|
+
thenDeps,
|
|
327
|
+
) =>
|
|
328
|
+
useSetCallback(
|
|
329
|
+
storeOrStoreId,
|
|
330
|
+
VALUE,
|
|
331
|
+
getValue,
|
|
332
|
+
getValueDeps,
|
|
333
|
+
then,
|
|
334
|
+
thenDeps,
|
|
335
|
+
valueId,
|
|
336
|
+
);
|
|
337
|
+
const useIndexesOrIndexesById = (indexesOrIndexesId) =>
|
|
338
|
+
useThingOrThingById(indexesOrIndexesId, OFFSET_INDEXES);
|
|
339
|
+
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
340
|
+
useListenable(
|
|
341
|
+
SLICE + ROW_IDS,
|
|
342
|
+
useIndexesOrIndexesById(indexesOrIndexesId),
|
|
343
|
+
1 /* Array */,
|
|
344
|
+
[indexId, sliceId],
|
|
345
|
+
);
|
|
346
|
+
const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
|
|
347
|
+
useThingOrThingById(relationshipsOrRelationshipsId, OFFSET_RELATIONSHIPS);
|
|
348
|
+
const useRemoteRowId = (
|
|
349
|
+
relationshipId,
|
|
350
|
+
localRowId,
|
|
351
|
+
relationshipsOrRelationshipsId,
|
|
352
|
+
) =>
|
|
353
|
+
useListenable(
|
|
354
|
+
REMOTE_ROW_ID,
|
|
355
|
+
useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
|
|
356
|
+
3 /* CellOrValue */,
|
|
357
|
+
[relationshipId, localRowId],
|
|
358
|
+
);
|
|
359
|
+
const useQueriesOrQueriesById = (queriesOrQueriesId) =>
|
|
360
|
+
useThingOrThingById(queriesOrQueriesId, OFFSET_QUERIES);
|
|
361
|
+
const useResultTableCellIds = (queryId, queriesOrQueriesId) =>
|
|
362
|
+
useListenable(
|
|
363
|
+
RESULT + TABLE + CELL_IDS,
|
|
364
|
+
useQueriesOrQueriesById(queriesOrQueriesId),
|
|
365
|
+
1 /* Array */,
|
|
366
|
+
[queryId],
|
|
367
|
+
);
|
|
368
|
+
const useResultRowCount = (queryId, queriesOrQueriesId) =>
|
|
369
|
+
useListenable(
|
|
370
|
+
RESULT + ROW_COUNT,
|
|
371
|
+
useQueriesOrQueriesById(queriesOrQueriesId),
|
|
372
|
+
5 /* Number */,
|
|
373
|
+
[queryId],
|
|
374
|
+
);
|
|
375
|
+
const useResultRowIds = (queryId, queriesOrQueriesId) =>
|
|
376
|
+
useListenable(
|
|
377
|
+
RESULT + ROW_IDS,
|
|
378
|
+
useQueriesOrQueriesById(queriesOrQueriesId),
|
|
379
|
+
1 /* Array */,
|
|
380
|
+
[queryId],
|
|
381
|
+
);
|
|
382
|
+
const useResultSortedRowIds = (
|
|
383
|
+
queryId,
|
|
384
|
+
cellId,
|
|
385
|
+
descending,
|
|
386
|
+
offset = 0,
|
|
387
|
+
limit,
|
|
388
|
+
queriesOrQueriesId,
|
|
389
|
+
) =>
|
|
390
|
+
useListenable(
|
|
391
|
+
RESULT + SORTED_ROW_IDS,
|
|
392
|
+
useQueriesOrQueriesById(queriesOrQueriesId),
|
|
393
|
+
1 /* Array */,
|
|
394
|
+
[queryId, cellId, descending, offset, limit],
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
const getCellOrValueType = (cellOrValue) => {
|
|
398
|
+
const type = getTypeOf(cellOrValue);
|
|
399
|
+
return isTypeStringOrBoolean(type) ||
|
|
400
|
+
(type == NUMBER && isFiniteNumber(cellOrValue))
|
|
401
|
+
? type
|
|
402
|
+
: void 0;
|
|
403
|
+
};
|
|
404
|
+
const getTypeCase = (type, stringCase, numberCase, booleanCase) =>
|
|
405
|
+
type == STRING
|
|
406
|
+
? stringCase
|
|
407
|
+
: type == NUMBER
|
|
408
|
+
? numberCase
|
|
409
|
+
: type == BOOLEAN
|
|
410
|
+
? booleanCase
|
|
411
|
+
: null;
|
|
412
|
+
|
|
413
|
+
const useStoreCellComponentProps = (store, tableId) =>
|
|
414
|
+
useMemo(() => ({store, tableId}), [store, tableId]);
|
|
415
|
+
const useQueriesCellComponentProps = (queries, queryId) =>
|
|
416
|
+
useMemo(() => ({queries, queryId}), [queries, queryId]);
|
|
101
417
|
const useCallbackOrUndefined = (callback, deps, test) => {
|
|
102
418
|
const returnCallback = useCallback(callback, deps);
|
|
103
419
|
return test ? returnCallback : void 0;
|
|
@@ -108,69 +424,6 @@ const useParams = (...args) =>
|
|
|
108
424
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
425
|
args,
|
|
110
426
|
);
|
|
111
|
-
const useStoreCellComponentProps = (store, tableId) =>
|
|
112
|
-
useMemo(() => ({store, tableId}), [store, tableId]);
|
|
113
|
-
const useQueriesCellComponentProps = (queries, queryId) =>
|
|
114
|
-
useMemo(() => ({queries, queryId}), [queries, queryId]);
|
|
115
|
-
const useSortingAndPagination = (
|
|
116
|
-
cellId,
|
|
117
|
-
descending = false,
|
|
118
|
-
sortOnClick,
|
|
119
|
-
offset = 0,
|
|
120
|
-
limit,
|
|
121
|
-
total,
|
|
122
|
-
paginator,
|
|
123
|
-
onChange,
|
|
124
|
-
) => {
|
|
125
|
-
const [[currentCellId, currentDescending, currentOffset], setState] =
|
|
126
|
-
useState([cellId, descending, offset]);
|
|
127
|
-
const setStateAndChange = useCallback(
|
|
128
|
-
(sortAndOffset) => {
|
|
129
|
-
setState(sortAndOffset);
|
|
130
|
-
onChange?.(sortAndOffset);
|
|
131
|
-
},
|
|
132
|
-
[onChange],
|
|
133
|
-
);
|
|
134
|
-
const handleSort = useCallbackOrUndefined(
|
|
135
|
-
(cellId2) =>
|
|
136
|
-
setStateAndChange([
|
|
137
|
-
cellId2,
|
|
138
|
-
cellId2 == currentCellId ? !currentDescending : false,
|
|
139
|
-
currentOffset,
|
|
140
|
-
]),
|
|
141
|
-
[setStateAndChange, currentCellId, currentDescending, currentOffset],
|
|
142
|
-
sortOnClick,
|
|
143
|
-
);
|
|
144
|
-
const handleChangeOffset = useCallback(
|
|
145
|
-
(offset2) => setStateAndChange([currentCellId, currentDescending, offset2]),
|
|
146
|
-
[setStateAndChange, currentCellId, currentDescending],
|
|
147
|
-
);
|
|
148
|
-
const PaginatorComponent =
|
|
149
|
-
paginator === true ? SortedTablePaginator : paginator;
|
|
150
|
-
return [
|
|
151
|
-
[currentCellId, currentDescending, currentOffset],
|
|
152
|
-
handleSort,
|
|
153
|
-
useMemo(
|
|
154
|
-
() =>
|
|
155
|
-
paginator === false
|
|
156
|
-
? null
|
|
157
|
-
: /* @__PURE__ */ jsx(PaginatorComponent, {
|
|
158
|
-
offset: currentOffset,
|
|
159
|
-
limit,
|
|
160
|
-
total,
|
|
161
|
-
onChange: handleChangeOffset,
|
|
162
|
-
}),
|
|
163
|
-
[
|
|
164
|
-
paginator,
|
|
165
|
-
PaginatorComponent,
|
|
166
|
-
currentOffset,
|
|
167
|
-
limit,
|
|
168
|
-
total,
|
|
169
|
-
handleChangeOffset,
|
|
170
|
-
],
|
|
171
|
-
),
|
|
172
|
-
];
|
|
173
|
-
};
|
|
174
427
|
const useCells = (defaultCellIds, customCells, defaultCellComponent) =>
|
|
175
428
|
useMemo(() => {
|
|
176
429
|
const cellIds = customCells ?? defaultCellIds;
|
|
@@ -186,6 +439,54 @@ const useCells = (defaultCellIds, customCells, defaultCellComponent) =>
|
|
|
186
439
|
}),
|
|
187
440
|
);
|
|
188
441
|
}, [customCells, defaultCellComponent, defaultCellIds]);
|
|
442
|
+
|
|
443
|
+
const UP_ARROW = '\u2191';
|
|
444
|
+
const DOWN_ARROW = '\u2193';
|
|
445
|
+
const EDITABLE = 'editable';
|
|
446
|
+
const extraRowCells = (extraRowCells2 = [], extraRowCellProps, after = 0) =>
|
|
447
|
+
arrayMap(extraRowCells2, ({component: Component}, index) =>
|
|
448
|
+
/* @__PURE__ */ jsx(
|
|
449
|
+
'td',
|
|
450
|
+
{
|
|
451
|
+
className: EXTRA,
|
|
452
|
+
children: /* @__PURE__ */ jsx(Component, {...extraRowCellProps}),
|
|
453
|
+
},
|
|
454
|
+
extraKey(index, after),
|
|
455
|
+
),
|
|
456
|
+
);
|
|
457
|
+
const extraKey = (index, after) => (after ? '>' : '<') + index;
|
|
458
|
+
const extraHeaders = (extraCells = [], after = 0) =>
|
|
459
|
+
arrayMap(extraCells, ({label}, index) =>
|
|
460
|
+
/* @__PURE__ */ jsx(
|
|
461
|
+
'th',
|
|
462
|
+
{className: EXTRA, children: label},
|
|
463
|
+
extraKey(index, after),
|
|
464
|
+
),
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
const HtmlHeaderCell = ({
|
|
468
|
+
cellId,
|
|
469
|
+
sort: [sortCellId, sortDescending],
|
|
470
|
+
label = cellId ?? EMPTY_STRING,
|
|
471
|
+
onClick,
|
|
472
|
+
}) =>
|
|
473
|
+
/* @__PURE__ */ jsxs('th', {
|
|
474
|
+
onClick: useCallbackOrUndefined(
|
|
475
|
+
() => onClick?.(cellId),
|
|
476
|
+
[onClick, cellId],
|
|
477
|
+
onClick,
|
|
478
|
+
),
|
|
479
|
+
className:
|
|
480
|
+
isUndefined(sortDescending) || sortCellId != cellId
|
|
481
|
+
? void 0
|
|
482
|
+
: `sorted ${sortDescending ? 'de' : 'a'}scending`,
|
|
483
|
+
children: [
|
|
484
|
+
isUndefined(sortDescending) || sortCellId != cellId
|
|
485
|
+
? null
|
|
486
|
+
: (sortDescending ? DOWN_ARROW : UP_ARROW) + ' ',
|
|
487
|
+
label,
|
|
488
|
+
],
|
|
489
|
+
});
|
|
189
490
|
const HtmlTable = ({
|
|
190
491
|
className,
|
|
191
492
|
headerRow,
|
|
@@ -194,6 +495,8 @@ const HtmlTable = ({
|
|
|
194
495
|
cells,
|
|
195
496
|
cellComponentProps,
|
|
196
497
|
rowIds,
|
|
498
|
+
extraCellsBefore,
|
|
499
|
+
extraCellsAfter,
|
|
197
500
|
sortAndOffset,
|
|
198
501
|
handleSort,
|
|
199
502
|
paginatorComponent,
|
|
@@ -210,6 +513,7 @@ const HtmlTable = ({
|
|
|
210
513
|
: /* @__PURE__ */ jsx('thead', {
|
|
211
514
|
children: /* @__PURE__ */ jsxs('tr', {
|
|
212
515
|
children: [
|
|
516
|
+
extraHeaders(extraCellsBefore),
|
|
213
517
|
idColumn === false
|
|
214
518
|
? null
|
|
215
519
|
: /* @__PURE__ */ jsx(HtmlHeaderCell, {
|
|
@@ -229,124 +533,51 @@ const HtmlTable = ({
|
|
|
229
533
|
cellId,
|
|
230
534
|
),
|
|
231
535
|
),
|
|
536
|
+
extraHeaders(extraCellsAfter, 1),
|
|
232
537
|
],
|
|
233
538
|
}),
|
|
234
539
|
}),
|
|
235
540
|
/* @__PURE__ */ jsx('tbody', {
|
|
236
|
-
children: arrayMap(rowIds, (rowId) =>
|
|
237
|
-
|
|
541
|
+
children: arrayMap(rowIds, (rowId) => {
|
|
542
|
+
const rowProps = {...cellComponentProps, rowId};
|
|
543
|
+
return /* @__PURE__ */ jsxs(
|
|
238
544
|
'tr',
|
|
239
545
|
{
|
|
240
546
|
children: [
|
|
547
|
+
extraRowCells(extraCellsBefore, rowProps),
|
|
241
548
|
idColumn === false
|
|
242
549
|
? null
|
|
243
|
-
: /* @__PURE__ */ jsx('th', {children: rowId}),
|
|
550
|
+
: /* @__PURE__ */ jsx('th', {title: rowId, children: rowId}),
|
|
244
551
|
objToArray(
|
|
245
552
|
cells,
|
|
246
|
-
({component:
|
|
553
|
+
({component: CellView, getComponentProps}, cellId) =>
|
|
247
554
|
/* @__PURE__ */ jsx(
|
|
248
555
|
'td',
|
|
249
556
|
{
|
|
250
|
-
children: /* @__PURE__ */ jsx(
|
|
557
|
+
children: /* @__PURE__ */ jsx(CellView, {
|
|
251
558
|
...getProps(getComponentProps, rowId, cellId),
|
|
252
|
-
...
|
|
253
|
-
rowId,
|
|
559
|
+
...rowProps,
|
|
254
560
|
cellId,
|
|
255
561
|
}),
|
|
256
562
|
},
|
|
257
563
|
cellId,
|
|
258
564
|
),
|
|
259
565
|
),
|
|
566
|
+
extraRowCells(extraCellsAfter, rowProps, 1),
|
|
260
567
|
],
|
|
261
568
|
},
|
|
262
569
|
rowId,
|
|
263
|
-
)
|
|
264
|
-
),
|
|
570
|
+
);
|
|
571
|
+
}),
|
|
265
572
|
}),
|
|
266
573
|
],
|
|
267
574
|
});
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
/* @__PURE__ */ jsxs('th', {
|
|
275
|
-
onClick: useCallbackOrUndefined(
|
|
276
|
-
() => onClick?.(cellId),
|
|
277
|
-
[onClick, cellId],
|
|
278
|
-
onClick,
|
|
279
|
-
),
|
|
280
|
-
className:
|
|
281
|
-
isUndefined(sortDescending) || sortCellId != cellId
|
|
282
|
-
? void 0
|
|
283
|
-
: `sorted ${sortDescending ? 'de' : 'a'}scending`,
|
|
284
|
-
children: [
|
|
285
|
-
isUndefined(sortDescending) || sortCellId != cellId
|
|
286
|
-
? null
|
|
287
|
-
: (sortDescending ? DOWN_ARROW : UP_ARROW) + ' ',
|
|
288
|
-
label,
|
|
289
|
-
],
|
|
290
|
-
});
|
|
291
|
-
const RelationshipInHtmlRow = ({
|
|
292
|
-
localRowId,
|
|
293
|
-
params: [
|
|
294
|
-
idColumn,
|
|
295
|
-
cells,
|
|
296
|
-
localTableId,
|
|
297
|
-
remoteTableId,
|
|
298
|
-
relationshipId,
|
|
299
|
-
relationships,
|
|
300
|
-
store,
|
|
301
|
-
],
|
|
302
|
-
}) => {
|
|
303
|
-
const remoteRowId = useRemoteRowId(relationshipId, localRowId, relationships);
|
|
304
|
-
return /* @__PURE__ */ jsxs('tr', {
|
|
305
|
-
children: [
|
|
306
|
-
idColumn === false
|
|
307
|
-
? null
|
|
308
|
-
: /* @__PURE__ */ jsxs(Fragment, {
|
|
309
|
-
children: [
|
|
310
|
-
/* @__PURE__ */ jsx('th', {children: localRowId}),
|
|
311
|
-
/* @__PURE__ */ jsx('th', {children: remoteRowId}),
|
|
312
|
-
],
|
|
313
|
-
}),
|
|
314
|
-
objToArray(
|
|
315
|
-
cells,
|
|
316
|
-
({component: CellView2, getComponentProps}, compoundCellId) => {
|
|
317
|
-
const [tableId, cellId] = strSplit(compoundCellId, DOT, 2);
|
|
318
|
-
const rowId =
|
|
319
|
-
tableId === localTableId
|
|
320
|
-
? localRowId
|
|
321
|
-
: tableId === remoteTableId
|
|
322
|
-
? remoteRowId
|
|
323
|
-
: null;
|
|
324
|
-
return isUndefined(rowId)
|
|
325
|
-
? null
|
|
326
|
-
: /* @__PURE__ */ jsx(
|
|
327
|
-
'td',
|
|
328
|
-
{
|
|
329
|
-
children: /* @__PURE__ */ jsx(CellView2, {
|
|
330
|
-
...getProps(getComponentProps, rowId, cellId),
|
|
331
|
-
store,
|
|
332
|
-
tableId,
|
|
333
|
-
rowId,
|
|
334
|
-
cellId,
|
|
335
|
-
}),
|
|
336
|
-
},
|
|
337
|
-
compoundCellId,
|
|
338
|
-
);
|
|
339
|
-
},
|
|
340
|
-
),
|
|
341
|
-
],
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
const EditableThing = ({
|
|
345
|
-
thing,
|
|
346
|
-
onThingChange,
|
|
347
|
-
className,
|
|
348
|
-
hasSchema,
|
|
349
|
-
showType = true,
|
|
575
|
+
const EditableThing = ({
|
|
576
|
+
thing,
|
|
577
|
+
onThingChange,
|
|
578
|
+
className,
|
|
579
|
+
hasSchema,
|
|
580
|
+
showType = true,
|
|
350
581
|
}) => {
|
|
351
582
|
const [thingType, setThingType] = useState();
|
|
352
583
|
const [currentThing, setCurrentThing] = useState();
|
|
@@ -389,194 +620,172 @@ const EditableThing = ({
|
|
|
389
620
|
booleanThing,
|
|
390
621
|
thingType,
|
|
391
622
|
]);
|
|
623
|
+
const widget = getTypeCase(
|
|
624
|
+
thingType,
|
|
625
|
+
/* @__PURE__ */ jsx(
|
|
626
|
+
'input',
|
|
627
|
+
{
|
|
628
|
+
value: stringThing,
|
|
629
|
+
onChange: useCallback(
|
|
630
|
+
(event) =>
|
|
631
|
+
handleThingChange(
|
|
632
|
+
String(event[CURRENT_TARGET][_VALUE]),
|
|
633
|
+
setStringThing,
|
|
634
|
+
),
|
|
635
|
+
[handleThingChange],
|
|
636
|
+
),
|
|
637
|
+
},
|
|
638
|
+
thingType,
|
|
639
|
+
),
|
|
640
|
+
/* @__PURE__ */ jsx(
|
|
641
|
+
'input',
|
|
642
|
+
{
|
|
643
|
+
type: 'number',
|
|
644
|
+
value: numberThing,
|
|
645
|
+
onChange: useCallback(
|
|
646
|
+
(event) =>
|
|
647
|
+
handleThingChange(
|
|
648
|
+
Number(event[CURRENT_TARGET][_VALUE] || 0),
|
|
649
|
+
setNumberThing,
|
|
650
|
+
),
|
|
651
|
+
[handleThingChange],
|
|
652
|
+
),
|
|
653
|
+
},
|
|
654
|
+
thingType,
|
|
655
|
+
),
|
|
656
|
+
/* @__PURE__ */ jsx(
|
|
657
|
+
'input',
|
|
658
|
+
{
|
|
659
|
+
type: 'checkbox',
|
|
660
|
+
checked: booleanThing,
|
|
661
|
+
onChange: useCallback(
|
|
662
|
+
(event) =>
|
|
663
|
+
handleThingChange(
|
|
664
|
+
Boolean(event[CURRENT_TARGET].checked),
|
|
665
|
+
setBooleanThing,
|
|
666
|
+
),
|
|
667
|
+
[handleThingChange],
|
|
668
|
+
),
|
|
669
|
+
},
|
|
670
|
+
thingType,
|
|
671
|
+
),
|
|
672
|
+
);
|
|
392
673
|
return /* @__PURE__ */ jsxs('div', {
|
|
393
674
|
className,
|
|
394
675
|
children: [
|
|
395
|
-
showType
|
|
676
|
+
showType && widget
|
|
396
677
|
? /* @__PURE__ */ jsx('button', {
|
|
678
|
+
title: thingType,
|
|
397
679
|
className: thingType,
|
|
398
680
|
onClick: handleTypeChange,
|
|
399
681
|
children: thingType,
|
|
400
682
|
})
|
|
401
683
|
: null,
|
|
402
|
-
|
|
403
|
-
thingType,
|
|
404
|
-
/* @__PURE__ */ jsx(
|
|
405
|
-
'input',
|
|
406
|
-
{
|
|
407
|
-
value: stringThing,
|
|
408
|
-
onChange: useCallback(
|
|
409
|
-
(event) =>
|
|
410
|
-
handleThingChange(
|
|
411
|
-
String(event[CURRENT_TARGET][_VALUE]),
|
|
412
|
-
setStringThing,
|
|
413
|
-
),
|
|
414
|
-
[handleThingChange],
|
|
415
|
-
),
|
|
416
|
-
},
|
|
417
|
-
thingType,
|
|
418
|
-
),
|
|
419
|
-
/* @__PURE__ */ jsx(
|
|
420
|
-
'input',
|
|
421
|
-
{
|
|
422
|
-
type: 'number',
|
|
423
|
-
value: numberThing,
|
|
424
|
-
onChange: useCallback(
|
|
425
|
-
(event) =>
|
|
426
|
-
handleThingChange(
|
|
427
|
-
Number(event[CURRENT_TARGET][_VALUE] || 0),
|
|
428
|
-
setNumberThing,
|
|
429
|
-
),
|
|
430
|
-
[handleThingChange],
|
|
431
|
-
),
|
|
432
|
-
},
|
|
433
|
-
thingType,
|
|
434
|
-
),
|
|
435
|
-
/* @__PURE__ */ jsx(
|
|
436
|
-
'input',
|
|
437
|
-
{
|
|
438
|
-
type: 'checkbox',
|
|
439
|
-
checked: booleanThing,
|
|
440
|
-
onChange: useCallback(
|
|
441
|
-
(event) =>
|
|
442
|
-
handleThingChange(
|
|
443
|
-
Boolean(event[CURRENT_TARGET].checked),
|
|
444
|
-
setBooleanThing,
|
|
445
|
-
),
|
|
446
|
-
[handleThingChange],
|
|
447
|
-
),
|
|
448
|
-
},
|
|
449
|
-
thingType,
|
|
450
|
-
),
|
|
451
|
-
),
|
|
684
|
+
widget,
|
|
452
685
|
],
|
|
453
686
|
});
|
|
454
687
|
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
...props,
|
|
458
|
-
params: useParams(
|
|
459
|
-
useCells(
|
|
460
|
-
useTableCellIds(tableId, store),
|
|
461
|
-
customCells,
|
|
462
|
-
editable ? EditableCellView : CellView,
|
|
463
|
-
),
|
|
464
|
-
useStoreCellComponentProps(store, tableId),
|
|
465
|
-
useRowIds(tableId, store),
|
|
466
|
-
),
|
|
467
|
-
});
|
|
468
|
-
const SortedTableInHtmlTable = ({
|
|
688
|
+
|
|
689
|
+
const EditableCellView = ({
|
|
469
690
|
tableId,
|
|
691
|
+
rowId,
|
|
470
692
|
cellId,
|
|
471
|
-
descending,
|
|
472
|
-
offset,
|
|
473
|
-
limit,
|
|
474
693
|
store,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
useSortingAndPagination(
|
|
694
|
+
className,
|
|
695
|
+
showType,
|
|
696
|
+
}) =>
|
|
697
|
+
/* @__PURE__ */ jsx(EditableThing, {
|
|
698
|
+
thing: useCell(tableId, rowId, cellId, store),
|
|
699
|
+
onThingChange: useSetCellCallback(
|
|
700
|
+
tableId,
|
|
701
|
+
rowId,
|
|
484
702
|
cellId,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
limit,
|
|
489
|
-
useRowCount(tableId, store),
|
|
490
|
-
paginator,
|
|
491
|
-
onChange,
|
|
492
|
-
);
|
|
493
|
-
return /* @__PURE__ */ jsx(HtmlTable, {
|
|
494
|
-
...props,
|
|
495
|
-
params: useParams(
|
|
496
|
-
useCells(
|
|
497
|
-
useTableCellIds(tableId, store),
|
|
498
|
-
customCells,
|
|
499
|
-
editable ? EditableCellView : CellView,
|
|
500
|
-
),
|
|
501
|
-
useStoreCellComponentProps(store, tableId),
|
|
502
|
-
useSortedRowIds(tableId, ...sortAndOffset, limit, store),
|
|
503
|
-
sortAndOffset,
|
|
504
|
-
handleSort,
|
|
505
|
-
paginatorComponent,
|
|
703
|
+
(cell) => cell,
|
|
704
|
+
[],
|
|
705
|
+
store,
|
|
506
706
|
),
|
|
707
|
+
className: className ?? EDITABLE + CELL,
|
|
708
|
+
showType,
|
|
709
|
+
hasSchema: useStoreOrStoreById(store)?.hasTablesSchema,
|
|
507
710
|
});
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
711
|
+
|
|
712
|
+
const EditableValueView = ({valueId, store, className, showType}) =>
|
|
713
|
+
/* @__PURE__ */ jsx(EditableThing, {
|
|
714
|
+
thing: useValue(valueId, store),
|
|
715
|
+
onThingChange: useSetValueCallback(valueId, (value) => value, [], store),
|
|
716
|
+
className: className ?? EDITABLE + VALUE,
|
|
717
|
+
showType,
|
|
718
|
+
hasSchema: useStoreOrStoreById(store)?.hasValuesSchema,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
const useDottedCellIds = (tableId, store) =>
|
|
722
|
+
arrayMap(useTableCellIds(tableId, store), (cellId) => tableId + DOT + cellId);
|
|
723
|
+
const RelationshipInHtmlRow = ({
|
|
724
|
+
localRowId,
|
|
725
|
+
params: [
|
|
726
|
+
idColumn,
|
|
727
|
+
cells,
|
|
728
|
+
localTableId,
|
|
729
|
+
remoteTableId,
|
|
730
|
+
relationshipId,
|
|
731
|
+
relationships,
|
|
732
|
+
store,
|
|
733
|
+
extraCellsBefore,
|
|
734
|
+
extraCellsAfter,
|
|
735
|
+
],
|
|
736
|
+
}) => {
|
|
737
|
+
const remoteRowId = useRemoteRowId(relationshipId, localRowId, relationships);
|
|
738
|
+
const rowProps = {
|
|
739
|
+
tableId: localTableId ?? '',
|
|
740
|
+
rowId: localRowId,
|
|
741
|
+
store,
|
|
742
|
+
};
|
|
743
|
+
return /* @__PURE__ */ jsxs('tr', {
|
|
520
744
|
children: [
|
|
521
|
-
|
|
745
|
+
extraRowCells(extraCellsBefore, rowProps),
|
|
746
|
+
idColumn === false
|
|
522
747
|
? null
|
|
523
|
-
: /* @__PURE__ */
|
|
524
|
-
children:
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
748
|
+
: /* @__PURE__ */ jsxs(Fragment, {
|
|
749
|
+
children: [
|
|
750
|
+
/* @__PURE__ */ jsx('th', {
|
|
751
|
+
title: localRowId,
|
|
752
|
+
children: localRowId,
|
|
753
|
+
}),
|
|
754
|
+
/* @__PURE__ */ jsx('th', {
|
|
755
|
+
title: remoteRowId,
|
|
756
|
+
children: remoteRowId,
|
|
757
|
+
}),
|
|
758
|
+
],
|
|
532
759
|
}),
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
760
|
+
objToArray(
|
|
761
|
+
cells,
|
|
762
|
+
({component: CellView2, getComponentProps}, compoundCellId) => {
|
|
763
|
+
const [tableId, cellId] = strSplit(compoundCellId, DOT, 2);
|
|
764
|
+
const rowId =
|
|
765
|
+
tableId === localTableId
|
|
766
|
+
? localRowId
|
|
767
|
+
: tableId === remoteTableId
|
|
768
|
+
? remoteRowId
|
|
769
|
+
: null;
|
|
770
|
+
return isUndefined(rowId)
|
|
771
|
+
? null
|
|
772
|
+
: /* @__PURE__ */ jsx(
|
|
773
|
+
'td',
|
|
774
|
+
{
|
|
775
|
+
children: /* @__PURE__ */ jsx(CellView2, {
|
|
776
|
+
...getProps(getComponentProps, rowId, cellId),
|
|
546
777
|
store,
|
|
778
|
+
tableId,
|
|
779
|
+
rowId,
|
|
780
|
+
cellId,
|
|
547
781
|
}),
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
),
|
|
553
|
-
),
|
|
554
|
-
}),
|
|
555
|
-
],
|
|
556
|
-
});
|
|
557
|
-
const SliceInHtmlTable = ({
|
|
558
|
-
indexId,
|
|
559
|
-
sliceId,
|
|
560
|
-
indexes,
|
|
561
|
-
editable,
|
|
562
|
-
customCells,
|
|
563
|
-
...props
|
|
564
|
-
}) => {
|
|
565
|
-
const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
|
|
566
|
-
useIndexesOrIndexesById(indexes),
|
|
567
|
-
indexId,
|
|
568
|
-
);
|
|
569
|
-
return /* @__PURE__ */ jsx(HtmlTable, {
|
|
570
|
-
...props,
|
|
571
|
-
params: useParams(
|
|
572
|
-
useCells(
|
|
573
|
-
useTableCellIds(tableId, store),
|
|
574
|
-
customCells,
|
|
575
|
-
editable ? EditableCellView : CellView,
|
|
782
|
+
},
|
|
783
|
+
compoundCellId,
|
|
784
|
+
);
|
|
785
|
+
},
|
|
576
786
|
),
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
),
|
|
787
|
+
extraRowCells(extraCellsAfter, rowProps, 1),
|
|
788
|
+
],
|
|
580
789
|
});
|
|
581
790
|
};
|
|
582
791
|
const RelationshipInHtmlTable = ({
|
|
@@ -584,6 +793,8 @@ const RelationshipInHtmlTable = ({
|
|
|
584
793
|
relationships,
|
|
585
794
|
editable,
|
|
586
795
|
customCells,
|
|
796
|
+
extraCellsBefore,
|
|
797
|
+
extraCellsAfter,
|
|
587
798
|
className,
|
|
588
799
|
headerRow,
|
|
589
800
|
idColumn = true,
|
|
@@ -609,6 +820,8 @@ const RelationshipInHtmlTable = ({
|
|
|
609
820
|
relationshipId,
|
|
610
821
|
resolvedRelationships,
|
|
611
822
|
store,
|
|
823
|
+
extraCellsBefore,
|
|
824
|
+
extraCellsAfter,
|
|
612
825
|
);
|
|
613
826
|
return /* @__PURE__ */ jsxs('table', {
|
|
614
827
|
className,
|
|
@@ -618,6 +831,7 @@ const RelationshipInHtmlTable = ({
|
|
|
618
831
|
: /* @__PURE__ */ jsx('thead', {
|
|
619
832
|
children: /* @__PURE__ */ jsxs('tr', {
|
|
620
833
|
children: [
|
|
834
|
+
extraHeaders(extraCellsBefore),
|
|
621
835
|
idColumn === false
|
|
622
836
|
? null
|
|
623
837
|
: /* @__PURE__ */ jsxs(Fragment, {
|
|
@@ -633,6 +847,7 @@ const RelationshipInHtmlTable = ({
|
|
|
633
847
|
objToArray(cells, ({label}, cellId) =>
|
|
634
848
|
/* @__PURE__ */ jsx('th', {children: label}, cellId),
|
|
635
849
|
),
|
|
850
|
+
extraHeaders(extraCellsAfter, 1),
|
|
636
851
|
],
|
|
637
852
|
}),
|
|
638
853
|
}),
|
|
@@ -651,89 +866,68 @@ const RelationshipInHtmlTable = ({
|
|
|
651
866
|
],
|
|
652
867
|
});
|
|
653
868
|
};
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
useCells(
|
|
659
|
-
useResultTableCellIds(queryId, queries),
|
|
660
|
-
customCells,
|
|
661
|
-
ResultCellView,
|
|
662
|
-
),
|
|
663
|
-
useQueriesCellComponentProps(queries, queryId),
|
|
664
|
-
useResultRowIds(queryId, queries),
|
|
665
|
-
),
|
|
666
|
-
});
|
|
667
|
-
const ResultSortedTableInHtmlTable = ({
|
|
668
|
-
queryId,
|
|
869
|
+
|
|
870
|
+
const LEFT_ARROW = '\u2190';
|
|
871
|
+
const RIGHT_ARROW = '\u2192';
|
|
872
|
+
const useSortingAndPagination = (
|
|
669
873
|
cellId,
|
|
670
|
-
descending,
|
|
671
|
-
offset,
|
|
672
|
-
limit,
|
|
673
|
-
queries,
|
|
874
|
+
descending = false,
|
|
674
875
|
sortOnClick,
|
|
675
|
-
|
|
676
|
-
|
|
876
|
+
offset = 0,
|
|
877
|
+
limit,
|
|
878
|
+
total,
|
|
879
|
+
paginator,
|
|
677
880
|
onChange,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
881
|
+
) => {
|
|
882
|
+
const [[currentCellId, currentDescending, currentOffset], setState] =
|
|
883
|
+
useState([cellId, descending, offset]);
|
|
884
|
+
const setStateAndChange = useCallback(
|
|
885
|
+
(sortAndOffset) => {
|
|
886
|
+
setState(sortAndOffset);
|
|
887
|
+
onChange?.(sortAndOffset);
|
|
888
|
+
},
|
|
889
|
+
[onChange],
|
|
890
|
+
);
|
|
891
|
+
const handleSort = useCallbackOrUndefined(
|
|
892
|
+
(cellId2) =>
|
|
893
|
+
setStateAndChange([
|
|
894
|
+
cellId2,
|
|
895
|
+
cellId2 == currentCellId ? !currentDescending : false,
|
|
896
|
+
currentOffset,
|
|
897
|
+
]),
|
|
898
|
+
[setStateAndChange, currentCellId, currentDescending, currentOffset],
|
|
899
|
+
sortOnClick,
|
|
900
|
+
);
|
|
901
|
+
const handleChangeOffset = useCallback(
|
|
902
|
+
(offset2) => setStateAndChange([currentCellId, currentDescending, offset2]),
|
|
903
|
+
[setStateAndChange, currentCellId, currentDescending],
|
|
904
|
+
);
|
|
905
|
+
const PaginatorComponent =
|
|
906
|
+
paginator === true ? SortedTablePaginator : paginator;
|
|
907
|
+
return [
|
|
908
|
+
[currentCellId, currentDescending, currentOffset],
|
|
909
|
+
handleSort,
|
|
910
|
+
useMemo(
|
|
911
|
+
() =>
|
|
912
|
+
paginator === false
|
|
913
|
+
? null
|
|
914
|
+
: /* @__PURE__ */ jsx(PaginatorComponent, {
|
|
915
|
+
offset: currentOffset,
|
|
916
|
+
limit,
|
|
917
|
+
total,
|
|
918
|
+
onChange: handleChangeOffset,
|
|
919
|
+
}),
|
|
920
|
+
[
|
|
921
|
+
paginator,
|
|
922
|
+
PaginatorComponent,
|
|
923
|
+
currentOffset,
|
|
924
|
+
limit,
|
|
925
|
+
total,
|
|
926
|
+
handleChangeOffset,
|
|
927
|
+
],
|
|
704
928
|
),
|
|
705
|
-
|
|
929
|
+
];
|
|
706
930
|
};
|
|
707
|
-
const EditableCellView = ({
|
|
708
|
-
tableId,
|
|
709
|
-
rowId,
|
|
710
|
-
cellId,
|
|
711
|
-
store,
|
|
712
|
-
className,
|
|
713
|
-
showType,
|
|
714
|
-
}) =>
|
|
715
|
-
/* @__PURE__ */ jsx(EditableThing, {
|
|
716
|
-
thing: useCell(tableId, rowId, cellId, store),
|
|
717
|
-
onThingChange: useSetCellCallback(
|
|
718
|
-
tableId,
|
|
719
|
-
rowId,
|
|
720
|
-
cellId,
|
|
721
|
-
(cell) => cell,
|
|
722
|
-
[],
|
|
723
|
-
store,
|
|
724
|
-
),
|
|
725
|
-
className: className ?? EDITABLE + CELL,
|
|
726
|
-
showType,
|
|
727
|
-
hasSchema: useStoreOrStoreById(store)?.hasTablesSchema,
|
|
728
|
-
});
|
|
729
|
-
const EditableValueView = ({valueId, store, className, showType}) =>
|
|
730
|
-
/* @__PURE__ */ jsx(EditableThing, {
|
|
731
|
-
thing: useValue(valueId, store),
|
|
732
|
-
onThingChange: useSetValueCallback(valueId, (value) => value, [], store),
|
|
733
|
-
className: className ?? EDITABLE + VALUE,
|
|
734
|
-
showType,
|
|
735
|
-
hasSchema: useStoreOrStoreById(store)?.hasValuesSchema,
|
|
736
|
-
});
|
|
737
931
|
const SortedTablePaginator = ({
|
|
738
932
|
onChange,
|
|
739
933
|
total,
|
|
@@ -786,9 +980,251 @@ const SortedTablePaginator = ({
|
|
|
786
980
|
});
|
|
787
981
|
};
|
|
788
982
|
|
|
983
|
+
const ResultSortedTableInHtmlTable = ({
|
|
984
|
+
queryId,
|
|
985
|
+
cellId,
|
|
986
|
+
descending,
|
|
987
|
+
offset,
|
|
988
|
+
limit,
|
|
989
|
+
queries,
|
|
990
|
+
sortOnClick,
|
|
991
|
+
paginator = false,
|
|
992
|
+
customCells,
|
|
993
|
+
extraCellsBefore,
|
|
994
|
+
extraCellsAfter,
|
|
995
|
+
onChange,
|
|
996
|
+
...props
|
|
997
|
+
}) => {
|
|
998
|
+
const [sortAndOffset, handleSort, paginatorComponent] =
|
|
999
|
+
useSortingAndPagination(
|
|
1000
|
+
cellId,
|
|
1001
|
+
descending,
|
|
1002
|
+
sortOnClick,
|
|
1003
|
+
offset,
|
|
1004
|
+
limit,
|
|
1005
|
+
useResultRowCount(queryId, queries),
|
|
1006
|
+
paginator,
|
|
1007
|
+
onChange,
|
|
1008
|
+
);
|
|
1009
|
+
return /* @__PURE__ */ jsx(HtmlTable, {
|
|
1010
|
+
...props,
|
|
1011
|
+
params: useParams(
|
|
1012
|
+
useCells(
|
|
1013
|
+
useResultTableCellIds(queryId, queries),
|
|
1014
|
+
customCells,
|
|
1015
|
+
ResultCellView,
|
|
1016
|
+
),
|
|
1017
|
+
useQueriesCellComponentProps(queries, queryId),
|
|
1018
|
+
useResultSortedRowIds(queryId, ...sortAndOffset, limit, queries),
|
|
1019
|
+
extraCellsBefore,
|
|
1020
|
+
extraCellsAfter,
|
|
1021
|
+
sortAndOffset,
|
|
1022
|
+
handleSort,
|
|
1023
|
+
paginatorComponent,
|
|
1024
|
+
),
|
|
1025
|
+
});
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const ResultTableInHtmlTable = ({
|
|
1029
|
+
queryId,
|
|
1030
|
+
queries,
|
|
1031
|
+
customCells,
|
|
1032
|
+
extraCellsBefore,
|
|
1033
|
+
extraCellsAfter,
|
|
1034
|
+
...props
|
|
1035
|
+
}) =>
|
|
1036
|
+
/* @__PURE__ */ jsx(HtmlTable, {
|
|
1037
|
+
...props,
|
|
1038
|
+
params: useParams(
|
|
1039
|
+
useCells(
|
|
1040
|
+
useResultTableCellIds(queryId, queries),
|
|
1041
|
+
customCells,
|
|
1042
|
+
ResultCellView,
|
|
1043
|
+
),
|
|
1044
|
+
useQueriesCellComponentProps(queries, queryId),
|
|
1045
|
+
useResultRowIds(queryId, queries),
|
|
1046
|
+
extraCellsBefore,
|
|
1047
|
+
extraCellsAfter,
|
|
1048
|
+
),
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
const SliceInHtmlTable = ({
|
|
1052
|
+
indexId,
|
|
1053
|
+
sliceId,
|
|
1054
|
+
indexes,
|
|
1055
|
+
editable,
|
|
1056
|
+
customCells,
|
|
1057
|
+
extraCellsBefore,
|
|
1058
|
+
extraCellsAfter,
|
|
1059
|
+
...props
|
|
1060
|
+
}) => {
|
|
1061
|
+
const [resolvedIndexes, store, tableId] = getIndexStoreTableId(
|
|
1062
|
+
useIndexesOrIndexesById(indexes),
|
|
1063
|
+
indexId,
|
|
1064
|
+
);
|
|
1065
|
+
return /* @__PURE__ */ jsx(HtmlTable, {
|
|
1066
|
+
...props,
|
|
1067
|
+
params: useParams(
|
|
1068
|
+
useCells(
|
|
1069
|
+
useTableCellIds(tableId, store),
|
|
1070
|
+
customCells,
|
|
1071
|
+
editable ? EditableCellView : CellView,
|
|
1072
|
+
),
|
|
1073
|
+
useStoreCellComponentProps(store, tableId),
|
|
1074
|
+
useSliceRowIds(indexId, sliceId, resolvedIndexes),
|
|
1075
|
+
extraCellsBefore,
|
|
1076
|
+
extraCellsAfter,
|
|
1077
|
+
),
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
const SortedTableInHtmlTable = ({
|
|
1082
|
+
tableId,
|
|
1083
|
+
cellId,
|
|
1084
|
+
descending,
|
|
1085
|
+
offset,
|
|
1086
|
+
limit,
|
|
1087
|
+
store,
|
|
1088
|
+
editable,
|
|
1089
|
+
sortOnClick,
|
|
1090
|
+
paginator = false,
|
|
1091
|
+
onChange,
|
|
1092
|
+
customCells,
|
|
1093
|
+
extraCellsBefore,
|
|
1094
|
+
extraCellsAfter,
|
|
1095
|
+
...props
|
|
1096
|
+
}) => {
|
|
1097
|
+
const [sortAndOffset, handleSort, paginatorComponent] =
|
|
1098
|
+
useSortingAndPagination(
|
|
1099
|
+
cellId,
|
|
1100
|
+
descending,
|
|
1101
|
+
sortOnClick,
|
|
1102
|
+
offset,
|
|
1103
|
+
limit,
|
|
1104
|
+
useRowCount(tableId, store),
|
|
1105
|
+
paginator,
|
|
1106
|
+
onChange,
|
|
1107
|
+
);
|
|
1108
|
+
return /* @__PURE__ */ jsx(HtmlTable, {
|
|
1109
|
+
...props,
|
|
1110
|
+
params: useParams(
|
|
1111
|
+
useCells(
|
|
1112
|
+
useTableCellIds(tableId, store),
|
|
1113
|
+
customCells,
|
|
1114
|
+
editable ? EditableCellView : CellView,
|
|
1115
|
+
),
|
|
1116
|
+
useStoreCellComponentProps(store, tableId),
|
|
1117
|
+
useSortedRowIds(tableId, ...sortAndOffset, limit, store),
|
|
1118
|
+
extraCellsBefore,
|
|
1119
|
+
extraCellsAfter,
|
|
1120
|
+
sortAndOffset,
|
|
1121
|
+
handleSort,
|
|
1122
|
+
paginatorComponent,
|
|
1123
|
+
),
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
const TableInHtmlTable = ({
|
|
1128
|
+
tableId,
|
|
1129
|
+
store,
|
|
1130
|
+
editable,
|
|
1131
|
+
customCells,
|
|
1132
|
+
extraCellsBefore,
|
|
1133
|
+
extraCellsAfter,
|
|
1134
|
+
...props
|
|
1135
|
+
}) =>
|
|
1136
|
+
/* @__PURE__ */ jsx(HtmlTable, {
|
|
1137
|
+
...props,
|
|
1138
|
+
params: useParams(
|
|
1139
|
+
useCells(
|
|
1140
|
+
useTableCellIds(tableId, store),
|
|
1141
|
+
customCells,
|
|
1142
|
+
editable ? EditableCellView : CellView,
|
|
1143
|
+
),
|
|
1144
|
+
useStoreCellComponentProps(store, tableId),
|
|
1145
|
+
useRowIds(tableId, store),
|
|
1146
|
+
extraCellsBefore,
|
|
1147
|
+
extraCellsAfter,
|
|
1148
|
+
),
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
const extraValueCells = (
|
|
1152
|
+
extraValueCells2 = [],
|
|
1153
|
+
extraValueCellProps,
|
|
1154
|
+
after = 0,
|
|
1155
|
+
) =>
|
|
1156
|
+
arrayMap(extraValueCells2, ({component: Component}, index) =>
|
|
1157
|
+
/* @__PURE__ */ jsx(
|
|
1158
|
+
'td',
|
|
1159
|
+
{
|
|
1160
|
+
className: EXTRA,
|
|
1161
|
+
children: /* @__PURE__ */ jsx(Component, {...extraValueCellProps}),
|
|
1162
|
+
},
|
|
1163
|
+
extraKey(index, after),
|
|
1164
|
+
),
|
|
1165
|
+
);
|
|
1166
|
+
const ValuesInHtmlTable = ({
|
|
1167
|
+
store,
|
|
1168
|
+
editable = false,
|
|
1169
|
+
valueComponent: Value = editable ? EditableValueView : ValueView,
|
|
1170
|
+
getValueComponentProps,
|
|
1171
|
+
extraCellsBefore,
|
|
1172
|
+
extraCellsAfter,
|
|
1173
|
+
className,
|
|
1174
|
+
headerRow,
|
|
1175
|
+
idColumn,
|
|
1176
|
+
}) =>
|
|
1177
|
+
/* @__PURE__ */ jsxs('table', {
|
|
1178
|
+
className,
|
|
1179
|
+
children: [
|
|
1180
|
+
headerRow === false
|
|
1181
|
+
? null
|
|
1182
|
+
: /* @__PURE__ */ jsx('thead', {
|
|
1183
|
+
children: /* @__PURE__ */ jsxs('tr', {
|
|
1184
|
+
children: [
|
|
1185
|
+
extraHeaders(extraCellsBefore),
|
|
1186
|
+
idColumn === false
|
|
1187
|
+
? null
|
|
1188
|
+
: /* @__PURE__ */ jsx('th', {children: 'Id'}),
|
|
1189
|
+
/* @__PURE__ */ jsx('th', {children: VALUE}),
|
|
1190
|
+
extraHeaders(extraCellsAfter, 1),
|
|
1191
|
+
],
|
|
1192
|
+
}),
|
|
1193
|
+
}),
|
|
1194
|
+
/* @__PURE__ */ jsx('tbody', {
|
|
1195
|
+
children: arrayMap(useValueIds(store), (valueId) => {
|
|
1196
|
+
const valueProps = {valueId, store};
|
|
1197
|
+
return /* @__PURE__ */ jsxs(
|
|
1198
|
+
'tr',
|
|
1199
|
+
{
|
|
1200
|
+
children: [
|
|
1201
|
+
extraValueCells(extraCellsBefore, valueProps),
|
|
1202
|
+
idColumn === false
|
|
1203
|
+
? null
|
|
1204
|
+
: /* @__PURE__ */ jsx('th', {
|
|
1205
|
+
title: valueId,
|
|
1206
|
+
children: valueId,
|
|
1207
|
+
}),
|
|
1208
|
+
/* @__PURE__ */ jsx('td', {
|
|
1209
|
+
children: /* @__PURE__ */ jsx(Value, {
|
|
1210
|
+
...getProps(getValueComponentProps, valueId),
|
|
1211
|
+
...valueProps,
|
|
1212
|
+
}),
|
|
1213
|
+
}),
|
|
1214
|
+
extraValueCells(extraCellsAfter, valueProps, 1),
|
|
1215
|
+
],
|
|
1216
|
+
},
|
|
1217
|
+
valueId,
|
|
1218
|
+
);
|
|
1219
|
+
}),
|
|
1220
|
+
}),
|
|
1221
|
+
],
|
|
1222
|
+
});
|
|
1223
|
+
|
|
789
1224
|
export {
|
|
790
1225
|
EditableCellView,
|
|
791
1226
|
EditableValueView,
|
|
1227
|
+
RelationshipInHtmlRow,
|
|
792
1228
|
RelationshipInHtmlTable,
|
|
793
1229
|
ResultSortedTableInHtmlTable,
|
|
794
1230
|
ResultTableInHtmlTable,
|
|
@@ -796,5 +1232,6 @@ export {
|
|
|
796
1232
|
SortedTableInHtmlTable,
|
|
797
1233
|
SortedTablePaginator,
|
|
798
1234
|
TableInHtmlTable,
|
|
1235
|
+
useSortingAndPagination,
|
|
799
1236
|
ValuesInHtmlTable,
|
|
800
1237
|
};
|