UNPKG

@rjsf/core

Version:

A simple React component capable of building HTML forms out of a JSON schema.

13 lines (12 loc) 1.54 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { DateElement, TranslatableString, useAltDateWidgetProps, } from '@rjsf/utils'; /** The `AltDateWidget` is an alternative widget for rendering date properties. * @param props - The `WidgetProps` for this component */ function AltDateWidget(props) { const { disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus } = props; const { translateString } = registry; const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props); return (_jsxs("ul", { className: 'list-inline', children: [elements.map((elemProps, i) => (_jsx("li", { className: 'list-inline-item', children: _jsx(DateElement, { rootId: id, name: name, select: handleChange, ...elemProps, disabled: disabled, readonly: readonly, registry: registry, onBlur: onBlur, onFocus: onFocus, autofocus: autofocus && i === 0 }) }, i))), (options.hideNowButton !== 'undefined' ? !options.hideNowButton : true) && (_jsx("li", { className: 'list-inline-item', children: _jsx("a", { href: '#', className: 'btn btn-info btn-now', onClick: handleSetNow, children: translateString(TranslatableString.NowLabel) }) })), (options.hideClearButton !== 'undefined' ? !options.hideClearButton : true) && (_jsx("li", { className: 'list-inline-item', children: _jsx("a", { href: '#', className: 'btn btn-warning btn-clear', onClick: handleClear, children: translateString(TranslatableString.ClearLabel) }) }))] })); } export default AltDateWidget;