@luomus/laji-form 15.1.103 → 15.1.104
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 +10 -0
- package/lib/components/LajiForm.js +1 -33
- package/lib/components/components/ShortcutsPanel.d.ts +17 -0
- package/lib/components/components/ShortcutsPanel.js +94 -0
- package/lib/components/components/index.d.ts +1 -0
- package/lib/components/components/index.js +1 -0
- package/package.json +1 -1
package/dist/styles.css
CHANGED
|
@@ -3231,6 +3231,16 @@ body .laji-form {
|
|
|
3231
3231
|
.laji-form .shortcut-help {
|
|
3232
3232
|
bottom: 5px;
|
|
3233
3233
|
}
|
|
3234
|
+
.laji-form-shortcut-keycombo-container {
|
|
3235
|
+
display: inline-flex;
|
|
3236
|
+
gap: 2px;
|
|
3237
|
+
}
|
|
3238
|
+
.laji-form-shortcut-keycombo-container span {
|
|
3239
|
+
background: #efefef;
|
|
3240
|
+
border: 1px solid #b1b1b3;
|
|
3241
|
+
border-radius: 2px;
|
|
3242
|
+
padding: 0px 3px;
|
|
3243
|
+
}
|
|
3234
3244
|
.laji-form .hidden {
|
|
3235
3245
|
display: none;
|
|
3236
3246
|
}
|
|
@@ -32,17 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
-
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
37
|
};
|
|
@@ -509,10 +498,6 @@ class LajiForm extends React.Component {
|
|
|
509
498
|
const uiSchema = Object.assign(Object.assign({}, this.props.uiSchema), { "ui:submitButtonOptions": {
|
|
510
499
|
norender: true
|
|
511
500
|
} });
|
|
512
|
-
const { Panel, Table } = this.getContext(this.props, this.context).theme;
|
|
513
|
-
const panelHeader = (React.createElement("h3", null,
|
|
514
|
-
translations.Shortcuts,
|
|
515
|
-
React.createElement("button", { type: "button", className: "close pull-right", onClick: this.dismissHelp }, "\u00D7")));
|
|
516
501
|
return (React.createElement(ReactContext_1.default.Provider, { value: this.getContext(this.props, this.context) },
|
|
517
502
|
React.createElement("div", { className: "laji-form" },
|
|
518
503
|
showShortcutsButton && this.props.showShortcutButton !== false && shortcuts && (React.createElement(components_1.TooltipComponent, { tooltip: this.getShorcutButtonTooltip() },
|
|
@@ -521,24 +506,7 @@ class LajiForm extends React.Component {
|
|
|
521
506
|
React.createElement(core_1.default, Object.assign({}, this.props, { formData: this.state.formData, uiSchema: uiSchema, ref: this.formRef, onChange: this.onChange, onSubmit: this.onSubmit, fields: this.getFields(this.props.fields), widgets: this.getWidgets(this.props.widgets), templates: this.getTemplates(this.props.templates), formContext: this.state.formContext, validator: validator_ajv6_1.default, noValidate: true, extraErrors: this.state.extraErrors || {}, noHtml5Validate: true, liveValidate: true, autoComplete: "off", tagName: "div", readonly: readonly, disabled: disabled }), this.props.children),
|
|
522
507
|
(!this.props.children && this.props.renderSubmit !== false) ? (React.createElement(components_1.Button, { id: "submit", onClick: this.submit, disabled: readonly || disabled }, this.props.submitText || translations.Submit)) : null,
|
|
523
508
|
shortcuts &&
|
|
524
|
-
React.createElement(
|
|
525
|
-
React.createElement(Panel.Heading, null, panelHeader),
|
|
526
|
-
React.createElement(Table, null,
|
|
527
|
-
React.createElement("tbody", { className: "well" }, Object.keys(shortcuts).map((keyCombo, idx) => {
|
|
528
|
-
const _a = shortcuts[keyCombo], { fn, targetLabel, label } = _a, rest = __rest(_a, ["fn", "targetLabel", "label"]);
|
|
529
|
-
if (["help", "autosuggestToggle"].includes(fn) || fn === "navigateSection" && rest.goOverRow)
|
|
530
|
-
return;
|
|
531
|
-
let translation = "";
|
|
532
|
-
if (translation)
|
|
533
|
-
translation = label;
|
|
534
|
-
else
|
|
535
|
-
translation = translations[[fn, ...Object.keys(rest)].map(utils_1.capitalizeFirstLetter).join("")];
|
|
536
|
-
if (targetLabel)
|
|
537
|
-
translation = `${translation} ${targetLabel}`;
|
|
538
|
-
return (React.createElement("tr", { key: idx },
|
|
539
|
-
React.createElement("td", null, (0, utils_1.stringifyKeyCombo)(keyCombo)),
|
|
540
|
-
React.createElement("td", null, translation)));
|
|
541
|
-
})))),
|
|
509
|
+
React.createElement(components_1.ShortcutsPanel, { ref: this.shortcutHelpRef, shortcuts: shortcuts, formContext: this.state.formContext, onClose: this.dismissHelp }),
|
|
542
510
|
this.renderSubmitHooks())));
|
|
543
511
|
}
|
|
544
512
|
getSettings() {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { FormContext } from "../LajiForm";
|
|
3
|
+
type Action = {
|
|
4
|
+
fn: string;
|
|
5
|
+
targetLabel: string;
|
|
6
|
+
label: string;
|
|
7
|
+
goOverRow?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Props = {
|
|
10
|
+
formContext: FormContext;
|
|
11
|
+
onClose: (e: Event | React.SyntheticEvent) => void;
|
|
12
|
+
shortcuts: {
|
|
13
|
+
[keyCombo: string]: Action;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const ShortcutsPanel: React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
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
|
+
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.ShortcutsPanel = void 0;
|
|
51
|
+
const React = __importStar(require("react"));
|
|
52
|
+
const utils_1 = require("../../utils");
|
|
53
|
+
const ReactContext_1 = __importDefault(require("../../ReactContext"));
|
|
54
|
+
const hash = (action) => JSON.stringify(action);
|
|
55
|
+
exports.ShortcutsPanel = React.forwardRef(({ formContext, onClose, shortcuts }, ref) => {
|
|
56
|
+
const { translations, topOffset = 0, bottomOffset = 0 } = formContext;
|
|
57
|
+
const { Panel, Table } = React.useContext(ReactContext_1.default).theme;
|
|
58
|
+
const actionsToShortcuts = Object.keys(shortcuts).reduce((actionsToShortcuts, keyCombo) => {
|
|
59
|
+
const action = shortcuts[keyCombo];
|
|
60
|
+
const hashedAction = hash(action);
|
|
61
|
+
const existing = actionsToShortcuts.find(item => hash(item.action) === hashedAction);
|
|
62
|
+
if (existing) {
|
|
63
|
+
existing.keyCombos.push(keyCombo);
|
|
64
|
+
}
|
|
65
|
+
actionsToShortcuts.push({ action, keyCombos: [keyCombo] });
|
|
66
|
+
return actionsToShortcuts;
|
|
67
|
+
}, []);
|
|
68
|
+
return (React.createElement(Panel, { ref: ref, className: "shortcut-help laji-form-popped z-depth-3 hidden", style: { top: topOffset + 5, bottom: bottomOffset + 5 }, variant: "info" },
|
|
69
|
+
React.createElement(Panel.Heading, null,
|
|
70
|
+
React.createElement("h3", null,
|
|
71
|
+
translations.Shortcuts,
|
|
72
|
+
React.createElement("button", { type: "button", className: "close pull-right", onClick: onClose }, "\u00D7"))),
|
|
73
|
+
React.createElement(Table, null,
|
|
74
|
+
React.createElement("tbody", { className: "well" }, actionsToShortcuts.map((props, i) => React.createElement(ShortcutVisualization, Object.assign({}, props, { key: i, translations: translations })))))));
|
|
75
|
+
});
|
|
76
|
+
const ShortcutVisualization = ({ action, keyCombos, translations }) => {
|
|
77
|
+
const { fn, targetLabel, label } = action, rest = __rest(action, ["fn", "targetLabel", "label"]);
|
|
78
|
+
if (["help", "autosuggestToggle"].includes(fn) || fn === "navigateSection" && rest.goOverRow) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
let translation = "";
|
|
82
|
+
if (translation) {
|
|
83
|
+
translation = label;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
translation = translations[[fn, ...Object.keys(rest)].map(utils_1.capitalizeFirstLetter).join("")];
|
|
87
|
+
}
|
|
88
|
+
if (targetLabel) {
|
|
89
|
+
translation = `${translation} ${targetLabel}`;
|
|
90
|
+
}
|
|
91
|
+
return (React.createElement("tr", null,
|
|
92
|
+
React.createElement("td", { className: "laji-form-shortcut-keycombo-container" }, keyCombos.map(keyCombo => React.createElement("span", null, (0, utils_1.stringifyKeyCombo)(keyCombo)))),
|
|
93
|
+
React.createElement("td", null, translation)));
|
|
94
|
+
};
|
|
@@ -27,3 +27,4 @@ __exportStar(require("./FetcherInput"), exports);
|
|
|
27
27
|
__exportStar(require("./OverlayTrigger"), exports);
|
|
28
28
|
__exportStar(require("./Fullscreen"), exports);
|
|
29
29
|
__exportStar(require("./FailedBackgroundJobsPanel"), exports);
|
|
30
|
+
__exportStar(require("./ShortcutsPanel"), exports);
|