UNPKG

@quillforms/blocklib-multiple-choice-block

Version:
56 lines (55 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _emotion = require("emotion"); var _lodash = require("lodash"); var _jsxRuntime = require("react/jsx-runtime"); const EntryDetails = ({ id, attributes, value }) => { const { choices } = attributes; value = (0, _lodash.castArray)(value); console.log(value); return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: (0, _emotion.css)` display: flex; flex-wrap: wrap; flex-direction: column; align-items: flex-start; `, children: value.map((x, index) => { const choiceIndex = choices.findIndex(a => a.value === x); let choiceLabel; if (choiceIndex === -1) { if (x.type === 'other' && x.value) { choiceLabel = x.value; } else { choiceLabel = null; } } else { choiceLabel = 'Choice ' + (choiceIndex + 1); if (choices[choiceIndex].label) { choiceLabel = choices[choiceIndex].label; } } return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: (0, _emotion.css)` display: inline-flex; margin-bottom: 8px; padding: 5px 8px; border: 1px solid rgb( 184 184 184 ); border-radius: 3px; `, children: choiceLabel }, index); }) }); }; var _default = exports.default = EntryDetails; //# sourceMappingURL=entry-details.js.map