@expofp/ui 0.0.0-experimental.2632d13 → 0.0.0-experimental.3b0db16
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/components/LevelSelector/LevelSelector.d.ts +9 -8
- package/dist/components/LevelSelector/LevelSelector.js +3 -3
- package/dist/components/LevelSelector/index.d.ts +1 -1
- package/dist/components/LogoStrip/LogoStrip.d.ts +34 -0
- package/dist/components/LogoStrip/LogoStrip.js +9 -0
- package/dist/components/LogoStrip/index.d.ts +5 -0
- package/dist/components/LogoStrip/index.js +3 -0
- package/dist/components/LogoStrip/logo-layout.d.ts +53 -0
- package/dist/components/LogoStrip/logo-layout.js +65 -0
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/Modal/Modal.js +1 -2
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -4
- package/package.json +1 -1
- package/dist/components/PlanSelector/PlanSelector.d.ts +0 -13
- package/dist/components/PlanSelector/PlanSelector.js +0 -10
- package/dist/components/PlanSelector/index.d.ts +0 -3
- package/dist/components/PlanSelector/index.js +0 -2
- package/dist/components/VenuePicker/VenuePicker.d.ts +0 -23
- package/dist/components/VenuePicker/VenuePicker.js +0 -70
- package/dist/components/VenuePicker/index.d.ts +0 -3
- package/dist/components/VenuePicker/index.js +0 -2
- package/dist/shared/selector-option.d.ts +0 -7
- package/dist/shared/selector-option.js +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './LevelSelector.scss';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export interface LevelSelectorFloor {
|
|
3
|
+
/** Stable identifier for the floor (used as React key and passed to `onSelect`). */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Display name shown to the user (already resolved to short/full by the caller). */
|
|
6
|
+
label: string;
|
|
7
|
+
active: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}
|
|
9
10
|
export interface LevelSelectorProps {
|
|
10
|
-
floors:
|
|
11
|
+
floors: LevelSelectorFloor[];
|
|
11
12
|
layout: 'compact-list' | 'dropdown';
|
|
12
13
|
onSelect: (id: string) => void;
|
|
13
14
|
floorSelectionLabel: string;
|
|
@@ -60,11 +60,11 @@ export default function LevelSelector({ floors, layout, onSelect, floorSelection
|
|
|
60
60
|
if (floors.length === 0)
|
|
61
61
|
return null;
|
|
62
62
|
const activeFloor = floors.find((floor) => floor.active);
|
|
63
|
-
const tabbableFloor = activeFloor && !activeFloor.disabled ? activeFloor : floors.find((floor) => !floor.disabled);
|
|
64
63
|
if (layout === 'compact-list') {
|
|
65
64
|
// Roving tabindex: only the active floor (or the first enabled one as a
|
|
66
65
|
// fallback) is a tab stop; arrows move focus, Enter/Space select.
|
|
67
|
-
|
|
66
|
+
const tabbableFloor = activeFloor && !activeFloor.disabled ? activeFloor : floors.find((floor) => !floor.disabled);
|
|
67
|
+
return (_jsx("div", { className: classNames('efp-level-selector', 'efp-level-selector--compact-list'), role: "radiogroup", "aria-label": floorSelectionLabel, children: floors.map((floor) => (_jsx("button", { ref: (el) => {
|
|
68
68
|
if (el)
|
|
69
69
|
itemRefs.current.set(floor.id, el);
|
|
70
70
|
else
|
|
@@ -74,7 +74,7 @@ export default function LevelSelector({ floors, layout, onSelect, floorSelection
|
|
|
74
74
|
'efp-level-selector__item--disabled': floor.disabled,
|
|
75
75
|
}), role: "radio", title: `${floor.active ? currentFloorLabel : floorLabel} ${floor.label}`, "aria-label": `${floor.active ? currentFloorLabel : floorLabel} ${floor.label}`, "aria-checked": floor.active, "aria-disabled": floor.disabled, tabIndex: floor.id === tabbableFloor?.id ? 0 : -1, onClick: () => handleFloorSelect(floor), onKeyDown: (e) => focusAdjacentFloor(e, floor), children: _jsx("span", { dir: "auto", children: floor.label }) }, floor.id))) }));
|
|
76
76
|
}
|
|
77
|
-
return (_jsxs("div", { className:
|
|
77
|
+
return (_jsxs("div", { className: classNames('efp-level-selector', 'efp-level-selector--dropdown'), children: [_jsxs("button", { ref: triggerRef, type: "button", className: classNames('efp-level-selector__trigger', {
|
|
78
78
|
'efp-level-selector__trigger--open': isDropdownOpen,
|
|
79
79
|
}), onClick: () => setIsDropdownOpen(!isDropdownOpen), "aria-haspopup": "listbox", "aria-expanded": isDropdownOpen, "aria-label": `${currentFloorLabel}: ${activeFloor?.label ?? ''}`, children: [_jsxs("div", { className: "efp-level-selector__trigger-text", children: [_jsx("i", { className: "icon-layers", "aria-hidden": "true" }), _jsx("span", { dir: "auto", children: activeFloor?.label ?? '' })] }), _jsx("div", { className: "efp-level-selector__trigger-chevron", children: _jsx("i", { className: "icon-chevron-down", "aria-hidden": "true" }) })] }), isDropdownOpen && (_jsx("div", { ref: dropdownRef, className: classNames('efp-level-selector__dropdown', 'efp-level-selector__dropdown--full', {
|
|
80
80
|
'efp-level-selector__dropdown--opens-up': menuPosition === 'up',
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import './LogoStrip.scss';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface LogoStripItem {
|
|
4
|
+
key: string | number;
|
|
5
|
+
src: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
href: string;
|
|
8
|
+
/** Tile width in pixels. */
|
|
9
|
+
width: number;
|
|
10
|
+
/** Tile height in pixels. */
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LogoStripProps {
|
|
14
|
+
items: readonly LogoStripItem[];
|
|
15
|
+
/**
|
|
16
|
+
* Horizontal space around each tile in pixels; half goes on each side. The
|
|
17
|
+
* row is centered, so this is the whole gap between tiles — see `logoRowGap`.
|
|
18
|
+
*/
|
|
19
|
+
spacing: number;
|
|
20
|
+
/** The strip does not call `preventDefault()`; a handler that opens the item in-app must call it to keep the `href` from navigating. */
|
|
21
|
+
onItemClick?: (key: LogoStripItem['key'], event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
22
|
+
onPointerEnter?: React.PointerEventHandler<HTMLElement>;
|
|
23
|
+
onPointerLeave?: React.PointerEventHandler<HTMLElement>;
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
ref?: React.Ref<HTMLElement>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A row of logo links. Sizes come from the caller (see `logoTileSize`); the
|
|
30
|
+
* strip only lays them out and fades each new tile in.
|
|
31
|
+
*/
|
|
32
|
+
declare const LogoStrip: ({ items, spacing, onItemClick, onPointerEnter, onPointerLeave, className, style, ref, }: LogoStripProps) => React.JSX.Element;
|
|
33
|
+
export default LogoStrip;
|
|
34
|
+
//# sourceMappingURL=LogoStrip.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './LogoStrip.scss';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
/**
|
|
5
|
+
* A row of logo links. Sizes come from the caller (see `logoTileSize`); the
|
|
6
|
+
* strip only lays them out and fades each new tile in.
|
|
7
|
+
*/
|
|
8
|
+
const LogoStrip = ({ items, spacing, onItemClick, onPointerEnter, onPointerLeave, className, style, ref, }) => (_jsx("section", { ref: ref, className: classNames('efp-logo-strip', className), style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, children: items.map((item) => (_jsx("a", { href: item.href, className: "efp-logo-strip__item", style: { margin: `0 ${spacing / 2}px` }, onClick: (event) => onItemClick?.(item.key, event), children: _jsx("img", { src: item.src, alt: item.alt, crossOrigin: "anonymous", style: { width: `${item.width}px`, height: `${item.height}px` } }) }, item.key))) }));
|
|
9
|
+
export default LogoStrip;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default } from './LogoStrip.js';
|
|
2
|
+
export type { LogoStripItem, LogoStripProps } from './LogoStrip.js';
|
|
3
|
+
export { fitLogoRow, logoRowGap, logoTileSize } from './logo-layout.js';
|
|
4
|
+
export type { LogoTileOptions, LogoTileSize } from './logo-layout.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** How a logo tile is sized from its aspect ratio. All lengths are in pixels. */
|
|
2
|
+
export interface LogoTileOptions {
|
|
3
|
+
/** Side of a square logo. */
|
|
4
|
+
base: number;
|
|
5
|
+
/**
|
|
6
|
+
* 0 gives every logo the same width, 0.5 the same area, 1 the same height
|
|
7
|
+
* (the legacy behavior), since `height = base · ar^(exponent − 1)`.
|
|
8
|
+
*/
|
|
9
|
+
exponent: number;
|
|
10
|
+
/** Floor for the height, so wide logos stay readable. */
|
|
11
|
+
minHeight: number;
|
|
12
|
+
/** Hard ceiling for the height. Wins over every other bound. */
|
|
13
|
+
maxHeight: number;
|
|
14
|
+
/** Ceiling for the width. Wins over `minHeight`. */
|
|
15
|
+
maxWidth: number;
|
|
16
|
+
}
|
|
17
|
+
export interface LogoTileSize {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sizes a logo so logos of different proportions carry a similar visual weight.
|
|
23
|
+
*
|
|
24
|
+
* Width is `base · aspectRatio^exponent`; the bounds then apply in order
|
|
25
|
+
* `minHeight` → `maxWidth` → `maxHeight`, each keeping the aspect ratio, so a
|
|
26
|
+
* later bound wins over an earlier one.
|
|
27
|
+
* @param aspectRatio - The logo's width divided by its height.
|
|
28
|
+
* @param options - Base size, exponent and bounds.
|
|
29
|
+
* @returns The tile size in pixels.
|
|
30
|
+
*/
|
|
31
|
+
export declare function logoTileSize(aspectRatio: number, options: LogoTileOptions): LogoTileSize;
|
|
32
|
+
/**
|
|
33
|
+
* Counts how many leading tiles fit a row. Each tile takes its width plus
|
|
34
|
+
* `spacing` (half on each side), so `n` tiles need `Σwidth + n·spacing`.
|
|
35
|
+
* @param widths - Tile widths in row order.
|
|
36
|
+
* @param maxWidth - The width the row may fill.
|
|
37
|
+
* @param spacing - Space around each tile.
|
|
38
|
+
* @returns The number of leading tiles that fit; 0 when even the first does not.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fitLogoRow(widths: readonly number[], maxWidth: number, spacing: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* The even space around each tile of a row: the leftover width shared across
|
|
43
|
+
* the tiles, clamped to `[spacing, maxGap]`. A centered row then puts whatever
|
|
44
|
+
* the cap leaves over equally at both ends, so a few logos on a wide bar do not
|
|
45
|
+
* drift apart.
|
|
46
|
+
* @param widths - Tile widths in row order.
|
|
47
|
+
* @param maxWidth - The width the row may fill.
|
|
48
|
+
* @param spacing - The least space around each tile.
|
|
49
|
+
* @param maxGap - The most space around each tile.
|
|
50
|
+
* @returns Space around each tile (half on each side); `spacing` for an empty or overfull row.
|
|
51
|
+
*/
|
|
52
|
+
export declare function logoRowGap(widths: readonly number[], maxWidth: number, spacing: number, maxGap: number): number;
|
|
53
|
+
//# sourceMappingURL=logo-layout.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sizes a logo so logos of different proportions carry a similar visual weight.
|
|
3
|
+
*
|
|
4
|
+
* Width is `base · aspectRatio^exponent`; the bounds then apply in order
|
|
5
|
+
* `minHeight` → `maxWidth` → `maxHeight`, each keeping the aspect ratio, so a
|
|
6
|
+
* later bound wins over an earlier one.
|
|
7
|
+
* @param aspectRatio - The logo's width divided by its height.
|
|
8
|
+
* @param options - Base size, exponent and bounds.
|
|
9
|
+
* @returns The tile size in pixels.
|
|
10
|
+
*/
|
|
11
|
+
export function logoTileSize(aspectRatio, options) {
|
|
12
|
+
const ar = Number.isFinite(aspectRatio) && aspectRatio > 0 ? aspectRatio : 1;
|
|
13
|
+
let width = options.base * Math.pow(ar, options.exponent);
|
|
14
|
+
let height = width / ar;
|
|
15
|
+
if (height < options.minHeight) {
|
|
16
|
+
height = options.minHeight;
|
|
17
|
+
width = height * ar;
|
|
18
|
+
}
|
|
19
|
+
if (width > options.maxWidth) {
|
|
20
|
+
width = options.maxWidth;
|
|
21
|
+
height = width / ar;
|
|
22
|
+
}
|
|
23
|
+
if (height > options.maxHeight) {
|
|
24
|
+
height = options.maxHeight;
|
|
25
|
+
width = height * ar;
|
|
26
|
+
}
|
|
27
|
+
return { width, height };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Counts how many leading tiles fit a row. Each tile takes its width plus
|
|
31
|
+
* `spacing` (half on each side), so `n` tiles need `Σwidth + n·spacing`.
|
|
32
|
+
* @param widths - Tile widths in row order.
|
|
33
|
+
* @param maxWidth - The width the row may fill.
|
|
34
|
+
* @param spacing - Space around each tile.
|
|
35
|
+
* @returns The number of leading tiles that fit; 0 when even the first does not.
|
|
36
|
+
*/
|
|
37
|
+
export function fitLogoRow(widths, maxWidth, spacing) {
|
|
38
|
+
let used = 0;
|
|
39
|
+
for (let i = 0; i < widths.length; i++) {
|
|
40
|
+
used += widths[i] + spacing;
|
|
41
|
+
if (used > maxWidth)
|
|
42
|
+
return i;
|
|
43
|
+
}
|
|
44
|
+
return widths.length;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The even space around each tile of a row: the leftover width shared across
|
|
48
|
+
* the tiles, clamped to `[spacing, maxGap]`. A centered row then puts whatever
|
|
49
|
+
* the cap leaves over equally at both ends, so a few logos on a wide bar do not
|
|
50
|
+
* drift apart.
|
|
51
|
+
* @param widths - Tile widths in row order.
|
|
52
|
+
* @param maxWidth - The width the row may fill.
|
|
53
|
+
* @param spacing - The least space around each tile.
|
|
54
|
+
* @param maxGap - The most space around each tile.
|
|
55
|
+
* @returns Space around each tile (half on each side); `spacing` for an empty or overfull row.
|
|
56
|
+
*/
|
|
57
|
+
export function logoRowGap(widths, maxWidth, spacing, maxGap) {
|
|
58
|
+
const n = widths.length;
|
|
59
|
+
if (!n)
|
|
60
|
+
return spacing;
|
|
61
|
+
let used = 0;
|
|
62
|
+
for (const width of widths)
|
|
63
|
+
used += width;
|
|
64
|
+
return Math.max(spacing, Math.min(maxGap, (maxWidth - used) / n));
|
|
65
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './Modal.scss';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { type ButtonVariant } from '../Button';
|
|
4
|
-
export type ModalVariant = 'default' | 'share'
|
|
4
|
+
export type ModalVariant = 'default' | 'share';
|
|
5
5
|
export interface ModalButton {
|
|
6
6
|
label: string;
|
|
7
7
|
variant?: ButtonVariant;
|
|
@@ -19,8 +19,7 @@ const Modal = ({ open, className, variant = 'default', title, ariaLabel, maxWidt
|
|
|
19
19
|
if (!open) {
|
|
20
20
|
const deactivateFrame = requestAnimationFrame(() => setIsOpen(false));
|
|
21
21
|
const unmountTimer = setTimeout(() => setIsVisible(false), MODAL_EXIT_TRANSITION_MS);
|
|
22
|
-
|
|
23
|
-
previousFocusRef.current.focus();
|
|
22
|
+
previousFocusRef.current?.focus();
|
|
24
23
|
previousFocusRef.current = null;
|
|
25
24
|
return () => {
|
|
26
25
|
cancelAnimationFrame(deactivateFrame);
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export * from './components/LevelBadge';
|
|
|
27
27
|
export { default as LevelBadge } from './components/LevelBadge';
|
|
28
28
|
export * from './components/LevelSelector';
|
|
29
29
|
export { default as LevelSelector } from './components/LevelSelector';
|
|
30
|
+
export * from './components/LogoStrip/index.js';
|
|
31
|
+
export { default as LogoStrip } from './components/LogoStrip/index.js';
|
|
30
32
|
export * from './components/MapControls';
|
|
31
33
|
export { default as MapControls } from './components/MapControls';
|
|
32
34
|
export * from './components/MobileToggleButton';
|
|
@@ -41,8 +43,6 @@ export * from './components/OverlayGrip';
|
|
|
41
43
|
export { default as OverlayGrip } from './components/OverlayGrip';
|
|
42
44
|
export * from './components/PermissionNotice';
|
|
43
45
|
export { default as PermissionNotice } from './components/PermissionNotice';
|
|
44
|
-
export * from './components/PlanSelector';
|
|
45
|
-
export { default as PlanSelector } from './components/PlanSelector';
|
|
46
46
|
export * from './components/Radio';
|
|
47
47
|
export { default as Radio } from './components/Radio';
|
|
48
48
|
export * from './components/RebookingNotes';
|
|
@@ -66,9 +66,6 @@ export { default as ToggleButton } from './components/ToggleButton';
|
|
|
66
66
|
export * from './components/ToggleSwitch';
|
|
67
67
|
export { default as ToggleSwitch } from './components/ToggleSwitch';
|
|
68
68
|
export { default as TouchHand } from './components/TouchHand';
|
|
69
|
-
export * from './components/VenuePicker';
|
|
70
|
-
export { default as VenuePicker } from './components/VenuePicker';
|
|
71
69
|
export * from './components/WayfindingFloorSelector';
|
|
72
70
|
export { default as WayfindingFloorSelector } from './components/WayfindingFloorSelector';
|
|
73
|
-
export type { SelectorOption } from './shared/selector-option.js';
|
|
74
71
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,8 @@ export * from './components/LevelBadge';
|
|
|
32
32
|
export { default as LevelBadge } from './components/LevelBadge';
|
|
33
33
|
export * from './components/LevelSelector';
|
|
34
34
|
export { default as LevelSelector } from './components/LevelSelector';
|
|
35
|
+
export * from './components/LogoStrip/index.js';
|
|
36
|
+
export { default as LogoStrip } from './components/LogoStrip/index.js';
|
|
35
37
|
export * from './components/MapControls';
|
|
36
38
|
export { default as MapControls } from './components/MapControls';
|
|
37
39
|
export * from './components/MobileToggleButton';
|
|
@@ -46,8 +48,6 @@ export * from './components/OverlayGrip';
|
|
|
46
48
|
export { default as OverlayGrip } from './components/OverlayGrip';
|
|
47
49
|
export * from './components/PermissionNotice';
|
|
48
50
|
export { default as PermissionNotice } from './components/PermissionNotice';
|
|
49
|
-
export * from './components/PlanSelector';
|
|
50
|
-
export { default as PlanSelector } from './components/PlanSelector';
|
|
51
51
|
export * from './components/Radio';
|
|
52
52
|
export { default as Radio } from './components/Radio';
|
|
53
53
|
export * from './components/RebookingNotes';
|
|
@@ -71,7 +71,5 @@ export { default as ToggleButton } from './components/ToggleButton';
|
|
|
71
71
|
export * from './components/ToggleSwitch';
|
|
72
72
|
export { default as ToggleSwitch } from './components/ToggleSwitch';
|
|
73
73
|
export { default as TouchHand } from './components/TouchHand';
|
|
74
|
-
export * from './components/VenuePicker';
|
|
75
|
-
export { default as VenuePicker } from './components/VenuePicker';
|
|
76
74
|
export * from './components/WayfindingFloorSelector';
|
|
77
75
|
export { default as WayfindingFloorSelector } from './components/WayfindingFloorSelector';
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import './PlanSelector.scss';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export interface PlanSelectorProps {
|
|
4
|
-
/** Plan-scope controls, stacked top to bottom (venue picker, then levels). */
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Places the plan-scope controls in the map's top corner. This is the only
|
|
9
|
-
* component of the stack that positions itself — the controls inside stay
|
|
10
|
-
* layout-agnostic, so composing them never means undoing their own placement.
|
|
11
|
-
*/
|
|
12
|
-
export default function PlanSelector({ children }: PlanSelectorProps): import("react").JSX.Element;
|
|
13
|
-
//# sourceMappingURL=PlanSelector.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import './PlanSelector.scss';
|
|
3
|
-
/**
|
|
4
|
-
* Places the plan-scope controls in the map's top corner. This is the only
|
|
5
|
-
* component of the stack that positions itself — the controls inside stay
|
|
6
|
-
* layout-agnostic, so composing them never means undoing their own placement.
|
|
7
|
-
*/
|
|
8
|
-
export default function PlanSelector({ children }) {
|
|
9
|
-
return _jsx("div", { className: "efp-plan-selector", children: children });
|
|
10
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import './VenuePicker.scss';
|
|
2
|
-
import type { SelectorOption } from '../../shared/selector-option.js';
|
|
3
|
-
export interface VenuePickerLabels {
|
|
4
|
-
chooseVenue: string;
|
|
5
|
-
close: string;
|
|
6
|
-
currentVenue: string;
|
|
7
|
-
venueSelection: string;
|
|
8
|
-
viewAllVenues: string;
|
|
9
|
-
}
|
|
10
|
-
export interface VenuePickerProps {
|
|
11
|
-
venues: SelectorOption[];
|
|
12
|
-
labels: VenuePickerLabels;
|
|
13
|
-
renderTarget: HTMLElement | null;
|
|
14
|
-
onSelect: (id: string) => void;
|
|
15
|
-
onViewAllVenues: () => void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Collapsed combobox naming the current venue, backed by a drawer holding the
|
|
19
|
-
* full list. At campus scale an expanded list crowds the map, so only the
|
|
20
|
-
* current context (or a prompt when there is none) stays on screen.
|
|
21
|
-
*/
|
|
22
|
-
export default function VenuePicker({ venues, labels, renderTarget, onSelect, onViewAllVenues, }: VenuePickerProps): import("react").JSX.Element | null;
|
|
23
|
-
//# sourceMappingURL=VenuePicker.d.ts.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import './VenuePicker.scss';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { useRef, useState } from 'react';
|
|
5
|
-
import Modal from '../Modal/Modal.js';
|
|
6
|
-
/**
|
|
7
|
-
* Up to two uppercase letters standing in for a venue on the badge and drawer
|
|
8
|
-
* cards: the first letters of the first two words, or the first two letters of
|
|
9
|
-
* a single-word name. `Array.from` keeps multi-byte characters intact.
|
|
10
|
-
*/
|
|
11
|
-
function venueInitials(name) {
|
|
12
|
-
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
13
|
-
if (words.length === 0)
|
|
14
|
-
return '?';
|
|
15
|
-
if (words.length === 1)
|
|
16
|
-
return Array.from(words[0]).slice(0, 2).join('').toUpperCase();
|
|
17
|
-
return (Array.from(words[0])[0] + Array.from(words[1])[0]).toUpperCase();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Collapsed combobox naming the current venue, backed by a drawer holding the
|
|
21
|
-
* full list. At campus scale an expanded list crowds the map, so only the
|
|
22
|
-
* current context (or a prompt when there is none) stays on screen.
|
|
23
|
-
*/
|
|
24
|
-
export default function VenuePicker({ venues, labels, renderTarget, onSelect, onViewAllVenues, }) {
|
|
25
|
-
const [chooserOpen, setChooserOpen] = useState(false);
|
|
26
|
-
const [chooserTabStopId, setChooserTabStopId] = useState(null);
|
|
27
|
-
const chooserCardRef = useRef(new Map());
|
|
28
|
-
const defaultChooserTabStopId = venues.find((venue) => venue.active && !venue.disabled)?.id ??
|
|
29
|
-
venues.find((venue) => !venue.disabled)?.id ??
|
|
30
|
-
null;
|
|
31
|
-
const focusAdjacentVenue = (event, currentVenueId) => {
|
|
32
|
-
if (!['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(event.key))
|
|
33
|
-
return;
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
const direction = event.key === 'ArrowDown' || event.key === 'ArrowRight' ? 1 : -1;
|
|
36
|
-
const currentIndex = venues.findIndex((venue) => venue.id === currentVenueId);
|
|
37
|
-
for (let offset = 1; offset <= venues.length; offset++) {
|
|
38
|
-
const index = (currentIndex + direction * offset + venues.length) % venues.length;
|
|
39
|
-
if (venues[index].disabled)
|
|
40
|
-
continue;
|
|
41
|
-
setChooserTabStopId(venues[index].id);
|
|
42
|
-
chooserCardRef.current.get(venues[index].id)?.focus();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
// Closing the drawer returns focus to the trigger on its own (Modal restores
|
|
47
|
-
// the previously focused element), so venue entry only has to close it.
|
|
48
|
-
const selectVenue = (id) => {
|
|
49
|
-
setChooserOpen(false);
|
|
50
|
-
onSelect(id);
|
|
51
|
-
};
|
|
52
|
-
const viewAllVenues = () => {
|
|
53
|
-
setChooserOpen(false);
|
|
54
|
-
onViewAllVenues();
|
|
55
|
-
};
|
|
56
|
-
if (venues.length === 0)
|
|
57
|
-
return null;
|
|
58
|
-
const currentVenueLabel = venues.find((venue) => venue.active)?.label ?? null;
|
|
59
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "efp-venue-picker", "aria-haspopup": "dialog", "aria-expanded": chooserOpen, "aria-label": currentVenueLabel ? `${labels.currentVenue}: ${currentVenueLabel}` : labels.chooseVenue, onClick: () => {
|
|
60
|
-
setChooserTabStopId(defaultChooserTabStopId);
|
|
61
|
-
setChooserOpen(true);
|
|
62
|
-
}, children: [_jsx("i", { className: "icon-layers", "aria-hidden": "true" }), _jsx("span", { dir: "auto", children: currentVenueLabel ?? labels.chooseVenue }), _jsx("i", { className: "icon-chevron-down", "aria-hidden": "true" })] }), _jsxs(Modal, { open: chooserOpen, variant: "drawer", className: "efp-venue-chooser", title: labels.chooseVenue, closeLabel: labels.close, renderTarget: renderTarget, onClose: () => setChooserOpen(false), children: [_jsx("div", { className: "efp-venue-chooser__list", role: "radiogroup", "aria-label": labels.venueSelection, children: venues.map((venue) => (_jsxs("button", { ref: (element) => {
|
|
63
|
-
if (element)
|
|
64
|
-
chooserCardRef.current.set(venue.id, element);
|
|
65
|
-
else
|
|
66
|
-
chooserCardRef.current.delete(venue.id);
|
|
67
|
-
}, type: "button", className: classNames('efp-venue-chooser__card', {
|
|
68
|
-
'is-active': venue.active,
|
|
69
|
-
}), role: "radio", "aria-checked": venue.active, "aria-disabled": venue.disabled, disabled: venue.disabled, tabIndex: venue.id === (chooserTabStopId ?? defaultChooserTabStopId) ? 0 : -1, onFocus: () => setChooserTabStopId(venue.id), onKeyDown: (event) => focusAdjacentVenue(event, venue.id), onClick: () => selectVenue(venue.id), children: [_jsx("span", { className: "efp-venue-chooser__badge", "aria-hidden": "true", children: venueInitials(venue.label) }), _jsx("span", { className: "efp-venue-chooser__card-name", dir: "auto", children: venue.label })] }, venue.id))) }), _jsxs("button", { type: "button", className: "efp-venue-chooser__view-all", onClick: viewAllVenues, children: [_jsx("i", { className: "icon-zoom-out", "aria-hidden": "true" }), _jsx("span", { children: labels.viewAllVenues })] })] })] }));
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|