material 0.7.1 → 0.7.4
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/LICENSE +9 -18
- package/README.md +1 -5
- package/index.js +25 -48
- package/package.json +3 -24
- package/src/badge.js +1 -1
- package/src/button.js +50 -100
- package/src/calendar.js +53 -53
- package/src/card.js +1 -1
- package/src/checkbox.js +52 -104
- package/src/datehour.js +7 -7
- package/src/dialog.js +5 -5
- package/src/divider.js +1 -1
- package/src/drawer.js +1 -17
- package/src/element/attribute.js +7 -10
- package/src/element/build.js +6 -7
- package/src/element/create.js +3 -6
- package/src/element/event.js +2 -2
- package/src/element/insert.js +9 -20
- package/src/element/observer.js +22 -0
- package/src/element/offset.js +2 -2
- package/src/element/style.js +12 -12
- package/src/element.js +2 -2
- package/src/file.js +1 -1
- package/src/form/build.js +7 -7
- package/src/form/controller.js +8 -8
- package/src/form/create.js +1 -1
- package/src/form/data.js +9 -9
- package/src/form/delete.js +1 -1
- package/src/form/render.js +9 -9
- package/src/form/set.js +1 -1
- package/src/form/submit.js +6 -6
- package/src/form/update.js +3 -3
- package/src/form/verify.js +4 -4
- package/src/form.js +9 -9
- package/src/icon.js +4 -4
- package/src/image.js +7 -7
- package/src/item.js +1 -1
- package/src/layout.js +14 -14
- package/src/link.js +1 -1
- package/src/list/build.js +8 -8
- package/src/list/click.js +3 -3
- package/src/list/filter.js +11 -11
- package/src/list/image.js +3 -3
- package/src/list/render.js +15 -15
- package/src/list/request.js +7 -7
- package/src/list/search.js +9 -9
- package/src/list/select.js +18 -18
- package/src/list/status.js +1 -1
- package/src/list/update.js +6 -6
- package/src/list/virtual.js +20 -20
- package/src/list/virtual.new.js +5 -5
- package/src/list.js +8 -10
- package/src/map/build.js +2 -2
- package/src/map/countries.js +8 -8
- package/src/map/display.js +13 -13
- package/src/map/focus.js +7 -7
- package/src/map/select.js +2 -2
- package/src/map/set.js +3 -3
- package/src/map/viewport.js +11 -11
- package/src/menu.js +12 -12
- package/src/mixin/control.js +3 -3
- package/src/mixin/controller.js +5 -5
- package/src/mixin/create.js +1 -1
- package/src/mixin/display.js +1 -1
- package/src/mixin/events.js +4 -16
- package/src/mixin/focus.js +1 -1
- package/src/mixin/icon.js +2 -2
- package/src/mixin/init.js +2 -2
- package/src/mixin/insert.js +5 -5
- package/src/mixin/label.js +2 -2
- package/src/mixin/settings.js +5 -5
- package/src/module/attach.js +35 -49
- package/src/module/attributes.js +2 -2
- package/src/module/build.js +6 -11
- package/src/module/classify.js +4 -4
- package/src/module/controller.js +5 -32
- package/src/module/css.js +12 -84
- package/src/module/dataset.js +1 -1
- package/src/module/dom.js +9 -3
- package/src/module/dot.js +4 -4
- package/src/module/emitter.js +1 -1
- package/src/module/event.js +2 -2
- package/src/module/events.js +29 -35
- package/src/module/extract.js +10 -10
- package/src/module/last.js +18 -0
- package/src/module/mediator.js +1 -13
- package/src/module/object.js +4 -4
- package/src/module/observer.js +43 -16
- package/src/module/remove.js +10 -10
- package/src/module/request.js +33 -0
- package/src/module/ripple.js +19 -24
- package/src/module/scrollbar.js +10 -14
- package/src/module/smoothscroll.js +5 -9
- package/src/module/utils.js +14 -23
- package/src/module/viewport.js +5 -5
- package/src/navigation.js +7 -1
- package/src/progress.js +1 -9
- package/src/search.js +24 -29
- package/src/select.js +6 -6
- package/src/selecter.js +39 -39
- package/src/selector.js +3 -3
- package/src/skin/material/button/action.sass +6 -6
- package/src/skin/material/button/button.sass +6 -6
- package/src/skin/material/button/file.sass +1 -1
- package/src/skin/material/button/floating.sass +5 -5
- package/src/skin/material/button/raised.sass +5 -5
- package/src/skin/material/button/stroked.sass +5 -5
- package/src/skin/material/component/navigation.sass +13 -1
- package/src/skin/material/control/checkbox.sass +21 -21
- package/src/skin/material/module/ripple.sass +1 -1
- package/src/slider.js +1 -1
- package/src/snackbar.js +12 -9
- package/src/styles/M3/abstracts/variables.sass +44 -0
- package/src/styles/M3/components/button.sass +26 -0
- package/src/styles/M3/modules/ripple.sass +9 -0
- package/src/styles/M3/themes/classic.sass +2 -0
- package/src/switch.js +1 -1
- package/src/switcher.js +15 -15
- package/src/tabs.js +6 -8
- package/src/tabview.js +26 -46
- package/src/text.js +1 -1
- package/src/textfield.js +1 -1
- package/src/toolbar.js +12 -12
- package/src/tooltip.js +7 -7
- package/src/tree.js +10 -66
- package/src/view/build.js +2 -2
- package/src/view/dataset.js +1 -1
- package/src/view.js +9 -74
- package/dist/demo-bundle.js +0 -2
- package/dist/demo-bundle.js.map +0 -1
- package/dist/demo.css +0 -93
- package/dist/demo.css.map +0 -7
- package/dist/demo.html +0 -24
- package/dist/demo.js +0 -159
- package/dist/icon/accessibility.svg +0 -5
- package/dist/icon/apps.svg +0 -5
- package/dist/icon/happy.svg +0 -6
- package/dist/icon/link.svg +0 -5
- package/dist/icon/more.svg +0 -5
- package/dist/icon/navi.svg +0 -5
- package/dist/icon/phone.svg +0 -6
- package/dist/icon/share.svg +0 -6
- package/dist/icon/side.svg +0 -5
- package/dist/icon/star.svg +0 -7
- package/dist/icon/star_border.svg +0 -6
- package/dist/material.css +0 -2429
- package/dist/material.css.map +0 -7
- package/dist/styles/demo.sass +0 -110
- package/dist/styles.css +0 -23
- package/rollup.config.js +0 -34
- package/src/container.js +0 -66
- package/src/element/ripple.js +0 -90
- package/src/field/email.js +0 -59
- package/src/field/image.js +0 -93
- package/src/module/addclass.js +0 -16
package/LICENSE
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
This program is free software: you can redistribute it and/or modify
|
|
2
|
+
it under the terms of the GNU General Public License as published by
|
|
3
|
+
the Free Software Foundation, under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
This program is distributed in the hope that it will be useful,
|
|
6
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
7
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
8
|
+
GNU General Public License for more details.
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
You should have received a copy of the GNU General Public License
|
|
11
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
package/README.md
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
Material JS is a set of user interface components for the web.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[](https://github.com/standard/standard)
|
|
5
|
-
=======
|
|
1
|
+
Material JS is a set of user interface ES6 components for the web.
|
package/index.js
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
import AppBar from './src/appbar'
|
|
2
|
+
import Badge from './src/badge'
|
|
2
3
|
import Button from './src/button'
|
|
3
4
|
import Card from './src/card'
|
|
5
|
+
import Checkbox from './src/checkbox'
|
|
4
6
|
import Component from './src/component'
|
|
5
|
-
import DateHour from './src/
|
|
7
|
+
import DateHour from './src/datehour'
|
|
6
8
|
import Dialog from './src/dialog'
|
|
7
|
-
import
|
|
8
|
-
import Loading from './src/control/loading'
|
|
9
|
-
import Menu from './src/control/menu'
|
|
10
|
-
import Select from './src/select'
|
|
11
|
-
import Selecter from './src/control/selecter'
|
|
12
|
-
import Snackbar from './src/snackbar'
|
|
13
|
-
import Switch from './src/switch'
|
|
14
|
-
import Switcher from './src/control/switcher'
|
|
15
|
-
import Text from './src/text'
|
|
16
|
-
import Textfield from './src/textfield'
|
|
9
|
+
import Drawer from './src/drawer'
|
|
17
10
|
import Element from './src/element'
|
|
11
|
+
import File from './src/file'
|
|
12
|
+
import Form from './src/form'
|
|
13
|
+
import Image from './src/image'
|
|
18
14
|
import Layout from './src/layout'
|
|
19
15
|
import List from './src/list'
|
|
20
|
-
import
|
|
16
|
+
import Loading from './src/loading'
|
|
17
|
+
import Menu from './src/menu'
|
|
18
|
+
import Navigation from './src/navigation'
|
|
19
|
+
import Progress from './src/progress'
|
|
20
|
+
import Select from './src/select'
|
|
21
|
+
import Selecter from './src/selecter'
|
|
22
|
+
import Snackbar from './src/snackbar'
|
|
23
|
+
import Slider from './src/slider'
|
|
24
|
+
import Switch from './src/switch'
|
|
25
|
+
import Switcher from './src/switcher'
|
|
26
|
+
import Tabs from './src/tabs'
|
|
21
27
|
import TabView from './src/tabview'
|
|
22
28
|
import Text from './src/text'
|
|
29
|
+
import Textfield from './src/textfield'
|
|
23
30
|
import Toolbar from './src/toolbar'
|
|
24
31
|
import Tooltip from './src/tooltip'
|
|
25
32
|
import attach from './src/module/attach'
|
|
26
33
|
import attributes from './src/module/attributes'
|
|
27
34
|
import build from './src/module/build'
|
|
28
35
|
import dataset from './src/module/dataset'
|
|
29
|
-
import display from './src/
|
|
36
|
+
import display from './src/mixin/display'
|
|
30
37
|
import events from './src/module/attach'
|
|
31
38
|
import emitter from './src/module/emitter'
|
|
32
39
|
import jsonToHTML from './src/module/jsontohtml'
|
|
@@ -35,39 +42,9 @@ import observer from './src/module/observer'
|
|
|
35
42
|
import smoothscroll from './src/module/smoothscroll'
|
|
36
43
|
|
|
37
44
|
export {
|
|
38
|
-
AppBar
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Card,
|
|
44
|
-
Component,
|
|
45
|
-
Element,
|
|
46
|
-
File,
|
|
47
|
-
Loading,
|
|
48
|
-
Menu,
|
|
49
|
-
Select,
|
|
50
|
-
Selecter,
|
|
51
|
-
Snackbar,
|
|
52
|
-
Switch,
|
|
53
|
-
Switcher,
|
|
54
|
-
Tabview,
|
|
55
|
-
TabView,
|
|
56
|
-
Text,
|
|
57
|
-
Textfield,
|
|
58
|
-
Toolbar,
|
|
59
|
-
Tooltip,
|
|
60
|
-
Layout,
|
|
61
|
-
List,
|
|
62
|
-
attach,
|
|
63
|
-
attributes,
|
|
64
|
-
build,
|
|
65
|
-
dataset,
|
|
66
|
-
display,
|
|
67
|
-
events,
|
|
68
|
-
emitter,
|
|
69
|
-
jsonToHTML,
|
|
70
|
-
mediator,
|
|
71
|
-
observer,
|
|
72
|
-
smoothscroll
|
|
45
|
+
AppBar, Button, Card, Checkbox, Component, DateHour, Dialog, Drawer, Element,
|
|
46
|
+
File, Form, Image, Layout, List, Loading, Menu, Navigation, Progress, Select,
|
|
47
|
+
Selecter, Slider, Snackbar, Switch, Switcher, Tabs, TabView, Text, Textfield, Toolbar, Tooltip,
|
|
48
|
+
attach, attributes, build, dataset, display, events, emitter, jsonToHTML, mediator,
|
|
49
|
+
observer, smoothscroll
|
|
73
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "material",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "A lightweight implementation of Material Design Components - ES6",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+ssh://git@gitlab.com/alkaloid/material.git"
|
|
10
10
|
},
|
|
11
11
|
"author": "Jérôme Vial <jerome.vial@gmail.com>",
|
|
12
|
-
"license": "
|
|
12
|
+
"license": "GPL-3",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://gitlab.com/alkaloid/material/issues"
|
|
15
15
|
},
|
|
@@ -18,30 +18,9 @@
|
|
|
18
18
|
"lightweight material design ui component es6 vanilla javascript"
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"
|
|
22
|
-
"babel-eslint": "^8.0.0",
|
|
23
|
-
"babel-preset-es2015": "^6.24.1",
|
|
24
|
-
"babel-preset-es2015-rollup": "^3.0.0",
|
|
25
|
-
"npm-run-all": "^4.1.1",
|
|
26
|
-
"require-dir": "^0.3.0",
|
|
27
|
-
"rollup": "^0.49.2",
|
|
28
|
-
"rollup-plugin-babel": "^3.0.2",
|
|
29
|
-
"rollup-plugin-commonjs": "^8.2.0",
|
|
30
|
-
"rollup-plugin-node-resolve": "^3.0.0",
|
|
31
|
-
"rollup-plugin-npm": "^2.0.0",
|
|
32
|
-
"rollup-plugin-uglify-es": "0.0.1",
|
|
33
|
-
"standard": "^10.0.3",
|
|
34
|
-
"uglify-es": "^3.0.28"
|
|
21
|
+
"standard": "^10.0.3"
|
|
35
22
|
},
|
|
36
23
|
"scripts": {
|
|
37
|
-
"dev": "rollup -c --watch",
|
|
38
|
-
"reload": "livereload 'dist/' -d",
|
|
39
|
-
"styles": "sass --watch dist/styles/demo.sass:dist/demo.css",
|
|
40
|
-
"watch": "npm-run-all --parallel reload dev",
|
|
41
|
-
"docs": "jsdoc src -r -d docs",
|
|
42
24
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
43
|
-
},
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"fs-extra": "^11.1.1"
|
|
46
25
|
}
|
|
47
26
|
}
|
package/src/badge.js
CHANGED
package/src/button.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import EventEmitter from './mixin/emitter'
|
|
2
|
-
|
|
3
2
|
import build from './module/build'
|
|
4
3
|
import display from './mixin/display'
|
|
5
4
|
import bindEvents from './module/events'
|
|
6
|
-
|
|
7
5
|
import dataset from './module/dataset'
|
|
8
6
|
import ripple from './module/ripple'
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
const DEFAULT_TYPE = 'button'
|
|
9
|
+
const DEFAULT_CLASS = 'button'
|
|
10
|
+
|
|
11
|
+
class Button extends EventEmitter {
|
|
11
12
|
static isComponent () {
|
|
12
13
|
return true
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
static defaults = {
|
|
16
|
-
class:
|
|
17
|
+
class: DEFAULT_CLASS,
|
|
17
18
|
tag: 'button',
|
|
18
|
-
modules: [build, bindEvents],
|
|
19
19
|
styles: ['style', 'color'],
|
|
20
20
|
ripple: true,
|
|
21
21
|
stopPropagation: false,
|
|
@@ -29,11 +29,6 @@ class Button extends EventEmitter{
|
|
|
29
29
|
]
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Constructor
|
|
34
|
-
* @param {Object} options - Component options
|
|
35
|
-
* @return {Object} Class instance
|
|
36
|
-
*/
|
|
37
32
|
constructor (options) {
|
|
38
33
|
super()
|
|
39
34
|
|
|
@@ -41,112 +36,68 @@ class Button extends EventEmitter{
|
|
|
41
36
|
this.build()
|
|
42
37
|
this.setup()
|
|
43
38
|
this.bindEvents()
|
|
44
|
-
|
|
45
|
-
if (this.options.container) {
|
|
46
|
-
this.append(this.options.container)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return this
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
init (options) {
|
|
53
|
-
this.options =
|
|
42
|
+
this.options = { ...Button.defaults, ...options }
|
|
54
43
|
Object.assign(this, build, display, bindEvents)
|
|
55
|
-
|
|
56
44
|
}
|
|
57
45
|
|
|
58
46
|
setup () {
|
|
47
|
+
this.setAttributes()
|
|
59
48
|
this.styleAttributes()
|
|
60
|
-
|
|
61
|
-
this.buildIcon()
|
|
62
|
-
this.buildLabel()
|
|
49
|
+
this.buildElements()
|
|
63
50
|
|
|
64
51
|
if (this.options.text) {
|
|
65
52
|
this.element.innerHTML = this.element.innerHTML + this.options.text
|
|
66
53
|
}
|
|
54
|
+
}
|
|
67
55
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (this.options.type) {
|
|
73
|
-
this.element.setAttribute('type', this.options.type)
|
|
74
|
-
} else {
|
|
75
|
-
this.element.setAttribute('type', 'button')
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (this.options.name) {
|
|
79
|
-
this.element.setAttribute('name', this.options.name)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (this.options.value) {
|
|
83
|
-
this.element.setAttribute('value', this.options.value)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (this.options.title) {
|
|
87
|
-
this.element.setAttribute('title', this.options.title)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
this.element.setAttribute('aria-label', this.options.text || this.options.label || this.options.class)
|
|
91
|
-
|
|
92
|
-
if (this.options.tooltip) {
|
|
93
|
-
this.element.setAttribute('data-tooltip', this.options.tooltip)
|
|
94
|
-
}
|
|
56
|
+
buildElements () {
|
|
57
|
+
this.buildIcon()
|
|
58
|
+
this.buildLabel()
|
|
59
|
+
}
|
|
95
60
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
61
|
+
setAttributes () {
|
|
62
|
+
const { type, name, value, title, text, label, tooltip, data, case: caseOption } = this.options
|
|
99
63
|
|
|
64
|
+
this.element.setAttribute('type', type ?? DEFAULT_TYPE)
|
|
65
|
+
if (name) this.element.setAttribute('name', name)
|
|
66
|
+
if (value) this.element.setAttribute('value', value)
|
|
67
|
+
if (title) this.element.setAttribute('title', title)
|
|
68
|
+
this.element.setAttribute('aria-label', text ?? label ?? DEFAULT_CLASS)
|
|
69
|
+
if (tooltip) this.element.setAttribute('data-tooltip', tooltip)
|
|
70
|
+
if (data) dataset(this.element, data)
|
|
71
|
+
if (caseOption) this.element.classList.add(`${caseOption}-case`)
|
|
100
72
|
if (this.options.ripple) ripple(this.element)
|
|
101
73
|
}
|
|
102
74
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (this.
|
|
106
|
-
|
|
107
|
-
}
|
|
75
|
+
styleAttributes () {
|
|
76
|
+
const { style, size, color, bold } = this.options
|
|
77
|
+
if (style) this.element.classList.add(`style-${style}`)
|
|
78
|
+
if (size) this.element.classList.add(`${size}-size`)
|
|
79
|
+
if (color) this.element.classList.add(`color-${color}`)
|
|
80
|
+
if (bold) this.element.classList.add('bold')
|
|
108
81
|
}
|
|
109
82
|
|
|
110
83
|
buildLabel () {
|
|
111
84
|
if (!this.options.label) return
|
|
112
85
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.label.innerHTML = this.options.label
|
|
86
|
+
this.label = document.createElement('label')
|
|
87
|
+
this.label.classList.add('label')
|
|
88
|
+
this.label.innerHTML = this.options.label
|
|
117
89
|
|
|
118
|
-
|
|
119
|
-
}
|
|
90
|
+
this.element.appendChild(this.label)
|
|
120
91
|
}
|
|
121
92
|
|
|
122
93
|
buildIcon () {
|
|
123
94
|
if (!this.options.icon) return
|
|
124
95
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.icon.innerHTML = this.options.icon
|
|
129
|
-
|
|
130
|
-
this.element.appendChild(this.icon)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
styleAttributes () {
|
|
135
|
-
if (this.options.style) {
|
|
136
|
-
this.element.classList.add('style-' + this.options.style)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (this.options.size) {
|
|
140
|
-
this.element.classList.add(this.options.size + '-size')
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (this.options.color) {
|
|
144
|
-
this.element.classList.add('color-' + this.options.color)
|
|
145
|
-
}
|
|
96
|
+
this.icon = document.createElement('i')
|
|
97
|
+
this.icon.classList.add('icon')
|
|
98
|
+
this.icon.innerHTML = this.options.icon
|
|
146
99
|
|
|
147
|
-
|
|
148
|
-
this.element.classList.add('bold')
|
|
149
|
-
}
|
|
100
|
+
this.element.appendChild(this.icon)
|
|
150
101
|
}
|
|
151
102
|
|
|
152
103
|
set (prop, value) {
|
|
@@ -156,9 +107,8 @@ class Button extends EventEmitter{
|
|
|
156
107
|
this.element.value = value
|
|
157
108
|
break
|
|
158
109
|
case 'label':
|
|
159
|
-
if (this.label)
|
|
160
|
-
|
|
161
|
-
}
|
|
110
|
+
if (!this.label) this.buildLabel()
|
|
111
|
+
this.label.innerHTML = value
|
|
162
112
|
break
|
|
163
113
|
case 'text':
|
|
164
114
|
this.element.innerHTML = value
|
|
@@ -168,6 +118,12 @@ class Button extends EventEmitter{
|
|
|
168
118
|
this.icon.innerHTML = value
|
|
169
119
|
}
|
|
170
120
|
break
|
|
121
|
+
case 'enable':
|
|
122
|
+
this.element.disabled = false
|
|
123
|
+
break
|
|
124
|
+
case 'disable':
|
|
125
|
+
this.element.disabled = true
|
|
126
|
+
break
|
|
171
127
|
default:
|
|
172
128
|
// console.log('prop', prop)
|
|
173
129
|
this.element.innerHTML = prop
|
|
@@ -177,12 +133,12 @@ class Button extends EventEmitter{
|
|
|
177
133
|
}
|
|
178
134
|
|
|
179
135
|
setLabel (value) {
|
|
180
|
-
|
|
181
|
-
|
|
136
|
+
if (this.label) {
|
|
137
|
+
this.label.innerHTML = value
|
|
138
|
+
}
|
|
182
139
|
}
|
|
183
140
|
|
|
184
141
|
setText (value) {
|
|
185
|
-
// console.log('setText', value)
|
|
186
142
|
if (this.label) {
|
|
187
143
|
this.setLabel(value)
|
|
188
144
|
} else {
|
|
@@ -190,18 +146,12 @@ class Button extends EventEmitter{
|
|
|
190
146
|
}
|
|
191
147
|
}
|
|
192
148
|
|
|
193
|
-
|
|
194
|
-
* Setter
|
|
195
|
-
* @param {string} prop
|
|
196
|
-
* @param {string} value
|
|
197
|
-
* @return {Object} The class instance
|
|
198
|
-
*/
|
|
199
|
-
get (prop, value) {
|
|
149
|
+
get (prop) {
|
|
200
150
|
switch (prop) {
|
|
201
151
|
case 'value':
|
|
202
152
|
return this.element.value
|
|
203
153
|
case 'label':
|
|
204
|
-
return this.label.
|
|
154
|
+
return this.label?.innerHTML ?? this.element.value
|
|
205
155
|
default:
|
|
206
156
|
return this.element.value
|
|
207
157
|
}
|