diff --git a/docs/src/components/combobox.njk b/docs/src/components/combobox.njk index aabbf7c..c7c4cc1 100644 --- a/docs/src/components/combobox.njk +++ b/docs/src/components/combobox.njk @@ -15,6 +15,10 @@ toc: id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 + - label: JavaScript methods + id: usage-html-js-5 - label: Jinja and Nunjucks id: usage-macro - label: Examples @@ -130,6 +134,38 @@ toc: +

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
basecoat:popover
+
When the popover opens, the component dispatches a custom (non-bubbling) basecoat:popover event on document. Other popover components (Combobox, Dropdown Menu, Popover and Select) listen for this to close any open popovers.
+
change
+
When the selected value changes, the component dispatches a custom (bubbling) change event on itself, with the selected value in event.detail (e.g. {detail: {value: "something"}}).
+
+
+ +

JavaScript methods

+ +
+
+
selectByValue
+
+

You can call this method on the component after it is initialized to select an option by value (i.e. the option with the matching data-value attribute):

+ +{% set code_script %}{% endset %} +{{ code_block(code_script | prettyHtml, "html") }} +
+
+
+

Jinja and Nunjucks

diff --git a/docs/src/components/dropdown-menu.njk b/docs/src/components/dropdown-menu.njk index 37d410b..c660804 100644 --- a/docs/src/components/dropdown-menu.njk +++ b/docs/src/components/dropdown-menu.njk @@ -15,6 +15,8 @@ toc: id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 - label: Jinja and Nunjucks id: usage-macro - label: Examples @@ -155,6 +157,17 @@ toc: +

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
basecoat:popover
+
When the popover opens, the component dispatches a custom (non-bubbling) basecoat:popover event on document. Other popover components (Combobox, Dropdown Menu, Popover and Select) listen for this to close any open popovers.
+
+
+

Jinja and Nunjucks

diff --git a/docs/src/components/popover.njk b/docs/src/components/popover.njk index cfcbbf9..a81edde 100644 --- a/docs/src/components/popover.njk +++ b/docs/src/components/popover.njk @@ -15,6 +15,8 @@ toc: id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 - label: Jinja and Nunjucks id: usage-macro --- @@ -105,6 +107,17 @@ toc: +

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
basecoat:popover
+
When the popover opens, the component dispatches a custom (non-bubbling) basecoat:popover event on document. Other popover components (Combobox, Dropdown Menu, Popover and Select) listen for this to close any open popovers.
+
+
+

Jinja and Nunjucks

diff --git a/docs/src/components/select.njk b/docs/src/components/select.njk index e0e2ff8..7cbfd1d 100644 --- a/docs/src/components/select.njk +++ b/docs/src/components/select.njk @@ -17,6 +17,10 @@ toc: id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 + - label: JavaScript methods + id: usage-html-js-5 - label: Jinja and Nunjucks id: usage-macro - label: Examples @@ -156,6 +160,38 @@ toc: +

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
basecoat:popover
+
When the popover opens, the component dispatches a custom (non-bubbling) basecoat:popover event on document. Other popover components (Combobox, Dropdown Menu, Popover and Select) listen for this to close any open popovers.
+
change
+
When the selected value changes, the component dispatches a custom (bubbling) change event on itself, with the selected value in event.detail (e.g. { detail: { value: "something" }}).
+
+
+ +

JavaScript methods

+ +
+
+
selectByValue
+
+

You can call this method on the component after it is initialized to select an option by value (i.e. the option with the matching data-value attribute):

+ +{% set code_script %}{% endset %} +{{ code_block(code_script | prettyHtml, "html") }} +
+
+
+

Jinja and Nunjucks

@@ -250,10 +286,4 @@ toc: {% endcall %} {% endset %} -{{ code_preview("select-scrollable", code | prettyHtml) }} - \ No newline at end of file +{{ code_preview("select-scrollable", code | prettyHtml) }} \ No newline at end of file diff --git a/docs/src/components/sidebar.njk b/docs/src/components/sidebar.njk index fc14bc1..51e999c 100644 --- a/docs/src/components/sidebar.njk +++ b/docs/src/components/sidebar.njk @@ -15,6 +15,8 @@ toc: id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 - label: Jinja and Nunjucks id: usage-macro --- @@ -82,15 +84,6 @@ toc: {% endset %} {{ code_block(code_html | prettyHtml, "html") }} -
-

Any element on the page can toggle, open or close the sidebar by dispatching the basecoat:sidebar. By default, the event will toggle the sidebar, but can be used to open or close if you add an action to the detail:

-
- -{% set code_trigger %} - -{% endset %} -{{ code_block(code_trigger | prettyHtml, "html") }} -

HTML structure

@@ -160,6 +153,26 @@ toc:
+

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
basecoat:sidebar
+
+

Sidebars listen for this event on document to open, close or toggle themselves. By default, the event will toggle the sidebar, but can be used to open or close if you add an action to the detail. Additionally, if you have multiple sidebars on the page, you can target a specific sidebar by adding its id to the detail:

+ {% set code_trigger %} + + + + +{% endset %} + {{ code_block(code_trigger | prettyHtml, "html") }} +
+
+
+

Jinja and Nunjucks

diff --git a/docs/src/components/tabs.njk b/docs/src/components/tabs.njk index fec51fd..b3bd85a 100644 --- a/docs/src/components/tabs.njk +++ b/docs/src/components/tabs.njk @@ -8,6 +8,15 @@ toc: children: - label: HTML + JavaScript id: usage-default + children: + - label: "Step 1: Include the JavaScript files" + id: usage-html-js-1 + - label: "Step 2: Add your select HTML" + id: usage-html-js-2 + - label: HTML structure + id: usage-html-js-3 + - label: JavaScript events + id: usage-html-js-4 - label: Jinja and Nunjucks id: usage-macro --- @@ -130,6 +139,15 @@ toc: +

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on itself.
+
+
+

Jinja and Nunjucks

diff --git a/docs/src/components/toast.njk b/docs/src/components/toast.njk index ae6793c..1a885b4 100644 --- a/docs/src/components/toast.njk +++ b/docs/src/components/toast.njk @@ -17,8 +17,10 @@ toc: id: usage-html-js-3 - label: HTML structure id: usage-html-js-4 - - label: JavaScript config object + - label: JavaScript events id: usage-html-js-5 + - label: Toast config object + id: usage-html-js-6 - label: Jinja and Nunjucks id: usage-macro --- @@ -118,7 +120,7 @@ toc: {{ code_block(code_toast_html | prettyHtml, "html") }}
- + HTML structure {% lucide "arrow-right" %} @@ -131,8 +133,8 @@ toc: {{ code_block(code_client_side | prettyHtml, "html") }} @@ -176,7 +178,20 @@ toc: -

JavaScript config object

+

JavaScript events

+ +
+
+
basecoat:initialized
+
Once the component is fully initialized, it dispatches a custom (non-bubbling) basecoat:initialized event on the toaster element.
+
basecoat:toast
+
+

The toaster listens for basecoat:toast events on document to create toasts. The event's detail object must contain a config object (see JavaScript config object below).

+
+
+
+ +

Toast config object