-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect data object data types with data (#749)
- Loading branch information
1 parent
a75faeb
commit 0f4443c
Showing
40 changed files
with
2,524 additions
and
77 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
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
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 |
---|---|---|
|
@@ -26,6 +26,6 @@ export default config | |
|
||
export const _default = { | ||
args: { | ||
value: [0, 100] | ||
value: { minimum: 3, maximum: 10 } | ||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
...ic-types/defintinitions/objects/data-related/components/boolean-select/boolean-select.tsx
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,67 @@ | ||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - Pimcore Open Core License (POCL) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react' | ||
import { Select, type SelectProps } from '@Pimcore/components/select/select' | ||
|
||
export interface BooleanSelectProps extends SelectProps { | ||
value?: boolean | null | ||
className?: string | ||
onChange?: (value?: boolean | null) => void | ||
} | ||
|
||
export const BooleanSelect = (props: BooleanSelectProps): React.JSX.Element => { | ||
const [value, setValue] = useState<boolean | null>(props.value ?? null) | ||
|
||
const mapValue = (value?: boolean | null): number | undefined => { | ||
if (value === undefined) { | ||
return undefined | ||
} | ||
if (value === null) { | ||
return 0 | ||
} | ||
|
||
return value ? 1 : -1 | ||
} | ||
|
||
const reverseMapValue = (value?: number): boolean | null | undefined => { | ||
if (value === undefined) { | ||
return undefined | ||
} | ||
if (value === 0) { | ||
return null | ||
} | ||
|
||
return value === 1 | ||
} | ||
|
||
useEffect(() => { | ||
if (props.onChange !== undefined) { | ||
props.onChange(value) | ||
} | ||
}, [value]) | ||
|
||
const onChange = (value?: number): void => { | ||
const newValue = reverseMapValue(value) | ||
setValue(newValue ?? null) | ||
props.onChange?.(newValue) | ||
} | ||
|
||
return ( | ||
<Select | ||
{ ...props } | ||
onChange={ onChange } | ||
value={ mapValue(value) } | ||
/> | ||
) | ||
} |
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.