Skip to content

Commit a6d6995

Browse files
Initial commit. Branched off of widgetti/ipyvuetify@4695aef.
0 parents  commit a6d6995

32 files changed

+8015
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.egg-info/
2+
.eggs/
3+
.ipynb_checkpoints/
4+
dist/
5+
build/
6+
*.py[cod]
7+
**/node_modules/
8+
9+
# Compiled javascript
10+
ipyvue/static/
11+
js/lib
12+
js/jupyter-vue-*.tgz

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Mario Buikhuizen
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, 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,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include LICENSE
2+
recursive-include ipyvue/static *.*
3+
include jupyter-vue.json

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ipyvue
2+
======
3+
4+
Jupyter widgets base for [Vue](https://vuejs.org/) libraries
5+
6+
Installation
7+
------------
8+
9+
To install use pip:
10+
11+
$ pip install ipyvue
12+
$ jupyter nbextension enable --py --sys-prefix ipyvue
13+
14+
15+
For a development installation (requires npm),
16+
17+
$ git clone https://github.com/mariobuikhuizen/ipyvue.git
18+
$ cd ipyvue
19+
$ pip install -e .
20+
$ jupyter nbextension install --py --symlink --sys-prefix ipyvue
21+
$ jupyter nbextension enable --py --sys-prefix ipyvue

RELEASE.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- To release a new version of ipyvue on PyPI:
2+
3+
Update _version.py (set release version, remove 'dev')
4+
git add the _version.py file and git commit
5+
`python setup.py sdist upload`
6+
`python setup.py bdist_wheel upload`
7+
`git tag -a X.X.X -m 'comment'`
8+
Update _version.py (add 'dev' and increment minor)
9+
git add and git commit
10+
git push
11+
git push --tags
12+
13+
- To release a new version of jupyter-vue on NPM:
14+
15+
```
16+
# clean out the `dist` and `node_modules` directories
17+
git clean -fdx
18+
npm install
19+
npm publish
20+
```

ipyvue/ForceLoad.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from traitlets import Unicode
2+
from ipywidgets import DOMWidget
3+
from ._version import semver
4+
5+
6+
class ForceLoad(DOMWidget):
7+
_model_name = Unicode('ForceLoadModel').tag(sync=True)
8+
_model_module = Unicode('jupyter-vue').tag(sync=True)
9+
_model_module_version = Unicode(semver).tag(sync=True)
10+
11+
12+
force_load_instance = ForceLoad()

ipyvue/Html.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from traitlets import Unicode
2+
from .VueWidget import VueWidget
3+
4+
5+
class Html(VueWidget):
6+
7+
_model_name = Unicode('HtmlModel').tag(sync=True)
8+
9+
tag = Unicode().tag(sync=True)
10+
11+
12+
__all__ = ['Html']

ipyvue/VueTemplateWidget.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from traitlets import Any, Unicode, List, Dict
2+
from ipywidgets import DOMWidget
3+
from ipywidgets.widgets.widget import widget_serialization
4+
from ._version import semver
5+
from .ForceLoad import force_load_instance
6+
7+
8+
class Events(object):
9+
def __init__(self, **kwargs):
10+
self.on_msg(self._handle_event)
11+
self.events = [item[4:] for item in dir(self) if item.startswith("vue_")]
12+
13+
def _handle_event(self, _, content, buffers):
14+
event = content.get("event", "")
15+
data = content.get("data", {})
16+
getattr(self, 'vue_' + event)(data)
17+
18+
19+
class VueTemplate(DOMWidget, Events):
20+
21+
# Force the loading of jupyter-vue before dependent extensions when in a static context (embed,
22+
# voila)
23+
_jupyter_vue = Any(force_load_instance, read_only=True).tag(sync=True, **widget_serialization)
24+
25+
_model_name = Unicode('VueTemplateModel').tag(sync=True)
26+
27+
_view_name = Unicode('VueView').tag(sync=True)
28+
29+
_view_module = Unicode('jupyter-vue').tag(sync=True)
30+
31+
_model_module = Unicode('jupyter-vue').tag(sync=True)
32+
33+
_view_module_version = Unicode(semver).tag(sync=True)
34+
35+
_model_module_version = Unicode(semver).tag(sync=True)
36+
37+
template = Unicode(None, allow_none=True).tag(sync=True)
38+
39+
events = List(Unicode(), default_value=None, allow_none=True).tag(sync=True)
40+
41+
components = Dict(default_value=None, allow_none=True).tag(sync=True, **widget_serialization)
42+
43+
44+
__all__ = ['VueTemplate']

ipyvue/VueWidget.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from traitlets import (Unicode, Instance, Union, List, Any)
2+
from ipywidgets import DOMWidget
3+
from ipywidgets.widgets.widget import (widget_serialization, CallbackDispatcher)
4+
from ._version import semver
5+
from .ForceLoad import force_load_instance
6+
7+
8+
class Events(object):
9+
def __init__(self, **kwargs):
10+
self._event_handlers_map = {}
11+
self.on_msg(self._handle_event)
12+
13+
def on_event(self, event, callback, remove=False):
14+
self._event_handlers_map[event] = CallbackDispatcher()
15+
16+
self._event_handlers_map[event].register_callback(callback, remove=remove)
17+
18+
if remove and not self._event_handlers_map[event].callbacks:
19+
del self._event_handlers_map[event]
20+
21+
difference = set(self._event_handlers_map.keys()) ^ set(self._events)
22+
if len(difference) != 0:
23+
self._events = list(self._event_handlers_map.keys())
24+
25+
def fire_event(self, event, data):
26+
self._event_handlers_map[event](self, event, data)
27+
28+
def _handle_event(self, _, content, buffers):
29+
event = content.get("event", "")
30+
data = content.get("data", {})
31+
self.fire_event(event, data)
32+
33+
34+
class VueWidget(DOMWidget, Events):
35+
36+
# Force the loading of jupyter-vue before dependent extensions when in a static context (embed,
37+
# voila)
38+
_jupyter_vue = Any(force_load_instance, read_only=True).tag(sync=True, **widget_serialization)
39+
40+
_model_name = Unicode('VueModel').tag(sync=True)
41+
42+
_view_name = Unicode('VueView').tag(sync=True)
43+
44+
_view_module = Unicode('jupyter-vue').tag(sync=True)
45+
46+
_model_module = Unicode('jupyter-vue').tag(sync=True)
47+
48+
_view_module_version = Unicode(semver).tag(sync=True)
49+
50+
_model_module_version = Unicode(semver).tag(sync=True)
51+
52+
children = List(Union([
53+
Instance(DOMWidget),
54+
Unicode()
55+
], default_value=None)).tag(sync=True, **widget_serialization)
56+
57+
slot = Unicode(None, allow_none=True).tag(sync=True)
58+
59+
_events = List(Unicode(), default_value=None, allow_none=True).tag(sync=True)
60+
61+
v_model = Any('!!disabled!!', allow_none=True).tag(sync=True)
62+
63+
style_ = Unicode(None, allow_none=True).tag(sync=True)
64+
65+
class_ = Unicode(None, allow_none=True).tag(sync=True)
66+
67+
68+
__all__ = ['VueWidget']

ipyvue/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from ._version import version_info, __version__ # noqa: F401
2+
from .Html import Html # noqa: F401
3+
from .VueWidget import VueWidget # noqa: F401
4+
from .VueTemplateWidget import VueTemplate # noqa: F401
5+
6+
7+
def _jupyter_nbextension_paths():
8+
return [{
9+
'section': 'notebook',
10+
'src': 'static',
11+
'dest': 'jupyter-vue',
12+
'require': 'jupyter-vue/extension'
13+
}]

ipyvue/_version.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version_info = (0, 1, 0, 'final')
2+
3+
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
4+
5+
__version__ = '%s.%s.%s%s' % (
6+
version_info[0], version_info[1], version_info[2],
7+
'' if version_info[3] == 'final' else _specifier_[version_info[3]]+str(version_info[4]))
8+
9+
semver = '^' + __version__

js/.babelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{ "presets": [
2+
[
3+
"@babel/preset-env",
4+
{
5+
"useBuiltIns": "usage",
6+
"corejs": 3,
7+
"modules": false
8+
}
9+
]
10+
]
11+
}

js/.eslintrc.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
},
6+
extends: 'airbnb-base',
7+
globals: {
8+
Atomics: 'readonly',
9+
SharedArrayBuffer: 'readonly',
10+
},
11+
parserOptions: {
12+
ecmaVersion: 2018,
13+
sourceType: 'module',
14+
},
15+
plugins: [
16+
'vue',
17+
],
18+
rules: {
19+
'indent': ['error', 4, { 'SwitchCase': 1 }],
20+
'import/prefer-default-export': 'off',
21+
'camelcase': ["error", {allow: ['__webpack_public_path__', 'load_ipython_extension', '_model_name']}],
22+
'no-underscore-dangle': 'off',
23+
'class-methods-use-this': 'off',
24+
'no-use-before-define': 'off'
25+
},
26+
};

js/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Jupyter widgets base for Vue libraries
2+
3+
Package Install
4+
---------------
5+
6+
**Prerequisites**
7+
- [node](http://nodejs.org/)
8+
9+
```bash
10+
npm install --save jupyter-vue
11+
```

0 commit comments

Comments
 (0)