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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ui.js +23 -20
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nextia",
3
3
  "description": "Create fast web applications",
4
- "version": "9.0.0",
4
+ "version": "9.0.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
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 = {}, ...props }) {
14
- href ??= window.location.hash.split('?')[0]
15
- value = Object.keys(value).length
16
- ? `?${new URLSearchParams(value).toString()}`
17
- : ''
18
-
19
- return createElement('a', { href: href + value, ...props }, children)
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
- let text = value.split('.').reduce((ac, el) => ac[el], i18n)
29
-
30
- text = text[i18n.locales.indexOf(context.state?.i18n || i18n.defaultLocale)]
31
-
32
- if (args) {
33
- text = text.replace(
34
- /([{}])\\1|[{](.*?)(?:!(.+?))?[}]/g,
35
- (match, _literal, number) => args[number] || match
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 text
41
+ return translated
40
42
  } catch {
41
- console.error(`Error in [il8n] => ${value}`)
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
- const el = icons?.getElementById(id)
67
- if (ref.current && el) ref.current.innerHTML = el.innerHTML
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', {