UNPKG

modaq

Version:

Quiz Bowl Reader using TypeScript, React, and MobX

62 lines 3.9 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenameTeamDialog = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const React = __importStar(require("react")); const mobx_react_lite_1 = require("mobx-react-lite"); const react_1 = require("@fluentui/react"); const RenameTeamDialogController = __importStar(require("./RenameTeamDialogController")); require("../../state/AppState"); const StateContext_1 = require("../../contexts/StateContext"); require("../../state/RenameTeamDialogState"); const ModalVisibilityStatus_1 = require("../../state/ModalVisibilityStatus"); const ModalDialog_1 = require("./ModalDialog"); exports.RenameTeamDialog = mobx_react_lite_1.observer(function RenameTeamDialog() { return (jsx_runtime_1.jsxs(ModalDialog_1.ModalDialog, Object.assign({ title: "Rename Team", visibilityStatus: ModalVisibilityStatus_1.ModalVisibilityStatus.RenameTeam, onDismiss: RenameTeamDialogController.hideDialog }, { children: [jsx_runtime_1.jsx(RenameTeamDialogBody, {}, void 0), jsx_runtime_1.jsxs(react_1.DialogFooter, { children: [jsx_runtime_1.jsx(react_1.PrimaryButton, { text: "OK", onClick: RenameTeamDialogController.renameTeam }, void 0), jsx_runtime_1.jsx(react_1.DefaultButton, { text: "Cancel", onClick: RenameTeamDialogController.hideDialog }, void 0)] }, void 0)] }), void 0)); }); const RenameTeamDialogBody = mobx_react_lite_1.observer(function RenameTeamDialogBody() { const appState = React.useContext(StateContext_1.StateContext); const teamChangeHandler = React.useCallback((ev, option) => { if ((option === null || option === void 0 ? void 0 : option.text) != undefined) { RenameTeamDialogController.changeTeam(option.text); } }, []); const renameTeamDialog = appState.uiState.dialogState.renameTeamDialog; if (renameTeamDialog === undefined) { return jsx_runtime_1.jsx(jsx_runtime_1.Fragment, {}, void 0); } const teamOptions = appState.game.teamNames.map((teamName, index) => { return { key: index, text: teamName, selected: renameTeamDialog.teamName === teamName, }; }); return (jsx_runtime_1.jsxs(react_1.Stack, { children: [jsx_runtime_1.jsx(react_1.StackItem, { children: jsx_runtime_1.jsx(react_1.Dropdown, { label: "Team", options: teamOptions, onChange: teamChangeHandler }, void 0) }, void 0), jsx_runtime_1.jsx(react_1.StackItem, { children: jsx_runtime_1.jsx(react_1.TextField, { autoFocus: true, label: "Name", value: renameTeamDialog.newName, required: true, onChange: onNameChange, onGetErrorMessage: RenameTeamDialogController.validate, validateOnFocusOut: true, validateOnLoad: false }, void 0) }, void 0)] }, void 0)); }); function onNameChange(ev, newValue) { RenameTeamDialogController.changeNewName(newValue !== null && newValue !== void 0 ? newValue : ""); } //# sourceMappingURL=RenameTeamDialog.js.map