@teselagen/ui 0.10.19 → 0.10.20

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.
@@ -1,6 +1,6 @@
1
- export function PromptUnsavedChanges({ message, when }: {
1
+ export const defaultMessagge: "Are you sure you want to leave? There are unsaved changes.";
2
+ export default PromptUnsavedChanges;
3
+ declare function PromptUnsavedChanges({ message, when }: {
2
4
  message?: string | undefined;
3
5
  when?: boolean | undefined;
4
6
  }): import("react/jsx-runtime").JSX.Element | null;
5
- export const defaultMessagge: "Are you sure you want to leave? There are unsaved changes.";
6
- export default PromptUnsavedChanges;
package/index.cjs.js CHANGED
@@ -20132,6 +20132,23 @@ function applyWhereClause(records, where) {
20132
20132
  if (!isString$1(value) || !new RegExp(conditionValue.replace(/%/g, ".*")).test(value))
20133
20133
  return false;
20134
20134
  break;
20135
+ case "_in":
20136
+ if (!some(conditionValue, (item) => isEqual(value, item)))
20137
+ return false;
20138
+ break;
20139
+ case "_nin":
20140
+ if (some(conditionValue, (item) => isEqual(value, item)))
20141
+ return false;
20142
+ break;
20143
+ case "_regex": {
20144
+ try {
20145
+ if (!isString$1(value) || !new RegExp(conditionValue).test(value))
20146
+ return false;
20147
+ } catch (e) {
20148
+ return false;
20149
+ }
20150
+ break;
20151
+ }
20135
20152
  default:
20136
20153
  if (operator.startsWith("_")) {
20137
20154
  console.warn(`Unsupported operator: ${operator}`);
@@ -51110,7 +51127,7 @@ const FilterAndSortMenu = /* @__PURE__ */ __name(({
51110
51127
  filterValToUse = false;
51111
51128
  } else if (ccSelectedFilter2 === "inList" || ccSelectedFilter2 === "notInList") {
51112
51129
  if (dataType === "number") {
51113
- filterValToUse = filterValue && filterValue.map((val) => parseFloat(val.replaceAll(",", "")));
51130
+ filterValToUse = filterValue && filterValue.map((val) => parseFloat(`${val}`.replaceAll(",", "")));
51114
51131
  }
51115
51132
  }
51116
51133
  if (isInvalidFilterValue(filterValToUse)) {
@@ -51216,7 +51233,7 @@ const FilterInput = /* @__PURE__ */ __name(({
51216
51233
  multi: true,
51217
51234
  creatable: true,
51218
51235
  value: (filterValue || []).map((val) => ({
51219
- label: val,
51236
+ label: `${val}`,
51220
51237
  value: val
51221
51238
  })),
51222
51239
  onChange: /* @__PURE__ */ __name((selectedOptions) => {
@@ -67662,10 +67679,7 @@ const warnBeforeLeave = /* @__PURE__ */ __name((e) => {
67662
67679
  (e || window.event).returnValue = defaultMessagge;
67663
67680
  return defaultMessagge;
67664
67681
  }, "warnBeforeLeave");
67665
- function PromptUnsavedChanges({
67666
- message = defaultMessagge,
67667
- when = false
67668
- }) {
67682
+ function PromptUnsavedChanges({ message = defaultMessagge, when = false }) {
67669
67683
  React.useEffect(() => {
67670
67684
  if (when) {
67671
67685
  window.addEventListener("beforeunload", warnBeforeLeave);
package/index.es.js CHANGED
@@ -20114,6 +20114,23 @@ function applyWhereClause(records, where) {
20114
20114
  if (!isString$1(value) || !new RegExp(conditionValue.replace(/%/g, ".*")).test(value))
20115
20115
  return false;
20116
20116
  break;
20117
+ case "_in":
20118
+ if (!some(conditionValue, (item) => isEqual(value, item)))
20119
+ return false;
20120
+ break;
20121
+ case "_nin":
20122
+ if (some(conditionValue, (item) => isEqual(value, item)))
20123
+ return false;
20124
+ break;
20125
+ case "_regex": {
20126
+ try {
20127
+ if (!isString$1(value) || !new RegExp(conditionValue).test(value))
20128
+ return false;
20129
+ } catch (e) {
20130
+ return false;
20131
+ }
20132
+ break;
20133
+ }
20117
20134
  default:
20118
20135
  if (operator.startsWith("_")) {
20119
20136
  console.warn(`Unsupported operator: ${operator}`);
@@ -51092,7 +51109,7 @@ const FilterAndSortMenu = /* @__PURE__ */ __name(({
51092
51109
  filterValToUse = false;
51093
51110
  } else if (ccSelectedFilter2 === "inList" || ccSelectedFilter2 === "notInList") {
51094
51111
  if (dataType === "number") {
51095
- filterValToUse = filterValue && filterValue.map((val) => parseFloat(val.replaceAll(",", "")));
51112
+ filterValToUse = filterValue && filterValue.map((val) => parseFloat(`${val}`.replaceAll(",", "")));
51096
51113
  }
51097
51114
  }
51098
51115
  if (isInvalidFilterValue(filterValToUse)) {
@@ -51198,7 +51215,7 @@ const FilterInput = /* @__PURE__ */ __name(({
51198
51215
  multi: true,
51199
51216
  creatable: true,
51200
51217
  value: (filterValue || []).map((val) => ({
51201
- label: val,
51218
+ label: `${val}`,
51202
51219
  value: val
51203
51220
  })),
51204
51221
  onChange: /* @__PURE__ */ __name((selectedOptions) => {
@@ -67644,10 +67661,7 @@ const warnBeforeLeave = /* @__PURE__ */ __name((e) => {
67644
67661
  (e || window.event).returnValue = defaultMessagge;
67645
67662
  return defaultMessagge;
67646
67663
  }, "warnBeforeLeave");
67647
- function PromptUnsavedChanges({
67648
- message = defaultMessagge,
67649
- when = false
67650
- }) {
67664
+ function PromptUnsavedChanges({ message = defaultMessagge, when = false }) {
67651
67665
  useEffect(() => {
67652
67666
  if (when) {
67653
67667
  window.addEventListener("beforeunload", warnBeforeLeave);
package/index.umd.js CHANGED
@@ -44789,6 +44789,23 @@ ${latestSubscriptionCallbackError.current.stack}
44789
44789
  if (!isString$1(value) || !new RegExp(conditionValue.replace(/%/g, ".*")).test(value))
44790
44790
  return false;
44791
44791
  break;
44792
+ case "_in":
44793
+ if (!some(conditionValue, (item) => isEqual(value, item)))
44794
+ return false;
44795
+ break;
44796
+ case "_nin":
44797
+ if (some(conditionValue, (item) => isEqual(value, item)))
44798
+ return false;
44799
+ break;
44800
+ case "_regex": {
44801
+ try {
44802
+ if (!isString$1(value) || !new RegExp(conditionValue).test(value))
44803
+ return false;
44804
+ } catch (e) {
44805
+ return false;
44806
+ }
44807
+ break;
44808
+ }
44792
44809
  default:
44793
44810
  if (operator.startsWith("_")) {
44794
44811
  console.warn(`Unsupported operator: ${operator}`);
@@ -78545,7 +78562,7 @@ ${latestSubscriptionCallbackError.current.stack}
78545
78562
  filterValToUse = false;
78546
78563
  } else if (ccSelectedFilter2 === "inList" || ccSelectedFilter2 === "notInList") {
78547
78564
  if (dataType === "number") {
78548
- filterValToUse = filterValue && filterValue.map((val) => parseFloat(val.replaceAll(",", "")));
78565
+ filterValToUse = filterValue && filterValue.map((val) => parseFloat(`${val}`.replaceAll(",", "")));
78549
78566
  }
78550
78567
  }
78551
78568
  if (isInvalidFilterValue(filterValToUse)) {
@@ -78651,7 +78668,7 @@ ${latestSubscriptionCallbackError.current.stack}
78651
78668
  multi: true,
78652
78669
  creatable: true,
78653
78670
  value: (filterValue || []).map((val) => ({
78654
- label: val,
78671
+ label: `${val}`,
78655
78672
  value: val
78656
78673
  })),
78657
78674
  onChange: /* @__PURE__ */ __name((selectedOptions) => {
@@ -95097,10 +95114,7 @@ ${latestSubscriptionCallbackError.current.stack}
95097
95114
  (e || window.event).returnValue = defaultMessagge;
95098
95115
  return defaultMessagge;
95099
95116
  }, "warnBeforeLeave");
95100
- function PromptUnsavedChanges({
95101
- message = defaultMessagge,
95102
- when = false
95103
- }) {
95117
+ function PromptUnsavedChanges({ message = defaultMessagge, when = false }) {
95104
95118
  reactExports.useEffect(() => {
95105
95119
  if (when) {
95106
95120
  window.addEventListener("beforeunload", warnBeforeLeave);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teselagen/ui",
3
- "version": "0.10.19",
3
+ "version": "0.10.20",
4
4
  "main": "./src/index.js",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/TeselaGen/tg-oss",
@@ -11,7 +11,6 @@
11
11
  },
12
12
  "./style.css": "./style.css"
13
13
  },
14
- "devDependencies": {},
15
14
  "dependencies": {
16
15
  "@blueprintjs/core": "3.54.0",
17
16
  "@blueprintjs/datetime": "^3.24.1",
@@ -20,7 +19,6 @@
20
19
  "@dnd-kit/modifiers": "^7.0.0",
21
20
  "@dnd-kit/sortable": "^8.0.0",
22
21
  "@teselagen/react-table": "6.10.18",
23
- "chance": "1.1.11",
24
22
  "classnames": "^2.3.2",
25
23
  "color": "^3.2.1",
26
24
  "copy-to-clipboard": "^3.3.1",
@@ -48,7 +46,6 @@
48
46
  "recompose": "npm:react-recompose@0.31.1",
49
47
  "redux": "^4.1.2",
50
48
  "redux-form": "^8.3.10",
51
- "redux-thunk": "2.4.1",
52
49
  "remark-gfm": "^4.0.0",
53
50
  "reselect": "^4.1.7",
54
51
  "tippy.js": "^6.3.7",
@@ -58,5 +55,9 @@
58
55
  "@dnd-kit/utilities": "3.2.2",
59
56
  "@teselagen/file-utils": "0.3.23",
60
57
  "@blueprintjs/icons": "3.33.0"
58
+ },
59
+ "devDependencies": {
60
+ "chance": "1.1.11",
61
+ "redux-thunk": "2.4.1"
61
62
  }
62
63
  }
@@ -106,7 +106,7 @@ const FilterAndSortMenu = ({
106
106
  if (dataType === "number") {
107
107
  filterValToUse =
108
108
  filterValue &&
109
- filterValue.map(val => parseFloat(val.replaceAll(",", "")));
109
+ filterValue.map(val => parseFloat(`${val}`.replaceAll(",", "")));
110
110
  }
111
111
  }
112
112
 
@@ -234,7 +234,7 @@ const FilterInput = ({
234
234
  multi={true}
235
235
  creatable={true}
236
236
  value={(filterValue || []).map(val => ({
237
- label: val,
237
+ label: `${val}`,
238
238
  value: val
239
239
  }))}
240
240
  onChange={selectedOptions => {
@@ -205,6 +205,23 @@ function applyWhereClause(records, where) {
205
205
  )
206
206
  return false;
207
207
  break;
208
+ case "_in":
209
+ if (!some(conditionValue, item => isEqual(value, item)))
210
+ return false;
211
+ break;
212
+ case "_nin":
213
+ if (some(conditionValue, item => isEqual(value, item)))
214
+ return false;
215
+ break;
216
+ case "_regex": {
217
+ try {
218
+ if (!isString(value) || !new RegExp(conditionValue).test(value))
219
+ return false;
220
+ } catch (e) {
221
+ return false;
222
+ }
223
+ break;
224
+ }
208
225
  default:
209
226
  if (operator.startsWith("_")) {
210
227
  console.warn(`Unsupported operator: ${operator}`);
@@ -1282,4 +1282,203 @@ describe("filterLocalEntitiesToHasura", () => {
1282
1282
  ]);
1283
1283
  expect(result.entityCount).toBe(5);
1284
1284
  });
1285
+
1286
+ it("should filter protein features correctly", () => {
1287
+ const proteinFeatureEntities = [
1288
+ {
1289
+ type: "CDS",
1290
+ strand: 1,
1291
+ name: "araC",
1292
+ start: 3,
1293
+ end: 5,
1294
+ annotationTypePlural: "features",
1295
+ id: "WWBalzQw01Oq",
1296
+ forward: true,
1297
+ color: "#EF6500",
1298
+ size: 3
1299
+ },
1300
+ {
1301
+ type: "protein_bind",
1302
+ strand: 1,
1303
+ name: "Operator I2 and I1",
1304
+ start: 3,
1305
+ end: 8,
1306
+ annotationTypePlural: "features",
1307
+ id: "yOsnjK_GkeAv",
1308
+ forward: true,
1309
+ color: "#2E2E2E",
1310
+ size: 6
1311
+ },
1312
+ {
1313
+ type: "CDS",
1314
+ strand: 1,
1315
+ name: "signal_peptide",
1316
+ start: 3,
1317
+ end: 11,
1318
+ annotationTypePlural: "features",
1319
+ id: "aPKESKXj0qUR",
1320
+ forward: true,
1321
+ color: "#EF6500",
1322
+ size: 9
1323
+ }
1324
+ ];
1325
+ const result_equal = filterLocalEntitiesToHasura(proteinFeatureEntities, {
1326
+ where: {
1327
+ _and: [
1328
+ {
1329
+ size: {
1330
+ _eq: 3
1331
+ }
1332
+ }
1333
+ ]
1334
+ }
1335
+ });
1336
+ expect(result_equal.entities).toEqual([proteinFeatureEntities[0]]);
1337
+
1338
+ const result_in_list = filterLocalEntitiesToHasura(proteinFeatureEntities, {
1339
+ where: {
1340
+ _and: [
1341
+ {
1342
+ size: {
1343
+ _in: [3, 6]
1344
+ }
1345
+ }
1346
+ ]
1347
+ }
1348
+ });
1349
+ expect(result_in_list.entities).toEqual([
1350
+ proteinFeatureEntities[0],
1351
+ proteinFeatureEntities[1]
1352
+ ]);
1353
+
1354
+ const result_not_in_list = filterLocalEntitiesToHasura(
1355
+ proteinFeatureEntities,
1356
+ {
1357
+ where: {
1358
+ _and: [
1359
+ {
1360
+ size: {
1361
+ _nin: [3, 6]
1362
+ }
1363
+ }
1364
+ ]
1365
+ }
1366
+ }
1367
+ );
1368
+ expect(result_not_in_list.entities).toEqual([proteinFeatureEntities[2]]);
1369
+
1370
+ const result_valid_regex = filterLocalEntitiesToHasura(
1371
+ proteinFeatureEntities,
1372
+ {
1373
+ where: {
1374
+ _and: [
1375
+ {
1376
+ name: {
1377
+ _regex: "^signal_"
1378
+ }
1379
+ }
1380
+ ]
1381
+ }
1382
+ }
1383
+ );
1384
+ expect(result_valid_regex.entities).toEqual([proteinFeatureEntities[2]]);
1385
+
1386
+ const result_invalid_regex = filterLocalEntitiesToHasura(
1387
+ proteinFeatureEntities,
1388
+ {
1389
+ where: {
1390
+ _and: [
1391
+ {
1392
+ name: {
1393
+ _regex: "["
1394
+ }
1395
+ }
1396
+ ]
1397
+ }
1398
+ }
1399
+ );
1400
+ expect(result_invalid_regex.entities).toEqual([]);
1401
+ });
1402
+
1403
+ it("should filter DNA features correctly", () => {
1404
+ const dnaFeatureEntities = [
1405
+ {
1406
+ type: "CDS",
1407
+ strand: 1,
1408
+ name: "araC",
1409
+ start: 3,
1410
+ end: 5,
1411
+ annotationTypePlural: "features",
1412
+ id: "WWBalzQw01Oq",
1413
+ forward: true,
1414
+ color: "#EF6500",
1415
+ size: 3
1416
+ },
1417
+ {
1418
+ type: "protein_bind",
1419
+ strand: 1,
1420
+ name: "Operator I2 and I1",
1421
+ start: 3,
1422
+ end: 8,
1423
+ annotationTypePlural: "features",
1424
+ id: "yOsnjK_GkeAv",
1425
+ forward: true,
1426
+ color: "#2E2E2E",
1427
+ size: 6
1428
+ },
1429
+ {
1430
+ type: "CDS",
1431
+ strand: 1,
1432
+ name: "signal_peptide",
1433
+ start: 3,
1434
+ end: 11,
1435
+ annotationTypePlural: "features",
1436
+ id: "aPKESKXj0qUR",
1437
+ forward: true,
1438
+ color: "#EF6500",
1439
+ size: 9
1440
+ }
1441
+ ];
1442
+ const result_equal = filterLocalEntitiesToHasura(dnaFeatureEntities, {
1443
+ where: {
1444
+ _and: [
1445
+ {
1446
+ size: {
1447
+ _eq: 3
1448
+ }
1449
+ }
1450
+ ]
1451
+ }
1452
+ });
1453
+ expect(result_equal.entities).toEqual([dnaFeatureEntities[0]]);
1454
+
1455
+ const result_in_list = filterLocalEntitiesToHasura(dnaFeatureEntities, {
1456
+ where: {
1457
+ _and: [
1458
+ {
1459
+ size: {
1460
+ _in: [3, 6]
1461
+ }
1462
+ }
1463
+ ]
1464
+ }
1465
+ });
1466
+ expect(result_in_list.entities).toEqual([
1467
+ dnaFeatureEntities[0],
1468
+ dnaFeatureEntities[1]
1469
+ ]);
1470
+
1471
+ const result_not_in_list = filterLocalEntitiesToHasura(dnaFeatureEntities, {
1472
+ where: {
1473
+ _and: [
1474
+ {
1475
+ size: {
1476
+ _nin: [3, 6]
1477
+ }
1478
+ }
1479
+ ]
1480
+ }
1481
+ });
1482
+ expect(result_not_in_list.entities).toEqual([dnaFeatureEntities[2]]);
1483
+ });
1285
1484
  });
@@ -17,10 +17,7 @@ const warnBeforeLeave = e => {
17
17
  return defaultMessagge; //Webkit, Safari, Chrome
18
18
  };
19
19
 
20
- export function PromptUnsavedChanges({
21
- message = defaultMessagge,
22
- when = false
23
- }) {
20
+ function PromptUnsavedChanges({ message = defaultMessagge, when = false }) {
24
21
  useEffect(() => {
25
22
  if (when) {
26
23
  window.addEventListener("beforeunload", warnBeforeLeave);