@uxf/core-react 11.32.0 → 11.35.0

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.
@@ -6,9 +6,9 @@ interface Props<T extends HTMLElement> {
6
6
  onClick?: MouseEventHandler<T>;
7
7
  onKeyDown?: KeyboardEventHandler<T>;
8
8
  onKeyUp?: KeyboardEventHandler<T>;
9
- submit?: boolean;
9
+ isSubmitType?: boolean;
10
10
  }
11
- export declare function _useSimulatedButton<T extends HTMLElement>({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }: Props<T>): {
11
+ export declare function _useSimulatedButton<T extends HTMLElement>({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, isSubmitType, }: Props<T>): {
12
12
  onClick: MouseEventHandler<T>;
13
13
  onKeyDown: KeyboardEventHandler<T>;
14
14
  onKeyUp: KeyboardEventHandler<T>;
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._useSimulatedButton = _useSimulatedButton;
4
4
  const react_1 = require("react");
5
- function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, submit, }) {
5
+ function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onClick, onKeyDown, onKeyUp, isSubmitType, }) {
6
6
  const _onClick = (0, react_1.useCallback)((e) => {
7
7
  var _a;
8
8
  if ((isClickable || isHyperlink) && analyticsCallback) {
9
9
  analyticsCallback();
10
10
  }
11
11
  if (isClickable) {
12
- if (submit) {
12
+ if (isSubmitType) {
13
13
  const closestForm = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest("form");
14
14
  if (closestForm) {
15
15
  closestForm.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
@@ -22,7 +22,7 @@ function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onCl
22
22
  else {
23
23
  e.preventDefault();
24
24
  }
25
- }, [analyticsCallback, isClickable, isHyperlink, onClick, submit]);
25
+ }, [analyticsCallback, isClickable, isHyperlink, onClick, isSubmitType]);
26
26
  const _onKeyUp = (0, react_1.useCallback)((e) => {
27
27
  if (isClickable && (e.key === "Enter" || e.key === " ")) {
28
28
  e.target.dispatchEvent(new MouseEvent("click", {
@@ -1,8 +1,8 @@
1
1
  import { AnchorHTMLAttributes } from "react";
2
2
  export interface UseAnchorProps {
3
3
  analyticsCallback?: () => void;
4
- disabled?: boolean;
5
- loading?: boolean;
4
+ isDisabled?: boolean;
5
+ isLoading?: boolean;
6
6
  type?: "submit";
7
7
  }
8
- 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;
8
+ 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;
@@ -5,14 +5,14 @@ const classes_1 = require("@uxf/core/constants/classes");
5
5
  const cx_1 = require("@uxf/core/utils/cx");
6
6
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
7
7
  const _use_simulated_button_1 = require("./_use-simulated-button");
8
- 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 }) {
9
- const isBusy = loading ? loading : Boolean(ariaBusy);
10
- const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
11
- const isBusyOrDisabled = isBusy || isDisabled;
12
- const submit = type === "submit";
13
- const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick);
8
+ 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 }) {
9
+ const isBusy = Boolean(isLoading || ariaBusy);
10
+ const isDisabledOrAriaDisabled = Boolean(isDisabled || ariaDisabled);
11
+ const isBusyOrDisabled = isBusy || isDisabledOrAriaDisabled;
12
+ const isSubmitType = type === "submit";
13
+ const isButton = isSubmitType || (0, is_not_nil_1.isNotNil)(onClick);
14
14
  const tabIndexInteractive = isBusyOrDisabled ? -1 : tabIndex;
15
- const _className = [isBusy && classes_1.CLASSES.IS_LOADING, disabled && classes_1.CLASSES.IS_DISABLED, className];
15
+ const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabledOrAriaDisabled && classes_1.CLASSES.IS_DISABLED, className];
16
16
  const simulatedButton = (0, _use_simulated_button_1._useSimulatedButton)({
17
17
  analyticsCallback,
18
18
  isClickable: !isBusyOrDisabled || isButton,
@@ -20,12 +20,12 @@ function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabl
20
20
  onClick,
21
21
  onKeyDown,
22
22
  onKeyUp,
23
- submit,
23
+ isSubmitType,
24
24
  });
25
25
  if (href) {
26
26
  return {
27
27
  "aria-busy": isBusy,
28
- "aria-disabled": isDisabled,
28
+ "aria-disabled": isDisabledOrAriaDisabled,
29
29
  className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className),
30
30
  download,
31
31
  href,
@@ -46,7 +46,7 @@ function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabl
46
46
  if (isButton) {
47
47
  return {
48
48
  "aria-busy": isBusy,
49
- "aria-disabled": isDisabled,
49
+ "aria-disabled": isDisabledOrAriaDisabled,
50
50
  className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className),
51
51
  onClick: simulatedButton.onClick,
52
52
  onKeyDown: simulatedButton.onKeyDown,
@@ -1,8 +1,8 @@
1
1
  import { HTMLAttributes } from "react";
2
2
  export interface UseClickableProps {
3
3
  analyticsCallback?: () => void;
4
- disabled?: boolean;
5
- loading?: boolean;
4
+ isDisabled?: boolean;
5
+ isLoading?: boolean;
6
6
  type?: "submit";
7
7
  }
8
- 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;
8
+ 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;
@@ -5,13 +5,13 @@ const classes_1 = require("@uxf/core/constants/classes");
5
5
  const cx_1 = require("@uxf/core/utils/cx");
6
6
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
7
7
  const _use_simulated_button_1 = require("./_use-simulated-button");
8
- function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, disabled, loading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }) {
9
- const isBusy = loading ? loading : Boolean(ariaBusy);
10
- const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
11
- const isBusyOrDisabled = isBusy || isDisabled;
12
- const submit = type === "submit";
13
- const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick);
14
- const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabled && classes_1.CLASSES.IS_DISABLED, className];
8
+ function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabled, analyticsCallback, className, isDisabled, isLoading, onClick, onKeyDown, onKeyUp, role, tabIndex, type, ...restProps }) {
9
+ const isBusy = Boolean(isLoading || ariaBusy);
10
+ const isDisabledOrAriaDisabled = Boolean(isDisabled || ariaDisabled);
11
+ const isBusyOrDisabled = isBusy || isDisabledOrAriaDisabled;
12
+ const isSubmitType = type === "submit";
13
+ const isButton = isSubmitType || (0, is_not_nil_1.isNotNil)(onClick);
14
+ const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabledOrAriaDisabled && classes_1.CLASSES.IS_DISABLED, className];
15
15
  const simulatedButton = (0, _use_simulated_button_1._useSimulatedButton)({
16
16
  analyticsCallback,
17
17
  isClickable: !isBusyOrDisabled || isButton,
@@ -19,12 +19,12 @@ function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDis
19
19
  onClick,
20
20
  onKeyDown,
21
21
  onKeyUp,
22
- submit,
22
+ isSubmitType,
23
23
  });
24
24
  if (isButton) {
25
25
  return {
26
26
  "aria-busy": isBusy,
27
- "aria-disabled": isDisabled,
27
+ "aria-disabled": isDisabledOrAriaDisabled,
28
28
  className: (0, cx_1.cx)(classes_1.CLASSES.IS_HOVERABLE, ..._className),
29
29
  onClick: simulatedButton.onClick,
30
30
  onKeyDown: simulatedButton.onKeyDown,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core-react",
3
- "version": "11.32.0",
3
+ "version": "11.35.0",
4
4
  "description": "UXF Core",
5
5
  "author": "UX Fans s.r.o",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "typecheck": "tsc --noEmit --skipLibCheck"
13
13
  },
14
14
  "dependencies": {
15
- "@uxf/core": "11.32.0"
15
+ "@uxf/core": "11.35.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=18.2.0"