@loadsmart/loadsmart-ui 7.3.2 → 7.4.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.
Files changed (116) hide show
  1. package/dist/common/BackButton/BackButton.d.ts +1 -0
  2. package/dist/common/CloseButton/CloseButton.d.ts +1 -0
  3. package/dist/components/Accordion/Accordion.stories.d.ts +2 -1
  4. package/dist/components/Banner/Banner.d.ts +1 -1
  5. package/dist/components/Banner/Banner.stories.d.ts +1 -1
  6. package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +2 -2
  7. package/dist/components/Button/Button.stories.d.ts +1 -1
  8. package/dist/components/Calendar/Calendar.d.ts +1 -0
  9. package/dist/components/Calendar/Calendar.stories.d.ts +3 -2
  10. package/dist/components/Calendar/PickerModeToggle.d.ts +1 -0
  11. package/dist/components/Calendar/Pickers/DayPicker.d.ts +1 -0
  12. package/dist/components/Calendar/Pickers/MonthPicker.d.ts +1 -0
  13. package/dist/components/Calendar/Pickers/YearPicker.d.ts +1 -0
  14. package/dist/components/Card/Card.stories.d.ts +1 -1
  15. package/dist/components/Checkbox/Checkbox.stories.d.ts +2 -1
  16. package/dist/components/DatePicker/DatePicker.stories.d.ts +2 -1
  17. package/dist/components/DatePicker/DateRangePicker.d.ts +1 -0
  18. package/dist/components/DatePicker/DateRangePicker.stories.d.ts +2 -1
  19. package/dist/components/DatePicker/useDatePicker.d.ts +102 -102
  20. package/dist/components/DatePicker/useDateRangePicker.d.ts +153 -154
  21. package/dist/components/Dialog/Dialog.stories.d.ts +2 -1
  22. package/dist/components/DragDropFile/DragDropFile.stories.d.ts +2 -1
  23. package/dist/components/DragDropFile/components/DropZone.d.ts +1 -0
  24. package/dist/components/DragDropFile/components/FileItem.d.ts +1 -0
  25. package/dist/components/DragDropFile/components/FileList.d.ts +1 -0
  26. package/dist/components/DragDropFile/styles.d.ts +1 -1
  27. package/dist/components/Drawer/Drawer.stories.d.ts +1 -1
  28. package/dist/components/EmptyState/EmptyState.stories.d.ts +2 -1
  29. package/dist/components/ErrorMessage/ErrorMessage.stories.d.ts +2 -1
  30. package/dist/components/HighlightMatch/HighlightMatch.stories.d.ts +1 -1
  31. package/dist/components/Icon/Icon.d.ts +2 -1
  32. package/dist/components/IconFactory/IconFactory.d.ts +2 -1
  33. package/dist/components/IconFactory/IconFactory.stories.d.ts +1 -1
  34. package/dist/components/Label/Label.stories.d.ts +2 -1
  35. package/dist/components/Layout/Layout.stories.d.ts +2 -1
  36. package/dist/components/Link/Link.stories.d.ts +2 -1
  37. package/dist/components/Loaders/LoadingBar.stories.d.ts +1 -1
  38. package/dist/components/Loaders/LoadingDots.d.ts +1 -0
  39. package/dist/components/Loaders/LoadingDots.stories.d.ts +1 -1
  40. package/dist/components/Loaders/Spinner.d.ts +1 -0
  41. package/dist/components/Loaders/Spinner.stories.d.ts +1 -1
  42. package/dist/components/Modal/Modal.stories.d.ts +2 -1
  43. package/dist/components/Pagination/Pagination.d.ts +1 -0
  44. package/dist/components/Pagination/Pagination.stories.d.ts +1 -1
  45. package/dist/components/Pagination/PaginationItem.d.ts +1 -0
  46. package/dist/components/Popover/Popover.d.ts +1 -0
  47. package/dist/components/Popover/Popover.stories.d.ts +1 -1
  48. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +2 -1
  49. package/dist/components/Radio/Radio.stories.d.ts +2 -1
  50. package/dist/components/Section/Sections.stories.d.ts +2 -1
  51. package/dist/components/Select/Select.stories.d.ts +1 -1
  52. package/dist/components/Select/SelectCreatableOption.d.ts +1 -0
  53. package/dist/components/Select/SelectEmpty.d.ts +1 -0
  54. package/dist/components/Select/SelectOption.d.ts +1 -0
  55. package/dist/components/SideNavigation/Separator/Separator.d.ts +1 -0
  56. package/dist/components/SideNavigation/SideNavigation.stories.d.ts +2 -1
  57. package/dist/components/Steps/ProgressSteps/ProgressSteps.d.ts +1 -0
  58. package/dist/components/Steps/Steps.stories.d.ts +1 -1
  59. package/dist/components/Switch/Switch.stories.d.ts +1 -1
  60. package/dist/components/Table/Table.d.ts +1 -0
  61. package/dist/components/Table/Table.stories.d.ts +2 -1
  62. package/dist/components/Table/TableSortHandle.d.ts +1 -0
  63. package/dist/components/TablePagination/RowsPerPage.d.ts +1 -0
  64. package/dist/components/TablePagination/TablePagination.d.ts +1 -0
  65. package/dist/components/TablePagination/TablePagination.stories.d.ts +1 -1
  66. package/dist/components/TablePagination/TablePaginationActions.d.ts +2 -1
  67. package/dist/components/Tabs/Tabs.stories.d.ts +2 -1
  68. package/dist/components/Tag/Tag.stories.d.ts +1 -1
  69. package/dist/components/Text/Text.stories.d.ts +6 -4
  70. package/dist/components/TextField/TextField.stories.d.ts +2 -1
  71. package/dist/components/Textarea/Textarea.stories.d.ts +2 -1
  72. package/dist/components/Toast/Toast.stories.d.ts +2 -1
  73. package/dist/components/ToggleGroup/Toggle.d.ts +1 -0
  74. package/dist/components/ToggleGroup/ToggleGroup.d.ts +1 -0
  75. package/dist/components/ToggleGroup/ToggleGroup.stories.d.ts +1 -1
  76. package/dist/components/Tooltip/Tooltip.stories.d.ts +2 -1
  77. package/dist/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.d.ts +1 -0
  78. package/dist/components/TopNavigation/TopNavigation.stories.d.ts +1 -0
  79. package/dist/components/VisuallyHidden/VisuallyHidden.stories.d.ts +1 -0
  80. package/dist/hooks/useFocusTrap/useFocusTrap.stories.d.ts +1 -1
  81. package/dist/index.js +733 -733
  82. package/dist/index.js.map +1 -1
  83. package/dist/miranda-compatibility.theme-ce3baf7f.js +2 -0
  84. package/dist/miranda-compatibility.theme-ce3baf7f.js.map +1 -0
  85. package/dist/prop-d9ec2877.js +2 -0
  86. package/dist/{prop-597d4792.js.map → prop-d9ec2877.js.map} +1 -1
  87. package/dist/testing/index.js +1 -1
  88. package/dist/testing/index.js.map +1 -1
  89. package/dist/theming/index.js +1 -1
  90. package/dist/theming/index.js.map +1 -1
  91. package/dist/tools/index.js +1 -1
  92. package/dist/utils/toolset/flatten.d.ts +2 -1
  93. package/dist/utils/toolset/get.d.ts +2 -1
  94. package/dist/utils/toolset/highlightMatch.d.ts +1 -0
  95. package/dist/utils/toolset/isEmpty.d.ts +2 -1
  96. package/dist/utils/toolset/omit.d.ts +2 -1
  97. package/dist/utils/toolset/range.d.ts +2 -1
  98. package/package.json +25 -31
  99. package/src/components/Dropdown/Dropdown.stories.tsx +1 -2
  100. package/src/components/IconFactory/IconFactory.tsx +2 -2
  101. package/src/components/Select/Select.constants.ts +2 -2
  102. package/src/components/Select/Select.stories.tsx +1 -1
  103. package/src/components/Steps/useSteps.ts +1 -1
  104. package/src/components/Tag/Tag.tsx +1 -1
  105. package/src/components/Text/Text.stories.tsx +29 -25
  106. package/src/hooks/useSelectable/SelectableStrategy.ts +1 -1
  107. package/src/utils/toolset/flatten.ts +3 -1
  108. package/src/utils/toolset/get.ts +2 -1
  109. package/src/utils/toolset/isEmpty.ts +2 -1
  110. package/src/utils/toolset/omit.ts +2 -1
  111. package/src/utils/toolset/range.ts +2 -1
  112. package/dist/miranda-compatibility.theme-8689186b.js +0 -2
  113. package/dist/miranda-compatibility.theme-8689186b.js.map +0 -1
  114. package/dist/prop-597d4792.js +0 -2
  115. package/dist/utils/toolset/debounce.d.ts +0 -1
  116. package/src/utils/toolset/debounce.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","/* eslint-disable */\nimport { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string | RegExp} option - Label for the option to be selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement && optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string} option - Label for the option to be unselected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement && optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n if (clearButton) {\n fireEvent.click(clearButton)\n }\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param {string} query - Search term.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch (err) {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import React, { ReactNode } from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param {Interpolation<ThemeProps<CustomTheme>>} styles - A `css` reference with interpolated styles\n * @returns {string} The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","datePickerEvent","getContainer","day","act","focus","dayElement","getByLabelText","getAttribute","clearButton","selectedDays","queryAllByRole","checked","DatePickerEvent","dateRangePickerEvent","pick","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","clear","getSelectedDates","getDropZoneFromInput","DragDropFileEvent","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","Object","defineProperty","value","toArray","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","selectEvent","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","err","isMenuExpanded","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","styles","map","interpolation","isFunction","theme","Alice","join","ui","customContext","contextValue","assign","render","React","createElement","DragDropFileContext","Provider"],"mappings":"+WAGA,SAASA,EAAsBC,GAE7B,OAAOA,EAAMC,WAAYA,WAAYA,WAAYA,UACn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AAjB,GAA4Be,GAMtD,OAAOG,UAJapD,EAIKgD,EAHvBK,EAAAA,QAACC,cAAAC,EAAAA,oBAAoBC,SAAQ,CAAChE,MAAO0D,GAAelD,KADnC,IAACA,CAIS"}
1
+ {"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","/* eslint-disable */\nimport { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string | RegExp} option - Label for the option to be selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement && optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string} option - Label for the option to be unselected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement && optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n if (clearButton) {\n fireEvent.click(clearButton)\n }\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param {string} query - Search term.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch (err) {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import React, { ReactNode } from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param {Interpolation<ThemeProps<CustomTheme>>} styles - A `css` reference with interpolated styles\n * @returns {string} The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","datePickerEvent","getContainer","day","act","focus","dayElement","getByLabelText","getAttribute","clearButton","selectedDays","queryAllByRole","checked","DatePickerEvent","dateRangePickerEvent","pick","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","clear","getSelectedDates","getDropZoneFromInput","DragDropFileEvent","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","Object","defineProperty","value","toArray","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","selectEvent","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","err","isMenuExpanded","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","styles","map","interpolation","isFunction","theme","Alice","join","ui","customContext","contextValue","assign","render","React","createElement","DragDropFileContext","Provider"],"mappings":"wYAGA,SAASA,EAAsBC,GAE7B,OAAOA,EAAMC,WAAYA,WAAYA,WAAYA,UACnD,CAOA,SAAeC,EAAOF,sDACpB,MAAMG,EAAsBJ,EAAsBC,GAG9CI,UAAQC,YAAYF,EAAqB,UAI7CG,YAAUC,MAAMP,SAEVQ,EAAOA,SAAC,KACZC,OAAOL,EAAOA,QAACM,UAAUP,EAAqB,SAASQ,mBAAmB,OAE7E,CAOD,SAAeC,EAASZ,sDACtB,MAAMG,EAAsBJ,EAAsBC,GAG7CI,EAAAA,QAAQC,YAAYF,EAAqB,UAI9CG,EAASA,UAACC,MAAMH,EAAOA,QAACS,UAAUV,EAAqB,gBAEjDK,EAAOA,SAAC,KACZC,OAAOL,EAAAA,QAAQC,YAAYF,EAAqB,SAASW,IAAIH,mBAAmB,OAEnF,CA6DD,MAAMI,EAAkB,CACtBC,aAAcjB,SACdG,WACAU,OAvDF,SAAoBK,EAAajB,sDAC/B,MAAMG,EAAsBJ,EAAsBC,SAE5CE,EAAOF,GAEbkB,EAAAA,KAAI,KACFlB,EAAMmB,OAAO,IAGf,MAAMC,EAAahB,EAAOA,QAACiB,eAAelB,EAAqBc,GAE3DG,GAAyD,SAA3CA,E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GAEb,MAAM6E,EAAgBrB,EAAcxD,GACpC,IAAI2F,EAAiC,GAErC,IACEA,QAAwB1B,EAAMA,OAACY,GAAeU,cAAc,SAAU,CACpEK,UAAU,GAEb,CAAC,MAAOC,GACPF,EAAkB,EACnB,CAID,aAFM/E,EAASZ,GAER2F,IACR,EAWCG,eAAgBlC,GC7PlB,MAAMmC,EAAoD,CACxDC,SAAU,GACVC,aAAcC,KAAKC,KACnBC,cAAeF,KAAKC,KACpBE,aAAcH,KAAKC,+ICGG,SAAsBG,GAC5C,OAAOhD,EAAAA,QAAQgD,GACZC,KAAKC,IACJ,KAAOC,EAAAA,WAAWD,IAChBA,EAAgBA,EAAc,CAAEE,MAAOC,EAAAA,QAGzC,OAAOH,CAAa,IAErBI,KAAK,GACV,yCDVuC,CACrCC,EACAC,KAEA,MAAMC,EAAoB5D,OAAA6D,OAAA7D,OAAA6D,OAAA,GAAAjB,GAA4Be,GAMtD,OAAOG,UAJapD,EAIKgD,EAHvBK,EAAAA,QAACC,cAAAC,EAAAA,oBAAoBC,SAAQ,CAAChE,MAAO0D,GAAelD,KADnC,IAACA,CAIS"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../miranda-compatibility.theme-8689186b.js");require("@loadsmart/miranda-tokens");var t=Object.freeze({__proto__:null,Alice:e.alice,Loadsmart:e.loadsmart,Miranda:e.mirandaCompatibility});function r(t,r){const i=e.isFunction(t)?t(r):t;return r.theme[i]}exports.Themes=t,exports.getToken=function(e,t){return void 0===t?t=>r(e,t):r(e,t)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../miranda-compatibility.theme-ce3baf7f.js");require("@loadsmart/miranda-tokens"),require("lodash/get.js");var r=Object.freeze({__proto__:null,Alice:e.alice,Loadsmart:e.loadsmart,Miranda:e.mirandaCompatibility});function t(r,t){const a=e.isFunction(r)?r(t):r;return t.theme[a]}exports.Themes=r,exports.getToken=function(e,r){return void 0===r?r=>t(e,r):t(e,r)};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { isFunction } from '@loadsmart/utils-function'\n\nimport type { ThemeProps } from 'styled-components'\nimport type ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param {string} token - Token whose value should be returned.\n * @param {[ThemedStyledProps]} props - Component props.\n * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.\n */\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>\n): (props: TProps) => ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>,\n props: TProps\n): ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(token: any, props?: any): any {\n if (props === undefined) {\n return (props: TProps) => getTokenFromTheme(token, props)\n }\n\n return getTokenFromTheme(token, props)\n}\n\nexport * as Themes from './themes'\n"],"names":["getTokenFromTheme","token","props","tokenName","isFunction","theme","undefined"],"mappings":"8QAaA,SAASA,EAAyCC,EAAqBC,GACrE,MAAMC,EAAYC,EAAAA,WAAWH,GAASA,EAAMC,GAASD,EACrD,OAAOC,EAAMG,MAAMF,EACrB,mCAiBgB,SAAqCF,EAAYC,GAC/D,YAAcI,IAAVJ,EACMA,GAAkBF,EAAkBC,EAAOC,GAG9CF,EAAkBC,EAAOC,EAClC"}
1
+ {"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { isFunction } from '@loadsmart/utils-function'\n\nimport type { ThemeProps } from 'styled-components'\nimport type ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param {string} token - Token whose value should be returned.\n * @param {[ThemedStyledProps]} props - Component props.\n * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.\n */\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>\n): (props: TProps) => ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>,\n props: TProps\n): ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(token: any, props?: any): any {\n if (props === undefined) {\n return (props: TProps) => getTokenFromTheme(token, props)\n }\n\n return getTokenFromTheme(token, props)\n}\n\nexport * as Themes from './themes'\n"],"names":["getTokenFromTheme","token","props","tokenName","isFunction","theme","undefined"],"mappings":"uSAaA,SAASA,EAAyCC,EAAqBC,GACrE,MAAMC,EAAYC,EAAAA,WAAWH,GAASA,EAAMC,GAASD,EACrD,OAAOC,EAAMG,MAAMF,EACrB,mCAiBgB,SAAqCF,EAAYC,GAC/D,YAAcI,IAAVJ,EACMA,GAAkBF,EAAkBC,EAAOC,GAG9CF,EAAkBC,EAAOC,EAClC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-597d4792.js");require("../toArray-b56541b4.js"),require("../miranda-compatibility.theme-8689186b.js"),require("@loadsmart/miranda-tokens"),require("../theming/index.js"),exports.conditional=e.conditional,exports.prop=e.prop,exports.whenProps=e.whenProps;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-d9ec2877.js");require("../toArray-b56541b4.js"),require("../miranda-compatibility.theme-ce3baf7f.js"),require("@loadsmart/miranda-tokens"),require("lodash/get.js"),require("../theming/index.js"),exports.conditional=e.conditional,exports.prop=e.prop,exports.whenProps=e.whenProps;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
- export { default } from 'lodash.flatten';
1
+ import { flatten } from 'lodash';
2
+ export default flatten;
@@ -1 +1,2 @@
1
- export { default } from 'lodash.get';
1
+ import { get } from 'lodash';
2
+ export default get;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * A function that wraps a match into `mark` element to be highlighted.
3
4
  * @example
@@ -1 +1,2 @@
1
- export { default } from 'lodash.isempty';
1
+ import { isEmpty } from 'lodash';
2
+ export default isEmpty;
@@ -1 +1,2 @@
1
- export { default } from 'lodash.omit';
1
+ import { omit } from 'lodash';
2
+ export default omit;
@@ -1 +1,2 @@
1
- export { default } from 'lodash.range';
1
+ import { range } from 'lodash';
2
+ export default range;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadsmart/loadsmart-ui",
3
- "version": "7.3.2",
3
+ "version": "7.4.0",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -52,18 +52,21 @@
52
52
  "@commitlint/config-conventional": "^16.0.0",
53
53
  "@loadsmart/miranda-tokens": "^2.2.1",
54
54
  "@loadsmart/stylelint-config": "^0.0.3",
55
+ "@optimize-lodash/rollup-plugin": "^5.0.0",
55
56
  "@rollup/plugin-babel": "^5.3.0",
56
57
  "@rollup/plugin-commonjs": "^19.0.0",
57
58
  "@rollup/plugin-json": "^4.1.0",
58
59
  "@rollup/plugin-node-resolve": "^13.0.0",
60
+ "@rollup/plugin-terser": "^0.4.4",
59
61
  "@semantic-release/git": "^9.0.0",
60
- "@storybook/addon-a11y": "^7.0.17",
61
- "@storybook/addon-essentials": "^7.0.17",
62
- "@storybook/addon-links": "^7.0.17",
63
- "@storybook/addons": "^7.0.17",
64
- "@storybook/react": "^7.0.17",
65
- "@storybook/react-webpack5": "^7.0.17",
66
- "@storybook/theming": "^7.0.17",
62
+ "@storybook/addon-a11y": "^7.6.20",
63
+ "@storybook/addon-essentials": "^7.6.20",
64
+ "@storybook/addon-links": "^7.6.20",
65
+ "@storybook/addons": "^7.6.20",
66
+ "@storybook/client-api": "^7.6.20",
67
+ "@storybook/react": "^7.6.20",
68
+ "@storybook/react-webpack5": "^7.6.20",
69
+ "@storybook/theming": "^7.6.20",
67
70
  "@svgr/rollup": "^6.5.1",
68
71
  "@svgr/webpack": "^8.0.1",
69
72
  "@tailwindcss/postcss7-compat": "^2.1.2",
@@ -74,18 +77,12 @@
74
77
  "@testing-library/user-event": "^13.5.0",
75
78
  "@types/chance": "^1.1.1",
76
79
  "@types/jest": "^27.5.2",
77
- "@types/lodash.debounce": "^4.0.6",
78
- "@types/lodash.flatten": "^4.4.6",
79
- "@types/lodash.get": "^4.4.6",
80
- "@types/lodash.isempty": "^4.4.6",
81
- "@types/lodash.omit": "^4.5.6",
82
- "@types/lodash.range": "^3.2.6",
83
80
  "@types/mdx": "^2.0.2",
84
81
  "@types/node": "^18.11.18",
85
- "@types/react": "^17.0.59",
86
- "@types/react-dom": "^17.0.20",
82
+ "@types/react": "^17.0.83",
83
+ "@types/react-dom": "^17.0.25",
87
84
  "@types/react-test-renderer": "^17.0.1",
88
- "@types/styled-components": "^5.1.26",
85
+ "@types/styled-components": "^5.1.34",
89
86
  "@typescript-eslint/eslint-plugin": "^4.22.1",
90
87
  "@typescript-eslint/parser": "^4.22.1",
91
88
  "@zerollup/ts-transform-paths": "^1.7.18",
@@ -95,7 +92,6 @@
95
92
  "babel-plugin-react-remove-properties": "^0.3.0",
96
93
  "babel-plugin-styled-components": "^1.12.0",
97
94
  "babel-plugin-transform-inline-environment-variables": "^0.4.3",
98
- "babel-preset-react-app": "^10.0.0",
99
95
  "chance": "^1.1.8",
100
96
  "commitizen": "^4.2.4",
101
97
  "cross-env": "^7.0.3",
@@ -116,6 +112,7 @@
116
112
  "jest-junit": "^16.0.0",
117
113
  "jest-transformer-svg": "^1.0.2",
118
114
  "lint-staged": "^11.0.0",
115
+ "lodash": "^4.17.21",
119
116
  "npm-run-all": "^4.1.5",
120
117
  "postcss": "^7.0.39",
121
118
  "postcss-cli": "^7.1.2",
@@ -123,16 +120,13 @@
123
120
  "react": "^17.0.2",
124
121
  "react-dom": "^17.0.2",
125
122
  "react-is": "^17.0.2",
126
- "react-syntax-highlighter": "^15.5.0",
127
123
  "rollup": "^2.79.1",
128
124
  "rollup-plugin-delete": "^2.0.0",
129
125
  "rollup-plugin-peer-deps-external": "^2.2.4",
130
- "rollup-plugin-terser": "^7.0.2",
131
126
  "rollup-plugin-typescript2": "^0.34.1",
132
- "rollup-plugin-visualizer": "^5.5.2",
133
127
  "semantic-release": "^17.4.2",
134
- "storybook": "^7.0.17",
135
- "styled-components": "^5.3.0",
128
+ "storybook": "^7.6.20",
129
+ "styled-components": "^5.3.11",
136
130
  "stylelint": "^13.13.1",
137
131
  "stylelint-config-prettier": "^8.0.2",
138
132
  "stylelint-config-rational-order": "^0.1.2",
@@ -150,6 +144,7 @@
150
144
  "peerDependencies": {
151
145
  "@loadsmart/miranda-tokens": ">=1.3.0",
152
146
  "@testing-library/react": ">=11.2.6",
147
+ "lodash": ">=4.0.0",
153
148
  "react": ">=16.8.0",
154
149
  "react-dom": ">=16.8.0",
155
150
  "styled-components": ">=5.3.0"
@@ -159,13 +154,7 @@
159
154
  "@loadsmart/utils-function": "0.3.1",
160
155
  "@loadsmart/utils-object": "0.3.1",
161
156
  "@loadsmart/utils-string": "0.3.1",
162
- "clsx": "1.1.1",
163
- "lodash.debounce": "4.0.8",
164
- "lodash.flatten": "4.4.0",
165
- "lodash.get": "4.4.2",
166
- "lodash.isempty": "4.4.0",
167
- "lodash.omit": "4.5.0",
168
- "lodash.range": "3.2.0"
157
+ "clsx": "1.1.1"
169
158
  },
170
159
  "repository": {
171
160
  "type": "git",
@@ -181,6 +170,11 @@
181
170
  }
182
171
  },
183
172
  "resolutions": {
184
- "@stylelint/postcss-css-in-js": "0.37.2"
173
+ "@stylelint/postcss-css-in-js": "0.37.2",
174
+ "react": "17.0.2",
175
+ "react-dom": "17.0.2",
176
+ "@types/react": "17.0.83",
177
+ "@types/react-dom": "17.0.25",
178
+ "react-is": "17.0.2"
185
179
  }
186
180
  }
@@ -80,7 +80,7 @@ export const WithSections: Story<DropdownStoryProps> = (args) => {
80
80
  <div className="flex flex-col">
81
81
  <Dropdown {...args}>
82
82
  <Dropdown.Trigger outlined={args.outlined}>Sections</Dropdown.Trigger>
83
- <Dropdown.Menu align={args.align}>
83
+ <Dropdown.Menu>
84
84
  <Dropdown.Section header="My profile">
85
85
  {PROFILE_ACTIONS.map(({ label, value }) => (
86
86
  <Dropdown.Item
@@ -128,7 +128,6 @@ export const Extended: Story<DropdownStoryProps> = (args) => {
128
128
  <Dropdown {...args}>
129
129
  <Dropdown.Trigger outlined={args.outlined}>With Header &amp; Footer</Dropdown.Trigger>
130
130
  <Dropdown.Menu
131
- align={args.align}
132
131
  header={<p className="px-2">Header</p>}
133
132
  footer={<p className="px-2">A cool footer</p>}
134
133
  >
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react'
1
+ import React, { ReactNode, ComponentType } from 'react'
2
2
  import styled from 'styled-components'
3
3
 
4
4
  import transition from 'styles/transition'
@@ -50,7 +50,7 @@ export function UnknownIcon(): JSX.Element {
50
50
  return <span aria-label="Unknown icon">&#9785;</span>
51
51
  }
52
52
 
53
- function IconFactory(map: IconMapping): (props: IconProps<typeof map>) => JSX.Element {
53
+ function IconFactory(map: IconMapping): ComponentType<IconProps<typeof map>> {
54
54
  function getIcon(name: keyof typeof map): ReactNode | null {
55
55
  // eslint-disable-next-line no-param-reassign
56
56
  name = String(name || '').toLowerCase()
@@ -4,9 +4,9 @@ import type { SelectAdapter } from './Select.types'
4
4
 
5
5
  export const GenericAdapter: SelectAdapter<unknown> = {
6
6
  getKey(o): string {
7
- return get(o, 'value') as string
7
+ return get(o, 'value')!
8
8
  },
9
9
  getLabel(o): string {
10
- return get(o, 'label') as string
10
+ return get(o, 'label')!
11
11
  },
12
12
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useState } from 'react'
2
2
  import type { Story, Meta } from '@storybook/react'
3
- import omit from 'lodash.omit'
3
+ import { omit } from 'lodash'
4
4
 
5
5
  import { Label } from 'components/Label'
6
6
  import { Text } from 'components/Text'
@@ -115,7 +115,7 @@ function useSteps({ steps, current: currentProp }: useStepsProps): [State, Dispa
115
115
  // TODO: gather step info to feed Steps component
116
116
  function init(steps: Array<Step>, current?: number | string): State {
117
117
  return {
118
- current: current || (get(steps, '0.id') as number | string),
118
+ current: current || get(steps, '0.id')!,
119
119
  steps,
120
120
  }
121
121
  }
@@ -315,7 +315,7 @@ const StyledCloseButton = styled.button<WithSizeProps & WithVariantProps>`
315
315
  'tag-warning-background--focus': whenProps({ variant: 'warning' }),
316
316
  'tag-danger-background--focus': whenProps({ variant: 'danger' }),
317
317
  })};
318
- box-shadow: ${token('tag-outline')};
318
+ box-shadow: ${token('tag-box-shadow')};
319
319
  }
320
320
  `
321
321
 
@@ -1,55 +1,59 @@
1
1
  import React from 'react'
2
- import type { Story, Meta } from '@storybook/react'
2
+ import type { Meta, StoryObj } from '@storybook/react'
3
3
 
4
4
  import { Text } from '.'
5
5
  import type { TextProps } from './Text'
6
6
  import { COLORS } from '../../theming/themes/loadsmart.theme'
7
7
  import { typographyProperties } from 'styles/typography'
8
8
 
9
- export default {
9
+ const meta: Meta<typeof Text> = {
10
10
  title: 'Components/Text',
11
11
  component: Text,
12
12
  argTypes: {
13
13
  children: {
14
- control: { type: 'text' },
15
- defaultValue: 'This is a sample text content.',
14
+ control: 'text',
16
15
  description: 'Children to be passed as text content.',
17
16
  },
18
17
  variant: {
19
- control: {
20
- type: 'select',
21
- options: Object.keys(typographyProperties),
22
- },
23
- defaultValue: Object.keys(typographyProperties)[0],
18
+ control: 'select',
19
+ options: Object.keys(typographyProperties),
24
20
  description: 'One of the documented typography variants',
25
21
  },
26
22
  italic: {
27
- control: { type: 'boolean' },
28
- defaultValue: false,
23
+ control: 'boolean',
29
24
  description: 'Controls if the text should be on italic mode.',
30
25
  },
31
26
  color: {
32
- control: { type: 'select', options: Object.keys(COLORS) },
33
- defaultValue: 'color-neutral-darkest',
27
+ control: 'select',
28
+ options: Object.keys(COLORS),
34
29
  description: 'Accepts all colors supported by the theme.',
35
30
  },
36
31
  as: {
37
- control: {
38
- type: 'text',
39
- },
32
+ control: 'text',
40
33
  description:
41
34
  'Which HTML element will be used, such as `span`, `p`, `h1-h6`, `blockquote`, `q`, `abbr`, `address`, `cite`, and others.',
42
- defaultValue: 'span',
43
35
  },
44
36
  },
45
- } as Meta
37
+ }
38
+
39
+ export default meta
40
+
41
+ type Story = StoryObj<TextProps>
46
42
 
47
- export const Playground: Story<TextProps> = (args) => {
48
- return (
49
- <div className="flex flex-col space-y-2">
50
- <div className="flex items-center">
51
- <Text {...args} />
43
+ export const Playground: Story = {
44
+ args: {
45
+ children: 'This is a sample text content.',
46
+ italic: false,
47
+ variant: 'body',
48
+ color: 'color-neutral-darkest',
49
+ },
50
+ render: (args) => {
51
+ return (
52
+ <div className="flex flex-col space-y-2">
53
+ <div className="flex items-center">
54
+ <Text {...args} />
55
+ </div>
52
56
  </div>
53
- </div>
54
- )
57
+ )
58
+ },
55
59
  }
@@ -14,7 +14,7 @@ export type SelectableStrategyContext<T extends Selectable> = {
14
14
 
15
15
  const GenericAdapter: SelectableAdapter<unknown> = {
16
16
  getKey(o): string {
17
- return get(o, 'value') as string
17
+ return get(o, 'value')!
18
18
  },
19
19
  }
20
20
 
@@ -1 +1,3 @@
1
- export { default } from 'lodash.flatten'
1
+ import { flatten } from 'lodash'
2
+
3
+ export default flatten
@@ -1 +1,2 @@
1
- export { default } from 'lodash.get'
1
+ import { get } from 'lodash'
2
+ export default get
@@ -1 +1,2 @@
1
- export { default } from 'lodash.isempty'
1
+ import { isEmpty } from 'lodash'
2
+ export default isEmpty
@@ -1 +1,2 @@
1
- export { default } from 'lodash.omit'
1
+ import { omit } from 'lodash'
2
+ export default omit
@@ -1 +1,2 @@
1
- export { default } from 'lodash.range'
1
+ import { range } from 'lodash'
2
+ export default range