neko-ui 1.0.40 → 1.0.41

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 (146) hide show
  1. package/README.md +3 -3
  2. package/es/avatar/index.d.ts +4 -4
  3. package/es/avatar/index.js +1 -71
  4. package/es/avatar/style.d.ts +4 -0
  5. package/es/avatar/style.js +71 -0
  6. package/es/avatar-group/index.d.ts +2 -2
  7. package/es/avatar-group/index.js +1 -21
  8. package/es/avatar-group/style.d.ts +4 -0
  9. package/es/avatar-group/style.js +21 -0
  10. package/es/back-top/index.d.ts +2 -2
  11. package/es/back-top/index.js +1 -73
  12. package/es/back-top/style.d.ts +4 -0
  13. package/es/back-top/style.js +73 -0
  14. package/es/button/index.d.ts +5 -4
  15. package/es/button/index.js +1 -212
  16. package/es/button/style.d.ts +3 -0
  17. package/es/button/style.js +212 -0
  18. package/es/capture-screen/index.d.ts +3 -3
  19. package/es/capture-screen/index.js +1 -63
  20. package/es/capture-screen/style.d.ts +9 -0
  21. package/es/capture-screen/style.js +63 -0
  22. package/es/carousel/index.js +1 -153
  23. package/es/carousel/style.d.ts +11 -0
  24. package/es/carousel/style.js +153 -0
  25. package/es/code-block/index.d.ts +3 -3
  26. package/es/code-block/index.js +1 -1
  27. package/es/color-palette/index.d.ts +3 -3
  28. package/es/color-palette/index.js +1 -227
  29. package/es/color-palette/style.d.ts +15 -0
  30. package/es/color-palette/style.js +231 -0
  31. package/es/color-picker/index.d.ts +2 -2
  32. package/es/color-picker/index.js +1 -38
  33. package/es/color-picker/style.d.ts +7 -0
  34. package/es/color-picker/style.js +38 -0
  35. package/es/emotion/index.d.ts +10 -0
  36. package/es/emotion/index.js +1 -0
  37. package/es/highlight-text/index.d.ts +4 -4
  38. package/es/highlight-text/index.js +1 -8
  39. package/es/highlight-text/style.d.ts +4 -0
  40. package/es/highlight-text/style.js +8 -0
  41. package/es/index.d.ts +3 -0
  42. package/es/index.js +1 -1
  43. package/es/input/index.d.ts +5 -5
  44. package/es/input/index.js +7 -7
  45. package/es/input-number/index.d.ts +2 -2
  46. package/es/input-number/index.js +1 -10
  47. package/es/input-number/style.d.ts +3 -0
  48. package/es/input-number/style.js +10 -0
  49. package/es/markdown/index.css +52 -52
  50. package/es/markdown/index.d.ts +2 -2
  51. package/es/markdown/index.js +1 -1
  52. package/es/photo/index.js +1 -83
  53. package/es/photo/style.d.ts +10 -0
  54. package/es/photo/style.js +83 -0
  55. package/es/prism/prism.css +75 -75
  56. package/es/schema-to-tree-data/index.d.ts +3 -0
  57. package/es/schema-to-tree-data/index.js +1 -0
  58. package/es/skeleton/index.d.ts +3 -3
  59. package/es/skeleton/index.js +1 -80
  60. package/es/skeleton/style.d.ts +8 -0
  61. package/es/skeleton/style.js +80 -0
  62. package/es/tooltip/index.d.ts +6 -6
  63. package/es/tooltip/index.js +1 -83
  64. package/es/tooltip/style.d.ts +6 -0
  65. package/es/tooltip/style.js +83 -0
  66. package/es/tree/index.d.ts +25 -0
  67. package/es/tree/index.js +1 -0
  68. package/es/tree/style.d.ts +10 -0
  69. package/es/tree/style.js +103 -0
  70. package/es/wave-circle/index.d.ts +4 -4
  71. package/es/wave-circle/index.js +1 -65
  72. package/es/wave-circle/style.d.ts +6 -0
  73. package/es/wave-circle/style.js +65 -0
  74. package/lib/avatar/index.d.ts +4 -4
  75. package/lib/avatar/index.js +1 -1
  76. package/lib/avatar/style.d.ts +4 -0
  77. package/lib/avatar/style.js +1 -0
  78. package/lib/avatar-group/index.d.ts +2 -2
  79. package/lib/avatar-group/index.js +1 -1
  80. package/lib/avatar-group/style.d.ts +4 -0
  81. package/lib/avatar-group/style.js +1 -0
  82. package/lib/back-top/index.d.ts +2 -2
  83. package/lib/back-top/index.js +1 -1
  84. package/lib/back-top/style.d.ts +4 -0
  85. package/lib/back-top/style.js +1 -0
  86. package/lib/button/index.d.ts +5 -4
  87. package/lib/button/index.js +1 -1
  88. package/lib/button/style.d.ts +3 -0
  89. package/lib/button/style.js +1 -0
  90. package/lib/capture-screen/index.d.ts +3 -3
  91. package/lib/capture-screen/index.js +1 -1
  92. package/lib/capture-screen/style.d.ts +9 -0
  93. package/lib/capture-screen/style.js +1 -0
  94. package/lib/carousel/index.js +1 -1
  95. package/lib/carousel/style.d.ts +11 -0
  96. package/lib/carousel/style.js +1 -0
  97. package/lib/code-block/index.d.ts +3 -3
  98. package/lib/code-block/index.js +1 -1
  99. package/lib/color-palette/index.d.ts +3 -3
  100. package/lib/color-palette/index.js +1 -1
  101. package/lib/color-palette/style.d.ts +15 -0
  102. package/lib/color-palette/style.js +1 -0
  103. package/lib/color-picker/index.d.ts +2 -2
  104. package/lib/color-picker/index.js +1 -1
  105. package/lib/color-picker/style.d.ts +7 -0
  106. package/lib/color-picker/style.js +1 -0
  107. package/lib/emotion/index.d.ts +10 -0
  108. package/lib/emotion/index.js +1 -0
  109. package/lib/highlight-text/index.d.ts +4 -4
  110. package/lib/highlight-text/index.js +1 -1
  111. package/lib/highlight-text/style.d.ts +4 -0
  112. package/lib/highlight-text/style.js +1 -0
  113. package/lib/index.d.ts +3 -0
  114. package/lib/index.js +1 -1
  115. package/lib/input/index.d.ts +5 -5
  116. package/lib/input/index.js +1 -1
  117. package/lib/input-number/index.d.ts +2 -2
  118. package/lib/input-number/index.js +1 -1
  119. package/lib/input-number/style.d.ts +3 -0
  120. package/lib/input-number/style.js +1 -0
  121. package/lib/markdown/index.css +52 -52
  122. package/lib/markdown/index.d.ts +2 -2
  123. package/lib/markdown/index.js +1 -1
  124. package/lib/photo/index.js +1 -1
  125. package/lib/photo/style.d.ts +10 -0
  126. package/lib/photo/style.js +1 -0
  127. package/lib/prism/prism.css +75 -75
  128. package/lib/schema-to-tree-data/index.d.ts +3 -0
  129. package/lib/schema-to-tree-data/index.js +1 -0
  130. package/lib/skeleton/index.d.ts +3 -3
  131. package/lib/skeleton/index.js +1 -1
  132. package/lib/skeleton/style.d.ts +8 -0
  133. package/lib/skeleton/style.js +1 -0
  134. package/lib/tooltip/index.d.ts +6 -6
  135. package/lib/tooltip/index.js +1 -1
  136. package/lib/tooltip/style.d.ts +6 -0
  137. package/lib/tooltip/style.js +1 -0
  138. package/lib/tree/index.d.ts +25 -0
  139. package/lib/tree/index.js +1 -0
  140. package/lib/tree/style.d.ts +10 -0
  141. package/lib/tree/style.js +1 -0
  142. package/lib/wave-circle/index.d.ts +4 -4
  143. package/lib/wave-circle/index.js +1 -1
  144. package/lib/wave-circle/style.d.ts +6 -0
  145. package/lib/wave-circle/style.js +1 -0
  146. package/package.json +8 -6
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Neko UI
2
2
 
3
- > UI组件库
3
+ !> UI组件库
4
4
 
5
5
  [![version][version-tag]][npm-url]
6
6
  [![install size][size-tag]][size-url]
@@ -17,7 +17,7 @@
17
17
  [size-url]: https://packagephobia.com/result?p=neko-ui@latest
18
18
  [download-tag]: https://img.shields.io/npm/dm/neko-ui.svg?logo=docusign
19
19
 
20
- > logo轮廓其实是双马尾
20
+ !> logo轮廓其实是双马尾
21
21
 
22
22
  ## 安装依赖
23
23
 
@@ -45,7 +45,7 @@ yarn build
45
45
 
46
46
  ## 打包项目`使用自定义配置`
47
47
 
48
- > 在打包其它有特殊配置的bundle时, 可以通过命令行参数来加载额外的配置文件;
48
+ !> 在打包其它有特殊配置的bundle时, 可以通过命令行参数来加载额外的配置文件;
49
49
 
50
50
  例如: 使用 **config/index.ts** 与 **config/prod.ts** 合并后的配置进行编译.
51
51
 
@@ -1,11 +1,11 @@
1
- import { type FC, type HTMLAttributes, type ReactNode } from 'react';
1
+ import React from 'react';
2
2
  import { type ComponentSize } from '../';
3
- export interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
4
- src?: ReactNode;
3
+ export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ src?: React.ReactNode;
5
5
  alt?: string;
6
6
  size?: number | ComponentSize;
7
7
  username?: string;
8
8
  color?: string;
9
9
  }
10
- declare const Avatar: FC<AvatarProps>;
10
+ declare const Avatar: React.FC<AvatarProps>;
11
11
  export default Avatar;
@@ -1,71 +1 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{useEffect,useMemo,useRef,useState}from"react";import{injectGlobal}from"@emotion/css";import{classNames}from"@moneko/common";import clipPath from"./clip-path.svg";import favicon from"./favicon.svg";import prefixCls from"../prefix-cls";const svgPrefix="data:image/svg+xml,";const clip=decodeURIComponent(clipPath.replace(svgPrefix,""));const faviconBg=`data:image/svg+xml;base64,${window.btoa(decodeURIComponent(favicon.replace(svgPrefix,"")))}`;const avatarCls=prefixCls("avatar");const avatarCss=`
2
- .${avatarCls} {
3
- position: relative;
4
- display: inline-flex;
5
- justify-content: center;
6
- align-items: center;
7
- width: 32px;
8
- height: 32px;
9
- transition: transform 0.3s;
10
- cursor: pointer;
11
- user-select: none;
12
- background-image: linear-gradient(45deg, #cabdeb 0%, #e9887c 100%);
13
- animation: avatar-morph-effect 8s ease-in-out infinite;
14
-
15
- &::before,
16
- &::after {
17
- position: absolute;
18
- top: 0;
19
- left: 0;
20
- display: block;
21
- width: 100%;
22
- height: 100%;
23
- content: '';
24
- transition: transform 0.3s;
25
- }
26
-
27
- &::before {
28
- background-color: var(--avatar-color);
29
- clip-path: url('#clipPathAvatar');
30
- }
31
-
32
- &::after {
33
- background: url(${faviconBg}) no-repeat center/contain;
34
- }
35
-
36
- span {
37
- transition: transform 0.3s;
38
- }
39
-
40
- &:hover {
41
- > *,
42
- &::after,
43
- &::before {
44
- transform: scale(1.2);
45
- }
46
- }
47
-
48
- img {
49
- position: absolute;
50
- left: 0;
51
- width: 100%;
52
- height: 100%;
53
- clip-path: url('#clipPathAvatar');
54
- transition: transform 0.3s;
55
- }
56
- }
57
-
58
- @keyframes avatar-morph-effect {
59
- 0% {
60
- border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
61
- }
62
-
63
- 50% {
64
- border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
65
- }
66
-
67
- 100% {
68
- border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
69
- }
70
- }
71
- `;const avatarSize={small:24,normal:32,large:40};const Avatar=_param=>{var{className,src,alt,username,size,style={},color}=_param,props=_objectWithoutProperties(_param,["className","src","alt","username","size","style","color"]);const box=useRef(null);const label=useRef(null);const[scale,setScale]=useState(1);const cls=useMemo(()=>classNames(avatarCls,className),[className]);useEffect(()=>{injectGlobal([avatarCss]);const hasSvg=document.documentElement.querySelector("clipPath#clipPathAvatar");if(!hasSvg){const svg=document.createElement("a");svg.innerHTML=clip;document.body.insertBefore(svg.firstChild,document.body.firstChild)}},[]);const _style=useMemo(()=>{if(typeof size==="number"){style.width=size;style.height=size}else if(size&&avatarSize[size]){style.width=avatarSize[size];style.height=avatarSize[size]}if(color)Object.assign(style,{"--avatar-color":color});return style},[color,size,style]);const img=useMemo(()=>typeof src==="string"?React.createElement("img",{src:src,alt:alt}):src,[alt,src]);useEffect(()=>{if(label.current&&box.current){if(label.current.clientWidth+6>box.current.clientWidth){setScale((box.current.clientWidth-6)/label.current.clientWidth)}}},[]);return React.createElement("div",_extends({ref:box,className:cls,style:_style},props),img?img:username?React.createElement("span",{ref:label,style:{transform:`scale(${scale})`}},username):null)};export default Avatar;
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{useEffect,useMemo,useRef,useState}from"react";import clipPath from"./clip-path.svg";import{cls,svgPrefix}from"./style";import{cx}from"../emotion";const clip=decodeURIComponent(clipPath.replace(svgPrefix,""));const avatarSize={small:24,normal:32,large:40};const Avatar=_param=>{var{className,src,alt,username,size,style={},color}=_param,props=_objectWithoutProperties(_param,["className","src","alt","username","size","style","color"]);const box=useRef(null);const label=useRef(null);const[scale,setScale]=useState(1);useEffect(()=>{const hasSvg=document.documentElement.querySelector("clipPath#clipPathAvatar");if(!hasSvg){const svg=document.createElement("a");svg.innerHTML=clip;document.body.insertBefore(svg.firstChild,document.body.firstChild)}},[]);const _style=useMemo(()=>{if(typeof size==="number"){style.width=size;style.height=size}else if(size&&avatarSize[size]){style.width=avatarSize[size];style.height=avatarSize[size]}if(color)Object.assign(style,{"--avatar-color":color});return style},[color,size,style]);const img=useMemo(()=>typeof src==="string"?React.createElement("img",{src:src,alt:alt}):src,[alt,src]);useEffect(()=>{if(label.current&&box.current){if(label.current.clientWidth+6>box.current.clientWidth){setScale((box.current.clientWidth-6)/label.current.clientWidth)}}},[]);return React.createElement("div",_extends({ref:box,className:cx(cls.avatar,className),style:_style},props),img?img:username?React.createElement("span",{ref:label,style:{transform:`scale(${scale})`}},username):null)};export default Avatar;
@@ -0,0 +1,4 @@
1
+ export declare const svgPrefix = "data:image/svg+xml,";
2
+ export declare const cls: {
3
+ avatar: "n-avatar";
4
+ };
@@ -0,0 +1,71 @@
1
+ import favicon from"./favicon.svg";import{injectGlobal}from"../emotion";import prefixCls from"../prefix-cls";export const svgPrefix="data:image/svg+xml,";export const cls={avatar:prefixCls("avatar")};const faviconBg=`data:image/svg+xml;base64,${window.btoa(decodeURIComponent(favicon.replace(svgPrefix,"")))}`;injectGlobal`
2
+ .${cls.avatar} {
3
+ position: relative;
4
+ display: inline-flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ inline-size: 32px;
8
+ block-size: 32px;
9
+ transition: transform 0.3s;
10
+ cursor: pointer;
11
+ user-select: none;
12
+ background-image: linear-gradient(45deg, #cabdeb 0%, #e9887c 100%);
13
+ animation: avatar-morph-effect 8s ease-in-out infinite;
14
+
15
+ &::before,
16
+ &::after {
17
+ position: absolute;
18
+ inset-block-start: 0;
19
+ inset-inline-start: 0;
20
+ display: block;
21
+ inline-size: 100%;
22
+ block-size: 100%;
23
+ content: '';
24
+ transition: transform 0.3s;
25
+ }
26
+
27
+ &::before {
28
+ background-color: var(--avatar-color);
29
+ clip-path: url('#clipPathAvatar');
30
+ }
31
+
32
+ &::after {
33
+ background: url(${faviconBg}) no-repeat center/contain;
34
+ }
35
+
36
+ span {
37
+ transition: transform 0.3s;
38
+ }
39
+
40
+ &:hover {
41
+ > *,
42
+ &::after,
43
+ &::before {
44
+ transform: scale(1.2);
45
+ }
46
+ }
47
+
48
+ img {
49
+ position: absolute;
50
+ inset-inline-start: 0;
51
+ inline-size: 100%;
52
+ block-size: 100%;
53
+ clip-path: url('#clipPathAvatar');
54
+ transition: transform 0.3s;
55
+ }
56
+ }
57
+
58
+ @keyframes avatar-morph-effect {
59
+ 0% {
60
+ border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
61
+ }
62
+
63
+ 50% {
64
+ border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
65
+ }
66
+
67
+ 100% {
68
+ border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
69
+ }
70
+ }
71
+ `;
@@ -1,4 +1,4 @@
1
- import { type FC } from 'react';
1
+ import React from 'react';
2
2
  import { type AvatarProps } from '../index';
3
3
  export interface AvatarGroupProps {
4
4
  data: Omit<AvatarProps, 'size'>[];
@@ -6,5 +6,5 @@ export interface AvatarGroupProps {
6
6
  className?: string;
7
7
  maxCount?: number;
8
8
  }
9
- declare const AvatarGroup: FC<AvatarGroupProps>;
9
+ declare const AvatarGroup: React.FC<AvatarGroupProps>;
10
10
  export default AvatarGroup;
@@ -1,21 +1 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}import React,{useMemo,useEffect}from"react";import{injectGlobal}from"@emotion/css";import{classNames}from"@moneko/common";import{Avatar,Tooltip}from"../index";import prefixCls from"../prefix-cls";const cls={group:prefixCls("avatar-group"),more:prefixCls("avatar-more")};const avatarGroupCss=`
2
- .${cls.group} {
3
- display: inline-flex;
4
- align-items: center;
5
-
6
- & > *:not(:first-child) {
7
- margin-left: -5%;
8
- }
9
- }
10
- .${cls.more} {
11
- display: flex;
12
- justify-content: center;
13
- align-items: center;
14
- overflow-y: auto;
15
- padding: 8px;
16
- max-width: 60vw;
17
- max-height: 80vh;
18
- gap: 16px;
19
- flex-wrap: wrap;
20
- }
21
- `;const AvatarGroup=props=>{const showAvatar=useMemo(()=>props.data.slice(0,props.maxCount),[props.data,props.maxCount]);const more=useMemo(()=>props.data.length-(props.maxCount||props.data.length),[props.data.length,props.maxCount]);useEffect(()=>{injectGlobal([avatarGroupCss])},[]);return React.createElement("div",{className:classNames(cls.group,props.className)},showAvatar.map((a,i)=>React.createElement(Avatar,_extends({key:`${i}-${a.src}`,size:props.size},a))),more>0?React.createElement(Tooltip,{title:React.createElement("div",{className:cls.more},props.data.slice(-more).map((a,i)=>React.createElement(Avatar,_extends({key:`${i}-${a.src}`,size:props.size},a))))},React.createElement(Avatar,{size:props.size,username:`+${more}`})):null)};export default AvatarGroup;
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}import React,{useMemo}from"react";import{cls}from"./style";import{cx}from"../emotion";import{Avatar,Tooltip}from"../index";const AvatarGroup=props=>{const showAvatar=useMemo(()=>props.data.slice(0,props.maxCount),[props.data,props.maxCount]);const more=useMemo(()=>props.data.length-(props.maxCount||props.data.length),[props.data.length,props.maxCount]);return React.createElement("div",{className:cx(cls.group,props.className)},showAvatar.map((a,i)=>React.createElement(Avatar,_extends({key:`${i}-${a.src}`,size:props.size},a))),more>0?React.createElement(Tooltip,{title:React.createElement("div",{className:cls.more},props.data.slice(-more).map((a,i)=>React.createElement(Avatar,_extends({key:`${i}-${a.src}`,size:props.size},a))))},React.createElement(Avatar,{size:props.size,username:`+${more}`})):null)};export default AvatarGroup;
@@ -0,0 +1,4 @@
1
+ export declare const cls: {
2
+ group: "n-avatar-group";
3
+ more: "n-avatar-more";
4
+ };
@@ -0,0 +1,21 @@
1
+ import{injectGlobal}from"../emotion";import prefixCls from"../prefix-cls";export const cls={group:prefixCls("avatar-group"),more:prefixCls("avatar-more")};injectGlobal`
2
+ .${cls.group} {
3
+ display: inline-flex;
4
+ align-items: center;
5
+
6
+ & > *:not(:first-child) {
7
+ margin-inline-start: -5%;
8
+ }
9
+ }
10
+ .${cls.more} {
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ overflow-y: auto;
15
+ padding: 8px;
16
+ max-inline-size: 60vi;
17
+ max-block-size: 80vb;
18
+ gap: 16px;
19
+ flex-wrap: wrap;
20
+ }
21
+ `;
@@ -1,5 +1,5 @@
1
- import React, { type HTMLAttributes } from 'react';
2
- export interface BackTopProps extends HTMLAttributes<HTMLDivElement> {
1
+ import React from 'react';
2
+ export interface BackTopProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  /** 设置需要监听其滚动事件的元素,值为一个返回对应 DOM 元素 */
4
4
  target?: () => HTMLElement;
5
5
  /** 挂载到指定的元素,值为一个返回对应 DOM 元素 默认 document.body */
@@ -1,73 +1 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{memo,useCallback,useEffect,useRef,useState}from"react";import{injectGlobal}from"@emotion/css";import{classNames,getMaxZindex,getScrollTop,isEqual,isFunction}from"@moneko/common";import{createPortal}from"react-dom";import prefixCls from"../prefix-cls";const cls={backtop:prefixCls("back-top"),out:prefixCls("back-top-out")};const backTopCss=`
2
- :root {
3
- --back-top-color: #fff;
4
- --back-top-bg: var(--text-secondary, #4e4e4e);
5
- --back-top-hover-bg: var(--text-color, rgb(0 0 0 / 65%));
6
- }
7
-
8
- [data-theme='dark'] {
9
- --back-top-bg: rgb(255 255 255 / 45%);
10
- }
11
- .${cls.backtop} {
12
- position: sticky;
13
- bottom: 50px;
14
- left: calc(100% - 100px);
15
- z-index: 9;
16
- display: flex;
17
- justify-content: center;
18
- align-items: center;
19
- border-radius: 50%;
20
- width: 40px;
21
- min-width: 40px;
22
- height: 40px;
23
- min-height: 40px;
24
- color: var(--back-top-color);
25
- background-color: var(--back-top-bg);
26
- box-shadow: var(--box-shadow-base);
27
- transition: background-color var(--transition-duration), color var(--transition-duration);
28
- cursor: pointer;
29
- animation: back-top-fade-in 1s forwards;
30
- backdrop-filter: blur(16px);
31
-
32
- &::before {
33
- content: '';
34
- display: block;
35
- width: 16px;
36
- height: 8px;
37
- background-color: var(--back-top-color);
38
- clip-path: polygon(0 100%, 50% 0, 100% 100%);
39
- }
40
-
41
- &:hover {
42
- background-color: var(--back-top-hover-bg);
43
- }
44
- }
45
- .${cls.out} {
46
- animation: back-top-fade-out 1s forwards;
47
- }
48
-
49
- @keyframes back-top-fade-in {
50
- from {
51
- transform: translate3d(0, 16px, 0) scale(1);
52
- opacity: 0;
53
- }
54
-
55
- to {
56
- transform: translate3d(0, 0, 0) scale(1);
57
- opacity: 1;
58
- }
59
- }
60
-
61
- @keyframes back-top-fade-out {
62
- 0%,
63
- 20% {
64
- transform: translate3d(0, 0, 0);
65
- opacity: 1;
66
- }
67
-
68
- 100% {
69
- transform: translate3d(0, 16px, 0);
70
- opacity: 0;
71
- }
72
- }
73
- `;const BackTop=_param=>{var{target=()=>window,getPopupContainer,visibilityHeight=400,className}=_param,props=_objectWithoutProperties(_param,["target","getPopupContainer","visibilityHeight","className"]);const ref=useRef(null);const[show,setShow]=useState(null);const handleScrollY=useCallback(()=>{let scrollTop=0;let offsetHeight=0;if(isFunction(target)){const ele=target();if(ele){scrollTop=getScrollTop(ele);offsetHeight=ele.offsetHeight}}const nextShow=scrollTop>offsetHeight/3||scrollTop>visibilityHeight;if(Boolean(show)!==nextShow){setShow(nextShow)}},[show,target,visibilityHeight]);const handleBackTop=useCallback(()=>{var _target;(_target=target())===null||_target===void 0?void 0:_target.scrollTo({top:0,behavior:"smooth"})},[target]);useEffect(()=>{if(show&&ref.current){ref.current.style.zIndex=getMaxZindex().toString()}},[show]);useEffect(()=>{if(isFunction(target)){var _target;(_target=target())===null||_target===void 0?void 0:_target.addEventListener("scroll",handleScrollY,false)}return()=>{if(isFunction(target)){var _target;(_target=target())===null||_target===void 0?void 0:_target.removeEventListener("scroll",handleScrollY,false)}}},[handleScrollY,target]);const exit=useCallback(()=>{if(show===false){setShow(null)}},[show]);useEffect(()=>{injectGlobal([backTopCss])},[]);if(show===null)return null;return createPortal(React.createElement("div",_extends({},props,{ref:ref,onAnimationEnd:exit,className:classNames(className,cls.backtop,show===false&&cls.out),onClick:handleBackTop})),(getPopupContainer===null||getPopupContainer===void 0?void 0:getPopupContainer(target()))||document.body)};export default memo(BackTop,isEqual);
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{memo,useCallback,useEffect,useRef,useState}from"react";import{getMaxZindex,getScrollTop,isEqual,isFunction}from"@moneko/common";import{createPortal}from"react-dom";import{cls}from"./style";import{cx}from"../emotion";const BackTop=_param=>{var{target=()=>window,getPopupContainer,visibilityHeight=400,className}=_param,props=_objectWithoutProperties(_param,["target","getPopupContainer","visibilityHeight","className"]);const ref=useRef(null);const[show,setShow]=useState(null);const handleScrollY=useCallback(()=>{let scrollTop=0;let offsetHeight=0;if(isFunction(target)){const ele=target();if(ele){scrollTop=getScrollTop(ele);offsetHeight=ele.offsetHeight}}const nextShow=scrollTop>offsetHeight/3||scrollTop>visibilityHeight;if(Boolean(show)!==nextShow){setShow(nextShow)}},[show,target,visibilityHeight]);const handleBackTop=useCallback(()=>{var _target;(_target=target())===null||_target===void 0?void 0:_target.scrollTo({top:0,behavior:"smooth"})},[target]);useEffect(()=>{if(show&&ref.current){ref.current.style.zIndex=getMaxZindex().toString()}},[show]);useEffect(()=>{if(isFunction(target)){var _target;(_target=target())===null||_target===void 0?void 0:_target.addEventListener("scroll",handleScrollY,false)}return()=>{if(isFunction(target)){var _target;(_target=target())===null||_target===void 0?void 0:_target.removeEventListener("scroll",handleScrollY,false)}}},[handleScrollY,target]);const exit=useCallback(()=>{if(show===false){setShow(null)}},[show]);if(show===null)return null;return createPortal(React.createElement("div",_extends({},props,{ref:ref,onAnimationEnd:exit,className:cx(className,cls.backtop,show===false&&cls.out),onClick:handleBackTop})),(getPopupContainer===null||getPopupContainer===void 0?void 0:getPopupContainer(target()))||document.body)};export default memo(BackTop,isEqual);
@@ -0,0 +1,4 @@
1
+ export declare const cls: {
2
+ backtop: "n-back-top";
3
+ out: "n-back-top-out";
4
+ };
@@ -0,0 +1,73 @@
1
+ import{injectGlobal}from"../emotion";import prefixCls from"../prefix-cls";export const cls={backtop:prefixCls("back-top"),out:prefixCls("back-top-out")};injectGlobal`
2
+ :root {
3
+ --back-top-color: #fff;
4
+ --back-top-bg: var(--text-secondary, #4e4e4e);
5
+ --back-top-hover-bg: var(--text-color, rgb(0 0 0 / 65%));
6
+ }
7
+
8
+ [data-theme='dark'] {
9
+ --back-top-bg: rgb(255 255 255 / 45%);
10
+ }
11
+ .${cls.backtop} {
12
+ position: sticky;
13
+ inset-block-end: 50px;
14
+ inset-inline-start: calc(100% - 100px);
15
+ z-index: 9;
16
+ display: flex;
17
+ justify-content: center;
18
+ align-items: center;
19
+ border-radius: 50%;
20
+ inline-size: 40px;
21
+ min-inline-size: 40px;
22
+ block-size: 40px;
23
+ min-block-size: 40px;
24
+ color: var(--back-top-color);
25
+ background-color: var(--back-top-bg);
26
+ box-shadow: var(--box-shadow-base);
27
+ transition: background-color var(--transition-duration), color var(--transition-duration);
28
+ cursor: pointer;
29
+ animation: back-top-fade-in 1s forwards;
30
+ backdrop-filter: blur(16px);
31
+
32
+ &::before {
33
+ content: '';
34
+ display: block;
35
+ inline-size: 16px;
36
+ block-size: 8px;
37
+ background-color: var(--back-top-color);
38
+ clip-path: polygon(0 100%, 50% 0, 100% 100%);
39
+ }
40
+
41
+ &:hover {
42
+ background-color: var(--back-top-hover-bg);
43
+ }
44
+ }
45
+ .${cls.out} {
46
+ animation: back-top-fade-out 1s forwards;
47
+ }
48
+
49
+ @keyframes back-top-fade-in {
50
+ from {
51
+ transform: translate3d(0, 16px, 0) scale(1);
52
+ opacity: 0;
53
+ }
54
+
55
+ to {
56
+ transform: translate3d(0, 0, 0) scale(1);
57
+ opacity: 1;
58
+ }
59
+ }
60
+
61
+ @keyframes back-top-fade-out {
62
+ 0%,
63
+ 20% {
64
+ transform: translate3d(0, 0, 0);
65
+ opacity: 1;
66
+ }
67
+
68
+ 100% {
69
+ transform: translate3d(0, 16px, 0);
70
+ opacity: 0;
71
+ }
72
+ }
73
+ `;
@@ -1,7 +1,8 @@
1
- import { type FC, type HTMLAttributes } from 'react';
1
+ import React from 'react';
2
+ import { type ButtonType } from './style';
2
3
  import type { ComponentSize } from '../';
3
- export type ButtonType = 'success' | 'error' | 'primary' | 'warning' | 'default';
4
- export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
4
+ export type { ButtonType } from './style';
5
+ export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
5
6
  /** 按钮类型 */
6
7
  type?: ButtonType;
7
8
  /** 无限动画 */
@@ -26,5 +27,5 @@ export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
26
27
  danger?: boolean;
27
28
  size?: ComponentSize;
28
29
  }
29
- declare const Button: FC<ButtonProps>;
30
+ declare const Button: React.FC<ButtonProps>;
30
31
  export default Button;