@luomus/laji-form 15.1.14 → 15.1.16
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/laji-form.js +1 -1
- package/lib/components/LajiForm.js +1 -1
- package/lib/components/components.d.ts +0 -2
- package/lib/components/components.js +7 -16
- package/lib/components/widgets/DateTimeWidget.d.ts +7 -1
- package/lib/components/widgets/DateTimeWidget.js +31 -5
- package/lib/components/widgets/DateWidget.d.ts +6 -0
- package/lib/components/widgets/DateWidget.js +12 -0
- package/package.json +1 -1
|
@@ -479,7 +479,7 @@ class LajiForm extends React.Component {
|
|
|
479
479
|
return state;
|
|
480
480
|
}
|
|
481
481
|
getMemoizedFormContext(props) {
|
|
482
|
-
const nextKey = ["lang", "topOffset", "bottomOffset", "formContext", "settings", "schema", "uiSchemaContext", "lajiGeoServerAddress"].reduce((key, prop) => {
|
|
482
|
+
const nextKey = ["lang", "topOffset", "bottomOffset", "formContext", "settings", "schema", "uiSchemaContext", "mediaMetadata", "lajiGeoServerAddress"].reduce((key, prop) => {
|
|
483
483
|
key[prop] = props[prop];
|
|
484
484
|
return key;
|
|
485
485
|
}, {});
|
|
@@ -88,11 +88,9 @@ export class OverlayTrigger extends React.Component<any, any, any> {
|
|
|
88
88
|
static contextType: React.Context<import("../ReactContext").ContextProps>;
|
|
89
89
|
constructor(props: any);
|
|
90
90
|
overlayTriggerMouseOver: () => void;
|
|
91
|
-
overlayTriggerMouseIn: boolean | undefined;
|
|
92
91
|
overlayTriggerMouseOut: () => void;
|
|
93
92
|
overlayTimeout: any;
|
|
94
93
|
overlayMouseOver: () => void;
|
|
95
|
-
overlayMouseIn: boolean | undefined;
|
|
96
94
|
overlayMouseOut: () => void;
|
|
97
95
|
}
|
|
98
96
|
export class Fullscreen extends React.Component<any, any, any> {
|
|
@@ -473,35 +473,25 @@ class OverlayTrigger extends React.Component {
|
|
|
473
473
|
constructor(props) {
|
|
474
474
|
super(props);
|
|
475
475
|
this.overlayTriggerMouseOver = () => {
|
|
476
|
-
this.
|
|
477
|
-
this.setState({ show: true });
|
|
476
|
+
this.setState({ hoveringElem: true });
|
|
478
477
|
};
|
|
479
478
|
this.overlayTriggerMouseOut = () => {
|
|
480
|
-
this.overlayTriggerMouseIn = false;
|
|
481
479
|
if (this.overlayTimeout) {
|
|
482
480
|
clearTimeout(this.overlayTimeout);
|
|
483
481
|
}
|
|
484
482
|
this.overlayTimeout = this.props.formContext.setTimeout(() => {
|
|
485
483
|
if (!this.popoverMouseIn && !this.overlayTriggerMouseIn) {
|
|
486
|
-
this.setState({
|
|
484
|
+
this.setState({ hoveringElem: false });
|
|
487
485
|
}
|
|
488
486
|
}, 200);
|
|
489
487
|
};
|
|
490
488
|
this.overlayMouseOver = () => {
|
|
491
|
-
this.
|
|
489
|
+
this.setState({ hoveringOverlay: true });
|
|
492
490
|
};
|
|
493
491
|
this.overlayMouseOut = () => {
|
|
494
|
-
this.
|
|
495
|
-
if (this.overlayTimeout) {
|
|
496
|
-
clearTimeout(this.overlayTimeout);
|
|
497
|
-
}
|
|
498
|
-
this.overlayTimeout = this.props.formContext.setTimeout(() => {
|
|
499
|
-
if (!this.overlayMouseIn && !this.overlayTriggerMouseIn) {
|
|
500
|
-
this.setState({ show: false });
|
|
501
|
-
}
|
|
502
|
-
}, 200);
|
|
492
|
+
this.setState({ hoveringOverlay: false, hoveringElem: false });
|
|
503
493
|
};
|
|
504
|
-
this.state = {
|
|
494
|
+
this.state = {};
|
|
505
495
|
}
|
|
506
496
|
componentWillUnmount() {
|
|
507
497
|
if (this.overlayTimeout) {
|
|
@@ -515,8 +505,9 @@ class OverlayTrigger extends React.Component {
|
|
|
515
505
|
if (!this.props.hoverable)
|
|
516
506
|
return (React.createElement(OverlayTrigger, Object.assign({}, props, { overlay: overlay }), children));
|
|
517
507
|
let _overlay = React.cloneElement(overlay, { onMouseOver: this.overlayMouseOver, onMouseOut: this.overlayMouseOut });
|
|
508
|
+
const show = this.state.hoveringElem || this.state.hoveringOverlay;
|
|
518
509
|
return (React.createElement("div", { onMouseOver: this.overlayTriggerMouseOver, onMouseOut: this.overlayTriggerMouseOut },
|
|
519
|
-
React.createElement(OverlayTrigger, Object.assign({}, props, { delay: 1, trigger: [], placement: this.props.placement || "top", overlay: _overlay, show:
|
|
510
|
+
React.createElement(OverlayTrigger, Object.assign({}, props, { delay: 1, trigger: [], placement: this.props.placement || "top", overlay: _overlay, show: show }), children)));
|
|
520
511
|
}
|
|
521
512
|
}
|
|
522
513
|
exports.OverlayTrigger = OverlayTrigger;
|
|
@@ -10,6 +10,12 @@ export default class DateTimeWidget extends React.Component<any, any, any> {
|
|
|
10
10
|
same: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
11
11
|
path: PropTypes.Requireable<string>;
|
|
12
12
|
}>>;
|
|
13
|
+
plusSixMonths: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
14
|
+
path: PropTypes.Requireable<string>;
|
|
15
|
+
}>>;
|
|
16
|
+
plusSixYear: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
17
|
+
path: PropTypes.Requireable<string>;
|
|
18
|
+
}>>;
|
|
13
19
|
}>>;
|
|
14
20
|
showTimeList: PropTypes.Requireable<boolean>;
|
|
15
21
|
allowOnlyYear: PropTypes.Requireable<boolean>;
|
|
@@ -59,7 +65,7 @@ export default class DateTimeWidget extends React.Component<any, any, any> {
|
|
|
59
65
|
setPlusSixMonths: () => void;
|
|
60
66
|
setPlusYear: () => void;
|
|
61
67
|
formatValue(value: any, options: any, props: any): any;
|
|
62
|
-
|
|
68
|
+
getCurrentDateOrPathDate(path: any): moment.Moment | undefined;
|
|
63
69
|
}
|
|
64
70
|
import * as React from "react";
|
|
65
71
|
import * as moment from "moment";
|
|
@@ -103,10 +103,20 @@ let DateTimeWidget = DateTimeWidget_1 = class DateTimeWidget extends React.Compo
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
this.setPlusSixMonths = () => {
|
|
106
|
-
|
|
106
|
+
const plusSixMonthOptions = utils_1.getUiOptions(this.props).showButtons.plusSixMonths || {};
|
|
107
|
+
const { path } = plusSixMonthOptions;
|
|
108
|
+
const date = this.getCurrentDateOrPathDate(path);
|
|
109
|
+
if (date) {
|
|
110
|
+
this.onChange(date.add(6, "M").format("YYYY-MM-DD"));
|
|
111
|
+
}
|
|
107
112
|
};
|
|
108
113
|
this.setPlusYear = () => {
|
|
109
|
-
|
|
114
|
+
const plusYearOptions = utils_1.getUiOptions(this.props).showButtons.plusYear || {};
|
|
115
|
+
const { path } = plusYearOptions;
|
|
116
|
+
const date = this.getCurrentDateOrPathDate(path);
|
|
117
|
+
if (date) {
|
|
118
|
+
this.onChange(date.add(1, "y").format("YYYY-MM-DD"));
|
|
119
|
+
}
|
|
110
120
|
};
|
|
111
121
|
momentLocalizer(moment);
|
|
112
122
|
}
|
|
@@ -225,12 +235,16 @@ let DateTimeWidget = DateTimeWidget_1 = class DateTimeWidget extends React.Compo
|
|
|
225
235
|
const { inputFormat: format } = DateTimeWidget_1.prototype.getStateFromProps(Object.assign(Object.assign({}, props), { date: true, time: true, value }));
|
|
226
236
|
return localizers_1.date.format(value, format, props.formContext.lang);
|
|
227
237
|
}
|
|
228
|
-
|
|
229
|
-
const
|
|
238
|
+
getCurrentDateOrPathDate(path) {
|
|
239
|
+
const formData = this.props.formContext.services.rootInstance.getFormData();
|
|
240
|
+
const value = this.props.value || (path ? utils_1.parseJSONPointer(formData, path, !!"safely") : undefined);
|
|
241
|
+
if (!value) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const date = moment(value);
|
|
230
245
|
if (date.isValid()) {
|
|
231
246
|
return date;
|
|
232
247
|
}
|
|
233
|
-
return moment();
|
|
234
248
|
}
|
|
235
249
|
};
|
|
236
250
|
DateTimeWidget.contextType = ReactContext_1.default;
|
|
@@ -247,6 +261,18 @@ DateTimeWidget.propTypes = {
|
|
|
247
261
|
PropTypes.shape({
|
|
248
262
|
path: PropTypes.string
|
|
249
263
|
})
|
|
264
|
+
]),
|
|
265
|
+
plusSixMonths: PropTypes.oneOfType([
|
|
266
|
+
PropTypes.bool,
|
|
267
|
+
PropTypes.shape({
|
|
268
|
+
path: PropTypes.string
|
|
269
|
+
})
|
|
270
|
+
]),
|
|
271
|
+
plusSixYear: PropTypes.oneOfType([
|
|
272
|
+
PropTypes.bool,
|
|
273
|
+
PropTypes.shape({
|
|
274
|
+
path: PropTypes.string
|
|
275
|
+
})
|
|
250
276
|
])
|
|
251
277
|
})
|
|
252
278
|
]),
|
|
@@ -10,6 +10,12 @@ declare namespace DateWidget {
|
|
|
10
10
|
same: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
11
11
|
path: PropTypes.Requireable<string>;
|
|
12
12
|
}>>;
|
|
13
|
+
plusSixMonths: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
14
|
+
path: PropTypes.Requireable<string>;
|
|
15
|
+
}>>;
|
|
16
|
+
plusSixYear: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
17
|
+
path: PropTypes.Requireable<string>;
|
|
18
|
+
}>>;
|
|
13
19
|
}>>;
|
|
14
20
|
allowOnlyYear: PropTypes.Requireable<boolean>;
|
|
15
21
|
}>>;
|
|
@@ -27,6 +27,18 @@ DateWidget.propTypes = {
|
|
|
27
27
|
PropTypes.shape({
|
|
28
28
|
path: PropTypes.string
|
|
29
29
|
})
|
|
30
|
+
]),
|
|
31
|
+
plusSixMonths: PropTypes.oneOfType([
|
|
32
|
+
PropTypes.bool,
|
|
33
|
+
PropTypes.shape({
|
|
34
|
+
path: PropTypes.string
|
|
35
|
+
})
|
|
36
|
+
]),
|
|
37
|
+
plusSixYear: PropTypes.oneOfType([
|
|
38
|
+
PropTypes.bool,
|
|
39
|
+
PropTypes.shape({
|
|
40
|
+
path: PropTypes.string
|
|
41
|
+
})
|
|
30
42
|
])
|
|
31
43
|
})
|
|
32
44
|
]),
|