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

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,87 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.array.iterator.js");
4
+ require("core-js/modules/es.object.define-property.js");
5
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
6
+ require("core-js/modules/es.object.to-string.js");
7
+ require("core-js/modules/es.string.iterator.js");
8
+ require("core-js/modules/es.weak-map.js");
9
+ require("core-js/modules/web.dom-collections.iterator.js");
10
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
11
+ var _typeof = require("@babel/runtime/helpers/typeof");
12
+ Object.defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ exports["default"] = void 0;
16
+ var _react = _interopRequireWildcard(require("react"));
17
+ var _propTypes = _interopRequireDefault(require("prop-types"));
18
+ var _styles = require("@mui/material/styles");
19
+ var _reactTransitionGroup = require("react-transition-group");
20
+ 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); }
21
+ var transition = 'height ease-in 300ms, opacity ease-in 300ms';
22
+ var StyledExpander = (0, _styles.styled)('div')(function () {
23
+ return {
24
+ position: 'relative',
25
+ height: 0,
26
+ overflow: 'hidden',
27
+ display: 'flex',
28
+ visibility: 'hidden',
29
+ width: 0,
30
+ '&.enter': {
31
+ transition: transition,
32
+ opacity: 1,
33
+ height: 'auto',
34
+ width: 'auto',
35
+ visibility: 'visible',
36
+ minHeight: '25px'
37
+ },
38
+ '&.enter-done': {
39
+ height: 'auto',
40
+ visibility: 'visible',
41
+ width: 'auto',
42
+ minHeight: '25px'
43
+ },
44
+ '&.exit': {
45
+ transition: transition,
46
+ opacity: 0,
47
+ height: 0,
48
+ visibility: 'visible',
49
+ width: 0
50
+ },
51
+ '&.exit-done': {
52
+ opacity: 0,
53
+ visibility: 'hidden',
54
+ height: 0,
55
+ width: 0
56
+ }
57
+ };
58
+ });
59
+ var Expander = function Expander(props) {
60
+ var show = props.show,
61
+ children = props.children,
62
+ className = props.className;
63
+ var nodeRef = (0, _react.useRef)(null);
64
+ return /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
65
+ nodeRef: nodeRef,
66
+ "in": show,
67
+ appear: true,
68
+ mountOnEnter: false,
69
+ timeout: 300,
70
+ classNames: {
71
+ enter: 'enter',
72
+ enterDone: 'enter-done',
73
+ exit: 'exit',
74
+ exitDone: 'exit-done'
75
+ }
76
+ }, /*#__PURE__*/_react["default"].createElement(StyledExpander, {
77
+ ref: nodeRef,
78
+ className: className
79
+ }, children));
80
+ };
81
+ Expander.propTypes = {
82
+ show: _propTypes["default"].bool.isRequired,
83
+ className: _propTypes["default"].string,
84
+ children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
85
+ };
86
+ var _default = exports["default"] = Expander;
87
+ //# 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(PropTypes.node), PropTypes.node]).isRequired,\n};\n\nexport default Expander;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,qBAAA,GAAAJ,OAAA;AAAuD,SAAAD,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,wBAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,C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C,aAAM,EAAC,IAAI,CAAC;EAE5B,oBACE5C,MAAA,YAAA6C,aAAA,CAACvC,qBAAA,CAAAwC,aAAa;IACZH,OAAO,EAAEA,OAAQ;IACjB,MAAIH,IAAK;IACTO,MAAM,EAAE,IAAK;IACbC,YAAY,EAAE,KAAM;IACpBC,OAAO,EAAE,GAAI;IACbC,UAAU,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,223 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.js");
4
+ require("core-js/modules/es.array.filter.js");
5
+ require("core-js/modules/es.array.for-each.js");
6
+ require("core-js/modules/es.object.define-properties.js");
7
+ require("core-js/modules/es.object.define-property.js");
8
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
9
+ require("core-js/modules/es.object.get-own-property-descriptors.js");
10
+ require("core-js/modules/es.object.keys.js");
11
+ require("core-js/modules/es.object.to-string.js");
12
+ require("core-js/modules/es.reflect.construct.js");
13
+ require("core-js/modules/web.dom-collections.for-each.js");
14
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
15
+ Object.defineProperty(exports, "__esModule", {
16
+ value: true
17
+ });
18
+ exports["default"] = exports.CorrectAnswerToggle = void 0;
19
+ require("core-js/modules/es.function.bind.js");
20
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
21
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
22
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
24
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
26
+ var _styles = require("@mui/material/styles");
27
+ var _reactTransitionGroup = require("react-transition-group");
28
+ var _icons = require("@pie-lib/icons");
29
+ var _renderUi = require("@pie-lib/render-ui");
30
+ var _expander = _interopRequireDefault(require("./expander"));
31
+ var _react = _interopRequireDefault(require("react"));
32
+ var _propTypes = _interopRequireDefault(require("prop-types"));
33
+ var _translator = _interopRequireDefault(require("@pie-lib/translator"));
34
+ 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)); }
35
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
36
+ 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; }
37
+ 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; }
38
+ var translator = _translator["default"].translator;
39
+ var noTouch = {
40
+ '-webkit-touchCcallout': 'none',
41
+ '-webkit-user-select': 'none',
42
+ '-khtml-user-select': 'none',
43
+ '-moz-user-select': 'none',
44
+ '-ms-user-select': 'none',
45
+ 'user-select': 'none'
46
+ };
47
+ var StyledRoot = (0, _styles.styled)('div')(function () {
48
+ return {
49
+ width: '100%',
50
+ cursor: 'pointer'
51
+ };
52
+ });
53
+ var StyledContent = (0, _styles.styled)('div')(function () {
54
+ return {
55
+ margin: '0 auto',
56
+ textAlign: 'center',
57
+ display: 'flex'
58
+ };
59
+ });
60
+ var StyledLabel = (0, _styles.styled)('div')(function () {
61
+ return _objectSpread({
62
+ width: 'fit-content',
63
+ minWidth: '140px',
64
+ alignSelf: 'center',
65
+ verticalAlign: 'middle',
66
+ color: "var(--correct-answer-toggle-label-color, ".concat(_renderUi.color.text(), ")"),
67
+ fontWeight: 'normal'
68
+ }, noTouch);
69
+ });
70
+ var StyledIcon = (0, _styles.styled)('div')(function () {
71
+ return {
72
+ position: 'absolute',
73
+ width: '25px',
74
+ '&.enter': {
75
+ opacity: '0'
76
+ },
77
+ '&.enter-active': {
78
+ opacity: '1',
79
+ transition: 'opacity 0.3s ease-in'
80
+ },
81
+ '&.exit': {
82
+ opacity: '1'
83
+ },
84
+ '&.exit-active': {
85
+ opacity: '0',
86
+ transition: 'opacity 0.3s ease-in'
87
+ }
88
+ };
89
+ });
90
+ var StyledIconHolder = (0, _styles.styled)('div')(function () {
91
+ return {
92
+ width: '25px',
93
+ marginRight: '5px',
94
+ display: 'flex',
95
+ alignItems: 'center'
96
+ };
97
+ });
98
+
99
+ /**
100
+ * We export the raw unstyled class for testability. For public use please use the default export.
101
+ */
102
+ var CorrectAnswerToggle = exports.CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
103
+ function CorrectAnswerToggle(props) {
104
+ var _this;
105
+ (0, _classCallCheck2["default"])(this, CorrectAnswerToggle);
106
+ _this = _callSuper(this, CorrectAnswerToggle, [props]);
107
+ _this.state = {
108
+ show: props.show
109
+ };
110
+ _this.openIconRef = /*#__PURE__*/_react["default"].createRef();
111
+ _this.closedIconRef = /*#__PURE__*/_react["default"].createRef();
112
+ CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
113
+ showMessage: translator.t('common:showCorrectAnswer', {
114
+ lng: props.language
115
+ }),
116
+ hideMessage: translator.t('common:hideCorrectAnswer', {
117
+ lng: props.language
118
+ })
119
+ });
120
+ return _this;
121
+ }
122
+ (0, _inherits2["default"])(CorrectAnswerToggle, _React$Component);
123
+ return (0, _createClass2["default"])(CorrectAnswerToggle, [{
124
+ key: "onClick",
125
+ value: function onClick() {
126
+ this.props.onToggle(!this.props.toggled);
127
+ }
128
+ }, {
129
+ key: "onTouch",
130
+ value: function onTouch(event) {
131
+ event.preventDefault(); // Prevents the default action (click event)
132
+ this.props.onToggle(!this.props.toggled);
133
+ }
134
+ }, {
135
+ key: "UNSAFE_componentWillReceiveProps",
136
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
137
+ var _this$props;
138
+ this.setState({
139
+ show: nextProps.show
140
+ });
141
+ if (nextProps.language !== ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.language)) {
142
+ CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
143
+ showMessage: translator.t('common:showCorrectAnswer', {
144
+ lng: nextProps.language
145
+ }),
146
+ hideMessage: translator.t('common:hideCorrectAnswer', {
147
+ lng: nextProps.language
148
+ })
149
+ });
150
+ }
151
+ }
152
+ }, {
153
+ key: "render",
154
+ value: function render() {
155
+ var _this$props2 = this.props,
156
+ className = _this$props2.className,
157
+ toggled = _this$props2.toggled,
158
+ hideMessage = _this$props2.hideMessage,
159
+ showMessage = _this$props2.showMessage;
160
+ return /*#__PURE__*/_react["default"].createElement(StyledRoot, {
161
+ className: className
162
+ }, /*#__PURE__*/_react["default"].createElement(_expander["default"], {
163
+ show: this.state.show
164
+ }, /*#__PURE__*/_react["default"].createElement(StyledContent, {
165
+ onClick: this.onClick.bind(this),
166
+ onTouchEnd: this.onTouch.bind(this)
167
+ }, /*#__PURE__*/_react["default"].createElement(StyledIconHolder, null, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
168
+ nodeRef: this.openIconRef,
169
+ timeout: 400,
170
+ "in": toggled,
171
+ exit: !toggled,
172
+ classNames: {
173
+ enter: 'enter',
174
+ enterActive: 'enter-active',
175
+ exit: 'exit',
176
+ exitActive: 'exit-active'
177
+ }
178
+ }, /*#__PURE__*/_react["default"].createElement(StyledIcon, {
179
+ ref: this.openIconRef
180
+ }, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
181
+ open: toggled,
182
+ key: "correct-open"
183
+ }))), /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
184
+ nodeRef: this.closedIconRef,
185
+ timeout: 5000,
186
+ "in": !toggled,
187
+ exit: toggled,
188
+ classNames: {
189
+ enter: 'enter',
190
+ enterActive: 'enter-active',
191
+ exit: 'exit',
192
+ exitActive: 'exit-active'
193
+ }
194
+ }, /*#__PURE__*/_react["default"].createElement(StyledIcon, {
195
+ ref: this.closedIconRef
196
+ }, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
197
+ open: toggled,
198
+ key: "correct-closed"
199
+ })))), /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
200
+ "false": true
201
+ }, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
202
+ "aria-hidden": !this.state.show
203
+ }, toggled ? hideMessage : showMessage)))));
204
+ }
205
+ }]);
206
+ }(_react["default"].Component);
207
+ (0, _defineProperty2["default"])(CorrectAnswerToggle, "propTypes", {
208
+ onToggle: _propTypes["default"].func,
209
+ toggled: _propTypes["default"].bool,
210
+ show: _propTypes["default"].bool,
211
+ hideMessage: _propTypes["default"].string,
212
+ showMessage: _propTypes["default"].string,
213
+ className: _propTypes["default"].string,
214
+ language: _propTypes["default"].string
215
+ });
216
+ (0, _defineProperty2["default"])(CorrectAnswerToggle, "defaultProps", {
217
+ showMessage: 'Show correct answer',
218
+ hideMessage: 'Hide correct answer',
219
+ show: false,
220
+ toggled: false
221
+ });
222
+ var _default = exports["default"] = CorrectAnswerToggle;
223
+ //# 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 </Styled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S,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.35+086496dd",
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.35+086496dd",
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": "086496dd2bf934512555e4e84aa12847b3df4bf3"
40
40
  }