Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOM-1091 Upgrade Downshift dependency. #2283

Merged
merged 47 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6b8b2c0
upgrade downshift dependency v2 -> v9 XD
JohnC-80 May 10, 2024
b9c5fde
refactor Selection to use downshift. Implement option group feature -…
JohnC-80 May 10, 2024
ad9a812
assign proper aria-attributes to list items, properly render when no …
JohnC-80 May 13, 2024
6ea1c11
add hook to use provided ref or use an internal ref
JohnC-80 May 13, 2024
67041d7
fill out props for Selection migration
JohnC-80 May 14, 2024
5f22485
remove only from selection tests
JohnC-80 May 14, 2024
f5520b6
refactor AutoSugggest. Convert to functional component.
JohnC-80 May 14, 2024
47e3056
refactor MultiSelection component to use Downshift hooks.
JohnC-80 May 24, 2024
03866a0
clean up tests
JohnC-80 May 24, 2024
336627d
apply aria-labelledby to filter field
JohnC-80 May 24, 2024
17991f7
factor out OptionListWrapper component
JohnC-80 May 24, 2024
1f405ed
resolve merge conflict on MultiSelectValueInput
JohnC-80 May 24, 2024
ef21702
lint selection components
JohnC-80 May 28, 2024
c9173eb
whitespace
JohnC-80 May 28, 2024
6bfda04
fix option click removal in MultiSelection
JohnC-80 May 30, 2024
619ffad
get Selection in line with conventions in MultiSelection
JohnC-80 May 31, 2024
e2332d0
lint AutoSuggest
JohnC-80 May 31, 2024
faf7d1e
actually return something from getClass in AutoSuggest.
JohnC-80 May 31, 2024
95d0463
clean up sonardad's 'intentionality' suggestions
JohnC-80 Jun 3, 2024
648dc29
fix tests for multiSelection - use preventKeyAction in getDropdownProps
JohnC-80 Jun 3, 2024
7255402
render proper empy list message in Selection
JohnC-80 Jun 3, 2024
e7faf16
remove toggle from custom control click handler
JohnC-80 Jun 4, 2024
00afb92
test multiselection onChange handler
JohnC-80 Jun 4, 2024
e223dfa
minor lint in OptionSegment, multiselection
JohnC-80 Jun 4, 2024
2e1dc12
Merge branch 'master' into STCOM-1091
JohnC-80 Jun 4, 2024
b68efd7
add tests for Selection option groups, indented style...
JohnC-80 Jun 4, 2024
f024aa2
Merge branch 'STCOM-1091' of https://github.com/folio-org/stripes-com…
JohnC-80 Jun 4, 2024
cc4bef8
add onChange tests for AutoSuggest
JohnC-80 Jun 4, 2024
c62993c
remove only, you goof
JohnC-80 Jun 4, 2024
419d9a8
Merge branch 'master' into STCOM-1091
JohnC-80 Jun 6, 2024
b3c5318
document/test option groups for Selection
JohnC-80 Jun 6, 2024
1a19fa1
Merge branch 'STCOM-1091' of https://github.com/folio-org/stripes-com…
JohnC-80 Jun 6, 2024
34624d2
add hook for generating an id or accepting a provided id
JohnC-80 Jun 11, 2024
4978600
ensure same value is returned in getHookExecutionResult
JohnC-80 Jun 11, 2024
5c7a4e0
fix incorrect aria-labelledby attribute in SelectionList, ensure elem…
JohnC-80 Jun 12, 2024
b56cae2
Multiselection - fix actions feature
JohnC-80 Jun 12, 2024
96b3c52
Selection - fix error message about SelectedItem becoming controlled
JohnC-80 Jun 12, 2024
741724d
remove unnecessary variable in SelectionOverlay
JohnC-80 Jun 12, 2024
3a065ae
resolve conflicts within MultiSeletion files
JohnC-80 Jun 12, 2024
0f183b1
fix problem with changing the value for AutoSuggest
JohnC-80 Jun 12, 2024
3971834
absorb changes from STCOM-1299 into new MultiSelect
JohnC-80 Jun 12, 2024
f066919
apply isDisabled to items, disabled to filter field
JohnC-80 Jun 12, 2024
d17c1cc
Merge branch 'master' into STCOM-1091
JohnC-80 Jun 12, 2024
5684b46
MultiSelection - clicking the control should open the menu, fix propT…
JohnC-80 Jun 13, 2024
35de047
skip legacy popover test
JohnC-80 Jun 13, 2024
fa5a8e9
remove renderLoading prop from MultiSelect Option List
JohnC-80 Jun 13, 2024
c984b55
log changes
JohnC-80 Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Add `dndProvided` prop to the `<MCLRenderer>` to render a placeholder for a draggable row. Refs STCOM-1297.
* Adjust styles for links within default `<MessageBanner>`. Refs STCOM-1276.
* Support Optimistic Locking in Tags - allow disable and show loading indicator in MultiSelect. Refs STCOM-1299.
* Update `downshift` dependency. Refactor `<Selection>`, `<MultiSelection>`, `<AutoSuggest>` to functional components. Refs STCOM-1091.
* Implement option grouping feature in `<Selection>`. Refs STCOM-1278.

## [12.1.0](https://github.com/folio-org/stripes-components/tree/v12.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-components/compare/v12.0.0...v12.1.0)
Expand Down
25 changes: 25 additions & 0 deletions hooks/tests/useProvidedIdOrCreate-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
describe,
it,
} from 'mocha';
import { expect } from 'chai';

import getHookExecutionResult from '../../tests/helpers/getHookExecutionResult';
import useProvidedIdOrCreate from '../useProvidedIdOrCreate';

describe('useProvidedIdOrCreate', () => {
it('should return the provided id', async () => {
const res = await getHookExecutionResult(useProvidedIdOrCreate, 'testId');
expect(res).to.equal('testId');
});

it('with no id parameter provided, it should return a generated id', async () => {
const res = await getHookExecutionResult(useProvidedIdOrCreate);
expect(res).to.not.equal('testId');
});

it('supplies generated id with prefix', async () => {
const res = await getHookExecutionResult(useProvidedIdOrCreate, [undefined, 'testPrefix-']);
expect(res).to.match(new RegExp('^testPrefix-'));
});
});
1 change: 1 addition & 0 deletions hooks/useProvidedIdOrCreate/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useProvidedIdOrCreate';
8 changes: 8 additions & 0 deletions hooks/useProvidedIdOrCreate/useProvidedIdOrCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useId, useRef } from 'react';

const useProvidedIdOrCreate = (id, prefix = '') => {
const autoId = `${prefix}${useId()}`;
return useRef(id || autoId).current;
};

export default useProvidedIdOrCreate;
1 change: 1 addition & 0 deletions hooks/useProvidedRefOrCreate/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useProvidedRefOrCreate';
12 changes: 12 additions & 0 deletions hooks/useProvidedRefOrCreate/useProvidedRefOrCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useRef } from "react";

/** useProvidedRefOrCreate
* There are some situations where we only want to create a new ref if one is not provided to a component as a prop.
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
*/
export default function useProvidedRefOrCreate(providedRef) {
const internalRef = useRef(null);
return providedRef ?
providedRef :
internalRef;
}
17 changes: 17 additions & 0 deletions lib/AutoSuggest/AutoSuggest.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@
display: 'inline-block';
position: 'relative';
}

.autoSuggestItem {
padding: 1rem;
cursor: default;
display: flex;
justify-content: space-between;
background-color: white;
font-weight: normal;

&.cursor {
background-color: var(--color-fill-hover);
}

&.selected {
font-weight: bold;
}
}
Loading
Loading