@protobase/layout 0.40.7 → 0.40.8
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 +11 -0
- package/dist/blocks.d.ts +8 -0
- package/dist/cards-layout.d.ts +8 -0
- package/dist/cards-layout.js +8 -0
- package/dist/check-page.js +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/package.json +2 -2
package/dist/block-specs.js
CHANGED
|
@@ -107,6 +107,8 @@ const blockSpecs = {
|
|
|
107
107
|
props: {
|
|
108
108
|
...data,
|
|
109
109
|
...heading,
|
|
110
|
+
layout: optional("cardsLayout"),
|
|
111
|
+
cardWidth: optional("cardWidth"),
|
|
110
112
|
fields: optional("texts"),
|
|
111
113
|
cardActions: optional("texts"),
|
|
112
114
|
limit: optional("integer"),
|
|
@@ -213,6 +215,13 @@ const ranges = [
|
|
|
213
215
|
"1y",
|
|
214
216
|
"all"
|
|
215
217
|
];
|
|
218
|
+
const cardsLayouts = ["stack", "carousel"];
|
|
219
|
+
const cardWidths = [
|
|
220
|
+
"1/4",
|
|
221
|
+
"1/3",
|
|
222
|
+
"1/2",
|
|
223
|
+
"2/3"
|
|
224
|
+
];
|
|
216
225
|
const oneOf = (values) => [(value) => typeof value === "string" && values.includes(value), values.join(", ")];
|
|
217
226
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
218
227
|
const checks = {
|
|
@@ -232,6 +241,8 @@ const checks = {
|
|
|
232
241
|
chartType: oneOf(chartTypes),
|
|
233
242
|
bucket: oneOf(buckets),
|
|
234
243
|
range: oneOf(ranges),
|
|
244
|
+
cardsLayout: oneOf(cardsLayouts),
|
|
245
|
+
cardWidth: oneOf(cardWidths),
|
|
235
246
|
address: [(value) => isObject(value) && !isLayoutNode(value) && typeof value.kind === "string", "an address, such as { kind: 'list', resource: 'orders' }"]
|
|
236
247
|
};
|
|
237
248
|
/** Problems with one element's props and children against its block's spec. */
|
package/dist/blocks.d.ts
CHANGED
|
@@ -83,12 +83,20 @@ export type RecordRowProps = DataProps & Heading & {
|
|
|
83
83
|
empty?: string;
|
|
84
84
|
span?: GridSpan;
|
|
85
85
|
};
|
|
86
|
+
/** How a `RecordCards` lays out its cards: stacked full width, or in one row that scrolls sideways, snapping each card to its left edge. */
|
|
87
|
+
export type CardsLayout = 'stack' | 'carousel';
|
|
88
|
+
/** How wide each card of a carousel is, as a share of the block's width. */
|
|
89
|
+
export type CardWidth = '1/4' | '1/3' | '1/2' | '2/3';
|
|
86
90
|
/**
|
|
87
91
|
* What a filter finds as the cards a record page's related section draws with `presentation: 'cards'`, stacked full
|
|
88
92
|
* width under a heading that is not a card: each card its record's title linking to its page, its `fields` under their
|
|
89
93
|
* labels with a long value cut short behind Show more, and its `cardActions`' buttons; "View all" opens the rest.
|
|
90
94
|
*/
|
|
91
95
|
export type RecordCardsProps = DataProps & Heading & {
|
|
96
|
+
/** Default `stack`; `carousel` puts the cards in one row that scrolls sideways. */
|
|
97
|
+
layout?: CardsLayout;
|
|
98
|
+
/** How wide each card of a carousel is, as a share of the block's width, so the next one peeks in; default `2/3`. */
|
|
99
|
+
cardWidth?: CardWidth;
|
|
92
100
|
/** The fields each card shows, through relations too (`task_id.title`); the list's columns when omitted. */
|
|
93
101
|
fields?: string[];
|
|
94
102
|
/** Named actions of the resource's view, as buttons on each card. */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardWidth, CardsLayout, RecordCardsProps } from "./blocks.js";
|
|
2
|
+
//#region src/cards-layout.d.ts
|
|
3
|
+
/** How a `RecordCards` lays out its cards, its props' defaults filled in: stacked, and two thirds wide in a carousel. */
|
|
4
|
+
export declare const cardsLayoutOf: ({ layout, cardWidth }: Pick<RecordCardsProps, "layout" | "cardWidth">) => {
|
|
5
|
+
layout: CardsLayout;
|
|
6
|
+
cardWidth: CardWidth;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/cards-layout.ts
|
|
2
|
+
/** How a `RecordCards` lays out its cards, its props' defaults filled in: stacked, and two thirds wide in a carousel. */
|
|
3
|
+
const cardsLayoutOf = ({ layout, cardWidth }) => ({
|
|
4
|
+
layout: layout ?? "stack",
|
|
5
|
+
cardWidth: cardWidth ?? "2/3"
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { cardsLayoutOf };
|
package/dist/check-page.js
CHANGED
|
@@ -60,6 +60,7 @@ const nodeProblems = (node, scope, { models, actions, pages, createPages }) => {
|
|
|
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
62
|
case "RecordCards":
|
|
63
|
+
if (node.props.cardWidth !== void 0 && node.props.layout !== "carousel") problems.push(`"cardWidth" sizes the cards of a carousel; set layout to 'carousel' or leave it out`);
|
|
63
64
|
for (const name of node.props.fields ?? []) path(name, own);
|
|
64
65
|
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
66
|
break;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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, RecordCards, RecordCardsProps, RecordRow, RecordRowProps, Show, ShowProps, Stat, StatProps, Table, TableProps, Users, UsersProps } from "./blocks.js";
|
|
2
|
+
import { Action, ActionProps, ButtonVariant, Card, CardProps, CardRow, CardRowProps, CardWidth, CardsLayout, 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";
|
|
6
|
+
import { cardsLayoutOf } from "./cards-layout.js";
|
|
6
7
|
import { Location, walkTree } from "./walk.js";
|
|
7
8
|
import { checkPages } from "./check-page.js";
|
|
8
9
|
import { conditionProblems, conditionReadable } from "./check-condition.js";
|
|
@@ -11,4 +12,4 @@ import { countedResource, evaluateCondition, parseCondition } from "./condition.
|
|
|
11
12
|
import { PathStep, resolveFieldPath } from "./field-path.js";
|
|
12
13
|
import { jsx_runtime_d_exports } from "./jsx-runtime.js";
|
|
13
14
|
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, 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 };
|
|
15
|
+
export { Action, type ActionProps, type Block, type ButtonVariant, Card, type CardProps, CardRow, type CardRowProps, type CardWidth, type CardsLayout, 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, cardsLayoutOf, 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
|
@@ -5,10 +5,11 @@ import { countedResource, evaluateCondition, parseCondition } from "./condition.
|
|
|
5
5
|
import { walkTree } from "./walk.js";
|
|
6
6
|
import { isPageDefinition, page } from "./page.js";
|
|
7
7
|
import { usersPage } from "./presets/users-page.js";
|
|
8
|
+
import { cardsLayoutOf } from "./cards-layout.js";
|
|
8
9
|
import { resolveFieldPath } from "./field-path.js";
|
|
9
10
|
import { conditionProblems, conditionReadable } from "./check-condition.js";
|
|
10
11
|
import { checkPages } from "./check-page.js";
|
|
11
12
|
import { prunePage } from "./prune-page.js";
|
|
12
13
|
import { jsx_runtime_exports } from "./jsx-runtime.js";
|
|
13
14
|
import { fieldRef } from "@protobase/schema";
|
|
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 };
|
|
15
|
+
export { Action, Card, CardRow, Chart, Field, Grid, Link, ModalForm, Page, Progress, RecordCard, RecordCards, RecordRow, Show, Stat, Table, Users, cardsLayoutOf, checkPages, component, conditionProblems, conditionReadable, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath, usersPage, walkTree };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/layout",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.8",
|
|
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.40.
|
|
34
|
+
"@protobase/schema": "0.40.8",
|
|
35
35
|
"aip-parsers": "^1.0.0"
|
|
36
36
|
}
|
|
37
37
|
}
|