@umriss-ui/dashboard 0.0.0-stage → 0.40.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/CHANGELOG.md +28 -0
- package/LICENSE +20 -0
- package/README.md +100 -2
- package/dist/dashboard.css +1 -0
- package/dist/dashboard.js +426 -0
- package/dist/index.d.ts +147 -0
- package/docs/llms-full.md +964 -0
- package/package.json +76 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** What `useDashboard` takes. */
|
|
5
|
+
export declare interface DashboardOptions {
|
|
6
|
+
/** The arrangement the application gives a reader who has none of their own. */
|
|
7
|
+
defaultView: DashboardView;
|
|
8
|
+
/** The reader's kept arrangement, read once when the hook first runs; a
|
|
9
|
+
different value on a later render is ignored, as React ignores a changed
|
|
10
|
+
`defaultValue`. To go to another, call `setView`.
|
|
11
|
+
@default the `defaultView` */
|
|
12
|
+
initialView?: DashboardView;
|
|
13
|
+
/** Whether the reader may edit. Without it no bar is drawn and the mode cannot be entered.
|
|
14
|
+
@default true */
|
|
15
|
+
allowEdit?: boolean;
|
|
16
|
+
/** Called once per "Done" that changed something, with the whole arrangement. Not called by `setView`. */
|
|
17
|
+
onViewChange?: (view: DashboardView) => void;
|
|
18
|
+
/** Called with `true` when a draft opens and with `false` when it closes - to warn before navigation. */
|
|
19
|
+
onDraftChange?: (open: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** What `useDashboard` hands back. */
|
|
23
|
+
export declare interface DashboardParts {
|
|
24
|
+
/** The dashboard. One per `useDashboard`. */
|
|
25
|
+
Dashboard: (props: DashboardProps) => ReactNode;
|
|
26
|
+
/** Declares a widget type inside `Dashboard`. */
|
|
27
|
+
WidgetType: typeof WidgetType;
|
|
28
|
+
/** The arrangement in view: the draft while the mode is on. */
|
|
29
|
+
view: DashboardView;
|
|
30
|
+
/** Goes to a whole arrangement. Not reported. */
|
|
31
|
+
setView: (view: DashboardView) => void;
|
|
32
|
+
/** Whether the editing mode is on. */
|
|
33
|
+
editing: boolean;
|
|
34
|
+
/** Enters the editing mode. Does nothing where editing is not allowed. */
|
|
35
|
+
edit: () => void;
|
|
36
|
+
/** Leaves the mode, keeps the changes and reports them once if there are any. */
|
|
37
|
+
done: () => void;
|
|
38
|
+
/** Opens the catalogue. Does nothing outside the editing mode. */
|
|
39
|
+
catalogue: () => void;
|
|
40
|
+
/** Leaves the mode and puts the arrangement back as it was before `edit`. */
|
|
41
|
+
cancel: () => void;
|
|
42
|
+
/** Goes one step back in the draft. Does nothing at the first. */
|
|
43
|
+
undo: () => void;
|
|
44
|
+
/** Goes one step forward again. Does nothing at the last. */
|
|
45
|
+
redo: () => void;
|
|
46
|
+
/** Steps to the `defaultView`; `undo` brings the arrangement back. */
|
|
47
|
+
reset: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The props of `Dashboard`. */
|
|
51
|
+
export declare interface DashboardProps extends HTMLAttributes<HTMLDivElement> {
|
|
52
|
+
/** The `WidgetType`s of this dashboard. */
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
/** The `name`s of the widget types the catalogue lists.
|
|
55
|
+
@default every declared type */
|
|
56
|
+
catalogue?: ReadonlyArray<string>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The arrangement of a dashboard: which widgets, in what order, at which
|
|
60
|
+
sizes, with which options. An object, so that more can join it later. */
|
|
61
|
+
export declare interface DashboardView {
|
|
62
|
+
/** The widgets, in the order they are drawn and read. */
|
|
63
|
+
widgets: ReadonlyArray<DashboardWidget>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** One widget in a view. */
|
|
67
|
+
export declare interface DashboardWidget {
|
|
68
|
+
/** Unique within the view. */
|
|
69
|
+
id: string;
|
|
70
|
+
/** The `name` of the widget type it is an instance of. */
|
|
71
|
+
type: string;
|
|
72
|
+
/** One of the sizes its type offers. */
|
|
73
|
+
size: WidgetSize;
|
|
74
|
+
/** The type's own options, typed through the hook. */
|
|
75
|
+
options: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The options of the heading widget type. */
|
|
79
|
+
export declare interface HeadingOptions {
|
|
80
|
+
/** The title across the full width. */
|
|
81
|
+
text: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The built-in heading widget type, to put inside `Dashboard` when the
|
|
85
|
+
application wants readers to divide their dashboard: one size, `full`, one
|
|
86
|
+
row, its text as its options, drawn as a title without a card. */
|
|
87
|
+
export declare function HeadingType(): null;
|
|
88
|
+
|
|
89
|
+
/** The room a size takes on the twelve columns, in columns and rows. */
|
|
90
|
+
export declare interface SizeSpan {
|
|
91
|
+
/** Columns of twelve. */
|
|
92
|
+
columns: number;
|
|
93
|
+
/** Rows of the fixed row unit. */
|
|
94
|
+
rows: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Declares a dashboard: hands back `Dashboard`, `WidgetType`, the view in
|
|
98
|
+
view, `setView` and the editing actions. */
|
|
99
|
+
export declare function useDashboard({ defaultView, initialView, allowEdit, onViewChange, onDraftChange }: DashboardOptions): DashboardParts;
|
|
100
|
+
|
|
101
|
+
/** What a widget's content is told. */
|
|
102
|
+
export declare interface WidgetContent<Options> {
|
|
103
|
+
/** The size the widget stands at. */
|
|
104
|
+
size: WidgetSize;
|
|
105
|
+
/** The widget's options. */
|
|
106
|
+
options: Options;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** What a type's form is given. */
|
|
110
|
+
export declare interface WidgetFormProps<Options> {
|
|
111
|
+
/** The widget's current options. */
|
|
112
|
+
options: Options;
|
|
113
|
+
/** Replaces the options; one step of the draft. */
|
|
114
|
+
change: (options: Options) => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The closed set of names a widget's size comes from. A widget type offers a
|
|
118
|
+
subset of them. */
|
|
119
|
+
export declare type WidgetSize = "small" | "medium" | "wide" | "tall" | "large" | "full";
|
|
120
|
+
|
|
121
|
+
/** Declares one widget type inside a `Dashboard`. It draws nothing itself: the
|
|
122
|
+
dashboard reads its props. The options type is inferred from `defaultOptions`. */
|
|
123
|
+
export declare function WidgetType<Options>(props: WidgetTypeProps<Options>): null;
|
|
124
|
+
|
|
125
|
+
/** The props of `WidgetType`. */
|
|
126
|
+
export declare interface WidgetTypeProps<Options> {
|
|
127
|
+
/** The name a view refers to this type by. Unique within the dashboard. */
|
|
128
|
+
name: string;
|
|
129
|
+
/** The type's name for a reader, and the title of its frame unless `title` says otherwise. */
|
|
130
|
+
label: string;
|
|
131
|
+
/** One sentence on what the type shows. */
|
|
132
|
+
sentence: string;
|
|
133
|
+
/** The sizes the type offers, each with the columns (of twelve) and rows it takes. */
|
|
134
|
+
sizes: Partial<Record<WidgetSize, SizeSpan>>;
|
|
135
|
+
/** The size a new widget of this type starts at. One of `sizes`. */
|
|
136
|
+
start: WidgetSize;
|
|
137
|
+
/** The options a new widget starts with. Their type is the options type of `title` and of the content. */
|
|
138
|
+
defaultOptions: Options;
|
|
139
|
+
/** The title of a frame as a function of its options; the `label` without it. */
|
|
140
|
+
title?: (options: NoInfer<Options>) => string;
|
|
141
|
+
/** The form for the options, opened from the widget's menu. Without it the menu has no options entry. */
|
|
142
|
+
form?: (props: WidgetFormProps<NoInfer<Options>>) => ReactNode;
|
|
143
|
+
/** The content, as a function of the size and the options. */
|
|
144
|
+
children: (content: WidgetContent<NoInfer<Options>>) => ReactNode;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { }
|