@photon-ai/pho-ui 4.11.0 → 4.12.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 (48) hide show
  1. package/dist/chunks/animated-height-zr7BmFY1.js +56 -0
  2. package/dist/chunks/animated-height-zr7BmFY1.js.map +1 -0
  3. package/dist/chunks/basic-page-CJ11ekjH.js +2217 -0
  4. package/dist/chunks/basic-page-CJ11ekjH.js.map +1 -0
  5. package/dist/chunks/{chat-B0WIgEyM.js → chat-CU3XVm99.js} +2 -2
  6. package/dist/chunks/{chat-B0WIgEyM.js.map → chat-CU3XVm99.js.map} +1 -1
  7. package/dist/chunks/{checkbox-CLPmblNA.js → checkbox-CwvoEJhd.js} +2 -2
  8. package/dist/chunks/{checkbox-CLPmblNA.js.map → checkbox-CwvoEJhd.js.map} +1 -1
  9. package/dist/chunks/choice-card-_Ocs0iUj.js +17 -0
  10. package/dist/chunks/choice-card-_Ocs0iUj.js.map +1 -0
  11. package/dist/chunks/{command-iYvU6Mhf.js → command-D5g49VqR.js} +3 -3
  12. package/dist/chunks/{command-iYvU6Mhf.js.map → command-D5g49VqR.js.map} +1 -1
  13. package/dist/chunks/{data-table-B1dmrN6r.js → data-table-Ce_c6T73.js} +3 -3
  14. package/dist/chunks/{data-table-B1dmrN6r.js.map → data-table-Ce_c6T73.js.map} +1 -1
  15. package/dist/chunks/{dialog-MPvem7yV.js → dialog-ChS0tdHa.js} +120 -116
  16. package/dist/chunks/dialog-ChS0tdHa.js.map +1 -0
  17. package/dist/chunks/{filter-bar-B-oYYBsU.js → filter-bar-CMkvhvgL.js} +2 -2
  18. package/dist/chunks/{filter-bar-B-oYYBsU.js.map → filter-bar-CMkvhvgL.js.map} +1 -1
  19. package/dist/chunks/{input-DjvZoF8v.js → input-fFWvPJOf.js} +2 -1
  20. package/dist/chunks/{input-DjvZoF8v.js.map → input-fFWvPJOf.js.map} +1 -1
  21. package/dist/components/chat.js +1 -1
  22. package/dist/components/checkbox.js +1 -1
  23. package/dist/components/command.js +1 -1
  24. package/dist/components/data-table.js +1 -1
  25. package/dist/components/dialog.js +1 -1
  26. package/dist/components/field.js +34 -29
  27. package/dist/components/field.js.map +1 -1
  28. package/dist/components/filter-bar.js +1 -1
  29. package/dist/components/input.js +1 -1
  30. package/dist/components/radio-group.js +64 -59
  31. package/dist/components/radio-group.js.map +1 -1
  32. package/dist/index.js +6 -6
  33. package/dist/sections/basic-page.js +2 -2
  34. package/dist/src/components/dialog/dialog.d.ts +9 -1
  35. package/dist/src/components/field/field.d.ts +11 -1
  36. package/dist/src/components/radio-group/radio-card.d.ts +11 -4
  37. package/dist/src/sections/basic-page/basic-page.d.ts +145 -15
  38. package/dist/src/sections/basic-page/index.d.ts +1 -1
  39. package/dist/src/utils/animated-height.d.ts +16 -7
  40. package/dist/src/utils/choice-card.d.ts +8 -1
  41. package/package.json +1 -1
  42. package/dist/chunks/animated-height-I44sUq0n.js +0 -48
  43. package/dist/chunks/animated-height-I44sUq0n.js.map +0 -1
  44. package/dist/chunks/basic-page-B5FsORRi.js +0 -1885
  45. package/dist/chunks/basic-page-B5FsORRi.js.map +0 -1
  46. package/dist/chunks/choice-card-BVNP1NB6.js +0 -17
  47. package/dist/chunks/choice-card-BVNP1NB6.js.map +0 -1
  48. package/dist/chunks/dialog-MPvem7yV.js.map +0 -1
@@ -1,15 +1,24 @@
1
- import { ReactNode } from 'react';
2
- import { ValueAnimationTransition } from 'motion/react';
1
+ import { ReactNode, RefObject } from 'react';
2
+ import { MotionValue, ValueAnimationTransition } from 'motion/react';
3
3
  /**
4
- * Animates its own height to follow the measured height of `children`, so
5
- * content swaps (search filtering, skeleton → data) glide instead of jumping.
6
- * Honors `prefers-reduced-motion` by snapping height with no spring.
4
+ * Keeps a container's size on one axis following the measured size of its
5
+ * content on a spring — the core of `AnimatedHeight`, and of any part whose
6
+ * box should glide as its content changes (a paged `Onboard`'s step titles
7
+ * follow their words' width this way). Returns the motion value to put on
8
+ * the container's `style`. Reduced motion snaps it.
7
9
  *
8
10
  * The container clips only while the spring is in flight. ResizeObserver
9
11
  * callbacks run after layout but before paint, so the clip lands before the
10
12
  * swap frame can show; once the spring settles it is lifted again, so a focus
11
- * ring, an effect button's rim, or any other overhang on the last row paints
12
- * normally at rest instead of being cut off at the container's edge.
13
+ * ring, an effect button's rim, or any other overhang paints normally at
14
+ * rest instead of being cut off at the container's edge.
15
+ */
16
+ export declare function useSizeFollow(axis: "height" | "width", containerRef: RefObject<HTMLElement | null>, contentRef: RefObject<HTMLElement | null>, transition: ValueAnimationTransition<number | "auto">): MotionValue<number | "auto">;
17
+ /**
18
+ * Animates its own height to follow the measured height of `children`, so
19
+ * content swaps (search filtering, skeleton → data) glide instead of jumping.
20
+ * Honors `prefers-reduced-motion` by snapping height with no spring. Clips
21
+ * only while the spring is in flight (see `useSizeFollow`).
13
22
  */
14
23
  export declare function AnimatedHeight({ className, transition, children, }: {
15
24
  className?: string;
@@ -4,8 +4,15 @@ import { Transition } from 'motion/react';
4
4
  * tile. Applied to the radio/checkbox root itself so the whole tile is the
5
5
  * hit target. Hover fills (`bg-pho-ghost-hover`); selected uses the brand
6
6
  * ring. Press feedback lives on this surface (see `usePressPulse`).
7
+ *
8
+ * The side padding is `--choice-card-inset`, 12px unless the page says
9
+ * otherwise, and the padding above and below is three quarters of it: a
10
+ * `BasicPage.Stack` sets it to the page's text edge (20px), so tiles
11
+ * standing on the page as its surfaces reach the column's edge as a card
12
+ * does and start their words on the headings' line; a card, sheet or
13
+ * callout sets it back, so tiles inside one stay compact.
7
14
  */
8
- export declare const CHOICE_CARD_BASE = "group outline-pho-brand flex flex-1 cursor-pointer items-start gap-2.5 rounded-base p-3 text-base text-pho-secondary ring-1 ring-pho-primary ring-inset transition-[box-shadow,background-color] duration-150 ease-out select-none hover:bg-pho-ghost-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:hover:bg-transparent data-[checked]:ring-2 data-[checked]:ring-pho-brand has-[[data-checked]]:ring-2 has-[[data-checked]]:ring-pho-brand focus-visible:outline-2 focus-visible:outline-offset-2 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2";
15
+ export declare const CHOICE_CARD_BASE = "group outline-pho-brand flex flex-1 cursor-pointer items-start gap-2.5 rounded-base px-[var(--choice-card-inset,0.75rem)] py-[calc(var(--choice-card-inset,0.75rem)*0.75)] text-base text-pho-secondary ring-1 ring-pho-primary ring-inset transition-[box-shadow,background-color] duration-150 ease-out select-none hover:bg-pho-ghost-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:hover:bg-transparent data-[checked]:ring-2 data-[checked]:ring-pho-brand has-[[data-checked]]:ring-2 has-[[data-checked]]:ring-pho-brand focus-visible:outline-2 focus-visible:outline-offset-2 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2";
9
16
  /** Stacked icon above the copy — tighter than the checkbox/radio row gap. */
10
17
  export declare const CHOICE_CARD_WITH_ICON = "flex-col gap-1.5";
11
18
  /** Same press as Select's default trigger — field-sized, not Button's whileTap. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photon-ai/pho-ui",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "Pho Design System — Photon's React component library, built on Base UI",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1,48 +0,0 @@
1
- "use client";
2
- import { SPRING_SETTLE as b } from "../motion.js";
3
- import { useEffect as R, useRef as m } from "react";
4
- import { jsx as d } from "react/jsx-runtime";
5
- import { animate as x, motion as S, useMotionValue as g, useReducedMotion as w } from "motion/react";
6
- var y = b;
7
- function G({ className: p, transition: s, children: v }) {
8
- const i = m(null), c = m(null), t = g("auto"), l = w();
9
- return R(() => {
10
- const o = i.current, n = c.current;
11
- if (!o || !n) return;
12
- let e = null;
13
- const u = new ResizeObserver((h) => {
14
- const f = h[0]?.borderBoxSize?.[0], r = f ? f.blockSize : n.offsetHeight, a = t.get();
15
- if (a === "auto" || l) {
16
- e?.stop(), e = null, o.style.overflow = "", t.set(r);
17
- return;
18
- }
19
- !e && Math.abs(a - r) < 0.5 || (o.style.overflow = "hidden", e?.stop(), e = x(t, r, {
20
- ...s ?? y,
21
- onComplete: () => {
22
- e = null, o.style.overflow = "";
23
- }
24
- }));
25
- });
26
- return u.observe(n), () => {
27
- u.disconnect(), e?.stop();
28
- };
29
- }, [
30
- t,
31
- l,
32
- s
33
- ]), /* @__PURE__ */ d(S.div, {
34
- ref: i,
35
- className: "min-h-0",
36
- style: { height: t },
37
- children: /* @__PURE__ */ d("div", {
38
- ref: c,
39
- className: p,
40
- children: v
41
- })
42
- });
43
- }
44
- export {
45
- G as t
46
- };
47
-
48
- //# sourceMappingURL=animated-height-I44sUq0n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"animated-height-I44sUq0n.js","names":[],"sources":["../../src/utils/animated-height.tsx"],"sourcesContent":["import { useEffect, useRef, type ReactNode } from \"react\";\nimport { SPRING_SETTLE } from \"../motion\";\nimport {\n animate,\n motion,\n useMotionValue,\n useReducedMotion,\n type ValueAnimationTransition,\n} from \"motion/react\";\n\n/**\n * Height spring for container-size transitions — same feel as the onboarding /\n * invite card and BasicPage footer reveal: quick, critically damped (no\n * overshoot that would flash clipped content).\n */\nconst HEIGHT_SPRING = SPRING_SETTLE;\n\n/**\n * Animates its own height to follow the measured height of `children`, so\n * content swaps (search filtering, skeleton → data) glide instead of jumping.\n * Honors `prefers-reduced-motion` by snapping height with no spring.\n *\n * The container clips only while the spring is in flight. ResizeObserver\n * callbacks run after layout but before paint, so the clip lands before the\n * swap frame can show; once the spring settles it is lifted again, so a focus\n * ring, an effect button's rim, or any other overhang on the last row paints\n * normally at rest instead of being cut off at the container's edge.\n */\nexport function AnimatedHeight({\n className,\n transition,\n children,\n}: {\n className?: string;\n /** Spring override for the height follow. @default the Command spring */\n transition?: ValueAnimationTransition<number | \"auto\">;\n children: ReactNode;\n}) {\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const height = useMotionValue<number | \"auto\">(\"auto\");\n const reduceMotion = useReducedMotion();\n\n useEffect(() => {\n const container = containerRef.current;\n const content = contentRef.current;\n if (!container || !content) return;\n\n let animation: ReturnType<typeof animate> | null = null;\n\n const observer = new ResizeObserver((entries) => {\n const box = entries[0]?.borderBoxSize?.[0];\n const next = box ? box.blockSize : content.offsetHeight;\n const current = height.get();\n if (current === \"auto\" || reduceMotion) {\n animation?.stop();\n animation = null;\n container.style.overflow = \"\";\n height.set(next);\n return;\n }\n if (!animation && Math.abs(current - next) < 0.5) return;\n container.style.overflow = \"hidden\";\n animation?.stop();\n animation = animate(height, next, {\n ...(transition ?? HEIGHT_SPRING),\n // Not fired on stop(), so a retarget can't lift the clip early.\n onComplete: () => {\n animation = null;\n container.style.overflow = \"\";\n },\n });\n });\n observer.observe(content);\n\n return () => {\n observer.disconnect();\n animation?.stop();\n };\n }, [height, reduceMotion, transition]);\n\n return (\n <motion.div\n ref={containerRef}\n // Stack (and other flex parents) set `min-height: auto` on children,\n // which sizes to content and swallows the height spring. Allow\n // shrinking so the measured height can actually animate; the clip is\n // applied imperatively for the spring's duration only (see above).\n className=\"min-h-0\"\n style={{ height }}\n >\n <div ref={contentRef} className={className}>\n {children}\n </div>\n </motion.div>\n );\n}\n"],"mappings":";;;;;AAeA,IAAM,IAAgB;AAatB,SAAgB,EAAe,EAC7B,WAAA,GACA,YAAA,GACA,UAAA,EAAA,GAMC;AACD,QAAM,IAAe,EAAuB,IAAI,GAC1C,IAAa,EAAuB,IAAI,GACxC,IAAS,EAAgC,MAAM,GAC/C,IAAe,EAAiB;AAEtC,SAAA,EAAA,MAAgB;AACd,UAAM,IAAY,EAAa,SACzB,IAAU,EAAW;AAC3B,QAAI,CAAC,KAAa,CAAC,EAAS;AAE5B,QAAI,IAA+C;AAEnD,UAAM,IAAW,IAAI,eAAA,CAAgB,MAAY;AAC/C,YAAM,IAAM,EAAQ,CAAA,G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