@ray-js/components
Version:
Ray basic components
34 lines • 1.15 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["className", "style", "id", "onChange", "type", "color"];
import clsx from 'clsx';
import * as React from 'react';
import { inlineStyle } from '@ray-js/framework-shared';
import { Switch as RemaxSwitch } from '@ray-js/adapter';
const Switch = props => {
const {
className,
style,
id,
onChange,
type = 'switch',
color
} = props,
restProps = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/React.createElement(RemaxSwitch, _extends({
id: id,
onChange: e => {
onChange === null || onChange === void 0 || onChange(_objectSpread(_objectSpread({}, e), {}, {
type: 'change',
value: e.detail.value,
origin: e
}));
},
style: inlineStyle(style),
className: clsx(className),
color: color || (type === 'switch' ? '#007aff' : '#ffffff'),
type: type
}, restProps));
};
export default Switch;