playbook_ui 14.6.2 → 14.7.0.pre.alpha.PBNTR637quickpickdefaultdate4492

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +3 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +8 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +21 -28
  5. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +37 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell.jsx +13 -2
  7. data/app/pb_kits/playbook/pb_card/_card.tsx +11 -4
  8. data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -2
  9. data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
  10. data/app/pb_kits/playbook/pb_currency/_currency.tsx +16 -6
  11. data/app/pb_kits/playbook/pb_currency/currency.rb +38 -11
  12. data/app/pb_kits/playbook/pb_currency/currency.test.js +35 -0
  13. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.html.erb +7 -0
  14. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.jsx +18 -0
  15. data/app/pb_kits/playbook/pb_currency/docs/_currency_comma_separator.md +3 -0
  16. data/app/pb_kits/playbook/pb_currency/docs/example.yml +3 -1
  17. data/app/pb_kits/playbook/pb_currency/docs/index.js +1 -0
  18. data/app/pb_kits/playbook/pb_date/_date.scss +3 -0
  19. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -1
  20. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.html.erb +42 -0
  21. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.jsx +44 -0
  22. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_quick_pick_default_date.md +1 -0
  23. data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -0
  24. data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -0
  25. data/app/pb_kits/playbook/pb_date_picker/plugins/quickPick.tsx +17 -1
  26. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -1
  27. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default_rails.html.erb +26 -0
  28. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default_rails.md +7 -0
  29. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.html.erb +38 -0
  30. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards_rails.md +0 -0
  31. data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +19 -0
  32. data/app/pb_kits/playbook/pb_draggable/docs/example.yml +6 -0
  33. data/app/pb_kits/playbook/pb_draggable/draggable.html.erb +3 -0
  34. data/app/pb_kits/playbook/pb_draggable/draggable.rb +18 -0
  35. data/app/pb_kits/playbook/pb_draggable/draggable_container.html.erb +3 -0
  36. data/app/pb_kits/playbook/pb_draggable/draggable_container.rb +15 -0
  37. data/app/pb_kits/playbook/pb_draggable/draggable_item.html.erb +7 -0
  38. data/app/pb_kits/playbook/pb_draggable/draggable_item.rb +18 -0
  39. data/app/pb_kits/playbook/pb_draggable/index.js +125 -0
  40. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +8 -7
  41. data/app/pb_kits/playbook/pb_flex/_flex.tsx +3 -1
  42. data/app/pb_kits/playbook/pb_flex/_flex_item.tsx +8 -2
  43. data/app/pb_kits/playbook/pb_flex/flex_item.html.erb +3 -6
  44. data/app/pb_kits/playbook/pb_flex/flex_item.rb +7 -2
  45. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +6 -2
  46. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +30 -26
  47. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +24 -1
  48. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +25 -2
  49. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +3 -0
  50. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -0
  51. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +46 -8
  52. data/app/pb_kits/playbook/pb_link/_link.scss +66 -0
  53. data/app/pb_kits/playbook/pb_link/_link.tsx +107 -0
  54. data/app/pb_kits/playbook/pb_link/docs/_link_color.html.erb +30 -0
  55. data/app/pb_kits/playbook/pb_link/docs/_link_color.jsx +40 -0
  56. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.html.erb +5 -0
  57. data/app/pb_kits/playbook/pb_link/docs/_link_disabled.jsx +15 -0
  58. data/app/pb_kits/playbook/pb_link/docs/_link_icon.html.erb +15 -0
  59. data/app/pb_kits/playbook/pb_link/docs/_link_icon.jsx +25 -0
  60. data/app/pb_kits/playbook/pb_link/docs/_link_tag.html.erb +35 -0
  61. data/app/pb_kits/playbook/pb_link/docs/_link_tag.jsx +45 -0
  62. data/app/pb_kits/playbook/pb_link/docs/_link_underline.html.erb +5 -0
  63. data/app/pb_kits/playbook/pb_link/docs/_link_underline.jsx +15 -0
  64. data/app/pb_kits/playbook/pb_link/docs/example.yml +16 -0
  65. data/app/pb_kits/playbook/pb_link/docs/index.js +5 -0
  66. data/app/pb_kits/playbook/pb_link/link.html.erb +21 -0
  67. data/app/pb_kits/playbook/pb_link/link.rb +44 -0
  68. data/app/pb_kits/playbook/pb_link/link.test.jsx +92 -0
  69. data/app/pb_kits/playbook/pb_popover/_popover.tsx +1 -1
  70. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +67 -1
  71. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx +1 -0
  72. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
  73. data/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb +5 -1
  74. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss +37 -0
  75. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.tsx +67 -0
  76. data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading_mixins.scss +40 -0
  77. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.jsx +51 -0
  78. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.md +1 -0
  79. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.jsx +26 -0
  80. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.md +1 -0
  81. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb +1 -0
  82. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.jsx +11 -0
  83. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +59 -0
  84. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.md +3 -0
  85. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.jsx +20 -0
  86. data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +3 -0
  87. data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +13 -0
  88. data/app/pb_kits/playbook/pb_skeleton_loading/docs/index.js +5 -0
  89. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb +12 -0
  90. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb +8 -0
  91. data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.test.jsx +81 -0
  92. data/app/pb_kits/playbook/pb_timeline/_item.tsx +59 -23
  93. data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +8 -0
  94. data/app/pb_kits/playbook/pb_timeline/detail.html.erb +3 -0
  95. data/app/pb_kits/playbook/pb_timeline/detail.rb +11 -0
  96. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +43 -0
  97. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +68 -0
  98. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.md +2 -0
  99. data/app/pb_kits/playbook/pb_timeline/docs/example.yml +2 -1
  100. data/app/pb_kits/playbook/pb_timeline/docs/index.js +1 -0
  101. data/app/pb_kits/playbook/pb_timeline/item.html.erb +17 -21
  102. data/app/pb_kits/playbook/pb_timeline/item.rb +4 -0
  103. data/app/pb_kits/playbook/pb_timeline/label.html.erb +12 -0
  104. data/app/pb_kits/playbook/pb_timeline/label.rb +13 -0
  105. data/app/pb_kits/playbook/pb_timeline/step.html.erb +14 -0
  106. data/app/pb_kits/playbook/pb_timeline/step.rb +16 -0
  107. data/app/pb_kits/playbook/pb_timeline/subcomponents/Detail.tsx +29 -0
  108. data/app/pb_kits/playbook/pb_timeline/subcomponents/Label.tsx +38 -0
  109. data/app/pb_kits/playbook/pb_timeline/subcomponents/Step.tsx +42 -0
  110. data/app/pb_kits/playbook/pb_timeline/subcomponents/index.tsx +3 -0
  111. data/app/pb_kits/playbook/pb_timeline/timeline.test.js +84 -0
  112. data/app/pb_kits/playbook/tokens/_typography.scss +35 -0
  113. data/app/pb_kits/playbook/utilities/_hover.scss +46 -43
  114. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +4 -0
  115. data/app/pb_kits/playbook/utilities/globalProps.ts +44 -2
  116. data/dist/chunks/_typeahead-DZmYDBaL.js +22 -0
  117. data/dist/chunks/_weekday_stacked-CgPamJiY.js +45 -0
  118. data/dist/chunks/lazysizes-B7xYodB-.js +1 -0
  119. data/dist/chunks/{lib-D-mTv-kp.js → lib-BC6ESsxG.js} +1 -1
  120. data/dist/chunks/{pb_form_validation-BkWGwJsl.js → pb_form_validation-B_Z9rEbg.js} +1 -1
  121. data/dist/chunks/vendor.js +1 -1
  122. data/dist/menu.yml +8 -2
  123. data/dist/playbook-doc.js +1 -1
  124. data/dist/playbook-rails-react-bindings.js +1 -1
  125. data/dist/playbook-rails.js +1 -1
  126. data/dist/playbook.css +1 -1
  127. data/lib/playbook/hover.rb +4 -1
  128. data/lib/playbook/kit_base.rb +43 -5
  129. data/lib/playbook/version.rb +2 -2
  130. metadata +78 -11
  131. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md +0 -1
  132. data/dist/chunks/_typeahead-BV_n6U5W.js +0 -22
  133. data/dist/chunks/_weekday_stacked-Cy__g00H.js +0 -45
  134. data/dist/chunks/lazysizes-DHz07jlL.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38967efe7f613ebe395182885e76a479a253d06b235e8bd97deb65a729280db2
4
- data.tar.gz: ae918779c2270c3d255938c190d2458499b53cc96420e9697d517fa92fd87cac
3
+ metadata.gz: cabb1b07b6bb3785907ca83644f3d7f43e29d11abfe1fca5935f7a0a35acf129
4
+ data.tar.gz: f36d58a2b45618e78ed4c6946604afa443127de9d4ce9f7f68c6deddc1062329
5
5
  SHA512:
6
- metadata.gz: f499509bb88d4ee1c130a23b40c9254b655bda121da66a084c48c7601b63b4c63113e1e35da272d92c20650a7e2ab27a65825a629c3c3082714d0a0662fffb3e
7
- data.tar.gz: fa958023dcce99662705e2c3e108778cfd35ad051a03217e9d06725af4e267c8f9b4bb9884d81304df234d0316ca6f088384a9a171f2f7397972e11b3bbc83e8
6
+ metadata.gz: d20a7497d705050c8820b4ce8a028a9ca347353da2e15f66338a006b2513f97fa51b3f534c8ad48f3ddd921260f3f494025822f00416f96f627bcafab7a8f116
7
+ data.tar.gz: cce97684299c02d9d4b2745f3755da992ce4f34bd3f64aa074a5cc1ad97dcc637c078d35b799c741cc7e008ea4280dcda833660e6e261790a79a9017aa252dd6
@@ -1,4 +1,3 @@
1
-
2
1
  @import 'pb_advanced_table/advanced_table';
3
2
  @import 'pb_avatar/avatar';
4
3
  @import 'pb_avatar_action_button/avatar_action_button';
@@ -30,6 +29,7 @@
30
29
  @import 'pb_dialog/dialog';
31
30
  @import 'pb_distribution_bar/distribution_bar';
32
31
  @import 'pb_draggable/draggable';
32
+ @import 'pb_drawer/drawer';
33
33
  @import 'pb_dropdown/dropdown';
34
34
  @import 'pb_file_upload/file_upload';
35
35
  @import 'pb_filter/filter';
@@ -54,6 +54,7 @@
54
54
  @import 'pb_legend/legend';
55
55
  @import 'pb_lightbox/lightbox';
56
56
  @import 'pb_line_graph/line_graph';
57
+ @import 'pb_link/link';
57
58
  @import 'pb_list/list';
58
59
  @import 'pb_loading_inline/loading_inline';
59
60
  @import 'pb_map/map';
@@ -83,6 +84,7 @@
83
84
  @import 'pb_selectable_card_icon/selectable_card_icon';
84
85
  @import 'pb_selectable_icon/selectable_icon';
85
86
  @import 'pb_selectable_list/selectable_list';
87
+ @import 'pb_skeleton_loading/skeleton_loading';
86
88
  @import 'pb_source/source';
87
89
  @import 'pb_star_rating/star_rating';
88
90
  @import 'pb_stat_change/stat_change';
@@ -106,7 +108,6 @@
106
108
  @import 'pb_user_badge/user_badge';
107
109
  @import 'pb_walkthrough/walkthrough';
108
110
  @import 'pb_weekday_stacked/weekday_stacked';
109
- @import 'pb_drawer/drawer';
110
111
  @import 'utilities/mixins';
111
112
  @import 'utilities/spacing';
112
113
  @import 'utilities/cursor';
@@ -16,6 +16,7 @@ interface CustomCellProps {
16
16
  onRowToggleClick?: (arg: Row<GenericObject>) => void
17
17
  row: Row<GenericObject>
18
18
  value?: string
19
+ customRenderer?: (row: Row<GenericObject>, value: string | undefined) => React.ReactNode
19
20
  }
20
21
 
21
22
  export const CustomCell = ({
@@ -23,6 +24,7 @@ export const CustomCell = ({
23
24
  onRowToggleClick,
24
25
  row,
25
26
  value,
27
+ customRenderer,
26
28
  }: CustomCellProps & GlobalProps) => {
27
29
  const { setExpanded, expanded, expandedControl, inlineRowLoading } = useContext(AdvancedTableContext);
28
30
 
@@ -61,7 +63,12 @@ export const CustomCell = ({
61
63
  </button>
62
64
  ) : null}
63
65
  <FlexItem paddingLeft={renderButton? "none" : "xs"}>
64
- {row.depth === 0 ? getValue() : value}
66
+ {row.depth === 0 ? (
67
+ customRenderer ? customRenderer(row, getValue()) : getValue()
68
+ ) :(
69
+ customRenderer ? customRenderer(row, value) : value
70
+ )
71
+ }
65
72
  </FlexItem>
66
73
  </Flex>
67
74
  </div>
@@ -90,8 +90,8 @@ const AdvancedTable = (props: AdvancedTableProps) => {
90
90
 
91
91
  const columnHelper = createColumnHelper()
92
92
 
93
- //Create cells for first columns
94
- const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element) => {
93
+ //Create cells for columns, with customization for first column
94
+ const createCellFunction = (cellAccessors: string[], customRenderer?: (row: Row<GenericObject>, value: any) => JSX.Element, index?: number) => {
95
95
  const columnCells = ({
96
96
  row,
97
97
  getValue,
@@ -101,19 +101,16 @@ const AdvancedTable = (props: AdvancedTableProps) => {
101
101
  }) => {
102
102
  const rowData = row.original
103
103
 
104
- // Use customRenderer if provided, otherwise default rendering
105
- if (customRenderer) {
106
- return customRenderer(row, getValue())
107
- }
108
-
104
+ if (index === 0) {
109
105
  switch (row.depth) {
110
106
  case 0: {
111
107
  return (
112
- <CustomCell
113
- getValue={getValue}
114
- onRowToggleClick={onRowToggleClick}
115
- row={row}
116
- />
108
+ <CustomCell
109
+ customRenderer={customRenderer}
110
+ getValue={getValue}
111
+ onRowToggleClick={onRowToggleClick}
112
+ row={row}
113
+ />
117
114
  )
118
115
  }
119
116
  default: {
@@ -122,6 +119,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
122
119
  const accessorValue = rowData[depthAccessor]
123
120
  return accessorValue ? (
124
121
  <CustomCell
122
+ customRenderer={customRenderer}
125
123
  onRowToggleClick={onRowToggleClick}
126
124
  row={row}
127
125
  value={accessorValue}
@@ -132,11 +130,13 @@ const AdvancedTable = (props: AdvancedTableProps) => {
132
130
  }
133
131
  }
134
132
  }
135
-
133
+ return customRenderer
134
+ ? customRenderer(row, getValue())
135
+ : getValue()
136
+ }
136
137
  return columnCells
137
138
  }
138
-
139
- //Create column array in format needed by Tanstack
139
+ //Create column array in format needed by Tanstack
140
140
  const columns =
141
141
  columnDefinitions &&
142
142
  columnDefinitions.map((column, index) => {
@@ -147,19 +147,12 @@ const AdvancedTable = (props: AdvancedTableProps) => {
147
147
  }),
148
148
  }
149
149
 
150
- // Use the custom renderer if provided, EXCEPT for the first column
151
- if (index !== 0) {
152
- if (column.cellAccessors || column.customRenderer) {
153
- columnStructure.cell = createCellFunction(
154
- column.cellAccessors,
155
- column.customRenderer
156
- )
157
- }
158
- } else {
159
- // For the first column, apply createCellFunction without customRenderer
160
- if (column.cellAccessors) {
161
- columnStructure.cell = createCellFunction(column.cellAccessors)
162
- }
150
+ if (column.cellAccessors || column.customRenderer) {
151
+ columnStructure.cell = createCellFunction(
152
+ column.cellAccessors,
153
+ column.customRenderer,
154
+ index
155
+ )
163
156
  }
164
157
 
165
158
  return columnStructure
@@ -1,7 +1,7 @@
1
1
  import React, {useState} from "react"
2
2
  import { render, screen, waitFor } from "../utilities/test-utils"
3
3
 
4
- import { AdvancedTable } from "playbook-ui"
4
+ import { AdvancedTable, Pill } from "playbook-ui"
5
5
 
6
6
  const MOCK_DATA = [
7
7
  {
@@ -88,6 +88,28 @@ const columnDefinitions = [
88
88
  },
89
89
  ]
90
90
 
91
+ const columnDefinitionsCustomRenderer = [
92
+ {
93
+ accessor: "year",
94
+ label: "Year",
95
+ cellAccessors: ["quarter", "month", "day"],
96
+ },
97
+ {
98
+ accessor: "newEnrollments",
99
+ label: "New Enrollments",
100
+ customRenderer: (row, value) => (
101
+ <Pill text={value}
102
+ variant="success"
103
+ />
104
+ ),
105
+ },
106
+ {
107
+ accessor: "scheduledMeetings",
108
+ label: "Scheduled Meetings",
109
+ },
110
+ ]
111
+
112
+
91
113
  const subRowHeaders = ["Quarter"]
92
114
 
93
115
  const testId = "advanced_table"
@@ -463,3 +485,17 @@ test("responsive none prop functions as expected", () => {
463
485
  const kit = screen.getByTestId(testId)
464
486
  expect(kit).toHaveClass("pb_advanced_table table-responsive-none")
465
487
  })
488
+
489
+ test("customRenderer prop functions as expected", () => {
490
+ render(
491
+ <AdvancedTable
492
+ columnDefinitions={columnDefinitionsCustomRenderer}
493
+ data={{ testid: testId }}
494
+ tableData={MOCK_DATA}
495
+ />
496
+ )
497
+
498
+ const kit = screen.getByTestId(testId)
499
+ const pill = kit.querySelector(".pb_pill_kit_success_lowercase")
500
+ expect(pill).toBeInTheDocument()
501
+ })
@@ -1,5 +1,5 @@
1
1
  import React from "react"
2
- import { AdvancedTable, Pill, Body, Flex, Detail, Caption } from "playbook-ui"
2
+ import { AdvancedTable, Pill, Body, Flex, Detail, Caption, Badge, Title } from "playbook-ui"
3
3
  import MOCK_DATA from "./advanced_table_mock_data.json"
4
4
 
5
5
  const AdvancedTableCustomCell = (props) => {
@@ -8,7 +8,18 @@ const AdvancedTableCustomCell = (props) => {
8
8
  accessor: "year",
9
9
  label: "Year",
10
10
  cellAccessors: ["quarter", "month", "day"],
11
-
11
+ customRenderer: (row, value) => (
12
+ <Flex>
13
+ <Title size={4}
14
+ text={value}
15
+ />
16
+ <Badge dark
17
+ marginLeft="xxs"
18
+ text={row.original.newEnrollments > 20 ? "High" : "Low"}
19
+ variant="neutral"
20
+ />
21
+ </Flex>
22
+ ),
12
23
  },
13
24
  {
14
25
  accessor: "newEnrollments",
@@ -5,7 +5,7 @@ import { get } from 'lodash'
5
5
  import classnames from 'classnames'
6
6
 
7
7
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
8
- import { GlobalProps, globalProps } from '../utilities/globalProps'
8
+ import { GlobalProps, globalProps, globalInlineProps } from '../utilities/globalProps'
9
9
  import type { ProductColors, CategoryColors, BackgroundColors } from '../types/colors'
10
10
 
11
11
  import Icon from '../pb_icon/_icon'
@@ -49,6 +49,7 @@ type CardBodyProps = {
49
49
  padding?: string,
50
50
  } & GlobalProps
51
51
 
52
+
52
53
  // Header component
53
54
  const Header = (props: CardHeaderProps) => {
54
55
  const { children, className, headerColor = 'category_1', headerColorStriped = false } = props
@@ -107,6 +108,10 @@ const Card = (props: CardPropTypes): React.ReactElement => {
107
108
 
108
109
  // coerce to array
109
110
  const cardChildren = React.Children.toArray(children)
111
+ const dynamicInlineProps = globalInlineProps(props);
112
+ const { style: htmlStyle = {}, ...restHtmlProps } = htmlProps as { style?: React.CSSProperties };
113
+ const mergedStyles: React.CSSProperties = { ...htmlStyle, ...dynamicInlineProps };
114
+
110
115
 
111
116
  const subComponentTags = (tagName: string) => {
112
117
  return cardChildren.filter((c: string) => (
@@ -122,7 +127,7 @@ const Card = (props: CardPropTypes): React.ReactElement => {
122
127
 
123
128
  const tagOptions = ['div', 'section', 'footer', 'header', 'article', 'aside', 'main', 'nav']
124
129
  const Tag = tagOptions.includes(tag) ? tag : 'div'
125
-
130
+
126
131
  return (
127
132
  <>
128
133
  {
@@ -133,8 +138,9 @@ const Card = (props: CardPropTypes): React.ReactElement => {
133
138
  <Tag
134
139
  {...ariaProps}
135
140
  {...dataProps}
136
- {...htmlProps}
137
141
  className={classnames(cardCss, globalProps(props), className)}
142
+ {...restHtmlProps}
143
+ style={mergedStyles}
138
144
  >
139
145
  {subComponentTags('Header')}
140
146
  {
@@ -161,8 +167,9 @@ const Card = (props: CardPropTypes): React.ReactElement => {
161
167
  <Tag
162
168
  {...ariaProps}
163
169
  {...dataProps}
164
- {...htmlProps}
165
170
  className={classnames(cardCss, globalProps(props), className)}
171
+ {...restHtmlProps}
172
+ style={mergedStyles}
166
173
  >
167
174
  {subComponentTags('Header')}
168
175
  {nonHeaderChildren}
@@ -28,8 +28,7 @@ $pb_card_header_colors: map-merge(map-merge($product_colors, $additional_colors)
28
28
 
29
29
  @mixin pb_card_selected($border_color: $primary) {
30
30
  border-color: $border_color;
31
- border-width: $pb_card_border_width;
32
- outline: 1px solid $border_color;
31
+ border-width: $pb_card_border_width * 2;
33
32
  }
34
33
 
35
34
  @mixin pb_card_selected_dark {
@@ -1 +1 @@
1
- Card can leverage the max-width property. Learn more in our <a href="https://playbook.powerapp.cloud/visual_guidelines" target="_blank">visual guidelines.</a>
1
+ Card can leverage the max-width property. Learn more in our <a href="https://playbook.powerapp.cloud/visual_guidelines" target="_blank">visual guidelines.</a>
@@ -26,6 +26,7 @@ type CurrencyProps = {
26
26
  variant?: 'default' | 'light' | 'bold',
27
27
  unit?: string,
28
28
  unstyled?: boolean,
29
+ commaSeparator?: boolean,
29
30
  }
30
31
 
31
32
  const sizes: {lg: 1, md: 3, sm: 4} = {
@@ -53,6 +54,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
53
54
  variant = 'default',
54
55
  dark = false,
55
56
  unstyled = false,
57
+ commaSeparator = false,
56
58
  } = props
57
59
 
58
60
  const emphasizedClass = emphasized ? '' : '_deemphasized'
@@ -74,7 +76,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
74
76
  className
75
77
  )
76
78
 
77
- const getFormattedNumber = (input: number | any ) => new Intl.NumberFormat('en-US', {
79
+ const getFormattedNumber = (input: number | any) => new Intl.NumberFormat('en-US', {
78
80
  notation: 'compact',
79
81
  maximumFractionDigits: 1,
80
82
  }).format(input)
@@ -88,12 +90,20 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
88
90
  return isAmount ? num.slice(0, -1) : isUnit ? num.slice(-1) : ''
89
91
  }
90
92
 
91
- const getMatchingDecimalAmount = decimals === "matching" ? amount : whole,
92
- getMatchingDecimalValue = decimals === "matching" ? '' : `.${decimal}`
93
+ const getMatchingDecimalAmount = decimals === "matching" ? amount : whole
94
+ const getMatchingDecimalValue = decimals === "matching" ? '' : `.${decimal}`
93
95
 
94
- const getAmount = abbreviate ? getAbbreviatedValue('amount') : getMatchingDecimalAmount,
95
- getAbbreviation = abbreviate ? getAbbreviatedValue('unit') : null,
96
- getDecimalValue = abbreviate ? '' : getMatchingDecimalValue
96
+ const formatAmount = (amount: string) => {
97
+ if (!commaSeparator) return amount;
98
+
99
+ const [wholePart, decimalPart] = amount.split('.');
100
+ const formattedWhole = new Intl.NumberFormat('en-US').format(parseInt(wholePart));
101
+ return decimalPart ? `${formattedWhole}.${decimalPart}` : formattedWhole;
102
+ }
103
+
104
+ const getAmount = abbreviate ? getAbbreviatedValue('amount') : formatAmount(getMatchingDecimalAmount)
105
+ const getAbbreviation = abbreviate ? getAbbreviatedValue('unit') : null
106
+ const getDecimalValue = abbreviate ? '' : getMatchingDecimalValue
97
107
 
98
108
  return (
99
109
  <div
@@ -43,6 +43,9 @@ module Playbook
43
43
  prop :unstyled, type: Playbook::Props::Boolean,
44
44
  default: false
45
45
 
46
+ prop :comma_separator, type: Playbook::Props::Boolean,
47
+ default: false
48
+
46
49
  def classname
47
50
  generate_classname("pb_currency_kit", align, size, dark_class)
48
51
  end
@@ -65,7 +68,7 @@ module Playbook
65
68
  def title_props
66
69
  {
67
70
  size: size_value,
68
- text: abbreviate ? abbreviated_value : whole_value,
71
+ text: abbreviate ? abbreviated_value : formatted_amount,
69
72
  classname: "pb_currency_value",
70
73
  dark: dark,
71
74
  }
@@ -96,28 +99,38 @@ module Playbook
96
99
  private
97
100
 
98
101
  def whole_value
99
- return amount if decimals == "matching"
100
-
101
- amount.split(".").first.to_s
102
+ value = amount.split(".").first
103
+ if comma_separator
104
+ number_with_delimiter(value.gsub(",", ""))
105
+ else
106
+ value
107
+ end
102
108
  end
103
109
 
104
- def abbreviated_value(index = 0..-2)
105
- value = amount.split(".").first.split(",").join("")
106
- abbreviated_num = number_to_human(value, units: { thousand: "K", million: "M", billion: "B", trillion: "T" }).gsub(/\s+/, "").to_s
107
- abbreviated_num[index]
110
+ def decimal_value
111
+ amount.split(".")[1] || "00"
108
112
  end
109
113
 
110
114
  def units_element
111
115
  return "" if decimals == "matching" && !abbreviate && !unit
112
116
 
113
- _, decimal_part = amount.split(".")
114
- if unit.nil? && abbreviate == false
115
- decimal_part.nil? ? ".00" : ".#{decimal_part}"
117
+ if unit.nil? && !abbreviate
118
+ if decimals == "matching"
119
+ ""
120
+ else
121
+ ".#{decimal_value}"
122
+ end
116
123
  else
117
124
  abbreviate ? "#{abbreviated_value(-1)}#{unit}" : unit
118
125
  end
119
126
  end
120
127
 
128
+ def abbreviated_value(index = 0..-2)
129
+ value = amount.split(".").first.gsub(",", "").to_i
130
+ abbreviated_num = number_to_human(value, units: { thousand: "K", million: "M", billion: "B", trillion: "T" }).gsub(/\s+/, "")
131
+ abbreviated_num[index]
132
+ end
133
+
121
134
  def size_value
122
135
  case size
123
136
  when "lg"
@@ -132,6 +145,20 @@ module Playbook
132
145
  def dark_class
133
146
  dark ? "dark" : nil
134
147
  end
148
+
149
+ def formatted_amount
150
+ return abbreviated_value if abbreviate
151
+
152
+ if decimals == "matching"
153
+ if comma_separator
154
+ number_with_delimiter(amount.gsub(",", ""))
155
+ else
156
+ amount
157
+ end
158
+ else
159
+ whole_value
160
+ end
161
+ end
135
162
  end
136
163
  end
137
164
  end
@@ -61,3 +61,38 @@ test('decimals default prop returns decimals as body text', () => {
61
61
  expect(currencyKit.querySelector('.pb_currency_value')).toHaveTextContent('320')
62
62
  expect(currencyKit.querySelector('.unit')).toHaveTextContent('.20')
63
63
  })
64
+
65
+
66
+ test('commaSeparator prop returns comma separated amount', () => {
67
+ render(
68
+ <Currency
69
+ amount="1234567890"
70
+ commaSeparator
71
+ data={{ testid: 'comma-test' }}
72
+ />
73
+ )
74
+ expect(screen.getByTestId('comma-test')).toHaveTextContent('1,234,567,890')
75
+ })
76
+
77
+ test('commaSeparator prop returns comma separated amount with decimals', () => {
78
+ render(
79
+ <Currency
80
+ amount="1234567890.12"
81
+ commaSeparator
82
+ data={{ testid: 'comma-test-decimals' }}
83
+ />
84
+ )
85
+ expect(screen.getByTestId('comma-test-decimals')).toHaveTextContent('1,234,567,890.12')
86
+ })
87
+
88
+ test('commaSeparator prop returns comma separated amount with decimals="matching"', () => {
89
+ render(
90
+ <Currency
91
+ amount="1234567890.12"
92
+ commaSeparator
93
+ data={{ testid: 'comma-test-decimals-matching' }}
94
+ decimals="matching"
95
+ />
96
+ )
97
+ expect(screen.getByTestId('comma-test-decimals-matching')).toHaveTextContent('1,234,567,890.12')
98
+ })
@@ -0,0 +1,7 @@
1
+ <%= pb_rails("currency", props: {
2
+ amount: '1234567.89',
3
+ comma_separator: true,
4
+ size: 'lg',
5
+ emphasized: false,
6
+ decimals: 'matching',
7
+ }) %>
@@ -0,0 +1,18 @@
1
+ import React from "react"
2
+
3
+ import Currency from "../_currency"
4
+
5
+ const CurrencyCommaSeparator = (props) => {
6
+ return (
7
+ <Currency
8
+ amount='1234567.89'
9
+ commaSeparator
10
+ decimals="matching"
11
+ emphasized={false}
12
+ size="lg"
13
+ {...props}
14
+ />
15
+ )
16
+ }
17
+
18
+ export default CurrencyCommaSeparator
@@ -0,0 +1,3 @@
1
+ The optional `commaSeparator` can be used to auto-format the use of commas as a thousands separator.
2
+
3
+ **NOTE:** If the value passed into the `amount` prop is already comma-dilineated, it will not add additional commas.
@@ -8,7 +8,8 @@ examples:
8
8
  - currency_abbreviated: Abbreviate Larger Amounts
9
9
  - currency_matching_decimals: Matching Decimals
10
10
  - currency_unstyled: Unstyled
11
-
11
+ - currency_comma_separator: Comma Separator
12
+
12
13
  react:
13
14
  - currency_variants: Variants
14
15
  - currency_size: Size
@@ -17,6 +18,7 @@ examples:
17
18
  - currency_abbreviated: Abbreviate Larger Amounts
18
19
  - currency_matching_decimals: Matching Decimals
19
20
  - currency_unstyled: Unstyled
21
+ - currency_comma_separator: Comma Separator
20
22
 
21
23
  swift:
22
24
  - currency_size_swift: Size
@@ -5,3 +5,4 @@ export { default as CurrencyNoSymbol } from './_currency_no_symbol.jsx'
5
5
  export { default as CurrencyAbbreviated } from './_currency_abbreviated.jsx'
6
6
  export { default as CurrencyMatchingDecimals } from './_currency_matching_decimals.jsx'
7
7
  export { default as CurrencyUnstyled } from './_currency_unstyled.jsx'
8
+ export { default as CurrencyCommaSeparator } from './_currency_comma_separator.jsx'
@@ -28,5 +28,8 @@
28
28
  [class^=pb_title_kit] {
29
29
  color: $text_dk_default !important;
30
30
  }
31
+ [class^=pb_body_kit], [class^=pb_caption_kit] {
32
+ color: $text_dk_light !important;
33
+ }
31
34
  }
32
35
  }
@@ -143,7 +143,7 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
143
143
 
144
144
  } else if (selectionType === "quickpick") {
145
145
  //------- QUICKPICK VARIANT PLUGIN -------------//
146
- pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates))
146
+ pluginList.push(quickPickPlugin(thisRangesEndToday, customQuickPickDates, defaultDate as string))
147
147
  }
148
148
 
149
149
  // time selection
@@ -0,0 +1,42 @@
1
+ <%= pb_rails("date_picker", props: {
2
+ allow_input: true,
3
+ default_date: "This month",
4
+ end_date_id: "quick-pick-end-date",
5
+ end_date_name: "quick-pick-end-date",
6
+ mode: "range",
7
+ picker_id: "quick-pick-default-date",
8
+ placeholder: "mm/dd/yyyy to mm/dd/yyyy",
9
+ selection_type: "quickpick",
10
+ start_date_id: "quick-pick-start-date",
11
+ start_date_name: "quick-pick-start-date"
12
+ }) %>
13
+
14
+ <%= pb_rails("date_picker", props: {
15
+ allow_input: true,
16
+ custom_quick_pick_dates: {
17
+ dates: [
18
+ {
19
+ label: "Last 15 months",
20
+ value: {
21
+ timePeriod: "months",
22
+ amount: 15,
23
+ },
24
+ },
25
+ {
26
+ label: "First Week of June 2022",
27
+ value: ["06/01/2022", "06/07/2022"],
28
+ },
29
+ ],
30
+ },
31
+ default_date: "First Week of June 2022",
32
+ end_date_id: "quick-pick-end-date",
33
+ end_date_name: "quick-pick-end-date",
34
+ label: "Custom Date Picker",
35
+ mode: "range",
36
+ picker_id: "custom-quick-pick-default-date",
37
+ placeholder: "mm/dd/yyyy to mm/dd/yyyy",
38
+ selection_type: "quickpick",
39
+ start_date_id: "quick-pick-start-date",
40
+ start_date_name: "quick-pick-start-date"
41
+ }) %>
42
+
@@ -0,0 +1,44 @@
1
+ import React from "react"
2
+ import DatePicker from "../_date_picker"
3
+
4
+ const DatePickerQuickPickDefaultDate = (props) => (
5
+ <>
6
+ <DatePicker
7
+ allowInput
8
+ defaultDate="This month"
9
+ mode="range"
10
+ pickerId="quick-pick-default-date"
11
+ placeholder="mm/dd/yyyy to mm/dd/yyyy"
12
+ selectionType="quickpick"
13
+ {...props}
14
+ />
15
+
16
+ <DatePicker
17
+ allowInput
18
+ customQuickPickDates={{
19
+ dates: [
20
+ {
21
+ label: "Last 15 months",
22
+ value: {
23
+ timePeriod: "months",
24
+ amount: 15,
25
+ },
26
+ },
27
+ {
28
+ label: "First Week of June 2022",
29
+ value: ["06/01/2022", "06/07/2022"],
30
+ },
31
+ ],
32
+ }}
33
+ defaultDate="First Week of June 2022"
34
+ label="Custom Date Picker"
35
+ mode="range"
36
+ pickerId="custom-quick-pick-default-date"
37
+ placeholder="mm/dd/yyyy to mm/dd/yyyy"
38
+ selectionType="quickpick"
39
+ {...props}
40
+ />
41
+ </>
42
+ )
43
+
44
+ export default DatePickerQuickPickDefaultDate
@@ -0,0 +1 @@
1
+ To set a default value using Quick Pick, use the `defaultDate` or `default_date` prop. This prop should match one of the labels displayed in the UI of the dropdown menu.