@columenlabs/lumen-ui-types 0.1.1 → 0.1.3
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/README.md +1 -1
- package/dist/chart-formula.d.ts +14 -14
- package/dist/frames.d.ts +5 -5
- package/dist/market.d.ts +2 -2
- package/dist/tasks.d.ts +2 -2
- package/dist/view-formula.d.ts +1 -1
- package/dist/views.d.ts +2209 -1674
- package/dist/views.js +52 -19
- package/package.json +4 -4
package/dist/views.js
CHANGED
|
@@ -402,6 +402,25 @@ export const CONTROL_DEFAULTS = {
|
|
|
402
402
|
};
|
|
403
403
|
/** Slices an allocation bar shows on its own before the rest fold into Other. */
|
|
404
404
|
export const ALLOCATION_MAX = 10;
|
|
405
|
+
/**
|
|
406
|
+
* One connection: the domain `to` and the pairs that match a row to its rows, each a key the
|
|
407
|
+
* rows carry (`symbol`, `account`) or a field of each side. Left out of a card move, `on` is
|
|
408
|
+
* inferred from the keys both domains carry.
|
|
409
|
+
*/
|
|
410
|
+
export const viewConnectionSchema = z
|
|
411
|
+
.object({
|
|
412
|
+
// A catalog domain any reader returns, or a recipe `frame:<id>` (`linkIssues`, checked where
|
|
413
|
+
// views are written).
|
|
414
|
+
to: z
|
|
415
|
+
.string()
|
|
416
|
+
.regex(/^(?:frame:[A-Za-z0-9_-]+|[a-z][a-z0-9_]*)$/)
|
|
417
|
+
.max(80),
|
|
418
|
+
// No pairs: added but Not linked yet, unless both sides carry a key.
|
|
419
|
+
on: z.array(z.object({ from: fieldKey, to: fieldKey }).strict()).max(3),
|
|
420
|
+
})
|
|
421
|
+
.strict();
|
|
422
|
+
/** A widget's own main data: a catalog domain id (`zeus_credits`) or a recipe (`frame:<id>`). */
|
|
423
|
+
export const viewSourceSchema = viewConnectionSchema.shape.to;
|
|
405
424
|
const cardBase = {
|
|
406
425
|
id: viewKey,
|
|
407
426
|
/** Null or left out: the style's own title (the catalog's name for a pre-built widget). */
|
|
@@ -421,6 +440,13 @@ const cardBase = {
|
|
|
421
440
|
phone: viewCardPlaceSchema.optional(),
|
|
422
441
|
/** Tokens that narrow the view's rows for this widget only, e.g. kind:Option. */
|
|
423
442
|
filter: z.array(cardToken).max(MAX_FIELDS).default([]),
|
|
443
|
+
/**
|
|
444
|
+
* Its own main data, which gives its rows: a catalog domain id or a recipe (`frame:<id>`). Left
|
|
445
|
+
* out, the page's rows. A widget with a source follows the page's chips only by a key both carry.
|
|
446
|
+
*/
|
|
447
|
+
source: viewSourceSchema.optional(),
|
|
448
|
+
/** What it links to its own source (with `source` only; a page-data widget shares the view's). */
|
|
449
|
+
connections: z.array(viewConnectionSchema).max(4).optional(),
|
|
424
450
|
/** Its link colour: it shares its chips and tapped row with every card of that colour and
|
|
425
451
|
* follows theirs. Left out: none. */
|
|
426
452
|
link: z.enum(viewLinkColors).optional(),
|
|
@@ -840,7 +866,7 @@ export const defaultViewCards = [
|
|
|
840
866
|
];
|
|
841
867
|
export const cardsOf = (c) => c.cards ?? defaultViewCards;
|
|
842
868
|
/** The table that draws the view's own layout: the first table card without its own `table`. */
|
|
843
|
-
export const mainTableOf = (cards) => cards.find((c) => isTableCard(c) && !c.table);
|
|
869
|
+
export const mainTableOf = (cards) => cards.find((c) => isTableCard(c) && !c.table && !c.source);
|
|
844
870
|
/** A row card's numbers: its own, else the view's. */
|
|
845
871
|
export const tilesOfCard = (c, card) => card.tiles ?? c.tiles ?? [];
|
|
846
872
|
/** Every number on the page: the view's, each row's own and each single number. */
|
|
@@ -918,23 +944,6 @@ export const widgetPresets = (items) => items.map(([name, note, b]) => ({
|
|
|
918
944
|
note,
|
|
919
945
|
widget: viewCardSchema.parse({ title: name, ...b }),
|
|
920
946
|
}));
|
|
921
|
-
/**
|
|
922
|
-
* One connection: the domain `to` and the pairs that match a row to its rows, each a key the
|
|
923
|
-
* rows carry (`symbol`, `account`) or a field of each side. Left out of a card move, `on` is
|
|
924
|
-
* inferred from the keys both domains carry.
|
|
925
|
-
*/
|
|
926
|
-
export const viewConnectionSchema = z
|
|
927
|
-
.object({
|
|
928
|
-
// A catalog domain any reader returns, or a recipe `frame:<id>` (`linkIssues`, checked where
|
|
929
|
-
// views are written).
|
|
930
|
-
to: z
|
|
931
|
-
.string()
|
|
932
|
-
.regex(/^(?:frame:[A-Za-z0-9_-]+|[a-z][a-z0-9_]*)$/)
|
|
933
|
-
.max(80),
|
|
934
|
-
// No pairs: added but Not linked yet, unless both sides carry a key.
|
|
935
|
-
on: z.array(z.object({ from: fieldKey, to: fieldKey }).strict()).max(3),
|
|
936
|
-
})
|
|
937
|
-
.strict();
|
|
938
947
|
/** A connected field's key on the card: `holdings_quantity`; `holdings_count` counts the rows. */
|
|
939
948
|
export const connectedKey = (to, field) => `${linkSpace(to)}_${field}`;
|
|
940
949
|
/** A link's name in field keys: the domain id, or `r` and the end of a recipe's frame id. */
|
|
@@ -1098,6 +1107,19 @@ export function tableConfigOf(c, card) {
|
|
|
1098
1107
|
cards: [rest],
|
|
1099
1108
|
};
|
|
1100
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* The config a widget with its own `source` draws: its own table layout and links over a fresh
|
|
1112
|
+
* config, nothing of the page's (formulas, links, recipes) carried in.
|
|
1113
|
+
*/
|
|
1114
|
+
export function sourceConfigOf(card, name) {
|
|
1115
|
+
const base = {
|
|
1116
|
+
...customViewConfigSchema.parse({ connections: card.connections ?? [] }),
|
|
1117
|
+
name: card.title ?? name,
|
|
1118
|
+
};
|
|
1119
|
+
return isTableCard(card)
|
|
1120
|
+
? tableConfigOf(base, { ...card, table: card.table ?? tableLayoutOf(base) })
|
|
1121
|
+
: base;
|
|
1122
|
+
}
|
|
1101
1123
|
/** A custom view's domain: lowercase, like `holdings` or `explorer`. */
|
|
1102
1124
|
export const customViewDomainSchema = z
|
|
1103
1125
|
.string()
|
|
@@ -1209,7 +1231,18 @@ frames = []) {
|
|
|
1209
1231
|
...issues,
|
|
1210
1232
|
...tileListIssues(config.tiles ?? [], 'tiles'),
|
|
1211
1233
|
...(config.cards ?? []).flatMap((c, i) => isRowCard(c) && c.tiles ? tileListIssues(c.tiles, `cards.${i}.tiles`) : []),
|
|
1212
|
-
...(
|
|
1234
|
+
...(config.cards ?? []).flatMap((c, i) => {
|
|
1235
|
+
// A widget with its own data is checked against that data's fields, not the page's; a
|
|
1236
|
+
// recipe or a domain the view catalog does not list has its rows' fields, known on read.
|
|
1237
|
+
const cols = c.source
|
|
1238
|
+
? customViewFields[c.source]?.columns && [
|
|
1239
|
+
...(customViewFields[c.source]?.columns ?? []),
|
|
1240
|
+
...connectionColumns(c.connections, c),
|
|
1241
|
+
...formulas.map((f) => f.key),
|
|
1242
|
+
]
|
|
1243
|
+
: columns;
|
|
1244
|
+
return cols ? cardIssues([c], cols).map((x) => x.replace(/^cards\.0:/, `cards.${i}:`)) : [];
|
|
1245
|
+
}),
|
|
1213
1246
|
];
|
|
1214
1247
|
}
|
|
1215
1248
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@columenlabs/lumen-ui-types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Lumen's view model: views, formulas, domains and joins, frames.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"sideEffects": [
|
|
61
61
|
"**/*.css"
|
|
62
62
|
],
|
|
63
|
-
"homepage": "https://github.com/columenlabs/lumen",
|
|
63
|
+
"homepage": "https://github.com/columenlabs/lumen-ui",
|
|
64
64
|
"repository": {
|
|
65
65
|
"type": "git",
|
|
66
|
-
"url": "git+https://github.com/columenlabs/lumen.git",
|
|
66
|
+
"url": "git+https://github.com/columenlabs/lumen-ui.git",
|
|
67
67
|
"directory": "packages/lumen-types"
|
|
68
68
|
},
|
|
69
|
-
"bugs": "https://github.com/columenlabs/lumen/issues",
|
|
69
|
+
"bugs": "https://github.com/columenlabs/lumen-ui/issues",
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public",
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|