@blenx-dev/calendar 0.1.1

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 ADDED
@@ -0,0 +1,10 @@
1
+ # @blenx-dev/calendar
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0439e3e: Use Icon generator and simplify components
8
+ - Updated dependencies [0439e3e]
9
+ - @blenx-dev/core@0.2.3
10
+ - @blenx-dev/theme@0.2.3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Prashanth Kumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@blenx-dev/calendar",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "dependencies": {
10
+ "@vanilla-extract/css": "^1.20.1",
11
+ "@vanilla-extract/recipes": "^0.5.7",
12
+ "@vanilla-extract/sprinkles": "^1.6.5",
13
+ "clsx": "^2.1.1",
14
+ "react-day-picker": "^10.0.1",
15
+ "@blenx-dev/core": "0.2.3",
16
+ "@blenx-dev/theme": "0.2.3"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^19.2.15",
20
+ "@types/react-dom": "^19.2.3",
21
+ "changeset": "^0.2.6"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.2.6",
25
+ "react-dom": "^19.2.6",
26
+ "@blenx-dev/core": "0.2.3",
27
+ "@blenx-dev/theme": "0.2.3"
28
+ }
29
+ }
@@ -0,0 +1,187 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { semanticVars, tokenVars } from "@blenx-dev/theme/contract";
3
+
4
+ export const root = style({
5
+ display: "inline-block",
6
+ width: "100%",
7
+ });
8
+
9
+ export const months = style({
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ });
13
+
14
+ export const monthCaption = style({
15
+ display: "flex",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ position: "relative",
19
+ paddingBottom: tokenVars.spacing.sm,
20
+ minHeight: 40,
21
+ });
22
+
23
+ export const captionLabel = style({
24
+ fontSize: tokenVars.fontSize.md,
25
+ fontWeight: tokenVars.fontWeight.semibold,
26
+ color: semanticVars.text.primary,
27
+ margin: 0,
28
+ padding: 0,
29
+ });
30
+
31
+ export const nav = style({
32
+ height: "fit-content",
33
+ display: "flex",
34
+ justifyContent: "space-between",
35
+ alignItems: "center",
36
+ position: "absolute",
37
+ inset: 0,
38
+ padding: tokenVars.spacing.xs,
39
+ pointerEvents: "none",
40
+ zIndex: 10,
41
+ });
42
+
43
+ export const buttonNav = style({
44
+ pointerEvents: "auto",
45
+ appearance: "none",
46
+ backgroundColor: "transparent",
47
+ border: "none",
48
+ padding: 0,
49
+ font: "inherit",
50
+ WebkitTapHighlightColor: "transparent",
51
+ width: 28,
52
+ height: 28,
53
+ borderRadius: tokenVars.borderRadius.default,
54
+ display: "flex",
55
+ alignItems: "center",
56
+ justifyContent: "center",
57
+ color: semanticVars.text.secondary,
58
+ cursor: "pointer",
59
+ flexShrink: 0,
60
+ selectors: {
61
+ "&:hover": {
62
+ backgroundColor: semanticVars.background.subtle,
63
+ },
64
+ "&:focus-visible": {
65
+ boxShadow: `0 0 0 2px ${semanticVars.focus.ring}`,
66
+ },
67
+ },
68
+ });
69
+
70
+ export const monthGrid = style({
71
+ width: "100%",
72
+ borderCollapse: "collapse",
73
+ });
74
+
75
+ export const weekday = style({
76
+ fontSize: tokenVars.fontSize.xs,
77
+ fontWeight: tokenVars.fontWeight.medium,
78
+ color: semanticVars.text.secondary,
79
+ textAlign: "center",
80
+ verticalAlign: "middle",
81
+ padding: tokenVars.spacing.xxs,
82
+ width: 40,
83
+ height: 32,
84
+ boxSizing: "border-box",
85
+ });
86
+
87
+ export const day = style({
88
+ textAlign: "center",
89
+ verticalAlign: "middle",
90
+ padding: 1,
91
+ width: 40,
92
+ height: 40,
93
+ boxSizing: "border-box",
94
+ });
95
+
96
+ export const dayButton = style({
97
+ display: "flex",
98
+ alignItems: "center",
99
+ justifyContent: "center",
100
+ width: "100%",
101
+ height: "100%",
102
+ minWidth: 32,
103
+ minHeight: 32,
104
+ maxWidth: 36,
105
+ maxHeight: 36,
106
+ borderRadius: tokenVars.borderRadius.default,
107
+ border: "none",
108
+ backgroundColor: "transparent",
109
+ cursor: "pointer",
110
+ fontSize: tokenVars.fontSize.sm,
111
+ color: semanticVars.text.primary,
112
+ outline: "none",
113
+ margin: "0 auto",
114
+ padding: 0,
115
+ fontFamily: "inherit",
116
+ lineHeight: 1,
117
+ transitionProperty: "background-color, color",
118
+ transitionDuration: "100ms",
119
+ transitionTimingFunction: "ease",
120
+ selectors: {
121
+ "&:hover": {
122
+ backgroundColor: semanticVars.background.subtle,
123
+ },
124
+ "&:focus-visible": {
125
+ boxShadow: `0 0 0 2px ${semanticVars.focus.ring}`,
126
+ },
127
+ },
128
+ });
129
+
130
+ export const dayButtonSelected = style({
131
+ backgroundColor: semanticVars.interactive.primary.default,
132
+ color: semanticVars.interactive.primaryFg,
133
+ fontWeight: tokenVars.fontWeight.semibold,
134
+ selectors: {
135
+ "&:hover": {
136
+ backgroundColor: semanticVars.interactive.primary.default,
137
+ },
138
+ },
139
+ });
140
+
141
+ export const dayButtonToday = style({
142
+ fontWeight: tokenVars.fontWeight.semibold,
143
+ });
144
+
145
+ export const dayButtonDisabled = style({
146
+ color: semanticVars.text.disabled,
147
+ cursor: "not-allowed",
148
+ opacity: 0.5,
149
+ selectors: {
150
+ "&:hover": {
151
+ backgroundColor: "transparent",
152
+ },
153
+ },
154
+ });
155
+
156
+ export const dayButtonOutside = style({
157
+ color: semanticVars.text.disabled,
158
+ opacity: 0.5,
159
+ });
160
+
161
+ export const footer = style({
162
+ paddingTop: tokenVars.spacing.sm,
163
+ });
164
+
165
+ export const dropdowns = style({
166
+ display: "flex",
167
+ gap: tokenVars.spacing.xs,
168
+ alignItems: "center",
169
+ });
170
+
171
+ export const dropdown = style({
172
+ appearance: "none",
173
+ backgroundColor: semanticVars.background.subtle,
174
+ border: `1px solid ${semanticVars.border.default}`,
175
+ borderRadius: tokenVars.borderRadius.default,
176
+ color: semanticVars.text.primary,
177
+ fontSize: tokenVars.fontSize.sm,
178
+ padding: `${tokenVars.spacing.xxs} ${tokenVars.spacing.sm}`,
179
+ cursor: "pointer",
180
+ outline: "none",
181
+ selectors: {
182
+ "&:focus-visible": {
183
+ borderColor: semanticVars.border.strong,
184
+ boxShadow: `0 0 0 2px ${semanticVars.border.strong}`,
185
+ },
186
+ },
187
+ });
@@ -0,0 +1,142 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import { useEffect, useRef } from "react";
5
+ import { DayPicker, type DayPickerProps } from "react-day-picker";
6
+ import {
7
+ root,
8
+ months,
9
+ monthCaption,
10
+ captionLabel,
11
+ nav,
12
+ buttonNav,
13
+ monthGrid,
14
+ weekday,
15
+ day,
16
+ dayButton,
17
+ dayButtonSelected,
18
+ dayButtonToday,
19
+ dayButtonDisabled,
20
+ dayButtonOutside,
21
+ footer,
22
+ dropdowns,
23
+ dropdown,
24
+ } from "./calendar.css";
25
+ import { IconButton } from "@blenx-dev/core";
26
+ import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "@blenx-dev/core/icons";
27
+
28
+ function StyledDayButton({
29
+ day: _day,
30
+ modifiers,
31
+ className,
32
+ ...props
33
+ }: {
34
+ day: object;
35
+ modifiers: Record<string, boolean>;
36
+ } & React.ComponentPropsWithoutRef<"button">) {
37
+ const ref = useRef<HTMLButtonElement>(null);
38
+
39
+ useEffect(() => {
40
+ if (modifiers.focused) {
41
+ ref.current?.focus();
42
+ }
43
+ }, [modifiers.focused]);
44
+
45
+ const isSelected = modifiers.selected;
46
+ const isToday = modifiers.today;
47
+ const isDisabled = modifiers.disabled;
48
+ const isOutside = modifiers.outside;
49
+
50
+ const composed = clsx(
51
+ dayButton,
52
+ isSelected && dayButtonSelected,
53
+ isToday && dayButtonToday,
54
+ isDisabled && dayButtonDisabled,
55
+ isOutside && dayButtonOutside,
56
+ className,
57
+ );
58
+
59
+ return <button ref={ref} className={composed} {...props} />;
60
+ }
61
+
62
+ function Calendar({ className, components: userComponents, ...props }: DayPickerProps) {
63
+ const classNames = {
64
+ root: clsx(root, className),
65
+ months: months,
66
+ month: "",
67
+ month_caption: monthCaption,
68
+ caption_label: captionLabel,
69
+ nav: nav,
70
+ button_previous: buttonNav,
71
+ button_next: buttonNav,
72
+ chevron: "",
73
+ month_grid: monthGrid,
74
+ weekdays: "",
75
+ weekday: weekday,
76
+ weeks: "",
77
+ week: "",
78
+ day: day,
79
+ day_button: "",
80
+ footer: footer,
81
+ dropdowns: dropdowns,
82
+ dropdown: dropdown,
83
+ dropdown_root: "",
84
+ months_dropdown: "",
85
+ years_dropdown: "",
86
+ week_number: "",
87
+ week_number_header: "",
88
+ selected: "",
89
+ today: "",
90
+ disabled: "",
91
+ hidden: "",
92
+ outside: "",
93
+ focused: "",
94
+ range_start: "",
95
+ range_end: "",
96
+ range_middle: "",
97
+ weeks_before_enter: "",
98
+ weeks_before_exit: "",
99
+ weeks_after_enter: "",
100
+ weeks_after_exit: "",
101
+ caption_after_enter: "",
102
+ caption_after_exit: "",
103
+ caption_before_enter: "",
104
+ caption_before_exit: "",
105
+ };
106
+ const defaultComponents = {
107
+ Chevron: ({
108
+ orientation,
109
+ }: {
110
+ orientation?: "left" | "right" | "up" | "down";
111
+ }): React.ReactElement => {
112
+ if (orientation === "left") {
113
+ return (
114
+ <IconButton variant="ghost">
115
+ <ChevronLeftIcon width={16} />
116
+ </IconButton>
117
+ );
118
+ }
119
+ if (orientation === "right") {
120
+ return (
121
+ <IconButton variant="ghost">
122
+ <ChevronRightIcon width={16} />
123
+ </IconButton>
124
+ );
125
+ }
126
+ return (
127
+ <IconButton variant="ghost">
128
+ <ChevronDownIcon width={16} />
129
+ </IconButton>
130
+ );
131
+ },
132
+ };
133
+ const mergedComponents = {
134
+ ...defaultComponents,
135
+ ...userComponents,
136
+ DayButton: StyledDayButton,
137
+ };
138
+
139
+ return <DayPicker classNames={classNames} components={mergedComponents} {...props} />;
140
+ }
141
+
142
+ export { Calendar };
@@ -0,0 +1 @@
1
+ export * from "./calendar";
@@ -0,0 +1,79 @@
1
+ "use client";
2
+
3
+ import {
4
+ Button,
5
+ Field,
6
+ FieldError,
7
+ FieldLabel,
8
+ Icon,
9
+ Popover,
10
+ PopoverPopup,
11
+ PopoverPortal,
12
+ PopoverPositioner,
13
+ PopoverTrigger,
14
+ } from "@blenx-dev/core";
15
+ import { useState, useRef, type ReactNode } from "react";
16
+ import { Calendar } from "../Calendar";
17
+ import { CalendarIcon } from "@blenx-dev/core/icons";
18
+ type Props = {
19
+ value: Date | undefined;
20
+ triggerIcon?: ReactNode;
21
+ onChange: (date: Date | undefined) => void;
22
+ format?: (date: Date | undefined) => string;
23
+ label?: string;
24
+ placeholder?: string;
25
+ error?: string;
26
+ disabled?: boolean;
27
+ };
28
+
29
+ export function DatePicker({
30
+ value,
31
+ onChange,
32
+ label,
33
+ format,
34
+ placeholder = "Pick a date",
35
+ error,
36
+ triggerIcon,
37
+ disabled,
38
+ }: Props) {
39
+ const [open, setOpen] = useState(false);
40
+ const triggerRef = useRef<HTMLButtonElement>(null);
41
+
42
+ const handleSelect = (date: Date | undefined) => {
43
+ onChange(date);
44
+ setOpen(false);
45
+ };
46
+
47
+ return (
48
+ <Field>
49
+ <Popover open={open} onOpenChange={setOpen}>
50
+ {label && (
51
+ <FieldLabel
52
+ onClick={() => {
53
+ triggerRef.current?.click();
54
+ triggerRef.current?.focus();
55
+ }}
56
+ >
57
+ {label}
58
+ </FieldLabel>
59
+ )}
60
+ <PopoverTrigger
61
+ ref={triggerRef}
62
+ disabled={disabled}
63
+ render={<Button type="button" variant="outline" fullWidth />}
64
+ >
65
+ <Icon size="md">{triggerIcon ? triggerIcon : <CalendarIcon />}</Icon>
66
+ {value ? (format?.(value) ?? value.toString()) : placeholder}
67
+ </PopoverTrigger>
68
+ <PopoverPortal>
69
+ <PopoverPositioner sideOffset={6} side="bottom" align="start">
70
+ <PopoverPopup>
71
+ <Calendar mode="single" selected={value} onSelect={handleSelect} />
72
+ </PopoverPopup>
73
+ </PopoverPositioner>
74
+ </PopoverPortal>
75
+ </Popover>
76
+ {error && <FieldError>{error}</FieldError>}
77
+ </Field>
78
+ );
79
+ }
@@ -0,0 +1 @@
1
+ export * from "./date-picker";
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./DatePicker";
2
+ export * from "./Calendar";
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@blenx-dev/config/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
6
+ "types": []
7
+ },
8
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
9
+ "exclude": ["node_modules"]
10
+ }