From 97e3e790a3627ff7e291865807bbe3634cc3a291 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Thu, 3 Nov 2022 10:53:50 -0300 Subject: [PATCH] feat: Adds the DropdownContainer component (#21974) --- .../DropdownContainer.stories.tsx | 103 +++++++ .../components/DropdownContainer/index.tsx | 256 ++++++++++++++++++ .../src/components/Select/AsyncSelect.tsx | 9 +- .../src/components/Select/Select.tsx | 9 +- .../src/components/Select/styles.tsx | 40 ++- .../src/components/Select/types.ts | 4 + 6 files changed, 403 insertions(+), 18 deletions(-) create mode 100644 superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx create mode 100644 superset-frontend/src/components/DropdownContainer/index.tsx diff --git a/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx b/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx new file mode 100644 index 000000000000..eed8f166356d --- /dev/null +++ b/superset-frontend/src/components/DropdownContainer/DropdownContainer.stories.tsx @@ -0,0 +1,103 @@ +/** + * 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, { useEffect, useState } from 'react'; +import { isEqual } from 'lodash'; +import { css } from '@superset-ui/core'; +import Select from '../Select/Select'; +import DropdownContainer, { DropdownContainerProps } from '.'; + +export default { + title: 'DropdownContainer', + component: DropdownContainer, +}; + +const ITEMS_COUNT = 6; +const ITEM_OPTIONS = 10; +const MIN_WIDTH = 700; +const MAX_WIDTH = 1500; + +const itemsOptions = Array.from({ length: ITEM_OPTIONS }).map((_, i) => ({ + label: `Option ${i}`, + value: `option-${i}`, +})); + +type ItemsType = Pick['items']; + +type OverflowingState = { notOverflowed: string[]; overflowed: string[] }; + +const generateItems = (overflowingState?: OverflowingState) => + Array.from({ length: ITEMS_COUNT }).map((_, i) => ({ + id: `el-${i}`, + element: ( +
+