@luomus/laji-form 15.1.37 → 15.1.39
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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PropTypes from "prop-types";
|
|
3
|
+
import { FieldProps, JSONSchemaObject } from "../../types";
|
|
4
|
+
interface State {
|
|
5
|
+
sum: number;
|
|
6
|
+
}
|
|
7
|
+
export default class ArrayPropertySumField extends React.Component<FieldProps<JSONSchemaObject>, State> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
uiSchema: PropTypes.Validator<PropTypes.InferProps<{
|
|
10
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
11
|
+
propertyField: PropTypes.Validator<string>;
|
|
12
|
+
}>>;
|
|
13
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
14
|
+
}>>;
|
|
15
|
+
schema: PropTypes.Validator<object>;
|
|
16
|
+
formData: PropTypes.Validator<any[]>;
|
|
17
|
+
};
|
|
18
|
+
static getName(): string;
|
|
19
|
+
getStateFromProps(props: FieldProps): State;
|
|
20
|
+
render(): JSX.Element;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const React = require("react");
|
|
10
|
+
const PropTypes = require("prop-types");
|
|
11
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
let ArrayPropertySumField = class ArrayPropertySumField extends React.Component {
|
|
14
|
+
static getName() { return "ArrayPropertySumField"; }
|
|
15
|
+
getStateFromProps(props) {
|
|
16
|
+
const { formData = [] } = props;
|
|
17
|
+
const state = { sum: 0 };
|
|
18
|
+
const propertyField = utils_1.getUiOptions(this.props.uiSchema).propertyField;
|
|
19
|
+
state.sum = formData.reduce((acc, item) => acc + (Number(item[propertyField]) || 0), 0);
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
const SchemaField = this.props.registry.fields.SchemaField;
|
|
24
|
+
const { sum } = this.state;
|
|
25
|
+
return (React.createElement(React.Fragment, null,
|
|
26
|
+
React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: utils_1.getInnerUiSchema(this.props.uiSchema) })),
|
|
27
|
+
React.createElement("h4", null,
|
|
28
|
+
this.props.uiSchema["ui:title"],
|
|
29
|
+
": ",
|
|
30
|
+
sum)));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
ArrayPropertySumField.propTypes = {
|
|
34
|
+
uiSchema: PropTypes.shape({
|
|
35
|
+
"ui:options": PropTypes.shape({
|
|
36
|
+
propertyField: PropTypes.string.isRequired
|
|
37
|
+
}),
|
|
38
|
+
uiSchema: PropTypes.object
|
|
39
|
+
}).isRequired,
|
|
40
|
+
schema: PropTypes.object.isRequired,
|
|
41
|
+
formData: PropTypes.array.isRequired
|
|
42
|
+
};
|
|
43
|
+
ArrayPropertySumField = __decorate([
|
|
44
|
+
BaseComponent_1.default
|
|
45
|
+
], ArrayPropertySumField);
|
|
46
|
+
exports.default = ArrayPropertySumField;
|
|
@@ -418,9 +418,9 @@ class MobileEditorMap extends React.Component {
|
|
|
418
418
|
React.createElement("defs", null,
|
|
419
419
|
React.createElement("mask", { id: "mask", x: "0", y: "0", width: "100%", height: "100%" },
|
|
420
420
|
React.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "#fff" }),
|
|
421
|
-
React.createElement("circle", { cx:
|
|
421
|
+
React.createElement("circle", { cx: this.state.width / 2, cy: this.state.height / 2, r: radiusPixels }))),
|
|
422
422
|
React.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.2" }),
|
|
423
|
-
React.createElement("circle", { cx:
|
|
423
|
+
React.createElement("circle", { cx: this.state.width / 2, cy: this.state.height / 2, r: radiusPixels, stroke: "black", strokeWidth: "2", fillOpacity: "0" }),
|
|
424
424
|
React.createElement("line", { x1: this.state.width / 2, y1: this.state.height / 2 - radiusPixels, x2: this.state.width / 2, y2: this.state.height / 2 + radiusPixels, stroke: "black", strokeWidth: "2" }),
|
|
425
425
|
React.createElement("line", { x1: this.state.width / 2 - radiusPixels, y1: this.state.height / 2, x2: this.state.width / 2 + radiusPixels, y2: this.state.height / 2, stroke: "black", strokeWidth: "2" })));
|
|
426
426
|
}
|