@procore/core-react 11.25.0 → 11.25.2
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/babel.config.js +1 -1
- package/dist/Avatar/Avatar.d.ts +1 -1
- package/dist/Avatar/Avatar.styles.js +5 -5
- package/dist/AvatarStack/AvatarStack.d.ts +7 -7
- package/dist/AvatarStack/AvatarStack.styles.d.ts +1 -1
- package/dist/AvatarStack/AvatarStack.styles.js +7 -7
- package/dist/Badge/Badge.styles.js +2 -2
- package/dist/Banner/Banner.styles.js +10 -10
- package/dist/Box/Box.styles.js +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.styles.js +4 -4
- package/dist/Button/Button.styles.js +5 -5
- package/dist/Calendar/Calendar.d.ts +1 -1
- package/dist/Calendar/Calendar.styles.js +8 -8
- package/dist/Card/Card.styles.js +1 -1
- package/dist/Checkbox/Checkbox.styles.js +6 -6
- package/dist/ContactItem/ContactItem.styles.d.ts +1 -1
- package/dist/ContactItem/ContactItem.styles.js +5 -5
- package/dist/Content/Content.d.ts +3 -3
- package/dist/Content/Content.styles.js +2 -2
- package/dist/DateInput/DateInput.styles.js +6 -6
- package/dist/DetailPage/DetailPage.styles.js +7 -7
- package/dist/Dropdown/Dropdown.styles.js +3 -3
- package/dist/DropdownFlyout/DropdownFlyout.d.ts +2 -2
- package/dist/DropdownFlyout/DropdownFlyout.helpers.d.ts +1 -1
- package/dist/DropdownFlyout/DropdownFlyout.styles.js +4 -4
- package/dist/Dropzone/Dropzone.d.ts +2 -2
- package/dist/Dropzone/Dropzone.js +1 -1
- package/dist/Dropzone/Dropzone.styles.js +9 -9
- package/dist/EmptyState/EmptyState.styles.js +6 -6
- package/dist/Field/Field.styles.js +3 -3
- package/dist/FileList/FileList.d.ts +1 -1
- package/dist/FileList/FileList.styles.js +4 -4
- package/dist/FileSelect/FileExplorer/FileExplorer.styles.js +9 -9
- package/dist/FileSelect/FileExplorer/FileExplorerSidebar.d.ts +2 -2
- package/dist/FileSelect/FileExplorer/FileExplorerSidebar.styles.js +3 -3
- package/dist/FileSelect/FileSelect.styles.js +2 -2
- package/dist/FileSelect/FileSelectDropzone/FileSelectDropzone.styles.js +3 -3
- package/dist/FileSelect/FileTokenList/FileTokenList.styles.js +2 -2
- package/dist/FileSelect/GridSource/GridSource.styles.js +6 -6
- package/dist/FileSelect/LocalSource/LocalSource.styles.js +4 -4
- package/dist/FileSelect/SourceItem/SourceItem.styles.js +3 -3
- package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.d.ts +2 -2
- package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.js +6 -6
- package/dist/FileSelect/TreeSource/TreeSource.styles.js +1 -1
- package/dist/FileToken/FileToken.styles.js +4 -4
- package/dist/FilterToken/FilterToken.styles.js +2 -2
- package/dist/FlexList/FlexList.styles.js +1 -1
- package/dist/Form/Form.d.ts +71 -71
- package/dist/Form/Form.styles.js +16 -16
- package/dist/Form/stories/util.d.ts +3 -3
- package/dist/Grid/Grid.d.ts +1 -1
- package/dist/Grid/Grid.styles.js +2 -2
- package/dist/GroupSelect/GroupSelect.styles.js +1 -1
- package/dist/Input/Input.styles.js +1 -1
- package/dist/Link/Link.styles.js +1 -1
- package/dist/ListPage/ListPage.styles.js +8 -8
- package/dist/Loader/Loader.styles.js +2 -2
- package/dist/Menu/Menu.d.ts +4 -4
- package/dist/MenuImperative/MenuImperative.d.ts +3 -3
- package/dist/MenuImperative/MenuImperative.styles.js +10 -10
- package/dist/Modal/ChildRegistry.context.d.ts +1 -1
- package/dist/Modal/Modal.d.ts +1 -1
- package/dist/Modal/Modal.styles.js +13 -13
- package/dist/Modal/storyHelpers.d.ts +2 -2
- package/dist/MultiSelect/MultiSelect.styles.js +6 -6
- package/dist/NextMenu/NextMenu.styles.js +3 -3
- package/dist/NextTile/NextTile.d.ts +1 -1
- package/dist/Notation/Notation.js +1 -1
- package/dist/NumberInput/NumberInput.styles.js +7 -7
- package/dist/Overlay/OverlayArrow.styles.js +1 -1
- package/dist/OverlayTrigger/OverlayTrigger.d.ts +1 -1
- package/dist/OverlayTrigger/OverlayTrigger.js +9 -3
- package/dist/OverlayTrigger/OverlayTrigger.js.map +1 -1
- package/dist/OverlayTrigger/OverlayTrigger.types.d.ts +2 -1
- package/dist/OverlayTrigger/OverlayTrigger.types.js.map +1 -1
- package/dist/OverlayTrigger/a11yPresets.d.ts +48 -48
- package/dist/PageLayout/PageLayout.d.ts +1 -1
- package/dist/PageLayout/PageLayout.styles.js +13 -13
- package/dist/Pagination/Pagination.styles.js +5 -5
- package/dist/Panel/Panel.styles.js +11 -11
- package/dist/Pill/Pill.styles.js +2 -2
- package/dist/PillSelect/PillSelect.styles.js +4 -4
- package/dist/Popover/Popover.d.ts +1 -1
- package/dist/Popover/Popover.styles.js +2 -2
- package/dist/Portal/Portal.styles.js +1 -1
- package/dist/ProgressBar/ProgressBar.styles.js +2 -2
- package/dist/RadioButton/RadioButton.styles.js +3 -3
- package/dist/Required/Required.styles.js +3 -3
- package/dist/Search/Search.styles.js +5 -5
- package/dist/Section/Section.d.ts +2 -2
- package/dist/Section/Section.styles.js +6 -6
- package/dist/SegmentedController/SegmentedController.d.ts +2 -2
- package/dist/SegmentedController/SegmentedController.styles.js +4 -4
- package/dist/Select/Select.js +3 -1
- package/dist/Select/Select.js.map +1 -1
- package/dist/Select/Select.styles.js +7 -7
- package/dist/Select/Select.types.d.ts +3 -2
- package/dist/Select/Select.types.js.map +1 -1
- package/dist/Semantic/Semantic.d.ts +6 -1
- package/dist/Semantic/Semantic.js +7 -1
- package/dist/Semantic/Semantic.js.map +1 -1
- package/dist/Semantic/Semantic.styles.d.ts +14 -4
- package/dist/Semantic/Semantic.styles.js +20 -10
- package/dist/Semantic/Semantic.styles.js.map +1 -1
- package/dist/Semantic/index.d.ts +1 -1
- package/dist/Semantic/index.js +1 -1
- package/dist/Semantic/index.js.map +1 -1
- package/dist/Sidebar/Sidebar.styles.js +7 -7
- package/dist/Slider/Slider.styles.js +5 -5
- package/dist/Spinner/Spinner.styles.js +7 -7
- package/dist/SuperSelect/SuperSelect.components.d.ts +29 -29
- package/dist/SuperSelect/SuperSelect.d.ts +29 -29
- package/dist/SuperSelect/SuperSelect.presets.styles.js +1 -1
- package/dist/SuperSelect/SuperSelect.styles.js +37 -37
- package/dist/SuperSelect/useSuperSelect.d.ts +87 -87
- package/dist/Switch/Switch.styles.js +4 -4
- package/dist/Table/Table.styles.js +28 -28
- package/dist/TableShelf/TableShelf.styles.js +5 -5
- package/dist/Tabs/Tabs.d.ts +1 -1
- package/dist/Tabs/Tabs.styles.js +8 -8
- package/dist/Tearsheet/Tearsheet.styles.js +5 -5
- package/dist/TextArea/TextArea.styles.js +1 -1
- package/dist/TextEditor/TextEditor.d.ts +3 -3
- package/dist/TextEditorOutput/TextEditorOutput.styles.js +1 -1
- package/dist/Thumbnail/Thumbnail.d.ts +3 -3
- package/dist/Thumbnail/Thumbnail.hooks.d.ts +226 -210
- package/dist/Thumbnail/Thumbnail.styles.js +17 -17
- package/dist/Thumbnail/ThumbnailCaption.d.ts +2 -2
- package/dist/Thumbnail/ThumbnailDocumentIcon.d.ts +2 -2
- package/dist/Thumbnail/ThumbnailPreview.d.ts +2 -2
- package/dist/ThumbnailGrid/ThumbnailGrid.styles.d.ts +2 -2
- package/dist/ThumbnailGrid/ThumbnailGrid.styles.js +7 -7
- package/dist/TieredSelect/TieredSelect.styles.d.ts +1 -1
- package/dist/TieredSelect/TieredSelect.styles.js +9 -9
- package/dist/Tile/Tile.styles.js +8 -8
- package/dist/Title/Title.styles.js +7 -7
- package/dist/Toast/Toast.styles.js +3 -3
- package/dist/ToggleButton/ToggleButton.styles.js +1 -1
- package/dist/Token/Token.styles.js +3 -3
- package/dist/ToolHeader/ActionIcon.d.ts +2 -2
- package/dist/ToolHeader/ToolHeader.d.ts +2 -2
- package/dist/ToolHeader/ToolHeader.styles.js +6 -6
- package/dist/Tooltip/Tooltip.styles.js +2 -2
- package/dist/Tree/Tree.styles.js +9 -9
- package/dist/Typeahead/Typeahead.styles.js +3 -3
- package/dist/Typography/Typography.colors.story.d.ts +2 -2
- package/dist/Typography/Typography.styles.js +1 -1
- package/dist/Typography/Typography.table.story.d.ts +2 -2
- package/dist/Typography/Typography.table.story.js +2 -2
- package/dist/_hooks/Analytics.d.ts +1 -1
- package/dist/_hooks/Anchor.d.ts +1 -1
- package/dist/_hooks/BoundingRect.d.ts +1 -1
- package/dist/_hooks/Buffer.d.ts +1 -1
- package/dist/_hooks/ClickOutside.d.ts +3 -2
- package/dist/_hooks/ClickOutside.js +8 -3
- package/dist/_hooks/ClickOutside.js.map +1 -1
- package/dist/_hooks/DateTime/DateTime.d.ts +1 -1
- package/dist/_hooks/DelayedToggle.d.ts +1 -1
- package/dist/_hooks/Event.d.ts +1 -1
- package/dist/_hooks/EventListener.js +14 -4
- package/dist/_hooks/EventListener.js.map +1 -1
- package/dist/_hooks/I18n.d.ts +1 -1
- package/dist/_hooks/InjectedScript.d.ts +1 -1
- package/dist/_hooks/ListNavigation.d.ts +1 -1
- package/dist/_hooks/TextEntry.d.ts +1 -1
- package/dist/_hooks/Timer.d.ts +1 -1
- package/dist/_hooks/Trigger.d.ts +1 -1
- package/dist/_hooks/Visibility.d.ts +1 -1
- package/dist/_hooks/ZIndex.d.ts +1 -1
- package/dist/_typedoc/Avatar/Avatar.types.json +20 -20
- package/dist/_typedoc/AvatarStack/AvatarStack.types.json +23 -23
- package/dist/_typedoc/Badge/Badge.types.json +6 -6
- package/dist/_typedoc/Banner/Banner.types.json +13 -13
- package/dist/_typedoc/Box/Box.types.json +68 -68
- package/dist/_typedoc/Breadcrumbs/Breadcrumbs.types.json +10 -10
- package/dist/_typedoc/Button/Button.types.json +11 -11
- package/dist/_typedoc/Calendar/Calendar.types.json +80 -80
- package/dist/_typedoc/Card/Card.types.json +6 -6
- package/dist/_typedoc/Checkbox/Checkbox.types.json +9 -9
- package/dist/_typedoc/ContactItem/ContactItem.types.json +9 -9
- package/dist/_typedoc/DateInput/DateInput.types.json +35 -35
- package/dist/_typedoc/DateSelect/DateSelect.types.json +13 -13
- package/dist/_typedoc/DetailPage/DetailPage.types.json +4 -4
- package/dist/_typedoc/Dropdown/Dropdown.types.json +37 -37
- package/dist/_typedoc/DropdownFlyout/DropdownFlyout.types.json +29 -29
- package/dist/_typedoc/Dropzone/Dropzone.types.json +41 -41
- package/dist/_typedoc/EmptyState/EmptyState.types.json +14 -14
- package/dist/_typedoc/FileList/FileList.types.json +9 -9
- package/dist/_typedoc/FileSelect/FileSelect.types.json +26 -26
- package/dist/_typedoc/FileSelect/GridSource/GridSource.types.json +20 -20
- package/dist/_typedoc/FileSelect/LocalSource/LocalSource.types.json +14 -14
- package/dist/_typedoc/FileSelect/TreeSource/TreeSource.types.json +9 -9
- package/dist/_typedoc/Flex/Flex.types.json +27 -27
- package/dist/_typedoc/FlexList/FlexList.types.json +30 -30
- package/dist/_typedoc/Form/Form.types.json +764 -724
- package/dist/_typedoc/Grid/Grid.types.json +8 -8
- package/dist/_typedoc/GroupSelect/GroupSelect.types.json +52 -52
- package/dist/_typedoc/Input/Input.types.json +2 -2
- package/dist/_typedoc/Link/Link.types.json +4 -4
- package/dist/_typedoc/ListPage/ListPage.types.json +13 -13
- package/dist/_typedoc/Menu/Menu.types.json +62 -62
- package/dist/_typedoc/MenuImperative/MenuImperative.types.json +74 -74
- package/dist/_typedoc/Modal/Modal.types.json +41 -41
- package/dist/_typedoc/MultiSelect/MultiSelect.types.json +31 -31
- package/dist/_typedoc/Notation/Notation.types.json +4 -4
- package/dist/_typedoc/NumberInput/NumberInput.types.json +38 -38
- package/dist/_typedoc/OverlayTrigger/OverlayTrigger.types.json +40 -30
- package/dist/_typedoc/PageLayout/PageLayout.types.json +22 -22
- package/dist/_typedoc/Pagination/Pagination.types.json +7 -7
- package/dist/_typedoc/Panel/Panel.types.json +27 -27
- package/dist/_typedoc/Pill/Pill.types.json +2 -2
- package/dist/_typedoc/PillSelect/PillSelect.types.json +56 -46
- package/dist/_typedoc/Popover/Popover.types.json +14 -14
- package/dist/_typedoc/ProgressBar/ProgressBar.types.json +6 -6
- package/dist/_typedoc/RadioButton/RadioButton.types.json +6 -6
- package/dist/_typedoc/Required/Required.types.json +5 -5
- package/dist/_typedoc/Search/Search.types.json +18 -18
- package/dist/_typedoc/Section/Section.types.json +14 -14
- package/dist/_typedoc/SegmentedController/SegmentedController.types.json +20 -20
- package/dist/_typedoc/Select/Select.types.json +75 -55
- package/dist/_typedoc/Slider/Slider.types.json +6 -6
- package/dist/_typedoc/Spinner/Spinner.types.json +9 -9
- package/dist/_typedoc/Switch/Switch.types.json +3 -3
- package/dist/_typedoc/Table/Table.types.json +106 -96
- package/dist/_typedoc/Tabs/Tabs.types.json +17 -17
- package/dist/_typedoc/Tearsheet/Tearsheet.types.json +16 -16
- package/dist/_typedoc/TextArea/TextArea.types.json +3 -3
- package/dist/_typedoc/TextEditor/TextEditor.types.json +9 -9
- package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +4 -4
- package/dist/_typedoc/Thumbnail/Thumbnail.types.json +19 -19
- package/dist/_typedoc/TieredDropdown/TieredDropdown.types.json +42 -42
- package/dist/_typedoc/TieredSelect/TieredSelect.types.json +28 -28
- package/dist/_typedoc/Tile/Tile.types.json +30 -30
- package/dist/_typedoc/Toast/Toast.types.json +4 -4
- package/dist/_typedoc/ToggleButton/ToggleButton.types.json +3 -3
- package/dist/_typedoc/Token/Token.types.json +4 -4
- package/dist/_typedoc/ToolHeader/ToolHeader.types.json +10 -10
- package/dist/_typedoc/Tooltip/Tooltip.types.json +13 -13
- package/dist/_typedoc/Tree/Tree.types.json +86 -86
- package/dist/_typedoc/Typeahead/Typeahead.types.json +2 -2
- package/dist/_typedoc/Typography/Typography.types.json +8 -8
- package/dist/_typedoc/_utils/types.json +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.prod.json +7 -1
- package/dist/FileSelect/SourceItem/SourceItem.test.js +0 -53
- package/dist/MultiSelect/MultiSelect.test.js +0 -250
- package/dist/OverlayTrigger/OverlayTrigger.test.js +0 -483
- package/dist/SuperSelect/SuperSelect.utils.test.js +0 -717
- package/dist/SuperSelect/useSuperSelect.test.js +0 -1284
- package/dist/_hooks/OverflowObserver/OverflowObserver.test.js +0 -110
- package/dist/_hooks/__tests__/Anchor.test.js +0 -109
- package/dist/_hooks/__tests__/BoundingRect.test.js +0 -85
- package/dist/_hooks/__tests__/Buffer.test.js +0 -76
- package/dist/_hooks/__tests__/DateTime.test.js +0 -136
- package/dist/_hooks/__tests__/DelayedCallback.test.js +0 -119
- package/dist/_hooks/__tests__/DelayedToggle.test.js +0 -50
- package/dist/_hooks/__tests__/Deprecation.test.js +0 -58
- package/dist/_hooks/__tests__/Event.test.js +0 -46
- package/dist/_hooks/__tests__/EventListener.test.js +0 -78
- package/dist/_hooks/__tests__/Hotkey.test.js +0 -18
- package/dist/_hooks/__tests__/InjectedScript.test.js +0 -80
- package/dist/_hooks/__tests__/ListNavigation.test.js +0 -101
- package/dist/_hooks/__tests__/TextEntry.test.js +0 -92
- package/dist/_hooks/__tests__/Timer.test.js +0 -60
- package/dist/_hooks/__tests__/Trigger.test.js +0 -52
- package/dist/_hooks/__tests__/Visibility.test.js +0 -86
- package/dist/_hooks/__tests__/ZIndex.test.js +0 -76
- package/dist/_utils/__tests__/CalendarHelpers.test.js +0 -64
- package/dist/_utils/__tests__/filename.test.js +0 -27
- package/dist/_utils/__tests__/getAnchorPosition.test.js +0 -250
- package/dist/_utils/__tests__/mergeRefs.test.js +0 -58
- package/dist/_utils/__tests__/slotify.test.js +0 -152
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
testContext,
|
|
3
|
-
testHook,
|
|
4
|
-
testRenderProp,
|
|
5
|
-
} from '../../__tests__/helpers/state'
|
|
6
|
-
import {
|
|
7
|
-
defaultZIndex,
|
|
8
|
-
useZIndex,
|
|
9
|
-
useZIndexContext,
|
|
10
|
-
ZIndex,
|
|
11
|
-
ZIndexProvider,
|
|
12
|
-
} from '../ZIndex'
|
|
13
|
-
|
|
14
|
-
const validateAPI = (api) => {
|
|
15
|
-
expect(api.value).toEqual(defaultZIndex)
|
|
16
|
-
expect(api.increment).toBeInstanceOf(Function)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const apiTest = {
|
|
20
|
-
test: 'api',
|
|
21
|
-
config: {},
|
|
22
|
-
callback: validateAPI,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const configTest = {
|
|
26
|
-
test: 'config',
|
|
27
|
-
config: { initialValue: 10 },
|
|
28
|
-
callback: ({ value }) => expect(value).toEqual(10),
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('ZIndex', () => {
|
|
32
|
-
testHook(useZIndex, [
|
|
33
|
-
apiTest,
|
|
34
|
-
configTest,
|
|
35
|
-
{
|
|
36
|
-
test: 'mutations',
|
|
37
|
-
config: {},
|
|
38
|
-
mutations: [['increment', null, ['value', 'toBe', defaultZIndex + 1]]],
|
|
39
|
-
},
|
|
40
|
-
])
|
|
41
|
-
|
|
42
|
-
testRenderProp(ZIndex, 'zIndex', [apiTest, configTest])
|
|
43
|
-
|
|
44
|
-
testContext(ZIndexProvider, useZIndexContext, [
|
|
45
|
-
{
|
|
46
|
-
test: 'api',
|
|
47
|
-
config: {},
|
|
48
|
-
callback: (api) => {
|
|
49
|
-
expect(api.value).toEqual(defaultZIndex + 1)
|
|
50
|
-
expect(api.increment).toBeInstanceOf(Function)
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
test: 'config',
|
|
55
|
-
config: { initialValue: 10 },
|
|
56
|
-
callback: ({ value }) => expect(value).toEqual(11),
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
test: 'missing provider',
|
|
60
|
-
config: {},
|
|
61
|
-
injectProvider: false,
|
|
62
|
-
callback: (context, { spy }) => {
|
|
63
|
-
spy.mockImplementation(() => {})
|
|
64
|
-
|
|
65
|
-
expect(context.value).toBe(defaultZIndex + 1)
|
|
66
|
-
context.increment()
|
|
67
|
-
expect(spy).toBeCalledTimes(1)
|
|
68
|
-
expect(spy).toBeCalledWith(
|
|
69
|
-
'Could not call `increment`, please wrap your component in a `<ZIndexProvider>`'
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
spy.mockRestore()
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
])
|
|
76
|
-
})
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { addDays, getDay, startOfMonth, subDays } from 'date-fns'
|
|
2
|
-
import {
|
|
3
|
-
daysInCalendar,
|
|
4
|
-
getDates,
|
|
5
|
-
getDayOfWeekLabel,
|
|
6
|
-
getMonthLabel,
|
|
7
|
-
} from '../CalendarHelpers'
|
|
8
|
-
|
|
9
|
-
describe('getDates', () => {
|
|
10
|
-
it('should always have a length of daysInCalendar days', () => {
|
|
11
|
-
const dateArray = getDates(new Date('2019-01-17'))
|
|
12
|
-
expect(dateArray.length).toBe(daysInCalendar)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('has the right start date', () => {
|
|
16
|
-
const date = new Date('2019-2-2')
|
|
17
|
-
const dateArray = getDates(date)
|
|
18
|
-
const startDate = subDays(startOfMonth(date), getDay(startOfMonth(date)))
|
|
19
|
-
expect(dateArray[0]).toEqual(startDate)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('has the right end date', () => {
|
|
23
|
-
const date = new Date('2019-2-2')
|
|
24
|
-
const dateArray = getDates(date)
|
|
25
|
-
const startDate = subDays(startOfMonth(date), getDay(startOfMonth(date)))
|
|
26
|
-
const endDate = addDays(startDate, daysInCalendar - 1)
|
|
27
|
-
expect(dateArray[daysInCalendar - 1]).toEqual(endDate)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('in january, previous month days come from december of previous year', () => {
|
|
31
|
-
const date = new Date('2019-01-02')
|
|
32
|
-
const dateArray = getDates(date)
|
|
33
|
-
expect(dateArray[0].getMonth()).toBe(11)
|
|
34
|
-
expect(date.getFullYear() - dateArray[0].getFullYear()).toBe(1)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('in december, next month days come from january of next year', () => {
|
|
38
|
-
const date = new Date('2019-12-25')
|
|
39
|
-
const dateArray = getDates(date)
|
|
40
|
-
const lastDay = dateArray[daysInCalendar - 1]
|
|
41
|
-
expect(lastDay.getMonth()).toBe(0)
|
|
42
|
-
expect(lastDay.getFullYear() - date.getFullYear()).toBe(1)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('is Jan month label', () => {
|
|
46
|
-
const label = getMonthLabel(0, 'en-US')
|
|
47
|
-
expect(label).toBe('Jan')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('is Jun month label', () => {
|
|
51
|
-
const label = getMonthLabel(5, 'en-US')
|
|
52
|
-
expect(label).toBe('Jun')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('is janv month label (fr)', () => {
|
|
56
|
-
const label = getMonthLabel(0, 'fr-FR')
|
|
57
|
-
expect(label).toBe('janv.')
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('day of week (fr)', () => {
|
|
61
|
-
const label = getDayOfWeekLabel(0, 'fr-FR')
|
|
62
|
-
expect(label).toBe('di')
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getFileExtension, parseFilename } from '../filename'
|
|
2
|
-
|
|
3
|
-
describe('parseFilename', () => {
|
|
4
|
-
it('should parse file name', () => {
|
|
5
|
-
expect(parseFilename('a.png')).toEqual({
|
|
6
|
-
filename: 'a',
|
|
7
|
-
extension: 'png',
|
|
8
|
-
isFilename: true,
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('should handle non-filename strings', () => {
|
|
13
|
-
expect(parseFilename('abcd-efg-hij')).toEqual({
|
|
14
|
-
filename: '',
|
|
15
|
-
extension: '',
|
|
16
|
-
isFilename: false,
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
describe('getFileExtension', () => {
|
|
22
|
-
it('should return file extension from a string', () => {
|
|
23
|
-
expect(getFileExtension('a.png')).toEqual('png')
|
|
24
|
-
expect(getFileExtension('abcd.jpg.png')).toEqual('png')
|
|
25
|
-
expect(getFileExtension('abcd')).toEqual('')
|
|
26
|
-
})
|
|
27
|
-
})
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAlignmentPosition,
|
|
3
|
-
getAnchorPosition,
|
|
4
|
-
getEdgePosition,
|
|
5
|
-
} from '../getAnchorPosition'
|
|
6
|
-
|
|
7
|
-
// TEST UTILS
|
|
8
|
-
// ==========
|
|
9
|
-
|
|
10
|
-
const getBox = (shape, position = { left: 0, top: 0 }) => ({
|
|
11
|
-
...position,
|
|
12
|
-
...shape,
|
|
13
|
-
right: shape.width + position.left,
|
|
14
|
-
bottom: shape.height + position.top,
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const Dimensions = {
|
|
18
|
-
target: { width: 100, height: 100 },
|
|
19
|
-
overlay: { width: 400, height: 400 },
|
|
20
|
-
container: { width: 1000, height: 1000 },
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const Positions = {
|
|
24
|
-
topLeft: { left: 200, top: 200 },
|
|
25
|
-
bottomLeft: { left: 200, top: 800 },
|
|
26
|
-
bottomRight: { left: 800, top: 800 },
|
|
27
|
-
topRight: { left: 800, top: 200 },
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const Targets = {
|
|
31
|
-
topLeft: getBox(Dimensions.target, Positions.topLeft),
|
|
32
|
-
topRight: getBox(Dimensions.target, Positions.topRight),
|
|
33
|
-
bottomRight: getBox(Dimensions.target, Positions.bottomRight),
|
|
34
|
-
bottomLeft: getBox(Dimensions.target, Positions.bottomLeft),
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe('getAnchorPosition', () => {
|
|
38
|
-
const container = getBox(Dimensions.container)
|
|
39
|
-
const overlay = getBox(Dimensions.overlay)
|
|
40
|
-
|
|
41
|
-
it('places an overlay around a contained target', () => {
|
|
42
|
-
const target = Targets.topLeft
|
|
43
|
-
const position = getAnchorPosition(
|
|
44
|
-
'bottom-left',
|
|
45
|
-
0,
|
|
46
|
-
container,
|
|
47
|
-
target,
|
|
48
|
-
overlay
|
|
49
|
-
)
|
|
50
|
-
expect(position.left).toBe(target.left)
|
|
51
|
-
expect(position.top).toBe(target.bottom)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('flips placement components as needed', () => {
|
|
55
|
-
const target = Targets.bottomRight
|
|
56
|
-
const position = getAnchorPosition(
|
|
57
|
-
'bottom-left',
|
|
58
|
-
0,
|
|
59
|
-
container,
|
|
60
|
-
target,
|
|
61
|
-
overlay
|
|
62
|
-
)
|
|
63
|
-
expect(position.left).toBe(target.right - overlay.width)
|
|
64
|
-
expect(position.top).toBe(target.top - overlay.height)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
describe('Adjusts position according to padding', () => {
|
|
68
|
-
const target = Targets.bottomLeft
|
|
69
|
-
const edgePadding = 10
|
|
70
|
-
const position = getAnchorPosition(
|
|
71
|
-
'top-left',
|
|
72
|
-
edgePadding,
|
|
73
|
-
container,
|
|
74
|
-
target,
|
|
75
|
-
overlay
|
|
76
|
-
)
|
|
77
|
-
it('adds edge padding', () => {
|
|
78
|
-
expect(position.top).toBe(target.top - overlay.height - edgePadding)
|
|
79
|
-
})
|
|
80
|
-
it('does NOT add alignment padding', () => {
|
|
81
|
-
expect(position.left).toBe(target.left)
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
describe('anchors to side or flip if necessary', () => {
|
|
86
|
-
it('anchors left', () => {
|
|
87
|
-
const target = Targets.topRight
|
|
88
|
-
const position = getEdgePosition({
|
|
89
|
-
container,
|
|
90
|
-
target,
|
|
91
|
-
overlay,
|
|
92
|
-
placement: 'left',
|
|
93
|
-
})
|
|
94
|
-
expect(position.left).toBe(target.left - overlay.width)
|
|
95
|
-
})
|
|
96
|
-
it('it anchors right when it should flip(left)', () => {
|
|
97
|
-
const target = Targets.topLeft
|
|
98
|
-
const position = getEdgePosition({
|
|
99
|
-
container,
|
|
100
|
-
target,
|
|
101
|
-
overlay,
|
|
102
|
-
placement: 'left',
|
|
103
|
-
})
|
|
104
|
-
expect(position.left).toBe(target.right)
|
|
105
|
-
})
|
|
106
|
-
it('anchors right', () => {
|
|
107
|
-
const target = Targets.topLeft
|
|
108
|
-
const position = getEdgePosition({
|
|
109
|
-
container,
|
|
110
|
-
target,
|
|
111
|
-
overlay,
|
|
112
|
-
placement: 'right',
|
|
113
|
-
})
|
|
114
|
-
expect(position.left).toBe(target.right)
|
|
115
|
-
})
|
|
116
|
-
it('it anchors left when it should flip(right)', () => {
|
|
117
|
-
const target = Targets.topRight
|
|
118
|
-
const position = getEdgePosition({
|
|
119
|
-
container,
|
|
120
|
-
target,
|
|
121
|
-
overlay,
|
|
122
|
-
placement: 'right',
|
|
123
|
-
})
|
|
124
|
-
expect(position.left).toBe(target.left - overlay.width)
|
|
125
|
-
})
|
|
126
|
-
it('anchors top', () => {
|
|
127
|
-
const target = Targets.bottomLeft
|
|
128
|
-
const position = getEdgePosition({
|
|
129
|
-
container,
|
|
130
|
-
target,
|
|
131
|
-
overlay,
|
|
132
|
-
placement: 'top',
|
|
133
|
-
})
|
|
134
|
-
expect(position.top).toBe(target.top - overlay.height)
|
|
135
|
-
})
|
|
136
|
-
it('it anchors bottom when it should flip(top)', () => {
|
|
137
|
-
const target = Targets.topLeft
|
|
138
|
-
const position = getEdgePosition({
|
|
139
|
-
container,
|
|
140
|
-
target,
|
|
141
|
-
overlay,
|
|
142
|
-
placement: 'top',
|
|
143
|
-
})
|
|
144
|
-
expect(position.top).toBe(target.bottom)
|
|
145
|
-
})
|
|
146
|
-
it('anchors bottom', () => {
|
|
147
|
-
const target = Targets.topRight
|
|
148
|
-
const position = getEdgePosition({
|
|
149
|
-
container,
|
|
150
|
-
target,
|
|
151
|
-
overlay,
|
|
152
|
-
placement: 'bottom',
|
|
153
|
-
})
|
|
154
|
-
expect(position.top).toBe(target.bottom)
|
|
155
|
-
})
|
|
156
|
-
it('it anchors top when it should flip(bottom)', () => {
|
|
157
|
-
const target = Targets.bottomLeft
|
|
158
|
-
const position = getEdgePosition({
|
|
159
|
-
container,
|
|
160
|
-
target,
|
|
161
|
-
overlay,
|
|
162
|
-
placement: 'bottom',
|
|
163
|
-
})
|
|
164
|
-
expect(position.top).toBe(target.top - overlay.height)
|
|
165
|
-
})
|
|
166
|
-
})
|
|
167
|
-
describe('align horizontally/vertically or flip if necessary', () => {
|
|
168
|
-
it('aligns left', () => {
|
|
169
|
-
const target = Targets.topLeft
|
|
170
|
-
const position = getAlignmentPosition({
|
|
171
|
-
container,
|
|
172
|
-
target,
|
|
173
|
-
overlay,
|
|
174
|
-
placement: 'left',
|
|
175
|
-
})
|
|
176
|
-
expect(position.left).toBe(target.left)
|
|
177
|
-
})
|
|
178
|
-
it('it aligns right when it should flip(left)', () => {
|
|
179
|
-
const target = Targets.topRight
|
|
180
|
-
const position = getAlignmentPosition({
|
|
181
|
-
container,
|
|
182
|
-
target,
|
|
183
|
-
overlay,
|
|
184
|
-
placement: 'left',
|
|
185
|
-
})
|
|
186
|
-
expect(position.left + overlay.width).toBe(target.right)
|
|
187
|
-
})
|
|
188
|
-
it('aligns right', () => {
|
|
189
|
-
const target = Targets.topRight
|
|
190
|
-
const position = getAlignmentPosition({
|
|
191
|
-
container,
|
|
192
|
-
target,
|
|
193
|
-
overlay,
|
|
194
|
-
placement: 'right',
|
|
195
|
-
})
|
|
196
|
-
expect(position.left + overlay.width).toBe(target.right)
|
|
197
|
-
})
|
|
198
|
-
it('it aligns left when it should flip(right)', () => {
|
|
199
|
-
const target = Targets.topLeft
|
|
200
|
-
const position = getAlignmentPosition({
|
|
201
|
-
container,
|
|
202
|
-
target,
|
|
203
|
-
overlay,
|
|
204
|
-
placement: 'right',
|
|
205
|
-
})
|
|
206
|
-
expect(position.left).toBe(target.left)
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
it('aligns top', () => {
|
|
210
|
-
const target = Targets.topLeft
|
|
211
|
-
const position = getAlignmentPosition({
|
|
212
|
-
container,
|
|
213
|
-
target,
|
|
214
|
-
overlay,
|
|
215
|
-
placement: 'top',
|
|
216
|
-
})
|
|
217
|
-
expect(position.top).toBe(target.top)
|
|
218
|
-
})
|
|
219
|
-
it('it aligns bottom when it should flip(top)', () => {
|
|
220
|
-
const target = Targets.bottomLeft
|
|
221
|
-
const position = getAlignmentPosition({
|
|
222
|
-
container,
|
|
223
|
-
target,
|
|
224
|
-
overlay,
|
|
225
|
-
placement: 'top',
|
|
226
|
-
})
|
|
227
|
-
expect(position.top + overlay.height).toBe(target.bottom)
|
|
228
|
-
})
|
|
229
|
-
it('aligns bottom', () => {
|
|
230
|
-
const target = Targets.bottomLeft
|
|
231
|
-
const position = getAlignmentPosition({
|
|
232
|
-
container,
|
|
233
|
-
target,
|
|
234
|
-
overlay,
|
|
235
|
-
placement: 'bottom',
|
|
236
|
-
})
|
|
237
|
-
expect(position.top + overlay.height).toBe(target.bottom)
|
|
238
|
-
})
|
|
239
|
-
it('it aligns top when it should flip(bottom)', () => {
|
|
240
|
-
const target = Targets.topRight
|
|
241
|
-
const position = getAlignmentPosition({
|
|
242
|
-
container,
|
|
243
|
-
target,
|
|
244
|
-
overlay,
|
|
245
|
-
placement: 'bottom',
|
|
246
|
-
})
|
|
247
|
-
expect(position.top).toBe(target.top)
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { mount } from 'enzyme'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { assignRef, mergeRefs } from '../mergeRefs'
|
|
4
|
-
|
|
5
|
-
const refValue = 'ref'
|
|
6
|
-
|
|
7
|
-
describe('assignRef', () => {
|
|
8
|
-
it('should call callback ref with value', () => {
|
|
9
|
-
const refAsFunc = jest.fn()
|
|
10
|
-
assignRef(refAsFunc, refValue)
|
|
11
|
-
|
|
12
|
-
expect(refAsFunc).toHaveBeenCalledTimes(1)
|
|
13
|
-
expect(refAsFunc).toHaveBeenCalledWith(refValue)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('should assign value to ref object', () => {
|
|
17
|
-
const refAsObj = { current: undefined }
|
|
18
|
-
assignRef(refAsObj, refValue)
|
|
19
|
-
|
|
20
|
-
expect(refAsObj.current).toBe(refValue)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should ignore when ref equals null', () => {
|
|
24
|
-
const refAsObj = null
|
|
25
|
-
assignRef(refAsObj, refValue)
|
|
26
|
-
|
|
27
|
-
expect(refAsObj).toBe(null)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('mergeRefs', () => {
|
|
32
|
-
const Dummy = React.forwardRef((_, forwardRef) => {
|
|
33
|
-
React.useImperativeHandle(forwardRef, () => refValue)
|
|
34
|
-
return null
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const refAsFunc = jest.fn()
|
|
38
|
-
const refAsObj = { current: undefined }
|
|
39
|
-
|
|
40
|
-
const Example = ({ visible }) => {
|
|
41
|
-
if (visible) {
|
|
42
|
-
return <Dummy ref={mergeRefs(refAsFunc, refAsObj)} />
|
|
43
|
-
}
|
|
44
|
-
return null
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const wrapper = mount(<Example visible />)
|
|
48
|
-
|
|
49
|
-
expect(refAsFunc).toHaveBeenCalledTimes(1)
|
|
50
|
-
expect(refAsFunc).toHaveBeenCalledWith(refValue)
|
|
51
|
-
expect(refAsObj.current).toBe(refValue)
|
|
52
|
-
|
|
53
|
-
wrapper.setProps({ visible: false })
|
|
54
|
-
|
|
55
|
-
expect(refAsFunc).toHaveBeenCalledTimes(2)
|
|
56
|
-
expect(refAsFunc).toHaveBeenCalledWith(null)
|
|
57
|
-
expect(refAsObj.current).toBe(null)
|
|
58
|
-
})
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import { slotify } from '../slotify'
|
|
4
|
-
|
|
5
|
-
const Foo = React.forwardRef(function Foo() {
|
|
6
|
-
return <div />
|
|
7
|
-
})
|
|
8
|
-
const Bar = React.forwardRef(function Bar() {
|
|
9
|
-
return <div />
|
|
10
|
-
})
|
|
11
|
-
const Baz = React.forwardRef(function Baz() {
|
|
12
|
-
return <div />
|
|
13
|
-
})
|
|
14
|
-
const Unexpected = React.forwardRef(function Fatal() {
|
|
15
|
-
return <div />
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('slotify', () => {
|
|
19
|
-
it('should display slot children if encountered', () => {
|
|
20
|
-
const slots = slotify(
|
|
21
|
-
[
|
|
22
|
-
<Foo>
|
|
23
|
-
<div id="foo-child" />
|
|
24
|
-
</Foo>,
|
|
25
|
-
<Bar>
|
|
26
|
-
<div id="bar-child" />
|
|
27
|
-
</Bar>,
|
|
28
|
-
<Baz bazattr="xyz" />,
|
|
29
|
-
],
|
|
30
|
-
{
|
|
31
|
-
foo: Foo,
|
|
32
|
-
bar: Bar,
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
expect(slots).toEqual({
|
|
37
|
-
foo: {
|
|
38
|
-
slotProps: {},
|
|
39
|
-
slotRef: null,
|
|
40
|
-
slotChildren: <div id="foo-child" />,
|
|
41
|
-
},
|
|
42
|
-
bar: {
|
|
43
|
-
slotProps: {},
|
|
44
|
-
slotRef: null,
|
|
45
|
-
slotChildren: <div id="bar-child" />,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should display only those slots that are expected to see', () => {
|
|
51
|
-
const slots = slotify(
|
|
52
|
-
[
|
|
53
|
-
<Foo ref={{ fooref: true }} fooattr="123">
|
|
54
|
-
<div id="foo-child" />
|
|
55
|
-
</Foo>,
|
|
56
|
-
<Bar ref={{ barref: true }} barattr="abc">
|
|
57
|
-
<div id="bar-child" />
|
|
58
|
-
</Bar>,
|
|
59
|
-
<Unexpected />,
|
|
60
|
-
],
|
|
61
|
-
{
|
|
62
|
-
foo: Foo,
|
|
63
|
-
bar: Bar,
|
|
64
|
-
}
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
expect(slots).toEqual({
|
|
68
|
-
foo: {
|
|
69
|
-
slotProps: {
|
|
70
|
-
fooattr: '123',
|
|
71
|
-
},
|
|
72
|
-
slotRef: {
|
|
73
|
-
fooref: true,
|
|
74
|
-
},
|
|
75
|
-
slotChildren: <div id="foo-child" />,
|
|
76
|
-
},
|
|
77
|
-
bar: {
|
|
78
|
-
slotProps: {
|
|
79
|
-
barattr: 'abc',
|
|
80
|
-
},
|
|
81
|
-
slotRef: {
|
|
82
|
-
barref: true,
|
|
83
|
-
},
|
|
84
|
-
slotChildren: <div id="bar-child" />,
|
|
85
|
-
},
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('should not display slots that are not encountered among the children', () => {
|
|
90
|
-
const slots = slotify(
|
|
91
|
-
[
|
|
92
|
-
<Foo>
|
|
93
|
-
<div id="foo-child" />
|
|
94
|
-
</Foo>,
|
|
95
|
-
<Bar>
|
|
96
|
-
<div />
|
|
97
|
-
</Bar>,
|
|
98
|
-
<Baz>
|
|
99
|
-
<div />
|
|
100
|
-
</Baz>,
|
|
101
|
-
],
|
|
102
|
-
{
|
|
103
|
-
foo: Foo,
|
|
104
|
-
}
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
expect(slots).toEqual({
|
|
108
|
-
foo: {
|
|
109
|
-
slotProps: {},
|
|
110
|
-
slotRef: null,
|
|
111
|
-
slotChildren: <div id="foo-child" />,
|
|
112
|
-
},
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('should return slot props', () => {
|
|
117
|
-
const slots = slotify([<Foo fooattr="123" />], {
|
|
118
|
-
foo: Foo,
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
expect(slots.foo).toEqual({
|
|
122
|
-
slotProps: {
|
|
123
|
-
fooattr: '123',
|
|
124
|
-
},
|
|
125
|
-
slotRef: null,
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
it('should return slot ref', () => {
|
|
130
|
-
const slots = slotify([<Bar ref={{ barref: true }} />], {
|
|
131
|
-
bar: Bar,
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
expect(slots.bar).toEqual({
|
|
135
|
-
slotProps: {},
|
|
136
|
-
slotRef: {
|
|
137
|
-
barref: true,
|
|
138
|
-
},
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
it('should return empty props object if the slot container does not have props', () => {
|
|
143
|
-
const slots = slotify([<Baz />], {
|
|
144
|
-
baz: Baz,
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
expect(slots.baz).toEqual({
|
|
148
|
-
slotProps: {},
|
|
149
|
-
slotRef: null,
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
})
|