devextreme-react
Version: 
DevExtreme React UI and Visualization Components
525 lines (523 loc) • 18.8 kB
JavaScript
/*!
 * devextreme-react
 * Version: 25.1.6
 * Build date: Mon Oct 13 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";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationRule = exports.TabPanelOptionsItem = exports.TabPanelOptions = exports.TabbedItem = exports.Tab = exports.StringLengthRule = exports.SimpleItem = exports.RequiredRule = exports.RangeRule = exports.PatternRule = exports.NumericRule = exports.Label = exports.Item = exports.GroupItem = exports.EmptyItem = exports.EmailRule = exports.CustomRule = exports.CompareRule = exports.ColCountByScreen = exports.ButtonOptions = exports.ButtonItem = exports.AsyncRule = exports.Form = void 0;
const React = __importStar(require("react"));
const react_1 = require("react");
const form_1 = __importDefault(require("devextreme/ui/form"));
const component_1 = require("./core/component");
const nested_option_1 = __importDefault(require("./core/nested-option"));
const Form = (0, react_1.memo)((0, react_1.forwardRef)((props, ref) => {
    const baseRef = (0, react_1.useRef)(null);
    (0, react_1.useImperativeHandle)(ref, () => ({
        instance() {
            return baseRef.current?.getInstance();
        }
    }), []);
    const subscribableOptions = (0, react_1.useMemo)(() => (["formData"]), []);
    const independentEvents = (0, react_1.useMemo)(() => (["onContentReady", "onDisposing", "onEditorEnterKey", "onInitialized"]), []);
    const defaults = (0, react_1.useMemo)(() => ({
        defaultFormData: "formData",
    }), []);
    const expectedChildren = (0, react_1.useMemo)(() => ({
        ButtonItem: { optionName: "items", isCollectionItem: true },
        colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false },
        EmptyItem: { optionName: "items", isCollectionItem: true },
        GroupItem: { optionName: "items", isCollectionItem: true },
        item: { optionName: "items", isCollectionItem: true },
        SimpleItem: { optionName: "items", isCollectionItem: true },
        TabbedItem: { optionName: "items", isCollectionItem: true }
    }), []);
    return (React.createElement((component_1.Component), {
        WidgetClass: form_1.default,
        ref: baseRef,
        subscribableOptions,
        independentEvents,
        defaults,
        expectedChildren,
        ...props,
    }));
}));
exports.Form = Form;
const _componentAsyncRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "async"
            },
        },
    });
};
const AsyncRule = Object.assign(_componentAsyncRule, {
    componentType: "option",
});
exports.AsyncRule = AsyncRule;
const _componentButtonItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            ExpectedChildren: {
                buttonOptions: { optionName: "buttonOptions", isCollectionItem: false }
            },
            PredefinedProps: {
                itemType: "button"
            },
        },
    });
};
const ButtonItem = Object.assign(_componentButtonItem, {
    componentType: "option",
});
exports.ButtonItem = ButtonItem;
const _componentButtonOptions = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "buttonOptions",
            TemplateProps: [{
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
        },
    });
};
const ButtonOptions = Object.assign(_componentButtonOptions, {
    componentType: "option",
});
exports.ButtonOptions = ButtonOptions;
const _componentColCountByScreen = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "colCountByScreen",
        },
    });
};
const ColCountByScreen = Object.assign(_componentColCountByScreen, {
    componentType: "option",
});
exports.ColCountByScreen = ColCountByScreen;
const _componentCompareRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "compare"
            },
        },
    });
};
const CompareRule = Object.assign(_componentCompareRule, {
    componentType: "option",
});
exports.CompareRule = CompareRule;
const _componentCustomRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "custom"
            },
        },
    });
};
const CustomRule = Object.assign(_componentCustomRule, {
    componentType: "option",
});
exports.CustomRule = CustomRule;
const _componentEmailRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "email"
            },
        },
    });
};
const EmailRule = Object.assign(_componentEmailRule, {
    componentType: "option",
});
exports.EmailRule = EmailRule;
const _componentEmptyItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            PredefinedProps: {
                itemType: "empty"
            },
        },
    });
};
const EmptyItem = Object.assign(_componentEmptyItem, {
    componentType: "option",
});
exports.EmptyItem = EmptyItem;
const _componentGroupItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            ExpectedChildren: {
                colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false }
            },
            TemplateProps: [{
                    tmplOption: "captionTemplate",
                    render: "captionRender",
                    component: "captionComponent"
                }, {
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
            PredefinedProps: {
                itemType: "group"
            },
        },
    });
};
const GroupItem = Object.assign(_componentGroupItem, {
    componentType: "option",
});
exports.GroupItem = GroupItem;
const _componentItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            ExpectedChildren: {
                AsyncRule: { optionName: "validationRules", isCollectionItem: true },
                buttonOptions: { optionName: "buttonOptions", isCollectionItem: false },
                colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false },
                CompareRule: { optionName: "validationRules", isCollectionItem: true },
                CustomRule: { optionName: "validationRules", isCollectionItem: true },
                EmailRule: { optionName: "validationRules", isCollectionItem: true },
                label: { optionName: "label", isCollectionItem: false },
                NumericRule: { optionName: "validationRules", isCollectionItem: true },
                PatternRule: { optionName: "validationRules", isCollectionItem: true },
                RangeRule: { optionName: "validationRules", isCollectionItem: true },
                RequiredRule: { optionName: "validationRules", isCollectionItem: true },
                StringLengthRule: { optionName: "validationRules", isCollectionItem: true },
                tab: { optionName: "tabs", isCollectionItem: true },
                tabPanelOptions: { optionName: "tabPanelOptions", isCollectionItem: false },
                validationRule: { optionName: "validationRules", isCollectionItem: true }
            },
            TemplateProps: [{
                    tmplOption: "tabTemplate",
                    render: "tabRender",
                    component: "tabComponent"
                }, {
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }, {
                    tmplOption: "captionTemplate",
                    render: "captionRender",
                    component: "captionComponent"
                }],
        },
    });
};
const Item = Object.assign(_componentItem, {
    componentType: "option",
});
exports.Item = Item;
const _componentLabel = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "label",
            TemplateProps: [{
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
        },
    });
};
const Label = Object.assign(_componentLabel, {
    componentType: "option",
});
exports.Label = Label;
const _componentNumericRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "numeric"
            },
        },
    });
};
const NumericRule = Object.assign(_componentNumericRule, {
    componentType: "option",
});
exports.NumericRule = NumericRule;
const _componentPatternRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "pattern"
            },
        },
    });
};
const PatternRule = Object.assign(_componentPatternRule, {
    componentType: "option",
});
exports.PatternRule = PatternRule;
const _componentRangeRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "range"
            },
        },
    });
};
const RangeRule = Object.assign(_componentRangeRule, {
    componentType: "option",
});
exports.RangeRule = RangeRule;
const _componentRequiredRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "required"
            },
        },
    });
};
const RequiredRule = Object.assign(_componentRequiredRule, {
    componentType: "option",
});
exports.RequiredRule = RequiredRule;
const _componentSimpleItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            ExpectedChildren: {
                AsyncRule: { optionName: "validationRules", isCollectionItem: true },
                CompareRule: { optionName: "validationRules", isCollectionItem: true },
                CustomRule: { optionName: "validationRules", isCollectionItem: true },
                EmailRule: { optionName: "validationRules", isCollectionItem: true },
                label: { optionName: "label", isCollectionItem: false },
                NumericRule: { optionName: "validationRules", isCollectionItem: true },
                PatternRule: { optionName: "validationRules", isCollectionItem: true },
                RangeRule: { optionName: "validationRules", isCollectionItem: true },
                RequiredRule: { optionName: "validationRules", isCollectionItem: true },
                StringLengthRule: { optionName: "validationRules", isCollectionItem: true },
                validationRule: { optionName: "validationRules", isCollectionItem: true }
            },
            TemplateProps: [{
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
            PredefinedProps: {
                itemType: "simple"
            },
        },
    });
};
const SimpleItem = Object.assign(_componentSimpleItem, {
    componentType: "option",
});
exports.SimpleItem = SimpleItem;
const _componentStringLengthRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "stringLength"
            },
        },
    });
};
const StringLengthRule = Object.assign(_componentStringLengthRule, {
    componentType: "option",
});
exports.StringLengthRule = StringLengthRule;
const _componentTab = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "tabs",
            IsCollectionItem: true,
            ExpectedChildren: {
                colCountByScreen: { optionName: "colCountByScreen", isCollectionItem: false }
            },
            TemplateProps: [{
                    tmplOption: "tabTemplate",
                    render: "tabRender",
                    component: "tabComponent"
                }, {
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
        },
    });
};
const Tab = Object.assign(_componentTab, {
    componentType: "option",
});
exports.Tab = Tab;
const _componentTabbedItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            ExpectedChildren: {
                tab: { optionName: "tabs", isCollectionItem: true },
                tabPanelOptions: { optionName: "tabPanelOptions", isCollectionItem: false }
            },
            PredefinedProps: {
                itemType: "tabbed"
            },
        },
    });
};
const TabbedItem = Object.assign(_componentTabbedItem, {
    componentType: "option",
});
exports.TabbedItem = TabbedItem;
const _componentTabPanelOptions = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "tabPanelOptions",
            DefaultsProps: {
                defaultItems: "items",
                defaultSelectedIndex: "selectedIndex",
                defaultSelectedItem: "selectedItem"
            },
            ExpectedChildren: {
                item: { optionName: "items", isCollectionItem: true },
                tabPanelOptionsItem: { optionName: "items", isCollectionItem: true }
            },
            TemplateProps: [{
                    tmplOption: "itemTemplate",
                    render: "itemRender",
                    component: "itemComponent"
                }, {
                    tmplOption: "itemTitleTemplate",
                    render: "itemTitleRender",
                    component: "itemTitleComponent"
                }],
        },
    });
};
const TabPanelOptions = Object.assign(_componentTabPanelOptions, {
    componentType: "option",
});
exports.TabPanelOptions = TabPanelOptions;
const _componentTabPanelOptionsItem = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "items",
            IsCollectionItem: true,
            TemplateProps: [{
                    tmplOption: "tabTemplate",
                    render: "tabRender",
                    component: "tabComponent"
                }, {
                    tmplOption: "template",
                    render: "render",
                    component: "component"
                }],
        },
    });
};
const TabPanelOptionsItem = Object.assign(_componentTabPanelOptionsItem, {
    componentType: "option",
});
exports.TabPanelOptionsItem = TabPanelOptionsItem;
const _componentValidationRule = (props) => {
    return React.createElement((nested_option_1.default), {
        ...props,
        elementDescriptor: {
            OptionName: "validationRules",
            IsCollectionItem: true,
            PredefinedProps: {
                type: "required"
            },
        },
    });
};
const ValidationRule = Object.assign(_componentValidationRule, {
    componentType: "option",
});
exports.ValidationRule = ValidationRule;
exports.default = Form;