playbook_ui 15.3.0.pre.alpha.PLAY2596datestackedcurrentyear12149 → 15.3.0.pre.alpha.PLAY2601advancedtablecustomcellmultiheaderrails12030
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/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.test.jsx +5 -68
- 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_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_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/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_row.rb +3 -32
- data/app/pb_kits/playbook/pb_background/background.html.erb +2 -10
- 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_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_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_stacked/_date_stacked.tsx +4 -6
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.html.erb +3 -2
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.rb +5 -11
- data/app/pb_kits/playbook/pb_date_stacked/date_stacked.test.js +9 -26
- data/app/pb_kits/playbook/pb_date_stacked/docs/_description.md +1 -1
- data/app/pb_kits/playbook/pb_date_stacked/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_date_stacked/docs/index.js +0 -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/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_dropdown/index.js +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_phone_number_input/_phone_number_input.tsx +17 -110
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -7
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +1 -64
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +1 -33
- data/dist/chunks/{_line_graph-C-AuMGN2.js → _line_graph-CqE0-dq5.js} +1 -1
- data/dist/chunks/_typeahead-3ZAbZUqU.js +6 -0
- data/dist/chunks/_weekday_stacked-BFB3mjtE.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 +1 -1
- 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 +7 -22
- 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_date_stacked/docs/_date_stacked_current_year.html.erb +0 -12
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.jsx +0 -27
- data/app/pb_kits/playbook/pb_date_stacked/docs/_date_stacked_current_year.md +0 -1
- 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/dist/chunks/_typeahead--38pnHwS.js +0 -6
- data/dist/chunks/_weekday_stacked-onVWU89T.js +0 -37
- data/dist/chunks/pb_form_validation-BNfSnIUF.js +0 -1
|
@@ -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'
|
|
@@ -19,7 +19,6 @@ type DateStackedProps = {
|
|
|
19
19
|
size?: "sm" | "md";
|
|
20
20
|
id?: string;
|
|
21
21
|
reverse?: boolean;
|
|
22
|
-
showCurrentYear?: boolean;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
const sizes: {sm: 4, md: 3} = {
|
|
@@ -38,7 +37,6 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
|
|
|
38
37
|
data={},
|
|
39
38
|
htmlOptions={},
|
|
40
39
|
size = "sm",
|
|
41
|
-
showCurrentYear = false,
|
|
42
40
|
} = props;
|
|
43
41
|
const classes = classnames(
|
|
44
42
|
buildCss("pb_date_stacked_kit", align, size, {
|
|
@@ -57,7 +55,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
|
|
|
57
55
|
return (
|
|
58
56
|
<>
|
|
59
57
|
{bold == false ? (
|
|
60
|
-
<div
|
|
58
|
+
<div
|
|
61
59
|
{...dataProps}
|
|
62
60
|
{...htmlProps}
|
|
63
61
|
className={classes}
|
|
@@ -70,10 +68,10 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
|
|
|
70
68
|
text={DateTime.toDay(date).toString()}
|
|
71
69
|
/>
|
|
72
70
|
</div>
|
|
73
|
-
{
|
|
71
|
+
{currentYear != inputYear && <Caption size="xs">{inputYear}</Caption>}
|
|
74
72
|
</div>
|
|
75
73
|
) : (
|
|
76
|
-
<div
|
|
74
|
+
<div
|
|
77
75
|
{...dataProps}
|
|
78
76
|
{...htmlProps}
|
|
79
77
|
className={classes}
|
|
@@ -91,7 +89,7 @@ const DateStacked = (props: DateStackedProps): React.ReactElement => {
|
|
|
91
89
|
size="4"
|
|
92
90
|
text={DateTime.toDay(date).toString()}
|
|
93
91
|
/>
|
|
94
|
-
{
|
|
92
|
+
{currentYear != inputYear && <Title size="4">{inputYear}</Title>}
|
|
95
93
|
</div>
|
|
96
94
|
</div>
|
|
97
95
|
)}
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
<div class="pb_date_stacked_day_month">
|
|
6
6
|
<%= pb_rails("caption", props: { text: object.month }) %>
|
|
7
|
-
<%= pb_rails("title", props: { text: object.day , size: object.title_size }) %>
|
|
7
|
+
<%= pb_rails("title", props: { text: object.day , size: object.title_size }) do %><% end %>
|
|
8
8
|
<%= pb_rails("caption", props: { text: object.year, size:"xs" }) %>
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
11
|
<% else %>
|
|
12
12
|
<div class="pb_date_stacked_day_month">
|
|
13
13
|
<%= pb_rails("title", props: { text: object.month, size: 4 }) %>
|
|
14
|
-
<%= pb_rails("title", props: { text: object.day, size: 4 }) %>
|
|
14
|
+
<%= pb_rails("title", props: { text: object.day, size: 4 }) do %><% end %>
|
|
15
15
|
<%= pb_rails("title", props: { text: object.year, size:4 }) %>
|
|
16
|
+
|
|
16
17
|
</div>
|
|
17
18
|
|
|
18
19
|
<% end %>
|
|
@@ -16,8 +16,6 @@ module Playbook
|
|
|
16
16
|
default: false
|
|
17
17
|
prop :bold, type: Playbook::Props::Boolean,
|
|
18
18
|
default: false
|
|
19
|
-
prop :show_current_year, type: Playbook::Props::Boolean,
|
|
20
|
-
default: false
|
|
21
19
|
|
|
22
20
|
def classname
|
|
23
21
|
generate_classname("pb_date_stacked_kit", align, size, reverse_class, dark_class)
|
|
@@ -39,15 +37,11 @@ module Playbook
|
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
def year
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if current_year != year
|
|
48
|
-
content_tag(:time, datetime: year) do
|
|
49
|
-
year.to_s
|
|
50
|
-
end
|
|
40
|
+
current_year = DateTime.now.year.to_i
|
|
41
|
+
year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
|
|
42
|
+
if current_year != year
|
|
43
|
+
content_tag(:time, datetime: year) do
|
|
44
|
+
year.to_s
|
|
51
45
|
end
|
|
52
46
|
end
|
|
53
47
|
end
|
|
@@ -22,7 +22,7 @@ describe("DateStacked Kit", () => {
|
|
|
22
22
|
align="left"
|
|
23
23
|
data={{ testid: testId }}
|
|
24
24
|
date={new Date()}
|
|
25
|
-
size="sm"
|
|
25
|
+
size="sm"
|
|
26
26
|
/>
|
|
27
27
|
)
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ describe("DateStacked Kit", () => {
|
|
|
36
36
|
align="left"
|
|
37
37
|
data={{ testid: testId }}
|
|
38
38
|
date={new Date()}
|
|
39
|
-
size="sm"
|
|
39
|
+
size="sm"
|
|
40
40
|
/>
|
|
41
41
|
)
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ describe("DateStacked Kit", () => {
|
|
|
51
51
|
align="left"
|
|
52
52
|
data={{ testid: testId }}
|
|
53
53
|
date={new Date()}
|
|
54
|
-
size="sm"
|
|
54
|
+
size="sm"
|
|
55
55
|
/>
|
|
56
56
|
)
|
|
57
57
|
|
|
@@ -66,7 +66,7 @@ describe("DateStacked Kit", () => {
|
|
|
66
66
|
align="left"
|
|
67
67
|
data={{ testid: testId }}
|
|
68
68
|
date={new Date()}
|
|
69
|
-
size="md"
|
|
69
|
+
size="md"
|
|
70
70
|
/>
|
|
71
71
|
)
|
|
72
72
|
|
|
@@ -80,7 +80,7 @@ describe("DateStacked Kit", () => {
|
|
|
80
80
|
align="left"
|
|
81
81
|
data={{ testid: testId }}
|
|
82
82
|
date={futureDate}
|
|
83
|
-
size="sm"
|
|
83
|
+
size="sm"
|
|
84
84
|
/>
|
|
85
85
|
)
|
|
86
86
|
|
|
@@ -89,23 +89,6 @@ describe("DateStacked Kit", () => {
|
|
|
89
89
|
expect(text.textContent).toEqual("2016")
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
test("renders current year when showCurrentYear is true", () => {
|
|
93
|
-
render(
|
|
94
|
-
<DateStacked
|
|
95
|
-
align="left"
|
|
96
|
-
data={{ testid: testId }}
|
|
97
|
-
date={new Date()}
|
|
98
|
-
showCurrentYear
|
|
99
|
-
size="sm"
|
|
100
|
-
/>
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
const kit = screen.getByTestId(testId)
|
|
104
|
-
const text = kit.querySelector(".pb_caption_kit_xs")
|
|
105
|
-
const currentYear = new Date().getFullYear()
|
|
106
|
-
expect(text.textContent).toEqual(`${currentYear}`)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
92
|
test("renders correct className when order reversed", () => {
|
|
110
93
|
render(
|
|
111
94
|
<DateStacked
|
|
@@ -113,7 +96,7 @@ describe("DateStacked Kit", () => {
|
|
|
113
96
|
data={{ testid: testId }}
|
|
114
97
|
date={futureDate}
|
|
115
98
|
reverse
|
|
116
|
-
size="sm"
|
|
99
|
+
size="sm"
|
|
117
100
|
/>
|
|
118
101
|
)
|
|
119
102
|
const kit = screen.getByTestId(testId)
|
|
@@ -127,7 +110,7 @@ describe("DateStacked Kit", () => {
|
|
|
127
110
|
bold
|
|
128
111
|
data={{ testid: testId }}
|
|
129
112
|
date={futureDate}
|
|
130
|
-
size="md"
|
|
113
|
+
size="md"
|
|
131
114
|
/>
|
|
132
115
|
)
|
|
133
116
|
|
|
@@ -142,7 +125,7 @@ describe("DateStacked Kit", () => {
|
|
|
142
125
|
align="center"
|
|
143
126
|
data={{ testid: testId }}
|
|
144
127
|
date={futureDate}
|
|
145
|
-
size="md"
|
|
128
|
+
size="md"
|
|
146
129
|
/>
|
|
147
130
|
)
|
|
148
131
|
|
|
@@ -156,7 +139,7 @@ describe("DateStacked Kit", () => {
|
|
|
156
139
|
align="right"
|
|
157
140
|
data={{ testid: testId }}
|
|
158
141
|
date={futureDate}
|
|
159
|
-
size="md"
|
|
142
|
+
size="md"
|
|
160
143
|
/>
|
|
161
144
|
)
|
|
162
145
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Use to display the date, stacking month and day.
|
|
1
|
+
Use to display the date, stacking month and day. Year will not show if it is the current year.
|
|
@@ -3,7 +3,6 @@ examples:
|
|
|
3
3
|
rails:
|
|
4
4
|
- date_stacked_default: Default
|
|
5
5
|
- date_stacked_not_current_year: Not Current Year
|
|
6
|
-
- date_stacked_current_year: Show Current Year
|
|
7
6
|
- date_stacked_reverse: Day & Month Reverse
|
|
8
7
|
- date_stacked_sizes: Sizes
|
|
9
8
|
- date_stacked_align: Alignment
|
|
@@ -13,7 +12,6 @@ examples:
|
|
|
13
12
|
react:
|
|
14
13
|
- date_stacked_default: Default
|
|
15
14
|
- date_stacked_not_current_year: Not Current Year
|
|
16
|
-
- date_stacked_current_year: Show Current Year
|
|
17
15
|
- date_stacked_reverse: Day & Month Reverse
|
|
18
16
|
- date_stacked_sizes: Sizes
|
|
19
17
|
- date_stacked_bold: Bold
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as DateStackedBold } from './_date_stacked_bold.jsx'
|
|
2
2
|
export { default as DateStackedDefault } from './_date_stacked_default.jsx'
|
|
3
3
|
export { default as DateStackedNotCurrentYear } from './_date_stacked_not_current_year.jsx'
|
|
4
|
-
export { default as DateStackedCurrentYear } from './_date_stacked_current_year.jsx'
|
|
5
4
|
export { default as DateStackedReverse } from './_date_stacked_reverse.jsx'
|
|
6
5
|
export { default as DateStackedSizes } from './_date_stacked_sizes.jsx'
|
|
7
6
|
export { default as DateStackedAlign } from './_date_stacked_align.jsx'
|
|
@@ -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
|
|
@@ -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'
|