@pie-lib/text-select 4.0.8-next.20261109072207 → 4.0.8-next.20261109085818

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 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/ar.ts
2
+ var e = {
3
+ correctAnswerSelected: "صحيح",
4
+ incorrectSelection: "تحديد غير صحيح",
5
+ correctAnswerNotSelected: "إجابة صحيحة لم تُحدَّد",
6
+ key: "مفتاح الرموز",
7
+ textGroup: "نص قابل للتحديد",
8
+ textGroupWithLimit: "نص قابل للتحديد، حدِّد ما يصل إلى {max}",
9
+ tokenPosition: "{index} من {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/cy.ts
2
+ var e = {
3
+ correctAnswerSelected: "Cywir",
4
+ incorrectSelection: "Dewis anghywir",
5
+ correctAnswerNotSelected: "Ateb cywir heb ei ddewis",
6
+ key: "Allwedd",
7
+ textGroup: "Testun y gellir ei ddewis",
8
+ textGroupWithLimit: "Testun y gellir ei ddewis, dewiswch hyd at {max}",
9
+ tokenPosition: "{index} o {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/en-AU.ts
2
+ var e = {
3
+ correctAnswerSelected: "Correct",
4
+ incorrectSelection: "Incorrect Selection",
5
+ correctAnswerNotSelected: "Correct Answer Not Selected",
6
+ key: "Key",
7
+ textGroup: "Selectable text",
8
+ textGroupWithLimit: "Selectable text, select up to {max}",
9
+ tokenPosition: "{index} of {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/en-GB.ts
2
+ var e = {
3
+ correctAnswerSelected: "Correct",
4
+ incorrectSelection: "Incorrect Selection",
5
+ correctAnswerNotSelected: "Correct Answer Not Selected",
6
+ key: "Key",
7
+ textGroup: "Selectable text",
8
+ textGroupWithLimit: "Selectable text, select up to {max}",
9
+ tokenPosition: "{index} of {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,19 @@
1
+ /** The interface strings `@pie-lib/text-select` renders; the source for every other locale. */
2
+ declare const _default: {
3
+ /**
4
+ * Evaluate markings, shown in the legend and given to each marked token as its description.
5
+ * `correctAnswerSelected` reads "Correct": the legend's check icon carries the rest.
6
+ */
7
+ correctAnswerSelected: string;
8
+ incorrectSelection: string;
9
+ correctAnswerNotSelected: string;
10
+ /** Title of the legend. */
11
+ key: string;
12
+ /** Accessible name of the group of selectable text. */
13
+ textGroup: string;
14
+ /** The same group's name when the item limits the number of selections. */
15
+ textGroupWithLimit: string;
16
+ /** Description of a selectable token, by its position in the keyboard sequence. */
17
+ tokenPosition: string;
18
+ };
19
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/en-US.ts
2
+ var e = {
3
+ correctAnswerSelected: "Correct",
4
+ incorrectSelection: "Incorrect Selection",
5
+ correctAnswerNotSelected: "Correct Answer Not Selected",
6
+ key: "Key",
7
+ textGroup: "Selectable text",
8
+ textGroupWithLimit: "Selectable text, select up to {max}",
9
+ tokenPosition: "{index} of {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/es.ts
2
+ var e = {
3
+ correctAnswerSelected: "Respuesta Correcta",
4
+ incorrectSelection: "Selección Incorrecta",
5
+ correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
6
+ key: "Clave",
7
+ textGroup: "Texto seleccionable",
8
+ textGroupWithLimit: "Texto seleccionable, selecciona hasta {max}",
9
+ tokenPosition: "{index} de {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/fr.ts
2
+ var e = {
3
+ correctAnswerSelected: "Correct",
4
+ incorrectSelection: "Sélection incorrecte",
5
+ correctAnswerNotSelected: "Réponse correcte non sélectionnée",
6
+ key: "Légende",
7
+ textGroup: "Texte sélectionnable",
8
+ textGroupWithLimit: "Texte sélectionnable, sélection jusqu'à {max}",
9
+ tokenPosition: "{index} sur {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,9 @@
1
+ export declare const catalogs: import("@pie-element/shared-i18n").Catalogs<{
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ }>;
@@ -0,0 +1,67 @@
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/text-select",
6
+ source: e,
7
+ loaders: {
8
+ es: () => import(
9
+ /* webpackMode: "eager" */
10
+ "./es.js"
11
+ ),
12
+ "th-TH": () => import(
13
+ /* webpackMode: "eager" */
14
+ "./th-TH.js"
15
+ ),
16
+ "en-GB": () => import(
17
+ /* webpackMode: "eager" */
18
+ "./en-GB.js"
19
+ ),
20
+ "en-AU": () => import(
21
+ /* webpackMode: "eager" */
22
+ "./en-AU.js"
23
+ ),
24
+ fr: () => import(
25
+ /* webpackMode: "eager" */
26
+ "./fr.js"
27
+ ),
28
+ ar: () => import(
29
+ /* webpackMode: "eager" */
30
+ "./ar.js"
31
+ ),
32
+ pt: () => import(
33
+ /* webpackMode: "eager" */
34
+ "./pt.js"
35
+ ),
36
+ ko: () => import(
37
+ /* webpackMode: "eager" */
38
+ "./ko.js"
39
+ ),
40
+ ja: () => import(
41
+ /* webpackMode: "eager" */
42
+ "./ja.js"
43
+ ),
44
+ zh: () => import(
45
+ /* webpackMode: "eager" */
46
+ "./zh.js"
47
+ ),
48
+ cy: () => import(
49
+ /* webpackMode: "eager" */
50
+ "./cy.js"
51
+ ),
52
+ sv: () => import(
53
+ /* webpackMode: "eager" */
54
+ "./sv.js"
55
+ ),
56
+ "nl-NL": () => import(
57
+ /* webpackMode: "eager" */
58
+ "./nl-NL.js"
59
+ ),
60
+ ro: () => import(
61
+ /* webpackMode: "eager" */
62
+ "./ro.js"
63
+ )
64
+ }
65
+ });
66
+ //#endregion
67
+ export { n as catalogs };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/ja.ts
2
+ var e = {
3
+ correctAnswerSelected: "正解",
4
+ incorrectSelection: "誤った選択",
5
+ correctAnswerNotSelected: "選択されていない正解",
6
+ key: "凡例",
7
+ textGroup: "選択できるテキスト",
8
+ textGroupWithLimit: "選択できるテキスト(最大{max}個まで選択)",
9
+ tokenPosition: "{total}個中{index}番目"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/ko.ts
2
+ var e = {
3
+ correctAnswerSelected: "정답",
4
+ incorrectSelection: "잘못된 선택",
5
+ correctAnswerNotSelected: "선택하지 않은 정답",
6
+ key: "범례",
7
+ textGroup: "선택 가능한 텍스트",
8
+ textGroupWithLimit: "선택 가능한 텍스트, 최대 {max}개 선택",
9
+ tokenPosition: "{total}개 중 {index}번째"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/nl-NL.ts
2
+ var e = {
3
+ correctAnswerSelected: "Juist",
4
+ incorrectSelection: "Onjuiste selectie",
5
+ correctAnswerNotSelected: "Juist antwoord niet geselecteerd",
6
+ key: "Legenda",
7
+ textGroup: "Selecteerbare tekst",
8
+ textGroupWithLimit: "Selecteerbare tekst, selecteer maximaal {max}",
9
+ tokenPosition: "{index} van {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/pt.ts
2
+ var e = {
3
+ correctAnswerSelected: "Correto",
4
+ incorrectSelection: "Seleção incorreta",
5
+ correctAnswerNotSelected: "Resposta correta não selecionada",
6
+ key: "Legenda",
7
+ textGroup: "Texto selecionável",
8
+ textGroupWithLimit: "Texto selecionável, selecione até {max}",
9
+ tokenPosition: "{index} de {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/ro.ts
2
+ var e = {
3
+ correctAnswerSelected: "Corect",
4
+ incorrectSelection: "Selecție greșită",
5
+ correctAnswerNotSelected: "Răspuns corect neselectat",
6
+ key: "Legendă",
7
+ textGroup: "Text selectabil",
8
+ textGroupWithLimit: "Text selectabil, selectează cel mult {max}",
9
+ tokenPosition: "{index} din {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/sv.ts
2
+ var e = {
3
+ correctAnswerSelected: "Rätt",
4
+ incorrectSelection: "Felaktig markering",
5
+ correctAnswerNotSelected: "Rätt svar inte markerat",
6
+ key: "Teckenförklaring",
7
+ textGroup: "Markerbar text",
8
+ textGroupWithLimit: "Markerbar text, markera upp till {max}",
9
+ tokenPosition: "{index} av {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/th-TH.ts
2
+ var e = {
3
+ correctAnswerSelected: "ถูกต้อง",
4
+ incorrectSelection: "การเลือกที่ไม่ถูกต้อง",
5
+ correctAnswerNotSelected: "คำตอบที่ถูกต้องที่ไม่ได้เลือก",
6
+ key: "คำอธิบายสัญลักษณ์",
7
+ textGroup: "ข้อความที่เลือกได้",
8
+ textGroupWithLimit: "ข้อความที่เลือกได้ เลือกได้สูงสุด {max} รายการ",
9
+ tokenPosition: "{index} จาก {total}"
10
+ };
11
+ //#endregion
12
+ export { e as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ correctAnswerSelected: string;
3
+ incorrectSelection: string;
4
+ correctAnswerNotSelected: string;
5
+ key: string;
6
+ textGroup: string;
7
+ textGroupWithLimit: string;
8
+ tokenPosition: string;
9
+ };
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ //#region src/i18n/zh.ts
2
+ var e = {
3
+ correctAnswerSelected: "正确",
4
+ incorrectSelection: "错误选择",
5
+ correctAnswerNotSelected: "未选择的正确答案",
6
+ key: "图例",
7
+ textGroup: "可选文本",
8
+ textGroupWithLimit: "可选文本,最多选择 {max} 项",
9
+ tokenPosition: "第 {index} 项,共 {total} 项"
10
+ };
11
+ //#endregion
12
+ export { e as default };
package/dist/legend.js CHANGED
@@ -1,12 +1,12 @@
1
- import "react";
2
- import { styled as e } from "@mui/material/styles";
3
- import { color as t } from "@pie-lib/render-ui";
4
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
- import i from "@mui/icons-material/Check";
6
- import a from "@mui/icons-material/Close";
7
- import o from "@pie-lib/translator";
1
+ import { catalogs as e } from "./i18n/index.js";
2
+ import { useReducer as t } from "react";
3
+ import { styled as n } from "@mui/material/styles";
4
+ import { color as r } from "@pie-lib/render-ui";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import o from "@mui/icons-material/Check";
7
+ import s from "@mui/icons-material/Close";
8
8
  //#region src/legend.tsx
9
- var { translator: s } = o, c = `1px solid ${t.v("pie")("border-light", "lightgrey")}`, l = e("div")(({ theme: e }) => ({
9
+ var c = `1px solid ${r.v("pie")("border-light", "lightgrey")}`, l = n("div")(({ theme: e }) => ({
10
10
  display: "flex",
11
11
  flexDirection: "row",
12
12
  alignItems: "center",
@@ -16,49 +16,49 @@ var { translator: s } = o, c = `1px solid ${t.v("pie")("border-light", "lightgre
16
16
  paddingBottom: e.spacing(1),
17
17
  paddingTop: e.spacing(1),
18
18
  marginBottom: e.spacing(1)
19
- })), u = e("span")(({ theme: e }) => ({
19
+ })), u = n("span")(({ theme: e }) => ({
20
20
  fontSize: "14px",
21
21
  fontWeight: "bold",
22
- color: t.text(),
22
+ color: r.text(),
23
23
  marginLeft: e.spacing(1)
24
- })), d = e("div")(() => ({
24
+ })), d = n("div")(() => ({
25
25
  position: "relative",
26
26
  padding: "4px",
27
27
  fontSize: "14px",
28
28
  borderRadius: "4px"
29
- })), f = e(d)(() => ({ border: `${t.correctTertiary()} solid 2px` })), p = e(d)(() => ({ border: `${t.incorrectWithIcon()} solid 2px` })), m = e(d)(() => ({ border: `${t.incorrectWithIcon()} dashed 2px` })), h = {
30
- color: t.white(),
29
+ })), f = n(d)(() => ({ border: `${r.correctTertiary()} solid 2px` })), p = n(d)(() => ({ border: `${r.incorrectWithIcon()} solid 2px` })), m = n(d)(() => ({ border: `${r.incorrectWithIcon()} dashed 2px` })), h = {
30
+ color: r.white(),
31
31
  position: "absolute",
32
32
  top: "-8px",
33
33
  left: "-8px",
34
34
  borderRadius: "50%",
35
35
  fontSize: "12px",
36
36
  padding: "2px"
37
- }, g = e(i)(() => ({
37
+ }, g = n(o)(() => ({
38
38
  ...h,
39
- backgroundColor: t.correctTertiary()
40
- })), _ = e(a)(() => ({
39
+ backgroundColor: r.correctTertiary()
40
+ })), _ = n(s)(() => ({
41
41
  ...h,
42
- backgroundColor: t.incorrectWithIcon()
43
- })), v = ({ language: e, showOnlyCorrect: t }) => {
44
- let i = [
42
+ backgroundColor: r.incorrectWithIcon()
43
+ })), v = ({ language: n, showOnlyCorrect: r }) => {
44
+ let [, o] = t((e) => e + 1, 0), s = e.forLocale(n, o), c = [
45
45
  {
46
46
  Icon: g,
47
- label: s.t("selectText.correctAnswerSelected", { lng: e }),
47
+ label: s.t("correctAnswerSelected"),
48
48
  Container: f
49
49
  },
50
50
  {
51
51
  Icon: _,
52
- label: s.t("selectText.incorrectSelection", { lng: e }),
52
+ label: s.t("incorrectSelection"),
53
53
  Container: p
54
54
  },
55
55
  {
56
56
  Icon: _,
57
- label: s.t("selectText.correctAnswerNotSelected", { lng: e }),
57
+ label: s.t("correctAnswerNotSelected"),
58
58
  Container: m
59
59
  }
60
60
  ];
61
- return t && i.splice(1, 2), /* @__PURE__ */ r(l, { children: [/* @__PURE__ */ n(u, { children: s.t("selectText.key", { lng: e }) }), i.map(({ Icon: e, label: t, Container: i }, a) => /* @__PURE__ */ r(i, { children: [/* @__PURE__ */ n(e, {}), /* @__PURE__ */ n("span", { children: t })] }, a))] });
61
+ return r && c.splice(1, 2), /* @__PURE__ */ a(l, { children: [/* @__PURE__ */ i(u, { children: s.t("key") }), c.map(({ Icon: e, label: t, Container: n }, r) => /* @__PURE__ */ a(n, { children: [/* @__PURE__ */ i(e, {}), /* @__PURE__ */ i("span", { children: t })] }, r))] });
62
62
  };
63
63
  //#endregion
64
64
  export { v as Legend };
@@ -37,6 +37,17 @@ export declare class TokenSelect extends React.Component {
37
37
  componentDidMount(): void;
38
38
  getSnapshotBeforeUpdate(): number | null | undefined;
39
39
  componentDidUpdate(prevProps: any, prevState: any, focusedIndex: any): void;
40
+ /** Re-renders once the language's catalog lands, for an element that did not preload it. */
41
+ relabel: () => void;
42
+ i18n: () => import("@pie-element/shared-i18n").Translator<import("@pie-element/shared-i18n").NestedKeys<{
43
+ correctAnswerSelected: string;
44
+ incorrectSelection: string;
45
+ correctAnswerNotSelected: string;
46
+ key: string;
47
+ textGroup: string;
48
+ textGroupWithLimit: string;
49
+ tokenPosition: string;
50
+ }>>;
40
51
  groupName: () => string;
41
52
  /**
42
53
  * Build an HTML string so that non-selectable token text (which may contain arbitrary or even
@@ -1,48 +1,49 @@
1
1
  import { Token as e, TokenTypes as t } from "./token.js";
2
- import n from "react";
3
- import r from "prop-types";
4
- import { styled as i } from "@mui/material/styles";
5
- import { createUniqueId as a } from "@pie-lib/render-ui";
6
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
- import { clone as l, isEqual as u } from "@pie-element/shared-lodash";
8
- import { noSelect as d } from "@pie-lib/style-utils";
9
- import f from "debug";
10
- import { renderToString as p } from "react-dom/server";
11
- import m from "@pie-lib/translator";
2
+ import { catalogs as n } from "../i18n/index.js";
3
+ import r from "react";
4
+ import i from "prop-types";
5
+ import { styled as a } from "@mui/material/styles";
6
+ import { createUniqueId as o } from "@pie-lib/render-ui";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import { clone as u, isEqual as d } from "@pie-element/shared-lodash";
9
+ import { noSelect as f } from "@pie-lib/style-utils";
10
+ import p from "debug";
11
+ import { renderToString as m } from "react-dom/server";
12
12
  import { sanitizeModelHtml as h } from "@pie-element/shared-utils";
13
+ import { dynamicMessageKey as g } from "@pie-element/shared-i18n";
13
14
  //#region src/token-select/index.tsx
14
- var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("div")(() => ({
15
+ var _ = p("@pie-lib:text-select:token-select"), v = a("div")(() => ({
15
16
  backgroundColor: "none",
16
17
  whiteSpace: "pre",
17
- ...d(),
18
+ ...f(),
18
19
  "& p": { whiteSpace: "break-spaces" }
19
- })), y = i("div")(() => ({
20
+ })), y = a("div")(() => ({
20
21
  display: "none",
21
22
  position: "absolute",
22
23
  visibility: "hidden",
23
24
  pointerEvents: "none"
24
25
  })), b = (e = "") => e.replace(/&nbsp;/gi, "\xA0"), x = (e = "") => b(e).replace(/<\/p>\s*<p[^>]*>/gi, "\n\n").replace(/<br\s*\/?>/gi, "\n").replace(/<\/?(table|tbody|tr|td|p)[^>]*>/gi, ""), S = {
25
- correct: "selectText.correctAnswerSelected",
26
- incorrect: "selectText.incorrectSelection",
27
- missing: "selectText.correctAnswerNotSelected"
28
- }, C = (e) => e.correct === void 0 ? e.isMissing ? "missing" : void 0 : e.correct ? "correct" : "incorrect", w = (e) => e.text === "\n\n" || e.text === "\n", T = "[data-indexkey][tabindex]", E = (e) => e ? Number(e.dataset.indexkey) : void 0, D = class extends n.Component {
26
+ correct: "correctAnswerSelected",
27
+ incorrect: "incorrectSelection",
28
+ missing: "correctAnswerNotSelected"
29
+ }, C = (e) => e.correct === void 0 ? e.isMissing ? "missing" : void 0 : e.correct ? "correct" : "incorrect", w = (e) => e.text === "\n\n" || e.text === "\n", T = "[data-indexkey][tabindex]", E = (e) => e ? Number(e.dataset.indexkey) : void 0, D = class extends r.Component {
29
30
  static propTypes = {
30
- tokens: r.arrayOf(r.shape(t)).isRequired,
31
- className: r.string,
32
- onChange: r.func.isRequired,
33
- disabled: r.bool,
34
- highlightChoices: r.bool,
35
- animationsDisabled: r.bool,
36
- maxNoOfSelections: r.number,
37
- language: r.string
31
+ tokens: i.arrayOf(i.shape(t)).isRequired,
32
+ className: i.string,
33
+ onChange: i.func.isRequired,
34
+ disabled: i.bool,
35
+ highlightChoices: i.bool,
36
+ animationsDisabled: i.bool,
37
+ maxNoOfSelections: i.number,
38
+ language: i.string
38
39
  };
39
40
  static defaultProps = {
40
41
  highlightChoices: !1,
41
42
  maxNoOfSelections: 0,
42
43
  tokens: []
43
44
  };
44
- containerRef = n.createRef();
45
- idPrefix = a("text-select");
45
+ containerRef = r.createRef();
46
+ idPrefix = o("text-select");
46
47
  activeIndex = void 0;
47
48
  keyboardToggle = !1;
48
49
  operable = () => !this.props.disabled && !this.props.animationsDisabled;
@@ -56,11 +57,11 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
56
57
  n !== void 0 && (this.keyboardToggle = !1, this.toggleAt(Number(n)));
57
58
  };
58
59
  toggleAt = (e) => {
59
- let { tokens: t, animationsDisabled: n } = this.props, r = l(t), i = r[e];
60
+ let { tokens: t, animationsDisabled: n } = this.props, r = u(t), i = r[e];
60
61
  if (this.operable() && i && i.correct === void 0 && !n && !i.isMissing && !i.eliminated) {
61
62
  let { onChange: n, maxNoOfSelections: a } = this.props, o = !i.selected;
62
63
  if (a === 1 && this.selectedCount() === 1) {
63
- let a = (t || []).filter((e) => e.selected), s = r.map((e) => u(e, a[0]) ? {
64
+ let a = (t || []).filter((e) => e.selected), s = r.map((e) => d(e, a[0]) ? {
64
65
  ...e,
65
66
  selected: !1
66
67
  } : {
@@ -132,39 +133,37 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
132
133
  focusVisible: this.keyboardToggle
133
134
  });
134
135
  }
136
+ relabel = () => this.forceUpdate();
137
+ i18n = () => n.forLocale(this.props.language, this.relabel);
135
138
  groupName = () => {
136
- let { maxNoOfSelections: e, language: t } = this.props;
137
- return e > 0 ? g.t("selectText.textGroupWithLimit", {
138
- lng: t,
139
- max: e
140
- }) : g.t("selectText.textGroup", { lng: t });
139
+ let { maxNoOfSelections: e } = this.props;
140
+ return e > 0 ? this.i18n().t("textGroupWithLimit", { max: e }) : this.i18n().t("textGroup");
141
141
  };
142
142
  generateTokensInHtml = () => {
143
- let { tokens: t, disabled: n, highlightChoices: r, animationsDisabled: i, language: a } = this.props, o = this.selectedCount(), c = this.operable(), l = {}, u = (e) => c && !w(e) && (e.selected || e.selectable), d = (t || []).filter(u).length, f = 0, m = (e, t) => {
143
+ let { tokens: t, disabled: n, highlightChoices: r, animationsDisabled: i } = this.props, a = this.i18n(), o = this.selectedCount(), s = this.operable(), l = {}, u = (e) => s && !w(e) && (e.selected || e.selectable), d = (t || []).filter(u).length, f = 0, p = (e, t) => {
144
144
  let n = `${this.idPrefix}-${e}`;
145
145
  return l[n] = t, n;
146
146
  };
147
147
  return {
148
- html: (t || []).reduce((t, c, l) => {
149
- let h = !c.eliminated && (c.selected || c.selectable && this.canSelectMore(o)), _ = c.correct !== void 0 && (c.selectable || c.selected);
150
- if (c.text === "\n\n") return `${t}</p><p>`;
151
- if (c.text === "\n") return `${t}<br>`;
152
- if (u(c) || h && !n || _ || c.selected || c.isMissing || i && c.predefined) {
153
- let o = u(c), _;
154
- if (o) f += 1, _ = m(`position-${f}`, g.t("selectText.tokenPosition", {
155
- lng: a,
148
+ html: (t || []).reduce((t, s, l) => {
149
+ let h = !s.eliminated && (s.selected || s.selectable && this.canSelectMore(o)), _ = s.correct !== void 0 && (s.selectable || s.selected);
150
+ if (s.text === "\n\n") return `${t}</p><p>`;
151
+ if (s.text === "\n") return `${t}<br>`;
152
+ if (u(s) || h && !n || _ || s.selected || s.isMissing || i && s.predefined) {
153
+ let o = u(s), _;
154
+ if (o) f += 1, _ = p(`position-${f}`, a.t("tokenPosition", {
156
155
  index: f,
157
156
  total: d
158
157
  }));
159
158
  else {
160
- let e = C(c);
161
- e && (_ = m(e, g.t(S[e], { lng: a })));
159
+ let e = C(s);
160
+ e && (_ = p(e, a.t(g(S[e]))));
162
161
  }
163
- return t + `<span data-token-start="${c.start}" data-token-end="${c.end}">` + p(/* @__PURE__ */ s(e, {
162
+ return t + `<span data-token-start="${s.start}" data-token-end="${s.end}">` + m(/* @__PURE__ */ c(e, {
164
163
  disabled: n,
165
164
  index: l,
166
- ...c,
167
- text: x(c.text),
165
+ ...s,
166
+ text: x(s.text),
168
167
  selectable: h,
169
168
  highlight: r,
170
169
  animationsDisabled: i,
@@ -172,18 +171,18 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
172
171
  describedBy: _
173
172
  }, l)) + "</span>";
174
173
  }
175
- return t + b(c.text);
174
+ return t + b(s.text);
176
175
  }, "<p>") + "</p>",
177
176
  descriptions: l
178
177
  };
179
178
  };
180
179
  render() {
181
180
  let { className: t } = this.props, { html: n, descriptions: r } = this.generateTokensInHtml();
182
- return /* @__PURE__ */ c(o, { children: [
183
- /* @__PURE__ */ c(y, {
181
+ return /* @__PURE__ */ l(s, { children: [
182
+ /* @__PURE__ */ l(y, {
184
183
  "aria-hidden": "true",
185
184
  children: [
186
- /* @__PURE__ */ s(e, {
185
+ /* @__PURE__ */ c(e, {
187
186
  text: " ",
188
187
  index: -1,
189
188
  selectable: !0,
@@ -191,7 +190,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
191
190
  highlight: !1,
192
191
  animationsDisabled: !1
193
192
  }),
194
- /* @__PURE__ */ s(e, {
193
+ /* @__PURE__ */ c(e, {
195
194
  text: " ",
196
195
  index: -1,
197
196
  selectable: !0,
@@ -199,7 +198,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
199
198
  highlight: !0,
200
199
  animationsDisabled: !1
201
200
  }),
202
- /* @__PURE__ */ s(e, {
201
+ /* @__PURE__ */ c(e, {
203
202
  text: " ",
204
203
  index: -1,
205
204
  selectable: !0,
@@ -208,7 +207,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
208
207
  highlight: !1,
209
208
  animationsDisabled: !1
210
209
  }),
211
- /* @__PURE__ */ s(e, {
210
+ /* @__PURE__ */ c(e, {
212
211
  text: " ",
213
212
  index: -1,
214
213
  selectable: !0,
@@ -217,7 +216,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
217
216
  highlight: !1,
218
217
  animationsDisabled: !1
219
218
  }),
220
- /* @__PURE__ */ s(e, {
219
+ /* @__PURE__ */ c(e, {
221
220
  text: " ",
222
221
  index: -1,
223
222
  selectable: !0,
@@ -226,7 +225,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
226
225
  animationsDisabled: !0,
227
226
  predefined: !0
228
227
  }),
229
- /* @__PURE__ */ s(e, {
228
+ /* @__PURE__ */ c(e, {
230
229
  text: " ",
231
230
  index: -1,
232
231
  selectable: !0,
@@ -236,7 +235,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
236
235
  highlight: !1,
237
236
  animationsDisabled: !1
238
237
  }),
239
- /* @__PURE__ */ s(e, {
238
+ /* @__PURE__ */ c(e, {
240
239
  text: " ",
241
240
  index: -1,
242
241
  selectable: !0,
@@ -246,7 +245,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
246
245
  highlight: !1,
247
246
  animationsDisabled: !1
248
247
  }),
249
- /* @__PURE__ */ s(e, {
248
+ /* @__PURE__ */ c(e, {
250
249
  text: " ",
251
250
  index: -1,
252
251
  isMissing: !0,
@@ -256,7 +255,7 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
256
255
  })
257
256
  ]
258
257
  }),
259
- /* @__PURE__ */ s(v, {
258
+ /* @__PURE__ */ c(v, {
260
259
  ref: this.containerRef,
261
260
  className: t,
262
261
  role: "group",
@@ -266,9 +265,9 @@ var { translator: g } = m, _ = f("@pie-lib:text-select:token-select"), v = i("di
266
265
  onFocus: this.onFocus,
267
266
  dangerouslySetInnerHTML: { __html: h(n) }
268
267
  }),
269
- Object.keys(r).length > 0 && /* @__PURE__ */ s("div", {
268
+ Object.keys(r).length > 0 && /* @__PURE__ */ c("div", {
270
269
  hidden: !0,
271
- children: Object.entries(r).map(([e, t]) => /* @__PURE__ */ s("span", {
270
+ children: Object.entries(r).map(([e, t]) => /* @__PURE__ */ c("span", {
272
271
  id: e,
273
272
  children: t
274
273
  }, e))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/text-select",
3
- "version": "4.0.8-next.20261109072207",
3
+ "version": "4.0.8-next.20261109085818",
4
4
  "description": "Some react components for text selection",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,11 +13,11 @@
13
13
  "@emotion/styled": "^11.14.1",
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
+ "@pie-element/shared-i18n": "0.1.3-next.20261109082044",
16
17
  "@pie-element/shared-utils": "0.1.7-next.20261027193325",
17
18
  "@pie-framework/parse-english": "^1.0.0",
18
- "@pie-lib/render-ui": "8.0.8-next.20261106152257",
19
+ "@pie-lib/render-ui": "8.0.8-next.20261109082044",
19
20
  "@pie-lib/style-utils": "3.0.3-next.20261107131445",
20
- "@pie-lib/translator": "5.0.3-next.20261109072207",
21
21
  "debug": "^4.1.1",
22
22
  "prop-types": "^15.6.2",
23
23
  "@pie-element/shared-lodash": "0.1.4-next.20261026212738",