@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,108 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, useId } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Box,
|
|
4
|
-
CircularProgress,
|
|
5
|
-
FormControl,
|
|
6
|
-
InputLabel,
|
|
7
|
-
LinearProgress,
|
|
8
|
-
Select as MuiSelect,
|
|
9
|
-
styled,
|
|
10
|
-
} from "@mui/material";
|
|
11
|
-
import { CenterContainer } from "../../containers/center-container";
|
|
12
|
-
import { SelectInputProps } from "@mui/material/Select/SelectInput";
|
|
13
|
-
|
|
14
|
-
export type SelectSize = "small" | "medium";
|
|
15
|
-
|
|
16
|
-
export interface SelectProps<T> {
|
|
17
|
-
label: string;
|
|
18
|
-
value: T;
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
fetching?: boolean;
|
|
21
|
-
size?: SelectSize;
|
|
22
|
-
color?: string;
|
|
23
|
-
fullWidth?: boolean;
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
onChange?: SelectInputProps<T>["onChange"];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const ProgressSize: Record<SelectSize, number> = {
|
|
29
|
-
small: 15,
|
|
30
|
-
medium: 20,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const Select = <T extends ReactNode>({
|
|
34
|
-
label,
|
|
35
|
-
value,
|
|
36
|
-
loading = false,
|
|
37
|
-
fetching = false,
|
|
38
|
-
size = "medium",
|
|
39
|
-
fullWidth = false,
|
|
40
|
-
color,
|
|
41
|
-
children,
|
|
42
|
-
onChange,
|
|
43
|
-
}: SelectProps<T>) => {
|
|
44
|
-
const id = useId();
|
|
45
|
-
|
|
46
|
-
const renderValue = (value: T): ReactNode => {
|
|
47
|
-
if (fetching) {
|
|
48
|
-
return (
|
|
49
|
-
<CenterContainer centerVertical centerHorizontal>
|
|
50
|
-
<CircularProgress color="inherit" size={ProgressSize[size]} />
|
|
51
|
-
</CenterContainer>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (loading) {
|
|
56
|
-
return (
|
|
57
|
-
<Box display="flex" flexDirection="column">
|
|
58
|
-
{value}
|
|
59
|
-
<LinearProgress
|
|
60
|
-
color="inherit"
|
|
61
|
-
sx={{ position: "absolute", left: 0, right: 0, bottom: 0 }}
|
|
62
|
-
/>
|
|
63
|
-
</Box>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return value;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const StyledFormControl = styled(FormControl)(() => {
|
|
71
|
-
if (!color) {
|
|
72
|
-
return {};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
label: {
|
|
77
|
-
color,
|
|
78
|
-
},
|
|
79
|
-
".MuiOutlinedInput-notchedOutline": {
|
|
80
|
-
borderColor: `${color} !important`,
|
|
81
|
-
},
|
|
82
|
-
".MuiInputBase-root": {
|
|
83
|
-
color,
|
|
84
|
-
},
|
|
85
|
-
".MuiSelect-icon": {
|
|
86
|
-
fill: color,
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<StyledFormControl fullWidth={fullWidth}>
|
|
93
|
-
<InputLabel id={id}>{label}</InputLabel>
|
|
94
|
-
<MuiSelect
|
|
95
|
-
labelId={id}
|
|
96
|
-
id={id}
|
|
97
|
-
value={value}
|
|
98
|
-
label={label}
|
|
99
|
-
onChange={onChange}
|
|
100
|
-
disabled={fetching}
|
|
101
|
-
size={size}
|
|
102
|
-
renderValue={renderValue}
|
|
103
|
-
>
|
|
104
|
-
{children}
|
|
105
|
-
</MuiSelect>
|
|
106
|
-
</StyledFormControl>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./sign-in";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { SignIn } from "./sign-in";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: "Components/Inputs/Sign In",
|
|
6
|
-
component: SignIn,
|
|
7
|
-
parameters: {
|
|
8
|
-
layout: "centered",
|
|
9
|
-
},
|
|
10
|
-
} satisfies Meta<typeof SignIn>;
|
|
11
|
-
type Story = StoryObj<typeof SignIn>;
|
|
12
|
-
|
|
13
|
-
export const Default: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
title: "Sign in into Garmin Workouts",
|
|
16
|
-
subtitle: "Enter your details below",
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const Error: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
title: "Sign in into Garmin Workouts",
|
|
23
|
-
subtitle: "Enter your details below",
|
|
24
|
-
error: {
|
|
25
|
-
name: "InvalidCredentials",
|
|
26
|
-
message: "Invalid user credentials",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Loading: Story = {
|
|
32
|
-
args: {
|
|
33
|
-
title: "Sign in into Garmin Workouts",
|
|
34
|
-
subtitle: "Enter your details below",
|
|
35
|
-
loading: true,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { SignIn } from "./sign-in";
|
|
3
|
-
import { render, screen } from "~/tests/testing-library";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
import { expectProgressIndicator } from "~/tests/assertions";
|
|
6
|
-
import { vi } from "vitest";
|
|
7
|
-
|
|
8
|
-
async function submitSignIn(email: string | null, password: string | null) {
|
|
9
|
-
email && (await userEvent.type(screen.getByRole("input", { name: /email/i }), email));
|
|
10
|
-
password && (await userEvent.type(screen.getByRole("input", { name: /password/i }), password));
|
|
11
|
-
await userEvent.click(screen.getByRole("button", { name: /sign in/i }));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe("SignIn", () => {
|
|
15
|
-
it("the title is displayed", () => {
|
|
16
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={() => null} />);
|
|
17
|
-
expect(screen.getByText("Lorem ipsum")).toBeInTheDocument();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("the subtitle is displayed", () => {
|
|
21
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={() => null} />);
|
|
22
|
-
expect(screen.getByText("Sit amet")).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("if I enter an email and a password and I submit onSubmitSignIn is called", async () => {
|
|
26
|
-
const onSubmitSignIn = vi.fn();
|
|
27
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={onSubmitSignIn} />);
|
|
28
|
-
|
|
29
|
-
await submitSignIn("test@example.com", "password1");
|
|
30
|
-
|
|
31
|
-
expect(onSubmitSignIn).toHaveBeenCalledTimes(1);
|
|
32
|
-
expect(onSubmitSignIn).toHaveBeenCalledWith("test@example.com", "password1");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("if I don't enter an email and I submit an error is shown and onSubmitSignIn is not called", async () => {
|
|
36
|
-
const onSubmitSignIn = vi.fn();
|
|
37
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={onSubmitSignIn} />);
|
|
38
|
-
|
|
39
|
-
await submitSignIn(null, "password1");
|
|
40
|
-
|
|
41
|
-
expect(screen.getByText(/please fill out this field/i)).toBeInTheDocument();
|
|
42
|
-
expect(onSubmitSignIn).not.toHaveBeenCalled();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("if I don't enter a valid email and I submit onSubmitSignIn is not called", async () => {
|
|
46
|
-
const onSubmitSignIn = vi.fn();
|
|
47
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={onSubmitSignIn} />);
|
|
48
|
-
|
|
49
|
-
await submitSignIn("invalid.com", "password1");
|
|
50
|
-
|
|
51
|
-
expect(onSubmitSignIn).not.toHaveBeenCalled();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("if I don't enter an password and I submit an error is shown and onSubmitSignIn is not called", async () => {
|
|
55
|
-
const onSubmitSignIn = vi.fn();
|
|
56
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={onSubmitSignIn} />);
|
|
57
|
-
|
|
58
|
-
await submitSignIn("test@example.com", null);
|
|
59
|
-
|
|
60
|
-
expect(screen.getByText(/please fill out this field/i)).toBeInTheDocument();
|
|
61
|
-
expect(onSubmitSignIn).not.toHaveBeenCalled();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("if I have an error and I enter the fields the errors are removed when I submit", async () => {
|
|
65
|
-
const onSubmitSignIn = vi.fn();
|
|
66
|
-
render(<SignIn title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={onSubmitSignIn} />);
|
|
67
|
-
|
|
68
|
-
await userEvent.click(screen.getByRole("button", { name: /sign in/i }));
|
|
69
|
-
expect(screen.getAllByText(/please fill out this field/i)).toBeTruthy();
|
|
70
|
-
|
|
71
|
-
await submitSignIn("test@example.com", "password1");
|
|
72
|
-
|
|
73
|
-
expect(screen.queryByText(/please fill out this field/i)).not.toBeInTheDocument();
|
|
74
|
-
expect(onSubmitSignIn).toHaveBeenCalledTimes(1);
|
|
75
|
-
expect(onSubmitSignIn).toHaveBeenCalledWith("test@example.com", "password1");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("if loading is true", () => {
|
|
79
|
-
it("the inputs and buttons are disabled", () => {
|
|
80
|
-
render(
|
|
81
|
-
<SignIn loading title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={() => null} />,
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(screen.getByRole("input", { name: /email/i })).toBeDisabled();
|
|
85
|
-
expect(screen.getByRole("input", { name: /password/i })).toBeDisabled();
|
|
86
|
-
expect(screen.getByRole("button", { name: /sign in/i })).toBeDisabled();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("a loading spinner appears", () => {
|
|
90
|
-
render(
|
|
91
|
-
<SignIn loading title="Lorem ipsum" subtitle="Sit amet" onSubmitSignIn={() => null} />,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expectProgressIndicator();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { FormEvent, useState } from "react";
|
|
2
|
-
import { Stack, Box, TextField, Typography, Alert } from "@mui/material";
|
|
3
|
-
import { LoadingButton } from "@mui/lab";
|
|
4
|
-
|
|
5
|
-
export interface SignInProps {
|
|
6
|
-
title: string;
|
|
7
|
-
subtitle: string;
|
|
8
|
-
error?: Error;
|
|
9
|
-
loading?: boolean;
|
|
10
|
-
onSubmitSignIn: (email: string, password: string) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const SignIn = ({ title, subtitle, loading, error, onSubmitSignIn }: SignInProps) => {
|
|
14
|
-
const [emailError, setEmailError] = useState("");
|
|
15
|
-
const [passwordError, setPasswordError] = useState("");
|
|
16
|
-
|
|
17
|
-
function handleSubmit(e: FormEvent<HTMLFormElement>) {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
setEmailError("");
|
|
20
|
-
setPasswordError("");
|
|
21
|
-
|
|
22
|
-
const data = new FormData(e.currentTarget);
|
|
23
|
-
const email = data.get("email")?.toString();
|
|
24
|
-
const password = data.get("password")?.toString();
|
|
25
|
-
|
|
26
|
-
if (!email) {
|
|
27
|
-
setEmailError("Please fill out this field");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!password) {
|
|
31
|
-
setPasswordError("Please fill out this field");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (email && password) {
|
|
35
|
-
onSubmitSignIn(email, password);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<Box marginBottom={2}>
|
|
42
|
-
<Typography component="h1" variant="h4">
|
|
43
|
-
{title}
|
|
44
|
-
</Typography>
|
|
45
|
-
<Typography variant="body1">{subtitle}</Typography>
|
|
46
|
-
</Box>
|
|
47
|
-
<Box component="form" onSubmit={handleSubmit}>
|
|
48
|
-
{error && (
|
|
49
|
-
<Stack width="100%" marginTop={1}>
|
|
50
|
-
<Alert variant="filled" severity="error">
|
|
51
|
-
{error.message}
|
|
52
|
-
</Alert>
|
|
53
|
-
</Stack>
|
|
54
|
-
)}
|
|
55
|
-
<TextField
|
|
56
|
-
margin="normal"
|
|
57
|
-
fullWidth
|
|
58
|
-
id="email"
|
|
59
|
-
label="Email Address"
|
|
60
|
-
name="email"
|
|
61
|
-
autoComplete="email"
|
|
62
|
-
autoFocus
|
|
63
|
-
disabled={loading}
|
|
64
|
-
type="email"
|
|
65
|
-
inputProps={{ role: "input" }}
|
|
66
|
-
error={!!emailError}
|
|
67
|
-
helperText={emailError}
|
|
68
|
-
/>
|
|
69
|
-
<TextField
|
|
70
|
-
margin="normal"
|
|
71
|
-
fullWidth
|
|
72
|
-
role="input"
|
|
73
|
-
name="password"
|
|
74
|
-
label="Password"
|
|
75
|
-
type="password"
|
|
76
|
-
id="password"
|
|
77
|
-
disabled={loading}
|
|
78
|
-
autoComplete="current-password"
|
|
79
|
-
inputProps={{ role: "input" }}
|
|
80
|
-
error={!!passwordError}
|
|
81
|
-
helperText={passwordError}
|
|
82
|
-
/>
|
|
83
|
-
<LoadingButton
|
|
84
|
-
type="submit"
|
|
85
|
-
fullWidth
|
|
86
|
-
variant="contained"
|
|
87
|
-
loading={loading}
|
|
88
|
-
disabled={loading}
|
|
89
|
-
role="button"
|
|
90
|
-
sx={{ mt: 2 }}
|
|
91
|
-
>
|
|
92
|
-
Sign In
|
|
93
|
-
</LoadingButton>
|
|
94
|
-
</Box>
|
|
95
|
-
</>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./text-field";
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { withContainer } from "../../../storybook";
|
|
3
|
-
import { TextField } from "./text-field";
|
|
4
|
-
import { faker } from "@faker-js/faker";
|
|
5
|
-
import { Box, IconButton, useTheme } from "@mui/material";
|
|
6
|
-
import ClearIcon from "@mui/icons-material/Clear";
|
|
7
|
-
import React from "react";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: "Components/Inputs/TextField",
|
|
11
|
-
component: TextField,
|
|
12
|
-
decorators: [withContainer({ width: 200 })],
|
|
13
|
-
parameters: {
|
|
14
|
-
layout: "centered",
|
|
15
|
-
},
|
|
16
|
-
} satisfies Meta<typeof TextField>;
|
|
17
|
-
type Story = StoryObj<typeof TextField>;
|
|
18
|
-
|
|
19
|
-
const options = faker.definitions.vehicle?.model || [];
|
|
20
|
-
|
|
21
|
-
export const Default: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
label: "Car model",
|
|
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
|
-
fetching: true,
|
|
60
|
-
loading: true,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const FetchingWithEndAdornment: Story = {
|
|
65
|
-
args: {
|
|
66
|
-
...Default.args,
|
|
67
|
-
fetching: true,
|
|
68
|
-
InputProps: {
|
|
69
|
-
endAdornment: (
|
|
70
|
-
<IconButton>
|
|
71
|
-
<ClearIcon />
|
|
72
|
-
</IconButton>
|
|
73
|
-
),
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const SizeSmall: Story = {
|
|
79
|
-
args: {
|
|
80
|
-
...Default.args,
|
|
81
|
-
size: "small",
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const SizeSmallFetching: Story = {
|
|
86
|
-
args: {
|
|
87
|
-
...Default.args,
|
|
88
|
-
size: "small",
|
|
89
|
-
fetching: true,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const Disabled: Story = {
|
|
94
|
-
args: {
|
|
95
|
-
...Default.args,
|
|
96
|
-
disabled: true,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const SizeSmallLoading: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
...Default.args,
|
|
103
|
-
size: "small",
|
|
104
|
-
loading: true,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
type WithBackgroundProps = {
|
|
109
|
-
bgcolor: "primary" | "secondary";
|
|
110
|
-
fetching?: boolean;
|
|
111
|
-
loading?: boolean;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const WithBackground = {
|
|
115
|
-
render: ({ bgcolor: bgcolorProp, fetching, loading }: WithBackgroundProps) => {
|
|
116
|
-
const { palette } = useTheme();
|
|
117
|
-
const BackgroundColors: Record<"primary" | "secondary", string> = {
|
|
118
|
-
primary: palette.primary.main,
|
|
119
|
-
secondary: palette.secondary.main,
|
|
120
|
-
};
|
|
121
|
-
const bgcolor = BackgroundColors[bgcolorProp];
|
|
122
|
-
const color = palette.getContrastText(bgcolor);
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<Box bgcolor={bgcolor} padding={3}>
|
|
126
|
-
<TextField label="Car model" hexColor={color} fetching={fetching} loading={loading} />
|
|
127
|
-
</Box>
|
|
128
|
-
);
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
args: {
|
|
132
|
-
bgcolor: "secondary",
|
|
133
|
-
loading: true,
|
|
134
|
-
fetching: true,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "~/tests/testing-library";
|
|
2
|
-
import { TextField } from "./text-field";
|
|
3
|
-
import { faker } from "@faker-js/faker";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import userEvent from "@testing-library/user-event";
|
|
6
|
-
import { expectProgressIndicator } from "~/tests/assertions";
|
|
7
|
-
import { vi } from "vitest";
|
|
8
|
-
|
|
9
|
-
const options = faker.definitions.vehicle?.model || [];
|
|
10
|
-
|
|
11
|
-
describe("TextField", () => {
|
|
12
|
-
const renderComponent = ({
|
|
13
|
-
value,
|
|
14
|
-
loading,
|
|
15
|
-
fetching,
|
|
16
|
-
}: { value?: string; loading?: boolean; fetching?: boolean } = {}) => {
|
|
17
|
-
const onChange = vi.fn();
|
|
18
|
-
render(
|
|
19
|
-
<TextField
|
|
20
|
-
label="Car model"
|
|
21
|
-
loading={loading}
|
|
22
|
-
fetching={fetching}
|
|
23
|
-
value={value}
|
|
24
|
-
onChange={onChange}
|
|
25
|
-
/>,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return { onChange };
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
it("should render a label", () => {
|
|
32
|
-
renderComponent();
|
|
33
|
-
|
|
34
|
-
expect(screen.getByRole("textbox", { name: /car model/i })).toBeVisible();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should render the value if is defined", () => {
|
|
38
|
-
const value = options[3];
|
|
39
|
-
renderComponent({ value });
|
|
40
|
-
|
|
41
|
-
expect(screen.getByRole("textbox")).toHaveValue(value);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should call onChange when we type something", async () => {
|
|
45
|
-
const { onChange } = renderComponent();
|
|
46
|
-
|
|
47
|
-
await userEvent.type(screen.getByRole("textbox"), "Model T");
|
|
48
|
-
|
|
49
|
-
expect(onChange).toHaveBeenCalledTimes(7);
|
|
50
|
-
expect(onChange.mock.calls[6][0].target.value).toBe("Model T");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should render a loading indicator if is fetching", () => {
|
|
54
|
-
renderComponent({ loading: true });
|
|
55
|
-
|
|
56
|
-
expectProgressIndicator();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should render a loading indicator if is loading", () => {
|
|
60
|
-
renderComponent({ fetching: true });
|
|
61
|
-
|
|
62
|
-
expectProgressIndicator();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
autocompleteClasses,
|
|
3
|
-
CircularProgress,
|
|
4
|
-
circularProgressClasses,
|
|
5
|
-
FormControl,
|
|
6
|
-
FormHelperText,
|
|
7
|
-
iconButtonClasses,
|
|
8
|
-
InputAdornment,
|
|
9
|
-
InputLabel,
|
|
10
|
-
inputLabelClasses,
|
|
11
|
-
LinearProgress,
|
|
12
|
-
linearProgressClasses,
|
|
13
|
-
OutlinedInput,
|
|
14
|
-
outlinedInputClasses,
|
|
15
|
-
TextFieldProps as MuiTextFieldProps,
|
|
16
|
-
} from "@mui/material";
|
|
17
|
-
import { unstable_useId as useId } from "@mui/utils";
|
|
18
|
-
import React from "react";
|
|
19
|
-
|
|
20
|
-
export type TextFieldProps = MuiTextFieldProps & {
|
|
21
|
-
fetching?: boolean;
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
hexColor?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const TextField = ({
|
|
27
|
-
id: overrideId,
|
|
28
|
-
label,
|
|
29
|
-
InputLabelProps,
|
|
30
|
-
InputProps,
|
|
31
|
-
fetching,
|
|
32
|
-
loading,
|
|
33
|
-
helperText,
|
|
34
|
-
hexColor,
|
|
35
|
-
size,
|
|
36
|
-
fullWidth,
|
|
37
|
-
sx,
|
|
38
|
-
...rest
|
|
39
|
-
}: TextFieldProps) => {
|
|
40
|
-
const id = useId(overrideId);
|
|
41
|
-
const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
|
|
42
|
-
const inputLabelId = label && id ? `${id}-label` : undefined;
|
|
43
|
-
|
|
44
|
-
const hexColorSx = hexColor
|
|
45
|
-
? {
|
|
46
|
-
[`& .${outlinedInputClasses.notchedOutline}`]: {
|
|
47
|
-
borderColor: `${hexColor} !important`,
|
|
48
|
-
},
|
|
49
|
-
[`& .${inputLabelClasses.root}`]: {
|
|
50
|
-
color: hexColor,
|
|
51
|
-
},
|
|
52
|
-
[`& .${outlinedInputClasses.input}`]: {
|
|
53
|
-
color: hexColor,
|
|
54
|
-
},
|
|
55
|
-
[`& .${circularProgressClasses.root}`]: {
|
|
56
|
-
color: hexColor,
|
|
57
|
-
},
|
|
58
|
-
[`& .${linearProgressClasses.bar}`]: {
|
|
59
|
-
backgroundColor: hexColor,
|
|
60
|
-
},
|
|
61
|
-
[`& .${autocompleteClasses.endAdornment} .${iconButtonClasses.root}`]: {
|
|
62
|
-
color: hexColor,
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
: {};
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<FormControl sx={hexColorSx} fullWidth={fullWidth}>
|
|
69
|
-
<InputLabel
|
|
70
|
-
size={size === "small" ? "small" : "normal"}
|
|
71
|
-
id={inputLabelId}
|
|
72
|
-
htmlFor={id}
|
|
73
|
-
{...InputLabelProps}
|
|
74
|
-
>
|
|
75
|
-
{label}
|
|
76
|
-
</InputLabel>
|
|
77
|
-
<OutlinedInput
|
|
78
|
-
{...InputProps}
|
|
79
|
-
id={id}
|
|
80
|
-
label={label}
|
|
81
|
-
size={size}
|
|
82
|
-
fullWidth={fullWidth}
|
|
83
|
-
endAdornment={
|
|
84
|
-
<InputAdornment position="end">
|
|
85
|
-
{InputProps?.endAdornment}
|
|
86
|
-
{loading ? <CircularProgress color="inherit" size={20} sx={{ ml: 1 }} /> : null}
|
|
87
|
-
</InputAdornment>
|
|
88
|
-
}
|
|
89
|
-
sx={sx}
|
|
90
|
-
{...(rest as any)}
|
|
91
|
-
/>
|
|
92
|
-
{fetching && !loading && (
|
|
93
|
-
<LinearProgress
|
|
94
|
-
color="inherit"
|
|
95
|
-
sx={{ position: "absolute", left: 0, right: 0, bottom: 0 }}
|
|
96
|
-
/>
|
|
97
|
-
)}
|
|
98
|
-
{helperText && <FormHelperText id={helperTextId}>{helperText}</FormHelperText>}
|
|
99
|
-
</FormControl>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./link";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Link as RouterLink, LinkProps as RouterLinkProps } from "react-router-dom";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
import { LinkProps, Link as MuiLink } from "@mui/material";
|
|
5
|
-
|
|
6
|
-
/* eslint-disable react/display-name, @typescript-eslint/no-explicit-any */
|
|
7
|
-
export const LinkBehaviour = forwardRef<
|
|
8
|
-
any,
|
|
9
|
-
Omit<RouterLinkProps, "to"> & { href: RouterLinkProps["to"] }
|
|
10
|
-
>((props, ref) => {
|
|
11
|
-
const { href, ...other } = props;
|
|
12
|
-
return <RouterLink ref={ref} to={href} {...other} />;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const Link = forwardRef<any, LinkProps>((props, _1) => {
|
|
16
|
-
return <MuiLink {...props} component={LinkBehaviour} />;
|
|
17
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/addon-docs';
|
|
2
|
-
import LinkTo from '@storybook/addon-links/react';
|
|
3
|
-
|
|
4
|
-
<Meta title="Components/Navigation/Introduction" />
|
|
5
|
-
|
|
6
|
-
# Navigation
|
|
7
|
-
|
|
8
|
-
<ul>
|
|
9
|
-
<li><LinkTo kind="Components/Navigation/Tab card">Tab card</LinkTo></li>
|
|
10
|
-
</ul>
|