diff --git a/.eleventy.js b/.eleventy.js
index 3d84cdf..368242c 100644
--- a/.eleventy.js
+++ b/.eleventy.js
@@ -21,19 +21,4 @@ export default async function(eleventyConfig) {
callback(err, code);
}
});
- // Registry to ensure component assets (JS) load only once per page.
- let componentRegistry;
- eleventyConfig.on('beforeBuild', () => { componentRegistry = {}; });
- eleventyConfig.addNunjucksGlobal("registerComponent", function(componentName) {
- // Reset registry at the start of each page build
- if (!this.page) {
- componentRegistry = {};
- }
-
- if (!componentRegistry[componentName]) {
- componentRegistry[componentName] = true;
- return true;
- }
- return false;
- });
}
\ No newline at end of file
diff --git a/docs/_includes/components/dialog.njk b/docs/_includes/components/dialog.njk
index c7d6cab..0a883c7 100644
--- a/docs/_includes/components/dialog.njk
+++ b/docs/_includes/components/dialog.njk
@@ -12,64 +12,77 @@
content_footer_attrs={},
open=false,
close_button=true,
- close_on_overlay_click=true
+ close_on_overlay_click=true,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
) %}
-{% if registerComponent('dialog') %}
+{% if include_script %}
{% endif %}
+
+{% if include_html %}
+{% endif %}
{% endmacro %}
\ No newline at end of file
diff --git a/docs/_includes/components/dropdown-menu.njk b/docs/_includes/components/dropdown-menu.njk
index b5d70d8..10ed87a 100644
--- a/docs/_includes/components/dropdown-menu.njk
+++ b/docs/_includes/components/dropdown-menu.njk
@@ -3,108 +3,120 @@
trigger=None,
main_attrs=None,
trigger_attrs=None,
- content_attrs=None
+ content_attrs=None,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
) %}
-{% if registerComponent('dropdown-menu') %}
+{% if include_script %}
{% endif %}
+{% if include_html %}
{% if trigger %}
@@ -138,4 +150,5 @@
+{% endif %}
{% endmacro %}
diff --git a/docs/_includes/components/popover.njk b/docs/_includes/components/popover.njk
index f642387..ec25cb5 100644
--- a/docs/_includes/components/popover.njk
+++ b/docs/_includes/components/popover.njk
@@ -3,44 +3,55 @@
trigger=None,
main_attrs=None,
trigger_attrs=None,
- content_attrs=None
+ content_attrs=None,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
) %}
-{% if registerComponent('popover') %}
+{% if include_script %}
{% endif %}
+{% if include_html %}
{% if trigger %}
@@ -72,4 +83,5 @@
{% if caller %}{{ caller() }}{% endif %}
+{% endif %}
{% endmacro %}
diff --git a/docs/_includes/components/select.njk b/docs/_includes/components/select.njk
index 5c73def..881a32c 100644
--- a/docs/_includes/components/select.njk
+++ b/docs/_includes/components/select.njk
@@ -6,157 +6,169 @@
trigger_attrs=None,
content_attrs=None,
listbox_attrs=None,
- is_combobox=False
+ is_combobox=False,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
) %}
-{% if registerComponent('select') %}
+{% if include_script %}
{% endif %}
+{% if include_html %}
{% endif %}
+{% endif %}
{% endmacro %}
\ No newline at end of file
diff --git a/docs/_includes/components/tabs.njk b/docs/_includes/components/tabs.njk
index 4177ec9..04d9311 100644
--- a/docs/_includes/components/tabs.njk
+++ b/docs/_includes/components/tabs.njk
@@ -3,75 +3,87 @@
tabsets=[],
main_attrs=None,
tablist_attrs=None,
- default_tab_index=1
+ default_tab_index=1,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
)
%}
-{% if registerComponent('tabs') %}
+{% if include_script %}
{% endif %}
+{% if include_html %}
+{% endif %}
{% endmacro %}
\ No newline at end of file
diff --git a/docs/_includes/components/toast.njk b/docs/_includes/components/toast.njk
index 1371440..406867e 100644
--- a/docs/_includes/components/toast.njk
+++ b/docs/_includes/components/toast.njk
@@ -2,55 +2,67 @@
id="toaster",
toasts=[],
main_attrs=None,
- is_fragment=false
+ is_fragment=false,
+ include_html=true,
+ include_script=true,
+ register_on=["alpine:init"]
) %}
-{% if not is_fragment and registerComponent('toast') %}
+{% if not is_fragment and include_script %}
{% endif %}
+{% if include_html %}
{% set iconMapping = {
'error': 'circle-x',
'success': 'circle-check',
@@ -131,4 +143,5 @@
{% endfor %}
+{% endif %}
{% endmacro %}
\ No newline at end of file
diff --git a/docs/_includes/layouts/base.njk b/docs/_includes/layouts/base.njk
index e75e7ee..fa989a7 100644
--- a/docs/_includes/layouts/base.njk
+++ b/docs/_includes/layouts/base.njk
@@ -47,6 +47,21 @@
+
+
+
+
+
+
+ {% if head %}{{ head | safe }}{% endif %}
+
{% from "components/toast.njk" import toaster %}
{{ toaster() }}
diff --git a/docs/_includes/layouts/component.njk b/docs/_includes/layouts/component.njk
index eb40f4e..a368e29 100644
--- a/docs/_includes/layouts/component.njk
+++ b/docs/_includes/layouts/component.njk
@@ -36,11 +36,4 @@ layout: layouts/base.njk
{% endif %}
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/_includes/macros/code_preview.njk b/docs/_includes/macros/code_preview.njk
index 2447ee5..9ee11a2 100644
--- a/docs/_includes/macros/code_preview.njk
+++ b/docs/_includes/macros/code_preview.njk
@@ -4,7 +4,7 @@
{% set preview_panel %}
-
@@ -21,7 +21,8 @@
{{ tabs(
id="code-block-{{ id }}",
tabsets=tabsets,
- default_tab_index=(2 if default_code else 1)
+ default_tab_index=(2 if default_code else 1),
+ register_on=["alpine:init", "htmx:afterSwap"]
) }}
{% endmacro %}
\ No newline at end of file
diff --git a/docs/components/alert-dialog.njk b/docs/components/alert-dialog.njk
index f035b5f..4a9a709 100644
--- a/docs/components/alert-dialog.njk
+++ b/docs/components/alert-dialog.njk
@@ -28,7 +28,8 @@ toc:
trigger_attrs={"class": "btn-outline"},
footer=footer,
close_button=false,
- close_on_overlay_click=false
+ close_on_overlay_click=false,
+ register_on=["alpine:init", "htmx:afterSwap"]
) }}{% endset %}
{{ code_preview("alert-dialog", code | prettyHtml) }}
diff --git a/docs/components/breadcrumb.njk b/docs/components/breadcrumb.njk
index 47e359a..acff3db 100644
--- a/docs/components/breadcrumb.njk
+++ b/docs/components/breadcrumb.njk
@@ -28,7 +28,8 @@ toc:
{% call dropdown_menu(
id="demo-breadcrumb-menu",
trigger=trigger,
- trigger_attrs={"class": "flex size-9 items-center justify-center h-4 w-4 hover:text-foreground cursor-pointer"}
+ trigger_attrs={"class": "flex size-9 items-center justify-center h-4 w-4 hover:text-foreground cursor-pointer"},
+ register_on=["alpine:init", "htmx:afterSwap"]
) %}
Documentation
diff --git a/docs/components/combobox.njk b/docs/components/combobox.njk
index bfd7c19..5d942e5 100644
--- a/docs/components/combobox.njk
+++ b/docs/components/combobox.njk
@@ -26,7 +26,8 @@ toc:
{% call select(
trigger_attrs={"class": "w-[200px]"},
listbox_attrs={"data-empty": "No framework found."},
- is_combobox=true
+ is_combobox=true,
+ register_on=["alpine:init", "htmx:afterSwap"]
) %}
{% for framework in options_frameworks %}
{{ framework }}
@@ -114,7 +115,8 @@ toc:
trigger_attrs={"class": "w-[200px]"},
content_attrs={"class": "w-72"},
listbox_attrs={"data-empty": "No timezone found."},
- is_combobox=true
+ is_combobox=true,
+ register_on=["alpine:init", "htmx:afterSwap"]
) %}