@slurp-ui/react 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,95 @@
1
+ # @slurp-ui/react
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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).
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [9e6f907]
12
+ - @slurp-ui/icons@1.1.0
13
+
14
+ ## 1.0.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 9aec3d3: The package now includes its CHANGELOG.md.
19
+ - Updated dependencies [9aec3d3]
20
+ - @slurp-ui/motion@1.0.1
21
+ - @slurp-ui/tokens@1.0.1
22
+ - @slurp-ui/icons@1.0.1
23
+
24
+ ## 1.0.0
25
+
26
+ ### Major Changes
27
+
28
+ - da26ea0: First stable release: the Slurp design system's tokens, icons, collapse / expand engine and React components, with a documentation page per component (props, accessibility, classes, variables and states). From here on the public API follows semver.
29
+
30
+ ### Minor Changes
31
+
32
+ - 56e94d4: First release of the Slurp design tokens: `--slurp-*` custom properties for the light and dark themes (`tokens.css`, inside `@layer slurp.base`), Poppins `@font-face` rules (`fonts.css`) and typed TS constants (`color`, `hue`, `space`, `radius`, `font`, `vars`, `cssVar()`, `COMPACT_QUERY`). `@slurp-ui/react` re-exports them from `@slurp-ui/react/tokens`, `@slurp-ui/react/tokens.css` and `@slurp-ui/react/styles.css`.
33
+ - 3b1c343: Add `AccentScope`: scopes `accent`, `on-accent`, `accent-soft`, `accent-ink` and `focus` to a `hue-*` preset or any colour (through `vivid()`), with a 0.9s cross-fade.
34
+ - 5e42219: Add `Avatar`: round photo with initials as fallback.
35
+ - cec612b: Add `Bento` (12 fluid columns, two below 860px) and `bentoLayout()`: with `layout="auto"` the children's `weight` shapes the spans, the first section tall on the left.
36
+ - 5e42219: Add `Bloom`: the button becomes the panel. One surface grows from the trigger (width, height, radius) and shrinks back, flipping when there is no room; built on `useDismiss` and `focusFirst`.
37
+ - 5e42219: Add `Bubble`, the round icon-only button with a required `label`.
38
+ - 5e42219: Add `Button`: `fill`, `soft`, `outline` or `plain` appearance, `accent` or `neutral` tone, sizes `sm`/`md`/`lg` (44px minimum), icons and `href`.
39
+ - cec612b: Add `Card` (one tinted surface, title and description pills inside, link or button) and `Shelf`, the auto-fill list of cards.
40
+ - 3b1c343: Add `Cell`, the base primitive: any element (`as`) styled with `css`.
41
+ - 5e42219: Add `Checkbox` on a native input, with the indeterminate state.
42
+ - 5e42219: Add `Chip`, a toggle with `aria-pressed`: selected is an accent fill plus a check.
43
+ - 5e42219: Add `Choice`, the select whose trigger becomes the list (Bloom), with full keyboard support and a hidden form input.
44
+ - 551769e: Add the colour utilities of the design system: `vivid()`, `contrast()`, `meetsContrast()`, `onColor()`, `alpha()`.
45
+ - 5e42219: Add `Count`, a badge whose `label` joins the accessible name of the control around it.
46
+ - 3b1c343: Add the `css` prop runtime: design tokens (`p: 4`, `bg: 'accent-soft'`, `radius: 'card'`, `font: 'title-l'`), nested selectors and `{ base, compact, wide }` breakpoints, compiled to hashed atomic classes in `@layer slurp.utilities` and hoisted with React 19 `<style>` (SSR included).
47
+ - 5e42219: Add `Dialog` (native modal `<dialog>`, grows out of the control that opened it) and `Sheet` (from the bottom edge).
48
+ - cec612b: Add `Dock`, the single navigation: `Dock.Crumbs` with `Dock.Back` and `Dock.Crumb` drawn as interlocking SVG pieces (`crumbPath()`), `Dock.Search` with the find-in-page counter, `Dock.Actions` / `Dock.Action`, and panels that grow above the bar. On phones earlier crumbs become icons and search becomes an action.
49
+ - cec612b: Add `Empty`: a message and a single way out, announced politely.
50
+ - cec612b: Add `Fact` (label and value as one pill) and `Score` (one decimal in an accent-ink ring, fully named for assistive tech).
51
+ - 5e42219: Add `Field`: label, input or textarea with a 3:1 boundary, hint and error wired with aria-describedby.
52
+ - cec612b: Add `Filters` and `Filters.Group`: the filter panel with "Azzera filtri", off when nothing is active.
53
+ - 3b1c343: Add `Flow`: column or row with a gap from the space scale; `direction`, `gap`, `align`, `justify` accept breakpoints.
54
+ - 5e42219: Add `Fold`, a disclosure that grows in height; closed content is inert.
55
+ - 3b1c343: Add `Frame`: centred page column, max 1280px, gutter 24px (16px on phones).
56
+ - 3b1c343: Add `Ground`: opt-in page baseline (box-sizing, Poppins body text, `bg` tinted 7% by the accent, 2px focus ring) in `@layer slurp.reset`.
57
+ - 5e42219: Add `Hint`, a tooltip in the top layer: hover (with delay) and focus, Escape, stays while hovered.
58
+ - cec612b: Add `List` and `ListRow`: mark, title with a highlight tag (with a check), meta, value and one action link named after its row; `Link` for text links.
59
+ - cec612b: Add `Mark` and `useFindInPage()` for find in page (case- and accent-insensitive, the active match filled and scrolled to the middle), with `matchesAll`, `matchRanges` and `focusHit`.
60
+ - 5e42219: Add `Menu` and `MenuItem` on Bloom: looping arrow keys, items close the menu and give focus back.
61
+ - f8991cf: Add opt-in motion: every component accepts `animationId`, `animationGroup`, `animationLead`, `animationDisabled` and `animationGhost` and only registers its root (nothing is allocated without them). `useSlurp()` starts collapse / expand transitions with the theme defaults (`createTheme({ motion })` now covers duration, stagger, curve, swell, drop, goo, ghost, order, reduced motion and interruptions), `<AnimationGroup>` groups descendants, `useAnimationTarget()` registers custom elements. The engine is re-exported from `@slurp-ui/react/motion`.
62
+ - 4b675d4: Add `useSlurpNavigate` and `useSlurpEnter` for transitions across routes: the first wraps any router's navigate function (no router is imported) and measures the source before navigating, the second plays the transition in the route that mounts and, with `content`, fades the rest of the page in while the droplets land. A stale handoff or missing targets fade; a direct visit or the browser's history only render the route.
63
+ - 5e42219: Add `Notice`: icon plus word for each tone, optional close button.
64
+ - 5e42219: Add `Placeholder`, rounded loading shapes (circle, capsule, soft square).
65
+ - 5e42219: Add `VisuallyHidden` and `Portal`.
66
+ - 5e42219: Add `Progress` as a bar or a ring, with value or indeterminate.
67
+ - 5e42219: Add `Radio` and `RadioGroup` (fieldset and legend, native arrow keys).
68
+ - 5e42219: Add `Range`, a slider on a native range input with a 44px target and a formatted value text.
69
+ - cec612b: Add `ResultRow`, a search result whose rows move with the arrow keys.
70
+ - 5e42219: Add `Search`: contextual placeholder, result count in a polite live region, clear button, Enter to search.
71
+ - 5e42219: Add `Segmented`, a single choice among a few: one tab stop, arrow keys move and select, the selected segment is filled and checked.
72
+ - cec612b: Add `Settings`: the round button that grows into its panel, with Tema always and Lingua when configured; `RadioGroup` gains `appearance="rows"` and `Radio` an `icon`.
73
+ - cec612b: Add `Stage`, the media stage with one breathing glow and one ring.
74
+ - 3b1c343: Add `Surface`: floating surface with `level` (`surface`, `dock`, `solid`) and `radius`.
75
+ - 5e42219: Add `Swatch` and `SwatchGroup`: colour choices with a ring for the selected one, arrow keys in the group.
76
+ - 5e42219: Add `Switch` (`role="switch"`): on shows the thumb at the end with a check.
77
+ - 5e42219: Add `Tabs`: the pill indicator moves on a spring (CSS `linear()` easing), arrow keys move and select.
78
+ - 3b1c343: Add `Text`: the 13 type styles of the design system (`font`), element chosen from the style, `tone` and `muted`.
79
+ - 3b1c343: Add `createTheme()`, `SlurpProvider`, `useTheme()`, `useColorScheme()` and `ColorSchemeScript`: accent, token overrides, per-component defaults and `css`, light / dark / system colour scheme remembered in localStorage. Nested providers theme only their subtree.
80
+ - cec612b: Add `Tile`, the entry grid cell tinted by its colour, with a drifting blob and container-scaled text and media; a collapse saturates toward its colour.
81
+ - 5e42219: Add `ToastProvider` and `useToast()`: toasts in a polite live region above the Dock, paused while hovered or focused.
82
+ - 5e42219: Add the shared behaviour of the components, also at `@slurp-ui/react/utils`: `useDismiss` (press outside, Escape, Tab out, focus back), `focusFirst`, `moveFocus`, `useRovingFocus`, `useControlled`, `useForkRef`, `useMediaQuery` with `COMPACT_QUERY`.
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [5cac9b1]
87
+ - Updated dependencies [201df15]
88
+ - Updated dependencies [878fd91]
89
+ - Updated dependencies [8b092aa]
90
+ - Updated dependencies [da26ea0]
91
+ - Updated dependencies [56e94d4]
92
+ - Updated dependencies [228b034]
93
+ - @slurp-ui/icons@1.0.0
94
+ - @slurp-ui/motion@1.0.0
95
+ - @slurp-ui/tokens@1.0.0
@@ -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,SAAS,SAAS,QAAQ,QAAQ;CACxC,MAAM,QAAQ,OAAO;CACrB,MAAM,CAAC,KAAK,YAAY,cAAc;EACpC,OAAO;EACP,cAAc;EACd,UAAU;CACZ,CAAC;CACD,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,QAAQ,CAAC,GAAG,KAAK,IAAI,GAAG,GAAG,CAAC;C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K,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"}
@@ -0,0 +1,3 @@
1
+
2
+ import { CAROUSEL_LABELS, Carousel, CarouselLabels, CarouselProps } from "./Carousel.js";
3
+ export { CAROUSEL_LABELS, Carousel, type CarouselLabels, type CarouselProps, Carousel as default };
@@ -0,0 +1,2 @@
1
+
2
+ export { CAROUSEL_LABELS, Carousel, Carousel as default } from "./Carousel.js";
@@ -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
@@ -0,0 +1,128 @@
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 { useControlled } from "../utils/useControlled.js";
6
+ import { Fragment } from "react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { ChevronLeftIcon, ChevronRightIcon } from "@slurp-ui/icons";
9
+ // src/Pages/Pages.tsx
10
+ const PAGES_LABELS = {
11
+ label: "Pagine",
12
+ previous: "Pagina precedente",
13
+ next: "Pagina successiva",
14
+ page: (n) => `Pagina ${n}`,
15
+ status: (n, count) => `${n} di ${count}`
16
+ };
17
+ const span = (from, to) => Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);
18
+ /**
19
+ * The items of a pagination: the ends, a window around the current page and a gap where pages are left out. The length
20
+ * stays the same whatever the page, so the controls never jump; a gap never stands for a single page.
21
+ */
22
+ function pageItems(page, count, siblings = 1, boundaries = 1) {
23
+ if (count <= 2 * boundaries + 2 * siblings + 3) return span(1, count);
24
+ const lo = Math.min(Math.max(page - siblings, boundaries + 2), count - boundaries - 1 - 2 * siblings);
25
+ const hi = lo + 2 * siblings;
26
+ const left = lo === boundaries + 2 ? span(1, boundaries + 1) : [...span(1, boundaries), "gap"];
27
+ const right = hi === count - boundaries - 1 ? span(count - boundaries, count) : ["gap", ...span(count - boundaries + 1, count)];
28
+ return [
29
+ ...left,
30
+ ...span(lo, hi),
31
+ ...right
32
+ ];
33
+ }
34
+ /**
35
+ * Pagination: previous, the page numbers (the current one filled, `aria-current="page"`) and next. On phones only
36
+ * previous, "3 di 12" and next. With `href` every item is a real link.
37
+ */
38
+ function Pages(props) {
39
+ const { as, css, className, count: countProp, page: pageProp, defaultPage = 1, onPageChange, siblings = 1, boundaries = 1, href, disabled = false, labels: labelsProp, parts, partProps, classNames, ...rest } = useThemeProps("Pages", props);
40
+ const labels = {
41
+ ...PAGES_LABELS,
42
+ ...labelsProp
43
+ };
44
+ const count = Math.max(1, Math.floor(countProp));
45
+ const [raw, setPage] = useControlled({
46
+ value: pageProp,
47
+ defaultValue: defaultPage,
48
+ onChange: onPageChange
49
+ });
50
+ const page = Math.min(count, Math.max(1, raw));
51
+ const Root = as ?? "nav";
52
+ const styled = useCss("Pages", "root", css);
53
+ const { part, style } = useParts("Pages", {
54
+ parts,
55
+ partProps,
56
+ classNames
57
+ });
58
+ const root = useAnimationRoot(rest);
59
+ /** A link or a button that goes to `to`; unavailable (the ends, disabled) it keeps its place but does nothing. */
60
+ const control = (to, off) => {
61
+ const go = (e) => {
62
+ if (off) {
63
+ e.preventDefault();
64
+ return;
65
+ }
66
+ if (to !== page) setPage(to);
67
+ };
68
+ if (href) return off ? {
69
+ "aria-disabled": true,
70
+ role: "link",
71
+ onClick: go
72
+ } : {
73
+ href: href(to),
74
+ onClick: go
75
+ };
76
+ return {
77
+ type: "button",
78
+ disabled: off,
79
+ onClick: go
80
+ };
81
+ };
82
+ const Tag = href ? "a" : "button";
83
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
84
+ styled.style,
85
+ style,
86
+ /* @__PURE__ */ jsxs(Root, {
87
+ className: cx("slurp-pages", styled.className, className),
88
+ "aria-label": labels.label,
89
+ "data-disabled": disabled ? "" : void 0,
90
+ ...root,
91
+ children: [
92
+ part("previous", Tag, {
93
+ ...control(page - 1, disabled || page <= 1),
94
+ className: "slurp-pages-step",
95
+ "aria-label": labels.previous,
96
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { size: 20 })
97
+ }),
98
+ part("list", "ul", {
99
+ className: "slurp-pages-list",
100
+ children: pageItems(page, count, siblings, boundaries).map((item, i) => /* @__PURE__ */ jsx("li", { children: item === "gap" ? /* @__PURE__ */ jsx("span", {
101
+ className: "slurp-pages-gap",
102
+ "aria-hidden": "true",
103
+ children: "…"
104
+ }) : /* @__PURE__ */ jsx(Fragment, { children: part("item", Tag, {
105
+ ...control(item, disabled),
106
+ className: "slurp-pages-item",
107
+ "aria-label": labels.page(item),
108
+ "aria-current": item === page ? "page" : void 0,
109
+ children: item
110
+ }) }) }, item === "gap" ? `gap-${i}` : item))
111
+ }),
112
+ part("status", "span", {
113
+ className: "slurp-pages-status",
114
+ children: labels.status(page, count)
115
+ }),
116
+ part("next", Tag, {
117
+ ...control(page + 1, disabled || page >= count),
118
+ className: "slurp-pages-step",
119
+ "aria-label": labels.next,
120
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { size: 20 })
121
+ })
122
+ ]
123
+ })
124
+ ] });
125
+ }
126
+ export { PAGES_LABELS, Pages, pageItems };
127
+
128
+ //# sourceMappingURL=Pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pages.js","names":[],"sources":["../../src/Pages/Pages.tsx"],"sourcesContent":["import { ChevronLeftIcon, ChevronRightIcon } from '@slurp-ui/icons';\nimport { cx } from '@slurp-ui/utils';\nimport { Fragment, type ElementType, type MouseEvent } from 'react';\n\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 PagesLabels {\n /** Name of the navigation landmark. */\n label: string;\n previous: string;\n next: string;\n /** Name of a page link (\"Pagina 3\"). */\n page: (page: number) => string;\n /** Where you are, shown on phones instead of the numbers (\"3 di 12\"). */\n status: (page: number, count: number) => string;\n}\n\nexport const PAGES_LABELS: PagesLabels = {\n label: 'Pagine',\n previous: 'Pagina precedente',\n next: 'Pagina successiva',\n page: (n) => `Pagina ${n}`,\n status: (n, count) => `${n} di ${count}`,\n};\n\nexport interface PagesOwnProps extends PartsProps<\n 'list' | 'item' | 'previous' | 'next' | 'status'\n> {\n /** Number of pages. */\n count: number;\n /** Current page, from 1. */\n page?: number;\n /** Default 1. */\n defaultPage?: number;\n onPageChange?: (page: number) => void;\n /** Pages shown on each side of the current one. Default 1. */\n siblings?: number;\n /** Pages always shown at each end. Default 1. */\n boundaries?: number;\n /** URL of a page: the items become links (crawlable, open in a new tab). */\n href?: (page: number) => string;\n disabled?: boolean;\n labels?: Partial<PagesLabels>;\n}\n\nexport type PagesProps<E extends ElementType = 'nav'> = PolymorphicProps<E, PagesOwnProps>;\n\n/** A page number or a gap (\"…\") standing for the pages left out. */\nexport type PageItem = number | 'gap';\n\nconst span = (from: number, to: number) =>\n Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);\n\n/**\n * The items of a pagination: the ends, a window around the current page and a gap where pages are left out. The length\n * stays the same whatever the page, so the controls never jump; a gap never stands for a single page.\n */\nexport function pageItems(page: number, count: number, siblings = 1, boundaries = 1): PageItem[] {\n const slots = 2 * boundaries + 2 * siblings + 3;\n if (count <= slots) return span(1, count);\n const lo = Math.min(\n Math.max(page - siblings, boundaries + 2),\n count - boundaries - 1 - 2 * siblings,\n );\n const hi = lo + 2 * siblings;\n const left: PageItem[] =\n lo === boundaries + 2 ? span(1, boundaries + 1) : [...span(1, boundaries), 'gap'];\n const right: PageItem[] =\n hi === count - boundaries - 1\n ? span(count - boundaries, count)\n : ['gap', ...span(count - boundaries + 1, count)];\n return [...left, ...span(lo, hi), ...right];\n}\n\n/**\n * Pagination: previous, the page numbers (the current one filled, `aria-current=\"page\"`) and next. On phones only\n * previous, \"3 di 12\" and next. With `href` every item is a real link.\n */\nexport function Pages<E extends ElementType = 'nav'>(props: PagesProps<E>) {\n const {\n as,\n css,\n className,\n count: countProp,\n page: pageProp,\n defaultPage = 1,\n onPageChange,\n siblings = 1,\n boundaries = 1,\n href,\n disabled = false,\n labels: labelsProp,\n parts,\n partProps,\n classNames,\n ...rest\n } = useThemeProps('Pages', props as PagesProps);\n const labels = { ...PAGES_LABELS, ...labelsProp };\n const count = Math.max(1, Math.floor(countProp));\n const [raw, setPage] = useControlled({\n value: pageProp,\n defaultValue: defaultPage,\n onChange: onPageChange,\n });\n const page = Math.min(count, Math.max(1, raw));\n const Root = (as ?? 'nav') as ElementType;\n const styled = useCss('Pages', 'root', css);\n const { part, style } = useParts('Pages', { parts, partProps, classNames });\n const root = useAnimationRoot(rest);\n\n /** A link or a button that goes to `to`; unavailable (the ends, disabled) it keeps its place but does nothing. */\n const control = (to: number, off: boolean) => {\n const go = (e: MouseEvent) => {\n if (off) {\n e.preventDefault();\n return;\n }\n if (to !== page) setPage(to);\n };\n if (href) {\n return off\n ? { 'aria-disabled': true, role: 'link', onClick: go }\n : { href: href(to), onClick: go };\n }\n return { type: 'button', disabled: off, onClick: go };\n };\n const Tag = href ? 'a' : 'button';\n\n return (\n <>\n {styled.style}\n {style}\n <Root\n className={cx('slurp-pages', styled.className, className)}\n aria-label={labels.label}\n data-disabled={disabled ? '' : undefined}\n {...root}\n >\n {part('previous', Tag, {\n ...control(page - 1, disabled || page <= 1),\n className: 'slurp-pages-step',\n 'aria-label': labels.previous,\n children: <ChevronLeftIcon size={20} />,\n })}\n {part('list', 'ul', {\n className: 'slurp-pages-list',\n children: pageItems(page, count, siblings, boundaries).map((item, i) => (\n <li key={item === 'gap' ? `gap-${i}` : item}>\n {item === 'gap' ? (\n <span className=\"slurp-pages-gap\" aria-hidden=\"true\">\n …\n </span>\n ) : (\n <Fragment>\n {part('item', Tag, {\n ...control(item, disabled),\n className: 'slurp-pages-item',\n 'aria-label': labels.page(item),\n 'aria-current': item === page ? 'page' : undefined,\n children: item,\n })}\n </Fragment>\n )}\n </li>\n )),\n })}\n {part('status', 'span', {\n className: 'slurp-pages-status',\n children: labels.status(page, count),\n })}\n {part('next', Tag, {\n ...control(page + 1, disabled || page >= count),\n className: 'slurp-pages-step',\n 'aria-label': labels.next,\n children: <ChevronRightIcon size={20} />,\n })}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAa,eAA4B;CACvC,OAAO;CACP,UAAU;CACV,MAAM;CACN,OAAO,MAAM,UAAU;CACvB,SAAS,GAAG,UAAU,GAAG,EAAE,MAAM;AACnC;AA2BA,MAAM,QAAQ,MAAc,OAC1B,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,KAAK,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,OAAO,CAAC;;;;;AAMvE,SAAgB,UAAU,MAAc,OAAe,WAAW,GAAG,aAAa,GAAe;CAE/F,IAAI,SADU,IAAI,aAAa,IAAI,WAAW,GAC1B,OAAO,KAAK,GAAG,KAAK;CACxC,MAAM,KAAK,KAAK,IACd,KAAK,IAAI,OAAO,UAAU,aAAa,CAAC,GACxC,QAAQ,aAAa,IAAI,IAAI,QAC/B;CACA,MAAM,KAAK,KAAK,IAAI;CACpB,MAAM,OACJ,OAAO,aAAa,IAAI,KAAK,GAAG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AGES_LABELS, type PageItem, Pages, type PagesLabels, type PagesProps, Pages as default, pageItems };
@@ -0,0 +1,2 @@
1
+
2
+ export { PAGES_LABELS, Pages, Pages as default, pageItems } from "./Pages.js";
@@ -0,0 +1,36 @@
1
+
2
+ import { PolymorphicProps } from "../lib/polymorphic.js";
3
+ import { ControlSize } from "../Button/Button.js";
4
+ import { ElementType } from "react";
5
+ export interface RatingLabels {
6
+ /** The value as words ("4.5 su 5"): the name of a read-only rating, after its label. */
7
+ value: (value: string, max: number) => string;
8
+ /** Name of one star of the input ("3 stelle"). */
9
+ star: (stars: number) => string;
10
+ }
11
+ export declare const RATING_LABELS: RatingLabels;
12
+ export interface RatingOwnProps {
13
+ /** What is rated ("Il tuo voto", "Valutazione media"): the legend of the input, the name of a read-only rating. */
14
+ label: string;
15
+ /** Stars chosen; null for none yet. A read-only rating may be fractional (4.5). */
16
+ value?: number | null;
17
+ defaultValue?: number | null;
18
+ onValueChange?: (value: number) => void;
19
+ /** Number of stars. Default 5. */
20
+ max?: number;
21
+ /** Shows a value instead of asking for one: one image named "Valutazione media: 4.5 su 5". */
22
+ readOnly?: boolean;
23
+ /** Form field name (radio inputs). */
24
+ name?: string;
25
+ disabled?: boolean;
26
+ /** Star size: `sm` 20, `md` 28 (default), `lg` 36. Each star of the input stays a 44px target. */
27
+ size?: ControlSize;
28
+ labels?: Partial<RatingLabels>;
29
+ }
30
+ export type RatingProps<E extends ElementType = 'fieldset'> = PolymorphicProps<E, RatingOwnProps>;
31
+ /**
32
+ * Stars. As an input it is a group of native radios (arrow keys move and choose, the legend names it): chosen stars
33
+ * are filled, the others outlined (shape, not only colour). Read-only it is one image with the value in words.
34
+ */
35
+ export declare function Rating<E extends ElementType = 'fieldset'>(props: RatingProps<E>): import("react").JSX.Element;
36
+ //# sourceMappingURL=Rating.d.ts.map