@adamjanicki/ui 1.7.0 → 1.7.2
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.
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { type BoxProps } from "../Box/Box";
|
|
3
3
|
import ui from "../ui";
|
|
4
4
|
type SelectProps = React.ComponentProps<typeof ui.select>;
|
|
5
|
-
type Props = Omit<BoxProps, "children"> & {
|
|
5
|
+
type Props = Omit<BoxProps, "children" | "onChange"> & {
|
|
6
6
|
/**
|
|
7
7
|
* Array of options to display in the select
|
|
8
8
|
*/
|
|
@@ -14,10 +14,18 @@ type Props = Omit<BoxProps, "children"> & {
|
|
|
14
14
|
* @returns the label of the option
|
|
15
15
|
*/
|
|
16
16
|
getOptionLabel?: (option: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Current value of the select
|
|
19
|
+
*/
|
|
20
|
+
value?: SelectProps["value"];
|
|
21
|
+
/**
|
|
22
|
+
* Change handler for the select
|
|
23
|
+
*/
|
|
24
|
+
onChange?: SelectProps["onChange"];
|
|
17
25
|
/**
|
|
18
26
|
* Props to pass to the underlying select element
|
|
19
27
|
*/
|
|
20
|
-
selectProps?: SelectProps
|
|
28
|
+
selectProps?: Omit<SelectProps, "value" | "onChange">;
|
|
21
29
|
};
|
|
22
30
|
declare const Select: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
23
31
|
export default Select;
|
|
@@ -27,8 +27,8 @@ import Box from "../Box/Box";
|
|
|
27
27
|
import Icon from "../Icon";
|
|
28
28
|
import ui from "../ui";
|
|
29
29
|
var Select = React.forwardRef(function (_a, ref) {
|
|
30
|
-
var className = _a.className, options = _a.options, vfx = _a.vfx, getOptionLabel = _a.getOptionLabel, selectProps = _a.selectProps, rest = __rest(_a, ["className", "options", "vfx", "getOptionLabel", "selectProps"]);
|
|
30
|
+
var className = _a.className, options = _a.options, vfx = _a.vfx, getOptionLabel = _a.getOptionLabel, selectProps = _a.selectProps, value = _a.value, onChange = _a.onChange, rest = __rest(_a, ["className", "options", "vfx", "getOptionLabel", "selectProps", "value", "onChange"]);
|
|
31
31
|
var selectClassName = (selectProps || {}).className;
|
|
32
|
-
return (_jsxs(Box, __assign({ vfx: __assign({ pos: "relative", width: "fit", axis: "x", align: "center", radius: "rounded", backgroundColor: "default", color: "default", padding: "none" }, vfx), className: classNames("aui-select-container", (selectProps === null || selectProps === void 0 ? void 0 : selectProps.disabled) ? "aui-select-disabled" : undefined, className) }, rest, { children: [_jsx(ui.select, __assign({}, selectProps, { className: classNames("aui-select", selectClassName), ref: ref, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "chevron-down", className: "aui-select-icon", "aria-hidden": true })] })));
|
|
32
|
+
return (_jsxs(Box, __assign({ vfx: __assign({ pos: "relative", width: "fit", axis: "x", align: "center", radius: "rounded", backgroundColor: "default", color: "default", padding: "none" }, vfx), className: classNames("aui-select-container", (selectProps === null || selectProps === void 0 ? void 0 : selectProps.disabled) ? "aui-select-disabled" : undefined, className) }, rest, { children: [_jsx(ui.select, __assign({}, selectProps, { value: value, onChange: onChange, className: classNames("aui-select", selectClassName), ref: ref, children: options.map(function (option, index) { return (_jsx("option", { value: option, children: (getOptionLabel === null || getOptionLabel === void 0 ? void 0 : getOptionLabel(option)) || option }, index)); }) })), _jsx(Icon, { icon: "chevron-down", className: "aui-select-icon", "aria-hidden": true })] })));
|
|
33
33
|
});
|
|
34
34
|
export default Select;
|