@xh/hoist 79.0.0-SNAPSHOT.1766020485210 → 79.0.0-SNAPSHOT.1766094533168
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 +8 -0
- package/admin/AppComponent.ts +9 -1
- package/admin/AppModel.ts +0 -4
- package/admin/tabs/cluster/instances/InstancesTab.ts +1 -1
- package/admin/tabs/cluster/instances/InstancesTabModel.ts +0 -1
- package/admin/tabs/userData/roles/details/RoleDetailsModel.ts +0 -1
- package/build/types/cmp/tab/TabContainer.d.ts +19 -4
- package/build/types/cmp/tab/TabContainerModel.d.ts +18 -19
- package/build/types/cmp/tab/Types.d.ts +61 -0
- package/build/types/cmp/tab/index.d.ts +1 -1
- package/build/types/data/RecordAction.d.ts +4 -1
- package/build/types/desktop/cmp/tab/TabSwitcher.d.ts +1 -1
- package/build/types/desktop/cmp/tab/dynamic/DynamicTabSwitcher.d.ts +7 -0
- package/build/types/desktop/cmp/tab/dynamic/DynamicTabSwitcherModel.d.ts +30 -0
- package/build/types/desktop/cmp/tab/dynamic/scroller/Scroller.d.ts +19 -0
- package/build/types/desktop/cmp/tab/dynamic/scroller/ScrollerModel.d.ts +23 -0
- package/build/types/desktop/cmp/tab/impl/Tab.d.ts +7 -2
- package/build/types/desktop/cmp/tab/impl/TabContainer.d.ts +1 -1
- package/build/types/desktop/cmp/tab/impl/TabContextMenuItems.d.ts +4 -0
- package/build/types/desktop/cmp/tab/index.d.ts +1 -0
- package/build/types/dynamics/desktop.d.ts +1 -0
- package/build/types/mobile/cmp/tab/impl/TabContainer.d.ts +1 -1
- package/cmp/tab/TabContainer.ts +19 -4
- package/cmp/tab/TabContainerModel.ts +113 -54
- package/cmp/tab/TabModel.ts +1 -2
- package/cmp/tab/Types.ts +80 -0
- package/cmp/tab/index.ts +1 -1
- package/data/RecordAction.ts +4 -1
- package/desktop/appcontainer/AppContainer.ts +3 -2
- package/desktop/cmp/grid/impl/filter/headerfilter/HeaderFilter.ts +1 -1
- package/desktop/cmp/grid/impl/filter/headerfilter/HeaderFilterModel.ts +0 -1
- package/desktop/cmp/tab/TabSwitcher.ts +18 -3
- package/desktop/cmp/tab/Tabs.scss +1 -0
- package/desktop/cmp/tab/dynamic/DynamicTabSwitcher.scss +53 -0
- package/desktop/cmp/tab/dynamic/DynamicTabSwitcher.ts +237 -0
- package/desktop/cmp/tab/dynamic/DynamicTabSwitcherModel.ts +167 -0
- package/desktop/cmp/tab/dynamic/scroller/Scroller.ts +69 -0
- package/desktop/cmp/tab/dynamic/scroller/ScrollerModel.ts +92 -0
- package/desktop/cmp/tab/impl/Tab.ts +30 -6
- package/desktop/cmp/tab/impl/TabContainer.ts +34 -9
- package/desktop/cmp/tab/impl/TabContextMenuItems.ts +21 -0
- package/desktop/cmp/tab/index.ts +1 -0
- package/dynamics/desktop.ts +2 -0
- package/mobile/cmp/tab/impl/TabContainer.ts +16 -9
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/types/cmp/tab/TabSwitcherProps.d.ts +0 -16
- package/cmp/tab/TabSwitcherProps.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,20 @@
|
|
|
5
5
|
### 🎁 New Features
|
|
6
6
|
|
|
7
7
|
* Enhance `LocalDate` with `addWeekdays` and `subtractWeekdays` methods.
|
|
8
|
+
* Added new `DynamicTabSwitcher` component, a more user-customizable version of `TabSwitcher` that
|
|
9
|
+
allows for dynamic addition, removal, and drag-and-drop reordering of tabs with the ability to
|
|
10
|
+
persist "favorited" tab state across sessions. Additionally, existing static `TabSwitcher` now
|
|
11
|
+
supports context-menu items. See `TabContainerConfig.switcher`.
|
|
8
12
|
|
|
9
13
|
### 💥 Breaking Changes
|
|
10
14
|
|
|
11
15
|
* Renamed `GridModel.applyColumnStateChanges()` to `updateColumnState()` for clarity and better
|
|
12
16
|
symmetry with `setColumnState()`. The prior method remains as an alias but is now deprecated and
|
|
13
17
|
scheduled for removal in v82.
|
|
18
|
+
* `TabSwitcherProps` has moved to `cmp/tab/Types.ts` but is still exported from `cmp/tab/index.ts`.
|
|
19
|
+
Some apps may need to update their imports.
|
|
20
|
+
* `TabContainerConfig.switcher` has been repurposed to accept a `TabSwitcherConfig`. To pass
|
|
21
|
+
`TabSwitcherProps` via a parent `TabContainer`, use `TabContainerProps.switcher`.
|
|
14
22
|
|
|
15
23
|
### 🐞 Bug Fixes
|
|
16
24
|
|
package/admin/AppComponent.ts
CHANGED
|
@@ -22,7 +22,15 @@ export const AppComponent = hoistCmp({
|
|
|
22
22
|
return panel({
|
|
23
23
|
tbar: tbar(),
|
|
24
24
|
className: 'xh-admin-app',
|
|
25
|
-
item: tabContainer(
|
|
25
|
+
item: tabContainer({
|
|
26
|
+
switcher: false,
|
|
27
|
+
childContainerProps: ({tabId}) => ({
|
|
28
|
+
switcher: {
|
|
29
|
+
orientation: 'left',
|
|
30
|
+
testId: `${tabId}-tab-switcher`
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
})
|
|
26
34
|
});
|
|
27
35
|
}
|
|
28
36
|
});
|
package/admin/AppModel.ts
CHANGED
|
@@ -37,7 +37,6 @@ export class AppModel extends HoistAppModel {
|
|
|
37
37
|
|
|
38
38
|
this.tabModel = new TabContainerModel({
|
|
39
39
|
route: 'default',
|
|
40
|
-
switcher: false,
|
|
41
40
|
tabs: this.createTabs()
|
|
42
41
|
});
|
|
43
42
|
|
|
@@ -130,7 +129,6 @@ export class AppModel extends HoistAppModel {
|
|
|
130
129
|
id: 'general',
|
|
131
130
|
icon: Icon.info(),
|
|
132
131
|
content: {
|
|
133
|
-
switcher: {orientation: 'left', testId: 'general-tab-switcher'},
|
|
134
132
|
tabs: [
|
|
135
133
|
{id: 'about', icon: Icon.info(), content: aboutPanel},
|
|
136
134
|
{id: 'config', icon: Icon.settings(), content: configPanel},
|
|
@@ -142,7 +140,6 @@ export class AppModel extends HoistAppModel {
|
|
|
142
140
|
id: 'servers',
|
|
143
141
|
icon: Icon.server(),
|
|
144
142
|
content: {
|
|
145
|
-
switcher: {orientation: 'left', testId: 'cluster-tab-switcher'},
|
|
146
143
|
tabs: [
|
|
147
144
|
{id: 'instances', icon: Icon.server(), content: instancesTab},
|
|
148
145
|
{id: 'objects', icon: Icon.boxFull(), content: clusterObjectsPanel}
|
|
@@ -163,7 +160,6 @@ export class AppModel extends HoistAppModel {
|
|
|
163
160
|
id: 'userData',
|
|
164
161
|
icon: Icon.users(),
|
|
165
162
|
content: {
|
|
166
|
-
switcher: {orientation: 'left', testId: 'user-data-tab-switcher'},
|
|
167
163
|
refreshMode: 'onShowAlways',
|
|
168
164
|
tabs: [
|
|
169
165
|
{
|
|
@@ -193,7 +193,6 @@ export class InstancesTabModel extends HoistModel {
|
|
|
193
193
|
private createTabContainerModel() {
|
|
194
194
|
return new TabContainerModel({
|
|
195
195
|
route: 'default.servers.instances',
|
|
196
|
-
switcher: false,
|
|
197
196
|
tabs: [
|
|
198
197
|
{id: 'logs', icon: Icon.fileText(), content: logViewer},
|
|
199
198
|
{id: 'memory', icon: Icon.memory(), content: memoryMonitorPanel},
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
+
import { TabSwitcherProps } from '@xh/hoist/cmp/tab/Types';
|
|
1
2
|
import { BoxProps, HoistProps } from '@xh/hoist/core';
|
|
2
3
|
import { TabContainerModel } from './TabContainerModel';
|
|
3
|
-
export
|
|
4
|
+
export interface TabContainerProps extends HoistProps<TabContainerModel>, BoxProps {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether to include a default switcher docked within this component. Specify as a
|
|
7
|
+
* boolean or props for a TabSwitcher component. False to not include a switcher. Default true.
|
|
8
|
+
*/
|
|
9
|
+
switcher?: boolean | TabSwitcherProps;
|
|
10
|
+
/**
|
|
11
|
+
* Props to apply to child TabContainers, if any. Specify as an object or a function
|
|
12
|
+
* that returns props based on the tabId and depth of the child container.
|
|
13
|
+
*/
|
|
14
|
+
childContainerProps?: TabContainerProps | ((ctx: {
|
|
15
|
+
tabId: string;
|
|
16
|
+
depth: number;
|
|
17
|
+
}) => TabContainerProps);
|
|
18
|
+
}
|
|
4
19
|
/**
|
|
5
20
|
* Display a set of child Tabs and (optionally) a switcher control.
|
|
6
21
|
*
|
|
7
|
-
* By default this TabContainer will install a TabSwitcher above the Tabs to control the currently
|
|
8
|
-
* displayed Tab. The '
|
|
9
|
-
*
|
|
22
|
+
* By default, this TabContainer will install a TabSwitcher above the Tabs to control the currently
|
|
23
|
+
* displayed Tab. The 'switcher' prop can be adjusted to place the switcher control on alternative
|
|
24
|
+
* edges of the container.
|
|
10
25
|
*
|
|
11
26
|
* If `switcher` is set to false then no TabSwitcher will be installed. This setting
|
|
12
27
|
* is useful for applications that wish to place an associated TabSwitcher elsewhere in the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TabSwitcherConfig, IDynamicTabSwitcherModel } from '@xh/hoist/cmp/tab/Types';
|
|
2
|
+
import { HoistModel, PersistOptions, RefreshContextModel, RefreshMode, RenderMode } from '@xh/hoist/core';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
4
|
import { TabConfig, TabModel } from './TabModel';
|
|
4
|
-
import { TabSwitcherProps } from './TabSwitcherProps';
|
|
5
5
|
export interface TabContainerConfig {
|
|
6
6
|
/** Tabs to be displayed. */
|
|
7
7
|
tabs: TabConfig[];
|
|
@@ -16,11 +16,10 @@ export interface TabContainerConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
route?: string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* include a switcher. Defaults to true.
|
|
19
|
+
* Specification for type of switcher. Specify `dynamic` or config for user-configurable tabs.
|
|
20
|
+
* Default `{mode: 'static'}` for simple, static switcher.
|
|
22
21
|
*/
|
|
23
|
-
switcher?:
|
|
22
|
+
switcher?: TabSwitcherConfig;
|
|
24
23
|
/**
|
|
25
24
|
* True to enable activity tracking of tab views (default false). Viewing of each tab will
|
|
26
25
|
* be tracked with the `oncePerSession` flag, to avoid duplication.
|
|
@@ -54,22 +53,26 @@ export interface TabContainerConfig {
|
|
|
54
53
|
*
|
|
55
54
|
* Note: Routing is currently enabled for desktop applications only.
|
|
56
55
|
*/
|
|
57
|
-
export declare class TabContainerModel extends HoistModel
|
|
58
|
-
activeTabId: string;
|
|
59
|
-
}> {
|
|
56
|
+
export declare class TabContainerModel extends HoistModel {
|
|
60
57
|
config: TabContainerConfig;
|
|
61
58
|
tabs: TabModel[];
|
|
62
59
|
activeTabId: string;
|
|
60
|
+
depth: number;
|
|
63
61
|
route: string;
|
|
64
62
|
defaultTabId: string;
|
|
65
|
-
switcher: TabSwitcherProps;
|
|
66
63
|
track: boolean;
|
|
67
64
|
renderMode: RenderMode;
|
|
68
65
|
refreshMode: RefreshMode;
|
|
69
66
|
emptyText: ReactNode;
|
|
67
|
+
switcherConfig: TabSwitcherConfig;
|
|
70
68
|
refreshContextModel: RefreshContextModel;
|
|
69
|
+
dynamicTabSwitcherModel: IDynamicTabSwitcherModel;
|
|
71
70
|
protected lastActiveTabId: string;
|
|
72
|
-
|
|
71
|
+
/**
|
|
72
|
+
* @param config - TabContainer configuration.
|
|
73
|
+
* @param [depth] - Depth in hierarchy of nested TabContainerModels. Not for application use.
|
|
74
|
+
*/
|
|
75
|
+
constructor({ tabs, defaultTabId, route, track, renderMode, refreshMode, persistWith, emptyText, xhImpl, switcher }: TabContainerConfig, depth?: number);
|
|
73
76
|
/** Set/replace all tabs within the container. */
|
|
74
77
|
setTabs(tabs: Array<TabModel | TabConfig>): void;
|
|
75
78
|
/** Add a single tab to the container. */
|
|
@@ -88,9 +91,9 @@ export declare class TabContainerModel extends HoistModel implements Persistable
|
|
|
88
91
|
/** Find a tab that is an immediate child of this container. */
|
|
89
92
|
findTab(id: string): TabModel;
|
|
90
93
|
get activeTab(): TabModel;
|
|
91
|
-
/** The tab immediately before the active tab in the model's tab list. */
|
|
94
|
+
/** The visitable tab immediately before the active tab in the model's tab list. */
|
|
92
95
|
get prevTab(): TabModel;
|
|
93
|
-
/** The tab immediately after the active tab in the model's tab list. */
|
|
96
|
+
/** The visitable tab immediately after the active tab in the model's tab list. */
|
|
94
97
|
get nextTab(): TabModel;
|
|
95
98
|
/**
|
|
96
99
|
* Set the currently active Tab.
|
|
@@ -114,16 +117,12 @@ export declare class TabContainerModel extends HoistModel implements Persistable
|
|
|
114
117
|
* @param cycle - true to loop back to first tab if necessary.
|
|
115
118
|
*/
|
|
116
119
|
activateNextTab(cycle?: boolean): void;
|
|
117
|
-
getPersistableState(): PersistableState<{
|
|
118
|
-
activeTabId: string;
|
|
119
|
-
}>;
|
|
120
|
-
setPersistableState(state: PersistableState<{
|
|
121
|
-
activeTabId: string;
|
|
122
|
-
}>): void;
|
|
123
120
|
protected setActiveTabIdInternal(id: any): void;
|
|
124
121
|
protected syncWithRouter(): void;
|
|
125
122
|
protected forwardRouterToTab(id: any): void;
|
|
126
123
|
protected calculateActiveTabId(tabs: any): any;
|
|
124
|
+
private parseSwitcher;
|
|
125
|
+
private initPersist;
|
|
127
126
|
}
|
|
128
127
|
export interface AddTabOptions {
|
|
129
128
|
/** Index in tab collection where tab is to be added. */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TabContainerModel } from '@xh/hoist/cmp/tab/TabContainerModel';
|
|
2
|
+
import { TabModel } from '@xh/hoist/cmp/tab/TabModel';
|
|
3
|
+
import { BoxProps, HoistModel, HoistProps, MenuContext, MenuItemLike, MenuToken, PersistOptions, Side } from '@xh/hoist/core';
|
|
4
|
+
export interface TabSwitcherProps extends HoistProps<TabContainerModel>, BoxProps {
|
|
5
|
+
/** Relative position within the parent TabContainer. Defaults to 'top'. */
|
|
6
|
+
orientation?: Side;
|
|
7
|
+
/**
|
|
8
|
+
* True to animate the indicator when switching tabs. False (default) to change instantly.
|
|
9
|
+
* Not supported by DynamicTabSwitcher.
|
|
10
|
+
*/
|
|
11
|
+
animate?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Enable scrolling and place tabs that overflow into a menu. Default to false.
|
|
14
|
+
* Not supported by DynamicTabSwitcher.
|
|
15
|
+
*/
|
|
16
|
+
enableOverflow?: boolean;
|
|
17
|
+
/** Width (in px) to render tabs. Only applies to horizontal orientations */
|
|
18
|
+
tabWidth?: number;
|
|
19
|
+
/** Minimum width (in px) to render tabs. Only applies to horizontal orientations */
|
|
20
|
+
tabMinWidth?: number;
|
|
21
|
+
/** Maximum width (in px) to render tabs. Only applies to horizontal orientations */
|
|
22
|
+
tabMaxWidth?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface TabSwitcherConfig {
|
|
25
|
+
/** Specification for type of switcher. Specify `dynamic`for user-configurable tabs */
|
|
26
|
+
mode: 'static' | 'dynamic';
|
|
27
|
+
/** Additional menu items to include in tab context menus. Only supported on desktop */
|
|
28
|
+
extraMenuItems?: Array<MenuItemLike<MenuToken, TabSwitcherMenuContext>>;
|
|
29
|
+
/** IDs of favorite tabs to display by default (in order). Only for `dynamic` switchers */
|
|
30
|
+
initialFavorites?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface TabContainerModelPersistOptions extends PersistOptions {
|
|
33
|
+
/** True (default) to persist the active tab ID or provide custom PersistOptions. */
|
|
34
|
+
persistActiveTabId?: boolean;
|
|
35
|
+
/** True (default) to persist favorite tab IDs or provide custom PersistOptions. */
|
|
36
|
+
persistFavoriteTabIds?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface TabSwitcherMenuContext extends MenuContext {
|
|
39
|
+
tab: TabModel;
|
|
40
|
+
}
|
|
41
|
+
/** Cross-platform interface for desktop and mobile (TBA) DynamicTabSwitcherModels. */
|
|
42
|
+
export interface IDynamicTabSwitcherModel extends HoistModel {
|
|
43
|
+
/** IDs of favorite tabs, in order. */
|
|
44
|
+
get favoriteTabIds(): string[];
|
|
45
|
+
/** Tabs displayed in switcher, in order. */
|
|
46
|
+
get visibleTabs(): TabModel[];
|
|
47
|
+
/** Enabled tabs displayed in switcher, in order. */
|
|
48
|
+
get enabledVisibleTabs(): TabModel[];
|
|
49
|
+
/** Whether the specified tab is currently active in the TabContainer. */
|
|
50
|
+
isTabActive(tabId: string): boolean;
|
|
51
|
+
/** Whether the specified tab is currently marked as a favorite. */
|
|
52
|
+
isTabFavorite(tabId: string): boolean;
|
|
53
|
+
/** Toggle the favorite status of the specified tab. */
|
|
54
|
+
toggleTabFavorite(tabId: string): void;
|
|
55
|
+
/** Activate the specified tab in the TabContainer. */
|
|
56
|
+
activate(tabId: string): void;
|
|
57
|
+
/** Remove the specified tab from the switcher. */
|
|
58
|
+
hide(tabId: string): void;
|
|
59
|
+
/** Set the IDs of all favorite tabs, in order. */
|
|
60
|
+
setFavoriteTabIds(tabIds: string[]): void;
|
|
61
|
+
}
|
|
@@ -17,7 +17,10 @@ export interface RecordActionSpec extends TestSupportProps {
|
|
|
17
17
|
tooltip?: string;
|
|
18
18
|
/** Function called on action execution. */
|
|
19
19
|
actionFn?: (data: ActionFnData) => void;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Function called to append / override display properties prior to each render. This function
|
|
22
|
+
* allows dynamic control over display properties.
|
|
23
|
+
* */
|
|
21
24
|
displayFn?: (data: ActionFnData) => RecordActionSpec;
|
|
22
25
|
/** Sub-actions for this action. */
|
|
23
26
|
items?: RecordActionLike[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TabSwitcherProps } from '@xh/hoist/cmp/tab/Types';
|
|
2
|
+
import './DynamicTabSwitcher.scss';
|
|
3
|
+
/**
|
|
4
|
+
* A tab switcher that displays tabs as draggable items in a horizontal list.
|
|
5
|
+
* Tabs can be added, removed, reordered and favorited with persistence.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DynamicTabSwitcher: import("react").FC<TabSwitcherProps>, dynamicTabSwitcher: import("@xh/hoist/core").ElementFactory<TabSwitcherProps>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TabContainerModel, TabModel } from '@xh/hoist/cmp/tab';
|
|
2
|
+
import { IDynamicTabSwitcherModel, TabSwitcherConfig, TabSwitcherMenuContext } from '@xh/hoist/cmp/tab/Types';
|
|
3
|
+
import { HoistModel, MenuItemLike, MenuToken } from '@xh/hoist/core';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* State management for the DynamicTabSwitcher component.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class DynamicTabSwitcherModel extends HoistModel implements IDynamicTabSwitcherModel {
|
|
10
|
+
config: TabSwitcherConfig;
|
|
11
|
+
private readonly extraMenuItems;
|
|
12
|
+
private readonly tabContainerModel;
|
|
13
|
+
private visibleTabState;
|
|
14
|
+
get favoriteTabIds(): string[];
|
|
15
|
+
get visibleTabs(): TabModel[];
|
|
16
|
+
get enabledVisibleTabs(): TabModel[];
|
|
17
|
+
constructor({ extraMenuItems, initialFavorites }: TabSwitcherConfig, tabContainerModel: TabContainerModel);
|
|
18
|
+
isTabActive(tabId: string): boolean;
|
|
19
|
+
isTabFavorite(tabId: string): boolean;
|
|
20
|
+
toggleTabFavorite(tabId: string): void;
|
|
21
|
+
activate(tabId: string): void;
|
|
22
|
+
hide(tabId: string): void;
|
|
23
|
+
getContextMenuItems(e: React.MouseEvent<HTMLDivElement, MouseEvent>, tab: TabModel): Array<MenuItemLike<MenuToken, TabSwitcherMenuContext>>;
|
|
24
|
+
setFavoriteTabIds(tabIds: string[]): void;
|
|
25
|
+
onDragEnd(result: any): void;
|
|
26
|
+
private activeTabReaction;
|
|
27
|
+
private getValidTabIds;
|
|
28
|
+
private isValidTabId;
|
|
29
|
+
private isTabVisible;
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BoxProps, HoistProps } from '@xh/hoist/core';
|
|
2
|
+
import { ScrollerModel } from '@xh/hoist/desktop/cmp/tab/dynamic/scroller/ScrollerModel';
|
|
3
|
+
import React, { Ref } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* A scroller component that displays a content component with directional scroll buttons when the
|
|
6
|
+
* content overflows the viewport.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface ScrollerProps extends HoistProps<ScrollerModel>, Omit<BoxProps, 'content'> {
|
|
10
|
+
/** The content to be displayed within the scroller. */
|
|
11
|
+
content: React.FC<{
|
|
12
|
+
ref: Ref<HTMLDivElement>;
|
|
13
|
+
}>;
|
|
14
|
+
/** Props to be passed to the content component. */
|
|
15
|
+
contentProps?: Record<string, any>;
|
|
16
|
+
/** Orientation of the scroller - horizontal (default) or vertical. */
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
}
|
|
19
|
+
export declare const Scroller: React.FC<ScrollerProps>, scroller: import("@xh/hoist/core").ElementFactory<ScrollerProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HoistModel } from '@xh/hoist/core';
|
|
2
|
+
/**
|
|
3
|
+
* Internal model for the Scroller component. Used to manage the scroll state and provide
|
|
4
|
+
* scroll functionality. Uses animation frames to ensure smooth scrolling.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class ScrollerModel extends HoistModel {
|
|
8
|
+
contentRef: import("react").RefObject<HTMLDivElement>;
|
|
9
|
+
private scrollStart;
|
|
10
|
+
private scrollSize;
|
|
11
|
+
private clientSize;
|
|
12
|
+
private animationFrameId;
|
|
13
|
+
get showScrollButtons(): boolean;
|
|
14
|
+
get isScrolledToStart(): boolean;
|
|
15
|
+
get isScrolledToEnd(): boolean;
|
|
16
|
+
get isHorizontal(): boolean;
|
|
17
|
+
constructor();
|
|
18
|
+
afterLinked(): void;
|
|
19
|
+
scroll(direction: 'forward' | 'backward'): void;
|
|
20
|
+
stopScrolling(): void;
|
|
21
|
+
onViewportEvent(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { TabModel } from '@xh/hoist/cmp/tab';
|
|
1
|
+
import { TabContainerProps, TabModel } from '@xh/hoist/cmp/tab';
|
|
2
|
+
import { HoistProps, TestSupportProps } from '@xh/hoist/core';
|
|
2
3
|
/**
|
|
3
4
|
* Wrapper for contents to be shown within a TabContainer. This Component is used by TabContainer's
|
|
4
5
|
* internal implementation to:
|
|
@@ -9,4 +10,8 @@ import { TabModel } from '@xh/hoist/cmp/tab';
|
|
|
9
10
|
*
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
interface TabProps extends HoistProps<TabModel>, TestSupportProps {
|
|
14
|
+
childContainerProps?: TabContainerProps['childContainerProps'];
|
|
15
|
+
}
|
|
16
|
+
export declare const tab: import("@xh/hoist/core").ElementFactory<TabProps>;
|
|
17
|
+
export {};
|
|
@@ -4,4 +4,4 @@ import '../Tabs.scss';
|
|
|
4
4
|
* Desktop implementation of TabContainer.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export declare function tabContainerImpl({ model, className, testId, ...props }: TabContainerProps): import("react").ReactElement<import("@xh/hoist/cmp/layout").BoxComponentProps, any>;
|
|
7
|
+
export declare function tabContainerImpl({ model, childContainerProps, className, testId, ...props }: TabContainerProps): import("react").ReactElement<import("@xh/hoist/cmp/layout").BoxComponentProps, any>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TabSwitcherMenuContext } from '@xh/hoist/cmp/tab';
|
|
2
|
+
import { type MenuItemLike, MenuToken } from '@xh/hoist/core';
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare function getContextMenuItem(item: MenuItemLike<MenuToken, TabSwitcherMenuContext>, context: TabSwitcherMenuContext): MenuItemLike<MenuToken, TabSwitcherMenuContext>;
|
|
@@ -22,6 +22,7 @@ export declare let tabContainerImpl: any;
|
|
|
22
22
|
export declare let useContextMenu: any;
|
|
23
23
|
export declare let errorMessageImpl: any;
|
|
24
24
|
export declare let maskImpl: any;
|
|
25
|
+
export declare let DynamicTabSwitcherModel: any;
|
|
25
26
|
/**
|
|
26
27
|
* Provide implementations of functions and classes exported in this file.
|
|
27
28
|
*
|
|
@@ -6,4 +6,4 @@ import { TabContainerProps } from '@xh/hoist/cmp/tab';
|
|
|
6
6
|
*
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export declare function tabContainerImpl({ model, className }: TabContainerProps): import("react").ReactElement<any, any>;
|
|
9
|
+
export declare function tabContainerImpl({ model, className, ...props }: TabContainerProps): import("react").ReactElement<any, any>;
|
package/cmp/tab/TabContainer.ts
CHANGED
|
@@ -4,19 +4,34 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
+
import {TabSwitcherProps} from '@xh/hoist/cmp/tab/Types';
|
|
7
8
|
import {BoxProps, hoistCmp, HoistProps, refreshContextView, uses, XH} from '@xh/hoist/core';
|
|
8
9
|
import {tabContainerImpl as desktopTabContainerImpl} from '@xh/hoist/dynamics/desktop';
|
|
9
10
|
import {tabContainerImpl as mobileTabContainerImpl} from '@xh/hoist/dynamics/mobile';
|
|
10
11
|
import {TabContainerModel} from './TabContainerModel';
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
+
export interface TabContainerProps extends HoistProps<TabContainerModel>, BoxProps {
|
|
14
|
+
/**
|
|
15
|
+
* Indicates whether to include a default switcher docked within this component. Specify as a
|
|
16
|
+
* boolean or props for a TabSwitcher component. False to not include a switcher. Default true.
|
|
17
|
+
*/
|
|
18
|
+
switcher?: boolean | TabSwitcherProps;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Props to apply to child TabContainers, if any. Specify as an object or a function
|
|
22
|
+
* that returns props based on the tabId and depth of the child container.
|
|
23
|
+
*/
|
|
24
|
+
childContainerProps?:
|
|
25
|
+
| TabContainerProps
|
|
26
|
+
| ((ctx: {tabId: string; depth: number}) => TabContainerProps);
|
|
27
|
+
}
|
|
13
28
|
|
|
14
29
|
/**
|
|
15
30
|
* Display a set of child Tabs and (optionally) a switcher control.
|
|
16
31
|
*
|
|
17
|
-
* By default this TabContainer will install a TabSwitcher above the Tabs to control the currently
|
|
18
|
-
* displayed Tab. The '
|
|
19
|
-
*
|
|
32
|
+
* By default, this TabContainer will install a TabSwitcher above the Tabs to control the currently
|
|
33
|
+
* displayed Tab. The 'switcher' prop can be adjusted to place the switcher control on alternative
|
|
34
|
+
* edges of the container.
|
|
20
35
|
*
|
|
21
36
|
* If `switcher` is set to false then no TabSwitcher will be installed. This setting
|
|
22
37
|
* is useful for applications that wish to place an associated TabSwitcher elsewhere in the
|