@koobiq/react-components 0.6.0 → 0.7.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/dist/components/Calendar/components/CalendarGrid/CalendarGrid.js +50 -6
- package/dist/components/Calendar/components/CalendarGrid/CalendarGrid.module.css.js +22 -1
- package/dist/components/Calendar/components/CalendarGrid/utils.d.ts +4 -0
- package/dist/components/Calendar/components/CalendarGrid/utils.js +6 -0
- package/dist/components/DatePicker/DatePicker.js +1 -0
- package/dist/components/DatePicker/DatePicker.module.css.js +5 -2
- package/dist/style.css +75 -2
- package/package.json +5 -5
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useRef, useEffect, createRef } from "react";
|
|
3
4
|
import { useLocale, getWeeksInMonth, clsx } from "@koobiq/react-core";
|
|
4
5
|
import { useCalendarGrid } from "@koobiq/react-primitives";
|
|
6
|
+
import { TransitionGroup, CSSTransition } from "react-transition-group";
|
|
5
7
|
import { utilClasses } from "../../../../styles/utility.js";
|
|
6
8
|
import s from "./CalendarGrid.module.css.js";
|
|
9
|
+
import { monthIndex } from "./utils.js";
|
|
7
10
|
import { CalendarCell } from "../CalendarCell/CalendarCell.js";
|
|
8
11
|
const textNormal = utilClasses.typography["text-normal"];
|
|
9
12
|
function CalendarGrid({ state, ...props }) {
|
|
@@ -12,16 +15,57 @@ function CalendarGrid({ state, ...props }) {
|
|
|
12
15
|
{ ...props, weekdayStyle: "short" },
|
|
13
16
|
state
|
|
14
17
|
);
|
|
18
|
+
const currentKey = useMemo(
|
|
19
|
+
() => state.visibleRange.start.toString(),
|
|
20
|
+
[state.visibleRange.start]
|
|
21
|
+
);
|
|
22
|
+
const prevStartRef = useRef(state.visibleRange.start);
|
|
23
|
+
const dir = useMemo(() => {
|
|
24
|
+
const curr = state.visibleRange.start;
|
|
25
|
+
const prev = prevStartRef.current;
|
|
26
|
+
const delta = monthIndex(curr) - monthIndex(prev);
|
|
27
|
+
if (delta === 0) return "next";
|
|
28
|
+
if (Math.abs(delta) > 1) return "jump";
|
|
29
|
+
return delta > 0 ? "next" : "prev";
|
|
30
|
+
}, [state.visibleRange.start]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
prevStartRef.current = state.visibleRange.start;
|
|
33
|
+
}, [state.visibleRange.start]);
|
|
15
34
|
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
|
|
16
|
-
|
|
35
|
+
const nodeRefs = useRef(
|
|
36
|
+
/* @__PURE__ */ new Map()
|
|
37
|
+
);
|
|
38
|
+
const k = currentKey;
|
|
39
|
+
if (!nodeRefs.current.has(k)) {
|
|
40
|
+
nodeRefs.current.set(k, createRef());
|
|
41
|
+
}
|
|
42
|
+
const tbodyRef = nodeRefs.current.get(k);
|
|
43
|
+
return /* @__PURE__ */ jsx("div", { className: s.container, children: /* @__PURE__ */ jsxs("table", { ...gridProps, className: clsx(s.base, s[dir], textNormal), children: [
|
|
17
44
|
/* @__PURE__ */ jsxs("thead", { ...headerProps, children: [
|
|
18
45
|
/* @__PURE__ */ jsx("tr", { children: weekDays.map((day, i) => /* @__PURE__ */ jsx("th", { className: clsx(s.weekDay, textNormal), children: day }, i)) }),
|
|
19
46
|
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", { colSpan: 7, className: s.divider }) })
|
|
20
47
|
] }),
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
48
|
+
/* @__PURE__ */ jsx(TransitionGroup, { component: null, children: /* @__PURE__ */ jsx(
|
|
49
|
+
CSSTransition,
|
|
50
|
+
{
|
|
51
|
+
timeout: 300,
|
|
52
|
+
nodeRef: tbodyRef,
|
|
53
|
+
classNames: {
|
|
54
|
+
enter: s.daysEnter,
|
|
55
|
+
enterActive: s.daysEnterActive,
|
|
56
|
+
exit: s.daysExit,
|
|
57
|
+
exitActive: s.daysExitActive
|
|
58
|
+
},
|
|
59
|
+
onExited: () => {
|
|
60
|
+
nodeRefs.current.delete(k);
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ jsx("tbody", { ref: tbodyRef, children: [...new Array(weeksInMonth).keys()].map((weekIndex) => /* @__PURE__ */ jsx("tr", { children: state.getDatesInWeek(weekIndex).map(
|
|
63
|
+
(date, i) => date ? /* @__PURE__ */ jsx(CalendarCell, { state, date }, i) : /* @__PURE__ */ jsx("td", {}, i)
|
|
64
|
+
) }, weekIndex)) })
|
|
65
|
+
},
|
|
66
|
+
k
|
|
67
|
+
) })
|
|
68
|
+
] }) });
|
|
25
69
|
}
|
|
26
70
|
export {
|
|
27
71
|
CalendarGrid
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
const base = "kbq-calendargrid-1a43cf";
|
|
2
|
+
const container = "kbq-calendargrid-container-aea3c5";
|
|
2
3
|
const weekDay = "kbq-calendargrid-weekDay-94b083";
|
|
3
4
|
const divider = "kbq-calendargrid-divider-3ec061";
|
|
5
|
+
const next = "kbq-calendargrid-next-56a233";
|
|
6
|
+
const daysEnter = "kbq-calendargrid-daysEnter-576154";
|
|
7
|
+
const daysEnterActive = "kbq-calendargrid-daysEnterActive-a174dd";
|
|
8
|
+
const daysExit = "kbq-calendargrid-daysExit-93902d";
|
|
9
|
+
const daysExitActive = "kbq-calendargrid-daysExitActive-57d3e5";
|
|
10
|
+
const prev = "kbq-calendargrid-prev-1d8448";
|
|
4
11
|
const s = {
|
|
5
12
|
base,
|
|
13
|
+
container,
|
|
6
14
|
weekDay,
|
|
7
|
-
divider
|
|
15
|
+
divider,
|
|
16
|
+
next,
|
|
17
|
+
daysEnter,
|
|
18
|
+
daysEnterActive,
|
|
19
|
+
daysExit,
|
|
20
|
+
daysExitActive,
|
|
21
|
+
prev
|
|
8
22
|
};
|
|
9
23
|
export {
|
|
10
24
|
base,
|
|
25
|
+
container,
|
|
26
|
+
daysEnter,
|
|
27
|
+
daysEnterActive,
|
|
28
|
+
daysExit,
|
|
29
|
+
daysExitActive,
|
|
11
30
|
s as default,
|
|
12
31
|
divider,
|
|
32
|
+
next,
|
|
33
|
+
prev,
|
|
13
34
|
weekDay
|
|
14
35
|
};
|
package/dist/style.css
CHANGED
|
@@ -3842,6 +3842,7 @@
|
|
|
3842
3842
|
padding-block: var(--kbq-size-m);
|
|
3843
3843
|
flex-direction: column;
|
|
3844
3844
|
display: flex;
|
|
3845
|
+
overflow-x: hidden;
|
|
3845
3846
|
}
|
|
3846
3847
|
|
|
3847
3848
|
.kbq-calendar-open-e506bb {
|
|
@@ -3863,15 +3864,23 @@
|
|
|
3863
3864
|
margin-inline-start: auto;
|
|
3864
3865
|
}
|
|
3865
3866
|
.kbq-calendargrid-1a43cf {
|
|
3867
|
+
border-spacing: 0;
|
|
3866
3868
|
border-collapse: separate;
|
|
3867
|
-
|
|
3868
|
-
border-spacing: 0 var(--kbq-size-3xs);
|
|
3869
|
+
position: relative;
|
|
3869
3870
|
}
|
|
3870
3871
|
|
|
3871
3872
|
.kbq-calendargrid-1a43cf td, .kbq-calendargrid-1a43cf th {
|
|
3872
3873
|
padding: 0;
|
|
3873
3874
|
}
|
|
3874
3875
|
|
|
3876
|
+
.kbq-calendargrid-1a43cf tr > td {
|
|
3877
|
+
padding-block-start: var(--kbq-size-3xs);
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
.kbq-calendargrid-container-aea3c5 {
|
|
3881
|
+
padding-inline: var(--kbq-size-m);
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3875
3884
|
.kbq-calendargrid-weekDay-94b083 {
|
|
3876
3885
|
block-size: var(--calendar-cell-block-size);
|
|
3877
3886
|
inline-size: var(--calendar-cell-inline-size);
|
|
@@ -3890,6 +3899,54 @@
|
|
|
3890
3899
|
background-color: var(--kbq-line-contrast-less);
|
|
3891
3900
|
position: absolute;
|
|
3892
3901
|
}
|
|
3902
|
+
|
|
3903
|
+
.kbq-calendargrid-next-56a233 .kbq-calendargrid-daysEnter-576154 {
|
|
3904
|
+
transform: translateX(50px);
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3907
|
+
.kbq-calendargrid-next-56a233 .kbq-calendargrid-daysEnterActive-a174dd, .kbq-calendargrid-next-56a233 .kbq-calendargrid-daysExit-93902d {
|
|
3908
|
+
transform: translateX(0);
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3911
|
+
.kbq-calendargrid-next-56a233 .kbq-calendargrid-daysExitActive-57d3e5 {
|
|
3912
|
+
transform: translateX(-50px);
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
.kbq-calendargrid-prev-1d8448 .kbq-calendargrid-daysEnter-576154 {
|
|
3916
|
+
transform: translateX(-50px);
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
.kbq-calendargrid-prev-1d8448 .kbq-calendargrid-daysEnterActive-a174dd, .kbq-calendargrid-prev-1d8448 .kbq-calendargrid-daysExit-93902d {
|
|
3920
|
+
transform: translateX(0);
|
|
3921
|
+
}
|
|
3922
|
+
|
|
3923
|
+
.kbq-calendargrid-prev-1d8448 .kbq-calendargrid-daysExitActive-57d3e5 {
|
|
3924
|
+
transform: translateX(50px);
|
|
3925
|
+
}
|
|
3926
|
+
|
|
3927
|
+
.kbq-calendargrid-daysEnter-576154 {
|
|
3928
|
+
opacity: 0;
|
|
3929
|
+
position: absolute;
|
|
3930
|
+
inset-inline-start: 0;
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
.kbq-calendargrid-daysEnterActive-a174dd {
|
|
3934
|
+
opacity: 1;
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
.kbq-calendargrid-daysExit-93902d {
|
|
3938
|
+
pointer-events: none;
|
|
3939
|
+
opacity: 1;
|
|
3940
|
+
position: absolute;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
.kbq-calendargrid-daysExitActive-57d3e5 {
|
|
3944
|
+
opacity: 0;
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
.kbq-calendargrid-daysEnterActive-a174dd, .kbq-calendargrid-daysExitActive-57d3e5 {
|
|
3948
|
+
transition: opacity .2s, transform .3s;
|
|
3949
|
+
}
|
|
3893
3950
|
.kbq-calendarcell-dc4d6e {
|
|
3894
3951
|
--table-cell-outline-color: transparent;
|
|
3895
3952
|
--table-cell-outline-width: var(--kbq-size-3xs);
|
|
@@ -4030,6 +4087,22 @@
|
|
|
4030
4087
|
.kbq-datepicker-calendar-25a0d7 {
|
|
4031
4088
|
margin-inline-end: calc(-1 * var(--kbq-size-xxs));
|
|
4032
4089
|
}
|
|
4090
|
+
|
|
4091
|
+
.kbq-datepicker-popover-831cde {
|
|
4092
|
+
border-radius: var(--kbq-size-s);
|
|
4093
|
+
opacity: 0;
|
|
4094
|
+
transform: translateY(-8px);
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
.kbq-datepicker-popover-831cde[data-transition="entering"], .kbq-datepicker-popover-831cde[data-transition="entered"] {
|
|
4098
|
+
opacity: 1;
|
|
4099
|
+
transform: translateY(0);
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
.kbq-datepicker-popover-831cde[data-transition="exiting"], .kbq-datepicker-popover-831cde[data-transition="exited"] {
|
|
4103
|
+
opacity: 0;
|
|
4104
|
+
transform: translateY(-8px);
|
|
4105
|
+
}
|
|
4033
4106
|
.kbq-timepicker-a6e9f3 {
|
|
4034
4107
|
min-inline-size: 150px;
|
|
4035
4108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@koobiq/design-tokens": "^3.14.0",
|
|
29
29
|
"@types/react-transition-group": "^4.4.12",
|
|
30
30
|
"react-transition-group": "^4.4.5",
|
|
31
|
-
"@koobiq/
|
|
32
|
-
"@koobiq/react-icons": "0.
|
|
33
|
-
"@koobiq/
|
|
34
|
-
"@koobiq/react-primitives": "0.
|
|
31
|
+
"@koobiq/react-core": "0.7.0",
|
|
32
|
+
"@koobiq/react-icons": "0.7.0",
|
|
33
|
+
"@koobiq/logger": "0.7.0",
|
|
34
|
+
"@koobiq/react-primitives": "0.7.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@koobiq/design-tokens": "^3.14.0",
|