ywana-core8 0.0.349 → 0.0.352
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 +41 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +70 -56
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +41 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +41 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/menu.css +62 -57
- package/src/html/menu.js +8 -4
- package/src/site/dialog.css +8 -0
- package/src/site/dialog.js +7 -2
- package/src/site/site.js +15 -0
- package/src/site/site.test.js +33 -2
package/package.json
CHANGED
package/src/html/menu.css
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
.menu-icon {
|
2
|
-
|
3
|
-
|
2
|
+
position: relative;
|
3
|
+
width: 3rem;
|
4
4
|
}
|
5
5
|
|
6
|
-
.menu-icon
|
6
|
+
.menu-icon > .overlay {
|
7
7
|
position: fixed;
|
8
8
|
top: 0px;
|
9
9
|
left: 0px;
|
@@ -13,70 +13,75 @@
|
|
13
13
|
background-color: transparent;
|
14
14
|
}
|
15
15
|
|
16
|
-
.menu-icon>menu {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
.menu-icon > menu {
|
17
|
+
z-index: 6;
|
18
|
+
position: absolute;
|
19
|
+
top: 3rem;
|
20
|
+
left: 0px;
|
21
|
+
margin: 0;
|
22
|
+
border: solid 1px var(--divider-color);
|
23
|
+
background-color: var(--paper-color);
|
24
|
+
padding: 0;
|
25
|
+
min-width: 7rem;
|
26
|
+
max-width: 14rem;
|
27
|
+
max-height: 50vh;
|
28
|
+
overflow: auto;
|
29
|
+
box-shadow: var(--shadow1);
|
30
|
+
}
|
31
|
+
|
32
|
+
.menu-icon > menu.alignRight {
|
33
|
+
left: unset;
|
34
|
+
right: 0px;
|
35
|
+
}
|
36
|
+
|
37
|
+
.menu-icon > menu ul {
|
38
|
+
list-style: none;
|
39
|
+
margin: 0;
|
40
|
+
padding: 0.5rem 0;
|
41
|
+
cursor: pointer;
|
42
|
+
}
|
43
|
+
|
44
|
+
.menu-icon > menu li {
|
45
|
+
min-height: 3rem;
|
46
|
+
padding: 0 0.5rem;
|
47
|
+
|
48
|
+
display: flex;
|
49
|
+
align-items: center;
|
30
50
|
}
|
31
51
|
|
32
|
-
.menu-icon>menu
|
33
|
-
|
34
|
-
|
35
|
-
}
|
52
|
+
.menu-icon > menu li:hover {
|
53
|
+
background-color: var(--primary-color-lighter);
|
54
|
+
}
|
36
55
|
|
37
|
-
.menu-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
|
44
|
-
.menu-icon>menu li {
|
45
|
-
min-height: 3rem;
|
46
|
-
padding: 0 .5rem;
|
47
|
-
|
48
|
-
display: flex;
|
49
|
-
align-items: center;
|
50
|
-
}
|
51
|
-
|
52
|
-
.menu-icon>menu li:hover {
|
53
|
-
background-color: var(--primary-color-lighter);
|
54
|
-
}
|
56
|
+
.menu-item {
|
57
|
+
flex: 1;
|
58
|
+
display: flex;
|
59
|
+
align-items: center;
|
60
|
+
}
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
align-items: center;
|
60
|
-
}
|
62
|
+
.menu-item > .icon {
|
63
|
+
color: var(--text-color-light);
|
64
|
+
}
|
61
65
|
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
.menu-item > label {
|
67
|
+
flex: 1;
|
68
|
+
white-space: nowrap;
|
69
|
+
padding: 0 0.5rem 0 0;
|
70
|
+
color: var(--text-color);
|
71
|
+
font-size: 0.9rem;
|
72
|
+
}
|
65
73
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
color: var(--text-color);
|
71
|
-
font-size: .9rem;
|
72
|
-
}
|
74
|
+
.menu-item.disabled > label,
|
75
|
+
.menu-item.disabled > .icon {
|
76
|
+
color: var(--text-color-lighter);
|
77
|
+
}
|
73
78
|
|
74
|
-
|
75
|
-
|
79
|
+
.menu-item > .meta {
|
80
|
+
color: var(--text-color-lighter);
|
76
81
|
}
|
77
82
|
|
78
83
|
.menu-separator {
|
79
84
|
min-height: 0px !important;
|
80
85
|
height: 1px;
|
81
86
|
border-top: solid 1px var(--divider-color);
|
82
|
-
}
|
87
|
+
}
|
package/src/html/menu.js
CHANGED
@@ -52,15 +52,19 @@ export const MenuIcon = (props) => {
|
|
52
52
|
*/
|
53
53
|
export const MenuItem = (props) => {
|
54
54
|
|
55
|
-
const { id, icon, label, meta, onSelect } = props
|
55
|
+
const { id, icon, label, meta, disabled=false, onSelect } = props
|
56
56
|
const [open, setOpen] = useContext(MenuContext)
|
57
57
|
|
58
58
|
function select() {
|
59
|
-
if (
|
60
|
-
|
59
|
+
if (!disabled) {
|
60
|
+
if (onSelect) onSelect()
|
61
|
+
setOpen(false)
|
62
|
+
}
|
61
63
|
}
|
64
|
+
|
65
|
+
const style = disabled ? "disabled" : ""
|
62
66
|
return (
|
63
|
-
<li className=
|
67
|
+
<li className={`menu-item ${style}`} onClick={select}>
|
64
68
|
{icon ? <Icon icon={icon} /> : null}
|
65
69
|
<label>{label}</label>
|
66
70
|
{meta ? <div className="meta">{meta}</div> : null}
|
package/src/site/dialog.css
CHANGED
@@ -12,6 +12,10 @@
|
|
12
12
|
z-index: 100;
|
13
13
|
}
|
14
14
|
|
15
|
+
.overlay.prompt {
|
16
|
+
z-index: 1000;
|
17
|
+
}
|
18
|
+
|
15
19
|
.dialog {
|
16
20
|
border-radius: 4px;
|
17
21
|
position: absolute;
|
@@ -25,6 +29,10 @@
|
|
25
29
|
justify-content: center;
|
26
30
|
}
|
27
31
|
|
32
|
+
.dialog.prompt {
|
33
|
+
z-index: 1010;
|
34
|
+
}
|
35
|
+
|
28
36
|
.dialog-panel {
|
29
37
|
min-width: 500px;
|
30
38
|
max-width: 90%;
|
package/src/site/dialog.js
CHANGED
@@ -9,11 +9,16 @@ import './dialog.css'
|
|
9
9
|
* <Dialog title={title} open={true} onAction={onAction} actions={actions}>
|
10
10
|
*/
|
11
11
|
export const Dialog = (props) => {
|
12
|
+
|
12
13
|
const site = useContext(SiteContext)
|
13
14
|
const { icon, title = "Dialog", children, onAction, actions, className, eventPropagation = false } = props
|
14
15
|
|
15
16
|
function close() {
|
16
|
-
|
17
|
+
if (className === "prompt") {
|
18
|
+
site.closePromptDialog()
|
19
|
+
} else {
|
20
|
+
site.closeDialog()
|
21
|
+
}
|
17
22
|
}
|
18
23
|
|
19
24
|
function prevent(e) {
|
@@ -25,7 +30,7 @@ export const Dialog = (props) => {
|
|
25
30
|
|
26
31
|
return (
|
27
32
|
<Fragment>
|
28
|
-
<div className=
|
33
|
+
<div className={`overlay ${className}`} />
|
29
34
|
<div className={`dialog ${className}`} onClick={close}>
|
30
35
|
<div className="dialog-panel" onClick={prevent}>
|
31
36
|
<header>
|
package/src/site/site.js
CHANGED
@@ -24,6 +24,7 @@ export const SiteProvider = ({ children, siteLang, siteDictionary, showConsole }
|
|
24
24
|
const [console, setConsole] = useState(false)
|
25
25
|
const [page, setPage] = useState()
|
26
26
|
const [dialog, setDialog] = useState()
|
27
|
+
const [promptDialog, setPromptDialog] = useState()
|
27
28
|
const [preview, setPreview] = useState()
|
28
29
|
const [breadcrumb, setBreadcrumb] = useState()
|
29
30
|
const [focused, setFocused] = useState()
|
@@ -72,6 +73,10 @@ export const SiteProvider = ({ children, siteLang, siteDictionary, showConsole }
|
|
72
73
|
confirm: (message) => window.confirm(message),
|
73
74
|
prompt: (message) => window.prompt(message),
|
74
75
|
|
76
|
+
promptDialog,
|
77
|
+
openPromptDialog: (dialog) => {setPromptDialog(dialog)},
|
78
|
+
closePromptDialog: () => { setPromptDialog(null)},
|
79
|
+
|
75
80
|
notify: ({ title, body, type = "success" }) => {
|
76
81
|
Store.addNotification({
|
77
82
|
title,
|
@@ -113,6 +118,7 @@ export const Site = ({ icon, logo, title, toolbar, children, init, min, lang, di
|
|
113
118
|
<SiteAside />
|
114
119
|
<SiteConsole />
|
115
120
|
<SiteDialog />
|
121
|
+
<SitePromptDialog />
|
116
122
|
<SitePreview />
|
117
123
|
<SiteNotifications />
|
118
124
|
</div>
|
@@ -249,6 +255,15 @@ const SiteDialog = () => {
|
|
249
255
|
return context.dialog ? context.dialog : ''
|
250
256
|
}
|
251
257
|
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Site Promtp Dialog
|
261
|
+
*/
|
262
|
+
const SitePromptDialog = () => {
|
263
|
+
const context = useContext(SiteContext)
|
264
|
+
return context.promptDialog ? context.promptDialog : ''
|
265
|
+
}
|
266
|
+
|
252
267
|
/**
|
253
268
|
* Site Preview
|
254
269
|
*/
|
package/src/site/site.test.js
CHANGED
@@ -5,6 +5,8 @@ import { Page } from './page'
|
|
5
5
|
import './site.css'
|
6
6
|
import './page.css'
|
7
7
|
import { TablePage } from '../domain/TablePage'
|
8
|
+
import { Dialog } from './dialog'
|
9
|
+
import { Button } from '../html'
|
8
10
|
|
9
11
|
const SiteTest = (prop) => {
|
10
12
|
return (
|
@@ -23,7 +25,7 @@ const Page1 = (props) => {
|
|
23
25
|
|
24
26
|
const site = useContext(SiteContext)
|
25
27
|
useEffect(() => {
|
26
|
-
site.notify({ title: "Notification 1", body: "Lorem ipsum dolor sit amet"})
|
28
|
+
site.notify({ title: "Notification 1", body: "Lorem ipsum dolor sit amet" })
|
27
29
|
}, [])
|
28
30
|
|
29
31
|
return (
|
@@ -37,10 +39,39 @@ const Page1 = (props) => {
|
|
37
39
|
}
|
38
40
|
|
39
41
|
const Page2 = (props) => {
|
42
|
+
|
43
|
+
const site = useContext(SiteContext)
|
44
|
+
|
45
|
+
function prompt() {
|
46
|
+
const actions = (
|
47
|
+
<Fragment>
|
48
|
+
<Button label="CLOSE" action={() => site.closePromptDialog()} />
|
49
|
+
</Fragment>
|
50
|
+
)
|
51
|
+
site.openPromptDialog(<Dialog className="prompt" actions={actions} >PROMPT</Dialog>)
|
52
|
+
}
|
53
|
+
|
54
|
+
function openDialog() {
|
55
|
+
const actions = (
|
56
|
+
<Fragment>
|
57
|
+
<Button label="CLOSE" action={() => site.closeDialog()} />
|
58
|
+
</Fragment>
|
59
|
+
)
|
60
|
+
site.openDialog(
|
61
|
+
<Dialog actions={actions}>
|
62
|
+
<main>
|
63
|
+
<Button label="open Custom Prompt" action={prompt} />
|
64
|
+
</main>
|
65
|
+
</Dialog>
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
40
69
|
return (
|
41
70
|
<Fragment>
|
42
71
|
<header>Page 2</header>
|
43
|
-
<main
|
72
|
+
<main>
|
73
|
+
<Button label="open Dialog" action={openDialog} />
|
74
|
+
</main>
|
44
75
|
<footer>f2</footer>
|
45
76
|
</Fragment>
|
46
77
|
)
|