SlideSettingForm.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, { useEffect } from 'react'
  21. import { SlideLayerSettingForm } from './Form'
  22. import { WrappedFormUtils } from 'antd/lib/form/Form'
  23. import { slideSettings, GraphTypes } from './Form/constants'
  24. import { ISlideParams } from 'containers/Viz/types'
  25. const slideSetting = slideSettings[GraphTypes.Slide]
  26. interface ISlideSettingFormProps {
  27. slideId: number
  28. slideParams: ISlideParams
  29. onChange: (changedValues: Partial<ISlideParams>) => void
  30. }
  31. const SlideSettingForm: React.FC<ISlideSettingFormProps> = (props) => {
  32. const { slideId, slideParams, onChange } = props
  33. const refForm = React.useRef<WrappedFormUtils>(null)
  34. useEffect(() => {
  35. if (refForm.current) {
  36. const fieldsValue: ISlideParams = {
  37. autoSlideGlobal: true,
  38. autoPlay: true,
  39. transitionGlobal: true,
  40. backgroundImage: undefined,
  41. ...slideParams
  42. }
  43. refForm.current.setFieldsValue(fieldsValue)
  44. }
  45. }, [slideParams])
  46. return (
  47. <SlideLayerSettingForm
  48. wrappedComponentRef={refForm}
  49. setting={slideSetting}
  50. slideId={slideId}
  51. onChange={onChange}
  52. />
  53. )
  54. }
  55. export default React.memo(SlideSettingForm)