How can I get common props from rSuiteComponents? #57
Answered
by
cherepanov
tuthanhoancanh012
asked this question in
Q&A
Answered by
cherepanov
Feb 28, 2025
Replies: 3 comments 8 replies
|
What is your issue with common properties? If you provide the correct definition, it should work. Below is an example of how it is implemented internally for some components. export const inputProps = {
placeholder: string.hinted('Input placeholder'),
size,
disabled: boolean.hinted('Disabled component').default(false),
readOnly,
onChange: event,
}
export const rsInput = define(RsInput, 'RsInput')
.name('Input')
.props({
label: string.default('Input').hinted('Input label'),
...inputProps,
type: oneOf('text', 'password', 'email', 'number', 'search', 'tel', 'url', 'time').default('text'),
value: string.valued,
passwordMask: boolean.default(false)
})All definitions are chainable and merge with existing definitions, allowing you to redefine or extend current components. export const rsTextAreaDefault = define(RsTextArea, 'RsTextArea')
.name('Text area')
.props({
label: string.default('Text area'),
value: string.default('').valued,
placeholder: string,
rows: positiveNumber.default(5),
size,
disabled: boolean.hinted('Disabled component').default(false),
readOnly,
onChange: event,
onPressEnter: event
})
export const rsTextArea = rsTextAreaDefault.name('Hinted Input').props({
hint: string.default('I am the clue!')
}) |
0 replies
Answer selected by
sergeythrees
|
You can define common CSS properties in the same way: export const rsTextAreaDefault = define(RsTextArea, 'RsTextArea')
.name('Text area')
.props({
label: string.default('Text area'),
value: string.default('').valued,
placeholder: string,
rows: positiveNumber.default(5),
size,
disabled: boolean.hinted('Disabled component').default(false),
readOnly,
onChange: event,
onPressEnter: event
})
const commonCssProps = {
width: cssSize.setup({default: '100%'}).hinted('Width of the map'),
padding: cssSize.setup({default: '1em'}).hinted('Padding'),
border: string.setup({default: '2px solid green'}).hinted('Border'),
}
export const rsTextArea = rsTextAreaDefault.name('Hinted Input').props({
// @ts-ignore redefine currently broken
hint: string.default('I am the clue!')
}).css({
...commonCssProps
})While the extension of wrapper styles definition is currently not implemented, it is doable. |
8 replies
|
Hi! Sorry for the delay, we've added this feature to our roadmap. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment






@tuthanhoancanh012
What is your issue with common properties? If you provide the correct definition, it should work. Below is an example of how it is implemented internally for some components.