@luomus/laji-form 15.1.0 → 15.1.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.
- package/CHANGELOG.md +0 -4
- package/dist/laji-form.js +1 -1
- package/jsonconfig.json +26 -0
- package/migrate.sh +0 -1
- package/package.json +8 -8
- package/test-export/test-utils.d.ts +100 -54
- package/test-export/test-utils.js +102 -84
- package/xsel -b +9 -0
- package/cypress/fixtures/example.json +0 -5
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and closes suggestion list (failed).png +0 -0
- package/cypress/screenshots/nafi.cy.ts/NAFI (MHL.6) -- selecting species name with keyboard navigation -- and is marked as suggested (failed).png +0 -0
- package/lib/ApiClient.d.ts +0 -46
- package/lib/ApiClient.js +0 -93
- package/lib/Context.d.ts +0 -8
- package/lib/Context.js +0 -18
- package/lib/ReactContext.d.ts +0 -7
- package/lib/ReactContext.js +0 -5
- package/lib/components/BaseComponent.d.ts +0 -9
- package/lib/components/BaseComponent.js +0 -29
- package/lib/components/LajiForm.d.ts +0 -221
- package/lib/components/LajiForm.js +0 -615
- package/lib/components/VirtualSchemaField.d.ts +0 -42
- package/lib/components/VirtualSchemaField.js +0 -74
- package/lib/components/components.d.ts +0 -119
- package/lib/components/components.js +0 -606
- package/lib/components/fields/AnnotationField.d.ts +0 -34
- package/lib/components/fields/AnnotationField.js +0 -242
- package/lib/components/fields/AnyToBooleanField.d.ts +0 -18
- package/lib/components/fields/AnyToBooleanField.js +0 -20
- package/lib/components/fields/ArrayBulkField.d.ts +0 -23
- package/lib/components/fields/ArrayBulkField.js +0 -82
- package/lib/components/fields/ArrayCombinerField.d.ts +0 -36
- package/lib/components/fields/ArrayCombinerField.js +0 -138
- package/lib/components/fields/ArrayField.d.ts +0 -39
- package/lib/components/fields/ArrayField.js +0 -148
- package/lib/components/fields/AudioArrayField.d.ts +0 -22
- package/lib/components/fields/AudioArrayField.js +0 -100
- package/lib/components/fields/AutoArrayField.d.ts +0 -24
- package/lib/components/fields/AutoArrayField.js +0 -56
- package/lib/components/fields/AutosuggestField.d.ts +0 -69
- package/lib/components/fields/AutosuggestField.js +0 -299
- package/lib/components/fields/CombinedValueDisplayField.d.ts +0 -41
- package/lib/components/fields/CombinedValueDisplayField.js +0 -100
- package/lib/components/fields/ConditionalOnChangeField.d.ts +0 -42
- package/lib/components/fields/ConditionalOnChangeField.js +0 -107
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +0 -123
- package/lib/components/fields/ConditionalUiSchemaField.js +0 -143
- package/lib/components/fields/ContextInjectionField.d.ts +0 -24
- package/lib/components/fields/ContextInjectionField.js +0 -68
- package/lib/components/fields/DataLeakerField.d.ts +0 -40
- package/lib/components/fields/DataLeakerField.js +0 -68
- package/lib/components/fields/DefaultValueArrayField.d.ts +0 -34
- package/lib/components/fields/DefaultValueArrayField.js +0 -59
- package/lib/components/fields/DependentBooleanField.d.ts +0 -38
- package/lib/components/fields/DependentBooleanField.js +0 -87
- package/lib/components/fields/DependentDisableField.d.ts +0 -35
- package/lib/components/fields/DependentDisableField.js +0 -71
- package/lib/components/fields/EnumRangeArrayField.d.ts +0 -27
- package/lib/components/fields/EnumRangeArrayField.js +0 -115
- package/lib/components/fields/ExtraLabelRowField.d.ts +0 -38
- package/lib/components/fields/ExtraLabelRowField.js +0 -100
- package/lib/components/fields/FakePropertyField.d.ts +0 -18
- package/lib/components/fields/FakePropertyField.js +0 -48
- package/lib/components/fields/FilterArrayField.d.ts +0 -73
- package/lib/components/fields/FilterArrayField.js +0 -121
- package/lib/components/fields/FlatField.d.ts +0 -29
- package/lib/components/fields/FlatField.js +0 -171
- package/lib/components/fields/GeocoderField.d.ts +0 -47
- package/lib/components/fields/GeocoderField.js +0 -372
- package/lib/components/fields/GridLayoutField.d.ts +0 -18
- package/lib/components/fields/GridLayoutField.js +0 -32
- package/lib/components/fields/HiddenField.d.ts +0 -10
- package/lib/components/fields/HiddenField.js +0 -11
- package/lib/components/fields/ImageArrayField.d.ts +0 -172
- package/lib/components/fields/ImageArrayField.js +0 -697
- package/lib/components/fields/ImageDisplayField.d.ts +0 -18
- package/lib/components/fields/ImageDisplayField.js +0 -44
- package/lib/components/fields/InitiallyHiddenField.d.ts +0 -21
- package/lib/components/fields/InitiallyHiddenField.js +0 -58
- package/lib/components/fields/InjectDefaultValueField.d.ts +0 -37
- package/lib/components/fields/InjectDefaultValueField.js +0 -68
- package/lib/components/fields/InjectField.d.ts +0 -46
- package/lib/components/fields/InjectField.js +0 -88
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +0 -25
- package/lib/components/fields/InputWithDefaultValueButtonField.js +0 -61
- package/lib/components/fields/LocalityField.d.ts +0 -22
- package/lib/components/fields/LocalityField.js +0 -94
- package/lib/components/fields/LocationChooserField.d.ts +0 -27
- package/lib/components/fields/LocationChooserField.js +0 -440
- package/lib/components/fields/MapArrayField.d.ts +0 -78
- package/lib/components/fields/MapArrayField.js +0 -1783
- package/lib/components/fields/MapField.d.ts +0 -48
- package/lib/components/fields/MapField.js +0 -434
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +0 -25
- package/lib/components/fields/MultiAnyToBooleanField.js +0 -100
- package/lib/components/fields/MultiArrayField.d.ts +0 -53
- package/lib/components/fields/MultiArrayField.js +0 -224
- package/lib/components/fields/MultiLanguageField.d.ts +0 -13
- package/lib/components/fields/MultiLanguageField.js +0 -52
- package/lib/components/fields/MultiTagArrayField.d.ts +0 -36
- package/lib/components/fields/MultiTagArrayField.js +0 -142
- package/lib/components/fields/NamedPlaceChooserField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceChooserField.js +0 -380
- package/lib/components/fields/NamedPlaceSaverField.d.ts +0 -29
- package/lib/components/fields/NamedPlaceSaverField.js +0 -237
- package/lib/components/fields/NestField.d.ts +0 -148
- package/lib/components/fields/NestField.js +0 -289
- package/lib/components/fields/ObjectField.d.ts +0 -2
- package/lib/components/fields/ObjectField.js +0 -119
- package/lib/components/fields/PdfArrayField.d.ts +0 -21
- package/lib/components/fields/PdfArrayField.js +0 -40
- package/lib/components/fields/PrefillingArrayField.d.ts +0 -22
- package/lib/components/fields/PrefillingArrayField.js +0 -65
- package/lib/components/fields/SchemaField.d.ts +0 -7
- package/lib/components/fields/SchemaField.js +0 -109
- package/lib/components/fields/ScopeField.d.ts +0 -85
- package/lib/components/fields/ScopeField.js +0 -521
- package/lib/components/fields/SectionArrayField.d.ts +0 -38
- package/lib/components/fields/SectionArrayField.js +0 -618
- package/lib/components/fields/SelectTreeField.d.ts +0 -39
- package/lib/components/fields/SelectTreeField.js +0 -143
- package/lib/components/fields/SingleActiveArrayField.d.ts +0 -49
- package/lib/components/fields/SingleActiveArrayField.js +0 -974
- package/lib/components/fields/SingleItemArrayField.d.ts +0 -15
- package/lib/components/fields/SingleItemArrayField.js +0 -60
- package/lib/components/fields/SortArrayField.d.ts +0 -73
- package/lib/components/fields/SortArrayField.js +0 -351
- package/lib/components/fields/SplitField.d.ts +0 -28
- package/lib/components/fields/SplitField.js +0 -65
- package/lib/components/fields/StringToArrayField.d.ts +0 -24
- package/lib/components/fields/StringToArrayField.js +0 -48
- package/lib/components/fields/SumField.d.ts +0 -35
- package/lib/components/fields/SumField.js +0 -83
- package/lib/components/fields/TableField.d.ts +0 -18
- package/lib/components/fields/TableField.js +0 -136
- package/lib/components/fields/TagArrayField.d.ts +0 -38
- package/lib/components/fields/TagArrayField.js +0 -128
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +0 -26
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +0 -81
- package/lib/components/fields/UiFieldApplierField.d.ts +0 -30
- package/lib/components/fields/UiFieldApplierField.js +0 -106
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +0 -42
- package/lib/components/fields/UiFieldMapperArrayField.js +0 -121
- package/lib/components/fields/UnitCountShorthandField.d.ts +0 -22
- package/lib/components/fields/UnitCountShorthandField.js +0 -149
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +0 -26
- package/lib/components/fields/UnitListShorthandArrayField.js +0 -108
- package/lib/components/fields/UnitShorthandField.d.ts +0 -32
- package/lib/components/fields/UnitShorthandField.js +0 -220
- package/lib/components/templates/ArrayFieldTemplate.d.ts +0 -85
- package/lib/components/templates/ArrayFieldTemplate.js +0 -417
- package/lib/components/templates/BaseInputTemplate.d.ts +0 -11
- package/lib/components/templates/BaseInputTemplate.js +0 -80
- package/lib/components/templates/DescriptionField.d.ts +0 -1
- package/lib/components/templates/DescriptionField.js +0 -37
- package/lib/components/templates/ErrorListTemplate.d.ts +0 -9
- package/lib/components/templates/ErrorListTemplate.js +0 -95
- package/lib/components/templates/FieldTemplate.d.ts +0 -6
- package/lib/components/templates/FieldTemplate.js +0 -112
- package/lib/components/templates/ObjectFieldTemplate.d.ts +0 -7
- package/lib/components/templates/ObjectFieldTemplate.js +0 -66
- package/lib/components/templates/TitleField.d.ts +0 -9
- package/lib/components/templates/TitleField.js +0 -51
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +0 -20
- package/lib/components/widgets/AnyToBooleanWidget.js +0 -49
- package/lib/components/widgets/AutosuggestWidget.d.ts +0 -66
- package/lib/components/widgets/AutosuggestWidget.js +0 -1127
- package/lib/components/widgets/CheckboxWidget.d.ts +0 -37
- package/lib/components/widgets/CheckboxWidget.js +0 -139
- package/lib/components/widgets/DateTimeWidget.d.ts +0 -62
- package/lib/components/widgets/DateTimeWidget.js +0 -251
- package/lib/components/widgets/DateWidget.d.ts +0 -23
- package/lib/components/widgets/DateWidget.js +0 -41
- package/lib/components/widgets/HiddenWidget.d.ts +0 -15
- package/lib/components/widgets/HiddenWidget.js +0 -19
- package/lib/components/widgets/ImageSelectWidget.d.ts +0 -14
- package/lib/components/widgets/ImageSelectWidget.js +0 -57
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +0 -43
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +0 -237
- package/lib/components/widgets/InputGroupWidget.d.ts +0 -21
- package/lib/components/widgets/InputGroupWidget.js +0 -36
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +0 -21
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +0 -47
- package/lib/components/widgets/NumberWidget.d.ts +0 -13
- package/lib/components/widgets/NumberWidget.js +0 -21
- package/lib/components/widgets/PlainTextWidget.d.ts +0 -12
- package/lib/components/widgets/PlainTextWidget.js +0 -24
- package/lib/components/widgets/SelectWidget.d.ts +0 -52
- package/lib/components/widgets/SelectWidget.js +0 -158
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +0 -19
- package/lib/components/widgets/SeparatedDateTimeWidget.js +0 -59
- package/lib/components/widgets/TaxonImageWidget.d.ts +0 -13
- package/lib/components/widgets/TaxonImageWidget.js +0 -30
- package/lib/components/widgets/TextSelectWidget.d.ts +0 -25
- package/lib/components/widgets/TextSelectWidget.js +0 -94
- package/lib/components/widgets/TextareaWidget.d.ts +0 -32
- package/lib/components/widgets/TextareaWidget.js +0 -87
- package/lib/components/widgets/TimeWidget.d.ts +0 -11
- package/lib/components/widgets/TimeWidget.js +0 -19
- package/lib/components/widgets/URLWidget.d.ts +0 -14
- package/lib/components/widgets/URLWidget.js +0 -12
- package/lib/components/widgets/UpperCaseWidget.d.ts +0 -13
- package/lib/components/widgets/UpperCaseWidget.js +0 -21
- package/lib/index.d.ts +0 -20
- package/lib/index.js +0 -50
- package/lib/services/blocker-service.d.ts +0 -11
- package/lib/services/blocker-service.js +0 -55
- package/lib/services/custom-event-service.d.ts +0 -17
- package/lib/services/custom-event-service.js +0 -35
- package/lib/services/dom-id-service.d.ts +0 -8
- package/lib/services/dom-id-service.js +0 -30
- package/lib/services/focus-service.d.ts +0 -13
- package/lib/services/focus-service.js +0 -60
- package/lib/services/id-service.d.ts +0 -22
- package/lib/services/id-service.js +0 -130
- package/lib/services/key-handler-service.d.ts +0 -56
- package/lib/services/key-handler-service.js +0 -184
- package/lib/services/root-instance-service.d.ts +0 -25
- package/lib/services/root-instance-service.js +0 -49
- package/lib/services/settings-service.d.ts +0 -34
- package/lib/services/settings-service.js +0 -154
- package/lib/services/singleton-map-service.d.ts +0 -23
- package/lib/services/singleton-map-service.js +0 -44
- package/lib/services/submit-hook-service.d.ts +0 -24
- package/lib/services/submit-hook-service.js +0 -73
- package/lib/styles.d.ts +0 -1
- package/lib/styles.js +0 -4
- package/lib/themes/bs3.d.ts +0 -3
- package/lib/themes/bs3.js +0 -133
- package/lib/themes/bs5.d.ts +0 -3
- package/lib/themes/bs5.js +0 -111
- package/lib/themes/glyphicon-fa-mapping.d.ts +0 -3
- package/lib/themes/glyphicon-fa-mapping.js +0 -271
- package/lib/themes/stub.d.ts +0 -3
- package/lib/themes/stub.js +0 -82
- package/lib/themes/theme.d.ts +0 -233
- package/lib/themes/theme.js +0 -2
- package/lib/translations.json +0 -847
- package/lib/utils.d.ts +0 -171
- package/lib/utils.js +0 -1191
- package/lib/validation.d.ts +0 -7
- package/lib/validation.js +0 -141
- package/llol +0 -10
- package/llol.pdf +0 -10
- package/playwright-report/index.html +0 -62
- package/q +0 -196
- package/rename.sh +0 -24
- package/trip-report.spec.ts +0 -594
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export default class CheckboxWidget extends React.Component<any, any, any> {
|
|
2
|
-
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
-
static propTypes: {
|
|
4
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
-
allowUndefined: PropTypes.Requireable<boolean>;
|
|
7
|
-
showUndefined: PropTypes.Requireable<boolean>;
|
|
8
|
-
invert: PropTypes.Requireable<boolean>;
|
|
9
|
-
trueLabel: PropTypes.Requireable<string>;
|
|
10
|
-
falseLabel: PropTypes.Requireable<string>;
|
|
11
|
-
unknownLabel: PropTypes.Requireable<string>;
|
|
12
|
-
}>>;
|
|
13
|
-
}>>;
|
|
14
|
-
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
15
|
-
type: PropTypes.Requireable<string>;
|
|
16
|
-
}>>;
|
|
17
|
-
value: PropTypes.Requireable<boolean>;
|
|
18
|
-
};
|
|
19
|
-
constructor(props: any);
|
|
20
|
-
trueRef: React.RefObject<any>;
|
|
21
|
-
falseRef: React.RefObject<any>;
|
|
22
|
-
undefinedRef: React.RefObject<any>;
|
|
23
|
-
groupRef: React.RefObject<any>;
|
|
24
|
-
rmInputTabIndices: () => void;
|
|
25
|
-
onChange: (value: any) => void;
|
|
26
|
-
onButtonGroupChange: (value: any) => void;
|
|
27
|
-
getOptions: (props: any) => any;
|
|
28
|
-
getToggleMode: (props: any) => boolean;
|
|
29
|
-
onGroupKeyDown: any;
|
|
30
|
-
onTrueKeyDown: any;
|
|
31
|
-
onFalseKeyDown: any;
|
|
32
|
-
onUndefinedKeyDown: any;
|
|
33
|
-
toggle: (e: any) => void;
|
|
34
|
-
formatValue(value: any, options: any, props: any): any;
|
|
35
|
-
}
|
|
36
|
-
import * as React from "react";
|
|
37
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const react_dom_1 = require("react-dom");
|
|
5
|
-
const PropTypes = require("prop-types");
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
8
|
-
class CheckboxWidget extends React.Component {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
this.rmInputTabIndices = () => {
|
|
12
|
-
[this.trueRef, this.falseRef, this.undefinedRef].forEach(node => {
|
|
13
|
-
const domNode = react_dom_1.findDOMNode(node.current);
|
|
14
|
-
if (!domNode) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const input = domNode.getElementsByTagName("input")[0];
|
|
18
|
-
if (!input) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
input.setAttribute("tabindex", -1);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
this.onChange = (value) => {
|
|
25
|
-
if (value !== undefined && this.getOptions(this.props).invert) {
|
|
26
|
-
value = !value;
|
|
27
|
-
}
|
|
28
|
-
this.props.onChange(value);
|
|
29
|
-
};
|
|
30
|
-
this.onButtonGroupChange = (value) => {
|
|
31
|
-
if (value === "undefined") {
|
|
32
|
-
value = undefined;
|
|
33
|
-
}
|
|
34
|
-
this.onChange(value);
|
|
35
|
-
};
|
|
36
|
-
this.getOptions = (props) => {
|
|
37
|
-
const { Yes, No, Unknown } = props.registry.formContext.translations;
|
|
38
|
-
return Object.assign({ allowUndefined: true, showUndefined: true, invert: false, trueLabel: Yes, falseLabel: No, unknownLabel: Unknown, required: this.props.required }, utils_1.getUiOptions(props));
|
|
39
|
-
};
|
|
40
|
-
this.getToggleMode = (props) => {
|
|
41
|
-
const { allowUndefined, showUndefined, falseLabel, trueLabel } = this.getOptions(props);
|
|
42
|
-
const displayUndefined = (allowUndefined && showUndefined);
|
|
43
|
-
const { Yes, No } = props.registry.formContext.translations;
|
|
44
|
-
return !displayUndefined && (trueLabel === Yes && falseLabel === No);
|
|
45
|
-
};
|
|
46
|
-
this.onGroupKeyDown = this.props.formContext.utils.keyboardClick((e) => {
|
|
47
|
-
this.getToggleMode(this.props) && this.toggle(e);
|
|
48
|
-
});
|
|
49
|
-
this.onTrueKeyDown = this.props.formContext.utils.keyboardClick(() => {
|
|
50
|
-
if (this.props.disabled || this.props.readonly) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this.onChange(true);
|
|
54
|
-
});
|
|
55
|
-
this.onFalseKeyDown = this.props.formContext.utils.keyboardClick(() => {
|
|
56
|
-
if (this.props.disabled || this.props.readonly) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.onChange(false);
|
|
60
|
-
});
|
|
61
|
-
this.onUndefinedKeyDown = this.props.formContext.utils.keyboardClick(() => {
|
|
62
|
-
this.onChange(undefined);
|
|
63
|
-
});
|
|
64
|
-
this.toggle = (e) => {
|
|
65
|
-
if (this.props.disabled || this.props.readonly) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const nodes = [this.trueRef, this.falseRef, this.groupRef].map(r => react_dom_1.findDOMNode(r.current));
|
|
69
|
-
if (!nodes.includes(e.target)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
this.props.onChange(!this.props.value);
|
|
74
|
-
};
|
|
75
|
-
this.trueRef = React.createRef();
|
|
76
|
-
this.falseRef = React.createRef();
|
|
77
|
-
this.undefinedRef = React.createRef();
|
|
78
|
-
this.groupRef = React.createRef();
|
|
79
|
-
}
|
|
80
|
-
componentDidMount() {
|
|
81
|
-
this.rmInputTabIndices();
|
|
82
|
-
}
|
|
83
|
-
componentDidUpdate() {
|
|
84
|
-
this.rmInputTabIndices();
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
const { value, disabled, readonly, label, id } = this.props;
|
|
88
|
-
const options = this.getOptions(this.props);
|
|
89
|
-
const { allowUndefined, showUndefined, invert, trueLabel, falseLabel, unknownLabel, required, label: uiOptionsLabel } = options;
|
|
90
|
-
const hasLabel = !utils_1.isEmptyString(label) && uiOptionsLabel !== false;
|
|
91
|
-
// "undefined" for silencing ToggleButton warning.
|
|
92
|
-
const _value = value === undefined
|
|
93
|
-
? "undefined"
|
|
94
|
-
: invert
|
|
95
|
-
? !value
|
|
96
|
-
: value;
|
|
97
|
-
const { ButtonToolbar, ToggleButton, ToggleButtonGroup } = this.context.theme;
|
|
98
|
-
const displayUndefined = (allowUndefined && showUndefined);
|
|
99
|
-
const toggleMode = this.getToggleMode(this.props);
|
|
100
|
-
const _disabled = disabled || readonly;
|
|
101
|
-
const commonProps = {
|
|
102
|
-
disabled: _disabled,
|
|
103
|
-
tabIndex: (toggleMode || _disabled) ? undefined : 0
|
|
104
|
-
};
|
|
105
|
-
const tabTargetClass = "laji-form-checkbox-widget-tab-target";
|
|
106
|
-
const checkbox = (React.createElement(ButtonToolbar, { className: utils_1.classNames(toggleMode && "desktop-layout") },
|
|
107
|
-
React.createElement(ToggleButtonGroup, Object.assign({ ref: this.groupRef, type: "radio", value: [_value], name: this.props.id, onChange: this.onButtonGroupChange, onKeyDown: this.onGroupKeyDown, className: utils_1.classNames(toggleMode && tabTargetClass) }, commonProps, { tabIndex: (toggleMode && !_disabled) ? 0 : undefined }),
|
|
108
|
-
React.createElement(ToggleButton, Object.assign({ id: `${id}-true`, ref: this.trueRef, value: true, onClick: toggleMode ? this.toggle : undefined, className: utils_1.classNames(toggleMode && _value === false && "laji-form-hide-btn-label", !toggleMode && tabTargetClass), onKeyDown: this.onTrueKeyDown }, commonProps), trueLabel),
|
|
109
|
-
React.createElement(ToggleButton, Object.assign({ id: `${id}-false`, ref: this.falseRef, value: false, onClick: toggleMode ? this.toggle : undefined, className: utils_1.classNames(toggleMode && _value === true && "laji-form-hide-btn-label"), onKeyDown: this.onFalseKeyDown }, commonProps), falseLabel),
|
|
110
|
-
(displayUndefined ? React.createElement(ToggleButton, Object.assign({ id: `${id}-undefined`, ref: this.undefinedRef, value: "undefined" }, commonProps, { onKeyDown: this.onUndefinedKeyDown }), unknownLabel) : null))));
|
|
111
|
-
const { Label } = this.props.formContext;
|
|
112
|
-
return !hasLabel ? checkbox : (React.createElement(Label, { label: label, required: required, uiSchema: options, contextId: this.props.formContext.contextId }, checkbox));
|
|
113
|
-
}
|
|
114
|
-
formatValue(value, options, props) {
|
|
115
|
-
return value === undefined
|
|
116
|
-
? ""
|
|
117
|
-
: value === true
|
|
118
|
-
? props.formContext.translations.Yes
|
|
119
|
-
: props.formContext.translations.No;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.default = CheckboxWidget;
|
|
123
|
-
CheckboxWidget.contextType = ReactContext_1.default;
|
|
124
|
-
CheckboxWidget.propTypes = {
|
|
125
|
-
uiSchema: PropTypes.shape({
|
|
126
|
-
"ui:options": PropTypes.shape({
|
|
127
|
-
allowUndefined: PropTypes.bool,
|
|
128
|
-
showUndefined: PropTypes.bool,
|
|
129
|
-
invert: PropTypes.bool,
|
|
130
|
-
trueLabel: PropTypes.string,
|
|
131
|
-
falseLabel: PropTypes.string,
|
|
132
|
-
unknownLabel: PropTypes.string
|
|
133
|
-
})
|
|
134
|
-
}),
|
|
135
|
-
schema: PropTypes.shape({
|
|
136
|
-
type: PropTypes.oneOf(["boolean"])
|
|
137
|
-
}),
|
|
138
|
-
value: PropTypes.bool
|
|
139
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export const YEAR_MATCH: RegExp;
|
|
2
|
-
export default class DateTimeWidget extends React.Component<any, any, any> {
|
|
3
|
-
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
4
|
-
static propTypes: {
|
|
5
|
-
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
7
|
-
showButtons: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
8
|
-
today: PropTypes.Requireable<boolean>;
|
|
9
|
-
yesterday: PropTypes.Requireable<boolean>;
|
|
10
|
-
same: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
11
|
-
path: PropTypes.Requireable<string>;
|
|
12
|
-
}>>;
|
|
13
|
-
}>>;
|
|
14
|
-
showTimeList: PropTypes.Requireable<boolean>;
|
|
15
|
-
allowOnlyYear: PropTypes.Requireable<boolean>;
|
|
16
|
-
dateFormat: PropTypes.Requireable<string>;
|
|
17
|
-
}>>;
|
|
18
|
-
}>>;
|
|
19
|
-
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
20
|
-
type: PropTypes.Requireable<string>;
|
|
21
|
-
}>>;
|
|
22
|
-
value: PropTypes.Requireable<string>;
|
|
23
|
-
};
|
|
24
|
-
static defaultProps: {
|
|
25
|
-
type: string;
|
|
26
|
-
readonly: boolean;
|
|
27
|
-
disabled: boolean;
|
|
28
|
-
required: boolean;
|
|
29
|
-
calendar: boolean;
|
|
30
|
-
time: boolean;
|
|
31
|
-
};
|
|
32
|
-
constructor(props: any);
|
|
33
|
-
focus: () => void;
|
|
34
|
-
getStateFromProps(props: any): {
|
|
35
|
-
dateFormat: any;
|
|
36
|
-
timeFormat: string;
|
|
37
|
-
format: string;
|
|
38
|
-
inputFormat: any;
|
|
39
|
-
placeholder: string;
|
|
40
|
-
};
|
|
41
|
-
parse: (value: any) => any;
|
|
42
|
-
timeWritten: any;
|
|
43
|
-
onlyYearWritten: any;
|
|
44
|
-
onChange: (value: any) => void;
|
|
45
|
-
onToggle: (p: any) => void;
|
|
46
|
-
toggle: any;
|
|
47
|
-
setRef: (elem: any) => void;
|
|
48
|
-
dateTimePickerRef: any;
|
|
49
|
-
setContainerRef: (elem: any) => void;
|
|
50
|
-
containerRef: any;
|
|
51
|
-
onTextWidgetFocus: () => void;
|
|
52
|
-
onBlur: () => void;
|
|
53
|
-
onDateTimePickerChange: (value: any) => void;
|
|
54
|
-
renderButtons(showButtons: any): JSX.Element[];
|
|
55
|
-
getDateWithCurrentTime: (date: any) => any;
|
|
56
|
-
setToday: () => void;
|
|
57
|
-
setYesterday: () => void;
|
|
58
|
-
setSameAsToday: () => void;
|
|
59
|
-
formatValue(value: any, options: any, props: any): any;
|
|
60
|
-
}
|
|
61
|
-
import * as React from "react";
|
|
62
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,251 +0,0 @@
|
|
|
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
|
-
var DateTimeWidget_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.YEAR_MATCH = void 0;
|
|
11
|
-
const React = require("react");
|
|
12
|
-
const react_dom_1 = require("react-dom");
|
|
13
|
-
const PropTypes = require("prop-types");
|
|
14
|
-
const DateTimePicker = require("react-widgets/lib/DateTimePicker");
|
|
15
|
-
const moment = require("moment");
|
|
16
|
-
const momentLocalizer = require("react-widgets-moment");
|
|
17
|
-
const localizers_1 = require("react-widgets/lib/util/localizers");
|
|
18
|
-
const utils_1 = require("../../utils");
|
|
19
|
-
const BaseComponent_1 = require("../BaseComponent");
|
|
20
|
-
const ReactContext_1 = require("../../ReactContext");
|
|
21
|
-
const DATE_TIME_SEPARATOR = ", ";
|
|
22
|
-
exports.YEAR_MATCH = /^\d{4}$/;
|
|
23
|
-
let DateTimeWidget = DateTimeWidget_1 = class DateTimeWidget extends React.Component {
|
|
24
|
-
constructor(props) {
|
|
25
|
-
super(props);
|
|
26
|
-
this.focus = () => {
|
|
27
|
-
this.dateTimePickerRef.focus();
|
|
28
|
-
};
|
|
29
|
-
this.parse = (value) => {
|
|
30
|
-
if (!value)
|
|
31
|
-
value = "";
|
|
32
|
-
const { allowOnlyYear } = utils_1.getUiOptions(this.props);
|
|
33
|
-
const hasTime = value.includes(DATE_TIME_SEPARATOR) || this.state.time && !this.state.calendar;
|
|
34
|
-
const onlyYear = allowOnlyYear && this.state.calendar && value.match(exports.YEAR_MATCH);
|
|
35
|
-
let momentValue = moment(value, onlyYear ? "YYYY" : this.state.format);
|
|
36
|
-
if (!momentValue.isValid()) {
|
|
37
|
-
return "";
|
|
38
|
-
}
|
|
39
|
-
const isoValue = onlyYear
|
|
40
|
-
? value
|
|
41
|
-
: hasTime
|
|
42
|
-
? momentValue.toISOString()
|
|
43
|
-
: momentValue.format("YYYY-MM-DD");
|
|
44
|
-
this.timeWritten = hasTime;
|
|
45
|
-
this.onlyYearWritten = onlyYear;
|
|
46
|
-
return onlyYear ? isoValue : moment(isoValue).toDate();
|
|
47
|
-
};
|
|
48
|
-
this.onChange = (value) => {
|
|
49
|
-
this.props.onChange(value, !!"force");
|
|
50
|
-
};
|
|
51
|
-
this.onToggle = p => {
|
|
52
|
-
if (p !== false)
|
|
53
|
-
this.toggle = p; //"time" or "date"
|
|
54
|
-
};
|
|
55
|
-
this.setRef = (elem) => {
|
|
56
|
-
this.dateTimePickerRef = elem;
|
|
57
|
-
};
|
|
58
|
-
this.setContainerRef = (elem) => {
|
|
59
|
-
this.containerRef = elem;
|
|
60
|
-
};
|
|
61
|
-
this.onTextWidgetFocus = () => {
|
|
62
|
-
this.setState({ textInputFocused: true }, this.focus);
|
|
63
|
-
};
|
|
64
|
-
this.onBlur = () => {
|
|
65
|
-
!utils_1.isDescendant(react_dom_1.findDOMNode(this.containerRef), document.activeElement) && this.setState({ textInputFocused: false });
|
|
66
|
-
};
|
|
67
|
-
this.onDateTimePickerChange = (value) => {
|
|
68
|
-
const momentValue = moment(value);
|
|
69
|
-
let formattedValue = momentValue.format("YYYY-MM-DDTHH:mm");
|
|
70
|
-
if (this.onlyYearWritten) {
|
|
71
|
-
formattedValue = value;
|
|
72
|
-
}
|
|
73
|
-
else if (value !== null && !momentValue.isValid()) {
|
|
74
|
-
formattedValue = this.props.value;
|
|
75
|
-
}
|
|
76
|
-
else if ((!this.toggle && !this.timeWritten) ||
|
|
77
|
-
(this.toggle === "date" && (!this.props.value || !this.props.value.includes("T")))) {
|
|
78
|
-
formattedValue = momentValue.format("YYYY-MM-DD");
|
|
79
|
-
}
|
|
80
|
-
this.onChange(!value ? undefined : formattedValue);
|
|
81
|
-
this.toggle = undefined;
|
|
82
|
-
this.timeWritten = false;
|
|
83
|
-
this.onlyYearWritten = false;
|
|
84
|
-
};
|
|
85
|
-
this.getDateWithCurrentTime = (date) => {
|
|
86
|
-
const { value } = this.props;
|
|
87
|
-
const time = value !== undefined && value !== null ? value.split("T")[1] : false;
|
|
88
|
-
return time ? `${date}T${time}` : date;
|
|
89
|
-
};
|
|
90
|
-
this.setToday = () => {
|
|
91
|
-
this.onChange(this.getDateWithCurrentTime(moment().format("YYYY-MM-DD")));
|
|
92
|
-
};
|
|
93
|
-
this.setYesterday = () => {
|
|
94
|
-
this.onChange(this.getDateWithCurrentTime(moment().subtract(1, "d").format("YYYY-MM-DD")));
|
|
95
|
-
};
|
|
96
|
-
this.setSameAsToday = () => {
|
|
97
|
-
const formData = this.props.formContext.services.rootInstance.getFormData();
|
|
98
|
-
const sameOptions = utils_1.getUiOptions(this.props).showButtons.same || {};
|
|
99
|
-
const { path = "/gatheringEvent/dateBegin" } = sameOptions;
|
|
100
|
-
const today = utils_1.parseJSONPointer(formData, path, !!"safely");
|
|
101
|
-
if (today) {
|
|
102
|
-
this.onChange(today);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
momentLocalizer(moment);
|
|
106
|
-
}
|
|
107
|
-
componentDidMount() {
|
|
108
|
-
this.props.formContext.services.focus.addFocusHandler(this.props.id, this.focus);
|
|
109
|
-
}
|
|
110
|
-
componentWillUnmount() {
|
|
111
|
-
this.props.formContext.services.focus.removeFocusHandler(this.props.id, this.focus);
|
|
112
|
-
}
|
|
113
|
-
getStateFromProps(props) {
|
|
114
|
-
const { lang, translations } = props.formContext;
|
|
115
|
-
const formatLang = lang === "sv" ? "fi" : lang === "en" ? "en-gb" : lang;
|
|
116
|
-
let localeFormats = moment().locale(formatLang)._locale._longDateFormat;
|
|
117
|
-
let { allowOnlyYear, dateFormat = "" } = utils_1.getUiOptions(props);
|
|
118
|
-
let timeFormat = "";
|
|
119
|
-
let placeholder = "";
|
|
120
|
-
if (props.calendar) {
|
|
121
|
-
if (!dateFormat)
|
|
122
|
-
dateFormat = localeFormats.L;
|
|
123
|
-
placeholder += translations[dateFormat.toLowerCase()] || dateFormat;
|
|
124
|
-
}
|
|
125
|
-
if (props.time) {
|
|
126
|
-
timeFormat = localeFormats.LT;
|
|
127
|
-
if (placeholder)
|
|
128
|
-
placeholder += DATE_TIME_SEPARATOR;
|
|
129
|
-
placeholder += translations[timeFormat.toLowerCase()] || timeFormat;
|
|
130
|
-
}
|
|
131
|
-
const format = `${dateFormat}${dateFormat ? DATE_TIME_SEPARATOR : ""}${timeFormat}`;
|
|
132
|
-
const splitted = props.value && props.value.split("T");
|
|
133
|
-
const hasTime = props.value && splitted.length > 1 && splitted[1] !== "";
|
|
134
|
-
let inputFormat = allowOnlyYear && props.value && props.value.match(exports.YEAR_MATCH)
|
|
135
|
-
? "YYYY"
|
|
136
|
-
: hasTime
|
|
137
|
-
? format
|
|
138
|
-
: dateFormat;
|
|
139
|
-
const state = {
|
|
140
|
-
dateFormat,
|
|
141
|
-
timeFormat,
|
|
142
|
-
format,
|
|
143
|
-
inputFormat,
|
|
144
|
-
placeholder
|
|
145
|
-
};
|
|
146
|
-
["value", "disabled", "time", "calendar"].forEach(prop => {
|
|
147
|
-
if (prop in props) {
|
|
148
|
-
state[prop] = props[prop];
|
|
149
|
-
if (prop === "calendar") {
|
|
150
|
-
state["date"] = props[prop];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return state;
|
|
155
|
-
}
|
|
156
|
-
render() {
|
|
157
|
-
const { value, readonly, disabled } = this.props;
|
|
158
|
-
const { translations, lang } = this.props.formContext;
|
|
159
|
-
const momentValue = moment(value);
|
|
160
|
-
if (!this.state.textInputFocused && value !== null && !momentValue.isValid()) {
|
|
161
|
-
const { TextWidget } = this.props.registry.widgets;
|
|
162
|
-
return React.createElement(TextWidget, Object.assign({}, this.props, { onFocus: this.onTextWidgetFocus }));
|
|
163
|
-
}
|
|
164
|
-
const options = utils_1.getUiOptions(this.props);
|
|
165
|
-
const showTimeList = options.showTimeList !== undefined ? options.showTimeList : true;
|
|
166
|
-
const culture = lang === "en" ? "en-gb" : lang;
|
|
167
|
-
const datePicker = (React.createElement(DateTimePicker, { ref: this.setRef, date: this.state.calendar, time: this.state.time && showTimeList, format: this.state.inputFormat, timeFormat: this.state.timeFormat, placeholder: this.state.placeholder, onToggle: this.onToggle, onChange: this.onDateTimePickerChange, value: value && momentValue.isValid() ? momentValue.toDate() : null, parse: this.parse, disabled: readonly || disabled, culture: culture, messages: {
|
|
168
|
-
calendarButton: translations.ChooseDate,
|
|
169
|
-
timeButton: translations.ChooseTime
|
|
170
|
-
}, onBlur: this.onBlur }));
|
|
171
|
-
const { showButtons } = options;
|
|
172
|
-
const { ButtonGroup } = this.context.theme;
|
|
173
|
-
return showButtons ? (React.createElement("div", { className: "date-widget", ref: this.setContainerRef },
|
|
174
|
-
React.createElement("div", { className: "date-picker" }, datePicker),
|
|
175
|
-
React.createElement(ButtonGroup, null, this.renderButtons(showButtons)))) : React.createElement("div", { className: "date-widget" }, datePicker);
|
|
176
|
-
}
|
|
177
|
-
renderButtons(showButtons) {
|
|
178
|
-
const { readonly, disabled } = this.props;
|
|
179
|
-
const { translations } = this.props.formContext;
|
|
180
|
-
const buttonDefinitions = {
|
|
181
|
-
today: {
|
|
182
|
-
className: "today",
|
|
183
|
-
label: translations.Today,
|
|
184
|
-
onClick: this.setToday
|
|
185
|
-
},
|
|
186
|
-
yesterday: {
|
|
187
|
-
className: "yesterday",
|
|
188
|
-
label: translations.Yesterday,
|
|
189
|
-
onClick: this.setYesterday
|
|
190
|
-
},
|
|
191
|
-
same: {
|
|
192
|
-
className: "same",
|
|
193
|
-
label: translations.Same,
|
|
194
|
-
onClick: this.setSameAsToday
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
const options = showButtons === true
|
|
198
|
-
? { today: true, yesterday: true }
|
|
199
|
-
: showButtons;
|
|
200
|
-
const { Button } = this.context.theme;
|
|
201
|
-
return Object.keys(options)
|
|
202
|
-
.filter(name => options[name])
|
|
203
|
-
.map(name => buttonDefinitions[name])
|
|
204
|
-
.map(({ className, onClick, label }) => (React.createElement(Button, { key: className, className: className, onClick: onClick, disabled: readonly || disabled }, label)));
|
|
205
|
-
}
|
|
206
|
-
formatValue(value, options, props) {
|
|
207
|
-
if (!value)
|
|
208
|
-
return value;
|
|
209
|
-
const { inputFormat: format } = DateTimeWidget_1.prototype.getStateFromProps(Object.assign(Object.assign({}, props), { date: true, time: true, value }));
|
|
210
|
-
return localizers_1.date.format(value, format, props.formContext.lang);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
DateTimeWidget.contextType = ReactContext_1.default;
|
|
214
|
-
DateTimeWidget.propTypes = {
|
|
215
|
-
uiSchema: PropTypes.shape({
|
|
216
|
-
"ui:options": PropTypes.shape({
|
|
217
|
-
showButtons: PropTypes.oneOfType([
|
|
218
|
-
PropTypes.bool,
|
|
219
|
-
PropTypes.shape({
|
|
220
|
-
today: PropTypes.bool,
|
|
221
|
-
yesterday: PropTypes.bool,
|
|
222
|
-
same: PropTypes.oneOfType([
|
|
223
|
-
PropTypes.bool,
|
|
224
|
-
PropTypes.shape({
|
|
225
|
-
path: PropTypes.string
|
|
226
|
-
})
|
|
227
|
-
])
|
|
228
|
-
})
|
|
229
|
-
]),
|
|
230
|
-
showTimeList: PropTypes.bool,
|
|
231
|
-
allowOnlyYear: PropTypes.bool,
|
|
232
|
-
dateFormat: PropTypes.string
|
|
233
|
-
})
|
|
234
|
-
}),
|
|
235
|
-
schema: PropTypes.shape({
|
|
236
|
-
type: PropTypes.oneOf(["string"])
|
|
237
|
-
}),
|
|
238
|
-
value: PropTypes.string
|
|
239
|
-
};
|
|
240
|
-
DateTimeWidget.defaultProps = {
|
|
241
|
-
type: "text",
|
|
242
|
-
readonly: false,
|
|
243
|
-
disabled: false,
|
|
244
|
-
required: false,
|
|
245
|
-
calendar: true,
|
|
246
|
-
time: true
|
|
247
|
-
};
|
|
248
|
-
DateTimeWidget = DateTimeWidget_1 = __decorate([
|
|
249
|
-
BaseComponent_1.default
|
|
250
|
-
], DateTimeWidget);
|
|
251
|
-
exports.default = DateTimeWidget;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default DateWidget;
|
|
2
|
-
declare function DateWidget(props: any): JSX.Element;
|
|
3
|
-
declare namespace DateWidget {
|
|
4
|
-
namespace propTypes {
|
|
5
|
-
const uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
-
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
7
|
-
showButtons: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
8
|
-
today: PropTypes.Requireable<boolean>;
|
|
9
|
-
yesterday: PropTypes.Requireable<boolean>;
|
|
10
|
-
same: PropTypes.Requireable<boolean | PropTypes.InferProps<{
|
|
11
|
-
path: PropTypes.Requireable<string>;
|
|
12
|
-
}>>;
|
|
13
|
-
}>>;
|
|
14
|
-
allowOnlyYear: PropTypes.Requireable<boolean>;
|
|
15
|
-
}>>;
|
|
16
|
-
}>>;
|
|
17
|
-
const schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
18
|
-
type: PropTypes.Requireable<string>;
|
|
19
|
-
}>>;
|
|
20
|
-
const value: PropTypes.Requireable<string>;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const PropTypes = require("prop-types");
|
|
5
|
-
const moment = require("moment");
|
|
6
|
-
const DateTimeWidget_1 = require("./DateTimeWidget");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const format = (allowOnlyYear, value) => moment(value).format(allowOnlyYear && value.match(DateTimeWidget_1.YEAR_MATCH)
|
|
9
|
-
? "YYYY"
|
|
10
|
-
: "YYYY-MM-DD");
|
|
11
|
-
const DateWidget = (props) => {
|
|
12
|
-
const { onChange } = props;
|
|
13
|
-
const { allowOnlyYear } = utils_1.getUiOptions(props);
|
|
14
|
-
const _onChange = React.useCallback((value) => onChange(utils_1.isEmptyString(value) ? undefined : format(allowOnlyYear, value)), [allowOnlyYear, onChange]);
|
|
15
|
-
return (React.createElement(DateTimeWidget_1.default, Object.assign({}, props, { onChange: _onChange, time: false, value: props.value ? format(allowOnlyYear, props.value) : null })));
|
|
16
|
-
};
|
|
17
|
-
DateWidget.propTypes = {
|
|
18
|
-
uiSchema: PropTypes.shape({
|
|
19
|
-
"ui:options": PropTypes.shape({
|
|
20
|
-
showButtons: PropTypes.oneOfType([
|
|
21
|
-
PropTypes.bool,
|
|
22
|
-
PropTypes.shape({
|
|
23
|
-
today: PropTypes.bool,
|
|
24
|
-
yesterday: PropTypes.bool,
|
|
25
|
-
same: PropTypes.oneOfType([
|
|
26
|
-
PropTypes.bool,
|
|
27
|
-
PropTypes.shape({
|
|
28
|
-
path: PropTypes.string
|
|
29
|
-
})
|
|
30
|
-
])
|
|
31
|
-
})
|
|
32
|
-
]),
|
|
33
|
-
allowOnlyYear: PropTypes.bool
|
|
34
|
-
})
|
|
35
|
-
}),
|
|
36
|
-
schema: PropTypes.shape({
|
|
37
|
-
type: PropTypes.oneOf(["string"])
|
|
38
|
-
}),
|
|
39
|
-
value: PropTypes.string
|
|
40
|
-
};
|
|
41
|
-
exports.default = DateWidget;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default HiddenWidget;
|
|
2
|
-
declare function HiddenWidget({ id, value }: {
|
|
3
|
-
id: any;
|
|
4
|
-
value: any;
|
|
5
|
-
}): JSX.Element;
|
|
6
|
-
declare namespace HiddenWidget {
|
|
7
|
-
namespace propTypes {
|
|
8
|
-
const id: PropTypes.Validator<string>;
|
|
9
|
-
const value: PropTypes.Requireable<string | number | boolean>;
|
|
10
|
-
const schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
11
|
-
type: PropTypes.Requireable<string>;
|
|
12
|
-
}>>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
4
|
-
const PropTypes = require("prop-types");
|
|
5
|
-
function HiddenWidget({ id, value }) {
|
|
6
|
-
return (React.createElement("input", { type: "hidden", id: id, value: typeof value === "undefined" ? "" : value }));
|
|
7
|
-
}
|
|
8
|
-
HiddenWidget.propTypes = {
|
|
9
|
-
id: PropTypes.string.isRequired,
|
|
10
|
-
value: PropTypes.oneOfType([
|
|
11
|
-
PropTypes.string,
|
|
12
|
-
PropTypes.number,
|
|
13
|
-
PropTypes.bool,
|
|
14
|
-
]),
|
|
15
|
-
schema: PropTypes.shape({
|
|
16
|
-
type: PropTypes.oneOf(["string", "number", "boolean", "integer"])
|
|
17
|
-
}).isRequired
|
|
18
|
-
};
|
|
19
|
-
exports.default = HiddenWidget;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default class ImageSelectWidget extends React.Component<any, any, any> {
|
|
2
|
-
static propTypes: {
|
|
3
|
-
options: PropTypes.Validator<object>;
|
|
4
|
-
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
|
-
type: PropTypes.Requireable<string>;
|
|
6
|
-
}>>;
|
|
7
|
-
value: PropTypes.Requireable<string>;
|
|
8
|
-
};
|
|
9
|
-
constructor(props: any);
|
|
10
|
-
_context: Record<string, unknown>;
|
|
11
|
-
renderImg: (enumName: any, fallback: any) => any;
|
|
12
|
-
}
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import * as PropTypes from "prop-types";
|
|
@@ -1,57 +0,0 @@
|
|
|
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 Context_1 = require("../../Context");
|
|
12
|
-
const utils_1 = require("../../utils");
|
|
13
|
-
const react_inlinesvg_1 = require("react-inlinesvg");
|
|
14
|
-
const SelectWidget_1 = require("./SelectWidget");
|
|
15
|
-
const BaseComponent_1 = require("../BaseComponent");
|
|
16
|
-
let ImageSelectWidget = class ImageSelectWidget extends React.Component {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this.renderImg = (enumName, fallback) => {
|
|
20
|
-
const imgName = utils_1.getUiOptions(this.props).images[enumName];
|
|
21
|
-
if (imgName === undefined)
|
|
22
|
-
return fallback;
|
|
23
|
-
let path = this._context[enumName] || {};
|
|
24
|
-
try {
|
|
25
|
-
path.svg = `https://cdn.laji.fi/images/${imgName}.svg`;
|
|
26
|
-
path.png = `https://cdn.laji.fi/images/${imgName}.png`;
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
this._context[enumName] = path;
|
|
30
|
-
return React.createElement("span", { className: "select-icon" },
|
|
31
|
-
React.createElement(react_inlinesvg_1.default, { key: enumName, src: path.svg, cacheGetRequests: true },
|
|
32
|
-
React.createElement("img", { src: path.png })));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
this._context = Context_1.default("IMAGES");
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
return (React.createElement(SelectWidget_1.default, Object.assign({}, this.props, { selectProps: {
|
|
39
|
-
renderValue: item => this.renderImg(item.value, item.label),
|
|
40
|
-
renderOption: item => React.createElement("div", null,
|
|
41
|
-
this.renderImg(item.value, item.label),
|
|
42
|
-
" ",
|
|
43
|
-
React.createElement("span", null, item.label))
|
|
44
|
-
} })));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
ImageSelectWidget.propTypes = {
|
|
48
|
-
options: PropTypes.object.isRequired,
|
|
49
|
-
schema: PropTypes.shape({
|
|
50
|
-
type: PropTypes.oneOf(["string"])
|
|
51
|
-
}),
|
|
52
|
-
value: PropTypes.string
|
|
53
|
-
};
|
|
54
|
-
ImageSelectWidget = __decorate([
|
|
55
|
-
BaseComponent_1.default
|
|
56
|
-
], ImageSelectWidget);
|
|
57
|
-
exports.default = ImageSelectWidget;
|