@navinc/base-react-components
Version:
Nav's Pattern Library
28 lines • 1.58 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { Select, SelectItem } from './select.js';
import { withInputWrapper } from '../input/index.js';
import { styledBackwardsCompatibility } from '../../styled-backwards-compatibility.js';
export const isSimpleSelectOptionObject = (option) => typeof option === 'object' && 'label' in option;
export const SimpleSelect = styledBackwardsCompatibility(forwardRef((_a, ref) => {
var { options } = _a, props = __rest(_a, ["options"]);
return (_jsx(Select, Object.assign({ ref: ref }, props, { children: options === null || options === void 0 ? void 0 : options.map((option) => {
const { label, value, disabled } = isSimpleSelectOptionObject(option)
? option
: { label: option, value: option, disabled: false };
return (_jsx(SelectItem, { value: value, disabled: disabled, children: label }, `${label}:${value}`));
}) })));
}));
export const SimpleSelectField = withInputWrapper(SimpleSelect);
//# sourceMappingURL=simple-select.js.map