djhtmx 1.2.0__py3-none-any.whl → 1.2.2__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.
djhtmx/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .middleware import middleware
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.2.2"
4
4
  __all__ = ("middleware",)
djhtmx/introspection.py CHANGED
@@ -13,6 +13,7 @@ from typing import (
13
13
  Annotated,
14
14
  Any,
15
15
  Generic,
16
+ Literal,
16
17
  TypedDict,
17
18
  TypeVar,
18
19
  Union,
@@ -381,6 +382,11 @@ infallible_bool_adapter = TypeAdapter(
381
382
  )
382
383
 
383
384
 
385
+ def is_literal_annotation(ann):
386
+ """Returns True if the annotation is a Literal type with simple values."""
387
+ return get_origin(ann) is Literal and all(type(arg) in _SIMPLE_TYPES for arg in get_args(ann))
388
+
389
+
384
390
  def is_basic_type(ann):
385
391
  """Returns True if the annotation is a simple type.
386
392
 
@@ -395,6 +401,8 @@ def is_basic_type(ann):
395
401
 
396
402
  - Instances of dict, tuple, list or set
397
403
 
404
+ - Literal types with simple values
405
+
398
406
  """
399
407
  return (
400
408
  ann in _SIMPLE_TYPES
@@ -402,6 +410,7 @@ def is_basic_type(ann):
402
410
  or issubclass_safe(getattr(ann, "__origin__", None), models.Model)
403
411
  or issubclass_safe(ann, (enum.IntEnum, enum.StrEnum))
404
412
  or is_collection_annotation(ann)
413
+ or is_literal_annotation(ann)
405
414
  )
406
415
 
407
416
 
@@ -1,15 +1,4 @@
1
1
  (function () {
2
- document.body.addEventListener("htmx:configRequest", (event) => {
3
- const csrf_header = document
4
- .querySelector("meta[name=django-csrf-header-name]")
5
- .getAttribute("content");
6
- const csrf_token = document
7
- .querySelector("meta[name=django-csrf-token]")
8
- .getAttribute("content");
9
-
10
- event.detail.headers[csrf_header] = csrf_token;
11
- });
12
-
13
2
  // WebSocket Management
14
3
  let sentComponents = new Set();
15
4
 
djhtmx/urls.py CHANGED
@@ -8,6 +8,7 @@ from django.http.request import HttpRequest
8
8
  from django.http.response import HttpResponse
9
9
  from django.urls import path, re_path
10
10
  from django.utils.html import format_html
11
+ from django.views.decorators.csrf import csrf_exempt
11
12
 
12
13
  from .commands import PushURL, ReplaceURL, SendHtml
13
14
  from .component import REGISTRY, Destroy, DispatchDOMEvent, Focus, Open, Redirect, Triggers
@@ -95,7 +96,7 @@ def app_name_of_component(cls: type):
95
96
  urlpatterns = [
96
97
  path(
97
98
  f"{app_name_of_component(component)}/{component_name}/<component_id>/<event_handler>",
98
- partial(endpoint, component_name=component_name),
99
+ csrf_exempt(partial(endpoint, component_name=component_name)),
99
100
  name=f"djhtmx.{component_name}",
100
101
  )
101
102
  for component_name, component in REGISTRY.items()
djhtmx/utils.py CHANGED
@@ -129,6 +129,7 @@ def autodiscover_htmx_modules():
129
129
  - htmx.py files (like standard autodiscover_modules("htmx"))
130
130
  - All Python files under htmx/ directories in apps (recursively)
131
131
  """
132
+
132
133
  def _import_modules_recursively(module_name):
133
134
  """Recursively import a module and all its submodules."""
134
135
  with contextlib.suppress(ImportError):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: djhtmx
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Interactive UI Components for Django using HTMX
5
5
  Project-URL: Homepage, https://github.com/edelvalle/djhtmx
6
6
  Project-URL: Documentation, https://github.com/edelvalle/djhtmx#readme
@@ -1,4 +1,4 @@
1
- djhtmx/__init__.py,sha256=3QdXDcoVk5icMta3uAvAdFpaUBzAyNy162DvVsELvRk,84
1
+ djhtmx/__init__.py,sha256=l25O4H6NDgkxXNhFUfB5NRdVr6ewp4P6sM4cDCO4YXE,84
2
2
  djhtmx/apps.py,sha256=hAyjzmInEstxLY9k8Qn58LvNlezgQLx5_NqyVL1WwYs,323
3
3
  djhtmx/command_queue.py,sha256=kiYbQFPyjnhMSR7KgO1Nu-lWiapnH511P2Pyg-Zrdq4,4862
4
4
  djhtmx/commands.py,sha256=UxXbARd4Teetjh_zjvAWgI2KNbvdETH-WrGf4qD9Xr8,1206
@@ -7,7 +7,7 @@ djhtmx/consumer.py,sha256=kHNoXokcWaFjs5zbZAhM7Y0x7GVwwawXbxBCkP8HNA8,2839
7
7
  djhtmx/context.py,sha256=cWvz8Z0MC6x_G8sn5mvoH8Hu38qReY21_eNdThuba1A,214
8
8
  djhtmx/exceptions.py,sha256=UtyE1N-52OmzwgRM9xFxjUuhHTMDvD7Oy3rNpgthLcs,47
9
9
  djhtmx/global_events.py,sha256=bYb8WmQn_WsZ_Dadr0pGiGOPia01K-VanPpM97Lt324,342
10
- djhtmx/introspection.py,sha256=OVNaQ8r6G13HMftydfW2UVCfs2dzy34HET2Tb7bGnN4,13431
10
+ djhtmx/introspection.py,sha256=flVolO6xZiXsxMm876ZCEcWRmVfFsJWpAVmIdfcJNf8,13734
11
11
  djhtmx/json.py,sha256=7cjwWIJj7e0dk54INKYZJe6zKkIW7wlsNSlD05cbXfY,1374
12
12
  djhtmx/middleware.py,sha256=JuMtv9ZnpungTvQ1qD2Lg6LiFPB3knQlA1ERgH4iGl0,1274
13
13
  djhtmx/query.py,sha256=UyjN1jokh4wTwQJxcRwA9f-Zn-A7A4GLToeGrCnPhKA,6674
@@ -15,10 +15,10 @@ djhtmx/repo.py,sha256=KYYhZWomrKB512QBjjb2ThaUWbmq6SZsYvcrl3Z5nGY,22797
15
15
  djhtmx/settings.py,sha256=ymFUMvrcXDkYU9KkhPOjRZSQMWz5GcUjlgh07x09-1s,1242
16
16
  djhtmx/testing.py,sha256=AdZKsT6sNTsyqSKx6EmfthOIHzSAPkTquheMfg9znbk,8301
17
17
  djhtmx/tracing.py,sha256=xkCXb7t_3yCj1PGzmQfHPu9sYQftDKwtALaEbFVnQ1E,1260
18
- djhtmx/urls.py,sha256=zWMlw_udCUWvo5DNxsvbebSNRFxy0C9ghBmRg08XlcU,3894
19
- djhtmx/utils.py,sha256=8dzSjEk4IR8LBHg-fDR9yn1Y2IVQjpmNn9x59rK5wgM,4645
18
+ djhtmx/urls.py,sha256=7u3Oj5coQR3aDwE3_DlEc52EKIbN8AMXoM--Zcuet0I,3960
19
+ djhtmx/utils.py,sha256=BcCdJHe0AqkRT_Kj-XJT_sHCpOyXtumo9mQGN2WqHek,4646
20
20
  djhtmx/management/commands/htmx.py,sha256=tEtiJn_Z6byOFzBNIzTbdluA4T5q21zFwGvJ7yt90bw,3642
21
- djhtmx/static/htmx/django.js,sha256=G59uwy5hA4QUcAFJv21SMxizATpNZG3KfgFlO2zXeGc,7086
21
+ djhtmx/static/htmx/django.js,sha256=XQgOfcqpF0Jtl9AZlrQ_tEBrNBdBj0OQ8hMFv3dLpoQ,6677
22
22
  djhtmx/static/htmx/2.0.4/htmx.amd.js,sha256=Hgmm_X5zw7ek0pjBaxhzH7OHx6Xfce5UYVa9ICWlWR0,165593
23
23
  djhtmx/static/htmx/2.0.4/htmx.cjs.js,sha256=4P3vh1eGwULBCT7wsKQ2bu4HiNQ_Kmnv2fP1RQ6_QW8,165586
24
24
  djhtmx/static/htmx/2.0.4/htmx.esm.d.ts,sha256=hV0FewMl4vWgZFCX_wIpSATGkXou7o1DXOLnVhvgvJI,7330
@@ -30,7 +30,7 @@ djhtmx/templates/htmx/headers.html,sha256=rBQTBt9rnlxE8lgxN4U7nvzQZNw4JZKS4flD1V
30
30
  djhtmx/templates/htmx/lazy.html,sha256=LfAThtKmFj-lCUZ7JWF_sC1Y6XsIpEz8A3IgWASn-J8,52
31
31
  djhtmx/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  djhtmx/templatetags/htmx.py,sha256=HlH7_B9lJoTDoIkYPeEE55OwpBTrrCesE70j1KcRC70,8063
33
- djhtmx-1.2.0.dist-info/METADATA,sha256=YxslHSLGP3ZdSVy0gYuJZ8xLluzIce0Ne38lfpneCi8,32245
34
- djhtmx-1.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- djhtmx-1.2.0.dist-info/licenses/LICENSE,sha256=kCi_iSBUGsRZInQn96w7LXYzjiRjZ8FXl6vP--mFRPk,1085
36
- djhtmx-1.2.0.dist-info/RECORD,,
33
+ djhtmx-1.2.2.dist-info/METADATA,sha256=b4XSwBq9PCYhdREgZbH49y7R3WhpoEr2LYroDp5FtAY,32245
34
+ djhtmx-1.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ djhtmx-1.2.2.dist-info/licenses/LICENSE,sha256=kCi_iSBUGsRZInQn96w7LXYzjiRjZ8FXl6vP--mFRPk,1085
36
+ djhtmx-1.2.2.dist-info/RECORD,,
File without changes