@websolutespa/bom-mixer-hooks 1.1.0 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-hooks
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Updating: next 13.
8
+
3
9
  ## 1.1.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -9,243 +9,243 @@ import { ISchema, IEquatable, ILayout, IPage } from '@websolutespa/bom-core';
9
9
  import { ICartItem, ICartAddItem, IAddressOptions, ICheckoutPartial, IFeatureType, IUser } from '@websolutespa/bom-mixer-models';
10
10
  import { NextRouter } from 'next/router';
11
11
 
12
- declare function useApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
13
- declare function useApiGet<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
14
- declare function useApiPost<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
15
- declare function useApiPut<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
16
- declare function useApiPatch<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
17
- declare function useApiDelete<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
18
- type Api = {
19
- get: <T = unknown>(pathname: string, options?: ApiRequestOptions) => Promise<T>;
20
- post: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
21
- put: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
22
- patch: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
23
- delete: <T = unknown>(pathname: string, options?: ApiRequestOptions) => Promise<T>;
24
- };
12
+ declare function useApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
13
+ declare function useApiGet<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
14
+ declare function useApiPost<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
15
+ declare function useApiPut<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
16
+ declare function useApiPatch<T = unknown>(pathname: string, payload: unknown, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
17
+ declare function useApiDelete<T = unknown>(pathname: string, options?: ApiRequestOptions): [T | undefined, boolean, any, React$1.Dispatch<any>];
18
+ type Api = {
19
+ get: <T = unknown>(pathname: string, options?: ApiRequestOptions) => Promise<T>;
20
+ post: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
21
+ put: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
22
+ patch: <T = unknown>(pathname: string, payload?: unknown, options?: ApiRequestOptions) => Promise<T>;
23
+ delete: <T = unknown>(pathname: string, options?: ApiRequestOptions) => Promise<T>;
24
+ };
25
25
  declare function useApi(): Api;
26
26
 
27
- declare function useBodyScroll(elementRef?: RefObject<HTMLElement> | null, options?: BodyScrollOptions): [boolean, Dispatch<SetStateAction<boolean>>];
28
- declare function getOwnerPaddingRight(element: Element): number;
29
- declare function getOwnerScrollbarWidth(element: Element): number;
30
- type ElementStackItem = {
31
- overflow: string;
32
- paddingRight: string;
33
- };
34
- type BodyScrollOptions = {
35
- scrollLayer?: boolean;
36
- delayReset?: number;
37
- };
38
-
39
- type BreakpointType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
40
- type Breakpoint = {
41
- key: BreakpointType;
42
- min: number;
43
- max: number;
44
- };
27
+ declare function useBodyScroll(elementRef?: RefObject<HTMLElement> | null, options?: BodyScrollOptions): [boolean, Dispatch<SetStateAction<boolean>>];
28
+ declare function getOwnerPaddingRight(element: Element): number;
29
+ declare function getOwnerScrollbarWidth(element: Element): number;
30
+ type ElementStackItem = {
31
+ overflow: string;
32
+ paddingRight: string;
33
+ };
34
+ type BodyScrollOptions = {
35
+ scrollLayer?: boolean;
36
+ delayReset?: number;
37
+ };
38
+
39
+ type BreakpointType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
40
+ type Breakpoint = {
41
+ key: BreakpointType;
42
+ min: number;
43
+ max: number;
44
+ };
45
45
  declare function useBreakpoint(): Breakpoint;
46
46
 
47
- type CartProps = {
48
- hydrated: boolean;
49
- items: ICartItem[];
50
- };
51
- type CartActions = {
52
- count(): number;
53
- has(item: ISchema): boolean;
54
- find(item: ISchema): ICartItem | undefined;
55
- add(item: ICartAddItem, qty?: number): void;
56
- remove(item: ISchema): number;
57
- update(item: ICartItem): void;
58
- clear(): void;
59
- };
60
- type CartState = CartProps & {
61
- actions: CartActions;
62
- };
63
- declare const CartContext: React$1.Context<(Omit<zustand.StoreApi<CartState>, "persist"> & {
64
- persist: {
65
- setOptions: (options: Partial<zustand_middleware.PersistOptions<CartState, unknown>>) => void;
66
- clearStorage: () => void;
67
- rehydrate: () => void | Promise<void>;
68
- hasHydrated: () => boolean;
69
- onHydrate: (fn: (state: CartState) => void) => () => void;
70
- onFinishHydration: (fn: (state: CartState) => void) => () => void;
71
- getOptions: () => Partial<zustand_middleware.PersistOptions<CartState, unknown>>;
72
- };
73
- }) | null>;
74
- type CartProviderProps = React.PropsWithChildren<{
75
- items?: ICartItem[];
76
- storage?: StateStorage;
77
- }>;
78
- declare function CartProvider({ children, ...props }: CartProviderProps): react_jsx_runtime.JSX.Element;
47
+ type CartProps = {
48
+ hydrated: boolean;
49
+ items: ICartItem[];
50
+ };
51
+ type CartActions = {
52
+ count(): number;
53
+ has(item: ISchema): boolean;
54
+ find(item: ISchema): ICartItem | undefined;
55
+ add(item: ICartAddItem, qty?: number): void;
56
+ remove(item: ISchema): number;
57
+ update(item: ICartItem): void;
58
+ clear(): void;
59
+ };
60
+ type CartState = CartProps & {
61
+ actions: CartActions;
62
+ };
63
+ declare const CartContext: React$1.Context<(Omit<zustand.StoreApi<CartState>, "persist"> & {
64
+ persist: {
65
+ setOptions: (options: Partial<zustand_middleware.PersistOptions<CartState, unknown>>) => void;
66
+ clearStorage: () => void;
67
+ rehydrate: () => void | Promise<void>;
68
+ hasHydrated: () => boolean;
69
+ onHydrate: (fn: (state: CartState) => void) => () => void;
70
+ onFinishHydration: (fn: (state: CartState) => void) => () => void;
71
+ getOptions: () => Partial<zustand_middleware.PersistOptions<CartState, unknown>>;
72
+ };
73
+ }) | null>;
74
+ type CartProviderProps = React.PropsWithChildren<{
75
+ items?: ICartItem[];
76
+ storage?: StateStorage;
77
+ }>;
78
+ declare function CartProvider({ children, ...props }: CartProviderProps): react_jsx_runtime.JSX.Element;
79
79
  declare function useCart<T>(selector: (state: CartState) => T): T;
80
80
 
81
- type CheckoutProps = {
82
- hydrated: boolean;
83
- data: IAddressOptions;
84
- checkout: ICheckoutPartial;
85
- };
86
- type CheckoutActions = {
87
- setCheckout(checkout: ICheckoutPartial): void;
88
- };
89
- type CheckoutState = CheckoutProps & {
90
- actions: CheckoutActions;
91
- };
92
- declare const CheckoutContext: React$1.Context<(Omit<zustand.StoreApi<CheckoutState>, "persist"> & {
93
- persist: {
94
- setOptions: (options: Partial<zustand_middleware.PersistOptions<CheckoutState, unknown>>) => void;
95
- clearStorage: () => void;
96
- rehydrate: () => void | Promise<void>;
97
- hasHydrated: () => boolean;
98
- onHydrate: (fn: (state: CheckoutState) => void) => () => void;
99
- onFinishHydration: (fn: (state: CheckoutState) => void) => () => void;
100
- getOptions: () => Partial<zustand_middleware.PersistOptions<CheckoutState, unknown>>;
101
- };
102
- }) | null>;
103
- type CheckoutProviderProps = React.PropsWithChildren<{
104
- data: IAddressOptions;
105
- checkout?: ICheckoutPartial;
106
- storage?: StateStorage;
107
- }>;
108
- declare function CheckoutProvider({ children, ...props }: CheckoutProviderProps): react_jsx_runtime.JSX.Element;
81
+ type CheckoutProps = {
82
+ hydrated: boolean;
83
+ data: IAddressOptions;
84
+ checkout: ICheckoutPartial;
85
+ };
86
+ type CheckoutActions = {
87
+ setCheckout(checkout: ICheckoutPartial): void;
88
+ };
89
+ type CheckoutState = CheckoutProps & {
90
+ actions: CheckoutActions;
91
+ };
92
+ declare const CheckoutContext: React$1.Context<(Omit<zustand.StoreApi<CheckoutState>, "persist"> & {
93
+ persist: {
94
+ setOptions: (options: Partial<zustand_middleware.PersistOptions<CheckoutState, unknown>>) => void;
95
+ clearStorage: () => void;
96
+ rehydrate: () => void | Promise<void>;
97
+ hasHydrated: () => boolean;
98
+ onHydrate: (fn: (state: CheckoutState) => void) => () => void;
99
+ onFinishHydration: (fn: (state: CheckoutState) => void) => () => void;
100
+ getOptions: () => Partial<zustand_middleware.PersistOptions<CheckoutState, unknown>>;
101
+ };
102
+ }) | null>;
103
+ type CheckoutProviderProps = React.PropsWithChildren<{
104
+ data: IAddressOptions;
105
+ checkout?: ICheckoutPartial;
106
+ storage?: StateStorage;
107
+ }>;
108
+ declare function CheckoutProvider({ children, ...props }: CheckoutProviderProps): react_jsx_runtime.JSX.Element;
109
109
  declare function useCheckout<T>(selector: (state: CheckoutState) => T): T;
110
110
 
111
111
  declare function useClickAnyWhere(handler: (event: MouseEvent) => void): void;
112
112
 
113
- type ClickOutGetContainer = () => HTMLElement | null;
113
+ type ClickOutGetContainer = () => HTMLElement | null;
114
114
  declare function useClickOut(ref: MutableRefObject<HTMLElement | null>, handler: (event: MouseEvent) => void): void;
115
115
 
116
116
  declare function useCurrency(currency?: string, locale?: string): (value: number) => string;
117
117
 
118
- declare function useCurrentState<S>(initialState: S | (() => S)): CurrentStateType<S>;
118
+ declare function useCurrentState<S>(initialState: S | (() => S)): CurrentStateType<S>;
119
119
  type CurrentStateType<S> = [S, Dispatch<SetStateAction<S>>, MutableRefObject<S>];
120
120
 
121
121
  declare function useDateTimeFormat(options?: Intl.DateTimeFormatOptions, locale?: string): (value: Date | string) => string;
122
122
 
123
123
  declare function useDebounce<T>(value: T, msec?: number): T;
124
124
 
125
- /**
126
- * Returns a memoized function that will only call the passed function when it hasn't been called for the msec period
127
- * @param func The function to be called
128
- * @param msec Wait period after function hasn't been called for
129
- * @returns A memoized function that is debounced
130
- */
125
+ /**
126
+ * Returns a memoized function that will only call the passed function when it hasn't been called for the msec period
127
+ * @param func The function to be called
128
+ * @param msec Wait period after function hasn't been called for
129
+ * @returns A memoized function that is debounced
130
+ */
131
131
  declare function useDebounceCallback<T extends (...args: any[]) => any>(callback: T, msec?: number): (...args: unknown[]) => void;
132
132
 
133
133
  declare function useDebugChangedProps(props: ComponentProps<any>): void;
134
134
 
135
135
  declare function useDomObserver(ref: MutableRefObject<HTMLElement | null> | undefined, callback?: MutationCallback): void;
136
136
 
137
- type UIValue = string | number | boolean | undefined;
138
- type UIViews = {
139
- [key: string]: UIValue;
140
- };
141
- type UIReducer = (state: UIViews) => UIValue;
142
- type UIActions = {
143
- reduce(key: string, reducer: UIReducer): void;
144
- };
145
- type UIStore = {
146
- views: UIViews;
147
- actions: UIActions;
148
- };
137
+ type UIValue = string | number | boolean | undefined;
138
+ type UIViews = {
139
+ [key: string]: UIValue;
140
+ };
141
+ type UIReducer = (state: UIViews) => UIValue;
142
+ type UIActions = {
143
+ reduce(key: string, reducer: UIReducer): void;
144
+ };
145
+ type UIStore = {
146
+ views: UIViews;
147
+ actions: UIActions;
148
+ };
149
149
  declare const useUI: zustand.UseBoundStore<zustand.StoreApi<UIStore>>;
150
150
 
151
151
  declare function useDrawer(): [drawer: UIValue, open: (value?: string) => void, close: () => void];
152
152
 
153
- type Size = {
154
- width: number;
155
- height: number;
156
- };
153
+ type Size = {
154
+ width: number;
155
+ height: number;
156
+ };
157
157
  declare function useElementSize<T extends HTMLElement = HTMLDivElement>(): [(node: T | null) => void, Size];
158
158
 
159
- declare function useEventListener_<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void;
160
- declare function useEventListener_<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>, options?: boolean | AddEventListenerOptions): void;
161
- declare function useEventListener_<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void;
159
+ declare function useEventListener_<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void;
160
+ declare function useEventListener_<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>, options?: boolean | AddEventListenerOptions): void;
161
+ declare function useEventListener_<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void;
162
162
  declare const useEventListener: typeof useEventListener_;
163
163
 
164
- type FilterParams = {
165
- [key: string]: IEquatable[] | null;
166
- };
167
- type FilterValues = IEquatable[][];
168
- declare enum FilterMode {
169
- SELECT = "select",
170
- AND = "and",
171
- OR = "or",
172
- QUERY = "query"
173
- }
174
- type IFilterOption = {
175
- id: IEquatable;
176
- title: string;
177
- count?: number;
178
- disabled?: boolean;
179
- };
180
- type IFilter = {
181
- id?: string;
182
- title?: string;
183
- mode?: FilterMode;
184
- options?: IFilterOption[];
185
- values?: IEquatable[];
186
- };
187
- declare class Filter<T> implements IFilter {
188
- id: string;
189
- title: string;
190
- mode: FilterMode;
191
- options: IFilterOption[];
192
- values: IEquatable[];
193
- constructor(options?: IFilter);
194
- static fromFeatureType<T>(featureType: IFeatureType, mode?: FilterMode): Filter<T>;
195
- filter(item: T, value: IEquatable): boolean;
196
- match(item: T): boolean;
197
- removeInvalidOptions(items: T[]): void;
198
- getLabel(): string | null;
199
- hasAny(): boolean;
200
- getCount(): number;
201
- hasResults(): boolean;
202
- has(option: IFilterOption): boolean;
203
- set(option: IFilterOption): void;
204
- remove(option: IFilterOption): void;
205
- toggle(option: IFilterOption): void;
206
- clear(): void;
164
+ type FilterParams = {
165
+ [key: string]: IEquatable[] | null;
166
+ };
167
+ type FilterValues = IEquatable[][];
168
+ declare enum FilterMode {
169
+ SELECT = "select",
170
+ AND = "and",
171
+ OR = "or",
172
+ QUERY = "query"
173
+ }
174
+ type IFilterOption = {
175
+ id: IEquatable;
176
+ title: string;
177
+ count?: number;
178
+ disabled?: boolean;
179
+ };
180
+ type IFilter = {
181
+ id?: string;
182
+ title?: string;
183
+ mode?: FilterMode;
184
+ options?: IFilterOption[];
185
+ values?: IEquatable[];
186
+ };
187
+ declare class Filter<T> implements IFilter {
188
+ id: string;
189
+ title: string;
190
+ mode: FilterMode;
191
+ options: IFilterOption[];
192
+ values: IEquatable[];
193
+ constructor(options?: IFilter);
194
+ static fromFeatureType<T>(featureType: IFeatureType, mode?: FilterMode): Filter<T>;
195
+ filter(item: T, value: IEquatable): boolean;
196
+ match(item: T): boolean;
197
+ removeInvalidOptions(items: T[]): void;
198
+ getLabel(): string | null;
199
+ hasAny(): boolean;
200
+ getCount(): number;
201
+ hasResults(): boolean;
202
+ has(option: IFilterOption): boolean;
203
+ set(option: IFilterOption): void;
204
+ remove(option: IFilterOption): void;
205
+ toggle(option: IFilterOption): void;
206
+ clear(): void;
207
207
  }
208
208
 
209
- declare function getFilters<T>(items: T[], featureTypes: IFeatureType[], filterMap: (key: string, item: T, value: IEquatable) => boolean, params?: FilterParams | null): Filter<T>[];
210
- declare function getFilteredItems<T>(items: T[], selectedFilters: Filter<T>[]): T[];
211
- declare function setFilters<T>(items: T[], filters: Filter<T>[], filter?: Filter<T>, values?: IEquatable[]): T[];
209
+ declare function getFilters<T>(items: T[], featureTypes: IFeatureType[], filterMap: (key: string, item: T, value: IEquatable) => boolean, params?: FilterParams | null): Filter<T>[];
210
+ declare function getFilteredItems<T>(items: T[], selectedFilters: Filter<T>[]): T[];
211
+ declare function setFilters<T>(items: T[], filters: Filter<T>[], filter?: Filter<T>, values?: IEquatable[]): T[];
212
212
  declare function filtersToParams<T>(filters: Filter<T>[]): FilterParams | null;
213
213
 
214
- declare function useFilters<T>(items: T[], featureTypes: IFeatureType[], filterItem: (key: string, item: T, value: IEquatable) => boolean, initialValues?: FilterParams | null): UseFiltersResultType<T>;
215
- type UseFiltersResultType<T> = {
216
- filteredItems: T[];
217
- filters: Filter<T>[];
218
- setFilter: (filter?: Filter<T>, values?: IEquatable[]) => void;
219
- itemsWithOmittedKeys: (...keys: string[]) => T[];
214
+ declare function useFilters<T>(items: T[], featureTypes: IFeatureType[], filterItem: (key: string, item: T, value: IEquatable) => boolean, initialValues?: FilterParams | null): UseFiltersResultType<T>;
215
+ type UseFiltersResultType<T> = {
216
+ filteredItems: T[];
217
+ filters: Filter<T>[];
218
+ setFilter: (filter?: Filter<T>, values?: IEquatable[]) => void;
219
+ itemsWithOmittedKeys: (...keys: string[]) => T[];
220
220
  };
221
221
 
222
222
  declare const createGenericContext: <T>(defaultContext?: T | null) => readonly [() => NonNullable<T>, React$1.Provider<T | undefined>];
223
223
 
224
- /**
225
- * @desc Made compatible with {GeolocationPositionError} and {PositionError} cause
226
- * PositionError been renamed to GeolocationPositionError in typescript 4.1.x and making
227
- * own compatible interface is most easiest way to avoid errors.
228
- */
229
- type IGeolocationPositionError = {
230
- readonly code: number;
231
- readonly message: string;
232
- readonly PERMISSION_DENIED: number;
233
- readonly POSITION_UNAVAILABLE: number;
234
- readonly TIMEOUT: number;
235
- };
236
- type GeoLocationSensorState = {
237
- loading: boolean;
238
- accuracy: number | null;
239
- altitude: number | null;
240
- altitudeAccuracy: number | null;
241
- heading: number | null;
242
- latitude: number | null;
243
- longitude: number | null;
244
- speed: number | null;
245
- timestamp: number | null;
246
- error?: Error | IGeolocationPositionError;
247
- };
248
- declare function getCurrentPosition(options?: PositionOptions): Promise<GeoLocationSensorState>;
224
+ /**
225
+ * @desc Made compatible with {GeolocationPositionError} and {PositionError} cause
226
+ * PositionError been renamed to GeolocationPositionError in typescript 4.1.x and making
227
+ * own compatible interface is most easiest way to avoid errors.
228
+ */
229
+ type IGeolocationPositionError = {
230
+ readonly code: number;
231
+ readonly message: string;
232
+ readonly PERMISSION_DENIED: number;
233
+ readonly POSITION_UNAVAILABLE: number;
234
+ readonly TIMEOUT: number;
235
+ };
236
+ type GeoLocationSensorState = {
237
+ loading: boolean;
238
+ accuracy: number | null;
239
+ altitude: number | null;
240
+ altitudeAccuracy: number | null;
241
+ heading: number | null;
242
+ latitude: number | null;
243
+ longitude: number | null;
244
+ speed: number | null;
245
+ timestamp: number | null;
246
+ error?: Error | IGeolocationPositionError;
247
+ };
248
+ declare function getCurrentPosition(options?: PositionOptions): Promise<GeoLocationSensorState>;
249
249
  declare function hasGeolocation(): boolean;
250
250
 
251
251
  declare function useGeolocation(options?: PositionOptions): GeoLocationSensorState;
@@ -256,137 +256,137 @@ declare function useInfiniteLoader(items: any[], perPage?: number, delayInMs?: n
256
256
 
257
257
  declare const useIsomorphicLayoutEffect: typeof useEffect;
258
258
 
259
- /**
260
- * KeyBinding Codes
261
- * The content of this file is based on the design of the open source project "microsoft/vscode",
262
- * Copyright (c) Microsoft Corporation. All rights reserved.
263
- *
264
- * We inherit the KeyMod values from "microsoft/vscode",
265
- * but use the Browser's KeyboardEvent event implementation, and all values are used only as identification.
266
- */
267
- declare enum KeyCode {
268
- Unknown = 0,
269
- Backspace = 8,
270
- Tab = 9,
271
- Enter = 13,
272
- Shift = 16,
273
- Ctrl = 17,
274
- Alt = 18,
275
- PauseBreak = 19,
276
- CapsLock = 20,
277
- Escape = 27,
278
- Space = 32,
279
- PageUp = 33,
280
- PageDown = 34,
281
- End = 35,
282
- Home = 36,
283
- LeftArrow = 37,
284
- UpArrow = 38,
285
- RightArrow = 39,
286
- DownArrow = 40,
287
- Insert = 45,
288
- Delete = 46,
289
- KEY_0 = 48,
290
- KEY_1 = 49,
291
- KEY_2 = 50,
292
- KEY_3 = 51,
293
- KEY_4 = 52,
294
- KEY_5 = 53,
295
- KEY_6 = 54,
296
- KEY_7 = 55,
297
- KEY_8 = 56,
298
- KEY_9 = 57,
299
- KEY_A = 65,
300
- KEY_B = 66,
301
- KEY_C = 67,
302
- KEY_D = 68,
303
- KEY_E = 69,
304
- KEY_F = 70,
305
- KEY_G = 71,
306
- KEY_H = 72,
307
- KEY_I = 73,
308
- KEY_J = 74,
309
- KEY_K = 75,
310
- KEY_L = 76,
311
- KEY_M = 77,
312
- KEY_N = 78,
313
- KEY_O = 79,
314
- KEY_P = 80,
315
- KEY_Q = 81,
316
- KEY_R = 82,
317
- KEY_S = 83,
318
- KEY_T = 84,
319
- KEY_U = 85,
320
- KEY_V = 86,
321
- KEY_W = 87,
322
- KEY_X = 88,
323
- KEY_Y = 89,
324
- KEY_Z = 90,
325
- Meta = 91,
326
- F1 = 112,
327
- F2 = 113,
328
- F3 = 114,
329
- F4 = 115,
330
- F5 = 116,
331
- F6 = 117,
332
- F7 = 118,
333
- F8 = 119,
334
- F9 = 120,
335
- F10 = 121,
336
- F11 = 122,
337
- F12 = 123,
338
- NumLock = 144,
339
- ScrollLock = 145,
340
- Equal = 187,
341
- Minus = 189,
342
- Backquote = 192,
343
- Backslash = 220
344
- }
345
- declare enum KeyMod {
346
- CtrlCmd = 2048,
347
- Shift = 1024,
348
- Alt = 512,
349
- WinCtrl = 256
259
+ /**
260
+ * KeyBinding Codes
261
+ * The content of this file is based on the design of the open source project "microsoft/vscode",
262
+ * Copyright (c) Microsoft Corporation. All rights reserved.
263
+ *
264
+ * We inherit the KeyMod values from "microsoft/vscode",
265
+ * but use the Browser's KeyboardEvent event implementation, and all values are used only as identification.
266
+ */
267
+ declare enum KeyCode {
268
+ Unknown = 0,
269
+ Backspace = 8,
270
+ Tab = 9,
271
+ Enter = 13,
272
+ Shift = 16,
273
+ Ctrl = 17,
274
+ Alt = 18,
275
+ PauseBreak = 19,
276
+ CapsLock = 20,
277
+ Escape = 27,
278
+ Space = 32,
279
+ PageUp = 33,
280
+ PageDown = 34,
281
+ End = 35,
282
+ Home = 36,
283
+ LeftArrow = 37,
284
+ UpArrow = 38,
285
+ RightArrow = 39,
286
+ DownArrow = 40,
287
+ Insert = 45,
288
+ Delete = 46,
289
+ KEY_0 = 48,
290
+ KEY_1 = 49,
291
+ KEY_2 = 50,
292
+ KEY_3 = 51,
293
+ KEY_4 = 52,
294
+ KEY_5 = 53,
295
+ KEY_6 = 54,
296
+ KEY_7 = 55,
297
+ KEY_8 = 56,
298
+ KEY_9 = 57,
299
+ KEY_A = 65,
300
+ KEY_B = 66,
301
+ KEY_C = 67,
302
+ KEY_D = 68,
303
+ KEY_E = 69,
304
+ KEY_F = 70,
305
+ KEY_G = 71,
306
+ KEY_H = 72,
307
+ KEY_I = 73,
308
+ KEY_J = 74,
309
+ KEY_K = 75,
310
+ KEY_L = 76,
311
+ KEY_M = 77,
312
+ KEY_N = 78,
313
+ KEY_O = 79,
314
+ KEY_P = 80,
315
+ KEY_Q = 81,
316
+ KEY_R = 82,
317
+ KEY_S = 83,
318
+ KEY_T = 84,
319
+ KEY_U = 85,
320
+ KEY_V = 86,
321
+ KEY_W = 87,
322
+ KEY_X = 88,
323
+ KEY_Y = 89,
324
+ KEY_Z = 90,
325
+ Meta = 91,
326
+ F1 = 112,
327
+ F2 = 113,
328
+ F3 = 114,
329
+ F4 = 115,
330
+ F5 = 116,
331
+ F6 = 117,
332
+ F7 = 118,
333
+ F8 = 119,
334
+ F9 = 120,
335
+ F10 = 121,
336
+ F11 = 122,
337
+ F12 = 123,
338
+ NumLock = 144,
339
+ ScrollLock = 145,
340
+ Equal = 187,
341
+ Minus = 189,
342
+ Backquote = 192,
343
+ Backslash = 220
350
344
  }
345
+ declare enum KeyMod {
346
+ CtrlCmd = 2048,
347
+ Shift = 1024,
348
+ Alt = 512,
349
+ WinCtrl = 256
350
+ }
351
+
352
+ declare const useKeyboard: UseKeyboard;
351
353
 
352
- declare const useKeyboard: UseKeyboard;
353
-
354
- type KeyboardOptions = {
355
- disableGlobalEvent?: boolean;
356
- stopPropagation?: boolean;
357
- preventDefault?: boolean;
358
- capture?: boolean;
359
- event?: 'keydown' | 'keypress' | 'keyup';
360
- };
361
- type KeyboardResult = {
362
- bindings: {
363
- onKeyDown: React__default.KeyboardEventHandler;
364
- onKeyDownCapture: React__default.KeyboardEventHandler;
365
- onKeyPress: React__default.KeyboardEventHandler;
366
- onKeyPressCapture: React__default.KeyboardEventHandler;
367
- onKeyUp: React__default.KeyboardEventHandler;
368
- onKeyUpCapture: React__default.KeyboardEventHandler;
369
- };
370
- };
371
- type UseKeyboardHandler = (event: React__default.KeyboardEvent | KeyboardEvent) => void;
354
+ type KeyboardOptions = {
355
+ disableGlobalEvent?: boolean;
356
+ stopPropagation?: boolean;
357
+ preventDefault?: boolean;
358
+ capture?: boolean;
359
+ event?: 'keydown' | 'keypress' | 'keyup';
360
+ };
361
+ type KeyboardResult = {
362
+ bindings: {
363
+ onKeyDown: React__default.KeyboardEventHandler;
364
+ onKeyDownCapture: React__default.KeyboardEventHandler;
365
+ onKeyPress: React__default.KeyboardEventHandler;
366
+ onKeyPressCapture: React__default.KeyboardEventHandler;
367
+ onKeyUp: React__default.KeyboardEventHandler;
368
+ onKeyUpCapture: React__default.KeyboardEventHandler;
369
+ };
370
+ };
371
+ type UseKeyboardHandler = (event: React__default.KeyboardEvent | KeyboardEvent) => void;
372
372
  type UseKeyboard = (handler: UseKeyboardHandler, keyBindings: Array<number> | number, options?: KeyboardOptions) => KeyboardResult;
373
373
 
374
- type ILabelContext = (key: string, params?: {
375
- [key: string]: any;
376
- }) => string;
377
- declare const useLabel: () => ILabelContext;
378
- declare function LabelProvider({ children }: {
379
- children?: React__default.ReactNode;
380
- }): react_jsx_runtime.JSX.Element;
381
- declare function parseParams(label: string, params: {
382
- [key: string]: any;
374
+ type ILabelContext = (key: string, params?: {
375
+ [key: string]: any;
376
+ }) => string;
377
+ declare const useLabel: () => ILabelContext;
378
+ declare function LabelProvider({ children }: {
379
+ children?: React__default.ReactNode;
380
+ }): react_jsx_runtime.JSX.Element;
381
+ declare function parseParams(label: string, params: {
382
+ [key: string]: any;
383
383
  }): string;
384
384
 
385
- type ILayoutContext = ILayout;
386
- declare const useLayout: () => ILayout;
387
- declare function LayoutProvider({ children, layout }: {
388
- children?: React__default.ReactNode;
389
- layout: ILayout;
385
+ type ILayoutContext = ILayout;
386
+ declare const useLayout: () => ILayout;
387
+ declare function LayoutProvider({ children, layout }: {
388
+ children?: React__default.ReactNode;
389
+ layout: ILayout;
390
390
  }): react_jsx_runtime.JSX.Element;
391
391
 
392
392
  declare function useModal(): [modal: UIValue, open: (value?: string) => void, close: () => void];
@@ -395,161 +395,161 @@ declare function useMounted(): boolean;
395
395
 
396
396
  declare function useNumber(options?: Intl.NumberFormatOptions, locale?: string): (value: number) => string;
397
397
 
398
- type IPageContext = IPage;
399
- declare const usePage: () => NonNullable<IPage>;
400
- declare function PageProvider({ children, page }: {
401
- children?: React__default.ReactNode;
402
- page: IPage;
398
+ type IPageContext = IPage;
399
+ declare const usePage: () => NonNullable<IPage>;
400
+ declare function PageProvider({ children, page }: {
401
+ children?: React__default.ReactNode;
402
+ page: IPage;
403
403
  }): react_jsx_runtime.JSX.Element;
404
404
 
405
- type IPaginationInfo<T> = {
406
- items: T[];
407
- total: number;
408
- pages: number;
409
- page: number;
410
- perPage: number;
411
- };
405
+ type IPaginationInfo<T> = {
406
+ items: T[];
407
+ total: number;
408
+ pages: number;
409
+ page: number;
410
+ perPage: number;
411
+ };
412
412
  declare function getPagedItems<T>(items: T[], page: number, perPage: number): T[];
413
413
 
414
- declare function usePagination<T>($items: T[], $page?: number, $perPage?: number): {
415
- items: T[];
416
- page: number;
417
- pages: number;
418
- total: number;
419
- nextPage: () => void;
420
- previousPage: () => void;
421
- goToPage: (page: number) => void;
422
- setPerPage: (perPage: number) => void;
414
+ declare function usePagination<T>($items: T[], $page?: number, $perPage?: number): {
415
+ items: T[];
416
+ page: number;
417
+ pages: number;
418
+ total: number;
419
+ nextPage: () => void;
420
+ previousPage: () => void;
421
+ goToPage: (page: number) => void;
422
+ setPerPage: (perPage: number) => void;
423
423
  };
424
424
 
425
- declare function usePortal(name?: string, getContainer?: () => HTMLElement | null): HTMLElement | null;
426
- declare function createElementWithId(id: string): HTMLElement;
425
+ declare function usePortal(name?: string, getContainer?: () => HTMLElement | null): HTMLElement | null;
426
+ declare function createElementWithId(id: string): HTMLElement;
427
427
  declare function getUID(): string;
428
428
 
429
429
  declare function usePrevious<T>(state: T): T | undefined | null;
430
430
 
431
- type SizeType = {
432
- width: number;
433
- height: number;
434
- };
435
- type SizeResult = [SizeType, () => void];
436
- declare function useRealSize<T extends HTMLElement>(ref: MutableRefObject<T | null>): SizeResult;
431
+ type SizeType = {
432
+ width: number;
433
+ height: number;
434
+ };
435
+ type SizeResult = [SizeType, () => void];
436
+ declare function useRealSize<T extends HTMLElement>(ref: MutableRefObject<T | null>): SizeResult;
437
437
  declare function getRealSize(element: HTMLElement | null): SizeType;
438
438
 
439
439
  declare function useResize(callback: () => unknown, immediate?: boolean): void;
440
440
 
441
- type SSRState = {
442
- isBrowser: boolean;
443
- isServer: boolean;
444
- };
445
- declare const detectIsBrowser: () => boolean;
441
+ type SSRState = {
442
+ isBrowser: boolean;
443
+ isServer: boolean;
444
+ };
445
+ declare const detectIsBrowser: () => boolean;
446
446
  declare function useSSR(): SSRState;
447
447
 
448
- type Scroll = {
449
- left: number;
450
- top: number;
451
- };
448
+ type Scroll = {
449
+ left: number;
450
+ top: number;
451
+ };
452
452
  declare function useScroll(): Scroll;
453
453
 
454
- declare function useScrollTo(): (event: React.MouseEvent<HTMLElement>) => void;
455
- declare function scrollToSelector(selector?: string, offset?: number): void;
456
- declare function scrollToRelativeY(y?: number, offset?: number): void;
454
+ declare function useScrollTo(): (event: React.MouseEvent<HTMLElement>) => void;
455
+ declare function scrollToSelector(selector?: string, offset?: number): void;
456
+ declare function scrollToRelativeY(y?: number, offset?: number): void;
457
457
  declare function scrollToY(y?: number): void;
458
458
 
459
459
  declare function useScrolled(callback?: (top: number, left: number) => boolean): boolean;
460
460
 
461
- declare const isBrowser: boolean;
462
- declare function getSearchParams(url: string, key?: string): IParams | string | null;
463
- declare function updateSearchParams(currentPath: string, params: IParams): {
464
- pathname: string;
465
- query: {
466
- [key: string]: string;
467
- };
468
- };
469
- declare function replaceSearchParams(router: NextRouter, params: IParams): void;
470
- declare function pushSearchParams(router: NextRouter, params: IParams): void;
471
- declare function replaceSearchParamsSilently(params: IParams): void;
472
- declare function useSearchParams(): IUseSearchParamsResult;
473
- declare function useSearchParamsValue(key: string): IUseSearchParamsValueResult;
474
- type IUseSearchParamsResult = {
475
- params: IParams;
476
- replaceParamsSilently: (params: IParams) => void;
477
- replaceParams: (params: IParams) => void;
478
- };
479
- type IUseSearchParamsValueResult = {
480
- params: string | null;
481
- replaceParamsSilently: (params: IParams) => void;
482
- };
483
- type IParams = {
484
- [key: string]: string;
485
- };
486
-
487
- declare function decode(encoded: string | null | undefined, key?: string): IParamsEncoded;
488
- declare function getSearchParamsEncoded(url: string, key?: string): {} | null;
489
- declare function updateSearchParamsEncoded(currentPath: string, value: IParamsEncoded, key?: string): {
490
- pathname: string;
491
- query: {
492
- [key: string]: string;
493
- };
494
- };
495
- declare function replaceSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
496
- declare function pushSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
497
- declare function replaceSearchParamsEncodedSilently(value: IParamsEncoded, key?: string): void;
498
- declare function useSearchParamsEncoded(key?: string): IUseSearchParamsEncodedResult;
499
- type IUseSearchParamsEncodedResult = {
500
- params: IParamsEncoded;
501
- replaceParamsSilently: (params: IParamsEncoded) => void;
502
- replaceParams: (params: IParamsEncoded) => void;
503
- };
504
- type IParamsEncoded = {
505
- [key: string]: any;
461
+ declare const isBrowser: boolean;
462
+ declare function getSearchParams(url: string, key?: string): IParams | string | null;
463
+ declare function updateSearchParams(currentPath: string, params: IParams): {
464
+ pathname: string;
465
+ query: {
466
+ [key: string]: string;
467
+ };
468
+ };
469
+ declare function replaceSearchParams(router: NextRouter, params: IParams): void;
470
+ declare function pushSearchParams(router: NextRouter, params: IParams): void;
471
+ declare function replaceSearchParamsSilently(params: IParams): void;
472
+ declare function useSearchParams(): IUseSearchParamsResult;
473
+ declare function useSearchParamsValue(key: string): IUseSearchParamsValueResult;
474
+ type IUseSearchParamsResult = {
475
+ params: IParams;
476
+ replaceParamsSilently: (params: IParams) => void;
477
+ replaceParams: (params: IParams) => void;
478
+ };
479
+ type IUseSearchParamsValueResult = {
480
+ params: string | null;
481
+ replaceParamsSilently: (params: IParams) => void;
482
+ };
483
+ type IParams = {
484
+ [key: string]: string;
485
+ };
486
+
487
+ declare function decode(encoded: string | null | undefined, key?: string): IParamsEncoded;
488
+ declare function getSearchParamsEncoded(url: string, key?: string): {} | null;
489
+ declare function updateSearchParamsEncoded(currentPath: string, value: IParamsEncoded, key?: string): {
490
+ pathname: string;
491
+ query: {
492
+ [key: string]: string;
493
+ };
494
+ };
495
+ declare function replaceSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
496
+ declare function pushSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
497
+ declare function replaceSearchParamsEncodedSilently(value: IParamsEncoded, key?: string): void;
498
+ declare function useSearchParamsEncoded(key?: string): IUseSearchParamsEncodedResult;
499
+ type IUseSearchParamsEncodedResult = {
500
+ params: IParamsEncoded;
501
+ replaceParamsSilently: (params: IParamsEncoded) => void;
502
+ replaceParams: (params: IParamsEncoded) => void;
503
+ };
504
+ type IParamsEncoded = {
505
+ [key: string]: any;
506
506
  } | null;
507
507
 
508
- type Sorting<T> = {
509
- items: T[];
510
- sort?: IEquatable;
511
- };
512
- declare function useSorting<T>(items_: T[], callback_: (items: T[], sort?: IEquatable) => T[], sort_?: IEquatable): {
513
- items: T[];
514
- sort: string | number | undefined;
515
- setSort: (sort?: IEquatable) => void;
508
+ type Sorting<T> = {
509
+ items: T[];
510
+ sort?: IEquatable;
511
+ };
512
+ declare function useSorting<T>(items_: T[], callback_: (items: T[], sort?: IEquatable) => T[], sort_?: IEquatable): {
513
+ items: T[];
514
+ sort: string | number | undefined;
515
+ setSort: (sort?: IEquatable) => void;
516
516
  };
517
517
 
518
518
  declare function useSwiperIndex(): [number, (index: number) => void];
519
519
 
520
- /**
521
- * Like `useRef`, but it returns immutable ref that contains actual value.
522
- *
523
- * @param value
524
- */
525
- declare function useSyncedRef<T>(value: T): {
526
- readonly current: T;
520
+ /**
521
+ * Like `useRef`, but it returns immutable ref that contains actual value.
522
+ *
523
+ * @param value
524
+ */
525
+ declare function useSyncedRef<T>(value: T): {
526
+ readonly current: T;
527
527
  };
528
528
 
529
529
  declare function useUnit(unit?: string, locale?: string): (value: number) => string;
530
530
 
531
- /**
532
- * Run effect only when component is unmounted.
533
- *
534
- * @param effect Effector to run on unmount
535
- */
531
+ /**
532
+ * Run effect only when component is unmounted.
533
+ *
534
+ * @param effect Effector to run on unmount
535
+ */
536
536
  declare function useUnmountEffect(effect: CallableFunction): void;
537
537
 
538
- type UserState = {
539
- user?: IUser;
540
- };
541
- type UserActions = {
542
- setUser: (user?: IUser) => void;
543
- };
544
- type UserStore = UserState & {
545
- actions: UserActions;
546
- };
538
+ type UserState = {
539
+ user?: IUser;
540
+ };
541
+ type UserActions = {
542
+ setUser: (user?: IUser) => void;
543
+ };
544
+ type UserStore = UserState & {
545
+ actions: UserActions;
546
+ };
547
547
  declare const useUser: zustand.UseBoundStore<zustand.StoreApi<UserStore>>;
548
548
 
549
- type WindowSize = {
550
- width: number;
551
- height: number;
552
- };
549
+ type WindowSize = {
550
+ width: number;
551
+ height: number;
552
+ };
553
553
  declare function useWindowSize(): WindowSize;
554
554
 
555
555
  export { BodyScrollOptions, CartContext, CartProvider, CheckoutContext, CheckoutProvider, ClickOutGetContainer, CurrentStateType, ElementStackItem, Filter, FilterMode, FilterParams, FilterValues, GeoLocationSensorState, IFilter, IFilterOption, IGeolocationPositionError, ILabelContext, ILayoutContext, IPageContext, IPaginationInfo, IParams, IParamsEncoded, IUseSearchParamsEncodedResult, IUseSearchParamsResult, IUseSearchParamsValueResult, KeyCode, KeyMod, KeyboardOptions, KeyboardResult, LabelProvider, LayoutProvider, PageProvider, SSRState, SizeResult, SizeType, Sorting, UIReducer, UIValue, UseFiltersResultType, UseKeyboard, UseKeyboardHandler, createElementWithId, createGenericContext, decode, detectIsBrowser, filtersToParams, getCurrentPosition, getFilteredItems, getFilters, getOwnerPaddingRight, getOwnerScrollbarWidth, getPagedItems, getRealSize, getSearchParams, getSearchParamsEncoded, getUID, hasGeolocation, isBrowser, parseParams, pushSearchParams, pushSearchParamsEncoded, replaceSearchParams, replaceSearchParamsEncoded, replaceSearchParamsEncodedSilently, replaceSearchParamsSilently, scrollToRelativeY, scrollToSelector, scrollToY, setFilters, updateSearchParams, updateSearchParamsEncoded, useApi, useApiDelete, useApiFetch, useApiGet, useApiPatch, useApiPost, useApiPut, useBodyScroll, useBreakpoint, useCart, useCheckout, useClickAnyWhere, useClickOut, useCurrency, useCurrentState, useDateTimeFormat, useDebounce, useDebounceCallback, useDebugChangedProps, useDomObserver, useDrawer, useElementSize, useEventListener, useFilters, useGeolocation, useIdle, useInfiniteLoader, useIsomorphicLayoutEffect, useKeyboard, useLabel, useLayout, useModal, useMounted, useNumber, usePage, usePagination, usePortal, usePrevious, useRealSize, useResize, useSSR, useScroll, useScrollTo, useScrolled, useSearchParams, useSearchParamsEncoded, useSearchParamsValue, useSorting, useSwiperIndex, useSyncedRef, useUI, useUnit, useUnmountEffect, useUser, useWindowSize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-hooks",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Mixer Hooks module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -29,28 +29,29 @@
29
29
  "@websolutespa/bom-mixer-store": "*",
30
30
  "framer-motion": ">= 7.2.1",
31
31
  "iron-session": ">= 6.2.1",
32
- "next": ">= 12.3.2",
32
+ "next": ">= 13.4.19",
33
33
  "react-dom": ">= 18.2.0",
34
34
  "react": ">= 18.2.0",
35
- "styled-components": ">= 5.3.5",
35
+ "styled-components": ">= 5.3.11",
36
36
  "swiper": ">= 8.3.2",
37
37
  "zustand": ">= 4.4.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@types/react": "^18.0.18",
41
- "@types/react-dom": "^18.0.6",
40
+ "@types/react": "^18.2.18",
41
+ "@types/react-dom": "^18.2.7",
42
42
  "@types/styled-components": "^5.1.26",
43
43
  "@websolutespa/bom-cli": "*",
44
44
  "@websolutespa/test": "*",
45
45
  "@websolutespa/tsconfig": "*",
46
- "eslint": "^8.36.0",
46
+ "eslint": "^8.46.0",
47
47
  "eslint-config-websolute": "*",
48
48
  "npm-run-all": "^4.1.5",
49
49
  "raw-loader": "^4.0.2",
50
50
  "react": "^18.2.0",
51
+ "styled-components": "^5.3.11",
51
52
  "ts-node": "^10.9.1",
52
53
  "tsup": "^6.7.0",
53
- "typescript": "^4.8.4"
54
+ "typescript": "^5.1.6"
54
55
  },
55
56
  "publishConfig": {
56
57
  "access": "public"