@operato/menu 8.0.0-beta.0 β 8.0.0-beta.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/CHANGELOG.md +9 -0
- package/package.json +11 -11
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/src/index.ts +0 -0
- package/src/menu-landscape-styles.ts +0 -149
- package/src/menu-portrait-styles.ts +0 -162
- package/src/ox-menu-landscape.ts +0 -105
- package/src/ox-menu-part.ts +0 -131
- package/src/ox-menu-portrait.ts +0 -91
- package/src/ox-top-menu-bar.ts +0 -147
- package/src/types.ts +0 -11
- package/stories/ox-menu-container.ts +0 -97
- package/stories/ox-menu-portrait.stories.ts +0 -65
- package/stories/test-menus.ts +0 -180
- package/tsconfig.json +0 -24
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @operato/menu
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operato/menu",
|
|
3
3
|
"description": "Webcomponent menu following open-wc recommendations",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "8.0.0-beta.
|
|
5
|
+
"version": "8.0.0-beta.1",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"module": "dist/src/index.js",
|
|
8
8
|
"license": "MIT",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@material/web": "^2.0.0",
|
|
57
|
-
"@operato/data-grist": "^8.0.0-beta.
|
|
58
|
-
"@operato/graphql": "^8.0.0-beta.
|
|
59
|
-
"@operato/i18n": "^8.0.0-beta.
|
|
60
|
-
"@operato/input": "^8.0.0-beta.
|
|
61
|
-
"@operato/layout": "^8.0.0-beta.
|
|
62
|
-
"@operato/popup": "^8.0.0-beta.
|
|
63
|
-
"@operato/shell": "^8.0.0-beta.
|
|
64
|
-
"@operato/styles": "^8.0.0-beta.
|
|
65
|
-
"@operato/utils": "^8.0.0-beta.
|
|
57
|
+
"@operato/data-grist": "^8.0.0-beta.1",
|
|
58
|
+
"@operato/graphql": "^8.0.0-beta.1",
|
|
59
|
+
"@operato/i18n": "^8.0.0-beta.1",
|
|
60
|
+
"@operato/input": "^8.0.0-beta.1",
|
|
61
|
+
"@operato/layout": "^8.0.0-beta.1",
|
|
62
|
+
"@operato/popup": "^8.0.0-beta.1",
|
|
63
|
+
"@operato/shell": "^8.0.0-beta.1",
|
|
64
|
+
"@operato/styles": "^8.0.0-beta.1",
|
|
65
|
+
"@operato/utils": "^8.0.0-beta.1",
|
|
66
66
|
"lit": "^3.1.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"prettier --write"
|
|
98
98
|
]
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "d5b28a2e9deb632c0dc80132f6a7196dd6fe4220"
|
|
101
101
|
}
|
package/.editorconfig
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# EditorConfig helps developers define and maintain consistent
|
|
2
|
-
# coding styles between different editors and IDEs
|
|
3
|
-
# editorconfig.org
|
|
4
|
-
|
|
5
|
-
root = true
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[*]
|
|
9
|
-
|
|
10
|
-
# Change these settings to your own preference
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
# We recommend you to keep these unchanged
|
|
15
|
-
end_of_line = lf
|
|
16
|
-
charset = utf-8
|
|
17
|
-
trim_trailing_whitespace = true
|
|
18
|
-
insert_final_newline = true
|
|
19
|
-
|
|
20
|
-
[*.md]
|
|
21
|
-
trim_trailing_whitespace = false
|
|
22
|
-
|
|
23
|
-
[*.json]
|
|
24
|
-
indent_size = 2
|
|
25
|
-
|
|
26
|
-
[*.{html,js,md}]
|
|
27
|
-
block_comment_start = /**
|
|
28
|
-
block_comment = *
|
|
29
|
-
block_comment_end = */
|
package/.storybook/main.js
DELETED
package/.storybook/preview.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { i18next } from '@operato/i18n'
|
|
2
|
-
|
|
3
|
-
export const globalTypes = {
|
|
4
|
-
locale: {
|
|
5
|
-
name: 'Locale',
|
|
6
|
-
description: 'Internationalization locale',
|
|
7
|
-
toolbar: {
|
|
8
|
-
icon: 'globe',
|
|
9
|
-
items: [
|
|
10
|
-
{ value: 'en', right: 'πΊπΈ', title: 'English' },
|
|
11
|
-
{ value: 'ko', right: 'π°π·', title: 'νκ΅μ΄' },
|
|
12
|
-
{ value: 'zh', right: 'π¨π³', title: 'δΈζ' },
|
|
13
|
-
{ value: 'ja', right: 'π―π΅', title: 'ζ₯ζ¬θͺ' },
|
|
14
|
-
{ value: 'ms', right: 'π²πΎ', title: 'Bahasa Melayu' }
|
|
15
|
-
],
|
|
16
|
-
showName: true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
theme: {
|
|
20
|
-
name: 'Theme',
|
|
21
|
-
description: 'Global theme for components',
|
|
22
|
-
toolbar: {
|
|
23
|
-
icon: 'paintbrush',
|
|
24
|
-
items: [
|
|
25
|
-
{ value: 'light', title: 'Light' },
|
|
26
|
-
{ value: 'dark', title: 'Dark' }
|
|
27
|
-
],
|
|
28
|
-
showName: true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const decorators = [
|
|
34
|
-
(Story, context) => {
|
|
35
|
-
const { locale, theme } = context.globals
|
|
36
|
-
|
|
37
|
-
if (locale) {
|
|
38
|
-
i18next.changeLanguage(locale)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Set the theme class for the document
|
|
42
|
-
if (theme === 'dark') {
|
|
43
|
-
document.documentElement.classList.add('dark')
|
|
44
|
-
document.documentElement.classList.remove('light')
|
|
45
|
-
} else {
|
|
46
|
-
document.documentElement.classList.add('light')
|
|
47
|
-
document.documentElement.classList.remove('dark')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return Story()
|
|
51
|
-
}
|
|
52
|
-
]
|
package/.storybook/server.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
-
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
-
|
|
4
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
-
...baseConfig,
|
|
6
|
-
open: '/',
|
|
7
|
-
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
-
});
|
package/src/index.ts
DELETED
|
File without changes
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { css } from 'lit'
|
|
2
|
-
|
|
3
|
-
export const MenuLandscapeStyles = css`
|
|
4
|
-
:host {
|
|
5
|
-
overflow-x: auto;
|
|
6
|
-
background-color: var(--md-sys-color-on-secondary-container);
|
|
7
|
-
--focus-anchor-color: #e6ffa2;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
:host > div {
|
|
11
|
-
overflow-x: auto;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:host > div > ul {
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: row;
|
|
17
|
-
list-style: none;
|
|
18
|
-
margin: auto;
|
|
19
|
-
padding: 0;
|
|
20
|
-
border: var(--border-dim-color);
|
|
21
|
-
border-width: 0 1px;
|
|
22
|
-
max-width: 1250px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host > div > ul > li {
|
|
26
|
-
flex: 1;
|
|
27
|
-
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
}
|
|
31
|
-
:host > div > ul > li > a {
|
|
32
|
-
display: none;
|
|
33
|
-
font-weight: bold;
|
|
34
|
-
font-size: var(--fontsize-large);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
ul[submenus] {
|
|
38
|
-
flex: 1;
|
|
39
|
-
list-style: none;
|
|
40
|
-
overflow-y: hidden;
|
|
41
|
-
background-color: var(--md-sys-color-on-primary-container);
|
|
42
|
-
margin: 0;
|
|
43
|
-
padding: 0;
|
|
44
|
-
border-left: var(--border-dim-color);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
ul[submenus] li {
|
|
48
|
-
min-width: 120px;
|
|
49
|
-
max-width: 180px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
a {
|
|
53
|
-
display: block;
|
|
54
|
-
padding: var(--padding-default) var(--padding-default) var(--spacing-small) var(--spacing-large);
|
|
55
|
-
text-decoration: none;
|
|
56
|
-
font: normal 14px var(--theme-font);
|
|
57
|
-
color: var(--md-sys-color-surface);
|
|
58
|
-
text-transform: capitalize;
|
|
59
|
-
|
|
60
|
-
overflow: hidden;
|
|
61
|
-
white-space: nowrap;
|
|
62
|
-
text-overflow: ellipsis;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
a:hover {
|
|
66
|
-
font-weight: bold;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
ul[submenus] a::before {
|
|
70
|
-
content: '';
|
|
71
|
-
display: inline-block;
|
|
72
|
-
position: relative;
|
|
73
|
-
top: -1px;
|
|
74
|
-
width: 5px;
|
|
75
|
-
height: 5px;
|
|
76
|
-
border: 1px solid var(--md-sys-color-surface);
|
|
77
|
-
border-radius: 50%;
|
|
78
|
-
background-color: transparent;
|
|
79
|
-
margin-right: 3px;
|
|
80
|
-
}
|
|
81
|
-
ul[submenus] a:hover,
|
|
82
|
-
ul[submenus] li[active] a {
|
|
83
|
-
background-color: rgba(var(--secondary-color-rgb), 0.3);
|
|
84
|
-
color: var(--focus-anchor-color);
|
|
85
|
-
font-weight: bold;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
[description] {
|
|
89
|
-
background-color: var(--md-sys-color-on-primary-container);
|
|
90
|
-
margin: 0;
|
|
91
|
-
padding: var(--padding-default) 0;
|
|
92
|
-
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
|
93
|
-
color: var(--focus-anchor-color);
|
|
94
|
-
font-size: 11px;
|
|
95
|
-
}
|
|
96
|
-
[description] md-icon {
|
|
97
|
-
background-color: rgba(0, 0, 0, 0.15);
|
|
98
|
-
margin-right: 4px;
|
|
99
|
-
padding: var(--spacing-small);
|
|
100
|
-
border-radius: 0 5px 5px 0;
|
|
101
|
-
float: left;
|
|
102
|
-
font-size: 26px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@media only screen and (max-width: 460px) {
|
|
106
|
-
:host {
|
|
107
|
-
min-width: 100vw;
|
|
108
|
-
}
|
|
109
|
-
:host > div {
|
|
110
|
-
display: initial;
|
|
111
|
-
}
|
|
112
|
-
:host > div > ul {
|
|
113
|
-
flex-direction: column;
|
|
114
|
-
}
|
|
115
|
-
a {
|
|
116
|
-
padding: var(--spacing-large);
|
|
117
|
-
font: normal 15px var(--theme-font);
|
|
118
|
-
}
|
|
119
|
-
li[active] ul {
|
|
120
|
-
border-bottom: 2px solid rgba(0, 0, 0, 0.1);
|
|
121
|
-
}
|
|
122
|
-
li li a {
|
|
123
|
-
display: block;
|
|
124
|
-
padding: var(--spacing-large) var(--padding-default) var(--spacing-large) 35px;
|
|
125
|
-
overflow: hidden;
|
|
126
|
-
text-overflow: ellipsis;
|
|
127
|
-
white-space: nowrap;
|
|
128
|
-
font: normal 14px var(--theme-font);
|
|
129
|
-
}
|
|
130
|
-
li li[active] a {
|
|
131
|
-
font: bold 14px var(--theme-font);
|
|
132
|
-
}
|
|
133
|
-
:host > div > ul > li > a {
|
|
134
|
-
display: block;
|
|
135
|
-
}
|
|
136
|
-
:host > div > ul > li > a md-icon {
|
|
137
|
-
font-size: 1em;
|
|
138
|
-
position: relative;
|
|
139
|
-
top: 2px;
|
|
140
|
-
}
|
|
141
|
-
[description] {
|
|
142
|
-
display: none;
|
|
143
|
-
}
|
|
144
|
-
ul[submenus] a:hover,
|
|
145
|
-
ul[submenus] li[active] a {
|
|
146
|
-
background-color: rgba(var(--secondary-color-rgb), 0.3);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
`
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { css } from 'lit'
|
|
2
|
-
|
|
3
|
-
export const MenuPortraitStyles = css`
|
|
4
|
-
:host {
|
|
5
|
-
display: flex;
|
|
6
|
-
overflow-y: auto;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
height: 100%;
|
|
9
|
-
background-color: var(--md-sys-color-on-primary);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
:host > ul {
|
|
13
|
-
margin-block-end: 1.5em;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
ul {
|
|
17
|
-
list-style: none;
|
|
18
|
-
margin: var(--spacing-none);
|
|
19
|
-
padding: var(--spacing-none);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
[group-label] {
|
|
23
|
-
padding: var(--spacing-huge) var(--spacing-none) var(--spacing-small) var(--spacing-large);
|
|
24
|
-
border-bottom: var(--border-dim-color);
|
|
25
|
-
font: var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500)) 12px var(--theme-font);
|
|
26
|
-
color: var(--md-sys-color-primary);
|
|
27
|
-
text-transform: uppercase;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
a {
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.07);
|
|
34
|
-
padding: var(--spacing-medium);
|
|
35
|
-
padding-left: var(--spacing-large);
|
|
36
|
-
text-decoration: none;
|
|
37
|
-
font: normal var(--md-sys-typescale-label-large-size, 0.875rem) var(--theme-font);
|
|
38
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
39
|
-
text-transform: capitalize;
|
|
40
|
-
|
|
41
|
-
overflow: hidden;
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
text-overflow: ellipsis;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
a:hover {
|
|
47
|
-
color: var(--md-sys-color-primary);
|
|
48
|
-
font-weight: bold;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
a * {
|
|
52
|
-
vertical-align: middle;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
a md-icon {
|
|
56
|
-
--md-icon-size: var(--icon-size-tiny);
|
|
57
|
-
opacity: 0.7;
|
|
58
|
-
margin-right: var(--spacing-small);
|
|
59
|
-
color: var(--md-sys-color-primary);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
md-icon[filled] {
|
|
63
|
-
font-variation-settings: 'FILL' 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
a [submenu-button] {
|
|
67
|
-
--md-icon-size: var(--icon-size-tiny);
|
|
68
|
-
max-height: 1em;
|
|
69
|
-
margin-left: auto;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
a [submenu-button]::before {
|
|
73
|
-
content: 'chevron_right';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
a > span {
|
|
77
|
-
flex: 1;
|
|
78
|
-
overflow: hidden;
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
text-overflow: ellipsis;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
li[active] > a [submenu-button]::before {
|
|
84
|
-
content: 'expand_more';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
li[active] > a {
|
|
88
|
-
color: var(--md-sys-color-on-primary-container);
|
|
89
|
-
font-weight: bold;
|
|
90
|
-
border-left: 3px solid var(--md-sys-color-primary);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
li li a {
|
|
94
|
-
padding: var(--spacing-medium);
|
|
95
|
-
padding-left: var(--spacing-huge);
|
|
96
|
-
font: normal 13px var(--theme-font);
|
|
97
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
li li[active] a {
|
|
101
|
-
background-color: var(--md-sys-color-primary-container);
|
|
102
|
-
font: var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500))
|
|
103
|
-
var(--md-sys-typescale-label-large-size, 0.875rem) var(--theme-font);
|
|
104
|
-
color: var(--md-sys-color-primary);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
li > ul {
|
|
108
|
-
overflow-y: hidden;
|
|
109
|
-
max-height: 0;
|
|
110
|
-
background-color: var(--md-sys-color-surface);
|
|
111
|
-
|
|
112
|
-
transition-property: all;
|
|
113
|
-
transition-duration: 0.7s;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
li[active] > ul {
|
|
117
|
-
max-height: 500px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
li[active] > ul[settled] {
|
|
121
|
-
overflow-y: auto;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
li li a::before {
|
|
125
|
-
margin-right: var(--spacing-small);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
a [badge] {
|
|
129
|
-
margin-left: auto;
|
|
130
|
-
background-color: var(--md-sys-color-primary);
|
|
131
|
-
border-radius: var(--md-sys-shape-corner-full);
|
|
132
|
-
padding: 0 var(--spacing-small);
|
|
133
|
-
color: var(--md-sys-color-on-primary);
|
|
134
|
-
font-size: 0.9em;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@media only screen and (max-width: 460px) {
|
|
138
|
-
:host {
|
|
139
|
-
min-width: 100vw;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
a {
|
|
143
|
-
padding: var(--spacing-large);
|
|
144
|
-
font: normal 15px var(--theme-font);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
li li a {
|
|
148
|
-
display: block;
|
|
149
|
-
padding: var(--spacing-medium);
|
|
150
|
-
padding-left: var(--spacing-huge);
|
|
151
|
-
overflow: hidden;
|
|
152
|
-
text-overflow: ellipsis;
|
|
153
|
-
white-space: nowrap;
|
|
154
|
-
font: normal var(--md-sys-typescale-label-large-size, 0.875rem) var(--theme-font);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
li li[active] a {
|
|
158
|
-
font: var(--md-sys-typescale-label-large-weight, var(--md-ref-typeface-weight-medium, 500))
|
|
159
|
-
var(--md-sys-typescale-label-large-size, 0.875rem) var(--theme-font);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
`
|
package/src/ox-menu-landscape.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
|
|
3
|
-
import { html, LitElement } from 'lit'
|
|
4
|
-
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
5
|
-
import { connect } from 'pwa-helpers'
|
|
6
|
-
|
|
7
|
-
import { navigate, store } from '@operato/shell'
|
|
8
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
9
|
-
|
|
10
|
-
import { Menu } from './types'
|
|
11
|
-
import { MenuLandscapeStyles } from './menu-landscape-styles'
|
|
12
|
-
|
|
13
|
-
@customElement('ox-menu-landscape')
|
|
14
|
-
export class OxMenuLandscape extends connect(store)(LitElement) {
|
|
15
|
-
static styles = [ScrollbarStyles, MenuLandscapeStyles]
|
|
16
|
-
|
|
17
|
-
@property({ type: Array }) menus?: Menu[]
|
|
18
|
-
@property({ type: Object }) activeTopLevel?: Menu
|
|
19
|
-
@property({ type: Object }) activeMenu!: Menu
|
|
20
|
-
@property({ type: String }) path?: string
|
|
21
|
-
|
|
22
|
-
render() {
|
|
23
|
-
const { menus = [], activeTopLevel, activeMenu } = this
|
|
24
|
-
|
|
25
|
-
return html`
|
|
26
|
-
<div id="wrap" @mousewheel=${this.onWheelEvent.bind(this)}>
|
|
27
|
-
<ul>
|
|
28
|
-
${menus.map(menu =>
|
|
29
|
-
menu.type == 'group'
|
|
30
|
-
? html``
|
|
31
|
-
: html`
|
|
32
|
-
<li ?active=${menu === activeTopLevel}>
|
|
33
|
-
<a href=${menu.path || '#'}>
|
|
34
|
-
${menu.icon ? html`<md-icon>${menu.icon}</md-icon>` : html``} ${menu.label || menu.name}
|
|
35
|
-
</a>
|
|
36
|
-
|
|
37
|
-
<ul submenus>
|
|
38
|
-
${menu.menus?.map(
|
|
39
|
-
menu => html`
|
|
40
|
-
<li ?active=${menu === activeMenu}>
|
|
41
|
-
<a href=${menu.path || '#'}> ${menu.label || menu.name} </a>
|
|
42
|
-
</li>
|
|
43
|
-
`
|
|
44
|
-
)}
|
|
45
|
-
</ul>
|
|
46
|
-
|
|
47
|
-
<div description>
|
|
48
|
-
${menu.icon ? html`<md-icon>${menu.icon}</md-icon>` : html``} ${menu.description || ''}
|
|
49
|
-
</div>
|
|
50
|
-
</li>
|
|
51
|
-
`
|
|
52
|
-
)}
|
|
53
|
-
</ul>
|
|
54
|
-
</div>
|
|
55
|
-
`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
firstUpdated() {
|
|
59
|
-
this.renderRoot.addEventListener('click', (e: Event) => {
|
|
60
|
-
//@ts-ignore
|
|
61
|
-
if (e.target.submenu) {
|
|
62
|
-
/* protect to act move to href. */
|
|
63
|
-
e.stopPropagation()
|
|
64
|
-
e.preventDefault()
|
|
65
|
-
|
|
66
|
-
//@ts-ignore
|
|
67
|
-
let menu = e.target.submenu
|
|
68
|
-
|
|
69
|
-
this.dispatchEvent(
|
|
70
|
-
new CustomEvent('active-toplevel', {
|
|
71
|
-
bubbles: true,
|
|
72
|
-
detail: this.activeTopLevel === menu ? undefined : menu
|
|
73
|
-
})
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* to respond even if current acting menu is selected */
|
|
80
|
-
let href = (e.target as HTMLAnchorElement).href
|
|
81
|
-
href && location.href === href && navigate(href + '#force', true)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
/* to hide scrollbar during transition */
|
|
85
|
-
this.renderRoot.addEventListener('transitionstart', e => {
|
|
86
|
-
;(e.target as HTMLElement).removeAttribute('settled')
|
|
87
|
-
})
|
|
88
|
-
this.renderRoot.addEventListener('transitionend', e => {
|
|
89
|
-
;(e.target as HTMLElement).setAttribute('settled', '')
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
onWheelEvent(e: WheelEvent) {
|
|
94
|
-
const { target, deltaY, detail } = e
|
|
95
|
-
|
|
96
|
-
if (!(target instanceof HTMLElement)) {
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const delta = deltaY || -detail
|
|
101
|
-
target.scrollLeft -= (delta / Math.abs(delta)) * 10
|
|
102
|
-
|
|
103
|
-
e.preventDefault()
|
|
104
|
-
}
|
|
105
|
-
}
|
package/src/ox-menu-part.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
import './ox-menu-portrait'
|
|
3
|
-
import './ox-menu-landscape'
|
|
4
|
-
|
|
5
|
-
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
6
|
-
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
7
|
-
import { connect } from 'pwa-helpers'
|
|
8
|
-
|
|
9
|
-
import { store } from '@operato/shell'
|
|
10
|
-
import { ScrollbarStyles } from '@operato/styles'
|
|
11
|
-
|
|
12
|
-
import { Menu } from './types'
|
|
13
|
-
|
|
14
|
-
function isActiveMenu(menu: Menu, path: string) {
|
|
15
|
-
return (
|
|
16
|
-
menu.path?.split('?')[0] === path ||
|
|
17
|
-
(menu.active && typeof menu.active === 'function' && menu.active.call(menu, { path }))
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@customElement('ox-menu-part')
|
|
22
|
-
export class OxMenuPart extends connect(store)(LitElement) {
|
|
23
|
-
static styles = [
|
|
24
|
-
ScrollbarStyles,
|
|
25
|
-
css`
|
|
26
|
-
:host {
|
|
27
|
-
display: flex;
|
|
28
|
-
overflow-y: auto;
|
|
29
|
-
flex-direction: column;
|
|
30
|
-
height: 100%;
|
|
31
|
-
min-width: 200px;
|
|
32
|
-
background-color: var(--md-sys-color-surface);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
:host([landscape]) {
|
|
36
|
-
overflow-x: auto;
|
|
37
|
-
flex-direction: row;
|
|
38
|
-
width: 100%;
|
|
39
|
-
min-height: 20px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
ox-menu-portrait,
|
|
43
|
-
ox-menu-landscape {
|
|
44
|
-
flex: 1;
|
|
45
|
-
}
|
|
46
|
-
`
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
@property({ type: String }) page!: string
|
|
50
|
-
@property({ type: String }) resourceId?: string
|
|
51
|
-
@property({ type: Array }) menus?: Menu[]
|
|
52
|
-
@property({ type: String }) orientation?: 'landscape' | 'portrait'
|
|
53
|
-
|
|
54
|
-
@state() slotTemplate: any
|
|
55
|
-
@state() _activeTopLevel?: Menu
|
|
56
|
-
@state() _activeMenu?: Menu
|
|
57
|
-
@state() _path?: string
|
|
58
|
-
|
|
59
|
-
render() {
|
|
60
|
-
return html`
|
|
61
|
-
<slot name="head"></slot>
|
|
62
|
-
${this.orientation !== 'landscape'
|
|
63
|
-
? html`<ox-menu-portrait
|
|
64
|
-
.menus=${this.menus}
|
|
65
|
-
.activeTopLevel=${this._activeTopLevel}
|
|
66
|
-
.activeMenu=${this._activeMenu}
|
|
67
|
-
.path=${this._path}
|
|
68
|
-
></ox-menu-portrait>`
|
|
69
|
-
: html`<ox-menu-landscape
|
|
70
|
-
.menus=${this.menus}
|
|
71
|
-
.activeTopLevel=${this._activeTopLevel}
|
|
72
|
-
.activeMenu=${this._activeMenu}
|
|
73
|
-
.path=${this._path}
|
|
74
|
-
></ox-menu-landscape>`}
|
|
75
|
-
<slot name="tail"></slot>
|
|
76
|
-
`
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
firstUpdated() {
|
|
80
|
-
this.renderRoot.addEventListener('active-toplevel', (e: Event) => {
|
|
81
|
-
e.stopPropagation()
|
|
82
|
-
e.preventDefault()
|
|
83
|
-
|
|
84
|
-
this._activeTopLevel = (e as CustomEvent).detail
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
updated(changes: PropertyValues<this>) {
|
|
89
|
-
if (changes.has('menus') || changes.has('page') || changes.has('resourceId')) {
|
|
90
|
-
this.findActivePage()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (changes.has('orientation')) {
|
|
94
|
-
if (this.orientation == 'portrait') {
|
|
95
|
-
this.removeAttribute('landscape')
|
|
96
|
-
} else {
|
|
97
|
-
this.setAttribute('landscape', '')
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (changes.has('slotTemplate')) {
|
|
102
|
-
this.replaceChild(this.slotTemplate, this.renderRoot)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
stateChanged(state: any): void {
|
|
107
|
-
this.page = state.route.page
|
|
108
|
-
this.resourceId = state.route.resourceId
|
|
109
|
-
this.menus = state.liteMenu.menus || []
|
|
110
|
-
this.slotTemplate = state.liteMenu.slotTemplate
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private findActivePage() {
|
|
114
|
-
var path = this.resourceId ? `${this.page}/${this.resourceId}` : this.page
|
|
115
|
-
var menus = this.menus || []
|
|
116
|
-
var activeMenu
|
|
117
|
-
|
|
118
|
-
this._activeTopLevel = menus.find(menu => {
|
|
119
|
-
if (isActiveMenu(menu, path)) {
|
|
120
|
-
activeMenu = menu
|
|
121
|
-
return true
|
|
122
|
-
} else if (menu.menus) {
|
|
123
|
-
activeMenu = menu.menus.find(menu => isActiveMenu(menu, path))
|
|
124
|
-
return !!activeMenu
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
this._path = path
|
|
129
|
-
this._activeMenu = activeMenu || this._activeTopLevel
|
|
130
|
-
}
|
|
131
|
-
}
|