LayerList.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React from 'react'
  21. import { Card } from 'antd'
  22. import CommandList from './CommandList'
  23. import { LayerRadioGroup, LayerRadio } from './LayerRadio'
  24. import { LayerOperations } from '../../constants'
  25. import { LayerBase } from '../../types'
  26. import { LayerSelectionInfo } from './types'
  27. interface ILayerListProps {
  28. layers: LayerBase[]
  29. selection: LayerSelectionInfo
  30. onCommand: (operation: LayerOperations) => void
  31. onSelectionChange: (
  32. layerId: number,
  33. checked: boolean,
  34. exclusive: boolean
  35. ) => void
  36. }
  37. const LayerList: React.FC<ILayerListProps> = (props) => {
  38. const { layers, selection, onCommand, onSelectionChange } = props
  39. return (
  40. <Card
  41. className="display-layer-list"
  42. size="small"
  43. title={
  44. <CommandList className="display-layer-command" onCommand={onCommand} />
  45. }
  46. >
  47. <LayerRadioGroup>
  48. {layers.map((layer) => (
  49. <LayerRadio
  50. key={layer.id}
  51. id={layer.id}
  52. checked={selection[layer.id].selected}
  53. onChange={onSelectionChange}
  54. >
  55. {layer.name}
  56. </LayerRadio>
  57. ))}
  58. </LayerRadioGroup>
  59. </Card>
  60. )
  61. }
  62. export default React.memo(LayerList)