playbook_ui 12.19.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown638 → 12.19.0.pre.alpha.PLAY699zindexresponsive650
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 +0 -26
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +95 -99
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +1 -44
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +2 -34
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +2 -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/app/pb_kits/playbook/utilities/_positioning.scss +14 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +16 -4
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/z_index.rb +20 -7
- metadata +2 -6
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.html.erb +0 -8
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.jsx +0 -18
- data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +0 -161
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79e97a67011051e8187bac717ed8b2cc199f71e734a3d239384343489dc52c0b
|
4
|
+
data.tar.gz: 0c8a7f21df4e5190feee41f12a69513721bff189a83d9d41184bd25930effb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 854df41d949dee72464fc27f20827fc741399c06af493e40f49e18e55e61d0e419f5a70a061f9be357f9f466e981f39b7b3b95f89da7a46d6ae85820f93fcd3c
|
7
|
+
data.tar.gz: '09057a46d7390ad744d988ec907ddb53e4e1fd0d3afd8945b04c1c59e5b3c77c98beca823c3341e5ce054649ba487647ce42cc5f003fd99bc63bb6cdeb917981'
|
@@ -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?:
|
33
|
+
inputValue?: any,
|
34
34
|
label?: string,
|
35
35
|
maxDate: string,
|
36
36
|
minDate: string,
|
@@ -39,7 +39,7 @@ type DatePickerProps = {
|
|
39
39
|
placeholder?: string,
|
40
40
|
positionElement?: HTMLElement | null,
|
41
41
|
scrollContainer?: string,
|
42
|
-
selectionType?: "month" | "week"
|
42
|
+
selectionType?: "month" | "week",
|
43
43
|
showTimezone?: boolean,
|
44
44
|
staticPosition: boolean,
|
45
45
|
timeFormat?: string,
|
@@ -96,46 +96,46 @@ const DatePicker = (props: DatePickerProps): React.ReactElement => {
|
|
96
96
|
const inputAriaProps = buildAriaProps(inputAria)
|
97
97
|
const inputDataProps = buildDataProps(inputData)
|
98
98
|
|
99
|
-
useEffect(() => {
|
100
|
-
datePickerHelper({
|
101
|
-
allowInput,
|
102
|
-
defaultDate,
|
103
|
-
disableDate,
|
104
|
-
disableRange,
|
105
|
-
disableWeekdays,
|
106
|
-
enableTime,
|
107
|
-
format,
|
108
|
-
hideIcon,
|
109
|
-
inLine,
|
110
|
-
maxDate,
|
111
|
-
minDate,
|
112
|
-
mode,
|
113
|
-
onChange,
|
114
|
-
onClose,
|
115
|
-
pickerId,
|
116
|
-
plugins,
|
117
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
118
|
-
// @ts-ignore
|
119
|
-
position,
|
120
|
-
positionElement,
|
121
|
-
selectionType,
|
122
|
-
showTimezone,
|
123
|
-
staticPosition,
|
124
|
-
yearRange,
|
125
|
-
required: false,
|
126
|
-
}, scrollContainer)
|
127
|
-
})
|
128
99
|
const filteredProps = {...props}
|
129
100
|
delete filteredProps?.position
|
130
101
|
|
131
102
|
const classes = classnames(
|
132
103
|
buildCss('pb_date_picker_kit'),
|
133
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
134
104
|
//@ts-ignore
|
135
105
|
globalProps(filteredProps),
|
136
106
|
error ? 'error' : null,
|
137
107
|
className
|
138
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
|
+
|
139
139
|
const iconWrapperClass = () => {
|
140
140
|
let base = 'cal_icon_wrapper'
|
141
141
|
if (dark) {
|
@@ -150,84 +150,80 @@ useEffect(() => {
|
|
150
150
|
return base
|
151
151
|
}
|
152
152
|
|
153
|
-
|
154
153
|
return (
|
155
154
|
<div
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
{...ariaProps}
|
156
|
+
{...dataProps}
|
157
|
+
className={classes}
|
158
|
+
id={id}
|
160
159
|
>
|
161
160
|
<div
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
>
|
161
|
+
{...inputAriaProps}
|
162
|
+
{...inputDataProps}
|
163
|
+
className="input_wrapper">
|
166
164
|
|
167
165
|
<Caption
|
168
|
-
|
169
|
-
|
166
|
+
className="pb_date_picker_kit_label"
|
167
|
+
text={hideLabel ? null : label}
|
170
168
|
/>
|
171
|
-
<>
|
172
|
-
<div className="date_picker_input_wrapper">
|
173
|
-
<input
|
174
|
-
autoComplete="off"
|
175
|
-
className="date_picker_input"
|
176
|
-
disabled={disableInput}
|
177
|
-
id={pickerId}
|
178
|
-
name={name}
|
179
|
-
onChange={inputOnChange}
|
180
|
-
placeholder={placeholder}
|
181
|
-
value={inputValue}
|
182
|
-
/>
|
183
169
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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>
|
192
189
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
}
|
228
|
-
</>
|
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}
|
229
224
|
</div>
|
230
225
|
</div>
|
231
226
|
)
|
232
227
|
}
|
228
|
+
|
233
229
|
export default DatePicker
|
@@ -61,8 +61,7 @@
|
|
61
61
|
|
62
62
|
<%= javascript_tag do %>
|
63
63
|
window.addEventListener("DOMContentLoaded", () => {
|
64
|
-
|
64
|
+
datePickerHelper(<%= object.date_picker_config %>, "<%= object.scroll_container %>")
|
65
65
|
})
|
66
|
-
|
67
66
|
<% end %>
|
68
|
-
<% end %>
|
67
|
+
<% end %>
|
@@ -51,7 +51,7 @@ module Playbook
|
|
51
51
|
prop :position_element, type: Playbook::Props::String
|
52
52
|
prop :scroll_container, type: Playbook::Props::String
|
53
53
|
prop :selection_type, type: Playbook::Props::Enum,
|
54
|
-
values: %w[week month
|
54
|
+
values: %w[week month none],
|
55
55
|
default: "none"
|
56
56
|
prop :show_timezone, type: Playbook::Props::Boolean,
|
57
57
|
default: false
|
@@ -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,8 +19,8 @@ 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
26
|
timeCaption?: string,
|
@@ -91,23 +90,18 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
91
90
|
}
|
92
91
|
|
93
92
|
const setPlugins = () => {
|
94
|
-
|
93
|
+
let pluginList = []
|
95
94
|
|
96
95
|
// month and week selection
|
97
96
|
if (selectionType === "month" || plugins.length > 0) {
|
98
97
|
pluginList.push(monthSelectPlugin({ shorthand: true, dateFormat: 'F Y', altFormat: 'F Y' }))
|
99
98
|
} else if ( selectionType === "week") {
|
100
99
|
pluginList.push(weekSelect())
|
101
|
-
|
102
|
-
} else if (selectionType === "quickpick") {
|
103
|
-
//------- QUICKPICK VARIANT PLUGIN -------------//
|
104
|
-
pluginList.push(quickPickPlugin())
|
105
100
|
}
|
106
101
|
|
107
102
|
// time selection
|
108
103
|
if (enableTime) pluginList.push(timeSelectPlugin({ caption: timeCaption, showTimezone: showTimezone}))
|
109
104
|
|
110
|
-
|
111
105
|
return pluginList
|
112
106
|
}
|
113
107
|
|
@@ -150,9 +144,6 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
150
144
|
},
|
151
145
|
] : disabledParser(),
|
152
146
|
enableTime,
|
153
|
-
locale: {
|
154
|
-
rangeSeparator: ' → '
|
155
|
-
},
|
156
147
|
maxDate,
|
157
148
|
minDate,
|
158
149
|
mode,
|
@@ -180,33 +171,10 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
180
171
|
static: staticPosition,
|
181
172
|
})
|
182
173
|
|
183
|
-
|
184
174
|
// ===========================================================
|
185
175
|
// Additional JS Functionality |
|
186
176
|
// ===========================================================
|
187
177
|
|
188
|
-
// opens flatpickr instance when calander icon is clicked so we can have a hover state on icon
|
189
|
-
// window.addEventListener("DOMContentLoaded", (event) => {
|
190
|
-
// event.preventDefault();
|
191
|
-
// function attachIconClickHandler() {
|
192
|
-
// const variantArr = document.querySelectorAll(`#cal-icon-${pickerId}`)
|
193
|
-
// if (!variantArr) {
|
194
|
-
// setTimeout(attachIconClickHandler, 100);
|
195
|
-
// return;
|
196
|
-
// }
|
197
|
-
|
198
|
-
// const instance = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
199
|
-
// variantArr.forEach((icon) => {
|
200
|
-
// icon.addEventListener("click", function(event) {
|
201
|
-
// event.preventDefault();
|
202
|
-
// instance.open()
|
203
|
-
// });
|
204
|
-
// })
|
205
|
-
// }
|
206
|
-
|
207
|
-
// attachIconClickHandler();
|
208
|
-
// });
|
209
|
-
|
210
178
|
// Assign dynamically sourced flatpickr instance to variable
|
211
179
|
const picker = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
212
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
|
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
|
-
|
16
|
+
&:hover {
|
17
|
+
cursor: pointer;
|
19
18
|
}
|
20
19
|
}
|
21
20
|
&.dark {
|
@@ -48,3 +48,17 @@
|
|
48
48
|
.z_index_10 {
|
49
49
|
z-index: 1000;
|
50
50
|
}
|
51
|
+
|
52
|
+
$zIndex_values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
|
53
|
+
|
54
|
+
@each $size, $size_value in $breakpoints_grid {
|
55
|
+
@each $zIndex_value in $zIndex_values {
|
56
|
+
$min_size: map-get($size_value, "min");
|
57
|
+
$max_size: map-get($size_value, "max");
|
58
|
+
.z_index_#{$size}_#{$zIndex_value} {
|
59
|
+
@include break_on($min_size, $max_size) {
|
60
|
+
z-index: #{$zIndex_value * 100} !important;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
@@ -113,9 +113,11 @@ type Shadow = {
|
|
113
113
|
|
114
114
|
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
115
115
|
|
116
|
+
type ZIndexType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
|
117
|
+
type ZIndexResponsiveType = {[key: string]: ZIndexType}
|
116
118
|
type ZIndex = {
|
117
|
-
zIndex?:
|
118
|
-
}
|
119
|
+
zIndex?: ZIndexType,
|
120
|
+
} | ZIndexResponsiveType
|
119
121
|
|
120
122
|
// keep this as the last type definition
|
121
123
|
export type GlobalProps = AlignContent & AlignItems & AlignSelf &
|
@@ -178,9 +180,19 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
178
180
|
css += maxWidth ? `max_width_${maxWidth } ` : ''
|
179
181
|
return css
|
180
182
|
},
|
181
|
-
zIndexProps: (
|
183
|
+
zIndexProps: (zIndex: ZIndex) => {
|
182
184
|
let css = ''
|
183
|
-
|
185
|
+
Object.entries(zIndex).forEach((zIndexEntry) => {
|
186
|
+
if (zIndexEntry[0] == "zIndex") {
|
187
|
+
if (typeof zIndexEntry[1] == "number") {
|
188
|
+
css += `z_index_${zIndexEntry[1]} `
|
189
|
+
} else if (typeof zIndexEntry[1] == "object") {
|
190
|
+
Object.entries(zIndexEntry[1]).forEach((zIndexObj) => {
|
191
|
+
css += `z_index_${zIndexObj[0]}_${zIndexObj[1]} `
|
192
|
+
})
|
193
|
+
}
|
194
|
+
}
|
195
|
+
})
|
184
196
|
return css
|
185
197
|
},
|
186
198
|
shadowProps: ({ shadow }: Shadow) => {
|
data/lib/playbook/version.rb
CHANGED
data/lib/playbook/z_index.rb
CHANGED
@@ -16,16 +16,29 @@ module Playbook
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
def screen_size_values
|
20
|
+
%w[xs sm md lg xl]
|
21
|
+
end
|
20
22
|
|
21
23
|
def z_index_props
|
22
|
-
|
23
|
-
return nil unless
|
24
|
+
selected_props = z_index_options.keys.select { |sk| try(sk) }
|
25
|
+
return nil unless selected_props.present?
|
26
|
+
|
27
|
+
responsive = selected_props.present? && try(:z_index).is_a?(::Hash)
|
28
|
+
css = ""
|
29
|
+
if responsive
|
30
|
+
z_index_value = send(:z_index)
|
31
|
+
z_index_value.each do |key, value|
|
32
|
+
css += "z_index_#{key}_#{value} " if screen_size_values.include?(key.to_s) && z_index_values.include?(value.to_s)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
selected_props.each do |k|
|
36
|
+
z_index_value = send(k)
|
37
|
+
css += "z_index_#{z_index_value} " if z_index_values.include? z_index_value
|
38
|
+
end
|
39
|
+
end
|
24
40
|
|
25
|
-
|
26
|
-
index_value = send(k)
|
27
|
-
"z_index_#{index_value}" if z_index_values.include? index_value
|
28
|
-
end.compact.join(" ")
|
41
|
+
css unless css.blank?
|
29
42
|
end
|
30
43
|
end
|
31
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.19.0.pre.alpha.
|
4
|
+
version: 12.19.0.pre.alpha.PLAY699zindexresponsive650
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-05-
|
12
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -745,8 +745,6 @@ files:
|
|
745
745
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions.md
|
746
746
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions_element.html.erb
|
747
747
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_positions_element.jsx
|
748
|
-
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.html.erb
|
749
|
-
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick.jsx
|
750
748
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.html.erb
|
751
749
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.jsx
|
752
750
|
- app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.html.erb
|
@@ -761,7 +759,6 @@ files:
|
|
761
759
|
- app/pb_kits/playbook/pb_date_picker/docs/_description.md
|
762
760
|
- app/pb_kits/playbook/pb_date_picker/docs/example.yml
|
763
761
|
- app/pb_kits/playbook/pb_date_picker/docs/index.js
|
764
|
-
- app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx
|
765
762
|
- app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.ts
|
766
763
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss
|
767
764
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_day_styles.scss
|
@@ -771,7 +768,6 @@ files:
|
|
771
768
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss
|
772
769
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_month_and_year_styles.scss
|
773
770
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss
|
774
|
-
- app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss
|
775
771
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss
|
776
772
|
- app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss
|
777
773
|
- app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,161 +0,0 @@
|
|
1
|
-
import moment from 'moment'
|
2
|
-
|
3
|
-
type FpTypes = {
|
4
|
-
setDate: (arg0: any, arg1: boolean) => void,
|
5
|
-
config: { [key: string]: string },
|
6
|
-
clear: (arg0: boolean, arg1: boolean) => void,
|
7
|
-
close: () => void,
|
8
|
-
calendarContainer?: {
|
9
|
-
classList: { add: (arg0: string) => void };
|
10
|
-
prepend: (arg0: HTMLDivElement) => void;
|
11
|
-
append: (arg0: HTMLDivElement) => void;
|
12
|
-
},
|
13
|
-
loadedPlugins: string[],
|
14
|
-
};
|
15
|
-
|
16
|
-
type pluginDataType = {
|
17
|
-
ranges: { [key: string]: Date[] },
|
18
|
-
rangesNav: HTMLUListElement,
|
19
|
-
rangesButtons: [] | any,
|
20
|
-
}
|
21
|
-
|
22
|
-
const quickPickPlugin = () => {
|
23
|
-
return function (fp: FpTypes & any): any {
|
24
|
-
|
25
|
-
let activeLabel = ""
|
26
|
-
|
27
|
-
// variable that holds the ranges available
|
28
|
-
const ranges = {
|
29
|
-
'Today': [new Date(), new Date()],
|
30
|
-
'Yesterday': [moment().subtract(1, 'days').toDate(), moment().subtract(1, 'days').toDate()],
|
31
|
-
'This week': [moment().startOf('week').toDate(), moment().endOf('week').toDate()],
|
32
|
-
'This month': [moment().startOf('month').toDate(), new Date()],
|
33
|
-
'This quarter': [moment().startOf('quarter').toDate(), new Date()],
|
34
|
-
'This year': [moment().startOf('year').toDate(), new Date()],
|
35
|
-
'Last week': [
|
36
|
-
moment().subtract(1, 'week').startOf('week').toDate(),
|
37
|
-
moment().subtract(1, 'week').endOf('week').toDate()
|
38
|
-
],
|
39
|
-
'Last month': [
|
40
|
-
moment().subtract(1, 'month').startOf('month').toDate(),
|
41
|
-
moment().subtract(1, 'month').endOf('month').toDate()
|
42
|
-
],
|
43
|
-
'Last quarter': [
|
44
|
-
moment().subtract(1, 'quarter').startOf('quarter').toDate(),
|
45
|
-
moment().subtract(1, 'quarter').endOf('quarter').toDate()
|
46
|
-
],
|
47
|
-
'Last year': [
|
48
|
-
moment().subtract(1, 'year').startOf('year').toDate(),
|
49
|
-
moment().subtract(1, 'year').endOf('year').toDate()
|
50
|
-
]
|
51
|
-
}
|
52
|
-
//creating the ul element for the nav dropdown and giving it classnames
|
53
|
-
const rangesNav = document.createElement('ul');
|
54
|
-
|
55
|
-
// creating the pluginData object that will hold the properties of this plugin
|
56
|
-
const pluginData: pluginDataType = {
|
57
|
-
ranges: ranges,
|
58
|
-
rangesNav: rangesNav,
|
59
|
-
rangesButtons: [],
|
60
|
-
};
|
61
|
-
|
62
|
-
/**
|
63
|
-
* @param {string} label
|
64
|
-
* @returns HTML Element
|
65
|
-
*/
|
66
|
-
|
67
|
-
//funciton for creating the range buttons in the nav
|
68
|
-
const addRangeButton = (label: string) => {
|
69
|
-
|
70
|
-
// creating new elements to mimick selectable card component
|
71
|
-
const div2 = document.createElement('div');
|
72
|
-
div2.className = "nav-item-link"
|
73
|
-
div2.innerHTML = label;
|
74
|
-
|
75
|
-
pluginData.rangesButtons[label] = div2;
|
76
|
-
|
77
|
-
// create li elements inside the dropdown
|
78
|
-
const item = document.createElement('li');
|
79
|
-
item.className = "nav-item";
|
80
|
-
|
81
|
-
// append those nav items to the li items
|
82
|
-
item.appendChild(pluginData.rangesButtons[label]);
|
83
|
-
|
84
|
-
// append the li item to the ul rangeNav prop
|
85
|
-
pluginData.rangesNav.appendChild(item);
|
86
|
-
|
87
|
-
// return the ranges buton prop
|
88
|
-
return pluginData.rangesButtons[label];
|
89
|
-
};
|
90
|
-
|
91
|
-
const selectActiveRangeButton = (selectedDates: Array<string>) => {
|
92
|
-
const current = pluginData.rangesNav.querySelector('.active');
|
93
|
-
|
94
|
-
if (current) {
|
95
|
-
current.classList.remove('active');
|
96
|
-
}
|
97
|
-
/** conditional statment to extract start and end dates from selectedDates,
|
98
|
-
* then loop through ranges prop in pluginData
|
99
|
-
* and check if chosen dates equal to a date in the ranges prop
|
100
|
-
* if they are equal, add the active class
|
101
|
-
*/
|
102
|
-
if (selectedDates.length > 0) {
|
103
|
-
pluginData.rangesButtons[activeLabel].classList.add('active');
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
return {
|
109
|
-
// onReady is a hook from flatpickr that runs when calender is in a ready state
|
110
|
-
onReady(selectedDates: Array<string>) {
|
111
|
-
// loop through the ranges and create an anchor tag for each range and add an event listiner to set the date when user clicks on a date range
|
112
|
-
for (const [label, range] of Object.entries(pluginData.ranges)) {
|
113
|
-
addRangeButton(label).addEventListener('click', function () {
|
114
|
-
|
115
|
-
const start = moment(range[0]).toDate();
|
116
|
-
const end = moment(range[1]).toDate();
|
117
|
-
|
118
|
-
if (!start) {
|
119
|
-
fp.clear();
|
120
|
-
}
|
121
|
-
else {
|
122
|
-
activeLabel = label
|
123
|
-
fp.setDate([start, end], true);
|
124
|
-
fp.close();
|
125
|
-
}
|
126
|
-
|
127
|
-
});
|
128
|
-
}
|
129
|
-
|
130
|
-
// conditional to check if there is a dropdown to add it to the calendar container and git it the classes it needs
|
131
|
-
if (pluginData.rangesNav.children.length > 0) {
|
132
|
-
|
133
|
-
fp.calendarContainer.prepend(pluginData.rangesNav);
|
134
|
-
pluginData.rangesNav.classList.add('quick-pick-ul')
|
135
|
-
fp.calendarContainer.classList.add('quick-pick-drop-down');
|
136
|
-
|
137
|
-
/**
|
138
|
-
*
|
139
|
-
* @param {Array} selectedDates
|
140
|
-
*/
|
141
|
-
|
142
|
-
// function to give the active butto the active class
|
143
|
-
selectActiveRangeButton(selectedDates);
|
144
|
-
}
|
145
|
-
|
146
|
-
},
|
147
|
-
onValueUpdate(selectedDates: Array<string>) {
|
148
|
-
selectActiveRangeButton(selectedDates);
|
149
|
-
},
|
150
|
-
|
151
|
-
// onClose(selectedDates: Array<string>) {
|
152
|
-
// // set the input value to the selected dates when the dropdown is closed
|
153
|
-
// // if (!selectedDates[1]) {
|
154
|
-
// // fp.input.value = fp.formatDate(this.selectedDates[0], fp.config.dateFormat) + ' → ' + fp.formatDate(this.selectedDates[1], fp.config.dateFormat);
|
155
|
-
// // }
|
156
|
-
// }
|
157
|
-
};
|
158
|
-
};
|
159
|
-
}
|
160
|
-
|
161
|
-
export default quickPickPlugin;
|
@@ -1,75 +0,0 @@
|
|
1
|
-
@import "../../tokens/animation-curves";
|
2
|
-
@import "../../tokens/colors";
|
3
|
-
@import "../../tokens/typography";
|
4
|
-
@import "../../tokens/titles";
|
5
|
-
@import "../../tokens/spacing";
|
6
|
-
|
7
|
-
$pb_card_border_width: 1px;
|
8
|
-
$pb_card_border_radius: $border_rad_heavier;
|
9
|
-
|
10
|
-
// used to display dropdown on the left of the calender
|
11
|
-
.quick-pick-drop-down {
|
12
|
-
width: auto;
|
13
|
-
display: grid;
|
14
|
-
}
|
15
|
-
|
16
|
-
.quick-pick-ul {
|
17
|
-
padding: $space_xs 0px;
|
18
|
-
margin: 0;
|
19
|
-
list-style: none;
|
20
|
-
}
|
21
|
-
|
22
|
-
.nav-item {
|
23
|
-
list-style: none;
|
24
|
-
border-radius: 6px;
|
25
|
-
border-bottom: 0;
|
26
|
-
margin: $space_xs $space_sm;
|
27
|
-
}
|
28
|
-
|
29
|
-
.nav-item-link {
|
30
|
-
text-decoration: none;
|
31
|
-
border-width: $pb_card_border_width;
|
32
|
-
border-style: solid;
|
33
|
-
border-color: $border_light;
|
34
|
-
border-radius: $pb_card_border_radius;
|
35
|
-
padding: $space_xs 14px;
|
36
|
-
transition-property: color, background-color;
|
37
|
-
transition-duration: 0.15s;
|
38
|
-
transition-timing-function: $bezier;
|
39
|
-
line-height: 1.4;
|
40
|
-
color: $charcoal;
|
41
|
-
font-size: $font_default;
|
42
|
-
font-weight: $regular;
|
43
|
-
&.active {
|
44
|
-
border-width: 2px;
|
45
|
-
border-color: $primary;
|
46
|
-
}
|
47
|
-
@media (hover:hover) {
|
48
|
-
&:hover {
|
49
|
-
cursor: pointer;
|
50
|
-
box-shadow: $shadow-deep;
|
51
|
-
border-color: $slate;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
// Hide the calendar
|
57
|
-
.quick-pick-drop-down > .flatpickr-months, .quick-pick-drop-down > .flatpickr-innerContainer {
|
58
|
-
display: none;
|
59
|
-
}
|
60
|
-
|
61
|
-
@media only screen and (max-width: 767px) {
|
62
|
-
.quick-pick-ul {
|
63
|
-
padding: $space_xs $space_xs;
|
64
|
-
display: grid;
|
65
|
-
grid-template-columns: 1fr 1fr;
|
66
|
-
}
|
67
|
-
|
68
|
-
.nav-item {
|
69
|
-
margin: $space_xxs $space_xs;
|
70
|
-
}
|
71
|
-
|
72
|
-
.nav-item-link {
|
73
|
-
padding: $space_xs $space_xxs;
|
74
|
-
}
|
75
|
-
}
|