!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/wincloud_gateway/node_modules/@buffetjs/core/src/components/DatePicker/   drwxr-xr-x
Free 13.02 GB of 57.97 GB (22.46%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     index.js (4.55 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/**
 *
 * Datepicker
 *
 */

import React, { useEffect, useReducer } from 'react';
import PropTypes from 'prop-types';

import moment from 'moment';
import momentPropTypes from 'react-moment-proptypes';
import 'react-dates/initialize';
import { DayPickerSingleDateController } from 'react-dates';
import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { DatePicker as StyledDatepicker } from '@buffetjs/styles';

import reducer, { initialState } from './reducer';

import Input from '../InputText';

function Datepicker({
  className,
  value,
  withDefaultValue,
  disabled,
  displayFormat,
  id,
  name,
  onChange,
  readOnly,
  tabIndex,
  wait,
}) {
  const [state, dispatch] = useReducer(reducer, initialState);

  useEffect(() => {
    let date = null;
    let displayedDate = '';

    if (withDefaultValue && !value) {
      date = moment();
      displayedDate = date.format('MM/DD/YYYY');
    }

    if (!!value && moment(value).isValid()) {
      date = value._isAMomentObject === true ? value : moment(value);
      displayedDate = date.format('MM/DD/YYYY');
    }

    dispatch({
      type: 'SET_DATE',
      date,
    });

    dispatch({
      type: 'SET_DISPLAYED_DATE',
      displayedDate,
    });
  }, [value, withDefaultValue]);

  let timer = null;
  const { date, displayedDate, isFocused, isVisible } = state;

  const getDateValue = () => {
    let dateValue = date ? date.format(displayFormat) : '';

    if (isVisible) {
      dateValue = displayedDate;
    }

    return dateValue;
  };

  const handleChange = ({ target }) => {
    clearTimeout(timer);

    dispatch({
      type: 'SET_IS_FOCUSED',
      isFocused: false,
    });

    dispatch({
      type: 'SET_DISPLAYED_DATE',
      displayedDate: target.value,
    });

    timer = setTimeout(() => {
      // Clearing the input
      if (!target.value) {
        onChange({ target: { name, type: 'date', value: null } });

        dispatch({
          type: 'SET_DATE',
          date: null,
        });

        dispatch({
          type: 'SET_DISPLAYED_DATE',
          displayedDate: '',
        });

        return;
      }

      handleDateChange(moment(target.value, 'MM/DD/YYYY'));
    }, wait);
  };

  const handleDateChange = dateValue => {
    if (moment(dateValue).isValid()) {
      onChange({ target: { name, type: 'date', value: dateValue } });

      dispatch({
        type: 'SET_DATE',
        date: dateValue,
      });

      dispatch({
        type: 'SET_DISPLAYED_DATE',
        displayedDate: dateValue.format('MM/DD/YYYY'),
      });
    }
  };

  const handleDateClick = dateValue => {
    handleDateChange(dateValue);

    toggleDatepicker(false);
  };

  const handleTabClick = ({ keyCode, which }) => {
    const code = keyCode || which;

    if (code === 9) {
      toggleDatepicker(false);
    }
  };

  const toggleDatepicker = shown => {
    dispatch({
      type: 'SET_IS_VISIBLE',
      isVisible: shown,
    });

    dispatch({
      type: 'SET_IS_FOCUSED',
      isFocused: shown,
    });
  };

  return (
    <StyledDatepicker isOpen={isVisible} className={className}>
      <div>
        <Input
          disabled={disabled}
          type="text"
          name="start_date"
          id={id || name}
          value={getDateValue()}
          readOnly={readOnly}
          onChange={handleChange}
          icon={<FontAwesomeIcon icon={faCalendarAlt} />}
          onFocus={() => toggleDatepicker(true)}
          onClick={() => toggleDatepicker(true)}
          onKeyDown={handleTabClick}
          tabIndex={tabIndex}
        />
      </div>
      {isFocused && (
        <DayPickerSingleDateController
          date={date}
          focused
          numberOfMonths={1}
          onDateChange={handleDateClick}
          onOutsideClick={() => toggleDatepicker(false)}
          daySize={37}
          transitionDuration={0}
        />
      )}
    </StyledDatepicker>
  );
}

Datepicker.defaultProps = {
  className: null,
  disabled: false,
  displayFormat: 'MMMM DD, YYYY',
  id: 'date',
  onChange: () => {},
  readOnly: false,
  tabIndex: '0',
  value: null,
  wait: 600,
  withDefaultValue: false,
};

Datepicker.propTypes = {
  className: PropTypes.string,
  disabled: PropTypes.bool,
  displayFormat: PropTypes.string,
  id: PropTypes.string,
  name: PropTypes.string.isRequired,
  onChange: PropTypes.func,
  readOnly: PropTypes.bool,
  tabIndex: PropTypes.string,
  value: PropTypes.oneOfType([momentPropTypes.momentObj, PropTypes.string]),
  wait: PropTypes.number,
  withDefaultValue: PropTypes.bool,
};

export default Datepicker;

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0185 ]--