nextia 8.0.6 → 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/README.md +1 -1
- package/package.json +4 -21
- package/src/{lib/ui.js → ui.js} +23 -20
- package/src/bin.js +0 -122
- /package/src/{lib/fx.js → fx.js} +0 -0
- /package/src/{lib/hooks.js → hooks.js} +0 -0
- /package/src/{lib/index.js → index.js} +0 -0
- /package/src/{lib/utils.js → utils.js} +0 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextia",
|
|
3
3
|
"description": "Create fast web applications",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "9.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -20,29 +20,12 @@
|
|
|
20
20
|
"keywords": [
|
|
21
21
|
"react"
|
|
22
22
|
],
|
|
23
|
-
"bin": {
|
|
24
|
-
"nextia": "src/bin.js"
|
|
25
|
-
},
|
|
26
23
|
"exports": {
|
|
27
|
-
".": "./src/
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"clean": "rm -fr node_modules .coverage out package-lock.json",
|
|
31
|
-
"format": "biome format",
|
|
32
|
-
"lint": "biome lint src",
|
|
33
|
-
"check": "biome check --reporter=summary src",
|
|
34
|
-
"test": "vitest run",
|
|
35
|
-
"test:name": "vitest run --testNamePattern",
|
|
36
|
-
"test:silent": "vitest run --silent",
|
|
37
|
-
"test:coverage": "vitest run --silent --coverage"
|
|
24
|
+
".": "./src/index.js"
|
|
38
25
|
},
|
|
26
|
+
"scripts": {},
|
|
39
27
|
"peerDependencies": {
|
|
40
28
|
"react": "^19.0.0"
|
|
41
29
|
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@vitejs/plugin-react": "6.0.2",
|
|
44
|
-
"@vitest/coverage-v8": "4.1.6",
|
|
45
|
-
"jsdom": "29.1.1",
|
|
46
|
-
"vitest": "4.1.6"
|
|
47
|
-
}
|
|
30
|
+
"devDependencies": {}
|
|
48
31
|
}
|
package/src/{lib/ui.js → ui.js}
RENAMED
|
@@ -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', {
|
package/src/bin.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) 2025 Sinuhe Maceda https://sinuhe.dev
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* https://github.com/sinuhedev/nextia
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { mkdir, writeFile } from 'node:fs/promises'
|
|
13
|
-
|
|
14
|
-
function toPascalCase(str) {
|
|
15
|
-
return str
|
|
16
|
-
.toLowerCase()
|
|
17
|
-
.replace(/[^a-zA-Z0-9 ]/g, ' ') // replace special characters
|
|
18
|
-
.split(/\s+/) // split by spaces
|
|
19
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
20
|
-
.join('')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function createPage(name) {
|
|
24
|
-
const dirName = `./src/pages/${name}`
|
|
25
|
-
const pageName = `${toPascalCase(name)}Page`
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
await mkdir(dirName)
|
|
29
|
-
|
|
30
|
-
// index.jsx
|
|
31
|
-
writeFile(
|
|
32
|
-
`${dirName}/index.jsx`,
|
|
33
|
-
`import useFunctions from './functions'
|
|
34
|
-
|
|
35
|
-
export default function ${pageName}() {
|
|
36
|
-
const { state, fx } = useFunctions()
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<section>
|
|
40
|
-
${pageName}
|
|
41
|
-
</section>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
// function.js
|
|
48
|
-
writeFile(
|
|
49
|
-
`${dirName}/functions.js`,
|
|
50
|
-
`import { useFx } from 'nextia'
|
|
51
|
-
|
|
52
|
-
export default () => {
|
|
53
|
-
const initialState = {}
|
|
54
|
-
|
|
55
|
-
return useFx({
|
|
56
|
-
initialState
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
`
|
|
60
|
-
)
|
|
61
|
-
console.info(`✔ Page "${pageName}" created at ${dirName}`)
|
|
62
|
-
} catch (err) {
|
|
63
|
-
console.error(`Failed to create page: ${err.message}`)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function createComponent(name) {
|
|
68
|
-
const dirName = `./src/components/${name}`
|
|
69
|
-
const componentName = toPascalCase(name)
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
await mkdir(dirName)
|
|
73
|
-
|
|
74
|
-
// index.jsx
|
|
75
|
-
writeFile(
|
|
76
|
-
`${dirName}/index.jsx`,
|
|
77
|
-
`import { css } from 'nextia'
|
|
78
|
-
import './style.css'
|
|
79
|
-
|
|
80
|
-
export default function ${componentName}({ className, style }) {
|
|
81
|
-
return (
|
|
82
|
-
<article className={css('${componentName}', className)} style={style}>
|
|
83
|
-
${componentName}
|
|
84
|
-
</article>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
`
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
// style.css
|
|
91
|
-
writeFile(
|
|
92
|
-
`${dirName}/style.css`,
|
|
93
|
-
`.${componentName} {
|
|
94
|
-
}
|
|
95
|
-
`
|
|
96
|
-
)
|
|
97
|
-
console.info(`✔ Component "${name}" created at ${dirName}`)
|
|
98
|
-
} catch (err) {
|
|
99
|
-
console.error(`Failed to create component: ${err.message}`)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function main() {
|
|
104
|
-
const ARG1 = process.argv[2]
|
|
105
|
-
const ARG2 = process.argv[3]
|
|
106
|
-
|
|
107
|
-
switch (ARG1) {
|
|
108
|
-
case 'page':
|
|
109
|
-
if (ARG2) await createPage(ARG2)
|
|
110
|
-
else console.warn('node --run page -- <page-name>')
|
|
111
|
-
break
|
|
112
|
-
|
|
113
|
-
case 'component':
|
|
114
|
-
if (ARG2) await createComponent(ARG2)
|
|
115
|
-
else console.warn('node --run component -- <ComponentName>')
|
|
116
|
-
break
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
main().catch((e) => {
|
|
121
|
-
console.error(e)
|
|
122
|
-
})
|
/package/src/{lib/fx.js → fx.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|