@esic-lab/data-core-ui 0.0.14 → 0.0.15

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.ts 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";
@@ -95,7 +97,35 @@ declare function MenuNavBar({ menus, onClick }: MenuNavBarProps): react_jsx_runt
95
97
 
96
98
  interface TopNavBarProps {
97
99
  onClickNoti: () => void;
100
+ logo?: React.ReactNode;
98
101
  }
99
- declare function TopNavBar({ onClickNoti }: TopNavBarProps): react_jsx_runtime.JSX.Element;
102
+ declare function TopNavBar({ onClickNoti, logo }: TopNavBarProps): react_jsx_runtime.JSX.Element;
100
103
 
101
- export { Checkbox, CheckboxGroup, GhostButton, Loader, MenuNavBar, type MenuNavBarProps, PrimaryButton, Radio, RadioGroup, SecondaryButton, Switch, TopNavBar };
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.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,13 +17,23 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
33
+ Calendar: () => Calendar,
23
34
  Checkbox: () => Checkbox,
24
35
  CheckboxGroup: () => CheckboxGroup,
36
+ DataTable: () => DataTable,
25
37
  GhostButton: () => GhostButton,
26
38
  Loader: () => Loader,
27
39
  MenuNavBar: () => MenuNavBar,
@@ -30,6 +42,7 @@ __export(index_exports, {
30
42
  RadioGroup: () => RadioGroup,
31
43
  SecondaryButton: () => SecondaryButton,
32
44
  Switch: () => Switch,
45
+ TextInput: () => TextInput,
33
46
  TopNavBar: () => TopNavBar
34
47
  });
35
48
  module.exports = __toCommonJS(index_exports);
@@ -208,12 +221,10 @@ function MenuNavBar({ menus, onClick }) {
208
221
  // src/NavBar/TopNavBar/TopNavBar.tsx
209
222
  var import_icons_react2 = require("@tabler/icons-react");
210
223
  var import_jsx_runtime11 = require("react/jsx-runtime");
211
- var import_meta = {};
212
- var STOLogo = new URL("../../assets/STO-logo.svg", import_meta.url).href;
213
- function TopNavBar({ onClickNoti }) {
224
+ function TopNavBar({ onClickNoti, logo }) {
214
225
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "w-full h-full flex", children: [
215
226
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-[20px] p-[10px]", children: [
216
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src: STOLogo }),
227
+ logo,
217
228
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "subtitle-1", children: "Project Management" })
218
229
  ] }),
219
230
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center ml-auto gap-[20px] p-[10px]", children: [
@@ -223,10 +234,206 @@ function TopNavBar({ onClickNoti }) {
223
234
  ] })
224
235
  ] });
225
236
  }
237
+
238
+ // src/Table/DataTable/DataTable.tsx
239
+ var import_jsx_runtime12 = require("react/jsx-runtime");
240
+ function DataTable({ columns, data }) {
241
+ const cols = Math.max(1, columns.length);
242
+ const gridClass = "grid [grid-template-columns:repeat(var(--cols),minmax(0,1fr))]";
243
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "border rounded-md", children: [
244
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${gridClass} font-semibold border-b border-gray-200`, style: { ["--cols"]: cols }, children: columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "py-[8px] px-[16px] body-4 truncate", children: col.header }, i)) }),
245
+ data.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
246
+ "div",
247
+ {
248
+ className: `${gridClass} border-b border-gray-200 items-center`,
249
+ style: { ["--cols"]: cols },
250
+ children: columns.map((col, c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "py-[8px] px-[16px] body-3 truncate", children: typeof col.accessor === "function" ? col.accessor(row) : String(row[col.accessor]) }, c))
251
+ },
252
+ i
253
+ ))
254
+ ] });
255
+ }
256
+
257
+ // src/Calendar/Calendar/Calendar.tsx
258
+ var import_react = require("react");
259
+ var import_react2 = __toESM(require("@fullcalendar/react"));
260
+ var import_daygrid = __toESM(require("@fullcalendar/daygrid"));
261
+ var import_timegrid = __toESM(require("@fullcalendar/timegrid"));
262
+ var import_interaction = __toESM(require("@fullcalendar/interaction"));
263
+ var import_en_gb = __toESM(require("@fullcalendar/core/locales/en-gb"));
264
+ var import_icons_react3 = require("@tabler/icons-react");
265
+ var import_jsx_runtime13 = require("react/jsx-runtime");
266
+ function Calendar({ events }) {
267
+ const calendarRef = (0, import_react.useRef)(null);
268
+ const [monthTitle, setMonthTitle] = (0, import_react.useState)("");
269
+ const updateTitle = () => {
270
+ const calendarApi = calendarRef.current?.getApi();
271
+ if (calendarApi) {
272
+ setMonthTitle(calendarApi.view.title);
273
+ }
274
+ };
275
+ const changeView = (viewName) => {
276
+ const calendarApi = calendarRef.current?.getApi();
277
+ calendarApi?.changeView(viewName);
278
+ };
279
+ (0, import_react.useEffect)(() => {
280
+ updateTitle();
281
+ }, []);
282
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "fc w-full h-full", children: [
283
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex mb-[8px]", children: [
284
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "headline-5", children: monthTitle }),
285
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex gap-[10px] ml-auto", children: [
286
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
287
+ "p",
288
+ {
289
+ className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
290
+ onClick: () => {
291
+ calendarRef.current.getApi().today();
292
+ updateTitle();
293
+ },
294
+ children: "\u0E27\u0E31\u0E19\u0E19\u0E35\u0E49"
295
+ }
296
+ ),
297
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
298
+ "p",
299
+ {
300
+ className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
301
+ onClick: () => {
302
+ changeView("dayGridMonth");
303
+ updateTitle();
304
+ },
305
+ children: "Month"
306
+ }
307
+ ),
308
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
309
+ "p",
310
+ {
311
+ className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
312
+ onClick: () => {
313
+ changeView("dayGridWeek");
314
+ updateTitle();
315
+ },
316
+ children: "Week"
317
+ }
318
+ ),
319
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
320
+ "p",
321
+ {
322
+ className: "w-[80px] h-[35px] border-[1px] flex justify-center items-center rounded-[2px] body-3 cursor-pointer",
323
+ onClick: () => {
324
+ changeView("timeGridDay");
325
+ updateTitle();
326
+ },
327
+ children: "Day"
328
+ }
329
+ ),
330
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
331
+ "button",
332
+ {
333
+ className: "cursor-pointer",
334
+ onClick: () => {
335
+ calendarRef.current?.getApi().prev();
336
+ updateTitle();
337
+ },
338
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react3.IconChevronLeft, {})
339
+ }
340
+ ),
341
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
342
+ "button",
343
+ {
344
+ className: "cursor-pointer",
345
+ onClick: () => {
346
+ calendarRef.current?.getApi().next();
347
+ updateTitle();
348
+ },
349
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_react3.IconChevronRight, {})
350
+ }
351
+ )
352
+ ] })
353
+ ] }),
354
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
355
+ import_react2.default,
356
+ {
357
+ ref: calendarRef,
358
+ plugins: [import_daygrid.default, import_timegrid.default, import_interaction.default],
359
+ events,
360
+ locale: import_en_gb.default,
361
+ slotLabelFormat: {
362
+ hour: "numeric",
363
+ minute: "2-digit"
364
+ },
365
+ firstDay: 0,
366
+ fixedWeekCount: false,
367
+ initialView: "dayGridMonth",
368
+ headerToolbar: false,
369
+ dayMaxEventRows: 4,
370
+ moreLinkText: "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",
371
+ editable: true,
372
+ eventDrop: (info) => {
373
+ console.log("Event \u0E02\u0E2D\u0E07\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48:", info.event.startStr);
374
+ },
375
+ eventContent: (arg) => {
376
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("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 }) });
377
+ }
378
+ }
379
+ )
380
+ ] });
381
+ }
382
+
383
+ // src/Input/TextInput/TextInput.tsx
384
+ var import_icons_react4 = require("@tabler/icons-react");
385
+ var import_react3 = require("react");
386
+ var import_jsx_runtime14 = require("react/jsx-runtime");
387
+ function TextInput({
388
+ label,
389
+ placeholder,
390
+ type = "text",
391
+ maxLength,
392
+ required,
393
+ error,
394
+ value,
395
+ onChange
396
+ }) {
397
+ const [showPassword, setShowPassword] = (0, import_react3.useState)(false);
398
+ const onShowPassword = () => {
399
+ setShowPassword(!showPassword);
400
+ };
401
+ const inputType = type === "password" ? showPassword ? "text" : "password" : "text";
402
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
403
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "body-1 mb-[8px]", children: [
404
+ label,
405
+ required && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-red-600", children: "\xA0*" })
406
+ ] }),
407
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
408
+ "div",
409
+ {
410
+ className: `border-[1px] rounded-[8px] w-full h-[40px] flex justify-center items-center ${error ? "border-red-600" : ""}`,
411
+ children: [
412
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
413
+ "input",
414
+ {
415
+ className: "w-full h-full px-[16px]",
416
+ style: { outline: "none" },
417
+ placeholder,
418
+ type: inputType,
419
+ maxLength,
420
+ value,
421
+ onChange: (e) => onChange(e.target.value)
422
+ }
423
+ ),
424
+ type === "password" && (showPassword ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons_react4.IconEye, { className: "text-gray-600 mr-[8px] cursor-pointer", onClick: onShowPassword }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons_react4.IconEyeOff, { className: "text-gray-600 mr-[8px] cursor-pointer", onClick: onShowPassword }))
425
+ ]
426
+ }
427
+ ),
428
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-red-600 body-1", children: error })
429
+ ] });
430
+ }
226
431
  // Annotate the CommonJS export names for ESM import in node:
227
432
  0 && (module.exports = {
433
+ Calendar,
228
434
  Checkbox,
229
435
  CheckboxGroup,
436
+ DataTable,
230
437
  GhostButton,
231
438
  Loader,
232
439
  MenuNavBar,
@@ -235,5 +442,6 @@ function TopNavBar({ onClickNoti }) {
235
442
  RadioGroup,
236
443
  SecondaryButton,
237
444
  Switch,
445
+ TextInput,
238
446
  TopNavBar
239
447
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esic-lab/data-core-ui",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "test": "echo \"Error: no test specified\" && exit 1",
40
40
  "storybook": "storybook dev -p 6006",
41
41
  "build-storybook": "storybook build",
42
- "build": "tsup src/index.ts --dts --dts-resolve --format esm --out-dir dist && npm run copy-assets",
42
+ "build": "tsup src/index.ts --dts --dts-resolve --format esm,cjs --out-dir dist && npm run copy-assets",
43
43
  "copy-assets": "xcopy src\\assets dist\\assets /E /I /Y"
44
44
  },
45
45
  "peerDependencies": {