@civet/events 4.1.1 → 4.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.
@@ -1,5 +1,6 @@
1
- import { ReactNode } from 'react';
1
+ import { PropsWithChildren } from 'react';
2
2
  import { GenericEventReceiver, InferEvent, InferOptions, InferResource } from './EventReceiver';
3
+ import { EventProps } from './useEventHandler';
3
4
  /**
4
5
  * Enables automatic updating for a Resource component or useResource hook by subscribing to an EventReceiver.
5
6
  *
@@ -7,21 +8,4 @@ import { GenericEventReceiver, InferEvent, InferOptions, InferResource } from '.
7
8
  *
8
9
  * onEvent can be used to directly access events allowing you to add custom event logic to your components.
9
10
  */
10
- export default function EventHandler<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, ResourceI extends InferResource<EventReceiverI> = InferResource<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>>({ eventReceiver, resource, disabled, options, onEvent, onNotify, children, }: {
11
- /** EventReceiver to be used */
12
- eventReceiver?: EventReceiverI;
13
- /** ResourceContext to be used */
14
- resource?: ResourceI;
15
- /** Disables the event handler */
16
- disabled?: boolean;
17
- /** Options for the EventReceiver */
18
- options?: OptionsI;
19
- /** Callback to filter events and handle your own event logic - if true is returned, the event does not cause the resource to update */
20
- onEvent?: (event: EventI) => boolean;
21
- /** Provides information on when the resource has been requested to update - events contains the events that lead to the update */
22
- onNotify?: (next: {
23
- request: string;
24
- revision: string;
25
- }, events: EventI[]) => void;
26
- children?: ReactNode;
27
- }): import("react/jsx-runtime").JSX.Element;
11
+ export default function EventHandler<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, ResourceI extends InferResource<EventReceiverI> = InferResource<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>>({ eventReceiver, resource, disabled, options, onEvent, onNotify, children, }: PropsWithChildren<EventProps<EventReceiverI, EventI, ResourceI, OptionsI>>): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,8 @@
1
1
  import { GenericDataProviderImplementation } from '@civet/core';
2
- import { GenericEventReceiver, InferEvent, InferOptions } from './EventReceiver';
3
- type EventProps<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>> = {
4
- events?: {
5
- /** EventReceiver to be used */
6
- eventReceiver?: EventReceiverI;
7
- /** Disables the event handler */
8
- disabled?: boolean;
9
- /** Options for the EventReceiver */
10
- options?: OptionsI;
11
- /** Callback to filter events and handle your own event logic - if true is returned, the event does not cause the resource to update */
12
- onEvent?: (event: EventI) => boolean;
13
- /** Provides information on when the resource has been requested to update - events contains the events that lead to the update */
14
- onNotify?: (next: {
15
- request: string;
16
- revision: string;
17
- }, events: EventI[]) => void;
18
- } | boolean;
2
+ import { GenericEventReceiver, InferEvent, InferOptions, InferResource } from './EventReceiver';
3
+ import { EventProps } from './useEventHandler';
4
+ type EventPluginContextProps = {
5
+ events?: Omit<EventProps<GenericEventReceiver, InferEvent<GenericEventReceiver>, InferResource<GenericEventReceiver>, InferOptions<GenericEventReceiver>>, 'resource'> | boolean;
19
6
  };
20
- declare const eventPlugin: import('@civet/core').DataProviderPlugin<GenericDataProviderImplementation, unknown, EventProps<GenericEventReceiver, unknown, unknown>, unknown, unknown, unknown>;
7
+ declare const eventPlugin: import('@civet/core').DataProviderPlugin<GenericDataProviderImplementation, unknown, EventPluginContextProps, unknown, unknown, unknown>;
21
8
  export default eventPlugin;
package/dist/main.js CHANGED
@@ -138,7 +138,7 @@ function Z({
138
138
  const $ = I(
139
139
  (o) => class extends o {
140
140
  extend(t) {
141
- t.context(
141
+ super.extend(t), t.context(
142
142
  (r, { events: n = !1 }) => (w(
143
143
  typeof n == "boolean" ? { disabled: !n, resource: r } : { ...n, resource: r }
144
144
  ), r)
@@ -1,12 +1,5 @@
1
1
  import { GenericEventReceiver, InferEvent, InferOptions, InferResource } from './EventReceiver';
2
- /**
3
- * Enables automatic updating for a Resource component or useResource hook by subscribing to an EventReceiver.
4
- *
5
- * Necessary configuration that is not directly specified is taken from the ConfigContext and ResourceContext.
6
- *
7
- * onEvent can be used to directly access events allowing you to add custom event logic to your components.
8
- */
9
- export default function useEventHandler<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, ResourceI extends InferResource<EventReceiverI> = InferResource<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>>({ eventReceiver: eventReceiverProp, resource: resourceProp, disabled, options: optionsProp, onEvent, onNotify, }: {
2
+ export type EventProps<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, ResourceI extends InferResource<EventReceiverI> = InferResource<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>> = {
10
3
  /** EventReceiver to be used */
11
4
  eventReceiver?: EventReceiverI;
12
5
  /** ResourceContext to be used */
@@ -22,4 +15,12 @@ export default function useEventHandler<EventReceiverI extends GenericEventRecei
22
15
  request: string;
23
16
  revision: string;
24
17
  }, events: EventI[]) => void;
25
- }): void;
18
+ };
19
+ /**
20
+ * Enables automatic updating for a Resource component or useResource hook by subscribing to an EventReceiver.
21
+ *
22
+ * Necessary configuration that is not directly specified is taken from the ConfigContext and ResourceContext.
23
+ *
24
+ * onEvent can be used to directly access events allowing you to add custom event logic to your components.
25
+ */
26
+ export default function useEventHandler<EventReceiverI extends GenericEventReceiver, EventI extends InferEvent<EventReceiverI> = InferEvent<EventReceiverI>, ResourceI extends InferResource<EventReceiverI> = InferResource<EventReceiverI>, OptionsI extends InferOptions<EventReceiverI> = InferOptions<EventReceiverI>>({ eventReceiver: eventReceiverProp, resource: resourceProp, disabled, options: optionsProp, onEvent, onNotify, }: EventProps<EventReceiverI, EventI, ResourceI, OptionsI>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civet/events",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "description": "Civet",
5
5
  "author": {
6
6
  "name": "Aaron Burmeister"
@@ -55,7 +55,7 @@
55
55
  "react-dom": ">=18.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@civet/core": "^6.2.2",
58
+ "@civet/core": "^6.2.4",
59
59
  "@eslint/js": "^9.39.3",
60
60
  "@types/react": "^19.1.12",
61
61
  "@types/react-dom": "^19.1.9",
@@ -67,14 +67,14 @@
67
67
  "eslint-plugin-import": "^2.32.0",
68
68
  "eslint-plugin-prettier": "^5.5.4",
69
69
  "eslint-plugin-react-hooks": "^7.0.1",
70
- "eslint-plugin-react-refresh": "^0.5.1",
70
+ "eslint-plugin-react-refresh": "^0.5.2",
71
71
  "eslint-plugin-unused-imports": "^4.2.0",
72
72
  "globals": "^17.3.0",
73
73
  "prettier": "^3.6.2",
74
74
  "react": "^19.1.1",
75
75
  "react-dom": "^19.1.1",
76
76
  "typescript": "^5.9.2",
77
- "typescript-eslint": "^8.56.0",
77
+ "typescript-eslint": "^8.56.1",
78
78
  "vite": "^7.1.5",
79
79
  "vite-plugin-dts": "^4.5.4",
80
80
  "vite-tsconfig-paths": "^6.1.1"