@khanacademy/wonder-blocks-timing 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +26 -6
  2. package/dist/components/action-scheduler-provider.d.ts +26 -0
  3. package/dist/components/action-scheduler-provider.js.flow +35 -0
  4. package/dist/components/with-action-scheduler.d.ts +14 -0
  5. package/dist/components/with-action-scheduler.js.flow +26 -0
  6. package/dist/es/index.js +165 -380
  7. package/dist/hooks/internal/use-updating-ref.d.ts +13 -0
  8. package/dist/hooks/internal/use-updating-ref.js.flow +22 -0
  9. package/dist/hooks/use-interval.d.ts +8 -0
  10. package/dist/hooks/use-interval.js.flow +18 -0
  11. package/dist/hooks/use-scheduled-interval.d.ts +2 -0
  12. package/dist/hooks/use-scheduled-interval.js.flow +13 -0
  13. package/dist/hooks/use-scheduled-timeout.d.ts +2 -0
  14. package/dist/hooks/use-scheduled-timeout.js.flow +13 -0
  15. package/dist/hooks/use-timeout.d.ts +8 -0
  16. package/dist/hooks/use-timeout.js.flow +18 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +335 -778
  19. package/dist/index.js.flow +31 -2
  20. package/dist/util/action-scheduler.d.ts +21 -0
  21. package/dist/util/action-scheduler.js.flow +39 -0
  22. package/dist/util/animation-frame.d.ts +62 -0
  23. package/dist/util/animation-frame.js.flow +71 -0
  24. package/dist/util/interval.d.ts +60 -0
  25. package/dist/util/interval.js.flow +70 -0
  26. package/dist/util/policies.d.ts +8 -0
  27. package/dist/util/policies.js.flow +17 -0
  28. package/dist/util/timeout.d.ts +62 -0
  29. package/dist/util/timeout.js.flow +72 -0
  30. package/dist/util/types.d.ts +228 -0
  31. package/dist/util/types.js.flow +235 -0
  32. package/dist/util/types.typestest.d.ts +1 -0
  33. package/dist/util/types.typestest.js.flow +6 -0
  34. package/package.json +3 -3
  35. package/src/__docs__/_overview_.stories.mdx +17 -0
  36. package/src/components/__tests__/{action-scheduler-provider.test.js → action-scheduler-provider.test.tsx} +7 -10
  37. package/src/components/__tests__/{with-action-scheduler.test.js → with-action-scheduler.test.tsx} +11 -12
  38. package/src/components/{action-scheduler-provider.js → action-scheduler-provider.ts} +6 -7
  39. package/src/components/{with-action-scheduler.js → with-action-scheduler.tsx} +11 -19
  40. package/src/hooks/__tests__/{use-interval.test.js → use-interval.test.ts} +6 -7
  41. package/src/hooks/__tests__/{use-scheduled-interval.test.js → use-scheduled-interval.test.ts} +15 -8
  42. package/src/hooks/__tests__/{use-scheduled-timeout.test.js → use-scheduled-timeout.test.ts} +22 -13
  43. package/src/hooks/__tests__/{use-timeout.test.js → use-timeout.test.ts} +6 -7
  44. package/src/hooks/internal/{use-updating-ref.js → use-updating-ref.ts} +5 -2
  45. package/src/hooks/{use-interval.js → use-interval.ts} +2 -3
  46. package/src/hooks/{use-scheduled-interval.js → use-scheduled-interval.ts} +6 -6
  47. package/src/hooks/{use-scheduled-timeout.js → use-scheduled-timeout.ts} +6 -6
  48. package/src/hooks/{use-timeout.js → use-timeout.ts} +2 -3
  49. package/src/{index.js → index.ts} +7 -8
  50. package/src/util/__tests__/{action-scheduler.test.js → action-scheduler.test.ts} +14 -24
  51. package/src/util/__tests__/{animation-frame.test.js → animation-frame.test.ts} +10 -9
  52. package/src/util/__tests__/{interval.test.js → interval.test.ts} +3 -4
  53. package/src/util/__tests__/{timeout.test.js → timeout.test.ts} +3 -4
  54. package/src/util/{action-scheduler.js → action-scheduler.ts} +17 -10
  55. package/src/util/{animation-frame.js → animation-frame.ts} +6 -6
  56. package/src/util/{interval.js → interval.ts} +7 -6
  57. package/src/util/{policies.js → policies.ts} +2 -3
  58. package/src/util/{timeout.js → timeout.ts} +7 -6
  59. package/src/util/{types.js → types.ts} +21 -28
  60. package/src/util/{types.flowtest.js → types.typestest.tsx} +22 -20
  61. package/tsconfig.json +11 -0
  62. package/tsconfig.tsbuildinfo +1 -0
  63. package/docs.md +0 -406
  64. package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -353
  65. package/src/__tests__/generated-snapshot.test.js +0 -155
  66. package/src/components/with-action-scheduler.md +0 -18
  67. package/src/hooks/use-interval.stories.mdx +0 -80
  68. package/src/hooks/use-scheduled-interval.stories.mdx +0 -147
  69. package/src/hooks/use-scheduled-timeout.stories.mdx +0 -148
  70. package/src/hooks/use-timeout.stories.mdx +0 -80
package/CHANGELOG.md CHANGED
@@ -1,11 +1,31 @@
1
1
  # @khanacademy/wonder-blocks-timing
2
2
 
3
+ ## 2.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d816af08: Update build and test configs use TypeScript
8
+ - 3891f544: Update babel config to include plugins that Storybook needed
9
+ - 0d28bb1c: Configured TypeScript
10
+ - 3d05f764: Fix HOCs and other type errors
11
+ - c2ec4902: Update eslint configuration, fix lint
12
+ - 2983c05b: Include 'types' field in package.json
13
+ - 77ff6a66: Generate Flow types from TypeScript types
14
+ - ec8d4b7f: Fix miscellaneous TypeScript errors
15
+
16
+ ## 2.1.1
17
+
18
+ ### Patch Changes
19
+
20
+ - 91cb727c: Remove file extensions from imports
21
+
3
22
  ## 2.1.0
23
+
4
24
  ### Minor Changes
5
25
 
6
- - 029b4810: Adds `useInterval()` hook that mimics the behavior of `ActionScheduler`'s
7
- `interval()` method.
8
- - c57cd770: Rename `useInterval` and `useTimeout` to `useScheduledInterval`
9
- and `useScheduledTimeout` respectively.
10
- - 29766c8e: Add `useInterval` and `useTimeout` hooks to provide a simple API for
11
- using intervals and timeouts.
26
+ - 029b4810: Adds `useInterval()` hook that mimics the behavior of `ActionScheduler`'s
27
+ `interval()` method.
28
+ - c57cd770: Rename `useInterval` and `useTimeout` to `useScheduledInterval`
29
+ and `useScheduledTimeout` respectively.
30
+ - 29766c8e: Add `useInterval` and `useTimeout` hooks to provide an API for
31
+ using intervals and timeouts.
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ import ActionScheduler from "../util/action-scheduler";
3
+ import type { IScheduleActions } from "../util/types";
4
+ type Props = {
5
+ /**
6
+ * A function that, when given an instance of `IScheduleActions` will
7
+ * render a `React.Node`.
8
+ */
9
+ children: (arg1: IScheduleActions) => React.ReactElement;
10
+ };
11
+ /**
12
+ * A provider component that passes our action scheduling API to its children
13
+ * and ensures that all scheduled actions are cleared on unmount.
14
+ *
15
+ * ```jsx
16
+ * <ActionSchedulerProvider>
17
+ * {schedule => this.renderThingThatNeedsTimers(schedule)}
18
+ * </ActionSchedulerProvider>
19
+ * ```
20
+ */
21
+ export default class ActionSchedulerProvider extends React.Component<Props> {
22
+ componentWillUnmount(): void;
23
+ _actionScheduler: ActionScheduler;
24
+ render(): React.ReactElement;
25
+ }
26
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Flowtype definitions for action-scheduler-provider
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import ActionScheduler from "../util/action-scheduler";
10
+ import type { IScheduleActions } from "../util/types";
11
+ declare type Props = {
12
+ /**
13
+ * A function that, when given an instance of `IScheduleActions` will
14
+ * render a `React.Node`.
15
+ */
16
+ children: (arg1: IScheduleActions) => React.Element<>,
17
+ ...
18
+ };
19
+ /**
20
+ * A provider component that passes our action scheduling API to its children
21
+ * and ensures that all scheduled actions are cleared on unmount.
22
+ *
23
+ * ```jsx
24
+ * <ActionSchedulerProvider>
25
+ * {schedule => this.renderThingThatNeedsTimers(schedule)}
26
+ * </ActionSchedulerProvider>
27
+ * ```
28
+ */
29
+ declare export default class ActionSchedulerProvider
30
+ mixins React.Component<Props>
31
+ {
32
+ componentWillUnmount(): void;
33
+ _actionScheduler: ActionScheduler;
34
+ render(): React.Element<>;
35
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import type { WithActionSchedulerProps } from "../util/types";
3
+ type WithoutActionScheduler<T> = Omit<T, "schedule">;
4
+ /**
5
+ * A higher order component that attaches the given component to an
6
+ * `IScheduleActions` instance. Any actions scheduled will automatically be
7
+ * cleared on unmount.
8
+ *
9
+ * @template TOwnProps The own props of the component being rendered, without
10
+ * the additional action scheduler prop. To attach the additional prop to
11
+ * these props use the `WithActionScheduler` type.
12
+ */
13
+ export default function withActionScheduler<Props extends WithActionSchedulerProps>(WrappedComponent: React.ComponentType<Props>): React.ForwardRefExoticComponent<React.PropsWithoutRef<WithoutActionScheduler<Props>> & React.RefAttributes<unknown>>;
14
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Flowtype definitions for with-action-scheduler
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { WithActionSchedulerProps } from "../util/types";
10
+ declare type WithoutActionScheduler<T> = $Diff<T, { schedule: any }>;
11
+ /**
12
+ * A higher order component that attaches the given component to an
13
+ * `IScheduleActions` instance. Any actions scheduled will automatically be
14
+ * cleared on unmount.
15
+ * @template The own props of the component being rendered, without
16
+ * the additional action scheduler prop. To attach the additional prop to
17
+ * these props use the `WithActionScheduler` type.
18
+ */
19
+ declare export default function withActionScheduler<
20
+ Props: WithActionSchedulerProps
21
+ >(
22
+ WrappedComponent: React.ComponentType<Props>
23
+ ): React.ForwardRefExoticComponent<{
24
+ ...React.PropsWithoutRef<WithoutActionScheduler<Props>>,
25
+ ...React.RefAttributes<mixed>,
26
+ }>;