@plexui/vue 0.39.4 → 0.40.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.
Files changed (27) hide show
  1. package/dist/es/components/Dialog/Dialog.js +2 -1
  2. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  3. package/dist/es/components/Menu/Menu.js +8 -2
  4. package/dist/es/components/Menu/Menu.js.map +1 -1
  5. package/dist/es/components/NavigationRow/NavigationRow.js +16 -3
  6. package/dist/es/components/NavigationRow/NavigationRow.js.map +1 -1
  7. package/dist/es/components/Progress/Progress.js +19 -5
  8. package/dist/es/components/Progress/Progress.js.map +1 -1
  9. package/dist/es/components/Progress/index.js.map +1 -1
  10. package/dist/es/components/StatsCard/StatsCard.js +11 -2
  11. package/dist/es/components/StatsCard/StatsCard.js.map +1 -1
  12. package/dist/es/components/Transition/TransitionGroup.js +11 -3
  13. package/dist/es/components/Transition/TransitionGroup.js.map +1 -1
  14. package/dist/es/components/Transition/shared.js +6 -0
  15. package/dist/es/components/Transition/shared.js.map +1 -1
  16. package/dist/es/components/Transition/useTransitionChild.js +1 -1
  17. package/dist/es/components/Transition/useTransitionChild.js.map +1 -1
  18. package/dist/es/lib/fitValueScale.js +54 -0
  19. package/dist/es/lib/fitValueScale.js.map +1 -0
  20. package/dist/types/components/NavigationRow/NavigationRow.d.ts +21 -3
  21. package/dist/types/components/Progress/Progress.d.ts +37 -0
  22. package/dist/types/components/Progress/index.d.ts +1 -1
  23. package/dist/types/components/Sidebar/Sidebar.d.ts +1 -1
  24. package/dist/types/components/Transition/TransitionGroup.d.ts +14 -4
  25. package/dist/types/components/Transition/shared.d.ts +9 -0
  26. package/dist/types/lib/fitValueScale.d.ts +7 -0
  27. package/package.json +2 -2
@@ -2,6 +2,7 @@ import { defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, re
2
2
  import { Button, ButtonLink } from "../Button/index.js";
3
3
  import { Disclosure } from "../Icon/index.js";
4
4
  import { useFieldColumns } from "../../lib/fieldRow.js";
5
+ import { hasContent } from "../../lib/slotContent.js";
5
6
  import s from "@plexui/styles/components/NavigationRow/NavigationRow.module.css";
6
7
  const shown = (value) => value !== null && value !== undefined && value !== false && value !== "";
7
8
  /** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */
@@ -21,7 +22,8 @@ const valueFitsBeside = (row) => {
21
22
  /**
22
23
  * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row
23
24
  * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through
24
- * to the pressable. The `label`, `value` and `description` slots take the place of their props.
25
+ * to the pressable. The `label`, `value` and `description` slots take the place of their props; the `leading` slot
26
+ * (an `Avatar` or a picture) leads the row, as React's `leading`.
25
27
  */
26
28
  const NavigationRowComponent = defineComponent({
27
29
  name: "NavigationRow",
@@ -31,7 +33,7 @@ const NavigationRowComponent = defineComponent({
31
33
  label: [String, Number],
32
34
  /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `""` do not. */
33
35
  value: [String, Number],
34
- /** A line under the label; the row grows from 52 to hold it */
36
+ /** A line under the label; the row grows from 52 to hold it. A `<br />` in the slot starts a second line. */
35
37
  description: [String, Number],
36
38
  /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */
37
39
  href: String,
@@ -48,6 +50,11 @@ const NavigationRowComponent = defineComponent({
48
50
  * it fits beside the label on one line, otherwise below (as Calendar sets a long value).
49
51
  */
50
52
  valuePlacement: { type: String, default: "end" },
53
+ /**
54
+ * The chevron at the end. `false` drops it, for a row that opens a record rather than a page of choices (as the
55
+ * Contacts list of iOS); the row is still one press.
56
+ */
57
+ disclosure: { type: Boolean, default: true },
51
58
  },
52
59
  setup(props, { attrs, slots, expose }) {
53
60
  const pressable = ref(null);
@@ -112,14 +119,18 @@ const NavigationRowComponent = defineComponent({
112
119
  const description = slots.description ? slots.description() : props.description;
113
120
  const hasValue = slots.value ? true : shown(props.value);
114
121
  const hasDescription = slots.description ? true : shown(props.description);
122
+ // A slot that renders nothing (a v-if that is off) leaves no column, as React's empty `leading` does
123
+ const leading = slots.leading?.();
124
+ const hasLeading = hasContent(leading);
115
125
  const below = hasValue && (props.valuePlacement === "below" || (props.valuePlacement === "auto" && !fits.value));
116
126
  const content = () => h("span", { "class": s.Content, "data-navigation-row-content": "" }, [
127
+ hasLeading ? h("span", { class: s.Leading }, [leading]) : null,
117
128
  h("span", { class: s.Text }, [
118
129
  h("span", { "class": s.Label, "data-navigation-row-part": "" }, [label]),
119
130
  hasDescription ? h("span", { class: s.Description }, [description]) : null,
120
131
  ]),
121
132
  hasValue ? h("span", { "class": s.Value, "data-navigation-row-part": "" }, [value]) : null,
122
- h(Disclosure, { "class": s.Disclosure, "aria-hidden": "true", "data-no-autosize": "" }),
133
+ props.disclosure ? h(Disclosure, { "class": s.Disclosure, "aria-hidden": "true", "data-no-autosize": "" }) : null,
123
134
  ]);
124
135
  const { class: className, ...rest } = attrs;
125
136
  const shared = {
@@ -137,6 +148,8 @@ const NavigationRowComponent = defineComponent({
137
148
  "data-value-below": below ? "" : undefined,
138
149
  "data-value": hasValue ? "" : undefined,
139
150
  "data-description": hasDescription ? "" : undefined,
151
+ "data-leading": hasLeading ? "" : undefined,
152
+ "data-disclosure": props.disclosure ? undefined : "none",
140
153
  }, [
141
154
  link
142
155
  ? h(ButtonLink, { ...rest, ...shared, ref: pressable, href: props.href, to: props.to, external: props.external, as: props.as }, { default: content })
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationRow.js","sourceRoot":"","sources":["../../../../src/components/NavigationRow/NavigationRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsF,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAiB,GAAG,EAAmB,KAAK,EAAE,MAAM,KAAK,CAAA;AACzN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,o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EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aACtG,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAYF,MAAM,CAAC,MAAM,aAAa,GAAG,sBAE5B,CAAA","sourcesContent":["import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentPublicInstance, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, type PropType, ref, type VNodeChild, watch } from \"vue\"\nimport { Button, ButtonLink } from \"../Button/index.js\"\nimport { Disclosure } from \"../Icon/index.js\"\nimport { useFieldColumns } from \"../../lib/fieldRow.js\"\nimport type { LinkComponent } from \"../PlexUIProvider/index.js\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\n\ntype RouteTarget = string | Record<string, unknown>\n\nconst shown = (value: unknown) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */\nconst valueFitsBeside = (row: HTMLElement) => {\n const content = row.querySelector<HTMLElement>(\"[data-navigation-row-content]\")\n if (!content) return true\n const below = row.hasAttribute(\"data-value-below\")\n row.removeAttribute(\"data-value-below\")\n row.setAttribute(\"data-measuring\", \"\")\n const fits = [content, ...content.querySelectorAll<HTMLElement>(\"[data-navigation-row-part]\")].every(\n (element) => element.scrollWidth <= element.clientWidth + 0.5,\n )\n row.removeAttribute(\"data-measuring\")\n if (below) row.setAttribute(\"data-value-below\", \"\")\n return fits\n}\n\n/**\n * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row\n * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through\n * to the pressable. The `label`, `value` and `description` slots take the place of their props.\n */\nconst NavigationRowComponent = defineComponent({\n name: \"NavigationRow\",\n inheritAttrs: false,\n props: {\n /** The row's name, where a row's label starts */\n label: [String, Number] as PropType<string | number>,\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value: [String, Number] as PropType<string | number | null>,\n /** A line under the label; the row grows from 52 to hold it */\n description: [String, Number] as PropType<string | number>,\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href: String,\n /** A router target; with it the row is a link through the provider's link component */\n to: [String, Object] as PropType<RouteTarget>,\n /** Force external-link behavior */\n external: { type: Boolean, default: undefined },\n /** Link component override (e.g. a router link). */\n as: [String, Object, Function] as PropType<LinkComponent>,\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled: { type: Boolean, default: undefined },\n /**\n * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while\n * it fits beside the label on one line, otherwise below (as Calendar sets a long value).\n */\n valuePlacement: { type: String as PropType<\"end\" | \"below\" | \"auto\">, default: \"end\" },\n },\n setup(props, { attrs, slots, expose }) {\n const pressable = ref<ComponentPublicInstance | null>(null)\n const element = () => (pressable.value?.$el ?? null) as HTMLElement | null\n // A ref reaches the pressable, as in React: its element and focus()\n expose({ focus: (options?: FocusOptions) => element()?.focus(options), get element() { return element() } })\n\n // \"auto\": measure after each render and when the row's width changes\n const row = ref<HTMLElement | null>(null)\n const fits = ref(true)\n const hasValueNow = () => !!slots.value || shown(props.value)\n const check = () => {\n if (props.valuePlacement !== \"auto\" || !hasValueNow() || !row.value) return\n const next = valueFitsBeside(row.value)\n if (next !== fits.value) fits.value = next\n }\n let observer: ResizeObserver | undefined\n let width = -1\n // A web font that arrives late (font-display: swap) changes the words' widths, not the row's\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined\n let live = true\n const onFonts = () => {\n if (live) check()\n }\n onMounted(() => {\n fonts?.addEventListener?.(\"loadingdone\", onFonts)\n if (typeof ResizeObserver === \"undefined\" || !row.value) {\n check()\n fonts?.ready.then(onFonts)\n return\n }\n // The first measure waits for the observer's first report, after the frame's layout and before its paint: a\n // measure on mount forced a layout for every row while a sheet of rows was being built. Fonts that finish\n // loading after that report measure again; before it, the report itself measures with them.\n fonts?.ready.then(() => {\n if (width !== -1) onFonts()\n })\n observer = new ResizeObserver((entries?: ResizeObserverEntry[]) => {\n const next = entries?.[entries.length - 1]?.contentRect.width ?? row.value?.getBoundingClientRect().width ?? width\n if (next === width) return\n width = next\n check()\n })\n observer.observe(row.value)\n })\n onUpdated(check)\n // FieldGroup columns give the label a column of its own: a change of them measures again, after the group renders\n const columns = useFieldColumns()\n watch(columns, () => nextTick(check), { flush: \"post\" })\n onBeforeUnmount(() => {\n live = false\n fonts?.removeEventListener?.(\"loadingdone\", onFonts)\n observer?.disconnect()\n })\n\n return () => {\n const label: VNodeChild = slots.label ? slots.label() : props.label\n const value: VNodeChild = slots.value ? slots.value() : shown(props.value) ? props.value : undefined\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const hasValue = slots.value ? true : shown(props.value)\n const hasDescription = slots.description ? true : shown(props.description)\n const below = hasValue && (props.valuePlacement === \"below\" || (props.valuePlacement === \"auto\" && !fits.value))\n\n const content = () =>\n h(\"span\", { \"class\": s.Content, \"data-navigation-row-content\": \"\" }, [\n h(\"span\", { class: s.Text }, [\n h(\"span\", { \"class\": s.Label, \"data-navigation-row-part\": \"\" }, [label as never]),\n hasDescription ? h(\"span\", { class: s.Description }, [description as never]) : null,\n ]),\n hasValue ? h(\"span\", { \"class\": s.Value, \"data-navigation-row-part\": \"\" }, [value as never]) : null,\n h(Disclosure, { \"class\": s.Disclosure, \"aria-hidden\": \"true\", \"data-no-autosize\": \"\" }),\n ])\n\n const { class: className, ...rest } = attrs\n const shared = {\n \"class\": [s.Pressable, className],\n \"block\": true,\n \"color\": \"secondary\",\n \"variant\": \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n const link = (props.href !== undefined || props.to !== undefined) && !props.disabled\n\n return h(\n \"div\",\n {\n \"ref\": row,\n \"class\": s.NavigationRow,\n \"data-row\": \"\",\n \"data-value-below\": below ? \"\" : undefined,\n \"data-value\": hasValue ? \"\" : undefined,\n \"data-description\": hasDescription ? \"\" : undefined,\n },\n [\n link\n ? h(\n ButtonLink,\n { ...rest, ...shared, ref: pressable, href: props.href, to: props.to, external: props.external, as: props.as },\n { default: content },\n )\n : h(Button, { ...rest, ...shared, ref: pressable, disabled: props.disabled }, { default: content }),\n ],\n )\n }\n },\n})\n\ntype NavigationRowOwnProps = InstanceType<typeof NavigationRowComponent>[\"$props\"]\n\n/** NavigationRow props plus the native button and link attributes and the click listener that fall through to the\n * pressable, as in React. */\nexport type NavigationRowProps = NavigationRowOwnProps &\n Omit<ButtonHTMLAttributes, keyof NavigationRowOwnProps | \"value\" | \"type\"> &\n Pick<AnchorHTMLAttributes, \"target\" | \"rel\" | \"download\" | \"hreflang\" | \"ping\" | \"referrerpolicy\"> & {\n onClick?: (event: MouseEvent) => void\n }\n\nexport const NavigationRow = NavigationRowComponent as typeof NavigationRowComponent & {\n new (): { $props: NavigationRowProps; focus: (options?: FocusOptions) => void; element: HTMLElement | null }\n}\n"]}
1
+ {"version":3,"file":"NavigationRow.js","sourceRoot":"","sources":["../../../../src/components/NavigationRow/NavigationRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsF,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAiB,GAAG,EAAmB,KAAK,EAAE,MAAM,KAAK,CAAA;AACzN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAIhF,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IA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G,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAC9G,EAAE,OAAO,EAAE,OAAO,EAAE,CACrB;oBACH,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;aACtG,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAYF,MAAM,CAAC,MAAM,aAAa,GAAG,sBAE5B,CAAA","sourcesContent":["import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ComponentPublicInstance, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUpdated, type PropType, ref, type VNodeChild, watch } from \"vue\"\nimport { Button, ButtonLink } from \"../Button/index.js\"\nimport { Disclosure } from \"../Icon/index.js\"\nimport { useFieldColumns } from \"../../lib/fieldRow.js\"\nimport type { LinkComponent } from \"../PlexUIProvider/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/NavigationRow/NavigationRow.module.css\"\n\ntype RouteTarget = string | Record<string, unknown>\n\nconst shown = (value: unknown) => value !== null && value !== undefined && value !== false && value !== \"\"\n\n/** Whether the label and the value of a row fit beside each other on one line: measured in the end layout, unwrapped */\nconst valueFitsBeside = (row: HTMLElement) => {\n const content = row.querySelector<HTMLElement>(\"[data-navigation-row-content]\")\n if (!content) return true\n const below = row.hasAttribute(\"data-value-below\")\n row.removeAttribute(\"data-value-below\")\n row.setAttribute(\"data-measuring\", \"\")\n const fits = [content, ...content.querySelectorAll<HTMLElement>(\"[data-navigation-row-part]\")].every(\n (element) => element.scrollWidth <= element.clientWidth + 0.5,\n )\n row.removeAttribute(\"data-measuring\")\n if (below) row.setAttribute(\"data-value-below\", \"\")\n return fits\n}\n\n/**\n * Vue port of `NavigationRow` from packages/ui/src/components/NavigationRow/NavigationRow.tsx: a FieldGroup row\n * that opens what it holds, as an iOS Settings drill-in. Attributes (id, class, ARIA, data, listeners) fall through\n * to the pressable. The `label`, `value` and `description` slots take the place of their props; the `leading` slot\n * (an `Avatar` or a picture) leads the row, as React's `leading`.\n */\nconst NavigationRowComponent = defineComponent({\n name: \"NavigationRow\",\n inheritAttrs: false,\n props: {\n /** The row's name, where a row's label starts */\n label: [String, Number] as PropType<string | number>,\n /** The current value, at the end of the row in the secondary label. `0` shows; `null`, `undefined` and `\"\"` do not. */\n value: [String, Number] as PropType<string | number | null>,\n /** A line under the label; the row grows from 52 to hold it. A `<br />` in the slot starts a second line. */\n description: [String, Number] as PropType<string | number>,\n /** Where the row goes. With it the row is a link (through `PlexUIProvider`'s `linkComponent`, or `as`). */\n href: String,\n /** A router target; with it the row is a link through the provider's link component */\n to: [String, Object] as PropType<RouteTarget>,\n /** Force external-link behavior */\n external: { type: Boolean, default: undefined },\n /** Link component override (e.g. a router link). */\n as: [String, Object, Function] as PropType<LinkComponent>,\n /** The row can't be pressed. A disabled link renders as a disabled button, so it never navigates. */\n disabled: { type: Boolean, default: undefined },\n /**\n * Where the value stands: at the `end` of the row, `below` the label at the full width, or `auto`: at the end while\n * it fits beside the label on one line, otherwise below (as Calendar sets a long value).\n */\n valuePlacement: { type: String as PropType<\"end\" | \"below\" | \"auto\">, default: \"end\" },\n /**\n * The chevron at the end. `false` drops it, for a row that opens a record rather than a page of choices (as the\n * Contacts list of iOS); the row is still one press.\n */\n disclosure: { type: Boolean, default: true },\n },\n setup(props, { attrs, slots, expose }) {\n const pressable = ref<ComponentPublicInstance | null>(null)\n const element = () => (pressable.value?.$el ?? null) as HTMLElement | null\n // A ref reaches the pressable, as in React: its element and focus()\n expose({ focus: (options?: FocusOptions) => element()?.focus(options), get element() { return element() } })\n\n // \"auto\": measure after each render and when the row's width changes\n const row = ref<HTMLElement | null>(null)\n const fits = ref(true)\n const hasValueNow = () => !!slots.value || shown(props.value)\n const check = () => {\n if (props.valuePlacement !== \"auto\" || !hasValueNow() || !row.value) return\n const next = valueFitsBeside(row.value)\n if (next !== fits.value) fits.value = next\n }\n let observer: ResizeObserver | undefined\n let width = -1\n // A web font that arrives late (font-display: swap) changes the words' widths, not the row's\n const fonts = typeof document !== \"undefined\" ? document.fonts : undefined\n let live = true\n const onFonts = () => {\n if (live) check()\n }\n onMounted(() => {\n fonts?.addEventListener?.(\"loadingdone\", onFonts)\n if (typeof ResizeObserver === \"undefined\" || !row.value) {\n check()\n fonts?.ready.then(onFonts)\n return\n }\n // The first measure waits for the observer's first report, after the frame's layout and before its paint: a\n // measure on mount forced a layout for every row while a sheet of rows was being built. Fonts that finish\n // loading after that report measure again; before it, the report itself measures with them.\n fonts?.ready.then(() => {\n if (width !== -1) onFonts()\n })\n observer = new ResizeObserver((entries?: ResizeObserverEntry[]) => {\n const next = entries?.[entries.length - 1]?.contentRect.width ?? row.value?.getBoundingClientRect().width ?? width\n if (next === width) return\n width = next\n check()\n })\n observer.observe(row.value)\n })\n onUpdated(check)\n // FieldGroup columns give the label a column of its own: a change of them measures again, after the group renders\n const columns = useFieldColumns()\n watch(columns, () => nextTick(check), { flush: \"post\" })\n onBeforeUnmount(() => {\n live = false\n fonts?.removeEventListener?.(\"loadingdone\", onFonts)\n observer?.disconnect()\n })\n\n return () => {\n const label: VNodeChild = slots.label ? slots.label() : props.label\n const value: VNodeChild = slots.value ? slots.value() : shown(props.value) ? props.value : undefined\n const description: VNodeChild = slots.description ? slots.description() : props.description\n const hasValue = slots.value ? true : shown(props.value)\n const hasDescription = slots.description ? true : shown(props.description)\n // A slot that renders nothing (a v-if that is off) leaves no column, as React's empty `leading` does\n const leading = slots.leading?.()\n const hasLeading = hasContent(leading)\n const below = hasValue && (props.valuePlacement === \"below\" || (props.valuePlacement === \"auto\" && !fits.value))\n\n const content = () =>\n h(\"span\", { \"class\": s.Content, \"data-navigation-row-content\": \"\" }, [\n hasLeading ? h(\"span\", { class: s.Leading }, [leading as never]) : null,\n h(\"span\", { class: s.Text }, [\n h(\"span\", { \"class\": s.Label, \"data-navigation-row-part\": \"\" }, [label as never]),\n hasDescription ? h(\"span\", { class: s.Description }, [description as never]) : null,\n ]),\n hasValue ? h(\"span\", { \"class\": s.Value, \"data-navigation-row-part\": \"\" }, [value as never]) : null,\n props.disclosure ? h(Disclosure, { \"class\": s.Disclosure, \"aria-hidden\": \"true\", \"data-no-autosize\": \"\" }) : null,\n ])\n\n const { class: className, ...rest } = attrs\n const shared = {\n \"class\": [s.Pressable, className],\n \"block\": true,\n \"color\": \"secondary\",\n \"variant\": \"ghost\",\n \"data-navigation-row\": \"\",\n } as const\n const link = (props.href !== undefined || props.to !== undefined) && !props.disabled\n\n return h(\n \"div\",\n {\n \"ref\": row,\n \"class\": s.NavigationRow,\n \"data-row\": \"\",\n \"data-value-below\": below ? \"\" : undefined,\n \"data-value\": hasValue ? \"\" : undefined,\n \"data-description\": hasDescription ? \"\" : undefined,\n \"data-leading\": hasLeading ? \"\" : undefined,\n \"data-disclosure\": props.disclosure ? undefined : \"none\",\n },\n [\n link\n ? h(\n ButtonLink,\n { ...rest, ...shared, ref: pressable, href: props.href, to: props.to, external: props.external, as: props.as },\n { default: content },\n )\n : h(Button, { ...rest, ...shared, ref: pressable, disabled: props.disabled }, { default: content }),\n ],\n )\n }\n },\n})\n\ntype NavigationRowOwnProps = InstanceType<typeof NavigationRowComponent>[\"$props\"]\n\n/** NavigationRow props plus the native button and link attributes and the click listener that fall through to the\n * pressable, as in React. */\nexport type NavigationRowProps = NavigationRowOwnProps &\n Omit<ButtonHTMLAttributes, keyof NavigationRowOwnProps | \"value\" | \"type\"> &\n Pick<AnchorHTMLAttributes, \"target\" | \"rel\" | \"download\" | \"hreflang\" | \"ping\" | \"referrerpolicy\"> & {\n onClick?: (event: MouseEvent) => void\n }\n\nexport const NavigationRow = NavigationRowComponent as typeof NavigationRowComponent & {\n new (): { $props: NavigationRowProps; focus: (options?: FocusOptions) => void; element: HTMLElement | null }\n}\n"]}
@@ -43,6 +43,17 @@ const ProgressComponent = defineComponent({
43
43
  * take `value`'s place. A part's share is clamped so the bar never passes `max`.
44
44
  */
45
45
  segments: { type: Array, default: undefined },
46
+ /**
47
+ * The bar's thickness: `sm` 4px (iOS's progress view), `md` 6px, `lg` 8px (a bar in a stats card, as Apple Fitness).
48
+ * @default "sm"
49
+ */
50
+ size: { type: String, default: "sm" },
51
+ /**
52
+ * The color of the filled part, such as `secondary` (grey) for a second series beside a `primary` one. A segmented
53
+ * bar's parts take their own colors.
54
+ * @default "primary"
55
+ */
56
+ color: { type: String, default: "primary" },
46
57
  },
47
58
  setup(props) {
48
59
  const getValueText = (value, max) => isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined;
@@ -57,6 +68,7 @@ const ProgressComponent = defineComponent({
57
68
  "getValueText": (current, currentMax) => props.getValueLabel && isNumber(current) ? props.getValueLabel(current, currentMax) : segmentsLabel(parts, rootMax),
58
69
  "class": s.Root,
59
70
  "data-segmented": "",
71
+ "data-size": props.size,
60
72
  }, {
61
73
  default: () => parts.map((part, index) => part.value > 0
62
74
  ? h("div", { "key": index, "class": s.Segment, "data-color": part.color ?? "primary", "style": { width: `${(part.value / rootMax) * 100}%` } })
@@ -70,11 +82,13 @@ const ProgressComponent = defineComponent({
70
82
  const rootMax = isValidMax(max) ? max : DEFAULT_MAX;
71
83
  const rootValue = isValidValue(resolved, rootMax) ? resolved : null;
72
84
  return h(ProgressRoot, {
73
- modelValue: rootValue,
74
- max: rootMax,
75
- getValueLabel: () => undefined,
76
- getValueText,
77
- class: s.Root,
85
+ "modelValue": rootValue,
86
+ "max": rootMax,
87
+ "getValueLabel": () => undefined,
88
+ "getValueText": getValueText,
89
+ "class": s.Root,
90
+ "data-size": props.size,
91
+ "data-color": props.color,
78
92
  }, {
79
93
  default: () => h(ProgressIndicator, {
80
94
  "class": s.Indicator,
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,4EAA4E;AAC5E,6EAA6E;AAC7E,qBAAqB;AACrB,8EAA8E;AAC9E,6EAA6E;AAC7E,iEAAiE;AACjE,2EAA2E;AAC3E,2EAA2E;AAC3E,gFAAgF;AAEhF,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA;AAC/E,MAAM,UAAU,GAAG,CAAC,GAAY,EAAiB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA;AAClG,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,GAAW,EAAmB,EAAE,CACpE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAA;AAavE,iGAAiG;AACjG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAA2B,EAAE,GAAW,EAAE,EAAE;IAC3E,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC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CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;iBAC1D,CAAC;aACL,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAqF,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { ProgressIndicator, ProgressRoot } from \"reka-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\n// Vue port of packages/ui/src/components/Progress/Progress.tsx on Reka UI's\n// Progress. Radix and Reka differ in three places, smoothed over here so the\n// DOM matches React:\n// - Radix announces the percentage as `aria-valuetext` (via `getValueLabel`),\n// Reka as `aria-label`. Reka's label is turned off and its value text set.\n// - Radix falls back to `max = 100` for an invalid max and to an\n// indeterminate value for an invalid value. Reka keeps them and asks the\n// parent to correct them, so the same fallbacks are applied before Reka.\n// - Caller attributes still win over Reka's, as `{...restProps}` does in React.\n\nconst DEFAULT_MAX = 100\n\nconst isNumber = (value: unknown): value is number => typeof value === \"number\"\nconst isValidMax = (max: unknown): max is number => isNumber(max) && !Number.isNaN(max) && max > 0\nconst isValidValue = (value: unknown, max: number): value is number =>\n isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0\n\nexport type ProgressColor = \"primary\" | \"secondary\" | \"success\" | \"warning\" | \"caution\" | \"danger\" | \"info\" | \"discovery\"\n\n/** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */\nexport type ProgressSegment = {\n value: number\n /** @default \"primary\" */\n color?: ProgressColor\n /** Read out with its share, such as \"Paid 60%\" */\n label?: string\n}\n\n/** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */\nexport const progressSegments = (segments: ProgressSegment[], max: number) => {\n let total = 0\n const parts = segments.map((segment) => {\n const value = Math.max(0, Math.min(max - total, segment.value || 0))\n total += value\n return { ...segment, value }\n })\n return { parts, total }\n}\n\nconst segmentsLabel = (parts: ProgressSegment[], max: number) =>\n parts.map((part) => `${part.label ? `${part.label} ` : \"\"}${Math.round((part.value / max) * 100)}%`).join(\", \")\n\nconst defaultGetValueLabel = (value: number, max: number) => `${Math.round((value / max) * 100)}%`\n\nconst ProgressComponent = defineComponent({\n name: \"Progress\",\n props: {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value: { type: Number as PropType<number | null>, default: null },\n /** Maximum value. @default 100 */\n max: { type: Number, default: DEFAULT_MAX },\n /** Accessible value text for the current value. @default \"<percentage>%\" */\n getValueLabel: Function as PropType<(value: number, max: number) => string>,\n /**\n * Parts of one bar, side by side in their colors, such as paid, pending and due. The value is their sum; they\n * take `value`'s place. A part's share is clamped so the bar never passes `max`.\n */\n segments: { type: Array as PropType<ProgressSegment[]>, default: undefined },\n },\n setup(props) {\n const getValueText = (value: number | null | undefined, max: number) =>\n isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined\n\n return () => {\n if (props.segments) {\n const rootMax = isValidMax(props.max) ? props.max : DEFAULT_MAX\n const { parts, total } = progressSegments(props.segments, rootMax)\n return h(\n ProgressRoot,\n {\n \"modelValue\": total,\n \"max\": rootMax,\n \"getValueLabel\": () => undefined,\n \"getValueText\": (current: number | null | undefined, currentMax: number) =>\n props.getValueLabel && isNumber(current) ? props.getValueLabel(current, currentMax) : segmentsLabel(parts, rootMax),\n \"class\": s.Root,\n \"data-segmented\": \"\",\n },\n {\n default: () => parts.map((part, index) =>\n part.value > 0\n ? h(\"div\", { \"key\": index, \"class\": s.Segment, \"data-color\": part.color ?? \"primary\", \"style\": { width: `${(part.value / rootMax) * 100}%` } })\n : null),\n },\n )\n }\n const { value, max } = props\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n // What Radix renders for the props React hands it\n const rootMax = isValidMax(max) ? max : DEFAULT_MAX\n const rootValue = isValidValue(resolved, rootMax) ? resolved : null\n\n return h(\n ProgressRoot,\n {\n modelValue: rootValue,\n max: rootMax,\n getValueLabel: () => undefined,\n getValueText,\n class: s.Root,\n },\n {\n default: () =>\n h(ProgressIndicator, {\n \"class\": s.Indicator,\n \"style\": percentage == null ? undefined : { transform: `translateX(-${100 - percentage}%)` },\n \"data-indeterminate\": percentage == null ? \"\" : undefined,\n }),\n },\n )\n }\n },\n})\n\ntype ProgressOwnProps = InstanceType<typeof ProgressComponent>[\"$props\"]\n\n/** Progress props plus the native <div> attributes that fall through to the root, as in React. */\nexport type ProgressProps = ProgressOwnProps & Omit<HTMLAttributes, keyof ProgressOwnProps>\n\nexport const Progress = ProgressComponent as typeof ProgressComponent & { new (): { $props: ProgressProps } }\n"]}
1
+ {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../../src/components/Progress/Progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,4EAA4E;AAC5E,6EAA6E;AAC7E,qBAAqB;AACrB,8EAA8E;AAC9E,6EAA6E;AAC7E,iEAAiE;AACjE,2EAA2E;AAC3E,2EAA2E;AAC3E,gFAAgF;AAEhF,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA;AAC/E,MAAM,UAAU,GAAG,CAAC,GAAY,EAAiB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA;AAClG,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,GAAW,EAAmB,EAAE,CACpE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAA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C,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;YAEnE,OAAO,CAAC,CACN,YAAY,EACZ;gBACE,YAAY,EAAE,SAAS;gBACvB,KAAK,EAAE,OAAO;gBACd,eAAe,EAAE,GAAG,EAAE,CAAC,SAAS;gBAChC,cAAc,EAAE,YAAY;gBAC5B,OAAO,EAAE,CAAC,CAAC,IAAI;gBACf,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,YAAY,EAAE,KAAK,CAAC,KAAK;aAC1B,EACD;gBACE,OAAO,EAAE,GAAG,EAAE,CACZ,CAAC,CAAC,iBAAiB,EAAE;oBACnB,OAAO,EAAE,CAAC,CAAC,SAAS;oBACpB,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,GAAG,GAAG,UAAU,IAAI,EAAE;oBAC5F,oBAAoB,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;iBAC1D,CAAC;aACL,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAqF,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { ProgressIndicator, ProgressRoot } from \"reka-ui\"\nimport s from \"@plexui/styles/components/Progress/Progress.module.css\"\n\n// Vue port of packages/ui/src/components/Progress/Progress.tsx on Reka UI's\n// Progress. Radix and Reka differ in three places, smoothed over here so the\n// DOM matches React:\n// - Radix announces the percentage as `aria-valuetext` (via `getValueLabel`),\n// Reka as `aria-label`. Reka's label is turned off and its value text set.\n// - Radix falls back to `max = 100` for an invalid max and to an\n// indeterminate value for an invalid value. Reka keeps them and asks the\n// parent to correct them, so the same fallbacks are applied before Reka.\n// - Caller attributes still win over Reka's, as `{...restProps}` does in React.\n\nconst DEFAULT_MAX = 100\n\nconst isNumber = (value: unknown): value is number => typeof value === \"number\"\nconst isValidMax = (max: unknown): max is number => isNumber(max) && !Number.isNaN(max) && max > 0\nconst isValidValue = (value: unknown, max: number): value is number =>\n isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0\n\nexport type ProgressSize = \"sm\" | \"md\" | \"lg\"\n\nexport type ProgressColor = \"primary\" | \"secondary\" | \"success\" | \"warning\" | \"caution\" | \"danger\" | \"info\" | \"discovery\"\n\n/** A part of a segmented bar: its share of `max`, its color, and the name it is read with. */\nexport type ProgressSegment = {\n value: number\n /** @default \"primary\" */\n color?: ProgressColor\n /** Read out with its share, such as \"Paid 60%\" */\n label?: string\n}\n\n/** The parts of a segmented bar, each clamped so their sum stays within `max`, and their sum. */\nexport const progressSegments = (segments: ProgressSegment[], max: number) => {\n let total = 0\n const parts = segments.map((segment) => {\n const value = Math.max(0, Math.min(max - total, segment.value || 0))\n total += value\n return { ...segment, value }\n })\n return { parts, total }\n}\n\nconst segmentsLabel = (parts: ProgressSegment[], max: number) =>\n parts.map((part) => `${part.label ? `${part.label} ` : \"\"}${Math.round((part.value / max) * 100)}%`).join(\", \")\n\nconst defaultGetValueLabel = (value: number, max: number) => `${Math.round((value / max) * 100)}%`\n\nconst ProgressComponent = defineComponent({\n name: \"Progress\",\n props: {\n /**\n * Current progress value, between `0` and `max`.\n * Omit (or pass `null`) for an indeterminate state.\n */\n value: { type: Number as PropType<number | null>, default: null },\n /** Maximum value. @default 100 */\n max: { type: Number, default: DEFAULT_MAX },\n /** Accessible value text for the current value. @default \"<percentage>%\" */\n getValueLabel: Function as PropType<(value: number, max: number) => string>,\n /**\n * Parts of one bar, side by side in their colors, such as paid, pending and due. The value is their sum; they\n * take `value`'s place. A part's share is clamped so the bar never passes `max`.\n */\n segments: { type: Array as PropType<ProgressSegment[]>, default: undefined },\n /**\n * The bar's thickness: `sm` 4px (iOS's progress view), `md` 6px, `lg` 8px (a bar in a stats card, as Apple Fitness).\n * @default \"sm\"\n */\n size: { type: String as PropType<ProgressSize>, default: \"sm\" },\n /**\n * The color of the filled part, such as `secondary` (grey) for a second series beside a `primary` one. A segmented\n * bar's parts take their own colors.\n * @default \"primary\"\n */\n color: { type: String as PropType<ProgressColor>, default: \"primary\" },\n },\n setup(props) {\n const getValueText = (value: number | null | undefined, max: number) =>\n isNumber(value) ? (props.getValueLabel ?? defaultGetValueLabel)(value, max) : undefined\n\n return () => {\n if (props.segments) {\n const rootMax = isValidMax(props.max) ? props.max : DEFAULT_MAX\n const { parts, total } = progressSegments(props.segments, rootMax)\n return h(\n ProgressRoot,\n {\n \"modelValue\": total,\n \"max\": rootMax,\n \"getValueLabel\": () => undefined,\n \"getValueText\": (current: number | null | undefined, currentMax: number) =>\n props.getValueLabel && isNumber(current) ? props.getValueLabel(current, currentMax) : segmentsLabel(parts, rootMax),\n \"class\": s.Root,\n \"data-segmented\": \"\",\n \"data-size\": props.size,\n },\n {\n default: () => parts.map((part, index) =>\n part.value > 0\n ? h(\"div\", { \"key\": index, \"class\": s.Segment, \"data-color\": part.color ?? \"primary\", \"style\": { width: `${(part.value / rootMax) * 100}%` } })\n : null),\n },\n )\n }\n const { value, max } = props\n const resolved = value == null ? null : Math.max(0, Math.min(max, value))\n const percentage = resolved == null ? null : (resolved / max) * 100\n\n // What Radix renders for the props React hands it\n const rootMax = isValidMax(max) ? max : DEFAULT_MAX\n const rootValue = isValidValue(resolved, rootMax) ? resolved : null\n\n return h(\n ProgressRoot,\n {\n \"modelValue\": rootValue,\n \"max\": rootMax,\n \"getValueLabel\": () => undefined,\n \"getValueText\": getValueText,\n \"class\": s.Root,\n \"data-size\": props.size,\n \"data-color\": props.color,\n },\n {\n default: () =>\n h(ProgressIndicator, {\n \"class\": s.Indicator,\n \"style\": percentage == null ? undefined : { transform: `translateX(-${100 - percentage}%)` },\n \"data-indeterminate\": percentage == null ? \"\" : undefined,\n }),\n },\n )\n }\n },\n})\n\ntype ProgressOwnProps = InstanceType<typeof ProgressComponent>[\"$props\"]\n\n/** Progress props plus the native <div> attributes that fall through to the root, as in React. */\nexport type ProgressProps = ProgressOwnProps & Omit<HTMLAttributes, keyof ProgressOwnProps>\n\nexport const Progress = ProgressComponent as typeof ProgressComponent & { new (): { $props: ProgressProps } }\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Progress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAgE,MAAM,eAAe,CAAA","sourcesContent":["export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment } from \"./Progress.js\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Progress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAmF,MAAM,eAAe,CAAA","sourcesContent":["export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment, type ProgressSize } from \"./Progress.js\"\n"]}
@@ -1,8 +1,9 @@
1
- import { defineComponent, h } from "vue";
1
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref } from "vue";
2
2
  import { Badge } from "../Badge/index.js";
3
3
  import { InfoCircle, Trending } from "../Icon/index.js";
4
4
  import { Tooltip } from "../Tooltip/index.js";
5
5
  import { hasContent } from "../../lib/slotContent.js";
6
+ import { fitValueScale } from "../../lib/fitValueScale.js";
6
7
  import s from "@plexui/styles/components/StatsCard/StatsCard.module.css";
7
8
  const StatsCardComponent = defineComponent({
8
9
  name: "StatsCard",
@@ -35,6 +36,14 @@ const StatsCardComponent = defineComponent({
35
36
  accentColor: { type: String, default: "primary" },
36
37
  },
37
38
  setup(props, { slots }) {
39
+ // A value wider than the card (two cards a row on a phone) scales down to fit, as iOS's minimumScaleFactor
40
+ const valueRef = ref(null);
41
+ let stopFit;
42
+ onMounted(() => {
43
+ if (valueRef.value)
44
+ stopFit = fitValueScale(valueRef.value, "--stats-card-value-scale");
45
+ });
46
+ onBeforeUnmount(() => stopFit?.());
38
47
  return () => {
39
48
  const { label, description, trend, invertTrend, progress, progressLabel, tooltip, trendPosition, trendVariant } = props;
40
49
  const trendValue = trend?.value ?? 0;
@@ -89,7 +98,7 @@ const StatsCardComponent = defineComponent({
89
98
  ]);
90
99
  const valueSlot = slots.value?.();
91
100
  const valueRowEl = h("div", { class: s.ValueRow }, [
92
- h("div", { class: s.Value }, hasContent(valueSlot) ? valueSlot : props.value),
101
+ h("div", { ref: valueRef, class: s.Value }, hasContent(valueSlot) ? valueSlot : props.value),
93
102
  ]);
94
103
  // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend
95
104
  // in the header leaves its label there
@@ -1 +1 @@
1
- {"version":3,"file":"StatsCard.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/StatsCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,CAAC,MAAM,0DAA0D,CAAA;AAyBxE,MAAM,kBAAkB,GAAG,eAAe,CAAC;IACzC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE;QACL,kCAAkC;QAClC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvC,6FAA6F;QAC7F,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA8B,EAAE,OAAO,EAAE,SAAS,EAAE;QAClF,uDAAuD;QACvD,WAAW,EAAE,MAAM;QACnB,6CAA6C;QAC7C,KAAK,EAAE,MAAkC;QACzC,yIAAyI;QACzI,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,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AAC,WAAW;4BACtB,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,aAAa,IAAI,CAAC,GAAG,EAAE;4BAC5C,aAAa,EAAE,MAAM;yBACtB,CAAC;qBACH,CAAC;oBACF,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;iBAC3E,CAAC;gBACJ,CAAC,CAAC,IAAI,CAAA;YAEV,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,CAAA;YACzC,MAAM,WAAW,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YAEtG,OAAO,CAAC,CACN,KAAK,EACL;gBACE,OAAO,EAAE,CAAC,CAAC,SAAS;gBACpB,cAAc,EAAE,KAAK,CAAC,OAAO;gBAC7B,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,mBAAmB,EAAE,KAAK,CAAC,WAAW;aACvC,EACD,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,CAC3E,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAwF,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport { Badge } from \"../Badge/index.js\"\nimport { InfoCircle, Trending } from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/StatsCard/StatsCard.module.css\"\n\n// Vue port of packages/ui/src/components/StatsCard/StatsCard.tsx. Props,\n// defaults and rendered DOM match React (checked by the parity tests).\n// ReactNode props are slots: `value` (also a prop, for plain values),\n// `icon` and `sparkline`. React spreads the remaining props after its own\n// attributes, so caller attributes win; Vue's fallthrough does the same.\n\nexport type StatsCardTrend = {\n /** The percentage change value (e.g. 12.5 for +12.5%) */\n value: number\n /** Optional label for the trend (e.g. \"vs last month\") */\n label?: string\n}\n\nexport type StatsCardAccentColor =\n | \"primary\"\n | \"secondary\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"discovery\"\n | \"caution\"\n\nconst StatsCardComponent = defineComponent({\n name: \"StatsCard\",\n props: {\n /** Label describing the metric */\n label: { type: String, required: true },\n /** The primary metric value (e.g. \"1,234\" or \"$50K\"); the `value` slot takes rich content */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Optional description or subtitle below the value */\n description: String,\n /** Trend indicator with percentage change */\n trend: Object as PropType<StatsCardTrend>,\n /** When true, a positive trend is bad (red) and negative is good (green). Use for metrics like \"Error Rate\" or \"Avg Completion Time\". */\n invertTrend: { type: Boolean, default: undefined },\n /** Progress value from 0 to 100. Shows a progress bar at the bottom. */\n progress: Number,\n /** Label displayed after the progress bar */\n progressLabel: String,\n /** Tooltip text: renders an (i) icon next to the label with a tooltip on hover */\n tooltip: String,\n /** Where the trend indicator is positioned: under the value with its label, or right-aligned in the header row (its label under the value). @default \"value\" */\n trendPosition: { type: String as PropType<\"value\" | \"header\">, default: \"value\" },\n /** Visual style of the trend indicator: plain colored text, or a Badge. @default \"text\" */\n trendVariant: { type: String as PropType<\"text\" | \"badge\">, default: \"text\" },\n /** Size of the card: standard dashboard card, or compact for dense layouts. @default \"default\" */\n size: { type: String as PropType<\"default\" | \"sm\">, default: \"default\" },\n /** Visual variant of the card. @default \"default\" */\n variant: { type: String as PropType<\"default\" | \"accent\">, default: \"default\" },\n /** Color of the accent variant's bar. @default \"primary\" */\n accentColor: { type: String as PropType<StatsCardAccentColor>, default: \"primary\" },\n },\n setup(props, { slots }) {\n return () => {\n const { label, description, trend, invertTrend, progress, progressLabel, tooltip, trendPosition, trendVariant } =\n props\n\n const trendValue = trend?.value ?? 0\n const trendClassName =\n trendValue === 0\n ? s.TrendNeutral\n : trendValue > 0\n ? invertTrend\n ? s.TrendNegative\n : s.TrendPositive\n : invertTrend\n ? s.TrendPositive\n : s.TrendNegative\n\n const trendText = `${trendValue > 0 ? \"+\" : \"\"}${trendValue}%`\n const progressValue = progress === undefined ? undefined : Math.min(100, Math.max(0, progress))\n\n const trendBadgeColor =\n trendValue === 0\n ? \"secondary\"\n : trendValue > 0\n ? invertTrend\n ? \"danger\"\n : \"success\"\n : invertTrend\n ? \"success\"\n : \"danger\"\n\n // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's\n // trending-up and trending-down); a fall is the rise mirrored\n const trendContent = () => [\n trendValue !== 0 ? h(Trending, { class: trendValue < 0 ? s.TrendDown : undefined }) : null,\n trendText,\n ]\n\n const trendEl =\n trend != null\n ? trendVariant === \"badge\"\n ? h(Badge, { size: \"sm\", color: trendBadgeColor }, { default: trendContent })\n : h(\"div\", { class: [s.Trend, trendClassName] }, trendContent())\n : null\n\n // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)\n const iconSlot = slots.icon?.()\n const iconEl = hasContent(iconSlot) ? h(\"div\", { class: s.IconWrapper }, iconSlot) : null\n const headerTrendEl = trendPosition === \"header\" ? trendEl : null\n\n const headerEl = h(\"div\", { class: s.Header }, [\n h(\"div\", { class: s.LabelRow }, [\n h(\"div\", { class: s.Label }, label),\n tooltip\n ? h(\n Tooltip,\n { content: tooltip },\n {\n // Focusable and named so keyboard and screen-reader users reach the tooltip\n default: () =>\n h(\"span\", { \"class\": s.InfoIcon, \"tabindex\": 0, \"role\": \"img\", \"aria-label\": \"More information\" }, [\n h(InfoCircle),\n ]),\n },\n )\n : null,\n ]),\n headerTrendEl || iconEl ? h(\"div\", { class: s.HeaderEnd }, [headerTrendEl, iconEl]) : null,\n ])\n\n const valueSlot = slots.value?.()\n const valueRowEl = h(\"div\", { class: s.ValueRow }, [\n h(\"div\", { class: s.Value }, hasContent(valueSlot) ? valueSlot : props.value),\n ])\n\n // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend\n // in the header leaves its label there\n const trendRowEl =\n trend != null && (trendPosition === \"value\" || trend.label)\n ? h(\"div\", { class: s.TrendRow }, [\n trendPosition === \"value\" ? trendEl : null,\n trend.label ? h(\"span\", { class: s.TrendLabel }, trend.label) : null,\n ])\n : null\n\n const descriptionEl = description ? h(\"div\", { class: s.Description }, description) : null\n\n const progressEl =\n progressValue !== undefined || progressLabel\n ? h(\"div\", { class: s.Progress }, [\n h(\"div\", { class: s.ProgressTrack }, [\n h(\"div\", {\n \"class\": s.ProgressBar,\n \"style\": { width: `${progressValue ?? 0}%` },\n \"aria-hidden\": \"true\",\n }),\n ]),\n progressLabel ? h(\"div\", { class: s.ProgressLabel }, progressLabel) : null,\n ])\n : null\n\n const sparklineSlot = slots.sparkline?.()\n const sparklineEl = hasContent(sparklineSlot) ? h(\"div\", { class: s.Sparkline }, sparklineSlot) : null\n\n return h(\n \"div\",\n {\n \"class\": s.StatsCard,\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-accent-color\": props.accentColor,\n },\n [headerEl, valueRowEl, trendRowEl, descriptionEl, progressEl, sparklineEl],\n )\n }\n },\n})\n\ntype StatsCardOwnProps = InstanceType<typeof StatsCardComponent>[\"$props\"]\n\n/** StatsCard props plus the native <div> attributes that fall through to it, as in React. */\nexport type StatsCardProps = StatsCardOwnProps & Omit<HTMLAttributes, keyof StatsCardOwnProps>\n\nexport const StatsCard = StatsCardComponent as typeof StatsCardComponent & { new (): { $props: StatsCardProps } }\n"]}
1
+ {"version":3,"file":"StatsCard.js","sourceRoot":"","sources":["../../../../src/components/StatsCard/StatsCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAsC,MAAM,KAAK,CAA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,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;iBAC3E,CAAC;gBACJ,CAAC,CAAC,IAAI,CAAA;YAEV,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,CAAA;YACzC,MAAM,WAAW,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YAEtG,OAAO,CAAC,CACN,KAAK,EACL;gBACE,OAAO,EAAE,CAAC,CAAC,SAAS;gBACpB,cAAc,EAAE,KAAK,CAAC,OAAO;gBAC7B,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,mBAAmB,EAAE,KAAK,CAAC,WAAW;aACvC,EACD,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,CAC3E,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAwF,CAAA","sourcesContent":["import { defineComponent, h, onBeforeUnmount, onMounted, ref, type HTMLAttributes, type PropType } from \"vue\"\nimport { Badge } from \"../Badge/index.js\"\nimport { InfoCircle, Trending } from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport { fitValueScale } from \"../../lib/fitValueScale.js\"\nimport s from \"@plexui/styles/components/StatsCard/StatsCard.module.css\"\n\n// Vue port of packages/ui/src/components/StatsCard/StatsCard.tsx. Props,\n// defaults and rendered DOM match React (checked by the parity tests).\n// ReactNode props are slots: `value` (also a prop, for plain values),\n// `icon` and `sparkline`. React spreads the remaining props after its own\n// attributes, so caller attributes win; Vue's fallthrough does the same.\n\nexport type StatsCardTrend = {\n /** The percentage change value (e.g. 12.5 for +12.5%) */\n value: number\n /** Optional label for the trend (e.g. \"vs last month\") */\n label?: string\n}\n\nexport type StatsCardAccentColor =\n | \"primary\"\n | \"secondary\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"discovery\"\n | \"caution\"\n\nconst StatsCardComponent = defineComponent({\n name: \"StatsCard\",\n props: {\n /** Label describing the metric */\n label: { type: String, required: true },\n /** The primary metric value (e.g. \"1,234\" or \"$50K\"); the `value` slot takes rich content */\n value: { type: [String, Number] as PropType<string | number>, default: undefined },\n /** Optional description or subtitle below the value */\n description: String,\n /** Trend indicator with percentage change */\n trend: Object as PropType<StatsCardTrend>,\n /** When true, a positive trend is bad (red) and negative is good (green). Use for metrics like \"Error Rate\" or \"Avg Completion Time\". */\n invertTrend: { type: Boolean, default: undefined },\n /** Progress value from 0 to 100. Shows a progress bar at the bottom. */\n progress: Number,\n /** Label displayed after the progress bar */\n progressLabel: String,\n /** Tooltip text: renders an (i) icon next to the label with a tooltip on hover */\n tooltip: String,\n /** Where the trend indicator is positioned: under the value with its label, or right-aligned in the header row (its label under the value). @default \"value\" */\n trendPosition: { type: String as PropType<\"value\" | \"header\">, default: \"value\" },\n /** Visual style of the trend indicator: plain colored text, or a Badge. @default \"text\" */\n trendVariant: { type: String as PropType<\"text\" | \"badge\">, default: \"text\" },\n /** Size of the card: standard dashboard card, or compact for dense layouts. @default \"default\" */\n size: { type: String as PropType<\"default\" | \"sm\">, default: \"default\" },\n /** Visual variant of the card. @default \"default\" */\n variant: { type: String as PropType<\"default\" | \"accent\">, default: \"default\" },\n /** Color of the accent variant's bar. @default \"primary\" */\n accentColor: { type: String as PropType<StatsCardAccentColor>, default: \"primary\" },\n },\n setup(props, { slots }) {\n // A value wider than the card (two cards a row on a phone) scales down to fit, as iOS's minimumScaleFactor\n const valueRef = ref<HTMLElement | null>(null)\n let stopFit: (() => void) | undefined\n onMounted(() => {\n if (valueRef.value) stopFit = fitValueScale(valueRef.value, \"--stats-card-value-scale\")\n })\n onBeforeUnmount(() => stopFit?.())\n\n return () => {\n const { label, description, trend, invertTrend, progress, progressLabel, tooltip, trendPosition, trendVariant } =\n props\n\n const trendValue = trend?.value ?? 0\n const trendClassName =\n trendValue === 0\n ? s.TrendNeutral\n : trendValue > 0\n ? invertTrend\n ? s.TrendNegative\n : s.TrendPositive\n : invertTrend\n ? s.TrendPositive\n : s.TrendNegative\n\n const trendText = `${trendValue > 0 ? \"+\" : \"\"}${trendValue}%`\n const progressValue = progress === undefined ? undefined : Math.min(100, Math.max(0, progress))\n\n const trendBadgeColor =\n trendValue === 0\n ? \"secondary\"\n : trendValue > 0\n ? invertTrend\n ? \"danger\"\n : \"success\"\n : invertTrend\n ? \"success\"\n : \"danger\"\n\n // A trend line points the way the value moved, whichever colour that is (shadcn's metric cards draw lucide's\n // trending-up and trending-down); a fall is the rise mirrored\n const trendContent = () => [\n trendValue !== 0 ? h(Trending, { class: trendValue < 0 ? s.TrendDown : undefined }) : null,\n trendText,\n ]\n\n const trendEl =\n trend != null\n ? trendVariant === \"badge\"\n ? h(Badge, { size: \"sm\", color: trendBadgeColor }, { default: trendContent })\n : h(\"div\", { class: [s.Trend, trendClassName] }, trendContent())\n : null\n\n // The icon's tile stands at the end of the header, as the trend may (shadcn's metric card with an icon)\n const iconSlot = slots.icon?.()\n const iconEl = hasContent(iconSlot) ? h(\"div\", { class: s.IconWrapper }, iconSlot) : null\n const headerTrendEl = trendPosition === \"header\" ? trendEl : null\n\n const headerEl = h(\"div\", { class: s.Header }, [\n h(\"div\", { class: s.LabelRow }, [\n h(\"div\", { class: s.Label }, label),\n tooltip\n ? h(\n Tooltip,\n { content: tooltip },\n {\n // Focusable and named so keyboard and screen-reader users reach the tooltip\n default: () =>\n h(\"span\", { \"class\": s.InfoIcon, \"tabindex\": 0, \"role\": \"img\", \"aria-label\": \"More information\" }, [\n h(InfoCircle),\n ]),\n },\n )\n : null,\n ]),\n headerTrendEl || iconEl ? h(\"div\", { class: s.HeaderEnd }, [headerTrendEl, iconEl]) : null,\n ])\n\n const valueSlot = slots.value?.()\n const valueRowEl = h(\"div\", { class: s.ValueRow }, [\n h(\"div\", { ref: valueRef, class: s.Value }, hasContent(valueSlot) ? valueSlot : props.value),\n ])\n\n // Under the value, a trend and what it compares with, on one line (shadcn's metric card with a trend); a trend\n // in the header leaves its label there\n const trendRowEl =\n trend != null && (trendPosition === \"value\" || trend.label)\n ? h(\"div\", { class: s.TrendRow }, [\n trendPosition === \"value\" ? trendEl : null,\n trend.label ? h(\"span\", { class: s.TrendLabel }, trend.label) : null,\n ])\n : null\n\n const descriptionEl = description ? h(\"div\", { class: s.Description }, description) : null\n\n const progressEl =\n progressValue !== undefined || progressLabel\n ? h(\"div\", { class: s.Progress }, [\n h(\"div\", { class: s.ProgressTrack }, [\n h(\"div\", {\n \"class\": s.ProgressBar,\n \"style\": { width: `${progressValue ?? 0}%` },\n \"aria-hidden\": \"true\",\n }),\n ]),\n progressLabel ? h(\"div\", { class: s.ProgressLabel }, progressLabel) : null,\n ])\n : null\n\n const sparklineSlot = slots.sparkline?.()\n const sparklineEl = hasContent(sparklineSlot) ? h(\"div\", { class: s.Sparkline }, sparklineSlot) : null\n\n return h(\n \"div\",\n {\n \"class\": s.StatsCard,\n \"data-variant\": props.variant,\n \"data-size\": props.size,\n \"data-accent-color\": props.accentColor,\n },\n [headerEl, valueRowEl, trendRowEl, descriptionEl, progressEl, sparklineEl],\n )\n }\n },\n})\n\ntype StatsCardOwnProps = InstanceType<typeof StatsCardComponent>[\"$props\"]\n\n/** StatsCard props plus the native <div> attributes that fall through to it, as in React. */\nexport type StatsCardProps = StatsCardOwnProps & Omit<HTMLAttributes, keyof StatsCardOwnProps>\n\nexport const StatsCard = StatsCardComponent as typeof StatsCardComponent & { new (): { $props: StatsCardProps } }\n"]}
@@ -1,5 +1,6 @@
1
1
  import clsx from "clsx";
2
2
  import { defineComponent, h, onBeforeUnmount, onErrorCaptured, onMounted, ref, watch, } from "vue";
3
+ import { prefersReducedMotion } from "../../lib/helpers.js";
3
4
  import getDisableAnimations from "./getDisableAnimations.js";
4
5
  import { flattenChildren, isPlaceholder, useChildList } from "./childList.js";
5
6
  import { useTransitionChild } from "./useTransitionChild.js";
@@ -107,6 +108,11 @@ export const TransitionGroup = defineComponent({
107
108
  transitionId: String,
108
109
  /** Determines the amount of time that the enter state is applied during mounting */
109
110
  enterDuration: { type: Number, default: 0 },
111
+ /**
112
+ * The enter time with reduced motion, in place of `enterDuration`: for an overlay
113
+ * whose styles fade it in over a time of its own then (a Dialog, a Menu).
114
+ */
115
+ reducedMotionEnterDuration: Number,
110
116
  /** Determines the amount of time that the exit state is applied before unmounting */
111
117
  exitDuration: { type: Number, default: 0 },
112
118
  /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */
@@ -117,8 +123,8 @@ export const TransitionGroup = defineComponent({
117
123
  disableAnimations: { type: Boolean, default: () => getDisableAnimations() },
118
124
  /**
119
125
  * For overlays: an exiting child is `inert`, out of the tab order and of hit
120
- * testing, and with reduced motion it settles and leaves without waiting for
121
- * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).
126
+ * testing, and with reduced motion it leaves without waiting for `exitDuration`. It
127
+ * still waits out `enterDuration`: with reduced motion an overlay fades in over it.
122
128
  */
123
129
  overlay: Boolean,
124
130
  /** Determines how new children are added to the children array */
@@ -164,7 +170,9 @@ export const TransitionGroup = defineComponent({
164
170
  transitionId: props.transitionId,
165
171
  styleValue: style,
166
172
  shouldRender: child.shouldRender,
167
- enterDuration: props.enterDuration,
173
+ enterDuration: props.reducedMotionEnterDuration !== undefined && prefersReducedMotion()
174
+ ? props.reducedMotionEnterDuration
175
+ : props.enterDuration,
168
176
  exitDuration: props.exitDuration,
169
177
  overlay: props.overlay,
170
178
  removeChild: () => children.remove(child.key),
@@ -1 +1 @@
1
- {"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/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ourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onErrorCaptured,\n onMounted,\n ref,\n watch,\n type PropType,\n type StyleValue,\n type VNode,\n} from \"vue\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n overlay: Boolean,\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n // An exiting child stays mounted with live slots, where React renders its\n // last element: state cleared along with the close must not throw here\n onErrorCaptured(() => (props.shouldRender ? undefined : false))\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"inert\": props.overlay && state.exit ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it settles and leaves without waiting for\n * `enterDuration` or `exitDuration` (nothing moves, so nothing is held).\n */\n overlay: Boolean,\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration: props.enterDuration,\n exitDuration: props.exitDuration,\n overlay: props.overlay,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
1
+ {"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAIN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAO/E,MAAM,YAAY,GAAG,QAAkD,CAAA;AAEvE,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE;QAC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AAC,KAAK,CAAC,CAC3C,CACF,CAAA;YACH,CAAC;YAED,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,CAAC,CACC,oBAAoB,EACpB;gBACE,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;gBACpD,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,SAAS;gBACT,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,UAAU,EAAE,KAAK;gBACjB,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,aAAa,EACX,KAAK,CAAC,0BAA0B,KAAK,SAAS,IAAI,oBAAoB,EAAE;oBACtE,CAAC,CAAC,KAAK,CAAC,0BAA0B;oBAClC,CAAC,CAAC,KAAK,CAAC,aAAa;gBACzB,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC7C,SAAS;aACV,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CACjC,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onErrorCaptured,\n onMounted,\n ref,\n watch,\n type PropType,\n type StyleValue,\n type VNode,\n} from \"vue\"\nimport { prefersReducedMotion } from \"../../lib/helpers.js\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n overlay: Boolean,\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n // An exiting child stays mounted with live slots, where React renders its\n // last element: state cleared along with the close must not throw here\n onErrorCaptured(() => (props.shouldRender ? undefined : false))\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"inert\": props.overlay && state.exit ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /**\n * The enter time with reduced motion, in place of `enterDuration`: for an overlay\n * whose styles fade it in over a time of its own then (a Dialog, a Menu).\n */\n reducedMotionEnterDuration: Number,\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it leaves without waiting for `exitDuration`. It\n * still waits out `enterDuration`: with reduced motion an overlay fades in over it.\n */\n overlay: Boolean,\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration:\n props.reducedMotionEnterDuration !== undefined && prefersReducedMotion()\n ? props.reducedMotionEnterDuration\n : props.enterDuration,\n exitDuration: props.exitDuration,\n overlay: props.overlay,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
@@ -6,6 +6,12 @@ export const overlayTiming = { enterDuration: 250, exitDuration: 150 };
6
6
  export const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 };
7
7
  /** A submenu: it opens after a hover delay of its own, so it shows at once */
8
8
  export const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 };
9
+ /**
10
+ * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2
11
+ * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These
12
+ * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.
13
+ */
14
+ export const reducedMotionEnter = { dialog: 350, menu: 500 };
9
15
  /**
10
16
  * An overlay stays a dismissable layer through its exit. A press on its trigger
11
17
  * turns it around, and the layer must not count that press as outside and
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAuDnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AACtE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YACD,aAAa,EAAE,GAAG,EAAE;gBAClB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;YACD,cAAc,EAAE,GAAG,EAAE;gBACnB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;SACF;QACD,iBAAiB,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,IAAI,OAAO;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["// Types and helpers shared by the Vue transition components. Mirrors\n// packages/ui/src/components/Transition/shared.ts.\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n/** The element a transition callback receives (HTML or SVG) */\nexport type TransitionElement = HTMLElement | SVGElement\n\nexport type TransitionGroupChildCallback = (element: TransitionElement) => void\n\n/** Lifecycle hooks, called with the transitioning element (same moments as React's `onEnter`...). */\nexport type TransitionGroupChildCallbacks = {\n onEnter?: TransitionGroupChildCallback\n onEnterActive?: TransitionGroupChildCallback\n onEnterComplete?: TransitionGroupChildCallback\n onExit?: TransitionGroupChildCallback\n onExitActive?: TransitionGroupChildCallback\n onExitComplete?: TransitionGroupChildCallback\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n/** A submenu: it opens after a hover delay of its own, so it shows at once */\nexport const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAuDnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AACtE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAC3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YACD,aAAa,EAAE,GAAG,EAAE;gBAClB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;YACD,cAAc,EAAE,GAAG,EAAE;gBACnB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;SACF;QACD,iBAAiB,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,IAAI,OAAO;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["// Types and helpers shared by the Vue transition components. Mirrors\n// packages/ui/src/components/Transition/shared.ts.\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n/** The element a transition callback receives (HTML or SVG) */\nexport type TransitionElement = HTMLElement | SVGElement\n\nexport type TransitionGroupChildCallback = (element: TransitionElement) => void\n\n/** Lifecycle hooks, called with the transitioning element (same moments as React's `onEnter`...). */\nexport type TransitionGroupChildCallbacks = {\n onEnter?: TransitionGroupChildCallback\n onEnterActive?: TransitionGroupChildCallback\n onEnterComplete?: TransitionGroupChildCallback\n onExit?: TransitionGroupChildCallback\n onExitActive?: TransitionGroupChildCallback\n onExitComplete?: TransitionGroupChildCallback\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n/** A submenu: it opens after a hover delay of its own, so it shows at once */\nexport const overlayTimingQuick = { enterDuration: 100, exitDuration: 100 }\n/**\n * With reduced motion a Dialog and a Menu fade in place, as on iOS with Reduce Motion (measured on the iOS 27.2\n * simulator: a sheet about 350 ms, a menu about 500 ms), and stay entering, holding touches, for the whole fade. These\n * match --motion-reduced-enter-dialog and --motion-reduced-enter-menu.\n */\nexport const reducedMotionEnter = { dialog: 350, menu: 500 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n"]}
@@ -69,7 +69,7 @@ export function useTransitionChild(props, getElement) {
69
69
  enterTimeout = window.setTimeout(() => {
70
70
  dispatch({ type: "done" });
71
71
  trigger("enter-complete");
72
- }, props.overlay && prefersReducedMotion() ? 0 : props.enterDuration);
72
+ }, props.enterDuration);
73
73
  });
74
74
  cancel = () => {
75
75
  cancelFrame();
@@ -1 +1 @@
1
- {"version":3,"file":"useTransitionChild.js","sourceRoot":"","sources":["../../../../src/components/Transition/useTransitionChild.ts"],"names":[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AAA;YACvB,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;gBAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAA;YAC3B,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QACvE,CAAC,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,EAAE;YACZ,WAAW,EAAE,CAAA;YACb,IAAI,YAAY,KAAK,SAAS;gBAAE,YAAY,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAA;IACH,CAAC,CAAA;IAED,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;IACxC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IACvD,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAEjC,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { onBeforeUnmount, onMounted, reactive, watch } from \"vue\"\nimport { prefersReducedMotion, waitForAnimationFrame } from \"../../lib/helpers.js\"\nimport type { CallbackType, TransitionElement, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { getInitialTransitionState, transitionReducer, type TransitionStateAction } from \"./transitionReducer.js\"\n\nexport type TransitionChildProps = {\n shouldRender: boolean\n preventMountTransition?: boolean\n enterDuration: number\n exitDuration: number\n overlay?: boolean\n removeChild: () => void\n callbacks?: TransitionGroupChildCallbacks\n}\n\nconst CALLBACKS: Record<CallbackType, keyof TransitionGroupChildCallbacks> = {\n \"enter\": \"onEnter\",\n \"enter-active\": \"onEnterActive\",\n \"enter-complete\": \"onEnterComplete\",\n \"exit\": \"onExit\",\n \"exit-active\": \"onExitActive\",\n \"exit-complete\": \"onExitComplete\",\n}\n\n/**\n * The per-child enter/exit state machine of React's TransitionGroupChild\n * (same reducer, frames and timers), shared by TransitionGroup and\n * SlotTransitionGroup. Returns the reactive state that drives the\n * `data-entering*` / `data-exiting*` / `data-interrupted` attributes.\n */\nexport function useTransitionChild(props: TransitionChildProps, getElement: () => TransitionElement | null) {\n const state = reactive(getInitialTransitionState(!!props.preventMountTransition))\n const dispatch = (action: TransitionStateAction) => {\n Object.assign(state, transitionReducer(state, action))\n }\n\n let lastCallback: CallbackType | null = null\n const trigger = (type: CallbackType) => {\n const element = getElement()\n if (!element || type === lastCallback) return\n lastCallback = type\n props.callbacks?.[CALLBACKS[type]]?.(element)\n }\n\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n let preventedMountTransition = false\n let cancel: (() => void) | undefined\n\n const run = (shouldRender: boolean) => {\n cancel?.()\n cancel = undefined\n\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n dispatch({ type: \"exit-before\" })\n trigger(\"exit\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n trigger(\"exit-active\")\n exitTimeout = window.setTimeout(\n () => {\n trigger(\"exit-complete\")\n props.removeChild()\n },\n props.overlay && prefersReducedMotion() ? 0 : props.exitDuration,\n )\n })\n cancel = () => {\n cancelFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n return\n }\n\n // Enter transition: check if we need to prevent this specific entering cycle\n if (props.preventMountTransition && !preventedMountTransition) {\n preventedMountTransition = true\n return\n }\n\n let enterTimeout: number | undefined\n dispatch({ type: \"enter-before\" })\n trigger(\"enter\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n trigger(\"enter-active\")\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n trigger(\"enter-complete\")\n }, props.overlay && prefersReducedMotion() ? 0 : props.enterDuration)\n })\n cancel = () => {\n cancelFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }\n\n onMounted(() => run(props.shouldRender))\n watch(() => props.shouldRender, run, { flush: \"post\" })\n onBeforeUnmount(() => cancel?.())\n\n return state\n}\n"]}
1
+ {"version":3,"file":"useTransitionChild.js","sourceRoot":"","sources":["../../../../src/components/Transition/useTransitionChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAElF,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAA8B,MAAM,wBAAwB,CAAA;AAYjH,MAAM,SAAS,GAA8D;IAC3E,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,eAAe;IAC/B,gBAAgB,EAAE,iBAAiB;IACnC,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,cAAc;IAC7B,eAAe,EAAE,gBAAgB;CAClC,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA2B,EAAE,UAA0C;IACxG,MAAM,KAAK,GAAG,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAA;IACjF,MAAM,QAAQ,GAAG,CAAC,MAA6B,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACxD,CAAC,CAAA;IAED,IAAI,YAAY,GAAwB,IAAI,CAAA;IAC5C,MAAM,OAAO,GAAG,CAAC,IAAkB,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;QAC5B,IAAI,CAAC,OAAO,IAAI,IAAI,KAAK,YAAY;YAAE,OAAM;QAC7C,YAAY,GAAG,IAAI,CAAA;QACnB,KAA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AA;QACpC,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;QAClC,OAAO,CAAC,OAAO,CAAC,CAAA;QAChB,MAAM,WAAW,GAAG,qBAAqB,CAAC,GAAG,EAAE;YAC7C,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;YAClC,OAAO,CAAC,cAAc,CAAC,CAAA;YACvB,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;gBAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAA;YAC3B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,EAAE;YACZ,WAAW,EAAE,CAAA;YACb,IAAI,YAAY,KAAK,SAAS;gBAAE,YAAY,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAA;IACH,CAAC,CAAA;IAED,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;IACxC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IACvD,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAEjC,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { onBeforeUnmount, onMounted, reactive, watch } from \"vue\"\nimport { prefersReducedMotion, waitForAnimationFrame } from \"../../lib/helpers.js\"\nimport type { CallbackType, TransitionElement, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { getInitialTransitionState, transitionReducer, type TransitionStateAction } from \"./transitionReducer.js\"\n\nexport type TransitionChildProps = {\n shouldRender: boolean\n preventMountTransition?: boolean\n enterDuration: number\n exitDuration: number\n overlay?: boolean\n removeChild: () => void\n callbacks?: TransitionGroupChildCallbacks\n}\n\nconst CALLBACKS: Record<CallbackType, keyof TransitionGroupChildCallbacks> = {\n \"enter\": \"onEnter\",\n \"enter-active\": \"onEnterActive\",\n \"enter-complete\": \"onEnterComplete\",\n \"exit\": \"onExit\",\n \"exit-active\": \"onExitActive\",\n \"exit-complete\": \"onExitComplete\",\n}\n\n/**\n * The per-child enter/exit state machine of React's TransitionGroupChild\n * (same reducer, frames and timers), shared by TransitionGroup and\n * SlotTransitionGroup. Returns the reactive state that drives the\n * `data-entering*` / `data-exiting*` / `data-interrupted` attributes.\n */\nexport function useTransitionChild(props: TransitionChildProps, getElement: () => TransitionElement | null) {\n const state = reactive(getInitialTransitionState(!!props.preventMountTransition))\n const dispatch = (action: TransitionStateAction) => {\n Object.assign(state, transitionReducer(state, action))\n }\n\n let lastCallback: CallbackType | null = null\n const trigger = (type: CallbackType) => {\n const element = getElement()\n if (!element || type === lastCallback) return\n lastCallback = type\n props.callbacks?.[CALLBACKS[type]]?.(element)\n }\n\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n let preventedMountTransition = false\n let cancel: (() => void) | undefined\n\n const run = (shouldRender: boolean) => {\n cancel?.()\n cancel = undefined\n\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n dispatch({ type: \"exit-before\" })\n trigger(\"exit\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n trigger(\"exit-active\")\n exitTimeout = window.setTimeout(\n () => {\n trigger(\"exit-complete\")\n props.removeChild()\n },\n props.overlay && prefersReducedMotion() ? 0 : props.exitDuration,\n )\n })\n cancel = () => {\n cancelFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n return\n }\n\n // Enter transition: check if we need to prevent this specific entering cycle\n if (props.preventMountTransition && !preventedMountTransition) {\n preventedMountTransition = true\n return\n }\n\n let enterTimeout: number | undefined\n dispatch({ type: \"enter-before\" })\n trigger(\"enter\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n trigger(\"enter-active\")\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n trigger(\"enter-complete\")\n }, props.enterDuration)\n })\n cancel = () => {\n cancelFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }\n\n onMounted(() => run(props.shouldRender))\n watch(() => props.shouldRender, run, { flush: \"post\" })\n onBeforeUnmount(() => cancel?.())\n\n return state\n}\n"]}