@fluenti/solid 0.3.3 → 0.4.0-rc.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/README.md +2 -2
- package/dist/components/DateTime.d.ts +3 -3
- package/dist/components/DateTime.d.ts.map +1 -1
- package/dist/components/NumberFormat.d.ts +3 -3
- package/dist/components/NumberFormat.d.ts.map +1 -1
- package/dist/components-entry.cjs +2 -0
- package/dist/components-entry.cjs.map +1 -0
- package/dist/components-entry.d.ts +12 -0
- package/dist/components-entry.d.ts.map +1 -0
- package/dist/components-entry.js +283 -0
- package/dist/components-entry.js.map +1 -0
- package/dist/context.d.ts +23 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -404
- package/dist/index.js.map +1 -1
- package/dist/plural.d.ts +9 -0
- package/dist/plural.d.ts.map +1 -1
- package/dist/provider.d.ts +19 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/rich-dom.d.ts.map +1 -1
- package/dist/select.d.ts +15 -0
- package/dist/select.d.ts.map +1 -1
- package/dist/trans.d.ts.map +1 -1
- package/dist/use-i18n-Bb-Ivibx.js +190 -0
- package/dist/use-i18n-Bb-Ivibx.js.map +1 -0
- package/dist/use-i18n-CooxLxjG.cjs +2 -0
- package/dist/use-i18n-CooxLxjG.cjs.map +1 -0
- package/llms.txt +44 -0
- package/package.json +18 -3
- package/src/components/DateTime.tsx +4 -4
- package/src/components/NumberFormat.tsx +4 -4
- package/src/components-entry.ts +13 -0
- package/src/context.ts +116 -142
- package/src/index.ts +5 -6
- package/src/plural.tsx +9 -0
- package/src/provider.tsx +19 -1
- package/src/rich-dom.tsx +10 -0
- package/src/select.tsx +15 -0
- package/src/trans.tsx +8 -2
package/README.md
CHANGED
|
@@ -217,7 +217,7 @@ ICU select patterns as a component:
|
|
|
217
217
|
```tsx
|
|
218
218
|
import { DateTime } from '@fluenti/solid'
|
|
219
219
|
|
|
220
|
-
<DateTime value={new Date()}
|
|
220
|
+
<DateTime value={new Date()} format="long" />
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
| Prop | Type | Default | Description |
|
|
@@ -230,7 +230,7 @@ import { DateTime } from '@fluenti/solid'
|
|
|
230
230
|
```tsx
|
|
231
231
|
import { NumberFormat } from '@fluenti/solid'
|
|
232
232
|
|
|
233
|
-
<NumberFormat value={1234.56}
|
|
233
|
+
<NumberFormat value={1234.56} format="currency" />
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
| Prop | Type | Default | Description |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface DateTimeProps {
|
|
2
2
|
/** Date value to format */
|
|
3
3
|
value: Date | number;
|
|
4
|
-
/** Named format
|
|
5
|
-
|
|
4
|
+
/** Named format key defined in dateFormats config */
|
|
5
|
+
format?: string;
|
|
6
6
|
}
|
|
7
7
|
/** @alias DateTimeProps */
|
|
8
8
|
export type FluentiDateTimeProps = DateTimeProps;
|
|
@@ -11,7 +11,7 @@ export type FluentiDateTimeProps = DateTimeProps;
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* <DateTime value={new Date()}
|
|
14
|
+
* <DateTime value={new Date()} format="long" />
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare function DateTime(props: DateTimeProps): import("solid-js").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,2BAA2B;AAC3B,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,kCAG5C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface NumberProps {
|
|
2
2
|
/** Number value to format */
|
|
3
3
|
value: number;
|
|
4
|
-
/** Named format
|
|
5
|
-
|
|
4
|
+
/** Named format key defined in numberFormats config */
|
|
5
|
+
format?: string;
|
|
6
6
|
}
|
|
7
7
|
/** @alias NumberProps */
|
|
8
8
|
export type FluentiNumberFormatProps = NumberProps;
|
|
@@ -11,7 +11,7 @@ export type FluentiNumberFormatProps = NumberProps;
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
|
-
* <NumberFormat value={1234.56}
|
|
14
|
+
* <NumberFormat value={1234.56} format="currency" />
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export declare function NumberFormat(props: NumberProps): import("solid-js").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../src/components/NumberFormat.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,
|
|
1
|
+
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../src/components/NumberFormat.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,yBAAyB;AACzB,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,kCAG9C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./use-i18n-CooxLxjG.cjs`);let t=require(`solid-js`),n=require(`solid-js/web`),r=require(`@fluenti/core/internal`);function i(e){return typeof Node<`u`&&e instanceof Node}function a(e){return typeof e==`function`&&!e.length?e():e}function o(e){let t=[],n=``;function s(e){let c=a(e);if(c==null||typeof c==`boolean`)return;if(Array.isArray(c)){for(let e of c)s(e);return}if(typeof c==`string`||typeof c==`number`){n+=String(c);return}if(!i(c))return;if(c.nodeType===Node.TEXT_NODE){n+=c.textContent??``;return}if(c.nodeType===Node.DOCUMENT_FRAGMENT_NODE){s(Array.from(c.childNodes));return}let l=t.length,u=o(Array.from(c.childNodes));t.push(c.cloneNode(!1)),t.push(...u.components),u.message===``&&u.components.length===0?n+=`<${l}/>`:n+=`<${l}>${(0,r.offsetIndices)(u.message,l+1)}</${l}>`}return s(e),{message:n,components:t}}function s(e,t){let n=a(t);if(!(n==null||typeof n==`boolean`)){if(Array.isArray(n)){for(let t of n)s(e,t);return}if(typeof n==`string`||typeof n==`number`){e.appendChild(document.createTextNode(String(n)));return}i(n)&&e.appendChild(n)}}function c(e,t){let n=/<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g,r=[],i=0,a;for(n.lastIndex=0,a=n.exec(e);a!==null;){a.index>i&&r.push(e.slice(i,a.index));let o=Number(a[1]),l=a[2]===void 0;if(!Number.isInteger(o)||o<0||o>=t.length){l||r.push(a[3]??``),i=n.lastIndex,a=n.exec(e);continue}let u=t[o];if(l)u&&r.push(u.cloneNode(!1));else{let e=c(a[2]===void 0?``:a[3],t);if(u){let t=u.cloneNode(!1);s(t,e),r.push(t)}else r.push(a[3]??``)}i=n.lastIndex,a=n.exec(e)}return i<e.length&&r.push(e.slice(i)),r.length<=1?r[0]??``:r}function l(e,t){let n={},i=[];for(let a of e){let e=t[a];if(e===void 0)continue;let s=o(e);n[a]=(0,r.offsetIndices)(s.message,i.length),i.push(...s.components)}for(let[a,s]of Object.entries(t)){if(e.includes(a)||s===void 0)continue;let t=o(s);n[a]=(0,r.offsetIndices)(t.message,i.length),i.push(...t.components)}return{messages:n,components:i}}var u=100;function d(e,t=0){if(t>u)return[{type:`text`,value:e}];let n=[],r=0;for(;r<e.length;){let i=e.indexOf(`<`,r);if(i===-1){n.push({type:`text`,value:e.slice(r)});break}i>r&&n.push({type:`text`,value:e.slice(r,i)});let a=e.slice(i).match(/^<(\w+)\s*\/>/);if(a){n.push({type:`tag`,name:a[1],children:[]}),r=i+a[0].length;continue}let o=e.slice(i).match(/^<(\w+)>/);if(!o){n.push({type:`text`,value:`<`}),r=i+1;continue}let s=o[1],c=i+o[0].length,l=f(e,s,c);if(l===-1){n.push({type:`text`,value:e.slice(i,c)}),r=c;continue}let u=e.slice(c,l),p=`</${s}>`;n.push({type:`tag`,name:s,children:d(u,t+1)}),r=l+p.length}return n}function f(e,t,n){let r=`<${t}>`,i=`</${t}>`,a=1,o=n;for(;o<e.length&&a>0;){let t=e.indexOf(r,o),n=e.indexOf(i,o);if(n===-1)return-1;if(t!==-1&&t<n)a++,o=t+r.length;else{if(a--,a===0)return n;o=n+i.length}}return-1}function p(e,t){let r=e.map(e=>{if(e.type===`text`)return e.value;let r=t[e.name];return r?(0,n.createComponent)(n.Dynamic,{component:r,children:e.children.length>0?p(e.children,t):void 0}):p(e.children,t)});return r.length===1?r[0]:r}var m=r=>{let{t:i}=e.t(),a=(0,t.children)(()=>r.children),s=(0,t.createMemo)(()=>{let e=r.__message??r.message;return typeof e==`function`?e():e}),l=(0,t.createMemo)(()=>r.__components??r.components);return(()=>{let e=s(),t=l();if(e!==void 0&&t)return p(d(i({...r.id===void 0?{}:{id:r.id},message:e,...r.context===void 0?{}:{context:r.context},...r.comment===void 0?{}:{comment:r.comment}})),t);let u=a.toArray();if(u.length===0)return null;let f=o(u),m=i({...r.id===void 0?{}:{id:r.id},message:f.message,...r.context===void 0?{}:{context:r.context},...r.comment===void 0?{}:{comment:r.comment}}),h=f.components.length>0?c(m,f.components):m;return Array.isArray(h)&&h.length>1&&r.tag?(0,n.createComponent)(n.Dynamic,{get component(){return r.tag},children:h}):h})},h=t=>{let{t:i}=e.t();function a(e){return typeof e==`function`?e():e}return(()=>{let e={};for(let n of r.PLURAL_CATEGORIES){let r=a(t[n]);r!==void 0&&(e[n]=r)}let{messages:o,components:s}=l(r.PLURAL_CATEGORIES,e),u=(0,r.buildICUPluralMessage)({...o.zero!==void 0&&{zero:o.zero},...o.one!==void 0&&{one:o.one},...o.two!==void 0&&{two:o.two},...o.few!==void 0&&{few:o.few},...o.many!==void 0&&{many:o.many},other:o.other??``},t.offset),d=i({id:t.id??(t.context===void 0?u:(0,r.hashMessage)(u,t.context)),message:u,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}},{count:t.value}),f=s.length>0?c(d,s):d;return t.tag?(0,n.createComponent)(n.Dynamic,{get component(){return t.tag},children:f}):f})},g=t=>{let{t:i}=e.t(),a=()=>{let e=t.options===void 0?{...Object.fromEntries(Object.entries(t).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`,`tag`].includes(e))),other:t.other}:{...t.options,other:t.other},n=[...Object.keys(e).filter(e=>e!==`other`),`other`],{messages:a,components:o}=l(n,e),s=(0,r.normalizeSelectForms)(Object.fromEntries([...n].map(e=>[e,a[e]??``]))),u=i({id:t.id??(t.context===void 0?(0,r.buildICUSelectMessage)(s.forms):(0,r.hashMessage)((0,r.buildICUSelectMessage)(s.forms),t.context)),message:(0,r.buildICUSelectMessage)(s.forms),...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}},{value:s.valueMap[t.value]??`other`});return o.length>0?c(u,o):u};return(()=>t.tag?(0,n.createComponent)(n.Dynamic,{get component(){return t.tag},get children(){return a()}}):(0,n.memo)(a))};function _(t){let{d:r}=e.t();return(0,n.memo)(()=>r(t.value,t.format))}function v(t){let{n:r}=e.t();return(0,n.memo)(()=>r(t.value,t.format))}exports.DateTime=_,exports.NumberFormat=v,exports.Plural=h,exports.Select=g,exports.Trans=m,Object.defineProperty(exports,`interpolate`,{enumerable:!0,get:function(){return r.interpolate}});
|
|
2
|
+
//# sourceMappingURL=components-entry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-entry.cjs","names":["JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","isInteger","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","MAX_TOKEN_DEPTH","parseTokens","input","depth","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","format","FluentiDateTimeProps","DateTime","props","d","_$memo","useI18n","NumberProps","value","format","FluentiNumberFormatProps","NumberFormat","props","n","_$memo"],"sources":["../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\n components.push(...inner.components)\n if (inner.message === '' && inner.components.length === 0) {\n message += `<${idx}/>`\n } else {\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n }\n\n visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.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 isSelfClosing = match[2] === undefined\n\n if (!Number.isInteger(idx) || idx < 0 || idx >= components.length) {\n if (!isSelfClosing) {\n result.push(match[3] ?? '')\n }\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n continue\n }\n\n const template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.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) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\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\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\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?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\nconst MAX_TOKEN_DEPTH = 100\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string, depth: number = 0): readonly Token[] {\n if (depth > MAX_TOKEN_DEPTH) {\n // Bail out as plain text to prevent stack overflow\n return [{ type: 'text', value: input }]\n }\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent, depth + 1),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\n value: number\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\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 core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n *\n * @example\n * ```tsx\n * import { Plural } from '@fluenti/solid'\n *\n * function ItemCount(props: { count: number }) {\n * return <Plural value={props.count} one=\"# item\" other=\"# items\" />\n * }\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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\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) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\n value: string\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 message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n *\n * @example\n * ```tsx\n * import { Select } from '@fluenti/solid'\n *\n * function Greeting(props: { gender: string }) {\n * return (\n * <Select value={props.gender}\n * male=\"He liked your post\"\n * female=\"She liked your post\"\n * other=\"They liked your post\"\n * />\n * )\n * }\n * ```\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.other,\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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/** @alias DateTimeProps */\nexport type FluentiDateTimeProps = DateTimeProps\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.format)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberProps */\nexport type FluentiNumberFormatProps = NumberProps\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.format)}</>\n}\n"],"mappings":"sMAEA,SAASC,EAAWC,EAA+B,CACjD,OAAO,OAAOC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AO,CAAA,CCFxC,SAAgBW,EAAaC,EAAoB,CAC/C,GAAM,CAAEC,KAAMP,EAAAA,GAAS,CACvB,OAAA,EAAA,EAAA,UAAUO,EAAED,EAAMJ,MAAOI,EAAMH,OAAO,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Trans } from './trans';
|
|
2
|
+
export type { FluentiTransProps } from './trans';
|
|
3
|
+
export { Plural } from './plural';
|
|
4
|
+
export type { FluentiPluralProps } from './plural';
|
|
5
|
+
export { SelectComp as Select } from './select';
|
|
6
|
+
export type { FluentiSelectProps } from './select';
|
|
7
|
+
export { DateTime } from './components/DateTime';
|
|
8
|
+
export type { DateTimeProps, FluentiDateTimeProps } from './components/DateTime';
|
|
9
|
+
export { NumberFormat } from './components/NumberFormat';
|
|
10
|
+
export type { NumberProps, FluentiNumberFormatProps } from './components/NumberFormat';
|
|
11
|
+
export { interpolate } from '@fluenti/core/internal';
|
|
12
|
+
//# sourceMappingURL=components-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-entry.d.ts","sourceRoot":"","sources":["../src/components-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { t as e } from "./use-i18n-Bb-Ivibx.js";
|
|
2
|
+
import { children as t, createMemo as n } from "solid-js";
|
|
3
|
+
import { Dynamic as r, createComponent as i, memo as a } from "solid-js/web";
|
|
4
|
+
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";
|
|
5
|
+
//#region src/rich-dom.tsx
|
|
6
|
+
function p(e) {
|
|
7
|
+
return typeof Node < "u" && e instanceof Node;
|
|
8
|
+
}
|
|
9
|
+
function m(e) {
|
|
10
|
+
return typeof e == "function" && !e.length ? e() : e;
|
|
11
|
+
}
|
|
12
|
+
function h(e) {
|
|
13
|
+
let t = [], n = "";
|
|
14
|
+
function r(e) {
|
|
15
|
+
let i = m(e);
|
|
16
|
+
if (i == null || typeof i == "boolean") return;
|
|
17
|
+
if (Array.isArray(i)) {
|
|
18
|
+
for (let e of i) r(e);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof i == "string" || typeof i == "number") {
|
|
22
|
+
n += String(i);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!p(i)) return;
|
|
26
|
+
if (i.nodeType === Node.TEXT_NODE) {
|
|
27
|
+
n += i.textContent ?? "";
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (i.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
31
|
+
r(Array.from(i.childNodes));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let a = t.length, o = h(Array.from(i.childNodes));
|
|
35
|
+
t.push(i.cloneNode(!1)), t.push(...o.components), o.message === "" && o.components.length === 0 ? n += `<${a}/>` : n += `<${a}>${f(o.message, a + 1)}</${a}>`;
|
|
36
|
+
}
|
|
37
|
+
return r(e), {
|
|
38
|
+
message: n,
|
|
39
|
+
components: t
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function g(e, t) {
|
|
43
|
+
let n = m(t);
|
|
44
|
+
if (!(n == null || typeof n == "boolean")) {
|
|
45
|
+
if (Array.isArray(n)) {
|
|
46
|
+
for (let t of n) g(e, t);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof n == "string" || typeof n == "number") {
|
|
50
|
+
e.appendChild(document.createTextNode(String(n)));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
p(n) && e.appendChild(n);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _(e, t) {
|
|
57
|
+
let n = /<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g, r = [], i = 0, a;
|
|
58
|
+
for (n.lastIndex = 0, a = n.exec(e); a !== null;) {
|
|
59
|
+
a.index > i && r.push(e.slice(i, a.index));
|
|
60
|
+
let o = Number(a[1]), s = a[2] === void 0;
|
|
61
|
+
if (!Number.isInteger(o) || o < 0 || o >= t.length) {
|
|
62
|
+
s || r.push(a[3] ?? ""), i = n.lastIndex, a = n.exec(e);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
let c = t[o];
|
|
66
|
+
if (s) c && r.push(c.cloneNode(!1));
|
|
67
|
+
else {
|
|
68
|
+
let e = _(a[2] === void 0 ? "" : a[3], t);
|
|
69
|
+
if (c) {
|
|
70
|
+
let t = c.cloneNode(!1);
|
|
71
|
+
g(t, e), r.push(t);
|
|
72
|
+
} else r.push(a[3] ?? "");
|
|
73
|
+
}
|
|
74
|
+
i = n.lastIndex, a = n.exec(e);
|
|
75
|
+
}
|
|
76
|
+
return i < e.length && r.push(e.slice(i)), r.length <= 1 ? r[0] ?? "" : r;
|
|
77
|
+
}
|
|
78
|
+
function v(e, t) {
|
|
79
|
+
let n = {}, r = [];
|
|
80
|
+
for (let i of e) {
|
|
81
|
+
let e = t[i];
|
|
82
|
+
if (e === void 0) continue;
|
|
83
|
+
let a = h(e);
|
|
84
|
+
n[i] = f(a.message, r.length), r.push(...a.components);
|
|
85
|
+
}
|
|
86
|
+
for (let [i, a] of Object.entries(t)) {
|
|
87
|
+
if (e.includes(i) || a === void 0) continue;
|
|
88
|
+
let t = h(a);
|
|
89
|
+
n[i] = f(t.message, r.length), r.push(...t.components);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
messages: n,
|
|
93
|
+
components: r
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/trans.tsx
|
|
98
|
+
var y = 100;
|
|
99
|
+
function b(e, t = 0) {
|
|
100
|
+
if (t > y) return [{
|
|
101
|
+
type: "text",
|
|
102
|
+
value: e
|
|
103
|
+
}];
|
|
104
|
+
let n = [], r = 0;
|
|
105
|
+
for (; r < e.length;) {
|
|
106
|
+
let i = e.indexOf("<", r);
|
|
107
|
+
if (i === -1) {
|
|
108
|
+
n.push({
|
|
109
|
+
type: "text",
|
|
110
|
+
value: e.slice(r)
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
i > r && n.push({
|
|
115
|
+
type: "text",
|
|
116
|
+
value: e.slice(r, i)
|
|
117
|
+
});
|
|
118
|
+
let a = e.slice(i).match(/^<(\w+)\s*\/>/);
|
|
119
|
+
if (a) {
|
|
120
|
+
n.push({
|
|
121
|
+
type: "tag",
|
|
122
|
+
name: a[1],
|
|
123
|
+
children: []
|
|
124
|
+
}), r = i + a[0].length;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
let o = e.slice(i).match(/^<(\w+)>/);
|
|
128
|
+
if (!o) {
|
|
129
|
+
n.push({
|
|
130
|
+
type: "text",
|
|
131
|
+
value: "<"
|
|
132
|
+
}), r = i + 1;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let s = o[1], c = i + o[0].length, l = x(e, s, c);
|
|
136
|
+
if (l === -1) {
|
|
137
|
+
n.push({
|
|
138
|
+
type: "text",
|
|
139
|
+
value: e.slice(i, c)
|
|
140
|
+
}), r = c;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
let u = e.slice(c, l), d = `</${s}>`;
|
|
144
|
+
n.push({
|
|
145
|
+
type: "tag",
|
|
146
|
+
name: s,
|
|
147
|
+
children: b(u, t + 1)
|
|
148
|
+
}), r = l + d.length;
|
|
149
|
+
}
|
|
150
|
+
return n;
|
|
151
|
+
}
|
|
152
|
+
function x(e, t, n) {
|
|
153
|
+
let r = `<${t}>`, i = `</${t}>`, a = 1, o = n;
|
|
154
|
+
for (; o < e.length && a > 0;) {
|
|
155
|
+
let t = e.indexOf(r, o), n = e.indexOf(i, o);
|
|
156
|
+
if (n === -1) return -1;
|
|
157
|
+
if (t !== -1 && t < n) a++, o = t + r.length;
|
|
158
|
+
else {
|
|
159
|
+
if (a--, a === 0) return n;
|
|
160
|
+
o = n + i.length;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return -1;
|
|
164
|
+
}
|
|
165
|
+
function S(e, t) {
|
|
166
|
+
let n = e.map((e) => {
|
|
167
|
+
if (e.type === "text") return e.value;
|
|
168
|
+
let n = t[e.name];
|
|
169
|
+
return n ? i(r, {
|
|
170
|
+
component: n,
|
|
171
|
+
children: e.children.length > 0 ? S(e.children, t) : void 0
|
|
172
|
+
}) : S(e.children, t);
|
|
173
|
+
});
|
|
174
|
+
return n.length === 1 ? n[0] : n;
|
|
175
|
+
}
|
|
176
|
+
var C = (a) => {
|
|
177
|
+
let { t: o } = e(), s = t(() => a.children), c = n(() => {
|
|
178
|
+
let e = a.__message ?? a.message;
|
|
179
|
+
return typeof e == "function" ? e() : e;
|
|
180
|
+
}), l = n(() => a.__components ?? a.components);
|
|
181
|
+
return (() => {
|
|
182
|
+
let e = c(), t = l();
|
|
183
|
+
if (e !== void 0 && t) return S(b(o({
|
|
184
|
+
...a.id === void 0 ? {} : { id: a.id },
|
|
185
|
+
message: e,
|
|
186
|
+
...a.context === void 0 ? {} : { context: a.context },
|
|
187
|
+
...a.comment === void 0 ? {} : { comment: a.comment }
|
|
188
|
+
})), t);
|
|
189
|
+
let n = s.toArray();
|
|
190
|
+
if (n.length === 0) return null;
|
|
191
|
+
let u = h(n), d = o({
|
|
192
|
+
...a.id === void 0 ? {} : { id: a.id },
|
|
193
|
+
message: u.message,
|
|
194
|
+
...a.context === void 0 ? {} : { context: a.context },
|
|
195
|
+
...a.comment === void 0 ? {} : { comment: a.comment }
|
|
196
|
+
}), f = u.components.length > 0 ? _(d, u.components) : d;
|
|
197
|
+
return Array.isArray(f) && f.length > 1 && a.tag ? i(r, {
|
|
198
|
+
get component() {
|
|
199
|
+
return a.tag;
|
|
200
|
+
},
|
|
201
|
+
children: f
|
|
202
|
+
}) : f;
|
|
203
|
+
});
|
|
204
|
+
}, w = (t) => {
|
|
205
|
+
let { t: n } = e();
|
|
206
|
+
function a(e) {
|
|
207
|
+
return typeof e == "function" ? e() : e;
|
|
208
|
+
}
|
|
209
|
+
return (() => {
|
|
210
|
+
let e = {};
|
|
211
|
+
for (let n of o) {
|
|
212
|
+
let r = a(t[n]);
|
|
213
|
+
r !== void 0 && (e[n] = r);
|
|
214
|
+
}
|
|
215
|
+
let { messages: c, components: u } = v(o, e), d = s({
|
|
216
|
+
...c.zero !== void 0 && { zero: c.zero },
|
|
217
|
+
...c.one !== void 0 && { one: c.one },
|
|
218
|
+
...c.two !== void 0 && { two: c.two },
|
|
219
|
+
...c.few !== void 0 && { few: c.few },
|
|
220
|
+
...c.many !== void 0 && { many: c.many },
|
|
221
|
+
other: c.other ?? ""
|
|
222
|
+
}, t.offset), f = n({
|
|
223
|
+
id: t.id ?? (t.context === void 0 ? d : l(d, t.context)),
|
|
224
|
+
message: d,
|
|
225
|
+
...t.context === void 0 ? {} : { context: t.context },
|
|
226
|
+
...t.comment === void 0 ? {} : { comment: t.comment }
|
|
227
|
+
}, { count: t.value }), p = u.length > 0 ? _(f, u) : f;
|
|
228
|
+
return t.tag ? i(r, {
|
|
229
|
+
get component() {
|
|
230
|
+
return t.tag;
|
|
231
|
+
},
|
|
232
|
+
children: p
|
|
233
|
+
}) : p;
|
|
234
|
+
});
|
|
235
|
+
}, T = (t) => {
|
|
236
|
+
let { t: n } = e(), o = () => {
|
|
237
|
+
let e = t.options === void 0 ? {
|
|
238
|
+
...Object.fromEntries(Object.entries(t).filter(([e]) => ![
|
|
239
|
+
"value",
|
|
240
|
+
"id",
|
|
241
|
+
"context",
|
|
242
|
+
"comment",
|
|
243
|
+
"options",
|
|
244
|
+
"other",
|
|
245
|
+
"tag"
|
|
246
|
+
].includes(e))),
|
|
247
|
+
other: t.other
|
|
248
|
+
} : {
|
|
249
|
+
...t.options,
|
|
250
|
+
other: t.other
|
|
251
|
+
}, r = [...Object.keys(e).filter((e) => e !== "other"), "other"], { messages: i, components: a } = v(r, e), o = d(Object.fromEntries([...r].map((e) => [e, i[e] ?? ""]))), s = n({
|
|
252
|
+
id: t.id ?? (t.context === void 0 ? c(o.forms) : l(c(o.forms), t.context)),
|
|
253
|
+
message: c(o.forms),
|
|
254
|
+
...t.context === void 0 ? {} : { context: t.context },
|
|
255
|
+
...t.comment === void 0 ? {} : { comment: t.comment }
|
|
256
|
+
}, { value: o.valueMap[t.value] ?? "other" });
|
|
257
|
+
return a.length > 0 ? _(s, a) : s;
|
|
258
|
+
};
|
|
259
|
+
return (() => t.tag ? i(r, {
|
|
260
|
+
get component() {
|
|
261
|
+
return t.tag;
|
|
262
|
+
},
|
|
263
|
+
get children() {
|
|
264
|
+
return o();
|
|
265
|
+
}
|
|
266
|
+
}) : a(o));
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/components/DateTime.tsx
|
|
270
|
+
function E(t) {
|
|
271
|
+
let { d: n } = e();
|
|
272
|
+
return a(() => n(t.value, t.format));
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/components/NumberFormat.tsx
|
|
276
|
+
function D(t) {
|
|
277
|
+
let { n } = e();
|
|
278
|
+
return a(() => n(t.value, t.format));
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
export { E as DateTime, D as NumberFormat, w as Plural, T as Select, C as Trans, u as interpolate };
|
|
282
|
+
|
|
283
|
+
//# sourceMappingURL=components-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-entry.js","names":["JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","isInteger","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","MAX_TOKEN_DEPTH","parseTokens","input","depth","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","format","FluentiDateTimeProps","DateTime","props","d","_$memo","useI18n","NumberProps","value","format","FluentiNumberFormatProps","NumberFormat","props","n","_$memo"],"sources":["../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\n components.push(...inner.components)\n if (inner.message === '' && inner.components.length === 0) {\n message += `<${idx}/>`\n } else {\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n }\n\n visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.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 isSelfClosing = match[2] === undefined\n\n if (!Number.isInteger(idx) || idx < 0 || idx >= components.length) {\n if (!isSelfClosing) {\n result.push(match[3] ?? '')\n }\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n continue\n }\n\n const template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.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) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\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\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\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?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\nconst MAX_TOKEN_DEPTH = 100\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string, depth: number = 0): readonly Token[] {\n if (depth > MAX_TOKEN_DEPTH) {\n // Bail out as plain text to prevent stack overflow\n return [{ type: 'text', value: input }]\n }\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent, depth + 1),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\n value: number\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\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 core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n *\n * @example\n * ```tsx\n * import { Plural } from '@fluenti/solid'\n *\n * function ItemCount(props: { count: number }) {\n * return <Plural value={props.count} one=\"# item\" other=\"# items\" />\n * }\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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\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) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\n value: string\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 message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n *\n * @example\n * ```tsx\n * import { Select } from '@fluenti/solid'\n *\n * function Greeting(props: { gender: string }) {\n * return (\n * <Select value={props.gender}\n * male=\"He liked your post\"\n * female=\"She liked your post\"\n * other=\"They liked your post\"\n * />\n * )\n * }\n * ```\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.other,\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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/** @alias DateTimeProps */\nexport type FluentiDateTimeProps = DateTimeProps\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.format)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberProps */\nexport type FluentiNumberFormatProps = NumberProps\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.format)}</>\n}\n"],"mappings":";;;;;AAEA,SAASC,EAAWC,GAA+B;AACjD,Q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}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
|
-
import { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core';
|
|
2
|
+
import { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig, CustomFormatter } from '@fluenti/core';
|
|
3
3
|
/** Chunk loader for lazy locale loading */
|
|
4
4
|
export type ChunkLoader = (locale: string) => Promise<Record<string, CompiledMessage> | {
|
|
5
5
|
default: Record<string, CompiledMessage>;
|
|
@@ -18,6 +18,14 @@ export interface FluentiConfig extends FluentiCoreConfig {
|
|
|
18
18
|
numberFormats?: NumberFormatOptions;
|
|
19
19
|
/** Runtime diagnostics configuration */
|
|
20
20
|
diagnostics?: DiagnosticsConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Custom message interpolation function.
|
|
23
|
+
*
|
|
24
|
+
* By default, the runtime uses a lightweight `{key}` replacer.
|
|
25
|
+
* Pass the full `interpolate` from `@fluenti/core/internal` for
|
|
26
|
+
* runtime ICU MessageFormat support (plurals, selects, nested arguments).
|
|
27
|
+
*/
|
|
28
|
+
interpolate?: (message: string, values: Record<string, unknown> | undefined, locale: string, formatters?: Record<string, CustomFormatter>) => string;
|
|
21
29
|
}
|
|
22
30
|
/** Reactive i18n context holding locale signal and translation utilities */
|
|
23
31
|
export interface FluentiContext {
|
|
@@ -55,6 +63,20 @@ export interface FluentiContext {
|
|
|
55
63
|
*
|
|
56
64
|
* The returned `t()` reads the internal `locale()` signal, so any
|
|
57
65
|
* Solid computation that calls `t()` will re-run when the locale changes.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* import { createFluentiContext } from '@fluenti/solid'
|
|
70
|
+
* import messages from './locales/compiled/en.js'
|
|
71
|
+
*
|
|
72
|
+
* const ctx = createFluentiContext({
|
|
73
|
+
* locale: 'en',
|
|
74
|
+
* messages: { en: messages },
|
|
75
|
+
* })
|
|
76
|
+
*
|
|
77
|
+
* // Use t`` tagged template (preferred)
|
|
78
|
+
* const greeting = ctx.t`Hello, {name}!`
|
|
79
|
+
* ```
|
|
58
80
|
*/
|
|
59
81
|
export declare function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext;
|
|
60
82
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAyB,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEhO,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,CAAC,CAAA;AAuD5F,uDAAuD;AACvD,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,iDAAiD;IACjD,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,sCAAsC;IACtC,aAAa,C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