@teaui/preact 1.3.8 → 1.5.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/components/FontStyle.d.ts +12 -0
- package/.dist/components/FontStyle.js +35 -0
- package/.dist/components/FontStyle.js.map +1 -0
- package/.dist/components/TextReact.d.ts +2 -0
- package/.dist/components/TextReact.js +31 -25
- package/.dist/components/TextReact.js.map +1 -1
- package/.dist/components.d.ts +31 -8
- package/.dist/components.js +101 -118
- package/.dist/components.js.map +1 -1
- package/.dist/index.d.ts +2 -2
- package/.dist/index.js +2 -18
- package/.dist/index.js.map +1 -1
- package/.dist/preact.d.ts +10 -6
- package/.dist/preact.js +122 -73
- package/.dist/preact.js.map +1 -1
- package/README.md +185 -21
- package/package.json +6 -5
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface FontStyleValue {
|
|
2
|
+
bold: boolean;
|
|
3
|
+
italic: boolean;
|
|
4
|
+
underline: boolean;
|
|
5
|
+
strikethrough: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface FontStyleProps {
|
|
8
|
+
value: FontStyleValue;
|
|
9
|
+
onChange: (value: FontStyleValue) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function FontStyle({ value, onChange }: FontStyleProps): preact.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'preact/hooks';
|
|
3
|
+
import { bold, italic, underline, strikeout } from '@teaui/core';
|
|
4
|
+
import { ToggleGroup } from '../components.js';
|
|
5
|
+
const LABELS = [bold('B'), italic('I'), underline('U'), strikeout('S')];
|
|
6
|
+
const KEYS = [
|
|
7
|
+
'bold',
|
|
8
|
+
'italic',
|
|
9
|
+
'underline',
|
|
10
|
+
'strikethrough',
|
|
11
|
+
];
|
|
12
|
+
export function FontStyle({ value, onChange }) {
|
|
13
|
+
const selected = useMemo(() => {
|
|
14
|
+
const indices = [];
|
|
15
|
+
KEYS.forEach((key, i) => {
|
|
16
|
+
if (value[key])
|
|
17
|
+
indices.push(i);
|
|
18
|
+
});
|
|
19
|
+
return indices;
|
|
20
|
+
}, [value]);
|
|
21
|
+
const handleChange = useCallback((_index, newSelected) => {
|
|
22
|
+
const next = {
|
|
23
|
+
bold: false,
|
|
24
|
+
italic: false,
|
|
25
|
+
underline: false,
|
|
26
|
+
strikethrough: false,
|
|
27
|
+
};
|
|
28
|
+
for (const i of newSelected) {
|
|
29
|
+
next[KEYS[i]] = true;
|
|
30
|
+
}
|
|
31
|
+
onChange(next);
|
|
32
|
+
}, [onChange]);
|
|
33
|
+
return (_jsx(ToggleGroup, { titles: LABELS, selected: selected, multiple: true, onChange: handleChange }));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=FontStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontStyle.js","sourceRoot":"","sources":["../../lib/components/FontStyle.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAc5C,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;AACvE,MAAM,IAAI,GAA6B;IACrC,MAAM;IACN,QAAQ;IACR,WAAW;IACX,eAAe;CAChB,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAiB;IACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,OAAO,GAAa,EAAE,CAAA;QAC5B,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,IAAI,KAAK,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAChB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,MAAc,EAAE,WAAqB,EAAE,EAAE;QACxC,MAAM,IAAI,GAAmB;YAC3B,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,KAAK;YAChB,aAAa,EAAE,KAAK;SACrB,CAAA;QACD,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;QACtB,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAO,CACL,KAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,QACR,QAAQ,EAAE,YAAY,GACtB,CACH,CAAA;AACH,CAAC"}
|
|
@@ -67,6 +67,8 @@ type StyledTextProps = Omit<ProviderProps, 'alignment' | 'wrap' | 'font'>;
|
|
|
67
67
|
* ideally it would be supported.
|
|
68
68
|
*/
|
|
69
69
|
export declare class TextStyle extends TextProvider {
|
|
70
|
+
#private;
|
|
70
71
|
constructor(props: StyledTextProps);
|
|
72
|
+
update(props: StyledTextProps): void;
|
|
71
73
|
}
|
|
72
74
|
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextStyle = exports.TextProvider = exports.TextContainer = exports.TextLiteral = void 0;
|
|
4
|
-
const core_1 = require("@teaui/core");
|
|
1
|
+
import { Container, define, Rect, Size, Style, Text, View, } from '@teaui/core';
|
|
5
2
|
// yeah I don't care about this namespace I just needed something to attach the JSDoc to
|
|
6
3
|
const DEFAULTS = {
|
|
7
4
|
alignment: 'left',
|
|
@@ -12,12 +9,12 @@ const DEFAULTS = {
|
|
|
12
9
|
* Used in the React reconciler for literal text JSX elements. They don't have any
|
|
13
10
|
* props.
|
|
14
11
|
*/
|
|
15
|
-
class TextLiteral extends
|
|
12
|
+
export class TextLiteral extends View {
|
|
16
13
|
#text;
|
|
17
14
|
constructor(text) {
|
|
18
15
|
super({});
|
|
19
16
|
this.#text = text;
|
|
20
|
-
|
|
17
|
+
define(this, 'text', { enumerable: true });
|
|
21
18
|
}
|
|
22
19
|
update({ text, ...props }) {
|
|
23
20
|
super.update(props);
|
|
@@ -38,7 +35,7 @@ class TextLiteral extends core_1.View {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
if (style) {
|
|
41
|
-
return style.toSGR(
|
|
38
|
+
return style.toSGR(Style.NONE, this.#text);
|
|
42
39
|
}
|
|
43
40
|
return this.#text;
|
|
44
41
|
}
|
|
@@ -61,17 +58,16 @@ class TextLiteral extends core_1.View {
|
|
|
61
58
|
textContainer?.invalidateText();
|
|
62
59
|
}
|
|
63
60
|
naturalSize() {
|
|
64
|
-
return
|
|
61
|
+
return Size.zero;
|
|
65
62
|
}
|
|
66
63
|
render() { }
|
|
67
64
|
}
|
|
68
|
-
exports.TextLiteral = TextLiteral;
|
|
69
65
|
/**
|
|
70
66
|
* Subsequent TextLiteral nodes are grouped into a TextContainer, which handles the
|
|
71
67
|
* layout of child nodes. It gets its style, font, and alignment from the nearest
|
|
72
68
|
* parent TextProvider.
|
|
73
69
|
*/
|
|
74
|
-
class TextContainer extends
|
|
70
|
+
export class TextContainer extends Container {
|
|
75
71
|
#nodes = [];
|
|
76
72
|
constructor() {
|
|
77
73
|
super({});
|
|
@@ -89,7 +85,7 @@ class TextContainer extends core_1.Container {
|
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
removeChild(child) {
|
|
92
|
-
if (child instanceof TextLiteral) {
|
|
88
|
+
if (child instanceof TextLiteral || child instanceof TextStyle) {
|
|
93
89
|
child.parent = undefined;
|
|
94
90
|
}
|
|
95
91
|
const index = this.#nodes.indexOf(child);
|
|
@@ -108,15 +104,16 @@ class TextContainer extends core_1.Container {
|
|
|
108
104
|
let childIndex = 0;
|
|
109
105
|
for (const nextChild of this.#nodesToChildren()) {
|
|
110
106
|
const childView = this.children.at(childIndex);
|
|
111
|
-
if (nextChild instanceof
|
|
107
|
+
if (nextChild instanceof View) {
|
|
112
108
|
childIndex += 1;
|
|
113
109
|
}
|
|
114
110
|
else {
|
|
115
|
-
if (!(childView instanceof
|
|
111
|
+
if (!(childView instanceof Text)) {
|
|
116
112
|
this.#invalidateNodes();
|
|
117
113
|
return;
|
|
118
114
|
}
|
|
119
115
|
childView.text = nextChild;
|
|
116
|
+
childIndex += 1;
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
}
|
|
@@ -126,7 +123,7 @@ class TextContainer extends core_1.Container {
|
|
|
126
123
|
// remove and re-add those views.
|
|
127
124
|
super.removeAllChildren();
|
|
128
125
|
for (const child of this.#nodesToChildren()) {
|
|
129
|
-
if (child instanceof
|
|
126
|
+
if (child instanceof View) {
|
|
130
127
|
super.add(child);
|
|
131
128
|
}
|
|
132
129
|
else {
|
|
@@ -158,7 +155,7 @@ class TextContainer extends core_1.Container {
|
|
|
158
155
|
return children;
|
|
159
156
|
}
|
|
160
157
|
naturalSize(available) {
|
|
161
|
-
const size =
|
|
158
|
+
const size = Size.zero.mutableCopy();
|
|
162
159
|
const remaining = available.mutableCopy();
|
|
163
160
|
for (const child of this.children) {
|
|
164
161
|
const childSize = child.naturalSize(remaining);
|
|
@@ -178,7 +175,7 @@ class TextContainer extends core_1.Container {
|
|
|
178
175
|
const childSize = child.naturalSize(remaining).mutableCopy();
|
|
179
176
|
childSize.width = viewport.contentSize.width;
|
|
180
177
|
remaining.height -= childSize.height;
|
|
181
|
-
const childViewport = new
|
|
178
|
+
const childViewport = new Rect([0, y], childSize);
|
|
182
179
|
viewport.clipped(childViewport, inner => child.render(inner));
|
|
183
180
|
y += childSize.height;
|
|
184
181
|
}
|
|
@@ -195,7 +192,7 @@ class TextContainer extends core_1.Container {
|
|
|
195
192
|
if (textProvider) {
|
|
196
193
|
textProps = { ...textProps, ...textProvider.textProps };
|
|
197
194
|
}
|
|
198
|
-
return new
|
|
195
|
+
return new Text({
|
|
199
196
|
text,
|
|
200
197
|
...textProps,
|
|
201
198
|
});
|
|
@@ -212,7 +209,6 @@ class TextContainer extends core_1.Container {
|
|
|
212
209
|
});
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
|
-
exports.TextContainer = TextContainer;
|
|
216
212
|
/**
|
|
217
213
|
* Intended to contain a single TextContainer. Provides the styling that is used to
|
|
218
214
|
* create Text views.
|
|
@@ -220,8 +216,8 @@ exports.TextContainer = TextContainer;
|
|
|
220
216
|
* @example
|
|
221
217
|
* <Text align='left' bold>text</Text>
|
|
222
218
|
*/
|
|
223
|
-
class TextProvider extends
|
|
224
|
-
#style =
|
|
219
|
+
export class TextProvider extends Container {
|
|
220
|
+
#style = Style.NONE;
|
|
225
221
|
#font;
|
|
226
222
|
#alignment;
|
|
227
223
|
#wrap;
|
|
@@ -240,7 +236,7 @@ class TextProvider extends core_1.Container {
|
|
|
240
236
|
break;
|
|
241
237
|
}
|
|
242
238
|
}
|
|
243
|
-
return parentStyle ??
|
|
239
|
+
return parentStyle ?? Style.NONE;
|
|
244
240
|
}
|
|
245
241
|
get textProps() {
|
|
246
242
|
let parentProvider;
|
|
@@ -275,23 +271,33 @@ class TextProvider extends core_1.Container {
|
|
|
275
271
|
}
|
|
276
272
|
#update(props) {
|
|
277
273
|
const { style, alignment, wrap, font, ...styleProps } = props;
|
|
278
|
-
this.#style = new
|
|
274
|
+
this.#style = new Style(styleProps).merge(style);
|
|
279
275
|
this.#font = font;
|
|
280
276
|
this.#alignment = alignment ?? 'left';
|
|
281
277
|
this.#wrap = wrap ?? false;
|
|
282
278
|
}
|
|
283
279
|
}
|
|
284
|
-
exports.TextProvider = TextProvider;
|
|
285
280
|
/**
|
|
286
281
|
* Provides inline styles - doesn't support wrap or alignment.
|
|
287
282
|
*
|
|
288
283
|
* Also doesn't support 'font' because that's not encoded as an SGR code - but
|
|
289
284
|
* ideally it would be supported.
|
|
290
285
|
*/
|
|
291
|
-
class TextStyle extends TextProvider {
|
|
286
|
+
export class TextStyle extends TextProvider {
|
|
292
287
|
constructor(props) {
|
|
293
288
|
super(props);
|
|
294
289
|
}
|
|
290
|
+
update(props) {
|
|
291
|
+
super.update(props);
|
|
292
|
+
this.#invalidateTextContainer();
|
|
293
|
+
}
|
|
294
|
+
#invalidateTextContainer() {
|
|
295
|
+
for (let ancestorView = this.parent; Boolean(ancestorView); ancestorView = ancestorView && ancestorView.parent) {
|
|
296
|
+
if (ancestorView instanceof TextContainer) {
|
|
297
|
+
ancestorView.invalidateText();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
295
302
|
}
|
|
296
|
-
exports.TextStyle = TextStyle;
|
|
297
303
|
//# sourceMappingURL=TextReact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextReact.js","sourceRoot":"","sources":["../../lib/components/TextReact.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextReact.js","sourceRoot":"","sources":["../../lib/components/TextReact.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,MAAM,EAEN,IAAI,EAEJ,IAAI,EACJ,KAAK,EACL,IAAI,EAEJ,IAAI,GAEL,MAAM,aAAa,CAAA;AA8CpB,wFAAwF;AAExF,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,SAAS;CACP,CAAA;AAEV;;;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B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACnB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,MAAM,EAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,UAAU,EAAC,GAAG,KAAK,CAAA;QAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAChD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,UAAU,GAAG,SAAS,IAAI,MAAM,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,CAAA;IAC5B,CAAC;CACF;AAID;;;;;GAKG;AACH,MAAM,OAAO,SAAU,SAAQ,YAAY;IACzC,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED,MAAM,CAAC,KAAsB;QAC3B,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACnB,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACjC,CAAC;IAED,wBAAwB;QACtB,KACE,IAAI,YAAY,GAA0B,IAAI,CAAC,MAAM,EACrD,OAAO,CAAC,YAAY,CAAC,EACrB,YAAY,GAAG,YAAY,IAAI,YAAY,CAAC,MAAM,EAClD,CAAC;YACD,IAAI,YAAY,YAAY,aAAa,EAAE,CAAC;gBAC1C,YAAY,CAAC,cAAc,EAAE,CAAA;gBAC7B,OAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/.dist/components.d.ts
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Accordion as WrAccordion, Box as WrBox, Button as WrButton, Checkbox as WrCheckbox, Collapsible as WrCollapsible, CollapsibleText as WrCollapsibleText, ConsoleLog as WrConsoleLog, Digits as WrDigits, Drawer as WrDrawer, Stack as WrStack, Input as WrInput, Scrollable as WrScrollable, Separator as WrSeparator, Slider as WrSlider, Space as WrSpace, Tabs as WrTabs, ToggleGroup as WrToggleGroup, ViewProps } from '@teaui/core';
|
|
3
|
-
import { TextProvider, TextStyle } from './components/TextReact';
|
|
1
|
+
import type * as preact from 'preact';
|
|
2
|
+
import type { Accordion as WrAccordion, Box as WrBox, Button as WrButton, Checkbox as WrCheckbox, Collapsible as WrCollapsible, CollapsibleText as WrCollapsibleText, ConsoleLog as WrConsoleLog, Digits as WrDigits, Drawer as WrDrawer, HotKey as WrHotKey, Stack as WrStack, Input as WrInput, Progress as WrProgress, Scrollable as WrScrollable, Separator as WrSeparator, Slider as WrSlider, Space as WrSpace, Spinner as WrSpinner, Tabs as WrTabs, ToggleGroup as WrToggleGroup, ViewProps } from '@teaui/core';
|
|
3
|
+
import { TextProvider, TextStyle } from './components/TextReact.js';
|
|
4
|
+
export { FontStyle } from './components/FontStyle.js';
|
|
5
|
+
export type { FontStyleValue } from './components/FontStyle.js';
|
|
4
6
|
type Children = 'children' | 'child';
|
|
5
7
|
type TUIView<T extends abstract new (arg: any, ...args: any) => any, OmitProps extends keyof ConstructorParameters<T>[0] = Children> = Omit<NonNullable<ConstructorParameters<T>[0]>, OmitProps>;
|
|
6
8
|
type TUIContainer<T extends abstract new (arg: any, ...args: any) => any, ChildrenProps extends keyof NonNullable<ConstructorParameters<T>[0]> = Children> = TUIView<T, ChildrenProps> & {
|
|
7
|
-
[Key in ChildrenProps]?:
|
|
9
|
+
[Key in ChildrenProps]?: preact.ComponentChildren;
|
|
8
10
|
};
|
|
9
11
|
export type CheckboxProps = TUIView<typeof WrCheckbox>;
|
|
10
12
|
export type CollapsibleTextProps = TUIView<typeof WrCollapsibleText>;
|
|
11
13
|
export type ConsoleProps = TUIView<typeof WrConsoleLog>;
|
|
12
14
|
export type DigitsProps = TUIView<typeof WrDigits>;
|
|
15
|
+
export type DropdownProps = {
|
|
16
|
+
choices: [string, any][];
|
|
17
|
+
selected?: any;
|
|
18
|
+
onSelect?: (value: any) => void;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
title?: string;
|
|
21
|
+
theme?: string;
|
|
22
|
+
height?: number | 'shrink';
|
|
23
|
+
width?: number | 'shrink';
|
|
24
|
+
flex?: number;
|
|
25
|
+
};
|
|
13
26
|
export type HeaderProps = {
|
|
14
27
|
text?: string;
|
|
15
28
|
};
|
|
29
|
+
export type HotKeyProps = TUIView<typeof WrHotKey>;
|
|
16
30
|
export type InputProps = TUIView<typeof WrInput>;
|
|
31
|
+
export type ProgressProps = TUIView<typeof WrProgress>;
|
|
17
32
|
export type SeparatorProps = TUIView<typeof WrSeparator>;
|
|
18
33
|
export type SliderProps = TUIView<typeof WrSlider>;
|
|
19
34
|
export type SpaceProps = TUIView<typeof WrSpace>;
|
|
35
|
+
export type SpinnerProps = TUIView<typeof WrSpinner>;
|
|
20
36
|
export type ToggleGroupProps = TUIView<typeof WrToggleGroup>;
|
|
21
37
|
export type BoxProps = TUIContainer<typeof WrBox>;
|
|
22
38
|
export type ButtonProps = TUIContainer<typeof WrButton>;
|
|
@@ -30,7 +46,7 @@ export type AccordionSectionProps = TUIContainer<typeof WrAccordion.Section>;
|
|
|
30
46
|
export type DrawerProps = TUIContainer<typeof WrDrawer, 'content' | 'drawer' | 'children'>;
|
|
31
47
|
export type TabsProps = TUIContainer<typeof WrTabs>;
|
|
32
48
|
export type TabsSectionProps = TUIContainer<typeof WrTabs.Section>;
|
|
33
|
-
declare module '
|
|
49
|
+
declare module 'preact' {
|
|
34
50
|
namespace JSX {
|
|
35
51
|
interface IntrinsicElements {
|
|
36
52
|
'tui-br': {};
|
|
@@ -38,6 +54,8 @@ declare module 'react' {
|
|
|
38
54
|
'tui-collapsible-text': CollapsibleTextProps;
|
|
39
55
|
'tui-console': ConsoleProps;
|
|
40
56
|
'tui-digits': DigitsProps;
|
|
57
|
+
'tui-dropdown': DropdownProps;
|
|
58
|
+
'tui-hotkey': HotKeyProps;
|
|
41
59
|
'tui-h1': HeaderProps;
|
|
42
60
|
'tui-h2': HeaderProps;
|
|
43
61
|
'tui-h3': HeaderProps;
|
|
@@ -45,9 +63,11 @@ declare module 'react' {
|
|
|
45
63
|
'tui-h5': HeaderProps;
|
|
46
64
|
'tui-h6': HeaderProps;
|
|
47
65
|
'tui-input': InputProps;
|
|
66
|
+
'tui-progress': ProgressProps;
|
|
48
67
|
'tui-separator': SeparatorProps;
|
|
49
68
|
'tui-slider': SliderProps;
|
|
50
69
|
'tui-space': SpaceProps;
|
|
70
|
+
'tui-spinner': SpinnerProps;
|
|
51
71
|
'tui-toggle-group': ToggleGroupProps;
|
|
52
72
|
'tui-tree': ViewProps;
|
|
53
73
|
'tui-box': BoxProps;
|
|
@@ -70,6 +90,8 @@ export declare function Checkbox(reactProps: CheckboxProps): preact.JSX.Element;
|
|
|
70
90
|
export declare function CollapsibleText(reactProps: CollapsibleTextProps): preact.JSX.Element;
|
|
71
91
|
export declare function ConsoleLog(reactProps: ConsoleProps): preact.JSX.Element;
|
|
72
92
|
export declare function Digits(reactProps: DigitsProps): preact.JSX.Element;
|
|
93
|
+
export declare function Dropdown(reactProps: DropdownProps): preact.JSX.Element;
|
|
94
|
+
export declare function HotKey(reactProps: HotKeyProps): preact.JSX.Element;
|
|
73
95
|
export declare function H1(reactProps: HeaderProps): preact.JSX.Element;
|
|
74
96
|
export declare function H2(reactProps: HeaderProps): preact.JSX.Element;
|
|
75
97
|
export declare function H3(reactProps: HeaderProps): preact.JSX.Element;
|
|
@@ -77,6 +99,7 @@ export declare function H4(reactProps: HeaderProps): preact.JSX.Element;
|
|
|
77
99
|
export declare function H5(reactProps: HeaderProps): preact.JSX.Element;
|
|
78
100
|
export declare function H6(reactProps: HeaderProps): preact.JSX.Element;
|
|
79
101
|
export declare function Input(reactProps: InputProps): preact.JSX.Element;
|
|
102
|
+
export declare function Progress(reactProps: ProgressProps): preact.JSX.Element;
|
|
80
103
|
interface Separator {
|
|
81
104
|
(reactProps: SeparatorProps): preact.JSX.Element;
|
|
82
105
|
horizontal(reactProps: Omit<SeparatorProps, 'direction'>): preact.JSX.Element;
|
|
@@ -90,12 +113,13 @@ interface Slider {
|
|
|
90
113
|
}
|
|
91
114
|
export declare const Slider: Slider;
|
|
92
115
|
export declare function Space(reactProps: SpaceProps): preact.JSX.Element;
|
|
116
|
+
export declare function Spinner(reactProps: SpinnerProps): preact.JSX.Element;
|
|
93
117
|
export declare function ToggleGroup(reactProps: ToggleGroupProps): preact.JSX.Element;
|
|
94
118
|
interface TreeProps<T> extends ViewProps {
|
|
95
119
|
data: T[];
|
|
96
|
-
render: (datum: T) =>
|
|
120
|
+
render: (datum: T) => preact.ComponentChildren;
|
|
97
121
|
getChildren?: (datum: T) => T[] | undefined;
|
|
98
|
-
title:
|
|
122
|
+
title: preact.ComponentChildren | string;
|
|
99
123
|
}
|
|
100
124
|
export declare function Tree<T>(reactProps: TreeProps<T>): preact.JSX.Element;
|
|
101
125
|
export declare function Box(reactProps: BoxProps): preact.JSX.Element;
|
|
@@ -140,4 +164,3 @@ interface Tabs {
|
|
|
140
164
|
Section(reactProps: Omit<TabsSectionProps, 'direction'>): preact.JSX.Element;
|
|
141
165
|
}
|
|
142
166
|
export declare const Tabs: Tabs;
|
|
143
|
-
export {};
|