cx 26.0.4 → 26.0.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/build/data/ArrayElementView.spec.js +1 -1
- package/build/hooks/store.spec.js +1 -1
- package/build/hooks/useTrigger.spec.js +1 -1
- package/build/ui/Controller.spec.js +6 -2
- package/build/ui/app/startAppLoop.d.ts +3 -2
- package/build/ui/app/startHotAppLoop.d.ts +3 -2
- package/build/ui/layout/ContentPlaceholder.spec.js +12 -12
- package/build.js +129 -129
- package/dist/manifest.js +844 -844
- package/package.json +3 -2
- package/src/charts/Chart.ts +108 -108
- package/src/data/ArrayElementView.ts +90 -90
- package/src/data/AugmentedViewBase.ts +88 -88
- package/src/data/Binding.ts +104 -104
- package/src/data/ExposedRecordView.ts +95 -95
- package/src/data/ExposedValueView.ts +89 -89
- package/src/data/Expression.spec.ts +229 -229
- package/src/data/Expression.ts +233 -233
- package/src/data/Grouper.spec.ts +57 -57
- package/src/data/Grouper.ts +158 -158
- package/src/data/NestedDataView.ts +43 -43
- package/src/data/ReadOnlyDataView.ts +39 -39
- package/src/data/Ref.ts +104 -104
- package/src/data/Selector.ts +10 -10
- package/src/data/Store.ts +52 -52
- package/src/data/StoreProxy.ts +19 -19
- package/src/data/StoreRef.ts +66 -66
- package/src/data/StringTemplate.spec.ts +132 -132
- package/src/data/StringTemplate.ts +93 -93
- package/src/data/StructuredSelector.spec.ts +113 -113
- package/src/data/StructuredSelector.ts +146 -146
- package/src/data/SubscribableView.ts +63 -63
- package/src/data/ZoomIntoPropertyView.spec.ts +64 -64
- package/src/data/ZoomIntoPropertyView.ts +45 -45
- package/src/data/computable.spec.ts +62 -62
- package/src/data/createAccessorModelProxy.ts +60 -60
- package/src/data/createStructuredSelector.ts +62 -62
- package/src/data/getAccessor.spec.ts +11 -11
- package/src/data/getAccessor.ts +74 -74
- package/src/data/getSelector.spec.ts +43 -43
- package/src/data/getSelector.ts +66 -66
- package/src/data/ops/filter.spec.ts +35 -35
- package/src/data/ops/filter.ts +9 -9
- package/src/data/ops/merge.ts +13 -13
- package/src/data/ops/removeTreeNodes.spec.ts +37 -37
- package/src/data/ops/removeTreeNodes.ts +15 -15
- package/src/data/ops/updateArray.spec.ts +69 -69
- package/src/data/ops/updateArray.ts +31 -31
- package/src/data/ops/updateTree.ts +23 -23
- package/src/data/test-types.ts +7 -7
- package/src/hooks/useTrigger.ts +26 -26
- package/src/index.scss +6 -6
- package/src/jsx-runtime.ts +72 -72
- package/src/svg/BoundedObject.ts +101 -101
- package/src/ui/CSSHelper.ts +17 -17
- package/src/ui/ContentResolver.ts +124 -124
- package/src/ui/Controller.ts +189 -189
- package/src/ui/Culture.ts +159 -159
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/FocusManager.ts +171 -171
- package/src/ui/Instance.ts +868 -868
- package/src/ui/RenderingContext.ts +99 -99
- package/src/ui/Rescope.ts +49 -49
- package/src/ui/StructuredInstanceDataAccessor.ts +32 -32
- package/src/ui/VDOM.ts +34 -34
- package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
- package/src/ui/adapter/ArrayAdapter.ts +226 -226
- package/src/ui/adapter/TreeAdapter.spec.ts +76 -76
- package/src/ui/adapter/TreeAdapter.ts +185 -185
- package/src/ui/app/History.ts +133 -133
- package/src/ui/app/Url.spec.ts +50 -50
- package/src/ui/app/startAppLoop.tsx +2 -1
- package/src/ui/app/startHotAppLoop.ts +2 -1
- package/src/ui/createFunctionalComponent.ts +65 -65
- package/src/ui/index.ts +45 -45
- package/src/ui/layout/Content.ts +30 -30
- package/src/ui/layout/FirstVisibleChildLayout.ts +60 -60
- package/src/ui/selection/KeySelection.ts +165 -165
- package/src/ui/selection/PropertySelection.ts +87 -87
- package/src/ui/selection/Selection.ts +118 -118
- package/src/util/Format.ts +267 -267
- package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
- package/src/util/color/rgbToHsl.ts +35 -35
- package/src/util/getActiveElement.ts +4 -4
- package/src/util/hasKey.ts +18 -18
- package/src/util/index.ts +55 -55
- package/src/util/innerTextTrim.ts +10 -10
- package/src/util/isArray.ts +3 -3
- package/src/util/isDataRecord.ts +5 -5
- package/src/util/isDefined.ts +3 -3
- package/src/util/isString.ts +3 -3
- package/src/widgets/Sandbox.ts +103 -103
- package/src/widgets/autoFocus.ts +9 -9
- package/src/widgets/cx.ts +63 -63
- package/src/widgets/drag-drop/ops.tsx +1 -1
- package/src/widgets/grid/GridCell.ts +143 -143
- package/src/widgets/icons/calendar.tsx +17 -17
- package/src/widgets/icons/check.tsx +13 -13
- package/src/widgets/icons/clear.tsx +15 -15
- package/src/widgets/icons/close.tsx +20 -20
- package/src/widgets/icons/cx.tsx +38 -38
- package/src/widgets/icons/drop-down.tsx +15 -15
- package/src/widgets/icons/file.tsx +13 -13
- package/src/widgets/icons/folder-open.tsx +15 -15
- package/src/widgets/icons/folder.tsx +13 -13
- package/src/widgets/icons/forward.tsx +22 -22
- package/src/widgets/icons/loading.tsx +24 -24
- package/src/widgets/icons/menu.tsx +17 -17
- package/src/widgets/icons/pixel-picker.tsx +18 -18
- package/src/widgets/icons/search.tsx +13 -13
- package/src/widgets/icons/sort-asc.tsx +14 -14
- package/src/widgets/icons/square.tsx +18 -18
- package/src/widgets/nav/Route.ts +142 -142
- package/src/widgets/overlay/ContextMenu.ts +42 -42
- package/src/widgets/overlay/Dropdown.tsx +762 -762
- package/src/widgets/overlay/MsgBox.tsx +141 -141
- package/src/widgets/overlay/Toast.ts +111 -111
- package/src/widgets/overlay/Window.tsx +299 -299
- package/src/widgets/overlay/alerts.ts +46 -46
- package/src/widgets/overlay/captureMouse.ts +195 -195
- package/src/widgets/overlay/createHotPromiseWindowFactory.ts +72 -72
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.ts +11 -11
- package/src/widgets/overlay/tooltip-ops.ts +173 -173
- package/build/ui/PureContainer.spec.d.ts +0 -1
- package/build/ui/PureContainer.spec.js +0 -149
- package/dist/manifest.d.ts +0 -1443
|
@@ -1,299 +1,299 @@
|
|
|
1
|
-
/** @jsxImportSource react */
|
|
2
|
-
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
3
|
-
import {
|
|
4
|
-
Overlay,
|
|
5
|
-
OverlayBase,
|
|
6
|
-
OverlayComponent,
|
|
7
|
-
OverlayComponentProps,
|
|
8
|
-
OverlayComponentState,
|
|
9
|
-
OverlayConfig,
|
|
10
|
-
OverlayInstance,
|
|
11
|
-
} from "./Overlay";
|
|
12
|
-
import { ContentPlaceholder, ContentPlaceholderInstance } from "../../ui/layout/ContentPlaceholder";
|
|
13
|
-
import { ZIndexManager } from "../../ui/ZIndexManager";
|
|
14
|
-
import { Button } from "../Button";
|
|
15
|
-
import { parseStyle } from "../../util/parseStyle";
|
|
16
|
-
import { Localization } from "../../ui/Localization";
|
|
17
|
-
import { stopPropagation } from "../../util/eventCallbacks";
|
|
18
|
-
import { ddMouseDown, ddDetect, ddMouseUp } from "../drag-drop/ops";
|
|
19
|
-
import { isDefined } from "../../util/isDefined";
|
|
20
|
-
import { isString } from "../../util/isString";
|
|
21
|
-
import { BooleanProp, StringProp, StyleProp, ClassProp } from "../../ui/Prop";
|
|
22
|
-
import { RenderingContext } from "../../ui/RenderingContext";
|
|
23
|
-
|
|
24
|
-
export interface WindowConfig extends OverlayConfig {
|
|
25
|
-
/** Text to be displayed in the header. */
|
|
26
|
-
title?: StringProp;
|
|
27
|
-
|
|
28
|
-
/** Controls the close button visibility. Defaults to `true`. */
|
|
29
|
-
closable?: BooleanProp;
|
|
30
|
-
|
|
31
|
-
/** A custom style which will be applied to the body. */
|
|
32
|
-
bodyStyle?: StyleProp;
|
|
33
|
-
|
|
34
|
-
/** A custom style which will be applied to the header. */
|
|
35
|
-
headerStyle?: StyleProp;
|
|
36
|
-
|
|
37
|
-
/** A custom style which will be applied to the footer. */
|
|
38
|
-
footerStyle?: StyleProp;
|
|
39
|
-
|
|
40
|
-
/** Base CSS class to be applied to the field. Defaults to `window`. */
|
|
41
|
-
baseClass?: string;
|
|
42
|
-
|
|
43
|
-
/** Additional CSS class to be applied to the section body. */
|
|
44
|
-
bodyClass?: ClassProp;
|
|
45
|
-
|
|
46
|
-
/** Set to `true` to enable resizing. */
|
|
47
|
-
resizable?: boolean;
|
|
48
|
-
|
|
49
|
-
/** Set to `true` to automatically focus the field, after it renders for the first time. */
|
|
50
|
-
autoFocus?: boolean;
|
|
51
|
-
|
|
52
|
-
/** Set to `false` to prevent the window itself to be focusable. Default value is true.*/
|
|
53
|
-
focusable?: boolean;
|
|
54
|
-
|
|
55
|
-
/** Set to `true` to disable moving the window by dragging the header. */
|
|
56
|
-
fixed?: boolean;
|
|
57
|
-
|
|
58
|
-
/** Set to `true` to add default padding to the window body. */
|
|
59
|
-
pad?: boolean;
|
|
60
|
-
|
|
61
|
-
/** Optional header widget. */
|
|
62
|
-
header?: any;
|
|
63
|
-
|
|
64
|
-
/** Optional footer widget. */
|
|
65
|
-
footer?: any;
|
|
66
|
-
|
|
67
|
-
/** Custom event handler for closeable. */
|
|
68
|
-
closeable?: BooleanProp;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class WindowInstance extends OverlayInstance<Window> {
|
|
72
|
-
headerEl?: HTMLElement;
|
|
73
|
-
footerEl?: HTMLElement;
|
|
74
|
-
bodyEl?: HTMLElement;
|
|
75
|
-
containerEl?: HTMLElement;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export class Window extends OverlayBase<WindowConfig, WindowInstance> {
|
|
79
|
-
declare closable?: BooleanProp;
|
|
80
|
-
declare closeable?: BooleanProp;
|
|
81
|
-
declare resizable?: boolean;
|
|
82
|
-
declare fixed?: boolean;
|
|
83
|
-
declare autoFocus?: boolean;
|
|
84
|
-
declare focusable?: boolean;
|
|
85
|
-
declare pad?: boolean;
|
|
86
|
-
declare bodyStyle?: StyleProp;
|
|
87
|
-
declare headerStyle?: StyleProp;
|
|
88
|
-
declare footerStyle?: StyleProp;
|
|
89
|
-
declare bodyClass?: ClassProp;
|
|
90
|
-
declare title?: StringProp;
|
|
91
|
-
declare header?: any;
|
|
92
|
-
declare footer?: any;
|
|
93
|
-
declare baseClass: string;
|
|
94
|
-
|
|
95
|
-
init() {
|
|
96
|
-
if (isDefined(this.closeable)) this.closable = this.closeable;
|
|
97
|
-
|
|
98
|
-
if (isString(this.headerStyle)) this.headerStyle = parseStyle(this.headerStyle);
|
|
99
|
-
|
|
100
|
-
if (isString(this.footerStyle)) this.footerStyle = parseStyle(this.footerStyle);
|
|
101
|
-
|
|
102
|
-
if (isString(this.bodyStyle)) this.bodyStyle = parseStyle(this.bodyStyle);
|
|
103
|
-
|
|
104
|
-
super.init();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
declareData(...args: any) {
|
|
108
|
-
return super.declareData(...args, {
|
|
109
|
-
title: undefined,
|
|
110
|
-
closable: undefined,
|
|
111
|
-
bodyStyle: { structured: true },
|
|
112
|
-
bodyClass: { structured: true },
|
|
113
|
-
headerStyle: { structured: true },
|
|
114
|
-
footerStyle: { structured: true },
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
initHelpers(...args: any) {
|
|
119
|
-
return super.initHelpers(...args, {
|
|
120
|
-
header: Widget.create(this.header || { type: ContentPlaceholder, name: "header", scoped: true }),
|
|
121
|
-
footer: Widget.create(this.footer || { type: ContentPlaceholder, name: "footer", scoped: true }),
|
|
122
|
-
close:
|
|
123
|
-
this.closable &&
|
|
124
|
-
Button.create({
|
|
125
|
-
mod: "hollow",
|
|
126
|
-
dismiss: true,
|
|
127
|
-
icon: "close",
|
|
128
|
-
style: "margin-left: auto",
|
|
129
|
-
onTouchStart: stopPropagation,
|
|
130
|
-
onMouseDown: stopPropagation,
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
exploreCleanup(context: RenderingContext, instance: WindowInstance): void {
|
|
136
|
-
super.exploreCleanup(context, instance);
|
|
137
|
-
|
|
138
|
-
let { helpers } = instance;
|
|
139
|
-
let unregisterHeader =
|
|
140
|
-
helpers!.header && (helpers!.header as ContentPlaceholderInstance).unregisterContentPlaceholder;
|
|
141
|
-
if (unregisterHeader) unregisterHeader();
|
|
142
|
-
|
|
143
|
-
let unregisterFooter =
|
|
144
|
-
helpers!.footer && (helpers!.footer as ContentPlaceholderInstance).unregisterContentPlaceholder;
|
|
145
|
-
if (unregisterFooter) unregisterFooter();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
renderHeader(context: RenderingContext, instance: WindowInstance, key: string): any[] {
|
|
149
|
-
let { data } = instance;
|
|
150
|
-
let result = [];
|
|
151
|
-
if (data.title) result.push(data.title);
|
|
152
|
-
if (instance.helpers) {
|
|
153
|
-
let header = getContent(instance.helpers.header && instance.helpers.header.render(context));
|
|
154
|
-
if (header) result.push(header);
|
|
155
|
-
if (data.closable && instance.helpers.close) result.push(getContent(instance.helpers.close.render(context)));
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
renderFooter(context: RenderingContext, instance: WindowInstance, key: string): any {
|
|
161
|
-
return getContent(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
render(context: RenderingContext, instance: WindowInstance, key: string): any {
|
|
165
|
-
var header = this.renderHeader(context, instance, "header");
|
|
166
|
-
var footer = this.renderFooter(context, instance, "footer");
|
|
167
|
-
return (
|
|
168
|
-
<WindowComponent
|
|
169
|
-
key={key}
|
|
170
|
-
instance={instance}
|
|
171
|
-
header={header}
|
|
172
|
-
footer={footer}
|
|
173
|
-
subscribeToBeforeDismiss={context.options.subscribeToBeforeDismiss}
|
|
174
|
-
>
|
|
175
|
-
{this.renderContents(context, instance)}
|
|
176
|
-
</WindowComponent>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
Window.prototype.baseClass = "window";
|
|
182
|
-
Window.prototype.closable = true;
|
|
183
|
-
Window.prototype.resizable = false;
|
|
184
|
-
Window.prototype.fixed = false;
|
|
185
|
-
Window.prototype.autoFocus = true;
|
|
186
|
-
Window.prototype.focusable = true;
|
|
187
|
-
Window.prototype.pad = true;
|
|
188
|
-
|
|
189
|
-
Widget.alias("window", Window);
|
|
190
|
-
Localization.registerPrototype("cx/widgets/Window", Window);
|
|
191
|
-
|
|
192
|
-
interface WindowComponentProps extends OverlayComponentProps {
|
|
193
|
-
header: any[];
|
|
194
|
-
footer: any;
|
|
195
|
-
instance: WindowInstance;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
interface WindowComponentState extends OverlayComponentState {
|
|
199
|
-
active?: boolean;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
class WindowComponent extends OverlayComponent<WindowComponentProps, WindowComponentState> {
|
|
203
|
-
headerEl?: HTMLElement | null;
|
|
204
|
-
footerEl?: HTMLElement | null;
|
|
205
|
-
bodyEl?: HTMLElement | null;
|
|
206
|
-
|
|
207
|
-
renderOverlayBody() {
|
|
208
|
-
var { widget, data } = this.props.instance;
|
|
209
|
-
var { CSS, baseClass, pad } = widget;
|
|
210
|
-
|
|
211
|
-
let header, footer;
|
|
212
|
-
|
|
213
|
-
if (this.props.header.length > 0) {
|
|
214
|
-
header = (
|
|
215
|
-
<header
|
|
216
|
-
key="header"
|
|
217
|
-
ref={(c) => {
|
|
218
|
-
this.headerEl = c;
|
|
219
|
-
}}
|
|
220
|
-
className={CSS.element(baseClass, "header")}
|
|
221
|
-
style={data.headerStyle}
|
|
222
|
-
onMouseDown={this.onHeaderMouseDown.bind(this)}
|
|
223
|
-
onMouseUp={ddMouseUp}
|
|
224
|
-
onMouseMove={this.onHeaderMouseMove.bind(this)}
|
|
225
|
-
onTouchStart={this.onHeaderMouseDown.bind(this)}
|
|
226
|
-
onTouchEnd={ddMouseUp}
|
|
227
|
-
onTouchMove={this.onHeaderMouseMove.bind(this)}
|
|
228
|
-
>
|
|
229
|
-
{this.props.header}
|
|
230
|
-
</header>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (this.props.footer) {
|
|
235
|
-
footer = (
|
|
236
|
-
<footer
|
|
237
|
-
key="footer"
|
|
238
|
-
ref={(c) => {
|
|
239
|
-
this.footerEl = c;
|
|
240
|
-
}}
|
|
241
|
-
className={CSS.element(baseClass, "footer")}
|
|
242
|
-
style={data.footerStyle}
|
|
243
|
-
>
|
|
244
|
-
{this.props.footer}
|
|
245
|
-
</footer>
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var body = (
|
|
250
|
-
<div
|
|
251
|
-
key="body"
|
|
252
|
-
ref={(c) => {
|
|
253
|
-
this.bodyEl = c;
|
|
254
|
-
}}
|
|
255
|
-
className={CSS.expand(CSS.element(baseClass, "body", { pad }), data.bodyClass)}
|
|
256
|
-
style={data.bodyStyle}
|
|
257
|
-
>
|
|
258
|
-
{this.props.children}
|
|
259
|
-
</div>
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
return [header, body, footer];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
getOverlayCssClass() {
|
|
266
|
-
var cls = super.getOverlayCssClass();
|
|
267
|
-
if (this.state.active) cls += " cxs-active";
|
|
268
|
-
return cls;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
onFocusIn() {
|
|
272
|
-
super.onFocusIn();
|
|
273
|
-
if (!this.state.active) {
|
|
274
|
-
if (this.containerEl!.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
|
|
275
|
-
this.setState({ active: true });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
onFocusOut() {
|
|
280
|
-
super.onFocusOut();
|
|
281
|
-
if (this.state.active) {
|
|
282
|
-
this.setState({
|
|
283
|
-
active: false,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
onHeaderMouseDown(e: any) {
|
|
289
|
-
e.stopPropagation();
|
|
290
|
-
ddMouseDown(e);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
onHeaderMouseMove(e: any) {
|
|
294
|
-
e.stopPropagation();
|
|
295
|
-
if (!(this.props.instance.widget as Window).fixed && ddDetect(e)) {
|
|
296
|
-
this.startMoveOperation(e);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
1
|
+
/** @jsxImportSource react */
|
|
2
|
+
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
3
|
+
import {
|
|
4
|
+
Overlay,
|
|
5
|
+
OverlayBase,
|
|
6
|
+
OverlayComponent,
|
|
7
|
+
OverlayComponentProps,
|
|
8
|
+
OverlayComponentState,
|
|
9
|
+
OverlayConfig,
|
|
10
|
+
OverlayInstance,
|
|
11
|
+
} from "./Overlay";
|
|
12
|
+
import { ContentPlaceholder, ContentPlaceholderInstance } from "../../ui/layout/ContentPlaceholder";
|
|
13
|
+
import { ZIndexManager } from "../../ui/ZIndexManager";
|
|
14
|
+
import { Button } from "../Button";
|
|
15
|
+
import { parseStyle } from "../../util/parseStyle";
|
|
16
|
+
import { Localization } from "../../ui/Localization";
|
|
17
|
+
import { stopPropagation } from "../../util/eventCallbacks";
|
|
18
|
+
import { ddMouseDown, ddDetect, ddMouseUp } from "../drag-drop/ops";
|
|
19
|
+
import { isDefined } from "../../util/isDefined";
|
|
20
|
+
import { isString } from "../../util/isString";
|
|
21
|
+
import { BooleanProp, StringProp, StyleProp, ClassProp } from "../../ui/Prop";
|
|
22
|
+
import { RenderingContext } from "../../ui/RenderingContext";
|
|
23
|
+
|
|
24
|
+
export interface WindowConfig extends OverlayConfig {
|
|
25
|
+
/** Text to be displayed in the header. */
|
|
26
|
+
title?: StringProp;
|
|
27
|
+
|
|
28
|
+
/** Controls the close button visibility. Defaults to `true`. */
|
|
29
|
+
closable?: BooleanProp;
|
|
30
|
+
|
|
31
|
+
/** A custom style which will be applied to the body. */
|
|
32
|
+
bodyStyle?: StyleProp;
|
|
33
|
+
|
|
34
|
+
/** A custom style which will be applied to the header. */
|
|
35
|
+
headerStyle?: StyleProp;
|
|
36
|
+
|
|
37
|
+
/** A custom style which will be applied to the footer. */
|
|
38
|
+
footerStyle?: StyleProp;
|
|
39
|
+
|
|
40
|
+
/** Base CSS class to be applied to the field. Defaults to `window`. */
|
|
41
|
+
baseClass?: string;
|
|
42
|
+
|
|
43
|
+
/** Additional CSS class to be applied to the section body. */
|
|
44
|
+
bodyClass?: ClassProp;
|
|
45
|
+
|
|
46
|
+
/** Set to `true` to enable resizing. */
|
|
47
|
+
resizable?: boolean;
|
|
48
|
+
|
|
49
|
+
/** Set to `true` to automatically focus the field, after it renders for the first time. */
|
|
50
|
+
autoFocus?: boolean;
|
|
51
|
+
|
|
52
|
+
/** Set to `false` to prevent the window itself to be focusable. Default value is true.*/
|
|
53
|
+
focusable?: boolean;
|
|
54
|
+
|
|
55
|
+
/** Set to `true` to disable moving the window by dragging the header. */
|
|
56
|
+
fixed?: boolean;
|
|
57
|
+
|
|
58
|
+
/** Set to `true` to add default padding to the window body. */
|
|
59
|
+
pad?: boolean;
|
|
60
|
+
|
|
61
|
+
/** Optional header widget. */
|
|
62
|
+
header?: any;
|
|
63
|
+
|
|
64
|
+
/** Optional footer widget. */
|
|
65
|
+
footer?: any;
|
|
66
|
+
|
|
67
|
+
/** Custom event handler for closeable. */
|
|
68
|
+
closeable?: BooleanProp;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class WindowInstance extends OverlayInstance<Window> {
|
|
72
|
+
headerEl?: HTMLElement;
|
|
73
|
+
footerEl?: HTMLElement;
|
|
74
|
+
bodyEl?: HTMLElement;
|
|
75
|
+
containerEl?: HTMLElement;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class Window extends OverlayBase<WindowConfig, WindowInstance> {
|
|
79
|
+
declare closable?: BooleanProp;
|
|
80
|
+
declare closeable?: BooleanProp;
|
|
81
|
+
declare resizable?: boolean;
|
|
82
|
+
declare fixed?: boolean;
|
|
83
|
+
declare autoFocus?: boolean;
|
|
84
|
+
declare focusable?: boolean;
|
|
85
|
+
declare pad?: boolean;
|
|
86
|
+
declare bodyStyle?: StyleProp;
|
|
87
|
+
declare headerStyle?: StyleProp;
|
|
88
|
+
declare footerStyle?: StyleProp;
|
|
89
|
+
declare bodyClass?: ClassProp;
|
|
90
|
+
declare title?: StringProp;
|
|
91
|
+
declare header?: any;
|
|
92
|
+
declare footer?: any;
|
|
93
|
+
declare baseClass: string;
|
|
94
|
+
|
|
95
|
+
init() {
|
|
96
|
+
if (isDefined(this.closeable)) this.closable = this.closeable;
|
|
97
|
+
|
|
98
|
+
if (isString(this.headerStyle)) this.headerStyle = parseStyle(this.headerStyle);
|
|
99
|
+
|
|
100
|
+
if (isString(this.footerStyle)) this.footerStyle = parseStyle(this.footerStyle);
|
|
101
|
+
|
|
102
|
+
if (isString(this.bodyStyle)) this.bodyStyle = parseStyle(this.bodyStyle);
|
|
103
|
+
|
|
104
|
+
super.init();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declareData(...args: any) {
|
|
108
|
+
return super.declareData(...args, {
|
|
109
|
+
title: undefined,
|
|
110
|
+
closable: undefined,
|
|
111
|
+
bodyStyle: { structured: true },
|
|
112
|
+
bodyClass: { structured: true },
|
|
113
|
+
headerStyle: { structured: true },
|
|
114
|
+
footerStyle: { structured: true },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
initHelpers(...args: any) {
|
|
119
|
+
return super.initHelpers(...args, {
|
|
120
|
+
header: Widget.create(this.header || { type: ContentPlaceholder, name: "header", scoped: true }),
|
|
121
|
+
footer: Widget.create(this.footer || { type: ContentPlaceholder, name: "footer", scoped: true }),
|
|
122
|
+
close:
|
|
123
|
+
this.closable &&
|
|
124
|
+
Button.create({
|
|
125
|
+
mod: "hollow",
|
|
126
|
+
dismiss: true,
|
|
127
|
+
icon: "close",
|
|
128
|
+
style: "margin-left: auto",
|
|
129
|
+
onTouchStart: stopPropagation,
|
|
130
|
+
onMouseDown: stopPropagation,
|
|
131
|
+
}),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exploreCleanup(context: RenderingContext, instance: WindowInstance): void {
|
|
136
|
+
super.exploreCleanup(context, instance);
|
|
137
|
+
|
|
138
|
+
let { helpers } = instance;
|
|
139
|
+
let unregisterHeader =
|
|
140
|
+
helpers!.header && (helpers!.header as ContentPlaceholderInstance).unregisterContentPlaceholder;
|
|
141
|
+
if (unregisterHeader) unregisterHeader();
|
|
142
|
+
|
|
143
|
+
let unregisterFooter =
|
|
144
|
+
helpers!.footer && (helpers!.footer as ContentPlaceholderInstance).unregisterContentPlaceholder;
|
|
145
|
+
if (unregisterFooter) unregisterFooter();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
renderHeader(context: RenderingContext, instance: WindowInstance, key: string): any[] {
|
|
149
|
+
let { data } = instance;
|
|
150
|
+
let result = [];
|
|
151
|
+
if (data.title) result.push(data.title);
|
|
152
|
+
if (instance.helpers) {
|
|
153
|
+
let header = getContent(instance.helpers.header && instance.helpers.header.render(context));
|
|
154
|
+
if (header) result.push(header);
|
|
155
|
+
if (data.closable && instance.helpers.close) result.push(getContent(instance.helpers.close.render(context)));
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
renderFooter(context: RenderingContext, instance: WindowInstance, key: string): any {
|
|
161
|
+
return getContent(instance.helpers && instance.helpers.footer && instance.helpers.footer.render(context));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
render(context: RenderingContext, instance: WindowInstance, key: string): any {
|
|
165
|
+
var header = this.renderHeader(context, instance, "header");
|
|
166
|
+
var footer = this.renderFooter(context, instance, "footer");
|
|
167
|
+
return (
|
|
168
|
+
<WindowComponent
|
|
169
|
+
key={key}
|
|
170
|
+
instance={instance}
|
|
171
|
+
header={header}
|
|
172
|
+
footer={footer}
|
|
173
|
+
subscribeToBeforeDismiss={context.options.subscribeToBeforeDismiss}
|
|
174
|
+
>
|
|
175
|
+
{this.renderContents(context, instance)}
|
|
176
|
+
</WindowComponent>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
Window.prototype.baseClass = "window";
|
|
182
|
+
Window.prototype.closable = true;
|
|
183
|
+
Window.prototype.resizable = false;
|
|
184
|
+
Window.prototype.fixed = false;
|
|
185
|
+
Window.prototype.autoFocus = true;
|
|
186
|
+
Window.prototype.focusable = true;
|
|
187
|
+
Window.prototype.pad = true;
|
|
188
|
+
|
|
189
|
+
Widget.alias("window", Window);
|
|
190
|
+
Localization.registerPrototype("cx/widgets/Window", Window);
|
|
191
|
+
|
|
192
|
+
interface WindowComponentProps extends OverlayComponentProps {
|
|
193
|
+
header: any[];
|
|
194
|
+
footer: any;
|
|
195
|
+
instance: WindowInstance;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface WindowComponentState extends OverlayComponentState {
|
|
199
|
+
active?: boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class WindowComponent extends OverlayComponent<WindowComponentProps, WindowComponentState> {
|
|
203
|
+
headerEl?: HTMLElement | null;
|
|
204
|
+
footerEl?: HTMLElement | null;
|
|
205
|
+
bodyEl?: HTMLElement | null;
|
|
206
|
+
|
|
207
|
+
renderOverlayBody() {
|
|
208
|
+
var { widget, data } = this.props.instance;
|
|
209
|
+
var { CSS, baseClass, pad } = widget;
|
|
210
|
+
|
|
211
|
+
let header, footer;
|
|
212
|
+
|
|
213
|
+
if (this.props.header.length > 0) {
|
|
214
|
+
header = (
|
|
215
|
+
<header
|
|
216
|
+
key="header"
|
|
217
|
+
ref={(c) => {
|
|
218
|
+
this.headerEl = c;
|
|
219
|
+
}}
|
|
220
|
+
className={CSS.element(baseClass, "header")}
|
|
221
|
+
style={data.headerStyle}
|
|
222
|
+
onMouseDown={this.onHeaderMouseDown.bind(this)}
|
|
223
|
+
onMouseUp={ddMouseUp}
|
|
224
|
+
onMouseMove={this.onHeaderMouseMove.bind(this)}
|
|
225
|
+
onTouchStart={this.onHeaderMouseDown.bind(this)}
|
|
226
|
+
onTouchEnd={ddMouseUp}
|
|
227
|
+
onTouchMove={this.onHeaderMouseMove.bind(this)}
|
|
228
|
+
>
|
|
229
|
+
{this.props.header}
|
|
230
|
+
</header>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (this.props.footer) {
|
|
235
|
+
footer = (
|
|
236
|
+
<footer
|
|
237
|
+
key="footer"
|
|
238
|
+
ref={(c) => {
|
|
239
|
+
this.footerEl = c;
|
|
240
|
+
}}
|
|
241
|
+
className={CSS.element(baseClass, "footer")}
|
|
242
|
+
style={data.footerStyle}
|
|
243
|
+
>
|
|
244
|
+
{this.props.footer}
|
|
245
|
+
</footer>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var body = (
|
|
250
|
+
<div
|
|
251
|
+
key="body"
|
|
252
|
+
ref={(c) => {
|
|
253
|
+
this.bodyEl = c;
|
|
254
|
+
}}
|
|
255
|
+
className={CSS.expand(CSS.element(baseClass, "body", { pad }), data.bodyClass)}
|
|
256
|
+
style={data.bodyStyle}
|
|
257
|
+
>
|
|
258
|
+
{this.props.children}
|
|
259
|
+
</div>
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
return [header, body, footer];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
getOverlayCssClass() {
|
|
266
|
+
var cls = super.getOverlayCssClass();
|
|
267
|
+
if (this.state.active) cls += " cxs-active";
|
|
268
|
+
return cls;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
onFocusIn() {
|
|
272
|
+
super.onFocusIn();
|
|
273
|
+
if (!this.state.active) {
|
|
274
|
+
if (this.containerEl!.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
|
|
275
|
+
this.setState({ active: true });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
onFocusOut() {
|
|
280
|
+
super.onFocusOut();
|
|
281
|
+
if (this.state.active) {
|
|
282
|
+
this.setState({
|
|
283
|
+
active: false,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
onHeaderMouseDown(e: any) {
|
|
289
|
+
e.stopPropagation();
|
|
290
|
+
ddMouseDown(e);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
onHeaderMouseMove(e: any) {
|
|
294
|
+
e.stopPropagation();
|
|
295
|
+
if (!(this.props.instance.widget as Window).fixed && ddDetect(e)) {
|
|
296
|
+
this.startMoveOperation(e);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|