From d578ae989797d73249e51b901d75a083dbd3e105 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Wed, 16 Jun 2021 20:05:58 +0300 Subject: [PATCH] feat: Select component (Iteration 1) (#15121) * Implement initial structure * Add aria-label * Rename files * Refactor single mode new options * Clean up * Add select at every corner in storybook * Clean up * Add pagination * Move selected options at the top * Clean up * Add license * Refactor * Improve pagination * Fetch when allowNewOptions * Clean up --- .../components/Select/AntdSelect.stories.tsx | 244 ++++++++++++ .../src/components/Select/AntdSelect.tsx | 355 ++++++++++++++++++ ...ories.tsx => DeprecatedSelect.stories.tsx} | 2 +- .../{Select.tsx => DeprecatedSelect.tsx} | 0 .../src/components/Select/index.ts | 4 +- .../src/components/Select/styles.tsx | 2 +- .../src/components/Select/utils.ts | 12 + superset-frontend/src/components/index.ts | 20 + 8 files changed, 635 insertions(+), 4 deletions(-) create mode 100644 superset-frontend/src/components/Select/AntdSelect.stories.tsx create mode 100644 superset-frontend/src/components/Select/AntdSelect.tsx rename superset-frontend/src/components/Select/{Select.stories.tsx => DeprecatedSelect.stories.tsx} (99%) rename superset-frontend/src/components/Select/{Select.tsx => DeprecatedSelect.tsx} (100%) create mode 100644 superset-frontend/src/components/index.ts diff --git a/superset-frontend/src/components/Select/AntdSelect.stories.tsx b/superset-frontend/src/components/Select/AntdSelect.stories.tsx new file mode 100644 index 0000000000..e26588ad99 --- /dev/null +++ b/superset-frontend/src/components/Select/AntdSelect.stories.tsx @@ -0,0 +1,244 @@ +/** + * 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 React from 'react'; +import Select, { OptionsType, SelectProps } from './AntdSelect'; + +export default { + title: 'Select', + component: Select, +}; + +const options = [ + { + label: 'Such an incredibly awesome long long label', + value: 'Such an incredibly awesome long long label', + }, + { + label: 'Another incredibly awesome long long label', + value: 'Another incredibly awesome long long label', + }, + { label: 'Just a label', value: 'Just a label' }, + { label: 'A', value: 'A' }, + { label: 'B', value: 'B' }, + { label: 'C', value: 'C' }, + { label: 'D', value: 'D' }, + { label: 'E', value: 'E' }, + { label: 'F', value: 'F' }, + { label: 'G', value: 'G' }, + { label: 'H', value: 'H' }, + { label: 'I', value: 'I' }, +]; + +const selectPositions = [ + { + id: 'topLeft', + style: { top: '0', left: '0' }, + }, + { + id: 'topRight', + style: { top: '0', right: '0' }, + }, + { + id: 'bottomLeft', + style: { bottom: '0', left: '0' }, + }, + { + id: 'bottomRight', + style: { bottom: '0', right: '0' }, + }, +]; + +export const AtEveryCorner = () => ( + <> + {selectPositions.map(position => ( +
+ +); + +AsyncSelect.args = { + withError: false, + allowNewOptions: false, + paginatedFetch: false, +}; + +AsyncSelect.argTypes = { + mode: { + control: { type: 'select', options: ['single', 'multiple', 'tags'] }, + }, +}; + +AsyncSelect.story = { + parameters: { + knobs: { + disable: true, + }, + }, +}; + +export const InteractiveSelect = (args: SelectProps) =>