lupine.components 1.1.21 → 1.1.23

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 (44) hide show
  1. package/package.json +1 -1
  2. package/src/components/action-sheet-demo.tsx +105 -0
  3. package/src/components/button-demo.tsx +33 -0
  4. package/src/components/button-push-animation-demo.tsx +32 -0
  5. package/src/components/button-push-animation.tsx +8 -4
  6. package/src/components/editable-label-demo.tsx +33 -0
  7. package/src/components/input-with-title-demo.tsx +42 -0
  8. package/src/components/message-box-demo.tsx +107 -0
  9. package/src/components/modal-demo.tsx +56 -0
  10. package/src/components/notice-message-demo.tsx +60 -0
  11. package/src/components/popup-menu-demo.tsx +68 -0
  12. package/src/components/popup-menu.tsx +1 -1
  13. package/src/components/progress-demo.tsx +63 -0
  14. package/src/components/progress.tsx +3 -3
  15. package/src/components/radio-label-demo.tsx +41 -0
  16. package/src/components/redirect-demo.tsx +36 -0
  17. package/src/components/resizable-splitter-demo.tsx +76 -0
  18. package/src/components/resizable-splitter.tsx +6 -6
  19. package/src/components/select-angle-demo.tsx +32 -0
  20. package/src/components/select-with-title-demo.tsx +53 -0
  21. package/src/components/spinner-demo.tsx +52 -0
  22. package/src/components/stars-component-demo.tsx +36 -0
  23. package/src/components/stars-component.tsx +11 -3
  24. package/src/components/switch-option-demo.tsx +36 -0
  25. package/src/components/tabs-demo.tsx +42 -0
  26. package/src/components/text-glow-demo.tsx +46 -0
  27. package/src/components/text-scale-demo.tsx +41 -0
  28. package/src/components/text-wave-demo.tsx +46 -0
  29. package/src/components/toggle-button-demo.tsx +42 -0
  30. package/src/components/toggle-play-button-demo.tsx +56 -0
  31. package/src/components/toggle-switch-demo.tsx +43 -0
  32. package/src/demo/demo-about.tsx +12 -0
  33. package/src/demo/demo-container.tsx +57 -0
  34. package/src/demo/demo-css.tsx +3 -0
  35. package/src/demo/demo-frame-helper.tsx +395 -0
  36. package/src/demo/demo-frame.tsx +139 -0
  37. package/src/demo/demo-index.tsx +17 -0
  38. package/src/demo/demo-page.tsx +198 -0
  39. package/src/demo/demo-registry.ts +54 -0
  40. package/src/demo/demo-render-page.tsx +77 -0
  41. package/src/demo/demo-types.ts +22 -0
  42. package/src/html-editor/buttons_morden.gif +0 -0
  43. package/src/html-editor/h-editor.ts +817 -0
  44. package/src/index.ts +2 -0
@@ -0,0 +1,42 @@
1
+ import { DemoStory } from '../demo/demo-types';
2
+ import { ToggleButton } from './toggle-base';
3
+
4
+ export const toggleButtonDemo: DemoStory<any> = {
5
+ id: 'toggle-button-demo',
6
+ text: 'Toggle Button Demo',
7
+ args: {
8
+ onText: 'Turn Off',
9
+ offText: 'Turn On',
10
+ disabled: false,
11
+ checked: false,
12
+ },
13
+ argTypes: {
14
+ onText: { control: 'text', description: 'Text shown when ON' },
15
+ offText: { control: 'text', description: 'Text shown when OFF' },
16
+ disabled: { control: 'boolean', description: 'Disabled state' },
17
+ checked: { control: 'boolean', description: 'Initial state' },
18
+ },
19
+ render: (args) => {
20
+ return (
21
+ <div style={{ padding: '20px' }}>
22
+ <ToggleButton
23
+ onText={args.onText}
24
+ offText={args.offText}
25
+ disabled={args.disabled}
26
+ checked={args.checked}
27
+ onClick={(val) => console.log('Toggled:', val)}
28
+ />
29
+ </div>
30
+ );
31
+ },
32
+ code: `import { ToggleButton } from 'lupine.components/components/toggle-base';
33
+
34
+ <ToggleButton
35
+ onText="Turn Off"
36
+ offText="Turn On"
37
+ disabled={false}
38
+ checked={false}
39
+ onClick={(val) => console.log('Toggled:', val)}
40
+ />
41
+ `,
42
+ };
@@ -0,0 +1,56 @@
1
+ import { DemoStory } from '../demo/demo-types';
2
+ import { TogglePlayButton, TogglePlayButtonSize } from './toggle-base';
3
+
4
+ export const togglePlayButtonDemo: DemoStory<any> = {
5
+ id: 'toggle-play-button-demo',
6
+ text: 'Toggle Play Button Demo',
7
+ args: {
8
+ size: 'Medium',
9
+ disabled: false,
10
+ checked: false,
11
+ textColor: '#ffffff',
12
+ backgroundColor: '#3b29cc',
13
+ noWave: false,
14
+ },
15
+ argTypes: {
16
+ size: { control: 'select', options: ['Small', 'Medium', 'Large'], description: 'Size preset' },
17
+ disabled: { control: 'boolean', description: 'Disabled state' },
18
+ checked: { control: 'boolean', description: 'Is playing?' },
19
+ textColor: { control: 'text', description: 'Color of the play icon' },
20
+ backgroundColor: { control: 'text', description: 'Background color of the button' },
21
+ noWave: { control: 'boolean', description: 'Disable the background wave animation' },
22
+ },
23
+ render: (args) => {
24
+ // Map string enum back to object
25
+ const sizeMap: any = {
26
+ Small: TogglePlayButtonSize.Small,
27
+ Medium: TogglePlayButtonSize.Medium,
28
+ Large: TogglePlayButtonSize.Large,
29
+ };
30
+ return (
31
+ <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '200px' }}>
32
+ <TogglePlayButton
33
+ size={sizeMap[args.size]}
34
+ disabled={args.disabled}
35
+ checked={args.checked}
36
+ textColor={args.textColor}
37
+ backgroundColor={args.backgroundColor}
38
+ noWave={args.noWave}
39
+ onClick={(val) => console.log('Playing:', val)}
40
+ />
41
+ </div>
42
+ );
43
+ },
44
+ code: `import { TogglePlayButton, TogglePlayButtonSize } from 'lupine.components/components/toggle-base';
45
+
46
+ <TogglePlayButton
47
+ size={TogglePlayButtonSize.Medium}
48
+ disabled={false}
49
+ checked={false}
50
+ textColor="#ffffff"
51
+ backgroundColor="#3b29cc"
52
+ noWave={false}
53
+ onClick={(val) => console.log('Playing:', val)}
54
+ />
55
+ `,
56
+ };
@@ -0,0 +1,43 @@
1
+ import { DemoStory } from '../demo/demo-types';
2
+ import { ToggleSwitch, ToggleSwitchProps, ToggleSwitchSize } from './toggle-switch';
3
+
4
+ export const toggleSwitchDemo: DemoStory<ToggleSwitchProps> = {
5
+ id: 'toggle-switch-demo',
6
+ text: 'Toggle Switch Demo',
7
+ args: {
8
+ size: ToggleSwitchSize.Medium,
9
+ disabled: false,
10
+ checked: false,
11
+ text: { on: 'ON', off: 'OFF' },
12
+ textWidth: '30px',
13
+ },
14
+ argTypes: {
15
+ size: {
16
+ control: 'select',
17
+ options: Object.values(ToggleSwitchSize),
18
+ description: 'The size of the switch',
19
+ },
20
+ disabled: { control: 'boolean', description: 'Whether the switch is disabled' },
21
+ checked: { control: 'boolean', description: 'Whether the switch is turned on' },
22
+ textWidth: { control: 'text', description: 'Fixed width for the text to prevent jumping' },
23
+ },
24
+ render: (args: ToggleSwitchProps) => {
25
+ // Note: We don't expose 'text' as a simple control because our current demo system
26
+ // handles primitives. But the user can see how it works with the default args.
27
+ return (
28
+ <div style={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
29
+ <ToggleSwitch {...args} />
30
+ </div>
31
+ );
32
+ },
33
+ code: `import { ToggleSwitch, ToggleSwitchSize } from 'lupine.components/components/toggle-switch';
34
+
35
+ <ToggleSwitch
36
+ size={ToggleSwitchSize.Medium}
37
+ disabled={false}
38
+ checked={false}
39
+ text={{ on: 'ON', off: 'OFF' }}
40
+ textWidth="30px"
41
+ />
42
+ `,
43
+ };
@@ -0,0 +1,12 @@
1
+ import { CssProps } from 'lupine.components';
2
+
3
+ export const DemoAboutPage = () => {
4
+ const css: CssProps = {};
5
+
6
+ return (
7
+ <div css={css} class='demo-about-top'>
8
+ <div class='row-box'>This is a demo page for testing components.</div>
9
+ <div class='row-box'></div>
10
+ </div>
11
+ );
12
+ };
@@ -0,0 +1,57 @@
1
+ import { CssProps, RefProps, VNode } from 'lupine.components';
2
+
3
+ export type DemoContainerProps = {
4
+ demoUrl: string;
5
+ onIframeLoad?: (iframeWindow: Window) => void;
6
+ controlBox: VNode<any>;
7
+ };
8
+ export const DemoContainer = (props: DemoContainerProps) => {
9
+ const css: CssProps = {
10
+ height: '100%',
11
+ width: '100%',
12
+ display: 'flex',
13
+ flexDirection: 'column',
14
+ '.&-iframe-box': {
15
+ flex: 1,
16
+ minHeight: '200px', // Ensure it has some height
17
+ },
18
+ '.&-iframe': {
19
+ width: '100%',
20
+ height: '100%',
21
+ // backgroundColor: 'white', // Default background for preview
22
+ border: 'dotted 1px red',
23
+ },
24
+ '.&-control-box': {
25
+ // Allow it to grow if needed, or scroll
26
+ minHeight: '50px',
27
+ maxHeight: '50%',
28
+ overflowY: 'auto',
29
+ borderTop: '1px solid var(--border-color, #ccc)',
30
+ padding: 'var(--space-m, 8px)',
31
+ },
32
+ };
33
+
34
+ const findIframe = () => {
35
+ const iframe = ref.$('&-iframe') as HTMLIFrameElement;
36
+ return iframe;
37
+ };
38
+
39
+ const onLoad = () => {
40
+ if (props.onIframeLoad) {
41
+ const iframe = findIframe();
42
+ if (iframe.contentWindow) {
43
+ props.onIframeLoad(iframe.contentWindow);
44
+ }
45
+ }
46
+ };
47
+
48
+ const ref: RefProps = {};
49
+ return (
50
+ <div css={css} ref={ref} class='demo-container-top'>
51
+ <div class='&-iframe-box'>
52
+ <iframe class='&-iframe' src={props.demoUrl} frameBorder='0' onLoad={onLoad}></iframe>
53
+ </div>
54
+ <div class='&-control-box'>{props.controlBox}</div>
55
+ </div>
56
+ );
57
+ };
@@ -0,0 +1,3 @@
1
+ import { CssProps } from 'lupine.components';
2
+
3
+ export const demoCss: CssProps = {};
@@ -0,0 +1,395 @@
1
+ import { VNode, MenuItemProps } from 'lupine.components';
2
+ import { NestMenuItemProps, TabsHookProps } from 'lupine.components';
3
+ import { DemoAboutPage } from './demo-about';
4
+ import { buttonDemo } from '../components/button-demo';
5
+ import { buttonPushAnimationDemo } from '../components/button-push-animation-demo';
6
+ import { toggleSwitchDemo } from '../components/toggle-switch-demo';
7
+ import { spinnerDemo } from '../components/spinner-demo';
8
+ import { starsDemo } from '../components/stars-component-demo';
9
+ import { editableLabelDemo } from '../components/editable-label-demo';
10
+ import { progressDemo } from '../components/progress-demo';
11
+ import { radioLabelDemo } from '../components/radio-label-demo';
12
+ import { selectAngleDemo } from '../components/select-angle-demo';
13
+ import { switchOptionDemo } from '../components/switch-option-demo';
14
+ import { actionSheetDemo } from '../components/action-sheet-demo';
15
+ import { selectWithTitleDemo } from '../components/select-with-title-demo';
16
+ import { inputWithTitleDemo } from '../components/input-with-title-demo';
17
+ import { tabsDemo } from '../components/tabs-demo';
18
+ import { modalDemo } from '../components/modal-demo';
19
+ import { popupMenuDemo } from '../components/popup-menu-demo';
20
+ import { noticeMessageDemo } from '../components/notice-message-demo';
21
+ import { resizableSplitterDemo } from '../components/resizable-splitter-demo';
22
+ import { redirectDemo } from '../components/redirect-demo';
23
+ import { textWaveDemo } from '../components/text-wave-demo';
24
+ import { textScaleDemo } from '../components/text-scale-demo';
25
+ import { textGlowDemo } from '../components/text-glow-demo';
26
+ import { togglePlayButtonDemo } from '../components/toggle-play-button-demo';
27
+ import { toggleButtonDemo } from '../components/toggle-button-demo';
28
+ import { messageBoxDemo } from '../components/message-box-demo';
29
+ import { DemoPage } from './demo-page';
30
+
31
+ const chineseMenuText: { text: string; zh: string }[] = [
32
+ { text: 'Contents', zh: '内容管理' },
33
+ { text: 'Menu List', zh: '菜单列表' },
34
+ { text: 'Page List', zh: '页面列表' },
35
+ { text: 'Process List', zh: '流程列表' },
36
+
37
+ { text: 'DB', zh: '数据库' },
38
+ { text: 'Table List', zh: '表' },
39
+ { text: 'Create Tables', zh: '创建表' },
40
+ { text: 'Run SQL', zh: '运行 SQL' },
41
+
42
+ { text: 'Test', zh: '测试' },
43
+ { text: 'Test Themes', zh: '测试主题' },
44
+ { text: 'Test Component', zh: '测试组件' },
45
+ { text: 'Test Animations', zh: '测试动画' },
46
+ { text: 'Test Edit', zh: '测试编辑' },
47
+
48
+ { text: 'Access', zh: '管理服务器' },
49
+ { text: 'Release', zh: '发布' },
50
+ { text: 'Tokens', zh: '管理令牌' },
51
+
52
+ { text: 'Server Info', zh: '服务器信息' },
53
+ { text: 'Resources', zh: '管理资源' },
54
+ { text: 'Config', zh: '管理配置' },
55
+ { text: 'Shell', zh: '命令终端' },
56
+ { text: 'Performance', zh: '性能' },
57
+
58
+ { text: 'Help', zh: '帮助' },
59
+ { text: 'About', zh: '关于' },
60
+ ];
61
+ const translateMenuToChinese = (text: string) => {
62
+ const menuItem = chineseMenuText.find((item) => item.text === text);
63
+ return menuItem ? menuItem.zh : text;
64
+ };
65
+
66
+ export type AppDemoHookCheckLoginProps = (authResponse: object) => Promise<boolean>;
67
+ export type AppDemoHookLogoutProps = () => Promise<void>;
68
+ export class DemoFrameHelper {
69
+ consoleTitle = 'Welcome to Demo Panel';
70
+ getConsoleTitle() {
71
+ return this.consoleTitle;
72
+ }
73
+ setConsoleTitle(title: string) {
74
+ this.consoleTitle = title;
75
+ }
76
+
77
+ maxWidthMobileMenu = '700px';
78
+ setMaxWidthMobileMenu(maxWidthMobileMenu: string) {
79
+ this.maxWidthMobileMenu = maxWidthMobileMenu;
80
+ }
81
+ getMaxWidthMobileMenu() {
82
+ return this.maxWidthMobileMenu;
83
+ }
84
+
85
+ maxTabsCount = 20;
86
+ setMaxTabsCount(count: number) {
87
+ this.maxTabsCount = count;
88
+ }
89
+ getMaxTabsCount() {
90
+ return this.maxTabsCount;
91
+ }
92
+
93
+ tabsHook: TabsHookProps = {} as TabsHookProps;
94
+ setTabsHook(hook: TabsHookProps) {
95
+ this.tabsHook = hook;
96
+ }
97
+ getTabsHook() {
98
+ return this.tabsHook;
99
+ }
100
+
101
+ AppDemoHookCheckLogin?: AppDemoHookCheckLoginProps;
102
+ setAppDemoHookCheckLogin(hook: AppDemoHookCheckLoginProps) {
103
+ this.AppDemoHookCheckLogin = hook;
104
+ }
105
+ getAppDemoHookCheckLogin() {
106
+ return this.AppDemoHookCheckLogin;
107
+ }
108
+
109
+ AppDemoHookLogout?: AppDemoHookLogoutProps;
110
+ setAppDemoHookLogout(hook: AppDemoHookLogoutProps) {
111
+ this.AppDemoHookLogout = hook;
112
+ }
113
+ getAppDemoHookLogout() {
114
+ return this.AppDemoHookLogout;
115
+ }
116
+
117
+ demoTopMenu: NestMenuItemProps[] = [
118
+ // { text: 'Top', url: '/admin' },
119
+ {
120
+ id: 'basic-demo',
121
+ text: 'Basic',
122
+ url: '',
123
+ // hide: true,
124
+ items: [
125
+ {
126
+ id: buttonDemo.id,
127
+ text: buttonDemo.text,
128
+ url: '',
129
+ // hide: true,
130
+ // Mounted via DemoPage to provide controls
131
+ js: () => this.addPanel(buttonDemo.text, <DemoPage story={buttonDemo} />),
132
+ },
133
+ {
134
+ id: buttonPushAnimationDemo.id,
135
+ text: buttonPushAnimationDemo.text,
136
+ url: '',
137
+ js: () => this.addPanel(buttonPushAnimationDemo.text, <DemoPage story={buttonPushAnimationDemo} />),
138
+ },
139
+ {
140
+ id: toggleSwitchDemo.id,
141
+ text: toggleSwitchDemo.text,
142
+ url: '',
143
+ js: () => this.addPanel(toggleSwitchDemo.text, <DemoPage story={toggleSwitchDemo} />),
144
+ },
145
+ {
146
+ id: spinnerDemo.id,
147
+ text: spinnerDemo.text,
148
+ url: '',
149
+ js: () => this.addPanel(spinnerDemo.text, <DemoPage story={spinnerDemo} />),
150
+ },
151
+ {
152
+ id: starsDemo.id,
153
+ text: starsDemo.text,
154
+ url: '',
155
+ js: () => this.addPanel(starsDemo.text, <DemoPage story={starsDemo} />),
156
+ },
157
+ {
158
+ id: editableLabelDemo.id,
159
+ text: editableLabelDemo.text,
160
+ url: '',
161
+ js: () => this.addPanel(editableLabelDemo.text, <DemoPage story={editableLabelDemo} />),
162
+ },
163
+ {
164
+ id: progressDemo.id,
165
+ text: progressDemo.text,
166
+ url: '',
167
+ js: () => this.addPanel(progressDemo.text, <DemoPage story={progressDemo} />),
168
+ },
169
+ {
170
+ id: textWaveDemo.id,
171
+ text: textWaveDemo.text,
172
+ url: '',
173
+ js: () => this.addPanel(textWaveDemo.text, <DemoPage story={textWaveDemo} />),
174
+ },
175
+ {
176
+ id: textScaleDemo.id,
177
+ text: textScaleDemo.text,
178
+ url: '',
179
+ js: () => this.addPanel(textScaleDemo.text, <DemoPage story={textScaleDemo} />),
180
+ },
181
+ {
182
+ id: textGlowDemo.id,
183
+ text: textGlowDemo.text,
184
+ url: '',
185
+ js: () => this.addPanel(textGlowDemo.text, <DemoPage story={textGlowDemo} />),
186
+ },
187
+ {
188
+ id: togglePlayButtonDemo.id,
189
+ text: togglePlayButtonDemo.text,
190
+ url: '',
191
+ js: () => this.addPanel(togglePlayButtonDemo.text, <DemoPage story={togglePlayButtonDemo} />),
192
+ },
193
+ {
194
+ id: toggleButtonDemo.id,
195
+ text: toggleButtonDemo.text,
196
+ url: '',
197
+ js: () => this.addPanel(toggleButtonDemo.text, <DemoPage story={toggleButtonDemo} />),
198
+ },
199
+ ],
200
+ },
201
+ {
202
+ id: 'forms-inputs-demo',
203
+ text: 'Forms & Inputs',
204
+ url: '',
205
+ items: [
206
+ {
207
+ id: radioLabelDemo.id,
208
+ text: radioLabelDemo.text,
209
+ url: '',
210
+ js: () => this.addPanel(radioLabelDemo.text, <DemoPage story={radioLabelDemo} />),
211
+ },
212
+ {
213
+ id: selectAngleDemo.id,
214
+ text: selectAngleDemo.text,
215
+ url: '',
216
+ js: () => this.addPanel(selectAngleDemo.text, <DemoPage story={selectAngleDemo} />),
217
+ },
218
+ {
219
+ id: switchOptionDemo.id,
220
+ text: switchOptionDemo.text,
221
+ url: '',
222
+ js: () => this.addPanel(switchOptionDemo.text, <DemoPage story={switchOptionDemo} />),
223
+ },
224
+ {
225
+ id: actionSheetDemo.id,
226
+ text: actionSheetDemo.text,
227
+ url: '',
228
+ js: () => this.addPanel(actionSheetDemo.text, <DemoPage story={actionSheetDemo} />),
229
+ },
230
+ {
231
+ id: selectWithTitleDemo.id,
232
+ text: selectWithTitleDemo.text,
233
+ url: '',
234
+ js: () => this.addPanel(selectWithTitleDemo.text, <DemoPage story={selectWithTitleDemo} />),
235
+ },
236
+ {
237
+ id: inputWithTitleDemo.id,
238
+ text: inputWithTitleDemo.text,
239
+ url: '',
240
+ js: () => this.addPanel(inputWithTitleDemo.text, <DemoPage story={inputWithTitleDemo} />),
241
+ },
242
+ ],
243
+ },
244
+ {
245
+ id: 'layout-popups-demo',
246
+ text: 'Layout & Popups',
247
+ url: '',
248
+ items: [
249
+ {
250
+ id: tabsDemo.id,
251
+ text: tabsDemo.text,
252
+ url: '',
253
+ js: () => this.addPanel(tabsDemo.text, <DemoPage story={tabsDemo} />),
254
+ },
255
+ {
256
+ id: modalDemo.id,
257
+ text: modalDemo.text,
258
+ url: '',
259
+ js: () => this.addPanel(modalDemo.text, <DemoPage story={modalDemo} />),
260
+ },
261
+ {
262
+ id: messageBoxDemo.id,
263
+ text: messageBoxDemo.text,
264
+ url: '',
265
+ js: () => this.addPanel(messageBoxDemo.text, <DemoPage story={messageBoxDemo} />),
266
+ },
267
+ {
268
+ id: popupMenuDemo.id,
269
+ text: popupMenuDemo.text,
270
+ url: '',
271
+ js: () => this.addPanel(popupMenuDemo.text, <DemoPage story={popupMenuDemo} />),
272
+ },
273
+ {
274
+ id: noticeMessageDemo.id,
275
+ text: noticeMessageDemo.text,
276
+ url: '',
277
+ js: () => this.addPanel(noticeMessageDemo.text, <DemoPage story={noticeMessageDemo} />),
278
+ },
279
+ {
280
+ id: resizableSplitterDemo.id,
281
+ text: resizableSplitterDemo.text,
282
+ url: '',
283
+ js: () => this.addPanel(resizableSplitterDemo.text, <DemoPage story={resizableSplitterDemo} />),
284
+ },
285
+ {
286
+ id: redirectDemo.id,
287
+ text: redirectDemo.text,
288
+ url: '',
289
+ js: () => this.addPanel(redirectDemo.text, <DemoPage story={redirectDemo} />),
290
+ },
291
+ ],
292
+ },
293
+
294
+ {
295
+ id: 'help',
296
+ text: 'Help',
297
+ url: '',
298
+ items: [
299
+ {
300
+ id: 'about',
301
+ text: 'About',
302
+ url: '',
303
+ js: () => this.addPanel('About', DemoAboutPage()),
304
+ },
305
+ ],
306
+ },
307
+ ];
308
+
309
+ hookBeforeShowMenu?: (adminTopMenu: NestMenuItemProps[]) => NestMenuItemProps[];
310
+ // Set a hook to modify the admin top menu dynamically before it is shown
311
+ setHookBeforeShowMenu(hook: (adminTopMenu: NestMenuItemProps[]) => NestMenuItemProps[]) {
312
+ this.hookBeforeShowMenu = hook;
313
+ }
314
+ getDemoTopMenu() {
315
+ if (this.hookBeforeShowMenu) {
316
+ return this.hookBeforeShowMenu(this.demoTopMenu);
317
+ }
318
+ return this.demoTopMenu;
319
+ }
320
+ setDemoTopMenu(demoTopMenu: NestMenuItemProps[]) {
321
+ this.demoTopMenu = demoTopMenu;
322
+ }
323
+ setChineseDemoTopMenu() {
324
+ this.demoTopMenu.forEach((item) => {
325
+ item.text = translateMenuToChinese(item.text);
326
+ item.items?.forEach((subItem) => {
327
+ subItem.text = translateMenuToChinese(subItem.text);
328
+ });
329
+ });
330
+ }
331
+
332
+ mobileMenuMaxWidth = '700px';
333
+ setMobileMenuMaxWidth(maxWidth: string) {
334
+ this.mobileMenuMaxWidth = maxWidth;
335
+ }
336
+ getMobileMenuMaxWidth() {
337
+ return this.mobileMenuMaxWidth;
338
+ }
339
+
340
+ insertMenuItem(item: NestMenuItemProps[], beforeMenuId?: string) {
341
+ let index = -1;
342
+ if (beforeMenuId) {
343
+ index = this.demoTopMenu.findIndex((m) => m.id === beforeMenuId);
344
+ }
345
+ if (index !== -1) {
346
+ this.demoTopMenu.splice(index, 0, ...item);
347
+ } else {
348
+ this.demoTopMenu.push(...item);
349
+ }
350
+ }
351
+ insertSubMenuItem(item: MenuItemProps[], beforeMenuId: string, beforeSubMenuId?: string) {
352
+ const index = this.demoTopMenu.findIndex((m) => m.id === beforeMenuId);
353
+ if (index !== -1) {
354
+ const subMenu = this.demoTopMenu[index].items || [];
355
+ const subIndex = subMenu.findIndex((s) => s.id === beforeSubMenuId);
356
+ if (subIndex !== -1) {
357
+ subMenu.splice(subIndex, 0, ...item);
358
+ } else {
359
+ subMenu.push(...item);
360
+ }
361
+ // this.adminTopMenu[index].items = subMenu;
362
+ }
363
+ }
364
+ getMenuItem(menuId: string): NestMenuItemProps | null {
365
+ const index = this.demoTopMenu.findIndex((m) => m.id === menuId);
366
+ if (index !== -1) {
367
+ return this.demoTopMenu[index];
368
+ }
369
+ return null;
370
+ }
371
+ getSubMenuItem(menuId: string, subMenuId: string): MenuItemProps | null {
372
+ const index = this.demoTopMenu.findIndex((m) => m.id === menuId);
373
+ if (index !== -1) {
374
+ const subMenu = this.demoTopMenu[index].items || [];
375
+ const subIndex = subMenu.findIndex((s) => s.id === subMenuId);
376
+ if (subIndex !== -1) {
377
+ return subMenu[subIndex];
378
+ }
379
+ }
380
+ return null;
381
+ }
382
+
383
+ refUpdate = this.getTabsHook();
384
+ async addPanel(title: string, page: VNode) {
385
+ if (this.getTabsHook().getCount!() > this.getMaxTabsCount()) {
386
+ alert('You are opening too many pages');
387
+ return;
388
+ }
389
+ if (this.getTabsHook().findAndActivate!(title)) {
390
+ return;
391
+ }
392
+ await this.getTabsHook().newPage!(title, page);
393
+ }
394
+ }
395
+ export const demoFrameHelper = /* @__PURE__ */ new DemoFrameHelper();