UNPKG

@procore/core-react

Version:
311 lines • 12.4 kB
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } import React from 'react'; import { Box } from '../Box/Box'; import { Dropdown } from '../Dropdown/Dropdown'; import { DropdownFlyout } from '../DropdownFlyout/DropdownFlyout'; import { MultiSelect } from '../MultiSelect/MultiSelect'; import { PillSelect } from '../PillSelect/PillSelect'; import { useId } from '@react-aria/utils'; import { Button } from '../Button'; import { Content } from '../Content'; import { Actions } from '../Content/Content'; import { Field } from '../Field'; import { Flex } from '../Flex'; import { Form } from '../Form'; import { Link } from '../Link'; import { Popover } from '../Popover'; import { Search } from '../Search/Search'; import { Select } from '../Select/Select'; import { H3, Label } from '../Semantic'; import { SuperSelect } from '../SuperSelect/SuperSelect'; import { TieredSelect } from '../TieredSelect/TieredSelect'; import { Tooltip } from '../Tooltip'; import { Typeahead } from '../Typeahead'; var idLabelOptions = [{ id: 1, label: 'One' }, { id: 2, label: 'Two' }, { id: 3, label: 'Three' }]; export function EscapefulFieldSet() { var _React$useState = React.useState(''), _React$useState2 = _slicedToArray(_React$useState, 2), typeaheadV = _React$useState2[0], setTyeahead = _React$useState2[1]; var baseId = useId(); return /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(H3, null, "Things with Esc key:"), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-search") }, "Search"), /*#__PURE__*/React.createElement(Search, { "aria-labelledby": "".concat(baseId, "-search") })), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-typeahead") }, "Typeahead"), /*#__PURE__*/React.createElement(Typeahead, { value: typeaheadV, onChange: setTyeahead, "aria-labelledby": "".concat(baseId, "-typeahead") })), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-select") }, "Select"), /*#__PURE__*/React.createElement(Flex, { gap: "sm" }, /*#__PURE__*/React.createElement(Box, { id: "s-default" }, "Default"), /*#__PURE__*/React.createElement(Select, { "aria-labelledby": "".concat(baseId, "-select s-default") }, idLabelOptions.map(function (_ref) { var id = _ref.id, label = _ref.label; return /*#__PURE__*/React.createElement(Select.Option, { key: id, value: id }, label); })), /*#__PURE__*/React.createElement(Box, { id: "s-search" }, "Search"), /*#__PURE__*/React.createElement(Select, { onSearch: console.log, "aria-labelledby": "".concat(baseId, "-select s-search") }, idLabelOptions.map(function (_ref2) { var id = _ref2.id, label = _ref2.label; return /*#__PURE__*/React.createElement(Select.Option, { key: id, value: id }, label); }), ' '))), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-pillselect") }, "PillSelect"), /*#__PURE__*/React.createElement(Flex, { gap: "sm" }, /*#__PURE__*/React.createElement(Box, { id: "p-default" }, "Default"), /*#__PURE__*/React.createElement(PillSelect, { options: idLabelOptions, onChange: console.log, value: null, "aria-labelledby": "".concat(baseId, "-pillselect p-default") }), /*#__PURE__*/React.createElement(Box, { id: "p-search" }, "Search"), /*#__PURE__*/React.createElement(PillSelect, { options: idLabelOptions, onChange: console.log, onSearch: console.log, value: null, "aria-labelledby": "".concat(baseId, "-pillselect p-search") }))), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-multiselect") }, "MultiSelect"), /*#__PURE__*/React.createElement(MultiSelect, { options: idLabelOptions, "aria-labelledby": "".concat(baseId, "-multiselect") })), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-dropdown") }, "Dropdown"), /*#__PURE__*/React.createElement(Flex, { gap: "sm", wrap: "wrap" }, /*#__PURE__*/React.createElement(Box, null, "Default"), /*#__PURE__*/React.createElement(Dropdown, { "aria-labelledby": "".concat(baseId, "-dropdown") }, idLabelOptions.map(function (_ref3) { var id = _ref3.id, label = _ref3.label; return /*#__PURE__*/React.createElement(Dropdown.Item, { key: id, item: id }, label); })), /*#__PURE__*/React.createElement(Box, null, "Search"), /*#__PURE__*/React.createElement(Dropdown, { onSearch: console.log, "aria-labelledby": "".concat(baseId, "-dropdown") }, idLabelOptions.map(function (_ref4) { var id = _ref4.id, label = _ref4.label; return /*#__PURE__*/React.createElement(Dropdown.Item, { key: id, item: id }, label); })), /*#__PURE__*/React.createElement(Box, null, "Restore"), /*#__PURE__*/React.createElement(Dropdown, { restoreFocusOnHide: true, "aria-labelledby": "".concat(baseId, "-dropdown") }, idLabelOptions.map(function (_ref5) { var id = _ref5.id, label = _ref5.label; return /*#__PURE__*/React.createElement(Dropdown.Item, { key: id, item: id }, label); })), /*#__PURE__*/React.createElement(Box, null, "Restore w/ search"), /*#__PURE__*/React.createElement(Dropdown, { onSearch: console.log, restoreFocusOnHide: true, "aria-labelledby": "".concat(baseId, "-dropdown") }, idLabelOptions.map(function (_ref6) { var id = _ref6.id, label = _ref6.label; return /*#__PURE__*/React.createElement(Dropdown.Item, { key: id, item: id }, label); })), /*#__PURE__*/React.createElement(Box, null, "DropdownFlyout"), /*#__PURE__*/React.createElement(DropdownFlyout, { style: { display: 'inline-block' }, options: [{ value: 1, label: 'wow' }, { value: 'Animals', label: 'Long complicated label that takes space', children: [{ value: 'Amphibians', label: 'Amphibians', children: [{ value: 1, label: 'Frogs' }, { value: 2, label: 'Salamanders' }] }, { value: 'Birds', label: 'Long complicated label that takes space', children: [{ value: 3, label: 'Chickens' }, { value: 4, label: 'Falcons' }, { value: 5, label: 'Owls' }, { value: 6, label: 'Parrots' }] }] }], "aria-labelledby": "".concat(baseId, "-dropdown") }))), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-tiered") }, "Tiered"), /*#__PURE__*/React.createElement(TieredSelect, { options: [{ id: 1, groupId: null, nextGroupId: 10, label: 'Apple Farm', disabled: true }, { id: 17, groupId: 10, nextGroupId: 100, label: 'Granny Smith' }, { id: 2, groupId: null, nextGroupId: 20, label: "Tim's Trees" }], "aria-labelledby": "".concat(baseId, "-tiered") })), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-tiered-leaf") }, "Tiered leaf only"), /*#__PURE__*/React.createElement(TieredSelect, { selectableTiers: false, options: [{ id: 1, groupId: null, nextGroupId: 10, label: 'Apple Farm', disabled: true }, { id: 17, groupId: 10, nextGroupId: 100, label: 'Granny Smith' }, { id: 2, groupId: null, nextGroupId: 20, label: "Tim's Trees" }], "aria-labelledby": "".concat(baseId, "-tiered-leaf") })), /*#__PURE__*/React.createElement(Field, null, /*#__PURE__*/React.createElement(Label, { id: "".concat(baseId, "-superselect") }, "SuperSelect"), /*#__PURE__*/React.createElement(SuperSelect, { onChange: console.log, options: [{ value: '1', label: 'some label one' }, { value: '2', label: 'two 2' }, { value: '3', label: 'three three three' }], emptyMessage: "E m p t y", "aria-labelledby": "".concat(baseId, "-superselect") }))); } function PopupSet(_ref7) { var _ref7$alignLeft = _ref7.alignLeft, alignLeft = _ref7$alignLeft === void 0 ? true : _ref7$alignLeft; var baseId = useId(); var id = { pop1: baseId + 'pop1', pop2: baseId + 'pop2' }; return /*#__PURE__*/React.createElement(Actions, { style: { // TODO new prop. sometimes left actions could make sense justifyContent: alignLeft ? 'flex-start' : undefined, // why not, different sizes (Switch) just align them alignItems: 'center' } }, /*#__PURE__*/React.createElement(Tooltip, { overlay: "Tooltip popup here, checks out.", role: "tooltip", trigger: ['focus', 'hover'] }, /*#__PURE__*/React.createElement(Button, { variant: "secondary", onClick: alert.bind(null, 'CORE') }, "Tooltip!")), /*#__PURE__*/React.createElement(Tooltip, { overlay: "Long name never gonna give you up.mp4", role: "tooltip", trigger: ['focus', 'hover'] }, /*#__PURE__*/React.createElement(Link, { href: "#" }, "Long name....up.mp4")), /*#__PURE__*/React.createElement(Popover, { "aria-labelledby": id.pop1, restoreFocusOnHide: true, role: "dialog", overlay: /*#__PURE__*/React.createElement(Popover.Content, null, /*#__PURE__*/React.createElement(Box, { padding: "sm" }, "Popover popup here, check out this", ' ', /*#__PURE__*/React.createElement(Link, { href: "https://app.procore.com" }, "app link"), " and", ' ', /*#__PURE__*/React.createElement(Link, { href: "https://login.procore.com" }, "login link"), ".")), trigger: ['click'] }, /*#__PURE__*/React.createElement(Button, { "aria-haspopup": "dialog", id: id.pop1, variant: "secondary" }, "Click to Popup!"))); } export function UserInteractionSet() { return /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(PopupSet, null), /*#__PURE__*/React.createElement(Form, { enableConfirmNavigation: true, initialValues: { rtf: '<b>Clicking the TinyMCE option to add a link should open a modal, and that modal should be able to receive focus.</b>' } }, /*#__PURE__*/React.createElement(Form.Row, null, /*#__PURE__*/React.createElement(Form.DateSelect, { colWidth: 12, description: "Form Field with misc interactions", label: "Form Component Field", name: "f_1", tooltip: "Tooltip popup here, checks out." }))), /*#__PURE__*/React.createElement(EscapefulFieldSet, null)); } //# sourceMappingURL=storyHelpers.js.map