npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

carefree-antd-transfer-search

v2.0.3

Published

穿梭框-查询

Downloads

3

Readme

carefree-antd-transfer-search

依赖安装

 npm i carefree-antd-transfer-search

参数

| 参数 | 说明 | 类型 | | :---------------- | :------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | initValue | 初始值 | Partial<{ left: Partial<StoreProps['left']>,right: Partial<StoreProps['right']>}> | | leftUseForm | 左侧 form | SimpleFormProps['form'] | | leftSearchConfig | 左侧 form 配置 | SimpleFormProps | | rightUseForm | 右侧 form | SimpleFormProps['form'] | | rightSearchConfig | 右侧 form 配置 | SimpleFormProps | | rowKey | 表格主键 | string | | columns | 表格列 | TableProps<any>['columns'] | | Api | 请求接口 | {left: ApiType<'left' \| 'right'>, right: ApiType<'left' \| 'right'>,add: ApiType<OperationType>, allAdd: ApiType<OperationType>, delete: ApiType<OperationType>,allDelete: ApiType<OperationType>} |

类型

import { SimpleFormProps } from 'carefree-antd-form';

export interface SearchProps {
  /** 左侧表单配置 */
  leftSearchConfig: SimpleFormProps;
  /** 右侧表单配置 */
  rightSearchConfig: SimpleFormProps;
  /** 查询方法  */
  onSearch: (type: 'left' | 'right') => void;
  /** 值更新 */
  onValuesChange: (value: any, allValue: any, type: 'left' | 'right') => void;
}

export type ApiType<T> = {
  /** 请求地址 */
  url: string;
  /** 其他请求配置 */
  options?: RequestOptionsInit;
  /** main 内部状态存储值 返回值为 false 不继续往下走 */
  before: (main: any, type: T) => false | object;
  /** 请求之后处理数据  返回值为 false 不继续往下走 */
  after: (response: any, type: T) => false | object;
};

export interface TransferSearchProps
  extends Omit<SearchProps, 'onSearch' | 'onValuesChange'> {
  /**  初始值 */
  initValue?: Partial<{
    left: Partial<StoreProps['left']>;
    right: Partial<StoreProps['right']>;
  }>;
  /** 左侧 form */
  leftUseForm?: SimpleFormProps['form'];
  /** 右侧侧 form */
  rightUseForm?: SimpleFormProps['form'];
  /** 表格主键 */
  rowKey: string;
  /** 表格列 */
  columns: TableProps<any>['columns'];
  /** 请求接口 */
  Api: {
    /** 左侧查询接口 */
    left: ApiType<'left' | 'right'>;
    /** 右侧查询接口 */
    right: ApiType<'left' | 'right'>;
    /** 中间操作  往左 单个 */
    add: ApiType<OperationType>;
    /** 中间操作  往左 双个 */
    allAdd: ApiType<OperationType>;
    /** 中间操作  往右 单个 */
    delete: ApiType<OperationType>;
    /** 中间操作  往右 双个 */
    allDelete: ApiType<OperationType>;
  };
}

export interface TransferSearchRef {
  /** 中间操作方法 */
  handleOperation: (type: OperationType) => Promise<void>;
  /** 翻页 */
  onPageChange: (
    page: number,
    pageSize: number,
    type: 'left' | 'right',
  ) => void;
  /** 选中 */
  onSelectedChange: (
    selectedKeys: React.Key[],
    selectedRows: any[],
    type: 'left' | 'right',
  ) => void;
  /** 查询 */
  onSearch: (type: 'left' | 'right') => Promise<void>;
  /** 状态存储数据 */
  store: Store;
  /** 更新当前组件 */
  forceUpdate: () => void;
  /** 左侧 form */
  leftUseForm: SimpleFormProps['form'];
  /** 右侧侧 form */
  rightUseForm: SimpleFormProps['form'];
}

案例

import React from 'react';
import TransferSearch from 'carefree-antd-transfer-search';

export default () => (
  <div>
    <TransferSearch
      rowKey="id"
      columns={[{ title: '标题', dataIndex: 'title' }]}
      initValue={{
        left: {
          dataList: [{ id: 1, title: '标题' }],
        },
        right: {
          dataList: [{ id: 2, title: '标题2' }],
        },
      }}
      Api={{
        // 左侧查询接口
        left: {
          url: '',
          options: {},
          before: () => ({}),
          after: () => ({}),
        },
        // 右侧查询接口
        right: {
          url: '',
          before: () => ({}),
          after: () => ({}),
        },
        // 中间按钮 往右
        add: {
          url: '',
          before: () => ({}),
          after: () => ({}),
        },
        // 中间按钮 往右
        allAdd: {
          url: '',
          before: () => ({}),
          after: () => ({}),
        },
        // 中间按钮 往左
        allDelete: {
          url: '',
          before: () => ({}),
          after: () => ({}),
        },
        // 中间按钮 往左
        delete: {
          url: '',
          before: () => ({}),
          after: () => ({}),
        },
      }}
      // 左侧查询表单配置
      leftSearch={{
        config: [
          {
            label: '标题',
            name: 'name1',
            type: 'Input',
          },
          {
            label: '标题',
            name: 'name2',
            type: 'Input',
          },
        ],
      }}
      // 右侧查询表单配置
      rightSearch={{
        config: [
          {
            label: '标题',
            name: 'name1',
            type: 'Input',
          },
          {
            label: '标题',
            name: 'name2',
            type: 'Input',
          },
        ],
      }}
    />
  </div>
);