@pie-lib/correct-answer-toggle 3.1.0-next.2 → 3.1.0-next.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.1.0-next.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@3.1.0-next.2...@pie-lib/correct-answer-toggle@3.1.0-next.4) (2026-01-27)
7
+
8
+ **Note:** Version bump only for package @pie-lib/correct-answer-toggle
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.1.0-next.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@3.1.0-next.1...@pie-lib/correct-answer-toggle@3.1.0-next.2) (2026-01-26)
7
15
 
8
16
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _reactTransitionGroup = require("react-transition-group");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
+ var transition = 'height ease-in 300ms, opacity ease-in 300ms';
15
+ var StyledExpander = (0, _styles.styled)('div')(function () {
16
+ return {
17
+ position: 'relative',
18
+ height: 0,
19
+ overflow: 'hidden',
20
+ display: 'flex',
21
+ visibility: 'hidden',
22
+ width: 0,
23
+ '&.enter': {
24
+ transition: transition,
25
+ opacity: 1,
26
+ height: 'auto',
27
+ width: 'auto',
28
+ visibility: 'visible',
29
+ minHeight: '25px'
30
+ },
31
+ '&.enter-done': {
32
+ height: 'auto',
33
+ visibility: 'visible',
34
+ width: 'auto',
35
+ minHeight: '25px'
36
+ },
37
+ '&.exit': {
38
+ transition: transition,
39
+ opacity: 0,
40
+ height: 0,
41
+ visibility: 'visible',
42
+ width: 0
43
+ },
44
+ '&.exit-done': {
45
+ opacity: 0,
46
+ visibility: 'hidden',
47
+ height: 0,
48
+ width: 0
49
+ }
50
+ };
51
+ });
52
+ var Expander = function Expander(props) {
53
+ var show = props.show,
54
+ children = props.children,
55
+ className = props.className;
56
+ var nodeRef = (0, _react.useRef)(null);
57
+ return /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
58
+ nodeRef: nodeRef,
59
+ "in": show,
60
+ appear: true,
61
+ mountOnEnter: false,
62
+ timeout: 300,
63
+ classNames: {
64
+ enter: 'enter',
65
+ enterDone: 'enter-done',
66
+ exit: 'exit',
67
+ exitDone: 'exit-done'
68
+ }
69
+ }, /*#__PURE__*/_react["default"].createElement(StyledExpander, {
70
+ ref: nodeRef,
71
+ className: className
72
+ }, children));
73
+ };
74
+ Expander.propTypes = {
75
+ show: _propTypes["default"].bool.isRequired,
76
+ className: _propTypes["default"].string,
77
+ children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
78
+ };
79
+ var _default = exports["default"] = Expander;
80
+ //# sourceMappingURL=expander.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expander.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_styles","_reactTransitionGroup","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","transition","StyledExpander","styled","position","height","overflow","display","visibility","width","opacity","minHeight","Expander","props","show","children","className","nodeRef","useRef","createElement","CSSTransition","appear","mountOnEnter","timeout","classNames","enter","enterDone","exit","exitDone","ref","propTypes","PropTypes","bool","isRequired","string","oneOfType","arrayOf","node","_default","exports"],"sources":["../src/expander.jsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { CSSTransition } from 'react-transition-group';\n\nconst transition = 'height ease-in 300ms, opacity ease-in 300ms';\n\nconst StyledExpander = styled('div')(() => ({\n position: 'relative',\n height: 0,\n overflow: 'hidden',\n display: 'flex',\n visibility: 'hidden',\n width: 0,\n '&.enter': {\n transition,\n opacity: 1,\n height: 'auto',\n width: 'auto',\n visibility: 'visible',\n minHeight: '25px',\n },\n '&.enter-done': {\n height: 'auto',\n visibility: 'visible',\n width: 'auto',\n minHeight: '25px',\n },\n '&.exit': {\n transition,\n opacity: 0,\n height: 0,\n visibility: 'visible',\n width: 0,\n },\n '&.exit-done': {\n opacity: 0,\n visibility: 'hidden',\n height: 0,\n width: 0,\n },\n}));\n\nconst Expander = (props) => {\n const { show, children, className } = props;\n const nodeRef = useRef(null);\n\n return (\n <CSSTransition\n nodeRef={nodeRef}\n in={show}\n appear={true}\n mountOnEnter={false}\n timeout={300}\n classNames={{\n enter: 'enter',\n enterDone: 'enter-done',\n exit: 'exit',\n exitDone: 'exit-done',\n }}\n >\n <StyledExpander ref={nodeRef} className={className}>\n {children}\n </StyledExpander>\n </CSSTransition>\n );\n};\n\nExpander.propTypes = {\n show: PropTypes.bool.isRequired,\n className: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.arrayOf(P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EAAE;MACVC,KAAK,EAAE,OAAO;MACdC,SAAS,EAAE,YAAY;MACvBC,IAAI,EAAE,MAAM;MACZC,QAAQ,EAAE;IACZ;EAAE,gBAEFtD,MAAA,YAAA6C,aAAA,CAACjB,cAAc;IAAC2B,GAAG,EAAEZ,OAAQ;IAACD,SAAS,EAAEA;EAAU,GAChDD,QACa,CACH,CAAC;AAEpB,CAAC;AAEDH,QAAQ,CAACkB,SAAS,GAAG;EACnBhB,IAAI,EAAEiB,qBAAS,CAACC,IAAI,CAACC,UAAU;EAC/BjB,SAAS,EAAEe,qBAAS,CAACG,MAAM;EAC3BnB,QAAQ,EAAEgB,qBAAS,CAACI,SAAS,CAAC,CAACJ,qBAAS,CAACK,OAAO,CAACL,qBAAS,CAACM,IAAI,CAAC,EAAEN,qBAAS,CAACM,IAAI,CAAC,CAAC,CAACJ;AACrF,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,cAEa3B,QAAQ","ignoreList":[]}
package/lib/index.js ADDED
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = exports.CorrectAnswerToggle = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _reactTransitionGroup = require("react-transition-group");
16
+ var _icons = require("@pie-lib/icons");
17
+ var _renderUi = require("@pie-lib/render-ui");
18
+ var _expander = _interopRequireDefault(require("./expander"));
19
+ var _react = _interopRequireDefault(require("react"));
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
21
+ var _translator = _interopRequireDefault(require("@pie-lib/translator"));
22
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
23
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
+ var translator = _translator["default"].translator;
27
+ var noTouch = {
28
+ '-webkit-touchCcallout': 'none',
29
+ '-webkit-user-select': 'none',
30
+ '-khtml-user-select': 'none',
31
+ '-moz-user-select': 'none',
32
+ '-ms-user-select': 'none',
33
+ 'user-select': 'none'
34
+ };
35
+ var StyledRoot = (0, _styles.styled)('div')(function () {
36
+ return {
37
+ width: '100%',
38
+ cursor: 'pointer'
39
+ };
40
+ });
41
+ var StyledContent = (0, _styles.styled)('div')(function () {
42
+ return {
43
+ margin: '0 auto',
44
+ textAlign: 'center',
45
+ display: 'flex'
46
+ };
47
+ });
48
+ var StyledLabel = (0, _styles.styled)('div')(function () {
49
+ return _objectSpread({
50
+ width: 'fit-content',
51
+ minWidth: '140px',
52
+ alignSelf: 'center',
53
+ verticalAlign: 'middle',
54
+ color: "var(--correct-answer-toggle-label-color, ".concat(_renderUi.color.text(), ")"),
55
+ fontWeight: 'normal'
56
+ }, noTouch);
57
+ });
58
+ var StyledIcon = (0, _styles.styled)('div')(function () {
59
+ return {
60
+ position: 'absolute',
61
+ width: '25px',
62
+ '&.enter': {
63
+ opacity: '0'
64
+ },
65
+ '&.enter-active': {
66
+ opacity: '1',
67
+ transition: 'opacity 0.3s ease-in'
68
+ },
69
+ '&.exit': {
70
+ opacity: '1'
71
+ },
72
+ '&.exit-active': {
73
+ opacity: '0',
74
+ transition: 'opacity 0.3s ease-in'
75
+ }
76
+ };
77
+ });
78
+ var StyledIconHolder = (0, _styles.styled)('div')(function () {
79
+ return {
80
+ width: '25px',
81
+ marginRight: '5px',
82
+ display: 'flex',
83
+ alignItems: 'center'
84
+ };
85
+ });
86
+
87
+ /**
88
+ * We export the raw unstyled class for testability. For public use please use the default export.
89
+ */
90
+ var CorrectAnswerToggle = exports.CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
91
+ function CorrectAnswerToggle(props) {
92
+ var _this;
93
+ (0, _classCallCheck2["default"])(this, CorrectAnswerToggle);
94
+ _this = _callSuper(this, CorrectAnswerToggle, [props]);
95
+ _this.state = {
96
+ show: props.show
97
+ };
98
+ _this.openIconRef = /*#__PURE__*/_react["default"].createRef();
99
+ _this.closedIconRef = /*#__PURE__*/_react["default"].createRef();
100
+ CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
101
+ showMessage: translator.t('common:showCorrectAnswer', {
102
+ lng: props.language
103
+ }),
104
+ hideMessage: translator.t('common:hideCorrectAnswer', {
105
+ lng: props.language
106
+ })
107
+ });
108
+ return _this;
109
+ }
110
+ (0, _inherits2["default"])(CorrectAnswerToggle, _React$Component);
111
+ return (0, _createClass2["default"])(CorrectAnswerToggle, [{
112
+ key: "onClick",
113
+ value: function onClick() {
114
+ this.props.onToggle(!this.props.toggled);
115
+ }
116
+ }, {
117
+ key: "onTouch",
118
+ value: function onTouch(event) {
119
+ event.preventDefault(); // Prevents the default action (click event)
120
+ this.props.onToggle(!this.props.toggled);
121
+ }
122
+ }, {
123
+ key: "UNSAFE_componentWillReceiveProps",
124
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
125
+ var _this$props;
126
+ this.setState({
127
+ show: nextProps.show
128
+ });
129
+ if (nextProps.language !== ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.language)) {
130
+ CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
131
+ showMessage: translator.t('common:showCorrectAnswer', {
132
+ lng: nextProps.language
133
+ }),
134
+ hideMessage: translator.t('common:hideCorrectAnswer', {
135
+ lng: nextProps.language
136
+ })
137
+ });
138
+ }
139
+ }
140
+ }, {
141
+ key: "render",
142
+ value: function render() {
143
+ var _this$props2 = this.props,
144
+ className = _this$props2.className,
145
+ toggled = _this$props2.toggled,
146
+ hideMessage = _this$props2.hideMessage,
147
+ showMessage = _this$props2.showMessage;
148
+ return /*#__PURE__*/_react["default"].createElement(StyledRoot, {
149
+ className: className
150
+ }, /*#__PURE__*/_react["default"].createElement(_expander["default"], {
151
+ show: this.state.show
152
+ }, /*#__PURE__*/_react["default"].createElement(StyledContent, {
153
+ onClick: this.onClick.bind(this),
154
+ onTouchEnd: this.onTouch.bind(this)
155
+ }, /*#__PURE__*/_react["default"].createElement(StyledIconHolder, null, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
156
+ nodeRef: this.openIconRef,
157
+ timeout: 400,
158
+ "in": toggled,
159
+ exit: !toggled,
160
+ classNames: {
161
+ enter: 'enter',
162
+ enterActive: 'enter-active',
163
+ exit: 'exit',
164
+ exitActive: 'exit-active'
165
+ }
166
+ }, /*#__PURE__*/_react["default"].createElement(StyledIcon, {
167
+ ref: this.openIconRef
168
+ }, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
169
+ open: toggled,
170
+ key: "correct-open"
171
+ }))), /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
172
+ nodeRef: this.closedIconRef,
173
+ timeout: 5000,
174
+ "in": !toggled,
175
+ exit: toggled,
176
+ classNames: {
177
+ enter: 'enter',
178
+ enterActive: 'enter-active',
179
+ exit: 'exit',
180
+ exitActive: 'exit-active'
181
+ }
182
+ }, /*#__PURE__*/_react["default"].createElement(StyledIcon, {
183
+ ref: this.closedIconRef
184
+ }, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
185
+ open: toggled,
186
+ key: "correct-closed"
187
+ })))), /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
188
+ "false": true
189
+ }, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
190
+ "aria-hidden": !this.state.show
191
+ }, toggled ? hideMessage : showMessage)))));
192
+ }
193
+ }]);
194
+ }(_react["default"].Component);
195
+ (0, _defineProperty2["default"])(CorrectAnswerToggle, "propTypes", {
196
+ onToggle: _propTypes["default"].func,
197
+ toggled: _propTypes["default"].bool,
198
+ show: _propTypes["default"].bool,
199
+ hideMessage: _propTypes["default"].string,
200
+ showMessage: _propTypes["default"].string,
201
+ className: _propTypes["default"].string,
202
+ language: _propTypes["default"].string
203
+ });
204
+ (0, _defineProperty2["default"])(CorrectAnswerToggle, "defaultProps", {
205
+ showMessage: 'Show correct answer',
206
+ hideMessage: 'Hide correct answer',
207
+ show: false,
208
+ toggled: false
209
+ });
210
+ var _default = exports["default"] = CorrectAnswerToggle;
211
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_styles","require","_reactTransitionGroup","_icons","_renderUi","_expander","_interopRequireDefault","_react","_propTypes","_translator","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","ownKeys","r","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","translator","Translator","noTouch","StyledRoot","styled","width","cursor","StyledContent","margin","textAlign","display","StyledLabel","minWidth","alignSelf","verticalAlign","color","concat","text","fontWeight","StyledIcon","position","opacity","transition","StyledIconHolder","marginRight","alignItems","CorrectAnswerToggle","exports","_React$Component","props","_this","_classCallCheck2","state","show","openIconRef","React","createRef","closedIconRef","defaultProps","showMessage","lng","language","hideMessage","_inherits2","_createClass2","key","value","onClick","onToggle","toggled","onTouch","event","preventDefault","UNSAFE_componentWillReceiveProps","nextProps","_this$props","setState","render","_this$props2","className","createElement","bind","onTouchEnd","CSSTransition","nodeRef","timeout","exit","classNames","enter","enterActive","exitActive","ref","CorrectResponse","open","Readable","Component","PropTypes","func","bool","string","_default"],"sources":["../src/index.jsx"],"sourcesContent":["import { styled } from '@mui/material/styles';\nimport { CSSTransition } from 'react-transition-group';\nimport { CorrectResponse } from '@pie-lib/icons';\nimport { Readable } from '@pie-lib/render-ui';\nimport Expander from './expander';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport Translator from '@pie-lib/translator';\nimport { color } from '@pie-lib/render-ui';\n\nconst { translator } = Translator;\n\nconst noTouch = {\n '-webkit-touchCcallout': 'none',\n '-webkit-user-select': 'none',\n '-khtml-user-select': 'none',\n '-moz-user-select': 'none',\n '-ms-user-select': 'none',\n 'user-select': 'none',\n};\n\nconst StyledRoot = styled('div')(() => ({\n width: '100%',\n cursor: 'pointer',\n}));\n\nconst StyledContent = styled('div')(() => ({\n margin: '0 auto',\n textAlign: 'center',\n display: 'flex',\n}));\n\nconst StyledLabel = styled('div')(() => ({\n width: 'fit-content',\n minWidth: '140px',\n alignSelf: 'center',\n verticalAlign: 'middle',\n color: `var(--correct-answer-toggle-label-color, ${color.text()})`,\n fontWeight: 'normal',\n ...noTouch,\n}));\n\nconst StyledIcon = styled('div')(() => ({\n position: 'absolute',\n width: '25px',\n '&.enter': {\n opacity: '0',\n },\n '&.enter-active': {\n opacity: '1',\n transition: 'opacity 0.3s ease-in',\n },\n '&.exit': {\n opacity: '1',\n },\n '&.exit-active': {\n opacity: '0',\n transition: 'opacity 0.3s ease-in',\n },\n}));\n\nconst StyledIconHolder = styled('div')(() => ({\n width: '25px',\n marginRight: '5px',\n display: 'flex',\n alignItems: 'center',\n}));\n\n/**\n * We export the raw unstyled class for testability. For public use please use the default export.\n */\nexport class CorrectAnswerToggle extends React.Component {\n static propTypes = {\n onToggle: PropTypes.func,\n toggled: PropTypes.bool,\n show: PropTypes.bool,\n hideMessage: PropTypes.string,\n showMessage: PropTypes.string,\n className: PropTypes.string,\n language: PropTypes.string,\n };\n\n static defaultProps = {\n showMessage: 'Show correct answer',\n hideMessage: 'Hide correct answer',\n show: false,\n toggled: false,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n show: props.show,\n };\n this.openIconRef = React.createRef();\n this.closedIconRef = React.createRef();\n\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: props.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: props.language }),\n };\n }\n\n onClick() {\n this.props.onToggle(!this.props.toggled);\n }\n onTouch(event) {\n event.preventDefault(); // Prevents the default action (click event)\n this.props.onToggle(!this.props.toggled);\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({\n show: nextProps.show,\n });\n\n if (nextProps.language !== this.props?.language) {\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: nextProps.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: nextProps.language }),\n };\n }\n }\n\n render() {\n const { className, toggled, hideMessage, showMessage } = this.props;\n\n return (\n <StyledRoot className={className}>\n <Expander show={this.state.show}>\n <StyledContent onClick={this.onClick.bind(this)} onTouchEnd={this.onTouch.bind(this)}>\n <StyledIconHolder>\n <CSSTransition\n nodeRef={this.openIconRef}\n timeout={400}\n in={toggled}\n exit={!toggled}\n classNames={{\n enter: 'enter',\n enterActive: 'enter-active',\n exit: 'exit',\n exitActive: 'exit-active',\n }}\n >\n <StyledIcon ref={this.openIconRef}>\n <CorrectResponse open={toggled} key=\"correct-open\" />\n </StyledIcon>\n </CSSTransition>\n <CSSTransition\n nodeRef={this.closedIconRef}\n timeout={5000}\n in={!toggled}\n exit={toggled}\n classNames={{\n enter: 'enter',\n enterActive: 'enter-active',\n exit: 'exit',\n exitActive: 'exit-active',\n }}\n >\n <StyledIcon ref={this.closedIconRef}>\n <CorrectResponse open={toggled} key=\"correct-closed\" />\n </StyledIcon>\n </CSSTransition>\n </StyledIconHolder>\n <Readable false>\n <StyledLabel aria-hidden={!this.state.show}>{toggled ? hideMessage : showMessage}</StyledLabel>\n </Readable>\n </StyledContent>\n </Expander>\n </StyledRoot>\n );\n }\n}\n\nexport default CorrectAnswerToggle;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,UAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,WAAA,GAAAH,sBAAA,CAAAL,OAAA;AAA6C,SAAAS,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,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,CAACzC,UAAU;QAACoD,GAAG,EAAE,IAAI,CAAClC;MAAc,gBAClCxE,MAAA,YAAA+F,aAAA,CAACnG,MAAA,CAAA+G,eAAe;QAACC,IAAI,EAAExB,OAAQ;QAACJ,GAAG,EAAC;MAAgB,CAAE,CAC5C,CACC,CACC,CAAC,eACnBhF,MAAA,YAAA+F,aAAA,CAAClG,SAAA,CAAAgH,QAAQ;QAAC;MAAK,gBACb7G,MAAA,YAAA+F,aAAA,CAACjD,WAAW;QAAC,eAAa,CAAC,IAAI,CAACqB,KAAK,CAACC;MAAK,GAAEgB,OAAO,GAAGP,WAAW,GAAGH,WAAyB,CACtF,CACG,CACP,CACA,CAAC;IAEjB;EAAC;AAAA,EAvGsCJ,iBAAK,CAACwC,SAAS;AAAA,IAAA/E,gBAAA,aAA3C8B,mBAAmB,eACX;EACjBsB,QAAQ,EAAE4B,qBAAS,CAACC,IAAI;EACxB5B,OAAO,EAAE2B,qBAAS,CAACE,IAAI;EACvB7C,IAAI,EAAE2C,qBAAS,CAACE,IAAI;EACpBpC,WAAW,EAAEkC,qBAAS,CAACG,MAAM;EAC7BxC,WAAW,EAAEqC,qBAAS,CAACG,MAAM;EAC7BpB,SAAS,EAAEiB,qBAAS,CAACG,MAAM;EAC3BtC,QAAQ,EAAEmC,qBAAS,CAACG;AACtB,CAAC;AAAA,IAAAnF,gBAAA,aATU8B,mBAAmB,kBAWR;EACpBa,WAAW,EAAE,qBAAqB;EAClCG,WAAW,EAAE,qBAAqB;EAClCT,IAAI,EAAE,KAAK;EACXgB,OAAO,EAAE;AACX,CAAC;AAAA,IAAA+B,QAAA,GAAArD,OAAA,cA0FYD,mBAAmB","ignoreList":[]}
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "publishConfig": {
13
13
  "access": "public"
14
14
  },
15
- "version": "3.1.0-next.2",
15
+ "version": "3.1.0-next.5",
16
16
  "main": "lib/index.js",
17
17
  "module": "src/index.jsx",
18
18
  "scripts": {},
@@ -21,9 +21,9 @@
21
21
  "@emotion/style": "^0.8.0",
22
22
  "@mui/icons-material": "^7.3.4",
23
23
  "@mui/material": "^7.3.4",
24
- "@pie-lib/icons": "3.1.0-next.1",
25
- "@pie-lib/render-ui": "5.1.0-next.2",
26
- "@pie-lib/translator": "3.1.0-next.1",
24
+ "@pie-lib/icons": "3.1.0-next.4",
25
+ "@pie-lib/render-ui": "5.1.0-next.5",
26
+ "@pie-lib/translator": "3.1.0-next.4",
27
27
  "lodash": "^4.17.11",
28
28
  "prop-types": "^15.6.2",
29
29
  "react-transition-group": "^4.4.5"
@@ -36,5 +36,5 @@
36
36
  "react": "^18.2.0",
37
37
  "react-dom": "^18.2.0"
38
38
  },
39
- "gitHead": "04c639af6e49d1881bf3244ebb3940171c26bd3e"
39
+ "gitHead": "e51620791bab7434375dc0a101c39dc5926a457d"
40
40
  }