@deephaven/golden-layout 0.27.0 → 0.27.1-beta.2

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.
@@ -3,6 +3,9 @@ import type Tab from '../controls/Tab';
3
3
  import type { Component } from '../items';
4
4
  import type LayoutManager from '../LayoutManager';
5
5
  import EventEmitter from '../utils/EventEmitter';
6
+ export type CloseOptions = {
7
+ force?: boolean;
8
+ };
6
9
  export default class ItemContainer<C extends ComponentConfig | ReactComponentConfig = ComponentConfig> extends EventEmitter {
7
10
  width?: number;
8
11
  height?: number;
@@ -14,6 +17,7 @@ export default class ItemContainer<C extends ComponentConfig | ReactComponentCon
14
17
  componentState: Record<string, unknown>;
15
18
  };
16
19
  isHidden: boolean;
20
+ beforeCloseHandler: ((options?: CloseOptions) => boolean) | null;
17
21
  _element: JQuery<HTMLElement>;
18
22
  _contentElement: JQuery<HTMLElement>;
19
23
  constructor(config: C, parent: Component, layoutManager: LayoutManager);
@@ -52,8 +56,14 @@ export default class ItemContainer<C extends ComponentConfig | ReactComponentCon
52
56
  * Closes the container if it is closable. Can be called by
53
57
  * both the component within at as well as the contentItem containing
54
58
  * it. Emits a close event before the container itself is closed.
59
+ * @param options Options to pass into the beforeClose handler
55
60
  */
56
- close(): void;
61
+ close(options?: CloseOptions): void;
62
+ /**
63
+ * Sets the beforeCloseHandler to callback
64
+ * @param callback Callback function to call before closing
65
+ */
66
+ beforeClose(callback: ((options?: CloseOptions) => boolean) | null): void;
57
67
  /**
58
68
  * Returns the current state object
59
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ItemContainer.d.ts","sourceRoot":"","sources":["../../src/container/ItemContainer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EAEpB,eAAe,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,EAAuB,SAAS,EAAE,MAAM,UAAU,CAAC;AAC/D,OAA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W,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,IAAI;IAIlE;;;;OAIG;IACH,QAAQ;IAIR;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKvC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,SAAI,EAAE,MAAM,SAAI;CAahC"}
@@ -17,6 +17,7 @@ export default class ItemContainer extends EventEmitter {
17
17
  _defineProperty(this, "tab", void 0);
18
18
  _defineProperty(this, "_config", void 0);
19
19
  _defineProperty(this, "isHidden", false);
20
+ _defineProperty(this, "beforeCloseHandler", void 0);
20
21
  _defineProperty(this, "_element", $(['<div class="lm_item_container">', '<div class="lm_content" tabindex="-1"></div>', '</div>'].join('')));
21
22
  _defineProperty(this, "_contentElement", void 0);
22
23
  this.title = isGLComponentConfig(config) ? config.componentName : '';
@@ -24,6 +25,7 @@ export default class ItemContainer extends EventEmitter {
24
25
  this.layoutManager = layoutManager;
25
26
  this._config = config;
26
27
  this._contentElement = this._element.find('.lm_content');
28
+ this.beforeCloseHandler = null;
27
29
  }
28
30
 
29
31
  /**
@@ -113,14 +115,28 @@ export default class ItemContainer extends EventEmitter {
113
115
  * Closes the container if it is closable. Can be called by
114
116
  * both the component within at as well as the contentItem containing
115
117
  * it. Emits a close event before the container itself is closed.
118
+ * @param options Options to pass into the beforeClose handler
116
119
  */
117
- close() {
118
- if (this._config.isClosable) {
120
+ close(options) {
121
+ var _this$beforeCloseHand, _this$beforeCloseHand2;
122
+ // Not closable, don't do anything
123
+ if (!this._config.isClosable) return;
124
+
125
+ // If beforeCloseHandler returns true or if the handler doesn't exist, close
126
+ if ((_this$beforeCloseHand = (_this$beforeCloseHand2 = this.beforeCloseHandler) === null || _this$beforeCloseHand2 === void 0 ? void 0 : _this$beforeCloseHand2.call(this, options)) !== null && _this$beforeCloseHand !== void 0 ? _this$beforeCloseHand : true) {
119
127
  this.emit('close');
120
128
  this.parent.close();
121
129
  }
122
130
  }
123
131
 
132
+ /**
133
+ * Sets the beforeCloseHandler to callback
134
+ * @param callback Callback function to call before closing
135
+ */
136
+ beforeClose(callback) {
137
+ this.beforeCloseHandler = callback;
138
+ }
139
+
124
140
  /**
125
141
  * Returns the current state object
126
142
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ItemContainer.js","names":["$","isGLComponentConfig","EventEmitter","ItemContainer","constructor","config","parent","layoutManager","join","title","componentName","_config","_contentElement","_element","find","getElement","hide","emit","isHidden","show","height","width","setSize","rowOrColumn","rowOrColumnChild","isColumn","isRow","isRoot","direction","newSize","totalPixel","percentage","delta","contentItems","length","i","callDownwards","close","isClosable","getState","componentState","extendState","state","setState","extend","emitBubblingEvent","setTitle","_$setSize","cl","hdelta","offsetWidth","clientWidth","vdelta","offsetHeight","clientHeight"],"sources":["../../src/container/ItemContainer.ts"],"sourcesContent":["import $ from 'jquery';\nimport {\n ReactComponentConfig,\n isGLComponentConfig,\n ComponentConfig,\n} from '../config';\nimport type Tab from '../controls/Tab';\nimport type { AbstractContentItem, Component } from '../items';\nimport type LayoutManager from '../LayoutManager';\nimport EventEmitter from '../utils/EventEmitter';\n\nexport default class ItemContainer<\n C extends ComponentConfig | ReactComponentConfig = ComponentConfig\n> extends EventEmitter {\n width?: number;\n height?: number;\n\n title?: string;\n\n parent: Component;\n\n layoutManager: LayoutManager;\n\n tab?: Tab;\n\n // This type is to make TS happy and allow ReactComponentConfig passed to container generic\n _config: C & { componentState: Record<string, unknown> };\n\n isHidden = false;\n\n _element = $(\n [\n '<div class=\"lm_item_container\">',\n '<div class=\"lm_content\" tabindex=\"-1\"></div>',\n '</div>',\n ].join('')\n );\n\n _contentElement: JQuery<HTMLElement>;\n\n constructor(config: C, parent: Component, layoutManager: LayoutManager) {\n super();\n\n this.title = isGLComponentConfig(config) ? config.componentName : '';\n this.parent = parent;\n this.layoutManager = layoutManager;\n\n this._config = config as C & { componentState: Record<string, unknown> };\n\n this._contentElement = this._element.find('.lm_content');\n }\n\n /**\n * Get the inner DOM element the container's content\n * is intended to live in\n */\n getElement() {\n return this._contentElement;\n }\n\n /**\n * Hide the container. Notifies the containers content first\n * and then hides the DOM node. If the container is already hidden\n * this should have no effect\n */\n hide() {\n this.emit('hide');\n this.isHidden = true;\n this._element.hide();\n }\n\n /**\n * Shows a previously hidden container. Notifies the\n * containers content first and then shows the DOM element.\n * If the container is already visible this has no effect.\n */\n show() {\n this.emit('show');\n this.isHidden = false;\n this._element.show();\n // call shown only if the container has a valid size\n if (this.height != 0 || this.width != 0) {\n this.emit('shown');\n }\n }\n\n /**\n * Set the size from within the container. Traverses up\n * the item tree until it finds a row or column element\n * and resizes its items accordingly.\n *\n * If this container isn't a descendant of a row or column\n * it returns false\n * @todo Rework!!!\n * @param width The new width in pixel\n * @param height The new height in pixel\n *\n * @returns resizeSuccesful\n */\n setSize(width: number, height: number) {\n let rowOrColumn: AbstractContentItem | null = this.parent;\n let rowOrColumnChild: AbstractContentItem | null = null;\n\n while (rowOrColumn && !rowOrColumn.isColumn && !rowOrColumn.isRow) {\n rowOrColumnChild = rowOrColumn;\n rowOrColumn = rowOrColumn.parent;\n\n /**\n * No row or column has been found\n */\n if (rowOrColumn?.isRoot) {\n return false;\n }\n }\n\n if (!rowOrColumn || !rowOrColumnChild) {\n return false;\n }\n\n const direction = rowOrColumn.isColumn ? 'height' : 'width';\n const newSize = direction === 'height' ? height : width;\n\n const totalPixel =\n (this[direction] ?? 0) *\n (1 / ((rowOrColumnChild.config[direction] ?? 0) / 100));\n const percentage = (newSize / totalPixel) * 100;\n const delta =\n ((rowOrColumnChild.config[direction] ?? 0) - percentage) /\n (rowOrColumn.contentItems.length - 1);\n\n for (let i = 0; i < rowOrColumn.contentItems.length; i++) {\n if (rowOrColumn.contentItems[i] === rowOrColumnChild) {\n rowOrColumn.contentItems[i].config[direction] = percentage;\n } else {\n rowOrColumn.contentItems[i].config[direction] =\n (rowOrColumn.contentItems[i].config[direction] ?? 0) + delta;\n }\n }\n\n rowOrColumn.callDownwards('setSize');\n\n return true;\n }\n\n /**\n * Closes the container if it is closable. Can be called by\n * both the component within at as well as the contentItem containing\n * it. Emits a close event before the container itself is closed.\n */\n close() {\n if (this._config.isClosable) {\n this.emit('close');\n this.parent.close();\n }\n }\n\n /**\n * Returns the current state object\n *\n * @returns state\n */\n getState() {\n return this._config.componentState;\n }\n\n /**\n * Merges the provided state into the current one\n *\n * @param state\n */\n extendState(state: string) {\n this.setState($.extend(true, this.getState(), state));\n }\n\n /**\n * Notifies the layout manager of a stateupdate\n *\n * @param state\n */\n setState(state: Record<string, unknown>) {\n this._config.componentState = state;\n this.parent.emitBubblingEvent('stateChanged');\n }\n\n /**\n * Set's the components title\n *\n * @param title\n */\n setTitle(title: string) {\n this.parent.setTitle(title);\n }\n\n /**\n * Set's the containers size. Called by the container's component.\n * To set the size programmatically from within the container please\n * use the public setSize method\n *\n * @param width in px\n * @param height in px\n */\n _$setSize(width = 0, height = 0) {\n if (width !== this.width || height !== this.height) {\n this.width = width;\n this.height = height;\n var cl = this._contentElement[0];\n var hdelta = cl.offsetWidth - cl.clientWidth;\n var vdelta = cl.offsetHeight - cl.clientHeight;\n this._contentElement\n .width(this.width - hdelta)\n .height(this.height - vdelta);\n this.emit('resize');\n }\n }\n}\n"],"mappings":";;;AAAA,OAAOA,CAAC,MAAM,QAAQ;AAAC,SAGrBC,mBAAmB;AAAA,OAMdC,YAAY;AAEnB,eAAe,MAAMC,aAAa,SAExBD,YAAY,CAAC;EAYrB;;EAeAE,WAAW,CAACC,MAAS,EAAEC,MAAiB,EAAEC,aAA4B,EAAE;IACtE,KAAK,EAAE;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,kCAbC,KAAK;IAAA,kCAELP,CAAC,CACV,CACE,iCA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MAChC,IAAIqC,MAAM,GAAGD,EAAE,CAACE,WAAW,GAAGF,EAAE,CAACG,WAAW;MAC5C,IAAIC,MAAM,GAAGJ,EAAE,CAACK,YAAY,GAAGL,EAAE,CAACM,YAAY;MAC9C,IAAI,CAAC1C,eAAe,CACjBS,KAAK,CAAC,IAAI,CAACA,KAAK,GAAG4B,MAAM,CAAC,CAC1B7B,MAAM,CAAC,IAAI,CAACA,MAAM,GAAGgC,MAAM,CAAC;MAC/B,IAAI,CAACnC,IAAI,CAAC,QAAQ,CAAC;IACrB;EACF;AACF"}
1
+ {"version":3,"file":"ItemContainer.js","names":["$","isGLComponentConfig","EventEmitter","ItemContainer","constructor","config","parent","layoutManager","join","title","componentName","_config","_contentElement","_element","find","beforeCloseHandler","getElement","hide","emit","isHidden","show","height","width","setSize","rowOrColumn","rowOrColumnChild","isColumn","isRow","isRoot","direction","newSize","totalPixel","percentage","delta","contentItems","length","i","callDownwards","close","options","isClosable","beforeClose","callback","getState","componentState","extendState","state","setState","extend","emitBubblingEvent","setTitle","_$setSize","cl","hdelta","offsetWidth","clientWidth","vdelta","offsetHeight","clientHeight"],"sources":["../../src/container/ItemContainer.ts"],"sourcesContent":["import $ from 'jquery';\nimport {\n ReactComponentConfig,\n isGLComponentConfig,\n ComponentConfig,\n} from '../config';\nimport type Tab from '../controls/Tab';\nimport type { AbstractContentItem, Component } from '../items';\nimport type LayoutManager from '../LayoutManager';\nimport EventEmitter from '../utils/EventEmitter';\n\nexport type CloseOptions = { force?: boolean };\n\nexport default class ItemContainer<\n C extends ComponentConfig | ReactComponentConfig = ComponentConfig\n> extends EventEmitter {\n width?: number;\n height?: number;\n\n title?: string;\n\n parent: Component;\n\n layoutManager: LayoutManager;\n\n tab?: Tab;\n\n // This type is to make TS happy and allow ReactComponentConfig passed to container generic\n _config: C & { componentState: Record<string, unknown> };\n\n isHidden = false;\n\n beforeCloseHandler: ((options?: CloseOptions) => boolean) | null;\n\n _element = $(\n [\n '<div class=\"lm_item_container\">',\n '<div class=\"lm_content\" tabindex=\"-1\"></div>',\n '</div>',\n ].join('')\n );\n\n _contentElement: JQuery<HTMLElement>;\n\n constructor(config: C, parent: Component, layoutManager: LayoutManager) {\n super();\n\n this.title = isGLComponentConfig(config) ? config.componentName : '';\n this.parent = parent;\n this.layoutManager = layoutManager;\n\n this._config = config as C & { componentState: Record<string, unknown> };\n\n this._contentElement = this._element.find('.lm_content');\n\n this.beforeCloseHandler = null;\n }\n\n /**\n * Get the inner DOM element the container's content\n * is intended to live in\n */\n getElement() {\n return this._contentElement;\n }\n\n /**\n * Hide the container. Notifies the containers content first\n * and then hides the DOM node. If the container is already hidden\n * this should have no effect\n */\n hide() {\n this.emit('hide');\n this.isHidden = true;\n this._element.hide();\n }\n\n /**\n * Shows a previously hidden container. Notifies the\n * containers content first and then shows the DOM element.\n * If the container is already visible this has no effect.\n */\n show() {\n this.emit('show');\n this.isHidden = false;\n this._element.show();\n // call shown only if the container has a valid size\n if (this.height != 0 || this.width != 0) {\n this.emit('shown');\n }\n }\n\n /**\n * Set the size from within the container. Traverses up\n * the item tree until it finds a row or column element\n * and resizes its items accordingly.\n *\n * If this container isn't a descendant of a row or column\n * it returns false\n * @todo Rework!!!\n * @param width The new width in pixel\n * @param height The new height in pixel\n *\n * @returns resizeSuccesful\n */\n setSize(width: number, height: number) {\n let rowOrColumn: AbstractContentItem | null = this.parent;\n let rowOrColumnChild: AbstractContentItem | null = null;\n\n while (rowOrColumn && !rowOrColumn.isColumn && !rowOrColumn.isRow) {\n rowOrColumnChild = rowOrColumn;\n rowOrColumn = rowOrColumn.parent;\n\n /**\n * No row or column has been found\n */\n if (rowOrColumn?.isRoot) {\n return false;\n }\n }\n\n if (!rowOrColumn || !rowOrColumnChild) {\n return false;\n }\n\n const direction = rowOrColumn.isColumn ? 'height' : 'width';\n const newSize = direction === 'height' ? height : width;\n\n const totalPixel =\n (this[direction] ?? 0) *\n (1 / ((rowOrColumnChild.config[direction] ?? 0) / 100));\n const percentage = (newSize / totalPixel) * 100;\n const delta =\n ((rowOrColumnChild.config[direction] ?? 0) - percentage) /\n (rowOrColumn.contentItems.length - 1);\n\n for (let i = 0; i < rowOrColumn.contentItems.length; i++) {\n if (rowOrColumn.contentItems[i] === rowOrColumnChild) {\n rowOrColumn.contentItems[i].config[direction] = percentage;\n } else {\n rowOrColumn.contentItems[i].config[direction] =\n (rowOrColumn.contentItems[i].config[direction] ?? 0) + delta;\n }\n }\n\n rowOrColumn.callDownwards('setSize');\n\n return true;\n }\n\n /**\n * Closes the container if it is closable. Can be called by\n * both the component within at as well as the contentItem containing\n * it. Emits a close event before the container itself is closed.\n * @param options Options to pass into the beforeClose handler\n */\n close(options?: CloseOptions) {\n // Not closable, don't do anything\n if (!this._config.isClosable) return;\n\n // If beforeCloseHandler returns true or if the handler doesn't exist, close\n if (this.beforeCloseHandler?.(options) ?? true) {\n this.emit('close');\n this.parent.close();\n }\n }\n\n /**\n * Sets the beforeCloseHandler to callback\n * @param callback Callback function to call before closing\n */\n beforeClose(callback: ((options?: CloseOptions) => boolean) | null) {\n this.beforeCloseHandler = callback;\n }\n\n /**\n * Returns the current state object\n *\n * @returns state\n */\n getState() {\n return this._config.componentState;\n }\n\n /**\n * Merges the provided state into the current one\n *\n * @param state\n */\n extendState(state: string) {\n this.setState($.extend(true, this.getState(), state));\n }\n\n /**\n * Notifies the layout manager of a stateupdate\n *\n * @param state\n */\n setState(state: Record<string, unknown>) {\n this._config.componentState = state;\n this.parent.emitBubblingEvent('stateChanged');\n }\n\n /**\n * Set's the components title\n *\n * @param title\n */\n setTitle(title: string) {\n this.parent.setTitle(title);\n }\n\n /**\n * Set's the containers size. Called by the container's component.\n * To set the size programmatically from within the container please\n * use the public setSize method\n *\n * @param width in px\n * @param height in px\n */\n _$setSize(width = 0, height = 0) {\n if (width !== this.width || height !== this.height) {\n this.width = width;\n this.height = height;\n var cl = this._contentElement[0];\n var hdelta = cl.offsetWidth - cl.clientWidth;\n var vdelta = cl.offsetHeight - cl.clientHeight;\n this._contentElement\n .width(this.width - hdelta)\n .height(this.height - vdelta);\n this.emit('resize');\n }\n }\n}\n"],"mappings":";;;AAAA,OAAOA,CAAC,MAAM,QAAQ;AAAC,SAGrBC,mBAAmB;AAAA,OAMdC,YAAY;AAInB,eAAe,MAAMC,aAAa,SAExBD,YAAY,CAAC;EAYrB;;EAiBAE,WAAW,CAACC,MAAS,EAAEC,MAAiB,EAAEC,aAA4B,EAAE;IACtE,KAAK,EAAE;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,kCAfC,KAAK;IAAA;IAAA,kCAILP,CAAC,CACV,CACE,iCAAiC,EACjC,8CAA8C,EAC9C,QAAQ,CACT,CAACQ,IAAI,CAAC,EAAE,CAAC,CACX;IAAA;IAOC,IAAI,CAACC,KAAK,GAAGR,mBAAmB,CAACI,MAAM,CAAC,GAAGA,MAAM,CAACK,aAAa,GAAG,EAAE;IACpE,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,aAAa,GAAGA,aAAa;IAElC,IAAI,CAACI,OAAO,GAAGN,MAAyD;IAExE,IAAI,CAACO,eAAe,GAAG,IAAI,CAACC,QAAQ,CAACC,IAAI,CAAC,aAAa,CAAC;IAExD,IAAI,CAACC,kBAAkB,GAAG,IAAI;EAChC;;EAEA;AACF;AACA;AACA;EACEC,UAAU,GAAG;IACX,OAAO,IAAI,CAACJ,eAAe;EAC7B;;EAEA;AACF;AACA;AACA;AACA;EACEK,IAAI,GAAG;IACL,IAAI,CAACC,IAAI,CAAC,MAAM,CAAC;IACjB,IAAI,CAACC,QAAQ,GAAG,IAAI;IACpB,IAAI,CAACN,QAAQ,CAACI,IAAI,EAAE;EACtB;;EAEA;AACF;AACA;AACA;AACA;EACEG,IAAI,GAAG;IACL,IAAI,CAACF,IAAI,CAAC,MAAM,CAAC;IACjB,IAAI,CAACC,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACN,QAAQ,CAACO,IAAI,EAAE;IACpB;IACA,I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C;EACvD;;EAEA;AACF;AACA;AACA;AACA;EACEC,QAAQ,CAACD,KAA8B,EAAE;IACvC,IAAI,CAACnC,OAAO,CAACiC,cAAc,GAAGE,KAAK;IACnC,IAAI,CAACxC,MAAM,CAAC2C,iBAAiB,CAAC,cAAc,CAAC;EAC/C;;EAEA;AACF;AACA;AACA;AACA;EACEC,QAAQ,CAACzC,KAAa,EAAE;IACtB,IAAI,CAACH,MAAM,CAAC4C,QAAQ,CAACzC,KAAK,CAAC;EAC7B;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE0C,SAAS,GAAwB;IAAA,IAAvB7B,KAAK,uEAAG,CAAC;IAAA,IAAED,MAAM,uEAAG,CAAC;IAC7B,IAAIC,KAAK,KAAK,IAAI,CAACA,KAAK,IAAID,MAAM,KAAK,IAAI,CAACA,MAAM,EAAE;MAClD,IAAI,CAACC,KAAK,GAAGA,KAAK;MAClB,IAAI,CAACD,MAAM,GAAGA,MAAM;MACpB,IAAI+B,EAAE,GAAG,IAAI,CAACxC,eAAe,CAAC,CAAC,CAAC;MAChC,IAAIyC,MAAM,GAAGD,EAAE,CAACE,WAAW,GAAGF,EAAE,CAACG,WAAW;MAC5C,IAAIC,MAAM,GAAGJ,EAAE,CAACK,YAAY,GAAGL,EAAE,CAACM,YAAY;MAC9C,IAAI,CAAC9C,eAAe,CACjBU,KAAK,CAAC,IAAI,CAACA,KAAK,GAAG+B,MAAM,CAAC,CAC1BhC,MAAM,CAAC,IAAI,CAACA,MAAM,GAAGmC,MAAM,CAAC;MAC/B,IAAI,CAACtC,IAAI,CAAC,QAAQ,CAAC;IACrB;EACF;AACF"}
@@ -1,3 +1,4 @@
1
1
  export { default as ItemContainer } from './ItemContainer';
2
2
  export { default as Container } from './ItemContainer';
3
+ export type { CloseOptions } from './ItemContainer';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","ItemContainer","Container"],"sources":["../../src/container/index.ts"],"sourcesContent":["export { default as ItemContainer } from './ItemContainer';\nexport { default as Container } from './ItemContainer';\n"],"mappings":"SAASA,OAAO,IAAIC,aAAa;AAAA,SACxBD,OAAO,IAAIE,SAAS"}
1
+ {"version":3,"file":"index.js","names":["default","ItemContainer","Container"],"sources":["../../src/container/index.ts"],"sourcesContent":["export { default as ItemContainer } from './ItemContainer';\nexport { default as Container } from './ItemContainer';\nexport type { CloseOptions } from './ItemContainer';\n"],"mappings":"SAASA,OAAO,IAAIC,aAAa;AAAA,SACxBD,OAAO,IAAIE,SAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/golden-layout",
3
- "version": "0.27.0",
3
+ "version": "0.27.1-beta.2+073f8f5",
4
4
  "author": "Deephaven Data Labs LLC",
5
5
  "license": "Apache-2.0",
6
6
  "description": "A multi-screen javascript Layout manager",
@@ -51,5 +51,5 @@
51
51
  "karma-browserify": "^8.1.0",
52
52
  "watchify": "^4.0.0"
53
53
  },
54
- "gitHead": "7f30992e9e99dac261f8d64e8a682a06e6a15c76"
54
+ "gitHead": "073f8f566aa57132edacc5867b8e02dd7ac4be7d"
55
55
  }