@luomus/laji-form 15.1.55 → 15.1.56
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/styles.css +6 -3
- package/lib/ReactContext.js +20 -1
- package/lib/components/LajiForm.js +47 -25
- package/lib/components/VirtualSchemaField.d.ts +1 -1
- package/lib/components/VirtualSchemaField.js +25 -3
- package/lib/components/components/Affix.d.ts +38 -0
- package/lib/components/components/Affix.js +155 -0
- package/lib/components/components/Button.d.ts +14 -0
- package/lib/components/components/Button.js +46 -0
- package/lib/components/components/DeleteButton.d.ts +36 -0
- package/lib/components/components/DeleteButton.js +132 -0
- package/lib/components/components/ErrorPanel.d.ts +29 -0
- package/lib/components/components/ErrorPanel.js +75 -0
- package/lib/components/components/FailedBackgroundJobsPanel.d.ts +24 -0
- package/lib/components/components/FailedBackgroundJobsPanel.js +97 -0
- package/lib/components/components/FetcherInput.d.ts +14 -0
- package/lib/components/components/FetcherInput.js +62 -0
- package/lib/components/components/Fullscreen.d.ts +14 -0
- package/lib/components/components/Fullscreen.js +43 -0
- package/lib/components/components/GlyphButton.d.ts +10 -0
- package/lib/components/components/GlyphButton.js +46 -0
- package/lib/components/components/Help.d.ts +19 -0
- package/lib/components/components/Help.js +54 -0
- package/lib/components/components/Label.d.ts +12 -0
- package/lib/components/components/Label.js +59 -0
- package/lib/components/components/OverlayTrigger.d.ts +36 -0
- package/lib/components/components/OverlayTrigger.js +90 -0
- package/lib/components/components/Stretch.d.ts +36 -0
- package/lib/components/components/Stretch.js +115 -0
- package/lib/components/components/TooltipComponent.d.ts +12 -0
- package/lib/components/components/TooltipComponent.js +38 -0
- package/lib/components/components/index.d.ts +13 -0
- package/lib/components/components/index.js +25 -0
- package/lib/components/fields/AnnotationField.js +30 -8
- package/lib/components/fields/AnyToBooleanField.js +21 -2
- package/lib/components/fields/ArrayBulkField.js +25 -3
- package/lib/components/fields/ArrayCombinerField.js +27 -5
- package/lib/components/fields/ArrayField.js +27 -5
- package/lib/components/fields/ArrayPropertySumField.js +25 -3
- package/lib/components/fields/AsArrayField.js +25 -3
- package/lib/components/fields/AudioArrayField.js +28 -6
- package/lib/components/fields/AutoArrayField.js +25 -3
- package/lib/components/fields/AutosuggestField.js +27 -5
- package/lib/components/fields/CombinedValueDisplayField.js +25 -3
- package/lib/components/fields/CondensedObjectField.d.ts +1 -1
- package/lib/components/fields/CondensedObjectField.js +29 -7
- package/lib/components/fields/ConditionalOnChangeField.js +25 -3
- package/lib/components/fields/ConditionalUiSchemaField.js +27 -5
- package/lib/components/fields/ContextInjectionField.js +26 -4
- package/lib/components/fields/DataLeakerField.js +25 -3
- package/lib/components/fields/DefaultValueArrayField.js +26 -4
- package/lib/components/fields/DependentBooleanField.js +26 -4
- package/lib/components/fields/DependentDisableField.js +26 -4
- package/lib/components/fields/EnumRangeArrayField.js +25 -3
- package/lib/components/fields/ExtraLabelRowField.d.ts +1 -3
- package/lib/components/fields/ExtraLabelRowField.js +29 -12
- package/lib/components/fields/FakePropertyField.js +25 -3
- package/lib/components/fields/FilterArrayField.js +25 -3
- package/lib/components/fields/FlatField.js +26 -4
- package/lib/components/fields/GeocoderField.js +32 -10
- package/lib/components/fields/GridLayoutField.js +21 -2
- package/lib/components/fields/HiddenField.js +21 -2
- package/lib/components/fields/HiddenWithTextField.js +21 -2
- package/lib/components/fields/ImageArrayField.js +41 -19
- package/lib/components/fields/ImageDisplayField.js +26 -4
- package/lib/components/fields/InitiallyHiddenField.js +26 -4
- package/lib/components/fields/InjectDefaultValueField.js +26 -4
- package/lib/components/fields/InjectField.js +25 -3
- package/lib/components/fields/InputWithDefaultValueButtonField.js +27 -5
- package/lib/components/fields/LocalityField.js +27 -5
- package/lib/components/fields/LocationChooserField.js +27 -5
- package/lib/components/fields/MapArrayField.js +33 -12
- package/lib/components/fields/MapField.js +29 -8
- package/lib/components/fields/MultiAnyToBooleanField.js +26 -4
- package/lib/components/fields/MultiArrayField.js +26 -4
- package/lib/components/fields/MultiLanguageField.js +25 -3
- package/lib/components/fields/MultiTagArrayField.d.ts +2 -5
- package/lib/components/fields/MultiTagArrayField.js +34 -19
- package/lib/components/fields/NamedPlaceChooserField.js +31 -9
- package/lib/components/fields/NamedPlaceSaverField.js +33 -11
- package/lib/components/fields/NestField.js +28 -6
- package/lib/components/fields/ObjectField.js +24 -2
- package/lib/components/fields/PdfArrayField.js +20 -1
- package/lib/components/fields/PrefillingArrayField.js +25 -3
- package/lib/components/fields/SchemaField.js +20 -1
- package/lib/components/fields/ScopeField.js +30 -8
- package/lib/components/fields/SectionArrayField.js +34 -13
- package/lib/components/fields/SelectTreeField.js +20 -1
- package/lib/components/fields/SingleActiveArrayField.js +41 -26
- package/lib/components/fields/SingleItemArrayField.js +25 -3
- package/lib/components/fields/SortArrayField.js +31 -9
- package/lib/components/fields/SplitField.js +26 -4
- package/lib/components/fields/StringToArrayField.js +25 -3
- package/lib/components/fields/SumField.js +25 -3
- package/lib/components/fields/TableField.js +26 -4
- package/lib/components/fields/TagArrayField.d.ts +1 -1
- package/lib/components/fields/TagArrayField.js +28 -6
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +26 -4
- package/lib/components/fields/UiFieldApplierField.js +25 -3
- package/lib/components/fields/UiFieldMapperArrayField.js +25 -3
- package/lib/components/fields/UnitCountShorthandField.js +29 -7
- package/lib/components/fields/UnitListShorthandArrayField.js +26 -4
- package/lib/components/fields/UnitShorthandField.js +27 -5
- package/lib/components/templates/ArrayFieldTemplate.js +27 -5
- package/lib/components/templates/BaseInputTemplate.js +24 -2
- package/lib/components/templates/DescriptionField.js +21 -2
- package/lib/components/templates/ErrorListTemplate.js +24 -2
- package/lib/components/templates/FieldTemplate.js +24 -2
- package/lib/components/templates/ObjectFieldTemplate.js +24 -2
- package/lib/components/templates/TitleField.js +25 -3
- package/lib/components/widgets/AnyToBooleanWidget.js +21 -2
- package/lib/components/widgets/AutosuggestWidget.js +33 -7
- package/lib/components/widgets/CheckboxWidget.js +25 -3
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/DateTimeWidget.js +38 -16
- package/lib/components/widgets/DateWidget.js +27 -5
- package/lib/components/widgets/HiddenWidget.js +21 -2
- package/lib/components/widgets/ImageSelectWidget.js +28 -6
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +30 -8
- package/lib/components/widgets/InputGroupWidget.js +27 -5
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +26 -4
- package/lib/components/widgets/NumberWidget.js +25 -3
- package/lib/components/widgets/PlainTextWidget.js +21 -2
- package/lib/components/widgets/SelectWidget.js +26 -4
- package/lib/components/widgets/SeparatedDateTimeWidget.js +28 -6
- package/lib/components/widgets/TaxonImageWidget.js +21 -2
- package/lib/components/widgets/TextSelectWidget.js +27 -5
- package/lib/components/widgets/TextareaWidget.js +26 -4
- package/lib/components/widgets/TimeWidget.js +28 -6
- package/lib/components/widgets/URLWidget.js +21 -2
- package/lib/components/widgets/UpperCaseWidget.js +25 -3
- package/lib/index.js +24 -2
- package/lib/services/id-service.d.ts +1 -1
- package/lib/services/id-service.js +1 -1
- package/lib/services/key-handler-service.js +4 -1
- package/lib/services/singleton-map-service.js +4 -1
- package/lib/services/submit-hook-service.d.ts +4 -2
- package/lib/services/submit-hook-service.js +1 -0
- package/lib/themes/bs3.js +94 -72
- package/lib/themes/bs5.js +20 -1
- package/lib/themes/stub.js +20 -1
- package/lib/themes/theme.d.ts +5 -3
- package/lib/utils.js +27 -5
- package/lib/validation.js +20 -1
- package/package.json +1 -1
- package/test-export/test-utils.js +20 -1
- package/lib/components/components.d.ts +0 -129
- package/lib/components/components.js +0 -633
package/dist/styles.css
CHANGED
|
@@ -2820,6 +2820,9 @@ body .laji-form {
|
|
|
2820
2820
|
left: initial !important;
|
|
2821
2821
|
right: 5px;
|
|
2822
2822
|
}
|
|
2823
|
+
.laji-form .laji-form-failed-jobs-list .list-group .btn {
|
|
2824
|
+
padding: 0;
|
|
2825
|
+
}
|
|
2823
2826
|
.laji-form .laji-form-error-list {
|
|
2824
2827
|
top: 5px;
|
|
2825
2828
|
left: 5px;
|
|
@@ -2865,13 +2868,13 @@ body .laji-form {
|
|
|
2865
2868
|
.laji-form .laji-form-error-list .panel-title {
|
|
2866
2869
|
color: white;
|
|
2867
2870
|
}
|
|
2868
|
-
.laji-form .laji-form-error-list .btn-link {
|
|
2871
|
+
.laji-form .laji-form-error-list .panel-title .btn-link {
|
|
2869
2872
|
color: white;
|
|
2870
2873
|
}
|
|
2871
|
-
.laji-form .laji-form-error-list .btn-link:hover {
|
|
2874
|
+
.laji-form .laji-form-error-list .panel-title .btn-link:hover {
|
|
2872
2875
|
color: #dddddd;
|
|
2873
2876
|
}
|
|
2874
|
-
.laji-form .laji-form-error-list .btn-link:focus {
|
|
2877
|
+
.laji-form .laji-form-error-list .panel-title .btn-link:focus {
|
|
2875
2878
|
outline: none;
|
|
2876
2879
|
}
|
|
2877
2880
|
.laji-form .btn-group.laji-form-checkbox-widget-tab-target:focus {
|
package/lib/ReactContext.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const React = require("react");
|
|
22
|
+
const React = __importStar(require("react"));
|
|
4
23
|
const Context = React.createContext({});
|
|
5
24
|
exports.default = Context;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
22
|
var t = {};
|
|
4
23
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,33 +29,36 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
29
|
}
|
|
11
30
|
return t;
|
|
12
31
|
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
13
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const React = require("react");
|
|
36
|
+
const React = __importStar(require("react"));
|
|
15
37
|
const react_dom_1 = require("react-dom");
|
|
16
|
-
const PropTypes = require("prop-types");
|
|
17
|
-
const validation_1 = require("../validation");
|
|
38
|
+
const PropTypes = __importStar(require("prop-types"));
|
|
39
|
+
const validation_1 = __importDefault(require("../validation"));
|
|
18
40
|
const validation_2 = require("../validation");
|
|
19
41
|
const components_1 = require("./components");
|
|
20
42
|
const utils_1 = require("../utils");
|
|
21
43
|
const equals = require("deep-equal");
|
|
22
|
-
const validator_ajv6_1 = require("@rjsf/validator-ajv6");
|
|
23
|
-
const
|
|
24
|
-
const ReactContext_1 = require("../ReactContext");
|
|
25
|
-
const stub_1 = require("../themes/stub");
|
|
26
|
-
const core_1 = require("@rjsf/core");
|
|
27
|
-
const ApiClient_1 = require("../ApiClient");
|
|
28
|
-
const Context_1 = require("../Context");
|
|
29
|
-
const
|
|
30
|
-
const key_handler_service_1 = require("../services/key-handler-service");
|
|
31
|
-
const settings_service_1 = require("../services/settings-service");
|
|
32
|
-
const focus_service_1 = require("../services/focus-service");
|
|
33
|
-
const blocker_service_1 = require("../services/blocker-service");
|
|
34
|
-
const custom_event_service_1 = require("../services/custom-event-service");
|
|
35
|
-
const submit_hook_service_1 = require("../services/submit-hook-service");
|
|
36
|
-
const dom_id_service_1 = require("../services/dom-id-service");
|
|
37
|
-
const id_service_1 = require("../services/id-service");
|
|
38
|
-
const root_instance_service_1 = require("../services/root-instance-service");
|
|
39
|
-
const singleton_map_service_1 = require("../services/singleton-map-service");
|
|
44
|
+
const validator_ajv6_1 = __importDefault(require("@rjsf/validator-ajv6"));
|
|
45
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
46
|
+
const ReactContext_1 = __importDefault(require("../ReactContext"));
|
|
47
|
+
const stub_1 = __importDefault(require("../themes/stub"));
|
|
48
|
+
const core_1 = __importDefault(require("@rjsf/core"));
|
|
49
|
+
const ApiClient_1 = __importDefault(require("../ApiClient"));
|
|
50
|
+
const Context_1 = __importDefault(require("../Context"));
|
|
51
|
+
const translations_json_1 = __importDefault(require("../translations.json"));
|
|
52
|
+
const key_handler_service_1 = __importDefault(require("../services/key-handler-service"));
|
|
53
|
+
const settings_service_1 = __importDefault(require("../services/settings-service"));
|
|
54
|
+
const focus_service_1 = __importDefault(require("../services/focus-service"));
|
|
55
|
+
const blocker_service_1 = __importDefault(require("../services/blocker-service"));
|
|
56
|
+
const custom_event_service_1 = __importDefault(require("../services/custom-event-service"));
|
|
57
|
+
const submit_hook_service_1 = __importDefault(require("../services/submit-hook-service"));
|
|
58
|
+
const dom_id_service_1 = __importDefault(require("../services/dom-id-service"));
|
|
59
|
+
const id_service_1 = __importDefault(require("../services/id-service"));
|
|
60
|
+
const root_instance_service_1 = __importDefault(require("../services/root-instance-service"));
|
|
61
|
+
const singleton_map_service_1 = __importDefault(require("../services/singleton-map-service"));
|
|
40
62
|
const fields = importLocalComponents("fields", [
|
|
41
63
|
"SchemaField",
|
|
42
64
|
{ "ArraySchemaField": "SchemaField" },
|
|
@@ -286,12 +308,12 @@ class LajiForm extends React.Component {
|
|
|
286
308
|
block && this.memoizedFormContext.services.blocker.push();
|
|
287
309
|
return new Promise(resolve => Promise.all([validation_1.default(validations, formData), validation_1.default(liveValidations, formData)]).then(([_validations, _liveValidations]) => {
|
|
288
310
|
if (nonlive || onlySchema) {
|
|
289
|
-
this.cachedNonliveValidations =
|
|
311
|
+
this.cachedNonliveValidations = deepmerge_1.default(schemaErrors, _validations);
|
|
290
312
|
block && this.memoizedFormContext.services.blocker.pop();
|
|
291
313
|
}
|
|
292
|
-
const merged =
|
|
314
|
+
const merged = deepmerge_1.default(_liveValidations, !nonlive
|
|
293
315
|
? (this.cachedNonliveValidations || {})
|
|
294
|
-
:
|
|
316
|
+
: deepmerge_1.default(_validations, schemaErrors));
|
|
295
317
|
this.validating = false;
|
|
296
318
|
resolve(!Object.keys(merged).length);
|
|
297
319
|
!equals((this.state.extraErrors || {}), merged) && this.setState({ extraErrors: merged }, this.popErrorListIfNeeded);
|
|
@@ -558,7 +580,7 @@ class LajiForm extends React.Component {
|
|
|
558
580
|
});
|
|
559
581
|
}
|
|
560
582
|
constructTranslations() {
|
|
561
|
-
return utils_1.constructTranslations(
|
|
583
|
+
return utils_1.constructTranslations(translations_json_1.default);
|
|
562
584
|
}
|
|
563
585
|
render() {
|
|
564
586
|
if (this.state.error)
|
|
@@ -14,10 +14,10 @@ export default function VirtualSchemaField<LFC extends Constructor<LajiFormCompo
|
|
|
14
14
|
getUiOptions(): any;
|
|
15
15
|
getStateFromProps: (props: FieldProps) => any;
|
|
16
16
|
render: () => React.ReactNode;
|
|
17
|
-
context: any;
|
|
18
17
|
readonly props: Readonly<FieldProps<import("../types").JSONSchema<any>>> & Readonly<{
|
|
19
18
|
children?: React.ReactNode;
|
|
20
19
|
}>;
|
|
20
|
+
context: any;
|
|
21
21
|
state: Readonly<{}>;
|
|
22
22
|
componentDidMount?: (() => void) | undefined;
|
|
23
23
|
setState: <K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<FieldProps<import("../types").JSONSchema<any>>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined) => void;
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
2
14
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
17
|
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
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
19
|
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
8
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
31
|
exports.getPropsWithInnerUiSchema = void 0;
|
|
10
|
-
const React = require("react");
|
|
32
|
+
const React = __importStar(require("react"));
|
|
11
33
|
const utils_1 = require("../utils");
|
|
12
|
-
const BaseComponent_1 = require("./BaseComponent");
|
|
13
|
-
const Context_1 = require("../Context");
|
|
34
|
+
const BaseComponent_1 = __importDefault(require("./BaseComponent"));
|
|
35
|
+
const Context_1 = __importDefault(require("../Context"));
|
|
14
36
|
function getPropsWithInnerUiSchema(props) {
|
|
15
37
|
return Object.assign(Object.assign({}, props), { uiSchema: utils_1.getInnerUiSchema(props.uiSchema) });
|
|
16
38
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare type Props = {
|
|
3
|
+
onAffixChange?: (changed: boolean) => void;
|
|
4
|
+
topOffset?: number;
|
|
5
|
+
bottomOffset?: number;
|
|
6
|
+
containerRef?: React.RefObject<HTMLElement>;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
declare enum AFFIX_STATE {
|
|
11
|
+
TOP = "TOP",
|
|
12
|
+
AFFIXED = "AFFIXED",
|
|
13
|
+
BOTTOM = "BOTTOM"
|
|
14
|
+
}
|
|
15
|
+
declare type State = {
|
|
16
|
+
affixState?: AFFIX_STATE | undefined;
|
|
17
|
+
change?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
top?: number;
|
|
20
|
+
affixHeight?: number;
|
|
21
|
+
fixerHeight?: number;
|
|
22
|
+
};
|
|
23
|
+
export declare class Affix extends React.Component<Props, State> {
|
|
24
|
+
constructor(props: Props);
|
|
25
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
26
|
+
wrapperRef: React.RefObject<HTMLDivElement>;
|
|
27
|
+
positionerRef: React.RefObject<HTMLDivElement>;
|
|
28
|
+
componentDidMount(): void;
|
|
29
|
+
componentWillUnmount(): void;
|
|
30
|
+
componentDidUpdate(prevProps: Props, prevState: State): void;
|
|
31
|
+
getState: (props: Props) => State;
|
|
32
|
+
_onScroll: () => void;
|
|
33
|
+
onScroll: () => void;
|
|
34
|
+
_onResize: () => void;
|
|
35
|
+
onResize: () => void;
|
|
36
|
+
render(): JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Affix = void 0;
|
|
23
|
+
const React = __importStar(require("react"));
|
|
24
|
+
const react_dom_1 = require("react-dom");
|
|
25
|
+
var AFFIX_STATE;
|
|
26
|
+
(function (AFFIX_STATE) {
|
|
27
|
+
AFFIX_STATE["TOP"] = "TOP";
|
|
28
|
+
AFFIX_STATE["AFFIXED"] = "AFFIXED";
|
|
29
|
+
AFFIX_STATE["BOTTOM"] = "BOTTOM";
|
|
30
|
+
})(AFFIX_STATE || (AFFIX_STATE = {}));
|
|
31
|
+
// const TOP = "TOP", AFFIXED = "AFFIXED", BOTTOM = "BOTTOM";
|
|
32
|
+
class Affix extends React.Component {
|
|
33
|
+
constructor(props) {
|
|
34
|
+
super(props);
|
|
35
|
+
this.containerRef = React.createRef();
|
|
36
|
+
this.wrapperRef = React.createRef();
|
|
37
|
+
this.positionerRef = React.createRef();
|
|
38
|
+
this.getState = (props) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const { topOffset = 0, bottomOffset = 0, containerRef } = props;
|
|
41
|
+
const container = react_dom_1.findDOMNode((containerRef || this.containerRef).current);
|
|
42
|
+
const wrapperElem = react_dom_1.findDOMNode(this.wrapperRef.current);
|
|
43
|
+
if (!container || !document.body.contains(container) || !wrapperElem) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
const containerTop = container.getBoundingClientRect().top;
|
|
47
|
+
const containerHeight = container.offsetHeight;
|
|
48
|
+
const containerVisibleHeight = containerHeight + containerTop;
|
|
49
|
+
const wrapperHeight = wrapperElem.offsetHeight;
|
|
50
|
+
const wrapperScrollHeight = wrapperElem.scrollHeight;
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
52
|
+
const scrolled = this.containerRef.current.getBoundingClientRect().top < topOffset;
|
|
53
|
+
const viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
|
54
|
+
const bottomDist = viewportHeight - container.getBoundingClientRect().top - containerHeight;
|
|
55
|
+
const bottomInvisibleHeight = Math.min(bottomDist, 0);
|
|
56
|
+
let affixState = AFFIX_STATE.TOP;
|
|
57
|
+
if (scrolled && containerVisibleHeight < wrapperScrollHeight + topOffset)
|
|
58
|
+
affixState = AFFIX_STATE.BOTTOM;
|
|
59
|
+
else if (scrolled)
|
|
60
|
+
affixState = AFFIX_STATE.AFFIXED;
|
|
61
|
+
const width = wrapperElem ? wrapperElem.offsetWidth : undefined;
|
|
62
|
+
const top = topOffset;
|
|
63
|
+
const affixHeight = affixState === AFFIX_STATE.BOTTOM
|
|
64
|
+
? Math.max(containerVisibleHeight
|
|
65
|
+
- topOffset
|
|
66
|
+
+ Math.min(bottomInvisibleHeight, 0)
|
|
67
|
+
- (bottomDist < bottomOffset ? Math.min(bottomOffset - bottomDist, bottomOffset) : 0), 0)
|
|
68
|
+
: undefined;
|
|
69
|
+
const wrapperCutHeight = wrapperHeight - (affixHeight || 0);
|
|
70
|
+
let change = undefined;
|
|
71
|
+
if (affixState === AFFIX_STATE.BOTTOM) {
|
|
72
|
+
if (!this.state) {
|
|
73
|
+
change = wrapperCutHeight;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (this.state.affixState === AFFIX_STATE.BOTTOM) {
|
|
77
|
+
const lastChange = (_a = this.state.change) !== null && _a !== void 0 ? _a : 0;
|
|
78
|
+
const changeNow = wrapperCutHeight;
|
|
79
|
+
change = lastChange + changeNow;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
change = wrapperCutHeight;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const fixerHeight = affixState === AFFIX_STATE.AFFIXED
|
|
87
|
+
? wrapperHeight - (affixHeight || 0)
|
|
88
|
+
: affixState === AFFIX_STATE.BOTTOM
|
|
89
|
+
? (affixHeight !== null && affixHeight !== void 0 ? affixHeight : 0) + (change !== null && change !== void 0 ? change : 0)
|
|
90
|
+
: 0;
|
|
91
|
+
return { affixState, width, top, affixHeight, fixerHeight, change };
|
|
92
|
+
};
|
|
93
|
+
this._onScroll = () => {
|
|
94
|
+
this.setState(this.getState(this.props));
|
|
95
|
+
};
|
|
96
|
+
this.onScroll = () => {
|
|
97
|
+
requestAnimationFrame(this._onScroll);
|
|
98
|
+
};
|
|
99
|
+
this._onResize = () => {
|
|
100
|
+
const positioner = react_dom_1.findDOMNode(this.positionerRef.current);
|
|
101
|
+
const width = positioner.getBoundingClientRect().width;
|
|
102
|
+
const nextState = { width };
|
|
103
|
+
const currentState = this.getState(this.props);
|
|
104
|
+
if (currentState.affixState !== AFFIX_STATE.TOP) {
|
|
105
|
+
nextState.top = currentState.top;
|
|
106
|
+
}
|
|
107
|
+
this.setState(nextState);
|
|
108
|
+
};
|
|
109
|
+
this.onResize = () => {
|
|
110
|
+
requestAnimationFrame(this._onResize);
|
|
111
|
+
};
|
|
112
|
+
this.state = this.getState(props);
|
|
113
|
+
}
|
|
114
|
+
componentDidMount() {
|
|
115
|
+
window.addEventListener("scroll", this.onScroll);
|
|
116
|
+
window.addEventListener("resize", this.onResize);
|
|
117
|
+
}
|
|
118
|
+
componentWillUnmount() {
|
|
119
|
+
window.removeEventListener("scroll", this.onScroll);
|
|
120
|
+
window.removeEventListener("resize", this.onResize);
|
|
121
|
+
}
|
|
122
|
+
componentDidUpdate(prevProps, prevState) {
|
|
123
|
+
if (!this.props.onAffixChange || !prevState || !this.state) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (prevState.affixState !== AFFIX_STATE.AFFIXED && this.state.affixState === AFFIX_STATE.AFFIXED) {
|
|
127
|
+
this.props.onAffixChange(true);
|
|
128
|
+
}
|
|
129
|
+
else if (prevState.affixState === AFFIX_STATE.AFFIXED && this.state.affixState !== AFFIX_STATE.AFFIXED) {
|
|
130
|
+
this.props.onAffixChange(false);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
const { children, style: containerStyle } = this.props;
|
|
135
|
+
const { top, width, affixState, affixHeight, fixerHeight } = this.state || {};
|
|
136
|
+
const style = {};
|
|
137
|
+
const fixerStyle = { position: "relative", zIndex: -1, height: fixerHeight };
|
|
138
|
+
style.position = "relative";
|
|
139
|
+
if (affixState === AFFIX_STATE.BOTTOM || affixState === AFFIX_STATE.AFFIXED) {
|
|
140
|
+
style.position = "fixed";
|
|
141
|
+
style.width = width;
|
|
142
|
+
style.top = top;
|
|
143
|
+
style.zIndex = 1000;
|
|
144
|
+
style.height = affixHeight;
|
|
145
|
+
if (affixState === AFFIX_STATE.BOTTOM) {
|
|
146
|
+
style.overflow = "hidden";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return (React.createElement("div", { style: containerStyle, ref: this.containerRef },
|
|
150
|
+
React.createElement("div", { ref: this.positionerRef }),
|
|
151
|
+
React.createElement("div", { ref: this.wrapperRef, style: style, className: this.props.className }, children),
|
|
152
|
+
React.createElement("div", { style: fixerStyle })));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.Affix = Affix;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ButtonProps as ThemedButtonProps } from "src/themes/theme";
|
|
3
|
+
export declare type ButtonProps = ThemedButtonProps & {
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
tooltipPlacement?: string;
|
|
6
|
+
tooltipTrigger?: string;
|
|
7
|
+
tooltipClass?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const Button: React.ForwardRefExoticComponent<Pick<ThemedButtonProps & {
|
|
10
|
+
tooltip?: string | undefined;
|
|
11
|
+
tooltipPlacement?: string | undefined;
|
|
12
|
+
tooltipTrigger?: string | undefined;
|
|
13
|
+
tooltipClass?: string | undefined;
|
|
14
|
+
}, "small" | "active" | "style" | "disabled" | "block" | "tooltip" | "children" | "key" | "id" | "className" | "onKeyDown" | "onClick" | "tooltipPlacement" | "tooltipTrigger" | "tooltipClass" | "variant"> & React.RefAttributes<unknown>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Button = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const ReactContext_1 = __importDefault(require("../../ReactContext"));
|
|
39
|
+
const components_1 = require("../components");
|
|
40
|
+
const react_1 = require("react");
|
|
41
|
+
exports.Button = react_1.forwardRef((_a, ref) => {
|
|
42
|
+
var { tooltip, tooltipPlacement, tooltipTrigger, tooltipClass } = _a, _props = __rest(_a, ["tooltip", "tooltipPlacement", "tooltipTrigger", "tooltipClass"]);
|
|
43
|
+
const { Button: _Button } = React.useContext(ReactContext_1.default).theme;
|
|
44
|
+
return (React.createElement(components_1.TooltipComponent, { tooltip: tooltip, placement: tooltipPlacement, trigger: tooltipTrigger, className: tooltipClass },
|
|
45
|
+
React.createElement(_Button, Object.assign({}, _props, { ref: ref }), _props.children)));
|
|
46
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ButtonProps } from "../components";
|
|
3
|
+
import { FormContext } from "../LajiForm";
|
|
4
|
+
declare type Props = ButtonProps & {
|
|
5
|
+
confirmStyle?: "browser";
|
|
6
|
+
corner?: boolean;
|
|
7
|
+
tooltip?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
glyphButton?: boolean;
|
|
11
|
+
confirm?: boolean;
|
|
12
|
+
confirmPlacement?: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
translations: FormContext["translations"];
|
|
16
|
+
};
|
|
17
|
+
declare type State = {
|
|
18
|
+
show?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class DeleteButton extends React.Component<Props, State> {
|
|
21
|
+
static contextType: React.Context<import("../../ReactContext").ContextProps>;
|
|
22
|
+
buttonRef: React.RefObject<any>;
|
|
23
|
+
constructor(props: Props);
|
|
24
|
+
onButtonKeyDown: ({ key }: React.KeyboardEvent) => void;
|
|
25
|
+
onHideConfirm: () => void;
|
|
26
|
+
onShowConfirm: (e: React.MouseEvent) => void;
|
|
27
|
+
onConfirmedClick: (e?: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent> | undefined) => void;
|
|
28
|
+
onClick: (e: React.MouseEvent) => void;
|
|
29
|
+
setConfirmAutofocus: (elem?: React.ReactInstance | undefined) => void;
|
|
30
|
+
render(): JSX.Element;
|
|
31
|
+
renderConfirm: () => JSX.Element | null;
|
|
32
|
+
getOverlayTarget: () => Element | Text | null;
|
|
33
|
+
renderConfirmPopup(): JSX.Element;
|
|
34
|
+
browserConfirm(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
+
var t = {};
|
|
23
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
+
t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
+
t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DeleteButton = void 0;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const react_dom_1 = require("react-dom");
|
|
39
|
+
const ReactContext_1 = __importDefault(require("../../ReactContext"));
|
|
40
|
+
const components_1 = require("../components");
|
|
41
|
+
class DeleteButton extends React.Component {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
this.buttonRef = React.createRef();
|
|
45
|
+
this.onButtonKeyDown = ({ key }) => {
|
|
46
|
+
if (key === "Enter")
|
|
47
|
+
this.onConfirmedClick();
|
|
48
|
+
else if (key === "Escape")
|
|
49
|
+
this.setState({ show: false });
|
|
50
|
+
};
|
|
51
|
+
this.onHideConfirm = () => {
|
|
52
|
+
this.setState({ show: false });
|
|
53
|
+
};
|
|
54
|
+
this.onShowConfirm = (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
this.setState({ show: true }, () => {
|
|
58
|
+
if (this.props.confirmStyle === "browser") {
|
|
59
|
+
this.browserConfirm();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this.onConfirmedClick = (e) => {
|
|
64
|
+
e && e.preventDefault();
|
|
65
|
+
e && e.stopPropagation();
|
|
66
|
+
this.props.onClick();
|
|
67
|
+
this.onHideConfirm();
|
|
68
|
+
};
|
|
69
|
+
this.onClick = (e) => {
|
|
70
|
+
this.props.confirm ? this.onShowConfirm(e) : this.onConfirmedClick(e);
|
|
71
|
+
};
|
|
72
|
+
this.setConfirmAutofocus = (elem) => {
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = react_dom_1.findDOMNode(elem)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
this.renderConfirm = () => {
|
|
79
|
+
const { show } = this.state;
|
|
80
|
+
if (!show) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const { confirmStyle = "popup" } = this.props;
|
|
84
|
+
if (confirmStyle === "popup") {
|
|
85
|
+
return this.renderConfirmPopup();
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
};
|
|
89
|
+
this.getOverlayTarget = () => react_dom_1.findDOMNode(this.buttonRef.current);
|
|
90
|
+
this.state = { show: false };
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
const { props } = this;
|
|
94
|
+
const { corner, tooltip, disabled, readonly, glyphButton = true, confirm, confirmPlacement, confirmStyle } = props, maybeProps = __rest(props, ["corner", "tooltip", "disabled", "readonly", "glyphButton", "confirm", "confirmPlacement", "confirmStyle"]); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
95
|
+
let buttonClassName = glyphButton ? "glyph-button" : "";
|
|
96
|
+
buttonClassName += corner ? " button-corner" : "";
|
|
97
|
+
if (props.className) {
|
|
98
|
+
buttonClassName = `${buttonClassName} ${props.className}`;
|
|
99
|
+
}
|
|
100
|
+
if (props.id !== undefined) {
|
|
101
|
+
maybeProps.id = `${props.id}-delete`;
|
|
102
|
+
}
|
|
103
|
+
const button = React.createElement(React.Fragment, null,
|
|
104
|
+
React.createElement(components_1.Button, Object.assign({}, maybeProps, { disabled: disabled || readonly, variant: "danger", className: buttonClassName, style: this.props.style, ref: this.buttonRef, onKeyDown: this.onButtonKeyDown, onClick: this.onClick }),
|
|
105
|
+
this.props.children,
|
|
106
|
+
" ",
|
|
107
|
+
"✖"),
|
|
108
|
+
this.renderConfirm());
|
|
109
|
+
return tooltip ? React.createElement(components_1.TooltipComponent, { tooltip: tooltip }, button) : button;
|
|
110
|
+
}
|
|
111
|
+
renderConfirmPopup() {
|
|
112
|
+
const { translations, confirmPlacement = "left" } = this.props;
|
|
113
|
+
const { Overlay, Popover, ButtonGroup } = this.context.theme;
|
|
114
|
+
return (React.createElement(Overlay, { show: true, placement: confirmPlacement, rootClose: true, onHide: this.onHideConfirm, target: this.getOverlayTarget },
|
|
115
|
+
React.createElement(Popover, { id: `${this.props.id}-button-confirm` },
|
|
116
|
+
React.createElement("span", null, translations.ConfirmRemove),
|
|
117
|
+
React.createElement(ButtonGroup, null,
|
|
118
|
+
React.createElement(components_1.Button, { variant: "danger", onClick: this.onConfirmedClick, ref: this.setConfirmAutofocus, id: `${this.props.id}-delete-confirm-yes` }, translations.Remove),
|
|
119
|
+
React.createElement(components_1.Button, { variant: "default", onClick: this.onHideConfirm, id: `${this.props.id}-delete-confirm-no` }, translations.Cancel)))));
|
|
120
|
+
}
|
|
121
|
+
browserConfirm() {
|
|
122
|
+
const choice = confirm(this.props.translations.ConfirmRemove);
|
|
123
|
+
if (choice) {
|
|
124
|
+
this.onConfirmedClick();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.onHideConfirm();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.DeleteButton = DeleteButton;
|
|
132
|
+
DeleteButton.contextType = ReactContext_1.default;
|