UNPKG

@quillforms/blocklib-multiple-choice-block

Version:
157 lines (154 loc) 5.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _adminComponents = require("@quillforms/admin-components"); var _react = require("react"); var _i18n = require("@wordpress/i18n"); var _jsxRuntime = require("react/jsx-runtime"); /** * QuillForms Dependencies */ /** * WordPress Dependencies */ const multipleChoiceControls = props => { const { attributes: { multiple, verticalAlign, choices, min, max, other }, setAttributes } = props; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.BaseControl, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Multiple", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ToggleControl, { checked: multiple, onChange: () => setAttributes({ multiple: !multiple }) })] }) }), multiple && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.BaseControl, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Minimum limit for choices", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ToggleControl, { checked: min, onChange: () => { setAttributes({ min: min === false ? 1 : false }); } })] }), min !== false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.TextControl, { type: "number", value: min, onChange: val => { setAttributes({ min: val }); } })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.BaseControl, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Maximum limit for choices", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ToggleControl, { checked: max, onChange: () => { setAttributes({ max: max === false ? 5 : false }); } })] }), max !== false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.TextControl, { type: "number", value: max, onChange: val => { setAttributes({ max: val }); } })] })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.BaseControl, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Vertical Align", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ToggleControl, { checked: verticalAlign, onChange: () => setAttributes({ verticalAlign: !verticalAlign }) })] }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.BaseControl, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Other Option", "quillforms"), isNew: true }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ToggleControl, { checked: other, onChange: () => setAttributes({ other: !other }) })] }) }), other && /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.BaseControl, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "vertical", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Other Text", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.TextControl, { value: otherText, onChange: val => { setAttributes({ otherText: val }); } })] }) }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.BaseControl, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_adminComponents.ControlWrapper, { orientation: "horizontal", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlLabel, { label: (0, _i18n.__)("Choices", "quillforms") }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ChoicesBulkBtn, { choices: choices, setChoices: val => { setAttributes({ choices: val }); } })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ControlWrapper, { orientation: "vertical", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_adminComponents.ChoicesInserter, { choices: choices, setChoices: val => { setAttributes({ choices: val }); } }) })] })] }); }; var _default = exports.default = multipleChoiceControls; //# sourceMappingURL=controls.js.map