@plexui/vue 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/Badge/Badge.js +1 -1
- package/dist/es/components/Badge/Badge.js.map +1 -1
- package/dist/es/components/Button/Button.js +13 -5
- package/dist/es/components/Button/Button.js.map +1 -1
- package/dist/es/components/Button/ButtonLink.js +7 -1
- package/dist/es/components/Button/ButtonLink.js.map +1 -1
- package/dist/es/components/Button/NavigationButton.js +27 -0
- package/dist/es/components/Button/NavigationButton.js.map +1 -0
- package/dist/es/components/Button/NavigationGlyph.js +27 -0
- package/dist/es/components/Button/NavigationGlyph.js.map +1 -0
- package/dist/es/components/Button/index.js +1 -0
- package/dist/es/components/Button/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +14 -4
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/DateInput/DateInput.js +7 -3
- package/dist/es/components/DateInput/DateInput.js.map +1 -1
- package/dist/es/components/DatePicker/Calendar.js +130 -86
- package/dist/es/components/DatePicker/Calendar.js.map +1 -1
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js +31 -0
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +16 -4
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/context.js.map +1 -1
- package/dist/es/components/DatePicker/useCalendarGutter.js +14 -0
- package/dist/es/components/DatePicker/useCalendarGutter.js.map +1 -0
- package/dist/es/components/DateRangePicker/Calendar.js +92 -71
- package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +13 -4
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/Trigger.js +1 -0
- package/dist/es/components/DateRangePicker/Trigger.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +124 -52
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +77 -24
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +58 -5
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +3 -1
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FileUpload/FileUpload.js +50 -11
- package/dist/es/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +24 -13
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js +9 -3
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Disclosure.js +10 -0
- package/dist/es/components/Icon/svg/Disclosure.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +2 -2
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +15 -5
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/InputGroup/InputGroup.js +3 -1
- package/dist/es/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +126 -151
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +217 -35
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/internal.js +2 -1
- package/dist/es/components/Menu/internal.js.map +1 -1
- package/dist/es/components/OTPInput/OTPInput.js +7 -4
- package/dist/es/components/OTPInput/OTPInput.js.map +1 -1
- package/dist/es/components/Page/Page.js +93 -14
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/Page/index.js +1 -1
- package/dist/es/components/Page/index.js.map +1 -1
- package/dist/es/components/Popover/Popover.js +16 -6
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/deferredPointerDownOutside.js +6 -0
- package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
- package/dist/es/components/RadioGroup/RadioGroup.js +29 -12
- package/dist/es/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/es/components/Select/Select.js +75 -25
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +58 -25
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/SelectControl/index.js +1 -1
- package/dist/es/components/SelectControl/index.js.map +1 -1
- package/dist/es/components/ShimmerText/ShimmerText.js +16 -3
- package/dist/es/components/ShimmerText/ShimmerText.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +56 -16
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Sortable/Sortable.js +20 -13
- package/dist/es/components/Sortable/Sortable.js.map +1 -1
- package/dist/es/components/Switch/Switch.js +6 -3
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +12 -11
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +46 -6
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +13 -2
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Toast/ToastRenderer.js +144 -0
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -0
- package/dist/es/components/Toast/Toaster.js +23 -1
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +283 -0
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -0
- package/dist/es/components/Toolbar/Toolbar.js +107 -0
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -0
- package/dist/es/components/Toolbar/index.js +2 -0
- package/dist/es/components/Toolbar/index.js.map +1 -0
- package/dist/es/components/Tooltip/CopyTooltip.js +39 -13
- package/dist/es/components/Tooltip/CopyTooltip.js.map +1 -1
- package/dist/es/components/Tooltip/Tooltip.js +35 -14
- package/dist/es/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/es/composables/useFloatingBoundary.js +48 -0
- package/dist/es/composables/useFloatingBoundary.js.map +1 -0
- package/dist/es/composables/usePhoneSubmenu.js +19 -0
- package/dist/es/composables/usePhoneSubmenu.js.map +1 -0
- package/dist/es/lib/copyToClipboard.js +16 -7
- package/dist/es/lib/copyToClipboard.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +90 -0
- package/dist/es/lib/floatingBoundary.js.map +1 -0
- package/dist/es/lib/focusRestore.js +56 -0
- package/dist/es/lib/focusRestore.js.map +1 -0
- package/dist/es/lib/helpers.js +0 -18
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/inputMode.js +9 -0
- package/dist/es/lib/inputMode.js.map +1 -0
- package/dist/es/lib/menuInitialFocus.js +100 -0
- package/dist/es/lib/menuInitialFocus.js.map +1 -0
- package/dist/es/lib/menuSubmenuPlacement.js +219 -0
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -0
- package/dist/es/lib/observeTextareaWidth.js +49 -0
- package/dist/es/lib/observeTextareaWidth.js.map +1 -0
- package/dist/es/lib/selectPress.js +34 -0
- package/dist/es/lib/selectPress.js.map +1 -0
- package/dist/es/lib/sortable.js +74 -20
- package/dist/es/lib/sortable.js.map +1 -1
- package/dist/types/components/Button/Button.d.ts +6 -2
- package/dist/types/components/Button/ButtonLink.d.ts +6 -2
- package/dist/types/components/Button/NavigationButton.d.ts +27 -0
- package/dist/types/components/Button/NavigationGlyph.d.ts +16 -0
- package/dist/types/components/Button/index.d.ts +1 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +12 -12
- package/dist/types/components/DateInput/DateInput.d.ts +4 -4
- package/dist/types/components/DatePicker/CalendarNavigationIcon.d.ts +6 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +13 -13
- package/dist/types/components/DatePicker/context.d.ts +1 -0
- package/dist/types/components/DatePicker/useCalendarGutter.d.ts +2 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +13 -13
- package/dist/types/components/Dialog/Dialog.d.ts +46 -11
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +2 -2
- package/dist/types/components/FileUpload/FileUpload.d.ts +6 -6
- package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +4 -4
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Disclosure.d.ts +3 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +8 -8
- package/dist/types/components/Menu/Menu.d.ts +18 -25
- package/dist/types/components/OTPInput/OTPInput.d.ts +6 -6
- package/dist/types/components/Page/Page.d.ts +48 -7
- package/dist/types/components/Page/index.d.ts +1 -1
- package/dist/types/components/Popover/Popover.d.ts +17 -6
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +10 -10
- package/dist/types/components/SelectControl/index.d.ts +1 -1
- package/dist/types/components/Sortable/Sortable.d.ts +8 -8
- package/dist/types/components/Switch/Switch.d.ts +34 -12
- package/dist/types/components/Tabs/Tabs.d.ts +6 -6
- package/dist/types/components/TagInput/TagInput.d.ts +4 -4
- package/dist/types/components/Textarea/Textarea.d.ts +2 -2
- package/dist/types/components/Toast/ToastRenderer.d.ts +79 -0
- package/dist/types/components/Toast/Toaster.d.ts +6 -2
- package/dist/types/components/Toast/toastLifecycle.d.ts +90 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +149 -0
- package/dist/types/components/Toolbar/index.d.ts +1 -0
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +2 -2
- package/dist/types/components/Tooltip/Tooltip.d.ts +6 -6
- package/dist/types/composables/useFloatingBoundary.d.ts +24 -0
- package/dist/types/composables/usePhoneSubmenu.d.ts +3 -0
- package/dist/types/lib/floatingBoundary.d.ts +9 -0
- package/dist/types/lib/focusRestore.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +0 -4
- package/dist/types/lib/inputMode.d.ts +7 -0
- package/dist/types/lib/menuInitialFocus.d.ts +9 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +44 -0
- package/dist/types/lib/observeTextareaWidth.d.ts +2 -0
- package/dist/types/lib/selectPress.d.ts +23 -0
- package/dist/types/lib/sortable.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../../src/components/Toast/Toaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAiC,MAAM,KAAK,CAAA;AACxG,OAAO,EAAE,OAAO,IAAI,aAAa,EAA2C,MAAM,YAAY,CAAA;AAC9F,mFAAmF;AACnF,OAAO,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAEhE,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,oDAAoD;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAW,CAAA;AAMpD,MAAM,SAAS,GAAG,GAAc,EAAE,CAChC,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;AAEnF;;sDAEsD;AACtD,MAAM,YAAY,GAAG;IACnB,aAAa,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AAC,IAAI,SAAS,CAAA;YAE1D,mFAAmF;YACnF,OAAO,CAAC,CACN,aAA0B,EAC1B;gBACE,OAAO,EAAE,KAAK,CAAC,KAAK;gBACpB,UAAU,EAAE,KAAK,CAAC,QAAQ;gBAC1B,UAAU,EAAE,KAAK,CAAC,QAAQ;gBAC1B,QAAQ,EAAE,KAAK,CAAC,MAAM;gBACtB,KAAK,EAAE,KAAK,CAAC,GAAG;gBAChB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,OAAO,EAAE,YAAY;gBACrB,cAAc,EAAE,YAAY;gBAC5B,iEAAiE;gBACjE,qEAAqE;gBACrE,0EAA0E;gBAC1E,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,qEAAqE;gBACrE,sEAAsE;gBACtE,qEAAqE;gBACrE,qBAAqB,EAAE,MAAM;gBAC7B,YAAY,EAAE,SAAS;gBACvB,GAAG,KAAK;aACT,EACD,SAAS,CACV,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAWF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAkF,CAAA","sourcesContent":["import { defineComponent, h, onBeforeUnmount, onMounted, ref, type Component, type PropType } from \"vue\"\nimport { Toaster as SonnerToaster, type ToasterProps as SonnerToasterProps } from \"vue-sonner\"\n// sonner (React) injects its stylesheet on import; vue-sonner 2 ships it as a file\nimport \"vue-sonner/style.css\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Toast/Toast.module.css\"\n\n// Vue port of packages/ui/src/components/Toast/Toaster.tsx on vue-sonner, the\n// Vue port of sonner. vue-sonner names a few options differently from sonner:\n// `class` (sonner `className`), `classes` (`classNames`), `descriptionClass`\n// (`descriptionClassName`), and `toast.custom` takes a component. The type\n// icons are slots in vue-sonner (`icons` only feeds the close icon), so the\n// Plex icons and a caller's `icons` go in as slots.\n\n/**\n * Spread into any `toast(...)` options to get a shrink-to-fit, centered\n * layout: `toast(\"Saved\", compact)`, `toast.success(\"Done\", { ...compact, description })`.\n */\nexport const compact = { class: s.Compact } as const\n\ntype PlexTheme = \"light\" | \"dark\"\n\ntype ToastIcons = NonNullable<SonnerToasterProps[\"icons\"]>\n\nconst readTheme = (): PlexTheme =>\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ? \"dark\" : \"light\"\n\n/* Maps PlexUI semantic tokens onto sonner's CSS-variable hooks. Sonner's own\n stylesheet reads these for every toast, so the base look stays aligned with\n <Popover> / <Menu> without overriding each slot. */\nconst toasterStyle = {\n \"--normal-bg\": \"var(--color-surface-elevated)\",\n \"--normal-text\": \"var(--color-text)\",\n \"--normal-border\": \"transparent\",\n \"--border-radius\": \"var(--radius-xl)\",\n \"--width\": \"400px\",\n}\n\nconst toastOptions = {\n classes: {\n toast: s.Toast,\n title: s.Title,\n description: s.Description,\n content: s.Content,\n icon: s.Icon,\n actionButton: s.ActionButton,\n cancelButton: s.CancelButton,\n success: s.Success,\n error: s.Error,\n warning: s.Warning,\n info: s.Info,\n },\n}\n\nconst PLEX_ICONS = {\n success: CheckCircle,\n error: XCircle,\n warning: Warning,\n info: InfoCircle,\n} as const\n\n// sonner's close icon. vue-sonner's own misspells `stroke-width` (`stoke-width`),\n// so its X draws at the default 1px instead of 1.5px.\nconst CloseIcon = () =>\n h(\n \"svg\",\n {\n \"xmlns\": \"http://www.w3.org/2000/svg\",\n \"width\": \"12\",\n \"height\": \"12\",\n \"viewBox\": \"0 0 24 24\",\n \"fill\": \"none\",\n \"stroke\": \"currentColor\",\n \"stroke-width\": \"1.5\",\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n },\n [h(\"line\", { x1: \"18\", y1: \"6\", x2: \"6\", y2: \"18\" }), h(\"line\", { x1: \"6\", y1: \"6\", x2: \"18\", y2: \"18\" })],\n )\n\nconst ToasterComponent = defineComponent({\n name: \"Toaster\",\n inheritAttrs: false,\n props: {\n /** Where toasts anchor on the viewport. @default \"top-center\" */\n position: { type: String as PropType<SonnerToasterProps[\"position\"]>, default: \"top-center\" },\n /** Default auto-dismiss duration in ms. @default 3000 */\n duration: { type: Number, default: 3000 },\n /** Distance from the viewport edge */\n offset: [String, Number, Object] as PropType<SonnerToasterProps[\"offset\"]>,\n /** Gap between stacked toasts in px */\n gap: Number,\n },\n setup(props, { attrs, slots }) {\n const theme = ref<PlexTheme>(\"light\")\n let observer: MutationObserver | null = null\n\n onMounted(() => {\n theme.value = readTheme()\n\n observer = new MutationObserver(() => {\n theme.value = readTheme()\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-theme\"],\n })\n })\n\n onBeforeUnmount(() => observer?.disconnect())\n\n // React passes `icons={{ success: <CheckCircle aria-hidden=\"true\" />, ... }}`,\n // which a caller's `icons` replaces as a whole (sonner's own icons then)\n const iconSlot = (type: keyof typeof PLEX_ICONS) => {\n const own = slots[`${type}-icon`]\n if (own) return own\n const userIcons = attrs.icons as ToastIcons | undefined\n if (userIcons) {\n const icon = userIcons[type]\n return icon ? () => h(icon as Component) : undefined\n }\n return () => h(PLEX_ICONS[type], { \"aria-hidden\": \"true\" })\n }\n\n return () => {\n const iconSlots: Record<string, () => unknown> = {}\n for (const type of Object.keys(PLEX_ICONS) as Array<keyof typeof PLEX_ICONS>) {\n const slot = iconSlot(type)\n if (slot) iconSlots[`${type}-icon`] = slot\n }\n // sonner wraps a custom `icons.loading` in its loader box (vue-sonner\n // ignores it); the slot renders only while the toast is loading\n const loadingIcon = (attrs.icons as ToastIcons | undefined)?.loading\n if (slots[\"loading-icon\"]) iconSlots[\"loading-icon\"] = slots[\"loading-icon\"]\n else if (loadingIcon) {\n iconSlots[\"loading-icon\"] = () => h(\"div\", { \"class\": \"sonner-loader\", \"data-visible\": \"true\" }, [h(loadingIcon)])\n }\n // vue-sonner prefers `icons.close` over this slot, as sonner does over its own icon\n iconSlots[\"close-icon\"] = slots[\"close-icon\"] ?? CloseIcon\n\n // vue-sonner's prop types reject `undefined`, which it treats as \"use the default\"\n return h(\n SonnerToaster as Component,\n {\n \"theme\": theme.value,\n \"position\": props.position,\n \"duration\": props.duration,\n \"offset\": props.offset,\n \"gap\": props.gap,\n \"class\": s.Toaster,\n \"style\": toasterStyle,\n \"toastOptions\": toastOptions,\n // sonner leaves these unset, so React renders no `data-invert` /\n // `data-rich-colors`. vue-sonner defaults them to `false` and prints\n // \"false\"; `null` keeps the attributes off, as `undefined` does in React.\n \"invert\": null,\n \"richColors\": null,\n // vue-sonner binds `$attrs` last on its <ol>: React's sonner renders\n // `data-sonner-toaster=\"true\"` there and no `data-theme` (which would\n // also re-scope Plex's `:where([data-theme])` tokens at the toaster)\n \"data-sonner-toaster\": \"true\",\n \"data-theme\": undefined,\n ...attrs,\n },\n iconSlots,\n )\n }\n },\n})\n\ntype ToasterOwnProps = InstanceType<typeof ToasterComponent>[\"$props\"]\n\n/** Toaster props plus the vue-sonner `Toaster` props it forwards. */\nexport type ToasterProps = ToasterOwnProps &\n Omit<\n SonnerToasterProps,\n \"position\" | \"duration\" | \"closeButton\" | \"offset\" | \"gap\" | \"theme\" | \"richColors\" | \"toastOptions\" | \"style\"\n >\n\n/**\n * Toast viewport. Every other vue-sonner `Toaster` prop (`expand`,\n * `visible-toasts`, `hotkey`, `dir`, `swipe-directions`, ...) is forwarded,\n * last, as React spreads `restProps`. Icon slots (`success-icon`, ...,\n * `close-icon`) replace the default icons.\n */\nexport const Toaster = ToasterComponent as typeof ToasterComponent & { new (): { $props: ToasterProps } }\n"]}
|
|
1
|
+
{"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../../src/components/Toast/Toaster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAiC,MAAM,KAAK,CAAA;AACxG,OAAO,EAA2C,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,oBAAo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oF;YACpF,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,SAAS,CAAA;YAE1D,mFAAmF;YACnF,OAAO,CAAC,CACN,aAA0B,EAC1B;gBACE,OAAO,EAAE,KAAK,CAAC,KAAK;gBACpB,UAAU,EAAE,KAAK,CAAC,QAAQ;gBAC1B,UAAU,EAAE,KAAK,CAAC,QAAQ;gBAC1B,QAAQ,EAAE,KAAK,CAAC,MAAM;gBACtB,cAAc,EAAE,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC;gBACvD,KAAK,EAAE,KAAK,CAAC,GAAG;gBAChB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,OAAO,EAAE,YAAY;gBACrB,cAAc,EAAE,YAAY;gBAC5B,iEAAiE;gBACjE,qEAAqE;gBACrE,0EAA0E;gBAC1E,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,qEAAqE;gBACrE,sEAAsE;gBACtE,qEAAqE;gBACrE,qBAAqB,EAAE,MAAM;gBAC7B,YAAY,EAAE,SAAS;gBACvB,GAAG,KAAK;aACT,EACD,SAAS,CACV,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAWF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAkF,CAAA","sourcesContent":["import { defineComponent, h, onBeforeUnmount, onMounted, ref, type Component, type PropType } from \"vue\"\nimport { type ToasterProps as SonnerToasterProps } from \"vue-sonner\"\nimport { ToastRenderer as SonnerToaster } from \"./ToastRenderer.js\"\n// sonner (React) injects its stylesheet on import; vue-sonner 2 ships it as a file\nimport \"vue-sonner/style.css\"\nimport { CheckCircle, InfoCircle, Warning, XCircle } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Toast/Toast.module.css\"\n\n// Vue port of packages/ui/src/components/Toast/Toaster.tsx on vue-sonner, the\n// Vue port of sonner. vue-sonner names a few options differently from sonner:\n// `class` (sonner `className`), `classes` (`classNames`), `descriptionClass`\n// (`descriptionClassName`), and `toast.custom` takes a component. The type\n// icons are slots in vue-sonner (`icons` only feeds the close icon), so the\n// Plex icons and a caller's `icons` go in as slots.\n\n/**\n * Spread into any `toast(...)` options to get a shrink-to-fit, centered\n * layout: `toast(\"Saved\", compact)`, `toast.success(\"Done\", { ...compact, description })`.\n */\nexport const compact = { class: s.Compact } as const\n\ntype PlexTheme = \"light\" | \"dark\"\n\ntype ToastIcons = NonNullable<SonnerToasterProps[\"icons\"]>\n\nconst readTheme = (): PlexTheme =>\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ? \"dark\" : \"light\"\n\n// Keep a gutter outside the safe area; explicit offsets override each supplied\n// edge, while omitted edges retain the safe default. Sonner applies these only\n// at its mobile breakpoint, so desktop positioning is unchanged.\nconst safeMobileOffset = {\n top: \"calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))\",\n right: \"calc(16px + var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))\",\n bottom: \"calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))\",\n left: \"calc(16px + var(--safe-area-inset-left, env(safe-area-inset-left, 0px)))\",\n}\n\nconst resolveMobileOffset = (offset: SonnerToasterProps[\"mobileOffset\"]) =>\n typeof offset === \"number\" || typeof offset === \"string\"\n ? offset\n : {\n top: offset?.top ?? safeMobileOffset.top,\n right: offset?.right ?? safeMobileOffset.right,\n bottom: offset?.bottom ?? safeMobileOffset.bottom,\n left: offset?.left ?? safeMobileOffset.left,\n }\n\n/* Maps PlexUI semantic tokens onto sonner's CSS-variable hooks. Sonner's own\n stylesheet reads these for every toast, so the base look stays aligned with\n <Popover> / <Menu> without overriding each slot. */\nconst toasterStyle = {\n \"--normal-bg\": \"var(--color-surface-elevated)\",\n \"--normal-text\": \"var(--color-text)\",\n \"--normal-border\": \"transparent\",\n \"--border-radius\": \"var(--radius-xl)\",\n \"--width\": \"400px\",\n}\n\nconst toastOptions = {\n classes: {\n toast: s.Toast,\n title: s.Title,\n description: s.Description,\n content: s.Content,\n icon: s.Icon,\n actionButton: s.ActionButton,\n cancelButton: s.CancelButton,\n success: s.Success,\n error: s.Error,\n warning: s.Warning,\n info: s.Info,\n },\n}\n\nconst PLEX_ICONS = {\n success: CheckCircle,\n error: XCircle,\n warning: Warning,\n info: InfoCircle,\n} as const\n\n// sonner's close icon. vue-sonner's own misspells `stroke-width` (`stoke-width`),\n// so its X draws at the default 1px instead of 1.5px.\nconst CloseIcon = () =>\n h(\n \"svg\",\n {\n \"xmlns\": \"http://www.w3.org/2000/svg\",\n \"aria-hidden\": \"true\",\n \"width\": \"12\",\n \"height\": \"12\",\n \"viewBox\": \"0 0 24 24\",\n \"fill\": \"none\",\n \"stroke\": \"currentColor\",\n \"stroke-width\": \"1.5\",\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n },\n [h(\"line\", { x1: \"18\", y1: \"6\", x2: \"6\", y2: \"18\" }), h(\"line\", { x1: \"6\", y1: \"6\", x2: \"18\", y2: \"18\" })],\n )\n\nconst ToasterComponent = defineComponent({\n name: \"Toaster\",\n inheritAttrs: false,\n props: {\n /** Where toasts anchor on the viewport. @default \"top-center\" */\n position: { type: String as PropType<SonnerToasterProps[\"position\"]>, default: \"top-center\" },\n /** Default auto-dismiss duration in ms. @default 3000 */\n duration: { type: Number, default: 3000 },\n /** Distance from the viewport edge */\n offset: [String, Number, Object] as PropType<SonnerToasterProps[\"offset\"]>,\n /** Mobile distance from each safe viewport edge; explicit values override the default. */\n mobileOffset: [String, Number, Object] as PropType<SonnerToasterProps[\"mobileOffset\"]>,\n /** Gap between stacked toasts in px */\n gap: Number,\n },\n setup(props, { attrs, slots }) {\n const theme = ref<PlexTheme>(\"light\")\n let observer: MutationObserver | null = null\n\n onMounted(() => {\n theme.value = readTheme()\n\n observer = new MutationObserver(() => {\n theme.value = readTheme()\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: [\"data-theme\"],\n })\n })\n\n onBeforeUnmount(() => observer?.disconnect())\n\n // React passes `icons={{ success: <CheckCircle aria-hidden=\"true\" />, ... }}`,\n // which a caller's `icons` replaces as a whole (sonner's own icons then)\n const iconSlot = (type: keyof typeof PLEX_ICONS) => {\n const own = slots[`${type}-icon`]\n if (own) return own\n const userIcons = attrs.icons as ToastIcons | undefined\n if (userIcons) {\n const icon = userIcons[type]\n return icon ? () => h(icon as Component) : undefined\n }\n return () => h(PLEX_ICONS[type], { \"aria-hidden\": \"true\" })\n }\n\n return () => {\n const iconSlots: Record<string, () => unknown> = {}\n for (const type of Object.keys(PLEX_ICONS) as Array<keyof typeof PLEX_ICONS>) {\n const slot = iconSlot(type)\n if (slot) iconSlots[`${type}-icon`] = slot\n }\n // sonner wraps a custom `icons.loading` in its loader box (vue-sonner\n // ignores it); the slot renders only while the toast is loading\n const loadingIcon = (attrs.icons as ToastIcons | undefined)?.loading\n if (slots[\"loading-icon\"]) iconSlots[\"loading-icon\"] = slots[\"loading-icon\"]\n else if (loadingIcon) {\n iconSlots[\"loading-icon\"] = () => h(\"div\", { \"class\": \"sonner-loader\", \"data-visible\": \"true\" }, [h(loadingIcon)])\n }\n // vue-sonner prefers `icons.close` over this slot, as sonner does over its own icon\n iconSlots[\"close-icon\"] = slots[\"close-icon\"] ?? CloseIcon\n\n // vue-sonner's prop types reject `undefined`, which it treats as \"use the default\"\n return h(\n SonnerToaster as Component,\n {\n \"theme\": theme.value,\n \"position\": props.position,\n \"duration\": props.duration,\n \"offset\": props.offset,\n \"mobileOffset\": resolveMobileOffset(props.mobileOffset),\n \"gap\": props.gap,\n \"class\": s.Toaster,\n \"style\": toasterStyle,\n \"toastOptions\": toastOptions,\n // sonner leaves these unset, so React renders no `data-invert` /\n // `data-rich-colors`. vue-sonner defaults them to `false` and prints\n // \"false\"; `null` keeps the attributes off, as `undefined` does in React.\n \"invert\": null,\n \"richColors\": null,\n // vue-sonner binds `$attrs` last on its <ol>: React's sonner renders\n // `data-sonner-toaster=\"true\"` there and no `data-theme` (which would\n // also re-scope Plex's `:where([data-theme])` tokens at the toaster)\n \"data-sonner-toaster\": \"true\",\n \"data-theme\": undefined,\n ...attrs,\n },\n iconSlots,\n )\n }\n },\n})\n\ntype ToasterOwnProps = InstanceType<typeof ToasterComponent>[\"$props\"]\n\n/** Toaster props plus the vue-sonner `Toaster` props it forwards. */\nexport type ToasterProps = ToasterOwnProps &\n Omit<\n SonnerToasterProps,\n \"position\" | \"duration\" | \"closeButton\" | \"offset\" | \"mobileOffset\" | \"gap\" | \"theme\" | \"richColors\" | \"toastOptions\" | \"style\"\n >\n\n/**\n * Toast viewport. Every other vue-sonner `Toaster` prop (`expand`,\n * `visible-toasts`, `hotkey`, `dir`, `swipe-directions`, ...) is forwarded,\n * last, as React spreads `restProps`. Icon slots (`success-icon`, ...,\n * `close-icon`) replace the default icons.\n */\nexport const Toaster = ToasterComponent as typeof ToasterComponent & { new (): { $props: ToasterProps } }\n"]}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
const EXIT_DURATION = 200;
|
|
2
|
+
export class ToastLifecycle {
|
|
3
|
+
dismissStore;
|
|
4
|
+
notify;
|
|
5
|
+
entries = [];
|
|
6
|
+
config = { position: "top-center", duration: 3000, gap: 14, visibleToasts: 3 };
|
|
7
|
+
listeners = new Set();
|
|
8
|
+
revision = 0;
|
|
9
|
+
doc = null;
|
|
10
|
+
hidden = false;
|
|
11
|
+
hovered = false;
|
|
12
|
+
focused = false;
|
|
13
|
+
gesture;
|
|
14
|
+
previousFocus = null;
|
|
15
|
+
nodes = new Map();
|
|
16
|
+
lists = new Map();
|
|
17
|
+
suppressed = new Map();
|
|
18
|
+
lastPointerType = "";
|
|
19
|
+
constructor(dismissStore, notify) {
|
|
20
|
+
this.dismissStore = dismissStore;
|
|
21
|
+
this.notify = notify;
|
|
22
|
+
}
|
|
23
|
+
subscribe = (listener) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; };
|
|
24
|
+
snapshot = () => this.revision;
|
|
25
|
+
emit() { this.revision++; this.listeners.forEach((listener) => listener()); }
|
|
26
|
+
get expanded() { return this.hovered || this.focused; }
|
|
27
|
+
get paused() { return this.expanded || Boolean(this.gesture) || this.hidden; }
|
|
28
|
+
connect(doc) { this.doc = doc; this.hidden = doc.hidden; doc.addEventListener("visibilitychange", this.visibility); this.refreshTimers(); }
|
|
29
|
+
visibility = () => { this.hidden = Boolean(this.doc?.hidden); this.refreshTimers(); this.emit(); };
|
|
30
|
+
disconnect() {
|
|
31
|
+
this.doc?.removeEventListener("visibilitychange", this.visibility);
|
|
32
|
+
for (const entry of this.entries) {
|
|
33
|
+
clearTimeout(entry.timer);
|
|
34
|
+
clearTimeout(entry.exitTimer);
|
|
35
|
+
clearTimeout(entry.mountTimer);
|
|
36
|
+
entry.timer = undefined;
|
|
37
|
+
entry.started = undefined;
|
|
38
|
+
}
|
|
39
|
+
this.doc = null;
|
|
40
|
+
this.gesture = undefined;
|
|
41
|
+
this.hovered = false;
|
|
42
|
+
this.focused = false;
|
|
43
|
+
this.previousFocus = null;
|
|
44
|
+
}
|
|
45
|
+
sync(toasts, config) {
|
|
46
|
+
const oldDuration = this.config.duration;
|
|
47
|
+
this.config = config;
|
|
48
|
+
const incoming = toasts.filter((toast) => config.id ? toast.toasterId === config.id : !toast.toasterId);
|
|
49
|
+
const present = new Set(incoming.map((toast) => toast.id));
|
|
50
|
+
for (const entry of this.entries)
|
|
51
|
+
if (!present.has(entry.toast.id) && !entry.removed)
|
|
52
|
+
this.close(entry.toast.id, toasts.some((toast) => toast.id === entry.toast.id) ? "detach" : "external");
|
|
53
|
+
const ordered = [];
|
|
54
|
+
for (const toast of incoming) {
|
|
55
|
+
if (this.suppressed.get(toast.id) === toast)
|
|
56
|
+
continue;
|
|
57
|
+
let entry = this.entries.find((item) => item.toast.id === toast.id);
|
|
58
|
+
if (!entry) {
|
|
59
|
+
entry = { toast, removed: false, mounted: false, height: 0, x: 0, y: 0, swiping: false, remaining: toast.duration || config.duration, exitOffset: 0 };
|
|
60
|
+
const mountedEntry = entry;
|
|
61
|
+
entry.mountTimer = setTimeout(() => { mountedEntry.mounted = true; this.emit(); }, 0);
|
|
62
|
+
}
|
|
63
|
+
else if (entry.toast !== toast || entry.detached) {
|
|
64
|
+
const restart = entry.removed || entry.toast.type !== toast.type || entry.toast.duration !== toast.duration;
|
|
65
|
+
entry.toast = toast;
|
|
66
|
+
entry.detached = false;
|
|
67
|
+
// Same-id updates restart the current budget; only an actual pause
|
|
68
|
+
// subtracts elapsed time (the public Sonner store/update contract).
|
|
69
|
+
clearTimeout(entry.timer);
|
|
70
|
+
entry.timer = undefined;
|
|
71
|
+
entry.started = undefined;
|
|
72
|
+
if (restart) {
|
|
73
|
+
clearTimeout(entry.exitTimer);
|
|
74
|
+
this.pause(entry);
|
|
75
|
+
entry.removed = false;
|
|
76
|
+
entry.swipeOut = undefined;
|
|
77
|
+
entry.remaining = toast.duration || config.duration;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (this.gesture?.id === toast.id && (toast.type === "loading" || toast.dismissible === false)) {
|
|
81
|
+
this.gesture = undefined;
|
|
82
|
+
entry.swiping = false;
|
|
83
|
+
entry.x = 0;
|
|
84
|
+
entry.y = 0;
|
|
85
|
+
}
|
|
86
|
+
if (oldDuration !== config.duration && !toast.duration) {
|
|
87
|
+
this.pause(entry);
|
|
88
|
+
entry.remaining = config.duration;
|
|
89
|
+
}
|
|
90
|
+
ordered.push(entry);
|
|
91
|
+
}
|
|
92
|
+
this.entries = [...ordered, ...this.entries.filter((entry) => entry.removed && !present.has(entry.toast.id))];
|
|
93
|
+
for (const id of this.suppressed.keys())
|
|
94
|
+
if (!present.has(id))
|
|
95
|
+
this.suppressed.delete(id);
|
|
96
|
+
this.refreshTimers();
|
|
97
|
+
this.emit();
|
|
98
|
+
}
|
|
99
|
+
pause(entry) {
|
|
100
|
+
if (entry.started !== undefined)
|
|
101
|
+
entry.remaining = Math.max(0, entry.remaining - (Date.now() - entry.started));
|
|
102
|
+
clearTimeout(entry.timer);
|
|
103
|
+
entry.timer = undefined;
|
|
104
|
+
entry.started = undefined;
|
|
105
|
+
}
|
|
106
|
+
refreshTimers() {
|
|
107
|
+
for (const entry of this.entries) {
|
|
108
|
+
if (entry.removed || this.paused || entry.toast.type === "loading" || entry.remaining === Infinity) {
|
|
109
|
+
this.pause(entry);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (entry.timer !== undefined)
|
|
113
|
+
continue;
|
|
114
|
+
entry.started = Date.now();
|
|
115
|
+
entry.timer = setTimeout(() => this.close(entry.toast.id, "auto"), Math.max(0, entry.remaining));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
position(entry) { return entry.toast.position ?? this.config.position; }
|
|
119
|
+
at(position) { return this.entries.filter((entry) => this.position(entry) === position); }
|
|
120
|
+
offset(entry) {
|
|
121
|
+
if (entry.removed)
|
|
122
|
+
return entry.exitOffset;
|
|
123
|
+
const siblings = this.at(this.position(entry)).filter((item) => !item.removed);
|
|
124
|
+
return siblings.slice(0, siblings.indexOf(entry)).reduce((sum, item) => sum + item.height + this.config.gap, 0);
|
|
125
|
+
}
|
|
126
|
+
setNode(id, node) { if (node)
|
|
127
|
+
this.nodes.set(id, node);
|
|
128
|
+
else
|
|
129
|
+
this.nodes.delete(id); }
|
|
130
|
+
setList(position, node) { if (node)
|
|
131
|
+
this.lists.set(position, node);
|
|
132
|
+
else
|
|
133
|
+
this.lists.delete(position); }
|
|
134
|
+
measure(id, height) { const entry = this.entries.find((item) => item.toast.id === id); if (entry && entry.height !== height) {
|
|
135
|
+
entry.height = height;
|
|
136
|
+
this.emit();
|
|
137
|
+
} }
|
|
138
|
+
close(id, reason) {
|
|
139
|
+
const entry = this.entries.find((item) => item.toast.id === id);
|
|
140
|
+
if (!entry || entry.removed || reason === "dismiss" && (entry.toast.dismissible === false || entry.toast.type === "loading"))
|
|
141
|
+
return;
|
|
142
|
+
entry.exitOffset = this.offset(entry);
|
|
143
|
+
entry.removed = true;
|
|
144
|
+
entry.detached = reason === "detach";
|
|
145
|
+
this.pause(entry);
|
|
146
|
+
if (this.gesture?.id === id)
|
|
147
|
+
this.gesture = undefined;
|
|
148
|
+
entry.swiping = false;
|
|
149
|
+
if (reason === "dismiss" || reason === "auto" || reason === "external")
|
|
150
|
+
this.notify(reason === "external" ? "dismiss" : reason, entry.toast);
|
|
151
|
+
const node = this.nodes.get(id);
|
|
152
|
+
if (node?.contains(this.doc?.activeElement ?? null))
|
|
153
|
+
this.restoreFocus();
|
|
154
|
+
entry.exitTimer = setTimeout(() => {
|
|
155
|
+
if (reason !== "detach")
|
|
156
|
+
this.suppressed.set(id, entry.toast);
|
|
157
|
+
this.entries = this.entries.filter((item) => item !== entry);
|
|
158
|
+
if (reason !== "external" && reason !== "detach")
|
|
159
|
+
this.dismissStore(id);
|
|
160
|
+
this.emit();
|
|
161
|
+
}, EXIT_DURATION);
|
|
162
|
+
this.refreshTimers();
|
|
163
|
+
this.emit();
|
|
164
|
+
}
|
|
165
|
+
ownsFocus(target) { return target instanceof Node && [...this.lists.values()].some((list) => list.contains(target)); }
|
|
166
|
+
focusIn(event) {
|
|
167
|
+
if (!this.focused && event.relatedTarget instanceof HTMLElement && !this.ownsFocus(event.relatedTarget))
|
|
168
|
+
this.previousFocus = event.relatedTarget;
|
|
169
|
+
this.focused = true;
|
|
170
|
+
this.refreshTimers();
|
|
171
|
+
this.emit();
|
|
172
|
+
}
|
|
173
|
+
focusOut(event) {
|
|
174
|
+
if (this.ownsFocus(event.relatedTarget))
|
|
175
|
+
return;
|
|
176
|
+
this.focused = false;
|
|
177
|
+
// An intentional move to another control owns focus. Never bounce through the opener.
|
|
178
|
+
if (event.relatedTarget instanceof HTMLElement)
|
|
179
|
+
this.previousFocus = null;
|
|
180
|
+
this.refreshTimers();
|
|
181
|
+
this.emit();
|
|
182
|
+
}
|
|
183
|
+
restoreFocus() {
|
|
184
|
+
const previous = this.previousFocus;
|
|
185
|
+
this.previousFocus = null;
|
|
186
|
+
this.focused = false;
|
|
187
|
+
if (previous?.isConnected)
|
|
188
|
+
previous.focus({ preventScroll: true });
|
|
189
|
+
}
|
|
190
|
+
keyDown(event, hotkey) {
|
|
191
|
+
if (hotkey.length && hotkey.every((key) => key === event.code || (key === "altKey" && event.altKey) || (key === "ctrlKey" && event.ctrlKey) || (key === "metaKey" && event.metaKey) || (key === "shiftKey" && event.shiftKey))) {
|
|
192
|
+
const list = this.lists.values().next().value;
|
|
193
|
+
if (list) {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
list.focus({ preventScroll: true });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (event.key === "Escape" && this.ownsFocus(this.doc?.activeElement ?? null)) {
|
|
199
|
+
this.hovered = false;
|
|
200
|
+
this.restoreFocus();
|
|
201
|
+
this.refreshTimers();
|
|
202
|
+
this.emit();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
pointerEnter(event) { this.lastPointerType = event.pointerType; this.hover(event.pointerType !== "touch"); }
|
|
206
|
+
hover(value) {
|
|
207
|
+
if (value && (this.lastPointerType === "touch" || this.doc?.documentElement.dataset.input === "touch" || this.doc?.defaultView?.matchMedia?.("(hover: none) and (pointer: coarse)").matches))
|
|
208
|
+
return;
|
|
209
|
+
this.hovered = value;
|
|
210
|
+
this.refreshTimers();
|
|
211
|
+
this.emit();
|
|
212
|
+
}
|
|
213
|
+
pointerDown(id, event) {
|
|
214
|
+
this.lastPointerType = event.pointerType;
|
|
215
|
+
if (event.pointerType === "touch" && this.hovered) {
|
|
216
|
+
this.hovered = false;
|
|
217
|
+
this.refreshTimers();
|
|
218
|
+
this.emit();
|
|
219
|
+
}
|
|
220
|
+
const entry = this.entries.find((item) => item.toast.id === id);
|
|
221
|
+
if (this.gesture || !entry || entry.removed || event.button !== 0 || entry.toast.type === "loading" || entry.toast.dismissible === false)
|
|
222
|
+
return;
|
|
223
|
+
if (event.target instanceof Element && event.target.closest("button, a, input, textarea, select, [contenteditable='true']"))
|
|
224
|
+
return;
|
|
225
|
+
this.gesture = { id, pointerId: event.pointerId, x: event.clientX, y: event.clientY, started: Date.now() };
|
|
226
|
+
entry.swiping = true;
|
|
227
|
+
this.nodes.get(id)?.setPointerCapture?.(event.pointerId);
|
|
228
|
+
this.refreshTimers();
|
|
229
|
+
this.emit();
|
|
230
|
+
}
|
|
231
|
+
pointerMove(id, event) {
|
|
232
|
+
const gesture = this.gesture;
|
|
233
|
+
const entry = this.entries.find((item) => item.toast.id === id);
|
|
234
|
+
if (!gesture || gesture.id !== id || gesture.pointerId !== event.pointerId || !entry)
|
|
235
|
+
return;
|
|
236
|
+
if (this.doc?.getSelection()?.toString())
|
|
237
|
+
return;
|
|
238
|
+
const dx = event.clientX - gesture.x, dy = event.clientY - gesture.y;
|
|
239
|
+
if (!gesture.axis && Math.max(Math.abs(dx), Math.abs(dy)) > 1)
|
|
240
|
+
gesture.axis = Math.abs(dx) > Math.abs(dy) ? "x" : "y";
|
|
241
|
+
const [vertical, horizontal] = this.position(entry).split("-");
|
|
242
|
+
const allowed = this.config.swipeDirections ?? [vertical, horizontal];
|
|
243
|
+
entry.x = gesture.axis === "x" && allowed.includes(dx > 0 ? "right" : "left") ? dx : 0;
|
|
244
|
+
entry.y = gesture.axis === "y" && allowed.includes(dy > 0 ? "bottom" : "top") ? dy : 0;
|
|
245
|
+
this.emit();
|
|
246
|
+
}
|
|
247
|
+
pointerEnd(id, event, cancelled = false) {
|
|
248
|
+
const gesture = this.gesture;
|
|
249
|
+
const entry = this.entries.find((item) => item.toast.id === id);
|
|
250
|
+
if (!gesture || gesture.id !== id || gesture.pointerId !== event.pointerId || !entry)
|
|
251
|
+
return;
|
|
252
|
+
const distance = Math.max(Math.abs(entry.x), Math.abs(entry.y));
|
|
253
|
+
this.gesture = undefined;
|
|
254
|
+
entry.swiping = false;
|
|
255
|
+
if (!cancelled && (distance >= 45 || distance > 3 && distance / Math.max(1, Date.now() - gesture.started) > 0.11)) {
|
|
256
|
+
entry.swipeOut = entry.x ? entry.x > 0 ? "right" : "left" : entry.y > 0 ? "down" : "up";
|
|
257
|
+
this.close(id, "dismiss");
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
entry.x = 0;
|
|
261
|
+
entry.y = 0;
|
|
262
|
+
}
|
|
263
|
+
this.refreshTimers();
|
|
264
|
+
this.emit();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
export const offsetStyles = (offset, mobileOffset) => {
|
|
268
|
+
const style = {};
|
|
269
|
+
for (const [prefix, value, fallback] of [["--offset", offset, "32px"], ["--mobile-offset", mobileOffset, "16px"]]) {
|
|
270
|
+
for (const edge of ["top", "right", "bottom", "left"]) {
|
|
271
|
+
const size = typeof value === "object" ? value[edge] ?? fallback : value ?? fallback;
|
|
272
|
+
style[`${prefix}-${edge}`] = typeof size === "number" ? `${size}px` : size;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return style;
|
|
276
|
+
};
|
|
277
|
+
export const documentDirection = (doc) => {
|
|
278
|
+
const direction = doc?.documentElement.getAttribute("dir");
|
|
279
|
+
if (direction === "ltr" || direction === "rtl")
|
|
280
|
+
return direction;
|
|
281
|
+
return doc?.defaultView?.getComputedStyle(doc.documentElement).direction === "rtl" ? "rtl" : "ltr";
|
|
282
|
+
};
|
|
283
|
+
//# sourceMappingURL=toastLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastLifecycle.js","sourceRoot":"","sources":["../../../../src/components/Toast/toastLifecycle.ts"],"names":[],"mappings":"AASA,MAAM,aAAa,GAAG,GAAG,CAAA;AAEzB,MAAM,OAAO,cAAc;IAgBL;IAAgD;IAfpE,OAAO,GAAoB,EAAE,CAAA;IAC7B,MAAM,GAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,CAAA;IACnF,SAAS,GAAG,IAAI,GAAG,EA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GAA2B,EAAE,CAAA;IACxC,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,iBAAiB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAU,EAAE,CAAC;QAC3H,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAU,EAAE,CAAC;YAC/D,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAA;YACpF,KAAK,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;QAC5E,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAyB,EAAE,EAAE;IAC7D,MAAM,SAAS,GAAG,GAAG,EAAE,eAAe,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1D,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;IAChE,OAAO,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AACpG,CAAC,CAAA","sourcesContent":["/** Framework-independent lifecycle, mirrored in the Vue/React packages so neither\n * published port depends on the other framework. Vendor stores remain public. */\nexport type ToastId = string | number\nexport type Position = \"top-left\" | \"top-center\" | \"top-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\"\nexport type Direction = \"top\" | \"bottom\" | \"left\" | \"right\"\ntype ToastData = { id: ToastId; toasterId?: string; position?: Position; duration?: number; type?: string; dismissible?: boolean }\nexport type ToastConfig = { id?: string; position: Position; duration: number; gap: number; visibleToasts: number; expand?: boolean; swipeDirections?: Direction[] }\nexport type ToastEntry<T> = { toast: T; removed: boolean; detached?: boolean; mounted: boolean; height: number; x: number; y: number; swiping: boolean; swipeOut?: \"up\" | \"down\" | \"left\" | \"right\"; remaining: number; started?: number; timer?: ReturnType<typeof setTimeout>; exitTimer?: ReturnType<typeof setTimeout>; mountTimer?: ReturnType<typeof setTimeout>; exitOffset: number }\ntype Gesture = { id: ToastId; pointerId: number; x: number; y: number; started: number; axis?: \"x\" | \"y\" }\nconst EXIT_DURATION = 200\n\nexport class ToastLifecycle<T extends ToastData> {\n entries: ToastEntry<T>[] = []\n config: ToastConfig = { position: \"top-center\", duration: 3000, gap: 14, visibleToasts: 3 }\n private listeners = new Set<() => void>()\n private revision = 0\n private doc: Document | null = null\n private hidden = false\n private hovered = false\n private focused = false\n private gesture?: Gesture\n private previousFocus: HTMLElement | null = null\n private nodes = new Map<ToastId, HTMLElement>()\n private lists = new Map<Position, HTMLElement>()\n private suppressed = new Map<ToastId, T>()\n private lastPointerType = \"\"\n\n constructor(private dismissStore: (id: ToastId) => unknown, private notify: (reason: \"dismiss\" | \"auto\", toast: T) => void) {}\n subscribe = (listener: () => void) => { this.listeners.add(listener); return () => { this.listeners.delete(listener) } }\n snapshot = () => this.revision\n private emit() { this.revision++; this.listeners.forEach((listener) => listener()) }\n get expanded() { return this.hovered || this.focused }\n get paused() { return this.expanded || Boolean(this.gesture) || this.hidden }\n connect(doc: Document) { this.doc = doc; this.hidden = doc.hidden; doc.addEventListener(\"visibilitychange\", this.visibility); this.refreshTimers() }\n private visibility = () => { this.hidden = Boolean(this.doc?.hidden); this.refreshTimers(); this.emit() }\n disconnect() {\n this.doc?.removeEventListener(\"visibilitychange\", this.visibility)\n for (const entry of this.entries) { clearTimeout(entry.timer); clearTimeout(entry.exitTimer); clearTimeout(entry.mountTimer); entry.timer = undefined; entry.started = undefined }\n this.doc = null\n this.gesture = undefined\n this.hovered = false\n this.focused = false\n this.previousFocus = null\n }\n sync(toasts: T[], config: ToastConfig) {\n const oldDuration = this.config.duration\n this.config = config\n const incoming = toasts.filter((toast) => config.id ? toast.toasterId === config.id : !toast.toasterId)\n const present = new Set(incoming.map((toast) => toast.id))\n for (const entry of this.entries) if (!present.has(entry.toast.id) && !entry.removed) this.close(entry.toast.id, toasts.some((toast) => toast.id === entry.toast.id) ? \"detach\" : \"external\")\n const ordered: ToastEntry<T>[] = []\n for (const toast of incoming) {\n if (this.suppressed.get(toast.id) === toast) continue\n let entry = this.entries.find((item) => item.toast.id === toast.id)\n if (!entry) {\n entry = { toast, removed: false, mounted: false, height: 0, x: 0, y: 0, swiping: false, remaining: toast.duration || config.duration, exitOffset: 0 }\n const mountedEntry = entry\n entry.mountTimer = setTimeout(() => { mountedEntry.mounted = true; this.emit() }, 0)\n } else if (entry.toast !== toast || entry.detached) {\n const restart = entry.removed || entry.toast.type !== toast.type || entry.toast.duration !== toast.duration\n entry.toast = toast\n entry.detached = false\n // Same-id updates restart the current budget; only an actual pause\n // subtracts elapsed time (the public Sonner store/update contract).\n clearTimeout(entry.timer); entry.timer = undefined; entry.started = undefined\n if (restart) {\n clearTimeout(entry.exitTimer); this.pause(entry); entry.removed = false; entry.swipeOut = undefined\n entry.remaining = toast.duration || config.duration\n }\n }\n if (this.gesture?.id === toast.id && (toast.type === \"loading\" || toast.dismissible === false)) { this.gesture = undefined; entry.swiping = false; entry.x = 0; entry.y = 0 }\n if (oldDuration !== config.duration && !toast.duration) { this.pause(entry); entry.remaining = config.duration }\n ordered.push(entry)\n }\n this.entries = [...ordered, ...this.entries.filter((entry) => entry.removed && !present.has(entry.toast.id))]\n for (const id of this.suppressed.keys()) if (!present.has(id)) this.suppressed.delete(id)\n this.refreshTimers()\n this.emit()\n }\n private pause(entry: ToastEntry<T>) {\n if (entry.started !== undefined) entry.remaining = Math.max(0, entry.remaining - (Date.now() - entry.started))\n clearTimeout(entry.timer); entry.timer = undefined; entry.started = undefined\n }\n private refreshTimers() {\n for (const entry of this.entries) {\n if (entry.removed || this.paused || entry.toast.type === \"loading\" || entry.remaining === Infinity) { this.pause(entry); continue }\n if (entry.timer !== undefined) continue\n entry.started = Date.now()\n entry.timer = setTimeout(() => this.close(entry.toast.id, \"auto\"), Math.max(0, entry.remaining))\n }\n }\n position(entry: ToastEntry<T>) { return entry.toast.position ?? this.config.position }\n at(position: Position) { return this.entries.filter((entry) => this.position(entry) === position) }\n offset(entry: ToastEntry<T>) {\n if (entry.removed) return entry.exitOffset\n const siblings = this.at(this.position(entry)).filter((item) => !item.removed)\n return siblings.slice(0, siblings.indexOf(entry)).reduce((sum, item) => sum + item.height + this.config.gap, 0)\n }\n setNode(id: ToastId, node: HTMLElement | null) { if (node) this.nodes.set(id, node); else this.nodes.delete(id) }\n setList(position: Position, node: HTMLElement | null) { if (node) this.lists.set(position, node); else this.lists.delete(position) }\n measure(id: ToastId, height: number) { const entry = this.entries.find((item) => item.toast.id === id); if (entry && entry.height !== height) { entry.height = height; this.emit() } }\n close(id: ToastId, reason: \"dismiss\" | \"auto\" | \"action\" | \"external\" | \"detach\") {\n const entry = this.entries.find((item) => item.toast.id === id)\n if (!entry || entry.removed || reason === \"dismiss\" && (entry.toast.dismissible === false || entry.toast.type === \"loading\")) return\n entry.exitOffset = this.offset(entry)\n entry.removed = true\n entry.detached = reason === \"detach\"\n this.pause(entry)\n if (this.gesture?.id === id) this.gesture = undefined\n entry.swiping = false\n if (reason === \"dismiss\" || reason === \"auto\" || reason === \"external\") this.notify(reason === \"external\" ? \"dismiss\" : reason, entry.toast)\n const node = this.nodes.get(id)\n if (node?.contains(this.doc?.activeElement ?? null)) this.restoreFocus()\n entry.exitTimer = setTimeout(() => {\n if (reason !== \"detach\") this.suppressed.set(id, entry.toast)\n this.entries = this.entries.filter((item) => item !== entry)\n if (reason !== \"external\" && reason !== \"detach\") this.dismissStore(id)\n this.emit()\n }, EXIT_DURATION)\n this.refreshTimers(); this.emit()\n }\n private ownsFocus(target: EventTarget | null) { return target instanceof Node && [...this.lists.values()].some((list) => list.contains(target)) }\n focusIn(event: FocusEvent) {\n if (!this.focused && event.relatedTarget instanceof HTMLElement && !this.ownsFocus(event.relatedTarget)) this.previousFocus = event.relatedTarget\n this.focused = true; this.refreshTimers(); this.emit()\n }\n focusOut(event: FocusEvent) {\n if (this.ownsFocus(event.relatedTarget)) return\n this.focused = false\n // An intentional move to another control owns focus. Never bounce through the opener.\n if (event.relatedTarget instanceof HTMLElement) this.previousFocus = null\n this.refreshTimers(); this.emit()\n }\n private restoreFocus() {\n const previous = this.previousFocus\n this.previousFocus = null; this.focused = false\n if (previous?.isConnected) previous.focus({ preventScroll: true })\n }\n keyDown(event: KeyboardEvent, hotkey: string[]) {\n if (hotkey.length && hotkey.every((key) => key === event.code || (key === \"altKey\" && event.altKey) || (key === \"ctrlKey\" && event.ctrlKey) || (key === \"metaKey\" && event.metaKey) || (key === \"shiftKey\" && event.shiftKey))) {\n const list = this.lists.values().next().value\n if (list) { event.preventDefault(); list.focus({ preventScroll: true }) }\n } else if (event.key === \"Escape\" && this.ownsFocus(this.doc?.activeElement ?? null)) {\n this.hovered = false; this.restoreFocus(); this.refreshTimers(); this.emit()\n }\n }\n pointerEnter(event: PointerEvent) { this.lastPointerType = event.pointerType; this.hover(event.pointerType !== \"touch\") }\n hover(value: boolean) {\n if (value && (this.lastPointerType === \"touch\" || this.doc?.documentElement.dataset.input === \"touch\" || this.doc?.defaultView?.matchMedia?.(\"(hover: none) and (pointer: coarse)\").matches)) return\n this.hovered = value; this.refreshTimers(); this.emit()\n }\n pointerDown(id: ToastId, event: PointerEvent) {\n this.lastPointerType = event.pointerType\n if (event.pointerType === \"touch\" && this.hovered) { this.hovered = false; this.refreshTimers(); this.emit() }\n const entry = this.entries.find((item) => item.toast.id === id)\n if (this.gesture || !entry || entry.removed || event.button !== 0 || entry.toast.type === \"loading\" || entry.toast.dismissible === false) return\n if (event.target instanceof Element && event.target.closest(\"button, a, input, textarea, select, [contenteditable='true']\")) return\n this.gesture = { id, pointerId: event.pointerId, x: event.clientX, y: event.clientY, started: Date.now() }\n entry.swiping = true\n this.nodes.get(id)?.setPointerCapture?.(event.pointerId)\n this.refreshTimers(); this.emit()\n }\n pointerMove(id: ToastId, event: PointerEvent) {\n const gesture = this.gesture\n const entry = this.entries.find((item) => item.toast.id === id)\n if (!gesture || gesture.id !== id || gesture.pointerId !== event.pointerId || !entry) return\n if (this.doc?.getSelection()?.toString()) return\n const dx = event.clientX - gesture.x, dy = event.clientY - gesture.y\n if (!gesture.axis && Math.max(Math.abs(dx), Math.abs(dy)) > 1) gesture.axis = Math.abs(dx) > Math.abs(dy) ? \"x\" : \"y\"\n const [vertical, horizontal] = this.position(entry).split(\"-\")\n const allowed = this.config.swipeDirections ?? [vertical, horizontal]\n entry.x = gesture.axis === \"x\" && allowed.includes(dx > 0 ? \"right\" : \"left\") ? dx : 0\n entry.y = gesture.axis === \"y\" && allowed.includes(dy > 0 ? \"bottom\" : \"top\") ? dy : 0\n this.emit()\n }\n pointerEnd(id: ToastId, event: PointerEvent, cancelled = false) {\n const gesture = this.gesture\n const entry = this.entries.find((item) => item.toast.id === id)\n if (!gesture || gesture.id !== id || gesture.pointerId !== event.pointerId || !entry) return\n const distance = Math.max(Math.abs(entry.x), Math.abs(entry.y))\n this.gesture = undefined; entry.swiping = false\n if (!cancelled && (distance >= 45 || distance > 3 && distance / Math.max(1, Date.now() - gesture.started) > 0.11)) {\n entry.swipeOut = entry.x ? entry.x > 0 ? \"right\" : \"left\" : entry.y > 0 ? \"down\" : \"up\"\n this.close(id, \"dismiss\")\n } else { entry.x = 0; entry.y = 0 }\n this.refreshTimers(); this.emit()\n }\n}\n\nexport type Offset = number | string | Partial<Record<\"top\" | \"right\" | \"bottom\" | \"left\", number | string>>\nexport const offsetStyles = (offset: Offset | undefined, mobileOffset: Offset | undefined) => {\n const style: Record<string, string> = {}\n for (const [prefix, value, fallback] of [[\"--offset\", offset, \"32px\"], [\"--mobile-offset\", mobileOffset, \"16px\"]] as const) {\n for (const edge of [\"top\", \"right\", \"bottom\", \"left\"] as const) {\n const size = typeof value === \"object\" ? value[edge] ?? fallback : value ?? fallback\n style[`${prefix}-${edge}`] = typeof size === \"number\" ? `${size}px` : size\n }\n }\n return style\n}\n\nexport const documentDirection = (doc: Document | undefined) => {\n const direction = doc?.documentElement.getAttribute(\"dir\")\n if (direction === \"ltr\" || direction === \"rtl\") return direction\n return doc?.defaultView?.getComputedStyle(doc.documentElement).direction === \"rtl\" ? \"rtl\" : \"ltr\"\n}\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { defineComponent, h, inject, onBeforeUnmount, onMounted, ref, } from "vue";
|
|
2
|
+
import s from "@plexui/styles/components/Toolbar/Toolbar.module.css";
|
|
3
|
+
export const TOOLBAR_HOST = Symbol("ToolbarHost");
|
|
4
|
+
const ToolbarComponent = defineComponent({
|
|
5
|
+
name: "Toolbar",
|
|
6
|
+
props: {
|
|
7
|
+
/** @default "top" */
|
|
8
|
+
placement: { type: String, default: "top" },
|
|
9
|
+
/** Layout of `ToolbarTitle` in a top bar. @default "inline" */
|
|
10
|
+
titleStyle: { type: String, default: "inline" },
|
|
11
|
+
/** Alignment of an inline title. Compact and large titles always start at the leading edge. @default "center" */
|
|
12
|
+
titleAlign: { type: String, default: "center" },
|
|
13
|
+
/** @default "edge" */
|
|
14
|
+
background: { type: String, default: "edge" },
|
|
15
|
+
},
|
|
16
|
+
setup(props, { slots }) {
|
|
17
|
+
const host = inject(TOOLBAR_HOST, null);
|
|
18
|
+
const element = ref(null);
|
|
19
|
+
let observer;
|
|
20
|
+
let reported;
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
const bar = element.value;
|
|
23
|
+
const setHeight = host?.setHeight;
|
|
24
|
+
if (!bar || !setHeight)
|
|
25
|
+
return;
|
|
26
|
+
// A desktop layout hides the bar; its height then leaves the host's own header in charge.
|
|
27
|
+
const update = () => {
|
|
28
|
+
if (reported && reported !== props.placement)
|
|
29
|
+
setHeight(reported, undefined);
|
|
30
|
+
reported = props.placement;
|
|
31
|
+
setHeight(props.placement, bar.offsetHeight || undefined);
|
|
32
|
+
};
|
|
33
|
+
update();
|
|
34
|
+
observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : undefined;
|
|
35
|
+
observer?.observe(bar, { box: "border-box" });
|
|
36
|
+
});
|
|
37
|
+
onBeforeUnmount(() => {
|
|
38
|
+
observer?.disconnect();
|
|
39
|
+
if (reported)
|
|
40
|
+
host?.setHeight?.(reported, undefined);
|
|
41
|
+
});
|
|
42
|
+
return () => h("div", {
|
|
43
|
+
"ref": element,
|
|
44
|
+
"class": s.Toolbar,
|
|
45
|
+
"data-toolbar": "",
|
|
46
|
+
"data-placement": props.placement,
|
|
47
|
+
"data-title-style": props.placement === "top" ? props.titleStyle : undefined,
|
|
48
|
+
"data-title-align": props.placement === "top" ? props.titleAlign : undefined,
|
|
49
|
+
"data-background": props.background,
|
|
50
|
+
"data-host": host?.kind,
|
|
51
|
+
"data-scrolled": props.placement === "top" && host?.scrolled?.value ? "" : undefined,
|
|
52
|
+
}, slots.default?.());
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
/** A phone toolbar, top or bottom. It never renders at the desktop breakpoint. */
|
|
56
|
+
export const Toolbar = ToolbarComponent;
|
|
57
|
+
function part(name, className, role) {
|
|
58
|
+
return defineComponent({
|
|
59
|
+
name,
|
|
60
|
+
setup(_, { slots }) {
|
|
61
|
+
return () => h("div", { class: className, role }, slots.default?.());
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Items at the leading edge (React `Toolbar.Leading`). */
|
|
66
|
+
export const ToolbarLeading = part("ToolbarLeading", s.Leading);
|
|
67
|
+
/** Items at the trailing edge (React `Toolbar.Trailing`). */
|
|
68
|
+
export const ToolbarTrailing = part("ToolbarTrailing", s.Trailing);
|
|
69
|
+
/** Buttons that share one capsule (React `Toolbar.Group`). */
|
|
70
|
+
export const ToolbarGroup = part("ToolbarGroup", s.Group, "group");
|
|
71
|
+
/** Custom middle content: a search field, a segmented control or a single centered action (React `Toolbar.Content`). */
|
|
72
|
+
export const ToolbarContent = defineComponent({
|
|
73
|
+
name: "ToolbarContent",
|
|
74
|
+
props: {
|
|
75
|
+
/** Stretch between the leading and trailing items, as a search field does. */
|
|
76
|
+
fill: { type: Boolean, default: false },
|
|
77
|
+
},
|
|
78
|
+
setup(props, { slots }) {
|
|
79
|
+
return () => h("div", { "class": s.Content, "data-fill": props.fill ? "" : undefined }, slots.default?.());
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
/** The bar title, with an optional second line (React `Toolbar.Title`). */
|
|
83
|
+
export const ToolbarTitle = defineComponent({
|
|
84
|
+
name: "ToolbarTitle",
|
|
85
|
+
inheritAttrs: false,
|
|
86
|
+
props: {
|
|
87
|
+
/** A second, smaller line below the title. The `subtitle` slot takes precedence. */
|
|
88
|
+
subtitle: { type: String, default: undefined },
|
|
89
|
+
/**
|
|
90
|
+
* Heading level. In a Dialog the dialog's own title names the Sheet, so the bar title is hidden
|
|
91
|
+
* from assistive technology there.
|
|
92
|
+
* @default "h1"
|
|
93
|
+
*/
|
|
94
|
+
as: { type: String, default: "h1" },
|
|
95
|
+
},
|
|
96
|
+
setup(props, { slots, attrs }) {
|
|
97
|
+
const host = inject(TOOLBAR_HOST, null);
|
|
98
|
+
return () => {
|
|
99
|
+
const subtitle = slots.subtitle?.() ?? props.subtitle;
|
|
100
|
+
return h("div", { "class": s.Heading, "aria-hidden": host?.kind === "dialog" ? "true" : undefined }, [
|
|
101
|
+
h(props.as, { ...attrs, class: [s.Title, attrs.class] }, slots.default?.()),
|
|
102
|
+
subtitle != null && subtitle !== "" ? h("p", { class: s.Subtitle }, subtitle) : null,
|
|
103
|
+
]);
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=Toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toolbar.js","sourceRoot":"","sources":["../../../../src/components/Toolbar/Toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,MAAM,EACN,eAAe,EACf,SAAS,EACT,GAAG,GAKJ,MAAM,KAAK,CAAA;AACZ,OAAO,CAAC,MAAM,sDAAsD,CAAA;AAuBpE,MAAM,CAAC,MAAM,YAAY,GAA8B,MAAM,CAAC,aAAa,CAAC,CAAA;AAE5E,MAAM,gBAAgB,GAAG,eAAe,CAAC;IACvC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE;QACL,qBAAqB;QACrB,SAAS,EAAE,EAAE,IAAI,EAAE,MAAoC,EAAE,OAAO,EAAE,KAAK,EAAE;QACzE,+DAA+D;QAC/D,UAAU,EAAE,EAAE,IAAI,EAAE,MAAqC,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC9E,iHAAiH;QACjH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAqC,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC9E,sBAAsB;QACtB,UAAU,EAAE,EAAE,IAAI,EAAE,MAAqC,EAAE,OAAO,EAAE,MAAM,EAAE;KAC7E;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;QACvC,MAAM,OAAO,GAAG,GAAG,CAAqB,IAAI,CAAC,CAAA;QAC7C,IAAI,QAAoC,CAAA;QACxC,IAAI,QAAsC,CAAA;QAC1C,SAAS,CAAC,GAAG,EAAE;YACb,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAA;YACzB,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAA;YACjC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS;g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AAK,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;aACrF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n ref,\n type HTMLAttributes,\n type InjectionKey,\n type PropType,\n type Ref,\n} from \"vue\"\nimport s from \"@plexui/styles/components/Toolbar/Toolbar.module.css\"\n\n// Vue port of packages/ui/src/components/Toolbar/Toolbar.tsx. Exports are flat\n// (`ToolbarLeading` for `Toolbar.Leading`, ...).\n\nexport type ToolbarPlacement = \"top\" | \"bottom\"\n/** Title layouts of the phone top bar. */\nexport type ToolbarTitleStyle = \"inline\" | \"large\" | \"compact-large\" | \"compact-medium\"\nexport type ToolbarTitleAlign = \"center\" | \"start\"\n/** `\"edge\"` fades the canvas over content scrolled under the bar; `\"solid\"` fills the bar. */\nexport type ToolbarBackground = \"edge\" | \"solid\"\n\n/**\n * A surface that places phone toolbars: `Page` puts the top bar over its content\n * and reserves the space; `Dialog` puts it under the Sheet's grabber.\n */\nexport type ToolbarHost = {\n kind: \"page\" | \"dialog\"\n setHeight?: (placement: ToolbarPlacement, height: number | undefined) => void\n /** Content has scrolled under the top bar, so its glass casts a shadow. */\n scrolled?: Ref<boolean>\n}\n\nexport const TOOLBAR_HOST: InjectionKey<ToolbarHost> = Symbol(\"ToolbarHost\")\n\nconst ToolbarComponent = defineComponent({\n name: \"Toolbar\",\n props: {\n /** @default \"top\" */\n placement: { type: String as PropType<ToolbarPlacement>, default: \"top\" },\n /** Layout of `ToolbarTitle` in a top bar. @default \"inline\" */\n titleStyle: { type: String as PropType<ToolbarTitleStyle>, default: \"inline\" },\n /** Alignment of an inline title. Compact and large titles always start at the leading edge. @default \"center\" */\n titleAlign: { type: String as PropType<ToolbarTitleAlign>, default: \"center\" },\n /** @default \"edge\" */\n background: { type: String as PropType<ToolbarBackground>, default: \"edge\" },\n },\n setup(props, { slots }) {\n const host = inject(TOOLBAR_HOST, null)\n const element = ref<HTMLElement | null>(null)\n let observer: ResizeObserver | undefined\n let reported: ToolbarPlacement | undefined\n onMounted(() => {\n const bar = element.value\n const setHeight = host?.setHeight\n if (!bar || !setHeight) return\n // A desktop layout hides the bar; its height then leaves the host's own header in charge.\n const update = () => {\n if (reported && reported !== props.placement) setHeight(reported, undefined)\n reported = props.placement\n setHeight(props.placement, bar.offsetHeight || undefined)\n }\n update()\n observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n observer?.observe(bar, { box: \"border-box\" })\n })\n onBeforeUnmount(() => {\n observer?.disconnect()\n if (reported) host?.setHeight?.(reported, undefined)\n })\n return () => h(\"div\", {\n \"ref\": element,\n \"class\": s.Toolbar,\n \"data-toolbar\": \"\",\n \"data-placement\": props.placement,\n \"data-title-style\": props.placement === \"top\" ? props.titleStyle : undefined,\n \"data-title-align\": props.placement === \"top\" ? props.titleAlign : undefined,\n \"data-background\": props.background,\n \"data-host\": host?.kind,\n \"data-scrolled\": props.placement === \"top\" && host?.scrolled?.value ? \"\" : undefined,\n }, slots.default?.())\n },\n})\n\n/** Props of `Toolbar`. */\nexport type ToolbarProps = {\n placement?: ToolbarPlacement\n titleStyle?: ToolbarTitleStyle\n titleAlign?: ToolbarTitleAlign\n background?: ToolbarBackground\n} & HTMLAttributes\n\n/** A phone toolbar, top or bottom. It never renders at the desktop breakpoint. */\nexport const Toolbar = ToolbarComponent as typeof ToolbarComponent & { new (): { $props: ToolbarProps } }\n\nfunction part(name: string, className: string, role?: string) {\n return defineComponent({\n name,\n setup(_, { slots }) {\n return () => h(\"div\", { class: className, role }, slots.default?.())\n },\n })\n}\n\n/** Items at the leading edge (React `Toolbar.Leading`). */\nexport const ToolbarLeading = part(\"ToolbarLeading\", s.Leading)\n/** Items at the trailing edge (React `Toolbar.Trailing`). */\nexport const ToolbarTrailing = part(\"ToolbarTrailing\", s.Trailing)\n/** Buttons that share one capsule (React `Toolbar.Group`). */\nexport const ToolbarGroup = part(\"ToolbarGroup\", s.Group, \"group\")\n\n/** Custom middle content: a search field, a segmented control or a single centered action (React `Toolbar.Content`). */\nexport const ToolbarContent = defineComponent({\n name: \"ToolbarContent\",\n props: {\n /** Stretch between the leading and trailing items, as a search field does. */\n fill: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n return () => h(\"div\", { \"class\": s.Content, \"data-fill\": props.fill ? \"\" : undefined }, slots.default?.())\n },\n})\n\n/** The bar title, with an optional second line (React `Toolbar.Title`). */\nexport const ToolbarTitle = defineComponent({\n name: \"ToolbarTitle\",\n inheritAttrs: false,\n props: {\n /** A second, smaller line below the title. The `subtitle` slot takes precedence. */\n subtitle: { type: String, default: undefined },\n /**\n * Heading level. In a Dialog the dialog's own title names the Sheet, so the bar title is hidden\n * from assistive technology there.\n * @default \"h1\"\n */\n as: { type: String as PropType<\"h1\" | \"h2\" | \"h3\">, default: \"h1\" },\n },\n setup(props, { slots, attrs }) {\n const host = inject(TOOLBAR_HOST, null)\n return () => {\n const subtitle = slots.subtitle?.() ?? props.subtitle\n return h(\"div\", { \"class\": s.Heading, \"aria-hidden\": host?.kind === \"dialog\" ? \"true\" : undefined }, [\n h(props.as, { ...attrs, class: [s.Title, attrs.class] }, slots.default?.()),\n subtitle != null && subtitle !== \"\" ? h(\"p\", { class: s.Subtitle }, subtitle) : null,\n ])\n }\n },\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Toolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,GAOb,MAAM,cAAc,CAAA","sourcesContent":["export {\n Toolbar,\n ToolbarContent,\n ToolbarGroup,\n ToolbarLeading,\n ToolbarTitle,\n ToolbarTrailing,\n TOOLBAR_HOST,\n type ToolbarBackground,\n type ToolbarHost,\n type ToolbarPlacement,\n type ToolbarProps,\n type ToolbarTitleAlign,\n type ToolbarTitleStyle,\n} from \"./Toolbar.js\"\n"]}
|