How to develop a component that people love?
AD |
() 2023-05-22 09:01 1~5 &AI ReactVue 1~5 1. TypeScript API API 2
() 2023-05-22 09:01
1~5 &AI
ReactVue
1~5
1. TypeScript API API
2. README Mock = link
3.VuexRedux
4.
Interface
type Size = any; // type Size = string; // type Size = "small" | "medium" | "large"; //
DOM
DOMDOMclassName classnames[1] clsx[2] className
export interface IProps {className?: string; style?: React.CSSProperties;}
data-spm dom Props
export type CommonDomProps = {className?: string; style?: React.CSSProperties;} & Record<`data-${string}`, string>// component.tsxexport interface IComponentProps extends CommonDomProps { ...}// orexport type IComponentProps = CommonDomProps & { ...}
1.export props
2.
export type IListProps{/** * Custom suffix element. * Used to append element after list */ suffix?: React.ReactNode;/** * List column definition. * This makes List acts like a Table, header depends on this property * @default [] */ columns?: IColumn[];/** * List dataSource. * Used with renderRow * @default [] */ dataSource?: Array<Record<string, any>>;}
jsdoc[3] vitdoc[4]DEMO API
AICopilot[5]
toolbar?: React.ReactNode; // List toolbar.// Columns // defaultValue is "[]" columns?: IColumns[];
string ReactNode
Input label props string label
export type IInputProps = { label?: string; // }export type IInputProps = { label?: React.ReactNode; // }
React ReactNode
export type IFormProps<T = string> = { value?: T; defaultValue?: T; onChange?: (value: T, ...args) => void;};
value
export type IVisibleProps = {/** * The visible state of the component. * If you want to control the visible state of the component, you can use this property. * @default false */ visible?: boolean;/** * The default visible state of the component. * If you want to set the default visible state of the component, you can use this property. * The component will be controlled by the visible property if it is set. * @default false */ defaultVisible?: boolean;/** * Callback when the visible state of the component changes. */ onVisibleChange?: (visible: boolean, ...args) => void;};
[6]
ahooks useControllableValue[7]
antd[8]/ fusion[9] Form
export type IFormProps = {/** * Field name */ name?: string;/** * Field label */ label?: ReactNode;/** * The status of the field */ state?: 'loading' | 'success' | 'error' | 'warning';/** * Whether the field is disabled * @default false */ disabled?: boolean;/** * Size of the field */ size?: 'small' | 'medium' | 'large';/** * The min value of the field */ min?: number;/** * The max value of the field */ max?: number;};
export interface ISelection<T extends object = Record<string, any>> {/** * The mode of selection * @default 'multiple' */ mode?: 'single' | 'multiple';/** * The selected keys */ selectedRowKeys?: string[];/** * The default selected keys */ defaultSelectedRowKeys?: string[];/** * Max count of selected keys */ maxSelection?: number;/** * Whether take a snapshot of the selected records * If true, the selected records will be stored in the state */ keepSelected?: boolean;/** * You can get the selected records by this function */ getProps?: (record: T, index: number) => { disabled?: boolean; [key: string]: any };/** * The callback when the selected keys changed */ onChange?: (selectedRowKeys: string[], records?: Array<T>, ...args: any[]) => void;/** * The callback when the selected records changed * The difference between `onChange` is that this function will return the single record */ onSelect?: (selected: boolean, record: T, records: Array<T>, ...args: any[]) => void;/** * The callback when the selected all records */ onSelectAll?: (selected: boolean, keys: string[], records: Array<T>, ...args: any[]) => void;}
Merlion UI - useSelection[10]
value mode
Select
mode="single" -> value: string | numbermode="multiple" -> value: string[] | number[]
value
Merlion UI - useCheckControllableValue[11]
url API
export type IAsyncProps { requestUrl?: string; extParams?: any;}
API API
export type IAsyncProps { requestUrl?: string; extParams?: any; beforeUpload?: (res: any) => any format?: (res: any) => any}
23API
API Promise
export type ProductList = { total: number; list: Array<{ id: string; name: string; image: string; ... }>}export type AsyncGetProductList = ( pageInfo: { current: number; pageSize: number }, searchParams: { name: string; id: string; },) => Promise<ProductList>;export type IComponentProps = {/** * The service to get product list */ loadProduct?: AsyncGetProductList;}
1 async
Hooks
- Lazada UploaderUpload + Lazada Upload Service
- Address Selector: Select + Address Service
- Brand Selector: Select + Brand Service
- ...
UI
React Hooks
export function Page() {const lzdUploadProps = useLzdUpload({ bu: 'seller' });return <Upload {...lzdUploadProps} />}
UI
Consumer
Consumer
Expand
isExpand
export type IExpandProps = { children?: (ctx: { isExpand: boolean }) => React.ReactNode;}
export function Page() {return (<Expand> {({ isExpand }) => { return isExpand ? <Table /> : <AnotherTable />; }}</Expand> );}
package.json
repository : npmjs.comnpm.alibaba-inc.commc.lazada.com
package.json mainmoduletypesexports package.json
{"name": "xxx-ui","version": "1.0.0","description": "Out-of-box UI solution for enterprise applications from B-side.","author": "[email protected]","exports": {".": {"import": "./dist/esm/index.js","require": "./dist/cjs/index.js" } },"main": "./dist/cjs/index.js","module": "./dist/esm/index.js","types": "./dist/cjs/index.d.ts","repository": {"type": "git","url": "[email protected]:yee94/xxx.git" }}
README.md
DEMO
`antd` `react` `vue`
`ChatGPT`
[1]https://www.npmjs.com/package/classnames
[2]https://www.npmjs.com/package/clsx
[3]https://jsdoc.app/
[4]https://vitdocjs.github.io/
[5]https://github.com/features/copilot
[6]https://segmentfault.com/a/1190000040308582
[7]https://ahooks.js.org/hooks/use-controllable-value
[8]https://ant.design/
[9]https://github.com/alibaba-fusion/next
[10]https://mc.lazada.com/package/@ali/merlion-ui#/src/hooks/use-selection/README.md
[11]https://mc.lazada.com/package/@ali/merlion-ui#/src/hooks/use-selection/README.md
Disclaimer: The content of this article is sourced from the internet. The copyright of the text, images, and other materials belongs to the original author. The platform reprints the materials for the purpose of conveying more information. The content of the article is for reference and learning only, and should not be used for commercial purposes. If it infringes on your legitimate rights and interests, please contact us promptly and we will handle it as soon as possible! We respect copyright and are committed to protecting it. Thank you for sharing.(Email:[email protected])
Mobile advertising space rental |
Tag: How to develop component that people love
Refund No Return: The "Fleece Party" Under the Vulnerability of Amazon Platform
NextThe Smart Education Scene of Zhongxin Tianjin Ecological City at the World Intelligence Conference is Live Online Nationwide
Guess you like
-
The 2025 Chinese New Year (Spring Festival) film box office has exploded, exceeding 3 billion RMB and setting a new record for presales!Detail
2025-01-29 11:55:06 1
-
Seres and Beihang University Join Hands to Build an Innovative Ecosystem, Deepening Industry-Academia-Research Collaboration and Promoting Technological TransformationDetail
2025-01-28 14:46:18 1
-
Douyin 2024 Platform Governance Report: Safeguarding Security, Building a Better CommunityDetail
2025-01-28 14:25:55 1
-
Chinese Scientists Develop a Lightweight Bionic Dexterous Hand with 19 Degrees of Freedom, Promising to Revolutionize Prosthetic and Robotics TechnologyDetail
2025-01-28 14:16:39 1
-
DeepSeek: A Chinese AI Startup's Meteoric Rise Shakes Up Global Tech and Sends US Stocks PlungingDetail
2025-01-28 14:13:23 1
-
WeChat's New Year's Red Envelope Feature Gets a Voice Message Upgrade for Warmer Wishes!Detail
2025-01-26 11:37:36 1
-
360 Digital Security Group and Zhibangyang Education Technology Join Forces to Build a New Ecosystem for Cybersecurity and AI Talent CultivationDetail
2025-01-24 15:09:51 1
-
Visionox Achieves Mass Production of AMOLED with Solid-State Laser Annealing (SLA) Technology, Ushering in a New Era for the Display IndustryDetail
2025-01-24 14:34:23 1
-
Seres at the Davos Forum: The Path to Globalizing New Energy Vehicles Through Cooperation in the Intelligent EraDetail
2025-01-23 13:28:12 1
-
Amazon to Close All French-Speaking Quebec Warehouses, Laying Off Nearly 2,000 EmployeesDetail
2025-01-23 10:51:23 1
-
The official launch of the 2025 Electric Bicycle Trade-in Policy: Upgraded Subsidy Standards, Procedures, and PromotionDetail
2025-01-23 10:48:52 1
-
Xbox Series X|S Officially Supports External Hard Drives Larger Than 16TB: Saying Goodbye to Storage WorriesDetail
2025-01-23 10:39:19 1
-
Leaders from the Beijing Chaoyang District CPPCC Visited Quantum Leap Group, Affirming its Contributions and Future Prospects in the Silver Hair EconomyDetail
2025-01-22 17:06:56 1
-
China's Car Imports Remain Sluggish in 2024: 12% Decline, Sharp Drop in New Energy VehiclesDetail
2025-01-22 11:37:25 1
-
China Railway Group Limited (CRGL) officially debunks "speed-up" ticket booking software: Not a shortcut, but a pathway to riskDetail
2025-01-22 11:36:09 1
-
Dago Bio Completes Over $20 Million A+ Round Funding to Accelerate Novel Molecular Glue Drug DevelopmentDetail
2025-01-22 11:34:05 11
-
Rapid Degradation of Global Lake Submerged Vegetation: Satellite Observations Reveal a Critical Period of Ecosystem ShiftDetail
2025-01-22 11:29:03 1
-
Star Ace Capital Group and Abu Dhabi Investment Office Partner to Build a Global Esports Industry BenchmarkDetail
2025-01-22 11:27:50 1
-
Hisense Television Leads the 100-Inch Large-Screen Market in 2024, Achieving an Unparalleled Industry LegacyDetail
2025-01-22 11:12:49 1
-
WeChat Launches "Gifts" Feature: Streamlining Gift-Giving and Powering Social Commerce GrowthDetail
2025-01-21 16:05:45 1