refactor: make it optional having to specify parent class of Args, Kwargs, Slots, etc (#1466)

This commit is contained in:
Juro Oravec 2025-10-21 15:30:08 +02:00 committed by GitHub
parent 0aeb96fa40
commit c37628dea0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 661 additions and 299 deletions

View file

@ -1,5 +1,3 @@
from typing import NamedTuple
from django_components import Component, register
@ -15,7 +13,7 @@ class Calendar(Component):
js_file = "calendar/calendar.js"
# This component takes one parameter, a date string to show in the template
class Kwargs(NamedTuple):
class Kwargs:
date: str
def get_template_data(self, args, kwargs: Kwargs, slots, context):
@ -46,7 +44,7 @@ class CalendarRelative(Component):
js_file = "calendar.js"
# This component takes one parameter, a date string to show in the template
class Kwargs(NamedTuple):
class Kwargs:
date: str
def get_template_data(self, args, kwargs: Kwargs, slots, context):

View file

@ -1,4 +1,4 @@
from typing import Any, NamedTuple
from typing import Any
from django.http import HttpRequest, HttpResponse
@ -17,7 +17,7 @@ class CalendarNested(Component):
js_file = "calendar.js"
# This component takes one parameter, a date string to show in the template
class Kwargs(NamedTuple):
class Kwargs:
date: str
def get_template_data(self, args, kwargs: Kwargs, slots, context):