@pautena/react-design-system 0.12.0 → 0.12.1
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/package.json +2 -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,66 +0,0 @@
|
|
|
1
|
-
import { Box, Switch, Typography, useTheme } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import CheckIcon from "@mui/icons-material/Check";
|
|
4
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
5
|
-
import {
|
|
6
|
-
BaseValueProps,
|
|
7
|
-
DefaultPlaceholder,
|
|
8
|
-
EditableValueProps,
|
|
9
|
-
useEditableValueDisplay,
|
|
10
|
-
ValueEditButton,
|
|
11
|
-
ValueEditButtons,
|
|
12
|
-
} from "../value-base";
|
|
13
|
-
import { ValueContent, getValueContentLabelId } from "../value-content";
|
|
14
|
-
|
|
15
|
-
export type ValueBooleanProps = BaseValueProps<boolean> & EditableValueProps<boolean>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Displays a boolean value with a label
|
|
19
|
-
*/
|
|
20
|
-
export const ValueBoolean = ({
|
|
21
|
-
label,
|
|
22
|
-
value,
|
|
23
|
-
placeholder = DefaultPlaceholder,
|
|
24
|
-
editable,
|
|
25
|
-
dense,
|
|
26
|
-
onEdit = () => null,
|
|
27
|
-
}: ValueBooleanProps) => {
|
|
28
|
-
const id = getValueContentLabelId(label);
|
|
29
|
-
const { typography } = useTheme();
|
|
30
|
-
const { isEditing, editValue, startEdit, cancelEdit, setEditValue, submitEdit } =
|
|
31
|
-
useEditableValueDisplay(value, onEdit);
|
|
32
|
-
|
|
33
|
-
const iconSx = { fontSize: dense ? typography.h6.fontSize : typography.h5.fontSize };
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<ValueContent label={label} dense={dense}>
|
|
37
|
-
{isEditing ? (
|
|
38
|
-
<Box display="flex" alignItems="center">
|
|
39
|
-
<Switch
|
|
40
|
-
size={dense ? "small" : "medium"}
|
|
41
|
-
checked={editValue}
|
|
42
|
-
onChange={(e) => setEditValue(e.target.checked)}
|
|
43
|
-
/>
|
|
44
|
-
<ValueEditButtons onClickCancel={cancelEdit} onClickSubmit={submitEdit} />
|
|
45
|
-
</Box>
|
|
46
|
-
) : (
|
|
47
|
-
<Box
|
|
48
|
-
display="flex"
|
|
49
|
-
alignItems="center"
|
|
50
|
-
aria-labelledby={id}
|
|
51
|
-
role="checkbox"
|
|
52
|
-
aria-checked={value}
|
|
53
|
-
>
|
|
54
|
-
{value === undefined ? (
|
|
55
|
-
<Typography variant="h5">{placeholder}</Typography>
|
|
56
|
-
) : value ? (
|
|
57
|
-
<CheckIcon color="success" sx={iconSx} />
|
|
58
|
-
) : (
|
|
59
|
-
<CloseIcon color="error" sx={iconSx} />
|
|
60
|
-
)}
|
|
61
|
-
{editable && <ValueEditButton dense={dense} onClick={startEdit} />}
|
|
62
|
-
</Box>
|
|
63
|
-
)}
|
|
64
|
-
</ValueContent>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-card";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import { ValueCard } from "./value-card";
|
|
4
|
-
import { ValueText } from "../value-text";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: "Components/Value displays/ValueCard",
|
|
8
|
-
component: ValueCard,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: "centered",
|
|
11
|
-
},
|
|
12
|
-
render: ({ children }: PropsWithChildren) => {
|
|
13
|
-
return <ValueCard>{children}</ValueCard>;
|
|
14
|
-
},
|
|
15
|
-
} satisfies Meta<typeof ValueCard>;
|
|
16
|
-
type Story = StoryObj<typeof ValueCard>;
|
|
17
|
-
|
|
18
|
-
export const ValueCardText: Story = {
|
|
19
|
-
args: {
|
|
20
|
-
children: <ValueText label="Hello world" value="Lorem ipsum sit amet" />,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ValueCard } from "./value-card";
|
|
3
|
-
import { render, screen } from "~/tests/testing-library";
|
|
4
|
-
import { ReactElement } from "react";
|
|
5
|
-
import { ValueText } from "../value-text";
|
|
6
|
-
|
|
7
|
-
describe("ValueCard", () => {
|
|
8
|
-
const renderComponent = ({ children }: { children: ReactElement }) => {
|
|
9
|
-
return render(<ValueCard>{children}</ValueCard>);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
it("would render with a ValueText inside", () => {
|
|
13
|
-
renderComponent({ children: <ValueText label="Hello world" value="Lorem ipsum sit amet" /> });
|
|
14
|
-
|
|
15
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
16
|
-
expect(screen.getByText(/lorem ipsum sit amet/i)).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Paper } from "@mui/material";
|
|
3
|
-
import { PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
|
-
export type ValueCardProps = PropsWithChildren;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Container to show a labeled value
|
|
9
|
-
*/
|
|
10
|
-
export const ValueCard = ({ children }: ValueCardProps) => {
|
|
11
|
-
return <Paper sx={{ p: 2 }}>{children}</Paper>;
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-content";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { ValueContent } from "./value-content";
|
|
3
|
-
import { withContainer } from "../../../storybook";
|
|
4
|
-
import { Typography } from "@mui/material";
|
|
5
|
-
import React from "react";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: "Components/Value displays/ValueContent",
|
|
9
|
-
component: ValueContent,
|
|
10
|
-
decorators: [withContainer({ width: 200 })],
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: "centered",
|
|
13
|
-
},
|
|
14
|
-
render: (args) => (
|
|
15
|
-
<ValueContent {...args} label="lorem ipsum">
|
|
16
|
-
<Typography>Demo content</Typography>
|
|
17
|
-
</ValueContent>
|
|
18
|
-
),
|
|
19
|
-
} satisfies Meta<typeof ValueContent>;
|
|
20
|
-
type Story = StoryObj<typeof ValueContent>;
|
|
21
|
-
|
|
22
|
-
export const Default: Story = {};
|
|
23
|
-
export const Dense: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
dense: true,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Typography } from "@mui/material";
|
|
3
|
-
import { render, screen } from "~/tests/testing-library";
|
|
4
|
-
import { ValueContent } from "./value-content";
|
|
5
|
-
import userEvent from "@testing-library/user-event";
|
|
6
|
-
|
|
7
|
-
describe("ValueContent", () => {
|
|
8
|
-
const renderComponent = ({
|
|
9
|
-
tooltip,
|
|
10
|
-
hideLabel,
|
|
11
|
-
}: { tooltip?: string; hideLabel?: boolean } = {}) => {
|
|
12
|
-
render(
|
|
13
|
-
<ValueContent
|
|
14
|
-
label="lorem ipsum"
|
|
15
|
-
tooltip={tooltip}
|
|
16
|
-
tooltipEnterDelay={0}
|
|
17
|
-
hideLabel={hideLabel}
|
|
18
|
-
>
|
|
19
|
-
<Typography>Test content</Typography>
|
|
20
|
-
</ValueContent>,
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
it("should render a label", () => {
|
|
25
|
-
renderComponent();
|
|
26
|
-
|
|
27
|
-
expect(screen.getByRole("label", { name: /lorem ipsum/i })).toBeVisible();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("shouldn't render a label if hideLabel=true", () => {
|
|
31
|
-
renderComponent({ hideLabel: true });
|
|
32
|
-
|
|
33
|
-
expect(screen.queryByRole("label", { name: /lorem ipsum/i })).not.toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe("tooltip", () => {
|
|
37
|
-
it("should render a tooltip if is defined and the user hovers the value", async () => {
|
|
38
|
-
renderComponent({ tooltip: "dolor sit amet" });
|
|
39
|
-
|
|
40
|
-
await userEvent.hover(screen.getByText(/test content/i));
|
|
41
|
-
|
|
42
|
-
expect(await screen.findByRole("tooltip", { name: /dolor sit amet/i })).toBeVisible();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("shouldn't render a tooltip if it's not defined", () => {
|
|
46
|
-
renderComponent({ tooltip: undefined });
|
|
47
|
-
|
|
48
|
-
expect(screen.queryByRole("tooltip", { name: /dolor sit amet/i })).not.toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("children", () => {
|
|
53
|
-
it("should render the children if tooltip is defined", () => {
|
|
54
|
-
renderComponent({ tooltip: "dolor sit amet" });
|
|
55
|
-
|
|
56
|
-
expect(screen.getByText(/test content/i)).toBeVisible();
|
|
57
|
-
});
|
|
58
|
-
it("should render the children if tooltip is undefined", () => {
|
|
59
|
-
renderComponent({ tooltip: undefined });
|
|
60
|
-
|
|
61
|
-
expect(screen.getByText(/test content/i)).toBeVisible();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Box, SxProps, Theme, Tooltip, Typography, useTheme } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
export const getValueContentLabelId = (label: string): string =>
|
|
5
|
-
`label-${label.replace(/ /g, "-")}`;
|
|
6
|
-
|
|
7
|
-
export interface ValueContentProps {
|
|
8
|
-
/**
|
|
9
|
-
* Name of the displayed value
|
|
10
|
-
*/
|
|
11
|
-
label: string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* If true, the label will not be shown
|
|
15
|
-
*/
|
|
16
|
-
hideLabel?: boolean;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* If defined, a tooltip is going to be added arround the children;
|
|
20
|
-
*/
|
|
21
|
-
tooltip?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Timeout before the tooltip appears when the user hovers the value
|
|
25
|
-
*/
|
|
26
|
-
tooltipEnterDelay?: number;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Component that's going to be renderd under the label
|
|
30
|
-
*/
|
|
31
|
-
children: React.ReactElement<any, any>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The value has to be displayed as compact or not.
|
|
35
|
-
* False by default
|
|
36
|
-
*/
|
|
37
|
-
dense?: boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Custom styles for the root component
|
|
41
|
-
*/
|
|
42
|
-
sx?: SxProps<Theme>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Displays a string value with a label
|
|
47
|
-
*/
|
|
48
|
-
export const ValueContent = ({
|
|
49
|
-
label,
|
|
50
|
-
hideLabel,
|
|
51
|
-
tooltip,
|
|
52
|
-
tooltipEnterDelay = 2000,
|
|
53
|
-
children,
|
|
54
|
-
dense,
|
|
55
|
-
sx,
|
|
56
|
-
}: ValueContentProps) => {
|
|
57
|
-
const { typography } = useTheme();
|
|
58
|
-
const id = getValueContentLabelId(label);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Box width={1} lineHeight={dense ? 0 : undefined} sx={sx}>
|
|
62
|
-
{!hideLabel && (
|
|
63
|
-
<Typography
|
|
64
|
-
variant={dense ? "caption" : "subtitle2"}
|
|
65
|
-
role="label"
|
|
66
|
-
id={id}
|
|
67
|
-
lineHeight={dense ? typography.pxToRem(15) : undefined}
|
|
68
|
-
>
|
|
69
|
-
{label}
|
|
70
|
-
</Typography>
|
|
71
|
-
)}
|
|
72
|
-
{tooltip ? (
|
|
73
|
-
<Tooltip title={tooltip} placement="top" enterDelay={tooltipEnterDelay}>
|
|
74
|
-
{children}
|
|
75
|
-
</Tooltip>
|
|
76
|
-
) : (
|
|
77
|
-
children
|
|
78
|
-
)}
|
|
79
|
-
</Box>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-datetime";
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { ValueDatetime } from "./value-datetime";
|
|
3
|
-
import { withContainer, withLocalizationProvider } from "../../../storybook";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Components/Value displays/ValueDatetime",
|
|
7
|
-
component: ValueDatetime,
|
|
8
|
-
decorators: [withContainer({ width: 600 }), withLocalizationProvider],
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: "centered",
|
|
11
|
-
},
|
|
12
|
-
} as Meta<typeof ValueDatetime>;
|
|
13
|
-
type Story = StoryObj<typeof ValueDatetime>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
args: {
|
|
17
|
-
label: "Lorem",
|
|
18
|
-
value: new Date(2022, 8, 22),
|
|
19
|
-
format: "yyyy/MM/dd",
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const Dense: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
label: "Lorem",
|
|
26
|
-
value: new Date(2022, 8, 22),
|
|
27
|
-
format: "yyyy/MM/dd",
|
|
28
|
-
dense: true,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const Placeholder: Story = {
|
|
33
|
-
args: {
|
|
34
|
-
label: "Lorem",
|
|
35
|
-
format: "yyyy/MM/dd",
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const CustomPlaceholder: Story = {
|
|
40
|
-
args: {
|
|
41
|
-
label: "Lorem",
|
|
42
|
-
format: "yyyy/MM/dd",
|
|
43
|
-
placeholder: ".",
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const EditableDatetime: Story = {
|
|
48
|
-
args: {
|
|
49
|
-
label: "Lorem",
|
|
50
|
-
value: new Date(2022, 8, 22, 12, 25),
|
|
51
|
-
format: "yyyy/MM/dd HH:mm",
|
|
52
|
-
editable: true,
|
|
53
|
-
editInputType: "datetime",
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const EditableTime: Story = {
|
|
58
|
-
args: {
|
|
59
|
-
label: "Lorem",
|
|
60
|
-
value: new Date(2022, 8, 22, 12, 25),
|
|
61
|
-
format: "HH:mm",
|
|
62
|
-
editable: true,
|
|
63
|
-
editInputType: "time",
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const EditableDate: Story = {
|
|
68
|
-
args: {
|
|
69
|
-
label: "Lorem",
|
|
70
|
-
value: new Date(2022, 8, 22),
|
|
71
|
-
format: "yyyy/MM/dd",
|
|
72
|
-
editable: true,
|
|
73
|
-
editInputType: "date",
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const DenseEditable: Story = {
|
|
78
|
-
args: {
|
|
79
|
-
label: "Lorem",
|
|
80
|
-
value: new Date(2022, 8, 22),
|
|
81
|
-
format: "yyyy/MM/dd",
|
|
82
|
-
editable: true,
|
|
83
|
-
editInputType: "date",
|
|
84
|
-
dense: true,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, screen } from "~/tests/testing-library";
|
|
3
|
-
import { EditInputType, ValueDatetime } from "./value-datetime";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
import { pickDatetime } from "~/tests/actions";
|
|
6
|
-
import { assertDatetimeInputValue } from "~/tests/assertions";
|
|
7
|
-
import { vi } from "vitest";
|
|
8
|
-
|
|
9
|
-
const DummyValue = new Date(2022, 7, 10, 0, 0);
|
|
10
|
-
const NewValue = new Date(2021, 8, 9, 11, 21);
|
|
11
|
-
const NewDateValue = new Date(2018, 2, 17);
|
|
12
|
-
const NewTimeValue = new Date(2021, 8, 9, 11, 21);
|
|
13
|
-
const datetimeFormat = "dd-MM-yyyy HH:mm";
|
|
14
|
-
const dateFormat = "dd-MM-yyyy";
|
|
15
|
-
const timeFormat = "HH:mm";
|
|
16
|
-
|
|
17
|
-
describe("ValueDatetime", () => {
|
|
18
|
-
const renderComponent = ({
|
|
19
|
-
value,
|
|
20
|
-
placeholder,
|
|
21
|
-
editable,
|
|
22
|
-
fmt = datetimeFormat,
|
|
23
|
-
editInputType = "datetime",
|
|
24
|
-
}: {
|
|
25
|
-
value?: Date;
|
|
26
|
-
placeholder?: string;
|
|
27
|
-
editable?: boolean;
|
|
28
|
-
fmt?: string;
|
|
29
|
-
editInputType?: EditInputType;
|
|
30
|
-
}) => {
|
|
31
|
-
const onEdit = vi.fn();
|
|
32
|
-
render(
|
|
33
|
-
<ValueDatetime
|
|
34
|
-
label="Hello world"
|
|
35
|
-
value={value}
|
|
36
|
-
placeholder={placeholder}
|
|
37
|
-
format={fmt}
|
|
38
|
-
editable={editable}
|
|
39
|
-
editInputType={editInputType}
|
|
40
|
-
onEdit={onEdit}
|
|
41
|
-
/>,
|
|
42
|
-
);
|
|
43
|
-
return { onEdit };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
it("would render the label", () => {
|
|
47
|
-
renderComponent({ value: DummyValue });
|
|
48
|
-
|
|
49
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("would render the value", () => {
|
|
53
|
-
renderComponent({ value: DummyValue });
|
|
54
|
-
|
|
55
|
-
expect(screen.getByText(/10-08-2022/i)).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should render the placeholder if value is undefined", () => {
|
|
59
|
-
renderComponent({ value: undefined });
|
|
60
|
-
|
|
61
|
-
expect(screen.getByText(/-/i)).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should render the custom placeholder if value is undefined and placeholder has value", () => {
|
|
65
|
-
renderComponent({ value: undefined, placeholder: "_" });
|
|
66
|
-
|
|
67
|
-
expect(screen.getByText(/_/i)).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe("editable", () => {
|
|
71
|
-
it("shouldn't render an option to edit if editable is false", () => {
|
|
72
|
-
renderComponent({ value: DummyValue, editable: false });
|
|
73
|
-
|
|
74
|
-
expect(screen.queryByTestId("EditIcon")).not.toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should render an option to edit if editable is true", () => {
|
|
78
|
-
renderComponent({ value: DummyValue, editable: true });
|
|
79
|
-
|
|
80
|
-
expect(screen.getByRole("button", { name: /edit/i })).toBeVisible();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should render an input with the value if the edit button is clicked", async () => {
|
|
84
|
-
renderComponent({ value: DummyValue, editable: true });
|
|
85
|
-
|
|
86
|
-
await userEvent.click(screen.getByRole("button", { name: /edit/i }));
|
|
87
|
-
|
|
88
|
-
assertDatetimeInputValue(screen.getByRole("textbox"), {
|
|
89
|
-
value: DummyValue,
|
|
90
|
-
fmt: datetimeFormat,
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it.each([
|
|
95
|
-
["datetime" as EditInputType, NewValue, new Date(2021, 8, 9, 11, 21), datetimeFormat],
|
|
96
|
-
["date" as EditInputType, NewDateValue, new Date(2018, 2, 17), dateFormat],
|
|
97
|
-
["time" as EditInputType, NewTimeValue, new Date(2022, 7, 10, 11, 21), timeFormat],
|
|
98
|
-
])(
|
|
99
|
-
"should submit the new value if is edited with type %s",
|
|
100
|
-
async (editInputType: EditInputType, newValue: Date, expectedDate: Date, fmt: string) => {
|
|
101
|
-
const { onEdit } = renderComponent({
|
|
102
|
-
value: DummyValue,
|
|
103
|
-
editable: true,
|
|
104
|
-
editInputType,
|
|
105
|
-
fmt,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
await userEvent.click(screen.getByRole("button", { name: /edit/i }));
|
|
109
|
-
pickDatetime(screen.getByRole("textbox"), newValue, fmt);
|
|
110
|
-
await userEvent.click(screen.getByRole("button", { name: /submit/i }));
|
|
111
|
-
|
|
112
|
-
expect(onEdit).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(onEdit).toHaveBeenCalledWith(expectedDate);
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
it("should not call onEdit if the edition is cancelled", async () => {
|
|
118
|
-
const { onEdit } = renderComponent({ value: DummyValue, editable: true });
|
|
119
|
-
|
|
120
|
-
await userEvent.click(screen.getByRole("button", { name: /edit/i }));
|
|
121
|
-
pickDatetime(screen.getByRole("textbox"), NewValue, datetimeFormat);
|
|
122
|
-
await userEvent.click(screen.getByRole("button", { name: /cancel/i }));
|
|
123
|
-
|
|
124
|
-
expect(onEdit).not.toHaveBeenCalled();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("should have the original value if is edited again after clear a change", async () => {
|
|
128
|
-
renderComponent({ value: DummyValue, editable: true });
|
|
129
|
-
|
|
130
|
-
await userEvent.click(screen.getByRole("button", { name: /edit/i }));
|
|
131
|
-
pickDatetime(screen.getByRole("textbox"), NewValue, datetimeFormat);
|
|
132
|
-
await userEvent.click(screen.getByRole("button", { name: /cancel/i }));
|
|
133
|
-
await userEvent.click(screen.getByRole("button", { name: /edit/i }));
|
|
134
|
-
|
|
135
|
-
assertDatetimeInputValue(screen.getByRole("textbox"), {
|
|
136
|
-
value: DummyValue,
|
|
137
|
-
fmt: datetimeFormat,
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Box, TextField, Typography } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
|
-
import {
|
|
5
|
-
BaseValueProps,
|
|
6
|
-
DefaultPlaceholder,
|
|
7
|
-
EditableValueProps,
|
|
8
|
-
} from "../value-base/value-displays.types";
|
|
9
|
-
import { getValueContentLabelId, ValueContent } from "../value-content";
|
|
10
|
-
import { useEditableValueDisplay, ValueEditButton, ValueEditButtons } from "../value-base";
|
|
11
|
-
import { DatePicker, DateTimePicker, TimePicker } from "@mui/x-date-pickers";
|
|
12
|
-
|
|
13
|
-
export type EditInputType = "datetime" | "date" | "time";
|
|
14
|
-
|
|
15
|
-
export interface ValueDatetimeProps extends BaseValueProps<Date>, EditableValueProps<Date> {
|
|
16
|
-
/**
|
|
17
|
-
* Datetime format
|
|
18
|
-
*/
|
|
19
|
-
format: string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Edit input type
|
|
23
|
-
*/
|
|
24
|
-
editInputType?: EditInputType;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Displays a formated datetime with a label
|
|
29
|
-
*/
|
|
30
|
-
export const ValueDatetime = ({
|
|
31
|
-
label,
|
|
32
|
-
value: valueProp,
|
|
33
|
-
format: fmt,
|
|
34
|
-
placeholder = DefaultPlaceholder,
|
|
35
|
-
editable,
|
|
36
|
-
editInputType = "datetime",
|
|
37
|
-
dense,
|
|
38
|
-
onEdit = () => null,
|
|
39
|
-
}: ValueDatetimeProps) => {
|
|
40
|
-
const { isEditing, editValue, startEdit, cancelEdit, setEditValue, submitEdit } =
|
|
41
|
-
useEditableValueDisplay(valueProp, onEdit);
|
|
42
|
-
const id = getValueContentLabelId(label);
|
|
43
|
-
const value = (valueProp && format(valueProp, fmt)) || placeholder;
|
|
44
|
-
|
|
45
|
-
const EditPickerComponent =
|
|
46
|
-
editInputType === "datetime"
|
|
47
|
-
? DateTimePicker
|
|
48
|
-
: editInputType === "time"
|
|
49
|
-
? TimePicker
|
|
50
|
-
: DatePicker;
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<ValueContent
|
|
54
|
-
label={label}
|
|
55
|
-
hideLabel={isEditing}
|
|
56
|
-
tooltip={value}
|
|
57
|
-
dense={dense}
|
|
58
|
-
sx={{ display: "flex", flexDirection: "column" }}
|
|
59
|
-
>
|
|
60
|
-
{isEditing ? (
|
|
61
|
-
<EditPickerComponent
|
|
62
|
-
value={editValue}
|
|
63
|
-
format={fmt}
|
|
64
|
-
label={label}
|
|
65
|
-
onChange={(newValue) => setEditValue(newValue ? newValue : undefined)}
|
|
66
|
-
slots={{
|
|
67
|
-
textField: (params) => (
|
|
68
|
-
<TextField
|
|
69
|
-
{...params}
|
|
70
|
-
size="small"
|
|
71
|
-
InputProps={{
|
|
72
|
-
...params.InputProps,
|
|
73
|
-
endAdornment: (
|
|
74
|
-
<>
|
|
75
|
-
{params.InputProps?.endAdornment}
|
|
76
|
-
<ValueEditButtons
|
|
77
|
-
onClickCancel={cancelEdit}
|
|
78
|
-
onClickSubmit={submitEdit}
|
|
79
|
-
sx={{ ml: 2 }}
|
|
80
|
-
/>
|
|
81
|
-
</>
|
|
82
|
-
),
|
|
83
|
-
sx: { marginY: !dense ? 1 : 0.2 },
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
),
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
) : (
|
|
90
|
-
<Box display="flex" alignItems="center">
|
|
91
|
-
<Typography variant={dense ? "body1" : "h5"} noWrap aria-labelledby={id}>
|
|
92
|
-
{value}
|
|
93
|
-
</Typography>
|
|
94
|
-
{editable && <ValueEditButton dense={dense} onClick={startEdit} />}
|
|
95
|
-
</Box>
|
|
96
|
-
)}
|
|
97
|
-
</ValueContent>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/addon-docs";
|
|
2
|
-
import LinkTo from "@storybook/addon-links/react";
|
|
3
|
-
|
|
4
|
-
<Meta title="Components/Value displays/Introduction" />
|
|
5
|
-
|
|
6
|
-
# Value Displays
|
|
7
|
-
|
|
8
|
-
<ul>
|
|
9
|
-
<li>
|
|
10
|
-
<LinkTo kind="Components/Value displays/GroupValueCard">GroupValueCard</LinkTo>
|
|
11
|
-
</li>
|
|
12
|
-
<li>
|
|
13
|
-
<LinkTo kind="Components/Value displays/ValueBoolean">ValueBoolean</LinkTo>
|
|
14
|
-
</li>
|
|
15
|
-
<li>
|
|
16
|
-
<LinkTo kind="Components/Value displays/ValueCard">ValueCard</LinkTo>
|
|
17
|
-
</li>
|
|
18
|
-
<li>
|
|
19
|
-
<LinkTo kind="Components/Value displays/ValueContent">ValueContent</LinkTo>
|
|
20
|
-
</li>
|
|
21
|
-
<li>
|
|
22
|
-
<LinkTo kind="Components/Value displays/ValueDatetime">ValueDatetime</LinkTo>
|
|
23
|
-
</li>
|
|
24
|
-
<li>
|
|
25
|
-
<LinkTo kind="Components/Value displays/ValueImage">ValueImage</LinkTo>
|
|
26
|
-
</li>
|
|
27
|
-
<li>
|
|
28
|
-
<LinkTo kind="Components/Value displays/ValueText">ValueText</LinkTo>
|
|
29
|
-
</li>
|
|
30
|
-
<li>
|
|
31
|
-
<LinkTo kind="Components/Value displays/ValueRating">ValueRating</LinkTo>
|
|
32
|
-
</li>
|
|
33
|
-
<li>
|
|
34
|
-
<LinkTo kind="Components/Value displays/ValueItem">ValueItem</LinkTo>
|
|
35
|
-
</li>
|
|
36
|
-
<li>
|
|
37
|
-
<LinkTo kind="Components/Value displays/ValueLabel">ValueLabel</LinkTo>
|
|
38
|
-
</li>
|
|
39
|
-
</ul>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-image";
|