@uxf/core-react
Advanced tools
Comparing version 11.32.0 to 11.33.0
@@ -9,5 +9,5 @@ import { KeyboardEventHandler, MouseEventHandler } from "react"; | ||
onKeyUp?: KeyboardEventHandler<T>; | ||
submit?: boolean; | ||
isSubmitType?: boolean; | ||
} | ||
export declare function _useSimulatedButton<T extends HTMLElement>({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }: Props<T>): { | ||
export declare function _useSimulatedButton<T extends HTMLElement>({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, isSubmitType, }: Props<T>): { | ||
onClick: MouseEventHandler<T>; | ||
@@ -14,0 +14,0 @@ onKeyDown: KeyboardEventHandler<T>; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const react_1 = require("react"); | ||
function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }) { | ||
function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, isSubmitType, }) { | ||
const _onClick = (0, react_1.useCallback)((e) => { | ||
@@ -13,3 +13,3 @@ var _a; | ||
if (isClickable) { | ||
if (submit) { | ||
if (isSubmitType) { | ||
const closestForm = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest("form"); | ||
@@ -27,3 +27,3 @@ if (closestForm) { | ||
} | ||
}, [analyticsCallback, isClickable, isHyperlink, onClick, submit]); | ||
}, [analyticsCallback, isClickable, isHyperlink, onClick, isSubmitType]); | ||
const _onKeyUp = (0, react_1.useCallback)((e) => { | ||
@@ -30,0 +30,0 @@ if (isClickable && (e.key === "Enter" || e.key === " ")) { |
import { AnchorHTMLAttributes } from "react"; | ||
export interface UseAnchorProps { | ||
analyticsCallback?: () => void; | ||
disabled?: boolean; | ||
loading?: boolean; | ||
isDisabled?: boolean; | ||
isLoading?: boolean; | ||
type?: "submit"; | ||
} | ||
export declare function useAnchorProps<T extends AnchorHTMLAttributes<HTMLAnchorElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, download, href, hrefLang, loading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }: UseAnchorProps & T): T; | ||
export declare function useAnchorProps<T extends AnchorHTMLAttributes<HTMLAnchorElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, isDisabled, download, href, hrefLang, isLoading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }: UseAnchorProps & T): T; |
@@ -8,10 +8,10 @@ "use strict"; | ||
const _use_simulated_button_1 = require("./_use-simulated-button"); | ||
function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, download, href, hrefLang, loading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }) { | ||
const isBusy = loading ? loading : Boolean(ariaBusy); | ||
const isDisabled = disabled ? disabled : Boolean(ariaDisabled); | ||
const isBusyOrDisabled = isBusy || isDisabled; | ||
const submit = type === "submit"; | ||
const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick); | ||
function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, isDisabled, download, href, hrefLang, isLoading, media, onClick, onKeyDown, onKeyUp, ping, referrerPolicy, rel, role, tabIndex, target, type, ...restProps }) { | ||
const isBusy = Boolean(isLoading || ariaBusy); | ||
const isDisabledOrAriaDisabled = Boolean(isDisabled || ariaDisabled); | ||
const isBusyOrDisabled = isBusy || isDisabledOrAriaDisabled; | ||
const isSubmitType = type === "submit"; | ||
const isButton = isSubmitType || (0, is_not_nil_1.isNotNil)(onClick); | ||
const tabIndexInteractive = isBusyOrDisabled ? -1 : tabIndex; | ||
const _className = [isBusy && classes_1.CLASSES.IS_LOADING, disabled && classes_1.CLASSES.IS_DISABLED, className]; | ||
const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabledOrAriaDisabled && classes_1.CLASSES.IS_DISABLED, className]; | ||
const simulatedButton = (0, _use_simulated_button_1._useSimulatedButton)({ | ||
@@ -24,3 +24,3 @@ analyticsCallback, | ||
onKeyUp, | ||
submit, | ||
isSubmitType, | ||
}); | ||
@@ -30,3 +30,3 @@ if (href) { | ||
"aria-busy": isBusy, | ||
"aria-disabled": isDisabled, | ||
"aria-disabled": isDisabledOrAriaDisabled, | ||
className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className), | ||
@@ -52,3 +52,3 @@ download, | ||
"aria-busy": isBusy, | ||
"aria-disabled": isDisabled, | ||
"aria-disabled": isDisabledOrAriaDisabled, | ||
className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className), | ||
@@ -55,0 +55,0 @@ onClick: simulatedButton.onClick, |
import { HTMLAttributes } from "react"; | ||
export interface UseClickableProps { | ||
analyticsCallback?: () => void; | ||
disabled?: boolean; | ||
loading?: boolean; | ||
isDisabled?: boolean; | ||
isLoading?: boolean; | ||
type?: "submit"; | ||
} | ||
export declare function useClickableProps<T extends HTMLAttributes<HTMLElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, loading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }: UseClickableProps & T): T; | ||
export declare function useClickableProps<T extends HTMLAttributes<HTMLElement>>({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, isDisabled, isLoading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }: UseClickableProps & T): T; |
@@ -8,9 +8,9 @@ "use strict"; | ||
const _use_simulated_button_1 = require("./_use-simulated-button"); | ||
function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, loading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }) { | ||
const isBusy = loading ? loading : Boolean(ariaBusy); | ||
const isDisabled = disabled ? disabled : Boolean(ariaDisabled); | ||
const isBusyOrDisabled = isBusy || isDisabled; | ||
const submit = type === "submit"; | ||
const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick); | ||
const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabled && classes_1.CLASSES.IS_DISABLED, className]; | ||
function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, isDisabled, isLoading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }) { | ||
const isBusy = Boolean(isLoading || ariaBusy); | ||
const isDisabledOrAriaDisabled = Boolean(isDisabled || ariaDisabled); | ||
const isBusyOrDisabled = isBusy || isDisabledOrAriaDisabled; | ||
const isSubmitType = type === "submit"; | ||
const isButton = isSubmitType || (0, is_not_nil_1.isNotNil)(onClick); | ||
const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabledOrAriaDisabled && classes_1.CLASSES.IS_DISABLED, className]; | ||
const simulatedButton = (0, _use_simulated_button_1._useSimulatedButton)({ | ||
@@ -23,3 +23,3 @@ analyticsCallback, | ||
onKeyUp, | ||
submit, | ||
isSubmitType, | ||
}); | ||
@@ -29,3 +29,3 @@ if (isButton) { | ||
"aria-busy": isBusy, | ||
"aria-disabled": isDisabled, | ||
"aria-disabled": isDisabledOrAriaDisabled, | ||
className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className), | ||
@@ -32,0 +32,0 @@ onClick: simulatedButton.onClick, |
{ | ||
"name": "@uxf/core-react", | ||
"version": "11.32.0", | ||
"version": "11.33.0", | ||
"description": "UXF Core", | ||
@@ -5,0 +5,0 @@ "author": "UX Fans s.r.o", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41220