@clicktap/state 0.16.2 → 0.16.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 (61) hide show
  1. package/__mocks__/nanoid.d.ts +7 -0
  2. package/auth/AuthProvider.d.ts +133 -0
  3. package/auth/actions/addError.d.ts +8 -0
  4. package/auth/actions/clearErrors.d.ts +5 -0
  5. package/auth/actions/index.d.ts +8 -0
  6. package/auth/actions/notifyAuthenticated.d.ts +6 -0
  7. package/auth/actions/setAccessToken.d.ts +9 -0
  8. package/auth/actions/setIgnoreRefreshToken.d.ts +4 -0
  9. package/auth/actions/setUserContext.d.ts +9 -0
  10. package/auth/actions/unsetRefreshToken.d.ts +4 -0
  11. package/auth/actions/unsetUserContext.d.ts +8 -0
  12. package/auth/actors/authenticate.d.ts +16 -0
  13. package/auth/actors/index.d.ts +3 -0
  14. package/auth/actors/refreshAccessToken.d.ts +18 -0
  15. package/auth/actors/unauthenticate.d.ts +14 -0
  16. package/auth/auth.d.ts +54 -0
  17. package/auth/types.d.ts +50 -0
  18. package/helpers/request.d.ts +2 -0
  19. package/index.js +41 -34
  20. package/index.mjs +1979 -1636
  21. package/package.json +2 -2
  22. package/quote/CheckoutProvider.d.ts +159 -0
  23. package/quote/QuoteProvider.d.ts +242 -0
  24. package/quote/checkout/actions/changeStep.d.ts +8 -0
  25. package/quote/checkout/actions/index.d.ts +5 -0
  26. package/quote/checkout/actions/nextStep.d.ts +8 -0
  27. package/quote/checkout/actions/resetCheckout.d.ts +104 -0
  28. package/quote/checkout/actions/updateQuote.d.ts +216 -0
  29. package/quote/checkout/actions/updateSuccessId.d.ts +8 -0
  30. package/quote/checkout/actors/index.d.ts +2 -0
  31. package/quote/checkout/actors/placeOrder.d.ts +20 -0
  32. package/quote/checkout/actors/submitStepData.d.ts +19 -0
  33. package/quote/checkout/guards/index.d.ts +1 -0
  34. package/quote/checkout/guards/quoteExists.d.ts +10 -0
  35. package/quote/checkout/types.d.ts +55 -0
  36. package/quote/checkout.d.ts +46 -0
  37. package/quote/quote/actions/addItems.d.ts +217 -0
  38. package/quote/quote/actions/index.d.ts +9 -0
  39. package/quote/quote/actions/notifyAddItems.d.ts +6 -0
  40. package/quote/quote/actions/notifyRemoveItems.d.ts +6 -0
  41. package/quote/quote/actions/notifyUpdateItems.d.ts +6 -0
  42. package/quote/quote/actions/refresh.d.ts +216 -0
  43. package/quote/quote/actions/removeItems.d.ts +217 -0
  44. package/quote/quote/actions/reset.d.ts +40 -0
  45. package/quote/quote/actions/syncAccessToken.d.ts +100 -0
  46. package/quote/quote/actions/updateItems.d.ts +217 -0
  47. package/quote/quote/actors/addItems.d.ts +24 -0
  48. package/quote/quote/actors/index.d.ts +4 -0
  49. package/quote/quote/actors/refresh.d.ts +22 -0
  50. package/quote/quote/actors/removeItems.d.ts +24 -0
  51. package/quote/quote/actors/updateItems.d.ts +24 -0
  52. package/quote/quote/guards/canRefresh.d.ts +10 -0
  53. package/quote/quote/guards/hasItems.d.ts +5 -0
  54. package/quote/quote/guards/index.d.ts +2 -0
  55. package/quote/quote/types.d.ts +291 -0
  56. package/quote/quote.d.ts +72 -0
  57. package/quote/types.d.ts +5 -0
  58. package/toast/ToastProvider.d.ts +80 -0
  59. package/toast/timer.d.ts +23 -0
  60. package/toast/toast.d.ts +69 -0
  61. package/toast/types.d.ts +58 -0
@@ -0,0 +1,72 @@
1
+ import { DeepPartial } from './types';
2
+ import { QuoteMachineContext } from './quote/types';
3
+ export declare const quoteMachine: import('xstate').StateMachine<QuoteMachineContext, import('./quote/types').SetQuoteEmptyEvent | import('./quote/types').SetQuoteActiveEvent | import('./quote/types').AddItemsEvent | import('./quote/types').RemoveItemsEvent | import('./quote/types').UpdateItemsEvent | import('./quote/types').ClearItemsEvent | import('./quote/types').RefreshEvent | import('./quote/types').ResetEvent | import('./quote/types').ApplyPromotionEvent | import('./quote/types').RemovePromotionEvent | import('./quote/types').AddAddressEvent | import('./quote/types').RemoveAddressEvent | import('./quote/types').ApplyPaymentMethodEvent | import('./quote/types').AddRewardEvent | import('./quote/types').RemoveRewardEvent | import('./quote/types').AddStoreCreditEvent | import('./quote/types').RemoveStoreCreditEvent | import('./quote/types').AddGiftCardEvent | import('./quote/types').RemoveGiftCardEvent | import('./quote/types').SyncAccessTokenEvent | import('xstate').DoneActorEvent<import('./quote/types').AddItemsSuccessEvent, string> | import('xstate').DoneActorEvent<import('./quote/types').RemoveItemsSuccessEvent, string> | import('xstate').DoneActorEvent<import('./quote/types').UpdateItemsSuccessEvent, string> | import('xstate').DoneActorEvent<import('./quote/types').ClearItemsSuccessEvent, string> | import('xstate').DoneActorEvent<import('./quote/types').RefreshSuccessEvent, string>, {
4
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./quote/types').RefreshSuccessEvent, import('./quote/actors').RefreshInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./quote/types').AddItemsSuccessEvent, import('./quote/actors').AddItemsInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./quote/types').RemoveItemsSuccessEvent, import('./quote/actors').RemoveItemsInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./quote/types').UpdateItemsSuccessEvent, import('./quote/actors').UpdateItemsInput, import('xstate').EventObject>> | undefined;
5
+ }, {
6
+ src: "refresh";
7
+ logic: import('xstate').PromiseActorLogic<import('./quote/types').RefreshSuccessEvent, import('./quote/actors').RefreshInput, import('xstate').EventObject>;
8
+ id: string | undefined;
9
+ } | {
10
+ src: "addItems";
11
+ logic: import('xstate').PromiseActorLogic<import('./quote/types').AddItemsSuccessEvent, import('./quote/actors').AddItemsInput, import('xstate').EventObject>;
12
+ id: string | undefined;
13
+ } | {
14
+ src: "removeItems";
15
+ logic: import('xstate').PromiseActorLogic<import('./quote/types').RemoveItemsSuccessEvent, import('./quote/actors').RemoveItemsInput, import('xstate').EventObject>;
16
+ id: string | undefined;
17
+ } | {
18
+ src: "updateItems";
19
+ logic: import('xstate').PromiseActorLogic<import('./quote/types').UpdateItemsSuccessEvent, import('./quote/actors').UpdateItemsInput, import('xstate').EventObject>;
20
+ id: string | undefined;
21
+ }, {
22
+ type: "refresh";
23
+ params: import('xstate').NonReducibleUnknown;
24
+ } | {
25
+ type: "addItems";
26
+ params: import('xstate').NonReducibleUnknown;
27
+ } | {
28
+ type: "removeItems";
29
+ params: import('xstate').NonReducibleUnknown;
30
+ } | {
31
+ type: "updateItems";
32
+ params: import('xstate').NonReducibleUnknown;
33
+ } | {
34
+ type: "notifyAddItems";
35
+ params: import('xstate').NonReducibleUnknown;
36
+ } | {
37
+ type: "notifyRemoveItems";
38
+ params: import('xstate').NonReducibleUnknown;
39
+ } | {
40
+ type: "notifyUpdateItems";
41
+ params: import('xstate').NonReducibleUnknown;
42
+ } | {
43
+ type: "reset";
44
+ params: import('xstate').NonReducibleUnknown;
45
+ } | {
46
+ type: "syncAccessToken";
47
+ params: import('xstate').NonReducibleUnknown;
48
+ }, {
49
+ type: "canRefresh";
50
+ params: unknown;
51
+ } | {
52
+ type: "hasItems";
53
+ params: unknown;
54
+ }, never, "active" | "refreshing" | "uninitialized" | "initializing" | "empty" | "addingItems" | "updatingItems" | "removingItems" | "resetting" | "checkingItems", string, {
55
+ initialContext: DeepPartial<QuoteMachineContext>;
56
+ initialState?: string;
57
+ }, import('xstate').NonReducibleUnknown, import('./quote/types').AddItemsEmittedEvent | import('./quote/types').RemoveItemsEmittedEvent | import('./quote/types').UpdateItemsEmittedEvent, import('xstate').MetaObject, {
58
+ id: "quote";
59
+ states: {
60
+ readonly uninitialized: {};
61
+ readonly empty: {};
62
+ readonly active: {};
63
+ readonly initializing: {};
64
+ readonly refreshing: {};
65
+ readonly checkingItems: {};
66
+ readonly addingItems: {};
67
+ readonly removingItems: {};
68
+ readonly updatingItems: {};
69
+ readonly resetting: {};
70
+ };
71
+ }>;
72
+ export default quoteMachine;
@@ -0,0 +1,5 @@
1
+ /** @todo is this level of deep partial necessary? */
2
+ export type DeepPartial<T> = {
3
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T[P] extends Date | Function | RegExp ? T[P] : T[P] extends object ? DeepPartial<T[P]> : T[P];
4
+ };
5
+ export default DeepPartial;
@@ -0,0 +1,80 @@
1
+ import { Actor } from 'xstate';
2
+ import { ReactNode } from 'react';
3
+ import { toastMachine } from './toast';
4
+ export interface ToastContextType {
5
+ toastActor: Actor<typeof toastMachine>;
6
+ }
7
+ export declare const ToastContext: import('react').Context<Actor<import('xstate').StateMachine<import('./types').ToastMachineContext, import('./types').AddItemEvent | import('./types').RemoveItemEvent | import('./types').SetToastIdleEvent | import('./types').SetToastActiveEvent | import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').TimerDoneEvent, {
8
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').StateMachine<import('./types').TimerContext, import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').StartTimerEvent | import('./types').TimerTickEvent | import('./types').TimerDurationUpdateEvent | import('./types').ResetTimerEvent, {
9
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
10
+ interval: number;
11
+ }, import('xstate').EventObject>> | undefined;
12
+ }, {
13
+ src: "tick";
14
+ logic: import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
15
+ interval: number;
16
+ }, import('xstate').EventObject>;
17
+ id: string | undefined;
18
+ }, never, never, never, "running" | "paused" | "completed", string, {
19
+ initialContext: Partial<import('./types').TimerContext>;
20
+ initialState?: string;
21
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
22
+ id: "timer";
23
+ states: {
24
+ readonly paused: {};
25
+ readonly running: {};
26
+ readonly completed: {};
27
+ };
28
+ }>> | undefined;
29
+ }, {
30
+ src: "timer";
31
+ logic: import('xstate').StateMachine<import('./types').TimerContext, import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').StartTimerEvent | import('./types').TimerTickEvent | import('./types').TimerDurationUpdateEvent | import('./types').ResetTimerEvent, {
32
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
33
+ interval: number;
34
+ }, import('xstate').EventObject>> | undefined;
35
+ }, {
36
+ src: "tick";
37
+ logic: import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
38
+ interval: number;
39
+ }, import('xstate').EventObject>;
40
+ id: string | undefined;
41
+ }, never, never, never, "running" | "paused" | "completed", string, {
42
+ initialContext: Partial<import('./types').TimerContext>;
43
+ initialState?: string;
44
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
45
+ id: "timer";
46
+ states: {
47
+ readonly paused: {};
48
+ readonly running: {};
49
+ readonly completed: {};
50
+ };
51
+ }>;
52
+ id: string | undefined;
53
+ }, {
54
+ type: "addItem";
55
+ params: import('xstate').NonReducibleUnknown;
56
+ } | {
57
+ type: "removeItem";
58
+ params: import('xstate').NonReducibleUnknown;
59
+ }, {
60
+ type: "itemHasTimeout";
61
+ params: unknown;
62
+ }, "ITEM_TIMEOUT", "active" | "idle" | "adding" | "removing", string, {
63
+ initialContext: Partial<import('./types').ToastMachineContext>;
64
+ initialState?: string;
65
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
66
+ id: "toast";
67
+ states: {
68
+ readonly idle: {};
69
+ readonly active: {};
70
+ readonly adding: {};
71
+ readonly removing: {};
72
+ };
73
+ }>>>;
74
+ export declare const useToast: () => ToastContextType;
75
+ type Props = {
76
+ children: ReactNode;
77
+ actor: Actor<typeof toastMachine>;
78
+ };
79
+ export declare function ToastProvider({ children, actor }: Props): import("react/jsx-runtime").JSX.Element;
80
+ export {};
@@ -0,0 +1,23 @@
1
+ import { TimerContext, TimerTickEvent } from './types';
2
+ export declare const timerMachine: import('xstate').StateMachine<TimerContext, import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').StartTimerEvent | TimerTickEvent | import('./types').TimerDurationUpdateEvent | import('./types').ResetTimerEvent, {
3
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').CallbackActorLogic<TimerTickEvent, {
4
+ interval: number;
5
+ }, import('xstate').EventObject>> | undefined;
6
+ }, {
7
+ src: "tick";
8
+ logic: import('xstate').CallbackActorLogic<TimerTickEvent, {
9
+ interval: number;
10
+ }, import('xstate').EventObject>;
11
+ id: string | undefined;
12
+ }, never, never, never, "running" | "paused" | "completed", string, {
13
+ initialContext: Partial<TimerContext>;
14
+ initialState?: string;
15
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
16
+ id: "timer";
17
+ states: {
18
+ readonly paused: {};
19
+ readonly running: {};
20
+ readonly completed: {};
21
+ };
22
+ }>;
23
+ export default timerMachine;
@@ -0,0 +1,69 @@
1
+ import { ToastMachineContext } from './types';
2
+ export declare const toastMachine: import('xstate').StateMachine<ToastMachineContext, import('./types').AddItemEvent | import('./types').RemoveItemEvent | import('./types').SetToastIdleEvent | import('./types').SetToastActiveEvent | import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').TimerDoneEvent, {
3
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').StateMachine<import('./types').TimerContext, import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').StartTimerEvent | import('./types').TimerTickEvent | import('./types').TimerDurationUpdateEvent | import('./types').ResetTimerEvent, {
4
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
5
+ interval: number;
6
+ }, import('xstate').EventObject>> | undefined;
7
+ }, {
8
+ src: "tick";
9
+ logic: import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
10
+ interval: number;
11
+ }, import('xstate').EventObject>;
12
+ id: string | undefined;
13
+ }, never, never, never, "running" | "paused" | "completed", string, {
14
+ initialContext: Partial<import('./types').TimerContext>;
15
+ initialState?: string;
16
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
17
+ id: "timer";
18
+ states: {
19
+ readonly paused: {};
20
+ readonly running: {};
21
+ readonly completed: {};
22
+ };
23
+ }>> | undefined;
24
+ }, {
25
+ src: "timer";
26
+ logic: import('xstate').StateMachine<import('./types').TimerContext, import('./types').ResumeTimerEvent | import('./types').PauseTimerEvent | import('./types').StartTimerEvent | import('./types').TimerTickEvent | import('./types').TimerDurationUpdateEvent | import('./types').ResetTimerEvent, {
27
+ [x: string]: import('xstate').ActorRefFromLogic<import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
28
+ interval: number;
29
+ }, import('xstate').EventObject>> | undefined;
30
+ }, {
31
+ src: "tick";
32
+ logic: import('xstate').CallbackActorLogic<import('./types').TimerTickEvent, {
33
+ interval: number;
34
+ }, import('xstate').EventObject>;
35
+ id: string | undefined;
36
+ }, never, never, never, "running" | "paused" | "completed", string, {
37
+ initialContext: Partial<import('./types').TimerContext>;
38
+ initialState?: string;
39
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
40
+ id: "timer";
41
+ states: {
42
+ readonly paused: {};
43
+ readonly running: {};
44
+ readonly completed: {};
45
+ };
46
+ }>;
47
+ id: string | undefined;
48
+ }, {
49
+ type: "addItem";
50
+ params: import('xstate').NonReducibleUnknown;
51
+ } | {
52
+ type: "removeItem";
53
+ params: import('xstate').NonReducibleUnknown;
54
+ }, {
55
+ type: "itemHasTimeout";
56
+ params: unknown;
57
+ }, "ITEM_TIMEOUT", "active" | "idle" | "adding" | "removing", string, {
58
+ initialContext: Partial<ToastMachineContext>;
59
+ initialState?: string;
60
+ }, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
61
+ id: "toast";
62
+ states: {
63
+ readonly idle: {};
64
+ readonly active: {};
65
+ readonly adding: {};
66
+ readonly removing: {};
67
+ };
68
+ }>;
69
+ export default toastMachine;
@@ -0,0 +1,58 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ /** @todo figure out TS here */
3
+ export type ToastItem = {
4
+ id: string | null;
5
+ duration: number;
6
+ element: ReactNode;
7
+ };
8
+ export interface ToastMachineContext {
9
+ /** @todo create proper type for Array items */
10
+ items: Array<ToastItem>;
11
+ order: 'asc' | 'desc';
12
+ duration: number;
13
+ activeItem: string | null;
14
+ }
15
+ export interface AddItemEvent {
16
+ type: 'ADD_ITEM';
17
+ item: ReactElement;
18
+ duration?: number;
19
+ }
20
+ export interface RemoveItemEvent {
21
+ type: 'REMOVE_ITEM';
22
+ }
23
+ export interface SetToastIdleEvent {
24
+ type: 'SET_IDLE';
25
+ }
26
+ export interface SetToastActiveEvent {
27
+ type: 'SET_ACTIVE';
28
+ }
29
+ export interface ResumeTimerEvent {
30
+ type: 'RESUME_TIMER';
31
+ }
32
+ export interface PauseTimerEvent {
33
+ type: 'PAUSE_TIMER';
34
+ }
35
+ export interface TimerDoneEvent {
36
+ type: 'xstate.done.actor.timer';
37
+ }
38
+ export type ToastMachineEvents = AddItemEvent | RemoveItemEvent | SetToastIdleEvent | SetToastActiveEvent | ResumeTimerEvent | PauseTimerEvent | TimerDoneEvent;
39
+ export interface TimerContext {
40
+ elapsed: number;
41
+ duration: number;
42
+ interval: number;
43
+ intervalId: NodeJS.Timer | null;
44
+ }
45
+ export type StartTimerEvent = {
46
+ type: 'START_TIMER';
47
+ };
48
+ export type TimerTickEvent = {
49
+ type: 'TICK';
50
+ };
51
+ export type TimerDurationUpdateEvent = {
52
+ type: 'DURATION.UPDATE';
53
+ value: number;
54
+ };
55
+ export type ResetTimerEvent = {
56
+ type: 'RESET_TIMER';
57
+ };
58
+ export type TimerEvents = StartTimerEvent | ResumeTimerEvent | PauseTimerEvent | TimerTickEvent | TimerDurationUpdateEvent | ResetTimerEvent;