Skip to content

Commit

Permalink
feat(ValidSelect): Add creatable option prop #minor
Browse files Browse the repository at this point in the history
  • Loading branch information
aris-fm authored Jun 27, 2022
1 parent 6b33ba7 commit d47486c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.6.0]
### Added
- `ValidSelect` add creatable props

## [0.5.1]
### Fixed
- `Pagination` fix display styling
Expand Down
2 changes: 1 addition & 1 deletion build/components/ValidatedInput/ValidSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export interface ValidSelectProps extends SelectProps {
className?: string;
helperText?: React.ReactNode;
}
export declare const ValidSelect: ({ label, placeholder, options, name, value, onChange, errMessage, optionalLabel, isInvalid, isDisabled, isRequired, isClearable, tooltip, selectDataQa, isMulti, className, helperText, ...props }: ValidSelectProps) => JSX.Element;
export declare const ValidSelect: ({ label, placeholder, options, name, value, onChange, errMessage, optionalLabel, isInvalid, isDisabled, isRequired, isClearable, tooltip, selectDataQa, isMulti, className, helperText, isCreatable, ...props }: ValidSelectProps) => JSX.Element;
3 changes: 2 additions & 1 deletion build/components/styled-atlaskit/Select/Select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { SelectOption } from "../../../types";
import "./Select.scss";
export interface SelectProps extends Omit<AkSelectProps<SelectOption, boolean>, "onChange"> {
onChange?: (option: SelectOption) => void;
isCreatable?: boolean;
}
export declare const Select: ({ isMulti, onChange, ...props }: SelectProps) => JSX.Element;
export declare const Select: ({ isMulti, isCreatable, onChange, ...props }: SelectProps) => JSX.Element;
2 changes: 1 addition & 1 deletion build/index.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.es.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "justice-ui-library",
"version": "0.5.1",
"version": "0.6.0",
"author": "AccelByte Inc",
"license": "AccelByte License",
"main": "./build/index.js",
Expand Down
2 changes: 2 additions & 0 deletions src/components/ValidatedInput/ValidSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const ValidSelect = ({
isMulti = false,
className,
helperText,
isCreatable = false,
...props
}: ValidSelectProps) => (
<div className={classNames("valid-select-input", className)}>
Expand All @@ -71,6 +72,7 @@ export const ValidSelect = ({
isDisabled={isDisabled}
isClearable={isClearable}
isMulti={isMulti}
isCreatable={isCreatable}
dataQa={selectDataQa}
/>
{isInvalid && <FieldErrorMessage message={errMessage} />}
Expand Down
30 changes: 19 additions & 11 deletions src/components/styled-atlaskit/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
*/

import React from "react";
import { default as AkSelect, SelectProps as AkSelectProps } from "@atlaskit/select";
import {
default as AkSelect,
SelectProps as AkSelectProps,
CreatableSelect,
OptionType,
OptionsType,
} from "@atlaskit/select";
import { SelectOption } from "../../../types";
import "./Select.scss";

export interface SelectProps extends Omit<AkSelectProps<SelectOption, boolean>, "onChange"> {
onChange?: (option: SelectOption) => void;
isCreatable?: boolean;
}

export const Select = ({ isMulti = false, onChange, ...props }: SelectProps) => {
return (
<AkSelect
className="styled-atlaskit-select"
classNamePrefix={"styled-atlaskit-select"}
isMulti={isMulti}
onChange={onChange ? (item) => onChange(item as SelectOption) : undefined}
{...props}
/>
);
export const Select = ({ isMulti = false, isCreatable = false, onChange, ...props }: SelectProps) => {
const defaultProps = {
isMulti,
className: "styled-atlaskit-select",
classNamePrefix: "styled-atlaskit-select",
onChange: onChange
? (item: OptionType | OptionsType<OptionType> | null) => onChange(item as SelectOption)
: undefined,
...props,
};
return isCreatable ? <CreatableSelect {...defaultProps} /> : <AkSelect {...defaultProps} />;
};

0 comments on commit d47486c

Please sign in to comment.