Skip to content

Commit

Permalink
Merge pull request writer#301 from raaymax/types-mapping-in-code-gene…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
ramedina86 authored Mar 12, 2024
2 parents 8d3801a + 668bf43 commit c08f174
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 47 deletions.
180 changes: 135 additions & 45 deletions src/streamsync/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"showIndex": str,
"enableSearch": str,
"enableDownload": str,
"displayRowCount": str,
"displayRowCount": Union[float, str],
"wrapText": str,
"primaryTextColor": str,
"secondaryTextColor": str,
Expand All @@ -155,8 +155,8 @@

HTMLElementProps = TypedDict('HTMLElementProps', {
"element": str,
"styles": str,
"attrs": str,
"styles": Union[Dict, str],
"attrs": Union[Dict, str],
"htmlInside": str,
"cssClasses": str
}, total=False)
Expand All @@ -165,9 +165,9 @@
}, total=False)

PaginationProps = TypedDict('PaginationProps', {
"page": str,
"pageSize": str,
"totalItems": str,
"page": Union[float, str],
"pageSize": Union[float, str],
"totalItems": Union[float, str],
"pageSizeOptions": str,
"pageSizeShowAll": str,
"jumpTo": str
Expand All @@ -179,7 +179,7 @@
}, total=False)

RepeaterProps = TypedDict('RepeaterProps', {
"repeaterObject": str,
"repeaterObject": Union[Dict, str],
"keyVariable": str,
"valueVariable": str
}, total=False)
Expand All @@ -189,7 +189,7 @@

ColumnProps = TypedDict('ColumnProps', {
"title": str,
"width": str,
"width": Union[float, str],
"isSticky": str,
"isCollapsible": str,
"startCollapsed": str,
Expand Down Expand Up @@ -268,8 +268,8 @@
ImageProps = TypedDict('ImageProps', {
"src": str,
"caption": str,
"maxWidth": str,
"maxHeight": str,
"maxWidth": Union[float, str],
"maxHeight": Union[float, str],
"secondaryTextColor": str,
"cssClasses": str
}, total=False)
Expand All @@ -280,9 +280,9 @@

PDFProps = TypedDict('PDFProps', {
"source": str,
"highlights": str,
"selectedMatch": str,
"page": str,
"highlights": Union[Dict, str],
"selectedMatch": Union[float, str],
"page": Union[float, str],
"controls": str,
"containerBackgroundColor": str,
"separatorColor": str,
Expand All @@ -306,10 +306,10 @@
"apiKey": str,
"mapId": str,
"mapType": str,
"zoom": str,
"lat": str,
"lng": str,
"markers": str,
"zoom": Union[float, str],
"lat": Union[float, str],
"lng": Union[float, str],
"markers": Union[Dict, str],
"cssClasses": str
}, total=False)

Expand All @@ -321,10 +321,10 @@
MapboxProps = TypedDict('MapboxProps', {
"accessToken": str,
"mapStyle": str,
"zoom": str,
"lat": str,
"lng": str,
"markers": str,
"zoom": Union[float, str],
"lat": Union[float, str],
"lng": Union[float, str],
"markers": Union[Dict, str],
"controls": str,
"cssClasses": str
}, total=False)
Expand All @@ -336,7 +336,7 @@

IconProps = TypedDict('IconProps', {
"icon": str,
"size": str,
"size": Union[float, str],
"color": str,
"cssClasses": str
}, total=False)
Expand All @@ -345,7 +345,7 @@
}, total=False)

TimerProps = TypedDict('TimerProps', {
"intervalMs": str,
"intervalMs": Union[float, str],
"isActive": str,
"accentColor": str,
"cssClasses": str
Expand All @@ -370,7 +370,7 @@
TextareaInputProps = TypedDict('TextareaInputProps', {
"label": str,
"placeholder": str,
"rows": str,
"rows": Union[float, str],
"cssClasses": str
}, total=False)

Expand All @@ -382,9 +382,9 @@
NumberInputProps = TypedDict('NumberInputProps', {
"label": str,
"placeholder": str,
"minValue": str,
"maxValue": str,
"valueStep": str,
"minValue": Union[float, str],
"maxValue": Union[float, str],
"valueStep": Union[float, str],
"cssClasses": str
}, total=False)

Expand All @@ -395,9 +395,9 @@

SliderInputProps = TypedDict('SliderInputProps', {
"label": str,
"minValue": str,
"maxValue": str,
"stepSize": str,
"minValue": Union[float, str],
"maxValue": Union[float, str],
"stepSize": Union[float, str],
"cssClasses": str
}, total=False)

Expand All @@ -416,7 +416,7 @@

RadioInputProps = TypedDict('RadioInputProps', {
"label": str,
"options": str,
"options": Union[Dict, str],
"orientation": str,
"cssClasses": str
}, total=False)
Expand All @@ -427,7 +427,7 @@

CheckboxInputProps = TypedDict('CheckboxInputProps', {
"label": str,
"options": str,
"options": Union[Dict, str],
"orientation": str,
"cssClasses": str
}, total=False)
Expand All @@ -438,7 +438,7 @@

DropdownInputProps = TypedDict('DropdownInputProps', {
"label": str,
"options": str,
"options": Union[Dict, str],
"cssClasses": str
}, total=False)

Expand All @@ -448,9 +448,9 @@

SelectInputProps = TypedDict('SelectInputProps', {
"label": str,
"options": str,
"options": Union[Dict, str],
"placeholder": str,
"maximumCount": str,
"maximumCount": Union[float, str],
"accentColor": str,
"chipTextColor": str,
"selectedColor": str,
Expand All @@ -467,9 +467,9 @@

MultiselectInputProps = TypedDict('MultiselectInputProps', {
"label": str,
"options": str,
"options": Union[Dict, str],
"placeholder": str,
"maximumCount": str,
"maximumCount": Union[float, str],
"accentColor": str,
"chipTextColor": str,
"selectedColor": str,
Expand All @@ -495,7 +495,7 @@
}, total=False)

WebcamCaptureProps = TypedDict('WebcamCaptureProps', {
"refreshRate": str,
"refreshRate": Union[float, str],
"buttonColor": str,
"buttonTextColor": str,
"buttonShadow": str,
Expand All @@ -508,15 +508,15 @@
}, total=False)

VegaLiteChartProps = TypedDict('VegaLiteChartProps', {
"spec": str,
"spec": Union[Dict, str],
"cssClasses": str
}, total=False)

VegaLiteChartEventHandlers = TypedDict('VegaLiteChartEventHandlers', {
}, total=False)

PlotlyGraphProps = TypedDict('PlotlyGraphProps', {
"spec": str,
"spec": Union[Dict, str],
"cssClasses": str
}, total=False)

Expand Down Expand Up @@ -572,6 +572,8 @@
"incomingInitials": str,
"outgoingInitials": str,
"useMarkdown": str,
"enableFileUpload": str,
"placeholder": str,
"incomingColor": str,
"outgoingColor": str,
"avatarBackgroundColor": str,
Expand All @@ -587,7 +589,8 @@

ChatEventHandlers = TypedDict('ChatEventHandlers', {
"ss-chat-message": Union[str, Callable],
"ss-chat-action-click": Union[str, Callable]
"ss-chat-action-click": Union[str, Callable],
"ss-file-change": Union[str, Callable]
}, total=False)

StepProps = TypedDict('StepProps', {
Expand Down Expand Up @@ -620,9 +623,9 @@
RatingInputProps = TypedDict('RatingInputProps', {
"label": str,
"feedback": str,
"minValue": str,
"maxValue": str,
"valueStep": str,
"minValue": Union[float, str],
"maxValue": Union[float, str],
"valueStep": Union[float, str],
"accentColor": str,
"primaryTextColor": str,
"cssClasses": str
Expand All @@ -632,6 +635,31 @@
"ss-number-change": Union[str, Callable]
}, total=False)

TagsProps = TypedDict('TagsProps', {
"tags": Union[Dict, str],
"referenceColor": str,
"seed": Union[float, str],
"rotateHue": str,
"primaryTextColor": str,
"cssClasses": str
}, total=False)

TagsEventHandlers = TypedDict('TagsEventHandlers', {
"ss-tag-click": Union[str, Callable]
}, total=False)

SwitchInputProps = TypedDict('SwitchInputProps', {
"label": str,
"accentColor": str,
"primaryTextColor": str,
"separatorColor": str,
"cssClasses": str
}, total=False)

SwitchInputEventHandlers = TypedDict('SwitchInputEventHandlers', {
"ss-toggle": Union[str, Callable]
}, total=False)

class StreamsyncUIManager(StreamsyncUI):
"""The StreamsyncUIManager class is intended to include dynamically-
generated methods corresponding to UI components defined in the Vue
Expand Down Expand Up @@ -1946,6 +1974,8 @@ def Chat(self,
"incomingInitials": "AI",
"outgoingInitials": "YOU",
"useMarkdown": "no",
"enableFileUpload": "no",
"placeholder": "Write something...",
"outgoingColor": "#F5F5F9",
"avatarBackgroundColor": "#2C2D30",
"avatarTextColor": "#FFFFFF",
Expand Down Expand Up @@ -2051,4 +2081,64 @@ def RatingInput(self,
visible=visible,
binding=binding)
return component


def Tags(self,
content: TagsProps = {},
*,
id: Optional[str] = None,
position: Optional[int] = None,
parentId: Optional[str] = None,
handlers: Optional[TagsEventHandlers] = None,
visible: Optional[Union[bool, str]] = None,
binding: Optional[Dict] = None,
) -> Component:
"""
A component to display coloured tag pills.
"""
defaultContent: TagsProps = {
"tags": "{}",
"referenceColor": "#29cf00",
"seed": "1",
"rotateHue": "yes",
"primaryTextColor": "#ffffff",
}
content = defaultContent | content
component = self.create_component(
'tags',
content=content,
id=id,
position=position,
parentId=parentId,
handlers=handlers,
visible=visible,
binding=binding)
return component

def SwitchInput(self,
content: SwitchInputProps = {},
*,
id: Optional[str] = None,
position: Optional[int] = None,
parentId: Optional[str] = None,
handlers: Optional[SwitchInputEventHandlers] = None,
visible: Optional[Union[bool, str]] = None,
binding: Optional[Dict] = None,
) -> Component:
"""
A user input component with a simple on/off status.
"""
defaultContent: SwitchInputProps = {

}
content = defaultContent | content
component = self.create_component(
'switchinput',
content=content,
id=id,
position=position,
parentId=parentId,
handlers=handlers,
visible=visible,
binding=binding)
return component

Loading

0 comments on commit c08f174

Please sign in to comment.