playbook_ui 15.5.0 → 15.6.0.pre.alpha.PLAY2686contactkittextonly13049
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_advanced_table/_advanced_table.scss +96 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_background/_background.tsx +6 -6
- data/app/pb_kits/playbook/pb_background/background.test.js +5 -1
- data/app/pb_kits/playbook/pb_background/docs/_background_light.html.erb +1 -1
- data/app/pb_kits/playbook/pb_background/docs/_background_light.jsx +0 -1
- data/app/pb_kits/playbook/pb_background/docs/_background_light.md +1 -0
- data/app/pb_kits/playbook/pb_background/docs/example.yml +2 -2
- 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_contact/_contact.tsx +51 -24
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +53 -19
- data/app/pb_kits/playbook/pb_contact/contact.rb +11 -1
- data/app/pb_kits/playbook/pb_contact/contact.test.js +76 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.html.erb +33 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.jsx +46 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_rails.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_react.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/index.js +1 -0
- 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/docs/_dialog_compound_components.html.erb +31 -0
- 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 +458 -7
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +8 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.jsx +180 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.md +22 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +77 -1
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +4 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +34 -22
- data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.html.erb +16 -12
- data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_home_address_street/none_emphasis.html.erb +16 -12
- data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.html.erb +16 -12
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +10 -0
- data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.tsx +66 -15
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.jsx +42 -0
- data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.md +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_multiple_users/multiple_users.test.js +25 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +44 -10
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +34 -4
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.jsx +16 -7
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +8 -3
- data/app/pb_kits/playbook/pb_select/docs/_select_error.md +1 -1
- 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_table/_table.tsx +187 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +134 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +101 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +33 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +180 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +122 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -0
- data/app/pb_kits/playbook/pb_table/table.html.erb +68 -12
- data/app/pb_kits/playbook/pb_table/table.rb +22 -3
- data/app/pb_kits/playbook/pb_table/table.test.js +143 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.md +1 -1
- 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/pb_typeahead/_typeahead.test.jsx +15 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +13 -2
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +6 -1
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +34 -7
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.html.erb +30 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.jsx +37 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.md +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +6 -1
- data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
- data/app/pb_kits/playbook/utilities/deprecated.ts +73 -0
- data/dist/chunks/_typeahead-CHwm9MTE.js +6 -0
- data/dist/chunks/lib-Cugvy62C.js +29 -0
- data/dist/chunks/vendor.js +3 -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 +35 -0
- data/lib/playbook/version.rb +2 -2
- metadata +31 -5
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
- data/dist/chunks/_typeahead-Bx4QsIEU.js +0 -6
- data/dist/chunks/lib-Dk4GKPut.js +0 -29
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<%= pb_rails("body", props: { color: "default" }) do %>
|
|
2
|
+
<%= pb_rails("contact", props: {
|
|
3
|
+
contact_value: "2125551234",
|
|
4
|
+
icon_enabled: false,
|
|
5
|
+
unstyled: true
|
|
6
|
+
}) %>
|
|
7
|
+
<% end %>
|
|
8
|
+
|
|
9
|
+
<%= pb_rails("body", props: { color: "light" }) do %>
|
|
10
|
+
<%= pb_rails("contact", props: {
|
|
11
|
+
contact_value: "12125551234",
|
|
12
|
+
icon_enabled: false,
|
|
13
|
+
unstyled: true
|
|
14
|
+
}) %>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<%= pb_rails("body", props: { color: "lighter" }) do %>
|
|
18
|
+
<%= pb_rails("contact", props: {
|
|
19
|
+
contact_value: "4155551234",
|
|
20
|
+
icon_enabled: false,
|
|
21
|
+
unstyled: true
|
|
22
|
+
}) %>
|
|
23
|
+
<% end %>
|
|
24
|
+
|
|
25
|
+
<%= pb_rails("body", props: { color: "default" }) do %>
|
|
26
|
+
<%= pb_rails("contact", props: {
|
|
27
|
+
contact_type: "extension",
|
|
28
|
+
contact_value: "1234",
|
|
29
|
+
icon_enabled: false,
|
|
30
|
+
unstyled: true
|
|
31
|
+
}) %>
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Contact from "../../pb_contact/_contact"
|
|
3
|
+
import Body from "../../pb_body/_body"
|
|
4
|
+
|
|
5
|
+
const ContactUnstyled = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<div>
|
|
8
|
+
<Body color="default">
|
|
9
|
+
<Contact
|
|
10
|
+
contactValue="2125551234"
|
|
11
|
+
iconEnabled={false}
|
|
12
|
+
unstyled
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
</Body>
|
|
16
|
+
<Body color="light">
|
|
17
|
+
<Contact
|
|
18
|
+
contactValue="12125551234"
|
|
19
|
+
iconEnabled={false}
|
|
20
|
+
unstyled
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
</Body>
|
|
24
|
+
<Body color="lighter">
|
|
25
|
+
<Contact
|
|
26
|
+
contactValue="4155551234"
|
|
27
|
+
iconEnabled={false}
|
|
28
|
+
unstyled
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
</Body>
|
|
32
|
+
<Body color="default">
|
|
33
|
+
<Contact
|
|
34
|
+
contactType="extension"
|
|
35
|
+
contactValue="1234"
|
|
36
|
+
iconEnabled={false}
|
|
37
|
+
unstyled
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
</Body>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default ContactUnstyled
|
|
46
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Use the Contact kit with `icon_enabled: false` and `unstyled: true` to display phone numbers with full typography control. When `unstyled: true`, the Contact kit renders just the formatted text without a Body wrapper, allowing you to wrap it in your own Typography kit to control the color and styling.
|
|
2
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Use the Contact kit with `iconEnabled={false}` and `unstyled` to display phone numbers with full typography control. With `unstyled`, the Contact kit renders just the formatted text without a Body wrapper, allowing you to wrap it in your own Typography kit to control the color and styling.
|
|
2
|
+
|
|
@@ -3,11 +3,13 @@ examples:
|
|
|
3
3
|
rails:
|
|
4
4
|
- contact_default: Default
|
|
5
5
|
- contact_with_detail: Detail Indicator
|
|
6
|
+
- contact_unstyled: Unstyled
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
react:
|
|
9
10
|
- contact_default: Default
|
|
10
11
|
- contact_with_detail: Detail Indicator
|
|
12
|
+
- contact_unstyled: Unstyled
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
swift:
|
|
@@ -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
|
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
<%
|
|
2
|
+
options = [
|
|
3
|
+
{
|
|
4
|
+
label: "United States",
|
|
5
|
+
value: "unitedStates",
|
|
6
|
+
id: "us"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: "United Kingdom",
|
|
10
|
+
value: "unitedKingdom",
|
|
11
|
+
id: "gb"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: "Pakistan",
|
|
15
|
+
value: "pakistan",
|
|
16
|
+
id: "pk"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
%>
|
|
20
|
+
|
|
21
|
+
|
|
1
22
|
<%= pb_rails("button", props: { text: "Open Complex Dialog", data:{"open-dialog": "dialog-complex"} }) %>
|
|
2
23
|
|
|
3
24
|
<%= pb_rails("dialog", props: { id:"dialog-complex", size: "lg", full_height: true }) do %>
|
|
@@ -10,6 +31,16 @@
|
|
|
10
31
|
<%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here"}) %>
|
|
11
32
|
<%= pb_rails("caption", props: { text: "Type in a word or term too help find tickets later. ex. training, phone setup, hr", margin_bottom: "xs", margin_top: "sm" }) %>
|
|
12
33
|
<%= pb_rails("typeahead", props: { placeholder: "Tags.."}) %>
|
|
34
|
+
<%= pb_rails("dropdown", props: {options: options, autocomplete: true}) %>
|
|
35
|
+
<%= pb_rails("typeahead", props: {
|
|
36
|
+
id: "typeahead-default",
|
|
37
|
+
placeholder: "Select one...",
|
|
38
|
+
options: options,
|
|
39
|
+
name: :foo,
|
|
40
|
+
margin_top: "sm",
|
|
41
|
+
is_multi: false
|
|
42
|
+
})
|
|
43
|
+
%>
|
|
13
44
|
|
|
14
45
|
<% end %>
|
|
15
46
|
<%= pb_rails("dialog/dialog_footer", props: {cancel_button: "Back", confirm_button: "Send my Issue", confirm_button_id:"confirm-complex", id: "dialog-complex"}) %>
|
|
@@ -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.
|