@lemon-fe/components 0.1.123 → 0.1.125

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.
@@ -2,5 +2,6 @@
2
2
  declare const BaseTableContext: import("react").Context<{
3
3
  scrollY?: string | number | undefined;
4
4
  rowHeight?: number | undefined;
5
+ antPrefixCls: string;
5
6
  }>;
6
7
  export default BaseTableContext;
@@ -1,6 +1,7 @@
1
1
  import { createContext } from 'react';
2
2
  var BaseTableContext = /*#__PURE__*/createContext({
3
3
  scrollY: 0,
4
- rowHeight: 37
4
+ rowHeight: 37,
5
+ antPrefixCls: 'ant-table'
5
6
  });
6
7
  export default BaseTableContext;
@@ -4,8 +4,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  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; }
5
5
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import React, { useState, useRef, useEffect } from 'react';
7
+ import React, { useState, useRef, useEffect, useContext } from 'react';
8
8
  import { Resizable } from 'react-resizable';
9
+ import BaseTableContext from './BaseTableContext';
9
10
  export default function ResizeHeaderCell(props) {
10
11
  var children = props.children,
11
12
  prefixCls = props.prefixCls,
@@ -22,6 +23,8 @@ export default function ResizeHeaderCell(props) {
22
23
  _useState4 = _slicedToArray(_useState3, 2),
23
24
  offset = _useState4[0],
24
25
  setOffset = _useState4[1];
26
+ var _useContext = useContext(BaseTableContext),
27
+ antPrefixCls = _useContext.antPrefixCls;
25
28
  useEffect(function () {
26
29
  setSize(width);
27
30
  }, [width]);
@@ -29,7 +32,7 @@ export default function ResizeHeaderCell(props) {
29
32
  if (fullTableRef.current === null) {
30
33
  return null;
31
34
  }
32
- return fullTableRef.current.querySelector('.ant-table');
35
+ return fullTableRef.current.querySelector(".".concat(antPrefixCls));
33
36
  };
34
37
  var handleResizeStart = function handleResizeStart() {
35
38
  var table = getTable();
@@ -22,7 +22,8 @@ export default function VirtualList(props) {
22
22
  var _useContext = useContext(BaseTableContext),
23
23
  scrollY = _useContext.scrollY,
24
24
  _useContext$rowHeight = _useContext.rowHeight,
25
- rowHeight = _useContext$rowHeight === void 0 ? 37 : _useContext$rowHeight;
25
+ rowHeight = _useContext$rowHeight === void 0 ? 37 : _useContext$rowHeight,
26
+ antPrefixCls = _useContext.antPrefixCls;
26
27
  var _useState = useState(null),
27
28
  _useState2 = _slicedToArray(_useState, 2),
28
29
  range = _useState2[0],
@@ -36,7 +37,7 @@ export default function VirtualList(props) {
36
37
  if (body === null) {
37
38
  return null;
38
39
  }
39
- var scroller = body.closest('.ant-table-body');
40
+ var scroller = body.closest(".".concat(antPrefixCls, "-body"));
40
41
  if (scroller === null) {
41
42
  return null;
42
43
  }
@@ -99,7 +100,7 @@ export default function VirtualList(props) {
99
100
  if (ref.current === null) {
100
101
  return;
101
102
  }
102
- var tableBody = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest('.ant-table-body');
103
+ var tableBody = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest(".".concat(antPrefixCls, "-body"));
103
104
  if (tableBody === null) {
104
105
  return;
105
106
  }
@@ -17,8 +17,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
17
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
  /// <reference path="../../typings.d.ts" />
20
- import React, { useMemo, useState, useEffect, useRef, forwardRef } from 'react';
21
- import { Table as AntdTable } from 'antd';
20
+ import React, { useMemo, useState, useEffect, useRef, forwardRef, useContext } from 'react';
21
+ import { Table as AntdTable, ConfigProvider } from 'antd';
22
22
  import classNames from 'classnames';
23
23
  import { get } from 'lodash';
24
24
  import ResizeObserver from 'rc-resize-observer';
@@ -52,13 +52,15 @@ function Th(props) {
52
52
  children = props.children,
53
53
  className = props.className,
54
54
  restProps = _objectWithoutProperties(props, _excluded);
55
- var reg = /\bant-table-cell-ellipsis\b/;
55
+ var _useContext = useContext(BaseTableContext),
56
+ antPrefixCls = _useContext.antPrefixCls;
57
+ var reg = new RegExp("\\b".concat(antPrefixCls, "-cell-ellipsis\\b"));
56
58
  var content = children;
57
59
  var mClassName = className;
58
60
  if (mClassName && reg.test(mClassName)) {
59
61
  mClassName = mClassName.replace(reg, '');
60
62
  content = /*#__PURE__*/React.createElement("div", {
61
- className: "ant-table-cell-ellipsis"
63
+ className: "".concat(antPrefixCls, "-cell-ellipsis")
62
64
  }, content);
63
65
  }
64
66
  if (!width || !onWidthChange) {
@@ -99,6 +101,7 @@ function BaseTable(props, _ref) {
99
101
  className = props.className,
100
102
  localeProp = props.locale,
101
103
  restProps = _objectWithoutProperties(props, _excluded2);
104
+ var antPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls('table');
102
105
  var fullTableRef = useRef(null);
103
106
  var _useState = useState(new Map()),
104
107
  _useState2 = _slicedToArray(_useState, 2),
@@ -116,8 +119,8 @@ function BaseTable(props, _ref) {
116
119
  if (wrapper === null) {
117
120
  return null;
118
121
  }
119
- var table = wrapper.querySelector('.ant-table');
120
- var tableBody = wrapper.querySelector('.ant-table-body');
122
+ var table = wrapper.querySelector(".".concat(antPrefixCls));
123
+ var tableBody = wrapper.querySelector(".".concat(antPrefixCls, "-body"));
121
124
  if (tableBody === null || table === null) {
122
125
  return null;
123
126
  }
@@ -170,7 +173,7 @@ function BaseTable(props, _ref) {
170
173
  }, [scrollYProp]);
171
174
  useEffect(function () {
172
175
  if (scrollY !== undefined && fullTableRef.current !== null) {
173
- var body = fullTableRef.current.querySelector('.ant-table-body');
176
+ var body = fullTableRef.current.querySelector(".".concat(antPrefixCls, "-body"));
174
177
  if (body !== null) {
175
178
  var dataType = _typeof(scrollY);
176
179
  switch (dataType) {
@@ -327,9 +330,10 @@ function BaseTable(props, _ref) {
327
330
  var ctx = useMemo(function () {
328
331
  return {
329
332
  scrollY: scrollY,
330
- rowHeight: rowHeight
333
+ rowHeight: rowHeight,
334
+ antPrefixCls: antPrefixCls
331
335
  };
332
- }, [scrollY, rowHeight]);
336
+ }, [scrollY, rowHeight, antPrefixCls]);
333
337
  var tableNode = /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
334
338
  size: "small",
335
339
  ref: function ref(elm) {
@@ -1,13 +1,14 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- import React from 'react';
5
- import { message } from 'antd';
4
+ import React, { useContext } from 'react';
5
+ import { ConfigProvider, message } from 'antd';
6
6
  import classNames from 'classnames';
7
7
  import { get } from 'lodash';
8
8
  import { PREFIX_CLS } from '../constants';
9
9
  import Icons from '../Icons';
10
10
  export default function EditableCell(props) {
11
+ var _classNames;
11
12
  var focused = props.focused,
12
13
  onFocus = props.onFocus,
13
14
  children = props.children,
@@ -19,15 +20,12 @@ export default function EditableCell(props) {
19
20
  _props$noStyle = props.noStyle,
20
21
  noStyle = _props$noStyle === void 0 ? false : _props$noStyle;
21
22
  var disabled = get(children, 'props.disabled');
23
+ var inputPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls('input');
22
24
  var mainProps = {
23
25
  onFocus: onFocus,
24
26
  'data-up-down': disableUpDown ? '0' : '1',
25
27
  'data-left-right': disableLeftRight ? '0' : '1',
26
- className: noStyle ? "".concat(PREFIX_CLS, "-form-item-no-style") : classNames("".concat(PREFIX_CLS, "-form-item"), {
27
- 'ant-input': focused >= 1 && bordered,
28
- 'ant-input-focused': focused >= 2 && bordered,
29
- 'ant-input-disabled': disabled
30
- })
28
+ className: noStyle ? "".concat(PREFIX_CLS, "-form-item-no-style") : classNames("".concat(PREFIX_CLS, "-form-item"), (_classNames = {}, _defineProperty(_classNames, inputPrefixCls, focused >= 1 && bordered), _defineProperty(_classNames, "".concat(inputPrefixCls, "-focused"), focused >= 2 && bordered), _defineProperty(_classNames, "".concat(inputPrefixCls, "-disabled"), disabled), _classNames))
31
29
  };
32
30
  return /*#__PURE__*/React.createElement("div", _objectSpread({}, mainProps), children, errors !== undefined ? /*#__PURE__*/React.createElement("div", {
33
31
  className: "".concat(PREFIX_CLS, "-form-item-error"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.123",
3
+ "version": "0.1.125",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -39,5 +39,5 @@
39
39
  "react": "^17.0.2",
40
40
  "react-dom": "^17.0.2"
41
41
  },
42
- "gitHead": "610b264721af7c351cbc1b825920c969d2b74900"
42
+ "gitHead": "8191ec827b85a64f75a3665133ce76851823d279"
43
43
  }