playbook_ui 15.7.0.pre.alpha.PLAY2675dropdownquickpickcustomquickpickdates13330 → 15.7.0.pre.alpha.play2607setheightofeditor13370

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -13
  3. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -2
  4. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
  5. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +1 -6
  6. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -121
  7. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +9 -85
  8. data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +2 -83
  9. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +9 -7
  10. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +3 -8
  11. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
  12. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -3
  13. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +53 -0
  14. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.jsx +71 -0
  15. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.md +1 -0
  16. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_heigh.md +1 -0
  17. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_height.jsx +71 -0
  18. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -0
  19. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +3 -1
  20. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +41 -3
  21. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.html.erb +7 -0
  22. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.jsx +24 -0
  23. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.md +2 -0
  24. data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -0
  25. data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
  26. data/app/pb_kits/playbook/pb_text_input/index.js +49 -8
  27. data/app/pb_kits/playbook/pb_text_input/text_input.rb +5 -1
  28. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +53 -0
  29. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +38 -2
  30. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.html.erb +5 -0
  31. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.jsx +24 -0
  32. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.md +1 -0
  33. data/app/pb_kits/playbook/pb_textarea/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_textarea/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_textarea/index.ts +62 -5
  36. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -0
  37. data/app/pb_kits/playbook/pb_textarea/textarea.rb +8 -0
  38. data/app/pb_kits/playbook/pb_textarea/textarea.test.js +57 -2
  39. data/app/pb_kits/playbook/utilities/emojiMask.ts +42 -0
  40. data/dist/chunks/{_typeahead-Ckz1ce-2.js → _typeahead-D0GNUBXn.js} +2 -2
  41. data/dist/chunks/{lib-DxDBrGZX.js → lib-DxCgrqqG.js} +1 -1
  42. data/dist/chunks/vendor.js +3 -3
  43. data/dist/playbook-rails-react-bindings.js +1 -1
  44. data/dist/playbook-rails.js +1 -1
  45. data/dist/playbook.css +1 -1
  46. data/lib/playbook/forms/builder/form_field_builder.rb +2 -0
  47. data/lib/playbook/version.rb +1 -1
  48. metadata +15 -8
  49. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.jsx +0 -56
  50. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.md +0 -10
  51. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.html.erb +0 -64
  52. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.md +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b48fc113950407e6045ecd779bef70a624758ae4d2c9b542c38130a31a35c68f
4
- data.tar.gz: fcd6bf8c37129585b0acca7a0d00e6ce54de65bb68fdba3395608883f7ae9011
3
+ metadata.gz: f960f22bca9b3635502362441b26a13583eb183fcdebab46ebbca3f5b2b64d33
4
+ data.tar.gz: 37dd6c333df8bc2149be578ef208c32fea70e3ebdec053a8ab180ec5bf56e1d7
5
5
  SHA512:
6
- metadata.gz: c0af7f993a8f9b64c9fd73d264e7aba87f692387c5c79a798728608c9c487e106270f5e7d1352f074b34bd0523fc15a127cfad5b13c2d6349e30d63fe4e65932
7
- data.tar.gz: bb66651f32b7e9b18f83fb47086580b168691b3000f23f98996a564f37f41d8d3012c5e516ab51cd8cc8843aff71a701a3d0dedf0765e5d939e5f11125bab045
6
+ metadata.gz: 694f79e8ddf8ab1bd308e0d0f85faacbd856f66dfbb52f728074ff1721d673b0d4d32513c0aa5dd4c05f652aeb73d1ae4f5c77258fedbdb26b17f80fdcbf1e3d
7
+ data.tar.gz: b8cb5e6390f7a57b562a29dfa341ec33860bdee17c24df89ead92d06d01ae82bf9283600c0d0f4aedcf9b6dafc1b0cddb2eebd4bebdf5118b4fd10a356e65004
@@ -20,23 +20,12 @@ 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
-
33
23
  type DropdownProps = {
34
24
  aria?: { [key: string]: string };
35
25
  autocomplete?: boolean;
36
26
  blankSelection?: string;
37
27
  children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
38
28
  className?: string;
39
- customQuickPickDates?: CustomQuickPickDates;
40
29
  formPillProps?: GenericObject;
41
30
  dark?: boolean;
42
31
  data?: { [key: string]: string };
@@ -74,7 +63,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
74
63
  blankSelection = '',
75
64
  children,
76
65
  className,
77
- customQuickPickDates,
78
66
  dark = false,
79
67
  data = {},
80
68
  defaultValue = {},
@@ -107,7 +95,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
107
95
  // ------------- Quick Pick ---------------------------------
108
96
  // Use QuickPick options when variant is "quickpick"
109
97
  const dropdownOptions = variant === "quickpick"
110
- ? getQuickPickOptions(rangeEndsToday, customQuickPickDates)
98
+ ? getQuickPickOptions(rangeEndsToday)
111
99
  : (options || []);
112
100
  // ----------------------------------------------------------
113
101
 
@@ -25,7 +25,6 @@ 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)
29
28
  - dropdown_quickpick_with_date_pickers_rails: Quick Pick with Date Pickers
30
29
  - dropdown_quickpick_with_date_pickers_default_rails: Quick Pick with Date Pickers (Default Value)
31
30
 
@@ -58,7 +57,6 @@ examples:
58
57
  - dropdown_quickpick: Quick Pick Variant
59
58
  - dropdown_quickpick_range_end: Quick Pick Variant (Range Ends Today)
60
59
  - dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
61
- - dropdown_quickpick_custom: Quick Pick Variant (Custom Quick Pick Dates)
62
60
  - dropdown_quickpick_with_date_pickers: Quick Pick Variant with Date Pickers
63
61
 
64
62
 
@@ -26,5 +26,4 @@ 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'
30
- export { default as DropdownQuickpickCustom } from './_dropdown_quickpick_custom.jsx'
29
+ export { default as DropdownQuickpickWithDatePickers } from './_dropdown_quickpick_with_date_pickers.jsx'
@@ -15,8 +15,6 @@ 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: {}
20
18
  prop :variant, type: Playbook::Props::Enum,
21
19
  values: %w[default subtle quickpick],
22
20
  default: "default"
@@ -96,10 +94,7 @@ module Playbook
96
94
  end
97
95
 
98
96
  def quickpick_options
99
- QuickpickHelper.get_quickpick_options(
100
- range_ends_today: range_ends_today,
101
- custom_quick_pick_dates: custom_quick_pick_dates
102
- )
97
+ QuickpickHelper.get_quickpick_options(range_ends_today: range_ends_today)
103
98
  end
104
99
  end
105
100
  end
@@ -539,125 +539,4 @@ 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())
663
542
  })
@@ -11,78 +11,8 @@ 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
-
84
14
  // Helper to get QuickPick options with date ranges
85
- const getQuickPickOptions = (rangeEndsToday = false, customQuickPickDates?: CustomQuickPickDates): QuickPickOption[] => {
15
+ const getQuickPickOptions = (rangeEndsToday = false): QuickPickOption[] => {
86
16
  const today = new Date();
87
17
  const yesterday = DateTime.getYesterdayDate(new Date());
88
18
 
@@ -106,7 +36,14 @@ const getQuickPickOptions = (rangeEndsToday = false, customQuickPickDates?: Cust
106
36
  const lastYearStartDate = DateTime.getPreviousYearStartDate(new Date());
107
37
  const lastYearEndDate = DateTime.getPreviousYearEndDate(new Date());
108
38
 
109
- const defaultOptions: QuickPickOption[] = [
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 [
110
47
  { label: 'Today', value: [today, today], id: 'quickpick-today' },
111
48
  { label: 'Yesterday', value: [yesterday, yesterday], formattedStartDate: `${formatDate(yesterday)}`, formattedEndDate: `${formatDate(yesterday)}`, id: 'quickpick-yesterday' },
112
49
  { label: 'This Week', value: [thisWeekStartDate, thisWeekEndDate], formattedStartDate: `${formatDate(thisWeekStartDate)}`, formattedEndDate: `${formatDate(thisWeekEndDate)}`, id: 'quickpick-this-week' },
@@ -118,19 +55,6 @@ const getQuickPickOptions = (rangeEndsToday = false, customQuickPickDates?: Cust
118
55
  { label: 'Last Quarter', value: [lastQuarterStartDate, lastQuarterEndDate], formattedStartDate: `${formatDate(lastQuarterStartDate)}`, formattedEndDate: `${formatDate(lastQuarterEndDate)}`, id: 'quickpick-last-quarter' },
119
56
  { label: 'Last Year', value: [lastYearStartDate, lastYearEndDate], formattedStartDate: `${formatDate(lastYearStartDate)}`, formattedEndDate: `${formatDate(lastYearEndDate)}`, id: 'quickpick-last-year' },
120
57
  ];
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;
134
58
  };
135
59
 
136
60
  export default getQuickPickOptions
@@ -4,31 +4,7 @@ module Playbook
4
4
  module PbDropdown
5
5
  module QuickpickHelper
6
6
  class << self
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)
7
+ def get_quickpick_options(range_ends_today: false)
32
8
  today = Date.today
33
9
  yesterday = today - 1.day
34
10
 
@@ -66,64 +42,7 @@ module Playbook
66
42
  ]
67
43
  end
68
44
 
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
45
+ private
127
46
 
128
47
  def format_date(date)
129
48
  date.strftime("%m/%d/%Y")
@@ -30,10 +30,6 @@ module Playbook
30
30
  closeable.present? ? " remove_toast" : ""
31
31
  end
32
32
 
33
- def auto_close_class
34
- auto_close.present? ? " auto_close_#{auto_close}" : ""
35
- end
36
-
37
33
  def position_class
38
34
  horizontal && vertical ? " positioned_toast #{vertical} #{horizontal}" : ""
39
35
  end
@@ -42,6 +38,14 @@ module Playbook
42
38
  multi_line.present? ? "multi_line" : nil
43
39
  end
44
40
 
41
+ def auto_close_attribute
42
+ auto_close.present? ? { "pb-auto-close": auto_close } : {}
43
+ end
44
+
45
+ def data
46
+ Hash(prop(:data)).merge(auto_close_attribute)
47
+ end
48
+
45
49
  def icon_value
46
50
  icon || case status
47
51
  when "success"
@@ -61,9 +65,7 @@ module Playbook
61
65
 
62
66
  def classname
63
67
  default_z_index = z_index.present? ? "" : " z_index_max"
64
- # IMPORTANT: the AutoClose class must be the last class in the string for JS to read it correctly
65
- # Changing the order will break the auto_close functionality
66
- generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index + auto_close_class
68
+ generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index
67
69
  end
68
70
  end
69
71
  end
@@ -21,17 +21,12 @@ export default class PbFixedConfirmationToast extends PbEnhancedElement {
21
21
  }
22
22
 
23
23
  autoCloseToast(element) {
24
- const classListValues = element.classList.value
25
- const hasAutoCloseClass = classListValues.includes('auto_close')
26
-
27
- if (hasAutoCloseClass) {
28
- const classList = classListValues.split(' ')
29
- const autoCloseValue = classList[classList.length - 1].split('_')[2]
30
- const autoCloseIntValue = parseInt(autoCloseValue)
24
+ const autoCloseDataAttr = element.getAttribute('data-pb-auto-close')
31
25
 
26
+ if (autoCloseDataAttr) {
32
27
  setTimeout(() => {
33
28
  this.removeToast(element)
34
- }, autoCloseIntValue)
29
+ }, parseInt(autoCloseDataAttr))
35
30
  }
36
31
  }
37
32
  }
@@ -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 {
@@ -0,0 +1,71 @@
1
+ import React from 'react'
2
+ import RichTextEditor from '../_rich_text_editor'
3
+ import { useEditor, EditorContent } from "@tiptap/react"
4
+ import StarterKit from "@tiptap/starter-kit"
5
+ import Link from '@tiptap/extension-link'
6
+ import { Caption } from "playbook-ui"
7
+
8
+
9
+ const RichTextEditorAdvancedHeight = (props) => {
10
+
11
+ const editor = useEditor({
12
+ extensions: [
13
+ StarterKit,
14
+ Link
15
+ ],
16
+ content: "Add your text here. You can format your text, add links, quotes, and bullets."
17
+ })
18
+
19
+ const editor2 = useEditor({
20
+ extensions: [
21
+ StarterKit,
22
+ Link
23
+ ],
24
+ content: "Add your text here. You can format your text, add links, quotes, and bullets."
25
+ })
26
+
27
+ const editor3 = useEditor({
28
+ extensions: [
29
+ StarterKit,
30
+ Link
31
+ ],
32
+ content: "Add your text here. You can format your text, add links, quotes, and bullets."
33
+ })
34
+
35
+ return (
36
+ <div>
37
+ <Caption>sm</Caption>
38
+ <RichTextEditor
39
+ advancedEditor={editor}
40
+ inputHeight="sm"
41
+ {...props}
42
+ >
43
+ <EditorContent editor={editor} />
44
+ </RichTextEditor>
45
+
46
+ <br />
47
+
48
+ <Caption>md</Caption>
49
+ <RichTextEditor
50
+ advancedEditor={editor2}
51
+ inputHeight="md"
52
+ {...props}
53
+ >
54
+ <EditorContent editor={editor2} />
55
+ </RichTextEditor>
56
+
57
+ <br />
58
+
59
+ <Caption>lg</Caption>
60
+ <RichTextEditor
61
+ advancedEditor={editor3}
62
+ inputHeight="lg"
63
+ {...props}
64
+ >
65
+ <EditorContent editor={editor3} />
66
+ </RichTextEditor>
67
+ </div>
68
+ )
69
+ }
70
+
71
+ export default RichTextEditorAdvancedHeight
@@ -0,0 +1 @@
1
+ Use the `inputHeight` prop to keep the text area a specific height. If the text exceeds the text area, it will automatically add a scrollbar to maintain the fixed height.
@@ -0,0 +1 @@
1
+ Use the inputMinHeight prop to render the text area with a minimum height. If the text exceeds the text area, the text area will grow to accommodate it.