@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260722072620 → 0.8.1-dev.20260722074927

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,110 @@
1
+ "use client";
2
+
3
+ import {
4
+ buttonClasses
5
+ } from "./chunk-IMNQO57B.mjs";
6
+
7
+ // src/components/controls/edit/InputControlType.tsx
8
+ var Constants = {
9
+ pagesize: 10
10
+ };
11
+ var InputControlType = {
12
+ lineTextInput: "text",
13
+ multilineTextInput: "multilinetext",
14
+ emailInput: "email",
15
+ moneyInput: "money",
16
+ select: "select",
17
+ percentageInput: "percentage",
18
+ asset: "asset",
19
+ phoneInput: "phone",
20
+ numberInput: "number",
21
+ checkboxInput: "boolean",
22
+ otpInput: "otp",
23
+ datetimeInput: "datetime",
24
+ timeInput: "time",
25
+ colorInput: "colorInput",
26
+ selectWithSearchInput: "selectWithSearchInput",
27
+ selectWithSearchPanel: "selectWithSearchPanel",
28
+ booleanSelect: "booleanSelect",
29
+ switchInput: "switchInput"
30
+ };
31
+ var InputControlType_default = InputControlType;
32
+
33
+ // src/components/dataForm/Hyperlink.tsx
34
+ import Link from "next/link";
35
+ import { Fragment, jsx } from "react/jsx-runtime";
36
+ function Hyperlink(props) {
37
+ let linkClass = props.linkType ? buttonClasses.get(props.linkType) : buttonClasses.get("Link" /* Link */);
38
+ const target = props?.href?.startsWith("http") ? "_blank" : "_self";
39
+ const additionalProps = {};
40
+ if (target == "_blank") {
41
+ additionalProps.rel = "noopener noreferrer";
42
+ }
43
+ return /* @__PURE__ */ jsx(Fragment, { children: props.href ? /* @__PURE__ */ jsx(
44
+ Link,
45
+ {
46
+ href: props.href,
47
+ prefetch: false,
48
+ className: [linkClass, props.className].filter(Boolean).join(" "),
49
+ ...additionalProps,
50
+ target,
51
+ children: props.children
52
+ }
53
+ ) : props.isHeading ? /* @__PURE__ */ jsx("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ jsx("span", { className: props.className, children: props.children }) });
54
+ }
55
+
56
+ // src/svg/chevron-updown.tsx
57
+ import { jsx as jsx2 } from "react/jsx-runtime";
58
+ var ChevronUpDown = (props) => {
59
+ 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" }) });
60
+ };
61
+ var chevron_updown_default = ChevronUpDown;
62
+
63
+ // src/svg/chevron-down.tsx
64
+ import { jsx as jsx3 } from "react/jsx-runtime";
65
+ var ChevronDown = (props) => {
66
+ 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" }) });
67
+ };
68
+ var chevron_down_default = ChevronDown;
69
+
70
+ // src/svg/chevron-up.tsx
71
+ import { jsx as jsx4 } from "react/jsx-runtime";
72
+ var ChevronUp = (props) => {
73
+ 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" }) });
74
+ };
75
+ var chevron_up_default = ChevronUp;
76
+
77
+ // src/svg/plus.tsx
78
+ import { jsx as jsx5 } from "react/jsx-runtime";
79
+ var Plus = (props) => {
80
+ 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" }) });
81
+ };
82
+ var plus_default = Plus;
83
+
84
+ // src/svg/Icons.tsx
85
+ var Icons = {
86
+ chevronUpDown: chevron_updown_default,
87
+ chevronDown: chevron_down_default,
88
+ chevronUp: chevron_up_default,
89
+ plus: plus_default
90
+ };
91
+ var Icons_default = Icons;
92
+
93
+ // src/svg/Icon.tsx
94
+ import { jsx as jsx6 } from "react/jsx-runtime";
95
+ var Icon = ({ name, className, ...props }) => {
96
+ const IconComponent = Icons_default[name];
97
+ if (!IconComponent) {
98
+ console.error(`Icon "${name}" not found.`);
99
+ return null;
100
+ }
101
+ return /* @__PURE__ */ jsx6(IconComponent, { ...props, className });
102
+ };
103
+ var Icon_default = Icon;
104
+
105
+ export {
106
+ Constants,
107
+ InputControlType_default,
108
+ Hyperlink,
109
+ Icon_default
110
+ };
@@ -0,0 +1,214 @@
1
+ "use client";
2
+
3
+ import {
4
+ buttonClasses,
5
+ progressClasses
6
+ } from "./chunk-IMNQO57B.mjs";
7
+
8
+ // src/components/ToastService.tsx
9
+ var toastHandlersKey = "__digitalStoreToastHandlers";
10
+ var getToastHandlers = () => {
11
+ const globalScope = globalThis;
12
+ if (!globalScope[toastHandlersKey]) {
13
+ globalScope[toastHandlersKey] = {};
14
+ }
15
+ return globalScope[toastHandlersKey];
16
+ };
17
+ var ToastService = class {
18
+ static initialize(showToast, closeToast) {
19
+ const handlers = getToastHandlers();
20
+ handlers.showToast = showToast;
21
+ handlers.closeToast = closeToast;
22
+ }
23
+ static showError(message) {
24
+ const handlers = getToastHandlers();
25
+ if (handlers.showToast) {
26
+ handlers.showToast(message, "error");
27
+ }
28
+ }
29
+ static showInfo(message) {
30
+ const handlers = getToastHandlers();
31
+ if (handlers.showToast) {
32
+ handlers.showToast(message, "info");
33
+ }
34
+ }
35
+ static showWarning(message) {
36
+ const handlers = getToastHandlers();
37
+ if (handlers.showToast) {
38
+ handlers.showToast(message, "warning");
39
+ }
40
+ }
41
+ static showSuccess(message) {
42
+ const handlers = getToastHandlers();
43
+ if (handlers.showToast) {
44
+ handlers.showToast(message, "success");
45
+ }
46
+ }
47
+ static close() {
48
+ const handlers = getToastHandlers();
49
+ if (handlers.closeToast) {
50
+ handlers.closeToast();
51
+ }
52
+ }
53
+ };
54
+ var ToastService_default = ToastService;
55
+
56
+ // src/components/Button.tsx
57
+ import React3, { useState as useState2 } from "react";
58
+
59
+ // src/components/Confirm.tsx
60
+ import { useState } from "react";
61
+
62
+ // src/components/ClientButton.tsx
63
+ import React from "react";
64
+ import { jsx } from "react/jsx-runtime";
65
+ var ClientButton = (props) => {
66
+ const execute = async (event) => {
67
+ if (props.onClick !== void 0) {
68
+ props.onClick();
69
+ } else {
70
+ ToastService_default.showError("No action defined.");
71
+ }
72
+ };
73
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
74
+ return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
75
+ "button",
76
+ {
77
+ type: "button",
78
+ onClick: execute,
79
+ className: buttonClass + " " + props.className,
80
+ children: props.children
81
+ }
82
+ ) });
83
+ };
84
+ var ClientButton_default = ClientButton;
85
+
86
+ // src/components/Confirm.tsx
87
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
88
+ var Confirm = ({ message, onConfirm, onCancel }) => {
89
+ const [showModal, setShowModal] = useState(true);
90
+ const handleConfirmAction = () => {
91
+ setShowModal(false);
92
+ if (onConfirm) {
93
+ onConfirm();
94
+ }
95
+ };
96
+ const handleCancelAction = () => {
97
+ setShowModal(false);
98
+ if (onCancel) {
99
+ onCancel();
100
+ }
101
+ };
102
+ return /* @__PURE__ */ jsx2(Fragment, { children: showModal && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
103
+ /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 bg-black opacity-70" }),
104
+ /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
105
+ /* @__PURE__ */ jsx2("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
106
+ /* @__PURE__ */ jsx2("p", { className: "mb-4", children: message }),
107
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-8", children: [
108
+ /* @__PURE__ */ jsx2(
109
+ ClientButton_default,
110
+ {
111
+ onClick: handleCancelAction,
112
+ ButtonType: "PrimaryHollow" /* Hollow */,
113
+ children: "Cancel"
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx2(
117
+ ClientButton_default,
118
+ {
119
+ onClick: handleConfirmAction,
120
+ children: "Confirm"
121
+ }
122
+ )
123
+ ] })
124
+ ] })
125
+ ] }) });
126
+ };
127
+ var Confirm_default = Confirm;
128
+ {
129
+ }
130
+
131
+ // src/components/Button.tsx
132
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
133
+ var Button = (props) => {
134
+ const [inProgress, setInProgress] = useState2(false);
135
+ const [isActionPerformed, setIsActionPerformed] = useState2(false);
136
+ const [responseMessage, setResponseMessage] = useState2(null);
137
+ const [showModal, setShowModal] = useState2(null);
138
+ const execute = async (event) => {
139
+ event.preventDefault();
140
+ event.stopPropagation();
141
+ if (props.confirm) {
142
+ const confirmed = await showConfirmation("Are you sure you want to delete this item?");
143
+ setShowModal(null);
144
+ if (!confirmed) {
145
+ return;
146
+ }
147
+ }
148
+ if (props.oneTimeAction && isActionPerformed) {
149
+ return;
150
+ }
151
+ setInProgress(true);
152
+ let isValid = true;
153
+ if (props.onValidate !== void 0) {
154
+ isValid = await props.onValidate();
155
+ if (!isValid) {
156
+ setInProgress(false);
157
+ ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
158
+ return;
159
+ }
160
+ }
161
+ if (props.onClick !== void 0) {
162
+ let response = await props.onClick();
163
+ if (response.isSuccessful) {
164
+ setIsActionPerformed(true);
165
+ setResponseMessage(response.message);
166
+ if (props.showToast) {
167
+ ToastService_default.showInfo(response.message || "");
168
+ }
169
+ } else {
170
+ ToastService_default.showError(response.message || "");
171
+ }
172
+ } else {
173
+ ToastService_default.showError("No action defined.");
174
+ }
175
+ setInProgress(false);
176
+ };
177
+ const showConfirmation = (message) => {
178
+ return new Promise((resolve) => {
179
+ const onConfirm = () => resolve(true);
180
+ const onCancel = () => resolve(false);
181
+ setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
182
+ });
183
+ };
184
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
185
+ let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
186
+ const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
187
+ return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
188
+ /* @__PURE__ */ jsxs2(
189
+ "button",
190
+ {
191
+ type: "submit",
192
+ onClick: execute,
193
+ disabled: props.disabled,
194
+ title: isDisabled ? "The button is disabled to prevent any action" : "",
195
+ className: buttonClass + " relative " + props.className,
196
+ children: [
197
+ isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
198
+ 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: [
199
+ /* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
200
+ /* @__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" })
201
+ ] }) })
202
+ ]
203
+ }
204
+ ),
205
+ showModal
206
+ ] });
207
+ };
208
+ var Button_default = Button;
209
+
210
+ export {
211
+ ToastService_default,
212
+ ClientButton_default,
213
+ Button_default
214
+ };
@@ -0,0 +1,201 @@
1
+ "use client";
2
+
3
+ import {
4
+ Constants
5
+ } from "./chunk-FI2KJBK2.mjs";
6
+
7
+ // src/clients/OdataBuilder.tsx
8
+ var OdataBuilder = class {
9
+ constructor(url) {
10
+ this.baseUrl = url;
11
+ this.top = Constants.pagesize.toString();
12
+ this.skip = "0";
13
+ this.keyword = "";
14
+ this.filterBy = "";
15
+ this.orderBy = "";
16
+ }
17
+ // parseSearchParams(ReadonlyUrlSearchParams): DataQuery {
18
+ // this.top = top;
19
+ // return this;
20
+ // }
21
+ setQuery(odata) {
22
+ if (odata) {
23
+ for (const key in odata) {
24
+ if (odata[key] != null && odata[key] != "") {
25
+ if (key == "$skip") {
26
+ this.setSkip(odata[key]);
27
+ }
28
+ if (key == "$filter") {
29
+ this.setFilter(odata[key]);
30
+ }
31
+ if (key == "$top") {
32
+ this.setTop(odata[key]);
33
+ }
34
+ if (key == "$orderby") {
35
+ this.setOrderBy(odata[key]);
36
+ }
37
+ if (key == "searchTerm") {
38
+ this.searchTerm = odata[key];
39
+ }
40
+ if (key == "searchCols") {
41
+ this.searchCols = odata[key];
42
+ }
43
+ }
44
+ }
45
+ }
46
+ return this;
47
+ }
48
+ // parseKeyValuePairs(inputString: string): { [key: string]: string } {
49
+ // return inputString.split('$')
50
+ // .map((pair) => pair.split('='))
51
+ // .reduce((result: { [key: string]: string }, [key, value]) => {
52
+ // if (key && value) {
53
+ // result[key.trim()] = value.trim();
54
+ // }
55
+ // return result;
56
+ // }, {});
57
+ // }
58
+ static getOdataQueryString(obj, defaultOrder) {
59
+ let queryString = "";
60
+ let skip = (obj && obj["$skip"]) ?? "0";
61
+ let top = (obj && obj["$top"]) ?? Constants.pagesize.toString();
62
+ queryString = `$skip=${skip}&$top=${top}&$count=true`;
63
+ if (obj?.["searchTerm"] && obj["searchTerm"].trim() !== "") {
64
+ queryString += `&searchTerm=${encodeURIComponent(obj["searchTerm"])}`;
65
+ }
66
+ if (obj?.["searchCols"] && obj["searchCols"].trim() !== "") {
67
+ queryString += `&searchCols=${encodeURIComponent(obj["searchCols"])}`;
68
+ }
69
+ if (obj) {
70
+ if (obj["$filter"] && obj["$filter"] !== null && obj["$filter"] !== "") {
71
+ queryString = queryString + `&$filter=${encodeURIComponent(obj["$filter"])}`;
72
+ }
73
+ if (obj["$orderby"] && obj["$orderby"] !== null && obj["$orderby"] !== "") {
74
+ queryString = queryString + `&$orderby=${encodeURIComponent(obj["$orderby"])}`;
75
+ } else if (defaultOrder) {
76
+ queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
77
+ }
78
+ } else {
79
+ if (defaultOrder) {
80
+ queryString = queryString + `&$orderby=${encodeURIComponent(defaultOrder)}`;
81
+ }
82
+ }
83
+ return queryString;
84
+ }
85
+ setTop(top) {
86
+ this.top = top;
87
+ return this;
88
+ }
89
+ setSkip(skip) {
90
+ this.skip = skip;
91
+ return this;
92
+ }
93
+ setKeyword(keyword) {
94
+ this.keyword = keyword;
95
+ return this;
96
+ }
97
+ setFilter(filterBy) {
98
+ this.filterBy = filterBy;
99
+ return this;
100
+ }
101
+ setOrderBy(orderBy) {
102
+ this.orderBy = orderBy;
103
+ return this;
104
+ }
105
+ getPageNumber(pageSize) {
106
+ let pageNumber = 1;
107
+ if (this.skip && this.top) {
108
+ const skip = parseInt(this.skip);
109
+ const top = parseInt(this.top);
110
+ if (!isNaN(skip) && !isNaN(top)) {
111
+ pageNumber = skip / pageSize + 1;
112
+ }
113
+ }
114
+ return pageNumber;
115
+ }
116
+ getUrl() {
117
+ let url = `${this.baseUrl}?$skip=${this.skip}&$top=${this.top}&$count=true`;
118
+ if (this.filterBy !== null && this.filterBy !== "") {
119
+ url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
120
+ }
121
+ if (this.orderBy !== null && this.orderBy !== "") {
122
+ url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
123
+ }
124
+ if (this.searchTerm) {
125
+ url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
126
+ }
127
+ if (this.searchCols) {
128
+ url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
129
+ }
130
+ console.log(url);
131
+ return url;
132
+ }
133
+ getNewOrderByUrl(orderBy) {
134
+ let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
135
+ if (this.filterBy !== null && this.filterBy !== "") {
136
+ url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
137
+ }
138
+ if (this.searchTerm) {
139
+ url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
140
+ }
141
+ if (this.searchCols) {
142
+ url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
143
+ }
144
+ url = url + `&$orderby=${encodeURIComponent(orderBy)}`;
145
+ return url;
146
+ }
147
+ getNewFilterUrl(filterBy) {
148
+ let url = `${this.baseUrl}?$skip=${0}&$top=${this.top}&$count=true`;
149
+ if (filterBy !== null && filterBy !== "") {
150
+ url = url + `&$filter=${encodeURIComponent(filterBy)}`;
151
+ }
152
+ if (this.orderBy !== null && this.orderBy !== "") {
153
+ url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
154
+ }
155
+ if (this.searchTerm) {
156
+ url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
157
+ }
158
+ if (this.searchCols) {
159
+ url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
160
+ }
161
+ return url;
162
+ }
163
+ getNewPageUrl(page) {
164
+ let skip = page * Constants.pagesize - Constants.pagesize;
165
+ let url = `${this.baseUrl}?$skip=${skip}&$top=${this.top}&$count=true`;
166
+ if (this.filterBy !== null && this.filterBy !== "") {
167
+ url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
168
+ }
169
+ if (this.orderBy !== null && this.orderBy !== "") {
170
+ url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
171
+ }
172
+ if (this.searchTerm) {
173
+ url += `&searchTerm=${encodeURIComponent(this.searchTerm)}`;
174
+ }
175
+ if (this.searchCols) {
176
+ url += `&searchCols=${encodeURIComponent(this.searchCols)}`;
177
+ }
178
+ return url;
179
+ }
180
+ getNewPageSizeUrl(pageSize) {
181
+ const currentPage = this.getPageNumber(
182
+ parseInt(this.top || Constants.pagesize.toString())
183
+ );
184
+ const skip = (currentPage - 1) * pageSize;
185
+ let url = `${this.baseUrl}?$skip=${skip}&$top=${pageSize}&$count=true`;
186
+ if (this.filterBy !== null && this.filterBy !== "") {
187
+ url = url + `&$filter=${encodeURIComponent(this.filterBy)}`;
188
+ }
189
+ if (this.orderBy !== null && this.orderBy !== "") {
190
+ url = url + `&$orderby=${encodeURIComponent(this.orderBy)}`;
191
+ }
192
+ return url;
193
+ }
194
+ getOrderBy() {
195
+ return this.orderBy;
196
+ }
197
+ };
198
+
199
+ export {
200
+ OdataBuilder
201
+ };