How can I get common props from rSuiteComponents? #57
-
Beta Was this translation helpful? Give feedback.
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!')
}) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Hi! Sorry for the delay, we've added this feature to our roadmap. |
Beta Was this translation helpful? Give feedback.
@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.