Skip to content

Commit 2578ab1

Browse files
committed
PluralLinkedSelect - accept valueIcons
1 parent 91ee687 commit 2578ab1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/components/linked-select.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const LinkedSelect = ({
3333
disableSubMessage,
3434
customRender,
3535
customRenderSub,
36+
icons,
3637
}) => {
3738
const [choice, setChoice] = useState(init)
3839
const [subChoice, setSubChoice] = useState(subInit)
@@ -77,6 +78,7 @@ const LinkedSelect = ({
7778
onSelect={setChoice}
7879
onClear={() => setChoice('')}
7980
placeholder={placeholders[0]}
81+
{...(icons && { icons })}
8082
/>
8183
}
8284
</div>
@@ -132,6 +134,7 @@ LinkedSelect.propTypes = {
132134
disableSubMessage: PropTypes.string,
133135
customRender: PropTypes.func,
134136
customRenderSub: PropTypes.func,
137+
icons: PropTypes.array,
135138
}
136139

137140
LinkedSelect.defaultProps = {
@@ -145,6 +148,7 @@ LinkedSelect.defaultProps = {
145148
disableSubMessage: '',
146149
customRender: null,
147150
customRenderSub: null,
151+
icons: null,
148152
}
149153

150154
export default LinkedSelect

src/components/plural-linked-select.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const PluralLinkedSelect = ({
4444
headerIcons,
4545
titles,
4646
values,
47+
valueIcons,
4748
primaryKey,
4849
secondaryKey,
4950
data,
@@ -55,6 +56,7 @@ const PluralLinkedSelect = ({
5556
addMessage,
5657
customRenderPrimary,
5758
customRenderSecondary,
59+
valueIcons,
5860
}) => {
5961
const renderValue = i => {
6062
const primary = values[i]?.[primaryKey]
@@ -65,6 +67,7 @@ const PluralLinkedSelect = ({
6567
className={`${i > 0 ? 'mt-2' : ''}`}
6668
callback={([_k, _v]) => callback(i, { [primaryKey]: _k, [secondaryKey]: _v })}
6769
data={data.filter(d => primary === d || !values.map(v => v[primaryKey]).includes(d))}
70+
{...(valueIcons && { icons: valueIcons })}
6871
init={primary}
6972
subData={subData}
7073
subInit={values[i]?.[secondaryKey]}
@@ -139,23 +142,27 @@ PluralLinkedSelect.propTypes = {
139142
callback: PropTypes.func.isRequired,
140143
deleteCallback: PropTypes.func,
141144
values: PropTypes.arrayOf(PropTypes.object).isRequired,
145+
valueIcons: PropTypes.array,
142146
disableSubs: PropTypes.bool,
143147
disableSubMessage: PropTypes.string,
144148
addMessage: PropTypes.string,
145149
customRenderPrimary: PropTypes.func,
146150
customRenderSecondary: PropTypes.func,
151+
valueIcons: PropTypes.array,
147152
}
148153

149154
PluralLinkedSelect.defaultProps = {
150155
staticQuantity: null,
151156
titles: [],
152157
headerIcons: [],
153158
deleteCallback: () => {},
159+
valueIcons: null,
154160
disableSubs: false,
155161
disableSubMessage: '',
156162
addMessage: 'Add',
157163
customRenderPrimary: null,
158164
customRenderSecondary: null,
165+
valueIcons: null,
159166
}
160167

161168
export default PluralLinkedSelect

0 commit comments

Comments
 (0)