@onesy/ui-react 1.0.195 → 1.0.197

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.
@@ -143,19 +143,19 @@ const DatePicker = props__ => {
143
143
  ref,
144
144
  tonal,
145
145
  color = 'primary',
146
- version: version_ = 'auto',
146
+ version: versionProps = 'auto',
147
147
  size = 'regular',
148
- value: value_,
148
+ value: valueProps,
149
149
  valueDefault,
150
150
  onChange,
151
- calendar: calendar_,
151
+ calendar: calendarProps,
152
152
  calendarDefault,
153
153
  onChangeCalendar,
154
154
  range,
155
155
  now,
156
- static: static_,
156
+ static: staticProps,
157
157
  openMobile = 'select',
158
- placeholder: placeholder_,
158
+ placeholder: placeholderProps,
159
159
  calendars = props.range ? 2 : 1,
160
160
  min,
161
161
  max,
@@ -163,31 +163,31 @@ const DatePicker = props__ => {
163
163
  name,
164
164
  nameFrom,
165
165
  nameTo,
166
- label: label_,
167
- labelFrom: labelFrom_ = l('Date from'),
168
- labelTo: labelTo_ = l('Date to'),
166
+ label: labelProps,
167
+ labelFrom: labelFromProps = l('Date from'),
168
+ labelTo: labelToProps = l('Date to'),
169
169
  modeModalSubHeadingText = l('Select date'),
170
170
  modeModalSubHeadingTextRange = `${l('Date from')}${SEPARATOR}${l('Date to')}`,
171
171
  selectModeHeadingText = l('Select date'),
172
172
  inputModeHeadingText = l('Enter date'),
173
- useHelperText: useHelperText_,
173
+ useHelperText: useHelperTextProps,
174
174
  weekStartDay = 'Monday',
175
- switch: switch__,
175
+ switch: switchProps,
176
176
  fullScreen,
177
177
  today,
178
178
  clear = true,
179
- heading: heading_ = true,
180
- actions: actions_ = true,
179
+ heading: headingProps = true,
180
+ actions: actionsProps = true,
181
181
  fullWidth,
182
182
  readOnly,
183
183
  disabled,
184
- valid: valid_,
185
- onClick: onClick_,
186
- onClose: onClose_,
187
- onToday: onToday_,
188
- onClear: onClear_,
189
- onCancel: onCancel_,
190
- onOk: onOk_,
184
+ valid: validProps,
185
+ onClick: onClickProps,
186
+ onClose: onCloseProps,
187
+ onToday: onTodayProps,
188
+ onClear: onClearProps,
189
+ onCancel: onCancelProps,
190
+ onOk: onOkProps,
191
191
  Icon: Icon_ = _IconMaterialCalendarTodayW100Filled.default,
192
192
  IconEnter = _IconMaterialEditW.default,
193
193
  IconClose = _IconMaterialCloseW.default,
@@ -213,21 +213,21 @@ const DatePicker = props__ => {
213
213
  };
214
214
  const keys = _react.default.useMemo(() => {
215
215
  const result = [];
216
- const items = [switch__, useHelperText_];
216
+ const items = [switchProps, useHelperTextProps];
217
217
  items.forEach(item => {
218
218
  if ((0, _utils.is)('object', item)) Object.keys(item).filter(key => theme.breakpoints.media[key]).forEach(key_0 => result.push(key_0));
219
219
  });
220
220
  return (0, _utils.unique)(result);
221
- }, [switch__, useHelperText_]);
221
+ }, [switchProps, useHelperTextProps]);
222
222
  const breakpoints = {};
223
223
  keys.forEach(key_1 => {
224
224
  breakpoints[key_1] = (0, _useMediaQuery.default)(theme.breakpoints.media[key_1], {
225
225
  element: refs.root.current
226
226
  });
227
227
  });
228
- const label = name !== undefined ? name : label_;
229
- const switch_ = (0, _utils2.valueBreakpoints)(switch__, true, breakpoints, theme);
230
- const useHelperText = (0, _utils2.valueBreakpoints)(useHelperText_, undefined, breakpoints, theme);
228
+ const label = name !== undefined ? name : labelProps;
229
+ const switch_ = (0, _utils2.valueBreakpoints)(switchProps, true, breakpoints, theme);
230
+ const useHelperText = (0, _utils2.valueBreakpoints)(useHelperTextProps, undefined, breakpoints, theme);
231
231
  const touch = (0, _useMediaQuery.default)('(pointer: coarse)', {
232
232
  element: refs.root.current
233
233
  });
@@ -237,10 +237,10 @@ const DatePicker = props__ => {
237
237
  return sorted;
238
238
  };
239
239
  const [value, setValue] = _react.default.useState(() => {
240
- const valueResult = (valueDefault !== undefined ? valueDefault : value_) || now && (range ? [new _date.OnesyDate(), new _date.OnesyDate()] : [new _date.OnesyDate()]);
240
+ const valueResult = (valueDefault !== undefined ? valueDefault : valueProps) || now && (range ? [new _date.OnesyDate(), new _date.OnesyDate()] : [new _date.OnesyDate()]);
241
241
  return onResolveValue(valueResult);
242
242
  });
243
- const [calendar, setCalendar] = _react.default.useState((calendarDefault !== undefined ? calendarDefault : calendar_) || new _date.OnesyDate());
243
+ const [calendar, setCalendar] = _react.default.useState((calendarDefault !== undefined ? calendarDefault : calendarProps) || new _date.OnesyDate());
244
244
  const [open, setOpen] = _react.default.useState(false);
245
245
  const [mode, setMode] = _react.default.useState((touch ? openMobile : 'select') || 'select');
246
246
  const [error, setError] = _react.default.useState(false);
@@ -261,7 +261,7 @@ const DatePicker = props__ => {
261
261
  };
262
262
  const [input, setInput] = _react.default.useState(valueToInput());
263
263
  const [inputModal, setInputModal] = _react.default.useState(valueToInput());
264
- let version = version_;
264
+ let version = versionProps;
265
265
  if (version === 'auto') {
266
266
  if (touch) version = 'mobile';else version = 'desktop';
267
267
  }
@@ -294,21 +294,21 @@ const DatePicker = props__ => {
294
294
 
295
295
  // Value
296
296
  _react.default.useEffect(() => {
297
- if (value_ !== undefined && value_ !== value) onUpdateValue(value_);
298
- }, [value_]);
297
+ if (valueProps !== undefined && valueProps !== value) onUpdateValue(valueProps);
298
+ }, [valueProps]);
299
299
 
300
300
  // Calendar
301
301
  _react.default.useEffect(() => {
302
- if (calendar_ !== undefined && calendar_ !== calendar) setCalendar(calendar_);
303
- }, [calendar_]);
302
+ if (calendarProps !== undefined && calendarProps !== calendar) setCalendar(calendarProps);
303
+ }, [calendarProps]);
304
304
  const onUpdate = (valueNew_3, triggerOnChange = true) => {
305
305
  // Inner update
306
- if (!props.hasOwnProperty('value')) setValue(valueNew_3);
306
+ if (!props.hasOwnProperty('value') || !triggerOnChange) setValue(valueNew_3);
307
307
  if (triggerOnChange && (0, _utils.is)('function', onChange)) onChange(!range ? valueNew_3[0] : valueNew_3);
308
308
  };
309
309
  const onUpdateCalendar = (valueNew_4, triggerOnChange_0 = true) => {
310
310
  // Inner update
311
- if (!props.hasOwnProperty('calendar')) setCalendar(valueNew_4);
311
+ if (!props.hasOwnProperty('calendar') || !triggerOnChange_0) setCalendar(valueNew_4);
312
312
  if (triggerOnChange_0 && (0, _utils.is)('function', onChangeCalendar)) onChangeCalendar(valueNew_4);
313
313
  };
314
314
 
@@ -319,7 +319,7 @@ const DatePicker = props__ => {
319
319
  const onCalendarChange = valueNew__0 => {
320
320
  const valueNew_5 = onResolveValue(valueNew__0);
321
321
  if (valueNew_5 !== value) {
322
- (!actions_ ? onUpdate : setValue)(valueNew_5);
322
+ (!actionsProps ? onUpdate : setValue)(valueNew_5);
323
323
 
324
324
  // Update input modal
325
325
  setInputModal(valueToInput(valueNew_5));
@@ -342,7 +342,7 @@ const DatePicker = props__ => {
342
342
  };
343
343
  const onClose = event => {
344
344
  setOpen(false);
345
- if ((0, _utils.is)('function', onClose_)) onClose_(event);
345
+ if ((0, _utils.is)('function', onCloseProps)) onCloseProps(event);
346
346
  };
347
347
  const onReset = () => {
348
348
  var _valueNew_;
@@ -390,7 +390,7 @@ const DatePicker = props__ => {
390
390
  // Update input modal
391
391
  setInputModal(valueToInput(valueNew_9));
392
392
  onClose(event_0);
393
- if ((0, _utils.is)('function', onToday_)) onToday_(event_0);
393
+ if ((0, _utils.is)('function', onTodayProps)) onTodayProps(event_0);
394
394
  };
395
395
  const onClear = event_1 => {
396
396
  const dateNow_1 = new _date.OnesyDate();
@@ -408,7 +408,7 @@ const DatePicker = props__ => {
408
408
  // Update input modal
409
409
  setInputModal(valueToInput(valueNew_10));
410
410
  onClose(event_1);
411
- if ((0, _utils.is)('function', onClear_)) onClear_(event_1);
411
+ if ((0, _utils.is)('function', onClearProps)) onClearProps(event_1);
412
412
  };
413
413
  const onOk = event_2 => {
414
414
  // Error
@@ -423,15 +423,15 @@ const DatePicker = props__ => {
423
423
  // Update input modal
424
424
  setInputModal(valueToInput(value));
425
425
  onClose(event_2);
426
- if ((0, _utils.is)('function', onOk_)) onOk_(event_2);
426
+ if ((0, _utils.is)('function', onOkProps)) onOkProps(event_2);
427
427
  };
428
428
  const onCancel = event_3 => {
429
429
  onReset();
430
430
  onClose(event_3);
431
- if ((0, _utils.is)('function', onCancel_)) onCancel_(event_3);
431
+ if ((0, _utils.is)('function', onCancelProps)) onCancelProps(event_3);
432
432
  };
433
433
  const valid = (...args) => {
434
- if ((0, _utils.is)('function', valid_)) return valid_(...args);
434
+ if ((0, _utils.is)('function', validProps)) return validProps(...args);
435
435
  const onesyDate = args[0];
436
436
  if (min || max || validate) {
437
437
  let response = true;
@@ -513,7 +513,7 @@ const DatePicker = props__ => {
513
513
  mask.push(' ', SEPARATOR_SYMBOL, ' ', ...mask);
514
514
  placeholder += `${SEPARATOR}${placeholder}`;
515
515
  }
516
- placeholder = placeholder_ || placeholder;
516
+ placeholder = placeholderProps || placeholder;
517
517
  const buttonProps = _objectSpread({
518
518
  color: 'inherit',
519
519
  version: 'text',
@@ -602,7 +602,7 @@ const DatePicker = props__ => {
602
602
  gap: 0,
603
603
  direction: "column",
604
604
  className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('DatePicker', theme) && ['onesy-DatePicker-header'], classes.header, fullScreen && classes.header_fullScreen]),
605
- children: [actions_ && fullScreen && /*#__PURE__*/(0, _jsxRuntime.jsxs)(Line, {
605
+ children: [actionsProps && fullScreen && /*#__PURE__*/(0, _jsxRuntime.jsxs)(Line, {
606
606
  gap: 0,
607
607
  direction: "row",
608
608
  align: "center",
@@ -624,7 +624,7 @@ const DatePicker = props__ => {
624
624
  }, buttonProps), {}, {
625
625
  children: l('Save')
626
626
  }))]
627
- }), heading_ && /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, {
627
+ }), headingProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, {
628
628
  version: "l2",
629
629
  className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('DatePicker', theme) && ['onesy-DatePicker-subheading'], classes.subheading, fullScreen && classes.subheading_fullScreen]),
630
630
  children: !range ? modeModalSubHeadingText : modeModalSubHeadingTextRange
@@ -735,7 +735,7 @@ const DatePicker = props__ => {
735
735
  }), fullScreen && /*#__PURE__*/(0, _jsxRuntime.jsx)(Divider, {
736
736
  tonal: false,
737
737
  className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('DatePicker', theme) && ['onesy-DatePicker-divider'], classes.divider])
738
- }), actions_ && /*#__PURE__*/_react.default.cloneElement(actions, {
738
+ }), actionsProps && /*#__PURE__*/_react.default.cloneElement(actions, {
739
739
  style: {
740
740
  paddingTop: theme.methods.space.value(1, 'px')
741
741
  }
@@ -756,11 +756,11 @@ const DatePicker = props__ => {
756
756
  min: min,
757
757
  max: max,
758
758
  validate: validate,
759
- belowCalendars: actions_ ? actions : undefined
759
+ belowCalendars: actionsProps ? actions : undefined
760
760
  }, CalendarProps), CalendarPropsDesktop), {}, {
761
761
  className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('DatePicker', theme) && ['onesy-DatePicker-calendar', 'onesy-DatePicker-version-desktop'], CalendarProps === null || CalendarProps === void 0 ? void 0 : CalendarProps.className, CalendarPropsDesktop === null || CalendarPropsDesktop === void 0 ? void 0 : CalendarPropsDesktop.className, classes.calendar, classes.calendar_desktop])
762
762
  }));
763
- if (static_) {
763
+ if (staticProps) {
764
764
  if (version === 'mobile') return mobile;
765
765
  if (version === 'desktop') return desktop;
766
766
  }
@@ -77,14 +77,14 @@ const DateTimePicker = props__ => {
77
77
  ref,
78
78
  tonal,
79
79
  color = 'primary',
80
- version: version_ = 'auto',
81
- value: value_,
80
+ version: versionProps = 'auto',
81
+ value: valueProps,
82
82
  valueDefault,
83
83
  onChange,
84
84
  label,
85
85
  range,
86
86
  now,
87
- static: static_,
87
+ static: staticProps,
88
88
  min,
89
89
  max,
90
90
  validate,
@@ -93,7 +93,7 @@ const DateTimePicker = props__ => {
93
93
  headingTextTimeRange,
94
94
  headingTextDate,
95
95
  headingTextDateRange,
96
- useHelperText: useHelperText_,
96
+ useHelperText: useHelperTextProps,
97
97
  format = '12',
98
98
  hour = true,
99
99
  minute = true,
@@ -101,16 +101,16 @@ const DateTimePicker = props__ => {
101
101
  today,
102
102
  clear = true,
103
103
  size,
104
- placeholder: placeholder_,
104
+ placeholder: placeholderProps,
105
105
  fullWidth,
106
106
  readOnly,
107
107
  disabled,
108
- valid: valid_,
109
- onClose: onClose_,
110
- onToday: onToday_,
111
- onClear: onClear_,
112
- onCancel: onCancel_,
113
- onOk: onOk_,
108
+ valid: validProps,
109
+ onClose: onCloseProps,
110
+ onToday: onTodayProps,
111
+ onClear: onClearProps,
112
+ onCancel: onCancelProps,
113
+ onOk: onOkProps,
114
114
  Icon: Icon_ = _IconMaterialDateRangeW100Filled.default,
115
115
  IconDate = _IconMaterialCalendarTodayW100Filled.default,
116
116
  IconTime = _IconMaterialScheduleW.default,
@@ -124,7 +124,7 @@ const DateTimePicker = props__ => {
124
124
  ModeDesktopProps,
125
125
  ModeMobileProps,
126
126
  ButtonProps,
127
- PickerProps: PickerProps_,
127
+ PickerProps: PickerPropsProps,
128
128
  MiddleProps,
129
129
  MainProps,
130
130
  IconProps,
@@ -140,19 +140,19 @@ const DateTimePicker = props__ => {
140
140
  };
141
141
  const keys = _react.default.useMemo(() => {
142
142
  const result = [];
143
- const items = [useHelperText_];
143
+ const items = [useHelperTextProps];
144
144
  items.forEach(item => {
145
145
  if ((0, _utils.is)('object', item)) Object.keys(item).filter(key => theme.breakpoints.media[key]).forEach(key_0 => result.push(key_0));
146
146
  });
147
147
  return (0, _utils.unique)(result);
148
- }, [useHelperText_]);
148
+ }, [useHelperTextProps]);
149
149
  const breakpoints = {};
150
150
  keys.forEach(key_1 => {
151
151
  breakpoints[key_1] = (0, _useMediaQuery.default)(theme.breakpoints.media[key_1], {
152
152
  element: refs.root.current
153
153
  });
154
154
  });
155
- const useHelperText = (0, _utils2.valueBreakpoints)(useHelperText_, undefined, breakpoints, theme);
155
+ const useHelperText = (0, _utils2.valueBreakpoints)(useHelperTextProps, undefined, breakpoints, theme);
156
156
  const touch = (0, _useMediaQuery.default)('(pointer: coarse)', {
157
157
  element: refs.root.current
158
158
  });
@@ -162,7 +162,7 @@ const DateTimePicker = props__ => {
162
162
  return sorted;
163
163
  };
164
164
  const [value, setValue] = _react.default.useState(() => {
165
- const valueResult = (valueDefault !== undefined ? valueDefault : value_) || now && (range ? [new _date.OnesyDate(), new _date.OnesyDate()] : [new _date.OnesyDate()]);
165
+ const valueResult = (valueDefault !== undefined ? valueDefault : valueProps) || now && (range ? [new _date.OnesyDate(), new _date.OnesyDate()] : [new _date.OnesyDate()]);
166
166
  return onResolveValue(valueResult);
167
167
  });
168
168
  const [calendar, setCalendar] = _react.default.useState(value[0]);
@@ -194,7 +194,7 @@ const DateTimePicker = props__ => {
194
194
  return result_0;
195
195
  };
196
196
  const [input, setInput] = _react.default.useState(valueToInput());
197
- let version = version_;
197
+ let version = versionProps;
198
198
  if (version === 'auto') {
199
199
  if (touch) version = 'mobile';else version = 'desktop';
200
200
  }
@@ -218,11 +218,11 @@ const DateTimePicker = props__ => {
218
218
 
219
219
  // Value
220
220
  _react.default.useEffect(() => {
221
- if (value_ !== undefined && value_ !== value) onUpdateValue(value_);
222
- }, [value_]);
221
+ if (valueProps !== undefined && valueProps !== value) onUpdateValue(valueProps);
222
+ }, [valueProps]);
223
223
  const onUpdate = (valueNew_3, triggerOnChange = true) => {
224
224
  // Inner update
225
- if (!props.hasOwnProperty('value')) setValue(valueNew_3);
225
+ if (!props.hasOwnProperty('value') || !triggerOnChange) setValue(valueNew_3);
226
226
  if (triggerOnChange && (0, _utils.is)('function', onChange)) onChange(!range ? valueNew_3[0] : valueNew_3);
227
227
  };
228
228
  const onPickSwitch = () => {
@@ -327,7 +327,7 @@ const DateTimePicker = props__ => {
327
327
  // Update input
328
328
  setInput(valueToInput(valueNew_10));
329
329
  onClose(event);
330
- if ((0, _utils.is)('function', onToday_)) onToday_(event);
330
+ if ((0, _utils.is)('function', onTodayProps)) onTodayProps(event);
331
331
  };
332
332
  const onClear = event_0 => {
333
333
  const valueNew_11 = [];
@@ -338,7 +338,7 @@ const DateTimePicker = props__ => {
338
338
  // Update input
339
339
  setInput(valueToInput(valueNew_11));
340
340
  onClose(event_0);
341
- if ((0, _utils.is)('function', onClear_)) onClear_(event_0);
341
+ if ((0, _utils.is)('function', onClearProps)) onClearProps(event_0);
342
342
  };
343
343
  const onOk = event_1 => {
344
344
  // Error
@@ -350,22 +350,22 @@ const DateTimePicker = props__ => {
350
350
  // Update input
351
351
  setInput(valueToInput(value));
352
352
  onClose(event_1);
353
- if ((0, _utils.is)('function', onOk_)) onOk_(event_1);
353
+ if ((0, _utils.is)('function', onOkProps)) onOkProps(event_1);
354
354
  };
355
355
  const onCancel = event_2 => {
356
356
  onReset();
357
357
  onClose(event_2);
358
- if ((0, _utils.is)('function', onCancel_)) onCancel_(event_2);
358
+ if ((0, _utils.is)('function', onCancelProps)) onCancelProps(event_2);
359
359
  };
360
360
  const onOpen = () => {
361
361
  setOpen(previous_0 => !previous_0);
362
362
  };
363
363
  const onClose = event_3 => {
364
364
  setOpen(false);
365
- if ((0, _utils.is)('function', onClose_)) onClose_(event_3);
365
+ if ((0, _utils.is)('function', onCloseProps)) onCloseProps(event_3);
366
366
  };
367
367
  const valid = (...args) => {
368
- if ((0, _utils.is)('function', valid_)) return valid_(...args);
368
+ if ((0, _utils.is)('function', validProps)) return validProps(...args);
369
369
  const onesyDate_0 = args[0];
370
370
  if (min || max || validate) {
371
371
  let response = true;
@@ -505,7 +505,7 @@ const DateTimePicker = props__ => {
505
505
  }
506
506
  placeholder += `${_DatePicker2.SEPARATOR}${placeholder}`;
507
507
  }
508
- placeholder = placeholder_ || placeholder;
508
+ placeholder = placeholderProps || placeholder;
509
509
  const buttonProps = _objectSpread({
510
510
  tonal,
511
511
  color,
@@ -580,7 +580,7 @@ const DateTimePicker = props__ => {
580
580
  heading: false,
581
581
  readOnly,
582
582
  disabled
583
- }, PickerProps_), tab === 'date' && DatePickerProps), tab === 'time' && TimePickerProps);
583
+ }, PickerPropsProps), tab === 'date' && DatePickerProps), tab === 'time' && TimePickerProps);
584
584
  const element = /*#__PURE__*/(0, _jsxRuntime.jsxs)(Surface, {
585
585
  gap: 0,
586
586
  direction: "column",
@@ -623,7 +623,7 @@ const DateTimePicker = props__ => {
623
623
  if (version === 'mobile') {
624
624
  if (!(readOnly || disabled)) moreProps.onClick = onOpen;
625
625
  }
626
- if (static_) return element;
626
+ if (staticProps) return element;
627
627
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Line, _objectSpread(_objectSpread({
628
628
  gap: 0,
629
629
  direction: "column",