ml-ui-lib 1.0.4 → 1.0.6

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
@@ -5,8 +5,6 @@ export { Modal } from "./components/Modal/Modal";
5
5
  export type { ModalProps } from "./components/Modal/Modal";
6
6
  export { Input } from "./components/Input/Input";
7
7
  export type { InputProps } from "./components/Input/Input";
8
- export { Alert } from "./components/Alert/Alert";
9
- export type { AlertProps, AlertVariant } from "./components/Alert/Alert";
10
8
  export { PhoneInput } from "./components/PhoneInput/PhoneInput";
11
9
  export type { PhoneInputProps } from "./components/PhoneInput/PhoneInput";
12
10
  export { Dropdown } from "./components/Dropdown/Dropdown";
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@ import "./common.css";
2
2
  export { Button } from "./components/Button/Button";
3
3
  export { Modal } from "./components/Modal/Modal";
4
4
  export { Input } from "./components/Input/Input";
5
- export { Alert } from "./components/Alert/Alert";
6
5
  export { PhoneInput } from "./components/PhoneInput/PhoneInput";
7
6
  export { Dropdown } from "./components/Dropdown/Dropdown";
8
7
  export { DatePicker2 } from "./components/DatePicker2/DatePicker2";
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "ml-ui-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "author": "Kenneth James B. Simbulan",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
- "dist",
10
- "src",
11
- "common.css",
12
- "components/**/*.css"
9
+ "dist"
13
10
  ],
14
11
  "scripts": {
15
- "build": "tsc",
12
+ "build": "tsc && npm run copy-css",
13
+ "copy-css": "npm exec copyfiles -- 'src/**/*.css' dist",
16
14
  "watch": "tsc --watch",
17
15
  "dev": "npm run build -- --watch"
18
16
  },
@@ -23,6 +21,7 @@
23
21
  "devDependencies": {
24
22
  "@types/react": "^18.0.0",
25
23
  "@types/react-dom": "^18.0.0",
24
+ "copyfiles": "^2.4.1",
26
25
  "typescript": "^5.9.3"
27
26
  }
28
27
  }
package/src/common.css DELETED
@@ -1,27 +0,0 @@
1
- @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
2
-
3
- /* Common global styles for all ml-ui-lib components */
4
- :root {
5
- --ml-font-family: 'Poppins', sans-serif;
6
- --ml-color-primary: #0070f3;
7
- --ml-color-secondary: #eaeaea;
8
- --ml-radius: 6px;
9
- }
10
-
11
- * {
12
- box-sizing: border-box;
13
- }
14
-
15
- body {
16
- font-family: var(--ml-font-family);
17
- margin: 0;
18
- padding: 0;
19
- background-color: #fff;
20
- color: #111;
21
- }
22
-
23
- button {
24
- font-family: inherit;
25
- border-radius: var(--ml-radius);
26
- transition: all 0.2s ease;
27
- }
@@ -1,56 +0,0 @@
1
- .alert {
2
- display: flex;
3
- align-items: flex-start;
4
- gap: 12px;
5
- border-radius: 8px;
6
- padding: 12px 16px;
7
- font-family: 'Poppins', sans-serif;
8
- font-size: 15px;
9
- line-height: 1.4;
10
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
11
- }
12
-
13
- .alert-icon {
14
- width: 24px;
15
- height: 24px;
16
- flex-shrink: 0;
17
- }
18
-
19
- .alert-content {
20
- flex: 1;
21
- }
22
-
23
- .alert-title {
24
- display: block;
25
- font-weight: 600;
26
- margin-bottom: 2px;
27
- }
28
-
29
- .alert-message {
30
- margin: 0;
31
- }
32
-
33
- /* Variants */
34
- .alert-info {
35
- background-color: #e6f4ff;
36
- border: 1px solid #91caff;
37
- color: #0958d9;
38
- }
39
-
40
- .alert-error {
41
- background-color: #fff1f0;
42
- border: 1px solid #ffa39e;
43
- color: #cf1322;
44
- }
45
-
46
- .alert-warning {
47
- background-color: #fffbe6;
48
- border: 1px solid #ffe58f;
49
- color: #ad8b00;
50
- }
51
-
52
- .alert-success {
53
- background-color: #f6ffed;
54
- border: 1px solid #b7eb8f;
55
- color: #389e0d;
56
- }
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import "./Alert.css";
3
-
4
- export type AlertVariant = "info" | "error" | "warning" | "success";
5
-
6
- export interface AlertProps {
7
- variant?: AlertVariant;
8
- title?: string;
9
- message: string;
10
- }
11
-
12
- export const Alert: React.FC<AlertProps> = ({
13
- variant = "info",
14
- title,
15
- message,
16
- }) => {
17
- return (
18
- <div className={`alert alert-${variant}`}>
19
- <div className="alert-content">
20
- {title && <strong className="alert-title">{title}</strong>}
21
- <p className="alert-message">{message}</p>
22
- </div>
23
- </div>
24
- );
25
- };
26
-
27
- export default Alert;
@@ -1,24 +0,0 @@
1
- .btn {
2
- border: none;
3
- border-radius: 6px;
4
- padding: 10px 16px;
5
- cursor: pointer;
6
- font-size: 16px;
7
- /* margin: 10px; */
8
- }
9
-
10
- .btn-default {
11
- background: #ffffff;
12
- color: #5d5d5d;
13
- border: solid 0.5px #5d5d5d;
14
- }
15
-
16
- .btn-red {
17
- background: #ff0000;
18
- color: #ffffff;
19
- }
20
-
21
- .btn-black {
22
- background: #333333;
23
- color: #ffffff;
24
- }
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import "./Button.css";
3
-
4
- export interface ButtonProps {
5
- label: string;
6
- variant?: "default" | "red" | "black";
7
- onClick?: () => void;
8
- }
9
-
10
- export const Button: React.FC<ButtonProps> = ({
11
- label,
12
- variant = "default",
13
- onClick,
14
- }) => {
15
- return (
16
- <button className={`btn btn-${variant}`} onClick={onClick}>
17
- {label}
18
- </button>
19
- );
20
- };
@@ -1,103 +0,0 @@
1
- .datepicker-wrapper {
2
- position: relative;
3
- font-family: "Poppins", sans-serif;
4
- width: 250px;
5
- }
6
-
7
- .datepicker-input-wrapper {
8
- display: flex;
9
- align-items: center;
10
- position: relative;
11
- cursor: pointer;
12
- }
13
-
14
- .datepicker-input {
15
- width: 100%;
16
- padding: 10px 36px 10px 12px;
17
- border: 1px solid #ddd;
18
- border-radius: 6px;
19
- font-size: 15px;
20
- cursor: pointer;
21
- }
22
-
23
- .datepicker-icon {
24
- position: absolute;
25
- right: 10px;
26
- pointer-events: none;
27
- color: #666;
28
- }
29
-
30
- .datepicker-calendar {
31
- position: absolute;
32
- top: 45px;
33
- width: 100%;
34
- background: #fff;
35
- border: 1px solid #ddd;
36
- border-radius: 6px;
37
- box-shadow: 0 4px 12px rgba(0,0,0,0.1);
38
- z-index: 10;
39
- padding: 8px;
40
- }
41
-
42
- .datepicker-header {
43
- display: flex;
44
- justify-content: space-between;
45
- align-items: center;
46
- margin-bottom: 8px;
47
- font-weight: 500;
48
- }
49
-
50
- .datepicker-weekdays {
51
- display: grid;
52
- grid-template-columns: repeat(7, 1fr);
53
- text-align: center;
54
- font-weight: 500;
55
- margin-bottom: 4px;
56
- }
57
-
58
- .datepicker-weekday {
59
- font-size: 12px;
60
- }
61
-
62
- .datepicker-days-grid {
63
- display: grid;
64
- grid-template-columns: repeat(7, 1fr);
65
- gap: 4px;
66
- }
67
-
68
- .datepicker-day {
69
- text-align: center;
70
- padding: 6px 0;
71
- cursor: pointer;
72
- border-radius: 4px;
73
- }
74
-
75
- .datepicker-day:hover {
76
- background: #f0f0f0;
77
- }
78
-
79
- .datepicker-day.selected {
80
- background: #ff4d4d;
81
- color: #fff;
82
- font-weight: 500;
83
- }
84
-
85
- .datepicker-day.today {
86
- border: 1px solid #ff4d4d;
87
- border-radius: 50%;
88
- }
89
-
90
- .datepicker-day.empty {
91
- pointer-events: none;
92
- }
93
-
94
- .has-error .datepicker-input {
95
- border-color: #ff4d4d;
96
- }
97
-
98
- .datepicker-error {
99
- color: #ff4d4d;
100
- font-size: 13px;
101
- margin-top: 4px;
102
- display: block;
103
- }
@@ -1,158 +0,0 @@
1
- "use client";
2
- import React, { useState, useRef, useEffect } from "react";
3
- import "./DatePicker.css";
4
-
5
- export interface DatePickerValue {
6
- day: number;
7
- month: number;
8
- year: number;
9
- }
10
-
11
- export interface DatePickerProps {
12
- value?: DatePickerValue;
13
- onChange?: (value: DatePickerValue) => void;
14
- placeholder?: string;
15
- className?: string;
16
- error?: string;
17
- }
18
-
19
- export const DatePicker: React.FC<DatePickerProps> = ({
20
- value,
21
- onChange,
22
- placeholder = "Select date",
23
- className = "",
24
- error,
25
- }) => {
26
- const [open, setOpen] = useState(false);
27
- const [selectedDate, setSelectedDate] = useState<DatePickerValue | null>(value || null);
28
-
29
- const today = new Date();
30
- const [currentMonth, setCurrentMonth] = useState<number>(
31
- value?.month ? value.month - 1 : today.getMonth()
32
- );
33
- const [currentYear, setCurrentYear] = useState<number>(value?.year || today.getFullYear());
34
-
35
- const wrapperRef = useRef<HTMLDivElement>(null);
36
-
37
- useEffect(() => {
38
- const handleClickOutside = (e: MouseEvent) => {
39
- if (wrapperRef.current && !wrapperRef.current.contains(e.target as Node)) {
40
- setOpen(false);
41
- }
42
- };
43
- document.addEventListener("mousedown", handleClickOutside);
44
- return () => document.removeEventListener("mousedown", handleClickOutside);
45
- }, []);
46
-
47
- const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
48
- const firstDayOfMonth = new Date(currentYear, currentMonth, 1).getDay();
49
- const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
50
- const weekDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
51
-
52
- const handleDayClick = (day: number) => {
53
- const newDate = { day, month: currentMonth + 1, year: currentYear };
54
- setSelectedDate(newDate);
55
- onChange?.(newDate);
56
- setOpen(false);
57
- };
58
-
59
- return (
60
- <div className={`datepicker-wrapper ${className} ${error ? "has-error" : ""}`} ref={wrapperRef}>
61
- <div className="datepicker-input-wrapper" onClick={() => setOpen(!open)}>
62
- <input
63
- readOnly
64
- value={
65
- selectedDate
66
- ? `${String(selectedDate.day).padStart(2, "0")}/${String(selectedDate.month).padStart(2, "0")}/${selectedDate.year}`
67
- : ""
68
- }
69
- placeholder={placeholder}
70
- className="datepicker-input"
71
- />
72
- {/* Inline line-style calendar icon */}
73
- <svg
74
- className="datepicker-icon"
75
- xmlns="http://www.w3.org/2000/svg"
76
- viewBox="0 0 24 24"
77
- fill="none"
78
- stroke="currentColor"
79
- strokeWidth="2"
80
- strokeLinecap="round"
81
- strokeLinejoin="round"
82
- width="18"
83
- height="18"
84
- >
85
- <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
86
- <line x1="16" y1="2" x2="16" y2="6"></line>
87
- <line x1="8" y1="2" x2="8" y2="6"></line>
88
- <line x1="3" y1="10" x2="21" y2="10"></line>
89
- </svg>
90
- </div>
91
-
92
- {open && (
93
- <div className="datepicker-calendar">
94
- {/* Header */}
95
- <div className="datepicker-header">
96
- <button
97
- onClick={() =>
98
- setCurrentMonth((prev) => (prev === 0 ? 11 : prev - 1))
99
- }
100
- >
101
-
102
- </button>
103
- <span>
104
- {monthNames[currentMonth]} {currentYear}
105
- </span>
106
- <button
107
- onClick={() =>
108
- setCurrentMonth((prev) => (prev === 11 ? 0 : prev + 1))
109
- }
110
- >
111
-
112
- </button>
113
- </div>
114
-
115
- {/* Weekday Names */}
116
- <div className="datepicker-weekdays">
117
- {weekDays.map((d) => (
118
- <div key={d} className="datepicker-weekday">
119
- {d}
120
- </div>
121
- ))}
122
- </div>
123
-
124
- {/* Days */}
125
- <div className="datepicker-days-grid">
126
- {Array.from({ length: firstDayOfMonth }).map((_, i) => (
127
- <div key={`empty-${i}`} className="datepicker-day empty" />
128
- ))}
129
- {Array.from({ length: daysInMonth }).map((_, i) => {
130
- const day = i + 1;
131
- const isSelected =
132
- selectedDate?.day === day &&
133
- selectedDate?.month === currentMonth + 1 &&
134
- selectedDate?.year === currentYear;
135
- const isToday =
136
- today.getDate() === day &&
137
- today.getMonth() === currentMonth &&
138
- today.getFullYear() === currentYear;
139
- return (
140
- <div
141
- key={day}
142
- className={`datepicker-day ${isSelected ? "selected" : ""} ${isToday ? "today" : ""}`}
143
- onClick={() => handleDayClick(day)}
144
- >
145
- {day}
146
- </div>
147
- );
148
- })}
149
- </div>
150
- </div>
151
- )}
152
-
153
- {error && <span className="datepicker-error">{error}</span>}
154
- </div>
155
- );
156
- };
157
-
158
- export default DatePicker;
@@ -1,113 +0,0 @@
1
- .date-picker-wrapper {
2
- display: flex;
3
- gap: 8px;
4
- font-family: "Poppins", sans-serif;
5
- flex-wrap: wrap;
6
- }
7
-
8
- .full-width {
9
- flex: 1 1 100px;
10
- /* position: relative; */
11
- }
12
-
13
- .date-picker-dropdown {
14
- cursor: pointer;
15
- background: #fff;
16
- border: 1px solid #ddd;
17
- border-radius: 6px;
18
- align-items: center;
19
- padding: 0.4rem 0.6rem;
20
- display: flex;
21
- justify-content: space-between;
22
- width: 100%;
23
- }
24
-
25
- .date-picker-dropdown-carret {
26
- font-size: 12px;
27
- color: #666;
28
- }
29
-
30
- .date-picker-grid-wrapper {
31
- width: 30%;
32
- position: absolute;
33
- /* left: 0px; */
34
- /* top: 40px;
35
- background: #fff;
36
- border: 1px solid #ddd;
37
- border-radius: 6px;
38
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
39
- z-index: 10; */
40
- }
41
-
42
- .date-picker-header {
43
- display: flex;
44
- justify-content: space-between;
45
- flex-direction: row;
46
- position: absolute;
47
- z-index: 100;
48
- left: 0px;
49
- padding: 10px;
50
- width: 100%;
51
- background-color: #f5f5f5;
52
- margin-top: 5px;
53
- border-top-left-radius: 8px;
54
- border-top-right-radius: 8px;
55
- }
56
-
57
- .date-picker-header button {
58
- background-color: #ffffff;
59
- color: #5f5f5f;
60
- border-radius: 15px;
61
- border: 0.5px solid #5f5f5f;
62
- }
63
-
64
- .date-picker-grid {
65
- display: grid;
66
- grid-template-columns: repeat(3, 1fr);
67
- gap: 8px;
68
- padding: 10px;
69
- background-color: white;
70
- border-radius: 8px;
71
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
72
- max-height: 250px;
73
- overflow-y: auto;
74
- position: absolute;
75
- z-index: 30;
76
- width: 100%;
77
- margin-top: 45px;
78
- left: 0px;
79
- }
80
-
81
- .date-picker-dropdown-option {
82
- text-align: center;
83
- padding: 10px;
84
- border-radius: 6px;
85
- cursor: pointer;
86
- /* font-size: 14px;
87
- font-weight: 500; */
88
- transition: background-color 0.2s ease, color 0.2s ease;
89
- user-select: none;
90
- }
91
-
92
- .date-picker-dropdown-option:hover {
93
- background-color: #f0f0f0;
94
- }
95
-
96
- .date-picker-dropdown-option.selected {
97
- background-color: #333;
98
- color: #fff;
99
- }
100
-
101
- .date-picker-empty {
102
- gap: 8px;
103
- padding: 10px;
104
- background-color: white;
105
- border-radius: 8px;
106
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
107
- overflow-y: auto;
108
- position: absolute;
109
- z-index: 30;
110
- /* width: 100%; */
111
- margin-top: 10px;
112
- left: 0px;
113
- }