@ada-cx/lovelace 1.18.4 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AgentMessage/AgentMessage.js.map +1 -1
- package/dist/components/AttachmentChip/AttachmentChip.css.js +1 -1
- package/dist/components/AttachmentChip/AttachmentChip.js.map +1 -1
- package/dist/components/Avatar/Avatar.css.js +1 -1
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/AvatarPlaceholder.js.map +1 -1
- package/dist/components/Banner/Banner.css.js +1 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/Banner/BannerContainer.js.map +1 -1
- package/dist/components/Banner/BannerContainerSlide.js.map +1 -1
- package/dist/components/BubbleOverlay/BubbleOverlay.js.map +1 -1
- package/dist/components/Button/Button.css.js +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Card/Card.css.d.ts +8 -0
- package/dist/components/Card/Card.css.js +7 -0
- package/dist/components/Card/Card.css.js.map +1 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.js +18 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/CardActions.d.ts +7 -0
- package/dist/components/Card/CardActions.js +14 -0
- package/dist/components/Card/CardActions.js.map +1 -0
- package/dist/components/Card/CardBody.d.ts +7 -0
- package/dist/components/Card/CardBody.js +14 -0
- package/dist/components/Card/CardBody.js.map +1 -0
- package/dist/components/Card/CardDescription.d.ts +9 -0
- package/dist/components/Card/CardDescription.js +15 -0
- package/dist/components/Card/CardDescription.js.map +1 -0
- package/dist/components/Card/CardMedia.d.ts +17 -0
- package/dist/components/Card/CardMedia.js +23 -0
- package/dist/components/Card/CardMedia.js.map +1 -0
- package/dist/components/Card/CardRoot.d.ts +22 -0
- package/dist/components/Card/CardRoot.js +25 -0
- package/dist/components/Card/CardRoot.js.map +1 -0
- package/dist/components/Card/CardTitle.d.ts +9 -0
- package/dist/components/Card/CardTitle.js +15 -0
- package/dist/components/Card/CardTitle.js.map +1 -0
- package/dist/components/Card/index.d.ts +6 -0
- package/dist/components/Carousel/Carousel.css.d.ts +6 -0
- package/dist/components/Carousel/Carousel.css.js +7 -0
- package/dist/components/Carousel/Carousel.css.js.map +1 -0
- package/dist/components/Carousel/Carousel.d.ts +19 -0
- package/dist/components/Carousel/Carousel.js +141 -0
- package/dist/components/Carousel/Carousel.js.map +1 -0
- package/dist/components/Carousel/CarouselItem.d.ts +8 -0
- package/dist/components/Carousel/CarouselItem.js +14 -0
- package/dist/components/Carousel/CarouselItem.js.map +1 -0
- package/dist/components/Carousel/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.css.js +1 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/CheckboxGroup.js.map +1 -1
- package/dist/components/Checkbox/CheckboxIndicator.js.map +1 -1
- package/dist/components/Chip/Chip.css.js +1 -1
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/Dialog/Dialog.css.js +1 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dialog/DialogActions.js.map +1 -1
- package/dist/components/Dialog/DialogBody.js.map +1 -1
- package/dist/components/Dialog/DialogContent.js.map +1 -1
- package/dist/components/Dialog/DialogIcon.js.map +1 -1
- package/dist/components/Dialog/DialogRoot.js.map +1 -1
- package/dist/components/Dialog/DialogTitle.js.map +1 -1
- package/dist/components/DialogOverlay/DialogOverlay.js.map +1 -1
- package/dist/components/Divider/Divider.css.js +1 -1
- package/dist/components/Divider/Divider.js.map +1 -1
- package/dist/components/DropZone/DropZone.js.map +1 -1
- package/dist/components/FullscreenOverlay/FullscreenOverlay.js.map +1 -1
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/Header/HeaderRoot.js.map +1 -1
- package/dist/components/Header/HeaderTitle.js.map +1 -1
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Icon/icons/AdaLogo.js.map +1 -1
- package/dist/components/Icon/icons/ArrowDown.js.map +1 -1
- package/dist/components/Icon/icons/ArrowLeft.js.map +1 -1
- package/dist/components/Icon/icons/ArrowNortheast.js.map +1 -1
- package/dist/components/Icon/icons/ArrowNorthwest.js.map +1 -1
- package/dist/components/Icon/icons/ArrowRight.js.map +1 -1
- package/dist/components/Icon/icons/ArrowUp.js.map +1 -1
- package/dist/components/Icon/icons/Bell.js.map +1 -1
- package/dist/components/Icon/icons/BellSlash.js.map +1 -1
- package/dist/components/Icon/icons/Checkmark.js.map +1 -1
- package/dist/components/Icon/icons/CheckmarkCircle.js.map +1 -1
- package/dist/components/Icon/icons/ChevronLeft.js.map +1 -1
- package/dist/components/Icon/icons/ChevronRight.js.map +1 -1
- package/dist/components/Icon/icons/CloudUpload.js.map +1 -1
- package/dist/components/Icon/icons/Document.js.map +1 -1
- package/dist/components/Icon/icons/Download.js.map +1 -1
- package/dist/components/Icon/icons/Ellipses.js.map +1 -1
- package/dist/components/Icon/icons/Email.js.map +1 -1
- package/dist/components/Icon/icons/ExclamationSync.js.map +1 -1
- package/dist/components/Icon/icons/ExclamationTriangle.js.map +1 -1
- package/dist/components/Icon/icons/Eye.js.map +1 -1
- package/dist/components/Icon/icons/EyeSlash.js.map +1 -1
- package/dist/components/Icon/icons/Glyph.js.map +1 -1
- package/dist/components/Icon/icons/Language.js.map +1 -1
- package/dist/components/Icon/icons/MediaSlash.js.map +1 -1
- package/dist/components/Icon/icons/MessagingFill.js.map +1 -1
- package/dist/components/Icon/icons/Minimize.js.map +1 -1
- package/dist/components/Icon/icons/Mute.js.map +1 -1
- package/dist/components/Icon/icons/Paperclip.js.map +1 -1
- package/dist/components/Icon/icons/PersonFill.js.map +1 -1
- package/dist/components/Icon/icons/PlayFill.js.map +1 -1
- package/dist/components/Icon/icons/Send.js.map +1 -1
- package/dist/components/Icon/icons/StarBadgeFill.js.map +1 -1
- package/dist/components/Icon/icons/ThumbsDown.js.map +1 -1
- package/dist/components/Icon/icons/ThumbsUp.js.map +1 -1
- package/dist/components/Icon/icons/Volume.js.map +1 -1
- package/dist/components/Icon/icons/Xmark.js.map +1 -1
- package/dist/components/Icon/icons/XmarkCircle.js.map +1 -1
- package/dist/components/IconButton/IconButton.css.js +1 -1
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Input/Input.context.js.map +1 -1
- package/dist/components/Input/Input.css.js +1 -1
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/InputAttachments.js.map +1 -1
- package/dist/components/Input/InputButton.js.map +1 -1
- package/dist/components/Input/InputControl.js.map +1 -1
- package/dist/components/Input/InputField.js.map +1 -1
- package/dist/components/Input/InputHelperText.js.map +1 -1
- package/dist/components/Input/InputLabel.js.map +1 -1
- package/dist/components/Input/InputRoot.js.map +1 -1
- package/dist/components/Input/InputTextArea.js.map +1 -1
- package/dist/components/Link/Link.css.js +1 -1
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/MenuItem/Menu.js.map +1 -1
- package/dist/components/MenuItem/MenuItem.js.map +1 -1
- package/dist/components/MenuItem/MenuItemCheckbox.js.map +1 -1
- package/dist/components/MenuItem/MenuItemLabel.js.map +1 -1
- package/dist/components/MenuItem/MenuItemRadio.js.map +1 -1
- package/dist/components/MenuItem/MenuItemRoot.js.map +1 -1
- package/dist/components/MenuItem/MenuItemToggle.js.map +1 -1
- package/dist/components/MessageError/MessageError.js.map +1 -1
- package/dist/components/MessageProse/MessageProse.js.map +1 -1
- package/dist/components/MessageRow/MessageRow.context.js.map +1 -1
- package/dist/components/MessageRow/MessageRow.css.js +1 -1
- package/dist/components/MessageRow/MessageRow.js.map +1 -1
- package/dist/components/MessageRow/MessageRowContent.js.map +1 -1
- package/dist/components/MessageRow/MessageRowRoot.js.map +1 -1
- package/dist/components/PictureMessage/PictureMessage.css.js +1 -1
- package/dist/components/PictureMessage/PictureMessage.js.map +1 -1
- package/dist/components/PillButton/PillButton.css.js +1 -1
- package/dist/components/PillButton/PillButton.js.map +1 -1
- package/dist/components/ProactiveMessage/ProactiveMessage.js.map +1 -1
- package/dist/components/Radio/Radio.css.js +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/RadioGroup.js.map +1 -1
- package/dist/components/Radio/RadioIndicator.js.map +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.css.js +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.js.map +1 -1
- package/dist/components/Sheet/Sheet.js.map +1 -1
- package/dist/components/Sheet/SheetActions.js.map +1 -1
- package/dist/components/Sheet/SheetBackButton.js.map +1 -1
- package/dist/components/Sheet/SheetBody.js.map +1 -1
- package/dist/components/Sheet/SheetCloseButton.js.map +1 -1
- package/dist/components/Sheet/SheetHeader.js.map +1 -1
- package/dist/components/Sheet/SheetRoot.js.map +1 -1
- package/dist/components/Sheet/SheetTitle.js.map +1 -1
- package/dist/components/SheetOverlay/SheetOverlay.js.map +1 -1
- package/dist/components/Spinner/Spinner.css.js +1 -1
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/SurveyRating/SurveyRating.js.map +1 -1
- package/dist/components/SurveySelect/SurveySelect.js.map +1 -1
- package/dist/components/Text/Text.css.js +1 -1
- package/dist/components/Text/Text.js.map +1 -1
- package/dist/components/ThinkingShimmer/ThinkingShimmer.js.map +1 -1
- package/dist/components/Toast/Toast.css.js +1 -1
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/ToastContainer.js.map +1 -1
- package/dist/components/Toast/index.js +4 -4
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Toggle/ToggleIndicator.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/TypingIndicator/TypingIndicator.js.map +1 -1
- package/dist/components/UserMessage/UserMessage.js.map +1 -1
- package/dist/components/VideoMessage/VideoMessage.css.js +1 -1
- package/dist/components/VideoMessage/VideoMessage.js.map +1 -1
- package/dist/hooks/overlayRegistry.js.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.js.map +1 -1
- package/dist/hooks/useSubmitOnEnter.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -43
- package/dist/runtime/LovelaceProvider.js +6 -6
- package/dist/runtime/LovelaceProvider.js.map +1 -1
- package/dist/runtime/branding.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tokens/tokens.js.map +1 -1
- package/dist/utils/animation.js.map +1 -1
- package/dist/utils/cx.js.map +1 -1
- package/dist/vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js +1 -1
- package/dist/vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveyRating.js","names":[],"sources":["../../../src/components/SurveyRating/SurveyRating.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"./SurveyLabelProps.js\";\nimport {\n\tsurveyRatingLabels,\n\tsurveyRatingRoot,\n\tsurveyRatingScale,\n} from \"./SurveyRating.css.js\";\n\nexport interface SurveyRatingOption {\n\t/** Numeric value shown on the chip (e.g. 1–5, 1–10). Rendered unless `icon` is set. */\n\tvalue: number;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n\t/** Endpoint label to render as selected option. */\n\tlabel?: string;\n\t/** Renders an icon chip (emoji, thumbs) instead of the numeric value. */\n\ticon?: ReactNode;\n\t/** Accessible name for the option. Overrides the numeric value / icon; icon options fall back to `label`. */\n\t\"aria-label\"?: string;\n}\n\nexport type SurveyRatingProps = SurveyLabelProps & {\n\t/** Ordered rating options, lowest value first. */\n\toptions: SurveyRatingOption[];\n\t/** Show the first and last options' labels as scale endpoints. */\n\tshowLabels?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option key (controlled). `null` means nothing selected. */\n\tselectedKey?: Key | null;\n\t/** Initially-selected option key (uncontrolled). */\n\tdefaultSelectedKey?: Key | null;\n\t/** Fires with the newly-selected key and option, or `null` when deselected. */\n\tonChange?: (key: Key | null, option: SurveyRatingOption | null) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveyRatingOption, index: number) =>\n\toption.key ?? index;\n\n/** Most chips allowed on one row before the scale wraps to a balanced grid. */\nconst MAX_PER_ROW = 7;\n\n/** Chip footprint at `size=\"lg\"` — mirrors Chip.css.ts's fixed 48px square + gap-8. */\nconst CHIP_SIZE_LG = 48;\nconst CHIP_GAP = 8;\n\n/** Column count that splits `count` options into evenly-sized rows (11 → 6, 10 → 5, 7 → 7). */\nconst balancedColumns = (count: number) => {\n\tconst rows = Math.max(1, Math.ceil(count / MAX_PER_ROW));\n\treturn Math.max(1, Math.ceil(count / rows));\n};\n\n/**\n * Width that wraps the scale at the balanced column count. A cap rather than a fixed\n * track count, so a container narrower than this wraps further instead of overflowing\n * (the 0-10 scale is 328px wide — wider than the 320px BubbleOverlay cap).\n */\nconst balancedMaxWidth = (count: number) => {\n\tconst cols = balancedColumns(count);\n\treturn cols * CHIP_SIZE_LG + (cols - 1) * CHIP_GAP;\n};\n\n/**\n * Single-select rating scale for post-conversation surveys. Renders each option as a\n * square {@link Chip}; a numeric `value` or an `icon` (emoji, thumbs) per option supports\n * arbitrary scales. Exactly one option is selectable at a time, and tapping the selected\n * option deselects it (React Aria toggle semantics).\n */\nexport function SurveyRating({\n\toptions,\n\tshowLabels = false,\n\tisDisabled,\n\tselectedKey,\n\tdefaultSelectedKey,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveyRatingProps) {\n\tconst lowLabel = options[0]?.label;\n\tconst highLabel = options[options.length - 1]?.label;\n\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst key = keys.size ? [...keys][0] : null;\n\t\tconst option =\n\t\t\tkey == null\n\t\t\t\t? null\n\t\t\t\t: (options.find((o, i) => keyFor(o, i) === key) ?? null);\n\t\tonChange?.(key, option);\n\t};\n\n\t// Translate the single-key facade into RAC's Set-based controlled/uncontrolled props:\n\t// a defined `selectedKey` (including `null`) is controlled; otherwise it's uncontrolled.\n\tconst toKeys = (key: Key | null | undefined) => (key == null ? [] : [key]);\n\tconst isControlled = selectedKey !== undefined;\n\n\treturn (\n\t\t<div ref={ref} className={cx(surveyRatingRoot, className)} style={style}>\n\t\t\t<ToggleButtonGroup\n\t\t\t\tselectionMode=\"single\"\n\t\t\t\tisDisabled={isDisabled}\n\t\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\tclassName={surveyRatingScale}\n\t\t\t\tstyle={{ maxWidth: balancedMaxWidth(options.length) }}\n\t\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\t\tselectedKeys={isControlled ? toKeys(selectedKey) : undefined}\n\t\t\t\tdefaultSelectedKeys={\n\t\t\t\t\tisControlled ? undefined : toKeys(defaultSelectedKey)\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{options.map((option, index) => {\n\t\t\t\t\tconst isIcon = option.icon != null;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\t\t\tvariant={isIcon ? \"icon\" : \"number\"}\n\t\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\toption[\"aria-label\"] ?? (isIcon ? option.label : undefined)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.icon ?? option.value}\n\t\t\t\t\t\t</Chip>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</ToggleButtonGroup>\n\t\t\t{showLabels && (lowLabel != null || highLabel != null) && (\n\t\t\t\t<div className={surveyRatingLabels}>\n\t\t\t\t\t<span>{lowLabel}</span>\n\t\t\t\t\t<span>{highLabel}</span>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AA0CA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO,GAGT,IAAc,GAGd,IAAe,IACf,IAAW,GAGX,KAAmB,MAAkB;CAC1C,IAAM,IAAO,KAAK,IAAI,GAAG,KAAK,KAAK,IAAQ,
|
|
1
|
+
{"version":3,"file":"SurveyRating.js","names":[],"sources":["../../../src/components/SurveyRating/SurveyRating.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"./SurveyLabelProps.js\";\nimport {\n\tsurveyRatingLabels,\n\tsurveyRatingRoot,\n\tsurveyRatingScale,\n} from \"./SurveyRating.css.js\";\n\nexport interface SurveyRatingOption {\n\t/** Numeric value shown on the chip (e.g. 1–5, 1–10). Rendered unless `icon` is set. */\n\tvalue: number;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n\t/** Endpoint label to render as selected option. */\n\tlabel?: string;\n\t/** Renders an icon chip (emoji, thumbs) instead of the numeric value. */\n\ticon?: ReactNode;\n\t/** Accessible name for the option. Overrides the numeric value / icon; icon options fall back to `label`. */\n\t\"aria-label\"?: string;\n}\n\nexport type SurveyRatingProps = SurveyLabelProps & {\n\t/** Ordered rating options, lowest value first. */\n\toptions: SurveyRatingOption[];\n\t/** Show the first and last options' labels as scale endpoints. */\n\tshowLabels?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option key (controlled). `null` means nothing selected. */\n\tselectedKey?: Key | null;\n\t/** Initially-selected option key (uncontrolled). */\n\tdefaultSelectedKey?: Key | null;\n\t/** Fires with the newly-selected key and option, or `null` when deselected. */\n\tonChange?: (key: Key | null, option: SurveyRatingOption | null) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveyRatingOption, index: number) =>\n\toption.key ?? index;\n\n/** Most chips allowed on one row before the scale wraps to a balanced grid. */\nconst MAX_PER_ROW = 7;\n\n/** Chip footprint at `size=\"lg\"` — mirrors Chip.css.ts's fixed 48px square + gap-8. */\nconst CHIP_SIZE_LG = 48;\nconst CHIP_GAP = 8;\n\n/** Column count that splits `count` options into evenly-sized rows (11 → 6, 10 → 5, 7 → 7). */\nconst balancedColumns = (count: number) => {\n\tconst rows = Math.max(1, Math.ceil(count / MAX_PER_ROW));\n\treturn Math.max(1, Math.ceil(count / rows));\n};\n\n/**\n * Width that wraps the scale at the balanced column count. A cap rather than a fixed\n * track count, so a container narrower than this wraps further instead of overflowing\n * (the 0-10 scale is 328px wide — wider than the 320px BubbleOverlay cap).\n */\nconst balancedMaxWidth = (count: number) => {\n\tconst cols = balancedColumns(count);\n\treturn cols * CHIP_SIZE_LG + (cols - 1) * CHIP_GAP;\n};\n\n/**\n * Single-select rating scale for post-conversation surveys. Renders each option as a\n * square {@link Chip}; a numeric `value` or an `icon` (emoji, thumbs) per option supports\n * arbitrary scales. Exactly one option is selectable at a time, and tapping the selected\n * option deselects it (React Aria toggle semantics).\n */\nexport function SurveyRating({\n\toptions,\n\tshowLabels = false,\n\tisDisabled,\n\tselectedKey,\n\tdefaultSelectedKey,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveyRatingProps) {\n\tconst lowLabel = options[0]?.label;\n\tconst highLabel = options[options.length - 1]?.label;\n\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst key = keys.size ? [...keys][0] : null;\n\t\tconst option =\n\t\t\tkey == null\n\t\t\t\t? null\n\t\t\t\t: (options.find((o, i) => keyFor(o, i) === key) ?? null);\n\t\tonChange?.(key, option);\n\t};\n\n\t// Translate the single-key facade into RAC's Set-based controlled/uncontrolled props:\n\t// a defined `selectedKey` (including `null`) is controlled; otherwise it's uncontrolled.\n\tconst toKeys = (key: Key | null | undefined) => (key == null ? [] : [key]);\n\tconst isControlled = selectedKey !== undefined;\n\n\treturn (\n\t\t<div ref={ref} className={cx(surveyRatingRoot, className)} style={style}>\n\t\t\t<ToggleButtonGroup\n\t\t\t\tselectionMode=\"single\"\n\t\t\t\tisDisabled={isDisabled}\n\t\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\tclassName={surveyRatingScale}\n\t\t\t\tstyle={{ maxWidth: balancedMaxWidth(options.length) }}\n\t\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\t\tselectedKeys={isControlled ? toKeys(selectedKey) : undefined}\n\t\t\t\tdefaultSelectedKeys={\n\t\t\t\t\tisControlled ? undefined : toKeys(defaultSelectedKey)\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{options.map((option, index) => {\n\t\t\t\t\tconst isIcon = option.icon != null;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\t\t\tvariant={isIcon ? \"icon\" : \"number\"}\n\t\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\toption[\"aria-label\"] ?? (isIcon ? option.label : undefined)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.icon ?? option.value}\n\t\t\t\t\t\t</Chip>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</ToggleButtonGroup>\n\t\t\t{showLabels && (lowLabel != null || highLabel != null) && (\n\t\t\t\t<div className={surveyRatingLabels}>\n\t\t\t\t\t<span>{lowLabel}</span>\n\t\t\t\t\t<span>{highLabel}</span>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AA0CA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO,GAGT,IAAc,GAGd,IAAe,IACf,IAAW,GAGX,KAAmB,MAAkB;CAC1C,IAAM,IAAO,KAAK,IAAI,GAAG,KAAK,KAAK,IAAQ,CAAW,CAAC;CACvD,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,IAAQ,CAAI,CAAC;AAC3C,GAOM,KAAoB,MAAkB;CAC3C,IAAM,IAAO,EAAgB,CAAK;CAClC,OAAO,IAAO,KAAgB,IAAO,KAAK;AAC3C;AAQA,SAAgB,EAAa,EAC5B,YACA,gBAAa,IACb,eACA,gBACA,uBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,IAAW,EAAQ,EAAE,EAAE,OACvB,IAAY,EAAQ,EAAQ,SAAS,EAAE,EAAE,OAEzC,KAAyB,MAAmB;EACjD,IAAM,IAAM,EAAK,OAAO,CAAC,GAAG,CAAI,CAAC,CAAC,KAAK,MACjC,IACL,KAAO,OACJ,OACC,EAAQ,MAAM,GAAG,MAAM,EAAO,GAAG,CAAC,MAAM,CAAG,KAAK;EACrD,IAAW,GAAK,CAAM;CACvB,GAIM,KAAU,MAAiC,KAAO,OAAO,CAAC,IAAI,CAAC,CAAG,GAClE,IAAe,MAAgB,KAAA;CAErC,OACC,kBAAC,OAAD;EAAU;EAAK,WAAW,EAAG,GAAkB,CAAS;EAAU;YAAlE,CACC,kBAAC,GAAD;GACC,eAAc;GACF;GACZ,cAAY,IAAiB,KAAA,IAAY;GACzC,mBAAiB;GACjB,WAAW;GACX,OAAO,EAAE,UAAU,EAAiB,EAAQ,MAAM,EAAE;GACpD,mBAAmB;GACnB,cAAc,IAAe,EAAO,CAAW,IAAI,KAAA;GACnD,qBACC,IAAe,KAAA,IAAY,EAAO,CAAkB;aAGpD,EAAQ,KAAK,GAAQ,MAAU;IAC/B,IAAM,IAAS,EAAO,QAAQ;IAC9B,OACC,kBAAC,GAAD;KAEC,IAAI,EAAO,GAAQ,CAAK;KACxB,SAAS,IAAS,SAAS;KAC3B,MAAK;KACL,cACC,EAAO,kBAAkB,IAAS,EAAO,QAAQ,KAAA;eAGjD,EAAO,QAAQ,EAAO;IAClB,GATA,EAAO,GAAQ,CAAK,CASpB;GAER,CAAC;EACiB,CAAA,GAClB,MAAe,KAAY,QAAQ,KAAa,SAChD,kBAAC,OAAD;GAAK,WAAA;aAAL,CACC,kBAAC,QAAD,EAAA,UAAO,EAAe,CAAA,GACtB,kBAAC,QAAD,EAAA,UAAO,EAAgB,CAAA,CACnB;IAEF;;AAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../src/components/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyRating/SurveyLabelProps.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport type SurveySelectProps = SurveyLabelProps & {\n\t/** Selectable options, rendered in order. */\n\toptions: SurveySelectOption[];\n\t/**\n\t * `multiple` (default) allows any number of selected chips; `single` allows at\n\t * most one (e.g. a Yes/No question) and renders as a radiogroup.\n\t */\n\tselectionMode?: \"single\" | \"multiple\";\n\t/**\n\t * When `true`, a selected option can't be toggled back off — restores radio\n\t * semantics for a required single-select (e.g. a Yes/No question).\n\t */\n\tdisallowEmptySelection?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option keys (controlled). */\n\tselectedKeys?: Key[];\n\t/** Initially-selected option keys (uncontrolled). */\n\tdefaultSelectedKeys?: Key[];\n\t/** Fires with the full set of selected keys and their options, in option order. */\n\tonChange?: (keys: Key[], options: SurveySelectOption[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveySelectOption, index: number) =>\n\toption.key ?? index;\n\n/**\n * Multi-select chip group for surveys — the labelled-pill counterpart to the single-select\n * {@link SurveyRating}. Any number of options can be selected at once; selection state\n * renders the accent fill on each {@link Chip}.\n */\nexport function SurveySelect({\n\toptions,\n\tselectionMode = \"multiple\",\n\tdisallowEmptySelection,\n\tisDisabled,\n\tselectedKeys,\n\tdefaultSelectedKeys,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveySelectProps) {\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst selected = options\n\t\t\t.map((option, index) => ({ option, key: keyFor(option, index) }))\n\t\t\t.filter(({ key }) => keys.has(key));\n\t\tonChange?.(\n\t\t\tselected.map((s) => s.key),\n\t\t\tselected.map((s) => s.option),\n\t\t);\n\t};\n\n\tconst isControlled = selectedKeys !== undefined;\n\n\treturn (\n\t\t<ToggleButtonGroup\n\t\t\tref={ref}\n\t\t\tselectionMode={selectionMode}\n\t\t\tdisallowEmptySelection={disallowEmptySelection}\n\t\t\tisDisabled={isDisabled}\n\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tclassName={cx(surveySelectRoot, className)}\n\t\t\tstyle={style}\n\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\tselectedKeys={isControlled ? selectedKeys : undefined}\n\t\t\tdefaultSelectedKeys={\n\t\t\t\tisControlled ? undefined : (defaultSelectedKeys ?? [])\n\t\t\t}\n\t\t>\n\t\t\t{options.map((option, index) => (\n\t\t\t\t<Chip\n\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\tvariant=\"text\"\n\t\t\t\t\tsize=\"md\"\n\t\t\t\t>\n\t\t\t\t\t{option.label}\n\t\t\t\t</Chip>\n\t\t\t))}\n\t\t</ToggleButtonGroup>\n\t);\n}\n"],"mappings":";;;;;;AAwCA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO;AAOf,SAAgB,EAAa,EAC5B,YACA,mBAAgB,YAChB,2BACA,eACA,iBACA,wBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,KAAyB,MAAmB;EACjD,IAAM,IAAW,EACf,KAAK,GAAQ,OAAW;GAAE;GAAQ,KAAK,EAAO,GAAQ,
|
|
1
|
+
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../src/components/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyRating/SurveyLabelProps.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport type SurveySelectProps = SurveyLabelProps & {\n\t/** Selectable options, rendered in order. */\n\toptions: SurveySelectOption[];\n\t/**\n\t * `multiple` (default) allows any number of selected chips; `single` allows at\n\t * most one (e.g. a Yes/No question) and renders as a radiogroup.\n\t */\n\tselectionMode?: \"single\" | \"multiple\";\n\t/**\n\t * When `true`, a selected option can't be toggled back off — restores radio\n\t * semantics for a required single-select (e.g. a Yes/No question).\n\t */\n\tdisallowEmptySelection?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option keys (controlled). */\n\tselectedKeys?: Key[];\n\t/** Initially-selected option keys (uncontrolled). */\n\tdefaultSelectedKeys?: Key[];\n\t/** Fires with the full set of selected keys and their options, in option order. */\n\tonChange?: (keys: Key[], options: SurveySelectOption[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveySelectOption, index: number) =>\n\toption.key ?? index;\n\n/**\n * Multi-select chip group for surveys — the labelled-pill counterpart to the single-select\n * {@link SurveyRating}. Any number of options can be selected at once; selection state\n * renders the accent fill on each {@link Chip}.\n */\nexport function SurveySelect({\n\toptions,\n\tselectionMode = \"multiple\",\n\tdisallowEmptySelection,\n\tisDisabled,\n\tselectedKeys,\n\tdefaultSelectedKeys,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveySelectProps) {\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst selected = options\n\t\t\t.map((option, index) => ({ option, key: keyFor(option, index) }))\n\t\t\t.filter(({ key }) => keys.has(key));\n\t\tonChange?.(\n\t\t\tselected.map((s) => s.key),\n\t\t\tselected.map((s) => s.option),\n\t\t);\n\t};\n\n\tconst isControlled = selectedKeys !== undefined;\n\n\treturn (\n\t\t<ToggleButtonGroup\n\t\t\tref={ref}\n\t\t\tselectionMode={selectionMode}\n\t\t\tdisallowEmptySelection={disallowEmptySelection}\n\t\t\tisDisabled={isDisabled}\n\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tclassName={cx(surveySelectRoot, className)}\n\t\t\tstyle={style}\n\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\tselectedKeys={isControlled ? selectedKeys : undefined}\n\t\t\tdefaultSelectedKeys={\n\t\t\t\tisControlled ? undefined : (defaultSelectedKeys ?? [])\n\t\t\t}\n\t\t>\n\t\t\t{options.map((option, index) => (\n\t\t\t\t<Chip\n\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\tvariant=\"text\"\n\t\t\t\t\tsize=\"md\"\n\t\t\t\t>\n\t\t\t\t\t{option.label}\n\t\t\t\t</Chip>\n\t\t\t))}\n\t\t</ToggleButtonGroup>\n\t);\n}\n"],"mappings":";;;;;;AAwCA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO;AAOf,SAAgB,EAAa,EAC5B,YACA,mBAAgB,YAChB,2BACA,eACA,iBACA,wBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,KAAyB,MAAmB;EACjD,IAAM,IAAW,EACf,KAAK,GAAQ,OAAW;GAAE;GAAQ,KAAK,EAAO,GAAQ,CAAK;EAAE,EAAE,CAAC,CAChE,QAAQ,EAAE,aAAU,EAAK,IAAI,CAAG,CAAC;EACnC,IACC,EAAS,KAAK,MAAM,EAAE,GAAG,GACzB,EAAS,KAAK,MAAM,EAAE,MAAM,CAC7B;CACD,GAEM,IAAe,MAAiB,KAAA;CAEtC,OACC,kBAAC,GAAD;EACM;EACU;EACS;EACZ;EACZ,cAAY,IAAiB,KAAA,IAAY;EACzC,mBAAiB;EACjB,WAAW,EAAG,GAAkB,CAAS;EAClC;EACP,mBAAmB;EACnB,cAAc,IAAe,IAAe,KAAA;EAC5C,qBACC,IAAe,KAAA,IAAa,KAAuB,CAAC;YAGpD,EAAQ,KAAK,GAAQ,MACrB,kBAAC,GAAD;GAEC,IAAI,EAAO,GAAQ,CAAK;GACxB,SAAQ;GACR,MAAK;aAEJ,EAAO;EACH,GANA,EAAO,GAAQ,CAAK,CAMpB,CACN;CACiB,CAAA;AAErB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
//#region src/components/Text/Text.css.ts
|
|
4
4
|
var t = e({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","names":[],"sources":["../../../src/components/Text/Text.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, Ref } from \"react\";\nimport type { TextVariant, TextWeight } from \"../../styles/typography.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { textRoot } from \"./Text.css.js\";\n\nexport interface TextProps extends HTMLAttributes<HTMLElement> {\n\t/**\n\t * Which semantic type tier to render at. Mirrors the Figma variable names.\n\t */\n\tvariant?: TextVariant;\n\tweight?: TextWeight;\n\t/**\n\t * The element to render. Defaults to `<span>`.\n\t *\n\t * Not for headings: a heading takes its level from its role, so compose RAC's\n\t * `Heading` there instead, as `Dialog.Title` does.\n\t */\n\tas?: keyof HTMLElementTagNameMap;\n\tref?: Ref<HTMLElement>;\n}\n\n/**\n * Text at one of the four semantic type tiers.\n *\n * Tier and weight are independent axes because they are independent in\n * practice: `body` ships at `regular` on seven components and `medium` on\n * seven others.\n *\n * Use this for a piece of text that owns its own element. A component whose\n * type sits on its own root — a `<button>`, a `<label>`, a toast — spreads\n * `typography()` into that root's class instead, rather than nesting a `Text`\n * inside itself.\n */\nexport function Text({\n\tvariant = \"body\",\n\tweight = \"regular\",\n\tclassName,\n\tas: Element = \"span\",\n\t...rest\n}: TextProps) {\n\tconst Component = Element as ElementType;\n\treturn (\n\t\t<Component\n\t\t\t{...rest}\n\t\t\tclassName={cx(textRoot({ variant, weight }), className)}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAiCA,SAAgB,EAAK,EACpB,aAAU,QACV,YAAS,WACT,cACA,IAAI,IAAU,QACd,GAAG,KACU;
|
|
1
|
+
{"version":3,"file":"Text.js","names":[],"sources":["../../../src/components/Text/Text.tsx"],"sourcesContent":["import type { ElementType, HTMLAttributes, Ref } from \"react\";\nimport type { TextVariant, TextWeight } from \"../../styles/typography.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { textRoot } from \"./Text.css.js\";\n\nexport interface TextProps extends HTMLAttributes<HTMLElement> {\n\t/**\n\t * Which semantic type tier to render at. Mirrors the Figma variable names.\n\t */\n\tvariant?: TextVariant;\n\tweight?: TextWeight;\n\t/**\n\t * The element to render. Defaults to `<span>`.\n\t *\n\t * Not for headings: a heading takes its level from its role, so compose RAC's\n\t * `Heading` there instead, as `Dialog.Title` does.\n\t */\n\tas?: keyof HTMLElementTagNameMap;\n\tref?: Ref<HTMLElement>;\n}\n\n/**\n * Text at one of the four semantic type tiers.\n *\n * Tier and weight are independent axes because they are independent in\n * practice: `body` ships at `regular` on seven components and `medium` on\n * seven others.\n *\n * Use this for a piece of text that owns its own element. A component whose\n * type sits on its own root — a `<button>`, a `<label>`, a toast — spreads\n * `typography()` into that root's class instead, rather than nesting a `Text`\n * inside itself.\n */\nexport function Text({\n\tvariant = \"body\",\n\tweight = \"regular\",\n\tclassName,\n\tas: Element = \"span\",\n\t...rest\n}: TextProps) {\n\tconst Component = Element as ElementType;\n\treturn (\n\t\t<Component\n\t\t\t{...rest}\n\t\t\tclassName={cx(textRoot({ variant, weight }), className)}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAiCA,SAAgB,EAAK,EACpB,aAAU,QACV,YAAS,WACT,cACA,IAAI,IAAU,QACd,GAAG,KACU;CAEb,OACC,kBAAC,GAAD;EACC,GAAI;EACJ,WAAW,EAAG,EAAS;GAAE;GAAS;EAAO,CAAC,GAAG,CAAS;CACtD,CAAA;AAEH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThinkingShimmer.js","names":[],"sources":["../../../src/components/ThinkingShimmer/ThinkingShimmer.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { dot, ellipsis, root, visuallyHidden } from \"./ThinkingShimmer.css.js\";\n\nexport interface ThinkingShimmerProps\n\textends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n\t/** Visible and announced label. Trailing dots are normalized before the animated ellipsis is appended. */\n\tlabel?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLSpanElement>;\n}\n\n/**\n * AI thinking indicator — a label with a trailing ellipsis, shown while the AI\n * agent is generating a response. A single shimmer band sweeps continuously\n * through the whole label (word and dots). Render it as a transient status line in\n * the message list while the assistant is streaming (or before the first token),\n * and remove it once content arrives. Use only for AI generation, not for a human\n * agent typing.\n *\n * Exposed as a polite live region. Two distinct a11y paths carry the same\n * `announced` string, which defaults to `label`: `aria-label` gives the region\n * its accessible name (`role=\"status\"` is not name-from-content, so descendant\n * text alone yields no name), and a visually-hidden copy of the text drives the\n * on-appearance announcement (live regions announce rendered text, not\n * `aria-label`). Both are needed — dropping either loses the name or the\n * announcement. The visible word (which strips trailing dots before rendering\n * the animated ellipsis) and dots are hidden from assistive tech. Honors reduced\n * motion by holding the shimmer static at a flat resting color.\n *\n * Reliable on-appearance announcement additionally depends on the consuming\n * surface keeping a persistent live region present before this mounts (the app's\n * MessageList/MessageAnnouncer already do); validate with a real screen reader\n * when a surface adopts this component.\n *\n * A surface that already wraps this in its own live region should pass\n * `aria-live=\"off\"`: two nested regions announce the same text twice, in an order\n * neither controls.\n */\nexport function ThinkingShimmer({\n\tlabel = \"Thinking\",\n\tclassName,\n\t\"aria-label\": ariaLabel,\n\t\"aria-live\": ariaLive = \"polite\",\n\t...rest\n}: ThinkingShimmerProps) {\n\tconst visibleLabel = stripTrailingEllipsis(label);\n\tconst announced = ariaLabel ?? label;\n\treturn (\n\t\t<span\n\t\t\t{...rest}\n\t\t\trole=\"status\"\n\t\t\taria-live={ariaLive}\n\t\t\taria-label={announced}\n\t\t\tclassName={cx(root, className)}\n\t\t>\n\t\t\t<span className={visuallyHidden}>{announced}</span>\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t{visibleLabel}\n\t\t\t\t<span className={ellipsis}>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</span>\n\t);\n}\n\nfunction stripTrailingEllipsis(label: string): string {\n\treturn label.replace(/[\\s.…]+$/, \"\");\n}\n"],"mappings":";;;;AAwCA,SAAgB,EAAgB,EAC/B,WAAQ,YACR,cACA,cAAc,GACd,aAAa,IAAW,UACxB,GAAG,KACqB;CACxB,IAAM,IAAe,EAAsB,
|
|
1
|
+
{"version":3,"file":"ThinkingShimmer.js","names":[],"sources":["../../../src/components/ThinkingShimmer/ThinkingShimmer.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { dot, ellipsis, root, visuallyHidden } from \"./ThinkingShimmer.css.js\";\n\nexport interface ThinkingShimmerProps\n\textends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n\t/** Visible and announced label. Trailing dots are normalized before the animated ellipsis is appended. */\n\tlabel?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLSpanElement>;\n}\n\n/**\n * AI thinking indicator — a label with a trailing ellipsis, shown while the AI\n * agent is generating a response. A single shimmer band sweeps continuously\n * through the whole label (word and dots). Render it as a transient status line in\n * the message list while the assistant is streaming (or before the first token),\n * and remove it once content arrives. Use only for AI generation, not for a human\n * agent typing.\n *\n * Exposed as a polite live region. Two distinct a11y paths carry the same\n * `announced` string, which defaults to `label`: `aria-label` gives the region\n * its accessible name (`role=\"status\"` is not name-from-content, so descendant\n * text alone yields no name), and a visually-hidden copy of the text drives the\n * on-appearance announcement (live regions announce rendered text, not\n * `aria-label`). Both are needed — dropping either loses the name or the\n * announcement. The visible word (which strips trailing dots before rendering\n * the animated ellipsis) and dots are hidden from assistive tech. Honors reduced\n * motion by holding the shimmer static at a flat resting color.\n *\n * Reliable on-appearance announcement additionally depends on the consuming\n * surface keeping a persistent live region present before this mounts (the app's\n * MessageList/MessageAnnouncer already do); validate with a real screen reader\n * when a surface adopts this component.\n *\n * A surface that already wraps this in its own live region should pass\n * `aria-live=\"off\"`: two nested regions announce the same text twice, in an order\n * neither controls.\n */\nexport function ThinkingShimmer({\n\tlabel = \"Thinking\",\n\tclassName,\n\t\"aria-label\": ariaLabel,\n\t\"aria-live\": ariaLive = \"polite\",\n\t...rest\n}: ThinkingShimmerProps) {\n\tconst visibleLabel = stripTrailingEllipsis(label);\n\tconst announced = ariaLabel ?? label;\n\treturn (\n\t\t<span\n\t\t\t{...rest}\n\t\t\trole=\"status\"\n\t\t\taria-live={ariaLive}\n\t\t\taria-label={announced}\n\t\t\tclassName={cx(root, className)}\n\t\t>\n\t\t\t<span className={visuallyHidden}>{announced}</span>\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t{visibleLabel}\n\t\t\t\t<span className={ellipsis}>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t\t<span className={dot}>.</span>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</span>\n\t);\n}\n\nfunction stripTrailingEllipsis(label: string): string {\n\treturn label.replace(/[\\s.…]+$/, \"\");\n}\n"],"mappings":";;;;AAwCA,SAAgB,EAAgB,EAC/B,WAAQ,YACR,cACA,cAAc,GACd,aAAa,IAAW,UACxB,GAAG,KACqB;CACxB,IAAM,IAAe,EAAsB,CAAK,GAC1C,IAAY,KAAa;CAC/B,OACC,kBAAC,QAAD;EACC,GAAI;EACJ,MAAK;EACL,aAAW;EACX,cAAY;EACZ,WAAW,EAAG,GAAM,CAAS;YAL9B,CAOC,kBAAC,QAAD;GAAM,WAAW;aAAiB;EAAgB,CAAA,GAClD,kBAAC,QAAD;GAAM,eAAY;aAAlB,CACE,GACD,kBAAC,QAAD;IAAM,WAAW;cAAjB;KACC,kBAAC,QAAD;MAAM,WAAW;gBAAK;KAAO,CAAA;KAC7B,kBAAC,QAAD;MAAM,WAAW;gBAAK;KAAO,CAAA;KAC7B,kBAAC,QAAD;MAAM,WAAW;gBAAK;KAAO,CAAA;IACxB;KACD;IACD;;AAER;AAEA,SAAS,EAAsB,GAAuB;CACrD,OAAO,EAAM,QAAQ,YAAY,EAAE;AACpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
//#region src/components/Toast/Toast.css.ts
|
|
4
4
|
var t = "_16991601", n = e({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","names":[],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, ReactNode, Ref } from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { cx } from \"../../utils/cx.js\";\nimport {\n\tCheckmarkCircle,\n\tExclamationTriangle,\n\tXmark,\n\tXmarkCircle,\n} from \"../Icon/icons/index.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Spinner } from \"../Spinner/Spinner.js\";\nimport { toast, toastDismiss, toastIcon, toastMessage } from \"./Toast.css.js\";\n\nexport type ToastStatus =\n\t| \"success\"\n\t| \"warning\"\n\t| \"error\"\n\t| \"custom\"\n\t| \"loading\";\n\nconst STATUS_ICON = {\n\tsuccess: CheckmarkCircle,\n\twarning: ExclamationTriangle,\n\terror: XmarkCircle,\n} as const;\n\nexport interface ToastProps {\n\t/**\n\t * The outcome being reported — selects the leading glyph and its colour. Bind\n\t * it to the result of the action, not the UI. `custom` takes the glyph from\n\t * `icon`; `loading` shows a spinner and refuses a dismiss control.\n\t */\n\tstatus?: ToastStatus;\n\t/** The glyph for `status=\"custom\"`. Ignored for every other status. */\n\ticon?: ReactNode;\n\t/**\n\t * Renders a trailing dismiss button and runs this when the user presses it.\n\t * Ignored while `status=\"loading\"`, whose lifetime belongs to whatever raised\n\t * it rather than to the reader.\n\t */\n\tonDismiss?: (event: PressEvent) => void;\n\t/** Accessible name for the dismiss button. Localize it. */\n\tdismissLabel?: string;\n\t/**\n\t * Takes the press away while the card is on screen only to finish leaving.\n\t * WebKit added `inert` in 15.5, after the iOS 15.4 floor in\n\t * `messaging/vite.browser-targets.mjs`. At that floor, the container's `inert`\n\t * attribute leaves the button tabbable even though its press no longer acts\n\t * on anything. Disabling keeps the card's layout still through the travel,\n\t * which removing the button would not.\n\t */\n\tdismissDisabled?: boolean;\n\t/**\n\t * Attributes for the message element. A container that owns announcement\n\t * passes its live-region props through here, so the dismiss button stays\n\t * outside what gets announced.\n\t */\n\tmessageProps?: HTMLAttributes<HTMLElement>;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/** The message to display. Keep it to a single line. */\n\tchildren?: ReactNode;\n}\n\nfunction LeadingGlyph({\n\tstatus,\n\ticon,\n}: {\n\tstatus: ToastStatus;\n\ticon: ReactNode;\n}) {\n\tif (status === \"loading\") {\n\t\t// Spinner carries its own `role=\"status\" aria-label=\"Loading\"`, and the\n\t\t// container already puts a live region on the message. Two of them inside\n\t\t// one alertdialog announces \"Loading\" ahead of the message, so this one is\n\t\t// hidden — the copy is what the reader needs.\n\t\treturn (\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t<Spinner size=\"sm\" />\n\t\t\t</span>\n\t\t);\n\t}\n\tif (status === \"custom\") {\n\t\treturn icon;\n\t}\n\tconst StatusIcon = STATUS_ICON[status];\n\treturn <StatusIcon />;\n}\n\n/**\n * The floating surface for a transient event — a card that sits above the\n * transcript on a neutral background, rather than the tinted full-width strip\n * `Banner` paints for a lasting condition. The two differ on purpose:\n * a card reads as passing through, a strip as part of the page.\n *\n * Purely presentational, and carries no live region of its own, so it can sit\n * inside a container that owns the announcement. Rendering it standalone\n * announces nothing — reach for `ToastContainer`.\n */\nexport function Toast({\n\tstatus = \"success\",\n\ticon,\n\tonDismiss,\n\tdismissLabel = \"Dismiss notification\",\n\tdismissDisabled = false,\n\tmessageProps,\n\tclassName,\n\tchildren,\n\t...rest\n}: ToastProps) {\n\t// Loading owns its own lifetime, so it never offers a dismiss control even\n\t// when the consumer passes one.\n\tconst canDismiss = !!onDismiss && status !== \"loading\";\n\t// Decided before the element exists: an element is truthy even when the\n\t// component returns null, so testing the rendered glyph would leave an empty\n\t// slot — and its `gap-8` — indenting the message of an iconless `custom`.\n\tconst hasGlyph = status !== \"custom\" || !!icon;\n\n\treturn (\n\t\t<div {...rest} data-status={status} className={cx(toast, className)}>\n\t\t\t{hasGlyph ? (\n\t\t\t\t<span className={toastIcon({ status })}>\n\t\t\t\t\t<LeadingGlyph status={status} icon={icon} />\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t{/* A div, not a span: a container that owns announcement puts a live\n\t\t\t region here, and React Aria renders that region as a div. */}\n\t\t\t<div\n\t\t\t\t{...messageProps}\n\t\t\t\tclassName={cx(messageProps?.className, toastMessage)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t\t{canDismiss && (\n\t\t\t\t<IconButton\n\t\t\t\t\tlabel={dismissLabel}\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\tisDisabled={dismissDisabled}\n\t\t\t\t\tonPress={onDismiss}\n\t\t\t\t\tclassName={toastDismiss}\n\t\t\t\t>\n\t\t\t\t\t<Xmark />\n\t\t\t\t</IconButton>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAoBA,IAAM,IAAc;CACnB,SAAS;CACT,SAAS;CACT,OAAO;
|
|
1
|
+
{"version":3,"file":"Toast.js","names":[],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, ReactNode, Ref } from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { cx } from \"../../utils/cx.js\";\nimport {\n\tCheckmarkCircle,\n\tExclamationTriangle,\n\tXmark,\n\tXmarkCircle,\n} from \"../Icon/icons/index.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Spinner } from \"../Spinner/Spinner.js\";\nimport { toast, toastDismiss, toastIcon, toastMessage } from \"./Toast.css.js\";\n\nexport type ToastStatus =\n\t| \"success\"\n\t| \"warning\"\n\t| \"error\"\n\t| \"custom\"\n\t| \"loading\";\n\nconst STATUS_ICON = {\n\tsuccess: CheckmarkCircle,\n\twarning: ExclamationTriangle,\n\terror: XmarkCircle,\n} as const;\n\nexport interface ToastProps {\n\t/**\n\t * The outcome being reported — selects the leading glyph and its colour. Bind\n\t * it to the result of the action, not the UI. `custom` takes the glyph from\n\t * `icon`; `loading` shows a spinner and refuses a dismiss control.\n\t */\n\tstatus?: ToastStatus;\n\t/** The glyph for `status=\"custom\"`. Ignored for every other status. */\n\ticon?: ReactNode;\n\t/**\n\t * Renders a trailing dismiss button and runs this when the user presses it.\n\t * Ignored while `status=\"loading\"`, whose lifetime belongs to whatever raised\n\t * it rather than to the reader.\n\t */\n\tonDismiss?: (event: PressEvent) => void;\n\t/** Accessible name for the dismiss button. Localize it. */\n\tdismissLabel?: string;\n\t/**\n\t * Takes the press away while the card is on screen only to finish leaving.\n\t * WebKit added `inert` in 15.5, after the iOS 15.4 floor in\n\t * `messaging/vite.browser-targets.mjs`. At that floor, the container's `inert`\n\t * attribute leaves the button tabbable even though its press no longer acts\n\t * on anything. Disabling keeps the card's layout still through the travel,\n\t * which removing the button would not.\n\t */\n\tdismissDisabled?: boolean;\n\t/**\n\t * Attributes for the message element. A container that owns announcement\n\t * passes its live-region props through here, so the dismiss button stays\n\t * outside what gets announced.\n\t */\n\tmessageProps?: HTMLAttributes<HTMLElement>;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/** The message to display. Keep it to a single line. */\n\tchildren?: ReactNode;\n}\n\nfunction LeadingGlyph({\n\tstatus,\n\ticon,\n}: {\n\tstatus: ToastStatus;\n\ticon: ReactNode;\n}) {\n\tif (status === \"loading\") {\n\t\t// Spinner carries its own `role=\"status\" aria-label=\"Loading\"`, and the\n\t\t// container already puts a live region on the message. Two of them inside\n\t\t// one alertdialog announces \"Loading\" ahead of the message, so this one is\n\t\t// hidden — the copy is what the reader needs.\n\t\treturn (\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t<Spinner size=\"sm\" />\n\t\t\t</span>\n\t\t);\n\t}\n\tif (status === \"custom\") {\n\t\treturn icon;\n\t}\n\tconst StatusIcon = STATUS_ICON[status];\n\treturn <StatusIcon />;\n}\n\n/**\n * The floating surface for a transient event — a card that sits above the\n * transcript on a neutral background, rather than the tinted full-width strip\n * `Banner` paints for a lasting condition. The two differ on purpose:\n * a card reads as passing through, a strip as part of the page.\n *\n * Purely presentational, and carries no live region of its own, so it can sit\n * inside a container that owns the announcement. Rendering it standalone\n * announces nothing — reach for `ToastContainer`.\n */\nexport function Toast({\n\tstatus = \"success\",\n\ticon,\n\tonDismiss,\n\tdismissLabel = \"Dismiss notification\",\n\tdismissDisabled = false,\n\tmessageProps,\n\tclassName,\n\tchildren,\n\t...rest\n}: ToastProps) {\n\t// Loading owns its own lifetime, so it never offers a dismiss control even\n\t// when the consumer passes one.\n\tconst canDismiss = !!onDismiss && status !== \"loading\";\n\t// Decided before the element exists: an element is truthy even when the\n\t// component returns null, so testing the rendered glyph would leave an empty\n\t// slot — and its `gap-8` — indenting the message of an iconless `custom`.\n\tconst hasGlyph = status !== \"custom\" || !!icon;\n\n\treturn (\n\t\t<div {...rest} data-status={status} className={cx(toast, className)}>\n\t\t\t{hasGlyph ? (\n\t\t\t\t<span className={toastIcon({ status })}>\n\t\t\t\t\t<LeadingGlyph status={status} icon={icon} />\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t{/* A div, not a span: a container that owns announcement puts a live\n\t\t\t region here, and React Aria renders that region as a div. */}\n\t\t\t<div\n\t\t\t\t{...messageProps}\n\t\t\t\tclassName={cx(messageProps?.className, toastMessage)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t\t{canDismiss && (\n\t\t\t\t<IconButton\n\t\t\t\t\tlabel={dismissLabel}\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\tisDisabled={dismissDisabled}\n\t\t\t\t\tonPress={onDismiss}\n\t\t\t\t\tclassName={toastDismiss}\n\t\t\t\t>\n\t\t\t\t\t<Xmark />\n\t\t\t\t</IconButton>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAoBA,IAAM,IAAc;CACnB,SAAS;CACT,SAAS;CACT,OAAO;AACR;AAyCA,SAAS,EAAa,EACrB,WACA,WAIE;CACF,IAAI,MAAW,WAKd,OACC,kBAAC,QAAD;EAAM,eAAY;YACjB,kBAAC,GAAD,EAAS,MAAK,KAAM,CAAA;CACf,CAAA;CAGR,IAAI,MAAW,UACd,OAAO;CAER,IAAM,IAAa,EAAY;CAC/B,OAAO,kBAAC,GAAD,CAAa,CAAA;AACrB;AAYA,SAAgB,EAAM,EACrB,YAAS,WACT,SACA,cACA,kBAAe,wBACf,qBAAkB,IAClB,iBACA,cACA,aACA,GAAG,KACW;CAGd,IAAM,IAAa,CAAC,CAAC,KAAa,MAAW,WAIvC,IAAW,MAAW,YAAY,CAAC,CAAC;CAE1C,OACC,kBAAC,OAAD;EAAK,GAAI;EAAM,eAAa;EAAQ,WAAW,EAAG,GAAO,CAAS;YAAlE;GACE,IACA,kBAAC,QAAD;IAAM,WAAW,EAAU,EAAE,UAAO,CAAC;cACpC,kBAAC,GAAD;KAAsB;KAAc;IAAO,CAAA;GACtC,CAAA,IACH;GAGJ,kBAAC,OAAD;IACC,GAAI;IACJ,WAAW,EAAG,GAAc,WAAW,CAAY;IAElD;GACG,CAAA;GACJ,KACA,kBAAC,GAAD;IACC,OAAO;IACP,SAAQ;IACR,MAAK;IACL,YAAY;IACZ,SAAS;IACT,WAAA;cAEA,kBAAC,GAAD,CAAQ,CAAA;GACG,CAAA;EAET;;AAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastContainer.js","names":[],"sources":["../../../src/components/Toast/ToastContainer.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { UNSAFE_PortalProvider, useFocusVisible } from \"react-aria\";\nimport {\n\tButtonContext,\n\tTextContext,\n\tUNSTABLE_Toast,\n\tUNSTABLE_ToastList,\n\tUNSTABLE_ToastRegion,\n\tuseSlottedContext,\n} from \"react-aria-components\";\nimport type { QueuedToast, ToastQueue } from \"react-stately\";\nimport { useHasOpenOverlay } from \"../../hooks/overlayRegistry.js\";\nimport { useEnterAnimation, useExitAnimation } from \"../../utils/animation.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toastAnchor, toastCard, toastList, toastRegion } from \"./Toast.css.js\";\nimport { Toast } from \"./Toast.js\";\nimport type { ToastItem } from \"./ToastItem.js\";\n\nexport interface ToastContainerProps {\n\t/** The queue to display. Create one per surface with `new ToastQueue()`. */\n\tqueue: ToastQueue<ToastItem>;\n\t/**\n\t * Keys of the toasts that are leaving. Keep each one on the queue until\n\t * `onExited` reports it, or it unmounts part-way through its travel.\n\t */\n\texiting: ReadonlySet<string>;\n\t/** Runs when a leaving toast finishes its travel and can be closed. */\n\tonExited: (key: string) => void;\n\t/** Runs when the reader presses a toast's dismiss button. */\n\tonDismiss: (key: string) => void;\n\t/**\n\t * Overrides the region's accessible name. Leave it unset: the default is\n\t * already localized and counts the toasts on show (\"2 notifications.\"), which\n\t * is what a screen-reader user hears on navigating here with F6.\n\t */\n\t\"aria-label\"?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/** Attaches to the always-mounted anchor, not the region. */\n\tref?: Ref<HTMLDivElement>;\n}\n\ninterface ToastCardProps {\n\ttoast: QueuedToast<ToastItem>;\n\tisExiting: boolean;\n\tonExited: (key: string) => void;\n\tonDismiss: (key: string) => void;\n}\n\n/**\n * The card's own dismiss control, named from the one React Aria would have\n * rendered.\n *\n * React Aria hands its close button down through `ButtonContext` under a `close`\n * slot, carrying both the localized name and a press handler that closes the\n * toast outright. `mergeProps` chains `on*` handlers rather than replacing them,\n * so a React Aria button given the container's handler would run both and take\n * the card off the queue before it could travel. Taking the name alone leaves the\n * lifetime with the caller.\n */\nfunction ToastDismiss({\n\tstatus,\n\ticon,\n\tmessage,\n\tisExiting,\n\tonPress,\n}: {\n\tstatus: NonNullable<ToastItem[\"status\"]>;\n\ticon: ToastItem[\"icon\"];\n\tmessage: ToastItem[\"message\"];\n\tisExiting: boolean;\n\tonPress: (event: PressEvent) => void;\n}) {\n\tconst closeButton = useSlottedContext(ButtonContext, \"close\");\n\t// React Aria names the card through `aria-labelledby`, pointing at the id it\n\t// hands down under the `title` slot. Nothing here renders its `Text`, so the\n\t// message has to carry that id or the card has no accessible name at all.\n\tconst title = useSlottedContext(TextContext, \"title\");\n\t// React Aria hides its own content element on the first render and reveals it\n\t// on the next, which is what makes NVDA announce a toast that mounts with its\n\t// text already in place. Those props reach that element through a context the\n\t// package does not export, so the reveal is repeated here.\n\tconst [isRevealed, setIsRevealed] = useState(false);\n\tuseLayoutEffect(() => setIsRevealed(true), []);\n\treturn (\n\t\t<Toast\n\t\t\tstatus={status}\n\t\t\ticon={icon}\n\t\t\tonDismiss={onPress}\n\t\t\t// The card carries `inert` by now, but WebKit added `inert` in 15.5,\n\t\t\t// after the iOS 15.4 floor in `messaging/vite.browser-targets.mjs`. At\n\t\t\t// that floor the button stays tabbable and offers a press that no longer\n\t\t\t// acts on anything, so it has to be disabled in its own right.\n\t\t\tdismissDisabled={isExiting}\n\t\t\tdismissLabel={closeButton?.[\"aria-label\"]}\n\t\t\t// The live region rides the message box itself. React Aria's own\n\t\t\t// `ToastContent` would need `display: contents` to stay out of the card's\n\t\t\t// row, and WebKit drops a box-less element from the accessibility tree\n\t\t\t// until 16, below the floor above, so the announcement would never reach\n\t\t\t// the reader there.\n\t\t\tmessageProps={{\n\t\t\t\tid: title && \"id\" in title ? title.id : undefined,\n\t\t\t\t// React Aria hardcodes `role=\"alert\"` for every toast, which interrupts\n\t\t\t\t// the reader whatever the outcome. The queue is one shared surface, so\n\t\t\t\t// urgency is chosen per card: a failure interrupts, anything else waits\n\t\t\t\t// its turn.\n\t\t\t\trole: status === \"error\" ? \"alert\" : \"status\",\n\t\t\t\t\"aria-live\": status === \"error\" ? \"assertive\" : \"polite\",\n\t\t\t\t\"aria-atomic\": \"true\",\n\t\t\t\t\"aria-hidden\": isRevealed ? undefined : \"true\",\n\t\t\t}}\n\t\t>\n\t\t\t{message}\n\t\t</Toast>\n\t);\n}\n\n/**\n * Where focus goes when the card under it leaves: the next card down the stack,\n * then the one above it, then the region itself. Landing on the region keeps\n * focus inside it, so React Aria still holds the element the reader came from and\n * restores it once the last card has gone.\n */\nfunction nextFocusTarget(element: HTMLElement): HTMLElement | null {\n\tconst region = element.closest<HTMLElement>('[role=\"region\"]');\n\t// React Aria wraps each card in a list item of its own, so the cards are read\n\t// off the region rather than from the element's own parent.\n\tconst cards = [\n\t\t...(region?.querySelectorAll<HTMLElement>(`.${toastCard}`) ?? []),\n\t];\n\tconst index = cards.indexOf(element);\n\tif (index === -1) {\n\t\treturn region;\n\t}\n\tconst settled = (card: HTMLElement) => !card.hasAttribute(\"data-exiting\");\n\t// `toastList` is `column-reverse`, so a higher DOM index sits visually above\n\t// and a lower one below. Take the card below first, nearest first, then walk\n\t// up, so focus lands on the card that rises into the freed row.\n\treturn (\n\t\tcards.slice(0, index).reverse().find(settled) ??\n\t\tcards.slice(index + 1).find(settled) ??\n\t\tregion\n\t);\n}\n\nfunction ToastCard({ toast, isExiting, onExited, onDismiss }: ToastCardProps) {\n\tconst ref = useRef<HTMLDivElement>(null);\n\t// The card rises in from `[data-entering]` and falls back out to\n\t// `[data-exiting]`, both off-screen, with a transition between. A transition\n\t// resumes from the current computed value, so a card dismissed mid-entry\n\t// reverses from wherever it stands. `useExitAnimation` and `useEnterAnimation`\n\t// watch the same transition, the way `BannerContainerSlide` does.\n\tconst isEntering = useEnterAnimation(ref);\n\tconst isLeaving = useExitAnimation(ref, !isExiting);\n\tconst { isFocusVisible } = useFocusVisible();\n\n\tuseEffect(() => {\n\t\tif (isExiting && !isLeaving) {\n\t\t\tonExited(toast.key);\n\t\t}\n\t}, [isExiting, isLeaving, onExited, toast.key]);\n\n\t// `inert` below drops the focus it holds to the document body. React Aria moves\n\t// focus for a toast that leaves the queue, and the card stays on the queue until\n\t// its travel is over, so the reader is handed on from here instead. It runs\n\t// before the effect below, which is what leaves it a card to read focus off.\n\t//\n\t// Only for a reader working the keyboard, though. A dismiss button focuses\n\t// itself under a mouse press in Chrome, so handing that on would park an\n\t// invisible focus on the card left standing, and a consumer that reads focus as\n\t// the reader asking for more time would hold its countdown there for as long as\n\t// the reader left the page alone.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element || !isFocusVisible) {\n\t\t\treturn;\n\t\t}\n\t\tif (element.contains(document.activeElement)) {\n\t\t\tnextFocusTarget(element)?.focus();\n\t\t}\n\t}, [isExiting, isFocusVisible]);\n\n\t// The caller has already let the card go, so it is on screen only to finish its\n\t// travel. `inert` takes it out of the accessibility tree, out of the tab order\n\t// and away from the pointer in one attribute. WebKit added `inert` in 15.5, and\n\t// the floor in `messaging/vite.browser-targets.mjs` is 15.4, so `role` and\n\t// `tabIndex` come off the element as well. React Aria pins both through props,\n\t// and a card never comes back from leaving, so nothing puts them back.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element) {\n\t\t\treturn;\n\t\t}\n\t\telement.setAttribute(\"inert\", \"\");\n\t\t// At the 15.4 floor `inert` does nothing, so the card would keep announcing\n\t\t// and stay in the reader's tree for the whole of its travel.\n\t\telement.setAttribute(\"aria-hidden\", \"true\");\n\t\telement.tabIndex = -1;\n\t\telement.removeAttribute(\"role\");\n\t}, [isExiting]);\n\n\tconst { status = \"success\", message, icon } = toast.content;\n\n\treturn (\n\t\t<UNSTABLE_Toast\n\t\t\ttoast={toast}\n\t\t\tref={ref}\n\t\t\tclassName={toastCard}\n\t\t\tdata-entering={isEntering || undefined}\n\t\t\tdata-exiting={isExiting || undefined}\n\t\t>\n\t\t\t<ToastDismiss\n\t\t\t\tstatus={status}\n\t\t\t\ticon={icon}\n\t\t\t\tmessage={message}\n\t\t\t\tisExiting={isExiting}\n\t\t\t\tonPress={(event) => {\n\t\t\t\t\t// The exit re-render disables this button, and a native disabled\n\t\t\t\t\t// button drops its focus to the document body in the same commit,\n\t\t\t\t\t// before the layout effect below can read focus off the card. Hand a\n\t\t\t\t\t// keyboard reader on here, while the button still holds focus.\n\t\t\t\t\tif (event.pointerType === \"keyboard\") {\n\t\t\t\t\t\tconst element = ref.current;\n\t\t\t\t\t\tif (element?.contains(document.activeElement)) {\n\t\t\t\t\t\t\tnextFocusTarget(element)?.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tonDismiss(toast.key);\n\t\t\t\t}}\n\t\t\t/>\n\t\t</UNSTABLE_Toast>\n\t);\n}\n\n/**\n * Displays the toasts on a queue as a labelled landmark region.\n *\n * The container owns announcement, the card surface and the motion. It does not\n * own the clock: the caller decides which toasts exist, when each one leaves, and\n * what a dismiss press means. Mark a toast in `exiting` to start its travel, and\n * take it off the queue when `onExited` reports it.\n *\n * No region renders while the queue is empty, so it does not sit in the\n * accessibility tree between notifications. The anchor it renders into stays\n * mounted regardless, carrying `data-react-aria-top-layer`: React Aria reads that\n * attribute to decide what an open overlay hides, what a press outside an overlay\n * counts as, and what a focus scope lets go. An anchor that came and went with the\n * toasts would leave the consumer's chrome hidden, and a toast raised afterwards\n * would mount inside that hidden subtree and never be announced.\n *\n * That exemption is why no region renders while a modal overlay is open. The\n * region is anchored in the consumer's chrome, which the overlay paints over and\n * seals off from the pointer, so a toast there would be announced and F6-reachable\n * with a dismiss control nobody could press.\n */\nexport function ToastContainer({\n\tqueue,\n\texiting,\n\tonExited,\n\tonDismiss,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n}: ToastContainerProps) {\n\tconst [anchor, setAnchor] = useState<HTMLDivElement | null>(null);\n\tconst hasOpenOverlay = useHasOpenOverlay();\n\n\tconst attachAnchor = useCallback(\n\t\t(node: HTMLDivElement | null) => {\n\t\t\tsetAnchor(node);\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t},\n\t\t[ref],\n\t);\n\n\t// React Aria's region portals itself through whatever `UNSAFE_PortalProvider`\n\t// it finds, and a consumer that scopes one to its app root would take the\n\t// toasts out of this container entirely. Pointing a nested provider at the\n\t// anchor keeps them where the consumer placed them.\n\tconst getContainer = useCallback(() => anchor ?? document.body, [anchor]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-react-aria-top-layer=\"true\"\n\t\t\tref={attachAnchor}\n\t\t\tclassName={cx(toastAnchor, className)}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{anchor && !hasOpenOverlay && (\n\t\t\t\t<UNSAFE_PortalProvider getContainer={getContainer}>\n\t\t\t\t\t<UNSTABLE_ToastRegion\n\t\t\t\t\t\tqueue={queue}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\tclassName={toastRegion}\n\t\t\t\t\t>\n\t\t\t\t\t\t<UNSTABLE_ToastList<ToastItem> className={toastList}>\n\t\t\t\t\t\t\t{({ toast }) => (\n\t\t\t\t\t\t\t\t<ToastCard\n\t\t\t\t\t\t\t\t\ttoast={toast}\n\t\t\t\t\t\t\t\t\tisExiting={exiting.has(toast.key)}\n\t\t\t\t\t\t\t\t\tonExited={onExited}\n\t\t\t\t\t\t\t\t\tonDismiss={onDismiss}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</UNSTABLE_ToastList>\n\t\t\t\t\t</UNSTABLE_ToastRegion>\n\t\t\t\t</UNSAFE_PortalProvider>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAoEA,SAAS,EAAa,EACrB,WACA,SACA,YACA,cACA,cAOE;CACF,IAAM,IAAc,EAAkB,GAAe,QAAQ,EAIvD,IAAQ,EAAkB,GAAa,QAAQ,EAK/C,CAAC,GAAY,KAAiB,EAAS,GAAM;AAEnD,QADA,QAAsB,EAAc,GAAK,EAAE,EAAE,CAAC,EAE7C,kBAAC,GAAD;EACS;EACF;EACN,WAAW;EAKX,iBAAiB;EACjB,cAAc,IAAc;EAM5B,cAAc;GACb,IAAI,KAAS,QAAQ,IAAQ,EAAM,KAAK,KAAA;GAKxC,MAAM,MAAW,UAAU,UAAU;GACrC,aAAa,MAAW,UAAU,cAAc;GAChD,eAAe;GACf,eAAe,IAAa,KAAA,IAAY;GACxC;YAEA;EACM,CAAA;;AAUV,SAAS,EAAgB,GAA0C;CAClE,IAAM,IAAS,EAAQ,QAAqB,oBAAkB,EAGxD,IAAQ,CACb,GAAI,GAAQ,iBAA8B,aAAgB,IAAI,EAAE,CAChE,EACK,IAAQ,EAAM,QAAQ,EAAQ;AACpC,KAAI,MAAU,GACb,QAAO;CAER,IAAM,KAAW,MAAsB,CAAC,EAAK,aAAa,eAAe;AAIzE,QACC,EAAM,MAAM,GAAG,EAAM,CAAC,SAAS,CAAC,KAAK,EAAQ,IAC7C,EAAM,MAAM,IAAQ,EAAE,CAAC,KAAK,EAAQ,IACpC;;AAIF,SAAS,EAAU,EAAE,UAAO,cAAW,aAAU,gBAA6B;CAC7E,IAAM,IAAM,EAAuB,KAAK,EAMlC,IAAa,EAAkB,EAAI,EACnC,IAAY,EAAiB,GAAK,CAAC,EAAU,EAC7C,EAAE,sBAAmB,GAAiB;AAkC5C,CAhCA,QAAgB;AACf,EAAI,KAAa,CAAC,KACjB,EAAS,EAAM,IAAI;IAElB;EAAC;EAAW;EAAW;EAAU,EAAM;EAAI,CAAC,EAY/C,QAAsB;EACrB,IAAM,IAAU,EAAI;AAChB,GAAC,KAAa,CAAC,KAAW,CAAC,KAG3B,EAAQ,SAAS,SAAS,cAAc,IAC3C,EAAgB,EAAQ,EAAE,OAAO;IAEhC,CAAC,GAAW,EAAe,CAAC,EAQ/B,QAAsB;EACrB,IAAM,IAAU,EAAI;AAChB,GAAC,KAAa,CAAC,MAGnB,EAAQ,aAAa,SAAS,GAAG,EAGjC,EAAQ,aAAa,eAAe,OAAO,EAC3C,EAAQ,WAAW,IACnB,EAAQ,gBAAgB,OAAO;IAC7B,CAAC,EAAU,CAAC;CAEf,IAAM,EAAE,YAAS,WAAW,YAAS,YAAS,EAAM;AAEpD,QACC,kBAAC,GAAD;EACQ;EACF;EACL,WAAW;EACX,iBAAe,KAAc,KAAA;EAC7B,gBAAc,KAAa,KAAA;YAE3B,kBAAC,GAAD;GACS;GACF;GACG;GACE;GACX,UAAU,MAAU;AAKnB,QAAI,EAAM,gBAAgB,YAAY;KACrC,IAAM,IAAU,EAAI;AACpB,KAAI,GAAS,SAAS,SAAS,cAAc,IAC5C,EAAgB,EAAQ,EAAE,OAAO;;AAGnC,MAAU,EAAM,IAAI;;GAEpB,CAAA;EACc,CAAA;;AAyBnB,SAAgB,EAAe,EAC9B,UACA,YACA,aACA,cACA,cACA,UACA,QACA,cAAc,KACS;CACvB,IAAM,CAAC,GAAQ,KAAa,EAAgC,KAAK,EAC3D,IAAiB,GAAmB,EAEpC,IAAe,GACnB,MAAgC;AAEhC,EADA,EAAU,EAAK,EACX,OAAO,KAAQ,aAClB,EAAI,EAAK,GACC,MACV,EAAI,UAAU;IAGhB,CAAC,EAAI,CACL,EAMK,IAAe,QAAkB,KAAU,SAAS,MAAM,CAAC,EAAO,CAAC;AAEzE,QACC,kBAAC,OAAD;EACC,6BAA0B;EAC1B,KAAK;EACL,WAAW,EAAG,GAAa,EAAU;EAC9B;YAEN,KAAU,CAAC,KACX,kBAAC,GAAD;GAAqC;aACpC,kBAAC,GAAD;IACQ;IACP,cAAY;IACZ,WAAA;cAEA,kBAAC,GAAD;KAA+B,WAAA;gBAC5B,EAAE,eACH,kBAAC,GAAD;MACQ;MACP,WAAW,EAAQ,IAAI,EAAM,IAAI;MACvB;MACC;MACV,CAAA;KAEiB,CAAA;IACC,CAAA;GACA,CAAA;EAEpB,CAAA"}
|
|
1
|
+
{"version":3,"file":"ToastContainer.js","names":[],"sources":["../../../src/components/Toast/ToastContainer.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { UNSAFE_PortalProvider, useFocusVisible } from \"react-aria\";\nimport {\n\tButtonContext,\n\tTextContext,\n\tUNSTABLE_Toast,\n\tUNSTABLE_ToastList,\n\tUNSTABLE_ToastRegion,\n\tuseSlottedContext,\n} from \"react-aria-components\";\nimport type { QueuedToast, ToastQueue } from \"react-stately\";\nimport { useHasOpenOverlay } from \"../../hooks/overlayRegistry.js\";\nimport { useEnterAnimation, useExitAnimation } from \"../../utils/animation.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toastAnchor, toastCard, toastList, toastRegion } from \"./Toast.css.js\";\nimport { Toast } from \"./Toast.js\";\nimport type { ToastItem } from \"./ToastItem.js\";\n\nexport interface ToastContainerProps {\n\t/** The queue to display. Create one per surface with `new ToastQueue()`. */\n\tqueue: ToastQueue<ToastItem>;\n\t/**\n\t * Keys of the toasts that are leaving. Keep each one on the queue until\n\t * `onExited` reports it, or it unmounts part-way through its travel.\n\t */\n\texiting: ReadonlySet<string>;\n\t/** Runs when a leaving toast finishes its travel and can be closed. */\n\tonExited: (key: string) => void;\n\t/** Runs when the reader presses a toast's dismiss button. */\n\tonDismiss: (key: string) => void;\n\t/**\n\t * Overrides the region's accessible name. Leave it unset: the default is\n\t * already localized and counts the toasts on show (\"2 notifications.\"), which\n\t * is what a screen-reader user hears on navigating here with F6.\n\t */\n\t\"aria-label\"?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/** Attaches to the always-mounted anchor, not the region. */\n\tref?: Ref<HTMLDivElement>;\n}\n\ninterface ToastCardProps {\n\ttoast: QueuedToast<ToastItem>;\n\tisExiting: boolean;\n\tonExited: (key: string) => void;\n\tonDismiss: (key: string) => void;\n}\n\n/**\n * The card's own dismiss control, named from the one React Aria would have\n * rendered.\n *\n * React Aria hands its close button down through `ButtonContext` under a `close`\n * slot, carrying both the localized name and a press handler that closes the\n * toast outright. `mergeProps` chains `on*` handlers rather than replacing them,\n * so a React Aria button given the container's handler would run both and take\n * the card off the queue before it could travel. Taking the name alone leaves the\n * lifetime with the caller.\n */\nfunction ToastDismiss({\n\tstatus,\n\ticon,\n\tmessage,\n\tisExiting,\n\tonPress,\n}: {\n\tstatus: NonNullable<ToastItem[\"status\"]>;\n\ticon: ToastItem[\"icon\"];\n\tmessage: ToastItem[\"message\"];\n\tisExiting: boolean;\n\tonPress: (event: PressEvent) => void;\n}) {\n\tconst closeButton = useSlottedContext(ButtonContext, \"close\");\n\t// React Aria names the card through `aria-labelledby`, pointing at the id it\n\t// hands down under the `title` slot. Nothing here renders its `Text`, so the\n\t// message has to carry that id or the card has no accessible name at all.\n\tconst title = useSlottedContext(TextContext, \"title\");\n\t// React Aria hides its own content element on the first render and reveals it\n\t// on the next, which is what makes NVDA announce a toast that mounts with its\n\t// text already in place. Those props reach that element through a context the\n\t// package does not export, so the reveal is repeated here.\n\tconst [isRevealed, setIsRevealed] = useState(false);\n\tuseLayoutEffect(() => setIsRevealed(true), []);\n\treturn (\n\t\t<Toast\n\t\t\tstatus={status}\n\t\t\ticon={icon}\n\t\t\tonDismiss={onPress}\n\t\t\t// The card carries `inert` by now, but WebKit added `inert` in 15.5,\n\t\t\t// after the iOS 15.4 floor in `messaging/vite.browser-targets.mjs`. At\n\t\t\t// that floor the button stays tabbable and offers a press that no longer\n\t\t\t// acts on anything, so it has to be disabled in its own right.\n\t\t\tdismissDisabled={isExiting}\n\t\t\tdismissLabel={closeButton?.[\"aria-label\"]}\n\t\t\t// The live region rides the message box itself. React Aria's own\n\t\t\t// `ToastContent` would need `display: contents` to stay out of the card's\n\t\t\t// row, and WebKit drops a box-less element from the accessibility tree\n\t\t\t// until 16, below the floor above, so the announcement would never reach\n\t\t\t// the reader there.\n\t\t\tmessageProps={{\n\t\t\t\tid: title && \"id\" in title ? title.id : undefined,\n\t\t\t\t// React Aria hardcodes `role=\"alert\"` for every toast, which interrupts\n\t\t\t\t// the reader whatever the outcome. The queue is one shared surface, so\n\t\t\t\t// urgency is chosen per card: a failure interrupts, anything else waits\n\t\t\t\t// its turn.\n\t\t\t\trole: status === \"error\" ? \"alert\" : \"status\",\n\t\t\t\t\"aria-live\": status === \"error\" ? \"assertive\" : \"polite\",\n\t\t\t\t\"aria-atomic\": \"true\",\n\t\t\t\t\"aria-hidden\": isRevealed ? undefined : \"true\",\n\t\t\t}}\n\t\t>\n\t\t\t{message}\n\t\t</Toast>\n\t);\n}\n\n/**\n * Where focus goes when the card under it leaves: the next card down the stack,\n * then the one above it, then the region itself. Landing on the region keeps\n * focus inside it, so React Aria still holds the element the reader came from and\n * restores it once the last card has gone.\n */\nfunction nextFocusTarget(element: HTMLElement): HTMLElement | null {\n\tconst region = element.closest<HTMLElement>('[role=\"region\"]');\n\t// React Aria wraps each card in a list item of its own, so the cards are read\n\t// off the region rather than from the element's own parent.\n\tconst cards = [\n\t\t...(region?.querySelectorAll<HTMLElement>(`.${toastCard}`) ?? []),\n\t];\n\tconst index = cards.indexOf(element);\n\tif (index === -1) {\n\t\treturn region;\n\t}\n\tconst settled = (card: HTMLElement) => !card.hasAttribute(\"data-exiting\");\n\t// `toastList` is `column-reverse`, so a higher DOM index sits visually above\n\t// and a lower one below. Take the card below first, nearest first, then walk\n\t// up, so focus lands on the card that rises into the freed row.\n\treturn (\n\t\tcards.slice(0, index).reverse().find(settled) ??\n\t\tcards.slice(index + 1).find(settled) ??\n\t\tregion\n\t);\n}\n\nfunction ToastCard({ toast, isExiting, onExited, onDismiss }: ToastCardProps) {\n\tconst ref = useRef<HTMLDivElement>(null);\n\t// The card rises in from `[data-entering]` and falls back out to\n\t// `[data-exiting]`, both off-screen, with a transition between. A transition\n\t// resumes from the current computed value, so a card dismissed mid-entry\n\t// reverses from wherever it stands. `useExitAnimation` and `useEnterAnimation`\n\t// watch the same transition, the way `BannerContainerSlide` does.\n\tconst isEntering = useEnterAnimation(ref);\n\tconst isLeaving = useExitAnimation(ref, !isExiting);\n\tconst { isFocusVisible } = useFocusVisible();\n\n\tuseEffect(() => {\n\t\tif (isExiting && !isLeaving) {\n\t\t\tonExited(toast.key);\n\t\t}\n\t}, [isExiting, isLeaving, onExited, toast.key]);\n\n\t// `inert` below drops the focus it holds to the document body. React Aria moves\n\t// focus for a toast that leaves the queue, and the card stays on the queue until\n\t// its travel is over, so the reader is handed on from here instead. It runs\n\t// before the effect below, which is what leaves it a card to read focus off.\n\t//\n\t// Only for a reader working the keyboard, though. A dismiss button focuses\n\t// itself under a mouse press in Chrome, so handing that on would park an\n\t// invisible focus on the card left standing, and a consumer that reads focus as\n\t// the reader asking for more time would hold its countdown there for as long as\n\t// the reader left the page alone.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element || !isFocusVisible) {\n\t\t\treturn;\n\t\t}\n\t\tif (element.contains(document.activeElement)) {\n\t\t\tnextFocusTarget(element)?.focus();\n\t\t}\n\t}, [isExiting, isFocusVisible]);\n\n\t// The caller has already let the card go, so it is on screen only to finish its\n\t// travel. `inert` takes it out of the accessibility tree, out of the tab order\n\t// and away from the pointer in one attribute. WebKit added `inert` in 15.5, and\n\t// the floor in `messaging/vite.browser-targets.mjs` is 15.4, so `role` and\n\t// `tabIndex` come off the element as well. React Aria pins both through props,\n\t// and a card never comes back from leaving, so nothing puts them back.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element) {\n\t\t\treturn;\n\t\t}\n\t\telement.setAttribute(\"inert\", \"\");\n\t\t// At the 15.4 floor `inert` does nothing, so the card would keep announcing\n\t\t// and stay in the reader's tree for the whole of its travel.\n\t\telement.setAttribute(\"aria-hidden\", \"true\");\n\t\telement.tabIndex = -1;\n\t\telement.removeAttribute(\"role\");\n\t}, [isExiting]);\n\n\tconst { status = \"success\", message, icon } = toast.content;\n\n\treturn (\n\t\t<UNSTABLE_Toast\n\t\t\ttoast={toast}\n\t\t\tref={ref}\n\t\t\tclassName={toastCard}\n\t\t\tdata-entering={isEntering || undefined}\n\t\t\tdata-exiting={isExiting || undefined}\n\t\t>\n\t\t\t<ToastDismiss\n\t\t\t\tstatus={status}\n\t\t\t\ticon={icon}\n\t\t\t\tmessage={message}\n\t\t\t\tisExiting={isExiting}\n\t\t\t\tonPress={(event) => {\n\t\t\t\t\t// The exit re-render disables this button, and a native disabled\n\t\t\t\t\t// button drops its focus to the document body in the same commit,\n\t\t\t\t\t// before the layout effect below can read focus off the card. Hand a\n\t\t\t\t\t// keyboard reader on here, while the button still holds focus.\n\t\t\t\t\tif (event.pointerType === \"keyboard\") {\n\t\t\t\t\t\tconst element = ref.current;\n\t\t\t\t\t\tif (element?.contains(document.activeElement)) {\n\t\t\t\t\t\t\tnextFocusTarget(element)?.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tonDismiss(toast.key);\n\t\t\t\t}}\n\t\t\t/>\n\t\t</UNSTABLE_Toast>\n\t);\n}\n\n/**\n * Displays the toasts on a queue as a labelled landmark region.\n *\n * The container owns announcement, the card surface and the motion. It does not\n * own the clock: the caller decides which toasts exist, when each one leaves, and\n * what a dismiss press means. Mark a toast in `exiting` to start its travel, and\n * take it off the queue when `onExited` reports it.\n *\n * No region renders while the queue is empty, so it does not sit in the\n * accessibility tree between notifications. The anchor it renders into stays\n * mounted regardless, carrying `data-react-aria-top-layer`: React Aria reads that\n * attribute to decide what an open overlay hides, what a press outside an overlay\n * counts as, and what a focus scope lets go. An anchor that came and went with the\n * toasts would leave the consumer's chrome hidden, and a toast raised afterwards\n * would mount inside that hidden subtree and never be announced.\n *\n * That exemption is why no region renders while a modal overlay is open. The\n * region is anchored in the consumer's chrome, which the overlay paints over and\n * seals off from the pointer, so a toast there would be announced and F6-reachable\n * with a dismiss control nobody could press.\n */\nexport function ToastContainer({\n\tqueue,\n\texiting,\n\tonExited,\n\tonDismiss,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n}: ToastContainerProps) {\n\tconst [anchor, setAnchor] = useState<HTMLDivElement | null>(null);\n\tconst hasOpenOverlay = useHasOpenOverlay();\n\n\tconst attachAnchor = useCallback(\n\t\t(node: HTMLDivElement | null) => {\n\t\t\tsetAnchor(node);\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t},\n\t\t[ref],\n\t);\n\n\t// React Aria's region portals itself through whatever `UNSAFE_PortalProvider`\n\t// it finds, and a consumer that scopes one to its app root would take the\n\t// toasts out of this container entirely. Pointing a nested provider at the\n\t// anchor keeps them where the consumer placed them.\n\tconst getContainer = useCallback(() => anchor ?? document.body, [anchor]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-react-aria-top-layer=\"true\"\n\t\t\tref={attachAnchor}\n\t\t\tclassName={cx(toastAnchor, className)}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{anchor && !hasOpenOverlay && (\n\t\t\t\t<UNSAFE_PortalProvider getContainer={getContainer}>\n\t\t\t\t\t<UNSTABLE_ToastRegion\n\t\t\t\t\t\tqueue={queue}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\tclassName={toastRegion}\n\t\t\t\t\t>\n\t\t\t\t\t\t<UNSTABLE_ToastList<ToastItem> className={toastList}>\n\t\t\t\t\t\t\t{({ toast }) => (\n\t\t\t\t\t\t\t\t<ToastCard\n\t\t\t\t\t\t\t\t\ttoast={toast}\n\t\t\t\t\t\t\t\t\tisExiting={exiting.has(toast.key)}\n\t\t\t\t\t\t\t\t\tonExited={onExited}\n\t\t\t\t\t\t\t\t\tonDismiss={onDismiss}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</UNSTABLE_ToastList>\n\t\t\t\t\t</UNSTABLE_ToastRegion>\n\t\t\t\t</UNSAFE_PortalProvider>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAoEA,SAAS,EAAa,EACrB,WACA,SACA,YACA,cACA,cAOE;CACF,IAAM,IAAc,EAAkB,GAAe,OAAO,GAItD,IAAQ,EAAkB,GAAa,OAAO,GAK9C,CAAC,GAAY,KAAiB,EAAS,EAAK;CAElD,OADA,QAAsB,EAAc,EAAI,GAAG,CAAC,CAAC,GAE5C,kBAAC,GAAD;EACS;EACF;EACN,WAAW;EAKX,iBAAiB;EACjB,cAAc,IAAc;EAM5B,cAAc;GACb,IAAI,KAAS,QAAQ,IAAQ,EAAM,KAAK,KAAA;GAKxC,MAAM,MAAW,UAAU,UAAU;GACrC,aAAa,MAAW,UAAU,cAAc;GAChD,eAAe;GACf,eAAe,IAAa,KAAA,IAAY;EACzC;YAEC;CACK,CAAA;AAET;AAQA,SAAS,EAAgB,GAA0C;CAClE,IAAM,IAAS,EAAQ,QAAqB,mBAAiB,GAGvD,IAAQ,CACb,GAAI,GAAQ,iBAA8B,YAAe,KAAK,CAAC,CAChE,GACM,IAAQ,EAAM,QAAQ,CAAO;CACnC,IAAI,MAAU,IACb,OAAO;CAER,IAAM,KAAW,MAAsB,CAAC,EAAK,aAAa,cAAc;CAIxE,OACC,EAAM,MAAM,GAAG,CAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAO,KAC5C,EAAM,MAAM,IAAQ,CAAC,CAAC,CAAC,KAAK,CAAO,KACnC;AAEF;AAEA,SAAS,EAAU,EAAE,UAAO,cAAW,aAAU,gBAA6B;CAC7E,IAAM,IAAM,EAAuB,IAAI,GAMjC,IAAa,EAAkB,CAAG,GAClC,IAAY,EAAiB,GAAK,CAAC,CAAS,GAC5C,EAAE,sBAAmB,EAAgB;CAkC3C,AAhCA,QAAgB;EACf,AAAI,KAAa,CAAC,KACjB,EAAS,EAAM,GAAG;CAEpB,GAAG;EAAC;EAAW;EAAW;EAAU,EAAM;CAAG,CAAC,GAY9C,QAAsB;EACrB,IAAM,IAAU,EAAI;EAChB,CAAC,KAAa,CAAC,KAAW,CAAC,KAG3B,EAAQ,SAAS,SAAS,aAAa,KAC1C,EAAgB,CAAO,CAAC,EAAE,MAAM;CAElC,GAAG,CAAC,GAAW,CAAc,CAAC,GAQ9B,QAAsB;EACrB,IAAM,IAAU,EAAI;EAChB,CAAC,KAAa,CAAC,MAGnB,EAAQ,aAAa,SAAS,EAAE,GAGhC,EAAQ,aAAa,eAAe,MAAM,GAC1C,EAAQ,WAAW,IACnB,EAAQ,gBAAgB,MAAM;CAC/B,GAAG,CAAC,CAAS,CAAC;CAEd,IAAM,EAAE,YAAS,WAAW,YAAS,YAAS,EAAM;CAEpD,OACC,kBAAC,GAAD;EACQ;EACF;EACL,WAAW;EACX,iBAAe,KAAc,KAAA;EAC7B,gBAAc,KAAa,KAAA;YAE3B,kBAAC,GAAD;GACS;GACF;GACG;GACE;GACX,UAAU,MAAU;IAKnB,IAAI,EAAM,gBAAgB,YAAY;KACrC,IAAM,IAAU,EAAI;KACpB,AAAI,GAAS,SAAS,SAAS,aAAa,KAC3C,EAAgB,CAAO,CAAC,EAAE,MAAM;IAElC;IACA,EAAU,EAAM,GAAG;GACpB;EACA,CAAA;CACc,CAAA;AAElB;AAuBA,SAAgB,EAAe,EAC9B,UACA,YACA,aACA,cACA,cACA,UACA,QACA,cAAc,KACS;CACvB,IAAM,CAAC,GAAQ,KAAa,EAAgC,IAAI,GAC1D,IAAiB,EAAkB,GAEnC,IAAe,GACnB,MAAgC;EAEhC,AADA,EAAU,CAAI,GACV,OAAO,KAAQ,aAClB,EAAI,CAAI,IACE,MACV,EAAI,UAAU;CAEhB,GACA,CAAC,CAAG,CACL,GAMM,IAAe,QAAkB,KAAU,SAAS,MAAM,CAAC,CAAM,CAAC;CAExE,OACC,kBAAC,OAAD;EACC,6BAA0B;EAC1B,KAAK;EACL,WAAW,EAAG,GAAa,CAAS;EAC7B;YAEN,KAAU,CAAC,KACX,kBAAC,GAAD;GAAqC;aACpC,kBAAC,GAAD;IACQ;IACP,cAAY;IACZ,WAAA;cAEA,kBAAC,GAAD;KAA+B,WAAA;gBAC5B,EAAE,eACH,kBAAC,GAAD;MACQ;MACP,WAAW,EAAQ,IAAI,EAAM,GAAG;MACtB;MACC;KACX,CAAA;IAEiB,CAAA;GACC,CAAA;EACA,CAAA;CAEpB,CAAA;AAEP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./Toast.js";
|
|
2
|
-
import "./ToastContainer.js";
|
|
3
|
-
import { ToastQueue as
|
|
4
|
-
export { e as ToastQueue };
|
|
1
|
+
import { Toast as e } from "./Toast.js";
|
|
2
|
+
import { ToastContainer as t } from "./ToastContainer.js";
|
|
3
|
+
import { ToastQueue as n } from "react-stately";
|
|
4
|
+
export { e as Toast, t as ToastContainer, n as ToastQueue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.js","names":[],"sources":["../../../src/components/Toggle/Toggle.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { SwitchProps as AriaSwitchProps } from \"react-aria-components\";\nimport { Switch as AriaSwitch } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toggleRoot } from \"./Toggle.css.js\";\nimport { ToggleIndicator } from \"./ToggleIndicator.js\";\n\nexport interface ToggleProps\n\textends Omit<AriaSwitchProps, \"children\" | \"className\" | \"style\"> {\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLLabelElement>;\n}\n\n/**\n * A binary on/off switch that applies instantly (RAC `Switch`, `role=\"switch\"`).\n * On renders the success-green track with the thumb at the trailing edge; off\n * renders the neutral track with the thumb leading. Track-only — give it an\n * accessible name with `aria-label` / `aria-labelledby`.\n *\n * Value is `isSelected` / `defaultSelected` / `onChange`; disabled is `isDisabled`.\n * Interaction states (hover/focus/pressed) and RTL mirroring come from RAC `data-*`\n * and the ambient `dir` — not props.\n */\nexport function Toggle({ className, ...rest }: ToggleProps) {\n\treturn (\n\t\t<AriaSwitch {...rest} className={cx(toggleRoot, className)}>\n\t\t\t<ToggleIndicator />\n\t\t</AriaSwitch>\n\t);\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAO,EAAE,cAAW,GAAG,KAAqB;
|
|
1
|
+
{"version":3,"file":"Toggle.js","names":[],"sources":["../../../src/components/Toggle/Toggle.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { SwitchProps as AriaSwitchProps } from \"react-aria-components\";\nimport { Switch as AriaSwitch } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toggleRoot } from \"./Toggle.css.js\";\nimport { ToggleIndicator } from \"./ToggleIndicator.js\";\n\nexport interface ToggleProps\n\textends Omit<AriaSwitchProps, \"children\" | \"className\" | \"style\"> {\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLLabelElement>;\n}\n\n/**\n * A binary on/off switch that applies instantly (RAC `Switch`, `role=\"switch\"`).\n * On renders the success-green track with the thumb at the trailing edge; off\n * renders the neutral track with the thumb leading. Track-only — give it an\n * accessible name with `aria-label` / `aria-labelledby`.\n *\n * Value is `isSelected` / `defaultSelected` / `onChange`; disabled is `isDisabled`.\n * Interaction states (hover/focus/pressed) and RTL mirroring come from RAC `data-*`\n * and the ambient `dir` — not props.\n */\nexport function Toggle({ className, ...rest }: ToggleProps) {\n\treturn (\n\t\t<AriaSwitch {...rest} className={cx(toggleRoot, className)}>\n\t\t\t<ToggleIndicator />\n\t\t</AriaSwitch>\n\t);\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAO,EAAE,cAAW,GAAG,KAAqB;CAC3D,OACC,kBAAC,GAAD;EAAY,GAAI;EAAM,WAAW,EAAG,GAAY,CAAS;YACxD,kBAAC,GAAD,CAAkB,CAAA;CACP,CAAA;AAEd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleIndicator.js","names":[],"sources":["../../../src/components/Toggle/ToggleIndicator.tsx"],"sourcesContent":["import type { Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toggleThumb, toggleTrack } from \"./Toggle.css.js\";\n\nexport interface ToggleIndicatorProps {\n\t/**\n\t * Draw the track's own focus ring and state-layer veil. True for a standalone\n\t * `Toggle`, where the pill is the only affordance; false inside a row, which\n\t * draws those on the row itself — leaving it true there would paint both.\n\t */\n\thasStateLayer?: boolean;\n\tclassName?: string;\n\tref?: Ref<HTMLSpanElement>;\n}\n\n/**\n * The pill track and its thumb, with no control of its own.\n *\n * On/off and disabled state are read from whichever ancestor element carries React\n * Aria's `data-selected` / `data-disabled` — the RAC `Switch` label, or a\n * `MenuItem` row — so the same markup and the same styles serve both hosts and\n * cannot drift apart. It must stay a **direct** child of that element; the state\n * rules use a child selector so an unrelated selected ancestor can't reach in.\n */\nexport function ToggleIndicator({\n\thasStateLayer = true,\n\tclassName,\n\tref,\n}: ToggleIndicatorProps) {\n\treturn (\n\t\t<span\n\t\t\tref={ref}\n\t\t\tdata-slot=\"indicator\"\n\t\t\tdata-state-layer={hasStateLayer || undefined}\n\t\t\tclassName={cx(toggleTrack, className)}\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<span className={toggleThumb} />\n\t\t</span>\n\t);\n}\n"],"mappings":";;;;AAwBA,SAAgB,EAAgB,EAC/B,mBAAgB,IAChB,cACA,UACwB;
|
|
1
|
+
{"version":3,"file":"ToggleIndicator.js","names":[],"sources":["../../../src/components/Toggle/ToggleIndicator.tsx"],"sourcesContent":["import type { Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toggleThumb, toggleTrack } from \"./Toggle.css.js\";\n\nexport interface ToggleIndicatorProps {\n\t/**\n\t * Draw the track's own focus ring and state-layer veil. True for a standalone\n\t * `Toggle`, where the pill is the only affordance; false inside a row, which\n\t * draws those on the row itself — leaving it true there would paint both.\n\t */\n\thasStateLayer?: boolean;\n\tclassName?: string;\n\tref?: Ref<HTMLSpanElement>;\n}\n\n/**\n * The pill track and its thumb, with no control of its own.\n *\n * On/off and disabled state are read from whichever ancestor element carries React\n * Aria's `data-selected` / `data-disabled` — the RAC `Switch` label, or a\n * `MenuItem` row — so the same markup and the same styles serve both hosts and\n * cannot drift apart. It must stay a **direct** child of that element; the state\n * rules use a child selector so an unrelated selected ancestor can't reach in.\n */\nexport function ToggleIndicator({\n\thasStateLayer = true,\n\tclassName,\n\tref,\n}: ToggleIndicatorProps) {\n\treturn (\n\t\t<span\n\t\t\tref={ref}\n\t\t\tdata-slot=\"indicator\"\n\t\t\tdata-state-layer={hasStateLayer || undefined}\n\t\t\tclassName={cx(toggleTrack, className)}\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<span className={toggleThumb} />\n\t\t</span>\n\t);\n}\n"],"mappings":";;;;AAwBA,SAAgB,EAAgB,EAC/B,mBAAgB,IAChB,cACA,UACwB;CACxB,OACC,kBAAC,QAAD;EACM;EACL,aAAU;EACV,oBAAkB,KAAiB,KAAA;EACnC,WAAW,EAAG,GAAa,CAAS;EACpC,eAAY;YAEZ,kBAAC,QAAD,EAAM,WAAW,EAAc,CAAA;CAC1B,CAAA;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { useLocale } from \"react-aria\";\nimport type { TooltipProps as AriaTooltipProps } from \"react-aria-components\";\nimport {\n\tTooltip as AriaTooltip,\n\tOverlayArrow,\n\tTooltipTrigger,\n} from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { arrow, arrowSvg, tooltip } from \"./Tooltip.css.js\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps\n\textends Omit<\n\t\tAriaTooltipProps,\n\t\t\"children\" | \"className\" | \"style\" | \"placement\"\n\t> {\n\t/** Which side of the trigger the tooltip sits on. The arrow points back at the trigger. */\n\tplacement?: TooltipPlacement;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/** Tooltip text. */\n\tchildren: ReactNode;\n}\n\n/**\n * Inverse-surface tooltip with a directional arrow, revealed on hover/focus of\n * its trigger. Render inside `TooltipTrigger` next to the focusable trigger:\n * `<TooltipTrigger><Button>…</Button><Tooltip>Help</Tooltip></TooltipTrigger>`.\n */\nexport function Tooltip({\n\tplacement = \"top\",\n\toffset = 6,\n\tclassName,\n\tstyle,\n\tchildren,\n\t...rest\n}: TooltipProps) {\n\t// Stated, not inherited: this renders through a portal, so its direction must\n\t// not depend on where the portal lands. See the portalled-surface scenario\n\t// under the RTL requirement in openspec/specs/accessibility/spec.md.\n\tconst { direction } = useLocale();\n\n\treturn (\n\t\t<AriaTooltip\n\t\t\t{...rest}\n\t\t\tplacement={placement}\n\t\t\toffset={offset}\n\t\t\tclassName={cx(tooltip, className)}\n\t\t\tstyle={style}\n\t\t\tdir={direction}\n\t\t>\n\t\t\t<OverlayArrow className={arrow}>\n\t\t\t\t{/* Square box so RAC's arrow centering keeps the same footprint under\n\t\t\t\t the ±90° left/right rotations; the triangle sits in the top half. */}\n\t\t\t\t<svg\n\t\t\t\t\tclassName={arrowSvg}\n\t\t\t\t\twidth={12}\n\t\t\t\t\theight={12}\n\t\t\t\t\tviewBox=\"0 0 12 12\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<path d=\"M0 0 L6 6 L12 0 Z\" />\n\t\t\t\t</svg>\n\t\t\t</OverlayArrow>\n\t\t\t{children}\n\t\t</AriaTooltip>\n\t);\n}\n\nexport { TooltipTrigger };\n"],"mappings":";;;;;;AA+BA,SAAgB,EAAQ,EACvB,eAAY,OACZ,YAAS,GACT,cACA,UACA,aACA,GAAG,KACa;CAIhB,IAAM,EAAE,iBAAc,
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { useLocale } from \"react-aria\";\nimport type { TooltipProps as AriaTooltipProps } from \"react-aria-components\";\nimport {\n\tTooltip as AriaTooltip,\n\tOverlayArrow,\n\tTooltipTrigger,\n} from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { arrow, arrowSvg, tooltip } from \"./Tooltip.css.js\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps\n\textends Omit<\n\t\tAriaTooltipProps,\n\t\t\"children\" | \"className\" | \"style\" | \"placement\"\n\t> {\n\t/** Which side of the trigger the tooltip sits on. The arrow points back at the trigger. */\n\tplacement?: TooltipPlacement;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/** Tooltip text. */\n\tchildren: ReactNode;\n}\n\n/**\n * Inverse-surface tooltip with a directional arrow, revealed on hover/focus of\n * its trigger. Render inside `TooltipTrigger` next to the focusable trigger:\n * `<TooltipTrigger><Button>…</Button><Tooltip>Help</Tooltip></TooltipTrigger>`.\n */\nexport function Tooltip({\n\tplacement = \"top\",\n\toffset = 6,\n\tclassName,\n\tstyle,\n\tchildren,\n\t...rest\n}: TooltipProps) {\n\t// Stated, not inherited: this renders through a portal, so its direction must\n\t// not depend on where the portal lands. See the portalled-surface scenario\n\t// under the RTL requirement in openspec/specs/accessibility/spec.md.\n\tconst { direction } = useLocale();\n\n\treturn (\n\t\t<AriaTooltip\n\t\t\t{...rest}\n\t\t\tplacement={placement}\n\t\t\toffset={offset}\n\t\t\tclassName={cx(tooltip, className)}\n\t\t\tstyle={style}\n\t\t\tdir={direction}\n\t\t>\n\t\t\t<OverlayArrow className={arrow}>\n\t\t\t\t{/* Square box so RAC's arrow centering keeps the same footprint under\n\t\t\t\t the ±90° left/right rotations; the triangle sits in the top half. */}\n\t\t\t\t<svg\n\t\t\t\t\tclassName={arrowSvg}\n\t\t\t\t\twidth={12}\n\t\t\t\t\theight={12}\n\t\t\t\t\tviewBox=\"0 0 12 12\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<path d=\"M0 0 L6 6 L12 0 Z\" />\n\t\t\t\t</svg>\n\t\t\t</OverlayArrow>\n\t\t\t{children}\n\t\t</AriaTooltip>\n\t);\n}\n\nexport { TooltipTrigger };\n"],"mappings":";;;;;;AA+BA,SAAgB,EAAQ,EACvB,eAAY,OACZ,YAAS,GACT,cACA,UACA,aACA,GAAG,KACa;CAIhB,IAAM,EAAE,iBAAc,EAAU;CAEhC,OACC,kBAAC,GAAD;EACC,GAAI;EACO;EACH;EACR,WAAW,EAAG,GAAS,CAAS;EACzB;EACP,KAAK;YANN,CAQC,kBAAC,GAAD;GAAc,WAAW;aAGxB,kBAAC,OAAD;IACC,WAAW;IACX,OAAO;IACP,QAAQ;IACR,SAAQ;IACR,eAAY;cAEZ,kBAAC,QAAD,EAAM,GAAE,oBAAqB,CAAA;GACzB,CAAA;EACQ,CAAA,GACb,CACW;;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingIndicator.js","names":[],"sources":["../../../src/components/TypingIndicator/TypingIndicator.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { bubble, dot, visuallyHidden } from \"./TypingIndicator.css.js\";\n\nexport interface TypingIndicatorProps\n\textends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Human-agent typing indicator — an animated three-dot bubble shown while a live\n * agent is composing a reply. Render it as a transient status in the message list\n * driven by the agent's live typing/presence signal, and remove it when the\n * message arrives or typing stops.\n *\n * Use only for a human agent typing — not for AI generation (use the\n * `ThinkingShimmer` for that).\n *\n * Exposed as a polite live region. The dots are hidden from assistive tech and\n * the announced string is carried as visually-hidden text (live regions announce\n * rendered text, not `aria-label`); pass `aria-label` to override it. Reliable\n * on-appearance announcement additionally depends on the consuming surface\n * keeping a persistent live region present before this mounts; validate with a\n * real screen reader when a surface adopts this component.\n *\n * A surface that already wraps this in its own live region should pass\n * `aria-live=\"off\"`: two nested regions announce the same text twice, in an order\n * neither controls.\n */\nexport function TypingIndicator({\n\tclassName,\n\t\"aria-label\": ariaLabel = \"Agent is typing\",\n\t\"aria-live\": ariaLive = \"polite\",\n\t...rest\n}: TypingIndicatorProps) {\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\trole=\"status\"\n\t\t\taria-live={ariaLive}\n\t\t\tclassName={cx(bubble, className)}\n\t\t>\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={visuallyHidden}>{ariaLabel}</span>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;AA+BA,SAAgB,EAAgB,EAC/B,cACA,cAAc,IAAY,mBAC1B,aAAa,IAAW,UACxB,GAAG,KACqB;
|
|
1
|
+
{"version":3,"file":"TypingIndicator.js","names":[],"sources":["../../../src/components/TypingIndicator/TypingIndicator.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { bubble, dot, visuallyHidden } from \"./TypingIndicator.css.js\";\n\nexport interface TypingIndicatorProps\n\textends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Human-agent typing indicator — an animated three-dot bubble shown while a live\n * agent is composing a reply. Render it as a transient status in the message list\n * driven by the agent's live typing/presence signal, and remove it when the\n * message arrives or typing stops.\n *\n * Use only for a human agent typing — not for AI generation (use the\n * `ThinkingShimmer` for that).\n *\n * Exposed as a polite live region. The dots are hidden from assistive tech and\n * the announced string is carried as visually-hidden text (live regions announce\n * rendered text, not `aria-label`); pass `aria-label` to override it. Reliable\n * on-appearance announcement additionally depends on the consuming surface\n * keeping a persistent live region present before this mounts; validate with a\n * real screen reader when a surface adopts this component.\n *\n * A surface that already wraps this in its own live region should pass\n * `aria-live=\"off\"`: two nested regions announce the same text twice, in an order\n * neither controls.\n */\nexport function TypingIndicator({\n\tclassName,\n\t\"aria-label\": ariaLabel = \"Agent is typing\",\n\t\"aria-live\": ariaLive = \"polite\",\n\t...rest\n}: TypingIndicatorProps) {\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\trole=\"status\"\n\t\t\taria-live={ariaLive}\n\t\t\tclassName={cx(bubble, className)}\n\t\t>\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={dot} aria-hidden=\"true\" />\n\t\t\t<span className={visuallyHidden}>{ariaLabel}</span>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;AA+BA,SAAgB,EAAgB,EAC/B,cACA,cAAc,IAAY,mBAC1B,aAAa,IAAW,UACxB,GAAG,KACqB;CACxB,OACC,kBAAC,OAAD;EACC,GAAI;EACJ,MAAK;EACL,aAAW;EACX,WAAW,EAAG,GAAQ,CAAS;YAJhC;GAMC,kBAAC,QAAD;IAAM,WAAW;IAAK,eAAY;GAAQ,CAAA;GAC1C,kBAAC,QAAD;IAAM,WAAW;IAAK,eAAY;GAAQ,CAAA;GAC1C,kBAAC,QAAD;IAAM,WAAW;IAAK,eAAY;GAAQ,CAAA;GAC1C,kBAAC,QAAD;IAAM,WAAW;cAAiB;GAAgB,CAAA;EAC9C;;AAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMessage.js","names":[],"sources":["../../../src/components/UserMessage/UserMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MessageProse } from \"../MessageProse/index.js\";\nimport { userMessageBubble, userMessageText } from \"./UserMessage.css.js\";\n\nexport interface UserMessageProps {\n\t/**\n\t * The message the chatter sent. One message per bubble; block content\n\t * (lists, tables) is allowed.\n\t */\n\tchildren: ReactNode;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The chatter's outbound chat message bubble — accent background, shrink-wrapped\n * to its content. Mirrors automatically under `dir=\"rtl\"` via logical properties.\n *\n * Where the bubble sits in the row is the transcript's decision, not this\n * component's, and so is anything beside it: pair it with `MessageError` as a\n * sibling when a send fails. `AgentMessage` draws the same boundary.\n */\nexport function UserMessage({\n\tchildren,\n\tclassName,\n\t...rest\n}: UserMessageProps) {\n\treturn (\n\t\t<div {...rest} className={cx(userMessageBubble, className)}>\n\t\t\t<MessageProse className={userMessageText}>{children}</MessageProse>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAwBA,SAAgB,EAAY,EAC3B,aACA,cACA,GAAG,KACiB;
|
|
1
|
+
{"version":3,"file":"UserMessage.js","names":[],"sources":["../../../src/components/UserMessage/UserMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MessageProse } from \"../MessageProse/index.js\";\nimport { userMessageBubble, userMessageText } from \"./UserMessage.css.js\";\n\nexport interface UserMessageProps {\n\t/**\n\t * The message the chatter sent. One message per bubble; block content\n\t * (lists, tables) is allowed.\n\t */\n\tchildren: ReactNode;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The chatter's outbound chat message bubble — accent background, shrink-wrapped\n * to its content. Mirrors automatically under `dir=\"rtl\"` via logical properties.\n *\n * Where the bubble sits in the row is the transcript's decision, not this\n * component's, and so is anything beside it: pair it with `MessageError` as a\n * sibling when a send fails. `AgentMessage` draws the same boundary.\n */\nexport function UserMessage({\n\tchildren,\n\tclassName,\n\t...rest\n}: UserMessageProps) {\n\treturn (\n\t\t<div {...rest} className={cx(userMessageBubble, className)}>\n\t\t\t<MessageProse className={userMessageText}>{children}</MessageProse>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAwBA,SAAgB,EAAY,EAC3B,aACA,cACA,GAAG,KACiB;CACpB,OACC,kBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,EAAG,GAAmB,CAAS;YACxD,kBAAC,GAAD;GAAc,WAAW;GAAkB;EAAuB,CAAA;CAC9D,CAAA;AAEP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
//#region src/components/VideoMessage/VideoMessage.css.ts
|
|
4
4
|
var t = e({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoMessage.js","names":[],"sources":["../../../src/components/VideoMessage/VideoMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { Children } from \"react\";\nimport { Group } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MediaSlash } from \"../Icon/icons/MediaSlash.js\";\nimport {\n\tvideoPlaceholderIcon,\n\tvideoRoot,\n\tvideoSlot,\n} from \"./VideoMessage.css.js\";\n\nexport type VideoAspectRatio = \"16:9\" | \"4:3\" | \"1:1\" | \"3:4\" | \"9:16\";\n\nexport interface VideoMessageProps {\n\t/**\n\t * The player rendered inside the frame. The shell carries no playback logic\n\t * of its own — the supplied player owns its controls, load state and error\n\t * handling; drive the placeholder through `unavailable`. When absent, the\n\t * frame shows the unavailable placeholder.\n\t */\n\tchildren?: ReactNode;\n\t/** Accessible name for the video — describe what it shows. */\n\talt: string;\n\t/**\n\t * Frame proportions — bind to the source video's proportions so it isn't\n\t * cropped. Defaults to `\"16:9\"`. The frame is context-sized (fills its\n\t * container's width); the consumer constrains it to the message column.\n\t */\n\taspectRatio?: VideoAspectRatio;\n\t/** Force the \"video unavailable\" placeholder (media-slash on a muted box). */\n\tunavailable?: boolean;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\nconst UNAVAILABLE_LABEL = \"Video unavailable\";\nconst GROUP_LABEL = \"Video\";\nconst DEFAULT_ASPECT_RATIO: VideoAspectRatio = \"16:9\";\n\n/**\n * The presentational frame for a video attachment rendered inside a chat\n * message: rounded clipping to the media-preview corner radius, a fixed aspect\n * ratio, and an accessible grouping label. The consumer supplies the player as\n * `children`; when the video is unavailable — or no player is supplied — the\n * frame shows a muted media-slash placeholder instead.\n */\nexport function VideoMessage({\n\tchildren,\n\talt,\n\taspectRatio = DEFAULT_ASPECT_RATIO,\n\tunavailable = false,\n\tclassName,\n\t...rest\n}: VideoMessageProps) {\n\t// Normalized emptiness, not a `!== false` check: a consumer gating its player\n\t// with `{ready && <Player />}` — alone or alongside siblings, where children\n\t// arrives as an array — renders nothing, and treating that as a supplied\n\t// player would leave the frame permanently empty. `Children.toArray` strips\n\t// null/undefined/booleans at any depth.\n\tconst supplied = Children.toArray(children).length > 0;\n\tconst showPlaceholder = unavailable || !supplied;\n\n\t// Lovelace can be consumed from older/untyped JavaScript even though the TS\n\t// contract requires a string, so the failure path must remain total.\n\tconst description = typeof alt === \"string\" ? alt.trim() : \"\";\n\tconst unavailableLabel = description\n\t\t? `${UNAVAILABLE_LABEL}: ${description}`\n\t\t: UNAVAILABLE_LABEL;\n\n\treturn (\n\t\t// RAC `Group` (role=\"group\"), not a bare div: `aria-label` on a generic\n\t\t// element is prohibited and assistive tech drops it (axe\n\t\t// `aria-prohibited-attr`), so a supplied player — which carries no label of\n\t\t// its own — would reach nobody.\n\t\t<Group\n\t\t\t{...rest}\n\t\t\taria-label={description || GROUP_LABEL}\n\t\t\tdata-aspect-ratio={aspectRatio}\n\t\t\tdata-unavailable={showPlaceholder || undefined}\n\t\t\tclassName={cx(\n\t\t\t\tvideoRoot({ aspectRatio, unavailable: showPlaceholder }),\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{showPlaceholder ? (\n\t\t\t\t<MediaSlash className={videoPlaceholderIcon} label={unavailableLabel} />\n\t\t\t) : (\n\t\t\t\t<div className={videoSlot}>{children}</div>\n\t\t\t)}\n\t\t</Group>\n\t);\n}\n"],"mappings":";;;;;;;AAoCA,IAAM,IAAoB,qBACpB,IAAc,SACd,IAAyC;AAS/C,SAAgB,EAAa,EAC5B,aACA,QACA,iBAAc,GACd,iBAAc,IACd,cACA,GAAG,KACkB;CAMrB,IAAM,IAAW,EAAS,QAAQ,
|
|
1
|
+
{"version":3,"file":"VideoMessage.js","names":[],"sources":["../../../src/components/VideoMessage/VideoMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { Children } from \"react\";\nimport { Group } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MediaSlash } from \"../Icon/icons/MediaSlash.js\";\nimport {\n\tvideoPlaceholderIcon,\n\tvideoRoot,\n\tvideoSlot,\n} from \"./VideoMessage.css.js\";\n\nexport type VideoAspectRatio = \"16:9\" | \"4:3\" | \"1:1\" | \"3:4\" | \"9:16\";\n\nexport interface VideoMessageProps {\n\t/**\n\t * The player rendered inside the frame. The shell carries no playback logic\n\t * of its own — the supplied player owns its controls, load state and error\n\t * handling; drive the placeholder through `unavailable`. When absent, the\n\t * frame shows the unavailable placeholder.\n\t */\n\tchildren?: ReactNode;\n\t/** Accessible name for the video — describe what it shows. */\n\talt: string;\n\t/**\n\t * Frame proportions — bind to the source video's proportions so it isn't\n\t * cropped. Defaults to `\"16:9\"`. The frame is context-sized (fills its\n\t * container's width); the consumer constrains it to the message column.\n\t */\n\taspectRatio?: VideoAspectRatio;\n\t/** Force the \"video unavailable\" placeholder (media-slash on a muted box). */\n\tunavailable?: boolean;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\nconst UNAVAILABLE_LABEL = \"Video unavailable\";\nconst GROUP_LABEL = \"Video\";\nconst DEFAULT_ASPECT_RATIO: VideoAspectRatio = \"16:9\";\n\n/**\n * The presentational frame for a video attachment rendered inside a chat\n * message: rounded clipping to the media-preview corner radius, a fixed aspect\n * ratio, and an accessible grouping label. The consumer supplies the player as\n * `children`; when the video is unavailable — or no player is supplied — the\n * frame shows a muted media-slash placeholder instead.\n */\nexport function VideoMessage({\n\tchildren,\n\talt,\n\taspectRatio = DEFAULT_ASPECT_RATIO,\n\tunavailable = false,\n\tclassName,\n\t...rest\n}: VideoMessageProps) {\n\t// Normalized emptiness, not a `!== false` check: a consumer gating its player\n\t// with `{ready && <Player />}` — alone or alongside siblings, where children\n\t// arrives as an array — renders nothing, and treating that as a supplied\n\t// player would leave the frame permanently empty. `Children.toArray` strips\n\t// null/undefined/booleans at any depth.\n\tconst supplied = Children.toArray(children).length > 0;\n\tconst showPlaceholder = unavailable || !supplied;\n\n\t// Lovelace can be consumed from older/untyped JavaScript even though the TS\n\t// contract requires a string, so the failure path must remain total.\n\tconst description = typeof alt === \"string\" ? alt.trim() : \"\";\n\tconst unavailableLabel = description\n\t\t? `${UNAVAILABLE_LABEL}: ${description}`\n\t\t: UNAVAILABLE_LABEL;\n\n\treturn (\n\t\t// RAC `Group` (role=\"group\"), not a bare div: `aria-label` on a generic\n\t\t// element is prohibited and assistive tech drops it (axe\n\t\t// `aria-prohibited-attr`), so a supplied player — which carries no label of\n\t\t// its own — would reach nobody.\n\t\t<Group\n\t\t\t{...rest}\n\t\t\taria-label={description || GROUP_LABEL}\n\t\t\tdata-aspect-ratio={aspectRatio}\n\t\t\tdata-unavailable={showPlaceholder || undefined}\n\t\t\tclassName={cx(\n\t\t\t\tvideoRoot({ aspectRatio, unavailable: showPlaceholder }),\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{showPlaceholder ? (\n\t\t\t\t<MediaSlash className={videoPlaceholderIcon} label={unavailableLabel} />\n\t\t\t) : (\n\t\t\t\t<div className={videoSlot}>{children}</div>\n\t\t\t)}\n\t\t</Group>\n\t);\n}\n"],"mappings":";;;;;;;AAoCA,IAAM,IAAoB,qBACpB,IAAc,SACd,IAAyC;AAS/C,SAAgB,EAAa,EAC5B,aACA,QACA,iBAAc,GACd,iBAAc,IACd,cACA,GAAG,KACkB;CAMrB,IAAM,IAAW,EAAS,QAAQ,CAAQ,CAAC,CAAC,SAAS,GAC/C,IAAkB,KAAe,CAAC,GAIlC,IAAc,OAAO,KAAQ,WAAW,EAAI,KAAK,IAAI,IACrD,IAAmB,IACtB,GAAG,EAAkB,IAAI,MACzB;CAEH,OAKC,kBAAC,GAAD;EACC,GAAI;EACJ,cAAY,KAAe;EAC3B,qBAAmB;EACnB,oBAAkB,KAAmB,KAAA;EACrC,WAAW,EACV,EAAU;GAAE;GAAa,aAAa;EAAgB,CAAC,GACvD,CACD;YAEC,IACA,kBAAC,GAAD;GAAY,WAAW;GAAsB,OAAO;EAAmB,CAAA,IAEvE,kBAAC,OAAD;GAAK,WAAW;GAAY;EAAc,CAAA;CAErC,CAAA;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlayRegistry.js","names":[],"sources":["../../src/hooks/overlayRegistry.tsx"],"sourcesContent":["import { useLayoutEffect, useSyncExternalStore } from \"react\";\n\n/**\n * How many modal overlays are mounted right now.\n *\n * Module-level because the reader is not an ancestor of the overlays: the toast\n * region sits in the consumer's chrome while every overlay renders through a\n * portal, so there is no shared provider to hang this on that a consumer could\n * not forget to mount.\n */\nlet openOverlays = 0;\nconst subscribers = new Set<() => void>();\n\nfunction subscribe(onStoreChange: () => void): () => void {\n\tsubscribers.add(onStoreChange);\n\treturn () => {\n\t\tsubscribers.delete(onStoreChange);\n\t};\n}\n\nfunction getSnapshot(): boolean {\n\treturn openOverlays > 0;\n}\n\nfunction getServerSnapshot(): boolean {\n\treturn false;\n}\n\nfunction publish(): void {\n\tfor (const onStoreChange of subscribers) {\n\t\tonStoreChange();\n\t}\n}\n\n/**\n * Counts one modal overlay as open for as long as the calling component is\n * mounted, so a surface underneath can stand down while it is.\n *\n * Call it from a component rendered **inside** the overlay, not from the one that\n * renders the overlay. RAC mounts an overlay's children for exactly the window the\n * scrim is on screen, which includes its exit transition — keying off an `isOpen`\n * prop instead releases the count while the scrim is still painted and still\n * blocking the pointer. `OverlayRegistration` is that component; render one inside\n * any `ModalOverlay` this package does not already wrap.\n */\nexport function useRegisterOverlay(): void {\n\t// Layout, not passive: a passive effect runs after the commit is painted, so\n\t// the frame that puts the scrim up would also show whatever was standing down\n\t// underneath it, and a toast mounted for that frame announces itself.\n\tuseLayoutEffect(() => {\n\t\topenOverlays += 1;\n\t\tpublish();\n\t\treturn () => {\n\t\t\topenOverlays -= 1;\n\t\t\tpublish();\n\t\t};\n\t}, []);\n}\n\n/** Registers its overlay for as long as it is rendered. Renders nothing. */\nexport function OverlayRegistration(): null {\n\tuseRegisterOverlay();\n\treturn null;\n}\n\n/**\n * Whether any modal overlay is open.\n *\n * For a surface that has to stand down while one is: an overlay traps focus and\n * paints over everything below it, so anything left underneath is unreachable by\n * pointer while still being announced and focusable.\n */\nexport function useHasOpenOverlay(): boolean {\n\treturn useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"],"mappings":";;AAUA,IAAI,IAAe,GACb,oBAAc,IAAI,
|
|
1
|
+
{"version":3,"file":"overlayRegistry.js","names":[],"sources":["../../src/hooks/overlayRegistry.tsx"],"sourcesContent":["import { useLayoutEffect, useSyncExternalStore } from \"react\";\n\n/**\n * How many modal overlays are mounted right now.\n *\n * Module-level because the reader is not an ancestor of the overlays: the toast\n * region sits in the consumer's chrome while every overlay renders through a\n * portal, so there is no shared provider to hang this on that a consumer could\n * not forget to mount.\n */\nlet openOverlays = 0;\nconst subscribers = new Set<() => void>();\n\nfunction subscribe(onStoreChange: () => void): () => void {\n\tsubscribers.add(onStoreChange);\n\treturn () => {\n\t\tsubscribers.delete(onStoreChange);\n\t};\n}\n\nfunction getSnapshot(): boolean {\n\treturn openOverlays > 0;\n}\n\nfunction getServerSnapshot(): boolean {\n\treturn false;\n}\n\nfunction publish(): void {\n\tfor (const onStoreChange of subscribers) {\n\t\tonStoreChange();\n\t}\n}\n\n/**\n * Counts one modal overlay as open for as long as the calling component is\n * mounted, so a surface underneath can stand down while it is.\n *\n * Call it from a component rendered **inside** the overlay, not from the one that\n * renders the overlay. RAC mounts an overlay's children for exactly the window the\n * scrim is on screen, which includes its exit transition — keying off an `isOpen`\n * prop instead releases the count while the scrim is still painted and still\n * blocking the pointer. `OverlayRegistration` is that component; render one inside\n * any `ModalOverlay` this package does not already wrap.\n */\nexport function useRegisterOverlay(): void {\n\t// Layout, not passive: a passive effect runs after the commit is painted, so\n\t// the frame that puts the scrim up would also show whatever was standing down\n\t// underneath it, and a toast mounted for that frame announces itself.\n\tuseLayoutEffect(() => {\n\t\topenOverlays += 1;\n\t\tpublish();\n\t\treturn () => {\n\t\t\topenOverlays -= 1;\n\t\t\tpublish();\n\t\t};\n\t}, []);\n}\n\n/** Registers its overlay for as long as it is rendered. Renders nothing. */\nexport function OverlayRegistration(): null {\n\tuseRegisterOverlay();\n\treturn null;\n}\n\n/**\n * Whether any modal overlay is open.\n *\n * For a surface that has to stand down while one is: an overlay traps focus and\n * paints over everything below it, so anything left underneath is unreachable by\n * pointer while still being announced and focusable.\n */\nexport function useHasOpenOverlay(): boolean {\n\treturn useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"],"mappings":";;AAUA,IAAI,IAAe,GACb,oBAAc,IAAI,IAAgB;AAExC,SAAS,EAAU,GAAuC;CAEzD,OADA,EAAY,IAAI,CAAa,SAChB;EACZ,EAAY,OAAO,CAAa;CACjC;AACD;AAEA,SAAS,IAAuB;CAC/B,OAAO,IAAe;AACvB;AAEA,SAAS,IAA6B;CACrC,OAAO;AACR;AAEA,SAAS,IAAgB;CACxB,KAAK,IAAM,KAAiB,GAC3B,EAAc;AAEhB;AAaA,SAAgB,IAA2B;CAI1C,SACC,KAAgB,GAChB,EAAQ,SACK;EAEZ,AADA,KACA,EAAQ;CACT,IACE,CAAC,CAAC;AACN;AAGA,SAAgB,IAA4B;CAE3C,OADA,EAAmB,GACZ;AACR;AASA,SAAgB,IAA6B;CAC5C,OAAO,EAAqB,GAAW,GAAa,CAAiB;AACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrefersReducedMotion.js","names":[],"sources":["../../src/hooks/usePrefersReducedMotion.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\nexport function readPrefersReducedMotion(): boolean {\n\tif (\n\t\ttypeof window === \"undefined\" ||\n\t\ttypeof window.matchMedia !== \"function\"\n\t) {\n\t\treturn false;\n\t}\n\treturn window.matchMedia(REDUCED_MOTION_QUERY).matches;\n}\n\n/** Tracks the user's `prefers-reduced-motion` setting, updating on change. */\nexport function usePrefersReducedMotion(): boolean {\n\tconst [reduced, setReduced] = useState(readPrefersReducedMotion);\n\n\tuseEffect(() => {\n\t\tif (\n\t\t\ttypeof window === \"undefined\" ||\n\t\t\ttypeof window.matchMedia !== \"function\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst mql = window.matchMedia(REDUCED_MOTION_QUERY);\n\t\tsetReduced(mql.matches);\n\t\tconst listener = (e: MediaQueryListEvent) => setReduced(e.matches);\n\t\tmql.addEventListener(\"change\", listener);\n\t\treturn () => mql.removeEventListener(\"change\", listener);\n\t}, []);\n\n\treturn reduced;\n}\n"],"mappings":";;AAEA,IAAM,IAAuB;AAE7B,SAAgB,IAAoC;
|
|
1
|
+
{"version":3,"file":"usePrefersReducedMotion.js","names":[],"sources":["../../src/hooks/usePrefersReducedMotion.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\nexport function readPrefersReducedMotion(): boolean {\n\tif (\n\t\ttypeof window === \"undefined\" ||\n\t\ttypeof window.matchMedia !== \"function\"\n\t) {\n\t\treturn false;\n\t}\n\treturn window.matchMedia(REDUCED_MOTION_QUERY).matches;\n}\n\n/** Tracks the user's `prefers-reduced-motion` setting, updating on change. */\nexport function usePrefersReducedMotion(): boolean {\n\tconst [reduced, setReduced] = useState(readPrefersReducedMotion);\n\n\tuseEffect(() => {\n\t\tif (\n\t\t\ttypeof window === \"undefined\" ||\n\t\t\ttypeof window.matchMedia !== \"function\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst mql = window.matchMedia(REDUCED_MOTION_QUERY);\n\t\tsetReduced(mql.matches);\n\t\tconst listener = (e: MediaQueryListEvent) => setReduced(e.matches);\n\t\tmql.addEventListener(\"change\", listener);\n\t\treturn () => mql.removeEventListener(\"change\", listener);\n\t}, []);\n\n\treturn reduced;\n}\n"],"mappings":";;AAEA,IAAM,IAAuB;AAE7B,SAAgB,IAAoC;CAOnD,OALC,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,aAEtB,KAED,OAAO,WAAW,CAAoB,CAAC,CAAC;AAChD;AAGA,SAAgB,IAAmC;CAClD,IAAM,CAAC,GAAS,KAAc,EAAS,CAAwB;CAgB/D,OAdA,QAAgB;EACf,IACC,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,YAE7B;EAED,IAAM,IAAM,OAAO,WAAW,CAAoB;EAClD,EAAW,EAAI,OAAO;EACtB,IAAM,KAAY,MAA2B,EAAW,EAAE,OAAO;EAEjE,OADA,EAAI,iBAAiB,UAAU,CAAQ,SAC1B,EAAI,oBAAoB,UAAU,CAAQ;CACxD,GAAG,CAAC,CAAC,GAEE;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSubmitOnEnter.js","names":[],"sources":["../../src/hooks/useSubmitOnEnter.ts"],"sourcesContent":["import type { KeyboardEvent } from \"react\";\nimport { useCallback } from \"react\";\n\n/** Returns an `onKeyDown` handler that calls `onSubmit` when Enter is pressed\n * without Shift — the standard chat-composer key handling. Shift+Enter falls\n * through so the field inserts a newline. Guards against IME composition:\n * pressing Enter to confirm a candidate (e.g. Japanese/Chinese input) must not\n * submit, so composition keystrokes are ignored. */\nexport function useSubmitOnEnter<T extends HTMLElement = HTMLTextAreaElement>(\n\tonSubmit: () => void,\n) {\n\treturn useCallback(\n\t\t(event: KeyboardEvent<T>) => {\n\t\t\tif (event.key !== \"Enter\" || event.shiftKey) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Enter confirms an IME candidate rather than sending — never submit mid-composition.\n\t\t\tif (event.nativeEvent.isComposing) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tonSubmit();\n\t\t},\n\t\t[onSubmit],\n\t);\n}\n"],"mappings":";;AAQA,SAAgB,EACf,GACC;
|
|
1
|
+
{"version":3,"file":"useSubmitOnEnter.js","names":[],"sources":["../../src/hooks/useSubmitOnEnter.ts"],"sourcesContent":["import type { KeyboardEvent } from \"react\";\nimport { useCallback } from \"react\";\n\n/** Returns an `onKeyDown` handler that calls `onSubmit` when Enter is pressed\n * without Shift — the standard chat-composer key handling. Shift+Enter falls\n * through so the field inserts a newline. Guards against IME composition:\n * pressing Enter to confirm a candidate (e.g. Japanese/Chinese input) must not\n * submit, so composition keystrokes are ignored. */\nexport function useSubmitOnEnter<T extends HTMLElement = HTMLTextAreaElement>(\n\tonSubmit: () => void,\n) {\n\treturn useCallback(\n\t\t(event: KeyboardEvent<T>) => {\n\t\t\tif (event.key !== \"Enter\" || event.shiftKey) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Enter confirms an IME candidate rather than sending — never submit mid-composition.\n\t\t\tif (event.nativeEvent.isComposing) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tonSubmit();\n\t\t},\n\t\t[onSubmit],\n\t);\n}\n"],"mappings":";;AAQA,SAAgB,EACf,GACC;CACD,OAAO,GACL,MAA4B;EACxB,EAAM,QAAQ,WAAW,EAAM,YAI/B,EAAM,YAAY,gBAGtB,EAAM,eAAe,GACrB,EAAS;CACV,GACA,CAAC,CAAQ,CACV;AACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from "./components/Avatar/index.js";
|
|
|
4
4
|
export * from "./components/Banner/index.js";
|
|
5
5
|
export * from "./components/BubbleOverlay/index.js";
|
|
6
6
|
export * from "./components/Button/index.js";
|
|
7
|
+
export * from "./components/Card/index.js";
|
|
8
|
+
export * from "./components/Carousel/index.js";
|
|
7
9
|
export * from "./components/Checkbox/index.js";
|
|
8
10
|
export * from "./components/Chip/index.js";
|
|
9
11
|
export * from "./components/Dialog/index.js";
|
package/dist/index.js
CHANGED
|
@@ -45,46 +45,49 @@ import { BannerContainer as U } from "./components/Banner/BannerContainer.js";
|
|
|
45
45
|
import { useHasOpenOverlay as W, useRegisterOverlay as G } from "./hooks/overlayRegistry.js";
|
|
46
46
|
import { BubbleOverlay as K } from "./components/BubbleOverlay/BubbleOverlay.js";
|
|
47
47
|
import { Button as q } from "./components/Button/Button.js";
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
90
|
-
|
|
48
|
+
import { Image as J } from "./components/Image/Image.js";
|
|
49
|
+
import { Card as Y } from "./components/Card/Card.js";
|
|
50
|
+
import { readPrefersReducedMotion as X, usePrefersReducedMotion as Z } from "./hooks/usePrefersReducedMotion.js";
|
|
51
|
+
import { IconButton as Q } from "./components/IconButton/IconButton.js";
|
|
52
|
+
import { Carousel as $ } from "./components/Carousel/Carousel.js";
|
|
53
|
+
import { CarouselItem as ee } from "./components/Carousel/CarouselItem.js";
|
|
54
|
+
import { Checkbox as te } from "./components/Checkbox/Checkbox.js";
|
|
55
|
+
import { CheckboxGroup as ne } from "./components/Checkbox/CheckboxGroup.js";
|
|
56
|
+
import { Chip as re } from "./components/Chip/Chip.js";
|
|
57
|
+
import { Dialog as ie } from "./components/Dialog/Dialog.js";
|
|
58
|
+
import { DialogOverlay as ae } from "./components/DialogOverlay/DialogOverlay.js";
|
|
59
|
+
import { Divider as oe } from "./components/Divider/Divider.js";
|
|
60
|
+
import { DropZone as se } from "./components/DropZone/DropZone.js";
|
|
61
|
+
import { FullscreenOverlay as ce } from "./components/FullscreenOverlay/FullscreenOverlay.js";
|
|
62
|
+
import { Header as le } from "./components/Header/Header.js";
|
|
63
|
+
import { Input as ue } from "./components/Input/Input.js";
|
|
64
|
+
import { Link as de } from "./components/Link/Link.js";
|
|
65
|
+
import { Menu as fe } from "./components/MenuItem/Menu.js";
|
|
66
|
+
import { MenuItem as pe } from "./components/MenuItem/MenuItem.js";
|
|
67
|
+
import { MessageError as me } from "./components/MessageError/MessageError.js";
|
|
68
|
+
import { MessageRow as he } from "./components/MessageRow/MessageRow.js";
|
|
69
|
+
import { PictureMessage as ge } from "./components/PictureMessage/PictureMessage.js";
|
|
70
|
+
import { PillButton as _e } from "./components/PillButton/PillButton.js";
|
|
71
|
+
import { ProactiveMessage as ve } from "./components/ProactiveMessage/ProactiveMessage.js";
|
|
72
|
+
import { Radio as ye } from "./components/Radio/Radio.js";
|
|
73
|
+
import { RadioGroup as be } from "./components/Radio/RadioGroup.js";
|
|
74
|
+
import { ScrollMarker as xe } from "./components/ScrollMarker/ScrollMarker.js";
|
|
75
|
+
import { Sheet as Se } from "./components/Sheet/Sheet.js";
|
|
76
|
+
import { SheetOverlay as Ce } from "./components/SheetOverlay/SheetOverlay.js";
|
|
77
|
+
import { useSubmitOnEnter as we } from "./hooks/useSubmitOnEnter.js";
|
|
78
|
+
import { Spinner as Te } from "./components/Spinner/Spinner.js";
|
|
79
|
+
import { SurveyRating as Ee } from "./components/SurveyRating/SurveyRating.js";
|
|
80
|
+
import { SurveySelect as De } from "./components/SurveySelect/SurveySelect.js";
|
|
81
|
+
import { Text as Oe } from "./components/Text/Text.js";
|
|
82
|
+
import { ThinkingShimmer as ke } from "./components/ThinkingShimmer/ThinkingShimmer.js";
|
|
83
|
+
import { Toast as Ae } from "./components/Toast/Toast.js";
|
|
84
|
+
import { ToastContainer as je } from "./components/Toast/ToastContainer.js";
|
|
85
|
+
import { ToastQueue as Me } from "./components/Toast/index.js";
|
|
86
|
+
import { Toggle as Ne } from "./components/Toggle/Toggle.js";
|
|
87
|
+
import { Tooltip as Pe, TooltipTrigger as Fe } from "./components/Tooltip/Tooltip.js";
|
|
88
|
+
import { TypingIndicator as Ie } from "./components/TypingIndicator/TypingIndicator.js";
|
|
89
|
+
import { UserMessage as Le } from "./components/UserMessage/UserMessage.js";
|
|
90
|
+
import { VideoMessage as Re } from "./components/VideoMessage/VideoMessage.js";
|
|
91
|
+
import { LOVELACE_SURFACES as ze, contrastRatioBetween as Be, createBrandOverrides as Ve, isLegibleAgainst as He, isLegibleOnSurface as Ue, readableTextOnAccent as We } from "./runtime/branding.js";
|
|
92
|
+
import { LovelaceProvider as Ge, useResolvedTheme as Ke } from "./runtime/LovelaceProvider.js";
|
|
93
|
+
export { a as AdaLogo, e as AgentMessage, o as ArrowDown, s as ArrowLeft, c as ArrowNortheast, l as ArrowNorthwest, u as ArrowRight, d as ArrowUp, t as AttachmentChip, r as Avatar, n as AvatarPlaceholder, H as Banner, U as BannerContainer, f as Bell, p as BellSlash, K as BubbleOverlay, q as Button, Y as Card, $ as Carousel, ee as CarouselItem, te as Checkbox, ne as CheckboxGroup, m as Checkmark, h as CheckmarkCircle, g as ChevronLeft, _ as ChevronRight, re as Chip, v as CloudUpload, ie as Dialog, ae as DialogOverlay, oe as Divider, y as Document, b as Download, se as DropZone, x as Ellipses, S as Email, C as ExclamationSync, w as ExclamationTriangle, T as Eye, E as EyeSlash, ce as FullscreenOverlay, le as Header, i as Icon, Q as IconButton, J as Image, ue as Input, ze as LOVELACE_SURFACES, D as Language, de as Link, Ge as LovelaceProvider, O as MediaSlash, fe as Menu, pe as MenuItem, me as MessageError, he as MessageRow, k as MessagingFill, A as Minimize, j as Mute, M as Paperclip, N as PersonFill, ge as PictureMessage, _e as PillButton, P as PlayFill, ve as ProactiveMessage, ye as Radio, be as RadioGroup, xe as ScrollMarker, F as Send, Se as Sheet, Ce as SheetOverlay, Te as Spinner, I as StarBadgeFill, Ee as SurveyRating, De as SurveySelect, Oe as Text, ke as ThinkingShimmer, L as ThumbsDown, R as ThumbsUp, Ae as Toast, je as ToastContainer, Me as ToastQueue, Ne as Toggle, Pe as Tooltip, Fe as TooltipTrigger, Ie as TypingIndicator, Le as UserMessage, Re as VideoMessage, z as Volume, B as Xmark, V as XmarkCircle, Be as contrastRatioBetween, Ve as createBrandOverrides, He as isLegibleAgainst, Ue as isLegibleOnSurface, X as readPrefersReducedMotion, We as readableTextOnAccent, W as useHasOpenOverlay, Z as usePrefersReducedMotion, G as useRegisterOverlay, Ke as useResolvedTheme, we as useSubmitOnEnter };
|
|
@@ -24,15 +24,15 @@ function c(e) {
|
|
|
24
24
|
}, [e]), t;
|
|
25
25
|
}
|
|
26
26
|
function l({ theme: n = "auto", override: o, children: s }) {
|
|
27
|
-
let l = c(n), [u, d] = i(null)
|
|
28
|
-
let t = { display: "contents" };
|
|
29
|
-
for (let [n, r] of Object.entries(o ?? {})) r != null && (t[e(n)] = r);
|
|
30
|
-
return t;
|
|
31
|
-
}, [o]);
|
|
27
|
+
let l = c(n), [u, d] = i(null);
|
|
32
28
|
return /* @__PURE__ */ t("div", {
|
|
33
29
|
ref: d,
|
|
34
30
|
"data-theme": l,
|
|
35
|
-
style:
|
|
31
|
+
style: r(() => {
|
|
32
|
+
let t = { display: "contents" };
|
|
33
|
+
for (let [n, r] of Object.entries(o ?? {})) r != null && (t[e(n)] = r);
|
|
34
|
+
return t;
|
|
35
|
+
}, [o]),
|
|
36
36
|
children: u != null && /* @__PURE__ */ t(a, {
|
|
37
37
|
getContainer: () => u,
|
|
38
38
|
children: s
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LovelaceProvider.js","names":[],"sources":["../../src/runtime/LovelaceProvider.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { UNSAFE_PortalProvider } from \"react-aria\";\nimport type { LovelaceOverridableToken } from \"../tokens/tokens.js\";\nimport { tokenName } from \"../tokens/tokens.js\";\n\nexport type LovelaceTheme = \"light\" | \"dark\" | \"auto\";\n\nexport interface LovelaceProviderProps {\n\t/** Color scheme. `auto` resolves via `prefers-color-scheme`. Defaults to `auto`. */\n\ttheme?: LovelaceTheme;\n\t/**\n\t * Type-safe token overrides applied to the provider root and cascaded to every\n\t * Lovelace component inside. Keys are overridable (semantic / component) tokens;\n\t * values are CSS values — typically a primitive reference via `t()` (e.g.\n\t * `{ \"font-size-body\": t(\"font-size-14\") }`) or a raw color.\n\t */\n\toverride?: Partial<Record<LovelaceOverridableToken, string>>;\n\tchildren?: ReactNode;\n}\n\nconst DARK_QUERY = \"(prefers-color-scheme: dark)\";\n\nfunction readPrefersDark(): boolean {\n\tif (\n\t\ttypeof window === \"undefined\" ||\n\t\ttypeof window.matchMedia !== \"function\"\n\t) {\n\t\treturn false;\n\t}\n\treturn window.matchMedia(DARK_QUERY).matches;\n}\n\n/**\n * Resolves `auto` against `prefers-color-scheme`, updating live. Exported so a\n * consumer deciding something per-surface (e.g. a contrast guard on a token\n * override) resolves the scheme through the same code path that stamps\n * `data-theme` — two independent media queries would disagree wherever\n * `matchMedia` is unavailable, since each falls back to light on its own.\n */\nexport function useResolvedTheme(theme: LovelaceTheme): \"light\" | \"dark\" {\n\tconst [resolved, setResolved] = useState<\"light\" | \"dark\">(() => {\n\t\tif (theme !== \"auto\") {\n\t\t\treturn theme;\n\t\t}\n\t\treturn readPrefersDark() ? \"dark\" : \"light\";\n\t});\n\n\tuseEffect(() => {\n\t\tif (theme !== \"auto\") {\n\t\t\tsetResolved(theme);\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\ttypeof window === \"undefined\" ||\n\t\t\ttypeof window.matchMedia !== \"function\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst mql = window.matchMedia(DARK_QUERY);\n\t\tconst update = (matches: boolean) => {\n\t\t\tsetResolved(matches ? \"dark\" : \"light\");\n\t\t};\n\t\tupdate(mql.matches);\n\t\tconst listener = (e: MediaQueryListEvent) => update(e.matches);\n\t\tmql.addEventListener(\"change\", listener);\n\t\treturn () => mql.removeEventListener(\"change\", listener);\n\t}, [theme]);\n\n\treturn resolved;\n}\n\nexport function LovelaceProvider({\n\ttheme = \"auto\",\n\toverride,\n\tchildren,\n}: LovelaceProviderProps) {\n\tconst resolvedTheme = useResolvedTheme(theme);\n\t// Callback-ref into state (not useRef): attaching the element triggers a\n\t// re-render. Children are gated on it (below) so an overlay never mounts before\n\t// the themed portal container exists — a plain ref wouldn't re-render, and\n\t// deferring the portal to a second render would move an already-open overlay,\n\t// cancelling its entrance transition and stranding it at the `data-entering`\n\t// start state (opacity 0).\n\tconst [themeEl, setThemeEl] = useState<HTMLDivElement | null>(null);\n\n\tconst overrides = useMemo<CSSProperties>(() => {\n\t\t// `display: contents` removes this wrapper from layout so it doesn't\n\t\t// interfere with the parent's sizing — children render as if the wrapper\n\t\t// isn't there. Custom properties and data-attributes still cascade.\n\t\tconst vars: Record<string, string> = { display: \"contents\" };\n\t\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\t\tif (value != null) {\n\t\t\t\tvars[tokenName(name as LovelaceOverridableToken)] = value;\n\t\t\t}\n\t\t}\n\t\treturn vars as CSSProperties;\n\t}, [override]);\n\n\t// Component tokens are declared on `[data-theme]` (this wrapper) so their var()\n\t// chain re-evaluates in the active theme. React Aria overlays (Dialog/Sheet/\n\t// Tooltip) portal to `document.body` by default — outside this element — where\n\t// they'd lose those aliases. Default the portal container to the themed wrapper\n\t// so overlays stay inside the theme boundary; a consumer can still nest its own\n\t// `UNSAFE_PortalProvider` deeper to override (as the app scopes to the chat window).\n\t//\n\t// Children render only once `themeEl` is attached so any overlay open on first\n\t// mount portals straight into the themed container — never to `document.body`\n\t// and then moved (which would cancel its entrance transition). The callback ref's\n\t// setState runs in the commit phase (before paint), so the extra commit causes no\n\t// visible flash. It does mean an SSR render would emit an empty themed div until\n\t// hydration — fine today since every lovelace tree is client-mounted.\n\treturn (\n\t\t<div ref={setThemeEl} data-theme={resolvedTheme} style={overrides}>\n\t\t\t{themeEl != null && (\n\t\t\t\t<UNSAFE_PortalProvider getContainer={() => themeEl}>\n\t\t\t\t\t{children}\n\t\t\t\t</UNSAFE_PortalProvider>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAqBA,IAAM,IAAa;AAEnB,SAAS,IAA2B;
|
|
1
|
+
{"version":3,"file":"LovelaceProvider.js","names":[],"sources":["../../src/runtime/LovelaceProvider.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { UNSAFE_PortalProvider } from \"react-aria\";\nimport type { LovelaceOverridableToken } from \"../tokens/tokens.js\";\nimport { tokenName } from \"../tokens/tokens.js\";\n\nexport type LovelaceTheme = \"light\" | \"dark\" | \"auto\";\n\nexport interface LovelaceProviderProps {\n\t/** Color scheme. `auto` resolves via `prefers-color-scheme`. Defaults to `auto`. */\n\ttheme?: LovelaceTheme;\n\t/**\n\t * Type-safe token overrides applied to the provider root and cascaded to every\n\t * Lovelace component inside. Keys are overridable (semantic / component) tokens;\n\t * values are CSS values — typically a primitive reference via `t()` (e.g.\n\t * `{ \"font-size-body\": t(\"font-size-14\") }`) or a raw color.\n\t */\n\toverride?: Partial<Record<LovelaceOverridableToken, string>>;\n\tchildren?: ReactNode;\n}\n\nconst DARK_QUERY = \"(prefers-color-scheme: dark)\";\n\nfunction readPrefersDark(): boolean {\n\tif (\n\t\ttypeof window === \"undefined\" ||\n\t\ttypeof window.matchMedia !== \"function\"\n\t) {\n\t\treturn false;\n\t}\n\treturn window.matchMedia(DARK_QUERY).matches;\n}\n\n/**\n * Resolves `auto` against `prefers-color-scheme`, updating live. Exported so a\n * consumer deciding something per-surface (e.g. a contrast guard on a token\n * override) resolves the scheme through the same code path that stamps\n * `data-theme` — two independent media queries would disagree wherever\n * `matchMedia` is unavailable, since each falls back to light on its own.\n */\nexport function useResolvedTheme(theme: LovelaceTheme): \"light\" | \"dark\" {\n\tconst [resolved, setResolved] = useState<\"light\" | \"dark\">(() => {\n\t\tif (theme !== \"auto\") {\n\t\t\treturn theme;\n\t\t}\n\t\treturn readPrefersDark() ? \"dark\" : \"light\";\n\t});\n\n\tuseEffect(() => {\n\t\tif (theme !== \"auto\") {\n\t\t\tsetResolved(theme);\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\ttypeof window === \"undefined\" ||\n\t\t\ttypeof window.matchMedia !== \"function\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst mql = window.matchMedia(DARK_QUERY);\n\t\tconst update = (matches: boolean) => {\n\t\t\tsetResolved(matches ? \"dark\" : \"light\");\n\t\t};\n\t\tupdate(mql.matches);\n\t\tconst listener = (e: MediaQueryListEvent) => update(e.matches);\n\t\tmql.addEventListener(\"change\", listener);\n\t\treturn () => mql.removeEventListener(\"change\", listener);\n\t}, [theme]);\n\n\treturn resolved;\n}\n\nexport function LovelaceProvider({\n\ttheme = \"auto\",\n\toverride,\n\tchildren,\n}: LovelaceProviderProps) {\n\tconst resolvedTheme = useResolvedTheme(theme);\n\t// Callback-ref into state (not useRef): attaching the element triggers a\n\t// re-render. Children are gated on it (below) so an overlay never mounts before\n\t// the themed portal container exists — a plain ref wouldn't re-render, and\n\t// deferring the portal to a second render would move an already-open overlay,\n\t// cancelling its entrance transition and stranding it at the `data-entering`\n\t// start state (opacity 0).\n\tconst [themeEl, setThemeEl] = useState<HTMLDivElement | null>(null);\n\n\tconst overrides = useMemo<CSSProperties>(() => {\n\t\t// `display: contents` removes this wrapper from layout so it doesn't\n\t\t// interfere with the parent's sizing — children render as if the wrapper\n\t\t// isn't there. Custom properties and data-attributes still cascade.\n\t\tconst vars: Record<string, string> = { display: \"contents\" };\n\t\tfor (const [name, value] of Object.entries(override ?? {})) {\n\t\t\tif (value != null) {\n\t\t\t\tvars[tokenName(name as LovelaceOverridableToken)] = value;\n\t\t\t}\n\t\t}\n\t\treturn vars as CSSProperties;\n\t}, [override]);\n\n\t// Component tokens are declared on `[data-theme]` (this wrapper) so their var()\n\t// chain re-evaluates in the active theme. React Aria overlays (Dialog/Sheet/\n\t// Tooltip) portal to `document.body` by default — outside this element — where\n\t// they'd lose those aliases. Default the portal container to the themed wrapper\n\t// so overlays stay inside the theme boundary; a consumer can still nest its own\n\t// `UNSAFE_PortalProvider` deeper to override (as the app scopes to the chat window).\n\t//\n\t// Children render only once `themeEl` is attached so any overlay open on first\n\t// mount portals straight into the themed container — never to `document.body`\n\t// and then moved (which would cancel its entrance transition). The callback ref's\n\t// setState runs in the commit phase (before paint), so the extra commit causes no\n\t// visible flash. It does mean an SSR render would emit an empty themed div until\n\t// hydration — fine today since every lovelace tree is client-mounted.\n\treturn (\n\t\t<div ref={setThemeEl} data-theme={resolvedTheme} style={overrides}>\n\t\t\t{themeEl != null && (\n\t\t\t\t<UNSAFE_PortalProvider getContainer={() => themeEl}>\n\t\t\t\t\t{children}\n\t\t\t\t</UNSAFE_PortalProvider>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAqBA,IAAM,IAAa;AAEnB,SAAS,IAA2B;CAOnC,OALC,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,aAEtB,KAED,OAAO,WAAW,CAAU,CAAC,CAAC;AACtC;AASA,SAAgB,EAAiB,GAAwC;CACxE,IAAM,CAAC,GAAU,KAAe,QAC3B,MAAU,SAGP,EAAgB,IAAI,SAAS,UAF5B,CAGR;CAuBD,OArBA,QAAgB;EACf,IAAI,MAAU,QAAQ;GACrB,EAAY,CAAK;GACjB;EACD;EACA,IACC,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,YAE7B;EAED,IAAM,IAAM,OAAO,WAAW,CAAU,GAClC,KAAU,MAAqB;GACpC,EAAY,IAAU,SAAS,OAAO;EACvC;EACA,EAAO,EAAI,OAAO;EAClB,IAAM,KAAY,MAA2B,EAAO,EAAE,OAAO;EAE7D,OADA,EAAI,iBAAiB,UAAU,CAAQ,SAC1B,EAAI,oBAAoB,UAAU,CAAQ;CACxD,GAAG,CAAC,CAAK,CAAC,GAEH;AACR;AAEA,SAAgB,EAAiB,EAChC,WAAQ,QACR,aACA,eACyB;CACzB,IAAM,IAAgB,EAAiB,CAAK,GAOtC,CAAC,GAAS,KAAc,EAAgC,IAAI;CA4BlE,OACC,kBAAC,OAAD;EAAK,KAAK;EAAY,cAAY;EAAe,OA3BhC,QAA6B;GAI9C,IAAM,IAA+B,EAAE,SAAS,WAAW;GAC3D,KAAK,IAAM,CAAC,GAAM,MAAU,OAAO,QAAQ,KAAY,CAAC,CAAC,GACxD,AAAI,KAAS,SACZ,EAAK,EAAU,CAAgC,KAAK;GAGtD,OAAO;EACR,GAAG,CAAC,CAAQ,CAgB6C;YACtD,KAAW,QACX,kBAAC,GAAD;GAAuB,oBAAoB;GACzC;EACqB,CAAA;CAEpB,CAAA;AAEP"}
|