@carbon/utilities 0.18.0-rc.0 → 0.19.0-rc.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.
@@ -1,2 +1,2 @@
1
- import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "../chunk-DPUOAfLB.js";
1
+ import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "../chunk-BxtJV719.js";
2
2
  export { CarouselResponse, CarouselStackHistory, Config, InitCarousel, TranslationKey, initCarousel };
@@ -1,3 +1,2 @@
1
- import { t as initCarousel } from "../chunk-Ci2WlFE4.js";
2
-
3
- export { initCarousel };
1
+ import { t as initCarousel } from "../chunk-DMEZ3h3f.js";
2
+ export { initCarousel };
@@ -45,4 +45,10 @@ declare function formatRange(startDate: Date | number, endDate: Date | number, o
45
45
  timeZone: Intl.DateTimeFormatOptions['timeZone'];
46
46
  }>): string;
47
47
  //#endregion
48
- export { relative_d_exports as n, absolute_d_exports as t };
48
+ //#region src/dateTimeFormat/index.d.ts
49
+ declare const dateTimeFormat: {
50
+ relative: typeof relative_d_exports;
51
+ absolute: typeof absolute_d_exports;
52
+ };
53
+ //#endregion
54
+ export { dateTimeFormat as t };
@@ -1,5 +1,4 @@
1
- import { t as __exportAll } from "./chunk-BYypO7fO.js";
2
-
1
+ import { t as __exportAll } from "./chunk-pbuEa-1d.js";
3
2
  //#region src/dateTimeFormat/relative.ts
4
3
  var relative_exports = /* @__PURE__ */ __exportAll({ format: () => format$1 });
5
4
  /**
@@ -11,8 +10,7 @@ var relative_exports = /* @__PURE__ */ __exportAll({ format: () => format$1 });
11
10
  function format$1(date, options) {
12
11
  const rtf = new Intl.RelativeTimeFormat(options?.locale, { style: options?.style ?? "long" });
13
12
  const d = typeof date === "number" ? new Date(date) : date;
14
- const now = Date.now();
15
- const seconds = Math.floor((now - d.getTime()) / 1e3);
13
+ const seconds = Math.floor((Date.now() - d.getTime()) / 1e3);
16
14
  const minutes = Math.floor(seconds / 60);
17
15
  const hours = Math.floor(minutes / 60);
18
16
  const days = Math.floor(hours / 24);
@@ -30,7 +28,6 @@ function format$1(date, options) {
30
28
  if (Math.abs(days) < 365) return rtf.format(months * -1, "months");
31
29
  return rtf.format(years * -1, "years");
32
30
  }
33
-
34
31
  //#endregion
35
32
  //#region src/dateTimeFormat/absolute.ts
36
33
  var absolute_exports = /* @__PURE__ */ __exportAll({
@@ -75,6 +72,17 @@ function formatRange(startDate, endDate, options) {
75
72
  timeZone: options?.timeZone
76
73
  }).formatRange(startDate, endDate);
77
74
  }
78
-
79
75
  //#endregion
80
- export { relative_exports as n, absolute_exports as t };
76
+ //#region src/dateTimeFormat/index.ts
77
+ /**
78
+ * Copyright IBM Corp. 2024
79
+ *
80
+ * This source code is licensed under the Apache-2.0 license found in the
81
+ * LICENSE file in the root directory of this source tree.
82
+ */
83
+ const dateTimeFormat = {
84
+ relative: relative_exports,
85
+ absolute: absolute_exports
86
+ };
87
+ //#endregion
88
+ export { dateTimeFormat as t };
@@ -9,7 +9,6 @@ const translationIds = {
9
9
  "carbon.carousel.item": "carbon.carousel.item",
10
10
  "carbon.carousel.of": "carbon.carousel.of"
11
11
  };
12
-
13
12
  //#endregion
14
13
  //#region src/carousel/swipeEvents.ts
15
14
  /**
@@ -89,7 +88,6 @@ const registerSwipeEvents = (carousel, next, prev, destroy) => {
89
88
  carousel.addEventListener("mouseup", mouseUpHandler);
90
89
  carousel.addEventListener("wheel", wheelHandler);
91
90
  };
92
-
93
91
  //#endregion
94
92
  //#region src/carousel/carousel.ts
95
93
  const defaultTranslations = {
@@ -432,6 +430,5 @@ const initCarousel = (carouselContainer, config) => {
432
430
  allViews: refs
433
431
  };
434
432
  };
435
-
436
433
  //#endregion
437
- export { initCarousel as t };
434
+ export { initCarousel as t };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
@@ -16,6 +16,5 @@ const datePartsOrder = {
16
16
  getMonthYearOrder,
17
17
  isMonthFirst
18
18
  };
19
-
20
19
  //#endregion
21
- export { datePartsOrder };
20
+ export { datePartsOrder };
@@ -1,9 +1,2 @@
1
- import { n as relative_d_exports, t as absolute_d_exports } from "../chunk-Bzxox1sl.js";
2
-
3
- //#region src/dateTimeFormat/index.d.ts
4
- declare const dateTimeFormat: {
5
- relative: typeof relative_d_exports;
6
- absolute: typeof absolute_d_exports;
7
- };
8
- //#endregion
1
+ import { t as dateTimeFormat } from "../chunk-BIOsKtwb.js";
9
2
  export { dateTimeFormat };
@@ -1,16 +1,2 @@
1
- import { n as relative_exports, t as absolute_exports } from "../chunk-CYAX4TFi.js";
2
-
3
- //#region src/dateTimeFormat/index.ts
4
- /**
5
- * Copyright IBM Corp. 2024
6
- *
7
- * This source code is licensed under the Apache-2.0 license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- const dateTimeFormat = {
11
- relative: relative_exports,
12
- absolute: absolute_exports
13
- };
14
-
15
- //#endregion
16
- export { dateTimeFormat };
1
+ import { t as dateTimeFormat } from "../chunk-D7jICOmO.js";
2
+ export { dateTimeFormat };
@@ -64,6 +64,5 @@ function subscribeDocumentLangChange(callback) {
64
64
  if (subscribers.length === 0) observerInitialized = false;
65
65
  };
66
66
  }
67
-
68
67
  //#endregion
69
- export { getDocumentLang, subscribeDocumentLangChange };
68
+ export { getDocumentLang, subscribeDocumentLangChange };
package/es/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "./chunk-DPUOAfLB.js";
1
+ import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "./chunk-BxtJV719.js";
2
2
  import { datePartsOrder } from "./datePartsOrder/index.js";
3
- import { dateTimeFormat } from "./dateTimeFormat/index.js";
3
+ import { t as dateTimeFormat } from "./chunk-BIOsKtwb.js";
4
4
  import { getDocumentLang, subscribeDocumentLangChange } from "./documentLang/index.js";
5
5
  import { makeDraggable } from "./makeDraggable/index.js";
6
6
  import { OverflowHandler, OverflowHandlerOptions, UpdateOverflowHandlerOptions, createOverflowHandler, getSize, updateOverflowHandler } from "./overflowHandler/index.js";
package/es/index.js CHANGED
@@ -1,10 +1,8 @@
1
- import { t as initCarousel } from "./chunk-Ci2WlFE4.js";
1
+ import { t as initCarousel } from "./chunk-DMEZ3h3f.js";
2
2
  import { datePartsOrder } from "./datePartsOrder/index.js";
3
- import { dateTimeFormat } from "./dateTimeFormat/index.js";
3
+ import { t as dateTimeFormat } from "./chunk-D7jICOmO.js";
4
4
  import { getDocumentLang, subscribeDocumentLangChange } from "./documentLang/index.js";
5
5
  import { makeDraggable } from "./makeDraggable/index.js";
6
6
  import { createOverflowHandler, getSize, updateOverflowHandler } from "./overflowHandler/index.js";
7
-
8
- export * from "@internationalized/number"
9
-
10
- export { createOverflowHandler, datePartsOrder, dateTimeFormat, getDocumentLang, getSize, initCarousel, makeDraggable, subscribeDocumentLangChange, updateOverflowHandler };
7
+ export * from "@internationalized/number";
8
+ export { createOverflowHandler, datePartsOrder, dateTimeFormat, getDocumentLang, getSize, initCarousel, makeDraggable, subscribeDocumentLangChange, updateOverflowHandler };
@@ -1,6 +1,6 @@
1
1
  //#region src/makeDraggable/makeDraggable.d.ts
2
2
  /**
3
- * Copyright IBM Corp. 2025, 2025
3
+ * Copyright IBM Corp. 2025, 2026
4
4
  *
5
5
  * This source code is licensed under the Apache-2.0 license found in the
6
6
  * LICENSE file in the root directory of this source tree.
@@ -41,6 +41,7 @@ declare const makeDraggable: ({
41
41
  shiftDragStep
42
42
  }: DraggableProps) => {
43
43
  cleanup: () => void;
44
+ init: () => void;
44
45
  };
45
46
  //#endregion
46
47
  export { makeDraggable };
@@ -9,8 +9,49 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
9
9
  el.style.cursor = "default";
10
10
  } else el.style.cursor = "move";
11
11
  let isDragging = false;
12
- let offsetX = 0;
13
- let offsetY = 0;
12
+ let currentX = 0;
13
+ let currentY = 0;
14
+ let initialMouseX = 0;
15
+ let initialMouseY = 0;
16
+ let baseMatrix = null;
17
+ /**
18
+ * Syncs position and extracts base matrix from computed style.
19
+ * Reads from getComputedStyle() to include all transform sources (inline, classes, etc.).
20
+ */
21
+ const syncTransformState = () => {
22
+ const transformString = window.getComputedStyle(el).transform;
23
+ if (!transformString || transformString === "none") {
24
+ currentX = 0;
25
+ currentY = 0;
26
+ baseMatrix = null;
27
+ return;
28
+ }
29
+ const matrix = new DOMMatrix(transformString);
30
+ currentX = matrix.m41;
31
+ currentY = matrix.m42;
32
+ if (matrix.a === 1 && matrix.b === 0 && matrix.c === 0 && matrix.d === 1 && matrix.e === 0 && matrix.f === 0) baseMatrix = null;
33
+ else baseMatrix = new DOMMatrix([
34
+ matrix.a,
35
+ matrix.b,
36
+ matrix.c,
37
+ matrix.d,
38
+ 0,
39
+ 0
40
+ ]);
41
+ };
42
+ syncTransformState();
43
+ /**
44
+ * Applies transform by combining translation with base matrix using matrix multiplication.
45
+ */
46
+ const applyTransform = (x, y) => {
47
+ if (baseMatrix) {
48
+ const translationMatrix = new DOMMatrix();
49
+ translationMatrix.m41 = x;
50
+ translationMatrix.m42 = y;
51
+ const combined = translationMatrix.multiply(baseMatrix);
52
+ el.style.transform = combined.toString();
53
+ } else el.style.transform = `translate(${x}px, ${y}px)`;
54
+ };
14
55
  const dispatch = (type, detail) => {
15
56
  const eventInit = {
16
57
  detail,
@@ -19,9 +60,13 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
19
60
  el.dispatchEvent(new CustomEvent(type, eventInit));
20
61
  };
21
62
  const onKeyDown = (e) => {
22
- if (e.key === "Enter") isDragging = !isDragging;
23
- if (isDragging) dispatch("dragstart", { keyboard: true });
24
- else dispatch("dragend", { keyboard: true });
63
+ if (e.key === "Enter") {
64
+ isDragging = !isDragging;
65
+ if (isDragging) {
66
+ syncTransformState();
67
+ dispatch("dragstart", { keyboard: true });
68
+ } else dispatch("dragend", { keyboard: true });
69
+ }
25
70
  if (!isDragging) return;
26
71
  const distance = e.shiftKey ? shiftDragStep ?? 32 : dragStep ?? 8;
27
72
  switch (e.key) {
@@ -30,16 +75,20 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
30
75
  e.preventDefault();
31
76
  break;
32
77
  case "ArrowLeft":
33
- el.style.left = `${el.offsetLeft - distance}px`;
78
+ currentX -= distance;
79
+ applyTransform(currentX, currentY);
34
80
  break;
35
81
  case "ArrowRight":
36
- el.style.left = `${el.offsetLeft + distance}px`;
82
+ currentX += distance;
83
+ applyTransform(currentX, currentY);
37
84
  break;
38
85
  case "ArrowUp":
39
- el.style.top = `${el.offsetTop - distance}px`;
86
+ currentY -= distance;
87
+ applyTransform(currentX, currentY);
40
88
  break;
41
89
  case "ArrowDown":
42
- el.style.top = `${el.offsetTop + distance}px`;
90
+ currentY += distance;
91
+ applyTransform(currentX, currentY);
43
92
  break;
44
93
  }
45
94
  };
@@ -47,8 +96,9 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
47
96
  const target = e.target;
48
97
  if (!(target instanceof Node)) return;
49
98
  if (!(dragHandle ? dragHandle.contains(target) : el.contains(target))) return;
50
- offsetX = e.clientX - el.offsetLeft;
51
- offsetY = e.clientY - el.offsetTop;
99
+ syncTransformState();
100
+ initialMouseX = e.clientX;
101
+ initialMouseY = e.clientY;
52
102
  isDragging = true;
53
103
  dispatch("dragstart", { mouse: true });
54
104
  document.addEventListener("mousemove", onMouseMove);
@@ -56,11 +106,16 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
56
106
  };
57
107
  const onMouseMove = (e) => {
58
108
  if (!isDragging) return;
59
- el.style.left = `${e.clientX - offsetX}px`;
60
- el.style.top = `${e.clientY - offsetY}px`;
109
+ const dx = e.clientX - initialMouseX;
110
+ const dy = e.clientY - initialMouseY;
111
+ applyTransform(currentX + dx, currentY + dy);
61
112
  };
62
- const onMouseUp = () => {
113
+ const onMouseUp = (e) => {
63
114
  if (!isDragging) return;
115
+ const dx = e.clientX - initialMouseX;
116
+ const dy = e.clientY - initialMouseY;
117
+ currentX += dx;
118
+ currentY += dy;
64
119
  isDragging = false;
65
120
  dispatch("dragend", { mouse: true });
66
121
  document.removeEventListener("mousemove", onMouseMove);
@@ -75,8 +130,18 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
75
130
  document.removeEventListener("mousemove", onMouseMove);
76
131
  document.removeEventListener("mouseup", onMouseUp);
77
132
  };
78
- return { cleanup: draggableCleanup };
133
+ /**
134
+ * Re-initialize the draggable position from the element's current computed transform.
135
+ * Call this if the element has been repositioned externally (e.g., via CSS animation,
136
+ * class changes, or other scripts) to prevent position jumps on the next drag.
137
+ */
138
+ const init = () => {
139
+ syncTransformState();
140
+ };
141
+ return {
142
+ cleanup: draggableCleanup,
143
+ init
144
+ };
79
145
  };
80
-
81
146
  //#endregion
82
- export { makeDraggable };
147
+ export { makeDraggable };
@@ -90,6 +90,5 @@ function createOverflowHandler({ container, maxVisibleItems, onChange, dimension
90
90
  resizeObserver.disconnect();
91
91
  } };
92
92
  }
93
-
94
93
  //#endregion
95
- export { createOverflowHandler, getSize, updateOverflowHandler };
94
+ export { createOverflowHandler, getSize, updateOverflowHandler };
@@ -1,4 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_carousel = require('../chunk-C5VBwGBG.js');
3
-
4
- exports.initCarousel = require_carousel.initCarousel;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_carousel = require("../chunk-DVu1wdA8.js");
3
+ exports.initCarousel = require_carousel.initCarousel;
@@ -2,20 +2,14 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
10
  return target;
15
11
  };
16
-
17
12
  //#endregion
18
-
19
13
  //#region src/dateTimeFormat/relative.ts
20
14
  var relative_exports = /* @__PURE__ */ __exportAll({ format: () => format$1 });
21
15
  /**
@@ -27,8 +21,7 @@ var relative_exports = /* @__PURE__ */ __exportAll({ format: () => format$1 });
27
21
  function format$1(date, options) {
28
22
  const rtf = new Intl.RelativeTimeFormat(options?.locale, { style: options?.style ?? "long" });
29
23
  const d = typeof date === "number" ? new Date(date) : date;
30
- const now = Date.now();
31
- const seconds = Math.floor((now - d.getTime()) / 1e3);
24
+ const seconds = Math.floor((Date.now() - d.getTime()) / 1e3);
32
25
  const minutes = Math.floor(seconds / 60);
33
26
  const hours = Math.floor(minutes / 60);
34
27
  const days = Math.floor(hours / 24);
@@ -46,7 +39,6 @@ function format$1(date, options) {
46
39
  if (Math.abs(days) < 365) return rtf.format(months * -1, "months");
47
40
  return rtf.format(years * -1, "years");
48
41
  }
49
-
50
42
  //#endregion
51
43
  //#region src/dateTimeFormat/absolute.ts
52
44
  var absolute_exports = /* @__PURE__ */ __exportAll({
@@ -91,17 +83,22 @@ function formatRange(startDate, endDate, options) {
91
83
  timeZone: options?.timeZone
92
84
  }).formatRange(startDate, endDate);
93
85
  }
94
-
95
86
  //#endregion
96
- Object.defineProperty(exports, 'absolute_exports', {
97
- enumerable: true,
98
- get: function () {
99
- return absolute_exports;
100
- }
87
+ //#region src/dateTimeFormat/index.ts
88
+ /**
89
+ * Copyright IBM Corp. 2024
90
+ *
91
+ * This source code is licensed under the Apache-2.0 license found in the
92
+ * LICENSE file in the root directory of this source tree.
93
+ */
94
+ const dateTimeFormat = {
95
+ relative: relative_exports,
96
+ absolute: absolute_exports
97
+ };
98
+ //#endregion
99
+ Object.defineProperty(exports, "dateTimeFormat", {
100
+ enumerable: true,
101
+ get: function() {
102
+ return dateTimeFormat;
103
+ }
101
104
  });
102
- Object.defineProperty(exports, 'relative_exports', {
103
- enumerable: true,
104
- get: function () {
105
- return relative_exports;
106
- }
107
- });
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/carousel/defs.ts
3
2
  /**
4
3
  * Copyright IBM Corp. 2026
@@ -10,7 +9,6 @@ const translationIds = {
10
9
  "carbon.carousel.item": "carbon.carousel.item",
11
10
  "carbon.carousel.of": "carbon.carousel.of"
12
11
  };
13
-
14
12
  //#endregion
15
13
  //#region src/carousel/swipeEvents.ts
16
14
  /**
@@ -90,7 +88,6 @@ const registerSwipeEvents = (carousel, next, prev, destroy) => {
90
88
  carousel.addEventListener("mouseup", mouseUpHandler);
91
89
  carousel.addEventListener("wheel", wheelHandler);
92
90
  };
93
-
94
91
  //#endregion
95
92
  //#region src/carousel/carousel.ts
96
93
  const defaultTranslations = {
@@ -433,11 +430,10 @@ const initCarousel = (carouselContainer, config) => {
433
430
  allViews: refs
434
431
  };
435
432
  };
436
-
437
433
  //#endregion
438
- Object.defineProperty(exports, 'initCarousel', {
439
- enumerable: true,
440
- get: function () {
441
- return initCarousel;
442
- }
443
- });
434
+ Object.defineProperty(exports, "initCarousel", {
435
+ enumerable: true,
436
+ get: function() {
437
+ return initCarousel;
438
+ }
439
+ });
@@ -1,5 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  //#region src/datePartsOrder/datePartsOrder.ts
4
3
  const _orderCache = /* @__PURE__ */ new Map();
5
4
  function getMonthYearOrder(locale) {
@@ -18,6 +17,5 @@ const datePartsOrder = {
18
17
  getMonthYearOrder,
19
18
  isMonthFirst
20
19
  };
21
-
22
20
  //#endregion
23
- exports.datePartsOrder = datePartsOrder;
21
+ exports.datePartsOrder = datePartsOrder;
@@ -1,17 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_absolute = require('../chunk-Dc0mzKQx.js');
3
-
4
- //#region src/dateTimeFormat/index.ts
5
- /**
6
- * Copyright IBM Corp. 2024
7
- *
8
- * This source code is licensed under the Apache-2.0 license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */
11
- const dateTimeFormat = {
12
- relative: require_absolute.relative_exports,
13
- absolute: require_absolute.absolute_exports
14
- };
15
-
16
- //#endregion
17
- exports.dateTimeFormat = dateTimeFormat;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_dateTimeFormat = require("../chunk-D5n0j0X6.js");
3
+ exports.dateTimeFormat = require_dateTimeFormat.dateTimeFormat;
@@ -1,5 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  //#region src/documentLang/documentLang.ts
4
3
  /**
5
4
  * Copyright IBM Corp. 2025
@@ -66,7 +65,6 @@ function subscribeDocumentLangChange(callback) {
66
65
  if (subscribers.length === 0) observerInitialized = false;
67
66
  };
68
67
  }
69
-
70
68
  //#endregion
71
69
  exports.getDocumentLang = getDocumentLang;
72
- exports.subscribeDocumentLangChange = subscribeDocumentLangChange;
70
+ exports.subscribeDocumentLangChange = subscribeDocumentLangChange;
package/lib/index.js CHANGED
@@ -1,14 +1,13 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_carousel = require('./chunk-C5VBwGBG.js');
3
- const require_datePartsOrder_index = require('./datePartsOrder/index.js');
4
- const require_dateTimeFormat_index = require('./dateTimeFormat/index.js');
5
- const require_documentLang_index = require('./documentLang/index.js');
6
- const require_makeDraggable_index = require('./makeDraggable/index.js');
7
- const require_overflowHandler_index = require('./overflowHandler/index.js');
8
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_dateTimeFormat = require("./chunk-D5n0j0X6.js");
3
+ const require_carousel = require("./chunk-DVu1wdA8.js");
4
+ const require_datePartsOrder_index = require("./datePartsOrder/index.js");
5
+ const require_documentLang_index = require("./documentLang/index.js");
6
+ const require_makeDraggable_index = require("./makeDraggable/index.js");
7
+ const require_overflowHandler_index = require("./overflowHandler/index.js");
9
8
  exports.createOverflowHandler = require_overflowHandler_index.createOverflowHandler;
10
9
  exports.datePartsOrder = require_datePartsOrder_index.datePartsOrder;
11
- exports.dateTimeFormat = require_dateTimeFormat_index.dateTimeFormat;
10
+ exports.dateTimeFormat = require_dateTimeFormat.dateTimeFormat;
12
11
  exports.getDocumentLang = require_documentLang_index.getDocumentLang;
13
12
  exports.getSize = require_overflowHandler_index.getSize;
14
13
  exports.initCarousel = require_carousel.initCarousel;
@@ -16,9 +15,11 @@ exports.makeDraggable = require_makeDraggable_index.makeDraggable;
16
15
  exports.subscribeDocumentLangChange = require_documentLang_index.subscribeDocumentLangChange;
17
16
  exports.updateOverflowHandler = require_overflowHandler_index.updateOverflowHandler;
18
17
  var _internationalized_number = require("@internationalized/number");
19
- Object.keys(_internationalized_number).forEach(function (k) {
20
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
21
- enumerable: true,
22
- get: function () { return _internationalized_number[k]; }
23
- });
18
+ Object.keys(_internationalized_number).forEach(function(k) {
19
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
20
+ enumerable: true,
21
+ get: function() {
22
+ return _internationalized_number[k];
23
+ }
24
+ });
24
25
  });
@@ -1,5 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  //#region src/makeDraggable/makeDraggable.ts
4
3
  /**
5
4
  * Makes a given element draggable using a handle element.
@@ -11,8 +10,49 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
11
10
  el.style.cursor = "default";
12
11
  } else el.style.cursor = "move";
13
12
  let isDragging = false;
14
- let offsetX = 0;
15
- let offsetY = 0;
13
+ let currentX = 0;
14
+ let currentY = 0;
15
+ let initialMouseX = 0;
16
+ let initialMouseY = 0;
17
+ let baseMatrix = null;
18
+ /**
19
+ * Syncs position and extracts base matrix from computed style.
20
+ * Reads from getComputedStyle() to include all transform sources (inline, classes, etc.).
21
+ */
22
+ const syncTransformState = () => {
23
+ const transformString = window.getComputedStyle(el).transform;
24
+ if (!transformString || transformString === "none") {
25
+ currentX = 0;
26
+ currentY = 0;
27
+ baseMatrix = null;
28
+ return;
29
+ }
30
+ const matrix = new DOMMatrix(transformString);
31
+ currentX = matrix.m41;
32
+ currentY = matrix.m42;
33
+ if (matrix.a === 1 && matrix.b === 0 && matrix.c === 0 && matrix.d === 1 && matrix.e === 0 && matrix.f === 0) baseMatrix = null;
34
+ else baseMatrix = new DOMMatrix([
35
+ matrix.a,
36
+ matrix.b,
37
+ matrix.c,
38
+ matrix.d,
39
+ 0,
40
+ 0
41
+ ]);
42
+ };
43
+ syncTransformState();
44
+ /**
45
+ * Applies transform by combining translation with base matrix using matrix multiplication.
46
+ */
47
+ const applyTransform = (x, y) => {
48
+ if (baseMatrix) {
49
+ const translationMatrix = new DOMMatrix();
50
+ translationMatrix.m41 = x;
51
+ translationMatrix.m42 = y;
52
+ const combined = translationMatrix.multiply(baseMatrix);
53
+ el.style.transform = combined.toString();
54
+ } else el.style.transform = `translate(${x}px, ${y}px)`;
55
+ };
16
56
  const dispatch = (type, detail) => {
17
57
  const eventInit = {
18
58
  detail,
@@ -21,9 +61,13 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
21
61
  el.dispatchEvent(new CustomEvent(type, eventInit));
22
62
  };
23
63
  const onKeyDown = (e) => {
24
- if (e.key === "Enter") isDragging = !isDragging;
25
- if (isDragging) dispatch("dragstart", { keyboard: true });
26
- else dispatch("dragend", { keyboard: true });
64
+ if (e.key === "Enter") {
65
+ isDragging = !isDragging;
66
+ if (isDragging) {
67
+ syncTransformState();
68
+ dispatch("dragstart", { keyboard: true });
69
+ } else dispatch("dragend", { keyboard: true });
70
+ }
27
71
  if (!isDragging) return;
28
72
  const distance = e.shiftKey ? shiftDragStep ?? 32 : dragStep ?? 8;
29
73
  switch (e.key) {
@@ -32,16 +76,20 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
32
76
  e.preventDefault();
33
77
  break;
34
78
  case "ArrowLeft":
35
- el.style.left = `${el.offsetLeft - distance}px`;
79
+ currentX -= distance;
80
+ applyTransform(currentX, currentY);
36
81
  break;
37
82
  case "ArrowRight":
38
- el.style.left = `${el.offsetLeft + distance}px`;
83
+ currentX += distance;
84
+ applyTransform(currentX, currentY);
39
85
  break;
40
86
  case "ArrowUp":
41
- el.style.top = `${el.offsetTop - distance}px`;
87
+ currentY -= distance;
88
+ applyTransform(currentX, currentY);
42
89
  break;
43
90
  case "ArrowDown":
44
- el.style.top = `${el.offsetTop + distance}px`;
91
+ currentY += distance;
92
+ applyTransform(currentX, currentY);
45
93
  break;
46
94
  }
47
95
  };
@@ -49,8 +97,9 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
49
97
  const target = e.target;
50
98
  if (!(target instanceof Node)) return;
51
99
  if (!(dragHandle ? dragHandle.contains(target) : el.contains(target))) return;
52
- offsetX = e.clientX - el.offsetLeft;
53
- offsetY = e.clientY - el.offsetTop;
100
+ syncTransformState();
101
+ initialMouseX = e.clientX;
102
+ initialMouseY = e.clientY;
54
103
  isDragging = true;
55
104
  dispatch("dragstart", { mouse: true });
56
105
  document.addEventListener("mousemove", onMouseMove);
@@ -58,11 +107,16 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
58
107
  };
59
108
  const onMouseMove = (e) => {
60
109
  if (!isDragging) return;
61
- el.style.left = `${e.clientX - offsetX}px`;
62
- el.style.top = `${e.clientY - offsetY}px`;
110
+ const dx = e.clientX - initialMouseX;
111
+ const dy = e.clientY - initialMouseY;
112
+ applyTransform(currentX + dx, currentY + dy);
63
113
  };
64
- const onMouseUp = () => {
114
+ const onMouseUp = (e) => {
65
115
  if (!isDragging) return;
116
+ const dx = e.clientX - initialMouseX;
117
+ const dy = e.clientY - initialMouseY;
118
+ currentX += dx;
119
+ currentY += dy;
66
120
  isDragging = false;
67
121
  dispatch("dragend", { mouse: true });
68
122
  document.removeEventListener("mousemove", onMouseMove);
@@ -77,8 +131,18 @@ const makeDraggable = ({ el, dragHandle, focusableDragHandle, dragStep, shiftDra
77
131
  document.removeEventListener("mousemove", onMouseMove);
78
132
  document.removeEventListener("mouseup", onMouseUp);
79
133
  };
80
- return { cleanup: draggableCleanup };
134
+ /**
135
+ * Re-initialize the draggable position from the element's current computed transform.
136
+ * Call this if the element has been repositioned externally (e.g., via CSS animation,
137
+ * class changes, or other scripts) to prevent position jumps on the next drag.
138
+ */
139
+ const init = () => {
140
+ syncTransformState();
141
+ };
142
+ return {
143
+ cleanup: draggableCleanup,
144
+ init
145
+ };
81
146
  };
82
-
83
147
  //#endregion
84
- exports.makeDraggable = makeDraggable;
148
+ exports.makeDraggable = makeDraggable;
@@ -1,5 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  //#region src/overflowHandler/overflowHandler.ts
4
3
  /**
5
4
  * Copyright IBM Corp. 2025, 2026
@@ -92,8 +91,7 @@ function createOverflowHandler({ container, maxVisibleItems, onChange, dimension
92
91
  resizeObserver.disconnect();
93
92
  } };
94
93
  }
95
-
96
94
  //#endregion
97
95
  exports.createOverflowHandler = createOverflowHandler;
98
96
  exports.getSize = getSize;
99
- exports.updateOverflowHandler = updateOverflowHandler;
97
+ exports.updateOverflowHandler = updateOverflowHandler;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/utilities",
3
3
  "description": "Utilities and helpers to drive consistency across software products using the Carbon Design System",
4
- "version": "0.18.0-rc.0",
4
+ "version": "0.19.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -59,12 +59,12 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "rimraf": "^6.0.1",
62
- "tsdown": "^0.20.3",
62
+ "tsdown": "^0.21.0",
63
63
  "typescript-config-carbon": "^0.9.0"
64
64
  },
65
65
  "dependencies": {
66
66
  "@ibm/telemetry-js": "^1.6.1",
67
67
  "@internationalized/number": "^3.6.1"
68
68
  },
69
- "gitHead": "d901529b78f5b70b49309ad45604fa5ec99a2e69"
69
+ "gitHead": "20a00767571db791cac99d499527e2f995ead478"
70
70
  }
@@ -1,18 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
4
- let target = {};
5
- for (var name in all) {
6
- __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
10
- }
11
- if (!no_symbols) {
12
- __defProp(target, Symbol.toStringTag, { value: "Module" });
13
- }
14
- return target;
15
- };
16
-
17
- //#endregion
18
- export { __exportAll as t };
File without changes