Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds select component #155

Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1b13eaa
feat: added select component with basic, disabled features
May 31, 2022
6b9e45b
feat: updating input comp to support select
May 31, 2022
84ef021
feat: clearable feature on select
May 31, 2022
d3f4842
feat: added filterable options
ktorlakonda-eightfold May 31, 2022
1a20445
feat: added support for multi selection
ktorlakonda-eightfold May 31, 2022
d403b4d
feat: added dynamic options
ktorlakonda-eightfold May 31, 2022
b01a8bf
feat: added styling
ktorlakonda-eightfold Jun 1, 2022
3f36681
feat: added more styling for multi select
ktorlakonda-eightfold Jun 2, 2022
d1f6f12
feat: readonly prop to input
ktorlakonda-eightfold Jun 2, 2022
08db037
feat: cleanup
ktorlakonda-eightfold Jun 2, 2022
8743d4f
feat: mr comments
ktorlakonda-eightfold Jun 3, 2022
016325e
feat: mr comments 2
ktorlakonda-eightfold Jun 3, 2022
c46b7c3
feat: exporting select component
ktorlakonda-eightfold Jun 3, 2022
c5bd29a
Merge remote-tracking branch upstream/main into ENG-13987-add-select-…
ktorlakonda-eightfold Jun 3, 2022
8038467
feat: add storybook docs
ktorlakonda-eightfold Jun 3, 2022
69d114a
feat: removing unwanted props
ktorlakonda-eightfold Jun 3, 2022
5396483
feat: small spinner
ktorlakonda-eightfold Jun 6, 2022
c8d468f
feat: added input width
ktorlakonda-eightfold Jun 6, 2022
3d3ec15
feat: mr comments
ktorlakonda-eightfold Jun 7, 2022
9aac6e2
feat: ci fixes
ktorlakonda-eightfold Jun 7, 2022
9d88137
Merge branch main of github.com:ktorlakonda-eightfold/octuple into EN…
ktorlakonda-eightfold Jun 8, 2022
091eaf4
feat: updating snaps after merge
ktorlakonda-eightfold Jun 8, 2022
5495299
feat: spacing, and minor fixes
ktorlakonda-eightfold Jun 10, 2022
0996b27
Merge branch 'main' of github.com:EightfoldAI/octuple into ENG-13987-…
ktorlakonda-eightfold Jun 13, 2022
50d419d
feat: fixing snaps and minor css alignment
ktorlakonda-eightfold Jun 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
677 changes: 677 additions & 0 deletions src/__snapshots__/storybook.test.js.snap

Large diffs are not rendered by default.

25 changes: 20 additions & 5 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const Dropdown: FC<DropdownProps> = ({
offset = 0,
positionStrategy = 'absolute',
onVisibleChange,
beforeToggleStateChange,
disabled,
closeOnDropdownClick = true,
}) => {
Expand All @@ -56,16 +57,21 @@ export const Dropdown: FC<DropdownProps> = ({
});

const toggle: Function =
(show: boolean): Function =>
(
show: boolean,
beforeToggleStateChange = (show: boolean) => show
): Function =>
(e: SyntheticEvent): void => {
// to control the toggle behaviour
const updatedShow = beforeToggleStateChange(show);
if (PREVENT_DEFAULT_TRIGGERS.includes(trigger)) {
e.preventDefault();
}
setClosing(!show);
setClosing(!updatedShow);
timeout && clearTimeout(timeout);
timeout = setTimeout(
() => {
setVisible(show);
setVisible(updatedShow);
},
!show ? ANIMATION_DURATION : 0
);
Expand Down Expand Up @@ -136,7 +142,11 @@ export const Dropdown: FC<DropdownProps> = ({
style={dropdownStyles}
className={dropdownClasses}
tabIndex={0}
onClick={closeOnDropdownClick ? toggle(false) : null}
onClick={
closeOnDropdownClick
? toggle(false, beforeToggleStateChange)
: null
}
id={dropdownId}
>
{overlay}
Expand All @@ -149,7 +159,12 @@ export const Dropdown: FC<DropdownProps> = ({
style={style}
ref={reference}
{...(TRIGGER_TO_HANDLER_MAP_ON_LEAVE[trigger]
? { [TRIGGER_TO_HANDLER_MAP_ON_LEAVE[trigger]]: toggle(false) }
? {
[TRIGGER_TO_HANDLER_MAP_ON_LEAVE[trigger]]: toggle(
false,
beforeToggleStateChange
),
}
: {})}
>
{getReference()}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Dropdown/Dropdown.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Placement, Strategy } from '@floating-ui/react-dom';
import React from 'react';
ktorlakonda-eightfold marked this conversation as resolved.
Show resolved Hide resolved
import { Placement, Strategy } from '@floating-ui/react-dom';

export interface DropdownProps {
/**
Expand All @@ -11,6 +11,11 @@ export interface DropdownProps {
* @param visible {boolean}
*/
onVisibleChange?: (visible: boolean) => void;
/**
* Callback to
ktorlakonda-eightfold marked this conversation as resolved.
Show resolved Hide resolved
* @param visible {boolean}
*/
beforeToggleStateChange?: (show: boolean) => boolean;
/**
* The dropdown content
*/
Expand Down
18 changes: 18 additions & 0 deletions src/components/Inputs/Input.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ export interface TextInputProps extends InputProps<HTMLInputElement> {
* @default false
*/
required?: boolean;

/**
* option to show the clear input button.
* default is true for backward compatibility
* @default true
*/
clearable?: boolean;

/**
* onclear event handler.
*/
onClear?: React.MouseEventHandler<Element>;
}

export interface InputProps<T>
Expand Down Expand Up @@ -283,4 +295,10 @@ export interface InputProps<T>
* @default 10
*/
waitInterval?: number;

/**
* input readonly.
* @default false
*/
readonly?: boolean;
}
Loading