@jswork/antd-components 1.0.106 → 1.0.108

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jswork/antd-components",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -32,7 +32,7 @@
32
32
  "postcss": "^8.5.3",
33
33
  "react": "^18.2.0",
34
34
  "react-dom": "^18.2.0",
35
- "tsup": "^7.2.0",
35
+ "tsup": "8.3.5",
36
36
  "typescript": "^5.2.2"
37
37
  },
38
38
  "publishConfig": {
@@ -44,15 +44,17 @@
44
44
  "@jswork/event-mitt": "^2.0.17",
45
45
  "@jswork/harmony-events": "^1.2.11",
46
46
  "@jswork/loadkit": "^1.0.6",
47
+ "@jswork/next-create-fetcher": "^1.0.5",
47
48
  "@jswork/next-dom-event": "^1.0.8",
48
49
  "@jswork/next-gpid": "^1.0.4",
49
50
  "@jswork/next-tree-walk": "^1.0.7",
51
+ "@jswork/next-unique": "^1.0.2",
50
52
  "@jswork/noop": "^1.0.0",
51
53
  "@jswork/react-codeflask": "^1.1.2",
52
54
  "@jswork/react-list": "^1.4.3",
53
55
  "@jswork/weibo2res": "^1.0.4",
54
56
  "fast-deep-equal": "^3.1.3",
55
- "nanoid": "^4.0.2",
57
+ "nanoid": "5.0.9",
56
58
  "react-input-autosize": "^3.0.0",
57
59
  "sortablejs": "^1.15.0"
58
60
  },
@@ -6,7 +6,6 @@ import { UploadChangeParam } from 'antd/es/upload/interface';
6
6
  import { UploadFile } from 'antd';
7
7
  import { flushSync } from 'react-dom';
8
8
 
9
- import nx from '@jswork/next';
10
9
  import '@jswork/next-gpid';
11
10
 
12
11
  const styleOpts = { id: 'viewer-style' };
@@ -17,7 +16,7 @@ const scriptURL = 'https://unpkg.com/viewerjs@1.11.1/dist/viewer.min.js';
17
16
  type StdEventTarget = { target: { value: any } };
18
17
  type StdCallback = (inEvent: StdEventTarget) => void;
19
18
 
20
- type Props = {
19
+ export type AcAbstractUploadProps = {
21
20
  className?: string;
22
21
  value?: any[] | [];
23
22
  onChange?: StdCallback;
@@ -29,7 +28,7 @@ type State = {
29
28
  fileList: any[];
30
29
  };
31
30
 
32
- export class AcAbstractUpload extends React.Component<Props, State> {
31
+ export class AcAbstractUpload extends React.Component<AcAbstractUploadProps, State> {
33
32
  protected rootRef = React.createRef<HTMLDivElement>();
34
33
  protected sortable: any = null;
35
34
  protected viewer: any = null;
@@ -43,7 +42,7 @@ export class AcAbstractUpload extends React.Component<Props, State> {
43
42
  });
44
43
  };
45
44
 
46
- constructor(inProps) {
45
+ constructor(inProps: AcAbstractUploadProps) {
47
46
  super(inProps);
48
47
  this.state = {
49
48
  fileList: this.toFileList(inProps.value)
@@ -58,7 +57,7 @@ export class AcAbstractUpload extends React.Component<Props, State> {
58
57
  await this.mountViewer(el);
59
58
  }
60
59
 
61
- shouldComponentUpdate(nextProps: Readonly<Props>): boolean {
60
+ shouldComponentUpdate(nextProps: Readonly<AcAbstractUploadProps>): boolean {
62
61
  const { value } = nextProps;
63
62
  if (value !== this.props.value) {
64
63
  this.setState({ fileList: this.toFileList(value as any[]) });
package/src/lib/alert.tsx CHANGED
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import nx from '@jswork/next';
3
2
  import { Input, InputProps, Modal } from 'antd';
4
3
 
5
4
  declare global {
@@ -14,7 +14,7 @@ const CLASS_NAME = 'ac-breadcrumb';
14
14
  type StdEventTarget = { target: { value: any } };
15
15
  type StdCallback = (inEvent: StdEventTarget) => void;
16
16
 
17
- type Props = {
17
+ export type AcBreadcrumbProps = {
18
18
  className?: string;
19
19
  items?: any[];
20
20
  template?: (args: TemplateArgs) => React.ReactNode;
@@ -22,7 +22,7 @@ type Props = {
22
22
  onChange?: StdCallback;
23
23
  } & BreadcrumbProps;
24
24
 
25
- export class AcBreadcrumb extends React.Component<Props> {
25
+ export class AcBreadcrumb extends React.Component<AcBreadcrumbProps> {
26
26
  static displayName = CLASS_NAME;
27
27
  static defaultProps = {
28
28
  onChange: noop,
@@ -38,3 +38,9 @@ export class AcBreadcrumb extends React.Component<Props> {
38
38
  );
39
39
  }
40
40
  }
41
+
42
+ export const AcBreadcrumbFc = (props: AcBreadcrumbProps) => {
43
+ return <AcBreadcrumb {...props} />;
44
+ };
45
+
46
+
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import noop from '@jswork/noop';
3
3
  import { Checkbox, Dropdown, Button, MenuProps } from 'antd';
4
4
  import { DownOutlined } from '@ant-design/icons';
5
- import nx from '@jswork/next';
6
5
  import '@jswork/next-dom-event';
7
6
  import { SizeType } from 'antd/es/config-provider/SizeContext';
8
7
 
@@ -11,7 +10,7 @@ const locales = { 'zh-CN': { selectAll: '全部' }, 'en-US': { selectAll: 'All'
11
10
  type StdEventTarget = { target: { value: any } };
12
11
  type StdCallback = (inEvent: StdEventTarget) => void;
13
12
 
14
- type Props = {
13
+ export type AcCheckableDropdownProps = {
15
14
  className?: string;
16
15
  lang?: string;
17
16
  items?: any[];
@@ -22,7 +21,7 @@ type Props = {
22
21
  onChange?: StdCallback;
23
22
  };
24
23
 
25
- export class AcCheckableDropdown extends React.Component<Props> {
24
+ export class AcCheckableDropdown extends React.Component<AcCheckableDropdownProps> {
26
25
  static displayName = CLASS_NAME;
27
26
  static formSchema = CLASS_NAME;
28
27
  static id = 1;
@@ -7,7 +7,7 @@ const CLASS_NAME = 'ac-checkbox';
7
7
  type StdEventTarget = { target: { value: any } };
8
8
  type StdCallback = (inEvent: StdEventTarget) => void;
9
9
 
10
- type AcCheckboxProps = {
10
+ export type AcCheckboxProps = {
11
11
  className?: string;
12
12
  value?: boolean;
13
13
  onChange?: StdCallback;
@@ -4,9 +4,8 @@ import noop from '@jswork/noop';
4
4
  import AutosizeInput from 'react-input-autosize';
5
5
  import { Button, Tag } from 'antd';
6
6
  import deepEqual from 'fast-deep-equal';
7
- import nx from '@jswork/next';
8
- import _ from 'lodash';
9
7
  import '@jswork/next-dom-event';
8
+ import '@jswork/next-unique';
10
9
  import { AcInteractiveList } from './interactive-list';
11
10
 
12
11
  const CLASS_NAME = 'ac-editable-tag-group';
@@ -155,7 +154,7 @@ export class AcEditableTagGroup extends React.Component<AcEditableTagGroupProps>
155
154
  let { value } = this.state;
156
155
  const len = value?.length;
157
156
  setTimeout(() => {
158
- value = _.uniq(value);
157
+ value = nx.unique(value || []);
159
158
  if (document.activeElement !== this.latestInput) {
160
159
  value = value?.filter(Boolean);
161
160
  }
@@ -7,7 +7,7 @@ const CLASS_NAME = 'ac-input-number';
7
7
  type StdEventTarget = { target: { value: any } };
8
8
  type StdCallback = (inEvent: StdEventTarget) => void;
9
9
 
10
- type AcInputNumberProps = {
10
+ export type AcInputNumberProps = {
11
11
  className?: string;
12
12
  value?: number;
13
13
  onChange?: StdCallback;
@@ -11,7 +11,7 @@ const TRIGGER_KEYS = ['Tab', 'Enter', 'Space'];
11
11
  type StdEventTarget = { target: { value: any } };
12
12
  type StdCallback = (inEvent: StdEventTarget) => void;
13
13
 
14
- type AcInputTagsProps = {
14
+ export type AcInputTagsProps = {
15
15
  className?: string;
16
16
  items?: string[];
17
17
  disabled?: boolean;
@@ -9,7 +9,7 @@ const CLASS_NAME = 'ac-input-token';
9
9
  type StdEventTarget = { target: { value: any } };
10
10
  type StdCallback = (inEvent: StdEventTarget) => void;
11
11
 
12
- type AcInputTokenProps = {
12
+ export type AcInputTokenProps = {
13
13
  className?: string;
14
14
  value?: string;
15
15
  onChange?: StdCallback;
package/src/lib/input.tsx CHANGED
@@ -7,7 +7,7 @@ const CLASS_NAME = 'ac-input';
7
7
  type StdEventTarget = { target: { value: any } };
8
8
  type StdCallback = (inEvent: StdEventTarget) => void;
9
9
 
10
- type AcInputProps = {
10
+ export type AcInputProps = {
11
11
  className?: string;
12
12
  onChange?: StdCallback;
13
13
  autoComplete?: boolean;
@@ -10,7 +10,7 @@ type StdEventTarget = { target: { value: any } };
10
10
  type StdCallback = (inEvent: StdEventTarget) => void;
11
11
  type TemplateCallback = (item: { item: any; index: number }, opts?: any) => React.ReactNode;
12
12
 
13
- type AcRadioGroupProps = {
13
+ export type AcRadioGroupProps = {
14
14
  className?: string;
15
15
  value?: any;
16
16
  defaultValue?: any;
@@ -12,7 +12,7 @@ const { RangePicker } = DatePicker;
12
12
  type StdEventTarget = { target: { value: any } };
13
13
  type StdCallback = (inEvent: StdEventTarget) => void;
14
14
 
15
- type AcRangePickerProps = {
15
+ export type AcRangePickerProps = {
16
16
  className?: string;
17
17
  value?: any;
18
18
  defaultValue?: any;
package/src/lib/rate.tsx CHANGED
@@ -7,7 +7,7 @@ const CLASS_NAME = 'ac-rate';
7
7
  type StdEventTarget = { target: { value: any } };
8
8
  type StdCallback = (inEvent: StdEventTarget) => void;
9
9
 
10
- type AcRateProps = {
10
+ export type AcRateProps = {
11
11
  className?: string;
12
12
  value?: number;
13
13
  onChange?: StdCallback;
@@ -8,7 +8,7 @@ const CLASS_NAME = 'ac-search';
8
8
  type StdEventTarget = { target: { value: any } };
9
9
  type StdCallback = (inEvent: StdEventTarget) => void;
10
10
 
11
- type AcSearchProps = {
11
+ export type AcSearchProps = {
12
12
  className?: string;
13
13
  value?: boolean;
14
14
  onChange?: StdCallback;
@@ -15,7 +15,7 @@ type StdEventTarget = { target: { value: any } };
15
15
  type StdCallback = (inEvent: StdEventTarget) => void;
16
16
  type TemplateCallback = (item: { item: any; index: number }) => React.ReactNode;
17
17
 
18
- type AcSelectProps = {
18
+ export type AcSelectProps = {
19
19
  className?: string;
20
20
  items?: any[];
21
21
  kv?: Record<string, string>;
@@ -7,7 +7,7 @@ const CLASS_NAME = 'ac-switch';
7
7
  type StdEventTarget = { target: { value: any } };
8
8
  type StdCallback = (inEvent: StdEventTarget) => void;
9
9
 
10
- type AcSwitchProps = {
10
+ export type AcSwitchProps = {
11
11
  className?: string;
12
12
  value?: boolean;
13
13
  onChange?: StdCallback;
package/src/lib/table.tsx CHANGED
@@ -4,11 +4,12 @@
4
4
  * @LastEditors: aric.zheng 1290657123@qq.com
5
5
  * @LastEditTime: 2025-10-16 08:20:55
6
6
  */
7
- import React from 'react';
7
+ import React, { FC } from 'react';
8
8
  import { Table, TableProps, message } from 'antd';
9
9
  import cx from 'classnames';
10
10
  import type { EventMittNamespace } from '@jswork/event-mitt';
11
11
  import { ReactHarmonyEvents } from '@jswork/harmony-events';
12
+ import '@jswork/next-create-fetcher';
12
13
 
13
14
  const CLASS_NAME = 'ac-table';
14
15
 
@@ -142,3 +143,28 @@ export class AcTable extends React.Component<AcTableProps, any> {
142
143
  );
143
144
  }
144
145
  }
146
+
147
+ export type AcTableMainProps = Omit<AcTableProps, 'fetcher'> & {
148
+ name: string;
149
+ dataPath?: string
150
+ totalPath?: string;
151
+ };
152
+
153
+ export const AcTableMain: FC<AcTableMainProps> = (props) => {
154
+ const { name, dataPath, totalPath, ...rest } = { dataPath: 'rows', totalPath: 'total', ...props };
155
+ const resourceId = `${name}_index`;
156
+ const fetcher = nx.createFetcher(resourceId, { dataPath, totalPath });
157
+
158
+ return (
159
+ <AcTable
160
+ size="middle"
161
+ rowKey="id"
162
+ bordered
163
+ name={name}
164
+ fetcher={fetcher}
165
+ pagination={{ showSizeChanger: true }}
166
+ {...rest}
167
+ />
168
+ );
169
+ };
170
+
@@ -9,7 +9,7 @@ type StdEventTarget = { target: { value: any } };
9
9
  type StdCallback = (inEvent: StdEventTarget) => void;
10
10
  type TemplateCallback = (item: { item: any }, options?: any) => React.ReactNode;
11
11
 
12
- type AcTransferProps = {
12
+ export type AcTransferProps = {
13
13
  className?: string;
14
14
  items?: any[];
15
15
  template: TemplateCallback;
@@ -11,7 +11,7 @@ type StdCallback = (inEvent: StdEventTarget) => void;
11
11
 
12
12
  // @see: https://github.com/afeiship/react-ant-tree-select
13
13
 
14
- type AcTreeSelectProps = {
14
+ export type AcTreeSelectProps = {
15
15
  className?: string;
16
16
  items?: any[];
17
17
  template?: any;
package/src/lib/tree.tsx CHANGED
@@ -10,7 +10,7 @@ const DEFAULT_KV = {
10
10
  value: 'value',
11
11
  };
12
12
 
13
- type Props = {
13
+ export type AcTreeProps = {
14
14
  className?: string;
15
15
  items?: any[];
16
16
  kv?: Record<string, string>;
@@ -19,7 +19,7 @@ type Props = {
19
19
  directory?: boolean;
20
20
  } & TreeProps;
21
21
 
22
- export class AcTree extends React.Component<Props> {
22
+ export class AcTree extends React.Component<AcTreeProps> {
23
23
  static displayName = CLASS_NAME;
24
24
  static formSchema = CLASS_NAME;
25
25
  static defaultProps = {
@@ -46,7 +46,6 @@ export class AcTree extends React.Component<Props> {
46
46
 
47
47
  render() {
48
48
  const { className, children, items, template, itemsKey, directory, ...props } = this.props;
49
-
50
49
  const RootComp: any = directory ? Tree.DirectoryTree : Tree;
51
50
 
52
51
  if (items?.length === 0) return null;
@@ -11,7 +11,7 @@ type StdEventTarget = { target: { value: any } };
11
11
  type StdCallback = (inEvent: StdEventTarget) => void;
12
12
  type CustomRequest = (inEvent: any) => Promise<any>;
13
13
 
14
- type AcUploadDraggerProps = {
14
+ export type AcUploadDraggerProps = {
15
15
  className?: string;
16
16
  value?: any[];
17
17
  defaultValue?: any[];
@@ -4,10 +4,9 @@ import { Space, Upload } from 'antd';
4
4
  import cx from 'classnames';
5
5
  import { UploadOutlined } from '@ant-design/icons';
6
6
 
7
- import nx from '@jswork/next';
8
7
  import weibo2res from '@jswork/weibo2res';
9
- import '@jswork/next-gpid';
10
8
  import { AcAbstractUpload } from './_abstract-upload';
9
+ import '@jswork/next-gpid';
11
10
 
12
11
  const CLASS_NAME = 'ac-upload-picture-card';
13
12
  const toWeiboPid = (inItem) => {
@@ -4,7 +4,7 @@ import { UploadOutlined } from '@ant-design/icons';
4
4
  import { Upload, Button } from 'antd';
5
5
  import cx from 'classnames';
6
6
  import { AcAbstractUpload } from './_abstract-upload';
7
- import nx from '@jswork/next';
7
+ import '@jswork/next-gpid';
8
8
 
9
9
  const CLASS_NAME = 'ac-upload-picture';
10
10
 
@@ -11,7 +11,7 @@ type StdEventTarget = { target: { value: any } };
11
11
  type StdCallback = (inEvent: StdEventTarget) => void;
12
12
  type CustomRequest = (inEvent: any) => Promise<any>;
13
13
 
14
- type AcUploadProps = {
14
+ export type AcUploadProps = {
15
15
  className?: string;
16
16
  value?: number;
17
17
  onChange?: StdCallback;
package/src/main.ts CHANGED
@@ -26,7 +26,7 @@ import { AcSelect, AcSelectFc } from './lib/select';
26
26
  import { AcSlider, AcSliderFc } from './lib/slider';
27
27
  import { AcSliderRange, AcSliderRangeFc } from './lib/slider-range';
28
28
  import { AcSwitch, AcSwitchFc } from './lib/switch';
29
- import { AcTable } from './lib/table';
29
+ import { AcTable, AcTableMain } from './lib/table';
30
30
  import { AcTextarea, AcTextareaFc } from './lib/textarea';
31
31
  import { AcTimePicker, AcTimePickerFc } from './lib/time-picker';
32
32
  import { AcTransfer, AcTransferFc } from './lib/transfer';
@@ -37,6 +37,7 @@ import { AcUploadPicture, AcUploadPictureFc } from './lib/upload-picture';
37
37
  import { AcUploadPictureCard, AcUploadPictureCardFc } from './lib/upload-picture-card';
38
38
  import { AcUpload, AcUploadFc } from './lib/upload';
39
39
 
40
+ import '@jswork/next';
40
41
  import './lib/alert';
41
42
 
42
43
  // commands
@@ -88,6 +89,7 @@ export {
88
89
  AcSliderRange,
89
90
  AcSwitch,
90
91
  AcTable,
92
+ AcTableMain,
91
93
  AcTextarea,
92
94
  AcTimePicker,
93
95
  AcTransfer,
@@ -98,7 +100,7 @@ export {
98
100
  AcUploadPictureCard,
99
101
  AcUpload,
100
102
 
101
- // --- fc ---
103
+ // --- fc components ---
102
104
  AcCheckableTagFc,
103
105
  AcCheckableTagListFc,
104
106
  AcCheckboxFc,