T-ui-Plus Documentation
repository·master·Indexed 18 days ago
https://github.com/wocwin/t-ui-plusA Vue 3 component library built on TypeScript and Element-Plus, providing enhanced, pre-configured components for administrative backends and complex management interfaces. Features include the TAdaptivePage layout component, TSelectTable with virtual scrolling, TButton with built-in debounce, and a TChart wrapper for Echarts.
What's inside @wocwin/t-ui-plus
- @wocwin/t-ui-plus is a collection of base components built on top of Vue 3, TypeScript, and Element-plus. It provides high-level abstractions for common UI patterns like adaptive layouts, query conditions, and complex tables to accelerate development.
Overview of T-ui-plus
masterT-ui-plus is a collection of basic components for Vue 3, built as a secondary encapsulation (wrapper) of Element-plus. It is designed to provide an enhanced development experience using Vue 3 and Vite 3, allowing developers to use Vue components within Markdown and develop custom themes using Vue.Customize TCheckbox appearance and slots
masterTCheckbox supports several visual customizations:
- Size: Use the
sizeattribute with values'large','default', or'small'. - Button Style: Set
type="button"to render checkboxes as buttons. - Border: Set
bordertotrueto render checkboxes with a border. - Slots:
- Use the
slotproperty within an option object to target a specific named slot. - Use the default slot to implement custom rendering for the checkbox items.
- Use the
- Size: Use the
Configure TTabs via el-tabs attributes, events, and slots
masterTheTTabscomponent inherits all attributes, events, and slots from the underlyingel-tabscomponent. This allows you to use standard Element Plus tab properties for advanced configuration and customization.Use `isDropDownSelectMore` to show extra conditions
masterWhen
isDropDownSelectMoreis set totrue, additional conditions are hidden behind a dropdown menu. This is useful for complex forms to save space.Attributes for Dropdown Mode:
Parameter Description Type Default popoverAttrsConfiguration for el-popoverand localized textobject { showTxt: '更多', title: '所有条件', allTxt: '全选', reverseTxt: '反选', clearTxt: '清空', placement: 'bottom', width: 240, trigger: 'click' }moreCheckListData source for the dropdown items Array - moreCheckListitem structure:label: Titlecomp: Component name/objectisSelfCom: If true, uses custom component withoutel-optionprop: Backend field namebind: Component attributes (can be a function receivingform)slotName: Custom input slotspan: Column span (1-4)type: Element type (radio,checkbox,select-arr,select-obj)list: Data source forel-select
Customize labels with labelRender or slots
masterTForm provides two ways to render custom labels:
labelRender(TSX/Function): Provide a function to thelabelRenderproperty in the field configuration. IflabelRenderis present, it takes precedence over thelabelproperty.labelSlotName(Slot): Use thelabelSlotNameproperty in the field configuration to specify a slot name, then provide the content via that slot in your template.
Configure Multiple Selection (Checkbox) Mode
masterEnable multiple selection by setting the
multipleprop totrue.Key features:
- Custom Selectability: Use the
selectableprop (a function(row: any, index: number) => boolean) to determine if a checkbox can be checked. - Fixed Checkbox Column:
multipleFixed(defaulttrue) keeps the checkbox column fixed. - Selection Event: Use
@selectionChangeto receive the selected items and the collection of theirkeywords.valueidentifiers. - Hide Delete Icon: Set
multipleDisableDeletetotrueto hide the delete icon on selected tags. This is useful when switching pages or performing queries where previously selected data might not exist in the current view. - Restore Selection: When using pagination, you can assign values to
state.defaultValueto show labels, but you must call the exposedselectTable.toggleRowSelectionmethod to actually check the rows.
- Custom Selectability: Use the
Configure Single Selection (Radio) Mode
masterBy default,
TSelectTableoperates in single selection mode.Common configurations:
- Disable specific rows: Use the
isRadioDisabledproperty (if applied to the table data) to prevent selection of certain rows. - Keyboard Navigation: Set
isKeyuptotrueto enable up/down arrow selection and Enter to confirm. Note:max-heightmust be set for scrolling to work correctly. - Hide first column: Set
isShowFirstColumntofalseto hide the radio button column. - Row Click:
rowClickRadio(defaulttrue) allows selecting a row by clicking anywhere on it. - Same item toggle:
radioSameIsCancel(defaulttrue) allows clicking the same item again to deselect it.
- Disable specific rows: Use the
Use TStepWizard in simple mode
masterWhen enabling the 'simple' (简洁风格) mode, certain layout properties will be ignored. Specifically, the following props will become ineffective:
align-centerdescriptiondirectionspace
Global Registration of T-ui-Plus
masterTo use T-ui-Plus globally in your Vue application, you must first ensure that
element-plusis globally registered, as T-ui-Plus depends on it. Import the T-ui-Plus CSS and the library itself, then useapp.use(TuiPlus)in your main entry file.When configuring locales, you can merge the
element-pluslocale with the@wocwin/t-ui-plus/localelocale to ensure both libraries are localized correctly.// main.ts import { createApp } from "vue" import App from "./App.vue" import ElementPlus from "element-plus" import "element-plus/dist/index.css" import "element-plus/theme-chalk/dark/css-vars.css" import zhCn from 'element-plus/es/locale/lang/zh-cn' import plusZhCn from '@wocwin/t-ui-plus/locale/zh-cn' import * as ElementPlusIconsVue from "@element-plus/icons-vue" import TuiPlus from "@wocwin/t-ui-plus" import "@wocwin/t-ui-plus/index.css" const app = createApp(App) // Register Element Plus icons for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } // Register ElementPlus with merged locales app.use(ElementPlus, { locale: { ...zhCn, ...plusZhCn } }) // Register TuiPlus app.use(TuiPlus) app.mount("#app")Use T-ui-Plus via CDN
masterYou can include T-ui-Plus directly in your HTML using a CDN provider like
unpkgorjsDelivr. This requiresvueandelement-plusto be loaded first.<!-- unpkg example --> <head> <link rel="stylesheet" href="//unpkg.com/element-plus/dist/index.css" /> <script src="//unpkg.com/vue@3"></script> <script src="//unpkg.com/element-plus"></script> <link rel="stylesheet" href="//unpkg.com/@wocwin/t-ui-plus/index.css" /> <script src="//unpkg.com/@wocwin/t-ui-plus"></script> </head>Use the TStepWizard component
masterThe
TStepWizardcomponent is a data-driven wrapper around Element-plusel-stepsandel-step. It simplifies step management by allowing you to define steps via astepDataarray rather than writing repetitive HTML. You can use named slots (e.g.,#first,#second) to define the content of each step.Key features include:
- Data-driven: Define steps, icons, descriptions, and buttons in a single array.
- Custom Buttons: Each step can have its own array of buttons (
btnArr) with custom titles, parameters, and event handlers. - Completion Flow: Supports a specialized final step with a success title and custom completion buttons (
lastBtnArr).
<t-step-wizard :stepData="stepData" :active="active" :successTitle="successTitle" @complete="complete" > <template #first>第一步骤</template> <!-- Additional step slots as needed --> </t-step-wizard>