pixelplay 1.0.13 → 1.2.0
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/CHANGELOG.md +93 -61
- package/README.md +91 -91
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -21
- package/dist/index.mjs.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +75 -80
package/dist/index.mjs
CHANGED
|
@@ -1794,7 +1794,7 @@ function DropdownMenuItem({
|
|
|
1794
1794
|
}
|
|
1795
1795
|
|
|
1796
1796
|
// ../../app/ui-kit/pixelplay-ui/shared/ui/select/Select.tsx
|
|
1797
|
-
import { useState, useRef, useEffect } from "react";
|
|
1797
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
1798
1798
|
import Image2 from "next/image";
|
|
1799
1799
|
import { Check as Check2, ChevronDown, ChevronUp, Search } from "react-feather";
|
|
1800
1800
|
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
@@ -1886,6 +1886,7 @@ function Select({
|
|
|
1886
1886
|
}) {
|
|
1887
1887
|
const [open, setOpen] = useState(false);
|
|
1888
1888
|
const [search, setSearch] = useState("");
|
|
1889
|
+
const [openAbove, setOpenAbove] = useState(false);
|
|
1889
1890
|
const containerRef = useRef(null);
|
|
1890
1891
|
useEffect(() => {
|
|
1891
1892
|
function onOutsideClick(e) {
|
|
@@ -1897,6 +1898,21 @@ function Select({
|
|
|
1897
1898
|
document.addEventListener("mousedown", onOutsideClick);
|
|
1898
1899
|
return () => document.removeEventListener("mousedown", onOutsideClick);
|
|
1899
1900
|
}, []);
|
|
1901
|
+
const computeOpenAbove = useCallback(() => {
|
|
1902
|
+
if (!containerRef.current) return false;
|
|
1903
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1904
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
1905
|
+
const panelHeight = 280;
|
|
1906
|
+
return spaceBelow < panelHeight && rect.top > spaceBelow;
|
|
1907
|
+
}, []);
|
|
1908
|
+
const toggleOpen = useCallback(() => {
|
|
1909
|
+
setOpen((prev) => {
|
|
1910
|
+
if (!prev) {
|
|
1911
|
+
setOpenAbove(computeOpenAbove());
|
|
1912
|
+
}
|
|
1913
|
+
return !prev;
|
|
1914
|
+
});
|
|
1915
|
+
}, [computeOpenAbove]);
|
|
1900
1916
|
const selectedOption = options.find((o) => o.value === value);
|
|
1901
1917
|
const filtered = isSearchable ? options.filter(
|
|
1902
1918
|
(o) => o.label.toLowerCase().includes(search.toLowerCase())
|
|
@@ -1916,7 +1932,7 @@ function Select({
|
|
|
1916
1932
|
{
|
|
1917
1933
|
type: "button",
|
|
1918
1934
|
disabled: isDisabled,
|
|
1919
|
-
onClick: () => !isDisabled &&
|
|
1935
|
+
onClick: () => !isDisabled && toggleOpen(),
|
|
1920
1936
|
className: cn(
|
|
1921
1937
|
"flex w-full items-center rounded-lg border transition-all",
|
|
1922
1938
|
"bg-[var(--surface-container-lowest)] border-[var(--outline)]",
|
|
@@ -1952,7 +1968,8 @@ function Select({
|
|
|
1952
1968
|
"div",
|
|
1953
1969
|
{
|
|
1954
1970
|
className: cn(
|
|
1955
|
-
"absolute left-0
|
|
1971
|
+
"absolute left-0 z-50 w-full overflow-hidden rounded-lg",
|
|
1972
|
+
openAbove ? "bottom-full mb-1" : "top-full mt-1",
|
|
1956
1973
|
"bg-[var(--surface-container-lowest)]",
|
|
1957
1974
|
"shadow-[0px_4px_6px_-2px_rgba(10,13,18,0.05),0px_12px_16px_-4px_rgba(10,13,18,0.10)]",
|
|
1958
1975
|
"outline outline-1 outline-offset-[-1px] outline-[var(--outline)]"
|
|
@@ -3360,7 +3377,7 @@ function TooltipTrigger({
|
|
|
3360
3377
|
import {
|
|
3361
3378
|
useEffect as useEffect2,
|
|
3362
3379
|
useRef as useRef3,
|
|
3363
|
-
useCallback,
|
|
3380
|
+
useCallback as useCallback2,
|
|
3364
3381
|
useId as useId4,
|
|
3365
3382
|
useSyncExternalStore
|
|
3366
3383
|
} from "react";
|
|
@@ -3562,7 +3579,7 @@ function Modal({
|
|
|
3562
3579
|
const titleId = useId4();
|
|
3563
3580
|
const descId = useId4();
|
|
3564
3581
|
const panelRef = useRef3(null);
|
|
3565
|
-
const handleKeyDown =
|
|
3582
|
+
const handleKeyDown = useCallback2(
|
|
3566
3583
|
(e) => {
|
|
3567
3584
|
if (e.key === "Escape") onClose == null ? void 0 : onClose();
|
|
3568
3585
|
},
|
|
@@ -6303,7 +6320,7 @@ function Alert({
|
|
|
6303
6320
|
// ../../app/ui-kit/pixelplay-ui/shared/ui/toast/Toast.tsx
|
|
6304
6321
|
import {
|
|
6305
6322
|
createContext,
|
|
6306
|
-
useCallback as
|
|
6323
|
+
useCallback as useCallback3,
|
|
6307
6324
|
useContext,
|
|
6308
6325
|
useEffect as useEffect4,
|
|
6309
6326
|
useState as useState6
|
|
@@ -6386,7 +6403,7 @@ function ToastProvider({ children }) {
|
|
|
6386
6403
|
const [toasts, setToasts] = useState6([]);
|
|
6387
6404
|
const [mounted, setMounted] = useState6(false);
|
|
6388
6405
|
useEffect4(() => setMounted(true), []);
|
|
6389
|
-
const removeToast =
|
|
6406
|
+
const removeToast = useCallback3((id) => {
|
|
6390
6407
|
setToasts(
|
|
6391
6408
|
(prev) => prev.map((t) => t.id === id ? __spreadProps(__spreadValues({}, t), { visible: false }) : t)
|
|
6392
6409
|
);
|
|
@@ -6394,7 +6411,7 @@ function ToastProvider({ children }) {
|
|
|
6394
6411
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
6395
6412
|
}, 300);
|
|
6396
6413
|
}, []);
|
|
6397
|
-
const addToast =
|
|
6414
|
+
const addToast = useCallback3(
|
|
6398
6415
|
(toast) => {
|
|
6399
6416
|
var _a;
|
|
6400
6417
|
const id = String(++_idCounter);
|
|
@@ -6437,7 +6454,7 @@ function ToastProvider({ children }) {
|
|
|
6437
6454
|
}
|
|
6438
6455
|
|
|
6439
6456
|
// ../../app/ui-kit/pixelplay-ui/shared/ui/date-picker/DatePicker.tsx
|
|
6440
|
-
import { useCallback as
|
|
6457
|
+
import { useCallback as useCallback4, useEffect as useEffect5, useRef as useRef5, useState as useState7 } from "react";
|
|
6441
6458
|
import { Calendar, ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight3 } from "react-feather";
|
|
6442
6459
|
import { jsx as jsx41, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
6443
6460
|
var MONTHS = [
|
|
@@ -6785,7 +6802,7 @@ function DatePicker({
|
|
|
6785
6802
|
const [pending, setPending] = useState7(current != null ? current : null);
|
|
6786
6803
|
const [open, setOpen] = useState7(false);
|
|
6787
6804
|
const wrapRef = useRef5(null);
|
|
6788
|
-
const handleClose =
|
|
6805
|
+
const handleClose = useCallback4(() => setOpen(false), []);
|
|
6789
6806
|
useClickOutside(wrapRef, handleClose, open && !inline);
|
|
6790
6807
|
useEffect5(() => {
|
|
6791
6808
|
if (controlled) {
|
|
@@ -6895,7 +6912,7 @@ function DateTimePicker({
|
|
|
6895
6912
|
const slots = timeSlots != null ? timeSlots : DEFAULT_SLOTS;
|
|
6896
6913
|
const wrapRef = useRef5(null);
|
|
6897
6914
|
const slotListRef = useRef5(null);
|
|
6898
|
-
const handleClose =
|
|
6915
|
+
const handleClose = useCallback4(() => setOpen(false), []);
|
|
6899
6916
|
useClickOutside(wrapRef, handleClose, open && !inline);
|
|
6900
6917
|
useEffect5(() => {
|
|
6901
6918
|
if (controlled) {
|
|
@@ -7058,7 +7075,7 @@ function DateRangePicker({
|
|
|
7058
7075
|
const [activePreset, setActivePreset] = useState7(null);
|
|
7059
7076
|
const [open, setOpen] = useState7(false);
|
|
7060
7077
|
const wrapRef = useRef5(null);
|
|
7061
|
-
const handleClose =
|
|
7078
|
+
const handleClose = useCallback4(() => setOpen(false), []);
|
|
7062
7079
|
useClickOutside(wrapRef, handleClose, open && !inline);
|
|
7063
7080
|
useEffect5(() => {
|
|
7064
7081
|
if (controlled) {
|
|
@@ -7191,7 +7208,7 @@ function DateRangePicker({
|
|
|
7191
7208
|
}
|
|
7192
7209
|
|
|
7193
7210
|
// ../../app/ui-kit/pixelplay-ui/shared/ui/calendar/Calendar.tsx
|
|
7194
|
-
import React23, { useState as useState8, useCallback as
|
|
7211
|
+
import React23, { useState as useState8, useCallback as useCallback5, useMemo } from "react";
|
|
7195
7212
|
import {
|
|
7196
7213
|
Plus,
|
|
7197
7214
|
ChevronLeft as ChevronLeft4,
|
|
@@ -7423,7 +7440,7 @@ function MonthView({
|
|
|
7423
7440
|
onEventClick
|
|
7424
7441
|
}) {
|
|
7425
7442
|
const cells = useMemo(() => getMonthCells(year, month), [year, month]);
|
|
7426
|
-
const eventsForDay =
|
|
7443
|
+
const eventsForDay = useCallback5(
|
|
7427
7444
|
(date) => events.filter((e) => isSameDay2(e.date, date)).sort((a, b) => {
|
|
7428
7445
|
return timeToMinutes(a.startTime) - timeToMinutes(b.startTime);
|
|
7429
7446
|
}),
|
|
@@ -7588,7 +7605,7 @@ function WeekView({
|
|
|
7588
7605
|
() => days.findIndex((d) => isToday2(d)),
|
|
7589
7606
|
[days]
|
|
7590
7607
|
);
|
|
7591
|
-
const eventsForDay =
|
|
7608
|
+
const eventsForDay = useCallback5(
|
|
7592
7609
|
(date) => events.filter((e) => isSameDay2(e.date, date)).sort(
|
|
7593
7610
|
(a, b) => timeToMinutes(a.startTime) - timeToMinutes(b.startTime)
|
|
7594
7611
|
),
|
|
@@ -7811,7 +7828,7 @@ function DayView({
|
|
|
7811
7828
|
const now = /* @__PURE__ */ new Date();
|
|
7812
7829
|
return now.getHours() * 60 + now.getMinutes();
|
|
7813
7830
|
}, [date]);
|
|
7814
|
-
const hasEvents =
|
|
7831
|
+
const hasEvents = useCallback5(
|
|
7815
7832
|
(d) => events.some((e) => isSameDay2(e.date, d)),
|
|
7816
7833
|
[events]
|
|
7817
7834
|
);
|
|
@@ -8210,35 +8227,35 @@ function Calendar2({
|
|
|
8210
8227
|
const view = controlledView != null ? controlledView : internalView;
|
|
8211
8228
|
const [internalDate, setInternalDate] = useState8(defaultDate != null ? defaultDate : today);
|
|
8212
8229
|
const date = controlledDate != null ? controlledDate : internalDate;
|
|
8213
|
-
const handleViewChange =
|
|
8230
|
+
const handleViewChange = useCallback5(
|
|
8214
8231
|
(v) => {
|
|
8215
8232
|
setInternalView(v);
|
|
8216
8233
|
onViewChange == null ? void 0 : onViewChange(v);
|
|
8217
8234
|
},
|
|
8218
8235
|
[onViewChange]
|
|
8219
8236
|
);
|
|
8220
|
-
const handleDateChange =
|
|
8237
|
+
const handleDateChange = useCallback5(
|
|
8221
8238
|
(d) => {
|
|
8222
8239
|
setInternalDate(d);
|
|
8223
8240
|
onDateChange == null ? void 0 : onDateChange(d);
|
|
8224
8241
|
},
|
|
8225
8242
|
[onDateChange]
|
|
8226
8243
|
);
|
|
8227
|
-
const handlePrev =
|
|
8244
|
+
const handlePrev = useCallback5(() => {
|
|
8228
8245
|
const d = new Date(date);
|
|
8229
8246
|
if (view === "month") d.setMonth(d.getMonth() - 1);
|
|
8230
8247
|
else if (view === "week") d.setDate(d.getDate() - 7);
|
|
8231
8248
|
else d.setDate(d.getDate() - 1);
|
|
8232
8249
|
handleDateChange(d);
|
|
8233
8250
|
}, [date, view, handleDateChange]);
|
|
8234
|
-
const handleNext =
|
|
8251
|
+
const handleNext = useCallback5(() => {
|
|
8235
8252
|
const d = new Date(date);
|
|
8236
8253
|
if (view === "month") d.setMonth(d.getMonth() + 1);
|
|
8237
8254
|
else if (view === "week") d.setDate(d.getDate() + 7);
|
|
8238
8255
|
else d.setDate(d.getDate() + 1);
|
|
8239
8256
|
handleDateChange(d);
|
|
8240
8257
|
}, [date, view, handleDateChange]);
|
|
8241
|
-
const handleToday =
|
|
8258
|
+
const handleToday = useCallback5(() => {
|
|
8242
8259
|
handleDateChange(/* @__PURE__ */ new Date());
|
|
8243
8260
|
}, [handleDateChange]);
|
|
8244
8261
|
return /* @__PURE__ */ jsxs38(
|