@alexandregme/zljs 2.2.0 → 3.0.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/dist/index.d.ts CHANGED
@@ -275,31 +275,6 @@ declare const Tag: ({ children, color, onRemove, removeLabel, }: TagProps) => re
275
275
 
276
276
  declare const Toaster: () => react.JSX.Element;
277
277
 
278
- interface AppState {
279
- fetchingCalls: number;
280
- fetching: boolean;
281
- startFetching: () => void;
282
- finishFetching: () => void;
283
- }
284
-
285
- declare const useAppStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppState>, "setState" | "devtools"> & {
286
- setState(partial: AppState | Partial<AppState> | ((state: AppState) => AppState | Partial<AppState>), replace?: false | undefined, action?: (string | {
287
- [x: string]: unknown;
288
- [x: number]: unknown;
289
- [x: symbol]: unknown;
290
- type: string;
291
- }) | undefined): void;
292
- setState(state: AppState | ((state: AppState) => AppState), replace: true, action?: (string | {
293
- [x: string]: unknown;
294
- [x: number]: unknown;
295
- [x: symbol]: unknown;
296
- type: string;
297
- }) | undefined): void;
298
- devtools: {
299
- cleanup: () => void;
300
- };
301
- }>;
302
-
303
278
  type ToastType = "success" | "error" | "info" | "warning";
304
279
  interface Toast {
305
280
  id: number;
@@ -334,27 +309,51 @@ declare const useToastStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ToastSt
334
309
  };
335
310
  }>;
336
311
 
337
- interface ModalEntry {
338
- name: string;
339
- payload?: unknown;
312
+ interface ConnectedModalProps {
313
+ /** The id of the modal in `useAppStore`, unique in the app: `openModal(modalId)` shows it. */
314
+ modalId: string;
315
+ title: string;
316
+ description?: string;
317
+ size?: ModalSize;
318
+ children?: ReactNode;
319
+ }
320
+
321
+ declare const ConnectedModal: ({ modalId, title, description, size, children, }: ConnectedModalProps) => react.JSX.Element;
322
+
323
+ interface LoaderProps {
324
+ label?: string;
340
325
  }
341
- interface ModalState {
342
- modals: ModalEntry[];
343
- openModal: (name: string) => void;
344
- openModalWithPayload: (name: string, payload: unknown) => void;
345
- closeModal: (name: string) => void;
346
- isOpen: (name: string) => boolean;
347
- getPayload: (name: string) => unknown | undefined;
326
+
327
+ declare const Loader: ({ label }: LoaderProps) => react.JSX.Element | null;
328
+
329
+ interface AppState {
330
+ fetchingCalls: number;
331
+ fetching: boolean;
332
+ /**
333
+ * The modals open now: each key is the id of a modal, unique in the app, and
334
+ * its value is the payload it was opened with. `ConnectedModal` shows the
335
+ * one with its `modalId`.
336
+ */
337
+ modals: Record<string, unknown>;
338
+ startFetching: () => void;
339
+ finishFetching: () => void;
340
+ openModal: (id: string) => void;
341
+ openModalWithPayload: (id: string, payload: unknown) => void;
342
+ closeModal: (id: string) => void;
343
+ isModalOpen: (id: string) => boolean;
344
+ getModalPayload: (id: string) => unknown | undefined;
348
345
  }
349
346
 
350
- declare const useModalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ModalState>, "setState" | "devtools"> & {
351
- setState(partial: ModalState | Partial<ModalState> | ((state: ModalState) => ModalState | Partial<ModalState>), replace?: false | undefined, action?: (string | {
347
+ declare const appInitialState: Pick<AppState, "fetchingCalls" | "fetching" | "modals">;
348
+
349
+ declare const useAppStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppState>, "setState" | "devtools"> & {
350
+ setState(partial: AppState | Partial<AppState> | ((state: AppState) => AppState | Partial<AppState>), replace?: false | undefined, action?: (string | {
352
351
  [x: string]: unknown;
353
352
  [x: number]: unknown;
354
353
  [x: symbol]: unknown;
355
354
  type: string;
356
355
  }) | undefined): void;
357
- setState(state: ModalState | ((state: ModalState) => ModalState), replace: true, action?: (string | {
356
+ setState(state: AppState | ((state: AppState) => AppState), replace: true, action?: (string | {
358
357
  [x: string]: unknown;
359
358
  [x: number]: unknown;
360
359
  [x: symbol]: unknown;
@@ -365,6 +364,12 @@ declare const useModalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ModalSt
365
364
  };
366
365
  }>;
367
366
 
367
+ interface ZustandProvidersProps {
368
+ children: ReactNode;
369
+ }
370
+
371
+ declare const ZustandProviders: ({ children }: ZustandProvidersProps) => react.JSX.Element;
372
+
368
373
  declare const ReduxProvider: ({ children, reducers, middlewares, preloadedState, coreReducers, }: ReduxProviderProps) => react.JSX.Element;
369
374
 
370
375
  interface ReduxStore extends Store {
@@ -420,16 +425,6 @@ declare const usePageStore: zustand.UseBoundStore<Omit<zustand.StoreApi<PageStat
420
425
  };
421
426
  }>;
422
427
 
423
- interface ConnectedModalProps {
424
- modalId: string;
425
- title: string;
426
- description?: string;
427
- size?: ModalSize;
428
- children?: ReactNode;
429
- }
430
-
431
- declare const ConnectedModal: ({ modalId, title, description, size, children, }: ConnectedModalProps) => react.JSX.Element;
432
-
433
428
  interface CardProps {
434
429
  children: ReactNode;
435
430
  /** Shows above the children, as a heading. */
@@ -453,12 +448,6 @@ interface SpinnerProps {
453
448
 
454
449
  declare const Spinner: ({ variant, size, label, }: SpinnerProps) => react.JSX.Element;
455
450
 
456
- interface LoaderProps {
457
- label?: string;
458
- }
459
-
460
- declare const Loader: ({ label }: LoaderProps) => react.JSX.Element | null;
461
-
462
451
  interface HttpClientConfig {
463
452
  baseUrl?: string;
464
453
  headers?: Record<string, string>;
@@ -482,5 +471,5 @@ declare class HTTPClient {
482
471
  patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
483
472
  }
484
473
 
485
- export { AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, Loader, Modal, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, splitURLasPath, useAppStore, useModalStore, usePageStore, useRouterStore, useToastStore };
486
- export type { AppState, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps, ModalEntry, ModalProps, ModalState, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
474
+ export { AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, Loader, Modal, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, ZustandProviders, appInitialState, splitURLasPath, useAppStore, usePageStore, useRouterStore, useToastStore };
475
+ export type { AppState, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps, ModalProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps, ZustandProvidersProps };