@object-ui/components 17.7.0 → 18.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.
- package/CHANGELOG.md +868 -0
- package/README.md +22 -0
- package/dist/custom/RecordTitleChip.d.ts +4 -3
- package/dist/custom/dialog-viewport-gutter.d.ts +37 -0
- package/dist/custom/empty-state-link.d.ts +63 -0
- package/dist/custom/filter-builder.d.ts +35 -19
- package/dist/custom/grouping-editor.d.ts +4 -0
- package/dist/custom/horizontal-overflow.d.ts +18 -0
- package/dist/custom/index.d.ts +4 -0
- package/dist/custom/sort-builder.d.ts +8 -0
- package/dist/custom/use-horizontal-overflow.d.ts +36 -0
- package/dist/hooks/related-count-store.d.ts +55 -0
- package/dist/index.css +194 -4
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5148 -3912
- package/dist/index.umd.cjs +6 -5
- package/dist/lib/inline-markdown.d.ts +64 -0
- package/dist/renderers/action/disabled-reason.d.ts +49 -0
- package/dist/renderers/action/static-params.d.ts +17 -25
- package/dist/renderers/basic/data-list.d.ts +2 -1
- package/dist/renderers/basic/elements.d.ts +2 -3
- package/dist/renderers/basic/record-picker.d.ts +3 -2
- package/dist/renderers/complex/dataTableBindDiagnostic.d.ts +2 -2
- package/dist/renderers/layout/containers.d.ts +30 -16
- package/dist/renderers/layout/page-block-grid.d.ts +29 -0
- package/dist/renderers/layout/page-block-span.d.ts +50 -0
- package/dist/renderers/layout/page-description-context.d.ts +14 -0
- package/dist/renderers/layout/page-print.d.ts +14 -0
- package/dist/renderers/layout/page-region-posture.d.ts +82 -0
- package/dist/ui/button.d.ts +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* The one inline Markdown renderer (objectui#12778): `**bold**`, `*italic*`,
|
|
9
|
+
* `` `code` `` and `[text](url)`, drawn as React elements, never as an HTML
|
|
10
|
+
* string. Two surfaces read it: `element:text`, whose spec declares its
|
|
11
|
+
* `content` as "Text or Markdown content", and the console's marketplace
|
|
12
|
+
* README renderer (`MarkdownText` in `@object-ui/app-shell`), which owns the
|
|
13
|
+
* block half (headings, lists, fences) and hands each block's text here.
|
|
14
|
+
*
|
|
15
|
+
* Raw HTML (objectui#12146) is recognised by CommonMark's "Raw HTML" grammar
|
|
16
|
+
* and skipped: neither rendered nor printed. The grammar pieces are exported
|
|
17
|
+
* because `MarkdownText`'s "HTML blocks" rules are spelled from the same open
|
|
18
|
+
* and closing tag.
|
|
19
|
+
*
|
|
20
|
+
* A link keeps its `href` only for `http:`, `https:`, `mailto:` and `tel:`, or
|
|
21
|
+
* for a scheme-less reference (a path, a query, a fragment). Anything else —
|
|
22
|
+
* `javascript:`, `data:`, `vbscript:`, in any case — prints its text with no
|
|
23
|
+
* anchor. React 19 blocks `javascript:` URLs itself; this package's peer range
|
|
24
|
+
* admits React 18, which does not. An `href` carrying whitespace or a control
|
|
25
|
+
* character is refused outright, because browsers strip those before reading
|
|
26
|
+
* the scheme (`java\tscript:` runs as `javascript:`).
|
|
27
|
+
*
|
|
28
|
+
* Emphasis follows CommonMark's flanking rule in its simplest form: the
|
|
29
|
+
* delimiter run may not sit against whitespace on its inner side, so a lone
|
|
30
|
+
* `*` or `2 * 3 * 4` prints as typed. A code span is a single backtick pair;
|
|
31
|
+
* a run of two or more backticks (a fence typed into inline text) prints as
|
|
32
|
+
* typed.
|
|
33
|
+
*/
|
|
34
|
+
import * as React from 'react';
|
|
35
|
+
/** CommonMark "open tag", as a RegExp source. */
|
|
36
|
+
export declare const RAW_HTML_OPEN_TAG = "<[A-Za-z][A-Za-z0-9-]*(?:\\s+[A-Za-z_:][A-Za-z0-9_.:-]*(?:\\s*=\\s*(?:[^\"'=<>`\\s]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>";
|
|
37
|
+
/** CommonMark "closing tag", as a RegExp source. */
|
|
38
|
+
export declare const RAW_HTML_CLOSING_TAG = "<\\/[A-Za-z][A-Za-z0-9-]*\\s*>";
|
|
39
|
+
/**
|
|
40
|
+
* The `href` a Markdown link may carry, or `null` when it may not carry one.
|
|
41
|
+
* Allow-list, not deny-list: a scheme this does not name is refused.
|
|
42
|
+
*/
|
|
43
|
+
export declare function safeLinkHref(raw: string): string | null;
|
|
44
|
+
export interface InlineMarkdownOptions {
|
|
45
|
+
/** Classes for the drawn elements; each defaults to none. */
|
|
46
|
+
classNames?: {
|
|
47
|
+
code?: string;
|
|
48
|
+
strong?: string;
|
|
49
|
+
em?: string;
|
|
50
|
+
link?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Which links open in a new tab (`target="_blank" rel="noopener noreferrer"`):
|
|
54
|
+
* `'all'`, or `'external'` — `http:` / `https:` and protocol-relative URLs,
|
|
55
|
+
* leaving a same-site path, `mailto:` and `tel:` in the same tab.
|
|
56
|
+
*/
|
|
57
|
+
newTab?: 'all' | 'external';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Renders one run of text through the inline subset. Every pattern is tried
|
|
61
|
+
* at each step and the earliest match wins, so the order below only breaks
|
|
62
|
+
* ties at the same position.
|
|
63
|
+
*/
|
|
64
|
+
export declare function renderInlineMarkdown(input: string, options?: InlineMarkdownOptions): React.ReactNode;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** A reason to show, with the ids the control's ARIA attributes point at. */
|
|
3
|
+
export interface DisabledReason {
|
|
4
|
+
/** The localized reason text. */
|
|
5
|
+
text: string;
|
|
6
|
+
/** Id of the element holding the reason — the control's description. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Id of a menu item's label element — the item's name when it shows a reason. */
|
|
9
|
+
labelId: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The reason for a control, or `undefined` when it gives none.
|
|
13
|
+
*
|
|
14
|
+
* `disabledByPredicate` is the caller's DECLARED-`disabled` verdict alone, never
|
|
15
|
+
* the OR it hands the control's `disabled` prop. A hook, so call it with the
|
|
16
|
+
* other hooks, ahead of any early return.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDisabledReason(disabledByPredicate: boolean): DisabledReason | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The control's `aria-describedby`: an id it already carries (an authored
|
|
21
|
+
* `ariaDescribedBy` reaches `action:button` and `action:icon` through their DOM
|
|
22
|
+
* pass-through) followed by the reason's, or `undefined` when there is neither.
|
|
23
|
+
*/
|
|
24
|
+
export declare function describedByWithReason(existing: unknown, reason: DisabledReason | undefined): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Wraps a disabled button in the tooltip trigger that carries its reason, or
|
|
27
|
+
* returns the button alone when there is no reason. `heading` is shown above
|
|
28
|
+
* the reason inside the tooltip; `action:icon` passes its label there, since an
|
|
29
|
+
* icon-only control has no visible name and its own label tooltip cannot open
|
|
30
|
+
* while it is disabled.
|
|
31
|
+
*/
|
|
32
|
+
export declare function DisabledReasonTrigger({ reason, heading, children, }: {
|
|
33
|
+
reason: DisabledReason | undefined;
|
|
34
|
+
heading?: React.ReactNode;
|
|
35
|
+
children: React.ReactElement;
|
|
36
|
+
}): React.ReactElement;
|
|
37
|
+
/** The ARIA a menu item carries while it shows a reason; none otherwise. */
|
|
38
|
+
export declare function menuItemReasonAria(reason: DisabledReason | undefined): {
|
|
39
|
+
'aria-labelledby'?: string;
|
|
40
|
+
'aria-describedby'?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A menu item's label, with the reason as a visible second line under it when
|
|
44
|
+
* there is one. Pair it with `menuItemReasonAria` on the item.
|
|
45
|
+
*/
|
|
46
|
+
export declare function DisabledReasonMenuLabel({ reason, children, }: {
|
|
47
|
+
reason: DisabledReason | undefined;
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
}): React.ReactElement;
|
|
@@ -28,43 +28,35 @@ export declare function readStaticParamValues(subject: StaticParamsSubject, wher
|
|
|
28
28
|
*/
|
|
29
29
|
export type ConfigBagEvaluator = (bag: unknown) => unknown;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* An `action:bar` member with its `properties` evaluated (objectui#10290).
|
|
32
32
|
*
|
|
33
|
-
* `action:bar
|
|
34
|
-
*
|
|
35
|
-
* evaluates a node's `properties`.
|
|
36
|
-
*
|
|
33
|
+
* `action:bar` mounts its inline members on `action:button` / `action:icon`
|
|
34
|
+
* itself, so a member never passes through the `SchemaRenderer` memo that
|
|
35
|
+
* evaluates a node's `properties`. The renderer it lands on reads the static
|
|
36
|
+
* values off `properties.params` ({@link readStaticParamValues},
|
|
37
|
+
* objectui#10289), and they are templates (objectui#7867): on a record page,
|
|
37
38
|
* `"recordId": "${record.id}"` has to reach the handler as the record's id. The
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* composes
|
|
39
|
+
* bar evaluates the member's `properties` with the memo's own evaluator and
|
|
40
|
+
* scope (`evaluateBag`, from `useConfigBagEvaluator()`), once, where it
|
|
41
|
+
* composes the member.
|
|
41
42
|
*
|
|
42
43
|
* Returns the member itself when it carries no `properties` bag. Only
|
|
43
44
|
* `properties` is evaluated. It is not copied onto the member (the memo's
|
|
44
45
|
* hoist), and the member's other keys are left as authored.
|
|
45
|
-
*/
|
|
46
|
-
export declare function withEvaluatedProperties<T extends object>(member: T, evaluateBag: ConfigBagEvaluator): T;
|
|
47
|
-
/**
|
|
48
|
-
* A container member's static values (objectui#10290): its `properties.params`,
|
|
49
|
-
* evaluated through {@link withEvaluatedProperties}, or `undefined`.
|
|
50
46
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* its `properties` already evaluated, and `readStaticParamValues` reads it
|
|
54
|
-
* there.)
|
|
47
|
+
* `action:group` and `action:menu` do not call this: their members carry no
|
|
48
|
+
* `properties` bag (objectui#11638).
|
|
55
49
|
*/
|
|
56
|
-
export declare function
|
|
50
|
+
export declare function withEvaluatedProperties<T extends object>(member: T, evaluateBag: ConfigBagEvaluator): T;
|
|
57
51
|
/**
|
|
58
52
|
* The same ruling on a spec ACTION ENTRY (objectui#10462): `element:button`'s
|
|
59
53
|
* inline `action`, `action:group` / `action:menu` items and `page:header`'s
|
|
60
54
|
* actions. `params` is an entry's `ActionParam[]` input list and nothing else.
|
|
61
|
-
* (
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* inline `action` and `page:header`'s actions do not read
|
|
67
|
-
* `properties.params`.)
|
|
55
|
+
* (No entry surface reads a `properties.params` bag. `UIActionSchema` declares
|
|
56
|
+
* no `properties`, and the spec refuses one on an `action:group` /
|
|
57
|
+
* `action:menu` member: its static parameter values are not part of the inline
|
|
58
|
+
* action vocabulary, and an action that needs them is its own `action:button`
|
|
59
|
+
* node (objectui#11638).)
|
|
68
60
|
*
|
|
69
61
|
* One type is still different: `api`. The objectstack#5777 window keeps the
|
|
70
62
|
* runner reading an object `params` as the request payload (with its own
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* row, no toolbar/card/pagination.
|
|
15
15
|
*
|
|
16
16
|
* Props are read off `schema.properties` (spec convention) with a `schema.props`
|
|
17
|
-
* fallback, matching the other `element:*` renderers.
|
|
17
|
+
* fallback, matching the other `element:*` renderers. The repeater's query is
|
|
18
|
+
* the node-level `dataSource` binding alone (objectui#11880, objectui#12345).
|
|
18
19
|
*/
|
|
19
20
|
export {};
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
* All props are read off `schema.properties` per the spec's
|
|
23
23
|
* `UIComponent.properties` convention; `schema.props` is also accepted
|
|
24
24
|
* as a fallback so authors transitioning between conventions keep working.
|
|
25
|
-
* `element:number`
|
|
26
|
-
* `object`
|
|
27
|
-
* flat one (objectui#10909).
|
|
25
|
+
* `element:number` reads its query from the node-level `dataSource` binding
|
|
26
|
+
* ONLY: its `object` and its `filter` (objectui#10909, objectui#11880).
|
|
28
27
|
*/
|
|
29
28
|
export {};
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Data binding follows the spec's ElementDataSource (`schema.dataSource`):
|
|
12
12
|
* { object, view?, filter?, sort?, limit? }
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
13
|
+
* and is read from there ONLY: the flat `properties.object` / `filter` /
|
|
14
|
+
* `sort` / `limit` are not read (objectui#11880, objectstack#11509 ruled
|
|
15
|
+
* A-narrow). Display config is read off `schema.properties`:
|
|
15
16
|
* { labelField='name', valueField='id', label?, placeholder?, emptyText? }
|
|
16
17
|
*
|
|
17
18
|
* The selection is written through `usePageVariableBinding(schema.id)`: the
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
* EMPTY_ROWS` off the node, and the file calls no such hook.
|
|
33
33
|
*
|
|
34
34
|
* A `bind` on a `data-table` is nevertheless accepted by every gate: the TS
|
|
35
|
-
* side
|
|
36
|
-
* being `.passthrough()` (which `DataTableSchema.extend(…)` inherits). So the
|
|
35
|
+
* side because `BaseSchema` declares `bind` for every node (objectui#6357), the
|
|
36
|
+
* zod side by `BaseSchema` being `.passthrough()` (which `DataTableSchema.extend(…)` inherits). So the
|
|
37
37
|
* author gets a table drawing a correct-looking header over the "No results
|
|
38
38
|
* found" empty state, with no error, no warning and no diagnostic — the
|
|
39
39
|
* hardest failure shape for a human OR an AI author to self-check, because a
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
3
|
+
* The props of {@link PageHeaderActions}.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
* `actions`, `maxVisible` and `mobileMaxVisible` are `page:header`'s own
|
|
6
|
+
* authored keys, read as that block reads them; the system actions are not a
|
|
7
|
+
* prop, they come from `RecordContext.headerSystemActions` as they always did.
|
|
8
|
+
*/
|
|
9
|
+
export interface PageHeaderActionsProps {
|
|
10
|
+
/** The authored `actions` array: action ids (the contract) or, during the transition, inline action objects. */
|
|
11
|
+
actions?: unknown;
|
|
12
|
+
/** The inline-button budget on desktop, as `page:header`'s `maxVisible`; an out-of-contract value falls back to 3. */
|
|
13
|
+
maxVisible?: unknown;
|
|
14
|
+
/** The inline-button budget on mobile, as `page:header`'s `mobileMaxVisible`; an out-of-contract value falls back to 1. */
|
|
15
|
+
mobileMaxVisible?: unknown;
|
|
16
|
+
/** Drawn in place of the action row when no action survives the gates. */
|
|
17
|
+
emptySlot?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A record's header actions: the declared actions placed at `record_header` /
|
|
21
|
+
* `record_more` and the host's system actions (Edit / Share / Delete), gated,
|
|
22
|
+
* ordered, split into inline buttons and the `⋯` overflow, and dispatched
|
|
23
|
+
* through the action runner.
|
|
11
24
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
25
|
+
* This is `page:header`'s action row, lifted out of `PageHeaderRenderer` so
|
|
26
|
+
* that a host can draw the same row where a page has no `page:header`
|
|
27
|
+
* (objectui#12906): a page that declares `print` may hold only the printable
|
|
28
|
+
* component types, and `page:header` is not one of them, so the console's
|
|
29
|
+
* record view draws this row in its screen-only chrome beside Print. It is
|
|
30
|
+
* the ONE resolver for both surfaces, ⛔ never a second one. It must render
|
|
31
|
+
* inside the record's `RecordContext` and `ActionProvider`, as `page:header`
|
|
32
|
+
* does.
|
|
19
33
|
*/
|
|
20
|
-
export
|
|
34
|
+
export declare const PageHeaderActions: React.FC<PageHeaderActionsProps>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Lays a list of page blocks on the 12-column block grid (objectui#12624):
|
|
4
|
+
* each block takes the span its kind gets from `./page-block-span`, folded by
|
|
5
|
+
* breakpoint. One component for every block list that folds this way: a
|
|
6
|
+
* region's blocks (`RegionContent` in `./page.tsx`) and the children of
|
|
7
|
+
* `page:card` / `page:section` (`./containers.tsx`), so a container in a
|
|
8
|
+
* region spans 12 by its own kind and its children fold like region blocks.
|
|
9
|
+
* A cell is `empty:hidden`, so a block that renders nothing leaves no gap.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PageBlockGrid: React.FC<{
|
|
12
|
+
nodes: readonly unknown[];
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Marks the list as a rail's: every block in it, nested ones too, spans 12. */
|
|
15
|
+
rail?: boolean;
|
|
16
|
+
/** Key prefix for blocks with no `id`. */
|
|
17
|
+
keyPrefix?: string;
|
|
18
|
+
/** Maps a node to the schema `SchemaRenderer` renders (identity by default). */
|
|
19
|
+
toSchema?: (node: unknown) => unknown;
|
|
20
|
+
attributes?: Record<string, string | undefined>;
|
|
21
|
+
/** The grid element, for a caller that measures it (the region's posture, objectui#12703). */
|
|
22
|
+
gridRef?: React.Ref<HTMLDivElement>;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* A container's child slot as a block grid: a list goes on the grid, while a
|
|
26
|
+
* bare node or text renders as it did (`renderChildren`), since there is
|
|
27
|
+
* nothing to lay out beside it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function renderBlockChildren(children: unknown, render: (c: unknown) => React.ReactNode): React.ReactNode;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* How wide a page block sits in its region's 12-column block grid
|
|
10
|
+
* (objectui#12624).
|
|
11
|
+
*
|
|
12
|
+
* The width is DERIVED from the block's kind, never authored:
|
|
13
|
+
* `@objectstack/spec`'s `PageComponentSchema` declares no `span`, and on
|
|
14
|
+
* `PageRegionSchema` `span` is only a refused alias of `width`. So this file
|
|
15
|
+
* adds no key an author can write; it names, once, which registered block
|
|
16
|
+
* types are metric tiles (3 of 12) and which are charts (6 of 12). Every other
|
|
17
|
+
* type, a type this table does not name included, spans the full 12.
|
|
18
|
+
*
|
|
19
|
+
* The keys are the registry keys the blocks are registered under (the bare
|
|
20
|
+
* key where the registration keeps one, and the namespaced key). The page
|
|
21
|
+
* renderer (`RegionContent` in `./page.tsx`) and the Studio page designer's
|
|
22
|
+
* block card (app-shell `PageBlockCanvas`) both read this table, so the span
|
|
23
|
+
* the designer shows is the span the page draws.
|
|
24
|
+
*/
|
|
25
|
+
export type PageBlockSpan = 3 | 6 | 12;
|
|
26
|
+
/** Registered block type → its span, for the types narrower than 12. */
|
|
27
|
+
export declare const PAGE_BLOCK_SPANS: ReadonlyMap<string, 3 | 6>;
|
|
28
|
+
/**
|
|
29
|
+
* The span a block of this type takes; a type the table does not name takes
|
|
30
|
+
* 12. A block in a `rail` region (below) takes 12 whatever its kind: a rail is
|
|
31
|
+
* a narrow column, where a fold by viewport width would squeeze a tile to a
|
|
32
|
+
* sliver.
|
|
33
|
+
*/
|
|
34
|
+
export declare function pageBlockSpan(type: unknown, rail?: boolean): PageBlockSpan;
|
|
35
|
+
/**
|
|
36
|
+
* Is this region a rail — the narrow `sidebar` / `aside` column beside `main`?
|
|
37
|
+
* Both are on every layout that places those slots beside `main` (no
|
|
38
|
+
* template, `default`, `full-width`, `three-column`); `header-sidebar-main`
|
|
39
|
+
* places only `sidebar` there (an `aside` joins `main`'s column); the
|
|
40
|
+
* `dashboard` template makes every region but `header` / `footer` a grid cell,
|
|
41
|
+
* so it has none. The page renderer passes the same answer structurally, by
|
|
42
|
+
* the slot it places a region in.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isPageRailRegion(regionName: unknown, template?: unknown): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The span folded by breakpoint: as declared from `xl` (1280px) up; between
|
|
47
|
+
* `md` (768px) and `xl` tiles take 6 and charts 12; under `md` every block
|
|
48
|
+
* takes 12. LITERAL class strings so Tailwind's scanner emits them.
|
|
49
|
+
*/
|
|
50
|
+
export declare const PAGE_BLOCK_SPAN_CLASS: Readonly<Record<PageBlockSpan, string>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The page `description` a titled `page:header` draws under its title
|
|
4
|
+
* (objectui#12624).
|
|
5
|
+
*
|
|
6
|
+
* When an authored `page:header` owns the page's `h1`, the page renderer no
|
|
7
|
+
* longer draws the description in its own heading block, which sat ABOVE the
|
|
8
|
+
* regions and so above the title. It hands the description down here instead,
|
|
9
|
+
* and the header draws it after the title, the order the console page header
|
|
10
|
+
* uses. Every page renderer provides a value (null when it draws the
|
|
11
|
+
* description itself), so a page nested in another never reads the outer
|
|
12
|
+
* page's description.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PageDescriptionContext: React.Context<React.ReactNode>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PageNodeSchema } from '@object-ui/types';
|
|
2
|
+
/** The page's `print` declaration, as the node type carries it from the spec by reference. */
|
|
3
|
+
export type PagePrintDeclaration = NonNullable<PageNodeSchema['print']>;
|
|
4
|
+
/** The DOM attribute `PageRenderer` stamps on the root of a print page; every rule below is scoped to it. */
|
|
5
|
+
export declare const PRINT_PAGE_ATTRIBUTE = "data-print-page";
|
|
6
|
+
/** The DOM attribute on the running-region table `PageRenderer` draws for `repeatHeader` / `repeatFooter`. */
|
|
7
|
+
export declare const PRINT_RUNNING_ATTRIBUTE = "data-print-running";
|
|
8
|
+
/** True when `value` is a `print` declaration object — the one condition under which a page is a print page. */
|
|
9
|
+
export declare function isPagePrintDeclaration(value: unknown): value is PagePrintDeclaration;
|
|
10
|
+
/**
|
|
11
|
+
* Build the print stylesheet for a page that declares `print`. Pure: the same
|
|
12
|
+
* declaration always yields the same text, so it is pinned as text.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildPagePrintStylesheet(print: PagePrintDeclaration): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* How a block in a page region should present itself, judged by the region's
|
|
11
|
+
* MEASURED width against the page's (objectui#12703).
|
|
12
|
+
*
|
|
13
|
+
* - `'compact'`: the region is narrower than half the page — the `aside` rail
|
|
14
|
+
* beside `main`, a sidebar, a third of a three-column body. A list block
|
|
15
|
+
* there draws a short list (title, count, two-line rows) instead of the
|
|
16
|
+
* object list's own chrome.
|
|
17
|
+
* - `'full'`: the region is half the page or wider.
|
|
18
|
+
*
|
|
19
|
+
* `null` — the answer outside any page region, and inside one whose width is
|
|
20
|
+
* not known yet (no layout: server render, jsdom, the first render before the
|
|
21
|
+
* measurement lands). A block reads `null` exactly as `'full'`: an unknown
|
|
22
|
+
* width keeps today's full rendering.
|
|
23
|
+
*
|
|
24
|
+
* ⭐ DERIVED, never authored. `@objectstack/spec` declares no posture or
|
|
25
|
+
* `compact` key on a page, a region or a block, and this adds none: the page
|
|
26
|
+
* renderer measures, and a block reads the answer through
|
|
27
|
+
* {@link usePageRegionPosture}. ⛔ Not a viewport breakpoint: a region's
|
|
28
|
+
* width relative to its page is what decides, so the same `aside` is compact
|
|
29
|
+
* on a wide screen and full once the layout stacks it under `main`.
|
|
30
|
+
*/
|
|
31
|
+
export type PageRegionPosture = 'compact' | 'full';
|
|
32
|
+
/**
|
|
33
|
+
* The posture a region `regionWidth` wide takes on a page `pageWidth` wide.
|
|
34
|
+
* `null` when either width is unknown (zero, negative or not a number): the
|
|
35
|
+
* caller then keeps the full rendering.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pageRegionPostureFor(regionWidth: number, pageWidth: number): PageRegionPosture | null;
|
|
38
|
+
/**
|
|
39
|
+
* The page body's width, as a store a region subscribes to rather than a
|
|
40
|
+
* context VALUE: a value that changed on every resize would re-render every
|
|
41
|
+
* region and the whole block tree under it, while a subscription re-renders a
|
|
42
|
+
* region only when its posture flips.
|
|
43
|
+
*/
|
|
44
|
+
export interface PageWidthStore {
|
|
45
|
+
get(): number;
|
|
46
|
+
set(width: number): void;
|
|
47
|
+
subscribe(listener: () => void): () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The page's width store, watching the page body `bodyRef` points at — the
|
|
51
|
+
* element the page's regions are laid out in. Called by `PageRenderer`, the
|
|
52
|
+
* component that RENDERS that element, and handed to {@link PageWidthProvider}.
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ The watch has to run in the component that renders the body element, not
|
|
55
|
+
* in a provider nested inside it: React attaches a host element's ref after
|
|
56
|
+
* the layout effects of the components below it have run, so a provider
|
|
57
|
+
* inside the body would find the ref still empty.
|
|
58
|
+
*/
|
|
59
|
+
export declare function usePageWidthStore(bodyRef: React.RefObject<HTMLElement | null>): PageWidthStore;
|
|
60
|
+
/** Publishes the page's width store to every region under it. Rendered by `PageRenderer`. */
|
|
61
|
+
export declare const PageWidthProvider: React.FC<{
|
|
62
|
+
store: PageWidthStore;
|
|
63
|
+
children: React.ReactNode;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Measures the region `regionRef` points at against the page width published
|
|
67
|
+
* above it and tells the region's blocks their posture. Rendered by the page
|
|
68
|
+
* renderer's `RegionContent`. It re-renders when the posture flips and at no
|
|
69
|
+
* other resize, and its `children` element is the same one each time, so a
|
|
70
|
+
* flip reaches the blocks that read the posture and nothing else.
|
|
71
|
+
*/
|
|
72
|
+
export declare const PageRegionPostureProvider: React.FC<{
|
|
73
|
+
regionRef: React.RefObject<HTMLElement | null>;
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* The posture of the page region this block renders in: `'compact'` when the
|
|
78
|
+
* region is narrower than half the page, `'full'` when it is not, `null`
|
|
79
|
+
* outside a page region or before the width is known — read `null` as
|
|
80
|
+
* `'full'`. Safe outside any provider.
|
|
81
|
+
*/
|
|
82
|
+
export declare function usePageRegionPosture(): PageRegionPosture | null;
|
package/dist/ui/button.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
8
8
|
*/
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
declare const buttonVariants: (props?: ({
|
|
11
|
-
variant?: "link" | "default" | "secondary" | "
|
|
11
|
+
variant?: "link" | "default" | "secondary" | "ghost" | "outline" | "destructive" | null | undefined;
|
|
12
12
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
13
13
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
14
14
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Standard UI component library for Object UI, built with Shadcn UI + Tailwind CSS",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"./style.css": "./dist/index.css"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@objectstack/spec": "^
|
|
29
|
+
"@objectstack/spec": "^18.0.0",
|
|
30
30
|
"@radix-ui/react-accordion": "^1.2.20",
|
|
31
31
|
"@radix-ui/react-alert-dialog": "^1.1.23",
|
|
32
32
|
"@radix-ui/react-aspect-ratio": "^1.1.15",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"tailwind-merge": "^3.6.0",
|
|
69
69
|
"tailwindcss-animate": "^1.0.7",
|
|
70
70
|
"vaul": "^1.1.2",
|
|
71
|
-
"@object-ui/core": "
|
|
72
|
-
"@object-ui/
|
|
73
|
-
"@object-ui/react-runtime": "
|
|
74
|
-
"@object-ui/
|
|
75
|
-
"@object-ui/sdui-parser": "
|
|
76
|
-
"@object-ui/types": "
|
|
71
|
+
"@object-ui/core": "18.0.0",
|
|
72
|
+
"@object-ui/react": "18.0.0",
|
|
73
|
+
"@object-ui/react-runtime": "18.0.0",
|
|
74
|
+
"@object-ui/i18n": "18.0.0",
|
|
75
|
+
"@object-ui/sdui-parser": "18.0.0",
|
|
76
|
+
"@object-ui/types": "18.0.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18.0.0 || ^19.0.0",
|