@pautena/react-design-system 0.12.0 → 0.12.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/.eslintrc.cjs +40 -0
- package/.prettierrc.cjs +5 -0
- package/package.json +1 -1
- package/src/components/alerts/alerts.stories.mdx +0 -10
- package/src/components/alerts/expandable-alert/expandable-alert.stories.tsx +0 -96
- package/src/components/alerts/expandable-alert/expandable-alert.test.tsx +0 -137
- package/src/components/alerts/expandable-alert/expandable-alert.tsx +0 -78
- package/src/components/alerts/expandable-alert/index.ts +0 -1
- package/src/components/alerts/index.ts +0 -1
- package/src/components/components.stories.mdx +0 -20
- package/src/components/containers/center-container/center-container.stories.tsx +0 -52
- package/src/components/containers/center-container/center-container.test.tsx +0 -16
- package/src/components/containers/center-container/center-container.tsx +0 -32
- package/src/components/containers/center-container/index.ts +0 -1
- package/src/components/containers/containers.stories.mdx +0 -12
- package/src/components/containers/content/content.stories.tsx +0 -20
- package/src/components/containers/content/content.test.tsx +0 -26
- package/src/components/containers/content/content.tsx +0 -11
- package/src/components/containers/content/content.types.ts +0 -5
- package/src/components/containers/content/index.ts +0 -2
- package/src/components/containers/index.ts +0 -3
- package/src/components/containers/list-panel/index.ts +0 -2
- package/src/components/containers/list-panel/list-panel-panel.tsx +0 -17
- package/src/components/containers/list-panel/list-panel.context.tsx +0 -5
- package/src/components/containers/list-panel/list-panel.mocks.tsx +0 -117
- package/src/components/containers/list-panel/list-panel.stories.tsx +0 -38
- package/src/components/containers/list-panel/list-panel.test.tsx +0 -65
- package/src/components/containers/list-panel/list-panel.tsx +0 -88
- package/src/components/data-display/board/board.stories.tsx +0 -58
- package/src/components/data-display/board/board.test.tsx +0 -118
- package/src/components/data-display/board/board.tsx +0 -80
- package/src/components/data-display/board/index.ts +0 -1
- package/src/components/data-display/bullet/bullet.stories.tsx +0 -47
- package/src/components/data-display/bullet/bullet.test.tsx +0 -24
- package/src/components/data-display/bullet/bullet.tsx +0 -35
- package/src/components/data-display/bullet/index.ts +0 -1
- package/src/components/data-display/data-display.stories.mdx +0 -15
- package/src/components/data-display/header/header-title.tsx +0 -51
- package/src/components/data-display/header/header.dummy.ts +0 -56
- package/src/components/data-display/header/header.stories.tsx +0 -212
- package/src/components/data-display/header/header.test.tsx +0 -299
- package/src/components/data-display/header/header.tsx +0 -144
- package/src/components/data-display/header/header.types.ts +0 -96
- package/src/components/data-display/header/index.ts +0 -3
- package/src/components/data-display/index.ts +0 -5
- package/src/components/data-display/label/index.ts +0 -1
- package/src/components/data-display/label/label.stories.tsx +0 -53
- package/src/components/data-display/label/label.test.tsx +0 -30
- package/src/components/data-display/label/label.tsx +0 -93
- package/src/components/data-display/link-card/index.ts +0 -0
- package/src/components/data-display/link-card/link-card.stories.tsx +0 -59
- package/src/components/data-display/link-card/link-card.test.tsx +0 -43
- package/src/components/data-display/link-card/link-card.tsx +0 -52
- package/src/components/data-display/markdown/index.ts +0 -1
- package/src/components/data-display/markdown/markdown.stories.tsx +0 -25
- package/src/components/data-display/markdown/markdown.test.tsx +0 -64
- package/src/components/data-display/markdown/markdown.tsx +0 -38
- package/src/components/dialogs/bootstrap-dialog/bootstrap-dialog.stories.tsx +0 -86
- package/src/components/dialogs/bootstrap-dialog/bootstrap-dialog.test.tsx +0 -268
- package/src/components/dialogs/bootstrap-dialog/bootstrap-dialog.tsx +0 -97
- package/src/components/dialogs/bootstrap-dialog/index.ts +0 -1
- package/src/components/dialogs/confirm-dialog/confirm-dialog.stories.tsx +0 -58
- package/src/components/dialogs/confirm-dialog/confirm-dialog.test.tsx +0 -186
- package/src/components/dialogs/confirm-dialog/confirm-dialog.tsx +0 -67
- package/src/components/dialogs/confirm-dialog/index.ts +0 -1
- package/src/components/dialogs/dialog-hooks/index.ts +0 -1
- package/src/components/dialogs/dialog-hooks/use-dialog.ts +0 -10
- package/src/components/dialogs/dialog.types.ts +0 -29
- package/src/components/dialogs/dialogs.stories.mdx +0 -12
- package/src/components/dialogs/form-dialog/form-dialog.stories.tsx +0 -54
- package/src/components/dialogs/form-dialog/form-dialog.test.tsx +0 -165
- package/src/components/dialogs/form-dialog/form-dialog.tsx +0 -63
- package/src/components/dialogs/form-dialog/index.ts +0 -1
- package/src/components/dialogs/index.ts +0 -5
- package/src/components/drawers/drawer/drawer.stories.tsx +0 -35
- package/src/components/drawers/drawer/drawer.test.tsx +0 -83
- package/src/components/drawers/drawer/drawer.tsx +0 -94
- package/src/components/drawers/drawer/index.ts +0 -1
- package/src/components/drawers/drawer-app-bar/drawer-app-bar.stories.tsx +0 -26
- package/src/components/drawers/drawer-app-bar/drawer-app-bar.test.tsx +0 -83
- package/src/components/drawers/drawer-app-bar/drawer-app-bar.tsx +0 -87
- package/src/components/drawers/drawer-app-bar/index.ts +0 -1
- package/src/components/drawers/drawer-content/drawer-content.stories.tsx +0 -48
- package/src/components/drawers/drawer-content/drawer-content.test.tsx +0 -64
- package/src/components/drawers/drawer-content/drawer-content.tsx +0 -19
- package/src/components/drawers/drawer-content/index.ts +0 -1
- package/src/components/drawers/drawer-demo.stories.tsx +0 -94
- package/src/components/drawers/drawer-item/drawer-item-link.tsx +0 -149
- package/src/components/drawers/drawer-item/drawer-item.stories.tsx +0 -148
- package/src/components/drawers/drawer-item/drawer-item.test.tsx +0 -270
- package/src/components/drawers/drawer-item/drawer-item.tsx +0 -53
- package/src/components/drawers/drawer-item/drawer-menu-item.tsx +0 -137
- package/src/components/drawers/drawer-item/index.ts +0 -3
- package/src/components/drawers/drawer-main/drawer-main.tsx +0 -42
- package/src/components/drawers/drawer-main/index.ts +0 -1
- package/src/components/drawers/drawer-provider/drawer-context.test.tsx +0 -24
- package/src/components/drawers/drawer-provider/drawer-context.ts +0 -28
- package/src/components/drawers/drawer-provider/drawer-mixins.test.tsx +0 -25
- package/src/components/drawers/drawer-provider/drawer-mixins.ts +0 -24
- package/src/components/drawers/drawer-provider/drawer-provider.test.tsx +0 -165
- package/src/components/drawers/drawer-provider/drawer.provider.tsx +0 -64
- package/src/components/drawers/drawer-provider/index.ts +0 -3
- package/src/components/drawers/drawer-section/drawer-section.stories.tsx +0 -55
- package/src/components/drawers/drawer-section/drawer-section.test.tsx +0 -88
- package/src/components/drawers/drawer-section/drawer-section.tsx +0 -49
- package/src/components/drawers/drawer-section/index.ts +0 -1
- package/src/components/drawers/drawer-subheader/drawer-subheader.stories.tsx +0 -27
- package/src/components/drawers/drawer-subheader/drawer-subheader.tsx +0 -15
- package/src/components/drawers/drawer-subheader/index.ts +0 -1
- package/src/components/drawers/drawer.mock.tsx +0 -195
- package/src/components/drawers/drawer.types.ts +0 -78
- package/src/components/drawers/drawers.stories.mdx +0 -15
- package/src/components/drawers/index.ts +0 -8
- package/src/components/feedback/feedback.stories.mdx +0 -13
- package/src/components/feedback/index.ts +0 -2
- package/src/components/feedback/loading-area/index.ts +0 -1
- package/src/components/feedback/loading-area/loading-area.stories.tsx +0 -15
- package/src/components/feedback/loading-area/loading-area.test.tsx +0 -12
- package/src/components/feedback/loading-area/loading-area.tsx +0 -13
- package/src/components/feedback/query-container/index.ts +0 -1
- package/src/components/feedback/query-container/query-container.stories.tsx +0 -87
- package/src/components/feedback/query-container/query-container.test.tsx +0 -144
- package/src/components/feedback/query-container/query-container.tsx +0 -86
- package/src/components/index.ts +0 -11
- package/src/components/inputs/action/action-header.test.tsx +0 -11
- package/src/components/inputs/action/action-header.tsx +0 -37
- package/src/components/inputs/action/action.stories.tsx +0 -77
- package/src/components/inputs/action/action.test.tsx +0 -97
- package/src/components/inputs/action/action.tsx +0 -88
- package/src/components/inputs/action/index.ts +0 -2
- package/src/components/inputs/autocomplete/autocomplete.stories.tsx +0 -123
- package/src/components/inputs/autocomplete/autocomplete.test.tsx +0 -75
- package/src/components/inputs/autocomplete/autocomplete.tsx +0 -68
- package/src/components/inputs/autocomplete/index.ts +0 -1
- package/src/components/inputs/date-range-calendar/date-range-calendar.stories.tsx +0 -19
- package/src/components/inputs/date-range-calendar/date-range-calendar.test.tsx +0 -150
- package/src/components/inputs/date-range-calendar/date-range-calendar.tsx +0 -118
- package/src/components/inputs/date-range-calendar/index.ts +0 -1
- package/src/components/inputs/date-range-picker/date-range-picker.stories.tsx +0 -32
- package/src/components/inputs/date-range-picker/date-range-picker.test.tsx +0 -165
- package/src/components/inputs/date-range-picker/date-range-picker.tsx +0 -67
- package/src/components/inputs/date-range-picker/index.ts +0 -1
- package/src/components/inputs/index.ts +0 -7
- package/src/components/inputs/inputs.stories.mdx +0 -17
- package/src/components/inputs/search-input/index.ts +0 -1
- package/src/components/inputs/search-input/search-input.stories.tsx +0 -60
- package/src/components/inputs/search-input/search-input.test.tsx +0 -166
- package/src/components/inputs/search-input/search-input.tsx +0 -218
- package/src/components/inputs/select/index.ts +0 -1
- package/src/components/inputs/select/select.stories.tsx +0 -107
- package/src/components/inputs/select/select.test.tsx +0 -96
- package/src/components/inputs/select/select.tsx +0 -108
- package/src/components/inputs/sign-in/index.ts +0 -1
- package/src/components/inputs/sign-in/sign-in.stories.tsx +0 -37
- package/src/components/inputs/sign-in/sign-in.test.tsx +0 -97
- package/src/components/inputs/sign-in/sign-in.tsx +0 -97
- package/src/components/inputs/text-field/index.ts +0 -1
- package/src/components/inputs/text-field/text-field.stories.tsx +0 -136
- package/src/components/inputs/text-field/text-field.test.tsx +0 -64
- package/src/components/inputs/text-field/text-field.tsx +0 -101
- package/src/components/navigation/index.ts +0 -2
- package/src/components/navigation/link/index.ts +0 -1
- package/src/components/navigation/link/link.tsx +0 -17
- package/src/components/navigation/navigation.stories.mdx +0 -10
- package/src/components/navigation/tab-card/index.ts +0 -2
- package/src/components/navigation/tab-card/tab-card-panel.tsx +0 -19
- package/src/components/navigation/tab-card/tab-card.context.tsx +0 -7
- package/src/components/navigation/tab-card/tab-card.dummy.tsx +0 -34
- package/src/components/navigation/tab-card/tab-card.stories.tsx +0 -21
- package/src/components/navigation/tab-card/tab-card.test.tsx +0 -74
- package/src/components/navigation/tab-card/tab-card.tsx +0 -81
- package/src/components/navigation/tab-panel/index.ts +0 -1
- package/src/components/navigation/tab-panel/tab-panel.test.tsx +0 -26
- package/src/components/navigation/tab-panel/tab-panel.tsx +0 -27
- package/src/components/placeholders/content-placeholder/content-placeholder.stories.tsx +0 -13
- package/src/components/placeholders/content-placeholder/content-placeholder.tsx +0 -17
- package/src/components/placeholders/content-placeholder/index.ts +0 -1
- package/src/components/placeholders/index.ts +0 -5
- package/src/components/placeholders/lorem-ipsum-placeholder/index.ts +0 -1
- package/src/components/placeholders/lorem-ipsum-placeholder/lorem-ipsum-placeholder.stories.tsx +0 -13
- package/src/components/placeholders/lorem-ipsum-placeholder/lorem-ipsum-placeholder.tsx +0 -26
- package/src/components/placeholders/placeholder/index.ts +0 -1
- package/src/components/placeholders/placeholder/placeholder.mock.ts +0 -15
- package/src/components/placeholders/placeholder/placeholder.stories.tsx +0 -45
- package/src/components/placeholders/placeholder/placeholder.test.tsx +0 -78
- package/src/components/placeholders/placeholder/placeholder.tsx +0 -77
- package/src/components/placeholders/placeholders.stories.mdx +0 -14
- package/src/components/placeholders/skeleton-card/index.ts +0 -1
- package/src/components/placeholders/skeleton-card/skeleton-card.stories.tsx +0 -17
- package/src/components/placeholders/skeleton-card/skeleton-card.tsx +0 -17
- package/src/components/placeholders/skeleton-grid/index.ts +0 -1
- package/src/components/placeholders/skeleton-grid/skeleton-grid.stories.tsx +0 -13
- package/src/components/placeholders/skeleton-grid/skeleton-grid.tsx +0 -20
- package/src/components/tables/enhanced-remote-table/enhanced-remote-table.mock.tsx +0 -28
- package/src/components/tables/enhanced-remote-table/enhanced-remote-table.stories.tsx +0 -22
- package/src/components/tables/enhanced-remote-table/enhanced-remote-table.test.tsx +0 -78
- package/src/components/tables/enhanced-remote-table/enhanced-remote-table.tsx +0 -74
- package/src/components/tables/enhanced-remote-table/index.ts +0 -1
- package/src/components/tables/enhanced-table/enhanced-table-head.tsx +0 -63
- package/src/components/tables/enhanced-table/enhanced-table.mock.tsx +0 -99
- package/src/components/tables/enhanced-table/enhanced-table.stories.tsx +0 -20
- package/src/components/tables/enhanced-table/enhanced-table.test.tsx +0 -108
- package/src/components/tables/enhanced-table/enhanced-table.tsx +0 -136
- package/src/components/tables/enhanced-table/index.ts +0 -2
- package/src/components/tables/index.ts +0 -2
- package/src/components/tables/table.stories.mdx +0 -11
- package/src/components/value-displays/group-value-card/group-value-card.mock.tsx +0 -61
- package/src/components/value-displays/group-value-card/group-value-card.stories.tsx +0 -76
- package/src/components/value-displays/group-value-card/group-value-card.test.tsx +0 -61
- package/src/components/value-displays/group-value-card/group-value-card.tsx +0 -60
- package/src/components/value-displays/group-value-card/index.ts +0 -1
- package/src/components/value-displays/index.ts +0 -10
- package/src/components/value-displays/value-base/index.ts +0 -2
- package/src/components/value-displays/value-base/value-displays.types.ts +0 -36
- package/src/components/value-displays/value-base/value-edit.test.tsx +0 -88
- package/src/components/value-displays/value-base/value-edit.tsx +0 -81
- package/src/components/value-displays/value-boolean/index.ts +0 -1
- package/src/components/value-displays/value-boolean/value-boolean.stories.tsx +0 -49
- package/src/components/value-displays/value-boolean/value-boolean.test.tsx +0 -133
- package/src/components/value-displays/value-boolean/value-boolean.tsx +0 -66
- package/src/components/value-displays/value-card/index.ts +0 -1
- package/src/components/value-displays/value-card/value-card.stories.tsx +0 -22
- package/src/components/value-displays/value-card/value-card.test.tsx +0 -18
- package/src/components/value-displays/value-card/value-card.tsx +0 -12
- package/src/components/value-displays/value-content/index.ts +0 -1
- package/src/components/value-displays/value-content/value-content.stories.tsx +0 -27
- package/src/components/value-displays/value-content/value-content.test.tsx +0 -64
- package/src/components/value-displays/value-content/value-content.tsx +0 -81
- package/src/components/value-displays/value-datetime/index.ts +0 -1
- package/src/components/value-displays/value-datetime/value-datetime.stories.tsx +0 -86
- package/src/components/value-displays/value-datetime/value-datetime.test.tsx +0 -141
- package/src/components/value-displays/value-datetime/value-datetime.tsx +0 -99
- package/src/components/value-displays/value-displays.stories.mdx +0 -39
- package/src/components/value-displays/value-image/index.ts +0 -1
- package/src/components/value-displays/value-image/value-image.stories.tsx +0 -37
- package/src/components/value-displays/value-image/value-image.test.tsx +0 -22
- package/src/components/value-displays/value-image/value-image.tsx +0 -26
- package/src/components/value-displays/value-item/index.ts +0 -1
- package/src/components/value-displays/value-item/value-item.stories.tsx +0 -45
- package/src/components/value-displays/value-item/value-item.test.tsx +0 -20
- package/src/components/value-displays/value-item/value-item.tsx +0 -54
- package/src/components/value-displays/value-label/index.ts +0 -1
- package/src/components/value-displays/value-label/value-label.stories.tsx +0 -78
- package/src/components/value-displays/value-label/value-label.test.tsx +0 -72
- package/src/components/value-displays/value-label/value-label.tsx +0 -45
- package/src/components/value-displays/value-rating/index.ts +0 -1
- package/src/components/value-displays/value-rating/value-rating.stories.tsx +0 -55
- package/src/components/value-displays/value-rating/value-rating.test.tsx +0 -105
- package/src/components/value-displays/value-rating/value-rating.tsx +0 -48
- package/src/components/value-displays/value-text/index.ts +0 -1
- package/src/components/value-displays/value-text/value-text.stories.tsx +0 -72
- package/src/components/value-displays/value-text/value-text.test.tsx +0 -129
- package/src/components/value-displays/value-text/value-text.tsx +0 -67
- package/src/generators/generators.mock.ts +0 -298
- package/src/generators/generators.model.test.ts +0 -79
- package/src/generators/generators.model.ts +0 -180
- package/src/generators/generators.stories.mdx +0 -13
- package/src/generators/index.ts +0 -5
- package/src/generators/model-form/index.ts +0 -1
- package/src/generators/model-form/model-form-field.tsx +0 -269
- package/src/generators/model-form/model-form.stories.tsx +0 -40
- package/src/generators/model-form/model-form.test.tsx +0 -133
- package/src/generators/model-form/model-form.tsx +0 -62
- package/src/generators/model-router/index.ts +0 -2
- package/src/generators/model-router/model-router.test.tsx +0 -1104
- package/src/generators/model-router/model-router.tsx +0 -30
- package/src/generators/model-router/model-router.types.ts +0 -18
- package/src/generators/model-router/screens/add-screen.tsx +0 -67
- package/src/generators/model-router/screens/details-screen.tsx +0 -64
- package/src/generators/model-router/screens/index.ts +0 -4
- package/src/generators/model-router/screens/list-screen.tsx +0 -143
- package/src/generators/model-router/screens/screens.types.ts +0 -38
- package/src/generators/model-router/screens/update-screen.tsx +0 -105
- package/src/generators/model-router/stories/details-screen.stories.tsx +0 -39
- package/src/generators/model-router/stories/list-screen.stories.tsx +0 -102
- package/src/generators/model-router/stories/model-router.stories.tsx +0 -229
- package/src/generators/model-router/stories/templates.tsx +0 -33
- package/src/generators/object-details/index.ts +0 -1
- package/src/generators/object-details/object-details.stories.tsx +0 -30
- package/src/generators/object-details/object-details.test.tsx +0 -22
- package/src/generators/object-details/object-details.tsx +0 -169
- package/src/generators/table-list/index.ts +0 -1
- package/src/generators/table-list/table-list.stories.tsx +0 -91
- package/src/generators/table-list/table-list.test.tsx +0 -297
- package/src/generators/table-list/table-list.tsx +0 -138
- package/src/hooks/index.ts +0 -1
- package/src/hooks/routing/index.ts +0 -1
- package/src/hooks/routing/routing.hooks.ts +0 -23
- package/src/hooks/routing/routing.test.tsx +0 -83
- package/src/index.ts +0 -5
- package/src/layouts/drawer-layout/drawer-layout.stories.tsx +0 -57
- package/src/layouts/drawer-layout/drawer-layout.test.tsx +0 -41
- package/src/layouts/drawer-layout/drawer-layout.tsx +0 -26
- package/src/layouts/drawer-layout/index.ts +0 -1
- package/src/layouts/header-layout/header-layout.stories.tsx +0 -245
- package/src/layouts/header-layout/header-layout.test.tsx +0 -102
- package/src/layouts/header-layout/header-layout.tsx +0 -49
- package/src/layouts/header-layout/index.ts +0 -1
- package/src/layouts/index.ts +0 -2
- package/src/layouts/layouts.stories.mdx +0 -11
- package/src/providers/index.ts +0 -2
- package/src/providers/notification-center/index.ts +0 -3
- package/src/providers/notification-center/notification-center.context.ts +0 -31
- package/src/providers/notification-center/notification-center.hooks.ts +0 -23
- package/src/providers/notification-center/notification-center.provider.tsx +0 -51
- package/src/providers/notification-center/notification-center.stories.tsx +0 -52
- package/src/providers/notification-center/notification-center.test.tsx +0 -198
- package/src/providers/tab-provider/index.ts +0 -2
- package/src/providers/tab-provider/tab-provider.context.ts +0 -8
- package/src/providers/tab-provider/tab-provider.provider.tsx +0 -13
- package/src/stories/Introduction.stories.mdx +0 -33
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/stories/assets/work-in-progress.jpg +0 -0
- package/src/stories/getting-started.stories.mdx +0 -23
- package/src/storybook.tsx +0 -139
- package/src/tests/actions.ts +0 -48
- package/src/tests/assertions.ts +0 -206
- package/src/tests/datatable-placeholder/datatable-placeholder.stories.tsx +0 -13
- package/src/tests/datatable-placeholder/datatable-placeholder.tsx +0 -38
- package/src/tests/datatable-placeholder/index.ts +0 -1
- package/src/tests/file-mock.ts +0 -1
- package/src/tests/mocks/markdown.mock.ts +0 -25
- package/src/tests/mocks.ts +0 -23
- package/src/tests/testing-library.tsx +0 -79
- package/src/types/index.d.ts +0 -10
- package/src/types.d.ts +0 -4
- package/src/utils/arrays.test.ts +0 -9
- package/src/utils/arrays.ts +0 -7
- package/src/utils/breakpoints.test.ts +0 -42
- package/src/utils/breakpoints.ts +0 -62
- package/src/utils/forms.ts +0 -11
- package/src/utils/index.ts +0 -4
- package/src/utils/theme.ts +0 -11
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "~/tests/testing-library";
|
|
3
|
-
import { screen } from "@testing-library/react";
|
|
4
|
-
import userEvents from "@testing-library/user-event";
|
|
5
|
-
import { TableRowOption, TableList } from "./table-list";
|
|
6
|
-
import { HeadCell } from "../../components/tables/enhanced-table";
|
|
7
|
-
import { BasicModelInstance } from "..";
|
|
8
|
-
import { expectProgressIndicator } from "~/tests/assertions";
|
|
9
|
-
import { vi } from "vitest";
|
|
10
|
-
|
|
11
|
-
const columns: HeadCell<BasicModelInstance>[] = [
|
|
12
|
-
{
|
|
13
|
-
id: "id",
|
|
14
|
-
numeric: true,
|
|
15
|
-
disablePadding: false,
|
|
16
|
-
label: "Item ID",
|
|
17
|
-
sort: false,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: "name",
|
|
21
|
-
numeric: false,
|
|
22
|
-
disablePadding: false,
|
|
23
|
-
label: "Name",
|
|
24
|
-
sort: true,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: "value",
|
|
28
|
-
numeric: true,
|
|
29
|
-
disablePadding: false,
|
|
30
|
-
label: "Value",
|
|
31
|
-
sort: true,
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
const data: BasicModelInstance[] = [
|
|
35
|
-
{
|
|
36
|
-
id: "item-c",
|
|
37
|
-
name: "fg Item 1",
|
|
38
|
-
value: 1,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: "item-a",
|
|
42
|
-
name: "aa Item 2",
|
|
43
|
-
value: 2,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "item-l",
|
|
47
|
-
name: "ba Item 3",
|
|
48
|
-
value: 3,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
id: "item-j",
|
|
52
|
-
name: "aa Item 4",
|
|
53
|
-
value: 4,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: "item-w",
|
|
57
|
-
name: "cd Item 5",
|
|
58
|
-
value: 5,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
const options = [
|
|
63
|
-
{
|
|
64
|
-
id: "edit",
|
|
65
|
-
label: "Edit",
|
|
66
|
-
onClick: vi.fn(),
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: "remove",
|
|
70
|
-
label: "Remove",
|
|
71
|
-
onClick: vi.fn(),
|
|
72
|
-
},
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
describe("TableList", () => {
|
|
76
|
-
const renderInstance = ({
|
|
77
|
-
search = false,
|
|
78
|
-
defaultSort = "value",
|
|
79
|
-
loading = false,
|
|
80
|
-
options = undefined,
|
|
81
|
-
onClick = vi.fn(),
|
|
82
|
-
}: {
|
|
83
|
-
defaultSort?: string;
|
|
84
|
-
loading?: boolean;
|
|
85
|
-
search?: boolean;
|
|
86
|
-
options?: TableRowOption<BasicModelInstance>[];
|
|
87
|
-
onClick?: jest.Mock;
|
|
88
|
-
} = {}) => {
|
|
89
|
-
const instance = render(
|
|
90
|
-
<TableList
|
|
91
|
-
search={search}
|
|
92
|
-
data={data}
|
|
93
|
-
columns={columns}
|
|
94
|
-
defaultSort={defaultSort}
|
|
95
|
-
defaultOrder="asc"
|
|
96
|
-
loading={loading}
|
|
97
|
-
options={options}
|
|
98
|
-
onClick={onClick}
|
|
99
|
-
/>,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
return { ...instance, onClick };
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const openOptionsMenu = async (index = 0) => {
|
|
106
|
-
await userEvents.click(screen.getAllByTestId("MoreVertIcon")[index]);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
it("would render all items and its values", () => {
|
|
110
|
-
renderInstance();
|
|
111
|
-
|
|
112
|
-
data.forEach(({ id, name, value }) => {
|
|
113
|
-
expect(screen.getByRole("cell", { name: id })).toBeInTheDocument();
|
|
114
|
-
expect(screen.getByRole("cell", { name: name as string })).toBeInTheDocument();
|
|
115
|
-
expect(screen.getByRole("cell", { name: value as string })).toBeInTheDocument();
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("all items are rendered in the correct default order", async () => {
|
|
120
|
-
renderInstance();
|
|
121
|
-
|
|
122
|
-
[/item 1/i, /item 2/i, /item 3/i, /item 4/i, /item 5/i].forEach((item, index) => {
|
|
123
|
-
expect(screen.getByRole("cell", { name: item })).toHaveAttribute(
|
|
124
|
-
"aria-rowindex",
|
|
125
|
-
index.toString(),
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("loading is true a loading indicator is displayed", () => {
|
|
131
|
-
renderInstance({ loading: true });
|
|
132
|
-
|
|
133
|
-
expectProgressIndicator();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe("search", () => {
|
|
137
|
-
it("would render a search input if search is true", () => {
|
|
138
|
-
renderInstance({ search: true });
|
|
139
|
-
|
|
140
|
-
expect(screen.getByRole("search")).toBeInTheDocument();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("wouldn't render a search input if search is false", () => {
|
|
144
|
-
renderInstance({ search: false });
|
|
145
|
-
|
|
146
|
-
expect(screen.queryByRole("search")).not.toBeInTheDocument();
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe("if I search an 'a'", () => {
|
|
151
|
-
it("would render the items 2,3 and 4", async () => {
|
|
152
|
-
renderInstance({ search: true });
|
|
153
|
-
|
|
154
|
-
const search = screen.getByPlaceholderText(/search/i);
|
|
155
|
-
await userEvents.type(search, "a");
|
|
156
|
-
|
|
157
|
-
expect(screen.getByText(/item 2/i)).toBeInTheDocument();
|
|
158
|
-
expect(screen.getByText(/item 3/i)).toBeInTheDocument();
|
|
159
|
-
expect(screen.getByText(/item 4/i)).toBeInTheDocument();
|
|
160
|
-
|
|
161
|
-
expect(screen.queryByText(/item 1/i)).not.toBeInTheDocument();
|
|
162
|
-
expect(screen.queryByText(/item 5/i)).not.toBeInTheDocument();
|
|
163
|
-
|
|
164
|
-
await userEvents.clear(search);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("would render all the items if I remove the search", async () => {
|
|
168
|
-
renderInstance({ search: true });
|
|
169
|
-
|
|
170
|
-
const search = screen.getByPlaceholderText(/search/i);
|
|
171
|
-
await userEvents.type(search, "a");
|
|
172
|
-
await userEvents.clear(search);
|
|
173
|
-
|
|
174
|
-
expect(screen.getByText(/item 1/i)).toBeInTheDocument();
|
|
175
|
-
expect(screen.getByText(/item 2/i)).toBeInTheDocument();
|
|
176
|
-
expect(screen.getByText(/item 3/i)).toBeInTheDocument();
|
|
177
|
-
expect(screen.getByText(/item 4/i)).toBeInTheDocument();
|
|
178
|
-
expect(screen.getByText(/item 5/i)).toBeInTheDocument();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe("sort by a sortable column", () => {
|
|
183
|
-
it("once it will be asc sorted", async () => {
|
|
184
|
-
renderInstance();
|
|
185
|
-
|
|
186
|
-
await userEvents.click(screen.getByText(/name/i));
|
|
187
|
-
|
|
188
|
-
expect(screen.getByRole("cell", { name: /item 2/i })).toHaveAttribute("aria-rowindex", "0");
|
|
189
|
-
expect(screen.getByRole("cell", { name: /item 4/i })).toHaveAttribute("aria-rowindex", "1");
|
|
190
|
-
expect(screen.getByRole("cell", { name: /item 3/i })).toHaveAttribute("aria-rowindex", "2");
|
|
191
|
-
expect(screen.getByRole("cell", { name: /item 5/i })).toHaveAttribute("aria-rowindex", "3");
|
|
192
|
-
expect(screen.getByRole("cell", { name: /item 1/i })).toHaveAttribute("aria-rowindex", "4");
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("two times it will be desc sorted", async () => {
|
|
196
|
-
renderInstance();
|
|
197
|
-
|
|
198
|
-
await userEvents.click(screen.getByText(/name/i));
|
|
199
|
-
await userEvents.click(screen.getByText(/name/i));
|
|
200
|
-
|
|
201
|
-
expect(screen.getByRole("cell", { name: /item 1/i })).toHaveAttribute("aria-rowindex", "0");
|
|
202
|
-
expect(screen.getByRole("cell", { name: /item 5/i })).toHaveAttribute("aria-rowindex", "1");
|
|
203
|
-
expect(screen.getByRole("cell", { name: /item 3/i })).toHaveAttribute("aria-rowindex", "2");
|
|
204
|
-
expect(screen.getByRole("cell", { name: /item 4/i })).toHaveAttribute("aria-rowindex", "3");
|
|
205
|
-
expect(screen.getByRole("cell", { name: /item 2/i })).toHaveAttribute("aria-rowindex", "4");
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("sort a non sortable column", async () => {
|
|
210
|
-
renderInstance();
|
|
211
|
-
|
|
212
|
-
await userEvents.click(screen.getByText(/id/i));
|
|
213
|
-
|
|
214
|
-
expect(screen.getByRole("cell", { name: /item 1/i })).toHaveAttribute("aria-rowindex", "0");
|
|
215
|
-
expect(screen.getByRole("cell", { name: /item 2/i })).toHaveAttribute("aria-rowindex", "1");
|
|
216
|
-
expect(screen.getByRole("cell", { name: /item 3/i })).toHaveAttribute("aria-rowindex", "2");
|
|
217
|
-
expect(screen.getByRole("cell", { name: /item 4/i })).toHaveAttribute("aria-rowindex", "3");
|
|
218
|
-
expect(screen.getByRole("cell", { name: /item 5/i })).toHaveAttribute("aria-rowindex", "4");
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
it("would call onClick if a row is clicked", async () => {
|
|
222
|
-
const { onClick } = renderInstance();
|
|
223
|
-
|
|
224
|
-
await userEvents.click(screen.getByRole("row", { name: /item 3/i }));
|
|
225
|
-
|
|
226
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
227
|
-
expect(onClick).toHaveBeenCalledWith(data[2]);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("would continue working if onClick is not defined and we click a row", async () => {
|
|
231
|
-
renderInstance({ onClick: undefined });
|
|
232
|
-
|
|
233
|
-
await userEvents.click(screen.getByRole("row", { name: /item 3/i }));
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// TODO: this tests are throwing a console.error
|
|
237
|
-
describe("options menu", () => {
|
|
238
|
-
it("would render a button to open the menu if doesn't have options", () => {
|
|
239
|
-
renderInstance({ options: undefined });
|
|
240
|
-
|
|
241
|
-
expect(screen.queryByTestId("MoreVertIcon")).not.toBeInTheDocument();
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it("would render a button to open the menu if has options", () => {
|
|
245
|
-
renderInstance({ options });
|
|
246
|
-
|
|
247
|
-
screen.getAllByTestId("MoreVertIcon");
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it("would render a menu if has options", async () => {
|
|
251
|
-
renderInstance({ options });
|
|
252
|
-
|
|
253
|
-
await openOptionsMenu();
|
|
254
|
-
|
|
255
|
-
expect(await screen.findByRole("menu")).toBeInTheDocument();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it.each([
|
|
259
|
-
[/edit/i, 0],
|
|
260
|
-
[/remove/i, 1],
|
|
261
|
-
])("would call the option onClick with the row if %s option is clicked", async (name, i) => {
|
|
262
|
-
const index = 1;
|
|
263
|
-
const item = data[index];
|
|
264
|
-
const option = options[i];
|
|
265
|
-
|
|
266
|
-
renderInstance({ options });
|
|
267
|
-
|
|
268
|
-
await openOptionsMenu(index);
|
|
269
|
-
|
|
270
|
-
await userEvents.click(screen.getByRole("menuitem", { name }));
|
|
271
|
-
|
|
272
|
-
expect(option.onClick).toHaveBeenCalledTimes(1);
|
|
273
|
-
expect(option.onClick).toHaveBeenCalledWith(item);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("would close the menu when an option is clicked", async () => {
|
|
277
|
-
const index = 1;
|
|
278
|
-
|
|
279
|
-
renderInstance({ options });
|
|
280
|
-
|
|
281
|
-
await openOptionsMenu(index);
|
|
282
|
-
await userEvents.click(screen.getByRole("menuitem", { name: /edit/i }));
|
|
283
|
-
|
|
284
|
-
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("wouldn't call the component onClick if an option if clicked", async () => {
|
|
288
|
-
const { onClick } = renderInstance({ options });
|
|
289
|
-
|
|
290
|
-
await openOptionsMenu();
|
|
291
|
-
|
|
292
|
-
await userEvents.click(screen.getByRole("menuitem", { name: /edit/i }));
|
|
293
|
-
|
|
294
|
-
expect(onClick).not.toHaveBeenCalled();
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { TableRow, TableCell, IconButton, MenuItem, Menu } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { EnhancedTable, HeadCell, Order } from "../../components/tables/enhanced-table";
|
|
4
|
-
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|
5
|
-
import { BasicModelInstance } from "../generators.model";
|
|
6
|
-
|
|
7
|
-
const OptionsId = "__options";
|
|
8
|
-
|
|
9
|
-
export interface TableRowOption<T extends BasicModelInstance> {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
onClick: (item: T) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface TableListProps<T extends BasicModelInstance> {
|
|
16
|
-
columns: HeadCell<T>[];
|
|
17
|
-
data: T[];
|
|
18
|
-
search?: boolean;
|
|
19
|
-
defaultSort: string;
|
|
20
|
-
defaultOrder?: Order;
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
options?: TableRowOption<T>[];
|
|
23
|
-
onClick?: (d: T) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// TODO: Move this to teh generators section
|
|
27
|
-
export const TableList = <T extends BasicModelInstance>({
|
|
28
|
-
columns: columnsProp,
|
|
29
|
-
options,
|
|
30
|
-
data,
|
|
31
|
-
onClick,
|
|
32
|
-
search,
|
|
33
|
-
defaultSort,
|
|
34
|
-
defaultOrder,
|
|
35
|
-
loading,
|
|
36
|
-
}: TableListProps<T>) => {
|
|
37
|
-
const columns = [
|
|
38
|
-
...columnsProp,
|
|
39
|
-
{
|
|
40
|
-
id: OptionsId,
|
|
41
|
-
label: "",
|
|
42
|
-
disablePadding: false,
|
|
43
|
-
numeric: false,
|
|
44
|
-
sort: false,
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
const [anchorMenuEl, setAnchorMenuEl] = React.useState<null | { item: T; anchor: HTMLElement }>(
|
|
48
|
-
null,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
<EnhancedTable<T>
|
|
54
|
-
columns={columns}
|
|
55
|
-
data={data}
|
|
56
|
-
search={search}
|
|
57
|
-
defaultSort={defaultSort}
|
|
58
|
-
defaultOrder={defaultOrder}
|
|
59
|
-
loading={loading}
|
|
60
|
-
>
|
|
61
|
-
{(filteredData) =>
|
|
62
|
-
filteredData.map((row, i) => {
|
|
63
|
-
return (
|
|
64
|
-
<TableRow
|
|
65
|
-
key={row.id}
|
|
66
|
-
onClick={() => onClick && onClick(row)}
|
|
67
|
-
role="row"
|
|
68
|
-
aria-rowindex={i}
|
|
69
|
-
sx={{ cursor: onClick && "pointer" }}
|
|
70
|
-
>
|
|
71
|
-
{columns.map(({ id }, j) => (
|
|
72
|
-
<TableCell
|
|
73
|
-
role="cell"
|
|
74
|
-
scope="row"
|
|
75
|
-
key={id.toString()}
|
|
76
|
-
aria-rowindex={i}
|
|
77
|
-
aria-colindex={j}
|
|
78
|
-
>
|
|
79
|
-
{
|
|
80
|
-
row[
|
|
81
|
-
id
|
|
82
|
-
] as string /* TODO: This has to be reimplemented having a cell based on each model type */
|
|
83
|
-
}
|
|
84
|
-
</TableCell>
|
|
85
|
-
))}
|
|
86
|
-
{options && (
|
|
87
|
-
<TableCell>
|
|
88
|
-
<IconButton
|
|
89
|
-
data-testid={`options-${row.id}`}
|
|
90
|
-
onClick={(event) => {
|
|
91
|
-
event.stopPropagation();
|
|
92
|
-
setAnchorMenuEl({
|
|
93
|
-
item: row,
|
|
94
|
-
anchor: event.currentTarget,
|
|
95
|
-
});
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<MoreVertIcon />
|
|
99
|
-
</IconButton>
|
|
100
|
-
</TableCell>
|
|
101
|
-
)}
|
|
102
|
-
</TableRow>
|
|
103
|
-
);
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
</EnhancedTable>
|
|
107
|
-
{options && (
|
|
108
|
-
<Menu
|
|
109
|
-
anchorEl={anchorMenuEl?.anchor}
|
|
110
|
-
open={!!anchorMenuEl}
|
|
111
|
-
onClose={() => setAnchorMenuEl(null)}
|
|
112
|
-
anchorOrigin={{
|
|
113
|
-
vertical: "top",
|
|
114
|
-
horizontal: "left",
|
|
115
|
-
}}
|
|
116
|
-
transformOrigin={{
|
|
117
|
-
vertical: "top",
|
|
118
|
-
horizontal: "left",
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
{options.map(({ id, label, onClick }) => (
|
|
122
|
-
<MenuItem
|
|
123
|
-
key={id}
|
|
124
|
-
onClick={() => {
|
|
125
|
-
if (anchorMenuEl) {
|
|
126
|
-
onClick(anchorMenuEl?.item);
|
|
127
|
-
}
|
|
128
|
-
setAnchorMenuEl(null);
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
{label}
|
|
132
|
-
</MenuItem>
|
|
133
|
-
))}
|
|
134
|
-
</Menu>
|
|
135
|
-
)}
|
|
136
|
-
</>
|
|
137
|
-
);
|
|
138
|
-
};
|
package/src/hooks/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./routing";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./routing.hooks";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useNavigate } from "react-router-dom";
|
|
3
|
-
|
|
4
|
-
export interface NavigateWhenValueChangesOptions<T> {
|
|
5
|
-
from: T;
|
|
6
|
-
to: T;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const useNavigateWhenValueChanges = <T>(
|
|
10
|
-
path: string,
|
|
11
|
-
value: T | undefined,
|
|
12
|
-
{ from, to }: NavigateWhenValueChangesOptions<T>,
|
|
13
|
-
) => {
|
|
14
|
-
const prevRef = useRef<T>();
|
|
15
|
-
const navigate = useNavigate();
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (prevRef.current === from && value === to) {
|
|
19
|
-
navigate(path);
|
|
20
|
-
}
|
|
21
|
-
prevRef.current = value;
|
|
22
|
-
}, [value]);
|
|
23
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Box, Button, Typography } from "@mui/material";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
import { Routes, Route } from "react-router-dom";
|
|
4
|
-
import { render, screen } from "~/tests/testing-library";
|
|
5
|
-
import { useNavigateWhenValueChanges } from "./routing.hooks";
|
|
6
|
-
import userEvent from "@testing-library/user-event";
|
|
7
|
-
|
|
8
|
-
describe("useNavigateWhenValueChanges", () => {
|
|
9
|
-
const renderHook = ({ to, from }: { to: boolean; from: boolean }) => {
|
|
10
|
-
const DummyComponent = () => {
|
|
11
|
-
const [value, setValue] = useState<boolean | undefined>(false);
|
|
12
|
-
useNavigateWhenValueChanges("/destination", value, { from, to });
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Box>
|
|
16
|
-
<Button onClick={() => setValue(undefined)}>undefined</Button>
|
|
17
|
-
<Button onClick={() => setValue(false)}>false</Button>
|
|
18
|
-
<Button onClick={() => setValue(true)}>true</Button>
|
|
19
|
-
</Box>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const DummyRoute = ({ label }: { label: string }) => {
|
|
24
|
-
return <Typography>{label}</Typography>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const { history } = render(
|
|
28
|
-
<>
|
|
29
|
-
<Routes>
|
|
30
|
-
<Route path="" element={<DummyRoute label="initial" />} />
|
|
31
|
-
<Route path="" element={<DummyRoute label="destination" />} />
|
|
32
|
-
</Routes>
|
|
33
|
-
<DummyComponent />
|
|
34
|
-
</>,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return { history };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const changeValueTo = async (value: "undefined" | "false" | "true") => {
|
|
41
|
-
await userEvent.click(screen.getByRole("button", { name: value }));
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
it("wouldn't change the route when method when is rendered", () => {
|
|
45
|
-
const { history } = renderHook({ to: true, from: false });
|
|
46
|
-
|
|
47
|
-
expect(history.location.pathname).toBe("/");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("wouldn't change the route when it changes to a value that is not to", async () => {
|
|
51
|
-
const { history } = renderHook({ to: true, from: false });
|
|
52
|
-
|
|
53
|
-
await changeValueTo("false");
|
|
54
|
-
|
|
55
|
-
expect(history.location.pathname).toBe("/");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("wouldn't change the route when value changes to a value that is not to", async () => {
|
|
59
|
-
const { history } = renderHook({ to: true, from: false });
|
|
60
|
-
|
|
61
|
-
await changeValueTo("false");
|
|
62
|
-
|
|
63
|
-
expect(history.location.pathname).toBe("/");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("wouldn't change the route when value changes from undefined to to", async () => {
|
|
67
|
-
const { history } = renderHook({ to: true, from: false });
|
|
68
|
-
|
|
69
|
-
await changeValueTo("undefined");
|
|
70
|
-
await changeValueTo("true");
|
|
71
|
-
|
|
72
|
-
expect(history.location.pathname).toBe("/");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("would change the route when value changes from to to", async () => {
|
|
76
|
-
const { history } = renderHook({ to: true, from: false });
|
|
77
|
-
|
|
78
|
-
await changeValueTo("false");
|
|
79
|
-
await changeValueTo("true");
|
|
80
|
-
|
|
81
|
-
expect(history.location.pathname).toBe("/destination");
|
|
82
|
-
});
|
|
83
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import { DrawerLayout } from "./drawer-layout";
|
|
4
|
-
import { mockDrawerNavigation } from "../../components/drawers/drawer.mock";
|
|
5
|
-
import { ContentPlaceholder, DrawerContent, Drawer, DrawerAppBar } from "../../components";
|
|
6
|
-
import { withMemoryRouter } from "~/storybook";
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: "Layouts/DrawerLayout",
|
|
10
|
-
component: DrawerLayout,
|
|
11
|
-
decorators: [withMemoryRouter()],
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: "fullscreen",
|
|
14
|
-
},
|
|
15
|
-
render: (args) => (
|
|
16
|
-
<DrawerLayout {...args}>
|
|
17
|
-
<Drawer>
|
|
18
|
-
<DrawerContent nav={mockDrawerNavigation} />
|
|
19
|
-
</Drawer>
|
|
20
|
-
<DrawerAppBar title="Lorem ipsum" />
|
|
21
|
-
<ContentPlaceholder p={3} />
|
|
22
|
-
</DrawerLayout>
|
|
23
|
-
),
|
|
24
|
-
} satisfies Meta<typeof DrawerLayout>;
|
|
25
|
-
type Story = StoryObj<typeof DrawerLayout>;
|
|
26
|
-
|
|
27
|
-
export const Temporary: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
drawerProviderProps: {
|
|
30
|
-
variant: "temporary",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const Persistent: Story = {
|
|
36
|
-
args: {
|
|
37
|
-
drawerProviderProps: {
|
|
38
|
-
variant: "persistent",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const Clipped: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
drawerProviderProps: {
|
|
46
|
-
variant: "clipped",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const Mini: Story = {
|
|
52
|
-
args: {
|
|
53
|
-
drawerProviderProps: {
|
|
54
|
-
variant: "mini",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, screen } from "~/tests/testing-library";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { expectContentPlaceholder } from "~/tests/assertions";
|
|
5
|
-
import { Drawer, DrawerContent, DrawerAppBar, ContentPlaceholder } from "~/components";
|
|
6
|
-
import { mockDrawerNavigation } from "~/components/drawers/drawer.mock";
|
|
7
|
-
import { DrawerLayout } from "./drawer-layout";
|
|
8
|
-
|
|
9
|
-
describe("DrawerLayout", () => {
|
|
10
|
-
const renderComponent = () => {
|
|
11
|
-
return render(
|
|
12
|
-
<DrawerLayout>
|
|
13
|
-
<Drawer>
|
|
14
|
-
<DrawerContent nav={mockDrawerNavigation} />
|
|
15
|
-
</Drawer>
|
|
16
|
-
<DrawerAppBar title="Lorem ipsum" />
|
|
17
|
-
<ContentPlaceholder p={3} />
|
|
18
|
-
</DrawerLayout>,
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
it("would render a drawer", async () => {
|
|
23
|
-
renderComponent();
|
|
24
|
-
|
|
25
|
-
await userEvent.click(screen.getByTestId("MenuIcon"));
|
|
26
|
-
|
|
27
|
-
expect(screen.getByRole("link", { name: /item 1.1/i })).toBeInTheDocument();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("would render an appbar", () => {
|
|
31
|
-
renderComponent();
|
|
32
|
-
|
|
33
|
-
expect(screen.getByRole("heading", { level: 1, name: /lorem ipsum/i })).toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("would render the content", async () => {
|
|
37
|
-
renderComponent();
|
|
38
|
-
|
|
39
|
-
await expectContentPlaceholder();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { DrawerAppBarElement, DrawerElement, DrawerMain } from "../../components/drawers";
|
|
3
|
-
import {
|
|
4
|
-
DrawerProvider,
|
|
5
|
-
DrawerProviderProps,
|
|
6
|
-
} from "../../components/drawers/drawer-provider/drawer.provider";
|
|
7
|
-
|
|
8
|
-
export interface DrawerLayoutProps {
|
|
9
|
-
drawerProviderProps?: DrawerProviderProps;
|
|
10
|
-
children: [DrawerElement, DrawerAppBarElement, ReactNode];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DrawerLayout = ({
|
|
14
|
-
drawerProviderProps,
|
|
15
|
-
children: childrenProps,
|
|
16
|
-
}: DrawerLayoutProps) => {
|
|
17
|
-
const [appBar, drawer, children] = childrenProps;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<DrawerProvider {...drawerProviderProps}>
|
|
21
|
-
{appBar}
|
|
22
|
-
{drawer}
|
|
23
|
-
<DrawerMain>{children}</DrawerMain>
|
|
24
|
-
</DrawerProvider>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./drawer-layout";
|