@alfadocs/ui-kit-debug 0.6.1 → 0.7.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfadocs/ui-kit-debug",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "AlfaDocs shared design system — tokens, components, patterns, and translations for platform, booking, and alfascribe. (debug build — identical runtime to @alfadocs/ui-kit, ships source maps for symbolication).",
6
6
  "license": "BUSL-1.1",
@@ -1,32 +0,0 @@
1
- import { useState as c, useEffect as s, useCallback as u } from "react";
2
- import "../i18n/config.js";
3
- import a from "i18next";
4
- function l(n) {
5
- const [o, i] = c(() => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia(n).matches);
6
- return s(() => {
7
- if (typeof window > "u" || typeof window.matchMedia != "function")
8
- return;
9
- const t = window.matchMedia(n);
10
- i(t.matches);
11
- const e = (r) => i(r.matches);
12
- return typeof t.addEventListener == "function" ? (t.addEventListener("change", e), () => t.removeEventListener("change", e)) : (t.addListener(e), () => t.removeListener(e));
13
- }, [n]), o;
14
- }
15
- function h() {
16
- const [n, o] = c(() => a.language);
17
- s(() => {
18
- const e = (r) => o(r);
19
- return a.on("languageChanged", e), a.language !== n && o(a.language), () => {
20
- a.off("languageChanged", e);
21
- };
22
- }, [n]);
23
- const i = u(async (e) => {
24
- await a.changeLanguage(e);
25
- }, []), t = a.dir(n) === "rtl" ? "rtl" : "ltr";
26
- return { locale: n, dir: t, setLocale: i };
27
- }
28
- export {
29
- l as a,
30
- h as u
31
- };
32
- //# sourceMappingURL=use-locale-BuXR_Zl9.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-locale-BuXR_Zl9.js","sources":["../../src/hooks/use-media-query.ts","../../src/hooks/use-locale.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * Subscribe to an arbitrary media query and return whether it currently\n * matches. Useful for responsive components that need to branch on\n * viewport size without hand-rolling `matchMedia` plumbing.\n *\n * SSR-safe: returns `false` when `window` is undefined. The effect is\n * client-only, so hydration mismatches are avoided without a null\n * sentinel at the type level.\n *\n * Mirrors the shape of `usePrefersReducedMotion` — Safari < 14 fallback\n * via `addListener` / `removeListener` is included.\n *\n * @example\n * const isMobile = useMediaQuery('(max-width: 640px)');\n */\nexport function useMediaQuery(query: string): boolean {\n const [matches, setMatches] = useState<boolean>(() => {\n if (\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return false;\n }\n return window.matchMedia(query).matches;\n });\n\n useEffect(() => {\n if (\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return;\n }\n const mql = window.matchMedia(query);\n // Re-sync in case the query (or the OS state) changed between the\n // initial useState read and the first effect.\n setMatches(mql.matches);\n const onChange = (ev: MediaQueryListEvent) => setMatches(ev.matches);\n if (typeof mql.addEventListener === 'function') {\n mql.addEventListener('change', onChange);\n return () => mql.removeEventListener('change', onChange);\n }\n mql.addListener(onChange);\n return () => mql.removeListener(onChange);\n }, [query]);\n\n return matches;\n}\n","import { useCallback, useEffect, useState } from 'react';\nimport i18n from '../i18n/config';\n\nexport type LocaleDir = 'ltr' | 'rtl';\n\nexport interface UseLocaleReturn {\n /** Current i18next language tag (e.g. `'en'`, `'ar'`, `'ja'`). */\n locale: string;\n /** Reading direction for the current locale, derived from `i18n.dir(locale)`. */\n dir: LocaleDir;\n /** Change the active i18next language. */\n setLocale: (next: string) => Promise<void>;\n}\n\n/**\n * Read the active i18n locale and its reading direction. Subscribes to\n * `i18next.on('languageChanged')` so consumers re-render when the locale\n * changes (e.g. via `<select>` in a settings page).\n *\n * SSR-safe: the initial state is read synchronously from the i18next\n * instance, which itself ships an SSR-friendly default. The\n * `languageChanged` listener attaches in `useEffect`, so it only runs\n * client-side.\n *\n * Thin wrapper — the underlying source of truth is the i18next instance\n * exported from `src/i18n/config.ts`. Use this hook over reading\n * `i18n.language` directly so components can:\n * 1. Re-render on language change without ad-hoc state.\n * 2. Get `dir` derived correctly (RTL for `ar`).\n */\nexport function useLocale(): UseLocaleReturn {\n const [locale, setLocaleState] = useState<string>(() => i18n.language);\n\n useEffect(() => {\n const onChange = (next: string) => setLocaleState(next);\n i18n.on('languageChanged', onChange);\n // Re-sync — the `i18n.language` may have settled between the\n // initial useState read and effect attach (async language load).\n if (i18n.language !== locale) setLocaleState(i18n.language);\n return () => {\n i18n.off('languageChanged', onChange);\n };\n }, [locale]);\n\n const setLocale = useCallback(async (next: string) => {\n await i18n.changeLanguage(next);\n }, []);\n\n // `i18n.dir(locale)` returns `'ltr' | 'rtl'` — the i18next types declare\n // it as `string`, so we narrow.\n const dir = (i18n.dir(locale) === 'rtl' ? 'rtl' : 'ltr') as LocaleDir;\n\n return { locale, dir, setLocale };\n}\n"],"names":["useMediaQuery","query","matches","setMatches","useState","useEffect","mql","onChange","ev","useLocale","locale","setLocaleState","i18n","next","setLocale","useCallback","dir"],"mappings":";;;AAiBO,SAASA,EAAcC,GAAwB;AACpD,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAkB,MAE5C,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,aAEtB,KAEF,OAAO,WAAWH,CAAK,EAAE,OACjC;AAED,SAAAI,EAAU,MAAM;AACd,QACE,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe;AAE7B;AAEF,UAAMC,IAAM,OAAO,WAAWL,CAAK;AAGnC,IAAAE,EAAWG,EAAI,OAAO;AACtB,UAAMC,IAAW,CAACC,MAA4BL,EAAWK,EAAG,OAAO;AACnE,WAAI,OAAOF,EAAI,oBAAqB,cAClCA,EAAI,iBAAiB,UAAUC,CAAQ,GAChC,MAAMD,EAAI,oBAAoB,UAAUC,CAAQ,MAEzDD,EAAI,YAAYC,CAAQ,GACjB,MAAMD,EAAI,eAAeC,CAAQ;AAAA,EAC1C,GAAG,CAACN,CAAK,CAAC,GAEHC;AACT;ACnB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