@pie-lib/correct-answer-toggle 2.5.12-next.1 → 2.6.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -56
- package/NEXT.CHANGELOG.json +1 -0
- package/package.json +5 -5
- package/src/__tests__/index.test.jsx +99 -0
- package/src/expander.jsx +4 -2
- package/src/index.jsx +5 -1
- package/src/styles.js +3 -3
- package/README.md +0 -64
- package/lib/expander.js +0 -86
- package/lib/expander.js.map +0 -1
- package/lib/index.js +0 -173
- package/lib/index.js.map +0 -1
- package/lib/styles.js +0 -66
- package/lib/styles.js.map +0 -1
- package/preview.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
## [2.
|
|
6
|
+
## [2.6.1-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.1-beta.0) (2025-07-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# [2.6.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.0-beta.0) (2025-07-20)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
17
17
|
|
|
@@ -19,124 +19,82 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# [2.7.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.7.0-beta.0) (2025-07-15)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
25
25
|
|
|
26
|
+
# [2.6.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.0-beta.0) (2025-07-15)
|
|
26
27
|
|
|
28
|
+
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
27
29
|
|
|
30
|
+
## [2.5.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.10...@pie-lib/correct-answer-toggle@2.5.11) (2023-10-03)
|
|
28
31
|
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
29
33
|
|
|
30
|
-
## [2.5.
|
|
34
|
+
## [2.5.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.9...@pie-lib/correct-answer-toggle@2.5.10) (2023-10-01)
|
|
31
35
|
|
|
32
36
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
33
37
|
|
|
38
|
+
## [2.5.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.8...@pie-lib/correct-answer-toggle@2.5.9) (2023-09-27)
|
|
34
39
|
|
|
40
|
+
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
35
41
|
|
|
42
|
+
## [2.5.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.7...@pie-lib/correct-answer-toggle@2.5.8) (2023-09-27)
|
|
36
43
|
|
|
44
|
+
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
37
45
|
|
|
38
46
|
## [2.5.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.6...@pie-lib/correct-answer-toggle@2.5.7) (2023-09-25)
|
|
39
47
|
|
|
40
48
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
50
|
## [2.5.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.5...@pie-lib/correct-answer-toggle@2.5.6) (2023-09-20)
|
|
47
51
|
|
|
48
52
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
54
|
## [2.5.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.4...@pie-lib/correct-answer-toggle@2.5.5) (2023-09-20)
|
|
55
55
|
|
|
56
56
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
58
|
## [2.5.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.3...@pie-lib/correct-answer-toggle@2.5.4) (2023-09-18)
|
|
63
59
|
|
|
64
60
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
62
|
## [2.5.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.2...@pie-lib/correct-answer-toggle@2.5.3) (2023-09-14)
|
|
71
63
|
|
|
72
64
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
66
|
## [2.5.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.1...@pie-lib/correct-answer-toggle@2.5.2) (2023-08-21)
|
|
79
67
|
|
|
80
68
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
81
69
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
70
|
## [2.5.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.0...@pie-lib/correct-answer-toggle@2.5.1) (2023-08-15)
|
|
87
71
|
|
|
88
72
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
89
73
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
74
|
# [2.5.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.4.0...@pie-lib/correct-answer-toggle@2.5.0) (2023-08-14)
|
|
95
75
|
|
|
96
|
-
|
|
97
76
|
### Features
|
|
98
77
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
- update language on props change PD-2802 ([000dae9](https://github.com/pie-framework/pie-lib/commit/000dae927ed4a650bfc3fa007b2a5d891079aafd))
|
|
104
79
|
|
|
105
80
|
# [2.4.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.79...@pie-lib/correct-answer-toggle@2.4.0) (2023-08-07)
|
|
106
81
|
|
|
107
|
-
|
|
108
82
|
### Features
|
|
109
83
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
84
|
+
- **correct-answer-toggle:** add translations PD-2802 ([b53b653](https://github.com/pie-framework/pie-lib/commit/b53b653246deea3f67328b37feeb17787181e590))
|
|
115
85
|
|
|
116
86
|
## [2.3.79](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.78...@pie-lib/correct-answer-toggle@2.3.79) (2023-07-24)
|
|
117
87
|
|
|
118
88
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
119
89
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
90
|
## [2.3.78](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.77...@pie-lib/correct-answer-toggle@2.3.78) (2023-06-24)
|
|
125
91
|
|
|
126
92
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
127
93
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
94
|
## [2.3.77](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.76...@pie-lib/correct-answer-toggle@2.3.77) (2023-06-13)
|
|
133
95
|
|
|
134
96
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
135
97
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
98
|
## [2.3.76](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.75...@pie-lib/correct-answer-toggle@2.3.76) (2023-06-12)
|
|
141
99
|
|
|
142
100
|
**Note:** Version bump only for package @pie-lib/correct-answer-toggle
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
package/package.json
CHANGED
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.6.1-beta.0",
|
|
15
15
|
"main": "lib/index.js",
|
|
16
16
|
"module": "src/index.jsx",
|
|
17
17
|
"scripts": {},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@material-ui/core": "^3.8.3",
|
|
20
|
-
"@pie-lib/icons": "^2.
|
|
21
|
-
"@pie-lib/render-ui": "^4.
|
|
22
|
-
"@pie-lib/translator": "^2.
|
|
20
|
+
"@pie-lib/icons": "^2.5.1-beta.0",
|
|
21
|
+
"@pie-lib/render-ui": "^4.16.1-beta.0",
|
|
22
|
+
"@pie-lib/translator": "^2.4.1-beta.0",
|
|
23
23
|
"classnames": "^2.2.6",
|
|
24
24
|
"lodash": "^4.17.11",
|
|
25
25
|
"prop-types": "^15.6.2",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"react": "^16.8.1",
|
|
34
34
|
"react-dom": "^16.8.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
|
|
37
37
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { mount, shallow, configure } from 'enzyme';
|
|
2
|
+
|
|
3
|
+
import Expander from '../expander';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { CorrectAnswerToggle } from '../index';
|
|
6
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
7
|
+
|
|
8
|
+
configure({ adapter: new Adapter() });
|
|
9
|
+
|
|
10
|
+
describe('CorrectAnswerToggle', () => {
|
|
11
|
+
let onToggle;
|
|
12
|
+
let wrapper;
|
|
13
|
+
let sheet;
|
|
14
|
+
|
|
15
|
+
let mkWrapper = (toggled, msgs) => {
|
|
16
|
+
toggled = toggled === false ? false : true;
|
|
17
|
+
msgs = msgs || {};
|
|
18
|
+
return shallow(
|
|
19
|
+
<CorrectAnswerToggle
|
|
20
|
+
toggled={toggled}
|
|
21
|
+
classes={{
|
|
22
|
+
root: 'root',
|
|
23
|
+
label: 'label',
|
|
24
|
+
}}
|
|
25
|
+
onToggle={onToggle}
|
|
26
|
+
hideMessage={msgs.hide}
|
|
27
|
+
showMessage={msgs.show}
|
|
28
|
+
sheet={sheet}
|
|
29
|
+
/>,
|
|
30
|
+
{
|
|
31
|
+
context: {},
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
let iconStub = {};
|
|
38
|
+
|
|
39
|
+
sheet = {
|
|
40
|
+
classes: {
|
|
41
|
+
root: 'root',
|
|
42
|
+
label: 'label',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
onToggle = jest.fn();
|
|
46
|
+
wrapper = mkWrapper();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('render', () => {
|
|
50
|
+
it('has the hide message', () => {
|
|
51
|
+
let holder = wrapper.find('.label');
|
|
52
|
+
expect(holder.text()).toEqual('Hide correct answer');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('has show message when toggled is false', () => {
|
|
56
|
+
const w = mkWrapper(false);
|
|
57
|
+
let holder = w.find(`.label`);
|
|
58
|
+
expect(holder.text()).toEqual('Show correct answer');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('sets a custom hide message', () => {
|
|
62
|
+
wrapper = mkWrapper(true, { hide: 'hide!' });
|
|
63
|
+
let holder = wrapper.find('.label');
|
|
64
|
+
expect(holder.text()).toEqual('hide!');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('sets a custom show message', () => {
|
|
68
|
+
wrapper = mkWrapper(false, { show: 'show!' });
|
|
69
|
+
let holder = wrapper.find('.label');
|
|
70
|
+
expect(holder.text()).toEqual('show!');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('onClick', () => {
|
|
75
|
+
it('calls onToggle', () => {
|
|
76
|
+
wrapper
|
|
77
|
+
.find(Expander)
|
|
78
|
+
.childAt(0)
|
|
79
|
+
.simulate('click');
|
|
80
|
+
expect(onToggle.mock.calls[0][0]).toEqual(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('calls onToggle with update state', () => {
|
|
84
|
+
onToggle.mockReset();
|
|
85
|
+
wrapper
|
|
86
|
+
.find(Expander)
|
|
87
|
+
.childAt(0)
|
|
88
|
+
.simulate('click');
|
|
89
|
+
expect(onToggle.mock.calls[0][0]).toEqual(false);
|
|
90
|
+
//simulate updating the toggled prop
|
|
91
|
+
wrapper.setProps({ toggled: false });
|
|
92
|
+
wrapper
|
|
93
|
+
.find(Expander)
|
|
94
|
+
.childAt(0)
|
|
95
|
+
.simulate('click');
|
|
96
|
+
expect(onToggle.mock.calls[1][0]).toEqual(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
package/src/expander.jsx
CHANGED
|
@@ -34,14 +34,16 @@ export default withStyles(() => ({
|
|
|
34
34
|
enter: {
|
|
35
35
|
transition,
|
|
36
36
|
opacity: 1,
|
|
37
|
-
height: '
|
|
37
|
+
height: 'auto',
|
|
38
38
|
width: 'auto',
|
|
39
39
|
visibility: 'visible',
|
|
40
|
+
minHeight: '25px',
|
|
40
41
|
},
|
|
41
42
|
enterDone: {
|
|
42
|
-
height: '
|
|
43
|
+
height: 'auto',
|
|
43
44
|
visibility: 'visible',
|
|
44
45
|
width: 'auto',
|
|
46
|
+
minHeight: '25px',
|
|
45
47
|
},
|
|
46
48
|
exit: {
|
|
47
49
|
transition,
|
package/src/index.jsx
CHANGED
|
@@ -49,6 +49,10 @@ export class CorrectAnswerToggle extends React.Component {
|
|
|
49
49
|
onClick() {
|
|
50
50
|
this.props.onToggle(!this.props.toggled);
|
|
51
51
|
}
|
|
52
|
+
onTouch(event) {
|
|
53
|
+
event.preventDefault(); // Prevents the default action (click event)
|
|
54
|
+
this.props.onToggle(!this.props.toggled);
|
|
55
|
+
}
|
|
52
56
|
|
|
53
57
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
54
58
|
this.setState({
|
|
@@ -70,7 +74,7 @@ export class CorrectAnswerToggle extends React.Component {
|
|
|
70
74
|
return (
|
|
71
75
|
<div className={classNames(classes.root, className)}>
|
|
72
76
|
<Expander show={this.state.show} className={classes.expander}>
|
|
73
|
-
<div className={classes.content} onClick={this.onClick.bind(this)}>
|
|
77
|
+
<div className={classes.content} onClick={this.onClick.bind(this)} onTouchEnd={this.onTouch.bind(this)}>
|
|
74
78
|
<div className={classes.iconHolder}>
|
|
75
79
|
<CSSTransition timeout={400} in={toggled} exit={!toggled} classNames={classes}>
|
|
76
80
|
<CorrectResponse open={toggled} key="correct-open" className={classes.icon} />
|
package/src/styles.js
CHANGED
|
@@ -25,11 +25,9 @@ export default {
|
|
|
25
25
|
minWidth: '140px',
|
|
26
26
|
// eslint-disable-next-line
|
|
27
27
|
fontFamily: "'Roboto', sans-serif",
|
|
28
|
-
|
|
29
|
-
lineHeight: '25px',
|
|
28
|
+
alignSelf: 'center',
|
|
30
29
|
verticalAlign: 'middle',
|
|
31
30
|
color: `var(--correct-answer-toggle-label-color, ${color.text()})`,
|
|
32
|
-
fontSize: '15px',
|
|
33
31
|
fontWeight: 'normal',
|
|
34
32
|
},
|
|
35
33
|
noTouch,
|
|
@@ -41,6 +39,8 @@ export default {
|
|
|
41
39
|
iconHolder: {
|
|
42
40
|
width: '25px',
|
|
43
41
|
marginRight: '5px',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
44
|
},
|
|
45
45
|
enter: {
|
|
46
46
|
opacity: '0',
|
package/README.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# corespring-correct-answer-toggle
|
|
2
|
-
|
|
3
|
-
[](https://travis-ci.org/PieLabs/corespring-correct-answer-toggle)
|
|
4
|
-
|
|
5
|
-
A toggle with an icon and a label.
|
|
6
|
-
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
# Usage
|
|
10
|
-
|
|
11
|
-
You need to include this in another library that builds react aka (babel).
|
|
12
|
-
|
|
13
|
-
## Webpack
|
|
14
|
-
|
|
15
|
-
We assume that you have a loader that will load in `.less`. In the demo we use `style-loader!css-loader!less-loader`.
|
|
16
|
-
|
|
17
|
-
## Install
|
|
18
|
-
|
|
19
|
-
```shell
|
|
20
|
-
npm install
|
|
21
|
-
```
|
|
22
|
-
## Test
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
npm test
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Demo
|
|
29
|
-
|
|
30
|
-
```shell
|
|
31
|
-
cd demo
|
|
32
|
-
../node_modules/.bin/webpack-dev-server --hot --inline
|
|
33
|
-
# go to http://localhost:8080
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Usage
|
|
37
|
-
```javascript
|
|
38
|
-
|
|
39
|
-
import Toggle from 'corespring-correct-answer-toggle';
|
|
40
|
-
|
|
41
|
-
function onToggle(toggled){
|
|
42
|
-
console.log('on toggle: ', toggled);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const MyComp = (props) => {
|
|
46
|
-
return <div>
|
|
47
|
-
<Toggle
|
|
48
|
-
show={props.show}
|
|
49
|
-
onToggle={onToggle}
|
|
50
|
-
initialValue={false}/>
|
|
51
|
-
</div>;
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Release
|
|
56
|
-
|
|
57
|
-
```shell
|
|
58
|
-
gulp release
|
|
59
|
-
git checkout master
|
|
60
|
-
npm publish
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
package/lib/expander.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _styles = require("@material-ui/core/styles");
|
|
17
|
-
|
|
18
|
-
var _reactTransitionGroup = require("react-transition-group");
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
24
|
-
var Expander = function Expander(props) {
|
|
25
|
-
var classes = props.classes,
|
|
26
|
-
show = props.show,
|
|
27
|
-
children = props.children;
|
|
28
|
-
return /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
|
|
29
|
-
"in": show,
|
|
30
|
-
appear: true,
|
|
31
|
-
mountOnEnter: false,
|
|
32
|
-
timeout: 300,
|
|
33
|
-
classNames: _objectSpread({}, classes)
|
|
34
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
35
|
-
className: classes.expander
|
|
36
|
-
}, children));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
Expander.propTypes = {
|
|
40
|
-
show: _propTypes["default"].bool.isRequired,
|
|
41
|
-
className: _propTypes["default"].string,
|
|
42
|
-
classes: _propTypes["default"].object,
|
|
43
|
-
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired
|
|
44
|
-
};
|
|
45
|
-
var transition = 'height ease-in 300ms, opacity ease-in 300ms';
|
|
46
|
-
|
|
47
|
-
var _default = (0, _styles.withStyles)(function () {
|
|
48
|
-
return {
|
|
49
|
-
expander: {
|
|
50
|
-
position: 'relative',
|
|
51
|
-
height: 0,
|
|
52
|
-
overflow: 'hidden',
|
|
53
|
-
display: 'flex',
|
|
54
|
-
visibility: 'hidden',
|
|
55
|
-
width: 0
|
|
56
|
-
},
|
|
57
|
-
enter: {
|
|
58
|
-
transition: transition,
|
|
59
|
-
opacity: 1,
|
|
60
|
-
height: '25px',
|
|
61
|
-
width: 'auto',
|
|
62
|
-
visibility: 'visible'
|
|
63
|
-
},
|
|
64
|
-
enterDone: {
|
|
65
|
-
height: '25px',
|
|
66
|
-
visibility: 'visible',
|
|
67
|
-
width: 'auto'
|
|
68
|
-
},
|
|
69
|
-
exit: {
|
|
70
|
-
transition: transition,
|
|
71
|
-
opacity: 0,
|
|
72
|
-
height: 0,
|
|
73
|
-
visibility: 'visible',
|
|
74
|
-
width: 0
|
|
75
|
-
},
|
|
76
|
-
exitDone: {
|
|
77
|
-
opacity: 0,
|
|
78
|
-
visibility: 'hidden',
|
|
79
|
-
height: 0,
|
|
80
|
-
width: 0
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
})(Expander);
|
|
84
|
-
|
|
85
|
-
exports["default"] = _default;
|
|
86
|
-
//# sourceMappingURL=expander.js.map
|
package/lib/expander.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/expander.jsx"],"names":["Expander","props","classes","show","children","expander","propTypes","PropTypes","bool","isRequired","className","string","object","oneOfType","arrayOf","node","transition","position","height","overflow","display","visibility","width","enter","opacity","enterDone","exit","exitDone"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;AAC1B,MAAQC,OAAR,GAAoCD,KAApC,CAAQC,OAAR;AAAA,MAAiBC,IAAjB,GAAoCF,KAApC,CAAiBE,IAAjB;AAAA,MAAuBC,QAAvB,GAAoCH,KAApC,CAAuBG,QAAvB;AAEA,sBACE,gCAAC,mCAAD;AAAe,UAAID,IAAnB;AAAyB,IAAA,MAAM,EAAE,IAAjC;AAAuC,IAAA,YAAY,EAAE,KAArD;AAA4D,IAAA,OAAO,EAAE,GAArE;AAA0E,IAAA,UAAU,oBAAOD,OAAP;AAApF,kBACE;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACG;AAAxB,KAAmCD,QAAnC,CAD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,UAAU,EAAE,QAFJ;AAGRH,MAAAA,MAAM,EAAE,CAHA;AAIRI,MAAAA,KAAK,EAAE;AAJC;AA5BqB,GAAP;AAAA,CAAX,EAkCXtB,QAlCW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { CSSTransition } from 'react-transition-group';\n\nconst Expander = (props) => {\n const { classes, show, children } = props;\n\n return (\n <CSSTransition in={show} appear={true} mountOnEnter={false} timeout={300} classNames={{ ...classes }}>\n <div className={classes.expander}>{children}</div>\n </CSSTransition>\n );\n};\n\nExpander.propTypes = {\n show: PropTypes.bool.isRequired,\n className: PropTypes.string,\n classes: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n};\n\nconst transition = 'height ease-in 300ms, opacity ease-in 300ms';\n\nexport default withStyles(() => ({\n expander: {\n position: 'relative',\n height: 0,\n overflow: 'hidden',\n display: 'flex',\n visibility: 'hidden',\n width: 0,\n },\n enter: {\n transition,\n opacity: 1,\n height: '25px',\n width: 'auto',\n visibility: 'visible',\n },\n enterDone: {\n height: '25px',\n visibility: 'visible',\n width: 'auto',\n },\n exit: {\n transition,\n opacity: 0,\n height: 0,\n visibility: 'visible',\n width: 0,\n },\n exitDone: {\n opacity: 0,\n visibility: 'hidden',\n height: 0,\n width: 0,\n },\n}))(Expander);\n"],"file":"expander.js"}
|
package/lib/index.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.CorrectAnswerToggle = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
20
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
-
|
|
24
|
-
var _styles2 = require("@material-ui/core/styles");
|
|
25
|
-
|
|
26
|
-
var _CSSTransition = _interopRequireDefault(require("react-transition-group/CSSTransition"));
|
|
27
|
-
|
|
28
|
-
var _icons = require("@pie-lib/icons");
|
|
29
|
-
|
|
30
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
31
|
-
|
|
32
|
-
var _expander = _interopRequireDefault(require("./expander"));
|
|
33
|
-
|
|
34
|
-
var _react = _interopRequireDefault(require("react"));
|
|
35
|
-
|
|
36
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
37
|
-
|
|
38
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
39
|
-
|
|
40
|
-
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
41
|
-
|
|
42
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
-
|
|
44
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
|
-
|
|
46
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
47
|
-
|
|
48
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
|
-
|
|
50
|
-
var translator = _translator["default"].translator;
|
|
51
|
-
/**
|
|
52
|
-
* We export the raw unstyled class for testability. For public use please use the default export.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
var CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
|
|
56
|
-
(0, _inherits2["default"])(CorrectAnswerToggle, _React$Component);
|
|
57
|
-
|
|
58
|
-
var _super = _createSuper(CorrectAnswerToggle);
|
|
59
|
-
|
|
60
|
-
function CorrectAnswerToggle(props) {
|
|
61
|
-
var _this;
|
|
62
|
-
|
|
63
|
-
(0, _classCallCheck2["default"])(this, CorrectAnswerToggle);
|
|
64
|
-
_this = _super.call(this, props);
|
|
65
|
-
_this.state = {
|
|
66
|
-
show: props.show
|
|
67
|
-
};
|
|
68
|
-
CorrectAnswerToggle.defaultProps = _objectSpread(_objectSpread({}, CorrectAnswerToggle.defaultProps), {}, {
|
|
69
|
-
showMessage: translator.t('common:showCorrectAnswer', {
|
|
70
|
-
lng: props.language
|
|
71
|
-
}),
|
|
72
|
-
hideMessage: translator.t('common:hideCorrectAnswer', {
|
|
73
|
-
lng: props.language
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
return _this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
(0, _createClass2["default"])(CorrectAnswerToggle, [{
|
|
80
|
-
key: "onClick",
|
|
81
|
-
value: function onClick() {
|
|
82
|
-
this.props.onToggle(!this.props.toggled);
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
86
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
87
|
-
var _this$props;
|
|
88
|
-
|
|
89
|
-
this.setState({
|
|
90
|
-
show: nextProps.show
|
|
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
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "render",
|
|
106
|
-
value: function render() {
|
|
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;
|
|
113
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
114
|
-
className: (0, _classnames["default"])(classes.root, className)
|
|
115
|
-
}, /*#__PURE__*/_react["default"].createElement(_expander["default"], {
|
|
116
|
-
show: this.state.show,
|
|
117
|
-
className: classes.expander
|
|
118
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
119
|
-
className: classes.content,
|
|
120
|
-
onClick: this.onClick.bind(this)
|
|
121
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
122
|
-
className: classes.iconHolder
|
|
123
|
-
}, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
124
|
-
timeout: 400,
|
|
125
|
-
"in": toggled,
|
|
126
|
-
exit: !toggled,
|
|
127
|
-
classNames: classes
|
|
128
|
-
}, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
|
|
129
|
-
open: toggled,
|
|
130
|
-
key: "correct-open",
|
|
131
|
-
className: classes.icon
|
|
132
|
-
})), /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
133
|
-
timeout: 5000,
|
|
134
|
-
"in": !toggled,
|
|
135
|
-
exit: toggled,
|
|
136
|
-
classNames: classes
|
|
137
|
-
}, /*#__PURE__*/_react["default"].createElement(_icons.CorrectResponse, {
|
|
138
|
-
open: toggled,
|
|
139
|
-
key: "correct-closed",
|
|
140
|
-
className: classes.icon
|
|
141
|
-
}))), /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
142
|
-
"false": true
|
|
143
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
144
|
-
className: classes.label,
|
|
145
|
-
"aria-hidden": !this.state.show
|
|
146
|
-
}, toggled ? hideMessage : showMessage)))));
|
|
147
|
-
}
|
|
148
|
-
}]);
|
|
149
|
-
return CorrectAnswerToggle;
|
|
150
|
-
}(_react["default"].Component);
|
|
151
|
-
|
|
152
|
-
exports.CorrectAnswerToggle = CorrectAnswerToggle;
|
|
153
|
-
(0, _defineProperty2["default"])(CorrectAnswerToggle, "propTypes", {
|
|
154
|
-
onToggle: _propTypes["default"].func,
|
|
155
|
-
toggled: _propTypes["default"].bool,
|
|
156
|
-
show: _propTypes["default"].bool,
|
|
157
|
-
hideMessage: _propTypes["default"].string,
|
|
158
|
-
showMessage: _propTypes["default"].string,
|
|
159
|
-
classes: _propTypes["default"].object.isRequired,
|
|
160
|
-
className: _propTypes["default"].string,
|
|
161
|
-
language: _propTypes["default"].string
|
|
162
|
-
});
|
|
163
|
-
(0, _defineProperty2["default"])(CorrectAnswerToggle, "defaultProps", {
|
|
164
|
-
showMessage: 'Show correct answer',
|
|
165
|
-
hideMessage: 'Hide correct answer',
|
|
166
|
-
show: false,
|
|
167
|
-
toggled: false
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
var _default = (0, _styles2.withStyles)(_styles["default"])(CorrectAnswerToggle);
|
|
171
|
-
|
|
172
|
-
exports["default"] = _default;
|
|
173
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,WA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,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/lib/styles.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.animationStyles = void 0;
|
|
7
|
-
|
|
8
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
9
|
-
|
|
10
|
-
var noTouch = {
|
|
11
|
-
'-webkit-touchCcallout': 'none',
|
|
12
|
-
'-webkit-user-select': 'none',
|
|
13
|
-
'-khtml-user-select': 'none',
|
|
14
|
-
'-moz-user-select': 'none',
|
|
15
|
-
'-ms-user-select': 'none',
|
|
16
|
-
'user-select': 'none'
|
|
17
|
-
};
|
|
18
|
-
var _default = {
|
|
19
|
-
root: {
|
|
20
|
-
width: '100%',
|
|
21
|
-
cursor: 'pointer'
|
|
22
|
-
},
|
|
23
|
-
content: {
|
|
24
|
-
margin: '0 auto',
|
|
25
|
-
textAlign: 'center',
|
|
26
|
-
display: 'flex'
|
|
27
|
-
},
|
|
28
|
-
label: Object.assign({
|
|
29
|
-
width: 'fit-content',
|
|
30
|
-
minWidth: '140px',
|
|
31
|
-
// eslint-disable-next-line
|
|
32
|
-
fontFamily: "'Roboto', sans-serif",
|
|
33
|
-
height: '25px',
|
|
34
|
-
lineHeight: '25px',
|
|
35
|
-
verticalAlign: 'middle',
|
|
36
|
-
color: "var(--correct-answer-toggle-label-color, ".concat(_renderUi.color.text(), ")"),
|
|
37
|
-
fontSize: '15px',
|
|
38
|
-
fontWeight: 'normal'
|
|
39
|
-
}, noTouch),
|
|
40
|
-
icon: {
|
|
41
|
-
position: 'absolute',
|
|
42
|
-
width: '25px'
|
|
43
|
-
},
|
|
44
|
-
iconHolder: {
|
|
45
|
-
width: '25px',
|
|
46
|
-
marginRight: '5px'
|
|
47
|
-
},
|
|
48
|
-
enter: {
|
|
49
|
-
opacity: '0'
|
|
50
|
-
},
|
|
51
|
-
enterActive: {
|
|
52
|
-
opacity: '1',
|
|
53
|
-
transition: 'opacity 0.3s ease-in'
|
|
54
|
-
},
|
|
55
|
-
exit: {
|
|
56
|
-
opacity: '1'
|
|
57
|
-
},
|
|
58
|
-
exitActive: {
|
|
59
|
-
opacity: '0',
|
|
60
|
-
transition: 'opacity 0.3s ease-in'
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports["default"] = _default;
|
|
64
|
-
var animationStyles = {};
|
|
65
|
-
exports.animationStyles = animationStyles;
|
|
66
|
-
//# sourceMappingURL=styles.js.map
|
package/lib/styles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/styles.js"],"names":["noTouch","root","width","cursor","content","margin","textAlign","display","label","Object","assign","minWidth","fontFamily","height","lineHeight","verticalAlign","color","text","fontSize","fontWeight","icon","position","iconHolder","marginRight","enter","opacity","enterActive","transition","exit","exitActive","animationStyles"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,OAAO,GAAG;AACd,2BAAyB,MADX;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EAAE;AAFF;AA3CC,C;;AAiDR,IAAMG,eAAe,GAAG,EAAxB","sourcesContent":["import { color } from '@pie-lib/render-ui';\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\nexport default {\n root: {\n width: '100%',\n cursor: 'pointer',\n },\n content: {\n margin: '0 auto',\n textAlign: 'center',\n display: 'flex',\n },\n label: Object.assign(\n {\n width: 'fit-content',\n minWidth: '140px',\n // eslint-disable-next-line\n fontFamily: \"'Roboto', sans-serif\",\n height: '25px',\n lineHeight: '25px',\n verticalAlign: 'middle',\n color: `var(--correct-answer-toggle-label-color, ${color.text()})`,\n fontSize: '15px',\n fontWeight: 'normal',\n },\n noTouch,\n ),\n icon: {\n position: 'absolute',\n width: '25px',\n },\n iconHolder: {\n width: '25px',\n marginRight: '5px',\n },\n enter: {\n opacity: '0',\n },\n enterActive: {\n opacity: '1',\n transition: 'opacity 0.3s ease-in',\n },\n exit: {\n opacity: '1',\n },\n exitActive: {\n opacity: '0',\n transition: 'opacity 0.3s ease-in',\n },\n};\n\nexport const animationStyles = {};\n"],"file":"styles.js"}
|
package/preview.png
DELETED
|
Binary file
|