nextia 9.0.0 → 9.0.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.
- package/package.json +1 -1
- package/src/ui.js +23 -20
package/package.json
CHANGED
package/src/ui.js
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
import { createElement, useEffect, useRef } from 'react'
|
|
11
11
|
import { useCx } from './fx.js'
|
|
12
12
|
|
|
13
|
-
function Link({ children, href, value
|
|
14
|
-
href
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
function Link({ children, href, value, ...props }) {
|
|
14
|
+
const base = href ?? window.location.hash.split('?')[0]
|
|
15
|
+
const query =
|
|
16
|
+
value && Object.keys(value).length
|
|
17
|
+
? `?${new URLSearchParams(value).toString()}`
|
|
18
|
+
: ''
|
|
19
|
+
|
|
20
|
+
return createElement('a', { href: base + query, ...props }, children)
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function I18n({ value, args = [] }) {
|
|
@@ -25,20 +26,21 @@ function I18n({ value, args = [] }) {
|
|
|
25
26
|
if (!i18n) return null
|
|
26
27
|
|
|
27
28
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(
|
|
29
|
+
const text = value.split('.').reduce((ac, el) => ac[el], i18n)
|
|
30
|
+
const locale = context.state?.i18n ?? i18n.defaultLocale
|
|
31
|
+
const index = i18n.locales.indexOf(locale)
|
|
32
|
+
let translated = text[index]
|
|
33
|
+
|
|
34
|
+
if (args?.length) {
|
|
35
|
+
translated = translated.replace(
|
|
36
|
+
/([{}])\1|[{](.*?)(?:!(.+?))?[}]/g,
|
|
37
|
+
(match, _literal, number) => args[number] ?? match
|
|
36
38
|
)
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
return
|
|
41
|
+
return translated
|
|
40
42
|
} catch {
|
|
41
|
-
console.error(`
|
|
43
|
+
console.error(`[i18n] key not found: "${value}"`)
|
|
42
44
|
return value
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -46,7 +48,6 @@ function I18n({ value, args = [] }) {
|
|
|
46
48
|
function Icon({
|
|
47
49
|
id,
|
|
48
50
|
className,
|
|
49
|
-
animate = false,
|
|
50
51
|
style,
|
|
51
52
|
width = '48',
|
|
52
53
|
height,
|
|
@@ -63,8 +64,10 @@ function Icon({
|
|
|
63
64
|
const ref = useRef()
|
|
64
65
|
|
|
65
66
|
useEffect(() => {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
if (!ref.current || !icons) return
|
|
68
|
+
|
|
69
|
+
const el = icons.getElementById(id)
|
|
70
|
+
if (el) ref.current.innerHTML = el.innerHTML
|
|
68
71
|
}, [id, icons])
|
|
69
72
|
|
|
70
73
|
return createElement('svg', {
|