diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-10-15 21:57:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 21:57:28 +0300 |
commit | c3d0cc55d98fb32b25cd2164cfa1c399985e7c84 (patch) | |
tree | 6a06ca7ec00e6c7143002fa1762bc5e08f858d4e /src/lib | |
parent | fe5eb507ca693e4db9ca1317b522765a513fea8c (diff) | |
download | voidsky-c3d0cc55d98fb32b25cd2164cfa1c399985e7c84.tar.zst |
Edit profile dialog ALF refresh (#5633)
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/strings/helpers.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/strings/helpers.ts b/src/lib/strings/helpers.ts index acd55da2d..ca77c4666 100644 --- a/src/lib/strings/helpers.ts +++ b/src/lib/strings/helpers.ts @@ -41,6 +41,20 @@ export function useEnforceMaxGraphemeCount() { ) } +export function useWarnMaxGraphemeCount({ + text, + maxCount, +}: { + text: string + maxCount: number +}) { + const splitter = useMemo(() => new Graphemer(), []) + + return useMemo(() => { + return splitter.countGraphemes(text) > maxCount + }, [splitter, maxCount, text]) +} + // https://stackoverflow.com/a/52171480 export function toHashCode(str: string, seed = 0): number { let h1 = 0xdeadbeef ^ seed, |