@onewelcome/react-lib-components 12.0.2 → 12.0.3
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.
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.js +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.es.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.es.js +5 -5
- package/dist/components/Button/BaseButton.cjs.js +1 -1
- package/dist/components/Button/BaseButton.cjs.js.map +1 -1
- package/dist/components/Button/BaseButton.es.js.map +1 -1
- package/dist/components/Button/BaseButton.module.scss.cjs.js +2 -2
- package/dist/components/Button/BaseButton.module.scss.es.js +4 -4
- package/dist/components/Button/Button.cjs.js +1 -1
- package/dist/components/Button/Button.cjs.js.map +1 -1
- package/dist/components/Button/Button.es.js.map +1 -1
- package/dist/components/Button/Button.module.scss.cjs.js +2 -2
- package/dist/components/Button/Button.module.scss.es.js +17 -17
- package/dist/components/Button/IconButton.cjs.js.map +1 -1
- package/dist/components/Button/IconButton.es.js.map +1 -1
- package/dist/components/Button/IconButton.module.scss.cjs.js +2 -2
- package/dist/components/Button/IconButton.module.scss.es.js +18 -18
- package/dist/components/Button/Spinner.cjs.js.map +1 -1
- package/dist/components/Button/Spinner.es.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.es.js +28 -11
- package/dist/components/ContextMenu/ContextMenu.es.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenu.module.scss.es.js +8 -5
- package/dist/components/ContextMenu/ContextMenu.module.scss.es.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuDivider.cjs.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuDivider.es.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuDivider.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenuDivider.module.scss.es.js +2 -2
- package/dist/components/ContextMenu/ContextMenuItem.cjs.js +1 -1
- package/dist/components/ContextMenu/ContextMenuItem.cjs.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuItem.es.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuItem.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenuItem.module.scss.es.js +3 -3
- package/dist/components/ContextMenu/ContextMenuService.cjs.js +1 -1
- package/dist/components/ContextMenu/ContextMenuService.cjs.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenuService.es.js.map +1 -1
- package/dist/components/DataGrid/DataGrid.cjs.js +1 -1
- package/dist/components/DataGrid/DataGrid.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGrid.es.js.map +1 -1
- package/dist/components/DataGrid/DataGrid.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGrid.module.scss.es.js +6 -6
- package/dist/components/DataGrid/DataGridActions/DataGridActions.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridActions.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridActions.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.es.js +6 -6
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.es.js +7 -7
- package/dist/components/DataGrid/DataGridBody/DataGridBody.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridBody.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridBody.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.es.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.es.js +5 -5
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.es.js +4 -4
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.es.js +5 -5
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.es.js +2 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.es.js +24 -24
- package/dist/components/DataGrid/DataGridBody/DataGridRow/useNestedRow.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/useNestedRow.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridBody/DataGridRow/useNestedRow.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridDateFilter.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridSearchbar.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +8 -8
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbarWrapper.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/FilterKeyMapper.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/useFiltersReducer.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/useFiltersReducer.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/useFiltersReducer.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +3 -3
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +7 -7
- package/dist/components/DatePicker/DatePicker.cjs.js +1 -1
- package/dist/components/DatePicker/DatePicker.cjs.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.es.js +1 -1
- package/dist/components/DatePicker/DatePicker.es.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
- package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
- package/dist/components/Form/Checkbox/Checkbox.cjs.js +1 -1
- package/dist/components/Form/Checkbox/Checkbox.cjs.js.map +1 -1
- package/dist/components/Form/Checkbox/Checkbox.es.js.map +1 -1
- package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
- package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
- package/dist/components/Form/Fieldset/Fieldset.cjs.js +1 -1
- package/dist/components/Form/Fieldset/Fieldset.cjs.js.map +1 -1
- package/dist/components/Form/Fieldset/Fieldset.es.js.map +1 -1
- package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
- package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +5 -5
- package/dist/components/Form/FileUpload/FileItem/FileItem.cjs.js +1 -1
- package/dist/components/Form/FileUpload/FileItem/FileItem.cjs.js.map +1 -1
- package/dist/components/Form/FileUpload/FileItem/FileItem.es.js.map +1 -1
- package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
- package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
- package/dist/components/Form/FileUpload/FileUpload.cjs.js +1 -1
- package/dist/components/Form/FileUpload/FileUpload.cjs.js.map +1 -1
- package/dist/components/Form/FileUpload/FileUpload.es.js +17 -4
- package/dist/components/Form/FileUpload/FileUpload.es.js.map +1 -1
- package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
- package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
- package/dist/components/Form/Form.cjs.js +1 -1
- package/dist/components/Form/Form.cjs.js.map +1 -1
- package/dist/components/Form/Form.es.js.map +1 -1
- package/dist/components/Form/Form.module.scss.cjs.js +2 -2
- package/dist/components/Form/Form.module.scss.es.js +2 -2
- package/dist/components/Form/FormControl/FormControl.cjs.js +1 -1
- package/dist/components/Form/FormControl/FormControl.cjs.js.map +1 -1
- package/dist/components/Form/FormControl/FormControl.es.js.map +1 -1
- package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
- package/dist/components/Form/FormErrorText/FormErrorText.cjs.js.map +1 -1
- package/dist/components/Form/FormErrorText/FormErrorText.es.js.map +1 -1
- package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +5 -5
- package/dist/components/Form/FormGroup/FormGroup.cjs.js +1 -1
- package/dist/components/Form/FormGroup/FormGroup.cjs.js.map +1 -1
- package/dist/components/Form/FormGroup/FormGroup.es.js.map +1 -1
- package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
- package/dist/components/Form/FormHelperText/FormHelperText.cjs.js +1 -1
- package/dist/components/Form/FormHelperText/FormHelperText.cjs.js.map +1 -1
- package/dist/components/Form/FormHelperText/FormHelperText.es.js.map +1 -1
- package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js +1 -1
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js.map +1 -1
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.es.js.map +1 -1
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
- package/dist/components/Form/FormStatusIndicator/FormStatusIndicator.cjs.js.map +1 -1
- package/dist/components/Form/FormStatusIndicator/FormStatusIndicator.es.js.map +1 -1
- package/dist/components/Form/Input/Input.cjs.js +1 -1
- package/dist/components/Form/Input/Input.cjs.js.map +1 -1
- package/dist/components/Form/Input/Input.es.js.map +1 -1
- package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
- package/dist/components/Form/Input/Input.module.scss.es.js +9 -9
- package/dist/components/Form/Label/Label.cjs.js +1 -1
- package/dist/components/Form/Label/Label.cjs.js.map +1 -1
- package/dist/components/Form/Label/Label.es.js.map +1 -1
- package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
- package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
- package/dist/components/Form/Radio/Radio.cjs.js +1 -1
- package/dist/components/Form/Radio/Radio.cjs.js.map +1 -1
- package/dist/components/Form/Radio/Radio.es.js.map +1 -1
- package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
- package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
- package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiOption.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +15 -15
- package/dist/components/Form/Select/MultiSelect/SelectButton.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectButton.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectButton.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
- package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useArrowNavigation.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useMultiSelect.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/useMultiSelect.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useMultiSelect.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useSearch.es.js.map +1 -1
- package/dist/components/Form/Select/Select.interfaces.cjs.js.map +1 -1
- package/dist/components/Form/Select/Select.interfaces.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +17 -17
- package/dist/components/Form/Select/SingleSelect/useArrowNavigation.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/useArrowNavigation.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/useArrowNavigation.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.es.js.map +1 -1
- package/dist/components/Form/Select/useAddNewBtn.cjs.js +1 -1
- package/dist/components/Form/Select/useAddNewBtn.cjs.js.map +1 -1
- package/dist/components/Form/Select/useAddNewBtn.es.js.map +1 -1
- package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
- package/dist/components/Form/Select/useSelectPositionList.cjs.js +1 -1
- package/dist/components/Form/Select/useSelectPositionList.cjs.js.map +1 -1
- package/dist/components/Form/Select/useSelectPositionList.es.js.map +1 -1
- package/dist/components/Form/Textarea/Textarea.cjs.js +1 -1
- package/dist/components/Form/Textarea/Textarea.cjs.js.map +1 -1
- package/dist/components/Form/Textarea/Textarea.es.js.map +1 -1
- package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
- package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
- package/dist/components/Form/Toggle/Toggle.cjs.js +1 -1
- package/dist/components/Form/Toggle/Toggle.cjs.js.map +1 -1
- package/dist/components/Form/Toggle/Toggle.es.js.map +1 -1
- package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
- package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +4 -4
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.cjs.js +1 -1
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.es.js.map +1 -1
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
- package/dist/components/Icon/Icon.cjs.js +1 -1
- package/dist/components/Icon/Icon.cjs.js.map +1 -1
- package/dist/components/Icon/Icon.es.js.map +1 -1
- package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
- package/dist/components/Icon/Icon.module.scss.es.js +107 -107
- package/dist/components/InlineEditing/InlineCheckbox/InlineCheckbox.cjs.js +1 -1
- package/dist/components/InlineEditing/InlineCheckbox/InlineCheckbox.cjs.js.map +1 -1
- package/dist/components/InlineEditing/InlineCheckbox/InlineCheckbox.es.js +11 -9
- package/dist/components/InlineEditing/InlineCheckbox/InlineCheckbox.es.js.map +1 -1
- package/dist/components/InlineEditing/InlineEditingContext.cjs.js +1 -1
- package/dist/components/InlineEditing/InlineEditingContext.cjs.js.map +1 -1
- package/dist/components/InlineEditing/InlineEditingContext.es.js +40 -2
- package/dist/components/InlineEditing/InlineEditingContext.es.js.map +1 -1
- package/dist/components/InlineEditing/InlineEditingSelect/InlineSelect.cjs.js +1 -1
- package/dist/components/InlineEditing/InlineEditingSelect/InlineSelect.cjs.js.map +1 -1
- package/dist/components/InlineEditing/InlineEditingSelect/InlineSelect.es.js +13 -10
- package/dist/components/InlineEditing/InlineEditingSelect/InlineSelect.es.js.map +1 -1
- package/dist/components/Layout/Card/Card.cjs.js.map +1 -1
- package/dist/components/Layout/Card/Card.es.js.map +1 -1
- package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
- package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
- package/dist/components/Layout/ContentHeader/ContentHeader.cjs.js +1 -1
- package/dist/components/Layout/ContentHeader/ContentHeader.cjs.js.map +1 -1
- package/dist/components/Layout/ContentHeader/ContentHeader.es.js.map +1 -1
- package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
- package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +12 -12
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.cjs.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.es.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.cjs.js +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.cjs.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.es.js +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.es.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.cjs.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.es.js.map +1 -1
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
- package/dist/components/Link/Link.cjs.js +1 -1
- package/dist/components/Link/Link.cjs.js.map +1 -1
- package/dist/components/Link/Link.es.js.map +1 -1
- package/dist/components/Link/Link.module.scss.cjs.js +2 -2
- package/dist/components/Link/Link.module.scss.es.js +19 -16
- package/dist/components/Link/Link.module.scss.es.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.es.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
- package/dist/components/Notifications/Alert/AlertContainer/useAlertContainerHeightAnimation.cjs.js +1 -1
- package/dist/components/Notifications/Alert/AlertContainer/useAlertContainerHeightAnimation.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertContainer/useAlertContainerHeightAnimation.es.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js +1 -1
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.es.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
- package/dist/components/Notifications/Alert/AlertProvider/AlertContext.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertProvider/AlertContext.es.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertProvider/AlertProvider.cjs.js +1 -1
- package/dist/components/Notifications/Alert/AlertProvider/AlertProvider.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/AlertProvider/AlertProvider.es.js.map +1 -1
- package/dist/components/Notifications/Alert/useAlert.cjs.js.map +1 -1
- package/dist/components/Notifications/Alert/useAlert.es.js.map +1 -1
- package/dist/components/Notifications/Banner/Banner.cjs.js +1 -1
- package/dist/components/Notifications/Banner/Banner.cjs.js.map +1 -1
- package/dist/components/Notifications/Banner/Banner.es.js.map +1 -1
- package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
- package/dist/components/Notifications/BaseModal/BaseModal.cjs.js +1 -1
- package/dist/components/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModal.es.js +1 -1
- package/dist/components/Notifications/BaseModal/BaseModal.es.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.es.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.cjs.js +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.cjs.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.es.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.es.js.map +1 -1
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
- package/dist/components/Notifications/Dialog/Dialog.cjs.js +1 -1
- package/dist/components/Notifications/Dialog/Dialog.cjs.js.map +1 -1
- package/dist/components/Notifications/Dialog/Dialog.es.js +2 -2
- package/dist/components/Notifications/Dialog/Dialog.es.js.map +1 -1
- package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.cjs.js +1 -1
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.cjs.js.map +1 -1
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.es.js.map +1 -1
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.cjs.js +1 -1
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.cjs.js.map +1 -1
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.es.js.map +1 -1
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
- package/dist/components/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.cjs.js +1 -1
- package/dist/components/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.cjs.js.map +1 -1
- package/dist/components/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.es.js.map +1 -1
- package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.cjs.js.map +1 -1
- package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.es.js.map +1 -1
- package/dist/components/Notifications/NotificationProvider/NotificationContext.cjs.js +1 -1
- package/dist/components/Notifications/NotificationProvider/NotificationContext.cjs.js.map +1 -1
- package/dist/components/Notifications/NotificationProvider/NotificationContext.es.js +1 -1
- package/dist/components/Notifications/NotificationProvider/NotificationContext.es.js.map +1 -1
- package/dist/components/Notifications/NotificationProvider/NotificationService.es.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheet.cjs.js +1 -1
- package/dist/components/Notifications/SideSheet/SideSheet.cjs.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheet.es.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.cjs.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.es.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.cjs.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.es.js.map +1 -1
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
- package/dist/components/Notifications/SlideInModal/SlideInModal.cjs.js +1 -1
- package/dist/components/Notifications/SlideInModal/SlideInModal.cjs.js.map +1 -1
- package/dist/components/Notifications/SlideInModal/SlideInModal.es.js.map +1 -1
- package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
- package/dist/components/Pagination/Pagination.cjs.js +1 -1
- package/dist/components/Pagination/Pagination.cjs.js.map +1 -1
- package/dist/components/Pagination/Pagination.es.js.map +1 -1
- package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
- package/dist/components/Pagination/Pagination.module.scss.es.js +14 -14
- package/dist/components/Popover/Popover.cjs.js +1 -1
- package/dist/components/Popover/Popover.cjs.js.map +1 -1
- package/dist/components/Popover/Popover.es.js.map +1 -1
- package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
- package/dist/components/Popover/Popover.module.scss.es.js +3 -3
- package/dist/components/ProgressBar/ProgressBar.cjs.js +1 -1
- package/dist/components/ProgressBar/ProgressBar.cjs.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.es.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
- package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
- package/dist/components/RequiredSign/RequiredSign.cjs.js.map +1 -1
- package/dist/components/RequiredSign/RequiredSign.es.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.cjs.js +1 -1
- package/dist/components/Skeleton/Skeleton.cjs.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.es.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
- package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
- package/dist/components/Spinner/Spinner.cjs.js.map +1 -1
- package/dist/components/Spinner/Spinner.es.js.map +1 -1
- package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
- package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
- package/dist/components/Stepper/Step.cjs.js.map +1 -1
- package/dist/components/Stepper/Step.es.js.map +1 -1
- package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
- package/dist/components/Stepper/Step.module.scss.es.js +22 -22
- package/dist/components/Stepper/Stepper.cjs.js +1 -1
- package/dist/components/Stepper/Stepper.cjs.js.map +1 -1
- package/dist/components/Stepper/Stepper.es.js.map +1 -1
- package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
- package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
- package/dist/components/Tabs/Tab.cjs.js.map +1 -1
- package/dist/components/Tabs/Tab.es.js.map +1 -1
- package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
- package/dist/components/Tabs/TabButton.cjs.js +1 -1
- package/dist/components/Tabs/TabButton.cjs.js.map +1 -1
- package/dist/components/Tabs/TabButton.es.js.map +1 -1
- package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
- package/dist/components/Tabs/Tabs.cjs.js +1 -1
- package/dist/components/Tabs/Tabs.cjs.js.map +1 -1
- package/dist/components/Tabs/Tabs.es.js.map +1 -1
- package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
- package/dist/components/Tag/RemoveButton.cjs.js +1 -1
- package/dist/components/Tag/RemoveButton.cjs.js.map +1 -1
- package/dist/components/Tag/RemoveButton.es.js.map +1 -1
- package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
- package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
- package/dist/components/Tag/Tag.cjs.js +1 -1
- package/dist/components/Tag/Tag.cjs.js.map +1 -1
- package/dist/components/Tag/Tag.es.js.map +1 -1
- package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
- package/dist/components/Tag/Tag.module.scss.es.js +6 -6
- package/dist/components/TextEllipsis/TextEllipsis.cjs.js +1 -1
- package/dist/components/TextEllipsis/TextEllipsis.cjs.js.map +1 -1
- package/dist/components/TextEllipsis/TextEllipsis.es.js.map +1 -1
- package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
- package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
- package/dist/components/Tiles/Tile.cjs.js +1 -1
- package/dist/components/Tiles/Tile.cjs.js.map +1 -1
- package/dist/components/Tiles/Tile.es.js.map +1 -1
- package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
- package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
- package/dist/components/Tiles/Tiles.cjs.js +1 -1
- package/dist/components/Tiles/Tiles.cjs.js.map +1 -1
- package/dist/components/Tiles/Tiles.es.js.map +1 -1
- package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
- package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
- package/dist/components/Tooltip/Tooltip.cjs.js +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.es.js +1 -1
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
- package/dist/components/Tooltip/Tooltip.module.scss.es.js +27 -27
- package/dist/components/Typography/Typography.cjs.js +1 -1
- package/dist/components/Typography/Typography.cjs.js.map +1 -1
- package/dist/components/Typography/Typography.es.js.map +1 -1
- package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
- package/dist/components/Typography/Typography.module.scss.es.js +13 -13
- package/dist/components/_BaseStyling_/BaseStyling.cjs.js +1 -1
- package/dist/components/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
- package/dist/components/_BaseStyling_/BaseStyling.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNav.cjs.js +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNav.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNav.es.js +2 -0
- package/dist/components/admin/layout/LeftNav/LeftNav.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
- package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.cjs.js +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js +2 -0
- package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.cjs.js +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.cjs.js +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js +90 -2
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/useKeyboardNavigation.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/LeftNavItem/useKeyboardNavigation.es.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/useRefItems.cjs.js +1 -1
- package/dist/components/admin/layout/LeftNav/useRefItems.cjs.js.map +1 -1
- package/dist/components/admin/layout/LeftNav/useRefItems.es.js.map +1 -1
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.cjs.js +1 -1
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.cjs.js.map +1 -1
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.es.js +1 -1
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.es.js.map +1 -1
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.cjs.js +2 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.cjs.js.map +1 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.es.js +33 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.es.js.map +1 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +3 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js.map +1 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +25 -0
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js.map +1 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.cjs.js +2 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.cjs.js.map +1 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.es.js +45 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.es.js.map +1 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +3 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js.map +1 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +25 -0
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js.map +1 -0
- package/dist/components/miscellaneous/IdentityProviderButton.cjs.js.map +1 -1
- package/dist/components/miscellaneous/IdentityProviderButton.es.js.map +1 -1
- package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
- package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
- package/dist/components/withReadOnly.cjs.js +1 -1
- package/dist/components/withReadOnly.cjs.js.map +1 -1
- package/dist/components/withReadOnly.es.js.map +1 -1
- package/dist/hooks/useAnimation.cjs.js +1 -1
- package/dist/hooks/useAnimation.cjs.js.map +1 -1
- package/dist/hooks/useAnimation.es.js.map +1 -1
- package/dist/hooks/useClickOutside.cjs.js +1 -1
- package/dist/hooks/useClickOutside.cjs.js.map +1 -1
- package/dist/hooks/useClickOutside.es.js.map +1 -1
- package/dist/hooks/useDebouncedCallback.cjs.js +1 -1
- package/dist/hooks/useDebouncedCallback.cjs.js.map +1 -1
- package/dist/hooks/useDebouncedCallback.es.js.map +1 -1
- package/dist/hooks/useDescribedBy.cjs.js.map +1 -1
- package/dist/hooks/useDescribedBy.es.js.map +1 -1
- package/dist/hooks/useDetermineStatusIcon.cjs.js.map +1 -1
- package/dist/hooks/useDetermineStatusIcon.es.js.map +1 -1
- package/dist/hooks/useFormSelector.cjs.js.map +1 -1
- package/dist/hooks/useFormSelector.es.js.map +1 -1
- package/dist/hooks/useFullHeightCollapse.cjs.js.map +1 -1
- package/dist/hooks/useFullHeightCollapse.es.js.map +1 -1
- package/dist/hooks/useGetDomRoot.cjs.js +1 -1
- package/dist/hooks/useGetDomRoot.cjs.js.map +1 -1
- package/dist/hooks/useGetDomRoot.es.js.map +1 -1
- package/dist/hooks/usePosition.cjs.js +1 -1
- package/dist/hooks/usePosition.cjs.js.map +1 -1
- package/dist/hooks/usePosition.es.js.map +1 -1
- package/dist/hooks/useRepeatFocus.cjs.js +1 -1
- package/dist/hooks/useRepeatFocus.cjs.js.map +1 -1
- package/dist/hooks/useRepeatFocus.es.js +6 -23
- package/dist/hooks/useRepeatFocus.es.js.map +1 -1
- package/dist/hooks/useRepeater.cjs.js +1 -1
- package/dist/hooks/useRepeater.cjs.js.map +1 -1
- package/dist/hooks/useRepeater.es.js.map +1 -1
- package/dist/hooks/useScreenSize.cjs.js +1 -1
- package/dist/hooks/useScreenSize.cjs.js.map +1 -1
- package/dist/hooks/useScreenSize.es.js.map +1 -1
- package/dist/hooks/useSpacing.cjs.js +1 -1
- package/dist/hooks/useSpacing.cjs.js.map +1 -1
- package/dist/hooks/useSpacing.es.js.map +1 -1
- package/dist/hooks/useUploadFile.cjs.js +1 -1
- package/dist/hooks/useUploadFile.cjs.js.map +1 -1
- package/dist/hooks/useUploadFile.es.js.map +1 -1
- package/dist/hooks/useWrapper.cjs.js.map +1 -1
- package/dist/hooks/useWrapper.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +48 -4
- package/dist/index.es.js +6 -0
- package/dist/index.es.js.map +1 -1
- package/dist/node_modules/tabbable/dist/index.esm.cjs.js +2 -0
- package/dist/node_modules/tabbable/dist/index.esm.cjs.js.map +1 -0
- package/dist/node_modules/tabbable/dist/index.esm.es.js +322 -0
- package/dist/node_modules/tabbable/dist/index.esm.es.js.map +1 -0
- package/dist/readyclasses.module.scss.cjs.js +2 -2
- package/dist/readyclasses.module.scss.es.js +5 -5
- package/dist/util/helper.cjs.js +1 -1
- package/dist/util/helper.cjs.js.map +1 -1
- package/dist/util/helper.es.js +1 -1
- package/dist/util/helper.es.js.map +1 -1
- package/dist/utils/focusManagement.cjs.js +2 -0
- package/dist/utils/focusManagement.cjs.js.map +1 -0
- package/dist/utils/focusManagement.es.js +8 -0
- package/dist/utils/focusManagement.es.js.map +1 -0
- package/dist/utils/statusUtils.cjs.js.map +1 -1
- package/dist/utils/statusUtils.es.js.map +1 -1
- package/dist/variables.cjs.js.map +1 -1
- package/dist/variables.es.js.map +1 -1
- package/package.json +26 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebouncedCallback.es.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\
|
|
1
|
+
{"version":3,"file":"useDebouncedCallback.es.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\nexport const useDebouncedCallback = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n dependencies?: React.DependencyList\n) => {\n const timeout = React.useRef<ReturnType<typeof setTimeout>>();\n const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];\n\n return React.useCallback((...args: T) => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n }\n\n timeout.current = setTimeout(() => {\n callback(...args);\n }, delay);\n }, comboDeps);\n};\n"],"names":[],"mappings":";AAkBO,MAAM,uBAAuB,CAClC,UACA,OACA,iBACG;AACH,QAAM,UAAU,MAAM,OAAA;AACtB,QAAM,YAAY,eAAe,CAAC,UAAU,OAAO,GAAG,YAAY,IAAI,CAAC,UAAU,KAAK;AAEtF,SAAO,MAAM,YAAY,IAAI,SAAY;AACvC,QAAI,QAAQ,WAAW,MAAM;AAC3B,mBAAa,QAAQ,OAAO;AAAA,IAC9B;AAEA,YAAQ,UAAU,WAAW,MAAM;AACjC,eAAS,GAAG,IAAI;AAAA,IAClB,GAAG,KAAK;AAAA,EACV,GAAG,SAAS;AACd;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDescribedBy.cjs.js","sources":["../../src/hooks/useDescribedBy.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface DescribedByConfig {\n error?: boolean;\n errorMessage?: string;\n helperText?: string;\n helperId: string;\n errorId: string;\n parentErrorId?: string;\n parentHelperId?: string;\n}\n\nexport const useDescribedBy = ({\n error,\n errorMessage,\n helperText,\n helperId,\n errorId,\n parentErrorId,\n parentHelperId\n}: DescribedByConfig): string | undefined => {\n if (error) {\n if (parentErrorId) {\n return parentErrorId;\n }\n if (errorMessage) {\n return errorId;\n }\n return undefined;\n }\n\n if (helperText) {\n return helperId;\n }\n if (parentHelperId) {\n return parentHelperId;\n }\n\n return undefined;\n};\n"],"names":["error","errorMessage","helperText","helperId","errorId","parentErrorId","parentHelperId"],"mappings":"uGA0B8B,EAC5BA,QACAC,eACAC,aACAC,WACAC,UACAC,gBACAC,oBAEIN,EACEK,IAGAJ,EACKG,
|
|
1
|
+
{"version":3,"file":"useDescribedBy.cjs.js","sources":["../../src/hooks/useDescribedBy.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface DescribedByConfig {\n error?: boolean;\n errorMessage?: string;\n helperText?: string;\n helperId: string;\n errorId: string;\n parentErrorId?: string;\n parentHelperId?: string;\n}\n\nexport const useDescribedBy = ({\n error,\n errorMessage,\n helperText,\n helperId,\n errorId,\n parentErrorId,\n parentHelperId\n}: DescribedByConfig): string | undefined => {\n if (error) {\n if (parentErrorId) {\n return parentErrorId;\n }\n if (errorMessage) {\n return errorId;\n }\n return undefined;\n }\n\n if (helperText) {\n return helperId;\n }\n if (parentHelperId) {\n return parentHelperId;\n }\n\n return undefined;\n};\n"],"names":["error","errorMessage","helperText","helperId","errorId","parentErrorId","parentHelperId"],"mappings":"uGA0B8B,EAC5BA,QACAC,eACAC,aACAC,WACAC,UACAC,gBACAC,oBAEIN,EACEK,IAGAJ,EACKG,OAET,GAGEF,EACKC,EAELG,QAAJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDescribedBy.es.js","sources":["../../src/hooks/useDescribedBy.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface DescribedByConfig {\n error?: boolean;\n errorMessage?: string;\n helperText?: string;\n helperId: string;\n errorId: string;\n parentErrorId?: string;\n parentHelperId?: string;\n}\n\nexport const useDescribedBy = ({\n error,\n errorMessage,\n helperText,\n helperId,\n errorId,\n parentErrorId,\n parentHelperId\n}: DescribedByConfig): string | undefined => {\n if (error) {\n if (parentErrorId) {\n return parentErrorId;\n }\n if (errorMessage) {\n return errorId;\n }\n return undefined;\n }\n\n if (helperText) {\n return helperId;\n }\n if (parentHelperId) {\n return parentHelperId;\n }\n\n return undefined;\n};\n"],"names":[],"mappings":"AA0BO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6C;AAC3C,MAAI,OAAO;AACT,QAAI,eAAe;
|
|
1
|
+
{"version":3,"file":"useDescribedBy.es.js","sources":["../../src/hooks/useDescribedBy.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface DescribedByConfig {\n error?: boolean;\n errorMessage?: string;\n helperText?: string;\n helperId: string;\n errorId: string;\n parentErrorId?: string;\n parentHelperId?: string;\n}\n\nexport const useDescribedBy = ({\n error,\n errorMessage,\n helperText,\n helperId,\n errorId,\n parentErrorId,\n parentHelperId\n}: DescribedByConfig): string | undefined => {\n if (error) {\n if (parentErrorId) {\n return parentErrorId;\n }\n if (errorMessage) {\n return errorId;\n }\n return undefined;\n }\n\n if (helperText) {\n return helperId;\n }\n if (parentHelperId) {\n return parentHelperId;\n }\n\n return undefined;\n};\n"],"names":[],"mappings":"AA0BO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA6C;AAC3C,MAAI,OAAO;AACT,QAAI,eAAe;AACjB,aAAO;AAAA,IACT;AACA,QAAI,cAAc;AAChB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,MAAI,YAAY;AACd,WAAO;AAAA,EACT;AACA,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDetermineStatusIcon.cjs.js","sources":["../../src/hooks/useDetermineStatusIcon.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FormElement } from \"../components/Form/form.interfaces\";\nimport React, { ReactElement, useRef } from \"react\";\nimport { Icon, Icons } from \"../components/Icon/Icon\";\nexport const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {\n const { error, success } = params || false;\n let icon = null;\n const errorRef = useRef(null);\n const successRef = useRef(null);\n\n if (error) {\n icon = <Icon ref={errorRef} data-icon-status=\"error\" icon={Icons.Error} />;\n } else if (success) {\n icon = <Icon ref={successRef} data-icon-status=\"success\" icon={Icons.CheckmarkCircleAlt} />;\n }\n\n return icon;\n};\n"],"names":["params","error","success","icon","errorRef","useRef","successRef","React","createElement","Icon","ref","Icons","Error","CheckmarkCircleAlt"],"mappings":"oLAmBuCA,IACrC,MAAMC,MAAEA,EAAAC,QAAOA,GAAYF,IAAU,EACrC,IAAIG,EAAO,
|
|
1
|
+
{"version":3,"file":"useDetermineStatusIcon.cjs.js","sources":["../../src/hooks/useDetermineStatusIcon.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FormElement } from \"../components/Form/form.interfaces\";\nimport React, { ReactElement, useRef } from \"react\";\nimport { Icon, Icons } from \"../components/Icon/Icon\";\nexport const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {\n const { error, success } = params || false;\n let icon = null;\n const errorRef = useRef(null);\n const successRef = useRef(null);\n\n if (error) {\n icon = <Icon ref={errorRef} data-icon-status=\"error\" icon={Icons.Error} />;\n } else if (success) {\n icon = <Icon ref={successRef} data-icon-status=\"success\" icon={Icons.CheckmarkCircleAlt} />;\n }\n\n return icon;\n};\n"],"names":["params","error","success","icon","errorRef","useRef","successRef","React","createElement","Icon","ref","Icons","Error","CheckmarkCircleAlt"],"mappings":"oLAmBuCA,IACrC,MAAMC,MAAEA,EAAAC,QAAOA,GAAYF,IAAU,EACrC,IAAIG,EAAO,KACX,MAAMC,EAAWC,EAAAA,OAAO,MAClBC,EAAaD,EAAAA,OAAO,MAQ1B,OANIJ,EACFE,EAAOI,EAAAC,cAACC,EAAAA,MAAKC,IAAKN,EAAU,mBAAiB,QAAQD,KAAMQ,EAAAA,MAAMC,QACxDV,IACTC,EAAOI,EAAAC,cAACC,EAAAA,MAAKC,IAAKJ,EAAY,mBAAiB,UAAUH,KAAMQ,EAAAA,MAAME,sBAGhEV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDetermineStatusIcon.es.js","sources":["../../src/hooks/useDetermineStatusIcon.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FormElement } from \"../components/Form/form.interfaces\";\nimport React, { ReactElement, useRef } from \"react\";\nimport { Icon, Icons } from \"../components/Icon/Icon\";\nexport const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {\n const { error, success } = params || false;\n let icon = null;\n const errorRef = useRef(null);\n const successRef = useRef(null);\n\n if (error) {\n icon = <Icon ref={errorRef} data-icon-status=\"error\" icon={Icons.Error} />;\n } else if (success) {\n icon = <Icon ref={successRef} data-icon-status=\"success\" icon={Icons.CheckmarkCircleAlt} />;\n }\n\n return icon;\n};\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useDetermineStatusIcon.es.js","sources":["../../src/hooks/useDetermineStatusIcon.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FormElement } from \"../components/Form/form.interfaces\";\nimport React, { ReactElement, useRef } from \"react\";\nimport { Icon, Icons } from \"../components/Icon/Icon\";\nexport const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {\n const { error, success } = params || false;\n let icon = null;\n const errorRef = useRef(null);\n const successRef = useRef(null);\n\n if (error) {\n icon = <Icon ref={errorRef} data-icon-status=\"error\" icon={Icons.Error} />;\n } else if (success) {\n icon = <Icon ref={successRef} data-icon-status=\"success\" icon={Icons.CheckmarkCircleAlt} />;\n }\n\n return icon;\n};\n"],"names":[],"mappings":";;AAmBO,MAAM,yBAAyB,CAAC,WAAsD;AAC3F,QAAM,EAAE,OAAO,QAAA,IAAY,UAAU;AACrC,MAAI,OAAO;AACX,QAAM,WAAW,OAAO,IAAI;AAC5B,QAAM,aAAa,OAAO,IAAI;AAE9B,MAAI,OAAO;AACT,WAAO,sBAAA,cAAC,QAAK,KAAK,UAAU,oBAAiB,SAAQ,MAAM,MAAM,MAAA,CAAO;AAAA,EAC1E,WAAW,SAAS;AAClB,WAAO,sBAAA,cAAC,QAAK,KAAK,YAAY,oBAAiB,WAAU,MAAM,MAAM,mBAAA,CAAoB;AAAA,EAC3F;AAEA,SAAO;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormSelector.cjs.js","sources":["../../src/hooks/useFormSelector.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\nimport { generateID } from \"../util/helper\";\nimport { useDescribedBy } from \"./useDescribedBy\";\n\nexport interface ConfigObject {\n name: string | undefined;\n errorMessage?: string;\n error?: boolean;\n parentErrorId?: string;\n helperText?: string;\n parentHelperId?: string;\n}\n\nexport const useFormSelector = (configObject: ConfigObject) => {\n const [identifier] = useState(generateID(15, configObject.name));\n const [errorId] = useState(generateID(15, configObject.errorMessage));\n\n const describedBy = useDescribedBy({\n error: configObject.error,\n errorMessage: configObject.errorMessage,\n helperText: configObject.helperText,\n helperId: identifier,\n errorId,\n parentErrorId: configObject.parentErrorId,\n parentHelperId: configObject.parentHelperId\n });\n\n return {\n describedBy,\n errorId,\n identifier\n };\n};\n"],"names":["configObject","identifier","useState","generateID","name","errorId","errorMessage","describedBy","useDescribedBy","error","helperText","helperId","parentErrorId","parentHelperId"],"mappings":"yMA6BgCA,
|
|
1
|
+
{"version":3,"file":"useFormSelector.cjs.js","sources":["../../src/hooks/useFormSelector.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\nimport { generateID } from \"../util/helper\";\nimport { useDescribedBy } from \"./useDescribedBy\";\n\nexport interface ConfigObject {\n name: string | undefined;\n errorMessage?: string;\n error?: boolean;\n parentErrorId?: string;\n helperText?: string;\n parentHelperId?: string;\n}\n\nexport const useFormSelector = (configObject: ConfigObject) => {\n const [identifier] = useState(generateID(15, configObject.name));\n const [errorId] = useState(generateID(15, configObject.errorMessage));\n\n const describedBy = useDescribedBy({\n error: configObject.error,\n errorMessage: configObject.errorMessage,\n helperText: configObject.helperText,\n helperId: identifier,\n errorId,\n parentErrorId: configObject.parentErrorId,\n parentHelperId: configObject.parentHelperId\n });\n\n return {\n describedBy,\n errorId,\n identifier\n };\n};\n"],"names":["configObject","identifier","useState","generateID","name","errorId","errorMessage","describedBy","useDescribedBy","error","helperText","helperId","parentErrorId","parentHelperId"],"mappings":"yMA6BgCA,IAC9B,MAAOC,GAAcC,EAAAA,SAASC,EAAAA,WAAW,GAAIH,EAAaI,QACnDC,GAAWH,EAAAA,SAASC,EAAAA,WAAW,GAAIH,EAAaM,eAYvD,MAAO,CACLC,YAXkBC,EAAAA,eAAe,CACjCC,MAAOT,EAAaS,MACpBH,aAAcN,EAAaM,aAC3BI,WAAYV,EAAaU,WACzBC,SAAUV,EACVI,UACAO,cAAeZ,EAAaY,cAC5BC,eAAgBb,EAAaa,iBAK7BR,UACAJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormSelector.es.js","sources":["../../src/hooks/useFormSelector.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\nimport { generateID } from \"../util/helper\";\nimport { useDescribedBy } from \"./useDescribedBy\";\n\nexport interface ConfigObject {\n name: string | undefined;\n errorMessage?: string;\n error?: boolean;\n parentErrorId?: string;\n helperText?: string;\n parentHelperId?: string;\n}\n\nexport const useFormSelector = (configObject: ConfigObject) => {\n const [identifier] = useState(generateID(15, configObject.name));\n const [errorId] = useState(generateID(15, configObject.errorMessage));\n\n const describedBy = useDescribedBy({\n error: configObject.error,\n errorMessage: configObject.errorMessage,\n helperText: configObject.helperText,\n helperId: identifier,\n errorId,\n parentErrorId: configObject.parentErrorId,\n parentHelperId: configObject.parentHelperId\n });\n\n return {\n describedBy,\n errorId,\n identifier\n };\n};\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"useFormSelector.es.js","sources":["../../src/hooks/useFormSelector.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\nimport { generateID } from \"../util/helper\";\nimport { useDescribedBy } from \"./useDescribedBy\";\n\nexport interface ConfigObject {\n name: string | undefined;\n errorMessage?: string;\n error?: boolean;\n parentErrorId?: string;\n helperText?: string;\n parentHelperId?: string;\n}\n\nexport const useFormSelector = (configObject: ConfigObject) => {\n const [identifier] = useState(generateID(15, configObject.name));\n const [errorId] = useState(generateID(15, configObject.errorMessage));\n\n const describedBy = useDescribedBy({\n error: configObject.error,\n errorMessage: configObject.errorMessage,\n helperText: configObject.helperText,\n helperId: identifier,\n errorId,\n parentErrorId: configObject.parentErrorId,\n parentHelperId: configObject.parentHelperId\n });\n\n return {\n describedBy,\n errorId,\n identifier\n };\n};\n"],"names":[],"mappings":";;;AA6BO,MAAM,kBAAkB,CAAC,iBAA+B;AAC7D,QAAM,CAAC,UAAU,IAAI,SAAS,WAAW,IAAI,aAAa,IAAI,CAAC;AAC/D,QAAM,CAAC,OAAO,IAAI,SAAS,WAAW,IAAI,aAAa,YAAY,CAAC;AAEpE,QAAM,cAAc,eAAe;AAAA,IACjC,OAAO,aAAa;AAAA,IACpB,cAAc,aAAa;AAAA,IAC3B,YAAY,aAAa;AAAA,IACzB,UAAU;AAAA,IACV;AAAA,IACA,eAAe,aAAa;AAAA,IAC5B,gBAAgB,aAAa;AAAA,EAAA,CAC9B;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFullHeightCollapse.cjs.js","sources":["../../src/hooks/useFullHeightCollapse.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\n\nexport const useFullHeightCollapse = (isCollapsed?: boolean) => {\n const [collapsed, setCollapsed] = useState(isCollapsed ?? false);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n const target = e.target as HTMLDivElement;\n const { scrollTop, scrollHeight, clientHeight } = target;\n const position = Math.ceil((scrollTop / (scrollHeight - clientHeight)) * 100);\n setCollapsed(position !== 0);\n };\n\n return {\n collapsed,\n handleScroll\n };\n};\n"],"names":["isCollapsed","collapsed","setCollapsed","useState","handleScroll","e","target","scrollTop","scrollHeight","clientHeight","position","Math","ceil"],"mappings":"uIAkBsCA,IACpC,MAAOC,EAAWC,GAAgBC,EAAAA,SAASH,IAAe,
|
|
1
|
+
{"version":3,"file":"useFullHeightCollapse.cjs.js","sources":["../../src/hooks/useFullHeightCollapse.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\n\nexport const useFullHeightCollapse = (isCollapsed?: boolean) => {\n const [collapsed, setCollapsed] = useState(isCollapsed ?? false);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n const target = e.target as HTMLDivElement;\n const { scrollTop, scrollHeight, clientHeight } = target;\n const position = Math.ceil((scrollTop / (scrollHeight - clientHeight)) * 100);\n setCollapsed(position !== 0);\n };\n\n return {\n collapsed,\n handleScroll\n };\n};\n"],"names":["isCollapsed","collapsed","setCollapsed","useState","handleScroll","e","target","scrollTop","scrollHeight","clientHeight","position","Math","ceil"],"mappings":"uIAkBsCA,IACpC,MAAOC,EAAWC,GAAgBC,EAAAA,SAASH,IAAe,GAS1D,MAAO,CACLC,YACAG,aAToBC,IACpB,MAAMC,EAASD,EAAEC,QACXC,UAAEA,EAAAC,aAAWA,EAAAC,aAAcA,GAAiBH,EAC5CI,EAAWC,KAAKC,KAAML,GAAaC,EAAeC,GAAiB,KACzEP,EAA0B,IAAbQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFullHeightCollapse.es.js","sources":["../../src/hooks/useFullHeightCollapse.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\n\nexport const useFullHeightCollapse = (isCollapsed?: boolean) => {\n const [collapsed, setCollapsed] = useState(isCollapsed ?? false);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n const target = e.target as HTMLDivElement;\n const { scrollTop, scrollHeight, clientHeight } = target;\n const position = Math.ceil((scrollTop / (scrollHeight - clientHeight)) * 100);\n setCollapsed(position !== 0);\n };\n\n return {\n collapsed,\n handleScroll\n };\n};\n"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"useFullHeightCollapse.es.js","sources":["../../src/hooks/useFullHeightCollapse.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState } from \"react\";\n\nexport const useFullHeightCollapse = (isCollapsed?: boolean) => {\n const [collapsed, setCollapsed] = useState(isCollapsed ?? false);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n const target = e.target as HTMLDivElement;\n const { scrollTop, scrollHeight, clientHeight } = target;\n const position = Math.ceil((scrollTop / (scrollHeight - clientHeight)) * 100);\n setCollapsed(position !== 0);\n };\n\n return {\n collapsed,\n handleScroll\n };\n};\n"],"names":[],"mappings":";AAkBO,MAAM,wBAAwB,CAAC,gBAA0B;AAC9D,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,eAAe,KAAK;AAE/D,QAAM,eAAe,CAAC,MAAqC;AACzD,UAAM,SAAS,EAAE;AACjB,UAAM,EAAE,WAAW,cAAc,aAAA,IAAiB;AAClD,UAAM,WAAW,KAAK,KAAM,aAAa,eAAe,gBAAiB,GAAG;AAC5E,iBAAa,aAAa,CAAC;AAAA,EAC7B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useGetDomRoot=(t,r)=>{const[o,s]=e.useState(document.body);return e.useEffect((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useGetDomRoot=(t,r)=>{const[o,s]=e.useState(document.body);return e.useEffect(()=>{if((null==r?void 0:r.current)&&!t){const e=r.current.closest(".basestyling-wrapper");if(e)return void s(e)}else if(t)return void s(t)},[r]),{root:o}};
|
|
2
2
|
//# sourceMappingURL=useGetDomRoot.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetDomRoot.cjs.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":["passedDomRoot","relativeElement","root","setRoot","useState","document","body","useEffect","current","closestBaseStylingWrapper","closest"],"mappings":"+HAkB6B,CAC3BA,EACAC,KAEA,MAAOC,EAAMC,GAAWC,EAAAA,SAAsBC,SAASC,MAgBvD,OAdAC,EAAAA,
|
|
1
|
+
{"version":3,"file":"useGetDomRoot.cjs.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":["passedDomRoot","relativeElement","root","setRoot","useState","document","body","useEffect","current","closestBaseStylingWrapper","closest"],"mappings":"+HAkB6B,CAC3BA,EACAC,KAEA,MAAOC,EAAMC,GAAWC,EAAAA,SAAsBC,SAASC,MAgBvD,OAdAC,EAAAA,UAAU,KACR,IAAI,MAAAN,OAAA,EAAAA,EAAiBO,WAAYR,EAAe,CAC9C,MAAMS,EAA4BR,EAAgBO,QAAQE,QAAQ,wBAElE,GAAID,EAEF,YADAN,EAAQM,EAGZ,SAAWT,EAET,YADAG,EAAQH,IAGT,CAACC,IAEG,CAAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetDomRoot.es.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"useGetDomRoot.es.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":[],"mappings":";AAkBO,MAAM,gBAAgB,CAC3B,eACA,oBACG;AACH,QAAM,CAAC,MAAM,OAAO,IAAI,SAAsB,SAAS,IAAI;AAE3D,YAAU,MAAM;AACd,SAAI,mDAAiB,YAAW,CAAC,eAAe;AAC9C,YAAM,4BAA4B,gBAAgB,QAAQ,QAAQ,sBAAsB;AAExF,UAAI,2BAA2B;AAC7B,gBAAQ,yBAAwC;AAChD;AAAA,MACF;AAAA,IACF,WAAW,eAAe;AACxB,cAAQ,aAAa;AACrB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAEpB,SAAO,EAAE,KAAA;AACX;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=require("./useDebouncedCallback.cjs.js");var o=(t=>(t.LEFT="left",t.CENTER="center",t.CENTER_H="centerh",t.RIGHT="right",t))(o||{}),i=(t=>(t.TOP="top",t.CENTER="center",t.CENTER_V="centerv",t.BOTTOM="bottom",t))(i||{});const n={relativeElement:void 0,elementToBePositioned:void 0,transformOrigin:{horizontal:"left",vertical:"top"},placement:{horizontal:"left",vertical:"top"},offset:{top:0,right:0,bottom:0,left:0},debounceAmount:20};exports.horizontal=o,exports.usePosition=(o=n)=>{const i={...n,...o},[r,l]=t.useState(!1);void 0===i.transformOrigin&&(i.transformOrigin=n.transformOrigin),void 0===i.placement&&(i.placement=n.placement),void 0===i.offset&&(i.offset=n.offset);const[h,f]=t.useState({left:0,top:0,right:"initial",bottom:"initial"}),a=(t,e,o)=>{var n,r;const l=((t,e,o,n,r)=>{const l="center"===e?(t=>{if("horizontal"===t)return"centerh";if("vertical"===t)return"centerv";throw new Error(`the requested return value isn't "vertical" or "horizontal" ${t} was given.`)})(o):e,h=((t,e,o,i,n)=>{let r=0;return"left"===t[e]||"top"===t[e]?r=o[i]:"center"===t[e]?r=o[i]-n["horizontal"===e?"width":"height"]/2:"right"!==t[e]&&"bottom"!==t[e]||(r=window["horizontal"===e?"innerWidth":"innerHeight"]-o[i]),r})(t,o,n,l,r),f=((t,e,o)=>{var n,r,l,h,f,a,d,c,s,u,g,v;let m=t;return("horizontal"===e&&0!==(null==(n=i.offset)?void 0:n.left)||"horizontal"===e&&0!==(null==(r=i.offset)?void 0:r.right))&&("left"!==o[e]&&"center"!==o[e]||(m+=null==(l=i.offset)?void 0:l.left,m-=null==(h=i.offset)?void 0:h.right),"right"===o[e]&&(m-=null==(f=i.offset)?void 0:f.left,m+=null==(a=i.offset)?void 0:a.right)),("vertical"===e&&0!==(null==(d=i.offset)?void 0:d.top)||"vertical"===e&&0!==(null==(c=i.offset)?void 0:c.bottom))&&("top"!==o[e]&&"center"!==o[e]||(m+=null==(s=i.offset)?void 0:s.top,m-=null==(u=i.offset)?void 0:u.bottom),"bottom"===o[e]&&(m-=null==(g=i.offset)?void 0:g.top,m+=null==(v=i.offset)?void 0:v.bottom)),m})(h,o,t);return((t,e,o,i)=>{let n=t;return("left"===e[o]&&n<0||"top"===e[o]&&n<0||"center"===e[o]&&n<0||"bottom"===e[o]&&n<0)&&(n=0),("left"===e[o]&&n>window.innerWidth-i.width||"center"===e[o]&&"horizontal"===o&&n>window.innerWidth-i.width)&&(n=window.innerWidth-i.width),("top"===e[o]&&n>window.innerHeight-i.height||"center"===e[o]&&"vertical"===o&&n>window.innerHeight-i.height)&&(n=window.innerHeight-i.height),"right"===e[o]&&n>window.innerWidth-i.width&&(n=window.innerWidth-i.width),"bottom"===e[o]&&n>window.innerHeight-i.height&&(n=window.innerHeight-i.height),n})(f,t,o,r)})(i.transformOrigin,i.placement[o],o,t,e);let h="left",a="right";"horizontal"===o&&"right"===(null==(n=i.transformOrigin)?void 0:n.horizontal)?(h="right",a="left"):"horizontal"===o&&(h="left",a="right"),"vertical"===o&&"bottom"===(null==(r=i.transformOrigin)?void 0:r.vertical)?(h="bottom",a="top"):"vertical"===o&&(h="top",a="bottom"),f(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),e=require("./useDebouncedCallback.cjs.js");var o=(t=>(t.LEFT="left",t.CENTER="center",t.CENTER_H="centerh",t.RIGHT="right",t))(o||{}),i=(t=>(t.TOP="top",t.CENTER="center",t.CENTER_V="centerv",t.BOTTOM="bottom",t))(i||{});const n={relativeElement:void 0,elementToBePositioned:void 0,transformOrigin:{horizontal:"left",vertical:"top"},placement:{horizontal:"left",vertical:"top"},offset:{top:0,right:0,bottom:0,left:0},debounceAmount:20};exports.horizontal=o,exports.usePosition=(o=n)=>{const i={...n,...o},[r,l]=t.useState(!1);void 0===i.transformOrigin&&(i.transformOrigin=n.transformOrigin),void 0===i.placement&&(i.placement=n.placement),void 0===i.offset&&(i.offset=n.offset);const[h,f]=t.useState({left:0,top:0,right:"initial",bottom:"initial"}),a=(t,e,o)=>{var n,r;const l=((t,e,o,n,r)=>{const l="center"===e?(t=>{if("horizontal"===t)return"centerh";if("vertical"===t)return"centerv";throw new Error(`the requested return value isn't "vertical" or "horizontal" ${t} was given.`)})(o):e,h=((t,e,o,i,n)=>{let r=0;return"left"===t[e]||"top"===t[e]?r=o[i]:"center"===t[e]?r=o[i]-n["horizontal"===e?"width":"height"]/2:"right"!==t[e]&&"bottom"!==t[e]||(r=window["horizontal"===e?"innerWidth":"innerHeight"]-o[i]),r})(t,o,n,l,r),f=((t,e,o)=>{var n,r,l,h,f,a,d,c,s,u,g,v;let m=t;return("horizontal"===e&&0!==(null==(n=i.offset)?void 0:n.left)||"horizontal"===e&&0!==(null==(r=i.offset)?void 0:r.right))&&("left"!==o[e]&&"center"!==o[e]||(m+=null==(l=i.offset)?void 0:l.left,m-=null==(h=i.offset)?void 0:h.right),"right"===o[e]&&(m-=null==(f=i.offset)?void 0:f.left,m+=null==(a=i.offset)?void 0:a.right)),("vertical"===e&&0!==(null==(d=i.offset)?void 0:d.top)||"vertical"===e&&0!==(null==(c=i.offset)?void 0:c.bottom))&&("top"!==o[e]&&"center"!==o[e]||(m+=null==(s=i.offset)?void 0:s.top,m-=null==(u=i.offset)?void 0:u.bottom),"bottom"===o[e]&&(m-=null==(g=i.offset)?void 0:g.top,m+=null==(v=i.offset)?void 0:v.bottom)),m})(h,o,t);return((t,e,o,i)=>{let n=t;return("left"===e[o]&&n<0||"top"===e[o]&&n<0||"center"===e[o]&&n<0||"bottom"===e[o]&&n<0)&&(n=0),("left"===e[o]&&n>window.innerWidth-i.width||"center"===e[o]&&"horizontal"===o&&n>window.innerWidth-i.width)&&(n=window.innerWidth-i.width),("top"===e[o]&&n>window.innerHeight-i.height||"center"===e[o]&&"vertical"===o&&n>window.innerHeight-i.height)&&(n=window.innerHeight-i.height),"right"===e[o]&&n>window.innerWidth-i.width&&(n=window.innerWidth-i.width),"bottom"===e[o]&&n>window.innerHeight-i.height&&(n=window.innerHeight-i.height),n})(f,t,o,r)})(i.transformOrigin,i.placement[o],o,t,e);let h="left",a="right";"horizontal"===o&&"right"===(null==(n=i.transformOrigin)?void 0:n.horizontal)?(h="right",a="left"):"horizontal"===o&&(h="left",a="right"),"vertical"===o&&"bottom"===(null==(r=i.transformOrigin)?void 0:r.vertical)?(h="bottom",a="top"):"vertical"===o&&(h="top",a="bottom"),f(t=>({...t,[h]:l,[a]:"initial"}))},d=e.useDebouncedCallback(()=>{var t,e;if(!(null==(t=i.relativeElement)?void 0:t.current)||!(null==(e=i.elementToBePositioned)?void 0:e.current))return;const o=i.relativeElement.current.getBoundingClientRect(),n={height:i.elementToBePositioned.current.offsetHeight,width:i.elementToBePositioned.current.offsetWidth},h={top:o.top,right:o.right,bottom:o.bottom,center:0,centerv:o.top+o.height/2,centerh:o.left+o.width/2,left:o.left,width:o.width,height:o.height,x:o.x,y:o.y};a(h,n,"horizontal"),a(h,n,"vertical"),r||l(!0)},i.debounceAmount??20);return{top:h.top,bottom:h.bottom,left:h.left,right:h.right,calculatePosition:d,initialCalculationDone:r}},exports.vertical=i;
|
|
2
2
|
//# sourceMappingURL=usePosition.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePosition.cjs.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain*/\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"top\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"center\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"bottom\" && returnValue < 0)\n ) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const calculatePosition = useDebouncedCallback(() => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n }, configObject.debounceAmount ?? 20);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n initialCalculationDone\n };\n};\n"],"names":["horizontal","vertical","defaultConfigObject","relativeElement","elementToBePositioned","transformOrigin","placement","offset","top","right","bottom","left","debounceAmount","providedConfigObject","configObject","initialCalculationDone","setInitialCalculationDone","useState","position","setPosition","_calculatePlacement","relEl","elDimensions","axis","placementValue","requestedReturnValue","placementOriginDefinition","Error","_determineCenteredPlacementOrigin","value","window","_calculateInitialPlacementValue","valueWithOffset","returnValue","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_applyOffsetToPlacementValue","innerWidth","width","innerHeight","height","_fixPossibleViewportOverflow","_calculatePlacementValue","direction","oppositeDirection","prevState","calculatePosition","useDebouncedCallback","current","relativeElRect","getBoundingClientRect","elementToBePositionedDimensions","offsetHeight","offsetWidth","clonedRelEl","center","centerv","centerh","x","y"],"mappings":"oJA4BY,IA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OAAAY,EAAArB,EAAaT,sBAAb,EAAA8B,EAA8BlC,WAC3CoD,EAAA,SACQC,EAAA,OACF,aAAT/B,IACG8B,EAAA,MACQC,EAAA,UAGtBnC,GAA0BoC,IAAA,IACrBA,EACHF,CAACA,GAAY7B,EACb8B,CAACA,GAAoB,aACrB,EAGEE,EAAoBC,EAAAA,sBAAqB,aACzC,KAAC,OAAAvB,IAAa/B,sBAAb,EAAA+B,EAA8BwB,YAAY,OAAAvB,EAAArB,EAAaV,4BAAb,EAAA+B,EAAoCuB,SACjF,OAEF,MAAMC,EAAkB7C,EAAaX,gBAClCuD,QAAyBE,wBACtBC,EAA8C,CAClDX,OAASpC,EAAaV,sBAAuBsD,QAAwBI,aACrEd,MAAQlC,EAAaV,sBAAuBsD,QAAwBK,aAIhEC,EAAc,CAClBxD,IAAKmD,EAAenD,IACpBC,MAAOkD,EAAelD,MACtBC,OAAQiD,EAAejD,OACvBuD,OAAQ,EACRC,QAASP,EAAenD,IAAMmD,EAAeT,OAAS,EACtDiB,QAASR,EAAehD,KAAOgD,EAAeX,MAAQ,EACtDrC,KAAMgD,EAAehD,KACrBqC,MAAOW,EAAeX,MACtBE,OAAQS,EAAeT,OACvBkB,EAAGT,EAAeS,EAClBC,EAAGV,EAAeU,GAGAjD,EAAA4C,EAAaH,EAAiC,cAC9CzC,EAAA4C,EAAaH,EAAiC,YAE7D9C,GACHC,GAA0B,EAAI,GAE/BF,EAAaF,gBAAkB,IAE3B,MAAA,CACLJ,IAAKU,EAASV,IACdE,OAAQQ,EAASR,OACjBC,KAAMO,EAASP,KACfF,MAAOS,EAAST,MAChB+C,oBACAzC,yBACF"}
|
|
1
|
+
{"version":3,"file":"usePosition.cjs.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"top\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"center\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"bottom\" && returnValue < 0)\n ) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const calculatePosition = useDebouncedCallback(() => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n }, configObject.debounceAmount ?? 20);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n initialCalculationDone\n };\n};\n"],"names":["horizontal","vertical","defaultConfigObject","relativeElement","elementToBePositioned","transformOrigin","placement","offset","top","right","bottom","left","debounceAmount","providedConfigObject","configObject","initialCalculationDone","setInitialCalculationDone","useState","position","setPosition","_calculatePlacement","relEl","elDimensions","axis","placementValue","requestedReturnValue","placementOriginDefinition","Error","_determineCenteredPlacementOrigin","value","window","_calculateInitialPlacementValue","valueWithOffset","returnValue","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_applyOffsetToPlacementValue","innerWidth","width","innerHeight","height","_fixPossibleViewportOverflow","_calculatePlacementValue","direction","oppositeDirection","prevState","calculatePosition","useDebouncedCallback","current","relativeElRect","getBoundingClientRect","elementToBePositionedDimensions","offsetHeight","offsetWidth","clonedRelEl","center","centerv","centerh","x","y"],"mappings":"oJA4BO,IAAKA,GAA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EAAA8B,EAA8BlC,WACvDoD,EAAY,SACZC,EAAoB,OACF,aAAT/B,IACT8B,EAAY,MACZC,EAAoB,UAGtBnC,EAAYoC,IAAA,IACPA,EACHF,CAACA,GAAY7B,EACb8B,CAACA,GAAoB,cAInBE,EAAoBC,EAAAA,qBAAqB,aAC7C,KAAK,OAAAvB,IAAa/B,sBAAb,EAAA+B,EAA8BwB,YAAY,OAAAvB,EAAArB,EAAaV,4BAAb,EAAA+B,EAAoCuB,SACjF,OAEF,MAAMC,EAAkB7C,EAAaX,gBAClCuD,QAAyBE,wBACtBC,EAA8C,CAClDX,OAASpC,EAAaV,sBAAuBsD,QAAwBI,aACrEd,MAAQlC,EAAaV,sBAAuBsD,QAAwBK,aAIhEC,EAAc,CAClBxD,IAAKmD,EAAenD,IACpBC,MAAOkD,EAAelD,MACtBC,OAAQiD,EAAejD,OACvBuD,OAAQ,EACRC,QAASP,EAAenD,IAAMmD,EAAeT,OAAS,EACtDiB,QAASR,EAAehD,KAAOgD,EAAeX,MAAQ,EACtDrC,KAAMgD,EAAehD,KACrBqC,MAAOW,EAAeX,MACtBE,OAAQS,EAAeT,OACvBkB,EAAGT,EAAeS,EAClBC,EAAGV,EAAeU,GAGpBjD,EAAoB4C,EAAaH,EAAiC,cAClEzC,EAAoB4C,EAAaH,EAAiC,YAE7D9C,GACHC,GAA0B,IAE3BF,EAAaF,gBAAkB,IAElC,MAAO,CACLJ,IAAKU,EAASV,IACdE,OAAQQ,EAASR,OACjBC,KAAMO,EAASP,KACfF,MAAOS,EAAST,MAChB+C,oBACAzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePosition.es.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\n/* eslint-disable @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain*/\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"top\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"center\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"bottom\" && returnValue < 0)\n ) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const calculatePosition = useDebouncedCallback(() => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n }, configObject.debounceAmount ?? 20);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n initialCalculationDone\n };\n};\n"],"names":["horizontal","vertical"],"mappings":";;AA4BY,IAAA,+BAAAA,gBAAL;AACLA,cAAA,MAAO,IAAA;AACPA,cAAA,QAAS,IAAA;AACTA,cAAA,UAAW,IAAA;AACXA,cAAA,OAAQ,IAAA;AAJEA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAOA,IAAA,6BAAAC,cAAL;AACLA,YAAA,KAAM,IAAA;AACNA,YAAA,QAAS,IAAA;AACTA,YAAA,UAAW,IAAA;AACXA,YAAA,QAAS,IAAA;AAJCA,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAqDZ,MAAM,sBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,IACf,YAAY;AA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kB,EAAE;AAE7B,SAAA;AAAA,IACL,KAAK,SAAS;AAAA,IACd,QAAQ,SAAS;AAAA,IACjB,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB;AAAA,IACA;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"usePosition.es.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"top\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"center\" && returnValue < 0) ||\n (transformOrigin[requestedReturnValue] === \"bottom\" && returnValue < 0)\n ) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const calculatePosition = useDebouncedCallback(() => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n }, configObject.debounceAmount ?? 20);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n initialCalculationDone\n };\n};\n"],"names":["horizontal","vertical"],"mappings":";;AA4BO,IAAK,+BAAAA,gBAAL;AACLA,cAAA,MAAA,IAAO;AACPA,cAAA,QAAA,IAAS;AACTA,cAAA,UAAA,IAAW;AACXA,cAAA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SAAS,eAAe,OAAO,eAAe,QAAQ;AAAA,MACtD,MAAM,eAAe;AAAA,MACrB,OAAO,eAAe;AAAA,MACtB,QAAQ,eAAe;AAAA,MACvB,GAAG,eAAe;AAAA,MAClB,GAAG,eAAe;AAAA,IAAA;AAGpB,wBAAoB,aAAa,iCAAiC,YAAY;AAC9E,wBAAoB,aAAa,iCAAiC,UAAU;AAE5E,QAAI,CAAC,wBAAwB;AAC3B,gCAA0B,IAAI;AAAA,IAChC;AAAA,EACF,GAAG,aAAa,kBAAkB,EAAE;AAEpC,SAAO;AAAA,IACL,KAAK,SAAS;AAAA,IACd,QAAQ,SAAS;AAAA,IACjB,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../utils/focusManagement.cjs.js");exports.useRepeatFocus=(n,r)=>{e.useEffect(()=>{if(!n.current||!r)return;const e=t.getTabbableElements(n.current),o=e[0],s=e[e.length-1];if(!s||!o)return;const u=e=>{e instanceof KeyboardEvent&&"Tab"===e.key&&(e.shiftKey?document.activeElement===o&&(e.preventDefault(),null==s||s.focus()):document.activeElement===s&&(e.preventDefault(),null==o||o.focus()))};return s.addEventListener("keydown",u),o.addEventListener("keydown",u),()=>{s.removeEventListener("keydown",u),o.removeEventListener("keydown",u)}},[n,r])};
|
|
2
2
|
//# sourceMappingURL=useRepeatFocus.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRepeatFocus.cjs.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement
|
|
1
|
+
{"version":3,"file":"useRepeatFocus.cjs.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":["ref","open","useEffect","current","tabbableElements","getTabbableElements","firstFocusableElement","lastFocusableElement","length","handleTabKeyPress","event","KeyboardEvent","key","shiftKey","document","activeElement","preventDefault","focus","addEventListener","removeEventListener"],"mappings":"6KAyB8B,CAACA,EAAgCC,KAC7DC,EAAAA,UAAU,KACR,IAAKF,EAAIG,UAAYF,EACnB,OAGF,MAAMG,EAAmBC,EAAAA,oBAAoBL,EAAIG,SAC3CG,EAAwBF,EAAiB,GACzCG,EAAuBH,EAAiBA,EAAiBI,OAAS,GAExE,IAAKD,IAAyBD,EAC5B,OAGF,MAAMG,EAAqBC,IACnBA,aAAiBC,eAAgC,QAAdD,EAAME,MAI3CF,EAAMG,SACJC,SAASC,gBAAkBT,IAC7BI,EAAMM,iBACN,MAAAT,GAAAA,EAAsBU,SAEfH,SAASC,gBAAkBR,IACpCG,EAAMM,iBACN,MAAAV,GAAAA,EAAuBW,WAO3B,OAHAV,EAAqBW,iBAAiB,UAAWT,GACjDH,EAAsBY,iBAAiB,UAAWT,GAE3C,KACLF,EAAqBY,oBAAoB,UAAWV,GACpDH,EAAsBa,oBAAoB,UAAWV,KAEtD,CAACT,EAAKC"}
|
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const baseSelectors = [
|
|
5
|
-
"button",
|
|
6
|
-
"[href]",
|
|
7
|
-
"input",
|
|
8
|
-
"select",
|
|
9
|
-
"textarea",
|
|
10
|
-
"[tabindex]",
|
|
11
|
-
"[contenteditable]"
|
|
12
|
-
];
|
|
13
|
-
const focusableSelectors = baseSelectors.map((selector) => `${selector}:not([tabindex="-1"])`).join(", ");
|
|
14
|
-
const focusableElements = element.querySelectorAll(focusableSelectors);
|
|
15
|
-
if (position === "first") {
|
|
16
|
-
return focusableElements[0] || null;
|
|
17
|
-
} else if (position === "last") {
|
|
18
|
-
return focusableElements[focusableElements.length - 1] || null;
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
};
|
|
2
|
+
import { getTabbableElements } from "../utils/focusManagement.es.js";
|
|
3
|
+
const useRepeatFocus = (ref, open) => {
|
|
22
4
|
useEffect(() => {
|
|
23
5
|
if (!ref.current || !open) {
|
|
24
6
|
return;
|
|
25
7
|
}
|
|
26
|
-
const
|
|
27
|
-
const firstFocusableElement =
|
|
8
|
+
const tabbableElements = getTabbableElements(ref.current);
|
|
9
|
+
const firstFocusableElement = tabbableElements[0];
|
|
10
|
+
const lastFocusableElement = tabbableElements[tabbableElements.length - 1];
|
|
28
11
|
if (!lastFocusableElement || !firstFocusableElement) {
|
|
29
12
|
return;
|
|
30
13
|
}
|
|
31
14
|
const handleTabKeyPress = (event) => {
|
|
32
|
-
if (event.key !== "Tab") {
|
|
15
|
+
if (!(event instanceof KeyboardEvent) || event.key !== "Tab") {
|
|
33
16
|
return;
|
|
34
17
|
}
|
|
35
18
|
if (event.shiftKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRepeatFocus.es.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement
|
|
1
|
+
{"version":3,"file":"useRepeatFocus.es.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":[],"mappings":";;AAyBO,MAAM,iBAAiB,CAAC,KAAgC,SAAmB;AAChF,YAAU,MAAM;AACd,QAAI,CAAC,IAAI,WAAW,CAAC,MAAM;AACzB;AAAA,IACF;AAEA,UAAM,mBAAmB,oBAAoB,IAAI,OAAO;AACxD,UAAM,wBAAwB,iBAAiB,CAAC;AAChD,UAAM,uBAAuB,iBAAiB,iBAAiB,SAAS,CAAC;AAEzE,QAAI,CAAC,wBAAwB,CAAC,uBAAuB;AACnD;AAAA,IACF;AAEA,UAAM,oBAAoB,CAAC,UAAiB;AAC1C,UAAI,EAAE,iBAAiB,kBAAkB,MAAM,QAAQ,OAAO;AAC5D;AAAA,MACF;AAEA,UAAI,MAAM,UAAU;AAClB,YAAI,SAAS,kBAAkB,uBAAuB;AACpD,gBAAM,eAAA;AACN,uEAAsB;AAAA,QACxB;AAAA,MACF,WAAW,SAAS,kBAAkB,sBAAsB;AAC1D,cAAM,eAAA;AACN,uEAAuB;AAAA,MACzB;AAAA,IACF;AAEA,yBAAqB,iBAAiB,WAAW,iBAAiB;AAClE,0BAAsB,iBAAiB,WAAW,iBAAiB;AAEnE,WAAO,MAAM;AACX,2BAAqB,oBAAoB,WAAW,iBAAiB;AACrE,4BAAsB,oBAAoB,WAAW,iBAAiB;AAAA,IACxE;AAAA,EACF,GAAG,CAAC,KAAK,IAAI,CAAC;AAChB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../util/helper.cjs.js");exports.useRepeater=({componentToRepeat:r})=>{const[o,n]=e.useState([]);e.useEffect((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../util/helper.cjs.js");exports.useRepeater=({componentToRepeat:r})=>{const[o,n]=e.useState([]);e.useEffect(()=>{s()},[]);const s=()=>{const o=e.cloneElement(r,{key:t.generateID(20)});n(e=>[...e,o])};return{repeatedComponents:o,repeat:s,remove:e=>{const t=o.filter(t=>t!==e);n(t)}}};
|
|
2
2
|
//# sourceMappingURL=useRepeater.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRepeater.cjs.js","sources":["../../src/hooks/useRepeater.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState, JSX } from \"react\";\nimport { generateID } from \"../util/helper\";\n\ninterface Arguments {\n componentToRepeat: React.ReactElement;\n}\n\nexport const useRepeater = <T>({ componentToRepeat }: Arguments) => {\n const [repeatedComponents, setRepeatedComponents] = useState<JSX.Element[]>([]);\n\n useEffect(() => {\n repeat();\n }, []);\n\n const repeat = () => {\n const clonedComponent = React.cloneElement(componentToRepeat, { key: generateID(20) });\n\n setRepeatedComponents(prevState => [...prevState, clonedComponent]);\n };\n\n const remove = (componentToRemove: React.ReactElement<T>) => {\n const newRepeatedComponents = repeatedComponents.filter(\n component => component !== componentToRemove\n );\n\n setRepeatedComponents(newRepeatedComponents);\n };\n\n return {\n repeatedComponents,\n repeat,\n remove\n };\n};\n"],"names":["componentToRepeat","repeatedComponents","setRepeatedComponents","useState","useEffect","repeat","clonedComponent","React","cloneElement","key","generateID","prevState","remove","componentToRemove","newRepeatedComponents","filter","component"],"mappings":"gKAuB2B,EAAMA,wBAC/B,MAAOC,EAAoBC,GAAyBC,EAAAA,SAAwB,IAE5EC,EAAAA,
|
|
1
|
+
{"version":3,"file":"useRepeater.cjs.js","sources":["../../src/hooks/useRepeater.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState, JSX } from \"react\";\nimport { generateID } from \"../util/helper\";\n\ninterface Arguments {\n componentToRepeat: React.ReactElement;\n}\n\nexport const useRepeater = <T>({ componentToRepeat }: Arguments) => {\n const [repeatedComponents, setRepeatedComponents] = useState<JSX.Element[]>([]);\n\n useEffect(() => {\n repeat();\n }, []);\n\n const repeat = () => {\n const clonedComponent = React.cloneElement(componentToRepeat, { key: generateID(20) });\n\n setRepeatedComponents(prevState => [...prevState, clonedComponent]);\n };\n\n const remove = (componentToRemove: React.ReactElement<T>) => {\n const newRepeatedComponents = repeatedComponents.filter(\n component => component !== componentToRemove\n );\n\n setRepeatedComponents(newRepeatedComponents);\n };\n\n return {\n repeatedComponents,\n repeat,\n remove\n };\n};\n"],"names":["componentToRepeat","repeatedComponents","setRepeatedComponents","useState","useEffect","repeat","clonedComponent","React","cloneElement","key","generateID","prevState","remove","componentToRemove","newRepeatedComponents","filter","component"],"mappings":"gKAuB2B,EAAMA,wBAC/B,MAAOC,EAAoBC,GAAyBC,EAAAA,SAAwB,IAE5EC,EAAAA,UAAU,KACRC,KACC,IAEH,MAAMA,EAAS,KACb,MAAMC,EAAkBC,EAAMC,aAAaR,EAAmB,CAAES,IAAKC,EAAAA,WAAW,MAEhFR,EAAsBS,GAAa,IAAIA,EAAWL,KAWpD,MAAO,CACLL,qBACAI,SACAO,OAXcC,IACd,MAAMC,EAAwBb,EAAmBc,UAClCC,IAAcH,GAG7BX,EAAsBY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRepeater.es.js","sources":["../../src/hooks/useRepeater.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState, JSX } from \"react\";\nimport { generateID } from \"../util/helper\";\n\ninterface Arguments {\n componentToRepeat: React.ReactElement;\n}\n\nexport const useRepeater = <T>({ componentToRepeat }: Arguments) => {\n const [repeatedComponents, setRepeatedComponents] = useState<JSX.Element[]>([]);\n\n useEffect(() => {\n repeat();\n }, []);\n\n const repeat = () => {\n const clonedComponent = React.cloneElement(componentToRepeat, { key: generateID(20) });\n\n setRepeatedComponents(prevState => [...prevState, clonedComponent]);\n };\n\n const remove = (componentToRemove: React.ReactElement<T>) => {\n const newRepeatedComponents = repeatedComponents.filter(\n component => component !== componentToRemove\n );\n\n setRepeatedComponents(newRepeatedComponents);\n };\n\n return {\n repeatedComponents,\n repeat,\n remove\n };\n};\n"],"names":[],"mappings":";;AAuBO,MAAM,cAAc,CAAI,EAAE,wBAAmC;AAClE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAwB,CAAA,CAAE;AAE9E,YAAU,MAAM;
|
|
1
|
+
{"version":3,"file":"useRepeater.es.js","sources":["../../src/hooks/useRepeater.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState, JSX } from \"react\";\nimport { generateID } from \"../util/helper\";\n\ninterface Arguments {\n componentToRepeat: React.ReactElement;\n}\n\nexport const useRepeater = <T>({ componentToRepeat }: Arguments) => {\n const [repeatedComponents, setRepeatedComponents] = useState<JSX.Element[]>([]);\n\n useEffect(() => {\n repeat();\n }, []);\n\n const repeat = () => {\n const clonedComponent = React.cloneElement(componentToRepeat, { key: generateID(20) });\n\n setRepeatedComponents(prevState => [...prevState, clonedComponent]);\n };\n\n const remove = (componentToRemove: React.ReactElement<T>) => {\n const newRepeatedComponents = repeatedComponents.filter(\n component => component !== componentToRemove\n );\n\n setRepeatedComponents(newRepeatedComponents);\n };\n\n return {\n repeatedComponents,\n repeat,\n remove\n };\n};\n"],"names":[],"mappings":";;AAuBO,MAAM,cAAc,CAAI,EAAE,wBAAmC;AAClE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAwB,CAAA,CAAE;AAE9E,YAAU,MAAM;AACd,WAAA;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,QAAM,SAAS,MAAM;AACnB,UAAM,kBAAkB,MAAM,aAAa,mBAAmB,EAAE,KAAK,WAAW,EAAE,GAAG;AAErF,0BAAsB,CAAA,cAAa,CAAC,GAAG,WAAW,eAAe,CAAC;AAAA,EACpE;AAEA,QAAM,SAAS,CAAC,sBAA6C;AAC3D,UAAM,wBAAwB,mBAAmB;AAAA,MAC/C,eAAa,cAAc;AAAA,IAAA;AAG7B,0BAAsB,qBAAqB;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),n=require("../variables.cjs.js"),r=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),t=e=>e<r(n.breakpoints[n.ScreenSize.SMALL])?n.ScreenSize.SMALL:e<r(n.breakpoints[n.ScreenSize.MEDIUM])?n.ScreenSize.MEDIUM:n.ScreenSize.LARGE;exports.useScreenSize=({onScreenSizeChange:r}={})=>{const[i,S]=e.useState(t(window.innerWidth));return e.useEffect((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),n=require("../variables.cjs.js"),r=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),t=e=>e<r(n.breakpoints[n.ScreenSize.SMALL])?n.ScreenSize.SMALL:e<r(n.breakpoints[n.ScreenSize.MEDIUM])?n.ScreenSize.MEDIUM:n.ScreenSize.LARGE;exports.useScreenSize=({onScreenSizeChange:r}={})=>{const[i,S]=e.useState(t(window.innerWidth));return e.useEffect(()=>{const e=()=>{const e=t(window.innerWidth);S(n=>e!==n?(null==r||r(e,n),e):n)};return window.addEventListener("resize",e),e(),()=>window.removeEventListener("resize",e)},[]),{screenSize:i,isDesktopScreenSize:()=>i===n.ScreenSize.LARGE}};
|
|
2
2
|
//# sourceMappingURL=useScreenSize.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenSize.cjs.js","sources":["../../src/hooks/useScreenSize.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { breakpoints, ScreenSize } from \"../variables\";\n\ninterface Props {\n onScreenSizeChange?: (nextScreenSize: ScreenSize, prevScreenSize?: ScreenSize) => void;\n}\n\nconst emToPx = (em: number) => em * parseFloat(getComputedStyle(document.documentElement).fontSize);\n\nconst getScreenSize = (width: number) => {\n if (width < emToPx(breakpoints[ScreenSize.SMALL])) {\n return ScreenSize.SMALL;\n }\n if (width < emToPx(breakpoints[ScreenSize.MEDIUM])) {\n return ScreenSize.MEDIUM;\n }\n\n return ScreenSize.LARGE;\n};\n\nexport const useScreenSize = ({ onScreenSizeChange }: Props = {}) => {\n const [screenSize, setScreenSize] = useState<ScreenSize>(getScreenSize(window.innerWidth));\n\n useEffect(() => {\n const handleResize = () => {\n const newScreenSize = getScreenSize(window.innerWidth);\n setScreenSize(prevScreenSize => {\n if (newScreenSize !== prevScreenSize) {\n onScreenSizeChange?.(newScreenSize, prevScreenSize);\n return newScreenSize;\n }\n return prevScreenSize;\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n handleResize();\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n const isDesktopScreenSize = () => screenSize === ScreenSize.LARGE;\n\n return { screenSize, isDesktopScreenSize };\n};\n"],"names":["emToPx","em","parseFloat","getComputedStyle","document","documentElement","fontSize","getScreenSize","width","breakpoints","ScreenSize","SMALL","MEDIUM","LARGE","onScreenSizeChange","screenSize","setScreenSize","useState","window","innerWidth","useEffect","handleResize","newScreenSize","prevScreenSize","addEventListener","removeEventListener","isDesktopScreenSize"],"mappings":"0IAuBMA,EAAUC,GAAeA,EAAKC,WAAWC,iBAAiBC,SAASC,iBAAiBC,UAEpFC,EAAiBC,GACjBA,EAAQR,EAAOS,EAAAA,YAAYC,EAAAA,WAAWC,QACjCD,
|
|
1
|
+
{"version":3,"file":"useScreenSize.cjs.js","sources":["../../src/hooks/useScreenSize.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { breakpoints, ScreenSize } from \"../variables\";\n\ninterface Props {\n onScreenSizeChange?: (nextScreenSize: ScreenSize, prevScreenSize?: ScreenSize) => void;\n}\n\nconst emToPx = (em: number) => em * parseFloat(getComputedStyle(document.documentElement).fontSize);\n\nconst getScreenSize = (width: number) => {\n if (width < emToPx(breakpoints[ScreenSize.SMALL])) {\n return ScreenSize.SMALL;\n }\n if (width < emToPx(breakpoints[ScreenSize.MEDIUM])) {\n return ScreenSize.MEDIUM;\n }\n\n return ScreenSize.LARGE;\n};\n\nexport const useScreenSize = ({ onScreenSizeChange }: Props = {}) => {\n const [screenSize, setScreenSize] = useState<ScreenSize>(getScreenSize(window.innerWidth));\n\n useEffect(() => {\n const handleResize = () => {\n const newScreenSize = getScreenSize(window.innerWidth);\n setScreenSize(prevScreenSize => {\n if (newScreenSize !== prevScreenSize) {\n onScreenSizeChange?.(newScreenSize, prevScreenSize);\n return newScreenSize;\n }\n return prevScreenSize;\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n handleResize();\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n const isDesktopScreenSize = () => screenSize === ScreenSize.LARGE;\n\n return { screenSize, isDesktopScreenSize };\n};\n"],"names":["emToPx","em","parseFloat","getComputedStyle","document","documentElement","fontSize","getScreenSize","width","breakpoints","ScreenSize","SMALL","MEDIUM","LARGE","onScreenSizeChange","screenSize","setScreenSize","useState","window","innerWidth","useEffect","handleResize","newScreenSize","prevScreenSize","addEventListener","removeEventListener","isDesktopScreenSize"],"mappings":"0IAuBMA,EAAUC,GAAeA,EAAKC,WAAWC,iBAAiBC,SAASC,iBAAiBC,UAEpFC,EAAiBC,GACjBA,EAAQR,EAAOS,EAAAA,YAAYC,EAAAA,WAAWC,QACjCD,EAAAA,WAAWC,MAEhBH,EAAQR,EAAOS,EAAAA,YAAYC,EAAAA,WAAWE,SACjCF,EAAAA,WAAWE,OAGbF,EAAAA,WAAWG,4BAGS,EAAGC,sBAA8B,MAC5D,MAAOC,EAAYC,GAAiBC,EAAAA,SAAqBV,EAAcW,OAAOC,aAqB9E,OAnBAC,EAAAA,UAAU,KACR,MAAMC,EAAe,KACnB,MAAMC,EAAgBf,EAAcW,OAAOC,YAC3CH,EAAcO,GACRD,IAAkBC,GACpB,MAAAT,GAAAA,EAAqBQ,EAAeC,GAC7BD,GAEFC,IAMX,OAFAL,OAAOM,iBAAiB,SAAUH,GAClCA,IACO,IAAMH,OAAOO,oBAAoB,SAAUJ,IACjD,IAII,CAAEN,aAAYW,oBAFO,IAAMX,IAAeL,EAAAA,WAAWG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreenSize.es.js","sources":["../../src/hooks/useScreenSize.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { breakpoints, ScreenSize } from \"../variables\";\n\ninterface Props {\n onScreenSizeChange?: (nextScreenSize: ScreenSize, prevScreenSize?: ScreenSize) => void;\n}\n\nconst emToPx = (em: number) => em * parseFloat(getComputedStyle(document.documentElement).fontSize);\n\nconst getScreenSize = (width: number) => {\n if (width < emToPx(breakpoints[ScreenSize.SMALL])) {\n return ScreenSize.SMALL;\n }\n if (width < emToPx(breakpoints[ScreenSize.MEDIUM])) {\n return ScreenSize.MEDIUM;\n }\n\n return ScreenSize.LARGE;\n};\n\nexport const useScreenSize = ({ onScreenSizeChange }: Props = {}) => {\n const [screenSize, setScreenSize] = useState<ScreenSize>(getScreenSize(window.innerWidth));\n\n useEffect(() => {\n const handleResize = () => {\n const newScreenSize = getScreenSize(window.innerWidth);\n setScreenSize(prevScreenSize => {\n if (newScreenSize !== prevScreenSize) {\n onScreenSizeChange?.(newScreenSize, prevScreenSize);\n return newScreenSize;\n }\n return prevScreenSize;\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n handleResize();\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n const isDesktopScreenSize = () => screenSize === ScreenSize.LARGE;\n\n return { screenSize, isDesktopScreenSize };\n};\n"],"names":[],"mappings":";;AAuBA,MAAM,SAAS,CAAC,OAAe,KAAK,WAAW,iBAAiB,SAAS,eAAe,EAAE,QAAQ;AAElG,MAAM,gBAAgB,CAAC,UAAkB;AACvC,MAAI,QAAQ,OAAO,YAAY,WAAW,KAAK,CAAC,GAAG;AACjD,WAAO,WAAW;AAAA,
|
|
1
|
+
{"version":3,"file":"useScreenSize.es.js","sources":["../../src/hooks/useScreenSize.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useEffect } from \"react\";\nimport { breakpoints, ScreenSize } from \"../variables\";\n\ninterface Props {\n onScreenSizeChange?: (nextScreenSize: ScreenSize, prevScreenSize?: ScreenSize) => void;\n}\n\nconst emToPx = (em: number) => em * parseFloat(getComputedStyle(document.documentElement).fontSize);\n\nconst getScreenSize = (width: number) => {\n if (width < emToPx(breakpoints[ScreenSize.SMALL])) {\n return ScreenSize.SMALL;\n }\n if (width < emToPx(breakpoints[ScreenSize.MEDIUM])) {\n return ScreenSize.MEDIUM;\n }\n\n return ScreenSize.LARGE;\n};\n\nexport const useScreenSize = ({ onScreenSizeChange }: Props = {}) => {\n const [screenSize, setScreenSize] = useState<ScreenSize>(getScreenSize(window.innerWidth));\n\n useEffect(() => {\n const handleResize = () => {\n const newScreenSize = getScreenSize(window.innerWidth);\n setScreenSize(prevScreenSize => {\n if (newScreenSize !== prevScreenSize) {\n onScreenSizeChange?.(newScreenSize, prevScreenSize);\n return newScreenSize;\n }\n return prevScreenSize;\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n handleResize();\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n const isDesktopScreenSize = () => screenSize === ScreenSize.LARGE;\n\n return { screenSize, isDesktopScreenSize };\n};\n"],"names":[],"mappings":";;AAuBA,MAAM,SAAS,CAAC,OAAe,KAAK,WAAW,iBAAiB,SAAS,eAAe,EAAE,QAAQ;AAElG,MAAM,gBAAgB,CAAC,UAAkB;AACvC,MAAI,QAAQ,OAAO,YAAY,WAAW,KAAK,CAAC,GAAG;AACjD,WAAO,WAAW;AAAA,EACpB;AACA,MAAI,QAAQ,OAAO,YAAY,WAAW,MAAM,CAAC,GAAG;AAClD,WAAO,WAAW;AAAA,EACpB;AAEA,SAAO,WAAW;AACpB;AAEO,MAAM,gBAAgB,CAAC,EAAE,mBAAA,IAA8B,OAAO;AACnE,QAAM,CAAC,YAAY,aAAa,IAAI,SAAqB,cAAc,OAAO,UAAU,CAAC;AAEzF,YAAU,MAAM;AACd,UAAM,eAAe,MAAM;AACzB,YAAM,gBAAgB,cAAc,OAAO,UAAU;AACrD,oBAAc,CAAA,mBAAkB;AAC9B,YAAI,kBAAkB,gBAAgB;AACpC,mEAAqB,eAAe;AACpC,iBAAO;AAAA,QACT;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,WAAO,iBAAiB,UAAU,YAAY;AAC9C,iBAAA;AACA,WAAO,MAAM,OAAO,oBAAoB,UAAU,YAAY;AAAA,EAChE,GAAG,CAAA,CAAE;AAEL,QAAM,sBAAsB,MAAM,eAAe,WAAW;AAE5D,SAAO,EAAE,YAAY,oBAAA;AACvB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/(\d+\.?\d*)+/g;exports.useSpacing=(r,t)=>r?Object.entries(r).reduce((
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/(\d+\.?\d*)+/g;exports.useSpacing=(r,t)=>r?Object.entries(r).reduce((r,[t,o])=>{const n=String(o).matchAll(e),c=Array.from(n).map(([e])=>.25*Number(e)+"rem").join(" ");return{...r,[t]:c}},t??{}):t;
|
|
2
2
|
//# sourceMappingURL=useSpacing.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpacing.cjs.js","sources":["../../src/hooks/useSpacing.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSSProperties } from \"react\";\n\nexport type SpacingMultiplier = 0 | 0.5 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;\ntype SpacingMultiplierStringOrNumber = `${SpacingMultiplier}` | SpacingMultiplier;\ntype MultiValueSpacingMultiplier =\n | `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}`\n | `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}`\n | `${SpacingMultiplier} ${SpacingMultiplier}`\n | SpacingMultiplierStringOrNumber;\n\nexport interface Spacing {\n padding?: MultiValueSpacingMultiplier;\n paddingTop?: SpacingMultiplierStringOrNumber;\n paddingBottom?: SpacingMultiplierStringOrNumber;\n paddingLeft?: SpacingMultiplierStringOrNumber;\n paddingRight?: SpacingMultiplierStringOrNumber;\n margin?: MultiValueSpacingMultiplier;\n marginTop?: SpacingMultiplierStringOrNumber;\n marginBottom?: SpacingMultiplierStringOrNumber;\n marginLeft?: SpacingMultiplierStringOrNumber;\n marginRight?: SpacingMultiplierStringOrNumber;\n}\n\nconst defaultFactor = 0.25;\nconst defaultUnit = \"rem\";\nconst spacingNumberRegex = /(\\d+\\.?\\d*)+/g;\n\nexport const useSpacing = (\n spacingProps?: Spacing,\n style?: CSSProperties\n): CSSProperties | undefined => {\n if (spacingProps) {\n return Object.entries(spacingProps).reduce<CSSProperties>((prev, [spacing, multiplier]) => {\n const matches = String(multiplier).matchAll(spacingNumberRegex);\n const cssSpacingValue = Array.from(matches)\n .map(([multiplierValue]) => `${Number(multiplierValue) * defaultFactor}${defaultUnit}`)\n .join(\" \");\n return { ...prev, [spacing]: cssSpacingValue };\n }, style ?? {});\n }\n return style;\n};\n"],"names":["spacingNumberRegex","spacingProps","style","Object","entries","reduce","prev","spacing","multiplier","matches","String","matchAll","cssSpacingValue","Array","from","map","multiplierValue","Number","join"],"mappings":"gFAuCA,MAEMA,EAAqB,mCAED,CACxBC,EACAC,IAEID,EACKE,OAAOC,QAAQH,GAAcI,
|
|
1
|
+
{"version":3,"file":"useSpacing.cjs.js","sources":["../../src/hooks/useSpacing.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CSSProperties } from \"react\";\n\nexport type SpacingMultiplier = 0 | 0.5 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;\ntype SpacingMultiplierStringOrNumber = `${SpacingMultiplier}` | SpacingMultiplier;\ntype MultiValueSpacingMultiplier =\n | `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}`\n | `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}`\n | `${SpacingMultiplier} ${SpacingMultiplier}`\n | SpacingMultiplierStringOrNumber;\n\nexport interface Spacing {\n padding?: MultiValueSpacingMultiplier;\n paddingTop?: SpacingMultiplierStringOrNumber;\n paddingBottom?: SpacingMultiplierStringOrNumber;\n paddingLeft?: SpacingMultiplierStringOrNumber;\n paddingRight?: SpacingMultiplierStringOrNumber;\n margin?: MultiValueSpacingMultiplier;\n marginTop?: SpacingMultiplierStringOrNumber;\n marginBottom?: SpacingMultiplierStringOrNumber;\n marginLeft?: SpacingMultiplierStringOrNumber;\n marginRight?: SpacingMultiplierStringOrNumber;\n}\n\nconst defaultFactor = 0.25;\nconst defaultUnit = \"rem\";\nconst spacingNumberRegex = /(\\d+\\.?\\d*)+/g;\n\nexport const useSpacing = (\n spacingProps?: Spacing,\n style?: CSSProperties\n): CSSProperties | undefined => {\n if (spacingProps) {\n return Object.entries(spacingProps).reduce<CSSProperties>((prev, [spacing, multiplier]) => {\n const matches = String(multiplier).matchAll(spacingNumberRegex);\n const cssSpacingValue = Array.from(matches)\n .map(([multiplierValue]) => `${Number(multiplierValue) * defaultFactor}${defaultUnit}`)\n .join(\" \");\n return { ...prev, [spacing]: cssSpacingValue };\n }, style ?? {});\n }\n return style;\n};\n"],"names":["spacingNumberRegex","spacingProps","style","Object","entries","reduce","prev","spacing","multiplier","matches","String","matchAll","cssSpacingValue","Array","from","map","multiplierValue","Number","join"],"mappings":"gFAuCA,MAEMA,EAAqB,mCAED,CACxBC,EACAC,IAEID,EACKE,OAAOC,QAAQH,GAAcI,OAAsB,CAACC,GAAOC,EAASC,MACzE,MAAMC,EAAUC,OAAOF,GAAYG,SAASX,GACtCY,EAAkBC,MAAMC,KAAKL,GAChCM,IAAI,EAAEC,KAZO,IAYiBC,OAAOD,GAAV,OAC3BE,KAAK,KACR,MAAO,IAAKZ,EAAMC,CAACA,GAAUK,IAC5BV,GAAS,IAEPA"}
|