nextia 9.0.1 → 9.0.2
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/fx.js +2 -15
- package/src/index.js +3 -3
- package/src/ui.js +14 -11
- package/src/utils.js +14 -14
package/package.json
CHANGED
package/src/fx.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* https://github.com/sinuhedev/nextia
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createContext, use,
|
|
10
|
+
import { createContext, use, useReducer } from 'react'
|
|
11
11
|
|
|
12
12
|
const Pagex = createContext()
|
|
13
13
|
|
|
@@ -158,24 +158,11 @@ const reducerLogger = (state, action) => {
|
|
|
158
158
|
|
|
159
159
|
function useCx() {
|
|
160
160
|
const pages = use(Pagex)
|
|
161
|
-
const [icons, setIcons] = useState()
|
|
162
|
-
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
if (!pages?.icons) return
|
|
165
|
-
|
|
166
|
-
fetch(pages?.icons)
|
|
167
|
-
.then((r) => r.text())
|
|
168
|
-
.then((text) => {
|
|
169
|
-
setIcons(
|
|
170
|
-
new DOMParser().parseFromString(text, 'image/svg+xml').documentElement
|
|
171
|
-
)
|
|
172
|
-
})
|
|
173
|
-
}, [pages?.icons])
|
|
174
161
|
|
|
175
162
|
return {
|
|
176
163
|
context: pages?.context,
|
|
177
164
|
i18n: pages?.i18n,
|
|
178
|
-
icons,
|
|
165
|
+
icons: pages?.icons,
|
|
179
166
|
logger: pages?.logger ?? false
|
|
180
167
|
}
|
|
181
168
|
}
|
package/src/index.js
CHANGED
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
import { Pagex, useCx, useFx } from './fx.js'
|
|
11
11
|
import { useQueryString, useResize } from './hooks.js'
|
|
12
12
|
import { I18n, Icon, Link, Svg } from './ui.js'
|
|
13
|
-
import { css,
|
|
13
|
+
import { css, getVersion, startViewTransition } from './utils.js'
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
css,
|
|
17
|
+
getVersion,
|
|
17
18
|
I18n,
|
|
18
19
|
Icon,
|
|
19
20
|
Link,
|
|
@@ -23,6 +24,5 @@ export {
|
|
|
23
24
|
useCx,
|
|
24
25
|
useFx,
|
|
25
26
|
useQueryString,
|
|
26
|
-
useResize
|
|
27
|
-
version
|
|
27
|
+
useResize
|
|
28
28
|
}
|
package/src/ui.js
CHANGED
|
@@ -10,16 +10,6 @@
|
|
|
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
|
-
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)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
function I18n({ value, args = [] }) {
|
|
24
14
|
const { context, i18n } = useCx()
|
|
25
15
|
|
|
@@ -66,7 +56,10 @@ function Icon({
|
|
|
66
56
|
useEffect(() => {
|
|
67
57
|
if (!ref.current || !icons) return
|
|
68
58
|
|
|
69
|
-
const el =
|
|
59
|
+
const el = new DOMParser()
|
|
60
|
+
.parseFromString(icons, 'image/svg+xml')
|
|
61
|
+
.documentElement.getElementById(id)
|
|
62
|
+
|
|
70
63
|
if (el) ref.current.innerHTML = el.innerHTML
|
|
71
64
|
}, [id, icons])
|
|
72
65
|
|
|
@@ -89,6 +82,16 @@ function Icon({
|
|
|
89
82
|
})
|
|
90
83
|
}
|
|
91
84
|
|
|
85
|
+
function Link({ children, href, value, ...props }) {
|
|
86
|
+
const base = href ?? window.location.hash.split('?')[0]
|
|
87
|
+
const query =
|
|
88
|
+
value && Object.keys(value).length
|
|
89
|
+
? `?${new URLSearchParams(value).toString()}`
|
|
90
|
+
: ''
|
|
91
|
+
|
|
92
|
+
return createElement('a', { href: base + query, ...props }, children)
|
|
93
|
+
}
|
|
94
|
+
|
|
92
95
|
function Svg({ ref, src, width, height, ...props }) {
|
|
93
96
|
ref ??= useRef()
|
|
94
97
|
|
package/src/utils.js
CHANGED
|
@@ -7,18 +7,6 @@
|
|
|
7
7
|
* https://github.com/sinuhedev/nextia
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* View Transition
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
async function startViewTransition(fun = () => {}, ref, animation = 'fade') {
|
|
15
|
-
if (!document.startViewTransition) return fun()
|
|
16
|
-
|
|
17
|
-
ref.style.viewTransitionName = animation
|
|
18
|
-
await document.startViewTransition(() => fun).finished
|
|
19
|
-
ref.style.viewTransitionName = ''
|
|
20
|
-
}
|
|
21
|
-
|
|
22
10
|
/**
|
|
23
11
|
* css
|
|
24
12
|
*/
|
|
@@ -46,7 +34,7 @@ function css(...classNames) {
|
|
|
46
34
|
* getVersion
|
|
47
35
|
*/
|
|
48
36
|
|
|
49
|
-
const
|
|
37
|
+
const getVersion = () =>
|
|
50
38
|
Object.fromEntries(
|
|
51
39
|
document
|
|
52
40
|
.querySelector('meta[name="version"]')
|
|
@@ -58,4 +46,16 @@ const version = () =>
|
|
|
58
46
|
}) ?? ''
|
|
59
47
|
)
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
/**
|
|
50
|
+
* View Transition
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
async function startViewTransition(fun = () => {}, ref, animation = 'fade') {
|
|
54
|
+
if (!document.startViewTransition) return fun()
|
|
55
|
+
|
|
56
|
+
ref.style.viewTransitionName = animation
|
|
57
|
+
await document.startViewTransition(() => fun).finished
|
|
58
|
+
ref.style.viewTransitionName = ''
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { css, getVersion, startViewTransition }
|