playbook_ui 12.26.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown794 → 12.26.0.pre.alpha.alphafix810

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 360413b8af66e57c96b50f7a3d42e090570ce350ffaa9ec7d316ce5f3cffd9df
4
- data.tar.gz: d96327fc8f503da031ffb1cfe9d5dfde31551860650d0ae01a0cc5e249fa5114
3
+ metadata.gz: 271bcae8bfc3bbad66487582748a9c6913456fdbb753930c4ae347592356c968
4
+ data.tar.gz: 3c1ecdc7a8ef45fb406d13e9c26336a1d4f1c690ecf188ffa629d9dcbb076559
5
5
  SHA512:
6
- metadata.gz: 5350397053b9dba7747150cf2f3a85d074456ecd0afbc70ebe68175c53c7840983427d4c38daf97423e3d09136ce0db11ad9445e38dbd49dcd46f4060f59cb4a
7
- data.tar.gz: 4422d0c952be46f567154bcd58037fb66763aa44cddfc47179de84b62d335083b055ac0edf97b616674e7b5861ff2d6f18b70ca1b41cc12e2ecf22df1be1a89a
6
+ metadata.gz: '08ae24ed193cc83d2d58b670103cd21f30198cb2cd399479795a194bc6968452a7e9e04cd8bc25aa27e029545fec02879b72b2810530b0b3d54dbb5dde32442e'
7
+ data.tar.gz: 295905c940167fae71cfc5e1842441d215db993973f141ac03ee95af119e9a187e83f713204b8a2d8da3a36d349b88be4cd6a85ee94f4ab984a1af35f7cb4542
@@ -6,7 +6,6 @@
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";
10
9
 
11
10
  [class^=pb_date_picker_kit] {
12
11
  .input_wrapper {
@@ -27,32 +26,7 @@
27
26
  @include transition_default;
28
27
  border-color: $primary;
29
28
  }
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
45
29
  }
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
56
30
  }
57
31
 
58
32
  .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?: string,
33
+ inputValue?: any,
34
34
  label?: string,
35
35
  maxDate: string,
36
36
  minDate: string,
@@ -39,10 +39,9 @@ type DatePickerProps = {
39
39
  placeholder?: string,
40
40
  positionElement?: HTMLElement | null,
41
41
  scrollContainer?: string,
42
- selectionType?: "month" | "week"| "quickpick",
42
+ selectionType?: "month" | "week",
43
43
  showTimezone?: boolean,
44
44
  staticPosition: boolean,
45
- thisRangesEndToday?: boolean,
46
45
  timeFormat?: string,
47
46
  type?: string,
48
47
  yearRange?: number[],
@@ -89,7 +88,6 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
89
88
  selectionType = '',
90
89
  showTimezone = false,
91
90
  staticPosition = true,
92
- thisRangesEndToday = false,
93
91
  yearRange = [1900, 2100],
94
92
  } = props
95
93
 
@@ -98,47 +96,46 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
98
96
  const inputAriaProps = buildAriaProps(inputAria)
99
97
  const inputDataProps = buildDataProps(inputData)
100
98
 
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
- })
131
99
  const filteredProps = {...props}
132
100
  delete filteredProps?.position
133
101
 
134
102
  const classes = classnames(
135
103
  buildCss('pb_date_picker_kit'),
136
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
137
104
  //@ts-ignore
138
105
  globalProps(filteredProps),
139
106
  error ? 'error' : null,
140
107
  className
141
108
  )
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
+
142
139
  const iconWrapperClass = () => {
143
140
  let base = 'cal_icon_wrapper'
144
141
  if (dark) {
@@ -153,84 +150,80 @@ useEffect(() => {
153
150
  return base
154
151
  }
155
152
 
156
-
157
153
  return (
158
154
  <div
159
- {...ariaProps}
160
- {...dataProps}
161
- className={classes}
162
- id={id}
155
+ {...ariaProps}
156
+ {...dataProps}
157
+ className={classes}
158
+ id={id}
163
159
  >
164
160
  <div
165
- {...inputAriaProps}
166
- {...inputDataProps}
167
- className="input_wrapper"
168
- >
161
+ {...inputAriaProps}
162
+ {...inputDataProps}
163
+ className="input_wrapper">
169
164
 
170
165
  <Caption
171
- className="pb_date_picker_kit_label"
172
- text={hideLabel ? null : label}
166
+ className="pb_date_picker_kit_label"
167
+ text={hideLabel ? null : label}
173
168
  />
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}
185
- />
186
169
 
187
- {error &&
188
- <Body
189
- status="negative"
190
- text={error}
191
- variant={null}
192
- />
193
- }
194
- </div>
170
+ <div className="date_picker_input_wrapper">
171
+ <input
172
+ autoComplete="off"
173
+ className="date_picker_input"
174
+ disabled={disableInput}
175
+ id={pickerId}
176
+ name={name}
177
+ onChange={inputOnChange}
178
+ placeholder={placeholder}
179
+ value={inputValue}
180
+ />
181
+
182
+ {error && <Body
183
+ status="negative"
184
+ text={error}
185
+ variant={null}
186
+ />
187
+ }
188
+ </div>
195
189
 
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
- </>
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"
220
+ />
221
+ </div>
222
+ </div>
223
+ : null}
232
224
  </div>
233
225
  </div>
234
226
  )
235
227
  }
228
+
236
229
  export default DatePicker
@@ -20,16 +20,6 @@
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 %>
33
23
  <% end %>
34
24
  <% if !object.hide_icon %>
35
25
  <div
@@ -70,26 +60,8 @@
70
60
  </div>
71
61
 
72
62
  <%= 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
-
81
63
  window.addEventListener("DOMContentLoaded", () => {
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
- }
64
+ datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
93
65
  })
94
66
  <% end %>
95
- <% end %>
67
+ <% end %>
@@ -19,8 +19,6 @@ 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"
24
22
  prop :error, type: Playbook::Props::String
25
23
  prop :format, type: Playbook::Props::String,
26
24
  default: "m/d/Y"
@@ -45,24 +43,20 @@ module Playbook
45
43
  required: true
46
44
  prop :placeholder, type: Playbook::Props::String,
47
45
  default: "Select Date"
48
- prop :plugins, type: Playbook::Props::Boolean,
49
- default: false,
50
- deprecated: true
46
+ prop :plugins, type: Playbook::Props::Boolean,
47
+ default: false,
48
+ deprecated: true
51
49
  prop :position, type: Playbook::Props::String,
52
50
  default: "auto"
53
51
  prop :position_element, type: Playbook::Props::String
54
52
  prop :scroll_container, type: Playbook::Props::String
55
53
  prop :selection_type, type: Playbook::Props::Enum,
56
- values: %w[week month quickpick none],
54
+ values: %w[week month none],
57
55
  default: "none"
58
56
  prop :show_timezone, type: Playbook::Props::Boolean,
59
57
  default: false
60
- prop :start_date, type: Playbook::Props::String,
61
- default: "startDate"
62
58
  prop :static_position, type: Playbook::Props::Boolean,
63
59
  default: true
64
- prop :this_ranges_end_today, type: Playbook::Props::Boolean,
65
- default: false
66
60
  prop :required, type: Playbook::Props::Boolean,
67
61
  default: false
68
62
  prop :year_range, type: Playbook::Props::Array,
@@ -94,7 +88,6 @@ module Playbook
94
88
  selectionType: selection_type,
95
89
  showTimezone: show_timezone,
96
90
  staticPosition: static_position,
97
- thisRangesEndToday: this_ranges_end_today,
98
91
  yearRange: year_range,
99
92
  }.to_json.html_safe
100
93
  end
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-console */
2
2
  import React from 'react'
3
- import moment from 'moment'
4
3
  import { fireEvent, render, screen, waitFor, within } from '../utilities/test-utils'
5
4
 
6
5
  import DatePicker from './_date_picker'
@@ -11,6 +10,7 @@ import { getTimezoneText } from './plugins/timeSelect'
11
10
  jest.setSystemTime(new Date('01/01/2020'));
12
11
  const DEFAULT_DATE = new Date()
13
12
 
13
+
14
14
  describe('DatePicker Kit', () => {
15
15
  beforeEach(() => {
16
16
  jest.spyOn(console, 'error').mockImplementation(() => { });
@@ -158,47 +158,4 @@ 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
- })
204
161
  })
@@ -3,7 +3,6 @@ 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'
7
6
 
8
7
  const getPositionElement = (element: string | Element) => {
9
8
  return (typeof element === 'string') ? document.querySelectorAll(element)[0] : element
@@ -20,11 +19,10 @@ type DatePickerConfig = {
20
19
  hideIcon?: boolean;
21
20
  inLine?: boolean,
22
21
  onChange: (dateStr: string, selectedDates: Date[]) => void,
23
- selectionType?: "month" | "week" | "quickpick" | "",
24
22
  onClose: (dateStr: Date[] | string, selectedDates: Date[] | string) => void,
23
+ selectionType?: "month" | "week" | "",
25
24
  showTimezone?: boolean,
26
25
  staticPosition: boolean,
27
- thisRangesEndToday?: boolean,
28
26
  timeCaption?: string,
29
27
  timeFormat?: string,
30
28
  yearRange: number[]
@@ -53,7 +51,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
53
51
  selectionType,
54
52
  showTimezone,
55
53
  staticPosition = true,
56
- thisRangesEndToday = false,
57
54
  timeCaption = 'Select Time',
58
55
  timeFormat = 'at h:i K',
59
56
  yearRange,
@@ -92,24 +89,19 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
92
89
  }
93
90
  }
94
91
 
95
- const setPlugins = (thisRangesEndToday: boolean) => {
96
- const pluginList = []
92
+ const setPlugins = () => {
93
+ let pluginList = []
97
94
 
98
95
  // month and week selection
99
96
  if (selectionType === "month" || plugins.length > 0) {
100
97
  pluginList.push(monthSelectPlugin({ shorthand: true, dateFormat: 'F Y', altFormat: 'F Y' }))
101
98
  } else if ( selectionType === "week") {
102
99
  pluginList.push(weekSelect())
103
-
104
- } else if (selectionType === "quickpick") {
105
- //------- QUICKPICK VARIANT PLUGIN -------------//
106
- pluginList.push(quickPickPlugin(thisRangesEndToday))
107
100
  }
108
101
 
109
102
  // time selection
110
103
  if (enableTime) pluginList.push(timeSelectPlugin({ caption: timeCaption, showTimezone: showTimezone}))
111
104
 
112
-
113
105
  return pluginList
114
106
  }
115
107
 
@@ -152,9 +144,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
152
144
  },
153
145
  ] : disabledParser(),
154
146
  enableTime,
155
- locale: {
156
- rangeSeparator: ' → '
157
- },
158
147
  maxDate,
159
148
  minDate,
160
149
  mode,
@@ -175,40 +164,17 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
175
164
  onYearChange: [() => {
176
165
  yearChangeHook()
177
166
  }],
178
- plugins: setPlugins(thisRangesEndToday),
167
+ plugins: setPlugins(),
179
168
  position,
180
169
  positionElement: getPositionElement(positionElement),
181
170
  prevArrow: '<i class="far fa-angle-left"></i>',
182
171
  static: staticPosition,
183
172
  })
184
173
 
185
-
186
174
  // ===========================================================
187
175
  // Additional JS Functionality |
188
176
  // ===========================================================
189
177
 
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
-
212
178
  // Assign dynamically sourced flatpickr instance to variable
213
179
  const picker = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
214
180
  picker.innerContainer.parentElement.id = `cal-${pickerId}`
@@ -8,7 +8,6 @@ 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)
12
11
  - date_picker_format: Format
13
12
  - date_picker_disabled: Disabled Dates
14
13
  - date_picker_min_max: Min Max
@@ -34,7 +33,6 @@ examples:
34
33
  - date_picker_on_change: onChange
35
34
  - date_picker_on_close: onClose
36
35
  - date_picker_range: Range
37
- - date_picker_quick_pick: Range (Quick Pick)
38
36
  - date_picker_format: Format
39
37
  - date_picker_disabled: Disabled Dates
40
38
  - date_picker_min_max: Min Max
@@ -19,5 +19,4 @@ 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 DatePickerQuickPick } from './_date_picker_quick_pick'
23
- export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
22
+ export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
@@ -1,4 +1,3 @@
1
- @import "../../tokens/colors";
2
1
  // Calendar Icon Styles
3
2
  .cal_icon_wrapper {
4
3
  pointer-events: none;
@@ -14,8 +13,8 @@
14
13
  padding-left: $space_sm - 1;
15
14
  color: $text_lt_light;
16
15
  @media (hover: hover) {
17
- &:hover{
18
- background-color: rgba($focus_input_light,$opacity_5);
16
+ &:hover {
17
+ cursor: pointer;
19
18
  }
20
19
  }
21
20
  &.dark {
@@ -87,7 +87,7 @@ const NavItem = (props: NavItemProps) => {
87
87
  <span className="pb_nav_list_item_text">
88
88
  {text || children}
89
89
  </span>
90
-
90
+
91
91
  {iconRight &&
92
92
  <div
93
93
  className="pb_nav_list_item_icon_section"
@@ -44,7 +44,7 @@
44
44
  &[class*=_active] [class*=_link] {
45
45
  @include pb_title_4;
46
46
  color: $primary;
47
- letter-spacing: normal;
47
+ letter-spacing: normal;
48
48
  }
49
49
  }
50
50
  }