@arqel-dev/i18n 0.8.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/LICENSE +21 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arqel Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Translation values are stored as a nested object — exactly as Laravel
|
|
5
|
+
* `lang/{locale}/arqel.php` returns. Lookup is dotted-path:
|
|
6
|
+
* `actions.create` → `translations.actions.create`.
|
|
7
|
+
*/
|
|
8
|
+
type TranslationDictionary = {
|
|
9
|
+
readonly [key: string]: string | TranslationDictionary;
|
|
10
|
+
};
|
|
11
|
+
type I18nSharedProps = {
|
|
12
|
+
locale: string;
|
|
13
|
+
available: readonly string[];
|
|
14
|
+
translations: TranslationDictionary;
|
|
15
|
+
};
|
|
16
|
+
type TranslateFn = (key: string, params?: Readonly<Record<string, string | number>>) => string;
|
|
17
|
+
type I18nContextValue = {
|
|
18
|
+
locale: string;
|
|
19
|
+
available: readonly string[];
|
|
20
|
+
translations: TranslationDictionary;
|
|
21
|
+
t: TranslateFn;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type I18nProviderProps = {
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Override the shared-prop `i18n` payload (useful in tests or in
|
|
28
|
+
* non-Inertia hosts). When omitted, falls back to
|
|
29
|
+
* `usePage().props.i18n`.
|
|
30
|
+
*/
|
|
31
|
+
i18n?: I18nSharedProps;
|
|
32
|
+
/** Fallback locale when neither `i18n` nor Inertia shared props supply one. */
|
|
33
|
+
fallbackLocale?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Provider que torna `useTranslation()` disponível abaixo. Lê os dados
|
|
37
|
+
* de `usePage().props.i18n` injetados pelo middleware PHP (ver
|
|
38
|
+
* `Arqel\Core\Http\Middleware\HandleArqelInertiaRequests`). Em testes
|
|
39
|
+
* ou em ambientes sem Inertia, a prop `i18n` pode ser passada
|
|
40
|
+
* diretamente.
|
|
41
|
+
*/
|
|
42
|
+
declare function I18nProvider({ children, i18n, fallbackLocale, }: I18nProviderProps): ReactElement;
|
|
43
|
+
declare function useI18nContext(): I18nContextValue;
|
|
44
|
+
|
|
45
|
+
type LocaleSwitcherProps = {
|
|
46
|
+
/** Endpoint POST que persiste o locale na sessão (default `/admin/locale`). */
|
|
47
|
+
endpoint?: string;
|
|
48
|
+
/** Label visível acima do select (default usa `t('locale.switcher.label')`). */
|
|
49
|
+
label?: string;
|
|
50
|
+
/** Override do mapa locale → display name. */
|
|
51
|
+
labels?: Readonly<Record<string, string>>;
|
|
52
|
+
className?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* `<LocaleSwitcher />` — Radix Select styled (shadcn) que dispara POST
|
|
56
|
+
* para `endpoint` com `{locale}`, aproveitando Inertia router para
|
|
57
|
+
* preservar state e re-renderizar com o novo locale resolvido.
|
|
58
|
+
*/
|
|
59
|
+
declare function LocaleSwitcher({ endpoint, label, labels, className, }: LocaleSwitcherProps): ReactElement;
|
|
60
|
+
|
|
61
|
+
declare function buildTranslator(dict: TranslationDictionary): TranslateFn;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* `useTranslation()` retorna o tradutor já bound ao locale ativo do
|
|
65
|
+
* provider. Mirror compacto da assinatura do Laravel `__()`:
|
|
66
|
+
*
|
|
67
|
+
* ```tsx
|
|
68
|
+
* const t = useTranslation();
|
|
69
|
+
* t('actions.save'); // → "Save" / "Salvar"
|
|
70
|
+
* t('messages.welcome', { name: 'Diogo' });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function useTranslation(): TranslateFn;
|
|
74
|
+
declare function useI18n(): {
|
|
75
|
+
t: TranslateFn;
|
|
76
|
+
locale: string;
|
|
77
|
+
available: readonly string[];
|
|
78
|
+
translations: TranslationDictionary;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { type I18nContextValue, I18nProvider, type I18nSharedProps, LocaleSwitcher, type TranslateFn, type TranslationDictionary, buildTranslator, useI18n, useI18nContext, useTranslation };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// src/I18nProvider.tsx
|
|
2
|
+
import { usePage } from "@inertiajs/react";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
|
|
5
|
+
// src/translate.ts
|
|
6
|
+
function lookup(dict, key) {
|
|
7
|
+
const segments = key.split(".");
|
|
8
|
+
let cursor = dict;
|
|
9
|
+
for (const segment of segments) {
|
|
10
|
+
if (cursor === void 0 || typeof cursor === "string") {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
cursor = cursor[segment];
|
|
14
|
+
}
|
|
15
|
+
return typeof cursor === "string" ? cursor : void 0;
|
|
16
|
+
}
|
|
17
|
+
function interpolate(template, params) {
|
|
18
|
+
if (params === void 0) {
|
|
19
|
+
return template;
|
|
20
|
+
}
|
|
21
|
+
return template.replace(/:([a-zA-Z0-9_]+)/g, (match, name) => {
|
|
22
|
+
const value = params[name];
|
|
23
|
+
return value === void 0 ? match : String(value);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function buildTranslator(dict) {
|
|
27
|
+
return (key, params) => {
|
|
28
|
+
const found = lookup(dict, key);
|
|
29
|
+
return found === void 0 ? key : interpolate(found, params);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/I18nProvider.tsx
|
|
34
|
+
import { jsx } from "react/jsx-runtime";
|
|
35
|
+
var I18nContext = createContext(null);
|
|
36
|
+
function I18nProvider({
|
|
37
|
+
children,
|
|
38
|
+
i18n,
|
|
39
|
+
fallbackLocale = "en"
|
|
40
|
+
}) {
|
|
41
|
+
const sharedI18n = useSharedI18n();
|
|
42
|
+
const resolved = i18n ?? sharedI18n ?? {
|
|
43
|
+
locale: fallbackLocale,
|
|
44
|
+
available: [fallbackLocale],
|
|
45
|
+
translations: {}
|
|
46
|
+
};
|
|
47
|
+
const value = useMemo(
|
|
48
|
+
() => ({
|
|
49
|
+
locale: resolved.locale,
|
|
50
|
+
available: resolved.available,
|
|
51
|
+
translations: resolved.translations,
|
|
52
|
+
t: buildTranslator(resolved.translations)
|
|
53
|
+
}),
|
|
54
|
+
[resolved.locale, resolved.available, resolved.translations]
|
|
55
|
+
);
|
|
56
|
+
return /* @__PURE__ */ jsx(I18nContext.Provider, { value, children });
|
|
57
|
+
}
|
|
58
|
+
function useSharedI18n() {
|
|
59
|
+
const page = usePage();
|
|
60
|
+
const i18n = page?.props?.["i18n"];
|
|
61
|
+
return isI18nSharedProps(i18n) ? i18n : void 0;
|
|
62
|
+
}
|
|
63
|
+
function isI18nSharedProps(value) {
|
|
64
|
+
if (typeof value !== "object" || value === null) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const v = value;
|
|
68
|
+
return typeof v["locale"] === "string" && Array.isArray(v["available"]) && typeof v["translations"] === "object" && v["translations"] !== null;
|
|
69
|
+
}
|
|
70
|
+
function useI18nContext() {
|
|
71
|
+
const ctx = useContext(I18nContext);
|
|
72
|
+
if (ctx === null) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"[@arqel-dev/i18n] useTranslation/useI18n must be used inside an <I18nProvider>."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return ctx;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/LocaleSwitcher.tsx
|
|
81
|
+
import {
|
|
82
|
+
Label,
|
|
83
|
+
Select,
|
|
84
|
+
SelectContent,
|
|
85
|
+
SelectItem,
|
|
86
|
+
SelectTrigger,
|
|
87
|
+
SelectValue
|
|
88
|
+
} from "@arqel-dev/ui";
|
|
89
|
+
import { router } from "@inertiajs/react";
|
|
90
|
+
import { useId } from "react";
|
|
91
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
92
|
+
var DEFAULT_LABELS = {
|
|
93
|
+
en: "English",
|
|
94
|
+
pt_BR: "Portugu\xEAs (BR)",
|
|
95
|
+
"pt-BR": "Portugu\xEAs (BR)",
|
|
96
|
+
es: "Espa\xF1ol",
|
|
97
|
+
fr: "Fran\xE7ais"
|
|
98
|
+
};
|
|
99
|
+
function LocaleSwitcher({
|
|
100
|
+
endpoint = "/admin/locale",
|
|
101
|
+
label,
|
|
102
|
+
labels,
|
|
103
|
+
className
|
|
104
|
+
}) {
|
|
105
|
+
const { locale, available, t } = useI18nContext();
|
|
106
|
+
const selectId = useId();
|
|
107
|
+
const fieldLabel = label ?? t("locale.switcher.label");
|
|
108
|
+
const map = { ...DEFAULT_LABELS, ...labels ?? {} };
|
|
109
|
+
const handleValueChange = (next) => {
|
|
110
|
+
if (next === locale) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
router.post(endpoint, { locale: next }, { preserveScroll: true, preserveState: true });
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", { className, "data-arqel-locale-switcher": "", children: [
|
|
116
|
+
/* @__PURE__ */ jsx2(Label, { htmlFor: selectId, className: "text-xs text-muted-foreground mb-1 block", children: fieldLabel }),
|
|
117
|
+
/* @__PURE__ */ jsxs(Select, { value: locale, onValueChange: handleValueChange, children: [
|
|
118
|
+
/* @__PURE__ */ jsx2(SelectTrigger, { id: selectId, "aria-label": fieldLabel, children: /* @__PURE__ */ jsx2(SelectValue, { placeholder: fieldLabel }) }),
|
|
119
|
+
/* @__PURE__ */ jsx2(SelectContent, { children: available.map((code) => /* @__PURE__ */ jsx2(SelectItem, { value: code, children: map[code] ?? code }, code)) })
|
|
120
|
+
] })
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/useTranslation.ts
|
|
125
|
+
function useTranslation() {
|
|
126
|
+
return useI18nContext().t;
|
|
127
|
+
}
|
|
128
|
+
function useI18n() {
|
|
129
|
+
const { t, locale, available, translations } = useI18nContext();
|
|
130
|
+
return { t, locale, available, translations };
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
I18nProvider,
|
|
134
|
+
LocaleSwitcher,
|
|
135
|
+
buildTranslator,
|
|
136
|
+
useI18n,
|
|
137
|
+
useI18nContext,
|
|
138
|
+
useTranslation
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/I18nProvider.tsx","../src/translate.ts","../src/LocaleSwitcher.tsx","../src/useTranslation.ts"],"sourcesContent":["import { usePage } from '@inertiajs/react';\nimport { createContext, type ReactElement, type ReactNode, useContext, useMemo } from 'react';\nimport { buildTranslator } from './translate';\nimport type { I18nContextValue, I18nSharedProps } from './types';\n\nconst I18nContext = createContext<I18nContextValue | null>(null);\n\ntype I18nProviderProps = {\n children: ReactNode;\n /**\n * Override the shared-prop `i18n` payload (useful in tests or in\n * non-Inertia hosts). When omitted, falls back to\n * `usePage().props.i18n`.\n */\n i18n?: I18nSharedProps;\n /** Fallback locale when neither `i18n` nor Inertia shared props supply one. */\n fallbackLocale?: string;\n};\n\n/**\n * Provider que torna `useTranslation()` disponível abaixo. Lê os dados\n * de `usePage().props.i18n` injetados pelo middleware PHP (ver\n * `Arqel\\Core\\Http\\Middleware\\HandleArqelInertiaRequests`). Em testes\n * ou em ambientes sem Inertia, a prop `i18n` pode ser passada\n * diretamente.\n */\nexport function I18nProvider({\n children,\n i18n,\n fallbackLocale = 'en',\n}: I18nProviderProps): ReactElement {\n const sharedI18n = useSharedI18n();\n const resolved: I18nSharedProps = i18n ??\n sharedI18n ?? {\n locale: fallbackLocale,\n available: [fallbackLocale],\n translations: {},\n };\n\n const value = useMemo<I18nContextValue>(\n () => ({\n locale: resolved.locale,\n available: resolved.available,\n translations: resolved.translations,\n t: buildTranslator(resolved.translations),\n }),\n [resolved.locale, resolved.available, resolved.translations],\n );\n\n return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>;\n}\n\nfunction useSharedI18n(): I18nSharedProps | undefined {\n // `usePage` is always called unconditionally to honour Rules of\n // Hooks. When Inertia is not bootstrapped, our test mock returns\n // `{ props: {} }` so the lookup just yields `undefined` here.\n const page = usePage();\n const i18n = (page?.props as Record<string, unknown> | undefined)?.['i18n'];\n return isI18nSharedProps(i18n) ? i18n : undefined;\n}\n\nfunction isI18nSharedProps(value: unknown): value is I18nSharedProps {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const v = value as Record<string, unknown>;\n return (\n typeof v['locale'] === 'string' &&\n Array.isArray(v['available']) &&\n typeof v['translations'] === 'object' &&\n v['translations'] !== null\n );\n}\n\nexport function useI18nContext(): I18nContextValue {\n const ctx = useContext(I18nContext);\n if (ctx === null) {\n throw new Error(\n '[@arqel-dev/i18n] useTranslation/useI18n must be used inside an <I18nProvider>.',\n );\n }\n return ctx;\n}\n","import type { TranslateFn, TranslationDictionary } from './types';\n\n/**\n * Walks the dotted-path `key` through `dict`, returning the leaf string\n * or — when missing — the original key. This mirrors Laravel's `__()`\n * fallback behaviour, keeping missing keys visible during development\n * without throwing in production.\n */\nfunction lookup(dict: TranslationDictionary, key: string): string | undefined {\n const segments = key.split('.');\n let cursor: string | TranslationDictionary | undefined = dict;\n for (const segment of segments) {\n if (cursor === undefined || typeof cursor === 'string') {\n return undefined;\n }\n cursor = cursor[segment];\n }\n return typeof cursor === 'string' ? cursor : undefined;\n}\n\n/**\n * Replaces `:placeholder` tokens with values from `params`. Numeric\n * values are coerced to strings — keep the API symmetric with Laravel\n * `__('greeting', ['name' => $name])`.\n */\nfunction interpolate(template: string, params?: Readonly<Record<string, string | number>>): string {\n if (params === undefined) {\n return template;\n }\n return template.replace(/:([a-zA-Z0-9_]+)/g, (match, name: string) => {\n const value = params[name];\n return value === undefined ? match : String(value);\n });\n}\n\nexport function buildTranslator(dict: TranslationDictionary): TranslateFn {\n return (key, params) => {\n const found = lookup(dict, key);\n return found === undefined ? key : interpolate(found, params);\n };\n}\n","import {\n Label,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@arqel-dev/ui';\nimport { router } from '@inertiajs/react';\nimport { type ReactElement, useId } from 'react';\nimport { useI18nContext } from './I18nProvider';\n\ntype LocaleSwitcherProps = {\n /** Endpoint POST que persiste o locale na sessão (default `/admin/locale`). */\n endpoint?: string;\n /** Label visível acima do select (default usa `t('locale.switcher.label')`). */\n label?: string;\n /** Override do mapa locale → display name. */\n labels?: Readonly<Record<string, string>>;\n className?: string;\n};\n\nconst DEFAULT_LABELS: Readonly<Record<string, string>> = {\n en: 'English',\n pt_BR: 'Português (BR)',\n 'pt-BR': 'Português (BR)',\n es: 'Español',\n fr: 'Français',\n};\n\n/**\n * `<LocaleSwitcher />` — Radix Select styled (shadcn) que dispara POST\n * para `endpoint` com `{locale}`, aproveitando Inertia router para\n * preservar state e re-renderizar com o novo locale resolvido.\n */\nexport function LocaleSwitcher({\n endpoint = '/admin/locale',\n label,\n labels,\n className,\n}: LocaleSwitcherProps): ReactElement {\n const { locale, available, t } = useI18nContext();\n const selectId = useId();\n const fieldLabel = label ?? t('locale.switcher.label');\n const map = { ...DEFAULT_LABELS, ...(labels ?? {}) };\n\n const handleValueChange = (next: string): void => {\n if (next === locale) {\n return;\n }\n router.post(endpoint, { locale: next }, { preserveScroll: true, preserveState: true });\n };\n\n return (\n <div className={className} data-arqel-locale-switcher=\"\">\n <Label htmlFor={selectId} className=\"text-xs text-muted-foreground mb-1 block\">\n {fieldLabel}\n </Label>\n <Select value={locale} onValueChange={handleValueChange}>\n <SelectTrigger id={selectId} aria-label={fieldLabel}>\n <SelectValue placeholder={fieldLabel} />\n </SelectTrigger>\n <SelectContent>\n {available.map((code) => (\n <SelectItem key={code} value={code}>\n {map[code] ?? code}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n );\n}\n","import { useI18nContext } from './I18nProvider';\nimport type { TranslateFn } from './types';\n\n/**\n * `useTranslation()` retorna o tradutor já bound ao locale ativo do\n * provider. Mirror compacto da assinatura do Laravel `__()`:\n *\n * ```tsx\n * const t = useTranslation();\n * t('actions.save'); // → \"Save\" / \"Salvar\"\n * t('messages.welcome', { name: 'Diogo' });\n * ```\n */\nexport function useTranslation(): TranslateFn {\n return useI18nContext().t;\n}\n\nexport function useI18n() {\n const { t, locale, available, translations } = useI18nContext();\n return { t, locale, available, translations };\n}\n"],"mappings":";AAA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,SACE,qBAAC,SAAI,WAAsB,8BAA2B,IACpD;AAAA,oBAAAA,KAAC,SAAM,SAAS,UAAU,WAAU,4CACjC,sBACH;AAAA,IACA,qBAAC,UAAO,OAAO,QAAQ,eAAe,mBACpC;AAAA,sBAAAA,KAAC,iBAAc,IAAI,UAAU,cAAY,YACvC,0BAAAA,KAAC,eAAY,aAAa,YAAY,GACxC;AAAA,MACA,gBAAAA,KAAC,iBACE,oBAAU,IAAI,CAAC,SACd,gBAAAA,KAAC,cAAsB,OAAO,MAC3B,cAAI,IAAI,KAAK,QADC,IAEjB,CACD,GACH;AAAA,OACF;AAAA,KACF;AAEJ;;;AC3DO,SAAS,iBAA8B;AAC5C,SAAO,eAAe,EAAE;AAC1B;AAEO,SAAS,UAAU;AACxB,QAAM,EAAE,GAAG,QAAQ,WAAW,aAAa,IAAI,eAAe;AAC9D,SAAO,EAAE,GAAG,QAAQ,WAAW,aAAa;AAC9C;","names":["jsx"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arqel-dev/i18n",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Internationalization primitives for Arqel admin panels (Inertia-driven, no runtime deps).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://arqel.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/arqel-dev/arqel.git",
|
|
10
|
+
"directory": "packages-js/i18n"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"arqel",
|
|
14
|
+
"laravel",
|
|
15
|
+
"inertia",
|
|
16
|
+
"react",
|
|
17
|
+
"i18n",
|
|
18
|
+
"translations"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"SKILL.md"
|
|
32
|
+
],
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@inertiajs/react": "^2.0.0 || ^3.0.0",
|
|
35
|
+
"react": "^19.0.0",
|
|
36
|
+
"react-dom": "^19.0.0",
|
|
37
|
+
"@arqel-dev/ui": "0.8.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@inertiajs/core": "^2.0.0",
|
|
41
|
+
"@inertiajs/react": "^2.0.0",
|
|
42
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
43
|
+
"@testing-library/react": "^16.1.0",
|
|
44
|
+
"@types/react": "^19.0.0",
|
|
45
|
+
"@types/react-dom": "^19.0.0",
|
|
46
|
+
"jsdom": "^25.0.1",
|
|
47
|
+
"react": "^19.0.0",
|
|
48
|
+
"react-dom": "^19.0.0",
|
|
49
|
+
"tsup": "^8.5.0",
|
|
50
|
+
"typescript": "^5.6.3",
|
|
51
|
+
"vitest": "^3.0.0",
|
|
52
|
+
"@arqel-dev/ui": "0.8.0"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=20.9.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsup",
|
|
62
|
+
"dev": "tsup --watch",
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"lint": "biome check --diagnostic-level=error src tests",
|
|
65
|
+
"format": "biome format --write src tests",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"test:watch": "vitest"
|
|
68
|
+
}
|
|
69
|
+
}
|