├── .gitignore
├── README.md
├── lib
├── appbar.js
├── button.js
├── checkbox.js
├── col.js
├── container.js
├── divider.js
├── dropdown-item.js
├── dropdown.js
├── form.js
├── index.js
├── input.js
├── modal.js
├── option.js
├── panel.js
├── radio.js
├── row.js
├── select.js
├── tab.js
├── tabs.js
└── textarea.js
├── package.json
├── rollup.config.index.js
├── rollup.config.js
└── src
└── components
├── appbar
└── index.js
├── button
└── index.js
├── checkbox
└── index.js
├── col
└── index.js
├── container
└── index.js
├── divider
└── index.js
├── dropdown-item
└── index.js
├── dropdown
└── index.js
├── form
└── index.js
├── index.js
├── input
└── index.js
├── modal
└── index.js
├── option
└── index.js
├── panel
└── index.js
├── radio
└── index.js
├── row
└── index.js
├── select
└── index.js
├── tab
└── index.js
├── tabs
└── index.js
└── textarea
└── index.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # preact-mui
2 |
3 | [](https://www.npmjs.com/package/preact-mui)
4 |
5 | >The MUI CSS Preact library is designed from the ground up to be fast, small and developer-friendly. Using the MUI Preact library you can add MUI components to your Preact apps and switch seamlessly between MUI CSS/JS and MUI Preact even within the same app.
6 |
7 | ---
8 |
9 | ### Components Example
10 |
11 | [**Preact MUI CSS Components **](http://preact-mui.surge.sh/)
12 |
13 |
14 | ### Get Started
15 |
16 | To use MUI Preact you must include the MUI CSS and JS file in your HTML payload:
17 | ```html
18 |
20 |
21 | ```
22 |
23 | #### Install
24 |
25 | `npm install preact-mui`
26 |
27 |
28 | #### Using Components
29 |
30 | ```javascript
31 | // Access components individually for smaller build files (RECOMMENDED)
32 | import Appbar from 'preact-mui/lib/appbar';
33 | import Button from 'preact-mui/lib/button';
34 | import Container from 'preact-mui/lib/container';
35 |
36 | // Access all components from preact-mui module
37 | import { Appbar, Button, Container } from 'preact-mui';
38 |
39 | // Preact-MUI also supports ES5 syntax
40 | var preactMui = require('preact-mui');
41 | var Appbar = preactMui.Appbar;
42 | var Button = preactMui.Button;
43 | var Container = preactMui.Container;
44 | ```
45 |
46 | #### Real life example:
47 |
48 | ```javascript
49 | import {h, Component, render} from 'preact';
50 |
51 | import Appbar from 'preact-mui/lib/appbar';
52 | import Button from 'preact-mui/lib/button';
53 | import Container from 'preact-mui/lib/container';
54 |
55 | class Example extends React.Component {
56 | render() {
57 | return (
58 |
59 |
60 |
61 |
62 |
63 |
64 | );
65 | }
66 | }
67 |
68 | render(, document.getElementById('example'));
69 | ```
70 |
71 | ### API
72 | Preact-MUI has the same API with React MUI, then you can check tre React API and use the same with Preact-MUI.
73 |
74 | MUI CSS React API
75 |
76 | ---
77 |
78 | ## API Documentation
79 |
80 | ### Preact Library
81 |
82 | All of the MUI React components can be accessed as top-level attributes of the `preact-mui` package. In addition, they can be accessed individually at `preact/lib/{component}`.
83 |
84 | #### Appbar
85 |
86 | ```jsx
87 | import Appbar from 'preact-mui/lib/appbar';
88 |
89 |
90 | ```
91 |
92 | Read more: https://www.muicss.com/docs/v1/react/appbar
93 |
94 | #### Button
95 |
96 | ```jsx
97 | import Button from 'preact-mui/lib/button';
98 |
99 |
100 | * {String} color=default|primary|danger|accent
101 | * {String} size=default|small|large
102 | * {String} type=submit|button
103 | * {String} variant=default|flat|raised|fab
104 | * {Boolean} disabled=false|true
105 | ```
106 |
107 | Read more: https://www.muicss.com/docs/v1/react/buttons
108 |
109 | #### Checkbox
110 |
111 | ```jsx
112 | import Checkbox from 'preact-mui/lib/checkbox';
113 |
114 |
115 | * {String} label
116 | * {String} value
117 | * {Boolean} checked
118 | * {Boolean} defaultChecked
119 | * {Boolean} disabled=false|true
120 | ```
121 |
122 | Read more: https://www.muicss.com/docs/v1/react/forms
123 |
124 | #### Container
125 |
126 | ```jsx
127 | import Container from 'preact-mui/lib/container';
128 |
129 |
130 | * {Boolean} fluid=false|true
131 | ```
132 |
133 | Read more: https://www.muicss.com/docs/v1/react/container
134 |
135 | #### Divider
136 |
137 | ```jsx
138 | import Divider from 'preact-mui/lib/divider';
139 |
140 |
141 | ```
142 |
143 | Read more: https://www.muicss.com/docs/v1/react/dividers
144 |
145 | #### Dropdown Component
146 |
147 | ##### Dropdown
148 |
149 | ```jsx
150 | import Dropdown from 'preact-mui/lib/dropdown';
151 |
152 |
153 | * {String} label
154 | * {String} alignMenu=left|right
155 | * {String} color=default|primary|danger|accent
156 | * {String} size=default|small|large
157 | * {String} variant=default|flat|raised|fab
158 | * {Boolean} disabled
159 |
160 | ```
161 |
162 | Read more: https://www.muicss.com/docs/v1/react/dropdowns
163 |
164 | ##### DropdownItem
165 |
166 | ```jsx
167 | import DropdownItem from 'preact-mui/lib/dropdown-item';
168 |
169 |
170 | * {String} link
171 | ```
172 |
173 | Read more: https://www.muicss.com/docs/v1/react/dropdowns
174 |
175 | #### Form
176 |
177 | ```jsx
178 | import Form from 'preact-mui/lib/form';
179 |
180 |
181 | * {Boolean} inline=false|true
182 | * {Boolean} legend=false|true
183 | ```
184 |
185 | Read more: https://www.muicss.com/docs/v1/react/forms
186 |
187 | #### Grid Elements
188 |
189 | ##### Row
190 |
191 | ```jsx
192 | import Row from 'preact-mui/lib/row';
193 |
194 |
195 | ```
196 |
197 | Read more: https://www.muicss.com/docs/v1/react/grid
198 |
199 | ##### Col
200 |
201 | ```jsx
202 | import Col from 'preact-mui/lib/col';
203 |
204 |
205 | * {Integer} xs
206 | * {Integer} xs-offset
207 | * {Integer} sm
208 | * {Integer} sm-offset
209 | * {Integer} md
210 | * {Integer} md-offset
211 | * {Integer} lg
212 | * {Integer} lg-offset
213 | * {Integer} xl
214 | * {Integer} xl-offset
215 | ```
216 |
217 | Read more: https://www.muicss.com/docs/v1/react/grid
218 |
219 | #### Input
220 |
221 | ```jsx
222 | import Input from 'preact-mui/lib/input';
223 |
224 |
225 | * {String} defaultValue
226 | * {String} hint
227 | * {String} value
228 | * {Boolean} floatingLabel
229 | * {String|Object} style
230 | * {String} type=text|email|url|tel|password
231 | ```
232 |
233 | Read more: https://www.muicss.com/docs/v1/react/forms
234 |
235 | #### Panel
236 |
237 | ```jsx
238 | import Panel from 'preact-mui/lib/panel';
239 |
240 |
241 | ```
242 |
243 | Read more: https://www.muicss.com/docs/v1/react/panels
244 |
245 | #### Radio
246 |
247 | ```jsx
248 | import Radio from 'preact-mui/lib/panel';
249 |
250 |
251 | * {String} name
252 | * {String} value
253 | * {String} label
254 | * {Boolean} checked
255 | * {Boolean} defaultChecked
256 | * {Boolean} disabled=false|true
257 | ```
258 |
259 | Read more: https://www.muicss.com/docs/v1/react/forms
260 |
261 | #### Select Component
262 |
263 | ##### Select
264 |
265 | ```jsx
266 | import Select from 'preact-mui/lib/select';
267 |
268 |
269 | * {String} defaultValue
270 | * {String} label
271 | * {String|Object} style
272 | * {Boolean} disabled=false|true
273 | ```
274 |
275 | Read more: https://www.muicss.com/docs/v1/react/forms
276 |
277 | ##### Option
278 |
279 | ```jsx
280 | import Option from 'preact-mui/lib/option';
281 |
282 |
283 | * {String} value
284 | * {String} label
285 | ```
286 |
287 | Read more: https://www.muicss.com/docs/v1/react/forms
288 |
289 | #### Tabs Component
290 |
291 | ##### Tabs
292 |
293 | ```jsx
294 | import Tabs from 'preact-mui/lib/tabs';
295 |
296 |
297 | * {Boolean} justified=false|true
298 | ```
299 |
300 | Read more: https://www.muicss.com/docs/v1/react/tabs
301 |
302 | ##### Tab
303 |
304 | ```jsx
305 | import Tab from 'preact-mui/lib/tab';
306 |
307 |
308 | * {Boolean} selected
309 | * {String} label
310 | * {String} value
311 | ```
312 |
313 | Read more: https://www.muicss.com/docs/v1/react/tabs
314 |
315 | #### Textarea
316 |
317 | ```jsx
318 | import Textarea from 'preact-mui/lib/textarea';
319 |
320 |
321 | * {String} defaultValue
322 | * {String} hint
323 | * {String} value
324 | * {Boolean} floatingLabel
325 | * {String} label
326 | * {String|Object} style
327 | ```
328 |
329 | Read more: https://www.muicss.com/docs/v1/react/forms
330 |
331 |
332 | ### Extra Components
333 | > Extra components that it's created on MUI Preact.js Library.
334 |
335 | #### Modal
336 |
337 | ```javascript
338 | import {h, Component, render} from 'preact';
339 | import Appbar from 'preact-mui/lib/appbar';
340 | import Button from 'preact-mui/lib/button';
341 | import Container from 'preact-mui/lib/container';
342 | import Modal from 'preact-mui/lib/modal'
343 |
344 | /**
345 | * @class Modal
346 | *
347 | * @param { string } openedBy The element Id that when clicked,
348 | * will open the modal
349 | *
350 | * @param { string } closedBy The element Id that when clicked,
351 | * will close the modal
352 | *
353 | * @param { function } onClose The hanlder that will trigger,
354 | * when you close the Modal
355 | *
356 | * @param { string } position The position of container modal.
357 | * Can be: center, centerLeft, centerRight, centerTop, centerBottom
358 | * If you set some of these positions, the modal will appear on this position
359 | */
360 | class Example extends React.Component {
361 | render() {
362 | return (
363 |
364 |
365 |
366 | {
371 | console.log('Modal Closed.')
372 | }
373 | }>
374 | I am a children of Modal Component
375 |
376 |
377 |
378 |
379 |
380 | );
381 | }
382 | }
383 |
384 | render(, document.getElementById('example'));
385 | ```
386 |
387 | ## CSS Helpers
388 |
389 | ```html
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 | Body2
449 | Body1
450 | Caption
451 |
452 | Button
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 | ```
489 |
490 | ### License
491 |
492 | [MIT]
493 |
494 |
495 | [Preact]: https://github.com/developit/preact
496 | [MUICSS]: https://facebook.github.io/react/docs/context.html
497 | [MIT]: http://choosealicense.com/licenses/mit/
498 |
499 |
--------------------------------------------------------------------------------
/lib/appbar.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.appbar = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Appbar Module
146 | * @module preact/appbar
147 | */
148 |
149 | /**
150 | * @name Appbar
151 | */
152 |
153 | var Appbar = function (_Component) {
154 | inherits(Appbar, _Component);
155 |
156 | function Appbar() {
157 | classCallCheck(this, Appbar);
158 | return possibleConstructorReturn(this, (Appbar.__proto__ || Object.getPrototypeOf(Appbar)).apply(this, arguments));
159 | }
160 |
161 | createClass(Appbar, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var children = _ref.children,
165 | props = objectWithoutProperties(_ref, ['children']);
166 |
167 | return preact.h(
168 | 'div',
169 | _extends({ 'class': 'mui-appbar' }, props),
170 | children
171 | );
172 | }
173 | }]);
174 | return Appbar;
175 | }(preact.Component);
176 |
177 | return Appbar;
178 |
179 | })));
180 |
--------------------------------------------------------------------------------
/lib/button.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.button = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Button Module
146 | * @module preact/button
147 | */
148 | /**
149 | * @name Button
150 | */
151 |
152 | var Button = function (_Component) {
153 | inherits(Button, _Component);
154 |
155 | function Button() {
156 | classCallCheck(this, Button);
157 | return possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).apply(this, arguments));
158 | }
159 |
160 | createClass(Button, [{
161 | key: 'render',
162 | value: function render(_ref) {
163 | var color = _ref.color,
164 | variant = _ref.variant,
165 | children = _ref.children,
166 | disabled = _ref.disabled,
167 | size = _ref.size,
168 | props = objectWithoutProperties(_ref, ['color', 'variant', 'children', 'disabled', 'size']);
169 |
170 | var variantClass = variant ? 'mui-btn--' + variant : '',
171 | colorClass = color ? 'mui-btn--' + color : '',
172 | sizeClass = size ? 'mui-btn--' + size : '',
173 | className = ('mui-btn ' + variantClass + ' ' + colorClass + ' ' + sizeClass).trim();
174 | return preact.h(
175 | 'button',
176 | _extends({
177 | 'class': className,
178 | disabled: disabled ? 'disabled' : ''
179 | }, props),
180 | children
181 | );
182 | }
183 | }]);
184 | return Button;
185 | }(preact.Component);
186 |
187 | return Button;
188 |
189 | })));
190 |
--------------------------------------------------------------------------------
/lib/checkbox.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.checkbox = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Checkbox Module
146 | * @module preact/checkbox
147 | */
148 |
149 | /**
150 | * @name Checkbox
151 | */
152 |
153 | var Checkbox = function (_Component) {
154 | inherits(Checkbox, _Component);
155 |
156 | function Checkbox() {
157 | classCallCheck(this, Checkbox);
158 | return possibleConstructorReturn(this, (Checkbox.__proto__ || Object.getPrototypeOf(Checkbox)).apply(this, arguments));
159 | }
160 |
161 | createClass(Checkbox, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var name = _ref.name,
165 | _ref$defaultChecked = _ref.defaultChecked,
166 | defaultChecked = _ref$defaultChecked === undefined ? false : _ref$defaultChecked,
167 | label = _ref.label,
168 | disabled = _ref.disabled,
169 | props = objectWithoutProperties(_ref, ['name', 'defaultChecked', 'label', 'disabled']);
170 |
171 | return preact.h(
172 | 'div',
173 | { 'class': 'mui-checkbox' },
174 | preact.h(
175 | 'label',
176 | null,
177 | preact.h('input', _extends({}, props, {
178 | type: 'checkbox',
179 | name: name,
180 | checked: defaultChecked,
181 | disabled: disabled ? 'disabled' : null
182 | })),
183 | label
184 | )
185 | );
186 | }
187 | }]);
188 | return Checkbox;
189 | }(preact.Component);
190 |
191 | return Checkbox;
192 |
193 | })));
194 |
--------------------------------------------------------------------------------
/lib/col.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.col = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Col Module
146 | * @module preact/col
147 | */
148 | /**
149 | * @name Col
150 | */
151 |
152 | var Col = function (_Component) {
153 | inherits(Col, _Component);
154 |
155 | function Col() {
156 | classCallCheck(this, Col);
157 | return possibleConstructorReturn(this, (Col.__proto__ || Object.getPrototypeOf(Col)).apply(this, arguments));
158 | }
159 |
160 | createClass(Col, [{
161 | key: 'render',
162 | value: function render(_ref) {
163 | var children = _ref.children,
164 | xs = _ref.xs,
165 | xsOffset = _ref.xsOffset,
166 | sm = _ref.sm,
167 | smOffset = _ref.smOffset,
168 | md = _ref.md,
169 | mdOffset = _ref.mdOffset,
170 | lg = _ref.lg,
171 | lgOffset = _ref.lgOffset,
172 | xl = _ref.xl,
173 | xlOffset = _ref.xlOffset,
174 | props = objectWithoutProperties(_ref, ['children', 'xs', 'xsOffset', 'sm', 'smOffset', 'md', 'mdOffset', 'lg', 'lgOffset', 'xl', 'xlOffset']);
175 |
176 | var colMdClass = md ? 'mui-col-md-' + md : '',
177 | colXsClass = xs ? 'mui-col-xs-' + xs : '',
178 | colSmClass = sm ? 'mui-col-sm-' + sm : '',
179 | colLgClass = lg ? 'mui-col-lg-' + lg : '',
180 | colXlClass = xl ? 'mui-col-xs-' + xl : '',
181 | xsOffsetClass = xsOffset ? 'mui-col-xs-offset-' + xsOffset : '',
182 | smOffsetClass = smOffset ? 'mui-col-sm-offset-' + smOffset : '',
183 | mdOffsetClass = mdOffset ? 'mui-col-md-offset-' + mdOffset : '',
184 | lgOffsetClass = lgOffset ? 'mui-col-lg-offset-' + lgOffset : '',
185 | xlOffsetClass = xlOffset ? 'mui-col-xl-offset-' + xlOffset : '',
186 | className = (colXsClass + ' ' + colSmClass + ' ' + colMdClass + ' ' + colLgClass + ' ' + colXlClass + ' ' + xsOffsetClass + ' ' + smOffsetClass + ' ' + mdOffsetClass + ' ' + lgOffsetClass + ' ' + xlOffsetClass).trim();
187 |
188 |
189 | return preact.h(
190 | 'div',
191 | _extends({ 'class': className }, props),
192 | children
193 | );
194 | }
195 | }]);
196 | return Col;
197 | }(preact.Component);
198 |
199 | return Col;
200 |
201 | })));
202 |
--------------------------------------------------------------------------------
/lib/container.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.container = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Container Module
146 | * @module preact/container
147 | */
148 |
149 | /**
150 | * @name Container
151 | */
152 |
153 | var Container = function (_Component) {
154 | inherits(Container, _Component);
155 |
156 | function Container() {
157 | classCallCheck(this, Container);
158 | return possibleConstructorReturn(this, (Container.__proto__ || Object.getPrototypeOf(Container)).apply(this, arguments));
159 | }
160 |
161 | createClass(Container, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var fluid = _ref.fluid,
165 | children = _ref.children,
166 | props = objectWithoutProperties(_ref, ['fluid', 'children']);
167 |
168 | return preact.h(
169 | 'div',
170 | _extends({
171 | 'class': fluid ? 'mui-container-fluid' : 'mui-container'
172 | }, props),
173 | children
174 | );
175 | }
176 | }]);
177 | return Container;
178 | }(preact.Component);
179 |
180 | return Container;
181 |
182 | })));
183 |
--------------------------------------------------------------------------------
/lib/divider.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.divider = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var get = function get(object, property, receiver) {
38 | if (object === null) object = Function.prototype;
39 | var desc = Object.getOwnPropertyDescriptor(object, property);
40 |
41 | if (desc === undefined) {
42 | var parent = Object.getPrototypeOf(object);
43 |
44 | if (parent === null) {
45 | return undefined;
46 | } else {
47 | return get(parent, property, receiver);
48 | }
49 | } else if ("value" in desc) {
50 | return desc.value;
51 | } else {
52 | var getter = desc.get;
53 |
54 | if (getter === undefined) {
55 | return undefined;
56 | }
57 |
58 | return getter.call(receiver);
59 | }
60 | };
61 |
62 | var inherits = function (subClass, superClass) {
63 | if (typeof superClass !== "function" && superClass !== null) {
64 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
65 | }
66 |
67 | subClass.prototype = Object.create(superClass && superClass.prototype, {
68 | constructor: {
69 | value: subClass,
70 | enumerable: false,
71 | writable: true,
72 | configurable: true
73 | }
74 | });
75 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
76 | };
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | var possibleConstructorReturn = function (self, call) {
89 | if (!self) {
90 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
91 | }
92 |
93 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
94 | };
95 |
96 |
97 |
98 | var set = function set(object, property, value, receiver) {
99 | var desc = Object.getOwnPropertyDescriptor(object, property);
100 |
101 | if (desc === undefined) {
102 | var parent = Object.getPrototypeOf(object);
103 |
104 | if (parent !== null) {
105 | set(parent, property, value, receiver);
106 | }
107 | } else if ("value" in desc && desc.writable) {
108 | desc.value = value;
109 | } else {
110 | var setter = desc.set;
111 |
112 | if (setter !== undefined) {
113 | setter.call(receiver, value);
114 | }
115 | }
116 |
117 | return value;
118 | };
119 |
120 | /**
121 | * MUI Preact Divider Module
122 | * @module preact/divider
123 | */
124 |
125 | /**
126 | * @name Divider
127 | */
128 |
129 | var Divider = function (_Component) {
130 | inherits(Divider, _Component);
131 |
132 | function Divider() {
133 | classCallCheck(this, Divider);
134 | return possibleConstructorReturn(this, (Divider.__proto__ || Object.getPrototypeOf(Divider)).apply(this, arguments));
135 | }
136 |
137 | createClass(Divider, [{
138 | key: 'render',
139 | value: function render() {
140 | return preact.h('div', { 'class': 'mui-divider' });
141 | }
142 | }]);
143 | return Divider;
144 | }(preact.Component);
145 |
146 | return Divider;
147 |
148 | })));
149 |
--------------------------------------------------------------------------------
/lib/dropdown-item.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.dropdownItem = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var get = function get(object, property, receiver) {
38 | if (object === null) object = Function.prototype;
39 | var desc = Object.getOwnPropertyDescriptor(object, property);
40 |
41 | if (desc === undefined) {
42 | var parent = Object.getPrototypeOf(object);
43 |
44 | if (parent === null) {
45 | return undefined;
46 | } else {
47 | return get(parent, property, receiver);
48 | }
49 | } else if ("value" in desc) {
50 | return desc.value;
51 | } else {
52 | var getter = desc.get;
53 |
54 | if (getter === undefined) {
55 | return undefined;
56 | }
57 |
58 | return getter.call(receiver);
59 | }
60 | };
61 |
62 | var inherits = function (subClass, superClass) {
63 | if (typeof superClass !== "function" && superClass !== null) {
64 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
65 | }
66 |
67 | subClass.prototype = Object.create(superClass && superClass.prototype, {
68 | constructor: {
69 | value: subClass,
70 | enumerable: false,
71 | writable: true,
72 | configurable: true
73 | }
74 | });
75 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
76 | };
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | var objectWithoutProperties = function (obj, keys) {
87 | var target = {};
88 |
89 | for (var i in obj) {
90 | if (keys.indexOf(i) >= 0) continue;
91 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
92 | target[i] = obj[i];
93 | }
94 |
95 | return target;
96 | };
97 |
98 | var possibleConstructorReturn = function (self, call) {
99 | if (!self) {
100 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
101 | }
102 |
103 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
104 | };
105 |
106 |
107 |
108 | var set = function set(object, property, value, receiver) {
109 | var desc = Object.getOwnPropertyDescriptor(object, property);
110 |
111 | if (desc === undefined) {
112 | var parent = Object.getPrototypeOf(object);
113 |
114 | if (parent !== null) {
115 | set(parent, property, value, receiver);
116 | }
117 | } else if ("value" in desc && desc.writable) {
118 | desc.value = value;
119 | } else {
120 | var setter = desc.set;
121 |
122 | if (setter !== undefined) {
123 | setter.call(receiver, value);
124 | }
125 | }
126 |
127 | return value;
128 | };
129 |
130 | /**
131 | * MUI Preact DropdownItem Module
132 | * @module preact/dropdown-item
133 | */
134 |
135 | /**
136 | * @name DropdownItem
137 | */
138 |
139 | var DropdownItem = function (_Component) {
140 | inherits(DropdownItem, _Component);
141 |
142 | function DropdownItem() {
143 | classCallCheck(this, DropdownItem);
144 | return possibleConstructorReturn(this, (DropdownItem.__proto__ || Object.getPrototypeOf(DropdownItem)).apply(this, arguments));
145 | }
146 |
147 | createClass(DropdownItem, [{
148 | key: 'render',
149 | value: function render(_ref) {
150 | var link = _ref.link,
151 | children = _ref.children,
152 | props = objectWithoutProperties(_ref, ['link', 'children']);
153 |
154 | return preact.h(
155 | 'li',
156 | props,
157 | preact.h(
158 | 'a',
159 | { href: link ? link : false },
160 | children
161 | )
162 | );
163 | }
164 | }]);
165 | return DropdownItem;
166 | }(preact.Component);
167 |
168 | return DropdownItem;
169 |
170 | })));
171 |
--------------------------------------------------------------------------------
/lib/dropdown.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.dropdown = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Button Module
146 | * @module preact/button
147 | */
148 | /**
149 | * @name Button
150 | */
151 |
152 | var Button = function (_Component) {
153 | inherits(Button, _Component);
154 |
155 | function Button() {
156 | classCallCheck(this, Button);
157 | return possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).apply(this, arguments));
158 | }
159 |
160 | createClass(Button, [{
161 | key: 'render',
162 | value: function render(_ref) {
163 | var color = _ref.color,
164 | variant = _ref.variant,
165 | children = _ref.children,
166 | disabled = _ref.disabled,
167 | size = _ref.size,
168 | props = objectWithoutProperties(_ref, ['color', 'variant', 'children', 'disabled', 'size']);
169 |
170 | var variantClass = variant ? 'mui-btn--' + variant : '',
171 | colorClass = color ? 'mui-btn--' + color : '',
172 | sizeClass = size ? 'mui-btn--' + size : '',
173 | className = ('mui-btn ' + variantClass + ' ' + colorClass + ' ' + sizeClass).trim();
174 | return preact.h(
175 | 'button',
176 | _extends({
177 | 'class': className,
178 | disabled: disabled ? 'disabled' : ''
179 | }, props),
180 | children
181 | );
182 | }
183 | }]);
184 | return Button;
185 | }(preact.Component);
186 |
187 | /**
188 | * MUI Preact Dropdown Module
189 | * @module preact/dropdown
190 | */
191 |
192 | /**
193 | * @name Dropdown
194 | */
195 |
196 | var Dropdown = function (_Component) {
197 | inherits(Dropdown, _Component);
198 |
199 | function Dropdown() {
200 | classCallCheck(this, Dropdown);
201 | return possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).apply(this, arguments));
202 | }
203 |
204 | createClass(Dropdown, [{
205 | key: 'render',
206 | value: function render(_ref) {
207 | var label = _ref.label,
208 | color = _ref.color,
209 | size = _ref.size,
210 | variant = _ref.variant,
211 | disabled = _ref.disabled,
212 | alignMenu = _ref.alignMenu,
213 | children = _ref.children,
214 | props = objectWithoutProperties(_ref, ['label', 'color', 'size', 'variant', 'disabled', 'alignMenu', 'children']);
215 |
216 | return preact.h(
217 | 'div',
218 | _extends({ 'class': 'mui-dropdown' }, props),
219 | preact.h(
220 | Button,
221 | {
222 | color: color,
223 | size: size,
224 | variant: variant,
225 | 'data-mui-toggle': 'dropdown',
226 | disabled: disabled ? disabled : null },
227 | label,
228 | preact.h('span', { 'class': 'mui-caret' })
229 | ),
230 | preact.h(
231 | 'ul',
232 | { 'class': 'mui-dropdown__menu ' + (alignMenu ? 'mui-dropdown__menu--' + alignMenu : false) },
233 | children
234 | )
235 | );
236 | }
237 | }]);
238 | return Dropdown;
239 | }(preact.Component);
240 |
241 | return Dropdown;
242 |
243 | })));
244 |
--------------------------------------------------------------------------------
/lib/form.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.form = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Form module
146 | * @module preact/form
147 | */
148 |
149 | /**
150 | * @name Form
151 | */
152 |
153 | var Form = function (_Component) {
154 | inherits(Form, _Component);
155 |
156 | function Form() {
157 | classCallCheck(this, Form);
158 | return possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments));
159 | }
160 |
161 | createClass(Form, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var legend = _ref.legend,
165 | children = _ref.children,
166 | inline = _ref.inline,
167 | props = objectWithoutProperties(_ref, ['legend', 'children', 'inline']);
168 |
169 | return preact.h(
170 | 'form',
171 | _extends({
172 | 'class': inline ? 'mui-form--inline' : null
173 | }, props),
174 | legend ? preact.h(
175 | 'legend',
176 | null,
177 | legend
178 | ) : null,
179 | children
180 | );
181 | }
182 | }]);
183 | return Form;
184 | }(preact.Component);
185 |
186 | return Form;
187 |
188 | })));
189 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var asyncGenerator = function () {
8 | function AwaitValue(value) {
9 | this.value = value;
10 | }
11 |
12 | function AsyncGenerator(gen) {
13 | var front, back;
14 |
15 | function send(key, arg) {
16 | return new Promise(function (resolve, reject) {
17 | var request = {
18 | key: key,
19 | arg: arg,
20 | resolve: resolve,
21 | reject: reject,
22 | next: null
23 | };
24 |
25 | if (back) {
26 | back = back.next = request;
27 | } else {
28 | front = back = request;
29 | resume(key, arg);
30 | }
31 | });
32 | }
33 |
34 | function resume(key, arg) {
35 | try {
36 | var result = gen[key](arg);
37 | var value = result.value;
38 |
39 | if (value instanceof AwaitValue) {
40 | Promise.resolve(value.value).then(function (arg) {
41 | resume("next", arg);
42 | }, function (arg) {
43 | resume("throw", arg);
44 | });
45 | } else {
46 | settle(result.done ? "return" : "normal", result.value);
47 | }
48 | } catch (err) {
49 | settle("throw", err);
50 | }
51 | }
52 |
53 | function settle(type, value) {
54 | switch (type) {
55 | case "return":
56 | front.resolve({
57 | value: value,
58 | done: true
59 | });
60 | break;
61 |
62 | case "throw":
63 | front.reject(value);
64 | break;
65 |
66 | default:
67 | front.resolve({
68 | value: value,
69 | done: false
70 | });
71 | break;
72 | }
73 |
74 | front = front.next;
75 |
76 | if (front) {
77 | resume(front.key, front.arg);
78 | } else {
79 | back = null;
80 | }
81 | }
82 |
83 | this._invoke = send;
84 |
85 | if (typeof gen.return !== "function") {
86 | this.return = undefined;
87 | }
88 | }
89 |
90 | if (typeof Symbol === "function" && Symbol.asyncIterator) {
91 | AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
92 | return this;
93 | };
94 | }
95 |
96 | AsyncGenerator.prototype.next = function (arg) {
97 | return this._invoke("next", arg);
98 | };
99 |
100 | AsyncGenerator.prototype.throw = function (arg) {
101 | return this._invoke("throw", arg);
102 | };
103 |
104 | AsyncGenerator.prototype.return = function (arg) {
105 | return this._invoke("return", arg);
106 | };
107 |
108 | return {
109 | wrap: function (fn) {
110 | return function () {
111 | return new AsyncGenerator(fn.apply(this, arguments));
112 | };
113 | },
114 | await: function (value) {
115 | return new AwaitValue(value);
116 | }
117 | };
118 | }();
119 |
120 | var classCallCheck = function (instance, Constructor) {
121 | if (!(instance instanceof Constructor)) {
122 | throw new TypeError("Cannot call a class as a function");
123 | }
124 | };
125 |
126 | var _extends = Object.assign || function (target) {
127 | for (var i = 1; i < arguments.length; i++) {
128 | var source = arguments[i];
129 |
130 | for (var key in source) {
131 | if (Object.prototype.hasOwnProperty.call(source, key)) {
132 | target[key] = source[key];
133 | }
134 | }
135 | }
136 |
137 | return target;
138 | };
139 |
140 | var inherits = function (subClass, superClass) {
141 | if (typeof superClass !== "function" && superClass !== null) {
142 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
143 | }
144 |
145 | subClass.prototype = Object.create(superClass && superClass.prototype, {
146 | constructor: {
147 | value: subClass,
148 | enumerable: false,
149 | writable: true,
150 | configurable: true
151 | }
152 | });
153 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
154 | };
155 |
156 | var objectWithoutProperties = function (obj, keys) {
157 | var target = {};
158 |
159 | for (var i in obj) {
160 | if (keys.indexOf(i) >= 0) continue;
161 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
162 | target[i] = obj[i];
163 | }
164 |
165 | return target;
166 | };
167 |
168 | var possibleConstructorReturn = function (self, call) {
169 | if (!self) {
170 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
171 | }
172 |
173 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
174 | };
175 |
176 | /**
177 | * @name Appbar
178 | */
179 |
180 | var Appbar = function (_Component) {
181 | inherits(Appbar, _Component);
182 |
183 | function Appbar() {
184 | classCallCheck(this, Appbar);
185 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
186 | }
187 |
188 | Appbar.prototype.render = function render(_ref) {
189 | var children = _ref.children,
190 | props = objectWithoutProperties(_ref, ['children']);
191 |
192 | return preact.h(
193 | 'div',
194 | _extends({ 'class': 'mui-appbar' }, props),
195 | children
196 | );
197 | };
198 |
199 | return Appbar;
200 | }(preact.Component);
201 |
202 | /**
203 | * @name Button
204 | */
205 |
206 | var Button = function (_Component) {
207 | inherits(Button, _Component);
208 |
209 | function Button() {
210 | classCallCheck(this, Button);
211 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
212 | }
213 |
214 | Button.prototype.render = function render(_ref) {
215 | var color = _ref.color,
216 | variant = _ref.variant,
217 | children = _ref.children,
218 | disabled = _ref.disabled,
219 | size = _ref.size,
220 | props = objectWithoutProperties(_ref, ['color', 'variant', 'children', 'disabled', 'size']);
221 |
222 | var variantClass = variant ? 'mui-btn--' + variant : '',
223 | colorClass = color ? 'mui-btn--' + color : '',
224 | sizeClass = size ? 'mui-btn--' + size : '',
225 | className = ('mui-btn ' + variantClass + ' ' + colorClass + ' ' + sizeClass).trim();
226 | return preact.h(
227 | 'button',
228 | _extends({
229 | 'class': className,
230 | disabled: disabled ? 'disabled' : ''
231 | }, props),
232 | children
233 | );
234 | };
235 |
236 | return Button;
237 | }(preact.Component);
238 |
239 | /**
240 | * @name Container
241 | */
242 |
243 | var Container = function (_Component) {
244 | inherits(Container, _Component);
245 |
246 | function Container() {
247 | classCallCheck(this, Container);
248 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
249 | }
250 |
251 | Container.prototype.render = function render(_ref) {
252 | var fluid = _ref.fluid,
253 | children = _ref.children,
254 | props = objectWithoutProperties(_ref, ['fluid', 'children']);
255 |
256 | return preact.h(
257 | 'div',
258 | _extends({
259 | 'class': fluid ? 'mui-container-fluid' : 'mui-container'
260 | }, props),
261 | children
262 | );
263 | };
264 |
265 | return Container;
266 | }(preact.Component);
267 |
268 | /**
269 | * @name Divider
270 | */
271 |
272 | var Divider = function (_Component) {
273 | inherits(Divider, _Component);
274 |
275 | function Divider() {
276 | classCallCheck(this, Divider);
277 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
278 | }
279 |
280 | Divider.prototype.render = function render() {
281 | return preact.h('div', { 'class': 'mui-divider' });
282 | };
283 |
284 | return Divider;
285 | }(preact.Component);
286 |
287 | /**
288 | * @name Dropdown
289 | */
290 |
291 | var Dropdown = function (_Component) {
292 | inherits(Dropdown, _Component);
293 |
294 | function Dropdown() {
295 | classCallCheck(this, Dropdown);
296 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
297 | }
298 |
299 | Dropdown.prototype.render = function render(_ref) {
300 | var label = _ref.label,
301 | color = _ref.color,
302 | size = _ref.size,
303 | variant = _ref.variant,
304 | disabled = _ref.disabled,
305 | alignMenu = _ref.alignMenu,
306 | children = _ref.children,
307 | props = objectWithoutProperties(_ref, ['label', 'color', 'size', 'variant', 'disabled', 'alignMenu', 'children']);
308 |
309 | return preact.h(
310 | 'div',
311 | _extends({ 'class': 'mui-dropdown' }, props),
312 | preact.h(
313 | Button,
314 | {
315 | color: color,
316 | size: size,
317 | variant: variant,
318 | 'data-mui-toggle': 'dropdown',
319 | disabled: disabled ? disabled : null },
320 | label,
321 | preact.h('span', { 'class': 'mui-caret' })
322 | ),
323 | preact.h(
324 | 'ul',
325 | { 'class': 'mui-dropdown__menu ' + (alignMenu ? 'mui-dropdown__menu--' + alignMenu : false) },
326 | children
327 | )
328 | );
329 | };
330 |
331 | return Dropdown;
332 | }(preact.Component);
333 |
334 | /**
335 | * @name DropdownItem
336 | */
337 |
338 | var DropdownItem = function (_Component) {
339 | inherits(DropdownItem, _Component);
340 |
341 | function DropdownItem() {
342 | classCallCheck(this, DropdownItem);
343 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
344 | }
345 |
346 | DropdownItem.prototype.render = function render(_ref) {
347 | var link = _ref.link,
348 | children = _ref.children,
349 | props = objectWithoutProperties(_ref, ['link', 'children']);
350 |
351 | return preact.h(
352 | 'li',
353 | props,
354 | preact.h(
355 | 'a',
356 | { href: link ? link : false },
357 | children
358 | )
359 | );
360 | };
361 |
362 | return DropdownItem;
363 | }(preact.Component);
364 |
365 | /**
366 | * @name Form
367 | */
368 |
369 | var Form = function (_Component) {
370 | inherits(Form, _Component);
371 |
372 | function Form() {
373 | classCallCheck(this, Form);
374 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
375 | }
376 |
377 | Form.prototype.render = function render(_ref) {
378 | var legend = _ref.legend,
379 | children = _ref.children,
380 | inline = _ref.inline,
381 | props = objectWithoutProperties(_ref, ['legend', 'children', 'inline']);
382 |
383 | return preact.h(
384 | 'form',
385 | _extends({
386 | 'class': inline ? 'mui-form--inline' : null
387 | }, props),
388 | legend ? preact.h(
389 | 'legend',
390 | null,
391 | legend
392 | ) : null,
393 | children
394 | );
395 | };
396 |
397 | return Form;
398 | }(preact.Component);
399 |
400 | /**
401 | * @name Input
402 | */
403 |
404 | var Input = function (_Component) {
405 | inherits(Input, _Component);
406 |
407 | function Input() {
408 | classCallCheck(this, Input);
409 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
410 | }
411 |
412 | Input.prototype.render = function render(_ref) {
413 | var style = _ref.style,
414 | hint = _ref.hint,
415 | label = _ref.label,
416 | _ref$type = _ref.type,
417 | type = _ref$type === undefined ? 'text' : _ref$type,
418 | required = _ref.required,
419 | defaultValue = _ref.defaultValue,
420 | floatingLabel = _ref.floatingLabel,
421 | props = objectWithoutProperties(_ref, ['style', 'hint', 'label', 'type', 'required', 'defaultValue', 'floatingLabel']);
422 |
423 | var floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
424 | var className = ('mui-textfield ' + floatingLabelClass).trim();
425 | return preact.h(
426 | 'div',
427 | {
428 | 'class': className,
429 | style: style ? style : null
430 | },
431 | preact.h('input', _extends({
432 | type: type,
433 | placeholder: hint,
434 | value: defaultValue ? defaultValue : null,
435 | required: required ? required : null
436 | }, props)),
437 | label ? preact.h(
438 | 'label',
439 | null,
440 | label
441 | ) : null
442 | );
443 | };
444 |
445 | return Input;
446 | }(preact.Component);
447 |
448 | /**
449 | * @name Checkbox
450 | */
451 |
452 | var Checkbox = function (_Component) {
453 | inherits(Checkbox, _Component);
454 |
455 | function Checkbox() {
456 | classCallCheck(this, Checkbox);
457 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
458 | }
459 |
460 | Checkbox.prototype.render = function render(_ref) {
461 | var name = _ref.name,
462 | _ref$defaultChecked = _ref.defaultChecked,
463 | defaultChecked = _ref$defaultChecked === undefined ? false : _ref$defaultChecked,
464 | label = _ref.label,
465 | disabled = _ref.disabled,
466 | props = objectWithoutProperties(_ref, ['name', 'defaultChecked', 'label', 'disabled']);
467 |
468 | return preact.h(
469 | 'div',
470 | { 'class': 'mui-checkbox' },
471 | preact.h(
472 | 'label',
473 | null,
474 | preact.h('input', _extends({}, props, {
475 | type: 'checkbox',
476 | name: name,
477 | checked: defaultChecked,
478 | disabled: disabled ? 'disabled' : null
479 | })),
480 | label
481 | )
482 | );
483 | };
484 |
485 | return Checkbox;
486 | }(preact.Component);
487 |
488 | /**
489 | * @name Radio
490 | */
491 |
492 | var Radio = function (_Component) {
493 | inherits(Radio, _Component);
494 |
495 | function Radio() {
496 | classCallCheck(this, Radio);
497 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
498 | }
499 |
500 | Radio.prototype.render = function render(_ref) {
501 | var name = _ref.name,
502 | _ref$defaultChecked = _ref.defaultChecked,
503 | defaultChecked = _ref$defaultChecked === undefined ? false : _ref$defaultChecked,
504 | checked = _ref.checked,
505 | label = _ref.label,
506 | disabled = _ref.disabled,
507 | props = objectWithoutProperties(_ref, ['name', 'defaultChecked', 'checked', 'label', 'disabled']);
508 |
509 | return preact.h(
510 | 'div',
511 | { 'class': 'mui-radio' },
512 | preact.h(
513 | 'label',
514 | null,
515 | preact.h('input', _extends({}, props, {
516 | type: 'radio',
517 | name: name,
518 | checked: defaultChecked || checked,
519 | disabled: disabled ? 'disabled' : null
520 | })),
521 | label
522 | )
523 | );
524 | };
525 |
526 | return Radio;
527 | }(preact.Component);
528 |
529 | /**
530 | * @name Select
531 | */
532 |
533 | var Select = function (_Component) {
534 | inherits(Select, _Component);
535 |
536 | function Select() {
537 | classCallCheck(this, Select);
538 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
539 | }
540 |
541 | Select.prototype.render = function render(_ref) {
542 | var style = _ref.style,
543 | children = _ref.children,
544 | label = _ref.label,
545 | _ref$defaultValue = _ref.defaultValue,
546 | defaultValue = _ref$defaultValue === undefined ? false : _ref$defaultValue,
547 | _ref$disabled = _ref.disabled,
548 | disabled = _ref$disabled === undefined ? false : _ref$disabled,
549 | props = objectWithoutProperties(_ref, ['style', 'children', 'label', 'defaultValue', 'disabled']);
550 |
551 | return preact.h(
552 | 'div',
553 | { 'class': 'mui-select', style: style },
554 | preact.h(
555 | 'select',
556 | _extends({}, props, { disabled: disabled, value: defaultValue }),
557 | label ? preact.h(
558 | 'label',
559 | null,
560 | label
561 | ) : null,
562 | children
563 | )
564 | );
565 | };
566 |
567 | return Select;
568 | }(preact.Component);
569 |
570 | /**
571 | * @name Option
572 | */
573 |
574 | var Option = function (_Component) {
575 | inherits(Option, _Component);
576 |
577 | function Option() {
578 | classCallCheck(this, Option);
579 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
580 | }
581 |
582 | Option.prototype.render = function render(_ref) {
583 | var label = _ref.label,
584 | value = _ref.value,
585 | props = objectWithoutProperties(_ref, ['label', 'value']);
586 |
587 | return preact.h(
588 | 'option',
589 | _extends({}, props, { value: value }),
590 | label
591 | );
592 | };
593 |
594 | return Option;
595 | }(preact.Component);
596 |
597 | /**
598 | * @name Textarea
599 | */
600 |
601 | var Textarea = function (_Component) {
602 | inherits(Textarea, _Component);
603 |
604 | function Textarea() {
605 | classCallCheck(this, Textarea);
606 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
607 | }
608 |
609 | Textarea.prototype.render = function render(_ref) {
610 | var style = _ref.style,
611 | hint = _ref.hint,
612 | label = _ref.label,
613 | required = _ref.required,
614 | defaultValue = _ref.defaultValue,
615 | floatingLabel = _ref.floatingLabel,
616 | props = objectWithoutProperties(_ref, ['style', 'hint', 'label', 'required', 'defaultValue', 'floatingLabel']);
617 |
618 | var floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
619 | var className = ('mui-textfield ' + floatingLabelClass).trim();
620 | return preact.h(
621 | 'div',
622 | {
623 | 'class': className,
624 | style: style ? style : null
625 | },
626 | preact.h('textarea', _extends({
627 | placeholder: hint,
628 | value: defaultValue ? defaultValue : null,
629 | required: required ? required : null
630 | }, props)),
631 | label ? preact.h(
632 | 'label',
633 | null,
634 | label
635 | ) : null
636 | );
637 | };
638 |
639 | return Textarea;
640 | }(preact.Component);
641 |
642 | /**
643 | * @name Row
644 | */
645 |
646 | var Row = function (_Component) {
647 | inherits(Row, _Component);
648 |
649 | function Row() {
650 | classCallCheck(this, Row);
651 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
652 | }
653 |
654 | Row.prototype.render = function render(_ref) {
655 | var children = _ref.children,
656 | props = objectWithoutProperties(_ref, ['children']);
657 |
658 | return preact.h(
659 | 'div',
660 | _extends({ 'class': 'mui-row' }, props),
661 | children
662 | );
663 | };
664 |
665 | return Row;
666 | }(preact.Component);
667 |
668 | /**
669 | * @name Col
670 | */
671 |
672 | var Col = function (_Component) {
673 | inherits(Col, _Component);
674 |
675 | function Col() {
676 | classCallCheck(this, Col);
677 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
678 | }
679 |
680 | Col.prototype.render = function render(_ref) {
681 | var children = _ref.children,
682 | xs = _ref.xs,
683 | xsOffset = _ref.xsOffset,
684 | sm = _ref.sm,
685 | smOffset = _ref.smOffset,
686 | md = _ref.md,
687 | mdOffset = _ref.mdOffset,
688 | lg = _ref.lg,
689 | lgOffset = _ref.lgOffset,
690 | xl = _ref.xl,
691 | xlOffset = _ref.xlOffset,
692 | props = objectWithoutProperties(_ref, ['children', 'xs', 'xsOffset', 'sm', 'smOffset', 'md', 'mdOffset', 'lg', 'lgOffset', 'xl', 'xlOffset']);
693 |
694 | var colMdClass = md ? 'mui-col-md-' + md : '',
695 | colXsClass = xs ? 'mui-col-xs-' + xs : '',
696 | colSmClass = sm ? 'mui-col-sm-' + sm : '',
697 | colLgClass = lg ? 'mui-col-lg-' + lg : '',
698 | colXlClass = xl ? 'mui-col-xs-' + xl : '',
699 | xsOffsetClass = xsOffset ? 'mui-col-xs-offset-' + xsOffset : '',
700 | smOffsetClass = smOffset ? 'mui-col-sm-offset-' + smOffset : '',
701 | mdOffsetClass = mdOffset ? 'mui-col-md-offset-' + mdOffset : '',
702 | lgOffsetClass = lgOffset ? 'mui-col-lg-offset-' + lgOffset : '',
703 | xlOffsetClass = xlOffset ? 'mui-col-xl-offset-' + xlOffset : '',
704 | className = (colXsClass + ' ' + colSmClass + ' ' + colMdClass + ' ' + colLgClass + ' ' + colXlClass + ' ' + xsOffsetClass + ' ' + smOffsetClass + ' ' + mdOffsetClass + ' ' + lgOffsetClass + ' ' + xlOffsetClass).trim();
705 | ;
706 |
707 | return preact.h(
708 | 'div',
709 | _extends({ 'class': className }, props),
710 | children
711 | );
712 | };
713 |
714 | return Col;
715 | }(preact.Component);
716 |
717 | /**
718 | * @name Panel
719 | */
720 |
721 | var Panel = function (_Component) {
722 | inherits(Panel, _Component);
723 |
724 | function Panel() {
725 | classCallCheck(this, Panel);
726 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
727 | }
728 |
729 | Panel.prototype.render = function render(_ref) {
730 | var children = _ref.children,
731 | props = objectWithoutProperties(_ref, ['children']);
732 |
733 | return preact.h(
734 | 'div',
735 | _extends({ 'class': 'mui-panel' }, props),
736 | children
737 | );
738 | };
739 |
740 | return Panel;
741 | }(preact.Component);
742 |
743 | /**
744 | * @name Tabs
745 | */
746 |
747 | var Tabs = function (_Component) {
748 | inherits(Tabs, _Component);
749 |
750 | function Tabs() {
751 | classCallCheck(this, Tabs);
752 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
753 | }
754 |
755 | Tabs.prototype.render = function render(_ref) {
756 | var children = _ref.children,
757 | justified = _ref.justified,
758 | initialSelectedIndex = _ref.initialSelectedIndex,
759 | props = objectWithoutProperties(_ref, ['children', 'justified', 'initialSelectedIndex']);
760 |
761 | var className = justified ? 'mui-tabs__bar mui-tabs__bar--justified' : 'mui-tabs__bar';
762 | return preact.h(
763 | 'ul',
764 | _extends({ 'class': className }, props),
765 | children
766 | );
767 | };
768 |
769 | return Tabs;
770 | }(preact.Component);
771 |
772 | function renderTabMuiChildren(props) {
773 | var div = document.createElement('div');
774 | div.classList.add('mui-tabs__pane');
775 | div.id = props.value;
776 | if (props.selected === true) {
777 | div.classList.add('mui--is-active');
778 | }
779 | div.appendChild(preact.render(props.children[0]));
780 | return div;
781 | }
782 | /**
783 | * @name Tab
784 | */
785 |
786 | var Tab = function (_Component) {
787 | inherits(Tab, _Component);
788 |
789 | function Tab() {
790 | classCallCheck(this, Tab);
791 | return possibleConstructorReturn(this, _Component.apply(this, arguments));
792 | }
793 |
794 | Tab.prototype.componentDidUpdate = function componentDidUpdate() {
795 | var div = renderTabMuiChildren(this.props);
796 | this.base.parentElement.insertAdjacentElement('afterend', div);
797 | };
798 |
799 | Tab.prototype.componentDidMount = function componentDidMount() {
800 | var div = renderTabMuiChildren(this.props);
801 | this.base.parentElement.insertAdjacentElement('afterend', div);
802 | };
803 |
804 | Tab.prototype.render = function render(_ref) {
805 | var value = _ref.value,
806 | selected = _ref.selected,
807 | label = _ref.label,
808 | props = objectWithoutProperties(_ref, ['value', 'selected', 'label']);
809 |
810 | return preact.h(
811 | 'li',
812 | _extends({}, props, { 'class': selected ? 'mui--is-active' : null }),
813 | preact.h(
814 | 'a',
815 | { 'data-mui-toggle': 'tab', 'data-mui-controls': value },
816 | ' ',
817 | label,
818 | ' '
819 | )
820 | );
821 | };
822 |
823 | return Tab;
824 | }(preact.Component);
825 |
826 | /**
827 | * @name Modal
828 | *
829 | * @param {string} openedBy The element id that will open the modal
830 | * when clicked
831 | *
832 | * @param {string} closedBy The element id that will close the modal
833 | * when clicked
834 | *
835 | * @param {function} onClose The function that will be called
836 | * when modal is closed
837 | */
838 |
839 | var Modal = function (_Component) {
840 | inherits(Modal, _Component);
841 |
842 | function Modal() {
843 | var _temp, _this, _ret;
844 |
845 | classCallCheck(this, Modal);
846 |
847 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
848 | args[_key] = arguments[_key];
849 | }
850 |
851 | return _ret = (_temp = (_this = possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
852 | isActive: false
853 | }, _temp), possibleConstructorReturn(_this, _ret);
854 | }
855 |
856 | Modal.prototype.componentDidMount = function componentDidMount() {
857 | var _this2 = this;
858 |
859 | if (this.props.openedBy !== undefined) {
860 | var openedBy = document.querySelector('#' + this.props.openedBy);
861 | openedBy.addEventListener('click', function () {
862 | _this2.toggleModal();
863 | });
864 | } else if (this.props.closedBy !== undefined) {
865 | var closedByElement = document.querySelector('#' + this.props.closedBy);
866 | closedByElement.addEventListener('click', function () {
867 | _this2.toggleModal();
868 | mui.overlay('off');
869 | });
870 | }
871 | };
872 |
873 | Modal.prototype.toggleModal = function toggleModal() {
874 | var _this3 = this;
875 |
876 | if (!this.state.isActive) {
877 | this.setState({ isActive: !this.state.isActive });
878 | mui.overlay('on', this.base, { onclose: function () {
879 | _this3.setState({ isActive: !_this3.state.isActive });
880 | _this3.props.onClose();
881 | } });
882 | }
883 | };
884 |
885 | Modal.prototype.render = function render(_ref, _ref2) {
886 | var isActive = _ref2.isActive;
887 | var children = _ref.children,
888 | props = objectWithoutProperties(_ref, ['children']);
889 |
890 | return preact.h(
891 | 'div',
892 | { style: ModalPositions[this.props.position || 'center'], onClick: function () {
893 | mui.overlay('off');
894 | } },
895 | isActive ? preact.h(
896 | 'div',
897 | props,
898 | children
899 | ) : null
900 | );
901 | };
902 |
903 | return Modal;
904 | }(preact.Component);
905 |
906 | var ModalPositions = {
907 | center: {
908 | display: 'flex',
909 | alignItems: 'center',
910 | justifyContent: 'center',
911 | width: '100%',
912 | height: '100%'
913 | },
914 | centerLeft: {
915 | display: 'flex',
916 | alignItems: 'center',
917 | justifyContent: 'flex-start',
918 | width: '100%',
919 | height: '100%'
920 | },
921 | centerRight: {
922 | display: 'flex',
923 | alignItems: 'center',
924 | justifyContent: 'flex-end',
925 | width: '100%',
926 | height: '100%'
927 | },
928 | centerBottom: {
929 | display: 'flex',
930 | alignItems: 'flex-end',
931 | justifyContent: 'center',
932 | width: '100%',
933 | height: '100%'
934 | },
935 | centerTop: {
936 | display: 'flex',
937 | alignItems: 'flex-start',
938 | justifyContent: 'center',
939 | width: '100%',
940 | height: '100%'
941 | }
942 | };
943 |
944 | /**
945 | * MUI NPM Package
946 | * @module pkg/preact.js
947 | */
948 |
949 | /** Define module API */
950 |
951 | module.exports = {
952 | Appbar: Appbar,
953 | Button: Button,
954 | Container: Container,
955 | Divider: Divider,
956 | Dropdown: Dropdown,
957 | DropdownItem: DropdownItem,
958 | Form: Form,
959 | Input: Input,
960 | Checkbox: Checkbox,
961 | Radio: Radio,
962 | Select: Select,
963 | Option: Option,
964 | Textarea: Textarea,
965 | Row: Row,
966 | Col: Col,
967 | Panel: Panel,
968 | Tabs: Tabs,
969 | Tab: Tab,
970 | Modal: Modal
971 | };
972 |
973 | })));
--------------------------------------------------------------------------------
/lib/input.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.input = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Input Module
146 | * @module preact/input
147 | */
148 |
149 | /**
150 | * @name Input
151 | */
152 |
153 | var Input = function (_Component) {
154 | inherits(Input, _Component);
155 |
156 | function Input() {
157 | classCallCheck(this, Input);
158 | return possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).apply(this, arguments));
159 | }
160 |
161 | createClass(Input, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var style = _ref.style,
165 | hint = _ref.hint,
166 | label = _ref.label,
167 | _ref$type = _ref.type,
168 | type = _ref$type === undefined ? 'text' : _ref$type,
169 | required = _ref.required,
170 | defaultValue = _ref.defaultValue,
171 | floatingLabel = _ref.floatingLabel,
172 | props = objectWithoutProperties(_ref, ['style', 'hint', 'label', 'type', 'required', 'defaultValue', 'floatingLabel']);
173 |
174 | var floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
175 | var className = ('mui-textfield ' + floatingLabelClass).trim();
176 | return preact.h(
177 | 'div',
178 | {
179 | 'class': className,
180 | style: style ? style : null
181 | },
182 | preact.h('input', _extends({
183 | type: type,
184 | placeholder: hint,
185 | value: defaultValue ? defaultValue : null,
186 | required: required ? required : null
187 | }, props)),
188 | label ? preact.h(
189 | 'label',
190 | null,
191 | label
192 | ) : null
193 | );
194 | }
195 | }]);
196 | return Input;
197 | }(preact.Component);
198 |
199 | return Input;
200 |
201 | })));
202 |
--------------------------------------------------------------------------------
/lib/modal.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.modal = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var get = function get(object, property, receiver) {
38 | if (object === null) object = Function.prototype;
39 | var desc = Object.getOwnPropertyDescriptor(object, property);
40 |
41 | if (desc === undefined) {
42 | var parent = Object.getPrototypeOf(object);
43 |
44 | if (parent === null) {
45 | return undefined;
46 | } else {
47 | return get(parent, property, receiver);
48 | }
49 | } else if ("value" in desc) {
50 | return desc.value;
51 | } else {
52 | var getter = desc.get;
53 |
54 | if (getter === undefined) {
55 | return undefined;
56 | }
57 |
58 | return getter.call(receiver);
59 | }
60 | };
61 |
62 | var inherits = function (subClass, superClass) {
63 | if (typeof superClass !== "function" && superClass !== null) {
64 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
65 | }
66 |
67 | subClass.prototype = Object.create(superClass && superClass.prototype, {
68 | constructor: {
69 | value: subClass,
70 | enumerable: false,
71 | writable: true,
72 | configurable: true
73 | }
74 | });
75 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
76 | };
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | var objectWithoutProperties = function (obj, keys) {
87 | var target = {};
88 |
89 | for (var i in obj) {
90 | if (keys.indexOf(i) >= 0) continue;
91 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
92 | target[i] = obj[i];
93 | }
94 |
95 | return target;
96 | };
97 |
98 | var possibleConstructorReturn = function (self, call) {
99 | if (!self) {
100 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
101 | }
102 |
103 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
104 | };
105 |
106 |
107 |
108 | var set = function set(object, property, value, receiver) {
109 | var desc = Object.getOwnPropertyDescriptor(object, property);
110 |
111 | if (desc === undefined) {
112 | var parent = Object.getPrototypeOf(object);
113 |
114 | if (parent !== null) {
115 | set(parent, property, value, receiver);
116 | }
117 | } else if ("value" in desc && desc.writable) {
118 | desc.value = value;
119 | } else {
120 | var setter = desc.set;
121 |
122 | if (setter !== undefined) {
123 | setter.call(receiver, value);
124 | }
125 | }
126 |
127 | return value;
128 | };
129 |
130 | /**
131 | * MUI Preact Modal Module
132 | * @module preact/modal
133 | */
134 |
135 | /**
136 | * @name Modal
137 | *
138 | * @param {string} openedBy The element id that will open the modal
139 | * when clicked
140 | *
141 | * @param {string} closedBy The element id that will close the modal
142 | * when clicked
143 | *
144 | * @param {function} onClose The function that will be called
145 | * when modal is closed
146 | */
147 |
148 | var Modal = function (_Component) {
149 | inherits(Modal, _Component);
150 |
151 | function Modal() {
152 | var _ref;
153 |
154 | var _temp, _this, _ret;
155 |
156 | classCallCheck(this, Modal);
157 |
158 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
159 | args[_key] = arguments[_key];
160 | }
161 |
162 | return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = Modal.__proto__ || Object.getPrototypeOf(Modal)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
163 | isActive: false
164 | }, _temp), possibleConstructorReturn(_this, _ret);
165 | }
166 |
167 | createClass(Modal, [{
168 | key: 'componentDidMount',
169 | value: function componentDidMount() {
170 | var _this2 = this;
171 |
172 | if (this.props.openedBy !== undefined) {
173 | var openedBy = document.querySelector('#' + this.props.openedBy);
174 | openedBy.addEventListener('click', function () {
175 | _this2.toggleModal();
176 | });
177 | } else if (this.props.closedBy !== undefined) {
178 | var closedByElement = document.querySelector('#' + this.props.closedBy);
179 | closedByElement.addEventListener('click', function () {
180 | _this2.toggleModal();
181 | mui.overlay('off');
182 | });
183 | }
184 | }
185 | }, {
186 | key: 'toggleModal',
187 | value: function toggleModal() {
188 | var _this3 = this;
189 |
190 | if (!this.state.isActive) {
191 | this.setState({ isActive: !this.state.isActive });
192 | mui.overlay('on', this.base, { onclose: function onclose() {
193 | _this3.setState({ isActive: !_this3.state.isActive });
194 | _this3.props.onClose();
195 | } });
196 | }
197 | }
198 | }, {
199 | key: 'render',
200 | value: function render(_ref2, _ref3) {
201 | var isActive = _ref3.isActive;
202 | var children = _ref2.children,
203 | props = objectWithoutProperties(_ref2, ['children']);
204 |
205 | return preact.h(
206 | 'div',
207 | { style: ModalPositions[this.props.position || 'center'], onClick: function onClick() {
208 | mui.overlay('off');
209 | } },
210 | isActive ? preact.h(
211 | 'div',
212 | props,
213 | children
214 | ) : null
215 | );
216 | }
217 | }]);
218 | return Modal;
219 | }(preact.Component);
220 |
221 | var ModalPositions = {
222 | center: {
223 | display: 'flex',
224 | alignItems: 'center',
225 | justifyContent: 'center',
226 | width: '100%',
227 | height: '100%'
228 | },
229 | centerLeft: {
230 | display: 'flex',
231 | alignItems: 'center',
232 | justifyContent: 'flex-start',
233 | width: '100%',
234 | height: '100%'
235 | },
236 | centerRight: {
237 | display: 'flex',
238 | alignItems: 'center',
239 | justifyContent: 'flex-end',
240 | width: '100%',
241 | height: '100%'
242 | },
243 | centerBottom: {
244 | display: 'flex',
245 | alignItems: 'flex-end',
246 | justifyContent: 'center',
247 | width: '100%',
248 | height: '100%'
249 | },
250 | centerTop: {
251 | display: 'flex',
252 | alignItems: 'flex-start',
253 | justifyContent: 'center',
254 | width: '100%',
255 | height: '100%'
256 | }
257 | };
258 |
259 | return Modal;
260 |
261 | })));
262 |
--------------------------------------------------------------------------------
/lib/option.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.option = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Option Module
146 | * @module preact/option
147 | */
148 |
149 | /**
150 | * @name Option
151 | */
152 |
153 | var Option = function (_Component) {
154 | inherits(Option, _Component);
155 |
156 | function Option() {
157 | classCallCheck(this, Option);
158 | return possibleConstructorReturn(this, (Option.__proto__ || Object.getPrototypeOf(Option)).apply(this, arguments));
159 | }
160 |
161 | createClass(Option, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var label = _ref.label,
165 | value = _ref.value,
166 | props = objectWithoutProperties(_ref, ['label', 'value']);
167 |
168 | return preact.h(
169 | 'option',
170 | _extends({}, props, { value: value }),
171 | label
172 | );
173 | }
174 | }]);
175 | return Option;
176 | }(preact.Component);
177 |
178 | return Option;
179 |
180 | })));
181 |
--------------------------------------------------------------------------------
/lib/panel.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.panel = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Panel Module
146 | * @module preact/panel
147 | */
148 |
149 | /**
150 | * @name Panel
151 | */
152 |
153 | var Panel = function (_Component) {
154 | inherits(Panel, _Component);
155 |
156 | function Panel() {
157 | classCallCheck(this, Panel);
158 | return possibleConstructorReturn(this, (Panel.__proto__ || Object.getPrototypeOf(Panel)).apply(this, arguments));
159 | }
160 |
161 | createClass(Panel, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var children = _ref.children,
165 | props = objectWithoutProperties(_ref, ['children']);
166 |
167 | return preact.h(
168 | 'div',
169 | _extends({ 'class': 'mui-panel' }, props),
170 | children
171 | );
172 | }
173 | }]);
174 | return Panel;
175 | }(preact.Component);
176 |
177 | return Panel;
178 |
179 | })));
180 |
--------------------------------------------------------------------------------
/lib/radio.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.radio = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Radio Module
146 | * @module preact/radio
147 | */
148 |
149 | /**
150 | * @name Radio
151 | */
152 |
153 | var Radio = function (_Component) {
154 | inherits(Radio, _Component);
155 |
156 | function Radio() {
157 | classCallCheck(this, Radio);
158 | return possibleConstructorReturn(this, (Radio.__proto__ || Object.getPrototypeOf(Radio)).apply(this, arguments));
159 | }
160 |
161 | createClass(Radio, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var name = _ref.name,
165 | _ref$defaultChecked = _ref.defaultChecked,
166 | defaultChecked = _ref$defaultChecked === undefined ? false : _ref$defaultChecked,
167 | checked = _ref.checked,
168 | label = _ref.label,
169 | disabled = _ref.disabled,
170 | props = objectWithoutProperties(_ref, ['name', 'defaultChecked', 'checked', 'label', 'disabled']);
171 |
172 | return preact.h(
173 | 'div',
174 | { 'class': 'mui-radio' },
175 | preact.h(
176 | 'label',
177 | null,
178 | preact.h('input', _extends({}, props, {
179 | type: 'radio',
180 | name: name,
181 | checked: defaultChecked || checked,
182 | disabled: disabled ? 'disabled' : null
183 | })),
184 | label
185 | )
186 | );
187 | }
188 | }]);
189 | return Radio;
190 | }(preact.Component);
191 |
192 | return Radio;
193 |
194 | })));
195 |
--------------------------------------------------------------------------------
/lib/row.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.row = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Row Module
146 | * @module preact/row
147 | */
148 |
149 | /**
150 | * @name Row
151 | */
152 |
153 | var Row = function (_Component) {
154 | inherits(Row, _Component);
155 |
156 | function Row() {
157 | classCallCheck(this, Row);
158 | return possibleConstructorReturn(this, (Row.__proto__ || Object.getPrototypeOf(Row)).apply(this, arguments));
159 | }
160 |
161 | createClass(Row, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var children = _ref.children,
165 | props = objectWithoutProperties(_ref, ['children']);
166 |
167 | return preact.h(
168 | 'div',
169 | _extends({ 'class': 'mui-row' }, props),
170 | children
171 | );
172 | }
173 | }]);
174 | return Row;
175 | }(preact.Component);
176 |
177 | return Row;
178 |
179 | })));
180 |
--------------------------------------------------------------------------------
/lib/select.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.select = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Select Module
146 | * @module preact/select
147 | */
148 |
149 | /**
150 | * @name Select
151 | */
152 |
153 | var Select = function (_Component) {
154 | inherits(Select, _Component);
155 |
156 | function Select() {
157 | classCallCheck(this, Select);
158 | return possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).apply(this, arguments));
159 | }
160 |
161 | createClass(Select, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var style = _ref.style,
165 | children = _ref.children,
166 | label = _ref.label,
167 | _ref$defaultValue = _ref.defaultValue,
168 | defaultValue = _ref$defaultValue === undefined ? false : _ref$defaultValue,
169 | _ref$disabled = _ref.disabled,
170 | disabled = _ref$disabled === undefined ? false : _ref$disabled,
171 | props = objectWithoutProperties(_ref, ['style', 'children', 'label', 'defaultValue', 'disabled']);
172 |
173 | return preact.h(
174 | 'div',
175 | { 'class': 'mui-select', style: style },
176 | preact.h(
177 | 'select',
178 | _extends({}, props, { disabled: disabled, value: defaultValue }),
179 | label ? preact.h(
180 | 'label',
181 | null,
182 | label
183 | ) : null,
184 | children
185 | )
186 | );
187 | }
188 | }]);
189 | return Select;
190 | }(preact.Component);
191 |
192 | return Select;
193 |
194 | })));
195 |
--------------------------------------------------------------------------------
/lib/tab.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.tab = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Tab Module
146 | * @module preact/tab
147 | */
148 |
149 | function renderTabMuiChildren(props) {
150 | var div = document.createElement('div');
151 | div.classList.add('mui-tabs__pane');
152 | div.id = props.value;
153 | if (props.selected === true) {
154 | div.classList.add('mui--is-active');
155 | }
156 | div.appendChild(preact.render(props.children[0]));
157 | return div;
158 | }
159 | /**
160 | * @name Tab
161 | */
162 |
163 | var Tab = function (_Component) {
164 | inherits(Tab, _Component);
165 |
166 | function Tab() {
167 | classCallCheck(this, Tab);
168 | return possibleConstructorReturn(this, (Tab.__proto__ || Object.getPrototypeOf(Tab)).apply(this, arguments));
169 | }
170 |
171 | createClass(Tab, [{
172 | key: 'componentDidUpdate',
173 | value: function componentDidUpdate() {
174 | var div = renderTabMuiChildren(this.props);
175 | this.base.parentElement.insertAdjacentElement('afterend', div);
176 | }
177 | }, {
178 | key: 'componentDidMount',
179 | value: function componentDidMount() {
180 | var div = renderTabMuiChildren(this.props);
181 | this.base.parentElement.insertAdjacentElement('afterend', div);
182 | }
183 | }, {
184 | key: 'render',
185 | value: function render(_ref) {
186 | var value = _ref.value,
187 | selected = _ref.selected,
188 | label = _ref.label,
189 | props = objectWithoutProperties(_ref, ['value', 'selected', 'label']);
190 |
191 | return preact.h(
192 | 'li',
193 | _extends({}, props, { 'class': selected ? 'mui--is-active' : null }),
194 | preact.h(
195 | 'a',
196 | { 'data-mui-toggle': 'tab', 'data-mui-controls': value },
197 | ' ',
198 | label,
199 | ' '
200 | )
201 | );
202 | }
203 | }]);
204 | return Tab;
205 | }(preact.Component);
206 |
207 | return Tab;
208 |
209 | })));
210 |
--------------------------------------------------------------------------------
/lib/tabs.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.tabs = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Tabs Module
146 | * @module preact/tabs
147 | */
148 | /**
149 | * @name Tabs
150 | */
151 |
152 | var Tabs = function (_Component) {
153 | inherits(Tabs, _Component);
154 |
155 | function Tabs() {
156 | classCallCheck(this, Tabs);
157 | return possibleConstructorReturn(this, (Tabs.__proto__ || Object.getPrototypeOf(Tabs)).apply(this, arguments));
158 | }
159 |
160 | createClass(Tabs, [{
161 | key: 'render',
162 | value: function render(_ref) {
163 | var children = _ref.children,
164 | justified = _ref.justified,
165 | initialSelectedIndex = _ref.initialSelectedIndex,
166 | props = objectWithoutProperties(_ref, ['children', 'justified', 'initialSelectedIndex']);
167 |
168 | var className = justified ? 'mui-tabs__bar mui-tabs__bar--justified' : 'mui-tabs__bar';
169 | return preact.h(
170 | 'ul',
171 | _extends({ 'class': className }, props),
172 | children
173 | );
174 | }
175 | }]);
176 | return Tabs;
177 | }(preact.Component);
178 |
179 | return Tabs;
180 |
181 | })));
182 |
--------------------------------------------------------------------------------
/lib/textarea.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
3 | typeof define === 'function' && define.amd ? define(['preact'], factory) :
4 | (global.textarea = factory(global.Preact));
5 | }(this, (function (preact) { 'use strict';
6 |
7 | var classCallCheck = function (instance, Constructor) {
8 | if (!(instance instanceof Constructor)) {
9 | throw new TypeError("Cannot call a class as a function");
10 | }
11 | };
12 |
13 | var createClass = function () {
14 | function defineProperties(target, props) {
15 | for (var i = 0; i < props.length; i++) {
16 | var descriptor = props[i];
17 | descriptor.enumerable = descriptor.enumerable || false;
18 | descriptor.configurable = true;
19 | if ("value" in descriptor) descriptor.writable = true;
20 | Object.defineProperty(target, descriptor.key, descriptor);
21 | }
22 | }
23 |
24 | return function (Constructor, protoProps, staticProps) {
25 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
26 | if (staticProps) defineProperties(Constructor, staticProps);
27 | return Constructor;
28 | };
29 | }();
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | var _extends = Object.assign || function (target) {
38 | for (var i = 1; i < arguments.length; i++) {
39 | var source = arguments[i];
40 |
41 | for (var key in source) {
42 | if (Object.prototype.hasOwnProperty.call(source, key)) {
43 | target[key] = source[key];
44 | }
45 | }
46 | }
47 |
48 | return target;
49 | };
50 |
51 | var get = function get(object, property, receiver) {
52 | if (object === null) object = Function.prototype;
53 | var desc = Object.getOwnPropertyDescriptor(object, property);
54 |
55 | if (desc === undefined) {
56 | var parent = Object.getPrototypeOf(object);
57 |
58 | if (parent === null) {
59 | return undefined;
60 | } else {
61 | return get(parent, property, receiver);
62 | }
63 | } else if ("value" in desc) {
64 | return desc.value;
65 | } else {
66 | var getter = desc.get;
67 |
68 | if (getter === undefined) {
69 | return undefined;
70 | }
71 |
72 | return getter.call(receiver);
73 | }
74 | };
75 |
76 | var inherits = function (subClass, superClass) {
77 | if (typeof superClass !== "function" && superClass !== null) {
78 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
79 | }
80 |
81 | subClass.prototype = Object.create(superClass && superClass.prototype, {
82 | constructor: {
83 | value: subClass,
84 | enumerable: false,
85 | writable: true,
86 | configurable: true
87 | }
88 | });
89 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
90 | };
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | var objectWithoutProperties = function (obj, keys) {
101 | var target = {};
102 |
103 | for (var i in obj) {
104 | if (keys.indexOf(i) >= 0) continue;
105 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
106 | target[i] = obj[i];
107 | }
108 |
109 | return target;
110 | };
111 |
112 | var possibleConstructorReturn = function (self, call) {
113 | if (!self) {
114 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
115 | }
116 |
117 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
118 | };
119 |
120 |
121 |
122 | var set = function set(object, property, value, receiver) {
123 | var desc = Object.getOwnPropertyDescriptor(object, property);
124 |
125 | if (desc === undefined) {
126 | var parent = Object.getPrototypeOf(object);
127 |
128 | if (parent !== null) {
129 | set(parent, property, value, receiver);
130 | }
131 | } else if ("value" in desc && desc.writable) {
132 | desc.value = value;
133 | } else {
134 | var setter = desc.set;
135 |
136 | if (setter !== undefined) {
137 | setter.call(receiver, value);
138 | }
139 | }
140 |
141 | return value;
142 | };
143 |
144 | /**
145 | * MUI Preact Textarea Module
146 | * @module preact/textarea
147 | */
148 |
149 | /**
150 | * @name Textarea
151 | */
152 |
153 | var Textarea = function (_Component) {
154 | inherits(Textarea, _Component);
155 |
156 | function Textarea() {
157 | classCallCheck(this, Textarea);
158 | return possibleConstructorReturn(this, (Textarea.__proto__ || Object.getPrototypeOf(Textarea)).apply(this, arguments));
159 | }
160 |
161 | createClass(Textarea, [{
162 | key: 'render',
163 | value: function render(_ref) {
164 | var style = _ref.style,
165 | hint = _ref.hint,
166 | label = _ref.label,
167 | required = _ref.required,
168 | defaultValue = _ref.defaultValue,
169 | floatingLabel = _ref.floatingLabel,
170 | props = objectWithoutProperties(_ref, ['style', 'hint', 'label', 'required', 'defaultValue', 'floatingLabel']);
171 |
172 | var floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
173 | var className = ('mui-textfield ' + floatingLabelClass).trim();
174 | return preact.h(
175 | 'div',
176 | {
177 | 'class': className,
178 | style: style ? style : null
179 | },
180 | preact.h('textarea', _extends({
181 | placeholder: hint,
182 | value: defaultValue ? defaultValue : null,
183 | required: required ? required : null
184 | }, props)),
185 | label ? preact.h(
186 | 'label',
187 | null,
188 | label
189 | ) : null
190 | );
191 | }
192 | }]);
193 | return Textarea;
194 | }(preact.Component);
195 |
196 | return Textarea;
197 |
198 | })));
199 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "preact-mui",
3 | "version": "0.1.1",
4 | "description": "Preact MUI CSS Components.",
5 | "main": "lib/index.js",
6 | "jsnext:main": "lib/index.js",
7 | "files": [
8 | "lib/appbar.js",
9 | "lib/button.js",
10 | "lib/checkbox.js",
11 | "lib/col.js",
12 | "lib/container.js",
13 | "lib/divider.js",
14 | "lib/dropdown.js",
15 | "lib/dropdown-item.js",
16 | "lib/form.js",
17 | "lib/input.js",
18 | "lib/modal.js",
19 | "lib/option.js",
20 | "lib/panel.js",
21 | "lib/radio.js",
22 | "lib/row.js",
23 | "lib/select.js",
24 | "lib/tab.js",
25 | "lib/tabs.js",
26 | "lib/textarea.js"
27 | ],
28 | "scripts": {
29 | "build:index": "rollup -c rollup.config.index.js",
30 | "test": "echo \"Error: no test specified\" && exit 1"
31 | },
32 | "author": "Luis Vinicius",
33 | "license": "MIT",
34 | "devDependencies": {
35 | "babel-core": "^6.9.0",
36 | "babel-eslint": "^6.0.4",
37 | "babel-loader": "^6.2.4",
38 | "babel-plugin-external-helpers": "^6.18.0",
39 | "babel-plugin-transform-class-properties": "^6.19.0",
40 | "babel-plugin-transform-es2015-classes": "^6.9.0",
41 | "babel-plugin-transform-es2015-parameters": "^6.18.0",
42 | "babel-plugin-transform-object-rest-spread": "^6.8.0",
43 | "babel-plugin-transform-react-jsx": "^6.8.0",
44 | "babel-preset-es2015": "^6.18.0",
45 | "babel-preset-es2015-loose": "^7.0.0",
46 | "babel-preset-es2015-loose-rollup": "^7.0.0",
47 | "babel-preset-es2015-minimal-rollup": "^2.0.0",
48 | "babel-preset-es2015-rollup": "^1.2.0",
49 | "babel-preset-stage-0": "^6.5.0",
50 | "babelrc-rollup": "^3.0.0",
51 | "preact": "latest",
52 | "rollup": "^0.34.1",
53 | "rollup-plugin-babel": "^2.4.0",
54 | "rollup-plugin-commonjs": "^5.0.5",
55 | "rollup-plugin-node-resolve": "^2.0.0",
56 | "rollup-plugin-replace": "^1.1.1",
57 | "rollup-plugin-uglify": "^1.0.1",
58 | "webpack": "^1.14.0"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/rollup.config.index.js:
--------------------------------------------------------------------------------
1 | import babel from 'rollup-plugin-babel';
2 | import nodeResolve from 'rollup-plugin-node-resolve';
3 | import commonjs from 'rollup-plugin-commonjs';
4 | import replace from 'rollup-plugin-replace';
5 |
6 | export default {
7 | entry : `src/components/index.js`,
8 | dest : `lib/index.js`,
9 | format : 'umd',
10 | moduleName : `preactMui`,
11 | external: [
12 | 'preact', 'preact-render-to-string'
13 | ],
14 | globals: {
15 | preact: 'Preact'
16 | },
17 | plugins : [
18 | nodeResolve({jsnext: true}),
19 | babel({
20 | babelrc: false,
21 | sourceMap: false,
22 | exclude: 'node_modules/**',
23 | presets: [
24 | 'es2015-minimal-rollup', 'stage-0'
25 | ],
26 | plugins: [
27 | [
28 | 'transform-react-jsx', {
29 | pragma: 'h'
30 | }
31 | ]
32 | ]
33 | }),
34 |
35 | commonjs({exclude: ['node_modules/**'], extensions: ['.js'], ignoreGlobal: false, sourceMap: false})
36 |
37 | ]
38 | };
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import babel from 'rollup-plugin-babel';
2 | import nodeResolve from 'rollup-plugin-node-resolve';
3 | import commonjs from 'rollup-plugin-commonjs';
4 | import replace from 'rollup-plugin-replace';
5 |
6 | export default {
7 | entry : `src/components/${process.env.entry}/index.js`,
8 | dest : `lib/${process.env.entry}.js`,
9 | format : 'umd',
10 | external: [
11 | 'preact', 'preact-render-to-string'
12 | ],
13 | globals: {
14 | preact: 'Preact', renderString: 'preact-render-to-string'
15 | },
16 | moduleName: `${process.env.entry}`,
17 | plugins : [
18 | nodeResolve({
19 | jsnext: true
20 | }),
21 | babel({
22 | babelrc: false,
23 | sourceMap: false,
24 | exclude: 'node_modules/**',
25 | presets: [
26 | 'es2015-rollup', 'stage-0'
27 | ],
28 | plugins: [
29 | [
30 | 'transform-react-jsx', {
31 | pragma: 'h'
32 | }
33 | ]
34 | ]
35 | }),
36 |
37 | commonjs({
38 | exclude: [
39 | 'node_modules/**',
40 | ],
41 | extensions: [
42 | '.js'
43 | ],
44 | ignoreGlobal: false,
45 | sourceMap: false,
46 | })
47 |
48 | ]
49 | };
--------------------------------------------------------------------------------
/src/components/appbar/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Appbar Module
3 | * @module preact/appbar
4 | */
5 |
6 | 'use scrict';
7 |
8 | import { h, Component } from 'preact';
9 |
10 | /**
11 | * @name Appbar
12 | */
13 | export default class Appbar extends Component {
14 | render({children, ...props}){
15 | return (
16 |
17 | {children}
18 |
19 | )
20 | }
21 | };
22 |
--------------------------------------------------------------------------------
/src/components/button/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Button Module
3 | * @module preact/button
4 | */
5 | 'use strict';
6 |
7 | import {h, Component} from 'preact';
8 |
9 | /**
10 | * @name Button
11 | */
12 |
13 | export default class Button extends Component {
14 | render({color, variant, children, disabled, size, ...props}) {
15 | let variantClass = variant ? `mui-btn--${variant}` : ''
16 | , colorClass = color ? `mui-btn--${color}` : ''
17 | , sizeClass = size ? `mui-btn--${size}` : ''
18 | , className = `mui-btn ${variantClass} ${colorClass} ${sizeClass}`.trim()
19 | ;
20 | return(
21 |
28 | )
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/components/checkbox/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Checkbox Module
3 | * @module preact/checkbox
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h,Component} from 'preact';
9 |
10 | /**
11 | * @name Checkbox
12 | */
13 | export default class Checkbox extends Component {
14 | render({name, defaultChecked=false, label, disabled, ...props}){
15 | return (
16 |
17 |
27 |
28 | )
29 | }
30 | }
--------------------------------------------------------------------------------
/src/components/col/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Col Module
3 | * @module preact/col
4 | */
5 | 'use strict';
6 |
7 | import {h, Component} from 'preact';
8 |
9 | /**
10 | * @name Col
11 | */
12 | export default class Col extends Component {
13 | render( {children, xs, xsOffset, sm, smOffset, md, mdOffset, lg, lgOffset, xl, xlOffset, ...props} ) {
14 | let colMdClass = md ? `mui-col-md-${md}` : ''
15 | , colXsClass = xs ? `mui-col-xs-${xs}` : ''
16 | , colSmClass = sm ? `mui-col-sm-${sm}` : ''
17 | , colLgClass = lg ? `mui-col-lg-${lg}` : ''
18 | , colXlClass = xl ? `mui-col-xs-${xl}` : ''
19 | , xsOffsetClass = xsOffset ? `mui-col-xs-offset-${xsOffset}` : ''
20 | , smOffsetClass = smOffset ? `mui-col-sm-offset-${smOffset}` : ''
21 | , mdOffsetClass = mdOffset ? `mui-col-md-offset-${mdOffset}` : ''
22 | , lgOffsetClass = lgOffset ? `mui-col-lg-offset-${lgOffset}` : ''
23 | , xlOffsetClass = xlOffset ? `mui-col-xl-offset-${xlOffset}` : ''
24 | , className = `${colXsClass} ${colSmClass} ${colMdClass} ${colLgClass} ${colXlClass} ${xsOffsetClass} ${smOffsetClass} ${mdOffsetClass} ${lgOffsetClass} ${xlOffsetClass}`.trim();
25 | ;
26 |
27 | return (
28 |
29 | {children}
30 |
31 | )
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/components/container/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Container Module
3 | * @module preact/container
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Container
12 | */
13 | export default class Container extends Component {
14 | render({fluid, children, ...props}) {
15 | return (
16 |
22 | {children}
23 |
24 | )
25 | }
26 | }
--------------------------------------------------------------------------------
/src/components/divider/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Divider Module
3 | * @module preact/divider
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 |
11 | /**
12 | * @name Divider
13 | */
14 | export default class Divider extends Component {
15 | render(){
16 | return (
17 |
18 | )
19 | }
20 | }
--------------------------------------------------------------------------------
/src/components/dropdown-item/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact DropdownItem Module
3 | * @module preact/dropdown-item
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name DropdownItem
12 | */
13 | export default class DropdownItem extends Component {
14 | render({ link, children, ...props}) {
15 | return (
16 | {children}
17 | )
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/components/dropdown/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Dropdown Module
3 | * @module preact/dropdown
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 | import Button from '../button';
10 |
11 | /**
12 | * @name Dropdown
13 | */
14 | export default class Dropdown extends Component {
15 | render({label, color, size, variant, disabled, alignMenu, children, ...props}){
16 | return(
17 |
18 |
27 |
30 |
31 | )
32 | }
33 | }
--------------------------------------------------------------------------------
/src/components/form/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Form module
3 | * @module preact/form
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Form
12 | */
13 | export default class Form extends Component {
14 | render({legend, children, inline, ...props}){
15 | return(
16 |
27 | )
28 | }
29 | }
--------------------------------------------------------------------------------
/src/components/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI NPM Package
3 | * @module pkg/preact.js
4 | */
5 |
6 | /** Define module API */
7 |
8 |
9 | import Appbar from './appbar/index.js';
10 | import Button from './button/index.js'
11 | import Container from './container/index.js';
12 | import Divider from './divider/index.js';
13 | import Dropdown from './dropdown/index.js';
14 | import DropdownItem from './dropdown-item/index.js';
15 | import Form from './form/index.js';
16 | import Input from './input/index.js';
17 | import Checkbox from './checkbox/index.js';
18 | import Radio from './radio/index.js';
19 | import Select from './select/index.js';
20 | import Option from './option/index.js';
21 | import Textarea from './textarea/index.js';
22 | import Row from './row/index.js';
23 | import Col from './col/index.js';
24 | import Panel from './panel/index.js';
25 | import Tabs from './tabs/index.js';
26 | import Tab from './tab/index.js';
27 | import Modal from './modal/index.js'
28 |
29 | module.exports = {
30 | Appbar,
31 | Button,
32 | Container,
33 | Divider,
34 | Dropdown,
35 | DropdownItem,
36 | Form,
37 | Input,
38 | Checkbox,
39 | Radio,
40 | Select,
41 | Option,
42 | Textarea,
43 | Row,
44 | Col,
45 | Panel,
46 | Tabs,
47 | Tab,
48 | Modal
49 | }
--------------------------------------------------------------------------------
/src/components/input/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Input Module
3 | * @module preact/input
4 | */
5 |
6 | 'use strict';
7 |
8 | import { h, Component } from 'preact';
9 |
10 | /**
11 | * @name Input
12 | */
13 | export default class Input extends Component {
14 | render({style, hint, label, type='text', required, defaultValue, floatingLabel, ...props}){
15 | let floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
16 | let className = `mui-textfield ${floatingLabelClass}`.trim();
17 | return(
18 |
22 |
29 | { label
30 | ? ()
31 | : null
32 | }
33 |
34 | )
35 | }
36 | }
--------------------------------------------------------------------------------
/src/components/modal/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Modal Module
3 | * @module preact/modal
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Modal
12 | *
13 | * @param {string} openedBy The element id that will open the modal
14 | * when clicked
15 | *
16 | * @param {string} closedBy The element id that will close the modal
17 | * when clicked
18 | *
19 | * @param {function} onClose The function that will be called
20 | * when modal is closed
21 | */
22 | export default class Modal extends Component {
23 | state = {
24 | isActive: false
25 | }
26 | componentDidMount ( ) {
27 | if (this.props.openedBy !== undefined) {
28 | let openedBy = document.querySelector(`#${this.props.openedBy}`)
29 | openedBy.addEventListener('click', () => {
30 | this.toggleModal();
31 | })
32 | } else if (this.props.closedBy !== undefined) {
33 | let closedByElement = document.querySelector(`#${this.props.closedBy}`)
34 | closedByElement.addEventListener('click', () => {
35 | this.toggleModal();
36 | mui.overlay('off');
37 | })
38 | }
39 | }
40 | toggleModal() {
41 | if (!this.state.isActive) {
42 | this.setState({isActive: !this.state.isActive})
43 | mui.overlay('on', this.base, { onclose: () => {
44 | this.setState({isActive: !this.state.isActive});
45 | this.props.onClose();
46 | }});
47 | }
48 | }
49 |
50 | render({children, ...props}, {isActive}){
51 | return (
52 | {mui.overlay('off');}}>
53 | {isActive ? (
{children}
) : null}
54 |
55 | )
56 | }
57 | }
58 |
59 | let ModalPositions = {
60 | center: {
61 | display: 'flex',
62 | alignItems: 'center',
63 | justifyContent: 'center',
64 | width: '100%',
65 | height:'100%'
66 | },
67 | centerLeft: {
68 | display: 'flex',
69 | alignItems: 'center',
70 | justifyContent: 'flex-start',
71 | width: '100%',
72 | height:'100%'
73 | },
74 | centerRight: {
75 | display: 'flex',
76 | alignItems: 'center',
77 | justifyContent: 'flex-end',
78 | width: '100%',
79 | height:'100%'
80 | },
81 | centerBottom: {
82 | display: 'flex',
83 | alignItems: 'flex-end',
84 | justifyContent: 'center',
85 | width: '100%',
86 | height:'100%'
87 | },
88 | centerTop: {
89 | display: 'flex',
90 | alignItems: 'flex-start',
91 | justifyContent: 'center',
92 | width: '100%',
93 | height:'100%'
94 | }
95 | }
--------------------------------------------------------------------------------
/src/components/option/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Option Module
3 | * @module preact/option
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Option
12 | */
13 | export default class Option extends Component {
14 | render({label, value, ...props}){
15 | return(
16 |
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/src/components/panel/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Panel Module
3 | * @module preact/panel
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Panel
12 | */
13 | export default class Panel extends Component {
14 | render({children, ...props}){
15 | return (
16 |
17 | {children}
18 |
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/src/components/radio/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Radio Module
3 | * @module preact/radio
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Radio
12 | */
13 | export default class Radio extends Component {
14 | render({name, defaultChecked=false, checked, label, disabled, ...props}){
15 | return (
16 |
17 |
27 |
28 | )
29 | }
30 | }
--------------------------------------------------------------------------------
/src/components/row/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Row Module
3 | * @module preact/row
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Row
12 | */
13 | export default class Row extends Component {
14 | render({ children, ...props}){
15 | return (
16 |
17 | {children}
18 |
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/src/components/select/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Select Module
3 | * @module preact/select
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 |
10 | /**
11 | * @name Select
12 | */
13 | export default class Select extends Component {
14 | render({style, children, label, defaultValue=false, disabled=false, ...props}){
15 | return (
16 |
17 |
21 |
22 |
23 | )
24 | }
25 | }
--------------------------------------------------------------------------------
/src/components/tab/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Tab Module
3 | * @module preact/tab
4 | */
5 |
6 | 'use strict';
7 |
8 | import {h, Component} from 'preact';
9 | import {render as renderer} from 'preact';
10 |
11 | function renderTabMuiChildren(props){
12 | let div = document.createElement('div');
13 | div.classList.add('mui-tabs__pane');
14 | div.id = props.value;
15 | if ( props.selected === true ) {
16 | div.classList.add('mui--is-active');
17 | }
18 | div.appendChild(renderer(props.children[0]))
19 | return div;
20 | }
21 | /**
22 | * @name Tab
23 | */
24 | export default class Tab extends Component {
25 | componentDidUpdate(){
26 | let div = renderTabMuiChildren(this.props);
27 | this.base.parentElement.insertAdjacentElement('afterend', div);
28 | }
29 | componentDidMount(){
30 | let div = renderTabMuiChildren(this.props);
31 | this.base.parentElement.insertAdjacentElement('afterend', div);
32 | }
33 | render({value, selected, label, ...props}) {
34 | return (
35 |
36 | {label}
37 |
38 | )
39 | }
40 | }
--------------------------------------------------------------------------------
/src/components/tabs/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Tabs Module
3 | * @module preact/tabs
4 | */
5 | 'use strict';
6 |
7 | import {h, Component} from 'preact';
8 |
9 | /**
10 | * @name Tabs
11 | */
12 | export default class Tabs extends Component {
13 | render({children, justified, initialSelectedIndex, ...props}) {
14 | let className = justified ? 'mui-tabs__bar mui-tabs__bar--justified' : 'mui-tabs__bar';
15 | return (
16 |
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/src/components/textarea/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MUI Preact Textarea Module
3 | * @module preact/textarea
4 | */
5 |
6 | 'use strict';
7 |
8 | import { h, Component } from 'preact';
9 |
10 | /**
11 | * @name Textarea
12 | */
13 | export default class Textarea extends Component {
14 | render({style, hint, label, required, defaultValue, floatingLabel, ...props}){
15 | let floatingLabelClass = floatingLabel ? ' mui-textfield--float-label' : '';
16 | let className = `mui-textfield ${floatingLabelClass}`.trim();
17 | return(
18 |
22 |
28 | { label
29 | ? ()
30 | : null
31 | }
32 |
33 | )
34 | }
35 | }
--------------------------------------------------------------------------------