@dtjoy/dt-design 1.0.0 → 1.0.2

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 (161) hide show
  1. package/esm/_util/gapSize.d.ts +3 -0
  2. package/esm/_util/gapSize.js +10 -0
  3. package/esm/_util/hooks/index.d.ts +1 -0
  4. package/esm/_util/hooks/index.js +1 -0
  5. package/esm/_util/hooks/useOrientation.d.ts +2 -0
  6. package/esm/_util/hooks/useOrientation.js +19 -0
  7. package/esm/_util/isNonNullable.d.ts +2 -0
  8. package/esm/_util/isNonNullable.js +4 -0
  9. package/esm/_util/type.d.ts +2 -1
  10. package/esm/blockHeader/index.d.ts +1 -1
  11. package/esm/blockHeader/index.js +13 -10
  12. package/esm/blockHeader/style/index.d.ts +2 -0
  13. package/esm/blockHeader/style/index.js +2 -0
  14. package/esm/blockHeader/{style.less → style/index.less} +143 -141
  15. package/esm/button/index.d.ts +10 -0
  16. package/esm/button/index.js +29 -0
  17. package/esm/button/style/index.d.ts +2 -0
  18. package/esm/button/style/index.js +2 -0
  19. package/esm/button/style/index.less +134 -0
  20. package/esm/button/style/mixin.less +47 -0
  21. package/esm/collapsible/index.d.ts +97 -0
  22. package/esm/collapsible/index.js +234 -0
  23. package/esm/collapsible/style/index.d.ts +1 -0
  24. package/esm/collapsible/style/index.js +1 -0
  25. package/esm/collapsible/style/index.less +24 -0
  26. package/esm/collapsibleActionItems/index.d.ts +24 -0
  27. package/esm/collapsibleActionItems/index.js +74 -0
  28. package/esm/collapsibleActionItems/style/index.d.ts +2 -0
  29. package/esm/collapsibleActionItems/style/index.js +2 -0
  30. package/esm/collapsibleActionItems/style/index.less +7 -0
  31. package/esm/flex/index.d.ts +7 -0
  32. package/esm/flex/index.js +62 -0
  33. package/esm/flex/interface.d.ts +16 -0
  34. package/esm/flex/interface.js +1 -0
  35. package/esm/flex/style/index.d.ts +2 -0
  36. package/esm/flex/style/index.js +2 -0
  37. package/esm/flex/style/index.less +77 -0
  38. package/esm/flex/utils.d.ts +7 -0
  39. package/esm/flex/utils.js +33 -0
  40. package/esm/index.d.ts +10 -1
  41. package/esm/index.js +8 -7
  42. package/esm/resize/index.d.ts +8 -0
  43. package/esm/resize/index.js +29 -0
  44. package/esm/splitter/Panel.d.ts +7 -0
  45. package/esm/splitter/Panel.js +38 -0
  46. package/esm/splitter/SplitBar.d.ts +24 -0
  47. package/esm/splitter/SplitBar.js +185 -0
  48. package/esm/splitter/Splitter.d.ts +5 -0
  49. package/esm/splitter/Splitter.js +215 -0
  50. package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
  51. package/esm/splitter/hooks/sizeUtil.js +63 -0
  52. package/esm/splitter/hooks/useItems.d.ts +14 -0
  53. package/esm/splitter/hooks/useItems.js +44 -0
  54. package/esm/splitter/hooks/useResizable.d.ts +10 -0
  55. package/esm/splitter/hooks/useResizable.js +73 -0
  56. package/esm/splitter/hooks/useResize.d.ts +6 -0
  57. package/esm/splitter/hooks/useResize.js +158 -0
  58. package/esm/splitter/hooks/useSizes.d.ts +4 -0
  59. package/esm/splitter/hooks/useSizes.js +80 -0
  60. package/esm/splitter/index.d.ts +8 -0
  61. package/esm/splitter/index.js +5 -0
  62. package/esm/splitter/interface.d.ts +68 -0
  63. package/esm/splitter/interface.js +1 -0
  64. package/esm/splitter/style/index.d.ts +2 -0
  65. package/esm/splitter/style/index.js +2 -0
  66. package/esm/splitter/style/index.less +312 -0
  67. package/esm/statusTag/index.d.ts +28 -0
  68. package/esm/statusTag/index.js +122 -0
  69. package/esm/statusTag/style/index.d.ts +2 -0
  70. package/esm/statusTag/style/index.js +2 -0
  71. package/esm/statusTag/style/index.less +70 -0
  72. package/esm/statusTag/style/mixin.less +39 -0
  73. package/esm/style/index.d.ts +1 -0
  74. package/esm/style/index.js +1 -0
  75. package/esm/style/index.less +1 -0
  76. package/esm/style/mixins/index.less +0 -0
  77. package/esm/style/themes/index.less +2 -0
  78. package/esm/style/themes/variable.less +1 -0
  79. package/lib/_util/gapSize.d.ts +3 -0
  80. package/lib/_util/gapSize.js +17 -0
  81. package/lib/_util/hooks/index.d.ts +1 -0
  82. package/lib/_util/hooks/index.js +16 -0
  83. package/lib/_util/hooks/useOrientation.d.ts +2 -0
  84. package/lib/_util/hooks/useOrientation.js +26 -0
  85. package/lib/_util/isNonNullable.d.ts +2 -0
  86. package/lib/_util/isNonNullable.js +10 -0
  87. package/lib/_util/type.d.ts +2 -1
  88. package/lib/blockHeader/index.d.ts +1 -1
  89. package/lib/blockHeader/index.js +13 -11
  90. package/lib/blockHeader/style/index.d.ts +2 -0
  91. package/lib/blockHeader/style/index.js +4 -0
  92. package/lib/blockHeader/{style.less → style/index.less} +143 -141
  93. package/lib/button/index.d.ts +10 -0
  94. package/lib/button/index.js +33 -0
  95. package/lib/button/style/index.d.ts +2 -0
  96. package/lib/button/style/index.js +4 -0
  97. package/lib/button/style/index.less +134 -0
  98. package/lib/button/style/mixin.less +47 -0
  99. package/lib/collapsible/index.d.ts +97 -0
  100. package/lib/collapsible/index.js +199 -0
  101. package/lib/collapsible/style/index.d.ts +1 -0
  102. package/lib/collapsible/style/index.js +3 -0
  103. package/lib/collapsible/style/index.less +24 -0
  104. package/lib/collapsibleActionItems/index.d.ts +24 -0
  105. package/lib/collapsibleActionItems/index.js +68 -0
  106. package/lib/collapsibleActionItems/style/index.d.ts +2 -0
  107. package/lib/collapsibleActionItems/style/index.js +4 -0
  108. package/lib/collapsibleActionItems/style/index.less +7 -0
  109. package/lib/flex/index.d.ts +7 -0
  110. package/lib/flex/index.js +60 -0
  111. package/lib/flex/interface.d.ts +16 -0
  112. package/lib/flex/interface.js +5 -0
  113. package/lib/flex/style/index.d.ts +2 -0
  114. package/lib/flex/style/index.js +4 -0
  115. package/lib/flex/style/index.less +77 -0
  116. package/lib/flex/utils.d.ts +7 -0
  117. package/lib/flex/utils.js +39 -0
  118. package/lib/index.d.ts +10 -1
  119. package/lib/index.js +72 -1
  120. package/lib/resize/index.d.ts +8 -0
  121. package/lib/resize/index.js +38 -0
  122. package/lib/splitter/Panel.d.ts +7 -0
  123. package/lib/splitter/Panel.js +44 -0
  124. package/lib/splitter/SplitBar.d.ts +24 -0
  125. package/lib/splitter/SplitBar.js +179 -0
  126. package/lib/splitter/Splitter.d.ts +5 -0
  127. package/lib/splitter/Splitter.js +202 -0
  128. package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
  129. package/lib/splitter/hooks/sizeUtil.js +56 -0
  130. package/lib/splitter/hooks/useItems.d.ts +14 -0
  131. package/lib/splitter/hooks/useItems.js +46 -0
  132. package/lib/splitter/hooks/useResizable.d.ts +10 -0
  133. package/lib/splitter/hooks/useResizable.js +83 -0
  134. package/lib/splitter/hooks/useResize.d.ts +6 -0
  135. package/lib/splitter/hooks/useResize.js +142 -0
  136. package/lib/splitter/hooks/useSizes.d.ts +4 -0
  137. package/lib/splitter/hooks/useSizes.js +62 -0
  138. package/lib/splitter/index.d.ts +8 -0
  139. package/lib/splitter/index.js +12 -0
  140. package/lib/splitter/interface.d.ts +68 -0
  141. package/lib/splitter/interface.js +5 -0
  142. package/lib/splitter/style/index.d.ts +2 -0
  143. package/lib/splitter/style/index.js +4 -0
  144. package/lib/splitter/style/index.less +312 -0
  145. package/lib/statusTag/index.d.ts +28 -0
  146. package/lib/statusTag/index.js +125 -0
  147. package/lib/statusTag/style/index.d.ts +2 -0
  148. package/lib/statusTag/style/index.js +4 -0
  149. package/lib/statusTag/style/index.less +70 -0
  150. package/lib/statusTag/style/mixin.less +39 -0
  151. package/lib/style/index.d.ts +1 -0
  152. package/lib/style/index.js +3 -0
  153. package/lib/style/index.less +1 -0
  154. package/lib/style/mixins/index.less +0 -0
  155. package/lib/style/themes/index.less +2 -0
  156. package/lib/style/themes/variable.less +1 -0
  157. package/package.json +142 -141
  158. package/esm/styles/entry.less +0 -6
  159. package/esm/styles/variables.less +0 -1
  160. package/lib/styles/entry.less +0 -6
  161. package/lib/styles/variables.less +0 -1
@@ -0,0 +1,68 @@
1
+ /// <reference types="react" />
2
+ import { ShowCollapsibleIconMode } from './SplitBar';
3
+ export interface SplitterProps {
4
+ prefixCls?: string;
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ rootClassName?: string;
8
+ layout?: 'horizontal' | 'vertical';
9
+ onResizeStart?: (sizes: number[]) => void;
10
+ onResize?: (sizes: number[]) => void;
11
+ onResizeEnd?: (sizes: number[]) => void;
12
+ lazy?: boolean;
13
+ }
14
+ export interface PanelProps {
15
+ className?: string;
16
+ style?: React.CSSProperties;
17
+ min?: number | string;
18
+ max?: number | string;
19
+ size?: number | string;
20
+ collapsible?: boolean | {
21
+ start?: boolean;
22
+ end?: boolean;
23
+ showCollapsibleIcon?: ShowCollapsibleIconMode;
24
+ };
25
+ resizable?: boolean;
26
+ defaultSize?: number | string;
27
+ }
28
+ export interface InternalPanelProps extends PanelProps {
29
+ className?: string;
30
+ prefixCls?: string;
31
+ }
32
+ export interface UseResizeProps extends Pick<SplitterProps, 'onResize'> {
33
+ basicsState: number[];
34
+ items: PanelProps[];
35
+ panelsRef: React.RefObject<(HTMLDivElement | null)[]>;
36
+ reverse: boolean;
37
+ setBasicsState: React.Dispatch<React.SetStateAction<number[]>>;
38
+ }
39
+ export interface UseResize {
40
+ setSize: (data: {
41
+ size: number;
42
+ index: number;
43
+ }[]) => void;
44
+ setOffset: (offset: number, containerSize: number, index: number) => void;
45
+ }
46
+ export interface UseHandleProps extends Pick<SplitterProps, 'layout' | 'onResizeStart' | 'onResizeEnd'> {
47
+ basicsState: number[];
48
+ containerRef?: React.RefObject<HTMLDivElement | null>;
49
+ setOffset: UseResize['setOffset'];
50
+ setResizing: React.Dispatch<React.SetStateAction<boolean>>;
51
+ }
52
+ export interface UseHandle {
53
+ onStart: (x: number, y: number, index: number) => void;
54
+ }
55
+ export interface UseCollapsibleProps {
56
+ basicsState: number[];
57
+ collapsible?: PanelProps['collapsible'];
58
+ index: number;
59
+ reverse: boolean;
60
+ setSize?: UseResize['setSize'];
61
+ }
62
+ export interface UseCollapsible {
63
+ nextIcon: boolean;
64
+ overlap: boolean;
65
+ previousIcon: boolean;
66
+ onFold: (type: 'previous' | 'next') => void;
67
+ setOldBasics: () => void;
68
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,2 @@
1
+ import '../../style';
2
+ import './index.less';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../../style");
4
+ require("./index.less");
@@ -0,0 +1,312 @@
1
+ @import '../../style/themes/index.less';
2
+
3
+ @splitter-prefix-cls: ~'@{ant-prefix}-splitter';
4
+
5
+ @splitter-resize-spinner-size: 20px;
6
+ @splitter-split-bar-draggable-size: @splitter-resize-spinner-size;
7
+ @splitter-split-bar-size: 2px;
8
+ @splitter-split-trigger-size: 6px;
9
+
10
+ @splitterBarPreviewOffsetVar: ~'@{splitter-prefix-cls}-bar-preview-offset';
11
+ @splitter-transform-x: ~'translateX(var(--@{splitterBarPreviewOffsetVar}))';
12
+ @splitter-transform-y: ~'translateY(var(--@{splitterBarPreviewOffsetVar}))';
13
+
14
+ .center-position() {
15
+ position: absolute;
16
+ top: 50%;
17
+ left: 50%;
18
+ transform: translate(-50%, -50%);
19
+ }
20
+
21
+ .@{splitter-prefix-cls} {
22
+ display: flex;
23
+ width: 100%;
24
+ height: 100%;
25
+ align-items: stretch;
26
+
27
+ & > .@{splitter-prefix-cls}-bar {
28
+ flex: none;
29
+ position: relative;
30
+ user-select: none;
31
+
32
+ .@{splitter-prefix-cls}-bar-dragger {
33
+ .center-position();
34
+ z-index: 1;
35
+ pointer-events: auto;
36
+
37
+ &::before {
38
+ content: '';
39
+ background: @item-hover-bg;
40
+ .center-position();
41
+ }
42
+
43
+ &::after {
44
+ content: '';
45
+ background: rgba(0, 0, 0, 0.15);
46
+ .center-position();
47
+ }
48
+
49
+ &:hover:not(.@{splitter-prefix-cls}-bar-dragger-active) {
50
+ &::before {
51
+ background: @item-active-bg;
52
+ }
53
+ }
54
+
55
+ &.@{splitter-prefix-cls}-bar-dragger-active {
56
+ z-index: 2;
57
+
58
+ &::before {
59
+ background: @item-active-bg;
60
+ }
61
+ }
62
+
63
+ &.@{splitter-prefix-cls}-bar-dragger-disabled {
64
+ z-index: 0;
65
+ cursor: default;
66
+
67
+ &,
68
+ &:hover,
69
+ &.@{splitter-prefix-cls}-bar-dragger-active {
70
+ &::before {
71
+ background: @disabled-bg;
72
+ }
73
+ }
74
+
75
+ &::after {
76
+ display: none;
77
+ }
78
+ }
79
+ }
80
+
81
+ .@{splitter-prefix-cls}-bar-collapse-bar {
82
+ .center-position();
83
+ z-index: @zindex-popover;
84
+ background: @item-hover-bg;
85
+ font-size: @font-size-base;
86
+ border-radius: @border-radius-base;
87
+ color: @text-color;
88
+ cursor: pointer;
89
+ opacity: 0;
90
+ display: flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+
94
+ &:hover {
95
+ background: @item-active-bg;
96
+ }
97
+
98
+ &:active {
99
+ background: @item-active-bg;
100
+ }
101
+ }
102
+
103
+ &:hover,
104
+ &:active {
105
+ .@{splitter-prefix-cls}-bar-collapse-bar-hover-only {
106
+ opacity: 1;
107
+ }
108
+ }
109
+
110
+ .@{splitter-prefix-cls}-bar-collapse-bar-hover-only {
111
+ @media (hover: none) {
112
+ opacity: 1;
113
+ }
114
+ }
115
+
116
+ .@{splitter-prefix-cls}-bar-collapse-bar-always-hidden {
117
+ display: none;
118
+ }
119
+
120
+ .@{splitter-prefix-cls}-bar-collapse-bar-always-visible {
121
+ opacity: 1;
122
+ }
123
+ }
124
+
125
+ .@{splitter-prefix-cls}-mask {
126
+ position: fixed;
127
+ z-index: 9999;
128
+ top: 0;
129
+ right: 0;
130
+ bottom: 0;
131
+ left: 0;
132
+ background: transparent;
133
+
134
+ &.@{splitter-prefix-cls}-mask-horizontal {
135
+ cursor: col-resize;
136
+ }
137
+
138
+ &.@{splitter-prefix-cls}-mask-vertical {
139
+ cursor: row-resize;
140
+ }
141
+ }
142
+
143
+ &.@{splitter-prefix-cls}-horizontal {
144
+ flex-direction: row;
145
+
146
+ & > .@{splitter-prefix-cls}-bar {
147
+ width: 0;
148
+
149
+ .@{splitter-prefix-cls}-bar-preview {
150
+ height: 100%;
151
+ width: @splitter-split-bar-size;
152
+ position: absolute;
153
+ background: @primary-color;
154
+ opacity: 0.2;
155
+ pointer-events: none;
156
+ transition: none;
157
+ z-index: 1;
158
+ display: none;
159
+
160
+ &.@{splitter-prefix-cls}-bar-preview-active {
161
+ display: block;
162
+
163
+ transform: @splitter-transform-x;
164
+ }
165
+ }
166
+
167
+ .@{splitter-prefix-cls}-bar-dragger {
168
+ cursor: col-resize;
169
+ height: 100%;
170
+ width: @splitter-split-trigger-size;
171
+
172
+ &::before {
173
+ height: 100%;
174
+ width: @splitter-split-bar-size;
175
+ }
176
+
177
+ &::after {
178
+ height: @splitter-split-bar-draggable-size;
179
+ width: @splitter-split-bar-size;
180
+ }
181
+ }
182
+
183
+ .@{splitter-prefix-cls}-bar-collapse-bar {
184
+ width: @font-size-sm;
185
+ height: @btn-height-sm;
186
+
187
+ &.@{splitter-prefix-cls}-bar-collapse-bar-start {
188
+ left: auto;
189
+ right: (@splitter-split-trigger-size / 2);
190
+ transform: translateY(-50%);
191
+ }
192
+
193
+ &.@{splitter-prefix-cls}-bar-collapse-bar-end {
194
+ left: (@splitter-split-trigger-size / 2);
195
+ right: auto;
196
+ transform: translateY(-50%);
197
+ }
198
+ }
199
+ }
200
+ }
201
+
202
+ &.@{splitter-prefix-cls}-vertical {
203
+ flex-direction: column;
204
+
205
+ & > .@{splitter-prefix-cls}-bar {
206
+ height: 0;
207
+
208
+ .@{splitter-prefix-cls}-bar-preview {
209
+ height: @splitter-split-bar-size;
210
+ width: 100%;
211
+ position: absolute;
212
+ background: @primary-color;
213
+ opacity: 0.2;
214
+ pointer-events: none;
215
+ transition: none;
216
+ z-index: 1;
217
+ display: none;
218
+
219
+ &.@{splitter-prefix-cls}-bar-preview-active {
220
+ display: block;
221
+ transform: @splitter-transform-y;
222
+ }
223
+ }
224
+
225
+ .@{splitter-prefix-cls}-bar-dragger {
226
+ cursor: row-resize;
227
+ width: 100%;
228
+ height: @splitter-split-trigger-size;
229
+
230
+ &::before {
231
+ width: 100%;
232
+ height: @splitter-split-bar-size;
233
+ }
234
+
235
+ &::after {
236
+ width: @splitter-split-bar-draggable-size;
237
+ height: @splitter-split-bar-size;
238
+ }
239
+ }
240
+
241
+ .@{splitter-prefix-cls}-bar-collapse-bar {
242
+ height: @font-size-sm;
243
+ width: @btn-height-sm;
244
+
245
+ &.@{splitter-prefix-cls}-bar-collapse-bar-start {
246
+ top: auto;
247
+ bottom: (@splitter-split-trigger-size / 2);
248
+ transform: translateX(-50%);
249
+ }
250
+
251
+ &.@{splitter-prefix-cls}-bar-collapse-bar-end {
252
+ top: (@splitter-split-trigger-size / 2);
253
+ bottom: auto;
254
+ transform: translateX(-50%);
255
+ }
256
+ }
257
+ }
258
+ }
259
+
260
+ .@{splitter-prefix-cls}-panel {
261
+ overflow: auto;
262
+ padding: 0 1px;
263
+ box-sizing: border-box;
264
+
265
+ &::-webkit-scrollbar {
266
+ width: 8px;
267
+ height: 8px;
268
+ }
269
+
270
+ &::-webkit-scrollbar-thumb {
271
+ background: @table-sticky-scroll-bar-bg;
272
+ border-radius: @table-sticky-scroll-bar-radius;
273
+ }
274
+
275
+ &.@{splitter-prefix-cls}-panel-hidden {
276
+ padding: 0;
277
+ overflow: hidden;
278
+ }
279
+
280
+ &:has(.@{splitter-prefix-cls}:only-child) {
281
+ overflow: hidden;
282
+ }
283
+ }
284
+
285
+ &.@{ant-prefix}-rtl.@{splitter-prefix-cls}-horizontal {
286
+ & > .@{splitter-prefix-cls}-bar {
287
+ .@{splitter-prefix-cls}-bar-collapse-previous {
288
+ right: 0;
289
+ left: unset;
290
+ }
291
+
292
+ .@{splitter-prefix-cls}-bar-collapse-next {
293
+ right: unset;
294
+ left: 0;
295
+ }
296
+ }
297
+ }
298
+
299
+ &.@{ant-prefix}-rtl.@{splitter-prefix-cls}-vertical {
300
+ & > .@{splitter-prefix-cls}-bar {
301
+ .@{splitter-prefix-cls}-bar-collapse-previous {
302
+ right: 50%;
303
+ left: unset;
304
+ }
305
+
306
+ .@{splitter-prefix-cls}-bar-collapse-next {
307
+ right: 50%;
308
+ left: unset;
309
+ }
310
+ }
311
+ }
312
+ }
@@ -0,0 +1,28 @@
1
+ import React, { CSSProperties, HTMLAttributes, ReactNode } from 'react';
2
+ import './style';
3
+ export declare const PRESET_COLOR_TYPES: readonly ["blue", "yellow", "green", "gray", "red", "purple", "cyan", "pink"];
4
+ export declare const STATUS_TAG_TYPES: readonly ["default", "outline", "fill"];
5
+ export declare type PresetColorType = (typeof PRESET_COLOR_TYPES)[number] | (string & {});
6
+ export declare type StatusTagType = (typeof STATUS_TAG_TYPES)[number];
7
+ export interface IStatusTagProps extends HTMLAttributes<HTMLDivElement> {
8
+ /** 状态类型 */
9
+ type?: StatusTagType;
10
+ /** 是否圆角 */
11
+ rounded?: boolean;
12
+ /** 状态颜色(支持预设值/自定义十六进制/RGB) */
13
+ color?: PresetColorType;
14
+ /** 是否加载中 */
15
+ loading?: boolean;
16
+ /** 自定义图标 */
17
+ icon?: ReactNode;
18
+ /** 背景颜色(仅fill类型生效),未设置时使用color的0.15透明度 */
19
+ background?: string;
20
+ /** 类名 */
21
+ className?: string;
22
+ /** 子节点 */
23
+ children?: ReactNode;
24
+ /** 自定义样式 */
25
+ style?: CSSProperties;
26
+ }
27
+ declare const StatusTag: React.FC<IStatusTagProps>;
28
+ export default StatusTag;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.STATUS_TAG_TYPES = exports.PRESET_COLOR_TYPES = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactIcons = require("@dtinsight/react-icons");
9
+ var _antd = require("antd");
10
+ var _configProvider = require("antd/es/config-provider");
11
+ var _classnames = _interopRequireDefault(require("classnames"));
12
+ require("./style");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ 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 && Object.prototype.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; }
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
17
+ const PRESET_COLOR_TYPES = exports.PRESET_COLOR_TYPES = Object.freeze(['blue', 'yellow', 'green', 'gray', 'red', 'purple', 'cyan', 'pink']);
18
+ const STATUS_TAG_TYPES = exports.STATUS_TAG_TYPES = Object.freeze(['default', 'outline', 'fill']);
19
+ const DEFAULT_OPACITY = 0.15;
20
+ /**
21
+ * 校验是否为预设颜色
22
+ * @param color 待校验颜色值
23
+ */
24
+ function isPresetColor(color) {
25
+ if (!color || typeof color !== 'string') return false;
26
+ return PRESET_COLOR_TYPES.includes(color);
27
+ }
28
+
29
+ /**
30
+ * 计算颜色的透明版本
31
+ * @param color 原始颜色(支持hex/rgb/rgba)
32
+ * @param opacity 透明度(默认0.15)
33
+ */
34
+ function calculateTransparentColor(color, opacity = DEFAULT_OPACITY) {
35
+ if (!color) return 'rgba(0, 0, 0, 0.15)';
36
+ if (color.startsWith('rgb')) {
37
+ if (color.startsWith('rgba')) return color.replace(/,\s*[\d.]+(?=\))/, `,${opacity}`);
38
+ return `${color.slice(0, -1)},${opacity})`;
39
+ }
40
+ let hex = color.trim().replace(/^#/, '');
41
+ if (hex.length === 3) {
42
+ hex = hex.split('').map(char => char + char).join('');
43
+ }
44
+ if (!/^[0-9A-Fa-f]{6}$/.test(hex)) return 'rgba(0, 0, 0, 0.15)';
45
+ const r = parseInt(hex.substring(0, 2), 16);
46
+ const g = parseInt(hex.substring(2, 4), 16);
47
+ const b = parseInt(hex.substring(4, 6), 16);
48
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
49
+ }
50
+ const StatusTag = /*#__PURE__*/_react.default.memo(props => {
51
+ const {
52
+ className,
53
+ type = 'default',
54
+ icon,
55
+ color = 'green',
56
+ loading = false,
57
+ rounded = false,
58
+ background,
59
+ style,
60
+ children,
61
+ ...restProps
62
+ } = props;
63
+ const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('status-tag');
64
+ const showDefaultIcon = (0, _react.useMemo)(() => icon === undefined, [icon]);
65
+ const containerClasses = (0, _react.useMemo)(() => (0, _classnames.default)(prefixCls, className, {
66
+ [`${prefixCls}--border`]: type === 'outline',
67
+ [`${prefixCls}--fill`]: type === 'fill',
68
+ [`${prefixCls}--rounded`]: rounded,
69
+ [`${prefixCls}__${color}--fill`]: type === 'fill' && isPresetColor(color)
70
+ }), [className, type, color, rounded, prefixCls]);
71
+ const customColorStyle = (0, _react.useMemo)(() => {
72
+ if (type !== 'fill' || isPresetColor(color)) return {};
73
+ return {
74
+ color,
75
+ background: background || calculateTransparentColor(color)
76
+ };
77
+ }, [type, color, background]);
78
+ const iconStyleConfig = (0, _react.useMemo)(() => {
79
+ if (isPresetColor(color)) {
80
+ return {
81
+ className: (0, _classnames.default)('anticon', {
82
+ [`${prefixCls}__${color}--icon`]: true,
83
+ [`${prefixCls}__icon--default`]: !icon,
84
+ [`${prefixCls}__${color}--iconBg`]: !icon
85
+ }),
86
+ style: {}
87
+ };
88
+ }
89
+ return {
90
+ className: (0, _classnames.default)('anticon', {
91
+ [`${prefixCls}__icon--default`]: !icon
92
+ }),
93
+ style: {
94
+ color: icon ? color : undefined,
95
+ background: !icon ? color : undefined
96
+ }
97
+ };
98
+ }, [color, icon, prefixCls]);
99
+ const loadingIndicator = (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_reactIcons.SpinOutlined, {
100
+ className: `${prefixCls}__icon ${prefixCls}__icon--loading`
101
+ }), [prefixCls]);
102
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, restProps, {
103
+ className: containerClasses,
104
+ style: {
105
+ ...customColorStyle,
106
+ ...style
107
+ },
108
+ "aria-busy": loading
109
+ }), loading ? /*#__PURE__*/_react.default.createElement(_antd.Spin, {
110
+ spinning: true,
111
+ indicator: loadingIndicator,
112
+ size: "small"
113
+ }) : (icon || showDefaultIcon) && /*#__PURE__*/_react.default.createElement("div", {
114
+ className: `${prefixCls}__icon`
115
+ }, /*#__PURE__*/_react.default.createElement("span", {
116
+ className: iconStyleConfig.className,
117
+ style: iconStyleConfig.style
118
+ }, icon ?? null)), children && /*#__PURE__*/_react.default.createElement("span", {
119
+ className: `${prefixCls}__text`
120
+ }, children));
121
+ });
122
+ if (process.env.NODE_ENV !== 'production') {
123
+ StatusTag.displayName = 'StatusTag';
124
+ }
125
+ var _default = exports.default = StatusTag;
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../../style/index.less");
4
+ require("./index.less");
@@ -0,0 +1,70 @@
1
+ @import '../../style/themes/index.less';
2
+ @import './mixin.less';
3
+ @import './mixin.less';
4
+
5
+ @status-tag-prefix-cls: ~'@{ant-prefix}-status-tag';
6
+
7
+ @keyframes spin {
8
+ from {
9
+ transform: rotate(0deg);
10
+ }
11
+ to {
12
+ transform: rotate(360deg);
13
+ }
14
+ }
15
+
16
+ // 主选择器
17
+ .@{status-tag-prefix-cls} {
18
+ display: flex;
19
+ align-items: center;
20
+ width: fit-content;
21
+ height: 24px;
22
+ font-size: 12px;
23
+ color: #3d446e;
24
+
25
+ .ant-spin {
26
+ font-size: 14px; // 修复 antd 字体居中问题
27
+ }
28
+
29
+ &--border {
30
+ padding: 2px 12px;
31
+ border: 1px solid #d8dae2;
32
+ background-color: #fff;
33
+ }
34
+
35
+ &--fill {
36
+ padding: 2px 12px;
37
+ }
38
+
39
+ &--rounded {
40
+ border-radius: 14px;
41
+ }
42
+
43
+ &__icon {
44
+ display: flex;
45
+ align-items: center;
46
+ font-size: 16px;
47
+ margin-right: 8px;
48
+
49
+ &--default {
50
+ display: inline-block;
51
+ width: 6px;
52
+ height: 6px;
53
+ border-radius: 50%;
54
+ }
55
+
56
+ &--loading {
57
+ animation: spin 1s linear infinite;
58
+ }
59
+ }
60
+
61
+ &__text {
62
+ font-size: 12px;
63
+ font-weight: 400;
64
+ line-height: 22px;
65
+ white-space: nowrap;
66
+ }
67
+
68
+ // 调用颜色映射 Mixin,生成所有颜色的样式
69
+ .color-map();
70
+ }
@@ -0,0 +1,39 @@
1
+ .status-color(@color, @bg) {
2
+ &--icon {
3
+ color: @color;
4
+ }
5
+ &--fill {
6
+ color: @color;
7
+ background-color: @bg;
8
+ }
9
+ &--iconBg {
10
+ background: @color;
11
+ }
12
+ }
13
+
14
+ .color-map() {
15
+ &__yellow {
16
+ .status-color(#FBB310, #FFF4D9);
17
+ }
18
+ &__blue {
19
+ .status-color(#1d78ff, #E8F1FF);
20
+ }
21
+ &__green {
22
+ .status-color(#11d782, #E7FBF7);
23
+ }
24
+ &__gray {
25
+ .status-color(#B1B4C5, #F5F5F8);
26
+ }
27
+ &__red {
28
+ .status-color(#F96C5B, #FDE9E7);
29
+ }
30
+ &__purple {
31
+ .status-color(#AC9DFF, #EAE6FF);
32
+ }
33
+ &__cyan {
34
+ .status-color(#2cccdf, #E7F8FA);
35
+ }
36
+ &__pink {
37
+ .status-color(#FF82AE, #FFE6EF);
38
+ }
39
+ }
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("./index.less");
@@ -0,0 +1 @@
1
+ @import "./themes/index.less";
File without changes
@@ -0,0 +1,2 @@
1
+ @import '~antd/es/style/themes/default.less';
2
+ @import './variable.less';
@@ -0,0 +1 @@
1
+ @primary-color-disabled: #f3f3f3;