@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,51 +0,0 @@
|
|
|
1
|
-
import { CircularProgress, Typography, useTheme } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
|
-
export type HeaderTitleProps = PropsWithChildren<{ loading?: boolean }>;
|
|
6
|
-
|
|
7
|
-
export const HeaderTitle = ({ loading, children }: HeaderTitleProps) => {
|
|
8
|
-
const { typography } = useTheme();
|
|
9
|
-
|
|
10
|
-
if (loading) {
|
|
11
|
-
return (
|
|
12
|
-
<CircularProgress color="inherit" size={typography.h4.fontSize} aria-label="title loading" />
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof children === "string") {
|
|
17
|
-
return (
|
|
18
|
-
<Typography variant="h4" role="heading" aria-level={1}>
|
|
19
|
-
{children}
|
|
20
|
-
</Typography>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return <>{children}</>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type HeaderSubtitleProps = PropsWithChildren<{ loading?: boolean }>;
|
|
28
|
-
|
|
29
|
-
export const HeaderSubtitle = ({ loading, children }: HeaderSubtitleProps) => {
|
|
30
|
-
const { typography } = useTheme();
|
|
31
|
-
|
|
32
|
-
if (loading) {
|
|
33
|
-
return (
|
|
34
|
-
<CircularProgress
|
|
35
|
-
color="inherit"
|
|
36
|
-
size={typography.body1.fontSize}
|
|
37
|
-
aria-label="subtitle loading"
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof children === "string") {
|
|
43
|
-
return (
|
|
44
|
-
<Typography variant="body1" role="heading" aria-level={2}>
|
|
45
|
-
{children}
|
|
46
|
-
</Typography>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return <>{children}</>;
|
|
51
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { action } from "@storybook/addon-actions";
|
|
2
|
-
import { HeaderBreadcrumb, HeaderAction, HeaderTab } from "./header.types";
|
|
3
|
-
|
|
4
|
-
export const breadcrumbs: HeaderBreadcrumb[] = [
|
|
5
|
-
{
|
|
6
|
-
id: "list",
|
|
7
|
-
text: "Items",
|
|
8
|
-
link: "/items",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
id: "item",
|
|
12
|
-
text: "Item 1",
|
|
13
|
-
link: "/items/1",
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
export const actions: HeaderAction[] = [
|
|
18
|
-
{
|
|
19
|
-
id: "new",
|
|
20
|
-
text: "Add",
|
|
21
|
-
href: "/items/add",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: "edit",
|
|
25
|
-
text: "Edit",
|
|
26
|
-
onClick: action("click action edit"),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: "disabled",
|
|
30
|
-
text: "Disabled",
|
|
31
|
-
disabled: true,
|
|
32
|
-
onClick: action("click action disabled"),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: "delete",
|
|
36
|
-
text: "Delete",
|
|
37
|
-
onClick: action("click action delete"),
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
export const tabs: HeaderTab[] = [
|
|
42
|
-
{
|
|
43
|
-
id: "tab1",
|
|
44
|
-
label: "Tab 1",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: "tab2",
|
|
48
|
-
label: "Tab 2",
|
|
49
|
-
disabled: true,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: "tab3",
|
|
53
|
-
label: "Tab 3",
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
export const linkedTabs = tabs.map((tab) => ({ ...tab, href: `/tab/${tab.id}` }));
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Header } from "./header";
|
|
3
|
-
import { withMemoryRouter } from "~/storybook";
|
|
4
|
-
import { breadcrumbs, tabs, actions, linkedTabs } from "./header.dummy";
|
|
5
|
-
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { TabProvider } from "~/providers";
|
|
8
|
-
import { Content } from "~/components/containers";
|
|
9
|
-
import { Box, Typography } from "@mui/material";
|
|
10
|
-
import { TabPanel } from "~/components/navigation/tab-panel";
|
|
11
|
-
import { Route, Routes, useLocation } from "react-router-dom";
|
|
12
|
-
import { Label } from "../label";
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
title: "Components/Data Display/Header",
|
|
16
|
-
component: Header,
|
|
17
|
-
decorators: [withMemoryRouter()],
|
|
18
|
-
parameters: {
|
|
19
|
-
layout: "fullscreen",
|
|
20
|
-
},
|
|
21
|
-
} satisfies Meta<typeof Header>;
|
|
22
|
-
type Story = StoryObj<typeof Header>;
|
|
23
|
-
|
|
24
|
-
export const Default: Story = {
|
|
25
|
-
args: {
|
|
26
|
-
title: "Lorem ipsum",
|
|
27
|
-
subtitle: "Dolor sit amet",
|
|
28
|
-
preset: "default",
|
|
29
|
-
breadcrumbs,
|
|
30
|
-
actions,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const OnlyTitle: Story = {
|
|
35
|
-
args: {
|
|
36
|
-
title: "Lorem ipsum",
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const CustomTitle: Story = {
|
|
41
|
-
args: {
|
|
42
|
-
...Default.args,
|
|
43
|
-
title: (
|
|
44
|
-
<Box display="flex" flexDirection="row" alignItems="center">
|
|
45
|
-
<Typography variant="h6">Lorem ipsum</Typography>
|
|
46
|
-
<Label variant="primary" text="4 items" sx={{ ml: 1 }} />
|
|
47
|
-
</Box>
|
|
48
|
-
),
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const TitleLoading: Story = {
|
|
53
|
-
args: {
|
|
54
|
-
...Default.args,
|
|
55
|
-
loadingTitle: true,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const CustomSubtitle: Story = {
|
|
60
|
-
args: {
|
|
61
|
-
...Default.args,
|
|
62
|
-
subtitle: (
|
|
63
|
-
<Box display="flex" flexDirection="row" alignItems="center">
|
|
64
|
-
<Typography variant="body2">Dolor sit amet</Typography>
|
|
65
|
-
<Label variant="error" text="since yesterday" sx={{ ml: 1 }} />
|
|
66
|
-
</Box>
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const SubtitleLoading: Story = {
|
|
72
|
-
args: {
|
|
73
|
-
...Default.args,
|
|
74
|
-
loadingSubtitle: true,
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const ColorInherit: Story = {
|
|
79
|
-
args: {
|
|
80
|
-
title: "Lorem ipsum",
|
|
81
|
-
subtitle: "Dolor sit amet",
|
|
82
|
-
preset: "inherit",
|
|
83
|
-
breadcrumbs,
|
|
84
|
-
tabs,
|
|
85
|
-
actions,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const ColorPrimary: Story = {
|
|
90
|
-
args: {
|
|
91
|
-
title: "Lorem ipsum",
|
|
92
|
-
subtitle: "Dolor sit amet",
|
|
93
|
-
preset: "primary",
|
|
94
|
-
breadcrumbs,
|
|
95
|
-
tabs,
|
|
96
|
-
actions,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const ColorSecondary: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
title: "Lorem ipsum",
|
|
103
|
-
subtitle: "Dolor sit amet",
|
|
104
|
-
preset: "secondary",
|
|
105
|
-
breadcrumbs,
|
|
106
|
-
tabs,
|
|
107
|
-
actions,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const ColorDefault: Story = {
|
|
112
|
-
args: {
|
|
113
|
-
title: "Lorem ipsum",
|
|
114
|
-
subtitle: "Dolor sit amet",
|
|
115
|
-
preset: "default",
|
|
116
|
-
breadcrumbs,
|
|
117
|
-
tabs,
|
|
118
|
-
actions,
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const ColorTransparent: Story = {
|
|
123
|
-
args: {
|
|
124
|
-
title: "Lorem ipsum",
|
|
125
|
-
subtitle: "Dolor sit amet",
|
|
126
|
-
preset: "transparent",
|
|
127
|
-
breadcrumbs,
|
|
128
|
-
tabs,
|
|
129
|
-
actions,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const WithSubheader: Story = {
|
|
134
|
-
args: {
|
|
135
|
-
title: "Lorem ipsum",
|
|
136
|
-
subtitle: "Dolor sit amet",
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const WithBreadcumbs: Story = {
|
|
141
|
-
args: {
|
|
142
|
-
title: "Lorem ipsum",
|
|
143
|
-
breadcrumbs,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export const WithActions: Story = {
|
|
148
|
-
args: {
|
|
149
|
-
title: "Lorem ipsum",
|
|
150
|
-
subtitle: "Dolor sit amet",
|
|
151
|
-
preset: "default",
|
|
152
|
-
tabsMode: "panel",
|
|
153
|
-
breadcrumbs,
|
|
154
|
-
actions,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const WithPanelTabs = () => (
|
|
159
|
-
<TabProvider>
|
|
160
|
-
<Header title="Lorem ipsum" subtitle="Dolor sit amet" tabsMode="panel" tabs={tabs} />
|
|
161
|
-
<Content>
|
|
162
|
-
<TabPanel index={0}>
|
|
163
|
-
<Typography>Panel Tab 1</Typography>
|
|
164
|
-
</TabPanel>
|
|
165
|
-
<TabPanel index={1}>
|
|
166
|
-
<Typography>Panel Tab 2</Typography>
|
|
167
|
-
</TabPanel>
|
|
168
|
-
<TabPanel index={2}>
|
|
169
|
-
<Typography>Panel Tab 3</Typography>
|
|
170
|
-
</TabPanel>
|
|
171
|
-
</Content>
|
|
172
|
-
</TabProvider>
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
export const WithLinkedTabs = () => {
|
|
176
|
-
const location = useLocation();
|
|
177
|
-
|
|
178
|
-
return (
|
|
179
|
-
<Box>
|
|
180
|
-
<Header
|
|
181
|
-
title="Lorem ipsum"
|
|
182
|
-
subtitle="Dolor sit amet"
|
|
183
|
-
tabsMode="navigation"
|
|
184
|
-
tabs={linkedTabs}
|
|
185
|
-
/>
|
|
186
|
-
<Content>
|
|
187
|
-
<>
|
|
188
|
-
<Typography>Location: {location.pathname}</Typography>
|
|
189
|
-
<Routes>
|
|
190
|
-
<Route path="/tab/tab1" element={<Typography>Panel: /tab/tab1</Typography>} />
|
|
191
|
-
<Route path="/tab/tab2" element={<Typography>Panel: /tab/tab2</Typography>} />
|
|
192
|
-
<Route path="/tab/tab3" element={<Typography>Panel: /tab/tab3</Typography>} />
|
|
193
|
-
<Route path="/" element={<Typography>Home</Typography>} />
|
|
194
|
-
</Routes>
|
|
195
|
-
</>
|
|
196
|
-
</Content>
|
|
197
|
-
</Box>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export const NavigationButton: Story = {
|
|
202
|
-
args: {
|
|
203
|
-
title: "Lorem ipsum",
|
|
204
|
-
subtitle: "Dolor sit amet",
|
|
205
|
-
preset: "default",
|
|
206
|
-
navigationButton: {
|
|
207
|
-
text: "Go back",
|
|
208
|
-
href: "/back",
|
|
209
|
-
icon: <ArrowBackIcon />,
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
};
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from "react";
|
|
2
|
-
import { render, screen } from "~/tests/testing-library";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { Header } from "./header";
|
|
5
|
-
import { vi } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
HeaderAction,
|
|
8
|
-
HeaderActionVariant,
|
|
9
|
-
HeaderBreadcrumb,
|
|
10
|
-
HeaderPreset,
|
|
11
|
-
HeaderTab,
|
|
12
|
-
} from "./header.types";
|
|
13
|
-
import { breadcrumbs, actions as actionsData, tabs, linkedTabs } from "./header.dummy";
|
|
14
|
-
import { TabProvider } from "../../../providers";
|
|
15
|
-
import { WithLinkedTabs, WithPanelTabs } from "./header.stories";
|
|
16
|
-
import { Typography } from "@mui/material";
|
|
17
|
-
import { Box } from "@mui/system";
|
|
18
|
-
import { Label } from "../label";
|
|
19
|
-
|
|
20
|
-
const actions = actionsData.map((a) => ({ ...a, onClick: a.onClick && vi.fn() }));
|
|
21
|
-
|
|
22
|
-
const renderInstance = ({
|
|
23
|
-
title = "Lorem ipsum",
|
|
24
|
-
loadingTitle,
|
|
25
|
-
subtitle,
|
|
26
|
-
loadingSubtitle,
|
|
27
|
-
preset = "default",
|
|
28
|
-
breadcrumbs,
|
|
29
|
-
actions,
|
|
30
|
-
actionsVariant,
|
|
31
|
-
tabs,
|
|
32
|
-
selectedTab,
|
|
33
|
-
navigationButton,
|
|
34
|
-
}: {
|
|
35
|
-
title?: string | ReactElement;
|
|
36
|
-
subtitle?: string | ReactElement;
|
|
37
|
-
loadingTitle?: boolean;
|
|
38
|
-
loadingSubtitle?: boolean;
|
|
39
|
-
preset?: HeaderPreset;
|
|
40
|
-
breadcrumbs?: HeaderBreadcrumb[];
|
|
41
|
-
actions?: HeaderAction[];
|
|
42
|
-
actionsVariant?: HeaderActionVariant;
|
|
43
|
-
tabs?: HeaderTab[];
|
|
44
|
-
selectedTab?: number;
|
|
45
|
-
navigationButton?: boolean;
|
|
46
|
-
}) => {
|
|
47
|
-
const instance = render(
|
|
48
|
-
<TabProvider initialValue={selectedTab}>
|
|
49
|
-
<Header
|
|
50
|
-
title={title}
|
|
51
|
-
loadingTitle={loadingTitle}
|
|
52
|
-
subtitle={subtitle}
|
|
53
|
-
loadingSubtitle={loadingSubtitle}
|
|
54
|
-
preset={preset}
|
|
55
|
-
breadcrumbs={breadcrumbs}
|
|
56
|
-
actions={actions}
|
|
57
|
-
actionsVariant={actionsVariant}
|
|
58
|
-
tabs={tabs}
|
|
59
|
-
navigationButton={navigationButton ? { text: "go back", href: "/back" } : undefined}
|
|
60
|
-
/>
|
|
61
|
-
</TabProvider>,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return { ...instance };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
describe("Header", () => {
|
|
68
|
-
describe("title", () => {
|
|
69
|
-
it("should render the title", () => {
|
|
70
|
-
renderInstance({ title: "Lorem ipsum" });
|
|
71
|
-
|
|
72
|
-
expect(screen.getByRole("heading", { level: 1, name: /lorem ipsum/i })).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should render the custom title", () => {
|
|
76
|
-
renderInstance({
|
|
77
|
-
title: (
|
|
78
|
-
<Box display="flex" flexDirection="row" alignItems="center">
|
|
79
|
-
<Typography variant="h6">custom title</Typography>
|
|
80
|
-
<Label variant="primary" text="4 items" sx={{ ml: 1 }} />
|
|
81
|
-
</Box>
|
|
82
|
-
),
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
expect(screen.getByRole("heading", { level: 6, name: /custom title/i })).toBeVisible();
|
|
86
|
-
expect(screen.getByText(/4 items/i)).toBeVisible();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should render a loading indicator if title is loading", () => {
|
|
90
|
-
renderInstance({ title: "Lorem ipsum", loadingTitle: true });
|
|
91
|
-
|
|
92
|
-
expect(
|
|
93
|
-
screen.queryByRole("heading", { level: 1, name: /lorem ipsum/i }),
|
|
94
|
-
).not.toBeInTheDocument();
|
|
95
|
-
expect(screen.queryByRole("progressbar", { name: /title loading/i })).toBeInTheDocument();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe("subtitle", () => {
|
|
100
|
-
it("should render when is set", () => {
|
|
101
|
-
renderInstance({ subtitle: "sit amet" });
|
|
102
|
-
|
|
103
|
-
expect(screen.queryByRole("heading", { level: 2, name: /sit amet/i })).toBeInTheDocument();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("shouldn't render if it is not set", () => {
|
|
107
|
-
renderInstance({ subtitle: undefined });
|
|
108
|
-
|
|
109
|
-
expect(screen.queryByRole("heading", { level: 2 })).not.toBeInTheDocument();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should render the custom title", () => {
|
|
113
|
-
renderInstance({
|
|
114
|
-
subtitle: (
|
|
115
|
-
<Box display="flex" flexDirection="row" alignItems="center">
|
|
116
|
-
<Typography variant="body2">Dolor sit amet</Typography>
|
|
117
|
-
<Label variant="error" text="since yesterday" sx={{ ml: 1 }} />
|
|
118
|
-
</Box>
|
|
119
|
-
),
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
expect(screen.getByText(/dolor sit amet/i)).toBeVisible();
|
|
123
|
-
expect(screen.getByText(/since yesterday/i)).toBeVisible();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("should render a loading indicator if title is loading", () => {
|
|
127
|
-
renderInstance({ subtitle: "sit amet", loadingSubtitle: true });
|
|
128
|
-
|
|
129
|
-
expect(screen.queryByRole("heading", { level: 2 })).not.toBeInTheDocument();
|
|
130
|
-
expect(screen.queryByRole("progressbar", { name: /subtitle loading/i })).toBeInTheDocument();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe("breadcrumbs", () => {
|
|
135
|
-
it("should render a list of links", () => {
|
|
136
|
-
renderInstance({ breadcrumbs });
|
|
137
|
-
|
|
138
|
-
expect(screen.getByRole("link", { name: /items/i })).toBeInTheDocument();
|
|
139
|
-
expect(screen.getByRole("link", { name: /item 1/i })).toBeInTheDocument();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("should navigate to a breadcrumb when is", async () => {
|
|
143
|
-
const { history } = renderInstance({ breadcrumbs });
|
|
144
|
-
|
|
145
|
-
await userEvent.click(screen.getByRole("link", { name: /items/i }));
|
|
146
|
-
|
|
147
|
-
expect(history.location.pathname).toBe("/items");
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe("actions", () => {
|
|
152
|
-
it("should render a list of buttons", () => {
|
|
153
|
-
renderInstance({ actions });
|
|
154
|
-
|
|
155
|
-
expect(screen.getByRole("button", { name: /add/i })).toBeInTheDocument();
|
|
156
|
-
expect(screen.getByRole("button", { name: /edit/i })).toBeInTheDocument();
|
|
157
|
-
expect(screen.getByRole("button", { name: /disabled/i })).toBeInTheDocument();
|
|
158
|
-
expect(screen.getByRole("button", { name: /delete/i })).toBeInTheDocument();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("clicks an action with an onClick defined it will be called", async () => {
|
|
162
|
-
renderInstance({ actions });
|
|
163
|
-
|
|
164
|
-
const button = actions[1];
|
|
165
|
-
|
|
166
|
-
await userEvent.click(screen.getByRole("button", { name: button.text }));
|
|
167
|
-
|
|
168
|
-
expect(button.onClick).toHaveBeenCalledTimes(1);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("shouldn't be possible to click a disabled action", async () => {
|
|
172
|
-
renderInstance({ actions });
|
|
173
|
-
|
|
174
|
-
expect(screen.getByRole("button", { name: /disabled/i })).toBeDisabled();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("should redirect to the expected url when click an action with an href", async () => {
|
|
178
|
-
const { history } = renderInstance({ actions });
|
|
179
|
-
|
|
180
|
-
await userEvent.click(screen.getByRole("button", { name: /add/i }));
|
|
181
|
-
|
|
182
|
-
expect(history.location.pathname).toBe("/items/add");
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe("tabs", () => {
|
|
187
|
-
it("should render a list of tabs", () => {
|
|
188
|
-
renderInstance({ tabs, selectedTab: 2 });
|
|
189
|
-
|
|
190
|
-
expect(screen.getByRole("tab", { name: /tab 1/i })).toBeInTheDocument();
|
|
191
|
-
expect(screen.getByRole("tab", { name: /tab 2/i })).toBeInTheDocument();
|
|
192
|
-
expect(screen.getByRole("tab", { name: /tab 3/i })).toBeInTheDocument();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("should mark as active the selectedTab", () => {
|
|
196
|
-
renderInstance({ tabs, selectedTab: 2 });
|
|
197
|
-
|
|
198
|
-
expect(screen.getByRole("tab", { name: /tab 1/i, selected: false })).toBeInTheDocument();
|
|
199
|
-
expect(screen.getByRole("tab", { name: /tab 2/i, selected: false })).toBeInTheDocument();
|
|
200
|
-
expect(screen.getByRole("tab", { name: /tab 3/i, selected: true })).toBeInTheDocument();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("shouldn't be possible to click a disabled tab", () => {
|
|
204
|
-
renderInstance({ tabs, selectedTab: 2 });
|
|
205
|
-
|
|
206
|
-
expect(screen.getByRole("tab", { name: /tab 2/i })).toBeDisabled();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe("tabMode = panel", () => {
|
|
210
|
-
const enabledTestCases = tabs.filter((tab) => !tab.disabled).map(({ label }) => [label]);
|
|
211
|
-
|
|
212
|
-
const renderPanelTabsInstance = () => {
|
|
213
|
-
render(<WithPanelTabs />);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
it("should change the selected tab when a tab is clicked", async () => {
|
|
217
|
-
renderPanelTabsInstance();
|
|
218
|
-
|
|
219
|
-
await userEvent.click(screen.getByRole("tab", { name: /tab 3/i }));
|
|
220
|
-
|
|
221
|
-
expect(screen.getByRole("tab", { name: /tab 1/i, selected: false })).toBeInTheDocument();
|
|
222
|
-
expect(screen.getByRole("tab", { name: /tab 2/i, selected: false })).toBeInTheDocument();
|
|
223
|
-
expect(screen.getByRole("tab", { name: /tab 3/i, selected: true })).toBeInTheDocument();
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it.each(enabledTestCases)(
|
|
227
|
-
"if i cliick the tab %s the content of that panel should be rendered",
|
|
228
|
-
async (label: string) => {
|
|
229
|
-
renderPanelTabsInstance();
|
|
230
|
-
|
|
231
|
-
await userEvent.click(screen.getByRole("tab", { name: label }));
|
|
232
|
-
|
|
233
|
-
expect(screen.getByText(`Panel ${label}`)).toBeVisible();
|
|
234
|
-
},
|
|
235
|
-
);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
describe("tabMode = navigation", () => {
|
|
239
|
-
const enabledTestCases = linkedTabs
|
|
240
|
-
.filter((tab) => !tab.disabled)
|
|
241
|
-
.map(({ label, href }) => [href, label]);
|
|
242
|
-
const renderLinkedTabsInstance = () => {
|
|
243
|
-
render(<WithLinkedTabs />, { router: "memory" });
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
it("should render a list of tabs", () => {
|
|
247
|
-
renderLinkedTabsInstance();
|
|
248
|
-
|
|
249
|
-
tabs.forEach(({ label }) => {
|
|
250
|
-
expect(screen.getByRole("tab", { name: label })).toBeVisible();
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it.each(enabledTestCases)(
|
|
255
|
-
"should render %s if the user click %s label",
|
|
256
|
-
async (href: string, label: string) => {
|
|
257
|
-
renderLinkedTabsInstance();
|
|
258
|
-
|
|
259
|
-
await userEvent.click(screen.getByRole("tab", { name: label }));
|
|
260
|
-
|
|
261
|
-
expect(screen.getByText(`Panel: ${href}`)).toBeVisible();
|
|
262
|
-
},
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
it.each(enabledTestCases)(
|
|
266
|
-
"should navigate to %s if the user click %s label",
|
|
267
|
-
async (href: string, label: string) => {
|
|
268
|
-
renderLinkedTabsInstance();
|
|
269
|
-
|
|
270
|
-
await userEvent.click(screen.getByRole("tab", { name: label }));
|
|
271
|
-
|
|
272
|
-
expect(screen.getByText(`Location: ${href}`)).toBeVisible();
|
|
273
|
-
},
|
|
274
|
-
);
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
describe("navigationButton", () => {
|
|
279
|
-
it("should render a navigation button if is set", () => {
|
|
280
|
-
renderInstance({ navigationButton: true });
|
|
281
|
-
|
|
282
|
-
expect(screen.getByRole("link", { name: /go back/i })).toBeVisible();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("shouldn't render a navigation button if is not set", () => {
|
|
286
|
-
renderInstance({ navigationButton: false });
|
|
287
|
-
|
|
288
|
-
expect(screen.queryByRole("link", { name: /go back/i })).not.toBeInTheDocument();
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it("should navigate to the navigation path if is clicked", async () => {
|
|
292
|
-
const { history } = renderInstance({ navigationButton: true });
|
|
293
|
-
|
|
294
|
-
await userEvent.click(screen.getByRole("link", { name: /go back/i }));
|
|
295
|
-
|
|
296
|
-
expect(history.location.pathname).toBe("/back");
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
});
|