@cozeloop/components 0.0.3 → 0.0.4

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 (165) hide show
  1. package/package.json +9 -3
  2. package/.eslintcache +0 -1
  3. package/.rush/temp/shrinkwrap-deps.json +0 -770
  4. package/OWNERS +0 -5
  5. package/config/rush-project.json +0 -8
  6. package/eslint.config.js +0 -7
  7. package/rslib.config.js +0 -7
  8. package/script/publish.js +0 -146
  9. package/src/base-search-select/base-search-form-select.tsx +0 -10
  10. package/src/base-search-select/base-search-select.tsx +0 -200
  11. package/src/base-search-select/index.module.less +0 -16
  12. package/src/base-search-select/index.tsx +0 -3
  13. package/src/base-search-select/types.ts +0 -16
  14. package/src/base-search-select/utils.ts +0 -78
  15. package/src/basic-card/index.tsx +0 -23
  16. package/src/card-pane/index.module.less +0 -14
  17. package/src/card-pane/index.tsx +0 -25
  18. package/src/chip-select/index.module.less +0 -17
  19. package/src/chip-select/index.tsx +0 -7
  20. package/src/code-editor/index.tsx +0 -9
  21. package/src/code-usage/code-item.module.less +0 -32
  22. package/src/code-usage/index.tsx +0 -91
  23. package/src/codemirror-editor/code-editor.tsx +0 -139
  24. package/src/codemirror-editor/index.ts +0 -4
  25. package/src/codemirror-editor/json-editor.tsx +0 -183
  26. package/src/codemirror-editor/raw-text-editor.tsx +0 -68
  27. package/src/codemirror-editor/text-editor.tsx +0 -58
  28. package/src/codemirror-editor/themes/coze-dark.ts +0 -116
  29. package/src/codemirror-editor/themes/coze-light.ts +0 -122
  30. package/src/collapse-card/index.module.less +0 -27
  31. package/src/collapse-card/index.tsx +0 -93
  32. package/src/collapsible-card/index.module.less +0 -63
  33. package/src/collapsible-card/index.tsx +0 -57
  34. package/src/column-manage-storage/index.tsx +0 -64
  35. package/src/columns-select/index.tsx +0 -244
  36. package/src/edit-icon-button/index.tsx +0 -36
  37. package/src/footer-actions/index.tsx +0 -33
  38. package/src/hooks/use-infinite-scroll.ts +0 -183
  39. package/src/hooks/use-mouse-down-offset.ts +0 -50
  40. package/src/hooks/use-unsave-leave-warning.ts +0 -49
  41. package/src/id-render/icon-button-container.tsx +0 -37
  42. package/src/id-render/index.tsx +0 -64
  43. package/src/index-controller/record-navigation.tsx +0 -57
  44. package/src/index-controller/use-item-index-controller.ts +0 -197
  45. package/src/index.ts +0 -208
  46. package/src/infinite-scroll-table/index.tsx +0 -99
  47. package/src/info-tooltip/index.tsx +0 -41
  48. package/src/input-components/radio-button.tsx +0 -63
  49. package/src/input-slider/index.module.less +0 -30
  50. package/src/input-slider/index.tsx +0 -161
  51. package/src/input-with-count/index.tsx +0 -31
  52. package/src/jump-button/jump-icon-button.tsx +0 -12
  53. package/src/large-txt-render/index.tsx +0 -46
  54. package/src/layout/content.tsx +0 -28
  55. package/src/layout/header.tsx +0 -15
  56. package/src/layout/index.module.less +0 -28
  57. package/src/layout/index.tsx +0 -9
  58. package/src/layout/tabs.tsx +0 -11
  59. package/src/lazy-load-component/index.tsx +0 -55
  60. package/src/logic-editor/index.ts +0 -3
  61. package/src/logic-editor/logic-editor.module.less +0 -13
  62. package/src/logic-editor/logic-editor.tsx +0 -200
  63. package/src/logic-editor/logic-left-render.tsx +0 -100
  64. package/src/logic-editor/logic-operator-render.tsx +0 -54
  65. package/src/logic-editor/logic-right-render.tsx +0 -51
  66. package/src/logic-editor/logic-types.tsx +0 -238
  67. package/src/logic-editor/utils.ts +0 -22
  68. package/src/logic-expr/assets/select.svg +0 -1
  69. package/src/logic-expr/consts.ts +0 -6
  70. package/src/logic-expr/expr-group-render.tsx +0 -238
  71. package/src/logic-expr/expr-render.tsx +0 -226
  72. package/src/logic-expr/index.module.less +0 -252
  73. package/src/logic-expr/index.ts +0 -13
  74. package/src/logic-expr/logic-expr.tsx +0 -261
  75. package/src/logic-expr/logic-not.tsx +0 -46
  76. package/src/logic-expr/logic-toggle.tsx +0 -96
  77. package/src/logic-expr/types.ts +0 -95
  78. package/src/loop-radio-group/index.tsx +0 -16
  79. package/src/multi-part-editor/components/image-item-renderer.tsx +0 -134
  80. package/src/multi-part-editor/components/index.module.less +0 -21
  81. package/src/multi-part-editor/components/multipart-item-renderer.tsx +0 -74
  82. package/src/multi-part-editor/components/url-input-modal.tsx +0 -317
  83. package/src/multi-part-editor/components/video-item-renderer.tsx +0 -145
  84. package/src/multi-part-editor/index.module.less +0 -8
  85. package/src/multi-part-editor/index.tsx +0 -571
  86. package/src/multi-part-editor/multi-part-render.tsx +0 -87
  87. package/src/multi-part-editor/type.tsx +0 -103
  88. package/src/multi-part-editor/upload-button.tsx +0 -256
  89. package/src/multi-part-editor/utils.ts +0 -64
  90. package/src/open-detail-button/index.tsx +0 -30
  91. package/src/page-content/index.tsx +0 -99
  92. package/src/primary-page/index.tsx +0 -1
  93. package/src/primary-page/primary-header.tsx +0 -64
  94. package/src/primary-title/index.module.less +0 -14
  95. package/src/primary-title/index.tsx +0 -18
  96. package/src/provider/index.tsx +0 -89
  97. package/src/resizable-side-sheet/index.tsx +0 -69
  98. package/src/resize-sidesheet/index.module.less +0 -14
  99. package/src/resize-sidesheet/index.tsx +0 -68
  100. package/src/resize-sidesheet/use-drag.ts +0 -43
  101. package/src/schema-editor/index.tsx +0 -52
  102. package/src/search-form/index.tsx +0 -134
  103. package/src/semi-schema-form/components/tmpls/array-field-item.tsx +0 -97
  104. package/src/semi-schema-form/components/tmpls/array-field.tsx +0 -127
  105. package/src/semi-schema-form/components/tmpls/base-input.tsx +0 -126
  106. package/src/semi-schema-form/components/tmpls/description-field.tsx +0 -23
  107. package/src/semi-schema-form/components/tmpls/error-list.tsx +0 -44
  108. package/src/semi-schema-form/components/tmpls/field-error.tsx +0 -33
  109. package/src/semi-schema-form/components/tmpls/field.tsx +0 -54
  110. package/src/semi-schema-form/components/tmpls/icon-button.tsx +0 -112
  111. package/src/semi-schema-form/components/tmpls/index.ts +0 -39
  112. package/src/semi-schema-form/components/tmpls/object-field.tsx +0 -173
  113. package/src/semi-schema-form/components/tmpls/submit.tsx +0 -31
  114. package/src/semi-schema-form/components/tmpls/title-field.tsx +0 -30
  115. package/src/semi-schema-form/components/widgets/checkbox.tsx +0 -67
  116. package/src/semi-schema-form/components/widgets/checkboxs.tsx +0 -100
  117. package/src/semi-schema-form/components/widgets/index.ts +0 -17
  118. package/src/semi-schema-form/components/widgets/radio.tsx +0 -105
  119. package/src/semi-schema-form/components/widgets/range.tsx +0 -73
  120. package/src/semi-schema-form/components/widgets/select.tsx +0 -108
  121. package/src/semi-schema-form/components/widgets/textarea.tsx +0 -63
  122. package/src/semi-schema-form/index.tsx +0 -14
  123. package/src/sentinel-form/enum.ts +0 -16
  124. package/src/sentinel-form/index.tsx +0 -382
  125. package/src/step-nav/index.module.less +0 -45
  126. package/src/step-nav/index.tsx +0 -53
  127. package/src/table/index.module.less +0 -144
  128. package/src/table/index.tsx +0 -18
  129. package/src/table/sort-icon.tsx +0 -73
  130. package/src/table/table-with-pagination.tsx +0 -150
  131. package/src/table/table-without-pagniation.tsx +0 -66
  132. package/src/table-batch-operate/table-batch-operation.tsx +0 -47
  133. package/src/table-batch-operate/use-batch-operate.ts +0 -111
  134. package/src/table-col-actions/index.module.less +0 -8
  135. package/src/table-col-actions/index.tsx +0 -149
  136. package/src/table-cols-config/index.module.less +0 -34
  137. package/src/table-cols-config/index.tsx +0 -171
  138. package/src/table-cols-config/type.ts +0 -12
  139. package/src/table-cols-config/use-hidden-col-keys.ts +0 -53
  140. package/src/table-cols-config/util.ts +0 -56
  141. package/src/table-empty/index.tsx +0 -23
  142. package/src/table-header/index.module.less +0 -7
  143. package/src/table-header/index.tsx +0 -70
  144. package/src/tabs/index.module.less +0 -48
  145. package/src/tabs/index.tsx +0 -9
  146. package/src/text-area-pro/index.module.less +0 -5
  147. package/src/text-area-pro/index.tsx +0 -49
  148. package/src/text-with-copy/index.tsx +0 -95
  149. package/src/title-with-sub/index.tsx +0 -27
  150. package/src/tooltip-when-disabled/index.tsx +0 -23
  151. package/src/tooltip-with-disabled/index.tsx +0 -17
  152. package/src/types.d.ts +0 -24
  153. package/src/upload/index.ts +0 -39
  154. package/src/user-profile/index.tsx +0 -49
  155. package/src/utils/basic.ts +0 -29
  156. package/src/version-list/index.module.less +0 -16
  157. package/src/version-list/version-descriptions.tsx +0 -80
  158. package/src/version-list/version-item.tsx +0 -30
  159. package/src/version-list/version-list.tsx +0 -59
  160. package/src/version-list/version-switch-panel.tsx +0 -31
  161. package/tailwind.config.ts +0 -6
  162. package/tsconfig.build.json +0 -44
  163. package/tsconfig.json +0 -17
  164. package/tsconfig.misc.json +0 -28
  165. package/vitest.config.mts +0 -7
@@ -1,261 +0,0 @@
1
- /* eslint-disable complexity */
2
- import { useState } from 'react';
3
-
4
- import { cloneDeep, get, isNumber, set } from 'lodash-es';
5
-
6
- import type { Expr, ExprGroup, LogicExprProps } from './types';
7
- import { ExprGroupRender } from './expr-group-render';
8
-
9
- function getObjectPath(path?: string, index?: number) {
10
- let groupPath = path
11
- ? path
12
- .split('-')
13
- .map(p => `childExprGroups[${p}]`)
14
- .join('.')
15
- : '';
16
- if (isNumber(index)) {
17
- groupPath = `${groupPath}${groupPath ? '.' : ''}exprs[${index}]`;
18
- }
19
- return groupPath;
20
- }
21
-
22
- function splitPath(path: string): [string, string] {
23
- const last = path.lastIndexOf('-');
24
- if (last === -1) {
25
- return ['', path];
26
- }
27
- return [path.substring(0, last), path.substring(last + 1)];
28
- }
29
-
30
- // eslint-disable-next-line @coze-arch/max-line-per-function
31
- export function LogicExpr<L = string, O = string, R = string>({
32
- defaultExpr,
33
- value,
34
- onChange: _onChange,
35
- ...restProps
36
- }: LogicExprProps<L, O, R>) {
37
- const [singleTag, setSingleTag] = useState(value?.exprs?.length === 1);
38
-
39
- // 通用特化逻辑处理
40
- const onChange = (exprGroup?: ExprGroup<L, O, R>) => {
41
- let processedExprGroup = exprGroup;
42
- if (
43
- (!exprGroup?.childExprGroups || exprGroup.childExprGroups.length === 0) &&
44
- exprGroup?.exprs?.length === 1
45
- ) {
46
- processedExprGroup = {
47
- exprs: exprGroup.exprs,
48
- };
49
- }
50
- _onChange?.(processedExprGroup);
51
- };
52
-
53
- const onExprGroupChange = (exprGroup: ExprGroup<L, O, R>, path: string) => {
54
- const objectPath = getObjectPath(path);
55
- if (!value || !objectPath) {
56
- onChange(exprGroup);
57
- return;
58
- }
59
- const newValue = set(cloneDeep(value), objectPath, exprGroup);
60
-
61
- onChange(newValue);
62
- };
63
-
64
- const onExprChange = (expr: Expr<L, O, R>, path: string, index: number) => {
65
- if (!value) {
66
- setSingleTag(true);
67
- onChange({
68
- exprs: [expr],
69
- });
70
- return;
71
- }
72
- const objectPath = getObjectPath(path, index);
73
- const newValue = set(cloneDeep(value), objectPath, expr);
74
-
75
- onChange(newValue);
76
- };
77
-
78
- const onAddExprItem = (path: string) => {
79
- const clonedDefaultExpr = cloneDeep(defaultExpr);
80
- if (!value) {
81
- onExprChange(clonedDefaultExpr, path, 0);
82
- return;
83
- }
84
-
85
- const clonedGroupValue = cloneDeep(value);
86
- const targetGroupValue: ExprGroup<L, O, R> = path
87
- ? get(clonedGroupValue, getObjectPath(path))
88
- : clonedGroupValue;
89
-
90
- if (targetGroupValue.exprs?.length) {
91
- targetGroupValue.exprs.push(clonedDefaultExpr);
92
- } else {
93
- targetGroupValue.exprs = [clonedDefaultExpr];
94
- }
95
-
96
- onExprGroupChange(targetGroupValue, path);
97
- };
98
-
99
- const onAddExprGroup = (path: string) => {
100
- const clonedDefaultExpr = cloneDeep(defaultExpr);
101
- const emptyGroup: ExprGroup<L, O, R> = {
102
- exprs: [clonedDefaultExpr],
103
- };
104
- if (!value) {
105
- setSingleTag(false);
106
- onExprGroupChange(emptyGroup, path);
107
- return;
108
- }
109
-
110
- const clonedGroupValue = cloneDeep(value);
111
- const targetGroupValue: ExprGroup<L, O, R> = path
112
- ? get(clonedGroupValue, getObjectPath(path))
113
- : clonedGroupValue;
114
-
115
- if (targetGroupValue.childExprGroups?.length) {
116
- targetGroupValue.childExprGroups.push(emptyGroup);
117
- } else {
118
- targetGroupValue.childExprGroups = [emptyGroup];
119
- }
120
-
121
- onExprGroupChange(targetGroupValue, path);
122
- };
123
-
124
- const findDelPath = (path: string): string => {
125
- const [parentPath] = splitPath(path);
126
-
127
- if (!parentPath) {
128
- return path;
129
- }
130
-
131
- const parentGroup: ExprGroup<L, O, R> = get(
132
- value,
133
- getObjectPath(parentPath),
134
- );
135
-
136
- const needDeleteParent =
137
- (parentGroup.childExprGroups?.length || 0) +
138
- (parentGroup.exprs?.length || 0) <=
139
- 1;
140
-
141
- if (needDeleteParent) {
142
- return findDelPath(parentPath);
143
- }
144
-
145
- return path;
146
- };
147
-
148
- const onDeleteExprGroup = (path: string) => {
149
- if (!value) {
150
- return;
151
- }
152
-
153
- const clonedValue = cloneDeep(value);
154
-
155
- const baseDelPath = findDelPath(path);
156
-
157
- const [parentPath, selfPath] = splitPath(baseDelPath);
158
-
159
- if (!baseDelPath) {
160
- onChange(undefined);
161
- return;
162
- }
163
-
164
- if (!parentPath) {
165
- const needDeleteRoot =
166
- (clonedValue.childExprGroups?.length || 0) +
167
- (clonedValue.exprs?.length || 0) <=
168
- 1;
169
-
170
- if (needDeleteRoot) {
171
- onChange(undefined);
172
- return;
173
- }
174
- }
175
-
176
- const parentGroup: ExprGroup<L, O, R> = parentPath
177
- ? get(clonedValue, getObjectPath(parentPath))
178
- : clonedValue;
179
-
180
- const selfPathIndex = parseInt(selfPath, 10);
181
-
182
- parentGroup.childExprGroups?.splice(selfPathIndex, 1);
183
-
184
- if (
185
- parentGroup.childExprGroups?.length &&
186
- parentGroup.childExprGroups.length === 1 &&
187
- (!parentGroup.exprs || parentGroup.exprs.length === 0)
188
- ) {
189
- if (parentPath) {
190
- const newValue = set(
191
- clonedValue,
192
- getObjectPath(parentPath),
193
- parentGroup.childExprGroups[0],
194
- );
195
- onChange(newValue);
196
- } else {
197
- onChange(parentGroup.childExprGroups[0]);
198
- }
199
- return;
200
- }
201
-
202
- onChange(clonedValue);
203
- };
204
-
205
- const onDeleteExpr = (path: string, index: number) => {
206
- if (!value) {
207
- return;
208
- }
209
-
210
- const clonedValue = cloneDeep(value);
211
-
212
- const parentGroup: ExprGroup<L, O, R> = path
213
- ? get(clonedValue, getObjectPath(path))
214
- : clonedValue;
215
-
216
- const needDeleteParent =
217
- (parentGroup.childExprGroups?.length || 0) +
218
- (parentGroup.exprs?.length || 0) <=
219
- 1;
220
-
221
- if (needDeleteParent) {
222
- onDeleteExprGroup(path);
223
- restProps.onDeleteExpr?.(parentGroup?.exprs?.[index]?.left as L);
224
- } else {
225
- parentGroup?.exprs?.splice(index, 1);
226
- if (
227
- parentGroup.childExprGroups?.length &&
228
- parentGroup.childExprGroups.length === 1 &&
229
- (!parentGroup.exprs || parentGroup.exprs.length === 0)
230
- ) {
231
- if (path) {
232
- const newValue = set(
233
- clonedValue,
234
- getObjectPath(path),
235
- parentGroup.childExprGroups[0],
236
- );
237
- onChange(newValue);
238
- } else {
239
- onChange(parentGroup.childExprGroups[0]);
240
- }
241
- return;
242
- }
243
- onChange(clonedValue);
244
- }
245
- };
246
-
247
- return (
248
- <ExprGroupRender<L, O, R>
249
- path=""
250
- singleTag={singleTag}
251
- value={value}
252
- {...restProps}
253
- onExprChange={onExprChange}
254
- onExprGroupChange={onExprGroupChange}
255
- onAddItem={onAddExprItem}
256
- onAddGroup={onAddExprGroup}
257
- onDeleteExprGroup={onDeleteExprGroup}
258
- onDeleteExpr={onDeleteExpr}
259
- />
260
- );
261
- }
@@ -1,46 +0,0 @@
1
- import { type CSSProperties } from 'react';
2
-
3
- import classNames from 'classnames';
4
-
5
- import { useI18n } from '../provider';
6
-
7
- import styles from './index.module.less';
8
-
9
- interface LogicNotProps {
10
- not?: boolean;
11
- readonly?: boolean;
12
- onChange?: (not: boolean) => void;
13
- className?: string;
14
- style?: CSSProperties;
15
- }
16
-
17
- export function LogicNot(props: LogicNotProps) {
18
- const { not, readonly, onChange, className, style } = props;
19
- const I18n = useI18n();
20
- const onClick = () => {
21
- if (readonly) {
22
- return;
23
- }
24
-
25
- onChange?.(not ? false : true);
26
- };
27
-
28
- return (
29
- <div
30
- className={classNames(
31
- styles['logic-not'],
32
- {
33
- [styles['logic-not_active']]: not,
34
- },
35
- className,
36
- )}
37
- style={style}
38
- onClick={e => {
39
- e.stopPropagation();
40
- onClick();
41
- }}
42
- >
43
- {I18n.t('fornax_components_logic_expr_not')}
44
- </div>
45
- );
46
- }
@@ -1,96 +0,0 @@
1
- import classNames from 'classnames';
2
- import { Select } from '@coze-arch/coze-design';
3
-
4
- import { useI18n } from '../provider';
5
- import type { LogicOperator } from './types';
6
- import { LogicNot } from './logic-not';
7
- import { LOGIC_OPTIONS } from './consts';
8
- import { ReactComponent as SelectIcon } from './assets/select.svg';
9
-
10
- import styles from './index.module.less';
11
-
12
- interface LogicToggleProps {
13
- enableNot?: boolean;
14
- operator?: LogicOperator;
15
- not?: boolean;
16
- hideLine?: boolean;
17
- readonly?: boolean;
18
- allowLogicOperators?: LogicOperator[];
19
- onChange: (operator: LogicOperator, not: boolean) => void;
20
- }
21
-
22
- export function LogicToggle(props: LogicToggleProps) {
23
- const {
24
- operator = 'and',
25
- hideLine,
26
- enableNot,
27
- not = false,
28
- readonly,
29
- allowLogicOperators,
30
- onChange,
31
- } = props;
32
-
33
- const I18n = useI18n();
34
-
35
- const filteredLogicOptions = allowLogicOperators
36
- ? LOGIC_OPTIONS.filter(op =>
37
- allowLogicOperators.includes(op.value as LogicOperator),
38
- )
39
- : LOGIC_OPTIONS;
40
-
41
- const label =
42
- (filteredLogicOptions.find(op => op.value === operator)?.label as string) ||
43
- '-';
44
-
45
- return (
46
- <div
47
- className={classNames(styles['logic-toggle'], {
48
- [styles['logic-toggle_and']]: operator === 'and',
49
- [styles['logic-toggle_or']]: operator === 'or',
50
- [styles['logic-toggle_hide-line']]: hideLine,
51
- })}
52
- >
53
- {readonly ? (
54
- <div className={styles['logic-toggle-tag']}>{I18n.t(label)}</div>
55
- ) : (
56
- <Select
57
- size="small"
58
- showClear={false}
59
- dropdownClassName={styles['logic-toggle-select-dropdown']}
60
- triggerRender={() => (
61
- <div
62
- className={classNames(
63
- styles['logic-toggle-tag'],
64
- styles['logic-toggle-tag_edit'],
65
- )}
66
- >
67
- {enableNot ? (
68
- <LogicNot
69
- not={not}
70
- readonly={readonly}
71
- className={styles['logic-toggle-tag-not']}
72
- onChange={val => {
73
- onChange(operator, val);
74
- }}
75
- />
76
- ) : null}
77
- {I18n.t(label)}
78
- <SelectIcon className={styles['logic-toggle-tag-icon']} />
79
- </div>
80
- )}
81
- optionList={filteredLogicOptions.map(item => ({
82
- ...item,
83
- label: I18n.t((item.label ?? '') as string),
84
- }))}
85
- value={operator}
86
- onChange={val => {
87
- if (!val) {
88
- return;
89
- }
90
- onChange(val as LogicOperator, not);
91
- }}
92
- />
93
- )}
94
- </div>
95
- );
96
- }
@@ -1,95 +0,0 @@
1
- import { type CSSProperties, type ReactNode } from 'react';
2
-
3
- export type LogicOperator = 'and' | 'or';
4
-
5
- export interface Expr<L = string, O = string, R = string> {
6
- left: L;
7
- operator: O;
8
- right: R;
9
- not?: boolean;
10
- disableDeletion?: boolean;
11
- }
12
-
13
- export interface ExprGroup<L = string, O = string, R = string> {
14
- logicOperator?: LogicOperator;
15
- not?: boolean;
16
- disableDeletion?: boolean;
17
- exprs?: Expr<L, O, R>[];
18
- childExprGroups?: ExprGroup<L, O, R>[];
19
- }
20
-
21
- export interface OperatorOption {
22
- label: ReactNode | string;
23
- value: string | number;
24
- }
25
-
26
- interface BaseRenderProps<L, O, R> {
27
- expr: Expr<L, O, R>;
28
- readonly?: boolean;
29
- size?: 'small' | 'large' | 'default';
30
- onExprChange?: (expr: Partial<Expr<L, O, R>>) => void;
31
- }
32
-
33
- export interface LeftRenderProps<L, O, R> extends BaseRenderProps<L, O, R> {
34
- onChange?: (val: L) => void;
35
- }
36
-
37
- export interface RightRenderProps<L, O, R> extends BaseRenderProps<L, O, R> {
38
- onChange?: (val: R) => void;
39
- }
40
-
41
- export interface OperatorRenderProps<L, O, R> extends BaseRenderProps<L, O, R> {
42
- onChange?: (val: O) => void;
43
- }
44
-
45
- interface Props<L, O, R> {
46
- enableNot?: boolean;
47
- readonly?: boolean;
48
- leftRender?: (props: LeftRenderProps<L, O, R>) => ReactNode;
49
- operatorRender?:
50
- | ((props: OperatorRenderProps<L, O, R>) => ReactNode)
51
- | OperatorOption[];
52
- rightRender?: (props: RightRenderProps<L, O, R>) => ReactNode;
53
- errorMsgRender?: (props: RightRenderProps<L, O, R>) => ReactNode;
54
- // maxExpressions?: number;
55
- // maxExpressionGroups?: number;
56
- // maxExpressionsPerGroup?: number;
57
- elementSize?: 'small' | 'large' | 'default';
58
- className?: string;
59
- style?: CSSProperties;
60
- }
61
-
62
- export interface LogicExprProps<L, O, R> extends Props<L, O, R> {
63
- value?: ExprGroup<L, O, R>;
64
- defaultExpr: Expr<L, O, R>;
65
- allowLogicOperators?: LogicOperator[];
66
- maxNestingDepth?: number;
67
- exprGroupRenderContentItemsClassName?: string;
68
- logicToggleReadonly?: boolean;
69
- onChange?: (exprGroup?: ExprGroup<L, O, R>) => void;
70
- onDeleteExpr?: (key: L) => void;
71
- }
72
-
73
- export interface ExprGroupRenderProps<L, O, R> extends Props<L, O, R> {
74
- value?: ExprGroup<L, O, R>;
75
- singleTag?: boolean;
76
- path: string;
77
- allowLogicOperators?: LogicOperator[];
78
- maxNestingDepth?: number;
79
- exprGroupRenderContentItemsClassName?: string;
80
- logicToggleReadonly?: boolean;
81
- onExprChange?: (expr: Expr<L, O, R>, path: string, index: number) => void;
82
- onExprGroupChange?: (exprGroup: ExprGroup<L, O, R>, path: string) => void;
83
- onAddItem?: (path: string) => void;
84
- onAddGroup?: (path: string) => void;
85
- onDeleteExpr?: (path: string, index: number) => void;
86
- onDeleteExprGroup?: (path: string) => void;
87
- }
88
-
89
- export interface ExprRenderProps<L, O, R> extends Props<L, O, R> {
90
- value: Expr<L, O, R>;
91
- path: string;
92
- onChange?: (expr: Expr<L, O, R>, path: string) => void;
93
- onDelete?: (path: string) => void;
94
- renderTool?: () => React.JSX.Element;
95
- }
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import {
4
- type RadioGroupProps,
5
- RadioGroup as SemiRadioGroup,
6
- } from '@coze-arch/coze-design';
7
-
8
- export function LoopRadioGroup({ className, ...props }: RadioGroupProps) {
9
- return (
10
- <SemiRadioGroup
11
- className={classNames('!bg-semi-fill-0 !p-0', className)}
12
- type="button"
13
- {...props}
14
- />
15
- );
16
- }
@@ -1,134 +0,0 @@
1
- /* eslint-disable @coze-arch/use-error-in-catch */
2
- /* eslint-disable complexity */
3
- import React, { useState } from 'react';
4
-
5
- import classNames from 'classnames';
6
- import { StorageProvider } from '@cozeloop/api-schema/data';
7
- import {
8
- IconCozCross,
9
- IconCozEye,
10
- IconCozImageBroken,
11
- IconCozRefresh,
12
- } from '@coze-arch/coze-design/icons';
13
- import { Image, ImagePreview, Loading } from '@coze-arch/coze-design';
14
-
15
- import { ImageStatus, type MultipartItem } from '../type';
16
-
17
- interface ImageItemRendererProps {
18
- className?: string;
19
- style?: React.CSSProperties;
20
- spaceID?: Int64;
21
- item: MultipartItem;
22
- readonly?: boolean;
23
- onRemove: () => void;
24
- onChange: (item: MultipartItem) => void;
25
- uploadFile?: (params: unknown) => Promise<string>;
26
- }
27
-
28
- export const ImageItemRenderer: React.FC<ImageItemRendererProps> = ({
29
- className,
30
- style,
31
- spaceID,
32
- item,
33
- onRemove,
34
- onChange,
35
- uploadFile,
36
- readonly,
37
- }) => {
38
- const [visible, setVisible] = useState(false);
39
- const [fileLoadError, setFileLoadError] = useState(false);
40
- const status = item?.sourceImage?.status;
41
- const uri = item?.image?.uri;
42
- const url = item?.image?.thumb_url || item?.image?.url;
43
- const isError = status === ImageStatus.Error;
44
- const file = item?.sourceImage?.file as File;
45
- const retryUpload = async () => {
46
- try {
47
- onChange({
48
- ...item,
49
- sourceImage: {
50
- ...item.sourceImage,
51
- status: ImageStatus.Loading,
52
- },
53
- });
54
- const newUri = await uploadFile?.({
55
- file,
56
- fileType: 'image',
57
- spaceID,
58
- });
59
- onChange({
60
- ...item,
61
- sourceImage: {
62
- ...item.sourceImage,
63
- status: ImageStatus.Success,
64
- },
65
- image: {
66
- ...item.image,
67
- uri: newUri,
68
- storage_provider: StorageProvider.ImageX,
69
- },
70
- });
71
- } catch (error) {
72
- onChange({
73
- ...item,
74
- sourceImage: {
75
- ...item.sourceImage,
76
- status: ImageStatus.Error,
77
- },
78
- });
79
- }
80
- };
81
-
82
- return (
83
- <div className="flex flex-col">
84
- <div
85
- className={classNames('w-[64px] h-[64px] relative group', className)}
86
- style={style}
87
- >
88
- <ImagePreview
89
- src={url}
90
- visible={visible}
91
- onVisibleChange={setVisible}
92
- />
93
- <Image
94
- src={url}
95
- className="w-full h-full rounded-[6px] border border-solid coz-stroke-plus"
96
- imgStyle={{ objectFit: 'contain', width: '100%', height: '100%' }}
97
- fallback={<IconCozImageBroken className="text-[24px]" />}
98
- onError={() => setFileLoadError(true)}
99
- />
100
- {status !== ImageStatus.Loading && (
101
- <div
102
- className={`absolute inset-0 flex gap-3 items-center rounded-[6px] justify-center coz-mg-mask ${isError ? 'visible' : 'invisible'} group-hover:visible`}
103
- >
104
- {isError && !readonly && file ? (
105
- <IconCozRefresh
106
- className="text-white w-[16px] h-[16px] cursor-pointer"
107
- onClick={retryUpload}
108
- />
109
- ) : null}
110
- {(uri || url) && !fileLoadError ? (
111
- <IconCozEye
112
- className="text-white w-[16px] h-[16px] cursor-pointer"
113
- onClick={() => setVisible(true)}
114
- />
115
- ) : null}
116
- {readonly ? null : (
117
- <div className="p-[2px] text-white cursor-pointer absolute right-[-4px] top-[-4px] z-10 bg-[var(--coz-fg-secondary)] rounded-[16px] flex items-end justify-center">
118
- <IconCozCross onClick={onRemove} className="text-[12px]" />
119
- </div>
120
- )}
121
- </div>
122
- )}
123
- {status === ImageStatus.Loading && (
124
- <div className="absolute inset-0 flex items-center rounded-[6px] justify-center bg-[rgba(0,0,0,0.4)] z-10">
125
- <Loading loading color="blue" />
126
- </div>
127
- )}
128
- </div>
129
- {status === ImageStatus.Error && (
130
- <div className="text-sm text-red-500">上传失败</div>
131
- )}
132
- </div>
133
- );
134
- };
@@ -1,21 +0,0 @@
1
- .video-preview-modal{
2
- :global{
3
- .semi-modal-content{
4
- padding-bottom: 0 !important;
5
- padding-top: 8px !important;
6
- gap:6px !important;
7
- }
8
- .semi-modal-body{
9
- padding: 6px 0 0 0 !important;
10
- margin: 0 -24px !important;
11
- background: rgba(0, 0, 0);
12
- }
13
-
14
- .semi-modal-footer{
15
- display: none;
16
- }
17
- }
18
- video{
19
- object-fit: contain
20
- }
21
- }