@kreativa/ui 0.1.4 → 0.1.5
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -157,7 +157,8 @@ function EmptyState({ icon, title, description, action }) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// src/components/Modal.tsx
|
|
160
|
-
import { useEffect } from "react";
|
|
160
|
+
import { useEffect, useState } from "react";
|
|
161
|
+
import { createPortal } from "react-dom";
|
|
161
162
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
162
163
|
var maxWidthClasses = {
|
|
163
164
|
sm: "max-w-sm",
|
|
@@ -167,6 +168,10 @@ var maxWidthClasses = {
|
|
|
167
168
|
"2xl": "max-w-2xl"
|
|
168
169
|
};
|
|
169
170
|
function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
171
|
+
const [mounted, setMounted] = useState(false);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
setMounted(true);
|
|
174
|
+
}, []);
|
|
170
175
|
useEffect(() => {
|
|
171
176
|
const handleEscape = (e) => {
|
|
172
177
|
if (e.key === "Escape") {
|
|
@@ -182,8 +187,8 @@ function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
|
182
187
|
document.body.style.overflow = "";
|
|
183
188
|
};
|
|
184
189
|
}, [isOpen, onClose]);
|
|
185
|
-
if (!isOpen) return null;
|
|
186
|
-
|
|
190
|
+
if (!isOpen || !mounted) return null;
|
|
191
|
+
const modalContent = /* @__PURE__ */ jsx9(
|
|
187
192
|
"div",
|
|
188
193
|
{
|
|
189
194
|
className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",
|
|
@@ -204,6 +209,7 @@ function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
|
204
209
|
)
|
|
205
210
|
}
|
|
206
211
|
);
|
|
212
|
+
return createPortal(modalContent, document.body);
|
|
207
213
|
}
|
|
208
214
|
|
|
209
215
|
// src/components/FormInput.tsx
|
|
@@ -286,7 +292,7 @@ function FormButtonGroup({
|
|
|
286
292
|
}
|
|
287
293
|
|
|
288
294
|
// src/components/Table.tsx
|
|
289
|
-
import { useState, useMemo, useRef, useCallback } from "react";
|
|
295
|
+
import { useState as useState2, useMemo, useRef, useCallback } from "react";
|
|
290
296
|
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
291
297
|
function Table({
|
|
292
298
|
data,
|
|
@@ -299,9 +305,9 @@ function Table({
|
|
|
299
305
|
resizable = false,
|
|
300
306
|
fixedLayout = false
|
|
301
307
|
}) {
|
|
302
|
-
const [sortKey, setSortKey] =
|
|
303
|
-
const [sortDirection, setSortDirection] =
|
|
304
|
-
const [columnWidths, setColumnWidths] =
|
|
308
|
+
const [sortKey, setSortKey] = useState2(null);
|
|
309
|
+
const [sortDirection, setSortDirection] = useState2(null);
|
|
310
|
+
const [columnWidths, setColumnWidths] = useState2({});
|
|
305
311
|
const tableRef = useRef(null);
|
|
306
312
|
const resizingRef = useRef(null);
|
|
307
313
|
const handleHeaderClick = (column) => {
|
|
@@ -462,10 +468,10 @@ function Table({
|
|
|
462
468
|
}
|
|
463
469
|
|
|
464
470
|
// src/components/DataTable.tsx
|
|
465
|
-
import { useState as
|
|
471
|
+
import { useState as useState4, useMemo as useMemo3, useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
466
472
|
|
|
467
473
|
// src/components/Select.tsx
|
|
468
|
-
import { useState as
|
|
474
|
+
import { useState as useState3, useRef as useRef2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
469
475
|
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
470
476
|
function Select({
|
|
471
477
|
options,
|
|
@@ -479,9 +485,9 @@ function Select({
|
|
|
479
485
|
disabled = false,
|
|
480
486
|
className = ""
|
|
481
487
|
}) {
|
|
482
|
-
const [isOpen, setIsOpen] =
|
|
483
|
-
const [searchTerm, setSearchTerm] =
|
|
484
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
488
|
+
const [isOpen, setIsOpen] = useState3(false);
|
|
489
|
+
const [searchTerm, setSearchTerm] = useState3("");
|
|
490
|
+
const [highlightedIndex, setHighlightedIndex] = useState3(0);
|
|
485
491
|
const containerRef = useRef2(null);
|
|
486
492
|
const inputRef = useRef2(null);
|
|
487
493
|
const filteredOptions = useMemo2(() => {
|
|
@@ -720,9 +726,9 @@ function DataTable({
|
|
|
720
726
|
resizable = false,
|
|
721
727
|
fixedLayout = false
|
|
722
728
|
}) {
|
|
723
|
-
const [filters, setFilters] =
|
|
724
|
-
const [sortKey, setSortKey] =
|
|
725
|
-
const [sortDirection, setSortDirection] =
|
|
729
|
+
const [filters, setFilters] = useState4({});
|
|
730
|
+
const [sortKey, setSortKey] = useState4(initialSortKey || null);
|
|
731
|
+
const [sortDirection, setSortDirection] = useState4(initialSortDirection);
|
|
726
732
|
const handleFilterChange = useCallback2((columnKey, value) => {
|
|
727
733
|
setFilters((prev) => {
|
|
728
734
|
const next = { ...prev };
|
|
@@ -888,7 +894,7 @@ function createFilterOptions(data, getValue, labelMap) {
|
|
|
888
894
|
}
|
|
889
895
|
|
|
890
896
|
// src/components/Tabs.tsx
|
|
891
|
-
import { useState as
|
|
897
|
+
import { useState as useState5 } from "react";
|
|
892
898
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
893
899
|
function Tabs({
|
|
894
900
|
tabs,
|
|
@@ -900,7 +906,7 @@ function Tabs({
|
|
|
900
906
|
className = ""
|
|
901
907
|
}) {
|
|
902
908
|
const isControlled = controlledActiveTab !== void 0;
|
|
903
|
-
const [internalActiveTab, setInternalActiveTab] =
|
|
909
|
+
const [internalActiveTab, setInternalActiveTab] = useState5(
|
|
904
910
|
defaultTab || tabs.find((t) => !t.disabled)?.id || tabs[0]?.id
|
|
905
911
|
);
|
|
906
912
|
const activeTab = isControlled ? controlledActiveTab : internalActiveTab;
|
|
@@ -997,7 +1003,7 @@ function Tabs({
|
|
|
997
1003
|
}
|
|
998
1004
|
|
|
999
1005
|
// src/components/DatePicker.tsx
|
|
1000
|
-
import { useState as
|
|
1006
|
+
import { useState as useState6, useRef as useRef3, useEffect as useEffect4, useMemo as useMemo4 } from "react";
|
|
1001
1007
|
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1002
1008
|
var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
1003
1009
|
var MONTHS = [
|
|
@@ -1101,11 +1107,11 @@ function DatePicker({
|
|
|
1101
1107
|
disabled = false,
|
|
1102
1108
|
className = ""
|
|
1103
1109
|
}) {
|
|
1104
|
-
const [isOpen, setIsOpen] =
|
|
1105
|
-
const [viewDate, setViewDate] =
|
|
1106
|
-
const [hoverDate, setHoverDate] =
|
|
1110
|
+
const [isOpen, setIsOpen] = useState6(false);
|
|
1111
|
+
const [viewDate, setViewDate] = useState6(/* @__PURE__ */ new Date());
|
|
1112
|
+
const [hoverDate, setHoverDate] = useState6(null);
|
|
1107
1113
|
const containerRef = useRef3(null);
|
|
1108
|
-
const [selectingEnd, setSelectingEnd] =
|
|
1114
|
+
const [selectingEnd, setSelectingEnd] = useState6(false);
|
|
1109
1115
|
useEffect4(() => {
|
|
1110
1116
|
const handleClickOutside = (e) => {
|
|
1111
1117
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -1307,7 +1313,7 @@ function DatePicker({
|
|
|
1307
1313
|
}
|
|
1308
1314
|
|
|
1309
1315
|
// src/components/Timer.tsx
|
|
1310
|
-
import { useState as
|
|
1316
|
+
import { useState as useState7, useEffect as useEffect5, useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1311
1317
|
import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1312
1318
|
function formatTime(totalSeconds) {
|
|
1313
1319
|
const hours = Math.floor(totalSeconds / 3600);
|
|
@@ -1332,8 +1338,8 @@ function Timer({
|
|
|
1332
1338
|
elapsedSeconds: controlledElapsedSeconds
|
|
1333
1339
|
}) {
|
|
1334
1340
|
const isControlled = controlledIsRunning !== void 0;
|
|
1335
|
-
const [internalIsRunning, setInternalIsRunning] =
|
|
1336
|
-
const [internalElapsedSeconds, setInternalElapsedSeconds] =
|
|
1341
|
+
const [internalIsRunning, setInternalIsRunning] = useState7(false);
|
|
1342
|
+
const [internalElapsedSeconds, setInternalElapsedSeconds] = useState7(initialSeconds);
|
|
1337
1343
|
const isRunning = isControlled ? controlledIsRunning : internalIsRunning;
|
|
1338
1344
|
const elapsedSeconds = isControlled ? controlledElapsedSeconds ?? 0 : internalElapsedSeconds;
|
|
1339
1345
|
const intervalRef = useRef4(null);
|