aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/value-and-defaultValue.html
blob: 8dd57170acd9e3c9e42eeba1de85a921c0f44e13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html>

<head>
  <title>value-and-defaultValue.js - example - rc-time-picker@1.1.5</title>
  <meta name="viewport"
        content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css" rel="stylesheet"/>
  <style>
    .highlight pre {
      padding: .8em 1em;
      font: 14px/20px Consolas, Monaco, 'Andale Mono', monospace;
      border: 1px solid #e5e8ec;
      border-radius: 3px;
      background-color: #21221d;
      background-image: -webkit-linear-gradient(#21221d 50%, #272822 50%);
      background-image: -moz-linear-gradient(#21221d 50%, #272822 50%);
      background-image: -ms-linear-gradient(#21221d 50%, #272822 50%);
      background-image: -o-linear-gradient(#21221d 50%, #272822 50%);
      background-image: linear-gradient(#21221d 50%, #272822 50%);
      background-size: 40px 40px;
      background-origin: content-box;
      overflow: auto;
      -webkit-overflow-scrolling: touch;
    }

    .highlight pre > code {
      font-family: inherit;
      direction: ltr;
      text-align: left;
      white-space: pre;
      word-spacing: normal;
      vertical-align: 2px;
      display: block;
      -moz-tab-size: 2;
      -o-tab-size: 2;
      tab-size: 2;
      -webkit-hyphens: none;
      -moz-hyphens: none;
      -ms-hyphens: none;
      hyphens: none;
      color: #E5E5C2;
    }
  </style>
  <style>
/*

Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/

*/

.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  background: #23241f;
  -webkit-text-size-adjust: none;
}

.hljs,
.hljs-tag,
.css .hljs-rule,
.css .hljs-value,
.aspectj .hljs-function,
.css .hljs-function
.hljs-preprocessor,
.hljs-pragma {
  color: #f8f8f2;
}

.hljs-strongemphasis,
.hljs-strong,
.hljs-emphasis {
  color: #a8a8a2;
}

.hljs-bullet,
.hljs-blockquote,
.hljs-horizontal_rule,
.hljs-number,
.hljs-regexp,
.alias .hljs-keyword,
.hljs-literal,
.hljs-hexcolor {
  color: #ae81ff;
}

.hljs-code,
.hljs-title,
.css .hljs-class,
.hljs-class .hljs-title:last-child {
  color: #a6e22e;
  /*color: #e6db74;*/
}

.hljs-link_url {
  font-size: 80%;
}

.hljs-strong,
.hljs-strongemphasis {
  font-weight: bold;
}

.hljs-emphasis,
.hljs-strongemphasis,
.hljs-class .hljs-title:last-child,
.hljs-typename {
  font-style: italic;
}

.hljs-keyword,
.ruby .hljs-class .hljs-keyword:first-child,
.ruby .hljs-function .hljs-keyword,
.hljs-function,
.hljs-change,
.hljs-winutils,
.hljs-flow,
.nginx .hljs-title,
.tex .hljs-special,
.hljs-header,
.hljs-symbol,
.hljs-symbol .hljs-string,
.hljs-tag .hljs-title,
.hljs-value,
.alias .hljs-keyword:first-child,
.css .hljs-tag,
.css .unit,
.css .hljs-important {
  color: #f92672;
}

.hljs-function .hljs-keyword,
.hljs-class .hljs-keyword:first-child,
.hljs-aspect .hljs-keyword:first-child,
.hljs-constant,
.hljs-typename,
.hljs-name,
.css .hljs-attribute {
  color: #66d9ef;
}

.hljs-variable,
.hljs-params,
.hljs-class .hljs-title,
.hljs-aspect .hljs-title {
  color: #f8f8f2;
}

.hljs-tag .hljs-value,
.hljs-string,
.css .hljs-id,
.hljs-subst,
.hljs-type,
.ruby .hljs-class .hljs-parent,
.django .hljs-template_tag,
.django .hljs-variable,
.smalltalk .hljs-class,
.django .hljs-filter .hljs-argument,
.smalltalk .hljs-localvars,
.smalltalk .hljs-array,
.hljs-attr_selector,
.hljs-pseudo,
.hljs-addition,
.hljs-stream,
.hljs-envvar,
.apache .hljs-tag,
.apache .hljs-cbracket,
.tex .hljs-command,
.hljs-prompt,
.hljs-link_label,
.hljs-link_url {
  color: #e6db74;
}

.hljs-comment,
.hljs-annotation,
.hljs-decorator,
.hljs-pi,
.hljs-doctype,
.hljs-deletion,
.hljs-shebang,
.apache .hljs-sqbracket,
.tex .hljs-formula {
  color: #75715e;
}

.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata,
.xml .php,
.php .xml {
  opacity: 0.5;
}
/***********/
.hljs-attribute{
  color: #a6e22e;
}
/***** node keyword ******/
.hljs-built_in{
  color: #3396dc;
  font-weight: bold;
}
  </style>
  <style>
    .container {
      width: 86%;
      max-width: 1000px;
      margin-left: auto;
      margin-right: auto;
    }

    .header p {
      color: #666;
    }

    .example {
      padding: 20px 0;
    }
  </style>

  <script>
    // Console-polyfill. MIT license.
    // https://github.com/paulmillr/console-polyfill
    // Make it safe to do console.log() always.
    (function (global) {
      'use strict';
      global.console = global.console || {};
      var con = global.console;
      var prop, method;
      var empty = {};
      var dummy = function () {
      };
      var properties = 'memory'.split(',');
      var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
      'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
      'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
      while (prop = properties.pop()) con[prop] = con[prop] || empty;
      while (method = methods.pop()) con[method] = con[method] || dummy;
    })(typeof window === 'undefined' ? this : window);
    // Using `this` for web workers while maintaining compatibility with browser
    // targeted script loaders such as Browserify or Webpack where the only way to
    // get to the global object is via `window`.
  </script>
  <!--[if lt IE 9]>
  <script src="https://a.alipayobjects.com/??es5-shim/4.0.5/es5-shim.js,es5-shim/4.0.5/es5-sham.js,html5shiv/3.7.2/src/html5shiv.js"></script>
  <![endif]-->
  <link rel="stylesheet" href="common.css" />
</head>

<body>
<div class="container">
  <div class="header">
    <h1>rc-time-picker@1.1.5</h1>

    <p>React TimePicker</p>
  </div>
  <div class="example" id="__react-content"></div>
  <script src="common.js?nowrap"></script>
  <script src="value-and-defaultValue.js?nowrap"></script>
  <div class="highlight"><pre><code language="js"><span class="hljs-comment">/* eslint no-console:0 */</span>

import <span class="hljs-string">'rc-time-picker/assets/index.css'</span>;

import React from <span class="hljs-string">'react'</span>;
import ReactDom from <span class="hljs-string">'react-dom'</span>;

import GregorianCalendar from <span class="hljs-string">'gregorian-calendar'</span>;
import DateTimeFormat from <span class="hljs-string">'gregorian-calendar-format'</span>;
import TimePicker from <span class="hljs-string">'rc-time-picker'</span>;
import TimePickerLocale from <span class="hljs-string">'rc-time-picker/lib/locale/zh_CN'</span>;

<span class="hljs-keyword">const</span> formatter = <span class="hljs-keyword">new</span> DateTimeFormat(<span class="hljs-string">'HH:mm:ss'</span>);

<span class="hljs-keyword">const</span> now = <span class="hljs-keyword">new</span> GregorianCalendar(TimePickerLocale.calendar);
now.setTime(<span class="hljs-built_in">Date</span>.now());

<span class="hljs-keyword">const</span> App = React.createClass({
  getInitialState() {
    <span class="hljs-keyword">return</span> {
      value: now,
    };
  },
  handleValueChange(value) {
    <span class="hljs-built_in">console</span>.log(value &amp;&amp; formatter.format(value));
    <span class="hljs-keyword">this</span>.setState({ value });
  },
  clear() {
    <span class="hljs-keyword">this</span>.setState({
      value: <span class="hljs-literal">undefined</span>,
    });
  },
  render() {
    <span class="hljs-keyword">return</span> (
      <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-title">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">TimePicker</span> <span class="hljs-attribute">formatter</span>=<span class="hljs-value">{formatter}</span> <span class="hljs-attribute">locale</span>=<span class="hljs-value">{TimePickerLocale}</span>
              <span class="hljs-attribute">defaultValue</span>=<span class="hljs-value">{now}</span> /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">TimePicker</span> <span class="hljs-attribute">formatter</span>=<span class="hljs-value">{formatter}</span> <span class="hljs-attribute">locale</span>=<span class="hljs-value">{TimePickerLocale}</span>
              <span class="hljs-attribute">value</span>=<span class="hljs-value">{this.state.value}</span>
              <span class="hljs-attribute">onChange</span>=<span class="hljs-value">{this.handleValueChange}</span>/&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">button</span> <span class="hljs-attribute">onClick</span>=<span class="hljs-value">{this.clear}</span>&gt;</span>clear<span class="hljs-tag">&lt;/<span class="hljs-title">button</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-title">div</span>&gt;</span>
    );
  },
});

ReactDom.render(
  <span class="hljs-tag">&lt;<span class="hljs-title">App</span> /&gt;</span>,
  document.getElementById('__react-content')
);
</span></code></pre></div>
</div>
<a href="http://github.com/react-component/time-picker">
  <img style="position: absolute; top: 0; right: 0; border: 0;"
       src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
       alt="Fork me on GitHub"
       data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
</body>

</html>