@lark-project/ui-kit-plugin
Version:
Lark Project UI Kit Plugin
102 lines (101 loc) • 3.31 kB
TypeScript
/**
* Copyright (c) 2024 Lark Technologies Pte. Ltd.
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,provided that the above copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
import { CSSProperties, ReactElement } from 'react';
import type { IPortalHandler } from './portal';
/**
* dom 通用属性
*/
export interface IBaseDOMProps {
/**
* 类名
*/
className?: string;
/**
* 样式
*/
style?: CSSProperties;
}
export interface IBasePortalProps {
serviceType: string;
refer?: {
handler?: IPortalHandler;
};
/**
* init 时触发回调
*
* 为了不忘记要有return销毁,这里类型上强制有返回函数
* @returns 组件销毁时会调用 return 的函数,用于销毁一些副作用,函数不会响应引用变化
*/
onInit?: (params: {
handler: IPortalHandler;
}) => () => void;
}
/**
* 对标基础组件库 api 设置
*/
export interface IBasePopoverProps {
/**
* 自定义 trigger dom 元素
*
* 满足与semi Popover 一致的约定,以下描述引用自semi:
*
* Popover 需要将 DOM 事件监听器应用到 children 中,如果子元素是自定义的组件,你需要确保它能将属性传递至底层的 DOM 元素
*
* 同时为了计算弹出层的定位,需要获取到 children 的真实 DOM 元素,因此 Popover 支持如下类型的 children
*
* 1. Class Component,不强制绑定ref,但需要确保 props 可被透传至真实的 DOM 节点上
* 2. 使用 forwardRef 包裹后的函数式组件,将 props 与 ref 透传到 children 内真实的 DOM 节点上
* 3. 真实 DOM 节点, 如 span,div,p...
*/
children?: ReactElement;
/**
* 支持设置浮层弹出方向
*/
position?: 'left' | 'top' | 'topLeft' | 'topRight' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom' | 'bottom' | 'bottomLeft' | 'bottomRight';
}
export interface IBaseSelectProps {
/**
* 选择框默认文字
*/
placeholder?: string;
/**
* 是否禁用
*/
disabled?: boolean;
/**
* 多选模式下,已选项超出 maxTagCount 时,后续选项会被渲染成+N 的形式
*/
maxTagCount?: number;
/**
* 是否多选
*/
multiple?: boolean;
/**
* 是否展示清除按钮
*/
showClear?: boolean;
}
/**
* 通用错误表达结构
*/
export interface IError {
/**
* 错误码,一般非0表示存在错误
*/
c: number;
/**
* 当有错误时,提供对应的错误描述信息
*/
m: string;
}