RCTDatePickerNativeComponent.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
  12. import type {ViewProps} from '../View/ViewPropTypes';
  13. import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
  14. import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
  15. import * as React from 'react';
  16. import type {
  17. Float,
  18. WithDefault,
  19. BubblingEventHandler,
  20. } from 'react-native/Libraries/Types/CodegenTypes';
  21. type Event = $ReadOnly<{|
  22. timestamp: Float,
  23. |}>;
  24. type NativeProps = $ReadOnly<{|
  25. ...ViewProps,
  26. date?: ?Float,
  27. initialDate?: ?Float,
  28. locale?: ?string,
  29. maximumDate?: ?Float,
  30. minimumDate?: ?Float,
  31. minuteInterval?: WithDefault<
  32. 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30,
  33. 1,
  34. >,
  35. mode?: WithDefault<'date' | 'time' | 'datetime', 'date'>,
  36. onChange?: ?BubblingEventHandler<Event>,
  37. timeZoneOffsetInMinutes?: ?Float,
  38. |}>;
  39. type ComponentType = HostComponent<NativeProps>;
  40. interface NativeCommands {
  41. +setNativeDate: (
  42. viewRef: React.ElementRef<ComponentType>,
  43. date: Float,
  44. ) => void;
  45. }
  46. export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
  47. supportedCommands: ['setNativeDate'],
  48. });
  49. export default (codegenNativeComponent<NativeProps>('DatePicker', {
  50. paperComponentName: 'RCTDatePicker',
  51. excludedPlatform: 'android',
  52. }): HostComponent<NativeProps>);