@telus-uds/components-web 2.8.0 → 2.8.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/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Wed, 14 Jun 2023 00:01:25 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 14 Jun 2023 19:30:33 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.8.1
8
+
9
+ Wed, 14 Jun 2023 19:30:33 GMT
10
+
11
+ ### Patches
12
+
13
+ - datepicker prop bug fix (srikanthkhari@gmail.com)
14
+
7
15
  ## 2.8.0
8
16
 
9
- Wed, 14 Jun 2023 00:01:25 GMT
17
+ Wed, 14 Jun 2023 00:06:30 GMT
10
18
 
11
19
  ### Minor changes
12
20
 
@@ -127,9 +127,9 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
127
127
  validation,
128
128
  ...rest
129
129
  } = _ref;
130
- const [inputDate, setInputDate] = (0, _react.useState)(date);
130
+ const [inputDate, setInputDate] = (0, _react.useState)(date instanceof _moment.default ? date : undefined);
131
+ const [inputText, setInputText] = (0, _react.useState)(date instanceof _moment.default ? date.format(dateFormat) : '');
131
132
  const [isFocused, setIsFocused] = (0, _react.useState)(false);
132
- const [inputText, setInputText] = (0, _react.useState)((0, _moment.default)(date, dateFormat, true).isValid() ? date : '');
133
133
  const [isClickedInside, setIsClickedInside] = (0, _react.useState)(false);
134
134
  const getCopy = (0, _componentsBase.useCopy)({
135
135
  dictionary: _dictionary.default,
@@ -180,7 +180,6 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
180
180
  const viewport = (0, _componentsBase.useViewport)();
181
181
  const daySize = getResponsiveDaySize(inline, viewport);
182
182
  const circleSize = getResponsiveCircleSize(inline, viewport);
183
- const value = date ?? inputDate;
184
183
 
185
184
  const HiddenInputFieldContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
186
185
  displayName: "DatePicker__HiddenInputFieldContainer",
@@ -259,11 +258,11 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
259
258
  ref: ref,
260
259
  id: id,
261
260
  type: "text",
262
- value: (value === null || value === void 0 ? void 0 : value.format('DD/MM/YYYY')) ?? '',
261
+ value: inputText,
263
262
  readOnly: true
264
263
  })
265
264
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DayPickerSingleDateController.default, {
266
- date: value,
265
+ date: inputDate,
267
266
  onDateChange: onChange,
268
267
  focused: isFocused,
269
268
  onFocusChange: onFocusChange,
@@ -304,7 +303,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
304
303
  value: inputText,
305
304
  validation: validation,
306
305
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SingleDatePicker.default, {
307
- date: value,
306
+ date: inputDate,
308
307
  onDateChange: onChange,
309
308
  focused: isFocused,
310
309
  onFocusChange: onFocusChange,
@@ -101,9 +101,9 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
101
101
  validation,
102
102
  ...rest
103
103
  } = _ref;
104
- const [inputDate, setInputDate] = useState(date);
104
+ const [inputDate, setInputDate] = useState(date instanceof moment ? date : undefined);
105
+ const [inputText, setInputText] = useState(date instanceof moment ? date.format(dateFormat) : '');
105
106
  const [isFocused, setIsFocused] = useState(false);
106
- const [inputText, setInputText] = useState(moment(date, dateFormat, true).isValid() ? date : '');
107
107
  const [isClickedInside, setIsClickedInside] = useState(false);
108
108
  const getCopy = useCopy({
109
109
  dictionary,
@@ -154,7 +154,6 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
154
154
  const viewport = useViewport();
155
155
  const daySize = getResponsiveDaySize(inline, viewport);
156
156
  const circleSize = getResponsiveCircleSize(inline, viewport);
157
- const value = date ?? inputDate;
158
157
  const HiddenInputFieldContainer = /*#__PURE__*/styled.div.withConfig({
159
158
  displayName: "DatePicker__HiddenInputFieldContainer",
160
159
  componentId: "components-web__sc-mz8fi3-2"
@@ -231,11 +230,11 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
231
230
  ref: ref,
232
231
  id: id,
233
232
  type: "text",
234
- value: (value === null || value === void 0 ? void 0 : value.format('DD/MM/YYYY')) ?? '',
233
+ value: inputText,
235
234
  readOnly: true
236
235
  })
237
236
  }), /*#__PURE__*/_jsx(DayPickerSingleDateController, {
238
- date: value,
237
+ date: inputDate,
239
238
  onDateChange: onChange,
240
239
  focused: isFocused,
241
240
  onFocusChange: onFocusChange,
@@ -276,7 +275,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
276
275
  value: inputText,
277
276
  validation: validation,
278
277
  children: /*#__PURE__*/_jsx(SingleDatePicker, {
279
- date: value,
278
+ date: inputDate,
280
279
  onDateChange: onChange,
281
280
  focused: isFocused,
282
281
  onFocusChange: onFocusChange,
package/package.json CHANGED
@@ -63,5 +63,5 @@
63
63
  "skip": true
64
64
  },
65
65
  "types": "types/index.d.ts",
66
- "version": "2.8.0"
66
+ "version": "2.8.1"
67
67
  }
@@ -95,9 +95,12 @@ const DatePicker = forwardRef(
95
95
  },
96
96
  ref
97
97
  ) => {
98
- const [inputDate, setInputDate] = useState(date)
98
+ const [inputDate, setInputDate] = useState(date instanceof moment ? date : undefined)
99
+ const [inputText, setInputText] = useState(
100
+ date instanceof moment ? date.format(dateFormat) : ''
101
+ )
102
+
99
103
  const [isFocused, setIsFocused] = useState(false)
100
- const [inputText, setInputText] = useState(moment(date, dateFormat, true).isValid() ? date : '')
101
104
  const [isClickedInside, setIsClickedInside] = useState(false)
102
105
  const getCopy = useCopy({ dictionary, copy })
103
106
  const onFocusChange = ({ focused }) => {
@@ -135,7 +138,6 @@ const DatePicker = forwardRef(
135
138
  const daySize = getResponsiveDaySize(inline, viewport)
136
139
  const circleSize = getResponsiveCircleSize(inline, viewport)
137
140
 
138
- const value = date ?? inputDate
139
141
  const HiddenInputFieldContainer = styled.div`
140
142
  height: ${(props) => props.height};
141
143
  width: ${(props) => props.width};
@@ -202,16 +204,10 @@ const DatePicker = forwardRef(
202
204
  height={hiddenInputFieldContainerHeight}
203
205
  width={hiddenInputFieldContainerWidth}
204
206
  >
205
- <input
206
- ref={ref}
207
- id={id}
208
- type="text"
209
- value={value?.format('DD/MM/YYYY') ?? ''}
210
- readOnly
211
- />
207
+ <input ref={ref} id={id} type="text" value={inputText} readOnly />
212
208
  </HiddenInputFieldContainer>
213
209
  <DayPickerSingleDateController
214
- date={value}
210
+ date={inputDate}
215
211
  onDateChange={onChange}
216
212
  focused={isFocused}
217
213
  onFocusChange={onFocusChange}
@@ -253,7 +249,7 @@ const DatePicker = forwardRef(
253
249
  validation={validation}
254
250
  >
255
251
  <SingleDatePicker
256
- date={value}
252
+ date={inputDate}
257
253
  onDateChange={onChange}
258
254
  focused={isFocused}
259
255
  onFocusChange={onFocusChange}