@web-atoms/web-controls 2.1.2 → 2.1.6
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/auto-complete/AutoCompleteBox.js.map +1 -1
- 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 +16 -0
- package/dist/basic/PopupButton.d.ts.map +1 -0
- package/dist/basic/PopupButton.js +118 -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/calendar/res/SRCalendar.js +1 -1
- package/dist/calendar/res/SRCalendar.js.map +1 -1
- package/dist/data-grid/AtomDataGrid.js +2 -2
- package/dist/data-grid/AtomDataGrid.js.map +1 -1
- 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/dist/mobile/pages/PageFrameViewModel.js +1 -1
- package/dist/mobile/pages/PageFrameViewModel.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 +132 -0
- package/src/basic/Switch.tsx +110 -0
- package/src/basic/combineClasses.ts +3 -0
- package/src/form/AtomField.tsx +25 -33
|
@@ -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
|
}
|