@qsxy/element-plus-react 1.0.0-next.13 → 1.0.0-next.15

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.
@@ -1,11 +1,4 @@
1
1
  import { FC } from 'react';
2
- import SkeletonGraph from './PlaceholderGraph';
3
- import PlaceholderGrid from './PlaceholderGrid';
4
- import PlaceholderParagraph, { PlaceholderParagraphProps } from './PlaceholderParagraph';
5
- export interface Skeleton extends FC<PlaceholderParagraphProps> {
6
- Paragraph: typeof PlaceholderParagraph;
7
- Grid: typeof PlaceholderGrid;
8
- Graph: typeof SkeletonGraph;
9
- }
10
- declare const Skeleton: Skeleton;
2
+ import { SkeletonProps } from './typings';
3
+ declare const Skeleton: FC<SkeletonProps>;
11
4
  export default Skeleton;
@@ -1,8 +1,95 @@
1
- import SkeletonGraph from "./PlaceholderGraph";
2
- import PlaceholderGrid from "./PlaceholderGrid";
3
- import PlaceholderParagraph from "./PlaceholderParagraph";
4
- var Skeleton = PlaceholderParagraph;
5
- Skeleton.Paragraph = PlaceholderParagraph;
6
- Skeleton.Grid = PlaceholderGrid;
7
- Skeleton.Graph = SkeletonGraph;
1
+ var _templateObject, _templateObject2;
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
9
+ import classNames from 'classnames';
10
+ import debounce from 'lodash/debounce';
11
+ import React, { Children, useEffect, useRef } from 'react';
12
+ import { mergeDefaultProps } from "../Util";
13
+ import { useClassNames, useControlled } from "../hooks";
14
+ import { SkeletonContext } from "./SkeletonContext";
15
+ import SkeletonItem from "./SkeletonItem";
16
+ var SkeletonCore = function SkeletonCore(props) {
17
+ var animated = props.animated,
18
+ _props$rows = props.rows,
19
+ rows = _props$rows === void 0 ? 4 : _props$rows,
20
+ variant = props.variant,
21
+ _props$rowHeight = props.rowHeight,
22
+ rowHeight = _props$rowHeight === void 0 ? 16 : _props$rowHeight,
23
+ _props$rowMargin = props.rowMargin,
24
+ rowMargin = _props$rowMargin === void 0 ? 16 : _props$rowMargin,
25
+ _props$classPrefix = props.classPrefix,
26
+ classPrefix = _props$classPrefix === void 0 ? 'skeleton' : _props$classPrefix,
27
+ formatter = props.formatter,
28
+ className = props.className,
29
+ style = props.style;
30
+ var _useClassNames = useClassNames(classPrefix),
31
+ b = _useClassNames.b,
32
+ wb = _useClassNames.wb;
33
+ return /*#__PURE__*/React.createElement(SkeletonContext.Provider, {
34
+ value: {
35
+ rowHeight: rowHeight,
36
+ rowMargin: rowMargin,
37
+ rows: rows
38
+ }
39
+ }, /*#__PURE__*/React.createElement("div", {
40
+ className: classNames(className, wb('paragraph', {
41
+ active: animated
42
+ })),
43
+ style: style
44
+ }, variant && /*#__PURE__*/React.createElement("div", {
45
+ className: b('paragraph-graph', "paragraph-graph-".concat(variant))
46
+ }, variant === 'image' ? /*#__PURE__*/React.createElement("svg", {
47
+ xmlns: "http://www.w3.org/2000/svg",
48
+ viewBox: "0 0 1024 1024"
49
+ }, /*#__PURE__*/React.createElement("path", {
50
+ fill: "currentColor",
51
+ d: "M96 896a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h832a32 32 0 0 1 32 32v704a32 32 0 0 1-32 32zm315.52-228.48-68.928-68.928a32 32 0 0 0-45.248 0L128 768.064h778.688l-242.112-290.56a32 32 0 0 0-49.216 0L458.752 665.408a32 32 0 0 1-47.232 2.112M256 384a96 96 0 1 0 192.064-.064A96 96 0 0 0 256 384"
52
+ })) : null, /*#__PURE__*/React.createElement("span", {
53
+ className: b(_templateObject || (_templateObject = _taggedTemplateLiteral(["paragraph-graph-inner"])))
54
+ })), /*#__PURE__*/React.createElement("div", {
55
+ className: b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["paragraph-rows"])))
56
+ }, Children.count(formatter) === 0 ? new Array(rows).fill(0).map(function (_, index) {
57
+ return /*#__PURE__*/React.createElement(SkeletonItem, {
58
+ key: index,
59
+ isFirst: index === 0
60
+ });
61
+ }) : formatter)));
62
+ };
63
+ var Skeleton = function Skeleton(props) {
64
+ var _throttle$leading, _throttle$trailing;
65
+ props = mergeDefaultProps({
66
+ visible: true
67
+ }, props);
68
+ var _props = props,
69
+ defaultVisible = _props.defaultVisible,
70
+ throttle = _props.throttle,
71
+ children = _props.children;
72
+ var initLoad = useRef(false);
73
+ var _useControlled = useControlled(undefined, defaultVisible !== null && defaultVisible !== void 0 ? defaultVisible : props.visible),
74
+ _useControlled2 = _slicedToArray(_useControlled, 2),
75
+ visible = _useControlled2[0],
76
+ setVisible = _useControlled2[1];
77
+ var display = debounce(function () {
78
+ return setVisible(true);
79
+ }, typeof throttle === 'number' ? throttle : (_throttle$leading = throttle === null || throttle === void 0 ? void 0 : throttle.leading) !== null && _throttle$leading !== void 0 ? _throttle$leading : 0);
80
+ var hide = debounce(function () {
81
+ return setVisible(false);
82
+ }, typeof throttle !== 'number' ? (_throttle$trailing = throttle === null || throttle === void 0 ? void 0 : throttle.trailing) !== null && _throttle$trailing !== void 0 ? _throttle$trailing : 0 : 0);
83
+ useEffect(function () {
84
+ if (defaultVisible === true && !initLoad.current) {
85
+ setVisible(true);
86
+ } else {
87
+ props.visible ? display() : hide();
88
+ }
89
+ initLoad.current = true;
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, [props.visible]);
92
+ return visible ? /*#__PURE__*/React.createElement(SkeletonCore, props) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
93
+ };
94
+ Skeleton.displayName = 'ElSkeleton';
8
95
  export default Skeleton;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export declare const SkeletonContext: import("react").Context<{
3
+ /** 骨架屏段落数量 */
4
+ rows?: number;
5
+ /** 是否使用动画 */
6
+ animated?: boolean;
7
+ rowHeight?: number;
8
+ rowMargin?: number;
9
+ }>;
10
+ export declare const useSkeletonContext: () => {
11
+ /** 骨架屏段落数量 */
12
+ rows?: number;
13
+ /** 是否使用动画 */
14
+ animated?: boolean;
15
+ rowHeight?: number;
16
+ rowMargin?: number;
17
+ };
@@ -0,0 +1,5 @@
1
+ import { createContext, useContext } from 'react';
2
+ export var SkeletonContext = /*#__PURE__*/createContext({});
3
+ export var useSkeletonContext = function useSkeletonContext() {
4
+ return useContext(SkeletonContext);
5
+ };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { SkeletonItemProps } from './typings';
3
+ declare const SkeletonItem: (props: SkeletonItemProps) => React.JSX.Element;
4
+ export default SkeletonItem;
@@ -0,0 +1,47 @@
1
+ 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); }
2
+ var _templateObject, _templateObject2;
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
9
+ import classNames from 'classnames';
10
+ import React from 'react';
11
+ import { useClassNames } from "../hooks";
12
+ import { useSkeletonContext } from "./SkeletonContext";
13
+ var SkeletonItem = function SkeletonItem(props) {
14
+ var _props$rowHeight, _props$rowMargin, _props$rowMargin2;
15
+ var isFirst = props.isFirst,
16
+ variant = props.variant,
17
+ className = props.className,
18
+ style = props.style,
19
+ _props$classPrefix = props.classPrefix,
20
+ classPrefix = _props$classPrefix === void 0 ? 'skeleton' : _props$classPrefix;
21
+ var _useClassNames = useClassNames(classPrefix),
22
+ b = _useClassNames.b,
23
+ e = _useClassNames.e;
24
+ var _useSkeletonContext = useSkeletonContext(),
25
+ rowHeight = _useSkeletonContext.rowHeight,
26
+ rowMargin = _useSkeletonContext.rowMargin;
27
+ return variant ? /*#__PURE__*/React.createElement("div", {
28
+ className: classNames(b('paragraph-graph', "paragraph-graph-".concat(variant)), className),
29
+ style: style
30
+ }, variant === 'image' ? /*#__PURE__*/React.createElement("svg", {
31
+ xmlns: "http://www.w3.org/2000/svg",
32
+ viewBox: "0 0 1024 1024"
33
+ }, /*#__PURE__*/React.createElement("path", {
34
+ fill: "currentColor",
35
+ d: "M96 896a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h832a32 32 0 0 1 32 32v704a32 32 0 0 1-32 32zm315.52-228.48-68.928-68.928a32 32 0 0 0-45.248 0L128 768.064h778.688l-242.112-290.56a32 32 0 0 0-49.216 0L458.752 665.408a32 32 0 0 1-47.232 2.112M256 384a96 96 0 1 0 192.064-.064A96 96 0 0 0 256 384"
36
+ })) : null, /*#__PURE__*/React.createElement("span", {
37
+ className: b(_templateObject || (_templateObject = _taggedTemplateLiteral(["paragraph-graph-inner"])))
38
+ })) : /*#__PURE__*/React.createElement("div", {
39
+ className: classNames(e(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["item"]))), className),
40
+ style: _objectSpread({
41
+ width: "".concat(Math.random() * 75 + 25, "%"),
42
+ height: (_props$rowHeight = props.rowHeight) !== null && _props$rowHeight !== void 0 ? _props$rowHeight : rowHeight,
43
+ marginTop: isFirst ? Number((_props$rowMargin = props.rowMargin) !== null && _props$rowMargin !== void 0 ? _props$rowMargin : rowMargin) / 2 : (_props$rowMargin2 = props.rowMargin) !== null && _props$rowMargin2 !== void 0 ? _props$rowMargin2 : rowMargin
44
+ }, style)
45
+ });
46
+ };
47
+ export default SkeletonItem;
@@ -1,4 +1,3 @@
1
- export type { SkeletonGraphProps } from './PlaceholderGraph';
2
- export type { PlaceholderGridProps } from './PlaceholderGrid';
3
- export type { PlaceholderParagraphProps } from './PlaceholderParagraph';
4
1
  export { default as Skeleton } from './Skeleton';
2
+ export { default as SkeletonItem } from './SkeletonItem';
3
+ export type { SkeletonItemProps, SkeletonProps } from './typings';
@@ -1 +1,2 @@
1
- export { default as Skeleton } from "./Skeleton";
1
+ export { default as Skeleton } from "./Skeleton";
2
+ export { default as SkeletonItem } from "./SkeletonItem";
@@ -0,0 +1,29 @@
1
+ import { ReactElement } from 'react';
2
+ import { BaseProps, NativeProps } from '../types/common';
3
+ export interface SkeletonProps extends BaseProps, NativeProps {
4
+ /** 是否显示模态框(可控) */
5
+ visible?: boolean;
6
+ /** 默认是否显示模态框 */
7
+ defaultVisible?: boolean;
8
+ /** 骨架屏段落数量 */
9
+ rows?: number;
10
+ /** 是否使用动画 */
11
+ animated?: boolean;
12
+ rowHeight?: number;
13
+ rowMargin?: number;
14
+ /** 当前渲染 skeleton 类型 */
15
+ variant?: 'image' | 'circle' | 'rect';
16
+ /** 渲染延迟(以毫秒为单位) 数字代表延迟显示, 也可以设置为延迟隐藏, 例如 { leading: 500, trailing: 500 } 当需要控制初始加载值时,您可以设置 { initVal: true } */
17
+ throttle?: number | {
18
+ leading?: number;
19
+ trailing?: number;
20
+ };
21
+ formatter?: ReactElement;
22
+ }
23
+ export interface SkeletonItemProps extends BaseProps, NativeProps {
24
+ /** 当前渲染 skeleton 类型 */
25
+ variant?: 'image' | 'circle' | 'rect';
26
+ isFirst?: boolean;
27
+ rowHeight?: number;
28
+ rowMargin?: number;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -12,6 +12,6 @@ export declare const useHandlers: (props: Omit<UploadProps, 'fileList'> & {
12
12
  handleProgress: (evt: import("./typings").UploadProgressEvent, rawFile: UploadRawFile) => void;
13
13
  handleStart: (rawFile: UploadRawFile) => void;
14
14
  handleSuccess: (response: any, rawFile: UploadRawFile) => unknown;
15
- handleRemove: (file: UploadRawFile | UploadFile) => void;
15
+ handleRemove: (file: UploadFile | UploadRawFile) => void;
16
16
  submit: () => void;
17
17
  };