oolib 2.175.3 → 2.176.0
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/components/RadioAndCheckbox/styled.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +40 -8
- package/dist/stories/v2/components/BarChart.stories.d.ts +11 -0
- package/dist/stories/v2/components/BarChart.stories.js +14 -47
- package/dist/stories/v2/components/Checkbox.stories.d.ts +254 -0
- package/dist/stories/v2/components/Checkbox.stories.js +254 -0
- package/dist/stories/v2/components/RadioButton.stories.d.ts +260 -0
- package/dist/stories/v2/components/RadioButton.stories.js +268 -0
- package/dist/v2/components/BarChart/comps/CustomTooltip/index.d.ts +4 -0
- package/dist/v2/components/BarChart/comps/CustomTooltip/index.js +25 -25
- package/dist/v2/components/BarChart/index.js +12 -1
- package/dist/v2/components/Buttons/styled.js +28 -29
- package/dist/v2/components/HomeCover/comps/ImageSwitcher/styled.js +2 -2
- package/dist/v2/components/HomeCover/comps/WrapperContentSection/styled.js +2 -2
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/index.d.ts +12 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/index.js +38 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/styled.d.ts +1 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/styled.js +73 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxInput/index.d.ts +11 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxInput/index.js +48 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/index.d.ts +20 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/index.js +124 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/styled.d.ts +2 -0
- package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/styled.js +17 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/index.d.ts +18 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/index.js +53 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/styled.d.ts +1 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/styled.js +105 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/index.d.ts +1 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/index.js +6 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/index.d.ts +17 -0
- package/dist/v2/components/RadioAndCheckbox/comps/RadioList/index.js +109 -0
- package/dist/v2/components/RadioAndCheckbox/index.d.ts +5 -0
- package/dist/v2/components/RadioAndCheckbox/index.js +14 -0
- package/dist/v2/components/RadioAndCheckbox/styled.d.ts +5 -0
- package/dist/v2/components/RadioAndCheckbox/styled.js +93 -0
- package/dist/v2/components/RadioAndCheckbox/utils.d.ts +22 -0
- package/dist/v2/components/RadioAndCheckbox/utils.js +49 -0
- package/dist/v2/components/Switches/styled.js +6 -6
- package/dist/v2/components/TabBar/index.styled.js +6 -6
- package/dist/v2/components/Tags/Comps/TagLink/styled.js +3 -3
- package/dist/v2/themes/utils/baseStyling.d.ts +5 -0
- package/dist/v2/themes/utils/baseStyling.js +17 -0
- package/dist/v2/themes/{utils.d.ts → utils/getDynamicColors.d.ts} +1 -1
- package/dist/v2/themes/{utils.js → utils/getDynamicColors.js} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.StyledCheckbox = void 0;
|
|
41
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
42
|
+
var themes_1 = require("../../../../../../themes");
|
|
43
|
+
var mixins_1 = require("../../../../../../../themes/mixins");
|
|
44
|
+
var getDynamicColors_1 = require("../../../../../../themes/utils/getDynamicColors");
|
|
45
|
+
var baseStyling_1 = require("../../../../../../themes/utils/baseStyling");
|
|
46
|
+
var grey20 = themes_1.colors.grey20, grey5 = themes_1.colors.grey5, grey10 = themes_1.colors.grey10, grey50 = themes_1.colors.grey50;
|
|
47
|
+
exports.StyledCheckbox = styled_components_1.default.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n \n width: 2.4rem;\n height: 2.4rem;\n ", "{\n width: 1.8rem;\n height: 1.8rem;\n }\n border-radius: 4px;\n border: ", ";\n background-color: ", ";\n cursor: ", ";\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n\n &:hover {\n ", "\n }\n"], ["\n \n width: 2.4rem;\n height: 2.4rem;\n ", "{\n width: 1.8rem;\n height: 1.8rem;\n }\n border-radius: 4px;\n border: ", ";\n background-color: ", ";\n cursor: ", ";\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n\n &:hover {\n ", "\n }\n"])), (0, mixins_1.mediaQuery)('md'), function (_a) {
|
|
48
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
49
|
+
if (isSelected && disabled) {
|
|
50
|
+
return "1px solid ".concat(grey20);
|
|
51
|
+
}
|
|
52
|
+
if (!isSelected) {
|
|
53
|
+
return "1px solid ".concat(disabled ? grey10 : grey20);
|
|
54
|
+
}
|
|
55
|
+
return "none";
|
|
56
|
+
}, function (_a) {
|
|
57
|
+
var isSelected = _a.isSelected, disabled = _a.disabled, colors = _a.theme.colors;
|
|
58
|
+
if (isSelected) {
|
|
59
|
+
return disabled ? grey5 : (0, getDynamicColors_1.getSecondaryContainer)(colors);
|
|
60
|
+
}
|
|
61
|
+
return disabled ? grey5 : "white";
|
|
62
|
+
}, function (_a) {
|
|
63
|
+
var disabled = _a.disabled;
|
|
64
|
+
return (disabled ? "not-allowed" : "pointer");
|
|
65
|
+
}, function (_a) {
|
|
66
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
67
|
+
return isSelected && !disabled && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", " \n "], ["\n ", " \n "])), (0, baseStyling_1.apply10PercentBlackOnHover)());
|
|
68
|
+
}, function (_a) {
|
|
69
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
70
|
+
return !disabled &&
|
|
71
|
+
!isSelected && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border: 1px solid ", ";\n "], ["\n border: 1px solid ", ";\n "])), grey50);
|
|
72
|
+
});
|
|
73
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function CheckboxInput({ option, onClick, S, inputStyle, value, invert, disabled, rightWrongResult, }: {
|
|
2
|
+
option: any;
|
|
3
|
+
onClick: any;
|
|
4
|
+
S: any;
|
|
5
|
+
inputStyle: any;
|
|
6
|
+
value?: any[];
|
|
7
|
+
invert: any;
|
|
8
|
+
disabled: any;
|
|
9
|
+
rightWrongResult: any;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
import React from "react";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CheckboxInput = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var icons_1 = require("../../../../../../../icons");
|
|
9
|
+
var themes_1 = require("../../../../../../themes");
|
|
10
|
+
var Tags_1 = require("../../../../../Tags");
|
|
11
|
+
var Typo2_1 = require("../../../../../Typo2");
|
|
12
|
+
var styled_1 = require("../../../../styled");
|
|
13
|
+
var utils_1 = require("../../../../utils");
|
|
14
|
+
var CheckboxButton_1 = require("../CheckboxButton");
|
|
15
|
+
var TextLoader_1 = require("../../../../../../../components/LoadersAndProgress/TextLoader");
|
|
16
|
+
var CheckSquare = icons_1.icons.CheckSquare, XSquare = icons_1.icons.XSquare;
|
|
17
|
+
var red = themes_1.colors.red, grey40 = themes_1.colors.grey40, grey80 = themes_1.colors.grey80, onSecondary = themes_1.colors.onSecondary, invertGreen = themes_1.colors.invertGreen, green = themes_1.colors.green, invertRed = themes_1.colors.invertRed;
|
|
18
|
+
var CheckboxInput = function (_a) {
|
|
19
|
+
var option = _a.option, onClick = _a.onClick, S = _a.S, inputStyle = _a.inputStyle, _b = _a.value, value = _b === void 0 ? [] : _b, invert = _a.invert, disabled = _a.disabled, rightWrongResult = _a.rightWrongResult;
|
|
20
|
+
var isSelected = !!value.find(function (selOp) { return selOp.value === option.value; });
|
|
21
|
+
var markingCommand = (0, utils_1.getMarkingCommand)({ option: option, isSelected: isSelected }); // returns undefined if option isn't labeled as 'correct' nor selected
|
|
22
|
+
var genCheckboxButton = function (options) {
|
|
23
|
+
if (options === void 0) { options = {}; }
|
|
24
|
+
return (react_1.default.createElement(CheckboxButton_1.CheckboxButton, { isSelected: isSelected, disabled: disabled, invert: invert, S: S, className: "checkboxButton_inside_checkboxInput", disabled: disabled }));
|
|
25
|
+
};
|
|
26
|
+
var genCheckSquare = function () { return (react_1.default.createElement("div", { style: { flexShrink: 0 } },
|
|
27
|
+
react_1.default.createElement(CheckSquare, { size: S ? 22.5 : 26, color: disabled ? grey40 : onSecondary, style: {
|
|
28
|
+
margin: "-7px -2.8px -7px -3.2px",
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
} }))); };
|
|
31
|
+
var genXSquare = function () { return (react_1.default.createElement(XSquare, { size: S ? 21.5 : 26, color: invert ? invertRed : red, style: {
|
|
32
|
+
margin: "-7px -2.8px -7px -3.2px",
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
} })); };
|
|
35
|
+
return option.loading ? (react_1.default.createElement(TextLoader_1.TextLoader, { style: { width: "8rem", height: "1.5rem" } })) : inputStyle === "tagSelect" ? (react_1.default.createElement(Tags_1.TagSelect, { isSelected: isSelected, invert: invert, disabled: disabled, onClick: function () { return !disabled && onClick(isSelected, option); }, display: option.display, value: option.value, style: { alignSelf: "flex-start" } })) : (react_1.default.createElement(styled_1.StyledOption, { rightWrongResult: rightWrongResult, isSelected: isSelected, disabled: disabled, invert: invert, S: S, onClick: function () {
|
|
36
|
+
return !rightWrongResult && !disabled && onClick && onClick(isSelected, option);
|
|
37
|
+
} },
|
|
38
|
+
react_1.default.createElement("div", { style: { flexShrink: 0 } }, rightWrongResult
|
|
39
|
+
? ["markCorrect", "revealCorrect"].includes(markingCommand)
|
|
40
|
+
? genCheckSquare()
|
|
41
|
+
: markingCommand === "markWrong"
|
|
42
|
+
? genXSquare()
|
|
43
|
+
: genCheckboxButton({ disabled: true }) //else rightWrongResult has come in, but this doesnt have to be marked right or wrong
|
|
44
|
+
: genCheckboxButton() // rightWrongResult has not come in. so gen normal radio button
|
|
45
|
+
),
|
|
46
|
+
react_1.default.createElement(Typo2_1.UI_BODY_SM_DF, { bold: rightWrongResult && isSelected, color: disabled ? grey40 : grey80, invert: invert }, option.display)));
|
|
47
|
+
};
|
|
48
|
+
exports.CheckboxInput = CheckboxInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function CheckboxList({ id, injectOtherOption, value: valueProp, onChange, commonIsCorrectDesc, options, saveValueAsString, inputStyle, rightWrongResult, listType, invert, optionsLimit, style, disabled, className, S, readOnly }: {
|
|
2
|
+
id: any;
|
|
3
|
+
injectOtherOption?: boolean;
|
|
4
|
+
value?: any[];
|
|
5
|
+
onChange: any;
|
|
6
|
+
commonIsCorrectDesc: any;
|
|
7
|
+
options?: any[];
|
|
8
|
+
saveValueAsString: any;
|
|
9
|
+
inputStyle?: string;
|
|
10
|
+
rightWrongResult: any;
|
|
11
|
+
listType?: string;
|
|
12
|
+
invert: any;
|
|
13
|
+
optionsLimit?: number;
|
|
14
|
+
style: any;
|
|
15
|
+
disabled: any;
|
|
16
|
+
className: any;
|
|
17
|
+
S: any;
|
|
18
|
+
readOnly: any;
|
|
19
|
+
}, ...args: any[]): React.JSX.Element;
|
|
20
|
+
import React from "react";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.CheckboxList = CheckboxList;
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
49
|
+
var BlockLabel_1 = require("../../../BlockLabel");
|
|
50
|
+
var TextInputs_1 = require("../../../TextInputs");
|
|
51
|
+
var Buttons_1 = require("../../../Buttons");
|
|
52
|
+
var _EXPORTS_1 = require("../../../../../utils/_EXPORTS");
|
|
53
|
+
var utils_1 = require("../../utils");
|
|
54
|
+
var styled_1 = require("../../styled");
|
|
55
|
+
var CheckboxInput_1 = require("./comps/CheckboxInput");
|
|
56
|
+
var styled_2 = require("./styled");
|
|
57
|
+
var Typo2_1 = require("../../../Typo2");
|
|
58
|
+
var OKELink_1 = require("../../../OKELink");
|
|
59
|
+
var Tags_1 = require("../../../../../components/Tags");
|
|
60
|
+
var optionsContainers = {
|
|
61
|
+
checkbox: styled_1.StyledOptionsContainer,
|
|
62
|
+
tagSelect: styled_2.StyledTagOptionsContainer,
|
|
63
|
+
};
|
|
64
|
+
var convToString = function (value) { return value.map(function (v) { var _a; return (_a = v.display_desc) !== null && _a !== void 0 ? _a : v.value; }); };
|
|
65
|
+
function CheckboxList(_a) {
|
|
66
|
+
var id = _a.id, _b = _a.injectOtherOption, injectOtherOption = _b === void 0 ? false : _b, _c = _a.value, valueProp = _c === void 0 ? [] : _c, onChange = _a.onChange, commonIsCorrectDesc = _a.commonIsCorrectDesc, _d = _a.options, options = _d === void 0 ? [] : _d, saveValueAsString = _a.saveValueAsString, _e = _a.inputStyle, inputStyle = _e === void 0 ? 'checkbox' : _e, rightWrongResult = _a.rightWrongResult, _f = _a.listType, listType = _f === void 0 ? 'horizontal' : _f, invert = _a.invert, _g = _a.optionsLimit, optionsLimit = _g === void 0 ? Infinity : _g, style = _a.style, disabled = _a.disabled, className = _a.className, S = _a.S, readOnly = _a.readOnly;
|
|
67
|
+
var props = arguments[0];
|
|
68
|
+
var shouldHideSomeOptions = options.length > optionsLimit;
|
|
69
|
+
var _h = (0, react_1.useState)(false), seeMore = _h[0], setSeeMore = _h[1];
|
|
70
|
+
var _j = (0, utils_1.genDisplayedOptions)({ injectOtherOption: injectOtherOption, options: options, valueProp: valueProp, saveValueAsString: saveValueAsString }), typicalOptions = _j.typicalOptions, injectedOtherOption = _j.injectedOtherOption;
|
|
71
|
+
var value = saveValueAsString ?
|
|
72
|
+
typicalOptions
|
|
73
|
+
.concat(injectedOtherOption || [])
|
|
74
|
+
.filter(function (op) { var _a; return valueProp.includes((_a = op.display_desc) !== null && _a !== void 0 ? _a : op.value); })
|
|
75
|
+
: valueProp;
|
|
76
|
+
var handleTextInputChange = function (text) {
|
|
77
|
+
var newValue = value.map(function (selectedOp) { return (selectedOp.value === 'other' ? (0, utils_1.genOtherValueObject)(text) : selectedOp); });
|
|
78
|
+
if (saveValueAsString)
|
|
79
|
+
newValue = convToString(newValue);
|
|
80
|
+
onChange && onChange(id, newValue);
|
|
81
|
+
};
|
|
82
|
+
var handleCheckboxClick = function (isSelected, option) {
|
|
83
|
+
var newValue = isSelected
|
|
84
|
+
? value.filter(function (selOp) { return selOp.value !== option.value; })
|
|
85
|
+
: value.concat(option);
|
|
86
|
+
if (saveValueAsString)
|
|
87
|
+
newValue = convToString(newValue);
|
|
88
|
+
onChange(id, newValue);
|
|
89
|
+
};
|
|
90
|
+
var otherOpInSelectees = value.find(function (selectedOp) { return selectedOp.value === 'other'; });
|
|
91
|
+
var InputCommonProps = {
|
|
92
|
+
invert: invert,
|
|
93
|
+
value: value,
|
|
94
|
+
S: S,
|
|
95
|
+
disabled: disabled,
|
|
96
|
+
inputStyle: inputStyle,
|
|
97
|
+
rightWrongResult: rightWrongResult,
|
|
98
|
+
onClick: handleCheckboxClick,
|
|
99
|
+
};
|
|
100
|
+
var OptionsContainer = optionsContainers[inputStyle];
|
|
101
|
+
return (react_1.default.createElement("div", { className: className, id: id },
|
|
102
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, _EXPORTS_1.getBlockLabelProps)(props))),
|
|
103
|
+
readOnly ? (react_1.default.createElement(styled_2.StyledDisplayTagsContainer, null, value === null || value === void 0 ? void 0 : value.map(function (selOp) { return react_1.default.createElement(Tags_1.TagDisplay, { key: selOp.value, invert: invert, display: selOp.display_desc || selOp.display }); }))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
104
|
+
react_1.default.createElement(OptionsContainer, { style: style, listType: listType, S: S }, typicalOptions === null || typicalOptions === void 0 ? void 0 :
|
|
105
|
+
typicalOptions.map(function (option, idx) { return idx < optionsLimit && (react_1.default.createElement(CheckboxInput_1.CheckboxInput, __assign({}, InputCommonProps, { option: option, key: option.value }))); }),
|
|
106
|
+
shouldHideSomeOptions && // if we have the case of off limit options
|
|
107
|
+
(seeMore || rightWrongResult) && //and decided to show them
|
|
108
|
+
typicalOptions.slice(optionsLimit).map(function (option) {
|
|
109
|
+
return react_1.default.createElement(CheckboxInput_1.CheckboxInput, __assign({}, InputCommonProps, { option: option, key: option.value }));
|
|
110
|
+
}),
|
|
111
|
+
injectOtherOption && injectedOtherOption && ( //so other box and its textInput act as one entity in the flexbox
|
|
112
|
+
react_1.default.createElement(styled_1.StyledOtherOptionContainer, { listType: listType },
|
|
113
|
+
react_1.default.createElement(CheckboxInput_1.CheckboxInput, __assign({}, InputCommonProps, { option: injectedOtherOption })),
|
|
114
|
+
otherOpInSelectees && (react_1.default.createElement(styled_1.StyledOtherTextInputWrapper, { listType: listType, rightWrongResult: rightWrongResult },
|
|
115
|
+
react_1.default.createElement(TextInputs_1.TextInput, { placeholder: "Please Specify Here", value: otherOpInSelectees.display_desc, onChange: function (k, v) { return handleTextInputChange(v); }, disabled: disabled, invert: invert, S: S })))))),
|
|
116
|
+
shouldHideSomeOptions && !rightWrongResult && (react_1.default.createElement(Typo2_1.UI_BODY_BOLD, { style: { marginTop: '1rem' } },
|
|
117
|
+
react_1.default.createElement(OKELink_1.OKELink, { onClick: function () { return setSeeMore(!seeMore); }, children: !seeMore ? 'See More' : 'See Less' }))), /*
|
|
118
|
+
the minute the results have come in, irrespective of user's answers
|
|
119
|
+
being right or wrong, we show an explanation
|
|
120
|
+
below the options. provided that an explanation is provided.
|
|
121
|
+
*/
|
|
122
|
+
rightWrongResult && commonIsCorrectDesc &&
|
|
123
|
+
react_1.default.createElement(styled_1.StyledCorrectMessage, { invert: invert }, commonIsCorrectDesc)))));
|
|
124
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StyledTagOptionsContainer = exports.StyledDisplayTagsContainer = void 0;
|
|
11
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
exports.StyledDisplayTagsContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n"])));
|
|
13
|
+
exports.StyledTagOptionsContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n gap: 1rem;\n"], ["\n display: flex;\n flex-wrap: wrap;\n flex-direction: ", ";\n gap: 1rem;\n"])), function (_a) {
|
|
14
|
+
var listType = _a.listType;
|
|
15
|
+
return listType === 'vertical' ? 'column' : 'row';
|
|
16
|
+
});
|
|
17
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function RadioButton({ isSelected, onClick, disabled, invert, S, readOnly }: {
|
|
2
|
+
isSelected: any;
|
|
3
|
+
onClick: any;
|
|
4
|
+
disabled: any;
|
|
5
|
+
invert: any;
|
|
6
|
+
S: any;
|
|
7
|
+
readOnly: any;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export function RadioInput({ option, onClick, disabled, invert, value, S, rightWrongResult, }: {
|
|
10
|
+
option: any;
|
|
11
|
+
onClick: any;
|
|
12
|
+
disabled: any;
|
|
13
|
+
invert: any;
|
|
14
|
+
value: any;
|
|
15
|
+
S: any;
|
|
16
|
+
rightWrongResult: any;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
import React from "react";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RadioInput = exports.RadioButton = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var themes_1 = require("../../../../../../themes");
|
|
9
|
+
var icons_1 = require("../../../../../../../icons");
|
|
10
|
+
var Typo_1 = require("../../../../../../../components/Typo");
|
|
11
|
+
var utils_1 = require("../../../../utils");
|
|
12
|
+
var styled_1 = require("../../../../styled");
|
|
13
|
+
var styled_2 = require("./styled");
|
|
14
|
+
var invertGreen = themes_1.colors.invertGreen, red = themes_1.colors.red, greyColor40 = themes_1.colors.greyColor40, green = themes_1.colors.green, invertRed = themes_1.colors.invertRed;
|
|
15
|
+
var XCircle = icons_1.icons.XCircle, CheckCircle = icons_1.icons.CheckCircle;
|
|
16
|
+
var RadioButton = function (_a) {
|
|
17
|
+
var isSelected = _a.isSelected, onClick = _a.onClick, disabled = _a.disabled, invert = _a.invert, S = _a.S, readOnly = _a.readOnly;
|
|
18
|
+
return (react_1.default.createElement(styled_2.StyledRadioInput, { onClick: function (ev) { return onClick && onClick(ev); }, isSelected: isSelected, disabled: disabled, invert: invert, S: S, readOnly: readOnly }));
|
|
19
|
+
};
|
|
20
|
+
exports.RadioButton = RadioButton;
|
|
21
|
+
var RadioInput = function (_a) {
|
|
22
|
+
var option = _a.option, onClick = _a.onClick, disabled = _a.disabled, invert = _a.invert, value = _a.value, S = _a.S, rightWrongResult = _a.rightWrongResult;
|
|
23
|
+
var isSelected = option.value === (value === null || value === void 0 ? void 0 : value.value);
|
|
24
|
+
var markingCommand = (0, utils_1.getMarkingCommand)({ option: option, isSelected: isSelected }); // returns undefined if option isn't labeled as 'correct' nor selected
|
|
25
|
+
var TYPO_COMP = S
|
|
26
|
+
? Typo_1.SANS_2
|
|
27
|
+
: Typo_1.SANS_3;
|
|
28
|
+
var genRadioButton = function (options) {
|
|
29
|
+
if (options === void 0) { options = {}; }
|
|
30
|
+
return (react_1.default.createElement(exports.RadioButton, { isSelected: isSelected, invert: invert, S: S, className: 'btn',
|
|
31
|
+
disabled: options.disabled || disabled //because we force disabled if rightWrongResult exists & no markingCommand exists against this option i.e, it neither has to be marked right nor wrong
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
var genCheckCircle = function () { return (react_1.default.createElement(CheckCircle, { size: S ? 21 : 24.5, color: invert ? invertGreen : green, style: {
|
|
35
|
+
margin: '-5px -1.5px -5px -3px',
|
|
36
|
+
flexShrink: 0
|
|
37
|
+
} })); };
|
|
38
|
+
var genXCircle = function () { return (react_1.default.createElement(XCircle, { size: S ? 21 : 24.5, color: invert ? invertRed : red, style: {
|
|
39
|
+
margin: '-5px -1.5px -5px -3px',
|
|
40
|
+
flexShrink: 0
|
|
41
|
+
} })); };
|
|
42
|
+
return (react_1.default.createElement(styled_1.StyledOption, { disabled: disabled, rightWrongResult: rightWrongResult, isSelected: isSelected, invert: invert, S: S, onClick: function () { return !rightWrongResult && !disabled && onClick(option); } },
|
|
43
|
+
rightWrongResult
|
|
44
|
+
? ["markCorrect", "revealCorrect"].includes(markingCommand)
|
|
45
|
+
? genCheckCircle()
|
|
46
|
+
: markingCommand === 'markWrong'
|
|
47
|
+
? genXCircle()
|
|
48
|
+
: genRadioButton({ disabled: true }) //else rightWrongResult has come in, but this doesnt have to be marked right or wrong
|
|
49
|
+
: genRadioButton() // rightWrongResult as not come in. so gen normal radio button
|
|
50
|
+
,
|
|
51
|
+
react_1.default.createElement(TYPO_COMP, { bold: rightWrongResult && isSelected, color: disabled && greyColor40, invert: invert }, option.display)));
|
|
52
|
+
};
|
|
53
|
+
exports.RadioInput = RadioInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const StyledRadioInput: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.StyledRadioInput = void 0;
|
|
41
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
42
|
+
var themes_1 = require("../../../../../../themes");
|
|
43
|
+
var mixins_1 = require("../../../../../../../themes/mixins");
|
|
44
|
+
var utilsOolib_1 = require("../../../../../../../utilsOolib");
|
|
45
|
+
var none = themes_1.colors.none, white = themes_1.colors.white, greyColor40 = themes_1.colors.greyColor40, greyColor100 = themes_1.colors.greyColor100, greyColor80 = themes_1.colors.greyColor80, grey5 = themes_1.colors.grey5, grey10 = themes_1.colors.grey10, grey20 = themes_1.colors.grey20;
|
|
46
|
+
// secondaryContainer = "#1F3B0A";
|
|
47
|
+
// onSecondary = "#CFE8BD";
|
|
48
|
+
exports.StyledRadioInput = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n background: ", ";\n border: ", ";\n cursor: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n ", "\n }\n\n &:focus {\n outline: none;\n box-shadow: ", ";\n }\n\n /* add the smaller circle for selected state */\n &::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: ", ";\n border: ", ";\n box-shadow: ", ";\n }\n"], ["\n position: relative;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n background: ", ";\n border: ", ";\n cursor: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n ", "\n }\n\n &:focus {\n outline: none;\n box-shadow: ", ";\n }\n\n /* add the smaller circle for selected state */\n &::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: ", ";\n border: ", ";\n box-shadow: ", ";\n }\n"])), function (_a) {
|
|
49
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
50
|
+
if (isSelected) {
|
|
51
|
+
return disabled ? grey5 : utilsOolib_1.onSecondary;
|
|
52
|
+
}
|
|
53
|
+
return disabled ? grey5 : "none";
|
|
54
|
+
}, function (_a) {
|
|
55
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
56
|
+
if (isSelected) {
|
|
57
|
+
return "none";
|
|
58
|
+
}
|
|
59
|
+
return disabled ? "1px solid ".concat(grey10) : "1px solid ".concat(grey20);
|
|
60
|
+
}, function (_a) {
|
|
61
|
+
var disabled = _a.disabled;
|
|
62
|
+
return (disabled ? "not-allowed" : "pointer");
|
|
63
|
+
}, function (_a) {
|
|
64
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
65
|
+
return !disabled &&
|
|
66
|
+
!isSelected &&
|
|
67
|
+
"\n background: rgba(0, 0, 0, 0.05); \n ";
|
|
68
|
+
}, function (_a) {
|
|
69
|
+
var isSelected = _a.isSelected;
|
|
70
|
+
return isSelected ? "0px 4px 6px rgba(0, 0, 0, 0.25)" : "none";
|
|
71
|
+
}, function (_a) {
|
|
72
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
73
|
+
return isSelected ? (disabled ? grey10 : white) : "transparent";
|
|
74
|
+
}, function (_a) {
|
|
75
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
76
|
+
return isSelected
|
|
77
|
+
? disabled
|
|
78
|
+
? "1px solid ".concat(grey20)
|
|
79
|
+
: "1px solid ".concat(utilsOolib_1.secondaryContainer)
|
|
80
|
+
: "none";
|
|
81
|
+
}, function (_a) {
|
|
82
|
+
var isSelected = _a.isSelected, disabled = _a.disabled;
|
|
83
|
+
return isSelected && !disabled ? "0px 4px 6px rgba(0, 0, 0, 0.25)" : "none";
|
|
84
|
+
});
|
|
85
|
+
var templateObject_1;
|
|
86
|
+
// we no longer need StyleRadioInputFill since the ::after pseudo is doing the work. It wasn't working without it.
|
|
87
|
+
// export const StyledRadioInputFill = styled.div`
|
|
88
|
+
// width: ${({ isSelected }) => (isSelected ? '10px' : '0px')};
|
|
89
|
+
// height: ${({ isSelected }) => (isSelected ? '10px' : '0px')};
|
|
90
|
+
// border-radius: 50%;
|
|
91
|
+
// background: ${({ isSelected, disabled }) => {
|
|
92
|
+
// if (isSelected) {
|
|
93
|
+
// return disabled ? 'rgba(0, 0, 0, 0.1)' : white; /* White for selected, light gray for disabled */
|
|
94
|
+
// }
|
|
95
|
+
// return 'transparent';
|
|
96
|
+
// }};
|
|
97
|
+
// border: ${({ isSelected, disabled }) => {
|
|
98
|
+
// if (isSelected) {
|
|
99
|
+
// return disabled ? '1px solid rgba(0, 0, 0, 0.2)' : `1px solid ${onSecondary}`; /* Dark border for selected */
|
|
100
|
+
// }
|
|
101
|
+
// return 'none';
|
|
102
|
+
// }};
|
|
103
|
+
// box-shadow: ${({ isSelected, disabled }) =>
|
|
104
|
+
// isSelected && !disabled ? '0px 4px 6px rgba(0, 0, 0, 0.25)' : 'none'};
|
|
105
|
+
// `;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RadioInput, RadioButton } from "./RadioInput";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RadioButton = exports.RadioInput = void 0;
|
|
4
|
+
var RadioInput_1 = require("./RadioInput");
|
|
5
|
+
Object.defineProperty(exports, "RadioInput", { enumerable: true, get: function () { return RadioInput_1.RadioInput; } });
|
|
6
|
+
Object.defineProperty(exports, "RadioButton", { enumerable: true, get: function () { return RadioInput_1.RadioButton; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function RadioList({ id, injectOtherOption, value: valueProp, onChange, saveValueAsString, options, commonIsCorrectDesc, rightWrongResult, optionsLimit, listType, disabled, invert, readOnly, S }: {
|
|
2
|
+
id: any;
|
|
3
|
+
injectOtherOption?: boolean;
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: any;
|
|
6
|
+
saveValueAsString: any;
|
|
7
|
+
options?: any[];
|
|
8
|
+
commonIsCorrectDesc: any;
|
|
9
|
+
rightWrongResult: any;
|
|
10
|
+
optionsLimit?: number;
|
|
11
|
+
listType?: string;
|
|
12
|
+
disabled: any;
|
|
13
|
+
invert: any;
|
|
14
|
+
readOnly: any;
|
|
15
|
+
S: any;
|
|
16
|
+
}, ...args: any[]): React.JSX.Element;
|
|
17
|
+
import React from "react";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.RadioList = RadioList;
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
49
|
+
var BlockLabel_1 = require("../../../BlockLabel");
|
|
50
|
+
var Tags_1 = require("../../../Tags");
|
|
51
|
+
var TextInputs_1 = require("../../../TextInputs");
|
|
52
|
+
var Buttons_1 = require("../../../Buttons");
|
|
53
|
+
var _EXPORTS_1 = require("../../../../../utils/_EXPORTS");
|
|
54
|
+
var styled_1 = require("../../styled");
|
|
55
|
+
var utils_1 = require("../../utils");
|
|
56
|
+
var comps_1 = require("./comps");
|
|
57
|
+
function RadioList(_a) {
|
|
58
|
+
var id = _a.id, _b = _a.injectOtherOption, injectOtherOption = _b === void 0 ? false : _b, valueProp = _a.value, onChange = _a.onChange, saveValueAsString = _a.saveValueAsString, _c = _a.options, options = _c === void 0 ? [] : _c, commonIsCorrectDesc = _a.commonIsCorrectDesc, rightWrongResult = _a.rightWrongResult, _d = _a.optionsLimit, optionsLimit = _d === void 0 ? Infinity : _d, _e = _a.listType, listType = _e === void 0 ? 'horizontal' : _e, disabled = _a.disabled, invert = _a.invert, readOnly = _a.readOnly, S = _a.S;
|
|
59
|
+
var props = arguments[0];
|
|
60
|
+
var shouldHideSomeOptions = options.length > optionsLimit;
|
|
61
|
+
var _f = (0, react_1.useState)(false), seeMore = _f[0], setSeeMore = _f[1];
|
|
62
|
+
var _g = (0, utils_1.genDisplayedOptions)({ injectOtherOption: injectOtherOption, options: options, valueProp: valueProp, saveValueAsString: saveValueAsString }), typicalOptions = _g.typicalOptions, injectedOtherOption = _g.injectedOtherOption;
|
|
63
|
+
var value = saveValueAsString ?
|
|
64
|
+
typicalOptions
|
|
65
|
+
.concat(injectedOtherOption || [])
|
|
66
|
+
.find(function (op) { var _a; return ((_a = op.display_desc) !== null && _a !== void 0 ? _a : op.value) === valueProp; })
|
|
67
|
+
: valueProp;
|
|
68
|
+
var correctOp = options.find(function (op) { return op.isCorrect; }); //
|
|
69
|
+
var handleInputClick = function (option) {
|
|
70
|
+
var _a;
|
|
71
|
+
onChange(id, saveValueAsString ? ((_a = option.display_desc) !== null && _a !== void 0 ? _a : option.value) : option);
|
|
72
|
+
};
|
|
73
|
+
var handleTextInputChange = function (text) {
|
|
74
|
+
onChange(id, saveValueAsString ? text : (0, utils_1.genOtherValueObject)(text) //text === display_desc
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
var InputCommonProps = {
|
|
78
|
+
invert: invert,
|
|
79
|
+
value: value,
|
|
80
|
+
S: S,
|
|
81
|
+
disabled: disabled,
|
|
82
|
+
rightWrongResult: rightWrongResult,
|
|
83
|
+
onClick: handleInputClick,
|
|
84
|
+
};
|
|
85
|
+
return (react_1.default.createElement("div", { id: id },
|
|
86
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, _EXPORTS_1.getBlockLabelProps)(props))),
|
|
87
|
+
readOnly ? ((value === null || value === void 0 ? void 0 : value.display) && react_1.default.createElement(Tags_1.TagDisplay, { display: value.display_desc || value.display, invert: invert }) //prioritzing display_desc since display of 'other' option is === other
|
|
88
|
+
) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
89
|
+
react_1.default.createElement(styled_1.StyledOptionsContainer, { listType: listType, S: S }, typicalOptions === null || typicalOptions === void 0 ? void 0 :
|
|
90
|
+
typicalOptions.map(function (option, idx) { return idx < optionsLimit && (react_1.default.createElement(comps_1.RadioInput, __assign({}, InputCommonProps, { option: option, key: option.value }))); }),
|
|
91
|
+
shouldHideSomeOptions && // if we have the case of off limit options
|
|
92
|
+
(seeMore || rightWrongResult) && //and decided to show them
|
|
93
|
+
typicalOptions.slice(optionsLimit).map(function (option) {
|
|
94
|
+
return react_1.default.createElement(comps_1.RadioInput, __assign({}, InputCommonProps, { option: option, key: option.value }));
|
|
95
|
+
}),
|
|
96
|
+
injectOtherOption && injectedOtherOption && ( //so other box and its textInput act as one entity in the flexbox
|
|
97
|
+
react_1.default.createElement(styled_1.StyledOtherOptionContainer, { listType: listType },
|
|
98
|
+
react_1.default.createElement(comps_1.RadioInput, __assign({}, InputCommonProps, { option: injectedOtherOption })),
|
|
99
|
+
(value === null || value === void 0 ? void 0 : value.value) === "other" && (react_1.default.createElement(styled_1.StyledOtherTextInputWrapper, { listType: listType, rightWrongResult: rightWrongResult },
|
|
100
|
+
react_1.default.createElement(TextInputs_1.TextInput, { placeholder: "Please Specify Here", value: value.display_desc, onChange: function (k, v) { return handleTextInputChange(v); }, disabled: disabled, invert: invert, S: S })))))),
|
|
101
|
+
shouldHideSomeOptions && !rightWrongResult && (react_1.default.createElement(Buttons_1.ButtonGhost, { onClick: function () { return setSeeMore(!seeMore); }, value: !seeMore ? 'See More' : 'See Less', style: { marginTop: 10 } })),
|
|
102
|
+
/*
|
|
103
|
+
the minute the results have come in, irrespective of user's answer
|
|
104
|
+
being right or wrong, we always show an explanation
|
|
105
|
+
against the right answer. provided that an explanation is provided.
|
|
106
|
+
*/
|
|
107
|
+
correctOp && rightWrongResult && commonIsCorrectDesc &&
|
|
108
|
+
react_1.default.createElement(styled_1.StyledCorrectMessage, { invert: invert }, commonIsCorrectDesc)))));
|
|
109
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { RadioList } from "./comps/RadioList";
|
|
2
|
+
export { CheckboxList } from "./comps/CheckboxList";
|
|
3
|
+
export { CheckboxInput } from "./comps/CheckboxList/comps/CheckboxInput";
|
|
4
|
+
export { CheckboxButton } from "./comps/CheckboxList/comps/CheckboxButton";
|
|
5
|
+
export { RadioInput, RadioButton } from "./comps/RadioList/comps";
|