├── circle.yml
├── docs
├── SimpleWrapper.json
├── BasicComponent.json
├── Tab.json
├── TabActive.json
├── TabInactive.json
├── BottomToolbar.json
├── Row.json
├── ListHeader.json
├── CarouselItem.json
├── Ripple.json
├── SplitterContent.json
├── Col.json
├── Toolbar.json
├── ToolbarButton.json
├── Splitter.json
├── Range.json
├── Switch.json
├── Button.json
├── BackButton.json
├── SpeedDialItem.json
├── ProgressCircular.json
├── ProgressBar.json
├── ListItem.json
├── LazyList.json
├── List.json
├── SpeedDial.json
├── Modal.json
├── Fab.json
├── PullHook.json
├── Icon.json
├── Input.json
├── Page.json
├── Tabbar.json
├── Dialog.json
├── AlertDialog.json
├── Popover.json
├── SplitterSide.json
└── Carousel.json
├── .gitmodules
├── tests.webpack.js
├── ISSUE_TEMPLATE.md
├── test
├── todo
├── col-test.js
├── fab-test.js
├── row-test.js
├── tab-test.js
├── icon-test.js
├── input.js
├── range-test.js
├── switch-test.js
├── button-test.js
├── page-test.js
├── ripple-test.js
├── carousel-test.js
├── modal-test.js
├── toolbar-test.js
├── pullHook-test.js
├── splitter-test.js
├── tabActive-test.js
├── speedDial-test.js
├── backButton-test.js
├── tabInactive-test.js
├── bottomToolbar-test.js
├── carouselItem-test.js
├── progressBar-test.js
├── listHeader-test.js
├── speedDialItem-test.js
├── toolbarButton-test.js
├── listItem-test.js
├── splitterContent-test.js
├── splitterSide-test.js
├── progressBarCircular-test.js
├── tabbar-test.js
├── testUtil.js
├── list-test.js
└── lazyList-test.js
├── scripts
└── react-docgen.js
├── demo
├── examples
│ ├── MyToolbar.js
│ ├── Ripple.js
│ ├── BackButton.js
│ ├── Switch.js
│ ├── BottomToolbar.js
│ ├── LazyList.js
│ ├── Range.js
│ ├── ProgressBar.js
│ ├── SpeedDial.js
│ ├── List.js
│ ├── Page.js
│ ├── AlertDialog.js
│ ├── PullHook.js
│ ├── Tabbar.js
│ ├── Icon.js
│ ├── Modal.js
│ ├── Carousel.js
│ ├── Input.js
│ ├── Splitter.js
│ └── Popover.js
└── index.html
├── src
├── components
│ ├── Tab.jsx
│ ├── SimpleWrapper.jsx
│ ├── TabActive.jsx
│ ├── TabInactive.jsx
│ ├── BottomToolbar.jsx
│ ├── Util.js
│ ├── ListHeader.jsx
│ ├── BasicComponent.jsx
│ ├── CarouselItem.jsx
│ ├── Row.jsx
│ ├── SplitterContent.jsx
│ ├── Ripple.jsx
│ ├── Toolbar.jsx
│ ├── Splitter.jsx
│ ├── ToolbarButton.jsx
│ ├── Col.jsx
│ ├── Button.jsx
│ ├── BackButton.jsx
│ ├── SpeedDialItem.jsx
│ ├── ProgressCircular.jsx
│ ├── Switch.jsx
│ ├── ProgressBar.jsx
│ ├── Range.jsx
│ ├── SpeedDial.jsx
│ ├── Fab.jsx
│ ├── ListItem.jsx
│ ├── List.jsx
│ ├── Modal.jsx
│ ├── BaseDialog.jsx
│ ├── PullHook.jsx
│ ├── Icon.jsx
│ ├── LazyList.jsx
│ ├── Dialog.jsx
│ ├── Input.jsx
│ └── AlertDialog.jsx
└── index.js
├── CHANGELOG.md
├── .gitignore
├── .npmignore
├── docgen.js
├── index.html
├── karma.conf.js
├── rollup.config.js
├── webpack.config.js
├── githubRelease.js
├── package.json
└── README.md
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 6.2.0
4 |
--------------------------------------------------------------------------------
/docs/SimpleWrapper.json:
--------------------------------------------------------------------------------
1 | {"description":"","methods":[]}
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "OnsenUI"]
2 | path = OnsenUI
3 | url = https://github.com/OnsenUI/OnsenUI.git
4 |
--------------------------------------------------------------------------------
/tests.webpack.js:
--------------------------------------------------------------------------------
1 | var context = require.context('./test', true, /-test\.js$/);
2 | context.keys().forEach(context);
3 |
--------------------------------------------------------------------------------
/docs/BasicComponent.json:
--------------------------------------------------------------------------------
1 | {"description":"","methods":[{"name":"updateClasses","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/test/todo:
--------------------------------------------------------------------------------
1 | ../src/components/SimpleWrapper.jsx
2 | ../src/components/Popover.jsx
3 | ../src/components/Navigator.jsx
4 | ../src/components/AlertDialog.jsx
5 | ../src/components/BaseDialog.jsx
6 | ../src/components/Dialog.jsx
7 | ../src/components/BasicComponent.jsx
8 |
--------------------------------------------------------------------------------
/docs/Tab.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-tab\n@category tabbar\n@tutorial react/Reference/tabbar\n@description\n[en] Represents a tab inside tab bar.\n [/en]\n[jp][/jp]\n@example\n\n Home\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/test/col-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Col} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Col', function() {
10 | rendersToComponent(
11 |
,
12 | 'ons-col'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/fab-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Fab} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Fab', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-fab'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/row-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Row} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Row', function() {
10 | rendersToComponent(
11 |
,
12 | 'ons-row'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/tab-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Tab} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Tab', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-tab'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/icon-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Icon} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Icon', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-icon'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/input.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Input} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Input', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-input'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/scripts/react-docgen.js:
--------------------------------------------------------------------------------
1 | var Module = require('module');
2 | var originalRequire = Module.prototype.require;
3 |
4 | Module.prototype.require = function(){
5 | if (arguments[0].indexOf('isReactComponentClass') > -1) {
6 | return function() {
7 | return true;
8 | }
9 | }
10 |
11 | return originalRequire.apply(this, arguments);
12 | };
13 |
14 | require('../node_modules/.bin/react-docgen');
15 |
--------------------------------------------------------------------------------
/test/range-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Range} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Range', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-range'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/switch-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Switch} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Switch', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-switch'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/docs/TabActive.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-tab-active\n@category tabbar\n@tutorial react/Reference/tabbar\n@description\n[en] Tab element for showing shown when the tab is active [/en]\n[jp][/jp]\n@example\n\n \n HOME\n \n \n home\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/test/button-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Button} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Button', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-button'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/page-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Page} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Page', function() {
11 | rendersToComponent(
12 | Hello ,
13 | 'ons-page'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/ripple-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Ripple} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Ripple', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-ripple'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/docs/TabInactive.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-tab-inactive\n@category tabbar\n@tutorial react/Reference/tabbar\n@description\n[en] Tab element for showing shown when the tab is inactive [/en]\n[jp][/jp]\n@example\n\n \n HOME\n \n \n home\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/test/carousel-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Carousel} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('Carousel', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-carousel'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/modal-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Modal} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Modal', function() {
11 | rendersToComponent(
12 | Hello ,
13 | 'ons-modal'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/toolbar-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Toolbar} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Toolbar', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-toolbar'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/pullHook-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {PullHook} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('PullHook', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-pull-hook'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/splitter-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Splitter} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Splitter', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-splitter'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/tabActive-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {TabActive} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('TabActive', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-tab-active'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/speedDial-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {SpeedDial} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('SpeedDial', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-speed-dial'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/backButton-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {BackButton} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('BackButon', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-back-button'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/tabInactive-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {TabInactive} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('TabInactive', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-tab-inactive'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/bottomToolbar-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {BottomToolbar} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('B', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-bottom-toolbar'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/carouselItem-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {CarouselItem} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('CarouselItem', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-carousel-item'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/progressBar-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {ProgressBar} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('ProgressBar', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-progress-bar'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/listHeader-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {ListHeader} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('ListHeader', function() {
10 | rendersToComponent(
11 | ,
12 | 'ons-list-header'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/speedDialItem-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {SpeedDialItem} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('SpeedDialItem', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-speed-dial-item'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/toolbarButton-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {ToolbarButton} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('ToolbarButon', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-toolbar-button'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/listItem-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {ListItem} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('ListItem', function() {
10 | rendersToComponent(
11 |
} />,
12 | 'ons-list-item'
13 | );
14 | });
15 |
--------------------------------------------------------------------------------
/test/splitterContent-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {SplitterContent} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('SplitterContent', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-splitter-content'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/splitterSide-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {SplitterSide} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('SplitterSide', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-splitter-side'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/demo/examples/MyToolbar.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Toolbar, BackButton} from '../../src/index.js';
4 |
5 | export default class extends React.Component {
6 | render() {
7 | return(
8 |
9 | Back
10 | {this.props.title}
11 |
12 | )
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/components/Tab.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 |
3 | /**
4 | * @original ons-tab
5 | * @category tabbar
6 | * @tutorial react/Reference/tabbar
7 | * @description
8 | * [en] Represents a tab inside tab bar.
9 | [/en]
10 | * [jp][/jp]
11 | * @example
12 | *
13 | * Home
14 | *
15 | */
16 | class Tab extends SimpleWrapper {
17 | _getDomNodeName() {
18 | return 'ons-tab';
19 | }
20 | };
21 |
22 | export default Tab;
23 |
--------------------------------------------------------------------------------
/test/progressBarCircular-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {ProgressCircular} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('ProgressCircular', function() {
11 | rendersToComponent(
12 | ,
13 | 'ons-progress-circular'
14 | );
15 | });
16 |
--------------------------------------------------------------------------------
/test/tabbar-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Tabbar} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('Tabbar', function() {
11 | rendersToComponent(
12 | [] }
14 | />,
15 | 'ons-tabbar'
16 | );
17 | });
18 |
--------------------------------------------------------------------------------
/test/testUtil.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import TestUtils from 'react/lib/ReactTestUtils';
6 |
7 | export default (component, name) => {
8 | it(`renders to <${name}>`, () => {
9 | var root = TestUtils.renderIntoDocument(component);
10 | var node = ReactDOM.findDOMNode(root);
11 | assert.isNotNull(node);
12 | assert.equal(node.nodeName, name.toUpperCase());
13 | });
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/src/components/SimpleWrapper.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import BasicComponent from './BasicComponent.jsx';
3 | import Util from './Util.js';
4 |
5 | class SimpleWrapper extends BasicComponent {
6 | render() {
7 | var {...others} = this.props;
8 |
9 | Util.convert(others, 'disabled');
10 | Util.convert(others, 'ripple');
11 |
12 | return React.createElement(this._getDomNodeName(), others, this.props.children);
13 | }
14 | };
15 |
16 | export default SimpleWrapper;
17 |
--------------------------------------------------------------------------------
/docs/BottomToolbar.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-bottom-toolbar\n@category page\n@description\n[en]Toolbar component that is positioned at the bottom of the page.[/en]\n[jp][/jp]\n@example\n Content ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]Specify modifier name to specify custom styles. Optional.[/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/test/list-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {List} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 | import rendersToComponent from './testUtil.js';
8 |
9 | describe('List', function() {
10 | rendersToComponent(
11 |
} />,
12 | 'ons-list'
13 | );
14 | });
15 |
16 | describe('List without dataSource attributes', function() {
17 | rendersToComponent(
18 |
,
19 | 'ons-list'
20 | );
21 | });
22 |
--------------------------------------------------------------------------------
/src/components/TabActive.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 |
3 | /**
4 | * @original ons-tab-active
5 | * @category tabbar
6 | * @tutorial react/Reference/tabbar
7 | * @description
8 | * [en] Tab element for showing shown when the tab is active [/en]
9 | * [jp][/jp]
10 | * @example
11 | *
12 | *
13 | HOME
14 |
15 |
16 | home
17 |
18 |
19 | */
20 | class TabActive extends SimpleWrapper {
21 | _getDomNodeName() {
22 | return 'ons-tab-active';
23 | }
24 | };
25 |
26 | export default TabActive;
27 |
--------------------------------------------------------------------------------
/src/components/TabInactive.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 |
3 | /**
4 | * @original ons-tab-inactive
5 | * @category tabbar
6 | * @tutorial react/Reference/tabbar
7 | * @description
8 | * [en] Tab element for showing shown when the tab is inactive [/en]
9 | * [jp][/jp]
10 | * @example
11 | *
12 | *
13 | HOME
14 |
15 |
16 | home
17 |
18 |
19 | */
20 | class TabInactive extends SimpleWrapper {
21 | _getDomNodeName() {
22 | return 'ons-tab-inactive';
23 | }
24 | };
25 |
26 | export default TabInactive;
27 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | CHANGELOG
3 | ====
4 |
5 | v1.0.1
6 | ----
7 | * list: Support static lists.
8 | * navigator: Properly render pages.
9 |
10 | v1.0.0
11 | ----
12 |
13 | v0.7.4
14 | ----
15 | * modal: Fix hide and show logic.
16 | * carousel: Refresh carousel when number of children changes.
17 |
18 | v0.7.2
19 | ----
20 | * tabbar: Fix regression.
21 |
22 | v0.7.1
23 | ----
24 | * navigator: add routes to events
25 |
26 | v0.7.0
27 | ----
28 | * tabbar: New interface with index.
29 | * page: Fixed bug with modifier not being applied to pages. Add contentStyle property.
30 | * page: Add `renderFixed` prop to render fixed position conent.
31 | * range: Fix `value` prop.
32 |
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # node-waf configuration
21 | .lock-wscript
22 |
23 | # Compiled binary addons (http://nodejs.org/api/addons.html)
24 | build/Release
25 |
26 | # Dependency directory
27 | node_modules
28 |
29 | # Optional npm cache directory
30 | .npm
31 |
32 | # Optional REPL history
33 | .node_repl_history
34 |
35 | # Demo bundle
36 | demo/bundle.js
37 |
--------------------------------------------------------------------------------
/demo/examples/Ripple.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Button, Page, Ripple, Icon} from '../../src/index.js';
4 |
5 | import MyToolbar from './MyToolbar';
6 |
7 | export default class extends React.Component {
8 | constructor(props) {
9 | super(props);
10 | }
11 |
12 | render() {
13 | return (
14 | }
16 | >
17 |
22 |
23 |
24 |
25 |
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/docs/Row.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-row\n@category grid\n@description\n[en]\nRepresents a row in the grid system. Use with `Col` to layout components.\n[/en]\n[jp][/jp]\n\n \n \n \n Text\n
","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"verticalAlign":{"type":{"name":"enum","value":[{"value":"'top'","computed":false},{"value":"'bottom'","computed":false},{"value":"'center'","computed":false}]},"required":false,"description":"@name verticalAlign\n@type {String}\n@description\n [en]Short hand attribute for aligning vertically. Valid values are top, bottom, and center.[/en]\n [ja][/ja]"}}}
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # node-waf configuration
21 | .lock-wscript
22 |
23 | # Compiled binary addons (http://nodejs.org/api/addons.html)
24 | build/Release
25 |
26 | # Dependency directory
27 | node_modules
28 |
29 | # Optional npm cache directory
30 | .npm
31 |
32 | # Optional REPL history
33 | .node_repl_history
34 |
35 | # Demos
36 | demo
37 |
38 | # Submodule
39 | OnsenUI
40 |
--------------------------------------------------------------------------------
/docgen.js:
--------------------------------------------------------------------------------
1 | var filter = require('filter-files');
2 | var exec = require('child_process').exec;
3 |
4 | var files = filter.sync('./src/components/', (fp) => {
5 | // console.log(fp);
6 | return fp.indexOf('Util') === -1 &&
7 | fp.indexOf('BaseDialog') === -1 &&
8 | fp.indexOf('todo') === -1;
9 | });
10 |
11 | console.log('Generating docs, this may take a while: ..');
12 | for (var i = 0; i < files.length; i++) {
13 | var fileName = files[i].replace(/^.*[\\\/]/, '').slice(0, -4);
14 | var cmd = 'node ./scripts/react-docgen.js ' + files[i] + ' > ' + './docs/' + fileName + '.json';
15 | exec(cmd, function callback(error, stdout, stderr) {
16 | if (error) {
17 | throw new Error('error generating docs');
18 | }
19 | });
20 | }
21 |
--------------------------------------------------------------------------------
/docs/ListHeader.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-list-header\n@category list\n@tutorial react/Reference/list\n@description\n[en] Header element for list items. Must be put inside ons-list component.\n [/en]\n[jp][/jp]\n@example\n \n Header Text }\n renderRow={(row, idx) => (\n {row} \n )}\n />","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]\n Specify modifier name to specify custom styles. Optional.\n [/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/BottomToolbar.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-bottom-toolbar
6 | * @category page
7 | * @description
8 | * [en]Toolbar component that is positioned at the bottom of the page.[/en]
9 | * [jp][/jp]
10 | * @example
11 | * Content
12 | */
13 | class BottomToolbar extends SimpleWrapper {
14 | _getDomNodeName() {
15 | return 'ons-bottom-toolbar';
16 | }
17 | };
18 |
19 | BottomToolbar.propTypes = {
20 | /**
21 | * @name modifier
22 | * @type string
23 | * @description
24 | * [en]Specify modifier name to specify custom styles. Optional.[/en]
25 | * [jp][/jp]
26 | */
27 | modifier: React.PropTypes.string
28 | };
29 |
30 | export default BottomToolbar;
31 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Onsen UI React Demo
8 |
9 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/docs/CarouselItem.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-carousel-item\n@category carousel\n@tutorial react/Reference/carousel\n@description\n[en] Carousel item component. Used as a child of the `` element.\n [/en]\n[jp][/jp]\n@example\n \n \n GRAY
\n \n \n BLUE
\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]\n Specify modifier name to specify custom styles. Optional.\n [/en]\n [jp] どうしよう[/jp]"}}}
2 |
--------------------------------------------------------------------------------
/test/lazyList-test.js:
--------------------------------------------------------------------------------
1 | /* global describe it assert */
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import {Page, LazyList} from '../dist/react-onsenui.js';
6 | import TestUtils from 'react/lib/ReactTestUtils';
7 |
8 | import rendersToComponent from './testUtil.js';
9 |
10 | describe('LazyList', function() {
11 | it(`renders to <${name}>`, () => {
12 | // lazy repeat needs to be inside page
13 | var root = TestUtils.renderIntoDocument(
14 |
15 |
}
18 | calculateItemHeight={() => 45}
19 | />
20 |
21 |
22 | );
23 | var node = ReactDOM.findDOMNode(root);
24 | assert.isNotNull(node);
25 | assert.equal(node.nodeName, 'ONS-PAGE');
26 | assert.equal(node.children[1].firstChild.nodeName, 'ONS-LIST');
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/docs/Ripple.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-ripple\n@category visual\n@tutorial react/Reference/ripple\n@description\n[en]\n Adds a Material Design \"ripple\" effect to an element.\n[/en]\n[jp][/jp]\n@example\n \n \n
","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"color":{"type":{"name":"string"},"required":false,"description":"@name color\n@type string\n@required false\n@description\n [en]Color of the ripple effect.[/en]\n [jp] [/jp]"},"background":{"type":{"name":"string"},"required":false,"description":"@name background\n@type string\n@required false\n@description\n [en]Color of the background.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en]\n Specifies whether the button is disabled.\n [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/docs/SplitterContent.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-splitter-content\n@category menu\n@tutorial react/Reference/splitter\n@description\n[en] The SplitterContent element is used as a child element of Splitter.\n It contains the main content of the page while SplitterSide contains the list.\n [/en]\n[jp][/jp]\n@example\n \n \n Page Left \n \n \n Page Content \n \n \n Page Right \n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/src/components/Util.js:
--------------------------------------------------------------------------------
1 | export default {
2 | sizeConverter(item) {
3 | if (typeof (item) === 'number') {
4 | return `${item}px`;
5 | } else {
6 | return item;
7 | }
8 | },
9 |
10 | numberConverter(item) {
11 | return `${item}px`;
12 | },
13 |
14 | animationOptionsConverter(options) {
15 | var keys = Object.keys(options);
16 | var innerString = keys.map((key) => key + ': "' + options[key] + '"');
17 | return '{' + innerString.join(',') + '}';
18 | },
19 |
20 | convert(dict, name, additionalDict = {}) {
21 | const fun = additionalDict.fun ? additionalDict.fun : (x) => x;
22 | const newName = additionalDict.newName ? additionalDict.newName : name;
23 |
24 | var val = dict[name];
25 | if (val) {
26 | if (newName !== name) {
27 | delete dict[name];
28 | }
29 | dict[newName] = fun(val);
30 | } else {
31 | dict[newName] = null;
32 | }
33 | return dict;
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/docs/Col.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-col\n@category grid\n@description\n[en]\nRepresents a column in the grid system. Use with `` to layout components.\n[/en]\n[jp][/jp]\n\n \n \n \n Text\n
","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"verticalAlign":{"type":{"name":"enum","value":[{"value":"'top'","computed":false},{"value":"'bottom'","computed":false},{"value":"'center'","computed":false}]},"required":false,"description":"@name verticalAlign\n@type {String}\n@description\n [en]Short hand attribute for aligning vertically. Valid values are top, bottom, and center.[/en]\n [ja][/ja]"},"width":{"type":{"name":"union","value":[{"name":"number"},{"name":"string"}]},"required":false,"description":"@name width\n@type {String}\n@description\n [en]The width of the column. Valid values are css width values (\"10%\", 50).[/en]\n [ja][/ja]"}}}
2 |
--------------------------------------------------------------------------------
/docs/Toolbar.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-toolbar\n@category page\n@tutorial react/Reference/page\n@description\n[en]Toolbar component that can be used with navigation. Left, center and right container can be specified by class names. This component will automatically displays as a Material Design toolbar when running on Android devices.[/en]\n[jp] どうしよう[/jp]\n@example\n\n\n \n \n \n Back\n \n
\n \n Title\n
\n \n \n \n \n
\n }\n/>","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]\n Specify modifier name to specify custom styles. Optional.\n [/en]\n [jp] どうしよう[/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Onsen UI React Demo
10 |
11 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/docs/ToolbarButton.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-toolbar-button\n@category page\n@tutorial react/Reference/page\n@description\n [en]\n Button component for the Toolbar. Using this component gives a nice default style.\n\n\n [/en]\n[jp][/jp]\n@example\n\n \n Back
\n Input
\n \n Add \n
\n \n }>\n Page Content\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the button.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en]\n Indicates whether the button is disabled.\n [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/ListHeader.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-list-header
6 | * @category list
7 | * @tutorial react/Reference/list
8 | * @description
9 | * [en] Header element for list items. Must be put inside ons-list component.
10 | [/en]
11 | * [jp][/jp]
12 | * @example
13 |
16 | Header Text }
17 | renderRow={(row, idx) => (
18 | {row}
19 | )}
20 | />
21 | */
22 | class ListHeader extends SimpleWrapper {
23 | _getDomNodeName() {
24 | return 'ons-list-header';
25 | }
26 | };
27 |
28 | ListHeader.propTypes = {
29 | /**
30 | * @name modifier
31 | * @type string
32 | * @description
33 | * [en]
34 | * Specify modifier name to specify custom styles. Optional.
35 | * [/en]
36 | * [jp][/jp]
37 | */
38 | modifier: React.PropTypes.string
39 | };
40 |
41 | export default ListHeader;
42 |
--------------------------------------------------------------------------------
/docs/Splitter.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-splitter\n@category menu\n@tutorial react/Reference/splitter\n@description\n[en] A component that enables responsive layout by implementing both a two-column layout and a sliding menu layout.\n\n It can be configured to automatically expand into a column layout on large screens and collapse the menu on smaller screens. When the menu is collapsed the user can open it by swiping.\n [/en]\n[jp] どうしよう[/jp]\n@example\n \n \n Page Left \n \n \n Page Content \n \n \n Page Right \n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}]}
2 |
--------------------------------------------------------------------------------
/demo/examples/BackButton.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import ons from '../../OnsenUI/build/js/onsenui.js'
4 |
5 | import {
6 | Page,
7 | Toolbar,
8 | BackButton,
9 | } from '../../src/index.js';
10 |
11 | export default class extends React.Component {
12 | constructor(props) {
13 | super(props);
14 | }
15 |
16 | handleClick() {
17 | ons.notification.confirm('Do you really want to go back?')
18 | .then(
19 | (response) => {
20 | if (response === 1) {
21 | this.props.navigator.popPage();
22 | }
23 | }
24 | );
25 | }
26 |
27 | renderToolbar() {
28 | return (
29 |
30 |
31 |
32 | Back
33 |
34 |
35 | Back button
36 |
37 | );
38 | }
39 |
40 | render() {
41 | return (
42 |
45 |
46 | );
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/docs/Range.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-range\n@category form\n@tutorial react/Reference/range\n@description\n[en]\n Range input component.\n[/en]\n[jp][/jp]\n@example\n this.setState({value: parseInt(event.target.value)})}\n />","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the progress indicator.[/en]\n [jp] [/jp]"},"onChange":{"type":{"name":"func"},"required":false,"description":"@name onChange\n@type function\n@description\n [en] Called when the value of the input changes.[/en]\n [jp][/jp]"},"value":{"type":{"name":"number"},"required":false,"description":"@name value\n@type number\n@description\n [en]\n Current value of the element.\n [/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en] If true, the element is disabled. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/Switch.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | Toolbar,
6 | ToolbarButton,
7 | BackButton,
8 | Input,
9 | Switch
10 | } from '../../src/index.js';
11 |
12 | import MyToolbar from './MyToolbar';
13 |
14 | export default class extends React.Component {
15 | constructor(props) {
16 | super(props);
17 | this.state = {checked: true};
18 | this.onChange = this.onChange.bind(this);
19 | }
20 |
21 | onChange(event) {
22 | this.setState({checked: event.target.checked});
23 | }
24 |
25 | render() {
26 | return (
27 | } >
28 |
29 |
Page Content
30 |
31 |
32 |
33 |
34 |
The switch is {this.state.checked ? 'on' : 'off'}
35 |
36 |
37 | );
38 | }
39 | };
40 |
--------------------------------------------------------------------------------
/docs/Switch.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-switch\n@category form\n@tutorial react/Reference/switch\n@description\n[en] Switch component. The switch can be toggled both by dragging and tapping.\n Will automatically displays a Material Design switch on Android devices.\n [/en]\n[jp][/jp]\n@example\n ","methods":[],"props":{"onChange":{"type":{"name":"func"},"required":false,"description":"@name onChange\n@type function\n@description\n [en] Called when the value of the switch changes (checked/unchecked) [/en]\n [jp] [/jp]"},"checked":{"type":{"name":"bool"},"required":false,"description":"@name checked\n@type bool\n@description\n [en] Whether the switch is checked.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en] If set, the switch is disabled.[/en]\n [jp] [/jp]"},"inputId":{"type":{"name":"string"},"required":false,"description":"@name inputId\n@type bool\n@description\n [en] Specify the `id` attribute of the inner ` ` element. This is useful when using `` elements.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/BottomToolbar.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Page, Button, BottomToolbar} from '../../src/index.js';
4 |
5 | import MyToolbar from './MyToolbar';
6 |
7 | export default class extends React.Component {
8 | constructor(props) {
9 | super(props);
10 |
11 | this.state = {
12 | modifier: 'material'
13 | };
14 | }
15 |
16 | toggleModifier() {
17 | this.setState({
18 | modifier: this.state.modifier === 'material' ? '' : 'material'
19 | });
20 | }
21 |
22 | render() {
23 | return (
24 | }
26 | renderBottomToolbar={() => Bottom Toolbar content
}
27 | modifier={this.state.modifier} >
28 |
29 | This is a page!
30 |
31 |
32 | Switch modifier
33 |
34 |
35 | 1
36 | 1
37 | 1
38 |
39 |
40 |
41 |
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/components/BasicComponent.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import ons from 'onsenui';
5 |
6 | class BasicComponent extends React.Component {
7 | constructor(...args) {
8 | super(...args);
9 | this.updateClasses = this.updateClasses.bind(this);
10 | }
11 |
12 | updateClasses() {
13 | var node = ReactDOM.findDOMNode(this);
14 |
15 | if (typeof this.props.className !== 'undefined') {
16 | if (this.lastClass) {
17 | node.className = node.className.replace(this.lastClass, ' ');
18 | }
19 |
20 | this.lastClass = ' ' + this.props.className.trim();
21 |
22 | node.className = node.className.trim() + this.lastClass;
23 | }
24 |
25 | if (!ons) {
26 | throw new Error("react-onsenui requires `onsenui`, make sure you are loading it with `import onsenui` or `require('onsenui')` before using the components");
27 | }
28 |
29 | ons._autoStyle.prepare(node);
30 | }
31 |
32 | componentDidMount() {
33 | this.updateClasses();
34 | }
35 |
36 | componentDidUpdate() {
37 | this.updateClasses();
38 | }
39 | }
40 |
41 | export default BasicComponent;
42 |
--------------------------------------------------------------------------------
/src/components/CarouselItem.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-carousel-item
6 | * @category carousel
7 | * @tutorial react/Reference/carousel
8 | * @description
9 | * [en] Carousel item component. Used as a child of the `` element.
10 | [/en]
11 | * [jp][/jp]
12 | * @example
13 | *
14 |
15 | GRAY
16 |
17 |
18 | BLUE
19 |
20 |
21 | */
22 | class CarouselItem extends SimpleWrapper {
23 | _getDomNodeName() {
24 | return 'ons-carousel-item';
25 | }
26 | };
27 |
28 | CarouselItem.propTypes = {
29 | /**
30 | * @name modifier
31 | * @type string
32 | * @description
33 | * [en]
34 | * Specify modifier name to specify custom styles. Optional.
35 | * [/en]
36 | * [jp] どうしよう[/jp]
37 | */
38 | modifier: React.PropTypes.string
39 | };
40 |
41 | export default CarouselItem;
42 |
--------------------------------------------------------------------------------
/docs/Button.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-button\n@category form\n@tutorial react/Reference/button\n@description\n[en] Button component. If you want to place a button in a toolbar, use `ToolbarButton` or `BackButton` instead. Will automatically display as a Material Design button with a ripple effect on Android.\n [/en]\n[jp][/jp]\n@example\n\n Tap Me\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the button.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en]\n Specifies whether the button is disabled.\n [/en]\n [jp] [/jp]"},"ripple":{"type":{"name":"bool"},"required":false,"description":"@name ripple\n@type bool\n@description\n [en]\n Specifies whether the button has a ripple effect.\n [/en]\n [jp] [/jp]"},"onClick":{"type":{"name":"func"},"required":false,"description":"@name onClick\n@type function\n@description\n [en] This function will be called ones the button is clicked. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Row.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-row
7 | * @category grid
8 | * @description
9 | * [en]
10 | * Represents a row in the grid system. Use with `Col` to layout components.
11 | * [/en]
12 | * [jp][/jp]
13 | *
14 | *
15 | *
16 | *
17 | * Text
18 | *
19 | */
20 | class Row extends SimpleWrapper {
21 | _getDomNodeName() {
22 | return 'ons-row';
23 | }
24 |
25 | render() {
26 | var {...others} = this.props;
27 |
28 | Util.convert(others, 'verticalAlign', {newName: 'vertical-align'});
29 |
30 | return React.createElement(this._getDomNodeName(), others, this.props.children);
31 | }
32 |
33 | };
34 |
35 | Row.propTypes = {
36 |
37 | /**
38 | * @name verticalAlign
39 | * @type {String}
40 | * @description
41 | * [en]Short hand attribute for aligning vertically. Valid values are top, bottom, and center.[/en]
42 | * [ja][/ja]
43 | */
44 | verticalAlign: React.PropTypes.oneOf(['top', 'bottom', 'center'])
45 |
46 | };
47 |
48 | export default Row;
49 |
--------------------------------------------------------------------------------
/src/components/SplitterContent.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | /**
3 | * @original ons-splitter-content
4 | * @category menu
5 | * @tutorial react/Reference/splitter
6 | * @description
7 | * [en] The SplitterContent element is used as a child element of Splitter.
8 | * It contains the main content of the page while SplitterSide contains the list.
9 | [/en]
10 | * [jp][/jp]
11 | * @example
12 |
13 |
17 | Page Left
18 |
19 |
20 | Page Content
21 |
22 |
30 | Page Right
31 |
32 |
33 | */
34 | class SplitterContent extends SimpleWrapper {
35 | _getDomNodeName() {
36 | return 'ons-splitter-content';
37 | }
38 | };
39 |
40 | export default SplitterContent;
41 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 |
3 | module.exports = function(config) {
4 | config.set({
5 | browsers: [ 'Chrome' ], // run in Chrome
6 | singleRun: true, // just run once by default
7 | frameworks: [ 'mocha', 'chai' ], // use the mocha test framework
8 | files: [
9 | 'node_modules/onsenui/css/onsenui.css',
10 | 'node_modules/onsenui/css/onsen-css-components.css',
11 | 'tests.webpack.js' // just load this file
12 | ],
13 | preprocessors: {
14 | 'tests.webpack.js': [ 'webpack', 'sourcemap' ] // preprocess with webpack and our sourcemap loader
15 | },
16 | reporters: [ 'dots' ], // report results in this format
17 | webpack: { // kind of a copy of your webpack config
18 | devtool: 'inline-source-map', // just do inline source maps instead of the default
19 |
20 | module: {
21 | loaders: [
22 | { test: /\.js$/, loader: 'babel-loader',
23 | exclude: [/node_modules/, /onsenui\.js/],
24 | query: { presets: ['es2015', 'react'] }
25 | }
26 | ]
27 | }
28 | },
29 | webpackServer: {
30 | noInfo: true // please don't spam the console when running in karma!
31 | }
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/docs/BackButton.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-back-button\n@category navigation\n@tutorial react/Reference/navigator\n@description\n[en]\n Back button component for Toolbar. It enables to automatically to pop the top page of the navigator. When only presented with one page, the button is hidden automatically.\n\n The default behavior can be overridden using the `onClick` prop.\n[/en]\n[jp][/jp]\n@example\n\n Back
\n {this.props.title}
\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null},{"name":"_updateOnClick","docblock":null,"modifiers":[],"params":[{"name":"props","type":null}],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the back button.[/en]\n [jp][/jp]"},"onClick":{"type":{"name":"func"},"required":false,"description":"@name onClick\n@type function\n@description\n [en]This function will be called ones the button is clicked. It overrides the default behavior of the back button.[/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/LazyList.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import MyToolbar from './MyToolbar';
4 | import ons from '../../OnsenUI/build/js/onsenui.js';
5 |
6 | import {
7 | Page,
8 | BackButton,
9 | Button,
10 | ListItem,
11 | LazyList,
12 | Toolbar
13 | } from '../../src/index.js';
14 |
15 | export default class extends React.Component {
16 |
17 | constructor(props) {
18 | super(props);
19 | this.state = {
20 | length: 0
21 | };
22 | }
23 |
24 | renderRow(index) {
25 | return (
26 |
27 | {'Item ' + (index + 1)}
28 |
29 | );
30 | }
31 |
32 | render() {
33 | return (
34 | } >
35 |
36 | this.setState({length: 10})} > Change Length 10
37 | this.setState({length: 100})} > Change Length 100
38 | ons.platform.isAndroid() ? 76 : 45}
42 | />
43 |
44 |
45 | );
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/docs/SpeedDialItem.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-speed-dial-item\n@category control\n@tutorial react/Reference/speed-dial\n@description\n[en] This component displays the child elements of the Material Design Speed dial component. [/en]\n[jp][/jp]\n@example\n console.log('test1')} position='left bottom'>\n \n \n \n console.log('speed A')}> A \n console.log('speed B')}> B \n console.log('speed C')}> C \n console.log('speed D')}> D \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the button.[/en]\n [jp] [/jp]"},"onClick":{"type":{"name":"func"},"required":false,"description":"@name onClick\n@type function\n@description\n [en] This function will be called ones the button is clicked. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import {readFileSync} from 'fs';
2 | import babel from 'rollup-plugin-babel';
3 | import nodeResolve from 'rollup-plugin-node-resolve';
4 | import replace from 'rollup-plugin-replace';
5 | import commonjs from 'rollup-plugin-commonjs';
6 |
7 | const pkg = JSON.parse(readFileSync('package.json', 'utf-8' ));
8 |
9 | export default {
10 | entry: 'src/index.js',
11 | dest: 'dist/react-onsenui.js',
12 | plugins: [
13 | babel({presets: ['es2015-rollup', 'react', 'stage-2']}),
14 | nodeResolve(),
15 | commonjs({
16 | 'node_modules/react-dom/server.js': ['ReactDOMServer']
17 | }),
18 | replace({
19 | 'process.env.NODE_ENV': JSON.stringify('production')
20 | }),
21 | babel({
22 | externalHelpers: true, presets: ['es2015-rollup'], plugins: ['transform-react-jsx', 'transform-object-rest-spread']
23 | })
24 | ],
25 | external: [
26 | 'react',
27 | 'react-dom/server',
28 | 'react-dom',
29 | 'onsenui'
30 | ],
31 | globals: {
32 | 'react': 'React',
33 | 'react-dom': 'ReactDOM',
34 | 'react-dom/server': 'ReactDOMServer',
35 | 'onsenui': 'ons'
36 | },
37 | format: 'umd',
38 | moduleName: 'Ons',
39 | banner: `/*! ${pkg.name} v${pkg.version} - ${new Date()} */`,
40 | sourceMap: true
41 | };
42 |
--------------------------------------------------------------------------------
/demo/examples/Range.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | Range
6 | } from '../../src/index.js';
7 |
8 | import MyToolbar from './MyToolbar';
9 |
10 | export default class extends React.Component {
11 | constructor(props) {
12 | super(props);
13 | this.changeFirstRange = this.changeFirstRange.bind(this);
14 | this.changeSecondRange = this.changeSecondRange.bind(this);
15 | this.state = {value: 20, value2: 50};
16 | }
17 |
18 | changeFirstRange(event) {
19 | console.log(event.target.value);
20 | this.setState({
21 | value: parseInt(event.target.value)
22 | });
23 | }
24 |
25 | changeSecondRange(event) {
26 | this.setState({
27 | value2: parseInt(event.target.value)
28 | });
29 | }
30 |
31 | render() {
32 | return (
33 | } >
34 |
35 |
36 | {this.state.value}
37 |
38 |
39 | {this.state.value2}
40 |
41 |
42 |
43 |
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/components/Ripple.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-ripple
6 | * @category visual
7 | * @tutorial react/Reference/ripple
8 | * @description
9 | * [en]
10 | * Adds a Material Design "ripple" effect to an element.
11 | * [/en]
12 | * [jp][/jp]
13 | * @example
14 |
15 |
16 |
17 | */
18 | class Ripple extends SimpleWrapper {
19 | _getDomNodeName() {
20 | return 'ons-ripple';
21 | }
22 | };
23 |
24 | Ripple.propTypes = {
25 | /**
26 | * @name color
27 | * @type string
28 | * @required false
29 | * @description
30 | * [en]Color of the ripple effect.[/en]
31 | * [jp] [/jp]
32 | */
33 | color: React.PropTypes.string,
34 |
35 | /**
36 | * @name background
37 | * @type string
38 | * @required false
39 | * @description
40 | * [en]Color of the background.[/en]
41 | * [jp] [/jp]
42 | */
43 | background: React.PropTypes.string,
44 |
45 | /**
46 | * @name disabled
47 | * @type bool
48 | * @description
49 | * [en]
50 | * Specifies whether the button is disabled.
51 | * [/en]
52 | * [jp] [/jp]
53 | */
54 | disabled: React.PropTypes.bool
55 | };
56 |
57 | export default Ripple;
58 |
--------------------------------------------------------------------------------
/src/components/Toolbar.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-toolbar
6 | * @category page
7 | * @tutorial react/Reference/page
8 | * @description
9 | * [en]Toolbar component that can be used with navigation. Left, center and right container can be specified by class names. This component will automatically displays as a Material Design toolbar when running on Android devices.[/en]
10 | * [jp] どうしよう[/jp]
11 | * @example
12 | *
13 |
14 |
15 |
16 |
17 | Back
18 |
19 |
20 |
21 | Title
22 |
23 |
24 |
25 |
26 |
27 |
28 | }
29 | />
30 | */
31 | class Toolbar extends SimpleWrapper {
32 | _getDomNodeName() {
33 | return 'ons-toolbar';
34 | }
35 | };
36 |
37 | Toolbar.propTypes = {
38 | /**
39 | * @name modifier
40 | * @type string
41 | * @description
42 | * [en]
43 | * Specify modifier name to specify custom styles. Optional.
44 | * [/en]
45 | * [jp] どうしよう[/jp]
46 | */
47 | modifier: React.PropTypes.string
48 | };
49 |
50 | export default Toolbar;
51 |
--------------------------------------------------------------------------------
/docs/ProgressCircular.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-progress-circular\n@category visual\n@tutorial react/Reference/progress\n@description\n[en] This component displays a circular progress indicator. It can either be used to show how much of a task has been completed or to show a looping animation to indicate that an operation is currently running.\n[/en]\n[jp][/jp]\n@example\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the progress indicator.[/en]\n [jp] [/jp]"},"value":{"type":{"name":"number"},"required":false,"description":"@name value\n@type number\n@description\n [en]\n Current progress. Should be a value between 0 and 100.\n [/en]\n [jp] [/jp]"},"secondaryValue":{"type":{"name":"number"},"required":false,"description":"@name secondaryValue\n@type bool\n@description\n [en]\n Current secondary progress. Should be a value between 0 and 100.\n [/en]\n [jp] [/jp]"},"indeterminate":{"type":{"name":"bool"},"required":false,"description":"@name intermediate\n@type bool\n@description\n [en] If this property is set, an infinite looping animation will be shown. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Splitter.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 |
3 | /**
4 | * @original ons-splitter
5 | * @category menu
6 | * @tutorial react/Reference/splitter
7 | * @description
8 | * [en] A component that enables responsive layout by implementing both a two-column layout and a sliding menu layout.
9 | *
10 | * It can be configured to automatically expand into a column layout on large screens and collapse the menu on smaller screens. When the menu is collapsed the user can open it by swiping.
11 | [/en]
12 | * [jp] どうしよう[/jp]
13 | * @example
14 |
15 |
19 | Page Left
20 |
21 |
22 | Page Content
23 |
24 |
32 | Page Right
33 |
34 |
35 | */
36 |
37 | class Splitter extends SimpleWrapper {
38 | _getDomNodeName() {
39 | return 'ons-splitter';
40 | }
41 | };
42 |
43 | export default Splitter;
44 |
--------------------------------------------------------------------------------
/docs/ProgressBar.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-progress-bar\n@category visual\n@tutorial react/Reference/progress\n@description\n[en] The component is used to display a linear progress bar. It can either display a progress bar that shows the user how much of a task has been completed. In the case where the percentage is not known it can be used to display an animated progress bar so the user can see that an operation is in progress. [/en]\n[jp][/jp]\n@example\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the progress indicator.[/en]\n [jp] [/jp]"},"value":{"type":{"name":"number"},"required":false,"description":"@name value\n@type number\n@description\n [en]\n Current progress. Should be a value between 0 and 100.\n [/en]\n [jp] [/jp]"},"secondaryValue":{"type":{"name":"number"},"required":false,"description":"@name secondaryValue\n@type bool\n@description\n [en]\n Current secondary progress. Should be a value between 0 and 100.\n [/en]\n [jp] [/jp]"},"indeterminate":{"type":{"name":"bool"},"required":false,"description":"@name intermediate\n@type bool\n@description\n [en] If this property is set, an infinite looping animation will be shown. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/ToolbarButton.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-toolbar-button
6 | * @category page
7 | * @tutorial react/Reference/page
8 | * @description
9 | * [en]
10 | * Button component for the Toolbar. Using this component gives a nice default style.
11 | *
12 | *
13 | * [/en]
14 | * [jp][/jp]
15 | * @example
16 | *
18 |
19 | Back
20 | Input
21 |
22 | Add
23 |
24 |
25 | }>
26 | Page Content
27 |
28 | */
29 | class ToolbarButton extends SimpleWrapper {
30 | _getDomNodeName() {
31 | return 'ons-toolbar-button';
32 | }
33 | };
34 |
35 | ToolbarButton.propTypes = {
36 | /**
37 | * @name modifier
38 | * @type string
39 | * @required false
40 | * @description
41 | * [en]The appearance of the button.[/en]
42 | * [jp] [/jp]
43 | */
44 | modifier: React.PropTypes.string,
45 |
46 | /**
47 | * @name disabled
48 | * @type bool
49 | * @description
50 | * [en]
51 | * Indicates whether the button is disabled.
52 | * [/en]
53 | * [jp] [/jp]
54 | */
55 | disabled: React.PropTypes.bool
56 | };
57 |
58 | export default ToolbarButton;
59 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack');
2 | var path = require('path');
3 |
4 | module.exports = {
5 | devtool: 'eval-source-map',
6 | context: __dirname + "/demo",
7 | entry: [
8 | 'webpack-dev-server/client?http://0.0.0.0:9000',
9 | 'webpack/hot/only-dev-server',
10 | './index.js'
11 | ],
12 | output: {
13 | path: __dirname + '/demo',
14 | filename: "bundle.js"
15 | },
16 | devServer: {
17 | // contentBase
18 | colors: true,
19 | historyApiFallback: true,
20 | inline: false,
21 | port: 9000,
22 | hot: true
23 | },
24 | resolve: {
25 | alias: {
26 | 'onsenui': path.join(__dirname, 'OnsenUI/build/js/onsenui.js')
27 | }
28 | },
29 | module: {
30 | loaders: [
31 | // font-awesome
32 | {
33 | test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
34 | loader: 'url-loader?limit=10000&minetype=application/font-woff'
35 | },
36 | { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
37 | loader: 'file-loader'
38 | },
39 | {
40 | test: /\.json$/,
41 | loader: 'json'
42 | },
43 | {
44 | test: /\.css$/,
45 | loader: 'style!css'
46 | },
47 | { test: /\.js$|\.jsx$/,
48 | exclude: [/node_modules/, /onsenui\.js/],
49 | loaders: [ 'react-hot',
50 | 'babel?' + JSON.stringify({presets: ['stage-2', 'es2015', 'react']})
51 | ]
52 | }
53 | ]
54 | },
55 | plugins: [
56 | new webpack.HotModuleReplacementPlugin()
57 | ]
58 | };
59 |
--------------------------------------------------------------------------------
/demo/examples/ProgressBar.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | ProgressBar,
6 | ProgressCircular
7 | } from '../../src/index.js';
8 |
9 | import MyToolbar from './MyToolbar';
10 |
11 | export default class extends React.Component {
12 | constructor(props) {
13 | super(props);
14 |
15 | this.state = {
16 | modifier: 'material',
17 | value: 0,
18 | secondValue: 100
19 | };
20 |
21 | this.increaseTime = this.increaseTime.bind(this);
22 | this.increaseTime();
23 | }
24 |
25 | increaseTime() {
26 | this.timeout = setTimeout(() => {
27 | let val = this.state.value + 5;
28 | if (val > 100) val -= 100;
29 | this.setState({value: val}, this.increaseTime);
30 | }, 500);
31 | }
32 |
33 | componentWillUnmount() {
34 | clearTimeout(this.timeout);
35 | }
36 |
37 | render() {
38 | return (
39 | }
41 | modifier={this.state.modifier} >
42 |
43 |
44 | Progress Bar:
45 |
46 |
47 |
48 |
49 |
50 |
51 | Circular Progress Bar:
52 |
53 |
54 |
55 |
56 |
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/components/Col.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-col
7 | * @category grid
8 | * @description
9 | * [en]
10 | * Represents a column in the grid system. Use with `` to layout components.
11 | * [/en]
12 | * [jp][/jp]
13 | *
14 | *
15 | *
16 | *
17 | * Text
18 | *
19 | */
20 | class Col extends SimpleWrapper {
21 | _getDomNodeName() {
22 | return 'ons-col';
23 | }
24 |
25 | render() {
26 | var {...others} = this.props;
27 |
28 | Util.convert(others, 'verticalAlign', {newName: 'vertical-align'});
29 | Util.convert(others, 'width', {fun: Util.sizeConverter});
30 |
31 | return React.createElement(this._getDomNodeName(), others, this.props.children);
32 | }
33 |
34 | };
35 |
36 | Col.propTypes = {
37 |
38 | /**
39 | * @name verticalAlign
40 | * @type {String}
41 | * @description
42 | * [en]Short hand attribute for aligning vertically. Valid values are top, bottom, and center.[/en]
43 | * [ja][/ja]
44 | */
45 | verticalAlign: React.PropTypes.oneOf(['top', 'bottom', 'center']),
46 |
47 | /**
48 | * @name width
49 | * @type {String}
50 | * @description
51 | * [en]The width of the column. Valid values are css width values ("10%", 50).[/en]
52 | * [ja][/ja]
53 | */
54 | width: React.PropTypes.oneOfType([React.PropTypes.number, React.PropTypes.string])
55 | };
56 |
57 | export default Col;
58 |
--------------------------------------------------------------------------------
/docs/ListItem.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-list-item\n@category list\n@tutorial react/Reference/list\n@description\n [en]\n Component that represents each item in the list. Must be put inside the `List` component. The list item is composed of three parts that are represented with the `left`, `center` and `right` classes. These classes can be used to ensure that the content of the list items is properly aligned.\n [/en]\n[jp][/jp]\n@example\n \n Left
\n Center
\n Right
\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en] The appearance of the list item.[/en]\n [jp] [/jp]"},"tappable":{"type":{"name":"bool"},"required":false,"description":"@name tappable\n@type bool\n@description\n [en]\n Specifies whether the list item is tappable.\n [/en]\n [jp] [/jp]"},"tapBackgroundColor":{"type":{"name":"string"},"required":false,"description":"@name tapBackgroundColor\n@type string\n@description\n [en]\n Changes the background color when tapped. For this to work, the attribute \"tappable\" needs to be set. The default color is \"#d9d9d9\". It will display as a ripple effect on Android.\n [/en]\n [jp] [/jp]"},"lockOnDrag":{"type":{"name":"bool"},"required":false,"description":"@name lockOnDrag\n@type bool\n@description\n [en] Prevent vertical scrolling when the user drags horizontally. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/SpeedDial.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | Icon,
6 | Fab,
7 | SpeedDial,
8 | SpeedDialItem,
9 | Toolbar,
10 | BackButton
11 | } from '../../src/index.js';
12 |
13 | export default class extends React.Component {
14 | constructor(props) {
15 | super(props);
16 |
17 | this.state = {
18 | modifier: 'material',
19 | };
20 | }
21 |
22 | renderToolbar() {
23 | return (
24 |
25 |
26 | Back
27 |
28 |
29 | Speed Dial
30 |
31 |
32 | );
33 | }
34 |
35 | renderFixed() {
36 | return (
37 | console.log('test1')} position='bottom right'>
38 |
39 |
44 |
45 | console.log('speed A')}> A
46 | console.log('speed B')}> B
47 | console.log('speed C')}> C
48 | console.log('speed D')}> D
49 |
50 | );
51 | }
52 |
53 | render() {
54 | return (
55 |
56 |
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/components/Button.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-button
6 | * @category form
7 | * @tutorial react/Reference/button
8 | * @description
9 | * [en] Button component. If you want to place a button in a toolbar, use `ToolbarButton` or `BackButton` instead. Will automatically display as a Material Design button with a ripple effect on Android.
10 | [/en]
11 | * [jp][/jp]
12 | * @example
13 | *
14 | * Tap Me
15 | *
16 | */
17 | class Button extends SimpleWrapper {
18 | _getDomNodeName() {
19 | return 'ons-button';
20 | }
21 | };
22 |
23 | Button.propTypes = {
24 | /**
25 | * @name modifier
26 | * @type string
27 | * @required false
28 | * @description
29 | * [en]The appearance of the button.[/en]
30 | * [jp] [/jp]
31 | */
32 | modifier: React.PropTypes.string,
33 |
34 | /**
35 | * @name disabled
36 | * @type bool
37 | * @description
38 | * [en]
39 | * Specifies whether the button is disabled.
40 | * [/en]
41 | * [jp] [/jp]
42 | */
43 | disabled: React.PropTypes.bool,
44 |
45 | /**
46 | * @name ripple
47 | * @type bool
48 | * @description
49 | * [en]
50 | * Specifies whether the button has a ripple effect.
51 | * [/en]
52 | * [jp] [/jp]
53 | */
54 | ripple: React.PropTypes.bool,
55 |
56 | /**
57 | * @name onClick
58 | * @type function
59 | * @description
60 | * [en] This function will be called ones the button is clicked. [/en]
61 | * [jp] [/jp]
62 | */
63 | onClick: React.PropTypes.func
64 | };
65 |
66 | export default Button;
67 |
--------------------------------------------------------------------------------
/demo/examples/List.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import MyToolbar from './MyToolbar';
3 |
4 | import {
5 | Page,
6 | List,
7 | ListItem,
8 | ListHeader,
9 | Toolbar,
10 | ToolbarButton,
11 | BackButton,
12 | Button
13 | } from '../../src/index.js';
14 |
15 | export default class extends React.Component {
16 | constructor(props) {
17 | super(props);
18 |
19 | this.state = {
20 | data: [1, 2, 3, 4, 5, 6]
21 | };
22 | }
23 |
24 | reverseData() {
25 | this.setState({
26 | data: this.state.data.reverse()
27 | });
28 | }
29 |
30 | remove(idx) {
31 | const data = this.state.data;
32 | data.splice(idx, 1);
33 |
34 | this.setState({
35 | data: data
36 | });
37 | }
38 |
39 | add() {
40 | const data = this.state.data;
41 | data.push(data.length);
42 |
43 | this.setState({
44 | data: data
45 | });
46 | }
47 |
48 | render() {
49 | return (
50 | } >
51 | Header Text }
54 | renderRow={(row, idx) => (
55 |
56 | {row}
57 | Remove
58 |
59 | )}
60 | renderFooter={() => (
61 | Add more
62 | )}
63 | />
64 |
65 | );
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/demo/examples/Page.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Page, Button} from '../../src/index.js';
4 |
5 | import MyToolbar from './MyToolbar';
6 |
7 | class Page2 extends React.Component {
8 | constructor(props) {
9 | super(props);
10 | this.state = {};
11 | }
12 | render() {
13 | console.log('props');
14 | console.log(this.props);
15 | return (
16 |
17 | lala
18 | this.props.navigator.popPage()}> Pop
19 |
20 | );
21 | }
22 | };
23 |
24 | export default class extends React.Component {
25 | constructor(props) {
26 | super(props);
27 |
28 | this.state = {
29 | modifier: 'material'
30 | };
31 | }
32 |
33 | toggleModifier() {
34 | this.setState({
35 | modifier: this.state.modifier === 'material' ? '' : 'material'
36 | });
37 | }
38 |
39 | render() {
40 | return (
41 | }
44 | modifier={this.state.modifier} >
45 |
46 | This is a page!
47 |
48 |
49 | Switch modifier
50 |
51 |
52 |
54 | this.props.navigator.replacePage({
55 | title: 'Input',
56 | component: Page2,
57 | props: {
58 | navigator: this.props.navigator
59 | }
60 | })
61 | }> Replace Page
62 |
63 |
64 | );
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/githubRelease.js:
--------------------------------------------------------------------------------
1 | var prompt = require('prompt');
2 | var GitHubApi = require('github');
3 | var colors = require('colors');
4 |
5 | colors.setTheme({ warn: 'yellow', error: 'red', success: 'green' });
6 |
7 | prompt.start();
8 |
9 | var github = new GitHubApi({version: '3.0.0'});
10 |
11 | var properties = [
12 | {
13 | description: 'GitHub username',
14 | name: 'username'
15 | },
16 | {
17 | description: 'GitHub password',
18 | name: 'password',
19 | hidden: true
20 | }
21 | ];
22 |
23 | var login = (callback) => {
24 | prompt.get(properties, (err, result) => {
25 | github.authenticate({
26 | type: 'basic',
27 | username: result.username,
28 | password: result.password
29 | });
30 |
31 | github.repos.getLatestRelease({
32 | user: 'OnsenUI',
33 | repo: 'react-onsenui'
34 | }, (err, res) => {
35 | if (err != null) {
36 | console.log('Wrong Username/Password'.warn);
37 | return login(callback);
38 | } else {
39 | callback(res);
40 | }
41 | });
42 | });
43 | };
44 |
45 | var data = login((res) => {
46 | var tagname = res.tag_name;
47 | var nodeJSON = require('./package.json');
48 | var version = nodeJSON.version;
49 |
50 | if (tagname == version) {
51 | console.log('Error: Version has already been released, update package.json first'.error);
52 | } else {
53 | github.repos.createRelease( {
54 | user: 'OnsenUI',
55 | repo: 'react-onsenui',
56 | tag_name: version
57 | }, function(err, war) {
58 | if (err) {
59 | console.log('An error occurred'.error);
60 | } else {
61 | console.log(('New version ' + version + ' released').success);
62 | }
63 | });
64 | }
65 | });
66 |
--------------------------------------------------------------------------------
/docs/LazyList.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-lazy-repeat\n@category list\n@tutorial react/Reference/lazy-list\n@description\n[en] Using this component a list with millions of items can be rendered without a drop in performance.\n It does that by \"lazily\" loading elements into the DOM when they come into view and\n removing items from the DOM when they are not visible.\n [/en]\n[jp][/jp]\n@example\n\n renderRow(index) {\n return (\n \n {'Item ' + (index + 1)}\n \n );\n }\n\n render() {\n return (\n } >\n \n \n \n {'Item ' + (index + 1)}\n \n }\n calculateItemHeight={() => 44}\n />\n
\n \n );\n }\n}","methods":[{"name":"update","docblock":null,"modifiers":[],"params":[{"name":"props","type":null}],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the lazy list.[/en]\n [jp] [/jp]"},"length":{"type":{"name":"number"},"required":true,"description":"@name length\n@type number\n@description\n [en]The length of the list.[/en]\n [jp] [/jp]"},"renderRow":{"type":{"name":"func"},"required":true,"description":"@name renderRow\n@type function\n@description\n [en] A function given the index of the to display row, renders it.[/en]\n [jp] [/jp]"},"calculateItemHeight":{"type":{"name":"func"},"required":true,"description":"@name calculateItemHeight\n@type function\n@description\n [en] A function given the index of the to row, returns the height of it.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/BackButton.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import ReactDOM from 'react-dom';
4 |
5 | /**
6 | * @original ons-back-button
7 | * @category navigation
8 | * @tutorial react/Reference/navigator
9 | * @description
10 | * [en]
11 | * Back button component for Toolbar. It enables to automatically to pop the top page of the navigator. When only presented with one page, the button is hidden automatically.
12 | *
13 | * The default behavior can be overridden using the `onClick` prop.
14 | * [/en]
15 | * [jp][/jp]
16 | * @example
17 | *
18 | Back
19 | {this.props.title}
20 |
21 | */
22 | class BackButton extends SimpleWrapper {
23 | _getDomNodeName() {
24 | return 'ons-back-button';
25 | }
26 |
27 | _updateOnClick(props) {
28 | const node = ReactDOM.findDOMNode(this);
29 |
30 | if (props.onClick) {
31 | node.onClick = () => null;
32 | } else {
33 | delete node.onClick;
34 | }
35 | }
36 |
37 | componentDidMount() {
38 | this._updateOnClick(this.props);
39 | }
40 |
41 | componentWillReceiveProps(props) {
42 | this._updateOnClick(props);
43 | }
44 | };
45 |
46 | BackButton.propTypes = {
47 | /**
48 | * @name modifier
49 | * @type string
50 | * @required false
51 | * @description
52 | * [en]The appearance of the back button.[/en]
53 | * [jp][/jp]
54 | */
55 | modifier: React.PropTypes.string,
56 |
57 | /**
58 | * @name onClick
59 | * @type function
60 | * @description
61 | * [en]This function will be called ones the button is clicked. It overrides the default behavior of the back button.[/en]
62 | * [jp][/jp]
63 | */
64 | onClick: React.PropTypes.func
65 | };
66 |
67 | export default BackButton;
68 |
--------------------------------------------------------------------------------
/docs/List.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-list\n@category list\n@tutorial react/Reference/list\n@description\n [en]\n Component for representing a list. It takes an array called datasource and calls renderRow(row, index) for every row. Furthermore, the header and the footer can be specified with `renderRow` and `renderHeader` respectivly. [/en]\n[jp][/jp]\n@example\n (\n \n {row}\n Remove \n \n )}\n renderFooter={this.renderFooter}\n />","methods":[],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]\n Specify modifier name to specify custom styles.\n [/en]\n [jp] どうしよう[/jp]"},"dataSource":{"type":{"name":"array"},"required":false,"description":"@name dataSource\n@type string\n@description\n [en]\n Source of the list data. Should be an array.\n [/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"[]","computed":false}},"renderRow":{"type":{"name":"func"},"required":false,"description":"@name renderRow\n@type function\n@description\n [en]\n Function to specify the rendering function for every element in\n in the dataSource.\n [/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}},"renderHeader":{"type":{"name":"func"},"required":false,"description":"@name renderHeader\n@type function\n@description\n [en]\n Function to specify the rendering function for the header\n [/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}},"renderFooter":{"type":{"name":"func"},"required":false,"description":"@name renderFooter\n@type function\n@description\n [en]\n Function to specify the rendering function for the footer\n [/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/AlertDialog.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Page, Toolbar, Button, BackButton, AlertDialog} from '../../src/index.js';
4 |
5 | export default class extends React.Component {
6 | constructor(props) {
7 | super(props);
8 |
9 | this.state = {
10 | isOpen: false
11 | };
12 | }
13 |
14 | handleClick() {
15 | this.setState({
16 | isOpen: true
17 | });
18 | }
19 |
20 | handleCancel() {
21 | this.setState({
22 | isOpen: false
23 | });
24 | }
25 |
26 | render() {
27 | return (
28 |
31 |
32 | Back
33 |
34 |
35 | Alert dialog
36 |
37 |
38 | }
39 | >
40 |
41 |
42 | Show dialog
43 |
44 |
45 |
53 | Warning!
54 |
55 | An error has occurred!
56 |
57 |
58 |
59 | Cancel
60 |
61 |
62 | Ok
63 |
64 |
65 |
66 |
67 | );
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/components/SpeedDialItem.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import ReactDOM from 'react-dom';
3 | import React from 'react';
4 |
5 | /**
6 | * @original ons-speed-dial-item
7 | * @category control
8 | * @tutorial react/Reference/speed-dial
9 | * @description
10 | * [en] This component displays the child elements of the Material Design Speed dial component. [/en]
11 | * [jp][/jp]
12 | * @example
13 | * console.log('test1')} position='left bottom'>
14 |
15 |
16 |
17 | console.log('speed A')}> A
18 | console.log('speed B')}> B
19 | console.log('speed C')}> C
20 | console.log('speed D')}> D
21 |
22 | */
23 | class SpeedDialItem extends SimpleWrapper {
24 | _getDomNodeName() {
25 | return 'ons-speed-dial-item';
26 | }
27 |
28 | componentDidMount() {
29 | super.componentDidMount();
30 | var node = ReactDOM.findDOMNode(this);
31 | node.addEventListener('click', this.props.onClick);
32 | }
33 |
34 | componentWillUnmount() {
35 | var node = ReactDOM.findDOMNode(this);
36 | node.removeEventListener('click', this.props.onClick);
37 | }
38 | };
39 |
40 | SpeedDialItem.propTypes = {
41 | /**
42 | * @name modifier
43 | * @type string
44 | * @required false
45 | * @description
46 | * [en]The appearance of the button.[/en]
47 | * [jp] [/jp]
48 | */
49 | modifier: React.PropTypes.string,
50 |
51 | /**
52 | * @name onClick
53 | * @type function
54 | * @description
55 | * [en] This function will be called ones the button is clicked. [/en]
56 | * [jp] [/jp]
57 | */
58 | onClick: React.PropTypes.func
59 | };
60 |
61 | export default SpeedDialItem;
62 |
--------------------------------------------------------------------------------
/demo/examples/PullHook.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | PullHook,
6 | Fab,
7 | Icon,
8 | Toolbar,
9 | List,
10 | ListItem
11 | } from '../../src/index.js';
12 |
13 | import MyToolbar from './MyToolbar.js';
14 |
15 | class MyPullHook extends React.Component {
16 | constructor(props) {
17 | super(props);
18 | this.onLoad = this.onLoad.bind(this);
19 | this.onChange = this.onChange.bind(this);
20 | this.state = {pullHookState: 'initial'};
21 | }
22 |
23 | onLoad(done) {
24 | setTimeout(done, 1000);
25 | }
26 |
27 | onChange(event) {
28 | console.log('state : ' + event.state);
29 | this.setState({pullHookState: event.state});
30 | }
31 |
32 | render() {
33 | var child;
34 |
35 | if (this.state.pullHookState === 'initial') {
36 | child =
37 |
41 | Pull down to refresh
42 | ;
43 | } else if (this.state.pullHookState === 'preaction') {
44 | child = Release to refresh ;
45 | } else {
46 | child = Loading data... ;
47 | }
48 |
49 | return (
50 |
51 | {child}
52 |
53 | );
54 | }
55 | };
56 |
57 | export default class extends React.Component {
58 | constructor(props) {
59 | super(props);
60 |
61 | this.state = {
62 | modifier: 'material'
63 | };
64 | }
65 |
66 | render() {
67 | return (
68 | }
70 | renderFixed={() => }>
71 |
72 |
73 | {data} } />
76 |
77 | );
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/docs/SpeedDial.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-speed-dial\n@category control\n@tutorial react/Reference/speed-dial\n@description\n[en] Element that displays a Material Design Speed Dialog component. It is useful when there are more than one primary action that can be performed in a page.\n The Speed dial looks like a `Fab` element but will expand a menu when tapped.\n [/en]\n[jp][/jp]\n@example\n console.log('test1')} position='left bottom'>\n \n \n \n console.log('speed A')}> A \n console.log('speed B')}> B \n console.log('speed C')}> C \n console.log('speed D')}> D \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the speed dial.[/en]\n [jp] [/jp]"},"position":{"type":{"name":"string"},"required":false,"description":"@name position\n@type string\n@description\n [en]Specify the vertical and horizontal position of the component.\n I.e. to display it in the top right corner specify \"right top\".\n Choose from \"right\", \"left\", \"top\" and \"bottom\".\n[/en]\n [jp] [/jp]"},"direction":{"type":{"name":"enum","value":[{"value":"'up'","computed":false},{"value":"'down'","computed":false},{"value":"'left'","computed":false},{"value":"'right'","computed":false}]},"required":false,"description":"@name direction\n@type string\n@description\n [en]Specify the direction the items are displayed. Possible values are \"up\", \"down\", \"left\" and \"right\".[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type string\n@description\n [en]Specify if button should be disabled.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/Tabbar.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {Tabbar, Tab, Page, Button} from '../../src/index.js';
4 | import MyToolbar from './MyToolbar';
5 |
6 | class TabPage extends React.Component {
7 | render() {
8 | return (
9 | } >
10 | {this.props.active
11 | ? This is the {this.props.title} page.
12 | : null}
13 | Go to the other tab
14 |
15 | );
16 | }
17 | }
18 |
19 | export default class extends React.Component {
20 |
21 | constructor(props) {
22 | super(props);
23 | this.state = {
24 | index: 0
25 | };
26 | this.renderTabs = this.renderTabs.bind(this);
27 | }
28 |
29 | renderTabs(activeIndex, tabbar) {
30 | console.log('index : ' , activeIndex);
31 | return [
32 | {
33 | content: { this.setState({index: 1}); }}
34 | title='Home' active={activeIndex == 0} tabbar={tabbar} />,
35 | tab: console.log('click home')}
37 | label='Home'
38 | icon='md-home' />
39 | },
40 | {
41 | content: { this.setState({index: 0}); }}
43 |
44 | title='Settings' active={activeIndex == 1} tabbar={tabbar} />,
45 | tab: console.log('click setting')} label='Settings' icon='md-settings' />
46 | }
47 | ];
48 | }
49 |
50 | render() {
51 | return (
52 |
53 |
56 | {
57 | this.setState({index: event.index});
58 | console.log('preChange', event.index);
59 | }
60 | }
61 | onPostChange={() => console.log('postChange')}
62 | onReactive={() => console.log('postChange')}
63 | position='bottom'
64 | renderTabs={this.renderTabs}
65 | />
66 |
67 | );
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/demo/examples/Icon.js:
--------------------------------------------------------------------------------
1 |
2 | import React from 'react';
3 |
4 | import {Button, Page, Icon} from '../../src/index.js';
5 |
6 | import MyToolbar from './MyToolbar';
7 |
8 | export default class extends React.Component {
9 | constructor(props) {
10 | super(props);
11 |
12 | this.changeModifier = this.changeModifier.bind(this);
13 | this.state = {
14 | showMaterial: false,
15 | btnText: 'Switch to material design',
16 | modifier: 'defaullt',
17 | };
18 | }
19 |
20 | changeModifier() {
21 | if (this.state.showMaterial) {
22 | this.setState({
23 | showMaterial: false,
24 | btnText: 'Switch to material design',
25 | modifier: 'defaullt',
26 | });
27 | } else {
28 | this.setState({
29 | showMaterial: true,
30 | btnText: 'Switch to default design',
31 | modifier: 'material'
32 | });
33 | }
34 | }
35 |
36 | render() {
37 | return (
38 | } >
39 |
40 |
41 |
{this.state.btnText}
42 |
modifier: {this.state.modifier}
43 |
Button standard
44 |
48 |
Button standard2
49 | {[0, 90, 180, 270].map((val) =>
50 |
51 |
63 | )}
64 |
65 |
66 | );
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/docs/Modal.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-modal\n@category dialog\n@tutorial react/Reference/modal\n@description\n[en]\n A modal component covers the entire screen. Underlying components are not\n subject to any events while the modal component is shown.\n\n This component can be used to block user input while some operation is\n running or to show some information to the user.\n[/en]\n[jp]\n 画面全体をマスクするモーダル用コンポーネントです。下側にあるコンポーネントは、\n モーダルが表示されている間はイベント通知が行われません\n[/jp]\n@example\n (\n \n Loading ...\n \n )}>\n Page content
\n ","methods":[{"name":"_update","docblock":null,"modifiers":[],"params":[{"name":"props","type":null},{"name":"isOpen","type":null}],"returns":null}],"props":{"animation":{"type":{"name":"enum","value":[{"value":"'none'","computed":false},{"value":"'fade'","computed":false}]},"required":false,"description":"@property animation\n@type {String}\n@description\n [en]\n Animation name. Available animations are `\"slide\"`, `\"lift\"`, `\"fade\"` and `\"none\"`.\n These are platform based animations. For fixed animations, add `\"-ios\"` or `\"-md\"` suffix to the animation name. E.g. `\"lift-ios\"`, `\"lift-md\"`. Defaults values are `\"slide-ios\"` and `\"fade-md\"`.\n [/en]","defaultValue":{"value":"'none'","computed":false}},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]"},"onShow":{"type":{"name":"func"},"required":false,"description":"@name onShow\n@type function\n@required false\n@description\n [en]\n Called Fired right after the modal is shown.\n [/en]"},"onHide":{"type":{"name":"func"},"required":false,"description":"@name onHide\n@type function\n@required false\n@description\n [en]\n Called after the modal is hidden.\n [/en]"},"isOpen":{"type":{"name":"bool"},"required":false,"description":"@name isOpen\n@type boolean\n@description\n [en]When `true` the modal will show itself.[/en]","defaultValue":{"value":"false","computed":false}}}}
2 |
--------------------------------------------------------------------------------
/src/components/ProgressCircular.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-progress-circular
7 | * @category visual
8 | * @tutorial react/Reference/progress
9 | * @description
10 | * [en] This component displays a circular progress indicator. It can either be used to show how much of a task has been completed or to show a looping animation to indicate that an operation is currently running.
11 | * [/en]
12 | * [jp][/jp]
13 | * @example
14 | *
15 | *
16 | */
17 | class ProgressCircular extends SimpleWrapper {
18 | _getDomNodeName() {
19 | return 'ons-progress-circular';
20 | }
21 |
22 | render() {
23 | var {...others} = this.props;
24 |
25 | Util.convert(others, 'indeterminate');
26 | Util.convert(others, 'secondaryValue', {newName: 'secondary-value'});
27 |
28 | return React.createElement(this._getDomNodeName(), others, this.props.children);
29 | }
30 |
31 | };
32 |
33 | ProgressCircular.propTypes = {
34 | /**
35 | * @name modifier
36 | * @type string
37 | * @required false
38 | * @description
39 | * [en]The appearance of the progress indicator.[/en]
40 | * [jp] [/jp]
41 | */
42 | modifier: React.PropTypes.string,
43 |
44 | /**
45 | * @name value
46 | * @type number
47 | * @description
48 | * [en]
49 | * Current progress. Should be a value between 0 and 100.
50 | * [/en]
51 | * [jp] [/jp]
52 | */
53 | value: React.PropTypes.number,
54 |
55 | /**
56 | * @name secondaryValue
57 | * @type bool
58 | * @description
59 | * [en]
60 | * Current secondary progress. Should be a value between 0 and 100.
61 | * [/en]
62 | * [jp] [/jp]
63 | */
64 | secondaryValue: React.PropTypes.number,
65 |
66 | /**
67 | * @name intermediate
68 | * @type bool
69 | * @description
70 | * [en] If this property is set, an infinite looping animation will be shown. [/en]
71 | * [jp] [/jp]
72 | */
73 | indeterminate: React.PropTypes.bool
74 | };
75 |
76 | export default ProgressCircular;
77 |
--------------------------------------------------------------------------------
/src/components/Switch.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import BasicComponent from './BasicComponent.jsx';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-switch
7 | * @category form
8 | * @tutorial react/Reference/switch
9 | * @description
10 | * [en] Switch component. The switch can be toggled both by dragging and tapping.
11 | * Will automatically displays a Material Design switch on Android devices.
12 | [/en]
13 | * [jp][/jp]
14 | * @example
15 | *
16 | */
17 | class Switch extends BasicComponent {
18 |
19 | componentDidMount() {
20 | super.componentDidMount();
21 | this.refs.switch.addEventListener('change', this.props.onChange);
22 | }
23 |
24 | componentWillUnmount() {
25 | this.refs.switch.removeEventListener('change', this.props.onChange);
26 | }
27 |
28 | render() {
29 | var {checked, inputId, ...other} = this.props;
30 |
31 | Util.convert(other, 'disabled');
32 |
33 | if (inputId) {
34 | other['input-id'] = inputId;
35 | }
36 | return (
37 |
38 | );
39 | }
40 | };
41 |
42 | Switch.propTypes = {
43 | /**
44 | * @name onChange
45 | * @type function
46 | * @description
47 | * [en] Called when the value of the switch changes (checked/unchecked) [/en]
48 | * [jp] [/jp]
49 | */
50 | onChange: React.PropTypes.func,
51 |
52 | /**
53 | * @name checked
54 | * @type bool
55 | * @description
56 | * [en] Whether the switch is checked.[/en]
57 | * [jp] [/jp]
58 | */
59 | checked: React.PropTypes.bool,
60 |
61 | /**
62 | * @name disabled
63 | * @type bool
64 | * @description
65 | * [en] If set, the switch is disabled.[/en]
66 | * [jp] [/jp]
67 | */
68 | disabled: React.PropTypes.bool,
69 |
70 | /**
71 | * @name inputId
72 | * @type bool
73 | * @description
74 | * [en] Specify the `id` attribute of the inner ` ` element. This is useful when using `` elements.[/en]
75 | * [jp] [/jp]
76 | */
77 | inputId: React.PropTypes.string
78 | };
79 |
80 | export default Switch;
81 |
--------------------------------------------------------------------------------
/docs/Fab.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-fab\n@category form\n@tutorial react/Reference/fab\n@description\n[en] The Floating action button is a circular button defined in the [Material Design specification](https://www.google.com/design/spec/components/buttons-floating-action-button.html). They are often used to promote the primary action of the app.\n It can be displayed either as an inline element or in one of the corners. Normally it will be positioned in the lower right corner of the screen.\n [/en]\n[jp][/jp]\n@example\n console.log('test1')} position='left bottom'>\n \n \n \n console.log('speed A')}> A \n console.log('speed B')}> B \n console.log('speed C')}> C \n console.log('speed D')}> D \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the button.[/en]\n [jp] [/jp]"},"ripple":{"type":{"name":"bool"},"required":false,"description":"@name ripple\n@type bool\n@description\n [en]If true, the button will have a ripple effect when tapped.[/en]\n [jp] [/jp]"},"position":{"type":{"name":"string"},"required":false,"description":"@name position\n@type string\n@required false\n@description\n [en]The position of the button. Should be a string like `\"bottom right\"` or `\"top left\"`. If this attribute is not defined it will be displayed as an inline element.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en] If true, the button will be disabled. [/en]\n [jp] [/jp]"},"onClick":{"type":{"name":"func"},"required":false,"description":"@name onClick\n@type function\n@description\n [en] This function will be called ones the button is clicked. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/ProgressBar.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-progress-bar
7 | * @category visual
8 | * @tutorial react/Reference/progress
9 | * @description
10 | * [en] The component is used to display a linear progress bar. It can either display a progress bar that shows the user how much of a task has been completed. In the case where the percentage is not known it can be used to display an animated progress bar so the user can see that an operation is in progress. [/en]
11 | * [jp][/jp]
12 | * @example
13 | *
14 | *
15 | */
16 | class ProgressBar extends SimpleWrapper {
17 | _getDomNodeName() {
18 | return 'ons-progress-bar';
19 | }
20 |
21 | render() {
22 | var {...others} = this.props;
23 |
24 | Util.convert(others, 'indeterminate');
25 | Util.convert(others, 'secondaryValue', {newName: 'secondary-value'});
26 |
27 | return React.createElement(this._getDomNodeName(), others, this.props.children);
28 | }
29 |
30 | };
31 |
32 | ProgressBar.propTypes = {
33 | /**
34 | * @name modifier
35 | * @type string
36 | * @required false
37 | * @description
38 | * [en]The appearance of the progress indicator.[/en]
39 | * [jp] [/jp]
40 | */
41 | modifier: React.PropTypes.string,
42 |
43 | /**
44 | * @name value
45 | * @type number
46 | * @description
47 | * [en]
48 | * Current progress. Should be a value between 0 and 100.
49 | * [/en]
50 | * [jp] [/jp]
51 | */
52 | value: React.PropTypes.number,
53 |
54 | /**
55 | * @name secondaryValue
56 | * @type bool
57 | * @description
58 | * [en]
59 | * Current secondary progress. Should be a value between 0 and 100.
60 | * [/en]
61 | * [jp] [/jp]
62 | */
63 | secondaryValue: React.PropTypes.number,
64 |
65 | /**
66 | * @name intermediate
67 | * @type bool
68 | * @description
69 | * [en] If this property is set, an infinite looping animation will be shown. [/en]
70 | * [jp] [/jp]
71 | */
72 | indeterminate: React.PropTypes.bool
73 | };
74 |
75 | export default ProgressBar;
76 |
--------------------------------------------------------------------------------
/docs/PullHook.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-pull-hook\n@category control\n@tutorial react/Reference/pull-hook\n@description\n[en] Component that adds **Pull to refresh** functionality to an `` element.\n It can be used to perform a task when the user pulls down at the top of the page. A common usage is to refresh the data displayed in a page.\n [/en]\n[jp] どうしよう[/jp]\n@example\n\n return (\n \n {\n (this.state.pullHookState === 'initial') ?\n \n \n Pull down to refresh\n :\n (this.state.pullHookState === 'preaction') ?\n \n \n Release to refresh\n \n :\n Loading data... \n }\n \n );","methods":[],"props":{"onChange":{"type":{"name":"func"},"required":false,"description":"@name onChange\n@type function\n@required false\n@description\n [en]Called when the pull hook inner state is changed. The state can be either \"initial\", \"preaction\" or \"action\"[/en]\n [jp] [/jp]"},"onLoad":{"type":{"name":"func"},"required":false,"description":"@name onLoad\n@type function\n@required false\n@description\n [en]Called when the pull hook is in the `action` state[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en] When set to true, the pull hook will be disabled.[/en]\n [jp] [/jp]"},"height":{"type":{"name":"number"},"required":false,"description":"@name height\n@type number\n@description\n [en] The height of the pull hook in pixels. The default value is 64.[/en]\n [jp] [/jp]"},"thresholdHeight":{"type":{"name":"number"},"required":false,"description":"@name thresholdHeight\n@type number\n@description\n [en] The threshold height of the pull hook in pixels. The default value is 96.[/en]\n [jp] [/jp]"},"fixedContent":{"type":{"name":"bool"},"required":false,"description":"@name fixedContent\n@type number\n@description\n [en] If set to true, the content of the page will not move when pulling.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Range.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import ReactDOM from 'react-dom';
4 |
5 | const EVENT_TYPES = ['change', 'input'];
6 |
7 | /**
8 | * @original ons-range
9 | * @category form
10 | * @tutorial react/Reference/range
11 | * @description
12 | * [en]
13 | * Range input component.
14 | * [/en]
15 | * [jp][/jp]
16 | * @example
17 | * this.setState({value: parseInt(event.target.value)})}
20 | * />
21 | */
22 | class Range extends SimpleWrapper {
23 |
24 | componentDidMount() {
25 | super.componentDidMount();
26 | var node = ReactDOM.findDOMNode(this);
27 |
28 | EVENT_TYPES.forEach((eventType) => {
29 | node.addEventListener(eventType, this.props.onChange);
30 | });
31 | }
32 |
33 | componentWillUnmount() {
34 | var node = ReactDOM.findDOMNode(this);
35 |
36 | EVENT_TYPES.forEach((eventType) => {
37 | node.removeEventListener(eventType, this.props.onChange);
38 | });
39 | }
40 |
41 | componentWillReceiveProps(props) {
42 | const node = ReactDOM.findDOMNode(this);
43 | node.value = props.value;
44 | }
45 |
46 | _getDomNodeName() {
47 | return 'ons-range';
48 | }
49 | };
50 |
51 | Range.propTypes = {
52 | /**
53 | * @name modifier
54 | * @type string
55 | * @required false
56 | * @description
57 | * [en]The appearance of the progress indicator.[/en]
58 | * [jp] [/jp]
59 | */
60 | modifier: React.PropTypes.string,
61 |
62 | /**
63 | * @name onChange
64 | * @type function
65 | * @description
66 | * [en] Called when the value of the input changes.[/en]
67 | * [jp][/jp]
68 | */
69 | onChange: React.PropTypes.func,
70 |
71 | /**
72 | * @name value
73 | * @type number
74 | * @description
75 | * [en]
76 | * Current value of the element.
77 | * [/en]
78 | * [jp] [/jp]
79 | */
80 | value: React.PropTypes.number,
81 |
82 | /**
83 | * @name disabled
84 | * @type bool
85 | * @description
86 | * [en] If true, the element is disabled. [/en]
87 | * [jp] [/jp]
88 | */
89 | disabled: React.PropTypes.bool
90 | };
91 |
92 | export default Range;
93 |
--------------------------------------------------------------------------------
/demo/examples/Modal.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Page,
4 | Modal,
5 | Button,
6 | BackButton,
7 | Toolbar,
8 | ToolbarButton,
9 | Icon
10 | } from '../../src/index.js';
11 |
12 | const MyToolbar = ({ title = '', leftButton }) => (
13 |
14 | {leftButton &&
15 |
16 | {leftButton}
17 |
18 | }
19 |
20 | {title}
21 |
22 |
23 | );
24 |
25 | export default class extends React.Component {
26 | constructor(props) {
27 | super(props);
28 |
29 | this.state = {
30 | showModal: false
31 | };
32 | }
33 |
34 | renderModalToolbar() {
35 | return (
36 | this.setState({ showModal: false })}>
40 |
44 |
45 | )}
46 | />
47 | );
48 | }
49 |
50 | renderModal() {
51 | return (
52 | console.log('modal shown')}
57 | onHide={() => console.log('modal hidden')}
58 | >
59 |
60 |
61 | I'm a modal page.
62 |
63 |
64 |
65 | );
66 | }
67 |
68 | render() {
69 | return (
70 | (
73 | Back}
76 | />
77 | )}
78 | >
79 |
80 | this.setState({ showModal: true })}>
81 | Open Modal
82 |
83 |
84 |
85 | );
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/demo/examples/Carousel.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import MyToolbar from './MyToolbar';
4 |
5 | import {
6 | Page,
7 | Button,
8 | Navigator,
9 | Toolbar,
10 | List,
11 | ListItem,
12 | Ripple,
13 | Carousel,
14 | CarouselItem,
15 | BottomToolbar,
16 | ToolbarButton
17 | } from '../../src/index.js';
18 |
19 | export default class extends React.Component {
20 | constructor(props) {
21 | super(props);
22 | this.state = {
23 | index: 1,
24 | items: [
25 | 'gray',
26 | 'red',
27 | 'orange',
28 | 'blue'
29 | ]
30 | };
31 | this.goTo = this.goTo.bind(this);
32 | }
33 |
34 | goTo(number) {
35 | console.log('number', number);
36 | this.setState({index: number});
37 | }
38 |
39 | render() {
40 | return (
41 | }>
42 | this.setState({index: event.activeIndex})}
50 | onOverscroll={() => console.log('onOverscroll')}
51 | onRefresh={() => console.log('onRefresh')}
52 | ref='carousel' swipeable overscrollable autoScroll fullscreen autoScrollRatio={0.2}>
53 |
54 | {this.state.items.map((item) =>
55 |
56 | {item}
57 | {this.state.items.map((item, index) =>
58 | this.goTo(index)}> Go to page {index + 1}
59 | )}
60 | this.setState({items: this.state.items.slice(0, this.state.items.length - 1)})}>Remove
61 | this.setState({items: [...this.state.items, 'yellow']})}>Add
62 |
63 | )}
64 |
65 |
66 |
67 | Next
68 | Prev
69 |
70 |
71 | );
72 | }
73 | };
74 |
--------------------------------------------------------------------------------
/src/components/SpeedDial.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-speed-dial
6 | * @category control
7 | * @tutorial react/Reference/speed-dial
8 | * @description
9 | * [en] Element that displays a Material Design Speed Dialog component. It is useful when there are more than one primary action that can be performed in a page.
10 | * The Speed dial looks like a `Fab` element but will expand a menu when tapped.
11 | [/en]
12 | * [jp][/jp]
13 | * @example
14 | * console.log('test1')} position='left bottom'>
15 |
16 |
17 |
18 | console.log('speed A')}> A
19 | console.log('speed B')}> B
20 | console.log('speed C')}> C
21 | console.log('speed D')}> D
22 |
23 | */
24 | class SpeedDial extends SimpleWrapper {
25 | _getDomNodeName() {
26 | return 'ons-speed-dial';
27 | }
28 | };
29 |
30 | SpeedDial.propTypes = {
31 | /**
32 | * @name modifier
33 | * @type string
34 | * @required false
35 | * @description
36 | * [en]The appearance of the speed dial.[/en]
37 | * [jp] [/jp]
38 | */
39 | modifier: React.PropTypes.string,
40 |
41 | /**
42 | * @name position
43 | * @type string
44 | * @description
45 | * [en]Specify the vertical and horizontal position of the component.
46 | * I.e. to display it in the top right corner specify "right top".
47 | * Choose from "right", "left", "top" and "bottom".
48 | [/en]
49 | * [jp] [/jp]
50 | */
51 | position: React.PropTypes.string,
52 |
53 | /**
54 | * @name direction
55 | * @type string
56 | * @description
57 | * [en]Specify the direction the items are displayed. Possible values are "up", "down", "left" and "right".[/en]
58 | * [jp] [/jp]
59 | */
60 | direction: React.PropTypes.oneOf(['up', 'down', 'left', 'right']),
61 |
62 | /**
63 | * @name disabled
64 | * @type string
65 | * @description
66 | * [en]Specify if button should be disabled.[/en]
67 | * [jp] [/jp]
68 | */
69 | disabled: React.PropTypes.bool
70 | };
71 |
72 | export default SpeedDial;
73 |
--------------------------------------------------------------------------------
/docs/Icon.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-icon\n@category visual\n@tutorial react/Reference/icon\n@description\n[en]\nDisplays an icon. The following icon suites are available:\n * [Font Awesome](https://fortawesome.github.io/Font-Awesome/)\n * [Ionicons](http://ionicons.com/)\n * [Material Design Iconic Font](http://zavoloklom.github.io/material-design-iconic-font/)\n[/en]\n[jp][/jp]\n@example\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the icon.[/en]\n [jp] [/jp]"},"icon":{"type":{"name":"union","value":[{"name":"string"},{"name":"custom","raw":"React.PropTypes.objectOf(React.PropTypes.string)"}]},"required":false,"description":"@name icon\n@type 'object or string'\n@description\n [en] can be either a string or an object. If it is an string, it is set to an specific icon like 'ions-navicon'. If it is an object, it represents a dictionary of the icons depending on the modifier e.g. `{{default: 'ion-navicon', material: 'md-menu'}}` [/en]\n [jp] [/jp]"},"size":{"type":{"name":"union","value":[{"name":"number"},{"name":"custom","raw":"React.PropTypes.objectOf(React.PropTypes.number)"}]},"required":false,"description":"@name size\n@type 'object or number'\n@description\n [en] can be either a number or an object. If it is an number, it specifies the icon size with a number in pixels. If it is an object, it represents a dictionary of the icon sizes depending on the modifier e.g. `{{default: 20, material: 18}}` [/en]\n [jp] [/jp]"},"rotate":{"type":{"name":"enum","value":[{"value":"0","computed":false},{"value":"90","computed":false},{"value":"180","computed":false},{"value":"270","computed":false}]},"required":false,"description":"@name rotate\n@type number\n@description\n [en] Number of degrees to rotate the icon. Valid values are 90, 180 and 270. [/en]\n [jp] [/jp]"},"fixedWidth":{"type":{"name":"bool"},"required":false,"description":"@name fixedWidth\n@type bool\n@description\n[en] When used in a list, you want the icons to have the same width so that they align vertically by defining this attribute. [/en]\n [jp] [/jp]"},"spin":{"type":{"name":"bool"},"required":false,"description":"@name spin\n@type bool\n@description\n[en] Specify whether the icon should be spinning. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import AlertDialog from './components/AlertDialog.jsx';
2 | import BackButton from './components/BackButton.jsx';
3 | import BottomToolbar from './components/BottomToolbar.jsx';
4 | import Button from './components/Button.jsx';
5 | import Carousel from './components/Carousel.jsx';
6 | import CarouselItem from './components/CarouselItem.jsx';
7 | import Col from './components/Col.jsx';
8 | import Dialog from './components/Dialog.jsx';
9 | import Fab from './components/Fab.jsx';
10 | import Icon from './components/Icon.jsx';
11 | import Input from './components/Input.jsx';
12 | import LazyList from './components/LazyList.jsx';
13 | import List from './components/List.jsx';
14 | import ListHeader from './components/ListHeader.jsx';
15 | import ListItem from './components/ListItem.jsx';
16 | import Navigator from './components/Navigator.jsx';
17 | import Modal from './components/Modal.jsx';
18 | import Page from './components/Page.jsx';
19 | import Popover from './components/Popover.jsx';
20 | import ProgressBar from './components/ProgressBar.jsx';
21 | import ProgressCircular from './components/ProgressCircular.jsx';
22 | import PullHook from './components/PullHook.jsx';
23 | import Range from './components/Range.jsx';
24 | import Ripple from './components/Ripple.jsx';
25 | import Row from './components/Row.jsx';
26 | import SpeedDial from './components/SpeedDial.jsx';
27 | import SpeedDialItem from './components/SpeedDialItem.jsx';
28 | import Splitter from './components/Splitter.jsx';
29 | import SplitterContent from './components/SplitterContent.jsx';
30 | import SplitterSide from './components/SplitterSide.jsx';
31 | import Switch from './components/Switch.jsx';
32 | import Tab from './components/Tab.jsx';
33 | import TabActive from './components/TabActive.jsx';
34 | import TabInactive from './components/TabInactive.jsx';
35 | import Tabbar from './components/Tabbar.jsx';
36 | import Toolbar from './components/Toolbar.jsx';
37 | import ToolbarButton from './components/ToolbarButton.jsx';
38 |
39 | export {
40 | AlertDialog,
41 | BackButton,
42 | BottomToolbar,
43 | Button,
44 | Carousel,
45 | CarouselItem,
46 | Col,
47 | Dialog,
48 | Fab,
49 | Icon,
50 | Input,
51 | LazyList,
52 | List,
53 | ListHeader,
54 | ListItem,
55 | Navigator,
56 | Modal,
57 | Page,
58 | Popover,
59 | ProgressBar,
60 | ProgressCircular,
61 | PullHook,
62 | Range,
63 | Ripple,
64 | Row,
65 | SpeedDial,
66 | SpeedDialItem,
67 | Splitter,
68 | SplitterContent,
69 | SplitterSide,
70 | Switch,
71 | Tab,
72 | TabActive,
73 | TabInactive,
74 | Tabbar,
75 | Toolbar,
76 | ToolbarButton
77 | };
78 |
--------------------------------------------------------------------------------
/docs/Input.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-input\n@category form\n@tutorial react/Reference/input\n@description\n[en]\nAn input element. The `type` attribute can be used to change the input type. All text input types as well as `checkbox` and `radio` are supported. The component will automatically render as a Material Design input on Android devices. Most attributes that can be used for a normal ` ` element can also be used on the `` element..\n [/en]\n[jp][/jp]\n@example\n { this.setState({text: event.target.value})} }\n modifier='material'\n placeholder='Username' />","methods":[],"props":{"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the input.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en]\n Specifies whether the input is disabled.\n [/en]\n [jp] [/jp]"},"onChange":{"type":{"name":"func"},"required":false,"description":"@name onChange\n@type function\n@description\n [en] Called when the text of the input changes.[/en]\n [jp][/jp]"},"value":{"type":{"name":"string"},"required":false,"description":"@name value\n@type string\n@description\n [en] Content of the input.[/en]\n [jp][/jp]"},"checked":{"type":{"name":"bool"},"required":false,"description":"@name checked\n@type boolean\n@description\n [en]Set to to true if the input is checked. Only used for radio buttons and checkboxes.[/en]\n [ja][/ja]"},"placeholder":{"type":{"name":"string"},"required":false,"description":"@name placehoder\n@type string\n@description\n [en] Placeholder text. In Material Design this placeholder will be a floating label. [/en]\n [jp][/jp]"},"type":{"type":{"name":"string"},"required":false,"description":"@name type\n@type string\n@description\n [en] Specify the input type. This is the same as the \"type\" attribute for normal inputs.\n Please take a look at [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type) for an exhaustive list of possible values. Depending on the platform and browser version some of these might not work.\n [/en]\n [jp][/jp]"},"inputId":{"type":{"name":"string"},"required":false,"description":"@name inputId\n@type string\n@description\n [en] Specify the \"id\" attribute of the inner ` ` element. This is useful when using elements [/en]\n [jp][/jp]"},"float":{"type":{"name":"bool"},"required":false,"description":"@name float\n@type bool\n@description\n [en] If this attribute is present, the placeholder will be animated in Material Design. [/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Fab.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-fab
6 | * @category form
7 | * @tutorial react/Reference/fab
8 | * @description
9 | * [en] The Floating action button is a circular button defined in the [Material Design specification](https://www.google.com/design/spec/components/buttons-floating-action-button.html). They are often used to promote the primary action of the app.
10 | * It can be displayed either as an inline element or in one of the corners. Normally it will be positioned in the lower right corner of the screen.
11 | [/en]
12 | * [jp][/jp]
13 | * @example
14 | * console.log('test1')} position='left bottom'>
15 |
16 |
17 |
18 | console.log('speed A')}> A
19 | console.log('speed B')}> B
20 | console.log('speed C')}> C
21 | console.log('speed D')}> D
22 |
23 | */
24 | class Fab extends SimpleWrapper {
25 | _getDomNodeName() {
26 | return 'ons-fab';
27 | }
28 | };
29 |
30 | Fab.propTypes = {
31 | /**
32 | * @name modifier
33 | * @type string
34 | * @required false
35 | * @description
36 | * [en]The appearance of the button.[/en]
37 | * [jp] [/jp]
38 | */
39 | modifier: React.PropTypes.string,
40 |
41 | /**
42 | * @name ripple
43 | * @type bool
44 | * @description
45 | * [en]If true, the button will have a ripple effect when tapped.[/en]
46 | * [jp] [/jp]
47 | */
48 | ripple: React.PropTypes.bool,
49 |
50 | /**
51 | * @name position
52 | * @type string
53 | * @required false
54 | * @description
55 | * [en]The position of the button. Should be a string like `"bottom right"` or `"top left"`. If this attribute is not defined it will be displayed as an inline element.[/en]
56 | * [jp] [/jp]
57 | */
58 | position: React.PropTypes.string,
59 |
60 | /**
61 | * @name disabled
62 | * @type bool
63 | * @description
64 | * [en] If true, the button will be disabled. [/en]
65 | * [jp] [/jp]
66 | */
67 | disabled: React.PropTypes.bool,
68 |
69 | /**
70 | * @name onClick
71 | * @type function
72 | * @description
73 | * [en] This function will be called ones the button is clicked. [/en]
74 | * [jp] [/jp]
75 | */
76 | onClick: React.PropTypes.func
77 | };
78 |
79 | export default Fab;
80 |
--------------------------------------------------------------------------------
/src/components/ListItem.jsx:
--------------------------------------------------------------------------------
1 | import ReactDOM from 'react-dom';
2 | import React from 'react';
3 | import SimpleWrapper from './SimpleWrapper.jsx';
4 | import Util from './Util.js';
5 |
6 | /**
7 | * @original ons-list-item
8 | * @category list
9 | * @tutorial react/Reference/list
10 | * @description
11 | * [en]
12 | * Component that represents each item in the list. Must be put inside the `List` component. The list item is composed of three parts that are represented with the `left`, `center` and `right` classes. These classes can be used to ensure that the content of the list items is properly aligned.
13 | * [/en]
14 | * [jp][/jp]
15 | * @example
16 |
17 | * Left
18 | * Center
19 | * Right
20 | *
21 | */
22 | class ListItem extends SimpleWrapper {
23 | _getDomNodeName() {
24 | return 'ons-list-item';
25 | }
26 |
27 | componentDidMount() {
28 | super.componentDidMount();
29 | this.node = ReactDOM.findDOMNode(this);
30 | }
31 |
32 | componentDidUpdate() {
33 | super.componentDidUpdate();
34 | this.node._compile();
35 | }
36 |
37 | render() {
38 | var {...others} = this.props;
39 |
40 | Util.convert(others, 'tappable');
41 | Util.convert(others, 'tapBackgroundColor', {newName: 'tap-background-color'});
42 | Util.convert(others, 'lockOnDrag', {newName: 'lock-on-drag'});
43 |
44 | return React.createElement(this._getDomNodeName(), others, this.props.children);
45 | }
46 | };
47 |
48 | ListItem.propTypes = {
49 | /**
50 | * @name modifier
51 | * @type string
52 | * @required false
53 | * @description
54 | * [en] The appearance of the list item.[/en]
55 | * [jp] [/jp]
56 | */
57 | modifier: React.PropTypes.string,
58 |
59 | /**
60 | * @name tappable
61 | * @type bool
62 | * @description
63 | * [en]
64 | * Specifies whether the list item is tappable.
65 | * [/en]
66 | * [jp] [/jp]
67 | */
68 | tappable: React.PropTypes.bool,
69 |
70 | /**
71 | * @name tapBackgroundColor
72 | * @type string
73 | * @description
74 | * [en]
75 | * Changes the background color when tapped. For this to work, the attribute "tappable" needs to be set. The default color is "#d9d9d9". It will display as a ripple effect on Android.
76 | * [/en]
77 | * [jp] [/jp]
78 | */
79 | tapBackgroundColor: React.PropTypes.string,
80 |
81 | /**
82 | * @name lockOnDrag
83 | * @type bool
84 | * @description
85 | * [en] Prevent vertical scrolling when the user drags horizontally. [/en]
86 | * [jp] [/jp]
87 | */
88 | lockOnDrag: React.PropTypes.bool
89 | };
90 |
91 | export default ListItem;
92 |
--------------------------------------------------------------------------------
/docs/Page.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-page\n@category page\n@tutorial react/Reference/page\n@description\n[en]\n This component is handling the entire page. The content can be scrolled.\n\n To add fixed content that doesn't scroll with the page the `renderFixed` prop is used.\n\n A page toolbar can be added with the `renderToolbar` prop.\n[/en]\n[jp] どうしよう[/jp]\n@example\n }\n renderToolbar={() => ... }\n contentStyle={{padding: 40}}>\n Page content
\n ","methods":[],"props":{"contentStyle":{"type":{"name":"object"},"required":false,"description":"@name contentStyle\n@type Object\n@description\n [en]\n Specify the style of the page content. Optional.\n [/en]"},"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@description\n [en]\n Specify modifier name to specify custom styles. Optional.\n [/en]\n [jp] どうしよう[/jp]"},"renderModal":{"type":{"name":"func"},"required":false,"description":"@name renderModal\n@type function\n@required false\n@defaultValue null\n@description\n [en] This function renders a modal that masks current screen.[/en]","defaultValue":{"value":"() => null","computed":false}},"renderToolbar":{"type":{"name":"func"},"required":false,"description":"@name renderToolbar\n@type function\n@required false\n@defaultValue null\n@description\n [en] This function renders the toolbar of the page.[/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}},"renderBottomToolbar":{"type":{"name":"func"},"required":false,"description":"@name renderBottomToolbar\n@type function\n@defaultValue null\n@description\n [en] This function renders the bottom toolbar of the page.[/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}},"renderFixed":{"type":{"name":"func"},"required":false,"description":"@name renderFixed\n@type function\n@defaultValue null\n@description\n [en] This function renders fixed content of the page. Can be used to render `Fab` or `SpeedDial` components as well as other components that don't scroll with the page.[/en]\n [jp] どうしよう[/jp]","defaultValue":{"value":"() => null","computed":false}},"onInit":{"type":{"name":"func"},"required":false,"description":"@name onInit\n@type function\n@required false\n@description\n [en]\n \tFired right after the page is attached.\n [/en]\n [jp] どうしよう[/jp]"},"onShow":{"type":{"name":"func"},"required":false,"description":"@name onShow\n@type function\n@required false\n@description\n [en]\n Called Fired right after the page is shown.\n [/en]\n [jp] どうしよう[/jp]"},"onHide":{"type":{"name":"func"},"required":false,"description":"@name onHide\n@type function\n@required false\n@description\n [en]\n Called after the page is hidden.\n [/en]\n [jp] どうしよう[/jp]"}}}
2 |
--------------------------------------------------------------------------------
/docs/Tabbar.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-tabbar\n@category tabbar\n@tutorial react/Reference/tabbar\n@description\n[en] Component to display a tabbar on either the top or the bottom of a page.\nTo define the tabs and the content the property renderTabs need to be implemented, that returns an array of tabs and their content. See the example for specifics. [/en]* [jp][/jp]\n@example\n\n \n this.setState(index)}\n onPostChange={() => console.log('postChange')}\n onReactive={() => console.log('postChange')}\n position='bottom'\n index={this.state.index}\n renderTabs={(activeIndex, tabbar) => [\n {\n content: ,\n tab: \n },\n {\n content: ,\n tab: \n }]\n }\n />\n ","methods":[],"props":{"index":{"type":{"name":"number"},"required":true,"description":"@name index\n@type number\n@required\n@description\n [en] The index of the tab to highlight.[/en]\n [jp] [/jp]","defaultValue":{"value":"0","computed":false}},"renderTabs":{"type":{"name":"func"},"required":true,"description":"@name renderTabs\n@type function\n@description\n [en] The index of the first tab to show.[/en]\n [jp] [/jp]"},"position":{"type":{"name":"string"},"required":false,"description":"@name position\n@type string\n@description\n [en] Tabbar's position. Available values are `\"bottom\"` and `\"top\"`. Use `\"auto\"` to choose position depending on platform (iOS bottom, Android top). [/en]\n [jp] [/jp]"},"animation":{"type":{"name":"enum","value":[{"value":"'none'","computed":false},{"value":"'slide'","computed":false},{"value":"'fade'","computed":false}]},"required":false,"description":"@name animation\n@type string\n@description\n [en] Animation name. Available values are `\"none\"`, `\"slide\"` and `\"fade\"`. Default is `\"none\"`. [/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"},"onPreChange":{"type":{"name":"func"},"required":false,"description":"@name onPreChange\n@type function\n@description\n [en]Called just before the tab is changed.[/en]\n [jp] [/jp]"},"onPostChange":{"type":{"name":"func"},"required":false,"description":"@name onPostChange\n@type function\n@description\n [en]Called just after the tab is changed.[/en]\n [jp] [/jp]"},"onReactive":{"type":{"name":"func"},"required":false,"description":"@name onReactive\n@type function\n@description\n [en]Called if the already open tab is tapped again.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-onsenui",
3 | "version": "1.0.3",
4 | "description": "Onsen UI - React Components for Hybrid Cordova/PhoneGap Apps with Material Design and iOS UI components",
5 | "main": "dist/react-onsenui.js",
6 | "scripts": {
7 | "build": "npm run lint && rollup -c",
8 | "prepublish": "npm run build",
9 | "commit-dist": "git commit -m 'Update generated files.' dist docs && git push origin master",
10 | "postpublish": "npm run gen-docs && npm run commit-dist && npm run release-github",
11 | "release-github": "node githubRelease.js",
12 | "lint": "eslint --ext .js,.jsx src",
13 | "lint-fix": "eslint --ext .js,.jsx src --fix",
14 | "dev": "webpack-dev-server --progress --host 0.0.0.0",
15 | "test": "karma start",
16 | "gen-docs": "node ./docgen.js"
17 | },
18 | "repository": {
19 | "type": "git",
20 | "url": "git+https://github.com/OnsenUI/react-onsenui.git"
21 | },
22 | "keywords": [
23 | "react",
24 | "react-component",
25 | "phonegap",
26 | "cordova",
27 | "hybrid",
28 | "app",
29 | "mobile",
30 | "ui",
31 | "onsen",
32 | "onsenui"
33 | ],
34 | "author": "Onsen UI Team ",
35 | "license": "Apache-2.0",
36 | "bugs": {
37 | "url": "https://github.com/OnsenUI/react-onsenui/issues"
38 | },
39 | "homepage": "https://onsen.io/v2/",
40 | "devDependencies": {
41 | "babel-core": "^6.17.0",
42 | "babel-loader": "^6.2.5",
43 | "babel-preset-es2015": "^6.16.0",
44 | "babel-preset-es2015-rollup": "^1.2.0",
45 | "babel-preset-react": "^6.16.0",
46 | "babel-preset-stage-2": "^6.17.0",
47 | "chai": "^3.5.0",
48 | "colors": "^1.1.2",
49 | "css-loader": "^0.25.0",
50 | "eslint": "^3.7.1",
51 | "eslint-plugin-promise": "^3.0.0",
52 | "eslint-plugin-react": "^6.4.1",
53 | "eslint-plugin-standard": "^2.0.1",
54 | "file-loader": "^0.9.0",
55 | "filter-files": "^0.4.0",
56 | "github": "^3.1.1",
57 | "karma": "^1.3.0",
58 | "karma-chai": "^0.1.0",
59 | "karma-chrome-launcher": "^2.0.0",
60 | "karma-mocha": "^1.2.0",
61 | "karma-sourcemap-loader": "^0.3.7",
62 | "karma-webpack": "^1.8.0",
63 | "mocha": "^3.1.2",
64 | "onsenui": "^2.0.3",
65 | "prompt": "^1.0.0",
66 | "react": "^15.3.2",
67 | "react-docgen": "^2.11.0",
68 | "react-dom": "^15.3.2",
69 | "react-hot-loader": "^1.3.0",
70 | "rollup": "^0.36.3",
71 | "rollup-plugin-babel": "^2.6.1",
72 | "rollup-plugin-commonjs": "^5.0.4",
73 | "rollup-plugin-node-resolve": "^2.0.0",
74 | "rollup-plugin-replace": "^1.1.1",
75 | "style-loader": "^0.13.1",
76 | "url-loader": "^0.5.7",
77 | "webpack": "^1.13.2",
78 | "webpack-dev-server": "^1.16.2"
79 | },
80 | "peerDependencies": {
81 | "react": "^15.3.2",
82 | "react-dom": "^15.3.2",
83 | "onsenui": "^2.0.3"
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/components/List.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import BasicComponent from './BasicComponent.jsx';
3 |
4 | /**
5 | * @original ons-list
6 | * @category list
7 | * @tutorial react/Reference/list
8 | * @description
9 | * [en]
10 | * Component for representing a list. It takes an array called datasource and calls renderRow(row, index) for every row. Furthermore, the header and the footer can be specified with `renderRow` and `renderHeader` respectivly. [/en]
11 | * [jp][/jp]
12 | * @example
13 | (
17 |
18 | {row}
19 | Remove
20 |
21 | )}
22 | renderFooter={this.renderFooter}
23 | />
24 | */
25 | class List extends BasicComponent {
26 | render() {
27 | var pages = this.props.dataSource.map((data, idx) => this.props.renderRow(data, idx));
28 |
29 | return (
30 |
31 | {this.props.renderHeader()}
32 | {pages}
33 | {this.props.children}
34 | {this.props.renderFooter()}
35 |
36 | );
37 | }
38 | }
39 |
40 | List.propTypes = {
41 | /**
42 | * @name modifier
43 | * @type string
44 | * @description
45 | * [en]
46 | * Specify modifier name to specify custom styles.
47 | * [/en]
48 | * [jp] どうしよう[/jp]
49 | */
50 | modifier: React.PropTypes.string,
51 |
52 | /**
53 | * @name dataSource
54 | * @type string
55 | * @description
56 | * [en]
57 | * Source of the list data. Should be an array.
58 | * [/en]
59 | * [jp] どうしよう[/jp]
60 | */
61 | dataSource: React.PropTypes.array,
62 |
63 | /**
64 | * @name renderRow
65 | * @type function
66 | * @description
67 | * [en]
68 | * Function to specify the rendering function for every element in
69 | * in the dataSource.
70 | * [/en]
71 | * [jp] どうしよう[/jp]
72 | */
73 | renderRow: React.PropTypes.func,
74 |
75 | /**
76 | * @name renderHeader
77 | * @type function
78 | * @description
79 | * [en]
80 | * Function to specify the rendering function for the header
81 | * [/en]
82 | * [jp] どうしよう[/jp]
83 | */
84 | renderHeader: React.PropTypes.func,
85 |
86 | /**
87 | * @name renderFooter
88 | * @type function
89 | * @description
90 | * [en]
91 | * Function to specify the rendering function for the footer
92 | * [/en]
93 | * [jp] どうしよう[/jp]
94 | */
95 | renderFooter: React.PropTypes.func
96 | };
97 |
98 | List.defaultProps = {
99 | dataSource: [],
100 | renderRow: () => null,
101 | renderHeader: () => null,
102 | renderFooter: () => null
103 | };
104 |
105 | export default List;
106 |
--------------------------------------------------------------------------------
/demo/examples/Input.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Page,
5 | Toolbar,
6 | ToolbarButton,
7 | BackButton,
8 | Input
9 | } from '../../src/index.js';
10 |
11 | import MyToolbar from './MyToolbar';
12 |
13 | export default class extends React.Component {
14 | constructor(props) {
15 | super(props);
16 |
17 | this.state = {
18 | text: 'text',
19 | selected: [1],
20 | selected2: 1
21 | };
22 | }
23 |
24 | handleCheckbox(idx, event) {
25 | const selected = this.state.selected;
26 |
27 | if (event.target.checked && selected.indexOf(idx) < 0) {
28 | selected.push(idx);
29 | }
30 | else if(!event.target.checked) {
31 | selected.splice(selected.indexOf(idx), 1);
32 | }
33 |
34 | this.setState({selected: selected});
35 | }
36 |
37 | handleRadio(idx, event) {
38 | if (event.target.checked) {
39 | this.setState({selected2: idx});
40 | }
41 | }
42 |
43 | render() {
44 | return (
45 |
47 | Back
48 | Input
49 |
50 | }
51 | >
52 |
53 | Please enter a text
54 |
55 | {
56 | this.setState({text: event.target.value})} } modifier='material' placeholder='Username'>
57 |
58 | {
59 | this.setState({text: event.target.value});
60 | }} />
61 | Text : {this.state.text}
62 |
63 | Checkboxes
64 |
65 | {
66 | [0, 1, 2].map((idx) => (
67 |
68 | = 0}
72 | />
73 |
74 | = 0}
78 | />
79 |
80 | ))
81 | }
82 | Selected: [{this.state.selected.join(', ')}]
83 |
84 | Radio buttons
85 |
86 | {
87 | [0, 1, 2].map((idx) => (
88 |
89 |
94 |
95 |
100 |
101 | ))
102 | }
103 |
104 | Selected: {this.state.selected2}
105 |
106 | );
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/docs/Dialog.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-dialog\n@category dialog\n@tutorial react/Reference/dialog\n@description\n[en] Dialog that is displayed on top of current screen. As opposed to the AlertDialog element, this component can contain any kind of content. The dialog is useful for displaying menus, additional information or to ask the user to make a decision. It will automatically be displayed as Material Design when running on an Android device.\n [/en]\n[jp][/jp]\n@example\n \n \n Page Content\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"onCancel":{"type":{"name":"func"},"required":false,"description":"@name onCancel\n@type function\n@required false\n@description\n [en]\n Called only if isCancelable is true. It will be called after tapping the background or by pressing the back button on Android devices.\n [/en]\n [jp] どうしよう[/jp]"},"isOpen":{"type":{"name":"bool"},"required":true,"description":"@name isOpen\n@type bool\n@required true\n@description\n [en]\n Indicates whether the dialog is open and shown.\n [/en]\n [jp] [/jp]"},"isCancelable":{"type":{"name":"bool"},"required":false,"description":"@name isCancelable\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is cancelable or not.\n A cancelable dialog will call onCancel when tapping the background or or pressing the back button on Android devices\n [/en]\n [jp] [/jp]"},"isDisabled":{"type":{"name":"bool"},"required":false,"description":"@name isDisabled\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is disabled.\n [/en]\n [jp] [/jp]"},"animation":{"type":{"name":"string"},"required":false,"description":"@name animation\n@type string\n@required false\n@description\n [en]\n The animation used when showing and hiding the dialog. Can be either `\"none\"` or `\"default\"`.\n [/en]\n [jp] [/jp]"},"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the dialog.[/en]\n [jp] [/jp]"},"maskColor":{"type":{"name":"string"},"required":false,"description":"@name maskColor\n@type string\n@required false\n@description\n [en]Color of the background mask. Default is \"rgba(0, 0, 0, 0.2)\"[/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"},"onPreShow":{"type":{"name":"func"},"required":false,"description":"@name onPreShow\n@type function\n@required false\n@description\n [en]\n Called just before the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPostShow":{"type":{"name":"func"},"required":false,"description":"@name onPostShow\n@type function\n@required false\n@description\n [en]\n Called just after the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPreHide":{"type":{"name":"func"},"required":false,"description":"@name onPreHide\n@type function\n@required false\n@description\n [en]Called just before the alert dialog is hidden.[/en]\n [jp][/jp]"},"onPostHide":{"type":{"name":"func"},"required":false,"description":"@name onPostHide\n@type function\n@required false\n@description\n [en]Called just after the alert dialog is hidden.[/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Modal.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import BasicComponent from './BasicComponent.jsx';
4 |
5 | /**
6 | * @original ons-modal
7 | * @category dialog
8 | * @tutorial react/Reference/modal
9 | * @description
10 | * [en]
11 | * A modal component covers the entire screen. Underlying components are not
12 | * subject to any events while the modal component is shown.
13 | *
14 | * This component can be used to block user input while some operation is
15 | * running or to show some information to the user.
16 | * [/en]
17 | * [jp]
18 | * 画面全体をマスクするモーダル用コンポーネントです。下側にあるコンポーネントは、
19 | * モーダルが表示されている間はイベント通知が行われません
20 | * [/jp]
21 | * @example
22 | (
24 |
25 | Loading ...
26 |
27 | )}>
28 | Page content
29 |
30 | */
31 | class Modal extends BasicComponent {
32 | constructor(...args) {
33 | super(...args);
34 | this.node = null;
35 | }
36 |
37 | componentDidMount() {
38 | super.componentDidMount();
39 | this.node = ReactDOM.findDOMNode(this);
40 |
41 | this._update(this.props, false);
42 | }
43 |
44 | componentWillReceiveProps(nextProps) {
45 | this._update(nextProps, this.props.isOpen);
46 | }
47 |
48 | _update(props, isOpen) {
49 | const animationOptions = {
50 | animation: props.animation,
51 | animationOptions: props.animationOptions
52 | };
53 |
54 | if (props.isOpen && !isOpen) {
55 | this.node.show(animationOptions).then(() => props.onShow && props.onShow());
56 | } else if (!props.isOpen && isOpen) {
57 | this.node.hide(animationOptions).then(() => props.onHide && props.onHide());
58 | }
59 | }
60 |
61 | componentWillUnmount() {
62 | this.node = null;
63 | }
64 |
65 | render() {
66 | const {...others} = this.props;
67 | return (
68 |
71 | {this.props.children}
72 |
73 | );
74 | }
75 | };
76 |
77 | Modal.propTypes = {
78 | /**
79 | * @name animation
80 | * @type {String}
81 | * @description
82 | * [en]
83 | * Animation name. Available animations are `"fade"` and `"none"`.
84 | * [/en]
85 | */
86 | animation: React.PropTypes.oneOf(['none', 'fade']),
87 |
88 | /**
89 | * @name animationOptions
90 | * @type object
91 | * @description
92 | * [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
93 | */
94 | animationOptions: React.PropTypes.object,
95 |
96 | /**
97 | * @name onShow
98 | * @type function
99 | * @required false
100 | * @description
101 | * [en]
102 | * Called Fired right after the modal is shown.
103 | * [/en]
104 | */
105 | onShow: React.PropTypes.func,
106 |
107 | /**
108 | * @name onHide
109 | * @type function
110 | * @required false
111 | * @description
112 | * [en]
113 | * Called after the modal is hidden.
114 | * [/en]
115 | */
116 | onHide: React.PropTypes.func,
117 |
118 | /**
119 | * @name isOpen
120 | * @type boolean
121 | * @description
122 | * [en]When `true` the modal will show itself.[/en]
123 | */
124 | isOpen: React.PropTypes.bool
125 | };
126 |
127 | Modal.defaultProps = {
128 | isOpen: false,
129 | animation: 'none'
130 | };
131 |
132 | export default Modal;
133 |
--------------------------------------------------------------------------------
/src/components/BaseDialog.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import Util from './Util.js';
4 |
5 | class BaseDialog extends React.Component {
6 | show() {
7 | this.node.firstChild.show();
8 | }
9 |
10 | updateClasses() {
11 | var node = this.node.firstChild;
12 |
13 | if (this.props.className) {
14 | if (this.lastClass) {
15 | node.className = node.className.replace(this.lastClass, '');
16 | }
17 |
18 | this.lastClass = ' ' + this.props.className;
19 | node.className += this.lastClass;
20 | }
21 | }
22 |
23 | hide() {
24 | this.node.firstChild.hide();
25 | }
26 |
27 | componentDidMount() {
28 | this.node = document.createElement('div');
29 | document.body.appendChild(this.node);
30 |
31 | this.node.addEventListener('dialog-cancel', this.props.onCancel);
32 | this.node.addEventListener('preshow', this.props.onPreShow);
33 | this.node.addEventListener('postshow', this.props.onPostShow);
34 | this.node.addEventListener('prehide', this.props.onPreHide);
35 | this.node.addEventListener('posthide', this.props.onPostHide);
36 |
37 | this.renderPortal(this.props, false);
38 | }
39 |
40 | componentWillReceiveProps(newProps) {
41 | this.renderPortal(newProps, this.props.isOpen);
42 | }
43 |
44 | componentWillUnmount() {
45 | this.node.removeEventListener('cancel', this.props.onCancel);
46 | this.node.removeEventListener('preshow', this.props.onPreShow);
47 | this.node.removeEventListener('postshow', this.props.onPostShow);
48 | this.node.removeEventListener('prehide', this.props.onPreHide);
49 | this.node.removeEventListener('posthide', this.props.onPostHide);
50 |
51 | ReactDOM.unmountComponentAtNode(this.node);
52 | document.body.removeChild(this.node);
53 | }
54 |
55 | _update(isShown) {
56 | if (this.props.isOpen) {
57 | if (!isShown) {
58 | this.show();
59 | }
60 | } else {
61 | this.hide();
62 | }
63 | this.updateClasses();
64 | }
65 |
66 | _getDomNodeName() {
67 | throw new Error('_getDomNodeName is not implemented');
68 | }
69 |
70 | renderPortal(props, isShown) {
71 | var {...newProps} = props;
72 |
73 | Util.convert(newProps, 'isCancelable', {newName: 'cancelable'});
74 | Util.convert(newProps, 'isDisabled', {newName: 'disabled'});
75 | Util.convert(newProps, 'maskColor', {newName: 'mask-color'});
76 | Util.convert(newProps, 'animationOptions', {fun: Util.animationOptionsConverter, newName: 'animation-options'});
77 |
78 | var element = React.createElement(this._getDomNodeName(), newProps);
79 | ReactDOM.render(element, this.node, this._update.bind(this, isShown));
80 | }
81 |
82 | shouldComponentUpdate() {
83 | return false;
84 | }
85 |
86 | render() {
87 | return React.DOM.noscript();
88 | }
89 | }
90 |
91 | BaseDialog.propTypes = {
92 | onCancel: React.PropTypes.func,
93 | isOpen: React.PropTypes.bool.isRequired,
94 | isCancelable: React.PropTypes.bool,
95 | isDisabled: React.PropTypes.bool,
96 | animation: React.PropTypes.string,
97 | maskColor: React.PropTypes.string,
98 | animationOptions: React.PropTypes.object,
99 | onPreShow: React.PropTypes.func,
100 | onPostShow: React.PropTypes.func,
101 | onPreHide: React.PropTypes.func,
102 | onPostHide: React.PropTypes.func
103 | };
104 |
105 | BaseDialog.defaultProps = {
106 | isCancelable: true,
107 | isDisabled: false
108 | };
109 |
110 | export default BaseDialog;
111 |
--------------------------------------------------------------------------------
/demo/examples/Splitter.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import {
4 | Splitter,
5 | SplitterSide,
6 | SplitterContent,
7 | Page,
8 | Toolbar,
9 | Button
10 | } from '../../src/index.js';
11 |
12 | import MyToolbar from './MyToolbar';
13 |
14 | export default class extends React.Component {
15 | constructor(props) {
16 | super(props);
17 | this.state = {
18 | showLeft: false,
19 | showRight: false,
20 | openLeft: false,
21 | openRight: false,
22 | isSwipeable: true
23 | };
24 | }
25 |
26 | handleLeftClose() {
27 | this.setState({
28 | openLeft: false
29 | });
30 | }
31 |
32 | handleLeftOpen() {
33 | this.setState({
34 | openLeft: true
35 | });
36 | }
37 |
38 | handleRightClose() {
39 | this.setState({
40 | openRight: false
41 | });
42 | }
43 |
44 | handleRightOpen() {
45 | this.setState({
46 | openRight: true,
47 | });
48 | }
49 |
50 | render() {
51 | return (
52 | } >
53 |
54 |
62 |
63 |
64 | content
65 |
66 |
67 |
68 |
69 |
70 | }>
71 |
72 | this.setState({isSwipeable: !this.state.isSwipeable})}
74 | >
75 | {this.state.isSwipeable ? 'Disable Swipe' : 'Enable Swipeable'}
76 |
77 |
78 |
79 | this.setState({showLeft: !this.state.showLeft})}
81 | >toggle left menu 2
82 |
83 |
84 | this.setState({showRight: !this.state.showRight })} > toggle right menu
86 |
87 |
88 | this.setState({openLeft: true})}>
90 | Open left menu
91 |
92 |
93 |
94 |
95 | this.setState({openRight: true})}>
97 | Open right menu
98 |
99 |
100 |
101 |
102 |
103 |
111 |
112 |
113 | ons-splitter-side
114 |
115 |
116 |
117 |
118 |
119 | );
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/docs/AlertDialog.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-alert-dialog\n@category dialog\n@tutorial react/Reference/dialog\n@description\n[en]\n Alert dialog that is displayed on top of the current screen. Useful for displaying questions, warnings or error messages to the user. The title, content and buttons can be easily customized and it will automatically switch style based on the platform.\n[/en]\n[jp][/jp]\n@example\n \n Warning!
\n \n An error has occurred!\n
\n \n \n Cancel\n \n \n Ok\n \n
\n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"onCancel":{"type":{"name":"func"},"required":false,"description":"@name onCancel\n@type function\n@required false\n@description\n [en]\n Called only if isCancelable is true. It will be called after tapping the background or by pressing the back button on Android devices.\n [/en]\n [jp] どうしよう[/jp]"},"isOpen":{"type":{"name":"bool"},"required":true,"description":"@name isOpen\n@type bool\n@required true\n@description\n [en]\n Indicates whether the dialog is open and shown.\n [/en]\n [jp] [/jp]"},"isCancelable":{"type":{"name":"bool"},"required":false,"description":"@name isCancelable\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is cancelable or not.\n A cancelable dialog will call onCancel when tapping the background or or pressing the back button on Android devices\n [/en]\n [jp] [/jp]"},"isDisabled":{"type":{"name":"bool"},"required":false,"description":"@name isDisabled\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is disabled.\n [/en]\n [jp] [/jp]"},"animation":{"type":{"name":"string"},"required":false,"description":"@name animation\n@type string\n@required false\n@description\n [en]\n The animation used when showing and hiding the dialog. Can be either `\"none\"` or `\"default\"`.\n [/en]\n [jp] [/jp]"},"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the dialog.[/en]\n [jp] [/jp]"},"maskColor":{"type":{"name":"string"},"required":false,"description":"@name maskColor\n@type string\n@required false\n@description\n [en]Color of the background mask. Default is \"rgba(0, 0, 0, 0.2)\"[/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"},"onPreShow":{"type":{"name":"func"},"required":false,"description":"@name onPreShow\n@type function\n@required false\n@description\n [en]\n Called just before the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPostShow":{"type":{"name":"func"},"required":false,"description":"@name onPostShow\n@type function\n@required false\n@description\n [en]\n Called just after the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPreHide":{"type":{"name":"func"},"required":false,"description":"@name onPreHide\n@type function\n@required false\n@description\n [en]Called just before the alert dialog is hidden.[/en]\n [jp][/jp]"},"onPostHide":{"type":{"name":"func"},"required":false,"description":"@name onPostHide\n@type function\n@required false\n@description\n [en]Called just after the alert dialog is hidden.[/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/PullHook.jsx:
--------------------------------------------------------------------------------
1 | import ReactDOM from 'react-dom';
2 | import BasicComponent from './BasicComponent.jsx';
3 | import React from 'react';
4 | import Util from './Util.js';
5 |
6 | /**
7 | * @original ons-pull-hook
8 | * @category control
9 | * @tutorial react/Reference/pull-hook
10 | * @description
11 | * [en] Component that adds **Pull to refresh** functionality to an `` element.
12 | * It can be used to perform a task when the user pulls down at the top of the page. A common usage is to refresh the data displayed in a page.
13 | [/en]
14 | * [jp] どうしよう[/jp]
15 | * @example
16 |
17 | return (
18 |
19 | {
20 | (this.state.pullHookState === 'initial') ?
21 |
22 |
23 | Pull down to refresh
24 | :
25 | (this.state.pullHookState === 'preaction') ?
26 |
27 |
28 | Release to refresh
29 |
30 | :
31 | Loading data...
32 | }
33 |
34 | );
35 | */
36 | class PullHook extends BasicComponent {
37 | componentDidMount() {
38 | super.componentDidMount();
39 | var node = ReactDOM.findDOMNode(this);
40 | node.addEventListener('changestate', this.props.onChange);
41 | this.refs.pullHook.onAction = this.props.onLoad;
42 | }
43 |
44 | componentWillUnmount() {
45 | var node = ReactDOM.findDOMNode(this);
46 | node.removeEventListener('changestate', this.props.onChange);
47 | }
48 |
49 | render() {
50 | var {...others} = this.props;
51 |
52 | ['disabled'].forEach((el) => {
53 | Util.convert(others, el);
54 | });
55 |
56 | Util.convert(others, 'height', {fun: Util.sizeConverter});
57 | Util.convert(others, 'thresholdHeight', {fun: Util.sizeConverter, newName: 'threshold-height'});
58 | Util.convert(others, 'fixedContent', {newName: 'fixed-content'});
59 |
60 | return ;
61 | }
62 | }
63 |
64 | PullHook.propTypes = {
65 | /**
66 | * @name onChange
67 | * @type function
68 | * @required false
69 | * @description
70 | * [en]Called when the pull hook inner state is changed. The state can be either "initial", "preaction" or "action"[/en]
71 | * [jp] [/jp]
72 | */
73 | onChange: React.PropTypes.func,
74 |
75 | /**
76 | * @name onLoad
77 | * @type function
78 | * @required false
79 | * @description
80 | * [en]Called when the pull hook is in the `action` state[/en]
81 | * [jp] [/jp]
82 | */
83 | onLoad: React.PropTypes.func,
84 |
85 | /**
86 | * @name disabled
87 | * @type bool
88 | * @description
89 | * [en] When set to true, the pull hook will be disabled.[/en]
90 | * [jp] [/jp]
91 | */
92 | disabled: React.PropTypes.bool,
93 |
94 | /**
95 | * @name height
96 | * @type number
97 | * @description
98 | * [en] The height of the pull hook in pixels. The default value is 64.[/en]
99 | * [jp] [/jp]
100 | */
101 | height: React.PropTypes.number,
102 |
103 | /**
104 | * @name thresholdHeight
105 | * @type number
106 | * @description
107 | * [en] The threshold height of the pull hook in pixels. The default value is 96.[/en]
108 | * [jp] [/jp]
109 | */
110 | thresholdHeight: React.PropTypes.number,
111 |
112 | /**
113 | * @name fixedContent
114 | * @type number
115 | * @description
116 | * [en] If set to true, the content of the page will not move when pulling.[/en]
117 | * [jp] [/jp]
118 | */
119 | fixedContent: React.PropTypes.bool
120 | };
121 |
122 | export default PullHook;
123 |
--------------------------------------------------------------------------------
/docs/Popover.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-popover\n@category dialog\n@tutorial react/Reference/popover\n@description\n [en]\n A component that displays a popover next to an element. The popover can be used to display extra information about a component or a tooltip.\n Another common way to use the popover is to display a menu when a button on the screen is tapped.\n [/en]\n[jp][/jp]\n@example\n\n this.setState({target: this.refs.btn, isOpen: true})}/>\n this.setState({isOpen: false})}\n getTarget={() => this.state.target} >\n \n
This is a popover!
\n
Click the background to remove the popover.
\n
\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null},{"name":"show","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"getTarget":{"type":{"name":"func"},"required":true,"description":"@name getTarget\n@type function\n@required true\n@description\n [en]\n This function should return react component or a domnode that the popover is showing on.\n [/en]\n [jp][/jp]"},"onCancel":{"type":{"name":"func"},"required":false,"description":"@name onCancel\n@type function\n@required false\n@description\n [en]\n Called only if isCancelable is true. It will be called after tapping the background or by pressing the back button on Android devices.\n [/en]\n [jp] どうしよう[/jp]"},"isOpen":{"type":{"name":"bool"},"required":true,"description":"@name isOpen\n@type bool\n@required true\n@description\n [en]\n Indicates whether the dialog is open and shown.\n [/en]\n [jp] [/jp]"},"isCancelable":{"type":{"name":"bool"},"required":false,"description":"@name isCancelable\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is cancelable or not.\n A cancelable dialog will call onCancel when tapping the background or or pressing the back button on Android devices\n [/en]\n [jp] [/jp]"},"isDisabled":{"type":{"name":"bool"},"required":false,"description":"@name isDisabled\n@type bool\n@required false\n@description\n [en]\n Specifies whether the dialog is disabled.\n [/en]\n [jp] [/jp]"},"animation":{"type":{"name":"string"},"required":false,"description":"@name animation\n@type string\n@required false\n@description\n [en]\n The animation used when showing and hiding the dialog. Can be either `\"none\"` or `\"default\"`.\n [/en]\n [jp] [/jp]"},"modifier":{"type":{"name":"string"},"required":false,"description":"@name modifier\n@type string\n@required false\n@description\n [en]The appearance of the dialog.[/en]\n [jp] [/jp]"},"maskColor":{"type":{"name":"string"},"required":false,"description":"@name maskColor\n@type string\n@required false\n@description\n [en]Color of the background mask. Default is \"rgba(0, 0, 0, 0.2)\"[/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"},"onPreShow":{"type":{"name":"func"},"required":false,"description":"@name onPreShow\n@type function\n@required false\n@description\n [en]\n Called just before the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPostShow":{"type":{"name":"func"},"required":false,"description":"@name onPostShow\n@type function\n@required false\n@description\n [en]\n Called just after the alert dialog is displayed.\n [/en]\n [jp][/jp]"},"onPreHide":{"type":{"name":"func"},"required":false,"description":"@name onPreHide\n@type function\n@required false\n@description\n [en]Called just before the alert dialog is hidden.[/en]\n [jp][/jp]"},"onPostHide":{"type":{"name":"func"},"required":false,"description":"@name onPostHide\n@type function\n@required false\n@description\n [en]Called just after the alert dialog is hidden.[/en]\n [jp][/jp]"}}}
2 |
--------------------------------------------------------------------------------
/demo/examples/Popover.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import MyToolbar from './MyToolbar';
3 |
4 | import {
5 | Page,
6 | Button,
7 | Popover
8 | } from '../../src/index.js';
9 |
10 | export default class extends React.Component {
11 |
12 | constructor(props) {
13 | super(props);
14 | this.state = {isOpen: false};
15 | this.showClick = this.showClick.bind(this);
16 | this.getTarget = this.getTarget.bind(this);
17 | this.cancel = this.cancel.bind(this);
18 | }
19 |
20 | showClick(target) {
21 | console.log('target: ' + target);
22 | this.setState({isOpen: true, target: target});
23 | }
24 |
25 | getTarget() {
26 | return this.state.target;
27 | }
28 |
29 | cancel() {
30 | console.log('cancel');
31 | this.setState({isOpen: false});
32 | }
33 |
34 | render() {
35 | return (
36 | }
38 | >
39 |
40 |
41 | this.showClick(this.refs.navigation)} className='toolbar-button--outline navigation-bar__line-height'>
42 |
43 |
44 |
45 |
46 |
47 | Popover demo!
48 |
49 |
50 |
51 | this.showClick(this.refs.topRight)} className='toolbar-button--outline navigation-bar__line-height'>Button
52 |
53 |
54 |
55 |
56 |
57 |
58 | this.showClick(this.refs.button)}>Click me!
59 |
60 |
61 |
62 | this.showClick(this.refs.stop)} className='tab-bar__item'>
63 |
64 |
65 |
66 |
67 |
68 |
69 | this.showClick(this.refs.record)} className='tab-bar__item'>
70 |
71 |
72 |
73 |
74 |
75 |
76 | this.showClick(this.refs.star)} className='tab-bar__item'>
77 |
78 |
79 |
80 |
81 |
82 |
83 | this.showClick(this.refs.cloud)} className='tab-bar__item'>
84 |
85 |
86 |
87 |
88 |
89 |
90 | this.showClick(this.refs.pie)} className='tab-bar__item'>
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
This is a popover!
100 |
Click the background to remove the popover.
101 |
102 |
103 |
104 | );
105 | }
106 | };
107 |
--------------------------------------------------------------------------------
/src/components/Icon.jsx:
--------------------------------------------------------------------------------
1 | import SimpleWrapper from './SimpleWrapper.jsx';
2 | import React from 'react';
3 | import Util from './Util.js';
4 |
5 | /**
6 | * @original ons-icon
7 | * @category visual
8 | * @tutorial react/Reference/icon
9 | * @description
10 | * [en]
11 | * Displays an icon. The following icon suites are available:
12 | * * [Font Awesome](https://fortawesome.github.io/Font-Awesome/)
13 | * * [Ionicons](http://ionicons.com/)
14 | * * [Material Design Iconic Font](http://zavoloklom.github.io/material-design-iconic-font/)
15 | * [/en]
16 | * [jp][/jp]
17 | * @example
18 |
22 | */
23 | class Icon extends SimpleWrapper {
24 | _getDomNodeName() {
25 | return 'ons-icon';
26 | }
27 |
28 | render() {
29 | var {icon, size, ...others} = this.props;
30 |
31 | Util.convert(others, 'fixedWidth', {newName: 'fixed-width'});
32 | Util.convert(others, 'spin');
33 |
34 | if (icon) {
35 | if ((typeof icon) === 'string') {
36 | others.icon = icon;
37 | } else {
38 | let keys = Object.keys(icon).filter((a) => a !== 'default');
39 | let innerString = keys.map((key) => key + ':' + icon[key] + '');
40 | others.icon = icon.default + ', ' + innerString.join(',');
41 | }
42 | }
43 |
44 | if (size) {
45 | if ((typeof size) === 'number') {
46 | others.size = `${size}px`;
47 | } else {
48 | let keys = Object.keys(size).filter((a) => a !== 'default');
49 | let innerString = keys.map((key) => key + ':' + size[key] + 'px');
50 | others.size = size.default + 'px, ' + innerString.join(',');
51 | }
52 | }
53 |
54 | return React.createElement(this._getDomNodeName(), others, this.props.children);
55 | }
56 |
57 | };
58 |
59 | Icon.propTypes = {
60 | /**
61 | * @name modifier
62 | * @type string
63 | * @required false
64 | * @description
65 | * [en]The appearance of the icon.[/en]
66 | * [jp] [/jp]
67 | */
68 | modifier: React.PropTypes.string,
69 |
70 | /**
71 | * @name icon
72 | * @type 'object or string'
73 | * @description
74 | * [en] can be either a string or an object. If it is an string, it is set to an specific icon like 'ions-navicon'. If it is an object, it represents a dictionary of the icons depending on the modifier e.g. `{{default: 'ion-navicon', material: 'md-menu'}}` [/en]
75 | * [jp] [/jp]
76 | */
77 | icon: React.PropTypes.oneOfType([
78 | React.PropTypes.string,
79 | React.PropTypes.objectOf(React.PropTypes.string)
80 | ]),
81 |
82 | /**
83 | * @name size
84 | * @type 'object or number'
85 | * @description
86 | * [en] can be either a number or an object. If it is an number, it specifies the icon size with a number in pixels. If it is an object, it represents a dictionary of the icon sizes depending on the modifier e.g. `{{default: 20, material: 18}}` [/en]
87 | * [jp] [/jp]
88 | */
89 | size: React.PropTypes.oneOfType([
90 | React.PropTypes.number,
91 | React.PropTypes.objectOf(React.PropTypes.number)
92 | ]),
93 |
94 | /**
95 | * @name rotate
96 | * @type number
97 | * @description
98 | * [en] Number of degrees to rotate the icon. Valid values are 90, 180 and 270. [/en]
99 | * [jp] [/jp]
100 | */
101 | rotate: React.PropTypes.oneOf([0, 90, 180, 270]),
102 |
103 | /**
104 | * @name fixedWidth
105 | * @type bool
106 | * @description
107 | * [en] When used in a list, you want the icons to have the same width so that they align vertically by defining this attribute. [/en]
108 | * [jp] [/jp]
109 | */
110 | fixedWidth: React.PropTypes.bool,
111 |
112 | /**
113 | * @name spin
114 | * @type bool
115 | * @description
116 | * [en] Specify whether the icon should be spinning. [/en]
117 | * [jp] [/jp]
118 | */
119 | spin: React.PropTypes.bool
120 |
121 | };
122 |
123 | export default Icon;
124 |
--------------------------------------------------------------------------------
/src/components/LazyList.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import BasicComponent from './BasicComponent.jsx';
3 |
4 | /**
5 | * @original ons-lazy-repeat
6 | * @category list
7 | * @tutorial react/Reference/lazy-list
8 | * @description
9 | * [en] Using this component a list with millions of items can be rendered without a drop in performance.
10 | * It does that by "lazily" loading elements into the DOM when they come into view and
11 | * removing items from the DOM when they are not visible.
12 | [/en]
13 | * [jp][/jp]
14 | * @example
15 | *
16 | renderRow(index) {
17 | return (
18 |
19 | {'Item ' + (index + 1)}
20 |
21 | );
22 | }
23 |
24 | render() {
25 | return (
26 | } >
27 |
28 |
31 |
32 | {'Item ' + (index + 1)}
33 |
34 | }
35 | calculateItemHeight={() => 44}
36 | />
37 |
38 |
39 | );
40 | }
41 | }
42 | */
43 | class LazyList extends BasicComponent {
44 | constructor(...args) {
45 | super(...args);
46 | this.state = {children: []};
47 | this.update = this.update.bind(this);
48 | }
49 |
50 | update(props) {
51 | var self = this;
52 |
53 | this.refs.lazyRepeat.delegate = {
54 | calculateItemHeight: function(index) {
55 | return props.calculateItemHeight(index);
56 | },
57 | _render: function(items, newHeight) {
58 | var createElement = function({index: index, top: top}) {
59 | return props.renderRow(index);
60 | };
61 |
62 | var el = items.map(createElement);
63 | self.setState({children: el, height: newHeight},
64 | () => {
65 | var list = this.refs.list;
66 | // ignore i=0
99 |
100 | {this.state.children}
101 |
102 | );
103 | }
104 | }
105 |
106 | LazyList.propTypes = {
107 | /**
108 | * @name modifier
109 | * @type string
110 | * @required false
111 | * @description
112 | * [en]The appearance of the lazy list.[/en]
113 | * [jp] [/jp]
114 | */
115 | modifier: React.PropTypes.string,
116 |
117 | /**
118 | * @name length
119 | * @type number
120 | * @description
121 | * [en]The length of the list.[/en]
122 | * [jp] [/jp]
123 | */
124 | length: React.PropTypes.number.isRequired,
125 |
126 | /**
127 | * @name renderRow
128 | * @type function
129 | * @description
130 | * [en] A function given the index of the to display row, renders it.[/en]
131 | * [jp] [/jp]
132 | */
133 | renderRow: React.PropTypes.func.isRequired,
134 |
135 | /**
136 | * @name calculateItemHeight
137 | * @type function
138 | * @description
139 | * [en] A function given the index of the to row, returns the height of it.[/en]
140 | * [jp] [/jp]
141 | */
142 | calculateItemHeight: React.PropTypes.func.isRequired
143 | };
144 |
145 | export default LazyList;
146 |
--------------------------------------------------------------------------------
/docs/SplitterSide.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-splitter-side\n@category menu\n@tutorial react/Reference/splitter\n@description\n[en] The SplitterContent element is used as a child element of Splitter.\n It contains the main content of the page while SplitterSide contains the list.\n [/en]\n[jp][/jp]\n@example\n \n \n Page Left \n \n \n Page Content \n \n \n Page Right \n \n ","methods":[],"props":{"collapse":{"type":{"name":"union","value":[{"name":"bool"},{"name":"string"}]},"required":false,"description":"@name collapse\n@type bool\n@description\n [en] Specify the collapse behavior. Valid values are `\"portrait\"`, `\"landscape\"` or a media query.\n The strings `\"portrait\"` and `\"landscape\"` means the view will collapse when device is in landscape or portrait orientation.\n If the value is not defined, the view always be in `\"collapse\"` mode.\n[/en]\n [jp] [/jp]"},"isSwipeable":{"type":{"name":"bool"},"required":false,"description":"@name isSwipeable\n@type bool\n@description\n [en]Ennable swipe interaction on collapse mode.[/en]\n [jp] [/jp]"},"isOpen":{"type":{"name":"bool"},"required":false,"description":"@name isOpen\n@type bool\n@description\n [en]Specifies whether the menu is open.[/en]\n [jp] [/jp]"},"onOpen":{"type":{"name":"func"},"required":false,"description":"@name onOpen\n@type function\n@description\n [en]Called after the menu is opened.[/en]\n [jp] [/jp]"},"onClose":{"type":{"name":"func"},"required":false,"description":"@name onClose\n@type function\n@description\n [en]Called after the menu is closed.[/en]\n [jp] [/jp]"},"side":{"type":{"name":"enum","value":[{"value":"'left'","computed":false},{"value":"'right'","computed":false}]},"required":false,"description":"@name side\n@type string\n@description\n [en]Specify which side of the screen the SplitterSide element is located. Possible values are `\"left\"` and `\"right\"`.[/en]\n [jp] [/jp]"},"swipeTargetWidth":{"type":{"name":"number"},"required":false,"description":"@name swipeTargetWidth\n@type number\n@description\n [en]Specifies the width of the menu with a number (for pixels) or a string (e.g. \"20%\" for percentage).[/en]\n [jp] [/jp]"},"width":{"type":{"name":"union","value":[{"name":"number"},{"name":"string"}]},"required":false,"description":"@name width\n@type number\n@description\n [en]Specifies the width of the menu with a number (for pixels) or a string (e.g. \"20%\" for percentage).[/en]\n [jp] [/jp]"},"animation":{"type":{"name":"string"},"required":false,"description":"@name animation\n@type string\n@required false\n@description\n [en]Specify the animation. Use one of `\"overlay\"`, and `\"default\"`.[/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"},"openThreshold":{"type":{"name":"number"},"required":false,"description":"@name openThreshold\n@type object\n@required false\n@description\n [en] Specify how much the menu needs to be swiped before opening. A value between `0` and `1`. [/en]\n [jp] [/jp]"},"mode":{"type":{"name":"enum","value":[{"value":"'collapse'","computed":false},{"value":"'split'","computed":false}]},"required":false,"description":"@name mode\n@type string\n@required false\n@description\n [en] Current mode. Possible values are `\"collapse\"` or `\"split\"`. This attribute is read only. [/en]\n [jp] [/jp]"},"onPreOpen":{"type":{"name":"func"},"required":false,"description":"@name onPreOpen\n@type string\n@description\n [en] Called before the menu opens. [/en]\n [jp] [/jp]"},"onPreClose":{"type":{"name":"func"},"required":false,"description":"@name onPreClose\n@type string\n@description\n [en] Called before the menu closes. [/en]\n [jp] [/jp]"},"onModeChange":{"type":{"name":"func"},"required":false,"description":"@name onModeChange\n@type string\n@description\n [en] Called after the component's mode changes. [/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/Dialog.jsx:
--------------------------------------------------------------------------------
1 | import BaseDialog from './BaseDialog.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-dialog
6 | * @category dialog
7 | * @tutorial react/Reference/dialog
8 | * @description
9 | * [en] Dialog that is displayed on top of current screen. As opposed to the AlertDialog element, this component can contain any kind of content. The dialog is useful for displaying menus, additional information or to ask the user to make a decision. It will automatically be displayed as Material Design when running on an Android device.
10 | [/en]
11 | * [jp][/jp]
12 | * @example
13 |
16 |
17 | Page Content
18 |
19 |
20 |
21 | */
22 | class Dialog extends BaseDialog {
23 | _getDomNodeName() {
24 | return 'ons-dialog';
25 | }
26 | }
27 |
28 | Dialog.propTypes = {
29 | /**
30 | * @name onCancel
31 | * @type function
32 | * @required false
33 | * @description
34 | * [en]
35 | * Called only if isCancelable is true. It will be called after tapping the background or by pressing the back button on Android devices.
36 | * [/en]
37 | * [jp] どうしよう[/jp]
38 | */
39 | onCancel: React.PropTypes.func,
40 |
41 | /**
42 | * @name isOpen
43 | * @type bool
44 | * @required true
45 | * @description
46 | * [en]
47 | * Indicates whether the dialog is open and shown.
48 | * [/en]
49 | * [jp] [/jp]
50 | */
51 | isOpen: React.PropTypes.bool.isRequired,
52 |
53 | /**
54 | * @name isCancelable
55 | * @type bool
56 | * @required false
57 | * @description
58 | * [en]
59 | * Specifies whether the dialog is cancelable or not.
60 | * A cancelable dialog will call onCancel when tapping the background or or pressing the back button on Android devices
61 | * [/en]
62 | * [jp] [/jp]
63 | */
64 | isCancelable: React.PropTypes.bool,
65 |
66 | /**
67 | * @name isDisabled
68 | * @type bool
69 | * @required false
70 | * @description
71 | * [en]
72 | * Specifies whether the dialog is disabled.
73 | * [/en]
74 | * [jp] [/jp]
75 | */
76 | isDisabled: React.PropTypes.bool,
77 |
78 | /**
79 | * @name animation
80 | * @type string
81 | * @required false
82 | * @description
83 | * [en]
84 | * The animation used when showing and hiding the dialog. Can be either `"none"` or `"default"`.
85 | * [/en]
86 | * [jp] [/jp]
87 | */
88 | animation: React.PropTypes.string,
89 |
90 | /**
91 | * @name modifier
92 | * @type string
93 | * @required false
94 | * @description
95 | * [en]The appearance of the dialog.[/en]
96 | * [jp] [/jp]
97 | */
98 | modifier: React.PropTypes.string,
99 |
100 | /**
101 | * @name maskColor
102 | * @type string
103 | * @required false
104 | * @description
105 | * [en]Color of the background mask. Default is "rgba(0, 0, 0, 0.2)"[/en]
106 | * [jp] [/jp]
107 | */
108 | maskColor: React.PropTypes.string,
109 |
110 | /**
111 | * @name animationOptions
112 | * @type object
113 | * @required false
114 | * @description
115 | * [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
116 | * [jp] [/jp]
117 | */
118 | animationOptions: React.PropTypes.object,
119 |
120 | /**
121 | * @name onPreShow
122 | * @type function
123 | * @required false
124 | * @description
125 | * [en]
126 | * Called just before the alert dialog is displayed.
127 | * [/en]
128 | * [jp][/jp]
129 | */
130 | onPreShow: React.PropTypes.func,
131 |
132 | /**
133 | * @name onPostShow
134 | * @type function
135 | * @required false
136 | * @description
137 | * [en]
138 | * Called just after the alert dialog is displayed.
139 | * [/en]
140 | * [jp][/jp]
141 | */
142 | onPostShow: React.PropTypes.func,
143 |
144 | /**
145 | * @name onPreHide
146 | * @type function
147 | * @required false
148 | * @description
149 | * [en]Called just before the alert dialog is hidden.[/en]
150 | * [jp][/jp]
151 | */
152 | onPreHide: React.PropTypes.func,
153 |
154 | /**
155 | * @name onPostHide
156 | * @type function
157 | * @required false
158 | * @description
159 | * [en]Called just after the alert dialog is hidden.[/en]
160 | * [jp][/jp]
161 | */
162 | onPostHide: React.PropTypes.func
163 | };
164 |
165 | export default Dialog;
166 |
--------------------------------------------------------------------------------
/src/components/Input.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import BasicComponent from './BasicComponent.jsx';
4 | import Util from './Util.js';
5 |
6 | const EVENT_TYPES = ['change', 'input'];
7 |
8 | /**
9 | * @original ons-input
10 | * @category form
11 | * @tutorial react/Reference/input
12 | * @description
13 | * [en]
14 | * An input element. The `type` attribute can be used to change the input type. All text input types as well as `checkbox` and `radio` are supported. The component will automatically render as a Material Design input on Android devices. Most attributes that can be used for a normal ` ` element can also be used on the `` element..
15 | [/en]
16 | * [jp][/jp]
17 | * @example
18 | * { this.setState({text: event.target.value})} }
21 | * modifier='material'
22 | * placeholder='Username' />
23 | */
24 | class Input extends BasicComponent {
25 | componentDidMount() {
26 | super.componentDidMount();
27 | var node = ReactDOM.findDOMNode(this);
28 |
29 | EVENT_TYPES.forEach((eventType) => {
30 | node.addEventListener(eventType, this.props.onChange);
31 | });
32 | }
33 |
34 | componentWillUnmount() {
35 | var node = ReactDOM.findDOMNode(this);
36 |
37 | EVENT_TYPES.forEach((eventType) => {
38 | node.removeEventListener(eventType, this.props.onChange);
39 | });
40 | }
41 |
42 | componentWillReceiveProps(props) {
43 | var node = ReactDOM.findDOMNode(this);
44 |
45 | if (typeof props.value !== 'undefined' && node.value !== props.value) {
46 | node.value = props.value;
47 | }
48 |
49 | if (typeof props.checked !== 'undefined') {
50 | node.checked = props.checked;
51 | }
52 | }
53 |
54 | render() {
55 | var {checked, ...other} = this.props;
56 | other['input-id'] = this.props.inputId;
57 |
58 | Util.convert(other, 'disabled');
59 |
60 | return (
61 |
62 | );
63 | }
64 | }
65 |
66 | Input.propTypes = {
67 | /**
68 | * @name modifier
69 | * @type string
70 | * @required false
71 | * @description
72 | * [en]The appearance of the input.[/en]
73 | * [jp] [/jp]
74 | */
75 | modifier: React.PropTypes.string,
76 |
77 | /**
78 | * @name disabled
79 | * @type bool
80 | * @description
81 | * [en]
82 | * Specifies whether the input is disabled.
83 | * [/en]
84 | * [jp] [/jp]
85 | */
86 | disabled: React.PropTypes.bool,
87 |
88 | /**
89 | * @name onChange
90 | * @type function
91 | * @description
92 | * [en] Called when the text of the input changes.[/en]
93 | * [jp][/jp]
94 | */
95 | onChange: React.PropTypes.func,
96 |
97 | /**
98 | * @name value
99 | * @type string
100 | * @description
101 | * [en] Content of the input.[/en]
102 | * [jp][/jp]
103 | */
104 | value: React.PropTypes.string,
105 |
106 | /**
107 | * @name checked
108 | * @type boolean
109 | * @description
110 | * [en]Set to to true if the input is checked. Only used for radio buttons and checkboxes.[/en]
111 | * [ja][/ja]
112 | */
113 | checked: React.PropTypes.bool,
114 |
115 | /**
116 | * @name placehoder
117 | * @type string
118 | * @description
119 | * [en] Placeholder text. In Material Design this placeholder will be a floating label. [/en]
120 | * [jp][/jp]
121 | */
122 | placeholder: React.PropTypes.string,
123 |
124 | /**
125 | * @name type
126 | * @type string
127 | * @description
128 | * [en] Specify the input type. This is the same as the "type" attribute for normal inputs.
129 | * Please take a look at [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type) for an exhaustive list of possible values. Depending on the platform and browser version some of these might not work.
130 | [/en]
131 | * [jp][/jp]
132 | */
133 | type: React.PropTypes.string,
134 |
135 | /**
136 | * @name inputId
137 | * @type string
138 | * @description
139 | * [en] Specify the "id" attribute of the inner ` ` element. This is useful when using elements [/en]
140 | * [jp][/jp]
141 | */
142 | inputId: React.PropTypes.string,
143 |
144 | /**
145 | * @name float
146 | * @type bool
147 | * @description
148 | * [en] If this attribute is present, the placeholder will be animated in Material Design. [/en]
149 | * [jp][/jp]
150 | */
151 | float: React.PropTypes.bool
152 | };
153 |
154 | export default Input;
155 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **This package has been moved to the [main Onsen UI repository](https://github.com/OnsenUI/OnsenUI/tree/master/bindings/react).**
2 |
3 | [](https://badge.fury.io/js/react-onsenui)
4 |
5 | # Onsen UI - React Components for Cordova/PhoneGap hybrid apps
6 |
7 | **Make beautiful high performance hybrid mobile apps using HTML5, CSS and JavaScript. Includes Material Design for Android and flat design for iOS.**
8 |
9 | [Onsen UI](https://onsen.io/2/) is a UI component library for hybrid mobile apps. It provides components for navigation, forms, tabs, Material Design, infinite lists and much more.
10 |
11 | It can be used to build hybrid apps with [Cordova](https://cordova.apache.org/) and [PhoneGap](http://phonegap.com/) but can also run in the browser.
12 |
13 | We have build a [Tutorial Website](http://tutorial.onsen.io/?framework=react&category=Getting%20started&module=Using%20the%20components) where you can see live examples of OnsenUI without installing it. If you find any issues, feel free to report at [our OpenSource Repository](https://github.com/OnsenUI/tutorial). Also pull requests are welcome.
14 |
15 | To learn how to use these components, please refer to [the documentation](https://onsen.io/v2/docs/guide/react/index.html). You can also check out our [kitchensink example](https://github.com/OnsenUI/react-onsenui-kitchensink) to learn how to use this or you can [click here](http://onsenui.github.io/react-onsenui-kitchensink/demo.html) for a quick demo.
16 |
17 | We also have a highly engaged [community](https://community.onsen.io/) that will be available to answer your questions.
18 |
19 | The main [Onsen UI repo](https://github.com/OnsenUI/OnsenUI) contains the CSS and core JS library for these components. Please star it if you like it!
20 |
21 | ## Using Onsen UI with npm
22 |
23 | The easiest way to use these components is by installing them through npm and using a CommonJS module system such as browserify and webpack (the kitchensink example above is using browserify).
24 |
25 | You need to install `react`, `react-dom`, `onsenui` and `react-onsenui`. You probably also need to add [Babel](https://babeljs.io/) with the `react` preset.
26 |
27 | Now you can import the necessary libraries in your code:
28 |
29 | ```jsx
30 | var React = require('react');
31 | var ReactDOM = require('react-dom');
32 |
33 | require('onsenui'); // This needs to be imported to bootstrap the components.
34 | var Ons = require('react-onsenui');
35 |
36 | var MyPage = React.createClass({
37 | renderToolbar: function() {
38 | return (
39 |
40 | Onsen UI
41 |
42 | );
43 | }
44 |
45 | render: function() {
46 | return (
47 |
48 | This is Onsen UI!
49 |
50 | );
51 | }
52 | });
53 |
54 | ReactDOM.render( , document.getElementById('app'));
55 | ```
56 |
57 | Take a look at the kitchensink example for more complex code.
58 |
59 |
60 |
61 |
62 | **Make beautiful high performance hybrid mobile apps using HTML5, CSS and JavaScript. Includes Material Design for Android and flat design for iOS.**
63 |
64 | [Onsen UI](https://onsen.io/2/) is a UI component library for hybrid mobile apps. It provides components for navigation, forms, tabs, Material Design, infinite lists and much more.
65 |
66 | It can be used to build hybrid apps with [Cordova](https://cordova.apache.org/) and [PhoneGap](http://phonegap.com/) but can also run in the browser.
67 |
68 | To learn how to use these components, please refer to [the documentation](https://onsen.io/v2/docs/guide/react/index.html). You can also check out our [kitchensink example](https://github.com/OnsenUI/react-onsenui-kitchensink) to learn how to use this or you can [click here](http://onsenui.github.io/react-onsenui-kitchensink/demo.html) for a quick demo.
69 |
70 | The main [Onsen UI repo](https://github.com/OnsenUI/OnsenUI) contains the CSS and core JS library for these components. Please star it if you like it!
71 |
72 | # Contribution
73 |
74 | We always welcome contributions by either opening an issue or doing a pull request.
75 |
76 | To test this repo in the current state of master, one needs to first clone this repo recursivly (it binds onsenui in a specific version) and run `npm install` in both the main folder and OnsenUI folder and finally build OnsenUI.
77 |
78 | ```bash
79 | $ git clone --recursive git@github.com:OnsenUI/react-onsenui.git
80 | $ npm install
81 | $ cd OnsenUI; npm install
82 | $ npm install -g gulp # install gulp if not already installed
83 | $ gulp build
84 | ```
85 |
86 | After these changes one can run our demo examples with `npm run dev` and open a brower at port 9000.
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/docs/Carousel.json:
--------------------------------------------------------------------------------
1 | {"description":"@original ons-carousel\n@category carousel\n@tutorial react/Reference/carousel\n@description\n[en] Carousel component. A carousel can be used to display several items in the same space.\n The component supports displaying content both horizontally and vertically. The user can scroll through the items by dragging and it can also be controller programmatically.\n [/en]\n[jp][/jp]\n@example\n console.log('onPostChange')}\n onOverscroll={() => console.log('onOverscroll')}\n onRefresh={() => console.log('onRefresh')}\n ref='carousel' swipeable overscrollable autoScroll fullscreen autoScrollRatio={0.2}>\n \n GRAY
\n \n \n BLUE
\n \n ","methods":[{"name":"_getDomNodeName","docblock":null,"modifiers":[],"params":[],"returns":null}],"props":{"direction":{"type":{"name":"enum","value":[{"value":"'horizontal'","computed":false},{"value":"'vertical'","computed":false}]},"required":false,"description":"@name direction\n@type string\n@required false\n@description\n [en]The direction of the carousel. Can be either \"horizontal\" or \"vertical\". Default is \"horizontal\".[/en]\n [jp] [/jp]"},"fullscreen":{"type":{"name":"bool"},"required":false,"description":"@name fullscreen\n@type bool\n@description\n [en]If true, the carousel will cover the whole screen.[/en]\n [jp] [/jp]"},"overscrollable":{"type":{"name":"bool"},"required":false,"description":"@name overscrollable\n@type bool\n@description\n [en]If true, the carousel will be scrollable over the edge. It will bounce back when released.[/en]\n [jp] [/jp]"},"centered":{"type":{"name":"bool"},"required":false,"description":"@name centered\n@type bool\n@description\n [en]If true, the carousel then the selected item will be in the center of the carousel instead of the beginning. Useful only when the items are smaller than the carousel.[/en]\n [jp] [/jp]"},"itemWidth":{"type":{"name":"union","value":[{"name":"string"},{"name":"number"}]},"required":false,"description":"@name itemWidth\n@type number\n@description\n [en]ons-carousel-item's width. Only works when the direction is set to \"horizontal\".[/en]\n [jp] [/jp]"},"itemHeight":{"type":{"name":"union","value":[{"name":"string"},{"name":"number"}]},"required":false,"description":"@name itemHeight\n@type number\n@description\n [en]ons-carousel-item's height. Only works when the direction is set to \"vertical\".[/en]\n [jp] [/jp]"},"autoScroll":{"type":{"name":"bool"},"required":false,"description":"@name autoScroll\n@type bool\n@description\n [en]If true, the carousel will be automatically scrolled to the closest item border when released.[/en]\n [jp] [/jp]"},"autoScrollRatio":{"type":{"name":"number"},"required":false,"description":"@name autoScrollRatio\n@type number\n@description\n [en]A number between 0.0 and 1.0 that specifies how much the user must drag the carousel in order for it to auto scroll to the next item.[/en]\n [jp] [/jp]"},"swipeable":{"type":{"name":"bool"},"required":false,"description":"@name swipeable\n@type bool\n@description\n [en]If true, the carousel can be scrolled by drag or swipe.[/en]\n [jp] [/jp]"},"disabled":{"type":{"name":"bool"},"required":false,"description":"@name disabled\n@type bool\n@description\n [en]If true, the carousel will be disabled.[/en]\n [jp] [/jp]"},"index":{"type":{"name":"number"},"required":false,"description":"@name index\n@type number\n@description\n [en]Specify the index of the ons-carousel-item to show. Default is 0.[/en]\n [jp] [/jp]"},"autoRefresh":{"type":{"name":"bool"},"required":false,"description":"@name autoRefresh\n@type bool\n@description\n [en]When this attribute is set the carousel will automatically refresh when the number of child nodes change.[/en]\n [jp] [/jp]"},"onPostChange":{"type":{"name":"func"},"required":false,"description":"@name onPostChange\n@type function\n@description\n [en]Called just after the current carousel item has changed. [/en]\n [jp] [/jp]"},"onRefresh":{"type":{"name":"func"},"required":false,"description":"@name onRefresh\n@type function\n@description\n [en]Called when the carousel has been refreshed. [/en]\n [jp] [/jp]"},"onOverscroll":{"type":{"name":"func"},"required":false,"description":"@name onOverscroll\n@type function\n@description\n [en]Called when the carousel has been overscrolled. [/en]\n [jp] [/jp]"},"animationOptions":{"type":{"name":"object"},"required":false,"description":"@name animationOptions\n@type object\n@required false\n@description\n [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]\n [jp] [/jp]"}}}
2 |
--------------------------------------------------------------------------------
/src/components/AlertDialog.jsx:
--------------------------------------------------------------------------------
1 | import BaseDialog from './BaseDialog.jsx';
2 | import React from 'react';
3 |
4 | /**
5 | * @original ons-alert-dialog
6 | * @category dialog
7 | * @tutorial react/Reference/dialog
8 | * @description
9 | * [en]
10 | * Alert dialog that is displayed on top of the current screen. Useful for displaying questions, warnings or error messages to the user. The title, content and buttons can be easily customized and it will automatically switch style based on the platform.
11 | * [/en]
12 | * [jp][/jp]
13 | * @example
14 |
15 | Warning!
16 |
17 | An error has occurred!
18 |
19 |
20 |
21 | Cancel
22 |
23 |
24 | Ok
25 |
26 |
27 |
28 | */
29 | class AlertDialog extends BaseDialog {
30 | _getDomNodeName() {
31 | return 'ons-alert-dialog';
32 | }
33 | }
34 |
35 | AlertDialog.propTypes = {
36 | /**
37 | * @name onCancel
38 | * @type function
39 | * @required false
40 | * @description
41 | * [en]
42 | * Called only if isCancelable is true. It will be called after tapping the background or by pressing the back button on Android devices.
43 | * [/en]
44 | * [jp] どうしよう[/jp]
45 | */
46 | onCancel: React.PropTypes.func,
47 |
48 | /**
49 | * @name isOpen
50 | * @type bool
51 | * @required true
52 | * @description
53 | * [en]
54 | * Indicates whether the dialog is open and shown.
55 | * [/en]
56 | * [jp] [/jp]
57 | */
58 | isOpen: React.PropTypes.bool.isRequired,
59 |
60 | /**
61 | * @name isCancelable
62 | * @type bool
63 | * @required false
64 | * @description
65 | * [en]
66 | * Specifies whether the dialog is cancelable or not.
67 | * A cancelable dialog will call onCancel when tapping the background or or pressing the back button on Android devices
68 | * [/en]
69 | * [jp] [/jp]
70 | */
71 | isCancelable: React.PropTypes.bool,
72 |
73 | /**
74 | * @name isDisabled
75 | * @type bool
76 | * @required false
77 | * @description
78 | * [en]
79 | * Specifies whether the dialog is disabled.
80 | * [/en]
81 | * [jp] [/jp]
82 | */
83 | isDisabled: React.PropTypes.bool,
84 |
85 | /**
86 | * @name animation
87 | * @type string
88 | * @required false
89 | * @description
90 | * [en]
91 | * The animation used when showing and hiding the dialog. Can be either `"none"` or `"default"`.
92 | * [/en]
93 | * [jp] [/jp]
94 | */
95 | animation: React.PropTypes.string,
96 |
97 | /**
98 | * @name modifier
99 | * @type string
100 | * @required false
101 | * @description
102 | * [en]The appearance of the dialog.[/en]
103 | * [jp] [/jp]
104 | */
105 | modifier: React.PropTypes.string,
106 |
107 | /**
108 | * @name maskColor
109 | * @type string
110 | * @required false
111 | * @description
112 | * [en]Color of the background mask. Default is "rgba(0, 0, 0, 0.2)"[/en]
113 | * [jp] [/jp]
114 | */
115 | maskColor: React.PropTypes.string,
116 |
117 | /**
118 | * @name animationOptions
119 | * @type object
120 | * @required false
121 | * @description
122 | * [en]Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.[/en]
123 | * [jp] [/jp]
124 | */
125 | animationOptions: React.PropTypes.object,
126 |
127 | /**
128 | * @name onPreShow
129 | * @type function
130 | * @required false
131 | * @description
132 | * [en]
133 | * Called just before the alert dialog is displayed.
134 | * [/en]
135 | * [jp][/jp]
136 | */
137 | onPreShow: React.PropTypes.func,
138 |
139 | /**
140 | * @name onPostShow
141 | * @type function
142 | * @required false
143 | * @description
144 | * [en]
145 | * Called just after the alert dialog is displayed.
146 | * [/en]
147 | * [jp][/jp]
148 | */
149 | onPostShow: React.PropTypes.func,
150 |
151 | /**
152 | * @name onPreHide
153 | * @type function
154 | * @required false
155 | * @description
156 | * [en]Called just before the alert dialog is hidden.[/en]
157 | * [jp][/jp]
158 | */
159 | onPreHide: React.PropTypes.func,
160 |
161 | /**
162 | * @name onPostHide
163 | * @type function
164 | * @required false
165 | * @description
166 | * [en]Called just after the alert dialog is hidden.[/en]
167 | * [jp][/jp]
168 | */
169 | onPostHide: React.PropTypes.func
170 | };
171 |
172 | export default AlertDialog;
173 |
--------------------------------------------------------------------------------