groupProps.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import React, { useState, useLayoutEffect, Component } from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { Button, Modal, TreeSelect, Row, Col, Avatar, Icon, Select as BasicSelect,
  4. Form,
  5. useFormState,
  6. useFormApi,
  7. useFieldApi,
  8. useFieldState,
  9. withFormState,
  10. withFormApi,
  11. withField,
  12. ArrayField,
  13. AutoComplete,
  14. Collapse } from '../../../index';
  15. const InputGroupDemo = () => {
  16. const selectProps = {
  17. style: { width: '100px' },
  18. placeholder: '国家',
  19. field: 'country',
  20. rules: [
  21. { required: true }
  22. ]
  23. };
  24. return (
  25. <>
  26. <Form onSubmit={(values) => console.log(values)} labelPosition='top' style={{ width: 600 }}>
  27. <Form.InputGroup label={{ text: 'Movie', required: true }} labelPosition="left" style={{ width: 500 }}>
  28. <Form.Select {...selectProps} field='area'>
  29. <Form.Select.Option value="crime">+86</Form.Select.Option>
  30. <Form.Select.Option value="comedy">+1</Form.Select.Option>
  31. <Form.Select.Option value="tragedy">+83</Form.Select.Option>
  32. </Form.Select>
  33. <Form.Input placeholder="手机号码" style={{ width: 100 }} field="phone" noLabel rules={[{ required: true }]} />
  34. <Form.InputNumber placeholder="评分" style={{ width: 140 }} field="MovieScore" noLabel />
  35. </Form.InputGroup>
  36. <Form.InputGroup label={{ text: (<span>手机号码</span>), required: true }} labelPosition='top' extraText='i am extraText of Form.InputGroup'>
  37. <Form.Select style={{ width: 150 }} field='phonePrefix1' initValue='+86' rules={[{ required: true }]} showClear>
  38. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  39. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  40. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  41. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  42. </Form.Select>
  43. <Form.Input initValue='18912345678' style={{ width: 250 }} field='phoneNumber1' trigger={['mount', 'change']} validate={val => 'always errors'} showClear />
  44. </Form.InputGroup>
  45. <Form.InputGroup
  46. label={{ text: (<span>手机号码</span>), required: true }}
  47. labelPosition='top'
  48. extraTextPosition='middle'
  49. extraText='i am extraText of Form.InputGroup'>
  50. <Form.Select style={{ width: 150 }} field='phonePrefix1' initValue='+86' rules={[{ required: true }]} showClear>
  51. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  52. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  53. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  54. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  55. </Form.Select>
  56. <Form.Input initValue='18912345678' style={{ width: 250 }} field='phoneNumber1' trigger={['mount', 'change']} validate={val => 'always errors'} showClear />
  57. </Form.InputGroup>
  58. <Form.InputGroup label={{ text: (<span>手机号码</span>), required: true }} labelPosition='left' style={{ width: 400 }}>
  59. <Form.Select style={{ width: 150 }} field='phonePrefix2' initValue='+86' rules={[{ required: true }]} showClear>
  60. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  61. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  62. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  63. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  64. </Form.Select>
  65. <Form.Input initValue='18912345678' style={{ width: 250 }} field='phoneNumber2' showClear />
  66. </Form.InputGroup>
  67. <Form.InputGroup
  68. label={{ text: (<span>手机号码</span>), required: true }}
  69. labelPosition='left'
  70. extraTextPosition='bottom'
  71. extraText='i am extraText of Form.InputGroup'
  72. style={{ width: 400 }}
  73. >
  74. <Form.Select style={{ width: 150 }} field='phonePrefix3' initValue='+86' rules={[{ required: true }]} showClear>
  75. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  76. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  77. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  78. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  79. </Form.Select>
  80. <Form.Input style={{ width: 250 }} field='phoneNumber3' trigger={['mount', 'change']} validate={val => 'always errors'} showClear />
  81. </Form.InputGroup>
  82. <Form.InputGroup
  83. label={{ text: (<span>手机号码</span>), required: true }}
  84. labelPosition='left'
  85. extraTextPosition='middle'
  86. extraText='i am extraText of Form.InputGroup'
  87. style={{ width: 400 }}
  88. >
  89. <Form.Select style={{ width: 150 }} field='phonePrefix4' initValue='+86' rules={[{ required: true }]} showClear>
  90. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  91. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  92. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  93. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  94. </Form.Select>
  95. <Form.Input style={{ width: 250 }} field='phoneNumber4' trigger={['mount', 'change']} validate={val => 'always errors'} rules={[{ required: true }]} showClear />
  96. </Form.InputGroup>
  97. <Button htmlType='submit'>提交</Button>
  98. </Form>
  99. <Form
  100. labelCol={{ span: 2 }}
  101. wrapperCol={{ span: 22 }}
  102. >
  103. <Form.InputGroup
  104. label={{ text: (<span>手机号码</span>), required: true }}
  105. labelPosition='left'
  106. extraTextPosition='bottom'
  107. extraText='i am extraText of Form.InputGroup'
  108. style={{ width: 400 }}
  109. >
  110. <Form.Select style={{ width: 150 }} field='phonePrefix3' initValue='+86' rules={[{ required: true }]} showClear>
  111. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  112. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  113. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  114. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  115. </Form.Select>
  116. <Form.Input style={{ width: 250 }} field='phoneNumber3' trigger={['mount', 'change']} validate={val => 'always errors'} showClear />
  117. </Form.InputGroup>
  118. <Form.InputGroup
  119. label={{ text: (<span>手机号码</span>), required: true }}
  120. labelPosition='left'
  121. extraTextPosition='middle'
  122. extraText='i am extraText of Form.InputGroup'
  123. style={{ width: 400 }}
  124. >
  125. <Form.Select style={{ width: 150 }} field='phonePrefix4' initValue='+86' rules={[{ required: true }]} showClear>
  126. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  127. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  128. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  129. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  130. </Form.Select>
  131. <Form.Input style={{ width: 250 }} field='phoneNumber4' trigger={['mount', 'change']} validate={val => 'always errors'} rules={[{ required: true }]} showClear />
  132. </Form.InputGroup>
  133. </Form>
  134. <Form
  135. labelCol={{ span: 4 }}
  136. wrapperCol={{ span: 20 }}
  137. >
  138. <Form.InputGroup
  139. label={{ text: (<span>手机号码</span>), required: true }}
  140. labelPosition='top'
  141. extraTextPosition='bottom'
  142. extraText='i am extraText of Form.InputGroup'
  143. style={{ width: 400 }}
  144. >
  145. <Form.Select style={{ width: 150 }} field='phonePrefix3' initValue='+86' rules={[{ required: true }]} showClear>
  146. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  147. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  148. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  149. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  150. </Form.Select>
  151. <Form.Input style={{ width: 250 }} field='phoneNumber3' trigger={['mount', 'change']} validate={val => 'always errors'} showClear />
  152. </Form.InputGroup>
  153. <Form.InputGroup
  154. label={{ text: (<span>手机号码</span>), required: true }}
  155. labelPosition='top'
  156. extraTextPosition='middle'
  157. extraText='i am extraText of Form.InputGroup'
  158. style={{ width: 400 }}
  159. >
  160. <Form.Select style={{ width: 150 }} field='phonePrefix4' initValue='+86' rules={[{ required: true }]} showClear>
  161. <Form.Select.Option value='+1'>美国+1</Form.Select.Option>
  162. <Form.Select.Option value='+852'>香港+852</Form.Select.Option>
  163. <Form.Select.Option value='+86'>中国+86</Form.Select.Option>
  164. <Form.Select.Option value='+81'>日本+81</Form.Select.Option>
  165. </Form.Select>
  166. <Form.Input style={{ width: 250 }} field='phoneNumber4' trigger={['mount', 'change']} validate={val => 'always errors'} rules={[{ required: true }]} showClear />
  167. </Form.InputGroup>
  168. </Form>
  169. </>
  170. );
  171. };
  172. export { InputGroupDemo };