@opencxh/ui-kit 3.137.8 → 3.137.10
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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2053 -1887
- package/dist/index.js.map +1 -1
- package/dist/src/content/SettingsPage.d.ts +78 -0
- package/dist/src/content/tableColumns.d.ts +67 -0
- package/dist/src/feedback/Badge.d.ts +7 -1
- package/dist/src/feedback/ContentLoading.d.ts +18 -10
- package/dist/src/forms/Form.d.ts +6 -0
- package/dist/src/index.d.ts +3 -1
- package/package.json +2 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { ContentLoadingShape } from '../feedback/ContentLoading';
|
|
3
|
+
import { PageHeaderAction } from './PageHeader';
|
|
4
|
+
/**
|
|
5
|
+
* What a panel adds to the frame it is rendered in: the record it drilled into,
|
|
6
|
+
* and the way back out. The settings frame already draws the app breadcrumb and
|
|
7
|
+
* the page title, so a panel that repeats them produces the double bar this
|
|
8
|
+
* component exists to remove.
|
|
9
|
+
*/
|
|
10
|
+
export interface SettingsTrailEntry {
|
|
11
|
+
/** Appended to the frame breadcrumb; usually the detail record's name. */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** When set, the frame renders the back affordance and calls this. */
|
|
14
|
+
onBack?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface SettingsFrameApi {
|
|
17
|
+
/**
|
|
18
|
+
* `ownerId` scopes the write to one panel instance. Stable across renders,
|
|
19
|
+
* so it is safe to use as a hook dependency.
|
|
20
|
+
*/
|
|
21
|
+
setTrail: (ownerId: string, entry: SettingsTrailEntry | null) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Provided by the settings frame (the shell overlay), consumed by panels that
|
|
25
|
+
* are federated remotes. Safe across the module-federation boundary because
|
|
26
|
+
* React and `@opencxh/ui-kit` are both shared singletons — a second copy of
|
|
27
|
+
* either would hand panels a different context object and the trail would
|
|
28
|
+
* silently never arrive.
|
|
29
|
+
*/
|
|
30
|
+
export declare const SettingsFrameProvider: React.Provider<SettingsFrameApi | null>;
|
|
31
|
+
export declare function useSettingsFrame(): SettingsFrameApi | null;
|
|
32
|
+
/**
|
|
33
|
+
* State half of the frame contract, for the host to own. Returns the current
|
|
34
|
+
* trail plus the stable api to hand down through `SettingsFrameProvider`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useSettingsFrameHost(): {
|
|
37
|
+
trail: SettingsTrailEntry | null;
|
|
38
|
+
api: SettingsFrameApi;
|
|
39
|
+
};
|
|
40
|
+
declare const paddingClasses: {
|
|
41
|
+
readonly none: "";
|
|
42
|
+
readonly sm: "px-3 py-3";
|
|
43
|
+
readonly md: "px-5 py-4";
|
|
44
|
+
};
|
|
45
|
+
export interface SettingsPageProps {
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Primary actions, right-aligned in the sticky footer — the Cancel/Save pair
|
|
49
|
+
* of a form. Omit entirely on a read-only or list page and no footer renders.
|
|
50
|
+
*/
|
|
51
|
+
actions?: PageHeaderAction[];
|
|
52
|
+
/** Left-aligned footer actions, set apart from the primary pair (e.g. Delete). */
|
|
53
|
+
secondaryActions?: PageHeaderAction[];
|
|
54
|
+
/** Renders the back affordance in the frame header (or inline when unframed). */
|
|
55
|
+
onBack?: () => void;
|
|
56
|
+
backLabel?: string;
|
|
57
|
+
/** The record's own name, appended to the frame breadcrumb. */
|
|
58
|
+
title?: string;
|
|
59
|
+
/** Swaps the body for a skeleton while keeping the footer in place. */
|
|
60
|
+
loading?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* What the body is about to render. A settings panel is nearly always a form
|
|
63
|
+
* or a table, and saying which keeps the placeholder from announcing a
|
|
64
|
+
* heading and two paragraphs that never arrive.
|
|
65
|
+
*/
|
|
66
|
+
loadingShape?: ContentLoadingShape;
|
|
67
|
+
padding?: keyof typeof paddingClasses;
|
|
68
|
+
className?: string;
|
|
69
|
+
contentClassName?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The body of one settings panel. Owns the three things every panel used to
|
|
73
|
+
* re-invent: the scroll container, the content padding, and where the actions
|
|
74
|
+
* live. Title, description and breadcrumb belong to the frame — pass `title`
|
|
75
|
+
* and `onBack` to extend them rather than drawing a second header here.
|
|
76
|
+
*/
|
|
77
|
+
export declare const SettingsPage: React.FC<SettingsPageProps>;
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { BadgeProps } from '../feedback/Badge';
|
|
2
|
+
import { TableColumn } from './Table';
|
|
3
|
+
/**
|
|
4
|
+
* Column builders for the three things table configs kept getting wrong, each
|
|
5
|
+
* in the same way across apps: a state rendered as prose, a stored code shown
|
|
6
|
+
* raw, and an id shown instead of the name it points at.
|
|
7
|
+
*
|
|
8
|
+
* They all keep the *label* in `accessor` and render only the decoration in
|
|
9
|
+
* `cell`, because `Table` searches and sorts on the accessor value. Putting the
|
|
10
|
+
* readable text there means a search for "Active" or for a team's name matches
|
|
11
|
+
* what the row actually shows — which is exactly what a raw `enabled` boolean
|
|
12
|
+
* or a bare `teamId` used to break.
|
|
13
|
+
*/
|
|
14
|
+
export interface BadgeColumnConfig<T, V = unknown> {
|
|
15
|
+
id: string;
|
|
16
|
+
header: string;
|
|
17
|
+
accessor: (row: T) => V;
|
|
18
|
+
/** The text in the badge — and the text this column is searched on. */
|
|
19
|
+
label: (value: V, row: T) => string;
|
|
20
|
+
/** Defaults to `default`; give states their own tone (success/error/…). */
|
|
21
|
+
tone?: (value: V, row: T) => BadgeProps["variant"];
|
|
22
|
+
/** Return false to render nothing at all for this row. */
|
|
23
|
+
visible?: (value: V, row: T) => boolean;
|
|
24
|
+
width?: string | number;
|
|
25
|
+
sortable?: boolean;
|
|
26
|
+
align?: TableColumn<T>["align"];
|
|
27
|
+
}
|
|
28
|
+
/** A value that is a state rather than prose — render it as a pill. */
|
|
29
|
+
export declare function badgeColumn<T, V = unknown>(config: BadgeColumnConfig<T, V>): TableColumn<T>;
|
|
30
|
+
export interface BooleanBadgeColumnConfig<T> {
|
|
31
|
+
id: string;
|
|
32
|
+
header: string;
|
|
33
|
+
accessor: (row: T) => boolean | undefined;
|
|
34
|
+
onLabel: string;
|
|
35
|
+
offLabel: string;
|
|
36
|
+
/** Defaults to success/secondary — on reads as healthy, off as merely quiet. */
|
|
37
|
+
onTone?: BadgeProps["variant"];
|
|
38
|
+
offTone?: BadgeProps["variant"];
|
|
39
|
+
width?: string | number;
|
|
40
|
+
sortable?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** The on/off case of `badgeColumn`, which is most of them. */
|
|
43
|
+
export declare function booleanBadgeColumn<T>(config: BooleanBadgeColumnConfig<T>): TableColumn<T>;
|
|
44
|
+
export interface LabelsColumnConfig<T> {
|
|
45
|
+
id: string;
|
|
46
|
+
header: string;
|
|
47
|
+
/** One code, a list of them, or nothing. */
|
|
48
|
+
accessor: (row: T) => string | string[] | undefined | null;
|
|
49
|
+
/**
|
|
50
|
+
* Code to readable text. Return `undefined` to fall back to the code itself,
|
|
51
|
+
* so an unknown value still shows something instead of vanishing.
|
|
52
|
+
*/
|
|
53
|
+
label: (code: string) => string | undefined;
|
|
54
|
+
/** Shown when there is nothing at all. Defaults to an em dash. */
|
|
55
|
+
empty?: string;
|
|
56
|
+
separator?: string;
|
|
57
|
+
width?: string | number;
|
|
58
|
+
searchable?: boolean;
|
|
59
|
+
sortable?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stored codes rendered as the words the user picked them by. Covers both
|
|
63
|
+
* localising an enum (`interactions:created` → "Interaction created") and
|
|
64
|
+
* resolving a foreign key (a `teamId` → that team's name — pass a lookup as
|
|
65
|
+
* `label`), because from the table's side those are the same problem.
|
|
66
|
+
*/
|
|
67
|
+
export declare function labelsColumn<T>(config: LabelsColumnConfig<T>): TableColumn<T>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `color` is deliberately omitted from the inherited HTML attributes. It is a
|
|
4
|
+
* legacy HTML attribute, so `<Badge color="success">` used to type-check while
|
|
5
|
+
* doing nothing at all — the badge silently rendered as `default`. Omitting it
|
|
6
|
+
* turns that mistake into a compile error pointing at `variant`.
|
|
7
|
+
*/
|
|
8
|
+
export interface BadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'> {
|
|
3
9
|
/**
|
|
4
10
|
* The visual variant of the badge
|
|
5
11
|
*/
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What is about to appear here. A placeholder only does its job if it has the
|
|
4
|
+
* geometry of the thing it stands in for: the default `text` shape under a form
|
|
5
|
+
* or a list announces a heading and two paragraphs, and the real content then
|
|
6
|
+
* shoves everything sideways when it lands.
|
|
7
|
+
*/
|
|
8
|
+
export type ContentLoadingShape = "text" | "table" | "list" | "form" | "menu" | "cards";
|
|
2
9
|
export interface ContentLoadingProps {
|
|
3
10
|
/**
|
|
4
11
|
* `page` (default) fills the route with its own `<main>` shell and padding.
|
|
@@ -6,21 +13,22 @@ export interface ContentLoadingProps {
|
|
|
6
13
|
* card or scroll container without nesting a second `<main>` landmark.
|
|
7
14
|
*/
|
|
8
15
|
variant?: "page" | "inline";
|
|
16
|
+
/** The shape of what is coming. Defaults to `text`. */
|
|
17
|
+
shape?: ContentLoadingShape;
|
|
18
|
+
/** Rows/items/fields/cards to draw, depending on `shape`. */
|
|
19
|
+
rows?: number;
|
|
20
|
+
/** Columns, for `table` and `cards`. */
|
|
21
|
+
columns?: number;
|
|
9
22
|
/**
|
|
10
23
|
* Optional custom skeleton content (overrides default)
|
|
11
24
|
*/
|
|
12
25
|
children?: ReactNode;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
26
|
+
className?: string;
|
|
27
|
+
/** @deprecated Pass `shape="table"`. */
|
|
16
28
|
showTableSkeleton?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Number of table columns (default: 6)
|
|
19
|
-
*/
|
|
29
|
+
/** @deprecated Pass `columns`. */
|
|
20
30
|
tableColumns?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Number of table rows (default: 8)
|
|
23
|
-
*/
|
|
31
|
+
/** @deprecated Pass `rows`. */
|
|
24
32
|
tableRows?: number;
|
|
25
33
|
}
|
|
26
|
-
export declare function ContentLoading({ variant, children, showTableSkeleton, tableColumns, tableRows, }: ContentLoadingProps): import("react").JSX.Element;
|
|
34
|
+
export declare function ContentLoading({ variant, shape, rows, columns, children, className, showTableSkeleton, tableColumns, tableRows, }: ContentLoadingProps): import("react").JSX.Element;
|
package/dist/src/forms/Form.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export interface FormGroupItem<T = any> {
|
|
|
59
59
|
width?: string | number;
|
|
60
60
|
/** Placeholder text */
|
|
61
61
|
placeholder?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Visible rows for `textarea`. Defaults to 4, which is right for a note and
|
|
64
|
+
* far too small for a field that holds an instruction someone actually reads
|
|
65
|
+
* back while editing (a system prompt).
|
|
66
|
+
*/
|
|
67
|
+
rows?: number;
|
|
62
68
|
/** Autocomplete attribute */
|
|
63
69
|
autocomplete?: string;
|
|
64
70
|
/** Options for select/radio/checkbox types */
|
package/dist/src/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export { ConfirmDialog, type ConfirmDialogProps } from './overlays/ConfirmDialog
|
|
|
25
25
|
export { Modal, type ModalProps } from './overlays/Modal';
|
|
26
26
|
export { Popover, type PopoverProps } from './overlays/Popover';
|
|
27
27
|
export { Badge, type BadgeProps } from './feedback/Badge';
|
|
28
|
-
export { ContentLoading } from './feedback/ContentLoading';
|
|
28
|
+
export { ContentLoading, type ContentLoadingProps, type ContentLoadingShape } from './feedback/ContentLoading';
|
|
29
29
|
export { EmptyState, type EmptyStateProps } from './feedback/EmptyState';
|
|
30
30
|
export { Kbd, type KbdProps } from './feedback/Kbd';
|
|
31
31
|
export { ProgressBar, type ProgressBarProps } from './feedback/ProgressBar';
|
|
@@ -46,9 +46,11 @@ export { PageToolbar, PageToolbarActions, type PageToolbarActionsProps, type Pag
|
|
|
46
46
|
export { RichText, type RichTextProps } from './content/RichText';
|
|
47
47
|
export { SectionCaption, type SectionCaptionProps } from './content/SectionCaption';
|
|
48
48
|
export { SectionDivider, type SectionDividerProps } from './content/SectionDivider';
|
|
49
|
+
export { SettingsFrameProvider, SettingsPage, useSettingsFrame, useSettingsFrameHost, type SettingsFrameApi, type SettingsPageProps, type SettingsTrailEntry } from './content/SettingsPage';
|
|
49
50
|
export { SettingsRow, SettingsSection, type SettingsRowProps, type SettingsSectionProps } from './content/SettingsRow';
|
|
50
51
|
export { SourceChip, type SourceChipProps } from './content/SourceChip';
|
|
51
52
|
export { Table, dateFilterHandler, selectFilterHandler, type TableAction, type TableColumn, type TableFilter, type TableProps } from './content/Table';
|
|
53
|
+
export { badgeColumn, booleanBadgeColumn, labelsColumn, type BadgeColumnConfig, type BooleanBadgeColumnConfig, type LabelsColumnConfig } from './content/tableColumns';
|
|
52
54
|
export { View, type ViewGroup, type ViewProps } from './content/View';
|
|
53
55
|
export { SidebarMenu, type MenuItem, type MenuItemAction } from './navigation/Sidebar';
|
|
54
56
|
export { TabBar, Tabs, type TabItem, type TabsProps } from './navigation/Tabs';
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencxh/ui-kit",
|
|
3
|
-
"version": "3.137.
|
|
3
|
+
"version": "3.137.10",
|
|
4
4
|
"description": "Theme-aware UI component library for OpenCXH platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"source": "./src/index.ts",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"import": "./dist/index.js",
|
|
10
11
|
"require": "./dist/index.cjs"
|