-
-
Notifications
You must be signed in to change notification settings - Fork 12
Root: ui|v2.5|src|components|Galleries: GallerySelect.tsx
Serechops edited this page Apr 9, 2024
·
1 revision
Contains React components for selecting galleries using React Select.
-
Imports: The file imports various modules and components from React, react-select, classnames, and other custom modules within the project.
-
Type Definitions:
-
Gallery
: This type defines the structure of a gallery object, including itsid
,title
,files
, andfolder
. -
Option
: This type defines the structure of an option for the select component, which includes thevalue
andobject
properties.
-
-
Component Props:
-
ExtraGalleryProps
: This interface defines additional props that can be passed to the gallery select components, such ashoverPlacement
,excludeIds
, andextraCriteria
.
-
-
_GallerySelect:
- This component is responsible for rendering a select component for galleries. It includes functionality to load galleries based on user input, display options with their titles and paths, and handle multi-value selection.
- It uses
FilterSelectComponent
from../Shared/FilterSelect
to render the select component. - Inside this component, there are three nested components:
GalleryOption
,GalleryMultiValueLabel
, andGalleryValueLabel
, responsible for rendering options, multi-value labels, and single value labels respectively.
-
_GalleryIDSelect:
- This component extends
_GallerySelect
and adds functionality to load galleries by their IDs. - It maintains the selected galleries' state and updates it when the IDs change.
- This component extends
-
getExcludeFilebaseGalleriesFilter:
- This function creates a criterion for excluding file-based galleries. It returns a
PathCriterion
with themodifier
set toIsNull
.
- This function creates a criterion for excluding file-based galleries. It returns a
-
excludeFileBasedGalleries:
- This is an array containing a single criterion returned by
getExcludeFilebaseGalleriesFilter
. It's used to exclude file-based galleries when filtering.
- This is an array containing a single criterion returned by
Example usage:
import { GallerySelect } from "./GallerySelect";
// Inside a React component
<GallerySelect
isMulti={true}
excludeIds={["gallery1", "gallery2"]}
extraCriteria={[...]}
onSelect={(selectedGalleries) => console.log(selectedGalleries)}
/>
This example renders a multi-select gallery component, excluding galleries with IDs "gallery1" and "gallery2", and applying additional criteria specified in extraCriteria. When galleries are selected, their details will be logged to the console.