playbook_ui 14.8.0.pre.rc.5 → 14.8.0.pre.rc.6
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_helper.ts +1 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.html.erb +42 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.jsx +44 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.md +1 -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 +1 -0
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +17 -1
- data/app/pb_kits/playbook/utilities/_hover.scss +27 -29
- data/app/pb_kits/playbook/utilities/globalProps.ts +2 -2
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +79 -0
- data/dist/chunks/{_typeahead-DEskmS_o.js → _typeahead-DM5bD2ck.js} +2 -2
- data/dist/chunks/{_weekday_stacked-f4faf8xD.js → _weekday_stacked-RuOgC2uD.js} +1 -1
- data/dist/chunks/{lib-DpxYMiKe.js → lib-GRGYd9YR.js} +1 -1
- data/dist/chunks/{pb_form_validation-LqRlnmi6.js → pb_form_validation-CS6rgdtE.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/hover.rb +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d627b06d309a6c7d0c0daa7237d7e6b367a10a02b4c838ea24b4fe636efc5fb5
|
4
|
+
data.tar.gz: c7d1ab8399cfde8133b8120e3476ba4abf1c4f4ef2eb3af0427e49723aa4648f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cebda480fd5a9d3ee6f4e3a54948771126b478622fc12aefc524d818616b28625546a2673e08c2b2229c6396c6b61e7bd613c6d57aa7e2d11e97b5c7414a00d2
|
7
|
+
data.tar.gz: d2bf56befdf4788aaeeec043d775a33d6686b5c18b9c059455f281ac3d43f38dd12ea8d02a54355327b1e3982ff0722c06f602e061b892ea23422ac845c79892
|
@@ -143,7 +143,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
143
143
|
|
144
144
|
} else if (selectionType === "quickpick") {
|
145
145
|
//------- QUICKPICK VARIANT PLUGIN -------------//
|
146
|
-
pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates))
|
146
|
+
pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates, defaultDate as string))
|
147
147
|
}
|
148
148
|
|
149
149
|
// time selection
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= pb_rails("date_picker", props: {
|
2
|
+
allow_input: true,
|
3
|
+
default_date: "This month",
|
4
|
+
end_date_id: "quick-pick-end-date",
|
5
|
+
end_date_name: "quick-pick-end-date",
|
6
|
+
mode: "range",
|
7
|
+
picker_id: "quick-pick-default-date",
|
8
|
+
placeholder: "mm/dd/yyyy to mm/dd/yyyy",
|
9
|
+
selection_type: "quickpick",
|
10
|
+
start_date_id: "quick-pick-start-date",
|
11
|
+
start_date_name: "quick-pick-start-date"
|
12
|
+
}) %>
|
13
|
+
|
14
|
+
<%= pb_rails("date_picker", props: {
|
15
|
+
allow_input: true,
|
16
|
+
custom_quick_pick_dates: {
|
17
|
+
dates: [
|
18
|
+
{
|
19
|
+
label: "Last 15 months",
|
20
|
+
value: {
|
21
|
+
timePeriod: "months",
|
22
|
+
amount: 15,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
{
|
26
|
+
label: "First Week of June 2022",
|
27
|
+
value: ["06/01/2022", "06/07/2022"],
|
28
|
+
},
|
29
|
+
],
|
30
|
+
},
|
31
|
+
default_date: "First Week of June 2022",
|
32
|
+
end_date_id: "quick-pick-end-date",
|
33
|
+
end_date_name: "quick-pick-end-date",
|
34
|
+
label: "Custom Date Picker",
|
35
|
+
mode: "range",
|
36
|
+
picker_id: "custom-quick-pick-default-date",
|
37
|
+
placeholder: "mm/dd/yyyy to mm/dd/yyyy",
|
38
|
+
selection_type: "quickpick",
|
39
|
+
start_date_id: "quick-pick-start-date",
|
40
|
+
start_date_name: "quick-pick-start-date"
|
41
|
+
}) %>
|
42
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import DatePicker from "../_date_picker"
|
3
|
+
|
4
|
+
const DatePickerQuickPickDefaultDate = (props) => (
|
5
|
+
<>
|
6
|
+
<DatePicker
|
7
|
+
allowInput
|
8
|
+
defaultDate="This month"
|
9
|
+
mode="range"
|
10
|
+
pickerId="quick-pick-default-date"
|
11
|
+
placeholder="mm/dd/yyyy to mm/dd/yyyy"
|
12
|
+
selectionType="quickpick"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
|
16
|
+
<DatePicker
|
17
|
+
allowInput
|
18
|
+
customQuickPickDates={{
|
19
|
+
dates: [
|
20
|
+
{
|
21
|
+
label: "Last 15 months",
|
22
|
+
value: {
|
23
|
+
timePeriod: "months",
|
24
|
+
amount: 15,
|
25
|
+
},
|
26
|
+
},
|
27
|
+
{
|
28
|
+
label: "First Week of June 2022",
|
29
|
+
value: ["06/01/2022", "06/07/2022"],
|
30
|
+
},
|
31
|
+
],
|
32
|
+
}}
|
33
|
+
defaultDate="First Week of June 2022"
|
34
|
+
label="Custom Date Picker"
|
35
|
+
mode="range"
|
36
|
+
pickerId="custom-quick-pick-default-date"
|
37
|
+
placeholder="mm/dd/yyyy to mm/dd/yyyy"
|
38
|
+
selectionType="quickpick"
|
39
|
+
{...props}
|
40
|
+
/>
|
41
|
+
</>
|
42
|
+
)
|
43
|
+
|
44
|
+
export default DatePickerQuickPickDefaultDate
|
@@ -0,0 +1 @@
|
|
1
|
+
To set a default value using Quick Pick, use the `defaultDate` or `default_date` prop. This prop should match one of the labels displayed in the UI of the dropdown menu.
|
@@ -12,6 +12,7 @@ examples:
|
|
12
12
|
- date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
|
13
13
|
- date_picker_quick_pick_custom: Custom Quick Pick Dates
|
14
14
|
- date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
|
15
|
+
- date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
|
15
16
|
- date_picker_format: Format
|
16
17
|
- date_picker_disabled: Disabled Dates
|
17
18
|
- date_picker_min_max: Min Max
|
@@ -42,6 +43,7 @@ examples:
|
|
42
43
|
- date_picker_quick_pick_range_limit: Range (Quick Pick w/ “This” Range limit)
|
43
44
|
- date_picker_quick_pick_custom: Custom Quick Pick Dates
|
44
45
|
- date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
|
46
|
+
- date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
|
45
47
|
- date_picker_format: Format
|
46
48
|
- date_picker_disabled: Disabled Dates
|
47
49
|
- date_picker_min_max: Min Max
|
@@ -25,3 +25,4 @@ export { default as DatePickerQuickPickRangeLimit } from './_date_picker_quick_p
|
|
25
25
|
export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
|
26
26
|
export { default as DatePickerQuickPickCustom } from './_date_picker_quick_pick_custom'
|
27
27
|
export { default as DatePickerQuickPickCustomOverride } from './_date_picker_quick_pick_custom_override'
|
28
|
+
export { default as DatePickerQuickPickDefaultDate } from './_date_picker_quick_pick_default_date'
|
@@ -26,7 +26,7 @@ type customQuickPickDatesType = {
|
|
26
26
|
|
27
27
|
let activeLabel = ""
|
28
28
|
|
29
|
-
const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: customQuickPickDatesType | undefined) => {
|
29
|
+
const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: customQuickPickDatesType | undefined, defaultDate: string) => {
|
30
30
|
return function (fp: FpTypes & any): any {
|
31
31
|
const today = new Date()
|
32
32
|
const yesterday = DateTime.getYesterdayDate(new Date())
|
@@ -185,6 +185,8 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
185
185
|
return {
|
186
186
|
// onReady is a hook from flatpickr that runs when calendar is in a ready state
|
187
187
|
onReady(selectedDates: Array<Date>) {
|
188
|
+
let defaultDateRange
|
189
|
+
|
188
190
|
// loop through the ranges and create an anchor tag for each range and add an event listener to set the date when user clicks on a date range
|
189
191
|
for (const [label, range] of Object.entries(pluginData.ranges)) {
|
190
192
|
addRangeButton(label).addEventListener('click', function () {
|
@@ -201,6 +203,14 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
201
203
|
fp.close();
|
202
204
|
}
|
203
205
|
});
|
206
|
+
|
207
|
+
// check if there is a default date and set the default date range and label for quick pick
|
208
|
+
if (defaultDate) {
|
209
|
+
if (label.toLowerCase() === defaultDate.toLowerCase()) {
|
210
|
+
activeLabel = label
|
211
|
+
defaultDateRange = range
|
212
|
+
}
|
213
|
+
}
|
204
214
|
}
|
205
215
|
// conditional to check if there is a dropdown to add it to the calendar container and get it the classes it needs
|
206
216
|
if (pluginData.rangesNav.children.length > 0) {
|
@@ -216,6 +226,12 @@ const quickPickPlugin = (thisRangesEndToday: boolean, customQuickPickDates: cust
|
|
216
226
|
// function to give the active button the active class
|
217
227
|
selectActiveRangeButton(selectedDates);
|
218
228
|
}
|
229
|
+
|
230
|
+
// set the default date range if there is one and select the active button
|
231
|
+
if (defaultDateRange) {
|
232
|
+
fp.setDate(defaultDateRange, false);
|
233
|
+
selectActiveRangeButton(defaultDateRange);
|
234
|
+
}
|
219
235
|
},
|
220
236
|
onValueUpdate(selectedDates: Array<Date>) {
|
221
237
|
selectActiveRangeButton(selectedDates)
|
@@ -21,34 +21,32 @@
|
|
21
21
|
}
|
22
22
|
|
23
23
|
@mixin hover-color-classes($colors-list) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
transition: color $transition-speed ease;
|
24
|
+
@each $name, $color in $colors-list {
|
25
|
+
.hover_background-#{"" + $name}:hover {
|
26
|
+
background-color: $color !important;
|
27
|
+
transition: background-color $transition-speed ease;
|
28
|
+
}
|
29
|
+
.hover_color-#{"" + $name}:hover {
|
30
|
+
color: $color !important;
|
31
|
+
transition: color $transition-speed ease;
|
32
|
+
}
|
34
33
|
}
|
35
34
|
}
|
36
|
-
|
37
|
-
|
38
|
-
@include hover-
|
39
|
-
@include hover-
|
40
|
-
@include hover-color-classes($
|
41
|
-
@include hover-color-classes($
|
42
|
-
@include hover-color-classes($
|
43
|
-
@include hover-color-classes($
|
44
|
-
@include hover-color-classes($
|
45
|
-
@include hover-color-classes($
|
46
|
-
@include hover-color-classes($
|
47
|
-
@include hover-color-classes($
|
48
|
-
@include hover-color-classes($
|
49
|
-
@include hover-color-classes($
|
50
|
-
@include hover-color-classes($
|
51
|
-
@include hover-color-classes($
|
52
|
-
@include hover-color-classes($
|
53
|
-
@include hover-color-classes($
|
54
|
-
@include hover-color-classes($category_colors);
|
35
|
+
|
36
|
+
@include hover-scale-classes($scales);
|
37
|
+
@include hover-shadow-classes($box_shadows);
|
38
|
+
@include hover-color-classes($product_colors);
|
39
|
+
@include hover-color-classes($status_colors);
|
40
|
+
@include hover-color-classes($data_colors);
|
41
|
+
@include hover-color-classes($shadow_colors);
|
42
|
+
@include hover-color-classes($colors);
|
43
|
+
@include hover-color-classes($interface_colors);
|
44
|
+
@include hover-color-classes($main_colors);
|
45
|
+
@include hover-color-classes($background_colors);
|
46
|
+
@include hover-color-classes($card_colors);
|
47
|
+
@include hover-color-classes($active_colors);
|
48
|
+
@include hover-color-classes($action_colors);
|
49
|
+
@include hover-color-classes($hover_colors);
|
50
|
+
@include hover-color-classes($border_colors);
|
51
|
+
@include hover-color-classes($text_colors);
|
52
|
+
@include hover-color-classes($category_colors);
|
@@ -230,9 +230,9 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
230
230
|
let css = '';
|
231
231
|
if (!hover) return css;
|
232
232
|
css += hover.shadow ? `hover_shadow_${hover.shadow} ` : '';
|
233
|
-
css += hover.background ? `
|
233
|
+
css += hover.background ? `hover_background-${hover.background } ` : '';
|
234
234
|
css += hover.scale ? `hover_scale_${hover.scale} ` : '';
|
235
|
-
css += hover.color ? `
|
235
|
+
css += hover.color ? `hover_color-${hover.color } ` : '';
|
236
236
|
return css;
|
237
237
|
},
|
238
238
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '../../test-utils';
|
3
|
+
import Body from '../../../pb_body/_body';
|
4
|
+
|
5
|
+
const testSubject = 'body';
|
6
|
+
|
7
|
+
test('Hover Props: returns proper class name', () => {
|
8
|
+
const testIdColor = `${testSubject}-hover-color-red`;
|
9
|
+
render(
|
10
|
+
<Body
|
11
|
+
data={{ testid: testIdColor }}
|
12
|
+
hover={{ color: 'red' }}
|
13
|
+
text="Hi"
|
14
|
+
/>
|
15
|
+
);
|
16
|
+
|
17
|
+
let kit = screen.getByTestId(testIdColor);
|
18
|
+
let expectedClassName = `hover_color-red`;
|
19
|
+
expect(kit).toHaveClass(expectedClassName);
|
20
|
+
|
21
|
+
const testIdBackground = `${testSubject}-hover-background-blue`;
|
22
|
+
render(
|
23
|
+
<Body
|
24
|
+
data={{ testid: testIdBackground }}
|
25
|
+
hover={{ background: 'blue' }}
|
26
|
+
text="Hi"
|
27
|
+
/>
|
28
|
+
);
|
29
|
+
|
30
|
+
kit = screen.getByTestId(testIdBackground);
|
31
|
+
expectedClassName = `hover_background-blue`;
|
32
|
+
expect(kit).toHaveClass(expectedClassName);
|
33
|
+
|
34
|
+
const testIdShadow = `${testSubject}-hover-shadow-deep`;
|
35
|
+
render(
|
36
|
+
<Body
|
37
|
+
data={{ testid: testIdShadow }}
|
38
|
+
hover={{ shadow: 'deep' }}
|
39
|
+
text="Hi"
|
40
|
+
/>
|
41
|
+
);
|
42
|
+
|
43
|
+
kit = screen.getByTestId(testIdShadow);
|
44
|
+
expectedClassName = `hover_shadow_deep`;
|
45
|
+
expect(kit).toHaveClass(expectedClassName);
|
46
|
+
|
47
|
+
const testIdScale = `${testSubject}-hover-scale`;
|
48
|
+
render(
|
49
|
+
<Body
|
50
|
+
data={{ testid: testIdScale }}
|
51
|
+
hover={{ scale: 'xl' }}
|
52
|
+
text="Test"
|
53
|
+
/>
|
54
|
+
);
|
55
|
+
|
56
|
+
kit = screen.getByTestId(testIdScale);
|
57
|
+
expectedClassName = `hover_scale_xl`;
|
58
|
+
expect(kit).toHaveClass(expectedClassName);
|
59
|
+
|
60
|
+
const testIdMultiple = `${testSubject}-hover-multiple`;
|
61
|
+
render(
|
62
|
+
<Body
|
63
|
+
data={{ testid: testIdMultiple }}
|
64
|
+
hover={{
|
65
|
+
color: 'green',
|
66
|
+
background: 'error',
|
67
|
+
shadow: 'deeper',
|
68
|
+
scale: 'xl',
|
69
|
+
}}
|
70
|
+
text="Hi"
|
71
|
+
/>
|
72
|
+
);
|
73
|
+
|
74
|
+
kit = screen.getByTestId(testIdMultiple);
|
75
|
+
expect(kit).toHaveClass('hover_color-green');
|
76
|
+
expect(kit).toHaveClass('hover_background-error');
|
77
|
+
expect(kit).toHaveClass('hover_shadow_deeper');
|
78
|
+
expect(kit).toHaveClass('hover_scale_xl');
|
79
|
+
});
|