tntd 2.8.38 → 2.8.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/es/_util/hooks/useScrollLock.js +64 -0
  2. package/es/_util/hooks/useScrollLock.js.map +1 -0
  3. package/es/array-input/index.js +17 -4
  4. package/es/array-input/index.js.map +1 -1
  5. package/es/array-input/index.less +123 -1
  6. package/es/array-input/utils.js +71 -0
  7. package/es/array-input/utils.js.map +1 -0
  8. package/es/ellipsis/index.js +11 -1
  9. package/es/ellipsis/index.js.map +1 -1
  10. package/es/page-loading/index.less +4 -4
  11. package/es/page-loading/loading.gif +0 -0
  12. package/es/tntd-rc-select/style/index.less +20 -2
  13. package/es/tooltip/tooltip.js +19 -5
  14. package/es/tooltip/tooltip.js.map +1 -1
  15. package/lib/_util/hooks/useScrollLock.d.ts +9 -0
  16. package/lib/_util/hooks/useScrollLock.d.ts.map +1 -0
  17. package/lib/_util/hooks/useScrollLock.js +107 -0
  18. package/lib/_util/hooks/useScrollLock.js.map +1 -0
  19. package/lib/array-input/index.d.ts.map +1 -1
  20. package/lib/array-input/index.js +17 -4
  21. package/lib/array-input/index.js.map +1 -1
  22. package/lib/array-input/index.less +123 -1
  23. package/lib/array-input/utils.d.ts +2 -0
  24. package/lib/array-input/utils.d.ts.map +1 -0
  25. package/lib/array-input/utils.js +414 -0
  26. package/lib/array-input/utils.js.map +1 -0
  27. package/lib/ellipsis/index.d.ts.map +1 -1
  28. package/lib/ellipsis/index.js +11 -1
  29. package/lib/ellipsis/index.js.map +1 -1
  30. package/lib/page-loading/index.less +4 -4
  31. package/lib/page-loading/loading.gif +0 -0
  32. package/lib/tntd-rc-select/style/index.less +20 -2
  33. package/lib/tooltip/tooltip.d.ts +1 -0
  34. package/lib/tooltip/tooltip.d.ts.map +1 -1
  35. package/lib/tooltip/tooltip.js +23 -9
  36. package/lib/tooltip/tooltip.js.map +1 -1
  37. package/package.json +2 -2
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = require("react");
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+ // ==================== 优化版 Hook ====================
15
+ var _default = exports["default"] = function _default(config) {
16
+ var _ref = config || {},
17
+ _ref$enableScrollObse = _ref.enableScrollObserver,
18
+ enableScrollObserver = _ref$enableScrollObse === void 0 ? true : _ref$enableScrollObse,
19
+ _ref$debounceTime = _ref.debounceTime,
20
+ debounceTime = _ref$debounceTime === void 0 ? 100 : _ref$debounceTime,
21
+ _ref$throttleTime = _ref.throttleTime,
22
+ throttleTime = _ref$throttleTime === void 0 ? 50 : _ref$throttleTime,
23
+ _ref$scrollContainer = _ref.scrollContainer,
24
+ scrollContainer = _ref$scrollContainer === void 0 ? window : _ref$scrollContainer;
25
+ // 滚动状态追踪
26
+ var _useState = (0, _react.useState)(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ isScrolling = _useState2[0],
29
+ setIsScrolling = _useState2[1];
30
+ // 定时器引用
31
+ var timerRef = (0, _react.useRef)();
32
+ // 最后一次滚动时间戳
33
+ var lastScrollTime = (0, _react.useRef)(0);
34
+ // ==================== 核心逻辑 ====================
35
+ var handleScroll = (0, _react.useCallback)(function () {
36
+ // 节流控制:限制执行频率
37
+ var now = Date.now();
38
+ if (now - lastScrollTime.current < throttleTime) return;
39
+ lastScrollTime.current = now;
40
+ // 标记开始滚动
41
+ setIsScrolling(true);
42
+ // 防抖控制:延迟结束标记
43
+ if (timerRef.current) clearTimeout(timerRef.current);
44
+ timerRef.current = setTimeout(function () {
45
+ setIsScrolling(false);
46
+ }, debounceTime);
47
+ }, [debounceTime, throttleTime]);
48
+ // ==================== 事件监听 ====================
49
+ (0, _react.useEffect)(function () {
50
+ var container = scrollContainer || window;
51
+ if (!container || !enableScrollObserver) return;
52
+ // 高性能事件监听选项
53
+ var options = {
54
+ passive: true,
55
+ capture: true // 捕获阶段触发
56
+ };
57
+ container.addEventListener('scroll', handleScroll, options);
58
+ return function () {
59
+ container.removeEventListener('scroll', handleScroll, options);
60
+ if (timerRef.current) clearTimeout(timerRef.current);
61
+ };
62
+ }, [handleScroll, scrollContainer, enableScrollObserver]);
63
+ return isScrolling;
64
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollLock.js","sourceRoot":"","sources":["../../../src/_util/hooks/useScrollLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,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AI,EAAE,SAAS;SACzB,CAAA;QAED,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;QAE3D,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;YAC9D,IAAI,QAAQ,CAAC,OAAO;gBAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,oBAAoB,CAAC,CAAC,CAAA;IAEzD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA","sourcesContent":["import { useState, useEffect, useRef, useCallback } from 'react'\n\n// ==================== 类型定义 ====================\ninterface ScrollControlConfig {\n debounceTime?: number // 防抖时间 (默认: 100ms)\n throttleTime?: number // 节流时间 (默认: 50ms)\n scrollContainer?: HTMLElement | Window | null\n enableScrollObserver?: boolean\n}\n\n// ==================== 优化版 Hook ====================\nexport default (config?: ScrollControlConfig) => {\n const {\n enableScrollObserver = true,\n debounceTime = 100,\n throttleTime = 50,\n scrollContainer = window,\n } = config || {}\n\n // 滚动状态追踪\n const [isScrolling, setIsScrolling] = useState(false)\n // 定时器引用\n const timerRef = useRef<ReturnType<typeof setTimeout>>()\n // 最后一次滚动时间戳\n const lastScrollTime = useRef(0)\n\n // ==================== 核心逻辑 ====================\n const handleScroll = useCallback(() => {\n // 节流控制:限制执行频率\n const now = Date.now()\n if (now - lastScrollTime.current < throttleTime) return\n lastScrollTime.current = now\n\n // 标记开始滚动\n setIsScrolling(true)\n\n // 防抖控制:延迟结束标记\n if (timerRef.current) clearTimeout(timerRef.current)\n timerRef.current = setTimeout(() => {\n setIsScrolling(false)\n }, debounceTime)\n }, [debounceTime, throttleTime])\n\n // ==================== 事件监听 ====================\n useEffect(() => {\n const container = scrollContainer || window\n if (!container || !enableScrollObserver) return\n\n // 高性能事件监听选项\n const options: AddEventListenerOptions = {\n passive: true, // 启用被动监听提升性能\n capture: true, // 捕获阶段触发\n }\n\n container.addEventListener('scroll', handleScroll, options)\n\n return () => {\n container.removeEventListener('scroll', handleScroll, options)\n if (timerRef.current) clearTimeout(timerRef.current)\n }\n }, [handleScroll, scrollContainer, enableScrollObserver])\n\n return isScrolling\n}\n"]}
@@ -110,6 +110,7 @@ function ArrayInput(_ref) {
110
110
  gutter = _ref$gutter === void 0 ? 10 : _ref$gutter,
111
111
  _ref$require = _ref.require,
112
112
  require = _ref$require === void 0 ? false : _ref$require,
113
+ errorMap = _ref.errorMap,
113
114
  _ref$deleteTip = _ref.deleteTip,
114
115
  deleteTip = _ref$deleteTip === void 0 ? '' : _ref$deleteTip,
115
116
  _ref$plusTip = _ref.plusTip,
@@ -221,9 +222,12 @@ function ArrayInput(_ref) {
221
222
  span = _a$span === void 0 ? 4 : _a$span,
222
223
  fieldChange = _a.onChange,
223
224
  other = __rest(_a, ["name", "span", "onChange"]);
225
+ var isError = errorMap ? errorMap["".concat(index, "-").concat(name)] : '';
224
226
  return _react["default"].createElement(_col["default"], {
225
227
  span: span,
226
228
  key: i
229
+ }, _react["default"].createElement("div", {
230
+ className: !isError ? 'tntd-array-input-hide-error' : ''
227
231
  }, _react["default"].cloneElement(field, Object.assign({
228
232
  value: item[name] || undefined,
229
233
  onChange: function onChange(e) {
@@ -231,7 +235,9 @@ function ArrayInput(_ref) {
231
235
  var newValue = e.target ? e.target.value : e;
232
236
  changeValue(index, name, newValue);
233
237
  }
234
- }, other)));
238
+ }, other))), isError && _react["default"].createElement("div", {
239
+ className: "ant-form-item-explain-error"
240
+ }, isError));
235
241
  }), _react["default"].createElement(_col["default"], {
236
242
  span: actionSpan
237
243
  }, _react["default"].createElement("span", {
@@ -316,15 +322,22 @@ function ArrayInput(_ref) {
316
322
  if (!(0, _react.isValidElement)(field)) {
317
323
  return field;
318
324
  }
319
- var fieldChange = field.props.onChange;
320
- return _react["default"].cloneElement(field, {
325
+ var _field$props = field.props,
326
+ name = _field$props.name,
327
+ fieldChange = _field$props.onChange;
328
+ var isError = errorMap ? errorMap["".concat(index, "-").concat(name)] : '';
329
+ return _react["default"].createElement("div", {
330
+ className: !isError ? 'tntd-array-input-hide-error' : ''
331
+ }, _react["default"].cloneElement(field, {
321
332
  value: inValue[index][name] || undefined,
322
333
  onChange: function onChange(e) {
323
334
  fieldChange && fieldChange(e, index, changeValue);
324
335
  var newValue = e.target ? e.target.value : e;
325
336
  changeValue(index, name, newValue);
326
337
  }
327
- });
338
+ }), isError && _react["default"].createElement("div", {
339
+ className: "ant-form-item-explain-error"
340
+ }, isError));
328
341
  }
329
342
  });
330
343
  }), _react["default"].createElement(Column, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array-input/index.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EACL,eAAe,EACf,SAAS,EACT,WAAW,EACX,2BAA2B,GAC5B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAClE,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpG,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,OAAO,M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AAG,CACjB,CACC,CACX,CAAC,CAAC,CAAC,CACF,8BAAM,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;oCAClC,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CACjB,CACR,CACI,CACR,CAAA;4BACH,CAAC,GACO,CACJ,CACQ,CACP;YACb,oBAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,KAAK,QAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE;gBACjE,oBAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG;gBACnB,OAAO,CACD,CACL,CACP,CAAA;KACF;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK;IAC1C,OAAO,CACL,oBAAC,cAAc,IAAC,aAAa,EAAC,YAAY,IACvC,CAAC,MAAM,EAAE,EAAE;QACV,OAAO,oBAAC,UAAU,oBAAK,KAAK,IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClD,CAAC,CACc,CAClB,CAAA;AACH,CAAC","sourcesContent":["import { DndContext } from '@dnd-kit/core'\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers'\nimport {\n SortableContext,\n arrayMove,\n useSortable,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable'\nimport { CSS } from '@dnd-kit/utilities'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport { get, isArray, isFunction, set, sum, sumBy } from 'lodash'\nimport React, { isValidElement, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport Button from '../button'\nimport Col from '../col'\nimport Icon from '../icon'\nimport Row from '../row'\nimport Table from '../table'\nimport Tooltip from '../tooltip'\nimport './index.less'\n\nconst { Column } = Table\nconst RowContext = React.createContext({})\nconst getWidth = (span) => 1000 / span\nlet key = 1\n\nfunction DragHandle() {\n const { setActivatorNodeRef, listeners } = useContext(RowContext)\n return (\n <Button\n className=\"drag-btn\"\n type=\"tertiary\"\n size=\"small\"\n icon=\"drag\"\n ref={setActivatorNodeRef}\n {...listeners}\n />\n )\n}\nfunction BodyRow(props) {\n const {\n attributes,\n listeners,\n setNodeRef,\n setActivatorNodeRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id: props['data-row-key'],\n })\n const style = {\n ...props.style,\n transform: CSS.Translate.toString(transform),\n transition,\n ...(isDragging\n ? {\n position: 'relative',\n zIndex: 9999,\n }\n : {}),\n }\n const contextValue = useMemo(\n () => ({\n setActivatorNodeRef,\n listeners,\n }),\n [setActivatorNodeRef, listeners]\n )\n return (\n <RowContext.Provider value={contextValue}>\n <tr {...props} ref={setNodeRef} style={style} {...attributes} />\n </RowContext.Provider>\n )\n}\n\nfunction ArrayInput({\n children,\n defaultValue,\n value,\n onChange,\n mode = 'list',\n drag = false, // 只做了table的拖拽排序\n gutter = 10,\n require = false,\n deleteTip = '',\n plusTip = '',\n addText,\n locale,\n xProps = {},\n renderAction,\n}) {\n if (!isFunction(children)) {\n throw new Error(locale.error)\n }\n if (addText === undefined) {\n addText = locale?.add\n }\n\n const [_value, setValue] = useState(value || defaultValue)\n\n useEffect(() => {\n let newValue = value\n // 如果数组没有key\n if (Array.isArray(value) && value.some((obj) => !obj.key)) {\n newValue = value.map((obj) => ({ ...obj, key: obj.key || key++ }))\n _onChange(newValue)\n } else {\n setValue(newValue)\n }\n }, [value])\n\n const _onChange = useCallback((value) => {\n if (onChange) {\n onChange(value)\n } else {\n setValue(value)\n }\n }, [])\n\n let inValue = _value || []\n if (require && inValue.length === 0) {\n inValue = [{ key: key++ }]\n }\n\n const changeValue = (index, name, value) => {\n inValue[index] = {\n ...inValue[index],\n [name]: value,\n }\n _onChange([...inValue])\n }\n\n const onAdd = (index) => {\n if (index === undefined) {\n _onChange([...inValue, { key: key++ }])\n } else {\n inValue.splice(index + 1, 0, { key: key++ })\n _onChange([...inValue])\n }\n }\n\n const onDelete = (i) => {\n inValue.splice(i, 1)\n _onChange([...inValue])\n }\n\n const onDragEnd = ({ active, over }) => {\n if (active.id !== over?.id) {\n _onChange((prevState) => {\n const activeIndex = prevState.findIndex((record) => record.key === active?.id)\n const overIndex = prevState.findIndex((record) => record.key === over?.id)\n return arrayMove(prevState, activeIndex, overIndex)\n })\n }\n }\n\n if (mode === 'list') {\n return (\n <div className=\"tntd-array-input\">\n {inValue.map((item, index) => {\n let fields = children(item, index)\n if (!isArray(fields)) {\n fields = get(fields, 'props.children', [])\n }\n const actionSpan = 24 - (sum(fields.map((f) => get(f, 'props.span', 4))) % 24)\n return (\n <Row gutter={gutter} key={index} className=\"tntd-array-input-item\">\n {fields.map((field, i) => {\n if (!isValidElement(field)) {\n return field ? (\n <Col span={4} key={i}>\n {field}\n </Col>\n ) : (\n ''\n )\n }\n const { name, span = 4, onChange: fieldChange, ...other } = field?.props\n return (\n <Col span={span} key={i}>\n {React.cloneElement(field, {\n value: item[name] || undefined,\n onChange: (e) => {\n fieldChange && fieldChange(e, index, changeValue)\n const newValue = e.target ? e.target.value : e\n changeValue(index, name, newValue)\n },\n ...other,\n })}\n </Col>\n )\n })}\n <Col span={actionSpan}>\n <span className=\"tntd-array-input-action\">\n {renderAction ? (\n renderAction(item, index, onDelete, onAdd)\n ) : (\n <>\n {deleteTip ? (\n <Tooltip title={deleteTip}>\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n </Tooltip>\n ) : (\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n )}\n </>\n )}\n </span>\n </Col>\n </Row>\n )\n })}\n <Button type=\"link\" onClick={() => onAdd()}>\n <Icon type=\"plus\" />\n {addText}\n </Button>\n </div>\n )\n } else {\n let fields = children({}, 0)\n if (!isArray(fields)) {\n fields = get(fields, 'props.children', [])\n }\n const dataSource = inValue.map((value, index) => {\n const fields = children(value, index)\n const back = { key: value.key }\n fields.forEach((field) => {\n const name = field?.props?.name\n name && set(back, name, field)\n })\n return back\n })\n\n return (\n <div className=\"tntd-array-input\">\n <DndContext modifiers={[restrictToVerticalAxis]} onDragEnd={onDragEnd}>\n <SortableContext\n items={dataSource.map((i) => i.key)}\n strategy={verticalListSortingStrategy}\n >\n <Table\n dataSource={dataSource}\n pagination={false}\n components={{\n body: {\n row: BodyRow,\n },\n }}\n bordered\n {...xProps}\n >\n {drag && (\n <Column\n key=\"dragger\"\n dataIndex=\"dragger\"\n width={60}\n render={() => <DragHandle />}\n ></Column>\n )}\n {fields.map((field) => {\n const { name, span, title } = field?.props || {}\n return (\n <Column\n key={name}\n dataIndex={name}\n title={title}\n width={getWidth(span || 24 / (fields.length + 1))}\n render={(field, row, index) => {\n if (!isValidElement(field)) {\n return field\n }\n const { onChange: fieldChange } = field.props\n return React.cloneElement(field, {\n value: inValue[index][name] || undefined,\n onChange: (e) => {\n fieldChange && fieldChange(e, index, changeValue)\n const newValue = e.target ? e.target.value : e\n changeValue(index, name, newValue)\n },\n })\n }}\n ></Column>\n )\n })}\n <Column\n key=\"action\"\n dataIndex=\"action\"\n title={locale.action}\n width={getWidth(24 - (sumBy(fields, 'props.span') % 24))}\n render={(text, row, index) => {\n if (renderAction) {\n return renderAction(row, index, onDelete, onAdd)\n }\n return (\n <span className=\"tntd-array-input-action\">\n {deleteTip ? (\n <Tooltip title={deleteTip}>\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n </Tooltip>\n ) : (\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n )}\n </span>\n )\n }}\n ></Column>\n </Table>\n </SortableContext>\n </DndContext>\n <Button type=\"dashed\" block className=\"mt10\" onClick={() => onAdd()}>\n <Icon type=\"plus\" />\n {addText}\n </Button>\n </div>\n )\n }\n}\n\nexport default function WarpArrayInput(props) {\n return (\n <LocaleReceiver componentName=\"ArrayInput\">\n {(locale) => {\n return <ArrayInput {...props} locale={locale} />\n }}\n </LocaleReceiver>\n )\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array-input/index.js"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vB,8BAAM,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;wCAClC,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CACjB,CACC,CACX,CAAC,CAAC,CAAC,CACF,8BAAM,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;oCAClC,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,CACjB,CACR,CACI,CACR,CAAA;4BACH,CAAC,GACO,CACJ,CACQ,CACP;YACb,oBAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,KAAK,QAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE;gBACjE,oBAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG;gBACnB,OAAO,CACD,CACL,CACP,CAAA;KACF;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK;IAC1C,OAAO,CACL,oBAAC,cAAc,IAAC,aAAa,EAAC,YAAY,IACvC,CAAC,MAAM,EAAE,EAAE;QACV,OAAO,oBAAC,UAAU,oBAAK,KAAK,IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClD,CAAC,CACc,CAClB,CAAA;AACH,CAAC","sourcesContent":["import { DndContext } from '@dnd-kit/core'\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers'\nimport {\n SortableContext,\n arrayMove,\n useSortable,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable'\nimport { CSS } from '@dnd-kit/utilities'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport { get, isArray, isFunction, set, sum, sumBy } from 'lodash'\nimport React, { isValidElement, useCallback, useContext, useEffect, useMemo, useState } from 'react'\nimport Button from '../button'\nimport Col from '../col'\nimport Icon from '../icon'\nimport Row from '../row'\nimport Table from '../table'\nimport Tooltip from '../tooltip'\nimport './index.less'\n\nconst { Column } = Table\nconst RowContext = React.createContext({})\nconst getWidth = (span) => 1000 / span\nlet key = 1\n\nfunction DragHandle() {\n const { setActivatorNodeRef, listeners } = useContext(RowContext)\n return (\n <Button\n className=\"drag-btn\"\n type=\"tertiary\"\n size=\"small\"\n icon=\"drag\"\n ref={setActivatorNodeRef}\n {...listeners}\n />\n )\n}\nfunction BodyRow(props) {\n const {\n attributes,\n listeners,\n setNodeRef,\n setActivatorNodeRef,\n transform,\n transition,\n isDragging,\n } = useSortable({\n id: props['data-row-key'],\n })\n const style = {\n ...props.style,\n transform: CSS.Translate.toString(transform),\n transition,\n ...(isDragging\n ? {\n position: 'relative',\n zIndex: 9999,\n }\n : {}),\n }\n const contextValue = useMemo(\n () => ({\n setActivatorNodeRef,\n listeners,\n }),\n [setActivatorNodeRef, listeners]\n )\n return (\n <RowContext.Provider value={contextValue}>\n <tr {...props} ref={setNodeRef} style={style} {...attributes} />\n </RowContext.Provider>\n )\n}\n\nfunction ArrayInput({\n children,\n defaultValue,\n value,\n onChange,\n mode = 'list',\n drag = false, // 只做了table的拖拽排序\n gutter = 10,\n require = false,\n errorMap,\n deleteTip = '',\n plusTip = '',\n addText,\n locale,\n xProps = {},\n renderAction,\n}) {\n if (!isFunction(children)) {\n throw new Error(locale.error)\n }\n if (addText === undefined) {\n addText = locale?.add\n }\n\n const [_value, setValue] = useState(value || defaultValue)\n\n useEffect(() => {\n let newValue = value\n // 如果数组没有key\n if (Array.isArray(value) && value.some((obj) => !obj.key)) {\n newValue = value.map((obj) => ({ ...obj, key: obj.key || key++ }))\n _onChange(newValue)\n } else {\n setValue(newValue)\n }\n }, [value])\n\n const _onChange = useCallback((value) => {\n if (onChange) {\n onChange(value)\n } else {\n setValue(value)\n }\n }, [])\n\n let inValue = _value || []\n if (require && inValue.length === 0) {\n inValue = [{ key: key++ }]\n }\n\n const changeValue = (index, name, value) => {\n inValue[index] = {\n ...inValue[index],\n [name]: value,\n }\n _onChange([...inValue])\n }\n\n const onAdd = (index) => {\n if (index === undefined) {\n _onChange([...inValue, { key: key++ }])\n } else {\n inValue.splice(index + 1, 0, { key: key++ })\n _onChange([...inValue])\n }\n }\n\n const onDelete = (i) => {\n inValue.splice(i, 1)\n _onChange([...inValue])\n }\n\n const onDragEnd = ({ active, over }) => {\n if (active.id !== over?.id) {\n _onChange((prevState) => {\n const activeIndex = prevState.findIndex((record) => record.key === active?.id)\n const overIndex = prevState.findIndex((record) => record.key === over?.id)\n return arrayMove(prevState, activeIndex, overIndex)\n })\n }\n }\n\n if (mode === 'list') {\n return (\n <div className=\"tntd-array-input\">\n {inValue.map((item, index) => {\n let fields = children(item, index)\n if (!isArray(fields)) {\n fields = get(fields, 'props.children', [])\n }\n const actionSpan = 24 - (sum(fields.map((f) => get(f, 'props.span', 4))) % 24)\n return (\n <Row gutter={gutter} key={index} className=\"tntd-array-input-item\">\n {fields.map((field, i) => {\n if (!isValidElement(field)) {\n return field ? (\n <Col span={4} key={i}>\n {field}\n </Col>\n ) : (\n ''\n )\n }\n const { name, span = 4, onChange: fieldChange, ...other } = field?.props;\n const isError = errorMap ? errorMap[`${index}-${name}`] : '';\n return (\n <Col span={span} key={i}>\n <div className={!isError ? 'tntd-array-input-hide-error' : ''}>\n {React.cloneElement(field, {\n value: item[name] || undefined,\n onChange: (e) => {\n fieldChange && fieldChange(e, index, changeValue)\n const newValue = e.target ? e.target.value : e\n changeValue(index, name, newValue)\n },\n ...other,\n })}\n </div>\n {isError&&<div className=\"ant-form-item-explain-error\">{isError}</div>}\n </Col>\n )\n })}\n <Col span={actionSpan}>\n <span className=\"tntd-array-input-action\">\n {renderAction ? (\n renderAction(item, index, onDelete, onAdd)\n ) : (\n <>\n {deleteTip ? (\n <Tooltip title={deleteTip}>\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n </Tooltip>\n ) : (\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n )}\n </>\n )}\n </span>\n </Col>\n </Row>\n )\n })}\n <Button type=\"link\" onClick={() => onAdd()}>\n <Icon type=\"plus\" />\n {addText}\n </Button>\n </div>\n )\n } else {\n let fields = children({}, 0)\n if (!isArray(fields)) {\n fields = get(fields, 'props.children', [])\n }\n const dataSource = inValue.map((value, index) => {\n const fields = children(value, index)\n const back = { key: value.key }\n fields.forEach((field) => {\n const name = field?.props?.name\n name && set(back, name, field)\n })\n return back\n })\n\n return (\n <div className=\"tntd-array-input\">\n <DndContext modifiers={[restrictToVerticalAxis]} onDragEnd={onDragEnd}>\n <SortableContext\n items={dataSource.map((i) => i.key)}\n strategy={verticalListSortingStrategy}\n >\n <Table\n dataSource={dataSource}\n pagination={false}\n components={{\n body: {\n row: BodyRow,\n },\n }}\n bordered\n {...xProps}\n >\n {drag && (\n <Column\n key=\"dragger\"\n dataIndex=\"dragger\"\n width={60}\n render={() => <DragHandle />}\n ></Column>\n )}\n {fields.map((field) => {\n const { name, span, title } = field?.props || {}\n return (\n <Column\n key={name}\n dataIndex={name}\n title={title}\n width={getWidth(span || 24 / (fields.length + 1))}\n render={(field, row, index) => {\n if (!isValidElement(field)) {\n return field\n }\n const { name, onChange: fieldChange } = field.props\n const isError = errorMap ? errorMap[`${index}-${name}`] : '';\n return <div className={!isError ? 'tntd-array-input-hide-error' : ''}>\n { React.cloneElement(field, {\n value: inValue[index][name] || undefined,\n onChange: (e) => {\n fieldChange && fieldChange(e, index, changeValue)\n const newValue = e.target ? e.target.value : e\n changeValue(index, name, newValue)\n },\n }) }\n { isError && <div className=\"ant-form-item-explain-error\">{isError}</div> }\n </div>\n }}\n ></Column>\n )\n })}\n <Column\n key=\"action\"\n dataIndex=\"action\"\n title={locale.action}\n width={getWidth(24 - (sumBy(fields, 'props.span') % 24))}\n render={(text, row, index) => {\n if (renderAction) {\n return renderAction(row, index, onDelete, onAdd)\n }\n return (\n <span className=\"tntd-array-input-action\">\n {deleteTip ? (\n <Tooltip title={deleteTip}>\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n </Tooltip>\n ) : (\n <span onClick={() => onDelete(index)}>\n <Icon type=\"delete\" />\n </span>\n )}\n </span>\n )\n }}\n ></Column>\n </Table>\n </SortableContext>\n </DndContext>\n <Button type=\"dashed\" block className=\"mt10\" onClick={() => onAdd()}>\n <Icon type=\"plus\" />\n {addText}\n </Button>\n </div>\n )\n }\n}\n\nexport default function WarpArrayInput(props) {\n return (\n <LocaleReceiver componentName=\"ArrayInput\">\n {(locale) => {\n return <ArrayInput {...props} locale={locale} />\n }}\n </LocaleReceiver>\n )\n}\n"]}
@@ -1,28 +1,150 @@
1
+ @import '../style/themes/index';
2
+ @import '../style/mixins/index';
3
+ @import '../form/style/mixin.less';
4
+
5
+ @form-prefix-cls: ~'@{ant-prefix}-form';
6
+
1
7
  .tntd-array-input {
8
+ line-height: 1.5;
9
+
2
10
  &-item {
3
11
  margin-bottom: 10px;
4
12
  }
13
+
5
14
  .ant-col,
6
15
  .ant-table-row {
7
16
  .ant-select {
8
17
  width: 100%;
9
18
  }
10
19
  }
20
+
11
21
  .mr10 {
12
22
  margin-right: 10px;
13
23
  }
24
+
14
25
  .mt10 {
15
26
  margin-top: 10px;
16
27
  }
28
+
17
29
  &-action {
18
30
  line-height: @btn-height-base;
19
- > span {
31
+
32
+ >span {
20
33
  cursor: pointer;
21
34
  }
22
35
  }
36
+
23
37
  .drag-btn {
24
38
  border: none;
25
39
  background-color: transparent;
26
40
  cursor: move;
27
41
  }
28
42
  }
43
+
44
+ .has-error {
45
+ .tntd-array-input-hide-error {
46
+ .form-control-validation();
47
+
48
+ &.has-feedback .@{form-prefix-cls}-item-children-icon {
49
+ color: @text-color;
50
+ animation-name: diffZoomIn2 !important;
51
+ }
52
+
53
+ //select
54
+ .@{ant-prefix}-select {
55
+ &-selection {
56
+ border-color: @input-border-color;
57
+
58
+ &:hover {
59
+ border-color: @primary-color;
60
+ }
61
+ }
62
+
63
+ &-open .@{ant-prefix}-select-selection,
64
+ &-focused .@{ant-prefix}-select-selection {
65
+ .active();
66
+ }
67
+ }
68
+
69
+ .@{ant-prefix}-select.@{ant-prefix}-select-auto-complete {
70
+ .@{ant-prefix}-input:focus {
71
+ border-color: @primary-color;
72
+ }
73
+ }
74
+
75
+ .@{ant-prefix}-input-group-addon .@{ant-prefix}-select {
76
+ &-selection {
77
+ border-color: transparent;
78
+ box-shadow: none;
79
+ }
80
+ }
81
+
82
+ // arrow and icon
83
+ .@{ant-prefix}-calendar-picker-icon::after,
84
+ .@{ant-prefix}-time-picker-icon::after,
85
+ .@{ant-prefix}-picker-icon::after,
86
+ .@{ant-prefix}-select-arrow,
87
+ .@{ant-prefix}-cascader-picker-arrow {
88
+ color: @disabled-color;
89
+ }
90
+
91
+ //input-number, timepicker
92
+ .@{ant-prefix}-input-number,
93
+ .@{ant-prefix}-time-picker-input {
94
+ border-color: @input-border-color;
95
+
96
+ &-focused,
97
+ &:focus {
98
+ .active();
99
+ }
100
+
101
+ &:not([disabled]):hover {
102
+ border-color: @primary-color;
103
+ }
104
+ }
105
+
106
+ .@{ant-prefix}-mention-wrapper {
107
+ .@{ant-prefix}-mention-editor {
108
+
109
+ &,
110
+ &:not([disabled]):hover {
111
+ border-color: @primary-color;
112
+ }
113
+ }
114
+
115
+ &.@{ant-prefix}-mention-active:not([disabled]) .@{ant-prefix}-mention-editor,
116
+ .@{ant-prefix}-mention-editor:not([disabled]):focus {
117
+ .active();
118
+ }
119
+ }
120
+
121
+ .@{ant-prefix}-cascader-picker {
122
+ &:focus .@{ant-prefix}-cascader-input {
123
+ .active();
124
+ }
125
+
126
+ &:hover .@{ant-prefix}-cascader-input {
127
+ border-color: @input-border-color;
128
+ }
129
+ }
130
+
131
+ // transfer
132
+ .@{ant-prefix}-transfer {
133
+ &-list {
134
+ border-color: @input-border-color;
135
+
136
+ &-search:not([disabled]) {
137
+ border-color: @input-border-color;
138
+
139
+ &:hover {
140
+ .hover();
141
+ }
142
+
143
+ &:focus {
144
+ .active();
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateRules = validateRules;
8
+ var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
9
+ var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
10
+ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
+ function validateRules(rules, value) {
16
+ return new Promise( /*#__PURE__*/function () {
17
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
18
+ var i, rule, meg;
19
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
20
+ while (1) switch (_context.prev = _context.next) {
21
+ case 0:
22
+ i = 0;
23
+ case 1:
24
+ if (!(i < rules.length)) {
25
+ _context.next = 17;
26
+ break;
27
+ }
28
+ rule = rules[i];
29
+ if (!((0, _isObject2["default"])(rule) && rule.required)) {
30
+ _context.next = 8;
31
+ break;
32
+ }
33
+ if (!((0, _isNil2["default"])(value) || value === '')) {
34
+ _context.next = 6;
35
+ break;
36
+ }
37
+ return _context.abrupt("return", resolve(rule.message));
38
+ case 6:
39
+ _context.next = 14;
40
+ break;
41
+ case 8:
42
+ if (!(0, _isFunction2["default"])(rule)) {
43
+ _context.next = 14;
44
+ break;
45
+ }
46
+ _context.next = 11;
47
+ return rule(value);
48
+ case 11:
49
+ meg = _context.sent;
50
+ if (!meg) {
51
+ _context.next = 14;
52
+ break;
53
+ }
54
+ return _context.abrupt("return", resolve(meg));
55
+ case 14:
56
+ i++;
57
+ _context.next = 1;
58
+ break;
59
+ case 17:
60
+ resolve(false);
61
+ case 18:
62
+ case "end":
63
+ return _context.stop();
64
+ }
65
+ }, _callee);
66
+ }));
67
+ return function (_x) {
68
+ return _ref.apply(this, arguments);
69
+ };
70
+ }());
71
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/array-input/utils.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEpD,MAAM,UAAU,aAAa,CAAC,KAAK,EAAE,KAAK;IACxC,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YACrB,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACnC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,EAAE,EAAE;oBAChC,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;iBAC7B;aACF;iBAAM,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC3B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAA;gBAC7B,IAAI,GAAG,EAAE;oBACP,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;iBACpB;aACF;SACF;QACD,OAAO,CAAC,KAAK,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { isFunction, isNil, isObject } from 'lodash'\n\nexport function validateRules(rules, value) {\n return new Promise(async (resolve) => {\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i]\n if (isObject(rule) && rule.required) {\n if (isNil(value) || value === '') {\n return resolve(rule.message)\n }\n } else if (isFunction(rule)) {\n const meg = await rule(value)\n if (meg) {\n return resolve(meg)\n }\n }\n }\n resolve(false)\n })\n}\n"]}
@@ -11,6 +11,7 @@ var _popover2 = _interopRequireDefault(require("../popover"));
11
11
  var _tooltip = _interopRequireDefault(require("../tooltip"));
12
12
  var _CopySVG = _interopRequireDefault(require("./Svg/CopySVG"));
13
13
  var _TickSVG = _interopRequireDefault(require("./Svg/TickSVG"));
14
+ var _useScrollLock = _interopRequireDefault(require("../_util/hooks/useScrollLock"));
14
15
  require("./index.less");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -57,7 +58,8 @@ var _default = exports["default"] = function _default(props) {
57
58
  prefix = props.prefix,
58
59
  suffix = props.suffix,
59
60
  _props$needRefresh = props.needRefresh,
60
- needRefresh = _props$needRefresh === void 0 ? true : _props$needRefresh;
61
+ needRefresh = _props$needRefresh === void 0 ? true : _props$needRefresh,
62
+ enableScrollObserver = props.enableScrollObserver;
61
63
  var _useState = (0, _react.useState)(1),
62
64
  _useState2 = _slicedToArray(_useState, 2),
63
65
  renderId = _useState2[0],
@@ -82,6 +84,14 @@ var _default = exports["default"] = function _default(props) {
82
84
  lineHeight = _useState10[0],
83
85
  setLineHeight = _useState10[1];
84
86
  var elementRef = (0, _react.useRef)();
87
+ var isScrolling = (0, _useScrollLock["default"])({
88
+ enableScrollObserver: enableScrollObserver
89
+ });
90
+ (0, _react.useEffect)(function () {
91
+ if (isScrolling) {
92
+ setTipVisible(false);
93
+ }
94
+ }, [isScrolling]);
85
95
  var computeElement = function computeElement() {
86
96
  elementRef.current && isEllipsisActive(elementRef.current) ? setFlag(true) : (setFlag(false), setTipVisible(false));
87
97
  if (elementRef.current) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ellipsis/index.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3E,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,cAAc,CAAA;AAErB,MAAM,SAAS,GAAG,CAAC,CAAA,CAAC,2CAA2C;AAE/D,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE;;IAC7B,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,EAAE;QACxE,IAAI,QAAQ,GAAG,oBAAoB,CAAA;QACnC,IAAI,CAAC,CAAA,MAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,0CAA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ACL,CACJ,CAAA;AACH,CAAC,CAAA","sourcesContent":["/*\n * @Author: 梁洪刚\n * @CreatDate: 2021-03-31 13:57:32\n * @Describe: 省略号组件\n */\n\nimport copy from 'copy-to-clipboard'\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport Popover from '../popover'\nimport Tooltip from '../tooltip'\n\nimport CopySVG from './Svg/CopySVG'\nimport TickSVG from './Svg/TickSVG'\nimport './index.less'\n\nconst tolerance = 0 // In px. Depends on the font you are using\n\nconst isEllipsisActive = (e) => {\n if (e.offsetWidth === e.scrollWidth && e.offsetHeight === e.scrollHeight) {\n let styleStr = 'overflow:visible; '\n if (!e?.parentNode?.getAttribute('style')?.includes('width')) {\n styleStr += 'max-width:100%;'\n }\n e.parentNode.setAttribute('style', styleStr)\n e.setAttribute(\"style\",'overflow:inherit');\n }else {\n e.setAttribute(\"style\", \"\")\n }\n return e.offsetWidth + tolerance < e.scrollWidth || e.offsetHeight < e.scrollHeight\n}\n\nexport default (props) => {\n let {\n _popover = props.Popover, // `Popover` or `Tooltip` ?\n title, // in most cases for `Tooltip`\n content, // in most cases for `Popover`\n className,\n style,\n widthLimit, // width trigger value\n _lines = props.lines !== 1 && props.lines, // number or lines, default 1 line;\n children, // children Node\n emptyText, // default: null\n _copyable = props.copyable, // copy function\n prefix, // 前缀dom\n suffix, // 后缀dom\n needRefresh = true // select.options的情况下不要刷新\n } = props\n\n const [renderId, setRenderId] = useState(1);\n // allow visible or not state\n const [flag, setFlag] = useState(true)\n // visible[Tooltip/Popover] state\n const [tipVisible, setTipVisible] = useState(false)\n // copy animation state\n const [hasCopy, setHasCopy] = useState(false)\n const [lineHeight, setLineHeight] = useState()\n\n const elementRef = useRef()\n\n const computeElement = ()=>{\n elementRef.current && isEllipsisActive(elementRef.current)\n ? setFlag(true)\n : (setFlag(false), setTipVisible(false))\n\n if (elementRef.current) {\n setLineHeight(getComputedStyle(elementRef.current, null).getPropertyValue('line-height'))\n }\n }\n\n useLayoutEffect(()=>{\n if (needRefresh) {\n setRenderId(id => id + 1);\n }else {\n if(renderId < 2) {\n setRenderId(id => id + 1);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [title, needRefresh, content, children])\n\n useEffect(() => {\n computeElement()\n },[renderId])\n\n useEffect(()=>{\n window.addEventListener(\"resize\",computeElement)\n return ()=>{\n window.removeEventListener('resize',computeElement)\n }\n },[])\n\n // original Node\n const inner = typeof children === 'string' ? children : _popover ? content : title\n\n // for className\n const getClassName = () => {\n return `overflow min-width-0 ${_lines ? 'ellipsis-wrap' : 'ellipsis-nowrap'} ${className || ''}`\n }\n\n // Tooltip.trigger(default 'hover') ==trigger==> onVisibleChange(visible)\n const handleVisibleChange = (visible) => {\n // const { onVisibleChange } = props;\n // onVisibleChange(visible);\n flag && setTipVisible(visible)\n }\n\n // onClick Copy Button\n const handleCopy = (innerText) => {\n copy(innerText)\n setHasCopy(!hasCopy)\n setTimeout(() => {\n setHasCopy(false)\n }, 1000)\n }\n\n const renderNode = () => {\n const popoverNode = (\n <Popover\n {...props}\n content={content || children}\n visible={tipVisible}\n onVisibleChange={(visible) => handleVisibleChange(visible)}\n >\n <div className={className} style={{ WebkitLineClamp: _lines }} ref={elementRef}>\n {children || content}\n </div>\n </Popover>\n )\n\n const tooltipNode = (\n <Tooltip\n {...props}\n title={title || children}\n visible={tipVisible}\n onVisibleChange={(visible) => handleVisibleChange(visible)}\n >\n <div className={className} style={{ WebkitLineClamp: _lines }} ref={elementRef}>\n {children || title}\n </div>\n </Tooltip>\n )\n\n return _popover ? popoverNode : tooltipNode\n }\n\n return (\n <>\n <div\n className=\"tntd-ellipsis\"\n style={{\n ...style,\n maxWidth: widthLimit,\n }}\n >\n {/* prefix */}\n {prefix && prefix}\n {/* content */}\n <div className={getClassName()} key={renderId}>{(inner||inner===0) ? renderNode() : emptyText}</div>\n {/* suffix */}\n {!!suffix && suffix}\n {/* copyable button */}\n {(inner||inner===0) && _copyable && lineHeight && (\n <div\n className=\"svg-button\"\n style={{\n height: lineHeight,\n }}\n onClick={() => handleCopy(elementRef.current.innerText)}\n >\n {!hasCopy ? (\n <CopySVG\n style={{\n height: lineHeight,\n }}\n />\n ) : (\n <TickSVG\n style={{\n height: lineHeight,\n }}\n />\n )}\n </div>\n )}\n </div>\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ellipsis/index.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,mBAAmB,CAAA;AACpC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3E,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,aAAa,MAAM,8BAA8B,CAAA;AACxD,OAAO,cAAc,CAAA;AAErB,MAAM,SAAS,GAAG,CAAC,CAAA,CAAC,2CAA2C;AAE/D,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE;;IAC7B,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY,EAAE;QACxE,IAAI,QAAQ,GAAG,oBAAoB,CAAA;QACnC,IAAI,CAAC,CAAA,MAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,0CAAE,YAAY,CAAC,OAAO,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAA,EAAE;YAC5D,QAAQ,IAAI,iBAAiB,CAAA;SAC9B;QACD,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC,CAAC,YAAY,CAAC,OAAO,EAAC,kBAAkB,CAAC,CAAC;KAC5C;SAAK;QACJ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":["/*\n * @Author: 梁洪刚\n * @CreatDate: 2021-03-31 13:57:32\n * @Describe: 省略号组件\n */\n\nimport copy from 'copy-to-clipboard'\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport Popover from '../popover'\nimport Tooltip from '../tooltip'\n\nimport CopySVG from './Svg/CopySVG'\nimport TickSVG from './Svg/TickSVG'\nimport useScrollLock from '../_util/hooks/useScrollLock'\nimport './index.less'\n\nconst tolerance = 0 // In px. Depends on the font you are using\n\nconst isEllipsisActive = (e) => {\n if (e.offsetWidth === e.scrollWidth && e.offsetHeight === e.scrollHeight) {\n let styleStr = 'overflow:visible; '\n if (!e?.parentNode?.getAttribute('style')?.includes('width')) {\n styleStr += 'max-width:100%;'\n }\n e.parentNode.setAttribute('style', styleStr)\n e.setAttribute(\"style\",'overflow:inherit');\n }else {\n e.setAttribute(\"style\", \"\")\n }\n return e.offsetWidth + tolerance < e.scrollWidth || e.offsetHeight < e.scrollHeight\n}\n\nexport default (props) => {\n let {\n _popover = props.Popover, // `Popover` or `Tooltip` ?\n title, // in most cases for `Tooltip`\n content, // in most cases for `Popover`\n className,\n style,\n widthLimit, // width trigger value\n _lines = props.lines !== 1 && props.lines, // number or lines, default 1 line;\n children, // children Node\n emptyText, // default: null\n _copyable = props.copyable, // copy function\n prefix, // 前缀dom\n suffix, // 后缀dom\n needRefresh = true, \n enableScrollObserver// select.options的情况下不要刷新\n } = props\n\n const [renderId, setRenderId] = useState(1);\n // allow visible or not state\n const [flag, setFlag] = useState(true)\n // visible[Tooltip/Popover] state\n const [tipVisible, setTipVisible] = useState(false)\n // copy animation state\n const [hasCopy, setHasCopy] = useState(false)\n const [lineHeight, setLineHeight] = useState()\n\n const elementRef = useRef()\n\n const isScrolling = useScrollLock({enableScrollObserver});\n useEffect(()=>{\n if(isScrolling) {\n setTipVisible(false)\n }\n },[isScrolling])\n \n const computeElement = ()=>{\n elementRef.current && isEllipsisActive(elementRef.current)\n ? setFlag(true)\n : (setFlag(false), setTipVisible(false))\n\n if (elementRef.current) {\n setLineHeight(getComputedStyle(elementRef.current, null).getPropertyValue('line-height'))\n }\n }\n\n useLayoutEffect(()=>{\n if (needRefresh) {\n setRenderId(id => id + 1);\n }else {\n if(renderId < 2) {\n setRenderId(id => id + 1);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [title, needRefresh, content, children])\n\n useEffect(() => {\n computeElement()\n },[renderId])\n\n useEffect(()=>{\n window.addEventListener(\"resize\",computeElement)\n return ()=>{\n window.removeEventListener('resize',computeElement)\n }\n },[])\n\n // original Node\n const inner = typeof children === 'string' ? children : _popover ? content : title\n\n // for className\n const getClassName = () => {\n return `overflow min-width-0 ${_lines ? 'ellipsis-wrap' : 'ellipsis-nowrap'} ${className || ''}`\n }\n\n // Tooltip.trigger(default 'hover') ==trigger==> onVisibleChange(visible)\n const handleVisibleChange = (visible) => {\n // const { onVisibleChange } = props;\n // onVisibleChange(visible);\n flag && setTipVisible(visible)\n }\n\n // onClick Copy Button\n const handleCopy = (innerText) => {\n copy(innerText)\n setHasCopy(!hasCopy)\n setTimeout(() => {\n setHasCopy(false)\n }, 1000)\n }\n\n const renderNode = () => {\n const popoverNode = (\n <Popover\n {...props}\n content={content || children}\n visible={tipVisible}\n onVisibleChange={(visible) => handleVisibleChange(visible)}\n >\n <div className={className} style={{ WebkitLineClamp: _lines }} ref={elementRef}>\n {children || content}\n </div>\n </Popover>\n )\n\n const tooltipNode = (\n <Tooltip\n {...props}\n title={title || children}\n visible={tipVisible}\n onVisibleChange={(visible) => handleVisibleChange(visible)}\n >\n <div className={className} style={{ WebkitLineClamp: _lines }} ref={elementRef}>\n {children || title}\n </div>\n </Tooltip>\n )\n\n return _popover ? popoverNode : tooltipNode\n }\n\n return (\n <>\n <div\n className=\"tntd-ellipsis\"\n style={{\n ...style,\n maxWidth: widthLimit,\n }}\n >\n {/* prefix */}\n {prefix && prefix}\n {/* content */}\n <div className={getClassName()} key={renderId}>{(inner||inner===0) ? renderNode() : emptyText}</div>\n {/* suffix */}\n {!!suffix && suffix}\n {/* copyable button */}\n {(inner||inner===0) && _copyable && lineHeight && (\n <div\n className=\"svg-button\"\n style={{\n height: lineHeight,\n }}\n onClick={() => handleCopy(elementRef.current.innerText)}\n >\n {!hasCopy ? (\n <CopySVG\n style={{\n height: lineHeight,\n }}\n />\n ) : (\n <TickSVG\n style={{\n height: lineHeight,\n }}\n />\n )}\n </div>\n )}\n </div>\n </>\n )\n}\n"]}
@@ -10,8 +10,8 @@
10
10
  position: absolute;
11
11
  top: 45%;
12
12
  left: 50%;
13
- width: 70px;
14
- height: 70px;
13
+ width: 51px;
14
+ height: 64px;
15
15
  background-size: 100% 100%;
16
16
  transform: translate(-50%, -50%);
17
17
  background-repeat: no-repeat;
@@ -21,7 +21,7 @@
21
21
  span {
22
22
  position: absolute;
23
23
  left: 50%;
24
- bottom: 0;
24
+ bottom: -17px;
25
25
  transform: translate(-50%, 0);
26
26
  width: 100%;
27
27
  font-size: 12px;
@@ -35,4 +35,4 @@
35
35
  color: #fff;
36
36
  }
37
37
  }
38
- }
38
+ }
Binary file
@@ -1338,7 +1338,7 @@
1338
1338
  .tntd-rc-select:not(.tntd-rc-select-customize-input) .tntd-rc-select-selector {
1339
1339
  position: relative;
1340
1340
  background-color: #fff;
1341
- border: 1px solid @border-color;
1341
+ border: 1px solid #c9d2dd;
1342
1342
  border-radius: 2px;
1343
1343
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
1344
1344
  }
@@ -1446,7 +1446,7 @@
1446
1446
  align-items: center;
1447
1447
  height: 12px;
1448
1448
  margin-top: -6px;
1449
- color: rgba(0, 0, 0, 0.25);
1449
+ color: rgba(23, 35, 61, 0.3);
1450
1450
  font-size: 12px;
1451
1451
  line-height: 1;
1452
1452
  text-align: center;
@@ -1767,3 +1767,21 @@
1767
1767
  .tntd-rc-select:not(.tntd-rc-select-customize-input) .tntd-rc-select-selector {
1768
1768
  border-radius: @border-radius-base;
1769
1769
  }
1770
+
1771
+ .has-error{
1772
+ .tntd-rc-select:not(.tntd-rc-select-customize-input) .tntd-rc-select-selector {
1773
+ border-color: @red-5;
1774
+ box-shadow: none ;
1775
+ }
1776
+
1777
+ .tntd-rc-select-focused:not(.tntd-rc-select-disabled).tntd-rc-select:not(
1778
+ .tntd-rc-select-customize-input
1779
+ ) .tntd-rc-select-selector {
1780
+ border-color: @red-5;
1781
+ box-shadow: none;
1782
+ }
1783
+
1784
+ .tntd-rc-select-arrow{
1785
+ color: @red-5;
1786
+ }
1787
+ }