UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

90 lines (88 loc) 2.93 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 dxNumberBox from "devextreme/ui/number_box"; import { Component as BaseComponent } from "./core/component"; import NestedOption from "./core/nested-option"; const NumberBox = memo(forwardRef((props, ref) => { const baseRef = useRef(null); useImperativeHandle(ref, () => ({ instance() { return baseRef.current?.getInstance(); } }), [baseRef.current]); const subscribableOptions = useMemo(() => (["value"]), []); const independentEvents = useMemo(() => (["onChange", "onContentReady", "onCopy", "onCut", "onDisposing", "onEnterKey", "onFocusIn", "onFocusOut", "onInitialized", "onInput", "onKeyDown", "onKeyUp", "onPaste", "onValueChanged"]), []); const defaults = useMemo(() => ({ defaultValue: "value", }), []); const expectedChildren = useMemo(() => ({ button: { optionName: "buttons", isCollectionItem: true }, format: { optionName: "format", isCollectionItem: false } }), []); return (React.createElement((BaseComponent), { WidgetClass: dxNumberBox, ref: baseRef, subscribableOptions, independentEvents, defaults, expectedChildren, ...props, })); })); const _componentButton = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "buttons", IsCollectionItem: true, ExpectedChildren: { options: { optionName: "options", isCollectionItem: false } }, }, }); }; const Button = Object.assign(_componentButton, { componentType: "option", }); const _componentFormat = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "format", }, }); }; const Format = Object.assign(_componentFormat, { componentType: "option", }); const _componentOptions = (props) => { return React.createElement((NestedOption), { ...props, elementDescriptor: { OptionName: "options", TemplateProps: [{ tmplOption: "template", render: "render", component: "component" }], }, }); }; const Options = Object.assign(_componentOptions, { componentType: "option", }); export default NumberBox; export { NumberBox, Button, Format, Options };