@mortenbrudvik/waveui 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,146 +5,154 @@ import { slotRendersContent as i } from "../../lib/slot.mjs";
5
5
  import { teachingPopoverClassNames as ee } from "../../lib/classNames.mjs";
6
6
  import { useEventCallback as a } from "../../hooks/useEventCallback.mjs";
7
7
  import { useControllable as o } from "../../hooks/useControllable.mjs";
8
- import { useId as s } from "../../hooks/useId.mjs";
9
- import { useMergedRefs as te } from "../../hooks/useMergedRefs.mjs";
10
- import { useTargetConflictWarning as ne } from "../../hooks/useResolvedTarget.mjs";
11
- import { TeachingPopoverContext as re } from "./TeachingPopover.context.mjs";
12
- import { TeachingPopoverSurface as c, TeachingPopoverTrigger as l, TeachingSurface as ie } from "./TeachingPopover.parts.mjs";
13
- import * as u from "react";
14
- import { jsx as ae, jsxs as oe } from "react/jsx-runtime";
8
+ import { useId as te } from "../../hooks/useId.mjs";
9
+ import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
10
+ import { useTargetConflictWarning as re } from "../../hooks/useResolvedTarget.mjs";
11
+ import { TeachingPopoverContext as ie } from "./TeachingPopover.context.mjs";
12
+ import { TeachingPopoverSurface as s, TeachingPopoverTrigger as c, TeachingSurface as ae } from "./TeachingPopover.parts.mjs";
13
+ import * as l from "react";
14
+ import { jsx as oe, jsxs as se } from "react/jsx-runtime";
15
15
  //#region src/components/overlays/TeachingPopover.root.tsx
16
- var se = "Back", ce = "Next", le = "Done", ue = "Choose step", de = (e, t) => `step ${e + 1} of ${t}`, fe = (e, t) => `Step ${e + 1} of ${t}`;
17
- function pe(e, t) {
16
+ var ce = "Back", le = "Next", ue = "Done", de = "Choose step", fe = (e, t) => `step ${e + 1} of ${t}`, pe = (e, t) => `Step ${e + 1} of ${t}`;
17
+ function u(e, t) {
18
18
  return i(e) ? e : i(t) ? t : void 0;
19
19
  }
20
- function me(e, t) {
20
+ function d(e, t) {
21
21
  return Number.isFinite(e) ? Math.min(Math.max(Math.trunc(e), 0), t - 1) : 0;
22
22
  }
23
- function he(n) {
23
+ function me(n) {
24
24
  let r = {
25
25
  trigger: !1,
26
26
  surface: !1
27
27
  };
28
28
  if (n == null) return r;
29
- for (let { node: i } of e(n)) t(i, l) ? r.trigger = !0 : t(i, c) && (r.surface = !0);
29
+ for (let { node: i } of e(n)) t(i, c) ? r.trigger = !0 : t(i, s) && (r.surface = !0);
30
30
  return r;
31
31
  }
32
- var ge = "TeachingPopover.Surface:placement", _e = "TeachingPopover.Surface: render one TeachingPopover.Surface in a TeachingPopover; a second Surface renders a second popover.", ve = "TeachingPopover:surface-props", ye = "TeachingPopover: the props of the surface element on TeachingPopover (`className`, `style`, `ref`, `onKeyDown` and the other element props) are ignored next to a TeachingPopover.Surface: pass them to the Surface.", d = ({ steps: e, activeStep: t, defaultActiveStep: i, currentStep: c, defaultCurrentStep: l, onStepChange: d, onDismiss: f, onFinish: be, primaryAction: xe, secondaryAction: Se, footerLayout: p = "horizontal", open: Ce, defaultOpen: we, onOpenChange: Te, closeLabel: m = "Close", labels: h, target: g, positioning: _, side: v = "bottom", align: y = "center", children: b, id: x, className: S, style: C, onKeyDown: w, ref: T, ...E }) => {
33
- ne("TeachingPopover", g, _?.target);
34
- let D = g === void 0 ? _?.target : g, Ee = n("TeachingPopover", t, c, "currentStep", "activeStep"), De = n("TeachingPopover", i, l, "defaultCurrentStep", "defaultActiveStep") ?? 0, [O, k] = o(Ee, De, d), A = he(b), [j, M] = o(Ce, we ?? !A.trigger, Te), N = s("teaching-popover-title"), P = e.length, F = j && P > 0, I = P > 0 ? me(O, P) : 0, L = P > 0 && I !== O, R = P > 0 ? e[I] : void 0, z = I === 0, B = I === P - 1, V = P > 0 ? (h?.step ?? de)(I, P) : "", Oe = R ? pe(R.primaryAction, xe) : void 0, H = R ? pe(R.secondaryAction, Se) : void 0, U = h?.back ?? se, W = h?.next ?? ce, G = h?.done ?? le, K = h?.nav ?? ue, q = h?.navButton ?? fe, [J, ke] = u.useState(null), Y = A.trigger || J !== null, Ae = D === void 0 ? Y ? J : void 0 : D, je = u.useRef(null), Me = te(je, ke), X = u.useRef(0), [Ne, Pe] = u.useState(!1), Fe = u.useCallback(() => (X.current += 1, Pe(!0), () => {
35
- --X.current, X.current === 0 && Pe(!1);
36
- }), []), Z = A.surface || Ne;
37
- u.useEffect(() => {
38
- X.current > 1 && r(ge, _e);
32
+ var he = "TeachingPopover.Surface:placement", ge = "TeachingPopover.Surface: render one TeachingPopover.Surface in a TeachingPopover; a second Surface renders a second popover.", _e = "TeachingPopover:surface-props", ve = "TeachingPopover: the props of the surface element on TeachingPopover (`className`, `style`, `ref`, `onKeyDown` and the other element props) are ignored next to a TeachingPopover.Surface: pass them to the Surface.", f = ({ steps: e, activeStep: t, defaultActiveStep: i, currentStep: s, defaultCurrentStep: c, onStepChange: f, onDismiss: p, onFinish: ye, primaryAction: be, secondaryAction: xe, footerLayout: m = "horizontal", open: Se, defaultOpen: Ce, onOpenChange: we, closeLabel: h = "Close", labels: g, target: _, positioning: v, side: Te = "bottom", align: Ee = "center", children: y, id: b, className: x, style: S, onKeyDown: C, ref: w, ...T }) => {
33
+ re("TeachingPopover", _, v?.target);
34
+ let E = _ === void 0 ? v?.target : _, De = n("TeachingPopover", t, s, "currentStep", "activeStep"), D = n("TeachingPopover", i, c, "defaultCurrentStep", "defaultActiveStep") ?? 0, [O, k, A] = o(De, D, f), j = me(y), [M, N] = o(Se, Ce ?? !j.trigger, we), P = te("teaching-popover-title"), [Oe, ke] = l.useState(M), [F, I] = l.useState(!1);
35
+ M !== Oe && (ke(M), M && !A && !Object.is(O, D) && I(!0)), F && (A || Object.is(O, D)) && I(!1), l.useLayoutEffect(() => {
36
+ F && k(D);
37
+ }, [
38
+ F,
39
+ D,
40
+ k
41
+ ]);
42
+ let L = F ? D : O, R = e.length, z = M && R > 0, B = R > 0 ? d(L, R) : 0, V = R > 0 && B !== L, H = R > 0 ? e[B] : void 0, U = B === 0, W = B === R - 1, Ae = R > 0 ? (g?.step ?? fe)(B, R) : "", G = H ? u(H.primaryAction, be) : void 0, K = H ? u(H.secondaryAction, xe) : void 0, q = g?.back ?? ce, J = g?.next ?? le, je = g?.done ?? ue, Me = g?.nav ?? de, Ne = g?.navButton ?? pe, [Pe, Fe] = l.useState(null), Y = j.trigger || Pe !== null, Ie = E === void 0 ? Y ? Pe : void 0 : E, Le = l.useRef(null), Re = ne(Le, Fe), X = l.useRef(0), [ze, Be] = l.useState(!1), Ve = l.useCallback(() => (X.current += 1, Be(!0), () => {
43
+ --X.current, X.current === 0 && Be(!1);
44
+ }), []), Z = j.surface || ze;
45
+ l.useEffect(() => {
46
+ X.current > 1 && r(he, ge);
39
47
  });
40
- let Ie = s("teaching-popover"), [Le, Re] = u.useState(void 0), ze = (Z ? Le : x || void 0) ?? Ie, Be = a(() => M(!0)), Ve = a(() => {
41
- M(!1), f?.();
48
+ let He = te("teaching-popover"), [Ue, We] = l.useState(void 0), Ge = (Z ? Ue : b || void 0) ?? He, Ke = a(() => N(!0)), qe = a(() => {
49
+ N(!1), p?.();
42
50
  }), Q = a(() => {
43
- M(!1), be?.(), f?.();
44
- }), He = a(() => {
45
- z || k(I - 1);
46
- }), Ue = a(() => {
47
- B ? Q() : k(I + 1);
48
- }), We = a((e) => {
49
- if (P === 0) return;
50
- let t = me(e, P);
51
- t !== I && k(t);
52
- }), Ge = Z && (x !== void 0 || S !== void 0 || C !== void 0 || w !== void 0 || T !== void 0 || Object.keys(E).length > 0);
53
- u.useEffect(() => {
54
- Ge && r(ve, ye);
55
- }, [Ge]), u.useEffect(() => {
56
- L && r("TeachingPopover:activeStep-range", `TeachingPopover: activeStep ${O} is out of range for ${P} steps; showing step ${I + 1}.`);
51
+ N(!1), ye?.(), p?.();
52
+ }), Je = a(() => {
53
+ U || k(B - 1);
54
+ }), Ye = a(() => {
55
+ W ? Q() : k(B + 1);
56
+ }), Xe = a((e) => {
57
+ if (R === 0) return;
58
+ let t = d(e, R);
59
+ t !== B && k(t);
60
+ }), Ze = Z && (b !== void 0 || x !== void 0 || S !== void 0 || C !== void 0 || w !== void 0 || Object.keys(T).length > 0);
61
+ l.useEffect(() => {
62
+ Ze && r(_e, ve);
63
+ }, [Ze]), l.useEffect(() => {
64
+ V && r("TeachingPopover:activeStep-range", `TeachingPopover: activeStep ${L} is out of range for ${R} steps; showing step ${B + 1}.`);
57
65
  }, [
66
+ V,
58
67
  L,
59
- O,
60
- P,
61
- I
68
+ R,
69
+ B
62
70
  ]);
63
- let $ = u.useMemo(() => ({
64
- open: j,
65
- shown: F,
66
- requestOpen: Be,
67
- dismiss: Ve,
71
+ let $ = l.useMemo(() => ({
72
+ open: M,
73
+ shown: z,
74
+ requestOpen: Ke,
75
+ dismiss: qe,
68
76
  finish: Q,
69
- count: P,
70
- index: I,
71
- step: R,
72
- isFirst: z,
73
- isLast: B,
74
- stepPosition: V,
75
- goBack: He,
76
- goNext: Ue,
77
- goToStep: We,
78
- primaryAction: Oe,
79
- secondaryAction: H,
80
- footerLayout: p,
81
- backLabel: U,
82
- nextLabel: W,
83
- doneLabel: G,
84
- closeLabel: m,
85
- navLabel: K,
86
- navButtonLabel: q,
87
- titleId: N,
88
- target: Ae,
89
- side: v,
90
- align: y,
91
- positioning: _,
77
+ count: R,
78
+ index: B,
79
+ step: H,
80
+ isFirst: U,
81
+ isLast: W,
82
+ stepPosition: Ae,
83
+ goBack: Je,
84
+ goNext: Ye,
85
+ goToStep: Xe,
86
+ primaryAction: G,
87
+ secondaryAction: K,
88
+ footerLayout: m,
89
+ backLabel: q,
90
+ nextLabel: J,
91
+ doneLabel: je,
92
+ closeLabel: h,
93
+ navLabel: Me,
94
+ navButtonLabel: Ne,
95
+ titleId: P,
96
+ target: Ie,
97
+ side: Te,
98
+ align: Ee,
99
+ positioning: v,
92
100
  hasTrigger: Y,
93
- triggerElementRef: Me,
94
- triggerRef: je,
95
- surfaceId: ze,
96
- setCustomSurfaceId: Re,
97
- registerSurface: Fe
101
+ triggerElementRef: Re,
102
+ triggerRef: Le,
103
+ surfaceId: Ge,
104
+ setCustomSurfaceId: We,
105
+ registerSurface: Ve
98
106
  }), [
99
- j,
100
- F,
101
- Be,
102
- Ve,
107
+ M,
108
+ z,
109
+ Ke,
110
+ qe,
103
111
  Q,
104
- P,
105
- I,
106
112
  R,
107
- z,
108
113
  B,
109
- V,
110
- He,
111
- Ue,
112
- We,
113
- Oe,
114
114
  H,
115
- p,
116
115
  U,
117
116
  W,
117
+ Ae,
118
+ Je,
119
+ Ye,
120
+ Xe,
118
121
  G,
119
- m,
120
122
  K,
123
+ m,
121
124
  q,
122
- N,
123
- Ae,
125
+ J,
126
+ je,
127
+ h,
128
+ Me,
129
+ Ne,
130
+ P,
131
+ Ie,
132
+ Te,
133
+ Ee,
124
134
  v,
125
- y,
126
- _,
127
135
  Y,
128
- Me,
129
- ze,
130
- Fe
136
+ Re,
137
+ Ge,
138
+ Ve
131
139
  ]);
132
- return /* @__PURE__ */ oe(re.Provider, {
140
+ return /* @__PURE__ */ se(ie.Provider, {
133
141
  value: $,
134
- children: [b, Z ? null : /* @__PURE__ */ ae(ie, {
142
+ children: [y, Z ? null : /* @__PURE__ */ oe(ae, {
135
143
  context: $,
136
144
  rootClassName: ee.root,
137
- id: x,
138
- className: S,
139
- style: C,
140
- onKeyDown: w,
141
- ...E,
142
- ref: T
145
+ id: b,
146
+ className: x,
147
+ style: S,
148
+ onKeyDown: C,
149
+ ...T,
150
+ ref: w
143
151
  })]
144
152
  });
145
153
  };
146
- d.displayName = "TeachingPopover";
154
+ f.displayName = "TeachingPopover";
147
155
  //#endregion
148
- export { d as TeachingPopoverRoot };
156
+ export { f as TeachingPopoverRoot };
149
157
 
150
158
  //# sourceMappingURL=TeachingPopover.root.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TeachingPopover.root.mjs","names":["useId","useId$1","React","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","DEFAULT_NAV_LABEL","defaultStepLabel","index","count","defaultNavButtonLabel","pickAction","slotRendersContent","own","fallback","clampStep","step","findParts","found","children","flattenChildren","isElementOfType","node","TeachingPopoverTrigger","TeachingPopoverSurface","SURFACE_PLACEMENT_WARNING_KEY","SURFACE_PLACEMENT_WARNING","SURFACE_PROPS_WARNING_KEY","SURFACE_PROPS_WARNING","TeachingPopoverRoot","activeStepProp","primaryActionProp","secondaryActionProp","openProp","targetProp","rest","positioning","explicitTarget","controlledStep","resolveDeprecatedProp","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","useControllable","onStepChange","parts","open","setOpen","defaultOpen","onOpenChange","titleId","steps","shown","outOfRange","isFirst","isLast","stepPosition","labels","primaryAction","secondaryAction","backLabel","nextLabel","doneLabel","navLabel","navButtonLabel","triggerElement","setTriggerElement","hasTrigger","target","triggerRef","triggerElementRef","useMergedRefs","surfaceCountRef","hasRegisteredSurface","setHasRegisteredSurface","registerSurface","hasSurfacePart","warnOnce","generatedSurfaceId","customSurfaceId","setCustomSurfaceId","surfaceId","id","requestOpen","useEventCallback","dismiss","onDismiss","finish","onFinish","goBack","goNext","goToStep","next","ignoresSurfaceProps","className","style","onKeyDown","ref","context","footerLayout","closeLabel","side","align","TeachingPopoverContext","TeachingSurface","teachingPopoverClassNames"],"sources":["../../../src/components/overlays/TeachingPopover.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { teachingPopoverClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { PopupAlign, PopupPositioning, PopupSide, VirtualElement } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTargetConflictWarning } from '../../hooks/useResolvedTarget';\nimport {\n TeachingPopoverContext,\n type TeachingPopoverAction,\n type TeachingPopoverContextValue,\n type TeachingPopoverLabels,\n type TeachingPopoverStep,\n} from './TeachingPopover.context';\nimport {\n TeachingPopoverSurface,\n TeachingPopoverTrigger,\n TeachingSurface,\n} from './TeachingPopover.parts';\n\n/*\n * The TeachingPopover root: its props, the state of both forms (the open state, the step and the\n * step's resolved content), the child scan for the Trigger and the Surface, and the surface it\n * renders when no Surface is among its children. Imports the context and parts modules (never\n * `TeachingPopover.tsx`, which holds the compound).\n */\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst DEFAULT_NAV_LABEL = 'Choose step';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\nconst defaultNavButtonLabel = (index: number, count: number) => `Step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /**\n * Called with the requested step index when Next, Back or a step button of\n * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing).\n */\n onStepChange?: (step: number) => void;\n /**\n * Called when the popover is dismissed with Close, Done, Escape or a `TeachingPopover.Trigger`\n * that closes it.\n *\n * Done also calls it in 0.x, after `onFinish`, so that code written before `onFinish` keeps\n * working; from 1.0 only Close, Escape and the Trigger will.\n */\n onDismiss?: () => void;\n /**\n * Called when the tour is finished: Done, the button that replaces Next on the last step, or a\n * `primaryAction` on the last step whose click was not prevented. The popover closes first.\n * Close, Escape and the Trigger call only `onDismiss`. Fires on every activation, like\n * `onStepChange`.\n */\n onFinish?: () => void;\n /**\n * Replaces the Next (or Done) button on every step that sets no `primaryAction` of its own.\n */\n primaryAction?: TeachingPopoverAction;\n /**\n * Replaces the Back button on every step that sets no `secondaryAction` of its own.\n */\n secondaryAction?: TeachingPopoverAction;\n /**\n * How the footer lays out the step dots and the buttons: side by side, or the dots above\n * buttons that fill the width. Rendered as `data-layout` on the popover and on its footer.\n * `TeachingPopover.CarouselFooter` has its own `layout` instead.\n * @default 'horizontal'\n */\n footerLayout?: 'horizontal' | 'vertical';\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /**\n * Initial visibility for uncontrolled usage: `true` (a tour that shows on page load), or\n * `false` when a `TeachingPopover.Trigger` is a direct child (a Fragment is fine), which then\n * opens it.\n * @default true (false with a direct TeachingPopover.Trigger)\n */\n defaultOpen?: boolean;\n /**\n * Called with `false` when Close, Done or Escape dismisses the popover, and with the new state\n * when a `TeachingPopover.Trigger` opens or closes it.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons, the wording of the step position (“step 2 of 3”) and\n * the names of `TeachingPopover.CarouselNav`'s step buttons, for localization. Unset members keep\n * their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref, the element, or a `VirtualElement`: a rectangle such as a\n * point; an inline object is fine). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour), or,\n * with a `TeachingPopover.Trigger`, points at the trigger.\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | VirtualElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset`, `fitViewport`, `matchReferenceWidth`,\n * `fallbackPlacements` and `target` (used when the `target` prop is not set). `side` and `align`\n * stay separate props.\n * @default `{ offset: 12 }`\n */\n positioning?: PopupPositioning;\n /**\n * `TeachingPopover.Trigger` and `TeachingPopover.Surface` (Fluent's composition), rendered where\n * they are written. Without a `TeachingPopover.Surface` among them, the popover renders its\n * surface itself, after the children, with the element props given here (`className`, `style`,\n * `ref`, …); with one (best written directly inside, a Fragment is fine: see\n * `TeachingPopover.Surface`), the Surface takes them instead.\n */\n children?: React.ReactNode;\n /**\n * Ref to the popover surface (`role=\"dialog\"`). Ignored next to a `TeachingPopover.Surface`\n * (pass it to the Surface).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The action a step shows: its own when it renders anything, else the popover's. */\nfunction pickAction(\n own: TeachingPopoverAction | undefined,\n fallback: TeachingPopoverAction | undefined,\n): TeachingPopoverAction | undefined {\n if (slotRendersContent(own)) return own;\n return slotRendersContent(fallback) ? fallback : undefined;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * Which parts are direct children (Fragments flattened, lazy types of a Server Component\n * unwrapped): a Trigger closes `defaultOpen`, a Surface replaces the root's own surface. Runs\n * during render, so the server HTML agrees (a Surface deeper down registers once mounted).\n */\nfunction findParts(children: React.ReactNode): { trigger: boolean; surface: boolean } {\n const found = { trigger: false, surface: false };\n if (children === null || children === undefined) return found;\n for (const { node } of flattenChildren(children)) {\n if (isElementOfType(node, TeachingPopoverTrigger)) found.trigger = true;\n else if (isElementOfType(node, TeachingPopoverSurface)) found.surface = true;\n }\n return found;\n}\n\nconst SURFACE_PLACEMENT_WARNING_KEY = 'TeachingPopover.Surface:placement';\nconst SURFACE_PLACEMENT_WARNING =\n 'TeachingPopover.Surface: render one TeachingPopover.Surface in a TeachingPopover; a second Surface renders a second popover.';\n\nconst SURFACE_PROPS_WARNING_KEY = 'TeachingPopover:surface-props';\nconst SURFACE_PROPS_WARNING =\n 'TeachingPopover: the props of the surface element on TeachingPopover (`className`, `style`, `ref`, `onKeyDown` and the other element props) are ignored next to a TeachingPopover.Surface: pass them to the Surface.';\n\n// The root of `TeachingPopover` (documented on the export in TeachingPopover.tsx).\nexport const TeachingPopoverRoot = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n onFinish,\n primaryAction: primaryActionProp,\n secondaryAction: secondaryActionProp,\n footerLayout = 'horizontal',\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target: targetProp,\n positioning,\n side = 'bottom',\n align = 'center',\n children,\n id,\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n useTargetConflictWarning('TeachingPopover', targetProp, positioning?.target);\n const explicitTarget = (\n targetProp !== undefined ? targetProp : positioning?.target\n ) as TeachingPopoverProps['target'];\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const parts = findParts(children);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? !parts.trigger, onOpenChange);\n const titleId = useId('teaching-popover-title');\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n const primaryAction = step ? pickAction(step.primaryAction, primaryActionProp) : undefined;\n const secondaryAction = step ? pickAction(step.secondaryAction, secondaryActionProp) : undefined;\n const backLabel = labels?.back ?? DEFAULT_BACK_LABEL;\n const nextLabel = labels?.next ?? DEFAULT_NEXT_LABEL;\n const doneLabel = labels?.done ?? DEFAULT_DONE_LABEL;\n const navLabel = labels?.nav ?? DEFAULT_NAV_LABEL;\n const navButtonLabel = labels?.navButton ?? defaultNavButtonLabel;\n\n // A Trigger is the target when neither `target` nor `positioning.target` is set: a direct one\n // from the first render (the surface stays hidden until its element attaches), a nested one\n // once its element has attached.\n const [triggerElement, setTriggerElement] = React.useState<HTMLElement | null>(null);\n const hasTrigger = parts.trigger || triggerElement !== null;\n const target =\n explicitTarget !== undefined ? explicitTarget : hasTrigger ? triggerElement : undefined;\n // The Trigger's element also as a ref, where the surface returns focus.\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const triggerElementRef = useMergedRefs<HTMLElement>(triggerRef, setTriggerElement);\n\n // Surfaces (TeachingPopover.Surface) register while mounted, wherever they are among the\n // children: once one has, the root renders no surface of its own. A direct one is also found by\n // the scan above, so it never renders next to the root's own; one inside a component of yours\n // does in its first commit, until its registration re-renders the root. After every commit\n // (every surface's layout effect has run) more than one warns.\n const surfaceCountRef = React.useRef(0);\n const [hasRegisteredSurface, setHasRegisteredSurface] = React.useState(false);\n const registerSurface = React.useCallback(() => {\n surfaceCountRef.current += 1;\n setHasRegisteredSurface(true);\n return () => {\n surfaceCountRef.current -= 1;\n if (surfaceCountRef.current === 0) setHasRegisteredSurface(false);\n };\n }, []);\n const hasSurfacePart = parts.surface || hasRegisteredSurface;\n React.useEffect(() => {\n if (surfaceCountRef.current > 1) {\n warnOnce(SURFACE_PLACEMENT_WARNING_KEY, SURFACE_PLACEMENT_WARNING);\n }\n });\n\n // The Trigger's `aria-controls`: the surface's id (the root's own `id` on its own surface, or\n // the id a Surface reports), else a generated one.\n const generatedSurfaceId = useId('teaching-popover');\n const [customSurfaceId, setCustomSurfaceId] = React.useState<string | undefined>(undefined);\n const surfaceId = (hasSurfacePart ? customSurfaceId : id || undefined) ?? generatedSurfaceId;\n\n const requestOpen = useEventCallback(() => setOpen(true));\n const dismiss = useEventCallback(() => {\n setOpen(false);\n onDismiss?.();\n });\n // Done: close, then `onFinish`. `onDismiss` still follows in 0.x (see its JSDoc).\n const finish = useEventCallback(() => {\n setOpen(false);\n onFinish?.();\n onDismiss?.();\n });\n const goBack = useEventCallback(() => {\n if (!isFirst) setStep(index - 1);\n });\n const goNext = useEventCallback(() => {\n if (isLast) finish();\n else setStep(index + 1);\n });\n // A step button of TeachingPopover.CarouselNav: the shown (clamped) step requests nothing.\n const goToStep = useEventCallback((target: number) => {\n if (count === 0) return;\n const next = clampStep(target, count);\n if (next !== index) setStep(next);\n });\n\n // Next to a Surface the root renders no surface element, so its element props go nowhere.\n const ignoresSurfaceProps =\n hasSurfacePart &&\n (id !== undefined ||\n className !== undefined ||\n style !== undefined ||\n onKeyDown !== undefined ||\n ref !== undefined ||\n Object.keys(rest).length > 0);\n React.useEffect(() => {\n if (ignoresSurfaceProps) warnOnce(SURFACE_PROPS_WARNING_KEY, SURFACE_PROPS_WARNING);\n }, [ignoresSurfaceProps]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n const context = React.useMemo<TeachingPopoverContextValue>(\n () => ({\n open,\n shown,\n requestOpen,\n dismiss,\n finish,\n count,\n index,\n step,\n isFirst,\n isLast,\n stepPosition,\n goBack,\n goNext,\n goToStep,\n primaryAction,\n secondaryAction,\n footerLayout,\n backLabel,\n nextLabel,\n doneLabel,\n closeLabel,\n navLabel,\n navButtonLabel,\n titleId,\n target,\n side,\n align,\n positioning,\n hasTrigger,\n triggerElementRef,\n triggerRef,\n surfaceId,\n setCustomSurfaceId,\n registerSurface,\n }),\n [\n open,\n shown,\n requestOpen,\n dismiss,\n finish,\n count,\n index,\n step,\n isFirst,\n isLast,\n stepPosition,\n goBack,\n goNext,\n goToStep,\n primaryAction,\n secondaryAction,\n footerLayout,\n backLabel,\n nextLabel,\n doneLabel,\n closeLabel,\n navLabel,\n navButtonLabel,\n titleId,\n target,\n side,\n align,\n positioning,\n hasTrigger,\n triggerElementRef,\n surfaceId,\n registerSurface,\n ],\n );\n\n return (\n <TeachingPopoverContext.Provider value={context}>\n {children}\n {hasSurfacePart ? null : (\n <TeachingSurface\n context={context}\n rootClassName={teachingPopoverClassNames.root}\n id={id}\n className={className}\n style={style}\n onKeyDown={onKeyDown}\n {...rest}\n ref={ref}\n />\n )}\n </TeachingPopoverContext.Provider>\n );\n};\nTeachingPopoverRoot.displayName = 'TeachingPopover';\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,IAAMG,KAAqB,QACrBC,KAAqB,QACrBC,KAAqB,QACrBC,KAAoB,eACpBC,MAAoB,GAAe,MAAkB,QAAQC,IAAQ,EAAE,MAAMC,KAC7EC,MAAyB,GAAe,MAAkB,QAAQF,IAAQ,EAAE,MAAMC;AAwIxF,SAASE,GACP,GACA,GACmC;CAEnC,OADIC,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;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE+C;EACAM;EACA+B;EACAE;EACAE;EACAjF;EACAD;EACAQ;EACAyC;EACAC;EACAC;EACAiC;EACAC;EACAC;EACAjC;EACAC;EACAwC;EACAvC;EACAC;EACAC;EACAsC;EACArC;EACAC;EACAd;EACAkB;EACAiC;EACAC;EACArE;EACAkC;EACAG;EACAW;EACAN;CACF,CACF;CAEA,OACE,mBAAC4B,GAAuB,UAAxB;EAAiC,OAAOL;EAAxC,UAAA,CACGlF,GACA4D,IAAiB,OAChB,mBAAC4B,IAAD;GACW;GACT,eAAeC,GAA0B;GACrC;GACO;GACJ;GACI;GACX,GAAIzE;GACC;EACN,CAAA,CAE4B;;AAErC;AACA,EAAoB,cAAc"}
1
+ {"version":3,"file":"TeachingPopover.root.mjs","names":["useId","useId$1","React","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","DEFAULT_NAV_LABEL","defaultStepLabel","index","count","defaultNavButtonLabel","pickAction","slotRendersContent","own","fallback","clampStep","step","findParts","found","children","flattenChildren","isElementOfType","node","TeachingPopoverTrigger","TeachingPopoverSurface","SURFACE_PLACEMENT_WARNING_KEY","SURFACE_PLACEMENT_WARNING","SURFACE_PROPS_WARNING_KEY","SURFACE_PROPS_WARNING","TeachingPopoverRoot","activeStepProp","primaryActionProp","secondaryActionProp","openProp","targetProp","rest","positioning","explicitTarget","controlledStep","resolveDeprecatedProp","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","storedStep","setStep","stepControlled","useControllable","onStepChange","parts","open","setOpen","defaultOpen","onOpenChange","titleId","openSeen","setOpenSeen","stepResetPending","setStepResetPending","rawStep","steps","shown","outOfRange","isFirst","isLast","stepPosition","labels","primaryAction","secondaryAction","backLabel","nextLabel","doneLabel","navLabel","navButtonLabel","triggerElement","setTriggerElement","hasTrigger","target","triggerRef","triggerElementRef","useMergedRefs","surfaceCountRef","hasRegisteredSurface","setHasRegisteredSurface","registerSurface","hasSurfacePart","warnOnce","generatedSurfaceId","customSurfaceId","setCustomSurfaceId","surfaceId","id","requestOpen","useEventCallback","dismiss","onDismiss","finish","onFinish","goBack","goNext","goToStep","next","ignoresSurfaceProps","className","style","onKeyDown","ref","context","footerLayout","closeLabel","side","align","TeachingPopoverContext","TeachingSurface","teachingPopoverClassNames"],"sources":["../../../src/components/overlays/TeachingPopover.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { teachingPopoverClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { PopupAlign, PopupPositioning, PopupSide, VirtualElement } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTargetConflictWarning } from '../../hooks/useResolvedTarget';\nimport {\n TeachingPopoverContext,\n type TeachingPopoverAction,\n type TeachingPopoverContextValue,\n type TeachingPopoverLabels,\n type TeachingPopoverStep,\n} from './TeachingPopover.context';\nimport {\n TeachingPopoverSurface,\n TeachingPopoverTrigger,\n TeachingSurface,\n} from './TeachingPopover.parts';\n\n/*\n * The TeachingPopover root: its props, the state of both forms (the open state, the step and the\n * step's resolved content), the child scan for the Trigger and the Surface, and the surface it\n * renders when no Surface is among its children. Imports the context and parts modules (never\n * `TeachingPopover.tsx`, which holds the compound).\n */\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst DEFAULT_NAV_LABEL = 'Choose step';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\nconst defaultNavButtonLabel = (index: number, count: number) => `Step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning). Opening the popover leaves it as it is.\n */\n activeStep?: number;\n /**\n * Initial step index for uncontrolled usage, and the step the popover starts on again each time\n * it opens (after Done, Close, Escape or the Trigger closed it, or a controlled `open` turned it\n * off), so a tour opened again starts over; `onStepChange` is called with it when the step was\n * elsewhere.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /**\n * Called with the requested step index when Next, Back or a step button of\n * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing),\n * and, while the step is uncontrolled, with the initial step when an opening moves the step back\n * to it (see `defaultActiveStep`).\n */\n onStepChange?: (step: number) => void;\n /**\n * Called when the popover is dismissed with Close, Done, Escape or a `TeachingPopover.Trigger`\n * that closes it.\n *\n * Done also calls it in 0.x, after `onFinish`, so that code written before `onFinish` keeps\n * working; from 1.0 only Close, Escape and the Trigger will.\n */\n onDismiss?: () => void;\n /**\n * Called when the tour is finished: Done, the button that replaces Next on the last step, or a\n * `primaryAction` on the last step whose click was not prevented. The popover closes first.\n * Close, Escape and the Trigger call only `onDismiss`. Fires on every activation, like\n * `onStepChange`.\n */\n onFinish?: () => void;\n /**\n * Replaces the Next (or Done) button on every step that sets no `primaryAction` of its own.\n */\n primaryAction?: TeachingPopoverAction;\n /**\n * Replaces the Back button on every step that sets no `secondaryAction` of its own.\n */\n secondaryAction?: TeachingPopoverAction;\n /**\n * How the footer lays out the step dots and the buttons: side by side, or the dots above\n * buttons that fill the width. Rendered as `data-layout` on the popover and on its footer.\n * `TeachingPopover.CarouselFooter` has its own `layout` instead.\n * @default 'horizontal'\n */\n footerLayout?: 'horizontal' | 'vertical';\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /**\n * Initial visibility for uncontrolled usage: `true` (a tour that shows on page load), or\n * `false` when a `TeachingPopover.Trigger` is a direct child (a Fragment is fine), which then\n * opens it.\n * @default true (false with a direct TeachingPopover.Trigger)\n */\n defaultOpen?: boolean;\n /**\n * Called with `false` when Close, Done or Escape dismisses the popover, and with the new state\n * when a `TeachingPopover.Trigger` opens or closes it.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons, the wording of the step position (“step 2 of 3”) and\n * the names of `TeachingPopover.CarouselNav`'s step buttons, for localization. Unset members keep\n * their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref, the element, or a `VirtualElement`: a rectangle such as a\n * point; an inline object is fine). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour), or,\n * with a `TeachingPopover.Trigger`, points at the trigger.\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | VirtualElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset`, `fitViewport`, `matchReferenceWidth`,\n * `fallbackPlacements` and `target` (used when the `target` prop is not set). `side` and `align`\n * stay separate props.\n * @default `{ offset: 12 }`\n */\n positioning?: PopupPositioning;\n /**\n * `TeachingPopover.Trigger` and `TeachingPopover.Surface` (Fluent's composition), rendered where\n * they are written. Without a `TeachingPopover.Surface` among them, the popover renders its\n * surface itself, after the children, with the element props given here (`className`, `style`,\n * `ref`, …); with one (best written directly inside, a Fragment is fine: see\n * `TeachingPopover.Surface`), the Surface takes them instead.\n */\n children?: React.ReactNode;\n /**\n * Ref to the popover surface (`role=\"dialog\"`). Ignored next to a `TeachingPopover.Surface`\n * (pass it to the Surface).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The action a step shows: its own when it renders anything, else the popover's. */\nfunction pickAction(\n own: TeachingPopoverAction | undefined,\n fallback: TeachingPopoverAction | undefined,\n): TeachingPopoverAction | undefined {\n if (slotRendersContent(own)) return own;\n return slotRendersContent(fallback) ? fallback : undefined;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * Which parts are direct children (Fragments flattened, lazy types of a Server Component\n * unwrapped): a Trigger closes `defaultOpen`, a Surface replaces the root's own surface. Runs\n * during render, so the server HTML agrees (a Surface deeper down registers once mounted).\n */\nfunction findParts(children: React.ReactNode): { trigger: boolean; surface: boolean } {\n const found = { trigger: false, surface: false };\n if (children === null || children === undefined) return found;\n for (const { node } of flattenChildren(children)) {\n if (isElementOfType(node, TeachingPopoverTrigger)) found.trigger = true;\n else if (isElementOfType(node, TeachingPopoverSurface)) found.surface = true;\n }\n return found;\n}\n\nconst SURFACE_PLACEMENT_WARNING_KEY = 'TeachingPopover.Surface:placement';\nconst SURFACE_PLACEMENT_WARNING =\n 'TeachingPopover.Surface: render one TeachingPopover.Surface in a TeachingPopover; a second Surface renders a second popover.';\n\nconst SURFACE_PROPS_WARNING_KEY = 'TeachingPopover:surface-props';\nconst SURFACE_PROPS_WARNING =\n 'TeachingPopover: the props of the surface element on TeachingPopover (`className`, `style`, `ref`, `onKeyDown` and the other element props) are ignored next to a TeachingPopover.Surface: pass them to the Surface.';\n\n// The root of `TeachingPopover` (documented on the export in TeachingPopover.tsx).\nexport const TeachingPopoverRoot = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n onFinish,\n primaryAction: primaryActionProp,\n secondaryAction: secondaryActionProp,\n footerLayout = 'horizontal',\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target: targetProp,\n positioning,\n side = 'bottom',\n align = 'center',\n children,\n id,\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n useTargetConflictWarning('TeachingPopover', targetProp, positioning?.target);\n const explicitTarget = (\n targetProp !== undefined ? targetProp : positioning?.target\n ) as TeachingPopoverProps['target'];\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [storedStep, setStep, stepControlled] = useControllable(\n controlledStep,\n initialStep,\n onStepChange,\n );\n const parts = findParts(children);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? !parts.trigger, onOpenChange);\n const titleId = useId('teaching-popover-title');\n\n // An uncontrolled step starts again at the initial step each time the popover opens (not on\n // mount), whatever closed it and whatever opens it. The opening is noticed during render (C-HOOKS:\n // a previous-value state), so the opened popover shows the initial step from its first render;\n // the layout effect stores it through the setter (which calls `onStepChange` once, from the\n // commit), and the render that reads it back ends the reset.\n const [openSeen, setOpenSeen] = React.useState(open);\n const [stepResetPending, setStepResetPending] = React.useState(false);\n if (open !== openSeen) {\n setOpenSeen(open);\n if (open && !stepControlled && !Object.is(storedStep, initialStep)) {\n setStepResetPending(true);\n }\n }\n if (stepResetPending && (stepControlled || Object.is(storedStep, initialStep))) {\n setStepResetPending(false);\n }\n React.useLayoutEffect(() => {\n if (stepResetPending) setStep(initialStep);\n }, [stepResetPending, initialStep, setStep]);\n const rawStep = stepResetPending ? initialStep : storedStep;\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n const primaryAction = step ? pickAction(step.primaryAction, primaryActionProp) : undefined;\n const secondaryAction = step ? pickAction(step.secondaryAction, secondaryActionProp) : undefined;\n const backLabel = labels?.back ?? DEFAULT_BACK_LABEL;\n const nextLabel = labels?.next ?? DEFAULT_NEXT_LABEL;\n const doneLabel = labels?.done ?? DEFAULT_DONE_LABEL;\n const navLabel = labels?.nav ?? DEFAULT_NAV_LABEL;\n const navButtonLabel = labels?.navButton ?? defaultNavButtonLabel;\n\n // A Trigger is the target when neither `target` nor `positioning.target` is set: a direct one\n // from the first render (the surface stays hidden until its element attaches), a nested one\n // once its element has attached.\n const [triggerElement, setTriggerElement] = React.useState<HTMLElement | null>(null);\n const hasTrigger = parts.trigger || triggerElement !== null;\n const target =\n explicitTarget !== undefined ? explicitTarget : hasTrigger ? triggerElement : undefined;\n // The Trigger's element also as a ref, where the surface returns focus.\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const triggerElementRef = useMergedRefs<HTMLElement>(triggerRef, setTriggerElement);\n\n // Surfaces (TeachingPopover.Surface) register while mounted, wherever they are among the\n // children: once one has, the root renders no surface of its own. A direct one is also found by\n // the scan above, so it never renders next to the root's own; one inside a component of yours\n // does in its first commit, until its registration re-renders the root. After every commit\n // (every surface's layout effect has run) more than one warns.\n const surfaceCountRef = React.useRef(0);\n const [hasRegisteredSurface, setHasRegisteredSurface] = React.useState(false);\n const registerSurface = React.useCallback(() => {\n surfaceCountRef.current += 1;\n setHasRegisteredSurface(true);\n return () => {\n surfaceCountRef.current -= 1;\n if (surfaceCountRef.current === 0) setHasRegisteredSurface(false);\n };\n }, []);\n const hasSurfacePart = parts.surface || hasRegisteredSurface;\n React.useEffect(() => {\n if (surfaceCountRef.current > 1) {\n warnOnce(SURFACE_PLACEMENT_WARNING_KEY, SURFACE_PLACEMENT_WARNING);\n }\n });\n\n // The Trigger's `aria-controls`: the surface's id (the root's own `id` on its own surface, or\n // the id a Surface reports), else a generated one.\n const generatedSurfaceId = useId('teaching-popover');\n const [customSurfaceId, setCustomSurfaceId] = React.useState<string | undefined>(undefined);\n const surfaceId = (hasSurfacePart ? customSurfaceId : id || undefined) ?? generatedSurfaceId;\n\n const requestOpen = useEventCallback(() => setOpen(true));\n const dismiss = useEventCallback(() => {\n setOpen(false);\n onDismiss?.();\n });\n // Done: close, then `onFinish`. `onDismiss` still follows in 0.x (see its JSDoc).\n const finish = useEventCallback(() => {\n setOpen(false);\n onFinish?.();\n onDismiss?.();\n });\n const goBack = useEventCallback(() => {\n if (!isFirst) setStep(index - 1);\n });\n const goNext = useEventCallback(() => {\n if (isLast) finish();\n else setStep(index + 1);\n });\n // A step button of TeachingPopover.CarouselNav: the shown (clamped) step requests nothing.\n const goToStep = useEventCallback((target: number) => {\n if (count === 0) return;\n const next = clampStep(target, count);\n if (next !== index) setStep(next);\n });\n\n // Next to a Surface the root renders no surface element, so its element props go nowhere.\n const ignoresSurfaceProps =\n hasSurfacePart &&\n (id !== undefined ||\n className !== undefined ||\n style !== undefined ||\n onKeyDown !== undefined ||\n ref !== undefined ||\n Object.keys(rest).length > 0);\n React.useEffect(() => {\n if (ignoresSurfaceProps) warnOnce(SURFACE_PROPS_WARNING_KEY, SURFACE_PROPS_WARNING);\n }, [ignoresSurfaceProps]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n const context = React.useMemo<TeachingPopoverContextValue>(\n () => ({\n open,\n shown,\n requestOpen,\n dismiss,\n finish,\n count,\n index,\n step,\n isFirst,\n isLast,\n stepPosition,\n goBack,\n goNext,\n goToStep,\n primaryAction,\n secondaryAction,\n footerLayout,\n backLabel,\n nextLabel,\n doneLabel,\n closeLabel,\n navLabel,\n navButtonLabel,\n titleId,\n target,\n side,\n align,\n positioning,\n hasTrigger,\n triggerElementRef,\n triggerRef,\n surfaceId,\n setCustomSurfaceId,\n registerSurface,\n }),\n [\n open,\n shown,\n requestOpen,\n dismiss,\n finish,\n count,\n index,\n step,\n isFirst,\n isLast,\n stepPosition,\n goBack,\n goNext,\n goToStep,\n primaryAction,\n secondaryAction,\n footerLayout,\n backLabel,\n nextLabel,\n doneLabel,\n closeLabel,\n navLabel,\n navButtonLabel,\n titleId,\n target,\n side,\n align,\n positioning,\n hasTrigger,\n triggerElementRef,\n surfaceId,\n registerSurface,\n ],\n );\n\n return (\n <TeachingPopoverContext.Provider value={context}>\n {children}\n {hasSurfacePart ? null : (\n <TeachingSurface\n context={context}\n rootClassName={teachingPopoverClassNames.root}\n id={id}\n className={className}\n style={style}\n onKeyDown={onKeyDown}\n {...rest}\n ref={ref}\n />\n )}\n </TeachingPopoverContext.Provider>\n );\n};\nTeachingPopoverRoot.displayName = 'TeachingPopover';\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,IAAMG,KAAqB,QACrBC,KAAqB,QACrBC,KAAqB,QACrBC,KAAoB,eACpBC,MAAoB,GAAe,MAAkB,QAAQC,IAAQ,EAAE,MAAMC,KAC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AAc,KAAA,KACdC,MAAU,KAAA,KACVC,MAAc,KAAA,KACdC,MAAQ,KAAA,KACR,OAAO,KAAKvE,CAAI,CAAC,CAAC,SAAS;CAK/B,AAJAjC,EAAM,gBAAgB;EACpB,AAAIoG,MAAqBhB,EAAS3D,IAA2BC,EAAqB;CACpF,GAAG,CAAC0E,EAAmB,CAAC,GAExBpG,EAAM,gBAAgB;EACpB,AAAK4D,KACLwB,EACE,oCACA,+BAA+B3B,EAAQ,uBAAuBlD,EAAM,uBAAuBD,IAAQ,EAAE,EACvG;CACF,GAAG;EAACsD;EAAYH;EAASlD;EAAOD;CAAK,CAAC;CAEtC,IAAMmG,IAAUzG,EAAM,eACb;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACEgD;EACAW;EACA+B;EACAE;EACAE;EACAvF;EACAD;EACAQ;EACA+C;EACAC;EACAC;EACAiC;EACAC;EACAC;EACAjC;EACAC;EACAwC;EACAvC;EACAC;EACAC;EACAsC;EACArC;EACAC;EACAnB;EACAuB;EACAiC;EACAC;EACA3E;EACAwC;EACAG;EACAW;EACAN;CACF,CACF;CAEA,OACE,mBAAC4B,GAAuB,UAAxB;EAAiC,OAAOL;EAAxC,UAAA,CACGxF,GACAkE,IAAiB,OAChB,mBAAC4B,IAAD;GACW;GACT,eAAeC,GAA0B;GACrC;GACO;GACJ;GACI;GACX,GAAI/E;GACC;EACN,CAAA,CAE4B;;AAErC;AACA,EAAoB,cAAc"}
package/dist/index.d.cts CHANGED
@@ -14610,8 +14610,11 @@ export declare type TagSize = Extract<Size, 'extra-small' | 'small' | 'medium'>;
14610
14610
  * `TeachingPopover.Trigger`)/`onOpenChange`; Close, Done, Escape (anywhere in the document) and
14611
14611
  * the Trigger dismiss it and call `onDismiss`.
14612
14612
  * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to
14613
- * the available steps. The heading carries a visually hidden “step n of m”, the new step is
14614
- * announced politely, and Back stays focusable (`aria-disabled`) on the first step.
14613
+ * the available steps. An uncontrolled step starts again at `defaultActiveStep` each time the
14614
+ * popover opens, so a tour finished with Done or closed midway starts over (`onStepChange`
14615
+ * reports the move back); a controlled `activeStep` is left as it is. The heading carries a
14616
+ * visually hidden “step n of m”, the new step is announced politely, and Back stays focusable
14617
+ * (`aria-disabled`) on the first step.
14615
14618
  * - `primaryAction` and `secondaryAction` (on the popover, or on a step, which wins) replace Next/Done
14616
14619
  * and Back: a label, a Button-like element or a slot object. The consumer's `onClick` runs first,
14617
14620
  * then the step's normal action unless it called `preventDefault()`. Done calls `onFinish`
@@ -15094,10 +15097,14 @@ export declare interface TeachingPopoverProps extends React_2.HTMLAttributes<HTM
15094
15097
  steps: readonly TeachingPopoverStep[];
15095
15098
  /**
15096
15099
  * Controlled index of the displayed step. Out-of-range values are clamped to the first or last
15097
- * step (with a development warning).
15100
+ * step (with a development warning). Opening the popover leaves it as it is.
15098
15101
  */
15099
15102
  activeStep?: number;
15100
- /** Initial step index for uncontrolled usage.
15103
+ /**
15104
+ * Initial step index for uncontrolled usage, and the step the popover starts on again each time
15105
+ * it opens (after Done, Close, Escape or the Trigger closed it, or a controlled `open` turned it
15106
+ * off), so a tour opened again starts over; `onStepChange` is called with it when the step was
15107
+ * elsewhere.
15101
15108
  * @default 0
15102
15109
  */
15103
15110
  defaultActiveStep?: number;
@@ -15107,7 +15114,9 @@ export declare interface TeachingPopoverProps extends React_2.HTMLAttributes<HTM
15107
15114
  defaultCurrentStep?: number;
15108
15115
  /**
15109
15116
  * Called with the requested step index when Next, Back or a step button of
15110
- * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing).
15117
+ * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing),
15118
+ * and, while the step is uncontrolled, with the initial step when an opening moves the step back
15119
+ * to it (see `defaultActiveStep`).
15111
15120
  */
15112
15121
  onStepChange?: (step: number) => void;
15113
15122
  /**
package/dist/index.d.ts CHANGED
@@ -14610,8 +14610,11 @@ export declare type TagSize = Extract<Size, 'extra-small' | 'small' | 'medium'>;
14610
14610
  * `TeachingPopover.Trigger`)/`onOpenChange`; Close, Done, Escape (anywhere in the document) and
14611
14611
  * the Trigger dismiss it and call `onDismiss`.
14612
14612
  * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to
14613
- * the available steps. The heading carries a visually hidden “step n of m”, the new step is
14614
- * announced politely, and Back stays focusable (`aria-disabled`) on the first step.
14613
+ * the available steps. An uncontrolled step starts again at `defaultActiveStep` each time the
14614
+ * popover opens, so a tour finished with Done or closed midway starts over (`onStepChange`
14615
+ * reports the move back); a controlled `activeStep` is left as it is. The heading carries a
14616
+ * visually hidden “step n of m”, the new step is announced politely, and Back stays focusable
14617
+ * (`aria-disabled`) on the first step.
14615
14618
  * - `primaryAction` and `secondaryAction` (on the popover, or on a step, which wins) replace Next/Done
14616
14619
  * and Back: a label, a Button-like element or a slot object. The consumer's `onClick` runs first,
14617
14620
  * then the step's normal action unless it called `preventDefault()`. Done calls `onFinish`
@@ -15094,10 +15097,14 @@ export declare interface TeachingPopoverProps extends React_2.HTMLAttributes<HTM
15094
15097
  steps: readonly TeachingPopoverStep[];
15095
15098
  /**
15096
15099
  * Controlled index of the displayed step. Out-of-range values are clamped to the first or last
15097
- * step (with a development warning).
15100
+ * step (with a development warning). Opening the popover leaves it as it is.
15098
15101
  */
15099
15102
  activeStep?: number;
15100
- /** Initial step index for uncontrolled usage.
15103
+ /**
15104
+ * Initial step index for uncontrolled usage, and the step the popover starts on again each time
15105
+ * it opens (after Done, Close, Escape or the Trigger closed it, or a controlled `open` turned it
15106
+ * off), so a tour opened again starts over; `onStepChange` is called with it when the step was
15107
+ * elsewhere.
15101
15108
  * @default 0
15102
15109
  */
15103
15110
  defaultActiveStep?: number;
@@ -15107,7 +15114,9 @@ export declare interface TeachingPopoverProps extends React_2.HTMLAttributes<HTM
15107
15114
  defaultCurrentStep?: number;
15108
15115
  /**
15109
15116
  * Called with the requested step index when Next, Back or a step button of
15110
- * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing).
15117
+ * `TeachingPopover.CarouselNav` is activated (the button of the current step requests nothing),
15118
+ * and, while the step is uncontrolled, with the initial step when an opening moves the step back
15119
+ * to it (see `defaultActiveStep`).
15111
15120
  */
15112
15121
  onStepChange?: (step: number) => void;
15113
15122
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mortenbrudvik/waveui",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "description": "A comprehensive React component library with modern design tokens — accessible, composable components built with TypeScript and Tailwind CSS",
6
6
  "license": "MIT",