ywana-core8 0.1.57 → 0.1.59

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -36,7 +36,7 @@
36
36
  "axios": "^1.3.4",
37
37
  "crypto-js": "^4.1.1",
38
38
  "deep-equal": "^2.0.5",
39
- "framer-motion": "^5.6.0",
39
+ "framer-motion": "^5.3.1",
40
40
  "material-design-icons-iconfont": "^6.7.0",
41
41
  "moment": "^2.29.1",
42
42
  "moment-range": "^4.0.2",
package/src/site/link.js CHANGED
@@ -1,55 +1,6 @@
1
- import { useEffect, useState, useRef } from "react"
2
1
  import React, { useContext } from 'react'
3
2
  import { SiteContext } from './siteContext'
4
3
 
5
- /**
6
- * Use Hash Page
7
- */
8
- export function useHashPage(defaultPage = "home") {
9
- const getCurrentPageFromURL = () => {
10
- const hash = window.location.hash.replace("#", "")
11
- return hash || defaultPage
12
- }
13
-
14
- const [page, setPage] = useState(getCurrentPageFromURL())
15
- const [history, setHistory] = useState([])
16
- const isFirstLoad = useRef(true)
17
-
18
- useEffect(() => {
19
- const handleHashChange = () => {
20
- const newPage = getCurrentPageFromURL()
21
- if (!isFirstLoad.current) {
22
- setHistory(prev => [...prev, page]) // Guarda la página anterior
23
- } else {
24
- isFirstLoad.current = false
25
- }
26
- setPage(newPage)
27
- }
28
-
29
- window.addEventListener("hashchange", handleHashChange)
30
- return () => window.removeEventListener("hashchange", handleHashChange)
31
- }, [page])
32
-
33
- const goto = (id) => {
34
- if (page) {
35
- setHistory(prev => [...prev, page])
36
- }
37
- setPage(id)
38
- window.location.hash = id
39
- }
40
-
41
- const goBack = () => {
42
- if (history.length > 0) {
43
- const lastPage = history[history.length - 1]
44
- setHistory(prev => prev.slice(0, -1))
45
- setPage(lastPage)
46
- window.location.hash = lastPage
47
- }
48
- }
49
-
50
- return { page, goto, goBack, history }
51
- }
52
-
53
4
  /**
54
5
  * PageLink - Navegación declarativa usando el sistema de hash
55
6
  *
@@ -50,5 +50,5 @@ export function useHashPage(defaultPage = "home") {
50
50
  }
51
51
  }
52
52
 
53
- return { page, goto, goBack, history }
53
+ return { page, goto, goBack, history, direction }
54
54
  }
package/src/site/site.js CHANGED
@@ -6,10 +6,9 @@ import { Tooltip } from '../html/tooltip'
6
6
  import { Page } from './page'
7
7
  import { SiteContext } from './siteContext'
8
8
  import { ReactNotifications, Store } from 'react-notifications-component'
9
- import { useHashPage } from './navigation'
10
- import { AnimatePresence, motion } from 'framer-motion'
11
9
  import 'react-notifications-component/dist/theme.css'
12
10
  import './site.css'
11
+ import { useHashPage } from './navigation'
13
12
 
14
13
  /**
15
14
  * Site Provider
@@ -28,7 +27,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
28
27
  const [preview, setPreview] = useState()
29
28
  const [breadcrumb, setBreadcrumb] = useState()
30
29
 
31
- const { page, goto, goBack } = useHashPage()
30
+ const { page, goto, goBack, direction } = useHashPage()
32
31
 
33
32
  const value = {
34
33
 
@@ -64,6 +63,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
64
63
  page,
65
64
  goto,
66
65
  goBack,
66
+ direction,
67
67
 
68
68
  dialog,
69
69
  openDialog: (dialog) => { setDialog(dialog) },
@@ -254,7 +254,7 @@ const SiteMenu = ({ iconSrc, title, children, min }) => {
254
254
  */
255
255
  const SitePage = ({ children, init }) => {
256
256
  const context = useContext(SiteContext)
257
- const { page, direction } = context
257
+ const { page } = context
258
258
  useEffect(() => {
259
259
  if (init) {
260
260
  context.goto(init)
@@ -262,24 +262,9 @@ const SitePage = ({ children, init }) => {
262
262
  context.goto("EMPTY")
263
263
  }
264
264
  }, [])
265
-
266
- const currentPage = React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)
267
- const xOffset = direction === "left" ? 40 : -40
268
265
  return (
269
- <main className='site-page-container'>
270
- <AnimatePresence exitBeforeEnter>
271
- {currentPage && (
272
- <motion.div
273
- key={page}
274
- initial={{ opacity: 0, x: xOffset }}
275
- animate={{ opacity: 1, x: 0 }}
276
- exit={{ opacity: 0, x: -xOffset }}
277
- transition={{ duration: 0.3 }}
278
- >
279
- {currentPage}
280
- </motion.div>
281
- )}
282
- </AnimatePresence>
266
+ <main>
267
+ {React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)}
283
268
  </main>
284
269
  )
285
270
  }