2022-04-11 11:57:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
import Select from 'react-select';
|
|
|
|
|
import defaultStyles from './styles';
|
|
|
|
|
|
Feature Homepage and settings redesign (#5763)
* adding colors
* feat :: add button
* feat :: added typography
* feat: init storybook
* removes browserlist
* feat :: adding button styles and button component
* feat :: added sass addon
* stories update
* feat :: replacing with radix colors
* danger variants
* updates buttin story
* fix :: removing default items
* cleanup
* fix icons update
* feat :: folder list component
* fix :: naming
* icon and split button :: init
* intermediate save :: app card component
* renaming
* updates
* update for module imports
* updates icon
* update :: homepage design updates
* design changes dashboard
* updates :: apps section
* workspace stting new design upate
* updates dasboard design
* style :: fixes
* feat :: added context for sidebar nav breadcrumb
* added all solid icons
* intermediate update
* change: conditions for fetching users
* sorybook updates
* design updates :: workspace settings page
* manage users page
* lint fixes
* fix :: styling
* stle fixes :: workspace settings
* homepage redesign
* fix :: all drawer colors and position ,teplate page revamp , database page header fixes
* imported all bulk icons
* svg to jsx : bulk icons
* minor :: cleanup
* fix :: manage users drawer
* fix :: searchboxes , userspage fixes
* fix :: all inputs and minor ui fixes
* database page ui fixes
* fix :: database and folder search functionality and iconlist in homecard
* fixed some db functionality and edge cases for longer texts
* fix :: user addition manage user page
* self review cleanup and change in bulk icon fill state
* fix :: homepage seacbar
* merging develop and resolving conflicts
* remove unwanted stories
* reverting merge with develop
* Revert "reverting merge with develop"
This reverts commit 2150c8ec0ce9cedda4f4676211faa3321d4af7f8.
* clearing out warnings
* lint fixes
* feat :: added org modal in database page
* fix :: sso loader theme
* fix :: broken styles select
* fixed icon warning and select ui
* fix :: upload bulk and user select dark mode
* merge styles with develop
* feat :: integrated new ui for database
* removing storybook files
* fix :: all bugs related to users dropdown and cleanup
* fix: user search api for organization page
* cleanup and splitting dropzone component
* fix :: overflow issue in app card time
* fix for scrollbars in homepage
* PR review fixes
* updates :: fix d=global datasource design issues , homepage responsiveness
* tj db operations
* breadcrumb bug fixes
* lint fixes
* removing logs , removed fade in in datasource and database page
* marketplace page ui fix
* removing inital users table fetch
* Pr :: review changes
* remove logs
* fix :: popover bug
* minot style fix
* fix :: remove arrow from all popovers
* fix :: for loading states
* ux :: sidebar items reorder
* style :: fix
* style fix :: templates
* fix :: qa bugs
* fix :: Qa reported bugs
* removes :: folder fetch bug
* share link and datsource bg color fix
* fixes :: rename group ,
* removed logs
* pages popover background fix
* fix :: tj db table addition ui bug
* fix :: ui bug confirm modal password disable
* modal , revert name capitalize in lists, typos fix
* typos , users page route bugfix
* users page header bugfix
* workspace archive btn , datasources form style for select
* groups updated , delete, create flow updated
* avatar bug in profile page fix
* revert styles
* fix :: for create new table nav breadcrumb not being updated
* click state bug fix in avatar
* fix bug with appcard popover
* fix :: text capitalize issue
* fix :: lints and updated icon for filter delete
* fix warnings
---------
Co-authored-by: gandharv <gandharvkumargarg@gmail.com>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
2023-04-21 06:15:48 +00:00
|
|
|
export const SelectComponent = ({
|
|
|
|
|
options = [],
|
|
|
|
|
value,
|
|
|
|
|
onChange,
|
|
|
|
|
closeMenuOnSelect,
|
2023-09-04 08:00:39 +00:00
|
|
|
classNamePrefix,
|
2024-04-19 07:25:16 +00:00
|
|
|
darkMode,
|
Feature Homepage and settings redesign (#5763)
* adding colors
* feat :: add button
* feat :: added typography
* feat: init storybook
* removes browserlist
* feat :: adding button styles and button component
* feat :: added sass addon
* stories update
* feat :: replacing with radix colors
* danger variants
* updates buttin story
* fix :: removing default items
* cleanup
* fix icons update
* feat :: folder list component
* fix :: naming
* icon and split button :: init
* intermediate save :: app card component
* renaming
* updates
* update for module imports
* updates icon
* update :: homepage design updates
* design changes dashboard
* updates :: apps section
* workspace stting new design upate
* updates dasboard design
* style :: fixes
* feat :: added context for sidebar nav breadcrumb
* added all solid icons
* intermediate update
* change: conditions for fetching users
* sorybook updates
* design updates :: workspace settings page
* manage users page
* lint fixes
* fix :: styling
* stle fixes :: workspace settings
* homepage redesign
* fix :: all drawer colors and position ,teplate page revamp , database page header fixes
* imported all bulk icons
* svg to jsx : bulk icons
* minor :: cleanup
* fix :: manage users drawer
* fix :: searchboxes , userspage fixes
* fix :: all inputs and minor ui fixes
* database page ui fixes
* fix :: database and folder search functionality and iconlist in homecard
* fixed some db functionality and edge cases for longer texts
* fix :: user addition manage user page
* self review cleanup and change in bulk icon fill state
* fix :: homepage seacbar
* merging develop and resolving conflicts
* remove unwanted stories
* reverting merge with develop
* Revert "reverting merge with develop"
This reverts commit 2150c8ec0ce9cedda4f4676211faa3321d4af7f8.
* clearing out warnings
* lint fixes
* feat :: added org modal in database page
* fix :: sso loader theme
* fix :: broken styles select
* fixed icon warning and select ui
* fix :: upload bulk and user select dark mode
* merge styles with develop
* feat :: integrated new ui for database
* removing storybook files
* fix :: all bugs related to users dropdown and cleanup
* fix: user search api for organization page
* cleanup and splitting dropzone component
* fix :: overflow issue in app card time
* fix for scrollbars in homepage
* PR review fixes
* updates :: fix d=global datasource design issues , homepage responsiveness
* tj db operations
* breadcrumb bug fixes
* lint fixes
* removing logs , removed fade in in datasource and database page
* marketplace page ui fix
* removing inital users table fetch
* Pr :: review changes
* remove logs
* fix :: popover bug
* minot style fix
* fix :: remove arrow from all popovers
* fix :: for loading states
* ux :: sidebar items reorder
* style :: fix
* style fix :: templates
* fix :: qa bugs
* fix :: Qa reported bugs
* removes :: folder fetch bug
* share link and datsource bg color fix
* fixes :: rename group ,
* removed logs
* pages popover background fix
* fix :: tj db table addition ui bug
* fix :: ui bug confirm modal password disable
* modal , revert name capitalize in lists, typos fix
* typos , users page route bugfix
* users page header bugfix
* workspace archive btn , datasources form style for select
* groups updated , delete, create flow updated
* avatar bug in profile page fix
* revert styles
* fix :: for create new table nav breadcrumb not being updated
* click state bug fix in avatar
* fix bug with appcard popover
* fix :: text capitalize issue
* fix :: lints and updated icon for filter delete
* fix warnings
---------
Co-authored-by: gandharv <gandharvkumargarg@gmail.com>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
2023-04-21 06:15:48 +00:00
|
|
|
...restProps
|
|
|
|
|
}) => {
|
2024-04-19 07:25:16 +00:00
|
|
|
const isDarkMode = darkMode ?? localStorage.getItem('darkMode') === 'true';
|
2022-04-11 11:57:07 +00:00
|
|
|
const {
|
2023-01-04 07:58:55 +00:00
|
|
|
isMulti = false,
|
2023-01-03 11:42:43 +00:00
|
|
|
styles = {},
|
2022-12-22 20:39:57 +00:00
|
|
|
isLoading = false,
|
2022-04-11 11:57:07 +00:00
|
|
|
hasSearch = true,
|
|
|
|
|
height,
|
|
|
|
|
width,
|
|
|
|
|
placeholder = 'Select..',
|
|
|
|
|
customOption = undefined,
|
|
|
|
|
defaultValue = null,
|
2023-01-25 12:32:39 +00:00
|
|
|
useMenuPortal = true, // todo: deprecate this prop, use menuPortalTarget instead
|
2022-04-27 12:51:50 +00:00
|
|
|
maxMenuHeight = 250,
|
2022-12-22 20:39:57 +00:00
|
|
|
menuPortalTarget = null,
|
2022-12-26 11:39:12 +00:00
|
|
|
menuPlacement = 'auto',
|
2023-01-03 11:42:43 +00:00
|
|
|
useCustomStyles = false,
|
2023-01-05 06:23:53 +00:00
|
|
|
isDisabled = false,
|
2022-04-11 11:57:07 +00:00
|
|
|
} = restProps;
|
|
|
|
|
|
2024-04-19 07:25:16 +00:00
|
|
|
const customStyles = useCustomStyles ? styles : defaultStyles(isDarkMode, width, height, styles);
|
2022-04-11 11:57:07 +00:00
|
|
|
const selectOptions =
|
|
|
|
|
Array.isArray(options) && options.length === 0
|
|
|
|
|
? options
|
|
|
|
|
: options.map((option) => {
|
|
|
|
|
if (!option.hasOwnProperty('label')) {
|
|
|
|
|
return _.mapKeys(option, (value, key) => (key === 'value' ? key : 'label'));
|
|
|
|
|
}
|
|
|
|
|
return option;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const currentValue = selectOptions.find((option) => option.value === value) || value;
|
|
|
|
|
|
2023-01-04 07:58:55 +00:00
|
|
|
const handleOnChange = (data) => {
|
|
|
|
|
if (isMulti) {
|
|
|
|
|
onChange(data);
|
|
|
|
|
} else {
|
|
|
|
|
onChange(data.value);
|
|
|
|
|
}
|
2022-04-11 11:57:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderCustomOption = (option) => {
|
|
|
|
|
if (customOption) {
|
|
|
|
|
return customOption(option);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return option.label;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2022-12-22 20:39:57 +00:00
|
|
|
<Select
|
|
|
|
|
{...restProps}
|
|
|
|
|
defaultValue={defaultValue}
|
|
|
|
|
isLoading={isLoading}
|
2023-01-05 06:23:53 +00:00
|
|
|
isDisabled={isDisabled || isLoading}
|
2022-12-22 20:39:57 +00:00
|
|
|
options={selectOptions}
|
|
|
|
|
value={currentValue}
|
2022-12-29 11:48:24 +00:00
|
|
|
isSearchable={hasSearch}
|
2022-12-22 20:39:57 +00:00
|
|
|
onChange={handleOnChange}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
styles={customStyles}
|
|
|
|
|
formatOptionLabel={(option) => renderCustomOption(option)}
|
2022-12-26 11:39:12 +00:00
|
|
|
menuPlacement={menuPlacement}
|
2022-12-22 20:39:57 +00:00
|
|
|
maxMenuHeight={maxMenuHeight}
|
|
|
|
|
menuPortalTarget={useMenuPortal ? document.body : menuPortalTarget}
|
Feature Homepage and settings redesign (#5763)
* adding colors
* feat :: add button
* feat :: added typography
* feat: init storybook
* removes browserlist
* feat :: adding button styles and button component
* feat :: added sass addon
* stories update
* feat :: replacing with radix colors
* danger variants
* updates buttin story
* fix :: removing default items
* cleanup
* fix icons update
* feat :: folder list component
* fix :: naming
* icon and split button :: init
* intermediate save :: app card component
* renaming
* updates
* update for module imports
* updates icon
* update :: homepage design updates
* design changes dashboard
* updates :: apps section
* workspace stting new design upate
* updates dasboard design
* style :: fixes
* feat :: added context for sidebar nav breadcrumb
* added all solid icons
* intermediate update
* change: conditions for fetching users
* sorybook updates
* design updates :: workspace settings page
* manage users page
* lint fixes
* fix :: styling
* stle fixes :: workspace settings
* homepage redesign
* fix :: all drawer colors and position ,teplate page revamp , database page header fixes
* imported all bulk icons
* svg to jsx : bulk icons
* minor :: cleanup
* fix :: manage users drawer
* fix :: searchboxes , userspage fixes
* fix :: all inputs and minor ui fixes
* database page ui fixes
* fix :: database and folder search functionality and iconlist in homecard
* fixed some db functionality and edge cases for longer texts
* fix :: user addition manage user page
* self review cleanup and change in bulk icon fill state
* fix :: homepage seacbar
* merging develop and resolving conflicts
* remove unwanted stories
* reverting merge with develop
* Revert "reverting merge with develop"
This reverts commit 2150c8ec0ce9cedda4f4676211faa3321d4af7f8.
* clearing out warnings
* lint fixes
* feat :: added org modal in database page
* fix :: sso loader theme
* fix :: broken styles select
* fixed icon warning and select ui
* fix :: upload bulk and user select dark mode
* merge styles with develop
* feat :: integrated new ui for database
* removing storybook files
* fix :: all bugs related to users dropdown and cleanup
* fix: user search api for organization page
* cleanup and splitting dropzone component
* fix :: overflow issue in app card time
* fix for scrollbars in homepage
* PR review fixes
* updates :: fix d=global datasource design issues , homepage responsiveness
* tj db operations
* breadcrumb bug fixes
* lint fixes
* removing logs , removed fade in in datasource and database page
* marketplace page ui fix
* removing inital users table fetch
* Pr :: review changes
* remove logs
* fix :: popover bug
* minot style fix
* fix :: remove arrow from all popovers
* fix :: for loading states
* ux :: sidebar items reorder
* style :: fix
* style fix :: templates
* fix :: qa bugs
* fix :: Qa reported bugs
* removes :: folder fetch bug
* share link and datsource bg color fix
* fixes :: rename group ,
* removed logs
* pages popover background fix
* fix :: tj db table addition ui bug
* fix :: ui bug confirm modal password disable
* modal , revert name capitalize in lists, typos fix
* typos , users page route bugfix
* users page header bugfix
* workspace archive btn , datasources form style for select
* groups updated , delete, create flow updated
* avatar bug in profile page fix
* revert styles
* fix :: for create new table nav breadcrumb not being updated
* click state bug fix in avatar
* fix bug with appcard popover
* fix :: text capitalize issue
* fix :: lints and updated icon for filter delete
* fix warnings
---------
Co-authored-by: gandharv <gandharvkumargarg@gmail.com>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
2023-04-21 06:15:48 +00:00
|
|
|
closeMenuOnSelect={closeMenuOnSelect ?? true}
|
2024-04-19 07:25:16 +00:00
|
|
|
classNamePrefix={`${isDarkMode && 'dark-theme'} ${'react-select'}`}
|
2022-12-22 20:39:57 +00:00
|
|
|
/>
|
2022-04-11 11:57:07 +00:00
|
|
|
);
|
|
|
|
|
};
|