@acoustte-digital-services/digitalstore-controls 0.12.0 → 0.12.1
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.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +214 -0
- package/dist/index.mjs +206 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ViewControlPropsView {
|
|
4
|
+
value?: any;
|
|
5
|
+
controlType: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
width?: string;
|
|
8
|
+
apiBaseUrl?: string;
|
|
9
|
+
customProps?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const ViewControl: React.FC<ViewControlPropsView>;
|
|
13
|
+
|
|
1
14
|
declare const ViewControlTypesView: {
|
|
2
15
|
lineTextView: string;
|
|
3
16
|
emailTextView: string;
|
|
@@ -13,4 +26,4 @@ declare const ViewControlTypesView: {
|
|
|
13
26
|
text: string;
|
|
14
27
|
};
|
|
15
28
|
|
|
16
|
-
export { ViewControlTypesView };
|
|
29
|
+
export { ViewControl, ViewControlTypesView };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ViewControlPropsView {
|
|
4
|
+
value?: any;
|
|
5
|
+
controlType: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
width?: string;
|
|
8
|
+
apiBaseUrl?: string;
|
|
9
|
+
customProps?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const ViewControl: React.FC<ViewControlPropsView>;
|
|
13
|
+
|
|
1
14
|
declare const ViewControlTypesView: {
|
|
2
15
|
lineTextView: string;
|
|
3
16
|
emailTextView: string;
|
|
@@ -13,4 +26,4 @@ declare const ViewControlTypesView: {
|
|
|
13
26
|
text: string;
|
|
14
27
|
};
|
|
15
28
|
|
|
16
|
-
export { ViewControlTypesView };
|
|
29
|
+
export { ViewControl, ViewControlTypesView };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
6
22
|
var __export = (target, all) => {
|
|
7
23
|
for (var name in all)
|
|
8
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,15 +31,190 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
31
|
}
|
|
16
32
|
return to;
|
|
17
33
|
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
18
42
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
43
|
|
|
20
44
|
// src/index.ts
|
|
21
45
|
var index_exports = {};
|
|
22
46
|
__export(index_exports, {
|
|
47
|
+
ViewControl: () => ViewControlView_default,
|
|
23
48
|
ViewControlTypesView: () => ViewControlTypesView_default
|
|
24
49
|
});
|
|
25
50
|
module.exports = __toCommonJS(index_exports);
|
|
26
51
|
|
|
52
|
+
// src/controls/view/ViewControlView.tsx
|
|
53
|
+
var import_react11 = __toESM(require("react"));
|
|
54
|
+
|
|
55
|
+
// src/controls/view/LineTextView.tsx
|
|
56
|
+
var import_react = __toESM(require("react"));
|
|
57
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
58
|
+
var linetextView = (props) => {
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: props.value });
|
|
60
|
+
};
|
|
61
|
+
var LineTextView_default = linetextView;
|
|
62
|
+
|
|
63
|
+
// src/controls/view/EmailTextView.tsx
|
|
64
|
+
var import_react2 = __toESM(require("react"));
|
|
65
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
66
|
+
var emailtextView = (props) => {
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: props.value });
|
|
68
|
+
};
|
|
69
|
+
var EmailTextView_default = emailtextView;
|
|
70
|
+
|
|
71
|
+
// src/controls/view/MoneyView.tsx
|
|
72
|
+
var import_react3 = __toESM(require("react"));
|
|
73
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
74
|
+
var moneyView = (props) => {
|
|
75
|
+
const parsednumberView = parseFloat(props.value);
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.default.Fragment, { children: !Number.isNaN(parsednumberView) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: parsednumberView < 0 ? "textView-alert" : "", children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "mr-0.5", children: "\u20B9" }),
|
|
78
|
+
parsednumberView.toLocaleString()
|
|
79
|
+
] }) });
|
|
80
|
+
};
|
|
81
|
+
var MoneyView_default = moneyView;
|
|
82
|
+
|
|
83
|
+
// src/controls/view/NumberView.tsx
|
|
84
|
+
var import_react4 = __toESM(require("react"));
|
|
85
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
86
|
+
var numberView = (props) => {
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.default.Fragment, { children: props.value });
|
|
88
|
+
};
|
|
89
|
+
var NumberView_default = numberView;
|
|
90
|
+
|
|
91
|
+
// src/controls/view/DateView.tsx
|
|
92
|
+
var import_react5 = __toESM(require("react"));
|
|
93
|
+
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
94
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
95
|
+
var dateViewView = (props) => {
|
|
96
|
+
var _a;
|
|
97
|
+
let localdateViewTime = "";
|
|
98
|
+
let timezone;
|
|
99
|
+
try {
|
|
100
|
+
const val = props.value && props.value.toString().includes("Z") ? props.value : props.value + "Z";
|
|
101
|
+
const parseddateView = new Date(val);
|
|
102
|
+
const timezoneOffset = parseddateView.getTimezoneOffset();
|
|
103
|
+
timezone = (_a = import_moment_timezone.default.tz.zone(import_moment_timezone.default.tz.guess())) == null ? void 0 : _a.abbr(timezoneOffset);
|
|
104
|
+
if (props.format && props.format == "timeago") {
|
|
105
|
+
localdateViewTime = formatTimeAgo(parseddateView);
|
|
106
|
+
} else {
|
|
107
|
+
localdateViewTime = parseddateView.toLocaleString() + " " + timezone;
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error("Error parsing dateView:", props.value);
|
|
111
|
+
}
|
|
112
|
+
function formatTimeAgo(inputdate) {
|
|
113
|
+
const currentdateView = /* @__PURE__ */ new Date();
|
|
114
|
+
const timeDifference = Math.floor((currentdateView.getTime() - inputdate.getTime()) / 1e3);
|
|
115
|
+
if (timeDifference < 10) {
|
|
116
|
+
return "few secs ago";
|
|
117
|
+
} else if (timeDifference < 60) {
|
|
118
|
+
return `${timeDifference} secs ago`;
|
|
119
|
+
} else if (timeDifference < 3600) {
|
|
120
|
+
const minutes = Math.floor(timeDifference / 60);
|
|
121
|
+
return `${minutes} min${minutes > 1 ? "s" : ""} ago`;
|
|
122
|
+
} else if (timeDifference < 86400) {
|
|
123
|
+
const hours = Math.floor(timeDifference / 3600);
|
|
124
|
+
const remainingMinutes = Math.floor(timeDifference % 3600 / 60);
|
|
125
|
+
return `${hours} hour${hours > 1 ? "s" : ""}, ${remainingMinutes} min${remainingMinutes > 1 ? "s" : ""} ago`;
|
|
126
|
+
} else if (timeDifference < 14 * 3600) {
|
|
127
|
+
const daysAgo = Math.floor(timeDifference / 86400);
|
|
128
|
+
return `${daysAgo} day${daysAgo > 1 ? "s" : ""} ago`;
|
|
129
|
+
} else {
|
|
130
|
+
const formatteddateView = inputdate.toLocaleString();
|
|
131
|
+
return formatteddateView;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "inline-flex gap-1", children: localdateViewTime == "Invalid dateView undefined" ? "-" : localdateViewTime }) });
|
|
135
|
+
};
|
|
136
|
+
var DateView_default = dateViewView;
|
|
137
|
+
|
|
138
|
+
// src/controls/view/StatusView.tsx
|
|
139
|
+
var import_react6 = __toESM(require("react"));
|
|
140
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
141
|
+
var statusView = (props) => {
|
|
142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react6.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "capitalize font-semibold rounded textView-statusView textView-statusView-" + props.value, children: props.value }) });
|
|
143
|
+
};
|
|
144
|
+
var StatusView_default = statusView;
|
|
145
|
+
|
|
146
|
+
// src/controls/view/StatusBgView.tsx
|
|
147
|
+
var import_react7 = __toESM(require("react"));
|
|
148
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
149
|
+
var statusBgView = (props) => {
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.default.Fragment, { children: props.value && props.value != "" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "py-0.5 px-1.5 textView-xs capitalize textView-white font-semibold rounded bg-statusView bg-statusView-" + props.value, children: props.value }) });
|
|
151
|
+
};
|
|
152
|
+
var StatusBgView_default = statusBgView;
|
|
153
|
+
|
|
154
|
+
// src/controls/view/BooleanView.tsx
|
|
155
|
+
var import_react8 = __toESM(require("react"));
|
|
156
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
157
|
+
var booleanViewView = (props) => {
|
|
158
|
+
const { value, customProps } = props;
|
|
159
|
+
const showOnlyTrueIcon = customProps == null ? void 0 : customProps.showOnlyTrueIcon;
|
|
160
|
+
console.log("BooleanView Debug:", {
|
|
161
|
+
value,
|
|
162
|
+
type: typeof value,
|
|
163
|
+
customProps,
|
|
164
|
+
showOnlyTrueIcon
|
|
165
|
+
});
|
|
166
|
+
const booleanValue = import_react8.default.useMemo(() => {
|
|
167
|
+
if (typeof value === "boolean") return value;
|
|
168
|
+
if (typeof value === "string") {
|
|
169
|
+
return value.toLowerCase() === "true";
|
|
170
|
+
}
|
|
171
|
+
if (typeof value === "number") {
|
|
172
|
+
return value === 1;
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}, [value]);
|
|
176
|
+
if (showOnlyTrueIcon) {
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react8.default.Fragment, { children: booleanValue === true && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
178
|
+
"svg",
|
|
179
|
+
{
|
|
180
|
+
className: "w-15 h-8 textView-green-600",
|
|
181
|
+
fill: "currentColor",
|
|
182
|
+
viewBox: "0 0 20 20",
|
|
183
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
184
|
+
"path",
|
|
185
|
+
{
|
|
186
|
+
fillRule: "evenodd",
|
|
187
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
188
|
+
clipRule: "evenodd"
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
) });
|
|
193
|
+
}
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react8.default.Fragment, { children: booleanValue ? "true" : "false" });
|
|
195
|
+
};
|
|
196
|
+
var BooleanView_default = booleanViewView;
|
|
197
|
+
|
|
198
|
+
// src/controls/view/MultilineTextBulletsView.tsx
|
|
199
|
+
var import_react9 = __toESM(require("react"));
|
|
200
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
201
|
+
var multilineTextBulletsView = (props) => {
|
|
202
|
+
var _a;
|
|
203
|
+
const lines = (_a = props.value) == null ? void 0 : _a.split("\\n");
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react9.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "list-disc", children: lines && lines.map((line, index) => {
|
|
205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: line }, index);
|
|
206
|
+
}) }) });
|
|
207
|
+
};
|
|
208
|
+
var MultilineTextBulletsView_default = multilineTextBulletsView;
|
|
209
|
+
|
|
210
|
+
// src/controls/view/MultilineTextView.tsx
|
|
211
|
+
var import_react10 = __toESM(require("react"));
|
|
212
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
213
|
+
var MultilinetextView = (props) => {
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react10.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "whitespace-pre-line", children: props.value }) });
|
|
215
|
+
};
|
|
216
|
+
var MultilineTextView_default = MultilinetextView;
|
|
217
|
+
|
|
27
218
|
// src/controls/view/ViewControlTypesView.tsx
|
|
28
219
|
var ViewControlTypesView = {
|
|
29
220
|
lineTextView: "lineTextView",
|
|
@@ -41,7 +232,30 @@ var ViewControlTypesView = {
|
|
|
41
232
|
// booleanView: "booleanView"
|
|
42
233
|
};
|
|
43
234
|
var ViewControlTypesView_default = ViewControlTypesView;
|
|
235
|
+
|
|
236
|
+
// src/controls/view/ViewControlView.tsx
|
|
237
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
238
|
+
var ViewControl = (props) => {
|
|
239
|
+
const ControlComponents = {
|
|
240
|
+
[ViewControlTypesView_default.lineTextView]: LineTextView_default,
|
|
241
|
+
[ViewControlTypesView_default.emailTextView]: EmailTextView_default,
|
|
242
|
+
[ViewControlTypesView_default.multilineTextBulletsView]: MultilineTextBulletsView_default,
|
|
243
|
+
[ViewControlTypesView_default.moneyView]: MoneyView_default,
|
|
244
|
+
[ViewControlTypesView_default.numberView]: NumberView_default,
|
|
245
|
+
[ViewControlTypesView_default.dateView]: DateView_default,
|
|
246
|
+
[ViewControlTypesView_default.statusView]: StatusView_default,
|
|
247
|
+
[ViewControlTypesView_default.statusBgView]: StatusBgView_default,
|
|
248
|
+
[ViewControlTypesView_default.multilineTextView]: MultilineTextView_default,
|
|
249
|
+
[ViewControlTypesView_default.booleanView]: BooleanView_default,
|
|
250
|
+
[ViewControlTypesView_default.lineTextView]: LineTextView_default
|
|
251
|
+
// [ViewControlTypes.booleanView]: booleanViewView
|
|
252
|
+
};
|
|
253
|
+
const SelectedControlComponent = ControlComponents[props.controlType];
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.default.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SelectedControlComponent, __spreadValues({}, props)) : "Control not found" });
|
|
255
|
+
};
|
|
256
|
+
var ViewControlView_default = ViewControl;
|
|
44
257
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
258
|
0 && (module.exports = {
|
|
259
|
+
ViewControl,
|
|
46
260
|
ViewControlTypesView
|
|
47
261
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,186 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/controls/view/ViewControlView.tsx
|
|
19
|
+
import React11 from "react";
|
|
20
|
+
|
|
21
|
+
// src/controls/view/LineTextView.tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
var linetextView = (props) => {
|
|
25
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: props.value });
|
|
26
|
+
};
|
|
27
|
+
var LineTextView_default = linetextView;
|
|
28
|
+
|
|
29
|
+
// src/controls/view/EmailTextView.tsx
|
|
30
|
+
import React2 from "react";
|
|
31
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
32
|
+
var emailtextView = (props) => {
|
|
33
|
+
return /* @__PURE__ */ jsx2(React2.Fragment, { children: props.value });
|
|
34
|
+
};
|
|
35
|
+
var EmailTextView_default = emailtextView;
|
|
36
|
+
|
|
37
|
+
// src/controls/view/MoneyView.tsx
|
|
38
|
+
import React3 from "react";
|
|
39
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
40
|
+
var moneyView = (props) => {
|
|
41
|
+
const parsednumberView = parseFloat(props.value);
|
|
42
|
+
return /* @__PURE__ */ jsx3(React3.Fragment, { children: !Number.isNaN(parsednumberView) && /* @__PURE__ */ jsxs("span", { className: parsednumberView < 0 ? "textView-alert" : "", children: [
|
|
43
|
+
/* @__PURE__ */ jsx3("span", { className: "mr-0.5", children: "\u20B9" }),
|
|
44
|
+
parsednumberView.toLocaleString()
|
|
45
|
+
] }) });
|
|
46
|
+
};
|
|
47
|
+
var MoneyView_default = moneyView;
|
|
48
|
+
|
|
49
|
+
// src/controls/view/NumberView.tsx
|
|
50
|
+
import React4 from "react";
|
|
51
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
52
|
+
var numberView = (props) => {
|
|
53
|
+
return /* @__PURE__ */ jsx4(React4.Fragment, { children: props.value });
|
|
54
|
+
};
|
|
55
|
+
var NumberView_default = numberView;
|
|
56
|
+
|
|
57
|
+
// src/controls/view/DateView.tsx
|
|
58
|
+
import React5 from "react";
|
|
59
|
+
import moment from "moment-timezone";
|
|
60
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
61
|
+
var dateViewView = (props) => {
|
|
62
|
+
var _a;
|
|
63
|
+
let localdateViewTime = "";
|
|
64
|
+
let timezone;
|
|
65
|
+
try {
|
|
66
|
+
const val = props.value && props.value.toString().includes("Z") ? props.value : props.value + "Z";
|
|
67
|
+
const parseddateView = new Date(val);
|
|
68
|
+
const timezoneOffset = parseddateView.getTimezoneOffset();
|
|
69
|
+
timezone = (_a = moment.tz.zone(moment.tz.guess())) == null ? void 0 : _a.abbr(timezoneOffset);
|
|
70
|
+
if (props.format && props.format == "timeago") {
|
|
71
|
+
localdateViewTime = formatTimeAgo(parseddateView);
|
|
72
|
+
} else {
|
|
73
|
+
localdateViewTime = parseddateView.toLocaleString() + " " + timezone;
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("Error parsing dateView:", props.value);
|
|
77
|
+
}
|
|
78
|
+
function formatTimeAgo(inputdate) {
|
|
79
|
+
const currentdateView = /* @__PURE__ */ new Date();
|
|
80
|
+
const timeDifference = Math.floor((currentdateView.getTime() - inputdate.getTime()) / 1e3);
|
|
81
|
+
if (timeDifference < 10) {
|
|
82
|
+
return "few secs ago";
|
|
83
|
+
} else if (timeDifference < 60) {
|
|
84
|
+
return `${timeDifference} secs ago`;
|
|
85
|
+
} else if (timeDifference < 3600) {
|
|
86
|
+
const minutes = Math.floor(timeDifference / 60);
|
|
87
|
+
return `${minutes} min${minutes > 1 ? "s" : ""} ago`;
|
|
88
|
+
} else if (timeDifference < 86400) {
|
|
89
|
+
const hours = Math.floor(timeDifference / 3600);
|
|
90
|
+
const remainingMinutes = Math.floor(timeDifference % 3600 / 60);
|
|
91
|
+
return `${hours} hour${hours > 1 ? "s" : ""}, ${remainingMinutes} min${remainingMinutes > 1 ? "s" : ""} ago`;
|
|
92
|
+
} else if (timeDifference < 14 * 3600) {
|
|
93
|
+
const daysAgo = Math.floor(timeDifference / 86400);
|
|
94
|
+
return `${daysAgo} day${daysAgo > 1 ? "s" : ""} ago`;
|
|
95
|
+
} else {
|
|
96
|
+
const formatteddateView = inputdate.toLocaleString();
|
|
97
|
+
return formatteddateView;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return /* @__PURE__ */ jsx5(React5.Fragment, { children: /* @__PURE__ */ jsx5("div", { className: "inline-flex gap-1", children: localdateViewTime == "Invalid dateView undefined" ? "-" : localdateViewTime }) });
|
|
101
|
+
};
|
|
102
|
+
var DateView_default = dateViewView;
|
|
103
|
+
|
|
104
|
+
// src/controls/view/StatusView.tsx
|
|
105
|
+
import React6 from "react";
|
|
106
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
107
|
+
var statusView = (props) => {
|
|
108
|
+
return /* @__PURE__ */ jsx6(React6.Fragment, { children: /* @__PURE__ */ jsx6("span", { className: "capitalize font-semibold rounded textView-statusView textView-statusView-" + props.value, children: props.value }) });
|
|
109
|
+
};
|
|
110
|
+
var StatusView_default = statusView;
|
|
111
|
+
|
|
112
|
+
// src/controls/view/StatusBgView.tsx
|
|
113
|
+
import React7 from "react";
|
|
114
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
115
|
+
var statusBgView = (props) => {
|
|
116
|
+
return /* @__PURE__ */ jsx7(React7.Fragment, { children: props.value && props.value != "" && /* @__PURE__ */ jsx7("span", { className: "py-0.5 px-1.5 textView-xs capitalize textView-white font-semibold rounded bg-statusView bg-statusView-" + props.value, children: props.value }) });
|
|
117
|
+
};
|
|
118
|
+
var StatusBgView_default = statusBgView;
|
|
119
|
+
|
|
120
|
+
// src/controls/view/BooleanView.tsx
|
|
121
|
+
import React8 from "react";
|
|
122
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
123
|
+
var booleanViewView = (props) => {
|
|
124
|
+
const { value, customProps } = props;
|
|
125
|
+
const showOnlyTrueIcon = customProps == null ? void 0 : customProps.showOnlyTrueIcon;
|
|
126
|
+
console.log("BooleanView Debug:", {
|
|
127
|
+
value,
|
|
128
|
+
type: typeof value,
|
|
129
|
+
customProps,
|
|
130
|
+
showOnlyTrueIcon
|
|
131
|
+
});
|
|
132
|
+
const booleanValue = React8.useMemo(() => {
|
|
133
|
+
if (typeof value === "boolean") return value;
|
|
134
|
+
if (typeof value === "string") {
|
|
135
|
+
return value.toLowerCase() === "true";
|
|
136
|
+
}
|
|
137
|
+
if (typeof value === "number") {
|
|
138
|
+
return value === 1;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}, [value]);
|
|
142
|
+
if (showOnlyTrueIcon) {
|
|
143
|
+
return /* @__PURE__ */ jsx8(React8.Fragment, { children: booleanValue === true && /* @__PURE__ */ jsx8(
|
|
144
|
+
"svg",
|
|
145
|
+
{
|
|
146
|
+
className: "w-15 h-8 textView-green-600",
|
|
147
|
+
fill: "currentColor",
|
|
148
|
+
viewBox: "0 0 20 20",
|
|
149
|
+
children: /* @__PURE__ */ jsx8(
|
|
150
|
+
"path",
|
|
151
|
+
{
|
|
152
|
+
fillRule: "evenodd",
|
|
153
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
154
|
+
clipRule: "evenodd"
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
) });
|
|
159
|
+
}
|
|
160
|
+
return /* @__PURE__ */ jsx8(React8.Fragment, { children: booleanValue ? "true" : "false" });
|
|
161
|
+
};
|
|
162
|
+
var BooleanView_default = booleanViewView;
|
|
163
|
+
|
|
164
|
+
// src/controls/view/MultilineTextBulletsView.tsx
|
|
165
|
+
import React9 from "react";
|
|
166
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
167
|
+
var multilineTextBulletsView = (props) => {
|
|
168
|
+
var _a;
|
|
169
|
+
const lines = (_a = props.value) == null ? void 0 : _a.split("\\n");
|
|
170
|
+
return /* @__PURE__ */ jsx9(React9.Fragment, { children: /* @__PURE__ */ jsx9("ul", { className: "list-disc", children: lines && lines.map((line, index) => {
|
|
171
|
+
return /* @__PURE__ */ jsx9("li", { children: line }, index);
|
|
172
|
+
}) }) });
|
|
173
|
+
};
|
|
174
|
+
var MultilineTextBulletsView_default = multilineTextBulletsView;
|
|
175
|
+
|
|
176
|
+
// src/controls/view/MultilineTextView.tsx
|
|
177
|
+
import React10 from "react";
|
|
178
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
179
|
+
var MultilinetextView = (props) => {
|
|
180
|
+
return /* @__PURE__ */ jsx10(React10.Fragment, { children: /* @__PURE__ */ jsx10("span", { className: "whitespace-pre-line", children: props.value }) });
|
|
181
|
+
};
|
|
182
|
+
var MultilineTextView_default = MultilinetextView;
|
|
183
|
+
|
|
1
184
|
// src/controls/view/ViewControlTypesView.tsx
|
|
2
185
|
var ViewControlTypesView = {
|
|
3
186
|
lineTextView: "lineTextView",
|
|
@@ -15,6 +198,29 @@ var ViewControlTypesView = {
|
|
|
15
198
|
// booleanView: "booleanView"
|
|
16
199
|
};
|
|
17
200
|
var ViewControlTypesView_default = ViewControlTypesView;
|
|
201
|
+
|
|
202
|
+
// src/controls/view/ViewControlView.tsx
|
|
203
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
204
|
+
var ViewControl = (props) => {
|
|
205
|
+
const ControlComponents = {
|
|
206
|
+
[ViewControlTypesView_default.lineTextView]: LineTextView_default,
|
|
207
|
+
[ViewControlTypesView_default.emailTextView]: EmailTextView_default,
|
|
208
|
+
[ViewControlTypesView_default.multilineTextBulletsView]: MultilineTextBulletsView_default,
|
|
209
|
+
[ViewControlTypesView_default.moneyView]: MoneyView_default,
|
|
210
|
+
[ViewControlTypesView_default.numberView]: NumberView_default,
|
|
211
|
+
[ViewControlTypesView_default.dateView]: DateView_default,
|
|
212
|
+
[ViewControlTypesView_default.statusView]: StatusView_default,
|
|
213
|
+
[ViewControlTypesView_default.statusBgView]: StatusBgView_default,
|
|
214
|
+
[ViewControlTypesView_default.multilineTextView]: MultilineTextView_default,
|
|
215
|
+
[ViewControlTypesView_default.booleanView]: BooleanView_default,
|
|
216
|
+
[ViewControlTypesView_default.lineTextView]: LineTextView_default
|
|
217
|
+
// [ViewControlTypes.booleanView]: booleanViewView
|
|
218
|
+
};
|
|
219
|
+
const SelectedControlComponent = ControlComponents[props.controlType];
|
|
220
|
+
return /* @__PURE__ */ jsx11(React11.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx11(SelectedControlComponent, __spreadValues({}, props)) : "Control not found" });
|
|
221
|
+
};
|
|
222
|
+
var ViewControlView_default = ViewControl;
|
|
18
223
|
export {
|
|
224
|
+
ViewControlView_default as ViewControl,
|
|
19
225
|
ViewControlTypesView_default as ViewControlTypesView
|
|
20
226
|
};
|