react-samay
Advanced tools
Comparing version
@@ -9,5 +9,2 @@ var $83Duu$reactjsxruntime = require("react/jsx-runtime"); | ||
function $parcel$defineInteropFlag(a) { | ||
Object.defineProperty(a, '__esModule', {value: true, configurable: true}); | ||
} | ||
function $parcel$export(e, n, v, s) { | ||
@@ -20,5 +17,4 @@ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); | ||
$parcel$defineInteropFlag(module.exports); | ||
$parcel$export(module.exports, "TimePicker", () => $c16740f6382790a5$export$2e2bcd8739ae039); | ||
$parcel$export(module.exports, "default", () => $c16740f6382790a5$export$2e2bcd8739ae039); | ||
@@ -30,3 +26,2 @@ | ||
function $69e6bb98e7bc51ac$export$8793edee2d425525() { | ||
@@ -163,7 +158,8 @@ /* empty noop function */ } | ||
getInput() { | ||
const { name: name , prefixCls: prefixCls , disabled: disabled , placeholder: placeholder , inputReadOnly: inputReadOnly , onKeyDown: onKeyDown } = this.props; | ||
const { name: name , prefixCls: prefixCls , inputClassName: inputClassName , disabled: disabled , placeholder: placeholder , inputReadOnly: inputReadOnly , onKeyDown: onKeyDown , } = this.props; | ||
const { invalid: invalid , str: str } = this.state; | ||
const invalidClass = invalid ? `${prefixCls}-input-invalid` : ""; | ||
return /*#__PURE__*/ (0, $83Duu$reactjsxruntime.jsx)("input", { | ||
className: (0, ($parcel$interopDefault($83Duu$classnames)))(`${prefixCls}-input`, invalidClass), | ||
className: (0, ($parcel$interopDefault($83Duu$classnames)))(`${prefixCls}-input`, inputClassName, { | ||
[`${prefixCls}-input-invalid`]: invalid | ||
}), | ||
ref: this.refInput, | ||
@@ -364,3 +360,3 @@ onKeyDown: onKeyDown, | ||
width: 100%; | ||
background-color: inherit; | ||
background-color: white; | ||
`; | ||
@@ -605,3 +601,3 @@ class $6d6dfe87a472df4a$var$Combobox extends (0, $83Duu$react.Component) { | ||
render() { | ||
const { name: name , prefixCls: prefixCls , className: className , placeholder: placeholder , disabled: disabled , disabledMinutes: disabledMinutes , disabledSeconds: disabledSeconds , hideDisabledOptions: hideDisabledOptions , showHour: showHour , showMinute: showMinute , showSecond: showSecond , format: format , defaultOpenValue: defaultOpenValue , closePanel: closePanel , use12Hours: use12Hours , onKeyDown: onKeyDown , hourStep: hourStep , minuteStep: minuteStep , secondStep: secondStep , inputReadOnly: inputReadOnly , } = this.props; | ||
const { name: name , prefixCls: prefixCls , className: className , inputClassName: inputClassName , placeholder: placeholder , disabled: disabled , disabledMinutes: disabledMinutes , disabledSeconds: disabledSeconds , hideDisabledOptions: hideDisabledOptions , showHour: showHour , showMinute: showMinute , showSecond: showSecond , format: format , defaultOpenValue: defaultOpenValue , closePanel: closePanel , use12Hours: use12Hours , onKeyDown: onKeyDown , hourStep: hourStep , minuteStep: minuteStep , secondStep: secondStep , inputReadOnly: inputReadOnly , } = this.props; | ||
const { value: value } = this.state; | ||
@@ -628,2 +624,3 @@ const disabledHourOptions = this.disabledHours(); | ||
prefixCls: prefixCls, | ||
inputClassName: inputClassName, | ||
defaultOpenValue: validDefaultOpenValue, | ||
@@ -684,4 +681,5 @@ value: value, | ||
popupClassName: "", | ||
inputClassName: "", | ||
defaultOpenValue: new Date(), | ||
allowEmpty: true, | ||
use12Hours: false, | ||
showHour: true, | ||
@@ -700,5 +698,4 @@ showMinute: true, | ||
onBlur: (0, $69e6bb98e7bc51ac$export$8793edee2d425525), | ||
use12Hours: false, | ||
onKeyDown: (0, $69e6bb98e7bc51ac$export$8793edee2d425525), | ||
ariaLabelFunc: ()=>"react-samay-input-time" | ||
getAriaLabel: ()=>"react-samay-input-time" | ||
}; | ||
@@ -779,32 +776,2 @@ constructor(props){ | ||
} | ||
getPanelElement() { | ||
const { name: name , className: className , prefixCls: prefixCls , placeholder: placeholder , disabledHours: disabledHours , disabledMinutes: disabledMinutes , disabledSeconds: disabledSeconds , hideDisabledOptions: hideDisabledOptions , inputReadOnly: inputReadOnly , disabled: disabled , showHour: showHour , showMinute: showMinute , showSecond: showSecond , defaultOpenValue: defaultOpenValue , use12Hours: use12Hours , onKeyDown: onKeyDown , hourStep: hourStep , minuteStep: minuteStep , secondStep: secondStep , } = this.props; | ||
return /*#__PURE__*/ (0, $83Duu$reactjsxruntime.jsx)((0, $e4ec07a709221854$export$2e2bcd8739ae039), { | ||
name: name, | ||
className: className, | ||
prefixCls: `${prefixCls}-panel`, | ||
ref: this.savePanelRef, | ||
value: this.state.value, | ||
inputReadOnly: inputReadOnly, | ||
disabled: disabled, | ||
onChange: this.onPanelChange, | ||
onAmPmChange: this.onAmPmChange, | ||
defaultOpenValue: defaultOpenValue, | ||
showHour: showHour, | ||
showMinute: showMinute, | ||
showSecond: showSecond, | ||
closePanel: this.closePanel, | ||
format: this.getFormat(), | ||
placeholder: placeholder, | ||
disabledHours: disabledHours, | ||
disabledMinutes: disabledMinutes, | ||
disabledSeconds: disabledSeconds, | ||
hideDisabledOptions: hideDisabledOptions, | ||
use12Hours: use12Hours, | ||
hourStep: hourStep, | ||
minuteStep: minuteStep, | ||
secondStep: secondStep, | ||
onKeyDown: onKeyDown | ||
}); | ||
} | ||
setOpen(open) { | ||
@@ -830,3 +797,3 @@ const { onOpen: onOpen , onClose: onClose } = this.props; | ||
render() { | ||
const { prefixCls: prefixCls , id: id , name: name , disabled: disabled , placeholder: placeholder , use12Hours: use12Hours , inputReadOnly: inputReadOnly , className: className , ariaLabelFunc: ariaLabelFunc , onFocus: onFocus , onBlur: onBlur , style: style , } = this.props; | ||
const { prefixCls: prefixCls , id: id , name: name , disabled: disabled , placeholder: placeholder , className: className , inputClassName: inputClassName , getAriaLabel: getAriaLabel , onFocus: onFocus , onBlur: onBlur , style: style , disabledHours: disabledHours , disabledMinutes: disabledMinutes , disabledSeconds: disabledSeconds , hideDisabledOptions: hideDisabledOptions , inputReadOnly: inputReadOnly , showHour: showHour , showMinute: showMinute , showSecond: showSecond , defaultOpenValue: defaultOpenValue , use12Hours: use12Hours , onKeyDown: onKeyDown , hourStep: hourStep , minuteStep: minuteStep , secondStep: secondStep , } = this.props; | ||
const { open: open , value: value } = this.state; | ||
@@ -838,6 +805,33 @@ const strValue = value && (0, $83Duu$datefns.format)(value, this.getFormat(use12Hours)) || ""; | ||
className: (0, ($parcel$interopDefault($83Duu$classnames)))(`${prefixCls}-wrapper`, className), | ||
children: open ? this.getPanelElement() : /*#__PURE__*/ (0, $83Duu$reactjsxruntime.jsx)("input", { | ||
children: open ? /*#__PURE__*/ (0, $83Duu$reactjsxruntime.jsx)((0, $e4ec07a709221854$export$2e2bcd8739ae039), { | ||
name: name, | ||
className: className, | ||
inputClassName: inputClassName, | ||
prefixCls: `${prefixCls}-panel`, | ||
ref: this.savePanelRef, | ||
value: this.state.value, | ||
inputReadOnly: inputReadOnly, | ||
disabled: disabled, | ||
onChange: this.onPanelChange, | ||
onAmPmChange: this.onAmPmChange, | ||
defaultOpenValue: defaultOpenValue, | ||
showHour: showHour, | ||
showMinute: showMinute, | ||
showSecond: showSecond, | ||
closePanel: this.closePanel, | ||
format: this.getFormat(), | ||
placeholder: placeholder, | ||
disabledHours: disabledHours, | ||
disabledMinutes: disabledMinutes, | ||
disabledSeconds: disabledSeconds, | ||
hideDisabledOptions: hideDisabledOptions, | ||
use12Hours: use12Hours, | ||
hourStep: hourStep, | ||
minuteStep: minuteStep, | ||
secondStep: secondStep, | ||
onKeyDown: onKeyDown | ||
}) : /*#__PURE__*/ (0, $83Duu$reactjsxruntime.jsx)("input", { | ||
type: "text", | ||
name: name, | ||
className: `${prefixCls}-input`, | ||
className: (0, ($parcel$interopDefault($83Duu$classnames)))(`${prefixCls}-input`, inputClassName), | ||
ref: this.saveInputRef, | ||
@@ -847,3 +841,3 @@ placeholder: placeholder, | ||
readOnly: !!inputReadOnly, | ||
"aria-label": ariaLabelFunc(strValue), | ||
"aria-label": getAriaLabel(strValue), | ||
defaultValue: strValue, | ||
@@ -850,0 +844,0 @@ onFocus: onFocus, |
{ | ||
"name": "react-samay", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Time picker for React.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/sushantdhiman/react-samay", |
# React Samay | ||
 | ||
[](https://npmjs.com/package/react-samay) | ||
Time picker library for React.js | ||
Time picker for React.js | ||
> This is mainly a fork from [rc-time-picker](https://github.com/react-component/time-picker/), | ||
> This is a fork from [rc-time-picker](https://github.com/react-component/time-picker/), | ||
> which is no longer maintained. I have also mixed styling | ||
@@ -37,6 +37,6 @@ > support from [time-picker-io](https://github.com/codercodingthecode/time-picker-io). | ||
```js | ||
import TimePicker from 'react-samay'; | ||
import { TimePicker } from 'react-samay'; | ||
import ReactDOM from 'react-dom'; | ||
ReactDOM.render(<TimePicker />, container); | ||
ReactDOM.render(<TimePicker />, <div id="app" />); | ||
``` | ||
@@ -43,0 +43,0 @@ |
import React, { Component, KeyboardEvent } from "react"; | ||
type Props = { | ||
prefixCls: string; | ||
value: Date; | ||
className: string; | ||
defaultOpen: boolean; | ||
defaultOpenValue: Date; | ||
inputReadOnly: boolean; | ||
allowEmpty: boolean; | ||
defaultValue: Date; | ||
open: boolean; | ||
id: string; | ||
disabled?: boolean; | ||
defaultOpen: boolean; | ||
placeholder: string; | ||
format: string; | ||
showHour: boolean; | ||
showMinute: boolean; | ||
showSecond: boolean; | ||
className: string; | ||
popupClassName: string; | ||
disabledHours: () => number[]; | ||
disabledMinutes: (hour: number | null) => number[]; | ||
disabledSeconds: (hour: number | null, minute: number | null) => number[]; | ||
format: string; | ||
getAriaLabel: (value: string) => string; | ||
hideDisabledOptions: boolean; | ||
hourStep: number; | ||
id: string; | ||
inputClassName: string; | ||
inputReadOnly: boolean; | ||
minuteStep: number; | ||
name: string; | ||
onAmPmChange: (ampm: string) => void; | ||
onBlur: () => void; | ||
onChange: (value: Date) => void; | ||
onAmPmChange: (ampm: string) => void; | ||
onOpen: (value: { | ||
open: true; | ||
}) => void; | ||
onClose: (value: { | ||
@@ -33,14 +27,20 @@ open: false; | ||
onFocus: () => void; | ||
onBlur: () => void; | ||
name: string; | ||
use12Hours: boolean; | ||
hourStep: number; | ||
minuteStep: number; | ||
onKeyDown: () => void; | ||
onOpen: (value: { | ||
open: true; | ||
}) => void; | ||
open: boolean; | ||
placeholder: string; | ||
popupClassName: string; | ||
prefixCls: string; | ||
secondStep: number; | ||
onKeyDown: () => void; | ||
ariaLabelFunc: (value: string) => string; | ||
showHour: boolean; | ||
showMinute: boolean; | ||
showSecond: boolean; | ||
style: React.CSSProperties; | ||
use12Hours: boolean; | ||
value: Date; | ||
}; | ||
type PickerProps = typeof Picker.defaultProps & Props; | ||
export default class Picker extends Component<PickerProps, { | ||
export class TimePicker extends Component<PickerProps, { | ||
value: Date; | ||
@@ -60,3 +60,2 @@ open: boolean; | ||
getFormat(includeAMPM?: boolean): string; | ||
getPanelElement(): JSX.Element; | ||
setOpen(open: boolean): void; | ||
@@ -63,0 +62,0 @@ focus(): void; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111680
0.12%1105
-0.18%