index.js 15 KB

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