@carbon/utilities 0.20.0-rc.0 → 0.21.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-BxtJV719.js";
2
- export { CarouselResponse, CarouselStackHistory, Config, InitCarousel, TranslationKey, initCarousel };
1
+ import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "../chunk-DHHCmWMn.js";
2
+ export { type CarouselResponse, type CarouselStackHistory, Config, type InitCarousel, TranslationKey, initCarousel };
@@ -1,2 +1,2 @@
1
- import { t as initCarousel } from "../chunk-DMEZ3h3f.js";
1
+ import { t as initCarousel } from "../chunk-8mMgI_GR.js";
2
2
  export { initCarousel };
@@ -112,6 +112,8 @@ const initCarousel = (carouselContainer, config) => {
112
112
  let previousViewIndexStack = [0];
113
113
  const refs = {};
114
114
  const carouselListeners = /* @__PURE__ */ new WeakMap();
115
+ const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
116
+ let supportsAnimations;
115
117
  const minHeight = 4;
116
118
  const { onViewChangeStart, onViewChangeEnd, excludeSwipeSupport, useMaxHeight, translateWithId: t = defaultTranslateWithId } = config || {};
117
119
  /**
@@ -228,12 +230,14 @@ const initCarousel = (carouselContainer, config) => {
228
230
  * @returns {void}
229
231
  */
230
232
  const transitionToViewIndex = (idx) => {
233
+ const viewItems = getCarouselItems();
231
234
  const sanitizedIndex = sanitizeIndex(idx);
232
235
  if (viewIndexStack[0] !== sanitizedIndex) {
233
236
  handleTransitionStart();
234
237
  viewIndexStack = [sanitizedIndex, ...viewIndexStack];
235
238
  syncLiveRegionWithActiveView();
236
239
  performAnimation(false);
240
+ if ((prefersReducedMotion || prefersReducedMotion === false && supportsAnimations === false) && viewItems) handleTransitionEnd(viewItems[sanitizedIndex]);
237
241
  }
238
242
  };
239
243
  const transitionComplete = (ref) => {
@@ -314,6 +318,7 @@ const initCarousel = (carouselContainer, config) => {
314
318
  const listener = (e) => {
315
319
  removeReCycleClasses(viewItem);
316
320
  if (e.target === refs[viewIndexStack[0]]) transitionComplete(viewItem);
321
+ if (!supportsAnimations) supportsAnimations = true;
317
322
  };
318
323
  carouselListeners.set(viewItem, listener);
319
324
  viewItem.addEventListener("animationend", listener);
@@ -340,10 +345,15 @@ const initCarousel = (carouselContainer, config) => {
340
345
  */
341
346
  const navigatePrev = () => {
342
347
  if (viewIndexStack.length - 1 >= 1) {
348
+ const viewItems = getCarouselItems();
343
349
  handleTransitionStart();
344
350
  viewIndexStack = viewIndexStack.slice(1);
345
351
  syncLiveRegionWithActiveView();
346
352
  performAnimation(false);
353
+ if ((prefersReducedMotion || prefersReducedMotion === false && !supportsAnimations) && viewItems) {
354
+ const targetViewIndex = viewIndexStack[0];
355
+ handleTransitionEnd(viewItems[targetViewIndex]);
356
+ }
347
357
  }
348
358
  };
349
359
  /**
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./chunk-pbuEa-1d.js";
1
+ import { t as __exportAll } from "./chunk-D7D4PA-g.js";
2
2
  //#region src/dateTimeFormat/relative.ts
3
3
  var relative_exports = /* @__PURE__ */ __exportAll({ format: () => format$1 });
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { t as dateTimeFormat } from "../chunk-BIOsKtwb.js";
1
+ import { t as dateTimeFormat } from "../chunk-B_oT5GVP.js";
2
2
  export { dateTimeFormat };
@@ -1,2 +1,2 @@
1
- import { t as dateTimeFormat } from "../chunk-D7jICOmO.js";
1
+ import { t as dateTimeFormat } from "../chunk-WCnoMKEo.js";
2
2
  export { dateTimeFormat };
package/es/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "./chunk-BxtJV719.js";
1
+ import { a as InitCarousel, i as Config, n as CarouselResponse, o as TranslationKey, r as CarouselStackHistory, t as initCarousel } from "./chunk-DHHCmWMn.js";
2
2
  import { datePartsOrder } from "./datePartsOrder/index.js";
3
- import { t as dateTimeFormat } from "./chunk-BIOsKtwb.js";
3
+ import { t as dateTimeFormat } from "./chunk-B_oT5GVP.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";
7
- export * from "@internationalized/number";
8
- export { CarouselResponse, CarouselStackHistory, Config, InitCarousel, OverflowHandler, OverflowHandlerOptions, TranslationKey, UpdateOverflowHandlerOptions, createOverflowHandler, datePartsOrder, dateTimeFormat, getDocumentLang, getSize, initCarousel, makeDraggable, subscribeDocumentLangChange, updateOverflowHandler };
7
+ export type * from "@internationalized/number";
8
+ export { type CarouselResponse, type CarouselStackHistory, Config, type InitCarousel, OverflowHandler, OverflowHandlerOptions, TranslationKey, UpdateOverflowHandlerOptions, createOverflowHandler, datePartsOrder, dateTimeFormat, getDocumentLang, getSize, initCarousel, makeDraggable, subscribeDocumentLangChange, updateOverflowHandler };
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { t as initCarousel } from "./chunk-DMEZ3h3f.js";
1
+ import { t as initCarousel } from "./chunk-8mMgI_GR.js";
2
2
  import { datePartsOrder } from "./datePartsOrder/index.js";
3
- import { t as dateTimeFormat } from "./chunk-D7jICOmO.js";
3
+ import { t as dateTimeFormat } from "./chunk-WCnoMKEo.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";
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_carousel = require("../chunk-DVu1wdA8.js");
2
+ const require_carousel = require("../chunk-BE34e-3u.js");
3
3
  exports.initCarousel = require_carousel.initCarousel;
@@ -112,6 +112,8 @@ const initCarousel = (carouselContainer, config) => {
112
112
  let previousViewIndexStack = [0];
113
113
  const refs = {};
114
114
  const carouselListeners = /* @__PURE__ */ new WeakMap();
115
+ const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
116
+ let supportsAnimations;
115
117
  const minHeight = 4;
116
118
  const { onViewChangeStart, onViewChangeEnd, excludeSwipeSupport, useMaxHeight, translateWithId: t = defaultTranslateWithId } = config || {};
117
119
  /**
@@ -228,12 +230,14 @@ const initCarousel = (carouselContainer, config) => {
228
230
  * @returns {void}
229
231
  */
230
232
  const transitionToViewIndex = (idx) => {
233
+ const viewItems = getCarouselItems();
231
234
  const sanitizedIndex = sanitizeIndex(idx);
232
235
  if (viewIndexStack[0] !== sanitizedIndex) {
233
236
  handleTransitionStart();
234
237
  viewIndexStack = [sanitizedIndex, ...viewIndexStack];
235
238
  syncLiveRegionWithActiveView();
236
239
  performAnimation(false);
240
+ if ((prefersReducedMotion || prefersReducedMotion === false && supportsAnimations === false) && viewItems) handleTransitionEnd(viewItems[sanitizedIndex]);
237
241
  }
238
242
  };
239
243
  const transitionComplete = (ref) => {
@@ -314,6 +318,7 @@ const initCarousel = (carouselContainer, config) => {
314
318
  const listener = (e) => {
315
319
  removeReCycleClasses(viewItem);
316
320
  if (e.target === refs[viewIndexStack[0]]) transitionComplete(viewItem);
321
+ if (!supportsAnimations) supportsAnimations = true;
317
322
  };
318
323
  carouselListeners.set(viewItem, listener);
319
324
  viewItem.addEventListener("animationend", listener);
@@ -340,10 +345,15 @@ const initCarousel = (carouselContainer, config) => {
340
345
  */
341
346
  const navigatePrev = () => {
342
347
  if (viewIndexStack.length - 1 >= 1) {
348
+ const viewItems = getCarouselItems();
343
349
  handleTransitionStart();
344
350
  viewIndexStack = viewIndexStack.slice(1);
345
351
  syncLiveRegionWithActiveView();
346
352
  performAnimation(false);
353
+ if ((prefersReducedMotion || prefersReducedMotion === false && !supportsAnimations) && viewItems) {
354
+ const targetViewIndex = viewIndexStack[0];
355
+ handleTransitionEnd(viewItems[targetViewIndex]);
356
+ }
347
357
  }
348
358
  };
349
359
  /**
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dateTimeFormat = require("../chunk-D5n0j0X6.js");
2
+ const require_dateTimeFormat = require("../chunk-Cd3Qp242.js");
3
3
  exports.dateTimeFormat = require_dateTimeFormat.dateTimeFormat;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dateTimeFormat = require("./chunk-D5n0j0X6.js");
3
- const require_carousel = require("./chunk-DVu1wdA8.js");
2
+ const require_dateTimeFormat = require("./chunk-Cd3Qp242.js");
3
+ const require_carousel = require("./chunk-BE34e-3u.js");
4
4
  const require_datePartsOrder_index = require("./datePartsOrder/index.js");
5
5
  const require_documentLang_index = require("./documentLang/index.js");
6
6
  const require_makeDraggable_index = require("./makeDraggable/index.js");
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.20.0-rc.0",
4
+ "version": "0.21.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.21.0",
63
- "typescript-config-carbon": "^0.10.0-rc.0"
62
+ "tsdown": "^0.22.0",
63
+ "typescript-config-carbon": "^0.10.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": "3d219dfcc2a3da515016f7ce0e769d013c3a6c03"
69
+ "gitHead": "415bf87b56763dc172a38f310ee5536e70dd792b"
70
70
  }
File without changes
File without changes
File without changes
File without changes