@wardic/solid 3.0.0-next.3 → 3.0.0-next.4

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 (78) hide show
  1. package/dist/browser/create-animate.js +48 -7
  2. package/dist/browser/create-animate.js.map +1 -1
  3. package/dist/browser/diagnostic-codes.js +10 -0
  4. package/dist/browser/diagnostic-codes.js.map +1 -1
  5. package/dist/browser/hooks/ward.js +33 -8
  6. package/dist/browser/hooks/ward.js.map +1 -1
  7. package/dist/browser/index.js +33 -13
  8. package/dist/browser/index.js.map +1 -1
  9. package/dist/browser/live-scroll.js +14 -6
  10. package/dist/browser/live-scroll.js.map +1 -1
  11. package/dist/browser/reorder-components.js +4 -0
  12. package/dist/browser/reorder-components.js.map +1 -1
  13. package/dist/browser/v1/index.js +1 -1
  14. package/dist/browser/v1/live-scroll.js +3 -2
  15. package/dist/browser/v1/live-scroll.js.map +1 -1
  16. package/dist/browser/ward.js +1 -1
  17. package/dist/browser/ward.js.map +1 -1
  18. package/dist/server/create-animate.js +48 -7
  19. package/dist/server/create-animate.js.map +1 -1
  20. package/dist/server/diagnostic-codes.js +10 -0
  21. package/dist/server/diagnostic-codes.js.map +1 -1
  22. package/dist/server/hooks/ward.js +33 -8
  23. package/dist/server/hooks/ward.js.map +1 -1
  24. package/dist/server/index.js +33 -13
  25. package/dist/server/index.js.map +1 -1
  26. package/dist/server/live-scroll.js +14 -6
  27. package/dist/server/live-scroll.js.map +1 -1
  28. package/dist/server/reorder-components.js +4 -0
  29. package/dist/server/reorder-components.js.map +1 -1
  30. package/dist/server/v1/index.js +1 -1
  31. package/dist/server/v1/live-scroll.js +3 -2
  32. package/dist/server/v1/live-scroll.js.map +1 -1
  33. package/dist/server/ward.js +1 -1
  34. package/dist/server/ward.js.map +1 -1
  35. package/dist/solid/create-animate.d.ts +36 -6
  36. package/dist/solid/create-animate.d.ts.map +1 -1
  37. package/dist/solid/create-animate.jsx +46 -7
  38. package/dist/solid/create-animate.jsx.map +1 -1
  39. package/dist/solid/diagnostic-codes.d.ts.map +1 -1
  40. package/dist/solid/diagnostic-codes.js +11 -0
  41. package/dist/solid/diagnostic-codes.js.map +1 -1
  42. package/dist/solid/hooks/ward.d.ts.map +1 -1
  43. package/dist/solid/hooks/ward.js +35 -9
  44. package/dist/solid/hooks/ward.js.map +1 -1
  45. package/dist/solid/index.d.ts +132 -20
  46. package/dist/solid/index.d.ts.map +1 -1
  47. package/dist/solid/index.jsx +50 -14
  48. package/dist/solid/index.jsx.map +1 -1
  49. package/dist/solid/live-scroll.d.ts +9 -4
  50. package/dist/solid/live-scroll.d.ts.map +1 -1
  51. package/dist/solid/live-scroll.jsx +14 -6
  52. package/dist/solid/live-scroll.jsx.map +1 -1
  53. package/dist/solid/reorder-components.d.ts +3 -0
  54. package/dist/solid/reorder-components.d.ts.map +1 -1
  55. package/dist/solid/reorder-components.jsx +4 -0
  56. package/dist/solid/reorder-components.jsx.map +1 -1
  57. package/dist/solid/v1/index.d.ts +1 -1
  58. package/dist/solid/v1/index.jsx +1 -1
  59. package/dist/solid/v1/live-scroll.d.ts +3 -2
  60. package/dist/solid/v1/live-scroll.d.ts.map +1 -1
  61. package/dist/solid/v1/live-scroll.jsx +3 -2
  62. package/dist/solid/v1/live-scroll.jsx.map +1 -1
  63. package/dist/solid/ward.d.ts +2 -2
  64. package/dist/solid/ward.d.ts.map +1 -1
  65. package/dist/solid/ward.jsx +1 -1
  66. package/dist/solid/ward.jsx.map +1 -1
  67. package/package.json +5 -5
  68. package/skills/wardic-diagnostics/SKILL.md +43 -2
  69. package/skills/wardic-solid/from-motion.md +1 -0
  70. package/src/create-animate.tsx +93 -8
  71. package/src/diagnostic-codes.ts +13 -0
  72. package/src/hooks/ward.ts +33 -8
  73. package/src/index.tsx +121 -20
  74. package/src/live-scroll.tsx +22 -9
  75. package/src/reorder-components.tsx +4 -0
  76. package/src/v1/index.tsx +1 -1
  77. package/src/v1/live-scroll.tsx +3 -2
  78. package/src/ward.tsx +3 -3
@@ -8,11 +8,52 @@
8
8
  */
9
9
  import { isServer } from "@solidjs/web"
10
10
  import * as Bool from "effect/Boolean"
11
- import { onCleanup } from "solid-js"
11
+ import { constFalse } from "effect/Function"
12
+ import * as Option from "effect/Option"
13
+ import * as Predicate from "effect/Predicate"
14
+ import * as UndefinedOr from "effect/UndefinedOr"
15
+ import { onCleanup, untrack } from "solid-js"
12
16
  import * as Imperative from "@wardic/dom/unstable/Imperative"
13
17
  import { useWardicDefaultTransition, useWardicGate, useWardicValueReads, useWardicPositionalKeys, useWardicReducedMotion, useWardicRuntime, useWardicSkipAnimations } from "./provider.tsx"
14
18
  import * as ElementSetup from "@wardic/dom/unstable/ElementSetup"
19
+ import { report } from "./diagnostics.ts"
15
20
  import { flightsOf } from "./flights.ts"
21
+ import type { HookWard } from "./hooks/ward.ts"
22
+ import { type Sensed, sensedOf } from "./ward.tsx"
23
+
24
+ /**
25
+ * What `animate` animates on Solid 2: an element, a selector looked up inside the scope, a list of
26
+ * elements, or a ward, a `createWards` row included, its Subject as the run starts (the 3.0 bar's Q4).
27
+ * Motion's `ElementOrSelector`.
28
+ */
29
+ export type WardicAnimationSubject = Imperative.WardicAnimationSubject | HookWard
30
+
31
+ /** A Segment of elements on Solid 2, `[subject, target, options?]`: its subject a {@link WardicAnimationSubject}, a ward too. Motion's. */
32
+ export type WardicElementSegment = Imperative.WardicElementSegment<HookWard>
33
+
34
+ /** One step of a sequence on Solid 2: a label, a Segment of elements (a ward's too), a function Segment, or a Segment of a Batch. */
35
+ export type WardicSegment = Imperative.WardicSegment<HookWard>
36
+
37
+ /**
38
+ * A sequence on Solid 2: Segments played one after another, unless an `at` says where one starts, and
39
+ * labels to start them at, a ward a Segment's subject too. `animate(sequence, options)` plays it.
40
+ * Motion's `AnimationSequence`.
41
+ *
42
+ * @example
43
+ * animate([
44
+ * [title, { opacity: 1 }],
45
+ * ["li", { x: [-20, 0] }, { delay: stagger(0.05), at: "-0.1" }],
46
+ * ])
47
+ * @see https://wardic.dev/reference/solid/animation/sequences
48
+ */
49
+ export type WardicAnimationSequence = Imperative.WardicAnimationSequence<HookWard>
50
+
51
+ /**
52
+ * A scope's `animate` on Solid 2: `animate(subject, target, options?)` animates the subject's elements,
53
+ * a ward's Subject among them, to `target`, and `animate(sequence, options?)` plays a sequence. Either
54
+ * returns its playback controls. Motion's `animate`, as `useAnimate` gives it.
55
+ */
56
+ export type WardicAnimate = Imperative.WardicAnimate<HookWard>
16
57
 
17
58
  /** A scope's landing: the animation that landed last, as `scope.settled()` gives it. */
18
59
  // #433's Q8: held in an object, as the controls are awaitable, which an async value would wait on
@@ -42,13 +83,57 @@ const settledOf = (): { readonly watch: Imperative.AnimationWatch; readonly read
42
83
  return { watch, read: flights.read }
43
84
  }
44
85
 
86
+ const RUN_WITHOUT_SUBJECT =
87
+ "animate: the ward has no Subject to animate: it isn't rendered yet, its `show` hides it, or it's gone, so the run starts nothing and resolves at once. Start the run once its Subject is on the page: from an event on it, in `onSettled`, or from an effect over what shows it."
88
+
89
+ /** The wards a run was given with no Subject, reported once each (the 3.0 bar's Q8). */
90
+ // Module state (#460, Q7): each ward reported, held weakly, so one report a ward however many scopes run it.
91
+ const REPORTED = new WeakSet<object>()
92
+
93
+ /** A run given `ward` with no Subject (Q8): reported once for it, in development. */
94
+ const reportRunWithoutSubject = (ward: object): void => {
95
+ if (REPORTED.has(ward)) return
96
+ REPORTED.add(ward)
97
+ report("WARDIC_RUN_WITHOUT_SUBJECT", RUN_WITHOUT_SUBJECT)
98
+ }
99
+
100
+ /** Whether `ward` is leaving now: a hook ward's `exiting()`. A ward no hook shows never leaves. */
101
+ const leaving = (ward: object): boolean =>
102
+ Bool.match(Predicate.hasProperty(ward, "exiting"), { onFalse: constFalse, onTrue: () => untrack((ward as HookWard).exiting) })
103
+
104
+ /**
105
+ * The element a ward is on, while it's on the page: none before it's rendered, while its `show` hides it,
106
+ * or once it's gone, though a ward keeps the last element it was given.
107
+ */
108
+ const onThePage = (sensed: Sensed): Option.Option<HTMLElement> => Option.filter(Option.fromUndefinedOr(untrack(sensed.element)), (element) => element.isConnected)
109
+
110
+ /**
111
+ * The element a ward is on as a run starts (the 3.0 bar's Q4): what `animate` takes a ward for. None while
112
+ * it's leaving (Q5), or while it has none on the page (Q5, Q8: reported); `undefined` for anything that
113
+ * isn't a ward, which `animate` then reads as it reads any subject.
114
+ */
115
+ const wardSubjectsOf = (given: unknown): ReadonlyArray<Element> | undefined =>
116
+ UndefinedOr.map(sensedOf(given), (sensed): ReadonlyArray<Element> =>
117
+ Bool.match(leaving(given as object), {
118
+ onTrue: () => [],
119
+ onFalse: () =>
120
+ Option.match(onThePage(sensed), {
121
+ onNone: () => {
122
+ reportRunWithoutSubject(given as object)
123
+ return []
124
+ },
125
+ onSome: (element) => [element],
126
+ }),
127
+ }),
128
+ )
129
+
45
130
  /**
46
131
  * Animates elements from code, Wardic's and plain ones alike: returns a scope, given to an element's
47
- * `ref`, and `animate`. `animate(subject, target, options?)` animates an element, the elements a
48
- * selector finds inside the scope, or a list; `animate(sequence)` plays a sequence. Each returns its
49
- * playback controls, which can be awaited. `scope.settled()` is pending while its animations are in
50
- * flight. Call it in a component under a `WardicProvider`; the component's cleanup stops its
51
- * animations. Motion's `useAnimate`.
132
+ * `ref`, and `animate`. `animate(subject, target, options?)` animates an element, a ward's Subject, the
133
+ * elements a selector finds inside the scope, or a list; `animate(sequence)` plays a sequence. Each
134
+ * returns its playback controls, which can be awaited. `scope.settled()` is pending while its animations
135
+ * are in flight. Call it in a component: it takes a `WardicProvider`'s settings above it, else the
136
+ * page's, and the component's cleanup stops its animations. Motion's `useAnimate`.
52
137
  *
53
138
  * @example
54
139
  * const [scope, animate] = createAnimate()
@@ -58,7 +143,7 @@ const settledOf = (): { readonly watch: Imperative.AnimationWatch; readonly read
58
143
  * @see https://wardic.dev/reference/solid/animation/create-animate
59
144
  */
60
145
  // #433, as Solid 1's; `settled()` is #433's Q8, as a ward's (ADR-0046).
61
- export function createAnimate<T extends Element = HTMLElement>(): readonly [WardicAnimationScopeV2<T>, Imperative.WardicAnimate] {
146
+ export function createAnimate<T extends Element = HTMLElement>(): readonly [WardicAnimationScopeV2<T>, WardicAnimate] {
62
147
  const settled = settledOf()
63
148
  const made = Imperative.scopeOf<T>(settled.watch)
64
149
  const scope = Object.defineProperty(made.scope, "settled", { value: settled.read }) as WardicAnimationScopeV2<T>
@@ -74,5 +159,5 @@ export function createAnimate<T extends Element = HTMLElement>(): readonly [Ward
74
159
  ...ElementSetup.valueReadsOf(useWardicValueReads()),
75
160
  }
76
161
  onCleanup(made.stopAll)
77
- return [scope, Imperative.scopedAnimate(env, () => scope.current, made.watch)] as const
162
+ return [scope, Imperative.scopedAnimate<HookWard>(env, () => scope.current, made.watch, wardSubjectsOf)] as const
78
163
  }
@@ -254,6 +254,19 @@ export const CODES: ReadonlyArray<Diagnostic.Entry> = [
254
254
  after: 'import { createWard } from "@wardic/solid/hooks"\n\nexport const Card = () => {\n const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })\n return <div {...card.with({ style: { width: "40px" } })} />\n}',
255
255
  },
256
256
  },
257
+ {
258
+ code: "WARDIC_RUN_WITHOUT_SUBJECT",
259
+ group: "Animating from code",
260
+ summary: "A run from code (`animate(ward, …)`, a sequence's `[ward, …]`) was given a ward with no Subject: not rendered yet, hidden by its `show`, or gone.",
261
+ why: "A ward stands for its Subject as a run starts. With none on the page there's nothing to animate, so the run starts nothing and its controls resolve at once. A run is a moment, and doesn't wait for its Subject to arrive: a ward its `show` hides may never show.",
262
+ repair: "Start the run once the ward's Subject is on the page: from an event on it, in `onSettled` for one its component renders, or from an effect over what shows it. A run started in a component's body comes before its Subject is rendered.",
263
+ example: {
264
+ before:
265
+ 'import { createAnimate } from "@wardic/solid"\nimport { createWard } from "@wardic/solid/hooks"\n\nfunction Card() {\n const card = createWard()\n const [, animate] = createAnimate()\n animate(card, { x: [0, 8, -8, 0] })\n return <div {...card}>Saved</div>\n}',
266
+ after:
267
+ 'import { createAnimate } from "@wardic/solid"\nimport { createWard } from "@wardic/solid/hooks"\nimport { onSettled } from "solid-js"\n\nfunction Card() {\n const card = createWard()\n const [, animate] = createAnimate()\n onSettled(() => {\n animate(card, { x: [0, 8, -8, 0] })\n })\n return <div {...card}>Saved</div>\n}',
268
+ },
269
+ },
257
270
  {
258
271
  code: "WARDIC_NO_PROVIDER",
259
272
  group: "Runtime and page",
package/src/hooks/ward.ts CHANGED
@@ -1125,6 +1125,9 @@ const popping = (ward: Ward, made: Joined, state: ShowState, exits: ((now: Seen)
1125
1125
  })
1126
1126
  state.letGo = () => popped().letGo()
1127
1127
  let wasShown: boolean | undefined
1128
+ // A ward taken late, by a row or a presence value already leaving (Q20, Q12), was on the page and
1129
+ // shown as it was taken: its first run, which reads it hidden already, is its leave, not its mount.
1130
+ if (takingLate) wasShown = true
1128
1131
  const shownIs = (shown: boolean): void => {
1129
1132
  const before = wasShown
1130
1133
  wasShown = shown
@@ -1306,9 +1309,13 @@ const poppedOf = (
1306
1309
  if (Predicate.isUndefined(sensed)) return undefined
1307
1310
  return untrack(() => sensed.element())
1308
1311
  }
1309
- // What it has taken to leave with it, held for at each of its leaves until their exits land: the
1310
- // wards inside a row's or a presence value's element (Q20), and its followers with an exit of their own (Q12).
1311
- const swept: Array<ShowState> = []
1312
+ // What it has taken to leave with it, held for at each of its leaves until their exits land. The
1313
+ // wards inside a row's or a presence value's element (Q20), of the element they were taken from: a
1314
+ // presence's ward is on a new element for every value, and what was inside the old one went with
1315
+ // it. Its followers with an exit of their own (Q12), each taken once, as they're followers still.
1316
+ const inside: Array<ShowState> = []
1317
+ let insideOf: HTMLElement | undefined
1318
+ const tookFollowers = new WeakMap<Ward, ShowState>()
1312
1319
  /**
1313
1320
  * Its leave, for what leaves with it. A row's or a presence value's element: the wards inside it,
1314
1321
  * still alive as it stays to leave (Q20). Any leader's followers with an `exit` of their own, which
@@ -1318,8 +1325,15 @@ const poppedOf = (
1318
1325
  const leaveWithIt = (el: HTMLElement): void => {
1319
1326
  queueMicrotask(() => {
1320
1327
  if (untrack(state.shown)) return
1321
- if (state.sweeps) sweepInside(el, ward, state.shown, swept)
1322
- followersLeaving(ward, state.shown, swept)
1328
+ // On the element it left from before, a leave turned round and begun again: what it took inside
1329
+ // it is taken already, and holds this leave as it held that one.
1330
+ if (insideOf !== el) {
1331
+ inside.length = 0
1332
+ insideOf = el
1333
+ }
1334
+ if (state.sweeps) sweepInside(el, ward, state.shown, inside)
1335
+ const swept = [...inside]
1336
+ followersLeaving(ward, state.shown, tookFollowers, swept)
1323
1337
  Arr.forEach(swept, (inner) => {
1324
1338
  if (!untrack(inner.leaves)) return
1325
1339
  inner.gone = holdOn(state)()
@@ -1876,16 +1890,27 @@ const takenLate = (found: Ward, kept: Kept, shown: Accessor<boolean>): ShowState
1876
1890
  return take.state
1877
1891
  }
1878
1892
 
1879
- /** `leader`'s followers with an `exit` of their own, each taken by it as it first leaves (Q12), each one's leaving state added to `into`. */
1880
- const followersLeaving = (leader: Ward, shown: Accessor<boolean>, into: Array<ShowState>): void => {
1893
+ /**
1894
+ * `leader`'s followers with an `exit` of their own, each taken by it as it first leaves (Q12) and kept
1895
+ * in `took`, each one's leaving state added to `into`. Its followers now: one whose owner has ended
1896
+ * is one no more ({@link followsOf}), so a presence value's follower holds that value's leave alone.
1897
+ */
1898
+ const followersLeaving = (leader: Ward, shown: Accessor<boolean>, took: WeakMap<Ward, ShowState>, into: Array<ShowState>): void => {
1881
1899
  const all = FOLLOWERS.get(leader)
1882
1900
  if (Predicate.isUndefined(all)) return
1883
1901
  Iter.forEach(all, (follower) => {
1884
1902
  if (!follower.exits) return
1903
+ const before = took.get(follower.ward)
1904
+ if (Predicate.isNotUndefined(before)) {
1905
+ into.push(before)
1906
+ return
1907
+ }
1885
1908
  const kept = keptFor(follower.ward)
1886
1909
  if (Predicate.isUndefined(kept)) return
1887
1910
  const taken = takenLate(follower.ward, kept, shown)
1888
- if (Predicate.isNotUndefined(taken)) into.push(taken)
1911
+ if (Predicate.isUndefined(taken)) return
1912
+ took.set(follower.ward, taken)
1913
+ into.push(taken)
1889
1914
  })
1890
1915
  }
1891
1916
 
package/src/index.tsx CHANGED
@@ -69,19 +69,37 @@ export type { WardicConfigProps } from "./wardic-config.tsx"
69
69
  * of the element's props, so an inline `{...ward(config)}` would make a new one each time, and throws.
70
70
  * A kept ward has `.Provider` for its Variant children, `.read(key)` and `.atom(key)` for its values.
71
71
  */
72
+ // `ward(config)`, `wardic.*`, `w.*` and what serves them alone, the main entry's presence handle, `reorderGroup`,
73
+ // `reorderItem`, drag controls and the four sensors go at 3.0, `@deprecated` until then, each naming what takes
74
+ // its place (the 3.0 bar's Q10, Q11 and Q13). TypeScript reads the tag on an export specifier, so each carries its own.
72
75
  export {
76
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
73
77
  type AnyWard,
78
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
74
79
  type Ward,
80
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
75
81
  type WardChecked,
82
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
76
83
  type WardConfig,
84
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
77
85
  type WardOptions,
86
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
78
87
  type WardProps,
88
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
79
89
  type WardRead,
90
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
80
91
  type WardStyle,
92
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
81
93
  type WardWithProps,
82
94
  } from "./ward.tsx"
83
- export { ward } from "./complete.tsx"
84
- export type { HeldWard } from "./ward-first.ts"
95
+ export {
96
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
97
+ ward,
98
+ } from "./complete.tsx"
99
+ export type {
100
+ /** @deprecated `ward(config)` goes at 3.0: `createWard(...runes)` from `@wardic/solid/hooks` takes its place. */
101
+ HeldWard,
102
+ } from "./ward-first.ts"
85
103
  /** A Stage (#884, ADR-0073 decisions 12 and 20): what runs a scene, found through its own Solid context. */
86
104
  export {
87
105
  type SceneObjectEvent,
@@ -131,8 +149,16 @@ export type { WardicAnimationDefinition } from "@wardic/dom/unstable/WardConfig"
131
149
  export type { AnimatedKey, WardKey, WardValueOf } from "./ward-keys.ts"
132
150
 
133
151
  /** The variant context (ADR-0007): what a ward's `.Provider` and a `wardic.*` element hand their children. */
134
- export { useVariantContext, WardicVariantContext } from "./variant-node.ts"
135
- export type { WardicVariantContextValue } from "@wardic/core/unstable/VariantTree"
152
+ export {
153
+ /** @deprecated What a 2.x ward's `.Provider` and `wardic.*` hand their children, going at 3.0 with them: a hook ward's child follows it by the rune key `follow`. */
154
+ useVariantContext,
155
+ /** @deprecated What a 2.x ward's `.Provider` and `wardic.*` hand their children, going at 3.0 with them: a hook ward's child follows it by the rune key `follow`. */
156
+ WardicVariantContext,
157
+ } from "./variant-node.ts"
158
+ export type {
159
+ /** @deprecated What a 2.x ward's `.Provider` and `wardic.*` hand their children, going at 3.0 with them: a hook ward's child follows it by the rune key `follow`. */
160
+ WardicVariantContextValue,
161
+ } from "@wardic/core/unstable/VariantTree"
136
162
  export type {
137
163
  WardicOrchestration,
138
164
  WardicReducedMotion,
@@ -161,31 +187,60 @@ export type {
161
187
  * element's own props and the motion props; a `wardic.create(Component)` component forwards its `ref`.
162
188
  */
163
189
  export {
190
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
164
191
  type GivenWard,
192
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
165
193
  type Wardic,
194
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
166
195
  type WardicBeside,
196
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
167
197
  type WardicComponent,
198
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
168
199
  type WardicMotion,
200
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
169
201
  type WardicProps,
202
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
170
203
  type WardicWrappable,
204
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
171
205
  type WardicWrapped,
206
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
172
207
  type WardNodeKey,
208
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
173
209
  type WardRefCallback,
210
+ /** @deprecated `wardic.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
174
211
  wardic,
175
212
  } from "./wardic.tsx"
176
213
  /**
177
214
  * `w` (#511, ADR-0067; Motion's `m`): the **Slim element**'s forms, `w.<tag>`, `w.create` and
178
215
  * `w.ward()`, each as its Complete form but with only the Features chosen above it.
179
216
  */
180
- export { type W, w } from "./w.tsx"
217
+ export {
218
+ /** @deprecated `w.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
219
+ type W,
220
+ /** @deprecated `w.*` goes at 3.0: a hook ward, `createWard(...runes)` from `@wardic/solid/hooks`, spread on the element. */
221
+ w,
222
+ } from "./w.tsx"
181
223
  // #516: a Wardic instance, its `w` and its ward typed to its Features: what `makeWard({ features, elements })`
182
224
  // gives. `createWardic` was deleted at the owner's word (probe: behaviour-runes, after the scopes round); Solid 1's stays.
183
225
  export type { WardConfigOf, WardicInstance } from "./wardic-instance.ts"
184
- export type { WardicMotionPropsV2 as WardicMotionProps } from "./motion-props.ts"
226
+ export type {
227
+ /** @deprecated `w.*`'s and `wardic.*`'s, going at 3.0 with them: a hook ward (`createWard` from `@wardic/solid/hooks`) takes runes, not motion props. */
228
+ WardicMotionPropsV2 as WardicMotionProps,
229
+ } from "./motion-props.ts"
185
230
  // #443 (Motion's): `wardic.create`'s options; whether a component is a Wardic element's and what it
186
231
  // wraps; whether a prop is a motion prop, Solid 2's own list.
187
- export { isWardicComponent, unwrapWardicComponent, type WardicCreateOptions } from "./wardic-component.ts"
188
- export { isValidWardicPropV2 as isValidWardicProp } from "./motion-props.ts"
232
+ export {
233
+ /** @deprecated `w.*`'s and `wardic.*`'s, going at 3.0 with them: a hook ward (`createWard` from `@wardic/solid/hooks`) is spread on its element, no component of its own. */
234
+ isWardicComponent,
235
+ /** @deprecated `w.*`'s and `wardic.*`'s, going at 3.0 with them: a hook ward (`createWard` from `@wardic/solid/hooks`) is spread on its element, no component of its own. */
236
+ unwrapWardicComponent,
237
+ /** @deprecated `w.*`'s and `wardic.*`'s, going at 3.0 with them: a hook ward (`createWard` from `@wardic/solid/hooks`) is spread on its element, no component of its own. */
238
+ type WardicCreateOptions,
239
+ } from "./wardic-component.ts"
240
+ export {
241
+ /** @deprecated `w.*`'s and `wardic.*`'s, going at 3.0 with them: a hook ward (`createWard` from `@wardic/solid/hooks`) takes runes, not motion props. */
242
+ isValidWardicPropV2 as isValidWardicProp,
243
+ } from "./motion-props.ts"
189
244
 
190
245
  /**
191
246
  * A presence (ADR-0007): each child's exit before it's removed, from its ward's `exit`. `<AnimatePresence>`
@@ -193,7 +248,14 @@ export { isValidWardicPropV2 as isValidWardicProp } from "./motion-props.ts"
193
248
  * hooks' `<Presence>` and `createPresenceScope` are built on it, and take its place. Solid 1's stays. A
194
249
  * presence handle, `createPresence()`, is what a `<Presence ref>` is given.
195
250
  */
196
- export { createPresence, type Presence, type PresenceEvent, type PresenceEvents } from "./presence-handle.ts"
251
+ export {
252
+ /** @deprecated The main entry's presence handle goes at 3.0: `createPresenceRef()` from `@wardic/solid/hooks`, for `<Presence ref>`. */
253
+ createPresence,
254
+ /** @deprecated The main entry's presence handle goes at 3.0: `createPresenceRef()` from `@wardic/solid/hooks`, for `<Presence ref>`. */
255
+ type Presence,
256
+ type PresenceEvent,
257
+ type PresenceEvents,
258
+ } from "./presence-handle.ts"
197
259
  export type { PresenceMode, PresenceRecord } from "@wardic/dom/unstable/PresenceController"
198
260
  // `usePresence`, `useIsPresent`, `usePresenceData`, `PresenceContext` and `usePresenceContext` were deleted at the owner's
199
261
  // word (probe: behaviour-runes, after the scopes round; the gap grill's Q52): what cares about leaving has a ward, one with
@@ -215,6 +277,7 @@ export { measureLayoutBox } from "@wardic/dom/ProjectionSystem"
215
277
  * setting over it, and `createPageInView` whether the page is shown (#443).
216
278
  */
217
279
  export {
280
+ /** @deprecated `createDrag` goes at 3.0: a hook ward's `dragging()` and its `drag` events (`when("drag")`), `createWard` from `@wardic/solid/hooks`. */
218
281
  type CreateDragOptions,
219
282
  createInView,
220
283
  createPageInView,
@@ -222,10 +285,22 @@ export {
222
285
  createReducedMotionConfig,
223
286
  type Sensor,
224
287
  } from "./sensors.tsx"
225
- export { createDrag } from "./drag-sensor.tsx"
226
- export { createFocus } from "./focus-sensor.tsx"
227
- export { createHover } from "./hover-sensor.tsx"
228
- export { createPress } from "./press-sensor.tsx"
288
+ export {
289
+ /** @deprecated `createDrag` goes at 3.0: a hook ward's `dragging()` and its `drag` events (`when("drag")`), `createWard` from `@wardic/solid/hooks`. */
290
+ createDrag,
291
+ } from "./drag-sensor.tsx"
292
+ export {
293
+ /** @deprecated `createFocus` goes at 3.0: a hook ward's `focusing()`, `createWard` from `@wardic/solid/hooks`, spread on its element or handed one by a rune's `subject`. */
294
+ createFocus,
295
+ } from "./focus-sensor.tsx"
296
+ export {
297
+ /** @deprecated `createHover` goes at 3.0: a hook ward's `hovering()`, `createWard` from `@wardic/solid/hooks`, spread on its element or handed one by a rune's `subject`. */
298
+ createHover,
299
+ } from "./hover-sensor.tsx"
300
+ export {
301
+ /** @deprecated `createPress` goes at 3.0: a hook ward's `pressing()`, `createWard` from `@wardic/solid/hooks`, spread on its element or handed one by a rune's `subject`. */
302
+ createPress,
303
+ } from "./press-sensor.tsx"
229
304
  // `createCycle` (#443, Motion's `useCycle`): one of a list of states at a time, stepped through.
230
305
  export { createCycle, type Cycle } from "./cycle.ts"
231
306
 
@@ -234,10 +309,26 @@ export { fromAtom, streamToSignal } from "./bridge.tsx"
234
309
  export type { WardicDragTransition, WardicLayoutBox, WardicScaleCorrector, WardicTransformPoint, WardicTransformTemplate, WardicViewport } from "@wardic/dom/unstable/WardConfig"
235
310
  export type { WardicBoundingBox, WardicDragConstraints, WardicMeasureDragConstraints } from "@wardic/dom/unstable/DragConstraints"
236
311
  // Drag controls (#431, Motion's `useDragControls`): a drag started from a handle or a track.
237
- export { createDragControls, type WardicDragControls, type WardicDragControlsOptions } from "@wardic/dom/unstable/DragControls"
312
+ export {
313
+ /** @deprecated `createDragControls` goes at 3.0: `createGrip(row)` from `@wardic/solid/hooks`, a rune of the grip's own ward. */
314
+ createDragControls,
315
+ /** @deprecated `createDragControls` goes at 3.0: `createGrip(row)` from `@wardic/solid/hooks`, a rune of the grip's own ward. */
316
+ type WardicDragControls,
317
+ /** @deprecated `createDragControls` goes at 3.0: `createGrip(row)` from `@wardic/solid/hooks`, a rune of the grip's own ward. */
318
+ type WardicDragControlsOptions,
319
+ } from "@wardic/dom/unstable/DragControls"
238
320
  // Imperative animation (#433, Motion's `useAnimate`): an Animation scope with `settled()`, its `animate` and its Playback controls.
239
321
  // `WardicAnimationScope` on both bindings, each its own (#618, P1), as `isValidWardicProp` is.
240
- export { createAnimate, type WardicAnimationScopeV2 as WardicAnimationScope, type WardicScopeLanding } from "./create-animate.tsx"
322
+ export {
323
+ createAnimate,
324
+ type WardicAnimate,
325
+ type WardicAnimationScopeV2 as WardicAnimationScope,
326
+ type WardicAnimationSequence,
327
+ type WardicAnimationSubject,
328
+ type WardicElementSegment,
329
+ type WardicScopeLanding,
330
+ type WardicSegment,
331
+ } from "./create-animate.tsx"
241
332
  export {
242
333
  createBatch,
243
334
  type WardicBatch,
@@ -264,17 +355,12 @@ export type {
264
355
  WardicBatchValues,
265
356
  } from "@wardic/dom/unstable/BatchMembers"
266
357
  export type {
267
- WardicAnimate,
268
358
  WardicAnimateOptions,
269
359
  WardicAnimationEnd,
270
- WardicAnimationSequence,
271
- WardicAnimationSubject,
272
360
  WardicBatchSegment,
273
- WardicElementSegment,
274
361
  WardicFunctionSegment,
275
362
  WardicPlaybackControls,
276
363
  WardicPlayState,
277
- WardicSegment,
278
364
  WardicSegmentOptions,
279
365
  WardicSegmentTarget,
280
366
  WardicSequenceLabel,
@@ -311,23 +397,38 @@ export type { FollowAccessor, FollowValueOptions, Live, LiveSource, SpringAccess
311
397
  * utilities over `createReorder` (probe: hooks-first, the Reorder round).
312
398
  */
313
399
  export { Reorder } from "./reorder-components.tsx"
400
+ // `ReorderGroup`, `ReorderGroupEvents` and `ReorderElementTag` the Batch pair names too, so the Batch round decides them.
314
401
  export {
402
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
315
403
  type AnyReorderGroup,
404
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
316
405
  type AnyReorderItem,
406
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
317
407
  type GroupRefCallback,
318
408
  type ReorderElementTag,
319
409
  type ReorderGroup,
410
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
320
411
  type ReorderGroupComponentProps,
412
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
321
413
  type ReorderGroupConfig,
322
414
  type ReorderGroupEvents,
415
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
323
416
  type ReorderGroupOf,
417
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
324
418
  type ReorderGroupProps,
419
+ /** @deprecated `reorderGroup` and `<Reorder.Group>` go at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
325
420
  reorderGroup,
421
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
326
422
  type ReorderItem,
423
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
327
424
  type ReorderItemComponentProps,
425
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
328
426
  type ReorderItemConfig,
427
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
329
428
  type ReorderItemLayout,
429
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
330
430
  type ReorderItemOf,
431
+ /** @deprecated `reorderItem` and `<Reorder.Item>` go at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
331
432
  reorderItem,
332
433
  type ReorderBatchColumnSize,
333
434
  type ReorderBatchGap,
@@ -22,6 +22,8 @@ import * as Scroll from "@wardic/dom/unstable/features/Scroll"
22
22
  import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
23
23
  import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
24
24
  import { followScroll, letGoScroll, scrollAtomsOf } from "./scroll-values.ts"
25
+ import type { HookWard } from "./hooks/ward.ts"
26
+ import { sensedOf } from "./ward.tsx"
25
27
  import * as Timelines from "@wardic/core/unstable/Timelines"
26
28
  import { followAtom } from "./bridge.tsx"
27
29
  import { CLOSE_FAILED, SERVER_ZERO } from "./live-value.tsx"
@@ -38,8 +40,11 @@ export type ElementSource = Element | Accessor<Element | undefined>
38
40
  export interface ScrollOptions {
39
41
  /** The scrolling element, as an accessor of its ref: `() => box`. The page's scroll when left out. */
40
42
  readonly container?: ElementSource
41
- /** An element whose way through the container the progress reads, between the `offset`s. */
42
- readonly target?: ElementSource
43
+ /**
44
+ * An element whose way through the container the progress reads, between the `offset`s, or a ward, its
45
+ * Subject's, followed to another element as the ward moves (the 3.0 bar's Q4).
46
+ */
47
+ readonly target?: ElementSource | HookWard
43
48
  /**
44
49
  * Where the progress runs, as Motion's: each stop pairs an edge of the target with an edge of the
45
50
  * container, `["start end", "end start"]`, 0 at the first and 1 at the last. An edge is `start`,
@@ -67,11 +72,18 @@ export interface ScrollValues {
67
72
  const NOT_YET = { container: Option.none(), target: Option.none() } as const
68
73
  const SERVER_SCROLL: ScrollValues = { scrollX: SERVER_ZERO, scrollY: SERVER_ZERO, scrollXProgress: SERVER_ZERO, scrollYProgress: SERVER_ZERO }
69
74
 
70
- /** An element source read now: `None` for an accessor whose ref hasn't arrived. */
71
- const elementOf = (source: ElementSource | undefined): Option.Option<Element | undefined> =>
72
- Bool.match(Predicate.isFunction(source), {
73
- onTrue: () => Option.fromUndefinedOr((source as Accessor<Element | undefined>)()),
74
- onFalse: () => Option.some(source as Element | undefined),
75
+ /**
76
+ * An element source read now: `None` for an accessor whose ref hasn't arrived, or a ward with no Subject.
77
+ * A ward's is followed (the 3.0 bar's Q4), so the scroll moves with it to another element.
78
+ */
79
+ const elementOf = (source: ElementSource | HookWard | undefined): Option.Option<Element | undefined> =>
80
+ UndefinedOr.match(sensedOf(source), {
81
+ onDefined: (sensed) => Option.fromUndefinedOr(sensed.element()),
82
+ onUndefined: () =>
83
+ Bool.match(Predicate.isFunction(source), {
84
+ onTrue: () => Option.fromUndefinedOr((source as Accessor<Element | undefined>)()),
85
+ onFalse: () => Option.some(source as Element | undefined),
86
+ }),
75
87
  })
76
88
 
77
89
  /**
@@ -79,8 +91,9 @@ const elementOf = (source: ElementSource | undefined): Option.Option<Element | u
79
91
  * and `scrollYProgress`, from 0 to 1 through its range. The page's, or a `container`'s. With a
80
92
  * `target`, the progress is the target's way through, between two `offset`s, on `axis`. Each is set in
81
93
  * the scroll's own event, so a value derived from one paints in the frame that shows the scroll. A
82
- * `container` or `target` given as an accessor of a ref reads 0s until the ref is there. 0s on a
83
- * server. Motion's `useScroll`.
94
+ * `container` or `target` given as an accessor of a ref reads 0s until the ref is there, and a target
95
+ * taken off the page holds the values where they were until one is back. 0s on a server. Motion's
96
+ * `useScroll`.
84
97
  *
85
98
  * Where the browser has native scroll timelines, an element's `opacity`, `filter`, `clipPath` or
86
99
  * transform key given one of these, or a `createTransform` of one through ranges, is drawn by the
@@ -52,9 +52,13 @@ const Grip = (props: Record<string, unknown>): JSX.Element => elements().Grip(pr
52
52
  * @see https://wardic.dev/reference/solid/reorder/reorder
53
53
  */
54
54
  // ADR-0020; the Batch pair, ADR-0072 (#712); the grip, probe: behaviour-runes (Q29).
55
+ // The three going at 3.0 are `@deprecated` until then (the 3.0 bar's Q10 and Q13); the Batch pair is the Batch round's.
55
56
  export const Reorder = {
57
+ /** @deprecated `<Reorder.Group>` goes at 3.0: `createReorder({ each, onReorder })` from `@wardic/solid/hooks`, spread on the list. */
56
58
  Group: Group as <V, Tag extends ReorderElementTag = "ul">(props: ReorderGroupComponentProps<V, Tag>) => JSX.Element,
59
+ /** @deprecated `<Reorder.Item>` goes at 3.0: `list.item(value)`, a rune of the row's ward (`createReorder` from `@wardic/solid/hooks`). */
57
60
  Item: Item as <V, Tag extends ReorderElementTag = "li">(props: ReorderItemComponentProps<V, Tag>) => JSX.Element,
61
+ /** @deprecated `<Reorder.Grip>` goes at 3.0: `createGrip(row)` from `@wardic/solid/hooks`, a rune of the grip's own ward. */
58
62
  Grip: Grip as <Tag extends ReorderElementTag = "button">(props: ReorderGripComponentProps<Tag>) => JSX.Element,
59
63
  BatchGroup,
60
64
  BatchItem,
package/src/v1/index.tsx CHANGED
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566).
19
19
  */
20
- export const VERSION = "3.0.0-next.3"
20
+ export const VERSION = "3.0.0-next.4"
21
21
 
22
22
  /**
23
23
  * `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
@@ -78,8 +78,9 @@ const elementOf = (source: ElementSource): Option.Option<Element> =>
78
78
  * and `scrollYProgress`, from 0 to 1 through its range. The page's, or a `container`'s. With a
79
79
  * `target`, the progress is the target's way through, between two `offset`s, on `axis`. Each is set in
80
80
  * the scroll's own event, so a value derived from one paints in the frame that shows the scroll. A
81
- * `container` or `target` given as an accessor of a ref reads 0s until the ref is there. 0s on a
82
- * server. Motion's `useScroll`.
81
+ * `container` or `target` given as an accessor of a ref reads 0s until the ref is there, and a target
82
+ * taken off the page holds the values where they were until one is back. 0s on a server. Motion's
83
+ * `useScroll`.
83
84
  *
84
85
  * Where the browser has native scroll timelines, an element's `opacity`, `filter`, `clipPath` or
85
86
  * transform key given one of these, or a `createTransform` of one through ranges, is drawn by the
package/src/ward.tsx CHANGED
@@ -387,10 +387,10 @@ export const heldOf = (ward: AnyWard, subject?: Accessor<unknown>): JSX.Element
387
387
  }) as unknown as JSX.Element
388
388
  }
389
389
 
390
- /** A client ward's {@link Sensed}: `undefined` for a server's, which has none. */
391
- export const sensedOf = (ward: AnyWard): Sensed | undefined => {
390
+ /** A client ward's {@link Sensed}: `undefined` for a server's, which has none, and for anything that isn't a ward. */
391
+ export const sensedOf = (ward: unknown): Sensed | undefined => {
392
392
  if (Bool.not(Predicate.hasProperty(ward, WARD_STATE))) return undefined
393
- const state = stateOf(ward)
393
+ const state = stateOf(ward as object)
394
394
  return { lifecycle: state.lifecycle, element: state.element }
395
395
  }
396
396