@esic-lab/data-core-ui 0.0.13 → 0.0.14
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 +30 -1
- package/dist/index.mjs +197 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import { EventSourceInput } from '@fullcalendar/core';
|
|
2
4
|
|
|
3
5
|
type ColorScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
4
6
|
type BaseColor = "primary" | "gray" | "green" | "red" | "yellow" | "blue";
|
|
@@ -99,4 +101,31 @@ interface TopNavBarProps {
|
|
|
99
101
|
}
|
|
100
102
|
declare function TopNavBar({ onClickNoti, logo }: TopNavBarProps): react_jsx_runtime.JSX.Element;
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
interface Column<T> {
|
|
105
|
+
header: string;
|
|
106
|
+
accessor: keyof T | ((row: T) => React$1.ReactNode);
|
|
107
|
+
}
|
|
108
|
+
interface DataTableProps<T> {
|
|
109
|
+
columns: Column<T>[];
|
|
110
|
+
data: T[];
|
|
111
|
+
}
|
|
112
|
+
declare function DataTable<T>({ columns, data }: DataTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
113
|
+
|
|
114
|
+
interface CalendarProps {
|
|
115
|
+
events: EventSourceInput | undefined;
|
|
116
|
+
}
|
|
117
|
+
declare function Calendar({ events }: CalendarProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
|
|
119
|
+
interface TextInputProps {
|
|
120
|
+
label: string;
|
|
121
|
+
placeholder?: string;
|
|
122
|
+
type?: "text" | "password";
|
|
123
|
+
maxLength?: number;
|
|
124
|
+
required?: boolean;
|
|
125
|
+
error?: string;
|
|
126
|
+
value?: string;
|
|
127
|
+
onChange: (value: string) => void;
|
|
128
|
+
}
|
|
129
|
+
declare function TextInput({ label, placeholder, type, maxLength, required, error, value, onChange, }: TextInputProps): react_jsx_runtime.JSX.Element;
|
|
130
|
+
|
|
131
|
+
export { Calendar, Checkbox, CheckboxGroup, DataTable, GhostButton, Loader, MenuNavBar, type MenuNavBarProps, PrimaryButton, Radio, RadioGroup, SecondaryButton, Switch, TextInput, TopNavBar };
|
package/dist/index.mjs
CHANGED
|
@@ -185,9 +185,205 @@ function TopNavBar({ onClickNoti, logo }) {
|
|
|
185
185
|
] })
|
|
186
186
|
] });
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
// src/Table/DataTable/DataTable.tsx
|
|
190
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
191
|
+
function DataTable({ columns, data }) {
|
|
192
|
+
const cols = Math.max(1, columns.length);
|
|
193
|
+
const gridClass = "grid [grid-template-columns:repeat(var(--cols),minmax(0,1fr))]";
|
|
194
|
+
return /* @__PURE__ */ jsxs9("div", { className: "border rounded-md", children: [
|
|
195
|
+
/* @__PURE__ */ jsx12("div", { className: `${gridClass} font-semibold border-b border-gray-200`, style: { ["--cols"]: cols }, children: columns.map((col, i) => /* @__PURE__ */ jsx12("div", { className: "py-[8px] px-[16px] body-4 truncate", children: col.header }, i)) }),
|
|
196
|
+
data.map((row, i) => /* @__PURE__ */ jsx12(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
className: `${gridClass} border-b border-gray-200 items-center`,
|
|
200
|
+
style: { ["--cols"]: cols },
|
|
201
|
+
children: columns.map((col, c) => /* @__PURE__ */ jsx12("div", { className: "py-[8px] px-[16px] body-3 truncate", children: typeof col.accessor === "function" ? col.accessor(row) : String(row[col.accessor]) }, c))
|
|
202
|
+
},
|
|
203
|
+
i
|
|
204
|
+
))
|
|
205
|
+
] });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// src/Calendar/Calendar/Calendar.tsx
|
|
209
|
+
import { useEffect, useRef, useState } from "react";
|
|
210
|
+
import FullCalendar from "@fullcalendar/react";
|
|
211
|
+
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
212
|
+
import timeGridPlugin from "@fullcalendar/timegrid";
|
|
213
|
+
import interactionPlugin from "@fullcalendar/interaction";
|
|
214
|
+
import enLocale from "@fullcalendar/core/locales/en-gb";
|
|
215
|
+
import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
|
|
216
|
+
import { Fragment, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
217
|
+
function Calendar({ events }) {
|
|
218
|
+
const calendarRef = useRef(null);
|
|
219
|
+
const [monthTitle, setMonthTitle] = useState("");
|
|
220
|
+
const updateTitle = () => {
|
|
221
|
+
const calendarApi = calendarRef.current?.getApi();
|
|
222
|
+
if (calendarApi) {
|
|
223
|
+
setMonthTitle(calendarApi.view.title);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const changeView = (viewName) => {
|
|
227
|
+
const calendarApi = calendarRef.current?.getApi();
|
|
228
|
+
calendarApi?.changeView(viewName);
|
|
229
|
+
};
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
updateTitle();
|
|
232
|
+
}, []);
|
|
233
|
+
return /* @__PURE__ */ jsxs10("div", { className: "fc w-full h-full", children: [
|
|
234
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex mb-[8px]", children: [
|
|
235
|
+
/* @__PURE__ */ jsx13("p", { className: "headline-5", children: monthTitle }),
|
|
236
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-[10px] ml-auto", children: [
|
|
237
|
+
/* @__PURE__ */ jsx13(
|
|
238
|
+
"p",
|
|
239
|
+
{
|
|
240
|
+
className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
|
|
241
|
+
onClick: () => {
|
|
242
|
+
calendarRef.current.getApi().today();
|
|
243
|
+
updateTitle();
|
|
244
|
+
},
|
|
245
|
+
children: "\u0E27\u0E31\u0E19\u0E19\u0E35\u0E49"
|
|
246
|
+
}
|
|
247
|
+
),
|
|
248
|
+
/* @__PURE__ */ jsx13(
|
|
249
|
+
"p",
|
|
250
|
+
{
|
|
251
|
+
className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
|
|
252
|
+
onClick: () => {
|
|
253
|
+
changeView("dayGridMonth");
|
|
254
|
+
updateTitle();
|
|
255
|
+
},
|
|
256
|
+
children: "Month"
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ jsx13(
|
|
260
|
+
"p",
|
|
261
|
+
{
|
|
262
|
+
className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
|
|
263
|
+
onClick: () => {
|
|
264
|
+
changeView("dayGridWeek");
|
|
265
|
+
updateTitle();
|
|
266
|
+
},
|
|
267
|
+
children: "Week"
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ jsx13(
|
|
271
|
+
"p",
|
|
272
|
+
{
|
|
273
|
+
className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
|
|
274
|
+
onClick: () => {
|
|
275
|
+
changeView("timeGridDay");
|
|
276
|
+
updateTitle();
|
|
277
|
+
},
|
|
278
|
+
children: "Day"
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
/* @__PURE__ */ jsx13(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
className: "cursor-pointer",
|
|
285
|
+
onClick: () => {
|
|
286
|
+
calendarRef.current?.getApi().prev();
|
|
287
|
+
updateTitle();
|
|
288
|
+
},
|
|
289
|
+
children: /* @__PURE__ */ jsx13(IconChevronLeft, {})
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
/* @__PURE__ */ jsx13(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
className: "cursor-pointer",
|
|
296
|
+
onClick: () => {
|
|
297
|
+
calendarRef.current?.getApi().next();
|
|
298
|
+
updateTitle();
|
|
299
|
+
},
|
|
300
|
+
children: /* @__PURE__ */ jsx13(IconChevronRight, {})
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ jsx13(
|
|
306
|
+
FullCalendar,
|
|
307
|
+
{
|
|
308
|
+
ref: calendarRef,
|
|
309
|
+
plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
|
|
310
|
+
events,
|
|
311
|
+
locale: enLocale,
|
|
312
|
+
slotLabelFormat: {
|
|
313
|
+
hour: "numeric",
|
|
314
|
+
minute: "2-digit"
|
|
315
|
+
},
|
|
316
|
+
firstDay: 0,
|
|
317
|
+
fixedWeekCount: false,
|
|
318
|
+
initialView: "dayGridMonth",
|
|
319
|
+
headerToolbar: false,
|
|
320
|
+
dayMaxEventRows: 4,
|
|
321
|
+
moreLinkText: "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",
|
|
322
|
+
editable: true,
|
|
323
|
+
eventDrop: (info) => {
|
|
324
|
+
console.log("Event \u0E02\u0E2D\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48:", info.event.startStr);
|
|
325
|
+
},
|
|
326
|
+
eventContent: (arg) => {
|
|
327
|
+
return /* @__PURE__ */ jsx13(Fragment, { children: /* @__PURE__ */ jsx13("div", { className: "relative top-4 flex items-center h-[28px] p-[4px] border-green-500 border-l-[10px] bg-red-400 rounded text-left text-white caption-1", children: arg.event.title }) });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
] });
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/Input/TextInput/TextInput.tsx
|
|
335
|
+
import { IconEye, IconEyeOff } from "@tabler/icons-react";
|
|
336
|
+
import { useState as useState2 } from "react";
|
|
337
|
+
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
338
|
+
function TextInput({
|
|
339
|
+
label,
|
|
340
|
+
placeholder,
|
|
341
|
+
type = "text",
|
|
342
|
+
maxLength,
|
|
343
|
+
required,
|
|
344
|
+
error,
|
|
345
|
+
value,
|
|
346
|
+
onChange
|
|
347
|
+
}) {
|
|
348
|
+
const [showPassword, setShowPassword] = useState2(false);
|
|
349
|
+
const onShowPassword = () => {
|
|
350
|
+
setShowPassword(!showPassword);
|
|
351
|
+
};
|
|
352
|
+
const inputType = type === "password" ? showPassword ? "text" : "password" : "text";
|
|
353
|
+
return /* @__PURE__ */ jsxs11("div", { children: [
|
|
354
|
+
/* @__PURE__ */ jsxs11("p", { className: "body-1 mb-[8px]", children: [
|
|
355
|
+
label,
|
|
356
|
+
required && /* @__PURE__ */ jsx14("span", { className: "text-red-600", children: "\xA0*" })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ jsxs11(
|
|
359
|
+
"div",
|
|
360
|
+
{
|
|
361
|
+
className: `border-[1px] rounded-[8px] w-full h-[40px] flex justify-center items-center ${error ? "border-red-600" : ""}`,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ jsx14(
|
|
364
|
+
"input",
|
|
365
|
+
{
|
|
366
|
+
className: "w-full h-full px-[16px]",
|
|
367
|
+
style: { outline: "none" },
|
|
368
|
+
placeholder,
|
|
369
|
+
type: inputType,
|
|
370
|
+
maxLength,
|
|
371
|
+
value,
|
|
372
|
+
onChange: (e) => onChange(e.target.value)
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
type === "password" && (showPassword ? /* @__PURE__ */ jsx14(IconEye, { className: "text-gray-600 mr-[8px] cursor-pointer", onClick: onShowPassword }) : /* @__PURE__ */ jsx14(IconEyeOff, { className: "text-gray-600 mr-[8px] cursor-pointer", onClick: onShowPassword }))
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
error && /* @__PURE__ */ jsx14("p", { className: "text-red-600 body-1", children: error })
|
|
380
|
+
] });
|
|
381
|
+
}
|
|
188
382
|
export {
|
|
383
|
+
Calendar,
|
|
189
384
|
Checkbox,
|
|
190
385
|
CheckboxGroup,
|
|
386
|
+
DataTable,
|
|
191
387
|
GhostButton,
|
|
192
388
|
Loader,
|
|
193
389
|
MenuNavBar,
|
|
@@ -196,5 +392,6 @@ export {
|
|
|
196
392
|
RadioGroup,
|
|
197
393
|
SecondaryButton,
|
|
198
394
|
Switch,
|
|
395
|
+
TextInput,
|
|
199
396
|
TopNavBar
|
|
200
397
|
};
|