cozy-sharing 30.2.2 → 30.3.1
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.
- package/CHANGELOG.md +12 -0
- package/dist/components/ShareAutosuggest.js +19 -2
- package/dist/components/SharedDrive/helpers.js +2 -2
- package/dist/components/SharedDrive/helpers.spec.js +19 -0
- package/package.json +2 -2
- package/src/components/ShareAutosuggest.jsx +38 -22
- package/src/components/SharedDrive/helpers.js +2 -2
- package/src/components/SharedDrive/helpers.spec.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [30.3.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.3.0...cozy-sharing@30.3.1) (2026-04-24)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cozy-sharing:** Flatten contact name object in formatRecipients ([c804f59](https://github.com/cozy/cozy-libs/commit/c804f59d87d40cc8a6bfc5e96e88d88a13cbaadb))
|
|
11
|
+
|
|
12
|
+
# [30.3.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.2.2...cozy-sharing@30.3.0) (2026-04-23)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **cozy-sharing:** Auto-scroll highlighted suggestion into view ([8a367f7](https://github.com/cozy/cozy-libs/commit/8a367f73e36c9cce98cd492845faaf04ec4d1771))
|
|
17
|
+
|
|
6
18
|
## [30.2.2](https://github.com/cozy/cozy-libs/compare/cozy-sharing@30.2.1...cozy-sharing@30.2.2) (2026-04-22)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package cozy-sharing
|
|
@@ -53,6 +53,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
53
53
|
setLoadingDisplayed = _useState8[1];
|
|
54
54
|
|
|
55
55
|
var autosuggestRef = useRef(null);
|
|
56
|
+
var containerRef = useRef(null);
|
|
56
57
|
|
|
57
58
|
var computeSuggestions = function computeSuggestions(value) {
|
|
58
59
|
var inputValue = value.trim().toLowerCase();
|
|
@@ -151,6 +152,19 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
151
152
|
autosuggestRef === null || autosuggestRef === void 0 || (_autosuggestRef$curre2 = autosuggestRef.current) === null || _autosuggestRef$curre2 === void 0 || (_autosuggestRef$curre2 = _autosuggestRef$curre2.input) === null || _autosuggestRef$curre2 === void 0 || _autosuggestRef$curre2.focus();
|
|
152
153
|
};
|
|
153
154
|
|
|
155
|
+
var onSuggestionHighlighted = function onSuggestionHighlighted() {
|
|
156
|
+
requestAnimationFrame(function () {
|
|
157
|
+
if (!containerRef.current) return;
|
|
158
|
+
var highlighted = containerRef.current.querySelector('[aria-selected="true"]');
|
|
159
|
+
|
|
160
|
+
if (highlighted) {
|
|
161
|
+
highlighted.scrollIntoView({
|
|
162
|
+
block: 'nearest'
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
154
168
|
var renderInput = function renderInput(inputProps) {
|
|
155
169
|
return /*#__PURE__*/React.createElement("div", {
|
|
156
170
|
className: styles['recipientsContainer']
|
|
@@ -186,7 +200,9 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
186
200
|
});
|
|
187
201
|
};
|
|
188
202
|
|
|
189
|
-
return /*#__PURE__*/React.createElement(
|
|
203
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
ref: containerRef
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Autosuggest, {
|
|
190
206
|
ref: autosuggestRef,
|
|
191
207
|
theme: styles,
|
|
192
208
|
suggestions: suggestions.slice(0, 20),
|
|
@@ -195,6 +211,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
195
211
|
},
|
|
196
212
|
onSuggestionsFetchRequested: onSuggestionsFetchRequested,
|
|
197
213
|
onSuggestionsClearRequested: onSuggestionsClearRequested,
|
|
214
|
+
onSuggestionHighlighted: onSuggestionHighlighted,
|
|
198
215
|
renderSuggestion: renderSuggestion,
|
|
199
216
|
renderInputComponent: renderInput,
|
|
200
217
|
highlightFirstSuggestion: true,
|
|
@@ -209,7 +226,7 @@ var ShareAutocomplete = function ShareAutocomplete(_ref) {
|
|
|
209
226
|
className: styles['suggestionInput'],
|
|
210
227
|
disabled: disabled
|
|
211
228
|
}
|
|
212
|
-
});
|
|
229
|
+
}));
|
|
213
230
|
};
|
|
214
231
|
|
|
215
232
|
ShareAutocomplete.propTypes = {
|
|
@@ -68,7 +68,7 @@ export var formatRecipients = function formatRecipients(sharedDriveRecipients) {
|
|
|
68
68
|
recipients.push({
|
|
69
69
|
index: "".concat(RECIPIENT_INDEX_PREFIX).concat(r._id),
|
|
70
70
|
email: ContactModel.getPrimaryEmail(r),
|
|
71
|
-
public_name:
|
|
71
|
+
public_name: ContactModel.getDisplayName(r),
|
|
72
72
|
memberIndex: r._id,
|
|
73
73
|
type: 'two-way',
|
|
74
74
|
members: r.members
|
|
@@ -78,7 +78,7 @@ export var formatRecipients = function formatRecipients(sharedDriveRecipients) {
|
|
|
78
78
|
recipients.push({
|
|
79
79
|
index: "".concat(RECIPIENT_INDEX_PREFIX).concat(r._id),
|
|
80
80
|
email: ContactModel.getPrimaryEmail(r),
|
|
81
|
-
public_name:
|
|
81
|
+
public_name: ContactModel.getDisplayName(r),
|
|
82
82
|
memberIndex: r._id,
|
|
83
83
|
type: 'one-way',
|
|
84
84
|
members: r.members
|
|
@@ -182,6 +182,25 @@ describe('formatRecipients', function () {
|
|
|
182
182
|
public_name: 'Bob'
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
|
+
it('should flatten an object-shaped contact name into a string public_name', function () {
|
|
186
|
+
var input = {
|
|
187
|
+
recipients: [{
|
|
188
|
+
_id: '3',
|
|
189
|
+
name: {
|
|
190
|
+
givenName: 'Arya',
|
|
191
|
+
familyName: 'Stark'
|
|
192
|
+
},
|
|
193
|
+
email: [{
|
|
194
|
+
address: 'arya@example.com',
|
|
195
|
+
primary: true
|
|
196
|
+
}]
|
|
197
|
+
}],
|
|
198
|
+
readOnlyRecipients: []
|
|
199
|
+
};
|
|
200
|
+
var result = formatRecipients(input);
|
|
201
|
+
expect(typeof result[0].public_name).toBe('string');
|
|
202
|
+
expect(result[0].public_name).toBe('Arya Stark');
|
|
203
|
+
});
|
|
185
204
|
it('should sort recipients by public_name', function () {
|
|
186
205
|
var input = {
|
|
187
206
|
recipients: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.3.1",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"sideEffects": [
|
|
85
85
|
"*.css"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "8248557488c88af8242923be0f395fb252a57883"
|
|
88
88
|
}
|
|
@@ -33,6 +33,7 @@ const ShareAutocomplete = ({
|
|
|
33
33
|
const [isLoadingDisplayed, setLoadingDisplayed] = useState(false)
|
|
34
34
|
|
|
35
35
|
const autosuggestRef = useRef(null)
|
|
36
|
+
const containerRef = useRef(null)
|
|
36
37
|
|
|
37
38
|
const computeSuggestions = value => {
|
|
38
39
|
const inputValue = value.trim().toLowerCase()
|
|
@@ -138,6 +139,18 @@ const ShareAutocomplete = ({
|
|
|
138
139
|
autosuggestRef?.current?.input?.focus()
|
|
139
140
|
}
|
|
140
141
|
|
|
142
|
+
const onSuggestionHighlighted = () => {
|
|
143
|
+
requestAnimationFrame(() => {
|
|
144
|
+
if (!containerRef.current) return
|
|
145
|
+
const highlighted = containerRef.current.querySelector(
|
|
146
|
+
'[aria-selected="true"]'
|
|
147
|
+
)
|
|
148
|
+
if (highlighted) {
|
|
149
|
+
highlighted.scrollIntoView({ block: 'nearest' })
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
141
154
|
const renderInput = inputProps => (
|
|
142
155
|
<div className={styles['recipientsContainer']}>
|
|
143
156
|
{recipients.map((recipient, idx) => {
|
|
@@ -175,28 +188,31 @@ const ShareAutocomplete = ({
|
|
|
175
188
|
)
|
|
176
189
|
|
|
177
190
|
return (
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
<div ref={containerRef}>
|
|
192
|
+
<Autosuggest
|
|
193
|
+
ref={autosuggestRef}
|
|
194
|
+
theme={styles}
|
|
195
|
+
suggestions={suggestions.slice(0, 20)}
|
|
196
|
+
getSuggestionValue={contact => contact}
|
|
197
|
+
onSuggestionsFetchRequested={onSuggestionsFetchRequested}
|
|
198
|
+
onSuggestionsClearRequested={onSuggestionsClearRequested}
|
|
199
|
+
onSuggestionHighlighted={onSuggestionHighlighted}
|
|
200
|
+
renderSuggestion={renderSuggestion}
|
|
201
|
+
renderInputComponent={renderInput}
|
|
202
|
+
highlightFirstSuggestion
|
|
203
|
+
inputProps={{
|
|
204
|
+
onFocus: onAutosuggestFocus,
|
|
205
|
+
onChange: onAutosuggestChange,
|
|
206
|
+
onPaste: onAutosuggestPaste,
|
|
207
|
+
onBlur: onAutosuggestBlur,
|
|
208
|
+
value: inputValue,
|
|
209
|
+
type: 'email',
|
|
210
|
+
placeholder,
|
|
211
|
+
className: styles['suggestionInput'],
|
|
212
|
+
disabled
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
200
216
|
)
|
|
201
217
|
}
|
|
202
218
|
|
|
@@ -73,7 +73,7 @@ export const formatRecipients = sharedDriveRecipients => {
|
|
|
73
73
|
recipients.push({
|
|
74
74
|
index: `${RECIPIENT_INDEX_PREFIX}${r._id}`,
|
|
75
75
|
email: ContactModel.getPrimaryEmail(r),
|
|
76
|
-
public_name:
|
|
76
|
+
public_name: ContactModel.getDisplayName(r),
|
|
77
77
|
memberIndex: r._id,
|
|
78
78
|
type: 'two-way',
|
|
79
79
|
members: r.members
|
|
@@ -84,7 +84,7 @@ export const formatRecipients = sharedDriveRecipients => {
|
|
|
84
84
|
recipients.push({
|
|
85
85
|
index: `${RECIPIENT_INDEX_PREFIX}${r._id}`,
|
|
86
86
|
email: ContactModel.getPrimaryEmail(r),
|
|
87
|
-
public_name:
|
|
87
|
+
public_name: ContactModel.getDisplayName(r),
|
|
88
88
|
memberIndex: r._id,
|
|
89
89
|
type: 'one-way',
|
|
90
90
|
members: r.members
|
|
@@ -138,6 +138,22 @@ describe('formatRecipients', () => {
|
|
|
138
138
|
})
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
+
it('should flatten an object-shaped contact name into a string public_name', () => {
|
|
142
|
+
const input = {
|
|
143
|
+
recipients: [
|
|
144
|
+
{
|
|
145
|
+
_id: '3',
|
|
146
|
+
name: { givenName: 'Arya', familyName: 'Stark' },
|
|
147
|
+
email: [{ address: 'arya@example.com', primary: true }]
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
readOnlyRecipients: []
|
|
151
|
+
}
|
|
152
|
+
const result = formatRecipients(input)
|
|
153
|
+
expect(typeof result[0].public_name).toBe('string')
|
|
154
|
+
expect(result[0].public_name).toBe('Arya Stark')
|
|
155
|
+
})
|
|
156
|
+
|
|
141
157
|
it('should sort recipients by public_name', () => {
|
|
142
158
|
const input = {
|
|
143
159
|
recipients: [
|