@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260713051007 → 0.8.1-dev.20260713054521

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.
@@ -0,0 +1,171 @@
1
+ "use client";
2
+ import {
3
+ ServiceClient_default
4
+ } from "./chunk-3GWLDT7C.mjs";
5
+ import {
6
+ Button_default,
7
+ ToastService_default
8
+ } from "./chunk-YL6E76X2.mjs";
9
+ import "./chunk-56HSDML5.mjs";
10
+
11
+ // src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
12
+ import { useCallback, useState } from "react";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var LinkNodeButton = (props) => {
15
+ const { node, dataitem, children, linkText, linkType, linkUrl } = props;
16
+ const [isLoading, setIsLoading] = useState(false);
17
+ const extractFieldNames = useCallback((template) => {
18
+ if (!template) return [];
19
+ const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
20
+ const matches = Array.from(template.matchAll(regex));
21
+ const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
22
+ return fieldNames;
23
+ }, []);
24
+ const replaceTemplateVariables = useCallback((template, responseData) => {
25
+ if (!template) return template;
26
+ let result = template;
27
+ const fieldNames = extractFieldNames(template);
28
+ if (responseData) {
29
+ fieldNames.forEach((fieldName) => {
30
+ const value = getNestedValue(responseData, fieldName);
31
+ if (value !== void 0) {
32
+ const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
33
+ const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
34
+ result = result.replace(regex1, String(value));
35
+ result = result.replace(regex2, String(value));
36
+ }
37
+ });
38
+ }
39
+ if (props.routeParameters) {
40
+ Object.entries(props.routeParameters).forEach(([key, value]) => {
41
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
42
+ result = result.replace(regex, String(value));
43
+ });
44
+ }
45
+ if (dataitem) {
46
+ Object.entries(dataitem).forEach(([key, value]) => {
47
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
48
+ result = result.replace(regex, String(value));
49
+ });
50
+ }
51
+ return result;
52
+ }, [props.routeParameters, dataitem, extractFieldNames]);
53
+ const getNestedValue = useCallback((obj, path) => {
54
+ if (!obj || !path) return void 0;
55
+ if (obj[path] !== void 0) {
56
+ return obj[path];
57
+ }
58
+ const keys = path.split(".");
59
+ let current = obj;
60
+ for (const key of keys) {
61
+ if (current[key] === void 0) {
62
+ return void 0;
63
+ }
64
+ current = current[key];
65
+ }
66
+ return current;
67
+ }, []);
68
+ const onClick = useCallback(async () => {
69
+ if (!node.postUrl) {
70
+ return { isSuccessful: false, message: "No POST URL configured for this button" };
71
+ }
72
+ setIsLoading(true);
73
+ try {
74
+ const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
75
+ let parsedPayload = {};
76
+ if (node.payload) {
77
+ try {
78
+ const payloadStr = replaceTemplateVariables(node.payload);
79
+ parsedPayload = JSON.parse(payloadStr);
80
+ console.log("Parsed payload:", parsedPayload);
81
+ } catch (err) {
82
+ console.error("Failed to parse payload JSON:", err);
83
+ parsedPayload = { error: "Invalid payload JSON" };
84
+ }
85
+ }
86
+ const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
87
+ const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
88
+ console.log("API Response:", response);
89
+ if (response && !response.isSuccessful) {
90
+ const errorMessage = response.message || "API request failed";
91
+ setIsLoading(false);
92
+ return { isSuccessful: false, message: errorMessage };
93
+ }
94
+ if (response?.message) {
95
+ ToastService_default.showSuccess(response.message);
96
+ }
97
+ if (response && node.redirectUrl) {
98
+ const fieldNames = extractFieldNames(node.redirectUrl);
99
+ console.log("Field names in redirect URL:", fieldNames);
100
+ const fieldValueMap = {};
101
+ fieldNames.forEach((fieldName) => {
102
+ const value = getNestedValue(response, fieldName);
103
+ if (value !== void 0) {
104
+ fieldValueMap[fieldName] = String(value);
105
+ } else {
106
+ const resultValue = getNestedValue(response, `result.${fieldName}`);
107
+ if (resultValue !== void 0) {
108
+ fieldValueMap[fieldName] = String(resultValue);
109
+ } else {
110
+ const dataValue = getNestedValue(response, `data.${fieldName}`);
111
+ if (dataValue !== void 0) {
112
+ fieldValueMap[fieldName] = String(dataValue);
113
+ }
114
+ }
115
+ }
116
+ });
117
+ console.log("Field value map:", fieldValueMap);
118
+ const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
119
+ if (missingFields.length > 0) {
120
+ console.warn(`Missing field values for: ${missingFields.join(", ")}`);
121
+ }
122
+ let resolvedRedirectUrl = node.redirectUrl;
123
+ Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
124
+ const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
125
+ const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
126
+ resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
127
+ resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
128
+ });
129
+ resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
130
+ console.log("Final redirect URL:", resolvedRedirectUrl);
131
+ if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
132
+ window.location.href = resolvedRedirectUrl;
133
+ }
134
+ } else if (!response) {
135
+ const errorMessage = "No response from server";
136
+ setIsLoading(false);
137
+ return { isSuccessful: false, message: errorMessage };
138
+ }
139
+ setIsLoading(false);
140
+ return { isSuccessful: true, message: response?.message, result: response };
141
+ } catch (err) {
142
+ console.error("Button API call failed:", err);
143
+ const errorMessage = err.message || "An unexpected error occurred";
144
+ setIsLoading(false);
145
+ return { isSuccessful: false, message: errorMessage };
146
+ }
147
+ }, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue, props.apiBaseUrl, props.session]);
148
+ const renderButtonContent = () => {
149
+ if (children) {
150
+ return children;
151
+ }
152
+ if (linkText) {
153
+ return /* @__PURE__ */ jsx("span", { children: linkText });
154
+ }
155
+ return node.title || "Button";
156
+ };
157
+ return /* @__PURE__ */ jsx("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx(
158
+ Button_default,
159
+ {
160
+ ButtonType: linkType,
161
+ onClick,
162
+ disabled: isLoading,
163
+ className: "w-full",
164
+ children: renderButtonContent()
165
+ }
166
+ ) });
167
+ };
168
+ var LinkNodeButton_default = LinkNodeButton;
169
+ export {
170
+ LinkNodeButton_default as default
171
+ };
@@ -0,0 +1,181 @@
1
+ "use client";
2
+ import {
3
+ OdataBuilder
4
+ } from "./chunk-UFKPTMM7.mjs";
5
+ import {
6
+ Constants,
7
+ Hyperlink,
8
+ Icon_default
9
+ } from "./chunk-DBHUCH4B.mjs";
10
+ import "./chunk-56HSDML5.mjs";
11
+
12
+ // src/components/Pagination.tsx
13
+ import { useMemo } from "react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var Pagination = (props) => {
16
+ const { dataset, path, query, showPageSizeSelector = false, showJumpToPage = false } = props;
17
+ const builder = useMemo(() => {
18
+ const b = new OdataBuilder(path);
19
+ if (query) b.setQuery(query);
20
+ return b;
21
+ }, [path, query]);
22
+ const activePageNumber = builder.getPageNumber(Constants.pagesize);
23
+ const totalItems = dataset?.count || 0;
24
+ const itemsPerPage = parseInt(builder.top || Constants.pagesize.toString());
25
+ const totalPages = Math.ceil(totalItems / itemsPerPage);
26
+ const startItem = totalItems > 0 ? (activePageNumber - 1) * itemsPerPage + 1 : 0;
27
+ const endItem = Math.min(activePageNumber * itemsPerPage, totalItems);
28
+ const getPaginationRange = () => {
29
+ const delta = 1;
30
+ const range = [];
31
+ if (totalPages <= 7) {
32
+ return Array.from({ length: totalPages }, (_, i) => i + 1);
33
+ }
34
+ range.push(1);
35
+ let start = Math.max(2, activePageNumber - delta);
36
+ let end = Math.min(totalPages - 1, activePageNumber + delta);
37
+ if (activePageNumber - delta <= 2) {
38
+ end = Math.min(totalPages - 1, 4);
39
+ }
40
+ if (activePageNumber + delta >= totalPages - 1) {
41
+ start = Math.max(2, totalPages - 4);
42
+ }
43
+ if (start > 2) {
44
+ range.push("...");
45
+ }
46
+ for (let i = start; i <= end; i++) {
47
+ range.push(i);
48
+ }
49
+ if (end < totalPages - 1) {
50
+ range.push("...");
51
+ }
52
+ if (totalPages > 1) {
53
+ range.push(totalPages);
54
+ }
55
+ return range;
56
+ };
57
+ const paginationRange = getPaginationRange();
58
+ const PageButton = ({ page, children }) => /* @__PURE__ */ jsx(
59
+ Hyperlink,
60
+ {
61
+ linkType: "Link" /* Link */,
62
+ className: `
63
+ min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center px-2.5 md:px-3
64
+ border text-sm font-medium transition-colors duration-150
65
+ ${activePageNumber === page ? "bg-primary-base font-semibold" : ""}
66
+ `,
67
+ href: builder.getNewPageUrl(page),
68
+ children
69
+ }
70
+ );
71
+ const NavigationButton = ({ page, disabled, children }) => {
72
+ if (disabled) {
73
+ return /* @__PURE__ */ jsx("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 });
74
+ }
75
+ return /* @__PURE__ */ jsx(
76
+ Hyperlink,
77
+ {
78
+ 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",
79
+ href: builder.getNewPageUrl(page),
80
+ children
81
+ }
82
+ );
83
+ };
84
+ if (totalPages <= 1 && totalItems === 0) return null;
85
+ return /* @__PURE__ */ jsxs("div", { className: "py-6 border-t bg-default", children: [
86
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row items-center justify-between gap-4", children: [
87
+ /* @__PURE__ */ jsxs("div", { className: "text-sm", children: [
88
+ "Showing ",
89
+ /* @__PURE__ */ jsxs("span", { className: "font-semibold", children: [
90
+ startItem,
91
+ "-",
92
+ endItem
93
+ ] }),
94
+ " ",
95
+ "out of ",
96
+ /* @__PURE__ */ jsx("span", { className: "font-semibold", children: totalItems.toLocaleString() }),
97
+ " results"
98
+ ] }),
99
+ totalPages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-1", children: [
100
+ /* @__PURE__ */ jsxs(
101
+ NavigationButton,
102
+ {
103
+ page: activePageNumber - 1,
104
+ disabled: activePageNumber === 1,
105
+ children: [
106
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Icon_default, { name: "chevronLeft", className: "w-4 h-4 mr-1" }) }),
107
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Prev" })
108
+ ]
109
+ }
110
+ ),
111
+ paginationRange.map((item, index) => {
112
+ if (item === "...") {
113
+ return /* @__PURE__ */ jsx(
114
+ "span",
115
+ {
116
+ className: "min-w-[20px] md:min-w-[40px] h-10 flex items-center justify-center text-gray-500",
117
+ children: "..."
118
+ },
119
+ `ellipsis-${index}`
120
+ );
121
+ }
122
+ const page = item;
123
+ return /* @__PURE__ */ jsx(PageButton, { page, children: page }, page);
124
+ }),
125
+ /* @__PURE__ */ jsxs(
126
+ NavigationButton,
127
+ {
128
+ page: activePageNumber + 1,
129
+ disabled: activePageNumber === totalPages,
130
+ children: [
131
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Next" }),
132
+ /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Icon_default, { name: "chevronRight", className: "w-4 h-4 ml-1" }) })
133
+ ]
134
+ }
135
+ )
136
+ ] }),
137
+ showJumpToPage && totalPages > 5 && /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
138
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Go to:" }),
139
+ /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(
140
+ "input",
141
+ {
142
+ type: "number",
143
+ min: "1",
144
+ max: totalPages,
145
+ defaultValue: activePageNumber,
146
+ className: "w-20 h-10 px-3 border rounded text-sm focus:outline-none focus:ring-2 focus:border-transparent",
147
+ onKeyDown: (e) => {
148
+ if (e.key === "Enter") {
149
+ const input = e.target;
150
+ const page = parseInt(input.value);
151
+ if (page >= 1 && page <= totalPages && page !== activePageNumber) {
152
+ window.location.href = builder.getNewPageUrl(page);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ ) })
158
+ ] })
159
+ ] }),
160
+ showPageSizeSelector && /* @__PURE__ */ jsx("div", { className: "mt-4 pt-4 border-t bg-default", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
161
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Show:" }),
162
+ /* @__PURE__ */ jsx("div", { className: "flex space-x-1", children: [10, 25, 50, 100].map((size) => /* @__PURE__ */ jsx(
163
+ Hyperlink,
164
+ {
165
+ className: `
166
+ px-3 py-1 text-sm rounded border transition-colors duration-150
167
+ ${itemsPerPage === size ? "bg-primary-base font-medium" : "bg-neutral-weak"}
168
+ `,
169
+ href: builder.getNewPageSizeUrl(size),
170
+ children: size
171
+ },
172
+ size
173
+ )) }),
174
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "per page" })
175
+ ] }) })
176
+ ] });
177
+ };
178
+ var Pagination_default = Pagination;
179
+ export {
180
+ Pagination_default as default
181
+ };
@@ -0,0 +1,109 @@
1
+ import {
2
+ buttonClasses
3
+ } from "./chunk-56HSDML5.mjs";
4
+
5
+ // src/components/controls/edit/InputControlType.tsx
6
+ var Constants = {
7
+ pagesize: 10
8
+ };
9
+ var InputControlType = {
10
+ lineTextInput: "text",
11
+ multilineTextInput: "multilinetext",
12
+ emailInput: "email",
13
+ moneyInput: "money",
14
+ select: "select",
15
+ percentageInput: "percentage",
16
+ asset: "asset",
17
+ phoneInput: "phone",
18
+ numberInput: "number",
19
+ checkboxInput: "boolean",
20
+ otpInput: "otp",
21
+ datetimeInput: "datetime",
22
+ timeInput: "time",
23
+ colorInput: "colorInput",
24
+ selectWithSearchInput: "selectWithSearchInput",
25
+ selectWithSearchPanel: "selectWithSearchPanel",
26
+ booleanSelect: "booleanSelect",
27
+ switchInput: "switchInput",
28
+ videoInput: "videoInput"
29
+ };
30
+ var InputControlType_default = InputControlType;
31
+
32
+ // src/components/dataForm/Hyperlink.tsx
33
+ import Link from "next/link";
34
+ import { Fragment, jsx } from "react/jsx-runtime";
35
+ function Hyperlink(props) {
36
+ let linkClass = props.linkType ? buttonClasses.get(props.linkType) : buttonClasses.get("Link" /* Link */);
37
+ const target = props?.href?.startsWith("http") ? "_blank" : "_self";
38
+ const additionalProps = {};
39
+ if (target == "_blank") {
40
+ additionalProps.rel = "noopener noreferrer";
41
+ }
42
+ return /* @__PURE__ */ jsx(Fragment, { children: props.href ? /* @__PURE__ */ jsx(
43
+ Link,
44
+ {
45
+ href: props.href,
46
+ prefetch: false,
47
+ className: [linkClass, props.className].filter(Boolean).join(" "),
48
+ ...additionalProps,
49
+ target,
50
+ children: props.children
51
+ }
52
+ ) : props.isHeading ? /* @__PURE__ */ jsx("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ jsx("span", { className: props.className, children: props.children }) });
53
+ }
54
+
55
+ // src/svg/chevron-updown.tsx
56
+ import { jsx as jsx2 } from "react/jsx-runtime";
57
+ var ChevronUpDown = (props) => {
58
+ 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: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) });
59
+ };
60
+ var chevron_updown_default = ChevronUpDown;
61
+
62
+ // src/svg/chevron-down.tsx
63
+ import { jsx as jsx3 } from "react/jsx-runtime";
64
+ var ChevronDown = (props) => {
65
+ 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: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) });
66
+ };
67
+ var chevron_down_default = ChevronDown;
68
+
69
+ // src/svg/chevron-up.tsx
70
+ import { jsx as jsx4 } from "react/jsx-runtime";
71
+ var ChevronUp = (props) => {
72
+ 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: "M4.5 15.75l7.5-7.5 7.5 7.5" }) });
73
+ };
74
+ var chevron_up_default = ChevronUp;
75
+
76
+ // src/svg/plus.tsx
77
+ import { jsx as jsx5 } from "react/jsx-runtime";
78
+ var Plus = (props) => {
79
+ return /* @__PURE__ */ jsx5("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__ */ jsx5("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" }) });
80
+ };
81
+ var plus_default = Plus;
82
+
83
+ // src/svg/Icons.tsx
84
+ var Icons = {
85
+ chevronUpDown: chevron_updown_default,
86
+ chevronDown: chevron_down_default,
87
+ chevronUp: chevron_up_default,
88
+ plus: plus_default
89
+ };
90
+ var Icons_default = Icons;
91
+
92
+ // src/svg/Icon.tsx
93
+ import { jsx as jsx6 } from "react/jsx-runtime";
94
+ var Icon = ({ name, className, ...props }) => {
95
+ const IconComponent = Icons_default[name];
96
+ if (!IconComponent) {
97
+ console.error(`Icon "${name}" not found.`);
98
+ return null;
99
+ }
100
+ return /* @__PURE__ */ jsx6(IconComponent, { ...props, className });
101
+ };
102
+ var Icon_default = Icon;
103
+
104
+ export {
105
+ Constants,
106
+ InputControlType_default,
107
+ Hyperlink,
108
+ Icon_default
109
+ };