playbook_ui 14.8.0.pre.rc.5 → 14.8.0.pre.rc.7
Sign up to get free protection for your applications and to get access to all the features.
- 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 +40 -27
- data/app/pb_kits/playbook/utilities/globalProps.ts +5 -3
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +79 -0
- data/dist/chunks/{_typeahead-DEskmS_o.js → _typeahead-DPeGdNBp.js} +2 -2
- data/dist/chunks/{_weekday_stacked-f4faf8xD.js → _weekday_stacked-BP8UVQtC.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: b3dbd9296a8be2f574f6e9440274153cc9ace32a999bfa3200748cba88320b46
|
4
|
+
data.tar.gz: 56c5789d71eb070fb99d82af6988bac827be6fbffe3f8c57f2be4d9f6f162231
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589bec2f46576e48bd1a896d14fb883dbbc53ceaa247c9872b844232ace0d469625589d66fb5c880c4e7552c14e7fa6d9db5d161bcbfb2e29b8a7b9391eaf31c
|
7
|
+
data.tar.gz: 338073e12c672f9004ad556052be2c8fb1242ca9a0faad46f3360518691b0958ae5cb156ebe72f18c42b52cf3457d8934a81fa07386df8c348c1b91e2fd42c00
|
@@ -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,47 @@
|
|
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
|
}
|
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);
|
53
|
+
|
54
|
+
.hover_visibility {
|
55
|
+
opacity: 0;
|
56
|
+
transition: opacity $transition-speed ease;
|
57
|
+
|
58
|
+
&:hover {
|
59
|
+
opacity: 1;
|
60
|
+
}
|
36
61
|
}
|
37
62
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@include hover-color-classes($shadow_colors);
|
44
|
-
@include hover-color-classes($colors);
|
45
|
-
@include hover-color-classes($interface_colors);
|
46
|
-
@include hover-color-classes($main_colors);
|
47
|
-
@include hover-color-classes($background_colors);
|
48
|
-
@include hover-color-classes($card_colors);
|
49
|
-
@include hover-color-classes($active_colors);
|
50
|
-
@include hover-color-classes($action_colors);
|
51
|
-
@include hover-color-classes($hover_colors);
|
52
|
-
@include hover-color-classes($border_colors);
|
53
|
-
@include hover-color-classes($text_colors);
|
54
|
-
@include hover-color-classes($category_colors);
|
63
|
+
.group_hover:hover {
|
64
|
+
.group_hover.hover_visibility {
|
65
|
+
opacity: 1;
|
66
|
+
}
|
67
|
+
}
|
@@ -63,7 +63,8 @@ type FlexWrap = {
|
|
63
63
|
type Hover = Shadow & {
|
64
64
|
background?: string,
|
65
65
|
color?: string,
|
66
|
-
scale?: "sm" | "md" | "lg"
|
66
|
+
scale?: "sm" | "md" | "lg",
|
67
|
+
visibility?: boolean,
|
67
68
|
}
|
68
69
|
|
69
70
|
type GroupHover = {
|
@@ -230,9 +231,10 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
230
231
|
let css = '';
|
231
232
|
if (!hover) return css;
|
232
233
|
css += hover.shadow ? `hover_shadow_${hover.shadow} ` : '';
|
233
|
-
css += hover.background ? `
|
234
|
+
css += hover.background ? `hover_background-${hover.background } ` : '';
|
234
235
|
css += hover.scale ? `hover_scale_${hover.scale} ` : '';
|
235
|
-
css += hover.color ? `
|
236
|
+
css += hover.color ? `hover_color-${hover.color } ` : '';
|
237
|
+
css += hover.visibility ? `hover_visibility` : '';
|
236
238
|
return css;
|
237
239
|
},
|
238
240
|
|
@@ -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
|
+
});
|