@slurp-ui/react 1.0.1 → 1.1.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/CHANGELOG.md +25 -0
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/Card.js.map +1 -1
- package/dist/Carousel/Carousel.d.ts +36 -0
- package/dist/Carousel/Carousel.js +179 -0
- package/dist/Carousel/Carousel.js.map +1 -0
- package/dist/Carousel/index.d.ts +3 -0
- package/dist/Carousel/index.js +2 -0
- package/dist/Dock/Dock.d.ts +1 -1
- package/dist/Dock/Dock.js.map +1 -1
- package/dist/ListRow/ListRow.d.ts +1 -1
- package/dist/ListRow/ListRow.js.map +1 -1
- package/dist/Pages/Pages.d.ts +45 -0
- package/dist/Pages/Pages.js +128 -0
- package/dist/Pages/Pages.js.map +1 -0
- package/dist/Pages/index.d.ts +3 -0
- package/dist/Pages/index.js +2 -0
- package/dist/Range/Range.d.ts +1 -1
- package/dist/Range/Range.js.map +1 -1
- package/dist/Rating/Rating.d.ts +36 -0
- package/dist/Rating/Rating.js +118 -0
- package/dist/Rating/Rating.js.map +1 -0
- package/dist/Rating/index.d.ts +3 -0
- package/dist/Rating/index.js +2 -0
- package/dist/Search/Search.d.ts +1 -1
- package/dist/Search/Search.js.map +1 -1
- package/dist/Steps/Steps.d.ts +41 -0
- package/dist/Steps/Steps.js +89 -0
- package/dist/Steps/Steps.js.map +1 -0
- package/dist/Steps/index.d.ts +3 -0
- package/dist/Steps/index.js +2 -0
- package/dist/Suggest/Suggest.d.ts +54 -0
- package/dist/Suggest/Suggest.js +257 -0
- package/dist/Suggest/Suggest.js.map +1 -0
- package/dist/Suggest/index.d.ts +3 -0
- package/dist/Suggest/index.js +2 -0
- package/dist/Table/Table.d.ts +52 -0
- package/dist/Table/Table.js +127 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/index.d.ts +3 -0
- package/dist/Table/index.js +2 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +7 -1
- package/dist/lib/theme.d.ts +30 -0
- package/dist/lib/theme.js.map +1 -1
- package/dist/styles.css +968 -65
- package/dist/tokens.css +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @slurp-ui/react
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 75167a1: Use context-neutral examples in the props documentation (no prices or product names).
|
|
8
|
+
- 239f077: Fix motion on touch screens and on narrow Docks:
|
|
9
|
+
|
|
10
|
+
- Button, Chip, Tile, Card and Rating lift, grow or tilt on hover only with a fine pointer (`(hover: hover) and (pointer: fine)`), so they no longer stay raised after a tap. Colour changes on hover are unchanged.
|
|
11
|
+
- Button, Tile and Card press in 120ms and release more softly (240ms for Button and Chip, 300ms for Tile and Card) instead of using one slow transition both ways.
|
|
12
|
+
- On phones, Dock crumbs before the current one shrink first (to a 44px target), so the current page keeps its name instead of collapsing to a letter.
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [f3d9909]
|
|
15
|
+
- @slurp-ui/tokens@1.1.0
|
|
16
|
+
|
|
17
|
+
## 1.1.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 1bdb695: Add the extended components: `Suggest` (text field with suggestions, the field grows into the list), `Pages` (pagination, buttons or links), `Steps` (the steps of a flow of choices), `Rating` (stars, as an input or read-only), `Table` (sortable data table) and `Carousel` (media carousel on a scroll-snap track).
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [9e6f907]
|
|
26
|
+
- @slurp-ui/icons@1.1.0
|
|
27
|
+
|
|
3
28
|
## 1.0.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/Card/Card.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ElementType, ReactNode } from "react";
|
|
|
4
4
|
export interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {
|
|
5
5
|
title: ReactNode;
|
|
6
6
|
description?: ReactNode;
|
|
7
|
-
/** A value shown strong in the description pill ("1
|
|
7
|
+
/** A value shown strong in the description pill ("9.1", "24"). */
|
|
8
8
|
value?: ReactNode;
|
|
9
9
|
/** Before the value ("da"). */
|
|
10
10
|
valuePrefix?: ReactNode;
|
package/dist/Card/Card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","names":[],"sources":["../../src/Card/Card.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport { onColor } from '../lib/color';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {\n title: ReactNode;\n description?: ReactNode;\n /** A value shown strong in the description pill (\"1
|
|
1
|
+
{"version":3,"file":"Card.js","names":[],"sources":["../../src/Card/Card.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { CSSProperties, ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport { onColor } from '../lib/color';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nexport interface CardOwnProps extends PartsProps<'media' | 'badge' | 'title' | 'description'> {\n title: ReactNode;\n description?: ReactNode;\n /** A value shown strong in the description pill (\"9.1\", \"24\"). */\n value?: ReactNode;\n /** Before the value (\"da\"). */\n valuePrefix?: ReactNode;\n /** Pill at the top right (\"−15%\"). */\n badge?: ReactNode;\n /** Tint (any hex); default the accent. */\n color?: string;\n /** The media in the middle (illustration, photo), decorative. */\n media?: ReactNode;\n /** Renders a link. */\n href?: string;\n}\n\nexport type CardProps<E extends ElementType = 'a'> = PolymorphicProps<E, CardOwnProps>;\n\n/**\n * One tinted rounded surface (like a Tile): the media in the middle, the title and description pills inside at the\n * bottom left, never covering it. A link with `href`, a button with `onClick`.\n */\nexport function Card<E extends ElementType = 'a'>(props: CardProps<E>) {\n const {\n as,\n css,\n className,\n title,\n description,\n value,\n valuePrefix,\n badge,\n color,\n media,\n href,\n style,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Card', props as CardProps);\n const Root = (as ?? (href ? 'a' : rest.onClick ? 'button' : 'div')) as ElementType;\n const styled = useCss('Card', 'root', css);\n const { part, style: partsStyle } = useParts('Card', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const vars = {\n ...(color\n ? {\n '--slurp-card-color': color,\n '--slurp-card-on': /^#[0-9a-f]{6}$/i.test(color) ? onColor(color) : 'var(--slurp-fg)',\n '--slurp-animation-tint': color,\n }\n : null),\n ...style,\n } as CSSProperties;\n return (\n <>\n {styled.style}\n {partsStyle}\n <Root\n className={cx('slurp-card', styled.className, className)}\n href={href}\n style={vars}\n {...(Root === 'button' ? { type: 'button' } : null)}\n {...root}\n >\n {part('media', 'span', {\n className: 'slurp-card-media',\n 'aria-hidden': true,\n children: (\n <>\n <span className=\"slurp-stage-glow\" />\n <span className=\"slurp-stage-ring\" />\n {media != null && <span className=\"slurp-card-art\">{media}</span>}\n </>\n ),\n })}\n {badge != null && part('badge', 'span', { className: 'slurp-card-badge', children: badge })}\n {part('title', 'span', { className: 'slurp-card-title', children: title })}\n {(description != null || value != null) &&\n part('description', 'span', {\n className: 'slurp-card-description',\n children: (\n <>\n {description != null && <span>{description}</span>}\n {value != null && (\n <strong>\n {valuePrefix != null && <>{valuePrefix} </>}\n {value}\n </strong>\n )}\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,KAAkC,OAAqB;CACrE,MAAM,EACJ,IACA,KACA,WACA,OACA,aACA,OACA,aACA,OACA,OACA,OACA,MACA,OACA,OACA,WAC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,UAAA,EAAA,UAAA,CAAG,aAAY,GAAG,EAAA,CAAA,GACzC,KACK,EAAA,CAAA,CAEV,EAAA,CAAA;IAEN,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface CarouselLabels {
|
|
5
|
+
previous: string;
|
|
6
|
+
next: string;
|
|
7
|
+
/** Name of a slide ("2 di 5"). */
|
|
8
|
+
slide: (index: number, count: number) => string;
|
|
9
|
+
/** Name of the button of a slide ("Mostra 2 di 5"). */
|
|
10
|
+
show: (index: number, count: number) => string;
|
|
11
|
+
/** Name of the group of slide buttons. */
|
|
12
|
+
picker: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const CAROUSEL_LABELS: CarouselLabels;
|
|
15
|
+
export interface CarouselOwnProps extends PartsProps<'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot'> {
|
|
16
|
+
/** What it shows ("Foto del prodotto"): the name of the carousel. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** The slides: one per child (a Stage, an image…). */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** Slide shown, from 0. */
|
|
21
|
+
index?: number;
|
|
22
|
+
/** Default 0. */
|
|
23
|
+
defaultIndex?: number;
|
|
24
|
+
onIndexChange?: (index: number) => void;
|
|
25
|
+
/** Above this many slides the dots (44px targets each) become a "2 / 12" counter. Default 5, which fits a phone. */
|
|
26
|
+
maxDots?: number;
|
|
27
|
+
labels?: Partial<CarouselLabels>;
|
|
28
|
+
}
|
|
29
|
+
export type CarouselProps<E extends ElementType = 'section'> = PolymorphicProps<E, CarouselOwnProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Media carousel: one slide at a time on a scroll-snap track (swipe on touch, arrow keys on the focused track), with
|
|
32
|
+
* previous / next and a dot per slide (the current one is a longer pill). It never moves by itself; hidden slides are
|
|
33
|
+
* inert, the shown one is announced politely.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Carousel<E extends ElementType = 'section'>(props: CarouselProps<E>): import("react").JSX.Element;
|
|
36
|
+
//# sourceMappingURL=Carousel.d.ts.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useParts, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Bubble } from "../Bubble/Bubble.js";
|
|
6
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
7
|
+
import { Children, Fragment, useEffect, useId, useRef } from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "@slurp-ui/icons";
|
|
10
|
+
// src/Carousel/Carousel.tsx
|
|
11
|
+
const CAROUSEL_LABELS = {
|
|
12
|
+
previous: "Precedente",
|
|
13
|
+
next: "Successiva",
|
|
14
|
+
slide: (i, n) => `${i} di ${n}`,
|
|
15
|
+
show: (i, n) => `Mostra ${i} di ${n}`,
|
|
16
|
+
picker: "Scegli cosa mostrare"
|
|
17
|
+
};
|
|
18
|
+
const reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
19
|
+
/** Slide nearest to the track's scroll position (-1 when the track has no layout). */
|
|
20
|
+
function visible(track) {
|
|
21
|
+
const width = track.clientWidth;
|
|
22
|
+
return width ? Math.round(Math.abs(track.scrollLeft) / width) : -1;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Media carousel: one slide at a time on a scroll-snap track (swipe on touch, arrow keys on the focused track), with
|
|
26
|
+
* previous / next and a dot per slide (the current one is a longer pill). It never moves by itself; hidden slides are
|
|
27
|
+
* inert, the shown one is announced politely.
|
|
28
|
+
*/
|
|
29
|
+
function Carousel(props) {
|
|
30
|
+
const { as, css, className, label, children, index: indexProp, defaultIndex = 0, onIndexChange, maxDots = 5, labels: labelsProp, parts, partProps, classNames, ...rest } = useThemeProps("Carousel", props);
|
|
31
|
+
const labels = {
|
|
32
|
+
...CAROUSEL_LABELS,
|
|
33
|
+
...labelsProp
|
|
34
|
+
};
|
|
35
|
+
const slides = Children.toArray(children);
|
|
36
|
+
const count = slides.length;
|
|
37
|
+
const [raw, setIndex] = useControlled({
|
|
38
|
+
value: indexProp,
|
|
39
|
+
defaultValue: defaultIndex,
|
|
40
|
+
onChange: onIndexChange
|
|
41
|
+
});
|
|
42
|
+
const index = Math.min(Math.max(0, count - 1), Math.max(0, raw));
|
|
43
|
+
const trackId = `${useId()}-track`;
|
|
44
|
+
/** Slide a programmatic scroll is heading to: the scroll events on the way do not change the index. */
|
|
45
|
+
const heading = useRef(null);
|
|
46
|
+
const Root = as ?? "section";
|
|
47
|
+
const styled = useCss("Carousel", "root", css);
|
|
48
|
+
const { part, style } = useParts("Carousel", {
|
|
49
|
+
parts,
|
|
50
|
+
partProps,
|
|
51
|
+
classNames
|
|
52
|
+
});
|
|
53
|
+
const root = useAnimationRoot(rest);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const t = document.getElementById(trackId);
|
|
56
|
+
if (!t || visible(t) === index) return;
|
|
57
|
+
const slide = t.children[index];
|
|
58
|
+
if (!slide) return;
|
|
59
|
+
heading.current = {
|
|
60
|
+
to: index,
|
|
61
|
+
until: performance.now() + 1e3
|
|
62
|
+
};
|
|
63
|
+
t.scrollTo?.({
|
|
64
|
+
left: slide.offsetLeft,
|
|
65
|
+
behavior: reduced() ? "auto" : "smooth"
|
|
66
|
+
});
|
|
67
|
+
}, [index, trackId]);
|
|
68
|
+
const go = (to) => {
|
|
69
|
+
const next = Math.min(count - 1, Math.max(0, to));
|
|
70
|
+
if (next !== index) setIndex(next);
|
|
71
|
+
};
|
|
72
|
+
const latest = useRef({
|
|
73
|
+
index,
|
|
74
|
+
count,
|
|
75
|
+
setIndex
|
|
76
|
+
});
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
latest.current = {
|
|
79
|
+
index,
|
|
80
|
+
count,
|
|
81
|
+
setIndex
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const t = document.getElementById(trackId);
|
|
86
|
+
if (!t) return;
|
|
87
|
+
const onScroll = (e) => {
|
|
88
|
+
const at = visible(t);
|
|
89
|
+
const h = heading.current;
|
|
90
|
+
if (h) {
|
|
91
|
+
if (at === h.to || e.timeStamp > h.until) heading.current = null;
|
|
92
|
+
else return;
|
|
93
|
+
}
|
|
94
|
+
const { index: now, count: n, setIndex: set } = latest.current;
|
|
95
|
+
if (at >= 0 && at < n && at !== now) set(at);
|
|
96
|
+
};
|
|
97
|
+
t.addEventListener("scroll", onScroll, { passive: true });
|
|
98
|
+
return () => t.removeEventListener("scroll", onScroll);
|
|
99
|
+
}, [trackId]);
|
|
100
|
+
const onKeyDown = (e) => {
|
|
101
|
+
if (e.target !== e.currentTarget) return;
|
|
102
|
+
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
103
|
+
const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
|
|
104
|
+
if (step) go(index + (rtl ? -step : step));
|
|
105
|
+
else if (e.key === "Home") go(0);
|
|
106
|
+
else if (e.key === "End") go(count - 1);
|
|
107
|
+
else return;
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
};
|
|
110
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
111
|
+
styled.style,
|
|
112
|
+
style,
|
|
113
|
+
/* @__PURE__ */ jsxs(Root, {
|
|
114
|
+
className: cx("slurp-carousel", styled.className, className),
|
|
115
|
+
"aria-roledescription": "carousel",
|
|
116
|
+
"aria-label": label,
|
|
117
|
+
...root,
|
|
118
|
+
children: [part("track", "div", {
|
|
119
|
+
id: trackId,
|
|
120
|
+
className: "slurp-carousel-track",
|
|
121
|
+
tabIndex: 0,
|
|
122
|
+
"aria-live": "polite",
|
|
123
|
+
onKeyDown,
|
|
124
|
+
children: slides.map((s, i) => /* @__PURE__ */ jsx(Fragment, { children: part("slide", "div", {
|
|
125
|
+
role: "group",
|
|
126
|
+
"aria-roledescription": "slide",
|
|
127
|
+
"aria-label": labels.slide(i + 1, count),
|
|
128
|
+
className: "slurp-carousel-slide",
|
|
129
|
+
"data-current": i === index ? "" : void 0,
|
|
130
|
+
inert: i !== index,
|
|
131
|
+
children: s
|
|
132
|
+
}) }, i))
|
|
133
|
+
}), count > 1 && part("controls", "div", {
|
|
134
|
+
className: "slurp-carousel-controls",
|
|
135
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
136
|
+
part("previous", Bubble, {
|
|
137
|
+
className: "slurp-carousel-previous",
|
|
138
|
+
label: labels.previous,
|
|
139
|
+
appearance: "soft",
|
|
140
|
+
disabled: index === 0,
|
|
141
|
+
onClick: () => go(index - 1),
|
|
142
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { size: 20 })
|
|
143
|
+
}),
|
|
144
|
+
count <= maxDots ? /* @__PURE__ */ jsx("div", {
|
|
145
|
+
className: "slurp-carousel-dots",
|
|
146
|
+
role: "group",
|
|
147
|
+
"aria-label": labels.picker,
|
|
148
|
+
children: slides.map((_, i) => /* @__PURE__ */ jsx(Fragment, { children: part("dot", "button", {
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "slurp-carousel-dot",
|
|
151
|
+
"aria-label": labels.show(i + 1, count),
|
|
152
|
+
"aria-current": i === index ? "true" : void 0,
|
|
153
|
+
onClick: () => go(i)
|
|
154
|
+
}) }, i))
|
|
155
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
156
|
+
className: "slurp-carousel-status",
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
children: [
|
|
159
|
+
index + 1,
|
|
160
|
+
" / ",
|
|
161
|
+
count
|
|
162
|
+
]
|
|
163
|
+
}),
|
|
164
|
+
part("next", Bubble, {
|
|
165
|
+
className: "slurp-carousel-next",
|
|
166
|
+
label: labels.next,
|
|
167
|
+
appearance: "soft",
|
|
168
|
+
disabled: index === count - 1,
|
|
169
|
+
onClick: () => go(index + 1),
|
|
170
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { size: 20 })
|
|
171
|
+
})
|
|
172
|
+
] })
|
|
173
|
+
})]
|
|
174
|
+
})
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
export { CAROUSEL_LABELS, Carousel };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=Carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Carousel.js","names":[],"sources":["../../src/Carousel/Carousel.tsx"],"sourcesContent":["import { ChevronLeftIcon, ChevronRightIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n Fragment,\n useEffect,\n useId,\n useRef,\n type ElementType,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\n\nimport { Bubble } from '../Bubble/Bubble';\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\nimport { useControlled } from '../utils/useControlled';\n\nexport interface CarouselLabels {\n previous: string;\n next: string;\n /** Name of a slide (\"2 di 5\"). */\n slide: (index: number, count: number) => string;\n /** Name of the button of a slide (\"Mostra 2 di 5\"). */\n show: (index: number, count: number) => string;\n /** Name of the group of slide buttons. */\n picker: string;\n}\n\nexport const CAROUSEL_LABELS: CarouselLabels = {\n previous: 'Precedente',\n next: 'Successiva',\n slide: (i, n) => `${i} di ${n}`,\n show: (i, n) => `Mostra ${i} di ${n}`,\n picker: 'Scegli cosa mostrare',\n};\n\nexport interface CarouselOwnProps extends PartsProps<\n 'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot'\n> {\n /** What it shows (\"Foto del prodotto\"): the name of the carousel. */\n label: string;\n /** The slides: one per child (a Stage, an image…). */\n children: ReactNode;\n /** Slide shown, from 0. */\n index?: number;\n /** Default 0. */\n defaultIndex?: number;\n onIndexChange?: (index: number) => void;\n /** Above this many slides the dots (44px targets each) become a \"2 / 12\" counter. Default 5, which fits a phone. */\n maxDots?: number;\n labels?: Partial<CarouselLabels>;\n}\n\nexport type CarouselProps<E extends ElementType = 'section'> = PolymorphicProps<\n E,\n CarouselOwnProps\n>;\n\nconst reduced = () =>\n typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/** Slide nearest to the track's scroll position (-1 when the track has no layout). */\nfunction visible(track: HTMLElement): number {\n const width = track.clientWidth;\n return width ? Math.round(Math.abs(track.scrollLeft) / width) : -1;\n}\n\n/**\n * Media carousel: one slide at a time on a scroll-snap track (swipe on touch, arrow keys on the focused track), with\n * previous / next and a dot per slide (the current one is a longer pill). It never moves by itself; hidden slides are\n * inert, the shown one is announced politely.\n */\nexport function Carousel<E extends ElementType = 'section'>(props: CarouselProps<E>) {\n const {\n as,\n css,\n className,\n label,\n children,\n index: indexProp,\n defaultIndex = 0,\n onIndexChange,\n maxDots = 5,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Carousel', props as CarouselProps);\n const labels = { ...CAROUSEL_LABELS, ...labelsProp };\n const slides = Children.toArray(children);\n const count = slides.length;\n const [raw, setIndex] = useControlled({\n value: indexProp,\n defaultValue: defaultIndex,\n onChange: onIndexChange,\n });\n const index = Math.min(Math.max(0, count - 1), Math.max(0, raw));\n const trackId = `${useId()}-track`;\n /** Slide a programmatic scroll is heading to: the scroll events on the way do not change the index. */\n const heading = useRef<{ to: number; until: number } | null>(null);\n const Root = (as ?? 'section') as ElementType;\n const styled = useCss('Carousel', 'root', css);\n const { part, style } = useParts('Carousel', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n\n // The index changed (buttons, keys, a controlled value): bring that slide into view.\n useEffect(() => {\n const t = document.getElementById(trackId);\n if (!t || visible(t) === index) return;\n const slide = t.children[index] as HTMLElement | undefined;\n if (!slide) return;\n heading.current = { to: index, until: performance.now() + 1000 };\n t.scrollTo?.({ left: slide.offsetLeft, behavior: reduced() ? 'auto' : 'smooth' });\n }, [index, trackId]);\n\n const go = (to: number) => {\n const next = Math.min(count - 1, Math.max(0, to));\n if (next !== index) setIndex(next);\n };\n\n // Swipes and scrolling: the slide that snapped into view becomes the current one.\n const latest = useRef({ index, count, setIndex });\n useEffect(() => {\n latest.current = { index, count, setIndex };\n });\n useEffect(() => {\n const t = document.getElementById(trackId);\n if (!t) return;\n const onScroll = (e: Event) => {\n const at = visible(t);\n const h = heading.current;\n if (h) {\n if (at === h.to || e.timeStamp > h.until) heading.current = null;\n else return;\n }\n const { index: now, count: n, setIndex: set } = latest.current;\n if (at >= 0 && at < n && at !== now) set(at);\n };\n t.addEventListener('scroll', onScroll, { passive: true });\n return () => t.removeEventListener('scroll', onScroll);\n }, [trackId]);\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.target !== e.currentTarget) return;\n const rtl = getComputedStyle(e.currentTarget).direction === 'rtl';\n const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;\n if (step) go(index + (rtl ? -step : step));\n else if (e.key === 'Home') go(0);\n else if (e.key === 'End') go(count - 1);\n else return;\n e.preventDefault();\n };\n\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-carousel', styled.className, className)}\n aria-roledescription=\"carousel\"\n aria-label={label}\n {...root}\n >\n {part('track', 'div', {\n id: trackId,\n className: 'slurp-carousel-track',\n tabIndex: 0,\n 'aria-live': 'polite',\n onKeyDown,\n children: slides.map((s, i) => (\n <Fragment key={i}>\n {part('slide', 'div', {\n role: 'group',\n 'aria-roledescription': 'slide',\n 'aria-label': labels.slide(i + 1, count),\n className: 'slurp-carousel-slide',\n 'data-current': i === index ? '' : undefined,\n inert: i !== index,\n children: s,\n })}\n </Fragment>\n )),\n })}\n {count > 1 &&\n part('controls', 'div', {\n className: 'slurp-carousel-controls',\n children: (\n <>\n {part('previous', Bubble, {\n className: 'slurp-carousel-previous',\n label: labels.previous,\n appearance: 'soft',\n disabled: index === 0,\n onClick: () => go(index - 1),\n children: <ChevronLeftIcon size={20} />,\n })}\n {count <= maxDots ? (\n <div className=\"slurp-carousel-dots\" role=\"group\" aria-label={labels.picker}>\n {slides.map((_, i) => (\n <Fragment key={i}>\n {part('dot', 'button', {\n type: 'button',\n className: 'slurp-carousel-dot',\n 'aria-label': labels.show(i + 1, count),\n 'aria-current': i === index ? 'true' : undefined,\n onClick: () => go(i),\n })}\n </Fragment>\n ))}\n </div>\n ) : (\n <span className=\"slurp-carousel-status\" aria-hidden=\"true\">\n {index + 1} / {count}\n </span>\n )}\n {part('next', Bubble, {\n className: 'slurp-carousel-next',\n label: labels.next,\n appearance: 'soft',\n disabled: index === count - 1,\n onClick: () => go(index + 1),\n children: <ChevronRightIcon size={20} />,\n })}\n </>\n ),\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAa,kBAAkC;CAC7C,UAAU;CACV,MAAM;CACN,QAAQ,GAAG,MAAM,GAAG,EAAE,MAAM;CAC5B,OAAO,GAAG,MAAM,UAAU,EAAE,MAAM;CAClC,QAAQ;AACV;AAwBA,MAAM,gBACJ,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;;AAGrF,SAAS,QAAQ,OAA4B;CAC3C,MAAM,QAAQ,MAAM;CACpB,OAAO,QAAQ,KAAK,MAAM,KAAK,IAAI,MAAM,UAAU,IAAI,KAAK,IAAI;AAClE;;;;;;AAOA,SAAgB,SAA4C,OAAyB;CACnF,MAAM,EACJ,IACA,KACA,WACA,OACA,UACA,OAAO,WACP,eAAe,GACf,eACA,UAAU,GACV,QAAQ,YACR,OACA,WACA,YACA,GAAG,SACD,cAAc,YAAY,KAAsB;CACpD,MAAM,SAAS;EAAE,GAAG;EAAiB,GAAG;CAAW;CACnD,MAAM,SAA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,KACP,KAAK,YAAY,OAAO;IACtB,WAAW;IACX,UACE,qBAAA,YAAA,EAAA,UAAA;KACG,KAAK,YAAY,QAAQ;MACxB,WAAW;MACX,OAAO,OAAO;MACd,YAAY;MACZ,UAAU,UAAU;MACpB,eAAe,GAAG,QAAQ,CAAC;MAC3B,UAAU,oBAAC,iBAAD,EAAiB,MAAM,GAAK,CAAA;KACxC,CAAC;KACA,SAAS,UACR,oBAAC,OAAD;MAAK,WAAU;MAAsB,MAAK;MAAQ,cAAY,OAAO;MAClE,UAAA,OAAO,KAAK,GAAG,MACd,oBAAC,UAAD,EAAA,UACG,KAAK,OAAO,UAAU;OACrB,MAAM;OACN,WAAW;OACX,cAAc,OAAO,KAAK,IAAI,GAAG,KAAK;OACtC,gBAAgB,MAAM,QAAQ,SAAS,KAAA;OACvC,eAAe,GAAG,CAAC;MACrB,CAAC,EACO,GARK,CAQL,CACX;KACE,CAAA,IAEL,qBAAC,QAAD;MAAM,WAAU;MAAwB,eAAY;MAApD,UAAA;OACG,QAAQ;OAAE;OAAI;MACX;;KAEP,KAAK,QAAQ,QAAQ;MACpB,WAAW;MACX,OAAO,OAAO;MACd,YAAY;MACZ,UAAU,UAAU,QAAQ;MAC5B,eAAe,GAAG,QAAQ,CAAC;MAC3B,UAAU,oBAAC,kBAAD,EAAkB,MAAM,GAAK,CAAA;KACzC,CAAC;IACD,EAAA,CAAA;GAEN,CAAC,CACC;;CACN,EAAA,CAAA;AAEN"}
|
package/dist/Dock/Dock.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface DockLabels {
|
|
|
10
10
|
back: string;
|
|
11
11
|
/** Name of the search field and of the phone search action. */
|
|
12
12
|
search: string;
|
|
13
|
-
/** Placeholder: say where it looks ("Cerca in
|
|
13
|
+
/** Placeholder: say where it looks ("Cerca in Archivio…"). */
|
|
14
14
|
searchPlaceholder: string;
|
|
15
15
|
/** Find in page with no match. */
|
|
16
16
|
noResults: string;
|
package/dist/Dock/Dock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Smartphone…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n aria-label={count ? `${label}, ${countLabel(count)}` : label}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,\n Action: DockAction,\n}) as DockComponent;\n\nexport { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };\n"],"mappings":";;;;;;;;;;;;;;;AAoDA,MAAa,cAA0B;CACrC,YAAY;CACZ,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,mBAAmB;CACnB,WAAW;CACX,UAAU,GAAG,MAAM,GAAG,MAAM,IAAI,qBAAqB,GAAG,EAAE,iBAAiB,IAAI,EAAE,MAAM;CACvF,YAAY,GAAG,MAAM,qCAAqC,EAAE,MAAM;CAClE,aAAa;AACf;AAeA,MAAM,cA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AChC;GACG,CAAA;GACL,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"Dock.js","names":[],"sources":["../../src/Dock/Dock.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport {\n Children,\n createContext,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type ElementType,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport { CRUMB_TAN, crumbPath, type CrumbEnd } from '../lib/crumb';\nimport type { PolymorphicProps } from '../lib/polymorphic';\nimport { focusFirst, moveFocus } from '../utils/focus';\nimport { useControlled } from '../utils/useControlled';\nimport { useDismiss } from '../utils/useDismiss';\nimport { useForkRef } from '../utils/useForkRef';\nimport { COMPACT_QUERY, useMediaQuery } from '../utils/useMediaQuery';\n\nexport interface DockLabels {\n /** Name of the navigation landmark. */\n navigation: string;\n /** Name of the breadcrumb list. */\n crumbs: string;\n /** Name of the back button. */\n back: string;\n /** Name of the search field and of the phone search action. */\n search: string;\n /** Placeholder: say where it looks (\"Cerca in Archivio…\"). */\n searchPlaceholder: string;\n /** Find in page with no match. */\n noResults: string;\n /** Spoken count of find in page. */\n matches: (index: number, count: number) => string;\n /** Name of the \"2/5\" counter button. */\n nextMatch: (index: number, count: number) => string;\n /** How to move into results from the field. */\n resultsHint: string;\n}\n\nexport const DOCK_LABELS: DockLabels = {\n navigation: 'Navigazione',\n crumbs: 'Percorso',\n back: 'Indietro',\n search: 'Cerca',\n searchPlaceholder: 'Cerca…',\n noResults: 'Nessun risultato',\n matches: (i, n) => `${n === 1 ? '1 corrispondenza' : `${n} corrispondenze`}, ${i} di ${n}`,\n nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,\n resultsHint: 'Freccia giù per scorrere i risultati, Esc per chiuderli.',\n};\n\ninterface DockContextValue {\n compact: boolean;\n labels: DockLabels;\n panelId: string;\n panelInner: HTMLElement | null;\n /** The panel shows results (ArrowDown moves into them from the field). */\n hasPanel: boolean;\n searchOpen: boolean;\n setSearchOpen: (open: boolean) => void;\n searchInput: RefObject<HTMLInputElement | null>;\n focusResults: () => boolean;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\nfunction useDock(name: string) {\n const ctx = useContext(DockContext);\n if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);\n return ctx;\n}\n\nexport interface DockOwnProps {\n /** The bar's content: Dock.Crumbs, Dock.Search, Dock.Actions. */\n children?: ReactNode;\n /** Content of the panel above the bar (menu, filters, results). The panel grows in height while it is set. */\n panel?: ReactNode;\n /** Name of the panel region (\"Filtri\"). */\n panelLabel?: string;\n /**\n * Move focus into the panel when it opens (menus and filters: yes; results while typing: no). Default true.\n */\n focusPanel?: boolean;\n /** A press outside, Escape or Tab out: close your panel here. */\n onDismiss?: () => void;\n /** In the flow (previews, docs) instead of fixed at the bottom. */\n inline?: boolean;\n labels?: Partial<DockLabels>;\n}\n\nexport type DockProps<E extends ElementType = 'nav'> = PolymorphicProps<E, DockOwnProps>;\n\n/**\n * The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search\n * and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press\n * outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.\n */\nfunction DockRoot<E extends ElementType = 'nav'>(props: DockProps<E>) {\n const {\n as,\n css,\n className,\n children,\n panel,\n panelLabel,\n focusPanel = true,\n onDismiss,\n inline = false,\n labels: labelsProp,\n ...rest\n } = useThemeProps('Dock', props as DockProps);\n const labels = { ...DOCK_LABELS, ...labelsProp };\n const compact = useMediaQuery(COMPACT_QUERY);\n const [searchOpen, setSearchOpen] = useState(false);\n const [panelInner, setPanelInner] = useState<HTMLElement | null>(null);\n const bar = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const searchInput = useRef<HTMLInputElement>(null);\n const panelId = `${useId()}-panel`;\n const searching = compact && searchOpen;\n const shown = searching ? null : panel;\n const open = searching || (panel != null && panel !== false);\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Dock', 'root', css);\n const root = useAnimationRoot(rest);\n\n const dismiss = useDismiss({\n ref: bar,\n open,\n onDismiss: () => {\n setSearchOpen(false);\n if (panel != null) onDismiss?.();\n },\n fallbackFocus: () => searchInput.current,\n });\n\n const { opened } = dismiss;\n\n // Menus and filters take focus when they open: the panel sits before the bar, Tab would never reach it.\n const hadPanel = useRef(false);\n useEffect(() => {\n const has = shown != null && shown !== false;\n if (has && !hadPanel.current && focusPanel) {\n // Escape gives focus back to the control that opened the panel.\n if (document.activeElement instanceof HTMLElement) opened(document.activeElement);\n focusFirst(panelRef.current);\n }\n hadPanel.current = has;\n }, [shown, focusPanel, opened]);\n\n const focusResults = () => !!moveFocusFirst(panelRef.current);\n\n return (\n <>\n {styled.style}\n <Root\n className={cx('slurp-dock-wrap', styled.className, className)}\n data-inline={inline || undefined}\n aria-label={labels.navigation}\n {...root}\n >\n <div\n ref={bar}\n className=\"slurp-dock\"\n onKeyDown={dismiss.containerProps.onKeyDown}\n onBlur={dismiss.containerProps.onBlur}\n >\n <div\n ref={panelRef}\n id={panelId}\n className=\"slurp-dock-panel\"\n data-open={open || undefined}\n role={open ? 'region' : undefined}\n aria-label={open ? (searching ? labels.search : panelLabel) : undefined}\n inert={!open}\n onKeyDown={(e) =>\n moveFocus(e, panelRef.current, '[data-result]', () => searchInput.current?.focus())\n }\n >\n <div ref={setPanelInner} className=\"slurp-dock-panel-inner\">\n {shown}\n </div>\n </div>\n <DockContext\n value={{\n compact,\n labels,\n panelId,\n panelInner,\n hasPanel: shown != null && shown !== false,\n searchOpen: searching,\n setSearchOpen,\n searchInput,\n focusResults,\n }}\n >\n <div className=\"slurp-dock-row\">{children}</div>\n </DockContext>\n </div>\n </Root>\n </>\n );\n}\n\nfunction moveFocusFirst(root: HTMLElement | null) {\n const first = root?.querySelector<HTMLElement>('[data-result]');\n first?.focus();\n return first;\n}\n\n// ---------- Crumbs ----------\n\nconst CrumbPlace = createContext<{ first: boolean; last: boolean }>({ first: true, last: true });\n\nexport interface DockCrumbsProps {\n children?: ReactNode;\n /** Name of the list; default `labels.crumbs`. */\n label?: string;\n}\n\n/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */\nfunction DockCrumbs({ children, label }: DockCrumbsProps) {\n const { labels } = useDock('Dock.Crumbs');\n const items = Children.toArray(children).filter(isValidElement);\n return (\n <ol className=\"slurp-dock-crumbs\" aria-label={label ?? labels.crumbs}>\n {items.map((child, i) => (\n <CrumbPlace key={child.key ?? i} value={{ first: i === 0, last: i === items.length - 1 }}>\n <li>{child}</li>\n </CrumbPlace>\n ))}\n </ol>\n );\n}\n\ntype CrumbShapeProps = {\n left: CrumbEnd;\n right: CrumbEnd;\n className?: string;\n children?: ReactNode;\n} & Record<string, unknown>;\n\n/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */\nfunction CrumbShape({ left, right, className, children, ref, ...rest }: CrumbShapeProps) {\n const own = useRef<HTMLButtonElement>(null);\n const [size, setSize] = useState<{ w: number; h: number } | null>(null);\n const merged = useForkRef(ref as never, own);\n useLayoutEffect(() => {\n const el = own.current;\n if (!el || typeof ResizeObserver === 'undefined') return;\n const measure = () =>\n setSize((s) =>\n s && s.w === el.offsetWidth && s.h === el.offsetHeight\n ? s\n : { w: el.offsetWidth, h: el.offsetHeight },\n );\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const s = size ? size.h * CRUMB_TAN : 0;\n return (\n <button\n ref={merged}\n type=\"button\"\n className={cx('slurp-crumb', className)}\n data-drawn={size ? '' : undefined}\n data-left={left}\n data-right={right}\n {...rest}\n >\n {size && size.w > 0 && (\n <svg\n className=\"slurp-crumb-shape\"\n aria-hidden=\"true\"\n width={size.w + s}\n height={size.h}\n viewBox={`0 0 ${size.w + s} ${size.h}`}\n style={{ left: -s / 2 }}\n >\n <path d={crumbPath(size.w, size.h, left, right)} />\n </svg>\n )}\n {children}\n </button>\n );\n}\n\nexport type DockBackProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n { label?: string }\n>;\n\n/** The back button: the first crumb (the root), round on the left. */\nfunction DockBack<E extends ElementType = 'button'>(props: DockBackProps<E>) {\n const { label, className, css: _css, ...rest } = props as DockBackProps;\n const { labels } = useDock('Dock.Back');\n const { last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n return (\n <CrumbShape\n left=\"round\"\n right={last ? 'round' : 'slant'}\n className={cx('slurp-crumb-back', className)}\n aria-label={label ?? labels.back}\n data-crumb=\"0\"\n {...root}\n >\n <ArrowLeftIcon />\n </CrumbShape>\n );\n}\n\nexport interface DockCrumbOwnProps {\n /** The level's name. */\n children: ReactNode;\n /** The page you are on: accent-filled, `aria-current=\"page\"`. */\n current?: boolean;\n /** Shown instead of the label on phones when this crumb is not the current one (the label stays as its name). */\n icon?: ReactNode;\n /** The crumb opens a panel (the section menu): its open state, shown by an arrow and aria-expanded. */\n expanded?: boolean;\n}\n\nexport type DockCrumbProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockCrumbOwnProps\n>;\n\n/** A level of the path. Every crumb triggers the transition: give it an animationId. */\nfunction DockCrumb<E extends ElementType = 'button'>(props: DockCrumbProps<E>) {\n const {\n children,\n current = false,\n icon,\n expanded,\n className,\n css: _css,\n ...rest\n } = props as DockCrumbProps;\n const { compact, panelId } = useDock('Dock.Crumb');\n const { first, last } = useContext(CrumbPlace);\n const root = useAnimationRoot(rest);\n const iconOnly = compact && !current && icon != null;\n const name = typeof children === 'string' ? children : undefined;\n return (\n <CrumbShape\n left={first ? 'round' : 'slant'}\n right={last ? 'round' : 'slant'}\n className={className}\n data-current={current || undefined}\n data-icon={iconOnly || undefined}\n aria-current={current ? 'page' : undefined}\n aria-label={iconOnly ? name : undefined}\n title={iconOnly ? name : undefined}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n {...root}\n >\n {iconOnly ? (\n <span className=\"slurp-crumb-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : (\n <span className=\"slurp-crumb-label\">{children}</span>\n )}\n {expanded !== undefined && (\n <span className=\"slurp-crumb-arrow\" data-up={expanded || undefined} aria-hidden=\"true\">\n <ArrowDownIcon size={16} />\n </span>\n )}\n </CrumbShape>\n );\n}\n\n// ---------- Search ----------\n\nexport interface DockSearchProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Name of the field; default `labels.search`. */\n label?: string;\n /** Default `labels.searchPlaceholder`: say where it looks. */\n placeholder?: string;\n /** Enter, when this is not find in page. */\n onSearch?: (value: string) => void;\n /** Find in page: how many matches (shows \"2/5\" or \"Nessun risultato\"). */\n count?: number;\n /** Find in page: the active match, 0-based. */\n index?: number;\n /** Find in page: Enter / Shift+Enter / a tap on the counter. */\n onStep?: (delta: 1 | -1) => void;\n}\n\n/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */\nfunction DockSearch({\n value: valueProp,\n defaultValue = '',\n onValueChange,\n label,\n placeholder,\n onSearch,\n count,\n index = 0,\n onStep,\n}: DockSearchProps) {\n const ctx = useDock('Dock.Search');\n const { labels } = ctx;\n const [value, setValue] = useControlled({\n value: valueProp,\n defaultValue,\n onChange: onValueChange,\n });\n const name = label ?? labels.search;\n const typed = value.trim() !== '';\n\n const counter =\n count != null && typed ? (\n <>\n {count ? (\n <button\n type=\"button\"\n className=\"slurp-dock-search-count\"\n aria-label={labels.nextMatch(index + 1, count)}\n onClick={(e) => {\n e.preventDefault();\n onStep?.(1);\n }}\n >\n {index + 1}/{count}\n </button>\n ) : (\n <span className=\"slurp-dock-search-count\" data-empty=\"\" aria-hidden=\"true\">\n {labels.noResults}\n </span>\n )}\n <span className=\"slurp-visually-hidden\" role=\"status\">\n {count ? labels.matches(index + 1, count) : labels.noResults}\n </span>\n </>\n ) : null;\n\n const field = (inPanel: boolean) => (\n <label className=\"slurp-dock-search\">\n <SearchIcon size={18} />\n <span className=\"slurp-visually-hidden\">{name}</span>\n <input\n ref={ctx.searchInput}\n type=\"search\"\n value={value}\n placeholder={placeholder ?? labels.searchPlaceholder}\n enterKeyHint={onStep ? 'next' : 'search'}\n autoComplete=\"off\"\n autoFocus={inPanel}\n aria-controls={ctx.hasPanel ? ctx.panelId : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n if (onStep) onStep(e.shiftKey ? -1 : 1);\n else onSearch?.(value);\n } else if (e.key === 'ArrowDown' && ctx.hasPanel && ctx.focusResults()) {\n e.preventDefault();\n }\n }}\n />\n {counter}\n </label>\n );\n\n if (!ctx.compact) return field(false);\n return (\n <>\n <DockAction\n label={typed ? `${name}: “${value.trim()}”` : name}\n expanded={ctx.searchOpen}\n dot={typed && !ctx.searchOpen}\n onClick={() => ctx.setSearchOpen(!ctx.searchOpen)}\n >\n <SearchIcon />\n </DockAction>\n {ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)}\n </>\n );\n}\n\n// ---------- Actions ----------\n\n/** Actions at the right end of the bar (search before filters). */\nfunction DockActions({ children }: { children?: ReactNode }) {\n return <div className=\"slurp-dock-actions\">{children}</div>;\n}\n\nexport interface DockActionOwnProps {\n /** Accessible name (\"Filtri\"); the count is added to it. */\n label: string;\n /** The icon. */\n children: ReactNode;\n /** Its panel is open: accent fill and aria-expanded. */\n expanded?: boolean;\n /** Badge count (active filters). */\n count?: number;\n /** How the count is said; default `${n} attivi`. */\n countLabel?: (count: number) => string;\n /** A small accent dot (a query is active while the search panel is closed). */\n dot?: boolean;\n}\n\nexport type DockActionProps<E extends ElementType = 'button'> = PolymorphicProps<\n E,\n DockActionOwnProps\n>;\n\n/** Round 48px action of the bar (filters, the phone search). */\nfunction DockAction<E extends ElementType = 'button'>(props: DockActionProps<E>) {\n const {\n label,\n children,\n expanded,\n count,\n countLabel = (n) => (n === 1 ? '1 attivo' : `${n} attivi`),\n dot,\n className,\n css: _css,\n onClick,\n ...rest\n } = props as DockActionProps;\n const { panelId } = useDock('Dock.Action');\n const root = useAnimationRoot(rest);\n return (\n <button\n type=\"button\"\n className={cx('slurp-dock-action', className)}\n data-active={expanded || undefined}\n aria-label={count ? `${label}, ${countLabel(count)}` : label}\n aria-expanded={expanded}\n aria-controls={expanded !== undefined ? panelId : undefined}\n onClick={onClick as ((e: MouseEvent<HTMLButtonElement>) => void) | undefined}\n {...root}\n >\n <span aria-hidden=\"true\" className=\"slurp-dock-action-icon\">\n {children}\n </span>\n {count ? (\n <span className=\"slurp-dock-action-count\" aria-hidden=\"true\">\n {count}\n </span>\n ) : null}\n {dot ? <span className=\"slurp-dock-action-dot\" aria-hidden=\"true\" /> : null}\n </button>\n );\n}\n\ntype DockComponent = typeof DockRoot & {\n Crumbs: typeof DockCrumbs;\n Back: typeof DockBack;\n Crumb: typeof DockCrumb;\n Search: typeof DockSearch;\n Actions: typeof DockActions;\n Action: typeof DockAction;\n};\n\nexport const Dock = Object.assign(DockRoot, {\n Crumbs: DockCrumbs,\n Back: DockBack,\n Crumb: DockCrumb,\n Search: DockSearch,\n Actions: DockActions,\n Action: DockAction,\n}) as DockComponent;\n\nexport { DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };\n"],"mappings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I;CAClC,OACE,qBAAC,UAAD;EACE,MAAK;EACL,WAAW,GAAG,qBAAqB,SAAS;EAC5C,eAAa,YAAY,KAAA;EACzB,cAAY,QAAQ,GAAG,MAAM,IAAI,WAAW,KAAK,MAAM;EACvD,iBAAe;EACf,iBAAe,aAAa,KAAA,IAAY,UAAU,KAAA;EACzC;EACT,GAAI;EARN,UAAA;GAUE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IAChC;GACG,CAAA;GACL,QACC,oBAAC,QAAD;IAAM,WAAU;IAA0B,eAAY;IACnD,UAAA;GACG,CAAA,IACJ;GACH,MAAM,oBAAC,QAAD;IAAM,WAAU;IAAwB,eAAY;GAAQ,CAAA,IAAI;EACjE;;AAEZ;AAWA,MAAa,OAAO,OAAO,OAAO,UAAU;CAC1C,QAAQ;CACR,MAAM;CACN,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;AACV,CAAC"}
|
|
@@ -9,7 +9,7 @@ export interface ListRowOwnProps extends PartsProps<'mark' | 'title' | 'tag' | '
|
|
|
9
9
|
/** Leading mark (an icon, a logo); default the first letter of the title. */
|
|
10
10
|
mark?: ReactNode;
|
|
11
11
|
meta?: ReactNode;
|
|
12
|
-
/** Trailing value ("9.1", "
|
|
12
|
+
/** Trailing value ("9.1", "24"). */
|
|
13
13
|
value?: ReactNode;
|
|
14
14
|
/** Highlight tag next to the title ("Consigliato"): with a check, never colour alone. */
|
|
15
15
|
tag?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"
|
|
1
|
+
{"version":3,"file":"ListRow.js","names":[],"sources":["../../src/ListRow/ListRow.tsx"],"sourcesContent":["import { CheckIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { createContext, useContext, type ElementType, type ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useParts, useThemeProps } from '../internal/styled';\nimport type { PartsProps, PolymorphicProps } from '../lib/polymorphic';\n\nconst InList = createContext(false);\n\nexport type ListProps<E extends ElementType = 'ul'> = PolymorphicProps<E>;\n\n/** A list of ListRows (rows become list items). */\nexport function List<E extends ElementType = 'ul'>(props: ListProps<E>) {\n const { as, css, className, children, ...rest } = useThemeProps('List', props as ListProps);\n const Root = (as ?? 'ul') as ElementType;\n const styled = useCss('List', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-list', styled.className, className)} {...root}>\n <InList value={Root === 'ul' || Root === 'ol'}>{children}</InList>\n </Root>\n </>\n );\n}\n\nexport interface ListRowOwnProps extends PartsProps<\n 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action'\n> {\n title: ReactNode;\n /** Leading mark (an icon, a logo); default the first letter of the title. */\n mark?: ReactNode;\n meta?: ReactNode;\n /** Trailing value (\"9.1\", \"24\"). */\n value?: ReactNode;\n /** Highlight tag next to the title (\"Consigliato\"): with a check, never colour alone. */\n tag?: ReactNode;\n /** The row is highlighted: accent-soft with an accent-ink outline, and the tag. */\n highlighted?: boolean;\n /** Text of the trailing link; the row's title is added for assistive tech. */\n actionLabel?: ReactNode;\n href?: string;\n}\n\nexport type ListRowProps<E extends ElementType = 'div'> = PolymorphicProps<E, ListRowOwnProps>;\n\n/** Row of a list: mark, title (with an optional highlight tag), meta, a trailing value and one action link. */\nexport function ListRow<E extends ElementType = 'div'>(props: ListRowProps<E>) {\n const {\n as,\n css,\n className,\n title,\n mark,\n meta,\n value,\n tag,\n highlighted = false,\n actionLabel,\n href,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('ListRow', props as ListRowProps);\n const inList = useContext(InList);\n const Root = (as ?? (inList ? 'li' : 'div')) as ElementType;\n const styled = useCss('ListRow', 'root', css);\n const { part, style } = useParts('ListRow', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n const initial = typeof title === 'string' ? title.charAt(0) : null;\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-list-row', styled.className, className)}\n data-highlighted={highlighted || undefined}\n {...root}\n >\n {part('mark', 'span', {\n className: 'slurp-list-row-mark',\n 'aria-hidden': true,\n children: mark ?? initial,\n })}\n <span className=\"slurp-list-row-info\">\n {part('title', 'span', {\n className: 'slurp-list-row-title',\n children: (\n <>\n {title}\n {tag != null &&\n part('tag', 'span', {\n className: 'slurp-list-row-tag',\n children: (\n <>\n <CheckIcon size={12} />\n {tag}\n </>\n ),\n })}\n </>\n ),\n })}\n {meta != null &&\n part('meta', 'span', { className: 'slurp-list-row-meta', children: meta })}\n </span>\n {value != null &&\n part('value', 'span', { className: 'slurp-list-row-value', children: value })}\n {actionLabel != null &&\n part('action', 'a', {\n className: 'slurp-list-row-action',\n href: href ?? '#',\n // \"Vedi\" alone repeats on every row: the row's title completes the link's name.\n 'aria-label':\n typeof actionLabel === 'string' && typeof title === 'string'\n ? `${actionLabel} ${title}`\n : undefined,\n children: actionLabel,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,cAAc,KAAK;;AAKlC,SAAgB,KAAmC,OAAqB;CACtE,MAAM,EAAE,IAAI,KAAK,WAAW,UAAU,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC1F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,OAAO,OACR,oBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAClE,UAAA,oBAAC,QAAD;GAAQ,OAAO,SAAS,QAAQ,SAAS;GAAO;EAAiB,CAAA;CAC7D,CAAA,CACN,EAAA,CAAA;AAEN;;AAuBA,SAAgB,QAAuC,OAAwB;CAC7E,MAAM,EACJ,IACA,KACA,WACA,OACA,MACA,MACA,OACA,KACA,cAAc,OACd,aACA,MACA,OACA,WACA,YACA,GAAG,SACD,cAAc,WAAW,KAAqB;CAClD,MAAM,SAAS,WAAW,MAAM;CAChC,MAAM,OAAQ,OAAO,SAAS,OAAO;CACrC,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG;CAC5C,MAAM,EAAE,MAAM,UAAU,SAAS,WAAW;EAAE;EAAO;EAAW;CAAW,CAAC;CAC5E,MAAM,OAAO,iBAAiB,IAAI;CAClC,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,OAAO,CAAC,IAAI;CAC9D,OACE,qBAAA,YAAA,EAAA,UAAA;EACG,OAAO;EACP;EACD,qBAAC,MAAD;GACE,WAAW,GAAG,kBAAkB,OAAO,WAAW,SAAS;GAC3D,oBAAkB,eAAe,KAAA;GACjC,GAAI;GAHN,UAAA;IAKG,KAAK,QAAQ,QAAQ;KACpB,WAAW;KACX,eAAe;KACf,UAAU,QAAQ;IACpB,CAAC;IACD,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACG,KAAK,SAAS,QAAQ;MACrB,WAAW;MACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACG,OACA,OAAO,QACN,KAAK,OAAO,QAAQ;OAClB,WAAW;OACX,UACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,WAAD,EAAW,MAAM,GAAK,CAAA,GACrB,GACD,EAAA,CAAA;MAEN,CAAC,CACH,EAAA,CAAA;KAEN,CAAC,GACA,QAAQ,QACP,KAAK,QAAQ,QAAQ;MAAE,WAAW;MAAuB,UAAU;KAAK,CAAC,CACvE;;IACL,SAAS,QACR,KAAK,SAAS,QAAQ;KAAE,WAAW;KAAwB,UAAU;IAAM,CAAC;IAC7E,eAAe,QACd,KAAK,UAAU,KAAK;KAClB,WAAW;KACX,MAAM,QAAQ;KAEd,cACE,OAAO,gBAAgB,YAAY,OAAO,UAAU,WAChD,GAAG,YAAY,GAAG,UAClB,KAAA;KACN,UAAU;IACZ,CAAC;GACC;;CACN,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType } from "react";
|
|
4
|
+
export interface PagesLabels {
|
|
5
|
+
/** Name of the navigation landmark. */
|
|
6
|
+
label: string;
|
|
7
|
+
previous: string;
|
|
8
|
+
next: string;
|
|
9
|
+
/** Name of a page link ("Pagina 3"). */
|
|
10
|
+
page: (page: number) => string;
|
|
11
|
+
/** Where you are, shown on phones instead of the numbers ("3 di 12"). */
|
|
12
|
+
status: (page: number, count: number) => string;
|
|
13
|
+
}
|
|
14
|
+
export declare const PAGES_LABELS: PagesLabels;
|
|
15
|
+
export interface PagesOwnProps extends PartsProps<'list' | 'item' | 'previous' | 'next' | 'status'> {
|
|
16
|
+
/** Number of pages. */
|
|
17
|
+
count: number;
|
|
18
|
+
/** Current page, from 1. */
|
|
19
|
+
page?: number;
|
|
20
|
+
/** Default 1. */
|
|
21
|
+
defaultPage?: number;
|
|
22
|
+
onPageChange?: (page: number) => void;
|
|
23
|
+
/** Pages shown on each side of the current one. Default 1. */
|
|
24
|
+
siblings?: number;
|
|
25
|
+
/** Pages always shown at each end. Default 1. */
|
|
26
|
+
boundaries?: number;
|
|
27
|
+
/** URL of a page: the items become links (crawlable, open in a new tab). */
|
|
28
|
+
href?: (page: number) => string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
labels?: Partial<PagesLabels>;
|
|
31
|
+
}
|
|
32
|
+
export type PagesProps<E extends ElementType = 'nav'> = PolymorphicProps<E, PagesOwnProps>;
|
|
33
|
+
/** A page number or a gap ("…") standing for the pages left out. */
|
|
34
|
+
export type PageItem = number | 'gap';
|
|
35
|
+
/**
|
|
36
|
+
* The items of a pagination: the ends, a window around the current page and a gap where pages are left out. The length
|
|
37
|
+
* stays the same whatever the page, so the controls never jump; a gap never stands for a single page.
|
|
38
|
+
*/
|
|
39
|
+
export declare function pageItems(page: number, count: number, siblings?: number, boundaries?: number): PageItem[];
|
|
40
|
+
/**
|
|
41
|
+
* Pagination: previous, the page numbers (the current one filled, `aria-current="page"`) and next. On phones only
|
|
42
|
+
* previous, "3 di 12" and next. With `href` every item is a real link.
|
|
43
|
+
*/
|
|
44
|
+
export declare function Pages<E extends ElementType = 'nav'>(props: PagesProps<E>): import("react").JSX.Element;
|
|
45
|
+
//# sourceMappingURL=Pages.d.ts.map
|