@pie-lib/correct-answer-toggle 5.0.6-next.20261015154938 → 5.0.6-next.20261016234357

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.
@@ -0,0 +1,6 @@
1
+ /** The interface strings `@pie-lib/correct-answer-toggle` renders; the source for every other locale. */
2
+ declare const _default: {
3
+ showCorrectAnswer: string;
4
+ hideCorrectAnswer: string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ //#region src/i18n/en-US.ts
2
+ var e = {
3
+ showCorrectAnswer: "Show correct answer",
4
+ hideCorrectAnswer: "Hide correct answer"
5
+ };
6
+ //#endregion
7
+ export { e as default };
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ showCorrectAnswer: string;
3
+ hideCorrectAnswer: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ //#region src/i18n/es.ts
2
+ var e = {
3
+ showCorrectAnswer: "Mostrar respuesta correcta",
4
+ hideCorrectAnswer: "Ocultar respuesta correcta"
5
+ };
6
+ //#endregion
7
+ export { e as default };
@@ -0,0 +1,4 @@
1
+ export declare const catalogs: import("@pie-element/shared-i18n").Catalogs<{
2
+ showCorrectAnswer: string;
3
+ hideCorrectAnswer: string;
4
+ }>;
@@ -0,0 +1,13 @@
1
+ import e from "./en-US.js";
2
+ import { defineCatalogs as t } from "@pie-element/shared-i18n";
3
+ //#region src/i18n/index.ts
4
+ var n = t({
5
+ packageName: "@pie-lib/correct-answer-toggle",
6
+ source: e,
7
+ loaders: { es: () => import(
8
+ /* webpackMode: "eager" */
9
+ "./es.js"
10
+ ) }
11
+ });
12
+ //#endregion
13
+ export { n as catalogs };
package/dist/index.d.ts CHANGED
@@ -8,18 +8,21 @@ export declare class CorrectAnswerToggle extends React.Component {
8
8
  onToggle: PropTypes.Requireable<(...args: any[]) => any>;
9
9
  toggled: PropTypes.Requireable<boolean>;
10
10
  show: PropTypes.Requireable<boolean>;
11
+ /** Overrides the localized label of the toggled state. */
11
12
  hideMessage: PropTypes.Requireable<string>;
13
+ /** Overrides the localized label of the untoggled state. */
12
14
  showMessage: PropTypes.Requireable<string>;
13
15
  className: PropTypes.Requireable<string>;
16
+ /** The item language, which the default labels follow. */
14
17
  language: PropTypes.Requireable<string>;
15
18
  };
16
19
  static defaultProps: {
17
- showMessage: string;
18
- hideMessage: string;
19
20
  show: boolean;
20
21
  toggled: boolean;
21
22
  };
22
23
  constructor(props: any);
24
+ /** Re-renders once the item language's catalog lands, for an element that did not preload it. */
25
+ relabel: () => void;
23
26
  onClick(): void;
24
27
  onTouch(event: any): void;
25
28
  UNSAFE_componentWillReceiveProps(nextProps: any): void;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
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";
2
+ import { catalogs as t } from "./i18n/index.js";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import { CSSTransition as r } from "react-transition-group";
5
+ import { CorrectResponse as i } from "@pie-lib/icons";
6
+ import * as a from "@pie-lib/render-ui";
7
+ import { Readable as o, color as s } from "@pie-lib/render-ui";
8
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
+ import u from "react";
10
+ import d from "prop-types";
11
11
  //#region src/index.tsx
12
12
  function f(e) {
13
13
  return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
@@ -15,17 +15,17 @@ function f(e) {
15
15
  function p(e, t) {
16
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
17
  }
18
- var m = i, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(a, "Readable") || p(g.Readable, "Readable"), { translator: v } = d, y = {
18
+ var m = a, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(o, "Readable") || p(g.Readable, "Readable"), v = {
19
19
  WebkitTouchCallout: "none",
20
20
  WebkitUserSelect: "none",
21
21
  KhtmlUserSelect: "none",
22
22
  MozUserSelect: "none",
23
23
  msUserSelect: "none",
24
24
  userSelect: "none"
25
- }, b = t("div")(() => ({
25
+ }, y = n("div")(() => ({
26
26
  width: "100%",
27
27
  cursor: "pointer"
28
- })), x = t("button")(() => ({
28
+ })), b = n("button")(() => ({
29
29
  margin: "0 auto",
30
30
  textAlign: "center",
31
31
  display: "flex",
@@ -38,18 +38,18 @@ var m = i, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(a, "Reada
38
38
  font: "inherit",
39
39
  cursor: "pointer",
40
40
  "&:focus-visible": {
41
- outline: `2px solid ${o.buttonFocusOutline()}`,
41
+ outline: `2px solid ${s.buttonFocusOutline()}`,
42
42
  outlineOffset: "-2px"
43
43
  }
44
- })), S = t("div")(() => ({
44
+ })), x = n("div")(() => ({
45
45
  width: "fit-content",
46
46
  minWidth: "140px",
47
47
  alignSelf: "center",
48
48
  verticalAlign: "middle",
49
- color: `var(--correct-answer-toggle-label-color, ${o.text()})`,
49
+ color: `var(--correct-answer-toggle-label-color, ${s.text()})`,
50
50
  fontWeight: "normal",
51
- ...y
52
- })), C = t("div")(() => ({
51
+ ...v
52
+ })), S = n("div")(() => ({
53
53
  position: "absolute",
54
54
  width: "25px",
55
55
  "&.enter": { opacity: "0" },
@@ -62,34 +62,29 @@ var m = i, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(a, "Reada
62
62
  opacity: "0",
63
63
  transition: "opacity 0.3s ease-in"
64
64
  }
65
- })), w = t("div")(() => ({
65
+ })), C = n("div")(() => ({
66
66
  width: "25px",
67
67
  marginRight: "5px",
68
68
  display: "flex",
69
69
  alignItems: "center"
70
- })), T = class t extends l.Component {
70
+ })), w = class extends u.Component {
71
71
  static propTypes = {
72
- onToggle: u.func,
73
- toggled: u.bool,
74
- show: u.bool,
75
- hideMessage: u.string,
76
- showMessage: u.string,
77
- className: u.string,
78
- language: u.string
72
+ onToggle: d.func,
73
+ toggled: d.bool,
74
+ show: d.bool,
75
+ hideMessage: d.string,
76
+ showMessage: d.string,
77
+ className: d.string,
78
+ language: d.string
79
79
  };
80
80
  static defaultProps = {
81
- showMessage: "Show correct answer",
82
- hideMessage: "Hide correct answer",
83
81
  show: !1,
84
82
  toggled: !1
85
83
  };
86
84
  constructor(e) {
87
- super(e), this.state = { show: e.show }, this.openIconRef = l.createRef(), this.closedIconRef = l.createRef(), t.defaultProps = {
88
- ...t.defaultProps,
89
- showMessage: v.t("common:showCorrectAnswer", { lng: e.language }),
90
- hideMessage: v.t("common:hideCorrectAnswer", { lng: e.language })
91
- };
85
+ super(e), this.state = { show: e.show }, this.openIconRef = u.createRef(), this.closedIconRef = u.createRef();
92
86
  }
87
+ relabel = () => this.forceUpdate();
93
88
  onClick() {
94
89
  this.props.onToggle(!this.props.toggled);
95
90
  }
@@ -97,58 +92,54 @@ var m = i, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(a, "Reada
97
92
  e.preventDefault(), this.props.onToggle(!this.props.toggled);
98
93
  }
99
94
  UNSAFE_componentWillReceiveProps(e) {
100
- this.setState({ show: e.show }), e.language !== this.props?.language && (t.defaultProps = {
101
- ...t.defaultProps,
102
- showMessage: v.t("common:showCorrectAnswer", { lng: e.language }),
103
- hideMessage: v.t("common:hideCorrectAnswer", { lng: e.language })
104
- });
95
+ this.setState({ show: e.show });
105
96
  }
106
97
  render() {
107
- let { className: t, toggled: i, hideMessage: a, showMessage: o } = this.props;
108
- return /* @__PURE__ */ s(b, {
109
- className: t,
110
- children: /* @__PURE__ */ s(e, {
98
+ let { className: n, toggled: a, language: o } = this.props, s = t.forLocale(o, this.relabel), u = this.props.hideMessage ?? s.t("hideCorrectAnswer"), d = this.props.showMessage ?? s.t("showCorrectAnswer");
99
+ return /* @__PURE__ */ c(y, {
100
+ className: n,
101
+ children: /* @__PURE__ */ c(e, {
111
102
  show: this.state.show,
112
- children: /* @__PURE__ */ c(x, {
103
+ children: /* @__PURE__ */ l(b, {
113
104
  type: "button",
114
- "aria-pressed": !!i,
105
+ "aria-pressed": !!a,
115
106
  onClick: this.onClick.bind(this),
116
107
  onTouchEnd: this.onTouch.bind(this),
117
- children: [/* @__PURE__ */ c(w, { children: [/* @__PURE__ */ s(n, {
108
+ children: [/* @__PURE__ */ l(C, { children: [/* @__PURE__ */ c(r, {
118
109
  nodeRef: this.openIconRef,
119
110
  timeout: 400,
120
- in: i,
121
- exit: !i,
111
+ in: a,
112
+ exit: !a,
122
113
  classNames: {
123
114
  enter: "enter",
124
115
  enterActive: "enter-active",
125
116
  exit: "exit",
126
117
  exitActive: "exit-active"
127
118
  },
128
- children: /* @__PURE__ */ s(C, {
119
+ children: /* @__PURE__ */ c(S, {
129
120
  ref: this.openIconRef,
130
- children: /* @__PURE__ */ s(r, { open: i }, "correct-open")
121
+ children: /* @__PURE__ */ c(i, { open: a }, "correct-open")
131
122
  })
132
- }), /* @__PURE__ */ s(n, {
123
+ }), /* @__PURE__ */ c(r, {
133
124
  nodeRef: this.closedIconRef,
134
125
  timeout: 5e3,
135
- in: !i,
136
- exit: i,
126
+ in: !a,
127
+ exit: a,
137
128
  classNames: {
138
129
  enter: "enter",
139
130
  enterActive: "enter-active",
140
131
  exit: "exit",
141
132
  exitActive: "exit-active"
142
133
  },
143
- children: /* @__PURE__ */ s(C, {
134
+ children: /* @__PURE__ */ c(S, {
144
135
  ref: this.closedIconRef,
145
- children: /* @__PURE__ */ s(r, { open: i }, "correct-closed")
136
+ children: /* @__PURE__ */ c(i, { open: a }, "correct-closed")
146
137
  })
147
- })] }), /* @__PURE__ */ s(_, {
138
+ })] }), /* @__PURE__ */ c(_, {
148
139
  false: !0,
149
- children: /* @__PURE__ */ s(S, {
140
+ children: /* @__PURE__ */ c(x, {
150
141
  "aria-hidden": !this.state.show,
151
- children: i ? a : o
142
+ children: a ? u : d
152
143
  })
153
144
  })]
154
145
  })
@@ -157,4 +148,4 @@ var m = i, h = m.default, g = h && typeof h == "object" ? h : m, _ = p(a, "Reada
157
148
  }
158
149
  };
159
150
  //#endregion
160
- export { T as CorrectAnswerToggle, T as default };
151
+ export { w as CorrectAnswerToggle, w as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/correct-answer-toggle",
3
- "version": "5.0.6-next.20261015154938",
3
+ "version": "5.0.6-next.20261016234357",
4
4
  "description": "A react based toggle component",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,8 +13,8 @@
13
13
  "@mui/icons-material": "^7.3.4",
14
14
  "@mui/material": "^7.3.4",
15
15
  "@pie-lib/icons": "5.0.2-next.20261006160832",
16
- "@pie-lib/render-ui": "8.0.6-next.20261015154938",
17
- "@pie-lib/translator": "5.0.2-next.20261006160832",
16
+ "@pie-lib/render-ui": "8.0.6-next.20261016234357",
17
+ "@pie-element/shared-i18n": "0.1.1-next.20261016234357",
18
18
  "prop-types": "^15.6.2",
19
19
  "react-transition-group": "^4.4.5",
20
20
  "@pie-element/shared-lodash": "0.1.3-next.20261012213240"