@protobase/layout 0.11.0 → 0.11.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.
@@ -1,10 +1,17 @@
1
1
  import { Block, LayoutChildren } from "./node.js";
2
2
  //#region src/component.d.ts
3
+ /** `plugin`: the plugin that provides the component at runtime, instead of the project's protobase.ui.tsx. */
4
+ export type ComponentOptions = {
5
+ plugin?: string;
6
+ };
3
7
  /**
4
8
  * Declares a custom component for layouts: `<UsageChart metric="cpu" />` becomes an element of type `UsageChart`,
5
9
  * which the app renders with the React component registered under that name. Its props must be static values too.
10
+ * With `plugin`, a plugin provides it, so `protobase build` does not look for it in protobase.ui.tsx.
6
11
  */
7
- export declare const component: <P extends object = Record<string, never>>(name: string) => Block<P & {
12
+ export declare const component: <P extends object = Record<string, never>>(name: string, options?: ComponentOptions) => Block<P & {
8
13
  children?: LayoutChildren;
9
- }>;
14
+ }> & {
15
+ readonly plugin?: string;
16
+ };
10
17
  //#endregion
package/dist/component.js CHANGED
@@ -5,11 +5,14 @@ const componentName = /^[A-Z][A-Za-z0-9]*$/;
5
5
  /**
6
6
  * Declares a custom component for layouts: `<UsageChart metric="cpu" />` becomes an element of type `UsageChart`,
7
7
  * which the app renders with the React component registered under that name. Its props must be static values too.
8
+ * With `plugin`, a plugin provides it, so `protobase build` does not look for it in protobase.ui.tsx.
8
9
  */
9
- const component = (name) => {
10
+ const component = (name, options = {}) => {
10
11
  if (!componentName.test(name)) throw new Error(`Component name "${name}" must be PascalCase, such as UsageChart`);
11
12
  if (Object.hasOwn(blockSpecs, name) || name === "Fragment") throw new Error(`"${name}" is a built-in block; give the custom component another name`);
12
- return defineBlock(name, true);
13
+ if (options.plugin !== void 0 && options.plugin.trim() === "") throw new Error(`component('${name}') names an empty plugin; name the plugin that provides it`);
14
+ const block = defineBlock(name, true);
15
+ return options.plugin === void 0 ? block : Object.assign(block, { plugin: options.plugin });
13
16
  };
14
17
  //#endregion
15
18
  export { component };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Block, LayoutChild, LayoutChildren, LayoutNode, LayoutValue, isLayoutNode } from "./node.js";
2
2
  import { Action, ActionProps, ButtonVariant, Card, CardProps, CardRow, CardRowProps, DataProps, Elements, Field, FieldProps, Grid, GridProps, GridSpan, Link, LinkProps, ModalForm, ModalFormProps, Page, PageProps, Progress, ProgressProps, RecordCard, RecordCardProps, Show, ShowProps, Stat, StatProps, Table, TableProps } from "./blocks.js";
3
- import { component } from "./component.js";
3
+ import { ComponentOptions, component } from "./component.js";
4
4
  import { PageDefinition, PageModel, PageOptions, isPageDefinition, page } from "./page.js";
5
5
  import { checkPages } from "./check-page.js";
6
6
  import { prunePage } from "./prune-page.js";
@@ -8,4 +8,4 @@ import { countedResource, evaluateCondition, parseCondition } from "./condition.
8
8
  import { PathStep, resolveFieldPath } from "./field-path.js";
9
9
  import { jsx_runtime_d_exports } from "./jsx-runtime.js";
10
10
  import { FieldRefValue, fieldRef } from "@protobase/schema";
11
- export { Action, type ActionProps, type Block, type ButtonVariant, Card, type CardProps, CardRow, type CardRowProps, 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, ModalForm, type ModalFormProps, Page, type PageDefinition, type PageModel, type PageOptions, type PageProps, type PathStep, Progress, type ProgressProps, RecordCard, type RecordCardProps, Show, type ShowProps, Stat, type StatProps, Table, type TableProps, checkPages, component, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_d_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath };
11
+ export { Action, type ActionProps, type Block, type ButtonVariant, Card, type CardProps, CardRow, type CardRowProps, 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, ModalForm, type ModalFormProps, Page, type PageDefinition, type PageModel, type PageOptions, type PageProps, type PathStep, Progress, type ProgressProps, RecordCard, type RecordCardProps, Show, type ShowProps, Stat, type StatProps, Table, type TableProps, checkPages, component, countedResource, evaluateCondition, fieldRef, isLayoutNode, isPageDefinition, jsx_runtime_d_exports as jsxRuntime, page, parseCondition, prunePage, resolveFieldPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/layout",
3
- "version": "0.11.0",
3
+ "version": "0.11.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.11.0",
34
+ "@protobase/schema": "0.11.1",
35
35
  "aip-parsers": "^1.0.0"
36
36
  }
37
37
  }