x4js 1.4.3 → 1.4.4
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/lib/index.d.ts +55 -0
- package/lib/index.js +55 -56
- package/lib/router.d.ts +1 -8
- package/lib/router.js +1 -1
- package/package.json +2 -1
- package/src/index.ts +55 -0
- package/src/router.ts +1 -1
- package/tsconfig.json +2 -1
- package/lib/application.d.ts +0 -95
- package/lib/application.js +0 -137
- package/lib/base64.d.ts +0 -31
- package/lib/base64.js +0 -135
- package/lib/base_component.d.ts +0 -64
- package/lib/base_component.js +0 -77
- package/lib/button.d.ts +0 -145
- package/lib/button.js +0 -235
- package/lib/calendar.d.ts +0 -77
- package/lib/calendar.js +0 -236
- package/lib/canvas.d.ts +0 -88
- package/lib/canvas.js +0 -354
- package/lib/cardview.d.ts +0 -83
- package/lib/cardview.js +0 -152
- package/lib/checkbox.d.ts +0 -72
- package/lib/checkbox.js +0 -126
- package/lib/color.d.ts +0 -144
- package/lib/color.js +0 -584
- package/lib/component.d.ts +0 -572
- package/lib/component.js +0 -1712
- package/lib/dom_events.d.ts +0 -284
- package/lib/dom_events.js +0 -13
- package/lib/hosts/host.d.ts +0 -44
- package/lib/hosts/host.js +0 -69
- package/lib/i18n.d.ts +0 -67
- package/lib/i18n.js +0 -169
- package/lib/icon.d.ts +0 -56
- package/lib/icon.js +0 -173
- package/lib/input.d.ts +0 -86
- package/lib/input.js +0 -172
- package/lib/label.d.ts +0 -54
- package/lib/label.js +0 -86
- package/lib/layout.d.ts +0 -77
- package/lib/layout.js +0 -261
- package/lib/list.txt +0 -56
- package/lib/menu.d.ts +0 -122
- package/lib/menu.js +0 -276
- package/lib/popup.d.ts +0 -71
- package/lib/popup.js +0 -373
- package/lib/settings.d.ts +0 -33
- package/lib/settings.js +0 -63
- package/lib/styles.d.ts +0 -81
- package/lib/styles.js +0 -262
- package/lib/tools.d.ts +0 -382
- package/lib/tools.js +0 -1096
- package/lib/x4_events.d.ts +0 -253
- package/lib/x4_events.js +0 -363
- package/list.txt +0 -0
package/lib/cardview.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file cardview.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Component, CProps, CEventMap } from './component';
|
|
26
|
-
import { EvChange } from './x4_events';
|
|
27
|
-
import { IconID } from './icon';
|
|
28
|
-
export declare type PageOrCallback = Component | (() => Component);
|
|
29
|
-
export interface ICardViewItem {
|
|
30
|
-
icon?: IconID;
|
|
31
|
-
name: string;
|
|
32
|
-
title: string;
|
|
33
|
-
page: PageOrCallback;
|
|
34
|
-
}
|
|
35
|
-
interface CardViewEventMap extends CEventMap {
|
|
36
|
-
change?: EvChange;
|
|
37
|
-
}
|
|
38
|
-
export interface CardViewProps extends CProps<CardViewEventMap> {
|
|
39
|
-
pages: ICardViewItem[];
|
|
40
|
-
active?: string;
|
|
41
|
-
}
|
|
42
|
-
interface ICardItemEx extends ICardViewItem {
|
|
43
|
-
selector: Component;
|
|
44
|
-
active: boolean;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Standard CardView class
|
|
48
|
-
* a card view is composed of multiples pages with only one visible at a time.
|
|
49
|
-
* pages can be selected by a component (like tabs ou sidebar).
|
|
50
|
-
* or by code.
|
|
51
|
-
*/
|
|
52
|
-
export declare class CardView<P extends CardViewProps = CardViewProps, E extends CardViewEventMap = CardViewEventMap> extends Component<P, E> {
|
|
53
|
-
protected m_cards: ICardItemEx[];
|
|
54
|
-
protected m_ipage: string;
|
|
55
|
-
protected m_cpage: ICardItemEx;
|
|
56
|
-
constructor(props: P);
|
|
57
|
-
/** @ignore */
|
|
58
|
-
render(): void;
|
|
59
|
-
/**
|
|
60
|
-
* switch to a specific card
|
|
61
|
-
* @param name - card name as define in constructor
|
|
62
|
-
*/
|
|
63
|
-
switchTo(name?: string): void;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
setPages(pages: ICardViewItem[]): void;
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
*/
|
|
71
|
-
private _initTabs;
|
|
72
|
-
protected _updateSelector(): void;
|
|
73
|
-
/**
|
|
74
|
-
* prepare the cardinfo
|
|
75
|
-
* can be used by derivations to create & set selectors
|
|
76
|
-
*/
|
|
77
|
-
protected _prepareSelector(card: ICardViewItem): Component;
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
*/
|
|
81
|
-
protected _preparePage(page: Component): void;
|
|
82
|
-
}
|
|
83
|
-
export {};
|
package/lib/cardview.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file cardview.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Component } from './component';
|
|
26
|
-
import { EvChange } from './x4_events';
|
|
27
|
-
import { asap, isFunction } from './tools';
|
|
28
|
-
/**
|
|
29
|
-
* Standard CardView class
|
|
30
|
-
* a card view is composed of multiples pages with only one visible at a time.
|
|
31
|
-
* pages can be selected by a component (like tabs ou sidebar).
|
|
32
|
-
* or by code.
|
|
33
|
-
*/
|
|
34
|
-
export class CardView extends Component {
|
|
35
|
-
m_cards;
|
|
36
|
-
m_ipage; // initialy selected page
|
|
37
|
-
m_cpage; // currently selected page
|
|
38
|
-
constructor(props) {
|
|
39
|
-
super(props);
|
|
40
|
-
this.m_cards = [];
|
|
41
|
-
this.m_ipage = props.active;
|
|
42
|
-
this.m_cpage = null;
|
|
43
|
-
this.singleShot(() => {
|
|
44
|
-
this.setPages(props.pages);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/** @ignore */
|
|
48
|
-
render() {
|
|
49
|
-
let pages = [];
|
|
50
|
-
this.m_cards.forEach((p) => {
|
|
51
|
-
if (p.page) {
|
|
52
|
-
pages.push(p.page);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
this.setContent(pages);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* switch to a specific card
|
|
59
|
-
* @param name - card name as define in constructor
|
|
60
|
-
*/
|
|
61
|
-
switchTo(name) {
|
|
62
|
-
if (this.m_cards.length == 0) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (name === undefined) {
|
|
66
|
-
name = this.m_cards[0].name;
|
|
67
|
-
}
|
|
68
|
-
if (name === this.m_cpage?.name) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
// hide old one
|
|
72
|
-
if (this.m_cpage) {
|
|
73
|
-
if (this.m_cpage.selector) {
|
|
74
|
-
this.m_cpage.selector.removeClass('@active');
|
|
75
|
-
}
|
|
76
|
-
if (this.m_cpage.page && !(this.m_cpage.page instanceof Function)) {
|
|
77
|
-
let page = this.m_cpage.page;
|
|
78
|
-
page.removeClass('@active');
|
|
79
|
-
page.addClass('@hidden');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
this.m_cpage = this.m_cards.find((card) => card.name == name);
|
|
83
|
-
if (this.m_cpage) {
|
|
84
|
-
if (this.m_cpage.page) {
|
|
85
|
-
if (isFunction(this.m_cpage.page)) {
|
|
86
|
-
this.m_cpage.page = this.m_cpage.page();
|
|
87
|
-
console.assert(this.m_cpage.page != null, 'You must return a valid component');
|
|
88
|
-
}
|
|
89
|
-
let page = this.m_cpage.page;
|
|
90
|
-
page.addClass('@active');
|
|
91
|
-
page.removeClass('@hidden');
|
|
92
|
-
if (!page.dom) {
|
|
93
|
-
this._preparePage(page);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
this.emit('change', EvChange(this.m_cpage.name));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
*/
|
|
102
|
-
setPages(pages) {
|
|
103
|
-
let active = this._initTabs(pages);
|
|
104
|
-
if (active) {
|
|
105
|
-
asap(() => {
|
|
106
|
-
this.switchTo(active);
|
|
107
|
-
this.update();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
_initTabs(pages) {
|
|
115
|
-
if (!pages) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
let active = this.m_ipage;
|
|
119
|
-
pages.forEach((p) => {
|
|
120
|
-
if (!p) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
let card = { ...p };
|
|
124
|
-
card.selector = this._prepareSelector(p);
|
|
125
|
-
card.active = false;
|
|
126
|
-
this.m_cards.push(card);
|
|
127
|
-
if (!active) {
|
|
128
|
-
active = p.name;
|
|
129
|
-
}
|
|
130
|
-
if (p.active) {
|
|
131
|
-
active = p.name;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return active;
|
|
135
|
-
}
|
|
136
|
-
_updateSelector() {
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* prepare the cardinfo
|
|
140
|
-
* can be used by derivations to create & set selectors
|
|
141
|
-
*/
|
|
142
|
-
_prepareSelector(card) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
148
|
-
_preparePage(page) {
|
|
149
|
-
page.setStyleValue('flex', 1);
|
|
150
|
-
page.addClass('@tab-page');
|
|
151
|
-
}
|
|
152
|
-
}
|
package/lib/checkbox.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file checkbox.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { CEventMap, Component, CProps } from './component';
|
|
26
|
-
import { EvChange, EventCallback } from './x4_events';
|
|
27
|
-
import { HtmlString } from './tools';
|
|
28
|
-
interface CheckBoxEventMap extends CEventMap {
|
|
29
|
-
change?: EvChange;
|
|
30
|
-
}
|
|
31
|
-
interface CheckBoxProps extends CProps<CheckBoxEventMap> {
|
|
32
|
-
name?: string;
|
|
33
|
-
text?: string | HtmlString;
|
|
34
|
-
checked?: boolean;
|
|
35
|
-
value?: string;
|
|
36
|
-
labelWidth?: number;
|
|
37
|
-
labelAlign?: 'left' | 'right';
|
|
38
|
-
align?: 'left' | 'right';
|
|
39
|
-
change: EventCallback<EvChange>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Standard CheckBox
|
|
43
|
-
*/
|
|
44
|
-
export declare class CheckBox extends Component<CheckBoxProps, CheckBoxEventMap> {
|
|
45
|
-
constructor(props: CheckBoxProps);
|
|
46
|
-
/** @ignore */
|
|
47
|
-
render(props: CheckBoxProps): void;
|
|
48
|
-
/**
|
|
49
|
-
* check state changed
|
|
50
|
-
*/
|
|
51
|
-
private _change;
|
|
52
|
-
/**
|
|
53
|
-
* focus gained/loosed
|
|
54
|
-
*/
|
|
55
|
-
private _setFocus;
|
|
56
|
-
/**
|
|
57
|
-
* @return the checked value
|
|
58
|
-
*/
|
|
59
|
-
get check(): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* change the checked value
|
|
62
|
-
* @param {boolean} ck new checked value
|
|
63
|
-
*/
|
|
64
|
-
set check(ck: boolean);
|
|
65
|
-
get text(): string | HtmlString;
|
|
66
|
-
set text(text: string | HtmlString);
|
|
67
|
-
/**
|
|
68
|
-
* toggle the checkbox
|
|
69
|
-
*/
|
|
70
|
-
toggle(): void;
|
|
71
|
-
}
|
|
72
|
-
export {};
|
package/lib/checkbox.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file checkbox.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Component } from './component';
|
|
26
|
-
import { EvChange } from './x4_events';
|
|
27
|
-
import { Input } from './input';
|
|
28
|
-
import { Label } from './label';
|
|
29
|
-
/**
|
|
30
|
-
* Standard CheckBox
|
|
31
|
-
*/
|
|
32
|
-
export class CheckBox extends Component {
|
|
33
|
-
constructor(props) {
|
|
34
|
-
super(props);
|
|
35
|
-
this.setDomEvent('focus', () => this._setFocus());
|
|
36
|
-
this.mapPropEvents(props, 'change');
|
|
37
|
-
}
|
|
38
|
-
/** @ignore */
|
|
39
|
-
render(props) {
|
|
40
|
-
// checkbox
|
|
41
|
-
let labelWidth = props.labelWidth ?? -1;
|
|
42
|
-
let uid = '__cb_' + this.uid;
|
|
43
|
-
this.addClass('@hlayout');
|
|
44
|
-
this.addClass(props.align ?? 'left');
|
|
45
|
-
this.setProp('tag', 'label');
|
|
46
|
-
this.setContent([
|
|
47
|
-
new Input({
|
|
48
|
-
ref: 'input',
|
|
49
|
-
type: 'checkbox',
|
|
50
|
-
name: props.name,
|
|
51
|
-
id: uid,
|
|
52
|
-
tabIndex: props.tabIndex,
|
|
53
|
-
value: props.value ?? 'on',
|
|
54
|
-
attrs: {
|
|
55
|
-
checked: props.checked ? '' : undefined
|
|
56
|
-
},
|
|
57
|
-
dom_events: {
|
|
58
|
-
change: this._change.bind(this),
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
new Label({
|
|
62
|
-
text: props.text ?? '',
|
|
63
|
-
width: labelWidth < 0 ? undefined : labelWidth,
|
|
64
|
-
flex: labelWidth < 0 ? -labelWidth : undefined,
|
|
65
|
-
align: props.labelAlign ?? 'left',
|
|
66
|
-
style: {
|
|
67
|
-
order: props.align == 'right' ? -1 : 1,
|
|
68
|
-
},
|
|
69
|
-
attrs: {
|
|
70
|
-
"for": uid
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* check state changed
|
|
77
|
-
*/
|
|
78
|
-
_change() {
|
|
79
|
-
this.emit('change', EvChange(this.check));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* focus gained/loosed
|
|
83
|
-
*/
|
|
84
|
-
_setFocus() {
|
|
85
|
-
let input = this.itemWithRef('input');
|
|
86
|
-
input.focus();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @return the checked value
|
|
90
|
-
*/
|
|
91
|
-
get check() {
|
|
92
|
-
if (this.dom) {
|
|
93
|
-
let input = this.itemWithRef('input');
|
|
94
|
-
let dom = input.dom;
|
|
95
|
-
return dom.checked;
|
|
96
|
-
}
|
|
97
|
-
return this.m_props.checked;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* change the checked value
|
|
101
|
-
* @param {boolean} ck new checked value
|
|
102
|
-
*/
|
|
103
|
-
set check(ck) {
|
|
104
|
-
if (this.dom) {
|
|
105
|
-
let input = this.itemWithRef('input');
|
|
106
|
-
const dom = input.dom;
|
|
107
|
-
if (dom) {
|
|
108
|
-
dom.checked = ck;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
this.m_props.checked = ck;
|
|
112
|
-
//this._change(); // todo: is it needed when changed by code ? -> no
|
|
113
|
-
}
|
|
114
|
-
get text() {
|
|
115
|
-
return this.itemWithRef('label').text;
|
|
116
|
-
}
|
|
117
|
-
set text(text) {
|
|
118
|
-
this.itemWithRef('label').text = text;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* toggle the checkbox
|
|
122
|
-
*/
|
|
123
|
-
toggle() {
|
|
124
|
-
this.check = !this.check;
|
|
125
|
-
}
|
|
126
|
-
}
|
package/lib/color.d.ts
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file color.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
export declare class Color {
|
|
26
|
-
private m_value;
|
|
27
|
-
private static custom;
|
|
28
|
-
/**
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* let c = new Color( 255, 255, 255, 0.2 );
|
|
32
|
-
* let d = new Color( "fff" );
|
|
33
|
-
* let e = new Color( "css:selection-color" );
|
|
34
|
-
* let f = new Color( "rgba(255,0,255,0.6)" );
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
constructor();
|
|
38
|
-
constructor(value: number | string);
|
|
39
|
-
constructor(value: number | string, alpha: number);
|
|
40
|
-
constructor(r: number, g: number, b: number);
|
|
41
|
-
constructor(r: number, g: number, b: number, a: number);
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
private _shade;
|
|
46
|
-
/**
|
|
47
|
-
* return a color darken by percent
|
|
48
|
-
* @param percent
|
|
49
|
-
*/
|
|
50
|
-
darken(percent: number): Color;
|
|
51
|
-
/**
|
|
52
|
-
* return a color lighten by percent
|
|
53
|
-
* @param percent
|
|
54
|
-
*/
|
|
55
|
-
lighten(percent: number): Color;
|
|
56
|
-
/**
|
|
57
|
-
* mix 2 colors
|
|
58
|
-
* @param {rgb} c1 - color 1
|
|
59
|
-
* @param {rgb} c2 - color 2
|
|
60
|
-
* @param {float} percent - 0.0 to 1.0
|
|
61
|
-
* @example
|
|
62
|
-
* ```js
|
|
63
|
-
* let clr = Color.mix( color1, color2, 0.5 );
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
static mix(c1: Color, c2: Color, p: number): Color;
|
|
67
|
-
/**
|
|
68
|
-
* split the color into it's base element r,g,b & a (!a 1-255)
|
|
69
|
-
*/
|
|
70
|
-
private _split;
|
|
71
|
-
/**
|
|
72
|
-
* change the alpha value
|
|
73
|
-
*/
|
|
74
|
-
fadeout(percent: number): Color;
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
static fromHSV(h: number, s: number, v: number, a?: number): Color;
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
static toHSV(c: Color): {
|
|
83
|
-
h: any;
|
|
84
|
-
s: number;
|
|
85
|
-
v: number;
|
|
86
|
-
a: number;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
static fromHLS(h: number, l: number, s: number): Color;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
static toHLS(color: Color): {
|
|
96
|
-
h: number;
|
|
97
|
-
l: number;
|
|
98
|
-
s: any;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* get the red value of the color
|
|
102
|
-
*/
|
|
103
|
-
red(): number;
|
|
104
|
-
/**
|
|
105
|
-
* get the green value of the color
|
|
106
|
-
*/
|
|
107
|
-
green(): number;
|
|
108
|
-
/**
|
|
109
|
-
* get the blue value of the color
|
|
110
|
-
*/
|
|
111
|
-
blue(): number;
|
|
112
|
-
/**
|
|
113
|
-
* get the alpha value of the color
|
|
114
|
-
*/
|
|
115
|
-
alpha(): number;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
*/
|
|
119
|
-
value(): number;
|
|
120
|
-
/**
|
|
121
|
-
* convert the color into string value
|
|
122
|
-
*/
|
|
123
|
-
toString(): string;
|
|
124
|
-
toHex(with_alpha?: boolean): string;
|
|
125
|
-
static addCustomColor(name: string, value: Color): void;
|
|
126
|
-
static addCssColor(name: string): void;
|
|
127
|
-
static parse(str: string): Color;
|
|
128
|
-
private _getCustomColor;
|
|
129
|
-
static contrastColor(color: Color): Color;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*/
|
|
133
|
-
static WHITE: Color;
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
*/
|
|
137
|
-
static BLACK: Color;
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
static NONE: Color;
|
|
142
|
-
static valueFromColorName(name: string): Color;
|
|
143
|
-
static fromCssVar(varName: string): string;
|
|
144
|
-
}
|