playbook_ui 15.6.0.pre.alpha.play265012910 → 15.6.0.pre.alpha.play266013023
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_bar_graph/_bar_graph.tsx +0 -6
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +10 -8
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +0 -1
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +0 -3
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +24 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +181 -3
- data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +2 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +1 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +14 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +5 -4
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.html.erb +24 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.jsx +60 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_closeable.md +3 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +316 -15
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +1 -1
- data/app/pb_kits/playbook/pb_legend/_legend.tsx +1 -6
- data/app/pb_kits/playbook/pb_legend/legend.html.erb +0 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +8 -3
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.html.erb +16 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.jsx +30 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.md +1 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
- data/app/pb_kits/playbook/pb_select/select.rb +3 -1
- data/app/pb_kits/playbook/pb_select/select.test.js +23 -0
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +3 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.html.erb +60 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.jsx +118 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.md +1 -0
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_date.md +1 -1
- data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -1
- data/app/pb_kits/playbook/pb_timeline/item.rb +2 -0
- data/app/pb_kits/playbook/pb_timeline/label.html.erb +2 -1
- data/app/pb_kits/playbook/pb_timeline/label.rb +2 -0
- data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +3 -0
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +51 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
- data/dist/chunks/_typeahead-CYNrKU10.js +6 -0
- data/dist/chunks/lib-DDDLiZuu.js +29 -0
- data/dist/chunks/vendor.js +2 -2
- data/dist/menu.yml +2 -3
- 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/forms/builder/collection_select_field.rb +9 -1
- data/lib/playbook/forms/builder/select_field.rb +9 -1
- data/lib/playbook/forms/builder/time_zone_select_field.rb +9 -1
- data/lib/playbook/pb_kit_helper.rb +5 -1
- data/lib/playbook/version.rb +1 -1
- metadata +13 -4
- data/dist/chunks/_typeahead-CnPLuGbe.js +0 -6
- data/dist/chunks/lib-CgpqUb6l.js +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6db43d3a7fb9e0f943643cf6bcfdb94d3aec4ac7d76204cb9b3d37977d0b266
|
|
4
|
+
data.tar.gz: a4633939ff364118352b782652738e3d0d1ada1c9af1bdfac6fa3ab9fbea0eff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94a35af5bd9592f899fc5b0d4d92bfdad87fe9056f104910a01bd827f6f53871aeaceffd5e78b05296fb3b8c1ba075548b312016cc8f89fb863aa35cba084d33
|
|
7
|
+
data.tar.gz: b5c1c948b583c32209cba3fc3514d3f0f08d9537c33c7174b6b3c02afa954452972c3f881f3d313defb1d05afc0172ade58726a42f778004381b2d157a4c4a8c
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
2
|
import { globalProps } from "../utilities/globalProps";
|
|
3
3
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
|
4
|
-
import { deprecatedKitWarning } from "../utilities/deprecated";
|
|
5
4
|
|
|
6
5
|
import HighchartsReact from "highcharts-react-official";
|
|
7
6
|
import Highcharts from "highcharts";
|
|
@@ -169,11 +168,6 @@ if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
|
|
169
168
|
|
|
170
169
|
const [options, setOptions] = useState({});
|
|
171
170
|
|
|
172
|
-
useEffect(() => {
|
|
173
|
-
// Warn about deprecated kit (only once per page load, dev mode only)
|
|
174
|
-
deprecatedKitWarning('BarGraph', 'Please use "PbBarGraph" instead.');
|
|
175
|
-
}, []);
|
|
176
|
-
|
|
177
171
|
useEffect(() => {
|
|
178
172
|
setOptions(merge(staticOptions, customOptions));
|
|
179
173
|
}, [chartData]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Card headers pass category, product, status and background colors only. List of all category, product, status and background colors can be viewed <a href="https://playbook.powerapp.cloud/
|
|
1
|
+
Card headers pass category, product, status and background colors only. List of all category, product, status and background colors can be viewed <a href="https://playbook.powerapp.cloud/tokens/colors" target="_blank">here</a>.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Card highlight can pass status, product, and category colors. List of all colors can be viewed <a href="https://playbook.powerapp.cloud/
|
|
1
|
+
Card highlight can pass status, product, and category colors. List of all colors can be viewed <a href="https://playbook.powerapp.cloud/tokens/colors" target="_blank">here</a>.
|
|
@@ -25,11 +25,11 @@ exports[`html structure is correct 1`] = `
|
|
|
25
25
|
>
|
|
26
26
|
<div
|
|
27
27
|
class="icon_wrapper"
|
|
28
|
-
style="vertical-align: middle;
|
|
28
|
+
style="vertical-align: middle;"
|
|
29
29
|
>
|
|
30
30
|
<svg
|
|
31
31
|
aria-label="chevron-down icon"
|
|
32
|
-
class="pb_custom_icon svg-inline--fa svg_lg svg_fw"
|
|
32
|
+
class="pb_custom_icon svg-inline--fa color_text_lt_lighter svg_lg svg_fw"
|
|
33
33
|
color="currentColor"
|
|
34
34
|
fill="none"
|
|
35
35
|
height="auto"
|
|
@@ -27,12 +27,12 @@ type colorMap = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const colorMap = {
|
|
30
|
-
default:
|
|
31
|
-
light: "
|
|
32
|
-
lighter: "
|
|
33
|
-
link: "
|
|
34
|
-
error: "
|
|
35
|
-
success: "
|
|
30
|
+
default:"text_lt_default",
|
|
31
|
+
light: "text_lt_light",
|
|
32
|
+
lighter: "text_lt_lighter",
|
|
33
|
+
link: "primary",
|
|
34
|
+
error: "error",
|
|
35
|
+
success: "text_dk_success_sm",
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const CollapsibleIcon = ({
|
|
@@ -68,9 +68,10 @@ const CollapsibleIcon = ({
|
|
|
68
68
|
className="icon_wrapper"
|
|
69
69
|
key={icon ? showIcon(icon)[0] : "chevron-down"}
|
|
70
70
|
onClick={(e) => handleIconClick(e)}
|
|
71
|
-
style={{ verticalAlign: "middle"
|
|
71
|
+
style={{ verticalAlign: "middle"}}
|
|
72
72
|
>
|
|
73
73
|
<Icon
|
|
74
|
+
color={color}
|
|
74
75
|
icon={icon ? showIcon(icon)[0] : "chevron-down"}
|
|
75
76
|
size={iconSize}
|
|
76
77
|
/>
|
|
@@ -80,9 +81,10 @@ const CollapsibleIcon = ({
|
|
|
80
81
|
className="icon_wrapper"
|
|
81
82
|
key={icon ? showIcon(icon)[1] : "chevron-up"}
|
|
82
83
|
onClick={(e) => handleIconClick(e)}
|
|
83
|
-
style={{ verticalAlign: "middle"
|
|
84
|
+
style={{ verticalAlign: "middle" }}
|
|
84
85
|
>
|
|
85
86
|
<Icon
|
|
87
|
+
color={color}
|
|
86
88
|
icon={icon ? showIcon(icon)[1] : "chevron-up"}
|
|
87
89
|
size={iconSize}
|
|
88
90
|
/>
|
|
@@ -22,7 +22,6 @@ const CollapsibleState = (props) => {
|
|
|
22
22
|
<Collapsible
|
|
23
23
|
collapsed={isCollapsed}
|
|
24
24
|
icon={["plus", "minus"]}
|
|
25
|
-
iconColor='white'
|
|
26
25
|
padding="none"
|
|
27
26
|
>
|
|
28
27
|
<Collapsible.Main padding="sm"
|
|
@@ -41,7 +40,6 @@ const CollapsibleState = (props) => {
|
|
|
41
40
|
<Collapsible
|
|
42
41
|
collapsed={isCollapsed}
|
|
43
42
|
icon={["plus", "minus"]}
|
|
44
|
-
iconColor='white'
|
|
45
43
|
padding="none"
|
|
46
44
|
>
|
|
47
45
|
<Collapsible.Main padding="sm"
|
|
@@ -60,7 +58,6 @@ const CollapsibleState = (props) => {
|
|
|
60
58
|
<Collapsible
|
|
61
59
|
collapsed={isCollapsed}
|
|
62
60
|
icon={["plus", "minus"]}
|
|
63
|
-
iconColor='white'
|
|
64
61
|
padding="none"
|
|
65
62
|
>
|
|
66
63
|
<Collapsible.Main padding="sm"
|
|
@@ -251,4 +251,28 @@ describe('DatePicker Kit', () => {
|
|
|
251
251
|
expect(input).toHaveValue(DateTime.getYearStartDate(new Date()).formatDate() + " to " + new Date().formatDate())
|
|
252
252
|
})
|
|
253
253
|
})
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
test('displays defaultDate when it is later than maxDate', async () => {
|
|
257
|
+
const testId = 'datepicker-out-of-range-after'
|
|
258
|
+
const futureDateString = '01/15/2020'
|
|
259
|
+
const maxDateString = '01/10/2020'
|
|
260
|
+
|
|
261
|
+
render(
|
|
262
|
+
<DatePicker
|
|
263
|
+
data={{ testid: testId }}
|
|
264
|
+
defaultDate={futureDateString}
|
|
265
|
+
format="m/d/Y"
|
|
266
|
+
maxDate={maxDateString}
|
|
267
|
+
pickerId="date-picker-out-of-range-after"
|
|
268
|
+
/>
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
const kit = screen.getByTestId(testId)
|
|
272
|
+
const input = within(kit).getByPlaceholderText('Select Date')
|
|
273
|
+
|
|
274
|
+
await waitFor(() => {
|
|
275
|
+
expect(input).toHaveValue('01/15/2020')
|
|
276
|
+
}, { timeout: 5000 })
|
|
277
|
+
})
|
|
254
278
|
})
|
|
@@ -275,6 +275,80 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
275
275
|
|
|
276
276
|
const { setMinDate, setMaxDate } = getMinMaxDates()
|
|
277
277
|
|
|
278
|
+
// Default Date + Min/Max Date Initialization Helper Functions section ----/
|
|
279
|
+
const toDateObject = (dateValue: any): Date | null => {
|
|
280
|
+
if (!dateValue) return null
|
|
281
|
+
if (dateValue instanceof Date) return dateValue
|
|
282
|
+
if (typeof dateValue === 'string') {
|
|
283
|
+
const parsed = new Date(dateValue)
|
|
284
|
+
return isNaN(parsed.getTime()) ? null : parsed
|
|
285
|
+
}
|
|
286
|
+
if (typeof dateValue === 'number') {
|
|
287
|
+
return new Date(dateValue)
|
|
288
|
+
}
|
|
289
|
+
return null
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Formatting Date for Flatpickr
|
|
293
|
+
const formatDateForFlatpickr = (dateValue: any): string | null => {
|
|
294
|
+
const dateObj = toDateObject(dateValue)
|
|
295
|
+
if (!dateObj) return null
|
|
296
|
+
|
|
297
|
+
const year = dateObj.getFullYear()
|
|
298
|
+
const month = String(dateObj.getMonth() + 1).padStart(2, '0')
|
|
299
|
+
const day = String(dateObj.getDate()).padStart(2, '0')
|
|
300
|
+
return `${year}-${month}-${day}`
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Helper to check if defaultDate is earlier than minDate
|
|
304
|
+
const isDefaultDateBeforeMinDate = (defaultDateValue: any, minDateValue: any): boolean => {
|
|
305
|
+
if (!defaultDateValue || !minDateValue) return false
|
|
306
|
+
|
|
307
|
+
const defaultDateObj = toDateObject(defaultDateValue)
|
|
308
|
+
const minDateObj = toDateObject(minDateValue)
|
|
309
|
+
|
|
310
|
+
if (!defaultDateObj || !minDateObj) return false
|
|
311
|
+
|
|
312
|
+
const defaultDateOnly = new Date(defaultDateObj.getFullYear(), defaultDateObj.getMonth(), defaultDateObj.getDate())
|
|
313
|
+
const minDateOnly = new Date(minDateObj.getFullYear(), minDateObj.getMonth(), minDateObj.getDate())
|
|
314
|
+
|
|
315
|
+
return defaultDateOnly < minDateOnly
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Helper to check if defaultDate is later than maxDate
|
|
319
|
+
const isDefaultDateAfterMaxDate = (defaultDateValue: any, maxDateValue: any): boolean => {
|
|
320
|
+
if (!defaultDateValue || !maxDateValue) return false
|
|
321
|
+
|
|
322
|
+
const defaultDateObj = toDateObject(defaultDateValue)
|
|
323
|
+
const maxDateObj = toDateObject(maxDateValue)
|
|
324
|
+
|
|
325
|
+
if (!defaultDateObj || !maxDateObj) return false
|
|
326
|
+
|
|
327
|
+
const defaultDateOnly = new Date(defaultDateObj.getFullYear(), defaultDateObj.getMonth(), defaultDateObj.getDate())
|
|
328
|
+
const maxDateOnly = new Date(maxDateObj.getFullYear(), maxDateObj.getMonth(), maxDateObj.getDate())
|
|
329
|
+
|
|
330
|
+
return defaultDateOnly > maxDateOnly
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const defaultDateValue: any = defaultDateGetter()
|
|
334
|
+
// Only check for and out-of-range if user actually provided minDate/maxDate constraints
|
|
335
|
+
const isBeforeMin = minDate && isDefaultDateBeforeMinDate(defaultDateValue, setMinDate)
|
|
336
|
+
const isAfterMax = maxDate && isDefaultDateAfterMaxDate(defaultDateValue, setMaxDate)
|
|
337
|
+
|
|
338
|
+
// Store these values for use in onClose handler
|
|
339
|
+
const hasOutOfRangeDefault = (isBeforeMin || isAfterMax) && defaultDateValue
|
|
340
|
+
|
|
341
|
+
// Temporarily adjust minDate/maxDate to allow defaultDate to render if it's out of range via user provided minDate/maxDate constraints
|
|
342
|
+
const effectiveMinDate = isBeforeMin && defaultDateValue && minDate
|
|
343
|
+
? formatDateForFlatpickr(defaultDateValue) || setMinDate
|
|
344
|
+
: setMinDate
|
|
345
|
+
|
|
346
|
+
const effectiveMaxDate = isAfterMax && defaultDateValue && maxDate
|
|
347
|
+
? formatDateForFlatpickr(defaultDateValue) || setMaxDate
|
|
348
|
+
: setMaxDate
|
|
349
|
+
|
|
350
|
+
// End of Default Date + Min/Max Date Initialization Helper Functions section ----/
|
|
351
|
+
|
|
278
352
|
flatpickr(`#${pickerId}`, {
|
|
279
353
|
allowInput,
|
|
280
354
|
closeOnSelect,
|
|
@@ -286,11 +360,32 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
286
360
|
locale: {
|
|
287
361
|
rangeSeparator: ' to '
|
|
288
362
|
},
|
|
289
|
-
maxDate:
|
|
290
|
-
minDate:
|
|
363
|
+
maxDate: effectiveMaxDate,
|
|
364
|
+
minDate: effectiveMinDate,
|
|
291
365
|
mode,
|
|
292
366
|
nextArrow: '<i class="far fa-angle-right"></i>',
|
|
293
367
|
onOpen: [(_selectedDates, _dateStr, fp) => {
|
|
368
|
+
// If defaultDate was out of range of a dev set min/max date, restore it when calendar opens (in situation where the input was manually cleared or the calendar was closed without selection)
|
|
369
|
+
if (hasOutOfRangeDefault) {
|
|
370
|
+
const dateObj = toDateObject(defaultDateValue)
|
|
371
|
+
if (dateObj) {
|
|
372
|
+
const inputIsBlank = !fp.input.value || fp.input.value.trim() === ''
|
|
373
|
+
const noSelection = !fp.selectedDates || fp.selectedDates.length === 0
|
|
374
|
+
|
|
375
|
+
if (inputIsBlank || noSelection) {
|
|
376
|
+
const formattedDate = fp.formatDate(dateObj, getDateFormat())
|
|
377
|
+
if (formattedDate) {
|
|
378
|
+
fp.input.value = formattedDate
|
|
379
|
+
}
|
|
380
|
+
fp.selectedDates = [dateObj]
|
|
381
|
+
fp.jumpToDate(dateObj)
|
|
382
|
+
setTimeout(() => {
|
|
383
|
+
yearChangeHook(fp)
|
|
384
|
+
}, 0)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
294
389
|
calendarResizer()
|
|
295
390
|
if (resizeRepositionHandlerRef) {
|
|
296
391
|
window.removeEventListener('resize', resizeRepositionHandlerRef)
|
|
@@ -303,12 +398,30 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
303
398
|
if (!staticPosition && scrollContainer) attachToScroll(scrollContainer)
|
|
304
399
|
positionCalendarIfNeeded(fp)
|
|
305
400
|
}],
|
|
306
|
-
onClose: [(selectedDates, dateStr) => {
|
|
401
|
+
onClose: [(selectedDates, dateStr, fp) => {
|
|
307
402
|
if (resizeRepositionHandlerRef) {
|
|
308
403
|
window.removeEventListener('resize', resizeRepositionHandlerRef)
|
|
309
404
|
resizeRepositionHandlerRef = null
|
|
310
405
|
}
|
|
311
406
|
if (!staticPosition && scrollContainer) detachFromScroll(scrollContainer as HTMLElement)
|
|
407
|
+
|
|
408
|
+
// If defaultDate was out of range and no date was selected, preserve the default date
|
|
409
|
+
if (hasOutOfRangeDefault && (!selectedDates || selectedDates.length === 0)) {
|
|
410
|
+
const dateObj = toDateObject(defaultDateValue)
|
|
411
|
+
if (dateObj && fp.input) {
|
|
412
|
+
const formattedDate = fp.formatDate(dateObj, getDateFormat())
|
|
413
|
+
if (formattedDate) {
|
|
414
|
+
setTimeout(() => {
|
|
415
|
+
if (fp.input && (!fp.selectedDates || fp.selectedDates.length === 0)) {
|
|
416
|
+
fp.input.value = formattedDate
|
|
417
|
+
fp.selectedDates = [dateObj]
|
|
418
|
+
fp.jumpToDate(dateObj)
|
|
419
|
+
}
|
|
420
|
+
}, 0)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
312
425
|
onClose(selectedDates, dateStr)
|
|
313
426
|
}],
|
|
314
427
|
onChange: [(selectedDates, dateStr, fp) => {
|
|
@@ -330,6 +443,71 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
330
443
|
const picker = document.querySelector<HTMLElement & { [x: string]: any }>(`#${pickerId}`)._flatpickr
|
|
331
444
|
picker.innerContainer.parentElement.id = `cal-${pickerId}`
|
|
332
445
|
|
|
446
|
+
// If defaultDate was out of range, restore the original minDate/maxDate after initialization (defaultDate displayed, still cannot select dates outside the actual range via user provided minDate/maxDate constraints)
|
|
447
|
+
if ((isBeforeMin || isAfterMax) && defaultDateValue) {
|
|
448
|
+
const dateObj = toDateObject(defaultDateValue)
|
|
449
|
+
const formattedDate = dateObj ? picker.formatDate(dateObj, getDateFormat()) : null
|
|
450
|
+
|
|
451
|
+
setTimeout(() => {
|
|
452
|
+
if (!dateObj || !picker.input || !formattedDate) return
|
|
453
|
+
|
|
454
|
+
picker.setDate(dateObj, false)
|
|
455
|
+
|
|
456
|
+
if (isBeforeMin && setMinDate && minDate) {
|
|
457
|
+
picker.set('minDate', setMinDate)
|
|
458
|
+
}
|
|
459
|
+
if (isAfterMax && setMaxDate && maxDate) {
|
|
460
|
+
picker.set('maxDate', setMaxDate)
|
|
461
|
+
}
|
|
462
|
+
picker.input.value = formattedDate
|
|
463
|
+
|
|
464
|
+
picker.selectedDates = [dateObj]
|
|
465
|
+
|
|
466
|
+
setTimeout(() => {
|
|
467
|
+
yearChangeHook(picker)
|
|
468
|
+
}, 0)
|
|
469
|
+
|
|
470
|
+
// Restore function for out-of-range default dates
|
|
471
|
+
const restoreOutOfRangeValue = () => {
|
|
472
|
+
if (!picker.input) return
|
|
473
|
+
|
|
474
|
+
const inputIsBlank = !picker.input.value || picker.input.value.trim() === ''
|
|
475
|
+
const noSelection = !picker.selectedDates || picker.selectedDates.length === 0
|
|
476
|
+
|
|
477
|
+
if (inputIsBlank || noSelection) {
|
|
478
|
+
setTimeout(() => {
|
|
479
|
+
if (picker.input && (!picker.input.value || picker.input.value.trim() === '')) {
|
|
480
|
+
picker.input.value = formattedDate
|
|
481
|
+
}
|
|
482
|
+
if (!picker.selectedDates || picker.selectedDates.length === 0) {
|
|
483
|
+
picker.selectedDates = [dateObj]
|
|
484
|
+
if (picker.isOpen) {
|
|
485
|
+
picker.jumpToDate(dateObj)
|
|
486
|
+
picker.redraw()
|
|
487
|
+
setTimeout(() => {
|
|
488
|
+
yearChangeHook(picker)
|
|
489
|
+
}, 0)
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}, 0)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const originalClear = picker.clear.bind(picker)
|
|
497
|
+
picker.clear = function(...args: any[]) {
|
|
498
|
+
const result = originalClear(...args)
|
|
499
|
+
setTimeout(() => restoreOutOfRangeValue(), 0)
|
|
500
|
+
return result
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
picker.input.addEventListener('input', restoreOutOfRangeValue)
|
|
504
|
+
|
|
505
|
+
picker.config.onClose.push(() => {
|
|
506
|
+
restoreOutOfRangeValue()
|
|
507
|
+
})
|
|
508
|
+
}, 10)
|
|
509
|
+
}
|
|
510
|
+
|
|
333
511
|
// replace year selector with dropdown
|
|
334
512
|
picker.yearElements[0].parentElement.innerHTML = `<select class="numInput cur-year" type="number" tabIndex="-1" aria-label="Year" id="year-${pickerId}"></select>`
|
|
335
513
|
|
|
@@ -51,6 +51,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
51
51
|
cancelButton,
|
|
52
52
|
confirmButton,
|
|
53
53
|
className,
|
|
54
|
+
closeable,
|
|
54
55
|
data = {},
|
|
55
56
|
htmlOptions = {},
|
|
56
57
|
id,
|
|
@@ -187,7 +188,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
|
|
|
187
188
|
style={{ content: dynamicInlineProps }}
|
|
188
189
|
>
|
|
189
190
|
<>
|
|
190
|
-
{title && !status ? <Dialog.Header>{title}</Dialog.Header> : null}
|
|
191
|
+
{title && !status ? <Dialog.Header closeable={closeable}>{title}</Dialog.Header> : null}
|
|
191
192
|
{!status && text ? <Dialog.Body>{text}</Dialog.Body> : null}
|
|
192
193
|
{status && (
|
|
193
194
|
<Dialog.Body
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
>
|
|
15
15
|
<%= pb_content_tag(:dialog, role: "dialog", "aria-modal": "true", "aria-label": "Dialog") do %>
|
|
16
16
|
<% if object.status === "" && object.title %>
|
|
17
|
-
<%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
|
|
17
|
+
<%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id, closeable: object.closeable }) %>
|
|
18
18
|
<% end %>
|
|
19
19
|
<% if object.status === "" && object.text %>
|
|
20
20
|
<%= pb_rails("dialog/dialog_body", props: { text: object.text }) %>
|
|
@@ -23,6 +23,7 @@ module Playbook
|
|
|
23
23
|
default: ""
|
|
24
24
|
prop :custom_event_type, type: Playbook::Props::String,
|
|
25
25
|
default: ""
|
|
26
|
+
prop :closeable, type: Playbook::Props::Boolean, default: true
|
|
26
27
|
|
|
27
28
|
def classname
|
|
28
29
|
generate_classname("pb_dialog pb_dialog_rails pb_dialog_#{size}_#{placement}")
|
|
@@ -129,3 +129,17 @@ test('renders loading dialog with disabled buttons', async () => {
|
|
|
129
129
|
|
|
130
130
|
cleanup()
|
|
131
131
|
})
|
|
132
|
+
|
|
133
|
+
test('renders dialog without close button when closeable is false', async () => {
|
|
134
|
+
|
|
135
|
+
const { queryByText, container } = render(<DialogTest closeable={false} />);
|
|
136
|
+
|
|
137
|
+
fireEvent.click(queryByText('Open Dialog'));
|
|
138
|
+
|
|
139
|
+
await waitFor(() => expect(queryByText("Header Title is the Title Prop")));
|
|
140
|
+
|
|
141
|
+
const closeBtn = container.querySelector('.pb_dialog_close_icon');
|
|
142
|
+
expect(closeBtn).not.toBeInTheDocument();
|
|
143
|
+
|
|
144
|
+
cleanup()
|
|
145
|
+
})
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<%= pb_content_tag(:div, class: object.sticky_header) do %>
|
|
2
2
|
<%= pb_rails("flex", props: {classname:object.classname, spacing:"between", padding:"sm", align:"center"}) do %>
|
|
3
3
|
<%= content.presence || object.title %>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
<% if object.closeable %>
|
|
5
|
+
<button class="dialog-button-class pb_dialog_close_icon" type="button" data-close-dialog= <%= object.id %> aria-label="Close Dialog" >
|
|
6
|
+
<%= pb_rails("icon", props: { custom_icon: Playbook::Engine::root.join(times_icon), aria: { hidden: true } }) %>
|
|
7
|
+
</button>
|
|
8
|
+
<% end %>
|
|
8
9
|
<% end %>
|
|
9
10
|
<%= pb_rails("section_separator") %>
|
|
10
11
|
<% end %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%= pb_rails("flex", props:{wrap:true}) do %>
|
|
2
|
+
<%= pb_rails("button", props: { text: "Open Simple Dialog", data: {"open-dialog": "dialog-simple"}, margin_right:"md" }) %>
|
|
3
|
+
<%= pb_rails("button", props: { text: "Open Complex Dialog", data: {"open-dialog": "dialog-complex2"} }) %>
|
|
4
|
+
<% end %>
|
|
5
|
+
|
|
6
|
+
<%= pb_rails("dialog", props: {
|
|
7
|
+
id:"dialog-simple",
|
|
8
|
+
size: "sm",
|
|
9
|
+
title: "Header Title is the Title Prop",
|
|
10
|
+
text: "Hello Body Text, Nice to meet ya.",
|
|
11
|
+
cancel_button: "Cancel Button",
|
|
12
|
+
closeable: false,
|
|
13
|
+
confirm_button: "Okay",
|
|
14
|
+
confirm_button_id: "confirm-button-simple"
|
|
15
|
+
}) %>
|
|
16
|
+
|
|
17
|
+
<%= pb_rails("dialog", props: {
|
|
18
|
+
id:"dialog-complex2",
|
|
19
|
+
size: "sm"
|
|
20
|
+
}) do %>
|
|
21
|
+
<%= pb_rails("dialog/dialog_header", props: { id: "dialog-complex2", title:"Header Title inside Dialog Header", closeable: false } ) %>
|
|
22
|
+
<%= pb_rails("dialog/dialog_body", props:{text: "Hello Body Text, Nice to meet ya."}) %>
|
|
23
|
+
<%= pb_rails("dialog/dialog_footer", props: {cancel_button: "Cancel Button", confirm_button: "Okay", confirm_button_id:"confirm-complex2", id: "dialog-complex2"}) %>
|
|
24
|
+
<% end %>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import Button from '../../pb_button/_button'
|
|
3
|
+
import Dialog from '../../pb_dialog/_dialog'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const DialogCloseable = () => {
|
|
7
|
+
// Simple example
|
|
8
|
+
const [isOpenSimple, setIsOpenSimple] = useState(false)
|
|
9
|
+
const closeSimple = () => setIsOpenSimple(false)
|
|
10
|
+
const openSimple = () => setIsOpenSimple(true)
|
|
11
|
+
|
|
12
|
+
// Complex example
|
|
13
|
+
const [isOpenComplex, setIsOpenComplex] = useState(false)
|
|
14
|
+
const closeComplex = () => setIsOpenComplex(false)
|
|
15
|
+
const openComplex = () => setIsOpenComplex(true)
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<Button
|
|
20
|
+
marginRight='md'
|
|
21
|
+
onClick={openSimple}
|
|
22
|
+
>
|
|
23
|
+
{'Open Simple Dialog'}
|
|
24
|
+
</Button>
|
|
25
|
+
<Button onClick={openComplex}>{'Open Complex Dialog'}</Button>
|
|
26
|
+
|
|
27
|
+
<Dialog
|
|
28
|
+
cancelButton="Cancel Button"
|
|
29
|
+
closeable={false}
|
|
30
|
+
confirmButton="Okay"
|
|
31
|
+
onCancel={closeSimple}
|
|
32
|
+
onClose={closeSimple}
|
|
33
|
+
onConfirm={closeSimple}
|
|
34
|
+
opened={isOpenSimple}
|
|
35
|
+
size="sm"
|
|
36
|
+
text="Hello Body Text, Nice to meet ya."
|
|
37
|
+
title="Header Title is the Title Prop"
|
|
38
|
+
/>
|
|
39
|
+
<Dialog
|
|
40
|
+
onClose={closeComplex}
|
|
41
|
+
opened={isOpenComplex}
|
|
42
|
+
size="sm"
|
|
43
|
+
>
|
|
44
|
+
<Dialog.Header closeable={false}>{'Header Title inside Dialog.Header'}</Dialog.Header>
|
|
45
|
+
<Dialog.Body>{'Hello Body Text, Nice to meet ya.'}</Dialog.Body>
|
|
46
|
+
<Dialog.Footer>
|
|
47
|
+
<Button onClick={closeComplex}>{'Okay'}</Button>
|
|
48
|
+
<Button
|
|
49
|
+
onClick={closeComplex}
|
|
50
|
+
variant="link"
|
|
51
|
+
>
|
|
52
|
+
{'Cancel Button'}
|
|
53
|
+
</Button>
|
|
54
|
+
</Dialog.Footer>
|
|
55
|
+
</Dialog>
|
|
56
|
+
</>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default DialogCloseable
|
|
@@ -12,6 +12,7 @@ examples:
|
|
|
12
12
|
- dialog_full_height_placement: Full Height Placement
|
|
13
13
|
- dialog_loading: Loading
|
|
14
14
|
- dialog_turbo_frames: Within Turbo Frames
|
|
15
|
+
- dialog_closeable: Close Button in Header
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
react:
|
|
@@ -25,6 +26,7 @@ examples:
|
|
|
25
26
|
- dialog_full_height: Full Height
|
|
26
27
|
- dialog_full_height_placement: Full Height Placement
|
|
27
28
|
- dialog_loading: Loading
|
|
29
|
+
- dialog_closeable: Close Button in Header
|
|
28
30
|
|
|
29
31
|
swift:
|
|
30
32
|
- dialog_default_swift: Simple
|
|
@@ -8,4 +8,5 @@ export { default as DialogStatus } from './_dialog_status.jsx'
|
|
|
8
8
|
export { default as DialogStackedAlert } from './_dialog_stacked_alert.jsx'
|
|
9
9
|
export { default as DialogFullHeight } from './_dialog_full_height.jsx'
|
|
10
10
|
export { default as DialogFullHeightPlacement } from './_dialog_full_height_placement.jsx'
|
|
11
|
-
export { default as DialogLoading } from './_dialog_loading.jsx'
|
|
11
|
+
export { default as DialogLoading } from './_dialog_loading.jsx'
|
|
12
|
+
export { default as DialogCloseable } from './_dialog_closeable.jsx'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](https://playbook.powerapp.cloud/
|
|
1
|
+
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](https://playbook.powerapp.cloud/tokens/colors) for reference.
|