@iris-ui-kit/vue 0.1.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/admin.cjs +1869 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +376 -0
- package/dist/admin.d.ts +376 -0
- package/dist/admin.js +10 -0
- package/dist/admin.js.map +1 -0
- package/dist/async.cjs +76 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +59 -0
- package/dist/async.d.ts +59 -0
- package/dist/async.js +3 -0
- package/dist/async.js.map +1 -0
- package/dist/behaviors.cjs +659 -0
- package/dist/behaviors.cjs.map +1 -0
- package/dist/behaviors.d.cts +441 -0
- package/dist/behaviors.d.ts +441 -0
- package/dist/behaviors.js +3 -0
- package/dist/behaviors.js.map +1 -0
- package/dist/chunk-3FJUCHCC.js +146 -0
- package/dist/chunk-3FJUCHCC.js.map +1 -0
- package/dist/chunk-3R3QDLJC.js +172 -0
- package/dist/chunk-3R3QDLJC.js.map +1 -0
- package/dist/chunk-4FLIW67H.js +137 -0
- package/dist/chunk-4FLIW67H.js.map +1 -0
- package/dist/chunk-4FQ7XF52.js +3 -0
- package/dist/chunk-4FQ7XF52.js.map +1 -0
- package/dist/chunk-72PZMU6R.js +99 -0
- package/dist/chunk-72PZMU6R.js.map +1 -0
- package/dist/chunk-75GSYEJS.js +17 -0
- package/dist/chunk-75GSYEJS.js.map +1 -0
- package/dist/chunk-7IOJADZC.js +38 -0
- package/dist/chunk-7IOJADZC.js.map +1 -0
- package/dist/chunk-CIZGSGXN.js +651 -0
- package/dist/chunk-CIZGSGXN.js.map +1 -0
- package/dist/chunk-F77KIPOH.js +103 -0
- package/dist/chunk-F77KIPOH.js.map +1 -0
- package/dist/chunk-FJBYAIL4.js +1318 -0
- package/dist/chunk-FJBYAIL4.js.map +1 -0
- package/dist/chunk-H7HVVPYR.js +66 -0
- package/dist/chunk-H7HVVPYR.js.map +1 -0
- package/dist/chunk-I6D5VXQK.js +167 -0
- package/dist/chunk-I6D5VXQK.js.map +1 -0
- package/dist/chunk-PPYNXNGZ.js +73 -0
- package/dist/chunk-PPYNXNGZ.js.map +1 -0
- package/dist/chunk-QLUIKEMJ.js +1197 -0
- package/dist/chunk-QLUIKEMJ.js.map +1 -0
- package/dist/chunk-ROJV6RON.js +3 -0
- package/dist/chunk-ROJV6RON.js.map +1 -0
- package/dist/chunk-S43IHHBU.js +82 -0
- package/dist/chunk-S43IHHBU.js.map +1 -0
- package/dist/chunk-TCAXRWT6.js +108 -0
- package/dist/chunk-TCAXRWT6.js.map +1 -0
- package/dist/chunk-TQB5LVOH.js +17 -0
- package/dist/chunk-TQB5LVOH.js.map +1 -0
- package/dist/chunk-VM2CXEUA.js +46 -0
- package/dist/chunk-VM2CXEUA.js.map +1 -0
- package/dist/chunk-W2JVHGFR.js +103 -0
- package/dist/chunk-W2JVHGFR.js.map +1 -0
- package/dist/chunk-WL67XCH5.js +59 -0
- package/dist/chunk-WL67XCH5.js.map +1 -0
- package/dist/chunk-XCNCIG2I.js +165 -0
- package/dist/chunk-XCNCIG2I.js.map +1 -0
- package/dist/chunk-XSLBANUV.js +16 -0
- package/dist/chunk-XSLBANUV.js.map +1 -0
- package/dist/chunk-ZY4NLITM.js +73 -0
- package/dist/chunk-ZY4NLITM.js.map +1 -0
- package/dist/data.cjs +59 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +46 -0
- package/dist/data.d.ts +46 -0
- package/dist/data.js +4 -0
- package/dist/data.js.map +1 -0
- package/dist/error-boundary.cjs +115 -0
- package/dist/error-boundary.cjs.map +1 -0
- package/dist/error-boundary.d.cts +60 -0
- package/dist/error-boundary.d.ts +60 -0
- package/dist/error-boundary.js +4 -0
- package/dist/error-boundary.js.map +1 -0
- package/dist/floating.cjs +149 -0
- package/dist/floating.cjs.map +1 -0
- package/dist/floating.d.cts +106 -0
- package/dist/floating.d.ts +106 -0
- package/dist/floating.js +4 -0
- package/dist/floating.js.map +1 -0
- package/dist/form.cjs +144 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +128 -0
- package/dist/form.d.ts +128 -0
- package/dist/form.js +3 -0
- package/dist/form.js.map +1 -0
- package/dist/i18n.cjs +112 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +99 -0
- package/dist/i18n.d.ts +99 -0
- package/dist/i18n.js +3 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.cjs +18673 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8087 -0
- package/dist/index.d.ts +8087 -0
- package/dist/index.js +13525 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.cjs +392 -0
- package/dist/layouts.cjs.map +1 -0
- package/dist/layouts.d.cts +406 -0
- package/dist/layouts.d.ts +406 -0
- package/dist/layouts.js +5 -0
- package/dist/layouts.js.map +1 -0
- package/dist/machine.cjs +19 -0
- package/dist/machine.cjs.map +1 -0
- package/dist/machine.d.cts +18 -0
- package/dist/machine.d.ts +18 -0
- package/dist/machine.js +4 -0
- package/dist/machine.js.map +1 -0
- package/dist/modal-utils.cjs +170 -0
- package/dist/modal-utils.cjs.map +1 -0
- package/dist/modal-utils.d.cts +43 -0
- package/dist/modal-utils.d.ts +43 -0
- package/dist/modal-utils.js +3 -0
- package/dist/modal-utils.js.map +1 -0
- package/dist/motion.cjs +88 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +43 -0
- package/dist/motion.d.ts +43 -0
- package/dist/motion.js +3 -0
- package/dist/motion.js.map +1 -0
- package/dist/provider.cjs +272 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +130 -0
- package/dist/provider.d.ts +130 -0
- package/dist/provider.js +6 -0
- package/dist/provider.js.map +1 -0
- package/dist/resource.cjs +25 -0
- package/dist/resource.cjs.map +1 -0
- package/dist/resource.d.cts +17 -0
- package/dist/resource.d.ts +17 -0
- package/dist/resource.js +3 -0
- package/dist/resource.js.map +1 -0
- package/dist/skeletons.cjs +1659 -0
- package/dist/skeletons.cjs.map +1 -0
- package/dist/skeletons.d.cts +179 -0
- package/dist/skeletons.d.ts +179 -0
- package/dist/skeletons.js +7 -0
- package/dist/skeletons.js.map +1 -0
- package/dist/skins.cjs +138 -0
- package/dist/skins.cjs.map +1 -0
- package/dist/skins.d.cts +67 -0
- package/dist/skins.d.ts +67 -0
- package/dist/skins.js +3 -0
- package/dist/skins.js.map +1 -0
- package/dist/theme.cjs +106 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +103 -0
- package/dist/theme.d.ts +103 -0
- package/dist/theme.js +3 -0
- package/dist/theme.js.map +1 -0
- package/dist/undo.cjs +51 -0
- package/dist/undo.cjs.map +1 -0
- package/dist/undo.d.cts +48 -0
- package/dist/undo.d.ts +48 -0
- package/dist/undo.js +3 -0
- package/dist/undo.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/context.ts","../src/i18n/I18nProvider.ts","../src/i18n/useI18n.ts"],"names":["defineComponent","createI18n","provide","watch","applyDirection","localeDirection","onScopeDispose","inject","ref","onBeforeUnmount","computed"],"mappings":";;;;;;;;;AAIO,IAAM,gBAAA,0BAA8C,UAAU;;;ACO9D,IAAM,mBAAmBA,mBAAA,CAAgB;AAAA,EAC9C,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,MAAA,EAAU;AAAA,IAC3C,QAAA,EAAU,EAAE,IAAA,EAAM,MAAA,EAAkC,SAAS,MAAA,EAAU;AAAA,IACvE,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAA0B,SAAS,MAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ3D,aAAA,EAAe,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,KAAA,EAAM;AAAA;AA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AA,EAAK,MAAA,KAAW;AAClB,MAAA,KAAK,MAAM,KAAA,CAAM,MAAA;AACjB,MAAA,OAAO,IAAA,CAAK,CAAA,CAAE,GAAA,EAAK,MAAM,CAAA;AAAA,IAC3B,CAAA;AAAA,IACA,UAAA,EAAY,CAAC,KAAA,EAAO,OAAA,KAAY;AAC9B,MAAA,KAAK,MAAM,KAAA,CAAM,MAAA;AACjB,MAAA,OAAO,IAAA,CAAK,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AAAA,IACvC,CAAA;AAAA,IACA,YAAA,EAAc,CAAC,KAAA,EAAO,OAAA,KAAY;AAChC,MAAA,KAAK,MAAM,KAAA,CAAM,MAAA;AACjB,MAAA,OAAO,IAAA,CAAK,YAAA,CAAa,KAAA,EAAO,OAAO,CAAA;AAAA,IACzC,CAAA;AAAA,IACA,kBAAA,EAAoB,CAAC,KAAA,EAAO,IAAA,EAAM,OAAA,KAAY;AAC5C,MAAA,KAAK,MAAM,KAAA,CAAM,MAAA;AACjB,MAAA,OAAO,IAAA,CAAK,kBAAA,CAAmB,KAAA,EAAO,IAAA,EAAM,OAAO,CAAA;AAAA,IACrD,CAAA;AAAA,IACA,WAAW,IAAA,CAAK,SAAA;AAAA,IAChB,aAAa,IAAA,CAAK;AAAA,GACpB;AACF","file":"i18n.cjs","sourcesContent":["import { type InjectionKey } from 'vue'\nimport type { I18n } from '@iris-ui-kit/core'\n\n/** Injection key carrying the active {@link I18n} instance to `useI18n`. */\nexport const I18nInjectionKey: InjectionKey<I18n> = Symbol('IrisI18n')\n","import { defineComponent, onScopeDispose, provide, watch, type PropType } from 'vue'\nimport { createI18n, localeDirection, type I18n, type I18nMessages } from '@iris-ui-kit/core'\nimport { applyDirection } from '@iris-ui-kit/theme'\nimport { I18nInjectionKey } from './context'\n\n/**\n * Makes a locale + message dictionary available to descendant components via\n * `useI18n`. Pass `locale` / `messages` (an instance is created and kept in\n * sync) or a pre-built `i18n` instance you control externally. Renderless:\n * renders its default slot.\n */\nexport const IrisI18nProvider = defineComponent({\n name: 'IrisI18nProvider',\n props: {\n locale: { type: String, default: undefined },\n messages: { type: Object as PropType<I18nMessages>, default: undefined },\n i18n: { type: Object as PropType<I18n>, default: undefined },\n /**\n * When set, the locale's writing direction ({@link localeDirection}) is\n * applied to `directionTarget` (`dir` + `data-iris-dir`) and `<html lang>`\n * is set whenever `locale` changes — so \"set locale → flip direction +\n * announce language\" needs no manual wiring. Off by default so it never\n * fights an explicit `<ThemeProvider dir>`. Reverts on unmount.\n */\n autoDirection: { type: Boolean, default: false },\n /** Element to receive dir/lang when `autoDirection` is set. Defaults to `document.documentElement`. */\n directionTarget: { type: Object as PropType<HTMLElement | null>, default: undefined },\n },\n setup(props, { slots }) {\n const instance = props.i18n ?? createI18n({ locale: props.locale, messages: props.messages })\n provide(I18nInjectionKey, instance)\n\n if (!props.i18n) {\n watch(\n () => props.locale,\n (locale) => {\n if (locale) instance.setLocale(locale)\n },\n )\n watch(\n () => props.messages,\n (messages) => {\n if (messages) instance.setMessages(messages)\n },\n )\n }\n\n // Auto-apply writing direction + `lang` from the active locale (opt-in).\n let revertDirection: (() => void) | null = null\n watch(\n () => [props.autoDirection, props.locale, props.directionTarget] as const,\n ([autoDirection, locale]) => {\n revertDirection?.()\n revertDirection = null\n if (!autoDirection || !locale || typeof document === 'undefined') return\n const el = props.directionTarget ?? document.documentElement\n const applied = applyDirection(localeDirection(locale), el)\n const prevLang = el.getAttribute('lang')\n el.setAttribute('lang', locale)\n revertDirection = () => {\n applied.revert()\n if (prevLang === null) el.removeAttribute('lang')\n else el.setAttribute('lang', prevLang)\n }\n },\n { immediate: true },\n )\n onScopeDispose(() => {\n revertDirection?.()\n revertDirection = null\n })\n\n return () => slots.default?.()\n },\n})\n","import { computed, inject, onBeforeUnmount, ref, type ComputedRef, type Ref } from 'vue'\nimport { createI18n, type I18n, type I18nState } from '@iris-ui-kit/core'\nimport { I18nInjectionKey } from './context'\n\nexport interface UseI18nReturn {\n locale: ComputedRef<string>\n t: I18n['t']\n formatDate: I18n['formatDate']\n formatNumber: I18n['formatNumber']\n formatRelativeTime: I18n['formatRelativeTime']\n setLocale: I18n['setLocale']\n setMessages: I18n['setMessages']\n}\n\n// Shared fallback so components can call `useI18n()` without an enclosing\n// provider — they get English defaults rather than throwing.\nlet fallbackI18n: I18n | null = null\nfunction getFallback(): I18n {\n if (fallbackI18n === null) fallbackI18n = createI18n()\n return fallbackI18n\n}\n\n/**\n * Reactive access to the active locale + translation/formatting helpers.\n * Works with or without an `<IrisI18nProvider>` (falls back to English\n * defaults). `t` / formatters read the live locale at call time, and `locale`\n * is a reactive ref so templates re-render on change.\n */\nexport function useI18n(): UseI18nReturn {\n const i18n = inject(I18nInjectionKey, null) ?? getFallback()\n const state = ref(i18n.getState()) as Ref<I18nState>\n const unsubscribe = i18n.subscribe((next) => {\n state.value = next\n })\n onBeforeUnmount(unsubscribe)\n\n return {\n locale: computed(() => state.value.locale),\n t: (key, params) => {\n void state.value.locale\n return i18n.t(key, params)\n },\n formatDate: (value, options) => {\n void state.value.locale\n return i18n.formatDate(value, options)\n },\n formatNumber: (value, options) => {\n void state.value.locale\n return i18n.formatNumber(value, options)\n },\n formatRelativeTime: (value, unit, options) => {\n void state.value.locale\n return i18n.formatRelativeTime(value, unit, options)\n },\n setLocale: i18n.setLocale,\n setMessages: i18n.setMessages,\n }\n}\n"]}
|
package/dist/i18n.d.cts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, ComputedRef, InjectionKey } from 'vue';
|
|
3
|
+
import { I18nMessages, I18n } from '@iris-ui-kit/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes a locale + message dictionary available to descendant components via
|
|
7
|
+
* `useI18n`. Pass `locale` / `messages` (an instance is created and kept in
|
|
8
|
+
* sync) or a pre-built `i18n` instance you control externally. Renderless:
|
|
9
|
+
* renders its default slot.
|
|
10
|
+
*/
|
|
11
|
+
declare const IrisI18nProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
12
|
+
locale: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
messages: {
|
|
17
|
+
type: PropType<I18nMessages>;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
i18n: {
|
|
21
|
+
type: PropType<I18n>;
|
|
22
|
+
default: undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* When set, the locale's writing direction ({@link localeDirection}) is
|
|
26
|
+
* applied to `directionTarget` (`dir` + `data-iris-dir`) and `<html lang>`
|
|
27
|
+
* is set whenever `locale` changes — so "set locale → flip direction +
|
|
28
|
+
* announce language" needs no manual wiring. Off by default so it never
|
|
29
|
+
* fights an explicit `<ThemeProvider dir>`. Reverts on unmount.
|
|
30
|
+
*/
|
|
31
|
+
autoDirection: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** Element to receive dir/lang when `autoDirection` is set. Defaults to `document.documentElement`. */
|
|
36
|
+
directionTarget: {
|
|
37
|
+
type: PropType<HTMLElement | null>;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
43
|
+
locale: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
messages: {
|
|
48
|
+
type: PropType<I18nMessages>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
i18n: {
|
|
52
|
+
type: PropType<I18n>;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* When set, the locale's writing direction ({@link localeDirection}) is
|
|
57
|
+
* applied to `directionTarget` (`dir` + `data-iris-dir`) and `<html lang>`
|
|
58
|
+
* is set whenever `locale` changes — so "set locale → flip direction +
|
|
59
|
+
* announce language" needs no manual wiring. Off by default so it never
|
|
60
|
+
* fights an explicit `<ThemeProvider dir>`. Reverts on unmount.
|
|
61
|
+
*/
|
|
62
|
+
autoDirection: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
default: boolean;
|
|
65
|
+
};
|
|
66
|
+
/** Element to receive dir/lang when `autoDirection` is set. Defaults to `document.documentElement`. */
|
|
67
|
+
directionTarget: {
|
|
68
|
+
type: PropType<HTMLElement | null>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
}>> & Readonly<{}>, {
|
|
72
|
+
locale: string;
|
|
73
|
+
messages: I18nMessages;
|
|
74
|
+
i18n: I18n;
|
|
75
|
+
autoDirection: boolean;
|
|
76
|
+
directionTarget: HTMLElement | null;
|
|
77
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
78
|
+
|
|
79
|
+
interface UseI18nReturn {
|
|
80
|
+
locale: ComputedRef<string>;
|
|
81
|
+
t: I18n['t'];
|
|
82
|
+
formatDate: I18n['formatDate'];
|
|
83
|
+
formatNumber: I18n['formatNumber'];
|
|
84
|
+
formatRelativeTime: I18n['formatRelativeTime'];
|
|
85
|
+
setLocale: I18n['setLocale'];
|
|
86
|
+
setMessages: I18n['setMessages'];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reactive access to the active locale + translation/formatting helpers.
|
|
90
|
+
* Works with or without an `<IrisI18nProvider>` (falls back to English
|
|
91
|
+
* defaults). `t` / formatters read the live locale at call time, and `locale`
|
|
92
|
+
* is a reactive ref so templates re-render on change.
|
|
93
|
+
*/
|
|
94
|
+
declare function useI18n(): UseI18nReturn;
|
|
95
|
+
|
|
96
|
+
/** Injection key carrying the active {@link I18n} instance to `useI18n`. */
|
|
97
|
+
declare const I18nInjectionKey: InjectionKey<I18n>;
|
|
98
|
+
|
|
99
|
+
export { I18nInjectionKey, IrisI18nProvider, type UseI18nReturn, useI18n };
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, ComputedRef, InjectionKey } from 'vue';
|
|
3
|
+
import { I18nMessages, I18n } from '@iris-ui-kit/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes a locale + message dictionary available to descendant components via
|
|
7
|
+
* `useI18n`. Pass `locale` / `messages` (an instance is created and kept in
|
|
8
|
+
* sync) or a pre-built `i18n` instance you control externally. Renderless:
|
|
9
|
+
* renders its default slot.
|
|
10
|
+
*/
|
|
11
|
+
declare const IrisI18nProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
12
|
+
locale: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
messages: {
|
|
17
|
+
type: PropType<I18nMessages>;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
i18n: {
|
|
21
|
+
type: PropType<I18n>;
|
|
22
|
+
default: undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* When set, the locale's writing direction ({@link localeDirection}) is
|
|
26
|
+
* applied to `directionTarget` (`dir` + `data-iris-dir`) and `<html lang>`
|
|
27
|
+
* is set whenever `locale` changes — so "set locale → flip direction +
|
|
28
|
+
* announce language" needs no manual wiring. Off by default so it never
|
|
29
|
+
* fights an explicit `<ThemeProvider dir>`. Reverts on unmount.
|
|
30
|
+
*/
|
|
31
|
+
autoDirection: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** Element to receive dir/lang when `autoDirection` is set. Defaults to `document.documentElement`. */
|
|
36
|
+
directionTarget: {
|
|
37
|
+
type: PropType<HTMLElement | null>;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
43
|
+
locale: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
messages: {
|
|
48
|
+
type: PropType<I18nMessages>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
i18n: {
|
|
52
|
+
type: PropType<I18n>;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* When set, the locale's writing direction ({@link localeDirection}) is
|
|
57
|
+
* applied to `directionTarget` (`dir` + `data-iris-dir`) and `<html lang>`
|
|
58
|
+
* is set whenever `locale` changes — so "set locale → flip direction +
|
|
59
|
+
* announce language" needs no manual wiring. Off by default so it never
|
|
60
|
+
* fights an explicit `<ThemeProvider dir>`. Reverts on unmount.
|
|
61
|
+
*/
|
|
62
|
+
autoDirection: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
default: boolean;
|
|
65
|
+
};
|
|
66
|
+
/** Element to receive dir/lang when `autoDirection` is set. Defaults to `document.documentElement`. */
|
|
67
|
+
directionTarget: {
|
|
68
|
+
type: PropType<HTMLElement | null>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
}>> & Readonly<{}>, {
|
|
72
|
+
locale: string;
|
|
73
|
+
messages: I18nMessages;
|
|
74
|
+
i18n: I18n;
|
|
75
|
+
autoDirection: boolean;
|
|
76
|
+
directionTarget: HTMLElement | null;
|
|
77
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
78
|
+
|
|
79
|
+
interface UseI18nReturn {
|
|
80
|
+
locale: ComputedRef<string>;
|
|
81
|
+
t: I18n['t'];
|
|
82
|
+
formatDate: I18n['formatDate'];
|
|
83
|
+
formatNumber: I18n['formatNumber'];
|
|
84
|
+
formatRelativeTime: I18n['formatRelativeTime'];
|
|
85
|
+
setLocale: I18n['setLocale'];
|
|
86
|
+
setMessages: I18n['setMessages'];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reactive access to the active locale + translation/formatting helpers.
|
|
90
|
+
* Works with or without an `<IrisI18nProvider>` (falls back to English
|
|
91
|
+
* defaults). `t` / formatters read the live locale at call time, and `locale`
|
|
92
|
+
* is a reactive ref so templates re-render on change.
|
|
93
|
+
*/
|
|
94
|
+
declare function useI18n(): UseI18nReturn;
|
|
95
|
+
|
|
96
|
+
/** Injection key carrying the active {@link I18n} instance to `useI18n`. */
|
|
97
|
+
declare const I18nInjectionKey: InjectionKey<I18n>;
|
|
98
|
+
|
|
99
|
+
export { I18nInjectionKey, IrisI18nProvider, type UseI18nReturn, useI18n };
|
package/dist/i18n.js
ADDED
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"i18n.js"}
|