aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
committerbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
commitcda69e48361fce8d71a4dc66edd9dd976a27f52d (patch)
tree82b9a1a5967ae88a9534f89f7eaed3aeb289652f /src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
parentc01828308714874589d1f60c33ca59df4c656c0c (diff)
parenta958577d4c27b276aa37484e3f895e196138b17c (diff)
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx')
-rw-r--r--src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx109
1 files changed, 55 insertions, 54 deletions
diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
index b8509a005..d67e10c0b 100644
--- a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
+++ b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable jsx-a11y/no-static-element-interactions */
-/* eslint-disable jsx-a11y/click-events-have-key-events */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Tooltip } from '@mui/material';
import { Button, IconButton } from 'browndash-components';
@@ -12,13 +10,14 @@ import { BoolCast, NumCast, ScriptCast, StrCast } from '../../../../fields/Types
import { DragManager } from '../../../util/DragManager';
import { SettingsManager } from '../../../util/SettingsManager';
import { Transform } from '../../../util/Transform';
-import { undoBatch, undoable } from '../../../util/UndoManager';
+import { undoable } from '../../../util/UndoManager';
import { DocumentView } from '../../nodes/DocumentView';
-import { CollectionSubView } from '../CollectionSubView';
+import { CollectionSubView, SubCollectionViewProps } from '../CollectionSubView';
import './CollectionMulticolumnView.scss';
import ResizeBar from './MulticolumnResizer';
import WidthLabel from './MulticolumnWidthLabel';
import { dropActionType } from '../../../util/DropActionTypes';
+import { SnappingManager } from '../../../util/SnappingManager';
interface WidthSpecifier {
magnitude: number;
@@ -42,7 +41,7 @@ const resizerWidth = 8;
export class CollectionMulticolumnView extends CollectionSubView() {
@observable _startIndex = 0;
- constructor(props: any) {
+ constructor(props: SubCollectionViewProps) {
super(props);
makeObservable(this);
}
@@ -198,30 +197,28 @@ export class CollectionMulticolumnView extends CollectionSubView() {
* documents before the target.
*/
private lookupIndividualTransform = (layout: Doc) => {
- const { columnUnitLength } = this;
- if (columnUnitLength === undefined) {
+ if (this.columnUnitLength === undefined) {
return Transform.Identity(); // we're still waiting on promises to resolve
}
let offset = 0;
// eslint-disable-next-line no-restricted-syntax
for (const { layout: candidate } of this.childLayoutPairs) {
if (candidate === layout) {
- return this.ScreenToLocalBoxXf().translate(0, -offset / (this._props.NativeDimScaling?.() || 1));
+ return this.ScreenToLocalBoxXf().translate(-offset / (this._props.NativeDimScaling?.() || 1), 0);
}
offset += this.lookupPixels(candidate) + resizerWidth;
}
return Transform.Identity();
};
- @undoBatch
onInternalDrop = (e: Event, de: DragManager.DropEvent) => {
let dropInd = -1;
- if (de.complete.docDragData && this._mainCont) {
+ if (de.complete.docDragData && this._contRef.current) {
let curInd = -1;
de.complete.docDragData?.droppedDocuments.forEach(d => {
curInd = this.childDocs.indexOf(d);
});
- Array.from(this._mainCont.children).forEach((child, index) => {
+ Array.from(this._contRef.current.children).forEach((child, index) => {
const brect = child.getBoundingClientRect();
if (brect.x < de.x && brect.x + brect.width > de.x) {
if (curInd !== -1 && curInd === Math.floor(index / 2)) {
@@ -305,7 +302,7 @@ export class CollectionMulticolumnView extends CollectionSubView() {
whenChildContentsActiveChanged={this._props.whenChildContentsActiveChanged}
addDocTab={this._props.addDocTab}
pinToPres={this._props.pinToPres}
- dontCenter={StrCast(this.layoutDoc.layout_dontCenter) as any} // 'y', 'x', 'xy'
+ dontCenter={StrCast(this.layoutDoc.layout_dontCenter) as 'x' | 'y' | 'xy'}
/>
);
};
@@ -319,11 +316,11 @@ export class CollectionMulticolumnView extends CollectionSubView() {
this.childLayouts.forEach((layout, i) => {
collector.push(
// eslint-disable-next-line react/no-array-index-key
- <Tooltip title={'Tab: ' + StrCast(layout.title)} key={'wrapper' + i}>
+ <Tooltip title={'Doc: ' + StrCast(layout.title)} key={'wrapper' + i}>
<div className="document-wrapper" style={{ flexDirection: 'column', width: this.lookupPixels(layout) }}>
{this.getDisplayDoc(layout)}
{this.layoutDoc._chromeHidden ? null : (
- <Button tooltip="Remove document from header bar" icon={<FontAwesomeIcon icon="times" size="lg" />} onClick={undoable(() => this._props.removeDocument?.(layout), 'close doc')} color={SettingsManager.userColor} />
+ <Button tooltip="Remove document" icon={<FontAwesomeIcon icon="times" size="lg" />} onClick={undoable(() => this._props.removeDocument?.(layout), 'close doc')} color={SettingsManager.userColor} />
)}
<WidthLabel layout={layout} collectionDoc={this.Document} />
</div>
@@ -345,49 +342,53 @@ export class CollectionMulticolumnView extends CollectionSubView() {
return collector;
}
+ _contRef = React.createRef<HTMLDivElement>();
render() {
return (
- <div
- className="collectionMulticolumnView_contents"
- ref={this.createDashEventsTarget}
- style={{
- width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
- height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
- marginLeft: NumCast(this.Document._xMargin),
- marginRight: NumCast(this.Document._xMargin),
- marginTop: NumCast(this.Document._yMargin),
- marginBottom: NumCast(this.Document._yMargin),
- }}>
- {this.contents}
- {!this._startIndex ? null : (
- <Tooltip title="scroll back">
- <div
- style={{ position: 'absolute', bottom: 0, left: 0, background: SettingsManager.userVariantColor }}
- onClick={action(() => {
- this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
- })}>
- <Button
- tooltip="Scroll back"
- icon={<FontAwesomeIcon icon="chevron-left" size="lg" />}
+ <div className="collectionMulticolumnView_drop" ref={this.createDashEventsTarget}>
+ <div
+ className="collectionMulticolumnView_contents"
+ ref={this._contRef}
+ style={{
+ pointerEvents: this._props.isContentActive() && SnappingManager.IsDragging ? 'all' : this._props.pointerEvents?.(),
+ width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
+ height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
+ marginLeft: NumCast(this.Document._xMargin),
+ marginRight: NumCast(this.Document._xMargin),
+ marginTop: NumCast(this.Document._yMargin),
+ marginBottom: NumCast(this.Document._yMargin),
+ }}>
+ {this.contents}
+ {!this._startIndex ? null : (
+ <Tooltip title="scroll back">
+ <div
+ style={{ position: 'absolute', bottom: 0, left: 0, background: SettingsManager.userVariantColor }}
+ onClick={action(() => {
+ this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
+ })}>
+ <Button
+ tooltip="Scroll back"
+ icon={<FontAwesomeIcon icon="chevron-left" size="lg" />}
+ onClick={action(() => {
+ this._startIndex = Math.max(0, this._startIndex - this.maxShown);
+ })}
+ color={SettingsManager.userColor}
+ />
+ </div>
+ </Tooltip>
+ )}
+ {this._startIndex > this.childLayoutPairs.length - 1 || !this.maxShown ? null : (
+ <Tooltip title="scroll forward">
+ <div
+ style={{ position: 'absolute', bottom: 0, right: 0, background: SettingsManager.userVariantColor }}
onClick={action(() => {
- this._startIndex = Math.max(0, this._startIndex - this.maxShown);
- })}
- color={SettingsManager.userColor}
- />
- </div>
- </Tooltip>
- )}
- {this._startIndex > this.childLayoutPairs.length - 1 || !this.maxShown ? null : (
- <Tooltip title="scroll forward">
- <div
- style={{ position: 'absolute', bottom: 0, right: 0, background: SettingsManager.userVariantColor }}
- onClick={action(() => {
- this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
- })}>
- <IconButton icon={<FaChevronRight />} color={SettingsManager.userColor} />
- </div>
- </Tooltip>
- )}
+ this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
+ })}>
+ <IconButton icon={<FaChevronRight />} color={SettingsManager.userColor} />
+ </div>
+ </Tooltip>
+ )}
+ </div>
</div>
);
}