-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[optimize] update Upstream packages
- Loading branch information
Showing
7 changed files
with
234 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "idea-react", | ||
"version": "0.22.4", | ||
"version": "0.23.0", | ||
"license": "LGPL-3.0", | ||
"author": "[email protected]", | ||
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.", | ||
|
@@ -23,30 +23,30 @@ | |
"main": "dist/index.umd.js", | ||
"module": "dist/index.js", | ||
"dependencies": { | ||
"@editorjs/editorjs": "^2.23.2", | ||
"@editorjs/editorjs": "^2.24.3", | ||
"@editorjs/paragraph": "^2.8.0", | ||
"classnames": "^2.3.1", | ||
"editorjs-html": "^3.4.2", | ||
"lodash": "^4.17.21", | ||
"prismjs": "^1.27.0", | ||
"prismjs": "^1.28.0", | ||
"react": "^17.0.2", | ||
"react-bootstrap": "^2.2.3", | ||
"react-bootstrap": "^2.4.0", | ||
"react-dom": "^17.0.2", | ||
"react-editor-js": "^2.0.6", | ||
"react-element-to-jsx-string": "^14.3.4", | ||
"web-utility": "^3.6.1" | ||
"react-element-to-jsx-string": "^15.0.0", | ||
"web-utility": "^3.6.5" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.181", | ||
"@types/lodash": "^4.14.182", | ||
"@types/prismjs": "^1.26.0", | ||
"@types/react-dom": "^17.0.15", | ||
"husky": "^7.0.4", | ||
"@types/react-dom": "^17.0.17", | ||
"husky": "^8.0.1", | ||
"less": "^4.1.2", | ||
"lint-staged": "^12.3.7", | ||
"lint-staged": "^12.4.1", | ||
"microbundle": "^0.14.2", | ||
"open-cli": "^7.0.1", | ||
"prettier": "^2.6.2", | ||
"typedoc": "^0.22.14", | ||
"typedoc": "^0.22.15", | ||
"typedoc-plugin-mdn-links": "^1.0.6", | ||
"typescript": "~4.3.5" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { makeArray } from 'web-utility'; | ||
import classNames from 'classnames'; | ||
import React, { | ||
ReactNode, | ||
ReactElement, | ||
isValidElement, | ||
PropsWithChildren, | ||
FC | ||
} from 'react'; | ||
import { Dropdown } from 'react-bootstrap'; | ||
|
||
export type OptionProps = PropsWithChildren<{ | ||
value?: string; | ||
}>; | ||
|
||
export const Option: FC<OptionProps> = ({ value, children }) => ( | ||
<Dropdown.Item data-value={value}>{children}</Dropdown.Item> | ||
); | ||
|
||
Option.displayName = 'Option'; | ||
|
||
export type SelectProps = PropsWithChildren<{ | ||
className?: string; | ||
value?: string; | ||
onChange?: (value: string) => any; | ||
}>; | ||
|
||
export const Select: FC<SelectProps> = ({ | ||
className, | ||
children, | ||
value, | ||
onChange | ||
}) => { | ||
const current = (makeArray(children) as ReactNode[]).find( | ||
node => | ||
isValidElement<OptionProps>(node) && | ||
node.type === Option && | ||
node.props.value === value | ||
) as ReactElement<OptionProps, typeof Option>; | ||
|
||
return ( | ||
<Dropdown | ||
onClick={({ target }) => { | ||
const option = (target as HTMLElement).closest<HTMLElement>( | ||
'.dropdown-item' | ||
); | ||
if (!option) return; | ||
|
||
const { value } = option.dataset; | ||
|
||
onChange?.(value); | ||
}} | ||
> | ||
<Dropdown.Toggle | ||
className={classNames( | ||
'w-100', | ||
'd-flex', | ||
'justify-content-between', | ||
'align-items-center', | ||
'bg-white', | ||
'text-dark', | ||
className | ||
)} | ||
> | ||
<div>{current?.props.children}</div> | ||
</Dropdown.Toggle> | ||
|
||
<Dropdown.Menu>{children}</Dropdown.Menu> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
Select.displayName = 'Select'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
68ca421
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for idea-react ready!
✅ Preview
https://idea-react-5405qgaeg-stevending1st.vercel.app
Built with commit 68ca421.
This pull request is being automatically deployed with vercel-action