tosijs-ui 1.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/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/ab-test.d.ts +14 -0
- package/dist/ab-test.js +116 -0
- package/dist/babylon-3d.d.ts +53 -0
- package/dist/babylon-3d.js +292 -0
- package/dist/bodymovin-player.d.ts +32 -0
- package/dist/bodymovin-player.js +172 -0
- package/dist/bp-loader.d.ts +1 -0
- package/dist/bp-loader.js +26 -0
- package/dist/carousel.d.ts +113 -0
- package/dist/carousel.js +308 -0
- package/dist/code-editor.d.ts +27 -0
- package/dist/code-editor.js +102 -0
- package/dist/color-input.d.ts +41 -0
- package/dist/color-input.js +112 -0
- package/dist/data-table.d.ts +79 -0
- package/dist/data-table.js +774 -0
- package/dist/drag-and-drop.d.ts +2 -0
- package/dist/drag-and-drop.js +386 -0
- package/dist/editable-rect.d.ts +97 -0
- package/dist/editable-rect.js +450 -0
- package/dist/filter-builder.d.ts +64 -0
- package/dist/filter-builder.js +468 -0
- package/dist/float.d.ts +18 -0
- package/dist/float.js +170 -0
- package/dist/form.d.ts +68 -0
- package/dist/form.js +466 -0
- package/dist/gamepad.d.ts +34 -0
- package/dist/gamepad.js +115 -0
- package/dist/icon-data.d.ts +312 -0
- package/dist/icon-data.js +308 -0
- package/dist/icon-types.d.ts +7 -0
- package/dist/icon-types.js +1 -0
- package/dist/icons.d.ts +17 -0
- package/dist/icons.js +374 -0
- package/dist/iife.js +69 -0
- package/dist/iife.js.map +49 -0
- package/dist/index-iife.d.ts +1 -0
- package/dist/index-iife.js +4 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +47 -0
- package/dist/live-example.d.ts +63 -0
- package/dist/live-example.js +611 -0
- package/dist/localize.d.ts +46 -0
- package/dist/localize.js +381 -0
- package/dist/make-sorter.d.ts +3 -0
- package/dist/make-sorter.js +119 -0
- package/dist/make-sorter.test.d.ts +1 -0
- package/dist/make-sorter.test.js +48 -0
- package/dist/mapbox.d.ts +24 -0
- package/dist/mapbox.js +161 -0
- package/dist/markdown-viewer.d.ts +17 -0
- package/dist/markdown-viewer.js +173 -0
- package/dist/match-shortcut.d.ts +9 -0
- package/dist/match-shortcut.js +13 -0
- package/dist/match-shortcut.test.d.ts +1 -0
- package/dist/match-shortcut.test.js +194 -0
- package/dist/menu.d.ts +60 -0
- package/dist/menu.js +614 -0
- package/dist/notifications.d.ts +106 -0
- package/dist/notifications.js +308 -0
- package/dist/password-strength.d.ts +35 -0
- package/dist/password-strength.js +302 -0
- package/dist/playwright.config.d.ts +9 -0
- package/dist/playwright.config.js +73 -0
- package/dist/pop-float.d.ts +10 -0
- package/dist/pop-float.js +231 -0
- package/dist/rating.d.ts +62 -0
- package/dist/rating.js +192 -0
- package/dist/rich-text.d.ts +35 -0
- package/dist/rich-text.js +296 -0
- package/dist/segmented.d.ts +80 -0
- package/dist/segmented.js +298 -0
- package/dist/select.d.ts +43 -0
- package/dist/select.js +427 -0
- package/dist/side-nav.d.ts +36 -0
- package/dist/side-nav.js +106 -0
- package/dist/size-break.d.ts +18 -0
- package/dist/size-break.js +118 -0
- package/dist/sizer.d.ts +34 -0
- package/dist/sizer.js +92 -0
- package/dist/src/ab-test.d.ts +14 -0
- package/dist/src/babylon-3d.d.ts +53 -0
- package/dist/src/bodymovin-player.d.ts +32 -0
- package/dist/src/bp-loader.d.ts +0 -0
- package/dist/src/carousel.d.ts +113 -0
- package/dist/src/code-editor.d.ts +27 -0
- package/dist/src/color-input.d.ts +41 -0
- package/dist/src/data-table.d.ts +79 -0
- package/dist/src/drag-and-drop.d.ts +2 -0
- package/dist/src/editable-rect.d.ts +97 -0
- package/dist/src/filter-builder.d.ts +64 -0
- package/dist/src/float.d.ts +18 -0
- package/dist/src/form.d.ts +68 -0
- package/dist/src/gamepad.d.ts +34 -0
- package/dist/src/icon-data.d.ts +309 -0
- package/dist/src/icon-types.d.ts +7 -0
- package/dist/src/icons.d.ts +17 -0
- package/dist/src/index.d.ts +37 -0
- package/dist/src/live-example.d.ts +51 -0
- package/dist/src/localize.d.ts +30 -0
- package/dist/src/make-sorter.d.ts +3 -0
- package/dist/src/mapbox.d.ts +24 -0
- package/dist/src/markdown-viewer.d.ts +15 -0
- package/dist/src/match-shortcut.d.ts +9 -0
- package/dist/src/menu.d.ts +60 -0
- package/dist/src/notifications.d.ts +106 -0
- package/dist/src/password-strength.d.ts +35 -0
- package/dist/src/pop-float.d.ts +10 -0
- package/dist/src/rating.d.ts +62 -0
- package/dist/src/rich-text.d.ts +28 -0
- package/dist/src/segmented.d.ts +80 -0
- package/dist/src/select.d.ts +43 -0
- package/dist/src/side-nav.d.ts +36 -0
- package/dist/src/size-break.d.ts +18 -0
- package/dist/src/sizer.d.ts +34 -0
- package/dist/src/tab-selector.d.ts +91 -0
- package/dist/src/tag-list.d.ts +37 -0
- package/dist/src/track-drag.d.ts +5 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/via-tag.d.ts +2 -0
- package/dist/tab-selector.d.ts +91 -0
- package/dist/tab-selector.js +326 -0
- package/dist/tag-list.d.ts +37 -0
- package/dist/tag-list.js +375 -0
- package/dist/track-drag.d.ts +5 -0
- package/dist/track-drag.js +143 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/via-tag.d.ts +2 -0
- package/dist/via-tag.js +102 -0
- package/package.json +58 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*#
|
|
2
|
+
# code
|
|
3
|
+
|
|
4
|
+
An [ACE Editor](https://ace.c9.io/) wrapper.
|
|
5
|
+
|
|
6
|
+
Sometimes, it's nice to be able to just toss a code-editor in a web-page.
|
|
7
|
+
|
|
8
|
+
`<xin-code>`'s `value` is the code it contains. Its `mode` attribute sets the language, and you can further configure
|
|
9
|
+
the ACE editor instance via its `options` property.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<xin-code style="width: 100%; height: 100%" mode="css">
|
|
13
|
+
body {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
</xin-code>
|
|
17
|
+
```
|
|
18
|
+
*/
|
|
19
|
+
import { Component as WebComponent } from 'xinjs';
|
|
20
|
+
import { scriptTag } from './via-tag';
|
|
21
|
+
const ACE_BASE_URL = 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.2/';
|
|
22
|
+
const DEFAULT_THEME = 'ace/theme/tomorrow';
|
|
23
|
+
const makeCodeEditor = async (codeElement, mode = 'html', options = {}, theme = DEFAULT_THEME) => {
|
|
24
|
+
const { ace } = await scriptTag(`${ACE_BASE_URL}ace.min.js`);
|
|
25
|
+
ace.config.set('basePath', ACE_BASE_URL);
|
|
26
|
+
const editor = ace.edit(codeElement, {
|
|
27
|
+
mode: `ace/mode/${mode}`,
|
|
28
|
+
tabSize: 2,
|
|
29
|
+
useSoftTabs: true,
|
|
30
|
+
useWorker: false,
|
|
31
|
+
...options,
|
|
32
|
+
});
|
|
33
|
+
editor.setTheme(theme);
|
|
34
|
+
return editor;
|
|
35
|
+
};
|
|
36
|
+
export class CodeEditor extends WebComponent {
|
|
37
|
+
source = '';
|
|
38
|
+
get value() {
|
|
39
|
+
return this.editor === undefined ? this.source : this.editor.getValue();
|
|
40
|
+
}
|
|
41
|
+
set value(text) {
|
|
42
|
+
if (this.editor === undefined) {
|
|
43
|
+
this.source = text;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.editor.setValue(text);
|
|
47
|
+
this.editor.clearSelection();
|
|
48
|
+
this.editor.session.getUndoManager().reset();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
mode = 'javascript';
|
|
52
|
+
disabled = false;
|
|
53
|
+
role = 'code editor';
|
|
54
|
+
get editor() {
|
|
55
|
+
return this._editor;
|
|
56
|
+
}
|
|
57
|
+
_editor;
|
|
58
|
+
_editorPromise;
|
|
59
|
+
options = {};
|
|
60
|
+
theme = DEFAULT_THEME;
|
|
61
|
+
static styleSpec = {
|
|
62
|
+
':host': {
|
|
63
|
+
display: 'block',
|
|
64
|
+
position: 'relative',
|
|
65
|
+
width: '100%',
|
|
66
|
+
height: '100%',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
this.initAttributes('mode', 'theme', 'disabled');
|
|
72
|
+
}
|
|
73
|
+
onResize() {
|
|
74
|
+
if (this.editor !== undefined) {
|
|
75
|
+
this.editor.resize(true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
connectedCallback() {
|
|
79
|
+
super.connectedCallback();
|
|
80
|
+
if (this.source === '') {
|
|
81
|
+
this.value = this.textContent !== null ? this.textContent.trim() : '';
|
|
82
|
+
}
|
|
83
|
+
if (this._editorPromise === undefined) {
|
|
84
|
+
this._editorPromise = makeCodeEditor(this, this.mode, this.options, this.theme);
|
|
85
|
+
this._editorPromise.then((editor) => {
|
|
86
|
+
this._editor = editor;
|
|
87
|
+
editor.setValue(this.source, 1);
|
|
88
|
+
editor.clearSelection();
|
|
89
|
+
editor.session.getUndoManager().reset();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
super.render();
|
|
95
|
+
if (this._editorPromise !== undefined) {
|
|
96
|
+
this._editorPromise.then((editor) => editor.setReadOnly(this.disabled));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const codeEditor = CodeEditor.elementCreator({
|
|
101
|
+
tag: 'xin-code',
|
|
102
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Component, ElementCreator, Color, PartsMap } from 'tosijs';
|
|
2
|
+
interface ColorParts extends PartsMap {
|
|
3
|
+
rgb: HTMLInputElement;
|
|
4
|
+
alpha: HTMLInputElement;
|
|
5
|
+
css: HTMLInputElement;
|
|
6
|
+
}
|
|
7
|
+
declare class ColorInput extends Component<ColorParts> {
|
|
8
|
+
value: string;
|
|
9
|
+
color: Color;
|
|
10
|
+
static styleSpec: {
|
|
11
|
+
':host': {
|
|
12
|
+
_gap: number;
|
|
13
|
+
_swatchSize: number;
|
|
14
|
+
_cssWidth: number;
|
|
15
|
+
_alphaWidth: number;
|
|
16
|
+
display: string;
|
|
17
|
+
gap: string;
|
|
18
|
+
alignItems: string;
|
|
19
|
+
};
|
|
20
|
+
':host input[type="color"]': {
|
|
21
|
+
border: number;
|
|
22
|
+
width: string;
|
|
23
|
+
height: string;
|
|
24
|
+
background: string;
|
|
25
|
+
};
|
|
26
|
+
':host::part(alpha)': {
|
|
27
|
+
width: string;
|
|
28
|
+
};
|
|
29
|
+
':host::part(css)': {
|
|
30
|
+
width: string;
|
|
31
|
+
fontFamily: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
content: HTMLInputElement[];
|
|
35
|
+
private valueChanged;
|
|
36
|
+
update: (event: Event) => void;
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
render(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const colorInput: ElementCreator<ColorInput>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*#
|
|
2
|
+
|
|
3
|
+
# color input field
|
|
4
|
+
|
|
5
|
+
This is a color input field that supports opacity
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
const colorInput = preview.querySelector('xin-color')
|
|
9
|
+
const circle = preview.querySelector('div')
|
|
10
|
+
|
|
11
|
+
colorInput.addEventListener('change', () => {
|
|
12
|
+
console.log(colorInput.value)
|
|
13
|
+
circle.style.background = colorInput.value
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
```html
|
|
17
|
+
<xin-color value="red"></xin-color>
|
|
18
|
+
<div
|
|
19
|
+
style="
|
|
20
|
+
width: 200px;
|
|
21
|
+
height: 200px;
|
|
22
|
+
background: red;
|
|
23
|
+
border-radius: 100px;
|
|
24
|
+
"
|
|
25
|
+
></div>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<xin-css-var-editor element-selector="xin-color"></xin-css-var-editor>
|
|
30
|
+
*/
|
|
31
|
+
import { Component, elements, Color, vars, } from 'xinjs';
|
|
32
|
+
const { input } = elements;
|
|
33
|
+
const defaultColor = Color.fromCss('#8888');
|
|
34
|
+
class ColorInput extends Component {
|
|
35
|
+
value = defaultColor.rgba;
|
|
36
|
+
color = defaultColor;
|
|
37
|
+
static styleSpec = {
|
|
38
|
+
':host': {
|
|
39
|
+
_gap: 8,
|
|
40
|
+
_swatchSize: 32,
|
|
41
|
+
_cssWidth: 72,
|
|
42
|
+
_alphaWidth: 72,
|
|
43
|
+
display: 'inline-flex',
|
|
44
|
+
gap: vars.gap,
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
},
|
|
47
|
+
':host input[type="color"]': {
|
|
48
|
+
border: 0,
|
|
49
|
+
width: vars.swatchSize,
|
|
50
|
+
height: vars.swatchSize,
|
|
51
|
+
background: 'transparent',
|
|
52
|
+
},
|
|
53
|
+
':host::part(alpha)': {
|
|
54
|
+
width: vars.alphaWidth,
|
|
55
|
+
},
|
|
56
|
+
':host::part(css)': {
|
|
57
|
+
width: vars.cssWidth,
|
|
58
|
+
fontFamily: 'monospace',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
content = [
|
|
62
|
+
input({ title: 'base color', type: 'color', part: 'rgb' }),
|
|
63
|
+
input({
|
|
64
|
+
type: 'range',
|
|
65
|
+
title: 'opacity',
|
|
66
|
+
part: 'alpha',
|
|
67
|
+
min: 0,
|
|
68
|
+
max: 1,
|
|
69
|
+
step: 0.05,
|
|
70
|
+
}),
|
|
71
|
+
input({ title: 'css color spec', part: 'css' }),
|
|
72
|
+
];
|
|
73
|
+
valueChanged = false;
|
|
74
|
+
update = (event) => {
|
|
75
|
+
const { rgb, alpha, css } = this.parts;
|
|
76
|
+
if (event.type === 'input') {
|
|
77
|
+
this.color = Color.fromCss(rgb.value);
|
|
78
|
+
this.color.a = Number(alpha.value);
|
|
79
|
+
css.value = this.color.html;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.color = Color.fromCss(css.value);
|
|
83
|
+
rgb.value = this.color.html.substring(0, 7);
|
|
84
|
+
alpha.value = String(this.color.a);
|
|
85
|
+
}
|
|
86
|
+
rgb.style.opacity = String(this.color.a);
|
|
87
|
+
this.value = this.color.rgba;
|
|
88
|
+
this.valueChanged = true;
|
|
89
|
+
};
|
|
90
|
+
connectedCallback() {
|
|
91
|
+
super.connectedCallback();
|
|
92
|
+
const { rgb, alpha, css } = this.parts;
|
|
93
|
+
rgb.addEventListener('input', this.update);
|
|
94
|
+
alpha.addEventListener('input', this.update);
|
|
95
|
+
css.addEventListener('change', this.update);
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
if (this.valueChanged) {
|
|
99
|
+
this.valueChanged = false;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { rgb, alpha, css } = this.parts;
|
|
103
|
+
this.color = Color.fromCss(this.value);
|
|
104
|
+
rgb.value = this.color.html.substring(0, 7);
|
|
105
|
+
rgb.style.opacity = String(this.color.a);
|
|
106
|
+
alpha.value = String(this.color.a);
|
|
107
|
+
css.value = this.color.html;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export const colorInput = ColorInput.elementCreator({
|
|
111
|
+
tag: 'xin-color',
|
|
112
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Component as WebComponent, ElementCreator } from 'tosijs';
|
|
2
|
+
import { SortCallback } from './make-sorter';
|
|
3
|
+
export interface ColumnOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
prop: string;
|
|
6
|
+
width: number;
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
align?: string;
|
|
9
|
+
sort?: false | 'ascending' | 'descending';
|
|
10
|
+
headerCell?: (options: ColumnOptions) => HTMLElement;
|
|
11
|
+
dataCell?: (options: ColumnOptions) => HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
export interface TableData {
|
|
14
|
+
columns?: ColumnOptions[] | null;
|
|
15
|
+
array: any[];
|
|
16
|
+
filter?: ArrayFilter | null;
|
|
17
|
+
}
|
|
18
|
+
export type ArrayFilter = (array: any[]) => any[];
|
|
19
|
+
export type SelectCallback = (selected: any[]) => void;
|
|
20
|
+
export declare class DataTable extends WebComponent {
|
|
21
|
+
select: boolean;
|
|
22
|
+
multiple: boolean;
|
|
23
|
+
nosort: boolean;
|
|
24
|
+
nohide: boolean;
|
|
25
|
+
noreorder: boolean;
|
|
26
|
+
selectionChanged: SelectCallback;
|
|
27
|
+
localized: boolean;
|
|
28
|
+
private selectedKey;
|
|
29
|
+
private selectBinding;
|
|
30
|
+
pinnedTop: number;
|
|
31
|
+
pinnedBottom: number;
|
|
32
|
+
maxVisibleRows: number;
|
|
33
|
+
get value(): TableData;
|
|
34
|
+
set value(data: TableData);
|
|
35
|
+
private rowData;
|
|
36
|
+
private _array;
|
|
37
|
+
private _columns;
|
|
38
|
+
private _filter;
|
|
39
|
+
charWidth: number;
|
|
40
|
+
rowHeight: number;
|
|
41
|
+
minColumnWidth: number;
|
|
42
|
+
get virtual(): {
|
|
43
|
+
height: number;
|
|
44
|
+
} | undefined;
|
|
45
|
+
constructor();
|
|
46
|
+
get array(): any[];
|
|
47
|
+
set array(newArray: any[]);
|
|
48
|
+
get filter(): ArrayFilter;
|
|
49
|
+
set filter(filterFunc: ArrayFilter);
|
|
50
|
+
get sort(): SortCallback | undefined;
|
|
51
|
+
set sort(sortFunc: ArrayFilter);
|
|
52
|
+
get columns(): ColumnOptions[];
|
|
53
|
+
set columns(newColumns: ColumnOptions[]);
|
|
54
|
+
get visibleColumns(): ColumnOptions[];
|
|
55
|
+
content: null;
|
|
56
|
+
getColumn(event: any): ColumnOptions | undefined;
|
|
57
|
+
private setCursor;
|
|
58
|
+
private resizeColumn;
|
|
59
|
+
selectRow(row: any, select?: boolean): void;
|
|
60
|
+
selectRows(rows?: any[], select?: boolean): void;
|
|
61
|
+
deSelect(rows?: any[]): void;
|
|
62
|
+
private rangeStart?;
|
|
63
|
+
private updateSelection;
|
|
64
|
+
connectedCallback(): void;
|
|
65
|
+
setColumnWidths(): void;
|
|
66
|
+
sortByColumn: (columnOptions: ColumnOptions, direction?: "ascending" | "descending" | "auto") => void;
|
|
67
|
+
popColumnMenu: (target: HTMLElement, options: ColumnOptions) => void;
|
|
68
|
+
get captionSpan(): ElementCreator;
|
|
69
|
+
headerCell: (options: ColumnOptions) => HTMLElement;
|
|
70
|
+
dataCell: (options: ColumnOptions) => HTMLElement;
|
|
71
|
+
get visibleRows(): any[];
|
|
72
|
+
get visibleSelectedRows(): any[];
|
|
73
|
+
get selectedRows(): any[];
|
|
74
|
+
rowTemplate(columns: ColumnOptions[]): HTMLTemplateElement;
|
|
75
|
+
private draggedColumn?;
|
|
76
|
+
private dropColumn;
|
|
77
|
+
render(): void;
|
|
78
|
+
}
|
|
79
|
+
export declare const dataTable: ElementCreator<DataTable>;
|