@fibery/views 10.7.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/views.js +64 -40
  2. package/package.json +5 -5
package/lib/views.js CHANGED
@@ -270,20 +270,32 @@ const getUnitTypeForTextField = fieldMeta => {
270
270
  return "text";
271
271
  }
272
272
  };
273
+ const getUnitKind = unit => {
274
+ if (unit.type === "user-button") {
275
+ return "user-button";
276
+ }
277
+ if (["type-icon", "type-badge", "type-badge-abbr"].includes(unit.type)) {
278
+ return "db";
279
+ }
280
+ return "field";
281
+ };
273
282
  const migrateUnit = (schema, fromType, unit, units) => {
274
283
  const {
275
284
  type,
276
285
  expression
277
286
  } = unit;
287
+ const kind = unit.kind || getUnitKind(unit);
278
288
  if (type === "date-time") {
279
289
  return {
280
290
  ...unit,
291
+ kind,
281
292
  type: "date"
282
293
  };
283
294
  }
284
295
  if (type === "date-time-range") {
285
296
  return {
286
297
  ...unit,
298
+ kind,
287
299
  type: "date-range"
288
300
  };
289
301
  }
@@ -293,6 +305,7 @@ const migrateUnit = (schema, fromType, unit, units) => {
293
305
  if (fieldType === "fibery/email") {
294
306
  return {
295
307
  ...unit,
308
+ kind,
296
309
  type: "email"
297
310
  };
298
311
  }
@@ -302,6 +315,7 @@ const migrateUnit = (schema, fromType, unit, units) => {
302
315
  if (getFieldType(schema, fromType, field) === "fibery/text") {
303
316
  return {
304
317
  ...unit,
318
+ kind,
305
319
  type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
306
320
  };
307
321
  }
@@ -311,6 +325,7 @@ const migrateUnit = (schema, fromType, unit, units) => {
311
325
  if (getFieldType(schema, fromType, field) === "fibery/file") {
312
326
  return {
313
327
  ...unit,
328
+ kind,
314
329
  type: "collection-count"
315
330
  };
316
331
  }
@@ -322,11 +337,15 @@ const migrateUnit = (schema, fromType, unit, units) => {
322
337
  if (isAvatarExntensionEnabled && hasAvatarExntensionField) {
323
338
  return {
324
339
  ...unit,
325
- expression: ["avatar/avatars"]
340
+ expression: ["avatar/avatars"],
341
+ kind
326
342
  };
327
343
  }
328
344
  }
329
- return unit;
345
+ return {
346
+ ...unit,
347
+ kind
348
+ };
330
349
  };
331
350
  const fixViewUnit = (schema, fromType, unit, units, {
332
351
  unitDefinitions,
@@ -494,45 +513,50 @@ const visitView$5 = (view, visitor) => immutableUpdate__default["default"](view,
494
513
  $apply: y => visitAxis$1(y, visitor)
495
514
  },
496
515
  items: {
497
- $apply: items => items.map(item => {
498
- const fromType = ___default["default"].get(item, ["query", "q/from"]);
499
- return fromType ? immutableUpdate__default["default"](item, {
500
- coverExpression: {
501
- $apply: coverExpression => coverExpression ? visitor.visitExpression(fromType, coverExpression) : coverExpression
502
- },
503
- xExpression: {
504
- $apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
505
- },
506
- yExpression: {
507
- $apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
508
- },
509
- contextExpression: {
510
- $apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
511
- },
512
- query: {
513
- $apply: query => query ? visitor.visitQueryExpression(query) : null
514
- },
515
- filter: {
516
- $apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
517
- },
518
- units: {
519
- $apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
520
- },
521
- colorCoding: {
522
- $apply: colorCodings => {
523
- return colorCodings ? colorCodings.map(colorCoding => ({
524
- ...colorCoding,
525
- expression: visitor.visitExpression(fromType, colorCoding.expression)
526
- })).filter(colorCoding => colorCoding.expression !== null) : undefined;
516
+ $apply: items => {
517
+ if (!items) {
518
+ return [];
519
+ }
520
+ return items.map(item => {
521
+ const fromType = ___default["default"].get(item, ["query", "q/from"]);
522
+ return fromType ? immutableUpdate__default["default"](item, {
523
+ coverExpression: {
524
+ $apply: coverExpression => coverExpression ? visitor.visitExpression(fromType, coverExpression) : coverExpression
525
+ },
526
+ xExpression: {
527
+ $apply: xExpression => xExpression ? visitor.visitExpression(fromType, xExpression) : xExpression
528
+ },
529
+ yExpression: {
530
+ $apply: yExpression => yExpression ? visitor.visitExpression(fromType, yExpression) : yExpression
531
+ },
532
+ contextExpression: {
533
+ $apply: contextExpression => visitContextExpression(fromType, contextExpression, visitor)
534
+ },
535
+ query: {
536
+ $apply: query => query ? visitor.visitQueryExpression(query) : null
537
+ },
538
+ filter: {
539
+ $apply: filter => filter ? visitor.visitFilter(fromType, filter) : null
540
+ },
541
+ units: {
542
+ $apply: units => units ? units.filter(unit => Boolean(unit)).map(unit => visitViewUnit(fromType, unit, visitor)).filter(unit => isUnitExpressionValid(unit)).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(unit => unit !== REMOVE) : undefined
543
+ },
544
+ colorCoding: {
545
+ $apply: colorCodings => {
546
+ return colorCodings ? colorCodings.map(colorCoding => ({
547
+ ...colorCoding,
548
+ expression: visitor.visitExpression(fromType, colorCoding.expression)
549
+ })).filter(colorCoding => colorCoding.expression !== null) : undefined;
550
+ }
527
551
  }
528
- }
529
- }) : item;
530
- }).filter(item => {
531
- const {
532
- query
533
- } = item;
534
- return query ? item : null;
535
- })
552
+ }) : item;
553
+ }).filter(item => {
554
+ const {
555
+ query
556
+ } = item;
557
+ return query ? item : null;
558
+ });
559
+ }
536
560
  }
537
561
  }
538
562
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/views",
3
- "version": "10.7.1",
3
+ "version": "12.0.0",
4
4
  "description": "Operations on view objects",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Fibery",
@@ -20,12 +20,12 @@
20
20
  "microbundle": "0.15.1",
21
21
  "@fibery/babel-preset": "7.4.0",
22
22
  "@fibery/eslint-config": "8.6.0",
23
- "@fibery/expression-utils": "9.0.5",
24
- "@fibery/schema": "10.2.1"
23
+ "@fibery/expression-utils": "9.1.0",
24
+ "@fibery/schema": "10.2.2"
25
25
  },
26
26
  "peerDependencies": {
27
- "@fibery/expression-utils": "^9.0.5",
28
- "@fibery/schema": "^10.2.1",
27
+ "@fibery/expression-utils": "^9.1.0",
28
+ "@fibery/schema": "^10.2.2",
29
29
  "immutability-helper": "^2.4.0",
30
30
  "lodash": "^4.17.21"
31
31
  },