();
    @observable _dashDoc: Doc | undefined = undefined;
    @observable _expanded = false;
    constructor(props: IDashFieldViewInternal) {
        super(props);
        makeObservable(this);
        this._fieldKey = this._props.fieldKey;
        this._textBoxDoc = this._props.tbox.Document;
        if (this._props.docId) {
            DocServer.GetRefField(this._props.docId).then(action(dashDoc => dashDoc instanceof Doc && (this._dashDoc = dashDoc)));
        } else {
            this._dashDoc = this._props.tbox.Document;
        }
    }
    componentDidMount() {
        this._reactionDisposer = reaction(
            () => (this._dashDoc ? Field.toKeyValueString(this._dashDoc, this._props.fieldKey) : undefined),
            keyvalue => keyvalue && this._props.tbox.tryUpdateDoc(true)
        );
    }
    componentWillUnmount() {
        this._reactionDisposer?.();
    }
    return100 = () => 100;
    // set the display of the field's value (checkbox for booleans, span of text for strings)
    @computed get fieldValueContent() {
        return !this._dashDoc ? null : (
             (this._expanded = !this._props.editable ? !this._expanded : true))} style={{ fontSize: 'smaller', width: this._props.hideKey ? this._props.tbox._props.PanelWidth() - 20 : undefined }}>
                 this._props.tbox._props.PanelWidth() - 20 : returnZero}
                    selectedCell={() => [this._dashDoc!, 0]}
                    fieldKey={this._fieldKey}
                    rowHeight={returnZero}
                    isRowActive={() => this._expanded && this._props.editable}
                    padding={0}
                    getFinfo={emptyFunction}
                    setColumnValues={returnFalse}
                    allowCRs={true}
                    oneLine={!this._expanded}
                    finishEdit={action(() => (this._expanded = false))}
                    transform={Transform.Identity}
                    menuTarget={null}
                />
            
        );
    }
    createPivotForField = (e: React.MouseEvent) => {
        let container = this._props.tbox.DocumentView?.().containerViewPath?.().lastElement();
        if (container) {
            const embedding = Doc.MakeEmbedding(container.Document);
            embedding._type_collection = CollectionViewType.Time;
            const colHdrKey = '_' + container.LayoutFieldKey + '_columnHeaders';
            let list = Cast(embedding[colHdrKey], listSpec(SchemaHeaderField));
            if (!list) {
                embedding[colHdrKey] = list = new List();
            }
            list.map(c => c.heading).indexOf(this._fieldKey) === -1 && list.push(new SchemaHeaderField(this._fieldKey, '#f1efeb'));
            list.map(c => c.heading).indexOf('text') === -1 && list.push(new SchemaHeaderField('text', '#f1efeb'));
            embedding._pivotField = this._fieldKey.startsWith('#') ? 'tags' : this._fieldKey;
            this._props.tbox._props.addDocTab(embedding, OpenWhere.addRight);
        }
    };
    // clicking on the label creates a pivot view collection of all documents
    // in the same collection.  The pivot field is the fieldKey of this label
    onPointerDownLabelSpan = (e: any) => {
        setupMoveUpEvents(this, e, returnFalse, returnFalse, e => {
            DashFieldViewMenu.createFieldView = this.createPivotForField;
            DashFieldViewMenu.Instance.show(e.clientX, e.clientY + 16, this._fieldKey);
        });
    };
    @undoBatch
    selectVal = (event: React.ChangeEvent | undefined) => {
        event && this._dashDoc && (this._dashDoc[this._fieldKey] = event.target.value);
    };
    @computed get values() {
        const vals = FilterPanel.gatherFieldValues(DocListCast(Doc.ActiveDashboard?.data), this._fieldKey, []);
        return vals.strings.map(facet => ({ value: facet, label: facet }));
    }
    render() {
        return (
            
                {this._props.hideKey ? null : (
                    
                        {(this._textBoxDoc === this._dashDoc ? '' : this._dashDoc?.title + ':') + this._fieldKey}
                    
                )}
                {this._props.fieldKey.startsWith('#') ? null : this.fieldValueContent}
                {!this.values.length ? null : (
                    
                )}
            
        );
    }
}
@observer
export class DashFieldViewMenu extends AntimodeMenu {
    static Instance: DashFieldViewMenu;
    static createFieldView: (e: React.MouseEvent) => void = emptyFunction;
    constructor(props: any) {
        super(props);
        DashFieldViewMenu.Instance = this;
    }
    showFields = (e: React.MouseEvent) => {
        DashFieldViewMenu.createFieldView(e);
        DashFieldViewMenu.Instance.fadeOut(true);
    };
    @observable _fieldKey = '';
    @action
    public show = (x: number, y: number, fieldKey: string) => {
        this._fieldKey = fieldKey;
        this.jumpTo(x, y, true);
        const hideMenu = () => {
            this.fadeOut(true);
            document.removeEventListener('pointerdown', hideMenu, true);
        };
        document.addEventListener('pointerdown', hideMenu, true);
    };
    render() {
        return this.getElement(
            {`Show Pivot Viewer for '${this._fieldKey}'`}}>
                
            
        );
    }
}