@alexandregme/zljs 2.3.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/CHANGELOG.md +21 -1
- package/dist/{chunk-NM6CB35H.js → chunk-NIKMOT72.js} +307 -35
- package/dist/index.d.ts +26 -43
- package/dist/index.js +122 -396
- package/dist/next/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,25 @@ A change that needs action in an app has a **Migration** note. When updating, re
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.0.0] - 2026-11-10
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Modals on `useAppStore`: `openModal`, `openModalWithPayload`, `closeModal`, `isModalOpen` and `getModalPayload`, each by the id of the modal, which is unique in the app. `modals` has the open ones, by id
|
|
16
|
+
- `appInitialState`, the state `useAppStore` starts with. A test resets the store with `useAppStore.setState(appInitialState)`
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- `ConnectedModal` reads `useAppStore`, the same store as `Loader`. It works as before
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- `useModalStore` and the types `ModalState` and `ModalEntry`. The modals are on `useAppStore`
|
|
25
|
+
|
|
26
|
+
#### Migration
|
|
27
|
+
|
|
28
|
+
Search the app for `useModalStore`. Replace it with `useAppStore`, `isOpen` with `isModalOpen` and `getPayload` with `getModalPayload`. `openModal`, `openModalWithPayload` and `closeModal` keep their names. `modals` is no longer a list: it is an object with the open modals by id, so code that reads it directly uses `isModalOpen`.
|
|
29
|
+
|
|
11
30
|
## [2.3.0] - 2026-11-10
|
|
12
31
|
|
|
13
32
|
### Added
|
|
@@ -392,7 +411,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
|
|
|
392
411
|
|
|
393
412
|
The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
|
|
394
413
|
|
|
395
|
-
[Unreleased]: https://github.com/alexandregme/zljs/compare/
|
|
414
|
+
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.0.0...HEAD
|
|
415
|
+
[3.0.0]: https://github.com/alexandregme/zljs/compare/v2.3.0...v3.0.0
|
|
396
416
|
[2.3.0]: https://github.com/alexandregme/zljs/compare/v2.2.0...v2.3.0
|
|
397
417
|
[2.2.0]: https://github.com/alexandregme/zljs/compare/v2.1.2...v2.2.0
|
|
398
418
|
[2.1.2]: https://github.com/alexandregme/zljs/compare/v2.1.0...v2.1.2
|
|
@@ -61,9 +61,164 @@ var Icon = ({
|
|
|
61
61
|
);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
// core/
|
|
64
|
+
// core/button/button.styles.ts
|
|
65
65
|
import { tv as tv2 } from "tailwind-variants";
|
|
66
|
-
var
|
|
66
|
+
var button = tv2({
|
|
67
|
+
// outline-current covers the colors with no outline class (ghost, none): without it, browsers keep their default focus color.
|
|
68
|
+
base: "cursor-pointer font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center",
|
|
69
|
+
variants: {
|
|
70
|
+
variant: {
|
|
71
|
+
default: "px-4 py-2 text-sm gap-2 rounded-md",
|
|
72
|
+
icon: "p-1 bg-transparent text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md",
|
|
73
|
+
// The invisible ::after grows the touch target to 44px without changing the layout.
|
|
74
|
+
link: "relative text-xs hover:underline rounded-sm after:absolute after:top-1/2 after:left-1/2 after:h-11 after:w-full after:min-w-11 after:-translate-x-1/2 after:-translate-y-1/2"
|
|
75
|
+
},
|
|
76
|
+
color: {
|
|
77
|
+
primary: "bg-zl-primary-bg hover:bg-zl-primary-hover text-zl-primary-on focus-visible:outline-zl-primary",
|
|
78
|
+
success: "bg-zl-success-bg hover:bg-zl-success-hover text-zl-success-on focus-visible:outline-zl-success",
|
|
79
|
+
danger: "bg-zl-danger-bg hover:bg-zl-danger-hover text-zl-danger-on focus-visible:outline-zl-danger",
|
|
80
|
+
warning: "bg-zl-warning-bg hover:bg-zl-warning-hover text-zl-warning-on focus-visible:outline-zl-warning",
|
|
81
|
+
info: "bg-zl-info-bg hover:bg-zl-info-hover text-zl-info-on focus-visible:outline-zl-info",
|
|
82
|
+
muted: "bg-zl-muted-bg hover:bg-zl-muted-hover text-zl-muted-on focus-visible:outline-zl-muted",
|
|
83
|
+
ghost: "bg-transparent text-current hover:text-current hover:bg-neutral-500/20",
|
|
84
|
+
none: ""
|
|
85
|
+
},
|
|
86
|
+
size: {
|
|
87
|
+
sm: "",
|
|
88
|
+
md: "",
|
|
89
|
+
lg: ""
|
|
90
|
+
},
|
|
91
|
+
fullWidth: {
|
|
92
|
+
true: "w-full"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
compoundVariants: [
|
|
96
|
+
{
|
|
97
|
+
variant: "default",
|
|
98
|
+
color: "none",
|
|
99
|
+
class: "bg-gray-100 text-gray-900 hover:bg-gray-200"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
variant: "default",
|
|
103
|
+
size: "sm",
|
|
104
|
+
class: "px-2 py-1 text-xs gap-1"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
variant: "icon",
|
|
108
|
+
size: "sm",
|
|
109
|
+
class: "p-0.5"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
variant: "default",
|
|
113
|
+
size: "lg",
|
|
114
|
+
class: "px-6 py-3 text-base gap-2"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
variant: "icon",
|
|
118
|
+
size: "lg",
|
|
119
|
+
class: "p-2"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
variant: "link",
|
|
123
|
+
color: "primary",
|
|
124
|
+
class: "text-zl-primary hover:text-zl-primary-strong"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
variant: "link",
|
|
128
|
+
color: "success",
|
|
129
|
+
class: "text-zl-success hover:text-zl-success-strong"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
variant: "link",
|
|
133
|
+
color: "danger",
|
|
134
|
+
class: "text-zl-danger hover:text-zl-danger-strong"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
variant: "link",
|
|
138
|
+
color: "warning",
|
|
139
|
+
class: "text-zl-warning hover:text-zl-warning-strong"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
variant: "link",
|
|
143
|
+
color: "info",
|
|
144
|
+
class: "text-zl-info hover:text-zl-info-strong"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
variant: "link",
|
|
148
|
+
color: "muted",
|
|
149
|
+
class: "text-zl-muted hover:text-zl-muted-strong"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
variant: "link",
|
|
153
|
+
color: "none",
|
|
154
|
+
class: "text-slate-600 hover:text-slate-800"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
variant: "link",
|
|
158
|
+
class: "bg-transparent hover:bg-transparent"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
defaultVariants: {
|
|
162
|
+
variant: "default",
|
|
163
|
+
color: "primary",
|
|
164
|
+
size: "md"
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// core/button/button.tsx
|
|
169
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
170
|
+
var Button = ({
|
|
171
|
+
children,
|
|
172
|
+
type = "button",
|
|
173
|
+
variant: variantProp,
|
|
174
|
+
color = "primary",
|
|
175
|
+
size = "md",
|
|
176
|
+
fullWidth = false,
|
|
177
|
+
icon: icon2,
|
|
178
|
+
iconPosition = "left",
|
|
179
|
+
disabled = false,
|
|
180
|
+
"aria-label": ariaLabel,
|
|
181
|
+
onClick
|
|
182
|
+
}) => {
|
|
183
|
+
const isIconOnly = icon2 && !children;
|
|
184
|
+
const variant = variantProp ?? (isIconOnly ? "icon" : "default");
|
|
185
|
+
const renderContent = () => {
|
|
186
|
+
if (!icon2) {
|
|
187
|
+
return children;
|
|
188
|
+
}
|
|
189
|
+
const iconElement = /* @__PURE__ */ jsx2(Icon, { name: icon2, size });
|
|
190
|
+
if (isIconOnly) {
|
|
191
|
+
return iconElement;
|
|
192
|
+
}
|
|
193
|
+
return iconPosition === "left" ? /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
194
|
+
iconElement,
|
|
195
|
+
children
|
|
196
|
+
] }) : /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
197
|
+
children,
|
|
198
|
+
iconElement
|
|
199
|
+
] });
|
|
200
|
+
};
|
|
201
|
+
return /* @__PURE__ */ jsx2(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
type,
|
|
205
|
+
disabled,
|
|
206
|
+
onClick,
|
|
207
|
+
"aria-label": ariaLabel,
|
|
208
|
+
className: button({
|
|
209
|
+
variant,
|
|
210
|
+
color: variant === "icon" && color !== "ghost" ? "none" : color,
|
|
211
|
+
size,
|
|
212
|
+
fullWidth
|
|
213
|
+
}),
|
|
214
|
+
children: renderContent()
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// core/text/text.styles.ts
|
|
220
|
+
import { tv as tv3 } from "tailwind-variants";
|
|
221
|
+
var text = tv3({
|
|
67
222
|
variants: {
|
|
68
223
|
variant: {
|
|
69
224
|
body: "text-base",
|
|
@@ -78,14 +233,80 @@ var text = tv2({
|
|
|
78
233
|
});
|
|
79
234
|
|
|
80
235
|
// core/text/text.tsx
|
|
81
|
-
import { jsx as
|
|
236
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
82
237
|
var Text = ({
|
|
83
238
|
children,
|
|
84
239
|
as: Tag = "p",
|
|
85
240
|
variant = "body",
|
|
86
241
|
color
|
|
87
242
|
}) => {
|
|
88
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ jsx3(Tag, { "data-testid": "text", className: text({ variant, color }), children });
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// core/modal/modal.tsx
|
|
247
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
248
|
+
|
|
249
|
+
// core/modal/modal.styles.ts
|
|
250
|
+
import { tv as tv4 } from "tailwind-variants";
|
|
251
|
+
var overlay = tv4({
|
|
252
|
+
base: "fixed inset-0 bg-black/50"
|
|
253
|
+
});
|
|
254
|
+
var content = tv4({
|
|
255
|
+
base: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-white rounded-lg shadow-lg p-6 w-full focus:outline-none max-h-[90vh] overflow-y-auto",
|
|
256
|
+
variants: {
|
|
257
|
+
size: {
|
|
258
|
+
sm: "max-w-sm",
|
|
259
|
+
md: "max-w-md",
|
|
260
|
+
lg: "max-w-2xl",
|
|
261
|
+
xl: "max-w-4xl",
|
|
262
|
+
full: "max-w-6xl"
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
defaultVariants: {
|
|
266
|
+
size: "md"
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
var header = tv4({
|
|
270
|
+
base: "flex items-start justify-between"
|
|
271
|
+
});
|
|
272
|
+
var title = tv4({
|
|
273
|
+
base: "text-lg font-semibold text-gray-900 m-0"
|
|
274
|
+
});
|
|
275
|
+
var description = tv4({
|
|
276
|
+
base: "text-sm text-gray-600 mt-2"
|
|
277
|
+
});
|
|
278
|
+
var body = tv4({
|
|
279
|
+
base: "mt-4"
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// core/modal/modal.tsx
|
|
283
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
284
|
+
var Modal = ({
|
|
285
|
+
open,
|
|
286
|
+
onClose,
|
|
287
|
+
title: title2,
|
|
288
|
+
description: description2,
|
|
289
|
+
children,
|
|
290
|
+
size = "md"
|
|
291
|
+
}) => {
|
|
292
|
+
return /* @__PURE__ */ jsx4(Dialog.Root, { open, onOpenChange: (isOpen) => !isOpen && onClose(), children: /* @__PURE__ */ jsxs2(Dialog.Portal, { children: [
|
|
293
|
+
/* @__PURE__ */ jsx4(Dialog.Overlay, { className: overlay() }),
|
|
294
|
+
/* @__PURE__ */ jsxs2(
|
|
295
|
+
Dialog.Content,
|
|
296
|
+
{
|
|
297
|
+
className: content({ size }),
|
|
298
|
+
...!description2 && { "aria-describedby": void 0 },
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ jsxs2("div", { className: header(), children: [
|
|
301
|
+
/* @__PURE__ */ jsx4(Dialog.Title, { className: title(), children: title2 }),
|
|
302
|
+
/* @__PURE__ */ jsx4(Button, { icon: "X", "aria-label": "Close", onClick: onClose })
|
|
303
|
+
] }),
|
|
304
|
+
description2 && /* @__PURE__ */ jsx4(Dialog.Description, { className: description(), children: description2 }),
|
|
305
|
+
children && /* @__PURE__ */ jsx4("div", { className: body(), children })
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
] }) });
|
|
89
310
|
};
|
|
90
311
|
|
|
91
312
|
// core/heading/heading.const.ts
|
|
@@ -99,8 +320,8 @@ var headingTags = {
|
|
|
99
320
|
};
|
|
100
321
|
|
|
101
322
|
// core/heading/heading.styles.ts
|
|
102
|
-
import { tv as
|
|
103
|
-
var heading =
|
|
323
|
+
import { tv as tv5 } from "tailwind-variants";
|
|
324
|
+
var heading = tv5({
|
|
104
325
|
variants: {
|
|
105
326
|
level: {
|
|
106
327
|
1: "text-3xl font-bold",
|
|
@@ -118,10 +339,10 @@ var heading = tv3({
|
|
|
118
339
|
});
|
|
119
340
|
|
|
120
341
|
// core/heading/heading.tsx
|
|
121
|
-
import { jsx as
|
|
342
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
122
343
|
var Heading = ({ children, level = 1, color }) => {
|
|
123
344
|
const Tag = headingTags[level];
|
|
124
|
-
return /* @__PURE__ */
|
|
345
|
+
return /* @__PURE__ */ jsx5(Tag, { className: heading({ level, color }), children });
|
|
125
346
|
};
|
|
126
347
|
|
|
127
348
|
// features/toaster/state/toast.store.ts
|
|
@@ -168,9 +389,9 @@ import { useEffect } from "react";
|
|
|
168
389
|
import { Toaster as SonnerToaster, toast } from "sonner";
|
|
169
390
|
|
|
170
391
|
// features/toaster/components/toaster/toaster.styles.ts
|
|
171
|
-
import { tv as
|
|
392
|
+
import { tv as tv6 } from "tailwind-variants";
|
|
172
393
|
var focusOutline = "focus-visible:outline-2! focus-visible:outline-offset-2! focus-visible:outline-current!";
|
|
173
|
-
var toaster =
|
|
394
|
+
var toaster = tv6({
|
|
174
395
|
slots: {
|
|
175
396
|
toast: focusOutline,
|
|
176
397
|
closeButton: focusOutline
|
|
@@ -192,7 +413,7 @@ var toasterColors = {
|
|
|
192
413
|
};
|
|
193
414
|
|
|
194
415
|
// features/toaster/components/toaster/toaster.tsx
|
|
195
|
-
import { jsx as
|
|
416
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
196
417
|
var Toaster = () => {
|
|
197
418
|
const toasts = useToastStore((s) => s.toasts);
|
|
198
419
|
const removeToast = useToastStore((s) => s.removeToast);
|
|
@@ -203,7 +424,7 @@ var Toaster = () => {
|
|
|
203
424
|
removeToast(t.id);
|
|
204
425
|
});
|
|
205
426
|
}, [toasts, removeToast]);
|
|
206
|
-
return /* @__PURE__ */
|
|
427
|
+
return /* @__PURE__ */ jsx6(
|
|
207
428
|
SonnerToaster,
|
|
208
429
|
{
|
|
209
430
|
position: "bottom-right",
|
|
@@ -223,21 +444,20 @@ var Toaster = () => {
|
|
|
223
444
|
// features/toaster/components/toaster/index.ts
|
|
224
445
|
import { toast as toast2 } from "sonner";
|
|
225
446
|
|
|
226
|
-
// features/app/state/app.store.ts
|
|
227
|
-
import { create as create2 } from "zustand";
|
|
228
|
-
import { devtools as devtools2 } from "zustand/middleware";
|
|
229
|
-
|
|
230
447
|
// features/app/state/app.const.ts
|
|
231
448
|
var appInitialState = {
|
|
232
449
|
fetchingCalls: 0,
|
|
233
|
-
fetching: false
|
|
450
|
+
fetching: false,
|
|
451
|
+
modals: {}
|
|
234
452
|
};
|
|
235
453
|
var appDevtools = { name: "zljs", store: "app" };
|
|
236
454
|
|
|
237
455
|
// features/app/state/app.store.ts
|
|
456
|
+
import { create as create2 } from "zustand";
|
|
457
|
+
import { devtools as devtools2 } from "zustand/middleware";
|
|
238
458
|
var useAppStore = create2()(
|
|
239
459
|
devtools2(
|
|
240
|
-
(set) => ({
|
|
460
|
+
(set, get) => ({
|
|
241
461
|
...appInitialState,
|
|
242
462
|
startFetching: () => set(
|
|
243
463
|
(s) => {
|
|
@@ -254,12 +474,60 @@ var useAppStore = create2()(
|
|
|
254
474
|
},
|
|
255
475
|
false,
|
|
256
476
|
"finishFetching"
|
|
257
|
-
)
|
|
477
|
+
),
|
|
478
|
+
openModal: (id) => set(
|
|
479
|
+
(s) => ({ modals: { ...s.modals, [id]: void 0 } }),
|
|
480
|
+
false,
|
|
481
|
+
"openModal"
|
|
482
|
+
),
|
|
483
|
+
openModalWithPayload: (id, payload) => set(
|
|
484
|
+
(s) => ({ modals: { ...s.modals, [id]: payload } }),
|
|
485
|
+
false,
|
|
486
|
+
"openModalWithPayload"
|
|
487
|
+
),
|
|
488
|
+
closeModal: (id) => set(
|
|
489
|
+
(s) => {
|
|
490
|
+
const modals = { ...s.modals };
|
|
491
|
+
delete modals[id];
|
|
492
|
+
return { modals };
|
|
493
|
+
},
|
|
494
|
+
false,
|
|
495
|
+
"closeModal"
|
|
496
|
+
),
|
|
497
|
+
isModalOpen: (id) => Object.keys(get().modals).includes(id),
|
|
498
|
+
getModalPayload: (id) => get().modals[id]
|
|
258
499
|
}),
|
|
259
500
|
appDevtools
|
|
260
501
|
)
|
|
261
502
|
);
|
|
262
503
|
|
|
504
|
+
// features/app/components/connected-modal/connected-modal.tsx
|
|
505
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
506
|
+
var ConnectedModal = ({
|
|
507
|
+
modalId,
|
|
508
|
+
title: title2,
|
|
509
|
+
description: description2,
|
|
510
|
+
size,
|
|
511
|
+
children
|
|
512
|
+
}) => {
|
|
513
|
+
const open = useAppStore((s) => s.isModalOpen(modalId));
|
|
514
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
515
|
+
const close = () => {
|
|
516
|
+
closeModal(modalId);
|
|
517
|
+
};
|
|
518
|
+
return /* @__PURE__ */ jsx7(
|
|
519
|
+
Modal,
|
|
520
|
+
{
|
|
521
|
+
open,
|
|
522
|
+
onClose: close,
|
|
523
|
+
title: title2,
|
|
524
|
+
description: description2,
|
|
525
|
+
size,
|
|
526
|
+
children
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
};
|
|
530
|
+
|
|
263
531
|
// core/spinner/spinner.const.ts
|
|
264
532
|
var spinnerIcons = {
|
|
265
533
|
circle: "LoaderCircle",
|
|
@@ -268,47 +536,47 @@ var spinnerIcons = {
|
|
|
268
536
|
};
|
|
269
537
|
|
|
270
538
|
// core/spinner/spinner.styles.ts
|
|
271
|
-
import { tv as
|
|
272
|
-
var spinner =
|
|
539
|
+
import { tv as tv7 } from "tailwind-variants";
|
|
540
|
+
var spinner = tv7({
|
|
273
541
|
base: "inline-flex animate-spin"
|
|
274
542
|
});
|
|
275
543
|
|
|
276
544
|
// core/spinner/spinner.tsx
|
|
277
|
-
import { jsx as
|
|
545
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
278
546
|
var Spinner = ({
|
|
279
547
|
variant = "circle",
|
|
280
548
|
size = "md",
|
|
281
549
|
label = "Loading"
|
|
282
|
-
}) => /* @__PURE__ */
|
|
550
|
+
}) => /* @__PURE__ */ jsx8(
|
|
283
551
|
"span",
|
|
284
552
|
{
|
|
285
553
|
"data-testid": "spinner",
|
|
286
554
|
role: "status",
|
|
287
555
|
"aria-label": label,
|
|
288
556
|
className: spinner(),
|
|
289
|
-
children: /* @__PURE__ */
|
|
557
|
+
children: /* @__PURE__ */ jsx8(Icon, { name: spinnerIcons[variant], size })
|
|
290
558
|
}
|
|
291
559
|
);
|
|
292
560
|
|
|
293
561
|
// features/app/components/loader/loader.styles.ts
|
|
294
|
-
import { tv as
|
|
295
|
-
var loader =
|
|
562
|
+
import { tv as tv8 } from "tailwind-variants";
|
|
563
|
+
var loader = tv8({
|
|
296
564
|
base: "flex fixed inset-0 justify-center items-center bg-black/20 text-zl-primary z-50"
|
|
297
565
|
});
|
|
298
566
|
|
|
299
567
|
// features/app/components/loader/loader.tsx
|
|
300
|
-
import { jsx as
|
|
568
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
301
569
|
var Loader = ({ label = "Loading" }) => {
|
|
302
570
|
const fetching = useAppStore((s) => s.fetching);
|
|
303
571
|
if (!fetching) return null;
|
|
304
|
-
return /* @__PURE__ */
|
|
572
|
+
return /* @__PURE__ */ jsx9("div", { className: loader(), children: /* @__PURE__ */ jsx9(Spinner, { size: "lg", label }) });
|
|
305
573
|
};
|
|
306
574
|
|
|
307
575
|
// features/providers/components/zustand-providers/zustand-providers.tsx
|
|
308
|
-
import { Fragment as
|
|
309
|
-
var ZustandProviders = ({ children }) => /* @__PURE__ */
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
576
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
577
|
+
var ZustandProviders = ({ children }) => /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
578
|
+
/* @__PURE__ */ jsx10(Loader, {}),
|
|
579
|
+
/* @__PURE__ */ jsx10(Toaster, {}),
|
|
312
580
|
children
|
|
313
581
|
] });
|
|
314
582
|
|
|
@@ -346,7 +614,7 @@ var createReduxStore = ({
|
|
|
346
614
|
};
|
|
347
615
|
|
|
348
616
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
349
|
-
import { jsx as
|
|
617
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
350
618
|
var ReduxProvider = ({
|
|
351
619
|
children,
|
|
352
620
|
reducers = {},
|
|
@@ -362,7 +630,7 @@ var ReduxProvider = ({
|
|
|
362
630
|
coreReducers
|
|
363
631
|
})
|
|
364
632
|
);
|
|
365
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ jsx11(Provider, { store, children });
|
|
366
634
|
};
|
|
367
635
|
|
|
368
636
|
// core/state/zustand/router/router.utils.ts
|
|
@@ -416,7 +684,7 @@ var usePageStore = create4()(
|
|
|
416
684
|
devtools4(
|
|
417
685
|
(set) => ({
|
|
418
686
|
...pageInitialState,
|
|
419
|
-
setTitle: (
|
|
687
|
+
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
420
688
|
}),
|
|
421
689
|
pageDevtools
|
|
422
690
|
)
|
|
@@ -424,12 +692,16 @@ var usePageStore = create4()(
|
|
|
424
692
|
|
|
425
693
|
export {
|
|
426
694
|
Icon,
|
|
695
|
+
Button,
|
|
427
696
|
Text,
|
|
697
|
+
Modal,
|
|
428
698
|
Heading,
|
|
429
699
|
useToastStore,
|
|
430
700
|
Toaster,
|
|
431
701
|
toast2 as toast,
|
|
702
|
+
appInitialState,
|
|
432
703
|
useAppStore,
|
|
704
|
+
ConnectedModal,
|
|
433
705
|
Spinner,
|
|
434
706
|
Loader,
|
|
435
707
|
ZustandProviders,
|
package/dist/index.d.ts
CHANGED
|
@@ -309,6 +309,17 @@ declare const useToastStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ToastSt
|
|
|
309
309
|
};
|
|
310
310
|
}>;
|
|
311
311
|
|
|
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
|
+
|
|
312
323
|
interface LoaderProps {
|
|
313
324
|
label?: string;
|
|
314
325
|
}
|
|
@@ -318,10 +329,23 @@ declare const Loader: ({ label }: LoaderProps) => react.JSX.Element | null;
|
|
|
318
329
|
interface AppState {
|
|
319
330
|
fetchingCalls: number;
|
|
320
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>;
|
|
321
338
|
startFetching: () => void;
|
|
322
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;
|
|
323
345
|
}
|
|
324
346
|
|
|
347
|
+
declare const appInitialState: Pick<AppState, "fetchingCalls" | "fetching" | "modals">;
|
|
348
|
+
|
|
325
349
|
declare const useAppStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppState>, "setState" | "devtools"> & {
|
|
326
350
|
setState(partial: AppState | Partial<AppState> | ((state: AppState) => AppState | Partial<AppState>), replace?: false | undefined, action?: (string | {
|
|
327
351
|
[x: string]: unknown;
|
|
@@ -346,37 +370,6 @@ interface ZustandProvidersProps {
|
|
|
346
370
|
|
|
347
371
|
declare const ZustandProviders: ({ children }: ZustandProvidersProps) => react.JSX.Element;
|
|
348
372
|
|
|
349
|
-
interface ModalEntry {
|
|
350
|
-
name: string;
|
|
351
|
-
payload?: unknown;
|
|
352
|
-
}
|
|
353
|
-
interface ModalState {
|
|
354
|
-
modals: ModalEntry[];
|
|
355
|
-
openModal: (name: string) => void;
|
|
356
|
-
openModalWithPayload: (name: string, payload: unknown) => void;
|
|
357
|
-
closeModal: (name: string) => void;
|
|
358
|
-
isOpen: (name: string) => boolean;
|
|
359
|
-
getPayload: (name: string) => unknown | undefined;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
declare const useModalStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ModalState>, "setState" | "devtools"> & {
|
|
363
|
-
setState(partial: ModalState | Partial<ModalState> | ((state: ModalState) => ModalState | Partial<ModalState>), replace?: false | undefined, action?: (string | {
|
|
364
|
-
[x: string]: unknown;
|
|
365
|
-
[x: number]: unknown;
|
|
366
|
-
[x: symbol]: unknown;
|
|
367
|
-
type: string;
|
|
368
|
-
}) | undefined): void;
|
|
369
|
-
setState(state: ModalState | ((state: ModalState) => ModalState), replace: true, action?: (string | {
|
|
370
|
-
[x: string]: unknown;
|
|
371
|
-
[x: number]: unknown;
|
|
372
|
-
[x: symbol]: unknown;
|
|
373
|
-
type: string;
|
|
374
|
-
}) | undefined): void;
|
|
375
|
-
devtools: {
|
|
376
|
-
cleanup: () => void;
|
|
377
|
-
};
|
|
378
|
-
}>;
|
|
379
|
-
|
|
380
373
|
declare const ReduxProvider: ({ children, reducers, middlewares, preloadedState, coreReducers, }: ReduxProviderProps) => react.JSX.Element;
|
|
381
374
|
|
|
382
375
|
interface ReduxStore extends Store {
|
|
@@ -432,16 +425,6 @@ declare const usePageStore: zustand.UseBoundStore<Omit<zustand.StoreApi<PageStat
|
|
|
432
425
|
};
|
|
433
426
|
}>;
|
|
434
427
|
|
|
435
|
-
interface ConnectedModalProps {
|
|
436
|
-
modalId: string;
|
|
437
|
-
title: string;
|
|
438
|
-
description?: string;
|
|
439
|
-
size?: ModalSize;
|
|
440
|
-
children?: ReactNode;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
declare const ConnectedModal: ({ modalId, title, description, size, children, }: ConnectedModalProps) => react.JSX.Element;
|
|
444
|
-
|
|
445
428
|
interface CardProps {
|
|
446
429
|
children: ReactNode;
|
|
447
430
|
/** Shows above the children, as a heading. */
|
|
@@ -488,5 +471,5 @@ declare class HTTPClient {
|
|
|
488
471
|
patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
|
|
489
472
|
}
|
|
490
473
|
|
|
491
|
-
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, splitURLasPath, useAppStore,
|
|
492
|
-
export type { AppState, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps,
|
|
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 };
|