@ballistix.digital/react-components 9.12.2-rc-426.0 → 9.12.2

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/dist/index.js CHANGED
@@ -5619,11 +5619,8 @@ var $c1ef7dd4f2207e4b$export$2e2bcd8739ae039 = $c1ef7dd4f2207e4b$var$styles;
5619
5619
 
5620
5620
 
5621
5621
  const $4013d091ad44178a$var$DateRangeMenu = (props)=>{
5622
- const { name: name = 'date-menu-form', size: size = 'compact', label: label, i18n: i18n = 'en', description: description, hint: hint, placeholder: placeholder, separator: separator, startFrom: startFrom, displayFormat: displayFormat = 'DD.MM.YYYY', direction: direction = 'down', minDate: minDate, maxDate: maxDate, startWeekOn: startWeekOn = 'mon', icon: icon = (isEmpty)=>isEmpty ? (0, $iA2ta$reactjsxruntime.jsx)((0, $cbf4b156892acb71$export$2e2bcd8739ae039), {
5622
+ const { name: name = 'date-menu-form', size: size = 'compact', label: label, i18n: i18n = 'en', description: description, hint: hint, placeholder: placeholder, separator: separator, startFrom: startFrom, displayFormat: displayFormat = 'DD.MM.YYYY', direction: direction = 'down', minDate: minDate, maxDate: maxDate, startWeekOn: startWeekOn = 'mon', icon: icon = ()=>(0, $iA2ta$reactjsxruntime.jsx)((0, $cbf4b156892acb71$export$2e2bcd8739ae039), {
5623
5623
  accessor: "calendar"
5624
- }) : (0, $iA2ta$reactjsxruntime.jsx)((0, $cbf4b156892acb71$export$2e2bcd8739ae039), {
5625
- accessor: "xmark",
5626
- className: "text-black"
5627
5624
  }), required: required, value: defaultValue, error: error, type: type = 'normal', isRequired: isRequired = false, isTouched: isTouched = false, isDisabled: isDisabled, isSolo: isSolo = false, isRanged: isRanged = true, onChange: onChange, onClear: onClear, onBlur: onBlur, onClick: onClick, styles: stylesOverrides } = props;
5628
5625
  const isValid = error === undefined;
5629
5626
  const [state, setState] = (0, $iA2ta$react.useState)(defaultValue ?? {
@@ -5644,6 +5641,16 @@ const $4013d091ad44178a$var$DateRangeMenu = (props)=>{
5644
5641
  onChange,
5645
5642
  onClear
5646
5643
  ]);
5644
+ const hasValue = Boolean(state?.startDate || state?.endDate);
5645
+ const handleClear = (0, $iA2ta$react.useCallback)((event)=>{
5646
+ event.stopPropagation();
5647
+ handleValueChange({
5648
+ startDate: null,
5649
+ endDate: null
5650
+ });
5651
+ }, [
5652
+ handleValueChange
5653
+ ]);
5647
5654
  const handleGenerateStyle = ()=>{
5648
5655
  const result = (0, $f0c671820c340322$export$e2d2075c69d9100d)((0, $c1ef7dd4f2207e4b$export$2e2bcd8739ae039).base);
5649
5656
  const keys = (0, $iA2ta$lodash.concat)((0, $27f90b0cff19565d$export$be5d6ab3c5b84767)((0, $c1ef7dd4f2207e4b$export$2e2bcd8739ae039).base), (0, $27f90b0cff19565d$export$be5d6ab3c5b84767)((0, $3369f7d596d23d58$export$2e2bcd8739ae039).base), (0, $27f90b0cff19565d$export$be5d6ab3c5b84767)((0, $65bb4d593718fcda$export$2e2bcd8739ae039).base));
@@ -5668,6 +5675,16 @@ const $4013d091ad44178a$var$DateRangeMenu = (props)=>{
5668
5675
  const allowedCharacters = '0123456789';
5669
5676
  const separators = `./-${separator}`;
5670
5677
  const callback = (event)=>{
5678
+ if (event.key === 'Backspace' || event.key === 'Delete') {
5679
+ const hadValue = Boolean(input && input.value.length > 0);
5680
+ setTimeout(()=>{
5681
+ if (hadValue && input && input.value.length === 0) handleValueChange({
5682
+ startDate: null,
5683
+ endDate: null
5684
+ });
5685
+ }, 0);
5686
+ return;
5687
+ }
5671
5688
  if (input?.value === null || input?.value === undefined || (0, $iA2ta$lodash.intersection)(input.value.split(''), separators.split('')).length > 0 || isRanged) return;
5672
5689
  if (allowedCharacters.includes(event.key) && input?.value.length >= 7) {
5673
5690
  const newValue = input.value + event.key;
@@ -5685,7 +5702,9 @@ const $4013d091ad44178a$var$DateRangeMenu = (props)=>{
5685
5702
  }
5686
5703
  };
5687
5704
  if (input) input.addEventListener('keydown', callback);
5688
- return ()=>removeEventListener('keydown', callback);
5705
+ return ()=>{
5706
+ if (input) input.removeEventListener('keydown', callback);
5707
+ };
5689
5708
  }, [
5690
5709
  handleValueChange,
5691
5710
  isRanged,
@@ -5709,28 +5728,42 @@ const $4013d091ad44178a$var$DateRangeMenu = (props)=>{
5709
5728
  ref: $datepickerInputRef,
5710
5729
  onClick: onClick,
5711
5730
  children: [
5712
- (0, $iA2ta$reactjsxruntime.jsx)((0, ($parcel$interopDefault($iA2ta$ballistixdigitalreacttailwindcssdatepicker))), {
5713
- inputName: name,
5714
- inputId: name,
5715
- i18n: i18n,
5716
- useRange: size === 'expanded',
5717
- placeholder: placeholder,
5718
- asSingle: !isRanged,
5719
- separator: separator,
5720
- startFrom: startFrom,
5721
- displayFormat: displayFormat,
5722
- disabled: isDisabled,
5723
- popoverDirection: direction,
5724
- minDate: minDate,
5725
- maxDate: maxDate,
5726
- toggleIcon: icon,
5727
- //
5728
- value: state,
5729
- //
5730
- onChange: handleValueChange,
5731
- //
5732
- inputClassName: styles.input,
5733
- startWeekOn: startWeekOn
5731
+ (0, $iA2ta$reactjsxruntime.jsxs)("div", {
5732
+ className: "relative",
5733
+ children: [
5734
+ (0, $iA2ta$reactjsxruntime.jsx)((0, ($parcel$interopDefault($iA2ta$ballistixdigitalreacttailwindcssdatepicker))), {
5735
+ inputName: name,
5736
+ inputId: name,
5737
+ i18n: i18n,
5738
+ useRange: size === 'expanded',
5739
+ placeholder: placeholder,
5740
+ asSingle: !isRanged,
5741
+ separator: separator,
5742
+ startFrom: startFrom,
5743
+ displayFormat: displayFormat,
5744
+ disabled: isDisabled,
5745
+ popoverDirection: direction,
5746
+ minDate: minDate,
5747
+ maxDate: maxDate,
5748
+ toggleIcon: icon,
5749
+ //
5750
+ value: state,
5751
+ //
5752
+ onChange: handleValueChange,
5753
+ //
5754
+ inputClassName: styles.input,
5755
+ startWeekOn: startWeekOn
5756
+ }),
5757
+ hasValue && !isDisabled && (0, $iA2ta$reactjsxruntime.jsx)("button", {
5758
+ type: "button",
5759
+ "aria-label": "Clear date",
5760
+ onClick: handleClear,
5761
+ className: "absolute inset-y-0 right-9 flex items-center px-2 text-gray-400 hover:text-gray-600 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-primary-500",
5762
+ children: (0, $iA2ta$reactjsxruntime.jsx)((0, $cbf4b156892acb71$export$2e2bcd8739ae039), {
5763
+ accessor: "xmark"
5764
+ })
5765
+ })
5766
+ ]
5734
5767
  }),
5735
5768
  (0, $iA2ta$reactjsxruntime.jsx)((0, $dfbd7d015eae4218$export$2e2bcd8739ae039), {
5736
5769
  isHidden: isSolo,