@enableai-base/ui 1.0.0

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.
package/dist/ui.css ADDED
@@ -0,0 +1,224 @@
1
+ .color-checkbox-group {
2
+ display: flex;
3
+ row-gap: 8px;
4
+ flex-wrap: wrap;
5
+ }
6
+
7
+ .color-checkbox-item {
8
+ display: inline-flex;
9
+ align-items: center;
10
+ }
11
+
12
+ .color-checkbox-group .ant-checkbox-label {
13
+ display: flex;
14
+ align-items: center;
15
+ }
16
+
17
+ .color-checkbox-tag {
18
+ margin: 0;
19
+ cursor: pointer;
20
+ user-select: none;
21
+ }
22
+
23
+ .color-radio-group {
24
+ display: flex !important;
25
+ flex-wrap: wrap;
26
+ row-gap: 8px;
27
+ }
28
+
29
+ .color-radio-item {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ }
33
+
34
+ .color-radio-group .ant-radio-label {
35
+ display: flex;
36
+ align-items: center;
37
+ }
38
+
39
+ .color-radio-tag {
40
+ margin: 0;
41
+ cursor: pointer;
42
+ user-select: none;
43
+ }
44
+
45
+ .color-picker-button {
46
+ --cp-size: 18px;
47
+ --cp-radius: 50%;
48
+
49
+ position: relative;
50
+ width: var(--cp-size);
51
+ height: var(--cp-size);
52
+ cursor: pointer;
53
+ }
54
+
55
+ .color-picker-button:hover .color-picker-button-mask {
56
+ display: inline-block;
57
+ }
58
+
59
+ .color-picker-button .color-picker-button-mask {
60
+ position: absolute;
61
+ inset: 0;
62
+ width: var(--cp-size);
63
+ height: var(--cp-size);
64
+ border-radius: var(--cp-radius);
65
+ background: grey;
66
+ padding: 0;
67
+ opacity: 0.5;
68
+ display: none;
69
+ }
70
+
71
+ .color-picker-button .universe-icon {
72
+ position: absolute;
73
+ width: var(--cp-size);
74
+ height: var(--cp-size);
75
+ display: inline-block;
76
+
77
+ border-radius: var(--cp-radius);
78
+ padding: 4px;
79
+
80
+ font-style: normal;
81
+ font-size: 10px;
82
+ line-height: 14px;
83
+ text-align: center;
84
+ text-rendering: optimizeLegibility;
85
+ text-transform: none;
86
+ }
87
+
88
+ .color-picker-button .universe-icon svg {
89
+ transform: translate(0, -1px);
90
+ }
91
+
92
+ .color-picker-panel .ant-collapse-header {
93
+ display: none !important;
94
+ }
95
+
96
+ .content-editable-clear {
97
+ border: none;
98
+ box-shadow: none;
99
+ outline: unset;
100
+ }
101
+ .link-editor-input {
102
+ flex: 1;
103
+ overflow-wrap: anywhere;
104
+ word-break: break-all;
105
+ cursor: pointer;
106
+ }
107
+ .link-editor-form-item .item-label {
108
+ margin-bottom: 8px;
109
+ }
110
+
111
+ .option-editor {
112
+ --oe-radius: 6px;
113
+ --oe-icon-size: 24px;
114
+
115
+ border-radius: var(--oe-radius);
116
+ }
117
+
118
+ .option-editor .option-editor-title button {
119
+ color: var(--ant-color-primary) !important;
120
+ }
121
+
122
+ .option-editor .option-editor-title button:hover {
123
+ background: var(--ant-color-primary-bg-hover) !important;
124
+ }
125
+
126
+ .option-editor .option-item {
127
+ width: 100%;
128
+ height: 40px;
129
+ }
130
+
131
+ .option-editor .option-item .drag-point {
132
+ height: var(--oe-icon-size);
133
+ cursor: grab;
134
+ color: var(--ant-color-icon);
135
+ }
136
+
137
+ .option-editor .option-item .delete-button {
138
+ width: var(--oe-icon-size);
139
+ height: var(--oe-icon-size);
140
+ margin-right: 4px;
141
+ }
142
+
143
+ .option-editor .option-item .ant-btn-icon {
144
+ width: var(--oe-icon-size);
145
+ height: var(--oe-icon-size);
146
+ }
147
+
148
+ .option-editor .option-item .delete-icon {
149
+ font-size: 12px;
150
+ cursor: pointer;
151
+ color: var(--ant-color-icon);
152
+ }
153
+
154
+ .option-editor-list::-webkit-scrollbar {
155
+ width: 8px;
156
+ }
157
+
158
+ .option-editor-list::-webkit-scrollbar-track {
159
+ background: transparent;
160
+ }
161
+
162
+ .option-editor-list::-webkit-scrollbar-thumb {
163
+ border-radius: 8px;
164
+ background-color: rgba(147, 145, 145, 0.5);
165
+ }
166
+
167
+ .option-editor-list::-webkit-scrollbar-thumb:hover {
168
+ background-color: rgba(125, 125, 125, 0.6);
169
+ }
170
+
171
+ .multi-select-editor-popover-root .ant-popover-inner {
172
+ padding: 0 !important;
173
+ }
174
+
175
+ .tag-area .placeholder {
176
+ color: var(--ant-color-text-secondary);
177
+ font-size: 14px;
178
+ height: 22px;
179
+ line-height: 22px;
180
+ }
181
+
182
+ .option-item-modal .ant-modal-content {
183
+ padding: 0 !important;
184
+ box-shadow: none !important; /* 比 unset 更直观 */
185
+ }
186
+
187
+ .option-item-modal .ant-modal-mask {
188
+ background-color: rgba(0, 0, 0, 0) !important;
189
+ }
190
+
191
+ .select-editor-popover-content {
192
+ --se-radius: 6px;
193
+
194
+ min-width: 163px;
195
+ }
196
+
197
+ .select-editor-popover-content .ant-input {
198
+ height: 40px !important;
199
+ border-radius: var(--se-radius) !important;
200
+ /* input reset */
201
+ border: none !important;
202
+ outline: none !important;
203
+ box-shadow: none !important;
204
+ }
205
+
206
+ .select-editor-popover-content .icon-occupy {
207
+ display: inline-block;
208
+ width: 16px;
209
+ height: 16px;
210
+ margin-right: 4px;
211
+ flex-shrink: 0;
212
+ }
213
+
214
+ .select-editor-popover-content .option-item {
215
+ width: 100%;
216
+ padding: 4px 0 4px 8px;
217
+
218
+ display: flex;
219
+ align-items: center;
220
+
221
+ cursor: pointer;
222
+ border-radius: var(--se-radius);
223
+ transition: background-color 0.2s;
224
+ }
package/dist/ui.d.ts ADDED
@@ -0,0 +1,274 @@
1
+ /// <reference types="react" />
2
+ import * as react from 'react';
3
+ import react__default, { CSSProperties, RefObject, ChangeEvent } from 'react';
4
+ import { ButtonProps, TagProps, ColorPickerProps, InputRef, UploadProps, UploadFile } from 'antd';
5
+ import { RegistryKey } from '@enableai-fonts/font-icon-enableai-base';
6
+ import { UploadChangeParam, RcFile } from 'antd/es/upload';
7
+ import { ProFormItemProps } from '@ant-design/pro-components';
8
+
9
+ type AvatarPopoverProps = {
10
+ id: string | null;
11
+ column: {
12
+ request?: (id: string) => Promise<any>;
13
+ };
14
+ fontSize?: number;
15
+ };
16
+ /** 用户加载骨架 */
17
+ export declare const UserLoadingSkeleton: ({ fontSize }: {
18
+ fontSize: number;
19
+ }) => react.JSX.Element;
20
+ export declare const AvatarPopoverContent: FC<AvatarPopoverProps>;
21
+
22
+ export interface BlinkButtonRef {
23
+ /**
24
+ * 触发闪烁
25
+ */
26
+ blink: () => void;
27
+ }
28
+ export interface BlinkButtonProps extends ButtonProps {
29
+ /** 每次闪烁的间隔(ms),默认 300 */
30
+ blinkInterval?: number;
31
+ /** 闪烁次数(一次=变暗再变亮),默认 2 */
32
+ blinkTimes?: number;
33
+ /** 变暗时的透明度,默认 0.4 */
34
+ dimOpacity?: number;
35
+ }
36
+ export declare const BlinkButton: react__default.ForwardRefExoticComponent<BlinkButtonProps & react__default.RefAttributes<BlinkButtonRef>>;
37
+
38
+ export type SelectEditorOption = {
39
+ label: string;
40
+ value: string;
41
+ color: string;
42
+ };
43
+
44
+ export type ColorCheckboxGroupProps = {
45
+ value?: SelectEditorOption[];
46
+ options?: SelectEditorOption[];
47
+ onChange?: (value: SelectEditorOption[]) => void;
48
+ disabled?: boolean;
49
+ };
50
+ export declare const ColorCheckboxGroup: FC<ColorCheckboxGroupProps>;
51
+
52
+ export type ColorRadioGroupProps = {
53
+ value?: SelectEditorOption[];
54
+ options?: SelectEditorOption[];
55
+ onChange?: (value: SelectEditorOption[]) => void;
56
+ disabled?: boolean;
57
+ };
58
+ export declare const ColorRadioGroup: FC<ColorRadioGroupProps>;
59
+
60
+ type CustomTagProps = {
61
+ label: react__default.ReactNode;
62
+ maxWidth?: number | string;
63
+ color?: string;
64
+ closable?: boolean;
65
+ onClose?: (value: string) => void;
66
+ style?: react__default.CSSProperties;
67
+ className?: string;
68
+ fontSize?: number;
69
+ } & Omit<TagProps, 'children'>;
70
+ export declare const CustomTag: FC<CustomTagProps>;
71
+
72
+ export type FixedColorPickerProps = {
73
+ value: string;
74
+ } & ColorPickerProps;
75
+ export declare const FixedColorPicker: ({ ...args }: FixedColorPickerProps) => react.JSX.Element;
76
+
77
+ export declare const getRandomColor: () => string;
78
+
79
+ type IconFontProps = {
80
+ name: RegistryKey;
81
+ size?: number;
82
+ color?: string;
83
+ className?: string;
84
+ style?: React.CSSProperties;
85
+ };
86
+ export declare const IconFont: ({ name, size, color, className, style }: IconFontProps) => react.JSX.Element;
87
+
88
+ type LinkValue = {
89
+ title?: string;
90
+ url?: string;
91
+ };
92
+ export type LinkEditorProps = {
93
+ value?: LinkValue;
94
+ onChange?: (value?: LinkValue) => void;
95
+ disabled?: boolean;
96
+ styles?: React.CSSProperties;
97
+ popoverStyles?: React.CSSProperties;
98
+ placeholder?: string;
99
+ };
100
+ export declare const LinkEdit: FC<LinkEditorProps>;
101
+
102
+ export declare function isFocused(el: HTMLElement | null): boolean;
103
+ export declare function focusToEnd(el: HTMLElement): void;
104
+
105
+ export type OptionEditorItemData = {
106
+ value: string;
107
+ color: string;
108
+ label: string;
109
+ };
110
+ export type OptionItemValue = {
111
+ ordinal: number;
112
+ } & OptionEditorItemData;
113
+ export type OptionEditorAction = 'move' | 'delete' | 'add' | 'edit-value';
114
+ export type OptionItemDispatchEvent = {
115
+ type: 'move' | 'edit-value';
116
+ prev: OptionItemValue;
117
+ next: OptionItemValue;
118
+ } | {
119
+ type: 'delete';
120
+ prev: OptionItemValue;
121
+ next: null;
122
+ } | {
123
+ type: 'add';
124
+ prev: null;
125
+ next: OptionItemValue;
126
+ };
127
+ export type OptionEditorItemAction = {
128
+ focusInput: () => void;
129
+ };
130
+
131
+ export type OptionItemProps = {
132
+ value: OptionItemValue;
133
+ ref?: React.Ref<OptionEditorItemAction>;
134
+ onChange: (value: OptionItemValue) => void;
135
+ onRemove: (value: OptionItemValue) => void;
136
+ onEnterKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void;
137
+ dispatch?: (e: OptionItemDispatchEvent) => void;
138
+ style?: CSSProperties;
139
+ disabled?: boolean;
140
+ };
141
+ export declare const OptionItem: ({ ref, onRemove, dispatch, value, onChange, onEnterKeyUp, style, disabled, }: OptionItemProps) => react.JSX.Element;
142
+
143
+ export type OptionEditorProps = {
144
+ initialValues: OptionEditorItemData[];
145
+ onValuesChange?: (values: OptionEditorItemData[]) => void;
146
+ dispatch?: (e: OptionItemDispatchEvent) => void;
147
+ style?: CSSProperties;
148
+ virtualConfig?: {
149
+ height?: number;
150
+ };
151
+ disabled?: boolean;
152
+ };
153
+ export declare const OptionEditor: ({ initialValues, onValuesChange, virtualConfig, dispatch, style, disabled, }: OptionEditorProps) => react.JSX.Element;
154
+
155
+ type OptionInputProps = {
156
+ optionPosition: {
157
+ x: number;
158
+ y: number;
159
+ width: number;
160
+ height: number;
161
+ };
162
+ option: SelectEditorOption;
163
+ inputValue: string;
164
+ setInputValue: (value: string) => void;
165
+ updateOptionLabel: (value: string, color?: string) => void;
166
+ };
167
+ export declare const OptionInput: FC<OptionInputProps>;
168
+
169
+ export declare const COLOR_BG_OPTION_HOVER = "#1f232914";
170
+ type OptionItemProp = {
171
+ option: SelectEditorOption;
172
+ multiple?: boolean;
173
+ onCreate?: (option: SelectEditorOption) => Promise<SelectEditorOption>;
174
+ onSelect?: (option: SelectEditorOption) => void;
175
+ onChange?: (option: SelectEditorOption[]) => void;
176
+ filterOptions: SelectEditorOption[];
177
+ fontSize?: number;
178
+ style?: CSSProperties;
179
+ editValue: SelectEditorOption[];
180
+ onOptionChange?: (option: SelectEditorOption) => void;
181
+ };
182
+ export declare const SelectOptionItem: ({ editValue, option, multiple, onCreate, onChange, filterOptions, onOptionChange, onSelect, fontSize, style, }: OptionItemProp) => react.JSX.Element;
183
+
184
+ export declare const BORDER_SECONDARY_COLOR = "#f0f0f0";
185
+ type PopoverContentProps = {
186
+ editValue: SelectEditorOption[];
187
+ popoverRef: RefObject<HTMLDivElement | null>;
188
+ inputRef: RefObject<InputRef | null>;
189
+ open: boolean;
190
+ width: number | string;
191
+ filteredOptions: SelectEditorOption[];
192
+ searchText: string;
193
+ handleSearch: (e: ChangeEvent<HTMLInputElement>) => void;
194
+ listHeight: number;
195
+ itemHeight: number;
196
+ emptyText: string;
197
+ multiple: boolean;
198
+ onChange?: (option: SelectEditorOption[]) => void;
199
+ onSelect: (option: SelectEditorOption) => void;
200
+ onCreate: (option: SelectEditorOption) => Promise<SelectEditorOption>;
201
+ fontSize?: number;
202
+ onOptionChange?: (option: SelectEditorOption) => void;
203
+ };
204
+ export declare const PopoverContent: FC<PopoverContentProps>;
205
+
206
+ export type SelectProps = {
207
+ width?: number;
208
+ fontSize?: number;
209
+ listHeight?: number;
210
+ itemHeight?: number;
211
+ multiple?: boolean;
212
+ emptyText?: string;
213
+ options?: SelectEditorOption[];
214
+ value?: SelectEditorOption[];
215
+ placeholder?: string;
216
+ onChange?: (value: SelectEditorOption[]) => void;
217
+ onDeselect?: (option: SelectEditorOption) => void;
218
+ onSelect?: (option: SelectEditorOption) => void;
219
+ onOptionChange?: (option: SelectEditorOption) => void;
220
+ onOptionCreate?: (option: SelectEditorOption) => Promise<SelectEditorOption>;
221
+ tagAreaHeight?: number;
222
+ tagAreaWidth?: number;
223
+ tagAreaStyle?: React.CSSProperties;
224
+ showDownIcon?: boolean;
225
+ };
226
+ export declare const Select: FC<SelectProps>;
227
+
228
+ export type UploadFunction = <File extends {
229
+ file: any;
230
+ type: string;
231
+ }>(file: File, path: string, onProgress?: (event: {
232
+ percent: number;
233
+ loaded: number;
234
+ total: number;
235
+ bps: number;
236
+ }) => void) => Promise<any>;
237
+
238
+ export type FileInfo = {
239
+ name: string;
240
+ path: string;
241
+ };
242
+ export type UploadListProps = {
243
+ previewTitle?: string;
244
+ onlyOne?: boolean;
245
+ maxCount?: number;
246
+ value?: FileInfo[];
247
+ onChange?: (value: FileInfo[]) => void;
248
+ onPreview?: (value: FileInfo) => void;
249
+ uploadFunction: UploadFunction;
250
+ itemProps?: ProFormItemProps;
251
+ uploadProps?: UploadProps;
252
+ accept?: string;
253
+ disabled?: boolean;
254
+ };
255
+
256
+ type UploadListInnerProps = {
257
+ uploadProps?: UploadProps;
258
+ maxCount?: number;
259
+ fileList?: UploadFile<any>[];
260
+ onChange?: (info: UploadChangeParam<UploadFile<any>>) => void;
261
+ onPreview?: (fileInfo: FileInfo) => void;
262
+ accept?: string | undefined;
263
+ onRemove?: (file: UploadFile<any>) => void;
264
+ beforeUpload?: (file: RcFile) => boolean;
265
+ uploadFunction: UploadFunction;
266
+ disabled?: boolean;
267
+ };
268
+ export declare const UploadListInner: FC<UploadListInnerProps>;
269
+
270
+ export declare const computeSHA256: (file: File) => Promise<string>;
271
+
272
+ export declare const UploadList: FC<UploadListProps>;
273
+
274
+