TexteaInc / funix

Building web apps without manually creating widgets
http://funix.io
MIT License
89 stars 10 forks source link

Easy association from a new type to a parametric or non-parametric widget #72

Open forrestbao opened 10 months ago

forrestbao commented 10 months ago

To-do: support usage like this below where the user can different types of strings, inherited from the str type and associated with different UI components.

import funix

@funix.new_funix_type(
    widget=[
        # "MUI-TextField", 
        "textarea",
        {"min":10, "max":20 ,"multiline":True} # props of TextField in MUI
    ]
) 
class long_str(str):
    pass

type="password"@funix.new_funix_type(
    widget=[
        # "MUI-TextField", 
        "input",
        {"type":"password"} # props of TextField in MUI
    ]
) # Coming soon! 
class password(str): # For this type of strings,  the content will be hidden unless revealed
    pass

@funix.funix()
def foo(x: long_str, y: password) -> str: 
    return f"{x} {y}"