@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260721133206 → 0.8.1-dev.20260722070133
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/{InputControlClient-VUPWEYGB.mjs → InputControlClient-5RK7QDZZ.mjs} +1 -1
- package/dist/{InputControlClient-WW2T4W77.mjs → InputControlClient-7FJWGZDN.mjs} +1 -1
- package/dist/{LinkNodeButton-LX3KKGZY.mjs → LinkNodeButton-AOEDCCL7.mjs} +92 -38
- package/dist/{LinkNodeButton-XA7Z5IDR.mjs → LinkNodeButton-BIZA2NPE.mjs} +92 -38
- package/dist/{chunk-JKP4XOZB.mjs → chunk-23WJE3YB.mjs} +48 -9
- package/dist/{chunk-YL6E76X2.mjs → chunk-RHVNJMS4.mjs} +48 -9
- package/dist/index.js +137 -44
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/dist/EnterAnimationClient-4OKXLKSA.mjs +0 -45
- package/dist/EnterAnimationClient-ZN3NLFNO.mjs +0 -47
- package/dist/InputControlClient-AZRPSTUZ.mjs +0 -677
- package/dist/InputControlClient-HIZOJLKW.mjs +0 -677
- package/dist/InputControlClient-P4RA7DQN.mjs +0 -677
- package/dist/LinkNodeButton-U7T2NP22.mjs +0 -374
- package/dist/Pagination-6OFACRMQ.mjs +0 -229
- package/dist/Pagination-OQT7Q2XO.mjs +0 -183
- package/dist/chunk-3R4VVVNK.mjs +0 -903
- package/dist/chunk-FI2KJBK2.mjs +0 -110
- package/dist/chunk-OGGIS4AN.mjs +0 -201
- package/dist/chunk-TVL6KVD5.mjs +0 -229
- package/dist/server.d.mts +0 -113
- package/dist/server.d.ts +0 -113
- package/dist/server.js +0 -5225
- package/dist/server.mjs +0 -2782
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
ServiceClient_default
|
|
4
|
-
} from "./chunk-3GWLDT7C.mjs";
|
|
5
|
-
import {
|
|
6
|
-
buttonClasses,
|
|
7
|
-
progressClasses
|
|
8
|
-
} from "./chunk-56HSDML5.mjs";
|
|
9
|
-
|
|
10
|
-
// src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
|
|
11
|
-
import { useCallback, useState as useState3 } from "react";
|
|
12
|
-
|
|
13
|
-
// src/components/Button.tsx
|
|
14
|
-
import React3, { useState as useState2 } from "react";
|
|
15
|
-
|
|
16
|
-
// src/components/ToastService.tsx
|
|
17
|
-
var toastHandlersKey = "__digitalStoreToastHandlers";
|
|
18
|
-
var getToastHandlers = () => {
|
|
19
|
-
const globalScope = globalThis;
|
|
20
|
-
if (!globalScope[toastHandlersKey]) {
|
|
21
|
-
globalScope[toastHandlersKey] = {};
|
|
22
|
-
}
|
|
23
|
-
return globalScope[toastHandlersKey];
|
|
24
|
-
};
|
|
25
|
-
var ToastService = class {
|
|
26
|
-
static initialize(showToast, closeToast) {
|
|
27
|
-
const handlers = getToastHandlers();
|
|
28
|
-
handlers.showToast = showToast;
|
|
29
|
-
handlers.closeToast = closeToast;
|
|
30
|
-
}
|
|
31
|
-
static showError(message) {
|
|
32
|
-
const handlers = getToastHandlers();
|
|
33
|
-
if (handlers.showToast) {
|
|
34
|
-
handlers.showToast(message, "error");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
static showInfo(message) {
|
|
38
|
-
const handlers = getToastHandlers();
|
|
39
|
-
if (handlers.showToast) {
|
|
40
|
-
handlers.showToast(message, "info");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
static showWarning(message) {
|
|
44
|
-
const handlers = getToastHandlers();
|
|
45
|
-
if (handlers.showToast) {
|
|
46
|
-
handlers.showToast(message, "warning");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
static showSuccess(message) {
|
|
50
|
-
const handlers = getToastHandlers();
|
|
51
|
-
if (handlers.showToast) {
|
|
52
|
-
handlers.showToast(message, "success");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
static close() {
|
|
56
|
-
const handlers = getToastHandlers();
|
|
57
|
-
if (handlers.closeToast) {
|
|
58
|
-
handlers.closeToast();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var ToastService_default = ToastService;
|
|
63
|
-
|
|
64
|
-
// src/components/Confirm.tsx
|
|
65
|
-
import { useState } from "react";
|
|
66
|
-
|
|
67
|
-
// src/components/ClientButton.tsx
|
|
68
|
-
import React from "react";
|
|
69
|
-
import { jsx } from "react/jsx-runtime";
|
|
70
|
-
var ClientButton = (props) => {
|
|
71
|
-
const execute = async (event) => {
|
|
72
|
-
if (props.onClick !== void 0) {
|
|
73
|
-
props.onClick();
|
|
74
|
-
} else {
|
|
75
|
-
ToastService_default.showError("No action defined.");
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
79
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
|
|
80
|
-
"button",
|
|
81
|
-
{
|
|
82
|
-
type: "button",
|
|
83
|
-
onClick: execute,
|
|
84
|
-
className: buttonClass + " " + props.className,
|
|
85
|
-
children: props.children
|
|
86
|
-
}
|
|
87
|
-
) });
|
|
88
|
-
};
|
|
89
|
-
var ClientButton_default = ClientButton;
|
|
90
|
-
|
|
91
|
-
// src/components/Confirm.tsx
|
|
92
|
-
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
93
|
-
var Confirm = ({ message, onConfirm, onCancel }) => {
|
|
94
|
-
const [showModal, setShowModal] = useState(true);
|
|
95
|
-
const handleConfirmAction = () => {
|
|
96
|
-
setShowModal(false);
|
|
97
|
-
if (onConfirm) {
|
|
98
|
-
onConfirm();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const handleCancelAction = () => {
|
|
102
|
-
setShowModal(false);
|
|
103
|
-
if (onCancel) {
|
|
104
|
-
onCancel();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
return /* @__PURE__ */ jsx2(Fragment, { children: showModal && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
|
|
108
|
-
/* @__PURE__ */ jsx2("div", { className: "absolute inset-0 bg-black opacity-70" }),
|
|
109
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
|
|
110
|
-
/* @__PURE__ */ jsx2("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
|
|
111
|
-
/* @__PURE__ */ jsx2("p", { className: "mb-4", children: message }),
|
|
112
|
-
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-8", children: [
|
|
113
|
-
/* @__PURE__ */ jsx2(
|
|
114
|
-
ClientButton_default,
|
|
115
|
-
{
|
|
116
|
-
onClick: handleCancelAction,
|
|
117
|
-
ButtonType: "PrimaryHollow" /* Hollow */,
|
|
118
|
-
children: "Cancel"
|
|
119
|
-
}
|
|
120
|
-
),
|
|
121
|
-
/* @__PURE__ */ jsx2(
|
|
122
|
-
ClientButton_default,
|
|
123
|
-
{
|
|
124
|
-
onClick: handleConfirmAction,
|
|
125
|
-
children: "Confirm"
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
] })
|
|
129
|
-
] })
|
|
130
|
-
] }) });
|
|
131
|
-
};
|
|
132
|
-
var Confirm_default = Confirm;
|
|
133
|
-
{
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/components/Button.tsx
|
|
137
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
138
|
-
var Button = (props) => {
|
|
139
|
-
const [inProgress, setInProgress] = useState2(false);
|
|
140
|
-
const [isActionPerformed, setIsActionPerformed] = useState2(false);
|
|
141
|
-
const [responseMessage, setResponseMessage] = useState2(null);
|
|
142
|
-
const [showModal, setShowModal] = useState2(null);
|
|
143
|
-
const execute = async (event) => {
|
|
144
|
-
event.preventDefault();
|
|
145
|
-
event.stopPropagation();
|
|
146
|
-
if (props.confirm) {
|
|
147
|
-
const confirmed = await showConfirmation("Are you sure you want to delete this item?");
|
|
148
|
-
setShowModal(null);
|
|
149
|
-
if (!confirmed) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (props.oneTimeAction && isActionPerformed) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
setInProgress(true);
|
|
157
|
-
let isValid = true;
|
|
158
|
-
if (props.onValidate !== void 0) {
|
|
159
|
-
isValid = await props.onValidate();
|
|
160
|
-
if (!isValid) {
|
|
161
|
-
setInProgress(false);
|
|
162
|
-
ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (props.onClick !== void 0) {
|
|
167
|
-
let response = await props.onClick();
|
|
168
|
-
if (response.isSuccessful) {
|
|
169
|
-
setIsActionPerformed(true);
|
|
170
|
-
setResponseMessage(response.message);
|
|
171
|
-
if (props.showToast) {
|
|
172
|
-
ToastService_default.showInfo(response.message || "");
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
ToastService_default.showError(response.message || "");
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
ToastService_default.showError("No action defined.");
|
|
179
|
-
}
|
|
180
|
-
setInProgress(false);
|
|
181
|
-
};
|
|
182
|
-
const showConfirmation = (message) => {
|
|
183
|
-
return new Promise((resolve) => {
|
|
184
|
-
const onConfirm = () => resolve(true);
|
|
185
|
-
const onCancel = () => resolve(false);
|
|
186
|
-
setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
190
|
-
let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
|
|
191
|
-
const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
|
|
192
|
-
return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
|
|
193
|
-
/* @__PURE__ */ jsxs2(
|
|
194
|
-
"button",
|
|
195
|
-
{
|
|
196
|
-
type: "submit",
|
|
197
|
-
onClick: execute,
|
|
198
|
-
disabled: props.disabled,
|
|
199
|
-
title: isDisabled ? "The button is disabled to prevent any action" : "",
|
|
200
|
-
className: buttonClass + " relative " + props.className,
|
|
201
|
-
children: [
|
|
202
|
-
isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
|
|
203
|
-
inProgress && /* @__PURE__ */ jsx3(React3.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
204
|
-
/* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
205
|
-
/* @__PURE__ */ jsx3("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
206
|
-
] }) })
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
),
|
|
210
|
-
showModal
|
|
211
|
-
] });
|
|
212
|
-
};
|
|
213
|
-
var Button_default = Button;
|
|
214
|
-
|
|
215
|
-
// src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
|
|
216
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
217
|
-
var LinkNodeButton = (props) => {
|
|
218
|
-
const { node, dataitem, children, linkText, linkType, linkUrl } = props;
|
|
219
|
-
const [isLoading, setIsLoading] = useState3(false);
|
|
220
|
-
const extractFieldNames = useCallback((template) => {
|
|
221
|
-
if (!template) return [];
|
|
222
|
-
const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
|
|
223
|
-
const matches = Array.from(template.matchAll(regex));
|
|
224
|
-
const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
|
|
225
|
-
return fieldNames;
|
|
226
|
-
}, []);
|
|
227
|
-
const replaceTemplateVariables = useCallback((template, responseData) => {
|
|
228
|
-
if (!template) return template;
|
|
229
|
-
let result = template;
|
|
230
|
-
const fieldNames = extractFieldNames(template);
|
|
231
|
-
if (responseData) {
|
|
232
|
-
fieldNames.forEach((fieldName) => {
|
|
233
|
-
const value = getNestedValue(responseData, fieldName);
|
|
234
|
-
if (value !== void 0) {
|
|
235
|
-
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
236
|
-
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
237
|
-
result = result.replace(regex1, String(value));
|
|
238
|
-
result = result.replace(regex2, String(value));
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (props.routeParameters) {
|
|
243
|
-
Object.entries(props.routeParameters).forEach(([key, value]) => {
|
|
244
|
-
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
245
|
-
result = result.replace(regex, String(value));
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
if (dataitem) {
|
|
249
|
-
Object.entries(dataitem).forEach(([key, value]) => {
|
|
250
|
-
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
251
|
-
result = result.replace(regex, String(value));
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
return result;
|
|
255
|
-
}, [props.routeParameters, dataitem, extractFieldNames]);
|
|
256
|
-
const getNestedValue = useCallback((obj, path) => {
|
|
257
|
-
if (!obj || !path) return void 0;
|
|
258
|
-
if (obj[path] !== void 0) {
|
|
259
|
-
return obj[path];
|
|
260
|
-
}
|
|
261
|
-
const keys = path.split(".");
|
|
262
|
-
let current = obj;
|
|
263
|
-
for (const key of keys) {
|
|
264
|
-
if (current[key] === void 0) {
|
|
265
|
-
return void 0;
|
|
266
|
-
}
|
|
267
|
-
current = current[key];
|
|
268
|
-
}
|
|
269
|
-
return current;
|
|
270
|
-
}, []);
|
|
271
|
-
const onClick = useCallback(async () => {
|
|
272
|
-
if (!node.postUrl) {
|
|
273
|
-
return { isSuccessful: false, message: "No POST URL configured for this button" };
|
|
274
|
-
}
|
|
275
|
-
setIsLoading(true);
|
|
276
|
-
try {
|
|
277
|
-
const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
|
|
278
|
-
let parsedPayload = {};
|
|
279
|
-
if (node.payload) {
|
|
280
|
-
try {
|
|
281
|
-
const payloadStr = replaceTemplateVariables(node.payload);
|
|
282
|
-
parsedPayload = JSON.parse(payloadStr);
|
|
283
|
-
console.log("Parsed payload:", parsedPayload);
|
|
284
|
-
} catch (err) {
|
|
285
|
-
console.error("Failed to parse payload JSON:", err);
|
|
286
|
-
parsedPayload = { error: "Invalid payload JSON" };
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
|
|
290
|
-
const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
|
|
291
|
-
console.log("API Response:", response);
|
|
292
|
-
if (response && !response.isSuccessful) {
|
|
293
|
-
const errorMessage = response.message || "API request failed";
|
|
294
|
-
setIsLoading(false);
|
|
295
|
-
return { isSuccessful: false, message: errorMessage };
|
|
296
|
-
}
|
|
297
|
-
if (response?.message) {
|
|
298
|
-
ToastService_default.showSuccess(response.message);
|
|
299
|
-
}
|
|
300
|
-
if (response && node.redirectUrl) {
|
|
301
|
-
const fieldNames = extractFieldNames(node.redirectUrl);
|
|
302
|
-
console.log("Field names in redirect URL:", fieldNames);
|
|
303
|
-
const fieldValueMap = {};
|
|
304
|
-
fieldNames.forEach((fieldName) => {
|
|
305
|
-
const value = getNestedValue(response, fieldName);
|
|
306
|
-
if (value !== void 0) {
|
|
307
|
-
fieldValueMap[fieldName] = String(value);
|
|
308
|
-
} else {
|
|
309
|
-
const resultValue = getNestedValue(response, `result.${fieldName}`);
|
|
310
|
-
if (resultValue !== void 0) {
|
|
311
|
-
fieldValueMap[fieldName] = String(resultValue);
|
|
312
|
-
} else {
|
|
313
|
-
const dataValue = getNestedValue(response, `data.${fieldName}`);
|
|
314
|
-
if (dataValue !== void 0) {
|
|
315
|
-
fieldValueMap[fieldName] = String(dataValue);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
console.log("Field value map:", fieldValueMap);
|
|
321
|
-
const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
|
|
322
|
-
if (missingFields.length > 0) {
|
|
323
|
-
console.warn(`Missing field values for: ${missingFields.join(", ")}`);
|
|
324
|
-
}
|
|
325
|
-
let resolvedRedirectUrl = node.redirectUrl;
|
|
326
|
-
Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
|
|
327
|
-
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
328
|
-
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
329
|
-
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
|
|
330
|
-
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
|
|
331
|
-
});
|
|
332
|
-
resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
|
|
333
|
-
console.log("Final redirect URL:", resolvedRedirectUrl);
|
|
334
|
-
if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
|
|
335
|
-
window.location.href = resolvedRedirectUrl;
|
|
336
|
-
}
|
|
337
|
-
} else if (!response) {
|
|
338
|
-
const errorMessage = "No response from server";
|
|
339
|
-
setIsLoading(false);
|
|
340
|
-
return { isSuccessful: false, message: errorMessage };
|
|
341
|
-
}
|
|
342
|
-
setIsLoading(false);
|
|
343
|
-
return { isSuccessful: true, message: response?.message, result: response };
|
|
344
|
-
} catch (err) {
|
|
345
|
-
console.error("Button API call failed:", err);
|
|
346
|
-
const errorMessage = err.message || "An unexpected error occurred";
|
|
347
|
-
setIsLoading(false);
|
|
348
|
-
return { isSuccessful: false, message: errorMessage };
|
|
349
|
-
}
|
|
350
|
-
}, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue, props.apiBaseUrl, props.session]);
|
|
351
|
-
const renderButtonContent = () => {
|
|
352
|
-
if (children) {
|
|
353
|
-
return children;
|
|
354
|
-
}
|
|
355
|
-
if (linkText) {
|
|
356
|
-
return /* @__PURE__ */ jsx4("span", { children: linkText });
|
|
357
|
-
}
|
|
358
|
-
return node.title || "Button";
|
|
359
|
-
};
|
|
360
|
-
return /* @__PURE__ */ jsx4("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx4(
|
|
361
|
-
Button_default,
|
|
362
|
-
{
|
|
363
|
-
ButtonType: linkType,
|
|
364
|
-
onClick,
|
|
365
|
-
disabled: isLoading,
|
|
366
|
-
className: "w-full",
|
|
367
|
-
children: renderButtonContent()
|
|
368
|
-
}
|
|
369
|
-
) });
|
|
370
|
-
};
|
|
371
|
-
var LinkNodeButton_default = LinkNodeButton;
|
|
372
|
-
export {
|
|
373
|
-
LinkNodeButton_default as default
|
|
374
|
-
};
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
Constants,
|
|
4
|
-
Hyperlink,
|
|
5
|
-
OdataBuilder
|
|
6
|
-
} from "./chunk-TVL6KVD5.mjs";
|
|
7
|
-
import "./chunk-56HSDML5.mjs";
|
|
8
|
-
|
|
9
|
-
// src/components/Pagination.tsx
|
|
10
|
-
import { useMemo } from "react";
|
|
11
|
-
|
|
12
|
-
// src/svg/chevron-updown.tsx
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
var ChevronUpDown = (props) => {
|
|
15
|
-
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) });
|
|
16
|
-
};
|
|
17
|
-
var chevron_updown_default = ChevronUpDown;
|
|
18
|
-
|
|
19
|
-
// src/svg/chevron-down.tsx
|
|
20
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
21
|
-
var ChevronDown = (props) => {
|
|
22
|
-
return /* @__PURE__ */ jsx2("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) });
|
|
23
|
-
};
|
|
24
|
-
var chevron_down_default = ChevronDown;
|
|
25
|
-
|
|
26
|
-
// src/svg/chevron-up.tsx
|
|
27
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
28
|
-
var ChevronUp = (props) => {
|
|
29
|
-
return /* @__PURE__ */ jsx3("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) });
|
|
30
|
-
};
|
|
31
|
-
var chevron_up_default = ChevronUp;
|
|
32
|
-
|
|
33
|
-
// src/svg/plus.tsx
|
|
34
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
35
|
-
var Plus = (props) => {
|
|
36
|
-
return /* @__PURE__ */ jsx4("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" }) });
|
|
37
|
-
};
|
|
38
|
-
var plus_default = Plus;
|
|
39
|
-
|
|
40
|
-
// src/svg/Icons.tsx
|
|
41
|
-
var Icons = {
|
|
42
|
-
chevronUpDown: chevron_updown_default,
|
|
43
|
-
chevronDown: chevron_down_default,
|
|
44
|
-
chevronUp: chevron_up_default,
|
|
45
|
-
plus: plus_default
|
|
46
|
-
};
|
|
47
|
-
var Icons_default = Icons;
|
|
48
|
-
|
|
49
|
-
// src/svg/Icon.tsx
|
|
50
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
51
|
-
var Icon = ({ name, className, ...props }) => {
|
|
52
|
-
const IconComponent = Icons_default[name];
|
|
53
|
-
if (!IconComponent) {
|
|
54
|
-
console.error(`Icon "${name}" not found.`);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return /* @__PURE__ */ jsx5(IconComponent, { ...props, className });
|
|
58
|
-
};
|
|
59
|
-
var Icon_default = Icon;
|
|
60
|
-
|
|
61
|
-
// src/components/Pagination.tsx
|
|
62
|
-
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
63
|
-
var Pagination = (props) => {
|
|
64
|
-
const { dataset, path, query, showPageSizeSelector = false, showJumpToPage = false } = props;
|
|
65
|
-
const builder = useMemo(() => {
|
|
66
|
-
const b = new OdataBuilder(path);
|
|
67
|
-
if (query) b.setQuery(query);
|
|
68
|
-
return b;
|
|
69
|
-
}, [path, query]);
|
|
70
|
-
const activePageNumber = builder.getPageNumber(Constants.pagesize);
|
|
71
|
-
const totalItems = dataset?.count || 0;
|
|
72
|
-
const itemsPerPage = parseInt(builder.top || Constants.pagesize.toString());
|
|
73
|
-
const totalPages = Math.ceil(totalItems / itemsPerPage);
|
|
74
|
-
const startItem = totalItems > 0 ? (activePageNumber - 1) * itemsPerPage + 1 : 0;
|
|
75
|
-
const endItem = Math.min(activePageNumber * itemsPerPage, totalItems);
|
|
76
|
-
const getPaginationRange = () => {
|
|
77
|
-
const delta = 1;
|
|
78
|
-
const range = [];
|
|
79
|
-
if (totalPages <= 7) {
|
|
80
|
-
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
81
|
-
}
|
|
82
|
-
range.push(1);
|
|
83
|
-
let start = Math.max(2, activePageNumber - delta);
|
|
84
|
-
let end = Math.min(totalPages - 1, activePageNumber + delta);
|
|
85
|
-
if (activePageNumber - delta <= 2) {
|
|
86
|
-
end = Math.min(totalPages - 1, 4);
|
|
87
|
-
}
|
|
88
|
-
if (activePageNumber + delta >= totalPages - 1) {
|
|
89
|
-
start = Math.max(2, totalPages - 4);
|
|
90
|
-
}
|
|
91
|
-
if (start > 2) {
|
|
92
|
-
range.push("...");
|
|
93
|
-
}
|
|
94
|
-
for (let i = start; i <= end; i++) {
|
|
95
|
-
range.push(i);
|
|
96
|
-
}
|
|
97
|
-
if (end < totalPages - 1) {
|
|
98
|
-
range.push("...");
|
|
99
|
-
}
|
|
100
|
-
if (totalPages > 1) {
|
|
101
|
-
range.push(totalPages);
|
|
102
|
-
}
|
|
103
|
-
return range;
|
|
104
|
-
};
|
|
105
|
-
const paginationRange = getPaginationRange();
|
|
106
|
-
const PageButton = ({ page, children }) => /* @__PURE__ */ jsx6(
|
|
107
|
-
Hyperlink,
|
|
108
|
-
{
|
|
109
|
-
linkType: "Link" /* Link */,
|
|
110
|
-
className: `
|
|
111
|
-
min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2.5 md:px-3
|
|
112
|
-
border text-sm font-medium transition-colors duration-150
|
|
113
|
-
${activePageNumber === page ? "bg-primary-base font-semibold" : ""}
|
|
114
|
-
`,
|
|
115
|
-
href: builder.getNewPageUrl(page),
|
|
116
|
-
children
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
const NavigationButton = ({ page, disabled, children }) => {
|
|
120
|
-
if (disabled) {
|
|
121
|
-
return /* @__PURE__ */ jsx6("span", { className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2 md:px-3 border bg-neutral-base cursor-not-allowed", children });
|
|
122
|
-
}
|
|
123
|
-
return /* @__PURE__ */ jsx6(
|
|
124
|
-
Hyperlink,
|
|
125
|
-
{
|
|
126
|
-
className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2 md:px-3 border transition-colors duration-150",
|
|
127
|
-
href: builder.getNewPageUrl(page),
|
|
128
|
-
children
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
if (totalPages <= 1 && totalItems === 0) return null;
|
|
133
|
-
return /* @__PURE__ */ jsxs("div", { className: "py-6 border-t bg-default", children: [
|
|
134
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row items-center justify-between gap-4", children: [
|
|
135
|
-
/* @__PURE__ */ jsxs("div", { className: "text-sm", children: [
|
|
136
|
-
"Showing ",
|
|
137
|
-
/* @__PURE__ */ jsxs("span", { className: "font-semibold", children: [
|
|
138
|
-
startItem,
|
|
139
|
-
"-",
|
|
140
|
-
endItem
|
|
141
|
-
] }),
|
|
142
|
-
" ",
|
|
143
|
-
"out of ",
|
|
144
|
-
/* @__PURE__ */ jsx6("span", { className: "font-semibold", children: totalItems.toLocaleString() }),
|
|
145
|
-
" results"
|
|
146
|
-
] }),
|
|
147
|
-
totalPages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
|
|
148
|
-
/* @__PURE__ */ jsxs(
|
|
149
|
-
NavigationButton,
|
|
150
|
-
{
|
|
151
|
-
page: activePageNumber - 1,
|
|
152
|
-
disabled: activePageNumber === 1,
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ jsx6("span", { children: /* @__PURE__ */ jsx6(Icon_default, { name: "chevronLeft", className: "w-4 h-4 mr-1" }) }),
|
|
155
|
-
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: "Prev" })
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
paginationRange.map((item, index) => {
|
|
160
|
-
if (item === "...") {
|
|
161
|
-
return /* @__PURE__ */ jsx6(
|
|
162
|
-
"span",
|
|
163
|
-
{
|
|
164
|
-
className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center text-gray-500",
|
|
165
|
-
children: "..."
|
|
166
|
-
},
|
|
167
|
-
`ellipsis-${index}`
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
const page = item;
|
|
171
|
-
return /* @__PURE__ */ jsx6(PageButton, { page, children: page }, page);
|
|
172
|
-
}),
|
|
173
|
-
/* @__PURE__ */ jsxs(
|
|
174
|
-
NavigationButton,
|
|
175
|
-
{
|
|
176
|
-
page: activePageNumber + 1,
|
|
177
|
-
disabled: activePageNumber === totalPages,
|
|
178
|
-
children: [
|
|
179
|
-
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: "Next" }),
|
|
180
|
-
/* @__PURE__ */ jsx6("span", { children: /* @__PURE__ */ jsx6(Icon_default, { name: "chevronRight", className: "w-4 h-4 ml-1" }) })
|
|
181
|
-
]
|
|
182
|
-
}
|
|
183
|
-
)
|
|
184
|
-
] }),
|
|
185
|
-
showJumpToPage && totalPages > 5 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
186
|
-
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: "Go to:" }),
|
|
187
|
-
/* @__PURE__ */ jsx6("div", { className: "relative", children: /* @__PURE__ */ jsx6(
|
|
188
|
-
"input",
|
|
189
|
-
{
|
|
190
|
-
type: "number",
|
|
191
|
-
min: "1",
|
|
192
|
-
max: totalPages,
|
|
193
|
-
defaultValue: activePageNumber,
|
|
194
|
-
className: "w-20 h-10 px-3 border rounded text-sm focus:outline-none focus:ring-2 focus:border-transparent",
|
|
195
|
-
onKeyDown: (e) => {
|
|
196
|
-
if (e.key === "Enter") {
|
|
197
|
-
const input = e.target;
|
|
198
|
-
const page = parseInt(input.value);
|
|
199
|
-
if (page >= 1 && page <= totalPages && page !== activePageNumber) {
|
|
200
|
-
window.location.href = builder.getNewPageUrl(page);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
) })
|
|
206
|
-
] })
|
|
207
|
-
] }),
|
|
208
|
-
showPageSizeSelector && /* @__PURE__ */ jsx6("div", { className: "mt-4 pt-4 border-t bg-default", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
|
|
209
|
-
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: "Show:" }),
|
|
210
|
-
/* @__PURE__ */ jsx6("div", { className: "flex space-x-1", children: [10, 25, 50, 100].map((size) => /* @__PURE__ */ jsx6(
|
|
211
|
-
Hyperlink,
|
|
212
|
-
{
|
|
213
|
-
className: `
|
|
214
|
-
px-3 py-1 text-sm rounded border transition-colors duration-150
|
|
215
|
-
${itemsPerPage === size ? "bg-primary-base font-medium" : "bg-neutral-weak"}
|
|
216
|
-
`,
|
|
217
|
-
href: builder.getNewPageSizeUrl(size),
|
|
218
|
-
children: size
|
|
219
|
-
},
|
|
220
|
-
size
|
|
221
|
-
)) }),
|
|
222
|
-
/* @__PURE__ */ jsx6("span", { className: "text-sm", children: "per page" })
|
|
223
|
-
] }) })
|
|
224
|
-
] });
|
|
225
|
-
};
|
|
226
|
-
var Pagination_default = Pagination;
|
|
227
|
-
export {
|
|
228
|
-
Pagination_default as default
|
|
229
|
-
};
|