terrier-engine 4.71.1 → 4.71.5
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/package.json +1 -1
- package/terrier/parts/panel-part.ts +1 -0
- package/terrier/tabs.ts +12 -10
package/package.json
CHANGED
|
@@ -69,6 +69,7 @@ export default abstract class PanelPart<TState> extends ContentPart<TState & { c
|
|
|
69
69
|
this.app.theme.renderIcon(h2, this._icon, 'link')
|
|
70
70
|
}
|
|
71
71
|
h2.div('.title', {text: this._title || 'Call setTitle()'})
|
|
72
|
+
h2.class(...this._titleClasses)
|
|
72
73
|
})
|
|
73
74
|
header.div('.tertiary-actions', actions => {
|
|
74
75
|
this.theme.renderActions(actions, this.getActions('tertiary'))
|
package/terrier/tabs.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Logger } from "tuff-core/logging"
|
|
|
2
2
|
import Messages from "tuff-core/messages"
|
|
3
3
|
import { Part, PartParent, PartTag, StatelessPart } from "tuff-core/parts"
|
|
4
4
|
import TerrierPart from "./parts/terrier-part"
|
|
5
|
-
import { Action, IconName, Packet } from "./theme"
|
|
5
|
+
import { Action, ColorName, IconName, Packet } from "./theme"
|
|
6
6
|
import SortablePlugin from "tuff-sortable/sortable-plugin"
|
|
7
7
|
|
|
8
8
|
const log = new Logger("Tabs")
|
|
@@ -16,7 +16,9 @@ export type TabParams = {
|
|
|
16
16
|
icon?: IconName
|
|
17
17
|
state?: 'enabled' | 'disabled' | 'hidden'
|
|
18
18
|
classes?: string[]
|
|
19
|
+
tabClasses?: string[]
|
|
19
20
|
click?: Packet
|
|
21
|
+
iconColor?: ColorName
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -42,7 +44,6 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
42
44
|
private tabOrder = [] as string[]
|
|
43
45
|
changeTabKey = Messages.typedKey<{ tabKey: string }>()
|
|
44
46
|
changeSideKey = Messages.typedKey<{ side: TabSide }>()
|
|
45
|
-
tabsModifiedKey = Messages.untypedKey()
|
|
46
47
|
|
|
47
48
|
async init() {
|
|
48
49
|
this.state = Object.assign({ reorderable: false }, this.state)
|
|
@@ -67,17 +68,12 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
67
68
|
const ourTabList = this.element?.getElementsByClassName(`tablist-${this.id}`)[0]
|
|
68
69
|
const tabElements = Array.from(ourTabList?.getElementsByClassName('tab') || []) as HTMLElement[]
|
|
69
70
|
this.tabOrder = tabElements.map(tabElement => tabElement.dataset?.key!)
|
|
70
|
-
this.#onTabsModified()
|
|
71
71
|
this.dirty()
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
#onTabsModified() {
|
|
78
|
-
this.emitMessage(this.tabsModifiedKey, null)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
77
|
/**
|
|
82
78
|
* Gets the current tab order as an array of keys.
|
|
83
79
|
*/
|
|
@@ -102,7 +98,6 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
102
98
|
}, tab))
|
|
103
99
|
if (!this.tabOrder.includes(tab.key))
|
|
104
100
|
this.tabOrder.push(tab.key)
|
|
105
|
-
this.#onTabsModified()
|
|
106
101
|
this.dirty()
|
|
107
102
|
return part
|
|
108
103
|
}
|
|
@@ -118,6 +113,13 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
118
113
|
this.dirty()
|
|
119
114
|
}
|
|
120
115
|
|
|
116
|
+
partialUpdateTab(tab: Partial<TabParams> & Pick<TabParams, 'key'>): void {
|
|
117
|
+
const existingTab = this.tabs.get(tab.key)
|
|
118
|
+
if (!existingTab) throw `Tab with key '${tab.key}' does not exist!`
|
|
119
|
+
Object.assign(existingTab, tab)
|
|
120
|
+
this.dirty()
|
|
121
|
+
}
|
|
122
|
+
|
|
121
123
|
/**
|
|
122
124
|
* Removes the tab with the given key.
|
|
123
125
|
* @param key
|
|
@@ -130,7 +132,6 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
130
132
|
this.tabs.delete(key)
|
|
131
133
|
this.tabOrder.splice(this.tabOrder.indexOf(key), 1)
|
|
132
134
|
this.removeChild(tab.part)
|
|
133
|
-
this.#onTabsModified()
|
|
134
135
|
this.state.currentTab = undefined
|
|
135
136
|
this.dirty()
|
|
136
137
|
}
|
|
@@ -189,11 +190,12 @@ export class TabContainerPart extends TerrierPart<TabContainerState> {
|
|
|
189
190
|
if (tab.state == 'hidden') continue
|
|
190
191
|
|
|
191
192
|
tabList.a('.tab', a => {
|
|
193
|
+
if (tab.tabClasses?.length) a.class(...tab.tabClasses)
|
|
192
194
|
a.attrs({ draggable: this.state.reorderable })
|
|
193
195
|
a.data({ key: tab.key })
|
|
194
196
|
a.class(tab.state || 'enabled')
|
|
195
197
|
if (tab.key === currentTabKey) a.class('active')
|
|
196
|
-
if (tab.icon) this.theme.renderIcon(a, tab.icon)
|
|
198
|
+
if (tab.icon) this.theme.renderIcon(a, tab.icon, tab.iconColor ? tab.iconColor : 'secondary')
|
|
197
199
|
a.span({ text: tab.title })
|
|
198
200
|
a.emitClick(this.changeTabKey, { tabKey: tab.key })
|
|
199
201
|
if (tab.click) a.emitClick(tab.click.key, tab.click.data || {})
|