@khanacademy/wonder-blocks-dropdown 5.6.3 → 5.7.0
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 +11 -0
- package/dist/components/combobox.d.ts +7 -2
- package/dist/es/index.js +21 -2
- package/dist/index.js +20 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-dropdown
|
|
2
2
|
|
|
3
|
+
## 5.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c512e76e: Add `startIcon` prop to Combobox
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [b5cad0b1]
|
|
12
|
+
- @khanacademy/wonder-blocks-modal@5.1.17
|
|
13
|
+
|
|
3
14
|
## 5.6.3
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import { PhosphorIcon } from "@khanacademy/wonder-blocks-icon";
|
|
3
4
|
import { ComboboxLabels, MaybeValueOrValues, OptionItemComponent } from "../util/types";
|
|
4
5
|
type Props = {
|
|
5
6
|
/**
|
|
@@ -89,6 +90,10 @@ type Props = {
|
|
|
89
90
|
* (combobox).
|
|
90
91
|
*/
|
|
91
92
|
autoComplete?: "none" | "list" | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* An optional decorative icon to display at the start of the combobox.
|
|
95
|
+
*/
|
|
96
|
+
startIcon?: React.ReactElement<React.ComponentProps<typeof PhosphorIcon>> | null;
|
|
92
97
|
};
|
|
93
98
|
/**
|
|
94
99
|
* A `Combobox` is an input widget that has an associated `listbox`. This
|
|
@@ -102,5 +107,5 @@ type Props = {
|
|
|
102
107
|
* Open button (🔽) is pressed.
|
|
103
108
|
* - It is displayed when the combobox receives focus.
|
|
104
109
|
*/
|
|
105
|
-
export default function Combobox({ autoComplete, children, disabled, error, id, labels, onChange, onToggle, opened, placeholder, selectionType, testId, value, }: Props): JSX.Element;
|
|
110
|
+
export default function Combobox({ autoComplete, children, disabled, error, id, labels, onChange, onToggle, opened, placeholder, selectionType, startIcon, testId, value, }: Props): JSX.Element;
|
|
106
111
|
export {};
|
package/dist/es/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { StyleSheet } from 'aphrodite';
|
|
4
4
|
import { CompactCell, DetailCell } from '@khanacademy/wonder-blocks-cell';
|
|
5
5
|
import * as tokens from '@khanacademy/wonder-blocks-tokens';
|
|
6
|
-
import { spacing, color, mix, fade, font, border } from '@khanacademy/wonder-blocks-tokens';
|
|
6
|
+
import { spacing, color, mix, fade, font, border, semanticColor } from '@khanacademy/wonder-blocks-tokens';
|
|
7
7
|
import { LabelMedium, LabelSmall, LabelLarge } from '@khanacademy/wonder-blocks-typography';
|
|
8
8
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
9
9
|
import { View, addStyle, IDProvider, useUniqueIdWithMock } from '@khanacademy/wonder-blocks-core';
|
|
@@ -2845,6 +2845,7 @@ function Combobox({
|
|
|
2845
2845
|
opened,
|
|
2846
2846
|
placeholder,
|
|
2847
2847
|
selectionType = "single",
|
|
2848
|
+
startIcon,
|
|
2848
2849
|
testId,
|
|
2849
2850
|
value = ""
|
|
2850
2851
|
}) {
|
|
@@ -2988,6 +2989,20 @@ function Combobox({
|
|
|
2988
2989
|
}
|
|
2989
2990
|
return [labelFromSelected];
|
|
2990
2991
|
}, [children, labelFromSelected, selected]);
|
|
2992
|
+
const maybeRenderStartIcon = () => {
|
|
2993
|
+
var _startIcon$props$colo;
|
|
2994
|
+
if (!startIcon) {
|
|
2995
|
+
return null;
|
|
2996
|
+
}
|
|
2997
|
+
const startIconElement = React.cloneElement(startIcon, _extends({
|
|
2998
|
+
size: "small"
|
|
2999
|
+
}, startIcon.props, {
|
|
3000
|
+
color: disabled ? color.offBlack32 : (_startIcon$props$colo = startIcon.props.color) != null ? _startIcon$props$colo : semanticColor.icon.primary
|
|
3001
|
+
}));
|
|
3002
|
+
return React.createElement(View, {
|
|
3003
|
+
style: styles.iconWrapper
|
|
3004
|
+
}, startIconElement);
|
|
3005
|
+
};
|
|
2991
3006
|
const pillIdPrefix = id ? `${id}-pill-` : ids.get("pill");
|
|
2992
3007
|
const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
|
|
2993
3008
|
const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
|
|
@@ -3016,7 +3031,7 @@ function Combobox({
|
|
|
3016
3031
|
disabled: disabled,
|
|
3017
3032
|
testId: testId,
|
|
3018
3033
|
removeSelectedLabel: labels.removeSelected
|
|
3019
|
-
}), React.createElement(TextField, {
|
|
3034
|
+
}), maybeRenderStartIcon(), React.createElement(TextField, {
|
|
3020
3035
|
id: ids.get("input"),
|
|
3021
3036
|
testId: testId,
|
|
3022
3037
|
style: styles.combobox,
|
|
@@ -3154,6 +3169,10 @@ const styles = StyleSheet.create({
|
|
|
3154
3169
|
},
|
|
3155
3170
|
clearButton: {
|
|
3156
3171
|
right: spacing.xLarge_32 + spacing.xSmall_8
|
|
3172
|
+
},
|
|
3173
|
+
iconWrapper: {
|
|
3174
|
+
padding: spacing.xxxSmall_4,
|
|
3175
|
+
minWidth: "auto"
|
|
3157
3176
|
}
|
|
3158
3177
|
});
|
|
3159
3178
|
|
package/dist/index.js
CHANGED
|
@@ -2881,6 +2881,7 @@ function Combobox({
|
|
|
2881
2881
|
opened,
|
|
2882
2882
|
placeholder,
|
|
2883
2883
|
selectionType = "single",
|
|
2884
|
+
startIcon,
|
|
2884
2885
|
testId,
|
|
2885
2886
|
value = ""
|
|
2886
2887
|
}) {
|
|
@@ -3024,6 +3025,20 @@ function Combobox({
|
|
|
3024
3025
|
}
|
|
3025
3026
|
return [labelFromSelected];
|
|
3026
3027
|
}, [children, labelFromSelected, selected]);
|
|
3028
|
+
const maybeRenderStartIcon = () => {
|
|
3029
|
+
var _startIcon$props$colo;
|
|
3030
|
+
if (!startIcon) {
|
|
3031
|
+
return null;
|
|
3032
|
+
}
|
|
3033
|
+
const startIconElement = React__namespace.cloneElement(startIcon, _extends__default["default"]({
|
|
3034
|
+
size: "small"
|
|
3035
|
+
}, startIcon.props, {
|
|
3036
|
+
color: disabled ? tokens.color.offBlack32 : (_startIcon$props$colo = startIcon.props.color) != null ? _startIcon$props$colo : tokens.semanticColor.icon.primary
|
|
3037
|
+
}));
|
|
3038
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
3039
|
+
style: styles.iconWrapper
|
|
3040
|
+
}, startIconElement);
|
|
3041
|
+
};
|
|
3027
3042
|
const pillIdPrefix = id ? `${id}-pill-` : ids.get("pill");
|
|
3028
3043
|
const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null ? void 0 : (_renderList$focusedIn2 = _renderList$focusedIn.props) == null ? void 0 : _renderList$focusedIn2.id : pillIdPrefix + focusedMultiSelectIndex;
|
|
3029
3044
|
const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
|
|
@@ -3052,7 +3067,7 @@ function Combobox({
|
|
|
3052
3067
|
disabled: disabled,
|
|
3053
3068
|
testId: testId,
|
|
3054
3069
|
removeSelectedLabel: labels.removeSelected
|
|
3055
|
-
}), React__namespace.createElement(wonderBlocksForm.TextField, {
|
|
3070
|
+
}), maybeRenderStartIcon(), React__namespace.createElement(wonderBlocksForm.TextField, {
|
|
3056
3071
|
id: ids.get("input"),
|
|
3057
3072
|
testId: testId,
|
|
3058
3073
|
style: styles.combobox,
|
|
@@ -3190,6 +3205,10 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
3190
3205
|
},
|
|
3191
3206
|
clearButton: {
|
|
3192
3207
|
right: tokens.spacing.xLarge_32 + tokens.spacing.xSmall_8
|
|
3208
|
+
},
|
|
3209
|
+
iconWrapper: {
|
|
3210
|
+
padding: tokens.spacing.xxxSmall_4,
|
|
3211
|
+
minWidth: "auto"
|
|
3193
3212
|
}
|
|
3194
3213
|
});
|
|
3195
3214
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@khanacademy/wonder-blocks-core": "^7.0.1",
|
|
22
22
|
"@khanacademy/wonder-blocks-icon": "^4.2.0",
|
|
23
23
|
"@khanacademy/wonder-blocks-layout": "^2.2.2",
|
|
24
|
-
"@khanacademy/wonder-blocks-modal": "^5.1.
|
|
24
|
+
"@khanacademy/wonder-blocks-modal": "^5.1.17",
|
|
25
25
|
"@khanacademy/wonder-blocks-pill": "^2.5.3",
|
|
26
26
|
"@khanacademy/wonder-blocks-search-field": "^2.3.6",
|
|
27
27
|
"@khanacademy/wonder-blocks-timing": "^5.0.2",
|