box-ui-elements 17.1.0 → 17.2.0-beta.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/dist/explorer.css +1 -1
- package/dist/explorer.js +2 -2
- package/dist/picker.css +1 -1
- package/dist/preview.js +2 -2
- package/dist/sharing.js +3 -3
- package/dist/sidebar.js +2 -2
- package/es/components/pill-selector-dropdown/PillSelector.js +6 -6
- package/es/components/pill-selector-dropdown/PillSelector.js.flow +9 -5
- package/es/components/pill-selector-dropdown/PillSelector.js.map +1 -1
- package/es/components/pill-selector-dropdown/PillSelectorDropdown.js +3 -1
- package/es/components/pill-selector-dropdown/PillSelectorDropdown.js.flow +6 -1
- package/es/components/pill-selector-dropdown/PillSelectorDropdown.js.map +1 -1
- package/es/elements/common/sub-header/ViewModeChangeButton.scss +1 -1
- package/es/features/unified-share-modal/ContactsField.js +1 -0
- package/es/features/unified-share-modal/ContactsField.js.flow +1 -0
- package/es/features/unified-share-modal/ContactsField.js.map +1 -1
- package/package.json +1 -1
- package/src/components/pill-selector-dropdown/PillSelector.js +9 -5
- package/src/components/pill-selector-dropdown/PillSelectorDropdown.js +6 -1
- package/src/elements/common/sub-header/ViewModeChangeButton.scss +1 -1
- package/src/features/unified-share-modal/ContactsField.js +1 -0
- package/src/features/unified-share-modal/__tests__/__snapshots__/ContactsField.test.js.snap +2 -0
|
@@ -207,6 +207,7 @@ function (_React$Component) {
|
|
|
207
207
|
className = _this$props2.className,
|
|
208
208
|
disabled = _this$props2.disabled,
|
|
209
209
|
error = _this$props2.error,
|
|
210
|
+
errorTooltipPosition = _this$props2.errorTooltipPosition,
|
|
210
211
|
getPillClassName = _this$props2.getPillClassName,
|
|
211
212
|
getPillImageUrl = _this$props2.getPillImageUrl,
|
|
212
213
|
inputProps = _this$props2.inputProps,
|
|
@@ -222,7 +223,7 @@ function (_React$Component) {
|
|
|
222
223
|
suggestedPillsFilter = _this$props2.suggestedPillsFilter,
|
|
223
224
|
suggestedPillsTitle = _this$props2.suggestedPillsTitle,
|
|
224
225
|
validator = _this$props2.validator,
|
|
225
|
-
rest = _objectWithoutProperties(_this$props2, ["allowInvalidPills", "className", "disabled", "error", "getPillClassName", "getPillImageUrl", "inputProps", "onInput", "onRemove", "onSuggestedPillAdd", "placeholder", "innerRef", "selectedOptions", "showAvatars", "showRoundedPills", "suggestedPillsData", "suggestedPillsFilter", "suggestedPillsTitle", "validator"]);
|
|
226
|
+
rest = _objectWithoutProperties(_this$props2, ["allowInvalidPills", "className", "disabled", "error", "errorTooltipPosition", "getPillClassName", "getPillImageUrl", "inputProps", "onInput", "onRemove", "onSuggestedPillAdd", "placeholder", "innerRef", "selectedOptions", "showAvatars", "showRoundedPills", "suggestedPillsData", "suggestedPillsFilter", "suggestedPillsTitle", "validator"]);
|
|
226
227
|
|
|
227
228
|
var suggestedPillsEnabled = suggestedPillsData && suggestedPillsData.length > 0;
|
|
228
229
|
var hasError = !!error;
|
|
@@ -242,7 +243,7 @@ function (_React$Component) {
|
|
|
242
243
|
return React.createElement(Tooltip, {
|
|
243
244
|
isShown: hasError,
|
|
244
245
|
text: error || '',
|
|
245
|
-
position:
|
|
246
|
+
position: errorTooltipPosition,
|
|
246
247
|
theme: "error"
|
|
247
248
|
}, React.createElement("span", {
|
|
248
249
|
className: classes,
|
|
@@ -262,7 +263,7 @@ function (_React$Component) {
|
|
|
262
263
|
onRemove: onRemove.bind(_this2, option, index) // $FlowFixMe option.text is for backwards compatibility
|
|
263
264
|
,
|
|
264
265
|
text: option.displayText || option.text,
|
|
265
|
-
showAvatar:
|
|
266
|
+
showAvatar: showAvatars,
|
|
266
267
|
id: option.id,
|
|
267
268
|
hasWarning: option.hasWarning,
|
|
268
269
|
isExternal: option.isExternalUser
|
|
@@ -287,9 +288,7 @@ function (_React$Component) {
|
|
|
287
288
|
"data-testid": "pill-selection-helper"
|
|
288
289
|
}), React.createElement("textarea", _extends({}, ariaAttrs, rest, inputProps, {
|
|
289
290
|
autoComplete: "off",
|
|
290
|
-
className: classNames('bdl-PillSelector-input', 'pill-selector-input', className,
|
|
291
|
-
'bdl-PillSelector-input--showAvatars': showAvatars
|
|
292
|
-
}),
|
|
291
|
+
className: classNames('bdl-PillSelector-input', 'pill-selector-input', className),
|
|
293
292
|
disabled: disabled,
|
|
294
293
|
onInput: onInput,
|
|
295
294
|
placeholder: this.getNumSelected() === 0 ? placeholder : '',
|
|
@@ -317,6 +316,7 @@ _defineProperty(PillSelectorBase, "defaultProps", {
|
|
|
317
316
|
allowInvalidPills: false,
|
|
318
317
|
disabled: false,
|
|
319
318
|
error: '',
|
|
319
|
+
errorTooltipPosition: 'bottom-left',
|
|
320
320
|
inputProps: {},
|
|
321
321
|
placeholder: '',
|
|
322
322
|
selectedOptions: [],
|
|
@@ -11,6 +11,7 @@ import RoundPill from './RoundPill';
|
|
|
11
11
|
import Pill from './Pill';
|
|
12
12
|
import SuggestedPillsRow from './SuggestedPillsRow';
|
|
13
13
|
import type { RoundOption, Option, OptionValue, SuggestedPillsFilter } from './flowTypes';
|
|
14
|
+
import type { Position } from '../tooltip';
|
|
14
15
|
|
|
15
16
|
function stopDefaultEvent(event) {
|
|
16
17
|
event.preventDefault();
|
|
@@ -22,6 +23,8 @@ type Props = {
|
|
|
22
23
|
className?: string,
|
|
23
24
|
disabled?: boolean,
|
|
24
25
|
error?: React.Node,
|
|
26
|
+
/** Position of error message tooltip */
|
|
27
|
+
errorTooltipPosition?: Position,
|
|
25
28
|
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
|
|
26
29
|
getPillClassName?: (option: Option) => string,
|
|
27
30
|
/** Function to retrieve the image URL associated with a pill */
|
|
@@ -52,6 +55,7 @@ type DefaultProps = {
|
|
|
52
55
|
allowInvalidPills: boolean,
|
|
53
56
|
disabled: boolean,
|
|
54
57
|
error: string,
|
|
58
|
+
errorTooltipPosition: Position,
|
|
55
59
|
inputProps: Object,
|
|
56
60
|
placeholder: string,
|
|
57
61
|
selectedOptions: List<Object>,
|
|
@@ -65,6 +69,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
65
69
|
allowInvalidPills: false,
|
|
66
70
|
disabled: false,
|
|
67
71
|
error: '',
|
|
72
|
+
errorTooltipPosition: 'bottom-left',
|
|
68
73
|
inputProps: {},
|
|
69
74
|
placeholder: '',
|
|
70
75
|
selectedOptions: [],
|
|
@@ -185,6 +190,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
185
190
|
className,
|
|
186
191
|
disabled,
|
|
187
192
|
error,
|
|
193
|
+
errorTooltipPosition,
|
|
188
194
|
getPillClassName,
|
|
189
195
|
getPillImageUrl,
|
|
190
196
|
inputProps,
|
|
@@ -219,7 +225,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
219
225
|
};
|
|
220
226
|
|
|
221
227
|
return (
|
|
222
|
-
<Tooltip isShown={hasError} text={error || ''} position=
|
|
228
|
+
<Tooltip isShown={hasError} text={error || ''} position={errorTooltipPosition} theme="error">
|
|
223
229
|
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
|
|
224
230
|
<span
|
|
225
231
|
className={classes}
|
|
@@ -242,7 +248,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
242
248
|
onRemove={onRemove.bind(this, option, index)}
|
|
243
249
|
// $FlowFixMe option.text is for backwards compatibility
|
|
244
250
|
text={option.displayText || option.text}
|
|
245
|
-
showAvatar
|
|
251
|
+
showAvatar={showAvatars}
|
|
246
252
|
id={option.id}
|
|
247
253
|
hasWarning={option.hasWarning}
|
|
248
254
|
isExternal={option.isExternalUser}
|
|
@@ -278,9 +284,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
278
284
|
{...rest}
|
|
279
285
|
{...inputProps}
|
|
280
286
|
autoComplete="off"
|
|
281
|
-
className={classNames('bdl-PillSelector-input', 'pill-selector-input', className
|
|
282
|
-
'bdl-PillSelector-input--showAvatars': showAvatars,
|
|
283
|
-
})}
|
|
287
|
+
className={classNames('bdl-PillSelector-input', 'pill-selector-input', className)}
|
|
284
288
|
disabled={disabled}
|
|
285
289
|
onInput={onInput}
|
|
286
290
|
placeholder={this.getNumSelected() === 0 ? placeholder : ''}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/pill-selector-dropdown/PillSelector.js"],"names":["React","classNames","uniqueId","List","Tooltip","KEYS","RoundPill","Pill","SuggestedPillsRow","stopDefaultEvent","event","preventDefault","stopPropagation","PillSelectorBase","isFocused","selectedIndex","selectedOptions","props","size","length","key","map","option","inputEl","focus","setState","inputValue","value","numPills","getNumSelected","state","backspace","index","resetSelectedIndex","onRemove","selectedOption","get","arrowLeft","Math","max","hiddenEl","arrowRight","allowInvalidPills","className","disabled","error","getPillClassName","getPillImageUrl","inputProps","onInput","onSuggestedPillAdd","placeholder","innerRef","showAvatars","showRoundedPills","suggestedPillsData","suggestedPillsFilter","suggestedPillsTitle","validator","rest","suggestedPillsEnabled","hasError","classes","ariaAttrs","errorMessageID","handleBlur","handleClick","handleFocus","handleKeyDown","undefined","bind","displayText","text","id","hasWarning","isExternalUser","hiddenRef","input","getPillsByKey","Component","PillSelector","forwardRef","ref","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,IAAT,QAAqB,WAArB;AAEA,OAAOC,OAAP,MAAoB,YAApB;AACA,SAASC,IAAT,QAAqB,iBAArB;AAEA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;;AAGA,SAASC,gBAAT,CAA0BC,KAA1B,EAAiC;AAC7BA,EAAAA,KAAK,CAACC,cAAN;AACAD,EAAAA,KAAK,CAACE,eAAN;AACH;;IA6CKC,gB;;;;;;;;;;;;;;;;;;4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;AAAA,CAA1C,CAArB;AAGAF,YAAY,CAACG,WAAb,GAA2B,cAA3B;AAEA,eAAeH,YAAf","sourcesContent":["// @flow\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport uniqueId from 'lodash/uniqueId';\nimport { List } from 'immutable';\n\nimport Tooltip from '../tooltip';\nimport { KEYS } from '../../constants';\n\nimport RoundPill from './RoundPill';\nimport Pill from './Pill';\nimport SuggestedPillsRow from './SuggestedPillsRow';\nimport type { RoundOption, Option, OptionValue, SuggestedPillsFilter } from './flowTypes';\n\nfunction stopDefaultEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n\ntype Props = {\n allowInvalidPills: boolean,\n className?: string,\n disabled?: boolean,\n error?: React.Node,\n /** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */\n getPillClassName?: (option: Option) => string,\n /** Function to retrieve the image URL associated with a pill */\n getPillImageUrl?: (data: { id: string | number, [key: string]: any }) => string,\n innerRef?: React.Ref<any>,\n inputProps: Object,\n onInput: Function,\n onRemove: Function,\n onSuggestedPillAdd?: Function,\n placeholder: string,\n selectedOptions: List<Object>,\n /** Whether to show avatars in pills (if rounded style is enabled) */\n showAvatars?: boolean,\n /** Whether to use rounded style for pills */\n showRoundedPills?: boolean,\n suggestedPillsData?: Array<Object>,\n suggestedPillsFilter?: SuggestedPillsFilter,\n suggestedPillsTitle?: string,\n validator: (option: Option | OptionValue) => boolean,\n};\n\ntype State = {\n isFocused: boolean,\n selectedIndex: number,\n};\n\ntype DefaultProps = {\n allowInvalidPills: boolean,\n disabled: boolean,\n error: string,\n inputProps: Object,\n placeholder: string,\n selectedOptions: List<Object>,\n validator: () => boolean,\n};\n\ntype Config = React.Config<Props, DefaultProps>;\n\nclass PillSelectorBase extends React.Component<Props, State> {\n static defaultProps: DefaultProps = {\n allowInvalidPills: false,\n disabled: false,\n error: '',\n inputProps: {},\n placeholder: '',\n selectedOptions: [],\n validator: () => true,\n };\n\n state = {\n isFocused: false,\n selectedIndex: -1,\n };\n\n getNumSelected = (): number => {\n const { selectedOptions } = this.props;\n\n return typeof selectedOptions.size === 'number' ? selectedOptions.size : selectedOptions.length;\n };\n\n getPillsByKey = (key: string): Array<any> => {\n const { selectedOptions } = this.props;\n\n return selectedOptions.map(option => option[key]);\n };\n\n inputEl: HTMLInputElement;\n\n handleClick = () => {\n this.inputEl.focus();\n };\n\n handleFocus = () => {\n this.setState({ isFocused: true });\n };\n\n handleBlur = () => {\n this.setState({ isFocused: false });\n };\n\n hiddenEl: HTMLSpanElement;\n\n handleKeyDown = (event: SyntheticKeyboardEvent<>) => {\n const inputValue = this.inputEl.value;\n const numPills = this.getNumSelected();\n const { selectedIndex } = this.state;\n\n switch (event.key) {\n case KEYS.backspace: {\n let index = -1;\n if (selectedIndex >= 0) {\n // remove selected pill\n index = selectedIndex;\n this.resetSelectedIndex();\n this.inputEl.focus();\n } else if (inputValue === '') {\n // remove last pill\n index = numPills - 1;\n }\n if (index >= 0) {\n const { onRemove, selectedOptions } = this.props;\n const selectedOption =\n // $FlowFixMe\n typeof selectedOptions.get === 'function' ? selectedOptions.get(index) : selectedOptions[index];\n onRemove(selectedOption, index);\n stopDefaultEvent(event);\n }\n break;\n }\n case KEYS.arrowLeft:\n if (selectedIndex >= 0) {\n // select previous pill\n this.setState({\n selectedIndex: Math.max(selectedIndex - 1, 0),\n });\n stopDefaultEvent(event);\n } else if (inputValue === '' && numPills > 0) {\n // select last pill\n this.hiddenEl.focus();\n this.setState({ selectedIndex: numPills - 1 });\n stopDefaultEvent(event);\n }\n break;\n case KEYS.arrowRight: {\n if (selectedIndex >= 0) {\n const index = selectedIndex + 1;\n if (index >= numPills) {\n // deselect last pill\n this.resetSelectedIndex();\n this.inputEl.focus();\n } else {\n // select next pill\n this.setState({ selectedIndex: index });\n }\n stopDefaultEvent(event);\n }\n break;\n }\n // no default\n }\n };\n\n errorMessageID = uniqueId('errorMessage');\n\n hiddenRef = (hiddenEl: ?HTMLSpanElement) => {\n if (hiddenEl) {\n this.hiddenEl = hiddenEl;\n }\n };\n\n resetSelectedIndex = () => {\n if (this.state.selectedIndex !== -1) {\n this.setState({ selectedIndex: -1 });\n }\n };\n\n render() {\n const { isFocused, selectedIndex } = this.state;\n const {\n allowInvalidPills,\n className,\n disabled,\n error,\n getPillClassName,\n getPillImageUrl,\n inputProps,\n onInput,\n onRemove,\n onSuggestedPillAdd,\n placeholder,\n innerRef,\n selectedOptions,\n showAvatars,\n showRoundedPills,\n suggestedPillsData,\n suggestedPillsFilter,\n suggestedPillsTitle,\n validator,\n ...rest\n } = this.props;\n const suggestedPillsEnabled = suggestedPillsData && suggestedPillsData.length > 0;\n const hasError = !!error;\n const classes = classNames('bdl-PillSelector', 'pill-selector-input-wrapper', {\n 'is-disabled': disabled,\n 'bdl-is-disabled': disabled,\n 'is-focused': isFocused,\n 'show-error': hasError,\n 'pill-selector-suggestions-enabled': suggestedPillsEnabled,\n 'bdl-PillSelector--suggestionsEnabled': suggestedPillsEnabled,\n });\n const ariaAttrs = {\n 'aria-invalid': hasError,\n 'aria-errormessage': this.errorMessageID,\n 'aria-describedby': this.errorMessageID,\n };\n\n return (\n <Tooltip isShown={hasError} text={error || ''} position=\"bottom-left\" theme=\"error\">\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <span\n className={classes}\n onBlur={this.handleBlur}\n onClick={this.handleClick}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n ref={innerRef}\n >\n {showRoundedPills\n ? selectedOptions.map((option: RoundOption, index: number) => {\n return (\n <RoundPill\n className={getPillClassName ? getPillClassName(option) : undefined}\n getPillImageUrl={getPillImageUrl}\n isValid={allowInvalidPills ? validator(option) : true}\n isDisabled={disabled}\n isSelected={index === selectedIndex}\n key={option.value}\n onRemove={onRemove.bind(this, option, index)}\n // $FlowFixMe option.text is for backwards compatibility\n text={option.displayText || option.text}\n showAvatar\n id={option.id}\n hasWarning={option.hasWarning}\n isExternal={option.isExternalUser}\n />\n );\n })\n : selectedOptions.map((option: Option, index: number) => {\n // TODO: This and associated types will be removed once all views are updates with round pills.\n return (\n <Pill\n isValid={allowInvalidPills ? validator(option) : true}\n isDisabled={disabled}\n isSelected={index === selectedIndex}\n key={option.value}\n onRemove={onRemove.bind(this, option, index)}\n // $FlowFixMe option.text is for backwards compatibility\n text={option.displayText || option.text}\n />\n );\n })}\n\n {/* hidden element for focus/key events during pill selection */}\n <span\n aria-hidden=\"true\"\n className=\"accessibility-hidden\"\n onBlur={this.resetSelectedIndex}\n ref={this.hiddenRef}\n tabIndex={-1}\n data-testid=\"pill-selection-helper\"\n />\n <textarea\n {...ariaAttrs}\n {...rest}\n {...inputProps}\n autoComplete=\"off\"\n className={classNames('bdl-PillSelector-input', 'pill-selector-input', className, {\n 'bdl-PillSelector-input--showAvatars': showAvatars,\n })}\n disabled={disabled}\n onInput={onInput}\n placeholder={this.getNumSelected() === 0 ? placeholder : ''}\n ref={input => {\n this.inputEl = input;\n }}\n />\n <SuggestedPillsRow\n onSuggestedPillAdd={onSuggestedPillAdd}\n selectedPillsValues={this.getPillsByKey('value')}\n suggestedPillsFilter={suggestedPillsFilter}\n suggestedPillsData={suggestedPillsData}\n title={suggestedPillsTitle}\n />\n <span id={this.errorMessageID} className=\"accessibility-hidden\" role=\"alert\">\n {error}\n </span>\n </span>\n </Tooltip>\n );\n }\n}\n\nexport { PillSelectorBase };\n\nconst PillSelector = React.forwardRef<Config, HTMLSpanElement>((props: Config, ref: React.Ref<any>) => (\n <PillSelectorBase {...props} innerRef={ref} />\n));\nPillSelector.displayName = 'PillSelector';\n\nexport default PillSelector;\n"],"file":"PillSelector.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/pill-selector-dropdown/PillSelector.js"],"names":["React","classNames","uniqueId","List","Tooltip","KEYS","RoundPill","Pill","SuggestedPillsRow","stopDefaultEvent","event","preventDefault","stopPropagation","PillSelectorBase","isFocused","selectedIndex","selectedOptions","props","size","length","key","map","option","inputEl","focus","setState","inputValue","value","numPills","getNumSelected","state","backspace","index","resetSelectedIndex","onRemove","selectedOption","get","arrowLeft","Math","max","hiddenEl","arrowRight","allowInvalidPills","className","disabled","error","errorTooltipPosition","getPillClassName","getPillImageUrl","inputProps","onInput","onSuggestedPillAdd","placeholder","innerRef","showAvatars","showRoundedPills","suggestedPillsData","suggestedPillsFilter","suggestedPillsTitle","validator","rest","suggestedPillsEnabled","hasError","classes","ariaAttrs","errorMessageID","handleBlur","handleClick","handleFocus","handleKeyDown","undefined","bind","displayText","text","id","hasWarning","isExternalUser","hiddenRef","input","getPillsByKey","Component","PillSelector","forwardRef","ref","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,IAAT,QAAqB,WAArB;AAEA,OAAOC,OAAP,MAAoB,YAApB;AACA,SAASC,IAAT,QAAqB,iBAArB;AAEA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;;AAIA,SAASC,gBAAT,CAA0BC,KAA1B,EAAiC;AAC7BA,EAAAA,KAAK,CAACC,cAAN;AACAD,EAAAA,KAAK,CAACE,eAAN;AACH;;IAgDKC,gB;;;;;;;;;;;;;;;;;;4DAYM;AACJC,MAAAA,SAAS,EAAE,KADP;AAEJC,MAAAA,aAAa,EAAE,CAAC;AAFZ,K;;qEAKS,YAAc;AAAA,UACnBC,eADmB,GACC,MAAKC,KADN,CACnBD,eADmB;AAG3B,aAAO,OAAOA,eAAe,CAACE,IAAvB,KAAgC,QAAhC,GAA2CF,eAAe,CAACE,IAA3D,GAAkEF,eAAe,CAACG,MAAzF;AACH,K;;oEAEe,UAACC,GAAD,EAA6B;AAAA,UACjCJ,eADiC,GACb,MAAKC,KADQ,CACjCD,eADiC;AAGzC,aAAOA,eAAe,CAACK,GAA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AD;AACI,QAAA,kBAAkB,EAAE3B,kBADxB;AAEI,QAAA,mBAAmB,EAAE,KAAK4B,aAAL,CAAmB,OAAnB,CAFzB;AAGI,QAAA,oBAAoB,EAAEtB,oBAH1B;AAII,QAAA,kBAAkB,EAAED,kBAJxB;AAKI,QAAA,KAAK,EAAEE;AALX,QAjEJ,EAwEI;AAAM,QAAA,EAAE,EAAE,KAAKO,cAAf;AAA+B,QAAA,SAAS,EAAC,sBAAzC;AAAgE,QAAA,IAAI,EAAC;AAArE,SACKpB,KADL,CAxEJ,CAFJ,CADJ;AAiFH;;;;EAjP0B7C,KAAK,CAACgF,S;;gBAA/BnE,gB,kBACkC;AAChC6B,EAAAA,iBAAiB,EAAE,KADa;AAEhCE,EAAAA,QAAQ,EAAE,KAFsB;AAGhCC,EAAAA,KAAK,EAAE,EAHyB;AAIhCC,EAAAA,oBAAoB,EAAE,aAJU;AAKhCG,EAAAA,UAAU,EAAE,EALoB;AAMhCG,EAAAA,WAAW,EAAE,EANmB;AAOhCpC,EAAAA,eAAe,EAAE,EAPe;AAQhC2C,EAAAA,SAAS,EAAE;AAAA,WAAM,IAAN;AAAA;AARqB,C;;AAmPxC,SAAS9C,gBAAT;AAEA,IAAMoE,YAAY,GAAGjF,KAAK,CAACkF,UAAN,CAA0C,UAACjE,KAAD,EAAgBkE,GAAhB;AAAA,SAC3D,oBAAC,gBAAD,eAAsBlE,KAAtB;AAA6B,IAAA,QAAQ,EAAEkE;AAAvC,KAD2D;AAAA,CAA1C,CAArB;AAGAF,YAAY,CAACG,WAAb,GAA2B,cAA3B;AAEA,eAAeH,YAAf","sourcesContent":["// @flow\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport uniqueId from 'lodash/uniqueId';\nimport { List } from 'immutable';\n\nimport Tooltip from '../tooltip';\nimport { KEYS } from '../../constants';\n\nimport RoundPill from './RoundPill';\nimport Pill from './Pill';\nimport SuggestedPillsRow from './SuggestedPillsRow';\nimport type { RoundOption, Option, OptionValue, SuggestedPillsFilter } from './flowTypes';\nimport type { Position } from '../tooltip';\n\nfunction stopDefaultEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n\ntype Props = {\n allowInvalidPills: boolean,\n className?: string,\n disabled?: boolean,\n error?: React.Node,\n /** Position of error message tooltip */\n errorTooltipPosition?: Position,\n /** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */\n getPillClassName?: (option: Option) => string,\n /** Function to retrieve the image URL associated with a pill */\n getPillImageUrl?: (data: { id: string | number, [key: string]: any }) => string,\n innerRef?: React.Ref<any>,\n inputProps: Object,\n onInput: Function,\n onRemove: Function,\n onSuggestedPillAdd?: Function,\n placeholder: string,\n selectedOptions: List<Object>,\n /** Whether to show avatars in pills (if rounded style is enabled) */\n showAvatars?: boolean,\n /** Whether to use rounded style for pills */\n showRoundedPills?: boolean,\n suggestedPillsData?: Array<Object>,\n suggestedPillsFilter?: SuggestedPillsFilter,\n suggestedPillsTitle?: string,\n validator: (option: Option | OptionValue) => boolean,\n};\n\ntype State = {\n isFocused: boolean,\n selectedIndex: number,\n};\n\ntype DefaultProps = {\n allowInvalidPills: boolean,\n disabled: boolean,\n error: string,\n errorTooltipPosition: Position,\n inputProps: Object,\n placeholder: string,\n selectedOptions: List<Object>,\n validator: () => boolean,\n};\n\ntype Config = React.Config<Props, DefaultProps>;\n\nclass PillSelectorBase extends React.Component<Props, State> {\n static defaultProps: DefaultProps = {\n allowInvalidPills: false,\n disabled: false,\n error: '',\n errorTooltipPosition: 'bottom-left',\n inputProps: {},\n placeholder: '',\n selectedOptions: [],\n validator: () => true,\n };\n\n state = {\n isFocused: false,\n selectedIndex: -1,\n };\n\n getNumSelected = (): number => {\n const { selectedOptions } = this.props;\n\n return typeof selectedOptions.size === 'number' ? selectedOptions.size : selectedOptions.length;\n };\n\n getPillsByKey = (key: string): Array<any> => {\n const { selectedOptions } = this.props;\n\n return selectedOptions.map(option => option[key]);\n };\n\n inputEl: HTMLInputElement;\n\n handleClick = () => {\n this.inputEl.focus();\n };\n\n handleFocus = () => {\n this.setState({ isFocused: true });\n };\n\n handleBlur = () => {\n this.setState({ isFocused: false });\n };\n\n hiddenEl: HTMLSpanElement;\n\n handleKeyDown = (event: SyntheticKeyboardEvent<>) => {\n const inputValue = this.inputEl.value;\n const numPills = this.getNumSelected();\n const { selectedIndex } = this.state;\n\n switch (event.key) {\n case KEYS.backspace: {\n let index = -1;\n if (selectedIndex >= 0) {\n // remove selected pill\n index = selectedIndex;\n this.resetSelectedIndex();\n this.inputEl.focus();\n } else if (inputValue === '') {\n // remove last pill\n index = numPills - 1;\n }\n if (index >= 0) {\n const { onRemove, selectedOptions } = this.props;\n const selectedOption =\n // $FlowFixMe\n typeof selectedOptions.get === 'function' ? selectedOptions.get(index) : selectedOptions[index];\n onRemove(selectedOption, index);\n stopDefaultEvent(event);\n }\n break;\n }\n case KEYS.arrowLeft:\n if (selectedIndex >= 0) {\n // select previous pill\n this.setState({\n selectedIndex: Math.max(selectedIndex - 1, 0),\n });\n stopDefaultEvent(event);\n } else if (inputValue === '' && numPills > 0) {\n // select last pill\n this.hiddenEl.focus();\n this.setState({ selectedIndex: numPills - 1 });\n stopDefaultEvent(event);\n }\n break;\n case KEYS.arrowRight: {\n if (selectedIndex >= 0) {\n const index = selectedIndex + 1;\n if (index >= numPills) {\n // deselect last pill\n this.resetSelectedIndex();\n this.inputEl.focus();\n } else {\n // select next pill\n this.setState({ selectedIndex: index });\n }\n stopDefaultEvent(event);\n }\n break;\n }\n // no default\n }\n };\n\n errorMessageID = uniqueId('errorMessage');\n\n hiddenRef = (hiddenEl: ?HTMLSpanElement) => {\n if (hiddenEl) {\n this.hiddenEl = hiddenEl;\n }\n };\n\n resetSelectedIndex = () => {\n if (this.state.selectedIndex !== -1) {\n this.setState({ selectedIndex: -1 });\n }\n };\n\n render() {\n const { isFocused, selectedIndex } = this.state;\n const {\n allowInvalidPills,\n className,\n disabled,\n error,\n errorTooltipPosition,\n getPillClassName,\n getPillImageUrl,\n inputProps,\n onInput,\n onRemove,\n onSuggestedPillAdd,\n placeholder,\n innerRef,\n selectedOptions,\n showAvatars,\n showRoundedPills,\n suggestedPillsData,\n suggestedPillsFilter,\n suggestedPillsTitle,\n validator,\n ...rest\n } = this.props;\n const suggestedPillsEnabled = suggestedPillsData && suggestedPillsData.length > 0;\n const hasError = !!error;\n const classes = classNames('bdl-PillSelector', 'pill-selector-input-wrapper', {\n 'is-disabled': disabled,\n 'bdl-is-disabled': disabled,\n 'is-focused': isFocused,\n 'show-error': hasError,\n 'pill-selector-suggestions-enabled': suggestedPillsEnabled,\n 'bdl-PillSelector--suggestionsEnabled': suggestedPillsEnabled,\n });\n const ariaAttrs = {\n 'aria-invalid': hasError,\n 'aria-errormessage': this.errorMessageID,\n 'aria-describedby': this.errorMessageID,\n };\n\n return (\n <Tooltip isShown={hasError} text={error || ''} position={errorTooltipPosition} theme=\"error\">\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <span\n className={classes}\n onBlur={this.handleBlur}\n onClick={this.handleClick}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n ref={innerRef}\n >\n {showRoundedPills\n ? selectedOptions.map((option: RoundOption, index: number) => {\n return (\n <RoundPill\n className={getPillClassName ? getPillClassName(option) : undefined}\n getPillImageUrl={getPillImageUrl}\n isValid={allowInvalidPills ? validator(option) : true}\n isDisabled={disabled}\n isSelected={index === selectedIndex}\n key={option.value}\n onRemove={onRemove.bind(this, option, index)}\n // $FlowFixMe option.text is for backwards compatibility\n text={option.displayText || option.text}\n showAvatar={showAvatars}\n id={option.id}\n hasWarning={option.hasWarning}\n isExternal={option.isExternalUser}\n />\n );\n })\n : selectedOptions.map((option: Option, index: number) => {\n // TODO: This and associated types will be removed once all views are updates with round pills.\n return (\n <Pill\n isValid={allowInvalidPills ? validator(option) : true}\n isDisabled={disabled}\n isSelected={index === selectedIndex}\n key={option.value}\n onRemove={onRemove.bind(this, option, index)}\n // $FlowFixMe option.text is for backwards compatibility\n text={option.displayText || option.text}\n />\n );\n })}\n\n {/* hidden element for focus/key events during pill selection */}\n <span\n aria-hidden=\"true\"\n className=\"accessibility-hidden\"\n onBlur={this.resetSelectedIndex}\n ref={this.hiddenRef}\n tabIndex={-1}\n data-testid=\"pill-selection-helper\"\n />\n <textarea\n {...ariaAttrs}\n {...rest}\n {...inputProps}\n autoComplete=\"off\"\n className={classNames('bdl-PillSelector-input', 'pill-selector-input', className)}\n disabled={disabled}\n onInput={onInput}\n placeholder={this.getNumSelected() === 0 ? placeholder : ''}\n ref={input => {\n this.inputEl = input;\n }}\n />\n <SuggestedPillsRow\n onSuggestedPillAdd={onSuggestedPillAdd}\n selectedPillsValues={this.getPillsByKey('value')}\n suggestedPillsFilter={suggestedPillsFilter}\n suggestedPillsData={suggestedPillsData}\n title={suggestedPillsTitle}\n />\n <span id={this.errorMessageID} className=\"accessibility-hidden\" role=\"alert\">\n {error}\n </span>\n </span>\n </Tooltip>\n );\n }\n}\n\nexport { PillSelectorBase };\n\nconst PillSelector = React.forwardRef<Config, HTMLSpanElement>((props: Config, ref: React.Ref<any>) => (\n <PillSelectorBase {...props} innerRef={ref} />\n));\nPillSelector.displayName = 'PillSelector';\n\nexport default PillSelector;\n"],"file":"PillSelector.js"}
|
|
@@ -216,6 +216,7 @@ function (_React$Component) {
|
|
|
216
216
|
dividerIndex = _this$props4.dividerIndex,
|
|
217
217
|
dropdownScrollBoundarySelector = _this$props4.dropdownScrollBoundarySelector,
|
|
218
218
|
error = _this$props4.error,
|
|
219
|
+
errorTooltipPosition = _this$props4.errorTooltipPosition,
|
|
219
220
|
getPillClassName = _this$props4.getPillClassName,
|
|
220
221
|
getPillImageUrl = _this$props4.getPillImageUrl,
|
|
221
222
|
inputProps = _this$props4.inputProps,
|
|
@@ -251,6 +252,7 @@ function (_React$Component) {
|
|
|
251
252
|
allowInvalidPills: allowInvalidPills,
|
|
252
253
|
disabled: disabled,
|
|
253
254
|
error: error,
|
|
255
|
+
errorTooltipPosition: errorTooltipPosition,
|
|
254
256
|
getPillClassName: getPillClassName,
|
|
255
257
|
getPillImageUrl: getPillImageUrl,
|
|
256
258
|
onBlur: this.handleBlur,
|
|
@@ -260,8 +262,8 @@ function (_React$Component) {
|
|
|
260
262
|
onSuggestedPillAdd: onSuggestedPillAdd,
|
|
261
263
|
placeholder: placeholder,
|
|
262
264
|
selectedOptions: selectedOptions,
|
|
263
|
-
showRoundedPills: showRoundedPills,
|
|
264
265
|
showAvatars: showAvatars && showRoundedPills,
|
|
266
|
+
showRoundedPills: showRoundedPills,
|
|
265
267
|
suggestedPillsData: suggestedPillsData,
|
|
266
268
|
suggestedPillsFilter: suggestedPillsFilter,
|
|
267
269
|
suggestedPillsTitle: suggestedPillsTitle,
|
|
@@ -12,6 +12,7 @@ import PillSelector from './PillSelector';
|
|
|
12
12
|
import type { contactType as Contact } from '../../features/unified-share-modal/flowTypes';
|
|
13
13
|
import type { SelectOptionProp } from '../select-field/props';
|
|
14
14
|
import type { Option, OptionValue, SelectedOptions, SuggestedPillsFilter } from './flowTypes';
|
|
15
|
+
import type { Position } from '../tooltip';
|
|
15
16
|
|
|
16
17
|
import './PillSelectorDropdown.scss';
|
|
17
18
|
|
|
@@ -32,6 +33,8 @@ type Props = {
|
|
|
32
33
|
dropdownScrollBoundarySelector?: string,
|
|
33
34
|
/** Error message */
|
|
34
35
|
error?: React.Node,
|
|
36
|
+
/** Position of error message tooltip */
|
|
37
|
+
errorTooltipPosition?: Position,
|
|
35
38
|
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
|
|
36
39
|
getPillClassName?: (option: Option) => string,
|
|
37
40
|
/** Function to retrieve the image URL associated with a pill */
|
|
@@ -238,6 +241,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
238
241
|
dividerIndex,
|
|
239
242
|
dropdownScrollBoundarySelector,
|
|
240
243
|
error,
|
|
244
|
+
errorTooltipPosition,
|
|
241
245
|
getPillClassName,
|
|
242
246
|
getPillImageUrl,
|
|
243
247
|
inputProps,
|
|
@@ -276,6 +280,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
276
280
|
allowInvalidPills={allowInvalidPills}
|
|
277
281
|
disabled={disabled}
|
|
278
282
|
error={error}
|
|
283
|
+
errorTooltipPosition={errorTooltipPosition}
|
|
279
284
|
getPillClassName={getPillClassName}
|
|
280
285
|
getPillImageUrl={getPillImageUrl}
|
|
281
286
|
onBlur={this.handleBlur}
|
|
@@ -285,8 +290,8 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
285
290
|
onSuggestedPillAdd={onSuggestedPillAdd}
|
|
286
291
|
placeholder={placeholder}
|
|
287
292
|
selectedOptions={selectedOptions}
|
|
288
|
-
showRoundedPills={showRoundedPills}
|
|
289
293
|
showAvatars={showAvatars && showRoundedPills}
|
|
294
|
+
showRoundedPills={showRoundedPills}
|
|
290
295
|
suggestedPillsData={suggestedPillsData}
|
|
291
296
|
suggestedPillsFilter={suggestedPillsFilter}
|
|
292
297
|
suggestedPillsTitle={suggestedPillsTitle}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/pill-selector-dropdown/PillSelectorDropdown.js"],"names":["React","classNames","List","noop","parseCSV","Label","SelectorDropdown","PillSelector","PillSelectorDropdown","inputValue","isInCompositionMode","props","allowInvalidPills","parseItems","validator","pills","filter","pill","normalizedPills","map","displayText","text","value","allowCustomPills","onPillCreate","onSelect","selectedOptions","shouldClearUnmatchedInput","validateForError","parsePills","length","resetInputValue","event","onBlur","state","addPillsFromInput","target","setState","onInput","preventDefault","clipboardData","getData","index","selectorOptions","selectedOption","get","handleInput","children","className","disabled","dividerIndex","dropdownScrollBoundarySelector","error","getPillClassName","getPillImageUrl","inputProps","isPositionDynamic","label","onRemove","onSuggestedPillAdd","overlayTitle","placeholder","showAvatars","showRoundedPills","suggestedPillsData","suggestedPillsFilter","suggestedPillsTitle","shouldSetActiveItemOnOpen","selectorDropdownElement","handleEnter","handleSelect","handleCompositionEnd","handleCompositionStart","handleBlur","handlePaste","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,OAAOC,IAAP,MAAiB,aAAjB;AAEA,OAAOC,QAAP,MAAqB,sBAArB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AAKA,OAAO,6BAAP;;IA4EMC,oB;;;;;;;;;;;;;;;;;;4DAkBM;AAAEC,MAAAA,UAAU,EAAE,EAAd;AAAkBC,MAAAA,mBAAmB,EAAE;AAAvC,K;;iEAEK,UAACD,UAAD,EAAwB;AAAA,wBACoB,MAAKE,KADzB;AAAA,UACzBC,iBADyB,eACzBA,iBADyB;AAAA,UACNC,UADM,eACNA,UADM;AAAA,UACMC,SADN,eACMA,SADN;AAEjC,UAAIC,KAAK,GAAGF,UAAU,GAAGA,UAAU,CAACJ,UAAD,CAAb,GAA4BL,QAAQ,CAACK,UAAD,CAA1D;;AAEA,UAAI,CAACM,KAAL,EAAY;AACR,eAAO,EAAP;AACH;;AAED,UAAI,CAACH,iBAAL,EAAwB;AACpBG,QAAAA,KAAK,GAAGA,KAAK,CAACC,MAAN,CAAa,UAAAC,IAAI;AAAA,iBAAIH,SAAS,CAACG,IAAD,CAAb;AAAA,SAAjB,CAAR;AACH;;AAED,UAAMC,eAAe,GAAGH,KAAK,CAACI,GAAN,CAAU,UAAAF,IAAI;AAAA,eAClC,OAAOA,IAAP,KAAgB,QAAhB,GACM;AACIG,UAAAA,WAAW,EAAEH,IADjB;AAEII,UAAAA,IAAI,EAAEJ,IAFV;AAEgB;AACZK,UAAAA,KAAK,EAAEL;AAHX,SADN,GAMMA,IAP4B;AAAA,OAAd,CAAxB;AASA,aAAOC,eAAP;AACH,K;;wEAEmB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AAA,SAAS,EAAEpD,SAtBf;AAuBI,UAAA,KAAK,EAAE,KAAKoB,KAAL,CAAWzB;AAvBtB;AAVR,SAqCKsC,QArCL,CADJ;AA0CA,aAAOU,KAAK,GAAG,oBAAC,KAAD;AAAO,QAAA,IAAI,EAAEA;AAAb,SAAqBW,uBAArB,CAAH,GAA2DA,uBAAvE;AACH;;;;EAnN8BpE,KAAK,CAAC2E,S;;gBAAnCnE,oB,kBACoB;AAClBe,EAAAA,gBAAgB,EAAE,KADA;AAElBX,EAAAA,iBAAiB,EAAE,KAFD;AAGlBqC,EAAAA,QAAQ,EAAE,KAHQ;AAIlBG,EAAAA,KAAK,EAAE,EAJW;AAKlBG,EAAAA,UAAU,EAAE,EALM;AAMlBE,EAAAA,KAAK,EAAE,EANW;AAOlBxB,EAAAA,MAAM,EAAE9B,IAPU;AAQlBqB,EAAAA,YAAY,EAAErB,IARI;AASlB0D,EAAAA,WAAW,EAAE,EATK;AAUlBnC,EAAAA,eAAe,EAAE,EAVC;AAWlBiB,EAAAA,eAAe,EAAE,EAXC;AAYlBhB,EAAAA,yBAAyB,EAAE,KAZT;AAalBwC,EAAAA,yBAAyB,EAAE,KAbT;AAclBrD,EAAAA,SAAS,EAAE;AAAA,WAAM,IAAN;AAAA;AAdO,C;;AAqN1B,eAAeN,oBAAf","sourcesContent":["// @flow\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { List } from 'immutable';\nimport noop from 'lodash/noop';\n\nimport parseCSV from '../../utils/parseCSV';\nimport Label from '../label';\nimport SelectorDropdown from '../selector-dropdown';\n\nimport PillSelector from './PillSelector';\nimport type { contactType as Contact } from '../../features/unified-share-modal/flowTypes';\nimport type { SelectOptionProp } from '../select-field/props';\nimport type { Option, OptionValue, SelectedOptions, SuggestedPillsFilter } from './flowTypes';\n\nimport './PillSelectorDropdown.scss';\n\ntype Props = {\n /** If true, user can add pills not included in selector options */\n allowCustomPills: boolean,\n /** If true, pills with errors are parsed as pills also */\n allowInvalidPills: boolean,\n /** `DatalistItem` components for dropdown options to select */\n children: React.Node,\n /** CSS class for the component */\n className?: string,\n /** If true, the input control is disabled so no more input can be made */\n disabled: boolean,\n /** Index at which to insert a divider */\n dividerIndex?: number,\n /** A CSS selector matching the element to use as a boundary when auto-scrolling dropdown elements into view. When not provided, boundary will be determined by scrollIntoView utility function */\n dropdownScrollBoundarySelector?: string,\n /** Error message */\n error?: React.Node,\n /** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */\n getPillClassName?: (option: Option) => string,\n /** Function to retrieve the image URL associated with a pill */\n getPillImageUrl?: (data: { id: string, [key: string]: any }) => string | Promise<?string>,\n /** Passed in by `SelectorDropdown` for accessibility */\n inputProps: Object,\n /** Option to enable dynamic positioning with popper */\n isPositionDynamic?: boolean,\n /** Input label */\n label: React.Node,\n /** Called when pill selector input is blurred */\n onBlur: (event: SyntheticInputEvent<HTMLInputElement>) => void,\n /** Should update selectorOptions based on the given input value */\n onInput: Function,\n /** Called when creating pills */\n onPillCreate: (pills: Array<SelectOptionProp | Contact>) => void,\n /** Should update selectedOptions given the option and index to remove */\n onRemove: Function,\n /** Should update selectedOptions given an array of pills and the event */\n onSelect: Function,\n /** Function adds a collaborator from suggested collabs to form */\n onSuggestedPillAdd?: Function,\n /** Optional title of the overlay */\n overlayTitle?: string,\n /** function to parse user input into an array of items to be validated and then added to pill selector. If this function is not passed, a default CSV parser is used. */\n parseItems?: Function,\n /** A placeholder to show in the input when there are no pills */\n placeholder: string,\n /** Array or Immutable list with data for the selected options shown as pills */\n selectedOptions: SelectedOptions,\n /** Array or Immutable list with data for the dropdown options to select */\n selectorOptions: Array<Object> | List<Object>,\n /** Determines whether or not input text is cleared automatically when it does not result in new pills being added */\n shouldClearUnmatchedInput?: boolean,\n /** Determines whether or not the first item is highlighted automatically when the dropdown opens */\n shouldSetActiveItemOnOpen?: boolean,\n /** show avatars (uses showRoundedPills) */\n showAvatars?: boolean,\n /** Use rounded style for pills */\n showRoundedPills?: boolean,\n /** Array of suggested collaborators */\n suggestedPillsData?: Array<Object>,\n /** String decribes the datapoint to filter by so that items in the form are not shown in suggestions. */\n suggestedPillsFilter?: SuggestedPillsFilter,\n /** String describes the suggested pills */\n suggestedPillsTitle?: string,\n /** Validate the given input value, and update `error` prop if necessary */\n validateForError?: Function,\n /** Called to check if pill item data is valid. The `item` is passed in. */\n validator: (option: Option | OptionValue) => boolean,\n};\n\ntype State = {\n inputValue: string,\n isInCompositionMode: boolean,\n};\n\nclass PillSelectorDropdown extends React.Component<Props, State> {\n static defaultProps = {\n allowCustomPills: false,\n allowInvalidPills: false,\n disabled: false,\n error: '',\n inputProps: {},\n label: '',\n onBlur: noop,\n onPillCreate: noop,\n placeholder: '',\n selectedOptions: [],\n selectorOptions: [],\n shouldClearUnmatchedInput: false,\n shouldSetActiveItemOnOpen: false,\n validator: () => true,\n };\n\n state = { inputValue: '', isInCompositionMode: false };\n\n parsePills = (inputValue: string) => {\n const { allowInvalidPills, parseItems, validator } = this.props;\n let pills = parseItems ? parseItems(inputValue) : parseCSV(inputValue);\n\n if (!pills) {\n return [];\n }\n\n if (!allowInvalidPills) {\n pills = pills.filter(pill => validator(pill));\n }\n\n const normalizedPills = pills.map(pill =>\n typeof pill === 'string'\n ? {\n displayText: pill,\n text: pill, // deprecated, left for backwards compatibility\n value: pill,\n }\n : pill,\n );\n return normalizedPills;\n };\n\n addPillsFromInput = (inputValue: string) => {\n const {\n allowCustomPills,\n onPillCreate,\n onSelect,\n selectedOptions,\n shouldClearUnmatchedInput,\n validateForError,\n } = this.props;\n\n // Do nothing if custom pills are not allowed\n if (!allowCustomPills) {\n return;\n }\n\n // Parse pills from input\n const pills = this.parsePills(inputValue);\n\n // \"Select\" the pills\n if (pills.length > 0) {\n onSelect(pills);\n onPillCreate(pills);\n\n this.resetInputValue();\n } else {\n if (validateForError && (inputValue !== '' || selectedOptions.length === 0)) {\n /**\n * If no pills were added, but an inputValue exists or\n * there are no pills selected, check for errors\n */\n validateForError(inputValue);\n }\n if (shouldClearUnmatchedInput) {\n this.resetInputValue();\n }\n }\n };\n\n handleBlur = (event: SyntheticInputEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n const { inputValue } = this.state;\n this.addPillsFromInput(inputValue);\n onBlur(event);\n };\n\n handleInput = (event: SyntheticInputEvent<HTMLInputElement> | { target: HTMLInputElement | Object }) => {\n const { target } = event;\n const { value } = target;\n this.setState({ inputValue: value });\n this.props.onInput(value, event);\n };\n\n handleEnter = (event: SyntheticEvent<>) => {\n const { isInCompositionMode, inputValue } = this.state;\n if (!isInCompositionMode) {\n event.preventDefault();\n this.addPillsFromInput(inputValue);\n }\n };\n\n handlePaste = (event: SyntheticClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n\n const inputValue: string = event.clipboardData.getData('text');\n this.setState({ inputValue });\n this.props.onInput(inputValue, event);\n this.addPillsFromInput(inputValue);\n };\n\n handleSelect = (index: number, event: SyntheticEvent<>) => {\n const { onPillCreate, onSelect, selectorOptions } = this.props;\n const selectedOption =\n // $FlowFixMe\n typeof selectorOptions.get === 'function' ? selectorOptions.get(index) : selectorOptions[index];\n\n onSelect([selectedOption], event);\n onPillCreate([selectedOption]);\n\n this.handleInput({ target: { value: '' } });\n };\n\n handleCompositionStart = () => {\n this.setState({ isInCompositionMode: true });\n };\n\n handleCompositionEnd = () => {\n this.setState({ isInCompositionMode: false });\n };\n\n resetInputValue = () => {\n const { onInput } = this.props;\n\n this.setState({ inputValue: '' });\n onInput('');\n };\n\n render() {\n const {\n allowInvalidPills,\n children,\n className,\n disabled,\n dividerIndex,\n dropdownScrollBoundarySelector,\n error,\n getPillClassName,\n getPillImageUrl,\n inputProps,\n isPositionDynamic,\n label,\n onRemove,\n onSuggestedPillAdd,\n overlayTitle,\n placeholder,\n selectedOptions,\n showAvatars,\n showRoundedPills,\n suggestedPillsData,\n suggestedPillsFilter,\n suggestedPillsTitle,\n shouldSetActiveItemOnOpen,\n validator,\n } = this.props;\n\n const selectorDropdownElement = (\n <SelectorDropdown\n className={classNames('bdl-PillSelectorDropdown', 'pill-selector-wrapper', className)}\n dividerIndex={dividerIndex}\n isPositionDynamic={isPositionDynamic}\n onEnter={this.handleEnter}\n onSelect={this.handleSelect}\n overlayTitle={overlayTitle}\n scrollBoundarySelector={dropdownScrollBoundarySelector}\n shouldSetActiveItemOnOpen={shouldSetActiveItemOnOpen}\n selector={\n <PillSelector\n onChange={noop} // fix console error\n onCompositionEnd={this.handleCompositionEnd}\n onCompositionStart={this.handleCompositionStart}\n {...inputProps}\n allowInvalidPills={allowInvalidPills}\n disabled={disabled}\n error={error}\n getPillClassName={getPillClassName}\n getPillImageUrl={getPillImageUrl}\n onBlur={this.handleBlur}\n onInput={this.handleInput}\n onPaste={this.handlePaste}\n onRemove={onRemove}\n onSuggestedPillAdd={onSuggestedPillAdd}\n placeholder={placeholder}\n selectedOptions={selectedOptions}\n showRoundedPills={showRoundedPills}\n showAvatars={showAvatars && showRoundedPills}\n suggestedPillsData={suggestedPillsData}\n suggestedPillsFilter={suggestedPillsFilter}\n suggestedPillsTitle={suggestedPillsTitle}\n validator={validator}\n value={this.state.inputValue}\n />\n }\n >\n {children}\n </SelectorDropdown>\n );\n\n return label ? <Label text={label}>{selectorDropdownElement}</Label> : selectorDropdownElement;\n }\n}\n\nexport default PillSelectorDropdown;\n"],"file":"PillSelectorDropdown.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/pill-selector-dropdown/PillSelectorDropdown.js"],"names":["React","classNames","List","noop","parseCSV","Label","SelectorDropdown","PillSelector","PillSelectorDropdown","inputValue","isInCompositionMode","props","allowInvalidPills","parseItems","validator","pills","filter","pill","normalizedPills","map","displayText","text","value","allowCustomPills","onPillCreate","onSelect","selectedOptions","shouldClearUnmatchedInput","validateForError","parsePills","length","resetInputValue","event","onBlur","state","addPillsFromInput","target","setState","onInput","preventDefault","clipboardData","getData","index","selectorOptions","selectedOption","get","handleInput","children","className","disabled","dividerIndex","dropdownScrollBoundarySelector","error","errorTooltipPosition","getPillClassName","getPillImageUrl","inputProps","isPositionDynamic","label","onRemove","onSuggestedPillAdd","overlayTitle","placeholder","showAvatars","showRoundedPills","suggestedPillsData","suggestedPillsFilter","suggestedPillsTitle","shouldSetActiveItemOnOpen","selectorDropdownElement","handleEnter","handleSelect","handleCompositionEnd","handleCompositionStart","handleBlur","handlePaste","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,OAAOC,IAAP,MAAiB,aAAjB;AAEA,OAAOC,QAAP,MAAqB,sBAArB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AAMA,OAAO,6BAAP;;IA8EMC,oB;;;;;;;;;;;;;;;;;;4DAkBM;AAAEC,MAAAA,UAAU,EAAE,EAAd;AAAkBC,MAAAA,mBAAmB,EAAE;AAAvC,K;;iEAEK,UAACD,UAAD,EAAwB;AAAA,wBACoB,MAAKE,KADzB;AAAA,UACzBC,iBADyB,eACzBA,iBADyB;AAAA,UACNC,UADM,eACNA,UADM;AAAA,UACMC,SADN,eACMA,SADN;AAEjC,UAAIC,KAAK,GAAGF,UAAU,GAAGA,UAAU,CAACJ,UAAD,CAAb,GAA4BL,QAAQ,CAACK,UAAD,CAA1D;;AAEA,UAAI,CAACM,KAAL,EAAY;AACR,eAAO,EAAP;AACH;;AAED,UAAI,CAACH,iBAAL,EAAwB;AACpBG,QAAAA,KAAK,GAAGA,KAAK,CAACC,MAAN,CAAa,UAAAC,IAAI;AAAA,iBAAIH,SAAS,CAACG,IAAD,CAAb;AAAA,SAAjB,CAAR;AACH;;AAED,UAAMC,eAAe,GAAGH,KAAK,CAACI,GAAN,CAAU,UAAAF,IAAI;AAAA,eAClC,OAAOA,IAAP,KAAgB,QAAhB,GACM;AACIG,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AhBjB;AAiBI,UAAA,eAAe,EAAEpC,eAjBrB;AAkBI,UAAA,WAAW,EAAEqC,WAAW,IAAIC,gBAlBhC;AAmBI,UAAA,gBAAgB,EAAEA,gBAnBtB;AAoBI,UAAA,kBAAkB,EAAEC,kBApBxB;AAqBI,UAAA,oBAAoB,EAAEC,oBArB1B;AAsBI,UAAA,mBAAmB,EAAEC,mBAtBzB;AAuBI,UAAA,SAAS,EAAErD,SAvBf;AAwBI,UAAA,KAAK,EAAE,KAAKoB,KAAL,CAAWzB;AAxBtB;AAVR,SAsCKsC,QAtCL,CADJ;AA2CA,aAAOW,KAAK,GAAG,oBAAC,KAAD;AAAO,QAAA,IAAI,EAAEA;AAAb,SAAqBW,uBAArB,CAAH,GAA2DA,uBAAvE;AACH;;;;EArN8BrE,KAAK,CAAC4E,S;;gBAAnCpE,oB,kBACoB;AAClBe,EAAAA,gBAAgB,EAAE,KADA;AAElBX,EAAAA,iBAAiB,EAAE,KAFD;AAGlBqC,EAAAA,QAAQ,EAAE,KAHQ;AAIlBG,EAAAA,KAAK,EAAE,EAJW;AAKlBI,EAAAA,UAAU,EAAE,EALM;AAMlBE,EAAAA,KAAK,EAAE,EANW;AAOlBzB,EAAAA,MAAM,EAAE9B,IAPU;AAQlBqB,EAAAA,YAAY,EAAErB,IARI;AASlB2D,EAAAA,WAAW,EAAE,EATK;AAUlBpC,EAAAA,eAAe,EAAE,EAVC;AAWlBiB,EAAAA,eAAe,EAAE,EAXC;AAYlBhB,EAAAA,yBAAyB,EAAE,KAZT;AAalByC,EAAAA,yBAAyB,EAAE,KAbT;AAclBtD,EAAAA,SAAS,EAAE;AAAA,WAAM,IAAN;AAAA;AAdO,C;;AAuN1B,eAAeN,oBAAf","sourcesContent":["// @flow\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { List } from 'immutable';\nimport noop from 'lodash/noop';\n\nimport parseCSV from '../../utils/parseCSV';\nimport Label from '../label';\nimport SelectorDropdown from '../selector-dropdown';\n\nimport PillSelector from './PillSelector';\nimport type { contactType as Contact } from '../../features/unified-share-modal/flowTypes';\nimport type { SelectOptionProp } from '../select-field/props';\nimport type { Option, OptionValue, SelectedOptions, SuggestedPillsFilter } from './flowTypes';\nimport type { Position } from '../tooltip';\n\nimport './PillSelectorDropdown.scss';\n\ntype Props = {\n /** If true, user can add pills not included in selector options */\n allowCustomPills: boolean,\n /** If true, pills with errors are parsed as pills also */\n allowInvalidPills: boolean,\n /** `DatalistItem` components for dropdown options to select */\n children: React.Node,\n /** CSS class for the component */\n className?: string,\n /** If true, the input control is disabled so no more input can be made */\n disabled: boolean,\n /** Index at which to insert a divider */\n dividerIndex?: number,\n /** A CSS selector matching the element to use as a boundary when auto-scrolling dropdown elements into view. When not provided, boundary will be determined by scrollIntoView utility function */\n dropdownScrollBoundarySelector?: string,\n /** Error message */\n error?: React.Node,\n /** Position of error message tooltip */\n errorTooltipPosition?: Position,\n /** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */\n getPillClassName?: (option: Option) => string,\n /** Function to retrieve the image URL associated with a pill */\n getPillImageUrl?: (data: { id: string, [key: string]: any }) => string | Promise<?string>,\n /** Passed in by `SelectorDropdown` for accessibility */\n inputProps: Object,\n /** Option to enable dynamic positioning with popper */\n isPositionDynamic?: boolean,\n /** Input label */\n label: React.Node,\n /** Called when pill selector input is blurred */\n onBlur: (event: SyntheticInputEvent<HTMLInputElement>) => void,\n /** Should update selectorOptions based on the given input value */\n onInput: Function,\n /** Called when creating pills */\n onPillCreate: (pills: Array<SelectOptionProp | Contact>) => void,\n /** Should update selectedOptions given the option and index to remove */\n onRemove: Function,\n /** Should update selectedOptions given an array of pills and the event */\n onSelect: Function,\n /** Function adds a collaborator from suggested collabs to form */\n onSuggestedPillAdd?: Function,\n /** Optional title of the overlay */\n overlayTitle?: string,\n /** function to parse user input into an array of items to be validated and then added to pill selector. If this function is not passed, a default CSV parser is used. */\n parseItems?: Function,\n /** A placeholder to show in the input when there are no pills */\n placeholder: string,\n /** Array or Immutable list with data for the selected options shown as pills */\n selectedOptions: SelectedOptions,\n /** Array or Immutable list with data for the dropdown options to select */\n selectorOptions: Array<Object> | List<Object>,\n /** Determines whether or not input text is cleared automatically when it does not result in new pills being added */\n shouldClearUnmatchedInput?: boolean,\n /** Determines whether or not the first item is highlighted automatically when the dropdown opens */\n shouldSetActiveItemOnOpen?: boolean,\n /** show avatars (uses showRoundedPills) */\n showAvatars?: boolean,\n /** Use rounded style for pills */\n showRoundedPills?: boolean,\n /** Array of suggested collaborators */\n suggestedPillsData?: Array<Object>,\n /** String decribes the datapoint to filter by so that items in the form are not shown in suggestions. */\n suggestedPillsFilter?: SuggestedPillsFilter,\n /** String describes the suggested pills */\n suggestedPillsTitle?: string,\n /** Validate the given input value, and update `error` prop if necessary */\n validateForError?: Function,\n /** Called to check if pill item data is valid. The `item` is passed in. */\n validator: (option: Option | OptionValue) => boolean,\n};\n\ntype State = {\n inputValue: string,\n isInCompositionMode: boolean,\n};\n\nclass PillSelectorDropdown extends React.Component<Props, State> {\n static defaultProps = {\n allowCustomPills: false,\n allowInvalidPills: false,\n disabled: false,\n error: '',\n inputProps: {},\n label: '',\n onBlur: noop,\n onPillCreate: noop,\n placeholder: '',\n selectedOptions: [],\n selectorOptions: [],\n shouldClearUnmatchedInput: false,\n shouldSetActiveItemOnOpen: false,\n validator: () => true,\n };\n\n state = { inputValue: '', isInCompositionMode: false };\n\n parsePills = (inputValue: string) => {\n const { allowInvalidPills, parseItems, validator } = this.props;\n let pills = parseItems ? parseItems(inputValue) : parseCSV(inputValue);\n\n if (!pills) {\n return [];\n }\n\n if (!allowInvalidPills) {\n pills = pills.filter(pill => validator(pill));\n }\n\n const normalizedPills = pills.map(pill =>\n typeof pill === 'string'\n ? {\n displayText: pill,\n text: pill, // deprecated, left for backwards compatibility\n value: pill,\n }\n : pill,\n );\n return normalizedPills;\n };\n\n addPillsFromInput = (inputValue: string) => {\n const {\n allowCustomPills,\n onPillCreate,\n onSelect,\n selectedOptions,\n shouldClearUnmatchedInput,\n validateForError,\n } = this.props;\n\n // Do nothing if custom pills are not allowed\n if (!allowCustomPills) {\n return;\n }\n\n // Parse pills from input\n const pills = this.parsePills(inputValue);\n\n // \"Select\" the pills\n if (pills.length > 0) {\n onSelect(pills);\n onPillCreate(pills);\n\n this.resetInputValue();\n } else {\n if (validateForError && (inputValue !== '' || selectedOptions.length === 0)) {\n /**\n * If no pills were added, but an inputValue exists or\n * there are no pills selected, check for errors\n */\n validateForError(inputValue);\n }\n if (shouldClearUnmatchedInput) {\n this.resetInputValue();\n }\n }\n };\n\n handleBlur = (event: SyntheticInputEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n const { inputValue } = this.state;\n this.addPillsFromInput(inputValue);\n onBlur(event);\n };\n\n handleInput = (event: SyntheticInputEvent<HTMLInputElement> | { target: HTMLInputElement | Object }) => {\n const { target } = event;\n const { value } = target;\n this.setState({ inputValue: value });\n this.props.onInput(value, event);\n };\n\n handleEnter = (event: SyntheticEvent<>) => {\n const { isInCompositionMode, inputValue } = this.state;\n if (!isInCompositionMode) {\n event.preventDefault();\n this.addPillsFromInput(inputValue);\n }\n };\n\n handlePaste = (event: SyntheticClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n\n const inputValue: string = event.clipboardData.getData('text');\n this.setState({ inputValue });\n this.props.onInput(inputValue, event);\n this.addPillsFromInput(inputValue);\n };\n\n handleSelect = (index: number, event: SyntheticEvent<>) => {\n const { onPillCreate, onSelect, selectorOptions } = this.props;\n const selectedOption =\n // $FlowFixMe\n typeof selectorOptions.get === 'function' ? selectorOptions.get(index) : selectorOptions[index];\n\n onSelect([selectedOption], event);\n onPillCreate([selectedOption]);\n\n this.handleInput({ target: { value: '' } });\n };\n\n handleCompositionStart = () => {\n this.setState({ isInCompositionMode: true });\n };\n\n handleCompositionEnd = () => {\n this.setState({ isInCompositionMode: false });\n };\n\n resetInputValue = () => {\n const { onInput } = this.props;\n\n this.setState({ inputValue: '' });\n onInput('');\n };\n\n render() {\n const {\n allowInvalidPills,\n children,\n className,\n disabled,\n dividerIndex,\n dropdownScrollBoundarySelector,\n error,\n errorTooltipPosition,\n getPillClassName,\n getPillImageUrl,\n inputProps,\n isPositionDynamic,\n label,\n onRemove,\n onSuggestedPillAdd,\n overlayTitle,\n placeholder,\n selectedOptions,\n showAvatars,\n showRoundedPills,\n suggestedPillsData,\n suggestedPillsFilter,\n suggestedPillsTitle,\n shouldSetActiveItemOnOpen,\n validator,\n } = this.props;\n\n const selectorDropdownElement = (\n <SelectorDropdown\n className={classNames('bdl-PillSelectorDropdown', 'pill-selector-wrapper', className)}\n dividerIndex={dividerIndex}\n isPositionDynamic={isPositionDynamic}\n onEnter={this.handleEnter}\n onSelect={this.handleSelect}\n overlayTitle={overlayTitle}\n scrollBoundarySelector={dropdownScrollBoundarySelector}\n shouldSetActiveItemOnOpen={shouldSetActiveItemOnOpen}\n selector={\n <PillSelector\n onChange={noop} // fix console error\n onCompositionEnd={this.handleCompositionEnd}\n onCompositionStart={this.handleCompositionStart}\n {...inputProps}\n allowInvalidPills={allowInvalidPills}\n disabled={disabled}\n error={error}\n errorTooltipPosition={errorTooltipPosition}\n getPillClassName={getPillClassName}\n getPillImageUrl={getPillImageUrl}\n onBlur={this.handleBlur}\n onInput={this.handleInput}\n onPaste={this.handlePaste}\n onRemove={onRemove}\n onSuggestedPillAdd={onSuggestedPillAdd}\n placeholder={placeholder}\n selectedOptions={selectedOptions}\n showAvatars={showAvatars && showRoundedPills}\n showRoundedPills={showRoundedPills}\n suggestedPillsData={suggestedPillsData}\n suggestedPillsFilter={suggestedPillsFilter}\n suggestedPillsTitle={suggestedPillsTitle}\n validator={validator}\n value={this.state.inputValue}\n />\n }\n >\n {children}\n </SelectorDropdown>\n );\n\n return label ? <Label text={label}>{selectorDropdownElement}</Label> : selectorDropdownElement;\n }\n}\n\nexport default PillSelectorDropdown;\n"],"file":"PillSelectorDropdown.js"}
|
|
@@ -242,6 +242,7 @@ function (_React$Component) {
|
|
|
242
242
|
placeholder: intl.formatMessage(commonMessages.pillSelectorPlaceholder),
|
|
243
243
|
ref: fieldRef,
|
|
244
244
|
selectedOptions: selectedContacts,
|
|
245
|
+
showAvatars: true,
|
|
245
246
|
showRoundedPills: true,
|
|
246
247
|
selectorOptions: contacts,
|
|
247
248
|
validateForError: validateForError,
|
|
@@ -209,6 +209,7 @@ class ContactsField extends React.Component<Props, State> {
|
|
|
209
209
|
placeholder={intl.formatMessage(commonMessages.pillSelectorPlaceholder)}
|
|
210
210
|
ref={fieldRef}
|
|
211
211
|
selectedOptions={selectedContacts}
|
|
212
|
+
showAvatars
|
|
212
213
|
showRoundedPills
|
|
213
214
|
selectorOptions={contacts}
|
|
214
215
|
validateForError={validateForError}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/unified-share-modal/ContactsField.js"],"names":["React","FormattedMessage","injectIntl","debounce","noop","classNames","PillSelectorDropdown","ContactDatalistItem","computeSuggestedCollabs","parseEmails","commonMessages","messages","isSubstring","value","searchString","toLowerCase","indexOf","ContactsField","props","contacts","suggestedCollaborators","pillSelectorInputValue","state","suggestedOptions","otherOptions","setState","numSuggestedShowing","length","selectedContacts","fullContacts","filter","name","email","id","find","addSuggestedContacts","map","isExternalUser","type","text","query","getContacts","then","filteredContacts","filterContacts","catch","error","isCanceled","getContactsPromise","inputValue","validator","emails","validEmails","onInput","trimmedValue","trim","debouncedGetContacts","disabled","fieldRef","getContactAvatarUrl","getPillClassName","intl","label","onContactAdd","onContactRemove","onPillCreate","showContactAvatars","validateForError","groupLabel","shouldShowSuggested","pillSelectorOverlayClasses","scrollable","undefined","autoFocus","onChange","handlePillSelectorInput","formatMessage","suggestedCollabsTitle","handleParseItems","pillSelectorPlaceholder","Component","ContactsFieldBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,gBAAT,EAA2BC,UAA3B,QAA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,UANvB;AAOI,UAAA,KAAK,EAAE7B,IAPX;AAQI,UAAA,UAAU,EAAE2B;AARhB,UADU;AAAA,OAAb,CA5BL,CADJ;AA2CH;;;;EAtLuBlE,KAAK,CAACgF,S;;gBAA5B/D,a,kBACoB;AAClBiD,EAAAA,kBAAkB,EAAE;AADF,C;;AAwL1B,SAASjD,aAAa,IAAIgE,iBAA1B;AACA,eAAe/E,UAAU,CAACe,aAAD,CAAzB","sourcesContent":["// @flow\n\nimport * as React from 'react';\nimport { FormattedMessage, injectIntl } from 'react-intl';\nimport debounce from 'lodash/debounce';\nimport noop from 'lodash/noop';\nimport classNames from 'classnames';\n\nimport PillSelectorDropdown from '../../components/pill-selector-dropdown';\nimport ContactDatalistItem from '../../components/contact-datalist-item';\nimport computeSuggestedCollabs from './utils/computeSuggestedCollabs';\nimport parseEmails from '../../utils/parseEmails';\nimport commonMessages from '../../common/messages';\n\nimport messages from './messages';\nimport type { SuggestedCollabLookup, contactType as Contact } from './flowTypes';\nimport type { SelectOptionProp } from '../../components/select-field/props';\n\ntype Props = {\n disabled: boolean,\n error: string,\n fieldRef?: Object,\n getContactAvatarUrl?: (contact: Contact) => string,\n getContacts: (query: string) => Promise<Array<Contact>>,\n getPillClassName?: (option: SelectOptionProp) => string,\n intl: any,\n label: React.Node,\n onContactAdd: Function,\n onContactRemove: Function,\n onInput?: Function,\n onPillCreate?: (pills: Array<SelectOptionProp | Contact>) => void,\n selectedContacts: Array<Contact>,\n showContactAvatars?: boolean,\n suggestedCollaborators?: SuggestedCollabLookup,\n validateForError: Function,\n validator: Function,\n};\n\ntype State = {\n contacts: Array<Contact>,\n numSuggestedShowing: number,\n pillSelectorInputValue: string,\n};\n\nconst isSubstring = (value, searchString) => {\n return value && value.toLowerCase().indexOf(searchString.toLowerCase()) !== -1;\n};\n\nclass ContactsField extends React.Component<Props, State> {\n static defaultProps = {\n showContactAvatars: false,\n };\n\n constructor(props: Props) {\n super(props);\n\n this.state = {\n contacts: [],\n numSuggestedShowing: 0,\n pillSelectorInputValue: '',\n };\n }\n\n addSuggestedContacts = (contacts: Array<Contact>) => {\n const { suggestedCollaborators = {} } = this.props;\n const { pillSelectorInputValue } = this.state;\n\n const [suggestedOptions, otherOptions] = computeSuggestedCollabs(\n contacts,\n suggestedCollaborators,\n pillSelectorInputValue,\n );\n this.setState({ numSuggestedShowing: suggestedOptions.length });\n return [...suggestedOptions, ...otherOptions];\n };\n\n filterContacts = (contacts: Array<Contact>): Array<Contact> => {\n const { pillSelectorInputValue } = this.state;\n const { selectedContacts, suggestedCollaborators } = this.props;\n if (pillSelectorInputValue && contacts) {\n let fullContacts = contacts\n .filter(\n // filter contacts whose name or email don't match input value\n ({ name, email }) =>\n isSubstring(name, pillSelectorInputValue) || isSubstring(email, pillSelectorInputValue),\n )\n .filter(\n // filter contacts who have already been selected\n ({ email, id }) => !selectedContacts.find(({ value }) => value === email || value === id),\n );\n\n if (suggestedCollaborators) {\n fullContacts = this.addSuggestedContacts(fullContacts);\n }\n\n return fullContacts.map<Contact>(({ email, id, isExternalUser, name, type }) => ({\n // map to standardized DatalistItem format\n // TODO: refactor this so inline conversions aren't required at every usage\n email,\n id,\n isExternalUser,\n text: name,\n type,\n value: email || id, // if email doesn't exist, contact is a group, use id\n }));\n }\n\n // return empty selector options if input value is empty\n return [];\n };\n\n getContactsPromise = (query: string) => {\n return this.props\n .getContacts(query)\n .then(contacts => {\n const filteredContacts = this.filterContacts(contacts);\n this.setState({ contacts: filteredContacts });\n })\n .catch(error => {\n if (error.isCanceled) {\n // silently fail - this happens often when requests get cancelled\n // due to overlapping requests\n return;\n }\n throw error;\n });\n };\n\n debouncedGetContacts = debounce(this.getContactsPromise, 200);\n\n handleParseItems = (inputValue: string): Array<string> => {\n const { validator } = this.props;\n\n // ContactField allows invalid pills to be displayed in\n // in some cases (e.g., when user is external and external\n // collab is restricted). We don't allow, however, invalid\n // emails from the pill selector input to be turned into pills.\n const emails = parseEmails(inputValue);\n const validEmails = emails.filter(email => validator(email));\n\n return validEmails;\n };\n\n handlePillSelectorInput = (value: string) => {\n const { onInput } = this.props;\n const trimmedValue = value.trim();\n\n this.setState({\n pillSelectorInputValue: trimmedValue,\n });\n\n if (onInput) {\n onInput(value);\n }\n\n if (!trimmedValue) {\n this.setState({ contacts: [] });\n return;\n }\n\n this.debouncedGetContacts(trimmedValue);\n };\n\n render() {\n const {\n disabled,\n error,\n fieldRef,\n getContactAvatarUrl,\n getPillClassName,\n intl,\n label,\n onContactAdd,\n onContactRemove,\n onPillCreate,\n selectedContacts,\n showContactAvatars,\n validateForError,\n validator,\n } = this.props;\n const { contacts, numSuggestedShowing } = this.state;\n const groupLabel = <FormattedMessage {...messages.groupLabel} />;\n const shouldShowSuggested = numSuggestedShowing > 0;\n const pillSelectorOverlayClasses = classNames({\n scrollable: contacts.length > 5,\n });\n\n return (\n <PillSelectorDropdown\n allowCustomPills\n allowInvalidPills\n className={pillSelectorOverlayClasses}\n dividerIndex={shouldShowSuggested ? numSuggestedShowing : undefined}\n disabled={disabled}\n error={error}\n getPillClassName={getPillClassName}\n getPillImageUrl={getContactAvatarUrl}\n inputProps={{\n autoFocus: true,\n onChange: noop,\n }}\n label={label}\n onInput={this.handlePillSelectorInput}\n onRemove={onContactRemove}\n onSelect={onContactAdd}\n onPillCreate={onPillCreate}\n overlayTitle={shouldShowSuggested ? intl.formatMessage(messages.suggestedCollabsTitle) : undefined}\n parseItems={this.handleParseItems}\n placeholder={intl.formatMessage(commonMessages.pillSelectorPlaceholder)}\n ref={fieldRef}\n selectedOptions={selectedContacts}\n showRoundedPills\n selectorOptions={contacts}\n validateForError={validateForError}\n validator={validator}\n >\n {contacts.map(({ email, isExternalUser, text = null, id }) => (\n <ContactDatalistItem\n getContactAvatarUrl={getContactAvatarUrl}\n key={id}\n id={id}\n isExternal={isExternalUser}\n name={text}\n subtitle={email || groupLabel}\n title={text}\n showAvatar={showContactAvatars}\n />\n ))}\n </PillSelectorDropdown>\n );\n }\n}\n\nexport { ContactsField as ContactsFieldBase };\nexport default injectIntl(ContactsField);\n"],"file":"ContactsField.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/features/unified-share-modal/ContactsField.js"],"names":["React","FormattedMessage","injectIntl","debounce","noop","classNames","PillSelectorDropdown","ContactDatalistItem","computeSuggestedCollabs","parseEmails","commonMessages","messages","isSubstring","value","searchString","toLowerCase","indexOf","ContactsField","props","contacts","suggestedCollaborators","pillSelectorInputValue","state","suggestedOptions","otherOptions","setState","numSuggestedShowing","length","selectedContacts","fullContacts","filter","name","email","id","find","addSuggestedContacts","map","isExternalUser","type","text","query","getContacts","then","filteredContacts","filterContacts","catch","error","isCanceled","getContactsPromise","inputValue","validator","emails","validEmails","onInput","trimmedValue","trim","debouncedGetContacts","disabled","fieldRef","getContactAvatarUrl","getPillClassName","intl","label","onContactAdd","onContactRemove","onPillCreate","showContactAvatars","validateForError","groupLabel","shouldShowSuggested","pillSelectorOverlayClasses","scrollable","undefined","autoFocus","onChange","handlePillSelectorInput","formatMessage","suggestedCollabsTitle","handleParseItems","pillSelectorPlaceholder","Component","ContactsFieldBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,gBAAT,EAA2BC,UAA3B,QAA6C,YAA7C;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,oBAAP,MAAiC,yCAAjC;AACA,OAAOC,mBAAP,MAAgC,wCAAhC;AACA,OAAOC,uBAAP,MAAoC,iCAApC;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,cAAP,MAA2B,uBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;;AA8BA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD,EAAQC,YAAR,EAAyB;AACzC,SAAOD,KAAK,IAAIA,KAAK,CAACE,WAAN,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,CAACkE,qBAA5B,CAAH,GAAwDL,SAlB7F;AAmBI,QAAA,UAAU,EAAE,KAAKM,gBAnBrB;AAoBI,QAAA,WAAW,EAAEjB,IAAI,CAACe,aAAL,CAAmBlE,cAAc,CAACqE,uBAAlC,CApBjB;AAqBI,QAAA,GAAG,EAAErB,QArBT;AAsBI,QAAA,eAAe,EAAE9B,gBAtBrB;AAuBI,QAAA,WAAW,MAvBf;AAwBI,QAAA,gBAAgB,MAxBpB;AAyBI,QAAA,eAAe,EAAET,QAzBrB;AA0BI,QAAA,gBAAgB,EAAEgD,gBA1BtB;AA2BI,QAAA,SAAS,EAAEjB;AA3Bf,SA6BK/B,QAAQ,CAACiB,GAAT,CAAa;AAAA,YAAGJ,KAAH,SAAGA,KAAH;AAAA,YAAUK,cAAV,SAAUA,cAAV;AAAA,+BAA0BE,IAA1B;AAAA,YAA0BA,IAA1B,2BAAiC,IAAjC;AAAA,YAAuCN,EAAvC,SAAuCA,EAAvC;AAAA,eACV,oBAAC,mBAAD;AACI,UAAA,mBAAmB,EAAE0B,mBADzB;AAEI,UAAA,GAAG,EAAE1B,EAFT;AAGI,UAAA,EAAE,EAAEA,EAHR;AAII,UAAA,UAAU,EAAEI,cAJhB;AAKI,UAAA,IAAI,EAAEE,IALV;AAMI,UAAA,QAAQ,EAAEP,KAAK,IAAIoC,UANvB;AAOI,UAAA,KAAK,EAAE7B,IAPX;AAQI,UAAA,UAAU,EAAE2B;AARhB,UADU;AAAA,OAAb,CA7BL,CADJ;AA4CH;;;;EAvLuBlE,KAAK,CAACgF,S;;gBAA5B/D,a,kBACoB;AAClBiD,EAAAA,kBAAkB,EAAE;AADF,C;;AAyL1B,SAASjD,aAAa,IAAIgE,iBAA1B;AACA,eAAe/E,UAAU,CAACe,aAAD,CAAzB","sourcesContent":["// @flow\n\nimport * as React from 'react';\nimport { FormattedMessage, injectIntl } from 'react-intl';\nimport debounce from 'lodash/debounce';\nimport noop from 'lodash/noop';\nimport classNames from 'classnames';\n\nimport PillSelectorDropdown from '../../components/pill-selector-dropdown';\nimport ContactDatalistItem from '../../components/contact-datalist-item';\nimport computeSuggestedCollabs from './utils/computeSuggestedCollabs';\nimport parseEmails from '../../utils/parseEmails';\nimport commonMessages from '../../common/messages';\n\nimport messages from './messages';\nimport type { SuggestedCollabLookup, contactType as Contact } from './flowTypes';\nimport type { SelectOptionProp } from '../../components/select-field/props';\n\ntype Props = {\n disabled: boolean,\n error: string,\n fieldRef?: Object,\n getContactAvatarUrl?: (contact: Contact) => string,\n getContacts: (query: string) => Promise<Array<Contact>>,\n getPillClassName?: (option: SelectOptionProp) => string,\n intl: any,\n label: React.Node,\n onContactAdd: Function,\n onContactRemove: Function,\n onInput?: Function,\n onPillCreate?: (pills: Array<SelectOptionProp | Contact>) => void,\n selectedContacts: Array<Contact>,\n showContactAvatars?: boolean,\n suggestedCollaborators?: SuggestedCollabLookup,\n validateForError: Function,\n validator: Function,\n};\n\ntype State = {\n contacts: Array<Contact>,\n numSuggestedShowing: number,\n pillSelectorInputValue: string,\n};\n\nconst isSubstring = (value, searchString) => {\n return value && value.toLowerCase().indexOf(searchString.toLowerCase()) !== -1;\n};\n\nclass ContactsField extends React.Component<Props, State> {\n static defaultProps = {\n showContactAvatars: false,\n };\n\n constructor(props: Props) {\n super(props);\n\n this.state = {\n contacts: [],\n numSuggestedShowing: 0,\n pillSelectorInputValue: '',\n };\n }\n\n addSuggestedContacts = (contacts: Array<Contact>) => {\n const { suggestedCollaborators = {} } = this.props;\n const { pillSelectorInputValue } = this.state;\n\n const [suggestedOptions, otherOptions] = computeSuggestedCollabs(\n contacts,\n suggestedCollaborators,\n pillSelectorInputValue,\n );\n this.setState({ numSuggestedShowing: suggestedOptions.length });\n return [...suggestedOptions, ...otherOptions];\n };\n\n filterContacts = (contacts: Array<Contact>): Array<Contact> => {\n const { pillSelectorInputValue } = this.state;\n const { selectedContacts, suggestedCollaborators } = this.props;\n if (pillSelectorInputValue && contacts) {\n let fullContacts = contacts\n .filter(\n // filter contacts whose name or email don't match input value\n ({ name, email }) =>\n isSubstring(name, pillSelectorInputValue) || isSubstring(email, pillSelectorInputValue),\n )\n .filter(\n // filter contacts who have already been selected\n ({ email, id }) => !selectedContacts.find(({ value }) => value === email || value === id),\n );\n\n if (suggestedCollaborators) {\n fullContacts = this.addSuggestedContacts(fullContacts);\n }\n\n return fullContacts.map<Contact>(({ email, id, isExternalUser, name, type }) => ({\n // map to standardized DatalistItem format\n // TODO: refactor this so inline conversions aren't required at every usage\n email,\n id,\n isExternalUser,\n text: name,\n type,\n value: email || id, // if email doesn't exist, contact is a group, use id\n }));\n }\n\n // return empty selector options if input value is empty\n return [];\n };\n\n getContactsPromise = (query: string) => {\n return this.props\n .getContacts(query)\n .then(contacts => {\n const filteredContacts = this.filterContacts(contacts);\n this.setState({ contacts: filteredContacts });\n })\n .catch(error => {\n if (error.isCanceled) {\n // silently fail - this happens often when requests get cancelled\n // due to overlapping requests\n return;\n }\n throw error;\n });\n };\n\n debouncedGetContacts = debounce(this.getContactsPromise, 200);\n\n handleParseItems = (inputValue: string): Array<string> => {\n const { validator } = this.props;\n\n // ContactField allows invalid pills to be displayed in\n // in some cases (e.g., when user is external and external\n // collab is restricted). We don't allow, however, invalid\n // emails from the pill selector input to be turned into pills.\n const emails = parseEmails(inputValue);\n const validEmails = emails.filter(email => validator(email));\n\n return validEmails;\n };\n\n handlePillSelectorInput = (value: string) => {\n const { onInput } = this.props;\n const trimmedValue = value.trim();\n\n this.setState({\n pillSelectorInputValue: trimmedValue,\n });\n\n if (onInput) {\n onInput(value);\n }\n\n if (!trimmedValue) {\n this.setState({ contacts: [] });\n return;\n }\n\n this.debouncedGetContacts(trimmedValue);\n };\n\n render() {\n const {\n disabled,\n error,\n fieldRef,\n getContactAvatarUrl,\n getPillClassName,\n intl,\n label,\n onContactAdd,\n onContactRemove,\n onPillCreate,\n selectedContacts,\n showContactAvatars,\n validateForError,\n validator,\n } = this.props;\n const { contacts, numSuggestedShowing } = this.state;\n const groupLabel = <FormattedMessage {...messages.groupLabel} />;\n const shouldShowSuggested = numSuggestedShowing > 0;\n const pillSelectorOverlayClasses = classNames({\n scrollable: contacts.length > 5,\n });\n\n return (\n <PillSelectorDropdown\n allowCustomPills\n allowInvalidPills\n className={pillSelectorOverlayClasses}\n dividerIndex={shouldShowSuggested ? numSuggestedShowing : undefined}\n disabled={disabled}\n error={error}\n getPillClassName={getPillClassName}\n getPillImageUrl={getContactAvatarUrl}\n inputProps={{\n autoFocus: true,\n onChange: noop,\n }}\n label={label}\n onInput={this.handlePillSelectorInput}\n onRemove={onContactRemove}\n onSelect={onContactAdd}\n onPillCreate={onPillCreate}\n overlayTitle={shouldShowSuggested ? intl.formatMessage(messages.suggestedCollabsTitle) : undefined}\n parseItems={this.handleParseItems}\n placeholder={intl.formatMessage(commonMessages.pillSelectorPlaceholder)}\n ref={fieldRef}\n selectedOptions={selectedContacts}\n showAvatars\n showRoundedPills\n selectorOptions={contacts}\n validateForError={validateForError}\n validator={validator}\n >\n {contacts.map(({ email, isExternalUser, text = null, id }) => (\n <ContactDatalistItem\n getContactAvatarUrl={getContactAvatarUrl}\n key={id}\n id={id}\n isExternal={isExternalUser}\n name={text}\n subtitle={email || groupLabel}\n title={text}\n showAvatar={showContactAvatars}\n />\n ))}\n </PillSelectorDropdown>\n );\n }\n}\n\nexport { ContactsField as ContactsFieldBase };\nexport default injectIntl(ContactsField);\n"],"file":"ContactsField.js"}
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import RoundPill from './RoundPill';
|
|
|
11
11
|
import Pill from './Pill';
|
|
12
12
|
import SuggestedPillsRow from './SuggestedPillsRow';
|
|
13
13
|
import type { RoundOption, Option, OptionValue, SuggestedPillsFilter } from './flowTypes';
|
|
14
|
+
import type { Position } from '../tooltip';
|
|
14
15
|
|
|
15
16
|
function stopDefaultEvent(event) {
|
|
16
17
|
event.preventDefault();
|
|
@@ -22,6 +23,8 @@ type Props = {
|
|
|
22
23
|
className?: string,
|
|
23
24
|
disabled?: boolean,
|
|
24
25
|
error?: React.Node,
|
|
26
|
+
/** Position of error message tooltip */
|
|
27
|
+
errorTooltipPosition?: Position,
|
|
25
28
|
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
|
|
26
29
|
getPillClassName?: (option: Option) => string,
|
|
27
30
|
/** Function to retrieve the image URL associated with a pill */
|
|
@@ -52,6 +55,7 @@ type DefaultProps = {
|
|
|
52
55
|
allowInvalidPills: boolean,
|
|
53
56
|
disabled: boolean,
|
|
54
57
|
error: string,
|
|
58
|
+
errorTooltipPosition: Position,
|
|
55
59
|
inputProps: Object,
|
|
56
60
|
placeholder: string,
|
|
57
61
|
selectedOptions: List<Object>,
|
|
@@ -65,6 +69,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
65
69
|
allowInvalidPills: false,
|
|
66
70
|
disabled: false,
|
|
67
71
|
error: '',
|
|
72
|
+
errorTooltipPosition: 'bottom-left',
|
|
68
73
|
inputProps: {},
|
|
69
74
|
placeholder: '',
|
|
70
75
|
selectedOptions: [],
|
|
@@ -185,6 +190,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
185
190
|
className,
|
|
186
191
|
disabled,
|
|
187
192
|
error,
|
|
193
|
+
errorTooltipPosition,
|
|
188
194
|
getPillClassName,
|
|
189
195
|
getPillImageUrl,
|
|
190
196
|
inputProps,
|
|
@@ -219,7 +225,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
219
225
|
};
|
|
220
226
|
|
|
221
227
|
return (
|
|
222
|
-
<Tooltip isShown={hasError} text={error || ''} position=
|
|
228
|
+
<Tooltip isShown={hasError} text={error || ''} position={errorTooltipPosition} theme="error">
|
|
223
229
|
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
|
|
224
230
|
<span
|
|
225
231
|
className={classes}
|
|
@@ -242,7 +248,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
242
248
|
onRemove={onRemove.bind(this, option, index)}
|
|
243
249
|
// $FlowFixMe option.text is for backwards compatibility
|
|
244
250
|
text={option.displayText || option.text}
|
|
245
|
-
showAvatar
|
|
251
|
+
showAvatar={showAvatars}
|
|
246
252
|
id={option.id}
|
|
247
253
|
hasWarning={option.hasWarning}
|
|
248
254
|
isExternal={option.isExternalUser}
|
|
@@ -278,9 +284,7 @@ class PillSelectorBase extends React.Component<Props, State> {
|
|
|
278
284
|
{...rest}
|
|
279
285
|
{...inputProps}
|
|
280
286
|
autoComplete="off"
|
|
281
|
-
className={classNames('bdl-PillSelector-input', 'pill-selector-input', className
|
|
282
|
-
'bdl-PillSelector-input--showAvatars': showAvatars,
|
|
283
|
-
})}
|
|
287
|
+
className={classNames('bdl-PillSelector-input', 'pill-selector-input', className)}
|
|
284
288
|
disabled={disabled}
|
|
285
289
|
onInput={onInput}
|
|
286
290
|
placeholder={this.getNumSelected() === 0 ? placeholder : ''}
|
|
@@ -12,6 +12,7 @@ import PillSelector from './PillSelector';
|
|
|
12
12
|
import type { contactType as Contact } from '../../features/unified-share-modal/flowTypes';
|
|
13
13
|
import type { SelectOptionProp } from '../select-field/props';
|
|
14
14
|
import type { Option, OptionValue, SelectedOptions, SuggestedPillsFilter } from './flowTypes';
|
|
15
|
+
import type { Position } from '../tooltip';
|
|
15
16
|
|
|
16
17
|
import './PillSelectorDropdown.scss';
|
|
17
18
|
|
|
@@ -32,6 +33,8 @@ type Props = {
|
|
|
32
33
|
dropdownScrollBoundarySelector?: string,
|
|
33
34
|
/** Error message */
|
|
34
35
|
error?: React.Node,
|
|
36
|
+
/** Position of error message tooltip */
|
|
37
|
+
errorTooltipPosition?: Position,
|
|
35
38
|
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
|
|
36
39
|
getPillClassName?: (option: Option) => string,
|
|
37
40
|
/** Function to retrieve the image URL associated with a pill */
|
|
@@ -238,6 +241,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
238
241
|
dividerIndex,
|
|
239
242
|
dropdownScrollBoundarySelector,
|
|
240
243
|
error,
|
|
244
|
+
errorTooltipPosition,
|
|
241
245
|
getPillClassName,
|
|
242
246
|
getPillImageUrl,
|
|
243
247
|
inputProps,
|
|
@@ -276,6 +280,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
276
280
|
allowInvalidPills={allowInvalidPills}
|
|
277
281
|
disabled={disabled}
|
|
278
282
|
error={error}
|
|
283
|
+
errorTooltipPosition={errorTooltipPosition}
|
|
279
284
|
getPillClassName={getPillClassName}
|
|
280
285
|
getPillImageUrl={getPillImageUrl}
|
|
281
286
|
onBlur={this.handleBlur}
|
|
@@ -285,8 +290,8 @@ class PillSelectorDropdown extends React.Component<Props, State> {
|
|
|
285
290
|
onSuggestedPillAdd={onSuggestedPillAdd}
|
|
286
291
|
placeholder={placeholder}
|
|
287
292
|
selectedOptions={selectedOptions}
|
|
288
|
-
showRoundedPills={showRoundedPills}
|
|
289
293
|
showAvatars={showAvatars && showRoundedPills}
|
|
294
|
+
showRoundedPills={showRoundedPills}
|
|
290
295
|
suggestedPillsData={suggestedPillsData}
|
|
291
296
|
suggestedPillsFilter={suggestedPillsFilter}
|
|
292
297
|
suggestedPillsTitle={suggestedPillsTitle}
|