@luomus/laji-form 15.1.64 → 15.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/laji-form.js +1 -1
- package/dist/laji-form.js.LICENSE.txt +1 -1
- package/lib/Context.d.ts +1 -1
- package/lib/Context.js +1 -2
- package/lib/ReactContext.js +22 -8
- package/lib/components/BaseComponent.d.ts +1 -2
- package/lib/components/BaseComponent.js +2 -3
- package/lib/components/LajiForm.d.ts +13 -13
- package/lib/components/LajiForm.js +51 -35
- package/lib/components/VirtualSchemaField.d.ts +14 -14
- package/lib/components/VirtualSchemaField.js +31 -18
- package/lib/components/components/Affix.d.ts +2 -2
- package/lib/components/components/Affix.js +25 -12
- package/lib/components/components/Button.d.ts +6 -6
- package/lib/components/components/Button.js +23 -9
- package/lib/components/components/DeleteButton.d.ts +4 -4
- package/lib/components/components/DeleteButton.js +25 -11
- package/lib/components/components/ErrorPanel.d.ts +3 -3
- package/lib/components/components/ErrorPanel.js +22 -8
- package/lib/components/components/FailedBackgroundJobsPanel.d.ts +2 -2
- package/lib/components/components/FailedBackgroundJobsPanel.js +25 -11
- package/lib/components/components/FetcherInput.d.ts +1 -1
- package/lib/components/components/FetcherInput.js +28 -14
- package/lib/components/components/Fullscreen.d.ts +1 -1
- package/lib/components/components/Fullscreen.js +23 -9
- package/lib/components/components/GlyphButton.d.ts +5 -5
- package/lib/components/components/GlyphButton.js +22 -8
- package/lib/components/components/Help.d.ts +1 -1
- package/lib/components/components/Help.js +25 -12
- package/lib/components/components/Label.d.ts +1 -1
- package/lib/components/components/Label.js +24 -11
- package/lib/components/components/OverlayTrigger.d.ts +4 -4
- package/lib/components/components/OverlayTrigger.js +22 -8
- package/lib/components/components/Stretch.d.ts +4 -4
- package/lib/components/components/Stretch.js +25 -11
- package/lib/components/components/TooltipComponent.d.ts +1 -1
- package/lib/components/components/TooltipComponent.js +26 -12
- package/lib/components/components/index.js +5 -1
- package/lib/components/fields/AnnotationField.d.ts +8 -4
- package/lib/components/fields/AnnotationField.js +34 -20
- package/lib/components/fields/AnyToBooleanField.d.ts +4 -4
- package/lib/components/fields/AnyToBooleanField.js +22 -8
- package/lib/components/fields/ArrayBulkField.d.ts +9 -4
- package/lib/components/fields/ArrayBulkField.js +24 -10
- package/lib/components/fields/ArrayCombinerField.d.ts +4 -4
- package/lib/components/fields/ArrayCombinerField.js +25 -11
- package/lib/components/fields/ArrayField.d.ts +1 -0
- package/lib/components/fields/ArrayField.js +41 -27
- package/lib/components/fields/ArrayPropertySumField.d.ts +2 -2
- package/lib/components/fields/ArrayPropertySumField.js +24 -10
- package/lib/components/fields/AsArrayField.d.ts +7 -5
- package/lib/components/fields/AsArrayField.js +22 -8
- package/lib/components/fields/AudioArrayField.js +22 -8
- package/lib/components/fields/AutoArrayField.d.ts +2 -2
- package/lib/components/fields/AutoArrayField.js +26 -12
- package/lib/components/fields/AutosuggestField.d.ts +14 -6
- package/lib/components/fields/AutosuggestField.js +61 -47
- package/lib/components/fields/CombinedValueDisplayField.d.ts +6 -6
- package/lib/components/fields/CombinedValueDisplayField.js +24 -10
- package/lib/components/fields/CondensedObjectField.d.ts +3 -3
- package/lib/components/fields/CondensedObjectField.js +33 -19
- package/lib/components/fields/ConditionalOnChangeField.d.ts +7 -7
- package/lib/components/fields/ConditionalOnChangeField.js +22 -8
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +19 -19
- package/lib/components/fields/ConditionalUiSchemaField.js +28 -14
- package/lib/components/fields/ContextInjectionField.d.ts +7 -7
- package/lib/components/fields/ContextInjectionField.js +26 -13
- package/lib/components/fields/DataLeakerField.d.ts +6 -6
- package/lib/components/fields/DataLeakerField.js +25 -11
- package/lib/components/fields/DefaultValueArrayField.d.ts +6 -6
- package/lib/components/fields/DefaultValueArrayField.js +23 -9
- package/lib/components/fields/DependentBooleanField.d.ts +6 -6
- package/lib/components/fields/DependentBooleanField.js +24 -10
- package/lib/components/fields/DependentDisableField.d.ts +4 -4
- package/lib/components/fields/DependentDisableField.js +24 -10
- package/lib/components/fields/EnumRangeArrayField.d.ts +2 -3
- package/lib/components/fields/EnumRangeArrayField.js +26 -12
- package/lib/components/fields/ExtraLabelRowField.d.ts +9 -8
- package/lib/components/fields/ExtraLabelRowField.js +27 -13
- package/lib/components/fields/FakePropertyField.d.ts +2 -2
- package/lib/components/fields/FakePropertyField.js +26 -12
- package/lib/components/fields/FillDateRangeField.d.ts +28 -0
- package/lib/components/fields/FillDateRangeField.js +91 -0
- package/lib/components/fields/FilterArrayField.d.ts +13 -12
- package/lib/components/fields/FilterArrayField.js +27 -13
- package/lib/components/fields/FlatField.d.ts +4 -4
- package/lib/components/fields/FlatField.js +35 -21
- package/lib/components/fields/GeocoderField.d.ts +12 -4
- package/lib/components/fields/GeocoderField.js +38 -24
- package/lib/components/fields/GridLayoutField.d.ts +7 -7
- package/lib/components/fields/GridLayoutField.js +23 -9
- package/lib/components/fields/HiddenField.d.ts +2 -2
- package/lib/components/fields/HiddenField.js +22 -8
- package/lib/components/fields/HiddenWithTextField.d.ts +6 -7
- package/lib/components/fields/HiddenWithTextField.js +22 -8
- package/lib/components/fields/ImageArrayField.d.ts +17 -17
- package/lib/components/fields/ImageArrayField.js +53 -39
- package/lib/components/fields/ImageDisplayField.d.ts +4 -3
- package/lib/components/fields/ImageDisplayField.js +25 -11
- package/lib/components/fields/InitiallyHiddenField.d.ts +9 -4
- package/lib/components/fields/InitiallyHiddenField.js +23 -9
- package/lib/components/fields/InjectDefaultValueField.d.ts +6 -6
- package/lib/components/fields/InjectDefaultValueField.js +23 -9
- package/lib/components/fields/InjectField.d.ts +8 -8
- package/lib/components/fields/InjectField.js +34 -20
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +8 -8
- package/lib/components/fields/InputWithDefaultValueButtonField.js +29 -15
- package/lib/components/fields/LocalityField.d.ts +4 -2
- package/lib/components/fields/LocalityField.js +28 -14
- package/lib/components/fields/LocationChooserField.d.ts +5 -4
- package/lib/components/fields/LocationChooserField.js +60 -46
- package/lib/components/fields/MapArrayField.d.ts +17 -4
- package/lib/components/fields/MapArrayField.js +137 -132
- package/lib/components/fields/MapField.d.ts +10 -2
- package/lib/components/fields/MapField.js +42 -29
- package/lib/components/fields/MultiActiveArrayField.d.ts +3 -3
- package/lib/components/fields/MultiActiveArrayField.js +29 -15
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +6 -2
- package/lib/components/fields/MultiAnyToBooleanField.js +25 -11
- package/lib/components/fields/MultiArrayField.d.ts +11 -10
- package/lib/components/fields/MultiArrayField.js +45 -31
- package/lib/components/fields/MultiLanguageField.d.ts +3 -2
- package/lib/components/fields/MultiLanguageField.js +23 -9
- package/lib/components/fields/MultiTagArrayField.d.ts +8 -4
- package/lib/components/fields/MultiTagArrayField.js +34 -20
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooser.d.ts +2 -2
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooser.js +25 -11
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooserField.d.ts +6 -6
- package/lib/components/fields/NamedPlaceChooserField/NamedPlaceChooserField.js +29 -16
- package/lib/components/fields/NamedPlaceChooserField/Popup.d.ts +1 -1
- package/lib/components/fields/NamedPlaceChooserField/Popup.js +29 -15
- package/lib/components/fields/NamedPlaceSaverField.d.ts +7 -5
- package/lib/components/fields/NamedPlaceSaverField.js +35 -21
- package/lib/components/fields/NestField.d.ts +4 -4
- package/lib/components/fields/NestField.js +36 -23
- package/lib/components/fields/ObjectField.js +36 -22
- package/lib/components/fields/PdfArrayField.js +22 -8
- package/lib/components/fields/PrefillingArrayField.d.ts +2 -2
- package/lib/components/fields/PrefillingArrayField.js +23 -9
- package/lib/components/fields/PrefixArrayField.d.ts +35 -0
- package/lib/components/fields/PrefixArrayField.js +138 -0
- package/lib/components/fields/SchemaField.d.ts +1 -1
- package/lib/components/fields/SchemaField.js +34 -20
- package/lib/components/fields/ScopeField.d.ts +14 -6
- package/lib/components/fields/ScopeField.js +53 -39
- package/lib/components/fields/SectionArrayField.d.ts +2 -2
- package/lib/components/fields/SectionArrayField.js +110 -96
- package/lib/components/fields/SelectTreeField.d.ts +0 -1
- package/lib/components/fields/SelectTreeField.js +30 -16
- package/lib/components/fields/SingleActiveArrayField.d.ts +14 -2
- package/lib/components/fields/SingleActiveArrayField.js +112 -98
- package/lib/components/fields/SingleItemArrayField.d.ts +3 -2
- package/lib/components/fields/SingleItemArrayField.js +28 -14
- package/lib/components/fields/SortArrayField.d.ts +9 -9
- package/lib/components/fields/SortArrayField.js +43 -29
- package/lib/components/fields/SplitField.d.ts +4 -4
- package/lib/components/fields/SplitField.js +26 -12
- package/lib/components/fields/StringToArrayField.d.ts +5 -5
- package/lib/components/fields/StringToArrayField.js +23 -9
- package/lib/components/fields/SumField.d.ts +6 -6
- package/lib/components/fields/SumField.js +22 -8
- package/lib/components/fields/TableField.d.ts +4 -3
- package/lib/components/fields/TableField.js +31 -17
- package/lib/components/fields/TagArrayField.d.ts +8 -2
- package/lib/components/fields/TagArrayField.js +37 -23
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +10 -5
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +30 -16
- package/lib/components/fields/UiFieldApplierField.d.ts +4 -4
- package/lib/components/fields/UiFieldApplierField.js +33 -19
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +7 -6
- package/lib/components/fields/UiFieldMapperArrayField.js +26 -12
- package/lib/components/fields/UnitCountShorthandField.d.ts +6 -6
- package/lib/components/fields/UnitCountShorthandField.js +31 -17
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +6 -5
- package/lib/components/fields/UnitListShorthandArrayField.js +31 -17
- package/lib/components/fields/UnitShorthandField.d.ts +11 -5
- package/lib/components/fields/UnitShorthandField.js +41 -27
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
- package/lib/components/templates/ArrayFieldTemplate.js +60 -46
- package/lib/components/templates/BaseInputTemplate.d.ts +3 -0
- package/lib/components/templates/BaseInputTemplate.js +26 -13
- package/lib/components/templates/DescriptionField.js +25 -11
- package/lib/components/templates/ErrorListTemplate.d.ts +5 -0
- package/lib/components/templates/ErrorListTemplate.js +26 -12
- package/lib/components/templates/FieldTemplate.d.ts +8 -0
- package/lib/components/templates/FieldTemplate.js +31 -17
- package/lib/components/templates/ObjectFieldTemplate.js +30 -17
- package/lib/components/templates/TitleField.js +27 -13
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +6 -6
- package/lib/components/widgets/AnyToBooleanWidget.js +24 -10
- package/lib/components/widgets/AutosuggestWidget.d.ts +14 -2
- package/lib/components/widgets/AutosuggestWidget.js +49 -35
- package/lib/components/widgets/CheckboxWidget.d.ts +3 -0
- package/lib/components/widgets/CheckboxWidget.js +32 -18
- package/lib/components/widgets/DateTimeWidget.d.ts +16 -8
- package/lib/components/widgets/DateTimeWidget.js +67 -35
- package/lib/components/widgets/DateWidget.d.ts +11 -11
- package/lib/components/widgets/DateWidget.js +36 -14
- package/lib/components/widgets/HiddenWidget.d.ts +4 -4
- package/lib/components/widgets/HiddenWidget.js +22 -8
- package/lib/components/widgets/ImageSelectWidget.d.ts +1 -0
- package/lib/components/widgets/ImageSelectWidget.js +24 -10
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +12 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +26 -12
- package/lib/components/widgets/InputGroupWidget.d.ts +4 -3
- package/lib/components/widgets/InputGroupWidget.js +25 -11
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +18 -8
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +50 -14
- package/lib/components/widgets/NumberWidget.d.ts +3 -2
- package/lib/components/widgets/NumberWidget.js +23 -9
- package/lib/components/widgets/PlainTextWidget.d.ts +3 -3
- package/lib/components/widgets/PlainTextWidget.js +24 -10
- package/lib/components/widgets/SelectWidget.d.ts +5 -6
- package/lib/components/widgets/SelectWidget.js +92 -72
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +3 -2
- package/lib/components/widgets/SeparatedDateTimeWidget.js +22 -8
- package/lib/components/widgets/TaxonImageWidget.d.ts +3 -2
- package/lib/components/widgets/TaxonImageWidget.js +24 -10
- package/lib/components/widgets/TextSelectWidget.d.ts +10 -2
- package/lib/components/widgets/TextSelectWidget.js +26 -12
- package/lib/components/widgets/TextareaWidget.d.ts +5 -0
- package/lib/components/widgets/TextareaWidget.js +25 -11
- package/lib/components/widgets/TimeWidget.d.ts +2 -2
- package/lib/components/widgets/TimeWidget.js +24 -10
- package/lib/components/widgets/URLWidget.d.ts +2 -2
- package/lib/components/widgets/URLWidget.js +22 -8
- package/lib/components/widgets/UpperCaseWidget.d.ts +3 -2
- package/lib/components/widgets/UpperCaseWidget.js +23 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.js +25 -11
- package/lib/services/custom-event-service.d.ts +1 -1
- package/lib/services/focus-service.d.ts +1 -1
- package/lib/services/focus-service.js +3 -3
- package/lib/services/id-service.d.ts +1 -1
- package/lib/services/id-service.js +5 -6
- package/lib/services/key-handler-service.d.ts +3 -4
- package/lib/services/key-handler-service.js +4 -4
- package/lib/services/multi-active-array-service.d.ts +1 -1
- package/lib/services/settings-service.d.ts +2 -3
- package/lib/services/settings-service.js +3 -3
- package/lib/services/submit-hook-service.js +1 -1
- package/lib/themes/bs3.js +22 -8
- package/lib/themes/bs5.js +23 -9
- package/lib/themes/stub.js +22 -8
- package/lib/themes/theme.d.ts +15 -15
- package/lib/types.d.ts +18 -19
- package/lib/types.js +3 -4
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +138 -134
- package/lib/validation.js +25 -12
- package/package.json +12 -11
- package/test-export/test-utils.d.ts +7 -7
- package/test-export/test-utils.js +36 -22
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
46
|
};
|
|
33
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.SearchableDrowndown =
|
|
48
|
+
exports.SearchableDrowndown = SearchableDrowndown;
|
|
35
49
|
const React = __importStar(require("react"));
|
|
36
50
|
const ReactContext_1 = __importDefault(require("../../ReactContext"));
|
|
37
51
|
const utils_1 = require("../../utils");
|
|
@@ -39,8 +53,8 @@ const react_1 = require("react");
|
|
|
39
53
|
const react_dom_1 = require("react-dom");
|
|
40
54
|
const react_spinner_1 = __importDefault(require("react-spinner"));
|
|
41
55
|
const useRangeIncrementor = (length, defaultIdx) => {
|
|
42
|
-
const [idx, _setIdx] = react_1.useState(defaultIdx);
|
|
43
|
-
const setIdx = react_1.useCallback((idx) => {
|
|
56
|
+
const [idx, _setIdx] = (0, react_1.useState)(defaultIdx);
|
|
57
|
+
const setIdx = (0, react_1.useCallback)((idx) => {
|
|
44
58
|
let nextIdx = idx;
|
|
45
59
|
if (idx === undefined || idx < 0 || length === 0) {
|
|
46
60
|
nextIdx = undefined;
|
|
@@ -50,15 +64,15 @@ const useRangeIncrementor = (length, defaultIdx) => {
|
|
|
50
64
|
}
|
|
51
65
|
_setIdx(nextIdx);
|
|
52
66
|
}, [_setIdx, length]);
|
|
53
|
-
const increment = react_1.useCallback(() => setIdx((idx || 0) - 1), [idx, setIdx]);
|
|
54
|
-
const decrement = react_1.useCallback(() => setIdx(idx === undefined ? 0 : idx + 1), [idx, setIdx]);
|
|
67
|
+
const increment = (0, react_1.useCallback)(() => setIdx((idx || 0) - 1), [idx, setIdx]);
|
|
68
|
+
const decrement = (0, react_1.useCallback)(() => setIdx(idx === undefined ? 0 : idx + 1), [idx, setIdx]);
|
|
55
69
|
return [idx === undefined ? idx : Math.min(idx, length - 1), increment, decrement, _setIdx];
|
|
56
70
|
};
|
|
57
71
|
function removeByIndex(array, index) {
|
|
58
72
|
return [...array.slice(0, index), ...array.slice(index + 1)];
|
|
59
73
|
}
|
|
60
74
|
function getEnumOptions(enumOptions, uiSchema, includeEmpty = true) {
|
|
61
|
-
const enums = (utils_1.getUiOptions(uiSchema).enumOptions || enumOptions);
|
|
75
|
+
const enums = ((0, utils_1.getUiOptions)(uiSchema).enumOptions || enumOptions);
|
|
62
76
|
const emptyIdx = enums.findIndex(e => e.value === "");
|
|
63
77
|
if (!includeEmpty) {
|
|
64
78
|
return emptyIdx !== -1
|
|
@@ -77,51 +91,56 @@ const SelectWidget = (props) => props.schema.type === "array"
|
|
|
77
91
|
exports.default = SelectWidget;
|
|
78
92
|
function SearchableDrowndown(props) {
|
|
79
93
|
const { id, disabled, readonly, value, uiSchema, options, onChange, includeEmpty = true } = props;
|
|
80
|
-
const { theme } = react_1.useContext(ReactContext_1.default);
|
|
94
|
+
const { theme } = (0, react_1.useContext)(ReactContext_1.default);
|
|
81
95
|
const { FormControl } = theme;
|
|
82
|
-
const containerRef = react_1.useRef(null);
|
|
83
|
-
const inputRef = react_1.useRef(null);
|
|
84
|
-
const dropdownRef = react_1.useRef(null);
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
97
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
98
|
+
const dropdownRef = (0, react_1.useRef)(null);
|
|
99
|
+
const allEnumOptions = (0, react_1.useMemo)(() => getEnumOptions(options.enumOptions, uiSchema, includeEmpty), [options.enumOptions, uiSchema, includeEmpty]);
|
|
100
|
+
const enumOptions = (0, react_1.useMemo)(() => {
|
|
101
|
+
if (options.whitelist) {
|
|
102
|
+
return allEnumOptions.filter(e => e.value === undefined || options.whitelist.includes(e.value));
|
|
103
|
+
}
|
|
104
|
+
return allEnumOptions;
|
|
105
|
+
}, [allEnumOptions, options.whitelist]);
|
|
106
|
+
const getLabelFromValue = (0, react_1.useCallback)((value) => value !== undefined && value !== "" && value !== null
|
|
107
|
+
? allEnumOptions.find(item => item.value === value).label
|
|
108
|
+
: "", [allEnumOptions]);
|
|
109
|
+
const [filterTerm, setFilterTerm] = (0, react_1.useState)(undefined);
|
|
110
|
+
const [isOpen, show, hide] = (0, utils_1.useBooleanSetter)(false);
|
|
111
|
+
const filteredEnums = (0, react_1.useMemo)(() => {
|
|
95
112
|
return filterTerm !== undefined && filterTerm !== ""
|
|
96
113
|
? enumOptions.filter(({ label }) => label.toLowerCase().match(filterTerm.toLowerCase()))
|
|
97
114
|
: enumOptions;
|
|
98
115
|
}, [filterTerm, enumOptions]);
|
|
99
116
|
const [activeIdx, activeIdxUp, activeIdxDown, setActiveIdx] = useRangeIncrementor((filteredEnums || []).length, getDefaultActiveIdx(filteredEnums, value));
|
|
117
|
+
(0, react_1.useEffect)(() => {
|
|
118
|
+
setFilterTerm(undefined);
|
|
119
|
+
setActiveIdx(Math.max(enumOptions.findIndex(enu => enu.value === value), 0));
|
|
120
|
+
}, [enumOptions, setActiveIdx, value]);
|
|
100
121
|
const inputValue = filterTerm !== null && filterTerm !== void 0 ? filterTerm : getLabelFromValue(value);
|
|
101
|
-
const showAndSelectText = react_1.useCallback(() => {
|
|
122
|
+
const showAndSelectText = (0, react_1.useCallback)(() => {
|
|
102
123
|
var _a;
|
|
103
124
|
show();
|
|
104
|
-
(_a = react_dom_1.findDOMNode(inputRef.current)) === null || _a === void 0 ? void 0 : _a.setSelectionRange(0, inputValue.length);
|
|
125
|
+
(_a = (0, react_dom_1.findDOMNode)(inputRef.current)) === null || _a === void 0 ? void 0 : _a.setSelectionRange(0, inputValue.length);
|
|
105
126
|
}, [show, inputValue.length]);
|
|
106
|
-
const onInputChange = react_1.useCallback((e) => {
|
|
127
|
+
const onInputChange = (0, react_1.useCallback)((e) => {
|
|
107
128
|
const { value } = e.target;
|
|
108
129
|
setFilterTerm(value);
|
|
109
130
|
setActiveIdx(0);
|
|
110
131
|
}, [setActiveIdx]);
|
|
111
|
-
const onItemSelected = react_1.useCallback((item) => {
|
|
132
|
+
const onItemSelected = (0, react_1.useCallback)((item) => {
|
|
112
133
|
if (item.value === value) {
|
|
113
134
|
return;
|
|
114
135
|
}
|
|
115
136
|
onChange(item.value);
|
|
116
|
-
setFilterTerm(undefined);
|
|
117
|
-
setActiveIdx(enumOptions.findIndex(enu => enu.value === item.value));
|
|
118
137
|
hide();
|
|
119
|
-
}, [
|
|
120
|
-
const onBlur = react_1.useCallback((e) => {
|
|
138
|
+
}, [hide, onChange, value]);
|
|
139
|
+
const onBlur = (0, react_1.useCallback)((e) => {
|
|
121
140
|
// Fixes the issue that when user tries to click an enum item, `setOpen(false)`
|
|
122
141
|
// hides the enum list, so the elem list item is hidden before the click, thus never
|
|
123
142
|
// sending a click event.
|
|
124
|
-
if (e.relatedTarget && utils_1.isDescendant(containerRef.current, e.relatedTarget)) {
|
|
143
|
+
if (e.relatedTarget && (0, utils_1.isDescendant)(containerRef.current, e.relatedTarget)) {
|
|
125
144
|
return;
|
|
126
145
|
}
|
|
127
146
|
if (activeIdx !== undefined && filteredEnums[activeIdx]) {
|
|
@@ -132,7 +151,7 @@ function SearchableDrowndown(props) {
|
|
|
132
151
|
}
|
|
133
152
|
hide();
|
|
134
153
|
}, [activeIdx, filteredEnums, hide, onItemSelected]);
|
|
135
|
-
const onKeyDown = react_1.useCallback((e) => {
|
|
154
|
+
const onKeyDown = (0, react_1.useCallback)((e) => {
|
|
136
155
|
switch (e.key) {
|
|
137
156
|
case "ArrowDown":
|
|
138
157
|
if (!isOpen) {
|
|
@@ -166,23 +185,21 @@ function SearchableDrowndown(props) {
|
|
|
166
185
|
}
|
|
167
186
|
}, [activeIdx, activeIdxDown, activeIdxUp, filteredEnums, isOpen, onItemSelected, setActiveIdx, showAndSelectText, value]);
|
|
168
187
|
return (React.createElement("div", { onBlur: onBlur, onKeyDown: onKeyDown, ref: containerRef, style: { position: "relative" }, className: "laji-form-dropdown-container" },
|
|
169
|
-
React.createElement(FormControl, { disabled: disabled || readonly, id: id, onClick: showAndSelectText, onFocus: showAndSelectText, value: inputValue, onChange: onInputChange, autoComplete: "off", ref: inputRef }),
|
|
188
|
+
React.createElement(FormControl, { disabled: disabled || readonly, id: id, onClick: showAndSelectText, onFocus: showAndSelectText, value: inputValue, placeholder: options.placeholder, onChange: onInputChange, autoComplete: "off", ref: inputRef }),
|
|
170
189
|
React.createElement(Caret, null),
|
|
171
190
|
React.createElement("div", { className: `laji-form-dropdown laji-form-dropdown-${isOpen ? "open" : "closed"}`, style: { position: "absolute" }, tabIndex: -1, ref: dropdownRef }, filteredEnums.map((oneOf, idx) => {
|
|
172
191
|
var _a;
|
|
173
192
|
return (React.createElement(ListItem, { key: (_a = oneOf.value) !== null && _a !== void 0 ? _a : "", onSelected: onItemSelected, active: idx === activeIdx }, oneOf));
|
|
174
193
|
}))));
|
|
175
194
|
}
|
|
176
|
-
exports.SearchableDrowndown = SearchableDrowndown;
|
|
177
195
|
function SearchableMultiDrowndown(props) {
|
|
178
|
-
const { id, disabled, readonly, value, uiSchema, options, onChange, getEnumOptionsAsync } = props;
|
|
179
|
-
const [enumOptions, setEnumOptions] = react_1.useState(getEnumOptionsAsync
|
|
196
|
+
const { id, disabled, readonly, value, uiSchema, options, onChange, getEnumOptionsAsync, formContext } = props;
|
|
197
|
+
const [enumOptions, setEnumOptions] = (0, react_1.useState)(getEnumOptionsAsync
|
|
180
198
|
? undefined
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
182
199
|
: getEnumOptions(options.enumOptions, uiSchema, false));
|
|
183
|
-
const [filterTerm, setFilterTerm] = react_1.useState();
|
|
184
|
-
const [loading, setLoading] = react_1.useState(undefined);
|
|
185
|
-
const [isOpen, show, hide] = utils_1.useBooleanSetter(false);
|
|
200
|
+
const [filterTerm, setFilterTerm] = (0, react_1.useState)();
|
|
201
|
+
const [loading, setLoading] = (0, react_1.useState)(undefined);
|
|
202
|
+
const [isOpen, show, hide] = (0, utils_1.useBooleanSetter)(false);
|
|
186
203
|
const inputValue = filterTerm !== null && filterTerm !== void 0 ? filterTerm : "";
|
|
187
204
|
const containerRef = React.useRef(null);
|
|
188
205
|
const inputRef = React.useRef(null);
|
|
@@ -199,28 +216,27 @@ function SearchableMultiDrowndown(props) {
|
|
|
199
216
|
: notAlreadySelected;
|
|
200
217
|
}, [filterTerm, enumOptions, value]);
|
|
201
218
|
const [activeIdx, activeIdxUp, activeIdxDown, setActiveIdx] = useRangeIncrementor((filteredEnums || []).length, undefined);
|
|
202
|
-
const onInputChange = react_1.useCallback((e) => {
|
|
219
|
+
const onInputChange = (0, react_1.useCallback)((e) => {
|
|
203
220
|
const { value } = e.target;
|
|
204
221
|
setFilterTerm(value);
|
|
205
222
|
setActiveIdx(undefined);
|
|
206
223
|
}, [setActiveIdx]);
|
|
207
|
-
const onItemSelected = react_1.useCallback((item) => {
|
|
224
|
+
const onItemSelected = (0, react_1.useCallback)((item) => {
|
|
208
225
|
var _a;
|
|
209
226
|
onChange([...(value || []), item.value]);
|
|
210
227
|
setFilterTerm(undefined);
|
|
211
228
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
212
229
|
setActiveIdx(undefined);
|
|
213
230
|
}, [onChange, setActiveIdx, value]);
|
|
214
|
-
const onItemSelectedByBlur = react_1.useCallback((item) => {
|
|
231
|
+
const onItemSelectedByBlur = (0, react_1.useCallback)((item) => {
|
|
215
232
|
onChange([...(value || []), item.value]);
|
|
216
233
|
setFilterTerm(undefined);
|
|
217
234
|
setActiveIdx(undefined);
|
|
218
235
|
}, [onChange, setActiveIdx, value]);
|
|
219
|
-
const [isFocused, setFocused, setBlurred] = utils_1.useBooleanSetter(false);
|
|
220
|
-
const loadEnums = react_1.useCallback(() => {
|
|
236
|
+
const [isFocused, setFocused, setBlurred] = (0, utils_1.useBooleanSetter)(false);
|
|
237
|
+
const loadEnums = (0, react_1.useCallback)(() => {
|
|
221
238
|
const asyncOp = () => __awaiter(this, void 0, void 0, function* () {
|
|
222
239
|
try {
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
224
240
|
const enums = yield getEnumOptionsAsync();
|
|
225
241
|
setEnumOptions(enums);
|
|
226
242
|
}
|
|
@@ -231,10 +247,10 @@ function SearchableMultiDrowndown(props) {
|
|
|
231
247
|
setLoading(true);
|
|
232
248
|
void asyncOp();
|
|
233
249
|
}, [getEnumOptionsAsync]);
|
|
234
|
-
const prevEnumOptions = utils_1.usePrevious(enumOptions);
|
|
250
|
+
const prevEnumOptions = (0, utils_1.usePrevious)(enumOptions);
|
|
235
251
|
// If the enums are async loaded, this effect takes care of opening the
|
|
236
252
|
// dropdown once the enums are loaded, if the input if still focused.
|
|
237
|
-
react_1.useEffect(() => {
|
|
253
|
+
(0, react_1.useEffect)(() => {
|
|
238
254
|
if (!getEnumOptionsAsync) {
|
|
239
255
|
return;
|
|
240
256
|
}
|
|
@@ -244,12 +260,12 @@ function SearchableMultiDrowndown(props) {
|
|
|
244
260
|
}, [prevEnumOptions, enumOptions, isFocused, show, getEnumOptionsAsync]);
|
|
245
261
|
// If there is a pre-existing value (or a value is updated from parent after component is rendered) and we are async,
|
|
246
262
|
// load the enums.
|
|
247
|
-
react_1.useEffect(() => {
|
|
263
|
+
(0, react_1.useEffect)(() => {
|
|
248
264
|
if ((value === null || value === void 0 ? void 0 : value.length) && getEnumOptionsAsync && !enumOptions && !loading) {
|
|
249
265
|
loadEnums();
|
|
250
266
|
}
|
|
251
267
|
}, [enumOptions, getEnumOptionsAsync, loadEnums, loading, value === null || value === void 0 ? void 0 : value.length]);
|
|
252
|
-
const onFocus = react_1.useCallback(() => {
|
|
268
|
+
const onFocus = (0, react_1.useCallback)(() => {
|
|
253
269
|
setFocused();
|
|
254
270
|
if (!(enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions.length) && getEnumOptionsAsync) {
|
|
255
271
|
void loadEnums();
|
|
@@ -258,11 +274,11 @@ function SearchableMultiDrowndown(props) {
|
|
|
258
274
|
show();
|
|
259
275
|
}
|
|
260
276
|
}, [enumOptions === null || enumOptions === void 0 ? void 0 : enumOptions.length, getEnumOptionsAsync, loadEnums, setFocused, show]);
|
|
261
|
-
const onBlur = react_1.useCallback((e) => {
|
|
277
|
+
const onBlur = (0, react_1.useCallback)((e) => {
|
|
262
278
|
// Fixes the problem when user tries to click an enum item, `setOpen(false)`
|
|
263
279
|
// hides the enum list, so the elem list item is hidden before the click, thus never
|
|
264
280
|
// sending a click event.
|
|
265
|
-
if (e.relatedTarget && utils_1.isDescendant(containerRef.current, e.relatedTarget)) {
|
|
281
|
+
if (e.relatedTarget && (0, utils_1.isDescendant)(containerRef.current, e.relatedTarget)) {
|
|
266
282
|
return;
|
|
267
283
|
}
|
|
268
284
|
setBlurred();
|
|
@@ -274,7 +290,7 @@ function SearchableMultiDrowndown(props) {
|
|
|
274
290
|
setFilterTerm(undefined);
|
|
275
291
|
}
|
|
276
292
|
}, [activeIdx, filteredEnums, hide, onItemSelectedByBlur, setBlurred]);
|
|
277
|
-
const onKeyDown = react_1.useCallback((e) => {
|
|
293
|
+
const onKeyDown = (0, react_1.useCallback)((e) => {
|
|
278
294
|
switch (e.key) {
|
|
279
295
|
case "ArrowDown":
|
|
280
296
|
activeIdxDown();
|
|
@@ -296,15 +312,13 @@ function SearchableMultiDrowndown(props) {
|
|
|
296
312
|
break;
|
|
297
313
|
case "Backspace":
|
|
298
314
|
if (inputValue === "" && (value === null || value === void 0 ? void 0 : value.length)) {
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
300
315
|
onChange(value.slice(0, -1));
|
|
301
316
|
e.preventDefault();
|
|
302
317
|
}
|
|
303
318
|
break;
|
|
304
319
|
}
|
|
305
320
|
}, [activeIdx, activeIdxDown, activeIdxUp, filteredEnums, inputValue, onChange, onItemSelected, value]);
|
|
306
|
-
|
|
307
|
-
const onDelete = react_1.useCallback((enu) => {
|
|
321
|
+
const onDelete = (0, react_1.useCallback)((enu) => {
|
|
308
322
|
var _a;
|
|
309
323
|
const filtered = value.filter(v => v !== enu.value);
|
|
310
324
|
onChange(value.length === 0 ? undefined : filtered);
|
|
@@ -312,8 +326,7 @@ function SearchableMultiDrowndown(props) {
|
|
|
312
326
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
313
327
|
}
|
|
314
328
|
}, [isOpen, onChange, value]);
|
|
315
|
-
|
|
316
|
-
const redirectFocusToInput = react_1.useCallback((e) => {
|
|
329
|
+
const redirectFocusToInput = (0, react_1.useCallback)((e) => {
|
|
317
330
|
var _a;
|
|
318
331
|
// Only the input wrapper should redirect focus, otherwise the existing label deletion buttons will also redirect, breaking shift + tab navigation on the input.
|
|
319
332
|
if (!e.target.classList.contains("laji-form-multiselect-input-wrapper")) {
|
|
@@ -321,11 +334,18 @@ function SearchableMultiDrowndown(props) {
|
|
|
321
334
|
}
|
|
322
335
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
323
336
|
}, [inputRef]);
|
|
324
|
-
const wrapperClassNames = utils_1.classNames("laji-form-multiselect-input-wrapper", isOpen && "laji-form-multiselect-input-wrapper-focus", isOpen && "input-highlight", (readonly || disabled) && "laji-form-multiselect-input-wrapper-readonly");
|
|
337
|
+
const wrapperClassNames = (0, utils_1.classNames)("laji-form-multiselect-input-wrapper", isOpen && "laji-form-multiselect-input-wrapper-focus", isOpen && "input-highlight", (readonly || disabled) && "laji-form-multiselect-input-wrapper-readonly");
|
|
338
|
+
const selectedListChildren = value && enumOptions && value.map(v => enumOptions.find(({ value: _value }) => v === _value) || ({ value: v, label: "" + v }))
|
|
339
|
+
.map((enu, idx) => {
|
|
340
|
+
var _a;
|
|
341
|
+
const childId = id ? `${id}_${idx}` : undefined;
|
|
342
|
+
const childIdPointer = childId ? (0, utils_1.idSchemaIdToJSONPointer)(childId) : undefined;
|
|
343
|
+
const classNames = childIdPointer ? (_a = formContext.uiSchemaContext.additionalClassNames) === null || _a === void 0 ? void 0 : _a[childIdPointer] : undefined;
|
|
344
|
+
return React.createElement(SelectedMultiValue, { id: childId, className: classNames, key: enu.value, onDelete: onDelete, readonly: readonly || disabled }, enu);
|
|
345
|
+
});
|
|
325
346
|
return (React.createElement("div", { onBlur: onBlur, onKeyDown: onKeyDown, ref: containerRef, className: "laji-form-multiselect", style: { position: "relative" } },
|
|
326
347
|
React.createElement("div", { className: wrapperClassNames, tabIndex: -1, onFocus: redirectFocusToInput, style: { cursor: "text" } },
|
|
327
|
-
React.createElement("ul", { style: { listStyle: "none", display: "inline-block" } },
|
|
328
|
-
.map(enu => React.createElement(SelectedMultiValue, { key: enu.value, onDelete: onDelete, readonly: readonly || disabled }, enu))),
|
|
348
|
+
React.createElement("ul", { style: { listStyle: "none", display: "inline-block" } }, selectedListChildren),
|
|
329
349
|
React.createElement("input", { disabled: disabled || readonly, id: id, onFocus: onFocus, value: inputValue, onChange: onInputChange, autoComplete: "off", ref: inputRef }),
|
|
330
350
|
loading && React.createElement(react_spinner_1.default, null)),
|
|
331
351
|
React.createElement(Caret, null),
|
|
@@ -334,9 +354,9 @@ function SearchableMultiDrowndown(props) {
|
|
|
334
354
|
return (React.createElement(ListItem, { key: (_a = oneOf.value) !== null && _a !== void 0 ? _a : "", onSelected: onItemSelected, active: idx === activeIdx }, oneOf));
|
|
335
355
|
}))));
|
|
336
356
|
}
|
|
337
|
-
function SelectedMultiValue({ children: enu, onDelete, readonly }) {
|
|
338
|
-
const onDeleteClick = react_1.useCallback(() => !readonly && onDelete(enu), [enu, onDelete, readonly]);
|
|
339
|
-
return (React.createElement("li", { key: enu.value, style: { display: "inline-table" }, className: "laji-form-multiselect-tag" },
|
|
357
|
+
function SelectedMultiValue({ id, className, children: enu, onDelete, readonly }) {
|
|
358
|
+
const onDeleteClick = (0, react_1.useCallback)(() => !readonly && onDelete(enu), [enu, onDelete, readonly]);
|
|
359
|
+
return (React.createElement("li", { id: id ? `_laji-form_${id}` : undefined, key: enu.value, style: { display: "inline-table" }, className: (0, utils_1.classNames)("laji-form-multiselect-tag", className) },
|
|
340
360
|
enu.label,
|
|
341
361
|
React.createElement("span", { tabIndex: readonly ? undefined : 0, role: readonly ? undefined : "button", onClick: onDeleteClick }, "\u00D7")));
|
|
342
362
|
}
|
|
@@ -344,10 +364,10 @@ const Caret = () => (React.createElement("div", { className: "laji-form-dropdown
|
|
|
344
364
|
React.createElement("span", { className: "laji-form-dropdown-caret" },
|
|
345
365
|
React.createElement("img", { src: "https://cdn.laji.fi/images/icons/caret-down.svg" }))));
|
|
346
366
|
function ListItem({ onSelected, active, children }) {
|
|
347
|
-
const onClick = react_1.useCallback(() => {
|
|
367
|
+
const onClick = (0, react_1.useCallback)(() => {
|
|
348
368
|
onSelected(children);
|
|
349
369
|
}, [children, onSelected]);
|
|
350
|
-
return (React.createElement("div", { onClick: onClick, className: utils_1.classNames("laji-form-dropdown-item", active && "active"), tabIndex: -1 }, children.label));
|
|
370
|
+
return (React.createElement("div", { onClick: onClick, className: (0, utils_1.classNames)("laji-form-dropdown-item", active && "active"), tabIndex: -1 }, children.label));
|
|
351
371
|
}
|
|
352
372
|
function getDefaultActiveIdx(filteredEnums, value) {
|
|
353
373
|
return value !== undefined && value !== ""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default class SeparatedDateTimeWidget extends React.Component<any, any, any> {
|
|
2
2
|
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
3
3
|
static propTypes: {
|
|
4
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
4
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
5
5
|
type: PropTypes.Requireable<string>;
|
|
6
|
-
}
|
|
6
|
+
}>>>;
|
|
7
7
|
value: PropTypes.Requireable<string>;
|
|
8
8
|
};
|
|
9
9
|
constructor(props: any);
|
|
@@ -14,6 +14,7 @@ export default class SeparatedDateTimeWidget extends React.Component<any, any, a
|
|
|
14
14
|
};
|
|
15
15
|
onDateChange: (value: any) => void;
|
|
16
16
|
onTimeChange: (value: any) => void;
|
|
17
|
+
render(): JSX.Element;
|
|
17
18
|
}
|
|
18
19
|
import * as React from "react";
|
|
19
20
|
import * as PropTypes from "prop-types";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -17,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
17
21
|
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;
|
|
18
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
23
|
};
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
27
41
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
42
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
43
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export default class TaxonImageWidget extends React.Component<any, any, any> {
|
|
2
2
|
static propTypes: {
|
|
3
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
3
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
4
4
|
type: PropTypes.Requireable<string>;
|
|
5
|
-
}
|
|
5
|
+
}>>>;
|
|
6
6
|
value: PropTypes.Requireable<string>;
|
|
7
7
|
};
|
|
8
8
|
constructor(props: any);
|
|
9
9
|
constructor(props: any, context: any);
|
|
10
|
+
render(): JSX.Element;
|
|
10
11
|
onTaxonImageClick: (taxonID: any) => () => void;
|
|
11
12
|
}
|
|
12
13
|
import * as React from "react";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
36
|
const React = __importStar(require("react"));
|
|
23
37
|
const PropTypes = __importStar(require("prop-types"));
|
|
@@ -31,7 +45,7 @@ class TaxonImageWidget extends React.Component {
|
|
|
31
45
|
}
|
|
32
46
|
render() {
|
|
33
47
|
const { SchemaField } = this.props.registry.fields;
|
|
34
|
-
const { uiSchema } = utils_1.getUiOptions(this.props);
|
|
48
|
+
const { uiSchema } = (0, utils_1.getUiOptions)(this.props);
|
|
35
49
|
const schemaField = uiSchema
|
|
36
50
|
? React.createElement(SchemaField, Object.assign({}, this.props, { schema: Object.assign(Object.assign({}, this.props.schema), { title: "" }), uiSchema: Object.assign(Object.assign({}, uiSchema), { "ui:title": "" }) }))
|
|
37
51
|
: null;
|
|
@@ -40,10 +54,10 @@ class TaxonImageWidget extends React.Component {
|
|
|
40
54
|
schemaField));
|
|
41
55
|
}
|
|
42
56
|
}
|
|
43
|
-
exports.default = TaxonImageWidget;
|
|
44
57
|
TaxonImageWidget.propTypes = {
|
|
45
58
|
schema: PropTypes.shape({
|
|
46
59
|
type: PropTypes.oneOf(["string"])
|
|
47
60
|
}).isRequired,
|
|
48
61
|
value: PropTypes.string
|
|
49
62
|
};
|
|
63
|
+
exports.default = TaxonImageWidget;
|
|
@@ -2,12 +2,19 @@ export default TextSelectWidget;
|
|
|
2
2
|
declare class TextSelectWidget extends React.Component<any, any, any> {
|
|
3
3
|
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
4
4
|
static propTypes: {
|
|
5
|
-
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
5
|
+
schema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
6
6
|
type: PropTypes.Requireable<string>;
|
|
7
|
-
}
|
|
7
|
+
}>>>;
|
|
8
8
|
value: PropTypes.Requireable<string>;
|
|
9
9
|
};
|
|
10
10
|
constructor(props: any);
|
|
11
|
+
state: {
|
|
12
|
+
selectedCheckboxes: Set<any>;
|
|
13
|
+
enums: any;
|
|
14
|
+
otherValue: string;
|
|
15
|
+
freeTextField: any;
|
|
16
|
+
};
|
|
17
|
+
UNSAFE_componentWillReceiveProps(props: any): void;
|
|
11
18
|
getInitialState(props: any): {
|
|
12
19
|
selectedCheckboxes: Set<any>;
|
|
13
20
|
enums: any;
|
|
@@ -17,6 +24,7 @@ declare class TextSelectWidget extends React.Component<any, any, any> {
|
|
|
17
24
|
getStateFromProps(props: any): {
|
|
18
25
|
otherValue: string;
|
|
19
26
|
};
|
|
27
|
+
render(): JSX.Element;
|
|
20
28
|
onCheckBoxChange: (label: any) => () => void;
|
|
21
29
|
onInputChange: (value: any) => void;
|
|
22
30
|
onChange: (textValue: any) => void;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
37
|
};
|
|
@@ -49,7 +63,7 @@ class TextSelectWidget extends React.Component {
|
|
|
49
63
|
let newValue = [...Array.from(this.state.selectedCheckboxes)];
|
|
50
64
|
if (this.state.selectedCheckboxes.has(this.state.freeTextField)) {
|
|
51
65
|
if (textValue && textValue.length > 0) {
|
|
52
|
-
newValue = immutability_helper_1.default(newValue, { $push: [textValue] });
|
|
66
|
+
newValue = (0, immutability_helper_1.default)(newValue, { $push: [textValue] });
|
|
53
67
|
}
|
|
54
68
|
newValue.splice(newValue.indexOf(this.state.freeTextField), 1);
|
|
55
69
|
}
|
|
@@ -61,7 +75,7 @@ class TextSelectWidget extends React.Component {
|
|
|
61
75
|
this.setState(this.getStateFromProps(props));
|
|
62
76
|
}
|
|
63
77
|
getInitialState(props) {
|
|
64
|
-
let { enums = [], delimiter = ", ", freeTextField } = utils_1.getUiOptions(props);
|
|
78
|
+
let { enums = [], delimiter = ", ", freeTextField } = (0, utils_1.getUiOptions)(props);
|
|
65
79
|
const { value } = props;
|
|
66
80
|
const selectedCheckboxes = new Set();
|
|
67
81
|
const values = !value ? [] : value.split(delimiter);
|
|
@@ -80,7 +94,7 @@ class TextSelectWidget extends React.Component {
|
|
|
80
94
|
return { selectedCheckboxes, enums, otherValue: otherValues.join(delimiter), freeTextField };
|
|
81
95
|
}
|
|
82
96
|
getStateFromProps(props) {
|
|
83
|
-
let { enums = [], delimiter = ", " } = utils_1.getUiOptions(props);
|
|
97
|
+
let { enums = [], delimiter = ", " } = (0, utils_1.getUiOptions)(props);
|
|
84
98
|
const { value } = props;
|
|
85
99
|
const values = !value ? [] : value.split(delimiter);
|
|
86
100
|
const otherValues = [];
|
|
@@ -94,7 +108,7 @@ class TextSelectWidget extends React.Component {
|
|
|
94
108
|
render() {
|
|
95
109
|
let { enums, otherValue, freeTextField, selectedCheckboxes } = this.state;
|
|
96
110
|
if (freeTextField) {
|
|
97
|
-
enums = immutability_helper_1.default(enums, { $push: [freeTextField] });
|
|
111
|
+
enums = (0, immutability_helper_1.default)(enums, { $push: [freeTextField] });
|
|
98
112
|
}
|
|
99
113
|
const { Checkbox } = this.context.theme;
|
|
100
114
|
return (React.createElement("div", { className: "laji-text-select" },
|
|
@@ -11,8 +11,12 @@ export default class TextareaWidget extends React.Component<any, any, any> {
|
|
|
11
11
|
};
|
|
12
12
|
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
13
13
|
constructor(props: any);
|
|
14
|
+
state: {
|
|
15
|
+
value: any;
|
|
16
|
+
};
|
|
14
17
|
textareaRef: React.RefObject<any>;
|
|
15
18
|
_context: Record<string, unknown>;
|
|
19
|
+
UNSAFE_componentWillReceiveProps(props: any): void;
|
|
16
20
|
getStateFromProps: (props: any) => {
|
|
17
21
|
value: any;
|
|
18
22
|
};
|
|
@@ -26,6 +30,7 @@ export default class TextareaWidget extends React.Component<any, any, any> {
|
|
|
26
30
|
value: any;
|
|
27
31
|
};
|
|
28
32
|
}) => void;
|
|
33
|
+
render(): JSX.Element;
|
|
29
34
|
}
|
|
30
35
|
import * as React from "react";
|
|
31
36
|
import * as PropTypes from "prop-types";
|