@cozeloop/components 0.0.3 → 0.0.5

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 (169) hide show
  1. package/dist/es/index.js +1 -1
  2. package/dist/lib/code-editor/index.js +3 -1
  3. package/dist/lib/code-editor/index.js.map +1 -1
  4. package/dist/lib/tsconfig.build.tsbuildinfo +1 -1
  5. package/package.json +9 -3
  6. package/.eslintcache +0 -1
  7. package/.rush/temp/shrinkwrap-deps.json +0 -770
  8. package/OWNERS +0 -5
  9. package/config/rush-project.json +0 -8
  10. package/eslint.config.js +0 -7
  11. package/rslib.config.js +0 -7
  12. package/script/publish.js +0 -146
  13. package/src/base-search-select/base-search-form-select.tsx +0 -10
  14. package/src/base-search-select/base-search-select.tsx +0 -200
  15. package/src/base-search-select/index.module.less +0 -16
  16. package/src/base-search-select/index.tsx +0 -3
  17. package/src/base-search-select/types.ts +0 -16
  18. package/src/base-search-select/utils.ts +0 -78
  19. package/src/basic-card/index.tsx +0 -23
  20. package/src/card-pane/index.module.less +0 -14
  21. package/src/card-pane/index.tsx +0 -25
  22. package/src/chip-select/index.module.less +0 -17
  23. package/src/chip-select/index.tsx +0 -7
  24. package/src/code-editor/index.tsx +0 -9
  25. package/src/code-usage/code-item.module.less +0 -32
  26. package/src/code-usage/index.tsx +0 -91
  27. package/src/codemirror-editor/code-editor.tsx +0 -139
  28. package/src/codemirror-editor/index.ts +0 -4
  29. package/src/codemirror-editor/json-editor.tsx +0 -183
  30. package/src/codemirror-editor/raw-text-editor.tsx +0 -68
  31. package/src/codemirror-editor/text-editor.tsx +0 -58
  32. package/src/codemirror-editor/themes/coze-dark.ts +0 -116
  33. package/src/codemirror-editor/themes/coze-light.ts +0 -122
  34. package/src/collapse-card/index.module.less +0 -27
  35. package/src/collapse-card/index.tsx +0 -93
  36. package/src/collapsible-card/index.module.less +0 -63
  37. package/src/collapsible-card/index.tsx +0 -57
  38. package/src/column-manage-storage/index.tsx +0 -64
  39. package/src/columns-select/index.tsx +0 -244
  40. package/src/edit-icon-button/index.tsx +0 -36
  41. package/src/footer-actions/index.tsx +0 -33
  42. package/src/hooks/use-infinite-scroll.ts +0 -183
  43. package/src/hooks/use-mouse-down-offset.ts +0 -50
  44. package/src/hooks/use-unsave-leave-warning.ts +0 -49
  45. package/src/id-render/icon-button-container.tsx +0 -37
  46. package/src/id-render/index.tsx +0 -64
  47. package/src/index-controller/record-navigation.tsx +0 -57
  48. package/src/index-controller/use-item-index-controller.ts +0 -197
  49. package/src/index.ts +0 -208
  50. package/src/infinite-scroll-table/index.tsx +0 -99
  51. package/src/info-tooltip/index.tsx +0 -41
  52. package/src/input-components/radio-button.tsx +0 -63
  53. package/src/input-slider/index.module.less +0 -30
  54. package/src/input-slider/index.tsx +0 -161
  55. package/src/input-with-count/index.tsx +0 -31
  56. package/src/jump-button/jump-icon-button.tsx +0 -12
  57. package/src/large-txt-render/index.tsx +0 -46
  58. package/src/layout/content.tsx +0 -28
  59. package/src/layout/header.tsx +0 -15
  60. package/src/layout/index.module.less +0 -28
  61. package/src/layout/index.tsx +0 -9
  62. package/src/layout/tabs.tsx +0 -11
  63. package/src/lazy-load-component/index.tsx +0 -55
  64. package/src/logic-editor/index.ts +0 -3
  65. package/src/logic-editor/logic-editor.module.less +0 -13
  66. package/src/logic-editor/logic-editor.tsx +0 -200
  67. package/src/logic-editor/logic-left-render.tsx +0 -100
  68. package/src/logic-editor/logic-operator-render.tsx +0 -54
  69. package/src/logic-editor/logic-right-render.tsx +0 -51
  70. package/src/logic-editor/logic-types.tsx +0 -238
  71. package/src/logic-editor/utils.ts +0 -22
  72. package/src/logic-expr/assets/select.svg +0 -1
  73. package/src/logic-expr/consts.ts +0 -6
  74. package/src/logic-expr/expr-group-render.tsx +0 -238
  75. package/src/logic-expr/expr-render.tsx +0 -226
  76. package/src/logic-expr/index.module.less +0 -252
  77. package/src/logic-expr/index.ts +0 -13
  78. package/src/logic-expr/logic-expr.tsx +0 -261
  79. package/src/logic-expr/logic-not.tsx +0 -46
  80. package/src/logic-expr/logic-toggle.tsx +0 -96
  81. package/src/logic-expr/types.ts +0 -95
  82. package/src/loop-radio-group/index.tsx +0 -16
  83. package/src/multi-part-editor/components/image-item-renderer.tsx +0 -134
  84. package/src/multi-part-editor/components/index.module.less +0 -21
  85. package/src/multi-part-editor/components/multipart-item-renderer.tsx +0 -74
  86. package/src/multi-part-editor/components/url-input-modal.tsx +0 -317
  87. package/src/multi-part-editor/components/video-item-renderer.tsx +0 -145
  88. package/src/multi-part-editor/index.module.less +0 -8
  89. package/src/multi-part-editor/index.tsx +0 -571
  90. package/src/multi-part-editor/multi-part-render.tsx +0 -87
  91. package/src/multi-part-editor/type.tsx +0 -103
  92. package/src/multi-part-editor/upload-button.tsx +0 -256
  93. package/src/multi-part-editor/utils.ts +0 -64
  94. package/src/open-detail-button/index.tsx +0 -30
  95. package/src/page-content/index.tsx +0 -99
  96. package/src/primary-page/index.tsx +0 -1
  97. package/src/primary-page/primary-header.tsx +0 -64
  98. package/src/primary-title/index.module.less +0 -14
  99. package/src/primary-title/index.tsx +0 -18
  100. package/src/provider/index.tsx +0 -89
  101. package/src/resizable-side-sheet/index.tsx +0 -69
  102. package/src/resize-sidesheet/index.module.less +0 -14
  103. package/src/resize-sidesheet/index.tsx +0 -68
  104. package/src/resize-sidesheet/use-drag.ts +0 -43
  105. package/src/schema-editor/index.tsx +0 -52
  106. package/src/search-form/index.tsx +0 -134
  107. package/src/semi-schema-form/components/tmpls/array-field-item.tsx +0 -97
  108. package/src/semi-schema-form/components/tmpls/array-field.tsx +0 -127
  109. package/src/semi-schema-form/components/tmpls/base-input.tsx +0 -126
  110. package/src/semi-schema-form/components/tmpls/description-field.tsx +0 -23
  111. package/src/semi-schema-form/components/tmpls/error-list.tsx +0 -44
  112. package/src/semi-schema-form/components/tmpls/field-error.tsx +0 -33
  113. package/src/semi-schema-form/components/tmpls/field.tsx +0 -54
  114. package/src/semi-schema-form/components/tmpls/icon-button.tsx +0 -112
  115. package/src/semi-schema-form/components/tmpls/index.ts +0 -39
  116. package/src/semi-schema-form/components/tmpls/object-field.tsx +0 -173
  117. package/src/semi-schema-form/components/tmpls/submit.tsx +0 -31
  118. package/src/semi-schema-form/components/tmpls/title-field.tsx +0 -30
  119. package/src/semi-schema-form/components/widgets/checkbox.tsx +0 -67
  120. package/src/semi-schema-form/components/widgets/checkboxs.tsx +0 -100
  121. package/src/semi-schema-form/components/widgets/index.ts +0 -17
  122. package/src/semi-schema-form/components/widgets/radio.tsx +0 -105
  123. package/src/semi-schema-form/components/widgets/range.tsx +0 -73
  124. package/src/semi-schema-form/components/widgets/select.tsx +0 -108
  125. package/src/semi-schema-form/components/widgets/textarea.tsx +0 -63
  126. package/src/semi-schema-form/index.tsx +0 -14
  127. package/src/sentinel-form/enum.ts +0 -16
  128. package/src/sentinel-form/index.tsx +0 -382
  129. package/src/step-nav/index.module.less +0 -45
  130. package/src/step-nav/index.tsx +0 -53
  131. package/src/table/index.module.less +0 -144
  132. package/src/table/index.tsx +0 -18
  133. package/src/table/sort-icon.tsx +0 -73
  134. package/src/table/table-with-pagination.tsx +0 -150
  135. package/src/table/table-without-pagniation.tsx +0 -66
  136. package/src/table-batch-operate/table-batch-operation.tsx +0 -47
  137. package/src/table-batch-operate/use-batch-operate.ts +0 -111
  138. package/src/table-col-actions/index.module.less +0 -8
  139. package/src/table-col-actions/index.tsx +0 -149
  140. package/src/table-cols-config/index.module.less +0 -34
  141. package/src/table-cols-config/index.tsx +0 -171
  142. package/src/table-cols-config/type.ts +0 -12
  143. package/src/table-cols-config/use-hidden-col-keys.ts +0 -53
  144. package/src/table-cols-config/util.ts +0 -56
  145. package/src/table-empty/index.tsx +0 -23
  146. package/src/table-header/index.module.less +0 -7
  147. package/src/table-header/index.tsx +0 -70
  148. package/src/tabs/index.module.less +0 -48
  149. package/src/tabs/index.tsx +0 -9
  150. package/src/text-area-pro/index.module.less +0 -5
  151. package/src/text-area-pro/index.tsx +0 -49
  152. package/src/text-with-copy/index.tsx +0 -95
  153. package/src/title-with-sub/index.tsx +0 -27
  154. package/src/tooltip-when-disabled/index.tsx +0 -23
  155. package/src/tooltip-with-disabled/index.tsx +0 -17
  156. package/src/types.d.ts +0 -24
  157. package/src/upload/index.ts +0 -39
  158. package/src/user-profile/index.tsx +0 -49
  159. package/src/utils/basic.ts +0 -29
  160. package/src/version-list/index.module.less +0 -16
  161. package/src/version-list/version-descriptions.tsx +0 -80
  162. package/src/version-list/version-item.tsx +0 -30
  163. package/src/version-list/version-list.tsx +0 -59
  164. package/src/version-list/version-switch-panel.tsx +0 -31
  165. package/tailwind.config.ts +0 -6
  166. package/tsconfig.build.json +0 -44
  167. package/tsconfig.json +0 -17
  168. package/tsconfig.misc.json +0 -28
  169. package/vitest.config.mts +0 -7
@@ -1,89 +0,0 @@
1
- import { createContext, useContext, type ReactNode } from 'react';
2
-
3
- // I18n function type definition
4
- export type I18nFunction = (
5
- key: string,
6
- options?: Record<string, unknown>,
7
- fallbackText?: string,
8
- ) => string;
9
-
10
- // I18n object interface that matches the structure of @cozeloop/i18n-adapter
11
- export interface I18nObject {
12
- t: I18nFunction;
13
- language?: string; // en-US,zh-CN
14
- }
15
-
16
- // Context interface
17
- interface CozeLoopContextValue {
18
- i18n?: I18nFunction | I18nObject;
19
- sendEvent?: (
20
- name: string,
21
- params: Record<string, unknown>,
22
- target?: HTMLElement | string | null,
23
- ) => void;
24
- }
25
-
26
- // Create context
27
- const CozeLoopContext = createContext<CozeLoopContextValue>({});
28
-
29
- // Provider props
30
- interface CozeLoopProviderProps extends CozeLoopContextValue {
31
- children: ReactNode;
32
- }
33
-
34
- // Provider component
35
- export function CozeLoopProvider({
36
- children,
37
- i18n,
38
- sendEvent,
39
- }: CozeLoopProviderProps) {
40
- return (
41
- <CozeLoopContext.Provider value={{ i18n, sendEvent }}>
42
- {children}
43
- </CozeLoopContext.Provider>
44
- );
45
- }
46
-
47
- // Hook to use i18n - returns an object with t method to maintain I18n.t usage pattern
48
- export function useI18n(): I18nObject {
49
- const context = useContext(CozeLoopContext);
50
-
51
- if (!context.i18n) {
52
- // Fallback object when no i18n is provided
53
- return {
54
- t: (key: string) => {
55
- console.warn(
56
- `CozeLoopProvider: No i18n function provided, returning key: ${key}`,
57
- );
58
- return key;
59
- },
60
- language: 'zh-CN',
61
- };
62
- }
63
-
64
- // If context.i18n is already an object with t method, return it directly
65
- if (typeof context.i18n === 'object' && 't' in context.i18n) {
66
- return context.i18n;
67
- }
68
-
69
- // If context.i18n is a function, wrap it in an object
70
- return {
71
- t: context.i18n,
72
- };
73
- }
74
-
75
- // Hook to use sendEvent - return sendEvent function
76
- export function useReportEvent() {
77
- const context = useContext(CozeLoopContext);
78
- return (
79
- context.sendEvent ??
80
- ((name: string, params: Record<string, unknown>) => {
81
- console.info(name, params);
82
- })
83
- );
84
- }
85
-
86
- // Hook to get the full context (for advanced usage)
87
- export function useCozeLoopContext(): CozeLoopContextValue {
88
- return useContext(CozeLoopContext);
89
- }
@@ -1,69 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
-
3
- import classNames from 'classnames';
4
- import { useMouseDownOffset } from '@cozeloop/hooks';
5
- import { type SideSheetReactProps, SideSheet } from '@coze-arch/coze-design';
6
-
7
- interface ResizableSideSheetProps extends SideSheetReactProps {
8
- minSize?: number;
9
- maxSize?: number;
10
- defaultSize?: number;
11
- onResizeEnd?: (size: number) => void;
12
- }
13
-
14
- const SIZE_MAP = {
15
- small: 448,
16
- medium: 684,
17
- large: 920,
18
- };
19
- /** 仅支持 left 模式 */
20
- export const ResizableSideSheet = (props: ResizableSideSheetProps) => {
21
- const {
22
- minSize = Number.MIN_VALUE,
23
- defaultSize,
24
- maxSize = Number.MAX_VALUE,
25
- size = 'small',
26
- onResizeEnd,
27
- className,
28
- children,
29
- ...restProps
30
- } = props;
31
-
32
- const [sidePaneWidth, setSidePaneWidth] = useState(
33
- defaultSize ?? SIZE_MAP[size],
34
- );
35
- const prevWidthRef = useRef(sidePaneWidth);
36
-
37
- const { ref, isActive } = useMouseDownOffset(({ offsetX }) => {
38
- const newWidth = prevWidthRef.current - offsetX;
39
- setSidePaneWidth([maxSize, newWidth, minSize].sort((a, b) => a - b)[1]);
40
- });
41
-
42
- useEffect(() => {
43
- prevWidthRef.current = sidePaneWidth;
44
- document.body.style.cursor = isActive ? 'col-resize' : '';
45
- document.body.style.userSelect = isActive ? 'none' : 'auto';
46
- if (!isActive) {
47
- onResizeEnd?.(sidePaneWidth);
48
- }
49
- }, [isActive]);
50
- return (
51
- <SideSheet
52
- className={classNames('relative', className)}
53
- size={size}
54
- width={sidePaneWidth}
55
- {...restProps}
56
- >
57
- <div
58
- ref={ref}
59
- className={classNames(
60
- 'absolute h-full w-1 bg-white top-0 left-0 hover:cursor-col-resize hover:bg-blue-400 transition',
61
- {
62
- 'bg-blue-400 cursor-col-resize': isActive,
63
- },
64
- )}
65
- />
66
- {children}
67
- </SideSheet>
68
- );
69
- };
@@ -1,14 +0,0 @@
1
- .sheet{
2
- :global{
3
- .semi-sidesheet-header {
4
- display: flex;
5
- align-items: flex-start;
6
- padding: 18px 24px;
7
- border-bottom: 1px solid var(--semi-color-border);
8
- }
9
-
10
- .semi-sidesheet-footer{
11
- border-top: 1px solid var(--semi-color-border);
12
- }
13
- }
14
- }
@@ -1,68 +0,0 @@
1
- import cn from 'classnames';
2
- import { IconCozCrossFill } from '@coze-arch/coze-design/icons';
3
- import {
4
- type SideSheetReactProps,
5
- Divider,
6
- SideSheet,
7
- } from '@coze-arch/coze-design';
8
- import { Button } from '@coze-arch/coze-design';
9
-
10
- import { useDrag, type DragOptions } from './use-drag';
11
-
12
- import styles from './index.module.less';
13
-
14
- export const ResizeSidesheet = (
15
- props: SideSheetReactProps & {
16
- dragOptions?: DragOptions;
17
- showDivider?: boolean;
18
- disableDrag?: boolean;
19
- },
20
- ) => {
21
- const {
22
- children,
23
- dragOptions,
24
- title,
25
- onCancel,
26
- className,
27
- showDivider,
28
- disableDrag,
29
- ...rest
30
- } = props;
31
- const { containerRef, isActive, sidePaneWidth } = useDrag(dragOptions);
32
- return (
33
- <SideSheet
34
- title={
35
- <div className="flex items-center gap-2">
36
- <div className="flex-1">{title}</div>
37
- {showDivider ? (
38
- <Divider layout="vertical" className="h-[12px]" />
39
- ) : null}
40
- <Button
41
- type="primary"
42
- color="secondary"
43
- icon={<IconCozCrossFill className="w-[16px] h-[16px]" />}
44
- onClick={onCancel}
45
- />
46
- </div>
47
- }
48
- width={disableDrag ? undefined : sidePaneWidth}
49
- className={cn(styles.sheet, className)}
50
- {...rest}
51
- onCancel={onCancel}
52
- closable={false}
53
- >
54
- {disableDrag ? null : (
55
- <div
56
- ref={containerRef}
57
- className={cn(
58
- 'absolute h-full w-[2px] z-[20000] bg-transparent top-0 left-0 hover:cursor-col-resize hover:bg-[rgb(var(--coze-up-brand-9))] transition ',
59
- {
60
- 'bg-[rgb(var(--coze-up-brand-9))] cursor-col-resize': isActive,
61
- },
62
- )}
63
- />
64
- )}
65
- {props.children}
66
- </SideSheet>
67
- );
68
- };
@@ -1,43 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
-
3
- import { useMouseDownOffset } from '../hooks/use-mouse-down-offset';
4
-
5
- const DEFAULT_WIDTH = 500;
6
- const MAX_WIDTH = 800;
7
- const MIN_WIDTH = 300;
8
-
9
- export interface DragOptions {
10
- defaultWidth?: number;
11
- maxWidth?: number;
12
- minWidth?: number;
13
- onDragEnd?: (width: number) => void;
14
- }
15
-
16
- export const useDrag = (options: DragOptions = {}) => {
17
- const {
18
- defaultWidth = DEFAULT_WIDTH,
19
- maxWidth = MAX_WIDTH,
20
- minWidth = MIN_WIDTH,
21
- } = options;
22
- const [sidePaneWidth, setSidePaneWidth] = useState(defaultWidth);
23
- const prevWidthRef = useRef(sidePaneWidth);
24
- const isActiveRef = useRef(false);
25
- const { ref, isActive } = useMouseDownOffset(({ offsetX }) => {
26
- const newWidth = prevWidthRef.current - offsetX;
27
- setSidePaneWidth([maxWidth, newWidth, minWidth].sort((a, b) => a - b)[1]);
28
- });
29
- useEffect(() => {
30
- prevWidthRef.current = sidePaneWidth;
31
- document.body.style.cursor = isActive ? 'col-resize' : '';
32
- document.body.style.userSelect = isActive ? 'none' : 'auto';
33
- if (isActiveRef.current && !isActive) {
34
- options?.onDragEnd?.(sidePaneWidth);
35
- }
36
- isActiveRef.current = isActive;
37
- }, [isActive]);
38
- return {
39
- sidePaneWidth,
40
- containerRef: ref,
41
- isActive,
42
- };
43
- };
@@ -1,52 +0,0 @@
1
- import classNames from 'classnames';
2
-
3
- import {
4
- CodeMirrorJsonEditor,
5
- CodeMirrorRawTextEditor,
6
- } from '../codemirror-editor';
7
-
8
- interface SchemaEditorProps {
9
- value?: string;
10
- readOnly?: boolean;
11
- onChange?: (value?: string) => void;
12
- language?: string;
13
- placeholder?: string;
14
- showLineNumbs?: boolean;
15
- className?: string;
16
- }
17
-
18
- export const SchemaEditor = ({
19
- value,
20
- onChange,
21
- placeholder,
22
- readOnly,
23
- language,
24
- className,
25
- }: SchemaEditorProps) => (
26
- <div
27
- className={classNames(
28
- 'w-full h-[500px] border border-solid coz-stroke-primary rounded-[4px] overflow-hidden relative bg-white',
29
- { 'opacity-70': readOnly },
30
- className,
31
- )}
32
- >
33
- {language === 'json' ? (
34
- <CodeMirrorJsonEditor
35
- className="w-full h-full overflow-y-auto"
36
- onChange={onChange}
37
- value={value || ''}
38
- placeholder={placeholder}
39
- readonly={readOnly}
40
- borderRadius={4}
41
- />
42
- ) : (
43
- <CodeMirrorRawTextEditor
44
- className="w-full h-full overflow-y-auto"
45
- onChange={onChange}
46
- value={value || ''}
47
- placeholder={placeholder}
48
- readonly={readOnly}
49
- />
50
- )}
51
- </div>
52
- );
@@ -1,134 +0,0 @@
1
- /* eslint-disable security/detect-object-injection */
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- /* eslint-disable @typescript-eslint/no-explicit-any */
4
- import { useSearchParams } from 'react-router-dom';
5
- import React, {
6
- forwardRef,
7
- useCallback,
8
- useImperativeHandle,
9
- useRef,
10
- useState,
11
- } from 'react';
12
-
13
- import { omit } from 'lodash-es';
14
- import { type Form } from '@coze-arch/coze-design';
15
-
16
- import { safeJsonParse } from '@cozeloop/toolkit';
17
-
18
- export type SearchFormFilterRecord = Record<string, any>;
19
-
20
- export interface SearchFormRef {
21
- getValues: () => SearchFormFilterRecord | undefined;
22
- }
23
-
24
- interface SearchFormProps {
25
- className?: string;
26
- children: any;
27
- SemiForm: typeof Form;
28
- onSearch?: (v: SearchFormFilterRecord) => Promise<any>;
29
- initValue?: SearchFormFilterRecord;
30
- }
31
-
32
- /**
33
- * 如果对象的value为对象,将 value 转换为字符串
34
- * @param value
35
- * @returns
36
- */
37
- const stringifyObjectValue = (value: Record<string, any>) =>
38
- Object.keys(value).reduce(
39
- (acc, key) => {
40
- const val = value[key];
41
- if (typeof val === 'object') {
42
- acc[key] = JSON.stringify(val);
43
- } else {
44
- acc[key] = val;
45
- }
46
- return acc;
47
- },
48
- {} as unknown as Record<string, string>,
49
- );
50
-
51
- const parseObjectValue = (data: Record<string, string>) =>
52
- Object.keys(data).reduce(
53
- (acc, key) => {
54
- const value = data[key];
55
- if (value.startsWith('{') || value.startsWith('[')) {
56
- acc[key] = safeJsonParse(value) || value;
57
- } else {
58
- acc[key] = value;
59
- }
60
- return acc;
61
- },
62
- {} as unknown as Record<string, any>,
63
- );
64
-
65
- export const SearchForm = forwardRef<SearchFormRef, SearchFormProps>(
66
- ({ className, children, onSearch, SemiForm, initValue = {} }, ref) => {
67
- const formRef = useRef<Form<SearchFormFilterRecord>>(null);
68
-
69
- const [initValueAndParams] = useState(() => {
70
- const params = new URLSearchParams(window.location.search);
71
-
72
- const initParams: Record<string, string> = {};
73
- params.forEach((value, key) => {
74
- initParams[key] = value;
75
- });
76
-
77
- const urlValues = parseObjectValue(initParams);
78
- const defaultValue = { ...initValue, ...urlValues };
79
- const defaultSearchParams = new URLSearchParams(
80
- stringifyObjectValue(defaultValue),
81
- );
82
- const filterValue = omit(defaultValue, ['page', 'pageSize']);
83
- if (Object.keys(filterValue).length !== 0) {
84
- onSearch?.(filterValue);
85
- }
86
- return {
87
- defaultValue: filterValue,
88
- defaultSearchParams,
89
- };
90
- });
91
- const [searchParams, setSearchParams] = useSearchParams();
92
-
93
- const formValueChange = useCallback(
94
- (allValues: SearchFormFilterRecord) => {
95
- const searchResult = onSearch?.(allValues);
96
- searchResult?.then(() => {
97
- setSearchParams(
98
- prev => {
99
- const v = stringifyObjectValue(allValues || {});
100
- prev.forEach((_value, key) => {
101
- if (!['page', 'pageSize', 'tab'].includes(key)) {
102
- prev.delete(key);
103
- }
104
- });
105
- Object.keys(v).forEach(key => {
106
- prev.set(key, v[key]);
107
- });
108
- return prev;
109
- },
110
- { replace: true },
111
- );
112
- });
113
- },
114
- [searchParams],
115
- );
116
-
117
- useImperativeHandle(ref, () => ({
118
- getValues: () => formRef.current?.formApi?.getValues?.(),
119
- }));
120
-
121
- type ChangeValue = typeof initValueAndParams.defaultValue;
122
- return children ? (
123
- <SemiForm<ChangeValue>
124
- ref={formRef}
125
- initValues={initValueAndParams.defaultValue}
126
- onValueChange={formValueChange}
127
- layout="horizontal"
128
- className={className}
129
- >
130
- {children}
131
- </SemiForm>
132
- ) : null;
133
- },
134
- );
@@ -1,97 +0,0 @@
1
- /* eslint-disable complexity */
2
-
3
- import React from 'react';
4
- import {
5
- type ArrayFieldTemplateItemType,
6
- type FormContextType,
7
- type RJSFSchema,
8
- type StrictRJSFSchema,
9
- } from '@rjsf/utils';
10
- import { ButtonGroup, Col, Row } from '@coze-arch/coze-design';
11
-
12
- const BTN_GRP_STYLE = {
13
- width: '100%',
14
- };
15
-
16
- const BTN_STYLE = {
17
- width: 'calc(100% / 4)',
18
- };
19
-
20
- /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
21
- *
22
- * @param props - The `ArrayFieldTemplateItemType` props for the component
23
- */
24
- export default function ArrayFieldItemTemplate<
25
- T = unknown,
26
- S extends StrictRJSFSchema = RJSFSchema,
27
- F extends FormContextType = object,
28
- >(props: ArrayFieldTemplateItemType<T, S, F>) {
29
- const {
30
- children,
31
- disabled,
32
- hasCopy,
33
- hasMoveDown,
34
- hasMoveUp,
35
- hasRemove,
36
- hasToolbar,
37
- index,
38
- onCopyIndexClick,
39
- onDropIndexClick,
40
- onReorderClick,
41
- readonly,
42
- registry,
43
- uiSchema,
44
- } = props;
45
- const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } =
46
- registry.templates.ButtonTemplates;
47
- const { rowGutter = 24, toolbarAlign = 'top' } = registry.formContext;
48
-
49
- return (
50
- <Row align={toolbarAlign} key={`array-item-${index}`} gutter={rowGutter}>
51
- <Col span={18}>{children}</Col>
52
-
53
- {hasToolbar ? (
54
- <Col span={6}>
55
- <ButtonGroup style={BTN_GRP_STYLE}>
56
- {hasMoveUp || hasMoveDown ? (
57
- <MoveUpButton
58
- disabled={disabled || readonly || !hasMoveUp}
59
- onClick={onReorderClick(index, index - 1)}
60
- style={BTN_STYLE}
61
- uiSchema={uiSchema}
62
- registry={registry}
63
- />
64
- ) : null}
65
- {hasMoveUp || hasMoveDown ? (
66
- <MoveDownButton
67
- disabled={disabled || readonly || !hasMoveDown}
68
- onClick={onReorderClick(index, index + 1)}
69
- style={BTN_STYLE}
70
- uiSchema={uiSchema}
71
- registry={registry}
72
- />
73
- ) : null}
74
- {hasCopy ? (
75
- <CopyButton
76
- disabled={disabled || readonly}
77
- onClick={onCopyIndexClick(index)}
78
- style={BTN_STYLE}
79
- uiSchema={uiSchema}
80
- registry={registry}
81
- />
82
- ) : null}
83
- {hasRemove ? (
84
- <RemoveButton
85
- disabled={disabled || readonly}
86
- onClick={onDropIndexClick(index)}
87
- style={BTN_STYLE}
88
- uiSchema={uiSchema}
89
- registry={registry}
90
- />
91
- ) : null}
92
- </ButtonGroup>
93
- </Col>
94
- ) : null}
95
- </Row>
96
- );
97
- }
@@ -1,127 +0,0 @@
1
- import React from 'react';
2
- import cn from 'classnames';
3
- import {
4
- getTemplate,
5
- getUiOptions,
6
- type ArrayFieldTemplateProps,
7
- type ArrayFieldTemplateItemType,
8
- type FormContextType,
9
- type GenericObjectType,
10
- type RJSFSchema,
11
- type StrictRJSFSchema,
12
- } from '@rjsf/utils';
13
- import { Col, Row } from '@coze-arch/coze-design';
14
-
15
- // const DESCRIPTION_COL_STYLE = {
16
- // paddingBottom: '8px',
17
- // };
18
-
19
- /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
20
- *
21
- * @param props - The `ArrayFieldTemplateItemType` props for the component
22
- */
23
- export default function ArrayFieldTemplate<
24
- T = unknown,
25
- S extends StrictRJSFSchema = RJSFSchema,
26
- F extends FormContextType = object,
27
- >(props: ArrayFieldTemplateProps<T, S, F>) {
28
- const {
29
- canAdd,
30
- className,
31
- disabled,
32
- formContext,
33
- idSchema,
34
- items,
35
- onAddClick,
36
- readonly,
37
- registry,
38
- // required,
39
- // schema,
40
- // title,
41
- uiSchema,
42
- } = props;
43
- const uiOptions = getUiOptions<T, S, F>(uiSchema);
44
- // const ArrayFieldDescriptionTemplate = getTemplate<
45
- // 'ArrayFieldDescriptionTemplate',
46
- // T,
47
- // S,
48
- // F
49
- // >('ArrayFieldDescriptionTemplate', registry, uiOptions);
50
- const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
51
- 'ArrayFieldItemTemplate',
52
- registry,
53
- uiOptions,
54
- );
55
- // const ArrayFieldTitleTemplate = getTemplate<
56
- // 'ArrayFieldTitleTemplate',
57
- // T,
58
- // S,
59
- // F
60
- // >('ArrayFieldTitleTemplate', registry, uiOptions);
61
- // Button templates are not overridden in the uiSchema
62
- const {
63
- ButtonTemplates: { AddButton },
64
- } = registry.templates;
65
- const { rowGutter = 24 } = formContext as GenericObjectType;
66
-
67
- return (
68
- <div
69
- className={cn('p-3 semi-card-bordered rounded-[4px]', className)}
70
- id={idSchema.$id}
71
- >
72
- <Row gutter={rowGutter}>
73
- {/* {uiOptions.title || title ? (
74
- <Col span={24}>
75
- <ArrayFieldTitleTemplate
76
- idSchema={idSchema}
77
- required={required}
78
- title={uiOptions.title || title}
79
- schema={schema}
80
- uiSchema={uiSchema}
81
- registry={registry}
82
- />
83
- </Col>
84
- ) : null} */}
85
- {/* {uiOptions.description || schema.description ? (
86
- <Col span={24} style={DESCRIPTION_COL_STYLE}>
87
- <ArrayFieldDescriptionTemplate
88
- description={uiOptions.description || schema.description}
89
- idSchema={idSchema}
90
- schema={schema}
91
- uiSchema={uiSchema}
92
- registry={registry}
93
- />
94
- </Col>
95
- ) : null} */}
96
- <Col className="row array-item-list" span={24}>
97
- {items
98
- ? items.map(
99
- ({
100
- key,
101
- ...itemProps
102
- }: ArrayFieldTemplateItemType<T, S, F>) => (
103
- <ArrayFieldItemTemplate key={key} {...itemProps} />
104
- ),
105
- )
106
- : null}
107
- </Col>
108
-
109
- {canAdd ? (
110
- <Col span={24}>
111
- <Row gutter={rowGutter} justify="end">
112
- <Col span={6}>
113
- <AddButton
114
- className="array-item-add"
115
- disabled={disabled || readonly}
116
- onClick={onAddClick}
117
- uiSchema={uiSchema}
118
- registry={registry}
119
- />
120
- </Col>
121
- </Row>
122
- </Col>
123
- ) : null}
124
- </Row>
125
- </div>
126
- );
127
- }