@sproutsocial/seeds-react-datepicker 1.0.52 → 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 +43 -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 2.
|
|
21
|
+
Done in 2.38s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
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
|
+
|
|
3
46
|
## 1.0.52
|
|
4
47
|
|
|
5
48
|
### 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
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
// src/SingleDatePicker/SingleDatePicker.tsx
|
|
2
|
-
import
|
|
2
|
+
import React3, { useCallback, useState } from "react";
|
|
3
3
|
import moment2 from "moment";
|
|
4
4
|
import DayPickerSingleDateController from "react-dates/lib/components/DayPickerSingleDateController";
|
|
5
5
|
|
|
6
|
-
// src/
|
|
7
|
-
import
|
|
6
|
+
// src/common.tsx
|
|
7
|
+
import "react-dates/initialize";
|
|
8
|
+
import "react-dates/lib/css/_datepicker.css";
|
|
9
|
+
import "react";
|
|
10
|
+
import Icon from "@sproutsocial/seeds-react-icon";
|
|
11
|
+
|
|
12
|
+
// src/CalendarDayTailwind.tsx
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
|
|
15
|
+
// src/cn.ts
|
|
16
|
+
function cn(...inputs) {
|
|
17
|
+
const classes = [];
|
|
18
|
+
for (const input of inputs) {
|
|
19
|
+
if (!input) continue;
|
|
20
|
+
if (typeof input === "string") {
|
|
21
|
+
classes.push(input);
|
|
22
|
+
} else if (typeof input === "object") {
|
|
23
|
+
for (const [key, value] of Object.entries(input)) {
|
|
24
|
+
if (value) {
|
|
25
|
+
classes.push(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return classes.join(" ");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/dayModifiers.ts
|
|
8
34
|
import moment from "moment";
|
|
9
|
-
import { disabled } from "@sproutsocial/seeds-react-mixins";
|
|
10
|
-
import Box from "@sproutsocial/seeds-react-box";
|
|
11
35
|
var isSelected = (modifiers) => modifiers.has("selected-span") || modifiers.has("selected") || modifiers.has("selected-start") || modifiers.has("selected-end") || modifiers.has("hovered-span") || modifiers.has("after-hovered-start");
|
|
12
36
|
var isOutOfRange = (modifiers) => modifiers.has("blocked-out-of-range");
|
|
13
37
|
var isHoveredAndInRange = (modifiers) => modifiers.has("hovered") && !modifiers.has("blocked-out-of-range");
|
|
@@ -29,175 +53,55 @@ var shouldHaveRightPill = (modifiers, day) => {
|
|
|
29
53
|
}
|
|
30
54
|
return false;
|
|
31
55
|
};
|
|
32
|
-
|
|
33
|
-
|
|
56
|
+
|
|
57
|
+
// src/CalendarDayTailwind.tsx
|
|
58
|
+
import { jsx } from "react/jsx-runtime";
|
|
59
|
+
var dayStateClasses = (modifiers, day) => {
|
|
34
60
|
if (isSelected(modifiers)) {
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
border-top-left-radius: ${shouldHaveLeftPill(modifiers, day) && theme.radii.pill};
|
|
41
|
-
border-bottom-left-radius: ${shouldHaveLeftPill(modifiers, day) && theme.radii.pill};
|
|
42
|
-
border-top-right-radius: ${shouldHaveRightPill(modifiers, day) && theme.radii.pill};
|
|
43
|
-
border-bottom-right-radius: ${shouldHaveRightPill(modifiers, day) && theme.radii.pill};
|
|
44
|
-
`;
|
|
61
|
+
return {
|
|
62
|
+
"seeds-datepicker-day-selected": true,
|
|
63
|
+
"seeds-datepicker-day-pill-left": shouldHaveLeftPill(modifiers, day),
|
|
64
|
+
"seeds-datepicker-day-pill-right": shouldHaveRightPill(modifiers, day)
|
|
65
|
+
};
|
|
45
66
|
}
|
|
46
67
|
if (isHoveredAndInRange(modifiers)) {
|
|
47
|
-
return
|
|
48
|
-
margin: 0 ${theme.space[200]};
|
|
49
|
-
border-radius: ${theme.radii.pill};
|
|
50
|
-
border: 1px solid ${theme.colors.container.border.selected};
|
|
51
|
-
`;
|
|
52
|
-
} else if (isOutOfRange(modifiers)) {
|
|
53
|
-
return css`
|
|
54
|
-
color: ${theme.colors.text.subtext};
|
|
55
|
-
${disabled};
|
|
56
|
-
`;
|
|
68
|
+
return { "seeds-datepicker-day-hovered": true };
|
|
57
69
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/* Magic number to match position of .CalendarMonth_caption */
|
|
79
|
-
top: 26px;
|
|
80
|
-
|
|
81
|
-
/* Magic number to make the bottom border line stretch the full width */
|
|
82
|
-
width: 230px;
|
|
83
|
-
|
|
84
|
-
&_ul {
|
|
85
|
-
/* Magic number to line up day name headings over the correct numbers */
|
|
86
|
-
padding-left: 10px;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&_weekHeaders__horizontal {
|
|
91
|
-
margin-left: 0
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&_weekHeader_li {
|
|
95
|
-
${({ theme }) => theme.typography[200]}
|
|
96
|
-
color: ${({ theme }) => theme.colors.text.subtext};
|
|
97
|
-
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
98
|
-
margin: 0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&__horizontal {
|
|
102
|
-
box-shadow: none;
|
|
103
|
-
background: ${({ theme }) => theme.colors.container.background.base};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.CalendarDay {
|
|
108
|
-
background-color: transparent;
|
|
109
|
-
|
|
110
|
-
&__selected, &__selected_span, &:hover {
|
|
111
|
-
background-color: transparent;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&__default {
|
|
115
|
-
color: ${({ theme }) => theme.colors.text.body};
|
|
116
|
-
}
|
|
117
|
-
&__default,
|
|
118
|
-
&__default:hover {
|
|
119
|
-
border: none;
|
|
120
|
-
color: ${({ theme }) => theme.colors.text.body};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.CalendarMonth {
|
|
125
|
-
${({ theme }) => theme.typography[200]}
|
|
126
|
-
background: ${({ theme }) => theme.colors.container.background.base};
|
|
127
|
-
|
|
128
|
-
/* spacing between visible months and months off canvas */
|
|
129
|
-
padding: 0 15px;
|
|
130
|
-
|
|
131
|
-
&_caption {
|
|
132
|
-
${({ theme }) => theme.typography[200]}
|
|
133
|
-
color: ${({ theme }) => theme.colors.text.headline};
|
|
134
|
-
padding-top: 0;
|
|
135
|
-
background: ${({ theme }) => theme.colors.container.background.base};
|
|
136
|
-
|
|
137
|
-
strong {
|
|
138
|
-
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
&_table {
|
|
143
|
-
line-height: 21.333px;
|
|
144
|
-
tr {
|
|
145
|
-
vertical-align: middle;
|
|
146
|
-
}
|
|
147
|
-
td {
|
|
148
|
-
padding: 0;
|
|
149
|
-
border-bottom: none;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.CalendarMonthGrid {
|
|
155
|
-
background: ${({ theme }) => theme.colors.container.background.base};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* Left and Right Arrow Buttons to navigate months */
|
|
159
|
-
.DayPickerNavigation_button__horizontal {
|
|
160
|
-
color: ${({ theme }) => theme.colors.button.pill.text.base};
|
|
161
|
-
top: -4px;
|
|
162
|
-
padding: 7px 8px;
|
|
163
|
-
position: absolute;
|
|
164
|
-
line-height: 0.78;
|
|
165
|
-
border-radius: 9999px;
|
|
166
|
-
border: none;
|
|
167
|
-
background: ${({ theme }) => theme.colors.button.pill.background.base};
|
|
168
|
-
|
|
169
|
-
&:nth-child(1) {
|
|
170
|
-
left: 22px;
|
|
171
|
-
}
|
|
172
|
-
&:nth-child(2) {
|
|
173
|
-
right: 22px;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
&:hover {
|
|
177
|
-
background: ${({ theme }) => theme.colors.button.pill.background.hover};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
70
|
+
if (isOutOfRange(modifiers)) {
|
|
71
|
+
return { "seeds-datepicker-day-out-of-range": true };
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
};
|
|
75
|
+
var CalendarDayTailwind = React.forwardRef(({ modifiers, day, className, children }, ref) => /* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
ref,
|
|
79
|
+
className: cn(
|
|
80
|
+
"seeds-datepicker-day",
|
|
81
|
+
dayStateClasses(modifiers, day),
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
children
|
|
85
|
+
}
|
|
86
|
+
));
|
|
87
|
+
CalendarDayTailwind.displayName = "CalendarDay";
|
|
88
|
+
var CalendarDayTailwind_default = CalendarDayTailwind;
|
|
181
89
|
|
|
182
90
|
// src/common.tsx
|
|
183
|
-
import "react-
|
|
184
|
-
import "react-dates/lib/css/_datepicker.css";
|
|
185
|
-
import "react";
|
|
186
|
-
import Icon from "@sproutsocial/seeds-react-icon";
|
|
187
|
-
import { jsx } from "react/jsx-runtime";
|
|
91
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
188
92
|
var iconNames = {
|
|
189
93
|
left: "arrow-left-solid",
|
|
190
94
|
right: "arrow-right-solid"
|
|
191
95
|
};
|
|
192
96
|
var CalendarNavButton = ({
|
|
193
97
|
type
|
|
194
|
-
}) => /* @__PURE__ */
|
|
98
|
+
}) => /* @__PURE__ */ jsx2(Icon, { size: "mini", name: iconNames[type], "aria-hidden": true });
|
|
195
99
|
var commonDatePickerProps = {
|
|
196
100
|
hideKeyboardShortcutsPanel: true,
|
|
197
101
|
daySize: 30,
|
|
198
|
-
navPrev: /* @__PURE__ */
|
|
199
|
-
navNext: /* @__PURE__ */
|
|
200
|
-
renderDayContents: (day, modifiers) => /* @__PURE__ */
|
|
102
|
+
navPrev: /* @__PURE__ */ jsx2(CalendarNavButton, { type: "left" }),
|
|
103
|
+
navNext: /* @__PURE__ */ jsx2(CalendarNavButton, { type: "right" }),
|
|
104
|
+
renderDayContents: (day, modifiers) => /* @__PURE__ */ jsx2(CalendarDayTailwind_default, { day, modifiers, children: day.format("D") }),
|
|
201
105
|
initialVisibleMonth: null
|
|
202
106
|
};
|
|
203
107
|
var formatDateAsCalendarHeader = (date) => date.format("MMMM YYYY");
|
|
@@ -212,7 +116,7 @@ var DefaultSetStatusText = (dates) => dates.map(formatDateAsCalendarHeader).join
|
|
|
212
116
|
|
|
213
117
|
// src/SingleDatePicker/SingleDatePicker.tsx
|
|
214
118
|
import { VisuallyHidden } from "@sproutsocial/seeds-react-visually-hidden";
|
|
215
|
-
import { Fragment, jsx as
|
|
119
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
216
120
|
var noop = () => {
|
|
217
121
|
};
|
|
218
122
|
var SingleDatePicker = ({
|
|
@@ -249,9 +153,8 @@ var SingleDatePicker = ({
|
|
|
249
153
|
[onBlur, onFocusChange]
|
|
250
154
|
);
|
|
251
155
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */ jsx2(
|
|
156
|
+
/* @__PURE__ */ jsx3(VisuallyHidden, { children: /* @__PURE__ */ jsx3("div", { role: "status", children: statusText }) }),
|
|
157
|
+
/* @__PURE__ */ jsx3(
|
|
255
158
|
DayPickerSingleDateController,
|
|
256
159
|
{
|
|
257
160
|
...commonDatePickerProps,
|
|
@@ -269,11 +172,11 @@ var SingleDatePicker = ({
|
|
|
269
172
|
)
|
|
270
173
|
] });
|
|
271
174
|
};
|
|
272
|
-
var SingleDatePicker_default =
|
|
175
|
+
var SingleDatePicker_default = React3.memo(SingleDatePicker);
|
|
273
176
|
|
|
274
177
|
// src/SingleDatePicker/StatefulSingleDatePicker.tsx
|
|
275
178
|
import { useState as useState2 } from "react";
|
|
276
|
-
import { jsx as
|
|
179
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
277
180
|
var StatefulSingleDatePicker = ({
|
|
278
181
|
date,
|
|
279
182
|
onDateChange,
|
|
@@ -284,7 +187,7 @@ var StatefulSingleDatePicker = ({
|
|
|
284
187
|
onDateChange && onDateChange(date2);
|
|
285
188
|
setDate(date2);
|
|
286
189
|
};
|
|
287
|
-
return /* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsx4(
|
|
288
191
|
SingleDatePicker_default,
|
|
289
192
|
{
|
|
290
193
|
date: stateDate,
|
|
@@ -299,7 +202,7 @@ import { useCallback as useCallback2, useState as useState3 } from "react";
|
|
|
299
202
|
import moment3 from "moment";
|
|
300
203
|
import DayPickerRangeController from "react-dates/lib/components/DayPickerRangeController";
|
|
301
204
|
import { VisuallyHidden as VisuallyHidden2 } from "@sproutsocial/seeds-react-visually-hidden";
|
|
302
|
-
import { Fragment as Fragment2, jsx as
|
|
205
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
303
206
|
var DateRangePicker = ({
|
|
304
207
|
startDate = null,
|
|
305
208
|
endDate = null,
|
|
@@ -337,9 +240,8 @@ var DateRangePicker = ({
|
|
|
337
240
|
[onBlur, onFocusChange]
|
|
338
241
|
);
|
|
339
242
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
/* @__PURE__ */ jsx4(
|
|
243
|
+
/* @__PURE__ */ jsx5(VisuallyHidden2, { children: /* @__PURE__ */ jsx5("div", { role: "status", children: statusText }) }),
|
|
244
|
+
/* @__PURE__ */ jsx5(
|
|
343
245
|
DayPickerRangeController,
|
|
344
246
|
{
|
|
345
247
|
...commonDatePickerProps,
|
|
@@ -362,9 +264,9 @@ var DateRangePicker = ({
|
|
|
362
264
|
var DateRangePicker_default = DateRangePicker;
|
|
363
265
|
|
|
364
266
|
// src/DateRangePicker/StatefulDateRangePicker.tsx
|
|
365
|
-
import
|
|
267
|
+
import React6, { useState as useState4 } from "react";
|
|
366
268
|
import { START_DATE } from "react-dates/constants";
|
|
367
|
-
import { jsx as
|
|
269
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
368
270
|
var StatefulDateRangePicker = ({
|
|
369
271
|
startDate,
|
|
370
272
|
endDate,
|
|
@@ -376,7 +278,7 @@ var StatefulDateRangePicker = ({
|
|
|
376
278
|
startDate,
|
|
377
279
|
endDate
|
|
378
280
|
});
|
|
379
|
-
const [focusedInput, setFocusedInput] =
|
|
281
|
+
const [focusedInput, setFocusedInput] = React6.useState(START_DATE);
|
|
380
282
|
const handleDatesChange = (nextDates) => {
|
|
381
283
|
onDatesChange && onDatesChange(nextDates);
|
|
382
284
|
setDate(nextDates);
|
|
@@ -390,7 +292,7 @@ var StatefulDateRangePicker = ({
|
|
|
390
292
|
nextFocusedInput === null ? START_DATE : nextFocusedInput
|
|
391
293
|
);
|
|
392
294
|
};
|
|
393
|
-
return /* @__PURE__ */
|
|
295
|
+
return /* @__PURE__ */ jsx6(
|
|
394
296
|
DateRangePicker_default,
|
|
395
297
|
{
|
|
396
298
|
startDate: dates.startDate,
|