ywana-core8 0.1.48 → 0.1.49
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/dist/index.cjs +71 -30
 - package/dist/index.cjs.map +1 -1
 - package/dist/index.modern.js +73 -32
 - package/dist/index.modern.js.map +1 -1
 - package/dist/index.umd.js +71 -30
 - package/dist/index.umd.js.map +1 -1
 - package/package.json +1 -1
 - package/src/site/index.js +1 -1
 - package/src/site/site.js +20 -20
 - package/src/site/site2.js +0 -338
 
    
        package/package.json
    CHANGED
    
    
    
        package/src/site/index.js
    CHANGED
    
    
    
        package/src/site/site.js
    CHANGED
    
    | 
         @@ -25,25 +25,25 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => { 
     | 
|
| 
       25 
25 
     | 
    
         
             
                const [promptDialog, setPromptDialog] = useState()
         
     | 
| 
       26 
26 
     | 
    
         
             
                const [preview, setPreview] = useState()
         
     | 
| 
       27 
27 
     | 
    
         
             
                const [breadcrumb, setBreadcrumb] = useState()
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                const [history, setHistory] = useState([])
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                // 📌 Extraer la página actual desde la URL (por defecto "home")
         
     | 
| 
      
 31 
     | 
    
         
            +
                const getCurrentPageFromURL = () => {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    const path = window.location.pathname.replace("/", "")
         
     | 
| 
      
 33 
     | 
    
         
            +
                    return path || "home"
         
     | 
| 
      
 34 
     | 
    
         
            +
                }
         
     | 
| 
      
 35 
     | 
    
         
            +
                const [page, setPage] = useState(getCurrentPageFromURL())
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                useEffect(() => {
         
     | 
| 
      
 38 
     | 
    
         
            +
                    // 📌 Detectar cambios en la URL cuando el usuario presiona "Atrás" o "Adelante"
         
     | 
| 
      
 39 
     | 
    
         
            +
                    const handlePopState = (event) => {
         
     | 
| 
      
 40 
     | 
    
         
            +
                        const previousPage = event.state?.page || "home"
         
     | 
| 
      
 41 
     | 
    
         
            +
                        setPage(previousPage)
         
     | 
| 
       34 
42 
     | 
    
         
             
                    }
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                            const handlePopState = (event) => {
         
     | 
| 
       40 
     | 
    
         
            -
                                const previousPage = event.state?.page || "home"
         
     | 
| 
       41 
     | 
    
         
            -
                                setPage(previousPage)
         
     | 
| 
       42 
     | 
    
         
            -
                            }
         
     | 
| 
       43 
     | 
    
         
            -
                    
         
     | 
| 
       44 
     | 
    
         
            -
                            window.addEventListener("popstate", handlePopState)
         
     | 
| 
       45 
     | 
    
         
            -
                            return () => window.removeEventListener("popstate", handlePopState)
         
     | 
| 
       46 
     | 
    
         
            -
                        }, [])
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    window.addEventListener("popstate", handlePopState)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    return () => window.removeEventListener("popstate", handlePopState)
         
     | 
| 
      
 46 
     | 
    
         
            +
                }, [])
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                const value = {
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
         @@ -61,7 +61,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => { 
     | 
|
| 
       61 
61 
     | 
    
         
             
                        return term ? term[lang] : key
         
     | 
| 
       62 
62 
     | 
    
         
             
                    },
         
     | 
| 
       63 
63 
     | 
    
         
             
                    */
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
       65 
65 
     | 
    
         
             
                    sideNav,
         
     | 
| 
       66 
66 
     | 
    
         
             
                    setSideNav,
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
         @@ -136,7 +136,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => { 
     | 
|
| 
       136 
136 
     | 
    
         | 
| 
       137 
137 
     | 
    
         
             
                return (
         
     | 
| 
       138 
138 
     | 
    
         
             
                    <SiteContext.Provider value={value}>
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 139 
     | 
    
         
            +
                        {children}
         
     | 
| 
       140 
140 
     | 
    
         
             
                    </SiteContext.Provider>
         
     | 
| 
       141 
141 
     | 
    
         
             
                )
         
     | 
| 
       142 
142 
     | 
    
         
             
            }
         
     | 
    
        package/src/site/site2.js
    DELETED
    
    | 
         @@ -1,338 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import React, { Children, Fragment, useState, useContext, useEffect, useCallback, useMemo } from 'react'
         
     | 
| 
       2 
     | 
    
         
            -
            import { Header } from './header'
         
     | 
| 
       3 
     | 
    
         
            -
            import { Icon } from '../html/icon'
         
     | 
| 
       4 
     | 
    
         
            -
            import { Page } from './page'
         
     | 
| 
       5 
     | 
    
         
            -
            import { ConfirmDialog } from './dialog'
         
     | 
| 
       6 
     | 
    
         
            -
            import './site.css'
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            /**
         
     | 
| 
       9 
     | 
    
         
            -
             * Site Context
         
     | 
| 
       10 
     | 
    
         
            -
             */
         
     | 
| 
       11 
     | 
    
         
            -
            export const SiteContext = React.createContext({})
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            /**
         
     | 
| 
       14 
     | 
    
         
            -
             * Site Provider
         
     | 
| 
       15 
     | 
    
         
            -
             */
         
     | 
| 
       16 
     | 
    
         
            -
            export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                const [lang, setLang] = useState(siteLang)
         
     | 
| 
       19 
     | 
    
         
            -
                const [dictionary, setDictionary] = useState(siteDictionary)
         
     | 
| 
       20 
     | 
    
         
            -
                const [sideNav, setSideNav] = useState('max')
         
     | 
| 
       21 
     | 
    
         
            -
                const [showNav, setShowNav] = useState(false)
         
     | 
| 
       22 
     | 
    
         
            -
                const [info, setInfo] = useState(true)
         
     | 
| 
       23 
     | 
    
         
            -
                const [showConsole, setShowConsole] = useState(false)
         
     | 
| 
       24 
     | 
    
         
            -
                const [consoleLines, setConsoleLines] = useState([])
         
     | 
| 
       25 
     | 
    
         
            -
                const [dialog, setDialog] = useState()
         
     | 
| 
       26 
     | 
    
         
            -
                const [promptDialog, setPromptDialog] = useState()
         
     | 
| 
       27 
     | 
    
         
            -
                const [preview, setPreview] = useState()
         
     | 
| 
       28 
     | 
    
         
            -
                const [breadcrumb, setBreadcrumb] = useState()
         
     | 
| 
       29 
     | 
    
         
            -
                const [history, setHistory] = useState([])
         
     | 
| 
       30 
     | 
    
         
            -
                
         
     | 
| 
       31 
     | 
    
         
            -
                // 📌 Extraer la página actual desde la URL (por defecto "home")
         
     | 
| 
       32 
     | 
    
         
            -
                const getCurrentPageFromURL = () => {
         
     | 
| 
       33 
     | 
    
         
            -
                    const path = window.location.pathname.replace("/", "")
         
     | 
| 
       34 
     | 
    
         
            -
                    return path || "home"
         
     | 
| 
       35 
     | 
    
         
            -
                }
         
     | 
| 
       36 
     | 
    
         
            -
                const [page, setPage] = useState(getCurrentPageFromURL())
         
     | 
| 
       37 
     | 
    
         
            -
                
         
     | 
| 
       38 
     | 
    
         
            -
                useEffect(() => {
         
     | 
| 
       39 
     | 
    
         
            -
                    // 📌 Detectar cambios en la URL cuando el usuario presiona "Atrás" o "Adelante"
         
     | 
| 
       40 
     | 
    
         
            -
                    const handlePopState = (event) => {
         
     | 
| 
       41 
     | 
    
         
            -
                        const previousPage = event.state?.page || "home"
         
     | 
| 
       42 
     | 
    
         
            -
                        setPage(previousPage)
         
     | 
| 
       43 
     | 
    
         
            -
                    }
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                    window.addEventListener("popstate", handlePopState)
         
     | 
| 
       46 
     | 
    
         
            -
                    return () => window.removeEventListener("popstate", handlePopState)
         
     | 
| 
       47 
     | 
    
         
            -
                }, [])
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                const value = useMemo(() => ({
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                    lang,
         
     | 
| 
       52 
     | 
    
         
            -
                    setLang,
         
     | 
| 
       53 
     | 
    
         
            -
                    dictionary,
         
     | 
| 
       54 
     | 
    
         
            -
                    setDictionary,
         
     | 
| 
       55 
     | 
    
         
            -
                    translate: useCallback((key) => dictionary?.[key]?.[lang] || key, [lang, dictionary]),
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                    sideNav,
         
     | 
| 
       58 
     | 
    
         
            -
                    setSideNav,
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                    showNav,
         
     | 
| 
       61 
     | 
    
         
            -
                    setShowNav,
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                    info,
         
     | 
| 
       64 
     | 
    
         
            -
                    openInfo: (info) => { setInfo(info) },
         
     | 
| 
       65 
     | 
    
         
            -
                    closeInfo: () => { setInfo(null) },
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                    consoleLines,
         
     | 
| 
       68 
     | 
    
         
            -
                    showConsole,
         
     | 
| 
       69 
     | 
    
         
            -
                    toggleConsole: () => { setShowConsole(!showConsole) },
         
     | 
| 
       70 
     | 
    
         
            -
                    writeLog: (line) => {
         
     | 
| 
       71 
     | 
    
         
            -
                        const next = consoleLines.concat(line)
         
     | 
| 
       72 
     | 
    
         
            -
                        setConsoleLines(next)
         
     | 
| 
       73 
     | 
    
         
            -
                    },
         
     | 
| 
       74 
     | 
    
         
            -
                    clearLog: () => { setConsoleLines([]) },
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                    breadcrumb,
         
     | 
| 
       77 
     | 
    
         
            -
                    setBreadcrumb,
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                    page,
         
     | 
| 
       80 
     | 
    
         
            -
                    goto: (id) => {
         
     | 
| 
       81 
     | 
    
         
            -
                        if (page) {
         
     | 
| 
       82 
     | 
    
         
            -
                            setHistory(prev => [...prev, page]) // 🔹 Guarda la página actual en el historial antes de cambiar
         
     | 
| 
       83 
     | 
    
         
            -
                        }
         
     | 
| 
       84 
     | 
    
         
            -
                        setPage(id)
         
     | 
| 
       85 
     | 
    
         
            -
                        window.history.pushState({ page: id }, "", `/${id}`) // 🔹 Actualiza la URL
         
     | 
| 
       86 
     | 
    
         
            -
                    },
         
     | 
| 
       87 
     | 
    
         
            -
                    goBack: () => {
         
     | 
| 
       88 
     | 
    
         
            -
                        if (history.length > 0) {
         
     | 
| 
       89 
     | 
    
         
            -
                            const lastPage = history[history.length - 1]
         
     | 
| 
       90 
     | 
    
         
            -
                            setHistory(prev => prev.slice(0, -1)) // 🔹 Elimina la última entrada del historial
         
     | 
| 
       91 
     | 
    
         
            -
                            setPage(lastPage) // 🔹 Vuelve a la página anterior
         
     | 
| 
       92 
     | 
    
         
            -
                            window.history.back() // 🔹 Regresa en la navegación del navegador
         
     | 
| 
       93 
     | 
    
         
            -
                        }
         
     | 
| 
       94 
     | 
    
         
            -
                    },
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                    dialog,
         
     | 
| 
       97 
     | 
    
         
            -
                    openDialog: (dialog) => { setDialog(dialog) },
         
     | 
| 
       98 
     | 
    
         
            -
                    closeDialog: () => { setDialog(null) },
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                    preview,
         
     | 
| 
       101 
     | 
    
         
            -
                    openPreview: (preview) => { setPreview(preview) },
         
     | 
| 
       102 
     | 
    
         
            -
                    closePreview: () => { setPreview(null) },
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                    confirm: (props) => {
         
     | 
| 
       105 
     | 
    
         
            -
                        setPromptDialog(<ConfirmDialog {...props} />)
         
     | 
| 
       106 
     | 
    
         
            -
                    },
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                    prompt: (message) => window.prompt(message),
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                    promptDialog,
         
     | 
| 
       111 
     | 
    
         
            -
                    openPromptDialog: (dialog) => { setPromptDialog(dialog) },
         
     | 
| 
       112 
     | 
    
         
            -
                    closePromptDialog: () => { setPromptDialog(null) },
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                }), [lang, dictionary, sideNav, showNav, info, consoleLines, showConsole, breadcrumb, page, dialog, promptDialog, preview])
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
                return (
         
     | 
| 
       117 
     | 
    
         
            -
                    <SiteContext.Provider value={value}>
         
     | 
| 
       118 
     | 
    
         
            -
                        {children}
         
     | 
| 
       119 
     | 
    
         
            -
                    </SiteContext.Provider>
         
     | 
| 
       120 
     | 
    
         
            -
                )
         
     | 
| 
       121 
     | 
    
         
            -
            }
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
            /**
         
     | 
| 
       124 
     | 
    
         
            -
             * Site
         
     | 
| 
       125 
     | 
    
         
            -
             */
         
     | 
| 
       126 
     | 
    
         
            -
            export const Site = ({ icon, logo, title, headerBar, asideBar, footer, children, init, min, lang, dictionary }) => {
         
     | 
| 
       127 
     | 
    
         
            -
                return (
         
     | 
| 
       128 
     | 
    
         
            -
                    <SiteErrorBoundary>
         
     | 
| 
       129 
     | 
    
         
            -
                        <SiteProvider siteLang={lang} siteDictionary={dictionary}>
         
     | 
| 
       130 
     | 
    
         
            -
                            <div className="site10">
         
     | 
| 
       131 
     | 
    
         
            -
                                <SiteHeader icon={icon} logo={logo} title={title} >
         
     | 
| 
       132 
     | 
    
         
            -
                                    {headerBar}
         
     | 
| 
       133 
     | 
    
         
            -
                                </SiteHeader>
         
     | 
| 
       134 
     | 
    
         
            -
                                <SiteMenu title={title} min={min} >{children}</SiteMenu>
         
     | 
| 
       135 
     | 
    
         
            -
                                <SitePage init={init}>
         
     | 
| 
       136 
     | 
    
         
            -
                                    {children}
         
     | 
| 
       137 
     | 
    
         
            -
                                    <Page id="EMPTY">EMPTY</Page>
         
     | 
| 
       138 
     | 
    
         
            -
                                </SitePage>
         
     | 
| 
       139 
     | 
    
         
            -
                                <SiteBar>{asideBar}</SiteBar>
         
     | 
| 
       140 
     | 
    
         
            -
                                <SiteAside />
         
     | 
| 
       141 
     | 
    
         
            -
                                <SiteDialog />
         
     | 
| 
       142 
     | 
    
         
            -
                                <SitePromptDialog />
         
     | 
| 
       143 
     | 
    
         
            -
                                <SitePreview />
         
     | 
| 
       144 
     | 
    
         
            -
                                <SiteFooter>{footer}</SiteFooter>
         
     | 
| 
       145 
     | 
    
         
            -
                            </div>
         
     | 
| 
       146 
     | 
    
         
            -
                        </SiteProvider>
         
     | 
| 
       147 
     | 
    
         
            -
                    </SiteErrorBoundary>
         
     | 
| 
       148 
     | 
    
         
            -
                )
         
     | 
| 
       149 
     | 
    
         
            -
            }
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
            /**
         
     | 
| 
       152 
     | 
    
         
            -
             * Site Header
         
     | 
| 
       153 
     | 
    
         
            -
             */
         
     | 
| 
       154 
     | 
    
         
            -
            const SiteHeader = (props) => {
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       157 
     | 
    
         
            -
                const { sideNav, setSideNav } = context
         
     | 
| 
       158 
     | 
    
         
            -
                const { icon = "equalizer", logo, title } = props
         
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
                function toggleMenu() {
         
     | 
| 
       161 
     | 
    
         
            -
                    const next = sideNav === 'max' ? 'min' : 'max'
         
     | 
| 
       162 
     | 
    
         
            -
                    setSideNav(next)
         
     | 
| 
       163 
     | 
    
         
            -
                }
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
                return (
         
     | 
| 
       166 
     | 
    
         
            -
                    <Header icon={icon} iconAction={toggleMenu} logo={logo} title={title} />
         
     | 
| 
       167 
     | 
    
         
            -
                )
         
     | 
| 
       168 
     | 
    
         
            -
            }
         
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
            /**
         
     | 
| 
       171 
     | 
    
         
            -
             * Site Bar
         
     | 
| 
       172 
     | 
    
         
            -
             */
         
     | 
| 
       173 
     | 
    
         
            -
            const SiteBar = ({ children }) => {
         
     | 
| 
       174 
     | 
    
         
            -
                return (
         
     | 
| 
       175 
     | 
    
         
            -
                    <nav>
         
     | 
| 
       176 
     | 
    
         
            -
                        {children}
         
     | 
| 
       177 
     | 
    
         
            -
                    </nav>
         
     | 
| 
       178 
     | 
    
         
            -
                )
         
     | 
| 
       179 
     | 
    
         
            -
            }
         
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
            /**
         
     | 
| 
       182 
     | 
    
         
            -
             * Site Footer
         
     | 
| 
       183 
     | 
    
         
            -
             */
         
     | 
| 
       184 
     | 
    
         
            -
            const SiteFooter = ({ children }) => {
         
     | 
| 
       185 
     | 
    
         
            -
                return (
         
     | 
| 
       186 
     | 
    
         
            -
                    <footer>
         
     | 
| 
       187 
     | 
    
         
            -
                        {children}
         
     | 
| 
       188 
     | 
    
         
            -
                    </footer>
         
     | 
| 
       189 
     | 
    
         
            -
                )
         
     | 
| 
       190 
     | 
    
         
            -
            }
         
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
            /**
         
     | 
| 
       193 
     | 
    
         
            -
             * Site Aside
         
     | 
| 
       194 
     | 
    
         
            -
             */
         
     | 
| 
       195 
     | 
    
         
            -
            const SiteAside = () => {
         
     | 
| 
       196 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       197 
     | 
    
         
            -
                return context.info ? (
         
     | 
| 
       198 
     | 
    
         
            -
                    <aside>
         
     | 
| 
       199 
     | 
    
         
            -
                        {context.info}
         
     | 
| 
       200 
     | 
    
         
            -
                    </aside>
         
     | 
| 
       201 
     | 
    
         
            -
                ) : ''
         
     | 
| 
       202 
     | 
    
         
            -
            }
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
            /**
         
     | 
| 
       205 
     | 
    
         
            -
             * SiteMenu
         
     | 
| 
       206 
     | 
    
         
            -
             */
         
     | 
| 
       207 
     | 
    
         
            -
            const SiteMenu = ({ iconSrc, title, children, min }) => {
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       210 
     | 
    
         
            -
                const { page, sideNav, setSideNav, showNav } = context
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
                useEffect(() => {
         
     | 
| 
       213 
     | 
    
         
            -
                    if (min) context.setSideNav('min')
         
     | 
| 
       214 
     | 
    
         
            -
                }, [])
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
                function toggle() {
         
     | 
| 
       217 
     | 
    
         
            -
                    const next = sideNav === 'max' ? 'min' : 'max'
         
     | 
| 
       218 
     | 
    
         
            -
                    setSideNav(next)
         
     | 
| 
       219 
     | 
    
         
            -
                }
         
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
                const goto = (id) => {
         
     | 
| 
       222 
     | 
    
         
            -
                    context.setShowNav(false)
         
     | 
| 
       223 
     | 
    
         
            -
                    context.goto(id)
         
     | 
| 
       224 
     | 
    
         
            -
                }
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
                const sections = useMemo(() => {
         
     | 
| 
       227 
     | 
    
         
            -
                    return children.reduce((acc, child) => {
         
     | 
| 
       228 
     | 
    
         
            -
                        const section = child.props.section || "";
         
     | 
| 
       229 
     | 
    
         
            -
                        if (!acc[section]) acc[section] = [];
         
     | 
| 
       230 
     | 
    
         
            -
                        const { title } = child.props;
         
     | 
| 
       231 
     | 
    
         
            -
                        if (title) acc[section].push(child.props);
         
     | 
| 
       232 
     | 
    
         
            -
                        return acc;
         
     | 
| 
       233 
     | 
    
         
            -
                    }, {});
         
     | 
| 
       234 
     | 
    
         
            -
                }, [children]);
         
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
                const style = sideNav === 'max' ? 'max' : 'min'
         
     | 
| 
       237 
     | 
    
         
            -
                return (
         
     | 
| 
       238 
     | 
    
         
            -
                    <menu className={`${style} ${showNav ? 'show' : ''}`}>
         
     | 
| 
       239 
     | 
    
         
            -
                        <main >
         
     | 
| 
       240 
     | 
    
         
            -
                            {Object.keys(sections).map(title => (
         
     | 
| 
       241 
     | 
    
         
            -
                                <Fragment key={title}>
         
     | 
| 
       242 
     | 
    
         
            -
                                    {title === 'undefined' ? '' : <div className={`section-title ${style}`}>{sideNav === "max" ? title : ''}</div>}
         
     | 
| 
       243 
     | 
    
         
            -
                                    {sections[title].map(({ id, icon = 'info', title }) => {
         
     | 
| 
       244 
     | 
    
         
            -
                                        const styleItem = id === page ? 'selected' : ''
         
     | 
| 
       245 
     | 
    
         
            -
                                        const titleTxt = context.translate(title)
         
     | 
| 
       246 
     | 
    
         
            -
                                        return (
         
     | 
| 
       247 
     | 
    
         
            -
                                            <div className={`site-menu-item ${styleItem}`} key={id} onClick={() => goto(id)}>
         
     | 
| 
       248 
     | 
    
         
            -
                                                <Icon key={id} icon={icon} clickable />
         
     | 
| 
       249 
     | 
    
         
            -
                                                {sideNav === 'max' ? <label>{titleTxt}</label> : null}
         
     | 
| 
       250 
     | 
    
         
            -
                                            </div>
         
     | 
| 
       251 
     | 
    
         
            -
                                        )
         
     | 
| 
       252 
     | 
    
         
            -
                                    })}
         
     | 
| 
       253 
     | 
    
         
            -
                                    <div className="section-divider" ></div>
         
     | 
| 
       254 
     | 
    
         
            -
                                </Fragment>
         
     | 
| 
       255 
     | 
    
         
            -
                            ))}
         
     | 
| 
       256 
     | 
    
         
            -
                        </main>
         
     | 
| 
       257 
     | 
    
         
            -
                    </menu>
         
     | 
| 
       258 
     | 
    
         
            -
                )
         
     | 
| 
       259 
     | 
    
         
            -
            }
         
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
            /**
         
     | 
| 
       262 
     | 
    
         
            -
             * SitePage
         
     | 
| 
       263 
     | 
    
         
            -
             */
         
     | 
| 
       264 
     | 
    
         
            -
            const SitePage = ({ children, init }) => {
         
     | 
| 
       265 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       266 
     | 
    
         
            -
                const { page } = context
         
     | 
| 
       267 
     | 
    
         
            -
                useEffect(() => {
         
     | 
| 
       268 
     | 
    
         
            -
                    if (init) {
         
     | 
| 
       269 
     | 
    
         
            -
                        context.goto(init)
         
     | 
| 
       270 
     | 
    
         
            -
                    } else {
         
     | 
| 
       271 
     | 
    
         
            -
                        context.goto("EMPTY")
         
     | 
| 
       272 
     | 
    
         
            -
                    }
         
     | 
| 
       273 
     | 
    
         
            -
                }, [])
         
     | 
| 
       274 
     | 
    
         
            -
                return (
         
     | 
| 
       275 
     | 
    
         
            -
                    <main>
         
     | 
| 
       276 
     | 
    
         
            -
                        {React.Children.toArray(children).filter(child => child.props ? child.props.id === page : false)}
         
     | 
| 
       277 
     | 
    
         
            -
                    </main>
         
     | 
| 
       278 
     | 
    
         
            -
                )
         
     | 
| 
       279 
     | 
    
         
            -
            }
         
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
            /**
         
     | 
| 
       282 
     | 
    
         
            -
             * Site Dialog
         
     | 
| 
       283 
     | 
    
         
            -
             */
         
     | 
| 
       284 
     | 
    
         
            -
            const SiteDialog = () => {
         
     | 
| 
       285 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       286 
     | 
    
         
            -
                return context.dialog ? context.dialog : ''
         
     | 
| 
       287 
     | 
    
         
            -
            }
         
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
            /**
         
     | 
| 
       290 
     | 
    
         
            -
             * Site Promtp Dialog
         
     | 
| 
       291 
     | 
    
         
            -
             */
         
     | 
| 
       292 
     | 
    
         
            -
            const SitePromptDialog = () => {
         
     | 
| 
       293 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       294 
     | 
    
         
            -
                return context.promptDialog ? context.promptDialog : ''
         
     | 
| 
       295 
     | 
    
         
            -
            }
         
     | 
| 
       296 
     | 
    
         
            -
             
     | 
| 
       297 
     | 
    
         
            -
            /**
         
     | 
| 
       298 
     | 
    
         
            -
             * Site Preview
         
     | 
| 
       299 
     | 
    
         
            -
             */
         
     | 
| 
       300 
     | 
    
         
            -
            const SitePreview = () => {
         
     | 
| 
       301 
     | 
    
         
            -
                const context = useContext(SiteContext)
         
     | 
| 
       302 
     | 
    
         
            -
                return context.preview ? (
         
     | 
| 
       303 
     | 
    
         
            -
                    <div className="site-preview" >
         
     | 
| 
       304 
     | 
    
         
            -
                        {context.preview}
         
     | 
| 
       305 
     | 
    
         
            -
                    </div>
         
     | 
| 
       306 
     | 
    
         
            -
                ) : ''
         
     | 
| 
       307 
     | 
    
         
            -
            }
         
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
            class SiteErrorBoundary extends React.Component {
         
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
                constructor(props) {
         
     | 
| 
       312 
     | 
    
         
            -
                    super(props)
         
     | 
| 
       313 
     | 
    
         
            -
                    this.state = { hasError: false }
         
     | 
| 
       314 
     | 
    
         
            -
                }
         
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
                static getDerivedStateFromError(error) {
         
     | 
| 
       317 
     | 
    
         
            -
                    return { hasError: true, error }
         
     | 
| 
       318 
     | 
    
         
            -
                }
         
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
                componentDidCatch(error, errorInfo) {
         
     | 
| 
       321 
     | 
    
         
            -
                    console.error("SiteErrorBoundary >", error, errorInfo)
         
     | 
| 
       322 
     | 
    
         
            -
                }
         
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
                render() {
         
     | 
| 
       325 
     | 
    
         
            -
                    if (this.state.hasError) {
         
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
                        const { error } = this.state
         
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
                        return (
         
     | 
| 
       330 
     | 
    
         
            -
                            <div className="site-error">
         
     | 
| 
       331 
     | 
    
         
            -
                                <h1>Site Error</h1>
         
     | 
| 
       332 
     | 
    
         
            -
                                <p>Error {error.status}: {error.message}</p>
         
     | 
| 
       333 
     | 
    
         
            -
                            </div>
         
     | 
| 
       334 
     | 
    
         
            -
                        )
         
     | 
| 
       335 
     | 
    
         
            -
                    }
         
     | 
| 
       336 
     | 
    
         
            -
                    return this.props.children
         
     | 
| 
       337 
     | 
    
         
            -
                }
         
     | 
| 
       338 
     | 
    
         
            -
            } 
         
     |