material 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -10
- package/package.json +1 -1
- package/scripts/doccoAssistant.js +25 -0
- package/src/appbar.js +2 -4
- package/src/badge.js +6 -13
- package/src/button.js +10 -18
- package/src/calendar.js +23 -48
- package/src/card.js +2 -4
- package/src/checkbox.js +2 -7
- package/src/class/component.js +19 -0
- package/src/class/control.js +33 -0
- package/src/component.js +7 -41
- package/src/datehour.js +2 -4
- package/src/dialog.js +3 -5
- package/src/drawer.js +12 -12
- package/src/element.js +16 -20
- package/src/file.js +6 -4
- package/src/form/build.js +2 -2
- package/src/form.js +9 -22
- package/src/icon.js +6 -34
- package/src/image.js +1 -3
- package/src/item.js +3 -3
- package/src/link.js +1 -3
- package/src/list/build.js +2 -2
- package/src/list/render.js +5 -7
- package/src/list/select.js +4 -2
- package/src/list/update.js +2 -2
- package/src/list.js +12 -13
- package/src/loader.js +4 -7
- package/src/loading.js +2 -8
- package/src/map.js +27 -32
- package/src/menu.js +2 -2
- package/src/mixin/build.js +68 -0
- package/src/mixin/emitter.js +0 -2
- package/src/module/build.js +51 -46
- package/src/module/clone.js +15 -0
- package/src/module/dot.js +15 -9
- package/src/module/events.js +2 -0
- package/src/module/layout.js +75 -0
- package/src/module/merge.js +22 -0
- package/src/navigation.js +4 -3
- package/src/progress.js +9 -24
- package/src/search.js +3 -2
- package/src/select.js +2 -2
- package/src/selecter.js +5 -4
- package/src/selector.js +23 -41
- package/src/slider.js +33 -55
- package/src/snackbar.js +1 -1
- package/src/switch.js +1 -1
- package/src/switcher.js +1 -1
- package/src/tabs.js +12 -19
- package/src/tabview.js +1 -1
- package/src/text.js +2 -4
- package/src/textfield.js +1 -3
- package/src/toolbar.js +6 -20
- package/src/tooltip.js +14 -24
- package/src/tree.js +10 -14
- package/src/view/build.js +2 -2
- package/src/view.js +2 -2
- package/src/divider.js +0 -60
- package/src/layout.js +0 -106
package/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
// base classes
|
|
2
|
+
import Control from './src/class/control'
|
|
3
|
+
import Component from './src/class/component'
|
|
4
|
+
// components
|
|
1
5
|
import AppBar from './src/appbar'
|
|
2
6
|
import Badge from './src/badge'
|
|
3
7
|
import Button from './src/button'
|
|
4
8
|
import Card from './src/card'
|
|
5
9
|
import Checkbox from './src/checkbox'
|
|
6
|
-
import Component from './src/component'
|
|
7
10
|
import DateHour from './src/datehour'
|
|
8
11
|
import Dialog from './src/dialog'
|
|
9
12
|
import Drawer from './src/drawer'
|
|
@@ -11,7 +14,6 @@ import Element from './src/element'
|
|
|
11
14
|
import File from './src/file'
|
|
12
15
|
import Form from './src/form'
|
|
13
16
|
import Image from './src/image'
|
|
14
|
-
import Layout from './src/layout'
|
|
15
17
|
import List from './src/list'
|
|
16
18
|
import Loading from './src/loading'
|
|
17
19
|
import Menu from './src/menu'
|
|
@@ -31,22 +33,34 @@ import Toolbar from './src/toolbar'
|
|
|
31
33
|
import Tooltip from './src/tooltip'
|
|
32
34
|
import View from './src/view'
|
|
33
35
|
import attributes from './src/module/attributes'
|
|
34
|
-
|
|
36
|
+
// mixins
|
|
37
|
+
import EventEmitter from './src/mixin/emitter'
|
|
38
|
+
import display from './src/mixin/display'
|
|
39
|
+
import build from './src/mixin/build'
|
|
40
|
+
// modules
|
|
41
|
+
import clone from './src/module/clone'
|
|
35
42
|
import dataset from './src/module/dataset'
|
|
36
43
|
import device from './src/module/device'
|
|
37
|
-
import display from './src/mixin/display'
|
|
38
|
-
import request from './src/module/request'
|
|
39
|
-
import events from './src/module/events'
|
|
40
44
|
import emitter from './src/module/emitter'
|
|
45
|
+
import events from './src/module/events'
|
|
41
46
|
import jsonToHTML from './src/module/jsontohtml'
|
|
47
|
+
import { create } from './src/module/layout'
|
|
42
48
|
import mediator from './src/module/mediator'
|
|
49
|
+
import merge from './src/module/merge'
|
|
43
50
|
import observer from './src/module/observer'
|
|
51
|
+
import request from './src/module/request'
|
|
52
|
+
import ripple from './src/module/ripple'
|
|
44
53
|
import smoothscroll from './src/module/smoothscroll'
|
|
45
54
|
|
|
46
55
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
// classes
|
|
57
|
+
Component, Control,
|
|
58
|
+
AppBar, Button, Card, Checkbox, DateHour, Dialog, Drawer, Element,
|
|
59
|
+
File, Form, Image, List, Loading, Menu, Navigation, Progress, Select,
|
|
49
60
|
Selecter, Slider, Snackbar, Switch, Switcher, Tabs, TabView, Text, Textfield, Toolbar, Tooltip,
|
|
50
|
-
View,
|
|
51
|
-
|
|
61
|
+
View,
|
|
62
|
+
// mixins and modules
|
|
63
|
+
EventEmitter,
|
|
64
|
+
attributes, build, clone, create, dataset, device, display, events, emitter, jsonToHTML, mediator, merge,
|
|
65
|
+
observer, request, ripple, smoothscroll
|
|
52
66
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
|
|
5
|
+
// Construct __dirname equivalent for ES module
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
|
|
8
|
+
const doccoOutputDir = path.join(__dirname, '../docs/src') // Path to Docco output directory
|
|
9
|
+
const indexFilePath = path.join(__dirname, '..', 'docs', 'index.html') // Path to your index file
|
|
10
|
+
|
|
11
|
+
let indexContent = '<html><head><title>Library Index</title></head><body>'
|
|
12
|
+
indexContent += '<h1>Index of Documented Modules</h1><ul>'
|
|
13
|
+
|
|
14
|
+
fs.readdirSync(doccoOutputDir).forEach(file => {
|
|
15
|
+
console.log('file', file)
|
|
16
|
+
if (path.extname(file) === '.html') {
|
|
17
|
+
const moduleName = path.basename(file, '.html')
|
|
18
|
+
indexContent += `<li><a href="src/${file}">${moduleName}</a></li>`
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
indexContent += '</ul></body></html>'
|
|
23
|
+
|
|
24
|
+
fs.writeFileSync(indexFilePath, indexContent, 'utf8')
|
|
25
|
+
console.log('Index file generated at:', indexFilePath)
|
package/src/appbar.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import build from './
|
|
1
|
+
import build from './mixin/build'
|
|
2
2
|
|
|
3
3
|
class AppBar {
|
|
4
|
-
static uid = "material-appbar";
|
|
5
|
-
|
|
6
4
|
static defaults = {
|
|
7
5
|
class: 'appbar'
|
|
8
6
|
}
|
|
@@ -13,7 +11,7 @@ class AppBar {
|
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
init (options) {
|
|
16
|
-
this.options =
|
|
14
|
+
this.options = { ...AppBar.defaults, ...options }
|
|
17
15
|
Object.assign(this, build)
|
|
18
16
|
}
|
|
19
17
|
}
|
package/src/badge.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import build from '
|
|
2
|
-
import display from './mixin/display'
|
|
1
|
+
import { Component, build, display } from '../index'
|
|
3
2
|
|
|
4
3
|
const isStringNumber = (str) => !isNaN(parseFloat(str)) && isFinite(str)
|
|
5
4
|
|
|
6
|
-
class Badge {
|
|
7
|
-
static uid = "material-badge";
|
|
8
|
-
|
|
5
|
+
class Badge extends Component {
|
|
9
6
|
static defaults = {
|
|
10
|
-
class: 'badge'
|
|
7
|
+
class: 'badge',
|
|
8
|
+
mixins: [build, display]
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
constructor (options) {
|
|
14
|
-
|
|
15
|
-
this.build()
|
|
16
|
-
}
|
|
12
|
+
super(options)
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
this.options = Object.assign({}, Badge.defaults, options || {})
|
|
20
|
-
Object.assign(this, build, display)
|
|
14
|
+
this.build()
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
set (text) {
|
|
@@ -29,7 +23,6 @@ class Badge {
|
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
inc (value) {
|
|
32
|
-
// console.log('inc', value)
|
|
33
26
|
let actual = this.element.innerHTML
|
|
34
27
|
|
|
35
28
|
if (actual === '') actual = '0'
|
package/src/button.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
Control,
|
|
3
|
+
display,
|
|
4
|
+
dataset,
|
|
5
|
+
ripple
|
|
6
|
+
} from '../index'
|
|
7
7
|
|
|
8
8
|
const DEFAULT_TYPE = 'button'
|
|
9
9
|
const DEFAULT_CLASS = 'button'
|
|
10
10
|
|
|
11
|
-
class Button extends
|
|
11
|
+
class Button extends Control {
|
|
12
12
|
static isComponent () {
|
|
13
13
|
return true
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
static defaults = {
|
|
17
|
-
class:
|
|
17
|
+
class: 'button',
|
|
18
18
|
tag: 'button',
|
|
19
19
|
styles: ['style', 'color'],
|
|
20
|
+
mixins: [display],
|
|
20
21
|
ripple: true,
|
|
21
22
|
stopPropagation: false,
|
|
22
23
|
events: [
|
|
@@ -30,18 +31,11 @@ class Button extends EventEmitter {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
constructor (options) {
|
|
33
|
-
super()
|
|
34
|
+
super(options)
|
|
34
35
|
|
|
35
|
-
this.init(options)
|
|
36
|
-
this.build()
|
|
37
36
|
this.setup()
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
init (options) {
|
|
41
|
-
this.options = { ...Button.defaults, ...options }
|
|
42
|
-
Object.assign(this, build, display)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
setup () {
|
|
46
40
|
this.setAttributes()
|
|
47
41
|
this.styleAttributes()
|
|
@@ -49,8 +43,6 @@ class Button extends EventEmitter {
|
|
|
49
43
|
if (this.options.text) {
|
|
50
44
|
this.element.innerHTML = this.element.innerHTML + this.options.text
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
events.attach(this.options.events, this)
|
|
54
46
|
}
|
|
55
47
|
|
|
56
48
|
setAttributes () {
|
package/src/calendar.js
CHANGED
|
@@ -8,56 +8,32 @@ import Button from './button'
|
|
|
8
8
|
import iconBack from './skin/material/icon/back.svg'
|
|
9
9
|
import iconForward from './skin/material/icon/forward.svg'
|
|
10
10
|
|
|
11
|
-
const defaults = {
|
|
12
|
-
prefix: 'material',
|
|
13
|
-
class: 'calendar',
|
|
14
|
-
target: '.week-day',
|
|
15
|
-
functions: ['newEvent'],
|
|
16
|
-
rangedays: 7,
|
|
17
|
-
months: ['January', 'February', 'Mars', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
18
|
-
days: ['Sunday', 'Monday', 'Tuesday', 'wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
19
|
-
mode: 'view',
|
|
20
|
-
range: [8, 18],
|
|
21
|
-
display: 'three',
|
|
22
|
-
weekend: [0, 1],
|
|
23
|
-
events: [
|
|
24
|
-
['root.dblclick', 'add']
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* List view class
|
|
30
|
-
* @class
|
|
31
|
-
* @param {Object} options Default options for view
|
|
32
|
-
* @extends {View}
|
|
33
|
-
* @since 0.0.4
|
|
34
|
-
* @author Jerome Vial
|
|
35
|
-
*
|
|
36
|
-
* @type {prime}
|
|
37
|
-
*/
|
|
38
11
|
class Calendar {
|
|
39
|
-
static
|
|
12
|
+
static defaults = {
|
|
13
|
+
prefix: 'material',
|
|
14
|
+
class: 'calendar',
|
|
15
|
+
target: '.week-day',
|
|
16
|
+
functions: ['newEvent'],
|
|
17
|
+
rangedays: 7,
|
|
18
|
+
months: ['January', 'February', 'Mars', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
19
|
+
days: ['Sunday', 'Monday', 'Tuesday', 'wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
20
|
+
mode: 'view',
|
|
21
|
+
range: [8, 18],
|
|
22
|
+
display: 'three',
|
|
23
|
+
weekend: [0, 1],
|
|
24
|
+
events: [
|
|
25
|
+
['root.dblclick', 'add']
|
|
26
|
+
]
|
|
27
|
+
}
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* init
|
|
43
|
-
* @return {Object} The class options
|
|
44
|
-
*/
|
|
45
29
|
constructor (options) {
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
this.init()
|
|
30
|
+
this.init(options)
|
|
49
31
|
this.build()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return this
|
|
32
|
+
this.setup()
|
|
53
33
|
}
|
|
54
34
|
|
|
55
|
-
/**
|
|
56
|
-
* [_initView description]
|
|
57
|
-
* @return Class instance
|
|
58
|
-
*/
|
|
59
35
|
init (options) {
|
|
60
|
-
|
|
36
|
+
this.options = { ...Calendar.defaults, ...options }
|
|
61
37
|
Object.assign(this, emitter, attach)
|
|
62
38
|
|
|
63
39
|
// init function
|
|
@@ -74,11 +50,10 @@ class Calendar {
|
|
|
74
50
|
return this
|
|
75
51
|
}
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
53
|
+
setup () {
|
|
54
|
+
events.attach(this.options.events, this)
|
|
55
|
+
}
|
|
56
|
+
|
|
82
57
|
getFirstDayOfWeek (d) {
|
|
83
58
|
d = new Date(d)
|
|
84
59
|
const day = d.getDay()
|
package/src/card.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import build from './
|
|
1
|
+
import build from './mixin/build'
|
|
2
2
|
import display from './mixin/display'
|
|
3
3
|
import position from './mixin/position'
|
|
4
4
|
|
|
5
5
|
class Card {
|
|
6
|
-
static uid = "material-card";
|
|
7
|
-
|
|
8
6
|
static defaults = {
|
|
9
7
|
class: 'card',
|
|
10
8
|
position: {
|
|
@@ -23,7 +21,7 @@ class Card {
|
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
init (options) {
|
|
26
|
-
this.options =
|
|
24
|
+
this.options = { ...Card.defaults, ...options }
|
|
27
25
|
Object.assign(this, build, display, position)
|
|
28
26
|
}
|
|
29
27
|
}
|
package/src/checkbox.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import EventEmitter from './mixin/events'
|
|
2
2
|
// import control from './mixin/control'
|
|
3
|
-
import build from './
|
|
3
|
+
import build from './mixin/build'
|
|
4
4
|
import events from './module/events'
|
|
5
5
|
import * as css from './module/css'
|
|
6
6
|
|
|
7
7
|
import icon from './skin/material/icon/checkbox.svg'
|
|
8
|
-
|
|
9
8
|
import Element from './element'
|
|
10
9
|
|
|
11
10
|
class Checkbox {
|
|
12
|
-
static uid = "material-checkbox";
|
|
13
|
-
|
|
14
11
|
static defaults = {
|
|
15
12
|
class: 'checkbox',
|
|
16
13
|
layout: [
|
|
@@ -36,10 +33,8 @@ class Checkbox {
|
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
init (options) {
|
|
39
|
-
this.options =
|
|
36
|
+
this.options = { ...Checkbox.defaults, ...options }
|
|
40
37
|
Object.assign(this, build, attach)
|
|
41
|
-
|
|
42
|
-
return this
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
setup () {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import build from '../module/build'
|
|
2
|
+
|
|
3
|
+
class Component {
|
|
4
|
+
static base = 'component'
|
|
5
|
+
|
|
6
|
+
constructor (options) {
|
|
7
|
+
this.options = { ...this.constructor.defaults, ...options }
|
|
8
|
+
|
|
9
|
+
const mixins = this.options.mixins || []
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < mixins.length; i++) {
|
|
12
|
+
Object.assign(this, mixins[i])
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
build(this)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default Component
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Component from './component'
|
|
2
|
+
import events from '../module/events'
|
|
3
|
+
|
|
4
|
+
class Control extends Component {
|
|
5
|
+
static base = 'control'
|
|
6
|
+
|
|
7
|
+
constructor (options) {
|
|
8
|
+
super(options)
|
|
9
|
+
this.events = {}
|
|
10
|
+
|
|
11
|
+
if (this.options.events) {
|
|
12
|
+
events.attach(this.options.events, this)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
on (event, listener) {
|
|
17
|
+
if (!this.events[event]) {
|
|
18
|
+
this.events[event] = []
|
|
19
|
+
}
|
|
20
|
+
this.events[event].push(listener)
|
|
21
|
+
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
emit (event, ...args) {
|
|
26
|
+
if (this.events[event]) {
|
|
27
|
+
this.events[event].forEach(listener => listener.apply(this, args))
|
|
28
|
+
}
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default Control
|
package/src/component.js
CHANGED
|
@@ -4,60 +4,26 @@ import insert from './mixin/insert'
|
|
|
4
4
|
|
|
5
5
|
import emitter from './module/emitter'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
prefix: 'material',
|
|
9
|
-
class: 'component',
|
|
10
|
-
tag: 'span'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Base class for all ui components
|
|
15
|
-
* @class
|
|
16
|
-
* @param {Object} options - The component options
|
|
17
|
-
* @return {Object} The class Instance
|
|
18
|
-
*/
|
|
7
|
+
// Depracted
|
|
19
8
|
|
|
20
|
-
/**
|
|
21
|
-
* Class representing a UI Container. Can add components.
|
|
22
|
-
*
|
|
23
|
-
* @extends Component
|
|
24
|
-
* @return {parent} The class instance
|
|
25
|
-
* @example new Container({
|
|
26
|
-
* container: document.body
|
|
27
|
-
* });
|
|
28
|
-
*/
|
|
29
9
|
class Component {
|
|
30
|
-
static
|
|
10
|
+
static defaults = {
|
|
11
|
+
prefix: 'material',
|
|
12
|
+
class: 'component',
|
|
13
|
+
tag: 'span'
|
|
14
|
+
}
|
|
31
15
|
|
|
32
|
-
/**
|
|
33
|
-
* Constructor
|
|
34
|
-
* @param {Object} options - Component options
|
|
35
|
-
* @return {Object} Class instance
|
|
36
|
-
*/
|
|
37
16
|
constructor (options) {
|
|
38
17
|
this.init(options)
|
|
39
18
|
this.build()
|
|
40
|
-
|
|
41
|
-
return this
|
|
42
19
|
}
|
|
43
20
|
|
|
44
|
-
/**
|
|
45
|
-
* init method
|
|
46
|
-
* @param {Object} Options
|
|
47
|
-
* @return {Object} Instance
|
|
48
|
-
*/
|
|
49
21
|
init (options) {
|
|
50
|
-
this.options =
|
|
22
|
+
this.options = { ...Component.defaults, ...options }
|
|
51
23
|
|
|
52
24
|
Object.assign(this, emitter, events, insert)
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
25
|
}
|
|
56
26
|
|
|
57
|
-
/**
|
|
58
|
-
* Build Method
|
|
59
|
-
* @return {Object} This class instance
|
|
60
|
-
*/
|
|
61
27
|
build () {
|
|
62
28
|
this.element = create(this.options)
|
|
63
29
|
|
package/src/datehour.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import build from './
|
|
1
|
+
import build from './mixin/build'
|
|
2
2
|
|
|
3
3
|
class DateHour {
|
|
4
|
-
static uid = "material-datehour";
|
|
5
|
-
|
|
6
4
|
static defaults = {
|
|
7
5
|
class: 'date',
|
|
8
6
|
tag: 'span'
|
|
@@ -14,7 +12,7 @@ class DateHour {
|
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
init (options) {
|
|
17
|
-
this.options =
|
|
15
|
+
this.options = { ...DateHour.defaults, ...options }
|
|
18
16
|
Object.assign(this, build)
|
|
19
17
|
}
|
|
20
18
|
|
package/src/dialog.js
CHANGED
|
@@ -6,11 +6,9 @@ import display from './mixin/display'
|
|
|
6
6
|
import Element from './element'
|
|
7
7
|
import Text from './text'
|
|
8
8
|
import Button from './button'
|
|
9
|
-
import
|
|
9
|
+
import { create } from './module/layout'
|
|
10
10
|
|
|
11
11
|
class Dialog {
|
|
12
|
-
static uid = "material-dialog";
|
|
13
|
-
|
|
14
12
|
static defaults = {
|
|
15
13
|
class: 'dialog',
|
|
16
14
|
close: true,
|
|
@@ -46,7 +44,7 @@ class Dialog {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
init (options) {
|
|
49
|
-
this.options =
|
|
47
|
+
this.options = { ...Dialog.defaults, ...options }
|
|
50
48
|
Object.assign(this, emitter, display)
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -68,7 +66,7 @@ class Dialog {
|
|
|
68
66
|
this.surface.classList.add('surface')
|
|
69
67
|
this.element.appendChild(this.surface)
|
|
70
68
|
|
|
71
|
-
this.layout =
|
|
69
|
+
this.layout = create(this.options.layout, this.surface)
|
|
72
70
|
this.ui = this.layout.component
|
|
73
71
|
|
|
74
72
|
if (this.options.container) {
|
package/src/drawer.js
CHANGED
|
@@ -6,22 +6,22 @@ import events from './mixin/events'
|
|
|
6
6
|
import create from './element/create'
|
|
7
7
|
import emitter from './module/emitter'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
prefix: 'material',
|
|
11
|
-
class: 'drawer',
|
|
12
|
-
modifier: 'width',
|
|
13
|
-
state: 'closed',
|
|
14
|
-
position: 'left',
|
|
15
|
-
tag: 'div',
|
|
16
|
-
width: '340',
|
|
17
|
-
modules: [emitter, events]
|
|
18
|
-
}
|
|
9
|
+
// Depracted, see Navigation
|
|
19
10
|
|
|
20
11
|
class Drawer {
|
|
21
|
-
static
|
|
12
|
+
static defaults = {
|
|
13
|
+
prefix: 'material',
|
|
14
|
+
class: 'drawer',
|
|
15
|
+
modifier: 'width',
|
|
16
|
+
state: 'closed',
|
|
17
|
+
position: 'left',
|
|
18
|
+
tag: 'div',
|
|
19
|
+
width: '340',
|
|
20
|
+
modules: [emitter, events]
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
constructor (options) {
|
|
24
|
-
this.options =
|
|
24
|
+
this.options = { ...Drawer.defaults, ...options }
|
|
25
25
|
|
|
26
26
|
init(this)
|
|
27
27
|
|
package/src/element.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
class Element {
|
|
2
|
-
static uid = "material-element";
|
|
3
|
-
|
|
4
2
|
static isElement () {
|
|
5
3
|
return true
|
|
6
4
|
}
|
|
7
5
|
|
|
8
|
-
constructor (options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const element = document.createElement(this.options.tag || 'div')
|
|
12
|
-
|
|
13
|
-
const container = this.options.container
|
|
14
|
-
delete this.options.container
|
|
15
|
-
delete this.options.tag
|
|
16
|
-
|
|
17
|
-
if (options.html) element.innerHTML = this.options.html
|
|
18
|
-
delete this.options.html
|
|
6
|
+
constructor (options = {}) {
|
|
7
|
+
// Use the spread operator for default options
|
|
8
|
+
this.options = { tag: 'div', container: null, html: '', text: '', id: '', ...options }
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
delete this.options.text
|
|
10
|
+
const element = document.createElement(this.options.tag)
|
|
22
11
|
|
|
23
|
-
|
|
12
|
+
// Apply HTML, text, and id if provided
|
|
13
|
+
if (this.options.html) element.innerHTML = this.options.html
|
|
14
|
+
if (this.options.text) element.textContent = this.options.text
|
|
15
|
+
if (this.options.id) element.setAttribute('id', this.options.id)
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
// Apply additional attributes
|
|
18
|
+
for (const key in this.options) {
|
|
19
|
+
if (!['tag', 'container', 'html', 'text', 'id'].includes(key)) {
|
|
20
|
+
element.setAttribute(key, this.options[key])
|
|
21
|
+
}
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
// Append to container if available
|
|
25
|
+
if (this.options.container) {
|
|
26
|
+
this.options.container.appendChild(element)
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
return element
|
package/src/file.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import EventEmitter from './mixin/emitter'
|
|
2
2
|
import events from './module/events'
|
|
3
|
-
import build from './
|
|
3
|
+
import build from './mixin/build'
|
|
4
4
|
import dataset from './module/dataset'
|
|
5
5
|
import attributes from './module/attributes'
|
|
6
6
|
|
|
7
7
|
class File {
|
|
8
|
-
static uid = "material-file";
|
|
9
|
-
|
|
10
8
|
static defaults = {
|
|
11
9
|
class: 'file',
|
|
12
10
|
attributes: ['name', 'accept', 'required', 'disabled', 'multiple'],
|
|
@@ -20,7 +18,7 @@ class File {
|
|
|
20
18
|
this.init(options)
|
|
21
19
|
this.build()
|
|
22
20
|
this.buildInput()
|
|
23
|
-
|
|
21
|
+
this.setup()
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
init (options) {
|
|
@@ -46,6 +44,10 @@ class File {
|
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
|
|
47
|
+
setup () {
|
|
48
|
+
events.attach(this.options.events, this)
|
|
49
|
+
}
|
|
50
|
+
|
|
49
51
|
change (e) {
|
|
50
52
|
this.emit('change', e)
|
|
51
53
|
}
|
package/src/form/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import dataset from '../view/dataset'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { create } from '../module/layout'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
build () {
|
|
@@ -51,7 +51,7 @@ export default {
|
|
|
51
51
|
buildLayout () {
|
|
52
52
|
// console.log('buildLayout')
|
|
53
53
|
this.form.innerHTML = ''
|
|
54
|
-
this.layout =
|
|
54
|
+
this.layout = create(this.options.layout, this.form)
|
|
55
55
|
this.ui = this.layout.component
|
|
56
56
|
|
|
57
57
|
// console.log('ui', this.ui)
|