### Basic Usage of Empty Component - React
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Empty 空状态.md
Shows the basic usage of the Empty component in React, illustrating configurations for title, content, and a button with an click handler. It includes examples with and without an image.
```tsx
import React from 'react'
import { Empty } from '@kfe/mix-ui'
import { DemoBlock } from 'demos'
export default () => {
return (
<>
alert('OK')}
/>
>
)
}
```
--------------------------------
### Basic Icon Usage
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Icons 图标.md
Shows how to render various icons with different sizes (16px and 24px) using React components from '@kfe/mix-ui'. It includes examples for different icon types like arrows, Alipay, currency, and badges.
```tsx
import React from 'react'
import {
ArrowClockwise24,
ArrowClockwise16,
ArrowDown24,
ArrowDown16,
ArrowSquarePathFill24,
ArrowSquarePathFill16,
Alipay24,
CurrencyBubbleFill24,
BadgeCgFill24
} from '@kfe/mix-ui'
import { DemoBlock } from 'demos'
export default () => {
return (
)
}
```
--------------------------------
### Empty Component: CHIPS Theme Variations
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Empty 空状态.md
Demonstrates the Empty component's CHIPS theme variations for different states. It shows examples for 'chipsLoadingError', 'chipsNoNetwork', and 'chipsContentError', each with a title, the specified image, and a 'Refresh Try' button.
```tsx
import React from 'react'
import { Empty, ConfigProvider } from '@kfe/mix-ui'
import { DemoBlock } from 'demos'
export default () => {
return (
<>
>
)
}
```
--------------------------------
### Tabs Alignment
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Tabs 标签页.md
Demonstrates how to change the alignment of the tab bar using the `align` prop, with examples for 'start' and 'center' alignments.
```tsx
import React from 'react'
import { Tabs } from '@kfe/mix-ui'
export default () => {
return (
{[1, 2, 3].map(item => (
内容 {item}
))}
{[1, 2, 3].map(item => (
内容 {item}
))}
)
}
```
--------------------------------
### 运行 Mix-UI 文档处理器
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
使用 pnpm 或 node 命令运行 Mix-UI 文档处理器。可以指定调试模式以及自定义源目录和目标目录。
```Bash
# 基本用法
pnpm process-mixui
# 或者直接使用
node dist/index.js mixui
# 启用调试模式
node dist/index.js mixui --debug
# 自定义源目录和目标目录
node dist/index.js mixui --source-dir custom/source --target-dir custom/output
```
--------------------------------
### DOMPurify Sanitization Examples
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/RichText 富文本展示.md
Provides several examples of how DOMPurify sanitizes different types of potentially malicious HTML input, demonstrating its effectiveness against various XSS vectors.
```js
DOMPurify.sanitize(' '); // becomes
DOMPurify.sanitize(''); // becomes
DOMPurify.sanitize('abc
'); // becomes abc
DOMPurify.sanitize('alert(4)">'); // becomes
DOMPurify.sanitize('HELLO '); // becomes
DOMPurify.sanitize(''); // becomes
```
--------------------------------
### 调试处理过程
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
使用 `--debug` 选项运行文档处理器,以查看详细的处理过程信息。这有助于排查问题和理解工具的行为。
```Bash
node dist/index.js mixui --debug
```
--------------------------------
### 构建项目
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
构建项目以生成可执行文件。这通常在部署或运行脚本之前完成。
```Bash
pnpm build
```
--------------------------------
### CyclicRoll Horizontal and Vertical Scrolling Example
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/CyclicRoll 跑马灯.md
Provides a React example showcasing the CyclicRoll component with both horizontal and vertical scrolling. It demonstrates setting the 'direction' prop and includes basic styling.
```tsx
import React from 'react'
import { CyclicRoll } from '@kfe/mix-ui'
import './cyclicRoll.less'
export default () => {
return (
<>
横向滚动
1
2
3
纵向滚动
1
2
3
>
)
}
```
--------------------------------
### 开发模式
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
启动 tsup 的监听模式进行开发。当文件发生变更时,会自动重新构建项目。
```Bash
pnpm dev
```
--------------------------------
### Imperative Dialog Creation Example
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Dialog 弹出框.md
Demonstrates an incorrect way to create a Dialog imperatively, where the Dialog does not react to parent component re-renders or state updates. This example highlights a common pitfall when using imperative dialogs with dynamic state.
```jsx
export default function App() {
const [captcha, setCaptcha] = useState('');
const showCaptcha = () => {
return Dialog.confirm({
title: '短信验证',
message: (
),
});
};
return Show Dialog ;
}
```
--------------------------------
### Basic HorizontalCard Usage
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/HorizontalCard 横向卡片.md
Shows the fundamental usage of the HorizontalCard component, displaying a title and custom content. This example is suitable for simple card layouts.
```tsx
import React from 'react'
import { DemoBlock } from 'demos'
import { HorizontalCard } from '@kfe/mix-ui'
export default () => {
return (
自定义内容
)
}
```
--------------------------------
### Import Steps Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/steps.md
Demonstrates how to import the Steps component from the '@kfe/mix-ui' library.
```js
import { Steps } from '@kfe/mix-ui';
```
--------------------------------
### Input Alignment Options
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Input 输入框.md
Shows how to control the text alignment within the Input component using the `align` prop. Examples include center and right alignment.
```tsx
import React, { useState } from 'react'
import { Input, Cell } from '@kfe/mix-ui'
export default () => {
const [value, setValue] = useState('')
return (
<>
|
|
>
)
}
```
--------------------------------
### 查看帮助信息
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
显示文档处理工具的帮助信息,包括可用的命令和选项。
```Bash
node dist/index.js --help
```
--------------------------------
### 安装依赖
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
安装项目所需的依赖项。通常在克隆仓库后或开始开发前执行此命令。
```Bash
pnpm install
```
--------------------------------
### Custom Column Order
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/DatetimePicker 时间选择.md
Demonstrates how to customize the order of columns in the DatetimePicker using the `columnsOrder` prop. This example sets the order to month, day, year.
```tsx
import React from 'react'
import { DatetimePicker } from '@kfe/mix-ui'
export default () => {
const [value, setValue] = React.useState(new Date())
return (
)
}
```
--------------------------------
### 添加新的文档处理器
Source: https://github.com/zvip-fe/open-docs/blob/main/README.md
展示如何通过实现 `IDocProcessor` 接口并在主入口文件中注册来扩展新的文档处理器。这允许工具处理其他组件库的文档。
```TypeScript
// scripts/processors/my-processor.ts
import { IDocProcessor, ProcessOptions } from '../types/index.js';
export class MyProcessor implements IDocProcessor {
public readonly name = 'my-library';
async process(options: ProcessOptions = {}): Promise {
// 实现你的处理逻辑
}
}
```
```TypeScript
// scripts/index.ts
import { MyProcessor } from './processors/my-processor.js';
const processors: Record = {
mixui: new MixUIProcessor(),
mylibrary: new MyProcessor(), // 添加新的处理器
};
```
--------------------------------
### Flex Layout with Direction Control
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Flex 布局.md
Demonstrates how to control the direction of flex items using the 'direction' prop. Examples include 'row' and 'row-reverse' layouts.
```tsx
import React from 'react'
import { Flex } from '@kfe/mix-ui'
import './style.less'
export default () => {
return (
span: 8-1
span: 8-2
span: 8-3
span: 8-1
span: 8-2
span: 8-3
)
}
```
--------------------------------
### Popup Positioning
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Popup 弹出层.md
Illustrates how to control the position of the Popup component using the `position` prop. It provides examples for 'top', 'bottom', 'left', and 'right' positions, triggered by different buttons.
```tsx
import React, { useState } from 'react'
import { Button, Popup, PopupPosition } from '@kfe/mix-ui'
export default () => {
const [state, setState] = useState('')
const onClose = () => setState('')
return (
<>
setState('top')}>顶部弹出
setState('bottom')}>底部弹出
setState('left')}>左侧弹出
setState('right')}>右侧弹出
>
)
}
```
--------------------------------
### Import Input Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Input 输入框.md
Demonstrates how to import the Input component from the '@kfe/mix-ui' library.
```js
import { Input } from '@kfe/mix-ui';
```
--------------------------------
### Import Loading Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Loading 加载.md
Demonstrates how to import the Loading component from the '@kfe/mix-ui' library.
```js
import { Loading } from '@kfe/mix-ui';
```
--------------------------------
### Input with Prefix and Suffix Content
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Input 输入框.md
Shows how to add custom content before (prefix) and after (suffix) the input field. This example uses an emoji as a prefix and a Button component as a suffix.
```tsx
import React from 'react'
import { Input, Cell, Button } from '@kfe/mix-ui'
export default () => {
return (
发送}
placeholder='请输入短信验证码'
/>
|
)
}
```
--------------------------------
### Import Button Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Button 按钮.md
Demonstrates how to import the Button component from the '@kfe/mix-ui' library.
```js
import { Button } from '@kfe/mix-ui';
```
--------------------------------
### Option Filter
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/DatetimePicker 时间选择.md
Shows how to filter options using the `filter` prop, allowing for custom time intervals. This example filters minutes to only show multiples of 5.
```tsx
import React from 'react'
import { DatetimePicker } from '@kfe/mix-ui'
export default () => {
return (
{
if (type === 'minute') {
return options.filter(option => +option % 5 === 0)
}
return options
}}
/>
)
}
```
--------------------------------
### CountDown with Custom Format
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/CountDown 倒计时.md
Shows how to customize the display format of the CountDown component using the 'format' prop. This example sets the format to display days, hours, minutes, and seconds.
```tsx
import React from 'react'
import { CountDown } from '@kfe/mix-ui'
import { DemoBlock } from 'demos'
import './style.less'
export default () => {
return (
)
}
```
--------------------------------
### Import Popup Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Popup 弹出层.md
Demonstrates how to import the Popup component from the '@kfe/mix-ui' library.
```js
import { Popup } from '@kfe/mix-ui';
```
--------------------------------
### Integrating Picker with Form.Item (Basic)
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Form 表单.md
Shows how to render a Picker component within a Form.Item, displaying the selected value or a placeholder. This setup is a prerequisite for controlling the Picker's visibility.
```tsx
{value =>
value || 'Please select'
}
```
```tsx
{value =>
value || 'Please select'
}
```
--------------------------------
### 引入 List 组件
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/List 列表.md
展示如何从 '@kfe/mix-ui' 库中引入 List 组件。这是使用该组件的第一步。
```js
import { List } from '@kfe/mix-ui'
```
--------------------------------
### Import Skeleton Component
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Skeleton 骨架屏.md
Imports the Skeleton component from the '@kfe/mix-ui' library. This is a common first step when using the component.
```javascript
import { Skeleton } from '@kfe/mix-ui';
```
--------------------------------
### Set Square Button Shape
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Button 按钮.md
Demonstrates how to create square-shaped buttons using the 'square' prop. This example shows primary, pay, and default button types with the square attribute applied.
```tsx
import React from 'react'
import { Button } from '@kfe/mix-ui'
import { DemoBlock } from 'demos'
import './style.less'
export default () => {
return (
VIP 会员色
购买红
知乎蓝
)
}
```
--------------------------------
### 加载状态 - Switch
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Switch 开关.md
演示如何通过 `loading` 属性将 Switch 组件设置为加载状态,此时开关同样不可点击。
```tsx
import React from 'react'
import { Switch } from '@kfe/mix-ui'
export default () => {
return
}
```
--------------------------------
### Mix-UI Popup with Rounded Corners
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/Popup 弹出层.md
Demonstrates how to use the Mix-UI Popup component with the `round` prop to apply rounded corner styles based on its position. This example shows a basic popup triggered by a button.
```tsx
import React, { useState } from 'react'
import { Button, Popup } from '@kfe/mix-ui'
export default () => {
const [visible, setVisible] = useState(false)
return (
<>
setVisible(true)}>圆角弹窗
setVisible(false)}
/>
>
)
}
```
--------------------------------
### Basic Rich Text Rendering
Source: https://github.com/zvip-fe/open-docs/blob/main/docs/mix-ui/RichText 富文本展示.md
Shows a basic example of rendering rich text content using the RichText component. The content includes HTML tags like ,
, and