@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
61 lines • 1.95 kB
JavaScript
var _jsxFileName = "/home/runner/work/frontend-shared/frontend-shared/src/pattern-library/examples/select-truncate-listbox.tsx";
import { useId, useState } from 'preact/hooks';
import { Select } from '../..';
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "preact/jsx-dev-runtime";
const items = [{
id: '1',
name: 'All students - content is very long and will not fit the listbox'
}, {
id: '2',
name: 'Albert Banana - content is very long and will not fit the listbox'
}, {
id: '3',
name: 'Bernard California - content is very long and will not fit the listbox'
}, {
id: '4',
name: 'Cecelia Davenport - content is very long and will not fit the listbox'
}, {
id: '5',
name: 'Doris Evanescence - content is very long and will not fit the listbox'
}];
export default function App() {
const [value, setSelected] = useState();
const selectId = useId();
return _jsxDEV("div", {
className: "w-96 mx-auto",
children: [_jsxDEV("label", {
htmlFor: selectId,
children: "Select a person"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 34,
columnNumber: 7
}, this), _jsxDEV(Select, {
value: value,
onChange: newValue => setSelected(newValue),
buttonId: selectId,
buttonContent: value ? value.name : _jsxDEV(_Fragment, {
children: "Select one\u2026"
}, void 0, false),
popoverClasses: "w-36",
listboxOverflow: "truncate",
children: items.map(item => _jsxDEV(Select.Option, {
value: item,
children: item.name
}, item.id, false, {
fileName: _jsxFileName,
lineNumber: 44,
columnNumber: 11
}, this))
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 35,
columnNumber: 7
}, this)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 33,
columnNumber: 5
}, this);
}
//# sourceMappingURL=select-truncate-listbox.js.map