@drghaliasri/butex 6.1.2 → 6.1.3

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.
@@ -10412,6 +10412,15 @@ function document2Messages(locale) {
10412
10412
  return DOCUMENT2_MESSAGES[locale];
10413
10413
  }
10414
10414
 
10415
+ // src/react-document2/xelatexTextValidation.ts
10416
+ var XELATEX_UNSUPPORTED_EMOJI_PATTERN = /[\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Regional_Indicator}\uFE0F\u20E3]/u;
10417
+ function hasXeLatexUnsupportedEmoji(value) {
10418
+ return XELATEX_UNSUPPORTED_EMOJI_PATTERN.test(value);
10419
+ }
10420
+ function unsupportedEmojiMessage(uiLocale) {
10421
+ return uiLocale === "ar" ? "\u0647\u0630\u0627 \u0627\u0644\u0631\u0645\u0632 \u0627\u0644\u062A\u0639\u0628\u064A\u0631\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645." : "This emoji is not supported.";
10422
+ }
10423
+
10415
10424
  // src/react-document2/ArticleMetaPanel.tsx
10416
10425
  import { jsx, jsxs } from "react/jsx-runtime";
10417
10426
  var HIJRI_DAYS = Array.from({ length: 30 }, (_, index) => index + 1);
@@ -10419,6 +10428,20 @@ var HIJRI_YEARS = Array.from(
10419
10428
  { length: HIJRI_YEAR_MAX - HIJRI_YEAR_MIN + 1 },
10420
10429
  (_, index) => HIJRI_YEAR_MIN + index
10421
10430
  );
10431
+ var UNSUPPORTED_EMOJI_STYLE = {
10432
+ borderColor: "var(--butex-document2-error)",
10433
+ background: "var(--butex-document2-error-bg)"
10434
+ };
10435
+ function UnsupportedEmojiWarning({
10436
+ id,
10437
+ show,
10438
+ uiLocale
10439
+ }) {
10440
+ if (!show) {
10441
+ return null;
10442
+ }
10443
+ return /* @__PURE__ */ jsx("p", { id, className: "butex-document2-widget__field-error", children: unsupportedEmojiMessage(uiLocale) });
10444
+ }
10422
10445
  function HijriDateMenu({
10423
10446
  label,
10424
10447
  value,
@@ -10496,6 +10519,12 @@ function ArticleMetaPanel({
10496
10519
  const localRef = useRef(null);
10497
10520
  const resolvedRef = panelRef ?? localRef;
10498
10521
  const formattedDate = formatHijriDate(meta.date, { locale: uiLocale, digitForm });
10522
+ const titleUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.title);
10523
+ const authorsUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.authors);
10524
+ const abstractUnsupportedEmoji = hasXeLatexUnsupportedEmoji(meta.abstract);
10525
+ const titleErrorId = "butex-document2-meta-title-unsupported-emoji";
10526
+ const authorsErrorId = "butex-document2-meta-authors-unsupported-emoji";
10527
+ const abstractErrorId = "butex-document2-meta-abstract-unsupported-emoji";
10499
10528
  return /* @__PURE__ */ jsxs(
10500
10529
  "section",
10501
10530
  {
@@ -10522,12 +10551,16 @@ function ArticleMetaPanel({
10522
10551
  {
10523
10552
  ref: titleInputRef,
10524
10553
  value: meta.title,
10554
+ "aria-invalid": titleUnsupportedEmoji ? true : void 0,
10555
+ "aria-describedby": titleUnsupportedEmoji ? titleErrorId : void 0,
10556
+ style: titleUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
10525
10557
  onChange: (event) => {
10526
10558
  const value = event.currentTarget.value;
10527
10559
  onChange({ title: value });
10528
10560
  }
10529
10561
  }
10530
- )
10562
+ ),
10563
+ /* @__PURE__ */ jsx(UnsupportedEmojiWarning, { id: titleErrorId, show: titleUnsupportedEmoji, uiLocale })
10531
10564
  ] }),
10532
10565
  /* @__PURE__ */ jsxs("label", { className: "butex-document2-widget__article-meta-field", children: [
10533
10566
  /* @__PURE__ */ jsx("span", { children: messages.articleAuthors }),
@@ -10536,12 +10569,16 @@ function ArticleMetaPanel({
10536
10569
  {
10537
10570
  rows: 2,
10538
10571
  value: meta.authors,
10572
+ "aria-invalid": authorsUnsupportedEmoji ? true : void 0,
10573
+ "aria-describedby": authorsUnsupportedEmoji ? authorsErrorId : void 0,
10574
+ style: authorsUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
10539
10575
  onChange: (event) => {
10540
10576
  const value = event.currentTarget.value;
10541
10577
  onChange({ authors: value });
10542
10578
  }
10543
10579
  }
10544
- )
10580
+ ),
10581
+ /* @__PURE__ */ jsx(UnsupportedEmojiWarning, { id: authorsErrorId, show: authorsUnsupportedEmoji, uiLocale })
10545
10582
  ] }),
10546
10583
  /* @__PURE__ */ jsxs("div", { className: "butex-document2-widget__article-meta-field", children: [
10547
10584
  /* @__PURE__ */ jsx("span", { children: messages.articleDate }),
@@ -10592,12 +10629,16 @@ function ArticleMetaPanel({
10592
10629
  {
10593
10630
  rows: 3,
10594
10631
  value: meta.abstract,
10632
+ "aria-invalid": abstractUnsupportedEmoji ? true : void 0,
10633
+ "aria-describedby": abstractUnsupportedEmoji ? abstractErrorId : void 0,
10634
+ style: abstractUnsupportedEmoji ? UNSUPPORTED_EMOJI_STYLE : void 0,
10595
10635
  onChange: (event) => {
10596
10636
  const value = event.currentTarget.value;
10597
10637
  onChange({ abstract: value });
10598
10638
  }
10599
10639
  }
10600
- )
10640
+ ),
10641
+ /* @__PURE__ */ jsx(UnsupportedEmojiWarning, { id: abstractErrorId, show: abstractUnsupportedEmoji, uiLocale })
10601
10642
  ] })
10602
10643
  ] }),
10603
10644
  /* @__PURE__ */ jsx("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: BUTEX_CLOSING_HAMDALA })
@@ -11333,12 +11374,6 @@ function RefChip({
11333
11374
  ] });
11334
11375
  }
11335
11376
 
11336
- // src/react-document2/xelatexTextValidation.ts
11337
- var XELATEX_UNSUPPORTED_EMOJI_PATTERN = /[\p{Emoji_Presentation}\p{Emoji_Modifier}\p{Regional_Indicator}\uFE0F\u20E3]/u;
11338
- function hasXeLatexUnsupportedEmoji(value) {
11339
- return XELATEX_UNSUPPORTED_EMOJI_PATTERN.test(value);
11340
- }
11341
-
11342
11377
  // src/react-document2/InlineField.tsx
11343
11378
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
11344
11379
  function rememberCaret(element, blockId, fieldId, tokenId, onFieldFocus) {
@@ -11358,9 +11393,6 @@ function fitTextareaHeight(element) {
11358
11393
  element.style.height = "auto";
11359
11394
  element.style.height = `${String(element.scrollHeight)}px`;
11360
11395
  }
11361
- function xeLatexUnsupportedEmojiMessage(uiLocale) {
11362
- return uiLocale === "ar" ? "\u0647\u0630\u0627 \u0627\u0644\u0631\u0645\u0632 \u0627\u0644\u062A\u0639\u0628\u064A\u0631\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u0641\u064A \u062A\u0635\u062F\u064A\u0631 XeLaTeX \u0627\u0644\u062D\u0627\u0644\u064A \u0628\u062E\u0637 Amiri." : "This emoji is not supported by the current XeLaTeX export using the Amiri font.";
11363
- }
11364
11396
  function InlineField({
11365
11397
  field,
11366
11398
  blockId,
@@ -11480,7 +11512,7 @@ function InlineField({
11480
11512
  return /* @__PURE__ */ jsx6("div", { className: "butex-document2-widget__inline-field", dir: documentDirection, "data-document-direction": documentDirection, children: field.tokens.map((token) => {
11481
11513
  if (token.kind === "text") {
11482
11514
  const unsupportedEmoji = hasXeLatexUnsupportedEmoji(token.text);
11483
- const errorId = `butex-document2-xelatex-text-error-${token.id}`;
11515
+ const errorId = `butex-document2-unsupported-emoji-${token.id}`;
11484
11516
  return /* @__PURE__ */ jsxs5(Fragment, { children: [
11485
11517
  /* @__PURE__ */ jsx6(
11486
11518
  "textarea",
@@ -11561,7 +11593,7 @@ function InlineField({
11561
11593
  id: errorId,
11562
11594
  className: "butex-document2-widget__field-error",
11563
11595
  style: { flexBasis: "100%" },
11564
- children: xeLatexUnsupportedEmojiMessage(uiLocale)
11596
+ children: unsupportedEmojiMessage(uiLocale)
11565
11597
  }
11566
11598
  ) : null
11567
11599
  ] }, token.id);