@plexui/vue 0.41.1 → 0.42.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/es/components/Accordion/Accordion.js +18 -0
- package/dist/es/components/Accordion/Accordion.js.map +1 -1
- package/dist/es/components/Button/NavigationButton.js +13 -2
- package/dist/es/components/Button/NavigationButton.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +47 -3
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +45 -12
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +32 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/Icon/svg/Array.js +4 -4
- package/dist/es/components/Icon/svg/Array.js.map +1 -1
- package/dist/es/components/Icon/svg/Boolean.js +4 -4
- package/dist/es/components/Icon/svg/Boolean.js.map +1 -1
- package/dist/es/components/Icon/svg/Clipboard.js +4 -4
- package/dist/es/components/Icon/svg/Clipboard.js.map +1 -1
- package/dist/es/components/Icon/svg/Comment.js +4 -4
- package/dist/es/components/Icon/svg/Comment.js.map +1 -1
- package/dist/es/components/Icon/svg/Error.js +4 -4
- package/dist/es/components/Icon/svg/Error.js.map +1 -1
- package/dist/es/components/Icon/svg/Function.js +4 -4
- package/dist/es/components/Icon/svg/Function.js.map +1 -1
- package/dist/es/components/Icon/svg/Number.js +4 -4
- package/dist/es/components/Icon/svg/Number.js.map +1 -1
- package/dist/es/components/Icon/svg/Object.js +4 -4
- package/dist/es/components/Icon/svg/Object.js.map +1 -1
- package/dist/es/components/Icon/svg/Report.js +4 -4
- package/dist/es/components/Icon/svg/Report.js.map +1 -1
- package/dist/es/components/Icon/svg/Storage.js +4 -4
- package/dist/es/components/Icon/svg/Storage.js.map +1 -1
- package/dist/es/components/Icon/svg/String.js +4 -4
- package/dist/es/components/Icon/svg/String.js.map +1 -1
- package/dist/es/components/Icon/svg/Text.js +4 -4
- package/dist/es/components/Icon/svg/Text.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +29 -2
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/PlexUIProvider/PlexUIProvider.js +43 -3
- package/dist/es/components/PlexUIProvider/PlexUIProvider.js.map +1 -1
- package/dist/es/components/PlexUIProvider/androidRipple.js +98 -0
- package/dist/es/components/PlexUIProvider/androidRipple.js.map +1 -0
- package/dist/es/components/PlexUIProvider/index.js.map +1 -1
- package/dist/es/components/Select/Select.js +364 -22
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +8 -1
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Sidebar/index.js +1 -1
- package/dist/es/components/Sidebar/index.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +276 -17
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/components/Toolbar/index.js.map +1 -1
- package/dist/es/lib/accordionMotion.js +144 -0
- package/dist/es/lib/accordionMotion.js.map +1 -0
- package/dist/es/lib/fieldRow.js +54 -0
- package/dist/es/lib/fieldRow.js.map +1 -1
- package/dist/es/lib/presentMotion.js +151 -0
- package/dist/es/lib/presentMotion.js.map +1 -0
- package/dist/types/components/Button/NavigationButton.d.ts +30 -1
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +8 -8
- package/dist/types/components/Field/Field.d.ts +12 -2
- package/dist/types/components/FloatingLabelSelect/FloatingLabelSelect.d.ts +1 -1
- package/dist/types/components/Icon/svg/Array.d.ts +2 -2
- package/dist/types/components/Icon/svg/Boolean.d.ts +2 -2
- package/dist/types/components/Icon/svg/Clipboard.d.ts +2 -2
- package/dist/types/components/Icon/svg/Comment.d.ts +2 -2
- package/dist/types/components/Icon/svg/Error.d.ts +2 -2
- package/dist/types/components/Icon/svg/Function.d.ts +2 -2
- package/dist/types/components/Icon/svg/Number.d.ts +2 -2
- package/dist/types/components/Icon/svg/Object.d.ts +2 -2
- package/dist/types/components/Icon/svg/Report.d.ts +2 -2
- package/dist/types/components/Icon/svg/Storage.d.ts +2 -2
- package/dist/types/components/Icon/svg/String.d.ts +2 -2
- package/dist/types/components/Icon/svg/Text.d.ts +2 -2
- package/dist/types/components/PlexUIProvider/PlexUIProvider.d.ts +20 -3
- package/dist/types/components/PlexUIProvider/androidRipple.d.ts +9 -0
- package/dist/types/components/PlexUIProvider/index.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +51 -0
- package/dist/types/components/Sidebar/Sidebar.d.ts +20 -0
- package/dist/types/components/Sidebar/index.d.ts +2 -2
- package/dist/types/components/Sidebar/useSidebarContext.d.ts +1 -1
- package/dist/types/components/TabBar/TabBar.d.ts +4 -4
- package/dist/types/components/Toast/Toaster.d.ts +1 -1
- package/dist/types/components/Toolbar/Toolbar.d.ts +49 -12
- package/dist/types/components/Toolbar/index.d.ts +1 -1
- package/dist/types/lib/accordionMotion.d.ts +20 -0
- package/dist/types/lib/fieldRow.d.ts +12 -0
- package/dist/types/lib/presentMotion.d.ts +46 -0
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@ import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, provi
|
|
|
2
2
|
import { AccordionHeader as RekaAccordionHeader, AccordionItem as RekaAccordionItem, AccordionRoot as RekaAccordionRoot, Presence, injectAccordionItemContext, injectCollapsibleRootContext, useDirection, useId, } from "reka-ui";
|
|
3
3
|
import { ChevronDownMd } from "../Icon/index.js";
|
|
4
4
|
import s from "@plexui/styles/components/Accordion/Accordion.module.css";
|
|
5
|
+
import { attachAccordionMotion } from "../../lib/accordionMotion.js";
|
|
5
6
|
const AccordionContextKey = Symbol("PlexUIAccordion");
|
|
6
7
|
const useAccordionContext = () => {
|
|
7
8
|
const context = inject(AccordionContextKey, null);
|
|
@@ -45,6 +46,22 @@ export const Accordion = defineComponent({
|
|
|
45
46
|
"update:value": (_value) => true,
|
|
46
47
|
},
|
|
47
48
|
setup(props, { attrs, slots, emit }) {
|
|
49
|
+
// What follows an item slides as it opens and closes (lib/accordionMotion), on the root Reka renders, again
|
|
50
|
+
// when a new `type` remounts it
|
|
51
|
+
let motionRoot = null;
|
|
52
|
+
let detachMotion;
|
|
53
|
+
const setMotionRoot = (instance) => {
|
|
54
|
+
const element = instance?.$el;
|
|
55
|
+
const next = element instanceof HTMLElement ? element : null;
|
|
56
|
+
if (next === motionRoot)
|
|
57
|
+
return;
|
|
58
|
+
detachMotion?.();
|
|
59
|
+
detachMotion = undefined;
|
|
60
|
+
motionRoot = next;
|
|
61
|
+
if (next)
|
|
62
|
+
detachMotion = attachAccordionMotion(next, { root: s.Root, item: s.Item, content: s.Content });
|
|
63
|
+
};
|
|
64
|
+
onBeforeUnmount(() => setMotionRoot(null));
|
|
48
65
|
const isMultiple = () => props.type === "multiple";
|
|
49
66
|
const internalValue = ref(props.defaultValue ?? (isMultiple() ? [] : ""));
|
|
50
67
|
const controlledValue = () => props.value;
|
|
@@ -170,6 +187,7 @@ export const Accordion = defineComponent({
|
|
|
170
187
|
return h(RekaAccordionRoot, {
|
|
171
188
|
...restAttrs,
|
|
172
189
|
"key": props.type,
|
|
190
|
+
"ref": setMotionRoot,
|
|
173
191
|
"class": [s.Root, className],
|
|
174
192
|
"type": props.type,
|
|
175
193
|
// Reka reads the open item(s) from here; `null` is "none open" in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../../src/components/Accordion/Accordion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,OAAO,GAKR,MAAM,KAAK,CAAA;AACZ,OAAO,EACL,eAAe,IAAI,mBAAmB,EACtC,aAAa,IAAI,iBAAiB,EAClC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,EACR,0BAA0B,EAC1B,4BAA4B,EAC5B,YAAY,E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nmount,\n onMounted,\n provide,\n ref,\n toRef,\n watch,\n withCtx,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type InjectionKey,\n type PropType,\n} from \"vue\"\nimport {\n AccordionHeader as RekaAccordionHeader,\n AccordionItem as RekaAccordionItem,\n AccordionRoot as RekaAccordionRoot,\n Presence,\n injectAccordionItemContext,\n injectCollapsibleRootContext,\n useDirection,\n useId,\n} from \"reka-ui\"\nimport { ChevronDownMd } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Accordion/Accordion.module.css\"\n\n// Vue port of packages/ui/src/components/Accordion/Accordion.tsx. React\n// builds on Radix Accordion; this builds on Reka UI's (same anatomy) and\n// renders the same DOM. Exports are flat (`Accordion`, `AccordionItem`,\n// `AccordionTrigger`, `AccordionContent`) because runtime-compiled templates\n// cannot resolve `Accordion.Item` from the `components` option.\n//\n// Reka's root, item and header parts are used as they are. The trigger,\n// the content panel and the value state follow Radix where Reka differs:\n// - value: single mode emits \"\" (not undefined) when the open item closes,\n// and only emits real changes. `value` + `update:value` mirror React's\n// `value` / `onValueChange` (`v-model:value`).\n// - trigger: `aria-disabled` marks the open item of a non-collapsible\n// single accordion (Reka marks disabled items), and a `click` listener\n// that calls preventDefault() cancels the toggle (composeEventHandlers).\n// - keyboard: Radix's roving focus on the root: Home/End go to the first and\n// last *enabled* trigger, arrows across the orientation are swallowed, and\n// the root's own `keydown` listener runs first and can cancel it.\n// - content: Radix's CollapsibleContent (hidden-but-mounted when closed,\n// mount animation suppressed, exit animation kept via Presence) with the\n// `--radix-accordion-content-height` variable the shared CSS animates.\n\ntype AccordionType = \"single\" | \"multiple\"\ntype AccordionValue = string | string[]\ntype Orientation = \"vertical\" | \"horizontal\"\n\ntype AccordionContextValue = {\n orientation: () => Orientation\n /** Whether the open item may close (always true in multiple mode) */\n collapsible: () => boolean\n onItemOpen: (value: string) => void\n onItemClose: (value: string) => void\n /** Trigger buttons, for keyboard navigation (Radix's collection) */\n triggers: Set<HTMLButtonElement>\n}\n\nconst AccordionContextKey: InjectionKey<AccordionContextValue> = Symbol(\"PlexUIAccordion\")\n\nconst useAccordionContext = () => {\n const context = inject(AccordionContextKey, null)\n if (!context) {\n throw new Error(\"Accordion parts must be used inside <Accordion>\")\n }\n return context\n}\n\nconst ACCORDION_KEYS = [\"Home\", \"End\", \"ArrowDown\", \"ArrowUp\", \"ArrowLeft\", \"ArrowRight\"]\n\n// Calls a listener from `attrs` (a function or an array of them)\nconst invoke = (handler: unknown, event: Event) => {\n for (const fn of ([] as unknown[]).concat(handler ?? [])) {\n if (typeof fn === \"function\") fn(event)\n }\n}\n\nconst getState = (open: boolean) => (open ? \"open\" : \"closed\")\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport const Accordion = defineComponent({\n name: \"Accordion\",\n inheritAttrs: false,\n props: {\n /** Whether one item or many can be open at a time */\n type: { type: String as PropType<AccordionType>, required: true },\n /** Controlled open item(s) (`v-model:value`): a string for `single`, an array for `multiple` */\n value: { type: [String, Array] as PropType<AccordionValue>, default: undefined },\n /** Open item(s) when uncontrolled */\n defaultValue: { type: [String, Array] as PropType<AccordionValue>, default: undefined },\n /** When `type=\"single\"`, allow closing the open item. @default false */\n collapsible: { type: Boolean, default: false },\n /** Disable every item. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Reading direction, for horizontal arrow keys. @default \"ltr\" */\n dir: String as PropType<\"ltr\" | \"rtl\">,\n /** Layout axis. @default \"vertical\" */\n orientation: { type: String as PropType<Orientation>, default: \"vertical\" },\n },\n emits: {\n \"update:value\": (_value: AccordionValue) => true,\n },\n setup(props, { attrs, slots, emit }) {\n const isMultiple = () => props.type === \"multiple\"\n const internalValue = ref<AccordionValue>(props.defaultValue ?? (isMultiple() ? [] : \"\"))\n const controlledValue = () => props.value\n const currentValue = computed(() => controlledValue() ?? internalValue.value)\n // Radix's useControllableState: a controlled change is reported at once,\n // from the click, when it differs from `value`. An uncontrolled one is\n // reported from an effect, once the accordion has rendered it (so a\n // listener finds the opened panel's content), when it differs from the\n // last value reported.\n let reportedValue = internalValue.value\n watch(\n internalValue,\n (value) => {\n if (value === reportedValue) return\n reportedValue = value\n emit(\"update:value\", value)\n },\n { flush: \"post\" },\n )\n\n // React swaps the single and multiple implementations when `type`\n // changes: the accordion remounts from `defaultValue` (see the `key` below)\n watch(\n () => props.type,\n () => {\n internalValue.value = props.defaultValue ?? (isMultiple() ? [] : \"\")\n reportedValue = internalValue.value\n },\n )\n\n const setValue = (next: AccordionValue) => {\n const controlled = controlledValue()\n if (controlled === undefined) internalValue.value = next\n else if (next !== controlled) emit(\"update:value\", next)\n }\n\n const asArray = (value: AccordionValue | undefined) => (Array.isArray(value) ? value : [])\n\n const triggers = new Set<HTMLButtonElement>()\n provide(AccordionContextKey, {\n orientation: () => props.orientation,\n collapsible: () => isMultiple() || props.collapsible,\n onItemOpen: (itemValue) => setValue(isMultiple() ? [...asArray(currentValue.value), itemValue] : itemValue),\n onItemClose: (itemValue) => {\n if (isMultiple()) setValue(asArray(currentValue.value).filter((value) => value !== itemValue))\n else if (props.collapsible) setValue(\"\")\n },\n triggers,\n })\n\n const direction = useDirection(toRef(props, \"dir\"))\n\n // Radix's AccordionImpl key handling, on the root like in React\n const handleKeyDown = (event: KeyboardEvent) => {\n invoke(attrs.onKeydown, event)\n if (event.defaultPrevented) return\n if (!ACCORDION_KEYS.includes(event.key)) return\n const target = event.target as HTMLElement\n const triggerCollection = Array.from(triggers)\n .sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1))\n .filter((trigger) => !trigger.disabled)\n const triggerIndex = triggerCollection.findIndex((trigger) => trigger === target)\n const triggerCount = triggerCollection.length\n\n if (triggerIndex === -1) return\n\n // Prevents page scroll while user is navigating\n event.preventDefault()\n\n let nextIndex = triggerIndex\n const homeIndex = 0\n const endIndex = triggerCount - 1\n const isDirectionLTR = direction.value === \"ltr\"\n const { orientation } = props\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1\n if (nextIndex > endIndex) {\n nextIndex = homeIndex\n }\n }\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1\n if (nextIndex < homeIndex) {\n nextIndex = endIndex\n }\n }\n\n switch (event.key) {\n case \"Home\":\n nextIndex = homeIndex\n break\n case \"End\":\n nextIndex = endIndex\n break\n case \"ArrowRight\":\n if (orientation === \"horizontal\") {\n if (isDirectionLTR) {\n moveNext()\n } else {\n movePrev()\n }\n }\n break\n case \"ArrowDown\":\n if (orientation === \"vertical\") {\n moveNext()\n }\n break\n case \"ArrowLeft\":\n if (orientation === \"horizontal\") {\n if (isDirectionLTR) {\n movePrev()\n } else {\n moveNext()\n }\n }\n break\n case \"ArrowUp\":\n if (orientation === \"vertical\") {\n movePrev()\n }\n break\n }\n\n const clampedIndex = nextIndex % triggerCount\n triggerCollection[clampedIndex]?.focus()\n }\n\n return () => {\n const { class: className, onKeydown: _onKeydown, ...restAttrs } = attrs\n const value = currentValue.value\n return h(\n RekaAccordionRoot,\n {\n ...restAttrs,\n \"key\": props.type,\n \"class\": [s.Root, className],\n \"type\": props.type,\n // Reka reads the open item(s) from here; `null` is \"none open\" in\n // single mode (an empty string would open an item whose value is \"\")\n \"modelValue\": (isMultiple() ? asArray(value) : value || null) as AccordionValue,\n \"collapsible\": props.collapsible,\n \"disabled\": props.disabled,\n \"dir\": props.dir,\n \"orientation\": props.orientation,\n \"data-orientation\": props.orientation,\n // A disabled root drops the root's own keydown listener too, as in Radix\n \"onKeydown\": props.disabled ? undefined : handleKeyDown,\n },\n { default: () => slots.default?.() },\n )\n }\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\nexport const AccordionItem = defineComponent({\n name: \"AccordionItem\",\n props: {\n /** Unique identifier used by the root's `value` / `default-value` */\n value: { type: String, required: true },\n /** Disable this item. @default false */\n disabled: { type: Boolean, default: undefined },\n },\n setup(props, { slots }) {\n const context = useAccordionContext()\n // Other attributes (and `class`) fall through to the item <div>\n return () =>\n h(\n RekaAccordionItem,\n {\n \"value\": props.value,\n \"disabled\": props.disabled,\n \"class\": s.Item,\n // Reka reads the orientation once; keep it reactive\n \"data-orientation\": context.orientation(),\n },\n { default: () => slots.default?.() },\n )\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\n/** The item's <h3> header and <button>. Attributes and listeners go to the button. */\nexport const AccordionTrigger = defineComponent({\n name: \"AccordionTrigger\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const context = useAccordionContext()\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n // Set before the first render so aria-controls / aria-labelledby always\n // point at each other, like Radix's ids from the item\n itemContext.triggerId ||= useId(undefined, \"reka-accordion-trigger\")\n collapsibleContext.contentId ||= useId(undefined, \"reka-collapsible-content\")\n\n const buttonRef = ref<HTMLButtonElement | null>(null)\n onMounted(() => {\n if (buttonRef.value) context.triggers.add(buttonRef.value)\n })\n onBeforeUnmount(() => {\n if (buttonRef.value) context.triggers.delete(buttonRef.value)\n })\n\n const handleClick = (event: MouseEvent) => {\n // A disabled <button> never dispatches click in the browser, nor in React\n if (itemContext.disabled.value) return\n invoke(attrs.onClick, event)\n if (event.defaultPrevented) return\n const value = itemContext.value.value\n if (itemContext.open.value) context.onItemClose(value)\n else context.onItemOpen(value)\n }\n\n return () => {\n const { class: className, onClick: _onClick, ...restAttrs } = attrs\n const open = itemContext.open.value\n const disabled = itemContext.disabled.value\n return h(\n RekaAccordionHeader,\n { \"class\": s.Header, \"data-orientation\": context.orientation() },\n {\n default: () => [\n h(\n \"button\",\n {\n \"type\": \"button\",\n // Radix (radix-ui 1.8) points at the panel only while open\n \"aria-controls\": open ? collapsibleContext.contentId : undefined,\n \"aria-expanded\": open || false,\n \"data-state\": getState(open),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"disabled\": disabled,\n \"aria-disabled\": (open && !context.collapsible()) || undefined,\n \"data-orientation\": context.orientation(),\n \"id\": itemContext.triggerId,\n ...restAttrs,\n \"class\": [s.Trigger, className],\n \"ref\": buttonRef,\n \"onClick\": handleClick,\n },\n [slots.default?.(), h(ChevronDownMd, { \"class\": s.Chevron, \"aria-hidden\": true })],\n ),\n ],\n },\n )\n }\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\n// Radix's CollapsibleContentImpl: measures the panel for the height\n// variables, keeps it mounted (hidden, empty) while closed, and suppresses\n// the open animation of an item that mounts open.\nconst AccordionContentImpl = defineComponent({\n name: \"AccordionContentImpl\",\n inheritAttrs: false,\n props: {\n present: { type: Boolean, required: true },\n asChild: { type: Boolean, required: true },\n },\n setup(props, { attrs, slots }) {\n const context = useAccordionContext()\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n\n const node = ref<HTMLDivElement | null>(null)\n const isPresent = ref(props.present)\n // Plain values, read on render like Radix's refs\n let height = 0\n let width = 0\n const isOpen = () => itemContext.open.value || isPresent.value\n let isMountAnimationPrevented = isOpen()\n let originalStyles: { transitionDuration: string; animationName: string } | undefined\n\n let frame: number | undefined\n onMounted(() => {\n frame = requestAnimationFrame(() => (isMountAnimationPrevented = false))\n })\n onBeforeUnmount(() => {\n if (frame !== undefined) cancelAnimationFrame(frame)\n })\n\n const measure = () => {\n const element = node.value\n if (!element) return\n originalStyles = originalStyles || {\n transitionDuration: element.style.transitionDuration,\n animationName: element.style.animationName,\n }\n // block any animations/transitions so the element renders at its full dimensions\n element.style.transitionDuration = \"0s\"\n element.style.animationName = \"none\"\n\n // get width and height from full dimensions\n const rect = element.getBoundingClientRect()\n height = rect.height\n width = rect.width\n\n // kick off any animations/transitions that were originally set up if it isn't the initial mount\n if (!isMountAnimationPrevented) {\n element.style.transitionDuration = originalStyles.transitionDuration\n element.style.animationName = originalStyles.animationName\n }\n\n isPresent.value = props.present\n }\n onMounted(measure)\n watch(() => [itemContext.open.value, props.present], measure, { flush: \"post\" })\n\n return () => {\n const { class: className, style, ...restAttrs } = attrs\n const open = itemContext.open.value\n const showContent = isOpen()\n const panel = {\n \"data-state\": getState(open),\n \"data-disabled\": itemContext.disabled.value ? \"\" : undefined,\n \"id\": collapsibleContext.contentId,\n \"hidden\": !showContent,\n \"role\": \"region\",\n \"aria-labelledby\": itemContext.triggerId,\n \"data-orientation\": context.orientation(),\n ...restAttrs,\n \"class\": [s.Content, className],\n \"ref\": node,\n \"style\": [\n {\n \"--radix-collapsible-content-height\": height ? `${height}px` : undefined,\n \"--radix-collapsible-content-width\": width ? `${width}px` : undefined,\n \"--radix-accordion-content-height\": \"var(--radix-collapsible-content-height)\",\n \"--radix-accordion-content-width\": \"var(--radix-collapsible-content-width)\",\n },\n style,\n ],\n }\n // `asChild`: Radix's Slot merges the panel onto the inner element,\n // which only renders while the panel shows\n if (props.asChild) {\n return showContent ? h(\"div\", { ...panel, class: [s.Content, className, s.ContentInner] }, slots.default?.()) : null\n }\n return h(\"div\", panel, showContent ? [h(\"div\", { class: s.ContentInner }, slots.default?.())] : undefined)\n }\n },\n})\n\n/** The collapsible panel. Attributes go to the panel <div>. */\nexport const AccordionContent = defineComponent({\n name: \"AccordionContent\",\n inheritAttrs: false,\n props: {\n /** Keep the panel mounted and visible while closed (for custom CSS or JS animations) */\n forceMount: { type: Boolean, default: undefined },\n /**\n * Merge the panel onto its inner element instead of wrapping it, as\n * React's `asChild` does; a closed panel then renders nothing\n */\n asChild: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n collapsibleContext.contentId ||= useId(undefined, \"reka-collapsible-content\")\n itemContext.triggerId ||= useId(undefined, \"reka-accordion-trigger\")\n\n return () =>\n h(\n Presence,\n { present: !!props.forceMount || itemContext.open.value, forceMount: true },\n {\n // Presence calls its slot once during setup; withCtx marks it as a\n // render slot (returning an array, like compiled slots) so Vue does\n // not warn about that call\n default: withCtx(({ present }: { present: boolean }) => [\n h(AccordionContentImpl, { ...attrs, present, asChild: props.asChild }, { default: () => slots.default?.() }),\n ]),\n },\n )\n },\n})\n\ntype AccordionOwnProps = InstanceType<typeof Accordion>[\"$props\"]\ntype AccordionItemOwnProps = InstanceType<typeof AccordionItem>[\"$props\"]\ntype AccordionContentOwnProps = InstanceType<typeof AccordionContent>[\"$props\"]\n\n/** Accordion props plus the attributes that fall through to the root `<div>`, as in React. */\nexport type AccordionProps = AccordionOwnProps & Omit<HTMLAttributes, keyof AccordionOwnProps>\n\n/** AccordionItem props plus the attributes that fall through to the item `<div>`. */\nexport type AccordionItemProps = AccordionItemOwnProps & Omit<HTMLAttributes, keyof AccordionItemOwnProps>\n\n/** AccordionTrigger takes the attributes of its `<button>`. */\nexport type AccordionTriggerProps = ButtonHTMLAttributes\n\n/** AccordionContent props plus the attributes of the panel `<div>`. */\nexport type AccordionContentProps = AccordionContentOwnProps & Omit<HTMLAttributes, keyof AccordionContentOwnProps>\n"]}
|
|
1
|
+
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../../../src/components/Accordion/Accordion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,OAAO,GAKR,MAAM,KAAK,CAAA;AACZ,OAAO,EACL,eAAe,IAAI,mBAAmB,EACtC,aAAa,IAAI,iBAAiB,EAClC,aAAa,IAAI,iBAAiB,EAClC,QAAQ,EACR,0BAA0B,EAC1B,4BAA4B,EAC5B,YAAY,EACZ,KAAK,GACN,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,CAAC,MAAM,0DAA0D,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAqCpE,MAAM,mBAAmB,GAAwC,MAAM,CAAC,iBAAiB,CAA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,CAAC,CACC,QAAQ,EACR,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAC3E;YACE,mEAAmE;YACnE,oEAAoE;YACpE,2BAA2B;YAC3B,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,EAAwB,EAAE,EAAE,CAAC;gBACtD,CAAC,CAAC,oBAAoB,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC;aAC7G,CAAC;SACH,CACF,CAAA;IACL,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n computed,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n toRef,\n watch,\n withCtx,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type InjectionKey,\n type PropType,\n} from \"vue\"\nimport {\n AccordionHeader as RekaAccordionHeader,\n AccordionItem as RekaAccordionItem,\n AccordionRoot as RekaAccordionRoot,\n Presence,\n injectAccordionItemContext,\n injectCollapsibleRootContext,\n useDirection,\n useId,\n} from \"reka-ui\"\nimport { ChevronDownMd } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Accordion/Accordion.module.css\"\nimport { attachAccordionMotion } from \"../../lib/accordionMotion.js\"\n\n// Vue port of packages/ui/src/components/Accordion/Accordion.tsx. React\n// builds on Radix Accordion; this builds on Reka UI's (same anatomy) and\n// renders the same DOM. Exports are flat (`Accordion`, `AccordionItem`,\n// `AccordionTrigger`, `AccordionContent`) because runtime-compiled templates\n// cannot resolve `Accordion.Item` from the `components` option.\n//\n// Reka's root, item and header parts are used as they are. The trigger,\n// the content panel and the value state follow Radix where Reka differs:\n// - value: single mode emits \"\" (not undefined) when the open item closes,\n// and only emits real changes. `value` + `update:value` mirror React's\n// `value` / `onValueChange` (`v-model:value`).\n// - trigger: `aria-disabled` marks the open item of a non-collapsible\n// single accordion (Reka marks disabled items), and a `click` listener\n// that calls preventDefault() cancels the toggle (composeEventHandlers).\n// - keyboard: Radix's roving focus on the root: Home/End go to the first and\n// last *enabled* trigger, arrows across the orientation are swallowed, and\n// the root's own `keydown` listener runs first and can cancel it.\n// - content: Radix's CollapsibleContent (hidden-but-mounted when closed,\n// mount animation suppressed, exit animation kept via Presence) with the\n// `--radix-accordion-content-height` variable the shared CSS animates.\n\ntype AccordionType = \"single\" | \"multiple\"\ntype AccordionValue = string | string[]\ntype Orientation = \"vertical\" | \"horizontal\"\n\ntype AccordionContextValue = {\n orientation: () => Orientation\n /** Whether the open item may close (always true in multiple mode) */\n collapsible: () => boolean\n onItemOpen: (value: string) => void\n onItemClose: (value: string) => void\n /** Trigger buttons, for keyboard navigation (Radix's collection) */\n triggers: Set<HTMLButtonElement>\n}\n\nconst AccordionContextKey: InjectionKey<AccordionContextValue> = Symbol(\"PlexUIAccordion\")\n\nconst useAccordionContext = () => {\n const context = inject(AccordionContextKey, null)\n if (!context) {\n throw new Error(\"Accordion parts must be used inside <Accordion>\")\n }\n return context\n}\n\nconst ACCORDION_KEYS = [\"Home\", \"End\", \"ArrowDown\", \"ArrowUp\", \"ArrowLeft\", \"ArrowRight\"]\n\n// Calls a listener from `attrs` (a function or an array of them)\nconst invoke = (handler: unknown, event: Event) => {\n for (const fn of ([] as unknown[]).concat(handler ?? [])) {\n if (typeof fn === \"function\") fn(event)\n }\n}\n\nconst getState = (open: boolean) => (open ? \"open\" : \"closed\")\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport const Accordion = defineComponent({\n name: \"Accordion\",\n inheritAttrs: false,\n props: {\n /** Whether one item or many can be open at a time */\n type: { type: String as PropType<AccordionType>, required: true },\n /** Controlled open item(s) (`v-model:value`): a string for `single`, an array for `multiple` */\n value: { type: [String, Array] as PropType<AccordionValue>, default: undefined },\n /** Open item(s) when uncontrolled */\n defaultValue: { type: [String, Array] as PropType<AccordionValue>, default: undefined },\n /** When `type=\"single\"`, allow closing the open item. @default false */\n collapsible: { type: Boolean, default: false },\n /** Disable every item. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Reading direction, for horizontal arrow keys. @default \"ltr\" */\n dir: String as PropType<\"ltr\" | \"rtl\">,\n /** Layout axis. @default \"vertical\" */\n orientation: { type: String as PropType<Orientation>, default: \"vertical\" },\n },\n emits: {\n \"update:value\": (_value: AccordionValue) => true,\n },\n setup(props, { attrs, slots, emit }) {\n // What follows an item slides as it opens and closes (lib/accordionMotion), on the root Reka renders, again\n // when a new `type` remounts it\n let motionRoot: HTMLElement | null = null\n let detachMotion: (() => void) | undefined\n const setMotionRoot = (instance: unknown) => {\n const element = (instance as { $el?: unknown } | null)?.$el\n const next = element instanceof HTMLElement ? element : null\n if (next === motionRoot) return\n detachMotion?.()\n detachMotion = undefined\n motionRoot = next\n if (next) detachMotion = attachAccordionMotion(next, { root: s.Root, item: s.Item, content: s.Content })\n }\n onBeforeUnmount(() => setMotionRoot(null))\n\n const isMultiple = () => props.type === \"multiple\"\n const internalValue = ref<AccordionValue>(props.defaultValue ?? (isMultiple() ? [] : \"\"))\n const controlledValue = () => props.value\n const currentValue = computed(() => controlledValue() ?? internalValue.value)\n // Radix's useControllableState: a controlled change is reported at once,\n // from the click, when it differs from `value`. An uncontrolled one is\n // reported from an effect, once the accordion has rendered it (so a\n // listener finds the opened panel's content), when it differs from the\n // last value reported.\n let reportedValue = internalValue.value\n watch(\n internalValue,\n (value) => {\n if (value === reportedValue) return\n reportedValue = value\n emit(\"update:value\", value)\n },\n { flush: \"post\" },\n )\n\n // React swaps the single and multiple implementations when `type`\n // changes: the accordion remounts from `defaultValue` (see the `key` below)\n watch(\n () => props.type,\n () => {\n internalValue.value = props.defaultValue ?? (isMultiple() ? [] : \"\")\n reportedValue = internalValue.value\n },\n )\n\n const setValue = (next: AccordionValue) => {\n const controlled = controlledValue()\n if (controlled === undefined) internalValue.value = next\n else if (next !== controlled) emit(\"update:value\", next)\n }\n\n const asArray = (value: AccordionValue | undefined) => (Array.isArray(value) ? value : [])\n\n const triggers = new Set<HTMLButtonElement>()\n provide(AccordionContextKey, {\n orientation: () => props.orientation,\n collapsible: () => isMultiple() || props.collapsible,\n onItemOpen: (itemValue) => setValue(isMultiple() ? [...asArray(currentValue.value), itemValue] : itemValue),\n onItemClose: (itemValue) => {\n if (isMultiple()) setValue(asArray(currentValue.value).filter((value) => value !== itemValue))\n else if (props.collapsible) setValue(\"\")\n },\n triggers,\n })\n\n const direction = useDirection(toRef(props, \"dir\"))\n\n // Radix's AccordionImpl key handling, on the root like in React\n const handleKeyDown = (event: KeyboardEvent) => {\n invoke(attrs.onKeydown, event)\n if (event.defaultPrevented) return\n if (!ACCORDION_KEYS.includes(event.key)) return\n const target = event.target as HTMLElement\n const triggerCollection = Array.from(triggers)\n .sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1))\n .filter((trigger) => !trigger.disabled)\n const triggerIndex = triggerCollection.findIndex((trigger) => trigger === target)\n const triggerCount = triggerCollection.length\n\n if (triggerIndex === -1) return\n\n // Prevents page scroll while user is navigating\n event.preventDefault()\n\n let nextIndex = triggerIndex\n const homeIndex = 0\n const endIndex = triggerCount - 1\n const isDirectionLTR = direction.value === \"ltr\"\n const { orientation } = props\n\n const moveNext = () => {\n nextIndex = triggerIndex + 1\n if (nextIndex > endIndex) {\n nextIndex = homeIndex\n }\n }\n\n const movePrev = () => {\n nextIndex = triggerIndex - 1\n if (nextIndex < homeIndex) {\n nextIndex = endIndex\n }\n }\n\n switch (event.key) {\n case \"Home\":\n nextIndex = homeIndex\n break\n case \"End\":\n nextIndex = endIndex\n break\n case \"ArrowRight\":\n if (orientation === \"horizontal\") {\n if (isDirectionLTR) {\n moveNext()\n } else {\n movePrev()\n }\n }\n break\n case \"ArrowDown\":\n if (orientation === \"vertical\") {\n moveNext()\n }\n break\n case \"ArrowLeft\":\n if (orientation === \"horizontal\") {\n if (isDirectionLTR) {\n movePrev()\n } else {\n moveNext()\n }\n }\n break\n case \"ArrowUp\":\n if (orientation === \"vertical\") {\n movePrev()\n }\n break\n }\n\n const clampedIndex = nextIndex % triggerCount\n triggerCollection[clampedIndex]?.focus()\n }\n\n return () => {\n const { class: className, onKeydown: _onKeydown, ...restAttrs } = attrs\n const value = currentValue.value\n return h(\n RekaAccordionRoot,\n {\n ...restAttrs,\n \"key\": props.type,\n \"ref\": setMotionRoot,\n \"class\": [s.Root, className],\n \"type\": props.type,\n // Reka reads the open item(s) from here; `null` is \"none open\" in\n // single mode (an empty string would open an item whose value is \"\")\n \"modelValue\": (isMultiple() ? asArray(value) : value || null) as AccordionValue,\n \"collapsible\": props.collapsible,\n \"disabled\": props.disabled,\n \"dir\": props.dir,\n \"orientation\": props.orientation,\n \"data-orientation\": props.orientation,\n // A disabled root drops the root's own keydown listener too, as in Radix\n \"onKeydown\": props.disabled ? undefined : handleKeyDown,\n },\n { default: () => slots.default?.() },\n )\n }\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\nexport const AccordionItem = defineComponent({\n name: \"AccordionItem\",\n props: {\n /** Unique identifier used by the root's `value` / `default-value` */\n value: { type: String, required: true },\n /** Disable this item. @default false */\n disabled: { type: Boolean, default: undefined },\n },\n setup(props, { slots }) {\n const context = useAccordionContext()\n // Other attributes (and `class`) fall through to the item <div>\n return () =>\n h(\n RekaAccordionItem,\n {\n \"value\": props.value,\n \"disabled\": props.disabled,\n \"class\": s.Item,\n // Reka reads the orientation once; keep it reactive\n \"data-orientation\": context.orientation(),\n },\n { default: () => slots.default?.() },\n )\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\n/** The item's <h3> header and <button>. Attributes and listeners go to the button. */\nexport const AccordionTrigger = defineComponent({\n name: \"AccordionTrigger\",\n inheritAttrs: false,\n setup(_props, { attrs, slots }) {\n const context = useAccordionContext()\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n // Set before the first render so aria-controls / aria-labelledby always\n // point at each other, like Radix's ids from the item\n itemContext.triggerId ||= useId(undefined, \"reka-accordion-trigger\")\n collapsibleContext.contentId ||= useId(undefined, \"reka-collapsible-content\")\n\n const buttonRef = ref<HTMLButtonElement | null>(null)\n onMounted(() => {\n if (buttonRef.value) context.triggers.add(buttonRef.value)\n })\n onBeforeUnmount(() => {\n if (buttonRef.value) context.triggers.delete(buttonRef.value)\n })\n\n const handleClick = (event: MouseEvent) => {\n // A disabled <button> never dispatches click in the browser, nor in React\n if (itemContext.disabled.value) return\n invoke(attrs.onClick, event)\n if (event.defaultPrevented) return\n const value = itemContext.value.value\n if (itemContext.open.value) context.onItemClose(value)\n else context.onItemOpen(value)\n }\n\n return () => {\n const { class: className, onClick: _onClick, ...restAttrs } = attrs\n const open = itemContext.open.value\n const disabled = itemContext.disabled.value\n return h(\n RekaAccordionHeader,\n { \"class\": s.Header, \"data-orientation\": context.orientation() },\n {\n default: () => [\n h(\n \"button\",\n {\n \"type\": \"button\",\n // Radix (radix-ui 1.8) points at the panel only while open\n \"aria-controls\": open ? collapsibleContext.contentId : undefined,\n \"aria-expanded\": open || false,\n \"data-state\": getState(open),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"disabled\": disabled,\n \"aria-disabled\": (open && !context.collapsible()) || undefined,\n \"data-orientation\": context.orientation(),\n \"id\": itemContext.triggerId,\n ...restAttrs,\n \"class\": [s.Trigger, className],\n \"ref\": buttonRef,\n \"onClick\": handleClick,\n },\n [slots.default?.(), h(ChevronDownMd, { \"class\": s.Chevron, \"aria-hidden\": true })],\n ),\n ],\n },\n )\n }\n },\n})\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\n// Radix's CollapsibleContentImpl: measures the panel for the height\n// variables, keeps it mounted (hidden, empty) while closed, and suppresses\n// the open animation of an item that mounts open.\nconst AccordionContentImpl = defineComponent({\n name: \"AccordionContentImpl\",\n inheritAttrs: false,\n props: {\n present: { type: Boolean, required: true },\n asChild: { type: Boolean, required: true },\n },\n setup(props, { attrs, slots }) {\n const context = useAccordionContext()\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n\n const node = ref<HTMLDivElement | null>(null)\n const isPresent = ref(props.present)\n // Plain values, read on render like Radix's refs\n let height = 0\n let width = 0\n const isOpen = () => itemContext.open.value || isPresent.value\n let isMountAnimationPrevented = isOpen()\n let originalStyles: { transitionDuration: string; animationName: string } | undefined\n\n let frame: number | undefined\n onMounted(() => {\n frame = requestAnimationFrame(() => (isMountAnimationPrevented = false))\n })\n onBeforeUnmount(() => {\n if (frame !== undefined) cancelAnimationFrame(frame)\n })\n\n const measure = () => {\n const element = node.value\n if (!element) return\n originalStyles = originalStyles || {\n transitionDuration: element.style.transitionDuration,\n animationName: element.style.animationName,\n }\n // block any animations/transitions so the element renders at its full dimensions\n element.style.transitionDuration = \"0s\"\n element.style.animationName = \"none\"\n\n // get width and height from full dimensions\n const rect = element.getBoundingClientRect()\n height = rect.height\n width = rect.width\n\n // kick off any animations/transitions that were originally set up if it isn't the initial mount\n if (!isMountAnimationPrevented) {\n element.style.transitionDuration = originalStyles.transitionDuration\n element.style.animationName = originalStyles.animationName\n }\n\n isPresent.value = props.present\n }\n onMounted(measure)\n watch(() => [itemContext.open.value, props.present], measure, { flush: \"post\" })\n\n return () => {\n const { class: className, style, ...restAttrs } = attrs\n const open = itemContext.open.value\n const showContent = isOpen()\n const panel = {\n \"data-state\": getState(open),\n \"data-disabled\": itemContext.disabled.value ? \"\" : undefined,\n \"id\": collapsibleContext.contentId,\n \"hidden\": !showContent,\n \"role\": \"region\",\n \"aria-labelledby\": itemContext.triggerId,\n \"data-orientation\": context.orientation(),\n ...restAttrs,\n \"class\": [s.Content, className],\n \"ref\": node,\n \"style\": [\n {\n \"--radix-collapsible-content-height\": height ? `${height}px` : undefined,\n \"--radix-collapsible-content-width\": width ? `${width}px` : undefined,\n \"--radix-accordion-content-height\": \"var(--radix-collapsible-content-height)\",\n \"--radix-accordion-content-width\": \"var(--radix-collapsible-content-width)\",\n },\n style,\n ],\n }\n // `asChild`: Radix's Slot merges the panel onto the inner element,\n // which only renders while the panel shows\n if (props.asChild) {\n return showContent ? h(\"div\", { ...panel, class: [s.Content, className, s.ContentInner] }, slots.default?.()) : null\n }\n return h(\"div\", panel, showContent ? [h(\"div\", { class: s.ContentInner }, slots.default?.())] : undefined)\n }\n },\n})\n\n/** The collapsible panel. Attributes go to the panel <div>. */\nexport const AccordionContent = defineComponent({\n name: \"AccordionContent\",\n inheritAttrs: false,\n props: {\n /** Keep the panel mounted and visible while closed (for custom CSS or JS animations) */\n forceMount: { type: Boolean, default: undefined },\n /**\n * Merge the panel onto its inner element instead of wrapping it, as\n * React's `asChild` does; a closed panel then renders nothing\n */\n asChild: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n const itemContext = injectAccordionItemContext()\n const collapsibleContext = injectCollapsibleRootContext()\n collapsibleContext.contentId ||= useId(undefined, \"reka-collapsible-content\")\n itemContext.triggerId ||= useId(undefined, \"reka-accordion-trigger\")\n\n return () =>\n h(\n Presence,\n { present: !!props.forceMount || itemContext.open.value, forceMount: true },\n {\n // Presence calls its slot once during setup; withCtx marks it as a\n // render slot (returning an array, like compiled slots) so Vue does\n // not warn about that call\n default: withCtx(({ present }: { present: boolean }) => [\n h(AccordionContentImpl, { ...attrs, present, asChild: props.asChild }, { default: () => slots.default?.() }),\n ]),\n },\n )\n },\n})\n\ntype AccordionOwnProps = InstanceType<typeof Accordion>[\"$props\"]\ntype AccordionItemOwnProps = InstanceType<typeof AccordionItem>[\"$props\"]\ntype AccordionContentOwnProps = InstanceType<typeof AccordionContent>[\"$props\"]\n\n/** Accordion props plus the attributes that fall through to the root `<div>`, as in React. */\nexport type AccordionProps = AccordionOwnProps & Omit<HTMLAttributes, keyof AccordionOwnProps>\n\n/** AccordionItem props plus the attributes that fall through to the item `<div>`. */\nexport type AccordionItemProps = AccordionItemOwnProps & Omit<HTMLAttributes, keyof AccordionItemOwnProps>\n\n/** AccordionTrigger takes the attributes of its `<button>`. */\nexport type AccordionTriggerProps = ButtonHTMLAttributes\n\n/** AccordionContent props plus the attributes of the panel `<div>`. */\nexport type AccordionContentProps = AccordionContentOwnProps & Omit<HTMLAttributes, keyof AccordionContentOwnProps>\n"]}
|
|
@@ -6,7 +6,16 @@ const labels = { back: "Back", close: "Close", confirm: "Confirm" };
|
|
|
6
6
|
const NavigationButtonComponent = defineComponent({
|
|
7
7
|
name: "NavigationButton",
|
|
8
8
|
inheritAttrs: false,
|
|
9
|
-
props: {
|
|
9
|
+
props: {
|
|
10
|
+
action: { type: String, required: true },
|
|
11
|
+
/**
|
|
12
|
+
* The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or
|
|
13
|
+
* two at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws
|
|
14
|
+
* confirm as a check circle and shows no text, nor do back and close.
|
|
15
|
+
* @default "Done"
|
|
16
|
+
*/
|
|
17
|
+
label: { type: String, default: undefined },
|
|
18
|
+
},
|
|
10
19
|
setup(props, { attrs }) {
|
|
11
20
|
return () => h(Button, {
|
|
12
21
|
color: props.action === "confirm" ? "primary" : "secondary",
|
|
@@ -17,8 +26,10 @@ const NavigationButtonComponent = defineComponent({
|
|
|
17
26
|
"class": [s.NavigationButton, attrs.class],
|
|
18
27
|
uniform: true,
|
|
19
28
|
pill: true,
|
|
20
|
-
"aria-label": typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : labels[props.action],
|
|
29
|
+
"aria-label": typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : props.label ?? labels[props.action],
|
|
21
30
|
"data-navigation-action": props.action,
|
|
31
|
+
// The Plex Android look draws it on confirm's pill (NavigationButton.module.css), never the long accessible name
|
|
32
|
+
"data-navigation-label": props.action === "confirm" ? props.label ?? "Done" : undefined,
|
|
22
33
|
}, () => h(NavigationGlyph, { action: props.action }));
|
|
23
34
|
},
|
|
24
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationButton.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAA;AACvD,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,eAAe,EAAyB,MAAM,sBAAsB,CAAA;AAC7E,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAE5E,MAAM,MAAM,GAAqC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAErG,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAC9C,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"NavigationButton.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAA;AACvD,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,eAAe,EAAyB,MAAM,sBAAsB,CAAA;AAC7E,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAE5E,MAAM,MAAM,GAAqC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAErG,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAC9C,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACH,MAAM,EAAE,EAAE,IAAI,EAAE,MAAoC,EAAE,QAAQ,EAAE,IA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cesContent":["import { defineComponent, h, type PropType } from \"vue\"\nimport { Button, type ButtonProps } from \"./Button.js\"\nimport { NavigationGlyph, type NavigationAction } from \"./NavigationGlyph.js\"\nimport s from \"@plexui/styles/components/Button/NavigationButton.module.css\"\n\nconst labels: Record<NavigationAction, string> = { back: \"Back\", close: \"Close\", confirm: \"Confirm\" }\n\nconst NavigationButtonComponent = defineComponent({\n name: \"NavigationButton\",\n inheritAttrs: false,\n props: {\n action: { type: String as PropType<NavigationAction>, required: true },\n /**\n * The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or\n * two at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws\n * confirm as a check circle and shows no text, nor do back and close.\n * @default \"Done\"\n */\n label: { type: String, default: undefined },\n },\n setup(props, { attrs }) {\n return () => h(Button, {\n color: props.action === \"confirm\" ? \"primary\" : \"secondary\",\n variant: props.action === \"confirm\" ? \"solid\" : \"soft\",\n mobileMaterial: props.action === \"confirm\" ? undefined : \"glass\",\n size: \"lg\",\n ...attrs,\n \"class\": [s.NavigationButton, attrs.class],\n uniform: true,\n pill: true,\n \"aria-label\": typeof attrs[\"aria-label\"] === \"string\" ? attrs[\"aria-label\"] : props.label ?? labels[props.action],\n \"data-navigation-action\": props.action,\n // The Plex Android look draws it on confirm's pill (NavigationButton.module.css), never the long accessible name\n \"data-navigation-label\": props.action === \"confirm\" ? props.label ?? \"Done\" : undefined,\n }, () => h(NavigationGlyph, { action: props.action }))\n },\n})\n\nexport type NavigationButtonProps = Omit<ButtonProps, \"children\" | \"uniform\" | \"pill\" | \"iconSize\"> & {\n /** Visual role only; the caller owns navigation, dismissal and submission. */\n action: NavigationAction\n /**\n * The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or two\n * at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws confirm\n * as a check circle and shows no text, nor do back and close.\n * @default \"Done\"\n */\n label?: string\n}\n\n/** Every native/Button prop reaches the same button; refs retain the Button instance's $el. */\nexport const NavigationButton = NavigationButtonComponent as typeof NavigationButtonComponent & {\n new (): { $props: NavigationButtonProps }\n}\n"]}
|
|
@@ -7,6 +7,10 @@ import { dismissableSurfaces, useDeferredPointerDownOutside } from "../Popover/d
|
|
|
7
7
|
import { firstElementChild } from "../Tooltip/slot.js";
|
|
8
8
|
import { TransitionGroup } from "../Transition/index.js";
|
|
9
9
|
import { attachSheetDrag } from "./sheetDrag.js";
|
|
10
|
+
import { growsFromButton, presentationSource, SHEET_EXIT_MS, SHEET_SPRING_MS, sourceTransform, watchPresentationSources } from "../../lib/presentMotion.js";
|
|
11
|
+
// Notes the button each press lands on from the start, so the first dialog, mounted by the press that opens it, knows it
|
|
12
|
+
if (typeof document !== "undefined")
|
|
13
|
+
watchPresentationSources(document);
|
|
10
14
|
import { watchDialogViewport } from "./dialogViewport.js";
|
|
11
15
|
import { enterStep, leaveStep, releaseStepHeight, settleStepHeight, STEP_TIMING } from "./dialogSteps.js";
|
|
12
16
|
import { PHONE_LAYOUT as PHONE_LAYOUT_SCOPE } from "../PhoneLayout/PhoneLayout.js";
|
|
@@ -452,11 +456,46 @@ export const DialogContent = defineComponent({
|
|
|
452
456
|
const request = new CustomEvent("dialog.sheetDrag", { cancelable: true, detail: { originalEvent } });
|
|
453
457
|
if (ownerKeepsOpen(request))
|
|
454
458
|
return false;
|
|
455
|
-
|
|
456
|
-
|
|
459
|
+
draggedClose.value = true;
|
|
460
|
+
// An owner that keeps it open without saying so: its next close goes back into the button again
|
|
461
|
+
setTimeout(() => { if (open.value)
|
|
462
|
+
draggedClose.value = false; }, SHEET_EXIT_MS);
|
|
463
|
+
if (props.confirmClose) {
|
|
464
|
+
const closed = requestClose();
|
|
465
|
+
if (!closed)
|
|
466
|
+
draggedClose.value = false;
|
|
467
|
+
return closed;
|
|
468
|
+
}
|
|
457
469
|
setOpen(false);
|
|
458
470
|
return true;
|
|
459
471
|
};
|
|
472
|
+
// A phone sheet opened by a button grows out of it and shrinks back into it; one pulled down leaves at the
|
|
473
|
+
// finger's speed (lib/presentMotion). The button is the one pressed as the dialog opens.
|
|
474
|
+
let source = null;
|
|
475
|
+
// Reactive: a sheet let go of changes its exit timer, in the render that closes it
|
|
476
|
+
const draggedClose = shallowRef(false);
|
|
477
|
+
watch(open, (isOpen) => {
|
|
478
|
+
if (!isOpen)
|
|
479
|
+
return;
|
|
480
|
+
source = typeof document === "undefined" ? null : presentationSource(document);
|
|
481
|
+
draggedClose.value = false;
|
|
482
|
+
}, { immediate: true, flush: "sync" });
|
|
483
|
+
const sheetMotion = () => (phoneWindow.value || phoneLayout.value) && mobilePlacement.value === "bottom" && growsFromButton(undefined);
|
|
484
|
+
const growsFromSource = () => sheetMotion() && source !== null;
|
|
485
|
+
// The panel lies over its button before it enters and before it leaves, wherever the button is by then
|
|
486
|
+
watch([panelNode, open, draggedClose], ([panel]) => {
|
|
487
|
+
if (!panel)
|
|
488
|
+
return;
|
|
489
|
+
const from = growsFromSource() && !draggedClose.value ? sourceTransform(panel, source) : null;
|
|
490
|
+
if (from) {
|
|
491
|
+
panel.style.setProperty("--dialog-panel-source-transform", from);
|
|
492
|
+
panel.setAttribute("data-presented-from", "");
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
panel.style.removeProperty("--dialog-panel-source-transform");
|
|
496
|
+
panel.removeAttribute("data-presented-from");
|
|
497
|
+
}
|
|
498
|
+
}, { flush: "post" });
|
|
460
499
|
const handleInteractOutside = (event) => {
|
|
461
500
|
if (!open.value)
|
|
462
501
|
event.preventDefault();
|
|
@@ -608,6 +647,11 @@ export const DialogContent = defineComponent({
|
|
|
608
647
|
const sheetCrosses = (phoneWindow.value || phoneLayout.value || props.mobileVariant === "sheet" || props.mobilePlacement !== undefined) &&
|
|
609
648
|
(mobilePlacement.value === "bottom" || mobilePlacement.value === "fullscreen");
|
|
610
649
|
const crossesScreen = placement === "bottom" || placement === "start" || placement === "end" || placement === "fullscreen" || sheetCrosses;
|
|
650
|
+
const timing = crossesScreen ? overlayTimingLarge : overlayTiming;
|
|
651
|
+
const transitionTiming = sheetMotion() ? {
|
|
652
|
+
enterDuration: growsFromSource() ? SHEET_SPRING_MS : timing.enterDuration,
|
|
653
|
+
exitDuration: growsFromSource() || draggedClose.value ? SHEET_EXIT_MS : timing.exitDuration,
|
|
654
|
+
} : timing;
|
|
611
655
|
// Portaled out of any phone layout, a phone dialog carries its own scope, above its transition: the phone rules
|
|
612
656
|
// of the style sheet start there.
|
|
613
657
|
const scoped = (group) => phoneLayout.value && !portalTarget.value ? h("div", { class: s.PhoneScope, "data-plex-layout": "phone" }, [group]) : group;
|
|
@@ -617,7 +661,7 @@ export const DialogContent = defineComponent({
|
|
|
617
661
|
// A dialog mounted open enters too, as `v-if` and `open` together do
|
|
618
662
|
{
|
|
619
663
|
class: [s.Transition, HOLD_PRESSES_CLASS],
|
|
620
|
-
...
|
|
664
|
+
...transitionTiming,
|
|
621
665
|
reducedMotionEnterDuration: reducedMotionEnter.dialog,
|
|
622
666
|
overlay: true,
|
|
623
667
|
preventInitialTransition: false,
|