How can I get common props from rSuiteComponents? #57
Unanswered
tuthanhoancanh012
asked this question in
Q&A
Replies: 2 comments 6 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.
0 replies
-
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.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
rSuiteComponents.
Is there a way for me to get the common props to declare them in the
define
?Because I want to inject some of my custom
props
into RsTextAreaThank you
Beta Was this translation helpful? Give feedback.
All reactions