cx 25.6.2 → 25.6.3

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.
Files changed (103) hide show
  1. package/dist/manifest.js +749 -749
  2. package/dist/widgets.css +5 -0
  3. package/dist/widgets.js +77 -34
  4. package/package.json +1 -1
  5. package/src/charts/Legend.d.ts +45 -45
  6. package/src/charts/LegendEntry.js +128 -128
  7. package/src/charts/LegendEntry.scss +27 -27
  8. package/src/charts/PieChart.d.ts +92 -92
  9. package/src/charts/RangeMarker.js +159 -159
  10. package/src/charts/axis/Axis.d.ts +113 -113
  11. package/src/charts/axis/Axis.js +280 -280
  12. package/src/charts/axis/CategoryAxis.d.ts +30 -30
  13. package/src/charts/axis/CategoryAxis.js +241 -241
  14. package/src/charts/axis/NumericAxis.js +351 -351
  15. package/src/charts/axis/Stack.js +55 -55
  16. package/src/charts/axis/TimeAxis.js +611 -611
  17. package/src/charts/helpers/SnapPointFinder.js +69 -69
  18. package/src/data/Binding.spec.js +69 -69
  19. package/src/data/ExposedValueView.d.ts +19 -19
  20. package/src/data/Expression.js +229 -229
  21. package/src/data/Expression.spec.js +229 -229
  22. package/src/data/StringTemplate.js +92 -92
  23. package/src/data/StringTemplate.spec.js +132 -132
  24. package/src/data/StructuredSelector.js +132 -132
  25. package/src/data/getAccessor.spec.js +11 -11
  26. package/src/data/getSelector.js +49 -49
  27. package/src/hooks/createLocalStorageRef.d.ts +3 -3
  28. package/src/hooks/createLocalStorageRef.js +20 -20
  29. package/src/index.scss +6 -6
  30. package/src/ui/Culture.d.ts +57 -57
  31. package/src/ui/Culture.js +139 -139
  32. package/src/ui/FocusManager.js +171 -171
  33. package/src/ui/Format.js +108 -108
  34. package/src/ui/HoverSync.js +147 -147
  35. package/src/ui/Repeater.d.ts +61 -61
  36. package/src/ui/index.d.ts +42 -42
  37. package/src/ui/layout/ContentPlaceholder.d.ts +19 -19
  38. package/src/ui/layout/ContentPlaceholder.js +105 -105
  39. package/src/ui/layout/ContentPlaceholder.spec.js +579 -579
  40. package/src/ui/layout/LabelsTopLayout.js +134 -134
  41. package/src/util/Format.js +270 -270
  42. package/src/util/date/encodeDate.d.ts +1 -1
  43. package/src/util/date/encodeDate.js +8 -8
  44. package/src/util/date/encodeDateWithTimezoneOffset.d.ts +1 -1
  45. package/src/util/date/index.d.ts +11 -11
  46. package/src/util/date/index.js +11 -11
  47. package/src/util/date/parseDateInvariant.d.ts +3 -3
  48. package/src/util/date/parseDateInvariant.js +20 -20
  49. package/src/util/getSearchQueryPredicate.js +59 -59
  50. package/src/util/index.d.ts +51 -51
  51. package/src/util/index.js +54 -54
  52. package/src/util/isValidIdentifierName.d.ts +1 -1
  53. package/src/util/isValidIdentifierName.js +5 -5
  54. package/src/util/isValidIdentifierName.spec.js +33 -33
  55. package/src/util/scss/add-rules.scss +38 -38
  56. package/src/widgets/CxCredit.scss +37 -37
  57. package/src/widgets/HighlightedSearchText.js +36 -36
  58. package/src/widgets/HighlightedSearchText.scss +18 -18
  59. package/src/widgets/List.scss +91 -91
  60. package/src/widgets/Sandbox.d.ts +18 -16
  61. package/src/widgets/Sandbox.js +65 -63
  62. package/src/widgets/drag-drop/DropZone.js +214 -214
  63. package/src/widgets/form/Calendar.js +618 -618
  64. package/src/widgets/form/Calendar.scss +196 -196
  65. package/src/widgets/form/Checkbox.scss +127 -127
  66. package/src/widgets/form/ColorField.js +397 -397
  67. package/src/widgets/form/ColorField.scss +96 -96
  68. package/src/widgets/form/ColorPicker.scss +283 -283
  69. package/src/widgets/form/DateTimeField.js +576 -576
  70. package/src/widgets/form/DateTimePicker.js +392 -392
  71. package/src/widgets/form/LookupField.d.ts +179 -179
  72. package/src/widgets/form/LookupField.scss +219 -219
  73. package/src/widgets/form/MonthPicker.d.ts +8 -0
  74. package/src/widgets/form/MonthPicker.js +65 -23
  75. package/src/widgets/form/MonthPicker.scss +4 -0
  76. package/src/widgets/form/NumberField.js +459 -459
  77. package/src/widgets/form/NumberField.scss +61 -61
  78. package/src/widgets/form/Radio.scss +121 -121
  79. package/src/widgets/form/Select.scss +99 -99
  80. package/src/widgets/form/Slider.scss +118 -118
  81. package/src/widgets/form/Switch.scss +140 -140
  82. package/src/widgets/form/TextArea.scss +43 -43
  83. package/src/widgets/form/TextField.js +290 -290
  84. package/src/widgets/form/TextField.scss +55 -55
  85. package/src/widgets/form/UploadButton.d.ts +34 -34
  86. package/src/widgets/form/variables.scss +353 -353
  87. package/src/widgets/grid/Grid.d.ts +442 -442
  88. package/src/widgets/grid/GridRow.js +228 -228
  89. package/src/widgets/grid/TreeNode.d.ts +23 -23
  90. package/src/widgets/grid/TreeNode.scss +88 -88
  91. package/src/widgets/grid/variables.scss +133 -133
  92. package/src/widgets/nav/LinkButton.js +128 -128
  93. package/src/widgets/nav/Menu.scss +74 -74
  94. package/src/widgets/overlay/Dropdown.js +612 -612
  95. package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
  96. package/src/widgets/overlay/Overlay.d.ts +73 -73
  97. package/src/widgets/overlay/Window.js +202 -202
  98. package/src/widgets/overlay/captureMouse.js +124 -124
  99. package/src/widgets/overlay/createHotPromiseWindowFactory.d.ts +18 -18
  100. package/src/widgets/overlay/createHotPromiseWindowFactory.js +56 -56
  101. package/src/widgets/overlay/index.d.ts +11 -11
  102. package/src/widgets/overlay/index.js +11 -11
  103. package/src/widgets/variables.scss +144 -144
@@ -1,392 +1,392 @@
1
- import { Widget, VDOM } from "../../ui/Widget";
2
- import { Culture } from "../../ui/Culture";
3
- import { KeyCode } from "../../util/KeyCode";
4
- import { WheelComponent } from "./Wheel";
5
- import { oneFocusOut, offFocusOut } from "../../ui/FocusManager";
6
-
7
- import { enableCultureSensitiveFormatting } from "../../ui/Format";
8
- import { parseDateInvariant } from "../../util";
9
- enableCultureSensitiveFormatting();
10
-
11
- export class DateTimePicker extends Widget {
12
- declareData() {
13
- return super.declareData(...arguments, {
14
- value: undefined,
15
- });
16
- }
17
-
18
- render(context, instance, key) {
19
- return (
20
- <DateTimePickerComponent
21
- key={key}
22
- instance={instance}
23
- data={instance.data}
24
- size={this.size}
25
- segment={this.segment}
26
- />
27
- );
28
- }
29
- }
30
-
31
- DateTimePicker.prototype.baseClass = "datetimepicker";
32
- DateTimePicker.prototype.styled = true;
33
- DateTimePicker.prototype.size = 3;
34
- DateTimePicker.prototype.autoFocus = false;
35
- DateTimePicker.prototype.segment = "datetime";
36
- DateTimePicker.prototype.showSeconds = false;
37
-
38
- class DateTimePickerComponent extends VDOM.Component {
39
- constructor(props) {
40
- super(props);
41
- let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
42
- if (isNaN(date.getTime())) date = new Date();
43
- this.state = {
44
- date: date,
45
- activeWheel: null,
46
- };
47
-
48
- let { widget } = props.instance;
49
-
50
- this.handleChange = this.handleChange.bind(this);
51
- this.onFocus = this.onFocus.bind(this);
52
- this.onBlur = this.onBlur.bind(this);
53
- this.onKeyDown = this.onKeyDown.bind(this);
54
-
55
- let showDate = props.segment.indexOf("date") !== -1;
56
- let showTime = props.segment.indexOf("time") !== -1;
57
-
58
- this.wheels = {
59
- year: showDate,
60
- month: showDate,
61
- date: showDate,
62
- hours: showTime,
63
- minutes: showTime,
64
- seconds: showTime && widget.showSeconds,
65
- };
66
-
67
- this.keyDownPipes = {};
68
- }
69
-
70
- UNSAFE_componentWillReceiveProps(props) {
71
- let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
72
- if (isNaN(date.getTime())) date = new Date();
73
- this.setState({ date });
74
- }
75
-
76
- setDateComponent(date, component, value) {
77
- let v = new Date(date);
78
- switch (component) {
79
- case "year":
80
- v.setFullYear(value);
81
- break;
82
-
83
- case "month":
84
- v.setMonth(value);
85
- break;
86
-
87
- case "date":
88
- v.setDate(value);
89
- break;
90
-
91
- case "hours":
92
- v.setHours(value);
93
- break;
94
-
95
- case "minutes":
96
- v.setMinutes(value);
97
- break;
98
-
99
- case "seconds":
100
- v.setSeconds(value);
101
- break;
102
- }
103
- return v;
104
- }
105
-
106
- handleChange() {
107
- let encode = this.props.instance.widget.encoding || Culture.getDefaultDateEncoding();
108
- this.props.instance.set("value", encode(this.state.date));
109
- }
110
-
111
- render() {
112
- let { instance, data, size } = this.props;
113
- let { widget } = instance;
114
- let { CSS, baseClass } = widget;
115
- let date = this.state.date;
116
-
117
- let culture = Culture.getDateTimeCulture();
118
- let monthNames = culture.getMonthNames("short");
119
-
120
- let years = [];
121
- for (let y = 1970; y <= 2050; y++) years.push(<span key={y}>{y}</span>);
122
-
123
- let days = [];
124
- let start = new Date(date.getFullYear(), date.getMonth(), 1);
125
- while (start.getMonth() === date.getMonth()) {
126
- let day = start.getDate();
127
- days.push(<span key={day}>{day < 10 ? "0" + day : day}</span>);
128
- start.setDate(start.getDate() + 1);
129
- }
130
-
131
- let hours = [];
132
- for (let h = 0; h < 24; h++) {
133
- hours.push(<span key={h}>{h < 10 ? "0" + h : h}</span>);
134
- }
135
-
136
- let minutes = [];
137
- for (let m = 0; m < 60; m++) {
138
- minutes.push(<span key={m}>{m < 10 ? "0" + m : m}</span>);
139
- }
140
-
141
- return (
142
- <div
143
- tabIndex={0}
144
- ref={(el) => {
145
- this.el = el;
146
- }}
147
- className={data.classNames}
148
- onFocus={this.onFocus}
149
- onBlur={this.onBlur}
150
- onKeyDown={this.onKeyDown}
151
- >
152
- {this.wheels.year && (
153
- <WheelComponent
154
- size={size}
155
- CSS={CSS}
156
- active={this.state.activeWheel === "year"}
157
- baseClass={baseClass + "-wheel"}
158
- index={date.getFullYear() - 1970}
159
- onChange={(newIndex) => {
160
- this.setState(
161
- (state) => ({
162
- date: this.setDateComponent(this.state.date, "year", newIndex + 1970),
163
- }),
164
- this.handleChange,
165
- );
166
- }}
167
- onPipeKeyDown={(kd) => {
168
- this.keyDownPipes["year"] = kd;
169
- }}
170
- onMouseDown={() => {
171
- this.setState({ activeWheel: "year" });
172
- }}
173
- >
174
- {years}
175
- </WheelComponent>
176
- )}
177
- {this.wheels.year && this.wheels.month && <span>-</span>}
178
- {this.wheels.month && (
179
- <WheelComponent
180
- size={size}
181
- CSS={CSS}
182
- active={this.state.activeWheel === "month"}
183
- baseClass={baseClass + "-wheel"}
184
- index={date.getMonth()}
185
- onChange={(newIndex) => {
186
- this.setState(
187
- (state) => ({
188
- date: this.setDateComponent(this.state.date, "month", newIndex),
189
- }),
190
- this.handleChange,
191
- );
192
- }}
193
- onPipeKeyDown={(kd) => {
194
- this.keyDownPipes["month"] = kd;
195
- }}
196
- onMouseDown={() => {
197
- this.setState({ activeWheel: "month" });
198
- }}
199
- >
200
- {monthNames.map((m, i) => (
201
- <span key={i}>{m}</span>
202
- ))}
203
- </WheelComponent>
204
- )}
205
- {this.wheels.month && this.wheels.date && <span>-</span>}
206
- {this.wheels.date && (
207
- <WheelComponent
208
- size={size}
209
- CSS={CSS}
210
- active={this.state.activeWheel === "date"}
211
- baseClass={baseClass + "-wheel"}
212
- index={date.getDate() - 1}
213
- onChange={(newIndex) => {
214
- this.setState(
215
- (state) => ({
216
- date: this.setDateComponent(this.state.date, "date", newIndex + 1),
217
- }),
218
- this.handleChange,
219
- );
220
- }}
221
- onPipeKeyDown={(kd) => {
222
- this.keyDownPipes["date"] = kd;
223
- }}
224
- onMouseDown={() => {
225
- this.setState({ activeWheel: "date" });
226
- }}
227
- >
228
- {days}
229
- </WheelComponent>
230
- )}
231
- {this.wheels.hours && this.wheels.year && <span className={CSS.element(baseClass, "spacer")} />}
232
- {this.wheels.hours && (
233
- <WheelComponent
234
- size={size}
235
- CSS={CSS}
236
- active={this.state.activeWheel === "hours"}
237
- baseClass={baseClass + "-wheel"}
238
- index={date.getHours()}
239
- onChange={(newIndex) => {
240
- this.setState(
241
- (state) => ({
242
- date: this.setDateComponent(this.state.date, "hours", newIndex),
243
- }),
244
- this.handleChange,
245
- );
246
- }}
247
- onPipeKeyDown={(kd) => {
248
- this.keyDownPipes["hours"] = kd;
249
- }}
250
- onMouseDown={() => {
251
- this.setState({ activeWheel: "hours" });
252
- }}
253
- >
254
- {hours}
255
- </WheelComponent>
256
- )}
257
- {this.wheels.hours && this.wheels.minutes && <span>:</span>}
258
- {this.wheels.minutes && (
259
- <WheelComponent
260
- size={size}
261
- CSS={CSS}
262
- baseClass={baseClass + "-wheel"}
263
- active={this.state.activeWheel === "minutes"}
264
- index={date.getMinutes()}
265
- onChange={(newIndex) => {
266
- this.setState(
267
- (state) => ({
268
- date: this.setDateComponent(this.state.date, "minutes", newIndex),
269
- }),
270
- this.handleChange,
271
- );
272
- }}
273
- onPipeKeyDown={(kd) => {
274
- this.keyDownPipes["minutes"] = kd;
275
- }}
276
- onMouseDown={() => {
277
- this.setState({ activeWheel: "minutes" });
278
- }}
279
- >
280
- {minutes}
281
- </WheelComponent>
282
- )}
283
- {this.wheels.minutes && this.wheels.seconds && <span>:</span>}
284
- {this.wheels.seconds && (
285
- <WheelComponent
286
- size={size}
287
- CSS={CSS}
288
- baseClass={baseClass + "-wheel"}
289
- active={this.state.activeWheel === "seconds"}
290
- index={date.getSeconds()}
291
- onChange={(newIndex) => {
292
- this.setState(
293
- (state) => ({
294
- date: this.setDateComponent(this.state.date, "seconds", newIndex),
295
- }),
296
- this.handleChange,
297
- );
298
- }}
299
- onPipeKeyDown={(kd) => {
300
- this.keyDownPipes["seconds"] = kd;
301
- }}
302
- onMouseDown={() => {
303
- this.setState({ activeWheel: "seconds" });
304
- }}
305
- >
306
- {minutes}
307
- </WheelComponent>
308
- )}
309
- </div>
310
- );
311
- }
312
-
313
- componentDidMount() {
314
- if (this.props.instance.widget.autoFocus) this.el.focus();
315
- }
316
-
317
- componentWillUnmount() {
318
- offFocusOut(this);
319
- }
320
-
321
- onFocus() {
322
- oneFocusOut(this, this.el, this.onFocusOut.bind(this));
323
-
324
- if (!this.state.activeWheel) {
325
- let firstWheel = null;
326
- for (let wheel in this.wheels) {
327
- if (this.wheels[wheel]) {
328
- firstWheel = wheel;
329
- break;
330
- }
331
- }
332
-
333
- this.setState({
334
- activeWheel: firstWheel,
335
- });
336
- }
337
- }
338
-
339
- onFocusOut() {
340
- let { instance } = this.props;
341
- let { widget } = instance;
342
- if (widget.onFocusOut) instance.invoke("onFocusOut", null, instance);
343
- }
344
-
345
- onBlur() {
346
- this.setState({
347
- activeWheel: null,
348
- });
349
- }
350
-
351
- onKeyDown(e) {
352
- let tmp = null;
353
- let { instance } = this.props;
354
- switch (e.keyCode) {
355
- case KeyCode.right:
356
- e.preventDefault();
357
- for (let wheel in this.wheels) {
358
- if (this.wheels[wheel]) {
359
- if (tmp === this.state.activeWheel) {
360
- this.setState({ activeWheel: wheel });
361
- break;
362
- }
363
- tmp = wheel;
364
- }
365
- }
366
- break;
367
-
368
- case KeyCode.left:
369
- e.preventDefault();
370
- for (let wheel in this.wheels) {
371
- if (this.wheels[wheel]) {
372
- if (wheel === this.state.activeWheel && tmp) {
373
- this.setState({ activeWheel: tmp });
374
- break;
375
- }
376
- tmp = wheel;
377
- }
378
- }
379
- break;
380
-
381
- case KeyCode.enter:
382
- e.preventDefault();
383
- if (instance.widget.onSelect) instance.invoke("onSelect", e, instance, this.state.date);
384
- break;
385
-
386
- default:
387
- let kdp = this.keyDownPipes[this.state.activeWheel];
388
- if (kdp) kdp(e);
389
- break;
390
- }
391
- }
392
- }
1
+ import { Widget, VDOM } from "../../ui/Widget";
2
+ import { Culture } from "../../ui/Culture";
3
+ import { KeyCode } from "../../util/KeyCode";
4
+ import { WheelComponent } from "./Wheel";
5
+ import { oneFocusOut, offFocusOut } from "../../ui/FocusManager";
6
+
7
+ import { enableCultureSensitiveFormatting } from "../../ui/Format";
8
+ import { parseDateInvariant } from "../../util";
9
+ enableCultureSensitiveFormatting();
10
+
11
+ export class DateTimePicker extends Widget {
12
+ declareData() {
13
+ return super.declareData(...arguments, {
14
+ value: undefined,
15
+ });
16
+ }
17
+
18
+ render(context, instance, key) {
19
+ return (
20
+ <DateTimePickerComponent
21
+ key={key}
22
+ instance={instance}
23
+ data={instance.data}
24
+ size={this.size}
25
+ segment={this.segment}
26
+ />
27
+ );
28
+ }
29
+ }
30
+
31
+ DateTimePicker.prototype.baseClass = "datetimepicker";
32
+ DateTimePicker.prototype.styled = true;
33
+ DateTimePicker.prototype.size = 3;
34
+ DateTimePicker.prototype.autoFocus = false;
35
+ DateTimePicker.prototype.segment = "datetime";
36
+ DateTimePicker.prototype.showSeconds = false;
37
+
38
+ class DateTimePickerComponent extends VDOM.Component {
39
+ constructor(props) {
40
+ super(props);
41
+ let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
42
+ if (isNaN(date.getTime())) date = new Date();
43
+ this.state = {
44
+ date: date,
45
+ activeWheel: null,
46
+ };
47
+
48
+ let { widget } = props.instance;
49
+
50
+ this.handleChange = this.handleChange.bind(this);
51
+ this.onFocus = this.onFocus.bind(this);
52
+ this.onBlur = this.onBlur.bind(this);
53
+ this.onKeyDown = this.onKeyDown.bind(this);
54
+
55
+ let showDate = props.segment.indexOf("date") !== -1;
56
+ let showTime = props.segment.indexOf("time") !== -1;
57
+
58
+ this.wheels = {
59
+ year: showDate,
60
+ month: showDate,
61
+ date: showDate,
62
+ hours: showTime,
63
+ minutes: showTime,
64
+ seconds: showTime && widget.showSeconds,
65
+ };
66
+
67
+ this.keyDownPipes = {};
68
+ }
69
+
70
+ UNSAFE_componentWillReceiveProps(props) {
71
+ let date = props.data.value ? parseDateInvariant(props.data.value) : new Date();
72
+ if (isNaN(date.getTime())) date = new Date();
73
+ this.setState({ date });
74
+ }
75
+
76
+ setDateComponent(date, component, value) {
77
+ let v = new Date(date);
78
+ switch (component) {
79
+ case "year":
80
+ v.setFullYear(value);
81
+ break;
82
+
83
+ case "month":
84
+ v.setMonth(value);
85
+ break;
86
+
87
+ case "date":
88
+ v.setDate(value);
89
+ break;
90
+
91
+ case "hours":
92
+ v.setHours(value);
93
+ break;
94
+
95
+ case "minutes":
96
+ v.setMinutes(value);
97
+ break;
98
+
99
+ case "seconds":
100
+ v.setSeconds(value);
101
+ break;
102
+ }
103
+ return v;
104
+ }
105
+
106
+ handleChange() {
107
+ let encode = this.props.instance.widget.encoding || Culture.getDefaultDateEncoding();
108
+ this.props.instance.set("value", encode(this.state.date));
109
+ }
110
+
111
+ render() {
112
+ let { instance, data, size } = this.props;
113
+ let { widget } = instance;
114
+ let { CSS, baseClass } = widget;
115
+ let date = this.state.date;
116
+
117
+ let culture = Culture.getDateTimeCulture();
118
+ let monthNames = culture.getMonthNames("short");
119
+
120
+ let years = [];
121
+ for (let y = 1970; y <= 2050; y++) years.push(<span key={y}>{y}</span>);
122
+
123
+ let days = [];
124
+ let start = new Date(date.getFullYear(), date.getMonth(), 1);
125
+ while (start.getMonth() === date.getMonth()) {
126
+ let day = start.getDate();
127
+ days.push(<span key={day}>{day < 10 ? "0" + day : day}</span>);
128
+ start.setDate(start.getDate() + 1);
129
+ }
130
+
131
+ let hours = [];
132
+ for (let h = 0; h < 24; h++) {
133
+ hours.push(<span key={h}>{h < 10 ? "0" + h : h}</span>);
134
+ }
135
+
136
+ let minutes = [];
137
+ for (let m = 0; m < 60; m++) {
138
+ minutes.push(<span key={m}>{m < 10 ? "0" + m : m}</span>);
139
+ }
140
+
141
+ return (
142
+ <div
143
+ tabIndex={0}
144
+ ref={(el) => {
145
+ this.el = el;
146
+ }}
147
+ className={data.classNames}
148
+ onFocus={this.onFocus}
149
+ onBlur={this.onBlur}
150
+ onKeyDown={this.onKeyDown}
151
+ >
152
+ {this.wheels.year && (
153
+ <WheelComponent
154
+ size={size}
155
+ CSS={CSS}
156
+ active={this.state.activeWheel === "year"}
157
+ baseClass={baseClass + "-wheel"}
158
+ index={date.getFullYear() - 1970}
159
+ onChange={(newIndex) => {
160
+ this.setState(
161
+ (state) => ({
162
+ date: this.setDateComponent(this.state.date, "year", newIndex + 1970),
163
+ }),
164
+ this.handleChange,
165
+ );
166
+ }}
167
+ onPipeKeyDown={(kd) => {
168
+ this.keyDownPipes["year"] = kd;
169
+ }}
170
+ onMouseDown={() => {
171
+ this.setState({ activeWheel: "year" });
172
+ }}
173
+ >
174
+ {years}
175
+ </WheelComponent>
176
+ )}
177
+ {this.wheels.year && this.wheels.month && <span>-</span>}
178
+ {this.wheels.month && (
179
+ <WheelComponent
180
+ size={size}
181
+ CSS={CSS}
182
+ active={this.state.activeWheel === "month"}
183
+ baseClass={baseClass + "-wheel"}
184
+ index={date.getMonth()}
185
+ onChange={(newIndex) => {
186
+ this.setState(
187
+ (state) => ({
188
+ date: this.setDateComponent(this.state.date, "month", newIndex),
189
+ }),
190
+ this.handleChange,
191
+ );
192
+ }}
193
+ onPipeKeyDown={(kd) => {
194
+ this.keyDownPipes["month"] = kd;
195
+ }}
196
+ onMouseDown={() => {
197
+ this.setState({ activeWheel: "month" });
198
+ }}
199
+ >
200
+ {monthNames.map((m, i) => (
201
+ <span key={i}>{m}</span>
202
+ ))}
203
+ </WheelComponent>
204
+ )}
205
+ {this.wheels.month && this.wheels.date && <span>-</span>}
206
+ {this.wheels.date && (
207
+ <WheelComponent
208
+ size={size}
209
+ CSS={CSS}
210
+ active={this.state.activeWheel === "date"}
211
+ baseClass={baseClass + "-wheel"}
212
+ index={date.getDate() - 1}
213
+ onChange={(newIndex) => {
214
+ this.setState(
215
+ (state) => ({
216
+ date: this.setDateComponent(this.state.date, "date", newIndex + 1),
217
+ }),
218
+ this.handleChange,
219
+ );
220
+ }}
221
+ onPipeKeyDown={(kd) => {
222
+ this.keyDownPipes["date"] = kd;
223
+ }}
224
+ onMouseDown={() => {
225
+ this.setState({ activeWheel: "date" });
226
+ }}
227
+ >
228
+ {days}
229
+ </WheelComponent>
230
+ )}
231
+ {this.wheels.hours && this.wheels.year && <span className={CSS.element(baseClass, "spacer")} />}
232
+ {this.wheels.hours && (
233
+ <WheelComponent
234
+ size={size}
235
+ CSS={CSS}
236
+ active={this.state.activeWheel === "hours"}
237
+ baseClass={baseClass + "-wheel"}
238
+ index={date.getHours()}
239
+ onChange={(newIndex) => {
240
+ this.setState(
241
+ (state) => ({
242
+ date: this.setDateComponent(this.state.date, "hours", newIndex),
243
+ }),
244
+ this.handleChange,
245
+ );
246
+ }}
247
+ onPipeKeyDown={(kd) => {
248
+ this.keyDownPipes["hours"] = kd;
249
+ }}
250
+ onMouseDown={() => {
251
+ this.setState({ activeWheel: "hours" });
252
+ }}
253
+ >
254
+ {hours}
255
+ </WheelComponent>
256
+ )}
257
+ {this.wheels.hours && this.wheels.minutes && <span>:</span>}
258
+ {this.wheels.minutes && (
259
+ <WheelComponent
260
+ size={size}
261
+ CSS={CSS}
262
+ baseClass={baseClass + "-wheel"}
263
+ active={this.state.activeWheel === "minutes"}
264
+ index={date.getMinutes()}
265
+ onChange={(newIndex) => {
266
+ this.setState(
267
+ (state) => ({
268
+ date: this.setDateComponent(this.state.date, "minutes", newIndex),
269
+ }),
270
+ this.handleChange,
271
+ );
272
+ }}
273
+ onPipeKeyDown={(kd) => {
274
+ this.keyDownPipes["minutes"] = kd;
275
+ }}
276
+ onMouseDown={() => {
277
+ this.setState({ activeWheel: "minutes" });
278
+ }}
279
+ >
280
+ {minutes}
281
+ </WheelComponent>
282
+ )}
283
+ {this.wheels.minutes && this.wheels.seconds && <span>:</span>}
284
+ {this.wheels.seconds && (
285
+ <WheelComponent
286
+ size={size}
287
+ CSS={CSS}
288
+ baseClass={baseClass + "-wheel"}
289
+ active={this.state.activeWheel === "seconds"}
290
+ index={date.getSeconds()}
291
+ onChange={(newIndex) => {
292
+ this.setState(
293
+ (state) => ({
294
+ date: this.setDateComponent(this.state.date, "seconds", newIndex),
295
+ }),
296
+ this.handleChange,
297
+ );
298
+ }}
299
+ onPipeKeyDown={(kd) => {
300
+ this.keyDownPipes["seconds"] = kd;
301
+ }}
302
+ onMouseDown={() => {
303
+ this.setState({ activeWheel: "seconds" });
304
+ }}
305
+ >
306
+ {minutes}
307
+ </WheelComponent>
308
+ )}
309
+ </div>
310
+ );
311
+ }
312
+
313
+ componentDidMount() {
314
+ if (this.props.instance.widget.autoFocus) this.el.focus();
315
+ }
316
+
317
+ componentWillUnmount() {
318
+ offFocusOut(this);
319
+ }
320
+
321
+ onFocus() {
322
+ oneFocusOut(this, this.el, this.onFocusOut.bind(this));
323
+
324
+ if (!this.state.activeWheel) {
325
+ let firstWheel = null;
326
+ for (let wheel in this.wheels) {
327
+ if (this.wheels[wheel]) {
328
+ firstWheel = wheel;
329
+ break;
330
+ }
331
+ }
332
+
333
+ this.setState({
334
+ activeWheel: firstWheel,
335
+ });
336
+ }
337
+ }
338
+
339
+ onFocusOut() {
340
+ let { instance } = this.props;
341
+ let { widget } = instance;
342
+ if (widget.onFocusOut) instance.invoke("onFocusOut", null, instance);
343
+ }
344
+
345
+ onBlur() {
346
+ this.setState({
347
+ activeWheel: null,
348
+ });
349
+ }
350
+
351
+ onKeyDown(e) {
352
+ let tmp = null;
353
+ let { instance } = this.props;
354
+ switch (e.keyCode) {
355
+ case KeyCode.right:
356
+ e.preventDefault();
357
+ for (let wheel in this.wheels) {
358
+ if (this.wheels[wheel]) {
359
+ if (tmp === this.state.activeWheel) {
360
+ this.setState({ activeWheel: wheel });
361
+ break;
362
+ }
363
+ tmp = wheel;
364
+ }
365
+ }
366
+ break;
367
+
368
+ case KeyCode.left:
369
+ e.preventDefault();
370
+ for (let wheel in this.wheels) {
371
+ if (this.wheels[wheel]) {
372
+ if (wheel === this.state.activeWheel && tmp) {
373
+ this.setState({ activeWheel: tmp });
374
+ break;
375
+ }
376
+ tmp = wheel;
377
+ }
378
+ }
379
+ break;
380
+
381
+ case KeyCode.enter:
382
+ e.preventDefault();
383
+ if (instance.widget.onSelect) instance.invoke("onSelect", e, instance, this.state.date);
384
+ break;
385
+
386
+ default:
387
+ let kdp = this.keyDownPipes[this.state.activeWheel];
388
+ if (kdp) kdp(e);
389
+ break;
390
+ }
391
+ }
392
+ }