UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

66 lines (65 loc) 2.33 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { factory, Grid, Group, Select, Text, useProps } from '@mantine/core'; import { TableComponentsOrder } from '../Table'; import { useTableContext } from '../TableContext'; const defaultProps = {}; export const TablePredicate = factory((props, ref)=>{ const { store, getStyles } = useTableContext(); const { id, data, label, classNames, className, styles, style, renderOption, comboboxProps, vars, ...others } = useProps('PlasmaTablePredicate', defaultProps, props); const handleChange = (newValue)=>{ store.setPredicates((prev)=>({ ...prev, [id]: newValue })); store.setPagination((prev)=>({ ...prev, pageIndex: 0 })); }; const stylesApiProps = { classNames, styles }; return /*#__PURE__*/ _jsx(Grid.Col, { span: "content", order: TableComponentsOrder.Predicate, ref: ref, ...getStyles('predicate', { className, style, ...stylesApiProps }), ...others, children: /*#__PURE__*/ _jsxs(Group, { gap: "xs", wrap: "nowrap", ...getStyles('predicateWrapper', stylesApiProps), children: [ label ? /*#__PURE__*/ _jsxs(Text, { ...getStyles('predicateLabel', stylesApiProps), children: [ label, ":" ] }) : null, /*#__PURE__*/ _jsx(Select, { comboboxProps: { withinPortal: true, ...comboboxProps }, value: store.state.predicates[id], onChange: handleChange, data: data, "aria-label": label ?? id, searchable: data.length > 7, renderOption: renderOption, scrollAreaProps: { type: 'always' }, ...getStyles('predicateSelect', stylesApiProps) }) ] }) }); }); //# sourceMappingURL=TablePredicate.js.map