@memori.ai/memori-react 8.10.1 → 8.12.0
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/CHANGELOG.md +66 -0
- package/dist/components/AgeVerificationModal/AgeVerificationModal.css +41 -14
- package/dist/components/AgeVerificationModal/AgeVerificationModal.js +2 -2
- package/dist/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
- package/dist/components/Auth/Auth.js +36 -8
- package/dist/components/Auth/Auth.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.css +2 -2
- package/dist/components/Chat/Chat.js +2 -2
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.css +81 -13
- package/dist/components/ChatBubble/ChatBubble.js +86 -19
- package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
- package/dist/components/ChatHistoryDrawer/ChatHistory.css +5 -1
- package/dist/components/ChatInputs/ChatInputs.d.ts +1 -0
- package/dist/components/ChatInputs/ChatInputs.js +8 -3
- package/dist/components/ChatInputs/ChatInputs.js.map +1 -1
- package/dist/components/DateSelector/DateSelector.css +125 -104
- package/dist/components/DateSelector/DateSelector.d.ts +1 -1
- package/dist/components/DateSelector/DateSelector.js +110 -52
- package/dist/components/DateSelector/DateSelector.js.map +1 -1
- package/dist/components/Header/Header.js +1 -1
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/LoginDrawer/LoginDrawer.css +37 -5
- package/dist/components/LoginDrawer/LoginDrawer.d.ts +1 -2
- package/dist/components/LoginDrawer/LoginDrawer.js +2 -9
- package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/dist/components/MediaWidget/MediaItemWidget.js +40 -5
- package/dist/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/dist/components/MediaWidget/MediaWidget.css +4 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js +3 -0
- package/dist/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +2 -2
- package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +16 -7
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +6 -4
- package/dist/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/dist/components/MemoriWidget/MemoriWidget.js +69 -25
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/UploadButton/UploadButton.js +2 -0
- package/dist/components/UploadButton/UploadButton.js.map +1 -1
- package/dist/components/UploadButton/UploadImages/UploadImages.js +2 -2
- package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/dist/components/ui/Drawer.css +8 -0
- package/dist/components/ui/Drawer.d.ts +2 -0
- package/dist/components/ui/Drawer.js +2 -2
- package/dist/components/ui/Drawer.js.map +1 -1
- package/dist/components/ui/Tooltip.css +49 -1
- package/dist/components/ui/Tooltip.d.ts +1 -1
- package/dist/locales/de.json +6 -1
- package/dist/locales/en.json +9 -1
- package/dist/locales/es.json +6 -1
- package/dist/locales/fr.json +5 -1
- package/dist/locales/it.json +8 -1
- package/dist/styles.css +3 -2
- package/esm/components/AgeVerificationModal/AgeVerificationModal.css +41 -14
- package/esm/components/AgeVerificationModal/AgeVerificationModal.js +2 -2
- package/esm/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
- package/esm/components/Auth/Auth.js +36 -8
- package/esm/components/Auth/Auth.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.css +2 -2
- package/esm/components/Chat/Chat.js +2 -2
- package/esm/components/Chat/Chat.js.map +1 -1
- package/esm/components/ChatBubble/ChatBubble.css +81 -13
- package/esm/components/ChatBubble/ChatBubble.js +87 -20
- package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
- package/esm/components/ChatHistoryDrawer/ChatHistory.css +5 -1
- package/esm/components/ChatInputs/ChatInputs.d.ts +1 -0
- package/esm/components/ChatInputs/ChatInputs.js +8 -3
- package/esm/components/ChatInputs/ChatInputs.js.map +1 -1
- package/esm/components/DateSelector/DateSelector.css +125 -104
- package/esm/components/DateSelector/DateSelector.d.ts +1 -1
- package/esm/components/DateSelector/DateSelector.js +111 -52
- package/esm/components/DateSelector/DateSelector.js.map +1 -1
- package/esm/components/Header/Header.js +1 -1
- package/esm/components/Header/Header.js.map +1 -1
- package/esm/components/LoginDrawer/LoginDrawer.css +37 -5
- package/esm/components/LoginDrawer/LoginDrawer.d.ts +1 -2
- package/esm/components/LoginDrawer/LoginDrawer.js +2 -9
- package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
- package/esm/components/MediaWidget/MediaItemWidget.js +40 -5
- package/esm/components/MediaWidget/MediaItemWidget.js.map +1 -1
- package/esm/components/MediaWidget/MediaWidget.css +4 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js +3 -0
- package/esm/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +2 -2
- package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +16 -7
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js +6 -4
- package/esm/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.js.map +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +69 -25
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/UploadButton/UploadButton.js +2 -0
- package/esm/components/UploadButton/UploadButton.js.map +1 -1
- package/esm/components/UploadButton/UploadImages/UploadImages.js +2 -2
- package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
- package/esm/components/ui/Drawer.css +8 -0
- package/esm/components/ui/Drawer.d.ts +2 -0
- package/esm/components/ui/Drawer.js +2 -2
- package/esm/components/ui/Drawer.js.map +1 -1
- package/esm/components/ui/Tooltip.css +49 -1
- package/esm/components/ui/Tooltip.d.ts +1 -1
- package/esm/locales/de.json +6 -1
- package/esm/locales/en.json +9 -1
- package/esm/locales/es.json +6 -1
- package/esm/locales/fr.json +5 -1
- package/esm/locales/it.json +8 -1
- package/esm/styles.css +3 -2
- package/package.json +2 -2
- package/src/components/AgeVerificationModal/AgeVerificationModal.css +41 -14
- package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +3 -1
- package/src/components/Auth/Auth.tsx +55 -11
- package/src/components/Avatar/Avatar.stories.tsx +3 -0
- package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.css +2 -2
- package/src/components/Chat/Chat.stories.tsx +16 -2
- package/src/components/Chat/Chat.tsx +2 -1
- package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +1036 -36
- package/src/components/ChatBubble/ChatBubble.css +81 -13
- package/src/components/ChatBubble/ChatBubble.stories.tsx +16 -2
- package/src/components/ChatBubble/ChatBubble.test.tsx +17 -0
- package/src/components/ChatBubble/ChatBubble.tsx +144 -31
- package/src/components/ChatBubble/__snapshots__/ChatBubble.test.tsx.snap +304 -8
- package/src/components/ChatHistoryDrawer/ChatHistory.css +5 -1
- package/src/components/ChatInputs/ChatInputs.tsx +14 -1
- package/src/components/DateSelector/DateSelector.css +125 -104
- package/src/components/DateSelector/DateSelector.stories.tsx +1 -1
- package/src/components/DateSelector/DateSelector.test.tsx +137 -23
- package/src/components/DateSelector/DateSelector.tsx +203 -177
- package/src/components/Header/Header.stories.tsx +5 -1
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/Header/__snapshots__/Header.test.tsx.snap +1 -1
- package/src/components/LoginDrawer/LoginDrawer.css +37 -5
- package/src/components/LoginDrawer/LoginDrawer.stories.tsx +0 -1
- package/src/components/LoginDrawer/LoginDrawer.test.tsx +0 -1
- package/src/components/LoginDrawer/LoginDrawer.tsx +0 -19
- package/src/components/MediaWidget/MediaItemWidget.stories.tsx +69 -0
- package/src/components/MediaWidget/MediaItemWidget.tsx +66 -18
- package/src/components/MediaWidget/MediaWidget.css +4 -0
- package/src/components/MediaWidget/__snapshots__/MediaItemWidget.test.tsx.snap +10 -10
- package/src/components/MediaWidget/__snapshots__/MediaWidget.test.tsx.snap +2 -2
- package/src/components/MemoriArtifactSystem/ArtifactDrawer.stories.tsx +996 -204
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/ArtifactActions.tsx +2 -2
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyButtonWithDropdown.tsx +1 -1
- package/src/components/MemoriArtifactSystem/components/ArtifactActions/components/CopyMenuItem.tsx +3 -0
- package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +56 -54
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.css +16 -7
- package/src/components/MemoriArtifactSystem/components/ArtifactPreview/ArtifactPreview.tsx +12 -3
- package/src/components/MemoriWidget/MemoriWidget.stories.tsx +6 -3
- package/src/components/MemoriWidget/MemoriWidget.tsx +123 -48
- package/src/components/UploadButton/UploadButton.tsx +2 -0
- package/src/components/UploadButton/UploadImages/UploadImages.tsx +3 -2
- package/src/components/layouts/FullBody/FullBody.stories.tsx +110 -0
- package/src/components/layouts/Totem/Totem.stories.tsx +131 -0
- package/src/components/layouts/ZoomedFullBody/ZoomedFullBody.stories.tsx +131 -0
- package/src/components/layouts/layouts.stories.tsx +55 -508
- package/src/components/ui/Drawer.css +8 -0
- package/src/components/ui/Drawer.tsx +16 -12
- package/src/components/ui/Tooltip.css +49 -1
- package/src/components/ui/Tooltip.tsx +1 -1
- package/src/index.stories.tsx +13 -320
- package/src/locales/de.json +6 -1
- package/src/locales/en.json +9 -1
- package/src/locales/es.json +6 -1
- package/src/locales/fr.json +5 -1
- package/src/locales/it.json +8 -1
- package/src/mocks/data.ts +4 -2
- package/src/styles.css +3 -2
- package/src/components/SignupForm/SignupForm.test.tsx +0 -40
- package/src/components/SignupForm/SignupForm.tsx +0 -457
- package/src/components/SignupForm/__snapshots__/SignupForm.test.tsx.snap +0 -247
|
@@ -1,137 +1,158 @@
|
|
|
1
|
+
/* Screen reader only - visually hidden but accessible */
|
|
2
|
+
.sr-only {
|
|
3
|
+
position: absolute;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
width: 1px;
|
|
6
|
+
height: 1px;
|
|
7
|
+
padding: 0;
|
|
8
|
+
border-width: 0;
|
|
9
|
+
margin: -1px;
|
|
10
|
+
clip: rect(0, 0, 0, 0);
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Base Container */
|
|
1
15
|
.memori--date-selector {
|
|
2
|
-
|
|
3
|
-
|
|
16
|
+
width: 100%;
|
|
17
|
+
/* margin-top: 1.5rem; */
|
|
4
18
|
}
|
|
5
19
|
|
|
6
|
-
|
|
7
|
-
|
|
20
|
+
/* Mobile Styles */
|
|
21
|
+
.memori--date-selector--mobile {
|
|
22
|
+
display: flex;
|
|
23
|
+
width: 100%;
|
|
8
24
|
max-width: 100%;
|
|
9
|
-
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
padding: 0;
|
|
28
|
+
margin: 1rem 0;
|
|
10
29
|
}
|
|
11
30
|
|
|
12
|
-
.memori--date-
|
|
13
|
-
|
|
31
|
+
.memori--date-selector__mobile-label {
|
|
32
|
+
display: block;
|
|
14
33
|
width: 100%;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
border: 1px solid #e5e7eb;
|
|
20
|
-
border-radius: 0.5rem;
|
|
21
|
-
background: #fff;
|
|
22
|
-
box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.1) 0px 4px 6px -1px,
|
|
23
|
-
rgba(0, 0, 0, 0.1) 0px 2px 4px -2px;
|
|
24
|
-
cursor: pointer;
|
|
34
|
+
margin-bottom: 0.5rem;
|
|
35
|
+
color: #374151;
|
|
36
|
+
font-size: 0.95rem;
|
|
37
|
+
font-weight: 500;
|
|
25
38
|
text-align: left;
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
.memori--date-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
border
|
|
35
|
-
|
|
41
|
+
.memori--date-selector__mobile-input {
|
|
42
|
+
width: 100%;
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
min-height: 48px;
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
padding: 0.875rem 1rem;
|
|
47
|
+
border: 1px solid #e5e7eb;
|
|
48
|
+
border-radius: 0.5rem;
|
|
49
|
+
-webkit-appearance: none;
|
|
50
|
+
appearance: none;
|
|
51
|
+
background: #ffffff;
|
|
52
|
+
/* Touch-friendly */
|
|
53
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
54
|
+
color: #1f2937;
|
|
55
|
+
font-size: 1rem;
|
|
56
|
+
transition: all 0.2s ease;
|
|
36
57
|
}
|
|
37
58
|
|
|
38
|
-
.memori--date-
|
|
39
|
-
border-color: #
|
|
59
|
+
.memori--date-selector__mobile-input:focus {
|
|
60
|
+
border-color: var(--memori-primary, #9333ea);
|
|
61
|
+
box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
|
|
62
|
+
outline: none;
|
|
40
63
|
}
|
|
41
64
|
|
|
42
|
-
.memori--date-
|
|
43
|
-
border-color: #
|
|
65
|
+
.memori--date-selector__mobile-input:active {
|
|
66
|
+
border-color: var(--memori-primary, #9333ea);
|
|
44
67
|
}
|
|
45
68
|
|
|
46
|
-
.memori--date-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
color: #a0aec0;
|
|
69
|
+
.memori--date-selector__mobile-input:disabled {
|
|
70
|
+
background-color: #f9fafb;
|
|
71
|
+
color: #9ca3af;
|
|
50
72
|
cursor: not-allowed;
|
|
73
|
+
opacity: 0.6;
|
|
51
74
|
}
|
|
52
75
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.memori--date-selector__select-label {
|
|
61
|
-
display: inline-block;
|
|
62
|
-
margin-bottom: 0.25rem;
|
|
76
|
+
/* Desktop Styles */
|
|
77
|
+
.memori--date-selector--desktop {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
gap: 1rem;
|
|
63
82
|
}
|
|
64
83
|
|
|
65
|
-
.memori--date-
|
|
66
|
-
display:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
.memori--date-selector__input-group {
|
|
85
|
+
display: flex;
|
|
86
|
+
min-width: 80px;
|
|
87
|
+
/* flex: 1; */
|
|
88
|
+
flex-direction: column;
|
|
70
89
|
}
|
|
71
90
|
|
|
72
|
-
.memori--date-
|
|
73
|
-
|
|
74
|
-
top: 0;
|
|
75
|
-
right: 0;
|
|
76
|
-
bottom: 0;
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
padding-right: 0.5rem;
|
|
80
|
-
pointer-events: none;
|
|
91
|
+
.memori--date-selector__input-group--year {
|
|
92
|
+
min-width: 100px;
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
.memori--date-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
color:
|
|
95
|
+
.memori--date-selector__label {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
margin-bottom: 0.5rem;
|
|
98
|
+
color: #4b5563;
|
|
99
|
+
font-size: 0.875rem;
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
letter-spacing: 0.01em;
|
|
87
102
|
}
|
|
88
103
|
|
|
89
|
-
|
|
90
|
-
position: absolute;
|
|
91
|
-
z-index: 1;
|
|
92
|
-
overflow: auto;
|
|
104
|
+
.memori--date-selector__input {
|
|
93
105
|
width: 100%;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
padding: 0.75rem 1rem;
|
|
107
|
+
border: 2px solid #e5e7eb;
|
|
108
|
+
border-radius: 0.75rem;
|
|
109
|
+
-moz-appearance: textfield;
|
|
110
|
+
appearance: textfield;
|
|
111
|
+
/* Remove spinner buttons */
|
|
112
|
+
background: #ffffff;
|
|
113
|
+
color: #1f2937;
|
|
114
|
+
font-size: 0.95rem;
|
|
115
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.memori--date-selector__input::-webkit-outer-spin-button,
|
|
119
|
+
.memori--date-selector__input::-webkit-inner-spin-button {
|
|
120
|
+
margin: 0;
|
|
121
|
+
-webkit-appearance: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.memori--date-selector__input:focus {
|
|
125
|
+
border-color: var(--memori-primary);
|
|
126
|
+
box-shadow: 0 0 0 4px rgba(var(--memori-primary-rgb), 0.1);
|
|
127
|
+
outline: none;
|
|
128
|
+
transform: translateY(-1px);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.memori--date-selector__input:disabled {
|
|
132
|
+
border-color: #e5e7eb;
|
|
133
|
+
background: #f9fafb;
|
|
134
|
+
color: #9ca3af;
|
|
135
|
+
cursor: not-allowed;
|
|
136
|
+
opacity: 0.6;
|
|
116
137
|
}
|
|
117
138
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
padding-top: 0.5rem;
|
|
121
|
-
padding-right: 1rem;
|
|
122
|
-
padding-bottom: 0.5rem;
|
|
123
|
-
padding-left: 1rem;
|
|
124
|
-
color: rgb(17 24 39/1);
|
|
125
|
-
cursor: pointer;
|
|
126
|
-
user-select: none;
|
|
139
|
+
.memori--date-selector__input::placeholder {
|
|
140
|
+
color: #9ca3af;
|
|
127
141
|
}
|
|
128
142
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
143
|
+
/* Responsive adjustments */
|
|
144
|
+
@media (max-width: 767px) {
|
|
145
|
+
.memori--date-selector--desktop {
|
|
146
|
+
display: none;
|
|
147
|
+
/* Hide desktop version on mobile if both are rendered for some reason */
|
|
148
|
+
}
|
|
133
149
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
.memori--date-selector--mobile {
|
|
151
|
+
margin: 0.75rem 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.memori--date-selector__mobile-input {
|
|
155
|
+
min-height: 44px;
|
|
156
|
+
font-size: 16px; /* Prevents zoom on iOS */
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
2
2
|
import DateSelector from './DateSelector';
|
|
3
|
-
import { DateTime } from 'luxon';
|
|
4
3
|
|
|
5
4
|
const dateMock = new Date(Date.UTC(2022, 8, 24, 0, 0, 0, 0));
|
|
6
5
|
|
|
@@ -9,27 +8,142 @@ Date.now = jest.fn(() => dateMock.valueOf());
|
|
|
9
8
|
|
|
10
9
|
jest.spyOn(Date, 'now').mockImplementation(() => dateMock.valueOf());
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
<DateSelector defaultDate={new Date(Date.now())} onChange={jest.fn()} />
|
|
15
|
-
);
|
|
16
|
-
expect(container).toMatchSnapshot();
|
|
17
|
-
});
|
|
11
|
+
describe('DateSelector', () => {
|
|
12
|
+
const mockOnChange = jest.fn();
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockOnChange.mockClear();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders DateSelector with empty inputs when no defaultDate provided', () => {
|
|
19
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
20
|
+
|
|
21
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
22
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
23
|
+
const yearInput = screen.getByLabelText(/year/i);
|
|
24
|
+
|
|
25
|
+
expect(dayInput).toHaveValue(null); // number input value is null/empty string
|
|
26
|
+
expect(monthInput).toHaveValue(null);
|
|
27
|
+
expect(yearInput).toHaveValue(null);
|
|
28
|
+
|
|
29
|
+
// Should call onChange with undefined initially or not at all if we want strict behavior
|
|
30
|
+
// Based on implementation: useEffect triggers on mount. If empty, calls onChange(undefined).
|
|
31
|
+
expect(mockOnChange).toHaveBeenCalledWith(undefined);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('renders DateSelector with default value correctly', () => {
|
|
35
|
+
const defaultDate = new Date(Date.now());
|
|
36
|
+
render(
|
|
37
|
+
<DateSelector defaultDate={defaultDate} onChange={mockOnChange} />
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
41
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
42
|
+
const yearInput = screen.getByLabelText(/year/i);
|
|
43
|
+
|
|
44
|
+
expect(dayInput).toHaveValue(defaultDate.getDate());
|
|
45
|
+
expect(monthInput).toHaveValue(defaultDate.getMonth() + 1);
|
|
46
|
+
expect(yearInput).toHaveValue(defaultDate.getFullYear());
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('Desktop View', () => {
|
|
50
|
+
it('updates day and calls onChange with undefined if incomplete', () => {
|
|
51
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
52
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
53
|
+
|
|
54
|
+
fireEvent.change(dayInput, { target: { value: '15' } });
|
|
55
|
+
|
|
56
|
+
expect(dayInput).toHaveValue(15);
|
|
57
|
+
expect(mockOnChange).toHaveBeenCalledWith(undefined);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('calls onChange with valid date when all fields are filled', () => {
|
|
61
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
62
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
63
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
64
|
+
const yearInput = screen.getByLabelText(/year/i);
|
|
65
|
+
|
|
66
|
+
fireEvent.change(dayInput, { target: { value: '15' } });
|
|
67
|
+
fireEvent.change(monthInput, { target: { value: '5' } });
|
|
68
|
+
fireEvent.change(yearInput, { target: { value: '1990' } });
|
|
69
|
+
|
|
70
|
+
expect(mockOnChange).toHaveBeenCalledWith(
|
|
71
|
+
expect.objectContaining({
|
|
72
|
+
year: 1990,
|
|
73
|
+
month: 5,
|
|
74
|
+
day: 15,
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('auto-focuses month after day is filled', () => {
|
|
80
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
81
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
82
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
83
|
+
|
|
84
|
+
fireEvent.change(dayInput, { target: { value: '12' } });
|
|
85
|
+
|
|
86
|
+
expect(monthInput).toHaveFocus();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('auto-focuses year after month is filled', () => {
|
|
90
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
91
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
92
|
+
const yearInput = screen.getByLabelText(/year/i);
|
|
93
|
+
|
|
94
|
+
fireEvent.change(monthInput, { target: { value: '12' } });
|
|
95
|
+
|
|
96
|
+
expect(yearInput).toHaveFocus();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('disables all inputs when disabled prop is true', () => {
|
|
100
|
+
render(<DateSelector disabled onChange={mockOnChange} />);
|
|
101
|
+
|
|
102
|
+
const dayInput = screen.getByLabelText(/day/i);
|
|
103
|
+
const monthInput = screen.getByLabelText(/month/i);
|
|
104
|
+
const yearInput = screen.getByLabelText(/year/i);
|
|
105
|
+
|
|
106
|
+
expect(dayInput).toBeDisabled();
|
|
107
|
+
expect(monthInput).toBeDisabled();
|
|
108
|
+
expect(yearInput).toBeDisabled();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('Mobile View', () => {
|
|
113
|
+
it('renders native date input on mobile', () => {
|
|
114
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
115
|
+
|
|
116
|
+
const dateInput = screen.getByLabelText(/date/i);
|
|
117
|
+
expect(dateInput).toBeInTheDocument();
|
|
118
|
+
expect(dateInput).toHaveAttribute('type', 'date');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('calls onChange when mobile date input changes', async () => {
|
|
122
|
+
render(<DateSelector onChange={mockOnChange} />);
|
|
123
|
+
|
|
124
|
+
const dateInput = screen.getByLabelText(/date/i);
|
|
125
|
+
fireEvent.change(dateInput, { target: { value: '1995-06-15' } });
|
|
126
|
+
|
|
127
|
+
await waitFor(() => {
|
|
128
|
+
expect(mockOnChange).toHaveBeenCalledWith(
|
|
129
|
+
expect.objectContaining({
|
|
130
|
+
year: 1995,
|
|
131
|
+
month: 6,
|
|
132
|
+
day: 15
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('calls onChange with undefined when mobile input is cleared', async () => {
|
|
139
|
+
render(<DateSelector defaultDate="1995-06-15" onChange={mockOnChange} />);
|
|
140
|
+
|
|
141
|
+
const dateInput = screen.getByLabelText(/date/i);
|
|
142
|
+
fireEvent.change(dateInput, { target: { value: '' } });
|
|
25
143
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
onChange={jest.fn()}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
expect(container).toMatchSnapshot();
|
|
144
|
+
await waitFor(() => {
|
|
145
|
+
expect(mockOnChange).toHaveBeenCalledWith(undefined);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
35
149
|
});
|