cx 24.7.1 → 24.7.2

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.
@@ -1,196 +1,196 @@
1
- import { Widget, VDOM, getContent } from "../../ui/Widget";
2
- import { Overlay, OverlayComponent } from "./Overlay";
3
- import { ContentPlaceholder } from "../../ui/layout/ContentPlaceholder";
4
- import { ZIndexManager } from "../../ui/ZIndexManager";
5
- import { Button } from "../Button";
6
- import { parseStyle } from "../../util/parseStyle";
7
- import { Localization } from "../../ui/Localization";
8
- import { stopPropagation } from "../../util/eventCallbacks";
9
- import { ddMouseDown, ddDetect, ddMouseUp } from "../drag-drop/ops";
10
- import { isDefined } from "../../util/isDefined";
11
- import { isString } from "../../util/isString";
12
-
13
- export class Window extends Overlay {
14
- init() {
15
- if (isDefined(this.closeable)) this.closable = this.closeable;
16
-
17
- if (isString(this.headerStyle)) this.headerStyle = parseStyle(this.headerStyle);
18
-
19
- if (isString(this.footerStyle)) this.footerStyle = parseStyle(this.footerStyle);
20
-
21
- if (isString(this.bodyStyle)) this.bodyStyle = parseStyle(this.bodyStyle);
22
-
23
- super.init();
24
- }
25
-
26
- declareData() {
27
- return super.declareData(...arguments, {
28
- title: undefined,
29
- closable: undefined,
30
- bodyStyle: { structured: true },
31
- bodyClass: { structured: true },
32
- headerStyle: { structured: true },
33
- footerStyle: { structured: true },
34
- });
35
- }
36
-
37
- initHelpers() {
38
- return super.initHelpers(...arguments, {
39
- header: Widget.create(this.header || { type: ContentPlaceholder, name: "header", scoped: true }),
40
- footer: Widget.create(this.footer || { type: ContentPlaceholder, name: "footer", scoped: true }),
41
- close:
42
- this.closable &&
43
- Button.create({
44
- mod: "hollow",
45
- dismiss: true,
46
- icon: "close",
47
- style: "margin-left: auto",
48
- onTouchStart: stopPropagation,
49
- onMouseDown: stopPropagation,
50
- }),
51
- });
52
- }
53
-
54
- exploreCleanup(context, instance) {
55
- super.exploreCleanup(context, instance);
56
-
57
- let { helpers } = instance;
58
- let unregisterHeader = helpers.header && helpers.header.unregisterContentPlaceholder;
59
- if (unregisterHeader) unregisterHeader();
60
-
61
- let unregisterFooter = helpers.footer && helpers.footer.unregisterContentPlaceholder;
62
- if (unregisterFooter) unregisterFooter();
63
- }
64
-
65
- renderHeader(context, instance, key) {
66
- let { data } = instance;
67
- let result = [];
68
- if (data.title) result.push(data.title);
69
- if (instance.helpers) {
70
- let header = getContent(instance.helpers.header && instance.helpers.header.render(context, key));
71
- if (header) result.push(header);
72
- if (data.closable && instance.helpers.close) result.push(getContent(instance.helpers.close.render(context)));
73
- }
74
- return result;
75
- }
76
-
77
- renderFooter(context, instance, key) {
78
- return getContent(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context, key));
79
- }
80
-
81
- render(context, instance, key) {
82
- var header = this.renderHeader(context, instance, "header");
83
- var footer = this.renderFooter(context, instance, "footer");
84
- return (
85
- <WindowComponent key={key} instance={instance} header={header} footer={footer}>
86
- {this.renderContents(context, instance)}
87
- </WindowComponent>
88
- );
89
- }
90
- }
91
-
92
- Window.prototype.baseClass = "window";
93
- Window.prototype.closable = true;
94
- Window.prototype.resizable = false;
95
- Window.prototype.fixed = false;
96
- Window.prototype.autoFocus = true;
97
- Window.prototype.focusable = true;
98
- Window.prototype.pad = true;
99
-
100
- Widget.alias("window", Window);
101
- Localization.registerPrototype("cx/widgets/Window", Window);
102
-
103
- class WindowComponent extends OverlayComponent {
104
- renderOverlayBody() {
105
- var { widget, data } = this.props.instance;
106
- var { CSS, baseClass } = widget;
107
-
108
- let header, footer;
109
-
110
- if (this.props.header.length > 0) {
111
- header = (
112
- <header
113
- key="header"
114
- ref={(c) => {
115
- this.headerEl = c;
116
- }}
117
- className={CSS.element(baseClass, "header")}
118
- style={data.headerStyle}
119
- onMouseDown={this.onHeaderMouseDown.bind(this)}
120
- onMouseUp={ddMouseUp}
121
- onMouseMove={this.onHeaderMouseMove.bind(this)}
122
- onTouchStart={this.onHeaderMouseDown.bind(this)}
123
- onTouchEnd={ddMouseUp}
124
- onTouchMove={this.onHeaderMouseMove.bind(this)}
125
- >
126
- {this.props.header}
127
- </header>
128
- );
129
- }
130
-
131
- if (this.props.footer) {
132
- footer = (
133
- <footer
134
- key="footer"
135
- ref={(c) => {
136
- this.footerEl = c;
137
- }}
138
- className={CSS.element(baseClass, "footer")}
139
- style={data.footerStyle}
140
- >
141
- {this.props.footer}
142
- </footer>
143
- );
144
- }
145
-
146
- var body = (
147
- <div
148
- key="body"
149
- ref={(c) => {
150
- this.bodyEl = c;
151
- }}
152
- className={CSS.expand(CSS.element(widget.baseClass, "body", { pad: widget.pad }), data.bodyClass)}
153
- style={data.bodyStyle}
154
- >
155
- {this.props.children}
156
- </div>
157
- );
158
-
159
- return [header, body, footer];
160
- }
161
-
162
- getOverlayCssClass() {
163
- var cls = super.getOverlayCssClass();
164
- if (this.state.active) cls += " cxs-active";
165
- return cls;
166
- }
167
-
168
- onFocusIn() {
169
- super.onFocusIn();
170
- if (!this.state.active) {
171
- if (this.containerEl.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
172
- this.setState({ active: true });
173
- }
174
- }
175
-
176
- onFocusOut() {
177
- super.onFocusOut();
178
- if (this.state.active) {
179
- this.setState({
180
- active: false,
181
- });
182
- }
183
- }
184
-
185
- onHeaderMouseDown(e) {
186
- e.stopPropagation();
187
- ddMouseDown(e);
188
- }
189
-
190
- onHeaderMouseMove(e) {
191
- e.stopPropagation();
192
- if (!this.props.instance.widget.fixed && ddDetect(e)) {
193
- this.startMoveOperation(e);
194
- }
195
- }
196
- }
1
+ import { Widget, VDOM, getContent } from "../../ui/Widget";
2
+ import { Overlay, OverlayComponent } from "./Overlay";
3
+ import { ContentPlaceholder } from "../../ui/layout/ContentPlaceholder";
4
+ import { ZIndexManager } from "../../ui/ZIndexManager";
5
+ import { Button } from "../Button";
6
+ import { parseStyle } from "../../util/parseStyle";
7
+ import { Localization } from "../../ui/Localization";
8
+ import { stopPropagation } from "../../util/eventCallbacks";
9
+ import { ddMouseDown, ddDetect, ddMouseUp } from "../drag-drop/ops";
10
+ import { isDefined } from "../../util/isDefined";
11
+ import { isString } from "../../util/isString";
12
+
13
+ export class Window extends Overlay {
14
+ init() {
15
+ if (isDefined(this.closeable)) this.closable = this.closeable;
16
+
17
+ if (isString(this.headerStyle)) this.headerStyle = parseStyle(this.headerStyle);
18
+
19
+ if (isString(this.footerStyle)) this.footerStyle = parseStyle(this.footerStyle);
20
+
21
+ if (isString(this.bodyStyle)) this.bodyStyle = parseStyle(this.bodyStyle);
22
+
23
+ super.init();
24
+ }
25
+
26
+ declareData() {
27
+ return super.declareData(...arguments, {
28
+ title: undefined,
29
+ closable: undefined,
30
+ bodyStyle: { structured: true },
31
+ bodyClass: { structured: true },
32
+ headerStyle: { structured: true },
33
+ footerStyle: { structured: true },
34
+ });
35
+ }
36
+
37
+ initHelpers() {
38
+ return super.initHelpers(...arguments, {
39
+ header: Widget.create(this.header || { type: ContentPlaceholder, name: "header", scoped: true }),
40
+ footer: Widget.create(this.footer || { type: ContentPlaceholder, name: "footer", scoped: true }),
41
+ close:
42
+ this.closable &&
43
+ Button.create({
44
+ mod: "hollow",
45
+ dismiss: true,
46
+ icon: "close",
47
+ style: "margin-left: auto",
48
+ onTouchStart: stopPropagation,
49
+ onMouseDown: stopPropagation,
50
+ }),
51
+ });
52
+ }
53
+
54
+ exploreCleanup(context, instance) {
55
+ super.exploreCleanup(context, instance);
56
+
57
+ let { helpers } = instance;
58
+ let unregisterHeader = helpers.header && helpers.header.unregisterContentPlaceholder;
59
+ if (unregisterHeader) unregisterHeader();
60
+
61
+ let unregisterFooter = helpers.footer && helpers.footer.unregisterContentPlaceholder;
62
+ if (unregisterFooter) unregisterFooter();
63
+ }
64
+
65
+ renderHeader(context, instance, key) {
66
+ let { data } = instance;
67
+ let result = [];
68
+ if (data.title) result.push(data.title);
69
+ if (instance.helpers) {
70
+ let header = getContent(instance.helpers.header && instance.helpers.header.render(context, key));
71
+ if (header) result.push(header);
72
+ if (data.closable && instance.helpers.close) result.push(getContent(instance.helpers.close.render(context)));
73
+ }
74
+ return result;
75
+ }
76
+
77
+ renderFooter(context, instance, key) {
78
+ return getContent(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context, key));
79
+ }
80
+
81
+ render(context, instance, key) {
82
+ var header = this.renderHeader(context, instance, "header");
83
+ var footer = this.renderFooter(context, instance, "footer");
84
+ return (
85
+ <WindowComponent key={key} instance={instance} header={header} footer={footer}>
86
+ {this.renderContents(context, instance)}
87
+ </WindowComponent>
88
+ );
89
+ }
90
+ }
91
+
92
+ Window.prototype.baseClass = "window";
93
+ Window.prototype.closable = true;
94
+ Window.prototype.resizable = false;
95
+ Window.prototype.fixed = false;
96
+ Window.prototype.autoFocus = true;
97
+ Window.prototype.focusable = true;
98
+ Window.prototype.pad = true;
99
+
100
+ Widget.alias("window", Window);
101
+ Localization.registerPrototype("cx/widgets/Window", Window);
102
+
103
+ class WindowComponent extends OverlayComponent {
104
+ renderOverlayBody() {
105
+ var { widget, data } = this.props.instance;
106
+ var { CSS, baseClass } = widget;
107
+
108
+ let header, footer;
109
+
110
+ if (this.props.header.length > 0) {
111
+ header = (
112
+ <header
113
+ key="header"
114
+ ref={(c) => {
115
+ this.headerEl = c;
116
+ }}
117
+ className={CSS.element(baseClass, "header")}
118
+ style={data.headerStyle}
119
+ onMouseDown={this.onHeaderMouseDown.bind(this)}
120
+ onMouseUp={ddMouseUp}
121
+ onMouseMove={this.onHeaderMouseMove.bind(this)}
122
+ onTouchStart={this.onHeaderMouseDown.bind(this)}
123
+ onTouchEnd={ddMouseUp}
124
+ onTouchMove={this.onHeaderMouseMove.bind(this)}
125
+ >
126
+ {this.props.header}
127
+ </header>
128
+ );
129
+ }
130
+
131
+ if (this.props.footer) {
132
+ footer = (
133
+ <footer
134
+ key="footer"
135
+ ref={(c) => {
136
+ this.footerEl = c;
137
+ }}
138
+ className={CSS.element(baseClass, "footer")}
139
+ style={data.footerStyle}
140
+ >
141
+ {this.props.footer}
142
+ </footer>
143
+ );
144
+ }
145
+
146
+ var body = (
147
+ <div
148
+ key="body"
149
+ ref={(c) => {
150
+ this.bodyEl = c;
151
+ }}
152
+ className={CSS.expand(CSS.element(widget.baseClass, "body", { pad: widget.pad }), data.bodyClass)}
153
+ style={data.bodyStyle}
154
+ >
155
+ {this.props.children}
156
+ </div>
157
+ );
158
+
159
+ return [header, body, footer];
160
+ }
161
+
162
+ getOverlayCssClass() {
163
+ var cls = super.getOverlayCssClass();
164
+ if (this.state.active) cls += " cxs-active";
165
+ return cls;
166
+ }
167
+
168
+ onFocusIn() {
169
+ super.onFocusIn();
170
+ if (!this.state.active) {
171
+ if (this.containerEl.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
172
+ this.setState({ active: true });
173
+ }
174
+ }
175
+
176
+ onFocusOut() {
177
+ super.onFocusOut();
178
+ if (this.state.active) {
179
+ this.setState({
180
+ active: false,
181
+ });
182
+ }
183
+ }
184
+
185
+ onHeaderMouseDown(e) {
186
+ e.stopPropagation();
187
+ ddMouseDown(e);
188
+ }
189
+
190
+ onHeaderMouseMove(e) {
191
+ e.stopPropagation();
192
+ if (!this.props.instance.widget.fixed && ddDetect(e)) {
193
+ this.startMoveOperation(e);
194
+ }
195
+ }
196
+ }
@@ -1,83 +1,83 @@
1
- // TOOLTIP
2
- $cx-tooltip-background-color: white !default;
3
- $cx-tooltip-border-color: #d5d5d5 !default;
4
- $cx-tooltip-border-width: 1px !default;
5
- $cx-tooltip-border-radius: 5px !default;
6
- $cx-tooltip-arrow-size: 5px !default;
7
- $cx-tooltip-color: null !default;
8
- $cx-tooltip-padding: 10px !default;
9
-
10
- $cx-tooltip-background-color-error: white !default;
11
- $cx-tooltip-border-color-error: #e63001 !default;
12
- $cx-tooltip-color-error: null !default;
13
-
14
- // DROPDOWN
15
- $cx-default-dropdown-color: $cx-default-color !default;
16
- $cx-default-dropdown-background-color: white !default;
17
- $cx-default-dropdown-arrow-size: 6px !default;
18
- $cx-default-dropdown-arrow-offset: 16px !default;
19
-
20
- $cx-dropdown-styles: (
21
- color: $cx-default-dropdown-color,
22
- background-color: $cx-default-dropdown-background-color,
23
- border-radius: $cx-default-border-radius,
24
- border-color: $cx-default-border-color,
25
- border-width: 0,
26
- box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.29),
27
- white-space: normal,
28
- font-weight: normal,
29
- font-size: $cx-default-font-size,
30
- text-align: left,
31
- line-height: normal,
32
- ) !default;
33
-
34
- // TOAST
35
- $cx-default-toast-color: $cx-default-color !default;
36
- $cx-default-toast-background-color: rgb(255, 255, 255) !default;
37
- $cx-default-toast-border-width: 0 !default;
38
- $cx-default-toast-border-color: rgba(255, 255, 255, 0) !default;
39
- $cx-default-toast-box-shadow: 0 0 5px 1px rgba(128, 128, 128, 0.3) !default;
40
- $cx-default-toast-padding: 10px !default;
41
-
42
- $cx-toast-mods: (
43
- warning: (
44
- default: (
45
- color: #fff,
46
- background-color: #f09037,
47
- ),
48
- ),
49
- primary: (
50
- default: (
51
- color: #fff,
52
- background-color: #1f99f8,
53
- ),
54
- ),
55
- success: (
56
- default: (
57
- color: #fff,
58
- background-color: #5cb85c,
59
- ),
60
- ),
61
- error: (
62
- default: (
63
- color: #fff,
64
- background-color: #d9534f,
65
- ),
66
- ),
67
- ) !default;
68
-
69
- // WINDOW
70
- @import "Window.variables";
71
-
72
- $cx-dependencies: map-merge(
73
- $cx-dependencies,
74
- (
75
- "cx/widgets/Overlay": "cx/widgets/captureMouse",
76
- "cx/widgets/Dropdown": "cx/widgets/Overlay",
77
- "cx/widgets/Window": "cx/widgets/Overlay",
78
- "cx/widgets/Tooltip": "cx/widgets/Dropdown",
79
- "cx/widgets/enableMsgBoxAlerts": "cx/widgets/MsgBox",
80
- "cx/widgets/MsgBox": "cx/widgets/Window" "cx/widgets/FlexRow",
81
- "cx/widgets/Toast": "cx/widgets/Overlay",
82
- )
83
- );
1
+ // TOOLTIP
2
+ $cx-tooltip-background-color: white !default;
3
+ $cx-tooltip-border-color: #d5d5d5 !default;
4
+ $cx-tooltip-border-width: 1px !default;
5
+ $cx-tooltip-border-radius: 5px !default;
6
+ $cx-tooltip-arrow-size: 5px !default;
7
+ $cx-tooltip-color: null !default;
8
+ $cx-tooltip-padding: 10px !default;
9
+
10
+ $cx-tooltip-background-color-error: white !default;
11
+ $cx-tooltip-border-color-error: #e63001 !default;
12
+ $cx-tooltip-color-error: null !default;
13
+
14
+ // DROPDOWN
15
+ $cx-default-dropdown-color: $cx-default-color !default;
16
+ $cx-default-dropdown-background-color: white !default;
17
+ $cx-default-dropdown-arrow-size: 6px !default;
18
+ $cx-default-dropdown-arrow-offset: 16px !default;
19
+
20
+ $cx-dropdown-styles: (
21
+ color: $cx-default-dropdown-color,
22
+ background-color: $cx-default-dropdown-background-color,
23
+ border-radius: $cx-default-border-radius,
24
+ border-color: $cx-default-border-color,
25
+ border-width: 0,
26
+ box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.29),
27
+ white-space: normal,
28
+ font-weight: normal,
29
+ font-size: $cx-default-font-size,
30
+ text-align: left,
31
+ line-height: normal,
32
+ ) !default;
33
+
34
+ // TOAST
35
+ $cx-default-toast-color: $cx-default-color !default;
36
+ $cx-default-toast-background-color: rgb(255, 255, 255) !default;
37
+ $cx-default-toast-border-width: 0 !default;
38
+ $cx-default-toast-border-color: rgba(255, 255, 255, 0) !default;
39
+ $cx-default-toast-box-shadow: 0 0 5px 1px rgba(128, 128, 128, 0.3) !default;
40
+ $cx-default-toast-padding: 10px !default;
41
+
42
+ $cx-toast-mods: (
43
+ warning: (
44
+ default: (
45
+ color: #fff,
46
+ background-color: #f09037,
47
+ ),
48
+ ),
49
+ primary: (
50
+ default: (
51
+ color: #fff,
52
+ background-color: #1f99f8,
53
+ ),
54
+ ),
55
+ success: (
56
+ default: (
57
+ color: #fff,
58
+ background-color: #5cb85c,
59
+ ),
60
+ ),
61
+ error: (
62
+ default: (
63
+ color: #fff,
64
+ background-color: #d9534f,
65
+ ),
66
+ ),
67
+ ) !default;
68
+
69
+ // WINDOW
70
+ @import "Window.variables";
71
+
72
+ $cx-dependencies: map-merge(
73
+ $cx-dependencies,
74
+ (
75
+ "cx/widgets/Overlay": "cx/widgets/captureMouse",
76
+ "cx/widgets/Dropdown": "cx/widgets/Overlay",
77
+ "cx/widgets/Window": "cx/widgets/Overlay",
78
+ "cx/widgets/Tooltip": "cx/widgets/Dropdown",
79
+ "cx/widgets/enableMsgBoxAlerts": "cx/widgets/MsgBox",
80
+ "cx/widgets/MsgBox": "cx/widgets/Window" "cx/widgets/FlexRow",
81
+ "cx/widgets/Toast": "cx/widgets/Overlay",
82
+ )
83
+ );