@vnmfify/core
Version:
```shell npm i @vnmfify/core -S ```
42 lines (38 loc) • 1.35 kB
JavaScript
import { View } from "@vnxjs/components";
import classNames from "classnames";
import * as React from "react";
import { useContext } from "react";
import { prefixClassname } from "../styles";
import PickerContext from "./picker.context";
export var PickerButtonType;
(function (PickerButtonType) {
PickerButtonType["Cancel"] = "cancel";
PickerButtonType["Confirm"] = "confirm";
})(PickerButtonType || (PickerButtonType = {}));
export default function PickerButton(props) {
var {
type = PickerButtonType.Cancel,
children,
onClick: _onClick
} = props;
var {
onCancel,
onConfirm
} = useContext(PickerContext);
return /*#__PURE__*/React.createElement(View, {
className: classNames({
[prefixClassname("picker__cancel")]: type === PickerButtonType.Cancel,
[prefixClassname("picker__confirm")]: type === PickerButtonType.Confirm
}),
children: children,
onClick: e => {
_onClick === null || _onClick === void 0 ? void 0 : _onClick(e);
if (type === PickerButtonType.Cancel) {
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
} else if (type === PickerButtonType.Confirm) {
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
}
}
});
}
//# sourceMappingURL=picker-button.js.map