index.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. import React from 'react';
  2. import Types from '../../lib/Types';
  3. import Module from '../../lib/Module';
  4. import { Accordion as AccordionCtor } from 'native-base';
  5. import { Actionsheet as ActionsheetCtor } from 'native-base';
  6. import { Badge as BadgeCtor } from 'native-base';
  7. import { Body as BodyCtor } from 'native-base';
  8. import { Button as ButtonCtor } from 'native-base';
  9. import { Card as CardCtor } from 'native-base';
  10. import { CardItem as CardItemCtor } from 'native-base';
  11. import { CheckBox as CheckboxCtor } from 'native-base';
  12. import { Container as ContainerCtor } from 'native-base';
  13. import { Content as ContentCtor } from 'native-base';
  14. import { DatePicker as DatePickerCtor } from 'native-base';
  15. import { DeckSwiper as DeckSwiperCtor } from 'native-base';
  16. import { Fab as FabCtor } from 'native-base';
  17. import { Footer as FooterCtor } from 'native-base';
  18. import { FooterTab as FooterTabCtor } from 'native-base';
  19. import { Form as FormCtor } from 'native-base';
  20. import { Gravatar as GravatarCtor } from 'native-base';
  21. import { H1 as H1Ctor } from 'native-base';
  22. import { H2 as H2Ctor } from 'native-base';
  23. import { H3 as H3Ctor } from 'native-base';
  24. import { Header as HeaderCtor } from 'native-base';
  25. import { IconNB as IconNBCtor } from 'native-base';
  26. import { Input as InputCtor } from 'native-base';
  27. import { InputGroup as InputGroupCtor } from 'native-base';
  28. import { Item as ItemCtor } from 'native-base';
  29. import { Label as LabelCtor } from 'native-base';
  30. import { Left as LeftCtor } from 'native-base';
  31. import { List as ListCtor } from 'native-base';
  32. import { ListItem as ListItemCtor } from 'native-base';
  33. import { PickerItem as PickerItemCtor } from 'native-base';
  34. import { Radio as RadioCtor } from 'native-base';
  35. import { Right as RightCtor } from 'native-base';
  36. import { Root as RootCtor } from 'native-base';
  37. import { Segment as SegmentCtor } from 'native-base';
  38. import { Separator as SeparatorCtor } from 'native-base';
  39. import { Spinner as SpinnerCtor } from 'native-base';
  40. import { Subtitle as SubtitleCtor } from 'native-base';
  41. import { SwipeRow as SwipeRowCtor } from 'native-base';
  42. import { Switch as SwitchCtor } from 'native-base';
  43. import { Tab as TabCtor } from 'native-base';
  44. import { TabContainer as TabContainerCtor } from 'native-base';
  45. import { TabHeading as TabHeadingCtor } from 'native-base';
  46. import { Text as TextCtor } from 'native-base';
  47. import { Textarea as TextareaCtor } from 'native-base';
  48. import { Thumbnail as ThumbnailCtor } from 'native-base';
  49. import { Title as TitleCtor } from 'native-base';
  50. import { Toast as ToastCtor } from 'native-base';
  51. import { ToastContainer as ToastContainerCtor } from 'native-base';
  52. import { View as ViewCtor } from 'native-base';
  53. export class Accordion extends Module {
  54. constructor(props) {
  55. super(props);
  56. }
  57. display() {
  58. return <AccordionCtor {...this.props} />
  59. }
  60. }
  61. export class Actionsheet extends Module {
  62. constructor(props) {
  63. super(props);
  64. }
  65. display() {
  66. return <ActionsheetCtor {...this.props} />
  67. }
  68. }
  69. export class Badge extends Module {
  70. constructor(props) {
  71. super(props);
  72. }
  73. display() {
  74. let {
  75. text,
  76. icon,
  77. style,
  78. color,
  79. ...restProps
  80. } = this.props;
  81. return <BadgeCtor {...restProps} style={[{flexDirection: 'row'}, style]}>
  82. {icon ? <IconNBCtor name={icon} style={{ fontSize: 15, color, lineHeight: 27 }}/> : null}
  83. {text ? <TextCtor style={{ fontSize: 15, color, lineHeight: 27 }}>{text}</TextCtor> : null}
  84. </BadgeCtor>
  85. }
  86. }
  87. export class Body extends Module {
  88. constructor(props) {
  89. super(props);
  90. }
  91. display() {
  92. return <BodyCtor {...this.props} />
  93. }
  94. }
  95. export class Button extends Module {
  96. constructor(props) {
  97. super(props);
  98. }
  99. display() {
  100. let {
  101. text,
  102. icon,
  103. onPress,
  104. ...rest
  105. } = this.props;
  106. let run = () => {
  107. this.createAction(onPress)
  108. };
  109. return <ButtonCtor {...rest} onClick={run} onPress={run}>
  110. {icon ? <IconCtor name={icon} /> : null}
  111. {text ? <TextCtor>{text}</TextCtor> : null}
  112. </ButtonCtor>
  113. }
  114. }
  115. export class Card extends Module {
  116. constructor(props) {
  117. super(props);
  118. this.CoreSystem = props.CoreSystem;
  119. }
  120. display() {
  121. let {
  122. header,
  123. body,
  124. footer,
  125. bodyModules,
  126. ...rest
  127. } = this.props;
  128. let item = this.renderModule('Button','NativeBase');
  129. console.log("ITEM : ", item);
  130. return <CardCtor {...rest}>
  131. {header ? <CardItemCtor header>
  132. <TextCtor>{header}</TextCtor>
  133. </CardItemCtor>
  134. : null}
  135. <CardItemCtor>
  136. <BodyCtor>
  137. <TextCtor>
  138. {body}
  139. </TextCtor>
  140. {this.moduleArray(bodyModules)}
  141. </BodyCtor>
  142. </CardItemCtor>
  143. {footer ? <CardItemCtor footer>
  144. <TextCtor>{footer}</TextCtor>
  145. </CardItemCtor>
  146. : null}
  147. </CardCtor>;
  148. }
  149. }
  150. export class CardItem extends Module {
  151. constructor(props) {
  152. super(props);
  153. }
  154. display() {
  155. return <CardItemCtor {...this.props} />
  156. }
  157. }
  158. export class Checkbox extends Module {
  159. constructor(props) {
  160. super(props);
  161. }
  162. display() {
  163. return <CheckboxCtor {...this.props} />
  164. }
  165. }
  166. export class Container extends Module {
  167. constructor(props) {
  168. super(props);
  169. }
  170. display() {
  171. return <ContainerCtor {...this.props} />
  172. }
  173. }
  174. export class Content extends Module {
  175. constructor(props) {
  176. super(props);
  177. }
  178. display() {
  179. return <ContentCtor {...this.props} />
  180. }
  181. }
  182. export class DatePicker extends Module {
  183. constructor(props) {
  184. super(props);
  185. }
  186. display() {
  187. return <DatePickerCtor {...this.props} />
  188. }
  189. }
  190. export class DeckSwiper extends Module {
  191. constructor(props) {
  192. super(props);
  193. }
  194. display() {
  195. return <DeckSwiperCtor {...this.props} />
  196. }
  197. }
  198. export class Fab extends Module {
  199. constructor(props) {
  200. super(props);
  201. }
  202. display() {
  203. return <FabCtor {...this.props} />
  204. }
  205. }
  206. export class Footer extends Module {
  207. constructor(props) {
  208. super(props);
  209. }
  210. display() {
  211. return <FooterCtor {...this.props} />
  212. }
  213. }
  214. export class FooterTab extends Module {
  215. constructor(props) {
  216. super(props);
  217. }
  218. display() {
  219. return <FooterTabCtor {...this.props} />
  220. }
  221. }
  222. export class Form extends Module {
  223. constructor(props) {
  224. super(props);
  225. this.state = {};
  226. }
  227. submit() {
  228. this.createAction(this.props.onSubmit);
  229. }
  230. change(item, value) {
  231. this.setState({
  232. [item]: value
  233. });
  234. }
  235. display() {
  236. let {
  237. inputs,
  238. button,
  239. onSubmit,
  240. ...rest
  241. } = this.props;
  242. return [
  243. <FormCtor {...rest}>
  244. {inputs ? inputs.map((item, index) => {
  245. return <ItemCtor key={index} last={index === inputs.length-1}>
  246. <InputCtor placeholder={item}
  247. placeholderLabel={item}
  248. value={this.state[item && item.toLowerCase()] || ''}
  249. onChangeText={(value) => this.change(item && item.toLowerCase(), value)}/>
  250. </ItemCtor>
  251. }) : null}
  252. </FormCtor>,
  253. button ? <ButtonCtor onPress={() => this.submit()}>
  254. <TextCtor>{button}</TextCtor>
  255. </ButtonCtor>: null
  256. ]
  257. }
  258. }
  259. export class Gravatar extends Module {
  260. constructor(props) {
  261. super(props);
  262. }
  263. display() {
  264. return <GravatarCtor {...this.props} />
  265. }
  266. }
  267. export class H1 extends Module {
  268. constructor(props) {
  269. super(props);
  270. }
  271. display() {
  272. let {
  273. content,
  274. ...rest
  275. } = this.props;
  276. return <H1Ctor {...rest}>
  277. {content}
  278. </H1Ctor>
  279. }
  280. }
  281. export class H2 extends Module {
  282. constructor(props) {
  283. super(props);
  284. }
  285. display() {
  286. let {
  287. content,
  288. ...rest
  289. } = this.props;
  290. return <H2Ctor {...rest}>
  291. {content}
  292. </H2Ctor>
  293. }
  294. }
  295. export class H3 extends Module {
  296. constructor(props) {
  297. super(props);
  298. }
  299. display() {
  300. let {
  301. content,
  302. ...rest
  303. } = this.props;
  304. return <H3Ctor {...rest}>
  305. {content}
  306. </H3Ctor>
  307. }
  308. }
  309. export class Header extends Module {
  310. constructor(props) {
  311. super(props);
  312. }
  313. display() {
  314. return <HeaderCtor {...this.props} />
  315. }
  316. }
  317. export class IconNB extends Module {
  318. constructor(props) {
  319. super(props);
  320. }
  321. display() {
  322. return <IconNBCtor {...this.props} />
  323. }
  324. }
  325. export class Input extends Module {
  326. constructor(props) {
  327. super(props);
  328. }
  329. display() {
  330. let {
  331. icon,
  332. placeholder,
  333. ...rest
  334. } = this.props;
  335. return <ItemCtor {...rest}>
  336. <InputCtor placeholder={placeholder}/>
  337. {icon ? <IconNBCtor active name={icon} /> : null}
  338. </ItemCtor>;
  339. }
  340. }
  341. export class InputGroup extends Module {
  342. constructor(props) {
  343. super(props);
  344. }
  345. display() {
  346. return <InputGroupCtor {...this.props} />
  347. }
  348. }
  349. export class Item extends Module {
  350. constructor(props) {
  351. super(props);
  352. }
  353. display() {
  354. let {
  355. placeholder,
  356. mod,
  357. ...rest
  358. } = this.props;
  359. console.log("RENDERMOD:", mod);
  360. return <ContentCtor>
  361. <ItemCtor {...rest}>
  362. {this.module(mod)}
  363. </ItemCtor>
  364. </ContentCtor>;
  365. }
  366. }
  367. export class Label extends Module {
  368. constructor(props) {
  369. super(props);
  370. }
  371. display() {
  372. return <LabelCtor {...this.props} />
  373. }
  374. }
  375. export class Left extends Module {
  376. constructor(props) {
  377. super(props);
  378. }
  379. display() {
  380. return <LeftCtor {...this.props} />
  381. }
  382. }
  383. export class List extends Module {
  384. constructor(props) {
  385. super(props);
  386. }
  387. display() {
  388. return <ListCtor {...this.props} />
  389. }
  390. }
  391. export class ListItem extends Module {
  392. constructor(props) {
  393. super(props);
  394. }
  395. display() {
  396. return <ListItemCtor {...this.props} />
  397. }
  398. }
  399. export class PickerItem extends Module {
  400. constructor(props) {
  401. super(props);
  402. }
  403. display() {
  404. return <PickerItemCtor {...this.props} />
  405. }
  406. }
  407. export class Radio extends Module {
  408. constructor(props) {
  409. super(props);
  410. }
  411. display() {
  412. return <RadioCtor {...this.props} />
  413. }
  414. }
  415. export class Right extends Module {
  416. constructor(props) {
  417. super(props);
  418. }
  419. display() {
  420. return <RightCtor {...this.props} />
  421. }
  422. }
  423. export class Root extends Module {
  424. constructor(props) {
  425. super(props);
  426. }
  427. display() {
  428. return <RootCtor {...this.props} />
  429. }
  430. }
  431. export class Segment extends Module {
  432. constructor(props) {
  433. super(props);
  434. }
  435. display() {
  436. return <SegmentCtor {...this.props} />
  437. }
  438. }
  439. export class Separator extends Module {
  440. constructor(props) {
  441. super(props);
  442. }
  443. display() {
  444. return <SeparatorCtor {...this.props} />
  445. }
  446. }
  447. export class Spinner extends Module {
  448. constructor(props) {
  449. super(props);
  450. }
  451. display() {
  452. return <SpinnerCtor {...this.props} />
  453. }
  454. }
  455. export class Subtitle extends Module {
  456. constructor(props) {
  457. super(props);
  458. }
  459. display() {
  460. return <SubtitleCtor {...this.props} />
  461. }
  462. }
  463. export class SwipeRow extends Module {
  464. constructor(props) {
  465. super(props);
  466. }
  467. display() {
  468. return <SwipeRowCtor {...this.props} />
  469. }
  470. }
  471. export class Switch extends Module {
  472. constructor(props) {
  473. super(props);
  474. }
  475. display() {
  476. return <SwitchCtor {...this.props} />
  477. }
  478. }
  479. export class Tab extends Module {
  480. constructor(props) {
  481. super(props);
  482. }
  483. display() {
  484. return <TabCtor {...this.props} />
  485. }
  486. }
  487. export class TabContainer extends Module {
  488. constructor(props) {
  489. super(props);
  490. }
  491. display() {
  492. return <TabContainerCtor {...this.props} />
  493. }
  494. }
  495. export class TabHeading extends Module {
  496. constructor(props) {
  497. super(props);
  498. }
  499. display() {
  500. return <TabHeadingCtor {...this.props} />
  501. }
  502. }
  503. export class Text extends Module {
  504. constructor(props) {
  505. super(props);
  506. }
  507. display() {
  508. let {
  509. content,
  510. ...rest
  511. } = this.props
  512. return <TextCtor {...rest} >
  513. {content}
  514. </TextCtor>
  515. }
  516. }
  517. export class Textarea extends Module {
  518. constructor(props) {
  519. super(props);
  520. }
  521. display() {
  522. let {
  523. ...rest
  524. } = this.props;
  525. return <TextareaCtor {...rest}>
  526. </TextareaCtor>
  527. }
  528. }
  529. export class Thumbnail extends Module {
  530. constructor(props) {
  531. super(props);
  532. }
  533. display() {
  534. return <ThumbnailCtor {...this.props} />
  535. }
  536. }
  537. export class Title extends Module {
  538. constructor(props) {
  539. super(props);
  540. }
  541. display() {
  542. return <TitleCtor {...this.props} />
  543. }
  544. }
  545. export class Toast extends Module {
  546. constructor(props) {
  547. super(props);
  548. }
  549. display() {
  550. return <ToastCtor {...this.props} />
  551. }
  552. }
  553. export class ToastContainer extends Module {
  554. constructor(props) {
  555. super(props);
  556. }
  557. display() {
  558. return <ToastContainerCtor {...this.props} />
  559. }
  560. }
  561. export class View extends Module {
  562. constructor(props) {
  563. super(props);
  564. }
  565. display() {
  566. return <ViewCtor {...this.props} />
  567. }
  568. }
  569. Text.Inputs = {
  570. uppercase: new Types.Bool().default(false),
  571. content: new Types.Text().default("Hello world!")
  572. }
  573. Accordion.Inputs = {
  574. }
  575. Actionsheet.Inputs = {
  576. }
  577. Body.Inputs = {
  578. }
  579. Button.Inputs = {
  580. text: new Types.Text().default("Press me"),
  581. onPress: new Types.Action(),
  582. block: new Types.Bool(),
  583. primary: new Types.Bool(),
  584. transparent: new Types.Bool(),
  585. success: new Types.Bool(),
  586. danger: new Types.Bool(),
  587. warning: new Types.Bool(),
  588. info: new Types.Bool(),
  589. bordered: new Types.Bool(),
  590. disabled: new Types.Bool(),
  591. rounded: new Types.Bool(),
  592. large: new Types.Bool(),
  593. small: new Types.Bool(),
  594. active: new Types.Bool()
  595. }
  596. Badge.Inputs = {
  597. icon: new Types.Text(),
  598. text: new Types.Text().require().default("1"),
  599. color: new Types.Text().color().require().default("rgba(255,255,255,1)"),
  600. primary: new Types.Bool(),
  601. success: new Types.Bool(),
  602. danger: new Types.Bool(),
  603. warning: new Types.Bool(),
  604. info: new Types.Bool()
  605. }
  606. Card.Inputs = {
  607. header: new Types.Text().default("Header"),
  608. body: new Types.Text().default("Lorem ipsum body bla la trapala"),
  609. footer: new Types.Text().default("Add footer here"),
  610. bodyModules: new Types.Array(new Types.Module()),
  611. texts: new Types.Array(new Types.Text())
  612. }
  613. CardItem.Inputs = {
  614. header: new Types.Bool(),
  615. cardBody: new Types.Bool(),
  616. footer: new Types.Bool(),
  617. button: new Types.Bool()
  618. }
  619. Checkbox.Inputs = {
  620. checked: new Types.Bool()
  621. }
  622. Container.Inputs = {
  623. }
  624. Content.Inputs = {
  625. disableKBDismissScroll: new Types.Bool(),
  626. keyboardShouldPersistTaps: new Types.Text(),
  627. padder: new Types.Bool()
  628. }
  629. DatePicker.Inputs = {
  630. }
  631. DeckSwiper.Inputs = {
  632. }
  633. Fab.Inputs = {
  634. }
  635. Footer.Inputs = {
  636. }
  637. FooterTab.Inputs = {
  638. }
  639. Form.Inputs = {
  640. inputs: new Types.Array(new Types.Text()),
  641. button: new Types.Text().default('Submit'),
  642. onSubmit: new Types.Action()
  643. }
  644. Gravatar.Inputs = {
  645. email: new Types.Text().require(),
  646. size: new Types.Real(),
  647. circular: new Types.Bool(),
  648. square: new Types.Bool()
  649. }
  650. H1.Inputs = {
  651. ...Text.Inputs
  652. }
  653. H2.Inputs = {
  654. ...Text.Inputs
  655. }
  656. H3.Inputs = {
  657. ...Text.Inputs
  658. }
  659. Header.Inputs = {
  660. searchBar: new Types.Bool(),
  661. rounded: new Types.Bool()
  662. }
  663. IconNB.Inputs = {
  664. }
  665. Item.Inputs = {
  666. mod: new Types.Module(),
  667. inlineLabel: new Types.Bool(),
  668. floatingLabel: new Types.Bool(),
  669. stackedLabel: new Types.Bool(),
  670. fixedLabel: new Types.Bool(),
  671. success: new Types.Bool(),
  672. error: new Types.Bool()
  673. }
  674. Input.Inputs = {
  675. icon: new Types.Text(),
  676. placeholder: new Types.Text(),
  677. ...Item.Inputs
  678. }
  679. InputGroup.Inputs = {
  680. regular: new Types.Bool(),
  681. underline: new Types.Bool(),
  682. rounded: new Types.Bool(),
  683. success: new Types.Bool(),
  684. error: new Types.Bool(),
  685. disabled: new Types.Bool()
  686. }
  687. Label.Inputs = {
  688. floatBack: new Types.Real()
  689. }
  690. Left.Inputs = {
  691. }
  692. List.Inputs = {
  693. }
  694. ListItem.Inputs = {
  695. itemDivider: new Types.Bool(),
  696. button: new Types.Bool()
  697. }
  698. PickerItem.Inputs = {
  699. }
  700. Radio.Inputs = {
  701. selected: new Types.Bool(),
  702. standardStyle: new Types.Bool()
  703. }
  704. Right.Inputs = {
  705. }
  706. Root.Inputs = {
  707. }
  708. Segment.Inputs = {
  709. }
  710. Separator.Inputs = {
  711. }
  712. Spinner.Inputs = {
  713. color: new Types.Text(),
  714. inverse: new Types.Bool()
  715. }
  716. Subtitle.Inputs = {
  717. }
  718. SwipeRow.Inputs = {
  719. }
  720. Switch.Inputs = {
  721. }
  722. Tab.Inputs = {
  723. }
  724. TabContainer.Inputs = {
  725. }
  726. TabHeading.Inputs = {
  727. }
  728. Textarea.Inputs = {
  729. placeholder: new Types.Text(),
  730. rowSpan: new Types.Real(),
  731. bordered: new Types.Bool(),
  732. underline: new Types.Bool()
  733. }
  734. Thumbnail.Inputs = {
  735. square: new Types.Bool(),
  736. circular: new Types.Bool(),
  737. size: new Types.Real()
  738. }
  739. Title.Inputs = {
  740. }
  741. Toast.Inputs = {
  742. }
  743. ToastContainer.Inputs = {
  744. }
  745. View.Inputs = {
  746. }
  747. export default {
  748. // Accordion,
  749. // Actionsheet,
  750. Badge,
  751. // Body,
  752. Button,
  753. Card,
  754. // CardItem,
  755. Checkbox,
  756. // Container,
  757. // Content,
  758. // DatePicker,
  759. // DeckSwiper,
  760. // Fab,
  761. // Footer,
  762. // FooterTab,
  763. Form,
  764. // Gravatar,
  765. H1,
  766. H2,
  767. H3,
  768. // Header,
  769. IconNB,
  770. Input,
  771. // InputGroup,
  772. // Item,
  773. // Label,
  774. // Left,
  775. // List,
  776. // ListItem,
  777. // PickerItem,
  778. Radio,
  779. // Right,
  780. // Root,
  781. // Segment,
  782. // Separator,
  783. // Spinner,
  784. // Subtitle,
  785. // SwipeRow,
  786. // Switch,
  787. // Tab,
  788. // TabContainer,
  789. // TabHeading,
  790. // Text,
  791. // Textarea,
  792. // Thumbnail,
  793. // Title,
  794. // Toast,
  795. // ToastContainer,
  796. // View
  797. }