forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(input): Migrate Input component to Ant Design 5 (apache#30730)
- Loading branch information
Showing
15 changed files
with
237 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
superset-frontend/src/components/Input/Input.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { InputProps, TextAreaProps } from 'antd-v5/lib/input'; | ||
import { InputNumberProps } from 'antd-v5/lib/input-number'; | ||
import { AntdThemeProvider } from 'src/components/AntdThemeProvider'; | ||
import { Input, TextArea, InputNumber } from '.'; | ||
|
||
export default { | ||
title: 'Input', | ||
component: Input, | ||
}; | ||
|
||
export const InteractiveInput = (args: InputProps) => ( | ||
<AntdThemeProvider> | ||
<Input {...args} /> | ||
</AntdThemeProvider> | ||
); | ||
|
||
export const InteractiveInputNumber = (args: InputNumberProps) => ( | ||
<AntdThemeProvider> | ||
<InputNumber {...args} /> | ||
</AntdThemeProvider> | ||
); | ||
|
||
export const InteractiveTextArea = (args: TextAreaProps) => ( | ||
<AntdThemeProvider> | ||
<TextArea {...args} /> | ||
</AntdThemeProvider> | ||
); | ||
|
||
InteractiveInput.args = { | ||
allowClear: false, | ||
disabled: false, | ||
showCount: false, | ||
type: 'text', | ||
variant: 'outlined', | ||
}; | ||
|
||
InteractiveInput.argTypes = { | ||
defaultValue: { | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
|
||
id: { | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
|
||
maxLength: { | ||
control: { | ||
type: 'number', | ||
}, | ||
}, | ||
|
||
status: { | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['error', 'warning'], | ||
}, | ||
|
||
size: { | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['large', 'middle', 'small'], | ||
}, | ||
variant: { | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['outlined', 'borderless', 'filled'], | ||
}, | ||
}; | ||
|
||
InteractiveTextArea.args = { | ||
...InteractiveInput.args, | ||
autoSize: false, | ||
}; | ||
|
||
InteractiveTextArea.argTypes = InteractiveInput.argTypes; | ||
|
||
InteractiveInputNumber.args = { | ||
autoFocus: false, | ||
disabled: false, | ||
keyboard: true, | ||
max: Number.MAX_SAFE_INTEGER, | ||
min: Number.MIN_SAFE_INTEGER, | ||
readonly: false, | ||
step: 1, | ||
stringMode: false, | ||
}; | ||
|
||
InteractiveInputNumber.argTypes = { | ||
controls: { | ||
control: { type: 'boolean' }, | ||
}, | ||
|
||
decimalSeperator: { | ||
control: { type: 'text' }, | ||
}, | ||
|
||
placeholder: { | ||
control: { type: 'text' }, | ||
}, | ||
|
||
defaultValue: { | ||
control: { type: 'number' }, | ||
}, | ||
|
||
precision: { | ||
control: { type: 'number' }, | ||
}, | ||
|
||
status: InteractiveInput.argTypes.status, | ||
size: InteractiveInput.argTypes.size, | ||
variant: InteractiveInput.argTypes.variant, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { render } from 'spec/helpers/testing-library'; | ||
import { Input, InputNumber, TextArea } from '.'; | ||
|
||
test('should render Input', () => { | ||
const { container } = render(<Input />); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
test('should render InputNumber', () => { | ||
const { container } = render(<InputNumber />); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
test('should render TextArea', () => { | ||
const { container } = render(<TextArea />); | ||
expect(container).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.