@protobase/layout 0.33.0 → 0.33.1
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/dist/block-specs.js +13 -0
- package/dist/blocks.d.ts +18 -0
- package/dist/blocks.js +2 -1
- package/dist/check-page.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/prune-page.js +14 -0
- package/package.json +2 -2
package/dist/block-specs.js
CHANGED
|
@@ -102,6 +102,19 @@ const blockSpecs = {
|
|
|
102
102
|
span: optional("span")
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
|
+
RecordCards: {
|
|
106
|
+
children: false,
|
|
107
|
+
props: {
|
|
108
|
+
...data,
|
|
109
|
+
...heading,
|
|
110
|
+
fields: optional("texts"),
|
|
111
|
+
cardActions: optional("texts"),
|
|
112
|
+
limit: optional("integer"),
|
|
113
|
+
display: optional("text"),
|
|
114
|
+
empty: optional("text"),
|
|
115
|
+
span: optional("span")
|
|
116
|
+
}
|
|
117
|
+
},
|
|
105
118
|
Chart: {
|
|
106
119
|
children: false,
|
|
107
120
|
props: {
|
package/dist/blocks.d.ts
CHANGED
|
@@ -83,6 +83,23 @@ export type RecordRowProps = DataProps & Heading & {
|
|
|
83
83
|
empty?: string;
|
|
84
84
|
span?: GridSpan;
|
|
85
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* What a filter finds as the cards a record page's related section draws with `presentation: 'cards'`, stacked full
|
|
88
|
+
* width under a heading that is not a card: each card its record's title linking to its page, its `fields` under their
|
|
89
|
+
* labels with a long value cut short behind Show more, and its `cardActions`' buttons; "View all" opens the rest.
|
|
90
|
+
*/
|
|
91
|
+
export type RecordCardsProps = DataProps & Heading & {
|
|
92
|
+
/** The fields each card shows, through relations too (`task_id.title`); the list's columns when omitted. */
|
|
93
|
+
fields?: string[];
|
|
94
|
+
/** Named actions of the resource's view, as buttons on each card. */
|
|
95
|
+
cardActions?: string[];
|
|
96
|
+
/** How many records it shows, the first in `sort` order (the list's when omitted); default 10. */
|
|
97
|
+
limit?: number;
|
|
98
|
+
/** The display of the resource's list "View all" opens, such as `cards`; the list's default when omitted. */
|
|
99
|
+
display?: string;
|
|
100
|
+
empty?: string;
|
|
101
|
+
span?: GridSpan;
|
|
102
|
+
};
|
|
86
103
|
/** How a chart draws its groups: bars, a line through a date field's buckets, or a donut of a field's values. */
|
|
87
104
|
export type ChartType = 'bar' | 'line' | 'donut';
|
|
88
105
|
/** How long each bucket of a chart over a date or timestamp field is. */
|
|
@@ -169,6 +186,7 @@ export declare const Field: Block<FieldProps>;
|
|
|
169
186
|
export declare const Table: Block<TableProps>;
|
|
170
187
|
export declare const CardRow: Block<CardRowProps>;
|
|
171
188
|
export declare const RecordRow: Block<RecordRowProps>;
|
|
189
|
+
export declare const RecordCards: Block<RecordCardsProps>;
|
|
172
190
|
export declare const Chart: Block<ChartProps>;
|
|
173
191
|
export declare const Progress: Block<ProgressProps>;
|
|
174
192
|
export declare const ModalForm: Block<ModalFormProps>;
|
package/dist/blocks.js
CHANGED
|
@@ -9,6 +9,7 @@ const Field = defineBlock("Field", false);
|
|
|
9
9
|
const Table = defineBlock("Table", false);
|
|
10
10
|
const CardRow = defineBlock("CardRow", false);
|
|
11
11
|
const RecordRow = defineBlock("RecordRow", false);
|
|
12
|
+
const RecordCards = defineBlock("RecordCards", false);
|
|
12
13
|
const Chart = defineBlock("Chart", false);
|
|
13
14
|
const Progress = defineBlock("Progress", false);
|
|
14
15
|
const ModalForm = defineBlock("ModalForm", false);
|
|
@@ -17,4 +18,4 @@ const Show = defineBlock("Show", false);
|
|
|
17
18
|
const Link = defineBlock("Link", false);
|
|
18
19
|
const Users = defineBlock("Users", false);
|
|
19
20
|
//#endregion
|
|
20
|
-
export { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordRow, Show, Stat, Table, Users };
|
|
21
|
+
export { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordCards, RecordRow, Show, Stat, Table, Users };
|
package/dist/check-page.js
CHANGED
|
@@ -59,6 +59,10 @@ const nodeProblems = (node, scope, { models, actions, pages, createPages }) => {
|
|
|
59
59
|
case "Table":
|
|
60
60
|
for (const column of node.props.columns ?? []) if (model && !Object.hasOwn(model.fields, column)) problems.push(`unknown column "${column}" on ${model.name}`);
|
|
61
61
|
break;
|
|
62
|
+
case "RecordCards":
|
|
63
|
+
for (const name of node.props.fields ?? []) path(name, own);
|
|
64
|
+
for (const name of node.props.cardActions ?? []) if (own !== void 0 && !actions(own).has(name)) problems.push(`no action "${name}" on ${own}; declare it with view('${own}').actions(...)`);
|
|
65
|
+
break;
|
|
62
66
|
case "ModalForm":
|
|
63
67
|
if (!model) break;
|
|
64
68
|
for (const name of node.props.fields) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Block, LayoutChild, LayoutChildren, LayoutNode, LayoutValue, isLayoutNode } from "./node.js";
|
|
2
|
-
import { Action, ActionProps, ButtonVariant, Card, CardProps, CardRow, CardRowProps, Chart, ChartBucket, ChartProps, ChartType, DataProps, Elements, Field, FieldProps, Grid, GridProps, GridSpan, Link, LinkProps, ModalForm, ModalFormProps, Page, PageProps, Progress, ProgressProps, RecordCard, RecordCardProps, RecordRow, RecordRowProps, Show, ShowProps, Stat, StatProps, Table, TableProps, Users, UsersProps } from "./blocks.js";
|
|
2
|
+
import { Action, ActionProps, ButtonVariant, Card, CardProps, CardRow, CardRowProps, Chart, ChartBucket, ChartProps, ChartType, DataProps, Elements, Field, FieldProps, Grid, GridProps, GridSpan, Link, LinkProps, ModalForm, ModalFormProps, Page, PageProps, Progress, ProgressProps, RecordCard, RecordCardProps, RecordCards, RecordCardsProps, RecordRow, RecordRowProps, Show, ShowProps, Stat, StatProps, Table, TableProps, Users, UsersProps } from "./blocks.js";
|
|
3
3
|
import { ComponentOptions, component } from "./component.js";
|
|
4
4
|
import { usersPage } from "./presets/users-page.js";
|
|
5
5
|
import { PageDefinition, PageModel, PageOptions, isPageDefinition, page } from "./page.js";
|
|
@@ -11,4 +11,4 @@ import { countedResource, evaluateCondition, parseCondition } from "./condition.
|
|
|
11
11
|
import { PathStep, resolveFieldPath } from "./field-path.js";
|
|
12
12
|
import { jsx_runtime_d_exports } from "./jsx-runtime.js";
|
|
13
13
|
import { FieldRefValue, fieldRef } from "@protobase/schema";
|
|
14
|
-
export { Action, type ActionProps, type Block, type ButtonVariant, Card, type CardProps, CardRow, type CardRowProps, Chart, type ChartBucket, type ChartProps, type ChartType, type ComponentOptions, type DataProps, type Elements, Field, type FieldProps, type FieldRefValue, Grid, type GridProps, type GridSpan, type LayoutChild, type LayoutChildren, type LayoutNode, type LayoutValue, Link, type LinkProps, type Location, ModalForm, type ModalFormProps, Page, type PageDefinition, type PageModel, type PageOptions, type PageProps, type PathStep, Progress, type ProgressProps, RecordCard, type RecordCardProps, RecordRow, type RecordRowProps, Show, type ShowProps, Stat, type StatProps, Table, type TableProps, Users, type UsersProps, checkPages, component, conditionProblems, conditionReadable, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_d_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath, usersPage, walkTree };
|
|
14
|
+
export { Action, type ActionProps, type Block, type ButtonVariant, Card, type CardProps, CardRow, type CardRowProps, Chart, type ChartBucket, type ChartProps, type ChartType, type ComponentOptions, type DataProps, type Elements, Field, type FieldProps, type FieldRefValue, Grid, type GridProps, type GridSpan, type LayoutChild, type LayoutChildren, type LayoutNode, type LayoutValue, Link, type LinkProps, type Location, ModalForm, type ModalFormProps, Page, type PageDefinition, type PageModel, type PageOptions, type PageProps, type PathStep, Progress, type ProgressProps, RecordCard, type RecordCardProps, RecordCards, type RecordCardsProps, RecordRow, type RecordRowProps, Show, type ShowProps, Stat, type StatProps, Table, type TableProps, Users, type UsersProps, checkPages, component, conditionProblems, conditionReadable, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_d_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath, usersPage, walkTree };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isLayoutNode } from "./node.js";
|
|
2
|
-
import { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordRow, Show, Stat, Table, Users } from "./blocks.js";
|
|
2
|
+
import { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordCards, RecordRow, Show, Stat, Table, Users } from "./blocks.js";
|
|
3
3
|
import { component } from "./component.js";
|
|
4
4
|
import { countedResource, evaluateCondition, parseCondition } from "./condition.js";
|
|
5
5
|
import { walkTree } from "./walk.js";
|
|
@@ -11,4 +11,4 @@ import { checkPages } from "./check-page.js";
|
|
|
11
11
|
import { prunePage } from "./prune-page.js";
|
|
12
12
|
import { jsx_runtime_exports } from "./jsx-runtime.js";
|
|
13
13
|
import { fieldRef } from "@protobase/schema";
|
|
14
|
-
export { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordRow, Show, Stat, Table, Users, checkPages, component, conditionProblems, conditionReadable, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath, usersPage, walkTree };
|
|
14
|
+
export { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordCards, RecordRow, Show, Stat, Table, Users, checkPages, component, conditionProblems, conditionReadable, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath, usersPage, walkTree };
|
package/dist/prune-page.js
CHANGED
|
@@ -53,6 +53,20 @@ const prune = (node, scope, access) => {
|
|
|
53
53
|
} : props
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
case "RecordCards": {
|
|
57
|
+
if (!model || own === void 0) return node;
|
|
58
|
+
const fields = node.props.fields;
|
|
59
|
+
const cardActions = node.props.cardActions;
|
|
60
|
+
const props = {
|
|
61
|
+
...node.props,
|
|
62
|
+
...fields && { fields: fields.filter((name) => resolveFieldPath(models, own, name).ok) },
|
|
63
|
+
...cardActions && { cardActions: cardActions.filter((name) => access.actions(own).has(name)) }
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
...node,
|
|
67
|
+
props
|
|
68
|
+
};
|
|
69
|
+
}
|
|
56
70
|
case "ModalForm": {
|
|
57
71
|
if (!model || resource === void 0) return null;
|
|
58
72
|
if (!(node.props.mode === "create" ? access.permissions[resource]?.create : access.permissions[resource]?.update)) return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/layout",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "Composed pages for Protobase, written as JSX that compiles to plain data, with its JSX runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@protobase/schema": "0.33.
|
|
34
|
+
"@protobase/schema": "0.33.1",
|
|
35
35
|
"aip-parsers": "^1.0.0"
|
|
36
36
|
}
|
|
37
37
|
}
|