-
Couldn't load subscription status.
- Fork 4.4k
[Dashboards] - Min Max range on secondary axis bar charts #15118
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9882c6b
done
ehconitin bff3f99
range should be only for numeric values, like omit null values
ehconitin 808832c
improve input
ehconitin 4a5db13
validate range max min and make groupby resolver service changes more…
ehconitin ddb770b
grep
ehconitin a9c02d6
update snapshot
ehconitin 5031066
fix
ehconitin 27f2475
fix
ehconitin 871e2ea
improve
ehconitin 549b184
nit
ehconitin 58ab7f0
macros adjust
ehconitin a62ce9b
figma
ehconitin 3f46f4a
Merge remote-tracking branch 'upstream/main' into min-max-range-clean
ehconitin 138d3e7
improve
ehconitin f94c950
new plan
ehconitin eca043b
continuew
ehconitin 0983d71
Merge remote-tracking branch 'upstream/main' into min-max-range-clean
ehconitin dbe0da7
fix
ehconitin 9512d6d
improve
ehconitin 7d9df2c
match figma
ehconitin adf8d1c
Merge remote-tracking branch 'upstream/main' into min-max-range-clean
ehconitin e36a07f
Merge remote-tracking branch 'upstream/main' into min-max-range-clean
ehconitin 5d8295c
refact
ehconitin eaf6f06
Merge remote-tracking branch 'upstream/main' into min-max-range-clean
ehconitin 40fe7fc
Merge branch 'main' into min-max-range
charlesBochet 828d689
Merge branch 'main' into min-max-range
charlesBochet 9bc5100
Fixes
charlesBochet d707db7
Merge branch 'main' into min-max-range
charlesBochet bffe841
Fixes
charlesBochet 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
packages/twenty-front/src/modules/command-menu/components/CommandMenuItemNumberInput.tsx
This file contains hidden or 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,92 @@ | ||
| import { TextInput } from '@/ui/input/components/TextInput'; | ||
| import styled from '@emotion/styled'; | ||
| import { useState } from 'react'; | ||
| import { Key } from 'ts-key-enum'; | ||
| import { isDefined } from 'twenty-shared/utils'; | ||
| import { | ||
| canBeCastAsNumberOrNull, | ||
| castAsNumberOrNull, | ||
| } from '~/utils/cast-as-number-or-null'; | ||
|
|
||
| type CommandMenuItemNumberInputProps = { | ||
| value: string; | ||
| onChange: (value: number | null) => void; | ||
| onValidate?: (value: number | null) => boolean; | ||
| placeholder?: string; | ||
| }; | ||
| const StyledRightAlignedTextInput = styled(TextInput)` | ||
| input { | ||
| :focus { | ||
| color: ${({ theme }) => theme.font.color.primary}; | ||
| } | ||
| color: ${({ theme }) => theme.font.color.tertiary}; | ||
| text-align: right; | ||
| } | ||
| `; | ||
| export const CommandMenuItemNumberInput = ({ | ||
| value, | ||
| onChange, | ||
| onValidate, | ||
| placeholder, | ||
| }: CommandMenuItemNumberInputProps) => { | ||
| const [draftValue, setDraftValue] = useState(value); | ||
| const [hasError, setHasError] = useState(false); | ||
|
|
||
| const handleChange = (text: string) => { | ||
| setDraftValue(text); | ||
| if (hasError) { | ||
| setHasError(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleCommit = () => { | ||
| if (!canBeCastAsNumberOrNull(draftValue)) { | ||
| setHasError(true); | ||
| setDraftValue(value); | ||
| return; | ||
| } | ||
|
|
||
| const numericValue = castAsNumberOrNull(draftValue); | ||
|
|
||
| if (isDefined(onValidate)) { | ||
| const isInvalid = onValidate(numericValue); | ||
| if (isInvalid) { | ||
| setHasError(true); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| onChange(numericValue); | ||
| setHasError(false); | ||
| }; | ||
|
|
||
| const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => { | ||
| event.target.select(); | ||
| }; | ||
|
|
||
| const handleBlur = () => { | ||
| handleCommit(); | ||
| }; | ||
|
|
||
| const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => { | ||
| if (event.key === Key.Enter || event.key === Key.Escape) { | ||
| event.stopPropagation(); | ||
| handleCommit(); | ||
| } else { | ||
| event.stopPropagation(); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <StyledRightAlignedTextInput | ||
| value={draftValue} | ||
| sizeVariant="sm" | ||
| onChange={handleChange} | ||
| onFocus={handleFocus} | ||
| onBlur={handleBlur} | ||
| onKeyDown={handleKeyDown} | ||
| placeholder={placeholder} | ||
| noErrorHelper | ||
charlesBochet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or 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.
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.
this should be reviewed with design to make the TextInput component evolve rather than overriding here