@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,144 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { QueryContainer, QueryContainerError, QueryContainerSuccess } from "./query-container";
|
|
3
|
-
import { render, screen } from "~/tests/testing-library";
|
|
4
|
-
import { Typography } from "@mui/material";
|
|
5
|
-
import { expectProgressIndicator } from "~/tests/assertions";
|
|
6
|
-
|
|
7
|
-
describe("QueryContainer", () => {
|
|
8
|
-
const renderComponent = ({
|
|
9
|
-
fetching = false,
|
|
10
|
-
loading = false,
|
|
11
|
-
error = undefined,
|
|
12
|
-
success = undefined,
|
|
13
|
-
}: {
|
|
14
|
-
fetching?: boolean | boolean[];
|
|
15
|
-
loading?: boolean | boolean[];
|
|
16
|
-
error?: QueryContainerError;
|
|
17
|
-
success?: QueryContainerSuccess;
|
|
18
|
-
} = {}) => {
|
|
19
|
-
return render(
|
|
20
|
-
<QueryContainer fetching={fetching} loading={loading} error={error} success={success}>
|
|
21
|
-
<Typography>children content</Typography>
|
|
22
|
-
</QueryContainer>,
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
describe("fetching", () => {
|
|
27
|
-
it("should render a loading indicator if fetching=true", () => {
|
|
28
|
-
renderComponent({ fetching: true });
|
|
29
|
-
|
|
30
|
-
expectProgressIndicator();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should render a loading indicator if fetching is an array with a true value", () => {
|
|
34
|
-
renderComponent({ fetching: [false, false, true, false, false] });
|
|
35
|
-
|
|
36
|
-
expectProgressIndicator();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should render the children if fetching=true", () => {
|
|
40
|
-
renderComponent({ fetching: true });
|
|
41
|
-
|
|
42
|
-
expect(screen.getByText(/children content/i)).toBeVisible();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should render the children if fetching is an array with a true value", () => {
|
|
46
|
-
renderComponent({ fetching: [false, false, true, false, false] });
|
|
47
|
-
|
|
48
|
-
expect(screen.getByText(/children content/i)).toBeVisible();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("loading", () => {
|
|
53
|
-
it("should render a loading indicator if loading=true", () => {
|
|
54
|
-
renderComponent({ loading: true });
|
|
55
|
-
|
|
56
|
-
expectProgressIndicator();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should render a loading indicator if loading is an array with a true value", () => {
|
|
60
|
-
renderComponent({ loading: [false, false, true, false, false] });
|
|
61
|
-
|
|
62
|
-
expectProgressIndicator();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("shouldn't render the children", () => {
|
|
66
|
-
renderComponent({ loading: true });
|
|
67
|
-
|
|
68
|
-
expect(screen.queryByText(/children content/i)).not.toBeInTheDocument();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("shouldn't render the children if fetching is an array with a true value", () => {
|
|
72
|
-
renderComponent({ loading: [false, false, true, false, false] });
|
|
73
|
-
|
|
74
|
-
expect(screen.queryByText(/children content/i)).not.toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("error", () => {
|
|
79
|
-
it("should render an error alert", () => {
|
|
80
|
-
renderComponent({ error: { message: "Internal error" } });
|
|
81
|
-
|
|
82
|
-
expect(screen.getByRole("alert")).toHaveAttribute("aria-describedby", "error");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should render the error message if error is defined", () => {
|
|
86
|
-
renderComponent({ error: { message: "Internal error" } });
|
|
87
|
-
|
|
88
|
-
expect(screen.getByText(/internal error/i)).toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("should render the error title if error.name is defined", () => {
|
|
92
|
-
renderComponent({ error: { name: "Internal error", message: "There was an error" } });
|
|
93
|
-
|
|
94
|
-
expect(screen.getByRole("heading", { name: /internal error/i })).toBeInTheDocument();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("shouldn't render the error title if error is defined but the error.name not", () => {
|
|
98
|
-
renderComponent({ error: { message: "Internal error" } });
|
|
99
|
-
|
|
100
|
-
expect(screen.queryByRole("heading")).not.toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("success", () => {
|
|
105
|
-
it("should render a success alert", () => {
|
|
106
|
-
renderComponent({ success: { message: "Item added" } });
|
|
107
|
-
|
|
108
|
-
expect(screen.getByRole("alert")).toHaveAttribute("aria-describedby", "success");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("should render the success message if success is defined", () => {
|
|
112
|
-
renderComponent({ success: { message: "Item added" } });
|
|
113
|
-
|
|
114
|
-
expect(screen.getByText(/item added/i)).toBeInTheDocument();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("should render the success title if success.name is defined", () => {
|
|
118
|
-
renderComponent({
|
|
119
|
-
success: { name: "Item added", message: "The item has been added successfully" },
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
expect(screen.getByRole("heading", { name: /item added/i })).toBeInTheDocument();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("shouldn't render the error title if success is defined but the success.name not", () => {
|
|
126
|
-
renderComponent({ success: { message: "Item added" } });
|
|
127
|
-
|
|
128
|
-
expect(screen.queryByRole("heading")).not.toBeInTheDocument();
|
|
129
|
-
});
|
|
130
|
-
//TODO validate the severity of the alert
|
|
131
|
-
|
|
132
|
-
it("should render the content", () => {
|
|
133
|
-
renderComponent({ success: { message: "Item added" } });
|
|
134
|
-
|
|
135
|
-
expect(screen.getByText(/children content/i)).toBeInTheDocument();
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("should render the children if isFetching is false and there is no defined error", () => {
|
|
140
|
-
renderComponent({ fetching: false, error: undefined });
|
|
141
|
-
|
|
142
|
-
expect(screen.getByText(/children content/i)).toBeInTheDocument();
|
|
143
|
-
});
|
|
144
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Alert, AlertTitle, Box, LinearProgress } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { PropsWithChildren } from "react";
|
|
4
|
-
import { LoadingArea } from "../loading-area";
|
|
5
|
-
|
|
6
|
-
export interface QueryContainerError {
|
|
7
|
-
/**
|
|
8
|
-
* The error title
|
|
9
|
-
*/
|
|
10
|
-
name?: string;
|
|
11
|
-
/**
|
|
12
|
-
* The description of the error
|
|
13
|
-
*/
|
|
14
|
-
message: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface QueryContainerSuccess {
|
|
18
|
-
/**
|
|
19
|
-
* The success title
|
|
20
|
-
*/
|
|
21
|
-
name?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The success text
|
|
24
|
-
*/
|
|
25
|
-
message: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type QueryContainerProps = PropsWithChildren<{
|
|
29
|
-
/**
|
|
30
|
-
* There is a query in progress and we have available data
|
|
31
|
-
*/
|
|
32
|
-
fetching?: boolean | boolean[];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* There is a query in progress and we don't have available data
|
|
36
|
-
*/
|
|
37
|
-
loading?: boolean | boolean[];
|
|
38
|
-
/**
|
|
39
|
-
* The query has returned an error
|
|
40
|
-
*/
|
|
41
|
-
error?: QueryContainerError;
|
|
42
|
-
/**
|
|
43
|
-
* The query has finished successfully
|
|
44
|
-
*/
|
|
45
|
-
success?: QueryContainerSuccess;
|
|
46
|
-
}>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Component to show different indicators based on the usual api query statuses
|
|
50
|
-
*/
|
|
51
|
-
export function QueryContainer({
|
|
52
|
-
fetching: fetchingProp = false,
|
|
53
|
-
loading: loadingProp = false,
|
|
54
|
-
error,
|
|
55
|
-
success,
|
|
56
|
-
children,
|
|
57
|
-
}: QueryContainerProps) {
|
|
58
|
-
const fetching = Array.isArray(fetchingProp) ? fetchingProp.some((f) => f) : fetchingProp;
|
|
59
|
-
const loading = Array.isArray(loadingProp) ? loadingProp.some((f) => f) : loadingProp;
|
|
60
|
-
|
|
61
|
-
if (loading) {
|
|
62
|
-
return <LoadingArea />;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (error) {
|
|
66
|
-
return (
|
|
67
|
-
<Alert severity="error" role="alert" aria-describedby="error">
|
|
68
|
-
{error.name && <AlertTitle role="heading">{error.name}</AlertTitle>}
|
|
69
|
-
{error.message}
|
|
70
|
-
</Alert>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<Box>
|
|
76
|
-
{success && (
|
|
77
|
-
<Alert severity="success" role="alert" aria-describedby="success" sx={{ mb: 2 }}>
|
|
78
|
-
{success.name && <AlertTitle role="heading">{success.name}</AlertTitle>}
|
|
79
|
-
{success.message}
|
|
80
|
-
</Alert>
|
|
81
|
-
)}
|
|
82
|
-
{fetching && <LinearProgress sx={{ width: 1, mb: 1 }} />}
|
|
83
|
-
{children}
|
|
84
|
-
</Box>
|
|
85
|
-
);
|
|
86
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./value-displays";
|
|
2
|
-
export * from "./feedback";
|
|
3
|
-
export * from "./data-display";
|
|
4
|
-
export * from "./containers";
|
|
5
|
-
export * from "./drawers";
|
|
6
|
-
export * from "./inputs";
|
|
7
|
-
export * from "./navigation";
|
|
8
|
-
export * from "./tables";
|
|
9
|
-
export * from "./placeholders";
|
|
10
|
-
export * from "./alerts";
|
|
11
|
-
export * from "./dialogs";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import { ActionHeader } from "./action-header";
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
|
-
describe("ActionHeader", () => {
|
|
6
|
-
it("should render the title", () => {
|
|
7
|
-
render(<ActionHeader title="Lorem ipsum" />);
|
|
8
|
-
|
|
9
|
-
expect(screen.getByRole("heading", { name: /lorem ipsum/i, level: 4 }));
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Typography, useTheme } from "@mui/material";
|
|
2
|
-
import { Variant } from "@mui/material/styles/createTypography";
|
|
3
|
-
import React from "react";
|
|
4
|
-
|
|
5
|
-
type ActionVariant = "primary" | "error" | "warning" | "success";
|
|
6
|
-
|
|
7
|
-
export interface ActionHeaderProps {
|
|
8
|
-
variant?: ActionVariant;
|
|
9
|
-
title: string;
|
|
10
|
-
titleVariant?: Extract<Variant, "h4" | "h5" | "h6">;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const ActionHeader = ({
|
|
14
|
-
title,
|
|
15
|
-
titleVariant = "h4",
|
|
16
|
-
variant = "primary",
|
|
17
|
-
}: ActionHeaderProps) => {
|
|
18
|
-
const { palette } = useTheme();
|
|
19
|
-
|
|
20
|
-
const titleColor: Record<ActionVariant, string | undefined> = {
|
|
21
|
-
primary: undefined,
|
|
22
|
-
error: "error",
|
|
23
|
-
warning: palette.warning.main,
|
|
24
|
-
success: palette.success.main,
|
|
25
|
-
};
|
|
26
|
-
return (
|
|
27
|
-
<Typography
|
|
28
|
-
color={titleColor[variant]}
|
|
29
|
-
variant={titleVariant}
|
|
30
|
-
pb={1}
|
|
31
|
-
borderBottom={1}
|
|
32
|
-
borderColor="grey.300"
|
|
33
|
-
>
|
|
34
|
-
{title}
|
|
35
|
-
</Typography>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Action } from "./action";
|
|
3
|
-
import { loremIpsum } from "lorem-ipsum";
|
|
4
|
-
import { withContainer } from "../../../storybook";
|
|
5
|
-
import { Box, Typography } from "@mui/material";
|
|
6
|
-
import React from "react";
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: "Components/Inputs/Action",
|
|
10
|
-
component: Action,
|
|
11
|
-
decorators: [withContainer({ padding: 2 })],
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: "fullscreen",
|
|
14
|
-
},
|
|
15
|
-
} satisfies Meta<typeof Action>;
|
|
16
|
-
type Story = StoryObj<typeof Action>;
|
|
17
|
-
|
|
18
|
-
export const Default: Story = {
|
|
19
|
-
args: {
|
|
20
|
-
title: "Change username",
|
|
21
|
-
description: loremIpsum({ count: 5, units: "sentence" }),
|
|
22
|
-
buttonText: "Change username",
|
|
23
|
-
helperText: loremIpsum({ count: 1, units: "sentence" }),
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const CustomDescription: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
title: "Change username",
|
|
30
|
-
description: (
|
|
31
|
-
<Box>
|
|
32
|
-
<Typography>
|
|
33
|
-
This is a test description<Typography fontWeight="bold">with bold text</Typography>
|
|
34
|
-
</Typography>
|
|
35
|
-
</Box>
|
|
36
|
-
),
|
|
37
|
-
buttonText: "Change username",
|
|
38
|
-
helperText: loremIpsum({ count: 1, units: "sentence" }),
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Error: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
...Default.args,
|
|
45
|
-
variant: "error",
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Warning: Story = {
|
|
50
|
-
args: {
|
|
51
|
-
...Default.args,
|
|
52
|
-
variant: "warning",
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Sucess: Story = {
|
|
57
|
-
args: {
|
|
58
|
-
...Default.args,
|
|
59
|
-
variant: "success",
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const Confirmable: Story = {
|
|
64
|
-
args: {
|
|
65
|
-
...Default.args,
|
|
66
|
-
confirmable: true,
|
|
67
|
-
confirmTitle: "Username change",
|
|
68
|
-
confirmDescription: "Do you want to change the username?",
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const ConfirmableWithPassphrase: Story = {
|
|
73
|
-
args: {
|
|
74
|
-
...Confirmable.args,
|
|
75
|
-
passphrase: "yes",
|
|
76
|
-
},
|
|
77
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from "~/tests/testing-library";
|
|
2
|
-
import { Action } from "./action";
|
|
3
|
-
import { vi } from "vitest";
|
|
4
|
-
import React from "react";
|
|
5
|
-
|
|
6
|
-
describe("Action", () => {
|
|
7
|
-
const renderComponent = ({
|
|
8
|
-
description,
|
|
9
|
-
helperText,
|
|
10
|
-
confirmable = false,
|
|
11
|
-
passphrase,
|
|
12
|
-
}: {
|
|
13
|
-
confirmable?: boolean;
|
|
14
|
-
passphrase?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
helperText?: string;
|
|
17
|
-
} = {}) => {
|
|
18
|
-
const onAction = vi.fn();
|
|
19
|
-
render(
|
|
20
|
-
<Action
|
|
21
|
-
title="Change Username"
|
|
22
|
-
description={description}
|
|
23
|
-
helperText={helperText}
|
|
24
|
-
onAction={onAction}
|
|
25
|
-
variant={"primary"}
|
|
26
|
-
buttonText="Change"
|
|
27
|
-
confirmable={confirmable}
|
|
28
|
-
confirmTitle="Confirmation title"
|
|
29
|
-
confirmDescription="Confirmation description"
|
|
30
|
-
passphrase={passphrase}
|
|
31
|
-
/>,
|
|
32
|
-
);
|
|
33
|
-
return { onAction };
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
it("should render the title", () => {
|
|
37
|
-
renderComponent();
|
|
38
|
-
|
|
39
|
-
expect(screen.getByRole("heading", { name: "Change Username" })).toBeVisible();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should render the description if is defined", () => {
|
|
43
|
-
renderComponent({ description: "This will change the username" });
|
|
44
|
-
|
|
45
|
-
expect(screen.getByText("This will change the username")).toBeVisible();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("should render the helper text if is defined", () => {
|
|
49
|
-
renderComponent({ helperText: "I'm helping you" });
|
|
50
|
-
|
|
51
|
-
expect(screen.getByText("I'm helping you")).toBeVisible();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should call onAction if the button is clicked and confirmable=false", () => {
|
|
55
|
-
const { onAction } = renderComponent({ confirmable: false });
|
|
56
|
-
|
|
57
|
-
fireEvent.click(screen.getByRole("button", { name: "Change" }));
|
|
58
|
-
|
|
59
|
-
expect(onAction).toHaveBeenCalledTimes(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should open a dialog if the button is clicked and confirmable=true", () => {
|
|
63
|
-
const { onAction } = renderComponent({ confirmable: true });
|
|
64
|
-
|
|
65
|
-
fireEvent.click(screen.getByRole("button", { name: "Change" }));
|
|
66
|
-
|
|
67
|
-
expect(onAction).not.toHaveBeenCalled();
|
|
68
|
-
|
|
69
|
-
expect(screen.getByText("Confirmation title")).toBeVisible();
|
|
70
|
-
expect(screen.getByText("Confirmation description")).toBeVisible();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should call onAction if the dialog is confirmed", () => {
|
|
74
|
-
const { onAction } = renderComponent({ confirmable: true });
|
|
75
|
-
|
|
76
|
-
fireEvent.click(screen.getByRole("button", { name: "Change" }));
|
|
77
|
-
fireEvent.click(screen.getByRole("button", { name: "Confirm" }));
|
|
78
|
-
|
|
79
|
-
expect(onAction).toHaveBeenCalledTimes(1);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should call onAction if the dialog is confirmed with a passphrase", () => {
|
|
83
|
-
const { onAction } = renderComponent({ confirmable: true, passphrase: "yes" });
|
|
84
|
-
|
|
85
|
-
fireEvent.click(screen.getByRole("button", { name: "Change" }));
|
|
86
|
-
|
|
87
|
-
const confirmButton = screen.getByRole("button", { name: "Confirm" });
|
|
88
|
-
expect(confirmButton).toBeDisabled();
|
|
89
|
-
|
|
90
|
-
fireEvent.type(screen.getByRole("textbox"), "yes");
|
|
91
|
-
expect(confirmButton).toBeEnabled();
|
|
92
|
-
|
|
93
|
-
fireEvent.click(confirmButton);
|
|
94
|
-
|
|
95
|
-
expect(onAction).toHaveBeenCalledTimes(1);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Grid, Button, Typography, DialogContentText } from "@mui/material";
|
|
2
|
-
import { Variant } from "@mui/material/styles/createTypography";
|
|
3
|
-
import React, { ReactElement } from "react";
|
|
4
|
-
import { ConfirmDialog, useDialog } from "~/components/dialogs";
|
|
5
|
-
import { ActionHeader } from "./action-header";
|
|
6
|
-
|
|
7
|
-
export type ActionVariant = "primary" | "error" | "warning" | "success";
|
|
8
|
-
|
|
9
|
-
export interface ActionProps {
|
|
10
|
-
variant: ActionVariant;
|
|
11
|
-
title: string;
|
|
12
|
-
titleVariant?: Extract<Variant, "h4" | "h5" | "h6">;
|
|
13
|
-
description?: string | ReactElement;
|
|
14
|
-
descriptionVariant?: Variant;
|
|
15
|
-
helperText?: string;
|
|
16
|
-
helperTextVariant?: Variant;
|
|
17
|
-
buttonText: string;
|
|
18
|
-
confirmable?: boolean;
|
|
19
|
-
confirmTitle?: string;
|
|
20
|
-
confirmDescription?: string;
|
|
21
|
-
passphrase?: string;
|
|
22
|
-
onAction: () => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const Action = ({
|
|
26
|
-
variant = "primary",
|
|
27
|
-
title,
|
|
28
|
-
titleVariant = "h4",
|
|
29
|
-
description,
|
|
30
|
-
descriptionVariant = "body2",
|
|
31
|
-
buttonText,
|
|
32
|
-
helperText,
|
|
33
|
-
helperTextVariant = "caption",
|
|
34
|
-
confirmable,
|
|
35
|
-
passphrase,
|
|
36
|
-
confirmTitle = "",
|
|
37
|
-
confirmDescription = "",
|
|
38
|
-
onAction,
|
|
39
|
-
}: ActionProps) => {
|
|
40
|
-
const { isOpen, open, close } = useDialog();
|
|
41
|
-
|
|
42
|
-
const handleClickActionButton = () => {
|
|
43
|
-
if (confirmable) {
|
|
44
|
-
open();
|
|
45
|
-
} else {
|
|
46
|
-
onAction();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleConfirmDialog = () => {
|
|
51
|
-
onAction();
|
|
52
|
-
close;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<>
|
|
57
|
-
<Grid container spacing={1}>
|
|
58
|
-
<Grid item xs={12} mb={2}>
|
|
59
|
-
<ActionHeader title={title} titleVariant={titleVariant} />
|
|
60
|
-
</Grid>
|
|
61
|
-
{description && (
|
|
62
|
-
<Grid item xs={12}>
|
|
63
|
-
<Typography variant={descriptionVariant}>{description}</Typography>
|
|
64
|
-
</Grid>
|
|
65
|
-
)}
|
|
66
|
-
<Grid item xs={12} mt={1}>
|
|
67
|
-
<Button color={variant} variant="contained" onClick={handleClickActionButton}>
|
|
68
|
-
{buttonText}
|
|
69
|
-
</Button>
|
|
70
|
-
</Grid>
|
|
71
|
-
{helperText && (
|
|
72
|
-
<Grid item xs={12}>
|
|
73
|
-
<Typography variant={helperTextVariant}>{helperText}</Typography>
|
|
74
|
-
</Grid>
|
|
75
|
-
)}
|
|
76
|
-
</Grid>
|
|
77
|
-
<ConfirmDialog
|
|
78
|
-
open={isOpen}
|
|
79
|
-
title={confirmTitle}
|
|
80
|
-
passphrase={passphrase}
|
|
81
|
-
onCancel={close}
|
|
82
|
-
onConfirm={handleConfirmDialog}
|
|
83
|
-
>
|
|
84
|
-
<DialogContentText>{confirmDescription}</DialogContentText>
|
|
85
|
-
</ConfirmDialog>
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { withContainer } from "../../../storybook";
|
|
3
|
-
import { Autocomplete } from "./autocomplete";
|
|
4
|
-
import { faker } from "@faker-js/faker";
|
|
5
|
-
import { Box, useTheme } from "@mui/material";
|
|
6
|
-
import React from "react";
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: "Components/Inputs/Autocomplete",
|
|
10
|
-
component: Autocomplete,
|
|
11
|
-
decorators: [withContainer({ width: 300 })],
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: "centered",
|
|
14
|
-
},
|
|
15
|
-
} satisfies Meta<typeof Autocomplete>;
|
|
16
|
-
type Story = StoryObj<typeof Autocomplete>;
|
|
17
|
-
|
|
18
|
-
const options: string[] = [...faker.definitions.vehicle.model];
|
|
19
|
-
|
|
20
|
-
export const Default: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
label: "Car model",
|
|
23
|
-
options,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const HelperText: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
...Default.args,
|
|
30
|
-
helperText: "This is a helper text",
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const Loading: Story = {
|
|
35
|
-
args: {
|
|
36
|
-
...Default.args,
|
|
37
|
-
loading: true,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const LoadingWithValue: Story = {
|
|
42
|
-
args: {
|
|
43
|
-
...Default.args,
|
|
44
|
-
loading: true,
|
|
45
|
-
value: options[0],
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Fetching: Story = {
|
|
50
|
-
args: {
|
|
51
|
-
...Default.args,
|
|
52
|
-
fetching: true,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const LoadingAndFetching: Story = {
|
|
57
|
-
args: {
|
|
58
|
-
...Default.args,
|
|
59
|
-
loading: true,
|
|
60
|
-
fetching: true,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const SizeSmall: Story = {
|
|
65
|
-
args: {
|
|
66
|
-
...Default.args,
|
|
67
|
-
size: "small",
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const SizeSmallLoading: Story = {
|
|
72
|
-
args: {
|
|
73
|
-
...Default.args,
|
|
74
|
-
size: "small",
|
|
75
|
-
value: options[0],
|
|
76
|
-
loading: true,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const SizeSmallFetching: Story = {
|
|
81
|
-
args: {
|
|
82
|
-
...Default.args,
|
|
83
|
-
size: "small",
|
|
84
|
-
fetching: true,
|
|
85
|
-
value: options[0],
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
type WithBackgroundProps = {
|
|
90
|
-
bgcolor: "primary" | "secondary";
|
|
91
|
-
loading: boolean;
|
|
92
|
-
fetching: boolean;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const WithBackground = {
|
|
96
|
-
render: ({ bgcolor: bgcolorProp, loading, fetching }: WithBackgroundProps) => {
|
|
97
|
-
const { palette } = useTheme();
|
|
98
|
-
const BackgroundColors: Record<"primary" | "secondary", string> = {
|
|
99
|
-
primary: palette.primary.main,
|
|
100
|
-
secondary: palette.secondary.main,
|
|
101
|
-
};
|
|
102
|
-
const bgcolor = BackgroundColors[bgcolorProp];
|
|
103
|
-
const selectColor = palette.getContrastText(bgcolor);
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<Box bgcolor={bgcolor} padding={3}>
|
|
107
|
-
<Autocomplete
|
|
108
|
-
label="Car model"
|
|
109
|
-
options={options}
|
|
110
|
-
color={selectColor}
|
|
111
|
-
loading={loading}
|
|
112
|
-
fetching={fetching}
|
|
113
|
-
/>
|
|
114
|
-
</Box>
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
args: {
|
|
119
|
-
bgcolor: "secondary",
|
|
120
|
-
loading: true,
|
|
121
|
-
fetching: true,
|
|
122
|
-
},
|
|
123
|
-
};
|