Case Scenario
Use the custom component feature to add low-code enhancements to YiDA’s built-in text component, enabling text-copy functionality. This copies text content to the clipboard, making it easier for users to fill in repetitive fields.Result Preview
Steps
Step 1: Create a Custom Component
Configure properties such as the component name, type, and identifier to build a component tailored to your business needs at low cost. Steps:- Go to YiDA App >> App Settings >> Component Management >> Component Center (as shown below).
- Add a Component >> fill in the component name, component type, component identifier, and other properties >> Confirm (as shown below).
Step 2: Develop and Debug the Custom Component
Develop and debug the component to meet different business needs. In this case, we implement the copy functionality of the component. Steps:- Component Center >> My Components >> locate the component you want to debug >> Develop (as shown below).
-
As mentioned earlier, a component is built from a view and its properties. When developing a component, first abstract the properties it requires. Let’s build the component properties first. This component needs only one property for text content. Go to Property Configuration >> Property Definition, add a text content property named
content, set the property type to Text, and set the setter totextSetter. -
After the component properties are built, construct the component view by adding the required YiDA standard components to the canvas (in this case, two Text components are needed, named “Text” and “Copy” respectively). Configure their basic properties, and use variable binding to bind the Text component’s content to the property
props.contentyou just built. The passed-in property value is then displayed at runtime (as shown below). - Configure an action on the Button component to implement the text-copy effect. Select the “Copy” text >> Create Action >> onCopyText click (as shown below).
- Write the copy logic in the JS panel (as shown below).
- Save >> preview the component.
- Publish >> fill in the version number and related notes >> Confirm (as shown below).
- A prompt appears upon successful publishing (as shown below). In actual component development, once you save, you can install the development version (0.1.0) of the component for real-time debugging. The official version only needs to be published after component development is complete.
Step 3: Install the Custom Component
Install the developed and debugged custom component into a page so you can use it during page design. When installing the component, you must select the page type. Only after this selection will the custom component appear in the corresponding page designer. Steps:- Form Design Page >> Component Library >> Custom Components >> Component Management (as shown below).
- Component Management Page >> Component List >> select the custom component you want to install >> Install (as shown below).
- Select the installation version and installation scope >> Install (as shown below).
Step 4: Use the Custom Component
After the steps above, the custom component is installed under the Custom Components category in the page component library. Follow the steps below to use it. Steps:- Form Design Page >> Component Library >> Custom Components >> select the component you need >> drag it to the canvas (as shown below).
Step 5: View or Modify Component Information
While using a component, if you need to modify its thumbnail, help document URL, or description, follow the steps below. Steps- App Settings >> Component Management >> Component Center (as shown below).
- Select the component whose details you want to view or modify >> Details (as shown below).
Note: The component details page has three modules: Basic Information, Release Information, and Admin (as shown below).
- Basic Information: Click “Edit” to modify the custom component’s thumbnail, help document URL, and description. Other settings are configured at component creation and cannot be modified.
- Release Information: View the iteration history of the custom component, including the version and corresponding release notes.
- Admin (has permission to develop and debug the custom component; defaults to the component creator): Add or remove admins to manage permissions.
Custom Component Properties
In addition to supporting enhancements to YiDA’s built-in components, custom components also let you customize the properties (propTypes) of the generated custom component. This makes the custom component more aligned with developers’ daily work scenarios and habits, while giving it greater flexibility and customizability.
Entry for Custom Component Property Configuration
Path: Low-code component designer >> select the “low-code business component” on the canvas >> properties on the right (path shown below).Custom Component Property Configuration Details
Custom component properties are divided into four modules: Dual-end Design, Property Definition (propTypes), Lifecycle, and Unique Identifier. Specifically:
- Dual-end Design: A toggle. When enabled, the PC and mobile ends can be fully separated and designed independently to meet dual-end adaptation needs.
- Property Definition (propTypes): Customize basic properties of the custom component such as title, name, type (data format), and default value. You can also bind events such as Hide (whether the component is hidden) and On Change (when the displayed value changes) to meet various business needs. For details, see Component Property Configuration.
- Lifecycle: A custom component’s lifecycle has four stages: Component Rendered (
componentDidMount), Component Updated (componentDidUpdate), Component Error Caught (componentDidCatch), and Before Component Unmount (componentWillUnmount). Write different logic for different lifecycle stages to meet complex business needs. - Unique Identifier: Like YiDA standard components, custom components also have a unique identifier property that serves as the component’s unique identification code. It is automatically generated by the system and generally does not need to be changed. It is used for YiDA backend data storage, code binding, and so on.