UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

133 lines (131 loc) 4.55 kB
/*! * devextreme-react * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-react */ "use client"; import * as React from "react"; import { memo, forwardRef, useImperativeHandle, useRef, useMemo } from "react"; import dxFilterBuilder from "devextreme/ui/filter_builder"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const FilterBuilder = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const subscribableOptions = useMemo(() => (["value"]), []); const independentEvents = useMemo(() => (["onContentReady", "onDisposing", "onEditorPrepared", "onEditorPreparing", "onInitialized", "onValueChanged"]), []); const defaults = useMemo(() => ({ defaultValue: "value", }), []); const expectedChildren = useMemo(() => ({ customOperation: { optionName: "customOperations", isCollectionItem: true }, field: { optionName: "fields", isCollectionItem: true }, filterOperationDescriptions: { optionName: "filterOperationDescriptions", isCollectionItem: false }, groupOperationDescriptions: { optionName: "groupOperationDescriptions", isCollectionItem: false } }), []); return (React.createElement((BaseComponent), { WidgetClass: dxFilterBuilder, ref: baseRef, useRequestAnimationFrameFlag: true, subscribableOptions, independentEvents, defaults, expectedChildren, ...props, })); })); const _componentCustomOperation = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "customOperations", IsCollectionItem: true, TemplateProps: [{ tmplOption: "editorTemplate", render: "editorRender", component: "editorComponent" }], }, }); }; const CustomOperation = Object.assign(_componentCustomOperation, { componentType: "option", }); const _componentField = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "fields", IsCollectionItem: true, ExpectedChildren: { format: { optionName: "format", isCollectionItem: false }, lookup: { optionName: "lookup", isCollectionItem: false } }, TemplateProps: [{ tmplOption: "editorTemplate", render: "editorRender", component: "editorComponent" }], }, }); }; const Field = Object.assign(_componentField, { componentType: "option", }); const _componentFilterOperationDescriptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "filterOperationDescriptions", }, }); }; const FilterOperationDescriptions = Object.assign(_componentFilterOperationDescriptions, { componentType: "option", }); const _componentFormat = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "format", }, }); }; const Format = Object.assign(_componentFormat, { componentType: "option", }); const _componentGroupOperationDescriptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "groupOperationDescriptions", }, }); }; const GroupOperationDescriptions = Object.assign(_componentGroupOperationDescriptions, { componentType: "option", }); const _componentLookup = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "lookup", }, }); }; const Lookup = Object.assign(_componentLookup, { componentType: "option", }); export default FilterBuilder; export { FilterBuilder, CustomOperation, Field, FilterOperationDescriptions, Format, GroupOperationDescriptions, Lookup };