lupine.web 1.0.15 → 1.0.17

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 (78) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -5
  3. package/src/core/bind-lang.ts +6 -5
  4. package/src/core/bind-links.ts +2 -2
  5. package/src/core/bind-meta.tsx +52 -0
  6. package/src/core/bind-theme.ts +11 -9
  7. package/src/core/export-lupine.ts +64 -0
  8. package/src/core/index.ts +3 -1
  9. package/src/core/{core.ts → initialize.ts} +12 -79
  10. package/src/core/page-router.ts +3 -2
  11. package/src/core/server-cookie.ts +5 -3
  12. package/src/index.ts +2 -3
  13. package/src/lib/index.ts +2 -13
  14. package/src/lib/is-frontend.ts +3 -0
  15. package/src/models/index.ts +2 -0
  16. package/src/models/json-props.ts +8 -0
  17. package/src/models/theme-props.ts +7 -0
  18. package/src/{types → styles}/index.ts +0 -2
  19. package/src/assets/themes/base-themes.ts +0 -16
  20. package/src/assets/themes/dark-themes.ts +0 -85
  21. package/src/assets/themes/index.ts +0 -4
  22. package/src/assets/themes/light-themes.ts +0 -92
  23. package/src/assets/themes/shared-themes.ts +0 -50
  24. package/src/components/button-push-animation.tsx +0 -138
  25. package/src/components/button.tsx +0 -55
  26. package/src/components/drag-refresh.tsx +0 -110
  27. package/src/components/editable-label.tsx +0 -83
  28. package/src/components/float-window.tsx +0 -226
  29. package/src/components/grid.tsx +0 -18
  30. package/src/components/html-var.tsx +0 -41
  31. package/src/components/index.ts +0 -36
  32. package/src/components/input-with-title.tsx +0 -24
  33. package/src/components/link-item.tsx +0 -13
  34. package/src/components/link-list.tsx +0 -62
  35. package/src/components/menu-bar.tsx +0 -220
  36. package/src/components/menu-item-props.tsx +0 -10
  37. package/src/components/menu-sidebar.tsx +0 -289
  38. package/src/components/message-box.tsx +0 -44
  39. package/src/components/meta-data.tsx +0 -54
  40. package/src/components/meta-description.tsx +0 -19
  41. package/src/components/meta-title.tsx +0 -19
  42. package/src/components/modal.tsx +0 -29
  43. package/src/components/notice-message.tsx +0 -119
  44. package/src/components/paging-link.tsx +0 -100
  45. package/src/components/panel.tsx +0 -24
  46. package/src/components/popup-menu.tsx +0 -218
  47. package/src/components/progress.tsx +0 -91
  48. package/src/components/redirect.tsx +0 -19
  49. package/src/components/resizable-splitter.tsx +0 -129
  50. package/src/components/select-with-title.tsx +0 -37
  51. package/src/components/spinner.tsx +0 -100
  52. package/src/components/svg.tsx +0 -24
  53. package/src/components/tabs.tsx +0 -252
  54. package/src/components/text-glow.tsx +0 -36
  55. package/src/components/text-wave.tsx +0 -54
  56. package/src/components/theme-selector.tsx +0 -35
  57. package/src/components/toggle-base.tsx +0 -260
  58. package/src/components/toggle-switch.tsx +0 -156
  59. package/src/lib/date-utils.ts +0 -317
  60. package/src/lib/deep-merge.ts +0 -37
  61. package/src/lib/document-ready.ts +0 -36
  62. package/src/lib/dom/calculate-text-width.ts +0 -13
  63. package/src/lib/dom/download-stream.ts +0 -17
  64. package/src/lib/dom/download.ts +0 -12
  65. package/src/lib/dom/index.ts +0 -71
  66. package/src/lib/dynamical-load.ts +0 -138
  67. package/src/lib/format-bytes.ts +0 -11
  68. package/src/lib/lite-dom.ts +0 -227
  69. package/src/lib/message-hub.ts +0 -105
  70. package/src/lib/observable.ts +0 -188
  71. package/src/lib/promise-timeout.ts +0 -1
  72. package/src/lib/simple-storage.ts +0 -40
  73. package/src/lib/stop-propagation.ts +0 -7
  74. package/src/lib/upload-file.ts +0 -68
  75. package/src/types/css-types.ts +0 -17
  76. package/src/types/media-query.ts +0 -93
  77. /package/src/lib/{dom/cookie.ts → cookie.ts} +0 -0
  78. /package/src/{types → styles}/css-styles.ts +0 -0
@@ -1,226 +0,0 @@
1
- import { mountComponents } from '../core';
2
- import { CssProps, RefProps, VNode } from '../jsx';
3
- import { stopPropagation } from '../lib';
4
-
5
- export type FloatWindowCloseProps = () => void;
6
-
7
- export type FloatWindowShowProps = {
8
- title: string;
9
- children: VNode<any>;
10
- buttons?: string[];
11
- contentMaxHeight?: string;
12
- contentMinWidth?: string;
13
- noMoving?: boolean;
14
- noModal?: boolean;
15
- closeEvent?: () => void;
16
- handleClicked: (index: number, close: FloatWindowCloseProps) => void;
17
- closeWhenClickOutside?: boolean; // default false
18
- };
19
-
20
- // because it's over a mask, so it can use primary colors
21
- export class FloatWindow {
22
- static hostNode: HTMLElement;
23
-
24
- private static initialized = false;
25
- private static pressed = false;
26
- private static startX = 0;
27
- private static startY = 0;
28
- private static startTop = 0;
29
- private static startLeft = 0;
30
-
31
- static init() {
32
- window.addEventListener('mousemove', FloatWindow.onMousemove.bind(FloatWindow), false);
33
- document.documentElement.addEventListener('mouseup', FloatWindow.onMouseup.bind(FloatWindow), false);
34
- }
35
-
36
- static async show({
37
- title,
38
- children,
39
- contentMaxHeight,
40
- contentMinWidth,
41
- buttons,
42
- noMoving = false,
43
- noModal = false,
44
- closeEvent,
45
- handleClicked,
46
- closeWhenClickOutside = false,
47
- }: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
48
- const onClickContainer = (event: any) => {
49
- if (closeWhenClickOutside !== false && event.target.className === 'fwin-box') {
50
- handleClose();
51
- }
52
- };
53
- const handleClose = () => {
54
- closeEvent?.();
55
- ref.current.classList.add('transition');
56
- ref.current.classList.remove('animation');
57
- setTimeout(() => {
58
- base.remove();
59
- }, 300);
60
- };
61
-
62
- const base = document.createElement('div');
63
- const onMousedown = (event: any) => {
64
- if (noMoving) return;
65
-
66
- if (!this.initialized) {
67
- this.initialized = true;
68
- this.init();
69
- }
70
-
71
- FloatWindow.hostNode = ref.current;
72
- FloatWindow.onMousedown.bind(FloatWindow)(event);
73
- };
74
-
75
- const newButtons = !buttons || buttons.length === 0 ? ['OK', 'Cancel'] : buttons;
76
- const onClickButtons = (index: number) => {
77
- handleClicked(index, handleClose);
78
- };
79
-
80
- const ref: RefProps = {
81
- onLoad: async () => {
82
- ref.current.classList.add('transition', 'animation');
83
- setTimeout(() => {
84
- // don't need transition for moving
85
- ref.current.classList.remove('transition');
86
- }, 300);
87
- },
88
- };
89
- const cssContainer: CssProps = {
90
- position: noModal ? '' : 'fixed',
91
- top: 0,
92
- left: 0,
93
- width: '100%',
94
- height: '100%',
95
- backgroundColor: noModal ? '' : 'var(--cover-mask-bg-color)',
96
- '.fwin-body': {
97
- position: 'fixed',
98
- top: '50%',
99
- left: '50%',
100
- transform: 'translate(-50%, -50%) scale(0.1)',
101
- color: 'var(--primary-color)',
102
- backgroundColor: 'var(--cover-bg-color)', //'#fefefe',
103
- border: 'var(--primary-border)', //'1px solid #888',
104
- borderRadius: '6px',
105
- minWidth: contentMinWidth ? contentMinWidth : '',
106
- maxWidth: '90%',
107
- boxShadow: 'var(--cover-box-shadow)', //'#0000004c 0px 19px 38px, #00000038 0px 15px 12px',
108
- opacity: 0,
109
- zIndex: 'var(--layer-float-window)',
110
- '&.transition': {
111
- transition: 'all 0.3s',
112
- },
113
- '&.animation': {
114
- transform: 'translate(-50%, -50%) scale(1)',
115
- opacity: 1,
116
- },
117
- '&.animation-close': {
118
- transition: 'all 0.3s',
119
- transform: 'translate(-50%, -50%) scale(0)',
120
- opacity: 0,
121
- },
122
- '.fwin-title': {
123
- padding: '10px 15px 5px',
124
- borderBottom: 'var(--primary-border)', //'1px solid #e9ecef',
125
- '.fwin-close': {
126
- color: '#aaaaaa',
127
- float: 'right',
128
- fontSize: '26px',
129
- fontWeight: 'bold',
130
- cursor: 'pointer',
131
- marginTop: '-8px',
132
- marginRight: '-10px',
133
- },
134
- '.fwin-close:hover': {
135
- transition: 'all 300ms ease',
136
- color: '#555555',
137
- },
138
- },
139
- '.fwin-content': {
140
- padding: '15px',
141
- maxHeight: contentMaxHeight ? `min(${contentMaxHeight}, calc(100% - 100px))` : 'calc(100% - 100px)',
142
- overflowY: 'auto',
143
- },
144
- '.fwin-bottom': {
145
- display: 'flex',
146
- padding: '5px 15px',
147
- borderTop: 'var(--primary-border)', //'1px solid #e9ecef',
148
- justifyContent: 'end',
149
- '>div': {
150
- marginLeft: '5px',
151
- },
152
- },
153
- },
154
- };
155
- const component = (
156
- <div css={cssContainer} class='fwin-box' onClick={onClickContainer}>
157
- <div ref={ref} class='fwin-body' onMouseDown={onMousedown}>
158
- <div class='fwin-title'>
159
- {title}
160
- <span class='fwin-close' onClick={handleClose}>
161
- ×
162
- </span>
163
- </div>
164
- <div class='fwin-content'>{children}</div>
165
- <div class='fwin-bottom'>
166
- {newButtons.map((i, index) => (
167
- <button
168
- class='button-base button-s mr-m'
169
- onClick={() => {
170
- onClickButtons(index);
171
- }}
172
- >
173
- {i}
174
- </button>
175
- ))}
176
- </div>
177
- </div>
178
- </div>
179
- );
180
- base.style.position = 'fixed';
181
- document.body.appendChild(base);
182
- await mountComponents(base, component);
183
- return handleClose;
184
- }
185
-
186
- static onMousedown(event: any) {
187
- if (event.buttons !== 1 || event.button !== 0) return;
188
- if (event.srcElement.className !== 'fwin-title') return;
189
-
190
- this.pressed = true;
191
- this.startX = event.clientX;
192
- this.startY = event.clientY;
193
- const nodeStyle = document.defaultView!.getComputedStyle(this.hostNode);
194
- this.startTop = parseInt(nodeStyle['top'], 10);
195
- this.startLeft = parseInt(nodeStyle['left'], 10);
196
- }
197
-
198
- static onMousemove(event: any) {
199
- if (!this.pressed || event.buttons !== 1 || event.button !== 0) {
200
- return;
201
- }
202
-
203
- // prevent text/element selection when drag
204
- stopPropagation(event);
205
- if (
206
- event.clientX < 0 ||
207
- event.clientY < 0 ||
208
- event.clientX > window.innerWidth ||
209
- event.clientY > window.innerHeight
210
- ) {
211
- return;
212
- }
213
-
214
- let movedX = this.startLeft + (event.clientX - this.startX);
215
- let movedY = this.startTop + (event.clientY - this.startY);
216
- if (movedY <= 0) movedY = 0;
217
- if (movedX <= 0) movedX = 0;
218
-
219
- this.hostNode.style.top = movedY + 'px';
220
- this.hostNode.style.left = movedX + 'px';
221
- }
222
-
223
- static onMouseup() {
224
- if (this.pressed) this.pressed = false;
225
- }
226
- }
@@ -1,18 +0,0 @@
1
- export const Grid = ({ gridOption }: { gridOption: any }) => {
2
- const cssContainer: any = {
3
- display: 'grid',
4
- ...gridOption.options,
5
- };
6
- const cells: any = [];
7
- gridOption.cells.forEach((cell: any, index: number) => {
8
- const name = cell.name || 'cell' + index;
9
- cssContainer[`.${name}`] = cell.option;
10
- cells.push(<div class={name}>{cell.component}</div>);
11
- });
12
- const className = 'grid-box' + (gridOption.className ? ` ${gridOption.className}` : '');
13
- return (
14
- <div css={cssContainer} class={className}>
15
- {cells}
16
- </div>
17
- );
18
- };
@@ -1,41 +0,0 @@
1
- import { mountComponents } from '../core/mount-components';
2
- import { RefProps, VNode } from '../jsx';
3
-
4
- export const HtmlVar = (initial?: string | VNode<any>) => {
5
- let _value: string | VNode<any> = initial || '';
6
- let _dirty = false;
7
- const waitUpdate = async (value: string | VNode<any>) => {
8
- if (!ref.current) return;
9
- if (typeof value === 'object' && value.type && value.props) {
10
- await mountComponents(ref.current, value);
11
- } else {
12
- ref.current.innerHTML = value;
13
- }
14
- _dirty = false;
15
- }
16
- const ref: RefProps = { onLoad: async (el: Element) => {
17
- _dirty && waitUpdate(_value);
18
- } };
19
- const FragmentRef = (props: any) => {
20
- return <>{props.children}</>;
21
- };
22
-
23
- return {
24
- set value(value: string | VNode<any>) {
25
- _value = value;
26
- _dirty = true;
27
- waitUpdate(value);
28
- },
29
- get value() {
30
- return ref.current ? ref.current.innerHTML : _value;
31
- },
32
- get ref() {
33
- return ref;
34
- },
35
- // _fragment_ref is a special id to add ref to a fragment and it is processed in mount-components
36
- get node() {
37
- _dirty = false;
38
- return <FragmentRef _fragment_ref={ref}>{_value}</FragmentRef>;
39
- },
40
- };
41
- };
@@ -1,36 +0,0 @@
1
-
2
- export * from './button-push-animation';
3
- export * from './button';
4
- export * from './drag-refresh';
5
- export * from './editable-label';
6
- export * from './float-window';
7
- export * from './grid';
8
- export * from './html-var';
9
- export * from './input-with-title';
10
- export * from './link-item';
11
- export * from './link-list';
12
- export * from './menu-bar';
13
- export * from './menu-item-props';
14
- export * from './menu-sidebar';
15
- export * from './message-box';
16
- export * from './meta-data';
17
- export * from './meta-title';
18
- export * from './meta-description';
19
- export * from './meta-title';
20
- export * from './modal';
21
- export * from './notice-message';
22
- export * from './paging-link';
23
- export * from './panel';
24
- export * from './popup-menu';
25
- export * from './progress';
26
- export * from './redirect';
27
- export * from './resizable-splitter';
28
- export * from './select-with-title';
29
- export * from './spinner';
30
- export * from './svg';
31
- export * from './text-glow';
32
- export * from './text-wave';
33
- export * from './tabs';
34
- export * from './theme-selector';
35
- export * from './toggle-base';
36
- export * from './toggle-switch';
@@ -1,24 +0,0 @@
1
- // used in MessageBox.show
2
- export const InputWithTitle = (
3
- title: string,
4
- defaultValue: string,
5
- onInputChanged?: (option: string) => void,
6
- onInputInputed?: (option: string) => void,
7
- className = 'input-base',
8
- width = '100%',
9
- ) => {
10
- return (
11
- <div>
12
- <div>{title}</div>
13
- <div>
14
- <input
15
- class={className}
16
- style={{ width }}
17
- onChange={(e: any) => onInputChanged?.(e?.target?.value)}
18
- onInput={(e: any) => onInputInputed?.(e?.target?.value)}
19
- value={defaultValue}
20
- />
21
- </div>
22
- </div>
23
- );
24
- };
@@ -1,13 +0,0 @@
1
- export type LinkItemProps = {
2
- className?: string;
3
- text: string;
4
- url: string;
5
- alt?: string;
6
- };
7
- export const LinkItem = (props: LinkItemProps) => {
8
- return (
9
- <a class={['link-item', props.className].join(' ')} href={props.url} alt={props.alt || props.text}>
10
- {props.text}
11
- </a>
12
- );
13
- };
@@ -1,62 +0,0 @@
1
- import { LinkItem } from './link-item';
2
- import { NestMenuItemProps } from './menu-item-props';
3
-
4
- export type LinkListProps = {
5
- title: string;
6
- items: NestMenuItemProps[];
7
- className?: string;
8
- textColor?: string;
9
- backgroundColor?: string;
10
- titleBackgroundColor?: string;
11
- };
12
- export const LinkList = ({
13
- title,
14
- items,
15
- className,
16
- textColor = 'black',
17
- backgroundColor = '#d3d3d3',
18
- titleBackgroundColor = '#b6b6b6',
19
- }: LinkListProps) => {
20
- const css: any = {
21
- width: '100%',
22
- margin: 'auto',
23
- height: 'auto',
24
- backgroundColor,
25
- '.link-list-title, .link-list-top': {
26
- display: 'flex',
27
- width: '100%',
28
- flexWrap: 'wrap',
29
- padding: '0 16px',
30
- },
31
- '.link-list-title': {
32
- backgroundColor: titleBackgroundColor,
33
- },
34
- '.link-list-item': {
35
- display: 'inline-block',
36
- color: textColor,
37
- padding: '8px 16px 8px 0',
38
- textDecoration: 'none',
39
- },
40
- '.link-list-item:last-child': {
41
- paddingRight: 'unset',
42
- },
43
- '.link-list-title .link-list-item': {
44
- fontSize: '18px',
45
- },
46
- };
47
-
48
- return (
49
- <div css={css} class={['link-list-box', className].join(' ')}>
50
- {title && (
51
- <div class='link-list-title'>
52
- <div class='link-list-item'>{title}</div>
53
- </div>
54
- )}
55
- <div class='link-list-top'>
56
- {items.map((item) => {
57
- return <LinkItem className='link-list-item' url={item.url} alt={item.alt} text={item.text} />;
58
- })}
59
- </div>
60
- </div>
61
- );
62
- };
@@ -1,220 +0,0 @@
1
- import { getRenderPageProps } from '../core';
2
- import { RefProps } from '../jsx';
3
- import { MediaQueryMaxWidth } from '../types';
4
- import { LinkItem } from './link-item';
5
- import { NestMenuItemProps } from './menu-item-props';
6
-
7
- const fetchMenu = async (menuId: string) => {
8
- const data = await getRenderPageProps().renderPageFunctions.fetchData(`/api/menu/get/${menuId}`);
9
- return data.json;
10
- };
11
-
12
- export type MenuBarProps = {
13
- menuId?: string;
14
- items: NestMenuItemProps[];
15
- className?: string;
16
- textColor?: string;
17
- hoverColor?: string;
18
- hoverBgColor?: string;
19
- maxWidthMobileMenu?: string;
20
- maxWidth?: string;
21
- backgroundColor?: string;
22
- };
23
- export const MenuBar = ({
24
- menuId,
25
- items,
26
- className,
27
- textColor = 'var(--menubar-color)',
28
- backgroundColor = 'var(--menubar-bg-color)', //'black',
29
- hoverColor = 'var(--activatable-color-hover)', //'#ffffff',
30
- hoverBgColor = 'var(--activatable-bg-color-hover)', //'#d12121',
31
- maxWidth = '100%',
32
- maxWidthMobileMenu = MediaQueryMaxWidth.TabletMax,
33
- }: MenuBarProps) => {
34
- const css: any = {
35
- width: '100%',
36
- maxWidth: maxWidth,
37
- margin: 'auto',
38
- // height: 'auto',
39
- backgroundColor,
40
- position: 'relative',
41
- '.menu-bar-top': {
42
- display: 'flex',
43
- width: '100%',
44
- justifyContent: 'center',
45
- },
46
- '.menu-bar-item': {
47
- display: 'inline-block',
48
- color: textColor,
49
- padding: '14px 16px',
50
- textDecoration: 'none',
51
- position: 'relative',
52
- },
53
- '.menu-bar-item:hover, .menu-bar-sub-box:hover > .menu-bar-item': {
54
- // for desktop, make parent menu hover when sub menu is hover
55
- color: hoverColor,
56
- backgroundColor: hoverBgColor,
57
- },
58
- '.menu-bar-sub-box .menu-bar-sub': {
59
- display: 'none',
60
- position: 'absolute',
61
- backgroundColor: 'var(--menubar-sub-bg-color)', //'#f9f9f9',
62
- minWidth: '160px',
63
- boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
64
- zIndex: 'var(--layer-menu-sub)',
65
- flexDirection: 'column',
66
- },
67
- '.menu-bar-sub-box > .menu-bar-item': {
68
- padding: '14px 26px 14px 16px',
69
- width: '100%',
70
- },
71
- '.menu-bar-sub-box > .menu-bar-item::after': {
72
- content: '""',
73
- position: 'absolute',
74
- top: '50%',
75
- transform: 'translateY(-50%)',
76
- marginLeft: '6px',
77
- width: 0,
78
- height: 0,
79
- borderLeft: '5px solid transparent',
80
- borderRight: '5px solid transparent',
81
- borderTop: '5px solid ' + textColor,
82
- },
83
- '.menu-bar-sub-box .menu-bar-sub > .menu-bar-item': {
84
- color: 'black',
85
- },
86
- '.menu-bar-sub-box:hover > .menu-bar-sub': {
87
- display: 'flex',
88
- },
89
- '.menu-bar-sub-box .menu-bar-sub .menu-bar-item:hover': {
90
- // backgroundColor: '#ddd',
91
- color: hoverColor,
92
- backgroundColor: hoverBgColor,
93
- },
94
- '.menu-bar-mobile': {
95
- display: 'none',
96
- position: 'relative',
97
- backgroundColor,
98
- padding: '5px 18px 6px',
99
- '.menu-bar-toggle': {
100
- cursor: 'pointer',
101
- padding: '14px 0 19px 0',
102
- 'span, span::before, span::after': {
103
- cursor: 'pointer',
104
- height: '3px',
105
- width: '25px',
106
- borderRadius: '1px',
107
- background: '#ffffff',
108
- position: 'absolute',
109
- display: 'block',
110
- transition: 'all 300ms ease-in-out',
111
- },
112
- 'span::before, span::after': {
113
- content: '""',
114
- },
115
- 'span::before': {
116
- top: '-10px',
117
- },
118
- 'span::after': {
119
- bottom: '-10px',
120
- },
121
- },
122
- '.menu-bar-toggle.active span': {
123
- backgroundColor: 'transparent',
124
- },
125
- '.menu-bar-toggle.active span::before': {
126
- transform: 'rotate(45deg)',
127
- top: 0,
128
- },
129
- '.menu-bar-toggle.active span::after': {
130
- transform: 'rotate(-45deg)',
131
- top: 0,
132
- },
133
- },
134
- ['@media only screen and (max-width: ' + maxWidthMobileMenu + ')']: {
135
- '.menu-bar-mobile': {
136
- display: 'block',
137
- },
138
- '.menu-bar-top': {
139
- display: 'none',
140
- },
141
- '.menu-bar-top.open': {
142
- display: 'flex',
143
- flexDirection: 'column',
144
- },
145
- '.menu-bar-top.open .menu-bar-sub-box > .menu-bar-sub': {
146
- display: 'flex',
147
- position: 'unset',
148
- '.menu-bar-item': {
149
- paddingLeft: '32px',
150
- color: textColor,
151
- backgroundColor,
152
- },
153
- '.menu-bar-item:hover': {
154
- color: hoverColor,
155
- backgroundColor: hoverBgColor,
156
- },
157
- },
158
- '.menu-bar-sub-box:hover > .menu-bar-item': {
159
- // for mobile, no parent menu hover when sub menu is hover
160
- color: textColor,
161
- backgroundColor: backgroundColor,
162
- },
163
- '.menu-bar-sub-box:hover > .menu-bar-item:hover': {
164
- color: hoverColor,
165
- backgroundColor: hoverBgColor,
166
- },
167
- },
168
- };
169
-
170
- const renderItems = (items: NestMenuItemProps[], className: string) => {
171
- return (
172
- <div class={className}>
173
- {items.map((item) => {
174
- return item.items ? (
175
- <div class='menu-bar-sub-box'>
176
- <div class='menu-bar-item'>{item.text}</div>
177
- {renderItems(item.items, 'menu-bar-sub')}
178
- </div>
179
- ) : (
180
- <LinkItem className='menu-bar-item' url={item.url} alt={item.alt} text={item.text} />
181
- );
182
- })}
183
- </div>
184
- );
185
- };
186
-
187
- const ref: RefProps = {
188
- onLoad: async () => {
189
- if (menuId) {
190
- const menu = await fetchMenu(menuId);
191
- if (menu.result && menu.result.items.length > 0) {
192
- const items = menu.result.items.map((i: any) => {
193
- const l = i.split('\t');
194
- return { text: l[5], url: l[4] };
195
- });
196
- const newDom = renderItems(items, 'menu-bar-top');
197
- //mountComponents('.menu-bar-top', newDom);
198
- }
199
- }
200
- },
201
- };
202
- const onToggleClick = () => {
203
- const menu = ref.$('.menu-bar-mobile .menu-bar-toggle');
204
- menu.classList.toggle('active');
205
- const topMenu = ref.$('.menu-bar-top');
206
- topMenu.classList.toggle('open');
207
- };
208
-
209
- return (
210
- <div ref={ref} css={css} class={['menu-bar-box', className].join(' ')}>
211
- <div class='menu-bar-mobile'>
212
- <div class='menu-bar-toggle' onClick={onToggleClick}>
213
- <span></span>
214
- </div>
215
- </div>
216
-
217
- {renderItems(items, 'menu-bar-top')}
218
- </div>
219
- );
220
- };
@@ -1,10 +0,0 @@
1
- export type MenuItemProps = {
2
- text: string; // "-" for break line
3
- url: string;
4
- js?: () => void;
5
- alt?: string;
6
- };
7
-
8
- export type NestMenuItemProps = MenuItemProps & {
9
- items?: NestMenuItemProps[];
10
- };