@pie-lib/correct-answer-toggle 2.4.0 → 2.4.1-next.2
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/lib/index.js +19 -6
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.jsx +8 -0
package/lib/index.js
CHANGED
|
@@ -84,19 +84,32 @@ var CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
|
|
|
84
84
|
}, {
|
|
85
85
|
key: "UNSAFE_componentWillReceiveProps",
|
|
86
86
|
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
87
|
+
var _this$props;
|
|
88
|
+
|
|
87
89
|
this.setState({
|
|
88
90
|
show: nextProps.show
|
|
89
91
|
});
|
|
92
|
+
|
|
93
|
+
if (nextProps.language !== ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.language)) {
|
|
94
|
+
CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
|
|
95
|
+
showMessage: translator.t('common:showCorrectAnswer', {
|
|
96
|
+
lng: nextProps.language
|
|
97
|
+
}),
|
|
98
|
+
hideMessage: translator.t('common:hideCorrectAnswer', {
|
|
99
|
+
lng: nextProps.language
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
90
103
|
}
|
|
91
104
|
}, {
|
|
92
105
|
key: "render",
|
|
93
106
|
value: function render() {
|
|
94
|
-
var _this$
|
|
95
|
-
classes = _this$
|
|
96
|
-
className = _this$
|
|
97
|
-
toggled = _this$
|
|
98
|
-
hideMessage = _this$
|
|
99
|
-
showMessage = _this$
|
|
107
|
+
var _this$props2 = this.props,
|
|
108
|
+
classes = _this$props2.classes,
|
|
109
|
+
className = _this$props2.className,
|
|
110
|
+
toggled = _this$props2.toggled,
|
|
111
|
+
hideMessage = _this$props2.hideMessage,
|
|
112
|
+
showMessage = _this$props2.showMessage;
|
|
100
113
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
101
114
|
className: (0, _classnames["default"])(classes.root, className)
|
|
102
115
|
}, /*#__PURE__*/_react["default"].createElement(_expander["default"], {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.jsx"],"names":["translator","Translator","CorrectAnswerToggle","props","state","show","defaultProps","showMessage","t","lng","language","hideMessage","onToggle","toggled","nextProps","setState","classes","className","root","expander","content","onClick","bind","iconHolder","icon","label","React","Component","PropTypes","func","bool","string","object","isRequired","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA;AACA;AACA;;IACaE,mB;;;;;AAmBX,+BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AACXC,MAAAA,IAAI,EAAEF,KAAK,CAACE;AADD,KAAb;AAIAH,IAAAA,mBAAmB,CAACI,YAApB,mCACKJ,mBAAmB,CAACI,YADzB;AAEEC,MAAAA,WAAW,EAAEP,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC,CAFf;AAGEC,MAAAA,WAAW,EAAEX,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC;AAHf;AANiB;AAWlB;;;;WAED,mBAAU;AACR,WAAKP,KAAL,CAAWS,QAAX,CAAoB,CAAC,KAAKT,KAAL,CAAWU,OAAhC;AACD;;;WAED,0CAAiCC,SAAjC,EAA4C;AAC1C,WAAKC,QAAL,CAAc;AACZV,QAAAA,IAAI,EAAES,SAAS,CAACT;AADJ,OAAd;
|
|
1
|
+
{"version":3,"sources":["../src/index.jsx"],"names":["translator","Translator","CorrectAnswerToggle","props","state","show","defaultProps","showMessage","t","lng","language","hideMessage","onToggle","toggled","nextProps","setState","classes","className","root","expander","content","onClick","bind","iconHolder","icon","label","React","Component","PropTypes","func","bool","string","object","isRequired","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA;AACA;AACA;;IACaE,mB;;;;;AAmBX,+BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AACXC,MAAAA,IAAI,EAAEF,KAAK,CAACE;AADD,KAAb;AAIAH,IAAAA,mBAAmB,CAACI,YAApB,mCACKJ,mBAAmB,CAACI,YADzB;AAEEC,MAAAA,WAAW,EAAEP,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC,CAFf;AAGEC,MAAAA,WAAW,EAAEX,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC;AAHf;AANiB;AAWlB;;;;WAED,mBAAU;AACR,WAAKP,KAAL,CAAWS,QAAX,CAAoB,CAAC,KAAKT,KAAL,CAAWU,OAAhC;AACD;;;WAED,0CAAiCC,SAAjC,EAA4C;AAAA;;AAC1C,WAAKC,QAAL,CAAc;AACZV,QAAAA,IAAI,EAAES,SAAS,CAACT;AADJ,OAAd;;AAIA,UAAIS,SAAS,CAACJ,QAAV,qBAAuB,KAAKP,KAA5B,gDAAuB,YAAYO,QAAnC,CAAJ,EAAiD;AAC/CR,QAAAA,mBAAmB,CAACI,YAApB,mCACKJ,mBAAmB,CAACI,YADzB;AAEEC,UAAAA,WAAW,EAAEP,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAE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AvE,sBACE,gCAAC,sBAAD;AAAiB,QAAA,IAAI,EAAEH,OAAvB;AAAgC,QAAA,GAAG,EAAC,gBAApC;AAAqD,QAAA,SAAS,EAAEG,OAAO,CAACQ;AAAxE,QADF,CAJF,CADF,eASE,gCAAC,kBAAD;AAAU;AAAV,sBACE;AAAK,QAAA,SAAS,EAAER,OAAO,CAACS,KAAxB;AAA+B,uBAAa,CAAC,KAAKrB,KAAL,CAAWC;AAAxD,SACGQ,OAAO,GAAGF,WAAH,GAAiBJ,WAD3B,CADF,CATF,CADF,CADF,CADF;AAqBD;;;EA1EsCmB,kBAAMC,S;;;iCAAlCzB,mB,eACQ;AACjBU,EAAAA,QAAQ,EAAEgB,sBAAUC,IADH;AAEjBhB,EAAAA,OAAO,EAAEe,sBAAUE,IAFF;AAGjBzB,EAAAA,IAAI,EAAEuB,sBAAUE,IAHC;AAIjBnB,EAAAA,WAAW,EAAEiB,sBAAUG,MAJN;AAKjBxB,EAAAA,WAAW,EAAEqB,sBAAUG,MALN;AAMjBf,EAAAA,OAAO,EAAEY,sBAAUI,MAAV,CAAiBC,UANT;AAOjBhB,EAAAA,SAAS,EAAEW,sBAAUG,MAPJ;AAQjBrB,EAAAA,QAAQ,EAAEkB,sBAAUG;AARH,C;iCADR7B,mB,kBAYW;AACpBK,EAAAA,WAAW,EAAE,qBADO;AAEpBI,EAAAA,WAAW,EAAE,qBAFO;AAGpBN,EAAAA,IAAI,EAAE,KAHc;AAIpBQ,EAAAA,OAAO,EAAE;AAJW,C;;eAiET,yBAAWqB,kBAAX,EAAmBhC,mBAAnB,C","sourcesContent":["import styles from './styles';\nimport { withStyles } from '@material-ui/core/styles';\nimport CSSTransition from 'react-transition-group/CSSTransition';\nimport { CorrectResponse } from '@pie-lib/icons';\nimport { Readable } from '@pie-lib/render-ui';\nimport Expander from './expander';\nimport React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\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 classes: PropTypes.object.isRequired,\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\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\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 { classes, className, toggled, hideMessage, showMessage } = this.props;\n\n return (\n <div className={classNames(classes.root, className)}>\n <Expander show={this.state.show} className={classes.expander}>\n <div className={classes.content} onClick={this.onClick.bind(this)}>\n <div className={classes.iconHolder}>\n <CSSTransition timeout={400} in={toggled} exit={!toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-open\" className={classes.icon} />\n </CSSTransition>\n <CSSTransition timeout={5000} in={!toggled} exit={toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-closed\" className={classes.icon} />\n </CSSTransition>\n </div>\n <Readable false>\n <div className={classes.label} aria-hidden={!this.state.show}>\n {toggled ? hideMessage : showMessage}\n </div>\n </Readable>\n </div>\n </Expander>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectAnswerToggle);\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"version": "2.4.
|
|
14
|
+
"version": "2.4.1-next.2+fb7cedff",
|
|
15
15
|
"main": "lib/index.js",
|
|
16
16
|
"module": "src/index.jsx",
|
|
17
17
|
"scripts": {},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"react": "^16.8.1",
|
|
34
34
|
"react-dom": "^16.8.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "fb7cedffefa8c10340062ad845db115d9e2eb08b"
|
|
37
37
|
}
|
package/src/index.jsx
CHANGED
|
@@ -54,6 +54,14 @@ export class CorrectAnswerToggle extends React.Component {
|
|
|
54
54
|
this.setState({
|
|
55
55
|
show: nextProps.show,
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
if (nextProps.language !== this.props?.language) {
|
|
59
|
+
CorrectAnswerToggle.defaultProps = {
|
|
60
|
+
...CorrectAnswerToggle.defaultProps,
|
|
61
|
+
showMessage: translator.t('common:showCorrectAnswer', { lng: nextProps.language }),
|
|
62
|
+
hideMessage: translator.t('common:hideCorrectAnswer', { lng: nextProps.language }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
render() {
|