fetta 1.3.4 → 1.3.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.
package/README.md CHANGED
@@ -85,6 +85,7 @@ const result = splitText(element, options);
85
85
  | `onSplit` | `function` | — | Callback after initial split |
86
86
  | `revertOnComplete` | `boolean` | `false` | Auto-revert when animation completes |
87
87
  | `propIndex` | `boolean` | `false` | Add CSS custom properties: `--char-index`, `--word-index`, `--line-index` |
88
+ | `disableKerning` | `boolean` | `false` | Skip kerning compensation (no margin adjustments) |
88
89
 
89
90
  #### Return Value
90
91
 
@@ -110,7 +111,7 @@ import { SplitText } from 'fetta/react';
110
111
  | `children` | `ReactElement` | — | Single element to split |
111
112
  | `onSplit` | `function` | — | Called after text is split |
112
113
  | `onResize` | `function` | — | Called on autoSplit re-split |
113
- | `options` | `object` | — | Split options (type, classes, mask, propIndex) |
114
+ | `options` | `object` | — | Split options (type, classes, mask, propIndex, disableKerning) |
114
115
  | `autoSplit` | `boolean` | `false` | Re-split on container resize |
115
116
  | `revertOnComplete` | `boolean` | `false` | Revert after animation completes |
116
117
  | `inView` | `boolean \| InViewOptions` | `false` | Enable viewport detection |
@@ -33,6 +33,10 @@ var BREAK_CHARS = /* @__PURE__ */ new Set([
33
33
  "\u2015"
34
34
  // horizontal bar (U+2015)
35
35
  ]);
36
+ var CONTEXTUAL_SCRIPT_REGEX = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u0590-\u05FF\uFB1D-\uFB4F\u0E00-\u0E7F\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F]/;
37
+ function hasContextualScript(chars) {
38
+ return chars.some((char) => CONTEXTUAL_SCRIPT_REGEX.test(char));
39
+ }
36
40
  var INLINE_ELEMENTS = /* @__PURE__ */ new Set([
37
41
  "a",
38
42
  "abbr",
@@ -584,6 +588,8 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
584
588
  for (const wordSpan of allWords) {
585
589
  const wordChars = Array.from(wordSpan.querySelectorAll(`.${charClass}`));
586
590
  if (wordChars.length < 2) continue;
591
+ const charStringsForCheck = wordChars.map((c) => c.textContent || "");
592
+ if (hasContextualScript(charStringsForCheck)) continue;
587
593
  const styleGroups = [];
588
594
  const firstCharStyles = getComputedStyle(wordChars[0]);
589
595
  let currentKey = buildKerningStyleKey(firstCharStyles);
@@ -630,6 +636,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
630
636
  const lastChar = lastCharSpan.textContent || "";
631
637
  const firstChar = firstCharSpan.textContent || "";
632
638
  if (!lastChar || !firstChar) continue;
639
+ if (hasContextualScript([lastChar, firstChar])) continue;
633
640
  const styles = getComputedStyle(firstCharSpan);
634
641
  const kerningMap = measureKerning(element, firstCharSpan, [lastChar, " ", firstChar], styles);
635
642
  let totalKerning = 0;
@@ -650,6 +657,7 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
650
657
  if (!prevText || !currText) continue;
651
658
  const lastChar = prevText[prevText.length - 1];
652
659
  const firstChar = currText[0];
660
+ if (hasContextualScript([lastChar, firstChar])) continue;
653
661
  const styles = getComputedStyle(currWord);
654
662
  const kerningMap = measureKerning(element, currWord, [lastChar, " ", firstChar], styles);
655
663
  let totalKerning = 0;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { splitText } from './chunk-BXFBPQNP.js';
1
+ export { splitText } from './chunk-HQLYE4Q5.js';
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { splitText, __spreadProps, __spreadValues, normalizeToPromise } from './chunk-BXFBPQNP.js';
1
+ import { splitText, __spreadProps, __spreadValues, normalizeToPromise } from './chunk-HQLYE4Q5.js';
2
2
  import { forwardRef, useRef, useCallback, useState, useLayoutEffect, useEffect, isValidElement, cloneElement } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetta",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Text splitting library with kerning compensation for animations",
5
5
  "type": "module",
6
6
  "sideEffects": false,