@uxf/core 11.29.0 → 11.32.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.
Files changed (76) hide show
  1. package/components/hide.js +1 -2
  2. package/components/show.js +1 -2
  3. package/constants/empty-array.d.ts +1 -0
  4. package/constants/empty-array.js +4 -0
  5. package/constants/empty-object.d.ts +1 -0
  6. package/constants/empty-object.js +4 -0
  7. package/cookie/index.js +2 -1
  8. package/date/index.d.ts +1 -0
  9. package/date/is-time-string.d.ts +3 -0
  10. package/date/is-time-string.js +10 -0
  11. package/date/is-time-string.test.d.ts +1 -0
  12. package/date/is-time-string.test.js +11 -0
  13. package/date/to-date-string.d.ts +2 -0
  14. package/date/to-date-string.js +10 -0
  15. package/date/to-date-string.test.d.ts +1 -0
  16. package/date/to-date-string.test.js +7 -0
  17. package/date/to-datetime-string.d.ts +2 -0
  18. package/date/to-datetime-string.js +20 -0
  19. package/date/to-datetime-string.test.d.ts +1 -0
  20. package/date/to-datetime-string.test.js +14 -0
  21. package/date/to-time-string.d.ts +2 -0
  22. package/date/to-time-string.js +10 -0
  23. package/date/to-time-string.test.d.ts +1 -0
  24. package/date/to-time-string.test.js +8 -0
  25. package/hooks/_useSimulatedButton.js +1 -2
  26. package/hooks/useAnchorProps.js +4 -4
  27. package/hooks/useBodyScrollLock.js +1 -2
  28. package/hooks/useButtonProps.js +1 -2
  29. package/hooks/useClickableProps.js +4 -4
  30. package/hooks/useFocusReturn.js +2 -3
  31. package/hooks/useFocusTrap.js +1 -2
  32. package/hooks/useInputFocus.js +1 -2
  33. package/hooks/useIsMounted.js +1 -2
  34. package/hooks/useKey.js +1 -2
  35. package/hooks/useLatest.d.ts +0 -1
  36. package/hooks/useLatest.js +1 -2
  37. package/hooks/useMinWindowWidth.js +1 -2
  38. package/hooks/useMouseDragToScroll.js +1 -2
  39. package/hooks/useOnMount.js +1 -2
  40. package/hooks/useOnUnmount.js +1 -2
  41. package/hooks/useOnUpdate.js +1 -2
  42. package/hooks/usePrevious.d.ts +0 -1
  43. package/hooks/usePrevious.js +1 -2
  44. package/hooks/useRafState.js +1 -2
  45. package/hooks/useTabs.js +1 -2
  46. package/hooks/useWindowScroll.js +1 -2
  47. package/hooks/useWindowSize.js +1 -2
  48. package/package.json +3 -3
  49. package/types/index.d.ts +1 -0
  50. package/utils/assert-not-nil.js +1 -2
  51. package/utils/bodyScrollLock.js +10 -10
  52. package/utils/buildArray.js +1 -2
  53. package/utils/camelCaseToDash.js +1 -2
  54. package/utils/composeRefs.js +1 -2
  55. package/utils/copy-to-clipboard.js +7 -3
  56. package/utils/cx.js +1 -2
  57. package/utils/cxa.d.ts +1 -1
  58. package/utils/cxa.js +1 -2
  59. package/utils/file.js +1 -2
  60. package/utils/filter-nullish.js +1 -2
  61. package/utils/image.js +16 -17
  62. package/utils/is-empty.js +1 -2
  63. package/utils/is-nil.js +1 -2
  64. package/utils/is-not-empty.js +1 -2
  65. package/utils/is-not-nil.js +1 -2
  66. package/utils/isBrowser.js +1 -1
  67. package/utils/last.js +1 -2
  68. package/utils/noop.d.ts +2 -0
  69. package/utils/noop.js +5 -0
  70. package/utils/pagination.js +10 -7
  71. package/utils/resizer.js +2 -2
  72. package/utils/slugify.js +1 -2
  73. package/utils/sort-object-keys.js +1 -2
  74. package/utils/throw-error.d.ts +1 -0
  75. package/utils/throw-error.js +6 -0
  76. package/utils/trimTrailingZeros.js +1 -2
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Hide = void 0;
6
+ exports.Hide = Hide;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  /**
9
9
  * @deprecated Use import from @uxf/core-react instead.
@@ -14,4 +14,3 @@ function Hide(props) {
14
14
  }
15
15
  return react_1.default.createElement(react_1.default.Fragment, null, props.children);
16
16
  }
17
- exports.Hide = Hide;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Show = void 0;
6
+ exports.Show = Show;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  /**
9
9
  * @deprecated Use import from @uxf/core-react instead.
@@ -14,4 +14,3 @@ function Show(props) {
14
14
  }
15
15
  return react_1.default.createElement(react_1.default.Fragment, null, props.children);
16
16
  }
17
- exports.Show = Show;
@@ -0,0 +1 @@
1
+ export declare const EMPTY_ARRAY: [];
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_ARRAY = void 0;
4
+ exports.EMPTY_ARRAY = [];
@@ -0,0 +1 @@
1
+ export declare const EMPTY_OBJECT: Record<string, never>;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_OBJECT = void 0;
4
+ exports.EMPTY_OBJECT = {};
package/cookie/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cookie = void 0;
4
+ const is_not_empty_1 = require("../utils/is-not-empty");
4
5
  class Cookie {
5
6
  constructor(ctx = null) {
6
7
  this.ctx = ctx;
@@ -9,7 +10,7 @@ class Cookie {
9
10
  return new Cookie(ctx);
10
11
  }
11
12
  has(name) {
12
- return !!this.get(name);
13
+ return (0, is_not_empty_1.isNotEmpty)(this.get(name));
13
14
  }
14
15
  set(name, value, ttl = 3600, options = {}) {
15
16
  const date = new Date();
package/date/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export type DateString = `${number}-${number}-${number}`;
2
2
  export type DatetimeString = `${number}-${number}-${number}T${number}:${number}:${number}+${number}:${number}`;
3
3
  export type DateValue = Date | DateString | DatetimeString;
4
+ export type TimeString = `${number}:${number}:${number}`;
@@ -0,0 +1,3 @@
1
+ import { Nullish } from "../types";
2
+ import { TimeString } from "./index";
3
+ export declare function isTimeString(value: string | Nullish): value is TimeString;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTimeString = isTimeString;
4
+ const is_nil_1 = require("../utils/is-nil");
5
+ function isTimeString(value) {
6
+ if ((0, is_nil_1.isNil)(value)) {
7
+ return false;
8
+ }
9
+ return /(?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)/.test(value);
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const is_time_string_1 = require("./is-time-string");
4
+ test("toDateString", () => {
5
+ expect((0, is_time_string_1.isTimeString)("00:00:00")).toBe(true);
6
+ expect((0, is_time_string_1.isTimeString)("12:30:30")).toBe(true);
7
+ expect((0, is_time_string_1.isTimeString)("23:59:59")).toBe(true);
8
+ expect((0, is_time_string_1.isTimeString)("23:30")).toBe(false);
9
+ expect((0, is_time_string_1.isTimeString)("23:60:60")).toBe(false);
10
+ expect((0, is_time_string_1.isTimeString)("24:00:00")).toBe(false);
11
+ });
@@ -0,0 +1,2 @@
1
+ import { DateString } from "./index";
2
+ export declare function toDateString<T extends Date | null>(value: T): T extends null ? DateString | null : DateString;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDateString = toDateString;
4
+ const is_nil_1 = require("../utils/is-nil");
5
+ function toDateString(value) {
6
+ if ((0, is_nil_1.isNil)(value)) {
7
+ return null;
8
+ }
9
+ return value.toISOString().substring(0, 10);
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const to_date_string_1 = require("./to-date-string");
4
+ test("toDateString", () => {
5
+ expect((0, to_date_string_1.toDateString)(new Date("2024-10-30 12:00:00"))).toBe("2024-10-30");
6
+ expect((0, to_date_string_1.toDateString)(new Date("2300-01-01 12:00:00"))).toBe("2300-01-01");
7
+ });
@@ -0,0 +1,2 @@
1
+ import { DatetimeString } from "./index";
2
+ export declare function toDatetimeString<T extends Date | null>(value: T): T extends null ? DatetimeString | null : DatetimeString;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toDatetimeString = toDatetimeString;
4
+ const is_nil_1 = require("../utils/is-nil");
5
+ function toDatetimeString(value) {
6
+ if ((0, is_nil_1.isNil)(value)) {
7
+ return null;
8
+ }
9
+ const month = String(value.getMonth() + 1).padStart(2, "0");
10
+ const day = String(value.getDate()).padStart(2, "0");
11
+ const hours = String(value.getHours()).padStart(2, "0");
12
+ const minutes = String(value.getMinutes()).padStart(2, "0");
13
+ const seconds = String(value.getSeconds()).padStart(2, "0");
14
+ const timezoneOffset = -value.getTimezoneOffset();
15
+ const offsetHours = String(Math.floor(Math.abs(timezoneOffset) / 60)).padStart(2, "0");
16
+ const offsetMinutes = String(Math.abs(timezoneOffset) % 60).padStart(2, "0");
17
+ const offsetSign = timezoneOffset >= 0 ? "+" : "-";
18
+ const timezone = `${offsetSign}${offsetHours}:${offsetMinutes}`;
19
+ return `${value.getFullYear()}-${month}-${day}T${hours}:${minutes}:${seconds}${timezone}`;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const to_datetime_string_1 = require("./to-datetime-string");
4
+ test("toDatetimeString", () => {
5
+ const oldTimezoneFunction = Date.prototype.getTimezoneOffset;
6
+ Date.prototype.getTimezoneOffset = () => -60;
7
+ expect((0, to_datetime_string_1.toDatetimeString)(new Date("2024-01-01 20:15:30"))).toBe("2024-01-01T20:15:30+01:00");
8
+ Date.prototype.getTimezoneOffset = () => -120;
9
+ expect((0, to_datetime_string_1.toDatetimeString)(new Date("2024-08-01 20:15:30"))).toBe("2024-08-01T20:15:30+02:00");
10
+ expect((0, to_datetime_string_1.toDatetimeString)(new Date("2024-08-01 23:59:59"))).toBe("2024-08-01T23:59:59+02:00");
11
+ Date.prototype.getTimezoneOffset = () => -150;
12
+ expect((0, to_datetime_string_1.toDatetimeString)(new Date("2024-01-01 12:00:00"))).toBe("2024-01-01T12:00:00+02:30");
13
+ Date.prototype.getTimezoneOffset = oldTimezoneFunction;
14
+ });
@@ -0,0 +1,2 @@
1
+ import { TimeString } from "./index";
2
+ export declare function toTimeString<T extends Date | null>(value: T): T extends null ? TimeString | null : TimeString;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toTimeString = toTimeString;
4
+ const is_nil_1 = require("../utils/is-nil");
5
+ function toTimeString(value) {
6
+ if ((0, is_nil_1.isNil)(value)) {
7
+ return null;
8
+ }
9
+ return `${value.getHours().toString().padStart(2, "0")}:${value.getMinutes().toString().padStart(2, "0")}:${value.getSeconds().toString().padStart(2, "0")}`;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const to_time_string_1 = require("./to-time-string");
4
+ test("toDatetimeString", () => {
5
+ expect((0, to_time_string_1.toTimeString)(new Date("2024-01-01 01:01:01"))).toBe("01:01:01");
6
+ expect((0, to_time_string_1.toTimeString)(new Date("2024-01-01 20:15:30"))).toBe("20:15:30");
7
+ expect((0, to_time_string_1.toTimeString)(new Date("2024-01-01 23:59:59"))).toBe("23:59:59");
8
+ });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._useSimulatedButton = void 0;
3
+ exports._useSimulatedButton = _useSimulatedButton;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -49,4 +49,3 @@ function _useSimulatedButton({ analyticsCallback, isClickable, isHyperlink, onCl
49
49
  }, [isClickable, onKeyDown]);
50
50
  return { onClick: _onClick, onKeyDown: _onKeyDown, onKeyUp: _onKeyUp };
51
51
  }
52
- exports._useSimulatedButton = _useSimulatedButton;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useAnchorProps = void 0;
3
+ exports.useAnchorProps = useAnchorProps;
4
4
  const classes_1 = require("../constants/classes");
5
5
  const cx_1 = require("../utils/cx");
6
+ const is_not_nil_1 = require("../utils/is-not-nil");
6
7
  const _useSimulatedButton_1 = require("./_useSimulatedButton");
7
8
  /**
8
9
  * @deprecated Use import from @uxf/core-react instead.
@@ -12,13 +13,13 @@ function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabl
12
13
  const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
13
14
  const isBusyOrDisabled = isBusy || isDisabled;
14
15
  const submit = type === "submit";
15
- const isButton = submit || !!onClick;
16
+ const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick);
16
17
  const tabIndexInteractive = isBusyOrDisabled ? -1 : tabIndex;
17
18
  const _className = [isBusy && classes_1.CLASSES.IS_LOADING, disabled && classes_1.CLASSES.IS_DISABLED, className];
18
19
  const simulatedButton = (0, _useSimulatedButton_1._useSimulatedButton)({
19
20
  analyticsCallback,
20
21
  isClickable: !isBusyOrDisabled || isButton,
21
- isHyperlink: !isBusyOrDisabled || !!href,
22
+ isHyperlink: !isBusyOrDisabled || Boolean(href),
22
23
  onClick,
23
24
  onKeyDown,
24
25
  onKeyUp,
@@ -65,4 +66,3 @@ function useAnchorProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabl
65
66
  ...restProps,
66
67
  };
67
68
  }
68
- exports.useAnchorProps = useAnchorProps;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBodyScrollLock = void 0;
3
+ exports.useBodyScrollLock = useBodyScrollLock;
4
4
  const react_1 = require("react");
5
5
  const bodyScrollLock_1 = require("../utils/bodyScrollLock");
6
6
  /**
@@ -35,4 +35,3 @@ function useBodyScrollLock(containerRef, isOpen, { allowTouchMove, clearAllOnClo
35
35
  };
36
36
  }, [allowTouchMove, clearAllOnClose, containerRef, isOpen, reserveScrollBarGap]);
37
37
  }
38
- exports.useBodyScrollLock = useBodyScrollLock;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useButtonProps = void 0;
3
+ exports.useButtonProps = useButtonProps;
4
4
  const react_1 = require("react");
5
5
  const classes_1 = require("../constants/classes");
6
6
  const cx_1 = require("../utils/cx");
@@ -59,4 +59,3 @@ function useButtonProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDisabl
59
59
  ...restProps,
60
60
  };
61
61
  }
62
- exports.useButtonProps = useButtonProps;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useClickableProps = void 0;
3
+ exports.useClickableProps = useClickableProps;
4
4
  const classes_1 = require("../constants/classes");
5
5
  const cx_1 = require("../utils/cx");
6
+ const is_not_nil_1 = require("../utils/is-not-nil");
6
7
  const _useSimulatedButton_1 = require("./_useSimulatedButton");
7
8
  /**
8
9
  * @deprecated Use import from @uxf/core-react instead.
@@ -12,7 +13,7 @@ function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDis
12
13
  const isDisabled = disabled ? disabled : Boolean(ariaDisabled);
13
14
  const isBusyOrDisabled = isBusy || isDisabled;
14
15
  const submit = type === "submit";
15
- const isButton = submit || !!onClick;
16
+ const isButton = submit || (0, is_not_nil_1.isNotNil)(onClick);
16
17
  const _className = [isBusy && classes_1.CLASSES.IS_LOADING, isDisabled && classes_1.CLASSES.IS_DISABLED, className];
17
18
  const simulatedButton = (0, _useSimulatedButton_1._useSimulatedButton)({
18
19
  analyticsCallback,
@@ -32,7 +33,7 @@ function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDis
32
33
  onKeyDown: simulatedButton.onKeyDown,
33
34
  onKeyUp: simulatedButton.onKeyUp,
34
35
  role: role || "button",
35
- tabIndex: isBusyOrDisabled ? -1 : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
36
+ tabIndex: isBusyOrDisabled ? -1 : (tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0),
36
37
  ...restProps,
37
38
  };
38
39
  }
@@ -43,4 +44,3 @@ function useClickableProps({ ["aria-busy"]: ariaBusy, ["aria-disabled"]: ariaDis
43
44
  ...restProps,
44
45
  };
45
46
  }
46
- exports.useClickableProps = useClickableProps;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFocusReturn = void 0;
3
+ exports.useFocusReturn = useFocusReturn;
4
4
  const react_1 = require("react");
5
5
  const useOnUpdate_1 = require("./useOnUpdate");
6
6
  /**
@@ -32,7 +32,6 @@ function useFocusReturn(opened, transitionDuration = 0, shouldReturnFocus = true
32
32
  clearTimeout(timeout);
33
33
  document.removeEventListener("keydown", clearFocusTimeout);
34
34
  };
35
- }, [opened]);
35
+ }, [opened, shouldReturnFocus, transitionDuration]);
36
36
  return returnFocus;
37
37
  }
38
- exports.useFocusReturn = useFocusReturn;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFocusTrap = void 0;
3
+ exports.useFocusTrap = useFocusTrap;
4
4
  const react_1 = require("react");
5
5
  const useOnUnmount_1 = require("./useOnUnmount");
6
6
  const TABBABLE_NODES = /input|select|textarea|button|object/;
@@ -146,4 +146,3 @@ function useFocusTrap(active = true) {
146
146
  (0, useOnUnmount_1.useOnUnmount)(() => clearTimeout(timer.current));
147
147
  return setRef;
148
148
  }
149
- exports.useFocusTrap = useFocusTrap;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useInputFocus = void 0;
3
+ exports.useInputFocus = useInputFocus;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -27,4 +27,3 @@ function useInputFocus(focusRef, onBlur, onFocus) {
27
27
  }, [onBlur]);
28
28
  return { focused, focus, onBlur: _onBlur, onFocus: _onFocus };
29
29
  }
30
- exports.useInputFocus = useInputFocus;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useIsMounted = void 0;
3
+ exports.useIsMounted = useIsMounted;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -10,4 +10,3 @@ function useIsMounted() {
10
10
  (0, react_1.useEffect)(() => setIsMounted(true), []);
11
11
  return isMounted;
12
12
  }
13
- exports.useIsMounted = useIsMounted;
package/hooks/useKey.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useKey = void 0;
3
+ exports.useKey = useKey;
4
4
  const react_1 = require("react");
5
5
  const createKeyPredicate = (keyFilter) => typeof keyFilter === "function"
6
6
  ? keyFilter
@@ -28,4 +28,3 @@ function useKey(keyFilter, callback, { disabled, targetRef, type = "keydown" } =
28
28
  };
29
29
  }, [callback, disabled, keyFilter, targetRef, type]);
30
30
  }
31
- exports.useKey = useKey;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * @deprecated Use import from @uxf/core-react instead.
4
3
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useLatest = void 0;
3
+ exports.useLatest = useLatest;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -10,4 +10,3 @@ function useLatest(current) {
10
10
  storedValue.current = current;
11
11
  return storedValue;
12
12
  }
13
- exports.useLatest = useLatest;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMinWindowWidth = void 0;
3
+ exports.useMinWindowWidth = useMinWindowWidth;
4
4
  const react_1 = require("react");
5
5
  const useRafState_1 = require("./useRafState");
6
6
  /**
@@ -29,4 +29,3 @@ function useMinWindowWidth(minWidth, debounce = 0) {
29
29
  }, [debounce, minWidth, setState]);
30
30
  return state;
31
31
  }
32
- exports.useMinWindowWidth = useMinWindowWidth;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMouseDragToScroll = void 0;
3
+ exports.useMouseDragToScroll = useMouseDragToScroll;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -39,4 +39,3 @@ function useMouseDragToScroll(containerRef) {
39
39
  }, [containerRef]);
40
40
  return style;
41
41
  }
42
- exports.useMouseDragToScroll = useMouseDragToScroll;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOnMount = void 0;
3
+ exports.useOnMount = useOnMount;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -10,4 +10,3 @@ function useOnMount(effect) {
10
10
  return effect();
11
11
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
12
12
  }
13
- exports.useOnMount = useOnMount;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOnUnmount = void 0;
3
+ exports.useOnUnmount = useOnUnmount;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -15,4 +15,3 @@ function useOnUnmount(effect) {
15
15
  };
16
16
  }, []);
17
17
  }
18
- exports.useOnUnmount = useOnUnmount;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useOnUpdate = void 0;
3
+ exports.useOnUpdate = useOnUpdate;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -15,4 +15,3 @@ function useOnUpdate(effect, deps) {
15
15
  return effect();
16
16
  }, deps); // eslint-disable-line react-hooks/exhaustive-deps
17
17
  }
18
- exports.useOnUpdate = useOnUpdate;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /**
3
2
  * @deprecated Use import from @uxf/core-react instead.
4
3
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePrevious = void 0;
3
+ exports.usePrevious = usePrevious;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * @deprecated Use import from @uxf/core-react instead.
@@ -12,4 +12,3 @@ function usePrevious(current) {
12
12
  });
13
13
  return storedValue;
14
14
  }
15
- exports.usePrevious = usePrevious;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRafState = void 0;
3
+ exports.useRafState = useRafState;
4
4
  const react_1 = require("react");
5
5
  const useOnUnmount_1 = require("./useOnUnmount");
6
6
  /**
@@ -18,4 +18,3 @@ function useRafState(initialState) {
18
18
  (0, useOnUnmount_1.useOnUnmount)(() => cancelAnimationFrame(frame.current));
19
19
  return [state, setRafState];
20
20
  }
21
- exports.useRafState = useRafState;
package/hooks/useTabs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useTabs = void 0;
3
+ exports.useTabs = useTabs;
4
4
  const react_1 = require("react");
5
5
  const useKey_1 = require("./useKey");
6
6
  const useOnUpdate_1 = require("./useOnUpdate");
@@ -41,4 +41,3 @@ function useTabs({ activeTab, id, tabListRef, tabsCount }) {
41
41
  tabTitleIdPrefix,
42
42
  };
43
43
  }
44
- exports.useTabs = useTabs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useWindowScroll = void 0;
3
+ exports.useWindowScroll = useWindowScroll;
4
4
  const react_1 = require("react");
5
5
  const useRafState_1 = require("./useRafState");
6
6
  /**
@@ -22,4 +22,3 @@ function useWindowScroll() {
22
22
  }, [setState]);
23
23
  return state;
24
24
  }
25
- exports.useWindowScroll = useWindowScroll;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useWindowSize = void 0;
3
+ exports.useWindowSize = useWindowSize;
4
4
  const react_1 = require("react");
5
5
  const useRafState_1 = require("./useRafState");
6
6
  /**
@@ -19,4 +19,3 @@ function useWindowSize() {
19
19
  }, [setState]);
20
20
  return state;
21
21
  }
22
- exports.useWindowSize = useWindowSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/core",
3
- "version": "11.29.0",
3
+ "version": "11.32.0",
4
4
  "description": "UXF Core",
5
5
  "author": "Petr Vejvoda <vejvoda@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/core#readme",
@@ -26,8 +26,8 @@
26
26
  "react": ">=18.2.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/react": "18.2.63",
30
- "react": "18.2.0"
29
+ "@types/react": "18.3.5",
30
+ "react": "18.3.1"
31
31
  },
32
32
  "gitHead": "a2dee6aa67621f6eda17e63e88d0edf14f88455a"
33
33
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type Nullish = null | undefined;
2
+ export type Noop = () => void;
2
3
  export interface FileResponse {
3
4
  id: number;
4
5
  name: string;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertNotNil = void 0;
3
+ exports.assertNotNil = assertNotNil;
4
4
  const is_nil_1 = require("./is-nil");
5
5
  function assertNotNil(value, errorMessage = "Value is nil.") {
6
6
  if ((0, is_nil_1.isNil)(value)) {
7
7
  throw new Error(errorMessage);
8
8
  }
9
9
  }
10
- exports.assertNotNil = assertNotNil;
@@ -2,9 +2,7 @@
2
2
  // Forked from "body-scroll-lock" https://github.com/willmcpo/body-scroll-lock
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.enableBodyScroll = exports.clearAllBodyScrollLocks = exports.disableBodyScroll = void 0;
5
- function noop() {
6
- return void null;
7
- }
5
+ const noop_1 = require("./noop");
8
6
  // Older browsers don't support event options, feature detect it.
9
7
  let hasPassiveEvents = false;
10
8
  if (typeof window !== "undefined") {
@@ -14,8 +12,8 @@ if (typeof window !== "undefined") {
14
12
  return undefined;
15
13
  },
16
14
  };
17
- window.addEventListener("testPassive", noop, passiveTestOptions);
18
- window.removeEventListener("testPassive", noop);
15
+ window.addEventListener("testPassive", noop_1.noop, passiveTestOptions);
16
+ window.removeEventListener("testPassive", noop_1.noop);
19
17
  }
20
18
  const isIosDevice = typeof window !== "undefined" &&
21
19
  typeof window.navigator !== "undefined" &&
@@ -29,7 +27,7 @@ let previousBodyOverflowSetting;
29
27
  let previousBodyPosition;
30
28
  let previousBodyPaddingRight;
31
29
  // returns true if `el` should be allowed to receive touchmove events.
32
- const allowTouchMove = (el) => locks.some((lock) => !!(lock.options.allowTouchMove && lock.options.allowTouchMove(el)));
30
+ const allowTouchMove = (el) => locks.some((lock) => { var _a, _b; return Boolean((_b = (_a = lock.options) === null || _a === void 0 ? void 0 : _a.allowTouchMove) === null || _b === void 0 ? void 0 : _b.call(_a, el)); });
33
31
  const preventDefault = (rawEvent) => {
34
32
  const e = typeof rawEvent !== "undefined" ? rawEvent : window.event;
35
33
  // For the case whereby consumers adds a touchmove event listener to document.
@@ -51,7 +49,7 @@ const preventDefault = (rawEvent) => {
51
49
  const setOverflowHidden = (options) => {
52
50
  // If previousBodyPaddingRight is already set, don't set it again.
53
51
  if (previousBodyPaddingRight === undefined) {
54
- const reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
52
+ const reserveScrollBarGap = (options === null || options === void 0 ? void 0 : options.reserveScrollBarGap) === true;
55
53
  const scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
56
54
  if (reserveScrollBarGap && scrollBarGap > 0) {
57
55
  const computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"), 10);
@@ -119,7 +117,8 @@ const restorePositionSetting = () => {
119
117
  // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
120
118
  const isTargetElementTotallyScrolled = (targetElement) => targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
121
119
  const handleScroll = (event, targetElement) => {
122
- const clientY = event.targetTouches[0].clientY - initialClientY;
120
+ var _a, _b;
121
+ const clientY = (_b = (_a = event.targetTouches.item(0)) === null || _a === void 0 ? void 0 : _a.clientY) !== null && _b !== void 0 ? _b : 0 - initialClientY;
123
122
  if (event.target && allowTouchMove(event.target)) {
124
123
  return false;
125
124
  }
@@ -147,7 +146,7 @@ const disableBodyScroll = (targetElement, options) => {
147
146
  }
148
147
  const lock = {
149
148
  targetElement,
150
- options: options || {},
149
+ options,
151
150
  };
152
151
  locks = [...locks, lock];
153
152
  if (isIosDevice) {
@@ -158,9 +157,10 @@ const disableBodyScroll = (targetElement, options) => {
158
157
  }
159
158
  if (isIosDevice) {
160
159
  targetElement.ontouchstart = (event) => {
160
+ var _a, _b;
161
161
  if (event.targetTouches.length === 1) {
162
162
  // detect single touch.
163
- initialClientY = event.targetTouches[0].clientY;
163
+ initialClientY = (_b = (_a = event.targetTouches.item(0)) === null || _a === void 0 ? void 0 : _a.clientY) !== null && _b !== void 0 ? _b : 0;
164
164
  }
165
165
  };
166
166
  targetElement.ontouchmove = (event) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildArray = void 0;
3
+ exports.buildArray = buildArray;
4
4
  function buildArray(initial) {
5
5
  const initialArray = (initial ? [...initial] : []);
6
6
  const proxiedArray = new Proxy(initialArray, {
@@ -24,4 +24,3 @@ function buildArray(initial) {
24
24
  });
25
25
  return proxiedArray;
26
26
  }
27
- exports.buildArray = buildArray;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelCaseToDash = void 0;
3
+ exports.camelCaseToDash = camelCaseToDash;
4
4
  function camelCaseToDash(content) {
5
5
  return content.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
6
6
  }
7
- exports.camelCaseToDash = camelCaseToDash;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeRefs = void 0;
3
+ exports.composeRefs = composeRefs;
4
4
  /**
5
5
  * @deprecated Use import from @uxf/core-react instead.
6
6
  */
@@ -16,4 +16,3 @@ function composeRefs(...refs) {
16
16
  ref.current = value;
17
17
  });
18
18
  }
19
- exports.composeRefs = composeRefs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copyToClipboard = void 0;
3
+ exports.copyToClipboard = copyToClipboard;
4
4
  function copyToClipboardFallback(text) {
5
5
  const textArea = document.createElement("textarea");
6
6
  textArea.value = text;
@@ -17,7 +17,12 @@ function copyToClipboardFallback(text) {
17
17
  async function copyToClipboard(text) {
18
18
  const isSupported = typeof navigator.clipboard !== "undefined" && typeof navigator.clipboard.writeText === "function";
19
19
  try {
20
- isSupported ? await navigator.clipboard.writeText(text) : copyToClipboardFallback(text);
20
+ if (isSupported) {
21
+ await navigator.clipboard.writeText(text);
22
+ }
23
+ else {
24
+ copyToClipboardFallback(text);
25
+ }
21
26
  return true;
22
27
  }
23
28
  catch (e) {
@@ -26,4 +31,3 @@ async function copyToClipboard(text) {
26
31
  return false;
27
32
  }
28
33
  }
29
- exports.copyToClipboard = copyToClipboard;
package/utils/cx.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cx = void 0;
3
+ exports.cx = cx;
4
4
  function cx(...classes) {
5
5
  let i = 0, tmp, str = "";
6
6
  for (; i < classes.length; i++) {
@@ -12,4 +12,3 @@ function cx(...classes) {
12
12
  }
13
13
  return str;
14
14
  }
15
- exports.cx = cx;
package/utils/cxa.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export type CxaClassArray = CxaClassValue[];
2
1
  export type CxaClassValue = CxaClassArray | Record<string, any> | string | number | null | boolean | undefined;
2
+ export type CxaClassArray = CxaClassValue[];
3
3
  export declare function cxa(...classes: CxaClassValue[]): string;
package/utils/cxa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cxa = void 0;
3
+ exports.cxa = cxa;
4
4
  function toVal(mix) {
5
5
  let k;
6
6
  let y;
@@ -51,4 +51,3 @@ function cxa(...classes) {
51
51
  }
52
52
  return str;
53
53
  }
54
- exports.cxa = cxa;
package/utils/file.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFileUrl = void 0;
3
+ exports.getFileUrl = getFileUrl;
4
4
  function getFileUrl(file) {
5
5
  const ch1 = file.uuid.charAt(0);
6
6
  const ch2 = file.uuid.charAt(1);
@@ -8,4 +8,3 @@ function getFileUrl(file) {
8
8
  ? `/upload/${file.namespace}/${ch1}/${ch2}/${file.uuid}.${file.extension}`
9
9
  : `/upload/${ch1}/${ch2}/${file.uuid}.${file.extension}`;
10
10
  }
11
- exports.getFileUrl = getFileUrl;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterNullish = void 0;
3
+ exports.filterNullish = filterNullish;
4
4
  const is_not_nil_1 = require("./is-not-nil");
5
5
  function filterNullish(val) {
6
6
  return val.filter(is_not_nil_1.isNotNil);
7
7
  }
8
- exports.filterNullish = filterNullish;
package/utils/image.js CHANGED
@@ -3,7 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ImgSources = exports.getImgSrcSet = exports.getImgElementWidth = exports.getImgElementHeight = exports.getImgUniqueIdentifier = exports.getImgQuality = exports.getSvgImgUrl = exports.parseImgExtension = exports.isSrcStaticImageData = exports.isSrcImageResponse = exports.isSrcString = void 0;
6
+ exports.isSrcString = isSrcString;
7
+ exports.isSrcImageResponse = isSrcImageResponse;
8
+ exports.isSrcStaticImageData = isSrcStaticImageData;
9
+ exports.parseImgExtension = parseImgExtension;
10
+ exports.getSvgImgUrl = getSvgImgUrl;
11
+ exports.getImgQuality = getImgQuality;
12
+ exports.getImgUniqueIdentifier = getImgUniqueIdentifier;
13
+ exports.getImgElementHeight = getImgElementHeight;
14
+ exports.getImgElementWidth = getImgElementWidth;
15
+ exports.getImgSrcSet = getImgSrcSet;
16
+ exports.ImgSources = ImgSources;
7
17
  const hide_1 = require("@uxf/core-react/components/hide");
8
18
  const react_1 = __importDefault(require("react"));
9
19
  const file_1 = require("./file");
@@ -13,20 +23,16 @@ const resizer_1 = require("./resizer");
13
23
  function isSrcString(src) {
14
24
  return typeof src === "string";
15
25
  }
16
- exports.isSrcString = isSrcString;
17
26
  function isSrcImageResponse(src) {
18
27
  return !isSrcString(src) && "uuid" in src;
19
28
  }
20
- exports.isSrcImageResponse = isSrcImageResponse;
21
29
  function isSrcStaticImageData(src) {
22
30
  return !isSrcString(src) && "src" in src;
23
31
  }
24
- exports.isSrcStaticImageData = isSrcStaticImageData;
25
32
  function parseImgExtension(src) {
26
33
  const ext = src.slice(src.lastIndexOf(".") + 1);
27
34
  return ext.length > 1 ? ext : undefined;
28
35
  }
29
- exports.parseImgExtension = parseImgExtension;
30
36
  function isSvgExtension(src) {
31
37
  return parseImgExtension(src) === "svg";
32
38
  }
@@ -42,14 +48,12 @@ function getSvgImgUrl(src) {
42
48
  }
43
49
  return undefined;
44
50
  }
45
- exports.getSvgImgUrl = getSvgImgUrl;
46
51
  function getImgQuality(quality, format) {
47
52
  if (typeof quality === "number") {
48
53
  return quality;
49
54
  }
50
55
  return quality ? quality[format] : undefined;
51
56
  }
52
- exports.getImgQuality = getImgQuality;
53
57
  function getImgUniqueIdentifier(src) {
54
58
  return isSrcString(src)
55
59
  ? src
@@ -59,7 +63,6 @@ function getImgUniqueIdentifier(src) {
59
63
  ? src.src
60
64
  : undefined;
61
65
  }
62
- exports.getImgUniqueIdentifier = getImgUniqueIdentifier;
63
66
  function getImgElementHeight(src, width, height) {
64
67
  var _a, _b;
65
68
  if (isSrcString(src) || (0, is_not_nil_1.isNotNil)(height)) {
@@ -68,7 +71,6 @@ function getImgElementHeight(src, width, height) {
68
71
  const calculatedHeight = Math.floor((((_a = src.height) !== null && _a !== void 0 ? _a : 0) / ((_b = src.width) !== null && _b !== void 0 ? _b : 0)) * (width !== null && width !== void 0 ? width : 0));
69
72
  return calculatedHeight === 0 ? undefined : calculatedHeight;
70
73
  }
71
- exports.getImgElementHeight = getImgElementHeight;
72
74
  function getImgElementWidth(src, width, height) {
73
75
  var _a, _b;
74
76
  if (isSrcString(src) || (0, is_not_nil_1.isNotNil)(width)) {
@@ -77,7 +79,6 @@ function getImgElementWidth(src, width, height) {
77
79
  const calculatedWidth = Math.floor(((_a = src.width) !== null && _a !== void 0 ? _a : 0) / ((_b = src.height) !== null && _b !== void 0 ? _b : 0)) * (height !== null && height !== void 0 ? height : 0);
78
80
  return calculatedWidth === 0 ? undefined : calculatedWidth;
79
81
  }
80
- exports.getImgElementWidth = getImgElementWidth;
81
82
  function isDimensionNumber(value) {
82
83
  return typeof value === "number";
83
84
  }
@@ -123,12 +124,11 @@ function getImgSrcSet(src, width, height, options = {}) {
123
124
  }
124
125
  return (0, resizer_1.resizerImageUrl)(src, w, h, { toFormat, ...restOptions });
125
126
  }
126
- exports.getImgSrcSet = getImgSrcSet;
127
127
  /**
128
128
  * @deprecated Use import from @uxf/ui instead.
129
129
  */
130
130
  function ImgSources(props) {
131
- var _a, _b, _c, _d, _e;
131
+ var _a, _b;
132
132
  if (isSrcString(props.src) && (0, is_empty_1.isEmpty)(props.src)) {
133
133
  return null;
134
134
  }
@@ -144,19 +144,18 @@ function ImgSources(props) {
144
144
  return (react_1.default.createElement(react_1.default.Fragment, null,
145
145
  react_1.default.createElement(hide_1.Hide, { when: Boolean((_a = props.options) === null || _a === void 0 ? void 0 : _a.isAvifDisabled) },
146
146
  react_1.default.createElement("source", { media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, {
147
- ...((_b = props.options) !== null && _b !== void 0 ? _b : {}),
147
+ ...props.options,
148
148
  quality: getImgQuality(props.quality, "avif"),
149
149
  toFormat: "avif",
150
150
  }), type: "image/avif" })),
151
- react_1.default.createElement(hide_1.Hide, { when: Boolean((_c = props.options) === null || _c === void 0 ? void 0 : _c.isWebPDisabled) },
151
+ react_1.default.createElement(hide_1.Hide, { when: Boolean((_b = props.options) === null || _b === void 0 ? void 0 : _b.isWebPDisabled) },
152
152
  react_1.default.createElement("source", { media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, {
153
- ...((_d = props.options) !== null && _d !== void 0 ? _d : {}),
153
+ ...props.options,
154
154
  quality: getImgQuality(props.quality, "webp"),
155
155
  toFormat: "webp",
156
156
  }), type: "image/webp" })),
157
157
  react_1.default.createElement("source", { media: media, srcSet: getImgSrcSet(props.src, props.width, props.height, {
158
- ...((_e = props.options) !== null && _e !== void 0 ? _e : {}),
158
+ ...props.options,
159
159
  quality: getImgQuality(props.quality, "original"),
160
160
  }) })));
161
161
  }
162
- exports.ImgSources = ImgSources;
package/utils/is-empty.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmpty = void 0;
3
+ exports.isEmpty = isEmpty;
4
4
  function isEmpty(value) {
5
5
  if (Array.isArray(value)) {
6
6
  return value.length === 0;
7
7
  }
8
8
  return value === "";
9
9
  }
10
- exports.isEmpty = isEmpty;
package/utils/is-nil.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNil = void 0;
3
+ exports.isNil = isNil;
4
4
  function isNil(value) {
5
5
  return value === null || value === undefined;
6
6
  }
7
- exports.isNil = isNil;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNotEmpty = void 0;
3
+ exports.isNotEmpty = isNotEmpty;
4
4
  const is_empty_1 = require("./is-empty");
5
5
  function isNotEmpty(value) {
6
6
  return !(0, is_empty_1.isEmpty)(value);
7
7
  }
8
- exports.isNotEmpty = isNotEmpty;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNotNil = void 0;
3
+ exports.isNotNil = isNotNil;
4
4
  function isNotNil(val) {
5
5
  return val !== null && val !== undefined;
6
6
  }
7
- exports.isNotNil = isNotNil;
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBrowser = void 0;
4
4
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
5
- exports.isBrowser = !!(typeof window !== "undefined" && window.document && window.document.createElement);
5
+ exports.isBrowser = Boolean(typeof window !== "undefined" && window.document && window.document.createElement);
package/utils/last.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.last = void 0;
3
+ exports.last = last;
4
4
  function last(value) {
5
5
  if (value.length === 0) {
6
6
  return undefined;
7
7
  }
8
8
  return value[value.length - 1];
9
9
  }
10
- exports.last = last;
@@ -0,0 +1,2 @@
1
+ import type { Noop } from "../types";
2
+ export declare const noop: Noop;
package/utils/noop.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noop = void 0;
4
+ const noop = () => void null;
5
+ exports.noop = noop;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.paginationGenerate = void 0;
4
+ const empty_array_1 = require("../constants/empty-array");
5
+ const is_not_nil_1 = require("./is-not-nil");
4
6
  const FIRST = ["first"];
5
7
  const LAST = ["last"];
6
8
  const PREVIOUS = ["previous"];
@@ -24,18 +26,19 @@ const paginationGenerate = (config) => {
24
26
  count - boundaryCount - siblingCount * 2 - 1),
25
27
  // Greater than startPages
26
28
  boundaryCount + 2);
29
+ const firstEndPage = endPages.at(0);
27
30
  const siblingsEnd = Math.min(Math.max(
28
31
  // Natural end
29
32
  page + siblingCount,
30
33
  // Upper boundary when page is low
31
34
  boundaryCount + siblingCount * 2 + 2),
32
35
  // Less than endPages
33
- endPages.length > 0 ? endPages[0] - 2 : count - 1);
36
+ (0, is_not_nil_1.isNotNil)(firstEndPage) ? firstEndPage - 2 : count - 1);
34
37
  // Basic list of items to render
35
38
  // e.g. itemList = ['first', 'previous', 1, 'ellipsis', 4, 5, 6, 'ellipsis', 10, 'next', 'last']
36
39
  return [
37
- ...(showFirstButton ? FIRST : []),
38
- ...(hidePrevButton ? [] : PREVIOUS),
40
+ ...(showFirstButton ? FIRST : empty_array_1.EMPTY_ARRAY),
41
+ ...(hidePrevButton ? empty_array_1.EMPTY_ARRAY : PREVIOUS),
39
42
  ...startPages,
40
43
  // Start ellipsis
41
44
  // eslint-disable-next-line no-nested-ternary
@@ -43,7 +46,7 @@ const paginationGenerate = (config) => {
43
46
  ? START_ELLIPSIS
44
47
  : boundaryCount + 1 < count - boundaryCount
45
48
  ? [boundaryCount + 1]
46
- : []),
49
+ : empty_array_1.EMPTY_ARRAY),
47
50
  // Sibling pages
48
51
  ...range(siblingsStart, siblingsEnd),
49
52
  // End ellipsis
@@ -52,10 +55,10 @@ const paginationGenerate = (config) => {
52
55
  ? END_ELLIPSIS
53
56
  : count - boundaryCount > boundaryCount
54
57
  ? [count - boundaryCount]
55
- : []),
58
+ : empty_array_1.EMPTY_ARRAY),
56
59
  ...endPages,
57
- ...(hideNextButton ? [] : NEXT),
58
- ...(showLastButton ? LAST : []),
60
+ ...(hideNextButton ? empty_array_1.EMPTY_ARRAY : NEXT),
61
+ ...(showLastButton ? LAST : empty_array_1.EMPTY_ARRAY),
59
62
  ];
60
63
  };
61
64
  exports.paginationGenerate = paginationGenerate;
package/utils/resizer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resizerGetDefaultConfig = exports.resizerImageUrl = void 0;
3
+ exports.resizerImageUrl = void 0;
4
+ exports.resizerGetDefaultConfig = resizerGetDefaultConfig;
4
5
  const fitMapper = {
5
6
  cover: "cv",
6
7
  fill: "f",
@@ -81,4 +82,3 @@ function resizerGetDefaultConfig(generatedFilesUrl, staticFilesUrl) {
81
82
  },
82
83
  ];
83
84
  }
84
- exports.resizerGetDefaultConfig = resizerGetDefaultConfig;
package/utils/slugify.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.slugify = void 0;
3
+ exports.slugify = slugify;
4
4
  function slugify(content) {
5
5
  const a = "àáäâãåăæąçćčđďèéěėëêęǵḧìíïîįłḿǹńňñòóöôœøṕŕřßśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;";
6
6
  const b = "aaaaaaaaacccddeeeeeeeghiiiiilmnnnnooooooprrssssttuuuuuuuuuwxyyzzz------";
@@ -16,4 +16,3 @@ function slugify(content) {
16
16
  .replace(/^-+/, "") // Trim - from start of text
17
17
  .replace(/-+$/, ""); // Trim - from end of text
18
18
  }
19
- exports.slugify = slugify;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortObjectKeys = void 0;
3
+ exports.sortObjectKeys = sortObjectKeys;
4
4
  function sortObjectKeys(object) {
5
5
  const sortedObject = {};
6
6
  const keys = Object.keys(object);
@@ -15,4 +15,3 @@ function sortObjectKeys(object) {
15
15
  });
16
16
  return sortedObject;
17
17
  }
18
- exports.sortObjectKeys = sortObjectKeys;
@@ -0,0 +1 @@
1
+ export declare function throwError(message?: string): never;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwError = throwError;
4
+ function throwError(message) {
5
+ throw new Error(message);
6
+ }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimTrailingZeros = void 0;
3
+ exports.trimTrailingZeros = trimTrailingZeros;
4
4
  function trimTrailingZeros(value) {
5
5
  return value.replace(/\.?0+$/, "");
6
6
  }
7
- exports.trimTrailingZeros = trimTrailingZeros;