playbook_ui 13.13.0.pre.alpha.play10221678 → 13.13.0

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: 930c0e3d2587afad1b9ea3d50a4a80e37c9c2772ef0a9b12eb6499831bbbcbb5
4
- data.tar.gz: 9d8fe14193b9826133a1b47709975b5165aa54b44437feae9aa5eaa244879cfe
3
+ metadata.gz: '098c0dca78160e891e377c26ed0dff2b5b2528e0676f779c630fe54bed26aed8'
4
+ data.tar.gz: 4c58eab597c52277785c420a8c9d913d2de6911a57523612df5b52f76105b821
5
5
  SHA512:
6
- metadata.gz: cd5afb9fe7f8b9b3fcf226049a50ce83df67baddceb0bd22ccbbea5d8db2ec661390be9f7b5e9229da84fcddd4dba909167728b849a9d91215343577b8f9a16e
7
- data.tar.gz: 271d69aee52700ec882a56a7f48fe02b6cac9b2d83a3ea3e0c465b75a6dfc501356c0ee080a3f6fb2a178f1697ee05e38c6737c393a0ea73f414037902a9addf
6
+ metadata.gz: f085821c22ff14c787f4b1d9aa1d12f284d94773b1dafaa2b0b01b815db7cabef337d275d98a78418700eedd20bfa6acf49408d14b619d42a619d19ee6136ee1
7
+ data.tar.gz: 63e2f1a1aa8b5cef8ca6235ab4999f74995a9c68bfa6e4026a9d797470ab1e9419cc0287967b98fd82c51ce3bfedc53a9029e4ee4aa545e37d071c182215fcd9
@@ -13,7 +13,6 @@ type DatePickerProps = {
13
13
  allowInput?: boolean,
14
14
  aria?: { [key: string]: string },
15
15
  className?: string,
16
- customQuickPickDates: { override: boolean, dates: any[] },
17
16
  dark?: boolean,
18
17
  data?: { [key: string]: string },
19
18
  defaultDate?: string,
@@ -57,7 +56,6 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
57
56
  allowInput = false,
58
57
  aria = {},
59
58
  className,
60
- customQuickPickDates,
61
59
  dark = false,
62
60
  data = {},
63
61
  defaultDate = '',
@@ -106,7 +104,6 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
106
104
  useEffect(() => {
107
105
  datePickerHelper({
108
106
  allowInput,
109
- customQuickPickDates,
110
107
  defaultDate,
111
108
  disableDate,
112
109
  disableRange,
@@ -5,8 +5,6 @@ module Playbook
5
5
  class DatePicker < Playbook::KitBase
6
6
  prop :allow_input, type: Playbook::Props::Boolean,
7
7
  default: false
8
- prop :custom_quick_pick_dates, type: Playbook::Props::HashProp,
9
- default: {}
10
8
  prop :dark, type: Playbook::Props::Boolean,
11
9
  default: false
12
10
  prop :default_date, type: Playbook::Props::String,
@@ -81,7 +79,6 @@ module Playbook
81
79
  def date_picker_config
82
80
  {
83
81
  allowInput: allow_input,
84
- customQuickPickDates: custom_quick_pick_dates,
85
82
  defaultDate: default_date,
86
83
  disableDate: disable_date,
87
84
  disableRange: disable_range,
@@ -11,7 +11,6 @@ const getPositionElement = (element: string | Element) => {
11
11
 
12
12
  type DatePickerConfig = {
13
13
  closeOnSelect?: boolean,
14
- customQuickPickDates: { override: boolean, dates: any[] },
15
14
  disableDate?: number[],
16
15
  disableRange?: number[],
17
16
  disableWeekdays?: number[],
@@ -35,7 +34,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
35
34
  const {
36
35
  allowInput,
37
36
  closeOnSelect = true,
38
- customQuickPickDates = { override: true, dates: [] },
39
37
  defaultDate,
40
38
  disableDate,
41
39
  disableRange,
@@ -123,26 +121,27 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
123
121
  }
124
122
  }
125
123
 
126
- const setPlugins = (thisRangesEndToday: boolean, customQuickPickDates: any) => {
124
+ const setPlugins = (thisRangesEndToday: boolean) => {
127
125
  const pluginList = []
128
-
126
+
129
127
  // month and week selection
130
128
  if (selectionType === "month" || plugins.length > 0) {
131
129
  pluginList.push(monthSelectPlugin({ shorthand: true, dateFormat: 'F Y', altFormat: 'F Y' }))
132
130
  } else if ( selectionType === "week") {
133
131
  pluginList.push(weekSelect())
134
-
132
+
135
133
  } else if (selectionType === "quickpick") {
136
- //------- QUICKPICK VARIANT PLUGIN -------------//
137
- pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates))
134
+ //------- QUICKPICK VARIANT PLUGIN -------------//
135
+ pluginList.push(quickPickPlugin(thisRangesEndToday))
138
136
  }
139
-
137
+
140
138
  // time selection
141
139
  if (enableTime) pluginList.push(timeSelectPlugin({ caption: timeCaption, showTimezone: showTimezone}))
142
-
140
+
141
+
143
142
  return pluginList
144
143
  }
145
-
144
+
146
145
  const getDateFormat = () => {
147
146
  return enableTime ? `${format} ${timeFormat}` : format
148
147
  }
@@ -182,7 +181,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
182
181
  onYearChange: [() => {
183
182
  yearChangeHook()
184
183
  }],
185
- plugins: setPlugins(thisRangesEndToday, customQuickPickDates),
184
+ plugins: setPlugins(thisRangesEndToday),
186
185
  position,
187
186
  positionElement: getPositionElement(positionElement),
188
187
  prevArrow: '<i class="far fa-angle-left"></i>',
@@ -1,5 +1,5 @@
1
- import React from "react"
2
- import DatePicker from "../_date_picker"
1
+ import React from 'react'
2
+ import DatePicker from '../_date_picker'
3
3
 
4
4
  const DatePickerQuickPickReact = (props) => (
5
5
  <>
@@ -10,8 +10,6 @@ examples:
10
10
  - date_picker_range: Range
11
11
  - date_picker_quick_pick_rails: Range (Quick Pick)
12
12
  - date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
13
- - date_picker_quick_pick_custom: Custom Quick Pick Dates
14
- - date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
15
13
  - date_picker_format: Format
16
14
  - date_picker_disabled: Disabled Dates
17
15
  - date_picker_min_max: Min Max
@@ -39,8 +37,6 @@ examples:
39
37
  - date_picker_range: Range
40
38
  - date_picker_quick_pick_react: Range (Quick Pick)
41
39
  - date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
42
- - date_picker_quick_pick_custom: Custom Quick Pick Dates
43
- - date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
44
40
  - date_picker_format: Format
45
41
  - date_picker_disabled: Disabled Dates
46
42
  - date_picker_min_max: Min Max
@@ -22,5 +22,3 @@ export { default as DatePickerAllowInput } from './_date_picker_allow_input'
22
22
  export { default as DatePickerQuickPickReact } from './_date_picker_quick_pick_react'
23
23
  export { default as DatePickerQuickPickRangeLimit } from './_date_picker_quick_pick_range_limit'
24
24
  export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
25
- export { default as DatePickerQuickPickCustom } from './_date_picker_quick_pick_custom'
26
- export { default as DatePickerQuickPickCustomOverride } from './_date_picker_quick_pick_custom_override'
@@ -19,14 +19,9 @@ type pluginDataType = {
19
19
  rangesButtons: [] | any,
20
20
  }
21
21
 
22
- type customQuickPickDatesType = {
23
- override: boolean,
24
- dates: { label: string, value: string[] | { timePeriod: string, amount: number } }[],
25
- }
26
-
27
22
  let activeLabel = ""
28
23
 
29
- const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: customQuickPickDatesType | undefined) => {
24
+ const quickPickPlugin = (thisRangesEndToday: boolean) => {
30
25
  return function (fp: FpTypes & any): any {
31
26
  const today = new Date()
32
27
  const yesterday = DateTime.getYesterdayDate(new Date())
@@ -51,38 +46,8 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
51
46
  const lastYearStartDate = DateTime.getPreviousYearStartDate(new Date())
52
47
  const lastYearEndDate = DateTime.getPreviousYearEndDate(new Date())
53
48
 
54
- const calculateDateRange = (timePeriod: string, amount: number): Date[] => {
55
- const endDate = new Date();
56
- let startDate = new Date();
57
-
58
- switch (timePeriod) {
59
- case 'days':
60
- startDate.setDate(endDate.getDate() - amount);
61
- break;
62
- case 'weeks':
63
- startDate.setDate(endDate.getDate() - (amount * 7));
64
- break;
65
- case 'months':
66
- startDate.setMonth(endDate.getMonth() - amount);
67
- break;
68
- case 'quarters':
69
- startDate.setMonth(endDate.getMonth() - (amount * 3));
70
- break;
71
- case 'years':
72
- startDate.setFullYear(endDate.getFullYear() - amount);
73
- break;
74
- default:
75
- throw new Error('Invalid time period');
76
- }
77
- return [startDate, endDate];
78
- };
79
-
80
-
81
- type rangesType = {
82
- [key: string]: Date[]
83
- };
84
-
85
- let ranges: rangesType = {
49
+ // variable that holds the ranges available
50
+ const ranges = {
86
51
  'Today': [today, today],
87
52
  'Yesterday': [yesterday, yesterday],
88
53
  'This week': [thisWeekStartDate, thisWeekEndDate],
@@ -93,47 +58,16 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
93
58
  'Last month': [lastMonthStartDate, lastMonthEndDate],
94
59
  'Last quarter': [lastQuarterStartDate, lastQuarterEndDate],
95
60
  'Last year': [lastYearStartDate, lastYearEndDate]
96
- };
97
-
98
-
99
- if (customQuickPickDates && Object.keys(customQuickPickDates).length !== 0) {
100
- if (customQuickPickDates.dates.length && customQuickPickDates.override === false) {
101
- customQuickPickDates.dates.forEach((item) => {
102
- if (Array.isArray(item.value)) {
103
- ranges[item.label] = item.value.map((dateStr: string) => new Date(dateStr));
104
- } else {
105
- ranges[item.label] = calculateDateRange(
106
- item.value.timePeriod,
107
- item.value.amount
108
- )
109
- }
110
- })
111
- } else if(customQuickPickDates.dates.length && customQuickPickDates.override !== false) {
112
- ranges = {}
113
- customQuickPickDates.dates.forEach((item) => {
114
- if (Array.isArray(item.value)) {
115
- ranges[item.label] = item.value.map((dateStr: string) => new Date(dateStr));
116
- } else {
117
- ranges[item.label] = calculateDateRange(
118
- item.value.timePeriod,
119
- item.value.amount
120
- )
121
- }
122
- })
123
- }
124
61
  }
125
62
 
126
-
127
63
  // creating the ul element for the nav dropdown and giving it classnames
128
64
  const rangesNav = document.createElement('ul');
129
65
 
130
-
131
66
  // creating the pluginData object that will hold the properties of this plugin
132
67
  const pluginData: pluginDataType = {
133
68
  ranges: ranges,
134
69
  rangesNav: rangesNav,
135
70
  rangesButtons: [],
136
-
137
71
  };
138
72
 
139
73
  /**