@fluenti/vue 0.5.0 → 0.6.1

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.
Files changed (72) hide show
  1. package/dist/NumberFormat-Bxim144o.js +239 -0
  2. package/dist/NumberFormat-Bxim144o.js.map +1 -0
  3. package/dist/NumberFormat-CgU3BNm8.cjs +2 -0
  4. package/dist/NumberFormat-CgU3BNm8.cjs.map +1 -0
  5. package/dist/components-entry.cjs +1 -2
  6. package/dist/components-entry.js +2 -227
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +59 -59
  10. package/dist/index.js.map +1 -1
  11. package/dist/vite-plugin.cjs +1 -1
  12. package/dist/vite-plugin.cjs.map +1 -1
  13. package/dist/vite-plugin.js +1 -1
  14. package/dist/vite-plugin.js.map +1 -1
  15. package/dist/vue/src/compile-time-t.d.ts.map +1 -0
  16. package/dist/vue/src/components/DateTime.d.ts.map +1 -0
  17. package/dist/vue/src/components/NumberFormat.d.ts.map +1 -0
  18. package/dist/vue/src/components/Plural.d.ts.map +1 -0
  19. package/dist/vue/src/components/Select.d.ts.map +1 -0
  20. package/dist/vue/src/components/Trans.d.ts.map +1 -0
  21. package/dist/vue/src/components/rich-text.d.ts.map +1 -0
  22. package/dist/{components-entry.d.ts → vue/src/components-entry.d.ts} +0 -1
  23. package/dist/vue/src/components-entry.d.ts.map +1 -0
  24. package/dist/vue/src/hooks/__useI18n.d.ts.map +1 -0
  25. package/dist/{index.d.ts → vue/src/index.d.ts} +6 -1
  26. package/dist/vue/src/index.d.ts.map +1 -0
  27. package/dist/vue/src/injection-key.d.ts.map +1 -0
  28. package/dist/vue/src/msg.d.ts.map +1 -0
  29. package/dist/{plugin.d.ts → vue/src/plugin.d.ts} +4 -4
  30. package/dist/vue/src/plugin.d.ts.map +1 -0
  31. package/dist/vue/src/server.d.ts.map +1 -0
  32. package/dist/vue/src/use-i18n.d.ts.map +1 -0
  33. package/dist/vue/src/vite-plugin.d.ts.map +1 -0
  34. package/dist/vue/src/vue-runtime.d.ts.map +1 -0
  35. package/package.json +18 -18
  36. package/dist/compile-time-t.d.ts.map +0 -1
  37. package/dist/components/DateTime.d.ts.map +0 -1
  38. package/dist/components/NumberFormat.d.ts.map +0 -1
  39. package/dist/components/Plural.d.ts.map +0 -1
  40. package/dist/components/Select.d.ts.map +0 -1
  41. package/dist/components/Trans.d.ts.map +0 -1
  42. package/dist/components/rich-text.d.ts.map +0 -1
  43. package/dist/components-entry.cjs.map +0 -1
  44. package/dist/components-entry.d.ts.map +0 -1
  45. package/dist/components-entry.js.map +0 -1
  46. package/dist/hooks/__useI18n.d.ts.map +0 -1
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/injection-key.d.ts.map +0 -1
  49. package/dist/msg.d.ts.map +0 -1
  50. package/dist/plugin.d.ts.map +0 -1
  51. package/dist/server.d.ts.map +0 -1
  52. package/dist/use-i18n-D6iu0pGX.cjs +0 -2
  53. package/dist/use-i18n-D6iu0pGX.cjs.map +0 -1
  54. package/dist/use-i18n-DV-MXUZc.js +0 -17
  55. package/dist/use-i18n-DV-MXUZc.js.map +0 -1
  56. package/dist/use-i18n.d.ts.map +0 -1
  57. package/dist/vite-plugin.d.ts.map +0 -1
  58. package/dist/vue-runtime.d.ts.map +0 -1
  59. /package/dist/{compile-time-t.d.ts → vue/src/compile-time-t.d.ts} +0 -0
  60. /package/dist/{components → vue/src/components}/DateTime.d.ts +0 -0
  61. /package/dist/{components → vue/src/components}/NumberFormat.d.ts +0 -0
  62. /package/dist/{components → vue/src/components}/Plural.d.ts +0 -0
  63. /package/dist/{components → vue/src/components}/Select.d.ts +0 -0
  64. /package/dist/{components → vue/src/components}/Trans.d.ts +0 -0
  65. /package/dist/{components → vue/src/components}/rich-text.d.ts +0 -0
  66. /package/dist/{hooks → vue/src/hooks}/__useI18n.d.ts +0 -0
  67. /package/dist/{injection-key.d.ts → vue/src/injection-key.d.ts} +0 -0
  68. /package/dist/{msg.d.ts → vue/src/msg.d.ts} +0 -0
  69. /package/dist/{server.d.ts → vue/src/server.d.ts} +0 -0
  70. /package/dist/{use-i18n.d.ts → vue/src/use-i18n.d.ts} +0 -0
  71. /package/dist/{vite-plugin.d.ts → vue/src/vite-plugin.d.ts} +0 -0
  72. /package/dist/{vue-runtime.d.ts → vue/src/vue-runtime.d.ts} +0 -0
@@ -0,0 +1,239 @@
1
+ import { Comment as e, Text as t, defineComponent as n, h as r, inject as i, isVNode as a } from "vue";
2
+ import { PLURAL_CATEGORIES as o, buildICUPluralMessage as s, buildICUSelectMessage as c, hashMessage as l, normalizeSelectForms as u, offsetIndices as d } from "@fluenti/core/runtime";
3
+ //#region src/injection-key.ts
4
+ var f = /* @__PURE__ */ Symbol("fluenti");
5
+ //#endregion
6
+ //#region src/use-i18n.ts
7
+ function p() {
8
+ let e = i(f);
9
+ if (!e) throw Error("[fluenti] useI18n() requires createFluenti plugin");
10
+ return e;
11
+ }
12
+ function m() {
13
+ return p().locale;
14
+ }
15
+ //#endregion
16
+ //#region src/components/rich-text.ts
17
+ function h(n) {
18
+ let r = [], i = "";
19
+ function o(n) {
20
+ if (n == null || typeof n == "boolean") return;
21
+ if (Array.isArray(n)) {
22
+ for (let e of n) o(e);
23
+ return;
24
+ }
25
+ if (typeof n == "string" || typeof n == "number") {
26
+ i += String(n);
27
+ return;
28
+ }
29
+ if (!a(n) || n.type === e) return;
30
+ if (n.type === t) {
31
+ i += typeof n.children == "string" ? n.children : "";
32
+ return;
33
+ }
34
+ let s = r.length, c = h(n.children);
35
+ r.push(n), r.push(...c.components), i += `<${s}>${d(c.message, s + 1)}</${s}>`;
36
+ }
37
+ return o(n), {
38
+ message: i,
39
+ components: r
40
+ };
41
+ }
42
+ function g(e, t) {
43
+ let n = /<(\d+)>([\s\S]*?)<\/\1>/g, i = [], a = 0, o;
44
+ for (n.lastIndex = 0, o = n.exec(e); o !== null;) {
45
+ o.index > a && i.push(e.slice(a, o.index));
46
+ let s = t[Number(o[1])], c = g(o[2], t);
47
+ s ? i.push(r(s.type, s.props ?? {}, Array.isArray(c) ? c : [c])) : i.push(o[2]), a = n.lastIndex, o = n.exec(e);
48
+ }
49
+ return a < e.length && i.push(e.slice(a)), i.length <= 1 ? i[0] ?? "" : i;
50
+ }
51
+ function _(e, t) {
52
+ let n = {}, r = [];
53
+ for (let i of e) {
54
+ let e = t[i];
55
+ if (e === void 0) continue;
56
+ let a = h(e);
57
+ n[i] = d(a.message, r.length), r.push(...a.components);
58
+ }
59
+ for (let [i, a] of Object.entries(t)) {
60
+ if (e.includes(i) || a === void 0) continue;
61
+ let t = h(a);
62
+ n[i] = d(t.message, r.length), r.push(...t.components);
63
+ }
64
+ return {
65
+ messages: n,
66
+ components: r
67
+ };
68
+ }
69
+ var v = /* @__PURE__ */ n({
70
+ name: "Trans",
71
+ props: {
72
+ id: String,
73
+ context: String,
74
+ comment: String,
75
+ tag: {
76
+ type: String,
77
+ default: void 0
78
+ }
79
+ },
80
+ setup(e, { slots: t }) {
81
+ let { t: n } = p();
82
+ return () => {
83
+ let i = t.default?.();
84
+ if (!i) return null;
85
+ let { message: a, components: o } = h(i), s = n({
86
+ ...e.id === void 0 ? {} : { id: e.id },
87
+ message: a,
88
+ ...e.context === void 0 ? {} : { context: e.context },
89
+ ...e.comment === void 0 ? {} : { comment: e.comment }
90
+ }), c = o.length > 0 ? g(s, o) : s;
91
+ return Array.isArray(c) ? c.length === 1 ? c[0] : e.tag ? r(e.tag, null, c) : c : c;
92
+ };
93
+ }
94
+ }), y = /* @__PURE__ */ n({
95
+ name: "Plural",
96
+ props: {
97
+ value: {
98
+ type: Number,
99
+ required: !0
100
+ },
101
+ id: String,
102
+ context: String,
103
+ comment: String,
104
+ zero: String,
105
+ one: String,
106
+ two: String,
107
+ few: String,
108
+ many: String,
109
+ other: {
110
+ type: String,
111
+ required: !0
112
+ },
113
+ offset: Number,
114
+ tag: {
115
+ type: String,
116
+ default: void 0
117
+ }
118
+ },
119
+ setup(e, { slots: t }) {
120
+ let { t: n } = p();
121
+ return () => {
122
+ let i = {
123
+ zero: e.zero,
124
+ one: e.one,
125
+ two: e.two,
126
+ few: e.few,
127
+ many: e.many,
128
+ other: e.other
129
+ };
130
+ for (let e of o) {
131
+ let n = t[e];
132
+ n && (i[e] = n({ count: "#" }));
133
+ }
134
+ let { messages: a, components: c } = _(o, i), u = s({
135
+ ...a.zero !== void 0 && { zero: a.zero },
136
+ ...a.one !== void 0 && { one: a.one },
137
+ ...a.two !== void 0 && { two: a.two },
138
+ ...a.few !== void 0 && { few: a.few },
139
+ ...a.many !== void 0 && { many: a.many },
140
+ other: a.other ?? ""
141
+ }, e.offset), d = n({
142
+ id: e.id ?? (e.context === void 0 ? u : l(u, e.context)),
143
+ message: u,
144
+ ...e.context === void 0 ? {} : { context: e.context },
145
+ ...e.comment === void 0 ? {} : { comment: e.comment }
146
+ }, { count: e.value }), f = c.length > 0 ? g(d, c) : d;
147
+ return e.tag ? r(e.tag, void 0, f ?? void 0) : f ?? null;
148
+ };
149
+ }
150
+ }), b = /* @__PURE__ */ n({
151
+ name: "Select",
152
+ inheritAttrs: !1,
153
+ props: {
154
+ value: {
155
+ type: String,
156
+ required: !0
157
+ },
158
+ id: String,
159
+ context: String,
160
+ comment: String,
161
+ other: {
162
+ type: String,
163
+ required: !0
164
+ },
165
+ options: {
166
+ type: Object,
167
+ default: void 0
168
+ },
169
+ tag: {
170
+ type: String,
171
+ default: void 0
172
+ }
173
+ },
174
+ setup(e, { attrs: t, slots: n }) {
175
+ let { t: i } = p();
176
+ return () => {
177
+ let a = {};
178
+ if (e.options !== void 0) {
179
+ for (let [t, n] of Object.entries(e.options)) a[t] = n;
180
+ a.other = e.other;
181
+ } else {
182
+ for (let [e, n] of Object.entries(t)) typeof n == "string" && (a[e] = n);
183
+ a.other = e.other;
184
+ }
185
+ for (let [e, t] of Object.entries(n)) e === "default" || !t || (a[e] = t({ value: "{value}" }));
186
+ let o = [...Object.keys(a).filter((e) => e !== "other"), "other"], { messages: s, components: d } = _(o, a), f = u(Object.fromEntries([...o].map((e) => [e, s[e] ?? ""]))), p = c(f.forms), m = i({
187
+ id: e.id ?? (e.context === void 0 ? p : l(p, e.context)),
188
+ message: p,
189
+ ...e.context === void 0 ? {} : { context: e.context },
190
+ ...e.comment === void 0 ? {} : { comment: e.comment }
191
+ }, { value: f.valueMap[e.value] ?? "other" }), h = d.length > 0 ? g(m, d) : m;
192
+ return e.tag ? r(e.tag, void 0, h ?? void 0) : h ?? null;
193
+ };
194
+ }
195
+ }), x = /* @__PURE__ */ n({
196
+ name: "DateTime",
197
+ props: {
198
+ value: {
199
+ type: [Date, Number],
200
+ required: !0
201
+ },
202
+ format: {
203
+ type: String,
204
+ default: void 0
205
+ },
206
+ tag: {
207
+ type: String,
208
+ default: "span"
209
+ }
210
+ },
211
+ setup(e) {
212
+ let { d: t } = p();
213
+ return () => r(e.tag, t(e.value, e.format));
214
+ }
215
+ }), S = /* @__PURE__ */ n({
216
+ name: "NumberFormat",
217
+ props: {
218
+ value: {
219
+ type: Number,
220
+ required: !0
221
+ },
222
+ format: {
223
+ type: String,
224
+ default: void 0
225
+ },
226
+ tag: {
227
+ type: String,
228
+ default: "span"
229
+ }
230
+ },
231
+ setup(e) {
232
+ let { n: t } = p();
233
+ return () => r(e.tag, t(e.value, e.format));
234
+ }
235
+ });
236
+ //#endregion
237
+ export { v as a, f as c, y as i, x as n, p as o, b as r, m as s, S as t };
238
+
239
+ //# sourceMappingURL=NumberFormat-Bxim144o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberFormat-Bxim144o.js","names":[],"sources":["../src/injection-key.ts","../src/use-i18n.ts","../src/components/rich-text.ts","../src/components/Trans.ts","../src/components/Plural.ts","../src/components/Select.ts","../src/components/DateTime.ts","../src/components/NumberFormat.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { FluentiContext } from './plugin'\n\n/** Injection key for the Fluenti i18n context. @internal */\nexport const FLUENTI_KEY: InjectionKey<FluentiContext> = /* @__PURE__ */ Symbol('fluenti')\n","import { inject } from 'vue'\nimport { FLUENTI_KEY } from './injection-key'\nimport type { FluentiContext } from './plugin'\n\n/**\n * Composable that returns the Fluenti i18n context.\n *\n * Must be called inside a component whose ancestor app has installed the\n * `createFluenti()` plugin.\n *\n * @throws If the plugin has not been installed\n *\n * @example\n * ```vue\n * <template>\n * <!-- Preferred: v-t directive (compile-time, zero runtime cost) -->\n * <h1 v-t>Welcome to our app</h1>\n * <p v-t>Hello, {name}!</p>\n *\n * <!-- Alternative: tagged template in script -->\n * <p>{{ greeting }}</p>\n * </template>\n *\n * <script setup>\n * import { useI18n } from '@fluenti/vue'\n * const { t, locale, setLocale } = useI18n()\n * const greeting = t`Hello, {name}!`\n * </script>\n * ```\n */\nexport function useI18n(): FluentiContext {\n const ctx = inject(FLUENTI_KEY)\n if (!ctx) {\n throw new Error('[fluenti] useI18n() requires createFluenti plugin')\n }\n return ctx\n}\n\n/** Shorthand composable that returns only the reactive locale ref. */\nexport function useLocale() {\n return useI18n().locale\n}\n","import { Comment, Text, h, isVNode, type VNode, type VNodeChild } from 'vue'\nimport { offsetIndices } from '@fluenti/core/runtime'\n\nexport function extractMessage(children: VNodeChild | VNodeChild[] | undefined): {\n message: string\n components: VNode[]\n} {\n const components: VNode[] = []\n let message = ''\n\n function visit(node: VNodeChild | VNodeChild[] | undefined): void {\n if (node === null || node === undefined || typeof node === 'boolean') return\n if (Array.isArray(node)) {\n for (const child of node) visit(child)\n return\n }\n if (typeof node === 'string' || typeof node === 'number') {\n message += String(node)\n return\n }\n if (!isVNode(node) || node.type === Comment) return\n if (node.type === Text) {\n message += typeof node.children === 'string' ? node.children : ''\n return\n }\n\n const idx = components.length\n const inner = extractMessage(node.children as VNodeChild | VNodeChild[] | undefined)\n components.push(node)\n components.push(...inner.components)\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n\n visit(children)\n return { message, components }\n}\n\nexport function reconstruct(\n translated: string,\n components: VNode[],\n): VNodeChild {\n const tagRe = /<(\\d+)>([\\s\\S]*?)<\\/\\1>/g\n const result: VNodeChild[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n tagRe.lastIndex = 0\n match = tagRe.exec(translated)\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const component = components[idx]\n const innerContent = reconstruct(match[2]!, components)\n if (component) {\n result.push(h(component.type as never, component.props ?? {}, Array.isArray(innerContent) ? innerContent : [innerContent]))\n } else {\n result.push(match[2]!)\n }\n\n lastIndex = tagRe.lastIndex\n match = tagRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return result.length <= 1 ? (result[0] ?? '') : result\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, VNodeChild>> & Record<string, VNodeChild | undefined>,\n): {\n messages: Record<string, string>\n components: VNode[]\n} {\n const messages: Record<string, string> = {}\n const components: VNode[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes } from 'vue'\nimport { useI18n } from '../use-i18n'\nimport { extractMessage, reconstruct } from './rich-text'\n\n/**\n * `<Trans>` component for rich text with Vue components.\n *\n * @example\n * ```vue\n * <Trans>\n * Visit our <a href=\"/docs\">documentation</a> to learn more.\n * </Trans>\n * ```\n *\n * @example\n * ```vue\n * <Trans>\n * Click <RouterLink to=\"/next\">here</RouterLink> to continue.\n * </Trans>\n * ```\n */\nconst transProps = {\n /** Override auto-generated hash ID */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiTransProps = Readonly<ExtractPropTypes<typeof transProps>>\n\nexport const Trans = /* @__PURE__ */ defineComponent({\n name: 'Trans',\n props: transProps,\n setup(props, { slots }) {\n const { t } = useI18n()\n\n return () => {\n const defaultSlot = slots['default']?.()\n if (!defaultSlot) return null\n const { message, components } = extractMessage(defaultSlot)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (Array.isArray(result)) {\n if (result.length === 1) return result[0]!\n return props.tag ? h(props.tag, null, result) : result\n }\n return result\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, SetupContext, VNodeChild } from 'vue'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/runtime'\nimport { useI18n } from '../use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-text'\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via the `message` field of the\n * MessageDescriptor.\n *\n * Rich text is supported via named slots:\n * ```vue\n * <Plural :value=\"count\">\n * <template #zero>No <strong>items</strong></template>\n * <template #one><em>1</em> item</template>\n * <template #other><strong>{{ count }}</strong> items</template>\n * </Plural>\n * ```\n *\n * String props still work (backward compatible):\n * ```vue\n * <Plural :value=\"count\" zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n *\n * @example\n * ```vue\n * <template>\n * <!-- Preferred: v-t.plural (compile-time) -->\n * <p v-t.plural=\"count\">one item | {count} items</p>\n *\n * <!-- Alternative: Plural component (runtime) -->\n * <Plural :value=\"count\" one=\"# item in cart\" other=\"# items in cart\" />\n * </template>\n * ```\n */\nconst pluralProps = {\n /** The numeric value to pluralise on */\n value: { type: Number, required: true },\n /** Override the auto-generated synthetic ICU message id */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Text for zero items (maps to `=0`) */\n zero: String,\n /** Text for singular (maps to `one`) */\n one: String,\n /** Text for dual (maps to `two`) */\n two: String,\n /** Text for few (maps to `few`) */\n few: String,\n /** Text for many (maps to `many`) */\n many: String,\n /** Text for the default/other category */\n other: { type: String, required: true },\n /** Offset from value before selecting form */\n offset: Number,\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiPluralProps = Readonly<ExtractPropTypes<typeof pluralProps>>\n\nexport const Plural = /* @__PURE__ */ defineComponent({\n name: 'Plural',\n props: pluralProps,\n setup(props, { slots }: SetupContext) {\n const { t } = useI18n()\n\n return () => {\n const forms: Partial<Record<PluralCategory, VNodeChild>> & Record<string, VNodeChild | undefined> = {\n zero: props.zero,\n one: props.one,\n two: props.two,\n few: props.few,\n many: props.many,\n other: props.other,\n }\n\n for (const cat of PLURAL_CATEGORIES) {\n const slot = slots[cat]\n if (slot) {\n forms[cat] = slot({ count: '#' })\n }\n }\n\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages['zero'] !== undefined && { zero: messages['zero'] }),\n ...(messages['one'] !== undefined && { one: messages['one'] }),\n ...(messages['two'] !== undefined && { two: messages['two'] }),\n ...(messages['few'] !== undefined && { few: messages['few'] }),\n ...(messages['many'] !== undefined && { many: messages['many'] }),\n other: messages['other'] ?? '',\n },\n props.offset,\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) return h(props.tag, undefined, result ?? undefined)\n return result ?? null\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, PropType, SetupContext, VNodeChild } from 'vue'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/runtime'\nimport { useI18n } from '../use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-text'\n\n/**\n * `<Select>` component — shorthand for ICU select patterns.\n *\n * Accepts a `value` string that selects among named options. Options can be\n * provided via the type-safe `options` prop (recommended), as direct attrs\n * (convenience), or as named slots (rich text).\n *\n * Falls back to `other` when no match is found.\n *\n * @example Type-safe usage (recommended):\n * ```vue\n * <Select\n * :value=\"gender\"\n * :options=\"{ male: 'He liked it', female: 'She liked it' }\"\n * other=\"They liked it\"\n * />\n * ```\n *\n * @example Rich text via named slots:\n * ```vue\n * <Select :value=\"gender\">\n * <template #male><strong>He</strong> liked this</template>\n * <template #female><strong>She</strong> liked this</template>\n * <template #other><em>They</em> liked this</template>\n * </Select>\n * ```\n */\nconst selectProps = {\n /** The value to select on (e.g. `\"male\"`, `\"female\"`) */\n value: { type: String, required: true },\n /** Override the auto-generated synthetic ICU message id */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Fallback text when no option matches `value` */\n other: { type: String, required: true },\n /**\n * Named options map. Keys are match values, values are display strings.\n * Takes precedence over attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options: {\n type: Object as PropType<Record<string, string>>,\n default: undefined,\n },\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiSelectProps = Readonly<ExtractPropTypes<typeof selectProps>>\n\nexport const Select = /* @__PURE__ */ defineComponent({\n name: 'Select',\n inheritAttrs: false,\n props: selectProps,\n setup(props, { attrs, slots }: SetupContext) {\n const { t } = useI18n()\n\n return () => {\n const forms: Record<string, VNodeChild | undefined> = {}\n\n if (props.options !== undefined) {\n for (const [key, value] of Object.entries(props.options)) {\n forms[key] = value\n }\n forms['other'] = props.other\n } else {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'string') {\n forms[key] = value\n }\n }\n forms['other'] = props.other\n }\n\n for (const [key, slot] of Object.entries(slots)) {\n if (key === 'default' || !slot) continue\n forms[key] = slot({ value: '{value}' })\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) return h(props.tag, undefined, result ?? undefined)\n return result ?? null\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, PropType } from 'vue'\nimport { useI18n } from '../use-i18n'\n\n/**\n * `<DateTime>` component for formatting dates according to locale.\n *\n * @example\n * ```vue\n * <DateTime :value=\"new Date()\" />\n * <DateTime :value=\"Date.now()\" format=\"short\" />\n * <DateTime :value=\"event.date\" format=\"long\" tag=\"time\" />\n * ```\n */\nconst dateTimeProps = {\n value: { type: [Date, Number] as PropType<Date | number>, required: true },\n format: { type: String, default: undefined },\n tag: { type: String, default: 'span' },\n} as const\n\nexport type FluentiDateTimeProps = Readonly<ExtractPropTypes<typeof dateTimeProps>>\n\nexport const DateTime = /* @__PURE__ */ defineComponent({\n name: 'DateTime',\n props: dateTimeProps,\n setup(props) {\n const { d } = useI18n()\n return () => h(props.tag, d(props.value as Date | number, props.format))\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes } from 'vue'\nimport { useI18n } from '../use-i18n'\n\n/**\n * `<NumberFormat>` component for formatting numbers according to locale.\n *\n * @example\n * ```vue\n * <NumberFormat :value=\"1234.56\" />\n * <NumberFormat :value=\"0.75\" format=\"percent\" />\n * <NumberFormat :value=\"99.99\" format=\"currency\" tag=\"strong\" />\n * ```\n */\nconst numberFormatProps = {\n value: { type: Number, required: true },\n format: { type: String, default: undefined },\n tag: { type: String, default: 'span' },\n} as const\n\nexport type FluentiNumberFormatProps = Readonly<ExtractPropTypes<typeof numberFormatProps>>\n\nexport const NumberFormat = /* @__PURE__ */ defineComponent({\n name: 'NumberFormat',\n props: numberFormatProps,\n setup(props) {\n const { n } = useI18n()\n return () => h(props.tag, n(props.value, props.format))\n },\n})\n"],"mappings":";;;AAIA,IAAa,IAA4D,uBAAO,UAAU;;;AC0B1F,SAAgB,IAA0B;CACxC,IAAM,IAAM,EAAO,EAAY;AAC/B,KAAI,CAAC,EACH,OAAU,MAAM,oDAAoD;AAEtE,QAAO;;AAIT,SAAgB,IAAY;AAC1B,QAAO,GAAS,CAAC;;;;ACrCnB,SAAgB,EAAe,GAG7B;CACA,IAAM,IAAsB,EAAE,EAC1B,IAAU;CAEd,SAAS,EAAM,GAAmD;AAChE,MAAI,KAAS,QAA8B,OAAO,KAAS,UAAW;AACtE,MAAI,MAAM,QAAQ,EAAK,EAAE;AACvB,QAAK,IAAM,KAAS,EAAM,GAAM,EAAM;AACtC;;AAEF,MAAI,OAAO,KAAS,YAAY,OAAO,KAAS,UAAU;AACxD,QAAW,OAAO,EAAK;AACvB;;AAEF,MAAI,CAAC,EAAQ,EAAK,IAAI,EAAK,SAAS,EAAS;A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AAY,KAAA,IAAY,IAAa,EAAY,GAAY,EAAM,QAAQ;IAClG,SAAS;IACT,GAAI,EAAM,YAAY,KAAA,IAAyC,EAAE,GAA/B,EAAE,SAAS,EAAM,SAAS;IAC5D,GAAI,EAAM,YAAY,KAAA,IAAyC,EAAE,GAA/B,EAAE,SAAS,EAAM,SAAS;IAC7D,EACD,EAAE,OAAO,EAAW,SAAS,EAAM,UAAU,SAAS,CACvD,EACK,IAAS,EAAW,SAAS,IAAI,EAAY,GAAY,EAAW,GAAG;AAE7E,UADI,EAAM,MAAY,EAAE,EAAM,KAAK,KAAA,GAAW,KAAU,KAAA,EAAU,GAC3D,KAAU;;;CAGtB,CAAC,ECzFW,IAA2B,kBAAgB;CACtD,MAAM;CACN,OAVoB;EACpB,OAAO;GAAE,MAAM,CAAC,MAAM,OAAO;GAA6B,UAAU;GAAM;EAC1E,QAAQ;GAAE,MAAM;GAAQ,SAAS,KAAA;GAAW;EAC5C,KAAK;GAAE,MAAM;GAAQ,SAAS;GAAQ;EACvC;CAOC,MAAM,GAAO;EACX,IAAM,EAAE,SAAM,GAAS;AACvB,eAAa,EAAE,EAAM,KAAK,EAAE,EAAM,OAAwB,EAAM,OAAO,CAAC;;CAE3E,CAAC,ECPW,IAA+B,kBAAgB;CAC1D,MAAM;CACN,OAVwB;EACxB,OAAO;GAAE,MAAM;GAAQ,UAAU;GAAM;EACvC,QAAQ;GAAE,MAAM;GAAQ,SAAS,KAAA;GAAW;EAC5C,KAAK;GAAE,MAAM;GAAQ,SAAS;GAAQ;EACvC;CAOC,MAAM,GAAO;EACX,IAAM,EAAE,SAAM,GAAS;AACvB,eAAa,EAAE,EAAM,KAAK,EAAE,EAAM,OAAO,EAAM,OAAO,CAAC;;CAE1D,CAAC"}
@@ -0,0 +1,2 @@
1
+ let e=require(`vue`),t=require(`@fluenti/core/runtime`);var n=Symbol(`fluenti`);function r(){let t=(0,e.inject)(n);if(!t)throw Error(`[fluenti] useI18n() requires createFluenti plugin`);return t}function i(){return r().locale}function a(n){let r=[],i=``;function o(n){if(n==null||typeof n==`boolean`)return;if(Array.isArray(n)){for(let e of n)o(e);return}if(typeof n==`string`||typeof n==`number`){i+=String(n);return}if(!(0,e.isVNode)(n)||n.type===e.Comment)return;if(n.type===e.Text){i+=typeof n.children==`string`?n.children:``;return}let s=r.length,c=a(n.children);r.push(n),r.push(...c.components),i+=`<${s}>${(0,t.offsetIndices)(c.message,s+1)}</${s}>`}return o(n),{message:i,components:r}}function o(t,n){let r=/<(\d+)>([\s\S]*?)<\/\1>/g,i=[],a=0,s;for(r.lastIndex=0,s=r.exec(t);s!==null;){s.index>a&&i.push(t.slice(a,s.index));let c=n[Number(s[1])],l=o(s[2],n);c?i.push((0,e.h)(c.type,c.props??{},Array.isArray(l)?l:[l])):i.push(s[2]),a=r.lastIndex,s=r.exec(t)}return a<t.length&&i.push(t.slice(a)),i.length<=1?i[0]??``:i}function s(e,n){let r={},i=[];for(let o of e){let e=n[o];if(e===void 0)continue;let s=a(e);r[o]=(0,t.offsetIndices)(s.message,i.length),i.push(...s.components)}for(let[o,s]of Object.entries(n)){if(e.includes(o)||s===void 0)continue;let n=a(s);r[o]=(0,t.offsetIndices)(n.message,i.length),i.push(...n.components)}return{messages:r,components:i}}var c={id:String,context:String,comment:String,tag:{type:String,default:void 0}},l=(0,e.defineComponent)({name:`Trans`,props:c,setup(t,{slots:n}){let{t:i}=r();return()=>{let r=n.default?.();if(!r)return null;let{message:s,components:c}=a(r),l=i({...t.id===void 0?{}:{id:t.id},message:s,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}}),u=c.length>0?o(l,c):l;return Array.isArray(u)?u.length===1?u[0]:t.tag?(0,e.h)(t.tag,null,u):u:u}}}),u={value:{type:Number,required:!0},id:String,context:String,comment:String,zero:String,one:String,two:String,few:String,many:String,other:{type:String,required:!0},offset:Number,tag:{type:String,default:void 0}},d=(0,e.defineComponent)({name:`Plural`,props:u,setup(n,{slots:i}){let{t:a}=r();return()=>{let r={zero:n.zero,one:n.one,two:n.two,few:n.few,many:n.many,other:n.other};for(let e of t.PLURAL_CATEGORIES){let t=i[e];t&&(r[e]=t({count:`#`}))}let{messages:c,components:l}=s(t.PLURAL_CATEGORIES,r),u=(0,t.buildICUPluralMessage)({...c.zero!==void 0&&{zero:c.zero},...c.one!==void 0&&{one:c.one},...c.two!==void 0&&{two:c.two},...c.few!==void 0&&{few:c.few},...c.many!==void 0&&{many:c.many},other:c.other??``},n.offset),d=a({id:n.id??(n.context===void 0?u:(0,t.hashMessage)(u,n.context)),message:u,...n.context===void 0?{}:{context:n.context},...n.comment===void 0?{}:{comment:n.comment}},{count:n.value}),f=l.length>0?o(d,l):d;return n.tag?(0,e.h)(n.tag,void 0,f??void 0):f??null}}}),f={value:{type:String,required:!0},id:String,context:String,comment:String,other:{type:String,required:!0},options:{type:Object,default:void 0},tag:{type:String,default:void 0}},p=(0,e.defineComponent)({name:`Select`,inheritAttrs:!1,props:f,setup(n,{attrs:i,slots:a}){let{t:c}=r();return()=>{let r={};if(n.options!==void 0){for(let[e,t]of Object.entries(n.options))r[e]=t;r.other=n.other}else{for(let[e,t]of Object.entries(i))typeof t==`string`&&(r[e]=t);r.other=n.other}for(let[e,t]of Object.entries(a))e===`default`||!t||(r[e]=t({value:`{value}`}));let l=[...Object.keys(r).filter(e=>e!==`other`),`other`],{messages:u,components:d}=s(l,r),f=(0,t.normalizeSelectForms)(Object.fromEntries([...l].map(e=>[e,u[e]??``]))),p=(0,t.buildICUSelectMessage)(f.forms),m=c({id:n.id??(n.context===void 0?p:(0,t.hashMessage)(p,n.context)),message:p,...n.context===void 0?{}:{context:n.context},...n.comment===void 0?{}:{comment:n.comment}},{value:f.valueMap[n.value]??`other`}),h=d.length>0?o(m,d):m;return n.tag?(0,e.h)(n.tag,void 0,h??void 0):h??null}}}),m={value:{type:[Date,Number],required:!0},format:{type:String,default:void 0},tag:{type:String,default:`span`}},h=(0,e.defineComponent)({name:`DateTime`,props:m,setup(t){let{d:n}=r();return()=>(0,e.h)(t.tag,n(t.value,t.format))}}),g={value:{type:Number,required:!0},format:{type:String,default:void 0},tag:{type:String,default:`span`}},_=(0,e.defineComponent)({name:`NumberFormat`,props:g,setup(t){let{n}=r();return()=>(0,e.h)(t.tag,n(t.value,t.format))}});Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
2
+ //# sourceMappingURL=NumberFormat-CgU3BNm8.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberFormat-CgU3BNm8.cjs","names":[],"sources":["../src/injection-key.ts","../src/use-i18n.ts","../src/components/rich-text.ts","../src/components/Trans.ts","../src/components/Plural.ts","../src/components/Select.ts","../src/components/DateTime.ts","../src/components/NumberFormat.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { FluentiContext } from './plugin'\n\n/** Injection key for the Fluenti i18n context. @internal */\nexport const FLUENTI_KEY: InjectionKey<FluentiContext> = /* @__PURE__ */ Symbol('fluenti')\n","import { inject } from 'vue'\nimport { FLUENTI_KEY } from './injection-key'\nimport type { FluentiContext } from './plugin'\n\n/**\n * Composable that returns the Fluenti i18n context.\n *\n * Must be called inside a component whose ancestor app has installed the\n * `createFluenti()` plugin.\n *\n * @throws If the plugin has not been installed\n *\n * @example\n * ```vue\n * <template>\n * <!-- Preferred: v-t directive (compile-time, zero runtime cost) -->\n * <h1 v-t>Welcome to our app</h1>\n * <p v-t>Hello, {name}!</p>\n *\n * <!-- Alternative: tagged template in script -->\n * <p>{{ greeting }}</p>\n * </template>\n *\n * <script setup>\n * import { useI18n } from '@fluenti/vue'\n * const { t, locale, setLocale } = useI18n()\n * const greeting = t`Hello, {name}!`\n * </script>\n * ```\n */\nexport function useI18n(): FluentiContext {\n const ctx = inject(FLUENTI_KEY)\n if (!ctx) {\n throw new Error('[fluenti] useI18n() requires createFluenti plugin')\n }\n return ctx\n}\n\n/** Shorthand composable that returns only the reactive locale ref. */\nexport function useLocale() {\n return useI18n().locale\n}\n","import { Comment, Text, h, isVNode, type VNode, type VNodeChild } from 'vue'\nimport { offsetIndices } from '@fluenti/core/runtime'\n\nexport function extractMessage(children: VNodeChild | VNodeChild[] | undefined): {\n message: string\n components: VNode[]\n} {\n const components: VNode[] = []\n let message = ''\n\n function visit(node: VNodeChild | VNodeChild[] | undefined): void {\n if (node === null || node === undefined || typeof node === 'boolean') return\n if (Array.isArray(node)) {\n for (const child of node) visit(child)\n return\n }\n if (typeof node === 'string' || typeof node === 'number') {\n message += String(node)\n return\n }\n if (!isVNode(node) || node.type === Comment) return\n if (node.type === Text) {\n message += typeof node.children === 'string' ? node.children : ''\n return\n }\n\n const idx = components.length\n const inner = extractMessage(node.children as VNodeChild | VNodeChild[] | undefined)\n components.push(node)\n components.push(...inner.components)\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n\n visit(children)\n return { message, components }\n}\n\nexport function reconstruct(\n translated: string,\n components: VNode[],\n): VNodeChild {\n const tagRe = /<(\\d+)>([\\s\\S]*?)<\\/\\1>/g\n const result: VNodeChild[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n tagRe.lastIndex = 0\n match = tagRe.exec(translated)\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const component = components[idx]\n const innerContent = reconstruct(match[2]!, components)\n if (component) {\n result.push(h(component.type as never, component.props ?? {}, Array.isArray(innerContent) ? innerContent : [innerContent]))\n } else {\n result.push(match[2]!)\n }\n\n lastIndex = tagRe.lastIndex\n match = tagRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return result.length <= 1 ? (result[0] ?? '') : result\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, VNodeChild>> & Record<string, VNodeChild | undefined>,\n): {\n messages: Record<string, string>\n components: VNode[]\n} {\n const messages: Record<string, string> = {}\n const components: VNode[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes } from 'vue'\nimport { useI18n } from '../use-i18n'\nimport { extractMessage, reconstruct } from './rich-text'\n\n/**\n * `<Trans>` component for rich text with Vue components.\n *\n * @example\n * ```vue\n * <Trans>\n * Visit our <a href=\"/docs\">documentation</a> to learn more.\n * </Trans>\n * ```\n *\n * @example\n * ```vue\n * <Trans>\n * Click <RouterLink to=\"/next\">here</RouterLink> to continue.\n * </Trans>\n * ```\n */\nconst transProps = {\n /** Override auto-generated hash ID */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiTransProps = Readonly<ExtractPropTypes<typeof transProps>>\n\nexport const Trans = /* @__PURE__ */ defineComponent({\n name: 'Trans',\n props: transProps,\n setup(props, { slots }) {\n const { t } = useI18n()\n\n return () => {\n const defaultSlot = slots['default']?.()\n if (!defaultSlot) return null\n const { message, components } = extractMessage(defaultSlot)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (Array.isArray(result)) {\n if (result.length === 1) return result[0]!\n return props.tag ? h(props.tag, null, result) : result\n }\n return result\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, SetupContext, VNodeChild } from 'vue'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/runtime'\nimport { useI18n } from '../use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-text'\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via the `message` field of the\n * MessageDescriptor.\n *\n * Rich text is supported via named slots:\n * ```vue\n * <Plural :value=\"count\">\n * <template #zero>No <strong>items</strong></template>\n * <template #one><em>1</em> item</template>\n * <template #other><strong>{{ count }}</strong> items</template>\n * </Plural>\n * ```\n *\n * String props still work (backward compatible):\n * ```vue\n * <Plural :value=\"count\" zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n *\n * @example\n * ```vue\n * <template>\n * <!-- Preferred: v-t.plural (compile-time) -->\n * <p v-t.plural=\"count\">one item | {count} items</p>\n *\n * <!-- Alternative: Plural component (runtime) -->\n * <Plural :value=\"count\" one=\"# item in cart\" other=\"# items in cart\" />\n * </template>\n * ```\n */\nconst pluralProps = {\n /** The numeric value to pluralise on */\n value: { type: Number, required: true },\n /** Override the auto-generated synthetic ICU message id */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Text for zero items (maps to `=0`) */\n zero: String,\n /** Text for singular (maps to `one`) */\n one: String,\n /** Text for dual (maps to `two`) */\n two: String,\n /** Text for few (maps to `few`) */\n few: String,\n /** Text for many (maps to `many`) */\n many: String,\n /** Text for the default/other category */\n other: { type: String, required: true },\n /** Offset from value before selecting form */\n offset: Number,\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiPluralProps = Readonly<ExtractPropTypes<typeof pluralProps>>\n\nexport const Plural = /* @__PURE__ */ defineComponent({\n name: 'Plural',\n props: pluralProps,\n setup(props, { slots }: SetupContext) {\n const { t } = useI18n()\n\n return () => {\n const forms: Partial<Record<PluralCategory, VNodeChild>> & Record<string, VNodeChild | undefined> = {\n zero: props.zero,\n one: props.one,\n two: props.two,\n few: props.few,\n many: props.many,\n other: props.other,\n }\n\n for (const cat of PLURAL_CATEGORIES) {\n const slot = slots[cat]\n if (slot) {\n forms[cat] = slot({ count: '#' })\n }\n }\n\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages['zero'] !== undefined && { zero: messages['zero'] }),\n ...(messages['one'] !== undefined && { one: messages['one'] }),\n ...(messages['two'] !== undefined && { two: messages['two'] }),\n ...(messages['few'] !== undefined && { few: messages['few'] }),\n ...(messages['many'] !== undefined && { many: messages['many'] }),\n other: messages['other'] ?? '',\n },\n props.offset,\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) return h(props.tag, undefined, result ?? undefined)\n return result ?? null\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, PropType, SetupContext, VNodeChild } from 'vue'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/runtime'\nimport { useI18n } from '../use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-text'\n\n/**\n * `<Select>` component — shorthand for ICU select patterns.\n *\n * Accepts a `value` string that selects among named options. Options can be\n * provided via the type-safe `options` prop (recommended), as direct attrs\n * (convenience), or as named slots (rich text).\n *\n * Falls back to `other` when no match is found.\n *\n * @example Type-safe usage (recommended):\n * ```vue\n * <Select\n * :value=\"gender\"\n * :options=\"{ male: 'He liked it', female: 'She liked it' }\"\n * other=\"They liked it\"\n * />\n * ```\n *\n * @example Rich text via named slots:\n * ```vue\n * <Select :value=\"gender\">\n * <template #male><strong>He</strong> liked this</template>\n * <template #female><strong>She</strong> liked this</template>\n * <template #other><em>They</em> liked this</template>\n * </Select>\n * ```\n */\nconst selectProps = {\n /** The value to select on (e.g. `\"male\"`, `\"female\"`) */\n value: { type: String, required: true },\n /** Override the auto-generated synthetic ICU message id */\n id: String,\n /** Message context used for identity and translator disambiguation */\n context: String,\n /** Translator-facing note preserved in extraction catalogs */\n comment: String,\n /** Fallback text when no option matches `value` */\n other: { type: String, required: true },\n /**\n * Named options map. Keys are match values, values are display strings.\n * Takes precedence over attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options: {\n type: Object as PropType<Record<string, string>>,\n default: undefined,\n },\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag: { type: String, default: undefined },\n} as const\n\nexport type FluentiSelectProps = Readonly<ExtractPropTypes<typeof selectProps>>\n\nexport const Select = /* @__PURE__ */ defineComponent({\n name: 'Select',\n inheritAttrs: false,\n props: selectProps,\n setup(props, { attrs, slots }: SetupContext) {\n const { t } = useI18n()\n\n return () => {\n const forms: Record<string, VNodeChild | undefined> = {}\n\n if (props.options !== undefined) {\n for (const [key, value] of Object.entries(props.options)) {\n forms[key] = value\n }\n forms['other'] = props.other\n } else {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'string') {\n forms[key] = value\n }\n }\n forms['other'] = props.other\n }\n\n for (const [key, slot] of Object.entries(slots)) {\n if (key === 'default' || !slot) continue\n forms[key] = slot({ value: '{value}' })\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) return h(props.tag, undefined, result ?? undefined)\n return result ?? null\n }\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes, PropType } from 'vue'\nimport { useI18n } from '../use-i18n'\n\n/**\n * `<DateTime>` component for formatting dates according to locale.\n *\n * @example\n * ```vue\n * <DateTime :value=\"new Date()\" />\n * <DateTime :value=\"Date.now()\" format=\"short\" />\n * <DateTime :value=\"event.date\" format=\"long\" tag=\"time\" />\n * ```\n */\nconst dateTimeProps = {\n value: { type: [Date, Number] as PropType<Date | number>, required: true },\n format: { type: String, default: undefined },\n tag: { type: String, default: 'span' },\n} as const\n\nexport type FluentiDateTimeProps = Readonly<ExtractPropTypes<typeof dateTimeProps>>\n\nexport const DateTime = /* @__PURE__ */ defineComponent({\n name: 'DateTime',\n props: dateTimeProps,\n setup(props) {\n const { d } = useI18n()\n return () => h(props.tag, d(props.value as Date | number, props.format))\n },\n})\n","import { defineComponent, h } from 'vue'\nimport type { ExtractPropTypes } from 'vue'\nimport { useI18n } from '../use-i18n'\n\n/**\n * `<NumberFormat>` component for formatting numbers according to locale.\n *\n * @example\n * ```vue\n * <NumberFormat :value=\"1234.56\" />\n * <NumberFormat :value=\"0.75\" format=\"percent\" />\n * <NumberFormat :value=\"99.99\" format=\"currency\" tag=\"strong\" />\n * ```\n */\nconst numberFormatProps = {\n value: { type: Number, required: true },\n format: { type: String, default: undefined },\n tag: { type: String, default: 'span' },\n} as const\n\nexport type FluentiNumberFormatProps = Readonly<ExtractPropTypes<typeof numberFormatProps>>\n\nexport const NumberFormat = /* @__PURE__ */ defineComponent({\n name: 'NumberFormat',\n props: numberFormatProps,\n setup(props) {\n const { n } = useI18n()\n return () => h(props.tag, n(props.value, props.format))\n },\n})\n"],"mappings":"wDAIA,IAAa,EAA4D,OAAO,UAAU,CC0B1F,SAAgB,GAA0B,CACxC,IAAM,GAAA,EAAA,EAAA,QAAa,EAAY,CAC/B,GAAI,CAAC,EACH,MAAU,MAAM,oDAAoD,CAEtE,OAAO,EAIT,SAAgB,GAAY,CAC1B,OAAO,GAAS,CAAC,OCrCnB,SAAgB,EAAe,EAG7B,CACA,IAAM,EAAsB,EAAE,CAC1B,EAAU,GAEd,SAAS,EAAM,EAAmD,CAChE,GAAI,GAAS,MAA8B,OAAO,GAAS,UAAW,OACtE,GAAI,MAAM,QAAQ,EAAK,CAAE,CACvB,IAAK,IAAM,KAAS,EAAM,EAAM,EAAM,CACtC,OAEF,GAAI,OAAO,GAAS,UAAY,OAAO,GAAS,SAAU,CACxD,GAAW,OAAO,EAAK,CACvB,OAEF,GAAI,EAAA,EAAA,EAAA,SAAS,EAAK,EAAI,EAAK,OAAS,EAAA,QAAS,OAC7C,GAAI,EAAK,OAAS,EAAA,KAAM,CACtB,GAAW,OAAO,EAAK,UAAa,SAAW,EAAK,SAAW,GAC/D,OAGF,IAAM,EAAM,EAAW,OACjB,EAAQ,EAAe,EAAK,SAAkD,CACpF,EAAW,KAAK,EAAK,CACrB,EAAW,KAAK,GAAG,EAAM,WAAW,CACpC,GAAW,IAAI,EAAI,IAAA,EAAA,EAAA,eAAiB,EAAM,QAAS,EAAM,EAAE,CAAC,IAAI,EAAI,GAItE,OADA,EAAM,EAAS,CACR,CAAE,UAAS,aAAY,CAGhC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,QAAS,EAAM,QAAS,CAC7D,CACD,CAAE,MAAO,EAAW,SAAS,EAAM,QAAU,QAAS,CACvD,CACK,EAAS,EAAW,OAAS,EAAI,EAAY,EAAY,EAAW,CAAG,EAE7E,OADI,EAAM,KAAK,EAAA,EAAA,GAAS,EAAM,IAAK,IAAA,GAAW,GAAU,IAAA,GAAU,CAC3D,GAAU,OAGtB,CAAC,CCjGI,EAAgB,CACpB,MAAO,CAAE,KAAM,CAAC,KAAM,OAAO,CAA6B,SAAU,GAAM,CAC1E,OAAQ,CAAE,KAAM,OAAQ,QAAS,IAAA,GAAW,CAC5C,IAAK,CAAE,KAAM,OAAQ,QAAS,OAAQ,CACvC,CAIY,GAA2B,EAAA,EAAA,iBAAgB,CACtD,KAAM,WACN,MAAO,EACP,MAAM,EAAO,CACX,GAAM,CAAE,KAAM,GAAS,CACvB,WAAA,EAAA,EAAA,GAAe,EAAM,IAAK,EAAE,EAAM,MAAwB,EAAM,OAAO,CAAC,EAE3E,CAAC,CCfI,EAAoB,CACxB,MAAO,CAAE,KAAM,OAAQ,SAAU,GAAM,CACvC,OAAQ,CAAE,KAAM,OAAQ,QAAS,IAAA,GAAW,CAC5C,IAAK,CAAE,KAAM,OAAQ,QAAS,OAAQ,CACvC,CAIY,GAA+B,EAAA,EAAA,iBAAgB,CAC1D,KAAM,eACN,MAAO,EACP,MAAM,EAAO,CACX,GAAM,CAAE,GAAM,GAAS,CACvB,WAAA,EAAA,EAAA,GAAe,EAAM,IAAK,EAAE,EAAM,MAAO,EAAM,OAAO,CAAC,EAE1D,CAAC"}
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./use-i18n-D6iu0pGX.cjs`);let t=require(`vue`),n=require(`@fluenti/core/internal`);function r(e){let i=[],a=``;function o(e){if(e==null||typeof e==`boolean`)return;if(Array.isArray(e)){for(let t of e)o(t);return}if(typeof e==`string`||typeof e==`number`){a+=String(e);return}if(!(0,t.isVNode)(e)||e.type===t.Comment)return;if(e.type===t.Text){a+=typeof e.children==`string`?e.children:``;return}let s=i.length,c=r(e.children);i.push(e),i.push(...c.components),a+=`<${s}>${(0,n.offsetIndices)(c.message,s+1)}</${s}>`}return o(e),{message:a,components:i}}function i(e,n){let r=/<(\d+)>([\s\S]*?)<\/\1>/g,a=[],o=0,s;for(r.lastIndex=0,s=r.exec(e);s!==null;){s.index>o&&a.push(e.slice(o,s.index));let c=n[Number(s[1])],l=i(s[2],n);c?a.push((0,t.h)(c.type,c.props??{},Array.isArray(l)?l:[l])):a.push(s[2]),o=r.lastIndex,s=r.exec(e)}return o<e.length&&a.push(e.slice(o)),a.length<=1?a[0]??``:a}function a(e,t){let i={},a=[];for(let o of e){let e=t[o];if(e===void 0)continue;let s=r(e);i[o]=(0,n.offsetIndices)(s.message,a.length),a.push(...s.components)}for(let[o,s]of Object.entries(t)){if(e.includes(o)||s===void 0)continue;let t=r(s);i[o]=(0,n.offsetIndices)(t.message,a.length),a.push(...t.components)}return{messages:i,components:a}}var o={id:String,context:String,comment:String,tag:{type:String,default:void 0}},s=(0,t.defineComponent)({name:`Trans`,props:o,setup(n,{slots:a}){let{t:o}=e.t();return()=>{let e=a.default?.();if(!e)return null;let{message:s,components:c}=r(e),l=o({...n.id===void 0?{}:{id:n.id},message:s,...n.context===void 0?{}:{context:n.context},...n.comment===void 0?{}:{comment:n.comment}}),u=c.length>0?i(l,c):l;return Array.isArray(u)?u.length===1?u[0]:n.tag?(0,t.h)(n.tag,null,u):u:u}}}),c={value:{type:Number,required:!0},id:String,context:String,comment:String,zero:String,one:String,two:String,few:String,many:String,other:{type:String,required:!0},offset:Number,tag:{type:String,default:void 0}},l=(0,t.defineComponent)({name:`Plural`,props:c,setup(r,{slots:o}){let{t:s}=e.t();return()=>{let e={zero:r.zero,one:r.one,two:r.two,few:r.few,many:r.many,other:r.other};for(let t of n.PLURAL_CATEGORIES){let n=o[t];n&&(e[t]=n({count:`#`}))}let{messages:c,components:l}=a(n.PLURAL_CATEGORIES,e),u=(0,n.buildICUPluralMessage)({...c.zero!==void 0&&{zero:c.zero},...c.one!==void 0&&{one:c.one},...c.two!==void 0&&{two:c.two},...c.few!==void 0&&{few:c.few},...c.many!==void 0&&{many:c.many},other:c.other??``},r.offset),d=s({id:r.id??(r.context===void 0?u:(0,n.hashMessage)(u,r.context)),message:u,...r.context===void 0?{}:{context:r.context},...r.comment===void 0?{}:{comment:r.comment}},{count:r.value}),f=l.length>0?i(d,l):d;return r.tag?(0,t.h)(r.tag,void 0,f??void 0):f??null}}}),u={value:{type:String,required:!0},id:String,context:String,comment:String,other:{type:String,required:!0},options:{type:Object,default:void 0},tag:{type:String,default:void 0}},d=(0,t.defineComponent)({name:`Select`,inheritAttrs:!1,props:u,setup(r,{attrs:o,slots:s}){let{t:c}=e.t();return()=>{let e={};if(r.options!==void 0){for(let[t,n]of Object.entries(r.options))e[t]=n;e.other=r.other}else{for(let[t,n]of Object.entries(o))typeof n==`string`&&(e[t]=n);e.other=r.other}for(let[t,n]of Object.entries(s))t===`default`||!n||(e[t]=n({value:`{value}`}));let l=[...Object.keys(e).filter(e=>e!==`other`),`other`],{messages:u,components:d}=a(l,e),f=(0,n.normalizeSelectForms)(Object.fromEntries([...l].map(e=>[e,u[e]??``]))),p=(0,n.buildICUSelectMessage)(f.forms),m=c({id:r.id??(r.context===void 0?p:(0,n.hashMessage)(p,r.context)),message:p,...r.context===void 0?{}:{context:r.context},...r.comment===void 0?{}:{comment:r.comment}},{value:f.valueMap[r.value]??`other`}),h=d.length>0?i(m,d):m;return r.tag?(0,t.h)(r.tag,void 0,h??void 0):h??null}}}),f={value:{type:[Date,Number],required:!0},format:{type:String,default:void 0},tag:{type:String,default:`span`}},p=(0,t.defineComponent)({name:`DateTime`,props:f,setup(n){let{d:r}=e.t();return()=>(0,t.h)(n.tag,r(n.value,n.format))}}),m={value:{type:Number,required:!0},format:{type:String,default:void 0},tag:{type:String,default:`span`}},h=(0,t.defineComponent)({name:`NumberFormat`,props:m,setup(n){let{n:r}=e.t();return()=>(0,t.h)(n.tag,r(n.value,n.format))}});exports.DateTime=p,exports.NumberFormat=h,exports.Plural=l,exports.Select=d,exports.Trans=s,Object.defineProperty(exports,`interpolate`,{enumerable:!0,get:function(){return n.interpolate}});
2
- //# sourceMappingURL=components-entry.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./NumberFormat-CgU3BNm8.cjs`);exports.DateTime=e.n,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.a;
@@ -1,227 +1,2 @@
1
- import { t as e } from "./use-i18n-DV-MXUZc.js";
2
- import { Comment as t, Text as n, defineComponent as r, h as i, isVNode as a } from "vue";
3
- import { PLURAL_CATEGORIES as o, buildICUPluralMessage as s, buildICUSelectMessage as c, hashMessage as l, interpolate as u, normalizeSelectForms as d, offsetIndices as f } from "@fluenti/core/internal";
4
- //#region src/components/rich-text.ts
5
- function p(e) {
6
- let r = [], i = "";
7
- function o(e) {
8
- if (e == null || typeof e == "boolean") return;
9
- if (Array.isArray(e)) {
10
- for (let t of e) o(t);
11
- return;
12
- }
13
- if (typeof e == "string" || typeof e == "number") {
14
- i += String(e);
15
- return;
16
- }
17
- if (!a(e) || e.type === t) return;
18
- if (e.type === n) {
19
- i += typeof e.children == "string" ? e.children : "";
20
- return;
21
- }
22
- let s = r.length, c = p(e.children);
23
- r.push(e), r.push(...c.components), i += `<${s}>${f(c.message, s + 1)}</${s}>`;
24
- }
25
- return o(e), {
26
- message: i,
27
- components: r
28
- };
29
- }
30
- function m(e, t) {
31
- let n = /<(\d+)>([\s\S]*?)<\/\1>/g, r = [], a = 0, o;
32
- for (n.lastIndex = 0, o = n.exec(e); o !== null;) {
33
- o.index > a && r.push(e.slice(a, o.index));
34
- let s = t[Number(o[1])], c = m(o[2], t);
35
- s ? r.push(i(s.type, s.props ?? {}, Array.isArray(c) ? c : [c])) : r.push(o[2]), a = n.lastIndex, o = n.exec(e);
36
- }
37
- return a < e.length && r.push(e.slice(a)), r.length <= 1 ? r[0] ?? "" : r;
38
- }
39
- function h(e, t) {
40
- let n = {}, r = [];
41
- for (let i of e) {
42
- let e = t[i];
43
- if (e === void 0) continue;
44
- let a = p(e);
45
- n[i] = f(a.message, r.length), r.push(...a.components);
46
- }
47
- for (let [i, a] of Object.entries(t)) {
48
- if (e.includes(i) || a === void 0) continue;
49
- let t = p(a);
50
- n[i] = f(t.message, r.length), r.push(...t.components);
51
- }
52
- return {
53
- messages: n,
54
- components: r
55
- };
56
- }
57
- var g = r({
58
- name: "Trans",
59
- props: {
60
- id: String,
61
- context: String,
62
- comment: String,
63
- tag: {
64
- type: String,
65
- default: void 0
66
- }
67
- },
68
- setup(t, { slots: n }) {
69
- let { t: r } = e();
70
- return () => {
71
- let e = n.default?.();
72
- if (!e) return null;
73
- let { message: a, components: o } = p(e), s = r({
74
- ...t.id === void 0 ? {} : { id: t.id },
75
- message: a,
76
- ...t.context === void 0 ? {} : { context: t.context },
77
- ...t.comment === void 0 ? {} : { comment: t.comment }
78
- }), c = o.length > 0 ? m(s, o) : s;
79
- return Array.isArray(c) ? c.length === 1 ? c[0] : t.tag ? i(t.tag, null, c) : c : c;
80
- };
81
- }
82
- }), _ = r({
83
- name: "Plural",
84
- props: {
85
- value: {
86
- type: Number,
87
- required: !0
88
- },
89
- id: String,
90
- context: String,
91
- comment: String,
92
- zero: String,
93
- one: String,
94
- two: String,
95
- few: String,
96
- many: String,
97
- other: {
98
- type: String,
99
- required: !0
100
- },
101
- offset: Number,
102
- tag: {
103
- type: String,
104
- default: void 0
105
- }
106
- },
107
- setup(t, { slots: n }) {
108
- let { t: r } = e();
109
- return () => {
110
- let e = {
111
- zero: t.zero,
112
- one: t.one,
113
- two: t.two,
114
- few: t.few,
115
- many: t.many,
116
- other: t.other
117
- };
118
- for (let t of o) {
119
- let r = n[t];
120
- r && (e[t] = r({ count: "#" }));
121
- }
122
- let { messages: a, components: c } = h(o, e), u = s({
123
- ...a.zero !== void 0 && { zero: a.zero },
124
- ...a.one !== void 0 && { one: a.one },
125
- ...a.two !== void 0 && { two: a.two },
126
- ...a.few !== void 0 && { few: a.few },
127
- ...a.many !== void 0 && { many: a.many },
128
- other: a.other ?? ""
129
- }, t.offset), d = r({
130
- id: t.id ?? (t.context === void 0 ? u : l(u, t.context)),
131
- message: u,
132
- ...t.context === void 0 ? {} : { context: t.context },
133
- ...t.comment === void 0 ? {} : { comment: t.comment }
134
- }, { count: t.value }), f = c.length > 0 ? m(d, c) : d;
135
- return t.tag ? i(t.tag, void 0, f ?? void 0) : f ?? null;
136
- };
137
- }
138
- }), v = r({
139
- name: "Select",
140
- inheritAttrs: !1,
141
- props: {
142
- value: {
143
- type: String,
144
- required: !0
145
- },
146
- id: String,
147
- context: String,
148
- comment: String,
149
- other: {
150
- type: String,
151
- required: !0
152
- },
153
- options: {
154
- type: Object,
155
- default: void 0
156
- },
157
- tag: {
158
- type: String,
159
- default: void 0
160
- }
161
- },
162
- setup(t, { attrs: n, slots: r }) {
163
- let { t: a } = e();
164
- return () => {
165
- let e = {};
166
- if (t.options !== void 0) {
167
- for (let [n, r] of Object.entries(t.options)) e[n] = r;
168
- e.other = t.other;
169
- } else {
170
- for (let [t, r] of Object.entries(n)) typeof r == "string" && (e[t] = r);
171
- e.other = t.other;
172
- }
173
- for (let [t, n] of Object.entries(r)) t === "default" || !n || (e[t] = n({ value: "{value}" }));
174
- let o = [...Object.keys(e).filter((e) => e !== "other"), "other"], { messages: s, components: u } = h(o, e), f = d(Object.fromEntries([...o].map((e) => [e, s[e] ?? ""]))), p = c(f.forms), g = a({
175
- id: t.id ?? (t.context === void 0 ? p : l(p, t.context)),
176
- message: p,
177
- ...t.context === void 0 ? {} : { context: t.context },
178
- ...t.comment === void 0 ? {} : { comment: t.comment }
179
- }, { value: f.valueMap[t.value] ?? "other" }), _ = u.length > 0 ? m(g, u) : g;
180
- return t.tag ? i(t.tag, void 0, _ ?? void 0) : _ ?? null;
181
- };
182
- }
183
- }), y = r({
184
- name: "DateTime",
185
- props: {
186
- value: {
187
- type: [Date, Number],
188
- required: !0
189
- },
190
- format: {
191
- type: String,
192
- default: void 0
193
- },
194
- tag: {
195
- type: String,
196
- default: "span"
197
- }
198
- },
199
- setup(t) {
200
- let { d: n } = e();
201
- return () => i(t.tag, n(t.value, t.format));
202
- }
203
- }), b = r({
204
- name: "NumberFormat",
205
- props: {
206
- value: {
207
- type: Number,
208
- required: !0
209
- },
210
- format: {
211
- type: String,
212
- default: void 0
213
- },
214
- tag: {
215
- type: String,
216
- default: "span"
217
- }
218
- },
219
- setup(t) {
220
- let { n } = e();
221
- return () => i(t.tag, n(t.value, t.format));
222
- }
223
- });
224
- //#endregion
225
- export { y as DateTime, b as NumberFormat, _ as Plural, v as Select, g as Trans, u as interpolate };
226
-
227
- //# sourceMappingURL=components-entry.js.map
1
+ import { a as e, i as t, n, r, t as i } from "./NumberFormat-Bxim144o.js";
2
+ export { n as DateTime, i as NumberFormat, t as Plural, r as Select, e as Trans };
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./use-i18n-D6iu0pGX.cjs`);let t=require(`vue`),n=require(`@fluenti/core`);function r(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var i=Symbol.for(`fluenti.runtime.vue.v1`);function a(){let e=globalThis[i];return typeof e==`object`&&e?e:null}function o(e){return typeof e==`object`&&e&&`default`in e?e.default:e}function s(e){let t=Object.keys(e).filter(e=>e!==`plural`);return t.length>0?t[0]:void 0}function c(i){let c=i.lazyLocaleLoading??i.splitting??!1,l={locale:i.locale,messages:i.messages??{}};i.fallbackLocale!==void 0&&(l.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(l.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(l.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(l.numberFormats=i.numberFormats),i.missing!==void 0&&(l.missing=i.missing),i.diagnostics!==void 0&&(l.diagnostics=i.diagnostics),i.interpolate!==void 0&&(l.interpolate=i.interpolate),l.devWarnings=l.devWarnings??(typeof process<`u`&&process.env.NODE_ENV===`development`);let u=(0,n.createFluentiCore)(l),d=(0,t.ref)(i.locale),f=(0,t.shallowReactive)({...i.messages}),p=(0,t.ref)(!1),m=new Set([i.locale]),h=(0,t.ref)(new Set(m));function g(e,t){let n=f[e];if(n)return n[t]}function _(){u.locale!==d.value&&(u.locale=d.value)}function v(e,...t){return f[d.value],_(),Array.isArray(e)&&`raw`in e?u.t(e,...t):u.t(e,t[0])}let y=0;async function b(e){if(!c||!i.chunkLoader){u.locale=e,d.value=e;return}let t=a();if(m.has(e)){try{t?.__switchLocale&&await t.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}u.locale=e,d.value=e;return}let n=++y;p.value=!0;try{let r=o(await i.chunkLoader(e));if(n!==y)return;f[e]={...f[e],...r},u.loadMessages(e,r),m.add(e),h.value=new Set(m);try{t?.__switchLocale&&await t.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}if(n!==y)return;u.locale=e,d.value=e}finally{n===y&&(p.value=!1)}}function x(e,t){f[e]={...f[e],...t},u.loadMessages(e,t),m.add(e),h.value=new Set(m)}let S=new Set;function C(e){if(!c||m.has(e)||!i.chunkLoader||S.has(e))return;S.add(e);let t=a();i.chunkLoader(e).then(async n=>{let r=o(n);f[e]={...f[e],...r},u.loadMessages(e,r),m.add(e),h.value=new Set(m),t?.__preloadLocale&&await t.__preloadLocale(e)}).catch(t=>{console.warn(`[fluenti] preload failed:`,e,t)}).finally(()=>{S.delete(e)})}function w(){return _(),u.getLocales()}function T(e,t){return d.value,_(),u.d(e,t)}function E(e,t){return d.value,_(),u.n(e,t)}function D(e,t){return d.value,_(),u.format(e,t)}function O(e,t,n){let i=r(n?v(e,n):v(e));function a(e){if(e.rawAttrs!=null&&e.rawAttrs!==``){let t=[],n=/([\w:@.!-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'))?/g,i;for(;(i=n.exec(e.rawAttrs))!==null;){let e=r(i[1]),n=i[2]??i[3];t.push(n===void 0?e:`${e}="${r(n)}"`)}return t.join(` `)}return e.attrs?Object.entries(e.attrs).map(([e,t])=>t?`${r(e)}="${r(t)}"`:r(e)).join(` `):``}let o=i.replace(/&lt;(\d+)\/&gt;/g,(e,n)=>{let i=t[Number(n)];if(!i)return``;let o=r(i.tag),s=a(i);return`<${o}${s?` `+s:``} />`});return o=o.replace(/&lt;(\d+)&gt;([\s\S]*?)&lt;\/\1&gt;/g,(e,n,i)=>{let o=t[Number(n)];if(!o)return i;let s=r(o.tag),c=a(o);return`<${s}${c?` `+c:``}>${i}</${s}>`}),o}function k(e,t){return g(t??d.value,e)!==void 0}function A(e,t){return g(t??d.value,e)}let j={t:v,locale:d,setLocale:b,loadMessages:x,getLocales:w,d:T,n:E,format:D,isLoading:p,loadedLocales:h,preloadLocale:C,te:k,tm:A};return{install(t){if(t.provide(e.r,j),i.components){let e=i.componentPrefix??``,n=i.components;n.Trans&&t.component(`${e}Trans`,n.Trans),n.Plural&&t.component(`${e}Plural`,n.Plural),n.Select&&t.component(`${e}Select`,n.Select),n.DateTime&&t.component(`${e}DateTime`,n.DateTime),n.NumberFormat&&t.component(`${e}NumberFormat`,n.NumberFormat)}i.injectGlobalProperties!==!1&&(t.config.globalProperties.$t=v,t.config.globalProperties.$d=T,t.config.globalProperties.$n=E,t.config.globalProperties.$vtRich=O);let n=new WeakMap;t.directive(`t`,{mounted(e,t){let r=s(t.modifiers);if(r){let t=e.getAttribute(r)??``;n.set(e,t),e.setAttribute(r,v(t))}else{let r=t.arg??e.textContent??``;n.set(e,r.trim()),e.textContent=v(r.trim(),t.value==null?void 0:{...t.value})}},updated(e,t){let r=s(t.modifiers);if(r){let t=n.get(e)??e.getAttribute(r)??``;e.setAttribute(r,v(t))}else e.textContent=v((t.arg??n.get(e)??``).trim(),t.value==null?void 0:{...t.value})}})},global:j}}var l=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/vue' is a compile-time API. Use it only with the Fluenti build transform inside <script setup> or setup(). For runtime lookups, use useI18n().t(...).")});exports.FLUENTI_KEY=e.r,exports.createFluenti=c,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return n.msg}}),exports.t=l,exports.useI18n=e.t,exports.useLocale=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./NumberFormat-CgU3BNm8.cjs`);let t=require(`vue`),n=require(`@fluenti/core`);function r(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}var i=Symbol.for(`fluenti.runtime.vue.v1`);function a(){let e=globalThis[i];return typeof e==`object`&&e?e:null}function o(e){return typeof e==`object`&&e&&`default`in e?e.default:e}function s(e){let t=Object.keys(e).filter(e=>e!==`plural`);return t.length>0?t[0]:void 0}function c(i){let c=i.lazyLocaleLoading??i.splitting??!1,l={locale:i.locale,messages:i.messages??{}};i.fallbackLocale!==void 0&&(l.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(l.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(l.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(l.numberFormats=i.numberFormats),i.missing!==void 0&&(l.missing=i.missing),i.diagnostics!==void 0&&(l.diagnostics=i.diagnostics),i.interpolate!==void 0&&(l.interpolate=i.interpolate),l.devWarnings=l.devWarnings??(typeof process<`u`&&process.env.NODE_ENV===`development`);let u=(0,n.createFluentiCore)(l),d=(0,t.ref)(i.locale),f=(0,t.shallowReactive)({...i.messages}),p=(0,t.ref)(!1),m=new Set([i.locale]),h=(0,t.ref)(new Set(m));function g(e,t){let n=f[e];if(n)return n[t]}function _(){u.locale!==d.value&&(u.locale=d.value)}function v(e,...t){return f[d.value],_(),Array.isArray(e)&&`raw`in e?u.t(e,...t):u.t(e,t[0])}let y=0;async function b(e){if(!c||!i.chunkLoader){u.locale=e,d.value=e;return}let t=a();if(m.has(e)){try{t?.__switchLocale&&await t.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}u.locale=e,d.value=e;return}let n=++y;p.value=!0;try{let r=o(await i.chunkLoader(e));if(n!==y)return;f[e]={...f[e],...r},u.loadMessages(e,r),m.add(e),h.value=new Set(m);try{t?.__switchLocale&&await t.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}if(n!==y)return;u.locale=e,d.value=e}finally{n===y&&(p.value=!1)}}function x(e,t){f[e]={...f[e],...t},u.loadMessages(e,t),m.add(e),h.value=new Set(m)}let S=new Set;function C(e){if(!c||m.has(e)||!i.chunkLoader||S.has(e))return;S.add(e);let t=a();i.chunkLoader(e).then(async n=>{let r=o(n);f[e]={...f[e],...r},u.loadMessages(e,r),m.add(e),h.value=new Set(m),t?.__preloadLocale&&await t.__preloadLocale(e)}).catch(t=>{console.warn(`[fluenti] preload failed:`,e,t)}).finally(()=>{S.delete(e)})}function w(){return _(),u.getLocales()}function T(e,t){return d.value,_(),u.d(e,t)}function E(e,t){return d.value,_(),u.n(e,t)}function D(e,t){return d.value,_(),u.format(e,t)}function O(e,t,n){let i=r(n?v(e,n):v(e));function a(e){if(e.rawAttrs!=null&&e.rawAttrs!==``){let t=[],n=/([\w:@.!-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'))?/g,i;for(;(i=n.exec(e.rawAttrs))!==null;){let e=r(i[1]),n=i[2]??i[3];t.push(n===void 0?e:`${e}="${r(n)}"`)}return t.join(` `)}return e.attrs?Object.entries(e.attrs).map(([e,t])=>t?`${r(e)}="${r(t)}"`:r(e)).join(` `):``}let o=i.replace(/&lt;(\d+)\/&gt;/g,(e,n)=>{let i=t[Number(n)];if(!i)return``;let o=r(i.tag),s=a(i);return`<${o}${s?` `+s:``} />`});return o=o.replace(/&lt;(\d+)&gt;([\s\S]*?)&lt;\/\1&gt;/g,(e,n,i)=>{let o=t[Number(n)];if(!o)return i;let s=r(o.tag),c=a(o);return`<${s}${c?` `+c:``}>${i}</${s}>`}),o}function k(e,t){return g(t??d.value,e)!==void 0}function A(e,t){return g(t??d.value,e)}let j={t:v,locale:d,setLocale:b,loadMessages:x,getLocales:w,d:T,n:E,format:D,isLoading:p,loadedLocales:h,preloadLocale:C,te:k,tm:A};return{install(t){if(t.provide(e.c,j),i.components){let e=i.componentPrefix??``,n=i.components;n.Trans&&t.component(`${e}Trans`,n.Trans),n.Plural&&t.component(`${e}Plural`,n.Plural),n.Select&&t.component(`${e}Select`,n.Select),n.DateTime&&t.component(`${e}DateTime`,n.DateTime),n.NumberFormat&&t.component(`${e}NumberFormat`,n.NumberFormat)}i.injectGlobalProperties!==!1&&(t.config.globalProperties.$t=v,t.config.globalProperties.$d=T,t.config.globalProperties.$n=E,t.config.globalProperties.$vtRich=O);let n=new WeakMap;t.directive(`t`,{mounted(e,t){let r=s(t.modifiers);if(r){let t=e.getAttribute(r)??``;n.set(e,t),e.setAttribute(r,v(t))}else{let r=t.arg??e.textContent??``;n.set(e,r.trim()),e.textContent=v(r.trim(),t.value==null?void 0:{...t.value})}},updated(e,t){let r=s(t.modifiers);if(r){let t=n.get(e)??e.getAttribute(r)??``;e.setAttribute(r,v(t))}else e.textContent=v((t.arg??n.get(e)??``).trim(),t.value==null?void 0:{...t.value})}})},global:j}}var l=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/vue' is a compile-time API. Use it only with the Fluenti build transform inside <script setup> or setup(). For runtime lookups, use useI18n().t(...).")});exports.DateTime=e.n,exports.FLUENTI_KEY=e.c,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.a,exports.createFluenti=c,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return n.msg}}),exports.t=l,exports.useI18n=e.o,exports.useLocale=e.s;
2
2
  //# sourceMappingURL=index.cjs.map