magic-pill 9.3.0 → 9.4.0-next.2

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 (54) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +114 -3
  3. package/dist/MagicPill/MagicPill.d.mts +51 -1
  4. package/dist/MagicPill/MagicPill.d.ts +51 -1
  5. package/dist/MagicPill/MagicPill.js +53 -4
  6. package/dist/MagicPill/MagicPill.mjs +55 -6
  7. package/dist/MagicPill/flag.js +1 -59
  8. package/dist/MagicPill/flag.mjs +1 -58
  9. package/dist/Pill/PillProgress.d.mts +12 -0
  10. package/dist/Pill/PillProgress.d.ts +12 -0
  11. package/dist/Pill/PillProgress.js +42 -0
  12. package/dist/Pill/PillProgress.mjs +42 -0
  13. package/dist/Pill/goo.js +576 -0
  14. package/dist/Pill/goo.mjs +566 -0
  15. package/dist/Pill/morph.js +11 -4
  16. package/dist/Pill/morph.mjs +10 -5
  17. package/dist/PillNavbar/PillNavbar.d.mts +8 -0
  18. package/dist/PillNavbar/PillNavbar.d.ts +8 -0
  19. package/dist/PillNavbar/PillNavbar.js +3 -2
  20. package/dist/PillNavbar/PillNavbar.mjs +3 -2
  21. package/dist/PillNavbar/room.d.mts +3 -0
  22. package/dist/PillNavbar/room.d.ts +2 -0
  23. package/dist/PillNavbar/room.js +89 -17
  24. package/dist/PillNavbar/room.mjs +89 -18
  25. package/dist/index.d.mts +3 -2
  26. package/dist/index.d.ts +3 -2
  27. package/dist/index.js +2 -0
  28. package/dist/index.mjs +2 -1
  29. package/dist/satellites/Actions.d.mts +12 -0
  30. package/dist/satellites/Actions.d.ts +11 -0
  31. package/dist/satellites/Actions.js +181 -0
  32. package/dist/satellites/Actions.mjs +177 -0
  33. package/dist/satellites/Orbitals.js +585 -0
  34. package/dist/satellites/Orbitals.mjs +585 -0
  35. package/dist/satellites/Satellites.js +634 -0
  36. package/dist/satellites/Satellites.mjs +634 -0
  37. package/dist/satellites/layout.js +209 -0
  38. package/dist/satellites/layout.mjs +209 -0
  39. package/dist/satellites/measure.js +25 -0
  40. package/dist/satellites/measure.mjs +24 -0
  41. package/dist/satellites/orbits.js +139 -0
  42. package/dist/satellites/orbits.mjs +136 -0
  43. package/dist/satellites/types.d.mts +58 -0
  44. package/dist/satellites/types.d.ts +58 -0
  45. package/dist/satellites.d.mts +5 -0
  46. package/dist/satellites.d.ts +5 -0
  47. package/dist/satellites.js +14 -0
  48. package/dist/satellites.mjs +12 -0
  49. package/dist/store/store.d.mts +103 -0
  50. package/dist/store/store.d.ts +103 -0
  51. package/dist/store/store.js +52 -1
  52. package/dist/store/store.mjs +52 -2
  53. package/dist/styles.css +322 -8
  54. package/package.json +11 -1
@@ -1,5 +1,4 @@
1
1
  import { findActiveIndex } from "../PillNavbar/matchPath.mjs";
2
- import { prefersReducedMotion } from "../utils/timing.mjs";
3
2
 
4
3
  // src/MagicPill/flag.ts
5
4
  /** Measures the sidebar, and the navbar item whose `href` matches `at`, if any. */
@@ -31,61 +30,5 @@ function flagStyle({ shift, y }) {
31
30
  }
32
31
  return style;
33
32
  }
34
- /**
35
- * The bridge between the sidebar and its flag: it stretches out of the
36
- * sidebar as the flag pops out of it, then thins away as they part
37
- * (`split`), or the other way round as the flag goes back (`join`).
38
- */
39
- function playBridge(sidebar, flag, y, kind, timing) {
40
- if (timing.duration <= 0 || prefersReducedMotion() || typeof document.body.animate !== "function") return;
41
- const rect = sidebar.getBoundingClientRect();
42
- const flagStyles = getComputedStyle(flag);
43
- const gap = (Number.parseFloat(flagStyles.columnGap) || 16) * .75;
44
- const onRight = flag.dataset.placement === "right";
45
- const overlap = 8;
46
- const thickness = 22;
47
- const centre = y ?? rect.top + rect.height / 2;
48
- const bridge = document.createElement("div");
49
- bridge.setAttribute("data-mp", "flag-bridge");
50
- bridge.setAttribute("aria-hidden", "true");
51
- const from = getComputedStyle(sidebar).backgroundColor;
52
- const to = flagStyles.backgroundColor;
53
- bridge.style.cssText = [
54
- "position:fixed",
55
- "pointer-events:none",
56
- `z-index:${(Number.parseInt(flagStyles.zIndex, 10) || 50) - 1}`,
57
- `top:${centre - thickness / 2}px`,
58
- `left:${onRight ? rect.left - gap - overlap : rect.right - overlap}px`,
59
- `width:${gap + 16}px`,
60
- `height:${thickness}px`,
61
- `border-radius:${thickness / 2}px`,
62
- `background:linear-gradient(to ${onRight ? "left" : "right"}, ${from}, ${to})`,
63
- `transform-origin:${onRight ? "right" : "left"} center`,
64
- "transform:scaleX(0)"
65
- ].join(";");
66
- document.body.append(bridge);
67
- const out = [
68
- { transform: "scaleX(0)" },
69
- {
70
- transform: "scaleX(1)",
71
- offset: .35
72
- },
73
- {
74
- transform: "scaleX(1) scaleY(0.35)",
75
- offset: .7
76
- },
77
- { transform: "scaleX(1) scaleY(0)" }
78
- ];
79
- const remove = () => bridge.remove();
80
- bridge.animate(kind === "split" ? out : [...out].reverse().map((frame, index, all) => ({
81
- ...frame,
82
- offset: index / (all.length - 1)
83
- })), {
84
- delay: timing.delay,
85
- duration: timing.duration,
86
- easing: "ease-out",
87
- fill: "both"
88
- }).finished.then(remove, remove);
89
- }
90
33
 
91
- export { flagStyle, measureFlagSpot, playBridge };
34
+ export { flagStyle, measureFlagSpot };
@@ -0,0 +1,12 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ export interface PillProgressProps extends ComponentPropsWithoutRef<"span"> {
3
+ /** 0 to 1: how much of the ring is drawn. */
4
+ value: number;
5
+ /**
6
+ * What it measures, for screen readers ("Upload"). Without it, the ring is
7
+ * decorative: the pill around it says what it is (an electron's name).
8
+ */
9
+ label?: string;
10
+ }
11
+ /** A progress ring around its content (a value, an icon), in the text colour. */
12
+ export declare const PillProgress: import("react").ForwardRefExoticComponent<PillProgressProps & import("react").RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,12 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ export interface PillProgressProps extends ComponentPropsWithoutRef<"span"> {
3
+ /** 0 to 1: how much of the ring is drawn. */
4
+ value: number;
5
+ /**
6
+ * What it measures, for screen readers ("Upload"). Without it, the ring is
7
+ * decorative: the pill around it says what it is (an electron's name).
8
+ */
9
+ label?: string;
10
+ }
11
+ /** A progress ring around its content (a value, an icon), in the text colour. */
12
+ export declare const PillProgress: import("react").ForwardRefExoticComponent<PillProgressProps & import("react").RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,42 @@
1
+ let react = require("react");
2
+ let react_jsx_runtime = require("react/jsx-runtime");
3
+
4
+ // src/Pill/PillProgress.tsx
5
+ /** A progress ring around its content (a value, an icon), in the text colour. */
6
+ const PillProgress = (0, react.forwardRef)(function PillProgress({ value, label, children, ...rest }, ref) {
7
+ const amount = Math.min(1, Math.max(0, Number.isFinite(value) ? value : 0));
8
+ const a11y = label ? {
9
+ role: "progressbar",
10
+ "aria-label": label,
11
+ "aria-valuemin": 0,
12
+ "aria-valuemax": 100,
13
+ "aria-valuenow": Math.round(amount * 100)
14
+ } : {};
15
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
16
+ ...a11y,
17
+ ...rest,
18
+ ref,
19
+ "data-mp": "progress",
20
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
21
+ viewBox: "0 0 54 54",
22
+ "aria-hidden": "true",
23
+ focusable: "false",
24
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
25
+ "data-mp": "progress-track",
26
+ cx: "27",
27
+ cy: "27",
28
+ r: "24",
29
+ pathLength: "100"
30
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
31
+ "data-mp": "progress-bar",
32
+ cx: "27",
33
+ cy: "27",
34
+ r: "24",
35
+ pathLength: "100",
36
+ strokeDasharray: `${amount * 100} 100`
37
+ })]
38
+ }), children]
39
+ });
40
+ });
41
+
42
+ exports.PillProgress = PillProgress;
@@ -0,0 +1,42 @@
1
+ import { forwardRef } from "react";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+
4
+ // src/Pill/PillProgress.tsx
5
+ /** A progress ring around its content (a value, an icon), in the text colour. */
6
+ const PillProgress = forwardRef(function PillProgress({ value, label, children, ...rest }, ref) {
7
+ const amount = Math.min(1, Math.max(0, Number.isFinite(value) ? value : 0));
8
+ const a11y = label ? {
9
+ role: "progressbar",
10
+ "aria-label": label,
11
+ "aria-valuemin": 0,
12
+ "aria-valuemax": 100,
13
+ "aria-valuenow": Math.round(amount * 100)
14
+ } : {};
15
+ return /* @__PURE__ */ jsxs("span", {
16
+ ...a11y,
17
+ ...rest,
18
+ ref,
19
+ "data-mp": "progress",
20
+ children: [/* @__PURE__ */ jsxs("svg", {
21
+ viewBox: "0 0 54 54",
22
+ "aria-hidden": "true",
23
+ focusable: "false",
24
+ children: [/* @__PURE__ */ jsx("circle", {
25
+ "data-mp": "progress-track",
26
+ cx: "27",
27
+ cy: "27",
28
+ r: "24",
29
+ pathLength: "100"
30
+ }), /* @__PURE__ */ jsx("circle", {
31
+ "data-mp": "progress-bar",
32
+ cx: "27",
33
+ cy: "27",
34
+ r: "24",
35
+ pathLength: "100",
36
+ strokeDasharray: `${amount * 100} 100`
37
+ })]
38
+ }), children]
39
+ });
40
+ });
41
+
42
+ export { PillProgress };