@finsemble/finsemble-ui 7.0.0-beta.4 → 7.0.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finsemble/finsemble-ui",
3
- "version": "7.0.0-beta.4",
3
+ "version": "7.0.1",
4
4
  "description": "Ready-made React components to give you a head-start building your SmartDesktop.",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -28,7 +28,7 @@
28
28
  "build-storybook": "build-storybook"
29
29
  },
30
30
  "dependencies": {
31
- "@finsemble/finsemble-api": "7.0.0-beta.4",
31
+ "@finsemble/finsemble-api": "7.0.1",
32
32
  "@q42/floating-focus-a11y": "^1.3.3",
33
33
  "@reduxjs/toolkit": "^1.5.0",
34
34
  "@svgr/webpack": "^5.5.0",
@@ -56,8 +56,8 @@ body:after {
56
56
  background-color: var(--window-border-color);
57
57
  }
58
58
 
59
- /*
60
- * The next few items give the border of windows
59
+ /*
60
+ * The next few items give the border of windows
61
61
  * thickness so that the user can see them
62
62
  */
63
63
  html:before {
@@ -631,7 +631,7 @@ html.desktop-active .fsbl-active-tab .fsbl-tab-title {
631
631
  top: 1px;
632
632
  }
633
633
 
634
- .tab__input {
634
+ #title_editor_input {
635
635
  font-size: 12px;
636
636
  padding: 2px 10px;
637
637
  width: 80%;
@@ -3,15 +3,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _Title_instances, _Title_setWindowTitle, _Title_setTabTitle, _Title_getWindowManagerForTab, _Title_calculateTabTitle, _Title_getUserEditedTitle, _Title_getConfigTitle, _Title_getDocumentTitle, _Title_getAppDTitle, _Title_addListeners, _Title_removeListeners;
6
+ var _Title_instances, _Title_getWindowManagerForTab, _Title_calculateTabTitle, _Title_getUserEditedTitle, _Title_getConfigTitle, _Title_getDocumentTitle, _Title_getAppDTitle, _Title_addListeners, _Title_removeListeners;
7
7
  import React, { Component } from "react";
8
8
  import { Icon } from "../../icon/Icon";
9
9
  import { Store } from "../stores/windowTitleBarStore";
10
10
  const WINDOW_TAB_TITLE_STORE = "window-tab-title";
11
11
  const FIELD_NAME_PERSISTED_TITLE = "persistedTitle";
12
+ let windowTabNameStore;
12
13
  const getWindowTabNameStore = async () => {
13
- let { data: store } = await FSBL.Clients.DistributedStoreClient.createGlobalStore({ store: WINDOW_TAB_TITLE_STORE });
14
- return store;
14
+ if (!windowTabNameStore) {
15
+ let { data: store } = await FSBL.Clients.DistributedStoreClient.createGlobalStore({
16
+ store: WINDOW_TAB_TITLE_STORE,
17
+ });
18
+ windowTabNameStore = store;
19
+ }
20
+ return windowTabNameStore;
15
21
  };
16
22
  function EditTab(props) {
17
23
  const [editingTitle, setEditingTitle] = React.useState(false);
@@ -66,11 +72,11 @@ function EditTab(props) {
66
72
  e.stopPropagation();
67
73
  e.preventDefault();
68
74
  } },
69
- React.createElement("input", { ref: inputEl, onBlur: blurHandler, onKeyDown: keyDownHandler, type: "text", className: "tab__input", maxLength: 32 })))) : (props.children)));
75
+ React.createElement("input", { id: "title_editor_input", ref: inputEl, onBlur: blurHandler, onKeyDown: keyDownHandler, type: "text", className: "tab__input", maxLength: 32 })))) : (props.children)));
70
76
  }
71
77
  export class Title extends Component {
72
78
  constructor(props) {
73
- var _a, _b;
79
+ var _a, _b, _c;
74
80
  super(props);
75
81
  _Title_instances.add(this);
76
82
  this.tabTitleChangedStoreListener = (err, response) => {
@@ -79,20 +85,43 @@ export class Title extends Component {
79
85
  return;
80
86
  }
81
87
  FSBL.Clients.Logger.debug(`Store "${WINDOW_TAB_TITLE_STORE}" notified of new title "${response.value}" for window "${response.field}"`);
82
- this.updateTitle();
88
+ if (!!this._mounted) {
89
+ this.updateTitle();
90
+ }
83
91
  };
84
92
  this._mounted = false;
93
+ let initialTitle = " ";
94
+ if (undefined !== (finsembleWindow === null || finsembleWindow === void 0 ? void 0 : finsembleWindow.thisWindowName) &&
95
+ (finsembleWindow === null || finsembleWindow === void 0 ? void 0 : finsembleWindow.thisWindowName) === ((_a = props === null || props === void 0 ? void 0 : props.windowIdentifier) === null || _a === void 0 ? void 0 : _a.windowName)) {
96
+ initialTitle = document.title || ((_b = props.windowIdentifier) === null || _b === void 0 ? void 0 : _b.windowName);
97
+ }
85
98
  this.state = {
86
- title: document.title || ((_a = props.windowIdentifier) === null || _a === void 0 ? void 0 : _a.windowName),
99
+ title: initialTitle,
87
100
  icon: null,
88
- windowName: (_b = props.windowIdentifier) === null || _b === void 0 ? void 0 : _b.windowName,
101
+ windowName: (_c = props.windowIdentifier) === null || _c === void 0 ? void 0 : _c.windowName,
89
102
  };
90
103
  this.updateTitle = this.updateTitle.bind(this);
91
104
  this.updateTitle();
92
105
  }
93
106
  async updateTitle() {
94
- __classPrivateFieldGet(this, _Title_instances, "m", _Title_setTabTitle).call(this);
95
- __classPrivateFieldGet(this, _Title_instances, "m", _Title_setWindowTitle).call(this);
107
+ var _a, _b, _c;
108
+ const { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);
109
+ const { data: tabWindowOptions } = await tabWindow.getOptions();
110
+ let title = await __classPrivateFieldGet(this, _Title_instances, "m", _Title_calculateTabTitle).call(this);
111
+ const icon = (_c = (_b = (_a = tabWindowOptions) === null || _a === void 0 ? void 0 : _a.icons) === null || _b === void 0 ? void 0 : _b.titleBarIcon) !== null && _c !== void 0 ? _c : {
112
+ imageType: "initials",
113
+ name: title,
114
+ };
115
+ FSBL.Clients.Logger.debug(`Setting tab title ${title} for window ${this.props.windowIdentifier.windowName}`);
116
+ if (!!this._mounted) {
117
+ this.setState({
118
+ title,
119
+ icon: Object.assign(Object.assign({}, icon), { category: "Application" }),
120
+ });
121
+ }
122
+ if (finsembleWindow.thisWindowName === this.props.windowIdentifier.windowName) {
123
+ document.title = await __classPrivateFieldGet(this, _Title_instances, "m", _Title_calculateTabTitle).call(this);
124
+ }
96
125
  }
97
126
  componentDidMount() {
98
127
  this._mounted = true;
@@ -117,38 +146,7 @@ export class Title extends Component {
117
146
  React.createElement("div", { className: "title-text" }, this.state.title))));
118
147
  }
119
148
  }
120
- _Title_instances = new WeakSet(), _Title_setWindowTitle = async function _Title_setWindowTitle() {
121
- const store = await getWindowTabNameStore();
122
- if (!store) {
123
- FSBL.Clients.Logger.warn("Error setting the window title: the store was not found");
124
- return;
125
- }
126
- if (finsembleWindow.thisWindowName === this.props.windowIdentifier.windowName) {
127
- document.title = await __classPrivateFieldGet(this, _Title_instances, "m", _Title_calculateTabTitle).call(this);
128
- }
129
- }, _Title_setTabTitle = async function _Title_setTabTitle() {
130
- var _a, _b, _c;
131
- const { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);
132
- const { data: tabWindowOptions } = await tabWindow.getOptions();
133
- let title = await __classPrivateFieldGet(this, _Title_instances, "m", _Title_calculateTabTitle).call(this);
134
- const icon = (_c = (_b = (_a = tabWindowOptions) === null || _a === void 0 ? void 0 : _a.icons) === null || _b === void 0 ? void 0 : _b.titleBarIcon) !== null && _c !== void 0 ? _c : {
135
- imageType: "initials",
136
- name: title,
137
- };
138
- tabWindow.getComponentState({ field: FIELD_NAME_PERSISTED_TITLE }, (error, persistedTitle) => {
139
- if (!this._mounted) {
140
- return;
141
- }
142
- if (persistedTitle) {
143
- title = persistedTitle;
144
- }
145
- FSBL.Clients.Logger.debug(`Setting tab title ${title} for window ${this.props.windowIdentifier.windowName}`);
146
- this.setState({
147
- title,
148
- icon: Object.assign(Object.assign({}, icon), { category: "Application" }),
149
- });
150
- });
151
- }, _Title_getWindowManagerForTab = async function _Title_getWindowManagerForTab() {
149
+ _Title_instances = new WeakSet(), _Title_getWindowManagerForTab = async function _Title_getWindowManagerForTab() {
152
150
  var _a, _b, _c, _d, _e, _f, _g, _h;
153
151
  if (!!((_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.windowIdentifier) === null || _b === void 0 ? void 0 : _b.windowName)) {
154
152
  const tabsWindowName = this.props.windowIdentifier.windowName;
@@ -163,14 +161,10 @@ _Title_instances = new WeakSet(), _Title_setWindowTitle = async function _Title_
163
161
  __classPrivateFieldGet(this, _Title_instances, "m", _Title_getAppDTitle).call(this));
164
162
  }, _Title_getUserEditedTitle = async function _Title_getUserEditedTitle() {
165
163
  const { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);
166
- return new Promise((resolve, reject) => {
164
+ return new Promise((resolve) => {
167
165
  tabWindow.getComponentState({ field: FIELD_NAME_PERSISTED_TITLE }, (error, persistedTitle) => {
168
- if (!this._mounted) {
169
- resolve(undefined);
170
- return;
171
- }
172
166
  if (!!error) {
173
- reject(error);
167
+ resolve(undefined);
174
168
  }
175
169
  else {
176
170
  resolve(persistedTitle);
@@ -1 +1 @@
1
- {"version":3,"file":"windowTitle.js","sourceRoot":"","sources":["../../../../src/components/windowTitleBar/components/windowTitle.tsx"],"names":[],"mappings":";;;;;;AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAiDtD,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAOpD,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE;IAIxC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;IACrH,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAMF,SAAS,OAAO,CAAC,KAAm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AC,KAAK,CACxB,8BAA8B,sBAAsB,gBAAgB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAC7G,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC","sourcesContent":["import { WindowIdentifier, WindowDescriptor, services } from \"@finsemble/finsemble-api\";\nimport { ListenerFunction } from \"@finsemble/finsemble-api/types/clients/StoreModel\";\nimport { StandardError } from \"@finsemble/finsemble-api/types/types\";\nimport React, { Component } from \"react\";\nimport { EditTabProps } from \"../../../types/windowTitleBar\";\nimport { Icon } from \"../../icon/Icon\";\nimport { Store } from \"../stores/windowTitleBarStore\";\n\ntype IconDescriptor = services.window.types.IconDescriptor;\n\n/**\n * TAB TITLES: HOW DO THEY WORK?\n *\n * Each component, when stacked, will have several tab titles. For each component, there is a window. For each window, there are 2 tab titles per component.\n *\n * Whichever component is \"active\" will render all tabs - exactly one \"active\" tab and n-1 \"inactive\" tabs (where n is the number of components in the stack). When\n * the active component is changed (via a click, for example), then the visible window becomes the window associated with the active component.\n *\n * Tab titles may change at any time, and for a number of reasons. For example, the component may execute \"document.title='...some title'\". Or perhaps the tab title has\n * been edited by the user. In order to account for all title changes, the following flow is used:\n * *something* updates document.title\n * The WindowClient for the component will notice the title change and send a router message (via FinsembleWindow.setTitle) with a topic representitive of the windowName\n * BaseWindow listens to router changes on the same topic and updates a DistributedStore dedicated to tab names\n * The tab components all subscribe to the DistributedStore dedicated to tab names and will update the title accordingly\n *\n * This is a \"one-way\" operation; that is to say that some code will ultimately alter the DistributedStore and the tab title components will read the changes. While this generally\n * happens with a write to document.title, it can also happen when a user edits the tab title manually. In this case, the component state is altered with a field \"persistedTitle\"\n * whose value is the edited title. At render time, the tab title component will use any value in \"persistedTitle\" as the title, irregardless of any other value.\n *\n * NOTE: A tab may be edited only when it is the active component; ergo the call to \"setComponentState\" is safe.\n */\n\n/**\n * WINDOW TITLES: HOW DO THEY WORK?\n *\n * Each application window has a title which is displayed in the operating system taskbar and task switcher. This title comes from the\n * value of \"document.title\" in the window title bar component. It is important to understand that when tabs are stacked, the actual window\n * which holds the window title is the title of the window of the active component. It is therefore important to keep the window title and the\n * tab titles up to date and synchronized.\n */\n\ntype TitleProps = {\n\twindowIdentifier: WindowIdentifier;\n\tonUpdate?: Function;\n\ttitleWidth?: number;\n\tonClick?: () => void;\n};\n\ntype TitleState = {\n\ttitle: string | undefined;\n\ticon: any;\n\twindowName?: string;\n};\n\n// The store name for the distributed store which tracks tab titles\nconst WINDOW_TAB_TITLE_STORE = \"window-tab-title\";\n// The field name to watch for tab title edits\nconst FIELD_NAME_PERSISTED_TITLE = \"persistedTitle\";\n\n/**\n * Gets the store which tracks the tab title for a windowName. This is a distributed store shared by all components.\n *\n * @returns a Promise which resolves the StoreModel associated with window and tab names\n */\nconst getWindowTabNameStore = async () => {\n\t// This function should memoize the store, but probably not worth doing so since:\n\t// - the performance hit is trivial\n\t// - the code will be refactored\n\tlet { data: store } = await FSBL.Clients.DistributedStoreClient.createGlobalStore({ store: WINDOW_TAB_TITLE_STORE });\n\treturn store;\n};\n\n/**\n * The wrapper component for tab renaming\n * @param {*} props\n */\nfunction EditTab(props: EditTabProps) {\n\tconst [editingTitle, setEditingTitle] = React.useState(false);\n\tconst [clickTimeout, setClickTimeout] = React.useState<NodeJS.Timeout | undefined>(undefined);\n\tconst inputEl = React.useRef<HTMLInputElement>(null);\n\n\tconst updateTabTitle = async (e: React.KeyboardEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement>) => {\n\t\t// When the tab title has changed via a user edit, simply update the DistributedStore\n\n\t\t// Get the title\n\t\tconst title = (e.target as HTMLInputElement).value;\n\n\t\t// Get the tab name store\n\t\tlet store = await getWindowTabNameStore();\n\t\t// If the store is unavailable, then the tab name cannot be persisted\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error persisting tab title via EditTab: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Persist the tab title\n\t\tstore.setValue({ field: props.windowIdentifier.windowName, value: title });\n\n\t\t// Get the window which coresponds to the tab being edited\n\t\tconst { wrap: win } = await FSBL.FinsembleWindow.getInstance(props.windowIdentifier);\n\n\t\t// Set the component state \"persistedTitle\" (which is the edited title)\n\t\tFSBL.Clients.Logger.debug(`Setting component state \"${FIELD_NAME_PERSISTED_TITLE}\" with value \"${title}\"`);\n\t\tawait win.setComponentState({ field: FIELD_NAME_PERSISTED_TITLE, value: title });\n\n\t\t// Stop editing in all cases\n\t\tsetEditingTitle(false);\n\t};\n\n\tconst beginEditing = async () => {\n\t\tawait setEditingTitle(true);\n\t\tinputEl?.current?.focus();\n\t\tif (inputEl?.current) {\n\t\t\tinputEl.current.value = props.title ?? \"\";\n\t\t}\n\t};\n\n\tconst clickHandler = () => {\n\t\tconst allowWindowTitleRenaming = Store.getValue(\"allowWindowTitleRenaming\");\n\n\t\tif (clickTimeout) {\n\t\t\t// double click\n\t\t\tif (allowWindowTitleRenaming) {\n\t\t\t\tbeginEditing();\n\t\t\t}\n\t\t} else if (!editingTitle) {\n\t\t\t// single click\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tclearTimeout(clickTimeout);\n\t\t\t\tsetClickTimeout(undefined);\n\t\t\t}, 500);\n\t\t\tsetClickTimeout(timeout);\n\t\t\tif (props.setActiveTab) props.setActiveTab();\n\t\t}\n\t};\n\n\tconst blurHandler = (e: React.FocusEvent<HTMLInputElement>) => {\n\t\tupdateTabTitle(e);\n\t};\n\n\tconst keyDownHandler = (e: React.KeyboardEvent<HTMLInputElement>) => {\n\t\te.key === \"Enter\" && updateTabTitle(e);\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"fsbl-tab-editor\"\n\t\t\t// We can't use Click and Dblclick events together cause for one dblclick fires two click events which close title editor.\n\t\t\t// Workaround with setTimeout should resolve this behavior.\n\t\t\tonClick={clickHandler}\n\t\t>\n\t\t\t{editingTitle ? (\n\t\t\t\t<div className=\"fsbl-tab fsbl-active-tab\" style={{ width: props.tabWidth || \"auto\" }}>\n\t\t\t\t\t{/* workaround to disable tab dragging in the edit mode */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tdraggable={true}\n\t\t\t\t\t\tonDragStart={(e) => {\n\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tref={inputEl}\n\t\t\t\t\t\t\tonBlur={blurHandler}\n\t\t\t\t\t\t\tonKeyDown={keyDownHandler}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tclassName=\"tab__input\"\n\t\t\t\t\t\t\tmaxLength={32}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\tprops.children\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\n/*\n * Description how stacked window tabs work.\n *\n * The simplest case - when you have only 2 tabs. In that case you will actually have 2 windows and 4 tabs.\n * Lets call them as: window 1 - w1, window 2 - w2, tab 1 from window 1 - w1_t1, tab 2 from window 1 - w1_t2, for tabs from window 2 - w2_t1 and w2_t2.\n * When you switch tabs you activate w1 or w2 with active tab w1_t1 or w2_t2 correspondingly.\n * Tabs w1_t2 and w2_t1 are inactive. They needed only for rendering. I call them as remote tabs, cause their titles must be synchronized with active tabs titles.\n * Thus when you rename active tab (w1_t1), the corresponding remote tab (w2_t1) should be updated automatically.\n */\n\nexport class Title extends Component<TitleProps, TitleState> {\n\t// The listener for tab title change events via the DistributedStoreClient, kept as a reference so\n\t// that the listener can be deregistered when the component is unmounted\n\ttabTitleChangedStoreListener: ListenerFunction = (err: StandardError, response: { field: string; value: string }) => {\n\t\tif (!!err) {\n\t\t\t// This is not critical; in the worst case this tab title will be stale\n\t\t\tFSBL.Clients.Logger.warn(\n\t\t\t\t`Listener error for store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`,\n\t\t\t\terr\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Log a message\n\t\tFSBL.Clients.Logger.debug(\n\t\t\t`Store \"${WINDOW_TAB_TITLE_STORE}\" notified of new title \"${response.value}\" for window \"${response.field}\"`\n\t\t);\n\n\t\t// Invoke updateTitle\n\t\tthis.updateTitle();\n\t};\n\n\t// Flag to determine if this instance is currently mounted; this is necessary because:\n\t// 1.) Title components are mounted and unmounted as an artifact of how the tab or tab list is rendered\n\t// 2.) Keeping tab titles synchronized is an asynchronous process\n\t// 3.) During the asynchronous process of tab title synchronization, a call to setState is made and\n\t// that raises a React warning since the component state cannot be changed while the component\n\t// is unmounted\n\t_mounted = false;\n\n\tconstructor(props: TitleProps) {\n\t\tsuper(props);\n\t\tthis.state = {\n\t\t\t// Use document.title first to prevent a title flickering when dragging a tab of another window.\n\t\t\t// The reason for flickering is the component re-rendering multiple times. The initial place\n\t\t\t// where re-rendering start is the `disallowDragOnCenterRegion()` at the WindowTitleBarShell.\n\t\t\t// At that function, we change the state of the parent component which triggers re-rendering for the children tree.\n\t\t\ttitle: document.title || props.windowIdentifier?.windowName,\n\t\t\ticon: null,\n\t\t\t// The \"windowName\" is the name of the window which corresponds to the this instance of the\n\t\t\t// Title component, though the actual current window may belong to some other\n\t\t\t// component(ie this tab represents an inactive window)\n\t\t\twindowName: props.windowIdentifier?.windowName,\n\t\t};\n\n\t\t// Bind the \"updateTitle\" function (in order to use React component functions)\n\t\tthis.updateTitle = this.updateTitle.bind(this);\n\n\t\t// Initial title set\n\t\tthis.updateTitle();\n\t}\n\n\t/**\n\t * Sets the title of the window.\n\t *\n\t */\n\tasync #setWindowTitle() {\n\t\t// Get the store (which holds the values for the tab titles)\n\t\tconst store = await getWindowTabNameStore();\n\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error setting the window title: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\t// This code probably is not needed any longer\n\t\t//\n\t\t// // The FinsembleWindow which represents the current window\n\t\t// const { data: windowTitle } = await store.getGlobalValue(finsembleWindow.thisWindowName);\n\t\t//\n\t\t// // Set this first so it is less wrong than the default\n\t\t// document.title = windowTitle;\n\n\t\t// If this tab component instance represents the window (that is, this is the active tab), then set the title\n\t\tif (finsembleWindow.thisWindowName === this.props.windowIdentifier.windowName) {\n\t\t\tdocument.title = await this.#calculateTabTitle();\n\t\t}\n\t}\n\n\t/**\n\t * Sets the title of the tab.\n\t */\n\tasync #setTabTitle() {\n\t\t// The window represented by this tab title instance\n\t\tconst { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);\n\n\t\t// \"tabWindowOptions\" refers to the options from the window which hosts the component represented by this tab\n\t\tconst { data: tabWindowOptions } = await tabWindow.getOptions();\n\n\t\t// Derive the title: \"config title\" then \"document.title\" then \"appd title\"\n\t\tlet title = await this.#calculateTabTitle();\n\n\t\t// Get the titleBar icon from the WindowDescriptor for the TAB window (not the CURRENT window)\n\t\tconst icon: IconDescriptor = (tabWindowOptions as WindowDescriptor)?.icons?.titleBarIcon ?? {\n\t\t\timageType: \"initials\",\n\t\t\tname: title,\n\t\t};\n\n\t\t// Get the component state for THIS component (the tab title)\n\t\t// The field \"persistedTitle\" is set when a tab has been edited via EditTab\n\t\ttabWindow.getComponentState({ field: FIELD_NAME_PERSISTED_TITLE }, (error: any, persistedTitle: any) => {\n\t\t\t// When the component is being mounted/unmounted quickly, this code may be run during a time when\n\t\t\t// the component is not mounted. This check prevents React warnings in the dev console.\n\t\t\tif (!this._mounted) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a \"persistedTitle\" then the title has been edited by a user\n\t\t\tif (persistedTitle) {\n\t\t\t\t// Set the title to the edited title\n\t\t\t\ttitle = persistedTitle;\n\t\t\t}\n\t\t\tFSBL.Clients.Logger.debug(`Setting tab title ${title} for window ${this.props.windowIdentifier.windowName}`);\n\n\t\t\t// Finally, set the state\n\t\t\tthis.setState({\n\t\t\t\ttitle,\n\t\t\t\ticon: {\n\t\t\t\t\t...icon,\n\t\t\t\t\t// Application causes the background to default to a circle rather than a square\n\t\t\t\t\tcategory: \"Application\",\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Gets a reference to the \"Window Manager\" component for the tab which is rendering. If the this tab IS the active tab, then the WindowManager will be the same as the WindowManager\n\t * attached to the WindowClient. However, all other tab components displayed in this window will need to derive the WindowManager from the config, based on the\n\t * tab's windowIdentifier.\n\t *\n\t * This is because the tab's windowIdentifier only has the name (ex: SomeApp-37ba6708-3a75-462e-b900-1812e338cbf1). The name is derived by removing the last 5 substrings\n\t * separated by \"-\". This will fail in the face of a UUID format change.\n\t *\n\t * @returns the \"Window Manager\" component, or \"undefined\" if the \"Window Manager\" is not found\n\t */\n\tasync #getWindowManagerForTab() {\n\t\t// On second thought, ALL tabs will derive the WindowManager the same way; at least if it is wrong, it is wrong consistently\n\t\t//\n\t\t// if (finsembleWindow.thisWindowName === this.props?.windowIdentifier?.windowName) {\n\t\t// \treturn FSBL.Clients.WindowClient.options?.customData?.foreign?.components?.[\"Window Manager\"] || FSBL.Clients.WindowClient.options?.customData?.appDConfig?.manifest?.foreign?.components?.[\"Window Manager\"];\n\t\t// } else {\n\n\t\t// Check that \"windowName\" exists\n\t\tif (!!this.props?.windowIdentifier?.windowName) {\n\t\t\t// Get the window name\n\t\t\tconst tabsWindowName = this.props.windowIdentifier.windowName;\n\t\t\t// Get the active descriptors\n\t\t\tconst { data: activeDescriptors } = await FSBL.Clients.LauncherClient.getActiveDescriptors();\n\t\t\t// Return the \"Window Manager\" for the window whose name matches THIS tab's name\n\t\t\treturn activeDescriptors?.[tabsWindowName]?.customData?.appDConfig?.manifest?.foreign?.components?.[\n\t\t\t\t\"Window Manager\"\n\t\t\t];\n\t\t}\n\n\t\treturn undefined;\n\t\t// }\n\t}\n\n\t/**\n\t * Calculates a tab title. Uses the following algorithm until a non-null value is found.\n\t * <ol>\n\t * <li>user edited tab title</li>\n\t * <li>the component config</li>\n\t * <li>document.title</li>\n\t * <li>appd config</li>\n\t * </ol>\n\t *\n\t * @returns the calculated tab title\n\t */\n\tasync #calculateTabTitle() {\n\t\treturn (\n\t\t\t(await this.#getUserEditedTitle()) ||\n\t\t\t(await this.#getConfigTitle()) ||\n\t\t\t(await this.#getDocumentTitle()) ||\n\t\t\tthis.#getAppDTitle()\n\t\t);\n\t}\n\n\t/**\n\t * Returns the name of the title supplied by a user; undefined if the user has not supplied a title.\n\t *\n\t * @returns The name of the title supplied by a user; undefined if the user has not supplied a title\n\t */\n\tasync #getUserEditedTitle() {\n\t\tconst { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\ttabWindow.getComponentState({ field: FIELD_NAME_PERSISTED_TITLE }, (error: any, persistedTitle: any) => {\n\t\t\t\tif (!this._mounted) {\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!!error) {\n\t\t\t\t\treject(error);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(persistedTitle);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Gets a title set in the component configuration.\n\t *\n\t * @returns any title set in the component configuration\n\t */\n\tasync #getConfigTitle() {\n\t\tconst windowManager = await this.#getWindowManagerForTab();\n\t\treturn windowManager?.FSBLHeader?.title || windowManager?.title;\n\t}\n\n\t/**\n\t * Returns document.title.\n\t *\n\t * @returns the document.title (from the \"tab name\" store)\n\t */\n\tasync #getDocumentTitle() {\n\t\tconst store = await getWindowTabNameStore();\n\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error setting the tab title: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.props?.windowIdentifier?.windowName\n\t\t\t? (await store.getGlobalValue(this.props.windowIdentifier.windowName)).data\n\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Gets the AppD configuration\n\t *\n\t * @returns The AppD name\n\t */\n\t#getAppDTitle() {\n\t\treturn (\n\t\t\tFSBL.Clients.WindowClient.options?.customData?.appDConfig?.manifest?.component?.displayName ||\n\t\t\tFSBL.Clients.WindowClient.options?.customData?.appDConfig?.name\n\t\t);\n\t}\n\n\t/**\n\t * Updates the title for both the tab and the window.\n\t *\n\t * @returns a Promise which resolves nothing\n\t */\n\tasync updateTitle() {\n\t\t// There is a subtle difference bewtween windowTitle and tabTitle. Since this code executes\n\t\t// when *any* tab has a name change, this code can execute when the active window represents\n\t\t// a tab other than the currently rendering tab (ie an inactive tab).\n\n\t\tthis.#setTabTitle();\n\t\tthis.#setWindowTitle();\n\t}\n\n\t/**\n\t * Adds the listener(s) required to set window and tab titles.\n\t */\n\tasync #addListeners() {\n\t\t// Subscribe to the DistributedStoreClient (these messages originate from BaseWindow, when the\n\t\t// DistributedStore has been updated).\n\t\t//\n\t\t// Each window will have n listeners, where n is the number of tabs held in the window.\n\n\t\t// Get the store and add a listener\n\t\tconst store = await getWindowTabNameStore();\n\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error adding a tab title listener: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Add a listener\n\t\tstore.addListener({ field: this.props.windowIdentifier.windowName }, this.tabTitleChangedStoreListener, () => {\n\t\t\tFSBL.Clients.Logger.debug(\n\t\t\t\t`Added listener to store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Removes listener(s) required to set window and tab titles.\n\t */\n\tasync #removeListeners() {\n\t\t// Unsubscribe from the window/tab store\n\t\tconst store = await getWindowTabNameStore();\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error removing a tab title listener: the store was not found\");\n\t\t\treturn;\n\t\t}\n\t\tstore.removeListener(\n\t\t\t{ field: this.props.windowIdentifier.windowName },\n\t\t\tthis.tabTitleChangedStoreListener,\n\t\t\t(err: StandardError, response: boolean | undefined) => {\n\t\t\t\tif (!!err) {\n\t\t\t\t\t// This is not critical; the listener could not be removed from the store - this may be a memory leak\n\t\t\t\t\tFSBL.Clients.Logger.warn(\n\t\t\t\t\t\t`Could not remove listener from store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`,\n\t\t\t\t\t\terr\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tFSBL.Clients.Logger.debug(\n\t\t\t\t\t`Removed listener to store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * React component lifecycle event, triggered once the component has been added to the DOM.\n\t */\n\tcomponentDidMount() {\n\t\t// Set the mounted flag to true (this component is currently mounted)\n\t\tthis._mounted = true;\n\n\t\t// Add listeners\n\t\tthis.#addListeners();\n\t}\n\n\t// Triggers a re-rendering of the drag handle in the title bar.\n\tcomponentDidUpdate() {\n\t\tif (typeof this.props.onUpdate === \"function\") {\n\t\t\tthis.props.onUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * React component lifecycle event, triggered before the component is removed from the DOM.\n\t */\n\tcomponentWillUnmount() {\n\t\t// Set the mounted flag to false (this component is not currently mounted)\n\t\tthis._mounted = false;\n\n\t\t// Remove listeners\n\t\tthis.#removeListeners();\n\t}\n\n\trender() {\n\t\tconst { titleWidth } = this.props;\n\t\tconst style = titleWidth ? { width: titleWidth } : {};\n\t\treturn (\n\t\t\t<EditTab\n\t\t\t\ttabWidth={titleWidth}\n\t\t\t\tsetActiveTab={this?.props?.onClick}\n\t\t\t\ttitle={this.state.title}\n\t\t\t\t// The windowIdentifier indicates which app/component this tab instance should represent\n\t\t\t\twindowIdentifier={this.props.windowIdentifier}\n\t\t\t>\n\t\t\t\t<div className=\"fsbl-tab-title\" style={style}>\n\t\t\t\t\t{this.state.icon && <Icon {...this.state.icon} />}\n\t\t\t\t\t<div className=\"title-text\">{this.state.title}</div>\n\t\t\t\t</div>\n\t\t\t</EditTab>\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"windowTitle.js","sourceRoot":"","sources":["../../../../src/components/windowTitleBar/components/windowTitle.tsx"],"names":[],"mappings":";;;;;;AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAiDtD,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAGpD,IAAI,kBAAuB,CAAC;AAO5B,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE;IACxC,IAAI,CAAC,kBAAkB,EAAE;QACxB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,iBAAiB,CAAC;YACjF,KAAK,EAAE,sBAAsB;SAC7B,CAAC,CAAC;QACH,kBAAkB,GAAG,KAAK,CAAC;KAC3B;IAGD,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAMF,SAAS,OAAO,CAAC,KAAmB;IACnC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA6B,SA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,GAAG,EAAE;QAC5G,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACxB,4BAA4B,sBAAsB,gBAAgB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAC3G,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,2BAKD,KAAK;IAEJ,MAAM,KAAK,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAE5C,IAAI,CAAC,KAAK,EAAE;QAEX,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QACzF,OAAO;KACP;IACD,KAAK,CAAC,cAAc,CACnB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,EACjD,IAAI,CAAC,4BAA4B,EACjC,CAAC,GAAkB,EAAE,QAA6B,EAAE,EAAE;QACrD,IAAI,CAAC,CAAC,GAAG,EAAE;YAEV,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACvB,yCAAyC,sBAAsB,gBAAgB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,GAAG,EACxH,GAAG,CACH,CAAC;YACF,OAAO;SACP;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACxB,8BAA8B,sBAAsB,gBAAgB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,GAAG,CAC7G,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC","sourcesContent":["import { WindowIdentifier, WindowDescriptor, services } from \"@finsemble/finsemble-api\";\nimport { ListenerFunction } from \"@finsemble/finsemble-api/types/clients/StoreModel\";\nimport { StandardError } from \"@finsemble/finsemble-api/types/types\";\nimport React, { Component } from \"react\";\nimport { EditTabProps } from \"../../../types/windowTitleBar\";\nimport { Icon } from \"../../icon/Icon\";\nimport { Store } from \"../stores/windowTitleBarStore\";\n\ntype IconDescriptor = services.window.types.IconDescriptor;\n\n/**\n * TAB TITLES: HOW DO THEY WORK?\n *\n * Each component, when stacked, will have several tab titles. For each component, there is a window. For each window, there are 2 tab titles per component.\n *\n * Whichever component is \"active\" will render all tabs - exactly one \"active\" tab and n-1 \"inactive\" tabs (where n is the number of components in the stack). When\n * the active component is changed (via a click, for example), then the visible window becomes the window associated with the active component.\n *\n * Tab titles may change at any time, and for a number of reasons. For example, the component may execute \"document.title='...some title'\". Or perhaps the tab title has\n * been edited by the user. In order to account for all title changes, the following flow is used:\n * *something* updates document.title\n * The WindowClient for the component will notice the title change and send a router message (via FinsembleWindow.setTitle) with a topic representitive of the windowName\n * BaseWindow listens to router changes on the same topic and updates a DistributedStore dedicated to tab names\n * The tab components all subscribe to the DistributedStore dedicated to tab names and will update the title accordingly\n *\n * This is a \"one-way\" operation; that is to say that some code will ultimately alter the DistributedStore and the tab title components will read the changes. While this generally\n * happens with a write to document.title, it can also happen when a user edits the tab title manually. In this case, the component state is altered with a field \"persistedTitle\"\n * whose value is the edited title. At render time, the tab title component will use any value in \"persistedTitle\" as the title, irregardless of any other value.\n *\n * NOTE: A tab may be edited only when it is the active component; ergo the call to \"setComponentState\" is safe.\n */\n\n/**\n * WINDOW TITLES: HOW DO THEY WORK?\n *\n * Each application window has a title which is displayed in the operating system taskbar and task switcher. This title comes from the\n * value of \"document.title\" in the window title bar component. It is important to understand that when tabs are stacked, the actual window\n * which holds the window title is the title of the window of the active component. It is therefore important to keep the window title and the\n * tab titles up to date and synchronized.\n */\n\ntype TitleProps = {\n\twindowIdentifier: WindowIdentifier;\n\tonUpdate?: Function;\n\ttitleWidth?: number;\n\tonClick?: () => void;\n};\n\ntype TitleState = {\n\ttitle: string | undefined;\n\ticon: any;\n\twindowName?: string;\n};\n\n// The store name for the distributed store which tracks tab titles\nconst WINDOW_TAB_TITLE_STORE = \"window-tab-title\";\n// The field name to watch for tab title edits\nconst FIELD_NAME_PERSISTED_TITLE = \"persistedTitle\";\n\n// The windowTabNameStore reference\nlet windowTabNameStore: any;\n\n/**\n * Gets the store which tracks the tab title for a windowName. This is a distributed store shared by all components.\n *\n * @returns a Promise which resolves the StoreModel associated with window and tab names\n */\nconst getWindowTabNameStore = async () => {\n\tif (!windowTabNameStore) {\n\t\tlet { data: store } = await FSBL.Clients.DistributedStoreClient.createGlobalStore({\n\t\t\tstore: WINDOW_TAB_TITLE_STORE,\n\t\t});\n\t\twindowTabNameStore = store;\n\t}\n\n\t// Return the store\n\treturn windowTabNameStore;\n};\n\n/**\n * The wrapper component for tab renaming\n * @param {*} props\n */\nfunction EditTab(props: EditTabProps) {\n\tconst [editingTitle, setEditingTitle] = React.useState(false);\n\tconst [clickTimeout, setClickTimeout] = React.useState<NodeJS.Timeout | undefined>(undefined);\n\tconst inputEl = React.useRef<HTMLInputElement>(null);\n\n\tconst updateTabTitle = async (e: React.KeyboardEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement>) => {\n\t\t// When the tab title has changed via a user edit, simply update the DistributedStore\n\n\t\t// Get the title\n\t\tconst title = (e.target as HTMLInputElement).value;\n\n\t\t// Get the tab name store\n\t\tlet store = await getWindowTabNameStore();\n\t\t// If the store is unavailable, then the tab name cannot be persisted\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error persisting tab title via EditTab: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Persist the tab title\n\t\tstore.setValue({ field: props.windowIdentifier.windowName, value: title });\n\n\t\t// Get the window which coresponds to the tab being edited\n\t\tconst { wrap: win } = await FSBL.FinsembleWindow.getInstance(props.windowIdentifier);\n\n\t\t// Set the component state \"persistedTitle\" (which is the edited title)\n\t\tFSBL.Clients.Logger.debug(`Setting component state \"${FIELD_NAME_PERSISTED_TITLE}\" with value \"${title}\"`);\n\t\tawait win.setComponentState({ field: FIELD_NAME_PERSISTED_TITLE, value: title });\n\n\t\t// Stop editing in all cases\n\t\tsetEditingTitle(false);\n\t};\n\n\tconst beginEditing = async () => {\n\t\tawait setEditingTitle(true);\n\t\tinputEl?.current?.focus();\n\t\tif (inputEl?.current) {\n\t\t\tinputEl.current.value = props.title ?? \"\";\n\t\t}\n\t};\n\n\tconst clickHandler = () => {\n\t\tconst allowWindowTitleRenaming = Store.getValue(\"allowWindowTitleRenaming\");\n\n\t\tif (clickTimeout) {\n\t\t\t// double click\n\t\t\tif (allowWindowTitleRenaming) {\n\t\t\t\tbeginEditing();\n\t\t\t}\n\t\t} else if (!editingTitle) {\n\t\t\t// single click\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tclearTimeout(clickTimeout);\n\t\t\t\tsetClickTimeout(undefined);\n\t\t\t}, 500);\n\t\t\tsetClickTimeout(timeout);\n\t\t\tif (props.setActiveTab) props.setActiveTab();\n\t\t}\n\t};\n\n\tconst blurHandler = (e: React.FocusEvent<HTMLInputElement>) => {\n\t\tupdateTabTitle(e);\n\t};\n\n\tconst keyDownHandler = (e: React.KeyboardEvent<HTMLInputElement>) => {\n\t\te.key === \"Enter\" && updateTabTitle(e);\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"fsbl-tab-editor\"\n\t\t\t// We can't use Click and Dblclick events together cause for one dblclick fires two click events which close title editor.\n\t\t\t// Workaround with setTimeout should resolve this behavior.\n\t\t\tonClick={clickHandler}\n\t\t>\n\t\t\t{editingTitle ? (\n\t\t\t\t<div className=\"fsbl-tab fsbl-active-tab\" style={{ width: props.tabWidth || \"auto\" }}>\n\t\t\t\t\t{/* workaround to disable tab dragging in the edit mode */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tdraggable={true}\n\t\t\t\t\t\tonDragStart={(e) => {\n\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tid=\"title_editor_input\"\n\t\t\t\t\t\t\tref={inputEl}\n\t\t\t\t\t\t\tonBlur={blurHandler}\n\t\t\t\t\t\t\tonKeyDown={keyDownHandler}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tclassName=\"tab__input\"\n\t\t\t\t\t\t\tmaxLength={32}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\tprops.children\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\n/*\n * Description how stacked window tabs work.\n *\n * The simplest case - when you have only 2 tabs. In that case you will actually have 2 windows and 4 tabs.\n * Lets call them as: window 1 - w1, window 2 - w2, tab 1 from window 1 - w1_t1, tab 2 from window 1 - w1_t2, for tabs from window 2 - w2_t1 and w2_t2.\n * When you switch tabs you activate w1 or w2 with active tab w1_t1 or w2_t2 correspondingly.\n * Tabs w1_t2 and w2_t1 are inactive. They needed only for rendering. I call them as remote tabs, cause their titles must be synchronized with active tabs titles.\n * Thus when you rename active tab (w1_t1), the corresponding remote tab (w2_t1) should be updated automatically.\n */\n\nexport class Title extends Component<TitleProps, TitleState> {\n\t// The listener for tab title change events via the DistributedStoreClient, kept as a reference so\n\t// that the listener can be deregistered when the component is unmounted\n\ttabTitleChangedStoreListener: ListenerFunction = (err: StandardError, response: { field: string; value: string }) => {\n\t\tif (!!err) {\n\t\t\t// This is not critical; in the worst case this tab title will be stale\n\t\t\tFSBL.Clients.Logger.warn(\n\t\t\t\t`Listener error for store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`,\n\t\t\t\terr\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Log a message\n\t\tFSBL.Clients.Logger.debug(\n\t\t\t`Store \"${WINDOW_TAB_TITLE_STORE}\" notified of new title \"${response.value}\" for window \"${response.field}\"`\n\t\t);\n\n\t\t// Invoke updateTitle\n\t\tif (!!this._mounted) {\n\t\t\tthis.updateTitle();\n\t\t}\n\t};\n\n\t// Flag to determine if this instance is currently mounted; this is necessary because:\n\t// 1.) Title components are mounted and unmounted as an artifact of how the tab or tab list is rendered\n\t// 2.) Keeping tab titles synchronized is an asynchronous process\n\t// 3.) During the asynchronous process of tab title synchronization, a call to setState is made and\n\t// that raises a React warning since the component state cannot be changed while the component\n\t// is unmounted\n\t_mounted = false;\n\n\tconstructor(props: TitleProps) {\n\t\tsuper(props);\n\n\t\t// Declare the initial title as a blank string\n\t\tlet initialTitle = \" \";\n\n\t\t// If the currently rendering tab represents the current window, then use the document title (or window name)\n\t\tif (\n\t\t\tundefined !== finsembleWindow?.thisWindowName &&\n\t\t\tfinsembleWindow?.thisWindowName === props?.windowIdentifier?.windowName\n\t\t) {\n\t\t\tinitialTitle = document.title || props.windowIdentifier?.windowName;\n\t\t}\n\n\t\tthis.state = {\n\t\t\t// Use document.title first to prevent a title flickering when dragging a tab of another window.\n\t\t\t// The reason for flickering is the component re-rendering multiple times. The initial place\n\t\t\t// where re-rendering start is the `disallowDragOnCenterRegion()` at the WindowTitleBarShell.\n\t\t\t// At that function, we change the state of the parent component which triggers re-rendering for the children tree.\n\t\t\ttitle: initialTitle,\n\t\t\ticon: null,\n\t\t\t// The \"windowName\" is the name of the window which corresponds to the this instance of the\n\t\t\t// Title component, though the actual current window may belong to some other\n\t\t\t// component(ie this tab represents an inactive window)\n\t\t\twindowName: props.windowIdentifier?.windowName,\n\t\t};\n\n\t\t// Bind the \"updateTitle\" function (in order to use React component functions)\n\t\tthis.updateTitle = this.updateTitle.bind(this);\n\n\t\t// Initial title set\n\t\tthis.updateTitle();\n\t}\n\n\t/**\n\t * Gets a reference to the \"Window Manager\" component for the tab which is rendering. If the this tab IS the active tab, then the WindowManager will be the same as the WindowManager\n\t * attached to the WindowClient. However, all other tab components displayed in this window will need to derive the WindowManager from the config, based on the\n\t * tab's windowIdentifier.\n\t *\n\t * This is because the tab's windowIdentifier only has the name (ex: SomeApp-37ba6708-3a75-462e-b900-1812e338cbf1). The name is derived by removing the last 5 substrings\n\t * separated by \"-\". This will fail in the face of a UUID format change.\n\t *\n\t * @returns the \"Window Manager\" component, or \"undefined\" if the \"Window Manager\" is not found\n\t */\n\tasync #getWindowManagerForTab() {\n\t\t// On second thought, ALL tabs will derive the WindowManager the same way; at least if it is wrong, it is wrong consistently\n\t\t//\n\t\t// if (finsembleWindow.thisWindowName === this.props?.windowIdentifier?.windowName) {\n\t\t// \treturn FSBL.Clients.WindowClient.options?.customData?.foreign?.components?.[\"Window Manager\"] || FSBL.Clients.WindowClient.options?.customData?.appDConfig?.manifest?.foreign?.components?.[\"Window Manager\"];\n\t\t// } else {\n\n\t\t// Check that \"windowName\" exists\n\t\tif (!!this.props?.windowIdentifier?.windowName) {\n\t\t\t// Get the window name\n\t\t\tconst tabsWindowName = this.props.windowIdentifier.windowName;\n\t\t\t// Get the active descriptors\n\t\t\tconst { data: activeDescriptors } = await FSBL.Clients.LauncherClient.getActiveDescriptors();\n\t\t\t// Return the \"Window Manager\" for the window whose name matches THIS tab's name\n\t\t\treturn activeDescriptors?.[tabsWindowName]?.customData?.appDConfig?.manifest?.foreign?.components?.[\n\t\t\t\t\"Window Manager\"\n\t\t\t];\n\t\t}\n\n\t\treturn undefined;\n\t\t// }\n\t}\n\n\t/**\n\t * Calculates a tab title. Uses the following algorithm until a non-null value is found.\n\t * <ol>\n\t * <li>user edited tab title</li>\n\t * <li>the component config</li>\n\t * <li>document.title</li>\n\t * <li>appd config</li>\n\t * </ol>\n\t *\n\t * @returns the calculated tab title\n\t */\n\tasync #calculateTabTitle() {\n\t\treturn (\n\t\t\t(await this.#getUserEditedTitle()) ||\n\t\t\t(await this.#getConfigTitle()) ||\n\t\t\t(await this.#getDocumentTitle()) ||\n\t\t\tthis.#getAppDTitle()\n\t\t);\n\t}\n\n\t/**\n\t * Returns the name of the title supplied by a user; undefined if the user has not supplied a title.\n\t *\n\t * @returns The name of the title supplied by a user; undefined if the user has not supplied a title\n\t */\n\tasync #getUserEditedTitle() {\n\t\tconst { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);\n\t\treturn new Promise((resolve) => {\n\t\t\ttabWindow.getComponentState({ field: FIELD_NAME_PERSISTED_TITLE }, (error: any, persistedTitle: any) => {\n\t\t\t\tif (!!error) {\n\t\t\t\t\t// should always return value even if it hasn't been retrieved from the state\n\t\t\t\t\tresolve(undefined);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(persistedTitle);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Gets a title set in the component configuration.\n\t *\n\t * @returns any title set in the component configuration\n\t */\n\tasync #getConfigTitle() {\n\t\tconst windowManager = await this.#getWindowManagerForTab();\n\t\treturn windowManager?.FSBLHeader?.title || windowManager?.title;\n\t}\n\n\t/**\n\t * Returns document.title.\n\t *\n\t * @returns the document.title (from the \"tab name\" store)\n\t */\n\tasync #getDocumentTitle() {\n\t\tconst store = await getWindowTabNameStore();\n\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error setting the tab title: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.props?.windowIdentifier?.windowName\n\t\t\t? (await store.getGlobalValue(this.props.windowIdentifier.windowName)).data\n\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Gets the AppD configuration\n\t *\n\t * @returns The AppD name\n\t */\n\t#getAppDTitle() {\n\t\treturn (\n\t\t\tFSBL.Clients.WindowClient.options?.customData?.appDConfig?.manifest?.component?.displayName ||\n\t\t\tFSBL.Clients.WindowClient.options?.customData?.appDConfig?.name\n\t\t);\n\t}\n\n\t/**\n\t * Updates the title for both the tab and the window.\n\t *\n\t * @returns a Promise which resolves nothing\n\t */\n\tasync updateTitle() {\n\t\t// There is a subtle difference bewtween windowTitle and tabTitle. Since this code executes\n\t\t// when *any* tab has a name change, this code can execute when the active window represents\n\t\t// a tab other than the currently rendering tab (ie an inactive tab).\n\n\t\t// The window represented by this tab title instance\n\t\tconst { wrap: tabWindow } = await FSBL.FinsembleWindow.getInstance(this.props.windowIdentifier);\n\n\t\t// \"tabWindowOptions\" refers to the options from the window which hosts the component represented by this tab\n\t\tconst { data: tabWindowOptions } = await tabWindow.getOptions();\n\n\t\t// Derive the title: \"config title\" then \"document.title\" then \"appd title\"\n\t\tlet title = await this.#calculateTabTitle();\n\n\t\t// Get the titleBar icon from the WindowDescriptor for the TAB window (not the CURRENT window)\n\t\tconst icon: IconDescriptor = (tabWindowOptions as WindowDescriptor)?.icons?.titleBarIcon ?? {\n\t\t\timageType: \"initials\",\n\t\t\tname: title,\n\t\t};\n\n\t\t// Log a message\n\t\tFSBL.Clients.Logger.debug(`Setting tab title ${title} for window ${this.props.windowIdentifier.windowName}`);\n\n\t\t// Finally, set the state if the component is mounted\n\t\tif (!!this._mounted) {\n\t\t\tthis.setState({\n\t\t\t\ttitle,\n\t\t\t\ticon: {\n\t\t\t\t\t...icon,\n\t\t\t\t\t// Application causes the background to default to a circle rather than a square\n\t\t\t\t\tcategory: \"Application\",\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// If this tab component instance represents the window (that is, this is the active tab), then set the title\n\t\tif (finsembleWindow.thisWindowName === this.props.windowIdentifier.windowName) {\n\t\t\tdocument.title = await this.#calculateTabTitle();\n\t\t}\n\t}\n\n\t/**\n\t * Adds the listener(s) required to set window and tab titles.\n\t */\n\tasync #addListeners() {\n\t\t// Subscribe to the DistributedStoreClient (these messages originate from BaseWindow, when the\n\t\t// DistributedStore has been updated).\n\t\t//\n\t\t// Each window will have n listeners, where n is the number of tabs held in the window.\n\n\t\t// Get the store and add a listener\n\t\tconst store = await getWindowTabNameStore();\n\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error adding a tab title listener: the store was not found\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Add a listener\n\t\tstore.addListener({ field: this.props.windowIdentifier.windowName }, this.tabTitleChangedStoreListener, () => {\n\t\t\tFSBL.Clients.Logger.debug(\n\t\t\t\t`Added listener to store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Removes listener(s) required to set window and tab titles.\n\t */\n\tasync #removeListeners() {\n\t\t// Unsubscribe from the window/tab store\n\t\tconst store = await getWindowTabNameStore();\n\t\t// If the store is unavailable, then the tab name cannot be updated\n\t\tif (!store) {\n\t\t\t// This is not critical, but tab titles may be stale\n\t\t\tFSBL.Clients.Logger.warn(\"Error removing a tab title listener: the store was not found\");\n\t\t\treturn;\n\t\t}\n\t\tstore.removeListener(\n\t\t\t{ field: this.props.windowIdentifier.windowName },\n\t\t\tthis.tabTitleChangedStoreListener,\n\t\t\t(err: StandardError, response: boolean | undefined) => {\n\t\t\t\tif (!!err) {\n\t\t\t\t\t// This is not critical; the listener could not be removed from the store - this may be a memory leak\n\t\t\t\t\tFSBL.Clients.Logger.warn(\n\t\t\t\t\t\t`Could not remove listener from store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`,\n\t\t\t\t\t\terr\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tFSBL.Clients.Logger.debug(\n\t\t\t\t\t`Removed listener to store \"${WINDOW_TAB_TITLE_STORE}\" for field \"${this.props.windowIdentifier.windowName}\"`\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * React component lifecycle event, triggered once the component has been added to the DOM.\n\t */\n\tcomponentDidMount() {\n\t\t// Set the mounted flag to true (this component is currently mounted)\n\t\tthis._mounted = true;\n\n\t\t// Add listeners\n\t\tthis.#addListeners();\n\t}\n\n\t// Triggers a re-rendering of the drag handle in the title bar.\n\tcomponentDidUpdate() {\n\t\tif (typeof this.props.onUpdate === \"function\") {\n\t\t\tthis.props.onUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * React component lifecycle event, triggered before the component is removed from the DOM.\n\t */\n\tcomponentWillUnmount() {\n\t\t// Set the mounted flag to false (this component is not currently mounted)\n\t\tthis._mounted = false;\n\n\t\t// Remove listeners\n\t\tthis.#removeListeners();\n\t}\n\n\trender() {\n\t\tconst { titleWidth } = this.props;\n\t\tconst style = titleWidth ? { width: titleWidth } : {};\n\t\treturn (\n\t\t\t<EditTab\n\t\t\t\ttabWidth={titleWidth}\n\t\t\t\tsetActiveTab={this?.props?.onClick}\n\t\t\t\ttitle={this.state.title}\n\t\t\t\t// The windowIdentifier indicates which app/component this tab instance should represent\n\t\t\t\twindowIdentifier={this.props.windowIdentifier}\n\t\t\t>\n\t\t\t\t<div className=\"fsbl-tab-title\" style={style}>\n\t\t\t\t\t{this.state.icon && <Icon {...this.state.icon} />}\n\t\t\t\t\t<div className=\"title-text\">{this.state.title}</div>\n\t\t\t\t</div>\n\t\t\t</EditTab>\n\t\t);\n\t}\n}\n"]}