// Code generated by wa-generator. DO NOT EDIT. package wa import "fmt" // Event names for Web Awesome components // Use with Alpine.js x-on: directive or vanilla JS addEventListener const ( // blur - Emitted when the button loses focus. EventBlur = "blur" // change - Emitted when the checked state changes. EventChange = "change" // error - Emitted from the internal iframe when it fails to load. EventError = "error" // focus - Emitted when the button gains focus. EventFocus = "focus" // input - Emitted when the checkbox receives input. EventInput = "input" // load - Emitted when the internal iframe when it finishes loading. EventLoad = "load" // wa-after-collapse - Emitted after the tree item collapses and all animations are complete. EventWaAfterCollapse = "wa-after-collapse" // wa-after-expand - Emitted after the tree item expands and all animations are complete. EventWaAfterExpand = "wa-after-expand" // wa-after-hide - EventWaAfterHide = "wa-after-hide" // wa-after-show - EventWaAfterShow = "wa-after-show" // wa-cancel - Emitted when the animation is canceled. EventWaCancel = "wa-cancel" // wa-clear - Emitted when the control's value is cleared. EventWaClear = "wa-clear" // wa-collapse - Emitted when the tree item collapses. EventWaCollapse = "wa-collapse" // wa-copy - Emitted when the data has been copied. EventWaCopy = "wa-copy" // wa-error - Emitted when the image fails to load. EventWaError = "wa-error" // wa-expand - Emitted when the tree item expands. EventWaExpand = "wa-expand" // wa-finish - Emitted when the animation finishes. EventWaFinish = "wa-finish" // wa-hide - EventWaHide = "wa-hide" // wa-hover - Emitted when the user hovers over a value. The phase property indicates when hovering starts, moves to a new value, o... EventWaHover = "wa-hover" // wa-include-error - Emitted when the included file fails to load due to an error. EventWaIncludeError = "wa-include-error" // wa-intersect - Fired when a tracked element begins or ceases intersecting. EventWaIntersect = "wa-intersect" // wa-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. EventWaInvalid = "wa-invalid" // wa-lazy-change - Emitted when the tree item's lazy state changes. EventWaLazyChange = "wa-lazy-change" // wa-lazy-load - Emitted when a lazy item is selected. Use this event to asynchronously load data and append items to the tree before ... EventWaLazyLoad = "wa-lazy-load" // wa-load - Emitted when the image loads successfully. EventWaLoad = "wa-load" // wa-mutation - Emitted when a mutation occurs. EventWaMutation = "wa-mutation" // wa-remove - Emitted when the remove button is activated. EventWaRemove = "wa-remove" // wa-reposition - Emitted when the popup is repositioned. This event can fire a lot, so avoid putting expensive operations in your list... EventWaReposition = "wa-reposition" // wa-resize - Emitted when the element is resized. EventWaResize = "wa-resize" // wa-select - Emitted when an item in the dropdown is selected. EventWaSelect = "wa-select" // wa-selection-change - Emitted when a tree item is selected or deselected. EventWaSelectionChange = "wa-selection-change" // wa-show - EventWaShow = "wa-show" // wa-slide-change - Emitted when the active slide changes. EventWaSlideChange = "wa-slide-change" // wa-start - Emitted when the animation starts or restarts. EventWaStart = "wa-start" // wa-tab-hide - Emitted when a tab is hidden. EventWaTabHide = "wa-tab-hide" // wa-tab-show - Emitted when a tab is shown. EventWaTabShow = "wa-tab-show" ) // EventHandler creates an Alpine.js event handler string func EventHandler(jsCode string) string { return jsCode } // EventHandlerPrevent creates a handler that prevents default func EventHandlerPrevent(jsCode string) string { return "$event.preventDefault(); " + jsCode } // EventHandlerStop creates a handler that stops propagation func EventHandlerStop(jsCode string) string { return "$event.stopPropagation(); " + jsCode } // EventHandlerDebounce wraps handler with debounce func EventHandlerDebounce(jsCode string, ms int) string { return fmt.Sprintf("$debounce(() => { %s }, %d)", jsCode, ms) } // Common event handler patterns // ToggleHandler returns a handler that toggles a boolean value func ToggleHandler(varName string) string { return varName + " = !" + varName } // SetValueHandler returns a handler that sets a value func SetValueHandler(varName, value string) string { return fmt.Sprintf("%s = %s", varName, value) } // DispatchHandler returns a handler that dispatches a custom event func DispatchHandler(eventName string, detail string) string { if detail != "" { return fmt.Sprintf("$dispatch('%s', %s)", eventName, detail) } return fmt.Sprintf("$dispatch('%s')", eventName) } // FetchHandler returns a handler that performs a fetch request func FetchHandler(url, method, body string) string { if body != "" { return fmt.Sprintf("fetch('%s', {method: '%s', body: JSON.stringify(%s), headers: {'Content-Type': 'application/json'}})", url, method, body) } return fmt.Sprintf("fetch('%s', {method: '%s'})", url, method) }