playbook_ui 15.3.0.pre.alpha.PLAY2569advancedtablecolumnstylingfontcolor11977 → 15.3.0.pre.alpha.PLAY2596datestackedcurrentyear12147

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +1 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
  4. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +5 -5
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +2 -16
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers_rails.html.erb +1 -6
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +16 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +104 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +1 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +1 -1
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -0
  12. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
  13. data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
  14. data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
  15. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +90 -20
  16. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +1 -1
  17. data/app/pb_kits/playbook/pb_badge/_badge.tsx +4 -1
  18. data/app/pb_kits/playbook/pb_badge/badge.test.js +13 -0
  19. data/app/pb_kits/playbook/pb_currency/_currency.tsx +20 -7
  20. data/app/pb_kits/playbook/pb_currency/currency.rb +35 -8
  21. data/app/pb_kits/playbook/pb_currency/currency.test.js +47 -0
  22. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  23. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
  24. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +1 -0
  25. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -4
  26. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +38 -0
  27. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +14 -0
  28. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -1
  29. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +2 -1
  30. data/app/pb_kits/playbook/pb_date_stacked/_date_stacked.tsx +6 -4
  31. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +2 -3
  32. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.rb +10 -4
  33. data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +26 -9
  34. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.html.erb +12 -0
  35. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.jsx +27 -0
  36. data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.md +1 -0
  37. data/app/pb_kits/playbook/pb_date_stacked/docs/_description.md +1 -1
  38. data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +2 -0
  39. data/app/pb_kits/playbook/pb_date_stacked/docs/index.js +1 -0
  40. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +1 -0
  41. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +111 -6
  42. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +18 -0
  43. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +4 -0
  44. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +18 -0
  45. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +1 -0
  46. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +19 -0
  47. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +1 -0
  48. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +38 -0
  49. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +14 -0
  50. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
  51. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +5 -1
  52. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +148 -2
  53. data/app/pb_kits/playbook/pb_dropdown/index.js +1 -1
  54. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +60 -0
  55. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +15 -1
  56. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +9 -8
  57. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +11 -10
  58. data/app/pb_kits/playbook/pb_form/pb_form_validation.js +44 -11
  59. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +1 -1
  60. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +110 -17
  61. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +7 -0
  62. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +64 -1
  63. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +33 -1
  64. data/dist/chunks/{_line_graph-CqE0-dq5.js → _line_graph-C-AuMGN2.js} +1 -1
  65. data/dist/chunks/_typeahead--38pnHwS.js +6 -0
  66. data/dist/chunks/_weekday_stacked-onVWU89T.js +37 -0
  67. data/dist/chunks/{lib-CGxXTQ75.js → lib-BXBHAZMY.js} +1 -1
  68. data/dist/chunks/pb_form_validation-BNfSnIUF.js +1 -0
  69. data/dist/chunks/vendor.js +1 -1
  70. data/dist/playbook-doc.js +1 -1
  71. data/dist/playbook-rails-react-bindings.js +1 -1
  72. data/dist/playbook-rails.js +1 -1
  73. data/dist/playbook.css +1 -1
  74. data/lib/playbook/version.rb +1 -1
  75. metadata +24 -7
  76. data/dist/chunks/_typeahead-3ZAbZUqU.js +0 -6
  77. data/dist/chunks/_weekday_stacked-D32ib52e.js +0 -37
  78. data/dist/chunks/pb_form_validation-DebqlUKZ.js +0 -1
@@ -11,7 +11,7 @@ import Title from '../pb_title/_title'
11
11
  type CurrencyProps = {
12
12
  abbreviate?: boolean,
13
13
  align?: 'center' | 'left' | 'right',
14
- amount: string,
14
+ amount: string | number,
15
15
  aria?: {[key:string]:string},
16
16
  className?: string,
17
17
  dark?: boolean,
@@ -59,6 +59,19 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
59
59
  commaSeparator = false,
60
60
  } = props
61
61
 
62
+ // Convert numeric input to string format
63
+ const convertAmount = (input: string | number): string => {
64
+ if (typeof input === 'number') {
65
+ if (input === 0 && !nullDisplay) {
66
+ return ""
67
+ }
68
+ return input.toFixed(2)
69
+ }
70
+ return input
71
+ }
72
+
73
+ const currencyAmount = convertAmount(amount)
74
+
62
75
  const emphasizedClass = emphasized ? '' : '_deemphasized'
63
76
 
64
77
  let variantClass
@@ -68,7 +81,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
68
81
  variantClass = '_bold'
69
82
  }
70
83
 
71
- const [whole, decimal = '00'] = amount.split('.')
84
+ const [whole, decimal = '00'] = currencyAmount.split('.')
72
85
  const ariaProps = buildAriaProps(aria)
73
86
  const dataProps = buildDataProps(data)
74
87
  const htmlProps = buildHtmlProps(htmlOptions)
@@ -92,19 +105,19 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
92
105
  return isAmount ? num.slice(0, -1) : isUnit ? num.slice(-1) : ''
93
106
  }
94
107
 
95
- const getMatchingDecimalAmount = decimals === "matching" ? amount : whole
108
+ const getMatchingDecimalAmount = decimals === "matching" ? currencyAmount : whole
96
109
  const getMatchingDecimalValue = decimals === "matching" ? '' : `.${decimal}`
97
110
 
98
111
  const formatAmount = (amount: string) => {
99
112
  if (!commaSeparator) return amount;
100
-
113
+
101
114
  const [wholePart, decimalPart] = amount.split('.');
102
115
  const formattedWhole = new Intl.NumberFormat('en-US').format(parseInt(wholePart));
103
116
  return decimalPart ? `${formattedWhole}.${decimalPart}` : formattedWhole;
104
117
  }
105
118
 
106
119
  const swapNegative = size === "sm" && symbol !== ""
107
- const handleNegative = amount.startsWith("-") && swapNegative ? "-" : ""
120
+ const handleNegative = currencyAmount.startsWith("-") && swapNegative ? "-" : ""
108
121
  const getAbsoluteAmount = (amountString: string) => amountString.replace(/^-/,'')
109
122
  const getAbbrOrFormatAmount = abbreviate ? getAbbreviatedValue('amount') : formatAmount(getMatchingDecimalAmount)
110
123
  const getAmount = swapNegative ? getAbsoluteAmount(getAbbrOrFormatAmount) : getAbbrOrFormatAmount
@@ -152,7 +165,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
152
165
  >
153
166
  {handleNegative}{symbol}
154
167
  </Body>
155
-
168
+
156
169
  <Title
157
170
  className="pb_currency_value"
158
171
  dark={dark}
@@ -160,7 +173,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
160
173
  >
161
174
  {getAmount}
162
175
  </Title>
163
-
176
+
164
177
  <Body
165
178
  className="unit"
166
179
  color="light"
@@ -17,8 +17,7 @@ module Playbook
17
17
  prop :symbol, type: Playbook::Props::String,
18
18
  default: "$"
19
19
 
20
- prop :amount, type: Playbook::Props::String,
21
- required: true
20
+ prop :amount, required: true
22
21
 
23
22
  prop :unit, type: Playbook::Props::String,
24
23
  required: false
@@ -92,7 +91,7 @@ module Playbook
92
91
  end
93
92
 
94
93
  def negative_sign
95
- amount.starts_with?("-") && swap_negative ? "-" : ""
94
+ currency_amount.starts_with?("-") && swap_negative ? "-" : ""
96
95
  end
97
96
 
98
97
  def body_props
@@ -117,10 +116,32 @@ module Playbook
117
116
  end
118
117
  end
119
118
 
119
+ def currency_amount
120
+ @currency_amount ||= convert_amount(amount)
121
+ end
122
+
120
123
  private
121
124
 
125
+ # Convert numeric input to string format
126
+ def convert_amount(input)
127
+ if input.is_a?(Numeric)
128
+ if input.zero? && null_display.nil?
129
+ ""
130
+ else
131
+ format("%.2f", input)
132
+ end
133
+ # Handle string representations of zero
134
+ elsif input.to_s.strip.match?(/^-?0+(\.0+)?$/) && null_display.nil?
135
+ ""
136
+ else
137
+ input.to_s
138
+ end
139
+ end
140
+
122
141
  def whole_value
123
- value = amount.split(".").first
142
+ return "" if currency_amount.blank?
143
+
144
+ value = currency_amount.split(".").first
124
145
  if comma_separator
125
146
  number_with_delimiter(value.gsub(",", ""))
126
147
  else
@@ -129,7 +150,9 @@ module Playbook
129
150
  end
130
151
 
131
152
  def decimal_value
132
- amount.split(".")[1] || "00"
153
+ return "00" if currency_amount.blank?
154
+
155
+ currency_amount.split(".")[1] || "00"
133
156
  end
134
157
 
135
158
  def units_element
@@ -147,7 +170,9 @@ module Playbook
147
170
  end
148
171
 
149
172
  def abbreviated_value(index = 0..-2)
150
- value = amount.split(".").first.gsub(",", "").to_i
173
+ return "" if currency_amount.blank?
174
+
175
+ value = currency_amount.split(".").first.gsub(",", "").to_i
151
176
  abbreviated_num = number_to_human(value, units: { thousand: "K", million: "M", billion: "B", trillion: "T" }).gsub(/\s+/, "")
152
177
  abbreviated_num[index]
153
178
  end
@@ -174,9 +199,11 @@ module Playbook
174
199
 
175
200
  if decimals == "matching"
176
201
  if comma_separator
177
- number_with_delimiter(amount.gsub(",", ""))
202
+ return "" if currency_amount.blank?
203
+
204
+ number_with_delimiter(currency_amount.gsub(",", ""))
178
205
  else
179
- amount
206
+ currency_amount
180
207
  end
181
208
  else
182
209
  whole_value
@@ -133,3 +133,50 @@ test('handles negative amounts correctly', () => {
133
133
  expect(screen.getByTestId('test-negative-no-symbol')).toHaveTextContent('-400.50')
134
134
  expect(screen.getByTestId('test-negative-medium-size')).toHaveTextContent('$-500.55')
135
135
  })
136
+
137
+ test('handles numeric amounts correctly', () => {
138
+ render(
139
+ <>
140
+ <Currency
141
+ amount={320}
142
+ data={{ testid: 'test-numeric-default' }}
143
+ />
144
+ <Currency
145
+ abbreviate
146
+ amount={3200000}
147
+ data={{ testid: 'test-numeric-millions' }}
148
+ />
149
+ <Currency
150
+ amount={123456.78}
151
+ commaSeparator
152
+ data={{ testid: 'test-numeric-comma-decimals' }}
153
+ />
154
+ <Currency
155
+ amount={400.50}
156
+ data={{ testid: 'test-numeric-no-symbol' }}
157
+ symbol=""
158
+ />
159
+ <Currency
160
+ amount={500.55}
161
+ data={{ testid: 'test-numeric-medium-size' }}
162
+ size="md"
163
+ />
164
+ <Currency
165
+ amount={-600.70}
166
+ data={{ testid: 'test-numeric-negative' }}
167
+ />
168
+ <Currency
169
+ amount={0.00}
170
+ data={{ testid: 'test-numeric-null' }}
171
+ />
172
+ </>
173
+ )
174
+
175
+ expect(screen.getByTestId('test-numeric-default')).toHaveTextContent('$320')
176
+ expect(screen.getByTestId('test-numeric-millions')).toHaveTextContent('$3.2M')
177
+ expect(screen.getByTestId('test-numeric-comma-decimals')).toHaveTextContent('$123,456.78')
178
+ expect(screen.getByTestId('test-numeric-no-symbol')).toHaveTextContent('400.50')
179
+ expect(screen.getByTestId('test-numeric-medium-size')).toHaveTextContent('$500.55')
180
+ expect(screen.getByTestId('test-numeric-negative')).toHaveTextContent('-$600.70')
181
+ expect(screen.getByTestId('test-numeric-null')).toHaveTextContent('$.00')
182
+ })
@@ -7,7 +7,7 @@
7
7
  }) %>
8
8
 
9
9
  <%= pb_rails("currency", props: {
10
- amount: "342",
10
+ amount: 342,
11
11
  label: "Light",
12
12
  margin_bottom: "md",
13
13
  size: "sm",
@@ -14,7 +14,7 @@ const CurrencyVariants = (props) => {
14
14
  {...props}
15
15
  />
16
16
  <Currency
17
- amount="342"
17
+ amount={342}
18
18
  label="Light"
19
19
  marginBottom="md"
20
20
  size="sm"
@@ -0,0 +1 @@
1
+ **NOTE:** The value passed into the `amount` prop can be either a string or numeric value.
@@ -350,8 +350,14 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
350
350
  if (syncStartWith) {
351
351
  picker.config.onClose.push((selectedDates: string) => {
352
352
  if (selectedDates?.length) {
353
- const quickpick = (document.querySelector(`#${syncStartWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
354
- quickpick?.clear();
353
+ const element = document.querySelector(`#${syncStartWith}`) as any;
354
+ // Check if it's a Dropdown QuickPick (has _dropdownRef) or DatePicker QuickPick (has _flatpickr)
355
+ if (element?._dropdownRef?.current) {
356
+ element._dropdownRef.current.clearSelected();
357
+ } else {
358
+ const quickpick = element?._flatpickr;
359
+ quickpick?.clear();
360
+ }
355
361
  }
356
362
  });
357
363
  }
@@ -360,8 +366,14 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
360
366
  if (syncEndWith) {
361
367
  picker.config.onClose.push((selectedDates: string) => {
362
368
  if (selectedDates?.length) {
363
- const quickpick = (document.querySelector(`#${syncEndWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
364
- quickpick?.clear();
369
+ const element = document.querySelector(`#${syncEndWith}`) as any;
370
+ // Check if it's a Dropdown QuickPick (has _dropdownRef) or DatePicker QuickPick (has _flatpickr)
371
+ if (element?._dropdownRef?.current) {
372
+ element._dropdownRef.current.clearSelected();
373
+ } else {
374
+ const quickpick = element?._flatpickr;
375
+ quickpick?.clear();
376
+ }
365
377
  }
366
378
  });
367
379
  }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import Dropdown from "../../pb_dropdown/_dropdown";
3
+ import DatePicker from "../../pb_date_picker/_date_picker";
4
+
5
+ const DatePickerAndDropdownRange = (props) => {
6
+ return (
7
+ <>
8
+ <Dropdown
9
+ controlsEndId="end-date-picker1"
10
+ controlsStartId="start-date-picker1"
11
+ id="dropdown-as-quickpick"
12
+ label="Date Range"
13
+ marginBottom="sm"
14
+ placeholder="Select a Date Range"
15
+ variant="quickpick"
16
+ {...props}
17
+ />
18
+
19
+ <DatePicker
20
+ label="Start Date"
21
+ pickerId="start-date-picker1"
22
+ placeholder="Select a Start Date"
23
+ syncStartWith="dropdown-as-quickpick"
24
+ {...props}
25
+ />
26
+
27
+ <DatePicker
28
+ label="End Date"
29
+ pickerId="end-date-picker1"
30
+ placeholder="Select an End Date"
31
+ syncEndWith="dropdown-as-quickpick"
32
+ {...props}
33
+ />
34
+ </>
35
+ );
36
+ };
37
+
38
+ export default DatePickerAndDropdownRange;
@@ -0,0 +1,14 @@
1
+ You can link a Dropdown (`quickpick` variant) to standard DatePickers using the following props:
2
+
3
+ **For the Dropdown**:
4
+ `controlsStartId`: ID of the DatePicker that should receive the start date.
5
+
6
+ `controlsEndId`: ID of the DatePicker that should receive the end date.
7
+
8
+ When a quickpick option like “This Year” is selected, it automatically populates the linked start and end inputs.
9
+
10
+ **For the Start/End DatePickers**:
11
+ `syncStartWith`: ID of the quickpick this start date is synced to.
12
+ `syncEndWith`: ID of the quickpick this end date is synced to.
13
+
14
+ When a user manually edits the start or end date, it clears the selected quickpick to prevent conflicting values.
@@ -48,7 +48,8 @@ examples:
48
48
  - date_picker_quick_pick_custom: Custom Quick Pick Dates
49
49
  - date_picker_quick_pick_custom_override: Custom Quick Pick Dates (append to defaults)
50
50
  - date_picker_quick_pick_default_date: Range (Quick Pick w/ Default Date)
51
- - date_picker_range_pattern: Range with 2 Date Pickers and a Quick Pick
51
+ # - date_picker_range_pattern: Range with 2 Date Pickers and a Quick Pick
52
+ - date_picker_and_dropdown_range: Range with Dropdown and 2 Date Pickers
52
53
  - date_picker_format: Format
53
54
  - date_picker_disabled: Disabled Dates
54
55
  - date_picker_min_max: Min Max
@@ -26,4 +26,5 @@ export { default as DatePickerOnClose } from './_date_picker_on_close.jsx'
26
26
  export { default as DatePickerQuickPickCustom } from './_date_picker_quick_pick_custom'
27
27
  export { default as DatePickerQuickPickCustomOverride } from './_date_picker_quick_pick_custom_override'
28
28
  export { default as DatePickerQuickPickDefaultDate } from './_date_picker_quick_pick_default_date'
29
- export { default as DatePickerRangePattern } from './_date_picker_range_pattern'
29
+ export { default as DatePickerRangePattern } from './_date_picker_range_pattern'
30
+ export { default as DatePickerAndDropdownRange } from './_date_picker_and_dropdown_range.jsx'
@@ -19,6 +19,7 @@ type DateStackedProps = {
19
19
  size?: "sm" | "md";
20
20
  id?: string;
21
21
  reverse?: boolean;
22
+ showCurrentYear?: boolean;
22
23
  };
23
24
 
24
25
  const sizes: {sm: 4, md: 3} = {
@@ -37,6 +38,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
37
38
  data={},
38
39
  htmlOptions={},
39
40
  size = "sm",
41
+ showCurrentYear = false,
40
42
  } = props;
41
43
  const classes = classnames(
42
44
  buildCss("pb_date_stacked_kit", align, size, {
@@ -55,7 +57,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
55
57
  return (
56
58
  <>
57
59
  {bold == false ? (
58
- <div
60
+ <div
59
61
  {...dataProps}
60
62
  {...htmlProps}
61
63
  className={classes}
@@ -68,10 +70,10 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
68
70
  text={DateTime.toDay(date).toString()}
69
71
  />
70
72
  </div>
71
- {currentYear != inputYear && <Caption size="xs">{inputYear}</Caption>}
73
+ {(currentYear != inputYear || showCurrentYear) && <Caption size="xs">{inputYear}</Caption>}
72
74
  </div>
73
75
  ) : (
74
- <div
76
+ <div
75
77
  {...dataProps}
76
78
  {...htmlProps}
77
79
  className={classes}
@@ -89,7 +91,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
89
91
  size="4"
90
92
  text={DateTime.toDay(date).toString()}
91
93
  />
92
- {currentYear != inputYear && <Title size="4">{inputYear}</Title>}
94
+ {(currentYear != inputYear || showCurrentYear) && <Title size="4">{inputYear}</Title>}
93
95
  </div>
94
96
  </div>
95
97
  )}
@@ -4,16 +4,15 @@
4
4
 
5
5
  <div class="pb_date_stacked_day_month">
6
6
  <%= pb_rails("caption", props: { text: object.month }) %>
7
- <%= pb_rails("title", props: { text: object.day , size: object.title_size }) do %><% end %>
7
+ <%= pb_rails("title", props: { text: object.day , size: object.title_size }) %>
8
8
  <%= pb_rails("caption", props: { text: object.year, size:"xs" }) %>
9
9
  </div>
10
10
 
11
11
  <% else %>
12
12
  <div class="pb_date_stacked_day_month">
13
13
  <%= pb_rails("title", props: { text: object.month, size: 4 }) %>
14
- <%= pb_rails("title", props: { text: object.day, size: 4 }) do %><% end %>
14
+ <%= pb_rails("title", props: { text: object.day, size: 4 }) %>
15
15
  <%= pb_rails("title", props: { text: object.year, size:4 }) %>
16
-
17
16
  </div>
18
17
 
19
18
  <% end %>
@@ -16,6 +16,8 @@ module Playbook
16
16
  default: false
17
17
  prop :bold, type: Playbook::Props::Boolean,
18
18
  default: false
19
+ prop :show_current_year, type: Playbook::Props::Boolean,
20
+ default: false
19
21
 
20
22
  def classname
21
23
  generate_classname("pb_date_stacked_kit", align, size, reverse_class, dark_class)
@@ -38,10 +40,14 @@ module Playbook
38
40
 
39
41
  def year
40
42
  current_year = DateTime.now.year.to_i
41
- year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
42
- if current_year != year
43
- content_tag(:time, datetime: year) do
44
- year.to_s
43
+ if show_current_year
44
+ current_year.to_s
45
+ else
46
+ year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
47
+ if current_year != year
48
+ content_tag(:time, datetime: year) do
49
+ year.to_s
50
+ end
45
51
  end
46
52
  end
47
53
  end
@@ -22,7 +22,7 @@ describe("DateStacked Kit", () => {
22
22
  align="left"
23
23
  data={{ testid: testId }}
24
24
  date={new Date()}
25
- size="sm"
25
+ size="sm"
26
26
  />
27
27
  )
28
28
 
@@ -36,7 +36,7 @@ describe("DateStacked Kit", () => {
36
36
  align="left"
37
37
  data={{ testid: testId }}
38
38
  date={new Date()}
39
- size="sm"
39
+ size="sm"
40
40
  />
41
41
  )
42
42
 
@@ -51,7 +51,7 @@ describe("DateStacked Kit", () => {
51
51
  align="left"
52
52
  data={{ testid: testId }}
53
53
  date={new Date()}
54
- size="sm"
54
+ size="sm"
55
55
  />
56
56
  )
57
57
 
@@ -66,7 +66,7 @@ describe("DateStacked Kit", () => {
66
66
  align="left"
67
67
  data={{ testid: testId }}
68
68
  date={new Date()}
69
- size="md"
69
+ size="md"
70
70
  />
71
71
  )
72
72
 
@@ -80,7 +80,7 @@ describe("DateStacked Kit", () => {
80
80
  align="left"
81
81
  data={{ testid: testId }}
82
82
  date={futureDate}
83
- size="sm"
83
+ size="sm"
84
84
  />
85
85
  )
86
86
 
@@ -89,6 +89,23 @@ describe("DateStacked Kit", () => {
89
89
  expect(text.textContent).toEqual("2016")
90
90
  })
91
91
 
92
+ test("renders current year when showCurrentYear is true", () => {
93
+ render(
94
+ <DateStacked
95
+ align="left"
96
+ data={{ testid: testId }}
97
+ date={new Date()}
98
+ showCurrentYear
99
+ size="sm"
100
+ />
101
+ )
102
+
103
+ const kit = screen.getByTestId(testId)
104
+ const text = kit.querySelector(".pb_caption_kit_xs")
105
+ const currentYear = new Date().getFullYear()
106
+ expect(text.textContent).toEqual(`${currentYear}`)
107
+ })
108
+
92
109
  test("renders correct className when order reversed", () => {
93
110
  render(
94
111
  <DateStacked
@@ -96,7 +113,7 @@ describe("DateStacked Kit", () => {
96
113
  data={{ testid: testId }}
97
114
  date={futureDate}
98
115
  reverse
99
- size="sm"
116
+ size="sm"
100
117
  />
101
118
  )
102
119
  const kit = screen.getByTestId(testId)
@@ -110,7 +127,7 @@ describe("DateStacked Kit", () => {
110
127
  bold
111
128
  data={{ testid: testId }}
112
129
  date={futureDate}
113
- size="md"
130
+ size="md"
114
131
  />
115
132
  )
116
133
 
@@ -125,7 +142,7 @@ describe("DateStacked Kit", () => {
125
142
  align="center"
126
143
  data={{ testid: testId }}
127
144
  date={futureDate}
128
- size="md"
145
+ size="md"
129
146
  />
130
147
  )
131
148
 
@@ -139,7 +156,7 @@ describe("DateStacked Kit", () => {
139
156
  align="right"
140
157
  data={{ testid: testId }}
141
158
  date={futureDate}
142
- size="md"
159
+ size="md"
143
160
  />
144
161
  )
145
162
 
@@ -0,0 +1,12 @@
1
+ <%= pb_rails("date_stacked", props: {
2
+ date: DateTime.now,
3
+ show_current_year: true
4
+ }) %>
5
+
6
+ <br>
7
+
8
+ <%= pb_rails("date_stacked", props: {
9
+ date: DateTime.now,
10
+ show_current_year: true,
11
+ size: "md"
12
+ }) %>
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+ import DateStacked from '../_date_stacked'
3
+
4
+ const DateStackedCurrentYear = (props) => {
5
+ return (
6
+ <div>
7
+
8
+ <DateStacked
9
+ date={new Date()}
10
+ showCurrentYear
11
+ size="sm"
12
+ {...props}
13
+ />
14
+
15
+ <br />
16
+
17
+ <DateStacked
18
+ date={new Date()}
19
+ showCurrentYear
20
+ size="md"
21
+ {...props}
22
+ />
23
+ </div>
24
+ )
25
+ }
26
+
27
+ export default DateStackedCurrentYear
@@ -0,0 +1 @@
1
+ By default, the Date Stacked kit does NOT display the year if it is the current year. If you want to display the current year you can do so by setting `showCurrentYear`/`show_current_year` to true as shown here.
@@ -1 +1 @@
1
- Use to display the date, stacking month and day. Year will not show if it is the current year.
1
+ Use to display the date, stacking month and day.
@@ -3,6 +3,7 @@ examples:
3
3
  rails:
4
4
  - date_stacked_default: Default
5
5
  - date_stacked_not_current_year: Not Current Year
6
+ - date_stacked_current_year: Show Current Year
6
7
  - date_stacked_reverse: Day & Month Reverse
7
8
  - date_stacked_sizes: Sizes
8
9
  - date_stacked_align: Alignment
@@ -12,6 +13,7 @@ examples:
12
13
  react:
13
14
  - date_stacked_default: Default
14
15
  - date_stacked_not_current_year: Not Current Year
16
+ - date_stacked_current_year: Show Current Year
15
17
  - date_stacked_reverse: Day & Month Reverse
16
18
  - date_stacked_sizes: Sizes
17
19
  - date_stacked_bold: Bold
@@ -1,6 +1,7 @@
1
1
  export { default as DateStackedBold } from './_date_stacked_bold.jsx'
2
2
  export { default as DateStackedDefault } from './_date_stacked_default.jsx'
3
3
  export { default as DateStackedNotCurrentYear } from './_date_stacked_not_current_year.jsx'
4
+ export { default as DateStackedCurrentYear } from './_date_stacked_current_year.jsx'
4
5
  export { default as DateStackedReverse } from './_date_stacked_reverse.jsx'
5
6
  export { default as DateStackedSizes } from './_date_stacked_sizes.jsx'
6
7
  export { default as DateStackedAlign } from './_date_stacked_align.jsx'
@@ -12,6 +12,7 @@
12
12
 
13
13
  .pb_dropdown_default,
14
14
  .pb_dropdown_subtle,
15
+ .pb_dropdown_quickpick,
15
16
  .pb_dropdown_default_separators_hidden,
16
17
  .pb_dropdown_subtle_separators_hidden {
17
18
  .dropdown_wrapper {