solid-ctrl-flow 7.0.0 → 7.0.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.
package/dist/index.d.ts CHANGED
@@ -230,6 +230,21 @@ declare class State {
230
230
  /** Type of an element wrapping call-back which accepts an additional parameter */
231
231
  declare type Template<T> = (c: Accessor<JSX.Element>, x: T) => JSX.Element;
232
232
 
233
+ /** Object that reactively tells whether a CSS transition is currently in progress */
234
+ export declare class TransitionMonitor {
235
+ #private;
236
+ /** Whether a transition is currently in progress */
237
+ get pending(): boolean;
238
+ /**
239
+ * Starts waiting for the transition to end.
240
+ * This function should be called immediately before the transition is triggered.
241
+ * If a transition is already in progress, this function does nothing, allowing the object to keep monitoring the previous transition, but the returned {@link Promise} will not wait for the latter to complete
242
+ * @param ctrl The element on which the transition will occur
243
+ * @returns A {@link Promise} that resolves to whether monitoring completed successfully or was cancelled because a transition was already in progress
244
+ */
245
+ start(ctrl: HTMLElement): Promise<boolean>;
246
+ }
247
+
233
248
  /** Parameters to pass to an unkeyed {@link Enfold} */
234
249
  declare type Unkeyed<T> = Standard<T> & {
235
250
  keyed?: false;
package/dist/index.mjs CHANGED
@@ -285,6 +285,32 @@ class MemoPropsHandler {
285
285
  return runWithOwner(this.owner, () => createMemo(() => t[k], void 0, opts));
286
286
  }
287
287
  }
288
+ class TransitionMonitor {
289
+ #signal = createSignal(false);
290
+ /** Whether a transition is currently in progress */
291
+ get pending() {
292
+ return this.#signal[0]();
293
+ }
294
+ /**
295
+ * Starts waiting for the transition to end.
296
+ * This function should be called immediately before the transition is triggered.
297
+ * If a transition is already in progress, this function does nothing, allowing the object to keep monitoring the previous transition, but the returned {@link Promise} will not wait for the latter to complete
298
+ * @param ctrl The element on which the transition will occur
299
+ * @returns A {@link Promise} that resolves to whether monitoring completed successfully or was cancelled because a transition was already in progress
300
+ */
301
+ async start(ctrl) {
302
+ const [g, s] = this.#signal;
303
+ if (g())
304
+ return false;
305
+ s(true);
306
+ try {
307
+ await new Promise((t) => ctrl.addEventListener("transitionend", t, { once: true }));
308
+ } finally {
309
+ s(false);
310
+ }
311
+ return true;
312
+ }
313
+ }
288
314
  function SameContext(props) {
289
315
  return createMemo(() => {
290
316
  getOwner().context = props.owner.context;
@@ -304,6 +330,7 @@ export {
304
330
  OrderedLinkedList,
305
331
  SameContext,
306
332
  Spread,
333
+ TransitionMonitor,
307
334
  disposeWithOwner,
308
335
  memoProps,
309
336
  runWithContext,
package/dist/index.umd.js CHANGED
@@ -287,6 +287,32 @@
287
287
  return solidJs.runWithOwner(this.owner, () => solidJs.createMemo(() => t[k], void 0, opts));
288
288
  }
289
289
  }
290
+ class TransitionMonitor {
291
+ #signal = solidJs.createSignal(false);
292
+ /** Whether a transition is currently in progress */
293
+ get pending() {
294
+ return this.#signal[0]();
295
+ }
296
+ /**
297
+ * Starts waiting for the transition to end.
298
+ * This function should be called immediately before the transition is triggered.
299
+ * If a transition is already in progress, this function does nothing, allowing the object to keep monitoring the previous transition, but the returned {@link Promise} will not wait for the latter to complete
300
+ * @param ctrl The element on which the transition will occur
301
+ * @returns A {@link Promise} that resolves to whether monitoring completed successfully or was cancelled because a transition was already in progress
302
+ */
303
+ async start(ctrl) {
304
+ const [g, s] = this.#signal;
305
+ if (g())
306
+ return false;
307
+ s(true);
308
+ try {
309
+ await new Promise((t) => ctrl.addEventListener("transitionend", t, { once: true }));
310
+ } finally {
311
+ s(false);
312
+ }
313
+ return true;
314
+ }
315
+ }
290
316
  function SameContext(props) {
291
317
  return solidJs.createMemo(() => {
292
318
  solidJs.getOwner().context = props.owner.context;
@@ -305,6 +331,7 @@
305
331
  exports2.OrderedLinkedList = OrderedLinkedList;
306
332
  exports2.SameContext = SameContext;
307
333
  exports2.Spread = Spread;
334
+ exports2.TransitionMonitor = TransitionMonitor;
308
335
  exports2.disposeWithOwner = disposeWithOwner;
309
336
  exports2.memoProps = memoProps;
310
337
  exports2.runWithContext = runWithContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",