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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +96 -6
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
  4. data/app/pb_kits/playbook/pb_background/_background.tsx +6 -6
  5. data/app/pb_kits/playbook/pb_background/background.test.js +5 -1
  6. data/app/pb_kits/playbook/pb_background/docs/_background_light.html.erb +1 -1
  7. data/app/pb_kits/playbook/pb_background/docs/_background_light.jsx +0 -1
  8. data/app/pb_kits/playbook/pb_background/docs/_background_light.md +1 -0
  9. data/app/pb_kits/playbook/pb_background/docs/example.yml +2 -2
  10. data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
  11. data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
  12. data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
  13. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +10 -8
  14. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +0 -1
  15. data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +0 -3
  16. data/app/pb_kits/playbook/pb_contact/_contact.tsx +51 -24
  17. data/app/pb_kits/playbook/pb_contact/contact.html.erb +53 -19
  18. data/app/pb_kits/playbook/pb_contact/contact.rb +11 -1
  19. data/app/pb_kits/playbook/pb_contact/contact.test.js +76 -0
  20. data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.html.erb +33 -0
  21. data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.jsx +46 -0
  22. data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_rails.md +2 -0
  23. data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_react.md +2 -0
  24. data/app/pb_kits/playbook/pb_contact/docs/example.yml +2 -0
  25. data/app/pb_kits/playbook/pb_contact/docs/index.js +1 -0
  26. data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +24 -0
  27. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +181 -3
  28. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +31 -0
  29. data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
  30. data/app/pb_kits/playbook/pb_draggable/context/index.tsx +458 -7
  31. data/app/pb_kits/playbook/pb_draggable/context/types.ts +8 -3
  32. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.jsx +180 -0
  33. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.md +22 -0
  34. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +3 -2
  35. data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
  36. data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +77 -1
  37. data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +4 -4
  38. data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
  39. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +34 -22
  40. data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.html.erb +16 -12
  41. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_default.html.erb +1 -1
  42. data/app/pb_kits/playbook/pb_home_address_street/none_emphasis.html.erb +16 -12
  43. data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.html.erb +16 -12
  44. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +10 -0
  45. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.tsx +66 -15
  46. data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.jsx +42 -0
  47. data/app/pb_kits/playbook/pb_multiple_users/docs/_multiple_users_with_tooltip.md +1 -0
  48. data/app/pb_kits/playbook/pb_multiple_users/docs/example.yml +1 -0
  49. data/app/pb_kits/playbook/pb_multiple_users/docs/index.js +1 -0
  50. data/app/pb_kits/playbook/pb_multiple_users/multiple_users.test.js +25 -0
  51. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +44 -10
  52. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +34 -4
  53. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.jsx +16 -7
  54. data/app/pb_kits/playbook/pb_radio/docs/_radio_error.md +1 -1
  55. data/app/pb_kits/playbook/pb_select/_select.tsx +8 -3
  56. data/app/pb_kits/playbook/pb_select/docs/_select_error.md +1 -1
  57. data/app/pb_kits/playbook/pb_select/docs/_select_input_options.html.erb +16 -0
  58. data/app/pb_kits/playbook/pb_select/docs/_select_input_options.jsx +30 -0
  59. data/app/pb_kits/playbook/pb_select/docs/_select_input_options.md +1 -0
  60. data/app/pb_kits/playbook/pb_select/docs/example.yml +2 -0
  61. data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
  62. data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
  63. data/app/pb_kits/playbook/pb_select/select.rb +3 -1
  64. data/app/pb_kits/playbook/pb_select/select.test.js +23 -0
  65. data/app/pb_kits/playbook/pb_table/_table.tsx +187 -33
  66. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +134 -0
  67. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +34 -0
  68. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +101 -0
  69. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +33 -0
  70. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +180 -0
  71. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +3 -0
  72. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +122 -0
  73. data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +3 -0
  74. data/app/pb_kits/playbook/pb_table/docs/example.yml +4 -0
  75. data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
  76. data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -0
  77. data/app/pb_kits/playbook/pb_table/table.html.erb +68 -12
  78. data/app/pb_kits/playbook/pb_table/table.rb +22 -3
  79. data/app/pb_kits/playbook/pb_table/table.test.js +143 -0
  80. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md +1 -1
  81. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.md +1 -1
  82. data/app/pb_kits/playbook/pb_timeline/_item.tsx +3 -0
  83. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.html.erb +60 -0
  84. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.jsx +118 -0
  85. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_show_current_year.md +1 -0
  86. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_date.md +1 -1
  87. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -0
  88. data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
  89. data/app/pb_kits/playbook/pb_timeline/item.html.erb +1 -1
  90. data/app/pb_kits/playbook/pb_timeline/item.rb +2 -0
  91. data/app/pb_kits/playbook/pb_timeline/label.html.erb +2 -1
  92. data/app/pb_kits/playbook/pb_timeline/label.rb +2 -0
  93. data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +3 -0
  94. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +51 -0
  95. data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +15 -0
  96. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -0
  97. data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +13 -2
  98. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +6 -1
  99. data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +34 -7
  100. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.html.erb +30 -0
  101. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.jsx +37 -0
  102. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_input_display.md +3 -0
  103. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
  104. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +2 -1
  105. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +6 -1
  106. data/app/pb_kits/playbook/tokens/_colors.scss +2 -1
  107. data/app/pb_kits/playbook/utilities/deprecated.ts +73 -0
  108. data/dist/chunks/_typeahead-CHwm9MTE.js +6 -0
  109. data/dist/chunks/lib-Cugvy62C.js +29 -0
  110. data/dist/chunks/vendor.js +3 -3
  111. data/dist/playbook-rails-react-bindings.js +1 -1
  112. data/dist/playbook-rails.js +1 -1
  113. data/dist/playbook.css +1 -1
  114. data/lib/playbook/forms/builder/collection_select_field.rb +9 -1
  115. data/lib/playbook/forms/builder/select_field.rb +9 -1
  116. data/lib/playbook/forms/builder/time_zone_select_field.rb +9 -1
  117. data/lib/playbook/pb_kit_helper.rb +35 -0
  118. data/lib/playbook/version.rb +2 -2
  119. metadata +31 -5
  120. data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
  121. data/dist/chunks/_typeahead-Bx4QsIEU.js +0 -6
  122. data/dist/chunks/lib-Dk4GKPut.js +0 -29
@@ -184,3 +184,146 @@ test("when headerStyle is floating", () => {
184
184
  const kit = renderKit(Table, props, { headerStyle: "floating" })
185
185
  expect(kit).toHaveClass("pb_table table-sm table-responsive-collapse table-card header-floating table-collapse-sm")
186
186
  })
187
+
188
+ test("renders withFilter variant with Card wrapper", () => {
189
+ const { container } = render(
190
+ <Table
191
+ data={{testid: "table-with-filter"}}
192
+ filterContent={<div>{"Mock Filter"}</div>}
193
+ title="Test Table"
194
+ variant="withFilter"
195
+ >
196
+ <Table.Head>
197
+ <Table.Row>
198
+ <Table.Header>{"Column 1"}</Table.Header>
199
+ </Table.Row>
200
+ </Table.Head>
201
+ <Table.Body>
202
+ <Table.Row>
203
+ <Table.Cell>{"Value 1"}</Table.Cell>
204
+ </Table.Row>
205
+ </Table.Body>
206
+ </Table>
207
+ )
208
+
209
+ const card = container.querySelector('.pb_card_kit')
210
+ expect(card).toBeInTheDocument()
211
+ const filter = container.querySelector('.pb_filter_kit')
212
+ expect(filter).toBeInTheDocument()
213
+ })
214
+
215
+ test("renders title when provided with withFilter variant", () => {
216
+ render(
217
+ <Table
218
+ filterContent={<div>{"Mock Filter"}</div>}
219
+ title="Test Title"
220
+ variant="withFilter"
221
+ >
222
+ <Table.Head>
223
+ <Table.Row>
224
+ <Table.Header>{"Column 1"}</Table.Header>
225
+ </Table.Row>
226
+ </Table.Head>
227
+ <Table.Body>
228
+ <Table.Row>
229
+ <Table.Cell>{"Value 1"}</Table.Cell>
230
+ </Table.Row>
231
+ </Table.Body>
232
+ </Table>
233
+ )
234
+
235
+ expect(screen.getByText("Test Title")).toBeInTheDocument()
236
+ })
237
+
238
+ test("renders filter component in withFilter variant", () => {
239
+ const { container } = render(
240
+ <Table
241
+ filterContent={<div data-testid="test-filter">{"Filter inputs"}</div>}
242
+ variant="withFilter"
243
+ >
244
+ <Table.Head>
245
+ <Table.Row>
246
+ <Table.Header>{"Column 1"}</Table.Header>
247
+ </Table.Row>
248
+ </Table.Head>
249
+ <Table.Body>
250
+ <Table.Row>
251
+ <Table.Cell>{"Value 1"}</Table.Cell>
252
+ </Table.Row>
253
+ </Table.Body>
254
+ </Table>
255
+ )
256
+
257
+ const filter = container.querySelector('.pb_filter_kit')
258
+ expect(filter).toBeInTheDocument()
259
+ })
260
+
261
+ test("renders SectionSeparator between filter and table in withFilter variant", () => {
262
+ const { container } = render(
263
+ <Table
264
+ filterContent={<div>{"Filter content"}</div>}
265
+ variant="withFilter"
266
+ >
267
+ <Table.Head>
268
+ <Table.Row>
269
+ <Table.Header>{"Column 1"}</Table.Header>
270
+ </Table.Row>
271
+ </Table.Head>
272
+ <Table.Body>
273
+ <Table.Row>
274
+ <Table.Cell>{"Value 1"}</Table.Cell>
275
+ </Table.Row>
276
+ </Table.Body>
277
+ </Table>
278
+ )
279
+
280
+ const separator = container.querySelector('.pb_section_separator_kit')
281
+ expect(separator).toBeInTheDocument()
282
+ })
283
+
284
+ test("does not render title when not provided with withFilter variant", () => {
285
+ const { container } = render(
286
+ <Table
287
+ filterContent={<div>{"Filter content"}</div>}
288
+ variant="withFilter"
289
+ >
290
+ <Table.Head>
291
+ <Table.Row>
292
+ <Table.Header>{"Column 1"}</Table.Header>
293
+ </Table.Row>
294
+ </Table.Head>
295
+ <Table.Body>
296
+ <Table.Row>
297
+ <Table.Cell>{"Value 1"}</Table.Cell>
298
+ </Table.Row>
299
+ </Table.Body>
300
+ </Table>
301
+ )
302
+
303
+ const title = container.querySelector('.pb_title_kit')
304
+ expect(title).not.toBeInTheDocument()
305
+ })
306
+
307
+ test("renders default variant without Card wrapper", () => {
308
+ render(
309
+ <Table
310
+ data={{testid: "default-table"}}
311
+ variant="default"
312
+ >
313
+ <Table.Head>
314
+ <Table.Row>
315
+ <Table.Header>{"Column 1"}</Table.Header>
316
+ </Table.Row>
317
+ </Table.Head>
318
+ <Table.Body>
319
+ <Table.Row>
320
+ <Table.Cell>{"Value 1"}</Table.Cell>
321
+ </Table.Row>
322
+ </Table.Body>
323
+ </Table>
324
+ )
325
+
326
+ const table = screen.getByTestId("default-table")
327
+ expect(table).toBeInTheDocument()
328
+ expect(table.closest('.pb_card_kit')).not.toBeInTheDocument()
329
+ })
@@ -1 +1 @@
1
- Text Input w/ Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
1
+ Text Input w/ Error shows that the input must be filled out (i.e. when used in a form it signals a user to fix an error).
@@ -1 +1 @@
1
- Textarea w/ Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
1
+ Textarea w/ Error shows that the input must be filled out (i.e. when used in a form it signals a user to fix an error).
@@ -18,6 +18,7 @@ type ItemProps = {
18
18
  icon?: string,
19
19
  iconColor?: 'default' | 'royal' | 'blue' | 'purple' | 'teal' | 'red' | 'yellow' | 'green',
20
20
  lineStyle?: 'solid' | 'dotted',
21
+ showCurrentYear?: boolean,
21
22
  } & GlobalProps
22
23
 
23
24
  function isElementOfType<P>(
@@ -35,6 +36,7 @@ const TimelineItem = ({
35
36
  icon = 'user',
36
37
  iconColor = 'default',
37
38
  lineStyle = 'solid',
39
+ showCurrentYear = false,
38
40
  ...props
39
41
  }: ItemProps): React.ReactElement => {
40
42
  const timelineItemCss = buildCss('pb_timeline_item_kit', lineStyle)
@@ -73,6 +75,7 @@ const TimelineItem = ({
73
75
  <DateStacked
74
76
  align="center"
75
77
  date={date}
78
+ showCurrentYear={showCurrentYear}
76
79
  size="sm"
77
80
  />
78
81
  )}
@@ -0,0 +1,60 @@
1
+ <%= pb_rails("timeline", props: {orientation: "horizontal", show_date: true}) do %>
2
+ <%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal", line_style: "solid", date: Date.today, show_current_year: true }) do %>
3
+ <%= pb_rails("title_detail", props: {
4
+ title: "Jackson Heights",
5
+ detail: "37-27 74th Street"
6
+ }) %>
7
+ <% end %>
8
+ <%= pb_rails("timeline/item", props: {icon: "check", icon_color: "teal", line_style: "dotted" }) do %>
9
+ <%= pb_rails("title_detail", props: {
10
+ title: "Greenpoint",
11
+ detail: "81 Gate St Brooklyn"
12
+ }) %>
13
+ <% end %>
14
+ <%= pb_rails("timeline/item", props: { line_style: "solid"}) do |item| %>
15
+ <% item.label do %>
16
+ <%= pb_rails("timeline/label", props: { date: Date.today, show_current_year: true }) %>
17
+ <% end %>
18
+ <% item.step do %>
19
+ <%= pb_rails("timeline/step", props: { icon: 'map-marker-alt', icon_color: 'purple' }) %>
20
+ <% end %>
21
+ <% item.detail do %>
22
+ <%= pb_rails("title_detail", props: {
23
+ title: "Society Hill",
24
+ detail: "72 E St Astoria"
25
+ }) %>
26
+ <% end %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <br /><br /><br />
31
+
32
+ <%= pb_rails("timeline", props: {orientation: "vertical", show_date: true}) do %>
33
+ <%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal", line_style: "solid", date: Date.today, show_current_year: true }) do %>
34
+ <%= pb_rails("title_detail", props: {
35
+ title: "Jackson Heights",
36
+ detail: "37-27 74th Street"
37
+ }) %>
38
+ <% end %>
39
+ <%= pb_rails("timeline/item", props: {icon: "check", icon_color: "teal", line_style: "dotted" }) do %>
40
+ <%= pb_rails("title_detail", props: {
41
+ title: "Greenpoint",
42
+ detail: "81 Gate St Brooklyn"
43
+ }) %>
44
+ <% end %>
45
+ <%= pb_rails("timeline/item", props: { line_style: "solid"}) do |item| %>
46
+ <% item.label do %>
47
+ <%= pb_rails("timeline/label", props: { date: Date.today, show_current_year: true }) %>
48
+ <% end %>
49
+ <% item.step do %>
50
+ <%= pb_rails("timeline/step", props: { icon: 'map-marker-alt', icon_color: 'purple' }) %>
51
+ <% end %>
52
+ <% item.detail do %>
53
+ <%= pb_rails("title_detail", props: {
54
+ title: "Society Hill",
55
+ detail: "72 E St Astoria"
56
+ }) %>
57
+ <% end %>
58
+ <% end %>
59
+ <% end %>
60
+
@@ -0,0 +1,118 @@
1
+ import React from 'react'
2
+
3
+ import Timeline from '../_timeline'
4
+ import TitleDetail from '../../pb_title_detail/_title_detail'
5
+
6
+ const TimelineShowCurrentYear = (props) => (
7
+ <div>
8
+ <Timeline
9
+ orientation="horizontal"
10
+ showDate
11
+ {...props}
12
+ >
13
+ <Timeline.Item
14
+ date={new Date()}
15
+ icon="user"
16
+ iconColor="royal"
17
+ showCurrentYear
18
+ {...props}
19
+ >
20
+ <TitleDetail
21
+ detail="37-27 74th Street"
22
+ title="Jackson Heights"
23
+ {...props}
24
+ />
25
+ </Timeline.Item>
26
+ <Timeline.Item
27
+ icon="check"
28
+ iconColor="teal"
29
+ lineStyle="dotted"
30
+ {...props}
31
+ >
32
+ <TitleDetail
33
+ detail="81 Gate St Brooklyn"
34
+ title="Greenpoint"
35
+ {...props}
36
+ />
37
+ </Timeline.Item>
38
+ <Timeline.Item
39
+ lineStyle="solid"
40
+ {...props}
41
+ >
42
+ <Timeline.Label
43
+ date={new Date()}
44
+ showCurrentYear
45
+ />
46
+ <Timeline.Step
47
+ icon="map-marker-alt"
48
+ iconColor="purple"
49
+ />
50
+ <Timeline.Detail>
51
+ <TitleDetail
52
+ detail="72 E St Astoria"
53
+ title="Society Hill"
54
+ {...props}
55
+ />
56
+ </Timeline.Detail>
57
+ </Timeline.Item>
58
+ </Timeline>
59
+
60
+ <br />
61
+ <br />
62
+ <br />
63
+
64
+ <Timeline
65
+ orientation="vertical"
66
+ showDate
67
+ {...props}
68
+ >
69
+ <Timeline.Item
70
+ date={new Date()}
71
+ icon="user"
72
+ iconColor="royal"
73
+ showCurrentYear
74
+ {...props}
75
+ >
76
+ <TitleDetail
77
+ detail="37-27 74th Street"
78
+ title="Jackson Heights"
79
+ {...props}
80
+ />
81
+ </Timeline.Item>
82
+ <Timeline.Item
83
+ icon="check"
84
+ iconColor="teal"
85
+ lineStyle="dotted"
86
+ {...props}
87
+ >
88
+ <TitleDetail
89
+ detail="81 Gate St Brooklyn"
90
+ title="Greenpoint"
91
+ {...props}
92
+ />
93
+ </Timeline.Item>
94
+ <Timeline.Item
95
+ lineStyle="solid"
96
+ {...props}
97
+ >
98
+ <Timeline.Label
99
+ date={new Date()}
100
+ showCurrentYear
101
+ />
102
+ <Timeline.Step
103
+ icon="map-marker-alt"
104
+ iconColor="purple"
105
+ />
106
+ <Timeline.Detail>
107
+ <TitleDetail
108
+ detail="72 E St Astoria"
109
+ title="Society Hill"
110
+ {...props}
111
+ />
112
+ </Timeline.Detail>
113
+ </Timeline.Item>
114
+ </Timeline>
115
+ </div>
116
+ )
117
+
118
+ export default TimelineShowCurrentYear
@@ -0,0 +1 @@
1
+ By default, the Timeline 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. Pass it to `Timeline.Item`/`timeline/item` when using its `date` prop, or to `Timeline.Label`/`timeline/label` if following the "With Children" pattern.
@@ -1 +1 @@
1
- Use the optional `showDate` prop to render the timeline kit with a visible date. If the date is from the current year, the year will not be displayed, however if date is NOT from the current year, the kit will display the year as well.
1
+ Use the optional `showDate` prop to render the timeline kit with a visible date. By default, if the date is from the current year, the year will not be displayed; however, if the date is NOT from the current year, the kit will display the year as well.
@@ -5,6 +5,7 @@ examples:
5
5
  - timeline_vertical: Vertical
6
6
  - timeline_with_date: With Date
7
7
  - timeline_with_children: With Children
8
+ - timeline_show_current_year: Show Current Year
8
9
  - timeline_with_gap: With Gap
9
10
 
10
11
 
@@ -13,4 +14,5 @@ examples:
13
14
  - timeline_vertical: Vertical
14
15
  - timeline_with_date: With Date
15
16
  - timeline_with_children: With Children
17
+ - timeline_show_current_year: Show Current Year
16
18
  - timeline_with_gap: With Gap
@@ -3,4 +3,5 @@ export { default as TimelineVertical } from './_timeline_vertical.jsx'
3
3
  export { default as TimelineWithDate } from './_timeline_with_date.jsx'
4
4
  export { default as TimelineWithChildren } from './_timeline_with_children.jsx'
5
5
  export { default as TimelineWithGap } from './_timeline_with_gap.jsx'
6
+ export { default as TimelineShowCurrentYear } from './_timeline_show_current_year.jsx'
6
7
 
@@ -2,7 +2,7 @@
2
2
  <% if label %>
3
3
  <%= label %>
4
4
  <% else %>
5
- <%= pb_rails("timeline/label", props: { date: date }) %>
5
+ <%= pb_rails("timeline/label", props: { date: date, show_current_year: show_current_year }) %>
6
6
  <% end %>
7
7
 
8
8
  <% if step %>
@@ -12,6 +12,8 @@ module Playbook
12
12
  prop :line_style, type: Playbook::Props::Enum,
13
13
  values: %w[solid dotted],
14
14
  default: "solid"
15
+ prop :show_current_year, type: Playbook::Props::Boolean,
16
+ default: false
15
17
 
16
18
  renders_one :label
17
19
  renders_one :step
@@ -3,7 +3,8 @@
3
3
  <%= pb_rails("date_stacked", props: {
4
4
  date: object.date,
5
5
  size: "sm",
6
- align: "center"
6
+ align: "center",
7
+ show_current_year: object.show_current_year
7
8
  }) %>
8
9
  <% else %>
9
10
  <%= content.presence %>
@@ -4,6 +4,8 @@ module Playbook
4
4
  module PbTimeline
5
5
  class Label < Playbook::KitBase
6
6
  prop :date
7
+ prop :show_current_year, type: Playbook::Props::Boolean,
8
+ default: false
7
9
 
8
10
  def classname
9
11
  generate_classname("pb_timeline_item_left_block")
@@ -9,6 +9,7 @@ type TimelineLabelProps = {
9
9
  children?: React.ReactNode,
10
10
  className?: string,
11
11
  htmlOptions?: { [key: string]: any },
12
+ showCurrentYear?: boolean,
12
13
  } & GlobalProps
13
14
 
14
15
  const TimelineLabel: React.FC<TimelineLabelProps> = ({
@@ -16,6 +17,7 @@ const TimelineLabel: React.FC<TimelineLabelProps> = ({
16
17
  children,
17
18
  className,
18
19
  htmlOptions = {},
20
+ showCurrentYear = false,
19
21
  ...props
20
22
  }) => {
21
23
  const htmlProps = buildHtmlProps(htmlOptions)
@@ -28,6 +30,7 @@ const TimelineLabel: React.FC<TimelineLabelProps> = ({
28
30
  {date && (
29
31
  <DateStacked align="center"
30
32
  date={date}
33
+ showCurrentYear={showCurrentYear}
31
34
  size="sm"
32
35
  />
33
36
  )}
@@ -170,3 +170,54 @@ test('should pass showDate prop with Children', () => {
170
170
  const kit = screen.getByTestId(testId)
171
171
  expect(kit).toHaveClass('pb_timeline_kit_horizontal_with_date')
172
172
  })
173
+
174
+ test('should pass showCurrentYear prop to items with date', () => {
175
+ const currentYear = new Date().getFullYear().toString()
176
+ render(
177
+ <Timeline
178
+ data={{ testid: testId }}
179
+ showDate
180
+ >
181
+ <Timeline.Item
182
+ date={new Date()}
183
+ icon="user"
184
+ iconColor="royal"
185
+ showCurrentYear
186
+ >
187
+ <TitleDetail
188
+ detail="37-27 74th Street"
189
+ title="Jackson Heights"
190
+ />
191
+ </Timeline.Item>
192
+ </Timeline>
193
+ )
194
+ const kit = screen.getByTestId(testId)
195
+ expect(kit).toBeInTheDocument()
196
+ const yearCaption = kit.querySelector('.pb_caption_kit_xs')
197
+ expect(yearCaption).toBeInTheDocument()
198
+ expect(yearCaption.textContent).toEqual(currentYear)
199
+ })
200
+
201
+ test('should not show current year by default', () => {
202
+ const currentYear = new Date().getFullYear().toString()
203
+ render(
204
+ <Timeline
205
+ data={{ testid: testId }}
206
+ showDate
207
+ >
208
+ <Timeline.Item
209
+ date={new Date()}
210
+ icon="user"
211
+ iconColor="royal"
212
+ >
213
+ <TitleDetail
214
+ detail="37-27 74th Street"
215
+ title="Jackson Heights"
216
+ />
217
+ </Timeline.Item>
218
+ </Timeline>
219
+ )
220
+ const kit = screen.getByTestId(testId)
221
+ expect(kit).toBeInTheDocument()
222
+ expect(kit).not.toHaveTextContent(currentYear)
223
+ })
@@ -276,3 +276,18 @@ test('multi-value badges have tabIndex and focus class when focused', () => {
276
276
  })
277
277
  })
278
278
 
279
+ test('input display none shows number of selected items', () => {
280
+ render(
281
+ <Typeahead
282
+ data={{ testid: 'input-display-none-test' }}
283
+ defaultValue={[options[0], options[1]]}
284
+ inputDisplay="none"
285
+ isMulti
286
+ options={options}
287
+ />
288
+ )
289
+
290
+ const kit = screen.getByTestId('input-display-none-test')
291
+ const inputDisplayDiv = kit.querySelector(".pb_typeahead_selection_count")
292
+ expect(inputDisplayDiv).toHaveTextContent("2 items selected")
293
+ })
@@ -43,6 +43,7 @@ type TypeaheadProps = {
43
43
  error?: string,
44
44
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
45
45
  id?: string,
46
+ inputDisplay?: "pills" | "none",
46
47
  label?: string,
47
48
  loadOptions?: string | Noop,
48
49
  getOptionLabel?: string | (() => string),
@@ -89,6 +90,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
89
90
  getOptionValue,
90
91
  htmlOptions = {},
91
92
  id,
93
+ inputDisplay = "pills",
92
94
  name,
93
95
  loadOptions = noop,
94
96
  marginBottom = "sm",
@@ -238,6 +240,7 @@ const Typeahead = forwardRef<HTMLInputElement, TypeaheadProps>(({
238
240
  getOptionValue: isString(getOptionValue) ? get(window, getOptionValue) : getOptionValue,
239
241
  defaultOptions: true,
240
242
  id: id || uniqueId(),
243
+ inputDisplay: inputDisplay,
241
244
  inline: false,
242
245
  isClearable: true,
243
246
  isSearchable: true,
@@ -7,18 +7,29 @@ type ClearContainerProps = {
7
7
  id: string,
8
8
  },
9
9
  clearValue: () => void,
10
+ innerProps?: any,
10
11
  }
11
12
 
12
- const ClearContainer = (props: ClearContainerProps): React.ReactElement => {
13
- const { selectProps, clearValue } = props
13
+ const ClearContainer = (props: ClearContainerProps | any): React.ReactElement => {
14
+ const { selectProps, clearValue, innerProps } = props
14
15
  useEffect(() => {
15
16
  document.addEventListener(`pb-typeahead-kit-${selectProps.id}:clear`, clearValue)
16
17
  }, [clearValue, selectProps.id])
17
18
 
19
+ // To stop this from bubbling up when inside a dialog or other modal
20
+ const handleMouseDown = (event: React.MouseEvent) => {
21
+ event.stopPropagation()
22
+ innerProps?.onMouseDown?.(event)
23
+ }
24
+
18
25
  return (
19
26
  <components.ClearIndicator
20
27
  className="clear_indicator"
21
28
  {...props}
29
+ innerProps={{
30
+ ...innerProps,
31
+ onMouseDown: handleMouseDown,
32
+ }}
22
33
  />
23
34
  )
24
35
  }
@@ -19,7 +19,12 @@ type Props = {
19
19
  const MultiValue = (props: Props) => {
20
20
  const { removeProps, isFocused } = props
21
21
  const { imageUrl, label } = props.data
22
- const { dark, multiKit, pillColor, truncate, wrapped } = props.selectProps
22
+ const { dark, multiKit, pillColor, truncate, wrapped, inputDisplay } = props.selectProps
23
+
24
+ // If inputDisplay is "none", don't render the pill/badge, just return null (the count handled in ValueContainer file)
25
+ if (inputDisplay === 'none') {
26
+ return null
27
+ }
23
28
 
24
29
  const formPillProps = {
25
30
  marginRight: 'xs',
@@ -1,15 +1,42 @@
1
1
  import React from 'react'
2
2
  import { components } from 'react-select'
3
+ import Body from '../../pb_body/_body'
3
4
 
4
5
  type ValueContainerProps = {
5
- children: React.ReactNode,
6
+ children: React.ReactNode | React.ReactNode[],
7
+ selectProps?: Record<string, unknown>,
8
+ hasValue?: boolean,
6
9
  }
7
10
 
8
- const ValueContainer = (props: ValueContainerProps): React.ReactElement => (
9
- <components.ValueContainer
10
- className="text_input_value_container"
11
- {...props}
12
- />
13
- )
11
+ const ValueContainer = (props: ValueContainerProps | any): React.ReactElement => {
12
+ const { children, selectProps, hasValue } = props
13
+ const inputDisplay = (selectProps as any)?.inputDisplay
14
+ const value = (selectProps as any)?.value
15
+
16
+ // When inputDisplay is "none" and there are selected values, show count text (this is for multi-select only)
17
+ if (inputDisplay === 'none' && hasValue && value) {
18
+ const selectedCount = Array.isArray(value) ? value.length : 0
19
+
20
+ return (
21
+ <components.ValueContainer
22
+ className="text_input_value_container"
23
+ {...props}
24
+ >
25
+ <Body
26
+ className="pb_typeahead_selection_count"
27
+ text={`${selectedCount} item${selectedCount !== 1 ? 's' : ''} selected`}
28
+ />
29
+ {children}
30
+ </components.ValueContainer>
31
+ )
32
+ }
33
+
34
+ return (
35
+ <components.ValueContainer
36
+ className="text_input_value_container"
37
+ {...props}
38
+ />
39
+ )
40
+ }
14
41
 
15
42
  export default ValueContainer