playbook_ui 15.3.0.pre.alpha.PLAY2532flexboxdefaultresponsive12209 → 15.3.0.pre.alpha.PLAY2565formkitsubmitfix11681
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +1 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +3 -18
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +14 -71
- data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowUtils.ts +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +3 -12
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +5 -127
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +0 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_border_color_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.jsx +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling.md +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_column_headers.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.html.erb +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_rails.md +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.jsx +0 -28
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_row_loading.md +2 -11
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.jsx +1 -9
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_padding_control.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +1 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +2 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_columns_and_header.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +0 -16
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/index.js +7 -7
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +20 -90
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +3 -32
- data/app/pb_kits/playbook/pb_background/background.html.erb +2 -10
- data/app/pb_kits/playbook/pb_background/docs/_background_category.md +1 -1
- data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -4
- data/app/pb_kits/playbook/pb_badge/badge.test.js +0 -13
- data/app/pb_kits/playbook/pb_card/docs/_card_background.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_light.md +1 -1
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +7 -20
- data/app/pb_kits/playbook/pb_currency/currency.rb +8 -35
- data/app/pb_kits/playbook/pb_currency/currency.test.js +0 -47
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.jsx +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +0 -2
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +4 -16
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_quick_pick_styles.scss +30 -11
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +6 -111
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -5
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +2 -148
- data/app/pb_kits/playbook/pb_filter/docs/_filter_max_width.md +1 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_auto_close.html.erb +1 -15
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_multi_line.html.erb +8 -9
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_positions.html.erb +10 -11
- data/app/pb_kits/playbook/pb_form/pb_form_validation.js +11 -44
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md +1 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md +1 -1
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -1
- data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_color.md +1 -1
- data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.html.erb +14 -7
- data/app/pb_kits/playbook/pb_icon_stat_value/docs/_icon_stat_value_color.jsx +15 -6
- data/app/pb_kits/playbook/pb_layout/docs/_layout_collection.md +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_collapsible_nav_item_spacing.md +1 -1
- data/app/pb_kits/playbook/pb_nav/docs/_nav_with_spacing_control.md +1 -1
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_layout.md +1 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +17 -110
- data/app/pb_kits/playbook/pb_pill/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +34 -69
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_popover/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_popover/popover.test.js +0 -80
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_section_separator/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +0 -29
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_rails.md +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_react.md +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_side_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sm.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +2 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -7
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +1 -105
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +9 -23
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -33
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_options.html.erb +1 -67
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.jsx +6 -68
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.md +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -2
- data/app/pb_kits/playbook/utilities/globalProps.ts +8 -26
- data/app/pb_kits/playbook/utilities/test/globalProps/alignContent.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/alignItems.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/alignSelf.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/display.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/flex.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/flexDirection.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/flexGrow.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/flexShrink.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/flexWrap.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/justifyContent.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/justifySelf.test.js +0 -18
- data/app/pb_kits/playbook/utilities/test/globalProps/order.test.js +0 -18
- data/dist/chunks/{_line_graph-9bI76O2f.js → _line_graph-h5H-imfn.js} +1 -1
- data/dist/chunks/_typeahead-U8AjZIIW.js +6 -0
- data/dist/chunks/_weekday_stacked-CbCUYuuZ.js +37 -0
- data/dist/chunks/{lib-BXBHAZMY.js → lib-CGxXTQ75.js} +1 -1
- data/dist/chunks/pb_form_validation-DebqlUKZ.js +1 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +8 -32
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.html.erb +0 -104
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header_rails.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data_inline_loading_empty_children.js +0 -42
- data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.md +0 -1
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.jsx +0 -38
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_and_dropdown_range.md +0 -14
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.jsx +0 -18
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick.md +0 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.jsx +0 -18
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.jsx +0 -19
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end.md +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.jsx +0 -38
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers.md +0 -14
- data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +0 -60
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to.jsx +0 -68
- data/app/pb_kits/playbook/pb_popover/docs/_popover_append_to_react.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.html.erb +0 -63
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible.jsx +0 -89
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_rails.md +0 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_with_dynamic_collapsible_react.md +0 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.html.erb +0 -64
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.jsx +0 -70
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_options.md +0 -1
- data/dist/chunks/_typeahead-By0NwDwL.js +0 -6
- data/dist/chunks/_weekday_stacked-ClJbIaDx.js +0 -37
- data/dist/chunks/pb_form_validation-BNfSnIUF.js +0 -1
- /data/app/pb_kits/playbook/pb_popover/docs/{_popover_append_to_rails.md → _popover_append_to.md} +0 -0
|
@@ -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,
|
|
15
15
|
aria?: {[key:string]:string},
|
|
16
16
|
className?: string,
|
|
17
17
|
dark?: boolean,
|
|
@@ -59,19 +59,6 @@ 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
|
-
|
|
75
62
|
const emphasizedClass = emphasized ? '' : '_deemphasized'
|
|
76
63
|
|
|
77
64
|
let variantClass
|
|
@@ -81,7 +68,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
|
81
68
|
variantClass = '_bold'
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
const [whole, decimal = '00'] =
|
|
71
|
+
const [whole, decimal = '00'] = amount.split('.')
|
|
85
72
|
const ariaProps = buildAriaProps(aria)
|
|
86
73
|
const dataProps = buildDataProps(data)
|
|
87
74
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
@@ -105,19 +92,19 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
|
105
92
|
return isAmount ? num.slice(0, -1) : isUnit ? num.slice(-1) : ''
|
|
106
93
|
}
|
|
107
94
|
|
|
108
|
-
const getMatchingDecimalAmount = decimals === "matching" ?
|
|
95
|
+
const getMatchingDecimalAmount = decimals === "matching" ? amount : whole
|
|
109
96
|
const getMatchingDecimalValue = decimals === "matching" ? '' : `.${decimal}`
|
|
110
97
|
|
|
111
98
|
const formatAmount = (amount: string) => {
|
|
112
99
|
if (!commaSeparator) return amount;
|
|
113
|
-
|
|
100
|
+
|
|
114
101
|
const [wholePart, decimalPart] = amount.split('.');
|
|
115
102
|
const formattedWhole = new Intl.NumberFormat('en-US').format(parseInt(wholePart));
|
|
116
103
|
return decimalPart ? `${formattedWhole}.${decimalPart}` : formattedWhole;
|
|
117
104
|
}
|
|
118
105
|
|
|
119
106
|
const swapNegative = size === "sm" && symbol !== ""
|
|
120
|
-
const handleNegative =
|
|
107
|
+
const handleNegative = amount.startsWith("-") && swapNegative ? "-" : ""
|
|
121
108
|
const getAbsoluteAmount = (amountString: string) => amountString.replace(/^-/,'')
|
|
122
109
|
const getAbbrOrFormatAmount = abbreviate ? getAbbreviatedValue('amount') : formatAmount(getMatchingDecimalAmount)
|
|
123
110
|
const getAmount = swapNegative ? getAbsoluteAmount(getAbbrOrFormatAmount) : getAbbrOrFormatAmount
|
|
@@ -165,7 +152,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
|
165
152
|
>
|
|
166
153
|
{handleNegative}{symbol}
|
|
167
154
|
</Body>
|
|
168
|
-
|
|
155
|
+
|
|
169
156
|
<Title
|
|
170
157
|
className="pb_currency_value"
|
|
171
158
|
dark={dark}
|
|
@@ -173,7 +160,7 @@ const Currency = (props: CurrencyProps): React.ReactElement => {
|
|
|
173
160
|
>
|
|
174
161
|
{getAmount}
|
|
175
162
|
</Title>
|
|
176
|
-
|
|
163
|
+
|
|
177
164
|
<Body
|
|
178
165
|
className="unit"
|
|
179
166
|
color="light"
|
|
@@ -17,7 +17,8 @@ module Playbook
|
|
|
17
17
|
prop :symbol, type: Playbook::Props::String,
|
|
18
18
|
default: "$"
|
|
19
19
|
|
|
20
|
-
prop :amount,
|
|
20
|
+
prop :amount, type: Playbook::Props::String,
|
|
21
|
+
required: true
|
|
21
22
|
|
|
22
23
|
prop :unit, type: Playbook::Props::String,
|
|
23
24
|
required: false
|
|
@@ -91,7 +92,7 @@ module Playbook
|
|
|
91
92
|
end
|
|
92
93
|
|
|
93
94
|
def negative_sign
|
|
94
|
-
|
|
95
|
+
amount.starts_with?("-") && swap_negative ? "-" : ""
|
|
95
96
|
end
|
|
96
97
|
|
|
97
98
|
def body_props
|
|
@@ -116,32 +117,10 @@ module Playbook
|
|
|
116
117
|
end
|
|
117
118
|
end
|
|
118
119
|
|
|
119
|
-
def currency_amount
|
|
120
|
-
@currency_amount ||= convert_amount(amount)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
120
|
private
|
|
124
121
|
|
|
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
|
-
|
|
141
122
|
def whole_value
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
value = currency_amount.split(".").first
|
|
123
|
+
value = amount.split(".").first
|
|
145
124
|
if comma_separator
|
|
146
125
|
number_with_delimiter(value.gsub(",", ""))
|
|
147
126
|
else
|
|
@@ -150,9 +129,7 @@ module Playbook
|
|
|
150
129
|
end
|
|
151
130
|
|
|
152
131
|
def decimal_value
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
currency_amount.split(".")[1] || "00"
|
|
132
|
+
amount.split(".")[1] || "00"
|
|
156
133
|
end
|
|
157
134
|
|
|
158
135
|
def units_element
|
|
@@ -170,9 +147,7 @@ module Playbook
|
|
|
170
147
|
end
|
|
171
148
|
|
|
172
149
|
def abbreviated_value(index = 0..-2)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
value = currency_amount.split(".").first.gsub(",", "").to_i
|
|
150
|
+
value = amount.split(".").first.gsub(",", "").to_i
|
|
176
151
|
abbreviated_num = number_to_human(value, units: { thousand: "K", million: "M", billion: "B", trillion: "T" }).gsub(/\s+/, "")
|
|
177
152
|
abbreviated_num[index]
|
|
178
153
|
end
|
|
@@ -199,11 +174,9 @@ module Playbook
|
|
|
199
174
|
|
|
200
175
|
if decimals == "matching"
|
|
201
176
|
if comma_separator
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
number_with_delimiter(currency_amount.gsub(",", ""))
|
|
177
|
+
number_with_delimiter(amount.gsub(",", ""))
|
|
205
178
|
else
|
|
206
|
-
|
|
179
|
+
amount
|
|
207
180
|
end
|
|
208
181
|
else
|
|
209
182
|
whole_value
|
|
@@ -133,50 +133,3 @@ 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
|
-
})
|
|
@@ -350,14 +350,8 @@ 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
|
|
354
|
-
|
|
355
|
-
if (element?._dropdownRef?.current) {
|
|
356
|
-
element._dropdownRef.current.clearSelected();
|
|
357
|
-
} else {
|
|
358
|
-
const quickpick = element?._flatpickr;
|
|
359
|
-
quickpick?.clear();
|
|
360
|
-
}
|
|
353
|
+
const quickpick = (document.querySelector(`#${syncStartWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
354
|
+
quickpick?.clear();
|
|
361
355
|
}
|
|
362
356
|
});
|
|
363
357
|
}
|
|
@@ -366,14 +360,8 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
|
|
|
366
360
|
if (syncEndWith) {
|
|
367
361
|
picker.config.onClose.push((selectedDates: string) => {
|
|
368
362
|
if (selectedDates?.length) {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
if (element?._dropdownRef?.current) {
|
|
372
|
-
element._dropdownRef.current.clearSelected();
|
|
373
|
-
} else {
|
|
374
|
-
const quickpick = element?._flatpickr;
|
|
375
|
-
quickpick?.clear();
|
|
376
|
-
}
|
|
363
|
+
const quickpick = (document.querySelector(`#${syncEndWith}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
364
|
+
quickpick?.clear();
|
|
377
365
|
}
|
|
378
366
|
});
|
|
379
367
|
}
|
|
@@ -48,8 +48,7 @@ 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
|
-
|
|
52
|
-
- date_picker_and_dropdown_range: Range with Dropdown and 2 Date Pickers
|
|
51
|
+
- date_picker_range_pattern: Range with 2 Date Pickers and a Quick Pick
|
|
53
52
|
- date_picker_format: Format
|
|
54
53
|
- date_picker_disabled: Disabled Dates
|
|
55
54
|
- date_picker_min_max: Min Max
|
|
@@ -26,5 +26,4 @@ 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'
|
|
30
|
-
export { default as DatePickerAndDropdownRange } from './_date_picker_and_dropdown_range.jsx'
|
|
29
|
+
export { default as DatePickerRangePattern } from './_date_picker_range_pattern'
|
|
@@ -9,20 +9,29 @@ $pb_card_border_radius: $border_rad_heavier;
|
|
|
9
9
|
|
|
10
10
|
// used to display dropdown on the left of the calender
|
|
11
11
|
.quick-pick-drop-down {
|
|
12
|
-
width:
|
|
12
|
+
width: auto;
|
|
13
|
+
display: grid;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.quick-pick-ul {
|
|
17
|
+
padding: $space_xs 0px;
|
|
16
18
|
margin: 0;
|
|
17
19
|
list-style: none;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
.nav-item {
|
|
21
23
|
list-style: none;
|
|
24
|
+
border-radius: 6px;
|
|
25
|
+
border-bottom: 0;
|
|
26
|
+
margin: $space_xs $space_sm;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
.nav-item-link {
|
|
25
30
|
text-decoration: none;
|
|
31
|
+
border-width: $pb_card_border_width;
|
|
32
|
+
border-style: solid;
|
|
33
|
+
border-color: $border_light;
|
|
34
|
+
border-radius: $pb_card_border_radius;
|
|
26
35
|
padding: $space_xs 14px;
|
|
27
36
|
transition-property: color, background-color;
|
|
28
37
|
transition-duration: 0.15s;
|
|
@@ -31,21 +40,15 @@ $pb_card_border_radius: $border_rad_heavier;
|
|
|
31
40
|
color: $charcoal;
|
|
32
41
|
font-size: $font_default;
|
|
33
42
|
font-weight: $regular;
|
|
34
|
-
text-align: left;
|
|
35
|
-
border-bottom: 1px solid $border_light;
|
|
36
43
|
&.active {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
&:hover {
|
|
40
|
-
background-color: $product_1_background;
|
|
41
|
-
color: $white;
|
|
42
|
-
}
|
|
44
|
+
border-width: 2px;
|
|
45
|
+
border-color: $primary;
|
|
43
46
|
}
|
|
44
47
|
@media (hover:hover) {
|
|
45
48
|
&:hover {
|
|
46
49
|
cursor: pointer;
|
|
47
|
-
|
|
48
|
-
color: $
|
|
50
|
+
box-shadow: $shadow-deep;
|
|
51
|
+
border-color: $slate;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -54,3 +57,19 @@ $pb_card_border_radius: $border_rad_heavier;
|
|
|
54
57
|
.quick-pick-drop-down > .flatpickr-months, .quick-pick-drop-down > .flatpickr-innerContainer {
|
|
55
58
|
display: none;
|
|
56
59
|
}
|
|
60
|
+
|
|
61
|
+
@media only screen and (max-width: 767px) {
|
|
62
|
+
.quick-pick-ul {
|
|
63
|
+
padding: $space_xs $space_xs;
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-template-columns: 1fr 1fr;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nav-item {
|
|
69
|
+
margin: $space_xxs $space_xs;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nav-item-link {
|
|
73
|
+
padding: $space_xs $space_xxs;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](
|
|
1
|
+
You can customize the order of the colors you would like to use by using the `colors` prop. Only the data and status colors will work for Playbook charts. See the [design page](/visual_guidelines) for reference.
|
|
@@ -12,7 +12,6 @@ import DropdownContext from "./context";
|
|
|
12
12
|
import DropdownOption from "./subcomponents/DropdownOption";
|
|
13
13
|
import DropdownTrigger from "./subcomponents/DropdownTrigger";
|
|
14
14
|
import useDropdown from "./hooks/useDropdown";
|
|
15
|
-
import getQuickPickOptions from "./quickpick";
|
|
16
15
|
|
|
17
16
|
import {
|
|
18
17
|
separateChildComponents,
|
|
@@ -37,12 +36,9 @@ type DropdownProps = {
|
|
|
37
36
|
label?: string;
|
|
38
37
|
multiSelect?: boolean;
|
|
39
38
|
onSelect?: (arg: GenericObject) => null;
|
|
40
|
-
options
|
|
39
|
+
options: GenericObject;
|
|
41
40
|
separators?: boolean;
|
|
42
|
-
variant?: "default" | "subtle"
|
|
43
|
-
rangeEndsToday?: boolean;
|
|
44
|
-
controlsStartId?: string;
|
|
45
|
-
controlsEndId?: string;
|
|
41
|
+
variant?: "default" | "subtle";
|
|
46
42
|
activeStyle?: {
|
|
47
43
|
backgroundColor?: string;
|
|
48
44
|
fontColor?: string;
|
|
@@ -75,9 +71,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
75
71
|
formPillProps,
|
|
76
72
|
onSelect,
|
|
77
73
|
options,
|
|
78
|
-
rangeEndsToday = false,
|
|
79
|
-
controlsStartId,
|
|
80
|
-
controlsEndId,
|
|
81
74
|
separators = true,
|
|
82
75
|
variant = "default",
|
|
83
76
|
activeStyle,
|
|
@@ -92,25 +85,11 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
92
85
|
globalProps(props),
|
|
93
86
|
className
|
|
94
87
|
);
|
|
95
|
-
// ------------- Quick Pick ---------------------------------
|
|
96
|
-
// Use QuickPick options when variant is "quickpick"
|
|
97
|
-
const dropdownOptions = variant === "quickpick"
|
|
98
|
-
? getQuickPickOptions(rangeEndsToday)
|
|
99
|
-
: (options || []);
|
|
100
|
-
// ----------------------------------------------------------
|
|
101
88
|
|
|
102
89
|
const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(isClosed);
|
|
103
90
|
|
|
104
91
|
const [filterItem, setFilterItem] = useState("");
|
|
105
92
|
const initialSelected = useMemo(() => {
|
|
106
|
-
// Handle quickpick variant with string defaultValue (e.g., "This Month")
|
|
107
|
-
if (variant === "quickpick" && typeof defaultValue === "string" && defaultValue) {
|
|
108
|
-
const matchedOption = dropdownOptions.find(
|
|
109
|
-
(opt: GenericObject) => opt.label?.toLowerCase() === (defaultValue as string).toLowerCase()
|
|
110
|
-
);
|
|
111
|
-
return matchedOption || {};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
93
|
if (multiSelect) {
|
|
115
94
|
if (Array.isArray(defaultValue)) return defaultValue;
|
|
116
95
|
return defaultValue && Object.keys(defaultValue).length
|
|
@@ -118,7 +97,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
118
97
|
: [];
|
|
119
98
|
}
|
|
120
99
|
return defaultValue || {};
|
|
121
|
-
}, [multiSelect, defaultValue
|
|
100
|
+
}, [multiSelect, defaultValue]);
|
|
122
101
|
|
|
123
102
|
const [selected, setSelected] = useState<GenericObject | GenericObject[]>(
|
|
124
103
|
initialSelected
|
|
@@ -172,7 +151,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
172
151
|
}, [isClosed])
|
|
173
152
|
|
|
174
153
|
const blankSelectionOption: GenericObject = blankSelection ? [{ label: blankSelection, value: "" }] : [];
|
|
175
|
-
const optionsWithBlankSelection = blankSelectionOption.concat(
|
|
154
|
+
const optionsWithBlankSelection = blankSelectionOption.concat(options);
|
|
176
155
|
|
|
177
156
|
const availableOptions = useMemo(()=> {
|
|
178
157
|
if (!multiSelect) return optionsWithBlankSelection;
|
|
@@ -224,21 +203,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
224
203
|
setFilterItem("");
|
|
225
204
|
setIsDropDownClosed(true);
|
|
226
205
|
onSelect && onSelect(clickedItem);
|
|
227
|
-
|
|
228
|
-
// Sync with DatePickers if this is a quickpick variant
|
|
229
|
-
if (variant === "quickpick" && Array.isArray(clickedItem.value)) {
|
|
230
|
-
const [start, end] = clickedItem.value;
|
|
231
|
-
|
|
232
|
-
if (controlsStartId) {
|
|
233
|
-
const startPicker = (document.querySelector(`#${controlsStartId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
234
|
-
startPicker?.setDate(start, true);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (controlsEndId) {
|
|
238
|
-
const endPicker = (document.querySelector(`#${controlsEndId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
239
|
-
endPicker?.setDate(end, true);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
206
|
}
|
|
243
207
|
};
|
|
244
208
|
|
|
@@ -255,19 +219,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
255
219
|
setSelected({});
|
|
256
220
|
onSelect && onSelect(null);
|
|
257
221
|
setFocusedOptionIndex(-1);
|
|
258
|
-
|
|
259
|
-
// Clear linked DatePickers as well if this is a quickpick variant with controls
|
|
260
|
-
if (variant === "quickpick") {
|
|
261
|
-
if (controlsStartId) {
|
|
262
|
-
const startPicker = (document.querySelector(`#${controlsStartId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
263
|
-
startPicker?.clear();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (controlsEndId) {
|
|
267
|
-
const endPicker = (document.querySelector(`#${controlsEndId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
268
|
-
endPicker?.clear();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
222
|
}
|
|
272
223
|
};
|
|
273
224
|
|
|
@@ -281,8 +232,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
281
232
|
dark
|
|
282
233
|
});
|
|
283
234
|
|
|
284
|
-
|
|
285
|
-
const imperativeRef = useRef({
|
|
235
|
+
useImperativeHandle(ref, () => ({
|
|
286
236
|
clearSelected: () => {
|
|
287
237
|
if (multiSelect) {
|
|
288
238
|
setSelected([]);
|
|
@@ -294,61 +244,7 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
294
244
|
setFilterItem("");
|
|
295
245
|
setIsDropDownClosed(true);
|
|
296
246
|
},
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// Update imperativeRef whenever dependencies change
|
|
300
|
-
// (needed for external clearing of normal Dropdown + DatePicker-synced QuickPick Dropdown)
|
|
301
|
-
useEffect(() => {
|
|
302
|
-
imperativeRef.current = {
|
|
303
|
-
clearSelected: () => {
|
|
304
|
-
if (multiSelect) {
|
|
305
|
-
setSelected([]);
|
|
306
|
-
onSelect && onSelect([]);
|
|
307
|
-
} else {
|
|
308
|
-
setSelected({});
|
|
309
|
-
onSelect && onSelect(null);
|
|
310
|
-
}
|
|
311
|
-
setFilterItem("");
|
|
312
|
-
setIsDropDownClosed(true);
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
}, [multiSelect, onSelect, setSelected, setFilterItem, setIsDropDownClosed]);
|
|
316
|
-
|
|
317
|
-
useImperativeHandle(ref, () => imperativeRef.current);
|
|
318
|
-
|
|
319
|
-
// Create a ref to the outer div to attach the dropdown ref for DatePicker sync
|
|
320
|
-
const outerDivRef = useRef<HTMLDivElement>(null);
|
|
321
|
-
|
|
322
|
-
useEffect(() => {
|
|
323
|
-
// Attach the ref to the DOM element so DatePicker can access it
|
|
324
|
-
if (outerDivRef.current && variant === "quickpick" && id) {
|
|
325
|
-
(outerDivRef.current as any)._dropdownRef = imperativeRef;
|
|
326
|
-
}
|
|
327
|
-
}, [variant, id]);
|
|
328
|
-
|
|
329
|
-
// Sync defaultValue with DatePickers on mount when 3 input pattern is used
|
|
330
|
-
useEffect(() => {
|
|
331
|
-
if (variant === "quickpick" && initialSelected && typeof initialSelected === "object" && !Array.isArray(initialSelected)) {
|
|
332
|
-
const value = initialSelected.value;
|
|
333
|
-
|
|
334
|
-
if (Array.isArray(value) && value.length === 2) {
|
|
335
|
-
const [start, end] = value;
|
|
336
|
-
|
|
337
|
-
// Wait for DatePickers to be initialized
|
|
338
|
-
setTimeout(() => {
|
|
339
|
-
if (controlsStartId) {
|
|
340
|
-
const startPicker = (document.querySelector(`#${controlsStartId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
341
|
-
startPicker?.setDate(start, true);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (controlsEndId) {
|
|
345
|
-
const endPicker = (document.querySelector(`#${controlsEndId}`) as HTMLElement & { _flatpickr?: any })?._flatpickr;
|
|
346
|
-
endPicker?.setDate(end, true);
|
|
347
|
-
}
|
|
348
|
-
}, 0);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}, [variant, initialSelected, controlsStartId, controlsEndId]);
|
|
247
|
+
}));
|
|
352
248
|
|
|
353
249
|
return (
|
|
354
250
|
<div {...ariaProps}
|
|
@@ -356,7 +252,6 @@ let Dropdown = (props: DropdownProps, ref: any): React.ReactElement | null => {
|
|
|
356
252
|
{...htmlProps}
|
|
357
253
|
className={classes}
|
|
358
254
|
id={id}
|
|
359
|
-
ref={outerDivRef}
|
|
360
255
|
style={{position: "relative"}}
|
|
361
256
|
>
|
|
362
257
|
<DropdownContext.Provider
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_active_style_options_react.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
The `activeStyle` prop can be used to customize the appearance of the dropdown selection indicator. It accepts an object with the following keys: `backgroundColor` sets the background color of the selected item (and its hover state); `fontColor` sets the font color of the selected item.
|
|
2
2
|
|
|
3
3
|
`backgroundColor` **Type**: String | **Values**: bg_light | white | **Default**: (no selection) is primary
|
|
4
|
-
`fontColor` **Type**: String | **Values**: primary | all [Playbook Text Colors](https://playbook.powerapp.cloud/
|
|
4
|
+
`fontColor` **Type**: String | **Values**: primary | all [Playbook Text Colors](https://playbook.powerapp.cloud/visual_guidelines/colors) | **Default**: (no selection) is white
|
|
@@ -49,9 +49,4 @@ examples:
|
|
|
49
49
|
- dropdown_clear_selection: Clear Selection
|
|
50
50
|
- dropdown_separators_hidden: Separators Hidden
|
|
51
51
|
- dropdown_with_external_control: useDropdown Hook
|
|
52
|
-
- dropdown_quickpick: Quick Pick Variant
|
|
53
|
-
- dropdown_quickpick_range_end: Quick Pick Variant (Range Ends Today)
|
|
54
|
-
- dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
|
|
55
|
-
- dropdown_quickpick_with_date_pickers: Quick Pick Variant with Date Pickers
|
|
56
|
-
|
|
57
52
|
|
|
@@ -22,8 +22,4 @@ export { default as DropdownMultiSelectWithDefault } from './_dropdown_multi_sel
|
|
|
22
22
|
export { default as DropdownMultiSelectWithCustomOptions } from './_dropdown_multi_select_with_custom_options.jsx'
|
|
23
23
|
export {default as DropdownWithCustomIconOptions} from './_dropdown_with_custom_icon_options.jsx'
|
|
24
24
|
export {default as DropdownWithCustomRadioOptions} from './_dropdown_with_custom_radio_options.jsx'
|
|
25
|
-
export {default as DropdownWithCustomActiveStyleOptions} from './_dropdown_with_custom_active_style_options.jsx'
|
|
26
|
-
export { default as DropdownQuickpick } from './_dropdown_quickpick.jsx'
|
|
27
|
-
export { default as DropdownQuickpickRangeEnd } from './_dropdown_quickpick_range_end.jsx'
|
|
28
|
-
export { default as DropdownQuickpickDefaultDates } from './_dropdown_quickpick_default_dates.jsx'
|
|
29
|
-
export { default as DropdownQuickpickWithDatePickers } from './_dropdown_quickpick_with_date_pickers.jsx'
|
|
25
|
+
export {default as DropdownWithCustomActiveStyleOptions} from './_dropdown_with_custom_active_style_options.jsx'
|