@slurp-ui/react 0.0.0-stage → 1.0.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 +84 -0
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/AccentScope/AccentScope.d.ts +15 -0
- package/dist/AccentScope/AccentScope.js +31 -0
- package/dist/AccentScope/AccentScope.js.map +1 -0
- package/dist/AccentScope/index.d.ts +3 -0
- package/dist/AccentScope/index.js +2 -0
- package/dist/Avatar/Avatar.d.ts +17 -0
- package/dist/Avatar/Avatar.js +42 -0
- package/dist/Avatar/Avatar.js.map +1 -0
- package/dist/Avatar/index.d.ts +3 -0
- package/dist/Avatar/index.js +2 -0
- package/dist/Bento/Bento.d.ts +14 -0
- package/dist/Bento/Bento.js +42 -0
- package/dist/Bento/Bento.js.map +1 -0
- package/dist/Bento/index.d.ts +3 -0
- package/dist/Bento/index.js +2 -0
- package/dist/Bloom/Bloom.d.ts +42 -0
- package/dist/Bloom/Bloom.js +183 -0
- package/dist/Bloom/Bloom.js.map +1 -0
- package/dist/Bloom/index.d.ts +3 -0
- package/dist/Bloom/index.js +2 -0
- package/dist/Bubble/Bubble.d.ts +20 -0
- package/dist/Bubble/Bubble.js +30 -0
- package/dist/Bubble/Bubble.js.map +1 -0
- package/dist/Bubble/index.d.ts +3 -0
- package/dist/Bubble/index.js +2 -0
- package/dist/Button/Button.d.ts +26 -0
- package/dist/Button/Button.js +50 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/index.d.ts +3 -0
- package/dist/Button/index.js +2 -0
- package/dist/Card/Card.d.ts +26 -0
- package/dist/Card/Card.js +70 -0
- package/dist/Card/Card.js.map +1 -0
- package/dist/Card/index.d.ts +3 -0
- package/dist/Card/index.js +2 -0
- package/dist/Cell/Cell.d.ts +7 -0
- package/dist/Cell/Cell.js +20 -0
- package/dist/Cell/Cell.js.map +1 -0
- package/dist/Cell/index.d.ts +3 -0
- package/dist/Cell/index.js +2 -0
- package/dist/Checkbox/Checkbox.d.ts +27 -0
- package/dist/Checkbox/Checkbox.js +82 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/index.d.ts +3 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Chip/Chip.d.ts +15 -0
- package/dist/Chip/Chip.js +40 -0
- package/dist/Chip/Chip.js.map +1 -0
- package/dist/Chip/index.d.ts +3 -0
- package/dist/Chip/index.js +2 -0
- package/dist/Choice/Choice.d.ts +37 -0
- package/dist/Choice/Choice.js +134 -0
- package/dist/Choice/Choice.js.map +1 -0
- package/dist/Choice/index.d.ts +3 -0
- package/dist/Choice/index.js +2 -0
- package/dist/Count/Count.d.ts +19 -0
- package/dist/Count/Count.js +30 -0
- package/dist/Count/Count.js.map +1 -0
- package/dist/Count/index.d.ts +3 -0
- package/dist/Count/index.js +2 -0
- package/dist/Dialog/Dialog.d.ts +26 -0
- package/dist/Dialog/Dialog.js +152 -0
- package/dist/Dialog/Dialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +3 -0
- package/dist/Dialog/index.js +2 -0
- package/dist/Dock/Dock.d.ts +124 -0
- package/dist/Dock/Dock.js +359 -0
- package/dist/Dock/Dock.js.map +1 -0
- package/dist/Dock/index.d.ts +3 -0
- package/dist/Dock/index.js +2 -0
- package/dist/Empty/Empty.d.ts +17 -0
- package/dist/Empty/Empty.js +40 -0
- package/dist/Empty/Empty.js.map +1 -0
- package/dist/Empty/index.d.ts +3 -0
- package/dist/Empty/index.js +2 -0
- package/dist/Fact/Fact.d.ts +11 -0
- package/dist/Fact/Fact.js +27 -0
- package/dist/Fact/Fact.js.map +1 -0
- package/dist/Fact/index.d.ts +3 -0
- package/dist/Fact/index.js +2 -0
- package/dist/Field/Field.d.ts +44 -0
- package/dist/Field/Field.js +105 -0
- package/dist/Field/Field.js.map +1 -0
- package/dist/Field/index.d.ts +3 -0
- package/dist/Field/index.js +2 -0
- package/dist/Filters/Filters.d.ts +37 -0
- package/dist/Filters/Filters.js +64 -0
- package/dist/Filters/Filters.js.map +1 -0
- package/dist/Filters/index.d.ts +3 -0
- package/dist/Filters/index.js +2 -0
- package/dist/Flow/Flow.d.ts +17 -0
- package/dist/Flow/Flow.js +26 -0
- package/dist/Flow/Flow.js.map +1 -0
- package/dist/Flow/index.d.ts +3 -0
- package/dist/Flow/index.js +2 -0
- package/dist/Fold/Fold.d.ts +17 -0
- package/dist/Fold/Fold.js +64 -0
- package/dist/Fold/Fold.js.map +1 -0
- package/dist/Fold/index.d.ts +3 -0
- package/dist/Fold/index.js +2 -0
- package/dist/Frame/Frame.d.ts +7 -0
- package/dist/Frame/Frame.js +20 -0
- package/dist/Frame/Frame.js.map +1 -0
- package/dist/Frame/index.d.ts +3 -0
- package/dist/Frame/index.js +2 -0
- package/dist/Ground/Ground.d.ts +7 -0
- package/dist/Ground/Ground.js +19 -0
- package/dist/Ground/Ground.js.map +1 -0
- package/dist/Ground/index.d.ts +3 -0
- package/dist/Ground/index.js +2 -0
- package/dist/Hint/Hint.d.ts +21 -0
- package/dist/Hint/Hint.js +104 -0
- package/dist/Hint/Hint.js.map +1 -0
- package/dist/Hint/index.d.ts +3 -0
- package/dist/Hint/index.js +2 -0
- package/dist/Link/Link.d.ts +7 -0
- package/dist/Link/Link.js +20 -0
- package/dist/Link/Link.js.map +1 -0
- package/dist/Link/index.d.ts +3 -0
- package/dist/Link/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +25 -0
- package/dist/ListRow/ListRow.js +80 -0
- package/dist/ListRow/ListRow.js.map +1 -0
- package/dist/ListRow/index.d.ts +3 -0
- package/dist/ListRow/index.js +2 -0
- package/dist/Mark/Mark.d.ts +14 -0
- package/dist/Mark/Mark.js +28 -0
- package/dist/Mark/Mark.js.map +1 -0
- package/dist/Mark/index.d.ts +3 -0
- package/dist/Mark/index.js +2 -0
- package/dist/Menu/Menu.d.ts +29 -0
- package/dist/Menu/Menu.js +64 -0
- package/dist/Menu/Menu.js.map +1 -0
- package/dist/Menu/index.d.ts +3 -0
- package/dist/Menu/index.js +2 -0
- package/dist/Notice/Notice.d.ts +31 -0
- package/dist/Notice/Notice.js +82 -0
- package/dist/Notice/Notice.js.map +1 -0
- package/dist/Notice/index.d.ts +3 -0
- package/dist/Notice/index.js +2 -0
- package/dist/Placeholder/Placeholder.d.ts +15 -0
- package/dist/Placeholder/Placeholder.js +28 -0
- package/dist/Placeholder/Placeholder.js.map +1 -0
- package/dist/Placeholder/index.d.ts +3 -0
- package/dist/Placeholder/index.js +2 -0
- package/dist/Portal/Portal.d.ts +10 -0
- package/dist/Portal/Portal.js +13 -0
- package/dist/Portal/Portal.js.map +1 -0
- package/dist/Portal/index.d.ts +3 -0
- package/dist/Portal/index.js +2 -0
- package/dist/Progress/Progress.d.ts +22 -0
- package/dist/Progress/Progress.js +65 -0
- package/dist/Progress/Progress.js.map +1 -0
- package/dist/Progress/index.d.ts +3 -0
- package/dist/Progress/index.js +2 -0
- package/dist/Radio/Radio.d.ts +39 -0
- package/dist/Radio/Radio.js +118 -0
- package/dist/Radio/Radio.js.map +1 -0
- package/dist/Radio/index.d.ts +3 -0
- package/dist/Radio/index.js +2 -0
- package/dist/Range/Range.d.ts +26 -0
- package/dist/Range/Range.js +68 -0
- package/dist/Range/Range.js.map +1 -0
- package/dist/Range/index.d.ts +3 -0
- package/dist/Range/index.js +2 -0
- package/dist/ResultRow/ResultRow.d.ts +17 -0
- package/dist/ResultRow/ResultRow.js +46 -0
- package/dist/ResultRow/ResultRow.js.map +1 -0
- package/dist/ResultRow/index.d.ts +3 -0
- package/dist/ResultRow/index.js +2 -0
- package/dist/Score/Score.d.ts +16 -0
- package/dist/Score/Score.js +55 -0
- package/dist/Score/Score.js.map +1 -0
- package/dist/Score/index.d.ts +3 -0
- package/dist/Score/index.js +2 -0
- package/dist/Search/Search.d.ts +29 -0
- package/dist/Search/Search.js +94 -0
- package/dist/Search/Search.js.map +1 -0
- package/dist/Search/index.d.ts +3 -0
- package/dist/Search/index.js +2 -0
- package/dist/Segmented/Segmented.d.ts +24 -0
- package/dist/Segmented/Segmented.js +69 -0
- package/dist/Segmented/Segmented.js.map +1 -0
- package/dist/Segmented/index.d.ts +3 -0
- package/dist/Segmented/index.js +2 -0
- package/dist/Settings/Settings.d.ts +49 -0
- package/dist/Settings/Settings.js +93 -0
- package/dist/Settings/Settings.js.map +1 -0
- package/dist/Settings/index.d.ts +3 -0
- package/dist/Settings/index.js +2 -0
- package/dist/Sheet/Sheet.d.ts +7 -0
- package/dist/Sheet/Sheet.js +11 -0
- package/dist/Sheet/Sheet.js.map +1 -0
- package/dist/Sheet/index.d.ts +3 -0
- package/dist/Sheet/index.js +2 -0
- package/dist/Shelf/Shelf.d.ts +7 -0
- package/dist/Shelf/Shelf.js +23 -0
- package/dist/Shelf/Shelf.js.map +1 -0
- package/dist/Shelf/index.d.ts +3 -0
- package/dist/Shelf/index.js +2 -0
- package/dist/SlurpProvider/ColorSchemeScript.d.ts +15 -0
- package/dist/SlurpProvider/ColorSchemeScript.js +18 -0
- package/dist/SlurpProvider/ColorSchemeScript.js.map +1 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +18 -0
- package/dist/SlurpProvider/SlurpProvider.js +106 -0
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -0
- package/dist/SlurpProvider/index.d.ts +5 -0
- package/dist/SlurpProvider/index.js +5 -0
- package/dist/Stage/Stage.d.ts +14 -0
- package/dist/Stage/Stage.js +38 -0
- package/dist/Stage/Stage.js.map +1 -0
- package/dist/Stage/index.d.ts +3 -0
- package/dist/Stage/index.js +2 -0
- package/dist/Surface/Surface.d.ts +16 -0
- package/dist/Surface/Surface.js +25 -0
- package/dist/Surface/Surface.js.map +1 -0
- package/dist/Surface/index.d.ts +3 -0
- package/dist/Surface/index.js +2 -0
- package/dist/Swatch/Swatch.d.ts +31 -0
- package/dist/Swatch/Swatch.js +72 -0
- package/dist/Swatch/Swatch.js.map +1 -0
- package/dist/Swatch/index.d.ts +3 -0
- package/dist/Swatch/index.js +2 -0
- package/dist/Switch/Switch.d.ts +15 -0
- package/dist/Switch/Switch.js +62 -0
- package/dist/Switch/Switch.js.map +1 -0
- package/dist/Switch/index.d.ts +3 -0
- package/dist/Switch/index.js +2 -0
- package/dist/Tabs/Tabs.d.ts +21 -0
- package/dist/Tabs/Tabs.js +105 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/index.d.ts +3 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Text/Text.d.ts +17 -0
- package/dist/Text/Text.js +33 -0
- package/dist/Text/Text.js.map +1 -0
- package/dist/Text/index.d.ts +3 -0
- package/dist/Text/index.js +2 -0
- package/dist/Tile/Tile.d.ts +25 -0
- package/dist/Tile/Tile.js +67 -0
- package/dist/Tile/Tile.js.map +1 -0
- package/dist/Tile/index.d.ts +3 -0
- package/dist/Tile/index.js +2 -0
- package/dist/Toast/Toast.d.ts +43 -0
- package/dist/Toast/Toast.js +132 -0
- package/dist/Toast/Toast.js.map +1 -0
- package/dist/Toast/index.d.ts +3 -0
- package/dist/Toast/index.js +2 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +7 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +15 -0
- package/dist/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden/index.d.ts +3 -0
- package/dist/VisuallyHidden/index.js +2 -0
- package/dist/fonts/poppins-latin-400-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-500-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-600-normal.woff2 +0 -0
- package/dist/fonts/poppins-latin-700-normal.woff2 +0 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +69 -0
- package/dist/internal/animation.js +26 -0
- package/dist/internal/animation.js.map +1 -0
- package/dist/internal/context.d.ts +14 -0
- package/dist/internal/context.js +21 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/styled.js +79 -0
- package/dist/internal/styled.js.map +1 -0
- package/dist/lib/color.d.ts +21 -0
- package/dist/lib/color.js +151 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/crumb.d.ts +9 -0
- package/dist/lib/crumb.js +69 -0
- package/dist/lib/crumb.js.map +1 -0
- package/dist/lib/css.d.ts +53 -0
- package/dist/lib/css.js +142 -0
- package/dist/lib/css.js.map +1 -0
- package/dist/lib/ground.js +15 -0
- package/dist/lib/ground.js.map +1 -0
- package/dist/lib/layout.d.ts +24 -0
- package/dist/lib/layout.js +88 -0
- package/dist/lib/layout.js.map +1 -0
- package/dist/lib/polymorphic.d.ts +28 -0
- package/dist/lib/theme.d.ts +292 -0
- package/dist/lib/theme.js +90 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/motion/AnimationGroup.d.ts +10 -0
- package/dist/motion/AnimationGroup.js +14 -0
- package/dist/motion/AnimationGroup.js.map +1 -0
- package/dist/motion/context.js +8 -0
- package/dist/motion/context.js.map +1 -0
- package/dist/motion/index.d.ts +7 -0
- package/dist/motion/index.js +7 -0
- package/dist/motion/navigation.d.ts +51 -0
- package/dist/motion/navigation.js +122 -0
- package/dist/motion/navigation.js.map +1 -0
- package/dist/motion/useAnimationTarget.d.ts +22 -0
- package/dist/motion/useAnimationTarget.js +34 -0
- package/dist/motion/useAnimationTarget.js.map +1 -0
- package/dist/motion/useSlurp.d.ts +18 -0
- package/dist/motion/useSlurp.js +48 -0
- package/dist/motion/useSlurp.js.map +1 -0
- package/dist/styles.css +3439 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens.css +178 -0
- package/dist/utils/focus.d.ts +20 -0
- package/dist/utils/focus.js +50 -0
- package/dist/utils/focus.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/src/index.js +9 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/useControlled.d.ts +14 -0
- package/dist/utils/useControlled.js +23 -0
- package/dist/utils/useControlled.js.map +1 -0
- package/dist/utils/useDismiss.d.ts +24 -0
- package/dist/utils/useDismiss.js +60 -0
- package/dist/utils/useDismiss.js.map +1 -0
- package/dist/utils/useFindInPage.d.ts +18 -0
- package/dist/utils/useFindInPage.js +51 -0
- package/dist/utils/useFindInPage.js.map +1 -0
- package/dist/utils/useForkRef.d.ts +5 -0
- package/dist/utils/useForkRef.js +33 -0
- package/dist/utils/useForkRef.js.map +1 -0
- package/dist/utils/useMediaQuery.d.ts +11 -0
- package/dist/utils/useMediaQuery.js +21 -0
- package/dist/utils/useMediaQuery.js.map +1 -0
- package/dist/utils/useRovingFocus.d.ts +17 -0
- package/dist/utils/useRovingFocus.js +26 -0
- package/dist/utils/useRovingFocus.js.map +1 -0
- package/package.json +108 -3
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useForkRef } from "../utils/useForkRef.js";
|
|
4
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
5
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
6
|
+
import { useControlled } from "../utils/useControlled.js";
|
|
7
|
+
import { focusFirst, moveFocus } from "../utils/focus.js";
|
|
8
|
+
import { useDismiss } from "../utils/useDismiss.js";
|
|
9
|
+
import { CRUMB_TAN, crumbPath } from "../lib/crumb.js";
|
|
10
|
+
import { COMPACT_QUERY, useMediaQuery } from "../utils/useMediaQuery.js";
|
|
11
|
+
import { Children, createContext, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal } from "react-dom";
|
|
14
|
+
import { ArrowDownIcon, ArrowLeftIcon, SearchIcon } from "@slurp-ui/icons";
|
|
15
|
+
// src/Dock/Dock.tsx
|
|
16
|
+
const DOCK_LABELS = {
|
|
17
|
+
navigation: "Navigazione",
|
|
18
|
+
crumbs: "Percorso",
|
|
19
|
+
back: "Indietro",
|
|
20
|
+
search: "Cerca",
|
|
21
|
+
searchPlaceholder: "Cerca…",
|
|
22
|
+
noResults: "Nessun risultato",
|
|
23
|
+
matches: (i, n) => `${n === 1 ? "1 corrispondenza" : `${n} corrispondenze`}, ${i} di ${n}`,
|
|
24
|
+
nextMatch: (i, n) => `Vai alla prossima corrispondenza: ${i} di ${n}`,
|
|
25
|
+
resultsHint: "Freccia giù per scorrere i risultati, Esc per chiuderli."
|
|
26
|
+
};
|
|
27
|
+
const DockContext = createContext(null);
|
|
28
|
+
function useDock(name) {
|
|
29
|
+
const ctx = useContext(DockContext);
|
|
30
|
+
if (!ctx) throw new Error(`Slurp: <${name}> goes inside a <Dock>.`);
|
|
31
|
+
return ctx;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The single place to navigate, floating at the bottom: the path as a breadcrumb (back first, then each level), search
|
|
35
|
+
* and actions. One boundary: the bar. Panels (menu, filters, results) grow above it in height; they close on a press
|
|
36
|
+
* outside, Escape or Tab out. On phones earlier crumbs show their icon and search becomes an action.
|
|
37
|
+
*/
|
|
38
|
+
function DockRoot(props) {
|
|
39
|
+
const { as, css, className, children, panel, panelLabel, focusPanel = true, onDismiss, inline = false, labels: labelsProp, ...rest } = useThemeProps("Dock", props);
|
|
40
|
+
const labels = {
|
|
41
|
+
...DOCK_LABELS,
|
|
42
|
+
...labelsProp
|
|
43
|
+
};
|
|
44
|
+
const compact = useMediaQuery(COMPACT_QUERY);
|
|
45
|
+
const [searchOpen, setSearchOpen] = useState(false);
|
|
46
|
+
const [panelInner, setPanelInner] = useState(null);
|
|
47
|
+
const bar = useRef(null);
|
|
48
|
+
const panelRef = useRef(null);
|
|
49
|
+
const searchInput = useRef(null);
|
|
50
|
+
const panelId = `${useId()}-panel`;
|
|
51
|
+
const searching = compact && searchOpen;
|
|
52
|
+
const shown = searching ? null : panel;
|
|
53
|
+
const open = searching || panel != null && panel !== false;
|
|
54
|
+
const Root = as ?? "nav";
|
|
55
|
+
const styled = useCss("Dock", "root", css);
|
|
56
|
+
const root = useAnimationRoot(rest);
|
|
57
|
+
const dismiss = useDismiss({
|
|
58
|
+
ref: bar,
|
|
59
|
+
open,
|
|
60
|
+
onDismiss: () => {
|
|
61
|
+
setSearchOpen(false);
|
|
62
|
+
if (panel != null) onDismiss?.();
|
|
63
|
+
},
|
|
64
|
+
fallbackFocus: () => searchInput.current
|
|
65
|
+
});
|
|
66
|
+
const { opened } = dismiss;
|
|
67
|
+
const hadPanel = useRef(false);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const has = shown != null && shown !== false;
|
|
70
|
+
if (has && !hadPanel.current && focusPanel) {
|
|
71
|
+
if (document.activeElement instanceof HTMLElement) opened(document.activeElement);
|
|
72
|
+
focusFirst(panelRef.current);
|
|
73
|
+
}
|
|
74
|
+
hadPanel.current = has;
|
|
75
|
+
}, [
|
|
76
|
+
shown,
|
|
77
|
+
focusPanel,
|
|
78
|
+
opened
|
|
79
|
+
]);
|
|
80
|
+
const focusResults = () => !!moveFocusFirst(panelRef.current);
|
|
81
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [styled.style, /* @__PURE__ */ jsx(Root, {
|
|
82
|
+
className: cx("slurp-dock-wrap", styled.className, className),
|
|
83
|
+
"data-inline": inline || void 0,
|
|
84
|
+
"aria-label": labels.navigation,
|
|
85
|
+
...root,
|
|
86
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
87
|
+
ref: bar,
|
|
88
|
+
className: "slurp-dock",
|
|
89
|
+
onKeyDown: dismiss.containerProps.onKeyDown,
|
|
90
|
+
onBlur: dismiss.containerProps.onBlur,
|
|
91
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
92
|
+
ref: panelRef,
|
|
93
|
+
id: panelId,
|
|
94
|
+
className: "slurp-dock-panel",
|
|
95
|
+
"data-open": open || void 0,
|
|
96
|
+
role: open ? "region" : void 0,
|
|
97
|
+
"aria-label": open ? searching ? labels.search : panelLabel : void 0,
|
|
98
|
+
inert: !open,
|
|
99
|
+
onKeyDown: (e) => moveFocus(e, panelRef.current, "[data-result]", () => searchInput.current?.focus()),
|
|
100
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
101
|
+
ref: setPanelInner,
|
|
102
|
+
className: "slurp-dock-panel-inner",
|
|
103
|
+
children: shown
|
|
104
|
+
})
|
|
105
|
+
}), /* @__PURE__ */ jsx(DockContext, {
|
|
106
|
+
value: {
|
|
107
|
+
compact,
|
|
108
|
+
labels,
|
|
109
|
+
panelId,
|
|
110
|
+
panelInner,
|
|
111
|
+
hasPanel: shown != null && shown !== false,
|
|
112
|
+
searchOpen: searching,
|
|
113
|
+
setSearchOpen,
|
|
114
|
+
searchInput,
|
|
115
|
+
focusResults
|
|
116
|
+
},
|
|
117
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: "slurp-dock-row",
|
|
119
|
+
children
|
|
120
|
+
})
|
|
121
|
+
})]
|
|
122
|
+
})
|
|
123
|
+
})] });
|
|
124
|
+
}
|
|
125
|
+
function moveFocusFirst(root) {
|
|
126
|
+
const first = root?.querySelector("[data-result]");
|
|
127
|
+
first?.focus();
|
|
128
|
+
return first;
|
|
129
|
+
}
|
|
130
|
+
const CrumbPlace = createContext({
|
|
131
|
+
first: true,
|
|
132
|
+
last: true
|
|
133
|
+
});
|
|
134
|
+
/** The path: Dock.Back first, then a Dock.Crumb per level, the current one last. */
|
|
135
|
+
function DockCrumbs({ children, label }) {
|
|
136
|
+
const { labels } = useDock("Dock.Crumbs");
|
|
137
|
+
const items = Children.toArray(children).filter(isValidElement);
|
|
138
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
139
|
+
className: "slurp-dock-crumbs",
|
|
140
|
+
"aria-label": label ?? labels.crumbs,
|
|
141
|
+
children: items.map((child, i) => /* @__PURE__ */ jsx(CrumbPlace, {
|
|
142
|
+
value: {
|
|
143
|
+
first: i === 0,
|
|
144
|
+
last: i === items.length - 1
|
|
145
|
+
},
|
|
146
|
+
children: /* @__PURE__ */ jsx("li", { children: child })
|
|
147
|
+
}, child.key ?? i))
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/** A crumb button that draws its own shape: it measures itself and renders one SVG path. */
|
|
151
|
+
function CrumbShape({ left, right, className, children, ref, ...rest }) {
|
|
152
|
+
const own = useRef(null);
|
|
153
|
+
const [size, setSize] = useState(null);
|
|
154
|
+
const merged = useForkRef(ref, own);
|
|
155
|
+
useLayoutEffect(() => {
|
|
156
|
+
const el = own.current;
|
|
157
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
158
|
+
const measure = () => setSize((s) => s && s.w === el.offsetWidth && s.h === el.offsetHeight ? s : {
|
|
159
|
+
w: el.offsetWidth,
|
|
160
|
+
h: el.offsetHeight
|
|
161
|
+
});
|
|
162
|
+
measure();
|
|
163
|
+
const ro = new ResizeObserver(measure);
|
|
164
|
+
ro.observe(el);
|
|
165
|
+
return () => ro.disconnect();
|
|
166
|
+
}, []);
|
|
167
|
+
const s = size ? size.h * CRUMB_TAN : 0;
|
|
168
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
169
|
+
ref: merged,
|
|
170
|
+
type: "button",
|
|
171
|
+
className: cx("slurp-crumb", className),
|
|
172
|
+
"data-drawn": size ? "" : void 0,
|
|
173
|
+
"data-left": left,
|
|
174
|
+
"data-right": right,
|
|
175
|
+
...rest,
|
|
176
|
+
children: [size && size.w > 0 && /* @__PURE__ */ jsx("svg", {
|
|
177
|
+
className: "slurp-crumb-shape",
|
|
178
|
+
"aria-hidden": "true",
|
|
179
|
+
width: size.w + s,
|
|
180
|
+
height: size.h,
|
|
181
|
+
viewBox: `0 0 ${size.w + s} ${size.h}`,
|
|
182
|
+
style: { left: -s / 2 },
|
|
183
|
+
children: /* @__PURE__ */ jsx("path", { d: crumbPath(size.w, size.h, left, right) })
|
|
184
|
+
}), children]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/** The back button: the first crumb (the root), round on the left. */
|
|
188
|
+
function DockBack(props) {
|
|
189
|
+
const { label, className, css: _css, ...rest } = props;
|
|
190
|
+
const { labels } = useDock("Dock.Back");
|
|
191
|
+
const { last } = useContext(CrumbPlace);
|
|
192
|
+
const root = useAnimationRoot(rest);
|
|
193
|
+
return /* @__PURE__ */ jsx(CrumbShape, {
|
|
194
|
+
left: "round",
|
|
195
|
+
right: last ? "round" : "slant",
|
|
196
|
+
className: cx("slurp-crumb-back", className),
|
|
197
|
+
"aria-label": label ?? labels.back,
|
|
198
|
+
"data-crumb": "0",
|
|
199
|
+
...root,
|
|
200
|
+
children: /* @__PURE__ */ jsx(ArrowLeftIcon, {})
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/** A level of the path. Every crumb triggers the transition: give it an animationId. */
|
|
204
|
+
function DockCrumb(props) {
|
|
205
|
+
const { children, current = false, icon, expanded, className, css: _css, ...rest } = props;
|
|
206
|
+
const { compact, panelId } = useDock("Dock.Crumb");
|
|
207
|
+
const { first, last } = useContext(CrumbPlace);
|
|
208
|
+
const root = useAnimationRoot(rest);
|
|
209
|
+
const iconOnly = compact && !current && icon != null;
|
|
210
|
+
const name = typeof children === "string" ? children : void 0;
|
|
211
|
+
return /* @__PURE__ */ jsxs(CrumbShape, {
|
|
212
|
+
left: first ? "round" : "slant",
|
|
213
|
+
right: last ? "round" : "slant",
|
|
214
|
+
className,
|
|
215
|
+
"data-current": current || void 0,
|
|
216
|
+
"data-icon": iconOnly || void 0,
|
|
217
|
+
"aria-current": current ? "page" : void 0,
|
|
218
|
+
"aria-label": iconOnly ? name : void 0,
|
|
219
|
+
title: iconOnly ? name : void 0,
|
|
220
|
+
"aria-expanded": expanded,
|
|
221
|
+
"aria-controls": expanded !== void 0 ? panelId : void 0,
|
|
222
|
+
...root,
|
|
223
|
+
children: [iconOnly ? /* @__PURE__ */ jsx("span", {
|
|
224
|
+
className: "slurp-crumb-icon",
|
|
225
|
+
"aria-hidden": "true",
|
|
226
|
+
children: icon
|
|
227
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
228
|
+
className: "slurp-crumb-label",
|
|
229
|
+
children
|
|
230
|
+
}), expanded !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
231
|
+
className: "slurp-crumb-arrow",
|
|
232
|
+
"data-up": expanded || void 0,
|
|
233
|
+
"aria-hidden": "true",
|
|
234
|
+
children: /* @__PURE__ */ jsx(ArrowDownIcon, { size: 16 })
|
|
235
|
+
})]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** The one search field, scoped by context. On phones it is an action that opens the field in the panel. */
|
|
239
|
+
function DockSearch({ value: valueProp, defaultValue = "", onValueChange, label, placeholder, onSearch, count, index = 0, onStep }) {
|
|
240
|
+
const ctx = useDock("Dock.Search");
|
|
241
|
+
const { labels } = ctx;
|
|
242
|
+
const [value, setValue] = useControlled({
|
|
243
|
+
value: valueProp,
|
|
244
|
+
defaultValue,
|
|
245
|
+
onChange: onValueChange
|
|
246
|
+
});
|
|
247
|
+
const name = label ?? labels.search;
|
|
248
|
+
const typed = value.trim() !== "";
|
|
249
|
+
const counter = count != null && typed ? /* @__PURE__ */ jsxs(Fragment$1, { children: [count ? /* @__PURE__ */ jsxs("button", {
|
|
250
|
+
type: "button",
|
|
251
|
+
className: "slurp-dock-search-count",
|
|
252
|
+
"aria-label": labels.nextMatch(index + 1, count),
|
|
253
|
+
onClick: (e) => {
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
onStep?.(1);
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
index + 1,
|
|
259
|
+
"/",
|
|
260
|
+
count
|
|
261
|
+
]
|
|
262
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
263
|
+
className: "slurp-dock-search-count",
|
|
264
|
+
"data-empty": "",
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
children: labels.noResults
|
|
267
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
268
|
+
className: "slurp-visually-hidden",
|
|
269
|
+
role: "status",
|
|
270
|
+
children: count ? labels.matches(index + 1, count) : labels.noResults
|
|
271
|
+
})] }) : null;
|
|
272
|
+
const field = (inPanel) => /* @__PURE__ */ jsxs("label", {
|
|
273
|
+
className: "slurp-dock-search",
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx(SearchIcon, { size: 18 }),
|
|
276
|
+
/* @__PURE__ */ jsx("span", {
|
|
277
|
+
className: "slurp-visually-hidden",
|
|
278
|
+
children: name
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ jsx("input", {
|
|
281
|
+
ref: ctx.searchInput,
|
|
282
|
+
type: "search",
|
|
283
|
+
value,
|
|
284
|
+
placeholder: placeholder ?? labels.searchPlaceholder,
|
|
285
|
+
enterKeyHint: onStep ? "next" : "search",
|
|
286
|
+
autoComplete: "off",
|
|
287
|
+
autoFocus: inPanel,
|
|
288
|
+
"aria-controls": ctx.hasPanel ? ctx.panelId : void 0,
|
|
289
|
+
onChange: (e) => setValue(e.target.value),
|
|
290
|
+
onKeyDown: (e) => {
|
|
291
|
+
if (e.key === "Enter") {
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
if (onStep) onStep(e.shiftKey ? -1 : 1);
|
|
294
|
+
else onSearch?.(value);
|
|
295
|
+
} else if (e.key === "ArrowDown" && ctx.hasPanel && ctx.focusResults()) e.preventDefault();
|
|
296
|
+
}
|
|
297
|
+
}),
|
|
298
|
+
counter
|
|
299
|
+
]
|
|
300
|
+
});
|
|
301
|
+
if (!ctx.compact) return field(false);
|
|
302
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(DockAction, {
|
|
303
|
+
label: typed ? `${name}: “${value.trim()}”` : name,
|
|
304
|
+
expanded: ctx.searchOpen,
|
|
305
|
+
dot: typed && !ctx.searchOpen,
|
|
306
|
+
onClick: () => ctx.setSearchOpen(!ctx.searchOpen),
|
|
307
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
308
|
+
}), ctx.searchOpen && ctx.panelInner && createPortal(field(true), ctx.panelInner)] });
|
|
309
|
+
}
|
|
310
|
+
/** Actions at the right end of the bar (search before filters). */
|
|
311
|
+
function DockActions({ children }) {
|
|
312
|
+
return /* @__PURE__ */ jsx("div", {
|
|
313
|
+
className: "slurp-dock-actions",
|
|
314
|
+
children
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/** Round 48px action of the bar (filters, the phone search). */
|
|
318
|
+
function DockAction(props) {
|
|
319
|
+
const { label, children, expanded, count, countLabel = (n) => n === 1 ? "1 attivo" : `${n} attivi`, dot, className, css: _css, onClick, ...rest } = props;
|
|
320
|
+
const { panelId } = useDock("Dock.Action");
|
|
321
|
+
const root = useAnimationRoot(rest);
|
|
322
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
323
|
+
type: "button",
|
|
324
|
+
className: cx("slurp-dock-action", className),
|
|
325
|
+
"data-active": expanded || void 0,
|
|
326
|
+
"aria-label": count ? `${label}, ${countLabel(count)}` : label,
|
|
327
|
+
"aria-expanded": expanded,
|
|
328
|
+
"aria-controls": expanded !== void 0 ? panelId : void 0,
|
|
329
|
+
onClick,
|
|
330
|
+
...root,
|
|
331
|
+
children: [
|
|
332
|
+
/* @__PURE__ */ jsx("span", {
|
|
333
|
+
"aria-hidden": "true",
|
|
334
|
+
className: "slurp-dock-action-icon",
|
|
335
|
+
children
|
|
336
|
+
}),
|
|
337
|
+
count ? /* @__PURE__ */ jsx("span", {
|
|
338
|
+
className: "slurp-dock-action-count",
|
|
339
|
+
"aria-hidden": "true",
|
|
340
|
+
children: count
|
|
341
|
+
}) : null,
|
|
342
|
+
dot ? /* @__PURE__ */ jsx("span", {
|
|
343
|
+
className: "slurp-dock-action-dot",
|
|
344
|
+
"aria-hidden": "true"
|
|
345
|
+
}) : null
|
|
346
|
+
]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const Dock = Object.assign(DockRoot, {
|
|
350
|
+
Crumbs: DockCrumbs,
|
|
351
|
+
Back: DockBack,
|
|
352
|
+
Crumb: DockCrumb,
|
|
353
|
+
Search: DockSearch,
|
|
354
|
+
Actions: DockActions,
|
|
355
|
+
Action: DockAction
|
|
356
|
+
});
|
|
357
|
+
export { DOCK_LABELS, Dock, DockAction, DockActions, DockBack, DockCrumb, DockCrumbs, DockSearch };
|
|
358
|
+
|
|
359
|
+
//# sourceMappingURL=Dock.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;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C,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"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { DOCK_LABELS, Dock, DockAction, DockActionProps, DockActions, DockBack, DockBackProps, DockCrumb, DockCrumbProps, DockCrumbs, DockCrumbsProps, DockLabels, DockProps, DockSearch, DockSearchProps } from "./Dock.js";
|
|
3
|
+
export { DOCK_LABELS, Dock, DockAction, type DockActionProps, DockActions, DockBack, type DockBackProps, DockCrumb, type DockCrumbProps, DockCrumbs, type DockCrumbsProps, type DockLabels, type DockProps, DockSearch, type DockSearchProps, Dock as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface EmptyOwnProps {
|
|
5
|
+
/** What happened ("Nessun risultato"). */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/** Why, or what to try. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** One action only ("Azzera filtri"). */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
/** A decorative illustration. */
|
|
12
|
+
media?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export type EmptyProps<E extends ElementType = 'div'> = PolymorphicProps<E, EmptyOwnProps>;
|
|
15
|
+
/** Empty state: a message and a single way out. Announced politely when it appears (`role="status"`). */
|
|
16
|
+
export declare function Empty<E extends ElementType = 'div'>(props: EmptyProps<E>): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=Empty.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Empty/Empty.tsx
|
|
7
|
+
/** Empty state: a message and a single way out. Announced politely when it appears (`role="status"`). */
|
|
8
|
+
function Empty(props) {
|
|
9
|
+
const { as, css, className, title, description, action, media, ...rest } = useThemeProps("Empty", props);
|
|
10
|
+
const Root = as ?? "div";
|
|
11
|
+
const styled = useCss("Empty", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
14
|
+
className: cx("slurp-empty", styled.className, className),
|
|
15
|
+
role: "status",
|
|
16
|
+
...root,
|
|
17
|
+
children: [
|
|
18
|
+
media != null && /* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: "slurp-empty-media",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: media
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx("p", {
|
|
24
|
+
className: "slurp-empty-title",
|
|
25
|
+
children: title
|
|
26
|
+
}),
|
|
27
|
+
description != null && /* @__PURE__ */ jsx("p", {
|
|
28
|
+
className: "slurp-empty-description",
|
|
29
|
+
children: description
|
|
30
|
+
}),
|
|
31
|
+
action != null && /* @__PURE__ */ jsx("div", {
|
|
32
|
+
className: "slurp-empty-action",
|
|
33
|
+
children: action
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
})] });
|
|
37
|
+
}
|
|
38
|
+
export { Empty };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=Empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Empty.js","names":[],"sources":["../../src/Empty/Empty.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface EmptyOwnProps {\n /** What happened (\"Nessun risultato\"). */\n title: ReactNode;\n /** Why, or what to try. */\n description?: ReactNode;\n /** One action only (\"Azzera filtri\"). */\n action?: ReactNode;\n /** A decorative illustration. */\n media?: ReactNode;\n}\n\nexport type EmptyProps<E extends ElementType = 'div'> = PolymorphicProps<E, EmptyOwnProps>;\n\n/** Empty state: a message and a single way out. Announced politely when it appears (`role=\"status\"`). */\nexport function Empty<E extends ElementType = 'div'>(props: EmptyProps<E>) {\n const { as, css, className, title, description, action, media, ...rest } = useThemeProps(\n 'Empty',\n props as EmptyProps,\n );\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Empty', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-empty', styled.className, className)} role=\"status\" {...root}>\n {media != null && (\n <span className=\"slurp-empty-media\" aria-hidden=\"true\">\n {media}\n </span>\n )}\n <p className=\"slurp-empty-title\">{title}</p>\n {description != null && <p className=\"slurp-empty-description\">{description}</p>}\n {action != null && <div className=\"slurp-empty-action\">{action}</div>}\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAgB,MAAqC,OAAsB;CACzE,MAAM,EAAE,IAAI,KAAK,WAAW,OAAO,aAAa,QAAQ,OAAO,GAAG,SAAS,cACzE,SACA,KACF;CACA,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,SAAS,QAAQ,GAAG;CAC1C,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EAAM,WAAW,GAAG,eAAe,OAAO,WAAW,SAAS;EAAG,MAAK;EAAS,GAAI;EAAnF,UAAA;GACG,SAAS,QACR,oBAAC,QAAD;IAAM,WAAU;IAAoB,eAAY;IAC7C,UAAA;GACG,CAAA;GAER,oBAAC,KAAD;IAAG,WAAU;IAAqB,UAAA;GAAS,CAAA;GAC1C,eAAe,QAAQ,oBAAC,KAAD;IAAG,WAAU;IAA2B,UAAA;GAAe,CAAA;GAC9E,UAAU,QAAQ,oBAAC,OAAD;IAAK,WAAU;IAAsB,UAAA;GAAY,CAAA;EAChE;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import { PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ElementType, ReactNode } from "react";
|
|
4
|
+
export interface FactOwnProps {
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
value: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export type FactProps<E extends ElementType = 'div'> = PolymorphicProps<E, FactOwnProps>;
|
|
9
|
+
/** A label/value pair as one soft pill: specs and key facts on detail pages, instead of boxed panels. */
|
|
10
|
+
export declare function Fact<E extends ElementType = 'div'>(props: FactProps<E>): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=Fact.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/src/index.js";
|
|
3
|
+
import { useAnimationRoot } from "../internal/animation.js";
|
|
4
|
+
import { useCss, useThemeProps } from "../internal/styled.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/Fact/Fact.tsx
|
|
7
|
+
/** A label/value pair as one soft pill: specs and key facts on detail pages, instead of boxed panels. */
|
|
8
|
+
function Fact(props) {
|
|
9
|
+
const { as, css, className, label, value, ...rest } = useThemeProps("Fact", props);
|
|
10
|
+
const Root = as ?? "div";
|
|
11
|
+
const styled = useCss("Fact", "root", css);
|
|
12
|
+
const root = useAnimationRoot(rest);
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [styled.style, /* @__PURE__ */ jsxs(Root, {
|
|
14
|
+
className: cx("slurp-fact", styled.className, className),
|
|
15
|
+
...root,
|
|
16
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
17
|
+
className: "slurp-fact-label",
|
|
18
|
+
children: label
|
|
19
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
20
|
+
className: "slurp-fact-value",
|
|
21
|
+
children: value
|
|
22
|
+
})]
|
|
23
|
+
})] });
|
|
24
|
+
}
|
|
25
|
+
export { Fact };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=Fact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fact.js","names":[],"sources":["../../src/Fact/Fact.tsx"],"sourcesContent":["import { cx } from '@slurp-ui/utils';\nimport type { ElementType, ReactNode } from 'react';\n\nimport { useAnimationRoot } from '../internal/animation';\nimport { useCss, useThemeProps } from '../internal/styled';\nimport type { PolymorphicProps } from '../lib/polymorphic';\n\nexport interface FactOwnProps {\n label: ReactNode;\n value: ReactNode;\n}\n\nexport type FactProps<E extends ElementType = 'div'> = PolymorphicProps<E, FactOwnProps>;\n\n/** A label/value pair as one soft pill: specs and key facts on detail pages, instead of boxed panels. */\nexport function Fact<E extends ElementType = 'div'>(props: FactProps<E>) {\n const { as, css, className, label, value, ...rest } = useThemeProps('Fact', props as FactProps);\n const Root = (as ?? 'div') as ElementType;\n const styled = useCss('Fact', 'root', css);\n const root = useAnimationRoot(rest);\n return (\n <>\n {styled.style}\n <Root className={cx('slurp-fact', styled.className, className)} {...root}>\n <span className=\"slurp-fact-label\">{label}</span>\n <span className=\"slurp-fact-value\">{value}</span>\n </Root>\n </>\n );\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,KAAoC,OAAqB;CACvE,MAAM,EAAE,IAAI,KAAK,WAAW,OAAO,OAAO,GAAG,SAAS,cAAc,QAAQ,KAAkB;CAC9F,MAAM,OAAQ,MAAM;CACpB,MAAM,SAAS,OAAO,QAAQ,QAAQ,GAAG;CACzC,MAAM,OAAO,iBAAiB,IAAI;CAClC,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,OAAO,OACR,qBAAC,MAAD;EAAM,WAAW,GAAG,cAAc,OAAO,WAAW,SAAS;EAAG,GAAI;EAApE,UAAA,CACE,oBAAC,QAAD;GAAM,WAAU;GAAoB,UAAA;EAAY,CAAA,GAChD,oBAAC,QAAD;GAAM,WAAU;GAAoB,UAAA;EAAY,CAAA,CAC5C;CACN,CAAA,CAAA,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import { PartsProps, PolymorphicProps } from "../lib/polymorphic.js";
|
|
3
|
+
import { ChangeEvent, ElementType, FocusEventHandler, HTMLInputTypeAttribute, KeyboardEventHandler, ReactNode } from "react";
|
|
4
|
+
/** Props that belong to the native input (the rest goes to the root, like every component). */
|
|
5
|
+
export interface InputAttributes {
|
|
6
|
+
name?: string;
|
|
7
|
+
type?: HTMLInputTypeAttribute;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
autoComplete?: string;
|
|
10
|
+
autoFocus?: boolean;
|
|
11
|
+
inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
|
|
12
|
+
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
minLength?: number;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
spellCheck?: boolean;
|
|
20
|
+
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
21
|
+
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
22
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
23
|
+
}
|
|
24
|
+
export interface FieldOwnProps extends InputAttributes, PartsProps<'label' | 'control' | 'hint' | 'error'> {
|
|
25
|
+
/** Visible label (always: placeholders are not labels). */
|
|
26
|
+
label: ReactNode;
|
|
27
|
+
/** Help text under the field, linked with aria-describedby. */
|
|
28
|
+
hint?: ReactNode;
|
|
29
|
+
/** Error message: marks the field invalid and shows the message with an icon. */
|
|
30
|
+
error?: ReactNode;
|
|
31
|
+
value?: string;
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
onValueChange?: (value: string, event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
34
|
+
/** A textarea instead of an input. */
|
|
35
|
+
multiline?: boolean;
|
|
36
|
+
/** Rows of the textarea. Default 3. */
|
|
37
|
+
rows?: number;
|
|
38
|
+
/** id of the input (generated by default). */
|
|
39
|
+
id?: string;
|
|
40
|
+
}
|
|
41
|
+
export type FieldProps<E extends ElementType = 'div'> = PolymorphicProps<E, FieldOwnProps>;
|
|
42
|
+
/** Text field: label, input (boundary `border-control`, 3:1), hint and error, wired for assistive tech. */
|
|
43
|
+
export declare function Field<E extends ElementType = 'div'>(props: FieldProps<E>): import("react").JSX.Element;
|
|
44
|
+
//# sourceMappingURL=Field.d.ts.map
|