@lolmath/ui 2.2.0 → 2.3.1
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.
- package/dist/index.cjs +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -464,23 +464,48 @@ function ProgressBar({
|
|
|
464
464
|
// src/components/accordion.tsx
|
|
465
465
|
import { createContext, useState, useContext } from "react";
|
|
466
466
|
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
467
|
+
|
|
468
|
+
// src/utilities/css-id.tsx
|
|
469
|
+
import { useId } from "react";
|
|
470
|
+
function useCssId() {
|
|
471
|
+
return useId().replaceAll(":", "");
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/utilities/view-transition.tsx
|
|
475
|
+
import { flushSync } from "react-dom";
|
|
476
|
+
function startViewTransition(callback) {
|
|
477
|
+
if (document.startViewTransition) {
|
|
478
|
+
document.startViewTransition(() => {
|
|
479
|
+
flushSync(callback);
|
|
480
|
+
});
|
|
481
|
+
} else {
|
|
482
|
+
callback();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/components/accordion.tsx
|
|
467
487
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
468
488
|
function Accordion({ children, className }) {
|
|
469
489
|
const [activeItem, setActiveItem] = useState("");
|
|
490
|
+
const id = useCssId();
|
|
470
491
|
return /* @__PURE__ */ jsx7(
|
|
471
492
|
AccordionContext.Provider,
|
|
472
493
|
{
|
|
473
494
|
value: {
|
|
474
495
|
activeItem,
|
|
475
|
-
setActiveItem
|
|
496
|
+
setActiveItem,
|
|
497
|
+
id
|
|
476
498
|
},
|
|
477
499
|
children: /* @__PURE__ */ jsx7(
|
|
478
500
|
"div",
|
|
479
501
|
{
|
|
480
502
|
className: twMerge7(
|
|
481
|
-
"bg-lol-blue-950 border-lol-gold-500 overflow-hidden
|
|
503
|
+
"bg-lol-blue-950 border-lol-gold-500 rounded border overflow-hidden",
|
|
482
504
|
className
|
|
483
505
|
),
|
|
506
|
+
style: {
|
|
507
|
+
viewTransitionName: `${id}`
|
|
508
|
+
},
|
|
484
509
|
children
|
|
485
510
|
}
|
|
486
511
|
)
|
|
@@ -491,7 +516,7 @@ function AccordionTrigger({
|
|
|
491
516
|
children,
|
|
492
517
|
className
|
|
493
518
|
}) {
|
|
494
|
-
const { setActiveItem, activeItem } = useContext(AccordionContext);
|
|
519
|
+
const { setActiveItem, activeItem, id } = useContext(AccordionContext);
|
|
495
520
|
const { item } = useContext(AccordionItemContext);
|
|
496
521
|
return /* @__PURE__ */ jsxs6(
|
|
497
522
|
"button",
|
|
@@ -501,7 +526,12 @@ function AccordionTrigger({
|
|
|
501
526
|
className
|
|
502
527
|
),
|
|
503
528
|
onClick: () => {
|
|
504
|
-
|
|
529
|
+
startViewTransition(() => {
|
|
530
|
+
setActiveItem((currentItem) => currentItem === item ? "" : item);
|
|
531
|
+
});
|
|
532
|
+
},
|
|
533
|
+
style: {
|
|
534
|
+
viewTransitionName: `${id}-${item}`
|
|
505
535
|
},
|
|
506
536
|
children: [
|
|
507
537
|
/* @__PURE__ */ jsx7(
|