playbook_ui 15.8.0.pre.rc.0 → 15.8.0.pre.rc.1

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +13 -1
  3. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.jsx +56 -0
  4. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.md +10 -0
  5. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.html.erb +64 -0
  6. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.md +10 -0
  7. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
  8. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
  9. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -1
  10. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +121 -0
  11. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +85 -9
  12. data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +83 -2
  13. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
  14. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -3
  15. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +53 -0
  16. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.jsx +71 -0
  17. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.md +1 -0
  18. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_height.jsx +71 -0
  19. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_height.md +1 -0
  20. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +3 -1
  22. data/dist/chunks/{_typeahead-CSCNg6cp.js → _typeahead-D0GNUBXn.js} +1 -1
  23. data/dist/chunks/vendor.js +2 -2
  24. data/dist/playbook-rails-react-bindings.js +1 -1
  25. data/dist/playbook-rails.js +1 -1
  26. data/dist/playbook.css +1 -1
  27. data/lib/playbook/version.rb +1 -1
  28. metadata +11 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d90a9283e859938c8668c9bda85da84fedc435fb8c2e944540fba1a7b834ced
4
- data.tar.gz: 269fdbd32bd3da95347cffbcaca0e9c130e551c2288b0eb92a6f73e9d6e205fa
3
+ metadata.gz: d0177497af81bb89af7b26046f27197942cb10b7a6640df32234376c1f7cedcb
4
+ data.tar.gz: 164f59f14bfffc0a889b4859363c311d09dafddf5c1fce518000a42c4e647623
5
5
  SHA512:
6
- metadata.gz: 8718b1da13b30dc286191523f1ba14e8ec1304389bdd0263f2b71ec6543473b20234090aca5a8d06d56716e9eed8334118429038a31f2e0983dac1c7503b1b59
7
- data.tar.gz: 455f5232737b607d4c6c1d6b574e3bcfd5974246c2daff08bef7196af7e50e3ed3d4512fc4752240adb309ac74f1c56065e325ec7d15202ed3992da226a580a4
6
+ metadata.gz: 6c3ead358396ac6c1adf2c5a2a5af3409513bfc0a944fa7298d74135b66ea59f865e30a51167b6f81247967b5ac2be7326aa5717d5b3d0c2993a2a2a96831d48
7
+ data.tar.gz: 4a5d41bdcc5e01b9dc0a3ffbaba5292702873902e5325dfeba5759e54049e03c95ce6ba760a0c0e8b1c9bd35c0ca6958bbec137fe7a33da7d978148cc6bc5b2f
@@ -20,12 +20,23 @@ import {
20
20
  handleClickOutside,
21
21
  } from "./utilities";
22
22
 
23
+ type CustomQuickPickDate = {
24
+ label: string;
25
+ value: string[] | { timePeriod: string; amount: number };
26
+ };
27
+
28
+ type CustomQuickPickDates = {
29
+ override?: boolean;
30
+ dates: CustomQuickPickDate[];
31
+ };
32
+
23
33
  type DropdownProps = {
24
34
  aria?: { [key: string]: string };
25
35
  autocomplete?: boolean;
26
36
  blankSelection?: string;
27
37
  children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
28
38
  className?: string;
39
+ customQuickPickDates?: CustomQuickPickDates;
29
40
  formPillProps?: GenericObject;
30
41
  dark?: boolean;
31
42
  data?: { [key: string]: string };
@@ -63,6 +74,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
63
74
  blankSelection = '',
64
75
  children,
65
76
  className,
77
+ customQuickPickDates,
66
78
  dark = false,
67
79
  data = {},
68
80
  defaultValue = {},
@@ -95,7 +107,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
95
107
  // ------------- Quick Pick ---------------------------------
96
108
  // Use QuickPick options when variant is "quickpick"
97
109
  const dropdownOptions = variant === "quickpick"
98
- ? getQuickPickOptions(rangeEndsToday)
110
+ ? getQuickPickOptions(rangeEndsToday, customQuickPickDates)
99
111
  : (options || []);
100
112
  // ----------------------------------------------------------
101
113
 
@@ -0,0 +1,56 @@
1
+ import React from "react"
2
+ import Dropdown from "../_dropdown"
3
+
4
+ const DropdownQuickpickCustom = (props) => (
5
+ <div>
6
+ <Dropdown
7
+ customQuickPickDates={{
8
+ dates: [
9
+ // Allow Playbook to handle the logic...
10
+ {
11
+ label: "Last 15 months",
12
+ value: {
13
+ timePeriod: "months",
14
+ amount: 15,
15
+ },
16
+ },
17
+ // Or, be explicit with an exact date range for more control...
18
+ {
19
+ label: "First Week of June 2022",
20
+ value: ["06/01/2022", "06/07/2022"],
21
+ },
22
+ ],
23
+ }}
24
+ label="Date Range"
25
+ marginBottom="sm"
26
+ onSelect={(selectedItem) => console.log(selectedItem)}
27
+ variant="quickpick"
28
+ {...props}
29
+ />
30
+ <Dropdown
31
+ customQuickPickDates={{
32
+ dates: [
33
+ {
34
+ label: "Last 15 months",
35
+ value: {
36
+ timePeriod: "months",
37
+ amount: 15,
38
+ },
39
+ },
40
+ {
41
+ label: "First Week of June 2022",
42
+ value: ["06/01/2022", "06/07/2022"],
43
+ },
44
+ ],
45
+ override: false,
46
+ }}
47
+ label="Date Range - Append to Defaults"
48
+ onSelect={(selectedItem) => console.log(selectedItem)}
49
+ variant="quickpick"
50
+ {...props}
51
+ />
52
+ </div>
53
+ )
54
+
55
+ export default DropdownQuickpickCustom
56
+
@@ -0,0 +1,10 @@
1
+ The `customQuickPickDates` prop allows for defining custom quick pick date options for the dropdown. The prop accepts an object with two properties: `dates` and `override`.
2
+
3
+ **The `dates` property** accepts an array of objects. Each object has `label` and `value` properties. The `label` is what will be displayed in the dropdown menu. The `value` property defines the date range that will be selected, and can be:
4
+ - An array of two date strings representing a specific range (e.g., `["06/01/2022", "06/07/2022"]`)
5
+ - An object with `timePeriod` and `amount` properties for dynamic date calculations:
6
+ - The `timePeriod` property accepts `"days"`, `"weeks"`, `"months"`, `"quarters"`, or `"years"`, representing past time periods calculated from today.
7
+ - The `amount` property accepts any number.
8
+
9
+ **The `override` property** is a boolean that controls whether custom dates replace or append to the default quick pick options. Default is `true` (replaces defaults). Set to `false` to append your custom dates to the default quick pick options.
10
+
@@ -0,0 +1,64 @@
1
+ <%= pb_rails("dropdown", props: {
2
+ custom_quick_pick_dates: {
3
+ dates: [
4
+ # Allow Playbook to handle the logic...
5
+ {
6
+ label: "Last 15 months",
7
+ value: {
8
+ time_period: "months",
9
+ amount: 15
10
+ }
11
+ },
12
+ # Or, be explicit with an exact date range for more control...
13
+ {
14
+ label: "First Week of June 2022",
15
+ value: ["06/01/2022", "06/07/2022"]
16
+ }
17
+ ]
18
+ },
19
+ id: "date-range-quickpick-custom",
20
+ label: "Date Range",
21
+ margin_bottom: "sm",
22
+ variant: "quickpick"
23
+ }) %>
24
+
25
+ <%= pb_rails("dropdown", props: {
26
+ custom_quick_pick_dates: {
27
+ override: false,
28
+ dates: [
29
+ {
30
+ label: "Last 15 months",
31
+ value: {
32
+ time_period: "months",
33
+ amount: 15
34
+ }
35
+ },
36
+ {
37
+ label: "First Week of June 2022",
38
+ value: ["06/01/2022", "06/07/2022"]
39
+ }
40
+ ]
41
+ },
42
+ id: "date-range-quickpick-custom-append-to-defaults",
43
+ label: "Date Range - Append to Defaults",
44
+ variant: "quickpick"
45
+ }) %>
46
+
47
+ <script>
48
+ const dropdown1 = document.getElementById("date-range-quickpick-custom");
49
+ if (dropdown1) {
50
+ dropdown1.addEventListener("pb:dropdown:selected", (e) => {
51
+ const option = e.detail;
52
+ console.log("Selected option:", option);
53
+ });
54
+ }
55
+
56
+ const dropdown2 = document.getElementById("date-range-quickpick-custom-append-to-defaults");
57
+ if (dropdown2) {
58
+ dropdown2.addEventListener("pb:dropdown:selected", (e) => {
59
+ const option = e.detail;
60
+ console.log("Selected option:", option);
61
+ });
62
+ }
63
+ </script>
64
+
@@ -0,0 +1,10 @@
1
+ The `custom_quick_pick_dates` prop allows for defining custom quick pick date options for the dropdown. The prop accepts an object with two properties: `dates` and `override`.
2
+
3
+ **The `dates` property** accepts an array of objects. Each object has `label` and `value` properties. The `label` is what will be displayed in the dropdown menu. The `value` property defines the date range that will be selected, and can be:
4
+ - An array of two date strings representing a specific range (e.g., `["06/01/2022", "06/07/2022"]`)
5
+ - An object with `time_period` and `amount` properties for dynamic date calculations:
6
+ - The `time_period` property accepts `"days"`, `"weeks"`, `"months"`, `"quarters"`, or `"years"`, representing past time periods calculated from today.
7
+ - The `amount` property accepts any number.
8
+
9
+ **The `override` property** is a boolean that controls whether custom dates replace or append to the default quick pick options. Default is `true` (replaces defaults). Set to `false` to append your custom dates to the default quick pick options.
10
+
@@ -25,6 +25,7 @@ examples:
25
25
  - dropdown_quickpick_rails: Quick Pick Variant
26
26
  - dropdown_quickpick_range_end_rails: Quick Pick Variant (Range Ends Today)
27
27
  - dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
28
+ - dropdown_quickpick_custom_rails: Quick Pick Variant (Custom Quick Pick Dates)
28
29
  - dropdown_quickpick_with_date_pickers_rails: Quick Pick with Date Pickers
29
30
  - dropdown_quickpick_with_date_pickers_default_rails: Quick Pick with Date Pickers (Default Value)
30
31
 
@@ -57,6 +58,7 @@ examples:
57
58
  - dropdown_quickpick: Quick Pick Variant
58
59
  - dropdown_quickpick_range_end: Quick Pick Variant (Range Ends Today)
59
60
  - dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
61
+ - dropdown_quickpick_custom: Quick Pick Variant (Custom Quick Pick Dates)
60
62
  - dropdown_quickpick_with_date_pickers: Quick Pick Variant with Date Pickers
61
63
 
62
64
 
@@ -26,4 +26,5 @@ export {default as DropdownWithCustomActiveStyleOptions} from './_dropdown_with_
26
26
  export { default as DropdownQuickpick } from './_dropdown_quickpick.jsx'
27
27
  export { default as DropdownQuickpickRangeEnd } from './_dropdown_quickpick_range_end.jsx'
28
28
  export { default as DropdownQuickpickDefaultDates } from './_dropdown_quickpick_default_dates.jsx'
29
- export { default as DropdownQuickpickWithDatePickers } from './_dropdown_quickpick_with_date_pickers.jsx'
29
+ export { default as DropdownQuickpickWithDatePickers } from './_dropdown_quickpick_with_date_pickers.jsx'
30
+ export { default as DropdownQuickpickCustom } from './_dropdown_quickpick_custom.jsx'
@@ -15,6 +15,8 @@ module Playbook
15
15
  prop :default_value
16
16
  prop :blank_selection, type: Playbook::Props::String,
17
17
  default: ""
18
+ prop :custom_quick_pick_dates, type: Playbook::Props::HashProp,
19
+ default: {}
18
20
  prop :variant, type: Playbook::Props::Enum,
19
21
  values: %w[default subtle quickpick],
20
22
  default: "default"
@@ -94,7 +96,10 @@ module Playbook
94
96
  end
95
97
 
96
98
  def quickpick_options
97
- QuickpickHelper.get_quickpick_options(range_ends_today: range_ends_today)
99
+ QuickpickHelper.get_quickpick_options(
100
+ range_ends_today: range_ends_today,
101
+ custom_quick_pick_dates: custom_quick_pick_dates
102
+ )
98
103
  end
99
104
  end
100
105
  end
@@ -539,4 +539,125 @@ test("quickpick option values are Date objects", () => {
539
539
  expect(endDate.getTime()).not.toBeNaN()
540
540
 
541
541
  expect(endDate.getTime()).toBeGreaterThanOrEqual(startDate.getTime())
542
+ })
543
+
544
+ test("customQuickPickDates overrides default options when override is true or undefined", () => {
545
+ render(
546
+ <Dropdown
547
+ customQuickPickDates={{
548
+ dates: [
549
+ {
550
+ label: "Last 15 months",
551
+ value: { timePeriod: "months", amount: 15 }
552
+ },
553
+ {
554
+ label: "Custom Range",
555
+ value: ["06/01/2022", "06/07/2022"]
556
+ }
557
+ ]
558
+ }}
559
+ data={{ testid: testId }}
560
+ variant="quickpick"
561
+ />
562
+ )
563
+
564
+ const kit = screen.getByTestId(testId)
565
+ const options = kit.querySelectorAll('.pb_dropdown_option_list')
566
+
567
+ expect(options.length).toBe(2)
568
+ expect(options[0]).toHaveTextContent("Last 15 months")
569
+ expect(options[1]).toHaveTextContent("Custom Range")
570
+ })
571
+
572
+ test("customQuickPickDates appends to defaults when override is false", () => {
573
+ render(
574
+ <Dropdown
575
+ customQuickPickDates={{
576
+ override: false,
577
+ dates: [
578
+ {
579
+ label: "Custom Option",
580
+ value: { timePeriod: "days", amount: 30 }
581
+ }
582
+ ]
583
+ }}
584
+ data={{ testid: testId }}
585
+ variant="quickpick"
586
+ />
587
+ )
588
+
589
+ const kit = screen.getByTestId(testId)
590
+ const options = kit.querySelectorAll('.pb_dropdown_option_list')
591
+
592
+ expect(options.length).toBe(11)
593
+ expect(options[0]).toHaveTextContent("Today")
594
+ expect(options[10]).toHaveTextContent("Custom Option")
595
+ })
596
+
597
+ test("customQuickPickDates with explicit date array returns correct values", () => {
598
+ const onSelectMock = jest.fn()
599
+
600
+ render(
601
+ <Dropdown
602
+ customQuickPickDates={{
603
+ dates: [
604
+ {
605
+ label: "First Week of June 2022",
606
+ value: ["06/01/2022", "06/07/2022"]
607
+ }
608
+ ]
609
+ }}
610
+ data={{ testid: testId }}
611
+ onSelect={onSelectMock}
612
+ variant="quickpick"
613
+ />
614
+ )
615
+
616
+ const kit = screen.getByTestId(testId)
617
+ const option = kit.querySelector('.pb_dropdown_option_list')
618
+
619
+ fireEvent.click(option)
620
+
621
+ const selectedItem = onSelectMock.mock.calls[0][0]
622
+
623
+ expect(selectedItem.label).toBe("First Week of June 2022")
624
+ expect(Array.isArray(selectedItem.value)).toBe(true)
625
+ expect(selectedItem.value.length).toBe(2)
626
+ })
627
+
628
+ test("customQuickPickDates with timePeriod calculates dates correctly", () => {
629
+ const onSelectMock = jest.fn()
630
+
631
+ render(
632
+ <Dropdown
633
+ customQuickPickDates={{
634
+ dates: [
635
+ {
636
+ label: "Last 7 days",
637
+ value: { timePeriod: "days", amount: 7 }
638
+ }
639
+ ]
640
+ }}
641
+ data={{ testid: testId }}
642
+ onSelect={onSelectMock}
643
+ variant="quickpick"
644
+ />
645
+ )
646
+
647
+ const kit = screen.getByTestId(testId)
648
+ const option = kit.querySelector('.pb_dropdown_option_list')
649
+
650
+ fireEvent.click(option)
651
+
652
+ const selectedItem = onSelectMock.mock.calls[0][0]
653
+
654
+ expect(selectedItem.label).toBe("Last 7 days")
655
+ expect(Array.isArray(selectedItem.value)).toBe(true)
656
+
657
+ const [startDate, endDate] = selectedItem.value
658
+ expect(startDate instanceof Date).toBe(true)
659
+ expect(endDate instanceof Date).toBe(true)
660
+
661
+ const today = new Date()
662
+ expect(endDate.toDateString()).toBe(today.toDateString())
542
663
  })
@@ -11,8 +11,78 @@ type QuickPickOption = {
11
11
  id?: string;
12
12
  };
13
13
 
14
+ type CustomQuickPickDate = {
15
+ label: string;
16
+ value: string[] | { timePeriod: string; amount: number };
17
+ };
18
+
19
+ type CustomQuickPickDates = {
20
+ override?: boolean;
21
+ dates: CustomQuickPickDate[];
22
+ };
23
+
24
+ // Helper function to calculate date range from timePeriod and amount
25
+ const calculateDateRange = (timePeriod: string, amount: number): Date[] => {
26
+ const endDate = new Date();
27
+ const startDate = new Date();
28
+
29
+ switch (timePeriod) {
30
+ case 'days':
31
+ startDate.setDate(endDate.getDate() - amount);
32
+ break;
33
+ case 'weeks':
34
+ startDate.setDate(endDate.getDate() - (amount * 7));
35
+ break;
36
+ case 'months':
37
+ startDate.setMonth(endDate.getMonth() - amount);
38
+ break;
39
+ case 'quarters':
40
+ startDate.setMonth(endDate.getMonth() - (amount * 3));
41
+ break;
42
+ case 'years':
43
+ startDate.setFullYear(endDate.getFullYear() - amount);
44
+ break;
45
+ default:
46
+ throw new Error('Invalid time period');
47
+ }
48
+ return [startDate, endDate];
49
+ };
50
+
51
+ // Helper to format date for display
52
+ const formatDate = (date: Date) => {
53
+ const day = String(date.getDate()).padStart(2, "0");
54
+ const month = String(date.getMonth() + 1).padStart(2, "0");
55
+ const year = date.getFullYear();
56
+
57
+ return `${month}/${day}/${year}`;
58
+ };
59
+
60
+ // Helper to create a QuickPickOption from a custom date
61
+ const createOptionFromCustomDate = (customDate: CustomQuickPickDate): QuickPickOption => {
62
+ let dateRange: Date[];
63
+
64
+ if (Array.isArray(customDate.value)) {
65
+ // Explicit date range as string array
66
+ dateRange = customDate.value.map((dateStr: string) => new Date(dateStr));
67
+ } else {
68
+ // Calculate from timePeriod and amount
69
+ dateRange = calculateDateRange(
70
+ customDate.value.timePeriod,
71
+ customDate.value.amount
72
+ );
73
+ }
74
+
75
+ return {
76
+ label: customDate.label,
77
+ value: dateRange,
78
+ formattedStartDate: formatDate(dateRange[0]),
79
+ formattedEndDate: formatDate(dateRange[1]),
80
+ id: `quickpick-${customDate.label.toLowerCase().replace(/\s+/g, '-')}`,
81
+ };
82
+ };
83
+
14
84
  // Helper to get QuickPick options with date ranges
15
- const getQuickPickOptions = (rangeEndsToday = false): QuickPickOption[] => {
85
+ const getQuickPickOptions = (rangeEndsToday = false, customQuickPickDates?: CustomQuickPickDates): QuickPickOption[] => {
16
86
  const today = new Date();
17
87
  const yesterday = DateTime.getYesterdayDate(new Date());
18
88
 
@@ -36,14 +106,7 @@ const getQuickPickOptions = (rangeEndsToday = false): QuickPickOption[] => {
36
106
  const lastYearStartDate = DateTime.getPreviousYearStartDate(new Date());
37
107
  const lastYearEndDate = DateTime.getPreviousYearEndDate(new Date());
38
108
 
39
- const formatDate = (date: Date) => {
40
- const day = String(date.getDate()).padStart(2, "0")
41
- const month = String(date.getMonth() + 1).padStart(2, "0")
42
- const year = date.getFullYear()
43
-
44
- return `${month}/${day}/${year}`
45
- }
46
- return [
109
+ const defaultOptions: QuickPickOption[] = [
47
110
  { label: 'Today', value: [today, today], id: 'quickpick-today' },
48
111
  { label: 'Yesterday', value: [yesterday, yesterday], formattedStartDate: `${formatDate(yesterday)}`, formattedEndDate: `${formatDate(yesterday)}`, id: 'quickpick-yesterday' },
49
112
  { label: 'This Week', value: [thisWeekStartDate, thisWeekEndDate], formattedStartDate: `${formatDate(thisWeekStartDate)}`, formattedEndDate: `${formatDate(thisWeekEndDate)}`, id: 'quickpick-this-week' },
@@ -55,6 +118,19 @@ const getQuickPickOptions = (rangeEndsToday = false): QuickPickOption[] => {
55
118
  { label: 'Last Quarter', value: [lastQuarterStartDate, lastQuarterEndDate], formattedStartDate: `${formatDate(lastQuarterStartDate)}`, formattedEndDate: `${formatDate(lastQuarterEndDate)}`, id: 'quickpick-last-quarter' },
56
119
  { label: 'Last Year', value: [lastYearStartDate, lastYearEndDate], formattedStartDate: `${formatDate(lastYearStartDate)}`, formattedEndDate: `${formatDate(lastYearEndDate)}`, id: 'quickpick-last-year' },
57
120
  ];
121
+
122
+ // Handle customQuickPickDates and override logic
123
+ if (customQuickPickDates && customQuickPickDates.dates && customQuickPickDates.dates.length > 0) {
124
+ const customOptions = customQuickPickDates.dates.map(createOptionFromCustomDate);
125
+
126
+ if (customQuickPickDates.override === false) {
127
+ return [...defaultOptions, ...customOptions];
128
+ }
129
+
130
+ return customOptions;
131
+ }
132
+
133
+ return defaultOptions;
58
134
  };
59
135
 
60
136
  export default getQuickPickOptions
@@ -4,7 +4,31 @@ module Playbook
4
4
  module PbDropdown
5
5
  module QuickpickHelper
6
6
  class << self
7
- def get_quickpick_options(range_ends_today: false)
7
+ def get_quickpick_options(range_ends_today: false, custom_quick_pick_dates: {})
8
+ default_options = build_default_options(range_ends_today)
9
+
10
+ # Handle custom_quick_pick_dates
11
+ return default_options if custom_quick_pick_dates.blank?
12
+
13
+ dates = custom_quick_pick_dates[:dates] || custom_quick_pick_dates["dates"]
14
+ return default_options if dates.blank?
15
+
16
+ custom_options = dates.map { |date_config| build_custom_option(date_config) }
17
+
18
+ # Override logic
19
+ override = custom_quick_pick_dates[:override]
20
+ override = custom_quick_pick_dates["override"] if override.nil?
21
+
22
+ if override == false
23
+ default_options + custom_options
24
+ else
25
+ custom_options
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def build_default_options(range_ends_today)
8
32
  today = Date.today
9
33
  yesterday = today - 1.day
10
34
 
@@ -42,7 +66,64 @@ module Playbook
42
66
  ]
43
67
  end
44
68
 
45
- private
69
+ def build_custom_option(date_config)
70
+ label = date_config[:label] || date_config["label"]
71
+ value = date_config[:value] || date_config["value"]
72
+
73
+ date_range = calculate_date_range(value)
74
+ start_date = date_range[0]
75
+ end_date = date_range[1]
76
+
77
+ {
78
+ id: "quickpick-#{label.downcase.gsub(/\s+/, '-')}",
79
+ label: label,
80
+ value: [start_date.to_s, end_date.to_s],
81
+ formatted_start_date: format_date(start_date),
82
+ formatted_end_date: format_date(end_date),
83
+ }
84
+ end
85
+
86
+ def calculate_date_range(value)
87
+ # Parse date strings if value is an array
88
+ if value.is_a?(Array)
89
+ [parse_date_string(value[0]), parse_date_string(value[1])]
90
+ else
91
+ # Calculate date range from time_period and amount
92
+ time_period = value[:time_period] || value["time_period"] || value[:timePeriod] || value["timePeriod"]
93
+ amount = value[:amount] || value["amount"]
94
+
95
+ end_date = Date.today
96
+ start_date = calculate_start_date(time_period, amount, end_date)
97
+
98
+ [start_date, end_date]
99
+ end
100
+ end
101
+
102
+ def parse_date_string(date_str)
103
+ # Handle US date format (MM/DD/YYYY) because Ruby's Date.parse defaults to European format (DD/MM/YYYY)
104
+ if date_str.include?("/")
105
+ Date.strptime(date_str, "%m/%d/%Y")
106
+ else
107
+ Date.parse(date_str)
108
+ end
109
+ end
110
+
111
+ def calculate_start_date(time_period, amount, end_date)
112
+ case time_period.to_s
113
+ when "days"
114
+ end_date - amount.days
115
+ when "weeks"
116
+ end_date - amount.weeks
117
+ when "months"
118
+ end_date - amount.months
119
+ when "quarters"
120
+ end_date - (amount * 3).months
121
+ when "years"
122
+ end_date - amount.years
123
+ else
124
+ raise ArgumentError, "Invalid time period: #{time_period}"
125
+ end
126
+ end
46
127
 
47
128
  def format_date(date)
48
129
  date.strftime("%m/%d/%Y")
@@ -4,7 +4,7 @@ import Flex from "../../pb_flex/_flex";
4
4
  import FlexItem from "../../pb_flex/_flex_item";
5
5
  import SectionSeparator from "../../pb_section_separator/_section_separator";
6
6
 
7
- import EditorButton from "./EditorButton";
7
+ import EditorButton from "./EditorButton";
8
8
  import ToolbarDropdown from "./ToolbarDropdown";
9
9
  import ToolbarNodes from "./ToolbarNodes";
10
10
  import { ToolbarTypes } from "./EditorTypes";
@@ -44,6 +44,8 @@ type RichTextEditorProps = {
44
44
  name?: string,
45
45
  onChange: (html: string, text: string) => void,
46
46
  placeholder?: string,
47
+ inputHeight?: "sm" | "md" | "lg",
48
+ inputMinHeight?: "sm" | "md" | "lg",
47
49
  simple?: boolean,
48
50
  sticky?: boolean,
49
51
  template: string,
@@ -68,6 +70,8 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
68
70
  name,
69
71
  onChange = noop,
70
72
  placeholder,
73
+ inputHeight,
74
+ inputMinHeight,
71
75
  simple = false,
72
76
  sticky = false,
73
77
  template = '',
@@ -214,9 +218,10 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
214
218
  {
215
219
  advancedEditor ? (
216
220
  <div
217
- className={classnames("pb_rich_text_editor_advanced_container", {
218
- ["toolbar-active"]: shouldShowToolbar,
219
- })}
221
+ className={classnames(
222
+ "pb_rich_text_editor_advanced_container",
223
+ { [`input_height_${inputHeight}`]: !!inputHeight,[`input_min_height_${inputMinHeight}`]: !!inputMinHeight ,["toolbar-active"]: shouldShowToolbar }
224
+ )}
220
225
  >
221
226
  {shouldShowToolbar && (
222
227
  <EditorToolbar editor={advancedEditor}
@@ -205,6 +205,59 @@
205
205
  }
206
206
  }
207
207
  }
208
+
209
+ .pb_rich_text_editor_advanced_container.input_height_sm {
210
+ div {
211
+ .tiptap.ProseMirror {
212
+ height: 131px;
213
+ overflow: auto;
214
+ }
215
+ }
216
+ }
217
+
218
+ .pb_rich_text_editor_advanced_container.input_height_md {
219
+ div {
220
+ .tiptap.ProseMirror {
221
+ height: 180px;
222
+ overflow: auto;
223
+ }
224
+ }
225
+ }
226
+
227
+ .pb_rich_text_editor_advanced_container.input_height_lg {
228
+ div {
229
+ .tiptap.ProseMirror {
230
+ height: 230px;
231
+ overflow: auto;
232
+ }
233
+ }
234
+ }
235
+
236
+ .pb_rich_text_editor_advanced_container.input_min_height_sm {
237
+ div {
238
+ .tiptap.ProseMirror {
239
+ min-height: 131px;
240
+ }
241
+ }
242
+ }
243
+
244
+ .pb_rich_text_editor_advanced_container.input_min_height_md {
245
+ div {
246
+ .tiptap.ProseMirror {
247
+ min-height: 180px;
248
+ }
249
+ }
250
+ }
251
+
252
+ .pb_rich_text_editor_advanced_container.input_min_height_lg {
253
+ div {
254
+ .tiptap.ProseMirror {
255
+ min-height: 230px;
256
+ }
257
+ }
258
+ }
259
+
260
+
208
261
  .tiptap-content {
209
262
  @include preview_tiptap_first_child;
210
263
  a {