UNPKG

@talend/react-components

Version:
106 lines (105 loc) 3.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _propTypes = _interopRequireDefault(require("prop-types")); var _Dialog = _interopRequireDefault(require("../Dialog")); var _Action = _interopRequireDefault(require("../Actions/Action")); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * * @param size optional, allow to change the size of the model ( small / large ) * @param show allow to show the modal * @param header optional, set the text property for the header * @param children react's components children * @param validateAction object, describe the validate action * @param cancelAction object, describe the cancel action * @param progressValue number, if set shows progressbar with progress of progressValue * @param bodyOverflow bool, default true, * modal body automaticaly show a scrollbar if content overflow * const defaultProps = { header: 'Hello world', show: true, validateAction: { label: 'OK', onClick: action('ok'), }, cancelAction: { label: 'CANCEL', onClick: action('cancel'), }, }; const children = (<div>BODY content. You can put what ever you want here</div>); <ConfirmDialog {...defaultProps}>{children}</ConfirmDialog> * @constructor */function ConfirmDialog({ children, validateAction, secondaryActions, cancelAction, progressLabel, progressValue, onHide, ...props }) { const actions = { left: [], center: [], right: [] }; if (cancelAction) { actions.left.push(cancelAction); } if (secondaryActions) { actions.right = actions.right.concat(secondaryActions); } if (validateAction) { actions.right.push(validateAction); } let progress; if (progressValue) { progress = { percent: progressValue, tooltip: progressLabel }; } function onHideHandler(event) { if (cancelAction && cancelAction.onClick) { cancelAction.onClick(); } return onHide ? onHide(event) : null; } return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.default, { progress: progress, closeButton: false, actionbar: { actions }, onHide: onHideHandler, ...props, children: children }); } ConfirmDialog.displayName = 'ConfirmDialog'; ConfirmDialog.defaultValue = { secondaryActions: [] }; ConfirmDialog.propTypes = { header: _propTypes.default.string, size: _propTypes.default.oneOf(['small', 'large']), children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.arrayOf(_propTypes.default.element)]), show: _propTypes.default.bool, cancelAction: _propTypes.default.shape(_Action.default.propTypes), validateAction: _propTypes.default.shape(_Action.default.propTypes), secondaryActions: _propTypes.default.arrayOf(_propTypes.default.shape(_Action.default.propTypes)), progressLabel: _propTypes.default.string, progressValue: _propTypes.default.number, bodyOverflow: _propTypes.default.bool, onHide: _propTypes.default.func, getComponent: _propTypes.default.func }; var _default = exports.default = ConfirmDialog; //# sourceMappingURL=ConfirmDialog.component.js.map