nextia 7.0.0 → 7.0.3

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 (77) hide show
  1. package/package.json +9 -13
  2. package/src/bin.js +4 -62
  3. package/src/{lib.js → lib/fx.js} +16 -31
  4. package/src/lib/index.js +32 -0
  5. package/src/lib/ui.js +121 -0
  6. package/src/lib/utils.js +107 -0
  7. package/template/README.md +0 -29
  8. package/template/_env.dev +0 -4
  9. package/template/_env.prod +0 -1
  10. package/template/_env.test +0 -1
  11. package/template/_gitignore +0 -10
  12. package/template/package.json +0 -35
  13. package/template/public/error.html +0 -14
  14. package/template/public/logo.svg +0 -105
  15. package/template/src/assets/i18n/index.js +0 -26
  16. package/template/src/assets/img/image.jpg +0 -0
  17. package/template/src/components/Counter/index.jsx +0 -34
  18. package/template/src/components/Counter/style.css +0 -5
  19. package/template/src/components/Message/index.jsx +0 -12
  20. package/template/src/components/index.js +0 -10
  21. package/template/src/components/ui/I18n/index.jsx +0 -23
  22. package/template/src/components/ui/Icon/index.jsx +0 -50
  23. package/template/src/components/ui/Link/index.jsx +0 -12
  24. package/template/src/components/ui/Svg/index.jsx +0 -54
  25. package/template/src/components/ui/Translate/index.jsx +0 -18
  26. package/template/src/index.html +0 -18
  27. package/template/src/index.jsx +0 -4
  28. package/template/src/pages/counter/functions.js +0 -6
  29. package/template/src/pages/counter/index.jsx +0 -51
  30. package/template/src/pages/counter/style.css +0 -2
  31. package/template/src/pages/env/functions.js +0 -3
  32. package/template/src/pages/env/index.jsx +0 -27
  33. package/template/src/pages/env/style.css +0 -2
  34. package/template/src/pages/functions.js +0 -37
  35. package/template/src/pages/home/functions.js +0 -43
  36. package/template/src/pages/home/index.jsx +0 -211
  37. package/template/src/pages/home/style.css +0 -51
  38. package/template/src/pages/http/not-found/index.jsx +0 -10
  39. package/template/src/pages/http/not-found/style.css +0 -2
  40. package/template/src/pages/icons/functions.js +0 -3
  41. package/template/src/pages/icons/index.jsx +0 -20
  42. package/template/src/pages/icons/style.css +0 -5
  43. package/template/src/pages/images/functions.js +0 -3
  44. package/template/src/pages/images/index.jsx +0 -20
  45. package/template/src/pages/images/style.css +0 -8
  46. package/template/src/pages/index.jsx +0 -114
  47. package/template/src/pages/mockapi/functions.js +0 -71
  48. package/template/src/pages/mockapi/index.jsx +0 -101
  49. package/template/src/pages/mockapi/style.css +0 -57
  50. package/template/src/pages/my-context/functions.js +0 -7
  51. package/template/src/pages/my-context/index.jsx +0 -32
  52. package/template/src/pages/my-context/style.css +0 -2
  53. package/template/src/pages/resize/functions.js +0 -3
  54. package/template/src/pages/resize/index.jsx +0 -15
  55. package/template/src/pages/resize/style.css +0 -2
  56. package/template/src/pages/search-params/functions.js +0 -3
  57. package/template/src/pages/search-params/index.jsx +0 -36
  58. package/template/src/pages/search-params/style.css +0 -2
  59. package/template/src/pages/subpage/hello/functions.js +0 -3
  60. package/template/src/pages/subpage/hello/index.jsx +0 -11
  61. package/template/src/pages/subpage/hello/style.css +0 -2
  62. package/template/src/pages/translate/functions.js +0 -5
  63. package/template/src/pages/translate/index.jsx +0 -31
  64. package/template/src/pages/translate/style.css +0 -12
  65. package/template/src/services/api.js +0 -9
  66. package/template/src/services/http.js +0 -40
  67. package/template/src/theme/animations.css +0 -72
  68. package/template/src/theme/fonts/Roboto-Regular.ttf +0 -0
  69. package/template/src/theme/fonts/index.css +0 -7
  70. package/template/src/theme/icons/exit.svg +0 -69
  71. package/template/src/theme/icons/icons.svg +0 -126
  72. package/template/src/theme/index.css +0 -39
  73. package/template/src/theme/util.css +0 -27
  74. package/template/src/utils/hooks.js +0 -49
  75. package/template/src/utils/index.js +0 -19
  76. package/template/test/index.test.js +0 -12
  77. package/template/vite.config.js +0 -97
@@ -1,211 +0,0 @@
1
- import { useEffect } from 'react'
2
- import './style.css'
3
- import { css, useFx } from 'nextia'
4
- import { sum } from 'utils'
5
- import functions from './functions'
6
-
7
- export default function HomePage() {
8
- const { state, initialState, fx, context } = useFx(functions)
9
-
10
- useEffect(() => {
11
- console.info(sum(10, 10))
12
- }, [])
13
-
14
- return (
15
- <section className={css('HomePage', 'container')}>
16
- <div>
17
- <div>
18
- <p>set</p>
19
- <button
20
- type="button"
21
- className=""
22
- onClick={() => fx.set({ setNameValue: 'set 1 level' })}
23
- >
24
- set Value
25
- </button>
26
- <button
27
- type="button"
28
- onClick={() =>
29
- fx.set({
30
- form: {
31
- name: {
32
- firstName: 'ppppppppppp',
33
- lastName: '***********'
34
- }
35
- }
36
- })
37
- }
38
- >
39
- set Json
40
- </button>
41
- </div>
42
-
43
- <div>
44
- <button
45
- type="button"
46
- onClick={() => fx.set({ 'form.name.lastName': 'BOUCHAN' })}
47
- >
48
- set mulit level (Value)
49
- </button>
50
-
51
- <button
52
- type="button"
53
- onClick={() =>
54
- fx.set({
55
- 'form.name': { firstName: 'SINUHE', lastName: 'MACEDA' }
56
- })
57
- }
58
- >
59
- set mulit level (Json)
60
- </button>
61
- </div>
62
-
63
- <div>
64
- <p>Show and Hide :</p>
65
- <button type="button" onClick={() => fx.show('form.funny')}>
66
- show
67
- </button>
68
- <button type="button" onClick={() => fx.hide('form.funny')}>
69
- hide
70
- </button>
71
- </div>
72
-
73
- <div>
74
- <p>Reset :</p>
75
- <button type="button" onClick={() => fx.reset('ls')}>
76
- Reset (ls)
77
- </button>
78
- <button type="button" onClick={() => fx.reset('form.name')}>
79
- Reset (form.name)
80
- </button>
81
- <button
82
- type="button"
83
- onClick={() => fx.reset(['channel', 'msg', 'form.name'])}
84
- >
85
- Reset ([channel,msg,form.name])
86
- </button>
87
- </div>
88
-
89
- <div>
90
- <p>Simple actions/Reducer:</p>
91
- <button type="button" onClick={(e) => fx.increment(e)}>
92
- +
93
- </button>
94
- <button type="button" onClick={(e) => fx.decrement(e)}>
95
- -
96
- </button>
97
-
98
- <button
99
- type="button"
100
- onClick={() =>
101
- fx.set({
102
- channel: 256,
103
- msg: 256,
104
- data: { user: 256 },
105
- myArray: ['256', '256', '256'],
106
- setNameValue: '256',
107
- form: {
108
- // funny: 256,
109
- // gender: '256',
110
- name: {
111
- firstName: '256',
112
- lastName: '256'
113
- },
114
- year: 256,
115
- moreArray: [[[256, 256, 256]]]
116
- },
117
- ls: {
118
- users: [
119
- {
120
- name: '256',
121
- year: 256
122
- },
123
- {
124
- name: '256',
125
- year: 256
126
- }
127
- ]
128
- }
129
- })
130
- }
131
- >
132
- 256
133
- </button>
134
- </div>
135
-
136
- <div>
137
- <p>onChange:</p>
138
-
139
- {/* input text */}
140
- <input
141
- type="text"
142
- name="form.name.firstName"
143
- value={state.form.name.firstName}
144
- onChange={(evt) => fx.change(evt)}
145
- />
146
-
147
- {/* checkbox */}
148
- <input
149
- type="checkbox"
150
- name="form.funny"
151
- checked={state.form.funny}
152
- onChange={(evt) => fx.change(evt)}
153
- />
154
- <label htmlFor="form.funny">Funny</label>
155
-
156
- {/* radio */}
157
- <input
158
- type="radio"
159
- name="form.gender"
160
- value="M"
161
- checked={state.form.gender === 'M'}
162
- onChange={(evt) => fx.change(evt)}
163
- />
164
- <label htmlFor="M">M</label>
165
- <input
166
- type="radio"
167
- name="form.gender"
168
- value="F"
169
- checked={state.form.gender === 'F'}
170
- onChange={(evt) => fx.change(evt)}
171
- />
172
- <label htmlFor="F">F</label>
173
-
174
- {/* select */}
175
- <select name="form.year" onChange={(evt) => fx.change(evt)}>
176
- <option value="20">20</option>
177
- <option value="21">21</option>
178
- <option value="22">22</option>
179
- <option value="33">33</option>
180
- </select>
181
- </div>
182
- </div>
183
-
184
- <div>
185
- <div style={{ textAlign: 'center' }}>
186
- <button type="button" onClick={() => fx.reset()}>
187
- RESET
188
- </button>
189
- <button
190
- type="button"
191
- onClick={() => {
192
- if (context.state.loading) context.fx.hide('loading')
193
- else context.fx.show('loading')
194
- }}
195
- >
196
- loading
197
- </button>
198
- </div>
199
-
200
- <div style={{ display: 'flex' }}>
201
- <pre style={{ margin: '0 50px 0 50px' }}>
202
- state = {JSON.stringify(state, undefined, 2)}
203
- </pre>
204
- <pre style={{ margin: '0 50px 0 50px' }}>
205
- initialState = {JSON.stringify(initialState, undefined, 2)}
206
- </pre>
207
- </div>
208
- </div>
209
- </section>
210
- )
211
- }
@@ -1,51 +0,0 @@
1
- .HomePage {
2
- background-color: #21252b;
3
-
4
- &.container {
5
- display: flex;
6
- }
7
-
8
- p {
9
- padding-left: 25px;
10
- margin: 0px;
11
- }
12
-
13
- pre {
14
- color: gray;
15
- font-size: 12px;
16
- max-height: 700px;
17
- overflow: auto;
18
- }
19
-
20
- button {
21
- margin: 12px;
22
- height: 50px;
23
- width: 200px;
24
- }
25
-
26
- input[type="text"] {
27
- margin: 20px;
28
- height: 30px;
29
- width: 180px;
30
- }
31
-
32
- input[type="checkbox"] {
33
- height: 30px;
34
- width: 30px;
35
- }
36
-
37
- input[type="radio"] {
38
- height: 30px;
39
- width: 30px;
40
- }
41
-
42
- select {
43
- margin-left: 40px;
44
- height: 30px;
45
- width: 180px;
46
- }
47
-
48
- .my-css {
49
- font-size: 20px;
50
- }
51
- }
@@ -1,10 +0,0 @@
1
- import { css } from 'nextia'
2
- import './style.css'
3
-
4
- export default function HttpNotFoundPage() {
5
- return (
6
- <section className={css('HttpNotFoundPage')}>
7
- <h5>Not Found</h5>
8
- </section>
9
- )
10
- }
@@ -1,2 +0,0 @@
1
- .HttpNotFoundPage {
2
- }
@@ -1,3 +0,0 @@
1
- const initialState = {}
2
-
3
- export default { initialState }
@@ -1,20 +0,0 @@
1
- import { Icon, Svg } from 'components'
2
- import { css, useFx } from 'nextia'
3
- import functions from './functions'
4
- import './style.css'
5
- import exitSvg from 'theme/icons/exit.svg?raw'
6
-
7
- export default function IconsPage() {
8
- const { state, fx } = useFx(functions)
9
-
10
- return (
11
- <section className={css('IconsPage', '')}>
12
- <Icon id="globe" width="32" />
13
- <Icon id="camera" width="32" />
14
- <Icon id="video" width="32" />
15
- <br />
16
- <br />
17
- <Svg src={exitSvg} width="32" />
18
- </section>
19
- )
20
- }
@@ -1,5 +0,0 @@
1
- .IconsPage {
2
- svg {
3
- margin-right: 10px;
4
- }
5
- }
@@ -1,3 +0,0 @@
1
- const initialState = {}
2
-
3
- export default { initialState }
@@ -1,20 +0,0 @@
1
- import image from 'assets/img/image.jpg'
2
- import { css, useFx } from 'nextia'
3
- import functions from './functions'
4
- import './style.css'
5
-
6
- export default function ImagesPage() {
7
- const { state, fx } = useFx(functions)
8
-
9
- return (
10
- <section className={css('ImagesPage', '')}>
11
- <br />
12
- <p>css-img</p>
13
- <div className="css-img" />
14
-
15
- <br />
16
- <p>img</p>
17
- <img src={image} alt="img" height={200} />
18
- </section>
19
- )
20
- }
@@ -1,8 +0,0 @@
1
- .ImagesPage {
2
- .css-img {
3
- background: url("assets/img/image.jpg") no-repeat;
4
- height: 200px;
5
- background-repeat: no-repeat;
6
- background-size: contain;
7
- }
8
- }
@@ -1,114 +0,0 @@
1
- import { I18n, Icon, Link, Translate } from 'components'
2
- import { PagesContext, useFx } from 'nextia'
3
- import { lazy, useEffect, useRef, useState } from 'react'
4
- import { startViewTransition, useQueryString, useResize } from 'utils'
5
- import functions from './functions.js'
6
-
7
- export default function Pages() {
8
- const pagesContext = useFx(functions)
9
- const { state, fx } = pagesContext
10
-
11
- const [Page, setPage] = useState()
12
- const qs = useQueryString()
13
- const resize = useResize()
14
- const ref = useRef()
15
-
16
- useEffect(() => {
17
- const hash = ['', '#/'].includes(qs.hash) ? '#/home' : qs.hash
18
-
19
- const page = lazy(async () => {
20
- const path = hash.substring(2).split('/')
21
-
22
- try {
23
- if (path.length === 1) {
24
- return await import(`./${path[0]}/index.jsx`)
25
- } else if (path.length === 2) {
26
- return await import(`./${path[0]}/${path[1]}/index.jsx`)
27
- }
28
- } catch (e) {
29
- console.error(e)
30
- return await import('./http/not-found/index.jsx')
31
- }
32
- })
33
-
34
- startViewTransition(setPage(page), ref.current)
35
- }, [qs.hash])
36
-
37
- return (
38
- <PagesContext value={pagesContext}>
39
- <header style={{ display: 'flex', gap: '20px' }}>
40
- <Icon id="globe" width="24" />
41
-
42
- <Translate value={state.i18n} onChange={fx.changeI18n} />
43
-
44
- <I18n value="page.name" args={['Sinuhe', 'Maceda', 'Bouchan']} />
45
-
46
- <button type="button" onClick={(e) => fx.increment(e)}>
47
- increment
48
- </button>
49
- {' '}
50
- <button type="button" onClick={(e) => fx.decrement(e)}>
51
- decrement
52
- </button>
53
- {' '}
54
- <button type="button" onClick={() => fx.zero({ value: 0 })}>
55
- zero
56
- </button>
57
- {' '}
58
- {state.num}
59
- {' '}
60
- {state.loading ? <span> Loading... </span> : <span> View.. </span>}
61
- </header>
62
-
63
- <aside className="m-2">
64
- <Link href="/" className="mr-2">
65
- /
66
- </Link>
67
- <Link href="#/" className="mr-2">
68
- /home
69
- </Link>
70
- <Link href="#/env" className="mr-2">
71
- /env
72
- </Link>
73
- <Link href="#/my-context" className="mr-2">
74
- /my-context
75
- </Link>
76
- <Link href="#/mockapi" className="mr-2">
77
- /mockapi
78
- </Link>
79
- <Link
80
- href="#/search-params"
81
- value={{ id: 1, user: 'Sinuhe' }}
82
- className="mr-2"
83
- >
84
- /search-params
85
- </Link>
86
- <Link href="#/subpage/hello" className="mr-2">
87
- /subpage/hello
88
- </Link>
89
- <Link href="#/translate" className="mr-2">
90
- /translate
91
- </Link>
92
- <Link href="#/counter" className="mr-2">
93
- /counter
94
- </Link>
95
- <Link href="#/images" className="mr-2">
96
- /images
97
- </Link>
98
- <Link href="#/icons" className="mr-2">
99
- /icons
100
- </Link>
101
- <Link href="#/resize" className="mr-2">
102
- /resize
103
- </Link>
104
- <Link href="#/no" className="mr-2">
105
- /no
106
- </Link>
107
- </aside>
108
-
109
- <main ref={ref} className="m-2">
110
- {Page && <Page qs={qs.queryString} resize={resize} />}
111
- </main>
112
- </PagesContext>
113
- )
114
- }
@@ -1,71 +0,0 @@
1
- import { createUser, deleteUser, getUser, updateUser } from 'services/api'
2
-
3
- const initialState = {
4
- users: {},
5
- user: {},
6
- form: {
7
- id: 0,
8
- name: ''
9
- }
10
- }
11
-
12
- async function handlerUser({ payload, set }) {
13
- try {
14
- const { data } = await getUser({ path: { id: payload } })
15
- set({ users: data, user: {} })
16
- } catch (e) {
17
- console.error(e)
18
- }
19
- }
20
-
21
- async function handlerCreateUser({ state, set }) {
22
- try {
23
- const { data } = await createUser({
24
- body: {
25
- username: state.form.name,
26
- profile: {
27
- firstName: state.form.name,
28
- lastName: state.form.name
29
- }
30
- }
31
- })
32
- set({ users: {}, user: data })
33
- } catch (e) {
34
- console.error(e)
35
- }
36
- }
37
-
38
- async function handlerUpdateUser({ payload, state, set }) {
39
- try {
40
- const { data } = await updateUser({
41
- path: { id: payload },
42
- body: {
43
- username: state.form.name,
44
- profile: {
45
- firstName: state.form.name,
46
- lastName: state.form.name
47
- }
48
- }
49
- })
50
- set({ users: {}, user: data })
51
- } catch (e) {
52
- console.error(e)
53
- }
54
- }
55
-
56
- async function handlerDeleteUser({ payload }) {
57
- try {
58
- const { data } = await deleteUser({ path: { id: payload } })
59
- console.info(data)
60
- } catch (e) {
61
- console.error(e)
62
- }
63
- }
64
-
65
- export default {
66
- initialState,
67
- handlerUser,
68
- handlerCreateUser,
69
- handlerUpdateUser,
70
- handlerDeleteUser
71
- }
@@ -1,101 +0,0 @@
1
- import { css, useFx } from 'nextia'
2
- import functions from './functions'
3
- import './style.css'
4
-
5
- export default function MockapiPage() {
6
- const { initialState, state, fx } = useFx(functions)
7
-
8
- return (
9
- <section className={css('MockapiPage', 'container')}>
10
- <div>
11
- <button type="button" onClick={() => fx.reset(['users', 'user'])}>
12
- Reset
13
- </button>
14
-
15
- <button
16
- type="button"
17
- onClick={() => {
18
- fx.reset(['users', 'user'])
19
- fx.handlerUser()
20
- }}
21
- >
22
- Get users
23
- </button>
24
-
25
- <button
26
- type="button"
27
- onClick={() => {
28
- fx.reset(['users', 'user'])
29
- fx.handlerUser(state.form.id)
30
- }}
31
- >
32
- Get user
33
- </button>
34
-
35
- <button
36
- type="button"
37
- onClick={() => {
38
- fx.reset(['users', 'user'])
39
- fx.handlerCreateUser()
40
- }}
41
- >
42
- Create user
43
- </button>
44
-
45
- <button
46
- type="button"
47
- onClick={() => {
48
- fx.reset(['users', 'user'])
49
- fx.handlerUpdateUser(state.form.id)
50
- }}
51
- >
52
- Update user
53
- </button>
54
-
55
- <button
56
- type="button"
57
- onClick={() => {
58
- fx.reset(['users', 'user'])
59
- fx.handlerDeleteUser(state.form.id)
60
- }}
61
- >
62
- Delete user
63
- </button>
64
- </div>
65
-
66
- <div>
67
- <h1>MockapiPage</h1>
68
-
69
- <div>
70
- id:{' '}
71
- <input
72
- type="text"
73
- name="form.id"
74
- value={state.form.id}
75
- onChange={(evt) => fx.change(evt)}
76
- />
77
- </div>
78
- <div>
79
- name:{' '}
80
- <input
81
- type="text"
82
- name="form.name"
83
- value={state.form.name}
84
- onChange={(evt) => fx.change(evt)}
85
- />
86
- </div>
87
- </div>
88
-
89
- <section>
90
- <article style={{ display: 'flex' }}>
91
- <pre style={{ margin: '0 50px 0 50px', width: '250px' }}>
92
- state = {JSON.stringify(state, undefined, 2)}
93
- </pre>
94
- <pre style={{ margin: '0 5px 0 5px', width: '250px' }}>
95
- initialState = {JSON.stringify(initialState, undefined, 2)}
96
- </pre>
97
- </article>
98
- </section>
99
- </section>
100
- )
101
- }
@@ -1,57 +0,0 @@
1
- .MockapiPage {
2
- background-color: #21252b;
3
-
4
- &.container {
5
- display: flex;
6
- gap: 20px;
7
- padding: 20px;
8
-
9
- div {
10
- width: 300px;
11
- }
12
- }
13
-
14
- p {
15
- padding-left: 25px;
16
- margin: 0px;
17
- }
18
-
19
- pre {
20
- color: gray;
21
- font-size: 12px;
22
- max-height: 700px;
23
- overflow: auto;
24
- }
25
-
26
- button {
27
- margin: 10px;
28
- height: 50px;
29
- width: 180px;
30
- }
31
-
32
- input[type="text"] {
33
- margin: 20px;
34
- height: 30px;
35
- width: 180px;
36
- }
37
-
38
- input[type="checkbox"] {
39
- height: 30px;
40
- width: 30px;
41
- }
42
-
43
- input[type="radio"] {
44
- height: 30px;
45
- width: 30px;
46
- }
47
-
48
- select {
49
- margin-left: 40px;
50
- height: 30px;
51
- width: 180px;
52
- }
53
-
54
- .my-css {
55
- font-size: 20px;
56
- }
57
- }
@@ -1,7 +0,0 @@
1
- const initialState = {}
2
-
3
- function init({ context }) {
4
- context.fx.set({ num: 300 })
5
- }
6
-
7
- export default { initialState, init }