playbook_ui 12.25.0.pre.alpha.railsmultilevelimprovements785 → 12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown794
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +26 -0
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +102 -95
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +30 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +11 -4
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +44 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +38 -4
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.html.erb +8 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.jsx +18 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +168 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +3 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +75 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +0 -16
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -3
- data/app/pb_kits/playbook/pb_nav/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_nav/_subtle_mixin.scss +1 -1
- data/dist/playbook-rails.js +279 -7
- data/lib/playbook/forms/builder.rb +0 -1
- data/lib/playbook/version.rb +2 -2
- metadata +6 -4
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb +0 -72
- data/lib/playbook/forms/builder/multi_level_select_field.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 360413b8af66e57c96b50f7a3d42e090570ce350ffaa9ec7d316ce5f3cffd9df
|
4
|
+
data.tar.gz: d96327fc8f503da031ffb1cfe9d5dfde31551860650d0ae01a0cc5e249fa5114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5350397053b9dba7747150cf2f3a85d074456ecd0afbc70ebe68175c53c7840983427d4c38daf97423e3d09136ce0db11ad9445e38dbd49dcd46f4060f59cb4a
|
7
|
+
data.tar.gz: 4422d0c952be46f567154bcd58037fb66763aa44cddfc47179de84b62d335083b055ac0edf97b616674e7b5861ff2d6f18b70ca1b41cc12e2ecf22df1be1a89a
|
@@ -6,6 +6,7 @@
|
|
6
6
|
@import "./sass_partials/month_and_year_styles";
|
7
7
|
@import "./sass_partials/time_selection_styles";
|
8
8
|
@import "./sass_partials/input_styles";
|
9
|
+
@import "./sass_partials/quick_pick_styles";
|
9
10
|
|
10
11
|
[class^=pb_date_picker_kit] {
|
11
12
|
.input_wrapper {
|
@@ -26,7 +27,32 @@
|
|
26
27
|
@include transition_default;
|
27
28
|
border-color: $primary;
|
28
29
|
}
|
30
|
+
.add-on-card {
|
31
|
+
border-color: $primary;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
@media (hover: hover) {
|
36
|
+
&:hover {
|
37
|
+
.add-on-card {
|
38
|
+
cursor: pointer;
|
39
|
+
background-color: rgba($focus_input_light,$opacity_5);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
.text_input_wrapper_add_on .add-on-icon {
|
44
|
+
color: $text_lt_light
|
29
45
|
}
|
46
|
+
|
47
|
+
.text_input_wrapper_add_on .add-on-right .text_input{
|
48
|
+
cursor: pointer;
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
.pb_popover_reference_wrapper {
|
55
|
+
display: unset !important
|
30
56
|
}
|
31
57
|
|
32
58
|
.flatpickr-calendar {
|
@@ -30,7 +30,7 @@ type DatePickerProps = {
|
|
30
30
|
inputAria?: { [key: string]: string },
|
31
31
|
inputData?: { [key: string]: string },
|
32
32
|
inputOnChange?: (e: React.FormEvent<HTMLInputElement>) => void,
|
33
|
-
inputValue?:
|
33
|
+
inputValue?: string,
|
34
34
|
label?: string,
|
35
35
|
maxDate: string,
|
36
36
|
minDate: string,
|
@@ -39,9 +39,10 @@ type DatePickerProps = {
|
|
39
39
|
placeholder?: string,
|
40
40
|
positionElement?: HTMLElement | null,
|
41
41
|
scrollContainer?: string,
|
42
|
-
selectionType?: "month" | "week",
|
42
|
+
selectionType?: "month" | "week"| "quickpick",
|
43
43
|
showTimezone?: boolean,
|
44
44
|
staticPosition: boolean,
|
45
|
+
thisRangesEndToday?: boolean,
|
45
46
|
timeFormat?: string,
|
46
47
|
type?: string,
|
47
48
|
yearRange?: number[],
|
@@ -88,6 +89,7 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
88
89
|
selectionType = '',
|
89
90
|
showTimezone = false,
|
90
91
|
staticPosition = true,
|
92
|
+
thisRangesEndToday = false,
|
91
93
|
yearRange = [1900, 2100],
|
92
94
|
} = props
|
93
95
|
|
@@ -96,46 +98,47 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
96
98
|
const inputAriaProps = buildAriaProps(inputAria)
|
97
99
|
const inputDataProps = buildDataProps(inputData)
|
98
100
|
|
101
|
+
useEffect(() => {
|
102
|
+
datePickerHelper({
|
103
|
+
allowInput,
|
104
|
+
defaultDate,
|
105
|
+
disableDate,
|
106
|
+
disableRange,
|
107
|
+
disableWeekdays,
|
108
|
+
enableTime,
|
109
|
+
format,
|
110
|
+
hideIcon,
|
111
|
+
inLine,
|
112
|
+
maxDate,
|
113
|
+
minDate,
|
114
|
+
mode,
|
115
|
+
onChange,
|
116
|
+
onClose,
|
117
|
+
pickerId,
|
118
|
+
plugins,
|
119
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
120
|
+
// @ts-ignore
|
121
|
+
position,
|
122
|
+
positionElement,
|
123
|
+
selectionType,
|
124
|
+
showTimezone,
|
125
|
+
staticPosition,
|
126
|
+
thisRangesEndToday,
|
127
|
+
yearRange,
|
128
|
+
required: false,
|
129
|
+
}, scrollContainer)
|
130
|
+
})
|
99
131
|
const filteredProps = {...props}
|
100
132
|
delete filteredProps?.position
|
101
133
|
|
102
134
|
const classes = classnames(
|
103
135
|
buildCss('pb_date_picker_kit'),
|
136
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
104
137
|
//@ts-ignore
|
105
138
|
globalProps(filteredProps),
|
106
139
|
error ? 'error' : null,
|
107
140
|
className
|
108
141
|
)
|
109
|
-
|
110
|
-
useEffect(() => {
|
111
|
-
datePickerHelper({
|
112
|
-
allowInput,
|
113
|
-
defaultDate,
|
114
|
-
disableDate,
|
115
|
-
disableRange,
|
116
|
-
disableWeekdays,
|
117
|
-
enableTime,
|
118
|
-
format,
|
119
|
-
hideIcon,
|
120
|
-
inLine,
|
121
|
-
maxDate,
|
122
|
-
minDate,
|
123
|
-
mode,
|
124
|
-
onChange,
|
125
|
-
onClose,
|
126
|
-
pickerId,
|
127
|
-
plugins,
|
128
|
-
// @ts-ignore
|
129
|
-
position,
|
130
|
-
positionElement,
|
131
|
-
selectionType,
|
132
|
-
showTimezone,
|
133
|
-
staticPosition,
|
134
|
-
yearRange,
|
135
|
-
required: false,
|
136
|
-
}, scrollContainer)
|
137
|
-
})
|
138
|
-
|
139
142
|
const iconWrapperClass = () => {
|
140
143
|
let base = 'cal_icon_wrapper'
|
141
144
|
if (dark) {
|
@@ -150,80 +153,84 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
150
153
|
return base
|
151
154
|
}
|
152
155
|
|
156
|
+
|
153
157
|
return (
|
154
158
|
<div
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
+
{...ariaProps}
|
160
|
+
{...dataProps}
|
161
|
+
className={classes}
|
162
|
+
id={id}
|
159
163
|
>
|
160
164
|
<div
|
161
|
-
|
162
|
-
|
163
|
-
|
165
|
+
{...inputAriaProps}
|
166
|
+
{...inputDataProps}
|
167
|
+
className="input_wrapper"
|
168
|
+
>
|
164
169
|
|
165
170
|
<Caption
|
166
|
-
|
167
|
-
|
171
|
+
className="pb_date_picker_kit_label"
|
172
|
+
text={hideLabel ? null : label}
|
168
173
|
/>
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
/>
|
181
|
-
|
182
|
-
{error && <Body
|
183
|
-
status="negative"
|
184
|
-
text={error}
|
185
|
-
variant={null}
|
186
|
-
/>
|
187
|
-
}
|
188
|
-
</div>
|
189
|
-
|
190
|
-
{!hideIcon &&
|
191
|
-
<div
|
192
|
-
className={iconWrapperClass()}
|
193
|
-
id={`cal-icon-${pickerId}`}
|
194
|
-
>
|
195
|
-
<Icon
|
196
|
-
className="cal_icon"
|
197
|
-
icon="calendar-alt"
|
198
|
-
/>
|
199
|
-
</div>
|
200
|
-
}
|
201
|
-
|
202
|
-
{hideIcon && inLine ?
|
203
|
-
<div>
|
204
|
-
<div
|
205
|
-
className={iconWrapperClass()}
|
206
|
-
id={`${pickerId}-icon-plus`}
|
207
|
-
>
|
208
|
-
<Icon
|
209
|
-
className="date-picker-plus-icon"
|
210
|
-
icon="plus"
|
211
|
-
/>
|
212
|
-
</div>
|
213
|
-
<div
|
214
|
-
className={iconWrapperClass()}
|
215
|
-
id={`${pickerId}-angle-down`}
|
216
|
-
>
|
217
|
-
<Icon
|
218
|
-
className="angle_down_icon"
|
219
|
-
icon="angle-down"
|
174
|
+
<>
|
175
|
+
<div className="date_picker_input_wrapper">
|
176
|
+
<input
|
177
|
+
autoComplete="off"
|
178
|
+
className="date_picker_input"
|
179
|
+
disabled={disableInput}
|
180
|
+
id={pickerId}
|
181
|
+
name={name}
|
182
|
+
onChange={inputOnChange}
|
183
|
+
placeholder={placeholder}
|
184
|
+
value={inputValue}
|
220
185
|
/>
|
186
|
+
|
187
|
+
{error &&
|
188
|
+
<Body
|
189
|
+
status="negative"
|
190
|
+
text={error}
|
191
|
+
variant={null}
|
192
|
+
/>
|
193
|
+
}
|
221
194
|
</div>
|
222
|
-
|
223
|
-
|
195
|
+
|
196
|
+
{!hideIcon &&
|
197
|
+
<div
|
198
|
+
className={iconWrapperClass()}
|
199
|
+
id={`cal-icon-${pickerId}`}
|
200
|
+
>
|
201
|
+
<Icon
|
202
|
+
className="cal_icon"
|
203
|
+
icon="calendar-alt"
|
204
|
+
/>
|
205
|
+
</div>
|
206
|
+
}
|
207
|
+
|
208
|
+
{hideIcon && inLine ?
|
209
|
+
<div>
|
210
|
+
<div
|
211
|
+
className={iconWrapperClass()}
|
212
|
+
id={`${pickerId}-icon-plus`}
|
213
|
+
>
|
214
|
+
<Icon
|
215
|
+
className="date-picker-plus-icon"
|
216
|
+
icon="plus"
|
217
|
+
/>
|
218
|
+
</div>
|
219
|
+
<div
|
220
|
+
className={iconWrapperClass()}
|
221
|
+
id={`${pickerId}-angle-down`}
|
222
|
+
>
|
223
|
+
<Icon
|
224
|
+
className="angle_down_icon"
|
225
|
+
icon="angle-down"
|
226
|
+
/>
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
: null
|
230
|
+
}
|
231
|
+
</>
|
224
232
|
</div>
|
225
233
|
</div>
|
226
234
|
)
|
227
235
|
}
|
228
|
-
|
229
236
|
export default DatePicker
|
@@ -20,6 +20,16 @@
|
|
20
20
|
placeholder: object.placeholder,
|
21
21
|
required: object.required,
|
22
22
|
}) %>
|
23
|
+
<% if object.selection_type == "quickpick" %>
|
24
|
+
<%= pb_rails("text_input", props: {
|
25
|
+
id: "#{object.start_date}-#{object.picker_id}",
|
26
|
+
name: object.start_date,
|
27
|
+
}) %>
|
28
|
+
<%= pb_rails("text_input", props: {
|
29
|
+
id: "#{object.end_date}-#{object.picker_id}",
|
30
|
+
name: object.end_date,
|
31
|
+
}) %>
|
32
|
+
<% end %>
|
23
33
|
<% end %>
|
24
34
|
<% if !object.hide_icon %>
|
25
35
|
<div
|
@@ -60,8 +70,26 @@
|
|
60
70
|
</div>
|
61
71
|
|
62
72
|
<%= javascript_tag do %>
|
73
|
+
if (<%= object.selection_type == "quickpick" %>) {
|
74
|
+
const startDate = document.getElementById("<%= object.start_date %>-<%= object.picker_id %>")
|
75
|
+
if (startDate) startDate.style.display = "none"
|
76
|
+
|
77
|
+
const endDate = document.getElementById("<%= object.end_date %>-<%= object.picker_id %>")
|
78
|
+
if (endDate) endDate.style.display = "none"
|
79
|
+
}
|
80
|
+
|
63
81
|
window.addEventListener("DOMContentLoaded", () => {
|
64
|
-
|
82
|
+
datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
|
83
|
+
|
84
|
+
if (<%= object.selection_type == "quickpick" %>) {
|
85
|
+
document.getElementById("<%= object.picker_id %>").addEventListener("change", ({ target }) => {
|
86
|
+
const startDate = document.getElementById("<%= object.start_date %>-<%= object.picker_id %>")
|
87
|
+
const endDate = document.getElementById("<%= object.end_date %>-<%= object.picker_id %>")
|
88
|
+
const splittedValue = target.value.split(" → ")
|
89
|
+
startDate.value = splittedValue[0]
|
90
|
+
endDate.value = splittedValue[1] ? splittedValue[1] : splittedValue[0]
|
91
|
+
})
|
92
|
+
}
|
65
93
|
})
|
66
94
|
<% end %>
|
67
|
-
<% end %>
|
95
|
+
<% end %>
|
@@ -19,6 +19,8 @@ module Playbook
|
|
19
19
|
default: []
|
20
20
|
prop :enable_time, type: Playbook::Props::Boolean,
|
21
21
|
default: false
|
22
|
+
prop :end_date, type: Playbook::Props::String,
|
23
|
+
default: "endDate"
|
22
24
|
prop :error, type: Playbook::Props::String
|
23
25
|
prop :format, type: Playbook::Props::String,
|
24
26
|
default: "m/d/Y"
|
@@ -43,20 +45,24 @@ module Playbook
|
|
43
45
|
required: true
|
44
46
|
prop :placeholder, type: Playbook::Props::String,
|
45
47
|
default: "Select Date"
|
46
|
-
prop :plugins,
|
47
|
-
|
48
|
-
|
48
|
+
prop :plugins, type: Playbook::Props::Boolean,
|
49
|
+
default: false,
|
50
|
+
deprecated: true
|
49
51
|
prop :position, type: Playbook::Props::String,
|
50
52
|
default: "auto"
|
51
53
|
prop :position_element, type: Playbook::Props::String
|
52
54
|
prop :scroll_container, type: Playbook::Props::String
|
53
55
|
prop :selection_type, type: Playbook::Props::Enum,
|
54
|
-
values: %w[week month none],
|
56
|
+
values: %w[week month quickpick none],
|
55
57
|
default: "none"
|
56
58
|
prop :show_timezone, type: Playbook::Props::Boolean,
|
57
59
|
default: false
|
60
|
+
prop :start_date, type: Playbook::Props::String,
|
61
|
+
default: "startDate"
|
58
62
|
prop :static_position, type: Playbook::Props::Boolean,
|
59
63
|
default: true
|
64
|
+
prop :this_ranges_end_today, type: Playbook::Props::Boolean,
|
65
|
+
default: false
|
60
66
|
prop :required, type: Playbook::Props::Boolean,
|
61
67
|
default: false
|
62
68
|
prop :year_range, type: Playbook::Props::Array,
|
@@ -88,6 +94,7 @@ module Playbook
|
|
88
94
|
selectionType: selection_type,
|
89
95
|
showTimezone: show_timezone,
|
90
96
|
staticPosition: static_position,
|
97
|
+
thisRangesEndToday: this_ranges_end_today,
|
91
98
|
yearRange: year_range,
|
92
99
|
}.to_json.html_safe
|
93
100
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/* eslint-disable no-console */
|
2
2
|
import React from 'react'
|
3
|
+
import moment from 'moment'
|
3
4
|
import { fireEvent, render, screen, waitFor, within } from '../utilities/test-utils'
|
4
5
|
|
5
6
|
import DatePicker from './_date_picker'
|
@@ -10,7 +11,6 @@ import { getTimezoneText } from './plugins/timeSelect'
|
|
10
11
|
jest.setSystemTime(new Date('01/01/2020'));
|
11
12
|
const DEFAULT_DATE = new Date()
|
12
13
|
|
13
|
-
|
14
14
|
describe('DatePicker Kit', () => {
|
15
15
|
beforeEach(() => {
|
16
16
|
jest.spyOn(console, 'error').mockImplementation(() => { });
|
@@ -158,4 +158,47 @@ describe('DatePicker Kit', () => {
|
|
158
158
|
expect(input).toHaveValue('01/01/2020 at 12:00 PM')
|
159
159
|
})
|
160
160
|
})
|
161
|
+
test('shows DatePicker QuickPick dropdown and adds correct date to input', async () => {
|
162
|
+
const testId = 'datepicker-quick-pick'
|
163
|
+
render(
|
164
|
+
<DatePicker
|
165
|
+
allowInput
|
166
|
+
data={{ testid: testId }}
|
167
|
+
mode="range"
|
168
|
+
pickerId="date-picker-quick-pick"
|
169
|
+
placeholder="mm/dd/yyyy → mm/dd/yyyy"
|
170
|
+
selectionType="quickpick"
|
171
|
+
/>
|
172
|
+
)
|
173
|
+
|
174
|
+
const kit = screen.getByTestId(testId)
|
175
|
+
const input = within(kit).getByPlaceholderText('mm/dd/yyyy → mm/dd/yyyy')
|
176
|
+
|
177
|
+
fireEvent(
|
178
|
+
input,
|
179
|
+
new MouseEvent('click', {
|
180
|
+
bubbles: true,
|
181
|
+
cancelable: true,
|
182
|
+
}),
|
183
|
+
)
|
184
|
+
const today = within(kit).getByText('Today')
|
185
|
+
const thisYear = within(kit).getByText('This year')
|
186
|
+
await waitFor(() => {
|
187
|
+
expect(today).toBeInTheDocument()
|
188
|
+
expect(thisYear).toBeInTheDocument()
|
189
|
+
})
|
190
|
+
|
191
|
+
fireEvent(
|
192
|
+
thisYear,
|
193
|
+
new MouseEvent('click', {
|
194
|
+
bubbles: true,
|
195
|
+
cancelable: true,
|
196
|
+
}),
|
197
|
+
)
|
198
|
+
|
199
|
+
await waitFor(() => {
|
200
|
+
expect(input).toHaveValue(moment().startOf('year').format('MM/DD/YYYY') + " → " + moment().format('MM/DD/YYYY'))
|
201
|
+
})
|
202
|
+
|
203
|
+
})
|
161
204
|
})
|
@@ -3,6 +3,7 @@ import { BaseOptions } from 'flatpickr/dist/types/options'
|
|
3
3
|
import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect'
|
4
4
|
import weekSelect from "flatpickr/dist/plugins/weekSelect/weekSelect"
|
5
5
|
import timeSelectPlugin from './plugins/timeSelect'
|
6
|
+
import quickPickPlugin from './plugins/quickPick'
|
6
7
|
|
7
8
|
const getPositionElement = (element: string | Element) => {
|
8
9
|
return (typeof element === 'string') ? document.querySelectorAll(element)[0] : element
|
@@ -19,10 +20,11 @@ type DatePickerConfig = {
|
|
19
20
|
hideIcon?: boolean;
|
20
21
|
inLine?: boolean,
|
21
22
|
onChange: (dateStr: string, selectedDates: Date[]) => void,
|
23
|
+
selectionType?: "month" | "week" | "quickpick" | "",
|
22
24
|
onClose: (dateStr: Date[] | string, selectedDates: Date[] | string) => void,
|
23
|
-
selectionType?: "month" | "week" | "",
|
24
25
|
showTimezone?: boolean,
|
25
26
|
staticPosition: boolean,
|
27
|
+
thisRangesEndToday?: boolean,
|
26
28
|
timeCaption?: string,
|
27
29
|
timeFormat?: string,
|
28
30
|
yearRange: number[]
|
@@ -51,6 +53,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
51
53
|
selectionType,
|
52
54
|
showTimezone,
|
53
55
|
staticPosition = true,
|
56
|
+
thisRangesEndToday = false,
|
54
57
|
timeCaption = 'Select Time',
|
55
58
|
timeFormat = 'at h:i K',
|
56
59
|
yearRange,
|
@@ -89,19 +92,24 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
89
92
|
}
|
90
93
|
}
|
91
94
|
|
92
|
-
const setPlugins = () => {
|
93
|
-
|
95
|
+
const setPlugins = (thisRangesEndToday: boolean) => {
|
96
|
+
const pluginList = []
|
94
97
|
|
95
98
|
// month and week selection
|
96
99
|
if (selectionType === "month" || plugins.length > 0) {
|
97
100
|
pluginList.push(monthSelectPlugin({ shorthand: true, dateFormat: 'F Y', altFormat: 'F Y' }))
|
98
101
|
} else if ( selectionType === "week") {
|
99
102
|
pluginList.push(weekSelect())
|
103
|
+
|
104
|
+
} else if (selectionType === "quickpick") {
|
105
|
+
//------- QUICKPICK VARIANT PLUGIN -------------//
|
106
|
+
pluginList.push(quickPickPlugin(thisRangesEndToday))
|
100
107
|
}
|
101
108
|
|
102
109
|
// time selection
|
103
110
|
if (enableTime) pluginList.push(timeSelectPlugin({ caption: timeCaption, showTimezone: showTimezone}))
|
104
111
|
|
112
|
+
|
105
113
|
return pluginList
|
106
114
|
}
|
107
115
|
|
@@ -144,6 +152,9 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
144
152
|
},
|
145
153
|
] : disabledParser(),
|
146
154
|
enableTime,
|
155
|
+
locale: {
|
156
|
+
rangeSeparator: ' → '
|
157
|
+
},
|
147
158
|
maxDate,
|
148
159
|
minDate,
|
149
160
|
mode,
|
@@ -164,17 +175,40 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
164
175
|
onYearChange: [() => {
|
165
176
|
yearChangeHook()
|
166
177
|
}],
|
167
|
-
plugins: setPlugins(),
|
178
|
+
plugins: setPlugins(thisRangesEndToday),
|
168
179
|
position,
|
169
180
|
positionElement: getPositionElement(positionElement),
|
170
181
|
prevArrow: '<i class="far fa-angle-left"></i>',
|
171
182
|
static: staticPosition,
|
172
183
|
})
|
173
184
|
|
185
|
+
|
174
186
|
// ===========================================================
|
175
187
|
// Additional JS Functionality |
|
176
188
|
// ===========================================================
|
177
189
|
|
190
|
+
// opens flatpickr instance when calander icon is clicked so we can have a hover state on icon
|
191
|
+
// window.addEventListener("DOMContentLoaded", (event) => {
|
192
|
+
// event.preventDefault();
|
193
|
+
// function attachIconClickHandler() {
|
194
|
+
// const variantArr = document.querySelectorAll(`#cal-icon-${pickerId}`)
|
195
|
+
// if (!variantArr) {
|
196
|
+
// setTimeout(attachIconClickHandler, 100);
|
197
|
+
// return;
|
198
|
+
// }
|
199
|
+
|
200
|
+
// const instance = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
201
|
+
// variantArr.forEach((icon) => {
|
202
|
+
// icon.addEventListener("click", function(event) {
|
203
|
+
// event.preventDefault();
|
204
|
+
// instance.open()
|
205
|
+
// });
|
206
|
+
// })
|
207
|
+
// }
|
208
|
+
|
209
|
+
// attachIconClickHandler();
|
210
|
+
// });
|
211
|
+
|
178
212
|
// Assign dynamically sourced flatpickr instance to variable
|
179
213
|
const picker = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
180
214
|
picker.innerContainer.parentElement.id = `cal-${pickerId}`
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import DatePicker from '../_date_picker'
|
4
|
+
|
5
|
+
const DatePickerQuickPick = (props) => (
|
6
|
+
<div>
|
7
|
+
<DatePicker
|
8
|
+
allowInput
|
9
|
+
mode="range"
|
10
|
+
pickerId="date-picker-quick-pick"
|
11
|
+
placeholder="mm/dd/yyyy → mm/dd/yyyy"
|
12
|
+
selectionType="quickpick"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
17
|
+
|
18
|
+
export default DatePickerQuickPick
|
@@ -8,6 +8,7 @@ examples:
|
|
8
8
|
- date_picker_input: Input Field
|
9
9
|
- date_picker_label: Label
|
10
10
|
- date_picker_range: Range
|
11
|
+
- date_picker_quick_pick: Range (Quick Pick)
|
11
12
|
- date_picker_format: Format
|
12
13
|
- date_picker_disabled: Disabled Dates
|
13
14
|
- date_picker_min_max: Min Max
|
@@ -33,6 +34,7 @@ examples:
|
|
33
34
|
- date_picker_on_change: onChange
|
34
35
|
- date_picker_on_close: onClose
|
35
36
|
- date_picker_range: Range
|
37
|
+
- date_picker_quick_pick: Range (Quick Pick)
|
36
38
|
- date_picker_format: Format
|
37
39
|
- date_picker_disabled: Disabled Dates
|
38
40
|
- date_picker_min_max: Min Max
|
@@ -19,4 +19,5 @@ export { default as DatePickerWeek } from './_date_picker_week.jsx'
|
|
19
19
|
export { default as DatePickerPositions } from './_date_picker_positions.jsx'
|
20
20
|
export { default as DatePickerPositionsElement } from './_date_picker_positions_element.jsx'
|
21
21
|
export { default as DatePickerAllowInput } from './_date_picker_allow_input'
|
22
|
-
export { default as
|
22
|
+
export { default as DatePickerQuickPick } from './_date_picker_quick_pick'
|
23
|
+
export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
|