UNPKG

preact-arco-design

Version:

Arco Design React UI Library.

54 lines (47 loc) 1.85 kB
var __assign = this && this.__assign || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } } return t; }; return __assign.apply(this, arguments); }; import React, { memo } from "preact/compat"; import { isObject, isFunction } from "../_util/is"; import { formatPercent, valueInRange, getIntervalOffset } from "./utils"; import cs from "../_util/classNames"; var Dots = function Dots(props) { var _a = props.data, data = _a === void 0 ? [] : _a, _b = props.value, value = _b === void 0 ? [] : _b, vertical = props.vertical, prefixCls = props.prefixCls, reverse = props.reverse, intervalConfigs = props.intervalConfigs; if (!data.length) return null; return React.createElement("div", { className: "".concat(prefixCls, "-dots") }, data.map(function (_a) { var _b, _c, _d; var key = _a.key, content = _a.content; var offset = formatPercent(getIntervalOffset(+key, intervalConfigs)); return React.createElement("div", { className: "".concat(prefixCls, "-dot-wrapper"), key: key, style: __assign({}, vertical ? (_b = {}, _b[reverse ? 'top' : 'bottom'] = offset, _b) : (_c = {}, _c[reverse ? 'right' : 'left'] = offset, _c)), onMouseDown: function onMouseDown(e) { e.stopPropagation(); isFunction(props.onMouseDown) && props.onMouseDown(parseFloat(key)); } }, isObject(content) && content.dot ? content.dot : React.createElement("div", { className: cs("".concat(prefixCls, "-dot"), (_d = {}, _d["".concat(prefixCls, "-dot-active")] = valueInRange(key, value), _d)) })); })); }; export default memo(Dots);