@web-atoms/web-controls 2.1.3 → 2.1.7
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/basic/Button.d.ts +19 -0
- package/dist/basic/Button.d.ts.map +1 -0
- package/dist/basic/Button.js +63 -0
- package/dist/basic/Button.js.map +1 -0
- package/dist/basic/Checkbox.d.ts +5 -0
- package/dist/basic/Checkbox.d.ts.map +1 -0
- package/dist/basic/Checkbox.js +39 -0
- package/dist/basic/Checkbox.js.map +1 -0
- package/dist/basic/IElement.d.ts +11 -0
- package/dist/basic/IElement.d.ts.map +1 -0
- package/dist/basic/IElement.js +13 -0
- package/dist/basic/IElement.js.map +1 -0
- package/dist/basic/Input.d.ts +5 -0
- package/dist/basic/Input.d.ts.map +1 -0
- package/dist/basic/Input.js +30 -0
- package/dist/basic/Input.js.map +1 -0
- package/dist/basic/Panel.d.ts +6 -0
- package/dist/basic/Panel.d.ts.map +1 -0
- package/dist/basic/Panel.js +37 -0
- package/dist/basic/Panel.js.map +1 -0
- package/dist/basic/PopupButton.d.ts +17 -0
- package/dist/basic/PopupButton.d.ts.map +1 -0
- package/dist/basic/PopupButton.js +130 -0
- package/dist/basic/PopupButton.js.map +1 -0
- package/dist/basic/Switch.d.ts +7 -0
- package/dist/basic/Switch.d.ts.map +1 -0
- package/dist/basic/Switch.js +96 -0
- package/dist/basic/Switch.js.map +1 -0
- package/dist/basic/combineClasses.d.ts +2 -0
- package/dist/basic/combineClasses.d.ts.map +1 -0
- package/dist/basic/combineClasses.js +17 -0
- package/dist/basic/combineClasses.js.map +1 -0
- package/dist/form/AtomField.d.ts +2 -1
- package/dist/form/AtomField.d.ts.map +1 -1
- package/dist/form/AtomField.js +25 -16
- package/dist/form/AtomField.js.map +1 -1
- package/package.json +1 -1
- package/src/basic/Button.tsx +97 -0
- package/src/basic/Checkbox.tsx +48 -0
- package/src/basic/IElement.ts +10 -0
- package/src/basic/Input.tsx +30 -0
- package/src/basic/Panel.tsx +43 -0
- package/src/basic/PopupButton.tsx +146 -0
- package/src/basic/Switch.tsx +110 -0
- package/src/basic/combineClasses.ts +3 -0
- package/src/form/AtomField.tsx +25 -33
package/dist/form/AtomField.js
CHANGED
|
@@ -45,7 +45,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
45
45
|
return (this.helpText || this.helpLink) ? true : false;
|
|
46
46
|
}
|
|
47
47
|
onPropertyChanged(name) {
|
|
48
|
-
var _a
|
|
48
|
+
var _a;
|
|
49
49
|
switch (name) {
|
|
50
50
|
case "error":
|
|
51
51
|
AtomBinder_1.AtomBinder.refreshValue(this, "hasError");
|
|
@@ -60,21 +60,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
this.removeAllChildren(this.contentPresenter);
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
63
|
+
const content = this.content;
|
|
64
|
+
if (!content) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
for (const iterator of content) {
|
|
68
|
+
const e = (_a = iterator === null || iterator === void 0 ? void 0 : iterator.element) !== null && _a !== void 0 ? _a : iterator;
|
|
69
|
+
if (!e) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (typeof e === "string") {
|
|
73
|
+
this.contentPresenter.appendChild(document.createTextNode(e));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.contentPresenter.appendChild(e);
|
|
77
|
+
const input = e.tagName === "INPUT" ? e : e.getElementsByTagName("input")[0];
|
|
78
|
+
if (input) {
|
|
79
|
+
if (!input.id) {
|
|
80
|
+
input.id = `__ID__formElementInput${inputID++}`;
|
|
81
|
+
}
|
|
82
|
+
this.htmlFor = input.id;
|
|
76
83
|
}
|
|
77
|
-
this.htmlFor = input.id;
|
|
78
84
|
}
|
|
79
85
|
break;
|
|
80
86
|
}
|
|
@@ -167,9 +173,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
167
173
|
BindableProperty_1.BindableProperty,
|
|
168
174
|
__metadata("design:type", Object)
|
|
169
175
|
], AtomFieldControl.prototype, "htmlFor", void 0);
|
|
170
|
-
function AtomField(
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
function AtomField(attributes, ...children) {
|
|
177
|
+
var _a, _b, _c;
|
|
178
|
+
const ControlClass = (_a = attributes.baseClass) !== null && _a !== void 0 ? _a : AtomFieldControl;
|
|
179
|
+
(_b = attributes.visible) !== null && _b !== void 0 ? _b : (attributes.visible = true);
|
|
180
|
+
(_c = attributes.fieldClass) !== null && _c !== void 0 ? _c : (attributes.fieldClass = null);
|
|
181
|
+
return XNode_1.default.create(ControlClass, Object.assign({}, attributes, { content: children }));
|
|
173
182
|
}
|
|
174
183
|
exports.default = AtomField;
|
|
175
184
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AtomField.js","sourceRoot":"","sources":["../../src/form/AtomField.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,qEAAkE;IAClE,yDAAkD;IAClD,iFAA8E;IAE9E,2DAAoD;IACpD,uFAAoF;IAEpF,+EAA4E;IAC5E,yCAA4C;IAAnC,+FAAA,OAAO,OAAM;IAEtB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,gBAAiB,SAAQ,yBAAW;QAgCtC,IAAW,QAAQ;YACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACrC,CAAC;QAED,IAAW,OAAO;YACd,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC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I,QAAiB;;QAClF,MAAM,YAAY,GAAG,MAAA,UAAU,CAAC,SAAS,mCAAI,gBAAgB,CAAC;QAC9D,MAAA,UAAU,CAAC,OAAO,oCAAlB,UAAU,CAAC,OAAO,GAAK,IAAI,EAAC;QAC5B,MAAA,UAAU,CAAC,UAAU,oCAArB,UAAU,CAAC,UAAU,GAAK,IAAI,EAAC;QAC/B,OAAO,uBAAC,YAAY,oBACV,UAAU,IAChB,OAAO,EAAE,QAAQ,IACf,CAAC;IACX,CAAC;IARD,4BAQC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
4
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
5
|
+
|
|
6
|
+
export interface IButton {
|
|
7
|
+
id?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
eventClick?: any;
|
|
11
|
+
href?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
styleDisplay?: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
isVisible?: any;
|
|
17
|
+
subClass?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const css = CSS(
|
|
21
|
+
StyleRule()
|
|
22
|
+
.padding(8)
|
|
23
|
+
.marginLeft(3)
|
|
24
|
+
.marginRight(3)
|
|
25
|
+
.roundBorderFull()
|
|
26
|
+
.display("inline-block")
|
|
27
|
+
.height(40)
|
|
28
|
+
.minWidth(40)
|
|
29
|
+
.defaultBoxShadow()
|
|
30
|
+
.cursor("pointer")
|
|
31
|
+
.backgroundColor(Colors.transparent)
|
|
32
|
+
.hoverBackgroundColor(Colors.lightGreen)
|
|
33
|
+
.and(StyleRule(".pressed")
|
|
34
|
+
.backgroundColor(Colors.lightSteelBlue)
|
|
35
|
+
)
|
|
36
|
+
.child(StyleRule("label.label")
|
|
37
|
+
.display("flex")
|
|
38
|
+
.alignItems("center")
|
|
39
|
+
.gap("5px")
|
|
40
|
+
.child(StyleRule(".fad")
|
|
41
|
+
.fontSize(18)
|
|
42
|
+
.width("100%")
|
|
43
|
+
.color(Colors.purple.withAlphaPercent(0.5))
|
|
44
|
+
.cursor("pointer")
|
|
45
|
+
.and(StyleRule(".red")
|
|
46
|
+
.color(Colors.red)
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
.child(StyleRule("span")
|
|
50
|
+
.whiteSpace("nowrap")
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export default function Button({
|
|
56
|
+
id,
|
|
57
|
+
icon,
|
|
58
|
+
text,
|
|
59
|
+
eventClick,
|
|
60
|
+
href,
|
|
61
|
+
target,
|
|
62
|
+
title,
|
|
63
|
+
styleDisplay,
|
|
64
|
+
class: className,
|
|
65
|
+
subClass
|
|
66
|
+
}: IButton) {
|
|
67
|
+
|
|
68
|
+
const cn = className ?? ( subClass
|
|
69
|
+
? subClass + " " + css
|
|
70
|
+
: css
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (href) {
|
|
74
|
+
|
|
75
|
+
if (text) {
|
|
76
|
+
return <a id={id}
|
|
77
|
+
class={cn}
|
|
78
|
+
target={target}
|
|
79
|
+
title={title}
|
|
80
|
+
styleDisplay={styleDisplay}
|
|
81
|
+
>
|
|
82
|
+
<label class="label">
|
|
83
|
+
<i class={icon}/>
|
|
84
|
+
{ text && <span text={text}/> }
|
|
85
|
+
</label>
|
|
86
|
+
</a>;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return <button id={id} class={cn} eventClick={eventClick} title={title} styleDisplay={styleDisplay}>
|
|
90
|
+
<label class="label">
|
|
91
|
+
<i class={icon}/>
|
|
92
|
+
{ text && <span text={text}/> }
|
|
93
|
+
</label>
|
|
94
|
+
</button>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Button.className = css;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
4
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
5
|
+
|
|
6
|
+
const css = CSS(
|
|
7
|
+
StyleRule("check-box")
|
|
8
|
+
.display("inline-block")
|
|
9
|
+
.child(
|
|
10
|
+
StyleRule("label")
|
|
11
|
+
.display("flex")
|
|
12
|
+
.paddingLeft(5)
|
|
13
|
+
.paddingRight(5)
|
|
14
|
+
.child(
|
|
15
|
+
|
|
16
|
+
StyleRule("input[type=checkbox]")
|
|
17
|
+
.borderRadius(3)
|
|
18
|
+
.margin(0)
|
|
19
|
+
.padding(0)
|
|
20
|
+
.alignSelf("center")
|
|
21
|
+
)
|
|
22
|
+
.child(
|
|
23
|
+
StyleRule("span")
|
|
24
|
+
.alignSelf("center")
|
|
25
|
+
.whiteSpace("nowrap")
|
|
26
|
+
.marginLeft(5)
|
|
27
|
+
.flexStretch()
|
|
28
|
+
|
|
29
|
+
))
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export default function Checkbox({
|
|
33
|
+
checked,
|
|
34
|
+
text
|
|
35
|
+
}: {
|
|
36
|
+
checked: any,
|
|
37
|
+
text: string
|
|
38
|
+
}) {
|
|
39
|
+
return <div class={css}>
|
|
40
|
+
<label>
|
|
41
|
+
<input
|
|
42
|
+
type="checkbox"
|
|
43
|
+
checked={checked}/>
|
|
44
|
+
<span
|
|
45
|
+
text={text}></span>
|
|
46
|
+
</label>
|
|
47
|
+
</div>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
2
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
3
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
4
|
+
|
|
5
|
+
const css = CSS(
|
|
6
|
+
StyleRule("input")
|
|
7
|
+
.display("inline-block")
|
|
8
|
+
.child(
|
|
9
|
+
StyleRule("input[type=input]")
|
|
10
|
+
.margin(0)
|
|
11
|
+
.padding(5)
|
|
12
|
+
.height(25)
|
|
13
|
+
.marginRight(5)
|
|
14
|
+
.outline("none")
|
|
15
|
+
.alignSelf("center")
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export default function Input({
|
|
20
|
+
value,
|
|
21
|
+
placeholder
|
|
22
|
+
}:{
|
|
23
|
+
value:string,
|
|
24
|
+
placeholder: string
|
|
25
|
+
}){
|
|
26
|
+
return <div class={css}>
|
|
27
|
+
<input type="input"
|
|
28
|
+
placeholder={placeholder} />
|
|
29
|
+
</div>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
2
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
3
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
4
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
5
|
+
|
|
6
|
+
export interface IPanelAttributes {
|
|
7
|
+
header?: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const css = CSS(StyleRule("panel")
|
|
12
|
+
.display("inline-block")
|
|
13
|
+
.padding(5)
|
|
14
|
+
.margin(3)
|
|
15
|
+
.borderRadius(9999)
|
|
16
|
+
.defaultBoxShadow()
|
|
17
|
+
.child(StyleRule(".header")
|
|
18
|
+
.backgroundColor(Colors.lightGray)
|
|
19
|
+
.borderRadius(5)
|
|
20
|
+
.padding(5)
|
|
21
|
+
));
|
|
22
|
+
|
|
23
|
+
export default function Panel(
|
|
24
|
+
{
|
|
25
|
+
header,
|
|
26
|
+
class: className
|
|
27
|
+
}: IPanelAttributes,
|
|
28
|
+
... children: any[]) {
|
|
29
|
+
|
|
30
|
+
className = className ? css + " " + className : css;
|
|
31
|
+
|
|
32
|
+
if (header) {
|
|
33
|
+
return <div class={className}>
|
|
34
|
+
<label class="header">{header}</label>
|
|
35
|
+
{ ... children }
|
|
36
|
+
</div>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return <div class={className}>
|
|
40
|
+
{ ... children }
|
|
41
|
+
</div>;
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import Bind from "@web-atoms/core/dist/core/Bind";
|
|
2
|
+
import { BindableProperty } from "@web-atoms/core/dist/core/BindableProperty";
|
|
3
|
+
import Colors from "@web-atoms/core/dist/core/Colors";
|
|
4
|
+
import { IDisposable } from "@web-atoms/core/dist/core/types";
|
|
5
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
6
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
7
|
+
import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl";
|
|
8
|
+
import { AtomItemsControl } from "@web-atoms/core/dist/web/controls/AtomItemsControl";
|
|
9
|
+
import PopupService from "@web-atoms/core/dist/web/services/PopupService";
|
|
10
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
11
|
+
import combineClasses from "./combineClasses";
|
|
12
|
+
import Button from "./Button";
|
|
13
|
+
import IElement from "./IElement";
|
|
14
|
+
|
|
15
|
+
const menuCss = CSS(StyleRule()
|
|
16
|
+
.child(StyleRule(".menu")
|
|
17
|
+
.padding(5)
|
|
18
|
+
.margin(3)
|
|
19
|
+
.borderRadius(5)
|
|
20
|
+
.cursor("pointer")
|
|
21
|
+
.hoverBackgroundColor(Colors.lightGreen)
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export interface IMenuItem {
|
|
26
|
+
label?: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
eventClick?: any;
|
|
29
|
+
href?: string;
|
|
30
|
+
target?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function MenuItem({
|
|
35
|
+
label,
|
|
36
|
+
icon,
|
|
37
|
+
eventClick,
|
|
38
|
+
href,
|
|
39
|
+
target,
|
|
40
|
+
... others
|
|
41
|
+
}: IMenuItem) {
|
|
42
|
+
|
|
43
|
+
if (label) {
|
|
44
|
+
return <div class="menu" eventClick={eventClick} { ... others }>
|
|
45
|
+
<i class={icon}/>
|
|
46
|
+
</div>;
|
|
47
|
+
}
|
|
48
|
+
return <div class="menu" eventClick={eventClick} { ... others }>
|
|
49
|
+
<i class={icon}/>
|
|
50
|
+
</div>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class MenuItemTemplate extends AtomControl {
|
|
54
|
+
|
|
55
|
+
public data: IMenuItem;
|
|
56
|
+
|
|
57
|
+
public create() {
|
|
58
|
+
this.render(<div
|
|
59
|
+
class="menu"
|
|
60
|
+
eventClick={Bind.event(() => this.app.runAsync(() => this.data.eventClick()))}
|
|
61
|
+
>
|
|
62
|
+
<i
|
|
63
|
+
styleDisplay={Bind.oneWay(() => this.data.icon ? "" : "none")}
|
|
64
|
+
class={Bind.oneWay(() => this.data.icon)}/>
|
|
65
|
+
<span
|
|
66
|
+
styleDisplay={Bind.oneWay(() => this.data.label ? "" : "none")}
|
|
67
|
+
text={Bind.oneWay(() => this.data.label)}></span>
|
|
68
|
+
</div>);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class PopupMenuButton extends AtomControl {
|
|
73
|
+
|
|
74
|
+
@BindableProperty
|
|
75
|
+
public subClass: string;
|
|
76
|
+
|
|
77
|
+
@BindableProperty
|
|
78
|
+
public icon: string;
|
|
79
|
+
|
|
80
|
+
@BindableProperty
|
|
81
|
+
public text: string;
|
|
82
|
+
|
|
83
|
+
@BindableProperty
|
|
84
|
+
public menus: IMenuItem[];
|
|
85
|
+
|
|
86
|
+
private popup: IDisposable;
|
|
87
|
+
|
|
88
|
+
constructor(app, e) {
|
|
89
|
+
super(app, e ?? document.createElement("button"));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public preCreate() {
|
|
93
|
+
super.preCreate();
|
|
94
|
+
this.popup = null;
|
|
95
|
+
this.text = null;
|
|
96
|
+
this.icon = null;
|
|
97
|
+
this.subClass = null;
|
|
98
|
+
this.render(<button
|
|
99
|
+
class={Bind.oneWay(() => combineClasses(Button.className, this.popup ? "pressed" : null, this.subClass))}
|
|
100
|
+
eventClick={Bind.event(() => this.openPopup())}>
|
|
101
|
+
<label class="label">
|
|
102
|
+
<i class={Bind.oneWay(() => this.icon)}/>
|
|
103
|
+
<span
|
|
104
|
+
styleDisplay={Bind.oneWay(() => this.text ? "" : "none")}
|
|
105
|
+
text={Bind.oneWay(() => this.text)}/>
|
|
106
|
+
</label>
|
|
107
|
+
</button>);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private openPopup() {
|
|
111
|
+
if (this.popup) {
|
|
112
|
+
this.popup.dispose();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const menus = this.menus;
|
|
117
|
+
|
|
118
|
+
class Popup extends AtomControl {
|
|
119
|
+
protected create(): void {
|
|
120
|
+
this.render(<div class={menuCss}>
|
|
121
|
+
{ ... menus}
|
|
122
|
+
</div>);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const items = new Popup(this.app, document.createElement("div"));
|
|
126
|
+
items.registerDisposable({
|
|
127
|
+
dispose: () => {
|
|
128
|
+
this.popup = null;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
items.bindEvent(items.element, "click", () => {
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
this.openPopup();
|
|
134
|
+
}, 100);
|
|
135
|
+
});
|
|
136
|
+
const popupService = this.app.resolve(PopupService);
|
|
137
|
+
this.popup = popupService.show(this.element, items);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default function PopupButton( props: IElement, ... menus: IMenuItem[]) {
|
|
142
|
+
return <PopupMenuButton
|
|
143
|
+
{ ... props }
|
|
144
|
+
menus={menus}
|
|
145
|
+
/>;
|
|
146
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import XNode from "@web-atoms/core/dist/core/XNode";
|
|
2
|
+
import StyleRule from "@web-atoms/core/dist/style/StyleRule";
|
|
3
|
+
import CSS from "@web-atoms/core/dist/web/styles/CSS";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Original source = https://www.htmllion.com/css3-toggle-switch-button.html
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const css = CSS(StyleRule()
|
|
10
|
+
.position("relative")
|
|
11
|
+
.display("inline-block")
|
|
12
|
+
.verticalAlign("top")
|
|
13
|
+
.width(70)
|
|
14
|
+
.height(30)
|
|
15
|
+
.padding(3)
|
|
16
|
+
.margin("0 10px 10px 0")
|
|
17
|
+
.background("linear-gradient(to bottom, #eeeeee, #FFFFFF 25px)" as any)
|
|
18
|
+
.backgroundImage("-webkit-linear-gradient(top, #eeeeee, #FFFFFF 25px)")
|
|
19
|
+
.borderRadius(18)
|
|
20
|
+
.boxShadow("inset 0 -1px white, inset 0 1px 1px rgba(0, 0, 0, 0.05)")
|
|
21
|
+
.cursor("pointer")
|
|
22
|
+
.boxSizing("content-box")
|
|
23
|
+
.child(StyleRule(".switch-input")
|
|
24
|
+
.absolutePosition({ top: 0, left: 0})
|
|
25
|
+
.opacity(0 as any)
|
|
26
|
+
.boxSizing("content-box")
|
|
27
|
+
)
|
|
28
|
+
.child(StyleRule(".switch-label")
|
|
29
|
+
.position("relative")
|
|
30
|
+
.display("block")
|
|
31
|
+
.height("inherit")
|
|
32
|
+
.fontSize(10)
|
|
33
|
+
.textTransform("uppercase")
|
|
34
|
+
.backgroundColor("#eceeef")
|
|
35
|
+
.borderRadius("inherit")
|
|
36
|
+
.boxShadow("inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15)")
|
|
37
|
+
.boxSizing("content-box")
|
|
38
|
+
.and(StyleRule(":before, .switch-label:after")
|
|
39
|
+
.position("absolute")
|
|
40
|
+
.top("50%")
|
|
41
|
+
.marginTop("-.5em")
|
|
42
|
+
.lineHeight("1")
|
|
43
|
+
.webkitTransition("inherit")
|
|
44
|
+
.transition("inherit")
|
|
45
|
+
.boxSizing("content-box")
|
|
46
|
+
)
|
|
47
|
+
.and(StyleRule(":before")
|
|
48
|
+
.content("attr(data-off)" as any)
|
|
49
|
+
.right(11)
|
|
50
|
+
.color("#aaaaaa")
|
|
51
|
+
.textShadow("0 1px rgba(255, 255, 255, 0.5)")
|
|
52
|
+
)
|
|
53
|
+
.and(StyleRule(":after")
|
|
54
|
+
.content("attr(data-on)" as any)
|
|
55
|
+
.left(11)
|
|
56
|
+
.color("#FFFFFF")
|
|
57
|
+
.textShadow("0 1px rgba(0, 0, 0, 0.2)")
|
|
58
|
+
.opacity("0")
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
.child(StyleRule(".switch-input:checked ~ .switch-label")
|
|
62
|
+
.backgroundColor("#E1B42B")
|
|
63
|
+
.boxShadow("inset 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 3px rgba(0, 0, 0, 0.2)")
|
|
64
|
+
)
|
|
65
|
+
.child(StyleRule(".switch-input:checked ~ .switch-label:before")
|
|
66
|
+
.opacity("0")
|
|
67
|
+
)
|
|
68
|
+
.child(StyleRule(".switch-input:checked ~ .switch-label:after")
|
|
69
|
+
.opacity("1")
|
|
70
|
+
)
|
|
71
|
+
.child(StyleRule(".switch-handle")
|
|
72
|
+
.absolutePosition({top: 4, left: 4, width: 28, height: 28})
|
|
73
|
+
.background("linear-gradient(to bottom, #FFFFFF 40%, #f0f0f0)" as any)
|
|
74
|
+
.borderRadius("100%")
|
|
75
|
+
.boxShadow("1px 1px 5px rgba(0, 0, 0, 0.2)")
|
|
76
|
+
.and(StyleRule(":before")
|
|
77
|
+
.content("")
|
|
78
|
+
.absolutePosition({ top: "50%", left: "50%", width: 12, height: 12 })
|
|
79
|
+
.background("linear-gradient(to bottom, #eeeeee, #FFFFFF)" as any)
|
|
80
|
+
.borderRadius(6)
|
|
81
|
+
.boxShadow("inset 0 1px rgba(0, 0, 0, 0.02)")
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
.child(StyleRule(".switch-input:checked ~ .switch-handle")
|
|
85
|
+
.left(44)
|
|
86
|
+
.boxShadow("-1px 1px 5px rgba(0, 0, 0, 0.2)")
|
|
87
|
+
)
|
|
88
|
+
.child(StyleRule(".switch-label, .switch-handle")
|
|
89
|
+
.transition("All 0.3s ease")
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export interface ISwitch {
|
|
94
|
+
checked;
|
|
95
|
+
onLabel?: string;
|
|
96
|
+
offLabel?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default function Switch({
|
|
100
|
+
checked,
|
|
101
|
+
onLabel,
|
|
102
|
+
offLabel
|
|
103
|
+
}: ISwitch) {
|
|
104
|
+
|
|
105
|
+
return <label class={css}>
|
|
106
|
+
<input class="switch-input" type="checkbox" checked={checked} />
|
|
107
|
+
<span class="switch-label" data-on={onLabel ?? "On"} data-off={offLabel ?? "Off"}></span>
|
|
108
|
+
<span class="switch-handle"></span>
|
|
109
|
+
</label>;
|
|
110
|
+
}
|
package/src/form/AtomField.tsx
CHANGED
|
@@ -71,21 +71,27 @@ class AtomFieldControl extends AtomControl {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
this.removeAllChildren(this.contentPresenter);
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
74
|
+
const content = this.content;
|
|
75
|
+
if (!content) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
for (const iterator of content) {
|
|
79
|
+
const e = iterator?.element ?? iterator as HTMLElement;
|
|
80
|
+
if (!e) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (typeof e === "string") {
|
|
84
|
+
this.contentPresenter.appendChild(document.createTextNode(e));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.contentPresenter.appendChild(e);
|
|
88
|
+
const input = e.tagName === "INPUT" ? e : e.getElementsByTagName("input")[0];
|
|
89
|
+
if (input) {
|
|
90
|
+
if (!input.id) {
|
|
91
|
+
input.id = `__ID__formElementInput${inputID++}`;
|
|
92
|
+
}
|
|
93
|
+
this.htmlFor = input.id;
|
|
87
94
|
}
|
|
88
|
-
this.htmlFor = input.id;
|
|
89
95
|
}
|
|
90
96
|
break;
|
|
91
97
|
}
|
|
@@ -157,29 +163,15 @@ export interface IFieldAttributes {
|
|
|
157
163
|
visible?;
|
|
158
164
|
fieldClass?;
|
|
159
165
|
baseClass?: IClassOf<AtomFieldControl>;
|
|
166
|
+
[key: string]: any;
|
|
160
167
|
}
|
|
161
168
|
|
|
162
|
-
export default function AtomField({
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
helpLink,
|
|
167
|
-
helpIcon,
|
|
168
|
-
required,
|
|
169
|
-
visible = true,
|
|
170
|
-
fieldClass = null,
|
|
171
|
-
baseClass: controlClass = AtomFieldControl
|
|
172
|
-
}: IFieldAttributes, child: XNode) {
|
|
173
|
-
const ControlClass = controlClass;
|
|
169
|
+
export default function AtomField( attributes: IFieldAttributes, ... children: XNode[]) {
|
|
170
|
+
const ControlClass = attributes.baseClass ?? AtomFieldControl;
|
|
171
|
+
attributes.visible ??= true;
|
|
172
|
+
attributes.fieldClass ??= null;
|
|
174
173
|
return <ControlClass
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
helpIcon={helpIcon}
|
|
178
|
-
helpLink={helpLink}
|
|
179
|
-
helpText={helpText}
|
|
180
|
-
required={required}
|
|
181
|
-
visible={visible}
|
|
182
|
-
fieldClass={fieldClass}
|
|
183
|
-
content={child}
|
|
174
|
+
{ ... attributes}
|
|
175
|
+
content={children}
|
|
184
176
|
/>;
|
|
185
177
|
}
|