import { observable, computed } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { documentSchema, collectionSchema } from '../../../fields/documentSchemas';
import { makeInterface } from '../../../fields/Schema';
import { NumCast, StrCast, ScriptCast, Cast } from '../../../fields/Types';
import { DragManager } from '../../util/DragManager';
import { ContentFittingDocumentView } from '../nodes/ContentFittingDocumentView';
import "./CollectionCarousel3DView.scss";
import { CollectionSubView } from './CollectionSubView';
import { Doc } from '../../../fields/Doc';
import { ContextMenu } from '../ContextMenu';
import { ObjectField } from '../../../fields/ObjectField';
import { returnFalse } from '../../../Utils';
import { ScriptField } from '../../../fields/ScriptField';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
type Carousel3DDocument = makeInterface<[typeof documentSchema, typeof collectionSchema]>;
const Carousel3DDocument = makeInterface(documentSchema, collectionSchema);
@observer
export class CollectionCarousel3DView extends CollectionSubView(Carousel3DDocument) {
private _dropDisposer?: DragManager.DragDropDisposer;
componentWillUnmount() { this._dropDisposer?.(); }
protected createDashEventsTarget = (ele: HTMLDivElement) => { //used for stacking and masonry view
this._dropDisposer?.();
if (ele) {
this._dropDisposer = DragManager.MakeDropTarget(ele, this.onInternalDrop.bind(this), this.layoutDoc);
}
}
mainPanelWidth = () => this.props.PanelWidth() * 0.5;
mainPanelHeight = () => this.props.PanelHeight() * 0.9;
sidePanelWidth = () => this.props.PanelWidth() * 0.25;
sidePanelHeight = () => this.props.PanelHeight() * 0.5;
@computed get content() {
const currentIndex = NumCast(this.layoutDoc._itemIndex);
const displayDoc = (childPair: { layout: Doc, data: Doc }, width: () => number, height: () => number) => {
const showCaptionScript = ScriptField.MakeScript(
"child._showCaption = 'caption'",
{ child: Doc.name },
{ child: childPair.layout }
);
// const changeIndexScript = ScriptField.MakeScript(
// "collectionLayoutDoc._itemIndex = collectionLayoutDoc[fieldKey].indexOf(self)",
// { fieldKey: String.name, collectionLayoutDoc: Doc.name },
// { fieldKey: this.props.fieldKey, collectionLayoutDoc: this.layoutDoc }
// );
return