@consumidor-positivo/aurora 3.2.1 → 3.2.3
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/astro/Carousel/Root/index.astro +11 -4
- package/dist/components/BadgeInfo/styles.css +1 -1
- package/dist/components/Button/styles.css +1 -1
- package/dist/components/Carousel/Root/index.es.js +7 -2
- package/dist/components/Carousel/Root/index.es.js.map +1 -1
- package/dist/components/Carousel/styles.css +1 -1
- package/dist/components/PasswordField/styles.css +1 -1
- package/package.json +1 -1
|
@@ -23,7 +23,9 @@ export type CarouselItemsPerView = number | { mobile?: number; desktop?: number
|
|
|
23
23
|
export type Props = Omit<HTMLAttributes<'div'>, 'draggable' | 'style'> & {
|
|
24
24
|
/**
|
|
25
25
|
* How the position is shown (Figma: Type). `text` writes "Página 1 de 2"
|
|
26
|
-
* between the arrows; `pin` replaces it with dots
|
|
26
|
+
* between the arrows; `pin` replaces it with dots. The arrows sit at the
|
|
27
|
+
* edges of the row (on desktop the position goes to the start and both
|
|
28
|
+
* arrows to the end); `only-pin` has no arrows.
|
|
27
29
|
*/
|
|
28
30
|
navigation?: CarouselNavigation
|
|
29
31
|
/** White arrows, text and pins for dark backgrounds (Figma: Negative). */
|
|
@@ -294,7 +296,6 @@ const style = [
|
|
|
294
296
|
if (!draggable || event.pointerType !== 'mouse' || event.button !== 0) return
|
|
295
297
|
if (!rail!.contains(event.target as Node)) return
|
|
296
298
|
drag = { startX: event.clientX, scrollLeft: rail!.scrollLeft, page, moved: false }
|
|
297
|
-
rail!.setPointerCapture(event.pointerId)
|
|
298
299
|
})
|
|
299
300
|
|
|
300
301
|
on('pointermove', (event) => {
|
|
@@ -303,6 +304,8 @@ const style = [
|
|
|
303
304
|
if (!drag.moved) {
|
|
304
305
|
if (Math.abs(delta) < DRAG_THRESHOLD) return
|
|
305
306
|
drag.moved = true
|
|
307
|
+
// Capturing on press would retarget the click to the rail, away from the slide's own button.
|
|
308
|
+
rail!.setPointerCapture(event.pointerId)
|
|
306
309
|
rail!.classList.add(DRAGGING_CLASS)
|
|
307
310
|
}
|
|
308
311
|
rail!.scrollLeft = drag.scrollLeft - delta
|
|
@@ -312,11 +315,11 @@ const style = [
|
|
|
312
315
|
if (!drag) return
|
|
313
316
|
const { moved, page: from, startX } = drag
|
|
314
317
|
drag = null
|
|
318
|
+
if (!moved) return
|
|
319
|
+
|
|
315
320
|
if (rail!.hasPointerCapture(event.pointerId)) {
|
|
316
321
|
rail!.releasePointerCapture(event.pointerId)
|
|
317
322
|
}
|
|
318
|
-
if (!moved) return
|
|
319
|
-
|
|
320
323
|
rail!.classList.remove(DRAGGING_CLASS)
|
|
321
324
|
const direction = event.clientX < startX ? 1 : -1
|
|
322
325
|
const nearest = getActivePage(rail!, starts)
|
|
@@ -330,5 +333,9 @@ const style = [
|
|
|
330
333
|
|
|
331
334
|
on('pointerup', endDrag)
|
|
332
335
|
on('pointercancel', endDrag)
|
|
336
|
+
// On the rail, as in React: `on` binds to the root, which the pointer does not leave on its way to the navigation.
|
|
337
|
+
rail.addEventListener('pointerleave', () => {
|
|
338
|
+
if (drag && !drag.moved) drag = null
|
|
339
|
+
})
|
|
333
340
|
})
|
|
334
341
|
</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-badgeInfo{font-family:"Source Sans 3",sans-serif;display:flex;justify-content:center;border-radius:8px;width:fit-content;height:26px;padding:4px 8px}.au-badgeInfo__content{display:flex;gap:4px;justify-content:center;align-items:center}.au-badgeInfo__content-icon .au-icon,.au-badgeInfo__content-icon .au-icon>svg{width:16px;height:16px}.au-badgeInfo__content-support-text{color:#313131;font-size:12px;font-weight:600}.au-badgeInfo--color-primary.au-badgeInfo--info{background-color:#eee6ff}.au-badgeInfo--color-primary.au-badgeInfo--success{background-color:#e5fff0}.au-badgeInfo--color-primary.au-badgeInfo--error{background-color:#ffe5e5}.au-badgeInfo--color-primary.au-badgeInfo--warning{background-color:#fff0e6}.au-badgeInfo--color-primary.au-badgeInfo--progress{background-color:#f1fcff}.au-badgeInfo--color-primary.au-badgeInfo--neutral{background-color:#e2e4e9}.au-badgeInfo--color-secondary.au-badgeInfo--info{background-color:#d4bfff}.au-badgeInfo--color-secondary.au-badgeInfo--success{background-color:#a1e5bd}.au-badgeInfo--color-secondary.au-badgeInfo--error{background-color:#ffbfbf}.au-badgeInfo--color-secondary.au-badgeInfo--warning{background-color:#ffdabf}.au-badgeInfo--color-secondary.au-badgeInfo--progress{background-color:#ccf3ff}.au-badgeInfo--color-secondary.au-badgeInfo--neutral{background-color:#c4c9d4}
|
|
1
|
+
.au-badgeInfo{font-family:"Source Sans 3",sans-serif;display:flex;justify-content:center;border-radius:8px;width:fit-content;min-height:26px;padding:4px 8px}.au-badgeInfo__content{display:flex;gap:4px;justify-content:center;align-items:center}.au-badgeInfo__content-icon .au-icon,.au-badgeInfo__content-icon .au-icon>svg{width:16px;height:16px}.au-badgeInfo__content-support-text{color:#313131;font-size:12px;font-weight:600}.au-badgeInfo--color-primary.au-badgeInfo--info{background-color:#eee6ff}.au-badgeInfo--color-primary.au-badgeInfo--success{background-color:#e5fff0}.au-badgeInfo--color-primary.au-badgeInfo--error{background-color:#ffe5e5}.au-badgeInfo--color-primary.au-badgeInfo--warning{background-color:#fff0e6}.au-badgeInfo--color-primary.au-badgeInfo--progress{background-color:#f1fcff}.au-badgeInfo--color-primary.au-badgeInfo--neutral{background-color:#e2e4e9}.au-badgeInfo--color-secondary.au-badgeInfo--info{background-color:#d4bfff}.au-badgeInfo--color-secondary.au-badgeInfo--success{background-color:#a1e5bd}.au-badgeInfo--color-secondary.au-badgeInfo--error{background-color:#ffbfbf}.au-badgeInfo--color-secondary.au-badgeInfo--warning{background-color:#ffdabf}.au-badgeInfo--color-secondary.au-badgeInfo--progress{background-color:#ccf3ff}.au-badgeInfo--color-secondary.au-badgeInfo--neutral{background-color:#c4c9d4}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-btn{align-items:center;border:none;cursor:pointer;display:inline-flex;font-weight:600;justify-content:center;outline:none;text-align:center;text-decoration:none;transition:background-color .3s ease;font-family:"Source Sans 3",sans-serif;gap:8px;height:48px;border-radius:48px;font-size:16px;padding:
|
|
1
|
+
.au-btn{align-items:center;border:none;cursor:pointer;display:inline-flex;font-weight:600;justify-content:center;outline:none;text-align:center;text-decoration:none;transition:background-color .3s ease;font-family:"Source Sans 3",sans-serif;gap:8px;min-height:48px;border-radius:48px;font-size:16px;padding:12px 18px}.au-btn:hover,.au-btn:focus{background-color:#1737a4}.au-btn:active{background-color:#18256c}.au-btn .au-icon,.au-btn .au-icon>svg{width:20px;height:20px;color:#fff}@media(min-width:600px){.au-btn--size-large{min-height:64px;border-radius:60px;font-size:20px;padding:16px 30px}}.au-btn--size-medium{min-height:48px;border-radius:48px;font-size:16px;padding:12px 18px}.au-btn--color-default{background-color:#0048db;color:#fff}.au-btn--type-outlined{color:#0048db;border:1px solid #0048db;background-color:transparent}.au-btn--type-outlined .au-icon,.au-btn--type-outlined .au-icon>svg{color:#0048db}.au-btn--type-outlined:hover,.au-btn--type-outlined:focus{background-color:#f2f5fc}.au-btn--type-outlined:active{background-color:#dce8ff}.au-btn--type-ghost{background-color:transparent;border:0;color:#0048db}.au-btn--type-ghost .au-icon,.au-btn--type-ghost .au-icon>svg{color:#0048db}.au-btn--type-ghost:hover,.au-btn--type-ghost:focus{background-color:#f2f5fc;border-color:0}.au-btn--type-ghost:active{background-color:#dce8ff;border:1px solid #1737a4;color:#1737a4}.au-btn--type-link{color:#0048db;padding:0;background:transparent}.au-btn--type-link:hover,.au-btn--type-link:focus{background-color:transparent}.au-btn--expand-x{width:100%}.au-btn--disabled{background-color:#e2e4e9;color:#5e6573;cursor:not-allowed}.au-btn--disabled .au-icon svg{color:#5e6573}.au-btn--disabled:hover,.au-btn--disabled:focus{background-color:#e2e4e9}.au-btn--disabled.au-btn--type-outlined{background-color:#fff;color:#5e6573;border-color:#5e6573}.au-btn--disabled.au-btn--type-outlined:hover,.au-btn--disabled.au-btn--type-outlined:focus{background-color:#fff}.au-btn--disabled.au-btn--type-ghost{background-color:#fff;color:#5e6573}.au-btn--disabled.au-btn--type-ghost:hover,.au-btn--disabled.au-btn--type-ghost:focus{background-color:#fff}.au-btn--disabled.au-btn--type-ghost:active{border:0}.au-btn--loading{background-color:#1737a4;color:#fff;cursor:progress}.au-btn--loading .au-icon{animation:spin 1s infinite linear}.au-btn--loading:hover,.au-btn--loading:focus{background-color:#1737a4}.au-btn--loading.au-btn--type-outlined{background-color:#fff;color:#0048db;border-color:#0048db}.au-btn--loading.au-btn--type-outlined:hover,.au-btn--loading.au-btn--type-outlined:focus{background-color:#fff;color:#0048db}.au-btn--loading.au-btn--type-outlined:hover .au-icon,.au-btn--loading.au-btn--type-outlined:hover .au-icon svg,.au-btn--loading.au-btn--type-outlined:focus .au-icon,.au-btn--loading.au-btn--type-outlined:focus .au-icon svg{color:#0048db}.au-btn--loading.au-btn--type-ghost{background-color:transparent;color:#5e6573}.au-btn--loading.au-btn--type-ghost .au-icon,.au-btn--loading.au-btn--type-ghost .au-icon svg{color:#5e6573}.au-btn--loading.au-btn--type-ghost:hover,.au-btn--loading.au-btn--type-ghost:focus{background-color:transparent;color:#5e6573}.au-btn--negative{background-color:#fff;color:#0048db}.au-btn--negative .au-icon,.au-btn--negative .au-icon>svg{color:#0048db}.au-btn--negative:hover,.au-btn--negative:focus{background-color:#f2f5fc;color:#1737a4}.au-btn--negative:hover .au-icon,.au-btn--negative:hover .au-icon>svg,.au-btn--negative:focus .au-icon,.au-btn--negative:focus .au-icon>svg{color:#1737a4}.au-btn--negative:active{background-color:#fff;color:#18256c}.au-btn--negative:active .au-icon,.au-btn--negative:active .au-icon>svg{color:#18256c}.au-btn--negative.au-btn--type-outlined{background-color:transparent;border-color:#fff;color:#fff}.au-btn--negative.au-btn--type-outlined .au-icon,.au-btn--negative.au-btn--type-outlined .au-icon>svg{color:#fff}.au-btn--negative.au-btn--type-outlined:hover,.au-btn--negative.au-btn--type-outlined:focus{background-color:#f2f5fc;border-color:#f2f5fc;color:#1737a4}.au-btn--negative.au-btn--type-outlined:hover .au-icon,.au-btn--negative.au-btn--type-outlined:hover .au-icon>svg,.au-btn--negative.au-btn--type-outlined:focus .au-icon,.au-btn--negative.au-btn--type-outlined:focus .au-icon>svg{color:#1737a4}.au-btn--negative.au-btn--type-outlined:active{background-color:#fff;color:#18256c}.au-btn--negative.au-btn--type-outlined:active .au-icon,.au-btn--negative.au-btn--type-outlined:active .au-icon>svg{color:#18256c}.au-btn--negative.au-btn--type-ghost{background-color:transparent;color:#fff}.au-btn--negative.au-btn--type-ghost .au-icon,.au-btn--negative.au-btn--type-ghost .au-icon>svg{color:#fff}.au-btn--negative.au-btn--type-ghost:hover,.au-btn--negative.au-btn--type-ghost:focus{background-color:#f2f5fc;color:#1737a4}.au-btn--negative.au-btn--type-ghost:hover .au-icon,.au-btn--negative.au-btn--type-ghost:hover .au-icon>svg,.au-btn--negative.au-btn--type-ghost:focus .au-icon,.au-btn--negative.au-btn--type-ghost:focus .au-icon>svg{color:#1737a4}.au-btn--negative.au-btn--type-ghost:active{background-color:#fff;border:0;color:#18256c}.au-btn--negative.au-btn--type-ghost:active .au-icon,.au-btn--negative.au-btn--type-ghost:active .au-icon>svg{color:#18256c}.au-btn--negative.au-btn--disabled{background-color:#f6f7fa;border-color:transparent;color:#c4c9d4}.au-btn--negative.au-btn--disabled .au-icon,.au-btn--negative.au-btn--disabled .au-icon>svg{color:#c4c9d4}.au-btn--negative.au-btn--disabled:hover,.au-btn--negative.au-btn--disabled:focus{background-color:#f6f7fa;border-color:transparent;color:#c4c9d4}.au-btn--negative.au-btn--disabled:hover .au-icon,.au-btn--negative.au-btn--disabled:hover .au-icon>svg,.au-btn--negative.au-btn--disabled:focus .au-icon,.au-btn--negative.au-btn--disabled:focus .au-icon>svg{color:#c4c9d4}.au-btn--negative.au-btn--loading{background-color:#fff;border-color:transparent;color:#0048db}.au-btn--negative.au-btn--loading .au-icon,.au-btn--negative.au-btn--loading .au-icon>svg,.au-btn--negative.au-btn--loading .au-icon svg{color:#0048db}.au-btn--negative.au-btn--loading:hover,.au-btn--negative.au-btn--loading:focus{background-color:#fff;color:#0048db}.au-btn--round-large .au-icon,.au-btn--round-large .au-icon>svg,.au-btn--round-medium .au-icon,.au-btn--round-medium .au-icon>svg{width:24px;height:24px}.au-btn--round-large{padding:12px;height:48px;min-height:48px;width:48px}.au-btn--round-medium{padding:10px;height:40px;min-height:40px;width:40px}@keyframes spin{to{transform:rotate(360deg)}}.btn-text{background-color:transparent;border:none;display:flex;color:#0048db;font-weight:600}.btn-text .au-icon svg{color:#0048db}.btn-text:hover,.btn-text:focus{background-color:transparent}
|
|
@@ -87,7 +87,6 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
87
87
|
page: pageRef.current,
|
|
88
88
|
moved: false
|
|
89
89
|
};
|
|
90
|
-
rail.setPointerCapture(event.pointerId);
|
|
91
90
|
}
|
|
92
91
|
function onPointerMove(event) {
|
|
93
92
|
if (!drag) return;
|
|
@@ -95,6 +94,7 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
95
94
|
if (!drag.moved) {
|
|
96
95
|
if (Math.abs(delta) < DRAG_THRESHOLD) return;
|
|
97
96
|
drag.moved = true;
|
|
97
|
+
rail.setPointerCapture(event.pointerId);
|
|
98
98
|
rail.classList.add(DRAGGING_CLASS);
|
|
99
99
|
}
|
|
100
100
|
rail.scrollLeft = drag.scrollLeft - delta;
|
|
@@ -103,10 +103,10 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
103
103
|
if (!drag) return;
|
|
104
104
|
const { moved, page: from, startX } = drag;
|
|
105
105
|
drag = null;
|
|
106
|
+
if (!moved) return;
|
|
106
107
|
if (rail.hasPointerCapture(event.pointerId)) {
|
|
107
108
|
rail.releasePointerCapture(event.pointerId);
|
|
108
109
|
}
|
|
109
|
-
if (!moved) return;
|
|
110
110
|
rail.classList.remove(DRAGGING_CLASS);
|
|
111
111
|
const direction = event.clientX < startX ? 1 : -1;
|
|
112
112
|
const nearest = getActivePage(rail, startsRef.current);
|
|
@@ -114,6 +114,9 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
114
114
|
rail.addEventListener("click", suppressClick, { capture: true, once: true });
|
|
115
115
|
setTimeout(() => rail.removeEventListener("click", suppressClick, { capture: true }));
|
|
116
116
|
}
|
|
117
|
+
function onPointerLeave() {
|
|
118
|
+
if (drag && !drag.moved) drag = null;
|
|
119
|
+
}
|
|
117
120
|
const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : void 0;
|
|
118
121
|
function observeSlides() {
|
|
119
122
|
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
@@ -132,6 +135,7 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
132
135
|
rail.addEventListener("pointermove", onPointerMove);
|
|
133
136
|
rail.addEventListener("pointerup", onPointerUp);
|
|
134
137
|
rail.addEventListener("pointercancel", onPointerUp);
|
|
138
|
+
rail.addEventListener("pointerleave", onPointerLeave);
|
|
135
139
|
return () => {
|
|
136
140
|
cancelAnimationFrame(frame);
|
|
137
141
|
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
@@ -141,6 +145,7 @@ function useCarousel({ draggable, onPageChange }) {
|
|
|
141
145
|
rail.removeEventListener("pointermove", onPointerMove);
|
|
142
146
|
rail.removeEventListener("pointerup", onPointerUp);
|
|
143
147
|
rail.removeEventListener("pointercancel", onPointerUp);
|
|
148
|
+
rail.removeEventListener("pointerleave", onPointerLeave);
|
|
144
149
|
};
|
|
145
150
|
}, [goTo]);
|
|
146
151
|
return { railRef, page, pageCount, goTo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/Carousel/Root/hooks.ts","../../../../lib/components/Carousel/Root/index.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\n/** Pointer travel, in px, before a mouse press becomes a drag (a click below it still reaches the slide). */\nconst DRAG_THRESHOLD = 5\nconst DRAGGING_CLASS = 'au-carousel__rail--dragging'\n\n/**\n * Groups the slides into pages. A page starts at a slide and holds every\n * following slide that still fits, whole, in the rail's visible width.\n * Returns the scroll position of each page (the `offsetLeft` of its first\n * slide, which is also where CSS snaps). The rail is `position: relative`,\n * so `offsetLeft` is measured from the rail itself.\n */\nexport function getPageStarts(rail: HTMLElement): number[] {\n const slides = Array.from(rail.children) as HTMLElement[]\n const viewport = rail.clientWidth\n const starts: number[] = []\n let index = 0\n\n while (index < slides.length) {\n const start = slides[index].offsetLeft\n starts.push(start)\n let next = index + 1\n while (\n next < slides.length &&\n slides[next].offsetLeft + slides[next].offsetWidth <= start + viewport + 1\n ) {\n next += 1\n }\n index = next\n }\n\n return starts\n}\n\n/**\n * The page the rail is scrolled to: the one whose start is nearest to\n * `scrollLeft`, or the last page once the rail cannot scroll any further\n * (its start may lie past the maximum scroll, where the browser clamps it).\n */\nexport function getActivePage(rail: HTMLElement, starts: number[]): number {\n if (starts.length === 0) return 0\n\n const { scrollLeft } = rail\n const maxScroll = rail.scrollWidth - rail.clientWidth\n if (scrollLeft >= maxScroll - 1) return starts.length - 1\n\n let nearest = 0\n starts.forEach((start, index) => {\n if (Math.abs(start - scrollLeft) < Math.abs(starts[nearest] - scrollLeft)) {\n nearest = index\n }\n })\n return nearest\n}\n\ntype UseCarouselArgs = {\n draggable: boolean\n onPageChange?: (page: number, pageCount: number) => void\n}\n\n/**\n * Measures the rail, follows its scroll position and exposes `goTo`. Pages\n * are re-measured when the rail or a slide changes size (ResizeObserver) and\n * when slides are added, removed or replaced (MutationObserver), so a\n * skeleton turning into a card or a tab swapping the list keeps the\n * navigation right. Mouse drag follows the pointer with snapping off and\n * settles on a page on release; touch scrolls natively.\n */\nexport function useCarousel({ draggable, onPageChange }: UseCarouselArgs) {\n const railRef = useRef<HTMLDivElement>(null)\n const startsRef = useRef<number[]>([])\n const pageRef = useRef(0)\n const draggableRef = useRef(draggable)\n const onPageChangeRef = useRef(onPageChange)\n const [page, setPage] = useState(0)\n const [pageCount, setPageCount] = useState(0)\n\n draggableRef.current = draggable\n onPageChangeRef.current = onPageChange\n\n const goTo = useCallback((target: number) => {\n const rail = railRef.current\n const starts = startsRef.current\n if (!rail || target < 0 || target >= starts.length) return\n rail.scrollTo({ left: starts[target] })\n }, [])\n\n useEffect(() => {\n const rail = railRef.current\n if (!rail) return\n\n function setActive(next: number) {\n if (next === pageRef.current) return\n pageRef.current = next\n setPage(next)\n onPageChangeRef.current?.(next + 1, startsRef.current.length)\n }\n\n function measure() {\n startsRef.current = getPageStarts(rail!)\n setPageCount(startsRef.current.length)\n setActive(getActivePage(rail!, startsRef.current))\n }\n\n let frame = 0\n function onScroll() {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(() => {\n setActive(getActivePage(rail!, startsRef.current))\n })\n }\n\n let drag: { startX: number; scrollLeft: number; page: number; moved: boolean } | null = null\n\n function suppressClick(event: Event) {\n event.stopPropagation()\n event.preventDefault()\n }\n\n function onPointerDown(event: PointerEvent) {\n if (!draggableRef.current || event.pointerType !== 'mouse' || event.button !== 0) return\n drag = {\n startX: event.clientX,\n scrollLeft: rail!.scrollLeft,\n page: pageRef.current,\n moved: false,\n }\n rail!.setPointerCapture(event.pointerId)\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!drag) return\n const delta = event.clientX - drag.startX\n if (!drag.moved) {\n if (Math.abs(delta) < DRAG_THRESHOLD) return\n drag.moved = true\n rail!.classList.add(DRAGGING_CLASS)\n }\n rail!.scrollLeft = drag.scrollLeft - delta\n }\n\n function onPointerUp(event: PointerEvent) {\n if (!drag) return\n const { moved, page: from, startX } = drag\n drag = null\n if (rail!.hasPointerCapture(event.pointerId)) {\n rail!.releasePointerCapture(event.pointerId)\n }\n if (!moved) return\n\n rail!.classList.remove(DRAGGING_CLASS)\n const direction = event.clientX < startX ? 1 : -1\n const nearest = getActivePage(rail!, startsRef.current)\n goTo(nearest === from ? from + direction : nearest)\n\n // The click that ends a drag must not reach the slide. It fires in the\n // same task as `pointerup`, so the listener is gone by the next one.\n rail!.addEventListener('click', suppressClick, { capture: true, once: true })\n setTimeout(() => rail!.removeEventListener('click', suppressClick, { capture: true }))\n }\n\n const resizeObserver =\n typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : undefined\n\n function observeSlides() {\n resizeObserver?.disconnect()\n resizeObserver?.observe(rail!)\n Array.from(rail!.children).forEach((slide) => resizeObserver?.observe(slide))\n }\n\n const mutationObserver = new MutationObserver(() => {\n observeSlides()\n measure()\n })\n\n measure()\n observeSlides()\n mutationObserver.observe(rail, { childList: true })\n rail.addEventListener('scroll', onScroll, { passive: true })\n rail.addEventListener('pointerdown', onPointerDown)\n rail.addEventListener('pointermove', onPointerMove)\n rail.addEventListener('pointerup', onPointerUp)\n rail.addEventListener('pointercancel', onPointerUp)\n\n return () => {\n cancelAnimationFrame(frame)\n resizeObserver?.disconnect()\n mutationObserver.disconnect()\n rail.removeEventListener('scroll', onScroll)\n rail.removeEventListener('pointerdown', onPointerDown)\n rail.removeEventListener('pointermove', onPointerMove)\n rail.removeEventListener('pointerup', onPointerUp)\n rail.removeEventListener('pointercancel', onPointerUp)\n }\n }, [goTo])\n\n return { railRef, page, pageCount, goTo }\n}\n","import classNames from 'classnames'\nimport { CSSProperties, ReactNode } from 'react'\nimport { Button } from '@components/Button'\nimport { IconChevronLeft, IconChevronRight } from '@components/icons'\nimport { useCarousel } from './hooks'\n\nexport type CarouselNavigation = 'text' | 'pin' | 'only-pin'\n\nexport type CarouselItemsPerView = number | { mobile?: number; desktop?: number }\n\nexport type CarouselRootProps = {\n children: ReactNode\n navigation?: CarouselNavigation\n negative?: boolean\n pageLabel?: string\n label?: string\n gap?: number\n itemsPerView?: CarouselItemsPerView\n draggable?: boolean\n onPageChange?: (page: number, pageCount: number) => void\n className?: string\n 'data-testid'?: string\n}\n\nconst DEFAULT_GAP = 16\n\nfunction _itemsPerViewStyle(itemsPerView?: CarouselItemsPerView): CSSProperties {\n if (itemsPerView === undefined) return {}\n const { mobile, desktop } =\n typeof itemsPerView === 'number' ? { mobile: itemsPerView, desktop: undefined } : itemsPerView\n return {\n ...(mobile !== undefined && { '--au-carousel-items': mobile }),\n ...(desktop !== undefined && { '--au-carousel-items-desktop': desktop }),\n } as CSSProperties\n}\n\nexport const CarouselRoot = ({\n children,\n navigation = 'text',\n negative = false,\n pageLabel = 'Página',\n label = 'Carrossel',\n gap = DEFAULT_GAP,\n itemsPerView,\n draggable = true,\n onPageChange,\n className,\n 'data-testid': dataTestId,\n}: CarouselRootProps) => {\n const { railRef, page, pageCount, goTo } = useCarousel({ draggable, onPageChange })\n\n const hasArrows = navigation !== 'only-pin'\n const hasPins = navigation !== 'text'\n const total = Math.max(pageCount, 1)\n const status = [pageLabel.trim(), `${page + 1} de ${total}`].filter(Boolean).join(' ')\n const pinLabel = pageLabel.trim() || 'Página'\n\n const classes = classNames('au-carousel', `au-carousel--navigation-${navigation}`, {\n 'au-carousel--negative': negative,\n 'au-carousel--draggable': draggable,\n 'au-carousel--items-per-view': itemsPerView !== undefined,\n [String(className)]: !!className,\n })\n\n const style = {\n '--au-carousel-gap': `${gap}px`,\n ..._itemsPerViewStyle(itemsPerView),\n } as CSSProperties\n\n return (\n <div\n className={classes}\n role=\"region\"\n aria-roledescription=\"carrossel\"\n aria-label={label}\n style={style}\n data-testid={dataTestId}>\n <div className=\"au-carousel__rail\" ref={railRef}>\n {children}\n </div>\n\n <div className=\"au-carousel__nav\" hidden={pageCount <= 1}>\n {hasArrows && (\n <Button\n className=\"au-carousel__arrow au-carousel__arrow--previous\"\n type=\"outlined\"\n round\n negative={negative}\n disabled={page === 0}\n aria-label=\"Anterior\"\n onClick={() => goTo(page - 1)}>\n <IconChevronLeft />\n </Button>\n )}\n\n <span\n className={classNames('au-carousel__status', {\n 'au-carousel__status--hidden': hasPins,\n })}\n aria-live=\"polite\"\n aria-atomic=\"true\">\n {status}\n </span>\n\n {hasPins && (\n <div className=\"au-carousel__pins\">\n {Array.from({ length: total }, (_, index) => (\n <button\n key={index}\n type=\"button\"\n className={classNames('au-carousel__pin', {\n 'au-carousel__pin--active': index === page,\n })}\n aria-label={`${pinLabel} ${index + 1}`}\n aria-current={index === page ? 'true' : undefined}\n onClick={() => goTo(index)}\n />\n ))}\n </div>\n )}\n\n {hasArrows && (\n <Button\n className=\"au-carousel__arrow au-carousel__arrow--next\"\n type=\"outlined\"\n round\n negative={negative}\n disabled={page >= total - 1}\n aria-label=\"Próximo\"\n onClick={() => goTo(page + 1)}>\n <IconChevronRight />\n </Button>\n )}\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;AAGA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAShB,SAAS,cAAc,MAA6B;AACzD,QAAM,SAAS,MAAM,KAAK,KAAK,QAAQ;AACvC,QAAM,WAAW,KAAK;AACtB,QAAM,SAAmB,CAAA;AACzB,MAAI,QAAQ;AAEZ,SAAO,QAAQ,OAAO,QAAQ;AAC5B,UAAM,QAAQ,OAAO,KAAK,EAAE;AAC5B,WAAO,KAAK,KAAK;AACjB,QAAI,OAAO,QAAQ;AACnB,WACE,OAAO,OAAO,UACd,OAAO,IAAI,EAAE,aAAa,OAAO,IAAI,EAAE,eAAe,QAAQ,WAAW,GACzE;AACA,cAAQ;AAAA,IACV;AACA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAOO,SAAS,cAAc,MAAmB,QAA0B;AACzE,MAAI,OAAO,WAAW,EAAG,QAAO;AAEhC,QAAM,EAAE,eAAe;AACvB,QAAM,YAAY,KAAK,cAAc,KAAK;AAC1C,MAAI,cAAc,YAAY,EAAG,QAAO,OAAO,SAAS;AAExD,MAAI,UAAU;AACd,SAAO,QAAQ,CAAC,OAAO,UAAU;AAC/B,QAAI,KAAK,IAAI,QAAQ,UAAU,IAAI,KAAK,IAAI,OAAO,OAAO,IAAI,UAAU,GAAG;AACzE,gBAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAeO,SAAS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GF,WACC,oBAAC,OAAA,EAAI,WAAU,qBACZ,UAAA,MAAM,KAAK,EAAE,QAAQ,MAAA,GAAS,CAAC,GAAG,UACjC;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,MAAK;AAAA,cACL,WAAW,WAAW,oBAAoB;AAAA,gBACxC,4BAA4B,UAAU;AAAA,cAAA,CACvC;AAAA,cACD,cAAY,GAAG,QAAQ,IAAI,QAAQ,CAAC;AAAA,cACpC,gBAAc,UAAU,OAAO,SAAS;AAAA,cACxC,SAAS,MAAM,KAAK,KAAK;AAAA,YAAA;AAAA,YAPpB;AAAA,UAAA,CASR,GACH;AAAA,UAGD,aACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,MAAK;AAAA,cACL,OAAK;AAAA,cACL;AAAA,cACA,UAAU,QAAQ,QAAQ;AAAA,cAC1B,cAAW;AAAA,cACX,SAAS,MAAM,KAAK,OAAO,CAAC;AAAA,cAC5B,8BAAC,kBAAA,CAAA,CAAiB;AAAA,YAAA;AAAA,UAAA;AAAA,QACpB,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../lib/components/Carousel/Root/hooks.ts","../../../../lib/components/Carousel/Root/index.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\n/** Pointer travel, in px, before a mouse press becomes a drag (a click below it still reaches the slide). */\nconst DRAG_THRESHOLD = 5\nconst DRAGGING_CLASS = 'au-carousel__rail--dragging'\n\n/**\n * Groups the slides into pages. A page starts at a slide and holds every\n * following slide that still fits, whole, in the rail's visible width.\n * Returns the scroll position of each page (the `offsetLeft` of its first\n * slide, which is also where CSS snaps). The rail is `position: relative`,\n * so `offsetLeft` is measured from the rail itself.\n */\nexport function getPageStarts(rail: HTMLElement): number[] {\n const slides = Array.from(rail.children) as HTMLElement[]\n const viewport = rail.clientWidth\n const starts: number[] = []\n let index = 0\n\n while (index < slides.length) {\n const start = slides[index].offsetLeft\n starts.push(start)\n let next = index + 1\n while (\n next < slides.length &&\n slides[next].offsetLeft + slides[next].offsetWidth <= start + viewport + 1\n ) {\n next += 1\n }\n index = next\n }\n\n return starts\n}\n\n/**\n * The page the rail is scrolled to: the one whose start is nearest to\n * `scrollLeft`, or the last page once the rail cannot scroll any further\n * (its start may lie past the maximum scroll, where the browser clamps it).\n */\nexport function getActivePage(rail: HTMLElement, starts: number[]): number {\n if (starts.length === 0) return 0\n\n const { scrollLeft } = rail\n const maxScroll = rail.scrollWidth - rail.clientWidth\n if (scrollLeft >= maxScroll - 1) return starts.length - 1\n\n let nearest = 0\n starts.forEach((start, index) => {\n if (Math.abs(start - scrollLeft) < Math.abs(starts[nearest] - scrollLeft)) {\n nearest = index\n }\n })\n return nearest\n}\n\ntype UseCarouselArgs = {\n draggable: boolean\n onPageChange?: (page: number, pageCount: number) => void\n}\n\n/**\n * Measures the rail, follows its scroll position and exposes `goTo`. Pages\n * are re-measured when the rail or a slide changes size (ResizeObserver) and\n * when slides are added, removed or replaced (MutationObserver), so a\n * skeleton turning into a card or a tab swapping the list keeps the\n * navigation right. Mouse drag follows the pointer with snapping off and\n * settles on a page on release; touch scrolls natively.\n */\nexport function useCarousel({ draggable, onPageChange }: UseCarouselArgs) {\n const railRef = useRef<HTMLDivElement>(null)\n const startsRef = useRef<number[]>([])\n const pageRef = useRef(0)\n const draggableRef = useRef(draggable)\n const onPageChangeRef = useRef(onPageChange)\n const [page, setPage] = useState(0)\n const [pageCount, setPageCount] = useState(0)\n\n draggableRef.current = draggable\n onPageChangeRef.current = onPageChange\n\n const goTo = useCallback((target: number) => {\n const rail = railRef.current\n const starts = startsRef.current\n if (!rail || target < 0 || target >= starts.length) return\n rail.scrollTo({ left: starts[target] })\n }, [])\n\n useEffect(() => {\n const rail = railRef.current\n if (!rail) return\n\n function setActive(next: number) {\n if (next === pageRef.current) return\n pageRef.current = next\n setPage(next)\n onPageChangeRef.current?.(next + 1, startsRef.current.length)\n }\n\n function measure() {\n startsRef.current = getPageStarts(rail!)\n setPageCount(startsRef.current.length)\n setActive(getActivePage(rail!, startsRef.current))\n }\n\n let frame = 0\n function onScroll() {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(() => {\n setActive(getActivePage(rail!, startsRef.current))\n })\n }\n\n let drag: { startX: number; scrollLeft: number; page: number; moved: boolean } | null = null\n\n function suppressClick(event: Event) {\n event.stopPropagation()\n event.preventDefault()\n }\n\n function onPointerDown(event: PointerEvent) {\n if (!draggableRef.current || event.pointerType !== 'mouse' || event.button !== 0) return\n drag = {\n startX: event.clientX,\n scrollLeft: rail!.scrollLeft,\n page: pageRef.current,\n moved: false,\n }\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!drag) return\n const delta = event.clientX - drag.startX\n if (!drag.moved) {\n if (Math.abs(delta) < DRAG_THRESHOLD) return\n drag.moved = true\n // Capturing on press would retarget the click to the rail, away from the slide's own button.\n rail!.setPointerCapture(event.pointerId)\n rail!.classList.add(DRAGGING_CLASS)\n }\n rail!.scrollLeft = drag.scrollLeft - delta\n }\n\n function onPointerUp(event: PointerEvent) {\n if (!drag) return\n const { moved, page: from, startX } = drag\n drag = null\n if (!moved) return\n\n if (rail!.hasPointerCapture(event.pointerId)) {\n rail!.releasePointerCapture(event.pointerId)\n }\n rail!.classList.remove(DRAGGING_CLASS)\n const direction = event.clientX < startX ? 1 : -1\n const nearest = getActivePage(rail!, startsRef.current)\n goTo(nearest === from ? from + direction : nearest)\n\n // The click that ends a drag must not reach the slide. It fires in the\n // same task as `pointerup`, so the listener is gone by the next one.\n rail!.addEventListener('click', suppressClick, { capture: true, once: true })\n setTimeout(() => rail!.removeEventListener('click', suppressClick, { capture: true }))\n }\n\n function onPointerLeave() {\n if (drag && !drag.moved) drag = null\n }\n\n const resizeObserver =\n typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : undefined\n\n function observeSlides() {\n resizeObserver?.disconnect()\n resizeObserver?.observe(rail!)\n Array.from(rail!.children).forEach((slide) => resizeObserver?.observe(slide))\n }\n\n const mutationObserver = new MutationObserver(() => {\n observeSlides()\n measure()\n })\n\n measure()\n observeSlides()\n mutationObserver.observe(rail, { childList: true })\n rail.addEventListener('scroll', onScroll, { passive: true })\n rail.addEventListener('pointerdown', onPointerDown)\n rail.addEventListener('pointermove', onPointerMove)\n rail.addEventListener('pointerup', onPointerUp)\n rail.addEventListener('pointercancel', onPointerUp)\n rail.addEventListener('pointerleave', onPointerLeave)\n\n return () => {\n cancelAnimationFrame(frame)\n resizeObserver?.disconnect()\n mutationObserver.disconnect()\n rail.removeEventListener('scroll', onScroll)\n rail.removeEventListener('pointerdown', onPointerDown)\n rail.removeEventListener('pointermove', onPointerMove)\n rail.removeEventListener('pointerup', onPointerUp)\n rail.removeEventListener('pointercancel', onPointerUp)\n rail.removeEventListener('pointerleave', onPointerLeave)\n }\n }, [goTo])\n\n return { railRef, page, pageCount, goTo }\n}\n","import classNames from 'classnames'\nimport { CSSProperties, ReactNode } from 'react'\nimport { Button } from '@components/Button'\nimport { IconChevronLeft, IconChevronRight } from '@components/icons'\nimport { useCarousel } from './hooks'\n\nexport type CarouselNavigation = 'text' | 'pin' | 'only-pin'\n\nexport type CarouselItemsPerView = number | { mobile?: number; desktop?: number }\n\nexport type CarouselRootProps = {\n children: ReactNode\n navigation?: CarouselNavigation\n negative?: boolean\n pageLabel?: string\n label?: string\n gap?: number\n itemsPerView?: CarouselItemsPerView\n draggable?: boolean\n onPageChange?: (page: number, pageCount: number) => void\n className?: string\n 'data-testid'?: string\n}\n\nconst DEFAULT_GAP = 16\n\nfunction _itemsPerViewStyle(itemsPerView?: CarouselItemsPerView): CSSProperties {\n if (itemsPerView === undefined) return {}\n const { mobile, desktop } =\n typeof itemsPerView === 'number' ? { mobile: itemsPerView, desktop: undefined } : itemsPerView\n return {\n ...(mobile !== undefined && { '--au-carousel-items': mobile }),\n ...(desktop !== undefined && { '--au-carousel-items-desktop': desktop }),\n } as CSSProperties\n}\n\nexport const CarouselRoot = ({\n children,\n navigation = 'text',\n negative = false,\n pageLabel = 'Página',\n label = 'Carrossel',\n gap = DEFAULT_GAP,\n itemsPerView,\n draggable = true,\n onPageChange,\n className,\n 'data-testid': dataTestId,\n}: CarouselRootProps) => {\n const { railRef, page, pageCount, goTo } = useCarousel({ draggable, onPageChange })\n\n const hasArrows = navigation !== 'only-pin'\n const hasPins = navigation !== 'text'\n const total = Math.max(pageCount, 1)\n const status = [pageLabel.trim(), `${page + 1} de ${total}`].filter(Boolean).join(' ')\n const pinLabel = pageLabel.trim() || 'Página'\n\n const classes = classNames('au-carousel', `au-carousel--navigation-${navigation}`, {\n 'au-carousel--negative': negative,\n 'au-carousel--draggable': draggable,\n 'au-carousel--items-per-view': itemsPerView !== undefined,\n [String(className)]: !!className,\n })\n\n const style = {\n '--au-carousel-gap': `${gap}px`,\n ..._itemsPerViewStyle(itemsPerView),\n } as CSSProperties\n\n return (\n <div\n className={classes}\n role=\"region\"\n aria-roledescription=\"carrossel\"\n aria-label={label}\n style={style}\n data-testid={dataTestId}>\n <div className=\"au-carousel__rail\" ref={railRef}>\n {children}\n </div>\n\n <div className=\"au-carousel__nav\" hidden={pageCount <= 1}>\n {hasArrows && (\n <Button\n className=\"au-carousel__arrow au-carousel__arrow--previous\"\n type=\"outlined\"\n round\n negative={negative}\n disabled={page === 0}\n aria-label=\"Anterior\"\n onClick={() => goTo(page - 1)}>\n <IconChevronLeft />\n </Button>\n )}\n\n <span\n className={classNames('au-carousel__status', {\n 'au-carousel__status--hidden': hasPins,\n })}\n aria-live=\"polite\"\n aria-atomic=\"true\">\n {status}\n </span>\n\n {hasPins && (\n <div className=\"au-carousel__pins\">\n {Array.from({ length: total }, (_, index) => (\n <button\n key={index}\n type=\"button\"\n className={classNames('au-carousel__pin', {\n 'au-carousel__pin--active': index === page,\n })}\n aria-label={`${pinLabel} ${index + 1}`}\n aria-current={index === page ? 'true' : undefined}\n onClick={() => goTo(index)}\n />\n ))}\n </div>\n )}\n\n {hasArrows && (\n <Button\n className=\"au-carousel__arrow au-carousel__arrow--next\"\n type=\"outlined\"\n round\n negative={negative}\n disabled={page >= total - 1}\n aria-label=\"Próximo\"\n onClick={() => goTo(page + 1)}>\n <IconChevronRight />\n </Button>\n )}\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;AAGA,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAShB,SAAS,cAAc,MAA6B;AACzD,QAAM,SAAS,MAAM,KAAK,KAAK,QAAQ;AACvC,QAAM,WAAW,KAAK;AACtB,QAAM,SAAmB,CAAA;AACzB,MAAI,QAAQ;AAEZ,SAAO,QAAQ,OAAO,QAAQ;AAC5B,UAAM,QAAQ,OAAO,KAAK,EAAE;AAC5B,WAAO,KAAK,KAAK;AACjB,QAAI,OAAO,QAAQ;AACnB,WACE,OAAO,OAAO,UACd,OAAO,IAAI,EAAE,aAAa,OAAO,IAAI,EAAE,eAAe,QAAQ,WAAW,GACzE;AACA,cAAQ;AAAA,IACV;AACA,YAAQ;AAAA,EACV;AAEA,SAAO;AACT;AAOO,SAAS,cAAc,MAAmB,QAA0B;AACzE,MAAI,OAAO,WAAW,EAAG,QAAO;AAEhC,QAAM,EAAE,eAAe;AACvB,QAAM,YAAY,KAAK,cAAc,KAAK;AAC1C,MAAI,cAAc,YAAY,EAAG,QAAO,OAAO,SAAS;AAExD,MAAI,UAAU;AACd,SAAO,QAAQ,CAAC,OAAO,UAAU;AAC/B,QAAI,KAAK,IAAI,QAAQ,UAAU,IAAI,KAAK,IAAI,OAAO,OAAO,IAAI,UAAU,GAAG;AACzE,gBAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAeO,SAAS,YAAY,EAAE,WAAW,gBAAiC;AACxE,QAAM,UAAU,OAAuB,IAAI;AAC3C,QAAM,YAAY,OAAiB,EAAE;AACrC,QAAM,UAAU,OAAO,CAAC;AACxB,QAAM,eAAe,OAAO,SAAS;AACrC,QAAM,kBAA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A,EAAI,WAAU,qBACZ,UAAA,MAAM,KAAK,EAAE,QAAQ,MAAA,GAAS,CAAC,GAAG,UACjC;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,MAAK;AAAA,cACL,WAAW,WAAW,oBAAoB;AAAA,gBACxC,4BAA4B,UAAU;AAAA,cAAA,CACvC;AAAA,cACD,cAAY,GAAG,QAAQ,IAAI,QAAQ,CAAC;AAAA,cACpC,gBAAc,UAAU,OAAO,SAAS;AAAA,cACxC,SAAS,MAAM,KAAK,KAAK;AAAA,YAAA;AAAA,YAPpB;AAAA,UAAA,CASR,GACH;AAAA,UAGD,aACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,MAAK;AAAA,cACL,OAAK;AAAA,cACL;AAAA,cACA,UAAU,QAAQ,QAAQ;AAAA,cAC1B,cAAW;AAAA,cACX,SAAS,MAAM,KAAK,OAAO,CAAC;AAAA,cAC5B,8BAAC,kBAAA,CAAA,CAAiB;AAAA,YAAA;AAAA,UAAA;AAAA,QACpB,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-carousel{--au-carousel-gap: 16px;position:relative}.au-carousel__rail{position:relative;display:flex;gap:var(--au-carousel-gap);overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scrollbar-width:none}.au-carousel__rail::-webkit-scrollbar{display:none}@media(prefers-reduced-motion:no-preference){.au-carousel__rail{scroll-behavior:smooth}}.au-carousel__rail--dragging{scroll-snap-type:none;scroll-behavior:auto;cursor:grabbing;-webkit-user-select:none;user-select:none}.au-carousel--draggable .au-carousel__rail{cursor:grab}.au-carousel__item{flex:0 0 auto;min-width:0;scroll-snap-align:start}.au-carousel--items-per-view .au-carousel__item{flex-basis:calc((100% - var(--au-carousel-gap) * (var(--au-carousel-items) - 1)) / var(--au-carousel-items))}@media(min-width:600px){.au-carousel--items-per-view .au-carousel__item{flex-basis:calc((100% - var(--au-carousel-gap) * (var(--au-carousel-items-desktop, var(--au-carousel-items)) - 1)) / var(--au-carousel-items-desktop, var(--au-carousel-items)))}}.au-carousel__nav{display:flex;align-items:center;justify-content:space-between;gap:16px;
|
|
1
|
+
.au-carousel{--au-carousel-gap: 16px;position:relative}.au-carousel__rail{position:relative;display:flex;gap:var(--au-carousel-gap);overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scrollbar-width:none}.au-carousel__rail::-webkit-scrollbar{display:none}@media(prefers-reduced-motion:no-preference){.au-carousel__rail{scroll-behavior:smooth}}.au-carousel__rail--dragging{scroll-snap-type:none;scroll-behavior:auto;cursor:grabbing;-webkit-user-select:none;user-select:none}.au-carousel--draggable .au-carousel__rail{cursor:grab}.au-carousel__item{flex:0 0 auto;min-width:0;scroll-snap-align:start}.au-carousel--items-per-view .au-carousel__item{flex-basis:calc((100% - var(--au-carousel-gap) * (var(--au-carousel-items) - 1)) / var(--au-carousel-items))}@media(min-width:600px){.au-carousel--items-per-view .au-carousel__item{flex-basis:calc((100% - var(--au-carousel-gap) * (var(--au-carousel-items-desktop, var(--au-carousel-items)) - 1)) / var(--au-carousel-items-desktop, var(--au-carousel-items)))}}.au-carousel__nav{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:24px}.au-carousel__nav[hidden]{display:none}.au-carousel--navigation-only-pin .au-carousel__nav{justify-content:center}@media(min-width:600px){.au-carousel--navigation-text .au-carousel__nav,.au-carousel--navigation-pin .au-carousel__nav{margin-top:32px}}@media(min-width:600px){.au-carousel--navigation-text .au-carousel__status,.au-carousel--navigation-pin .au-carousel__pins{order:-1;margin-right:auto}}.au-carousel__arrow{flex:none}.au-carousel__status{font-family:"Source Sans 3",sans-serif;font-size:16px;font-weight:400;line-height:24px;color:#454a54;text-align:center}.au-carousel__status--hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.au-carousel--negative .au-carousel__status{color:#fff}.au-carousel__pins{display:flex;align-items:center;gap:8px}.au-carousel__pin{position:relative;width:8px;height:8px;padding:0;border:0;border-radius:999px;background-color:#e2e4e9;cursor:pointer;transition:width .2s ease,background-color .2s ease}.au-carousel__pin:before{content:"";position:absolute;top:-8px;right:-8px;bottom:-8px;left:-8px}.au-carousel__pin:focus-visible{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0048db}.au-carousel__pin--active{width:38px;background-color:#16181d}.au-carousel--negative .au-carousel__pin{background-color:#fff6}.au-carousel--negative .au-carousel__pin--active{background-color:#fff}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.au-password-field__container{
|
|
1
|
+
.au-password-field__container{display:flex;align-items:stretch;min-height:56px;background-color:#fff;border:1px solid #454a54;border-radius:8px}.au-password-field__container:hover{border-color:#16181d}.au-password-field__container:has(.au-password-field__input:focus){border-color:#0048db;outline:1px solid #0048db}.au-password-field__container .au-password-field__input.au-field__input{flex:1;min-width:0;height:auto;padding:15px 8px 15px 15px;background-color:transparent;border:0;outline:0;animation:none}.au-password-field__btn{flex-shrink:0;background-color:transparent;border:none;color:#0048db;cursor:pointer;font-family:"Source Sans 3",sans-serif;font-size:14px;font-weight:600;text-transform:uppercase;padding:0 15px 0 8px}.au-password-field__btn:disabled{cursor:not-allowed}.au-field--disabled .au-password-field__container{background-color:#e2e4e9;border-color:#5e6573}.au-field--error .au-password-field__container{background-color:#f5eff0;border-color:#991717}.au-field--error .au-password-field__container:has(.au-password-field__input:focus){border-color:#0048db}.au-field--success .au-password-field__container{animation:inputSuccess 2s forwards}
|