dash-sortable-items 0.7.1__py3-none-any.whl

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.
@@ -0,0 +1,78 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ import typing # noqa: F401
4
+ from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
5
+ from dash.development.base_component import Component, _explicitize_args
6
+ try:
7
+ from dash.types import NumberType # noqa: F401
8
+ except ImportError:
9
+ # Backwards compatibility for dash<=4.1.0
10
+ if typing.TYPE_CHECKING:
11
+ raise
12
+ NumberType = typing.Union[ # noqa: F401
13
+ typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
14
+ ]
15
+
16
+ ComponentSingleType = typing.Union[str, int, float, Component, None]
17
+ ComponentType = typing.Union[
18
+ ComponentSingleType,
19
+ typing.Sequence[ComponentSingleType],
20
+ ]
21
+
22
+
23
+ class HandleWrapper(Component):
24
+ """A HandleWrapper component.
25
+
26
+
27
+ Keyword arguments:
28
+
29
+ - id (string; optional):
30
+ Unique ID of the component.
31
+
32
+ - child (a list of or a singular dash component, string or number; required):
33
+ Child component wrapped with a ref.
34
+
35
+ - className (string; optional):
36
+ Class name of the component.
37
+
38
+ - key (string | number; optional)
39
+
40
+ - ref (string; optional):
41
+ Allows getting a ref to the component instance. Once the component
42
+ unmounts, React will set `ref.current` to `None` (or call the ref
43
+ with `None` if you passed a callback ref). @,see,,{@link
44
+ ,https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom
45
+ React Docs,}."""
46
+ _children_props: typing.List[str] = ['child']
47
+ _base_nodes = ['child', 'children']
48
+ _namespace = 'dash_sortable_items'
49
+ _type = 'HandleWrapper'
50
+
51
+
52
+ def __init__(
53
+ self,
54
+ child: typing.Optional[ComponentType] = None,
55
+ id: typing.Optional[typing.Union[str, dict]] = None,
56
+ className: typing.Optional[str] = None,
57
+ style: typing.Optional[typing.Any] = None,
58
+ ref: typing.Optional[typing.Union[str, typing.Any]] = None,
59
+ key: typing.Optional[typing.Union[str, NumberType]] = None,
60
+ **kwargs
61
+ ):
62
+ self._prop_names = ['id', 'child', 'className', 'key', 'ref', 'style']
63
+ self._valid_wildcard_attributes = []
64
+ self.available_properties = ['id', 'child', 'className', 'key', 'ref', 'style']
65
+ self.available_wildcard_properties = []
66
+ _explicit_args = kwargs.pop('_explicit_args')
67
+ _locals = locals()
68
+ _locals.update(kwargs) # For wildcard attrs and excess named props
69
+ args = {k: _locals[k] for k in _explicit_args}
70
+
71
+ for k in ['child']:
72
+ if k not in args:
73
+ raise TypeError(
74
+ 'Required argument `' + k + '` was not specified.')
75
+
76
+ super(HandleWrapper, self).__init__(**args)
77
+
78
+ setattr(HandleWrapper, "__init__", _explicitize_args(HandleWrapper.__init__))
@@ -0,0 +1,68 @@
1
+ r'''
2
+ This file defines a placeholder that users must use to create a sortable group.
3
+ This returns a _SortableGroup object which is the Python structure that creates the React component.
4
+ '''
5
+
6
+ # _SortableGroup and _SortableItem are used as placeholders here to avoid typing errors
7
+ from ._SortableGroup import _SortableGroup
8
+ from ._SortableItem import _SortableItem
9
+ from .SortableItem import SortableItem
10
+ from .types import DashId, CSSDict, AnimationOptions
11
+
12
+ class SortableGroup:
13
+ r'''
14
+ A sortable group containing SortableItem children.
15
+
16
+ :param items: List of SortableItem components that can be sorted within this group
17
+ :param id: Unique ID of the component.
18
+ :param className: Class name of the component.
19
+ :param style: Style to apply to the div element containing the children.
20
+ :param showClone: Whether a clone should be shown in the list when one of the elements is dragged or not.
21
+ :param dropAnimation: Specify the duration and easing of the drop animation. If None, the dragged item instantly reaches its destination.
22
+ '''
23
+
24
+ def __new__(
25
+ cls,
26
+ items : list[SortableItem],
27
+ id : DashId = None,
28
+ className : str = '',
29
+ style : CSSDict = {},
30
+ showClone : bool = False,
31
+ dropAnimation : AnimationOptions | None = None
32
+ ) -> _SortableGroup:
33
+
34
+
35
+ # Output list containing the new sortable items with indices set
36
+ new_items = []
37
+
38
+ for pos, item in enumerate(items):
39
+
40
+ handle_trick = {'handle' : item.handle} if item.handle is not None else {}
41
+ id_trick = {'id' : item.id} if item.id is not None else {}
42
+
43
+ # Create the real SortableItem component by giving it its position in the list
44
+ # as its index
45
+ new_item = _SortableItem(
46
+ index = pos,
47
+ children = item.children,
48
+ className = item.className,
49
+ handlePos = item.handlePos,
50
+ lock = item.lock,
51
+ restrict = item.restrict,
52
+ styles = item.styles,
53
+ styles_drag = item.styles_drag,
54
+ styles_drop = item.styles_drop,
55
+ transitionAnimation = item.transitionAnimation,
56
+ **handle_trick, **id_trick
57
+ )
58
+
59
+ new_items.append(new_item)
60
+
61
+ return _SortableGroup(
62
+ children = new_items,
63
+ id = id,
64
+ className = className,
65
+ style = style,
66
+ showClone = showClone,
67
+ dropAnimation = dropAnimation
68
+ )
@@ -0,0 +1,60 @@
1
+ r'''
2
+ This file defines a placeholder that users must use to create sortable items. When creating a SortableGroup component,
3
+ the class below is converted into a _SortableItem which maps to the React component.
4
+ '''
5
+
6
+ import typing
7
+ from .types import (
8
+ DashId,
9
+ handlePosType,
10
+ restrictType,
11
+ stylesType,
12
+ AnimationOptions
13
+ )
14
+
15
+ class SortableItem:
16
+ r"""
17
+ A sortable item used as a wrapper around any Dash component.
18
+ This item must be placed within a SortableGroup to make it draggable and sortable.
19
+
20
+ :param id: Unique ID of the component
21
+ :param children: Children of the component.
22
+ :param className: Class name of the component.
23
+ :param handle: Dash component used as handle to grab the row. None means the entire row is draggable.
24
+ :param handlePos: Position of the handle either at the start or at the end of the row.
25
+ :param lock: Whether to lock the item (i.e. make it not moveable) or not.
26
+ :param restrict: Whether to restrict items to vertical or horizontal motions only. None means there is no restriction.
27
+ :param styles: CSS styles to apply. This is a dictionary with keys 'div' and 'handle', each taking a dictionary with CSS properties.
28
+ :param styles_drag: CSS styles to apply when the item is being draggeds. This is a dictionary with keys 'div' and 'handle', each taking a dictionary with CSS properties.
29
+ :param styles_drop: CSS styles to apply when the item is being dropped. This is a dictionary with keys 'div' and 'handle', each taking a dictionary with CSS properties.
30
+ :param transitionAnimation: Dictionary with properties to style the animation when an item moves from one position to another. None disables the animation.
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ id : DashId,
36
+ children : typing.Any = None,
37
+ className : str = '',
38
+ handle : typing.Any = None,
39
+ handlePos : handlePosType = 'start',
40
+ lock : bool = False,
41
+ restrict : restrictType = None,
42
+ styles : stylesType = {},
43
+ styles_drag : stylesType = {},
44
+ styles_drop : stylesType = {},
45
+ transitionAnimation : AnimationOptions | None = {'duration' : 250, 'easing' : 'ease'},
46
+ ):
47
+
48
+ self.id = id
49
+ self.children = children
50
+ self.className = className
51
+ self.handle = handle
52
+ self.handlePos = handlePos
53
+ self.lock = lock
54
+ self.restrict = restrict
55
+ self.styles = styles
56
+ self.styles_drag = styles_drag
57
+ self.styles_drop = styles_drop
58
+ self.transitionAnimation = transitionAnimation
59
+
60
+ return
@@ -0,0 +1,93 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ import typing # noqa: F401
4
+ from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
5
+ from dash.development.base_component import Component, _explicitize_args
6
+ try:
7
+ from dash.types import NumberType # noqa: F401
8
+ except ImportError:
9
+ # Backwards compatibility for dash<=4.1.0
10
+ if typing.TYPE_CHECKING:
11
+ raise
12
+ NumberType = typing.Union[ # noqa: F401
13
+ typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
14
+ ]
15
+
16
+ ComponentSingleType = typing.Union[str, int, float, Component, None]
17
+ ComponentType = typing.Union[
18
+ ComponentSingleType,
19
+ typing.Sequence[ComponentSingleType],
20
+ ]
21
+
22
+
23
+ class _SortableGroup(Component):
24
+ """A _SortableGroup component.
25
+ sortable group that allows its children to be sorted
26
+
27
+ Keyword arguments:
28
+
29
+ - children (list of dicts; optional):
30
+ Children passed as props. These should be SortableItem components.
31
+
32
+ `children` is a list of dicts with keys:
33
+
34
+ - key (string; required):
35
+ Key provided by Dash. This corresponds to the ID the user has
36
+ provided.
37
+
38
+ - type (string; required)
39
+
40
+ - props (boolean | number | string | dict | list; required)
41
+
42
+ - id (string; optional):
43
+ Unique ID of the component.
44
+
45
+ - className (string; optional):
46
+ Class name of the component.
47
+
48
+ - dropAnimation (dict; default {duration : 250, easing: 'ease'})
49
+
50
+ `dropAnimation` is a dict with keys:
51
+
52
+ - duration (number; required)
53
+
54
+ - easing (string; required)
55
+
56
+ - showClone (boolean; default False):
57
+ Whether a clone should be shown in the list when dragging the
58
+ element or not."""
59
+ _children_props: typing.List[str] = []
60
+ _base_nodes = ['children']
61
+ _namespace = 'dash_sortable_items'
62
+ _type = '_SortableGroup'
63
+ DropAnimation = TypedDict(
64
+ "DropAnimation",
65
+ {
66
+ "duration": NumberType,
67
+ "easing": str
68
+ }
69
+ )
70
+
71
+
72
+ def __init__(
73
+ self,
74
+ children: typing.Optional[ComponentType] = None,
75
+ showClone: typing.Optional[bool] = None,
76
+ dropAnimation: typing.Optional["DropAnimation"] = None,
77
+ id: typing.Optional[typing.Union[str, dict]] = None,
78
+ className: typing.Optional[str] = None,
79
+ style: typing.Optional[typing.Any] = None,
80
+ **kwargs
81
+ ):
82
+ self._prop_names = ['children', 'id', 'className', 'dropAnimation', 'showClone', 'style']
83
+ self._valid_wildcard_attributes = []
84
+ self.available_properties = ['children', 'id', 'className', 'dropAnimation', 'showClone', 'style']
85
+ self.available_wildcard_properties = []
86
+ _explicit_args = kwargs.pop('_explicit_args')
87
+ _locals = locals()
88
+ _locals.update(kwargs) # For wildcard attrs and excess named props
89
+ args = {k: _locals[k] for k in _explicit_args if k != 'children'}
90
+
91
+ super(_SortableGroup, self).__init__(children=children, **args)
92
+
93
+ setattr(_SortableGroup, "__init__", _explicitize_args(_SortableGroup.__init__))
@@ -0,0 +1,169 @@
1
+ # AUTO GENERATED FILE - DO NOT EDIT
2
+
3
+ import typing # noqa: F401
4
+ from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
5
+ from dash.development.base_component import Component, _explicitize_args
6
+ try:
7
+ from dash.types import NumberType # noqa: F401
8
+ except ImportError:
9
+ # Backwards compatibility for dash<=4.1.0
10
+ if typing.TYPE_CHECKING:
11
+ raise
12
+ NumberType = typing.Union[ # noqa: F401
13
+ typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
14
+ ]
15
+
16
+ ComponentSingleType = typing.Union[str, int, float, Component, None]
17
+ ComponentType = typing.Union[
18
+ ComponentSingleType,
19
+ typing.Sequence[ComponentSingleType],
20
+ ]
21
+
22
+
23
+ class _SortableItem(Component):
24
+ """A _SortableItem component.
25
+ sortable item used in a SortableGroup component
26
+
27
+ Keyword arguments:
28
+
29
+ - children (string | number | boolean; optional):
30
+ Children of the component.
31
+
32
+ - id (string; required):
33
+ Unique ID of the component.
34
+
35
+ - className (string; optional):
36
+ Class name of the component.
37
+
38
+ - handle (a list of or a singular dash component, string or number; optional):
39
+ A Dash component used as handle to grab the row. None means the
40
+ entire row is draggable.
41
+
42
+ - handlePos (a value equal to: 'start', 'end'; default 'start'):
43
+ Position of the handle either at the start or at the end of the
44
+ row.
45
+
46
+ - index (number; required):
47
+ Initial position of the item in the sortable list.
48
+
49
+ - lock (boolean; default False):
50
+ Whether to lock the item (i.e. make it not moveable) or not.
51
+
52
+ - restrict (a value equal to: 'vertical', 'horizontal'; optional):
53
+ Whether to restrict items to vertical or horizontal motions only.
54
+ None means there is no restriction.
55
+
56
+ - styles (dict; optional):
57
+ CSS styles to apply. This is a dictionary with keys 'div' and
58
+ 'handle', each taking a dictionary with CSS properties.
59
+
60
+ `styles` is a dict with keys:
61
+
62
+ - div (boolean | number | string | dict | list; optional)
63
+
64
+ - handle (boolean | number | string | dict | list; optional)
65
+
66
+ - styles_drag (dict; optional):
67
+ CSS styles to apply when the item is dragged. This is a
68
+ dictionary with keys 'div' and 'handle', each taking a dictionary
69
+ with CSS properties.
70
+
71
+ `styles_drag` is a dict with keys:
72
+
73
+ - div (boolean | number | string | dict | list; optional)
74
+
75
+ - handle (boolean | number | string | dict | list; optional)
76
+
77
+ - styles_drop (dict; optional):
78
+ CSS styles to apply when the item is dropped. This is a
79
+ dictionary with keys 'div' and 'handle', each taking a dictionary
80
+ with CSS properties.
81
+
82
+ `styles_drop` is a dict with keys:
83
+
84
+ - div (boolean | number | string | dict | list; optional)
85
+
86
+ - handle (boolean | number | string | dict | list; optional)
87
+
88
+ - transitionAnimation (dict; default {duration : 250, easing: 'ease', idle: True}):
89
+ Animation used when the item translates from one position to the
90
+ next.
91
+
92
+ `transitionAnimation` is a dict with keys:
93
+
94
+ - duration (number; optional)
95
+
96
+ - easing (string; optional)
97
+
98
+ - idle (boolean; optional)"""
99
+ _children_props: typing.List[str] = ['handle']
100
+ _base_nodes = ['handle', 'children']
101
+ _namespace = 'dash_sortable_items'
102
+ _type = '_SortableItem'
103
+ TransitionAnimation = TypedDict(
104
+ "TransitionAnimation",
105
+ {
106
+ "duration": NotRequired[NumberType],
107
+ "easing": NotRequired[str],
108
+ "idle": NotRequired[bool]
109
+ }
110
+ )
111
+
112
+ Styles = TypedDict(
113
+ "Styles",
114
+ {
115
+ "div": NotRequired[typing.Any],
116
+ "handle": NotRequired[typing.Any]
117
+ }
118
+ )
119
+
120
+ StylesDrag = TypedDict(
121
+ "StylesDrag",
122
+ {
123
+ "div": NotRequired[typing.Any],
124
+ "handle": NotRequired[typing.Any]
125
+ }
126
+ )
127
+
128
+ StylesDrop = TypedDict(
129
+ "StylesDrop",
130
+ {
131
+ "div": NotRequired[typing.Any],
132
+ "handle": NotRequired[typing.Any]
133
+ }
134
+ )
135
+
136
+
137
+ def __init__(
138
+ self,
139
+ children: typing.Optional[ComponentType] = None,
140
+ id: typing.Optional[typing.Union[str, dict]] = None,
141
+ index: typing.Optional[NumberType] = None,
142
+ restrict: typing.Optional[Literal["vertical", "horizontal"]] = None,
143
+ handle: typing.Optional[ComponentType] = None,
144
+ lock: typing.Optional[bool] = None,
145
+ transitionAnimation: typing.Optional["TransitionAnimation"] = None,
146
+ handlePos: typing.Optional[Literal["start", "end"]] = None,
147
+ styles: typing.Optional["Styles"] = None,
148
+ styles_drag: typing.Optional["StylesDrag"] = None,
149
+ styles_drop: typing.Optional["StylesDrop"] = None,
150
+ className: typing.Optional[str] = None,
151
+ **kwargs
152
+ ):
153
+ self._prop_names = ['children', 'id', 'className', 'handle', 'handlePos', 'index', 'lock', 'restrict', 'styles', 'styles_drag', 'styles_drop', 'transitionAnimation']
154
+ self._valid_wildcard_attributes = []
155
+ self.available_properties = ['children', 'id', 'className', 'handle', 'handlePos', 'index', 'lock', 'restrict', 'styles', 'styles_drag', 'styles_drop', 'transitionAnimation']
156
+ self.available_wildcard_properties = []
157
+ _explicit_args = kwargs.pop('_explicit_args')
158
+ _locals = locals()
159
+ _locals.update(kwargs) # For wildcard attrs and excess named props
160
+ args = {k: _locals[k] for k in _explicit_args if k != 'children'}
161
+
162
+ for k in ['id', 'index']:
163
+ if k not in args:
164
+ raise TypeError(
165
+ 'Required argument `' + k + '` was not specified.')
166
+
167
+ super(_SortableItem, self).__init__(children=children, **args)
168
+
169
+ setattr(_SortableItem, "__init__", _explicitize_args(_SortableItem.__init__))
@@ -0,0 +1,61 @@
1
+ from __future__ import print_function as _
2
+
3
+ import os as _os
4
+ import sys as _sys
5
+ import json
6
+
7
+ import dash as _dash
8
+
9
+ # noinspection PyUnresolvedReferences
10
+ from ._imports_ import *
11
+ from ._imports_ import __all__
12
+
13
+ if not hasattr(_dash, '__plotly_dash') and not hasattr(_dash, 'development'):
14
+ print('Dash was not successfully imported. '
15
+ 'Make sure you don\'t have a file '
16
+ 'named \n"dash.py" in your current directory.', file=_sys.stderr)
17
+ _sys.exit(1)
18
+
19
+ _basepath = _os.path.dirname(__file__)
20
+ _filepath = _os.path.abspath(_os.path.join(_basepath, 'package-info.json'))
21
+ with open(_filepath) as f:
22
+ package = json.load(f)
23
+
24
+ package_name = package['name'].replace(' ', '_').replace('-', '_')
25
+ __version__ = package['version']
26
+
27
+ _current_path = _os.path.dirname(_os.path.abspath(__file__))
28
+
29
+ _this_module = _sys.modules[__name__]
30
+
31
+ _js_dist = []
32
+
33
+ _js_dist.extend(
34
+ [
35
+ {
36
+ 'relative_package_path': 'dash_sortable_items.js',
37
+
38
+ 'namespace': package_name
39
+ },
40
+ {
41
+ 'relative_package_path': 'dash_sortable_items.js.map',
42
+
43
+ 'namespace': package_name,
44
+ 'dynamic': True
45
+ }
46
+ ]
47
+ )
48
+
49
+ _js_dist.append(dict(
50
+ dev_package_path="proptypes.js",
51
+ dev_only=True,
52
+ namespace="dash_sortable_items"
53
+ ))
54
+
55
+
56
+ _css_dist = []
57
+
58
+
59
+ for _component in __all__:
60
+ setattr(locals()[_component], '_js_dist', _js_dist)
61
+ setattr(locals()[_component], '_css_dist', _css_dist)
@@ -0,0 +1,7 @@
1
+ from .SortableGroup import SortableGroup
2
+ from .SortableItem import SortableItem
3
+
4
+ __all__ = [
5
+ "SortableGroup",
6
+ "SortableItem"
7
+ ]