@operato/menu 2.0.0-alpha.100

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 (56) hide show
  1. package/.editorconfig +29 -0
  2. package/.storybook/main.js +3 -0
  3. package/.storybook/server.mjs +8 -0
  4. package/CHANGELOG.md +241 -0
  5. package/README.md +75 -0
  6. package/demo/index.html +40 -0
  7. package/dist/src/index.d.ts +0 -0
  8. package/dist/src/index.js +2 -0
  9. package/dist/src/index.js.map +1 -0
  10. package/dist/src/menu-landscape-styles.d.ts +1 -0
  11. package/dist/src/menu-landscape-styles.js +149 -0
  12. package/dist/src/menu-landscape-styles.js.map +1 -0
  13. package/dist/src/menu-portrait-styles.d.ts +1 -0
  14. package/dist/src/menu-portrait-styles.js +145 -0
  15. package/dist/src/menu-portrait-styles.js.map +1 -0
  16. package/dist/src/ox-menu-landscape.d.ts +21 -0
  17. package/dist/src/ox-menu-landscape.js +99 -0
  18. package/dist/src/ox-menu-landscape.js.map +1 -0
  19. package/dist/src/ox-menu-part.d.ts +29 -0
  20. package/dist/src/ox-menu-part.js +135 -0
  21. package/dist/src/ox-menu-part.js.map +1 -0
  22. package/dist/src/ox-menu-portrait.d.ts +13 -0
  23. package/dist/src/ox-menu-portrait.js +88 -0
  24. package/dist/src/ox-menu-portrait.js.map +1 -0
  25. package/dist/src/ox-top-menu-bar.d.ts +23 -0
  26. package/dist/src/ox-top-menu-bar.js +145 -0
  27. package/dist/src/ox-top-menu-bar.js.map +1 -0
  28. package/dist/src/types.d.ts +10 -0
  29. package/dist/src/types.js +2 -0
  30. package/dist/src/types.js.map +1 -0
  31. package/dist/stories/ox-menu-container.d.ts +15 -0
  32. package/dist/stories/ox-menu-container.js +94 -0
  33. package/dist/stories/ox-menu-container.js.map +1 -0
  34. package/dist/stories/ox-menu-portrait.stories.d.ts +17 -0
  35. package/dist/stories/ox-menu-portrait.stories.js +46 -0
  36. package/dist/stories/ox-menu-portrait.stories.js.map +1 -0
  37. package/dist/stories/test-menus.d.ts +2 -0
  38. package/dist/stories/test-menus.js +179 -0
  39. package/dist/stories/test-menus.js.map +1 -0
  40. package/dist/tsconfig.tsbuildinfo +1 -0
  41. package/package.json +99 -0
  42. package/src/index.ts +0 -0
  43. package/src/menu-landscape-styles.ts +149 -0
  44. package/src/menu-portrait-styles.ts +145 -0
  45. package/src/ox-menu-landscape.ts +105 -0
  46. package/src/ox-menu-part.ts +131 -0
  47. package/src/ox-menu-portrait.ts +91 -0
  48. package/src/ox-top-menu-bar.ts +147 -0
  49. package/src/types.ts +10 -0
  50. package/stories/ox-menu-container.ts +97 -0
  51. package/stories/ox-menu-portrait.stories.ts +57 -0
  52. package/stories/test-menus.ts +180 -0
  53. package/themes/app-theme.css +145 -0
  54. package/tsconfig.json +23 -0
  55. package/web-dev-server.config.mjs +27 -0
  56. package/web-test-runner.config.mjs +41 -0
@@ -0,0 +1,145 @@
1
+ import { css } from 'lit';
2
+ export const MenuPortraitStyles = css `
3
+ :host {
4
+ display: flex;
5
+ overflow-y: auto;
6
+ flex-direction: column;
7
+ height: 100%;
8
+ }
9
+
10
+ :host > ul {
11
+ margin-block-end: 1.5em;
12
+ }
13
+
14
+ ul {
15
+ list-style: none;
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+
20
+ [group-label] {
21
+ padding: 25px 0 var(--padding-narrow) var(--padding-wide);
22
+ border-bottom: var(--border-dark-color);
23
+ font: bold 12px var(--theme-font);
24
+ color: rgba(var(--primary-color-rgb), 0.9);
25
+ text-transform: uppercase;
26
+ }
27
+
28
+ a {
29
+ display: flex;
30
+ align-items: center;
31
+ border-bottom: 1px solid rgba(0, 0, 0, 0.07);
32
+ padding: var(--padding-default) var(--padding-default) var(--padding-default) var(--padding-wide);
33
+ text-decoration: none;
34
+ font: normal 14px var(--theme-font);
35
+ color: var(--secondary-color);
36
+ text-transform: capitalize;
37
+
38
+ overflow: hidden;
39
+ white-space: nowrap;
40
+ text-overflow: ellipsis;
41
+ }
42
+
43
+ a:hover {
44
+ color: var(--primary-color);
45
+ font-weight: bold;
46
+ }
47
+
48
+ a * {
49
+ vertical-align: middle;
50
+ }
51
+
52
+ a md-icon {
53
+ --md-icon-size: 20px;
54
+ font-variation-settings: 'FILL' 1;
55
+
56
+ margin-right: var(--margin-narrow);
57
+ color: rgba(var(--secondary-color-rgb), 0.7);
58
+ }
59
+
60
+ a [submenu-button] {
61
+ --md-icon-size: 20px;
62
+ max-height: 20px;
63
+ margin-left: auto;
64
+ }
65
+
66
+ a [submenu-button]::before {
67
+ content: 'chevron_right';
68
+ }
69
+
70
+ li[active] > a [submenu-button]::before {
71
+ content: 'expand_more';
72
+ }
73
+
74
+ li[active] > a {
75
+ border-left: 3px solid var(--primary-color);
76
+ font-weight: bold;
77
+ color: var(--primary-color);
78
+ }
79
+
80
+ li li a {
81
+ padding: 7px 0 7px 35px;
82
+ font: normal 13px var(--theme-font);
83
+ color: var(--secondary-color);
84
+ }
85
+
86
+ li li[active] a {
87
+ background-color: rgba(var(--primary-color-rgb), 0.15);
88
+ font: bold 13px var(--theme-font);
89
+ color: var(--primary-color);
90
+ }
91
+
92
+ li > ul {
93
+ overflow-y: hidden;
94
+ max-height: 0;
95
+ background-color: #f6f6f6;
96
+
97
+ transition-property: all;
98
+ transition-duration: 0.7s;
99
+ }
100
+
101
+ li[active] > ul {
102
+ max-height: 500px;
103
+ }
104
+
105
+ li[active] > ul[settled] {
106
+ overflow-y: auto;
107
+ }
108
+
109
+ li li a::before {
110
+ margin-right: var(--margin-narrow);
111
+ }
112
+
113
+ a [badge] {
114
+ margin-left: auto;
115
+ background-color: var(--primary-background-color);
116
+ color: white;
117
+ border-radius: 999em;
118
+ padding: 0px 6px;
119
+ }
120
+
121
+ @media only screen and (max-width: 460px) {
122
+ :host {
123
+ min-width: 100vw;
124
+ }
125
+
126
+ a {
127
+ padding: var(--padding-wide);
128
+ font: normal 15px var(--theme-font);
129
+ }
130
+
131
+ li li a {
132
+ display: block;
133
+ padding: var(--padding-wide) var(--padding-default) var(--padding-wide) 35px;
134
+ overflow: hidden;
135
+ text-overflow: ellipsis;
136
+ white-space: nowrap;
137
+ font: normal 14px var(--theme-font);
138
+ }
139
+
140
+ li li[active] a {
141
+ font: bold 14px var(--theme-font);
142
+ }
143
+ }
144
+ `;
145
+ //# sourceMappingURL=menu-portrait-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-portrait-styles.js","sourceRoot":"","sources":["../../src/menu-portrait-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8IpC,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport const MenuPortraitStyles = css`\n :host {\n display: flex;\n overflow-y: auto;\n flex-direction: column;\n height: 100%;\n }\n\n :host > ul {\n margin-block-end: 1.5em;\n }\n\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n [group-label] {\n padding: 25px 0 var(--padding-narrow) var(--padding-wide);\n border-bottom: var(--border-dark-color);\n font: bold 12px var(--theme-font);\n color: rgba(var(--primary-color-rgb), 0.9);\n text-transform: uppercase;\n }\n\n a {\n display: flex;\n align-items: center;\n border-bottom: 1px solid rgba(0, 0, 0, 0.07);\n padding: var(--padding-default) var(--padding-default) var(--padding-default) var(--padding-wide);\n text-decoration: none;\n font: normal 14px var(--theme-font);\n color: var(--secondary-color);\n text-transform: capitalize;\n\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n a:hover {\n color: var(--primary-color);\n font-weight: bold;\n }\n\n a * {\n vertical-align: middle;\n }\n\n a md-icon {\n --md-icon-size: 20px;\n font-variation-settings: 'FILL' 1;\n\n margin-right: var(--margin-narrow);\n color: rgba(var(--secondary-color-rgb), 0.7);\n }\n\n a [submenu-button] {\n --md-icon-size: 20px;\n max-height: 20px;\n margin-left: auto;\n }\n\n a [submenu-button]::before {\n content: 'chevron_right';\n }\n\n li[active] > a [submenu-button]::before {\n content: 'expand_more';\n }\n\n li[active] > a {\n border-left: 3px solid var(--primary-color);\n font-weight: bold;\n color: var(--primary-color);\n }\n\n li li a {\n padding: 7px 0 7px 35px;\n font: normal 13px var(--theme-font);\n color: var(--secondary-color);\n }\n\n li li[active] a {\n background-color: rgba(var(--primary-color-rgb), 0.15);\n font: bold 13px var(--theme-font);\n color: var(--primary-color);\n }\n\n li > ul {\n overflow-y: hidden;\n max-height: 0;\n background-color: #f6f6f6;\n\n transition-property: all;\n transition-duration: 0.7s;\n }\n\n li[active] > ul {\n max-height: 500px;\n }\n\n li[active] > ul[settled] {\n overflow-y: auto;\n }\n\n li li a::before {\n margin-right: var(--margin-narrow);\n }\n\n a [badge] {\n margin-left: auto;\n background-color: var(--primary-background-color);\n color: white;\n border-radius: 999em;\n padding: 0px 6px;\n }\n\n @media only screen and (max-width: 460px) {\n :host {\n min-width: 100vw;\n }\n\n a {\n padding: var(--padding-wide);\n font: normal 15px var(--theme-font);\n }\n\n li li a {\n display: block;\n padding: var(--padding-wide) var(--padding-default) var(--padding-wide) 35px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font: normal 14px var(--theme-font);\n }\n\n li li[active] a {\n font: bold 14px var(--theme-font);\n }\n }\n`\n"]}
@@ -0,0 +1,21 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { LitElement } from 'lit';
3
+ import { Menu } from './types';
4
+ declare const OxMenuLandscape_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & typeof LitElement;
11
+ export declare class OxMenuLandscape extends OxMenuLandscape_base {
12
+ static styles: import("lit").CSSResult[];
13
+ menus?: Menu[];
14
+ activeTopLevel?: Menu;
15
+ activeMenu: Menu;
16
+ path?: string;
17
+ render(): import("lit-html").TemplateResult<1>;
18
+ firstUpdated(): void;
19
+ onWheelEvent(e: WheelEvent): void;
20
+ }
21
+ export {};
@@ -0,0 +1,99 @@
1
+ import { __decorate } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import { html, LitElement } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { connect } from 'pwa-helpers';
6
+ import { navigate, store } from '@operato/shell';
7
+ import { ScrollbarStyles } from '@operato/styles';
8
+ import { MenuLandscapeStyles } from './menu-landscape-styles';
9
+ let OxMenuLandscape = class OxMenuLandscape extends connect(store)(LitElement) {
10
+ render() {
11
+ const { menus = [], activeTopLevel, activeMenu } = this;
12
+ return html `
13
+ <div id="wrap" @mousewheel=${this.onWheelEvent.bind(this)}>
14
+ <ul>
15
+ ${menus.map(menu => {
16
+ var _a;
17
+ return menu.type == 'group'
18
+ ? html ``
19
+ : html `
20
+ <li ?active=${menu === activeTopLevel}>
21
+ <a href=${menu.path || '#'}>
22
+ ${menu.icon ? html `<md-icon>${menu.icon}</md-icon>` : html ``} ${menu.name}
23
+ </a>
24
+
25
+ <ul submenus>
26
+ ${(_a = menu.menus) === null || _a === void 0 ? void 0 : _a.map(menu => html `
27
+ <li ?active=${menu === activeMenu}>
28
+ <a href=${menu.path || '#'}> ${menu.name} </a>
29
+ </li>
30
+ `)}
31
+ </ul>
32
+
33
+ <div description>
34
+ ${menu.icon ? html `<md-icon>${menu.icon}</md-icon>` : html ``} ${menu.description || ''}
35
+ </div>
36
+ </li>
37
+ `;
38
+ })}
39
+ </ul>
40
+ </div>
41
+ `;
42
+ }
43
+ firstUpdated() {
44
+ this.renderRoot.addEventListener('click', (e) => {
45
+ //@ts-ignore
46
+ if (e.target.submenu) {
47
+ /* protect to act move to href. */
48
+ e.stopPropagation();
49
+ e.preventDefault();
50
+ //@ts-ignore
51
+ let menu = e.target.submenu;
52
+ this.dispatchEvent(new CustomEvent('active-toplevel', {
53
+ bubbles: true,
54
+ detail: this.activeTopLevel === menu ? undefined : menu
55
+ }));
56
+ return;
57
+ }
58
+ /* to respond even if current acting menu is selected */
59
+ let href = e.target.href;
60
+ href && location.href === href && navigate(href + '#force', true);
61
+ });
62
+ /* to hide scrollbar during transition */
63
+ this.renderRoot.addEventListener('transitionstart', e => {
64
+ ;
65
+ e.target.removeAttribute('settled');
66
+ });
67
+ this.renderRoot.addEventListener('transitionend', e => {
68
+ ;
69
+ e.target.setAttribute('settled', '');
70
+ });
71
+ }
72
+ onWheelEvent(e) {
73
+ const { target, deltaY, detail } = e;
74
+ if (!(target instanceof HTMLElement)) {
75
+ return;
76
+ }
77
+ const delta = deltaY || -detail;
78
+ target.scrollLeft -= (delta / Math.abs(delta)) * 10;
79
+ e.preventDefault();
80
+ }
81
+ };
82
+ OxMenuLandscape.styles = [ScrollbarStyles, MenuLandscapeStyles];
83
+ __decorate([
84
+ property({ type: Array })
85
+ ], OxMenuLandscape.prototype, "menus", void 0);
86
+ __decorate([
87
+ property({ type: Object })
88
+ ], OxMenuLandscape.prototype, "activeTopLevel", void 0);
89
+ __decorate([
90
+ property({ type: Object })
91
+ ], OxMenuLandscape.prototype, "activeMenu", void 0);
92
+ __decorate([
93
+ property({ type: String })
94
+ ], OxMenuLandscape.prototype, "path", void 0);
95
+ OxMenuLandscape = __decorate([
96
+ customElement('ox-menu-landscape')
97
+ ], OxMenuLandscape);
98
+ export { OxMenuLandscape };
99
+ //# sourceMappingURL=ox-menu-landscape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-menu-landscape.js","sourceRoot":"","sources":["../../src/ox-menu-landscape.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,O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;IAED,YAAY,CAAC,CAAa;QACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;QAEpC,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC,EAAE,CAAC;YACrC,OAAM;QACR,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAA;QAC/B,MAAM,CAAC,UAAU,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;QAEnD,CAAC,CAAC,cAAc,EAAE,CAAA;IACpB,CAAC;;AAzFM,sBAAM,GAAG,CAAC,eAAe,EAAE,mBAAmB,CAAC,AAAzC,CAAyC;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAe;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAc;AAN9B,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA2F3B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers'\n\nimport { navigate, store } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { Menu } from './types'\nimport { MenuLandscapeStyles } from './menu-landscape-styles'\n\n@customElement('ox-menu-landscape')\nexport class OxMenuLandscape extends connect(store)(LitElement) {\n static styles = [ScrollbarStyles, MenuLandscapeStyles]\n\n @property({ type: Array }) menus?: Menu[]\n @property({ type: Object }) activeTopLevel?: Menu\n @property({ type: Object }) activeMenu!: Menu\n @property({ type: String }) path?: string\n\n render() {\n const { menus = [], activeTopLevel, activeMenu } = this\n\n return html`\n <div id=\"wrap\" @mousewheel=${this.onWheelEvent.bind(this)}>\n <ul>\n ${menus.map(menu =>\n menu.type == 'group'\n ? html``\n : html`\n <li ?active=${menu === activeTopLevel}>\n <a href=${menu.path || '#'}>\n ${menu.icon ? html`<md-icon>${menu.icon}</md-icon>` : html``} ${menu.name}\n </a>\n\n <ul submenus>\n ${menu.menus?.map(\n menu => html`\n <li ?active=${menu === activeMenu}>\n <a href=${menu.path || '#'}> ${menu.name} </a>\n </li>\n `\n )}\n </ul>\n\n <div description>\n ${menu.icon ? html`<md-icon>${menu.icon}</md-icon>` : html``} ${menu.description || ''}\n </div>\n </li>\n `\n )}\n </ul>\n </div>\n `\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('click', (e: Event) => {\n //@ts-ignore\n if (e.target.submenu) {\n /* protect to act move to href. */\n e.stopPropagation()\n e.preventDefault()\n\n //@ts-ignore\n let menu = e.target.submenu\n\n this.dispatchEvent(\n new CustomEvent('active-toplevel', {\n bubbles: true,\n detail: this.activeTopLevel === menu ? undefined : menu\n })\n )\n\n return\n }\n\n /* to respond even if current acting menu is selected */\n let href = (e.target as HTMLAnchorElement).href\n href && location.href === href && navigate(href + '#force', true)\n })\n\n /* to hide scrollbar during transition */\n this.renderRoot.addEventListener('transitionstart', e => {\n ;(e.target as HTMLElement).removeAttribute('settled')\n })\n this.renderRoot.addEventListener('transitionend', e => {\n ;(e.target as HTMLElement).setAttribute('settled', '')\n })\n }\n\n onWheelEvent(e: WheelEvent) {\n const { target, deltaY, detail } = e\n\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n const delta = deltaY || -detail\n target.scrollLeft -= (delta / Math.abs(delta)) * 10\n\n e.preventDefault()\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import '@material/web/icon/icon.js';
2
+ import './ox-menu-portrait';
3
+ import './ox-menu-landscape';
4
+ import { LitElement, PropertyValues } from 'lit';
5
+ import { Menu } from './types';
6
+ declare const OxMenuPart_base: (new (...args: any[]) => {
7
+ _storeUnsubscribe: import("redux").Unsubscribe;
8
+ connectedCallback(): void;
9
+ disconnectedCallback(): void;
10
+ stateChanged(_state: unknown): void;
11
+ readonly isConnected: boolean;
12
+ }) & typeof LitElement;
13
+ export declare class OxMenuPart extends OxMenuPart_base {
14
+ static styles: import("lit").CSSResult[];
15
+ page: string;
16
+ resourceId?: string;
17
+ menus?: Menu[];
18
+ orientation?: 'landscape' | 'portrait';
19
+ slotTemplate: any;
20
+ _activeTopLevel?: Menu;
21
+ _activeMenu?: Menu;
22
+ _path?: string;
23
+ render(): import("lit-html").TemplateResult<1>;
24
+ firstUpdated(): void;
25
+ updated(changes: PropertyValues<this>): void;
26
+ stateChanged(state: any): void;
27
+ private findActivePage;
28
+ }
29
+ export {};
@@ -0,0 +1,135 @@
1
+ import { __decorate } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import './ox-menu-portrait';
4
+ import './ox-menu-landscape';
5
+ import { css, html, LitElement } from 'lit';
6
+ import { customElement, property, state } from 'lit/decorators.js';
7
+ import { connect } from 'pwa-helpers';
8
+ import { store } from '@operato/shell';
9
+ import { ScrollbarStyles } from '@operato/styles';
10
+ function isActiveMenu(menu, path) {
11
+ var _a;
12
+ return (((_a = menu.path) === null || _a === void 0 ? void 0 : _a.split('?')[0]) === path ||
13
+ (menu.active && typeof menu.active === 'function' && menu.active.call(menu, { path })));
14
+ }
15
+ let OxMenuPart = class OxMenuPart extends connect(store)(LitElement) {
16
+ render() {
17
+ return html `
18
+ <slot name="head"></slot>
19
+ ${this.orientation !== 'landscape'
20
+ ? html `<ox-menu-portrait
21
+ .menus=${this.menus}
22
+ .activeTopLevel=${this._activeTopLevel}
23
+ .activeMenu=${this._activeMenu}
24
+ .path=${this._path}
25
+ ></ox-menu-portrait>`
26
+ : html `<ox-menu-landscape
27
+ .menus=${this.menus}
28
+ .activeTopLevel=${this._activeTopLevel}
29
+ .activeMenu=${this._activeMenu}
30
+ .path=${this._path}
31
+ ></ox-menu-landscape>`}
32
+ <slot name="tail"></slot>
33
+ `;
34
+ }
35
+ firstUpdated() {
36
+ this.renderRoot.addEventListener('active-toplevel', (e) => {
37
+ e.stopPropagation();
38
+ e.preventDefault();
39
+ this._activeTopLevel = e.detail;
40
+ });
41
+ }
42
+ updated(changes) {
43
+ if (changes.has('menus') || changes.has('page') || changes.has('resourceId')) {
44
+ this.findActivePage();
45
+ }
46
+ if (changes.has('orientation')) {
47
+ if (this.orientation == 'portrait') {
48
+ this.removeAttribute('landscape');
49
+ }
50
+ else {
51
+ this.setAttribute('landscape', '');
52
+ }
53
+ }
54
+ if (changes.has('slotTemplate')) {
55
+ this.replaceChild(this.slotTemplate, this.renderRoot);
56
+ }
57
+ }
58
+ stateChanged(state) {
59
+ this.page = state.route.page;
60
+ this.resourceId = state.route.resourceId;
61
+ this.menus = state.liteMenu.menus || [];
62
+ this.slotTemplate = state.liteMenu.slotTemplate;
63
+ }
64
+ findActivePage() {
65
+ var path = this.resourceId ? `${this.page}/${this.resourceId}` : this.page;
66
+ var menus = this.menus || [];
67
+ var activeMenu;
68
+ this._activeTopLevel = menus.find(menu => {
69
+ if (isActiveMenu(menu, path)) {
70
+ activeMenu = menu;
71
+ return true;
72
+ }
73
+ else if (menu.menus) {
74
+ activeMenu = menu.menus.find(menu => isActiveMenu(menu, path));
75
+ return !!activeMenu;
76
+ }
77
+ });
78
+ this._path = path;
79
+ this._activeMenu = activeMenu || this._activeTopLevel;
80
+ }
81
+ };
82
+ OxMenuPart.styles = [
83
+ ScrollbarStyles,
84
+ css `
85
+ :host {
86
+ display: flex;
87
+ overflow-y: auto;
88
+ flex-direction: column;
89
+ height: 100%;
90
+ min-width: 200px;
91
+ background-color: var(--theme-white-color);
92
+ }
93
+
94
+ :host([landscape]) {
95
+ overflow-x: auto;
96
+ flex-direction: row;
97
+ width: 100%;
98
+ min-height: 20px;
99
+ }
100
+
101
+ ox-menu-portrait,
102
+ ox-menu-landscape {
103
+ flex: 1;
104
+ }
105
+ `
106
+ ];
107
+ __decorate([
108
+ property({ type: String })
109
+ ], OxMenuPart.prototype, "page", void 0);
110
+ __decorate([
111
+ property({ type: String })
112
+ ], OxMenuPart.prototype, "resourceId", void 0);
113
+ __decorate([
114
+ property({ type: Array })
115
+ ], OxMenuPart.prototype, "menus", void 0);
116
+ __decorate([
117
+ property({ type: String })
118
+ ], OxMenuPart.prototype, "orientation", void 0);
119
+ __decorate([
120
+ state()
121
+ ], OxMenuPart.prototype, "slotTemplate", void 0);
122
+ __decorate([
123
+ state()
124
+ ], OxMenuPart.prototype, "_activeTopLevel", void 0);
125
+ __decorate([
126
+ state()
127
+ ], OxMenuPart.prototype, "_activeMenu", void 0);
128
+ __decorate([
129
+ state()
130
+ ], OxMenuPart.prototype, "_path", void 0);
131
+ OxMenuPart = __decorate([
132
+ customElement('ox-menu-part')
133
+ ], OxMenuPart);
134
+ export { OxMenuPart };
135
+ //# sourceMappingURL=ox-menu-part.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-menu-part.js","sourceRoot":"","sources":["../../src/ox-menu-part.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,oBAAoB,CAAA;AAC3B,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAIjD,SAAS,YAAY,CAAC,IAAU,EAAE,IAAY;;IAC5C,OAAO,CACL,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,MAAK,IAAI;QACjC,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AAI,CAAC,CAAC,CAAA;gBAC9D,OAAO,CAAC,CAAC,UAAU,CAAA;YACrB,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,WAAW,GAAG,UAAU,IAAI,IAAI,CAAC,eAAe,CAAA;IACvD,CAAC;;AA3GM,iBAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBF;CACF,AAxBY,CAwBZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoB;AACpB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAe;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAuC;AAEzD;IAAR,KAAK,EAAE;gDAAkB;AACjB;IAAR,KAAK,EAAE;mDAAuB;AACtB;IAAR,KAAK,EAAE;+CAAmB;AAClB;IAAR,KAAK,EAAE;yCAAe;AAnCZ,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CA6GtB","sourcesContent":["import '@material/web/icon/icon.js'\nimport './ox-menu-portrait'\nimport './ox-menu-landscape'\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers'\n\nimport { store } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { Menu } from './types'\n\nfunction isActiveMenu(menu: Menu, path: string) {\n return (\n menu.path?.split('?')[0] === path ||\n (menu.active && typeof menu.active === 'function' && menu.active.call(menu, { path }))\n )\n}\n\n@customElement('ox-menu-part')\nexport class OxMenuPart extends connect(store)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n overflow-y: auto;\n flex-direction: column;\n height: 100%;\n min-width: 200px;\n background-color: var(--theme-white-color);\n }\n\n :host([landscape]) {\n overflow-x: auto;\n flex-direction: row;\n width: 100%;\n min-height: 20px;\n }\n\n ox-menu-portrait,\n ox-menu-landscape {\n flex: 1;\n }\n `\n ]\n\n @property({ type: String }) page!: string\n @property({ type: String }) resourceId?: string\n @property({ type: Array }) menus?: Menu[]\n @property({ type: String }) orientation?: 'landscape' | 'portrait'\n\n @state() slotTemplate: any\n @state() _activeTopLevel?: Menu\n @state() _activeMenu?: Menu\n @state() _path?: string\n\n render() {\n return html`\n <slot name=\"head\"></slot>\n ${this.orientation !== 'landscape'\n ? html`<ox-menu-portrait\n .menus=${this.menus}\n .activeTopLevel=${this._activeTopLevel}\n .activeMenu=${this._activeMenu}\n .path=${this._path}\n ></ox-menu-portrait>`\n : html`<ox-menu-landscape\n .menus=${this.menus}\n .activeTopLevel=${this._activeTopLevel}\n .activeMenu=${this._activeMenu}\n .path=${this._path}\n ></ox-menu-landscape>`}\n <slot name=\"tail\"></slot>\n `\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('active-toplevel', (e: Event) => {\n e.stopPropagation()\n e.preventDefault()\n\n this._activeTopLevel = (e as CustomEvent).detail\n })\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('menus') || changes.has('page') || changes.has('resourceId')) {\n this.findActivePage()\n }\n\n if (changes.has('orientation')) {\n if (this.orientation == 'portrait') {\n this.removeAttribute('landscape')\n } else {\n this.setAttribute('landscape', '')\n }\n }\n\n if (changes.has('slotTemplate')) {\n this.replaceChild(this.slotTemplate, this.renderRoot)\n }\n }\n\n stateChanged(state: any): void {\n this.page = state.route.page\n this.resourceId = state.route.resourceId\n this.menus = state.liteMenu.menus || []\n this.slotTemplate = state.liteMenu.slotTemplate\n }\n\n private findActivePage() {\n var path = this.resourceId ? `${this.page}/${this.resourceId}` : this.page\n var menus = this.menus || []\n var activeMenu\n\n this._activeTopLevel = menus.find(menu => {\n if (isActiveMenu(menu, path)) {\n activeMenu = menu\n return true\n } else if (menu.menus) {\n activeMenu = menu.menus.find(menu => isActiveMenu(menu, path))\n return !!activeMenu\n }\n })\n\n this._path = path\n this._activeMenu = activeMenu || this._activeTopLevel\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { LitElement, nothing, TemplateResult } from 'lit';
3
+ import { Menu } from './types';
4
+ export declare class OxMenuPortrait extends LitElement {
5
+ static styles: import("lit").CSSResult[];
6
+ menus?: Menu[];
7
+ activeTopLevel?: Menu;
8
+ activeMenu?: Menu;
9
+ path: string;
10
+ renderMenus(menus: Menu[], activeTopLevel?: Menu, activeMenu?: Menu): TemplateResult | typeof nothing;
11
+ render(): TemplateResult | typeof nothing;
12
+ firstUpdated(): void;
13
+ }
@@ -0,0 +1,88 @@
1
+ import { __decorate } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import { html, LitElement, nothing } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { navigate } from '@operato/shell';
6
+ import { ScrollbarStyles } from '@operato/styles';
7
+ import { MenuPortraitStyles } from './menu-portrait-styles';
8
+ let OxMenuPortrait = class OxMenuPortrait extends LitElement {
9
+ renderMenus(menus, activeTopLevel, activeMenu) {
10
+ if (menus.length == 0) {
11
+ return nothing;
12
+ }
13
+ return html `
14
+ <ul>
15
+ ${menus.map(menu => {
16
+ var { type, active, path, name, badge, icon, menus = [] } = menu;
17
+ active = active && typeof active === 'function' ? active.call(menu, { path: this.path }) : false;
18
+ badge = typeof badge === 'function' ? badge.call(menu) : badge !== null && badge !== void 0 ? badge : false;
19
+ return type == 'group'
20
+ ? html `<li group-label>${name}</li>`
21
+ : html `
22
+ <li ?active=${activeTopLevel ? menu === activeTopLevel : active} .menu=${menu} menu>
23
+ <a href=${path || '#'}>
24
+ <md-icon>${icon || 'fiber_manual_record'}</md-icon>
25
+ ${name} ${badge !== false ? html `<div badge>${badge}</div>` : html ``}
26
+ ${menus.length > 0 ? html ` <md-icon submenu-button></md-icon> ` : html ``}
27
+ </a>
28
+ ${menus && this.renderMenus(menus || [], activeMenu)}
29
+ </li>
30
+ `;
31
+ })}
32
+ </ul>
33
+ `;
34
+ }
35
+ render() {
36
+ const { menus, activeTopLevel, activeMenu } = this;
37
+ return this.renderMenus(menus || [], activeTopLevel, activeMenu);
38
+ }
39
+ firstUpdated() {
40
+ this.renderRoot.addEventListener('click', (e) => {
41
+ const menuElement = e.target.closest('[menu]');
42
+ //@ts-ignore
43
+ if (menuElement === null || menuElement === void 0 ? void 0 : menuElement.menu) {
44
+ //@ts-ignore
45
+ let menu = menuElement.menu;
46
+ if (!menu.path) {
47
+ /* protect to act move to href. */
48
+ e.stopPropagation();
49
+ e.preventDefault();
50
+ }
51
+ this.dispatchEvent(new CustomEvent('active-toplevel', {
52
+ bubbles: true,
53
+ detail: this.activeTopLevel === menu ? undefined : menu
54
+ }));
55
+ }
56
+ /* to respond even if current acting menu is selected */
57
+ let href = e.target.href;
58
+ href && location.href === href && navigate(href + '#force', true);
59
+ });
60
+ /* to hide scrollbar during transition */
61
+ this.renderRoot.addEventListener('transitionstart', e => {
62
+ ;
63
+ e.target.removeAttribute('settled');
64
+ });
65
+ this.renderRoot.addEventListener('transitionend', e => {
66
+ ;
67
+ e.target.setAttribute('settled', '');
68
+ });
69
+ }
70
+ };
71
+ OxMenuPortrait.styles = [ScrollbarStyles, MenuPortraitStyles];
72
+ __decorate([
73
+ property({ type: Array })
74
+ ], OxMenuPortrait.prototype, "menus", void 0);
75
+ __decorate([
76
+ property({ type: Object })
77
+ ], OxMenuPortrait.prototype, "activeTopLevel", void 0);
78
+ __decorate([
79
+ property({ type: Object })
80
+ ], OxMenuPortrait.prototype, "activeMenu", void 0);
81
+ __decorate([
82
+ property({ type: String })
83
+ ], OxMenuPortrait.prototype, "path", void 0);
84
+ OxMenuPortrait = __decorate([
85
+ customElement('ox-menu-portrait')
86
+ ], OxMenuPortrait);
87
+ export { OxMenuPortrait };
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AAc,CA8E1B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { html, LitElement, nothing, TemplateResult } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { navigate } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { Menu } from './types'\nimport { MenuPortraitStyles } from './menu-portrait-styles'\n\n@customElement('ox-menu-portrait')\nexport class OxMenuPortrait extends LitElement {\n static styles = [ScrollbarStyles, MenuPortraitStyles]\n\n @property({ type: Array }) menus?: Menu[]\n @property({ type: Object }) activeTopLevel?: Menu\n @property({ type: Object }) activeMenu?: Menu\n @property({ type: String }) path!: string\n\n renderMenus(menus: Menu[], activeTopLevel?: Menu, activeMenu?: Menu): TemplateResult | typeof nothing {\n if (menus.length == 0) {\n return nothing\n }\n\n return html`\n <ul>\n ${menus.map(menu => {\n var { type, active, path, name, badge, icon, menus = [] } = menu\n active = active && typeof active === 'function' ? active.call(menu, { path: this.path }) : false\n badge = typeof badge === 'function' ? badge.call(menu) : badge ?? false\n\n return type == 'group'\n ? html`<li group-label>${name}</li>`\n : html`\n <li ?active=${activeTopLevel ? menu === activeTopLevel : active} .menu=${menu} menu>\n <a href=${path || '#'}>\n <md-icon>${icon || 'fiber_manual_record'}</md-icon>\n ${name} ${badge !== false ? html`<div badge>${badge}</div>` : html``}\n ${menus.length > 0 ? html` <md-icon submenu-button></md-icon> ` : html``}\n </a>\n ${menus && this.renderMenus(menus || [], activeMenu)}\n </li>\n `\n })}\n </ul>\n `\n }\n\n render() {\n const { menus, activeTopLevel, activeMenu } = this\n return this.renderMenus(menus || [], activeTopLevel, activeMenu)\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('click', (e: Event) => {\n const menuElement = (e.target as Element)!.closest('[menu]')\n\n //@ts-ignore\n if (menuElement?.menu) {\n //@ts-ignore\n let menu = menuElement.menu\n\n if (!menu.path) {\n /* protect to act move to href. */\n e.stopPropagation()\n e.preventDefault()\n }\n\n this.dispatchEvent(\n new CustomEvent('active-toplevel', {\n bubbles: true,\n detail: this.activeTopLevel === menu ? undefined : menu\n })\n )\n }\n\n /* to respond even if current acting menu is selected */\n let href = (e.target as HTMLAnchorElement)!.href\n href && location.href === href && navigate(href + '#force', true)\n })\n\n /* to hide scrollbar during transition */\n this.renderRoot.addEventListener('transitionstart', e => {\n ;(e.target as Element).removeAttribute('settled')\n })\n this.renderRoot.addEventListener('transitionend', e => {\n ;(e.target as Element).setAttribute('settled', '')\n })\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { LitElement, PropertyValueMap, TemplateResult } from 'lit';
3
+ import { Menu } from './types';
4
+ declare const OxTopMenuBar_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & typeof LitElement;
11
+ export declare class OxTopMenuBar extends OxTopMenuBar_base {
12
+ static styles: import("lit").CSSResult[];
13
+ page?: string;
14
+ resourceId?: string;
15
+ menus?: Menu[];
16
+ slotTemplate: Node;
17
+ private _activeTopLevel?;
18
+ render(): TemplateResult<1>;
19
+ stateChanged(state: any): void;
20
+ updated(changes: PropertyValueMap<this>): void;
21
+ _findActivePage(): void;
22
+ }
23
+ export {};