@luomus/laji-form 15.1.5 → 15.1.7
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/lib/ApiClient.d.ts +46 -0
- package/lib/ApiClient.js +93 -0
- package/lib/Context.d.ts +8 -0
- package/lib/Context.js +18 -0
- package/lib/ReactContext.d.ts +7 -0
- package/lib/ReactContext.js +5 -0
- package/lib/components/BaseComponent.d.ts +9 -0
- package/lib/components/BaseComponent.js +29 -0
- package/lib/components/LajiForm.d.ts +221 -0
- package/lib/components/LajiForm.js +616 -0
- package/lib/components/VirtualSchemaField.d.ts +42 -0
- package/lib/components/VirtualSchemaField.js +74 -0
- package/lib/components/components.d.ts +119 -0
- package/lib/components/components.js +606 -0
- package/lib/components/fields/AnnotationField.d.ts +34 -0
- package/lib/components/fields/AnnotationField.js +242 -0
- package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
- package/lib/components/fields/AnyToBooleanField.js +20 -0
- package/lib/components/fields/ArrayBulkField.d.ts +23 -0
- package/lib/components/fields/ArrayBulkField.js +82 -0
- package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
- package/lib/components/fields/ArrayCombinerField.js +138 -0
- package/lib/components/fields/ArrayField.d.ts +39 -0
- package/lib/components/fields/ArrayField.js +148 -0
- package/lib/components/fields/AsArrayField.d.ts +292 -0
- package/lib/components/fields/AsArrayField.js +38 -0
- package/lib/components/fields/AudioArrayField.d.ts +22 -0
- package/lib/components/fields/AudioArrayField.js +100 -0
- package/lib/components/fields/AutoArrayField.d.ts +24 -0
- package/lib/components/fields/AutoArrayField.js +56 -0
- package/lib/components/fields/AutosuggestField.d.ts +69 -0
- package/lib/components/fields/AutosuggestField.js +299 -0
- package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
- package/lib/components/fields/CombinedValueDisplayField.js +100 -0
- package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
- package/lib/components/fields/ConditionalOnChangeField.js +107 -0
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
- package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
- package/lib/components/fields/ContextInjectionField.d.ts +24 -0
- package/lib/components/fields/ContextInjectionField.js +68 -0
- package/lib/components/fields/DataLeakerField.d.ts +40 -0
- package/lib/components/fields/DataLeakerField.js +68 -0
- package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
- package/lib/components/fields/DefaultValueArrayField.js +59 -0
- package/lib/components/fields/DependentBooleanField.d.ts +38 -0
- package/lib/components/fields/DependentBooleanField.js +87 -0
- package/lib/components/fields/DependentDisableField.d.ts +35 -0
- package/lib/components/fields/DependentDisableField.js +71 -0
- package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
- package/lib/components/fields/EnumRangeArrayField.js +115 -0
- package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
- package/lib/components/fields/ExtraLabelRowField.js +100 -0
- package/lib/components/fields/FakePropertyField.d.ts +18 -0
- package/lib/components/fields/FakePropertyField.js +48 -0
- package/lib/components/fields/FilterArrayField.d.ts +73 -0
- package/lib/components/fields/FilterArrayField.js +121 -0
- package/lib/components/fields/FlatField.d.ts +29 -0
- package/lib/components/fields/FlatField.js +171 -0
- package/lib/components/fields/GeocoderField.d.ts +47 -0
- package/lib/components/fields/GeocoderField.js +372 -0
- package/lib/components/fields/GridLayoutField.d.ts +18 -0
- package/lib/components/fields/GridLayoutField.js +32 -0
- package/lib/components/fields/HiddenField.d.ts +10 -0
- package/lib/components/fields/HiddenField.js +11 -0
- package/lib/components/fields/ImageArrayField.d.ts +172 -0
- package/lib/components/fields/ImageArrayField.js +699 -0
- package/lib/components/fields/ImageDisplayField.d.ts +18 -0
- package/lib/components/fields/ImageDisplayField.js +44 -0
- package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
- package/lib/components/fields/InitiallyHiddenField.js +58 -0
- package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
- package/lib/components/fields/InjectDefaultValueField.js +68 -0
- package/lib/components/fields/InjectField.d.ts +46 -0
- package/lib/components/fields/InjectField.js +88 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
- package/lib/components/fields/LocalityField.d.ts +22 -0
- package/lib/components/fields/LocalityField.js +94 -0
- package/lib/components/fields/LocationChooserField.d.ts +27 -0
- package/lib/components/fields/LocationChooserField.js +440 -0
- package/lib/components/fields/MapArrayField.d.ts +78 -0
- package/lib/components/fields/MapArrayField.js +1783 -0
- package/lib/components/fields/MapField.d.ts +48 -0
- package/lib/components/fields/MapField.js +434 -0
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
- package/lib/components/fields/MultiArrayField.d.ts +53 -0
- package/lib/components/fields/MultiArrayField.js +224 -0
- package/lib/components/fields/MultiLanguageField.d.ts +13 -0
- package/lib/components/fields/MultiLanguageField.js +52 -0
- package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
- package/lib/components/fields/MultiTagArrayField.js +142 -0
- package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceChooserField.js +380 -0
- package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceSaverField.js +237 -0
- package/lib/components/fields/NestField.d.ts +148 -0
- package/lib/components/fields/NestField.js +289 -0
- package/lib/components/fields/ObjectField.d.ts +2 -0
- package/lib/components/fields/ObjectField.js +119 -0
- package/lib/components/fields/PdfArrayField.d.ts +21 -0
- package/lib/components/fields/PdfArrayField.js +40 -0
- package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
- package/lib/components/fields/PrefillingArrayField.js +65 -0
- package/lib/components/fields/SchemaField.d.ts +7 -0
- package/lib/components/fields/SchemaField.js +109 -0
- package/lib/components/fields/ScopeField.d.ts +85 -0
- package/lib/components/fields/ScopeField.js +521 -0
- package/lib/components/fields/SectionArrayField.d.ts +38 -0
- package/lib/components/fields/SectionArrayField.js +618 -0
- package/lib/components/fields/SelectTreeField.d.ts +39 -0
- package/lib/components/fields/SelectTreeField.js +143 -0
- package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
- package/lib/components/fields/SingleActiveArrayField.js +974 -0
- package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
- package/lib/components/fields/SingleItemArrayField.js +60 -0
- package/lib/components/fields/SortArrayField.d.ts +73 -0
- package/lib/components/fields/SortArrayField.js +351 -0
- package/lib/components/fields/SplitField.d.ts +28 -0
- package/lib/components/fields/SplitField.js +65 -0
- package/lib/components/fields/StringToArrayField.d.ts +24 -0
- package/lib/components/fields/StringToArrayField.js +48 -0
- package/lib/components/fields/SumField.d.ts +35 -0
- package/lib/components/fields/SumField.js +83 -0
- package/lib/components/fields/TableField.d.ts +18 -0
- package/lib/components/fields/TableField.js +136 -0
- package/lib/components/fields/TagArrayField.d.ts +38 -0
- package/lib/components/fields/TagArrayField.js +128 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
- package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
- package/lib/components/fields/UiFieldApplierField.js +106 -0
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
- package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
- package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
- package/lib/components/fields/UnitCountShorthandField.js +149 -0
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
- package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
- package/lib/components/fields/UnitShorthandField.d.ts +32 -0
- package/lib/components/fields/UnitShorthandField.js +220 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
- package/lib/components/templates/ArrayFieldTemplate.js +416 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
- package/lib/components/templates/BaseInputTemplate.js +80 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.js +37 -0
- package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
- package/lib/components/templates/ErrorListTemplate.js +95 -0
- package/lib/components/templates/FieldTemplate.d.ts +6 -0
- package/lib/components/templates/FieldTemplate.js +112 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ObjectFieldTemplate.js +66 -0
- package/lib/components/templates/TitleField.d.ts +9 -0
- package/lib/components/templates/TitleField.js +51 -0
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
- package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
- package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
- package/lib/components/widgets/AutosuggestWidget.js +1127 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
- package/lib/components/widgets/CheckboxWidget.js +139 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
- package/lib/components/widgets/DateTimeWidget.js +251 -0
- package/lib/components/widgets/DateWidget.d.ts +23 -0
- package/lib/components/widgets/DateWidget.js +41 -0
- package/lib/components/widgets/HiddenWidget.d.ts +15 -0
- package/lib/components/widgets/HiddenWidget.js +19 -0
- package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
- package/lib/components/widgets/ImageSelectWidget.js +57 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
- package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
- package/lib/components/widgets/InputGroupWidget.js +36 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
- package/lib/components/widgets/NumberWidget.d.ts +13 -0
- package/lib/components/widgets/NumberWidget.js +21 -0
- package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
- package/lib/components/widgets/PlainTextWidget.js +24 -0
- package/lib/components/widgets/SelectWidget.d.ts +52 -0
- package/lib/components/widgets/SelectWidget.js +158 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
- package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
- package/lib/components/widgets/TaxonImageWidget.js +30 -0
- package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
- package/lib/components/widgets/TextSelectWidget.js +94 -0
- package/lib/components/widgets/TextareaWidget.d.ts +32 -0
- package/lib/components/widgets/TextareaWidget.js +87 -0
- package/lib/components/widgets/TimeWidget.d.ts +11 -0
- package/lib/components/widgets/TimeWidget.js +19 -0
- package/lib/components/widgets/URLWidget.d.ts +14 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
- package/lib/components/widgets/UpperCaseWidget.js +21 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +50 -0
- package/lib/services/blocker-service.d.ts +11 -0
- package/lib/services/blocker-service.js +55 -0
- package/lib/services/custom-event-service.d.ts +17 -0
- package/lib/services/custom-event-service.js +35 -0
- package/lib/services/dom-id-service.d.ts +8 -0
- package/lib/services/dom-id-service.js +30 -0
- package/lib/services/focus-service.d.ts +13 -0
- package/lib/services/focus-service.js +60 -0
- package/lib/services/id-service.d.ts +22 -0
- package/lib/services/id-service.js +130 -0
- package/lib/services/key-handler-service.d.ts +56 -0
- package/lib/services/key-handler-service.js +184 -0
- package/lib/services/root-instance-service.d.ts +25 -0
- package/lib/services/root-instance-service.js +49 -0
- package/lib/services/settings-service.d.ts +34 -0
- package/lib/services/settings-service.js +154 -0
- package/lib/services/singleton-map-service.d.ts +23 -0
- package/lib/services/singleton-map-service.js +44 -0
- package/lib/services/submit-hook-service.d.ts +24 -0
- package/lib/services/submit-hook-service.js +73 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +4 -0
- package/lib/themes/bs3.d.ts +3 -0
- package/lib/themes/bs3.js +133 -0
- package/lib/themes/bs5.d.ts +3 -0
- package/lib/themes/bs5.js +111 -0
- package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
- package/lib/themes/glyphicon-fa-mapping.js +271 -0
- package/lib/themes/stub.d.ts +3 -0
- package/lib/themes/stub.js +82 -0
- package/lib/themes/theme.d.ts +233 -0
- package/lib/themes/theme.js +2 -0
- package/lib/translations.json +847 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1185 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/package.json +2 -2
- package/test-export/test-utils.d.ts +3 -2
- package/test-export/test-utils.js +14 -13
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const Combobox = require("react-widgets/lib/Combobox");
|
|
6
|
+
const Multiselect = require("react-widgets/lib/Multiselect");
|
|
7
|
+
const components_1 = require("../components");
|
|
8
|
+
const Context_1 = require("../../Context");
|
|
9
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
class SelectWidget extends React.Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.multiSelectOnChange = (values) => {
|
|
15
|
+
const lengthBeforeFiltering = values.length;
|
|
16
|
+
values = values.filter(v => v.value !== "");
|
|
17
|
+
if (this.props.value.length === lengthBeforeFiltering) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.props.onChange(values.map(({ value }) => this.getEnum(value)));
|
|
21
|
+
};
|
|
22
|
+
this.selectOnChange = (item) => {
|
|
23
|
+
this.props.onChange(this.getEnum(item.value));
|
|
24
|
+
};
|
|
25
|
+
this.onClick = () => {
|
|
26
|
+
!this.props.disabled && !this.props.readonly && this.setState({ open: true });
|
|
27
|
+
};
|
|
28
|
+
this.onFocus = () => this.setState({ open: true });
|
|
29
|
+
this.onBlur = () => this.setState({ open: false });
|
|
30
|
+
this.onSelect = (item) => {
|
|
31
|
+
this.state.open && this.props.formContext.setTimeout(() => this.mounted && this.setState({ open: false, value: item.value }));
|
|
32
|
+
const value = this.getEnum(item.value);
|
|
33
|
+
(!this.state.value || value !== this.state.value.value) && this.props.onChange(value);
|
|
34
|
+
};
|
|
35
|
+
// Quelch a warning from react-widgets with noop handler.
|
|
36
|
+
this.onToggle = () => { };
|
|
37
|
+
this.onKeyDown = (e) => {
|
|
38
|
+
if (e.key !== "Tab") {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const item = this.elemRef.state.focusedItem;
|
|
42
|
+
item && this.elemRef.handleSelect(item, e);
|
|
43
|
+
};
|
|
44
|
+
this.setRef = elem => {
|
|
45
|
+
this.elemRef = elem;
|
|
46
|
+
};
|
|
47
|
+
this.getEnum = val => utils_1.isEmptyString(val) ? undefined : val;
|
|
48
|
+
this.state = this.getStateFromProps(props);
|
|
49
|
+
this._context = Context_1.default(this.props.formContext.contextId);
|
|
50
|
+
}
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
this.mounted = true;
|
|
53
|
+
this.props.formContext.services.focus.addFocusHandler(this.props.id, this.onFocus);
|
|
54
|
+
}
|
|
55
|
+
componentWillUnmount() {
|
|
56
|
+
this.mounted = false;
|
|
57
|
+
this.props.formContext.services.focus.removeFocusHandler(this.props.id, this.onFocus);
|
|
58
|
+
}
|
|
59
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
60
|
+
this.setState(this.getStateFromProps(props));
|
|
61
|
+
}
|
|
62
|
+
getEnumOptions(props) {
|
|
63
|
+
return utils_1.getUiOptions(props.uiSchema).enumOptions || props.options.enumOptions;
|
|
64
|
+
}
|
|
65
|
+
getStateFromProps(props) {
|
|
66
|
+
let { multiple, value } = props;
|
|
67
|
+
let enumOptions = this.getEnumOptions(props);
|
|
68
|
+
function sort(enumOptions, order) {
|
|
69
|
+
if (!Array.isArray(order))
|
|
70
|
+
return enumOptions;
|
|
71
|
+
const idxs = order.reduce((idxs, _enum, i) => {
|
|
72
|
+
idxs[_enum] = i;
|
|
73
|
+
return idxs;
|
|
74
|
+
}, {});
|
|
75
|
+
return enumOptions.slice(0).sort((a, b) => {
|
|
76
|
+
return idxs[a.value] - idxs[b.value];
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const { filter: _filter, filterType, labels, order } = utils_1.getUiOptions(props);
|
|
80
|
+
if (_filter) {
|
|
81
|
+
enumOptions = utils_1.filter(enumOptions, _filter, filterType, item => item.value);
|
|
82
|
+
}
|
|
83
|
+
if (labels) {
|
|
84
|
+
enumOptions = enumOptions.map(({ value, label }) => {
|
|
85
|
+
return { value, label: value in labels ? labels[value] : label };
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (enumOptions.every(({ value: _value }) => value !== _value)) {
|
|
89
|
+
const _enum = this.getEnumOptions(props).find(({ value: _value }) => value === _value);
|
|
90
|
+
if (_enum) {
|
|
91
|
+
enumOptions.push(_enum);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (order)
|
|
95
|
+
enumOptions = sort(enumOptions, order);
|
|
96
|
+
const valsToItems = enumOptions.reduce((map, item) => {
|
|
97
|
+
map[item.value] = item;
|
|
98
|
+
return map;
|
|
99
|
+
}, {});
|
|
100
|
+
return {
|
|
101
|
+
valsToItems,
|
|
102
|
+
enumOptions,
|
|
103
|
+
value: multiple ? value : valsToItems[value]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
render() {
|
|
107
|
+
const { id, disabled, readonly, multiple, formContext, } = this.props;
|
|
108
|
+
const { enumOptions } = this.state;
|
|
109
|
+
const commonOptions = {
|
|
110
|
+
id,
|
|
111
|
+
value: this.state.value,
|
|
112
|
+
placeholder: utils_1.getUiOptions(this.props).placeholder,
|
|
113
|
+
data: enumOptions,
|
|
114
|
+
valueField: "value",
|
|
115
|
+
textField: "label",
|
|
116
|
+
disabled: disabled || readonly,
|
|
117
|
+
filter: "contains",
|
|
118
|
+
messages: {
|
|
119
|
+
open: formContext.translations.Open,
|
|
120
|
+
emptyList: formContext.translations.NoResults,
|
|
121
|
+
emptyFilter: formContext.translations.NoResults
|
|
122
|
+
},
|
|
123
|
+
onFocus: this.onFocus,
|
|
124
|
+
onBlur: this.onBlur,
|
|
125
|
+
onToggle: this.onToggle,
|
|
126
|
+
open: this.state.open,
|
|
127
|
+
onKeyDown: this.onKeyDown
|
|
128
|
+
};
|
|
129
|
+
const selectComponent = multiple ? (React.createElement(Multiselect, Object.assign({}, commonOptions, { onChange: this.multiSelectOnChange, ref: this.setRef }))) : (React.createElement(Combobox, Object.assign({}, commonOptions, { onChange: this.selectOnChange, ref: this.setRef, onClick: this.onClick, onSelect: this.onSelect })));
|
|
130
|
+
return (React.createElement(components_1.TooltipComponent, { placement: "top", trigger: "hover", tooltip: (multiple || utils_1.isEmptyString(this.props.value)) ? undefined : this.state.valsToItems[this.props.value].label },
|
|
131
|
+
React.createElement("div", null, selectComponent)));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
SelectWidget.contextType = ReactContext_1.default;
|
|
135
|
+
SelectWidget.defaultProps = {
|
|
136
|
+
autofocus: false,
|
|
137
|
+
};
|
|
138
|
+
SelectWidget.propTypes = {
|
|
139
|
+
schema: PropTypes.shape({
|
|
140
|
+
type: PropTypes.oneOf(["string", "array"])
|
|
141
|
+
}),
|
|
142
|
+
id: PropTypes.string.isRequired,
|
|
143
|
+
uiSchema: PropTypes.shape({
|
|
144
|
+
"ui:options": PropTypes.shape({
|
|
145
|
+
enumOptions: PropTypes.array,
|
|
146
|
+
order: PropTypes.array,
|
|
147
|
+
filter: PropTypes.array,
|
|
148
|
+
filterType: PropTypes.string,
|
|
149
|
+
labels: PropTypes.object,
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
153
|
+
required: PropTypes.bool,
|
|
154
|
+
multiple: PropTypes.bool,
|
|
155
|
+
autofocus: PropTypes.bool,
|
|
156
|
+
onChange: PropTypes.func,
|
|
157
|
+
};
|
|
158
|
+
exports.default = SelectWidget;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default class SeparatedDateTimeWidget extends React.Component<any, any, any> {
|
|
2
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
|
+
static propTypes: {
|
|
4
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
+
type: PropTypes.Requireable<string>;
|
|
6
|
+
}>>;
|
|
7
|
+
value: PropTypes.Requireable<string>;
|
|
8
|
+
};
|
|
9
|
+
constructor(props: any);
|
|
10
|
+
constructor(props: any, context: any);
|
|
11
|
+
getStateFromProps(props: any): {
|
|
12
|
+
date: any;
|
|
13
|
+
time: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
onDateChange: (value: any) => void;
|
|
16
|
+
onTimeChange: (value: any) => void;
|
|
17
|
+
}
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,59 @@
|
|
|
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 DateWidget_1 = require("./DateWidget");
|
|
12
|
+
const TimeWidget_1 = require("./TimeWidget");
|
|
13
|
+
const BaseComponent_1 = require("../BaseComponent");
|
|
14
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
15
|
+
let SeparatedDateTimeWidget = class SeparatedDateTimeWidget extends React.Component {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.onDateChange = (value) => {
|
|
19
|
+
this.props.onChange(value ? (this.state.time ? value + this.state.time : value) : null);
|
|
20
|
+
};
|
|
21
|
+
this.onTimeChange = (value) => {
|
|
22
|
+
this.props.onChange(value ? this.state.date + value : this.state.date);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getStateFromProps(props) {
|
|
26
|
+
let { value } = props;
|
|
27
|
+
let date, time;
|
|
28
|
+
if (value) {
|
|
29
|
+
let splitted = value.split("T");
|
|
30
|
+
if (splitted.length == 2) {
|
|
31
|
+
time = "T" + splitted[1];
|
|
32
|
+
}
|
|
33
|
+
date = splitted[0];
|
|
34
|
+
}
|
|
35
|
+
return { date, time };
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const hasDate = !!this.state.date;
|
|
39
|
+
const { Row, Col, FormGroup } = this.context.theme;
|
|
40
|
+
return (React.createElement(Row, null,
|
|
41
|
+
React.createElement(Col, { lg: hasDate ? 6 : 12 },
|
|
42
|
+
React.createElement(FormGroup, null,
|
|
43
|
+
React.createElement(DateWidget_1.default, Object.assign({}, this.props, { onChange: this.onDateChange, value: this.state.date })))),
|
|
44
|
+
hasDate ? (React.createElement(Col, { lg: 6 },
|
|
45
|
+
React.createElement(FormGroup, null,
|
|
46
|
+
React.createElement(TimeWidget_1.default, Object.assign({}, this.props, { onChange: this.onTimeChange, value: this.state.time }))))) : null));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
SeparatedDateTimeWidget.contextType = ReactContext_1.default;
|
|
50
|
+
SeparatedDateTimeWidget.propTypes = {
|
|
51
|
+
schema: PropTypes.shape({
|
|
52
|
+
type: PropTypes.oneOf(["string"])
|
|
53
|
+
}).isRequired,
|
|
54
|
+
value: PropTypes.string
|
|
55
|
+
};
|
|
56
|
+
SeparatedDateTimeWidget = __decorate([
|
|
57
|
+
BaseComponent_1.default
|
|
58
|
+
], SeparatedDateTimeWidget);
|
|
59
|
+
exports.default = SeparatedDateTimeWidget;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class TaxonImageWidget extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
type: PropTypes.Requireable<string>;
|
|
5
|
+
}>>;
|
|
6
|
+
value: PropTypes.Requireable<string>;
|
|
7
|
+
};
|
|
8
|
+
constructor(props: any);
|
|
9
|
+
constructor(props: any, context: any);
|
|
10
|
+
onTaxonImageClick: (taxonID: any) => () => void;
|
|
11
|
+
}
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
class TaxonImageWidget extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.onTaxonImageClick = (taxonID) => () => {
|
|
10
|
+
this.props.onChange(taxonID);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
const { SchemaField } = this.props.registry.fields;
|
|
15
|
+
const { uiSchema } = utils_1.getUiOptions(this.props);
|
|
16
|
+
const schemaField = uiSchema
|
|
17
|
+
? React.createElement(SchemaField, Object.assign({}, this.props, { schema: Object.assign(Object.assign({}, this.props.schema), { title: "" }), uiSchema: Object.assign(Object.assign({}, uiSchema), { "ui:title": "" }) }))
|
|
18
|
+
: null;
|
|
19
|
+
return (React.createElement(React.Fragment, null,
|
|
20
|
+
["MX.45", "MX.255"].map(taxonID => React.createElement("div", { key: taxonID, style: { height: 100, width: 100 }, onClick: this.onTaxonImageClick(taxonID) })),
|
|
21
|
+
schemaField));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = TaxonImageWidget;
|
|
25
|
+
TaxonImageWidget.propTypes = {
|
|
26
|
+
schema: PropTypes.shape({
|
|
27
|
+
type: PropTypes.oneOf(["string"])
|
|
28
|
+
}).isRequired,
|
|
29
|
+
value: PropTypes.string
|
|
30
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default TextSelectWidget;
|
|
2
|
+
declare class TextSelectWidget extends React.Component<any, any, any> {
|
|
3
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
4
|
+
static propTypes: {
|
|
5
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
6
|
+
type: PropTypes.Requireable<string>;
|
|
7
|
+
}>>;
|
|
8
|
+
value: PropTypes.Requireable<string>;
|
|
9
|
+
};
|
|
10
|
+
constructor(props: any);
|
|
11
|
+
getInitialState(props: any): {
|
|
12
|
+
selectedCheckboxes: Set<any>;
|
|
13
|
+
enums: any;
|
|
14
|
+
otherValue: string;
|
|
15
|
+
freeTextField: any;
|
|
16
|
+
};
|
|
17
|
+
getStateFromProps(props: any): {
|
|
18
|
+
otherValue: string;
|
|
19
|
+
};
|
|
20
|
+
onCheckBoxChange: (label: any) => () => void;
|
|
21
|
+
onInputChange: (value: any) => void;
|
|
22
|
+
onChange: (textValue: any) => void;
|
|
23
|
+
}
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const immutability_helper_1 = require("immutability-helper");
|
|
7
|
+
const BaseInputTemplate_1 = require("../templates/BaseInputTemplate");
|
|
8
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
9
|
+
class TextSelectWidget extends React.Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.onCheckBoxChange = (label) => () => {
|
|
13
|
+
const selectedCheckboxes = this.state.selectedCheckboxes;
|
|
14
|
+
if (selectedCheckboxes.has(label)) {
|
|
15
|
+
selectedCheckboxes.delete(label);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
selectedCheckboxes.add(label);
|
|
19
|
+
}
|
|
20
|
+
this.setState({ selectedCheckboxes: selectedCheckboxes });
|
|
21
|
+
this.onChange(this.state.otherValue);
|
|
22
|
+
};
|
|
23
|
+
this.onInputChange = (value) => {
|
|
24
|
+
this.onChange(value);
|
|
25
|
+
};
|
|
26
|
+
this.onChange = (textValue) => {
|
|
27
|
+
let newValue = [...Array.from(this.state.selectedCheckboxes)];
|
|
28
|
+
if (this.state.selectedCheckboxes.has(this.state.freeTextField)) {
|
|
29
|
+
if (textValue && textValue.length > 0) {
|
|
30
|
+
newValue = immutability_helper_1.default(newValue, { $push: [textValue] });
|
|
31
|
+
}
|
|
32
|
+
newValue.splice(newValue.indexOf(this.state.freeTextField), 1);
|
|
33
|
+
}
|
|
34
|
+
this.props.onChange(newValue.join(", "));
|
|
35
|
+
};
|
|
36
|
+
this.state = this.getInitialState(props);
|
|
37
|
+
}
|
|
38
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
39
|
+
this.setState(this.getStateFromProps(props));
|
|
40
|
+
}
|
|
41
|
+
getInitialState(props) {
|
|
42
|
+
let { enums = [], delimiter = ", ", freeTextField } = utils_1.getUiOptions(props);
|
|
43
|
+
const { value } = props;
|
|
44
|
+
const selectedCheckboxes = new Set();
|
|
45
|
+
const values = !value ? [] : value.split(delimiter);
|
|
46
|
+
const otherValues = [];
|
|
47
|
+
values.map(val => {
|
|
48
|
+
if (enums.indexOf(val) !== -1) {
|
|
49
|
+
selectedCheckboxes.add(val);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
otherValues.push(val);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (otherValues.length > 0) {
|
|
56
|
+
selectedCheckboxes.add(freeTextField);
|
|
57
|
+
}
|
|
58
|
+
return { selectedCheckboxes, enums, otherValue: otherValues.join(delimiter), freeTextField };
|
|
59
|
+
}
|
|
60
|
+
getStateFromProps(props) {
|
|
61
|
+
let { enums = [], delimiter = ", " } = utils_1.getUiOptions(props);
|
|
62
|
+
const { value } = props;
|
|
63
|
+
const values = !value ? [] : value.split(delimiter);
|
|
64
|
+
const otherValues = [];
|
|
65
|
+
values.map(val => {
|
|
66
|
+
if (enums.indexOf(val) === -1) {
|
|
67
|
+
otherValues.push(val);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return { otherValue: otherValues.join(delimiter) };
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
let { enums, otherValue, freeTextField, selectedCheckboxes } = this.state;
|
|
74
|
+
if (freeTextField) {
|
|
75
|
+
enums = immutability_helper_1.default(enums, { $push: [freeTextField] });
|
|
76
|
+
}
|
|
77
|
+
const { Checkbox } = this.context.theme;
|
|
78
|
+
return (React.createElement("div", { className: "laji-text-select" },
|
|
79
|
+
enums.map((label, i) => {
|
|
80
|
+
return (React.createElement(Checkbox, { key: i, title: label, checked: selectedCheckboxes.has(label), onChange: this.onCheckBoxChange(label) }, label));
|
|
81
|
+
}),
|
|
82
|
+
freeTextField ?
|
|
83
|
+
React.createElement(BaseInputTemplate_1.default, Object.assign({}, this.props, { id: this.props.id + "_input", value: otherValue, onChange: this.onInputChange, disabled: !selectedCheckboxes.has(freeTextField) }))
|
|
84
|
+
: null));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
TextSelectWidget.contextType = ReactContext_1.default;
|
|
88
|
+
TextSelectWidget.propTypes = {
|
|
89
|
+
schema: PropTypes.shape({
|
|
90
|
+
type: PropTypes.oneOf(["string"])
|
|
91
|
+
}).isRequired,
|
|
92
|
+
value: PropTypes.string
|
|
93
|
+
};
|
|
94
|
+
exports.default = TextSelectWidget;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default class TextareaWidget extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
+
emptyValue: PropTypes.Requireable<string>;
|
|
5
|
+
rows: PropTypes.Requireable<number>;
|
|
6
|
+
}>>;
|
|
7
|
+
schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
8
|
+
type: PropTypes.Requireable<string>;
|
|
9
|
+
}>>;
|
|
10
|
+
value: PropTypes.Requireable<string>;
|
|
11
|
+
};
|
|
12
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
13
|
+
constructor(props: any);
|
|
14
|
+
textareaRef: React.RefObject<any>;
|
|
15
|
+
_context: Record<string, unknown>;
|
|
16
|
+
getStateFromProps: (props: any) => {
|
|
17
|
+
value: any;
|
|
18
|
+
};
|
|
19
|
+
onFocus: (e: any) => void;
|
|
20
|
+
focused: boolean | undefined;
|
|
21
|
+
onBlur: (e: any) => void;
|
|
22
|
+
onChange: (value: any) => void;
|
|
23
|
+
timeout: any;
|
|
24
|
+
_onChange: ({ target: { value } }: {
|
|
25
|
+
target: {
|
|
26
|
+
value: any;
|
|
27
|
+
};
|
|
28
|
+
}) => void;
|
|
29
|
+
onKeyDown: (e: any) => void;
|
|
30
|
+
}
|
|
31
|
+
import * as React from "react";
|
|
32
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const components_1 = require("../components");
|
|
7
|
+
const Context_1 = require("../../Context");
|
|
8
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
9
|
+
const utils_2 = require("../../utils");
|
|
10
|
+
class TextareaWidget extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.getStateFromProps = (props) => {
|
|
14
|
+
return { value: props.value };
|
|
15
|
+
};
|
|
16
|
+
this.onFocus = (e) => {
|
|
17
|
+
this.focused = true;
|
|
18
|
+
this.props.onFocus && this.props.onFocus(e);
|
|
19
|
+
};
|
|
20
|
+
this.onBlur = (e) => {
|
|
21
|
+
this.focused = false;
|
|
22
|
+
if (this.state.value !== this.props.value) {
|
|
23
|
+
this.props.onChange(this.state.value);
|
|
24
|
+
}
|
|
25
|
+
if (this.timeout)
|
|
26
|
+
clearTimeout(this.timeout);
|
|
27
|
+
this.props.onBlur && this.props.onBlur(e);
|
|
28
|
+
};
|
|
29
|
+
this.onChange = (value) => {
|
|
30
|
+
this.setState({ value }, () => {
|
|
31
|
+
if (!this.focused) {
|
|
32
|
+
this.props.onChange(value);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (this.timeout)
|
|
36
|
+
clearTimeout(this.timeout);
|
|
37
|
+
this.timeout = this.props.formContext.setTimeout(() => {
|
|
38
|
+
this.props.onChange(value === "" ? utils_2.getUiOptions(this.props).emptyValue : value);
|
|
39
|
+
}, 1000);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
this._onChange = ({ target: { value } }) => {
|
|
44
|
+
this.onChange(value);
|
|
45
|
+
};
|
|
46
|
+
this.onKeyDown = (e) => {
|
|
47
|
+
const inputAllowed = !this.props.disabled && !this.props.readonly;
|
|
48
|
+
const isCtrlEnter = e.ctrlKey && e.key === "Enter";
|
|
49
|
+
if (this.state.enterReserved && inputAllowed && isCtrlEnter) {
|
|
50
|
+
this.onChange(this.state.value + "\n");
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
this.state = this.getStateFromProps(props);
|
|
56
|
+
this.textareaRef = React.createRef();
|
|
57
|
+
this._context = Context_1.default(props.formContext.contextId);
|
|
58
|
+
Object.keys(props.formContext.services.keyHandler.shortcuts).some(keyCombo => {
|
|
59
|
+
if (keyCombo === "Enter") {
|
|
60
|
+
// // Direct mutation should be ok in constructor.
|
|
61
|
+
this.state.enterReserved = true; // eslint-disable-line react/no-direct-mutation-state
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
66
|
+
this.setState(this.getStateFromProps(props));
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
const { id, options, placeholder, disabled, readonly, autofocus } = this.props;
|
|
70
|
+
const { value } = this.state;
|
|
71
|
+
const { required = this.props.required } = options;
|
|
72
|
+
const textarea = React.createElement("textarea", { id: id, className: "form-control", value: typeof value === "undefined" ? "" : value, placeholder: placeholder, required: required, disabled: disabled, readOnly: readonly, autoFocus: autofocus, rows: options.rows, onFocus: this.onFocus, onBlur: this.onBlur, onChange: this._onChange, onKeyDown: this.onKeyDown });
|
|
73
|
+
return this.state.enterReserved ? (React.createElement(components_1.TooltipComponent, { tooltip: `${utils_1.stringifyKeyCombo("ctrl+Enter")} ${this.props.formContext.translations.textareaHint}`, placement: "bottom" }, textarea)) : textarea;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.default = TextareaWidget;
|
|
77
|
+
TextareaWidget.propTypes = {
|
|
78
|
+
"ui:options": PropTypes.shape({
|
|
79
|
+
emptyValue: PropTypes.string,
|
|
80
|
+
rows: PropTypes.number,
|
|
81
|
+
}),
|
|
82
|
+
schema: PropTypes.shape({
|
|
83
|
+
type: PropTypes.oneOf(["string"])
|
|
84
|
+
}),
|
|
85
|
+
value: PropTypes.string
|
|
86
|
+
};
|
|
87
|
+
TextareaWidget.contextType = ReactContext_1.default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default TimeWidget;
|
|
2
|
+
declare function TimeWidget(props: any): JSX.Element;
|
|
3
|
+
declare namespace TimeWidget {
|
|
4
|
+
namespace propTypes {
|
|
5
|
+
const schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
6
|
+
type: PropTypes.Requireable<string>;
|
|
7
|
+
}>>;
|
|
8
|
+
const value: PropTypes.Requireable<string>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,19 @@
|
|
|
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 TimeWidget = (props) => {
|
|
9
|
+
const { onChange } = props;
|
|
10
|
+
const _onChange = React.useCallback((value) => onChange(utils_1.isEmptyString(value) ? undefined : (moment(value).format("HH:mm"))), [onChange]);
|
|
11
|
+
return (React.createElement(DateTimeWidget_1.default, Object.assign({}, props, { onChange: _onChange, calendar: false, value: props.value ? (moment().format("YYYY-MM-DD") + `T${props.value}`) : null })));
|
|
12
|
+
};
|
|
13
|
+
TimeWidget.propTypes = {
|
|
14
|
+
schema: PropTypes.shape({
|
|
15
|
+
type: PropTypes.oneOf(["string"])
|
|
16
|
+
}),
|
|
17
|
+
value: PropTypes.string
|
|
18
|
+
};
|
|
19
|
+
exports.default = TimeWidget;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default URLWidget;
|
|
2
|
+
declare function URLWidget({ value, options }: {
|
|
3
|
+
value: any;
|
|
4
|
+
options?: {} | undefined;
|
|
5
|
+
}): JSX.Element;
|
|
6
|
+
declare namespace URLWidget {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const schema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
9
|
+
type: PropTypes.Requireable<string>;
|
|
10
|
+
}>>;
|
|
11
|
+
const value: PropTypes.Requireable<string>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const URLWidget = ({ value, options = {} }) => React.createElement("a", { href: `${options.template || ""}${value}`, target: "_blank", rel: "noopener noreferrer" }, `${options.template || ""}${value}`);
|
|
6
|
+
URLWidget.propTypes = {
|
|
7
|
+
schema: PropTypes.shape({
|
|
8
|
+
type: PropTypes.oneOf(["string"])
|
|
9
|
+
}),
|
|
10
|
+
value: PropTypes.string
|
|
11
|
+
};
|
|
12
|
+
exports.default = URLWidget;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class UpperCaseWidget extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
type: PropTypes.Requireable<string>;
|
|
5
|
+
}>>;
|
|
6
|
+
value: PropTypes.Requireable<string>;
|
|
7
|
+
};
|
|
8
|
+
constructor(props: any);
|
|
9
|
+
constructor(props: any, context: any);
|
|
10
|
+
formatValue: (value: any) => any;
|
|
11
|
+
}
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import * as PropTypes from "prop-types";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const BaseInputTemplate_1 = require("../templates/BaseInputTemplate");
|
|
6
|
+
class UpperCaseWidget extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.formatValue = (value) => typeof value === "string" ? value.toUpperCase() : value;
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
return React.createElement(BaseInputTemplate_1.default, Object.assign({}, this.props, { formatValue: this.formatValue }));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = UpperCaseWidget;
|
|
16
|
+
UpperCaseWidget.propTypes = {
|
|
17
|
+
schema: PropTypes.shape({
|
|
18
|
+
type: PropTypes.oneOf(["string"])
|
|
19
|
+
}).isRequired,
|
|
20
|
+
value: PropTypes.string
|
|
21
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import LajiForm, { LajiFormProps } from "./components/LajiForm";
|
|
2
|
+
declare type LajiFormWrapperProps = LajiFormProps & {
|
|
3
|
+
rootElem: HTMLDivElement;
|
|
4
|
+
};
|
|
5
|
+
export default class LajiFormWrapper {
|
|
6
|
+
props: LajiFormProps;
|
|
7
|
+
state: LajiFormProps;
|
|
8
|
+
rootElem: HTMLDivElement;
|
|
9
|
+
lajiForm: LajiForm;
|
|
10
|
+
constructor(props: LajiFormWrapperProps);
|
|
11
|
+
submit: () => void;
|
|
12
|
+
submitOnlySchemaValidations: () => void;
|
|
13
|
+
setState: (state: Partial<LajiFormProps>) => void;
|
|
14
|
+
pushBlockingLoader: () => void;
|
|
15
|
+
popBlockingLoader: () => void;
|
|
16
|
+
getSettings: () => {};
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
unmount: () => void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|