mui-language-picker 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChangeName.js +11 -10
- package/dist/getDisplayName.js +5 -0
- package/package.json +1 -1
package/dist/ChangeName.js
CHANGED
|
@@ -34,29 +34,30 @@ var DialogActions_1 = __importDefault(require("@mui/material/DialogActions"));
|
|
|
34
34
|
var DialogContent_1 = __importDefault(require("@mui/material/DialogContent"));
|
|
35
35
|
var DialogContentText_1 = __importDefault(require("@mui/material/DialogContentText"));
|
|
36
36
|
var DialogTitle_1 = __importDefault(require("@mui/material/DialogTitle"));
|
|
37
|
+
var localization_1 = require("./localization");
|
|
37
38
|
function ChangeName(_a) {
|
|
38
39
|
var isOpen = _a.isOpen, onClose = _a.onClose, curName = _a.curName, onNewName = _a.onNewName, t = _a.t;
|
|
39
40
|
var _b = React.useState(isOpen), open = _b[0], setOpen = _b[1];
|
|
40
41
|
var _c = React.useState(curName || ''), name = _c[0], setName = _c[1];
|
|
41
|
-
var handleClose = function () {
|
|
42
|
-
|
|
42
|
+
var handleClose = function (save) { return function () {
|
|
43
|
+
if (save && name)
|
|
44
|
+
onNewName && onNewName(name);
|
|
43
45
|
onClose && onClose();
|
|
44
46
|
setOpen(false);
|
|
45
|
-
};
|
|
47
|
+
}; };
|
|
46
48
|
var handleNameChange = function (event) {
|
|
47
49
|
setName(event.target.value);
|
|
48
50
|
};
|
|
49
51
|
React.useEffect(function () {
|
|
50
52
|
setOpen(isOpen);
|
|
51
53
|
}, [isOpen]);
|
|
52
|
-
return (React.createElement(Dialog_1.default, { open: open, onClose: handleClose },
|
|
53
|
-
React.createElement(DialogTitle_1.default, null, (t === null || t === void 0 ? void 0 : t.changeName) ||
|
|
54
|
+
return (React.createElement(Dialog_1.default, { open: open, onClose: handleClose() },
|
|
55
|
+
React.createElement(DialogTitle_1.default, null, (t === null || t === void 0 ? void 0 : t.changeName) || localization_1.languagePickerStrings_en.changeName),
|
|
54
56
|
React.createElement(DialogContent_1.default, null,
|
|
55
|
-
React.createElement(DialogContentText_1.default, null, (t === null || t === void 0 ? void 0 : t.nameInstruction) ||
|
|
56
|
-
|
|
57
|
-
React.createElement(TextField_1.default, { autoFocus: true, margin: "dense", id: "name", label: (t === null || t === void 0 ? void 0 : t.newName) || 'New Language Name', fullWidth: true, value: name, onChange: handleNameChange })),
|
|
57
|
+
React.createElement(DialogContentText_1.default, null, (t === null || t === void 0 ? void 0 : t.nameInstruction) || localization_1.languagePickerStrings_en.nameInstruction),
|
|
58
|
+
React.createElement(TextField_1.default, { autoFocus: true, margin: "dense", id: "name", label: (t === null || t === void 0 ? void 0 : t.newName) || localization_1.languagePickerStrings_en.newName, fullWidth: true, value: name, onChange: handleNameChange })),
|
|
58
59
|
React.createElement(DialogActions_1.default, null,
|
|
59
|
-
React.createElement(Button_1.default, { onClick: handleClose }, t === null || t === void 0 ? void 0 : t.cancel),
|
|
60
|
-
React.createElement(Button_1.default, { onClick: handleClose }, (t === null || t === void 0 ? void 0 : t.change) ||
|
|
60
|
+
React.createElement(Button_1.default, { onClick: handleClose() }, (t === null || t === void 0 ? void 0 : t.cancel) || localization_1.languagePickerStrings_en.cancel),
|
|
61
|
+
React.createElement(Button_1.default, { onClick: handleClose(true) }, (t === null || t === void 0 ? void 0 : t.change) || localization_1.languagePickerStrings_en.change))));
|
|
61
62
|
}
|
|
62
63
|
exports.default = ChangeName;
|
package/dist/getDisplayName.js
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDisplayName = void 0;
|
|
4
4
|
var getDisplayName = function (curName, tag, displayName) {
|
|
5
|
+
// If user setup a custom language name
|
|
6
|
+
if (tag && curName !== tag.name)
|
|
7
|
+
return curName;
|
|
8
|
+
// if caller provided a custom name formatter
|
|
5
9
|
if (displayName)
|
|
6
10
|
return displayName(curName, tag);
|
|
11
|
+
// By default show the local name if present and the name
|
|
7
12
|
var tagName = curName;
|
|
8
13
|
if ((tag === null || tag === void 0 ? void 0 : tag.localname) && tag.localname.toLowerCase() !== curName.toLowerCase())
|
|
9
14
|
tagName = "".concat(tag.localname, " / ").concat(curName);
|