design-zystem 1.0.403 → 1.0.405

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.
@@ -1957,8 +1957,8 @@ interface TourStep {
1957
1957
  id: string;
1958
1958
  /** Identifiant(s) de `TourTarget` : le premier présent dans la page est mis en lumière. Absent : bulle centrée. */
1959
1959
  target?: string | string[];
1960
- title?: ReactNode;
1961
- content: ReactNode;
1960
+ title?: string;
1961
+ content: string;
1962
1962
  placement?: TourPlacement;
1963
1963
  /** La zone éclairée reste cliquable (défaut). `false` : elle est seulement montrée. */
1964
1964
  interactive?: boolean;
@@ -1987,6 +1987,6 @@ interface TourTargetProps {
1987
1987
  }
1988
1988
  /** Enveloppe sans boîte (`display: contents`) : marque une cible sans toucher à la mise en page. */
1989
1989
  declare const TourTarget: ({ id, children }: TourTargetProps) => react.JSX.Element;
1990
- declare const Tour: ({ steps, open, step, onStepChange, onClose, labels, targetTimeout, }: TourProps) => react.ReactPortal | null;
1990
+ declare const Tour: ({ steps, open, step, onStepChange, onClose, labels, targetTimeout, }: TourProps) => null;
1991
1991
 
1992
1992
  export { type ActivityFeedItem, ActivityFeedPanel, type ActivityFeedPanelProps, Attachment, type AttachmentProps, type AttachmentStatus, Avatar, AvatarBadge, type AvatarBadgeConfig, type AvatarBadgeProps, AvatarFallback, type AvatarFallbackProps, AvatarGroup, type AvatarGroupProps, AvatarImage, type AvatarImageProps, type AvatarProps, Badge, type BadgeProps, Banner, type BannerAction, type BannerJustify, type BannerProps, type BannerToggle, Box, type BoxProps, Bulk, type BulkProps, type BulkSection, Button, type ButtonProps, COLOR_TOKENS, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, CollapsibleTrigger, type ColorKey, ColorPicker, type ColorPickerProps, type ColorToken, DatePicker, type DatePickerMode, type DatePickerProps, type DatePreset, Divider, type DividerProps, Drawer, DrawerBody, DrawerClose, DrawerDescription, type DrawerDirection, DrawerFooter, DrawerHeader, type DrawerProps, DrawerTitle, EmailInput, type EmailInputProps, EmptyState, type EmptyStateProps, FAB_EDGE_MARGIN, FAB_SIZE, FilePicker, type FilePickerProps, FileUploadZone, type FileUploadZoneProps, type FloatingAction, FloatingButton, type FloatingButtonProps, type FloatingSafeArea, Gantt, type GanttBand, type GanttBar, type GanttDay, GanttDot, type GanttProps, type GanttRow, GanttSwatch, type HexColor, HistoryButton, type HistoryButtonProps, type HistoryChange, HistoryDrawer, type HistoryDrawerProps, type HistoryEntry, type HistoryFilter, HistoryList, type HistoryListProps, Icon, IconBadge, type IconBadgeProps, type IconColor, type IconFamily, type IconProps, type IconSize, type IconTabItem, IconTabs, type IconTabsProps, IconTooltip, type IconTooltipProps, type IconVariant, Image, type ImageProps, InfoTooltip, type InfoTooltipProps, type InfoTooltipVariant, Input, InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupProps, type InputProps, Item, ItemActions, ItemContent, ItemDescription, ItemMedia, type ItemMediaProps, type ItemProps, ItemTitle, Label, type LabelProps, Layout, type LayoutProps, Link, type LinkProps, Message, MessageDateSeparator, type MessageDateSeparatorProps, type MessageProps, MessageScroller, type MessageScrollerProps, type MessageSeparatorTone, type MessageVariant, MetricCard, type MetricCardProps, Modal, ModalBody, ModalClose, ModalDescription, ModalFooter, ModalHeader, type ModalProps, ModalTitle, type MultiSelectProps, type OptimizeImageOptions, type OptimizeImageResult, PageContainer, type PageContainerProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, PdfPreview, type PdfPreviewProps, PhoneInput, type PhoneInputMeta, type PhoneInputProps, Popover, type PopoverMenuItem, type PopoverProps, ProgressBar, type ProgressBarProps, Radio, type RadioOption, type RadioProps, ScrollArea, type ScrollAreaProps, SearchInput, type SearchInputProps, Select, type SelectBubbleOption, type SelectOption, type SelectProps, Sidebar, SidebarContent, type SidebarContentProps, SidebarFooter, type SidebarFooterProps, SidebarGroup, type SidebarGroupProps, SidebarHeader, type SidebarHeaderProps, SidebarMenuButton, type SidebarMenuButtonProps, SidebarMenuSearchInput, type SidebarMenuSearchInputProps, SidebarMenuSub, SidebarMenuSubButton, type SidebarMenuSubButtonProps, SidebarMenuSubItem, type SidebarMenuSubItemProps, type SidebarMenuSubProps, type SidebarProps, SidebarSupportInfo, type SidebarSupportInfoProps, SidebarTrigger, type SidebarTriggerProps, SidebarUserMenu, type SidebarUserMenuAction, type SidebarUserMenuLeafAction, type SidebarUserMenuProps, type SingleSelectProps, Skeleton, type SkeletonProps, Spinner, type SpinnerProps, type SpinnerSize, Stepper, type StepperProps, Switch, type SwitchProps, TOUR_TARGET_ATTRIBUTE, type TabItem, Table, TableCell, type TableCellProps, type TableEmptyState, TableFooter, TableFooterCell, type TableFooterCellProps, type TableFooterProps, TableFooterRow, type TableFooterRowProps, TableHeader, TableHeaderCell, type TableHeaderCellProps, type TableHeaderProps, TableHeaderRow, type TableHeaderRowProps, type TablePagination, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, type TabsVariant, TagBubble, type TagBubbleProps, type TagLevelItem, TagLevelPicker, type TagLevelPickerProps, type TagOption, type TagSearchOption, TagSelect, type TagSelectProps, Text, type TextProps, Textarea, type TextareaProps, type TextareaVariant, Timeline, type TimelineItem, type TimelineProps, type ToastId, type ToastOptions, type ToastType, Toaster, Tooltip, type TooltipProps, Tour, type TourCloseReason, type TourLabels, type TourPlacement, type TourProps, type TourStep, TourTarget, type TourTargetProps, VideoPlayer, type VideoPlayerProps, addBusinessDays, allowAutofill, appendCacheBuster, appendQueryParam, buttonVariants, capitalizeFirstLetter, colors, easterDate, formatAddress, formatCityFromFormattedAddress, formatCityWithPostalCode, formatDate, formatDateWithTime, formatDistance, formatDuration, formatEuro, formatKM, formatLocality, formatName, formatNameWithInitial, formatPhoneNumber, formatPlate, formatPlateWithoutDashes, formatPostalCodeFromFormattedAddress, formatRegionCode, formatTime, formatVideoDuration, formatVin, generateHexColor, getAvatarColor, getCleanFileName, getElapsedTime, getFileIconByMimeType, getFileKind, getFileNameFromUrl, getInitials, getMimeCategory, getPastelColorPair, getRelativeTime, isHoliday, isSameDay, isolateCity, linkVariants, noAutofillProps, optimizeImage, parseAmount, parseIsoDate, toast, truncateFileName, truncateText, useAvatarSize };
@@ -1957,8 +1957,8 @@ interface TourStep {
1957
1957
  id: string;
1958
1958
  /** Identifiant(s) de `TourTarget` : le premier présent dans la page est mis en lumière. Absent : bulle centrée. */
1959
1959
  target?: string | string[];
1960
- title?: ReactNode;
1961
- content: ReactNode;
1960
+ title?: string;
1961
+ content: string;
1962
1962
  placement?: TourPlacement;
1963
1963
  /** La zone éclairée reste cliquable (défaut). `false` : elle est seulement montrée. */
1964
1964
  interactive?: boolean;
@@ -1987,6 +1987,6 @@ interface TourTargetProps {
1987
1987
  }
1988
1988
  /** Enveloppe sans boîte (`display: contents`) : marque une cible sans toucher à la mise en page. */
1989
1989
  declare const TourTarget: ({ id, children }: TourTargetProps) => react.JSX.Element;
1990
- declare const Tour: ({ steps, open, step, onStepChange, onClose, labels, targetTimeout, }: TourProps) => react.ReactPortal | null;
1990
+ declare const Tour: ({ steps, open, step, onStepChange, onClose, labels, targetTimeout, }: TourProps) => null;
1991
1991
 
1992
1992
  export { type ActivityFeedItem, ActivityFeedPanel, type ActivityFeedPanelProps, Attachment, type AttachmentProps, type AttachmentStatus, Avatar, AvatarBadge, type AvatarBadgeConfig, type AvatarBadgeProps, AvatarFallback, type AvatarFallbackProps, AvatarGroup, type AvatarGroupProps, AvatarImage, type AvatarImageProps, type AvatarProps, Badge, type BadgeProps, Banner, type BannerAction, type BannerJustify, type BannerProps, type BannerToggle, Box, type BoxProps, Bulk, type BulkProps, type BulkSection, Button, type ButtonProps, COLOR_TOKENS, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, CollapsibleTrigger, type ColorKey, ColorPicker, type ColorPickerProps, type ColorToken, DatePicker, type DatePickerMode, type DatePickerProps, type DatePreset, Divider, type DividerProps, Drawer, DrawerBody, DrawerClose, DrawerDescription, type DrawerDirection, DrawerFooter, DrawerHeader, type DrawerProps, DrawerTitle, EmailInput, type EmailInputProps, EmptyState, type EmptyStateProps, FAB_EDGE_MARGIN, FAB_SIZE, FilePicker, type FilePickerProps, FileUploadZone, type FileUploadZoneProps, type FloatingAction, FloatingButton, type FloatingButtonProps, type FloatingSafeArea, Gantt, type GanttBand, type GanttBar, type GanttDay, GanttDot, type GanttProps, type GanttRow, GanttSwatch, type HexColor, HistoryButton, type HistoryButtonProps, type HistoryChange, HistoryDrawer, type HistoryDrawerProps, type HistoryEntry, type HistoryFilter, HistoryList, type HistoryListProps, Icon, IconBadge, type IconBadgeProps, type IconColor, type IconFamily, type IconProps, type IconSize, type IconTabItem, IconTabs, type IconTabsProps, IconTooltip, type IconTooltipProps, type IconVariant, Image, type ImageProps, InfoTooltip, type InfoTooltipProps, type InfoTooltipVariant, Input, InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupProps, type InputProps, Item, ItemActions, ItemContent, ItemDescription, ItemMedia, type ItemMediaProps, type ItemProps, ItemTitle, Label, type LabelProps, Layout, type LayoutProps, Link, type LinkProps, Message, MessageDateSeparator, type MessageDateSeparatorProps, type MessageProps, MessageScroller, type MessageScrollerProps, type MessageSeparatorTone, type MessageVariant, MetricCard, type MetricCardProps, Modal, ModalBody, ModalClose, ModalDescription, ModalFooter, ModalHeader, type ModalProps, ModalTitle, type MultiSelectProps, type OptimizeImageOptions, type OptimizeImageResult, PageContainer, type PageContainerProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, PdfPreview, type PdfPreviewProps, PhoneInput, type PhoneInputMeta, type PhoneInputProps, Popover, type PopoverMenuItem, type PopoverProps, ProgressBar, type ProgressBarProps, Radio, type RadioOption, type RadioProps, ScrollArea, type ScrollAreaProps, SearchInput, type SearchInputProps, Select, type SelectBubbleOption, type SelectOption, type SelectProps, Sidebar, SidebarContent, type SidebarContentProps, SidebarFooter, type SidebarFooterProps, SidebarGroup, type SidebarGroupProps, SidebarHeader, type SidebarHeaderProps, SidebarMenuButton, type SidebarMenuButtonProps, SidebarMenuSearchInput, type SidebarMenuSearchInputProps, SidebarMenuSub, SidebarMenuSubButton, type SidebarMenuSubButtonProps, SidebarMenuSubItem, type SidebarMenuSubItemProps, type SidebarMenuSubProps, type SidebarProps, SidebarSupportInfo, type SidebarSupportInfoProps, SidebarTrigger, type SidebarTriggerProps, SidebarUserMenu, type SidebarUserMenuAction, type SidebarUserMenuLeafAction, type SidebarUserMenuProps, type SingleSelectProps, Skeleton, type SkeletonProps, Spinner, type SpinnerProps, type SpinnerSize, Stepper, type StepperProps, Switch, type SwitchProps, TOUR_TARGET_ATTRIBUTE, type TabItem, Table, TableCell, type TableCellProps, type TableEmptyState, TableFooter, TableFooterCell, type TableFooterCellProps, type TableFooterProps, TableFooterRow, type TableFooterRowProps, TableHeader, TableHeaderCell, type TableHeaderCellProps, type TableHeaderProps, TableHeaderRow, type TableHeaderRowProps, type TablePagination, type TableProps, TableRow, type TableRowProps, Tabs, type TabsProps, type TabsVariant, TagBubble, type TagBubbleProps, type TagLevelItem, TagLevelPicker, type TagLevelPickerProps, type TagOption, type TagSearchOption, TagSelect, type TagSelectProps, Text, type TextProps, Textarea, type TextareaProps, type TextareaVariant, Timeline, type TimelineItem, type TimelineProps, type ToastId, type ToastOptions, type ToastType, Toaster, Tooltip, type TooltipProps, Tour, type TourCloseReason, type TourLabels, type TourPlacement, type TourProps, type TourStep, TourTarget, type TourTargetProps, VideoPlayer, type VideoPlayerProps, addBusinessDays, allowAutofill, appendCacheBuster, appendQueryParam, buttonVariants, capitalizeFirstLetter, colors, easterDate, formatAddress, formatCityFromFormattedAddress, formatCityWithPostalCode, formatDate, formatDateWithTime, formatDistance, formatDuration, formatEuro, formatKM, formatLocality, formatName, formatNameWithInitial, formatPhoneNumber, formatPlate, formatPlateWithoutDashes, formatPostalCodeFromFormattedAddress, formatRegionCode, formatTime, formatVideoDuration, formatVin, generateHexColor, getAvatarColor, getCleanFileName, getElapsedTime, getFileIconByMimeType, getFileKind, getFileNameFromUrl, getInitials, getMimeCategory, getPastelColorPair, getRelativeTime, isHoliday, isSameDay, isolateCity, linkVariants, noAutofillProps, optimizeImage, parseAmount, parseIsoDate, toast, truncateFileName, truncateText, useAvatarSize };
package/dist/ui/index.js CHANGED
@@ -2155,6 +2155,9 @@ var Tabs = ({
2155
2155
  var import_react21 = require("react");
2156
2156
  var RadixDialog = __toESM(require("@radix-ui/react-dialog"));
2157
2157
 
2158
+ // src/ui/lib/layers.ts
2159
+ var MODAL_LAYER = "z-[1000]";
2160
+
2158
2161
  // src/ui/lib/portalScroll.ts
2159
2162
  var import_react20 = require("react");
2160
2163
  var SCROLL_EVENTS = ["wheel", "touchmove"];
@@ -2241,7 +2244,8 @@ var Modal = ({
2241
2244
  "data-drawer-keep-open": true,
2242
2245
  onClick: (event) => event.stopPropagation(),
2243
2246
  className: cn(
2244
- "fixed inset-0 z-40",
2247
+ MODAL_LAYER,
2248
+ "fixed inset-0",
2245
2249
  draggable ? "bg-transparent" : "bg-black/50",
2246
2250
  overlayClassName
2247
2251
  )
@@ -2254,7 +2258,8 @@ var Modal = ({
2254
2258
  onOpenAutoFocus,
2255
2259
  onClick: (event) => event.stopPropagation(),
2256
2260
  className: cn(
2257
- "fixed left-1/2 top-1/2 z-50 flex max-h-[90vh] -translate-x-1/2 -translate-y-1/2 flex-col gap-4",
2261
+ MODAL_LAYER,
2262
+ "fixed left-1/2 top-1/2 flex max-h-[90vh] -translate-x-1/2 -translate-y-1/2 flex-col gap-4",
2258
2263
  "rounded-xl bg-white p-6 shadow-[0_10px_15px_-3px_rgba(0,0,0,0.1),0_4px_6px_-2px_rgba(0,0,0,0.05)] outline-none",
2259
2264
  className
2260
2265
  ),
@@ -4312,7 +4317,8 @@ var Drawer = ({
4312
4317
  ref: overlayRef,
4313
4318
  onClick: (event) => event.stopPropagation(),
4314
4319
  className: cn(
4315
- "fixed inset-0 z-40 bg-black/35 data-[stacked]:bg-transparent",
4320
+ MODAL_LAYER,
4321
+ "fixed inset-0 bg-black/35 data-[stacked]:bg-transparent",
4316
4322
  overlayClassName
4317
4323
  )
4318
4324
  }
@@ -4331,7 +4337,8 @@ var Drawer = ({
4331
4337
  },
4332
4338
  onClick: (event) => event.stopPropagation(),
4333
4339
  className: cn(
4334
- "fixed z-50 flex flex-col gap-4 bg-white p-6 outline-none",
4340
+ MODAL_LAYER,
4341
+ "fixed flex flex-col gap-4 bg-white p-6 outline-none",
4335
4342
  // vaul prolonge le panneau d'un ::after opaque de 200% (effet
4336
4343
  // élastique d'un panneau collé au bord) : sur un panneau qui flotte,
4337
4344
  // il déborde dans la marge et forme une barre blanche jusqu'au bord
@@ -8676,7 +8683,7 @@ var optimizeImage = async (file, desiredBaseName, opts = {}) => {
8676
8683
 
8677
8684
  // src/ui/components/ui/Tour.tsx
8678
8685
  var import_react57 = require("react");
8679
- var import_react_dom = require("react-dom");
8686
+ var import_driver = require("driver.js");
8680
8687
  var import_jsx_runtime94 = require("react/jsx-runtime");
8681
8688
  var TOUR_TARGET_ATTRIBUTE = "data-tour-target";
8682
8689
  var DEFAULT_LABELS = {
@@ -8686,23 +8693,13 @@ var DEFAULT_LABELS = {
8686
8693
  close: "Quitter le tutoriel",
8687
8694
  counter: (current, total) => `${current} / ${total}`
8688
8695
  };
8689
- var CARD_WIDTH = 340;
8690
- var HOLE_PADDING = 6;
8691
- var GAP2 = 14;
8692
- var MARGIN = 12;
8696
+ var STAGE_PADDING = 6;
8697
+ var GHOST_TRANSITION_MS = 200;
8698
+ var HIGHLIGHT_DURATION_MS = 400;
8693
8699
  var TourTarget = ({ id, children }) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", __spreadProps(__spreadValues({}, { [TOUR_TARGET_ATTRIBUTE]: id }), { className: "contents", children }));
8694
- var findTarget = (target) => {
8695
- const ids = Array.isArray(target) ? target : target ? [target] : [];
8696
- for (const id of ids) {
8697
- const element = document.querySelector(
8698
- `[${TOUR_TARGET_ATTRIBUTE}="${id.replace(/"/g, '\\"')}"]`
8699
- );
8700
- if (element && measure(element)) return element;
8701
- }
8702
- return null;
8703
- };
8700
+ var isContents = (element) => getComputedStyle(element).display === "contents";
8704
8701
  var measure = (element) => {
8705
- if (getComputedStyle(element).display !== "contents") {
8702
+ if (!isContents(element)) {
8706
8703
  const { top: top2, left: left2, width, height } = element.getBoundingClientRect();
8707
8704
  return width || height ? { top: top2, left: left2, width, height } : null;
8708
8705
  }
@@ -8714,47 +8711,18 @@ var measure = (element) => {
8714
8711
  const right = Math.max(...rects.map((r) => r.left + r.width));
8715
8712
  return { top, left, width: right - left, height: bottom - top };
8716
8713
  };
8717
- var sameRect = (a, b) => a === b || !!a && !!b && Math.abs(a.top - b.top) < 0.5 && Math.abs(a.left - b.left) < 0.5 && Math.abs(a.width - b.width) < 0.5 && Math.abs(a.height - b.height) < 0.5;
8718
- var clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min, max));
8719
- var firstBox = (element) => getComputedStyle(element).display === "contents" && element.firstElementChild ? firstBox(element.firstElementChild) : element;
8720
- var placeCard = (hole, cardHeight, preferred) => {
8721
- var _a;
8722
- const vw = window.innerWidth;
8723
- const vh = window.innerHeight;
8724
- const fits = {
8725
- bottom: vh - (hole.top + hole.height) >= cardHeight + GAP2 + MARGIN,
8726
- top: hole.top >= cardHeight + GAP2 + MARGIN,
8727
- right: vw - (hole.left + hole.width) >= CARD_WIDTH + GAP2 + MARGIN,
8728
- left: hole.left >= CARD_WIDTH + GAP2 + MARGIN
8729
- };
8730
- const order = ["bottom", "top", "left", "right"];
8731
- const side = (_a = preferred && fits[preferred] ? preferred : order.find((p) => fits[p])) != null ? _a : "bottom";
8732
- const centerX = hole.left + hole.width / 2;
8733
- const centerY = hole.top + hole.height / 2;
8734
- if (side === "bottom" || side === "top") {
8735
- const left2 = clamp(
8736
- centerX - CARD_WIDTH / 2,
8737
- MARGIN,
8738
- vw - CARD_WIDTH - MARGIN
8714
+ var boxesOf = (element) => isContents(element) ? Array.from(element.children).flatMap(boxesOf) : [element];
8715
+ var findTarget = (ids) => {
8716
+ for (const id of ids) {
8717
+ const element = document.querySelector(
8718
+ `[${TOUR_TARGET_ATTRIBUTE}="${id.replace(/"/g, '\\"')}"]`
8739
8719
  );
8740
- const top2 = side === "bottom" ? Math.min(hole.top + hole.height + GAP2, vh - cardHeight - MARGIN) : Math.max(hole.top - GAP2 - cardHeight, MARGIN);
8741
- return {
8742
- side,
8743
- top: top2,
8744
- left: left2,
8745
- arrow: clamp(centerX - left2, 18, CARD_WIDTH - 18)
8746
- };
8720
+ if (element && measure(element)) return element;
8747
8721
  }
8748
- const top = clamp(centerY - cardHeight / 2, MARGIN, vh - cardHeight - MARGIN);
8749
- const left = side === "right" ? hole.left + hole.width + GAP2 : hole.left - GAP2 - CARD_WIDTH;
8750
- return { side, top, left, arrow: clamp(centerY - top, 18, cardHeight - 18) };
8751
- };
8752
- var ARROW_CLASS = {
8753
- bottom: "-top-[7px] -translate-x-1/2",
8754
- top: "-bottom-[7px] -translate-x-1/2",
8755
- right: "-left-[7px] -translate-y-1/2",
8756
- left: "-right-[7px] -translate-y-1/2"
8722
+ return null;
8757
8723
  };
8724
+ var sameRect = (a, b) => a === b || !!a && !!b && Math.abs(a.top - b.top) < 0.5 && Math.abs(a.left - b.left) < 0.5 && Math.abs(a.width - b.width) < 0.5 && Math.abs(a.height - b.height) < 0.5;
8725
+ var isOutOfView = (rect) => rect.top < 0 || rect.left < 0 || rect.top + rect.height > window.innerHeight || rect.left + rect.width > window.innerWidth;
8758
8726
  var Tour = ({
8759
8727
  steps,
8760
8728
  open,
@@ -8767,234 +8735,168 @@ var Tour = ({
8767
8735
  var _a;
8768
8736
  const text = __spreadValues(__spreadValues({}, DEFAULT_LABELS), labels);
8769
8737
  const current = steps[step];
8770
- const hasStep = Boolean(current);
8771
- const targetKey = [(_a = current == null ? void 0 : current.target) != null ? _a : []].flat().join("|");
8772
8738
  const total = steps.length;
8773
8739
  const isLast = step === total - 1;
8774
- const titleId = (0, import_react57.useId)();
8775
- const [rect, setRect] = (0, import_react57.useState)(null);
8776
- const [status, setStatus] = (0, import_react57.useState)("pending");
8777
- const [cardHeight, setCardHeight] = (0, import_react57.useState)(0);
8778
- const cardRef = (0, import_react57.useRef)(null);
8779
- const nextRef = (0, import_react57.useRef)(null);
8740
+ const driverRef = (0, import_react57.useRef)(null);
8741
+ const ghostRef = (0, import_react57.useRef)(null);
8742
+ const actions = (0, import_react57.useRef)({
8743
+ next: () => {
8744
+ },
8745
+ previous: () => {
8746
+ },
8747
+ close: () => {
8748
+ }
8749
+ });
8750
+ actions.current = {
8751
+ next: () => isLast ? onClose("finish") : onStepChange(step + 1),
8752
+ previous: () => {
8753
+ if (step > 0) onStepChange(step - 1);
8754
+ },
8755
+ close: () => onClose("close")
8756
+ };
8780
8757
  (0, import_react57.useEffect)(() => {
8781
- if (!open || !hasStep) return;
8782
- const targets = targetKey ? targetKey.split("|") : void 0;
8758
+ if (!open) return;
8759
+ const ghost = document.createElement("div");
8760
+ ghost.className = "dz-tour-target";
8761
+ document.body.appendChild(ghost);
8762
+ const instance = (0, import_driver.driver)({
8763
+ duration: HIGHLIGHT_DURATION_MS,
8764
+ allowKeyboardControl: false,
8765
+ overlayClickBehavior: () => {
8766
+ },
8767
+ overlayColor: "rgb(15, 23, 42)",
8768
+ overlayOpacity: 0.6,
8769
+ stagePadding: STAGE_PADDING,
8770
+ stageRadius: 8,
8771
+ popoverOffset: 8,
8772
+ popoverClass: "dz-tour"
8773
+ });
8774
+ driverRef.current = instance;
8775
+ ghostRef.current = ghost;
8776
+ return () => {
8777
+ instance.destroy();
8778
+ ghost.remove();
8779
+ driverRef.current = null;
8780
+ ghostRef.current = null;
8781
+ };
8782
+ }, [open]);
8783
+ (0, import_react57.useEffect)(() => {
8784
+ if (!open) return;
8785
+ const onKeyDown = (event) => {
8786
+ if (event.key === "Escape") {
8787
+ event.stopPropagation();
8788
+ actions.current.close();
8789
+ } else if (event.key === "ArrowRight") actions.current.next();
8790
+ else if (event.key === "ArrowLeft") actions.current.previous();
8791
+ };
8792
+ window.addEventListener("keydown", onKeyDown, true);
8793
+ return () => window.removeEventListener("keydown", onKeyDown, true);
8794
+ }, [open]);
8795
+ const view = (0, import_react57.useRef)({ current, text, step, total, isLast });
8796
+ view.current = { current, text, step, total, isLast };
8797
+ const targetKey = [(_a = current == null ? void 0 : current.target) != null ? _a : []].flat().join("|");
8798
+ const popoverKey = [
8799
+ current == null ? void 0 : current.title,
8800
+ current == null ? void 0 : current.content,
8801
+ current == null ? void 0 : current.placement,
8802
+ current == null ? void 0 : current.interactive,
8803
+ text.counter(step + 1, total),
8804
+ text.previous,
8805
+ isLast ? text.finish : text.next,
8806
+ text.close
8807
+ ].join("|");
8808
+ (0, import_react57.useEffect)(() => {
8809
+ const instance = driverRef.current;
8810
+ const ghost = ghostRef.current;
8811
+ const { current: current2, text: text2, step: step2, total: total2, isLast: isLast2 } = view.current;
8812
+ if (!open || !current2 || !instance || !ghost) return;
8813
+ const targets = targetKey ? targetKey.split("|") : [];
8814
+ const interactive = current2.interactive !== false;
8815
+ const popover = {
8816
+ title: current2.title,
8817
+ description: current2.content,
8818
+ side: current2.placement,
8819
+ showButtons: step2 > 0 ? ["next", "previous", "close"] : ["next", "close"],
8820
+ showProgress: true,
8821
+ progressText: text2.counter(step2 + 1, total2),
8822
+ nextBtnText: isLast2 ? text2.finish : text2.next,
8823
+ prevBtnText: text2.previous,
8824
+ onNextClick: () => actions.current.next(),
8825
+ onPrevClick: () => actions.current.previous(),
8826
+ onCloseClick: () => actions.current.close(),
8827
+ onPopoverRender: (dom) => {
8828
+ var _a2;
8829
+ dom.closeButton.setAttribute("aria-label", text2.close);
8830
+ dom.wrapper.setAttribute("aria-label", (_a2 = current2.title) != null ? _a2 : current2.content);
8831
+ dom.nextButton.focus({ preventScroll: true });
8832
+ }
8833
+ };
8783
8834
  const startedAt = performance.now();
8835
+ let shown = "none";
8784
8836
  let scrolled = false;
8837
+ let lastRect = null;
8838
+ let refreshUntil = 0;
8839
+ let animatingUntil = 0;
8840
+ let clickable = [];
8785
8841
  let frame = 0;
8786
- setStatus("pending");
8787
- setRect(null);
8842
+ const setClickable = (elements) => {
8843
+ clickable.forEach((el) => el.classList.remove("driver-active-element"));
8844
+ clickable = elements;
8845
+ clickable.forEach((el) => el.classList.add("driver-active-element"));
8846
+ };
8788
8847
  const track = () => {
8848
+ var _a2;
8789
8849
  const element = findTarget(targets);
8790
- const box = element ? measure(element) : null;
8791
- if (element && box) {
8850
+ const rect = element ? measure(element) : null;
8851
+ if (element && rect) {
8792
8852
  if (!scrolled) {
8793
8853
  scrolled = true;
8794
- const outOfView = box.top < 0 || box.left < 0 || box.top + box.height > window.innerHeight || box.left + box.width > window.innerWidth;
8795
- if (outOfView) {
8796
- firstBox(element).scrollIntoView({
8854
+ if (isOutOfView(rect)) {
8855
+ (_a2 = boxesOf(element)[0]) == null ? void 0 : _a2.scrollIntoView({
8797
8856
  block: "center",
8798
8857
  inline: "nearest"
8799
8858
  });
8800
8859
  }
8801
8860
  }
8802
- setRect((previous) => sameRect(previous, box) ? previous : box);
8803
- setStatus("found");
8804
- } else {
8805
- setRect(null);
8806
- setStatus(
8807
- !targets || performance.now() - startedAt > targetTimeout ? "missing" : "pending"
8808
- );
8861
+ if (!sameRect(lastRect, rect)) {
8862
+ lastRect = rect;
8863
+ refreshUntil = Math.max(
8864
+ refreshUntil,
8865
+ performance.now() + GHOST_TRANSITION_MS + 50
8866
+ );
8867
+ Object.assign(ghost.style, {
8868
+ top: `${rect.top}px`,
8869
+ left: `${rect.left}px`,
8870
+ width: `${rect.width}px`,
8871
+ height: `${rect.height}px`
8872
+ });
8873
+ }
8874
+ if (shown !== "target") {
8875
+ shown = "target";
8876
+ ghost.style.pointerEvents = interactive ? "none" : "auto";
8877
+ ghost.style.display = "block";
8878
+ instance.highlight({ element: ghost, popover });
8879
+ animatingUntil = performance.now() + HIGHLIGHT_DURATION_MS;
8880
+ refreshUntil = animatingUntil + GHOST_TRANSITION_MS;
8881
+ setClickable(interactive ? boxesOf(element) : []);
8882
+ } else if (performance.now() >= animatingUntil && performance.now() < refreshUntil) {
8883
+ instance.refresh();
8884
+ }
8885
+ } else if (shown !== "center" && (!targets.length || performance.now() - startedAt > targetTimeout)) {
8886
+ shown = "center";
8887
+ ghost.style.display = "none";
8888
+ setClickable([]);
8889
+ instance.highlight({ popover });
8809
8890
  }
8810
8891
  frame = requestAnimationFrame(track);
8811
8892
  };
8812
8893
  track();
8813
- return () => cancelAnimationFrame(frame);
8814
- }, [open, step, hasStep, targetKey, targetTimeout]);
8815
- (0, import_react57.useLayoutEffect)(() => {
8816
- if (cardRef.current) setCardHeight(cardRef.current.offsetHeight);
8817
- });
8818
- (0, import_react57.useEffect)(() => {
8819
- var _a2;
8820
- if (open && status !== "pending")
8821
- (_a2 = nextRef.current) == null ? void 0 : _a2.focus({ preventScroll: true });
8822
- }, [open, step, status]);
8823
- const goNext = (0, import_react57.useCallback)(() => {
8824
- if (isLast) onClose("finish");
8825
- else onStepChange(step + 1);
8826
- }, [isLast, onClose, onStepChange, step]);
8827
- const goPrevious = (0, import_react57.useCallback)(() => {
8828
- if (step > 0) onStepChange(step - 1);
8829
- }, [onStepChange, step]);
8830
- (0, import_react57.useEffect)(() => {
8831
- if (!open) return;
8832
- const onKeyDown = (event) => {
8833
- if (event.key === "Escape") {
8834
- event.stopPropagation();
8835
- onClose("close");
8836
- } else if (event.key === "ArrowRight") goNext();
8837
- else if (event.key === "ArrowLeft") goPrevious();
8894
+ return () => {
8895
+ cancelAnimationFrame(frame);
8896
+ setClickable([]);
8838
8897
  };
8839
- window.addEventListener("keydown", onKeyDown, true);
8840
- return () => window.removeEventListener("keydown", onKeyDown, true);
8841
- }, [open, goNext, goPrevious, onClose]);
8842
- if (!open || !current) return null;
8843
- const hole = rect && {
8844
- top: rect.top - HOLE_PADDING,
8845
- left: rect.left - HOLE_PADDING,
8846
- width: rect.width + HOLE_PADDING * 2,
8847
- height: rect.height + HOLE_PADDING * 2
8848
- };
8849
- const placement = hole && placeCard(hole, cardHeight, current.placement);
8850
- const blockClick = (event) => event.stopPropagation();
8851
- const blocker = "fixed z-[10000]";
8852
- return (0, import_react_dom.createPortal)(
8853
- /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_jsx_runtime94.Fragment, { children: [
8854
- hole ? /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_jsx_runtime94.Fragment, { children: [
8855
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8856
- "div",
8857
- {
8858
- "aria-hidden": true,
8859
- className: "pointer-events-none fixed z-[10000] rounded-[8px] shadow-[0_0_0_9999px_rgba(15,23,42,0.6)] ring-[3px] ring-yellow-300 transition-all duration-200 ease-out",
8860
- style: hole
8861
- }
8862
- ),
8863
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8864
- "div",
8865
- {
8866
- className: cn(blocker, "inset-x-0 top-0"),
8867
- style: { height: Math.max(hole.top, 0) },
8868
- onMouseDown: blockClick,
8869
- onClick: blockClick
8870
- }
8871
- ),
8872
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8873
- "div",
8874
- {
8875
- className: cn(blocker, "inset-x-0 bottom-0"),
8876
- style: { top: hole.top + hole.height },
8877
- onMouseDown: blockClick,
8878
- onClick: blockClick
8879
- }
8880
- ),
8881
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8882
- "div",
8883
- {
8884
- className: cn(blocker, "left-0"),
8885
- style: {
8886
- top: hole.top,
8887
- height: hole.height,
8888
- width: Math.max(hole.left, 0)
8889
- },
8890
- onMouseDown: blockClick,
8891
- onClick: blockClick
8892
- }
8893
- ),
8894
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8895
- "div",
8896
- {
8897
- className: cn(blocker, "right-0"),
8898
- style: {
8899
- top: hole.top,
8900
- height: hole.height,
8901
- left: hole.left + hole.width
8902
- },
8903
- onMouseDown: blockClick,
8904
- onClick: blockClick
8905
- }
8906
- ),
8907
- current.interactive === false && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: blocker, style: hole, onClick: blockClick })
8908
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8909
- "div",
8910
- {
8911
- className: cn(blocker, "inset-0 bg-[rgba(15,23,42,0.6)]"),
8912
- onMouseDown: blockClick,
8913
- onClick: blockClick
8914
- }
8915
- ),
8916
- status !== "pending" && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
8917
- "div",
8918
- {
8919
- ref: cardRef,
8920
- role: "dialog",
8921
- "aria-modal": "true",
8922
- "aria-labelledby": titleId,
8923
- className: cn(
8924
- "fixed z-[10001] rounded-[12px] bg-yellow-300 p-5 shadow-[0_10px_30px_rgba(0,0,0,0.25)]",
8925
- !placement && "left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
8926
- placement && "transition-[top,left] duration-200 ease-out"
8927
- ),
8928
- style: __spreadValues({
8929
- width: CARD_WIDTH
8930
- }, placement && { top: placement.top, left: placement.left }),
8931
- children: [
8932
- placement && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8933
- "span",
8934
- {
8935
- "aria-hidden": true,
8936
- className: cn(
8937
- "absolute h-3 w-3 rotate-45 bg-yellow-300",
8938
- ARROW_CLASS[placement.side]
8939
- ),
8940
- style: placement.side === "bottom" || placement.side === "top" ? { left: placement.arrow } : { top: placement.arrow }
8941
- }
8942
- ),
8943
- /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Layout, { column: true, gap: 3, children: [
8944
- /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Layout, { row: true, justify: "between", align: "center", children: [
8945
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Text, { size: "xs", weight: "semibold", color: "white", children: text.counter(step + 1, total) }),
8946
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8947
- Icon,
8948
- {
8949
- name: "xmark",
8950
- size: "s",
8951
- color: "white",
8952
- onClick: () => onClose("close"),
8953
- "aria-label": text.close
8954
- }
8955
- )
8956
- ] }),
8957
- current.title && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Text, { id: titleId, size: "m", weight: "bold", color: "white", children: current.title }),
8958
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8959
- Text,
8960
- {
8961
- id: current.title ? void 0 : titleId,
8962
- size: "m",
8963
- weight: "medium",
8964
- color: "white",
8965
- className: "leading-relaxed",
8966
- children: current.content
8967
- }
8968
- ),
8969
- /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Layout, { row: true, justify: "end", gap: 2, children: [
8970
- step > 0 && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8971
- Button,
8972
- {
8973
- label: text.previous,
8974
- variant: "outline",
8975
- size: "s",
8976
- className: "border-white text-white",
8977
- onClick: goPrevious
8978
- }
8979
- ),
8980
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
8981
- Button,
8982
- {
8983
- ref: nextRef,
8984
- label: isLast ? text.finish : text.next,
8985
- size: "s",
8986
- className: "bg-white text-yellow-500",
8987
- onClick: goNext
8988
- }
8989
- )
8990
- ] })
8991
- ] })
8992
- ]
8993
- }
8994
- )
8995
- ] }),
8996
- document.body
8997
- );
8898
+ }, [open, step, targetKey, popoverKey, targetTimeout]);
8899
+ return null;
8998
8900
  };
8999
8901
  // Annotate the CommonJS export names for ESM import in node:
9000
8902
  0 && (module.exports = {