@wardic/solid 1.1.2 → 1.1.3

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 (144) hide show
  1. package/dist/browser/batch-reorder-group.js +2 -5
  2. package/dist/browser/batch-reorder-group.js.map +1 -1
  3. package/dist/browser/batch-reorder.js +4 -15
  4. package/dist/browser/batch-reorder.js.map +1 -1
  5. package/dist/browser/create-ward.js +6 -15
  6. package/dist/browser/create-ward.js.map +1 -1
  7. package/dist/browser/create-wardic.js +1 -1
  8. package/dist/browser/create-wardic.js.map +1 -1
  9. package/dist/browser/gesture-callbacks.js +11 -164
  10. package/dist/browser/gesture-callbacks.js.map +1 -1
  11. package/dist/browser/index.js +1 -1
  12. package/dist/browser/provider.js +1 -5
  13. package/dist/browser/provider.js.map +1 -1
  14. package/dist/browser/reorder.js +8 -22
  15. package/dist/browser/reorder.js.map +1 -1
  16. package/dist/browser/unstable/v2/batch-reorder-group.js +2 -5
  17. package/dist/browser/unstable/v2/batch-reorder-group.js.map +1 -1
  18. package/dist/browser/unstable/v2/bridge.js +5 -3
  19. package/dist/browser/unstable/v2/bridge.js.map +1 -1
  20. package/dist/browser/unstable/v2/create-wardic.js +1 -1
  21. package/dist/browser/unstable/v2/create-wardic.js.map +1 -1
  22. package/dist/browser/unstable/v2/flights.js +7 -4
  23. package/dist/browser/unstable/v2/flights.js.map +1 -1
  24. package/dist/browser/unstable/v2/provider.js +2 -6
  25. package/dist/browser/unstable/v2/provider.js.map +1 -1
  26. package/dist/browser/unstable/v2/reorder.js +3 -6
  27. package/dist/browser/unstable/v2/reorder.js.map +1 -1
  28. package/dist/browser/unstable/v2/solid-reactivity.js +10 -1
  29. package/dist/browser/unstable/v2/solid-reactivity.js.map +1 -1
  30. package/dist/browser/unstable/v2/ward.js +25 -10
  31. package/dist/browser/unstable/v2/ward.js.map +1 -1
  32. package/dist/server/batch-reorder-group.js +2 -5
  33. package/dist/server/batch-reorder-group.js.map +1 -1
  34. package/dist/server/batch-reorder.js +4 -15
  35. package/dist/server/batch-reorder.js.map +1 -1
  36. package/dist/server/create-ward.js +6 -15
  37. package/dist/server/create-ward.js.map +1 -1
  38. package/dist/server/create-wardic.js +1 -1
  39. package/dist/server/create-wardic.js.map +1 -1
  40. package/dist/server/gesture-callbacks.js +11 -164
  41. package/dist/server/gesture-callbacks.js.map +1 -1
  42. package/dist/server/index.js +1 -1
  43. package/dist/server/provider.js +1 -5
  44. package/dist/server/provider.js.map +1 -1
  45. package/dist/server/reorder.js +8 -22
  46. package/dist/server/reorder.js.map +1 -1
  47. package/dist/server/unstable/v2/batch-reorder-group.js +2 -5
  48. package/dist/server/unstable/v2/batch-reorder-group.js.map +1 -1
  49. package/dist/server/unstable/v2/bridge.js +5 -3
  50. package/dist/server/unstable/v2/bridge.js.map +1 -1
  51. package/dist/server/unstable/v2/create-wardic.js +1 -1
  52. package/dist/server/unstable/v2/create-wardic.js.map +1 -1
  53. package/dist/server/unstable/v2/flights.js +7 -4
  54. package/dist/server/unstable/v2/flights.js.map +1 -1
  55. package/dist/server/unstable/v2/provider.js +2 -6
  56. package/dist/server/unstable/v2/provider.js.map +1 -1
  57. package/dist/server/unstable/v2/reorder.js +3 -6
  58. package/dist/server/unstable/v2/reorder.js.map +1 -1
  59. package/dist/server/unstable/v2/solid-reactivity.js +10 -1
  60. package/dist/server/unstable/v2/solid-reactivity.js.map +1 -1
  61. package/dist/server/unstable/v2/ward.js +25 -10
  62. package/dist/server/unstable/v2/ward.js.map +1 -1
  63. package/dist/solid/batch-reorder-group.jsx +2 -2
  64. package/dist/solid/batch-reorder-group.jsx.map +1 -1
  65. package/dist/solid/batch-reorder.d.ts +1 -4
  66. package/dist/solid/batch-reorder.d.ts.map +1 -1
  67. package/dist/solid/batch-reorder.js +4 -9
  68. package/dist/solid/batch-reorder.js.map +1 -1
  69. package/dist/solid/create-ward.d.ts.map +1 -1
  70. package/dist/solid/create-ward.jsx +6 -15
  71. package/dist/solid/create-ward.jsx.map +1 -1
  72. package/dist/solid/create-wardic.jsx +1 -1
  73. package/dist/solid/create-wardic.jsx.map +1 -1
  74. package/dist/solid/gesture-callbacks.d.ts +10 -37
  75. package/dist/solid/gesture-callbacks.d.ts.map +1 -1
  76. package/dist/solid/gesture-callbacks.js +11 -178
  77. package/dist/solid/gesture-callbacks.js.map +1 -1
  78. package/dist/solid/index.d.ts +1 -1
  79. package/dist/solid/index.jsx +1 -1
  80. package/dist/solid/provider.d.ts.map +1 -1
  81. package/dist/solid/provider.jsx +1 -5
  82. package/dist/solid/provider.jsx.map +1 -1
  83. package/dist/solid/reorder.d.ts.map +1 -1
  84. package/dist/solid/reorder.jsx +7 -15
  85. package/dist/solid/reorder.jsx.map +1 -1
  86. package/dist/solid/unstable/v2/batch-reorder-group.jsx +2 -2
  87. package/dist/solid/unstable/v2/batch-reorder-group.jsx.map +1 -1
  88. package/dist/solid/unstable/v2/bridge.d.ts +4 -2
  89. package/dist/solid/unstable/v2/bridge.d.ts.map +1 -1
  90. package/dist/solid/unstable/v2/bridge.jsx +5 -3
  91. package/dist/solid/unstable/v2/bridge.jsx.map +1 -1
  92. package/dist/solid/unstable/v2/create-wardic.jsx +1 -1
  93. package/dist/solid/unstable/v2/create-wardic.jsx.map +1 -1
  94. package/dist/solid/unstable/v2/flights.d.ts +5 -2
  95. package/dist/solid/unstable/v2/flights.d.ts.map +1 -1
  96. package/dist/solid/unstable/v2/flights.js +7 -4
  97. package/dist/solid/unstable/v2/flights.js.map +1 -1
  98. package/dist/solid/unstable/v2/provider.d.ts.map +1 -1
  99. package/dist/solid/unstable/v2/provider.jsx +2 -4
  100. package/dist/solid/unstable/v2/provider.jsx.map +1 -1
  101. package/dist/solid/unstable/v2/reorder.jsx +3 -3
  102. package/dist/solid/unstable/v2/reorder.jsx.map +1 -1
  103. package/dist/solid/unstable/v2/solid-reactivity.d.ts +7 -0
  104. package/dist/solid/unstable/v2/solid-reactivity.d.ts.map +1 -1
  105. package/dist/solid/unstable/v2/solid-reactivity.js +10 -1
  106. package/dist/solid/unstable/v2/solid-reactivity.js.map +1 -1
  107. package/dist/solid/unstable/v2/ward.d.ts.map +1 -1
  108. package/dist/solid/unstable/v2/ward.jsx +26 -10
  109. package/dist/solid/unstable/v2/ward.jsx.map +1 -1
  110. package/package.json +11 -11
  111. package/src/batch-reorder-group.tsx +2 -2
  112. package/src/batch-reorder.ts +4 -10
  113. package/src/create-ward.tsx +6 -16
  114. package/src/create-wardic.tsx +1 -1
  115. package/src/gesture-callbacks.ts +21 -190
  116. package/src/index.tsx +1 -1
  117. package/src/provider.tsx +1 -5
  118. package/src/reorder.tsx +7 -19
  119. package/src/unstable/v2/batch-reorder-group.tsx +2 -2
  120. package/src/unstable/v2/bridge.tsx +5 -3
  121. package/src/unstable/v2/create-wardic.tsx +1 -1
  122. package/src/unstable/v2/flights.ts +8 -5
  123. package/src/unstable/v2/provider.tsx +2 -3
  124. package/src/unstable/v2/reorder.tsx +3 -3
  125. package/src/unstable/v2/solid-reactivity.ts +12 -1
  126. package/src/unstable/v2/ward.tsx +25 -10
  127. package/dist/browser/instance-features.js +0 -66
  128. package/dist/browser/instance-features.js.map +0 -1
  129. package/dist/browser/reorder-input.js +0 -117
  130. package/dist/browser/reorder-input.js.map +0 -1
  131. package/dist/server/instance-features.js +0 -66
  132. package/dist/server/instance-features.js.map +0 -1
  133. package/dist/server/reorder-input.js +0 -117
  134. package/dist/server/reorder-input.js.map +0 -1
  135. package/dist/solid/instance-features.d.ts +0 -7
  136. package/dist/solid/instance-features.d.ts.map +0 -1
  137. package/dist/solid/instance-features.js +0 -63
  138. package/dist/solid/instance-features.js.map +0 -1
  139. package/dist/solid/reorder-input.d.ts +0 -43
  140. package/dist/solid/reorder-input.d.ts.map +0 -1
  141. package/dist/solid/reorder-input.js +0 -113
  142. package/dist/solid/reorder-input.js.map +0 -1
  143. package/src/instance-features.ts +0 -76
  144. package/src/reorder-input.ts +0 -140
@@ -1,113 +0,0 @@
1
- /**
2
- * A Reorder item's input (ADR-0037), Solid-free (#379): its keys, blurs and presses told to its driver
3
- * by watches while a Scope is open, each inside its event, with no fiber at rest. Both bindings run it
4
- * in the item's watch Scope (ADR-0055, *Amendment (#379)*). A Batch Reorder group's items (#712) are
5
- * heard through the feeds over them instead, with no listener per item at rest.
6
- *
7
- * @module
8
- */
9
- import * as InputFeed from "@wardic/core/InputFeed";
10
- import * as InputSource from "@wardic/core/InputSource";
11
- import * as Report from "@wardic/dom/Report";
12
- import * as Bool from "effect/Boolean";
13
- import * as Effect from "effect/Effect";
14
- import * as Iter from "effect/Iterable";
15
- import * as Predicate from "effect/Predicate";
16
- import * as UndefinedOr from "effect/UndefinedOr";
17
- /** A Primary pointer's down: a press the driver hears. */
18
- const isPress = (event) => Bool.and(event.type === "down", InputSource.isPrimaryPointer(event));
19
- /**
20
- * Watch an item's keys, blurs and presses for its driver (ADR-0037, #379) while the Scope is open: its
21
- * keys inside their dispatch, so the reorder's `handle()` (the page's `preventDefault`) counts. A blur
22
- * is judged after this task's own work, one scheduler hop on (#318): a reorder can blur the node it
23
- * moves and puts focus back after (the driver's `keepFocus`). So `fork` runs that hop on the provider
24
- * runtime, only when a blur happens, and a blur whose judging fails is reported. A throw from the
25
- * driver inside an event goes to `onDefect`.
26
- */
27
- export const watchItemInput = (el, driver, fork, onDefect) => {
28
- const judgeBlur = judgedBlurOf(driver);
29
- return Effect.gen(function* () {
30
- const input = yield* InputSource.InputSource;
31
- yield* InputFeed.watch(input.keyboard(el), { on: (event) => driver.onKey(event), onDefect });
32
- yield* InputFeed.watch(input.focus(el), {
33
- on: (event) => {
34
- // The item's own blur: one inside it (#439) leaves it focused.
35
- if (Bool.and(event.type === "blur", event.fromTarget !== false))
36
- fork(judgeBlur);
37
- },
38
- onDefect,
39
- });
40
- yield* InputFeed.watch(input.pointer(el), {
41
- on: (event) => {
42
- if (isPress(event))
43
- driver.onPress();
44
- },
45
- onDefect,
46
- });
47
- });
48
- };
49
- /** A blur judged after this task's own work, one scheduler hop on (#318); a judging that fails reported. */
50
- const judgedBlurOf = (driver) => Effect.andThen(Effect.yieldNow, Effect.sync(() => driver.onBlur())).pipe(Effect.catchCause((cause) => Report.failure("wardic.reorder: judging an item's blur failed", cause)));
51
- /** An InputSource's feed over many targets, or a defect naming it. */
52
- const amongOf = (feed, name) => UndefinedOr.match(feed, {
53
- onUndefined: () => Effect.die(new Error(`wardic.reorder: the Environment's InputSource has no \`${name}\`, which a Batch Reorder group's items need`)),
54
- onDefined: Effect.succeed,
55
- });
56
- /** A Primary pointer's release or cancel: a press's end the group hears. */
57
- const isPressEnd = (event) => Bool.and(Bool.or(event.type === "up", event.type === "cancel"), InputSource.isPrimaryPointer(event));
58
- /**
59
- * Watch a Batch Reorder group's items' keys, blurs and presses (#712, ADR-0072 decision 7, Q28) while the
60
- * Scope is open, through the feeds over them: focus heard by `focusAmong`, and a focused item's own keys
61
- * from its focus to its blur, as a Batch's press watch holds them (#460); presses by `pointerAmong`. So at
62
- * rest no item listens. `memberOf` names the item a node is. Blurs are judged as {@link watchItemInput}'s are.
63
- */
64
- export const watchItemsInputAmong = Effect.fnUntraced(function* (memberOf, handlers) {
65
- const input = yield* InputSource.InputSource;
66
- const focusAmong = yield* amongOf(input.focusAmong, "focusAmong");
67
- const pointerAmong = yield* amongOf(input.pointerAmong, "pointerAmong");
68
- const { driverOf, onDefect } = handlers;
69
- // The focused items' keys, each open from its focus to its blur.
70
- const focusedKeys = new Map();
71
- const closeKeys = (target) => {
72
- UndefinedOr.map(focusedKeys.get(target), (keysNow) => keysNow.close());
73
- focusedKeys.delete(target);
74
- };
75
- const openKeys = (target) => {
76
- if (focusedKeys.has(target))
77
- return;
78
- const driver = driverOf(target);
79
- if (Predicate.isUndefined(driver))
80
- return;
81
- const keysNow = InputFeed.switched(input.keyboard(target), (event) => driver.onKey(event), onDefect);
82
- focusedKeys.set(target, keysNow);
83
- keysNow.open();
84
- };
85
- yield* Effect.addFinalizer(() => Effect.sync(() => {
86
- Iter.forEach(focusedKeys.values(), (keysNow) => keysNow.close());
87
- focusedKeys.clear();
88
- }));
89
- yield* InputFeed.watch(focusAmong(memberOf), {
90
- on: ({ target, event }) => {
91
- if (event.type === "focus")
92
- return openKeys(target);
93
- closeKeys(target);
94
- // The item's own blur: one inside it (#439) leaves it focused.
95
- if (event.fromTarget === false)
96
- return;
97
- UndefinedOr.map(driverOf(target), (driver) => handlers.fork(judgedBlurOf(driver)));
98
- },
99
- onDefect,
100
- });
101
- yield* InputFeed.watch(pointerAmong(memberOf), {
102
- on: ({ target, event }) => {
103
- if (isPressEnd(event))
104
- return handlers.onPressEnd(target);
105
- if (Bool.not(isPress(event)))
106
- return;
107
- UndefinedOr.map(driverOf(target), (driver) => driver.onPress());
108
- handlers.onPress(target);
109
- },
110
- onDefect,
111
- });
112
- });
113
- //# sourceMappingURL=reorder-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reorder-input.js","sourceRoot":"","sources":["../../src/reorder-input.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AAEvD,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAEvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AAEjD,0DAA0D;AAC1D,MAAM,OAAO,GAAG,CAAC,KAAmC,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAA;AAEtI;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,EA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AAK,OAAO;gBAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAA;YACnD,SAAS,CAAC,MAAM,CAAC,CAAA;YACjB,+DAA+D;YAC/D,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK;gBAAE,OAAM;YACtC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACpF,CAAC;QACD,QAAQ;KACT,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;QAC7C,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;YACxB,IAAI,UAAU,CAAC,KAAK,CAAC;gBAAE,OAAO,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;YACzD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAAE,OAAM;YACpC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;YAC/D,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC1B,CAAC;QACD,QAAQ;KACT,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,76 +0,0 @@
1
- /**
2
- * A **Wardic instance**'s Features (#516, ADR-0067 *Amendment (#516)*), for both bindings: what
3
- * `createWardic` splits its list into, and what its elements and hooks take in each provider. In a module
4
- * that only `createWardic` imports, apart from the spine every page shares, so an app with no Wardic
5
- * instance ships none of it (ADR-0067, *Amendment (#548)*).
6
- *
7
- * @module
8
- */
9
- import * as Arr from "effect/Array"
10
- import * as Bool from "effect/Boolean"
11
- import type * as Cause from "effect/Cause"
12
- import { constVoid, identity } from "effect/Function"
13
- import * as Predicate from "effect/Predicate"
14
- import * as UndefinedOr from "effect/UndefinedOr"
15
- import * as Feature from "@wardic/dom/unstable/Feature"
16
-
17
- /**
18
- * `prop`'s Features (#516): those given at once, flattened, each once, and its loads, each started once,
19
- * the first time any provider asks, so one module's Wardic instance loads each once.
20
- */
21
- export const instanceFeaturesOf = (prop: Feature.InstanceFeaturesProp): Feature.InstanceFeatures => {
22
- const leaves = leavesOf(prop)
23
- const given = Arr.dedupeWith(Arr.filter(leaves, isFeature), (a, b) => a === b)
24
- const loads = Arr.map(Arr.filter(leaves, isLoad), once)
25
- const owns = new WeakMap<Feature.FeatureRegistry, Feature.Own>()
26
- return {
27
- own: (registry, host) =>
28
- UndefinedOr.match(owns.get(registry), {
29
- onDefined: identity,
30
- onUndefined: () => {
31
- const own = ownIn(registry.build, given, loads, host.report, { reactivity: host.reactivity, server: host.server, onCleanup: registry.onEnd })
32
- owns.set(registry, own)
33
- return own
34
- },
35
- }),
36
- }
37
- }
38
-
39
- /** `prop`'s Features and loads, every list flattened. */
40
- const leavesOf = (prop: Feature.InstanceFeaturesProp): ReadonlyArray<Feature.Feature | Feature.FeatureLoad> =>
41
- Bool.match(Array.isArray(prop), {
42
- onTrue: () => Arr.flatMap(prop as ReadonlyArray<Feature.InstanceFeaturesProp>, leavesOf),
43
- onFalse: () => [prop as Feature.Feature | Feature.FeatureLoad],
44
- })
45
-
46
- const isFeature = (leaf: Feature.Feature | Feature.FeatureLoad): leaf is Feature.Feature => Predicate.hasProperty(leaf, "layer")
47
-
48
- const isLoad = (leaf: Feature.Feature | Feature.FeatureLoad): leaf is Feature.FeatureLoad => Predicate.isFunction(leaf)
49
-
50
- /**
51
- * `load`, started at its first call, its promise kept for every call after. A failed load is forgotten,
52
- * so the next provider to ask loads again, as a new `LazyWardic` does.
53
- */
54
- const once = (load: Feature.FeatureLoad): Feature.FeatureLoad => {
55
- let started: Promise<Feature.Features> | undefined
56
- return () =>
57
- UndefinedOr.match(started, {
58
- onDefined: identity,
59
- onUndefined: () => {
60
- const loading = load()
61
- started = loading
62
- loading.then(constVoid, () => {
63
- if (started === loading) started = undefined
64
- })
65
- return loading
66
- },
67
- })
68
- }
69
-
70
- /** A Wardic instance's Features in one provider: those given at once, and each load's, joined. */
71
- const ownIn = (build: Feature.Build, given: ReadonlyArray<Feature.Feature>, loads: ReadonlyArray<Feature.FeatureLoad>, report: (cause: Cause.Cause<unknown>) => void, host: Feature.SectionHost): Feature.Own =>
72
- Arr.reduce(
73
- Arr.map(loads, (load) => Feature.ownOf(build, load, report, host)),
74
- Feature.ownOf(build, given, report, host),
75
- Feature.joinOwns,
76
- )
@@ -1,140 +0,0 @@
1
- /**
2
- * A Reorder item's input (ADR-0037), Solid-free (#379): its keys, blurs and presses told to its driver
3
- * by watches while a Scope is open, each inside its event, with no fiber at rest. Both bindings run it
4
- * in the item's watch Scope (ADR-0055, *Amendment (#379)*). A Batch Reorder group's items (#712) are
5
- * heard through the feeds over them instead, with no listener per item at rest.
6
- *
7
- * @module
8
- */
9
- import * as InputFeed from "@wardic/core/InputFeed"
10
- import * as InputSource from "@wardic/core/InputSource"
11
- import type * as ReorderController from "@wardic/dom/ReorderController"
12
- import * as Report from "@wardic/dom/Report"
13
- import * as Bool from "effect/Boolean"
14
- import * as Effect from "effect/Effect"
15
- import * as Iter from "effect/Iterable"
16
- import type * as Option from "effect/Option"
17
- import * as Predicate from "effect/Predicate"
18
- import type * as Scope from "effect/Scope"
19
- import * as UndefinedOr from "effect/UndefinedOr"
20
-
21
- /** A Primary pointer's down: a press the driver hears. */
22
- const isPress = (event: InputSource.PointerLikeEvent): boolean => Bool.and(event.type === "down", InputSource.isPrimaryPointer(event))
23
-
24
- /**
25
- * Watch an item's keys, blurs and presses for its driver (ADR-0037, #379) while the Scope is open: its
26
- * keys inside their dispatch, so the reorder's `handle()` (the page's `preventDefault`) counts. A blur
27
- * is judged after this task's own work, one scheduler hop on (#318): a reorder can blur the node it
28
- * moves and puts focus back after (the driver's `keepFocus`). So `fork` runs that hop on the provider
29
- * runtime, only when a blur happens, and a blur whose judging fails is reported. A throw from the
30
- * driver inside an event goes to `onDefect`.
31
- */
32
- export const watchItemInput = (
33
- el: HTMLElement,
34
- driver: ReorderController.ItemDriver,
35
- fork: (effect: Effect.Effect<void>) => void,
36
- onDefect: InputFeed.OnDefect,
37
- ): Effect.Effect<void, never, Scope.Scope | InputSource.InputSource> => {
38
- const judgeBlur = judgedBlurOf(driver)
39
- return Effect.gen(function* () {
40
- const input = yield* InputSource.InputSource
41
- yield* InputFeed.watch(input.keyboard(el), { on: (event) => driver.onKey(event), onDefect })
42
- yield* InputFeed.watch(input.focus(el), {
43
- on: (event) => {
44
- // The item's own blur: one inside it (#439) leaves it focused.
45
- if (Bool.and(event.type === "blur", event.fromTarget !== false)) fork(judgeBlur)
46
- },
47
- onDefect,
48
- })
49
- yield* InputFeed.watch(input.pointer(el), {
50
- on: (event) => {
51
- if (isPress(event)) driver.onPress()
52
- },
53
- onDefect,
54
- })
55
- })
56
- }
57
-
58
- /** A blur judged after this task's own work, one scheduler hop on (#318); a judging that fails reported. */
59
- const judgedBlurOf = (driver: ReorderController.ItemDriver): Effect.Effect<void> =>
60
- Effect.andThen(Effect.yieldNow, Effect.sync(() => driver.onBlur())).pipe(
61
- Effect.catchCause((cause) => Report.failure("wardic.reorder: judging an item's blur failed", cause)),
62
- )
63
-
64
- /** An InputSource's feed over many targets, or a defect naming it. */
65
- const amongOf = <A>(feed: A | undefined, name: string): Effect.Effect<A> =>
66
- UndefinedOr.match(feed, {
67
- onUndefined: () => Effect.die(new Error(`wardic.reorder: the Environment's InputSource has no \`${name}\`, which a Batch Reorder group's items need`)),
68
- onDefined: Effect.succeed,
69
- })
70
-
71
- /** What a Batch Reorder group's items' input is told to: each item's driver, and its presses (#712). */
72
- export interface ItemsInputHandlers {
73
- /** The driver of the item a target is, `undefined` for an item gone. */
74
- readonly driverOf: (target: unknown) => ReorderController.ItemDriver | undefined
75
- /** A Primary pointer went down on an item, after its driver heard it: the group's grab. */
76
- readonly onPress: (target: unknown) => void
77
- /** That press ended, released or cancelled, wherever it was. */
78
- readonly onPressEnd: (target: unknown) => void
79
- /** Runs a blur's judging, one scheduler hop on. */
80
- readonly fork: (effect: Effect.Effect<void>) => void
81
- readonly onDefect: InputFeed.OnDefect
82
- }
83
-
84
- /** A Primary pointer's release or cancel: a press's end the group hears. */
85
- const isPressEnd = (event: InputSource.PointerLikeEvent): boolean => Bool.and(Bool.or(event.type === "up", event.type === "cancel"), InputSource.isPrimaryPointer(event))
86
-
87
- /**
88
- * Watch a Batch Reorder group's items' keys, blurs and presses (#712, ADR-0072 decision 7, Q28) while the
89
- * Scope is open, through the feeds over them: focus heard by `focusAmong`, and a focused item's own keys
90
- * from its focus to its blur, as a Batch's press watch holds them (#460); presses by `pointerAmong`. So at
91
- * rest no item listens. `memberOf` names the item a node is. Blurs are judged as {@link watchItemInput}'s are.
92
- */
93
- export const watchItemsInputAmong: (
94
- memberOf: (node: unknown) => Option.Option<unknown>,
95
- handlers: ItemsInputHandlers,
96
- ) => Effect.Effect<void, never, Scope.Scope | InputSource.InputSource> = Effect.fnUntraced(function* (memberOf: (node: unknown) => Option.Option<unknown>, handlers: ItemsInputHandlers) {
97
- const input = yield* InputSource.InputSource
98
- const focusAmong = yield* amongOf(input.focusAmong, "focusAmong")
99
- const pointerAmong = yield* amongOf(input.pointerAmong, "pointerAmong")
100
- const { driverOf, onDefect } = handlers
101
- // The focused items' keys, each open from its focus to its blur.
102
- const focusedKeys = new Map<unknown, InputFeed.Switch>()
103
- const closeKeys = (target: unknown): void => {
104
- UndefinedOr.map(focusedKeys.get(target), (keysNow) => keysNow.close())
105
- focusedKeys.delete(target)
106
- }
107
- const openKeys = (target: unknown): void => {
108
- if (focusedKeys.has(target)) return
109
- const driver = driverOf(target)
110
- if (Predicate.isUndefined(driver)) return
111
- const keysNow = InputFeed.switched(input.keyboard(target), (event) => driver.onKey(event), onDefect)
112
- focusedKeys.set(target, keysNow)
113
- keysNow.open()
114
- }
115
- yield* Effect.addFinalizer(() =>
116
- Effect.sync(() => {
117
- Iter.forEach(focusedKeys.values(), (keysNow) => keysNow.close())
118
- focusedKeys.clear()
119
- })
120
- )
121
- yield* InputFeed.watch(focusAmong(memberOf), {
122
- on: ({ target, event }) => {
123
- if (event.type === "focus") return openKeys(target)
124
- closeKeys(target)
125
- // The item's own blur: one inside it (#439) leaves it focused.
126
- if (event.fromTarget === false) return
127
- UndefinedOr.map(driverOf(target), (driver) => handlers.fork(judgedBlurOf(driver)))
128
- },
129
- onDefect,
130
- })
131
- yield* InputFeed.watch(pointerAmong(memberOf), {
132
- on: ({ target, event }) => {
133
- if (isPressEnd(event)) return handlers.onPressEnd(target)
134
- if (Bool.not(isPress(event))) return
135
- UndefinedOr.map(driverOf(target), (driver) => driver.onPress())
136
- handlers.onPress(target)
137
- },
138
- onDefect,
139
- })
140
- })