@emiketic/lib-mantine 1.0.0 → 1.0.2
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.js +215 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +627 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -5
- package/dist/index.cjs +0 -663
- package/dist/index.cjs.map +0 -1
- /package/dist/{index.d.cts → index.d.mts} +0 -0
package/dist/index.cjs
DELETED
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
ClientOnly: () => ClientOnly,
|
|
34
|
-
ConfirmBar: () => ConfirmBar_default,
|
|
35
|
-
ContentLoader: () => ContentLoader_default,
|
|
36
|
-
ImageInput: () => ImageInput_default,
|
|
37
|
-
Logo: () => Logo_default,
|
|
38
|
-
NativePDFViewer: () => NativePDFViewer,
|
|
39
|
-
NoData: () => NoData_default,
|
|
40
|
-
PageContainer: () => PageContainer_default,
|
|
41
|
-
PhoneInput: () => PhoneInput_default,
|
|
42
|
-
TextEditor: () => TextEditor_default,
|
|
43
|
-
ThemeToggle: () => ThemeToggle_default
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(src_exports);
|
|
46
|
-
|
|
47
|
-
// src/components/ClientOnly/index.tsx
|
|
48
|
-
var import_react = require("react");
|
|
49
|
-
var import_core = require("@mantine/core");
|
|
50
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
-
function ClientOnly({
|
|
52
|
-
children,
|
|
53
|
-
withLoader = false,
|
|
54
|
-
...delegated
|
|
55
|
-
}) {
|
|
56
|
-
const [hasMounted, setHasMounted] = (0, import_react.useState)(false);
|
|
57
|
-
(0, import_react.useEffect)(() => {
|
|
58
|
-
setHasMounted(true);
|
|
59
|
-
}, []);
|
|
60
|
-
if (!hasMounted) {
|
|
61
|
-
if (withLoader) {
|
|
62
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.LoadingOverlay, {});
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...delegated, children });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/components/ConfirmBar/index.tsx
|
|
70
|
-
var import_core2 = require("@mantine/core");
|
|
71
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
72
|
-
function ConfirmBar({
|
|
73
|
-
onConfirm = () => {
|
|
74
|
-
},
|
|
75
|
-
onCancel = () => {
|
|
76
|
-
},
|
|
77
|
-
disabled = false,
|
|
78
|
-
loading = false,
|
|
79
|
-
labelProps,
|
|
80
|
-
color,
|
|
81
|
-
withCancel = true,
|
|
82
|
-
...props
|
|
83
|
-
}) {
|
|
84
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Box, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Group, { h: "100%", justify: "flex-end", align: "center", children: [
|
|
85
|
-
withCancel ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Button, { onClick: () => onCancel(), variant: "subtle", children: labelProps?.cancel ?? "Cancel" }) : null,
|
|
86
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
87
|
-
import_core2.Button,
|
|
88
|
-
{
|
|
89
|
-
onClick: () => onConfirm(),
|
|
90
|
-
disabled,
|
|
91
|
-
variant: "filled",
|
|
92
|
-
loading,
|
|
93
|
-
color,
|
|
94
|
-
children: labelProps?.confirm ?? "Confirm"
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
] }) });
|
|
98
|
-
}
|
|
99
|
-
var ConfirmBar_default = ConfirmBar;
|
|
100
|
-
|
|
101
|
-
// src/components/ContentLoader/index.tsx
|
|
102
|
-
var import_react2 = require("react");
|
|
103
|
-
var import_core3 = require("@mantine/core");
|
|
104
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
105
|
-
function ContentLoader({
|
|
106
|
-
numberOfBars = 3,
|
|
107
|
-
numberOfBarGroups = 3,
|
|
108
|
-
barHeight = 15,
|
|
109
|
-
barSpacing = 6,
|
|
110
|
-
barGroupSpacing = "lg",
|
|
111
|
-
visible = true,
|
|
112
|
-
withCircle = false,
|
|
113
|
-
...props
|
|
114
|
-
}) {
|
|
115
|
-
if (!visible) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core3.Stack, { gap: "sm", px: "5rem", py: "md", ...props, children: [
|
|
119
|
-
withCircle ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.Skeleton, { height: 70, circle: true, mb: "xl" }) : null,
|
|
120
|
-
Array.from({ length: numberOfBarGroups }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.Fragment, { children: [
|
|
121
|
-
Array.from({ length: Math.ceil(numberOfBars / numberOfBarGroups) }).map((_2, index2) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react2.Fragment, { children: [
|
|
122
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.Skeleton, { height: barHeight, radius: "xl" }),
|
|
123
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.Skeleton, { height: barHeight, mt: barSpacing, radius: "xl" }),
|
|
124
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.Skeleton, { height: barHeight, mt: barSpacing, width: "70%", radius: "xl" })
|
|
125
|
-
] }, index2)),
|
|
126
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.Space, { h: barGroupSpacing })
|
|
127
|
-
] }, index))
|
|
128
|
-
] });
|
|
129
|
-
}
|
|
130
|
-
var ContentLoader_default = ContentLoader;
|
|
131
|
-
|
|
132
|
-
// src/components/ImageInput/index.tsx
|
|
133
|
-
var import_react3 = require("react");
|
|
134
|
-
var import_core4 = require("@mantine/core");
|
|
135
|
-
var import_icons_react = require("@tabler/icons-react");
|
|
136
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
137
|
-
var DEFAULT_MAX_FILE_SIZE_BYTES = 5e5;
|
|
138
|
-
var isClient = () => typeof window !== "undefined";
|
|
139
|
-
function ImageInput({
|
|
140
|
-
value,
|
|
141
|
-
withPreview = true,
|
|
142
|
-
maxFileSizeBytes = DEFAULT_MAX_FILE_SIZE_BYTES,
|
|
143
|
-
...props
|
|
144
|
-
}) {
|
|
145
|
-
const [imageUrl, setImageUrl] = (0, import_react3.useState)(null);
|
|
146
|
-
const largeFile = isClient() && value && value instanceof File && value.size >= maxFileSizeBytes;
|
|
147
|
-
const isFileValue = isClient() && value instanceof File;
|
|
148
|
-
const isString = typeof value == "string";
|
|
149
|
-
(0, import_react3.useEffect)(() => {
|
|
150
|
-
if (isFileValue) {
|
|
151
|
-
setImageUrl(URL.createObjectURL(value));
|
|
152
|
-
} else if (isString) {
|
|
153
|
-
setImageUrl(value);
|
|
154
|
-
}
|
|
155
|
-
}, [value, isFileValue, isString]);
|
|
156
|
-
if (props.disabled && !isFileValue) {
|
|
157
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
158
|
-
import_core4.Avatar,
|
|
159
|
-
{
|
|
160
|
-
size: "xl",
|
|
161
|
-
src: imageUrl,
|
|
162
|
-
...props.disabledPlaceholderProps
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_core4.Group, { children: [
|
|
167
|
-
withPreview && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.Paper, { radius: "md", p: "sm", withBorder: true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
168
|
-
import_core4.Image,
|
|
169
|
-
{
|
|
170
|
-
w: "5rem",
|
|
171
|
-
h: "5rem",
|
|
172
|
-
fit: "contain",
|
|
173
|
-
radius: "sm",
|
|
174
|
-
src: imageUrl,
|
|
175
|
-
...props.previewProps
|
|
176
|
-
}
|
|
177
|
-
) }),
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
179
|
-
import_core4.FileInput,
|
|
180
|
-
{
|
|
181
|
-
styles: { input: { fontSize: "var(--mantine-font-size-xs)" } },
|
|
182
|
-
leftSection: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ActionIcon, { variant: "light", size: "xs", color: "gray", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons_react.IconUpload, {}) }),
|
|
183
|
-
placeholder: "Upload",
|
|
184
|
-
error: largeFile ? `File size must be under ${maxFileSizeBytes / 1e3} KB` : void 0,
|
|
185
|
-
onChange: (file) => {
|
|
186
|
-
props.onChange?.(file);
|
|
187
|
-
if (file) {
|
|
188
|
-
setImageUrl(URL.createObjectURL(file));
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
...props
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
] });
|
|
195
|
-
}
|
|
196
|
-
var ImageInput_default = ImageInput;
|
|
197
|
-
|
|
198
|
-
// src/components/Logo/index.tsx
|
|
199
|
-
var import_react4 = require("react");
|
|
200
|
-
var import_core6 = require("@mantine/core");
|
|
201
|
-
|
|
202
|
-
// src/utils/colors.ts
|
|
203
|
-
var import_chroma_js = __toESM(require("chroma-js"), 1);
|
|
204
|
-
var import_core5 = require("@mantine/core");
|
|
205
|
-
function loadImage(imageUrl) {
|
|
206
|
-
return new Promise((resolve, reject) => {
|
|
207
|
-
const image = new Image();
|
|
208
|
-
image.crossOrigin = "anonymous";
|
|
209
|
-
image.referrerPolicy = "no-referrer";
|
|
210
|
-
image.onload = () => resolve(image);
|
|
211
|
-
image.onerror = () => reject(new Error("Could not load image for color extraction"));
|
|
212
|
-
image.src = imageUrl;
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
function quantizeChannel(value) {
|
|
216
|
-
return Math.round(value / 16) * 16;
|
|
217
|
-
}
|
|
218
|
-
function extractQuantizedPixels(imageData) {
|
|
219
|
-
const colors = [];
|
|
220
|
-
for (let index = 0; index < imageData.length; index += 4) {
|
|
221
|
-
const alpha = imageData[index + 3] ?? 0;
|
|
222
|
-
if (alpha < 16) continue;
|
|
223
|
-
const red = quantizeChannel(imageData[index] ?? 0);
|
|
224
|
-
const green = quantizeChannel(imageData[index + 1] ?? 0);
|
|
225
|
-
const blue = quantizeChannel(imageData[index + 2] ?? 0);
|
|
226
|
-
colors.push((0, import_chroma_js.default)(red, green, blue).hex());
|
|
227
|
-
}
|
|
228
|
-
return colors;
|
|
229
|
-
}
|
|
230
|
-
function extractEdgeQuantizedPixels(imageData, width, height) {
|
|
231
|
-
const edgeColors = [];
|
|
232
|
-
const edgeThickness = Math.max(1, Math.floor(Math.min(width, height) * 0.1));
|
|
233
|
-
for (let y = 0; y < height; y += 1) {
|
|
234
|
-
for (let x = 0; x < width; x += 1) {
|
|
235
|
-
const isEdge = x < edgeThickness || x >= width - edgeThickness || y < edgeThickness || y >= height - edgeThickness;
|
|
236
|
-
if (!isEdge) continue;
|
|
237
|
-
const pixelIndex = (y * width + x) * 4;
|
|
238
|
-
const alpha = imageData[pixelIndex + 3] ?? 0;
|
|
239
|
-
if (alpha < 16) continue;
|
|
240
|
-
const red = quantizeChannel(imageData[pixelIndex] ?? 0);
|
|
241
|
-
const green = quantizeChannel(imageData[pixelIndex + 1] ?? 0);
|
|
242
|
-
const blue = quantizeChannel(imageData[pixelIndex + 2] ?? 0);
|
|
243
|
-
edgeColors.push((0, import_chroma_js.default)(red, green, blue).hex());
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return edgeColors;
|
|
247
|
-
}
|
|
248
|
-
function getMostFrequentColor(colors) {
|
|
249
|
-
if (colors.length === 0) return null;
|
|
250
|
-
const frequencies = /* @__PURE__ */ new Map();
|
|
251
|
-
for (const color of colors) {
|
|
252
|
-
frequencies.set(color, (frequencies.get(color) ?? 0) + 1);
|
|
253
|
-
}
|
|
254
|
-
let selectedColor = null;
|
|
255
|
-
let selectedCount = 0;
|
|
256
|
-
for (const [color, count] of frequencies.entries()) {
|
|
257
|
-
if (count > selectedCount) {
|
|
258
|
-
selectedColor = color;
|
|
259
|
-
selectedCount = count;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return selectedColor;
|
|
263
|
-
}
|
|
264
|
-
var getDominantColorFromImageUrl = async (imageUrl, fallbackDominantColor = "#000000", fallbackBackgroundColor = "#ffffff") => {
|
|
265
|
-
try {
|
|
266
|
-
const image = await loadImage(imageUrl);
|
|
267
|
-
const canvas = document.createElement("canvas");
|
|
268
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
269
|
-
if (!context) {
|
|
270
|
-
return { dominant: fallbackDominantColor, background: fallbackBackgroundColor };
|
|
271
|
-
}
|
|
272
|
-
const maxSize = 96;
|
|
273
|
-
const ratio = Math.min(maxSize / image.naturalWidth, maxSize / image.naturalHeight, 1);
|
|
274
|
-
canvas.width = Math.max(1, Math.round(image.naturalWidth * ratio));
|
|
275
|
-
canvas.height = Math.max(1, Math.round(image.naturalHeight * ratio));
|
|
276
|
-
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
277
|
-
const imageData = context.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
278
|
-
const allPixels = extractQuantizedPixels(imageData);
|
|
279
|
-
const edgePixels = extractEdgeQuantizedPixels(imageData, canvas.width, canvas.height);
|
|
280
|
-
const background = getMostFrequentColor(edgePixels) ?? getMostFrequentColor(allPixels);
|
|
281
|
-
const dominant = getMostFrequentColor(
|
|
282
|
-
background ? allPixels.filter((hex) => import_chroma_js.default.distance(hex, background, "rgb") > 28) : allPixels
|
|
283
|
-
) ?? getMostFrequentColor(allPixels);
|
|
284
|
-
return {
|
|
285
|
-
dominant: dominant ?? fallbackDominantColor,
|
|
286
|
-
background: background ?? fallbackBackgroundColor
|
|
287
|
-
};
|
|
288
|
-
} catch {
|
|
289
|
-
return { dominant: fallbackDominantColor, background: fallbackBackgroundColor };
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// src/components/Logo/index.tsx
|
|
294
|
-
var import_icons_react2 = require("@tabler/icons-react");
|
|
295
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
296
|
-
function Logo({ withColorPair = true, ...props }) {
|
|
297
|
-
const [logoColorPair, setLogoColorPair] = (0, import_react4.useState)({
|
|
298
|
-
dominant: "#000000",
|
|
299
|
-
background: "#ffffff"
|
|
300
|
-
});
|
|
301
|
-
(0, import_react4.useEffect)(() => {
|
|
302
|
-
let isMounted = true;
|
|
303
|
-
if (props.src && withColorPair) {
|
|
304
|
-
getDominantColorFromImageUrl(props.src).then(({ dominant, background }) => {
|
|
305
|
-
if (isMounted) {
|
|
306
|
-
setLogoColorPair({ dominant, background });
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
} else if (isMounted) {
|
|
310
|
-
setLogoColorPair({ dominant: "#000000", background: "#ffffff" });
|
|
311
|
-
}
|
|
312
|
-
return () => {
|
|
313
|
-
isMounted = false;
|
|
314
|
-
};
|
|
315
|
-
}, [props.src, withColorPair]);
|
|
316
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
317
|
-
import_core6.Avatar,
|
|
318
|
-
{
|
|
319
|
-
size: "5rem",
|
|
320
|
-
radius: "lg",
|
|
321
|
-
p: "0.125rem",
|
|
322
|
-
bg: withColorPair ? logoColorPair.background : void 0,
|
|
323
|
-
styles: {
|
|
324
|
-
image: {
|
|
325
|
-
objectFit: "contain",
|
|
326
|
-
objectPosition: "center"
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
imageProps: { referrerPolicy: "no-referrer" },
|
|
330
|
-
...props,
|
|
331
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core6.ThemeIcon, { variant: "transparent", size: "5rem", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons_react2.IconBuildingSkyscraper, { size: 48 * 1.5, stroke: 1 }) })
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
var Logo_default = Logo;
|
|
336
|
-
|
|
337
|
-
// src/components/NativePDFViewer/index.tsx
|
|
338
|
-
var import_react5 = require("react");
|
|
339
|
-
var import_core7 = require("@mantine/core");
|
|
340
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
341
|
-
function getBrowser() {
|
|
342
|
-
const { userAgent } = navigator;
|
|
343
|
-
const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
|
|
344
|
-
const isEdge = /Edg\//.test(userAgent);
|
|
345
|
-
const isFirefox = /Firefox\//.test(userAgent);
|
|
346
|
-
const isChromium = /Chrome\/|CriOS\//.test(userAgent) && !isEdge;
|
|
347
|
-
if (isSafari) return "Safari";
|
|
348
|
-
if (isEdge) return "Edge";
|
|
349
|
-
if (isFirefox) return "Firefox";
|
|
350
|
-
if (isChromium) return "Chromium";
|
|
351
|
-
return "Unknown";
|
|
352
|
-
}
|
|
353
|
-
function NativePDFViewer({
|
|
354
|
-
mediaUrl,
|
|
355
|
-
title,
|
|
356
|
-
zoomLevel,
|
|
357
|
-
withToolbar = true,
|
|
358
|
-
fallback = "Cannot display PDF on this browser. Use a different browser or download the PDF."
|
|
359
|
-
}) {
|
|
360
|
-
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
361
|
-
const toolbarHeight = {
|
|
362
|
-
Safari: 0,
|
|
363
|
-
Edge: 40,
|
|
364
|
-
Firefox: 32,
|
|
365
|
-
Chromium: 58,
|
|
366
|
-
Unknown: 58
|
|
367
|
-
}[getBrowser()];
|
|
368
|
-
let optionsString = "";
|
|
369
|
-
if (zoomLevel) {
|
|
370
|
-
optionsString += `#zoom=${zoomLevel}%`;
|
|
371
|
-
}
|
|
372
|
-
if (!withToolbar) {
|
|
373
|
-
optionsString = "#toolbar=0";
|
|
374
|
-
}
|
|
375
|
-
const renderFallback = () => typeof fallback === "function" ? fallback() : fallback;
|
|
376
|
-
if (!mediaUrl) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
380
|
-
import_core7.Box,
|
|
381
|
-
{
|
|
382
|
-
w: "100%",
|
|
383
|
-
h: toolbarHeight ? `calc(100% + ${toolbarHeight}px)` : "100%",
|
|
384
|
-
style: {
|
|
385
|
-
transform: toolbarHeight ? `translateY(-${toolbarHeight}px)` : void 0
|
|
386
|
-
},
|
|
387
|
-
children: [
|
|
388
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core7.Center, { h: "100%", w: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core7.Loader, { size: "xl" }) }) : null,
|
|
389
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
390
|
-
"object",
|
|
391
|
-
{
|
|
392
|
-
data: `${mediaUrl}${optionsString}`,
|
|
393
|
-
type: "application/pdf",
|
|
394
|
-
width: "100%",
|
|
395
|
-
height: "100%",
|
|
396
|
-
onLoad: () => setLoading(false),
|
|
397
|
-
onError: () => setLoading(false),
|
|
398
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core7.Box, { children: renderFallback() })
|
|
399
|
-
}
|
|
400
|
-
)
|
|
401
|
-
]
|
|
402
|
-
}
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// src/components/NoData/index.tsx
|
|
407
|
-
var import_core8 = require("@mantine/core");
|
|
408
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
409
|
-
function NoData({ title, children, alertProps, ...props }) {
|
|
410
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core8.Center, { h: "100%", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core8.Alert, { p: "3rem", title: title ?? "No data", ...alertProps, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core8.Center, { children }) }) });
|
|
411
|
-
}
|
|
412
|
-
var NoData_default = NoData;
|
|
413
|
-
|
|
414
|
-
// src/components/PageContainer/index.tsx
|
|
415
|
-
var import_core9 = require("@mantine/core");
|
|
416
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
417
|
-
function PageContainer({
|
|
418
|
-
children,
|
|
419
|
-
title,
|
|
420
|
-
titleProps,
|
|
421
|
-
header,
|
|
422
|
-
headerProps,
|
|
423
|
-
rightSection = null,
|
|
424
|
-
contentProps,
|
|
425
|
-
outerContentProps,
|
|
426
|
-
fullPage = false,
|
|
427
|
-
withContentScroll = false,
|
|
428
|
-
...props
|
|
429
|
-
}) {
|
|
430
|
-
function getTitle() {
|
|
431
|
-
if (title) {
|
|
432
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.Title, { order: 2, ...titleProps, children: title });
|
|
433
|
-
}
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
function getHeader() {
|
|
437
|
-
if (header) {
|
|
438
|
-
return header;
|
|
439
|
-
}
|
|
440
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core9.Group, { justify: "space-between", w: "100%", ...headerProps, children: [
|
|
441
|
-
getTitle(),
|
|
442
|
-
rightSection
|
|
443
|
-
] });
|
|
444
|
-
}
|
|
445
|
-
function getContent() {
|
|
446
|
-
if (fullPage) {
|
|
447
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.Box, { ...contentProps, children });
|
|
448
|
-
}
|
|
449
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core9.Stack, { gap: "xl", ...outerContentProps, children: [
|
|
450
|
-
getHeader(),
|
|
451
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.Stack, { px: "xl", py: "lg", h: "100%", w: "100%", ...contentProps, children })
|
|
452
|
-
] });
|
|
453
|
-
}
|
|
454
|
-
if (withContentScroll) {
|
|
455
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.ScrollArea, { h: "100vh", p: 0, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.Container, { fluid: true, children: getContent() }) });
|
|
456
|
-
}
|
|
457
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core9.Container, { p: 0, w: "100%", fluid: true, children: getContent() });
|
|
458
|
-
}
|
|
459
|
-
var PageContainer_default = PageContainer;
|
|
460
|
-
|
|
461
|
-
// src/components/PhoneInput/index.tsx
|
|
462
|
-
var import_react6 = require("react");
|
|
463
|
-
var import_countries_list = require("countries-list");
|
|
464
|
-
var import_libphonenumber_js = __toESM(require("libphonenumber-js"), 1);
|
|
465
|
-
var import_core10 = require("@mantine/core");
|
|
466
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
467
|
-
var COUNTRY_CODES = (0, import_libphonenumber_js.getCountries)();
|
|
468
|
-
function PhoneInput({ value, defaultValue, defaultCountryCode, ...props }) {
|
|
469
|
-
const valueNumber = value ?? "";
|
|
470
|
-
const valueNumberData = (0, import_libphonenumber_js.default)(valueNumber);
|
|
471
|
-
let valueNumberCountryCode;
|
|
472
|
-
if (valueNumberData?.isValid()) {
|
|
473
|
-
valueNumberCountryCode = valueNumberData.country;
|
|
474
|
-
}
|
|
475
|
-
const [selectedCountryCode, setSelectedCountryCode] = (0, import_react6.useState)(
|
|
476
|
-
defaultCountryCode
|
|
477
|
-
);
|
|
478
|
-
const selectedCountryCodeCallingNumber = selectedCountryCode ? (0, import_libphonenumber_js.getCountryCallingCode)(selectedCountryCode) : void 0;
|
|
479
|
-
(0, import_react6.useEffect)(() => {
|
|
480
|
-
if (selectedCountryCode && selectedCountryCode !== valueNumberCountryCode) {
|
|
481
|
-
const code = selectedCountryCode ?? defaultCountryCode ?? "";
|
|
482
|
-
const callingCode = (0, import_libphonenumber_js.getCountryCallingCode)(code);
|
|
483
|
-
if (props.onChange) {
|
|
484
|
-
const numberUpdate = `+${callingCode}${valueNumber.replace(callingCode, "")}`;
|
|
485
|
-
const numberUpdateData = (0, import_libphonenumber_js.default)(numberUpdate, selectedCountryCode);
|
|
486
|
-
if (numberUpdateData?.isValid()) {
|
|
487
|
-
props.onChange(`+${callingCode}${valueNumber.replace(callingCode, "")}`);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}, [selectedCountryCode]);
|
|
492
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core10.Group, { wrap: "nowrap", children: [
|
|
493
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
494
|
-
import_core10.Select,
|
|
495
|
-
{
|
|
496
|
-
label: "Country code",
|
|
497
|
-
size: "sm",
|
|
498
|
-
classNames: { ...props.classNames },
|
|
499
|
-
defaultValue: defaultCountryCode,
|
|
500
|
-
value: valueNumberCountryCode,
|
|
501
|
-
onChange: (c) => {
|
|
502
|
-
if (c === null) {
|
|
503
|
-
setSelectedCountryCode(void 0);
|
|
504
|
-
} else {
|
|
505
|
-
setSelectedCountryCode(c);
|
|
506
|
-
}
|
|
507
|
-
},
|
|
508
|
-
data: COUNTRY_CODES.map((code) => {
|
|
509
|
-
const countryCallingCode = (0, import_libphonenumber_js.getCountryCallingCode)(code);
|
|
510
|
-
const countryName = (0, import_countries_list.getCountryData)(code).name;
|
|
511
|
-
return {
|
|
512
|
-
value: code,
|
|
513
|
-
label: `${countryName} ${(0, import_countries_list.getEmojiFlag)(code)} +${countryCallingCode}`
|
|
514
|
-
};
|
|
515
|
-
}),
|
|
516
|
-
rightSection: props.disabled ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, {}) : void 0,
|
|
517
|
-
disabled: props.disabled,
|
|
518
|
-
searchable: true
|
|
519
|
-
}
|
|
520
|
-
),
|
|
521
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
522
|
-
import_core10.TextInput,
|
|
523
|
-
{
|
|
524
|
-
...props,
|
|
525
|
-
defaultValue: valueNumberData?.nationalNumber,
|
|
526
|
-
onChange: (e) => {
|
|
527
|
-
if (props.onChange && selectedCountryCodeCallingNumber) {
|
|
528
|
-
const numberUpdate = `+${selectedCountryCodeCallingNumber}${e.currentTarget.value.replace(selectedCountryCodeCallingNumber, "")}`;
|
|
529
|
-
const numberUpdateData = (0, import_libphonenumber_js.default)(numberUpdate, selectedCountryCode);
|
|
530
|
-
if (numberUpdateData?.isValid()) {
|
|
531
|
-
props.onChange(numberUpdateData.number);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
)
|
|
537
|
-
] });
|
|
538
|
-
}
|
|
539
|
-
var PhoneInput_default = PhoneInput;
|
|
540
|
-
|
|
541
|
-
// src/components/TextEditor/index.tsx
|
|
542
|
-
var import_react7 = require("react");
|
|
543
|
-
var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
544
|
-
var import_extension_subscript = __toESM(require("@tiptap/extension-subscript"), 1);
|
|
545
|
-
var import_extension_superscript = __toESM(require("@tiptap/extension-superscript"), 1);
|
|
546
|
-
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
547
|
-
var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
|
|
548
|
-
var import_react8 = require("@tiptap/react");
|
|
549
|
-
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
550
|
-
var import_tiptap = require("@mantine/tiptap");
|
|
551
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
552
|
-
function TextEditor({
|
|
553
|
-
content,
|
|
554
|
-
value,
|
|
555
|
-
onChangeEditorHTML = () => {
|
|
556
|
-
},
|
|
557
|
-
onChange = () => {
|
|
558
|
-
},
|
|
559
|
-
...props
|
|
560
|
-
}) {
|
|
561
|
-
const editor = (0, import_react8.useEditor)({
|
|
562
|
-
editable: true,
|
|
563
|
-
extensions: [
|
|
564
|
-
import_starter_kit.default,
|
|
565
|
-
import_extension_underline.default,
|
|
566
|
-
import_tiptap.Link,
|
|
567
|
-
import_extension_superscript.default,
|
|
568
|
-
import_extension_subscript.default,
|
|
569
|
-
import_extension_highlight.default,
|
|
570
|
-
import_extension_text_align.default.configure({ types: ["heading", "paragraph"] })
|
|
571
|
-
],
|
|
572
|
-
content
|
|
573
|
-
});
|
|
574
|
-
(0, import_react7.useEffect)(() => {
|
|
575
|
-
onChangeEditorHTML(editor?.getHTML());
|
|
576
|
-
onChange(editor?.getHTML());
|
|
577
|
-
}, [editor?.state, editor, onChangeEditorHTML, onChange]);
|
|
578
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor, { editor, ...props, children: [
|
|
579
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.Toolbar, { sticky: true, stickyOffset: 60, children: [
|
|
580
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.ControlsGroup, { children: [
|
|
581
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Bold, {}),
|
|
582
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Italic, {}),
|
|
583
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Underline, {}),
|
|
584
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Strikethrough, {}),
|
|
585
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.ClearFormatting, {}),
|
|
586
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Highlight, {}),
|
|
587
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Code, {})
|
|
588
|
-
] }),
|
|
589
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.ControlsGroup, { children: [
|
|
590
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.H1, {}),
|
|
591
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.H2, {}),
|
|
592
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.H3, {}),
|
|
593
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.H4, {})
|
|
594
|
-
] }),
|
|
595
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.ControlsGroup, { children: [
|
|
596
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Blockquote, {}),
|
|
597
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Hr, {}),
|
|
598
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.BulletList, {}),
|
|
599
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.OrderedList, {}),
|
|
600
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Subscript, {}),
|
|
601
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Superscript, {})
|
|
602
|
-
] }),
|
|
603
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.ControlsGroup, { children: [
|
|
604
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Link, {}),
|
|
605
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Unlink, {})
|
|
606
|
-
] }),
|
|
607
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_tiptap.RichTextEditor.ControlsGroup, { children: [
|
|
608
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.AlignLeft, {}),
|
|
609
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.AlignCenter, {}),
|
|
610
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.AlignJustify, {}),
|
|
611
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.AlignRight, {})
|
|
612
|
-
] })
|
|
613
|
-
] }),
|
|
614
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_tiptap.RichTextEditor.Content, {})
|
|
615
|
-
] });
|
|
616
|
-
}
|
|
617
|
-
var TextEditor_default = TextEditor;
|
|
618
|
-
|
|
619
|
-
// src/components/ThemeToggle/index.tsx
|
|
620
|
-
var import_core11 = require("@mantine/core");
|
|
621
|
-
var import_icons_react3 = require("@tabler/icons-react");
|
|
622
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
623
|
-
function ThemeToggle({ ...props }) {
|
|
624
|
-
const { setColorScheme } = (0, import_core11.useMantineColorScheme)();
|
|
625
|
-
const computedColorScheme = (0, import_core11.useComputedColorScheme)("light", { getInitialValueInEffect: true });
|
|
626
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
627
|
-
import_core11.Tooltip,
|
|
628
|
-
{
|
|
629
|
-
label: computedColorScheme === "light" ? "Switch to dark mode" : "Switch to light mode",
|
|
630
|
-
position: "bottom",
|
|
631
|
-
withinPortal: true,
|
|
632
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ClientOnly, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
633
|
-
import_core11.Switch,
|
|
634
|
-
{
|
|
635
|
-
styles: { track: { cursor: "pointer" } },
|
|
636
|
-
defaultChecked: computedColorScheme === "dark",
|
|
637
|
-
onChange: () => setColorScheme(computedColorScheme === "light" ? "dark" : "light"),
|
|
638
|
-
onLabel: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core11.ThemeIcon, { size: props.size ?? "sm", variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons_react3.IconMoon, {}) }),
|
|
639
|
-
offLabel: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core11.ThemeIcon, { size: props.size ?? "sm", color: "yellow", variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons_react3.IconSun, {}) }),
|
|
640
|
-
color: "dark",
|
|
641
|
-
size: "md",
|
|
642
|
-
...props
|
|
643
|
-
}
|
|
644
|
-
) })
|
|
645
|
-
}
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
var ThemeToggle_default = ThemeToggle;
|
|
649
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
650
|
-
0 && (module.exports = {
|
|
651
|
-
ClientOnly,
|
|
652
|
-
ConfirmBar,
|
|
653
|
-
ContentLoader,
|
|
654
|
-
ImageInput,
|
|
655
|
-
Logo,
|
|
656
|
-
NativePDFViewer,
|
|
657
|
-
NoData,
|
|
658
|
-
PageContainer,
|
|
659
|
-
PhoneInput,
|
|
660
|
-
TextEditor,
|
|
661
|
-
ThemeToggle
|
|
662
|
-
});
|
|
663
|
-
//# sourceMappingURL=index.cjs.map
|