oolib 2.175.2 → 2.175.4

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.
Files changed (35) hide show
  1. package/dist/stories/v2/components/Checkbox.stories.d.ts +252 -0
  2. package/dist/stories/v2/components/Checkbox.stories.js +252 -0
  3. package/dist/stories/v2/components/RadioButton.stories.d.ts +260 -0
  4. package/dist/stories/v2/components/RadioButton.stories.js +268 -0
  5. package/dist/v2/components/Accordion/index.js +35 -8
  6. package/dist/v2/components/BarChart/comps/CustomTooltip/index.d.ts +1 -2
  7. package/dist/v2/components/BarChart/comps/CustomTooltip/index.js +5 -39
  8. package/dist/v2/components/BarChart/index.d.ts +1 -2
  9. package/dist/v2/components/BarChart/index.js +2 -2
  10. package/dist/v2/components/DataVizAccordion/index.js +4 -5
  11. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/index.d.ts +12 -0
  12. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/index.js +38 -0
  13. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/styled.d.ts +1 -0
  14. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxButton/styled.js +69 -0
  15. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxInput/index.d.ts +11 -0
  16. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/comps/CheckboxInput/index.js +48 -0
  17. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/index.d.ts +20 -0
  18. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/index.js +124 -0
  19. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/styled.d.ts +2 -0
  20. package/dist/v2/components/RadioAndCheckbox/comps/CheckboxList/styled.js +17 -0
  21. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/index.d.ts +18 -0
  22. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/index.js +53 -0
  23. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/styled.d.ts +1 -0
  24. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/RadioInput/styled.js +105 -0
  25. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/index.d.ts +1 -0
  26. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/comps/index.js +6 -0
  27. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/index.d.ts +17 -0
  28. package/dist/v2/components/RadioAndCheckbox/comps/RadioList/index.js +109 -0
  29. package/dist/v2/components/RadioAndCheckbox/index.d.ts +5 -0
  30. package/dist/v2/components/RadioAndCheckbox/index.js +14 -0
  31. package/dist/v2/components/RadioAndCheckbox/styled.d.ts +5 -0
  32. package/dist/v2/components/RadioAndCheckbox/styled.js +84 -0
  33. package/dist/v2/components/RadioAndCheckbox/utils.d.ts +22 -0
  34. package/dist/v2/components/RadioAndCheckbox/utils.js +49 -0
  35. package/package.json +1 -1
@@ -194,7 +194,7 @@ var barConfigs = {
194
194
  },
195
195
  };
196
196
  var BarChart = function (_a) {
197
- var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.breakdownDisplayType, breakdownDisplayType = _c === void 0 ? "grouped" : _c, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, _f = _a.colorIdx, colorIdx = _f === void 0 ? 0 : _f, setAccordionOverflow = _a.setAccordionOverflow;
197
+ var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.breakdownDisplayType, breakdownDisplayType = _c === void 0 ? "grouped" : _c, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, _f = _a.colorIdx, colorIdx = _f === void 0 ? 0 : _f;
198
198
  var isBreakdown = Array.isArray(valuePath);
199
199
  var data = usePrepareData({
200
200
  _data: _data,
@@ -272,7 +272,7 @@ var BarChart = function (_a) {
272
272
  // god knows why the dataindex gets stored against props.label.
273
273
  // this is some internal recharts thing for tooltips specifically.
274
274
  // we dont do this.
275
- value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[(colorIdx + idx) % colors_1.dataVizColors.length] })); }), setAccordionOverflow: setAccordionOverflow })));
275
+ value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[(colorIdx + idx) % colors_1.dataVizColors.length] })); }) })));
276
276
  }, cursor: false, allowEscapeViewBox: { x: true, y: true } })),
277
277
  isBreakdown
278
278
  ? data[0].map(function (_, stackIndex) {
@@ -44,18 +44,17 @@ var DataVizAccordion = function (_a) {
44
44
  },
45
45
  };
46
46
  var _c = (0, react_2.useState)(chartOptions[0]), activeCompConfig = _c[0], setActiveCompConfig = _c[1];
47
- var genActiveChartComp = function (activeCompConfig, setAccordionOverflow) {
47
+ var genActiveChartComp = function (activeCompConfig) {
48
48
  var ActiveChartComp = ChartComps[activeCompConfig.comp].comp;
49
49
  var wrapperStyle = ChartComps[activeCompConfig.comp].wrapperStyle;
50
50
  return (react_1.default.createElement("div", { style: __assign({ padding: "0 1.6rem 1rem 1.6rem" }, (wrapperStyle || {})) },
51
- react_1.default.createElement(ActiveChartComp, __assign({}, props, activeCompConfig.props, { setAccordionOverflow: setAccordionOverflow }))));
51
+ react_1.default.createElement(ActiveChartComp, __assign({}, props, activeCompConfig.props))));
52
52
  };
53
- var _d = (0, react_2.useState)('hidden'), accordionOverflow = _d[0], setAccordionOverflow = _d[1];
54
- return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, accordionOverflow: accordionOverflow, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
53
+ return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
55
54
  display: d.display,
56
55
  onClick: function () {
57
56
  return setActiveCompConfig(d);
58
57
  },
59
- }); }) }, genActiveChartComp(activeCompConfig, setAccordionOverflow)));
58
+ }); }) }, genActiveChartComp(activeCompConfig)));
60
59
  };
61
60
  exports.DataVizAccordion = DataVizAccordion;
@@ -0,0 +1,12 @@
1
+ export function CheckboxButton({ id, className, isSelected: _isSelected, isMixture, value, onChange, disabled, invert, S, }: {
2
+ id: any;
3
+ className: any;
4
+ isSelected: any;
5
+ isMixture: any;
6
+ value: any;
7
+ onChange: any;
8
+ disabled: any;
9
+ invert: any;
10
+ S: any;
11
+ }): React.JSX.Element;
12
+ import React from "react";
@@ -0,0 +1,38 @@
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.CheckboxButton = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var icons_1 = require("../../../../../../../icons");
9
+ var themes_1 = require("../../../../../../themes");
10
+ var styled_1 = require("./styled");
11
+ var Check = icons_1.icons.Check, Minus = icons_1.icons.Minus;
12
+ var white = themes_1.colors.white, greyColor100 = themes_1.colors.greyColor100, onSecondary = themes_1.colors.onSecondary, grey40 = themes_1.colors.grey40;
13
+ /**
14
+ * value and onChange are being passed as props so
15
+ * that it can be generated dynamically via our
16
+ * block generators.
17
+ */
18
+ var CheckboxButton = function (_a) {
19
+ var _b;
20
+ var id = _a.id, className = _a.className, _isSelected = _a.isSelected, isMixture = _a.isMixture, //basically if isSelected/value && isMixture is true, then we get that '-' thing in the checkbox (useful on table headers where some (not all) rows are selected below)
21
+ value = _a.value, //can be used interchangibly with isSelected
22
+ onChange = _a.onChange, disabled = _a.disabled, invert = _a.invert, S = _a.S;
23
+ var isSelected = (_b = _isSelected !== null && _isSelected !== void 0 ? _isSelected : value) !== null && _b !== void 0 ? _b : false;
24
+ var CheckIcon = (isSelected && isMixture)
25
+ ? Minus
26
+ : isSelected
27
+ ? Check
28
+ : undefined;
29
+ return (react_1.default.createElement(styled_1.StyledCheckbox, { style: { overflow: 'hidden' }, onClick: function (e) {
30
+ // e.preventDefault();
31
+ // e.stopPropagation(); //this disables the checkbox in checkboxlist which we dont want. so commented. tho we might need this later in table usecase in which case we will have to make stopPropagration a prop
32
+ onChange && onChange(id, !isSelected);
33
+ }, className: className, isSelected: isSelected, disabled: disabled, invert: invert, S: S }, isSelected && (react_1.default.createElement("div", { style: { filter: "drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.25))", display: 'flex' } },
34
+ react_1.default.createElement(CheckIcon, { weight: "bold", color: disabled ? grey40 : onSecondary, size: 16, style: {
35
+ flexShrink: 0,
36
+ } })))));
37
+ };
38
+ exports.CheckboxButton = CheckboxButton;
@@ -0,0 +1 @@
1
+ export const StyledCheckbox: import("styled-components").StyledComponent<"button", any, {}, never>;
@@ -0,0 +1,69 @@
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 utils_1 = require("../../../../../../themes/utils");
45
+ var grey20 = themes_1.colors.grey20, grey5 = themes_1.colors.grey5, grey10 = themes_1.colors.grey10, grey50 = themes_1.colors.grey50;
46
+ exports.StyledCheckbox = styled_components_1.default.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \n width: 2.4rem;\n height: 2.4rem;\n ", "{\n width: 2rem;\n height: 2rem;\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: 2rem;\n height: 2rem;\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) {
47
+ var isSelected = _a.isSelected, disabled = _a.disabled;
48
+ if (isSelected && disabled) {
49
+ return "1px solid ".concat(grey20);
50
+ }
51
+ if (!isSelected) {
52
+ return "1px solid ".concat(disabled ? grey10 : grey20);
53
+ }
54
+ return "none";
55
+ }, function (_a) {
56
+ var isSelected = _a.isSelected, disabled = _a.disabled, colors = _a.theme.colors;
57
+ if (isSelected) {
58
+ return disabled ? grey5 : (0, utils_1.getSecondaryContainer)(colors);
59
+ }
60
+ return disabled ? grey5 : "white";
61
+ }, function (_a) {
62
+ var disabled = _a.disabled;
63
+ return (disabled ? "not-allowed" : "pointer");
64
+ }, function (_a) {
65
+ var isSelected = _a.isSelected, disabled = _a.disabled;
66
+ return !disabled &&
67
+ !isSelected && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid ", ";\n "], ["\n border: 1px solid ", ";\n "])), grey50);
68
+ });
69
+ var templateObject_1, templateObject_2;
@@ -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: "btn", 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 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 utils_1 = require("../../utils");
55
+ var styled_1 = require("../../styled");
56
+ var CheckboxInput_1 = require("./comps/CheckboxInput");
57
+ var styled_2 = require("./styled");
58
+ var Typo2_1 = require("../../../Typo2");
59
+ var OKELink_1 = require("../../../OKELink");
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,2 @@
1
+ export const StyledDisplayTagsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export const StyledTagOptionsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -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";