@sproutsocial/seeds-react-datepicker 1.0.51 → 1.1.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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +54 -0
- package/dist/datepicker.css +262 -0
- package/dist/esm/index.js +76 -174
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +74 -172
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/CalendarDayTailwind.tsx +76 -0
- package/src/DateRangePicker/DateRangePicker.tsx +6 -2
- package/src/DateRangePicker/__tests__/DateRangePicker.test.tsx +1 -2
- package/src/SingleDatePicker/SingleDatePicker.tsx +6 -2
- package/src/SingleDatePicker/__tests__/SingleDatePicker.test.tsx +1 -2
- package/src/__tests__/DatepickerContract.test.tsx +269 -0
- package/src/__tests__/DatepickerRouting.test.tsx +501 -0
- package/src/cn.ts +28 -0
- package/src/common.tsx +1 -1
- package/src/datepicker.css +262 -0
- package/src/dayModifiers.ts +71 -0
- package/src/styles.ts +21 -54
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
2
|
+
$ tsup --dts && cp src/datepicker.css dist/datepicker.css
|
|
3
3
|
[34mCLI[39m Building entry: src/index.ts
|
|
4
4
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
5
|
[34mCLI[39m tsup v8.5.0
|
|
@@ -8,14 +8,14 @@ $ tsup --dts
|
|
|
8
8
|
[34mCLI[39m Cleaning output folder
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
-
[32mESM[39m [1mdist/esm/index.js [22m[
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m11.97 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m20.36 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 21ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m9.30 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m20.24 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 22ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 1656ms
|
|
19
19
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.01 KB[39m
|
|
20
20
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.01 KB[39m
|
|
21
|
-
Done in
|
|
21
|
+
Done in 2.38s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-datepicker
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 899c48b: Add a Tailwind static-CSS rendering path to `SingleDatePicker` and
|
|
8
|
+
`DateRangePicker`, and fix the weekday header layout.
|
|
9
|
+
|
|
10
|
+
The day cell now renders semantic `seeds-datepicker-day*` classes and the
|
|
11
|
+
react-dates overrides that were previously injected at runtime by
|
|
12
|
+
`createGlobalStyle` now ship as `datepicker.css`, so mounting a picker emits no
|
|
13
|
+
runtime CSS-in-JS. Public exports, types, prop-spread order, and rendered
|
|
14
|
+
structure and semantics are preserved.
|
|
15
|
+
|
|
16
|
+
**Rendering fix:** the weekday header no longer wraps `Sa` onto a second line,
|
|
17
|
+
and its underline now aligns with the month instead of cutting through the first
|
|
18
|
+
row of dates. The header had a hardcoded `width: 230px` that only worked while
|
|
19
|
+
it was `content-box`; once Tailwind's preflight made everything `border-box`,
|
|
20
|
+
react-dates' own horizontal padding started subtracting from that width, leaving
|
|
21
|
+
less room than the seven day columns need. The width and the two rules that
|
|
22
|
+
compensated for it are gone, so the header shrink-wraps to the month and tracks
|
|
23
|
+
`daySize` rather than a magic number. This was already broken on `main` from the
|
|
24
|
+
moment the Tailwind preflight landed — it is not a regression introduced by the
|
|
25
|
+
hybrid.
|
|
26
|
+
|
|
27
|
+
Consuming apps must import `@sproutsocial/racine/css/components` (alongside
|
|
28
|
+
`@sproutsocial/seeds-react-theme/css/theme-all`) for the pickers to be styled.
|
|
29
|
+
The react-dates override rules are emitted **unlayered** and qualified with the
|
|
30
|
+
`.DayPicker` ancestor, so they outrank `react-dates/lib/css/_datepicker.css`
|
|
31
|
+
regardless of cascade layer, and for every state except `:active`, regardless of
|
|
32
|
+
stylesheet order. react-dates' `:active` rules tie on specificity, so import
|
|
33
|
+
`@sproutsocial/racine/css/components` **after** react-dates' CSS to win those
|
|
34
|
+
too. These rules now load for every consumer of the aggregated component CSS
|
|
35
|
+
rather than only while a picker is mounted.
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [db4415c]
|
|
40
|
+
- @sproutsocial/seeds-react-theme@4.7.0
|
|
41
|
+
- @sproutsocial/seeds-react-box@1.1.34
|
|
42
|
+
- @sproutsocial/seeds-react-icon@2.5.4
|
|
43
|
+
- @sproutsocial/seeds-react-mixins@4.3.18
|
|
44
|
+
- @sproutsocial/seeds-react-visually-hidden@1.0.35
|
|
45
|
+
|
|
46
|
+
## 1.0.52
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [57372fe]
|
|
51
|
+
- @sproutsocial/seeds-react-theme@4.6.0
|
|
52
|
+
- @sproutsocial/seeds-react-box@1.1.33
|
|
53
|
+
- @sproutsocial/seeds-react-icon@2.5.3
|
|
54
|
+
- @sproutsocial/seeds-react-mixins@4.3.17
|
|
55
|
+
- @sproutsocial/seeds-react-visually-hidden@1.0.34
|
|
56
|
+
|
|
3
57
|
## 1.0.51
|
|
4
58
|
|
|
5
59
|
### Patch Changes
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Datepicker component classes
|
|
3
|
+
*
|
|
4
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
5
|
+
* CSS variable definitions and dark mode support.
|
|
6
|
+
*
|
|
7
|
+
* This file has two halves, and they are deliberately in different cascade
|
|
8
|
+
* positions.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* 1. react-dates overrides — UNLAYERED (approved exception)
|
|
12
|
+
* ---------------------------------------------------------------------------
|
|
13
|
+
* The block below restyles react-dates' own DOM. It is the static port of the
|
|
14
|
+
* `ReactDatesCssOverrides` createGlobalStyle in styles.ts, which used to be
|
|
15
|
+
* injected at runtime whenever a picker mounted.
|
|
16
|
+
*
|
|
17
|
+
* It is emitted OUTSIDE `@layer components`, which is an explicit, approved
|
|
18
|
+
* exception to the repository's Tailwind delivery convention. react-dates ships
|
|
19
|
+
* `react-dates/lib/css/_datepicker.css` with zero cascade layers, and an
|
|
20
|
+
* unlayered declaration beats every layered one no matter how specific. A
|
|
21
|
+
* layered port would silently lose the .DayPicker__horizontal box-shadow reset,
|
|
22
|
+
* the .CalendarDay__default color and hover reset, and the .CalendarMonth_caption
|
|
23
|
+
* padding — only the one !important rule would survive.
|
|
24
|
+
*
|
|
25
|
+
* Two unlayered rules of equal specificity fall back to source order, and a
|
|
26
|
+
* consuming bundler decides whether this file lands before or after
|
|
27
|
+
* _datepicker.css. So every override that contests a react-dates declaration is
|
|
28
|
+
* qualified with the .DayPicker ancestor (or, for the root element itself, with
|
|
29
|
+
* its own base class), which outranks react-dates' plain single-class rules
|
|
30
|
+
* whatever the stylesheet order.
|
|
31
|
+
*
|
|
32
|
+
* react-dates ALSO ships pseudo-class rules — .CalendarDay__default:hover and
|
|
33
|
+
* .CalendarDay__selected:hover among them — and a pseudo-class counts toward the
|
|
34
|
+
* same specificity component as a class, so those sit at (0,2,0) and tie with a
|
|
35
|
+
* plain .DayPicker-qualified override. That is why the two CalendarDay :hover
|
|
36
|
+
* variants below are written out at (0,3,0). They are load-bearing, NOT redundant
|
|
37
|
+
* copies of their base rules: delete them and the hover background and border
|
|
38
|
+
* resets become stylesheet-order-dependent again.
|
|
39
|
+
*
|
|
40
|
+
* The nav-button :hover rule is different. It is simply the hover state carried
|
|
41
|
+
* over from the styled implementation. react-dates ships no rule for
|
|
42
|
+
* .DayPickerNavigation_button__horizontal at all, only __horizontalDefault at
|
|
43
|
+
* (0,1,0), and its .DayPickerNavigation_button__default rules never apply here
|
|
44
|
+
* because Seeds always supplies navPrev and navNext, so react-dates marks the
|
|
45
|
+
* buttons non-default. Nothing contests it.
|
|
46
|
+
*
|
|
47
|
+
* NOT covered: react-dates' :active variants — .CalendarDay__selected:active and
|
|
48
|
+
* its blocked, hovered_span and highlighted_calendar siblings — also sit at
|
|
49
|
+
* (0,2,0) and therefore TIE with the overrides below, leaving the winner to
|
|
50
|
+
* stylesheet order in the consuming bundle. The styled implementation's
|
|
51
|
+
* unqualified single-class rules lost those contests outright, so this is
|
|
52
|
+
* same-or-better everywhere and never a regression, but a pressed day may still
|
|
53
|
+
* flash react-dates' own palette. Closing it means adding
|
|
54
|
+
* .DayPicker .CalendarDay:active to the transparent-background group and
|
|
55
|
+
* .DayPicker .CalendarDay__default:active to the border-reset group, which is a
|
|
56
|
+
* deliberate visual change and was not authorized for Phase A.
|
|
57
|
+
*
|
|
58
|
+
* The magic numbers are carried over verbatim from the styled implementation.
|
|
59
|
+
* They are tuned against react-dates' own layout — do not "normalize" them to
|
|
60
|
+
* theme tokens. In particular `line-height: 21.333px` is NOT --line-height-200,
|
|
61
|
+
* and `top: 26px` on the week header is still a magic number aligning it with
|
|
62
|
+
* .CalendarMonth_caption.
|
|
63
|
+
*
|
|
64
|
+
* One magic number was deliberately NOT carried over: `width: 230px` on the week
|
|
65
|
+
* header, along with the two rules that compensated for it. It assumed
|
|
66
|
+
* content-box and broke once Tailwind's preflight made everything border-box.
|
|
67
|
+
* The header now shrink-wraps to the month. See the comment on that rule.
|
|
68
|
+
*
|
|
69
|
+
*
|
|
70
|
+
* 2. Day cell — LAYERED, as usual
|
|
71
|
+
* ---------------------------------------------------------------------------
|
|
72
|
+
* `.seeds-datepicker-day*` styles a node this package renders itself, so it
|
|
73
|
+
* follows the normal convention and lives in `@layer components`, letting
|
|
74
|
+
* consumer Tailwind utilities override it.
|
|
75
|
+
*
|
|
76
|
+
* Usage (applied by CalendarDayTailwind.tsx):
|
|
77
|
+
* <div class="seeds-datepicker-day seeds-datepicker-day-selected
|
|
78
|
+
* seeds-datepicker-day-pill-left">17</div>
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/* ========================================================================== */
|
|
82
|
+
/* react-dates overrides (unlayered — see note 1 above) */
|
|
83
|
+
/* ========================================================================== */
|
|
84
|
+
|
|
85
|
+
/* The one override left unqualified, at (0,1,0). It therefore ties with
|
|
86
|
+
react-dates' own `.DayPicker` rule and the winner is load order — where the
|
|
87
|
+
styled version, injected last at runtime, always won. Harmless today because
|
|
88
|
+
the two declaration sets are disjoint (this rule sets box-sizing, font-weight
|
|
89
|
+
and font-family; react-dates sets background, position and text-align), so
|
|
90
|
+
there is nothing to contest. Qualify it as `.DayPicker.DayPicker` if react-dates
|
|
91
|
+
ever adds one of these properties. */
|
|
92
|
+
.DayPicker {
|
|
93
|
+
box-sizing: content-box;
|
|
94
|
+
font-weight: var(--font-weight-normal);
|
|
95
|
+
font-family: var(--font-family);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Override react-dates' height to better reflect how tall the component
|
|
99
|
+
actually is. Adding margin/padding is truer to the Seeds system, because the
|
|
100
|
+
calendar height adds an extra row of padding if we do not override it.
|
|
101
|
+
!important is required because react-dates sets height on the element. */
|
|
102
|
+
.DayPicker .DayPicker_transitionContainer {
|
|
103
|
+
height: 228px !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* No `width` here on purpose. The styled implementation pinned `width: 230px`
|
|
107
|
+
to stretch the underline the full month width, which only held while the
|
|
108
|
+
element was content-box. Tailwind's preflight sets `* { box-sizing:
|
|
109
|
+
border-box }`, so react-dates' own inline `padding: 0 13px` started
|
|
110
|
+
subtracting from that 230px: 230 - 26 - 10 = 194px of content against the
|
|
111
|
+
7 x 30px = 210px the day columns need, which wrapped Saturday onto a second
|
|
112
|
+
line and dropped the border-bottom through the first row of dates. Letting
|
|
113
|
+
the header shrink-wrap to the month makes it track `daySize` instead of a
|
|
114
|
+
magic number, and gives the same result under either box-sizing.
|
|
115
|
+
Deleting the width also means react-dates' own `.DayPicker_weekHeaders__horizontal`
|
|
116
|
+
margin-left and `.DayPicker_weekHeader_ul` padding-left must be left alone —
|
|
117
|
+
the styled version overrode both to compensate for the pinned width. */
|
|
118
|
+
.DayPicker .DayPicker_weekHeader {
|
|
119
|
+
color: var(--color-text-headline);
|
|
120
|
+
border-bottom: 1px solid var(--color-container-border-base);
|
|
121
|
+
|
|
122
|
+
/* Magic number to match position of .CalendarMonth_caption */
|
|
123
|
+
top: 26px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.DayPicker .DayPicker_weekHeader_li {
|
|
127
|
+
font-size: var(--font-size-200);
|
|
128
|
+
line-height: var(--line-height-200);
|
|
129
|
+
color: var(--color-text-subtext);
|
|
130
|
+
font-weight: var(--font-weight-semibold);
|
|
131
|
+
margin: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.DayPicker.DayPicker__horizontal {
|
|
135
|
+
box-shadow: none;
|
|
136
|
+
background: var(--color-container-bg-base);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.DayPicker .CalendarDay {
|
|
140
|
+
background-color: transparent;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.DayPicker .CalendarDay__selected,
|
|
144
|
+
.DayPicker .CalendarDay__selected_span,
|
|
145
|
+
.DayPicker .CalendarDay:hover {
|
|
146
|
+
background-color: transparent;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.DayPicker .CalendarDay__default,
|
|
150
|
+
.DayPicker .CalendarDay__default:hover {
|
|
151
|
+
border: none;
|
|
152
|
+
color: var(--color-text-body);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.DayPicker .CalendarMonth {
|
|
156
|
+
font-size: var(--font-size-200);
|
|
157
|
+
line-height: var(--line-height-200);
|
|
158
|
+
background: var(--color-container-bg-base);
|
|
159
|
+
|
|
160
|
+
/* spacing between visible months and months off canvas */
|
|
161
|
+
padding: 0 15px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.DayPicker .CalendarMonth_caption {
|
|
165
|
+
font-size: var(--font-size-200);
|
|
166
|
+
line-height: var(--line-height-200);
|
|
167
|
+
color: var(--color-text-headline);
|
|
168
|
+
padding-top: 0;
|
|
169
|
+
background: var(--color-container-bg-base);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.DayPicker .CalendarMonth_caption strong {
|
|
173
|
+
font-weight: var(--font-weight-semibold);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.DayPicker .CalendarMonth_table {
|
|
177
|
+
line-height: 21.333px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.DayPicker .CalendarMonth_table tr {
|
|
181
|
+
vertical-align: middle;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.DayPicker .CalendarMonth_table td {
|
|
185
|
+
padding: 0;
|
|
186
|
+
border-bottom: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.DayPicker .CalendarMonthGrid {
|
|
190
|
+
background: var(--color-container-bg-base);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* Left and Right Arrow Buttons to navigate months */
|
|
194
|
+
.DayPicker .DayPickerNavigation_button__horizontal {
|
|
195
|
+
color: var(--color-button-pill-text-base);
|
|
196
|
+
top: -4px;
|
|
197
|
+
padding: 7px 8px;
|
|
198
|
+
position: absolute;
|
|
199
|
+
line-height: 0.78;
|
|
200
|
+
border-radius: 9999px;
|
|
201
|
+
border: none;
|
|
202
|
+
background: var(--color-button-pill-bg-base);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.DayPicker .DayPickerNavigation_button__horizontal:nth-child(1) {
|
|
206
|
+
left: 22px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.DayPicker .DayPickerNavigation_button__horizontal:nth-child(2) {
|
|
210
|
+
right: 22px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.DayPicker .DayPickerNavigation_button__horizontal:hover {
|
|
214
|
+
background: var(--color-button-pill-bg-hover);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* ========================================================================== */
|
|
218
|
+
/* Day cell (layered — see note 2 above) */
|
|
219
|
+
/* ========================================================================== */
|
|
220
|
+
|
|
221
|
+
@layer components {
|
|
222
|
+
/* Baseline inherited from Box, which the legacy day cell extended. Box ships
|
|
223
|
+
no CSS of its own, so the static cell has to reproduce it here. */
|
|
224
|
+
.seeds-datepicker-day {
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
font-family: var(--font-family);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.seeds-datepicker-day-selected {
|
|
230
|
+
background-color: var(--color-container-bg-selected);
|
|
231
|
+
color: var(--color-text-inverse);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* The pill edges are separate classes on purpose. The legacy implementation
|
|
235
|
+
interpolated `margin-left: ${condition && space}`, which emits NO
|
|
236
|
+
declaration when the condition is false — writing a `0` fallback here would
|
|
237
|
+
square off the ends of every selected range. */
|
|
238
|
+
.seeds-datepicker-day-pill-left {
|
|
239
|
+
margin-left: var(--space-200);
|
|
240
|
+
border-top-left-radius: var(--radius-pill);
|
|
241
|
+
border-bottom-left-radius: var(--radius-pill);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.seeds-datepicker-day-pill-right {
|
|
245
|
+
margin-right: var(--space-200);
|
|
246
|
+
border-top-right-radius: var(--radius-pill);
|
|
247
|
+
border-bottom-right-radius: var(--radius-pill);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.seeds-datepicker-day-hovered {
|
|
251
|
+
margin: 0 var(--space-200);
|
|
252
|
+
border-radius: var(--radius-pill);
|
|
253
|
+
border: 1px solid var(--color-container-border-selected);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Mirrors the `disabled` mixin from seeds-react-mixins. */
|
|
257
|
+
.seeds-datepicker-day-out-of-range {
|
|
258
|
+
color: var(--color-text-subtext);
|
|
259
|
+
opacity: 0.4;
|
|
260
|
+
pointer-events: none;
|
|
261
|
+
}
|
|
262
|
+
}
|