@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260818060820 → 0.8.1-dev.20260824072352
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/DataBindingControls-QZ7ES2AS.mjs +205 -0
- package/dist/DataBindingControls-XCAIDMDC.mjs +209 -0
- package/dist/{InputControlClient-XR37ZIQ2.mjs → InputControlClient-4M2BZXQO.mjs} +5 -3
- package/dist/InputControlClient-AORN4DRF.mjs +1921 -0
- package/dist/{LinkNodeButton-AOEDCCL7.mjs → LinkNodeButton-BEAX4I4C.mjs} +1 -1
- package/dist/LinkNodeButton-IT2CELKO.mjs +225 -0
- package/dist/{Pagination-YKNCYVXV.mjs → Pagination-GL6B4MNO.mjs} +5 -3
- package/dist/{Pagination-6OFACRMQ.mjs → Pagination-ZQO3EUKB.mjs} +27 -71
- package/dist/chunk-2R26M6CK.mjs +30 -0
- package/dist/{chunk-KL2YKXXS.mjs → chunk-4P4HO663.mjs} +30 -6
- package/dist/chunk-4R7F7LBL.mjs +36 -0
- package/dist/chunk-6PW2RLUJ.mjs +52 -0
- package/dist/chunk-E4VOFO5Q.mjs +39 -0
- package/dist/{chunk-YDPISYMP.mjs → chunk-GCG4OYDJ.mjs} +0 -34
- package/dist/{chunk-65QPOTZ4.mjs → chunk-GJOJX2O3.mjs} +1 -1
- package/dist/chunk-GKI42H4B.mjs +13 -0
- package/dist/{chunk-TVL6KVD5.mjs → chunk-Q46GMD3P.mjs} +31 -37
- package/dist/chunk-RHVNJMS4.mjs +251 -0
- package/dist/{chunk-WEV5U33G.mjs → chunk-TKDSRAM6.mjs} +36 -20
- package/dist/chunk-TQ6BXQ3A.mjs +24 -0
- package/dist/{chunk-3GWLDT7C.mjs → chunk-WXZMRMRS.mjs} +36 -20
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +616 -311
- package/dist/index.mjs +101 -54
- package/dist/server.d.mts +17 -6
- package/dist/server.d.ts +17 -6
- package/dist/server.js +2717 -298
- package/dist/server.mjs +86 -52
- package/package.json +1 -1
- package/dist/LinkNodeButton-KZRNRJRI.mjs +0 -467
|
@@ -0,0 +1,1921 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Icon_default
|
|
4
|
+
} from "./chunk-6PW2RLUJ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
AssetUtility_default
|
|
7
|
+
} from "./chunk-TQ6BXQ3A.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Hyperlink
|
|
10
|
+
} from "./chunk-2R26M6CK.mjs";
|
|
11
|
+
import {
|
|
12
|
+
InputControlType_default
|
|
13
|
+
} from "./chunk-4R7F7LBL.mjs";
|
|
14
|
+
import {
|
|
15
|
+
Button_default,
|
|
16
|
+
ClientButton_default
|
|
17
|
+
} from "./chunk-RHVNJMS4.mjs";
|
|
18
|
+
import "./chunk-56HSDML5.mjs";
|
|
19
|
+
|
|
20
|
+
// src/components/controls/edit/InputControlClient.tsx
|
|
21
|
+
import React22 from "react";
|
|
22
|
+
|
|
23
|
+
// src/components/controls/edit/MultilineTextInput.tsx
|
|
24
|
+
import React from "react";
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var MultilineTextInput = (props) => {
|
|
27
|
+
const textChangeHandler = (event) => {
|
|
28
|
+
const text = event.target.value;
|
|
29
|
+
if (props.callback !== void 0) {
|
|
30
|
+
props.callback(
|
|
31
|
+
{
|
|
32
|
+
name: props.name,
|
|
33
|
+
value: text,
|
|
34
|
+
index: props.index,
|
|
35
|
+
groupKey: props.groupKey
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
let value = "";
|
|
41
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
42
|
+
value = props.value;
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsxs("label", { className: "block mb-1", children: [
|
|
45
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
46
|
+
" ",
|
|
47
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx("span", { className: "bg-error-weak", children: "*" }),
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
"textarea",
|
|
50
|
+
{
|
|
51
|
+
name: props.name,
|
|
52
|
+
id: props.name,
|
|
53
|
+
value,
|
|
54
|
+
onChange: textChangeHandler,
|
|
55
|
+
onBlur: props?.onBlur,
|
|
56
|
+
rows: 4,
|
|
57
|
+
required: props?.attributes?.required,
|
|
58
|
+
placeholder: props?.attributes?.placeholder,
|
|
59
|
+
maxLength: props?.attributes?.maxLength,
|
|
60
|
+
disabled: props?.attributes?.readOnly,
|
|
61
|
+
minLength: props?.attributes?.minLength,
|
|
62
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm input"
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ jsx("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
66
|
+
] }) });
|
|
67
|
+
};
|
|
68
|
+
var MultilineTextInput_default = MultilineTextInput;
|
|
69
|
+
|
|
70
|
+
// src/components/controls/edit/LineTextInput.tsx
|
|
71
|
+
import React2 from "react";
|
|
72
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
73
|
+
var LineTextInput = (props) => {
|
|
74
|
+
const textChangeHandler = (event) => {
|
|
75
|
+
const text = event.target.value;
|
|
76
|
+
if (props.callback !== void 0) {
|
|
77
|
+
props.callback(
|
|
78
|
+
{
|
|
79
|
+
name: props.name,
|
|
80
|
+
value: text,
|
|
81
|
+
index: props.index,
|
|
82
|
+
groupKey: props.groupKey
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
let value = "";
|
|
88
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
89
|
+
value = props.value;
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs2("label", { className: "block", children: [
|
|
92
|
+
props?.attributes?.label && /* @__PURE__ */ jsx2("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
|
|
93
|
+
" ",
|
|
94
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx2("span", { className: "bg-error-weak !bg-transparent", children: "*" }),
|
|
95
|
+
/* @__PURE__ */ jsx2(
|
|
96
|
+
"input",
|
|
97
|
+
{
|
|
98
|
+
type: "text",
|
|
99
|
+
name: props.name,
|
|
100
|
+
id: props.name,
|
|
101
|
+
value,
|
|
102
|
+
onChange: textChangeHandler,
|
|
103
|
+
onBlur: props?.onBlur,
|
|
104
|
+
required: props?.attributes?.required,
|
|
105
|
+
placeholder: props?.attributes?.placeholder,
|
|
106
|
+
maxLength: props?.attributes?.maxLength,
|
|
107
|
+
pattern: props?.attributes?.pattern,
|
|
108
|
+
disabled: props?.attributes?.readOnly,
|
|
109
|
+
minLength: props?.attributes?.minLength,
|
|
110
|
+
className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm transition-all duration-500 ease-in-out
|
|
111
|
+
${props?.inputClasses ? props.inputClasses : ``}
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsx2("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
116
|
+
] }) });
|
|
117
|
+
};
|
|
118
|
+
var LineTextInput_default = LineTextInput;
|
|
119
|
+
|
|
120
|
+
// src/components/controls/edit/MoneyInput.tsx
|
|
121
|
+
import React3 from "react";
|
|
122
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
123
|
+
var MoneyInput = (props) => {
|
|
124
|
+
const textChangeHandler = (event) => {
|
|
125
|
+
const rawValue = event.target.value;
|
|
126
|
+
const numericValue = parseFloat(rawValue);
|
|
127
|
+
if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
|
|
128
|
+
if (props.callback !== void 0) {
|
|
129
|
+
props.callback({
|
|
130
|
+
name: props.name,
|
|
131
|
+
value: rawValue,
|
|
132
|
+
index: props.index,
|
|
133
|
+
groupKey: props.groupKey
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const handleWheel = (event) => {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
event.target.blur();
|
|
141
|
+
};
|
|
142
|
+
let value;
|
|
143
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
144
|
+
value = props.value;
|
|
145
|
+
}
|
|
146
|
+
const preventNegative = (e) => {
|
|
147
|
+
if (e.key === "-") {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ jsx3(React3.Fragment, { children: /* @__PURE__ */ jsxs3("label", { className: "block mb-1", children: [
|
|
152
|
+
/* @__PURE__ */ jsx3("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
153
|
+
" ",
|
|
154
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx3("span", { className: "bg-error-weak", children: "*" }),
|
|
155
|
+
/* @__PURE__ */ jsx3(
|
|
156
|
+
"input",
|
|
157
|
+
{
|
|
158
|
+
type: "number",
|
|
159
|
+
name: props.name,
|
|
160
|
+
id: props.name,
|
|
161
|
+
value,
|
|
162
|
+
min: 0,
|
|
163
|
+
onChange: textChangeHandler,
|
|
164
|
+
onWheel: handleWheel,
|
|
165
|
+
onKeyDown: preventNegative,
|
|
166
|
+
required: props?.attributes?.required,
|
|
167
|
+
placeholder: props?.attributes?.placeholder,
|
|
168
|
+
maxLength: props?.attributes?.maxLength,
|
|
169
|
+
pattern: props?.attributes?.pattern,
|
|
170
|
+
disabled: props?.attributes?.readOnly,
|
|
171
|
+
minLength: props?.attributes?.minLength,
|
|
172
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm number-input"
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
/* @__PURE__ */ jsx3("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
176
|
+
] }) });
|
|
177
|
+
};
|
|
178
|
+
var MoneyInput_default = MoneyInput;
|
|
179
|
+
|
|
180
|
+
// src/components/controls/edit/Select.tsx
|
|
181
|
+
import { useState, useEffect } from "react";
|
|
182
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
183
|
+
var Select = (props) => {
|
|
184
|
+
const [list, setList] = useState();
|
|
185
|
+
const getSafeValue = (val) => {
|
|
186
|
+
if (val === null || val === void 0) return "";
|
|
187
|
+
if (typeof val === "boolean") return val ? "1" : "0";
|
|
188
|
+
return val;
|
|
189
|
+
};
|
|
190
|
+
const textChangeHandler = (event) => {
|
|
191
|
+
let rawValue = event.target.value;
|
|
192
|
+
if (rawValue === "") rawValue = null;
|
|
193
|
+
let finalValue = rawValue;
|
|
194
|
+
if (list && props.dataKeyFieldName) {
|
|
195
|
+
const key = props.dataKeyFieldName;
|
|
196
|
+
const selectedItem = list.find(
|
|
197
|
+
(item) => String(item[key]) === String(rawValue)
|
|
198
|
+
);
|
|
199
|
+
if (selectedItem) {
|
|
200
|
+
const keyValue = selectedItem[key];
|
|
201
|
+
if (typeof keyValue === "number") {
|
|
202
|
+
finalValue = Number(rawValue);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
props.callback?.({
|
|
207
|
+
name: props.name,
|
|
208
|
+
value: finalValue,
|
|
209
|
+
index: props.index,
|
|
210
|
+
groupKey: props.groupKey
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
const inputChangeHandler = (event) => {
|
|
214
|
+
props.callback?.({
|
|
215
|
+
name: props.name,
|
|
216
|
+
value: event.target.value,
|
|
217
|
+
index: props.index,
|
|
218
|
+
groupKey: props.groupKey
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
async function fetchData() {
|
|
223
|
+
if (props.dataset) {
|
|
224
|
+
setList(props.dataset);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (props.dataSource && props.serviceClient) {
|
|
228
|
+
let dataSource = props.dataSource;
|
|
229
|
+
let response;
|
|
230
|
+
if (props.dataSourceDependsOn) {
|
|
231
|
+
if (!props.dependentValue) {
|
|
232
|
+
setList([]);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
dataSource = dataSource.replace(
|
|
236
|
+
`{${props.dataSourceDependsOn}}`,
|
|
237
|
+
props.dependentValue
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
response = await props.serviceClient.get(dataSource);
|
|
241
|
+
setList(response.result ?? []);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
setList([]);
|
|
245
|
+
}
|
|
246
|
+
fetchData();
|
|
247
|
+
}, [
|
|
248
|
+
props.dataset,
|
|
249
|
+
props.dataSource,
|
|
250
|
+
props.dependentValue,
|
|
251
|
+
props.dataSourceDependsOn
|
|
252
|
+
]);
|
|
253
|
+
const value = getSafeValue(props.value);
|
|
254
|
+
return /* @__PURE__ */ jsxs4("label", { className: "block", children: [
|
|
255
|
+
props.attributes?.label && /* @__PURE__ */ jsx4("span", { className: "text-sm font-medium inline-block pb-1", children: props.attributes?.label }),
|
|
256
|
+
" ",
|
|
257
|
+
props.attributes?.label && props.attributes?.required && /* @__PURE__ */ jsx4("span", { className: "bg-error-weak", children: "*" }),
|
|
258
|
+
list && list.length === 0 && /* @__PURE__ */ jsx4(
|
|
259
|
+
"input",
|
|
260
|
+
{
|
|
261
|
+
type: "text",
|
|
262
|
+
name: props.name,
|
|
263
|
+
id: props.name,
|
|
264
|
+
value,
|
|
265
|
+
onChange: inputChangeHandler,
|
|
266
|
+
required: props.attributes?.required,
|
|
267
|
+
placeholder: props.attributes?.placeholder,
|
|
268
|
+
maxLength: props.attributes?.maxLength,
|
|
269
|
+
pattern: props.attributes?.pattern,
|
|
270
|
+
disabled: props.attributes?.readOnly,
|
|
271
|
+
minLength: props.attributes?.minLength,
|
|
272
|
+
className: `peer input select mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
list && list.length > 0 && /* @__PURE__ */ jsxs4(
|
|
276
|
+
"select",
|
|
277
|
+
{
|
|
278
|
+
name: props.name,
|
|
279
|
+
id: props.name,
|
|
280
|
+
value,
|
|
281
|
+
onChange: textChangeHandler,
|
|
282
|
+
required: props.attributes?.required,
|
|
283
|
+
disabled: props.attributes?.readOnly,
|
|
284
|
+
className: `peer select py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
|
|
285
|
+
focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
|
|
286
|
+
disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none ${props.inputClasses ?? ""}`,
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ jsx4("option", { value: "", children: props.attributes?.placeholder || "Select" }),
|
|
289
|
+
list.map((item, index) => {
|
|
290
|
+
const keyField = props.dataKeyFieldName;
|
|
291
|
+
const textField = props.dataTextFieldName;
|
|
292
|
+
return /* @__PURE__ */ jsx4("option", { value: item[keyField], children: item[textField] }, index);
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
/* @__PURE__ */ jsx4("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 text-alert text-sm", children: props.attributes?.errorMessage || "" })
|
|
298
|
+
] });
|
|
299
|
+
};
|
|
300
|
+
var Select_default = Select;
|
|
301
|
+
|
|
302
|
+
// src/components/controls/edit/PercentageInput.tsx
|
|
303
|
+
import React5 from "react";
|
|
304
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
305
|
+
var PercentageInput = (props) => {
|
|
306
|
+
const textChangeHandler = (event) => {
|
|
307
|
+
const rawValue = event.target.value;
|
|
308
|
+
const numericValue = parseFloat(rawValue);
|
|
309
|
+
if (rawValue === "" || !isNaN(numericValue) && numericValue >= 0) {
|
|
310
|
+
if (props.callback !== void 0) {
|
|
311
|
+
props.callback({
|
|
312
|
+
name: props.name,
|
|
313
|
+
value: rawValue,
|
|
314
|
+
index: props.index,
|
|
315
|
+
groupKey: props.groupKey
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const handleWheel = (event) => {
|
|
321
|
+
event.preventDefault();
|
|
322
|
+
event.target.blur();
|
|
323
|
+
};
|
|
324
|
+
let value;
|
|
325
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
326
|
+
value = props.value;
|
|
327
|
+
}
|
|
328
|
+
const preventNegative = (e) => {
|
|
329
|
+
if (e.key === "-") {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
return /* @__PURE__ */ jsx5(React5.Fragment, { children: /* @__PURE__ */ jsxs5("label", { className: "block mb-1", children: [
|
|
334
|
+
/* @__PURE__ */ jsx5("span", { className: "text-sm font-medium ", children: props?.attributes?.label ? props?.attributes?.label + " %" : "" }),
|
|
335
|
+
" ",
|
|
336
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx5("span", { className: "bg-error-weak", children: "*" }),
|
|
337
|
+
/* @__PURE__ */ jsx5(
|
|
338
|
+
"input",
|
|
339
|
+
{
|
|
340
|
+
type: "number",
|
|
341
|
+
name: props.name,
|
|
342
|
+
id: props.name,
|
|
343
|
+
value,
|
|
344
|
+
min: 0,
|
|
345
|
+
onChange: textChangeHandler,
|
|
346
|
+
onKeyDown: preventNegative,
|
|
347
|
+
onWheel: handleWheel,
|
|
348
|
+
required: props?.attributes?.required,
|
|
349
|
+
placeholder: props?.attributes?.placeholder,
|
|
350
|
+
pattern: props?.attributes?.pattern,
|
|
351
|
+
disabled: props?.attributes?.readOnly,
|
|
352
|
+
max: "100",
|
|
353
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm number-input"
|
|
354
|
+
}
|
|
355
|
+
),
|
|
356
|
+
/* @__PURE__ */ jsx5("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
357
|
+
] }) });
|
|
358
|
+
};
|
|
359
|
+
var PercentageInput_default = PercentageInput;
|
|
360
|
+
|
|
361
|
+
// src/components/controls/edit/PhoneInput.tsx
|
|
362
|
+
import React6 from "react";
|
|
363
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
364
|
+
var PhoneInput = (props) => {
|
|
365
|
+
const textChangeHandler = (event) => {
|
|
366
|
+
const text = event.target.value;
|
|
367
|
+
if (props.callback !== void 0) {
|
|
368
|
+
props.callback(
|
|
369
|
+
{
|
|
370
|
+
name: props.name,
|
|
371
|
+
value: text,
|
|
372
|
+
index: props.index,
|
|
373
|
+
groupKey: props.groupKey
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
let value = "";
|
|
379
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
380
|
+
value = props.value;
|
|
381
|
+
}
|
|
382
|
+
return /* @__PURE__ */ jsx6(React6.Fragment, { children: /* @__PURE__ */ jsxs6("label", { className: "block mb-1", children: [
|
|
383
|
+
/* @__PURE__ */ jsx6("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
384
|
+
" ",
|
|
385
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx6("span", { className: "bg-error-weak", children: "*" }),
|
|
386
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center rounded border ", children: [
|
|
387
|
+
/* @__PURE__ */ jsx6("span", { className: "px-3", children: props.prefix }),
|
|
388
|
+
/* @__PURE__ */ jsx6(
|
|
389
|
+
"input",
|
|
390
|
+
{
|
|
391
|
+
type: "text",
|
|
392
|
+
name: props.name,
|
|
393
|
+
id: props.name,
|
|
394
|
+
value,
|
|
395
|
+
onChange: textChangeHandler,
|
|
396
|
+
required: props?.attributes?.required,
|
|
397
|
+
placeholder: props?.attributes?.placeholder,
|
|
398
|
+
maxLength: props?.attributes?.maxLength,
|
|
399
|
+
pattern: props?.attributes?.pattern,
|
|
400
|
+
disabled: props?.attributes?.readOnly,
|
|
401
|
+
minLength: props?.attributes?.minLength,
|
|
402
|
+
className: "py-1.5 block w-full outline-none border-0 mr-0.5"
|
|
403
|
+
}
|
|
404
|
+
)
|
|
405
|
+
] }),
|
|
406
|
+
/* @__PURE__ */ jsx6("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
407
|
+
] }) });
|
|
408
|
+
};
|
|
409
|
+
var PhoneInput_default = PhoneInput;
|
|
410
|
+
|
|
411
|
+
// src/components/controls/edit/NumberInput.tsx
|
|
412
|
+
import React7 from "react";
|
|
413
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
414
|
+
var NumberInput = (props) => {
|
|
415
|
+
const textChangeHandler = (event) => {
|
|
416
|
+
const text = event.target.value;
|
|
417
|
+
if (props.callback !== void 0) {
|
|
418
|
+
props.callback(
|
|
419
|
+
{
|
|
420
|
+
name: props.name,
|
|
421
|
+
value: text,
|
|
422
|
+
index: props.index,
|
|
423
|
+
groupKey: props.groupKey
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
const handleWheel = (event) => {
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
event.target.blur();
|
|
431
|
+
};
|
|
432
|
+
let value;
|
|
433
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
434
|
+
value = props.value;
|
|
435
|
+
}
|
|
436
|
+
return /* @__PURE__ */ jsx7(React7.Fragment, { children: /* @__PURE__ */ jsxs7("label", { className: "block", children: [
|
|
437
|
+
props?.attributes?.label && /* @__PURE__ */ jsx7("span", { className: "text-sm inline-block pb-1 font-medium ", children: props?.attributes?.label }),
|
|
438
|
+
" ",
|
|
439
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx7("span", { className: "bg-error-weak", children: "*" }),
|
|
440
|
+
/* @__PURE__ */ jsx7(
|
|
441
|
+
"input",
|
|
442
|
+
{
|
|
443
|
+
type: "number",
|
|
444
|
+
name: props.name,
|
|
445
|
+
id: props.name,
|
|
446
|
+
value,
|
|
447
|
+
onChange: textChangeHandler,
|
|
448
|
+
onWheel: handleWheel,
|
|
449
|
+
required: props?.attributes?.required,
|
|
450
|
+
placeholder: props?.attributes?.placeholder,
|
|
451
|
+
onBlur: props?.onBlur,
|
|
452
|
+
pattern: props?.attributes?.pattern,
|
|
453
|
+
disabled: props?.attributes?.readOnly,
|
|
454
|
+
max: props?.attributes?.maxValue,
|
|
455
|
+
min: props?.attributes?.minValue,
|
|
456
|
+
className: "peer py-1.5 block w-full rounded shadow-sm number-input input\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\n "
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
/* @__PURE__ */ jsx7("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
460
|
+
] }) });
|
|
461
|
+
};
|
|
462
|
+
var NumberInput_default = NumberInput;
|
|
463
|
+
|
|
464
|
+
// src/components/controls/edit/CheckboxInput.tsx
|
|
465
|
+
import React8 from "react";
|
|
466
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
467
|
+
var CheckboxInput = (props) => {
|
|
468
|
+
const textChangeHandler = (event) => {
|
|
469
|
+
let text = event.target.checked;
|
|
470
|
+
if (props.callback !== void 0) {
|
|
471
|
+
props.callback({
|
|
472
|
+
name: props.name,
|
|
473
|
+
value: text,
|
|
474
|
+
index: props.index,
|
|
475
|
+
groupKey: props.groupKey
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
let value = false;
|
|
480
|
+
if (props.value != void 0 && props.value != null && props.value != "" && (props.value == "true" || props.value.toString() == "true")) {
|
|
481
|
+
value = true;
|
|
482
|
+
}
|
|
483
|
+
return /* @__PURE__ */ jsx8(React8.Fragment, { children: /* @__PURE__ */ jsxs8("div", { className: "mb-1", children: [
|
|
484
|
+
props?.attributes?.label && /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
485
|
+
/* @__PURE__ */ jsx8(
|
|
486
|
+
"label",
|
|
487
|
+
{
|
|
488
|
+
htmlFor: props.name,
|
|
489
|
+
className: "inline-block text-sm font-medium",
|
|
490
|
+
children: props.attributes.label
|
|
491
|
+
}
|
|
492
|
+
),
|
|
493
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx8("span", { className: "bg-error-weak", children: "*" })
|
|
494
|
+
] }),
|
|
495
|
+
/* @__PURE__ */ jsx8(
|
|
496
|
+
"input",
|
|
497
|
+
{
|
|
498
|
+
type: "checkbox",
|
|
499
|
+
name: props.name,
|
|
500
|
+
id: props.name,
|
|
501
|
+
checked: value,
|
|
502
|
+
onChange: textChangeHandler,
|
|
503
|
+
required: props?.attributes?.required,
|
|
504
|
+
placeholder: props?.attributes?.placeholder,
|
|
505
|
+
maxLength: props?.attributes?.maxLength,
|
|
506
|
+
pattern: props?.attributes?.pattern,
|
|
507
|
+
disabled: props?.attributes?.readOnly,
|
|
508
|
+
minLength: props?.attributes?.minLength,
|
|
509
|
+
className: "peer mt-1 py-1.5 block rounded shadow-sm\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\n "
|
|
510
|
+
}
|
|
511
|
+
),
|
|
512
|
+
/* @__PURE__ */ jsx8("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage || "" })
|
|
513
|
+
] }) });
|
|
514
|
+
};
|
|
515
|
+
var CheckboxInput_default = CheckboxInput;
|
|
516
|
+
|
|
517
|
+
// src/components/controls/edit/OtpInput.tsx
|
|
518
|
+
import React9 from "react";
|
|
519
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
520
|
+
var OtpInput = (props) => {
|
|
521
|
+
const textChangeHandler = (event) => {
|
|
522
|
+
const text = event.target.value;
|
|
523
|
+
if (props.callback !== void 0) {
|
|
524
|
+
props.callback(
|
|
525
|
+
{
|
|
526
|
+
name: props.name,
|
|
527
|
+
value: text,
|
|
528
|
+
index: props.index,
|
|
529
|
+
groupKey: props.groupKey
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const handleWheel = (event) => {
|
|
535
|
+
event.preventDefault();
|
|
536
|
+
};
|
|
537
|
+
let value;
|
|
538
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
539
|
+
value = props.value;
|
|
540
|
+
}
|
|
541
|
+
return /* @__PURE__ */ jsx9(React9.Fragment, { children: /* @__PURE__ */ jsxs9("label", { htmlFor: props.name, className: "block mb-1 w-full", children: [
|
|
542
|
+
/* @__PURE__ */ jsx9("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
543
|
+
" ",
|
|
544
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx9("span", { className: "bg-error-weak", children: "*" }),
|
|
545
|
+
/* @__PURE__ */ jsx9(
|
|
546
|
+
"input",
|
|
547
|
+
{
|
|
548
|
+
type: "text",
|
|
549
|
+
name: props.name,
|
|
550
|
+
id: props.name,
|
|
551
|
+
value,
|
|
552
|
+
onChange: textChangeHandler,
|
|
553
|
+
autoComplete: "off",
|
|
554
|
+
required: props?.attributes?.required,
|
|
555
|
+
placeholder: props?.attributes?.placeholder,
|
|
556
|
+
maxLength: 4,
|
|
557
|
+
pattern: props?.attributes?.pattern,
|
|
558
|
+
disabled: props?.attributes?.readOnly,
|
|
559
|
+
minLength: props?.attributes?.minLength,
|
|
560
|
+
autoFocus: props?.attributes?.autoFocus,
|
|
561
|
+
onWheel: handleWheel,
|
|
562
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm tracking-[1.25em] text-center"
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ jsx9("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
566
|
+
] }) });
|
|
567
|
+
};
|
|
568
|
+
var OtpInput_default = OtpInput;
|
|
569
|
+
|
|
570
|
+
// src/components/controls/edit/DateTimeInput.tsx
|
|
571
|
+
import React10 from "react";
|
|
572
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
573
|
+
var DateTimeInput = (props) => {
|
|
574
|
+
const textChangeHandler = (event) => {
|
|
575
|
+
const localDate = new Date(event.target.value);
|
|
576
|
+
if (props.callback !== void 0) {
|
|
577
|
+
const utcISOString = localDate.toISOString();
|
|
578
|
+
props.callback({
|
|
579
|
+
name: props.name,
|
|
580
|
+
value: utcISOString,
|
|
581
|
+
index: props.index,
|
|
582
|
+
groupKey: props.groupKey
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
let value;
|
|
587
|
+
let localvalue;
|
|
588
|
+
let timeZoneAbbr;
|
|
589
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
590
|
+
value = props.value;
|
|
591
|
+
const now = /* @__PURE__ */ new Date();
|
|
592
|
+
const offsetMinutes = now.getTimezoneOffset();
|
|
593
|
+
const offsetMilliseconds = offsetMinutes * 60 * 1e3;
|
|
594
|
+
const valDate = value.toString().includes("Z") ? new Date(value) : /* @__PURE__ */ new Date(value + "Z");
|
|
595
|
+
const localDate = new Date(valDate.getTime() - offsetMilliseconds);
|
|
596
|
+
timeZoneAbbr = now.toLocaleTimeString("en", { timeZoneName: "short" }).split(" ")[2];
|
|
597
|
+
localvalue = localDate?.toISOString()?.slice(0, 16);
|
|
598
|
+
}
|
|
599
|
+
const handleKeyDown = (e) => {
|
|
600
|
+
if (e.key === "Backspace") {
|
|
601
|
+
e.preventDefault();
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
return /* @__PURE__ */ jsx10(React10.Fragment, { children: /* @__PURE__ */ jsxs10("label", { className: "block mb-1", children: [
|
|
605
|
+
/* @__PURE__ */ jsx10("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
606
|
+
" ",
|
|
607
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx10("span", { className: "bg-error-weak", children: "*" }),
|
|
608
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
609
|
+
/* @__PURE__ */ jsx10(
|
|
610
|
+
"input",
|
|
611
|
+
{
|
|
612
|
+
type: "datetime-local",
|
|
613
|
+
name: props.name,
|
|
614
|
+
id: props.name,
|
|
615
|
+
value: localvalue,
|
|
616
|
+
onChange: textChangeHandler,
|
|
617
|
+
onKeyDown: handleKeyDown,
|
|
618
|
+
required: props?.attributes?.required,
|
|
619
|
+
placeholder: props?.attributes?.placeholder,
|
|
620
|
+
maxLength: props?.attributes?.maxLength,
|
|
621
|
+
pattern: props?.attributes?.pattern,
|
|
622
|
+
disabled: props?.attributes?.readOnly,
|
|
623
|
+
minLength: props?.attributes?.minLength,
|
|
624
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\n "
|
|
625
|
+
}
|
|
626
|
+
),
|
|
627
|
+
/* @__PURE__ */ jsx10("span", { children: timeZoneAbbr })
|
|
628
|
+
] }),
|
|
629
|
+
/* @__PURE__ */ jsx10("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
630
|
+
] }) });
|
|
631
|
+
};
|
|
632
|
+
var DateTimeInput_default = DateTimeInput;
|
|
633
|
+
|
|
634
|
+
// src/components/controls/edit/ColorInput.tsx
|
|
635
|
+
import React11, { useEffect as useEffect2 } from "react";
|
|
636
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
637
|
+
var ColorInput = (props) => {
|
|
638
|
+
const [color, setColor] = React11.useState("#3b82f6");
|
|
639
|
+
useEffect2(() => {
|
|
640
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
641
|
+
if (typeof props.value === "string") {
|
|
642
|
+
setColor(props.value);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}, [props.value]);
|
|
646
|
+
const handleColorChange = (event) => {
|
|
647
|
+
const newColor = event.target.value;
|
|
648
|
+
setColor(newColor);
|
|
649
|
+
if (props.callback) {
|
|
650
|
+
props.callback({
|
|
651
|
+
name: props.name,
|
|
652
|
+
value: newColor,
|
|
653
|
+
index: props.index,
|
|
654
|
+
groupKey: props.groupKey
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
return /* @__PURE__ */ jsxs11("label", { className: "block mb-1", children: [
|
|
659
|
+
/* @__PURE__ */ jsx11("span", { className: "text-sm font-medium", children: props?.attributes?.label }),
|
|
660
|
+
" ",
|
|
661
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx11("span", { className: "bg-error-weak", children: "*" }),
|
|
662
|
+
/* @__PURE__ */ jsx11(
|
|
663
|
+
"input",
|
|
664
|
+
{
|
|
665
|
+
type: "color",
|
|
666
|
+
name: props.name,
|
|
667
|
+
title: color,
|
|
668
|
+
id: props.name,
|
|
669
|
+
value: color,
|
|
670
|
+
onChange: handleColorChange,
|
|
671
|
+
required: props?.attributes?.required,
|
|
672
|
+
className: `w-[78px] h-12 block cursor-pointer`
|
|
673
|
+
}
|
|
674
|
+
),
|
|
675
|
+
props?.attributes?.errorMessage && /* @__PURE__ */ jsx11("p", { className: "mt-1 bg-error-weak text-sm", children: props.attributes.errorMessage })
|
|
676
|
+
] });
|
|
677
|
+
};
|
|
678
|
+
var ColorInput_default = ColorInput;
|
|
679
|
+
|
|
680
|
+
// src/components/controls/edit/SelectWithSearchInput.tsx
|
|
681
|
+
import React12, { useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
682
|
+
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
683
|
+
var SelectWithSearchInput = (props) => {
|
|
684
|
+
const [isOpen, setIsOpen] = useState2(false);
|
|
685
|
+
const [searchTerm, setSearchTerm] = useState2("");
|
|
686
|
+
const [highlightedIndex, setHighlightedIndex] = useState2(-1);
|
|
687
|
+
const [selectedItem, setSelectedItem] = useState2(
|
|
688
|
+
null
|
|
689
|
+
);
|
|
690
|
+
const [list, setList] = useState2([]);
|
|
691
|
+
const loadData = React12.useCallback(async () => {
|
|
692
|
+
if (props.dataset) {
|
|
693
|
+
setList(props.dataset);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (props.dataSource && props.serviceClient) {
|
|
697
|
+
let url = props.dataSource;
|
|
698
|
+
if (props.dataSourceDependsOn && props.dependentValue) {
|
|
699
|
+
url = url.replace(
|
|
700
|
+
`{${props.dataSourceDependsOn}}`,
|
|
701
|
+
props.dependentValue
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
const response = await props.serviceClient.get(url);
|
|
705
|
+
if (response?.result) {
|
|
706
|
+
setList(response.result);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}, [
|
|
710
|
+
props.dataset,
|
|
711
|
+
props.dataSource,
|
|
712
|
+
props.serviceClient,
|
|
713
|
+
props.dataSourceDependsOn,
|
|
714
|
+
props.dependentValue
|
|
715
|
+
]);
|
|
716
|
+
useEffect3(() => {
|
|
717
|
+
loadData();
|
|
718
|
+
}, [loadData]);
|
|
719
|
+
useEffect3(() => {
|
|
720
|
+
if (props.value && list.length && props.dataKeyFieldName && props.dataTextFieldName) {
|
|
721
|
+
const selected = list.find(
|
|
722
|
+
(x) => x[props.dataKeyFieldName] == props.value
|
|
723
|
+
);
|
|
724
|
+
if (selected) {
|
|
725
|
+
setSearchTerm(selected[props.dataTextFieldName]);
|
|
726
|
+
setSelectedItem(selected);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}, [props.value, list]);
|
|
730
|
+
const filteredItems = list.filter((item) => {
|
|
731
|
+
const text = item[props.dataTextFieldName] ?? "";
|
|
732
|
+
return text.toString().toLowerCase().includes(searchTerm.toLowerCase());
|
|
733
|
+
});
|
|
734
|
+
const handleSelect = (event, item) => {
|
|
735
|
+
event.preventDefault();
|
|
736
|
+
setSearchTerm(item[props.dataTextFieldName]);
|
|
737
|
+
setSelectedItem(item);
|
|
738
|
+
setIsOpen(false);
|
|
739
|
+
setHighlightedIndex(-1);
|
|
740
|
+
const selectedValue = item[props.dataKeyFieldName];
|
|
741
|
+
if (props.onChange) {
|
|
742
|
+
props.onChange(selectedValue);
|
|
743
|
+
}
|
|
744
|
+
if (props.callback) {
|
|
745
|
+
props.callback({
|
|
746
|
+
name: props.name,
|
|
747
|
+
value: selectedValue,
|
|
748
|
+
index: props.index,
|
|
749
|
+
groupKey: props.groupKey
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
const handleKeyDown = (e) => {
|
|
754
|
+
if (e.key === "ArrowDown") {
|
|
755
|
+
setHighlightedIndex(
|
|
756
|
+
(prev) => prev < filteredItems.length - 1 ? prev + 1 : 0
|
|
757
|
+
);
|
|
758
|
+
} else if (e.key === "ArrowUp") {
|
|
759
|
+
setHighlightedIndex(
|
|
760
|
+
(prev) => prev > 0 ? prev - 1 : filteredItems.length - 1
|
|
761
|
+
);
|
|
762
|
+
} else if (e.key === "Enter" && highlightedIndex >= 0) {
|
|
763
|
+
handleSelect(e, filteredItems[highlightedIndex]);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
const dropdownRef = useRef(null);
|
|
767
|
+
useEffect3(() => {
|
|
768
|
+
if (highlightedIndex >= 0 && dropdownRef.current) {
|
|
769
|
+
const highlightedItem = dropdownRef.current.children[highlightedIndex];
|
|
770
|
+
highlightedItem?.scrollIntoView({
|
|
771
|
+
behavior: "smooth",
|
|
772
|
+
block: "nearest"
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}, [highlightedIndex]);
|
|
776
|
+
const isReadOnly = props.attributes?.readOnly || props.disable || props.attributes?.disable;
|
|
777
|
+
return /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
778
|
+
/* @__PURE__ */ jsxs12("label", { className: "pb-1", children: [
|
|
779
|
+
props.attributes?.label,
|
|
780
|
+
" ",
|
|
781
|
+
props?.attributes?.required && /* @__PURE__ */ jsx12("span", { className: "bg-error-weak", children: "*" })
|
|
782
|
+
] }),
|
|
783
|
+
/* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
784
|
+
/* @__PURE__ */ jsx12(
|
|
785
|
+
"input",
|
|
786
|
+
{
|
|
787
|
+
type: "text",
|
|
788
|
+
value: searchTerm,
|
|
789
|
+
onChange: (e) => {
|
|
790
|
+
setSearchTerm(e.target.value);
|
|
791
|
+
setIsOpen(true);
|
|
792
|
+
setHighlightedIndex(-1);
|
|
793
|
+
},
|
|
794
|
+
onFocus: () => setIsOpen(true),
|
|
795
|
+
onKeyDown: handleKeyDown,
|
|
796
|
+
placeholder: props.attributes?.placeholder ?? "Search...",
|
|
797
|
+
readOnly: isReadOnly,
|
|
798
|
+
disabled: props.disable || props.attributes?.disable,
|
|
799
|
+
className: `peer mt-2 py-1.5 select block w-full text-black rounded border-gray-300 shadow-sm
|
|
800
|
+
focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50
|
|
801
|
+
disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none
|
|
802
|
+
${isReadOnly ? "bg-neutral-soft opacity-50 cursor-not-allowed" : "bg-default"}
|
|
803
|
+
`
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
/* @__PURE__ */ jsx12(
|
|
807
|
+
"button",
|
|
808
|
+
{
|
|
809
|
+
type: "button",
|
|
810
|
+
disabled: isReadOnly,
|
|
811
|
+
onClick: () => {
|
|
812
|
+
if (!isReadOnly) {
|
|
813
|
+
setIsOpen(!isOpen);
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
className: "absolute right-2 top-3 h-5 w-5 text-gray-500 focus:outline-none",
|
|
817
|
+
children: /* @__PURE__ */ jsx12(
|
|
818
|
+
"svg",
|
|
819
|
+
{
|
|
820
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
821
|
+
fill: "none",
|
|
822
|
+
viewBox: "0 0 24 24",
|
|
823
|
+
strokeWidth: 1.5,
|
|
824
|
+
stroke: "currentColor",
|
|
825
|
+
className: "w-full h-full",
|
|
826
|
+
children: /* @__PURE__ */ jsx12(
|
|
827
|
+
"path",
|
|
828
|
+
{
|
|
829
|
+
strokeLinecap: "round",
|
|
830
|
+
strokeLinejoin: "round",
|
|
831
|
+
d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
|
|
832
|
+
}
|
|
833
|
+
)
|
|
834
|
+
}
|
|
835
|
+
)
|
|
836
|
+
}
|
|
837
|
+
)
|
|
838
|
+
] }),
|
|
839
|
+
!isReadOnly && isOpen && /* @__PURE__ */ jsx12(
|
|
840
|
+
"div",
|
|
841
|
+
{
|
|
842
|
+
ref: dropdownRef,
|
|
843
|
+
className: "absolute z-10 w-full bg-default border border-gray-200 shadow-lg max-h-48 overflow-y-auto",
|
|
844
|
+
children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ jsx12(
|
|
845
|
+
"button",
|
|
846
|
+
{
|
|
847
|
+
onClick: (e) => handleSelect(e, item),
|
|
848
|
+
className: `w-full px-4 py-2 flex items-center space-x-2 text-left ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
849
|
+
role: "option",
|
|
850
|
+
tabIndex: -1,
|
|
851
|
+
onMouseEnter: () => setHighlightedIndex(index),
|
|
852
|
+
children: /* @__PURE__ */ jsx12("span", { children: item[props.dataTextFieldName] })
|
|
853
|
+
},
|
|
854
|
+
item[props.dataKeyFieldName]
|
|
855
|
+
)) : /* @__PURE__ */ jsx12("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
] });
|
|
859
|
+
};
|
|
860
|
+
var SelectWithSearchInput_default = SelectWithSearchInput;
|
|
861
|
+
|
|
862
|
+
// src/components/controls/edit/SelectWithSearchPanel.tsx
|
|
863
|
+
import React13, {
|
|
864
|
+
useEffect as useEffect4,
|
|
865
|
+
useRef as useRef2,
|
|
866
|
+
useState as useState3,
|
|
867
|
+
useCallback
|
|
868
|
+
} from "react";
|
|
869
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
870
|
+
var SelectWithSearchPanel = (props) => {
|
|
871
|
+
const [isOpen, setIsOpen] = useState3(false);
|
|
872
|
+
const [searchTerm, setSearchTerm] = useState3("");
|
|
873
|
+
const [highlightedIndex, setHighlightedIndex] = useState3(0);
|
|
874
|
+
const [list, setList] = useState3([]);
|
|
875
|
+
const listRef = useRef2(null);
|
|
876
|
+
const [isError, setIsError] = useState3(false);
|
|
877
|
+
const containerRef = useRef2(null);
|
|
878
|
+
const [isCreateOpen, setIsCreateOpen] = useState3(false);
|
|
879
|
+
const [formData, setFormData] = useState3({});
|
|
880
|
+
const getNestedValue = (obj, path) => {
|
|
881
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
882
|
+
};
|
|
883
|
+
useEffect4(() => {
|
|
884
|
+
const handleClickOutside = (event) => {
|
|
885
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
886
|
+
setIsOpen(false);
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
890
|
+
return () => {
|
|
891
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
892
|
+
};
|
|
893
|
+
}, []);
|
|
894
|
+
useEffect4(() => {
|
|
895
|
+
async function fetchData() {
|
|
896
|
+
if (props.dataset) {
|
|
897
|
+
setList(props.dataset);
|
|
898
|
+
} else if (props.dataSource && props.serviceClient) {
|
|
899
|
+
let dataSource = props.dataSource;
|
|
900
|
+
if (props.dataSourceDependsOn && props.dependentValue) {
|
|
901
|
+
dataSource = dataSource.replace(
|
|
902
|
+
`{${props.dataSourceDependsOn}}`,
|
|
903
|
+
props.dependentValue
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
const response = await props.serviceClient.get(dataSource);
|
|
907
|
+
if (response?.result) setList(response.result);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
fetchData();
|
|
911
|
+
}, [
|
|
912
|
+
props.dataSource,
|
|
913
|
+
props.dependentValue,
|
|
914
|
+
props.dataset,
|
|
915
|
+
props.dataSourceDependsOn
|
|
916
|
+
]);
|
|
917
|
+
const filteredItems = list?.filter((item) => {
|
|
918
|
+
const value = getNestedValue(item, props.dataTextFieldName);
|
|
919
|
+
return value?.toLowerCase().includes(searchTerm?.toLowerCase());
|
|
920
|
+
});
|
|
921
|
+
const playBeep = () => {
|
|
922
|
+
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
923
|
+
const oscillator = audioCtx.createOscillator();
|
|
924
|
+
const gainNode = audioCtx.createGain();
|
|
925
|
+
oscillator.type = "square";
|
|
926
|
+
oscillator.frequency.setValueAtTime(300, audioCtx.currentTime);
|
|
927
|
+
gainNode.gain.setValueAtTime(0.02, audioCtx.currentTime);
|
|
928
|
+
oscillator.connect(gainNode);
|
|
929
|
+
gainNode.connect(audioCtx.destination);
|
|
930
|
+
oscillator.start();
|
|
931
|
+
setTimeout(() => {
|
|
932
|
+
oscillator.stop();
|
|
933
|
+
audioCtx.close();
|
|
934
|
+
}, 250);
|
|
935
|
+
};
|
|
936
|
+
useEffect4(() => {
|
|
937
|
+
const filteredItems2 = list?.filter(
|
|
938
|
+
(item) => item[props?.dataTextFieldName]?.toLowerCase().includes(searchTerm?.toLowerCase())
|
|
939
|
+
);
|
|
940
|
+
if (searchTerm.length > 0 && filteredItems2.length === 0) {
|
|
941
|
+
playBeep();
|
|
942
|
+
setIsError(true);
|
|
943
|
+
} else {
|
|
944
|
+
setIsError(false);
|
|
945
|
+
}
|
|
946
|
+
}, [searchTerm]);
|
|
947
|
+
const handleSelect = (event, item) => {
|
|
948
|
+
event.preventDefault();
|
|
949
|
+
setSearchTerm(getNestedValue(item, props.dataTextFieldName));
|
|
950
|
+
if (props.callback) {
|
|
951
|
+
const val = {};
|
|
952
|
+
props.callback({
|
|
953
|
+
name: props.name,
|
|
954
|
+
value: item[props.dataKeyFieldName],
|
|
955
|
+
index: props.index,
|
|
956
|
+
groupKey: props.groupKey
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
setHighlightedIndex(0);
|
|
960
|
+
setIsOpen(false);
|
|
961
|
+
};
|
|
962
|
+
const handleKeyDown = (e) => {
|
|
963
|
+
if (e.key === "Escape") {
|
|
964
|
+
setIsOpen(false);
|
|
965
|
+
setHighlightedIndex(-1);
|
|
966
|
+
} else if (e.key === "ArrowDown") {
|
|
967
|
+
e.preventDefault();
|
|
968
|
+
setHighlightedIndex((prev) => {
|
|
969
|
+
const nextIndex = prev < filteredItems.length - 1 ? prev + 1 : prev;
|
|
970
|
+
scrollIntoView(nextIndex);
|
|
971
|
+
return nextIndex;
|
|
972
|
+
});
|
|
973
|
+
} else if (e.key === "ArrowUp") {
|
|
974
|
+
e.preventDefault();
|
|
975
|
+
setHighlightedIndex((prev) => {
|
|
976
|
+
const prevIndex = prev > 0 ? prev - 1 : prev;
|
|
977
|
+
scrollIntoView(prevIndex);
|
|
978
|
+
return prevIndex;
|
|
979
|
+
});
|
|
980
|
+
} else if (e.key === "Enter" && highlightedIndex >= 0) {
|
|
981
|
+
handleSelect(e, filteredItems[highlightedIndex]);
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
const scrollIntoView = (index) => {
|
|
985
|
+
if (listRef.current) {
|
|
986
|
+
const item = listRef.current.children[index];
|
|
987
|
+
if (item) {
|
|
988
|
+
item.scrollIntoView();
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
const textChangeHandler = (event) => {
|
|
993
|
+
const newSearchTerm = event.target.value;
|
|
994
|
+
setSearchTerm(newSearchTerm);
|
|
995
|
+
setIsOpen(true);
|
|
996
|
+
setHighlightedIndex(0);
|
|
997
|
+
};
|
|
998
|
+
const handleInputChange = (event, field) => {
|
|
999
|
+
setFormData((prev) => ({ ...prev, [field]: event.target.value }));
|
|
1000
|
+
};
|
|
1001
|
+
const handleSaveModal = useCallback(async () => {
|
|
1002
|
+
console.log("Form Data:", formData);
|
|
1003
|
+
return formData;
|
|
1004
|
+
}, []);
|
|
1005
|
+
return /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
|
|
1006
|
+
/* @__PURE__ */ jsxs13("label", { className: "text-sm mb-1 font-medium", children: [
|
|
1007
|
+
props.attributes?.label,
|
|
1008
|
+
" ",
|
|
1009
|
+
" ",
|
|
1010
|
+
props?.attributes?.required && /* @__PURE__ */ jsx13("span", { className: "bg-error-weak", children: "*" })
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13(
|
|
1013
|
+
"input",
|
|
1014
|
+
{
|
|
1015
|
+
type: "text",
|
|
1016
|
+
value: searchTerm,
|
|
1017
|
+
onChange: textChangeHandler,
|
|
1018
|
+
onFocus: () => setIsOpen(true),
|
|
1019
|
+
onKeyDown: handleKeyDown,
|
|
1020
|
+
placeholder: props.attributes?.placeholder,
|
|
1021
|
+
className: `peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm
|
|
1022
|
+
${isError ? "focus:border-red-300 focus:ring focus:ring-red-200 focus:ring-opacity-50" : "focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"}
|
|
1023
|
+
disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none`
|
|
1024
|
+
}
|
|
1025
|
+
) }),
|
|
1026
|
+
/* @__PURE__ */ jsx13("div", { ref: containerRef, children: isOpen && /* @__PURE__ */ jsxs13(React13.Fragment, { children: [
|
|
1027
|
+
/* @__PURE__ */ jsxs13("div", { className: "fixed z-50 right-0 bg-white top-[62px] w-1/4 border-l border-gray-200", children: [
|
|
1028
|
+
/* @__PURE__ */ jsx13("div", { className: "flex flex-col p-2 bg-accent-950 text-white", children: /* @__PURE__ */ jsxs13("h5", { className: "text-md text-white font-medium", children: [
|
|
1029
|
+
"Select a",
|
|
1030
|
+
" ",
|
|
1031
|
+
props.attributes?.label || props.attributes?.heading
|
|
1032
|
+
] }) }),
|
|
1033
|
+
/* @__PURE__ */ jsx13("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200 h-10", children: props.createFields && props.createFields.length > 0 && /* @__PURE__ */ jsx13(
|
|
1034
|
+
"button",
|
|
1035
|
+
{
|
|
1036
|
+
type: "button",
|
|
1037
|
+
className: "text-primary hover:text-primary-800",
|
|
1038
|
+
onMouseDown: (e) => {
|
|
1039
|
+
e.preventDefault();
|
|
1040
|
+
setIsCreateOpen(true);
|
|
1041
|
+
},
|
|
1042
|
+
children: "Create"
|
|
1043
|
+
}
|
|
1044
|
+
) })
|
|
1045
|
+
] }),
|
|
1046
|
+
isCreateOpen && /* @__PURE__ */ jsxs13("div", { className: "fixed right-0 w-1/4 h-full top-[62px] bg-white shadow-lg border-l border-gray-200 z-50", children: [
|
|
1047
|
+
/* @__PURE__ */ jsx13("div", { className: "flex flex-col p-2 bg-accent-950", children: /* @__PURE__ */ jsxs13("h5", { className: "text-md font-medium text-white", children: [
|
|
1048
|
+
"Create New ",
|
|
1049
|
+
props.attributes?.label
|
|
1050
|
+
] }) }),
|
|
1051
|
+
/* @__PURE__ */ jsx13("div", { className: "flex justify-end px-4 border-b py-2 border-gray-200", children: /* @__PURE__ */ jsx13(
|
|
1052
|
+
"button",
|
|
1053
|
+
{
|
|
1054
|
+
type: "button",
|
|
1055
|
+
onClick: () => setIsCreateOpen(false),
|
|
1056
|
+
className: "text-red-600 hover:text-red-800",
|
|
1057
|
+
children: "Close"
|
|
1058
|
+
}
|
|
1059
|
+
) }),
|
|
1060
|
+
/* @__PURE__ */ jsxs13("div", { className: "p-4", children: [
|
|
1061
|
+
props.createFields?.map((field) => /* @__PURE__ */ jsxs13("div", { className: "mb-4", children: [
|
|
1062
|
+
/* @__PURE__ */ jsx13("label", { className: "text-sm mb-1 font-medium block", children: field.label }),
|
|
1063
|
+
/* @__PURE__ */ jsx13(
|
|
1064
|
+
"input",
|
|
1065
|
+
{
|
|
1066
|
+
type: field.type,
|
|
1067
|
+
value: formData[field.name] || "",
|
|
1068
|
+
onChange: (e) => handleInputChange(e, field.name),
|
|
1069
|
+
placeholder: field.placeholder,
|
|
1070
|
+
required: field.required,
|
|
1071
|
+
disabled: field.disabled,
|
|
1072
|
+
pattern: field.pattern,
|
|
1073
|
+
minLength: field.minLength,
|
|
1074
|
+
maxLength: field.maxLength,
|
|
1075
|
+
className: "peer mt-1 py-1.5 block w-full text-black rounded border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
] }, field.name)),
|
|
1079
|
+
/* @__PURE__ */ jsxs13(Button_default, { onClick: async () => {
|
|
1080
|
+
handleSaveModal();
|
|
1081
|
+
return { isSuccessful: true };
|
|
1082
|
+
}, className: "w-full", children: [
|
|
1083
|
+
"Save ",
|
|
1084
|
+
props.attributes?.label
|
|
1085
|
+
] })
|
|
1086
|
+
] })
|
|
1087
|
+
] }),
|
|
1088
|
+
/* @__PURE__ */ jsx13(
|
|
1089
|
+
"div",
|
|
1090
|
+
{
|
|
1091
|
+
ref: listRef,
|
|
1092
|
+
className: "fixed z-10 right-0 mt-[130px] top-0 w-1/4 bg-white border-l border-gray-200 shadow-lg overflow-y-auto",
|
|
1093
|
+
style: { height: "calc(100vh - 130px)" },
|
|
1094
|
+
children: filteredItems.length > 0 ? filteredItems.map((item, index) => /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13(
|
|
1095
|
+
"button",
|
|
1096
|
+
{
|
|
1097
|
+
onClick: (e) => {
|
|
1098
|
+
handleSelect(e, item);
|
|
1099
|
+
},
|
|
1100
|
+
className: `w-full px-4 py-2 flex items-center space-x-2 text-left border-b border-gray-200 ${index === highlightedIndex ? "bg-gray-200" : "hover:bg-gray-100"}`,
|
|
1101
|
+
role: "option",
|
|
1102
|
+
tabIndex: -1,
|
|
1103
|
+
onMouseEnter: () => setHighlightedIndex(index),
|
|
1104
|
+
children: /* @__PURE__ */ jsx13("span", { children: getNestedValue(item, props.dataTextFieldName) })
|
|
1105
|
+
}
|
|
1106
|
+
) }, item[props.dataKeyFieldName])) : /* @__PURE__ */ jsx13("div", { className: "px-4 py-2 text-gray-500", children: "No results found" })
|
|
1107
|
+
}
|
|
1108
|
+
)
|
|
1109
|
+
] }) })
|
|
1110
|
+
] });
|
|
1111
|
+
};
|
|
1112
|
+
var SelectWithSearchPanel_default = SelectWithSearchPanel;
|
|
1113
|
+
|
|
1114
|
+
// src/components/controls/edit/BooleanSelect.tsx
|
|
1115
|
+
import React14, {
|
|
1116
|
+
useState as useState4,
|
|
1117
|
+
useEffect as useEffect5
|
|
1118
|
+
} from "react";
|
|
1119
|
+
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1120
|
+
var BooleanSelect = (props) => {
|
|
1121
|
+
const [list, setList] = useState4();
|
|
1122
|
+
const textChangeHandler = (event) => {
|
|
1123
|
+
const text = event.target.value;
|
|
1124
|
+
const boolValue = text?.toLowerCase() === "true" || text === "1";
|
|
1125
|
+
if (props.callback !== void 0) {
|
|
1126
|
+
props.callback({
|
|
1127
|
+
name: props.name,
|
|
1128
|
+
value: boolValue,
|
|
1129
|
+
index: props.index,
|
|
1130
|
+
groupKey: props.groupKey
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
useEffect5(() => {
|
|
1135
|
+
async function fetchData() {
|
|
1136
|
+
console.log("in select");
|
|
1137
|
+
if (props.dataset) {
|
|
1138
|
+
setList(props.dataset);
|
|
1139
|
+
} else if (props.dataSource && props.dataSource != "" && props.serviceClient) {
|
|
1140
|
+
let dataSource = props.dataSource;
|
|
1141
|
+
let response;
|
|
1142
|
+
if (props.dataSourceDependsOn) {
|
|
1143
|
+
if (props.dependentValue) {
|
|
1144
|
+
dataSource = dataSource.replace(
|
|
1145
|
+
`{${props.dataSourceDependsOn}}`,
|
|
1146
|
+
props.dependentValue
|
|
1147
|
+
);
|
|
1148
|
+
response = await props.serviceClient.get(dataSource);
|
|
1149
|
+
setList(response.result);
|
|
1150
|
+
}
|
|
1151
|
+
} else {
|
|
1152
|
+
response = await props.serviceClient.get(dataSource);
|
|
1153
|
+
setList(response.result);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
fetchData();
|
|
1158
|
+
}, [
|
|
1159
|
+
props.dataSource,
|
|
1160
|
+
props.dependentValue,
|
|
1161
|
+
props.dataset,
|
|
1162
|
+
props.dataSourceDependsOn
|
|
1163
|
+
]);
|
|
1164
|
+
let value;
|
|
1165
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
1166
|
+
value = props.value;
|
|
1167
|
+
}
|
|
1168
|
+
return /* @__PURE__ */ jsx14(React14.Fragment, { children: /* @__PURE__ */ jsxs14("label", { className: "block", children: [
|
|
1169
|
+
/* @__PURE__ */ jsx14("span", { className: "text-sm font-medium ", children: props?.attributes?.label }),
|
|
1170
|
+
" ",
|
|
1171
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx14("span", { className: "bg-error-weak", children: "*" }),
|
|
1172
|
+
/* @__PURE__ */ jsxs14(
|
|
1173
|
+
"select",
|
|
1174
|
+
{
|
|
1175
|
+
name: props.name,
|
|
1176
|
+
id: props.name,
|
|
1177
|
+
value,
|
|
1178
|
+
onChange: textChangeHandler,
|
|
1179
|
+
required: props?.attributes?.required,
|
|
1180
|
+
placeholder: props?.attributes?.placeholder,
|
|
1181
|
+
disabled: props?.attributes?.readOnly,
|
|
1182
|
+
className: "peer mt-1 py-1.5 block w-full text-black rounded shadow-sm\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none\n ",
|
|
1183
|
+
children: [
|
|
1184
|
+
/* @__PURE__ */ jsx14("option", { className: "", value: "", children: props.attributes?.placeholder || "Select" }),
|
|
1185
|
+
list && list.map((item, i) => {
|
|
1186
|
+
return /* @__PURE__ */ jsx14(
|
|
1187
|
+
"option",
|
|
1188
|
+
{
|
|
1189
|
+
className: "fac-select-option",
|
|
1190
|
+
value: item[props.dataKeyFieldName],
|
|
1191
|
+
children: item[props.dataTextFieldName]
|
|
1192
|
+
},
|
|
1193
|
+
item[props.dataKeyFieldName]
|
|
1194
|
+
);
|
|
1195
|
+
})
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
),
|
|
1199
|
+
/* @__PURE__ */ jsx14("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
1200
|
+
] }) });
|
|
1201
|
+
};
|
|
1202
|
+
var BooleanSelect_default = BooleanSelect;
|
|
1203
|
+
|
|
1204
|
+
// src/components/controls/edit/EmailInput.tsx
|
|
1205
|
+
import React15 from "react";
|
|
1206
|
+
import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1207
|
+
var EmailInput = (props) => {
|
|
1208
|
+
const textChangeHandler = (event) => {
|
|
1209
|
+
const text = event.target.value;
|
|
1210
|
+
if (text) {
|
|
1211
|
+
const atIndex = text.indexOf("@");
|
|
1212
|
+
const dotIndex = text.indexOf(".", atIndex);
|
|
1213
|
+
if (dotIndex < atIndex || text.length - dotIndex <= 2) {
|
|
1214
|
+
event.target.setCustomValidity("invaild-value");
|
|
1215
|
+
} else {
|
|
1216
|
+
event.target.setCustomValidity("");
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
if (props.callback !== void 0) {
|
|
1220
|
+
props.callback({
|
|
1221
|
+
name: props.name,
|
|
1222
|
+
value: text,
|
|
1223
|
+
index: props.index
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
let value = "";
|
|
1228
|
+
if (props.value !== void 0 && props.value !== null) {
|
|
1229
|
+
value = props.value;
|
|
1230
|
+
}
|
|
1231
|
+
return /* @__PURE__ */ jsx15(React15.Fragment, { children: /* @__PURE__ */ jsxs15("label", { className: "block mb-1", children: [
|
|
1232
|
+
/* @__PURE__ */ jsx15("span", { className: "text-sm font-medium text-slate-700", children: props?.attributes?.label }),
|
|
1233
|
+
" ",
|
|
1234
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx15("span", { className: "bg-error-weak", children: "*" }),
|
|
1235
|
+
/* @__PURE__ */ jsx15(
|
|
1236
|
+
"input",
|
|
1237
|
+
{
|
|
1238
|
+
type: "email",
|
|
1239
|
+
name: props.name,
|
|
1240
|
+
id: props.name,
|
|
1241
|
+
value,
|
|
1242
|
+
onChange: textChangeHandler,
|
|
1243
|
+
required: props?.attributes?.required,
|
|
1244
|
+
placeholder: props?.attributes?.placeholder,
|
|
1245
|
+
maxLength: props?.attributes?.maxLength,
|
|
1246
|
+
disabled: props?.attributes?.readOnly,
|
|
1247
|
+
minLength: props?.attributes?.minLength,
|
|
1248
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm\n transition-all duration-500 ease-in-out"
|
|
1249
|
+
}
|
|
1250
|
+
),
|
|
1251
|
+
/* @__PURE__ */ jsx15("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 mb-0 bg-error-weak text-sm", children: props?.attributes?.errorMessage ? props.attributes.errorMessage : "" })
|
|
1252
|
+
] }) });
|
|
1253
|
+
};
|
|
1254
|
+
var EmailInput_default = EmailInput;
|
|
1255
|
+
|
|
1256
|
+
// src/components/controls/edit/TimeInput.tsx
|
|
1257
|
+
import React16 from "react";
|
|
1258
|
+
import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1259
|
+
var TimeInput = (props) => {
|
|
1260
|
+
const timeChangeHandler = (event) => {
|
|
1261
|
+
const timeValue = event.target.value;
|
|
1262
|
+
if (props.callback) {
|
|
1263
|
+
props.callback({
|
|
1264
|
+
name: props.name,
|
|
1265
|
+
value: timeValue,
|
|
1266
|
+
index: props.index,
|
|
1267
|
+
groupKey: props.groupKey
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
return /* @__PURE__ */ jsx16(React16.Fragment, { children: /* @__PURE__ */ jsxs16("label", { className: "block mb-1", children: [
|
|
1272
|
+
/* @__PURE__ */ jsx16("span", { className: "text-sm font-medium", children: props?.attributes?.label }),
|
|
1273
|
+
" ",
|
|
1274
|
+
props?.attributes?.label && props?.attributes?.required && /* @__PURE__ */ jsx16("span", { className: "bg-error-weak", children: "*" }),
|
|
1275
|
+
/* @__PURE__ */ jsx16("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx16(
|
|
1276
|
+
"input",
|
|
1277
|
+
{
|
|
1278
|
+
type: "time",
|
|
1279
|
+
name: props.name,
|
|
1280
|
+
id: props.name,
|
|
1281
|
+
value: typeof props.value === "boolean" ? "" : props.value ?? "",
|
|
1282
|
+
onChange: timeChangeHandler,
|
|
1283
|
+
required: props?.attributes?.required,
|
|
1284
|
+
disabled: props?.attributes?.readOnly,
|
|
1285
|
+
className: "peer mt-1 py-1.5 block w-full rounded shadow-sm\n disabled:bg-slate-50 disabled:text-slate-500 disabled:border-slate-200 disabled:shadow-none"
|
|
1286
|
+
}
|
|
1287
|
+
) }),
|
|
1288
|
+
/* @__PURE__ */ jsx16("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage ?? "" })
|
|
1289
|
+
] }) });
|
|
1290
|
+
};
|
|
1291
|
+
var TimeInput_default = TimeInput;
|
|
1292
|
+
|
|
1293
|
+
// src/components/controls/edit/AssetUpload.tsx
|
|
1294
|
+
import React17, { useEffect as useEffect6 } from "react";
|
|
1295
|
+
import { jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1296
|
+
var AssetUpload = (props) => {
|
|
1297
|
+
const isDisabled = props.attributes?.disable ?? false;
|
|
1298
|
+
let allValues = [];
|
|
1299
|
+
if (props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
1300
|
+
try {
|
|
1301
|
+
allValues = JSON.parse(props.value.toString());
|
|
1302
|
+
} catch (error) {
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
const getInitialTab = () => {
|
|
1306
|
+
if (allValues.length > 0) {
|
|
1307
|
+
const asset = allValues[0];
|
|
1308
|
+
if (asset.posterUrl) {
|
|
1309
|
+
return "video";
|
|
1310
|
+
} else if (asset.assetUrl) {
|
|
1311
|
+
return "image";
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
return "image";
|
|
1315
|
+
};
|
|
1316
|
+
const [assetType, setAssetType] = React17.useState(getInitialTab);
|
|
1317
|
+
useEffect6(() => {
|
|
1318
|
+
setAssetType(getInitialTab());
|
|
1319
|
+
}, [props.value]);
|
|
1320
|
+
const assetUploadCallback = (newAsset) => {
|
|
1321
|
+
if (isDisabled) return;
|
|
1322
|
+
let updated = [];
|
|
1323
|
+
updated.push({
|
|
1324
|
+
assetUrl: newAsset.assetUrl,
|
|
1325
|
+
title: newAsset.title,
|
|
1326
|
+
posterUrl: newAsset.posterUrl,
|
|
1327
|
+
intrinsicHeight: newAsset.intrinsicHeight,
|
|
1328
|
+
intrinsicWidth: newAsset.intrinsicWidth
|
|
1329
|
+
});
|
|
1330
|
+
props.callback?.({
|
|
1331
|
+
name: props.name,
|
|
1332
|
+
value: JSON.stringify(updated),
|
|
1333
|
+
index: props.index,
|
|
1334
|
+
groupKey: props.groupKey
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
const deleteFile = (index) => {
|
|
1338
|
+
if (isDisabled) return;
|
|
1339
|
+
let existingValue = [];
|
|
1340
|
+
if (props.value) {
|
|
1341
|
+
try {
|
|
1342
|
+
existingValue = JSON.parse(props.value.toString());
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
if (existingValue.length > index) {
|
|
1347
|
+
existingValue.splice(index, 1);
|
|
1348
|
+
props.callback?.({
|
|
1349
|
+
name: props.name,
|
|
1350
|
+
value: JSON.stringify(existingValue),
|
|
1351
|
+
index: props.index,
|
|
1352
|
+
groupKey: props.groupKey
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
const textChangeHandler = (index, event) => {
|
|
1357
|
+
if (isDisabled) return;
|
|
1358
|
+
let existingValue = [];
|
|
1359
|
+
if (props.value) {
|
|
1360
|
+
try {
|
|
1361
|
+
existingValue = JSON.parse(props.value.toString());
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
const text = event.target.value;
|
|
1366
|
+
if (existingValue.length > index) {
|
|
1367
|
+
const updatedArray = [...existingValue];
|
|
1368
|
+
updatedArray[index] = { ...updatedArray[index], title: text };
|
|
1369
|
+
props.callback?.({
|
|
1370
|
+
name: props.name,
|
|
1371
|
+
value: JSON.stringify(updatedArray),
|
|
1372
|
+
index: props.index,
|
|
1373
|
+
groupKey: props.groupKey
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
const getAssetType = (asset) => {
|
|
1378
|
+
if (asset.assetUrl?.endsWith(".m3u8") || asset.posterUrl) return "video";
|
|
1379
|
+
return "image";
|
|
1380
|
+
};
|
|
1381
|
+
const shouldShowDetails = () => {
|
|
1382
|
+
if (allValues.length === 0) return false;
|
|
1383
|
+
const asset = allValues[0];
|
|
1384
|
+
if (assetType === "video") {
|
|
1385
|
+
return Boolean(asset.posterUrl && asset.assetUrl && asset.assetUrl.endsWith(".m3u8"));
|
|
1386
|
+
}
|
|
1387
|
+
if (assetType === "image") {
|
|
1388
|
+
return Boolean(asset.assetUrl && !asset.assetUrl.endsWith(".m3u8"));
|
|
1389
|
+
}
|
|
1390
|
+
return false;
|
|
1391
|
+
};
|
|
1392
|
+
return /* @__PURE__ */ jsxs17(React17.Fragment, { children: [
|
|
1393
|
+
/* @__PURE__ */ jsx17("label", { className: "block mb-1", children: /* @__PURE__ */ jsx17("span", { className: "text-sm font-medium", children: props?.attributes?.label }) }),
|
|
1394
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex gap-6 bg-neutral-100 rounded p-2", children: [
|
|
1395
|
+
/* @__PURE__ */ jsx17(
|
|
1396
|
+
ClientButton_default,
|
|
1397
|
+
{
|
|
1398
|
+
className: assetType === "image" ? "px-2 py-1 rounded bg-body-200 scale-95" : "text-neutral-700",
|
|
1399
|
+
ButtonType: "Link" /* Link */,
|
|
1400
|
+
onClick: () => setAssetType("image"),
|
|
1401
|
+
disabled: isDisabled,
|
|
1402
|
+
children: "Image Upload"
|
|
1403
|
+
}
|
|
1404
|
+
),
|
|
1405
|
+
/* @__PURE__ */ jsx17(
|
|
1406
|
+
ClientButton_default,
|
|
1407
|
+
{
|
|
1408
|
+
className: assetType === "video" ? "bg-body-200 px-2 py-1 rounded-md scale-95" : "text-neutral-700",
|
|
1409
|
+
ButtonType: "Link" /* Link */,
|
|
1410
|
+
onClick: () => setAssetType("video"),
|
|
1411
|
+
disabled: isDisabled,
|
|
1412
|
+
children: "Video Upload"
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
] }),
|
|
1416
|
+
shouldShowDetails() && /* @__PURE__ */ jsxs17("div", { className: "relative mt-4 rounded-md p-4 border-2 border-dotted border-gray-300 bg-gray-50", children: [
|
|
1417
|
+
/* @__PURE__ */ jsx17("span", { className: "absolute -top-2.5 left-3 bg-primary-600 text-white text-xs px-2 py-0.5 rounded-full", children: getAssetType(allValues[0]) === "video" ? "Video" : "Image" }),
|
|
1418
|
+
/* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-3", children: allValues.map((digitalAsset, index) => /* @__PURE__ */ jsxs17("div", { className: "flex justify-between items-start gap-5", children: [
|
|
1419
|
+
/* @__PURE__ */ jsxs17("div", { className: "grid grid-cols-2 gap-x-8 gap-y-3 text-sm w-full", children: [
|
|
1420
|
+
/* @__PURE__ */ jsxs17("div", { children: [
|
|
1421
|
+
/* @__PURE__ */ jsx17("p", { className: "text-gray-500", children: "Title" }),
|
|
1422
|
+
/* @__PURE__ */ jsx17(
|
|
1423
|
+
"input",
|
|
1424
|
+
{
|
|
1425
|
+
type: "text",
|
|
1426
|
+
value: digitalAsset.title,
|
|
1427
|
+
onChange: (event) => textChangeHandler(index, event),
|
|
1428
|
+
placeholder: "title",
|
|
1429
|
+
disabled: isDisabled,
|
|
1430
|
+
className: "w-full mt-1 py-1.5 block rounded border-gray-300 shadow-sm bg-white\n focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50\n disabled:bg-gray-100 disabled:text-gray-400 disabled:cursor-not-allowed"
|
|
1431
|
+
}
|
|
1432
|
+
)
|
|
1433
|
+
] }),
|
|
1434
|
+
digitalAsset.intrinsicWidth && digitalAsset.intrinsicHeight && /* @__PURE__ */ jsxs17("div", { children: [
|
|
1435
|
+
/* @__PURE__ */ jsx17("p", { className: "text-gray-500", children: "Resolution" }),
|
|
1436
|
+
/* @__PURE__ */ jsxs17("p", { className: "font-medium text-gray-900 mt-3", children: [
|
|
1437
|
+
digitalAsset.intrinsicWidth,
|
|
1438
|
+
"\xD7",
|
|
1439
|
+
digitalAsset.intrinsicHeight
|
|
1440
|
+
] })
|
|
1441
|
+
] }),
|
|
1442
|
+
(digitalAsset.assetUrl || digitalAsset.posterUrl) && /* @__PURE__ */ jsxs17("div", { children: [
|
|
1443
|
+
/* @__PURE__ */ jsx17("p", { className: "text-gray-500", children: "Image / Poster" }),
|
|
1444
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-shrink-0 flex flex-col gap-3 mt-1", children: [
|
|
1445
|
+
getAssetType(digitalAsset) === "video" && digitalAsset.posterUrl && /* @__PURE__ */ jsx17(
|
|
1446
|
+
"img",
|
|
1447
|
+
{
|
|
1448
|
+
src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.posterUrl),
|
|
1449
|
+
alt: digitalAsset.title || "Video poster",
|
|
1450
|
+
className: "w-32 h-auto object-cover rounded border p-1"
|
|
1451
|
+
}
|
|
1452
|
+
),
|
|
1453
|
+
getAssetType(digitalAsset) === "image" && digitalAsset.assetUrl && /* @__PURE__ */ jsx17(
|
|
1454
|
+
"img",
|
|
1455
|
+
{
|
|
1456
|
+
src: AssetUtility_default.resolveUrl(props.serviceClient?.baseUrl, digitalAsset.assetUrl),
|
|
1457
|
+
alt: digitalAsset.title || "Uploaded image",
|
|
1458
|
+
className: "w-32 h-auto object-cover rounded border p-1"
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
] })
|
|
1462
|
+
] }),
|
|
1463
|
+
digitalAsset.assetUrl?.endsWith(".m3u8") && /* @__PURE__ */ jsxs17("div", { className: "col-span-2", children: [
|
|
1464
|
+
/* @__PURE__ */ jsx17("p", { className: "text-gray-500", children: "HLS Link" }),
|
|
1465
|
+
/* @__PURE__ */ jsx17(
|
|
1466
|
+
Hyperlink,
|
|
1467
|
+
{
|
|
1468
|
+
href: digitalAsset.assetUrl,
|
|
1469
|
+
className: "text-primary-600 underline mt-1 break-all",
|
|
1470
|
+
title: digitalAsset.assetUrl,
|
|
1471
|
+
children: digitalAsset.assetUrl
|
|
1472
|
+
}
|
|
1473
|
+
)
|
|
1474
|
+
] })
|
|
1475
|
+
] }),
|
|
1476
|
+
/* @__PURE__ */ jsx17(
|
|
1477
|
+
"span",
|
|
1478
|
+
{
|
|
1479
|
+
onClick: () => !isDisabled && deleteFile(index),
|
|
1480
|
+
className: isDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer",
|
|
1481
|
+
children: /* @__PURE__ */ jsx17(Icon_default, { className: "w-4 h-4 text-primary", name: "delete" })
|
|
1482
|
+
}
|
|
1483
|
+
)
|
|
1484
|
+
] }, index)) })
|
|
1485
|
+
] })
|
|
1486
|
+
] });
|
|
1487
|
+
};
|
|
1488
|
+
var AssetUpload_default = AssetUpload;
|
|
1489
|
+
|
|
1490
|
+
// src/components/controls/edit/SwitchInput.tsx
|
|
1491
|
+
import React18 from "react";
|
|
1492
|
+
import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1493
|
+
var SwitchInput = (props) => {
|
|
1494
|
+
const textChangeHandler = (event) => {
|
|
1495
|
+
let text = event.target.checked;
|
|
1496
|
+
if (props.callback !== void 0) {
|
|
1497
|
+
props.callback({
|
|
1498
|
+
name: props.name,
|
|
1499
|
+
value: text,
|
|
1500
|
+
index: props.index,
|
|
1501
|
+
groupKey: props.groupKey
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
let value = false;
|
|
1506
|
+
if (props.value != void 0 && props.value != null && props.value != "" && (props.value == "true" || props.value.toString() == "true")) {
|
|
1507
|
+
value = true;
|
|
1508
|
+
}
|
|
1509
|
+
return /* @__PURE__ */ jsx18(React18.Fragment, { children: /* @__PURE__ */ jsxs18("div", { className: "flex items-start justify-between gap-4 py-3", children: [
|
|
1510
|
+
/* @__PURE__ */ jsxs18("div", { className: "min-w-0", children: [
|
|
1511
|
+
props?.attributes?.label && /* @__PURE__ */ jsxs18(
|
|
1512
|
+
"label",
|
|
1513
|
+
{
|
|
1514
|
+
htmlFor: props.name,
|
|
1515
|
+
className: "inline-block text-sm font-semibold text-slate-800",
|
|
1516
|
+
children: [
|
|
1517
|
+
props.attributes.label,
|
|
1518
|
+
props?.attributes?.required && /* @__PURE__ */ jsx18("span", { className: "bg-error-weak", children: "*" })
|
|
1519
|
+
]
|
|
1520
|
+
}
|
|
1521
|
+
),
|
|
1522
|
+
/* @__PURE__ */ jsx18("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props?.attributes?.errorMessage || "" })
|
|
1523
|
+
] }),
|
|
1524
|
+
/* @__PURE__ */ jsxs18(
|
|
1525
|
+
"label",
|
|
1526
|
+
{
|
|
1527
|
+
htmlFor: props.name,
|
|
1528
|
+
className: "relative inline-flex shrink-0 cursor-pointer items-center peer-disabled:cursor-not-allowed",
|
|
1529
|
+
children: [
|
|
1530
|
+
/* @__PURE__ */ jsx18(
|
|
1531
|
+
"input",
|
|
1532
|
+
{
|
|
1533
|
+
type: "checkbox",
|
|
1534
|
+
name: props.name,
|
|
1535
|
+
id: props.name,
|
|
1536
|
+
checked: value,
|
|
1537
|
+
onChange: textChangeHandler,
|
|
1538
|
+
required: props?.attributes?.required,
|
|
1539
|
+
disabled: props?.attributes?.readOnly,
|
|
1540
|
+
className: "peer sr-only"
|
|
1541
|
+
}
|
|
1542
|
+
),
|
|
1543
|
+
/* @__PURE__ */ jsx18(
|
|
1544
|
+
"div",
|
|
1545
|
+
{
|
|
1546
|
+
className: "h-6 w-11 rounded-full bg-slate-200 shadow-inner\n transition-colors duration-200 ease-in-out\n peer-checked:bg-blue-600\n peer-focus-visible:ring-2 peer-focus-visible:ring-blue-300 peer-focus-visible:ring-offset-2\n peer-disabled:bg-slate-100"
|
|
1547
|
+
}
|
|
1548
|
+
),
|
|
1549
|
+
/* @__PURE__ */ jsx18(
|
|
1550
|
+
"div",
|
|
1551
|
+
{
|
|
1552
|
+
className: "absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-default shadow\n transition-transform duration-200 ease-in-out\n peer-checked:translate-x-5\n peer-disabled:bg-slate-50"
|
|
1553
|
+
}
|
|
1554
|
+
)
|
|
1555
|
+
]
|
|
1556
|
+
}
|
|
1557
|
+
)
|
|
1558
|
+
] }) });
|
|
1559
|
+
};
|
|
1560
|
+
var SwitchInput_default = SwitchInput;
|
|
1561
|
+
|
|
1562
|
+
// src/components/controls/edit/DateInput.tsx
|
|
1563
|
+
import { useMemo } from "react";
|
|
1564
|
+
|
|
1565
|
+
// src/components/utilities/DateTimeUtility.tsx
|
|
1566
|
+
var DateTimeUtility = class {
|
|
1567
|
+
constructor() {
|
|
1568
|
+
}
|
|
1569
|
+
static formatDate(date) {
|
|
1570
|
+
if (!date) {
|
|
1571
|
+
throw new Error("Invalid date");
|
|
1572
|
+
}
|
|
1573
|
+
const pad = (num) => num.toString().padStart(2, "0");
|
|
1574
|
+
const year = date.getFullYear();
|
|
1575
|
+
const month = pad(date.getMonth() + 1);
|
|
1576
|
+
const day = pad(date.getDate());
|
|
1577
|
+
const hours = pad(date.getHours());
|
|
1578
|
+
const minutes = pad(date.getMinutes());
|
|
1579
|
+
const seconds = pad(date.getSeconds());
|
|
1580
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
|
|
1581
|
+
}
|
|
1582
|
+
static getMonthShortNameCustom(month) {
|
|
1583
|
+
const monthNames = [
|
|
1584
|
+
"Jan",
|
|
1585
|
+
"Feb",
|
|
1586
|
+
"Mar",
|
|
1587
|
+
"Apr",
|
|
1588
|
+
"May",
|
|
1589
|
+
"Jun",
|
|
1590
|
+
"Jul",
|
|
1591
|
+
"Aug",
|
|
1592
|
+
"Sep",
|
|
1593
|
+
"Oct",
|
|
1594
|
+
"Nov",
|
|
1595
|
+
"Dec"
|
|
1596
|
+
];
|
|
1597
|
+
if (month < 1 || month > 12) {
|
|
1598
|
+
throw new Error(
|
|
1599
|
+
"Invalid month. Please provide a value between 1 and 12."
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
return monthNames[month - 1];
|
|
1603
|
+
}
|
|
1604
|
+
static getCurrentWeekRange() {
|
|
1605
|
+
const today = /* @__PURE__ */ new Date();
|
|
1606
|
+
const day = today.getDay();
|
|
1607
|
+
const diffToMonday = (day === 0 ? -6 : 1) - day;
|
|
1608
|
+
const monday = new Date(today);
|
|
1609
|
+
monday.setDate(today.getDate() + diffToMonday);
|
|
1610
|
+
monday.setHours(0, 0, 0, 0);
|
|
1611
|
+
const sunday = new Date(monday);
|
|
1612
|
+
sunday.setDate(monday.getDate() + 6);
|
|
1613
|
+
sunday.setHours(23, 59, 59, 999);
|
|
1614
|
+
return { start: monday, end: sunday };
|
|
1615
|
+
}
|
|
1616
|
+
static getCurrentMonthRange() {
|
|
1617
|
+
const now = /* @__PURE__ */ new Date();
|
|
1618
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
1619
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
|
1620
|
+
return { start, end };
|
|
1621
|
+
}
|
|
1622
|
+
static formatShortDate(date) {
|
|
1623
|
+
const day = date.getDate();
|
|
1624
|
+
const month = this.getMonthShortNameCustom(date.getMonth() + 1);
|
|
1625
|
+
return `${day} ${month}`;
|
|
1626
|
+
}
|
|
1627
|
+
static formatIndianCurrencyShort(value) {
|
|
1628
|
+
if (value >= 1e7) {
|
|
1629
|
+
return `${(value / 1e7).toFixed(2)} Cr`;
|
|
1630
|
+
} else if (value >= 1e5) {
|
|
1631
|
+
return `${(value / 1e5).toFixed(2)} L`;
|
|
1632
|
+
} else if (value >= 1e3) {
|
|
1633
|
+
return `${(value / 1e3).toFixed(2)} K`;
|
|
1634
|
+
} else {
|
|
1635
|
+
return `${value}`;
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
var DateTimeUtility_default = DateTimeUtility;
|
|
1640
|
+
|
|
1641
|
+
// src/components/controls/edit/DateInput.tsx
|
|
1642
|
+
import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1643
|
+
var DateInput = (props) => {
|
|
1644
|
+
const value = useMemo(() => {
|
|
1645
|
+
if (props.value === void 0 || props.value === null || props.value === "") {
|
|
1646
|
+
return "";
|
|
1647
|
+
}
|
|
1648
|
+
try {
|
|
1649
|
+
const rawValue = String(props.value);
|
|
1650
|
+
const utcDate = new Date(rawValue.endsWith("Z") ? rawValue : `${rawValue}Z`);
|
|
1651
|
+
const localDate = new Date(
|
|
1652
|
+
utcDate.getTime() - utcDate.getTimezoneOffset() * 6e4
|
|
1653
|
+
);
|
|
1654
|
+
return localDate.toISOString().slice(0, 10);
|
|
1655
|
+
} catch {
|
|
1656
|
+
return String(props.value);
|
|
1657
|
+
}
|
|
1658
|
+
}, [props.value]);
|
|
1659
|
+
const changeHandler = (event) => {
|
|
1660
|
+
const dateValue = event.target.value;
|
|
1661
|
+
let callbackValue = dateValue;
|
|
1662
|
+
const parsedDate = new Date(dateValue);
|
|
1663
|
+
if (dateValue && !Number.isNaN(parsedDate.getTime())) {
|
|
1664
|
+
const adjustedDate = new Date(
|
|
1665
|
+
parsedDate.getTime() + 2 * parsedDate.getTimezoneOffset() * 6e4
|
|
1666
|
+
);
|
|
1667
|
+
callbackValue = DateTimeUtility_default.formatDate(adjustedDate);
|
|
1668
|
+
}
|
|
1669
|
+
props.callback?.({
|
|
1670
|
+
name: props.name,
|
|
1671
|
+
value: callbackValue,
|
|
1672
|
+
index: props.index,
|
|
1673
|
+
groupKey: props.groupKey
|
|
1674
|
+
});
|
|
1675
|
+
};
|
|
1676
|
+
return /* @__PURE__ */ jsxs19("label", { className: "block mb-1", children: [
|
|
1677
|
+
props.attributes?.label && /* @__PURE__ */ jsx19("span", { className: "text-sm font-medium", children: props.attributes.label }),
|
|
1678
|
+
" ",
|
|
1679
|
+
props.attributes?.label && props.attributes.required && /* @__PURE__ */ jsx19("span", { className: "bg-error-weak", children: "*" }),
|
|
1680
|
+
/* @__PURE__ */ jsx19(
|
|
1681
|
+
"input",
|
|
1682
|
+
{
|
|
1683
|
+
type: "date",
|
|
1684
|
+
name: props.name,
|
|
1685
|
+
id: props.name,
|
|
1686
|
+
value,
|
|
1687
|
+
onChange: changeHandler,
|
|
1688
|
+
required: props.attributes?.required,
|
|
1689
|
+
disabled: props.attributes?.readOnly,
|
|
1690
|
+
max: String(props.attributes?.maxValue ?? "9999-12-31"),
|
|
1691
|
+
className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
|
|
1692
|
+
}
|
|
1693
|
+
),
|
|
1694
|
+
/* @__PURE__ */ jsx19("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
|
|
1695
|
+
] });
|
|
1696
|
+
};
|
|
1697
|
+
var DateInput_default = DateInput;
|
|
1698
|
+
|
|
1699
|
+
// src/components/controls/edit/RadioInput.tsx
|
|
1700
|
+
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
1701
|
+
import { jsx as jsx20, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1702
|
+
var RadioInput = (props) => {
|
|
1703
|
+
const [list, setList] = useState5([]);
|
|
1704
|
+
useEffect7(() => {
|
|
1705
|
+
async function loadData() {
|
|
1706
|
+
if (props.dataset) {
|
|
1707
|
+
setList(props.dataset);
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
if (!props.dataSource || !props.serviceClient) {
|
|
1711
|
+
setList([]);
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
let dataSource = props.dataSource;
|
|
1715
|
+
if (props.dataSourceDependsOn) {
|
|
1716
|
+
if (!props.dependentValue) {
|
|
1717
|
+
setList([]);
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
dataSource = dataSource.replace(
|
|
1721
|
+
`{${props.dataSourceDependsOn}}`,
|
|
1722
|
+
props.dependentValue
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
const response = await props.serviceClient.get(dataSource);
|
|
1726
|
+
setList(response.result ?? []);
|
|
1727
|
+
}
|
|
1728
|
+
loadData();
|
|
1729
|
+
}, [
|
|
1730
|
+
props.dataSource,
|
|
1731
|
+
props.dataSourceDependsOn,
|
|
1732
|
+
props.dataset,
|
|
1733
|
+
props.dependentValue,
|
|
1734
|
+
props.serviceClient
|
|
1735
|
+
]);
|
|
1736
|
+
const changeHandler = (event) => {
|
|
1737
|
+
if (!props.attributes?.readOnly) {
|
|
1738
|
+
props.callback?.({
|
|
1739
|
+
name: props.name,
|
|
1740
|
+
value: event.target.value,
|
|
1741
|
+
index: props.index,
|
|
1742
|
+
groupKey: props.groupKey
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
return /* @__PURE__ */ jsxs20("div", { className: "block", children: [
|
|
1747
|
+
/* @__PURE__ */ jsx20("span", { className: "text-sm font-medium", children: props.attributes?.label }),
|
|
1748
|
+
/* @__PURE__ */ jsx20("div", { className: "flex flex-col gap-3", children: list.map((item, index) => {
|
|
1749
|
+
const itemValue = item[props.dataKeyFieldName];
|
|
1750
|
+
const isSelected = String(itemValue) === String(props.value ?? "");
|
|
1751
|
+
const isRecommended = props.dataRecommendedValue !== void 0 && String(itemValue) === String(props.dataRecommendedValue);
|
|
1752
|
+
const resultClassName = isSelected ? isRecommended ? "bg-success" : props.dataRecommendedValue ? "bg-alert" : "border-transparent" : "border-transparent";
|
|
1753
|
+
const iconName = isSelected && props.dataRecommendedValue ? isRecommended ? "checkCircle" : "xCircle" : void 0;
|
|
1754
|
+
const inputId = `${props.name}-${props.index ?? 0}-id-${index}`;
|
|
1755
|
+
return /* @__PURE__ */ jsxs20(
|
|
1756
|
+
"div",
|
|
1757
|
+
{
|
|
1758
|
+
className: `font-normal flex items-center justify-between gap-4 cursor-pointer border rounded p-2 ${resultClassName}`,
|
|
1759
|
+
children: [
|
|
1760
|
+
/* @__PURE__ */ jsxs20("div", { className: "flex gap-4 items-start", children: [
|
|
1761
|
+
/* @__PURE__ */ jsx20(
|
|
1762
|
+
"input",
|
|
1763
|
+
{
|
|
1764
|
+
type: "radio",
|
|
1765
|
+
className: "form-radio mt-1.5 focus:outline-none",
|
|
1766
|
+
name: `${props.name}-${props.index ?? 0}`,
|
|
1767
|
+
id: inputId,
|
|
1768
|
+
value: itemValue,
|
|
1769
|
+
checked: isSelected,
|
|
1770
|
+
readOnly: props.attributes?.readOnly,
|
|
1771
|
+
onChange: changeHandler,
|
|
1772
|
+
required: props.attributes?.required
|
|
1773
|
+
}
|
|
1774
|
+
),
|
|
1775
|
+
/* @__PURE__ */ jsx20("label", { className: "text-body-950 pr-2", htmlFor: inputId, children: item[props.dataTextFieldName] })
|
|
1776
|
+
] }),
|
|
1777
|
+
iconName && /* @__PURE__ */ jsx20(Icon_default, { className: "w-5 h-5 text-success", name: iconName })
|
|
1778
|
+
]
|
|
1779
|
+
},
|
|
1780
|
+
String(itemValue)
|
|
1781
|
+
);
|
|
1782
|
+
}) }),
|
|
1783
|
+
/* @__PURE__ */ jsx20("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
|
|
1784
|
+
] });
|
|
1785
|
+
};
|
|
1786
|
+
var RadioInput_default = RadioInput;
|
|
1787
|
+
|
|
1788
|
+
// src/components/controls/edit/Switcher.tsx
|
|
1789
|
+
import { useEffect as useEffect8, useState as useState6 } from "react";
|
|
1790
|
+
import { jsx as jsx21, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1791
|
+
var Switcher = (props) => {
|
|
1792
|
+
const [list, setList] = useState6([]);
|
|
1793
|
+
useEffect8(() => {
|
|
1794
|
+
async function loadData() {
|
|
1795
|
+
if (props.dataset) {
|
|
1796
|
+
setList(props.dataset);
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (!props.dataSource || !props.serviceClient) {
|
|
1800
|
+
setList([]);
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
let dataSource = props.dataSource;
|
|
1804
|
+
if (props.dataSourceDependsOn) {
|
|
1805
|
+
if (!props.dependentValue) {
|
|
1806
|
+
setList([]);
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
dataSource = dataSource.replace(
|
|
1810
|
+
`{${props.dataSourceDependsOn}}`,
|
|
1811
|
+
props.dependentValue
|
|
1812
|
+
);
|
|
1813
|
+
}
|
|
1814
|
+
const response = await props.serviceClient.get(dataSource);
|
|
1815
|
+
setList(response.result ?? []);
|
|
1816
|
+
}
|
|
1817
|
+
loadData();
|
|
1818
|
+
}, [
|
|
1819
|
+
props.dataSource,
|
|
1820
|
+
props.dataSourceDependsOn,
|
|
1821
|
+
props.dataset,
|
|
1822
|
+
props.dependentValue,
|
|
1823
|
+
props.serviceClient
|
|
1824
|
+
]);
|
|
1825
|
+
const changeHandler = (event) => {
|
|
1826
|
+
props.callback?.({
|
|
1827
|
+
name: props.name,
|
|
1828
|
+
value: event.target.value,
|
|
1829
|
+
index: props.index,
|
|
1830
|
+
groupKey: props.groupKey
|
|
1831
|
+
});
|
|
1832
|
+
};
|
|
1833
|
+
const value = props.value === void 0 || props.value === null ? "" : String(props.value);
|
|
1834
|
+
return /* @__PURE__ */ jsxs21("label", { className: "block mb-1", children: [
|
|
1835
|
+
/* @__PURE__ */ jsx21("span", { className: "text-sm font-medium", children: props.attributes?.label }),
|
|
1836
|
+
list.length === 0 ? /* @__PURE__ */ jsx21(
|
|
1837
|
+
"input",
|
|
1838
|
+
{
|
|
1839
|
+
type: "text",
|
|
1840
|
+
name: props.name,
|
|
1841
|
+
id: props.name,
|
|
1842
|
+
value,
|
|
1843
|
+
onChange: changeHandler,
|
|
1844
|
+
required: props.attributes?.required,
|
|
1845
|
+
placeholder: props.attributes?.placeholder,
|
|
1846
|
+
disabled: props.attributes?.readOnly,
|
|
1847
|
+
className: `peer input mt-1 py-1.5 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`
|
|
1848
|
+
}
|
|
1849
|
+
) : /* @__PURE__ */ jsxs21(
|
|
1850
|
+
"select",
|
|
1851
|
+
{
|
|
1852
|
+
name: props.name,
|
|
1853
|
+
id: props.name,
|
|
1854
|
+
value,
|
|
1855
|
+
onChange: changeHandler,
|
|
1856
|
+
required: props.attributes?.required,
|
|
1857
|
+
disabled: props.attributes?.readOnly,
|
|
1858
|
+
className: `peer select my-1 py-1 block w-full rounded shadow-sm ${props.inputClasses ?? ""}`,
|
|
1859
|
+
children: [
|
|
1860
|
+
/* @__PURE__ */ jsx21("option", { value: "", children: props.attributes?.placeholder || "Select" }),
|
|
1861
|
+
list.map((item) => /* @__PURE__ */ jsx21(
|
|
1862
|
+
"option",
|
|
1863
|
+
{
|
|
1864
|
+
value: item[props.dataKeyFieldName],
|
|
1865
|
+
children: item[props.dataTextFieldName]
|
|
1866
|
+
},
|
|
1867
|
+
String(item[props.dataKeyFieldName])
|
|
1868
|
+
))
|
|
1869
|
+
]
|
|
1870
|
+
}
|
|
1871
|
+
),
|
|
1872
|
+
/* @__PURE__ */ jsx21("p", { className: "hidden group-[.validated]:peer-invalid:block mt-1 bg-error-weak text-sm", children: props.attributes?.errorMessage ?? "" })
|
|
1873
|
+
] });
|
|
1874
|
+
};
|
|
1875
|
+
var Switcher_default = Switcher;
|
|
1876
|
+
|
|
1877
|
+
// src/components/controls/edit/ReferenceInput.tsx
|
|
1878
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1879
|
+
var ReferenceInput = (props) => {
|
|
1880
|
+
return /* @__PURE__ */ jsx22(SelectWithSearchInput_default, { ...props });
|
|
1881
|
+
};
|
|
1882
|
+
var ReferenceInput_default = ReferenceInput;
|
|
1883
|
+
|
|
1884
|
+
// src/components/controls/edit/InputControlClient.tsx
|
|
1885
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1886
|
+
var InputControl = React22.forwardRef(
|
|
1887
|
+
(props, ref) => {
|
|
1888
|
+
const ControlComponents = {
|
|
1889
|
+
[InputControlType_default.lineTextInput]: LineTextInput_default,
|
|
1890
|
+
[InputControlType_default.emailInput]: EmailInput_default,
|
|
1891
|
+
[InputControlType_default.multilineTextInput]: MultilineTextInput_default,
|
|
1892
|
+
[InputControlType_default.moneyInput]: MoneyInput_default,
|
|
1893
|
+
[InputControlType_default.select]: Select_default,
|
|
1894
|
+
[InputControlType_default.percentageInput]: PercentageInput_default,
|
|
1895
|
+
[InputControlType_default.phoneInput]: PhoneInput_default,
|
|
1896
|
+
[InputControlType_default.numberInput]: NumberInput_default,
|
|
1897
|
+
[InputControlType_default.checkboxInput]: CheckboxInput_default,
|
|
1898
|
+
[InputControlType_default.otpInput]: OtpInput_default,
|
|
1899
|
+
[InputControlType_default.datetimeInput]: DateTimeInput_default,
|
|
1900
|
+
[InputControlType_default.colorInput]: ColorInput_default,
|
|
1901
|
+
[InputControlType_default.selectWithSearchInput]: SelectWithSearchInput_default,
|
|
1902
|
+
[InputControlType_default.selectWithSearchPanel]: SelectWithSearchPanel_default,
|
|
1903
|
+
[InputControlType_default.booleanSelect]: BooleanSelect_default,
|
|
1904
|
+
[InputControlType_default.timeInput]: TimeInput_default,
|
|
1905
|
+
[InputControlType_default.asset]: AssetUpload_default,
|
|
1906
|
+
[InputControlType_default.assetUpload]: AssetUpload_default,
|
|
1907
|
+
[InputControlType_default.switchInput]: SwitchInput_default,
|
|
1908
|
+
[InputControlType_default.dateInput]: DateInput_default,
|
|
1909
|
+
[InputControlType_default.radioInput]: RadioInput_default,
|
|
1910
|
+
[InputControlType_default.switcher]: Switcher_default,
|
|
1911
|
+
[InputControlType_default.referenceInput]: ReferenceInput_default
|
|
1912
|
+
};
|
|
1913
|
+
const SelectedControlComponent = ControlComponents[props.controlType];
|
|
1914
|
+
return /* @__PURE__ */ jsx23(React22.Fragment, { children: SelectedControlComponent ? /* @__PURE__ */ jsx23(SelectedControlComponent, { ...props }) : "Control not found:" + props.controlType });
|
|
1915
|
+
}
|
|
1916
|
+
);
|
|
1917
|
+
InputControl.displayName = "InputControl";
|
|
1918
|
+
var InputControlClient_default = InputControl;
|
|
1919
|
+
export {
|
|
1920
|
+
InputControlClient_default as default
|
|
1921
|
+
};
|