@plexui/ui 0.36.0 → 0.37.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/dist/es/components/DateInput/DateInput.js +29 -30
- package/dist/es/components/DateInput/DateInput.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +14 -8
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/lib/dateInputText.js +201 -0
- package/dist/es/lib/dateInputText.js.map +1 -0
- package/dist/es/lib/phoneDrawer.js +27 -0
- package/dist/es/lib/phoneDrawer.js.map +1 -1
- package/dist/types/components/DateInput/DateInput.d.ts +1 -1
- package/dist/types/lib/dateInputText.d.ts +54 -0
- package/dist/types/lib/phoneDrawer.d.ts +7 -0
- package/package.json +2 -2
|
@@ -1,51 +1,50 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { maskitoDateOptionsGenerator, maskitoDateTimeOptionsGenerator,
|
|
3
|
+
import { maskitoDateOptionsGenerator, maskitoDateTimeOptionsGenerator, } from "@maskito/kit";
|
|
4
4
|
import { useMaskito } from "@maskito/react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {} from "luxon";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
7
|
import { mergeRefs } from "react-merge-refs";
|
|
8
|
+
import { dateInputValueKey, dateInputZone, formatDateInput, keepTypedValue, maskDate, parseDateInput, } from "../../lib/dateInputText.js";
|
|
8
9
|
import { Input } from "../Input/index.js";
|
|
9
10
|
export const DateInput = (props) => {
|
|
10
11
|
const { value, onChange, mode = "dd/mm/yyyy", separator = ".", timeMode, dateTimeSeparator = ", ", timeStep = 0, min, max, clearable = false, placeholder, inputMode, onBlur, ref, ...inputProps } = props;
|
|
11
12
|
const hasTime = !!timeMode;
|
|
13
|
+
// The value's text is made from its own fields in its own zone (lib/dateInputText),
|
|
14
|
+
// so these are keys, not the DateTime objects
|
|
15
|
+
const zone = dateInputZone(value);
|
|
16
|
+
const minMs = min?.toMillis();
|
|
17
|
+
const maxMs = max?.toMillis();
|
|
18
|
+
const textFormat = useMemo(() => ({ mode, separator, timeMode, dateTimeSeparator, min: minMs, max: maxMs, zone }), [mode, separator, timeMode, dateTimeSeparator, minMs, maxMs, zone]);
|
|
12
19
|
const dateParams = useMemo(() => ({
|
|
13
20
|
mode,
|
|
14
21
|
separator,
|
|
15
|
-
...(
|
|
16
|
-
...(
|
|
17
|
-
}),
|
|
18
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
[mode, separator, min?.toMillis(), max?.toMillis()]);
|
|
22
|
+
...(minMs !== undefined ? { min: maskDate(minMs, zone) } : undefined),
|
|
23
|
+
...(maxMs !== undefined ? { max: maskDate(maxMs, zone) } : undefined),
|
|
24
|
+
}), [mode, separator, minMs, maxMs, zone]);
|
|
20
25
|
const dateTimeParams = useMemo(() => ({
|
|
21
26
|
dateMode: mode,
|
|
22
27
|
dateSeparator: separator,
|
|
23
28
|
timeMode: timeMode ?? "HH:MM",
|
|
24
29
|
dateTimeSeparator,
|
|
25
30
|
...(timeStep ? { timeStep } : undefined),
|
|
26
|
-
...(
|
|
27
|
-
...(
|
|
28
|
-
}),
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
const maskOptions = useMemo(() => hasTime
|
|
32
|
-
? maskitoDateTimeOptionsGenerator(dateTimeParams)
|
|
33
|
-
: maskitoDateOptionsGenerator(dateParams), [hasTime, dateParams, dateTimeParams]);
|
|
31
|
+
...(minMs !== undefined ? { min: maskDate(minMs, zone) } : undefined),
|
|
32
|
+
...(maxMs !== undefined ? { max: maskDate(maxMs, zone) } : undefined),
|
|
33
|
+
}), [mode, separator, timeMode, dateTimeSeparator, timeStep, minMs, maxMs, zone]);
|
|
34
|
+
// The mask shows a complete text as the value reads it (lib/dateInputText)
|
|
35
|
+
const maskOptions = useMemo(() => keepTypedValue(hasTime ? maskitoDateTimeOptionsGenerator(dateTimeParams) : maskitoDateOptionsGenerator(dateParams), textFormat), [hasTime, dateParams, dateTimeParams, textFormat]);
|
|
34
36
|
const maskRef = useMaskito({ options: maskOptions });
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const valueMsKey = value?.toMillis() ?? null;
|
|
45
|
-
useEffect(() => {
|
|
37
|
+
const format = (date) => formatDateInput(date, textFormat);
|
|
38
|
+
const parse = (str) => parseDateInput(str, textFormat);
|
|
39
|
+
// The first render, on the server too, already shows the value. A new value
|
|
40
|
+
// or format shows it again during the render, so no frame has the old text
|
|
41
|
+
const syncKey = [dateInputValueKey(value), mode, separator, timeMode, dateTimeSeparator, timeStep, minMs, maxMs].join("|");
|
|
42
|
+
const [inputValue, setInputValue] = useState(() => format(value));
|
|
43
|
+
const [shownKey, setShownKey] = useState(syncKey);
|
|
44
|
+
if (shownKey !== syncKey) {
|
|
45
|
+
setShownKey(syncKey);
|
|
46
46
|
setInputValue(format(value));
|
|
47
|
-
|
|
48
|
-
}, [valueMsKey, hasTime, dateParams, dateTimeParams]);
|
|
47
|
+
}
|
|
49
48
|
const handleInput = (evt) => {
|
|
50
49
|
const str = evt.currentTarget.value;
|
|
51
50
|
setInputValue(str);
|
|
@@ -55,7 +54,7 @@ export const DateInput = (props) => {
|
|
|
55
54
|
}
|
|
56
55
|
const parsed = parse(str);
|
|
57
56
|
if (parsed) {
|
|
58
|
-
onChange(
|
|
57
|
+
onChange(parsed);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
// Text that is not a complete date never reaches onChange, so leaving the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components/DateInput/DateInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,
|
|
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AAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,EACvE,GAAG,EAAE,SAAS,CAAC,CAAC,OAAiD,EAAE,GAAG,CAAC,CAAC,EACxE,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,WAAW,IAAI,kBAAkB,EAC9C,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,GAC5C,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport {\n maskitoDateOptionsGenerator,\n maskitoDateTimeOptionsGenerator,\n type MaskitoDateMode,\n type MaskitoDateParams,\n type MaskitoDateTimeParams,\n type MaskitoTimeMode,\n} from \"@maskito/kit\"\nimport { useMaskito } from \"@maskito/react\"\nimport { type DateTime } from \"luxon\"\nimport { useMemo, useState } from \"react\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport {\n dateInputValueKey,\n dateInputZone,\n formatDateInput,\n keepTypedValue,\n maskDate,\n parseDateInput,\n type DateInputFormat,\n} from \"../../lib/dateInputText\"\nimport { Input, type InputProps } from \"../Input\"\n\nexport type DateInputProps = {\n value: DateTime | null\n onChange: (value: DateTime | null) => void\n mode?: MaskitoDateMode\n separator?: string\n timeMode?: MaskitoTimeMode\n dateTimeSeparator?: string\n timeStep?: number\n min?: DateTime\n max?: DateTime\n clearable?: boolean\n ref?: React.Ref<HTMLInputElement | null>\n} & Omit<\n InputProps,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onInput\" | \"onClear\" | \"ref\" | \"type\" | \"min\" | \"max\"\n>\n\nexport const DateInput = (props: DateInputProps) => {\n const {\n value,\n onChange,\n mode = \"dd/mm/yyyy\",\n separator = \".\",\n timeMode,\n dateTimeSeparator = \", \",\n timeStep = 0,\n min,\n max,\n clearable = false,\n placeholder,\n inputMode,\n onBlur,\n ref,\n ...inputProps\n } = props\n\n const hasTime = !!timeMode\n // The value's text is made from its own fields in its own zone (lib/dateInputText),\n // so these are keys, not the DateTime objects\n const zone = dateInputZone(value)\n const minMs = min?.toMillis()\n const maxMs = max?.toMillis()\n\n const textFormat = useMemo<DateInputFormat>(\n () => ({ mode, separator, timeMode, dateTimeSeparator, min: minMs, max: maxMs, zone }),\n [mode, separator, timeMode, dateTimeSeparator, minMs, maxMs, zone],\n )\n const dateParams = useMemo<MaskitoDateParams>(\n () => ({\n mode,\n separator,\n ...(minMs !== undefined ? { min: maskDate(minMs, zone) } : undefined),\n ...(maxMs !== undefined ? { max: maskDate(maxMs, zone) } : undefined),\n }),\n [mode, separator, minMs, maxMs, zone],\n )\n\n const dateTimeParams = useMemo<MaskitoDateTimeParams>(\n () => ({\n dateMode: mode,\n dateSeparator: separator,\n timeMode: timeMode ?? \"HH:MM\",\n dateTimeSeparator,\n ...(timeStep ? { timeStep } : undefined),\n ...(minMs !== undefined ? { min: maskDate(minMs, zone) } : undefined),\n ...(maxMs !== undefined ? { max: maskDate(maxMs, zone) } : undefined),\n }),\n [mode, separator, timeMode, dateTimeSeparator, timeStep, minMs, maxMs, zone],\n )\n\n // The mask shows a complete text as the value reads it (lib/dateInputText)\n const maskOptions = useMemo(\n () =>\n keepTypedValue(\n hasTime ? maskitoDateTimeOptionsGenerator(dateTimeParams) : maskitoDateOptionsGenerator(dateParams),\n textFormat,\n ),\n [hasTime, dateParams, dateTimeParams, textFormat],\n )\n\n const maskRef = useMaskito({ options: maskOptions })\n\n const format = (date: DateTime | null) => formatDateInput(date, textFormat)\n const parse = (str: string) => parseDateInput(str, textFormat)\n\n // The first render, on the server too, already shows the value. A new value\n // or format shows it again during the render, so no frame has the old text\n const syncKey = [dateInputValueKey(value), mode, separator, timeMode, dateTimeSeparator, timeStep, minMs, maxMs].join(\"|\")\n const [inputValue, setInputValue] = useState(() => format(value))\n const [shownKey, setShownKey] = useState(syncKey)\n if (shownKey !== syncKey) {\n setShownKey(syncKey)\n setInputValue(format(value))\n }\n\n const handleInput = (evt: React.FormEvent<HTMLInputElement>) => {\n const str = evt.currentTarget.value\n setInputValue(str)\n\n if (!str) {\n onChange(null)\n return\n }\n\n const parsed = parse(str)\n\n if (parsed) {\n onChange(parsed)\n }\n }\n\n // Text that is not a complete date never reaches onChange, so leaving the\n // field shows the value again instead of a date the value does not hold\n const handleBlur = (evt: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(evt)\n if (inputValue && !parse(inputValue)) {\n setInputValue(format(value))\n }\n }\n\n const handleClear = () => {\n setInputValue(\"\")\n onChange(null)\n }\n\n const defaultPlaceholder = useMemo(() => {\n const datePart = mode.replace(/\\//g, separator).toUpperCase()\n if (!hasTime) return datePart\n return `${datePart}${dateTimeSeparator}${timeMode}`\n }, [mode, separator, hasTime, timeMode, dateTimeSeparator])\n\n return (\n <Input\n {...inputProps}\n // Maskito inserts separators; only the AM/PM segment needs letters.\n inputMode={inputMode ?? (timeMode?.includes(\"AA\") ? \"text\" : \"numeric\")}\n ref={mergeRefs([maskRef as unknown as React.Ref<HTMLInputElement>, ref])}\n value={inputValue}\n onInput={handleInput}\n onBlur={handleBlur}\n placeholder={placeholder ?? defaultPlaceholder}\n onClear={clearable ? handleClear : undefined}\n />\n )\n}\n"]}
|
|
@@ -73,7 +73,7 @@ import { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIco
|
|
|
73
73
|
import { Input } from "../Input/index.js";
|
|
74
74
|
import { Tooltip } from "../Tooltip/index.js";
|
|
75
75
|
import s from "@plexui/styles/components/Sidebar/Sidebar.module.css";
|
|
76
|
-
import { attachDrawerSwipe, closeOnUnhandledEscape, drawerInitialFocus, loopDrawerFocus } from "../../lib/phoneDrawer.js";
|
|
76
|
+
import { attachDrawerSwipe, closeOnUnhandledEscape, drawerInitialFocus, returnDrawerFocus, loopDrawerFocus, } from "../../lib/phoneDrawer.js";
|
|
77
77
|
import { SidebarProvider, useSidebar, } from "./useSidebarContext.js";
|
|
78
78
|
// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)
|
|
79
79
|
const cleanProps = (props) => {
|
|
@@ -248,7 +248,7 @@ export const SidebarTrigger = forwardRef(({ className, children, onClick, ...pro
|
|
|
248
248
|
SidebarTrigger.displayName = "SidebarTrigger";
|
|
249
249
|
export const SidebarMobileMenuButton = forwardRef(({ className, onClick, ...props }, ref) => {
|
|
250
250
|
const { openMobile, setOpenMobile } = useSidebar();
|
|
251
|
-
return (_jsx("button", { ref: ref, type: "button", "data-expanded": openMobile ? "" : undefined, className: clsx(s.MobileMenuButton, className), onClick: (event) => {
|
|
251
|
+
return (_jsx("button", { ref: ref, type: "button", "data-expanded": openMobile ? "" : undefined, "data-sidebar-mobile-menu-button": "", className: clsx(s.MobileMenuButton, className), onClick: (event) => {
|
|
252
252
|
// The caller's handler runs first and can cancel the toggle
|
|
253
253
|
onClick?.(event);
|
|
254
254
|
if (!event.defaultPrevented)
|
|
@@ -265,24 +265,30 @@ SidebarMobileMenuButton.displayName = "SidebarMobileMenuButton";
|
|
|
265
265
|
export const SidebarMobile = forwardRef(({ className, children, contained, disclosure = true, onKeyDown, ...props }, ref) => {
|
|
266
266
|
const { isMobile, openMobile, setOpenMobile } = useSidebar();
|
|
267
267
|
const drawerRef = useRef(null);
|
|
268
|
+
// What the swipe and the keys read when they happen, kept current after each render
|
|
268
269
|
const state = useRef({ open: openMobile, isMobile, setOpenMobile });
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
state.current = { open: openMobile, isMobile, setOpenMobile };
|
|
272
|
+
});
|
|
273
|
+
// Focus moves in on open and back to what opened the drawer on close, or to a menu button when that can no longer
|
|
274
|
+
// take it. A drawer that is not contained shows only at phone width, so going back to it from a wide window moves
|
|
275
|
+
// focus in again.
|
|
272
276
|
const shown = openMobile && (isMobile || Boolean(contained));
|
|
273
277
|
useEffect(() => {
|
|
274
278
|
const drawer = drawerRef.current;
|
|
275
279
|
if (!shown || !drawer)
|
|
276
280
|
return;
|
|
277
281
|
const trigger = document.activeElement;
|
|
282
|
+
// Taken now: on unmount the cleanup runs once the drawer has left the page, with no provider around it
|
|
283
|
+
const root = drawer.closest("[data-mobile-menu]");
|
|
278
284
|
if (!drawer.contains(document.activeElement))
|
|
279
285
|
drawerInitialFocus(drawer).focus({ preventScroll: true });
|
|
280
286
|
return () => {
|
|
281
287
|
const active = document.activeElement;
|
|
282
288
|
const lost = !active || active === document.body || drawer.contains(active);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
// On unmount a menu button that left with the drawer is gone too, and is not picked
|
|
290
|
+
if (lost)
|
|
291
|
+
returnDrawerFocus(trigger, drawer, root);
|
|
286
292
|
};
|
|
287
293
|
}, [shown]);
|
|
288
294
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,IAAI,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,SAAS,CAAA;AACxH,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAA;AACjD,OAAO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AAC,WAAW,GAAG,cAAc,CAAA;AAQzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,KAAM,UAAU,CAAC,KAAK,CAAC,GAAI,CACpF,CACF,CAAA;AACD,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\n/**\n * Sidebar Component - Composable navigation sidebar\n *\n * API SPECIFICATION:\n *\n * SidebarProvider\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n * - onOpenChange?: (open: boolean) => void\n * - collapsible?: \"offcanvas\" | \"icon\" | \"none\" (default: \"offcanvas\")\n *\n * Sidebar\n * - side?: \"left\" | \"right\" (default: \"left\")\n * - variant?: \"sidebar\" | \"docs\" (default: \"sidebar\")\n *\n * SidebarHeader / SidebarContent / SidebarFooter\n * - Standard container props\n *\n * SidebarGroup\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n *\n * SidebarGroupLabel / SidebarGroupAction / SidebarGroupContent\n * - Standard container props\n *\n * SidebarMenu / SidebarMenuItem\n * - Standard container props\n *\n * SidebarMenuButton\n * - isActive?: boolean (default: false)\n * - size?: \"sm\" | \"md\" | \"lg\" (default: \"md\")\n * - tooltip?: string | ReactNode\n * - asChild?: boolean\n *\n * SidebarMenuAction / SidebarMenuBadge\n * - Standard container props\n *\n * SidebarMenuSkeleton\n * - showIcon?: boolean (default: true)\n *\n * SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton\n * - Same as parent menu components\n *\n * SidebarSeparator\n * - Standard separator props\n *\n * SidebarCard / SidebarCardHeader / SidebarCardContent / SidebarCardFooter\n * - variant?: \"default\" | \"elevated\"\n * - dismissible?: boolean\n * - onDismiss?: () => void\n *\n * SidebarInset\n * - Standard container for main content area\n *\n * SidebarTrigger\n * - Uses Button component internally\n * - Returns null when collapsible=\"none\"\n *\n * SidebarMobileMenuButton\n * - Mobile menu button: the SidebarMenuMobile icon turns into X\n *\n * SidebarInput\n * - shortcut?: string (keyboard shortcut display)\n */\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ComponentProps,\n type PointerEvent,\n type ReactNode,\n} from \"react\"\n\nimport { Button } from \"../Button\"\nimport { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIcon, SidebarMenuMobile, X } from \"../Icon\"\nimport { Input, type InputProps } from \"../Input\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\nimport { attachDrawerSwipe, closeOnUnhandledEscape, drawerInitialFocus, loopDrawerFocus } from \"../../lib/phoneDrawer\"\nimport {\n SidebarProvider,\n useSidebar,\n type SidebarCollapsible,\n type SidebarSide,\n type SidebarProviderVariant,\n type SidebarVariant,\n} from \"./useSidebarContext\"\n\n// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)\nconst cleanProps = <P extends object>(props: P): Omit<P, \"data-toggle\"> => {\n const { \"data-toggle\": _, ...rest } = props as P & { \"data-toggle\"?: unknown }\n return rest\n}\n\n// Re-export provider and hook\nexport { SidebarProvider, useSidebar }\nexport type { SidebarCollapsible, SidebarProviderVariant, SidebarSide, SidebarVariant }\n\n// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles), unless the drawer\n// leaves it out (`disclosure={false}`).\nconst SidebarDrawerContext = createContext(false)\n\n/** The chevron of a drawer row that leads to another page. */\nconst MenuDisclosure = () => (\n <span className={s.MenuDisclosure} aria-hidden=\"true\">\n <Disclosure />\n </span>\n)\n\n// =============================================\n// Sidebar Root\n// =============================================\n\nexport type SidebarProps = ComponentProps<\"aside\"> & {\n /**\n * The side the sidebar is on.\n * @default \"left\"\n */\n side?: SidebarSide\n /**\n * The visual variant of the sidebar.\n * @default \"sidebar\"\n */\n variant?: SidebarVariant\n}\n\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(\n ({ side = \"left\", variant = \"sidebar\", className, children, ...props }, ref) => {\n const { collapsible, isMobile } = useSidebar()\n\n // Skip rendering sidebar on mobile for offcanvas mode\n if (isMobile && collapsible === \"offcanvas\") {\n return null\n }\n\n return (\n <aside\n ref={ref}\n data-side={side}\n data-variant={variant}\n className={clsx(s.Sidebar, className)}\n {...cleanProps(props)}\n >\n {children}\n </aside>\n )\n },\n)\nSidebar.displayName = \"Sidebar\"\n\n// =============================================\n// Sidebar Sections\n// =============================================\n\nexport type SidebarHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarHeader = forwardRef<HTMLDivElement, SidebarHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Header, className)} {...cleanProps(props)} />\n ),\n)\nSidebarHeader.displayName = \"SidebarHeader\"\n\nexport type SidebarContentProps = ComponentProps<\"div\">\n\nexport const SidebarContent = forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, ...props }, ref) => {\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null)\n const setRef = useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as { current: HTMLDivElement | null }).current = el\n },\n [ref],\n )\n\n useLayoutEffect(() => {\n if (!contentEl) return\n const sidebar = contentEl.parentElement\n if (!sidebar) return\n\n const update = () => {\n const hasOverflow = contentEl.scrollHeight > contentEl.clientHeight\n sidebar.setAttribute(\"data-content-scrollable\", hasOverflow ? \"true\" : \"false\")\n }\n update()\n const ro = new ResizeObserver(update)\n ro.observe(contentEl)\n return () => ro.disconnect()\n }, [contentEl])\n\n return <div ref={setRef} className={clsx(s.Content, className)} {...cleanProps(props)} />\n },\n)\nSidebarContent.displayName = \"SidebarContent\"\n\nexport type SidebarFooterProps = ComponentProps<\"div\">\n\nexport const SidebarFooter = forwardRef<HTMLDivElement, SidebarFooterProps>(\n ({ className, children, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Footer, className)} {...cleanProps(props)}>\n <div className={s.FooterSeparator} />\n {children}\n </div>\n ),\n)\nSidebarFooter.displayName = \"SidebarFooter\"\n\nexport type SidebarRailProps = ComponentProps<\"div\">\n\nexport const SidebarRail = forwardRef<HTMLDivElement, SidebarRailProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Rail, className)} {...cleanProps(props)} />\n ),\n)\nSidebarRail.displayName = \"SidebarRail\"\n\n// =============================================\n// Groups\n// =============================================\n\nexport type SidebarGroupProps = ComponentProps<\"div\"> & {\n /**\n * Whether the group is open initially. A closed group hides its `SidebarGroupContent`.\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state. The group has no toggle of its own: change `open` from your own control.\n */\n open?: boolean\n}\n\nexport const SidebarGroup = forwardRef<HTMLDivElement, SidebarGroupProps>(\n ({ defaultOpen = true, open: openProp, className, ...props }, ref) => {\n // The initial value only, like an uncontrolled input's defaultValue\n const [initialOpen] = useState(defaultOpen)\n const open = openProp ?? initialOpen\n\n return (\n <div\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(s.Group, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroup.displayName = \"SidebarGroup\"\n\nexport type SidebarGroupLabelProps = ComponentProps<\"span\"> & {\n asChild?: boolean\n /**\n * Size variant for the label.\n * - \"sm\": Compact style for dashboard/settings sidebars\n * - \"lg\": Documentation style with larger text and more spacing\n * @default \"lg\"\n */\n size?: \"sm\" | \"lg\"\n}\n\nexport const SidebarGroupLabel = forwardRef<HTMLSpanElement, SidebarGroupLabelProps>(\n ({ asChild = false, size = \"lg\", className, ...props }, ref) => {\n const Comp = asChild ? Slot.Root : \"span\"\n return (\n <Comp\n ref={ref}\n data-size={size}\n className={clsx(s.GroupLabel, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroupLabel.displayName = \"SidebarGroupLabel\"\n\nexport type SidebarGroupActionProps = ComponentProps<\"div\">\n\nexport const SidebarGroupAction = forwardRef<HTMLDivElement, SidebarGroupActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupAction.displayName = \"SidebarGroupAction\"\n\nexport type SidebarGroupContentProps = ComponentProps<\"div\">\n\nexport const SidebarGroupContent = forwardRef<HTMLDivElement, SidebarGroupContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupContent.displayName = \"SidebarGroupContent\"\n\n// =============================================\n// Menu\n// =============================================\n\nexport type SidebarMenuProps = ComponentProps<\"ul\">\n\nexport const SidebarMenu = forwardRef<HTMLUListElement, SidebarMenuProps>(\n ({ className, ...props }, ref) => (\n <ul ref={ref} className={clsx(s.Menu, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenu.displayName = \"SidebarMenu\"\n\nexport type SidebarMenuItemProps = ComponentProps<\"li\"> & {\n expanded?: boolean\n}\n\nexport const SidebarMenuItem = forwardRef<HTMLLIElement, SidebarMenuItemProps>(\n ({ expanded, className, ...props }, ref) => (\n <li\n ref={ref}\n data-expanded={expanded ? \"true\" : undefined}\n className={clsx(s.MenuItem, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuItem.displayName = \"SidebarMenuItem\"\n\n// =============================================\n// Menu Button\n// =============================================\n\nexport type SidebarMenuButtonProps = ComponentProps<\"button\"> & {\n /**\n * Whether the button is in an active/highlighted state.\n * @default false\n */\n isActive?: boolean\n /**\n * Optional tooltip to show when the sidebar is collapsed.\n */\n tooltip?: string | ReactNode\n /**\n * Whether to render the button as a custom element via Slot.\n * @default false\n */\n asChild?: boolean\n}\n\n// Shared by every row of the rail: moving to the next one shows its label at once.\nlet railLeftAt = 0\n\nexport const SidebarMenuButton = forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n ({ isActive = false, tooltip, asChild = false, className, children, onPointerEnter, onPointerLeave, ...props }, ref) => {\n const { state, isMobile } = useSidebar()\n const inDrawer = useContext(SidebarDrawerContext)\n const [openDelay, setOpenDelay] = useState<number>()\n const Comp = asChild ? Slot.Root : \"button\"\n const disclosure = inDrawer ? <MenuDisclosure /> : null\n // With asChild the child element is the button, so the inner wrapper\n // goes inside it. Wrapping the child instead would make Slot merge the\n // button props onto the wrapper span.\n const content =\n asChild && isValidElement<{ children?: ReactNode }>(children) ? (\n cloneElement(\n children,\n undefined,\n <span className={s.MenuButtonInner}>{children.props.children}{disclosure}</span>,\n )\n ) : (\n <span className={s.MenuButtonInner}>{children}{disclosure}</span>\n )\n\n const button = (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuButton, className)}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerEnter?.(event)\n if (tooltip) setOpenDelay(Date.now() - railLeftAt < 300 ? 0 : undefined)\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerLeave?.(event)\n if (tooltip) railLeftAt = Date.now()\n }}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n\n // The tooltip shows when collapsed (icon mode) and not on mobile. It wraps\n // the row in every state, so the row stays mounted and its label can fade.\n if (tooltip) {\n return (\n <Tooltip content={state === \"collapsed\" && !isMobile ? tooltip : null} openDelay={openDelay} side=\"right\">\n {button}\n </Tooltip>\n )\n }\n\n return button\n },\n)\nSidebarMenuButton.displayName = \"SidebarMenuButton\"\n\n// =============================================\n// Menu Button Parts\n// =============================================\n\nexport type SidebarMenuButtonIconProps = ComponentProps<\"span\">\n\nexport const SidebarMenuButtonIcon = forwardRef<HTMLSpanElement, SidebarMenuButtonIconProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuButtonIcon, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuButtonIcon.displayName = \"SidebarMenuButtonIcon\"\n\nexport type SidebarMenuButtonLabelProps = ComponentProps<\"span\"> & {\n shortLabel?: string\n}\n\nexport const SidebarMenuButtonLabel = forwardRef<HTMLSpanElement, SidebarMenuButtonLabelProps>(\n ({ shortLabel, className, children, ...props }, ref) => (\n <>\n <span\n ref={ref}\n data-long-label=\"true\"\n className={clsx(s.MenuButtonLabel, className)}\n {...cleanProps(props)}\n >\n {children}\n </span>\n {shortLabel && (\n <span data-short-label=\"true\" className={clsx(s.MenuButtonLabel, className)}>\n {shortLabel}\n </span>\n )}\n </>\n ),\n)\nSidebarMenuButtonLabel.displayName = \"SidebarMenuButtonLabel\"\n\n// =============================================\n// Menu Chevron (Expand/Collapse Toggle)\n// =============================================\n\nexport type SidebarMenuChevronProps = ComponentProps<\"span\">\n\nexport const SidebarMenuChevron = forwardRef<HTMLSpanElement, SidebarMenuChevronProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuChevron, className)} {...cleanProps(props)}>\n <ChevronRightMd />\n </span>\n ),\n)\nSidebarMenuChevron.displayName = \"SidebarMenuChevron\"\n\n// =============================================\n// Menu Badge & Action\n// =============================================\n\nexport type SidebarMenuBadgeProps = ComponentProps<\"span\">\n\nexport const SidebarMenuBadge = forwardRef<HTMLSpanElement, SidebarMenuBadgeProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuBadge, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuBadge.displayName = \"SidebarMenuBadge\"\n\nexport type SidebarMenuActionProps = ComponentProps<\"div\">\n\nexport const SidebarMenuAction = forwardRef<HTMLDivElement, SidebarMenuActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MenuAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuAction.displayName = \"SidebarMenuAction\"\n\n// =============================================\n// Menu Skeleton\n// =============================================\n\nexport type SidebarMenuSkeletonProps = ComponentProps<\"div\"> & {\n showIcon?: boolean\n /** Width of the label skeleton (e.g., \"60%\", \"80%\", \"100px\") */\n labelWidth?: string\n}\n\nexport const SidebarMenuSkeleton = forwardRef<HTMLDivElement, SidebarMenuSkeletonProps>(\n ({ showIcon = true, labelWidth = \"60%\", className, ...props }, ref) => (\n <div\n ref={ref}\n data-skeleton\n className={clsx(s.MenuSkeleton, className)}\n {...cleanProps(props)}\n >\n {showIcon && <div className={s.MenuSkeletonIcon} />}\n <div className={s.MenuSkeletonLabel} style={{ width: labelWidth }} />\n </div>\n ),\n)\nSidebarMenuSkeleton.displayName = \"SidebarMenuSkeleton\"\n\n// =============================================\n// Submenu\n// =============================================\n\nexport type SidebarMenuSubProps = ComponentProps<\"ul\"> & {\n open?: boolean\n /**\n * When true, child items align with parent text that has icons.\n * This adjusts the padding so level 2 text aligns with level 1 text.\n */\n hasIcons?: boolean\n}\n\nexport const SidebarMenuSub = forwardRef<HTMLUListElement, SidebarMenuSubProps>(\n ({ open = true, hasIcons = false, className, ...props }, ref) => (\n <ul\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n data-has-icons={hasIcons ? \"true\" : undefined}\n // Collapsed items are only hidden visually: keep them out of the tab order\n inert={open ? undefined : true}\n className={clsx(s.MenuSub, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuSub.displayName = \"SidebarMenuSub\"\n\nexport type SidebarMenuSubItemProps = ComponentProps<\"li\">\n\nexport const SidebarMenuSubItem = forwardRef<HTMLLIElement, SidebarMenuSubItemProps>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={clsx(s.MenuSubItem, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuSubItem.displayName = \"SidebarMenuSubItem\"\n\nexport type SidebarMenuSubButtonProps = ComponentProps<\"button\"> & {\n isActive?: boolean\n asChild?: boolean\n /**\n * Indent level for nested items (0-3).\n * Each level adds 12px of left margin.\n * @default 0\n */\n indent?: 0 | 1 | 2 | 3\n}\n\nexport const SidebarMenuSubButton = forwardRef<HTMLButtonElement, SidebarMenuSubButtonProps>(\n ({ isActive = false, asChild = false, indent = 0, className, children, ...props }, ref) => {\n const inDrawer = useContext(SidebarDrawerContext)\n const Comp = asChild ? Slot.Root : \"button\"\n // In the drawer the disclosure follows the content, inside the child element with asChild\n const content = !inDrawer\n ? children\n : asChild && isValidElement<{ children?: ReactNode }>(children)\n ? cloneElement(children, undefined, <>{children.props.children}<MenuDisclosure /></>)\n : <>{children}<MenuDisclosure /></>\n return (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuSubButton, s[`indent${indent}`], className)}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n },\n)\nSidebarMenuSubButton.displayName = \"SidebarMenuSubButton\"\n\n// =============================================\n// Separator\n// =============================================\n\nexport type SidebarSeparatorProps = ComponentProps<\"hr\">\n\nexport const SidebarSeparator = forwardRef<HTMLHRElement, SidebarSeparatorProps>(\n ({ className, ...props }, ref) => (\n <hr ref={ref} className={clsx(s.Separator, className)} {...cleanProps(props)} />\n ),\n)\nSidebarSeparator.displayName = \"SidebarSeparator\"\n\n// =============================================\n// Card\n// =============================================\n\nexport type SidebarCardProps = ComponentProps<\"div\"> & {\n variant?: \"default\" | \"elevated\"\n dismissible?: boolean\n onDismiss?: () => void\n}\n\nexport const SidebarCard = forwardRef<HTMLDivElement, SidebarCardProps>(\n ({ variant = \"default\", dismissible = false, onDismiss, className, children, ...props }, ref) => (\n <div\n ref={ref}\n data-variant={variant}\n className={clsx(s.Card, className)}\n {...cleanProps(props)}\n >\n {dismissible && (\n <Button\n uniform\n size=\"3xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.CardDismiss}\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n >\n <X />\n </Button>\n )}\n {children}\n </div>\n ),\n)\nSidebarCard.displayName = \"SidebarCard\"\n\nexport type SidebarCardHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarCardHeader = forwardRef<HTMLDivElement, SidebarCardHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardHeader.displayName = \"SidebarCardHeader\"\n\nexport type SidebarCardTitleProps = ComponentProps<\"div\">\n\nexport const SidebarCardTitle = forwardRef<HTMLDivElement, SidebarCardTitleProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardTitle, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardTitle.displayName = \"SidebarCardTitle\"\n\nexport type SidebarCardTitleLinkProps = ComponentProps<\"a\">\n\nexport const SidebarCardTitleLink = forwardRef<HTMLAnchorElement, SidebarCardTitleLinkProps>(\n ({ className, children, ...props }, ref) => (\n <a ref={ref} className={clsx(s.CardTitleLink, className)} {...cleanProps(props)}>\n {children}\n <ChevronRightMd className={s.CardTitleChevron} />\n </a>\n ),\n)\nSidebarCardTitleLink.displayName = \"SidebarCardTitleLink\"\n\nexport type SidebarCardContentProps = ComponentProps<\"div\">\n\nexport const SidebarCardContent = forwardRef<HTMLDivElement, SidebarCardContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardContent.displayName = \"SidebarCardContent\"\n\nexport type SidebarCardFooterProps = ComponentProps<\"div\">\n\nexport const SidebarCardFooter = forwardRef<HTMLDivElement, SidebarCardFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardFooter.displayName = \"SidebarCardFooter\"\n\n// =============================================\n// Inset (Main Content Area)\n// =============================================\n\nexport type SidebarInsetProps = ComponentProps<\"main\">\n\nexport const SidebarInset = forwardRef<HTMLElement, SidebarInsetProps>(\n ({ className, ...props }, ref) => {\n const { isMobile, openMobile } = useSidebar()\n // Behind the open phone drawer the page takes no focus or touch; `inert` of your own wins\n return (\n <main\n ref={ref}\n className={clsx(s.Inset, className)}\n inert={isMobile && openMobile ? true : undefined}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarInset.displayName = \"SidebarInset\"\n\n// =============================================\n// Layout Container\n// =============================================\n\nexport type SidebarLayoutProps = ComponentProps<\"div\">\n\nexport const SidebarLayout = forwardRef<HTMLDivElement, SidebarLayoutProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.SidebarLayout, className)} {...cleanProps(props)} />\n ),\n)\nSidebarLayout.displayName = \"SidebarLayout\"\n\n// =============================================\n// Trigger (Collapse Button)\n// =============================================\n\nexport type SidebarTriggerProps = ComponentProps<\"button\"> & {\n children?: ReactNode\n}\n\nexport const SidebarTrigger = forwardRef<HTMLButtonElement, SidebarTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { state, collapsible, isMobile, toggleSidebar } = useSidebar()\n\n // Don't render if collapsible=\"none\" (text-only sidebars)\n if (collapsible === \"none\") {\n return null\n }\n\n // One icon for both states: the tooltip, not the icon, says what a press does\n const defaultIcon = <SidebarIcon />\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(s.Trigger, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) toggleSidebar()\n }}\n aria-label={\n isMobile ? \"Open menu\" : state === \"expanded\" ? \"Collapse sidebar\" : \"Expand sidebar\"\n }\n {...cleanProps(props)}\n >\n <span className={s.TriggerInner}>\n <span className={s.TriggerIcon}>{children ?? defaultIcon}</span>\n </span>\n </button>\n )\n },\n)\nSidebarTrigger.displayName = \"SidebarTrigger\"\n\n// =============================================\n// Mobile Menu Button (SidebarMenuMobile icon → X)\n// =============================================\n\nexport type SidebarMobileMenuButtonProps = ComponentProps<\"button\">\n\nexport const SidebarMobileMenuButton = forwardRef<HTMLButtonElement, SidebarMobileMenuButtonProps>(\n ({ className, onClick, ...props }, ref) => {\n const { openMobile, setOpenMobile } = useSidebar()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-expanded={openMobile ? \"\" : undefined}\n className={clsx(s.MobileMenuButton, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) setOpenMobile(!openMobile)\n }}\n aria-label={openMobile ? \"Close menu\" : \"Open menu\"}\n {...cleanProps(props)}\n >\n <span className={s.MobileMenuIcon}>\n <SidebarMenuMobile className={s.MobileMenuGlyph} data-glyph=\"menu\" />\n <X className={s.MobileMenuGlyph} data-glyph=\"close\" />\n </span>\n </button>\n )\n },\n)\nSidebarMobileMenuButton.displayName = \"SidebarMobileMenuButton\"\n\n// =============================================\n// Mobile Sidebar\n// =============================================\n\nexport type SidebarMobileProps = ComponentProps<\"div\"> & {\n /** When true, drawer is positioned absolute instead of fixed (for contained demos) */\n contained?: boolean\n /**\n * Rows that lead to another page end with a disclosure chevron, as in an iOS list. `false` leaves it out.\n * @default true\n */\n disclosure?: boolean\n}\n\n/**\n * The phone drawer: a modal dialog while it is open. Focus moves into it and Tab goes round its controls, the page\n * behind is inert (SidebarInset), Escape inside it closes it after any layer over it has taken its own, and focus\n * goes back to the control that opened it. A swipe in from the edge it slides from opens it and a swipe back closes\n * it (lib/phoneDrawer).\n */\nexport const SidebarMobile = forwardRef<HTMLDivElement, SidebarMobileProps>(\n ({ className, children, contained, disclosure = true, onKeyDown, ...props }, ref) => {\n const { isMobile, openMobile, setOpenMobile } = useSidebar()\n const drawerRef = useRef<HTMLDivElement>(null)\n const state = useRef({ open: openMobile, isMobile, setOpenMobile })\n state.current = { open: openMobile, isMobile, setOpenMobile }\n\n // Focus moves in on open and back to what opened the drawer on close. A drawer that is not contained shows only\n // at phone width, so going back to it from a wide window moves focus in again.\n const shown = openMobile && (isMobile || Boolean(contained))\n useEffect(() => {\n const drawer = drawerRef.current\n if (!shown || !drawer) return\n const trigger = document.activeElement\n if (!drawer.contains(document.activeElement)) drawerInitialFocus(drawer).focus({ preventScroll: true })\n return () => {\n const active = document.activeElement\n const lost = !active || active === document.body || drawer.contains(active)\n if (lost && trigger instanceof HTMLElement && trigger.isConnected && !drawer.contains(trigger)) {\n trigger.focus({ preventScroll: true })\n }\n }\n }, [shown])\n\n useEffect(() => {\n const drawer = drawerRef.current\n const root = drawer?.closest<HTMLElement>(\"[data-mobile-menu]\")\n if (!drawer || !root) return\n return attachDrawerSwipe({\n root,\n drawer,\n isOpen: () => state.current.open,\n setOpen: (open) => state.current.setOpenMobile(open),\n enabled: () => state.current.isMobile,\n })\n }, [])\n\n return (\n <>\n {/* Backdrop */}\n <div\n className={clsx(s.MobileBackdrop, contained && s.contained)}\n onClick={() => setOpenMobile(false)}\n aria-hidden=\"true\"\n />\n\n {/* Drawer */}\n <div\n ref={mergeRefs([ref, drawerRef])}\n role=\"dialog\"\n aria-modal={openMobile ? true : undefined}\n aria-label=\"Menu\"\n tabIndex={-1}\n inert={openMobile ? undefined : true}\n className={clsx(s.MobileSidebar, contained && s.contained, className)}\n onKeyDown={(event) => {\n // Your handler runs first and can keep the drawer open with preventDefault()\n onKeyDown?.(event)\n const drawer = drawerRef.current\n if (!openMobile || !drawer) return\n loopDrawerFocus(event.nativeEvent, drawer)\n closeOnUnhandledEscape(event.nativeEvent, drawer, () => state.current.setOpenMobile(false))\n }}\n {...cleanProps(props)}\n >\n <SidebarDrawerContext.Provider value={disclosure}>{children}</SidebarDrawerContext.Provider>\n </div>\n </>\n )\n },\n)\nSidebarMobile.displayName = \"SidebarMobile\"\n\nexport type SidebarMobileHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarMobileHeader = forwardRef<HTMLDivElement, SidebarMobileHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileHeader.displayName = \"SidebarMobileHeader\"\n\nexport type SidebarMobileFooterProps = ComponentProps<\"div\">\n\nexport const SidebarMobileFooter = forwardRef<HTMLDivElement, SidebarMobileFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileFooter.displayName = \"SidebarMobileFooter\"\n\n// =============================================\n// Input (Search)\n// =============================================\n\nexport type SidebarInputProps = InputProps\n\nexport const SidebarInput = forwardRef<HTMLInputElement, SidebarInputProps>(\n ({ className, ...props }, ref) => (\n <div className={s.Input}>\n <Input\n ref={ref}\n className={className}\n startAdornment={<SearchIcon />}\n {...cleanProps(props)}\n />\n </div>\n ),\n)\nSidebarInput.displayName = \"SidebarInput\"\n\n// =============================================\n// Footer Links\n// =============================================\n\nexport type SidebarFooterLinksProps = ComponentProps<\"div\">\n\nexport const SidebarFooterLinks = forwardRef<HTMLDivElement, SidebarFooterLinksProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.FooterLinks, className)} {...cleanProps(props)} />\n ),\n)\nSidebarFooterLinks.displayName = \"SidebarFooterLinks\"\n"]}
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AA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AAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,SAAS,EAAE,CAAC,CAAC,KAAK,YACrB,KAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,KAAC,UAAU,KAAG,KAC1B,UAAU,CAAC,KAAK,CAAC,GACrB,GACE,CACP,CACF,CAAA;AACD,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAQzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAC1C,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAChC,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,KAAM,UAAU,CAAC,KAAK,CAAC,GAAI,CACpF,CACF,CAAA;AACD,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAA","sourcesContent":["\"use client\"\n\n/**\n * Sidebar Component - Composable navigation sidebar\n *\n * API SPECIFICATION:\n *\n * SidebarProvider\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n * - onOpenChange?: (open: boolean) => void\n * - collapsible?: \"offcanvas\" | \"icon\" | \"none\" (default: \"offcanvas\")\n *\n * Sidebar\n * - side?: \"left\" | \"right\" (default: \"left\")\n * - variant?: \"sidebar\" | \"docs\" (default: \"sidebar\")\n *\n * SidebarHeader / SidebarContent / SidebarFooter\n * - Standard container props\n *\n * SidebarGroup\n * - defaultOpen?: boolean (default: true)\n * - open?: boolean (controlled)\n *\n * SidebarGroupLabel / SidebarGroupAction / SidebarGroupContent\n * - Standard container props\n *\n * SidebarMenu / SidebarMenuItem\n * - Standard container props\n *\n * SidebarMenuButton\n * - isActive?: boolean (default: false)\n * - size?: \"sm\" | \"md\" | \"lg\" (default: \"md\")\n * - tooltip?: string | ReactNode\n * - asChild?: boolean\n *\n * SidebarMenuAction / SidebarMenuBadge\n * - Standard container props\n *\n * SidebarMenuSkeleton\n * - showIcon?: boolean (default: true)\n *\n * SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton\n * - Same as parent menu components\n *\n * SidebarSeparator\n * - Standard separator props\n *\n * SidebarCard / SidebarCardHeader / SidebarCardContent / SidebarCardFooter\n * - variant?: \"default\" | \"elevated\"\n * - dismissible?: boolean\n * - onDismiss?: () => void\n *\n * SidebarInset\n * - Standard container for main content area\n *\n * SidebarTrigger\n * - Uses Button component internally\n * - Returns null when collapsible=\"none\"\n *\n * SidebarMobileMenuButton\n * - Mobile menu button: the SidebarMenuMobile icon turns into X\n *\n * SidebarInput\n * - shortcut?: string (keyboard shortcut display)\n */\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { mergeRefs } from \"react-merge-refs\"\nimport {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ComponentProps,\n type PointerEvent,\n type ReactNode,\n} from \"react\"\n\nimport { Button } from \"../Button\"\nimport { ChevronRightMd, Disclosure, Search as SearchIcon, Sidebar as SidebarIcon, SidebarMenuMobile, X } from \"../Icon\"\nimport { Input, type InputProps } from \"../Input\"\nimport { Tooltip } from \"../Tooltip\"\nimport s from \"@plexui/styles/components/Sidebar/Sidebar.module.css\"\nimport {\n attachDrawerSwipe,\n closeOnUnhandledEscape,\n drawerInitialFocus,\n returnDrawerFocus,\n loopDrawerFocus,\n} from \"../../lib/phoneDrawer\"\nimport {\n SidebarProvider,\n useSidebar,\n type SidebarCollapsible,\n type SidebarSide,\n type SidebarProviderVariant,\n type SidebarVariant,\n} from \"./useSidebarContext\"\n\n// Helper to filter out props that shouldn't be spread to the DOM (e.g. injected by MDX)\nconst cleanProps = <P extends object>(props: P): Omit<P, \"data-toggle\"> => {\n const { \"data-toggle\": _, ...rest } = props as P & { \"data-toggle\"?: unknown }\n return rest\n}\n\n// Re-export provider and hook\nexport { SidebarProvider, useSidebar }\nexport type { SidebarCollapsible, SidebarProviderVariant, SidebarSide, SidebarVariant }\n\n// Rows inside the mobile drawer end with a disclosure chevron (see the drawer list in the styles), unless the drawer\n// leaves it out (`disclosure={false}`).\nconst SidebarDrawerContext = createContext(false)\n\n/** The chevron of a drawer row that leads to another page. */\nconst MenuDisclosure = () => (\n <span className={s.MenuDisclosure} aria-hidden=\"true\">\n <Disclosure />\n </span>\n)\n\n// =============================================\n// Sidebar Root\n// =============================================\n\nexport type SidebarProps = ComponentProps<\"aside\"> & {\n /**\n * The side the sidebar is on.\n * @default \"left\"\n */\n side?: SidebarSide\n /**\n * The visual variant of the sidebar.\n * @default \"sidebar\"\n */\n variant?: SidebarVariant\n}\n\nexport const Sidebar = forwardRef<HTMLElement, SidebarProps>(\n ({ side = \"left\", variant = \"sidebar\", className, children, ...props }, ref) => {\n const { collapsible, isMobile } = useSidebar()\n\n // Skip rendering sidebar on mobile for offcanvas mode\n if (isMobile && collapsible === \"offcanvas\") {\n return null\n }\n\n return (\n <aside\n ref={ref}\n data-side={side}\n data-variant={variant}\n className={clsx(s.Sidebar, className)}\n {...cleanProps(props)}\n >\n {children}\n </aside>\n )\n },\n)\nSidebar.displayName = \"Sidebar\"\n\n// =============================================\n// Sidebar Sections\n// =============================================\n\nexport type SidebarHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarHeader = forwardRef<HTMLDivElement, SidebarHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Header, className)} {...cleanProps(props)} />\n ),\n)\nSidebarHeader.displayName = \"SidebarHeader\"\n\nexport type SidebarContentProps = ComponentProps<\"div\">\n\nexport const SidebarContent = forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, ...props }, ref) => {\n const [contentEl, setContentEl] = useState<HTMLDivElement | null>(null)\n const setRef = useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(el)\n if (typeof ref === \"function\") ref(el)\n else if (ref) (ref as { current: HTMLDivElement | null }).current = el\n },\n [ref],\n )\n\n useLayoutEffect(() => {\n if (!contentEl) return\n const sidebar = contentEl.parentElement\n if (!sidebar) return\n\n const update = () => {\n const hasOverflow = contentEl.scrollHeight > contentEl.clientHeight\n sidebar.setAttribute(\"data-content-scrollable\", hasOverflow ? \"true\" : \"false\")\n }\n update()\n const ro = new ResizeObserver(update)\n ro.observe(contentEl)\n return () => ro.disconnect()\n }, [contentEl])\n\n return <div ref={setRef} className={clsx(s.Content, className)} {...cleanProps(props)} />\n },\n)\nSidebarContent.displayName = \"SidebarContent\"\n\nexport type SidebarFooterProps = ComponentProps<\"div\">\n\nexport const SidebarFooter = forwardRef<HTMLDivElement, SidebarFooterProps>(\n ({ className, children, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Footer, className)} {...cleanProps(props)}>\n <div className={s.FooterSeparator} />\n {children}\n </div>\n ),\n)\nSidebarFooter.displayName = \"SidebarFooter\"\n\nexport type SidebarRailProps = ComponentProps<\"div\">\n\nexport const SidebarRail = forwardRef<HTMLDivElement, SidebarRailProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.Rail, className)} {...cleanProps(props)} />\n ),\n)\nSidebarRail.displayName = \"SidebarRail\"\n\n// =============================================\n// Groups\n// =============================================\n\nexport type SidebarGroupProps = ComponentProps<\"div\"> & {\n /**\n * Whether the group is open initially. A closed group hides its `SidebarGroupContent`.\n * @default true\n */\n defaultOpen?: boolean\n /**\n * Controlled open state. The group has no toggle of its own: change `open` from your own control.\n */\n open?: boolean\n}\n\nexport const SidebarGroup = forwardRef<HTMLDivElement, SidebarGroupProps>(\n ({ defaultOpen = true, open: openProp, className, ...props }, ref) => {\n // The initial value only, like an uncontrolled input's defaultValue\n const [initialOpen] = useState(defaultOpen)\n const open = openProp ?? initialOpen\n\n return (\n <div\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(s.Group, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroup.displayName = \"SidebarGroup\"\n\nexport type SidebarGroupLabelProps = ComponentProps<\"span\"> & {\n asChild?: boolean\n /**\n * Size variant for the label.\n * - \"sm\": Compact style for dashboard/settings sidebars\n * - \"lg\": Documentation style with larger text and more spacing\n * @default \"lg\"\n */\n size?: \"sm\" | \"lg\"\n}\n\nexport const SidebarGroupLabel = forwardRef<HTMLSpanElement, SidebarGroupLabelProps>(\n ({ asChild = false, size = \"lg\", className, ...props }, ref) => {\n const Comp = asChild ? Slot.Root : \"span\"\n return (\n <Comp\n ref={ref}\n data-size={size}\n className={clsx(s.GroupLabel, className)}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarGroupLabel.displayName = \"SidebarGroupLabel\"\n\nexport type SidebarGroupActionProps = ComponentProps<\"div\">\n\nexport const SidebarGroupAction = forwardRef<HTMLDivElement, SidebarGroupActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupAction.displayName = \"SidebarGroupAction\"\n\nexport type SidebarGroupContentProps = ComponentProps<\"div\">\n\nexport const SidebarGroupContent = forwardRef<HTMLDivElement, SidebarGroupContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.GroupContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarGroupContent.displayName = \"SidebarGroupContent\"\n\n// =============================================\n// Menu\n// =============================================\n\nexport type SidebarMenuProps = ComponentProps<\"ul\">\n\nexport const SidebarMenu = forwardRef<HTMLUListElement, SidebarMenuProps>(\n ({ className, ...props }, ref) => (\n <ul ref={ref} className={clsx(s.Menu, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenu.displayName = \"SidebarMenu\"\n\nexport type SidebarMenuItemProps = ComponentProps<\"li\"> & {\n expanded?: boolean\n}\n\nexport const SidebarMenuItem = forwardRef<HTMLLIElement, SidebarMenuItemProps>(\n ({ expanded, className, ...props }, ref) => (\n <li\n ref={ref}\n data-expanded={expanded ? \"true\" : undefined}\n className={clsx(s.MenuItem, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuItem.displayName = \"SidebarMenuItem\"\n\n// =============================================\n// Menu Button\n// =============================================\n\nexport type SidebarMenuButtonProps = ComponentProps<\"button\"> & {\n /**\n * Whether the button is in an active/highlighted state.\n * @default false\n */\n isActive?: boolean\n /**\n * Optional tooltip to show when the sidebar is collapsed.\n */\n tooltip?: string | ReactNode\n /**\n * Whether to render the button as a custom element via Slot.\n * @default false\n */\n asChild?: boolean\n}\n\n// Shared by every row of the rail: moving to the next one shows its label at once.\nlet railLeftAt = 0\n\nexport const SidebarMenuButton = forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n ({ isActive = false, tooltip, asChild = false, className, children, onPointerEnter, onPointerLeave, ...props }, ref) => {\n const { state, isMobile } = useSidebar()\n const inDrawer = useContext(SidebarDrawerContext)\n const [openDelay, setOpenDelay] = useState<number>()\n const Comp = asChild ? Slot.Root : \"button\"\n const disclosure = inDrawer ? <MenuDisclosure /> : null\n // With asChild the child element is the button, so the inner wrapper\n // goes inside it. Wrapping the child instead would make Slot merge the\n // button props onto the wrapper span.\n const content =\n asChild && isValidElement<{ children?: ReactNode }>(children) ? (\n cloneElement(\n children,\n undefined,\n <span className={s.MenuButtonInner}>{children.props.children}{disclosure}</span>,\n )\n ) : (\n <span className={s.MenuButtonInner}>{children}{disclosure}</span>\n )\n\n const button = (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuButton, className)}\n onPointerEnter={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerEnter?.(event)\n if (tooltip) setOpenDelay(Date.now() - railLeftAt < 300 ? 0 : undefined)\n }}\n onPointerLeave={(event: PointerEvent<HTMLButtonElement>) => {\n onPointerLeave?.(event)\n if (tooltip) railLeftAt = Date.now()\n }}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n\n // The tooltip shows when collapsed (icon mode) and not on mobile. It wraps\n // the row in every state, so the row stays mounted and its label can fade.\n if (tooltip) {\n return (\n <Tooltip content={state === \"collapsed\" && !isMobile ? tooltip : null} openDelay={openDelay} side=\"right\">\n {button}\n </Tooltip>\n )\n }\n\n return button\n },\n)\nSidebarMenuButton.displayName = \"SidebarMenuButton\"\n\n// =============================================\n// Menu Button Parts\n// =============================================\n\nexport type SidebarMenuButtonIconProps = ComponentProps<\"span\">\n\nexport const SidebarMenuButtonIcon = forwardRef<HTMLSpanElement, SidebarMenuButtonIconProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuButtonIcon, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuButtonIcon.displayName = \"SidebarMenuButtonIcon\"\n\nexport type SidebarMenuButtonLabelProps = ComponentProps<\"span\"> & {\n shortLabel?: string\n}\n\nexport const SidebarMenuButtonLabel = forwardRef<HTMLSpanElement, SidebarMenuButtonLabelProps>(\n ({ shortLabel, className, children, ...props }, ref) => (\n <>\n <span\n ref={ref}\n data-long-label=\"true\"\n className={clsx(s.MenuButtonLabel, className)}\n {...cleanProps(props)}\n >\n {children}\n </span>\n {shortLabel && (\n <span data-short-label=\"true\" className={clsx(s.MenuButtonLabel, className)}>\n {shortLabel}\n </span>\n )}\n </>\n ),\n)\nSidebarMenuButtonLabel.displayName = \"SidebarMenuButtonLabel\"\n\n// =============================================\n// Menu Chevron (Expand/Collapse Toggle)\n// =============================================\n\nexport type SidebarMenuChevronProps = ComponentProps<\"span\">\n\nexport const SidebarMenuChevron = forwardRef<HTMLSpanElement, SidebarMenuChevronProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuChevron, className)} {...cleanProps(props)}>\n <ChevronRightMd />\n </span>\n ),\n)\nSidebarMenuChevron.displayName = \"SidebarMenuChevron\"\n\n// =============================================\n// Menu Badge & Action\n// =============================================\n\nexport type SidebarMenuBadgeProps = ComponentProps<\"span\">\n\nexport const SidebarMenuBadge = forwardRef<HTMLSpanElement, SidebarMenuBadgeProps>(\n ({ className, ...props }, ref) => (\n <span ref={ref} className={clsx(s.MenuBadge, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuBadge.displayName = \"SidebarMenuBadge\"\n\nexport type SidebarMenuActionProps = ComponentProps<\"div\">\n\nexport const SidebarMenuAction = forwardRef<HTMLDivElement, SidebarMenuActionProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MenuAction, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuAction.displayName = \"SidebarMenuAction\"\n\n// =============================================\n// Menu Skeleton\n// =============================================\n\nexport type SidebarMenuSkeletonProps = ComponentProps<\"div\"> & {\n showIcon?: boolean\n /** Width of the label skeleton (e.g., \"60%\", \"80%\", \"100px\") */\n labelWidth?: string\n}\n\nexport const SidebarMenuSkeleton = forwardRef<HTMLDivElement, SidebarMenuSkeletonProps>(\n ({ showIcon = true, labelWidth = \"60%\", className, ...props }, ref) => (\n <div\n ref={ref}\n data-skeleton\n className={clsx(s.MenuSkeleton, className)}\n {...cleanProps(props)}\n >\n {showIcon && <div className={s.MenuSkeletonIcon} />}\n <div className={s.MenuSkeletonLabel} style={{ width: labelWidth }} />\n </div>\n ),\n)\nSidebarMenuSkeleton.displayName = \"SidebarMenuSkeleton\"\n\n// =============================================\n// Submenu\n// =============================================\n\nexport type SidebarMenuSubProps = ComponentProps<\"ul\"> & {\n open?: boolean\n /**\n * When true, child items align with parent text that has icons.\n * This adjusts the padding so level 2 text aligns with level 1 text.\n */\n hasIcons?: boolean\n}\n\nexport const SidebarMenuSub = forwardRef<HTMLUListElement, SidebarMenuSubProps>(\n ({ open = true, hasIcons = false, className, ...props }, ref) => (\n <ul\n ref={ref}\n data-state={open ? \"open\" : \"closed\"}\n data-has-icons={hasIcons ? \"true\" : undefined}\n // Collapsed items are only hidden visually: keep them out of the tab order\n inert={open ? undefined : true}\n className={clsx(s.MenuSub, className)}\n {...cleanProps(props)}\n />\n ),\n)\nSidebarMenuSub.displayName = \"SidebarMenuSub\"\n\nexport type SidebarMenuSubItemProps = ComponentProps<\"li\">\n\nexport const SidebarMenuSubItem = forwardRef<HTMLLIElement, SidebarMenuSubItemProps>(\n ({ className, ...props }, ref) => (\n <li ref={ref} className={clsx(s.MenuSubItem, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMenuSubItem.displayName = \"SidebarMenuSubItem\"\n\nexport type SidebarMenuSubButtonProps = ComponentProps<\"button\"> & {\n isActive?: boolean\n asChild?: boolean\n /**\n * Indent level for nested items (0-3).\n * Each level adds 12px of left margin.\n * @default 0\n */\n indent?: 0 | 1 | 2 | 3\n}\n\nexport const SidebarMenuSubButton = forwardRef<HTMLButtonElement, SidebarMenuSubButtonProps>(\n ({ isActive = false, asChild = false, indent = 0, className, children, ...props }, ref) => {\n const inDrawer = useContext(SidebarDrawerContext)\n const Comp = asChild ? Slot.Root : \"button\"\n // In the drawer the disclosure follows the content, inside the child element with asChild\n const content = !inDrawer\n ? children\n : asChild && isValidElement<{ children?: ReactNode }>(children)\n ? cloneElement(children, undefined, <>{children.props.children}<MenuDisclosure /></>)\n : <>{children}<MenuDisclosure /></>\n return (\n <Comp\n ref={ref}\n data-active={isActive ? \"true\" : \"false\"}\n aria-current={isActive ? \"page\" : undefined}\n className={clsx(s.MenuSubButton, s[`indent${indent}`], className)}\n {...cleanProps(props)}\n >\n {content}\n </Comp>\n )\n },\n)\nSidebarMenuSubButton.displayName = \"SidebarMenuSubButton\"\n\n// =============================================\n// Separator\n// =============================================\n\nexport type SidebarSeparatorProps = ComponentProps<\"hr\">\n\nexport const SidebarSeparator = forwardRef<HTMLHRElement, SidebarSeparatorProps>(\n ({ className, ...props }, ref) => (\n <hr ref={ref} className={clsx(s.Separator, className)} {...cleanProps(props)} />\n ),\n)\nSidebarSeparator.displayName = \"SidebarSeparator\"\n\n// =============================================\n// Card\n// =============================================\n\nexport type SidebarCardProps = ComponentProps<\"div\"> & {\n variant?: \"default\" | \"elevated\"\n dismissible?: boolean\n onDismiss?: () => void\n}\n\nexport const SidebarCard = forwardRef<HTMLDivElement, SidebarCardProps>(\n ({ variant = \"default\", dismissible = false, onDismiss, className, children, ...props }, ref) => (\n <div\n ref={ref}\n data-variant={variant}\n className={clsx(s.Card, className)}\n {...cleanProps(props)}\n >\n {dismissible && (\n <Button\n uniform\n size=\"3xs\"\n variant=\"ghost\"\n color=\"secondary\"\n className={s.CardDismiss}\n onClick={onDismiss}\n aria-label=\"Dismiss\"\n >\n <X />\n </Button>\n )}\n {children}\n </div>\n ),\n)\nSidebarCard.displayName = \"SidebarCard\"\n\nexport type SidebarCardHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarCardHeader = forwardRef<HTMLDivElement, SidebarCardHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardHeader.displayName = \"SidebarCardHeader\"\n\nexport type SidebarCardTitleProps = ComponentProps<\"div\">\n\nexport const SidebarCardTitle = forwardRef<HTMLDivElement, SidebarCardTitleProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardTitle, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardTitle.displayName = \"SidebarCardTitle\"\n\nexport type SidebarCardTitleLinkProps = ComponentProps<\"a\">\n\nexport const SidebarCardTitleLink = forwardRef<HTMLAnchorElement, SidebarCardTitleLinkProps>(\n ({ className, children, ...props }, ref) => (\n <a ref={ref} className={clsx(s.CardTitleLink, className)} {...cleanProps(props)}>\n {children}\n <ChevronRightMd className={s.CardTitleChevron} />\n </a>\n ),\n)\nSidebarCardTitleLink.displayName = \"SidebarCardTitleLink\"\n\nexport type SidebarCardContentProps = ComponentProps<\"div\">\n\nexport const SidebarCardContent = forwardRef<HTMLDivElement, SidebarCardContentProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardContent, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardContent.displayName = \"SidebarCardContent\"\n\nexport type SidebarCardFooterProps = ComponentProps<\"div\">\n\nexport const SidebarCardFooter = forwardRef<HTMLDivElement, SidebarCardFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.CardFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarCardFooter.displayName = \"SidebarCardFooter\"\n\n// =============================================\n// Inset (Main Content Area)\n// =============================================\n\nexport type SidebarInsetProps = ComponentProps<\"main\">\n\nexport const SidebarInset = forwardRef<HTMLElement, SidebarInsetProps>(\n ({ className, ...props }, ref) => {\n const { isMobile, openMobile } = useSidebar()\n // Behind the open phone drawer the page takes no focus or touch; `inert` of your own wins\n return (\n <main\n ref={ref}\n className={clsx(s.Inset, className)}\n inert={isMobile && openMobile ? true : undefined}\n {...cleanProps(props)}\n />\n )\n },\n)\nSidebarInset.displayName = \"SidebarInset\"\n\n// =============================================\n// Layout Container\n// =============================================\n\nexport type SidebarLayoutProps = ComponentProps<\"div\">\n\nexport const SidebarLayout = forwardRef<HTMLDivElement, SidebarLayoutProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.SidebarLayout, className)} {...cleanProps(props)} />\n ),\n)\nSidebarLayout.displayName = \"SidebarLayout\"\n\n// =============================================\n// Trigger (Collapse Button)\n// =============================================\n\nexport type SidebarTriggerProps = ComponentProps<\"button\"> & {\n children?: ReactNode\n}\n\nexport const SidebarTrigger = forwardRef<HTMLButtonElement, SidebarTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { state, collapsible, isMobile, toggleSidebar } = useSidebar()\n\n // Don't render if collapsible=\"none\" (text-only sidebars)\n if (collapsible === \"none\") {\n return null\n }\n\n // One icon for both states: the tooltip, not the icon, says what a press does\n const defaultIcon = <SidebarIcon />\n\n return (\n <button\n ref={ref}\n type=\"button\"\n className={clsx(s.Trigger, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) toggleSidebar()\n }}\n aria-label={\n isMobile ? \"Open menu\" : state === \"expanded\" ? \"Collapse sidebar\" : \"Expand sidebar\"\n }\n {...cleanProps(props)}\n >\n <span className={s.TriggerInner}>\n <span className={s.TriggerIcon}>{children ?? defaultIcon}</span>\n </span>\n </button>\n )\n },\n)\nSidebarTrigger.displayName = \"SidebarTrigger\"\n\n// =============================================\n// Mobile Menu Button (SidebarMenuMobile icon → X)\n// =============================================\n\nexport type SidebarMobileMenuButtonProps = ComponentProps<\"button\">\n\nexport const SidebarMobileMenuButton = forwardRef<HTMLButtonElement, SidebarMobileMenuButtonProps>(\n ({ className, onClick, ...props }, ref) => {\n const { openMobile, setOpenMobile } = useSidebar()\n\n return (\n <button\n ref={ref}\n type=\"button\"\n data-expanded={openMobile ? \"\" : undefined}\n // Where focus goes when a drawer closes and what opened it can no longer take it (lib/phoneDrawer)\n data-sidebar-mobile-menu-button=\"\"\n className={clsx(s.MobileMenuButton, className)}\n onClick={(event) => {\n // The caller's handler runs first and can cancel the toggle\n onClick?.(event)\n if (!event.defaultPrevented) setOpenMobile(!openMobile)\n }}\n aria-label={openMobile ? \"Close menu\" : \"Open menu\"}\n {...cleanProps(props)}\n >\n <span className={s.MobileMenuIcon}>\n <SidebarMenuMobile className={s.MobileMenuGlyph} data-glyph=\"menu\" />\n <X className={s.MobileMenuGlyph} data-glyph=\"close\" />\n </span>\n </button>\n )\n },\n)\nSidebarMobileMenuButton.displayName = \"SidebarMobileMenuButton\"\n\n// =============================================\n// Mobile Sidebar\n// =============================================\n\nexport type SidebarMobileProps = ComponentProps<\"div\"> & {\n /** When true, drawer is positioned absolute instead of fixed (for contained demos) */\n contained?: boolean\n /**\n * Rows that lead to another page end with a disclosure chevron, as in an iOS list. `false` leaves it out.\n * @default true\n */\n disclosure?: boolean\n}\n\n/**\n * The phone drawer: a modal dialog while it is open. Focus moves into it and Tab goes round its controls, the page\n * behind is inert (SidebarInset), Escape inside it closes it after any layer over it has taken its own, and focus\n * goes back to the control that opened it. A swipe in from the edge it slides from opens it and a swipe back closes\n * it (lib/phoneDrawer).\n */\nexport const SidebarMobile = forwardRef<HTMLDivElement, SidebarMobileProps>(\n ({ className, children, contained, disclosure = true, onKeyDown, ...props }, ref) => {\n const { isMobile, openMobile, setOpenMobile } = useSidebar()\n const drawerRef = useRef<HTMLDivElement>(null)\n // What the swipe and the keys read when they happen, kept current after each render\n const state = useRef({ open: openMobile, isMobile, setOpenMobile })\n useEffect(() => {\n state.current = { open: openMobile, isMobile, setOpenMobile }\n })\n\n // Focus moves in on open and back to what opened the drawer on close, or to a menu button when that can no longer\n // take it. A drawer that is not contained shows only at phone width, so going back to it from a wide window moves\n // focus in again.\n const shown = openMobile && (isMobile || Boolean(contained))\n useEffect(() => {\n const drawer = drawerRef.current\n if (!shown || !drawer) return\n const trigger = document.activeElement\n // Taken now: on unmount the cleanup runs once the drawer has left the page, with no provider around it\n const root = drawer.closest(\"[data-mobile-menu]\")\n if (!drawer.contains(document.activeElement)) drawerInitialFocus(drawer).focus({ preventScroll: true })\n return () => {\n const active = document.activeElement\n const lost = !active || active === document.body || drawer.contains(active)\n // On unmount a menu button that left with the drawer is gone too, and is not picked\n if (lost) returnDrawerFocus(trigger, drawer, root)\n }\n }, [shown])\n\n useEffect(() => {\n const drawer = drawerRef.current\n const root = drawer?.closest<HTMLElement>(\"[data-mobile-menu]\")\n if (!drawer || !root) return\n return attachDrawerSwipe({\n root,\n drawer,\n isOpen: () => state.current.open,\n setOpen: (open) => state.current.setOpenMobile(open),\n enabled: () => state.current.isMobile,\n })\n }, [])\n\n return (\n <>\n {/* Backdrop */}\n <div\n className={clsx(s.MobileBackdrop, contained && s.contained)}\n onClick={() => setOpenMobile(false)}\n aria-hidden=\"true\"\n />\n\n {/* Drawer */}\n <div\n ref={mergeRefs([ref, drawerRef])}\n role=\"dialog\"\n aria-modal={openMobile ? true : undefined}\n aria-label=\"Menu\"\n tabIndex={-1}\n inert={openMobile ? undefined : true}\n className={clsx(s.MobileSidebar, contained && s.contained, className)}\n onKeyDown={(event) => {\n // Your handler runs first and can keep the drawer open with preventDefault()\n onKeyDown?.(event)\n const drawer = drawerRef.current\n if (!openMobile || !drawer) return\n loopDrawerFocus(event.nativeEvent, drawer)\n closeOnUnhandledEscape(event.nativeEvent, drawer, () => state.current.setOpenMobile(false))\n }}\n {...cleanProps(props)}\n >\n <SidebarDrawerContext.Provider value={disclosure}>{children}</SidebarDrawerContext.Provider>\n </div>\n </>\n )\n },\n)\nSidebarMobile.displayName = \"SidebarMobile\"\n\nexport type SidebarMobileHeaderProps = ComponentProps<\"div\">\n\nexport const SidebarMobileHeader = forwardRef<HTMLDivElement, SidebarMobileHeaderProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileHeader, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileHeader.displayName = \"SidebarMobileHeader\"\n\nexport type SidebarMobileFooterProps = ComponentProps<\"div\">\n\nexport const SidebarMobileFooter = forwardRef<HTMLDivElement, SidebarMobileFooterProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.MobileFooter, className)} {...cleanProps(props)} />\n ),\n)\nSidebarMobileFooter.displayName = \"SidebarMobileFooter\"\n\n// =============================================\n// Input (Search)\n// =============================================\n\nexport type SidebarInputProps = InputProps\n\nexport const SidebarInput = forwardRef<HTMLInputElement, SidebarInputProps>(\n ({ className, ...props }, ref) => (\n <div className={s.Input}>\n <Input\n ref={ref}\n className={className}\n startAdornment={<SearchIcon />}\n {...cleanProps(props)}\n />\n </div>\n ),\n)\nSidebarInput.displayName = \"SidebarInput\"\n\n// =============================================\n// Footer Links\n// =============================================\n\nexport type SidebarFooterLinksProps = ComponentProps<\"div\">\n\nexport const SidebarFooterLinks = forwardRef<HTMLDivElement, SidebarFooterLinksProps>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={clsx(s.FooterLinks, className)} {...cleanProps(props)} />\n ),\n)\nSidebarFooterLinks.displayName = \"SidebarFooterLinks\"\n"]}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { maskitoParseTime, maskitoStringifyTime } from "@maskito/kit";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
|
+
const MS_IN_HOUR = 3_600_000;
|
|
4
|
+
const MS_IN_MINUTE = 60_000;
|
|
5
|
+
const MS_IN_SECOND = 1_000;
|
|
6
|
+
const inZone = (zone) => (zone ? { zone } : undefined);
|
|
7
|
+
const pad = (value, length) => String(value).padStart(length, "0");
|
|
8
|
+
const zones = new Map();
|
|
9
|
+
/**
|
|
10
|
+
* The zone typed dates are made in: the value's own zone object (Luxon's default zone without a value). A zone rebuilt
|
|
11
|
+
* from its name can be another one: Luxon's system zone becomes the zone of its name, the zone named UTC becomes the
|
|
12
|
+
* fixed UTC offset, and a name like UTC+5:5 (a 5:05 offset) does not parse back. The same object for the same zone,
|
|
13
|
+
* so it keys a memo.
|
|
14
|
+
*/
|
|
15
|
+
export const dateInputZone = (value) => {
|
|
16
|
+
if (!value?.isValid)
|
|
17
|
+
return undefined;
|
|
18
|
+
const { zone } = value;
|
|
19
|
+
const key = zone.isUniversal ? `${zone.type} ${zone.offset(0)}` : `${zone.type} ${zone.name}`;
|
|
20
|
+
const known = zones.get(key);
|
|
21
|
+
if (known)
|
|
22
|
+
return known;
|
|
23
|
+
zones.set(key, zone);
|
|
24
|
+
return zone;
|
|
25
|
+
};
|
|
26
|
+
/** The key a DateInput re-shows its value on: the instant and the zone. */
|
|
27
|
+
export const dateInputValueKey = (value) => value?.isValid ? `${value.toMillis()} ${value.zoneName}` : "";
|
|
28
|
+
// Maskito's own range: 0001-01-01 to 9999-12-31, end of day
|
|
29
|
+
const lowest = (zone) => DateTime.fromObject({ year: 1, month: 1, day: 1 }, inZone(zone));
|
|
30
|
+
const highest = (zone) => DateTime.fromObject({ year: 9999, month: 12, day: 31, hour: 23, minute: 59, second: 59, millisecond: 999 }, inZone(zone));
|
|
31
|
+
/**
|
|
32
|
+
* Within min and max, and within Maskito's own range when the mode has a year: a date typed without one is in
|
|
33
|
+
* year 0, which that range would turn into 0001-01-01.
|
|
34
|
+
*/
|
|
35
|
+
const clampToRange = (value, format, zone) => {
|
|
36
|
+
const withYear = format.mode.includes("y");
|
|
37
|
+
const min = format.min ?? (withYear ? lowest(zone).toMillis() : undefined);
|
|
38
|
+
const max = format.max ?? (withYear ? highest(zone).toMillis() : undefined);
|
|
39
|
+
const millis = value.toMillis();
|
|
40
|
+
if (min !== undefined && millis < min)
|
|
41
|
+
return DateTime.fromMillis(min, inZone(zone));
|
|
42
|
+
if (max !== undefined && millis > max)
|
|
43
|
+
return DateTime.fromMillis(max, inZone(zone));
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
/** The value's wall clock in its own zone, in the format */
|
|
47
|
+
const wallText = (shown, format) => {
|
|
48
|
+
const date = format.mode
|
|
49
|
+
.replaceAll("/", format.separator)
|
|
50
|
+
.replace(/d+/, pad(shown.day, 2))
|
|
51
|
+
.replace(/m+/, pad(shown.month, 2))
|
|
52
|
+
.replace(/y+/, (year) => pad(shown.year, 4).slice(-year.length));
|
|
53
|
+
if (!format.timeMode)
|
|
54
|
+
return date;
|
|
55
|
+
const msOfDay = shown.hour * MS_IN_HOUR + shown.minute * MS_IN_MINUTE + shown.second * MS_IN_SECOND + shown.millisecond;
|
|
56
|
+
return date + format.dateTimeSeparator + maskitoStringifyTime(msOfDay, { mode: format.timeMode });
|
|
57
|
+
};
|
|
58
|
+
/** The text a DateInput shows for a value: its wall clock in its own zone, kept within min and max. */
|
|
59
|
+
export const formatDateInput = (value, format) => value?.isValid ? wallText(clampToRange(value, format, value.zone), format) : "";
|
|
60
|
+
const segment = (digits, letters, letter) => digits.slice(letters.indexOf(letter), letters.lastIndexOf(letter) + 1);
|
|
61
|
+
/**
|
|
62
|
+
* Each instant the fields show in the zone, earliest first: two in an hour the clocks repeat, one in a time they skip,
|
|
63
|
+
* moved forward as Luxon does. `[]` for a date that does not exist.
|
|
64
|
+
*/
|
|
65
|
+
const passesAt = (fields, zone) => {
|
|
66
|
+
const parsed = DateTime.fromObject(fields, inZone(zone));
|
|
67
|
+
if (!parsed.isValid)
|
|
68
|
+
return [];
|
|
69
|
+
const passes = parsed.getPossibleOffsets().sort((a, b) => a.toMillis() - b.toMillis());
|
|
70
|
+
return passes.length ? passes : [parsed];
|
|
71
|
+
};
|
|
72
|
+
const withinBounds = (value, format) => (format.min === undefined || value.toMillis() >= format.min) && (format.max === undefined || value.toMillis() <= format.max);
|
|
73
|
+
/**
|
|
74
|
+
* Which instant a time the clocks show twice is. Luxon reads it with the offset in force today, so the same text would
|
|
75
|
+
* be one instant in summer and another in winter: it is the first pass, as the browser's Date reads it, or the second
|
|
76
|
+
* when only that one is within min and max. A text that is min's or max's own is that bound's pass, so a time kept at a
|
|
77
|
+
* bound reads back as the bound.
|
|
78
|
+
*/
|
|
79
|
+
const pickPass = (passes, format) => {
|
|
80
|
+
const [first] = passes;
|
|
81
|
+
if (passes.length < 2)
|
|
82
|
+
return first;
|
|
83
|
+
const text = wallText(first, format);
|
|
84
|
+
for (const bound of [format.min, format.max]) {
|
|
85
|
+
if (bound === undefined)
|
|
86
|
+
continue;
|
|
87
|
+
const shown = DateTime.fromMillis(bound, inZone(format.zone));
|
|
88
|
+
const onBound = wallText(shown, format) === text && passes.find((pass) => pass.offset === shown.offset);
|
|
89
|
+
if (onBound)
|
|
90
|
+
return onBound;
|
|
91
|
+
}
|
|
92
|
+
return passes.find((pass) => withinBounds(pass, format)) ?? first;
|
|
93
|
+
};
|
|
94
|
+
/** The typed fields of a complete text as a DateTime in the format's zone, or `null` */
|
|
95
|
+
const readTyped = (text, format) => {
|
|
96
|
+
const dateLetters = format.mode.replaceAll(/[^dmy]/g, "");
|
|
97
|
+
const timeLetters = format.timeMode?.replaceAll(/[^HMS]/g, "") ?? "";
|
|
98
|
+
const digits = text.replaceAll(/\D+/g, "");
|
|
99
|
+
if (digits.length !== dateLetters.length + timeLetters.length)
|
|
100
|
+
return null;
|
|
101
|
+
const dateDigits = digits.slice(0, dateLetters.length);
|
|
102
|
+
const day = segment(dateDigits, dateLetters, "d");
|
|
103
|
+
const month = segment(dateDigits, dateLetters, "m");
|
|
104
|
+
const year = segment(dateDigits, dateLetters, "y");
|
|
105
|
+
let msOfDay = 0;
|
|
106
|
+
if (format.timeMode) {
|
|
107
|
+
// Everything after the date's digits: the time and an AM/PM
|
|
108
|
+
const dateEnd = new RegExp(String.raw `^(?:\D*\d){${dateLetters.length}}`).exec(text)?.[0].length ?? 0;
|
|
109
|
+
msOfDay = maskitoParseTime(text.slice(dateEnd), { mode: format.timeMode });
|
|
110
|
+
}
|
|
111
|
+
const passes = passesAt({
|
|
112
|
+
// Maskito's reading: a two-digit year is in the 2000s, a missing one is year 0
|
|
113
|
+
year: year.length === 2 ? 2000 + Number(year) : Number(year || 0),
|
|
114
|
+
month: Number(month || 1),
|
|
115
|
+
day: Number(day || 1),
|
|
116
|
+
hour: Math.trunc(msOfDay / MS_IN_HOUR),
|
|
117
|
+
minute: Math.trunc((msOfDay % MS_IN_HOUR) / MS_IN_MINUTE),
|
|
118
|
+
second: Math.trunc((msOfDay % MS_IN_MINUTE) / MS_IN_SECOND),
|
|
119
|
+
millisecond: msOfDay % MS_IN_SECOND,
|
|
120
|
+
}, format.zone);
|
|
121
|
+
return passes.length ? pickPass(passes, format) : null;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The value for a complete text, or `null` while it is not one. A typed
|
|
125
|
+
* date is made in the format's zone from the typed fields, so the time is
|
|
126
|
+
* the one typed on a daylight saving day too. A date that does not exist is
|
|
127
|
+
* `null`; a time skipped by a clock change moves forward, as Luxon does, and
|
|
128
|
+
* a time the clocks show twice is its first pass, as the browser's Date reads
|
|
129
|
+
* it, unless only the second is within min and max or the text is a bound's
|
|
130
|
+
* own. Kept within min and max when the mode has a year, as Maskito's reading is.
|
|
131
|
+
*/
|
|
132
|
+
export const parseDateInput = (text, format) => {
|
|
133
|
+
const typed = readTyped(text, format);
|
|
134
|
+
if (!typed)
|
|
135
|
+
return null;
|
|
136
|
+
return format.mode.includes("y") ? clampToRange(typed, format, format.zone) : typed;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* min or max for Maskito's mask, which builds the typed dates with the
|
|
140
|
+
* browser's Date from their fields: the same fields, read in the value's
|
|
141
|
+
* zone, so the mask compares wall clocks. Only its steps for a date not yet
|
|
142
|
+
* complete read them, as keepTypedValue takes over the rest.
|
|
143
|
+
*/
|
|
144
|
+
export const maskDate = (millis, zone) => {
|
|
145
|
+
const shown = DateTime.fromMillis(millis, inZone(zone));
|
|
146
|
+
const date = new Date(shown.year, shown.month - 1, shown.day, shown.hour, shown.minute, shown.second, shown.millisecond);
|
|
147
|
+
// Years 0 to 99 would read as 1900 to 1999
|
|
148
|
+
date.setFullYear(shown.year);
|
|
149
|
+
return date;
|
|
150
|
+
};
|
|
151
|
+
const NO_BREAK_SPACE = "\u00A0";
|
|
152
|
+
/** A wall date made in UTC, where every day exists, to compare calendar dates */
|
|
153
|
+
const calendarDay = (value) => DateTime.fromObject({ year: value.year, month: value.month, day: value.day }, { zone: "UTC" });
|
|
154
|
+
/**
|
|
155
|
+
* A text whose date is complete but not its time: its date kept within the dates of min and max, as Maskito's step
|
|
156
|
+
* keeps it, on the calendar instead of the browser's Date. `null` for a date that does not exist, left to Maskito.
|
|
157
|
+
*/
|
|
158
|
+
const keepTypedDay = (value, format) => {
|
|
159
|
+
const dateLetters = format.mode.replaceAll(/[^dmy]/g, "");
|
|
160
|
+
const dateText = new RegExp(String.raw `^(?:\D*\d){${dateLetters.length}}`).exec(value)?.[0];
|
|
161
|
+
const dayFormat = { ...format, timeMode: undefined, min: undefined, max: undefined, zone: "UTC" };
|
|
162
|
+
const typed = dateText ? readTyped(dateText, dayFormat) : null;
|
|
163
|
+
if (!dateText || !typed)
|
|
164
|
+
return null;
|
|
165
|
+
const bound = (millis) => (millis === undefined ? undefined : calendarDay(DateTime.fromMillis(millis, inZone(format.zone))));
|
|
166
|
+
const min = bound(format.min);
|
|
167
|
+
const max = bound(format.max);
|
|
168
|
+
const kept = min && typed.toMillis() < min.toMillis() ? min : max && typed.toMillis() > max.toMillis() ? max : typed;
|
|
169
|
+
return wallText(kept, dayFormat) + value.slice(dateText.length);
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Maskito's date and date-and-time masks end with a step that rebuilds a complete date with the browser's Date to keep
|
|
173
|
+
* it within min and max: in a zone whose clocks skipped a whole day the date moved a day, in the hour the browser's
|
|
174
|
+
* clocks skip a time typed for a value in another zone moved an hour, and min and max held on the browser's clock.
|
|
175
|
+
* This step reads a complete text in the value's zone, as the value is read (a time the clocks skip moves forward, an
|
|
176
|
+
* hour they repeat is its first pass or the one within min and max), and shows it kept within min and max as instants,
|
|
177
|
+
* so the text is the value's. A date and time without its time yet keeps its date within the dates of min and max. A
|
|
178
|
+
* date that does not exist, or one not yet complete, stays with Maskito's step.
|
|
179
|
+
*/
|
|
180
|
+
export const keepTypedValue = (options, format) => {
|
|
181
|
+
const postprocessors = [...(options.postprocessors ?? [])];
|
|
182
|
+
const maskitoRange = postprocessors.pop();
|
|
183
|
+
if (!maskitoRange)
|
|
184
|
+
return options;
|
|
185
|
+
const keep = (state, initial) => {
|
|
186
|
+
// Complete once the AM or PM is typed too, as for Maskito
|
|
187
|
+
const complete = !format.timeMode?.includes("AA") || /[AP]M$/.test(state.value);
|
|
188
|
+
const typed = complete ? readTyped(state.value, format) : null;
|
|
189
|
+
// The mask puts a no-break space before AM and PM
|
|
190
|
+
const value = typed
|
|
191
|
+
? formatDateInput(typed, format).replace(/ (?=[AP]M$)/, NO_BREAK_SPACE)
|
|
192
|
+
: format.timeMode
|
|
193
|
+
? keepTypedDay(state.value, format)
|
|
194
|
+
: null;
|
|
195
|
+
if (value === null)
|
|
196
|
+
return maskitoRange(state, initial);
|
|
197
|
+
return value === state.value ? state : { value, selection: state.selection };
|
|
198
|
+
};
|
|
199
|
+
return { ...options, postprocessors: [...postprocessors, keep] };
|
|
200
|
+
};
|
|
201
|
+
//# s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,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9D,kDAAkD;QAClD,MAAM,KAAK,GAAG,KAAK;YACjB,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC;YACvE,CAAC,CAAC,MAAM,CAAC,QAAQ;gBACf,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC;gBACnC,CAAC,CAAC,IAAI,CAAA;QACV,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACvD,OAAO,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;IAC9E,CAAC,CAAA;IACD,OAAO,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,CAAA;AAClE,CAAC,CAAA","sourcesContent":["import type { MaskitoOptions, MaskitoPostprocessor } from \"@maskito/core\"\nimport { maskitoParseTime, maskitoStringifyTime, type MaskitoDateMode, type MaskitoTimeMode } from \"@maskito/kit\"\nimport { DateTime, type Zone } from \"luxon\"\n\n// DateInput's text and value, converted through the Luxon DateTime's own\n// calendar fields in its own zone. Maskito's date helpers go through the\n// browser's local Date instead: they show the browser's wall clock for a\n// value in another zone, and the date and time helpers count the time from\n// local midnight, an hour off on a daylight saving day.\n\nexport type DateInputFormat = {\n mode: MaskitoDateMode\n separator: string\n /** Set for a date and time */\n timeMode?: MaskitoTimeMode\n dateTimeSeparator: string\n /** Earliest allowed instant, in milliseconds */\n min?: number\n /** Latest allowed instant, in milliseconds */\n max?: number\n /** Zone of the value (dateInputZone): typed dates are made in it. Luxon's default zone when not set */\n zone?: Zone | string\n}\n\nconst MS_IN_HOUR = 3_600_000\nconst MS_IN_MINUTE = 60_000\nconst MS_IN_SECOND = 1_000\n\nconst inZone = (zone: Zone | string | undefined) => (zone ? { zone } : undefined)\n\nconst pad = (value: number, length: number) => String(value).padStart(length, \"0\")\n\nconst zones = new Map<string, Zone>()\n\n/**\n * The zone typed dates are made in: the value's own zone object (Luxon's default zone without a value). A zone rebuilt\n * from its name can be another one: Luxon's system zone becomes the zone of its name, the zone named UTC becomes the\n * fixed UTC offset, and a name like UTC+5:5 (a 5:05 offset) does not parse back. The same object for the same zone,\n * so it keys a memo.\n */\nexport const dateInputZone = (value: DateTime | null | undefined): Zone | undefined => {\n if (!value?.isValid) return undefined\n const { zone } = value\n const key = zone.isUniversal ? `${zone.type} ${zone.offset(0)}` : `${zone.type} ${zone.name}`\n const known = zones.get(key)\n if (known) return known\n zones.set(key, zone)\n return zone\n}\n\n/** The key a DateInput re-shows its value on: the instant and the zone. */\nexport const dateInputValueKey = (value: DateTime | null | undefined) =>\n value?.isValid ? `${value.toMillis()} ${value.zoneName}` : \"\"\n\n// Maskito's own range: 0001-01-01 to 9999-12-31, end of day\nconst lowest = (zone: Zone | string | undefined) => DateTime.fromObject({ year: 1, month: 1, day: 1 }, inZone(zone))\nconst highest = (zone: Zone | string | undefined) =>\n DateTime.fromObject({ year: 9999, month: 12, day: 31, hour: 23, minute: 59, second: 59, millisecond: 999 }, inZone(zone))\n\n/**\n * Within min and max, and within Maskito's own range when the mode has a year: a date typed without one is in\n * year 0, which that range would turn into 0001-01-01.\n */\nconst clampToRange = (value: DateTime, format: DateInputFormat, zone: Zone | string | undefined) => {\n const withYear = format.mode.includes(\"y\")\n const min = format.min ?? (withYear ? lowest(zone).toMillis() : undefined)\n const max = format.max ?? (withYear ? highest(zone).toMillis() : undefined)\n const millis = value.toMillis()\n if (min !== undefined && millis < min) return DateTime.fromMillis(min, inZone(zone))\n if (max !== undefined && millis > max) return DateTime.fromMillis(max, inZone(zone))\n return value\n}\n\n/** The value's wall clock in its own zone, in the format */\nconst wallText = (shown: DateTime, format: DateInputFormat) => {\n const date = format.mode\n .replaceAll(\"/\", format.separator)\n .replace(/d+/, pad(shown.day, 2))\n .replace(/m+/, pad(shown.month, 2))\n .replace(/y+/, (year) => pad(shown.year, 4).slice(-year.length))\n if (!format.timeMode) return date\n const msOfDay = shown.hour * MS_IN_HOUR + shown.minute * MS_IN_MINUTE + shown.second * MS_IN_SECOND + shown.millisecond\n return date + format.dateTimeSeparator + maskitoStringifyTime(msOfDay, { mode: format.timeMode })\n}\n\n/** The text a DateInput shows for a value: its wall clock in its own zone, kept within min and max. */\nexport const formatDateInput = (value: DateTime | null, format: DateInputFormat) =>\n value?.isValid ? wallText(clampToRange(value, format, value.zone), format) : \"\"\n\nconst segment = (digits: string, letters: string, letter: string) =>\n digits.slice(letters.indexOf(letter), letters.lastIndexOf(letter) + 1)\n\ntype Fields = { year: number; month: number; day: number; hour: number; minute: number; second: number; millisecond: number }\n\n/**\n * Each instant the fields show in the zone, earliest first: two in an hour the clocks repeat, one in a time they skip,\n * moved forward as Luxon does. `[]` for a date that does not exist.\n */\nconst passesAt = (fields: Fields, zone: Zone | string | undefined) => {\n const parsed = DateTime.fromObject(fields, inZone(zone))\n if (!parsed.isValid) return []\n const passes = parsed.getPossibleOffsets().sort((a, b) => a.toMillis() - b.toMillis())\n return passes.length ? passes : [parsed]\n}\n\nconst withinBounds = (value: DateTime, format: DateInputFormat) =>\n (format.min === undefined || value.toMillis() >= format.min) && (format.max === undefined || value.toMillis() <= format.max)\n\n/**\n * Which instant a time the clocks show twice is. Luxon reads it with the offset in force today, so the same text would\n * be one instant in summer and another in winter: it is the first pass, as the browser's Date reads it, or the second\n * when only that one is within min and max. A text that is min's or max's own is that bound's pass, so a time kept at a\n * bound reads back as the bound.\n */\nconst pickPass = (passes: DateTime[], format: DateInputFormat) => {\n const [first] = passes\n if (passes.length < 2) return first\n const text = wallText(first, format)\n for (const bound of [format.min, format.max]) {\n if (bound === undefined) continue\n const shown = DateTime.fromMillis(bound, inZone(format.zone))\n const onBound = wallText(shown, format) === text && passes.find((pass) => pass.offset === shown.offset)\n if (onBound) return onBound\n }\n return passes.find((pass) => withinBounds(pass, format)) ?? first\n}\n\n/** The typed fields of a complete text as a DateTime in the format's zone, or `null` */\nconst readTyped = (text: string, format: DateInputFormat) => {\n const dateLetters = format.mode.replaceAll(/[^dmy]/g, \"\")\n const timeLetters = format.timeMode?.replaceAll(/[^HMS]/g, \"\") ?? \"\"\n const digits = text.replaceAll(/\\D+/g, \"\")\n if (digits.length !== dateLetters.length + timeLetters.length) return null\n\n const dateDigits = digits.slice(0, dateLetters.length)\n const day = segment(dateDigits, dateLetters, \"d\")\n const month = segment(dateDigits, dateLetters, \"m\")\n const year = segment(dateDigits, dateLetters, \"y\")\n\n let msOfDay = 0\n if (format.timeMode) {\n // Everything after the date's digits: the time and an AM/PM\n const dateEnd = new RegExp(String.raw`^(?:\\D*\\d){${dateLetters.length}}`).exec(text)?.[0].length ?? 0\n msOfDay = maskitoParseTime(text.slice(dateEnd), { mode: format.timeMode })\n }\n\n const passes = passesAt(\n {\n // Maskito's reading: a two-digit year is in the 2000s, a missing one is year 0\n year: year.length === 2 ? 2000 + Number(year) : Number(year || 0),\n month: Number(month || 1),\n day: Number(day || 1),\n hour: Math.trunc(msOfDay / MS_IN_HOUR),\n minute: Math.trunc((msOfDay % MS_IN_HOUR) / MS_IN_MINUTE),\n second: Math.trunc((msOfDay % MS_IN_MINUTE) / MS_IN_SECOND),\n millisecond: msOfDay % MS_IN_SECOND,\n },\n format.zone,\n )\n return passes.length ? pickPass(passes, format) : null\n}\n\n/**\n * The value for a complete text, or `null` while it is not one. A typed\n * date is made in the format's zone from the typed fields, so the time is\n * the one typed on a daylight saving day too. A date that does not exist is\n * `null`; a time skipped by a clock change moves forward, as Luxon does, and\n * a time the clocks show twice is its first pass, as the browser's Date reads\n * it, unless only the second is within min and max or the text is a bound's\n * own. Kept within min and max when the mode has a year, as Maskito's reading is.\n */\nexport const parseDateInput = (text: string, format: DateInputFormat) => {\n const typed = readTyped(text, format)\n if (!typed) return null\n return format.mode.includes(\"y\") ? clampToRange(typed, format, format.zone) : typed\n}\n\n/**\n * min or max for Maskito's mask, which builds the typed dates with the\n * browser's Date from their fields: the same fields, read in the value's\n * zone, so the mask compares wall clocks. Only its steps for a date not yet\n * complete read them, as keepTypedValue takes over the rest.\n */\nexport const maskDate = (millis: number, zone: Zone | string | undefined) => {\n const shown = DateTime.fromMillis(millis, inZone(zone))\n const date = new Date(shown.year, shown.month - 1, shown.day, shown.hour, shown.minute, shown.second, shown.millisecond)\n // Years 0 to 99 would read as 1900 to 1999\n date.setFullYear(shown.year)\n return date\n}\n\nconst NO_BREAK_SPACE = \"\\u00A0\"\n\n/** A wall date made in UTC, where every day exists, to compare calendar dates */\nconst calendarDay = (value: DateTime) => DateTime.fromObject({ year: value.year, month: value.month, day: value.day }, { zone: \"UTC\" })\n\n/**\n * A text whose date is complete but not its time: its date kept within the dates of min and max, as Maskito's step\n * keeps it, on the calendar instead of the browser's Date. `null` for a date that does not exist, left to Maskito.\n */\nconst keepTypedDay = (value: string, format: DateInputFormat) => {\n const dateLetters = format.mode.replaceAll(/[^dmy]/g, \"\")\n const dateText = new RegExp(String.raw`^(?:\\D*\\d){${dateLetters.length}}`).exec(value)?.[0]\n const dayFormat = { ...format, timeMode: undefined, min: undefined, max: undefined, zone: \"UTC\" }\n const typed = dateText ? readTyped(dateText, dayFormat) : null\n if (!dateText || !typed) return null\n const bound = (millis: number | undefined) => (millis === undefined ? undefined : calendarDay(DateTime.fromMillis(millis, inZone(format.zone))))\n const min = bound(format.min)\n const max = bound(format.max)\n const kept = min && typed.toMillis() < min.toMillis() ? min : max && typed.toMillis() > max.toMillis() ? max : typed\n return wallText(kept, dayFormat) + value.slice(dateText.length)\n}\n\n/**\n * Maskito's date and date-and-time masks end with a step that rebuilds a complete date with the browser's Date to keep\n * it within min and max: in a zone whose clocks skipped a whole day the date moved a day, in the hour the browser's\n * clocks skip a time typed for a value in another zone moved an hour, and min and max held on the browser's clock.\n * This step reads a complete text in the value's zone, as the value is read (a time the clocks skip moves forward, an\n * hour they repeat is its first pass or the one within min and max), and shows it kept within min and max as instants,\n * so the text is the value's. A date and time without its time yet keeps its date within the dates of min and max. A\n * date that does not exist, or one not yet complete, stays with Maskito's step.\n */\nexport const keepTypedValue = (options: MaskitoOptions, format: DateInputFormat): MaskitoOptions => {\n const postprocessors = [...(options.postprocessors ?? [])]\n const maskitoRange = postprocessors.pop()\n if (!maskitoRange) return options\n const keep: MaskitoPostprocessor = (state, initial) => {\n // Complete once the AM or PM is typed too, as for Maskito\n const complete = !format.timeMode?.includes(\"AA\") || /[AP]M$/.test(state.value)\n const typed = complete ? readTyped(state.value, format) : null\n // The mask puts a no-break space before AM and PM\n const value = typed\n ? formatDateInput(typed, format).replace(/ (?=[AP]M$)/, NO_BREAK_SPACE)\n : format.timeMode\n ? keepTypedDay(state.value, format)\n : null\n if (value === null) return maskitoRange(state, initial)\n return value === state.value ? state : { value, selection: state.selection }\n }\n return { ...options, postprocessors: [...postprocessors, keep] }\n}\n"]}
|
|
@@ -158,6 +158,33 @@ export const drawerTabbables = (drawer) => Array.from(drawer.querySelectorAll(TA
|
|
|
158
158
|
(typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true })));
|
|
159
159
|
/** The first control of the open drawer, or the drawer itself */
|
|
160
160
|
export const drawerInitialFocus = (drawer) => drawerTabbables(drawer)[0] ?? drawer;
|
|
161
|
+
const MENU_BUTTON = "[data-sidebar-mobile-menu-button]";
|
|
162
|
+
const PROVIDER = "[data-mobile-menu]";
|
|
163
|
+
/** Focus can go there: connected, not disabled, not inert or hidden, visible */
|
|
164
|
+
const canTakeFocus = (element) => element instanceof HTMLElement &&
|
|
165
|
+
element.isConnected &&
|
|
166
|
+
!element.matches(":disabled") &&
|
|
167
|
+
!element.closest("[inert], [hidden]") &&
|
|
168
|
+
(typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true }));
|
|
169
|
+
/**
|
|
170
|
+
* Focuses where focus goes when the drawer closes: the control that opened it, or, when that cannot take focus (it
|
|
171
|
+
* sat in another drawer that has closed since, it is gone, or it was the page itself), the menu button of this
|
|
172
|
+
* drawer's provider, then any menu button on the page. The first that takes focus; `null` when none does. A drawer
|
|
173
|
+
* that has already left the page has no provider around it, so `root` is the provider taken while it was open.
|
|
174
|
+
*/
|
|
175
|
+
export const returnDrawerFocus = (opener, drawer, root = drawer.closest(PROVIDER)) => {
|
|
176
|
+
// The provider's own menu buttons, not those of a provider inside it
|
|
177
|
+
const own = [...(root?.querySelectorAll(MENU_BUTTON) ?? [])].filter((button) => button.closest(PROVIDER) === root);
|
|
178
|
+
const candidates = [opener, ...own, ...document.querySelectorAll(MENU_BUTTON)];
|
|
179
|
+
for (const candidate of candidates) {
|
|
180
|
+
if (!canTakeFocus(candidate) || drawer.contains(candidate) || candidate === candidate.ownerDocument.body)
|
|
181
|
+
continue;
|
|
182
|
+
candidate.focus({ preventScroll: true });
|
|
183
|
+
if (candidate.ownerDocument.activeElement === candidate)
|
|
184
|
+
return candidate;
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
161
188
|
/**
|
|
162
189
|
* Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open
|
|
163
190
|
* drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phoneDrawer.js","sourceRoot":"","sources":["../../../src/lib/phoneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAClC,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,sGAAsG;AACtG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,sF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,QAAQ,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;QACrE,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACrC,CAAC;SAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAC9C,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAoB,EAAE,MAAmB,EAAE,KAAiB;IACjG,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,gBAAgB;QAAE,OAAM;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAA;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,MAAM,WAAW,GAAG,CAAC,IAAW,EAAE,EAAE;QAClC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAChD,oGAAoG;QACpG,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAM;QACpD,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;IACD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/**\n * The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).\n *\n * - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes\n * it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in\n * `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`\n * and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.\n * - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other\n * listener has had the key, so a menu or dialog over the drawer takes its own Escape first.\n */\n\n/** How far in from its edge a swipe that opens the drawer may start */\nexport const DRAWER_EDGE_ZONE = 24\n/** How far a finger moves before the swipe is taken as horizontal or left to the page */\nexport const DRAWER_SWIPE_SLOP = 10\n/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */\nexport const DRAWER_SWIPE_VELOCITY = 0.3\n/** A finger held still this long, in ms, before it lifts lets go by distance alone */\nexport const DRAWER_SWIPE_HOLD = 100\n\nexport type DrawerSwipeOptions = {\n /** The element that holds the drawer and the page, where the drag state is written */\n root: HTMLElement\n /** The drawer itself */\n drawer: HTMLElement\n isOpen: () => boolean\n setOpen: (open: boolean) => void\n /** False turns the gesture off (a wide layout) */\n enabled?: () => boolean\n}\n\ntype Drag = {\n x: number\n y: number\n lastX: number\n lastTime: number\n velocity: number\n open: boolean\n edge: \"left\" | \"right\"\n travel: number\n state: \"pending\" | \"dragging\" | \"ignored\"\n progress: number\n}\n\nconst edgeOf = (drawer: HTMLElement): \"left\" | \"right\" =>\n getComputedStyle(drawer).getPropertyValue(\"--sidebar-drawer-edge\").trim() === \"left\" ? \"left\" : \"right\"\n\n/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */\nconst travelOf = (drawer: HTMLElement, root: HTMLElement, edge: \"left\" | \"right\") => {\n if (edge === \"left\") return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width\n const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null\n return container?.clientWidth || window.innerWidth\n}\n\n/**\n * A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such\n * as the Slider) or in a row that scrolls sideways moves that, not the drawer\n */\nconst ownsHorizontalSwipe = (target: EventTarget | null, root: HTMLElement) => {\n for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {\n if ((node instanceof HTMLInputElement && node.type === \"range\") || node.getAttribute(\"role\") === \"slider\") return true\n const style = getComputedStyle(node)\n if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes(\"pan-x\")) return true\n if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX)) return true\n }\n return false\n}\n\n/**\n * A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer\n * away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.\n */\nconst layerOpen = (root: HTMLElement) =>\n root.ownerDocument.querySelector(\"[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]\") !== null\n\n/** Starts the gesture on `root`; returns the cleanup */\nexport function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }: DrawerSwipeOptions) {\n let drag: Drag | null = null\n\n const setProgress = (progress: number) => {\n root.style.setProperty(\"--sidebar-drawer-progress\", String(progress))\n }\n\n const end = (commit: boolean, time = 0) => {\n const current = drag\n drag = null\n if (!current || current.state !== \"dragging\") return\n let next = current.open\n if (commit) {\n // Velocity in the opening direction is positive; a finger that stopped before lifting has none\n const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity\n const opening = current.edge === \"left\" ? velocity : -velocity\n next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5\n }\n if (next !== current.open) setOpen(next)\n // The drawer leaves the finger once the new state is on the page, so it animates from where it was let go\n requestAnimationFrame(() => {\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n })\n }\n\n const onTouchStart = (event: TouchEvent) => {\n // A second finger cancels a swipe under way, and the drawer goes back to where it was\n end(false)\n if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root)) return\n const touch = event.touches[0]!\n const open = isOpen()\n const edge = edgeOf(drawer)\n if (!open) {\n const bounds = root.getBoundingClientRect()\n const fromEdge = edge === \"left\" ? touch.clientX - bounds.left : bounds.right - touch.clientX\n if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE) return\n }\n drag = {\n x: touch.clientX,\n y: touch.clientY,\n lastX: touch.clientX,\n lastTime: event.timeStamp,\n velocity: 0,\n open,\n edge,\n travel: Math.max(1, travelOf(drawer, root, edge)),\n state: \"pending\",\n progress: open ? 1 : 0,\n }\n }\n\n const onTouchMove = (event: TouchEvent) => {\n if (!drag || drag.state === \"ignored\") return\n // A second finger put down outside the root shows only here\n if (event.touches.length !== 1) {\n end(false)\n return\n }\n const touch = event.touches[0]\n if (!touch) return\n const dx = touch.clientX - drag.x\n const dy = touch.clientY - drag.y\n // Toward the open drawer is positive\n const toward = drag.edge === \"left\" ? dx : -dx\n if (drag.state === \"pending\") {\n if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP) return\n const horizontal = Math.abs(dx) > Math.abs(dy)\n if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {\n drag.state = \"ignored\"\n return\n }\n drag.state = \"dragging\"\n root.setAttribute(\"data-mobile-dragging\", \"\")\n }\n if (event.cancelable) event.preventDefault()\n const elapsed = event.timeStamp - drag.lastTime\n if (elapsed > 0) drag.velocity = (touch.clientX - drag.lastX) / elapsed\n drag.lastX = touch.clientX\n drag.lastTime = event.timeStamp\n drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel))\n setProgress(drag.progress)\n }\n\n // A finger lifted while another stays on the screen cancels the swipe\n const onTouchEnd = (event: TouchEvent) => end(event.touches.length === 0, event.timeStamp)\n const onTouchCancel = () => end(false)\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true })\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false })\n root.addEventListener(\"touchend\", onTouchEnd)\n root.addEventListener(\"touchcancel\", onTouchCancel)\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart)\n root.removeEventListener(\"touchmove\", onTouchMove)\n root.removeEventListener(\"touchend\", onTouchEnd)\n root.removeEventListener(\"touchcancel\", onTouchCancel)\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n }\n}\n\nconst TABBABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]'\n\n/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */\nexport const drawerTabbables = (drawer: HTMLElement) =>\n Array.from(drawer.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n/** The first control of the open drawer, or the drawer itself */\nexport const drawerInitialFocus = (drawer: HTMLElement) => drawerTabbables(drawer)[0] ?? drawer\n\n/**\n * Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open\n * drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.\n */\nexport function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement) {\n if (event.key !== \"Tab\" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return\n if (!(event.target instanceof Node) || !drawer.contains(event.target)) return\n const items = drawerTabbables(drawer)\n const active = drawer.ownerDocument.activeElement\n const first = items[0]\n const last = items[items.length - 1]\n if (!first || !last) {\n event.preventDefault()\n drawer.focus({ preventScroll: true })\n } else if (event.shiftKey && (active === first || active === drawer)) {\n event.preventDefault()\n last.focus({ preventScroll: true })\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus({ preventScroll: true })\n }\n}\n\n/**\n * Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog\n * over the drawer has its listener on the way there and takes the key first, however it listens.\n */\nexport function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void) {\n if (event.key !== \"Escape\" || event.defaultPrevented) return\n const view = drawer.ownerDocument.defaultView\n if (!view) return\n const afterOthers = (late: Event) => {\n view.removeEventListener(\"keydown\", afterOthers)\n // A listener that stopped the key on its way leaves this one to the next key, which only removes it\n if (late !== event || event.defaultPrevented) return\n event.preventDefault()\n close()\n }\n view.addEventListener(\"keydown\", afterOthers)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phoneDrawer.js","sourceRoot":"","sources":["../../../src/lib/phoneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAClC,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,sGAAsG;AACtG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AA0BpC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAoB,EAAE,CACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;AAEzG,mHAAmH;AACnH,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAE,IAAiB,EAAE,IAAsB,EAAE,EAAE;IAClF,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,qBAAqB,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAA;IACtG,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,YAAY,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;IACzF,OAAO,SAAS,EAAE,WAAW,IAAI,MAAM,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IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAA;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,MAAM,WAAW,GAAG,CAAC,IAAW,EAAE,EAAE;QAClC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAChD,oGAAoG;QACpG,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAM;QACpD,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;IACD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/**\n * The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).\n *\n * - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes\n * it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in\n * `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`\n * and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.\n * - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other\n * listener has had the key, so a menu or dialog over the drawer takes its own Escape first.\n */\n\n/** How far in from its edge a swipe that opens the drawer may start */\nexport const DRAWER_EDGE_ZONE = 24\n/** How far a finger moves before the swipe is taken as horizontal or left to the page */\nexport const DRAWER_SWIPE_SLOP = 10\n/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */\nexport const DRAWER_SWIPE_VELOCITY = 0.3\n/** A finger held still this long, in ms, before it lifts lets go by distance alone */\nexport const DRAWER_SWIPE_HOLD = 100\n\nexport type DrawerSwipeOptions = {\n /** The element that holds the drawer and the page, where the drag state is written */\n root: HTMLElement\n /** The drawer itself */\n drawer: HTMLElement\n isOpen: () => boolean\n setOpen: (open: boolean) => void\n /** False turns the gesture off (a wide layout) */\n enabled?: () => boolean\n}\n\ntype Drag = {\n x: number\n y: number\n lastX: number\n lastTime: number\n velocity: number\n open: boolean\n edge: \"left\" | \"right\"\n travel: number\n state: \"pending\" | \"dragging\" | \"ignored\"\n progress: number\n}\n\nconst edgeOf = (drawer: HTMLElement): \"left\" | \"right\" =>\n getComputedStyle(drawer).getPropertyValue(\"--sidebar-drawer-edge\").trim() === \"left\" ? \"left\" : \"right\"\n\n/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */\nconst travelOf = (drawer: HTMLElement, root: HTMLElement, edge: \"left\" | \"right\") => {\n if (edge === \"left\") return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width\n const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null\n return container?.clientWidth || window.innerWidth\n}\n\n/**\n * A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such\n * as the Slider) or in a row that scrolls sideways moves that, not the drawer\n */\nconst ownsHorizontalSwipe = (target: EventTarget | null, root: HTMLElement) => {\n for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {\n if ((node instanceof HTMLInputElement && node.type === \"range\") || node.getAttribute(\"role\") === \"slider\") return true\n const style = getComputedStyle(node)\n if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes(\"pan-x\")) return true\n if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX)) return true\n }\n return false\n}\n\n/**\n * A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer\n * away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.\n */\nconst layerOpen = (root: HTMLElement) =>\n root.ownerDocument.querySelector(\"[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]\") !== null\n\n/** Starts the gesture on `root`; returns the cleanup */\nexport function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }: DrawerSwipeOptions) {\n let drag: Drag | null = null\n\n const setProgress = (progress: number) => {\n root.style.setProperty(\"--sidebar-drawer-progress\", String(progress))\n }\n\n const end = (commit: boolean, time = 0) => {\n const current = drag\n drag = null\n if (!current || current.state !== \"dragging\") return\n let next = current.open\n if (commit) {\n // Velocity in the opening direction is positive; a finger that stopped before lifting has none\n const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity\n const opening = current.edge === \"left\" ? velocity : -velocity\n next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5\n }\n if (next !== current.open) setOpen(next)\n // The drawer leaves the finger once the new state is on the page, so it animates from where it was let go\n requestAnimationFrame(() => {\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n })\n }\n\n const onTouchStart = (event: TouchEvent) => {\n // A second finger cancels a swipe under way, and the drawer goes back to where it was\n end(false)\n if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root)) return\n const touch = event.touches[0]!\n const open = isOpen()\n const edge = edgeOf(drawer)\n if (!open) {\n const bounds = root.getBoundingClientRect()\n const fromEdge = edge === \"left\" ? touch.clientX - bounds.left : bounds.right - touch.clientX\n if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE) return\n }\n drag = {\n x: touch.clientX,\n y: touch.clientY,\n lastX: touch.clientX,\n lastTime: event.timeStamp,\n velocity: 0,\n open,\n edge,\n travel: Math.max(1, travelOf(drawer, root, edge)),\n state: \"pending\",\n progress: open ? 1 : 0,\n }\n }\n\n const onTouchMove = (event: TouchEvent) => {\n if (!drag || drag.state === \"ignored\") return\n // A second finger put down outside the root shows only here\n if (event.touches.length !== 1) {\n end(false)\n return\n }\n const touch = event.touches[0]\n if (!touch) return\n const dx = touch.clientX - drag.x\n const dy = touch.clientY - drag.y\n // Toward the open drawer is positive\n const toward = drag.edge === \"left\" ? dx : -dx\n if (drag.state === \"pending\") {\n if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP) return\n const horizontal = Math.abs(dx) > Math.abs(dy)\n if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {\n drag.state = \"ignored\"\n return\n }\n drag.state = \"dragging\"\n root.setAttribute(\"data-mobile-dragging\", \"\")\n }\n if (event.cancelable) event.preventDefault()\n const elapsed = event.timeStamp - drag.lastTime\n if (elapsed > 0) drag.velocity = (touch.clientX - drag.lastX) / elapsed\n drag.lastX = touch.clientX\n drag.lastTime = event.timeStamp\n drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel))\n setProgress(drag.progress)\n }\n\n // A finger lifted while another stays on the screen cancels the swipe\n const onTouchEnd = (event: TouchEvent) => end(event.touches.length === 0, event.timeStamp)\n const onTouchCancel = () => end(false)\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true })\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false })\n root.addEventListener(\"touchend\", onTouchEnd)\n root.addEventListener(\"touchcancel\", onTouchCancel)\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart)\n root.removeEventListener(\"touchmove\", onTouchMove)\n root.removeEventListener(\"touchend\", onTouchEnd)\n root.removeEventListener(\"touchcancel\", onTouchCancel)\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n }\n}\n\nconst TABBABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]'\n\n/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */\nexport const drawerTabbables = (drawer: HTMLElement) =>\n Array.from(drawer.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n/** The first control of the open drawer, or the drawer itself */\nexport const drawerInitialFocus = (drawer: HTMLElement) => drawerTabbables(drawer)[0] ?? drawer\n\nconst MENU_BUTTON = \"[data-sidebar-mobile-menu-button]\"\nconst PROVIDER = \"[data-mobile-menu]\"\n\n/** Focus can go there: connected, not disabled, not inert or hidden, visible */\nconst canTakeFocus = (element: Element | null): element is HTMLElement =>\n element instanceof HTMLElement &&\n element.isConnected &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true }))\n\n/**\n * Focuses where focus goes when the drawer closes: the control that opened it, or, when that cannot take focus (it\n * sat in another drawer that has closed since, it is gone, or it was the page itself), the menu button of this\n * drawer's provider, then any menu button on the page. The first that takes focus; `null` when none does. A drawer\n * that has already left the page has no provider around it, so `root` is the provider taken while it was open.\n */\nexport const returnDrawerFocus = (\n opener: Element | null,\n drawer: HTMLElement,\n root: Element | null = drawer.closest(PROVIDER),\n): HTMLElement | null => {\n // The provider's own menu buttons, not those of a provider inside it\n const own = [...(root?.querySelectorAll(MENU_BUTTON) ?? [])].filter((button) => button.closest(PROVIDER) === root)\n const candidates = [opener, ...own, ...document.querySelectorAll(MENU_BUTTON)]\n for (const candidate of candidates) {\n if (!canTakeFocus(candidate) || drawer.contains(candidate) || candidate === candidate.ownerDocument.body) continue\n candidate.focus({ preventScroll: true })\n if (candidate.ownerDocument.activeElement === candidate) return candidate\n }\n return null\n}\n\n/**\n * Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open\n * drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.\n */\nexport function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement) {\n if (event.key !== \"Tab\" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return\n if (!(event.target instanceof Node) || !drawer.contains(event.target)) return\n const items = drawerTabbables(drawer)\n const active = drawer.ownerDocument.activeElement\n const first = items[0]\n const last = items[items.length - 1]\n if (!first || !last) {\n event.preventDefault()\n drawer.focus({ preventScroll: true })\n } else if (event.shiftKey && (active === first || active === drawer)) {\n event.preventDefault()\n last.focus({ preventScroll: true })\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus({ preventScroll: true })\n }\n}\n\n/**\n * Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog\n * over the drawer has its listener on the way there and takes the key first, however it listens.\n */\nexport function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void) {\n if (event.key !== \"Escape\" || event.defaultPrevented) return\n const view = drawer.ownerDocument.defaultView\n if (!view) return\n const afterOthers = (late: Event) => {\n view.removeEventListener(\"keydown\", afterOthers)\n // A listener that stopped the key on its way leaves this one to the next key, which only removes it\n if (late !== event || event.defaultPrevented) return\n event.preventDefault()\n close()\n }\n view.addEventListener(\"keydown\", afterOthers)\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { MaskitoOptions } from "@maskito/core";
|
|
2
|
+
import { type MaskitoDateMode, type MaskitoTimeMode } from "@maskito/kit";
|
|
3
|
+
import { DateTime, type Zone } from "luxon";
|
|
4
|
+
export type DateInputFormat = {
|
|
5
|
+
mode: MaskitoDateMode;
|
|
6
|
+
separator: string;
|
|
7
|
+
/** Set for a date and time */
|
|
8
|
+
timeMode?: MaskitoTimeMode;
|
|
9
|
+
dateTimeSeparator: string;
|
|
10
|
+
/** Earliest allowed instant, in milliseconds */
|
|
11
|
+
min?: number;
|
|
12
|
+
/** Latest allowed instant, in milliseconds */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** Zone of the value (dateInputZone): typed dates are made in it. Luxon's default zone when not set */
|
|
15
|
+
zone?: Zone | string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The zone typed dates are made in: the value's own zone object (Luxon's default zone without a value). A zone rebuilt
|
|
19
|
+
* from its name can be another one: Luxon's system zone becomes the zone of its name, the zone named UTC becomes the
|
|
20
|
+
* fixed UTC offset, and a name like UTC+5:5 (a 5:05 offset) does not parse back. The same object for the same zone,
|
|
21
|
+
* so it keys a memo.
|
|
22
|
+
*/
|
|
23
|
+
export declare const dateInputZone: (value: DateTime | null | undefined) => Zone | undefined;
|
|
24
|
+
/** The key a DateInput re-shows its value on: the instant and the zone. */
|
|
25
|
+
export declare const dateInputValueKey: (value: DateTime | null | undefined) => string;
|
|
26
|
+
/** The text a DateInput shows for a value: its wall clock in its own zone, kept within min and max. */
|
|
27
|
+
export declare const formatDateInput: (value: DateTime | null, format: DateInputFormat) => string;
|
|
28
|
+
/**
|
|
29
|
+
* The value for a complete text, or `null` while it is not one. A typed
|
|
30
|
+
* date is made in the format's zone from the typed fields, so the time is
|
|
31
|
+
* the one typed on a daylight saving day too. A date that does not exist is
|
|
32
|
+
* `null`; a time skipped by a clock change moves forward, as Luxon does, and
|
|
33
|
+
* a time the clocks show twice is its first pass, as the browser's Date reads
|
|
34
|
+
* it, unless only the second is within min and max or the text is a bound's
|
|
35
|
+
* own. Kept within min and max when the mode has a year, as Maskito's reading is.
|
|
36
|
+
*/
|
|
37
|
+
export declare const parseDateInput: (text: string, format: DateInputFormat) => DateTime<boolean> | null;
|
|
38
|
+
/**
|
|
39
|
+
* min or max for Maskito's mask, which builds the typed dates with the
|
|
40
|
+
* browser's Date from their fields: the same fields, read in the value's
|
|
41
|
+
* zone, so the mask compares wall clocks. Only its steps for a date not yet
|
|
42
|
+
* complete read them, as keepTypedValue takes over the rest.
|
|
43
|
+
*/
|
|
44
|
+
export declare const maskDate: (millis: number, zone: Zone | string | undefined) => Date;
|
|
45
|
+
/**
|
|
46
|
+
* Maskito's date and date-and-time masks end with a step that rebuilds a complete date with the browser's Date to keep
|
|
47
|
+
* it within min and max: in a zone whose clocks skipped a whole day the date moved a day, in the hour the browser's
|
|
48
|
+
* clocks skip a time typed for a value in another zone moved an hour, and min and max held on the browser's clock.
|
|
49
|
+
* This step reads a complete text in the value's zone, as the value is read (a time the clocks skip moves forward, an
|
|
50
|
+
* hour they repeat is its first pass or the one within min and max), and shows it kept within min and max as instants,
|
|
51
|
+
* so the text is the value's. A date and time without its time yet keeps its date within the dates of min and max. A
|
|
52
|
+
* date that does not exist, or one not yet complete, stays with Maskito's step.
|
|
53
|
+
*/
|
|
54
|
+
export declare const keepTypedValue: (options: MaskitoOptions, format: DateInputFormat) => MaskitoOptions;
|
|
@@ -32,6 +32,13 @@ export declare function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabl
|
|
|
32
32
|
export declare const drawerTabbables: (drawer: HTMLElement) => HTMLElement[];
|
|
33
33
|
/** The first control of the open drawer, or the drawer itself */
|
|
34
34
|
export declare const drawerInitialFocus: (drawer: HTMLElement) => HTMLElement;
|
|
35
|
+
/**
|
|
36
|
+
* Focuses where focus goes when the drawer closes: the control that opened it, or, when that cannot take focus (it
|
|
37
|
+
* sat in another drawer that has closed since, it is gone, or it was the page itself), the menu button of this
|
|
38
|
+
* drawer's provider, then any menu button on the page. The first that takes focus; `null` when none does. A drawer
|
|
39
|
+
* that has already left the page has no provider around it, so `root` is the provider taken while it was open.
|
|
40
|
+
*/
|
|
41
|
+
export declare const returnDrawerFocus: (opener: Element | null, drawer: HTMLElement, root?: Element | null) => HTMLElement | null;
|
|
35
42
|
/**
|
|
36
43
|
* Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open
|
|
37
44
|
* drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Modern design system for building high-quality applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@maskito/core": "^5.2.2",
|
|
100
100
|
"@maskito/kit": "^5.2.2",
|
|
101
101
|
"@maskito/react": "^5.2.2",
|
|
102
|
-
"@plexui/styles": "^0.1.
|
|
102
|
+
"@plexui/styles": "^0.1.42",
|
|
103
103
|
"@radix-ui/react-dismissable-layer": "1.2.1",
|
|
104
104
|
"@radix-ui/react-focus-guards": "1.2.0",
|
|
105
105
|
"@radix-ui/react-focus-scope": "1.3.1",
|