-
Notifications
You must be signed in to change notification settings - Fork 42
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: select component #251
Open
jz5426
wants to merge
30
commits into
IBM:main
Choose a base branch
from
jz5426:select
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
cb81955
dsl
jz5426 681ec67
resolve conflict
jz5426 dce07da
resolve comments
jz5426 8f812ea
ui setting progress
jz5426 4442665
develop option icon
jz5426 401dd37
developer option
jz5426 60b55fe
checkbox style
jz5426 2947cf1
developer option
jz5426 ee6a703
place tooltip position bottom
jz5426 81e8d98
lint
jz5426 cf102c3
fix export err
70c15e0
v11 code modification and export fix
18c5e9e
action
fb213b0
Merge branch 'main' of https://github.com/IBM/carbon-ui-builder into …
44e1c5e
lint error fix
f13a423
lint err
85c67c4
progress
d0b9b6a
checkbox errs
30aca9f
fixed react import
fc2a5ef
react export fix
3818863
angular export and helper text setting
79b71ce
remove unncessary slot
e4bf655
export code for angular
1405d2c
Merge branch 'main' into select
Akshat55 4a5b944
Update player/react/src/lib/components/index.ts
jz5426 278b0e4
revision
2504296
Merge branch 'select' of https://github.com/maxxyouu/carbon-ui-builde…
7522b2e
revision
73a03fe
revision
da0dc7b
terneries
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from 'react'; | ||
import { | ||
Select, | ||
SelectItem, | ||
SelectItemGroup | ||
} from '@carbon/react'; | ||
import { CssClasses, SendSignal } from '../types'; | ||
import { commonSlots, slotsDisabled } from '../common-slots'; | ||
|
||
export interface SelectState { | ||
id?: string; | ||
type: string; | ||
inline?: boolean; | ||
invalid?: boolean; | ||
disabled?: boolean; | ||
warn?: boolean; | ||
label: string; | ||
invalidText?: string; | ||
warnText?: string; | ||
size?: string; | ||
defaultValue: string; | ||
helperText?: string; | ||
items: []; | ||
cssClasses?: CssClasses[]; | ||
codeContext?: { | ||
name: string; | ||
href?: string; | ||
}; | ||
} | ||
|
||
export const type = 'select'; | ||
|
||
export const signals = ['click']; | ||
|
||
export const slots = { | ||
...commonSlots, | ||
...slotsDisabled, | ||
label: 'string', | ||
defaultValue: 'string' | ||
}; | ||
|
||
export const UISelect = ({ state, sendSignal }: { | ||
state: SelectState; | ||
setState: (state: any) => void; | ||
setGlobalState: (state: any) => void; | ||
sendSignal: SendSignal; | ||
}) => { | ||
|
||
if (state.type !== 'select') { | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
return <></>; | ||
} | ||
|
||
return <Select | ||
id={state.id} | ||
defaultValue={state.defaultValue} | ||
helperText={state.helperText} | ||
invalidText={state.invalidText} | ||
warn={state.warn} | ||
warnText={state.warnText} | ||
size={state.size} | ||
label={state.label} | ||
inline={state.inline} | ||
invalid={state.invalid} | ||
disabled={state.disabled}> | ||
{ | ||
state.items.map((step: any) => | ||
step.items && step.items.length > 0 | ||
? <SelectItemGroup | ||
key={step.id} | ||
label={step.label} | ||
disabled={step.disabled}> | ||
{ | ||
step.items.map((child: any) => <SelectItem | ||
key={step.id} | ||
onClick={() => sendSignal(step.id, 'click')} | ||
text={child.text} | ||
value={child.value} | ||
disabled={child.disabled} | ||
hidden={child.hidden} | ||
/>) | ||
} | ||
</SelectItemGroup> | ||
: <SelectItem | ||
onClick={() => sendSignal(step.id, 'click')} | ||
key={step.id} | ||
text={step.text} | ||
value={step.value} | ||
disabled={step.disabled} | ||
hidden={step.hidden} /> | ||
) | ||
} | ||
</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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what's the default defaultValue?
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.
follow the variable name in react:
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.
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.
make it optional!