@studiometa/js-toolkit 2.2.2 → 2.4.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 (116) hide show
  1. package/Base/index.cjs +29 -37
  2. package/Base/index.d.ts +0 -8
  3. package/Base/index.js +18 -26
  4. package/Base/managers/EventsManager.cjs +35 -36
  5. package/Base/managers/EventsManager.js +35 -36
  6. package/Base/managers/OptionsManager.cjs +19 -13
  7. package/Base/managers/OptionsManager.js +19 -13
  8. package/Base/managers/RefsManager.cjs +8 -5
  9. package/Base/managers/RefsManager.js +8 -5
  10. package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
  11. package/Base/managers/ResponsiveOptionsManager.js +4 -1
  12. package/Base/managers/ServicesManager.cjs +9 -7
  13. package/Base/managers/ServicesManager.js +9 -7
  14. package/Base/utils.cjs +22 -4
  15. package/Base/utils.d.ts +25 -8
  16. package/Base/utils.js +22 -4
  17. package/README.md +3 -3
  18. package/decorators/withBreakpointManager.cjs +15 -5
  19. package/decorators/withBreakpointManager.js +15 -5
  20. package/decorators/withBreakpointObserver.cjs +8 -2
  21. package/decorators/withBreakpointObserver.js +8 -2
  22. package/decorators/withVue2.cjs +10 -3
  23. package/decorators/withVue2.js +10 -3
  24. package/helpers/getDirectChildren.cjs +46 -0
  25. package/helpers/getDirectChildren.d.ts +24 -0
  26. package/helpers/getDirectChildren.js +24 -0
  27. package/helpers/importOnInteraction.cjs +2 -1
  28. package/helpers/importOnInteraction.js +2 -1
  29. package/helpers/importWhenVisible.cjs +2 -1
  30. package/helpers/importWhenVisible.js +2 -1
  31. package/helpers/index.cjs +2 -0
  32. package/helpers/index.d.ts +1 -0
  33. package/helpers/index.js +1 -0
  34. package/helpers/utils.cjs +3 -2
  35. package/helpers/utils.js +3 -2
  36. package/package.json +4 -1
  37. package/services/drag.cjs +126 -148
  38. package/services/drag.d.ts +10 -10
  39. package/services/drag.js +125 -148
  40. package/services/index.cjs +3 -1
  41. package/services/index.d.ts +1 -0
  42. package/services/index.js +3 -1
  43. package/services/key.cjs +48 -63
  44. package/services/key.d.ts +0 -8
  45. package/services/key.js +47 -63
  46. package/services/load.cjs +24 -40
  47. package/services/load.d.ts +0 -8
  48. package/services/load.js +23 -37
  49. package/services/pointer.cjs +73 -103
  50. package/services/pointer.d.ts +1 -9
  51. package/services/pointer.js +72 -100
  52. package/services/raf.cjs +38 -58
  53. package/services/raf.d.ts +0 -8
  54. package/services/raf.js +37 -55
  55. package/services/resize.cjs +59 -68
  56. package/services/resize.d.ts +0 -7
  57. package/services/resize.js +58 -68
  58. package/services/scroll.cjs +49 -71
  59. package/services/scroll.js +48 -71
  60. package/services/service.cjs +68 -0
  61. package/services/service.d.ts +18 -0
  62. package/services/service.js +46 -0
  63. package/utils/css/animate.cjs +31 -96
  64. package/utils/css/animate.d.ts +4 -16
  65. package/utils/css/animate.js +28 -93
  66. package/utils/css/classes.cjs +2 -1
  67. package/utils/css/classes.js +2 -1
  68. package/utils/css/styles.cjs +2 -5
  69. package/utils/css/styles.js +1 -1
  70. package/utils/css/transform.cjs +13 -16
  71. package/utils/css/transform.js +1 -1
  72. package/utils/css/transition.cjs +5 -3
  73. package/utils/css/transition.js +5 -3
  74. package/utils/focusTrap.cjs +2 -1
  75. package/utils/focusTrap.js +2 -1
  76. package/utils/{isFunction.cjs → has.cjs} +7 -7
  77. package/utils/has.d.ts +6 -0
  78. package/utils/has.js +6 -0
  79. package/utils/history.cjs +5 -7
  80. package/utils/history.js +4 -3
  81. package/utils/index.cjs +6 -5
  82. package/utils/index.d.ts +4 -2
  83. package/utils/index.js +6 -5
  84. package/utils/{object/isObject.cjs → is.cjs} +20 -8
  85. package/utils/is.d.ts +8 -0
  86. package/utils/is.js +18 -0
  87. package/utils/math/inertiaFinalValue.cjs +5 -3
  88. package/utils/math/inertiaFinalValue.js +2 -3
  89. package/utils/nextFrame.cjs +5 -3
  90. package/utils/nextFrame.js +5 -3
  91. package/utils/nextMicrotask.cjs +2 -1
  92. package/utils/nextMicrotask.js +2 -1
  93. package/utils/nextTick.cjs +2 -1
  94. package/utils/nextTick.js +2 -1
  95. package/utils/{isDefined.cjs → noop.cjs} +10 -7
  96. package/utils/noop.d.ts +12 -0
  97. package/utils/noop.js +9 -0
  98. package/utils/object/autoBind.cjs +3 -2
  99. package/utils/object/autoBind.js +3 -2
  100. package/utils/object/getAllProperties.cjs +2 -1
  101. package/utils/object/getAllProperties.js +2 -1
  102. package/utils/object/index.cjs +1 -3
  103. package/utils/object/index.d.ts +0 -1
  104. package/utils/object/index.js +1 -3
  105. package/utils/tween.cjs +114 -0
  106. package/utils/tween.d.ts +25 -0
  107. package/utils/tween.js +89 -0
  108. package/services/Service.cjs +0 -76
  109. package/services/Service.d.ts +0 -76
  110. package/services/Service.js +0 -55
  111. package/utils/isDefined.d.ts +0 -7
  112. package/utils/isDefined.js +0 -6
  113. package/utils/isFunction.d.ts +0 -7
  114. package/utils/isFunction.js +0 -6
  115. package/utils/object/isObject.d.ts +0 -7
  116. package/utils/object/isObject.js +0 -6
@@ -1,14 +1,10 @@
1
- import { cubicBezier } from "@motionone/easing";
2
- import { lerp, map, clamp01 } from "../math/index.js";
3
- import isDefined from "../isDefined.js";
1
+ import { lerp, map } from "../math/index.js";
2
+ import { isDefined, isFunction, isNumber } from "../is.js";
4
3
  import transform, { TRANSFORM_PROPS } from "./transform.js";
5
- import useRaf from "../../services/raf.js";
6
4
  import { domScheduler as scheduler } from "../scheduler.js";
5
+ import { tween, normalizeEase } from "../tween.js";
7
6
  let id = 0;
8
7
  const running = /* @__PURE__ */ new WeakMap();
9
- const noop = () => {
10
- };
11
- const PROGRESS_PRECISION = 1e-4;
12
8
  const CSSUnitConverter = {
13
9
  "%": (value, getSizeRef) => value * getSizeRef() / 100,
14
10
  vh: (value) => value * window.innerHeight / 100,
@@ -17,7 +13,7 @@ const CSSUnitConverter = {
17
13
  vmax: (value) => value * Math.max(window.innerWidth, window.innerHeight) / 100
18
14
  };
19
15
  function getAnimationStepValue(val, getSizeRef) {
20
- if (typeof val === "number") {
16
+ if (isNumber(val)) {
21
17
  return val;
22
18
  }
23
19
  if (!val[1] || !CSSUnitConverter[val[1]]) {
@@ -25,18 +21,6 @@ function getAnimationStepValue(val, getSizeRef) {
25
21
  }
26
22
  return CSSUnitConverter[val[1]](val[0], getSizeRef);
27
23
  }
28
- function linear(value) {
29
- return value;
30
- }
31
- function normalizeEase(ease) {
32
- if (!isDefined(ease)) {
33
- return linear;
34
- }
35
- if (Array.isArray(ease)) {
36
- return cubicBezier(...ease);
37
- }
38
- return ease;
39
- }
40
24
  const generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) => lerp(getAnimationStepValue(fromValue != null ? fromValue : 0, () => element[sizeRef]), getAnimationStepValue(toValue != null ? toValue : 0, () => element[sizeRef]), progress);
41
25
  const widthBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetWidth");
42
26
  const heightBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetHeight");
@@ -90,92 +74,43 @@ function render(element, from, to, progress) {
90
74
  });
91
75
  }
92
76
  function animate(element, keyframes, options = {}) {
93
- var _a;
94
- const raf = useRaf();
95
- let progressValue = 0;
96
- let easedProgress = 0;
97
- if (!running.has(element)) {
98
- running.set(element, /* @__PURE__ */ new Map());
99
- }
100
- const ease = normalizeEase(options.easing);
101
- let duration = (_a = options.duration) != null ? _a : 1;
102
- duration *= 1e3;
103
- let startTime = performance.now();
104
- let endTime = startTime + duration;
105
- const key = `animate-${id}`;
106
- id += 1;
107
- const { onProgress = noop, onFinish = noop } = options;
108
- let isRunning = false;
109
77
  const keyframesCount = keyframes.length - 1;
110
78
  const normalizedKeyframes = keyframes.map((keyframe, index) => {
111
- var _a2;
79
+ var _a;
112
80
  return {
113
81
  ...keyframe,
114
- offset: (_a2 = keyframe.offset) != null ? _a2 : index / keyframesCount,
82
+ offset: (_a = keyframe.offset) != null ? _a : index / keyframesCount,
115
83
  easing: normalizeEase(keyframe.easing)
116
84
  };
117
85
  });
118
- function pause() {
119
- isRunning = false;
120
- raf.remove(key);
86
+ if (!running.has(element)) {
87
+ running.set(element, /* @__PURE__ */ new Map());
121
88
  }
122
- function progress(newProgress) {
123
- if (typeof newProgress === "undefined") {
124
- return progressValue;
125
- }
126
- progressValue = newProgress;
127
- if (Math.abs(1 - progressValue) < PROGRESS_PRECISION) {
128
- progressValue = 1;
129
- pause();
130
- scheduler.afterWrite(() => onFinish(progressValue, easedProgress));
131
- }
132
- easedProgress = ease(progressValue);
89
+ const key = `animate-${id}`;
90
+ id += 1;
91
+ function callback(progress) {
133
92
  let toIndex = 0;
134
- while (normalizedKeyframes[toIndex] && normalizedKeyframes[toIndex].offset <= easedProgress && normalizedKeyframes[toIndex].offset !== 1) {
93
+ while (normalizedKeyframes[toIndex] && normalizedKeyframes[toIndex].offset <= progress && normalizedKeyframes[toIndex].offset !== 1) {
135
94
  toIndex += 1;
136
95
  }
137
- render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex], easedProgress);
138
- onProgress(progressValue, easedProgress);
139
- return progressValue;
140
- }
141
- function tick(props) {
142
- if (!isRunning) {
143
- raf.remove(key);
144
- return;
145
- }
146
- progress(clamp01(map(props.time, startTime, endTime, 0, 1)));
96
+ render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex], progress);
147
97
  }
148
- function start() {
149
- const runningKeys = running.get(element);
150
- runningKeys.forEach((runningPause, runningKey) => {
151
- runningPause();
152
- runningKeys.delete(runningKey);
153
- });
154
- runningKeys.set(key, pause);
155
- running.set(element, runningKeys);
156
- startTime = performance.now();
157
- endTime = startTime + duration;
158
- progressValue = 0;
159
- easedProgress = 0;
160
- isRunning = true;
161
- raf.add(key, tick);
162
- }
163
- function play() {
164
- if (isRunning) {
165
- return;
98
+ const controls = tween(callback, {
99
+ ...options,
100
+ onStart() {
101
+ if (isFunction(options.onStart)) {
102
+ options.onStart();
103
+ }
104
+ const runningKeys = running.get(element);
105
+ runningKeys.forEach((runningPause, runningKey) => {
106
+ runningPause();
107
+ runningKeys.delete(runningKey);
108
+ });
109
+ runningKeys.set(key, controls.pause);
110
+ running.set(element, runningKeys);
166
111
  }
167
- startTime = performance.now() - lerp(0, duration, progressValue);
168
- endTime = startTime + duration;
169
- isRunning = true;
170
- raf.add(key, tick);
171
- }
172
- return {
173
- start,
174
- finish: () => progress(1),
175
- pause,
176
- play,
177
- progress
178
- };
112
+ });
113
+ return controls;
179
114
  }
180
115
  export {
181
116
  animate
@@ -24,11 +24,12 @@ __export(classes_exports, {
24
24
  toggle: () => toggle
25
25
  });
26
26
  module.exports = __toCommonJS(classes_exports);
27
+ var import_is = require("../is.cjs");
27
28
  function setClasses(element, classNames, method, forceToggle) {
28
29
  if (!element || !classNames) {
29
30
  return;
30
31
  }
31
- const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
32
+ const normalizedClassNames = (0, import_is.isArray)(classNames) ? classNames : classNames.split(" ");
32
33
  if (method !== "toggle") {
33
34
  element.classList[method](...normalizedClassNames);
34
35
  } else {
@@ -1,8 +1,9 @@
1
+ import { isArray } from "../is.js";
1
2
  function setClasses(element, classNames, method, forceToggle) {
2
3
  if (!element || !classNames) {
3
4
  return;
4
5
  }
5
- const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
6
+ const normalizedClassNames = isArray(classNames) ? classNames : classNames.split(" ");
6
7
  if (method !== "toggle") {
7
8
  element.classList[method](...normalizedClassNames);
8
9
  } else {
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
18
 
22
19
  // packages/js-toolkit/utils/css/styles.js
@@ -26,9 +23,9 @@ __export(styles_exports, {
26
23
  remove: () => remove
27
24
  });
28
25
  module.exports = __toCommonJS(styles_exports);
29
- var import_isObject = __toESM(require("../object/isObject.cjs"), 1);
26
+ var import_is = require("../is.cjs");
30
27
  function setStyles(element, styles, method = "add") {
31
- if (!element || !styles || !(0, import_isObject.default)(styles)) {
28
+ if (!element || !styles || !(0, import_is.isObject)(styles)) {
32
29
  return;
33
30
  }
34
31
  Object.entries(styles).forEach(([prop, value]) => {
@@ -1,4 +1,4 @@
1
- import isObject from "../object/isObject.js";
1
+ import { isObject } from "../is.js";
2
2
  function setStyles(element, styles, method = "add") {
3
3
  if (!element || !styles || !isObject(styles)) {
4
4
  return;
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
18
 
22
19
  // packages/js-toolkit/utils/css/transform.js
@@ -26,7 +23,7 @@ __export(transform_exports, {
26
23
  default: () => transform
27
24
  });
28
25
  module.exports = __toCommonJS(transform_exports);
29
- var import_isDefined = __toESM(require("../isDefined.cjs"), 1);
26
+ var import_is = require("../is.cjs");
30
27
  var TRANSFORM_PROPS = [
31
28
  "x",
32
29
  "y",
@@ -46,42 +43,42 @@ var TRANSFORM_PROPS = [
46
43
  function transform(element, props) {
47
44
  var _a, _b, _c;
48
45
  let value = "";
49
- if ((0, import_isDefined.default)(props.x) || (0, import_isDefined.default)(props.y) || (0, import_isDefined.default)(props.z)) {
46
+ if ((0, import_is.isDefined)(props.x) || (0, import_is.isDefined)(props.y) || (0, import_is.isDefined)(props.z)) {
50
47
  value += `translate3d(${(_a = props.x) != null ? _a : 0}px, ${(_b = props.y) != null ? _b : 0}px, ${(_c = props.z) != null ? _c : 0}px) `;
51
48
  }
52
- if ((0, import_isDefined.default)(props.rotate)) {
49
+ if ((0, import_is.isDefined)(props.rotate)) {
53
50
  value += `rotate(${props.rotate}deg) `;
54
51
  } else {
55
- if ((0, import_isDefined.default)(props.rotateX)) {
52
+ if ((0, import_is.isDefined)(props.rotateX)) {
56
53
  value += `rotateX(${props.rotateX}deg) `;
57
54
  }
58
- if ((0, import_isDefined.default)(props.rotateY)) {
55
+ if ((0, import_is.isDefined)(props.rotateY)) {
59
56
  value += `rotateY(${props.rotateY}deg) `;
60
57
  }
61
- if ((0, import_isDefined.default)(props.rotateZ)) {
58
+ if ((0, import_is.isDefined)(props.rotateZ)) {
62
59
  value += `rotateZ(${props.rotateZ}deg) `;
63
60
  }
64
61
  }
65
- if ((0, import_isDefined.default)(props.scale)) {
62
+ if ((0, import_is.isDefined)(props.scale)) {
66
63
  value += `scale(${props.scale}) `;
67
64
  } else {
68
- if ((0, import_isDefined.default)(props.scaleX)) {
65
+ if ((0, import_is.isDefined)(props.scaleX)) {
69
66
  value += `scaleX(${props.scaleX}) `;
70
67
  }
71
- if ((0, import_isDefined.default)(props.scaleY)) {
68
+ if ((0, import_is.isDefined)(props.scaleY)) {
72
69
  value += `scaleY(${props.scaleY}) `;
73
70
  }
74
- if ((0, import_isDefined.default)(props.scaleZ)) {
71
+ if ((0, import_is.isDefined)(props.scaleZ)) {
75
72
  value += `scaleZ(${props.scaleZ}) `;
76
73
  }
77
74
  }
78
- if ((0, import_isDefined.default)(props.skew)) {
75
+ if ((0, import_is.isDefined)(props.skew)) {
79
76
  value += `skew(${props.skew}deg) `;
80
77
  } else {
81
- if ((0, import_isDefined.default)(props.skewX)) {
78
+ if ((0, import_is.isDefined)(props.skewX)) {
82
79
  value += `skewX(${props.skewX}deg) `;
83
80
  }
84
- if ((0, import_isDefined.default)(props.skewY)) {
81
+ if ((0, import_is.isDefined)(props.skewY)) {
85
82
  value += `skewY(${props.skewY}deg) `;
86
83
  }
87
84
  }
@@ -1,4 +1,4 @@
1
- import isDefined from "../isDefined.js";
1
+ import { isDefined } from "../is.js";
2
2
  const TRANSFORM_PROPS = [
3
3
  "x",
4
4
  "y",
@@ -34,6 +34,8 @@ module.exports = __toCommonJS(transition_exports);
34
34
  var import_nextFrame = require("../nextFrame.cjs");
35
35
  var classes = __toESM(require("./classes.cjs"), 1);
36
36
  var styles = __toESM(require("./styles.cjs"), 1);
37
+ var import_is = require("../is.cjs");
38
+ var import_has = require("../has.cjs");
37
39
  var cache = /* @__PURE__ */ new WeakMap();
38
40
  var Transition = class {
39
41
  constructor(element) {
@@ -50,14 +52,14 @@ var Transition = class {
50
52
  }
51
53
  };
52
54
  function setClassesOrStyles(element, classesOrStyles, method = "add") {
53
- if (typeof classesOrStyles === "string" || Array.isArray(classesOrStyles)) {
55
+ if ((0, import_is.isString)(classesOrStyles) || (0, import_is.isArray)(classesOrStyles)) {
54
56
  classes[method](element, classesOrStyles);
55
57
  } else {
56
58
  styles[method](element, classesOrStyles);
57
59
  }
58
60
  }
59
61
  function testTransition(element) {
60
- if (typeof window === "undefined") {
62
+ if (!(0, import_has.hasWindow)()) {
61
63
  return false;
62
64
  }
63
65
  const { transitionDuration } = window.getComputedStyle(element);
@@ -100,7 +102,7 @@ function end(element, classesOrStyles, mode = "remove") {
100
102
  trs.transitionEndHandler = null;
101
103
  }
102
104
  async function transition(element, name, endMode = "remove") {
103
- const classesOrStyles = typeof name === "string" ? {
105
+ const classesOrStyles = (0, import_is.isString)(name) ? {
104
106
  from: `${name}-from`,
105
107
  active: `${name}-active`,
106
108
  to: `${name}-to`
@@ -7,6 +7,8 @@ var __publicField = (obj, key, value) => {
7
7
  import { nextFrame } from "../nextFrame.js";
8
8
  import * as classes from "./classes.js";
9
9
  import * as styles from "./styles.js";
10
+ import { isArray, isString } from "../is.js";
11
+ import { hasWindow } from "../has.js";
10
12
  const cache = /* @__PURE__ */ new WeakMap();
11
13
  class Transition {
12
14
  constructor(element) {
@@ -23,14 +25,14 @@ class Transition {
23
25
  }
24
26
  }
25
27
  function setClassesOrStyles(element, classesOrStyles, method = "add") {
26
- if (typeof classesOrStyles === "string" || Array.isArray(classesOrStyles)) {
28
+ if (isString(classesOrStyles) || isArray(classesOrStyles)) {
27
29
  classes[method](element, classesOrStyles);
28
30
  } else {
29
31
  styles[method](element, classesOrStyles);
30
32
  }
31
33
  }
32
34
  function testTransition(element) {
33
- if (typeof window === "undefined") {
35
+ if (!hasWindow()) {
34
36
  return false;
35
37
  }
36
38
  const { transitionDuration } = window.getComputedStyle(element);
@@ -73,7 +75,7 @@ function end(element, classesOrStyles, mode = "remove") {
73
75
  trs.transitionEndHandler = null;
74
76
  }
75
77
  async function transition(element, name, endMode = "remove") {
76
- const classesOrStyles = typeof name === "string" ? {
78
+ const classesOrStyles = isString(name) ? {
77
79
  from: `${name}-from`,
78
80
  active: `${name}-active`,
79
81
  to: `${name}-to`
@@ -29,6 +29,7 @@ __export(focusTrap_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(focusTrap_exports);
31
31
  var import_keyCodes = __toESM(require("./keyCodes.cjs"), 1);
32
+ var import_is = require("./is.cjs");
32
33
  var FOCUSABLE_ELEMENTS = [
33
34
  'a[href]:not([tabindex^="-"]):not([inert])',
34
35
  'area[href]:not([tabindex^="-"]):not([inert])',
@@ -71,7 +72,7 @@ function trap(element, event) {
71
72
  }
72
73
  }
73
74
  function untrap() {
74
- if (focusedBefore && typeof focusedBefore.focus === "function") {
75
+ if (focusedBefore && (0, import_is.isFunction)(focusedBefore.focus)) {
75
76
  focusedBefore.focus();
76
77
  focusedBefore = null;
77
78
  }
@@ -1,4 +1,5 @@
1
1
  import keyCodes from "./keyCodes.js";
2
+ import { isFunction } from "./is.js";
2
3
  const FOCUSABLE_ELEMENTS = [
3
4
  'a[href]:not([tabindex^="-"]):not([inert])',
4
5
  'area[href]:not([tabindex^="-"]):not([inert])',
@@ -41,7 +42,7 @@ function trap(element, event) {
41
42
  }
42
43
  }
43
44
  function untrap() {
44
- if (focusedBefore && typeof focusedBefore.focus === "function") {
45
+ if (focusedBefore && isFunction(focusedBefore.focus)) {
45
46
  focusedBefore.focus();
46
47
  focusedBefore = null;
47
48
  }
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // packages/js-toolkit/utils/isFunction.js
20
- var isFunction_exports = {};
21
- __export(isFunction_exports, {
22
- default: () => isFunction
19
+ // packages/js-toolkit/utils/has.js
20
+ var has_exports = {};
21
+ __export(has_exports, {
22
+ hasWindow: () => hasWindow
23
23
  });
24
- module.exports = __toCommonJS(isFunction_exports);
25
- function isFunction(fn) {
26
- return typeof fn === "function";
24
+ module.exports = __toCommonJS(has_exports);
25
+ function hasWindow() {
26
+ return typeof window !== "undefined";
27
27
  }
28
28
  if (module.exports.default) module.exports = module.exports.default;
package/utils/has.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Test if the current context as a global `window` object available.
3
+ *
4
+ * @returns {boolean}
5
+ */
6
+ export function hasWindow(): boolean;
package/utils/has.js ADDED
@@ -0,0 +1,6 @@
1
+ function hasWindow() {
2
+ return typeof window !== "undefined";
3
+ }
4
+ export {
5
+ hasWindow
6
+ };
package/utils/history.cjs CHANGED
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
18
 
22
19
  // packages/js-toolkit/utils/history.js
@@ -27,7 +24,8 @@ __export(history_exports, {
27
24
  replace: () => replace
28
25
  });
29
26
  module.exports = __toCommonJS(history_exports);
30
- var import_isObject = __toESM(require("./object/isObject.cjs"), 1);
27
+ var import_is = require("./is.cjs");
28
+ var import_has = require("./has.cjs");
31
29
  function updateUrlSearchParam(params, name, value) {
32
30
  if (value === "" || value === null || value === void 0) {
33
31
  if (params.has(name)) {
@@ -35,14 +33,14 @@ function updateUrlSearchParam(params, name, value) {
35
33
  }
36
34
  return params;
37
35
  }
38
- if (Array.isArray(value)) {
36
+ if ((0, import_is.isArray)(value)) {
39
37
  value.forEach((val, index) => {
40
38
  const arrayName = `${name}[${index}]`;
41
39
  updateUrlSearchParam(params, arrayName, val);
42
40
  });
43
41
  return params;
44
42
  }
45
- if ((0, import_isObject.default)(value)) {
43
+ if ((0, import_is.isObject)(value)) {
46
44
  Object.entries(value).forEach(([key, val]) => {
47
45
  const objectName = `${name}[${key}]`;
48
46
  updateUrlSearchParam(params, objectName, val);
@@ -52,7 +50,7 @@ function updateUrlSearchParam(params, name, value) {
52
50
  params.set(name, value);
53
51
  return params;
54
52
  }
55
- function objectToURLSearchParams(obj, defaultSearch = typeof window === "undefined" ? "" : window.location.search) {
53
+ function objectToURLSearchParams(obj, defaultSearch = (0, import_has.hasWindow)() ? window.location.search : "") {
56
54
  return Object.entries(obj).reduce((urlSearchParams, [name, value]) => updateUrlSearchParam(urlSearchParams, name, value), new URLSearchParams(defaultSearch));
57
55
  }
58
56
  function updateHistory(mode, options, data = {}, title = "") {
package/utils/history.js CHANGED
@@ -1,4 +1,5 @@
1
- import isObject from "./object/isObject.js";
1
+ import { isArray, isObject } from "./is.js";
2
+ import { hasWindow } from "./has.js";
2
3
  function updateUrlSearchParam(params, name, value) {
3
4
  if (value === "" || value === null || value === void 0) {
4
5
  if (params.has(name)) {
@@ -6,7 +7,7 @@ function updateUrlSearchParam(params, name, value) {
6
7
  }
7
8
  return params;
8
9
  }
9
- if (Array.isArray(value)) {
10
+ if (isArray(value)) {
10
11
  value.forEach((val, index) => {
11
12
  const arrayName = `${name}[${index}]`;
12
13
  updateUrlSearchParam(params, arrayName, val);
@@ -23,7 +24,7 @@ function updateUrlSearchParam(params, name, value) {
23
24
  params.set(name, value);
24
25
  return params;
25
26
  }
26
- function objectToURLSearchParams(obj, defaultSearch = typeof window === "undefined" ? "" : window.location.search) {
27
+ function objectToURLSearchParams(obj, defaultSearch = hasWindow() ? window.location.search : "") {
27
28
  return Object.entries(obj).reduce((urlSearchParams, [name, value]) => updateUrlSearchParam(urlSearchParams, name, value), new URLSearchParams(defaultSearch));
28
29
  }
29
30
  function updateHistory(mode, options, data = {}, title = "") {
package/utils/index.cjs CHANGED
@@ -27,8 +27,6 @@ __export(utils_exports, {
27
27
  focusTrap: () => import_focusTrap.default,
28
28
  historyPush: () => import_history.push,
29
29
  historyReplace: () => import_history.replace,
30
- isDefined: () => import_isDefined.default,
31
- isFunction: () => import_isFunction.default,
32
30
  keyCodes: () => import_keyCodes.default,
33
31
  memoize: () => import_memoize.default,
34
32
  nextFrame: () => import_nextFrame.nextFrame,
@@ -36,7 +34,8 @@ __export(utils_exports, {
36
34
  nextTick: () => import_nextTick.default,
37
35
  objectToURLSearchParams: () => import_history.objectToURLSearchParams,
38
36
  scrollTo: () => import_scrollTo.default,
39
- throttle: () => import_throttle.default
37
+ throttle: () => import_throttle.default,
38
+ tween: () => import_tween.tween
40
39
  });
41
40
  module.exports = __toCommonJS(utils_exports);
42
41
  var import_debounce = __toESM(require("./debounce.cjs"), 1);
@@ -48,12 +47,14 @@ var import_nextTick = __toESM(require("./nextTick.cjs"), 1);
48
47
  var import_nextMicrotask = __toESM(require("./nextMicrotask.cjs"), 1);
49
48
  var import_throttle = __toESM(require("./throttle.cjs"), 1);
50
49
  var import_scrollTo = __toESM(require("./scrollTo.cjs"), 1);
51
- var import_isDefined = __toESM(require("./isDefined.cjs"), 1);
52
- var import_isFunction = __toESM(require("./isFunction.cjs"), 1);
50
+ __reExport(utils_exports, require("./is.cjs"), module.exports);
51
+ __reExport(utils_exports, require("./has.cjs"), module.exports);
53
52
  __reExport(utils_exports, require("./css/index.cjs"), module.exports);
54
53
  var import_history = require("./history.cjs");
55
54
  __reExport(utils_exports, require("./collide/index.cjs"), module.exports);
56
55
  __reExport(utils_exports, require("./math/index.cjs"), module.exports);
57
56
  __reExport(utils_exports, require("./string/index.cjs"), module.exports);
58
57
  __reExport(utils_exports, require("./scheduler.cjs"), module.exports);
58
+ __reExport(utils_exports, require("./noop.cjs"), module.exports);
59
+ var import_tween = require("./tween.cjs");
59
60
  if (module.exports.default) module.exports = module.exports.default;
package/utils/index.d.ts CHANGED
@@ -7,11 +7,13 @@ export { default as nextTick } from "./nextTick.js";
7
7
  export { default as nextMicrotask } from "./nextMicrotask.js";
8
8
  export { default as throttle } from "./throttle.js";
9
9
  export { default as scrollTo } from "./scrollTo.js";
10
- export { default as isDefined } from "./isDefined.js";
11
- export { default as isFunction } from "./isFunction.js";
10
+ export * from "./is.js";
11
+ export * from "./has.js";
12
12
  export * from "./css/index.js";
13
13
  export * from "./collide/index.js";
14
14
  export * from "./math/index.js";
15
15
  export * from "./string/index.js";
16
16
  export * from "./scheduler.js";
17
+ export * from "./noop.js";
18
+ export { tween } from "./tween.js";
17
19
  export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from "./history.js";
package/utils/index.js CHANGED
@@ -7,8 +7,8 @@ import { default as default6 } from "./nextTick.js";
7
7
  import { default as default7 } from "./nextMicrotask.js";
8
8
  import { default as default8 } from "./throttle.js";
9
9
  import { default as default9 } from "./scrollTo.js";
10
- import { default as default10 } from "./isDefined.js";
11
- import { default as default11 } from "./isFunction.js";
10
+ export * from "./is.js";
11
+ export * from "./has.js";
12
12
  export * from "./css/index.js";
13
13
  import {
14
14
  objectToURLSearchParams,
@@ -19,13 +19,13 @@ export * from "./collide/index.js";
19
19
  export * from "./math/index.js";
20
20
  export * from "./string/index.js";
21
21
  export * from "./scheduler.js";
22
+ export * from "./noop.js";
23
+ import { tween } from "./tween.js";
22
24
  export {
23
25
  default2 as debounce,
24
26
  default3 as focusTrap,
25
27
  push as historyPush,
26
28
  replace as historyReplace,
27
- default10 as isDefined,
28
- default11 as isFunction,
29
29
  default4 as keyCodes,
30
30
  default5 as memoize,
31
31
  nextFrame,
@@ -33,5 +33,6 @@ export {
33
33
  default6 as nextTick,
34
34
  objectToURLSearchParams,
35
35
  default9 as scrollTo,
36
- default8 as throttle
36
+ default8 as throttle,
37
+ tween
37
38
  };
@@ -16,13 +16,25 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // packages/js-toolkit/utils/object/isObject.js
20
- var isObject_exports = {};
21
- __export(isObject_exports, {
22
- default: () => isObject
19
+ // packages/js-toolkit/utils/is.js
20
+ var is_exports = {};
21
+ __export(is_exports, {
22
+ isArray: () => isArray,
23
+ isBoolean: () => isBoolean,
24
+ isDefined: () => isDefined,
25
+ isDev: () => isDev,
26
+ isFunction: () => isFunction,
27
+ isNumber: () => isNumber,
28
+ isObject: () => isObject,
29
+ isString: () => isString
23
30
  });
24
- module.exports = __toCommonJS(isObject_exports);
25
- function isObject(value) {
26
- return typeof value === "object" && !!value && value.toString() === "[object Object]";
27
- }
31
+ module.exports = __toCommonJS(is_exports);
32
+ var isDev = typeof __DEV__ !== "undefined" && __DEV__;
33
+ var isFunction = (value) => typeof value === "function";
34
+ var isDefined = (value) => typeof value !== "undefined";
35
+ var isString = (value) => typeof value === "string";
36
+ var isObject = (value) => typeof value === "object" && !!value && value.toString() === "[object Object]";
37
+ var isNumber = (value) => typeof value === "number";
38
+ var isBoolean = (value) => typeof value === "boolean";
39
+ var isArray = Array.isArray;
28
40
  if (module.exports.default) module.exports = module.exports.default;