@contentful/field-editor-date 2.0.12 → 2.0.13

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.
@@ -57,7 +57,9 @@ const validInputFormats = [
57
57
  'hh:mm a',
58
58
  'h:mm a',
59
59
  'HH:mm',
60
+ 'HHmm',
60
61
  'hh:mm',
62
+ 'hhmm',
61
63
  'kk:mm',
62
64
  'k:mm',
63
65
  'h a',
@@ -165,6 +165,59 @@ describe('TimepickerInput', ()=>{
165
165
  });
166
166
  });
167
167
  });
168
+ describe('shorthand input without colon', ()=>{
169
+ it('parses 1005 as 10:05 in 24h mode', ()=>{
170
+ const onChange = jest.fn();
171
+ const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
172
+ disabled: false,
173
+ uses12hClock: false,
174
+ time: "00:00",
175
+ ampm: "AM",
176
+ onChange: onChange
177
+ }));
178
+ _userevent.default.clear(getByTestId('time-input'));
179
+ _userevent.default.type(getByTestId('time-input'), '1005');
180
+ _userevent.default.tab();
181
+ expect(onChange).toHaveBeenCalledWith({
182
+ time: '10:05',
183
+ ampm: 'AM'
184
+ });
185
+ });
186
+ it('parses 1900 as 19:00 in 24h mode', ()=>{
187
+ const onChange = jest.fn();
188
+ const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
189
+ disabled: false,
190
+ uses12hClock: false,
191
+ time: "00:00",
192
+ ampm: "AM",
193
+ onChange: onChange
194
+ }));
195
+ _userevent.default.clear(getByTestId('time-input'));
196
+ _userevent.default.type(getByTestId('time-input'), '1900');
197
+ _userevent.default.tab();
198
+ expect(onChange).toHaveBeenCalledWith({
199
+ time: '19:00',
200
+ ampm: 'PM'
201
+ });
202
+ });
203
+ it('parses 0700 as 07:00 AM in 12h mode', ()=>{
204
+ const onChange = jest.fn();
205
+ const { getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_TimepickerInput.TimepickerInput, {
206
+ disabled: false,
207
+ uses12hClock: true,
208
+ time: "12:00",
209
+ ampm: "AM",
210
+ onChange: onChange
211
+ }));
212
+ _userevent.default.clear(getByTestId('time-input'));
213
+ _userevent.default.type(getByTestId('time-input'), '0700');
214
+ _userevent.default.tab();
215
+ expect(onChange).toHaveBeenCalledWith({
216
+ time: '07:00',
217
+ ampm: 'AM'
218
+ });
219
+ });
220
+ });
168
221
  describe('onChange on blur — 12h mode', ()=>{
169
222
  it('emits 07:00 AM correctly in 12h mode', ()=>{
170
223
  const onChange = jest.fn();
@@ -6,7 +6,9 @@ const validInputFormats = [
6
6
  'hh:mm a',
7
7
  'h:mm a',
8
8
  'HH:mm',
9
+ 'HHmm',
9
10
  'hh:mm',
11
+ 'hhmm',
10
12
  'kk:mm',
11
13
  'k:mm',
12
14
  'h a',
@@ -115,6 +115,59 @@ describe('TimepickerInput', ()=>{
115
115
  });
116
116
  });
117
117
  });
118
+ describe('shorthand input without colon', ()=>{
119
+ it('parses 1005 as 10:05 in 24h mode', ()=>{
120
+ const onChange = jest.fn();
121
+ const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
122
+ disabled: false,
123
+ uses12hClock: false,
124
+ time: "00:00",
125
+ ampm: "AM",
126
+ onChange: onChange
127
+ }));
128
+ userEvent.clear(getByTestId('time-input'));
129
+ userEvent.type(getByTestId('time-input'), '1005');
130
+ userEvent.tab();
131
+ expect(onChange).toHaveBeenCalledWith({
132
+ time: '10:05',
133
+ ampm: 'AM'
134
+ });
135
+ });
136
+ it('parses 1900 as 19:00 in 24h mode', ()=>{
137
+ const onChange = jest.fn();
138
+ const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
139
+ disabled: false,
140
+ uses12hClock: false,
141
+ time: "00:00",
142
+ ampm: "AM",
143
+ onChange: onChange
144
+ }));
145
+ userEvent.clear(getByTestId('time-input'));
146
+ userEvent.type(getByTestId('time-input'), '1900');
147
+ userEvent.tab();
148
+ expect(onChange).toHaveBeenCalledWith({
149
+ time: '19:00',
150
+ ampm: 'PM'
151
+ });
152
+ });
153
+ it('parses 0700 as 07:00 AM in 12h mode', ()=>{
154
+ const onChange = jest.fn();
155
+ const { getByTestId } = render(/*#__PURE__*/ React.createElement(TimepickerInput, {
156
+ disabled: false,
157
+ uses12hClock: true,
158
+ time: "12:00",
159
+ ampm: "AM",
160
+ onChange: onChange
161
+ }));
162
+ userEvent.clear(getByTestId('time-input'));
163
+ userEvent.type(getByTestId('time-input'), '0700');
164
+ userEvent.tab();
165
+ expect(onChange).toHaveBeenCalledWith({
166
+ time: '07:00',
167
+ ampm: 'AM'
168
+ });
169
+ });
170
+ });
118
171
  describe('onChange on blur — 12h mode', ()=>{
119
172
  it('emits 07:00 AM correctly in 12h mode', ()=>{
120
173
  const onChange = jest.fn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-date",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "registry": "https://npm.pkg.github.com/"
59
59
  },
60
- "gitHead": "011bb99013e7bb1c58fbc5f870b81bd3aba38b95"
60
+ "gitHead": "6be30c89c3f4f1681732bf59f01b6b823850f58a"
61
61
  }