@pie-lib/correct-answer-toggle 4.0.2-next.2 → 4.0.3-next.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/dist/expander.d.ts +19 -0
- package/dist/expander.js +68 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +146 -0
- package/package.json +29 -26
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -971
- package/LICENSE.md +0 -5
- package/lib/expander.js +0 -80
- package/lib/expander.js.map +0 -1
- package/lib/index.js +0 -211
- package/lib/index.js.map +0 -1
- package/src/__tests__/index.test.jsx +0 -85
- package/src/expander.jsx +0 -75
- package/src/index.jsx +0 -177
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/correct-answer-toggle/src/expander.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
declare const Expander: {
|
|
12
|
+
(props: any): React.JSX.Element;
|
|
13
|
+
propTypes: {
|
|
14
|
+
show: PropTypes.Validator<boolean>;
|
|
15
|
+
className: PropTypes.Requireable<string>;
|
|
16
|
+
children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default Expander;
|
package/dist/expander.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { styled as e } from "@mui/material/styles";
|
|
2
|
+
import { CSSTransition as t } from "react-transition-group";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import { useRef as r } from "react";
|
|
5
|
+
import i from "prop-types";
|
|
6
|
+
//#region src/expander.tsx
|
|
7
|
+
var a = "height ease-in 300ms, opacity ease-in 300ms", o = e("div")(() => ({
|
|
8
|
+
position: "relative",
|
|
9
|
+
height: 0,
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
display: "flex",
|
|
12
|
+
visibility: "hidden",
|
|
13
|
+
width: 0,
|
|
14
|
+
"&.enter": {
|
|
15
|
+
transition: a,
|
|
16
|
+
opacity: 1,
|
|
17
|
+
height: "auto",
|
|
18
|
+
width: "auto",
|
|
19
|
+
visibility: "visible",
|
|
20
|
+
minHeight: "25px"
|
|
21
|
+
},
|
|
22
|
+
"&.enter-done": {
|
|
23
|
+
height: "auto",
|
|
24
|
+
visibility: "visible",
|
|
25
|
+
width: "auto",
|
|
26
|
+
minHeight: "25px"
|
|
27
|
+
},
|
|
28
|
+
"&.exit": {
|
|
29
|
+
transition: a,
|
|
30
|
+
opacity: 0,
|
|
31
|
+
height: 0,
|
|
32
|
+
visibility: "visible",
|
|
33
|
+
width: 0
|
|
34
|
+
},
|
|
35
|
+
"&.exit-done": {
|
|
36
|
+
opacity: 0,
|
|
37
|
+
visibility: "hidden",
|
|
38
|
+
height: 0,
|
|
39
|
+
width: 0
|
|
40
|
+
}
|
|
41
|
+
})), s = (e) => {
|
|
42
|
+
let { show: i, children: a, className: s } = e, c = r(null);
|
|
43
|
+
return /* @__PURE__ */ n(t, {
|
|
44
|
+
nodeRef: c,
|
|
45
|
+
in: i,
|
|
46
|
+
appear: !0,
|
|
47
|
+
mountOnEnter: !1,
|
|
48
|
+
timeout: 300,
|
|
49
|
+
classNames: {
|
|
50
|
+
enter: "enter",
|
|
51
|
+
enterDone: "enter-done",
|
|
52
|
+
exit: "exit",
|
|
53
|
+
exitDone: "exit-done"
|
|
54
|
+
},
|
|
55
|
+
children: /* @__PURE__ */ n(o, {
|
|
56
|
+
ref: c,
|
|
57
|
+
className: s,
|
|
58
|
+
children: a
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
s.propTypes = {
|
|
63
|
+
show: i.bool.isRequired,
|
|
64
|
+
className: i.string,
|
|
65
|
+
children: i.oneOfType([i.arrayOf(i.node), i.node]).isRequired
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { s as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/correct-answer-toggle/src/index.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
/**
|
|
12
|
+
* We export the raw unstyled class for testability. For public use please use the default export.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CorrectAnswerToggle extends React.Component {
|
|
15
|
+
static propTypes: {
|
|
16
|
+
onToggle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
toggled: PropTypes.Requireable<boolean>;
|
|
18
|
+
show: PropTypes.Requireable<boolean>;
|
|
19
|
+
hideMessage: PropTypes.Requireable<string>;
|
|
20
|
+
showMessage: PropTypes.Requireable<string>;
|
|
21
|
+
className: PropTypes.Requireable<string>;
|
|
22
|
+
language: PropTypes.Requireable<string>;
|
|
23
|
+
};
|
|
24
|
+
static defaultProps: {
|
|
25
|
+
showMessage: string;
|
|
26
|
+
hideMessage: string;
|
|
27
|
+
show: boolean;
|
|
28
|
+
toggled: boolean;
|
|
29
|
+
};
|
|
30
|
+
constructor(props: any);
|
|
31
|
+
onClick(): void;
|
|
32
|
+
onTouch(event: any): void;
|
|
33
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
34
|
+
render(): React.JSX.Element;
|
|
35
|
+
}
|
|
36
|
+
export default CorrectAnswerToggle;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import e from "./expander.js";
|
|
2
|
+
import { styled as t } from "@mui/material/styles";
|
|
3
|
+
import { CSSTransition as n } from "react-transition-group";
|
|
4
|
+
import { CorrectResponse as r } from "@pie-lib/icons";
|
|
5
|
+
import * as i from "@pie-lib/render-ui";
|
|
6
|
+
import { Readable as a, color as o } from "@pie-lib/render-ui";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import l from "react";
|
|
9
|
+
import u from "prop-types";
|
|
10
|
+
import d from "@pie-lib/translator";
|
|
11
|
+
//#region src/index.tsx
|
|
12
|
+
function f(e) {
|
|
13
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
14
|
+
}
|
|
15
|
+
function p(e, t) {
|
|
16
|
+
return !e || f(e) ? e : f(e.default) ? e.default : t && f(e[t]) ? e[t] : t && f(e[t]?.default) ? e[t].default : e;
|
|
17
|
+
}
|
|
18
|
+
var m = p(a, "Readable") || p(_.Readable, "Readable"), h = i, g = h.default, _ = g && typeof g == "object" ? g : h, { translator: v } = d, y = {
|
|
19
|
+
WebkitTouchCallout: "none",
|
|
20
|
+
WebkitUserSelect: "none",
|
|
21
|
+
KhtmlUserSelect: "none",
|
|
22
|
+
MozUserSelect: "none",
|
|
23
|
+
msUserSelect: "none",
|
|
24
|
+
userSelect: "none"
|
|
25
|
+
}, b = t("div")(() => ({
|
|
26
|
+
width: "100%",
|
|
27
|
+
cursor: "pointer"
|
|
28
|
+
})), x = t("div")(() => ({
|
|
29
|
+
margin: "0 auto",
|
|
30
|
+
textAlign: "center",
|
|
31
|
+
display: "flex"
|
|
32
|
+
})), S = t("div")(() => ({
|
|
33
|
+
width: "fit-content",
|
|
34
|
+
minWidth: "140px",
|
|
35
|
+
alignSelf: "center",
|
|
36
|
+
verticalAlign: "middle",
|
|
37
|
+
color: `var(--correct-answer-toggle-label-color, ${o.text()})`,
|
|
38
|
+
fontWeight: "normal",
|
|
39
|
+
...y
|
|
40
|
+
})), C = t("div")(() => ({
|
|
41
|
+
position: "absolute",
|
|
42
|
+
width: "25px",
|
|
43
|
+
"&.enter": { opacity: "0" },
|
|
44
|
+
"&.enter-active": {
|
|
45
|
+
opacity: "1",
|
|
46
|
+
transition: "opacity 0.3s ease-in"
|
|
47
|
+
},
|
|
48
|
+
"&.exit": { opacity: "1" },
|
|
49
|
+
"&.exit-active": {
|
|
50
|
+
opacity: "0",
|
|
51
|
+
transition: "opacity 0.3s ease-in"
|
|
52
|
+
}
|
|
53
|
+
})), w = t("div")(() => ({
|
|
54
|
+
width: "25px",
|
|
55
|
+
marginRight: "5px",
|
|
56
|
+
display: "flex",
|
|
57
|
+
alignItems: "center"
|
|
58
|
+
})), T = class t extends l.Component {
|
|
59
|
+
static propTypes = {
|
|
60
|
+
onToggle: u.func,
|
|
61
|
+
toggled: u.bool,
|
|
62
|
+
show: u.bool,
|
|
63
|
+
hideMessage: u.string,
|
|
64
|
+
showMessage: u.string,
|
|
65
|
+
className: u.string,
|
|
66
|
+
language: u.string
|
|
67
|
+
};
|
|
68
|
+
static defaultProps = {
|
|
69
|
+
showMessage: "Show correct answer",
|
|
70
|
+
hideMessage: "Hide correct answer",
|
|
71
|
+
show: !1,
|
|
72
|
+
toggled: !1
|
|
73
|
+
};
|
|
74
|
+
constructor(e) {
|
|
75
|
+
super(e), this.state = { show: e.show }, this.openIconRef = l.createRef(), this.closedIconRef = l.createRef(), t.defaultProps = {
|
|
76
|
+
...t.defaultProps,
|
|
77
|
+
showMessage: v.t("common:showCorrectAnswer", { lng: e.language }),
|
|
78
|
+
hideMessage: v.t("common:hideCorrectAnswer", { lng: e.language })
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
onClick() {
|
|
82
|
+
this.props.onToggle(!this.props.toggled);
|
|
83
|
+
}
|
|
84
|
+
onTouch(e) {
|
|
85
|
+
e.preventDefault(), this.props.onToggle(!this.props.toggled);
|
|
86
|
+
}
|
|
87
|
+
UNSAFE_componentWillReceiveProps(e) {
|
|
88
|
+
this.setState({ show: e.show }), e.language !== this.props?.language && (t.defaultProps = {
|
|
89
|
+
...t.defaultProps,
|
|
90
|
+
showMessage: v.t("common:showCorrectAnswer", { lng: e.language }),
|
|
91
|
+
hideMessage: v.t("common:hideCorrectAnswer", { lng: e.language })
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
let { className: t, toggled: i, hideMessage: a, showMessage: o } = this.props;
|
|
96
|
+
return /* @__PURE__ */ s(b, {
|
|
97
|
+
className: t,
|
|
98
|
+
children: /* @__PURE__ */ s(e, {
|
|
99
|
+
show: this.state.show,
|
|
100
|
+
children: /* @__PURE__ */ c(x, {
|
|
101
|
+
onClick: this.onClick.bind(this),
|
|
102
|
+
onTouchEnd: this.onTouch.bind(this),
|
|
103
|
+
children: [/* @__PURE__ */ c(w, { children: [/* @__PURE__ */ s(n, {
|
|
104
|
+
nodeRef: this.openIconRef,
|
|
105
|
+
timeout: 400,
|
|
106
|
+
in: i,
|
|
107
|
+
exit: !i,
|
|
108
|
+
classNames: {
|
|
109
|
+
enter: "enter",
|
|
110
|
+
enterActive: "enter-active",
|
|
111
|
+
exit: "exit",
|
|
112
|
+
exitActive: "exit-active"
|
|
113
|
+
},
|
|
114
|
+
children: /* @__PURE__ */ s(C, {
|
|
115
|
+
ref: this.openIconRef,
|
|
116
|
+
children: /* @__PURE__ */ s(r, { open: i }, "correct-open")
|
|
117
|
+
})
|
|
118
|
+
}), /* @__PURE__ */ s(n, {
|
|
119
|
+
nodeRef: this.closedIconRef,
|
|
120
|
+
timeout: 5e3,
|
|
121
|
+
in: !i,
|
|
122
|
+
exit: i,
|
|
123
|
+
classNames: {
|
|
124
|
+
enter: "enter",
|
|
125
|
+
enterActive: "enter-active",
|
|
126
|
+
exit: "exit",
|
|
127
|
+
exitActive: "exit-active"
|
|
128
|
+
},
|
|
129
|
+
children: /* @__PURE__ */ s(C, {
|
|
130
|
+
ref: this.closedIconRef,
|
|
131
|
+
children: /* @__PURE__ */ s(r, { open: i }, "correct-closed")
|
|
132
|
+
})
|
|
133
|
+
})] }), /* @__PURE__ */ s(m, {
|
|
134
|
+
false: !0,
|
|
135
|
+
children: /* @__PURE__ */ s(S, {
|
|
136
|
+
"aria-hidden": !this.state.show,
|
|
137
|
+
children: i ? a : o
|
|
138
|
+
})
|
|
139
|
+
})]
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
//#endregion
|
|
146
|
+
export { T as CorrectAnswerToggle, T as default };
|
package/package.json
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/correct-answer-toggle",
|
|
3
|
+
"version": "4.0.3-next.0",
|
|
3
4
|
"description": "A react based toggle component",
|
|
4
|
-
"license": "ISC",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"pie",
|
|
8
|
-
"mui",
|
|
9
|
-
"@mui/material"
|
|
10
|
-
],
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
|
-
"version": "4.0.2-next.2",
|
|
15
|
-
"main": "lib/index.js",
|
|
16
|
-
"module": "src/index.jsx",
|
|
17
|
-
"repository": "pie-framework/pie-lib",
|
|
18
|
-
"scripts": {},
|
|
19
5
|
"dependencies": {
|
|
20
6
|
"@emotion/react": "^11.14.0",
|
|
21
7
|
"@emotion/style": "^0.8.0",
|
|
22
8
|
"@mui/icons-material": "^7.3.4",
|
|
23
9
|
"@mui/material": "^7.3.4",
|
|
24
|
-
"@pie-lib/icons": "
|
|
25
|
-
"@pie-lib/render-ui": "
|
|
26
|
-
"@pie-lib/translator": "
|
|
10
|
+
"@pie-lib/icons": "4.0.3-next.0",
|
|
11
|
+
"@pie-lib/render-ui": "6.1.1-next.0",
|
|
12
|
+
"@pie-lib/translator": "4.0.3-next.0",
|
|
27
13
|
"lodash-es": "^4.17.23",
|
|
28
14
|
"prop-types": "^15.6.2",
|
|
29
|
-
"react-transition-group": "^4.4.5"
|
|
15
|
+
"react-transition-group": "^4.4.5",
|
|
16
|
+
"react": "^18.2.0"
|
|
30
17
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
34
26
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun x vite build && bun x tsc --emitDeclarationOnly",
|
|
33
|
+
"dev": "bun x vite",
|
|
34
|
+
"test": "bun x vitest run"
|
|
38
35
|
},
|
|
39
|
-
"
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"vite": "^8.0.1",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
40
|
+
"@types/react": "^18.2.0",
|
|
41
|
+
"@types/react-dom": "^18.2.0"
|
|
42
|
+
}
|
|
40
43
|
}
|
package/CHANGELOG.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|