@uva-glass/component-library 1.62.3 → 1.62.5

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.
Files changed (47) hide show
  1. package/dist/{ListPlugin-Bb5eekAl.js → ListPlugin-B-2w9EIN.js} +2 -2
  2. package/dist/{ListPlugin-Bb5eekAl.js.map → ListPlugin-B-2w9EIN.js.map} +1 -1
  3. package/dist/RteEditor.module-XCAFrP3U.js +28 -0
  4. package/dist/RteEditor.module-XCAFrP3U.js.map +1 -0
  5. package/dist/{TablePlugin-B-Q_UBXj.js → TablePlugin-CMsi2UDH.js} +2 -2
  6. package/dist/{TablePlugin-B-Q_UBXj.js.map → TablePlugin-CMsi2UDH.js.map} +1 -1
  7. package/dist/assets/Container.css +1 -1
  8. package/dist/assets/FormInput.css +1 -1
  9. package/dist/assets/PeriodSelector.css +1 -1
  10. package/dist/assets/RteEditor.css +1 -1
  11. package/dist/assets/TableCellContextMenu.css +1 -1
  12. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  13. package/dist/components/FeedbackBox/FeedbackBox.js +2 -2
  14. package/dist/components/FeedbackBox/FeedbackBox.js.map +1 -1
  15. package/dist/components/FormInput/FormInput.js +23 -27
  16. package/dist/components/FormInput/FormInput.js.map +1 -1
  17. package/dist/components/InputField/InputField.stories.js +1 -1
  18. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  19. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  20. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  21. package/dist/components/MultiSelect/index.js +1 -1
  22. package/dist/components/PeriodSelector/PeriodSelector.js +65 -50
  23. package/dist/components/PeriodSelector/PeriodSelector.js.map +1 -1
  24. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  25. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  26. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +1 -1
  27. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +2 -2
  28. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkFrom.js +1 -1
  29. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +2 -2
  30. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +2 -2
  31. package/dist/components/RteEditor/Plugins/ListPlugin/index.js +1 -1
  32. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  33. package/dist/components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu.js +57 -43
  34. package/dist/components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu.js.map +1 -1
  35. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +2 -2
  36. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  37. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +3 -3
  38. package/dist/components/RteEditor/Plugins/index.js +2 -2
  39. package/dist/components/RteEditor/RteEditor.js +176 -179
  40. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  41. package/dist/components/RteEditor/UvaTheme/UvaTheme.js +1 -1
  42. package/dist/components/index.js +1 -1
  43. package/dist/index.js +1 -1
  44. package/dist/storyComponents/Container/Container.js +22 -22
  45. package/package.json +1 -1
  46. package/dist/RteEditor.module-BwAtWRHo.js +0 -29
  47. package/dist/RteEditor.module-BwAtWRHo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FormInput.js","sources":["../../../src/components/FormInput/FormInput.tsx"],"sourcesContent":["import clsx from 'clsx';\n\nimport styles from './FormInput.module.css';\n\nimport { Icon, Label } from 'components';\n\nexport interface FormInputProps {\n /** The id of the input element. */\n id: string;\n /** label text if empthy the label is not renderd */\n label: string;\n /** label position `top` or `left`. The default is `top`. */\n labelPosition?: 'top' | 'left';\n /** The type of the input element. */\n type?: 'text' | 'password' | 'email' | 'number';\n /** Shows red * */\n required?: boolean;\n /** error text to display if set */\n notValidatedText?: string;\n /** Returns array of selected values as number */\n onChange: (value: string) => void;\n}\n\nexport const FormInput = ({\n id,\n label,\n labelPosition = 'top',\n type = 'text',\n required = false,\n notValidatedText = '',\n onChange,\n}: FormInputProps) => {\n const blockInvalidChar = (event: React.KeyboardEvent<HTMLInputElement>) =>\n ['e', 'E', '+', '-'].includes(event.key) && event.preventDefault();\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (typeof onChange === 'function') {\n onChange(event.target.value);\n }\n };\n\n return (\n <div className={clsx(styles['form-field__container'], styles[`form-field__container--label-${labelPosition}`])}>\n {label && (\n <Label htmlFor={id} required={required}>\n {label}\n </Label>\n )}\n\n <div className={styles['form-field__input-container']}>\n <input\n id={id}\n type={type}\n {...(type === 'number' && { onKeyDown: blockInvalidChar })}\n onChange={handleChange}\n className={clsx(styles['form-field__input'], [notValidatedText !== '' && styles['form-field__input--error']])}\n />\n {notValidatedText !== '' && (\n <div className={styles['form-field__error']}>\n <Icon name=\"ExclamationTriangleFill\" size={24} />\n {notValidatedText}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["FormInput","id","label","labelPosition","type","required","notValidatedText","onChange","blockInvalidChar","event","handleChange","jsxs","clsx","styles","jsx","Label","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuBaA,IAAY,CAAC;AAAA,EACxB,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AACF,MAAsB;AACpB,QAAMC,IAAmB,CAACC,MACxB,CAAC,KAAK,KAAK,KAAK,GAAG,EAAE,SAASA,EAAM,GAAG,KAAKA,EAAM,eAAe,GAE7DC,IAAe,CAACD,MAA+C;AAC/D,IAAA,OAAOF,KAAa,cACbA,EAAAE,EAAM,OAAO,KAAK;AAAA,EAC7B;AAGF,SACG,gBAAAE,EAAA,OAAA,EAAI,WAAWC,EAAKC,EAAO,uBAAuB,GAAGA,EAAO,gCAAgCV,CAAa,EAAE,CAAC,GAC1G,UAAA;AAAA,IAAAD,KACE,gBAAAY,EAAAC,GAAA,EAAM,SAASd,GAAI,UAAAI,GACjB,UACHH,GAAA;AAAA,IAGD,gBAAAS,EAAA,OAAA,EAAI,WAAWE,EAAO,6BAA6B,GAClD,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAAb;AAAA,UACA,MAAAG;AAAA,UACC,GAAIA,MAAS,YAAY,EAAE,WAAWI,EAAiB;AAAA,UACxD,UAAUE;AAAA,UACV,WAAWE,EAAKC,EAAO,mBAAmB,GAAG,CAACP,MAAqB,MAAMO,EAAO,0BAA0B,CAAC,CAAC;AAAA,QAAA;AAAA,MAC9G;AAAA,MACCP,MAAqB,MACpB,gBAAAK,EAAC,SAAI,WAAWE,EAAO,mBAAmB,GACxC,UAAA;AAAA,QAAA,gBAAAC,EAACE,GAAK,EAAA,MAAK,2BAA0B,MAAM,IAAI;AAAA,QAC9CV;AAAA,MAAA,GACH;AAAA,IAAA,GAEJ;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"FormInput.js","sources":["../../../src/components/FormInput/FormInput.tsx"],"sourcesContent":["import clsx from 'clsx';\n\nimport styles from './FormInput.module.css';\n\nimport { FeedbackBox, Label } from 'components';\n\nexport interface FormInputProps {\n /** The id of the input element. */\n id: string;\n /** label text if empthy the label is not renderd */\n label: string;\n /** label position `top` or `left`. The default is `top`. */\n labelPosition?: 'top' | 'left';\n /** The type of the input element. */\n type?: 'text' | 'password' | 'email' | 'number';\n /** Shows red * */\n required?: boolean;\n /** error text to display if set */\n notValidatedText?: string;\n /** Returns array of selected values as number */\n onChange: (value: string) => void;\n}\n\nexport const FormInput = ({\n id,\n label,\n labelPosition = 'top',\n type = 'text',\n required = false,\n notValidatedText = '',\n onChange,\n}: FormInputProps) => {\n const blockInvalidChar = (event: React.KeyboardEvent<HTMLInputElement>) =>\n ['e', 'E', '+', '-'].includes(event.key) && event.preventDefault();\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (typeof onChange === 'function') {\n onChange(event.target.value);\n }\n };\n\n return (\n <div className={clsx(styles['form-field__container'], styles[`form-field__container--label-${labelPosition}`])}>\n {label && (\n <Label htmlFor={id} required={required}>\n {label}\n </Label>\n )}\n\n <div className={styles['form-field__input-container']}>\n <input\n id={id}\n type={type}\n {...(type === 'number' && { onKeyDown: blockInvalidChar })}\n onChange={handleChange}\n className={clsx(styles['form-field__input'], [notValidatedText !== '' && styles['form-field__input--error']])}\n />\n {notValidatedText !== '' && <FeedbackBox level=\"error\" feedback={notValidatedText} />}\n </div>\n </div>\n );\n};\n"],"names":["FormInput","id","label","labelPosition","type","required","notValidatedText","onChange","blockInvalidChar","event","handleChange","jsxs","clsx","styles","jsx","Label","FeedbackBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuBaA,IAAY,CAAC;AAAA,EACxB,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AACF,MAAsB;AACpB,QAAMC,IAAmB,CAACC,MACxB,CAAC,KAAK,KAAK,KAAK,GAAG,EAAE,SAASA,EAAM,GAAG,KAAKA,EAAM,eAAe,GAE7DC,IAAe,CAACD,MAA+C;AAC/D,IAAA,OAAOF,KAAa,cACbA,EAAAE,EAAM,OAAO,KAAK;AAAA,EAC7B;AAGF,SACG,gBAAAE,EAAA,OAAA,EAAI,WAAWC,EAAKC,EAAO,uBAAuB,GAAGA,EAAO,gCAAgCV,CAAa,EAAE,CAAC,GAC1G,UAAA;AAAA,IAAAD,KACE,gBAAAY,EAAAC,GAAA,EAAM,SAASd,GAAI,UAAAI,GACjB,UACHH,GAAA;AAAA,IAGD,gBAAAS,EAAA,OAAA,EAAI,WAAWE,EAAO,6BAA6B,GAClD,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAAb;AAAA,UACA,MAAAG;AAAA,UACC,GAAIA,MAAS,YAAY,EAAE,WAAWI,EAAiB;AAAA,UACxD,UAAUE;AAAA,UACV,WAAWE,EAAKC,EAAO,mBAAmB,GAAG,CAACP,MAAqB,MAAMO,EAAO,0BAA0B,CAAC,CAAC;AAAA,QAAA;AAAA,MAC9G;AAAA,MACCP,MAAqB,MAAM,gBAAAQ,EAACE,KAAY,OAAM,SAAQ,UAAUV,GAAkB;AAAA,IAAA,GACrF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -15,7 +15,7 @@ import "../GridRow/GridRow.js";
15
15
  import "../IconButton/IconButton.js";
16
16
  import "../Input/Input.js";
17
17
  import "react-router-dom";
18
- import "../../TablePlugin-B-Q_UBXj.js";
18
+ import "../../TablePlugin-CMsi2UDH.js";
19
19
  import "../RteEditor/Providers/LanguageProvider.js";
20
20
  import "../RteEditor/hooks/components/Flyout.js";
21
21
  import "../SelectListbox/SelectListbox.js";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../clsx-OuTLNxxd.js";
3
3
  import "../../MultiSelectItem-D9PxdX43.js";
4
- import { M as p } from "../../TablePlugin-B-Q_UBXj.js";
4
+ import { M as p } from "../../TablePlugin-CMsi2UDH.js";
5
5
  export {
6
6
  p as MultiSelect
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import { jsxs as S, jsx as r } from "react/jsx-runtime";
2
2
  import { fn as d } from "../../index-C9QoqAAt.js";
3
3
  import { useState as p } from "react";
4
- import { M as e } from "../../TablePlugin-B-Q_UBXj.js";
4
+ import { M as e } from "../../TablePlugin-CMsi2UDH.js";
5
5
  import { Container as M } from "../../storyComponents/Container/Container.js";
6
6
  const C = `
7
7
  // MultiSelectHeader can be added optionally
@@ -14,7 +14,7 @@ import "../../IconButton/IconButton.js";
14
14
  import "../../Input/Input.js";
15
15
  import "../../InputField/InputField.js";
16
16
  import "react-router-dom";
17
- import { a as q } from "../../../TablePlugin-B-Q_UBXj.js";
17
+ import { a as q } from "../../../TablePlugin-CMsi2UDH.js";
18
18
  import "../../RteEditor/Providers/LanguageProvider.js";
19
19
  import "../../RteEditor/hooks/components/Flyout.js";
20
20
  import "../../SelectListbox/SelectListbox.js";
@@ -1,4 +1,4 @@
1
- import { M as l } from "../../TablePlugin-B-Q_UBXj.js";
1
+ import { M as l } from "../../TablePlugin-CMsi2UDH.js";
2
2
  export {
3
3
  l as MultiSelect
4
4
  };
@@ -1,74 +1,89 @@
1
- import { jsxs as i, jsx as l } from "react/jsx-runtime";
2
- import { c as v } from "../../clsx-OuTLNxxd.js";
3
- import { useRef as N, useState as M, useEffect as $ } from "react";
4
- import { Label as k } from "../Label/Label.js";
5
- import { CheckboxButtonBar as I } from "../CheckboxButtonBar/CheckboxButtonBar.js";
6
- import { Icon as T } from "../Icon/Icon.js";
7
- import '../../assets/PeriodSelector.css';const c = {
8
- "period-selector__container": "_period-selector__container_1on0y_1",
9
- "period-selector__container--label-left": "_period-selector__container--label-left_1on0y_6",
10
- "period-selector__container--label-top": "_period-selector__container--label-top_1on0y_12",
11
- "period-selector__selector-container": "_period-selector__selector-container_1on0y_19",
12
- "period-selector__selector-row": "_period-selector__selector-row_1on0y_24",
13
- "period-selector__error": "_period-selector__error_1on0y_31"
14
- }, E = 0, S = 1, f = 2, a = 3, w = 7, D = (_) => {
15
- const n = [];
16
- for (let t = 0; t < _.length; t += a)
17
- n.push(_.slice(t, t + a));
18
- return n;
19
- }, L = ({
20
- maxPeriods: _ = w,
21
- defaultValues: n,
1
+ import { jsxs as h, jsx as i } from "react/jsx-runtime";
2
+ import { c as k } from "../../clsx-OuTLNxxd.js";
3
+ import { useRef as M, useState as N, useEffect as $ } from "react";
4
+ import "../Buttons/Button.js";
5
+ import "../Buttons/LinkButton.js";
6
+ import "@react-aria/button";
7
+ import { CheckboxButtonBar as w } from "../CheckboxButtonBar/CheckboxButtonBar.js";
8
+ import "@react-aria/dialog";
9
+ import "@react-aria/focus";
10
+ import "@react-aria/overlays";
11
+ import "../OverlayCloseButton/OverlayCloseButton.js";
12
+ import { FeedbackBox as B } from "../FeedbackBox/FeedbackBox.js";
13
+ import "../GridRow/GridRow.js";
14
+ import "../IconButton/IconButton.js";
15
+ import "../Input/Input.js";
16
+ import "../InputField/InputField.js";
17
+ import { Label as D } from "../Label/Label.js";
18
+ import "react-router-dom";
19
+ import "../../TablePlugin-CMsi2UDH.js";
20
+ import "../RteEditor/Providers/LanguageProvider.js";
21
+ import "../RteEditor/hooks/components/Flyout.js";
22
+ import "../SelectListbox/SelectListbox.js";
23
+ import "../SelectListbox/SelectProvider.js";
24
+ import "../Sortable/components/SortableItem.js";
25
+ import "../../SortableProvider-BUsvniX7.js";
26
+ import '../../assets/PeriodSelector.css';const s = {
27
+ "period-selector__container": "_period-selector__container_1v02t_1",
28
+ "period-selector__container--label-left": "_period-selector__container--label-left_1v02t_6",
29
+ "period-selector__container--label-top": "_period-selector__container--label-top_1v02t_12",
30
+ "period-selector__selector-container": "_period-selector__selector-container_1v02t_19",
31
+ "period-selector__selector-row": "_period-selector__selector-row_1v02t_24"
32
+ }, S = 0, f = 1, E = 2, _ = 3, I = 7, T = (l) => {
33
+ const c = [];
34
+ for (let t = 0; t < l.length; t += _)
35
+ c.push(l.slice(t, t + _));
36
+ return c;
37
+ }, nr = ({
38
+ maxPeriods: l = I,
39
+ defaultValues: c,
22
40
  label: t,
23
41
  labelPosition: b = "top",
24
42
  required: p = !1,
25
- notValidatedText: d = "",
26
- onChange: g
43
+ notValidatedText: m = "",
44
+ onChange: v
27
45
  }) => {
28
- const R = Array.from({ length: _ }, (e, r) => r + 1), m = D(R), x = m.map((e, r) => e.map((o) => ({
29
- label: `${r + 1}${e.length === 1 ? "" : `.${(o - 1) % a + 1}`}`,
46
+ const g = Array.from({ length: l }, (r, e) => e + 1), a = T(g), R = a.map((r, e) => r.map((o) => ({
47
+ label: `${e + 1}${r.length === 1 ? "" : `.${(o - 1) % _ + 1}`}`,
30
48
  value: o.toString()
31
- }))), s = N(
32
- m.map(
33
- (e) => e.reduce((r, o) => (n != null && n.includes(o) && r.push(o), r), [])
49
+ }))), n = M(
50
+ a.map(
51
+ (r) => r.reduce((e, o) => (c != null && c.includes(o) && e.push(o), e), [])
34
52
  )
35
- ), [y, u] = M([]), h = (e) => e[E].length !== 0 || e[S].length !== 0 ? [f] : e[f].length !== 0 ? [E, S] : [], P = (e, r) => {
36
- s.current[r] = e.map((o) => Number(o)), u(h(s.current)), g([...s.current.flat()].sort());
53
+ ), [x, d] = N([]), u = (r) => r[S].length !== 0 || r[f].length !== 0 ? [E] : r[E].length !== 0 ? [S, f] : [], P = (r, e) => {
54
+ n.current[e] = r.map((o) => Number(o)), d(u(n.current)), v([...n.current.flat()].sort());
37
55
  };
38
56
  return $(() => {
39
- u(h(s.current));
40
- }, []), /* @__PURE__ */ i(
57
+ d(u(n.current));
58
+ }, []), /* @__PURE__ */ h(
41
59
  "div",
42
60
  {
43
- className: v(
44
- c["period-selector__container"],
45
- c[`period-selector__container--label-${b}`]
61
+ className: k(
62
+ s["period-selector__container"],
63
+ s[`period-selector__container--label-${b}`]
46
64
  ),
47
65
  children: [
48
- t && /* @__PURE__ */ l(k, { htmlFor: "", required: p, children: t }),
49
- /* @__PURE__ */ i("div", { className: c["period-selector__selector-container"], children: [
50
- /* @__PURE__ */ l("div", { className: c["period-selector__selector-row"], children: x.map((e, r) => /* @__PURE__ */ l(
51
- I,
66
+ t && /* @__PURE__ */ i(D, { htmlFor: "", required: p, children: t }),
67
+ /* @__PURE__ */ h("div", { className: s["period-selector__selector-container"], children: [
68
+ /* @__PURE__ */ i("div", { className: s["period-selector__selector-row"], children: R.map((r, e) => /* @__PURE__ */ i(
69
+ w,
52
70
  {
53
- checkboxes: e,
54
- defaultValues: s.current[r].map((o) => o.toString()),
55
- disableGroup: y.includes(r),
71
+ checkboxes: r,
72
+ defaultValues: n.current[e].map((o) => o.toString()),
73
+ disableGroup: x.includes(e),
56
74
  required: p,
57
- onSetValues: (o) => P(o, r)
75
+ onSetValues: (o) => P(o, e)
58
76
  },
59
- `group_${r}`
77
+ `group_${e}`
60
78
  )) }),
61
- /* @__PURE__ */ l("div", { className: c["period-selector__error"] }),
62
- d !== "" && /* @__PURE__ */ i("div", { className: c["period-selector__error"], children: [
63
- /* @__PURE__ */ l(T, { name: "ExclamationTriangleFill", size: 24 }),
64
- d
65
- ] })
79
+ /* @__PURE__ */ i("div", { className: s["period-selector__error"] }),
80
+ m !== "" && /* @__PURE__ */ i(B, { level: "error", feedback: m })
66
81
  ] })
67
82
  ]
68
83
  }
69
84
  );
70
85
  };
71
86
  export {
72
- L as PeriodSelector
87
+ nr as PeriodSelector
73
88
  };
74
89
  //# sourceMappingURL=PeriodSelector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PeriodSelector.js","sources":["../../../src/components/PeriodSelector/PeriodSelector.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\n\nimport styles from './PeriodSelector.module.css';\n\nimport { Label } from 'components/Label';\nimport { CheckboxButtonBar } from 'components/CheckboxButtonBar';\nimport { Icon } from 'components/Icon';\n\nexport interface PeriodSelectorProps {\n /** Indicates how many periods are shown. */\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n maxPeriods: 6 | 7;\n /** array of period values [3, 5 ...] */\n defaultValues?: number[];\n label: string;\n labelPosition?: 'top' | 'left';\n /** Shows red * */\n required?: boolean;\n /** error text to display if set */\n notValidatedText?: string;\n /** Returns array of selected values as number */\n onChange: (values: number[]) => void;\n}\n\nconst SEMESTER_1 = 0;\nconst SEMESTER_2 = 1;\nconst SEMESTER_3 = 2;\n\nconst PERIODS_PER_SEMESTER = 3;\nconst MAX_PERIODS = 7;\n\nconst chunkPeriods = (array: number[]): number[][] => {\n const result: number[][] = [];\n for (let count = 0; count < array.length; count += PERIODS_PER_SEMESTER) {\n result.push(array.slice(count, count + PERIODS_PER_SEMESTER));\n }\n return result;\n};\n\n/** Checkbox group for selecting periods */\nexport const PeriodSelector = ({\n maxPeriods = MAX_PERIODS,\n defaultValues,\n label,\n labelPosition = 'top',\n required = false,\n notValidatedText = '',\n onChange,\n}: PeriodSelectorProps) => {\n const maxPeriodsList = Array.from({ length: maxPeriods }, (_, index) => index + 1);\n const chunkedPeriods = chunkPeriods(maxPeriodsList);\n\n const checkboxItems = chunkedPeriods.map((periods, semester) => {\n return periods.map((period) => ({\n label: `${semester + 1}${periods.length === 1 ? '' : `.${((period - 1) % PERIODS_PER_SEMESTER) + 1}`}`,\n value: period.toString(),\n }));\n });\n\n const returnValues = useRef<number[][]>(\n chunkedPeriods.map((semester) =>\n semester.reduce((periods, period) => {\n if (defaultValues?.includes(period)) periods.push(period);\n return periods;\n }, [] as number[])\n )\n );\n const [disableSemesters, setDisableSemesters] = useState<number[]>([]);\n\n const disableGroups = (selects: number[][]) => {\n if (selects[SEMESTER_1].length !== 0 || selects[SEMESTER_2].length !== 0) return [SEMESTER_3];\n if (selects[SEMESTER_3].length !== 0) return [SEMESTER_1, SEMESTER_2];\n return [];\n };\n\n const handleChange = (values: string[], index: number) => {\n returnValues.current[index] = values.map((num) => Number(num));\n setDisableSemesters(disableGroups(returnValues.current));\n onChange([...returnValues.current.flat()].sort());\n };\n\n useEffect(() => {\n setDisableSemesters(disableGroups(returnValues.current));\n }, []);\n\n return (\n <div\n className={clsx(\n styles['period-selector__container'],\n styles[`period-selector__container--label-${labelPosition}`]\n )}\n >\n {label && (\n <Label htmlFor=\"\" required={required}>\n {label}\n </Label>\n )}\n <div className={styles['period-selector__selector-container']}>\n <div className={styles['period-selector__selector-row']}>\n {checkboxItems.map((checkboxes, semester) => (\n <CheckboxButtonBar\n key={`group_${semester}`}\n checkboxes={checkboxes}\n defaultValues={returnValues.current[semester].map((num) => num.toString())}\n disableGroup={disableSemesters.includes(semester)}\n required={required}\n onSetValues={(event) => handleChange(event, semester)}\n />\n ))}\n </div>\n <div className={styles['period-selector__error']}></div>\n {notValidatedText !== '' && (\n <div className={styles['period-selector__error']}>\n <Icon name=\"ExclamationTriangleFill\" size={24} />\n {notValidatedText}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["SEMESTER_1","SEMESTER_2","SEMESTER_3","PERIODS_PER_SEMESTER","MAX_PERIODS","chunkPeriods","array","result","count","PeriodSelector","maxPeriods","defaultValues","label","labelPosition","required","notValidatedText","onChange","maxPeriodsList","_","index","chunkedPeriods","checkboxItems","periods","semester","period","returnValues","useRef","disableSemesters","setDisableSemesters","useState","disableGroups","selects","handleChange","values","num","useEffect","jsxs","clsx","styles","jsx","Label","checkboxes","CheckboxButtonBar","event","Icon"],"mappings":";;;;;;;;;;;;;GAyBMA,IAAa,GACbC,IAAa,GACbC,IAAa,GAEbC,IAAuB,GACvBC,IAAc,GAEdC,IAAe,CAACC,MAAgC;AACpD,QAAMC,IAAqB,CAAA;AAC3B,WAASC,IAAQ,GAAGA,IAAQF,EAAM,QAAQE,KAASL;AACjD,IAAAI,EAAO,KAAKD,EAAM,MAAME,GAAOA,IAAQL,CAAoB,CAAC;AAEvD,SAAAI;AACT,GAGaE,IAAiB,CAAC;AAAA,EAC7B,YAAAC,IAAaN;AAAA,EACb,eAAAO;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,UAAAC,IAAW;AAAA,EACX,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AACF,MAA2B;AACnB,QAAAC,IAAiB,MAAM,KAAK,EAAE,QAAQP,KAAc,CAACQ,GAAGC,MAAUA,IAAQ,CAAC,GAC3EC,IAAiBf,EAAaY,CAAc,GAE5CI,IAAgBD,EAAe,IAAI,CAACE,GAASC,MAC1CD,EAAQ,IAAI,CAACE,OAAY;AAAA,IAC9B,OAAO,GAAGD,IAAW,CAAC,GAAGD,E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AAO,+BAA+B,GACnD,UAAcjB,EAAA,IAAI,CAACoB,GAAYlB,MAC9B,gBAAAgB;AAAA,YAACG;AAAA,YAAA;AAAA,cAEC,YAAAD;AAAA,cACA,eAAehB,EAAa,QAAQF,CAAQ,EAAE,IAAI,CAACW,MAAQA,EAAI,UAAU;AAAA,cACzE,cAAcP,EAAiB,SAASJ,CAAQ;AAAA,cAChD,UAAAT;AAAA,cACA,aAAa,CAAC6B,MAAUX,EAAaW,GAAOpB,CAAQ;AAAA,YAAA;AAAA,YAL/C,SAASA,CAAQ;AAAA,UAOzB,CAAA,GACH;AAAA,UACC,gBAAAgB,EAAA,OAAA,EAAI,WAAWD,EAAO,wBAAwB,EAAG,CAAA;AAAA,UACjDvB,MAAqB,MACpB,gBAAAqB,EAAC,SAAI,WAAWE,EAAO,wBAAwB,GAC7C,UAAA;AAAA,YAAA,gBAAAC,EAACK,GAAK,EAAA,MAAK,2BAA0B,MAAM,IAAI;AAAA,YAC9C7B;AAAA,UAAA,GACH;AAAA,QAAA,GAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"PeriodSelector.js","sources":["../../../src/components/PeriodSelector/PeriodSelector.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\n\nimport styles from './PeriodSelector.module.css';\n\nimport { Label, CheckboxButtonBar, FeedbackBox } from 'components';\n\nexport interface PeriodSelectorProps {\n /** Indicates how many periods are shown. */\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n maxPeriods: 6 | 7;\n /** array of period values [3, 5 ...] */\n defaultValues?: number[];\n label: string;\n labelPosition?: 'top' | 'left';\n /** Shows red * */\n required?: boolean;\n /** error text to display if set */\n notValidatedText?: string;\n /** Returns array of selected values as number */\n onChange: (values: number[]) => void;\n}\n\nconst SEMESTER_1 = 0;\nconst SEMESTER_2 = 1;\nconst SEMESTER_3 = 2;\n\nconst PERIODS_PER_SEMESTER = 3;\nconst MAX_PERIODS = 7;\n\nconst chunkPeriods = (array: number[]): number[][] => {\n const result: number[][] = [];\n for (let count = 0; count < array.length; count += PERIODS_PER_SEMESTER) {\n result.push(array.slice(count, count + PERIODS_PER_SEMESTER));\n }\n return result;\n};\n\n/** Checkbox group for selecting periods */\nexport const PeriodSelector = ({\n maxPeriods = MAX_PERIODS,\n defaultValues,\n label,\n labelPosition = 'top',\n required = false,\n notValidatedText = '',\n onChange,\n}: PeriodSelectorProps) => {\n const maxPeriodsList = Array.from({ length: maxPeriods }, (_, index) => index + 1);\n const chunkedPeriods = chunkPeriods(maxPeriodsList);\n\n const checkboxItems = chunkedPeriods.map((periods, semester) => {\n return periods.map((period) => ({\n label: `${semester + 1}${periods.length === 1 ? '' : `.${((period - 1) % PERIODS_PER_SEMESTER) + 1}`}`,\n value: period.toString(),\n }));\n });\n\n const returnValues = useRef<number[][]>(\n chunkedPeriods.map((semester) =>\n semester.reduce((periods, period) => {\n if (defaultValues?.includes(period)) periods.push(period);\n return periods;\n }, [] as number[])\n )\n );\n const [disableSemesters, setDisableSemesters] = useState<number[]>([]);\n\n const disableGroups = (selects: number[][]) => {\n if (selects[SEMESTER_1].length !== 0 || selects[SEMESTER_2].length !== 0) return [SEMESTER_3];\n if (selects[SEMESTER_3].length !== 0) return [SEMESTER_1, SEMESTER_2];\n return [];\n };\n\n const handleChange = (values: string[], index: number) => {\n returnValues.current[index] = values.map((num) => Number(num));\n setDisableSemesters(disableGroups(returnValues.current));\n onChange([...returnValues.current.flat()].sort());\n };\n\n useEffect(() => {\n setDisableSemesters(disableGroups(returnValues.current));\n }, []);\n\n return (\n <div\n className={clsx(\n styles['period-selector__container'],\n styles[`period-selector__container--label-${labelPosition}`]\n )}\n >\n {label && (\n <Label htmlFor=\"\" required={required}>\n {label}\n </Label>\n )}\n <div className={styles['period-selector__selector-container']}>\n <div className={styles['period-selector__selector-row']}>\n {checkboxItems.map((checkboxes, semester) => (\n <CheckboxButtonBar\n key={`group_${semester}`}\n checkboxes={checkboxes}\n defaultValues={returnValues.current[semester].map((num) => num.toString())}\n disableGroup={disableSemesters.includes(semester)}\n required={required}\n onSetValues={(event) => handleChange(event, semester)}\n />\n ))}\n </div>\n <div className={styles['period-selector__error']}></div>\n {notValidatedText !== '' && <FeedbackBox level=\"error\" feedback={notValidatedText} />}\n </div>\n </div>\n );\n};\n"],"names":["SEMESTER_1","SEMESTER_2","SEMESTER_3","PERIODS_PER_SEMESTER","MAX_PERIODS","chunkPeriods","array","result","count","PeriodSelector","maxPeriods","defaultValues","label","labelPosition","required","notValidatedText","onChange","maxPeriodsList","_","index","chunkedPeriods","checkboxItems","periods","semester","period","returnValues","useRef","disableSemesters","setDisableSemesters","useState","disableGroups","selects","handleChange","values","num","useEffect","jsxs","clsx","styles","jsx","Label","checkboxes","CheckboxButtonBar","event","FeedbackBox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuBMA,IAAa,GACbC,IAAa,GACbC,IAAa,GAEbC,IAAuB,GACvBC,IAAc,GAEdC,IAAe,CAACC,MAAgC;AACpD,QAAMC,IAAqB,CAAA;AAC3B,WAASC,IAAQ,GAAGA,IAAQF,EAAM,QAAQE,KAASL;AACjD,IAAAI,EAAO,KAAKD,EAAM,MAAME,GAAOA,IAAQL,CAAoB,CAAC;AAEvD,SAAAI;AACT,GAGaE,KAAiB,CAAC;AAAA,EAC7B,YAAAC,IAAaN;AAAA,EACb,eAAAO;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,UAAAC,IAAW;AAAA,EACX,kBAAAC,IAAmB;AAAA,EACnB,UAAAC;AACF,MAA2B;AACnB,QAAAC,IAAiB,MAAM,KAAK,EAAE,QAAQP,KAAc,CAACQ,GAAGC,MAAUA,IAAQ,CAAC,GAC3EC,IAAiBf,EAAaY,CAAc,GAE5CI,IAAgBD,EAAe,IAAI,CAACE,GAASC,MAC1CD,EAAQ,IAAI,CAACE,OAAY;AAAA,IAC9B,OAAO,GAAGD,IAA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A,EAAI,WAAWD,EAAO,+BAA+B,GACnD,UAAcjB,EAAA,IAAI,CAACoB,GAAYlB,MAC9B,gBAAAgB;AAAA,YAACG;AAAA,YAAA;AAAA,cAEC,YAAAD;AAAA,cACA,eAAehB,EAAa,QAAQF,CAAQ,EAAE,IAAI,CAACW,MAAQA,EAAI,UAAU;AAAA,cACzE,cAAcP,EAAiB,SAASJ,CAAQ;AAAA,cAChD,UAAAT;AAAA,cACA,aAAa,CAAC6B,MAAUX,EAAaW,GAAOpB,CAAQ;AAAA,YAAA;AAAA,YAL/C,SAASA,CAAQ;AAAA,UAOzB,CAAA,GACH;AAAA,UACC,gBAAAgB,EAAA,OAAA,EAAI,WAAWD,EAAO,wBAAwB,EAAG,CAAA;AAAA,UACjDvB,MAAqB,MAAM,gBAAAwB,EAACK,KAAY,OAAM,SAAQ,UAAU7B,GAAkB;AAAA,QAAA,GACrF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -16,7 +16,7 @@ import "../IconButton/IconButton.js";
16
16
  import "../Input/Input.js";
17
17
  import "../InputField/InputField.js";
18
18
  import "react-router-dom";
19
- import "../../TablePlugin-B-Q_UBXj.js";
19
+ import "../../TablePlugin-CMsi2UDH.js";
20
20
  import { Repeater as i } from "../Repeater/Repeater.js";
21
21
  import "../RteEditor/Providers/LanguageProvider.js";
22
22
  import "../RteEditor/hooks/components/Flyout.js";
@@ -13,7 +13,7 @@ import "../../IconButton/IconButton.js";
13
13
  import "../../Input/Input.js";
14
14
  import "../../InputField/InputField.js";
15
15
  import "react-router-dom";
16
- import "../../../TablePlugin-B-Q_UBXj.js";
16
+ import "../../../TablePlugin-CMsi2UDH.js";
17
17
  import "../Providers/LanguageProvider.js";
18
18
  import "../hooks/components/Flyout.js";
19
19
  import "../../SelectListbox/SelectListbox.js";
@@ -4,7 +4,7 @@ import { c as f } from "../../../../clsx-OuTLNxxd.js";
4
4
  import { A as _, x as p, d as h } from "../../../../Lexical.prod-eo-UKDld.js";
5
5
  import { useState as l, useEffect as k } from "react";
6
6
  import { Icon as I } from "../../../Icon/Icon.js";
7
- import { s as a } from "../../../../RteEditor.module-BwAtWRHo.js";
7
+ import { s as a } from "../../../../RteEditor.module-XCAFrP3U.js";
8
8
  import { useTranslation as B } from "../../hooks/useTranslation.js";
9
9
  const x = {
10
10
  bold: "Bold",
@@ -16,8 +16,8 @@ import "../../../IconButton/IconButton.js";
16
16
  import "../../../Input/Input.js";
17
17
  import "../../../InputField/InputField.js";
18
18
  import "react-router-dom";
19
- import "../../../../TablePlugin-B-Q_UBXj.js";
20
- import { s as r } from "../../../../RteEditor.module-BwAtWRHo.js";
19
+ import "../../../../TablePlugin-CMsi2UDH.js";
20
+ import { s as r } from "../../../../RteEditor.module-XCAFrP3U.js";
21
21
  import { useTranslation as g } from "../../hooks/useTranslation.js";
22
22
  import "../../hooks/components/Flyout.js";
23
23
  import "../../Providers/LanguageProvider.js";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../../../helpers-BD3Y_bqE.js";
4
- import { A as z } from "../../../../TablePlugin-B-Q_UBXj.js";
4
+ import { A as z } from "../../../../TablePlugin-CMsi2UDH.js";
5
5
  import "../../../Icon/Icon.js";
6
6
  import "../../../Buttons/Button.js";
7
7
  import "../../../Buttons/LinkButton.js";
@@ -4,7 +4,7 @@ import { c as j } from "../../../../clsx-OuTLNxxd.js";
4
4
  import { g as w, m as V, e as z, U as W } from "../../../../helpers-BD3Y_bqE.js";
5
5
  import { useRef as p, useState as Y, useEffect as x } from "react";
6
6
  import { e as q, A as m, r as B, x as T, _ as G, L as J, l as M, E as Q } from "../../../../Lexical.prod-eo-UKDld.js";
7
- import { A as X } from "../../../../TablePlugin-B-Q_UBXj.js";
7
+ import { A as X } from "../../../../TablePlugin-CMsi2UDH.js";
8
8
  import { useFlyout as Z } from "../../hooks/useFlyout.js";
9
9
  import { Icon as $ } from "../../../Icon/Icon.js";
10
10
  import "../../../Buttons/Button.js";
@@ -19,7 +19,7 @@ import "../../../IconButton/IconButton.js";
19
19
  import "../../../Input/Input.js";
20
20
  import "../../../InputField/InputField.js";
21
21
  import "react-router-dom";
22
- import { s as d } from "../../../../RteEditor.module-BwAtWRHo.js";
22
+ import { s as d } from "../../../../RteEditor.module-XCAFrP3U.js";
23
23
  import { useTranslation as tt } from "../../hooks/useTranslation.js";
24
24
  import "../../Providers/LanguageProvider.js";
25
25
  import "../../../SelectListbox/SelectListbox.js";
@@ -1,11 +1,11 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../../../LexicalComposerContext.prod-Dyvim1tK.js";
3
- import { L as f } from "../../../../ListPlugin-Bb5eekAl.js";
3
+ import { L as f } from "../../../../ListPlugin-B-2w9EIN.js";
4
4
  import "react";
5
5
  import "../../../../clsx-OuTLNxxd.js";
6
6
  import "../../../../Lexical.prod-eo-UKDld.js";
7
7
  import "../../../Icon/Icon.js";
8
- import "../../../../RteEditor.module-BwAtWRHo.js";
8
+ import "../../../../RteEditor.module-XCAFrP3U.js";
9
9
  import "../../hooks/useTranslation.js";
10
10
  export {
11
11
  f as ListPlugin
@@ -1,4 +1,4 @@
1
- import { L as r } from "../../../../ListPlugin-Bb5eekAl.js";
1
+ import { L as r } from "../../../../ListPlugin-B-2w9EIN.js";
2
2
  export {
3
3
  r as ListPlugin
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { b as v } from "../../../../TablePlugin-B-Q_UBXj.js";
3
+ import { b as v } from "../../../../TablePlugin-CMsi2UDH.js";
4
4
  import "../../../Buttons/Button.js";
5
5
  import "../../../Buttons/LinkButton.js";
6
6
  import "@react-aria/button";
@@ -1,52 +1,62 @@
1
- import { jsxs as g, jsx as e } from "react/jsx-runtime";
2
- import { useState as _, useRef as d, useEffect as R } from "react";
1
+ import { jsxs as y, jsx as e } from "react/jsx-runtime";
2
+ import { useState as _, useRef as b, useEffect as R } from "react";
3
3
  import { c as w } from "../../../../../clsx-OuTLNxxd.js";
4
- import { u as $ } from "../../../../../LexicalComposerContext.prod-Dyvim1tK.js";
5
- import { Icon as k } from "../../../../Icon/Icon.js";
4
+ import { u as P } from "../../../../../LexicalComposerContext.prod-Dyvim1tK.js";
5
+ import { Icon as $ } from "../../../../Icon/Icon.js";
6
6
  import { useTranslation as H } from "../../../hooks/useTranslation.js";
7
7
  import '../../../../../assets/TableCellContextMenu.css';const n = {
8
- "context-menu__wrapper": "_context-menu__wrapper_y87hy_1",
9
- "context-menu__button": "_context-menu__button_y87hy_10",
10
- "context-menu": "_context-menu_y87hy_1",
11
- "context-menu--open": "_context-menu--open_y87hy_38",
12
- "context-menu__item": "_context-menu__item_y87hy_43",
13
- "context-menu__item-divider": "_context-menu__item-divider_y87hy_57",
14
- "context-menu__wrapper--hidden": "_context-menu__wrapper--hidden_y87hy_61"
15
- }, O = 25, N = 10, f = 4, A = 25, M = (u) => {
16
- const r = u.cloneNode(!0);
8
+ "context-menu__wrapper": "_context-menu__wrapper_xbeks_1",
9
+ "context-menu__button": "_context-menu__button_xbeks_10",
10
+ "context-menu": "_context-menu_xbeks_1",
11
+ "context-menu--open": "_context-menu--open_xbeks_38",
12
+ "context-menu__item": "_context-menu__item_xbeks_43",
13
+ "context-menu__item-divider": "_context-menu__item-divider_xbeks_57",
14
+ "context-menu__wrapper--hidden": "_context-menu__wrapper--hidden_xbeks_61"
15
+ }, O = 25, N = 10, f = 4, A = 25, M = (a) => {
16
+ const r = a.cloneNode(!0);
17
17
  r.style.height = "auto", r.style.left = "-3000px", document.body.appendChild(r);
18
- const b = r.getBoundingClientRect().height;
19
- return document.body.removeChild(r), b;
20
- }, W = ({ position: u, parentScrollPosition: r, onAction: b }) => {
21
- const t = H(), [T, h] = _(!1), [E, x] = _(!1), [c, B] = _({ xPos: 0, yPos: 0, height: 0 }), [m, I] = _(0), y = d(0), i = d(null), s = d(null), l = d(null), [v] = $(), a = (o) => {
22
- b(o), h(!1);
23
- }, C = () => {
24
- const o = i.current ? i.current.getBoundingClientRect().width : 0;
25
- s.current && i.current && l.current && (c.xPos < o && s.current ? (s.current.style.left = `${o - c.xPos + N}px`, l.current.style.right = `${o - c.xPos + f + N}px`) : (s.current.style.left = "0px", l.current.style.right = `${f}px`), m || I(M(i.current)), m > document.documentElement.clientHeight - c.yPos ? (s.current.style.top = `-${m + c.height}px`, l.current.style.top = `${m + f}px`, l.current.style.transform = "rotate(180deg)") : (s.current.style.top = "0px", l.current.style.top = `-${A}px`, l.current.style.transform = "none"));
26
- }, P = () => (C(), `translate(${((c == null ? void 0 : c.xPos) ?? 0) - (i.current ? i.current.getBoundingClientRect().width : 0)}px, ${c.yPos - (r - y.current)}px)`);
18
+ const d = r.getBoundingClientRect().height;
19
+ return document.body.removeChild(r), d;
20
+ }, W = ({ position: a, parentScrollPosition: r, onAction: d }) => {
21
+ const t = H(), [k, x] = _(!1), [T, p] = _(!1), [s, E] = _({ xPos: 0, yPos: 0, height: 0 }), [m, B] = _(0), C = b(0), c = b(null), i = b(null), o = b(null), [I] = P(), u = (l) => {
22
+ d(l), x(!1);
23
+ }, g = () => {
24
+ const l = c.current ? c.current.getBoundingClientRect().width : 0;
25
+ i.current && c.current && o.current && (s.xPos < l && i.current ? (i.current.style.left = `${l - s.xPos + N}px`, o.current.style.right = `${l - s.xPos + f + N}px`) : (i.current.style.left = "0px", o.current.style.right = `${f}px`), m || B(M(c.current)), m > document.documentElement.clientHeight - s.yPos ? (i.current.style.top = `-${m + s.height}px`, o.current.style.top = `${m + f}px`, o.current.style.transform = "rotate(180deg)") : (i.current.style.top = "0px", o.current.style.top = `-${A}px`, o.current.style.transform = "none"));
26
+ }, v = () => (g(), `translate(${((s == null ? void 0 : s.xPos) ?? 0) - (c.current ? c.current.getBoundingClientRect().width : 0)}px, ${s.yPos - (r - C.current)}px)`);
27
27
  return R(() => {
28
- B(u), u && (y.current = r), h(!1), x(!1);
29
- }, [u]), R(() => {
30
- if (l.current) {
31
- const o = l.current.getBoundingClientRect(), p = v.getRootElement();
32
- if (!p) return;
33
- o.top - p.getBoundingClientRect().top <= 0 || o.top - p.getBoundingClientRect().bottom + O >= 0 ? x(!0) : x(!1), C();
28
+ E(a), a && (C.current = r), x(!1), p(!1);
29
+ }, [a]), R(() => {
30
+ if (o.current) {
31
+ const l = o.current.getBoundingClientRect(), h = I.getRootElement();
32
+ if (!h) return;
33
+ l.top - h.getBoundingClientRect().top <= 0 || l.top - h.getBoundingClientRect().bottom + O >= 0 ? p(!0) : p(!1), g();
34
34
  }
35
- }, [r]), /* @__PURE__ */ g(
35
+ }, [r]), /* @__PURE__ */ y(
36
36
  "div",
37
37
  {
38
- className: w(n["context-menu__wrapper"], [E && n["context-menu__wrapper--hidden"]]),
38
+ className: w(n["context-menu__wrapper"], [T && n["context-menu__wrapper--hidden"]]),
39
39
  style: {
40
- transform: `${P()}`
40
+ transform: `${v()}`
41
41
  },
42
- ref: s,
42
+ ref: i,
43
43
  children: [
44
- /* @__PURE__ */ e("button", { onClick: () => h((o) => !o), className: n["context-menu__button"], ref: l, children: /* @__PURE__ */ e(k, { name: "CheveronDown", size: 16 }) }),
45
- /* @__PURE__ */ g("ul", { ref: i, className: w(n["context-menu"], T && n["context-menu--open"]), children: [
44
+ /* @__PURE__ */ e(
45
+ "button",
46
+ {
47
+ type: "button",
48
+ onClick: () => x((l) => !l),
49
+ className: n["context-menu__button"],
50
+ ref: o,
51
+ children: /* @__PURE__ */ e($, { name: "CheveronDown", size: 16 })
52
+ }
53
+ ),
54
+ /* @__PURE__ */ y("ul", { ref: c, className: w(n["context-menu"], k && n["context-menu--open"]), children: [
46
55
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
47
56
  "button",
48
57
  {
49
- onClick: () => a("insertRowAbove"),
58
+ type: "button",
59
+ onClick: () => u("insertRowAbove"),
50
60
  className: n["context-menu__item"],
51
61
  "aria-label": t.aria.labels.tableInsertRowAbove,
52
62
  children: t.table.insertRowAbove
@@ -55,7 +65,8 @@ import '../../../../../assets/TableCellContextMenu.css';const n = {
55
65
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
56
66
  "button",
57
67
  {
58
- onClick: () => a("insertRowBelow"),
68
+ type: "button",
69
+ onClick: () => u("insertRowBelow"),
59
70
  className: n["context-menu__item"],
60
71
  "aria-label": t.aria.labels.tableInsertRowBelow,
61
72
  children: t.table.insertRowBelow
@@ -64,7 +75,8 @@ import '../../../../../assets/TableCellContextMenu.css';const n = {
64
75
  /* @__PURE__ */ e("li", { className: n["context-menu__item-divider"], children: /* @__PURE__ */ e(
65
76
  "button",
66
77
  {
67
- onClick: () => a("deleteRow"),
78
+ type: "button",
79
+ onClick: () => u("deleteRow"),
68
80
  className: n["context-menu__item"],
69
81
  "aria-label": t.aria.labels.tableDeleteRow,
70
82
  children: t.table.deleteRow
@@ -73,7 +85,8 @@ import '../../../../../assets/TableCellContextMenu.css';const n = {
73
85
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
74
86
  "button",
75
87
  {
76
- onClick: () => a("insertColumnLeft"),
88
+ type: "button",
89
+ onClick: () => u("insertColumnLeft"),
77
90
  className: n["context-menu__item"],
78
91
  "aria-label": t.aria.labels.tableInsertColumnLeft,
79
92
  children: t.table.insertColumnLeft
@@ -82,7 +95,8 @@ import '../../../../../assets/TableCellContextMenu.css';const n = {
82
95
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
83
96
  "button",
84
97
  {
85
- onClick: () => a("insertColumnRight"),
98
+ type: "button",
99
+ onClick: () => u("insertColumnRight"),
86
100
  className: n["context-menu__item"],
87
101
  "aria-label": t.aria.labels.tableInsertColumnRight,
88
102
  children: t.table.insertColumnRight
@@ -91,20 +105,20 @@ import '../../../../../assets/TableCellContextMenu.css';const n = {
91
105
  /* @__PURE__ */ e("li", { className: n["context-menu__item-divider"], children: /* @__PURE__ */ e(
92
106
  "button",
93
107
  {
94
- onClick: () => a("deleteColumn"),
108
+ type: "button",
109
+ onClick: () => u("deleteColumn"),
95
110
  className: n["context-menu__item"],
96
111
  "aria-label": t.aria.labels.tableDeleteColumn,
97
- type: "button",
98
112
  children: t.table.deleteColumn
99
113
  }
100
114
  ) }),
101
115
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
102
116
  "button",
103
117
  {
104
- onClick: () => a("deleteTable"),
118
+ type: "button",
119
+ onClick: () => u("deleteTable"),
105
120
  className: n["context-menu__item"],
106
121
  "aria-label": t.aria.labels.tableDeleteTable,
107
- type: "button",
108
122
  children: t.table.deleteTable
109
123
  }
110
124
  ) })
@@ -1 +1 @@
1
- {"version":3,"file":"TableCellContextMenu.js","sources":["../../../../../../src/components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\n\nimport type { Position } from 'components/RteEditor/Plugins/ToolbarPlugin';\n\nimport styles from './TableCellContextMenu.module.css';\n\nimport { Icon } from 'components/Icon';\nimport { useTranslation } from 'components/RteEditor/hooks/useTranslation';\n\nexport type Actions =\n | 'insertRowAbove'\n | 'insertRowBelow'\n | 'deleteRow'\n | 'deleteTable'\n | 'insertColumnLeft'\n | 'insertColumnRight'\n | 'deleteColumn';\ninterface TableCellContextMenuProps {\n position: Position;\n parentScrollPosition: number;\n onAction: (action: Actions) => void;\n}\n\nconst CONTEXT_MENU_OFFSET = 25;\nconst WHITE_SPACE = 10;\nconst BUTTON_SHIFT = 4;\nconst BUTTON_RESET = 25;\n\nconst mesureElement = (srcElement: HTMLElement) => {\n const mesureElement = srcElement.cloneNode(true) as HTMLElement;\n mesureElement.style.height = 'auto';\n mesureElement.style.left = '-3000px';\n document.body.appendChild(mesureElement);\n const height = mesureElement.getBoundingClientRect().height;\n document.body.removeChild(mesureElement);\n return height;\n};\n\nexport const TableCellContextMenu = ({ position, parentScrollPosition, onAction }: TableCellContextMenuProps) => {\n const t = useTranslation();\n const [isOpen, setIsOpen] = useState(false);\n const [isHidden, setIsHidden] = useState(false);\n const [localPosition, setLocalPosition] = useState<Position>({ xPos: 0, yPos: 0, height: 0 });\n const [menuHeight, setMenuHeight] = useState(0);\n const startScrollPosition = useRef(0);\n const menuRef = useRef<HTMLUListElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [editor] = useLexicalComposerContext();\n\n const handleAction = (action: Actions) => {\n onAction(action);\n setIsOpen(false);\n };\n\n const flipMenuIfNotInViewpoort = () => {\n const menuWidth = menuRef.current ? menuRef.current.getBoundingClientRect().width : 0;\n\n if (containerRef.current && menuRef.current && buttonRef.current) {\n if (localPosition.xPos < menuWidth && containerRef.current) {\n containerRef.current.style.left = `${menuWidth - localPosition.xPos + WHITE_SPACE}px`;\n buttonRef.current.style.right = `${menuWidth - localPosition.xPos + BUTTON_SHIFT + WHITE_SPACE}px`;\n } else {\n containerRef.current.style.left = '0px';\n buttonRef.current.style.right = `${BUTTON_SHIFT}px`;\n }\n\n if (!menuHeight) {\n setMenuHeight(mesureElement(menuRef.current));\n }\n\n if (menuHeight > document.documentElement.clientHeight - localPosition.yPos) {\n containerRef.current.style.top = `-${menuHeight + localPosition.height}px`;\n buttonRef.current.style.top = `${menuHeight + BUTTON_SHIFT}px`;\n buttonRef.current.style.transform = 'rotate(180deg)';\n } else {\n containerRef.current.style.top = '0px';\n buttonRef.current.style.top = `-${BUTTON_RESET}px`;\n buttonRef.current.style.transform = 'none';\n }\n }\n };\n\n const setMenuPosition = () => {\n flipMenuIfNotInViewpoort();\n return `translate(${(localPosition?.xPos ?? 0) - (menuRef.current ? menuRef.current.getBoundingClientRect().width : 0)}px, ${localPosition.yPos - (parentScrollPosition - startScrollPosition.current)}px)`;\n };\n\n useEffect(() => {\n setLocalPosition(position);\n if (position) {\n startScrollPosition.current = parentScrollPosition;\n }\n setIsOpen(false);\n setIsHidden(false);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [position]);\n\n useEffect(() => {\n if (buttonRef.current) {\n const rect = buttonRef.current.getBoundingClientRect();\n const rootElement = editor.getRootElement();\n if (!rootElement) return;\n if (\n rect.top - rootElement.getBoundingClientRect().top <= 0 ||\n rect.top - rootElement.getBoundingClientRect().bottom + CONTEXT_MENU_OFFSET >= 0\n ) {\n setIsHidden(true);\n } else {\n setIsHidden(false);\n }\n flipMenuIfNotInViewpoort();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [parentScrollPosition]);\n\n return (\n <div\n className={clsx(styles['context-menu__wrapper'], [isHidden && styles['context-menu__wrapper--hidden']])}\n style={{\n transform: `${setMenuPosition()}`,\n }}\n ref={containerRef}\n >\n <button onClick={() => setIsOpen((prev) => !prev)} className={styles['context-menu__button']} ref={buttonRef}>\n <Icon name=\"CheveronDown\" size={16} />\n </button>\n <ul ref={menuRef} className={clsx(styles['context-menu'], isOpen && styles['context-menu--open'])}>\n <li>\n <button\n onClick={() => handleAction('insertRowAbove')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertRowAbove}\n >\n {t.table.insertRowAbove}\n </button>\n </li>\n <li>\n <button\n onClick={() => handleAction('insertRowBelow')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertRowBelow}\n >\n {t.table.insertRowBelow}\n </button>\n </li>\n <li className={styles['context-menu__item-divider']}>\n <button\n onClick={() => handleAction('deleteRow')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteRow}\n >\n {t.table.deleteRow}\n </button>\n </li>\n\n <li>\n <button\n onClick={() => handleAction('insertColumnLeft')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertColumnLeft}\n >\n {t.table.insertColumnLeft}\n </button>\n </li>\n <li>\n <button\n onClick={() => handleAction('insertColumnRight')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertColumnRight}\n >\n {t.table.insertColumnRight}\n </button>\n </li>\n <li className={styles['context-menu__item-divider']}>\n <button\n onClick={() => handleAction('deleteColumn')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteColumn}\n type=\"button\"\n >\n {t.table.deleteColumn}\n </button>\n </li>\n\n <li>\n <button\n onClick={() => handleAction('deleteTable')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteTable}\n type=\"button\"\n >\n {t.table.deleteTable}\n </button>\n </li>\n </ul>\n </div>\n );\n};\n"],"names":["CONTEXT_MENU_OFFSET","WHITE_SPACE","BUTTON_SHIFT","BUTTON_RESET","mesureElement","srcElement","height","TableCellContextMenu","position","parentScrollPosition","onAction","useTranslation","isOpen","setIsOpen","useState","isHidden","setIsHidden","localPosition","setLocalPosition","menuHeight","setMenuHeight","startScrollPosition","useRef","menuRef","containerRef","buttonRef","editor","useLexicalComposerContext","handleAction","action","flipMenuIfNotInViewpoort","menuWidth","setMenuPosition","useEffect","rect","rootElement","jsxs","clsx","styles","jsx","prev","Icon"],"mappings":";;;;;;;;;;;;;;GAyBMA,IAAsB,IACtBC,IAAc,IACdC,IAAe,GACfC,IAAe,IAEfC,IAAgB,CAACC,MAA4B;AAC3CD,QAAAA,IAAgBC,EAAW,UAAU,EAAI;AAC/CD,EAAAA,EAAc,MAAM,SAAS,QAC7BA,EAAc,MAAM,OAAO,WAClB,SAAA,KAAK,YAAYA,CAAa;AACjC,QAAAE,IAASF,EAAc,sBAAA,EAAwB;AAC5C,kBAAA,KAAK,YAAYA,CAAa,GAChCE;AACT,GAEaC,IAAuB,CAAC,EAAE,UAAAC,GAAU,sBAAAC,GAAsB,UAAAC,QAA0C;AAC/G,QAAM,IAAIC,KACJ,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxC,CAACG,GAAeC,CAAgB,IAAIJ,EAAmB,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,EAAG,CAAA,GACtF,CAACK,GAAYC,CAAa,IAAIN,EAAS,CAAC,GACxCO,IAAsBC,EAAO,CAAC,GA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AAC;AAAA,YAAA;AAAA,cACC,SAAS,MAAMX,EAAa,aAAa;AAAA,cACzC,WAAWU,EAAO,oBAAoB;AAAA,cACtC,cAAY,EAAE,KAAK,OAAO;AAAA,cAC1B,MAAK;AAAA,cAEJ,YAAE,MAAM;AAAA,YAAA;AAAA,UAAA,GAEb;AAAA,QAAA,GACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"TableCellContextMenu.js","sources":["../../../../../../src/components/RteEditor/Plugins/TablePlugin/TableCellContextMenu/TableCellContextMenu.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\n\nimport type { Position } from 'components/RteEditor/Plugins/ToolbarPlugin';\n\nimport styles from './TableCellContextMenu.module.css';\n\nimport { Icon } from 'components/Icon';\nimport { useTranslation } from 'components/RteEditor/hooks/useTranslation';\n\nexport type Actions =\n | 'insertRowAbove'\n | 'insertRowBelow'\n | 'deleteRow'\n | 'deleteTable'\n | 'insertColumnLeft'\n | 'insertColumnRight'\n | 'deleteColumn';\ninterface TableCellContextMenuProps {\n position: Position;\n parentScrollPosition: number;\n onAction: (action: Actions) => void;\n}\n\nconst CONTEXT_MENU_OFFSET = 25;\nconst WHITE_SPACE = 10;\nconst BUTTON_SHIFT = 4;\nconst BUTTON_RESET = 25;\n\nconst mesureElement = (srcElement: HTMLElement) => {\n const mesureElement = srcElement.cloneNode(true) as HTMLElement;\n mesureElement.style.height = 'auto';\n mesureElement.style.left = '-3000px';\n document.body.appendChild(mesureElement);\n const height = mesureElement.getBoundingClientRect().height;\n document.body.removeChild(mesureElement);\n return height;\n};\n\nexport const TableCellContextMenu = ({ position, parentScrollPosition, onAction }: TableCellContextMenuProps) => {\n const t = useTranslation();\n const [isOpen, setIsOpen] = useState(false);\n const [isHidden, setIsHidden] = useState(false);\n const [localPosition, setLocalPosition] = useState<Position>({ xPos: 0, yPos: 0, height: 0 });\n const [menuHeight, setMenuHeight] = useState(0);\n const startScrollPosition = useRef(0);\n const menuRef = useRef<HTMLUListElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [editor] = useLexicalComposerContext();\n\n const handleAction = (action: Actions) => {\n onAction(action);\n setIsOpen(false);\n };\n\n const flipMenuIfNotInViewpoort = () => {\n const menuWidth = menuRef.current ? menuRef.current.getBoundingClientRect().width : 0;\n\n if (containerRef.current && menuRef.current && buttonRef.current) {\n if (localPosition.xPos < menuWidth && containerRef.current) {\n containerRef.current.style.left = `${menuWidth - localPosition.xPos + WHITE_SPACE}px`;\n buttonRef.current.style.right = `${menuWidth - localPosition.xPos + BUTTON_SHIFT + WHITE_SPACE}px`;\n } else {\n containerRef.current.style.left = '0px';\n buttonRef.current.style.right = `${BUTTON_SHIFT}px`;\n }\n\n if (!menuHeight) {\n setMenuHeight(mesureElement(menuRef.current));\n }\n\n if (menuHeight > document.documentElement.clientHeight - localPosition.yPos) {\n containerRef.current.style.top = `-${menuHeight + localPosition.height}px`;\n buttonRef.current.style.top = `${menuHeight + BUTTON_SHIFT}px`;\n buttonRef.current.style.transform = 'rotate(180deg)';\n } else {\n containerRef.current.style.top = '0px';\n buttonRef.current.style.top = `-${BUTTON_RESET}px`;\n buttonRef.current.style.transform = 'none';\n }\n }\n };\n\n const setMenuPosition = () => {\n flipMenuIfNotInViewpoort();\n return `translate(${(localPosition?.xPos ?? 0) - (menuRef.current ? menuRef.current.getBoundingClientRect().width : 0)}px, ${localPosition.yPos - (parentScrollPosition - startScrollPosition.current)}px)`;\n };\n\n useEffect(() => {\n setLocalPosition(position);\n if (position) {\n startScrollPosition.current = parentScrollPosition;\n }\n setIsOpen(false);\n setIsHidden(false);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [position]);\n\n useEffect(() => {\n if (buttonRef.current) {\n const rect = buttonRef.current.getBoundingClientRect();\n const rootElement = editor.getRootElement();\n if (!rootElement) return;\n if (\n rect.top - rootElement.getBoundingClientRect().top <= 0 ||\n rect.top - rootElement.getBoundingClientRect().bottom + CONTEXT_MENU_OFFSET >= 0\n ) {\n setIsHidden(true);\n } else {\n setIsHidden(false);\n }\n flipMenuIfNotInViewpoort();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [parentScrollPosition]);\n\n return (\n <div\n className={clsx(styles['context-menu__wrapper'], [isHidden && styles['context-menu__wrapper--hidden']])}\n style={{\n transform: `${setMenuPosition()}`,\n }}\n ref={containerRef}\n >\n <button\n type=\"button\"\n onClick={() => setIsOpen((prev) => !prev)}\n className={styles['context-menu__button']}\n ref={buttonRef}\n >\n <Icon name=\"CheveronDown\" size={16} />\n </button>\n <ul ref={menuRef} className={clsx(styles['context-menu'], isOpen && styles['context-menu--open'])}>\n <li>\n <button\n type=\"button\"\n onClick={() => handleAction('insertRowAbove')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertRowAbove}\n >\n {t.table.insertRowAbove}\n </button>\n </li>\n <li>\n <button\n type=\"button\"\n onClick={() => handleAction('insertRowBelow')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertRowBelow}\n >\n {t.table.insertRowBelow}\n </button>\n </li>\n <li className={styles['context-menu__item-divider']}>\n <button\n type=\"button\"\n onClick={() => handleAction('deleteRow')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteRow}\n >\n {t.table.deleteRow}\n </button>\n </li>\n\n <li>\n <button\n type=\"button\"\n onClick={() => handleAction('insertColumnLeft')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertColumnLeft}\n >\n {t.table.insertColumnLeft}\n </button>\n </li>\n <li>\n <button\n type=\"button\"\n onClick={() => handleAction('insertColumnRight')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableInsertColumnRight}\n >\n {t.table.insertColumnRight}\n </button>\n </li>\n <li className={styles['context-menu__item-divider']}>\n <button\n type=\"button\"\n onClick={() => handleAction('deleteColumn')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteColumn}\n >\n {t.table.deleteColumn}\n </button>\n </li>\n\n <li>\n <button\n type=\"button\"\n onClick={() => handleAction('deleteTable')}\n className={styles['context-menu__item']}\n aria-label={t.aria.labels.tableDeleteTable}\n >\n {t.table.deleteTable}\n </button>\n </li>\n </ul>\n </div>\n );\n};\n"],"names":["CONTEXT_MENU_OFFSET","WHITE_SPACE","BUTTON_SHIFT","BUTTON_RESET","mesureElement","srcElement","height","TableCellContextMenu","position","parentScrollPosition","onAction","useTranslation","isOpen","setIsOpen","useState","isHidden","setIsHidden","localPosition","setLocalPosition","menuHeight","setMenuHeight","startScrollPosition","useRef","menuRef","containerRef","buttonRef","editor","useLexicalComposerContext","handleAction","action","flipMenuIfNotInViewpoort","menuWidth","setMenuPosition","useEffect","rect","rootElement","jsxs","clsx","styles","jsx","prev","Icon"],"mappings":";;;;;;;;;;;;;;GAyBMA,IAAsB,IACtBC,IAAc,IACdC,IAAe,GACfC,IAAe,IAEfC,IAAgB,CAACC,MAA4B;AAC3CD,QAAAA,IAAgBC,EAAW,UAAU,EAAI;AAC/CD,EAAAA,EAAc,MAAM,SAAS,QAC7BA,EAAc,MAAM,OAAO,WAClB,SAAA,KAAK,YAAYA,CAAa;AACjC,QAAAE,IAASF,EAAc,sBAAA,EAAwB;AAC5C,kBAAA,KAAK,YAAYA,CAAa,GAChCE;AACT,GAEaC,IAAuB,CAAC,EAAE,UAAAC,GAAU,sBAAAC,GAAsB,UAAAC,QAA0C;AAC/G,QAAM,IAAIC,KACJ,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxC,CAACG,GAAeC,CAAgB,IAAIJ,EAAmB,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,EAAG,CAAA,GACtF,CAACK,GAAYC,CAAa,IAAIN,EAAS,CAAC,GACxCO,IAAsBC,EAAO,CAAC,GA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,oBAAoB;AAAA,cACtC,cAAY,EAAE,KAAK,OAAO;AAAA,cAEzB,YAAE,MAAM;AAAA,YAAA;AAAA,UAAA,GAEb;AAAA,4BAEC,MACC,EAAA,UAAA,gBAAAC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAMX,EAAa,aAAa;AAAA,cACzC,WAAWU,EAAO,oBAAoB;AAAA,cACtC,cAAY,EAAE,KAAK,OAAO;AAAA,cAEzB,YAAE,MAAM;AAAA,YAAA;AAAA,UAAA,GAEb;AAAA,QAAA,GACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -4,7 +4,7 @@ import "../../../../clsx-OuTLNxxd.js";
4
4
  import "../../../../helpers-DONVwywj.js";
5
5
  import "../../../../Lexical.prod-eo-UKDld.js";
6
6
  import "react";
7
- import { T as B } from "../../../../TablePlugin-B-Q_UBXj.js";
7
+ import { T as B } from "../../../../TablePlugin-CMsi2UDH.js";
8
8
  import "../../hooks/useFlyout.js";
9
9
  import "../../../Icon/Icon.js";
10
10
  import "../../../Buttons/Button.js";
@@ -19,7 +19,7 @@ import "../../../IconButton/IconButton.js";
19
19
  import "../../../Input/Input.js";
20
20
  import "../../../InputField/InputField.js";
21
21
  import "react-router-dom";
22
- import "../../../../RteEditor.module-BwAtWRHo.js";
22
+ import "../../../../RteEditor.module-XCAFrP3U.js";
23
23
  import "../../hooks/useTranslation.js";
24
24
  import "../../Providers/LanguageProvider.js";
25
25
  import "../../../SelectListbox/SelectListbox.js";