terrier-engine 4.61.0 → 4.62.0

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.61.0",
7
+ "version": "4.62.0",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -81,6 +81,16 @@ export class PanelFragment extends ContentFragment {
81
81
  return this
82
82
  }
83
83
 
84
+ protected _customActions?: (parent: HtmlParentTag) => void
85
+
86
+ /**
87
+ * @param fun a function that renders custom content in between the primary and secondary actions
88
+ */
89
+ customActions(fun: (parent: HtmlParentTag) => void) {
90
+ this._customActions = fun
91
+ return this
92
+ }
93
+
84
94
  /**
85
95
  * Renders the panel into the given parent tag
86
96
  * @param parent
@@ -104,7 +114,7 @@ export class PanelFragment extends ContentFragment {
104
114
  this._content(content)
105
115
  }
106
116
  })
107
- panelActions(panel, this.actions, this.theme)
117
+ panelActions(panel, this.actions, this.theme, this._customActions)
108
118
  }).class(...this._classes)
109
119
  }
110
120
 
@@ -115,19 +125,34 @@ export class PanelFragment extends ContentFragment {
115
125
  * @param panel the .panel container
116
126
  * @param actions the actions
117
127
  * @param theme the theme with which to render actions
128
+ * @param customRender a custom function to render in between the primary and secondary actions
118
129
  */
119
- function panelActions(panel: PartTag, actions: PanelActions, theme: Theme) {
120
- if (actions.primary.length || actions.secondary.length) {
121
- panel.div('.panel-actions', actionsContainer => {
122
- for (const level of ['secondary', 'primary'] as const) {
123
- const levelActions = actions[level]
124
- if (!levelActions?.length) continue;
125
- actionsContainer.div(`.${level}-actions`, container => {
126
- theme.renderActions(container, levelActions, { defaultClass: level })
127
- })
128
- }
129
- })
130
- }
130
+ function panelActions(panel: PartTag, actions: PanelActions, theme: Theme, customRender?: (parent: HtmlParentTag) => void) {
131
+ if (!actions.primary.length && !actions.secondary.length && !customRender) return;
132
+ panel.div('.panel-actions', actionsContainer => {
133
+ // secondary actions
134
+ const secondaryActions = actions.secondary
135
+ if (secondaryActions.length) {
136
+ actionsContainer.div('.secondary-actions', container => {
137
+ theme.renderActions(container, secondaryActions, { defaultClass: 'secondary' })
138
+ })
139
+ }
140
+
141
+ // custom render
142
+ if (customRender) {
143
+ actionsContainer.div('.custom-actions', container => {
144
+ customRender(container)
145
+ })
146
+ }
147
+
148
+ // primary actions
149
+ const primaryActions = actions.primary
150
+ if (primaryActions.length) {
151
+ actionsContainer.div('.primary-actions', container => {
152
+ theme.renderActions(container, primaryActions, { defaultClass: 'primary' })
153
+ })
154
+ }
155
+ })
131
156
  }
132
157
 
133
158
 
package/terrier/theme.ts CHANGED
@@ -85,7 +85,7 @@ export default class Theme {
85
85
  }
86
86
 
87
87
  /**
88
- * Renders one ore more `Action`s into a parent tag.
88
+ * Renders one or more `Action`s into a parent tag.
89
89
  * @param parent the HTML element in which to render the action
90
90
  * @param actions the action or actions to render
91
91
  * @param options additional rendering options