import { PickerStandaloneLayout, } from '../PickerStandaloneLayout';
import { Picker } from '../Picker';
import React, { useEffect, useState } from 'react';
import { Splash } from '../Splash';
import { CollectionProvider } from '../CollectionContext';
import { PickerListContent } from '../PickerListContent';
import { PickerStandaloneTableListItem } from './PickerStandaloneTableListItem';
import { observer } from 'mobx-react-lite';
import { MultiCollectionSupportProvider } from '../MultiCollectionSupportProvider';
export function _PickerStandalone(props) {
    const { state, renderItem, renderEmptyState, renderError, selectorListProps, dataHook, height, mobileHeight, minContentHeight, primaryActionWidth, defaultPrimaryButtonText, ...rest } = props;
    const { picker, initTask, isMobileView } = state;
    const { collection } = picker;
    state._hasCreateNewAction = props.createNewAction != null;
    useState(() => {
        if (minContentHeight != null) {
            picker.minContentHeight = minContentHeight;
        }
    });
    useEffect(() => {
        return state.init();
    }, []);
    const { splashProps } = isMobileView
        ? {
            splashProps: {
                height: mobileHeight,
            },
        }
        : {
            splashProps: {
                paddingTop: 'SP8',
                paddingBottom: 'SP8',
                height,
            },
        };
    return (React.createElement(CollectionProvider, { value: collection },
        React.createElement(MultiCollectionSupportProvider, { value: state.picker.multi },
            React.createElement("div", { "data-patterns": true },
                React.createElement(Splash, { renderError: renderError, dataHook: dataHook, state: initTask, ...splashProps },
                    React.createElement(PickerStandaloneLayout, { renderError: renderError, state: state, ...rest },
                        React.createElement(Picker, { dataHook: "picker", state: picker, renderEmptyState: renderEmptyState, renderError: renderError },
                            React.createElement(PickerListContent, { ...selectorListProps, state: picker, spacing: 94, renderItem: (keyedItem, index) => (React.createElement(PickerStandaloneTableListItem, { ...renderItem?.(keyedItem.item, index, { isMobileView }), defaultPrimaryButtonText: defaultPrimaryButtonText, state: state, primaryActionWidth: primaryActionWidth, keyedItem: keyedItem })) }))))))));
}
export const PickerStandalone = observer(_PickerStandalone);
//# sourceMappingURL=PickerStandalone.js.map