tinybase 9.1.0-beta.0 → 9.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.
- package/@types/_internal/store/with-schemas/index.d.ts +133 -2
- package/@types/common/index.d.ts +17 -2
- package/@types/common/with-schemas/index.d.ts +18 -2
- package/@types/indexes/index.d.ts +97 -0
- package/@types/indexes/with-schemas/index.d.ts +137 -0
- package/@types/store/index.d.ts +133 -25
- package/@types/store/with-schemas/index.d.ts +145 -51
- package/@types/ui-react/index.d.ts +48 -2
- package/@types/ui-react/with-schemas/index.d.ts +108 -34
- package/@types/ui-solid/index.d.ts +51 -2
- package/@types/ui-solid/with-schemas/index.d.ts +111 -34
- package/@types/ui-svelte/index.d.ts +84 -2
- package/@types/ui-svelte/with-schemas/index.d.ts +122 -25
- package/index.js +155 -38
- package/indexes/index.js +39 -0
- package/indexes/with-schemas/index.js +39 -0
- package/mergeable-store/index.js +116 -38
- package/mergeable-store/with-schemas/index.js +116 -38
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/indexes/index.js +1 -1
- package/min/indexes/index.js.gz +0 -0
- package/min/indexes/with-schemas/index.js +1 -1
- package/min/indexes/with-schemas/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/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/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-dom-charts/index.js +1 -1
- package/min/ui-react-dom-charts/index.js.gz +0 -0
- package/min/ui-react-dom-charts/with-schemas/index.js +1 -1
- package/min/ui-react-dom-charts/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/ui-solid/index.js +1 -1
- package/min/ui-solid/index.js.gz +0 -0
- package/min/ui-solid/with-schemas/index.js +1 -1
- package/min/ui-solid/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-dom/index.js +1 -1
- package/min/ui-solid-dom/index.js.gz +0 -0
- package/min/ui-solid-dom/with-schemas/index.js +1 -1
- package/min/ui-solid-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-dom/index.js +1 -1
- package/min/ui-svelte-dom/index.js.gz +0 -0
- package/min/ui-svelte-dom/with-schemas/index.js +1 -1
- package/min/ui-svelte-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-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 +155 -38
- package/omni/with-schemas/index.js +155 -38
- package/package.json +3 -3
- package/readme.md +14 -14
- package/releases.md +101 -60
- package/store/index.js +116 -38
- package/store/with-schemas/index.js +116 -38
- package/ui-react/index.js +52 -6
- package/ui-react/with-schemas/index.js +52 -6
- package/ui-react-dom/index.js +24 -4
- package/ui-react-dom/with-schemas/index.js +24 -4
- package/ui-react-dom-charts/index.js +24 -4
- package/ui-react-dom-charts/with-schemas/index.js +24 -4
- package/ui-react-inspector/index.js +140 -42
- package/ui-react-inspector/with-schemas/index.js +140 -42
- package/ui-solid/index.js +48 -2
- package/ui-solid/with-schemas/index.js +48 -2
- package/ui-solid-dom/index.js +17 -1
- package/ui-solid-dom/with-schemas/index.js +17 -1
- package/ui-solid-inspector/index.js +133 -39
- package/ui-solid-inspector/with-schemas/index.js +133 -39
- package/ui-svelte/index.js +91 -31
- package/ui-svelte/with-schemas/index.js +91 -31
- package/ui-svelte-dom/index.js +35 -14
- package/ui-svelte-dom/with-schemas/index.js +35 -14
- package/ui-svelte-inspector/index.js +151 -52
- package/ui-svelte-inspector/with-schemas/index.js +151 -52
- package/with-schemas/index.js +155 -38
|
@@ -43,6 +43,7 @@ const RELATIONSHIP = 'Relationship';
|
|
|
43
43
|
const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
44
44
|
const QUERY = 'Query';
|
|
45
45
|
const EXTRA = 'extra';
|
|
46
|
+
const REQUIRED = 'required';
|
|
46
47
|
const UNDEFINED = '\uFFFC';
|
|
47
48
|
const JSON_PREFIX = '\uFFFD';
|
|
48
49
|
const id = (key) => EMPTY_STRING + key;
|
|
@@ -1177,6 +1178,7 @@ const createStore = () => {
|
|
|
1177
1178
|
const valuesSchemaMap = mapNew();
|
|
1178
1179
|
const valuesDefaulted = mapNew();
|
|
1179
1180
|
const valuesNonDefaulted = setNew();
|
|
1181
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
1180
1182
|
const tablePoolFunctions = mapNew();
|
|
1181
1183
|
const tableCellIds = mapNew();
|
|
1182
1184
|
const tablesMap = mapNew();
|
|
@@ -1229,7 +1231,7 @@ const createStore = () => {
|
|
|
1229
1231
|
const validateCellOrValueSchema = (schema) => {
|
|
1230
1232
|
if (
|
|
1231
1233
|
!objValidate(schema, (_child, id2) =>
|
|
1232
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
1234
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
1233
1235
|
)
|
|
1234
1236
|
) {
|
|
1235
1237
|
return false;
|
|
@@ -1264,20 +1266,32 @@ const createStore = () => {
|
|
|
1264
1266
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
1265
1267
|
() => cellInvalid(tableId),
|
|
1266
1268
|
);
|
|
1267
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
(
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1269
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
1270
|
+
const rowWithDefaults = skipDefaults
|
|
1271
|
+
? row
|
|
1272
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
1273
|
+
return (
|
|
1274
|
+
objValidate(
|
|
1275
|
+
rowWithDefaults,
|
|
1276
|
+
(cell, cellId) =>
|
|
1277
|
+
ifNotUndefined(
|
|
1278
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
1279
|
+
(validCell) => {
|
|
1280
|
+
row[cellId] = validCell;
|
|
1281
|
+
return true;
|
|
1282
|
+
},
|
|
1283
|
+
() => false,
|
|
1284
|
+
),
|
|
1285
|
+
() => cellInvalid(tableId, rowId),
|
|
1286
|
+
) &&
|
|
1287
|
+
(skipDefaults
|
|
1288
|
+
? true
|
|
1289
|
+
: arrayEvery(
|
|
1290
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
1291
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
1292
|
+
))
|
|
1280
1293
|
);
|
|
1294
|
+
};
|
|
1281
1295
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
1282
1296
|
hasTablesSchema
|
|
1283
1297
|
? ifNotUndefined(
|
|
@@ -1303,20 +1317,31 @@ const createStore = () => {
|
|
|
1303
1317
|
: isUndefined(getCellOrValueType(cell))
|
|
1304
1318
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
1305
1319
|
: encodeIfJson(cell);
|
|
1306
|
-
const validateValues = (values, skipDefaults) =>
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1320
|
+
const validateValues = (values, skipDefaults) => {
|
|
1321
|
+
const valuesWithDefaults = skipDefaults
|
|
1322
|
+
? values
|
|
1323
|
+
: addDefaultsToValues(values);
|
|
1324
|
+
return (
|
|
1325
|
+
objValidate(
|
|
1326
|
+
valuesWithDefaults,
|
|
1327
|
+
(value, valueId) =>
|
|
1328
|
+
ifNotUndefined(
|
|
1329
|
+
getValidatedValue(valueId, value),
|
|
1330
|
+
(validValue) => {
|
|
1331
|
+
values[valueId] = validValue;
|
|
1332
|
+
return true;
|
|
1333
|
+
},
|
|
1334
|
+
() => false,
|
|
1335
|
+
),
|
|
1336
|
+
() => valueInvalid(),
|
|
1337
|
+
) &&
|
|
1338
|
+
(skipDefaults
|
|
1339
|
+
? true
|
|
1340
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
1341
|
+
objHas(valuesWithDefaults, valueId),
|
|
1342
|
+
))
|
|
1319
1343
|
);
|
|
1344
|
+
};
|
|
1320
1345
|
const getValidatedValue = (valueId, value) =>
|
|
1321
1346
|
hasValuesSchema
|
|
1322
1347
|
? ifNotUndefined(
|
|
@@ -1387,6 +1412,7 @@ const createStore = () => {
|
|
|
1387
1412
|
(_tablesSchema, tableId, tableSchema) => {
|
|
1388
1413
|
const rowDefaulted = mapNew();
|
|
1389
1414
|
const rowNonDefaulted = setNew();
|
|
1415
|
+
const rowRequiredNonDefaulted = setNew();
|
|
1390
1416
|
mapMatch(
|
|
1391
1417
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
1392
1418
|
tableSchema,
|
|
@@ -1394,12 +1420,23 @@ const createStore = () => {
|
|
|
1394
1420
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
1395
1421
|
ifNotUndefined(
|
|
1396
1422
|
cellSchema[DEFAULT],
|
|
1397
|
-
(
|
|
1398
|
-
|
|
1423
|
+
(defaultCell) => {
|
|
1424
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
1425
|
+
},
|
|
1426
|
+
() => {
|
|
1427
|
+
setAdd(rowNonDefaulted, cellId);
|
|
1428
|
+
if (cellSchema[REQUIRED] === true) {
|
|
1429
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1399
1432
|
);
|
|
1400
1433
|
},
|
|
1401
1434
|
);
|
|
1402
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
1435
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
1436
|
+
rowDefaulted,
|
|
1437
|
+
rowNonDefaulted,
|
|
1438
|
+
rowRequiredNonDefaulted,
|
|
1439
|
+
]);
|
|
1403
1440
|
},
|
|
1404
1441
|
(_tablesSchema, tableId) => {
|
|
1405
1442
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -1414,14 +1451,27 @@ const createStore = () => {
|
|
|
1414
1451
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
1415
1452
|
ifNotUndefined(
|
|
1416
1453
|
valueSchema[DEFAULT],
|
|
1417
|
-
(
|
|
1418
|
-
|
|
1454
|
+
(defaultValue) => {
|
|
1455
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
1456
|
+
collDel(valuesNonDefaulted, valueId);
|
|
1457
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1458
|
+
},
|
|
1459
|
+
() => {
|
|
1460
|
+
mapSet(valuesDefaulted, valueId);
|
|
1461
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
1462
|
+
if (valueSchema[REQUIRED] === true) {
|
|
1463
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
1464
|
+
} else {
|
|
1465
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1466
|
+
}
|
|
1467
|
+
},
|
|
1419
1468
|
);
|
|
1420
1469
|
},
|
|
1421
1470
|
(_valuesSchema, valueId) => {
|
|
1422
1471
|
mapSet(valuesSchemaMap, valueId);
|
|
1423
1472
|
mapSet(valuesDefaulted, valueId);
|
|
1424
1473
|
collDel(valuesNonDefaulted, valueId);
|
|
1474
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1425
1475
|
},
|
|
1426
1476
|
);
|
|
1427
1477
|
const setOrDelTables = (tables) =>
|
|
@@ -2094,13 +2144,36 @@ const createStore = () => {
|
|
|
2094
2144
|
listener,
|
|
2095
2145
|
mutator,
|
|
2096
2146
|
) => {
|
|
2097
|
-
|
|
2147
|
+
const [descending, offset, limit, sorter] = otherArgs;
|
|
2148
|
+
let sortedRowIds = getSortedRowIds(
|
|
2149
|
+
tableId,
|
|
2150
|
+
cellId,
|
|
2151
|
+
descending,
|
|
2152
|
+
offset,
|
|
2153
|
+
limit,
|
|
2154
|
+
sorter,
|
|
2155
|
+
);
|
|
2098
2156
|
return addListener(
|
|
2099
2157
|
() => {
|
|
2100
|
-
const newSortedRowIds = getSortedRowIds(
|
|
2158
|
+
const newSortedRowIds = getSortedRowIds(
|
|
2159
|
+
tableId,
|
|
2160
|
+
cellId,
|
|
2161
|
+
descending,
|
|
2162
|
+
offset,
|
|
2163
|
+
limit,
|
|
2164
|
+
sorter,
|
|
2165
|
+
);
|
|
2101
2166
|
if (!arrayIsEqual(newSortedRowIds, sortedRowIds)) {
|
|
2102
2167
|
sortedRowIds = newSortedRowIds;
|
|
2103
|
-
listener(
|
|
2168
|
+
listener(
|
|
2169
|
+
store,
|
|
2170
|
+
tableId,
|
|
2171
|
+
cellId,
|
|
2172
|
+
descending,
|
|
2173
|
+
offset,
|
|
2174
|
+
limit,
|
|
2175
|
+
sortedRowIds,
|
|
2176
|
+
);
|
|
2104
2177
|
}
|
|
2105
2178
|
},
|
|
2106
2179
|
sortedRowIdsListeners[mutator ? 1 : 0],
|
|
@@ -2154,6 +2227,7 @@ const createStore = () => {
|
|
|
2154
2227
|
descending,
|
|
2155
2228
|
offset = 0,
|
|
2156
2229
|
limit,
|
|
2230
|
+
sorter = defaultSorter,
|
|
2157
2231
|
) =>
|
|
2158
2232
|
isObject(tableIdOrArgs)
|
|
2159
2233
|
? getSortedRowIds(
|
|
@@ -2162,16 +2236,19 @@ const createStore = () => {
|
|
|
2162
2236
|
tableIdOrArgs.descending,
|
|
2163
2237
|
tableIdOrArgs.offset,
|
|
2164
2238
|
tableIdOrArgs.limit,
|
|
2239
|
+
tableIdOrArgs.sorter,
|
|
2165
2240
|
)
|
|
2166
2241
|
: arrayMap(
|
|
2167
2242
|
slice(
|
|
2168
2243
|
arraySort(
|
|
2169
2244
|
mapMap(mapGet(tablesMap, id(tableIdOrArgs)), (row, rowId) => [
|
|
2170
|
-
isUndefined(cellId)
|
|
2245
|
+
isUndefined(cellId)
|
|
2246
|
+
? rowId
|
|
2247
|
+
: decodeIfJson(mapGet(row, id(cellId))),
|
|
2171
2248
|
rowId,
|
|
2172
2249
|
]),
|
|
2173
2250
|
([cell1], [cell2]) =>
|
|
2174
|
-
|
|
2251
|
+
sorter(cell1, cell2) * (descending ? -1 : 1),
|
|
2175
2252
|
),
|
|
2176
2253
|
offset,
|
|
2177
2254
|
isUndefined(limit) ? limit : offset + limit,
|
|
@@ -2649,6 +2726,7 @@ const createStore = () => {
|
|
|
2649
2726
|
tableIdOrArgs.descending ?? false,
|
|
2650
2727
|
tableIdOrArgs.offset ?? 0,
|
|
2651
2728
|
tableIdOrArgs.limit,
|
|
2729
|
+
tableIdOrArgs.sorter,
|
|
2652
2730
|
],
|
|
2653
2731
|
cellIdOrListener,
|
|
2654
2732
|
descendingOrMutator,
|
|
@@ -2656,7 +2734,7 @@ const createStore = () => {
|
|
|
2656
2734
|
: addSortedRowIdsListenerImpl(
|
|
2657
2735
|
tableIdOrArgs,
|
|
2658
2736
|
cellIdOrListener,
|
|
2659
|
-
[descendingOrMutator, offset, limit],
|
|
2737
|
+
[descendingOrMutator, offset, limit, void 0],
|
|
2660
2738
|
listener,
|
|
2661
2739
|
mutator,
|
|
2662
2740
|
);
|
|
@@ -3037,25 +3115,45 @@ const getRowIds = (tableId, storeOrStoreId) =>
|
|
|
3037
3115
|
]);
|
|
3038
3116
|
|
|
3039
3117
|
const getSortedRowIds = (
|
|
3040
|
-
|
|
3041
|
-
|
|
3118
|
+
tableIdOrArgs,
|
|
3119
|
+
cellIdOrStoreOrStoreId,
|
|
3042
3120
|
descending = false,
|
|
3043
3121
|
offset = 0,
|
|
3044
3122
|
limit,
|
|
3123
|
+
sorter,
|
|
3045
3124
|
storeOrStoreId,
|
|
3046
3125
|
) =>
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3126
|
+
isObject(tableIdOrArgs)
|
|
3127
|
+
? createListenable(
|
|
3128
|
+
resolveStore(cellIdOrStoreOrStoreId),
|
|
3129
|
+
SORTED_ROW_IDS,
|
|
3130
|
+
EMPTY_ARR,
|
|
3131
|
+
() => [tableIdOrArgs],
|
|
3132
|
+
)
|
|
3133
|
+
: createListenable(
|
|
3134
|
+
resolveStore(storeOrStoreId),
|
|
3135
|
+
SORTED_ROW_IDS,
|
|
3136
|
+
EMPTY_ARR,
|
|
3137
|
+
() =>
|
|
3138
|
+
isUndefined(sorter)
|
|
3139
|
+
? [
|
|
3140
|
+
maybeGet$1(tableIdOrArgs),
|
|
3141
|
+
maybeGet$1(cellIdOrStoreOrStoreId),
|
|
3142
|
+
maybeGet$1(descending),
|
|
3143
|
+
maybeGet$1(offset),
|
|
3144
|
+
maybeGet$1(limit),
|
|
3145
|
+
]
|
|
3146
|
+
: [
|
|
3147
|
+
{
|
|
3148
|
+
tableId: maybeGet$1(tableIdOrArgs),
|
|
3149
|
+
cellId: maybeGet$1(cellIdOrStoreOrStoreId),
|
|
3150
|
+
descending: maybeGet$1(descending) ?? false,
|
|
3151
|
+
offset: maybeGet$1(offset) ?? 0,
|
|
3152
|
+
limit: maybeGet$1(limit),
|
|
3153
|
+
sorter,
|
|
3154
|
+
},
|
|
3155
|
+
],
|
|
3156
|
+
);
|
|
3059
3157
|
const getCellIds = (tableId, rowId, storeOrStoreId) =>
|
|
3060
3158
|
createListenable(resolveStore(storeOrStoreId), CELL_IDS, EMPTY_ARR, () => [
|
|
3061
3159
|
maybeGet$1(tableId),
|
|
@@ -5045,6 +5143,7 @@ function SortedTableInHtmlTable($$anchor, $$props) {
|
|
|
5045
5143
|
() => sorting.sortAndOffset[1],
|
|
5046
5144
|
() => sorting.sortAndOffset[2],
|
|
5047
5145
|
() => $$props.limit,
|
|
5146
|
+
undefined,
|
|
5048
5147
|
() => $$props.store,
|
|
5049
5148
|
);
|
|
5050
5149
|
const defaultCellComponent = $.derived(() =>
|
|
@@ -43,6 +43,7 @@ const RELATIONSHIP = 'Relationship';
|
|
|
43
43
|
const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
|
|
44
44
|
const QUERY = 'Query';
|
|
45
45
|
const EXTRA = 'extra';
|
|
46
|
+
const REQUIRED = 'required';
|
|
46
47
|
const UNDEFINED = '\uFFFC';
|
|
47
48
|
const JSON_PREFIX = '\uFFFD';
|
|
48
49
|
const id = (key) => EMPTY_STRING + key;
|
|
@@ -1177,6 +1178,7 @@ const createStore = () => {
|
|
|
1177
1178
|
const valuesSchemaMap = mapNew();
|
|
1178
1179
|
const valuesDefaulted = mapNew();
|
|
1179
1180
|
const valuesNonDefaulted = setNew();
|
|
1181
|
+
const valuesRequiredNonDefaulted = setNew();
|
|
1180
1182
|
const tablePoolFunctions = mapNew();
|
|
1181
1183
|
const tableCellIds = mapNew();
|
|
1182
1184
|
const tablesMap = mapNew();
|
|
@@ -1229,7 +1231,7 @@ const createStore = () => {
|
|
|
1229
1231
|
const validateCellOrValueSchema = (schema) => {
|
|
1230
1232
|
if (
|
|
1231
1233
|
!objValidate(schema, (_child, id2) =>
|
|
1232
|
-
arrayHas([TYPE, DEFAULT, ALLOW_NULL], id2),
|
|
1234
|
+
arrayHas([TYPE, DEFAULT, ALLOW_NULL, REQUIRED], id2),
|
|
1233
1235
|
)
|
|
1234
1236
|
) {
|
|
1235
1237
|
return false;
|
|
@@ -1264,20 +1266,32 @@ const createStore = () => {
|
|
|
1264
1266
|
(row, rowId) => validateRow(tableId, rowId, row),
|
|
1265
1267
|
() => cellInvalid(tableId),
|
|
1266
1268
|
);
|
|
1267
|
-
const validateRow = (tableId, rowId, row, skipDefaults) =>
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
(
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1269
|
+
const validateRow = (tableId, rowId, row, skipDefaults) => {
|
|
1270
|
+
const rowWithDefaults = skipDefaults
|
|
1271
|
+
? row
|
|
1272
|
+
: addDefaultsToRow(row, tableId, rowId);
|
|
1273
|
+
return (
|
|
1274
|
+
objValidate(
|
|
1275
|
+
rowWithDefaults,
|
|
1276
|
+
(cell, cellId) =>
|
|
1277
|
+
ifNotUndefined(
|
|
1278
|
+
getValidatedCell(tableId, rowId, cellId, cell),
|
|
1279
|
+
(validCell) => {
|
|
1280
|
+
row[cellId] = validCell;
|
|
1281
|
+
return true;
|
|
1282
|
+
},
|
|
1283
|
+
() => false,
|
|
1284
|
+
),
|
|
1285
|
+
() => cellInvalid(tableId, rowId),
|
|
1286
|
+
) &&
|
|
1287
|
+
(skipDefaults
|
|
1288
|
+
? true
|
|
1289
|
+
: arrayEvery(
|
|
1290
|
+
collValues(mapGet(tablesSchemaRowCache, tableId)?.[2]),
|
|
1291
|
+
(cellId) => objHas(rowWithDefaults, cellId),
|
|
1292
|
+
))
|
|
1280
1293
|
);
|
|
1294
|
+
};
|
|
1281
1295
|
const getValidatedCell = (tableId, rowId, cellId, cell) =>
|
|
1282
1296
|
hasTablesSchema
|
|
1283
1297
|
? ifNotUndefined(
|
|
@@ -1303,20 +1317,31 @@ const createStore = () => {
|
|
|
1303
1317
|
: isUndefined(getCellOrValueType(cell))
|
|
1304
1318
|
? cellInvalid(tableId, rowId, cellId, cell)
|
|
1305
1319
|
: encodeIfJson(cell);
|
|
1306
|
-
const validateValues = (values, skipDefaults) =>
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1320
|
+
const validateValues = (values, skipDefaults) => {
|
|
1321
|
+
const valuesWithDefaults = skipDefaults
|
|
1322
|
+
? values
|
|
1323
|
+
: addDefaultsToValues(values);
|
|
1324
|
+
return (
|
|
1325
|
+
objValidate(
|
|
1326
|
+
valuesWithDefaults,
|
|
1327
|
+
(value, valueId) =>
|
|
1328
|
+
ifNotUndefined(
|
|
1329
|
+
getValidatedValue(valueId, value),
|
|
1330
|
+
(validValue) => {
|
|
1331
|
+
values[valueId] = validValue;
|
|
1332
|
+
return true;
|
|
1333
|
+
},
|
|
1334
|
+
() => false,
|
|
1335
|
+
),
|
|
1336
|
+
() => valueInvalid(),
|
|
1337
|
+
) &&
|
|
1338
|
+
(skipDefaults
|
|
1339
|
+
? true
|
|
1340
|
+
: arrayEvery(collValues(valuesRequiredNonDefaulted), (valueId) =>
|
|
1341
|
+
objHas(valuesWithDefaults, valueId),
|
|
1342
|
+
))
|
|
1319
1343
|
);
|
|
1344
|
+
};
|
|
1320
1345
|
const getValidatedValue = (valueId, value) =>
|
|
1321
1346
|
hasValuesSchema
|
|
1322
1347
|
? ifNotUndefined(
|
|
@@ -1387,6 +1412,7 @@ const createStore = () => {
|
|
|
1387
1412
|
(_tablesSchema, tableId, tableSchema) => {
|
|
1388
1413
|
const rowDefaulted = mapNew();
|
|
1389
1414
|
const rowNonDefaulted = setNew();
|
|
1415
|
+
const rowRequiredNonDefaulted = setNew();
|
|
1390
1416
|
mapMatch(
|
|
1391
1417
|
mapEnsure(tablesSchemaMap, tableId, mapNew),
|
|
1392
1418
|
tableSchema,
|
|
@@ -1394,12 +1420,23 @@ const createStore = () => {
|
|
|
1394
1420
|
mapSet(tableSchemaMap, cellId, cellSchema);
|
|
1395
1421
|
ifNotUndefined(
|
|
1396
1422
|
cellSchema[DEFAULT],
|
|
1397
|
-
(
|
|
1398
|
-
|
|
1423
|
+
(defaultCell) => {
|
|
1424
|
+
mapSet(rowDefaulted, cellId, defaultCell);
|
|
1425
|
+
},
|
|
1426
|
+
() => {
|
|
1427
|
+
setAdd(rowNonDefaulted, cellId);
|
|
1428
|
+
if (cellSchema[REQUIRED] === true) {
|
|
1429
|
+
setAdd(rowRequiredNonDefaulted, cellId);
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1399
1432
|
);
|
|
1400
1433
|
},
|
|
1401
1434
|
);
|
|
1402
|
-
mapSet(tablesSchemaRowCache, tableId, [
|
|
1435
|
+
mapSet(tablesSchemaRowCache, tableId, [
|
|
1436
|
+
rowDefaulted,
|
|
1437
|
+
rowNonDefaulted,
|
|
1438
|
+
rowRequiredNonDefaulted,
|
|
1439
|
+
]);
|
|
1403
1440
|
},
|
|
1404
1441
|
(_tablesSchema, tableId) => {
|
|
1405
1442
|
mapSet(tablesSchemaMap, tableId);
|
|
@@ -1414,14 +1451,27 @@ const createStore = () => {
|
|
|
1414
1451
|
mapSet(valuesSchemaMap, valueId, valueSchema);
|
|
1415
1452
|
ifNotUndefined(
|
|
1416
1453
|
valueSchema[DEFAULT],
|
|
1417
|
-
(
|
|
1418
|
-
|
|
1454
|
+
(defaultValue) => {
|
|
1455
|
+
mapSet(valuesDefaulted, valueId, defaultValue);
|
|
1456
|
+
collDel(valuesNonDefaulted, valueId);
|
|
1457
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1458
|
+
},
|
|
1459
|
+
() => {
|
|
1460
|
+
mapSet(valuesDefaulted, valueId);
|
|
1461
|
+
setAdd(valuesNonDefaulted, valueId);
|
|
1462
|
+
if (valueSchema[REQUIRED] === true) {
|
|
1463
|
+
setAdd(valuesRequiredNonDefaulted, valueId);
|
|
1464
|
+
} else {
|
|
1465
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1466
|
+
}
|
|
1467
|
+
},
|
|
1419
1468
|
);
|
|
1420
1469
|
},
|
|
1421
1470
|
(_valuesSchema, valueId) => {
|
|
1422
1471
|
mapSet(valuesSchemaMap, valueId);
|
|
1423
1472
|
mapSet(valuesDefaulted, valueId);
|
|
1424
1473
|
collDel(valuesNonDefaulted, valueId);
|
|
1474
|
+
collDel(valuesRequiredNonDefaulted, valueId);
|
|
1425
1475
|
},
|
|
1426
1476
|
);
|
|
1427
1477
|
const setOrDelTables = (tables) =>
|
|
@@ -2094,13 +2144,36 @@ const createStore = () => {
|
|
|
2094
2144
|
listener,
|
|
2095
2145
|
mutator,
|
|
2096
2146
|
) => {
|
|
2097
|
-
|
|
2147
|
+
const [descending, offset, limit, sorter] = otherArgs;
|
|
2148
|
+
let sortedRowIds = getSortedRowIds(
|
|
2149
|
+
tableId,
|
|
2150
|
+
cellId,
|
|
2151
|
+
descending,
|
|
2152
|
+
offset,
|
|
2153
|
+
limit,
|
|
2154
|
+
sorter,
|
|
2155
|
+
);
|
|
2098
2156
|
return addListener(
|
|
2099
2157
|
() => {
|
|
2100
|
-
const newSortedRowIds = getSortedRowIds(
|
|
2158
|
+
const newSortedRowIds = getSortedRowIds(
|
|
2159
|
+
tableId,
|
|
2160
|
+
cellId,
|
|
2161
|
+
descending,
|
|
2162
|
+
offset,
|
|
2163
|
+
limit,
|
|
2164
|
+
sorter,
|
|
2165
|
+
);
|
|
2101
2166
|
if (!arrayIsEqual(newSortedRowIds, sortedRowIds)) {
|
|
2102
2167
|
sortedRowIds = newSortedRowIds;
|
|
2103
|
-
listener(
|
|
2168
|
+
listener(
|
|
2169
|
+
store,
|
|
2170
|
+
tableId,
|
|
2171
|
+
cellId,
|
|
2172
|
+
descending,
|
|
2173
|
+
offset,
|
|
2174
|
+
limit,
|
|
2175
|
+
sortedRowIds,
|
|
2176
|
+
);
|
|
2104
2177
|
}
|
|
2105
2178
|
},
|
|
2106
2179
|
sortedRowIdsListeners[mutator ? 1 : 0],
|
|
@@ -2154,6 +2227,7 @@ const createStore = () => {
|
|
|
2154
2227
|
descending,
|
|
2155
2228
|
offset = 0,
|
|
2156
2229
|
limit,
|
|
2230
|
+
sorter = defaultSorter,
|
|
2157
2231
|
) =>
|
|
2158
2232
|
isObject(tableIdOrArgs)
|
|
2159
2233
|
? getSortedRowIds(
|
|
@@ -2162,16 +2236,19 @@ const createStore = () => {
|
|
|
2162
2236
|
tableIdOrArgs.descending,
|
|
2163
2237
|
tableIdOrArgs.offset,
|
|
2164
2238
|
tableIdOrArgs.limit,
|
|
2239
|
+
tableIdOrArgs.sorter,
|
|
2165
2240
|
)
|
|
2166
2241
|
: arrayMap(
|
|
2167
2242
|
slice(
|
|
2168
2243
|
arraySort(
|
|
2169
2244
|
mapMap(mapGet(tablesMap, id(tableIdOrArgs)), (row, rowId) => [
|
|
2170
|
-
isUndefined(cellId)
|
|
2245
|
+
isUndefined(cellId)
|
|
2246
|
+
? rowId
|
|
2247
|
+
: decodeIfJson(mapGet(row, id(cellId))),
|
|
2171
2248
|
rowId,
|
|
2172
2249
|
]),
|
|
2173
2250
|
([cell1], [cell2]) =>
|
|
2174
|
-
|
|
2251
|
+
sorter(cell1, cell2) * (descending ? -1 : 1),
|
|
2175
2252
|
),
|
|
2176
2253
|
offset,
|
|
2177
2254
|
isUndefined(limit) ? limit : offset + limit,
|
|
@@ -2649,6 +2726,7 @@ const createStore = () => {
|
|
|
2649
2726
|
tableIdOrArgs.descending ?? false,
|
|
2650
2727
|
tableIdOrArgs.offset ?? 0,
|
|
2651
2728
|
tableIdOrArgs.limit,
|
|
2729
|
+
tableIdOrArgs.sorter,
|
|
2652
2730
|
],
|
|
2653
2731
|
cellIdOrListener,
|
|
2654
2732
|
descendingOrMutator,
|
|
@@ -2656,7 +2734,7 @@ const createStore = () => {
|
|
|
2656
2734
|
: addSortedRowIdsListenerImpl(
|
|
2657
2735
|
tableIdOrArgs,
|
|
2658
2736
|
cellIdOrListener,
|
|
2659
|
-
[descendingOrMutator, offset, limit],
|
|
2737
|
+
[descendingOrMutator, offset, limit, void 0],
|
|
2660
2738
|
listener,
|
|
2661
2739
|
mutator,
|
|
2662
2740
|
);
|
|
@@ -3037,25 +3115,45 @@ const getRowIds = (tableId, storeOrStoreId) =>
|
|
|
3037
3115
|
]);
|
|
3038
3116
|
|
|
3039
3117
|
const getSortedRowIds = (
|
|
3040
|
-
|
|
3041
|
-
|
|
3118
|
+
tableIdOrArgs,
|
|
3119
|
+
cellIdOrStoreOrStoreId,
|
|
3042
3120
|
descending = false,
|
|
3043
3121
|
offset = 0,
|
|
3044
3122
|
limit,
|
|
3123
|
+
sorter,
|
|
3045
3124
|
storeOrStoreId,
|
|
3046
3125
|
) =>
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3126
|
+
isObject(tableIdOrArgs)
|
|
3127
|
+
? createListenable(
|
|
3128
|
+
resolveStore(cellIdOrStoreOrStoreId),
|
|
3129
|
+
SORTED_ROW_IDS,
|
|
3130
|
+
EMPTY_ARR,
|
|
3131
|
+
() => [tableIdOrArgs],
|
|
3132
|
+
)
|
|
3133
|
+
: createListenable(
|
|
3134
|
+
resolveStore(storeOrStoreId),
|
|
3135
|
+
SORTED_ROW_IDS,
|
|
3136
|
+
EMPTY_ARR,
|
|
3137
|
+
() =>
|
|
3138
|
+
isUndefined(sorter)
|
|
3139
|
+
? [
|
|
3140
|
+
maybeGet$1(tableIdOrArgs),
|
|
3141
|
+
maybeGet$1(cellIdOrStoreOrStoreId),
|
|
3142
|
+
maybeGet$1(descending),
|
|
3143
|
+
maybeGet$1(offset),
|
|
3144
|
+
maybeGet$1(limit),
|
|
3145
|
+
]
|
|
3146
|
+
: [
|
|
3147
|
+
{
|
|
3148
|
+
tableId: maybeGet$1(tableIdOrArgs),
|
|
3149
|
+
cellId: maybeGet$1(cellIdOrStoreOrStoreId),
|
|
3150
|
+
descending: maybeGet$1(descending) ?? false,
|
|
3151
|
+
offset: maybeGet$1(offset) ?? 0,
|
|
3152
|
+
limit: maybeGet$1(limit),
|
|
3153
|
+
sorter,
|
|
3154
|
+
},
|
|
3155
|
+
],
|
|
3156
|
+
);
|
|
3059
3157
|
const getCellIds = (tableId, rowId, storeOrStoreId) =>
|
|
3060
3158
|
createListenable(resolveStore(storeOrStoreId), CELL_IDS, EMPTY_ARR, () => [
|
|
3061
3159
|
maybeGet$1(tableId),
|
|
@@ -5045,6 +5143,7 @@ function SortedTableInHtmlTable($$anchor, $$props) {
|
|
|
5045
5143
|
() => sorting.sortAndOffset[1],
|
|
5046
5144
|
() => sorting.sortAndOffset[2],
|
|
5047
5145
|
() => $$props.limit,
|
|
5146
|
+
undefined,
|
|
5048
5147
|
() => $$props.store,
|
|
5049
5148
|
);
|
|
5050
5149
|
const defaultCellComponent = $.derived(() =>
|