react-time-input-polyfill
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -327,2 +327,3 @@ import React from 'react' | ||
handleKeyDown(e) { | ||
this.props.onKeyDown && this.props.onKeyDown(e) | ||
if (!this.state.usePolyfill) return null | ||
@@ -329,0 +330,0 @@ const key = e.key |
{ | ||
"name": "react-time-input-polyfill", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A pre-built, plug-and-play, fully accessible React component that will produce an `input[type='time']` element with a built in polyfill for IE and Safari support.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,54 +7,2 @@ import React, { useState } from 'react' | ||
// import React, { useState } from 'react' | ||
// import TimeInputPolyfill from 'react-time-input-polyfill' | ||
const TimeInputExample = ({ label, currentValue, onInputChange }) => { | ||
return ( | ||
<label> | ||
<span>{label}</span> | ||
<TimeInput | ||
// set the value through props | ||
value={currentValue} | ||
// onChange will run every time the value is updated | ||
onChange={({ value, element }) => { | ||
console.log({ | ||
// The current value in 24 hour time format | ||
value, | ||
// The <input> HTML element | ||
element, | ||
}) | ||
// Export the new value to the parent component | ||
onInputChange(value) | ||
}} | ||
/> | ||
</label> | ||
) | ||
} | ||
////////////////////////////////////// | ||
const ExampleForm = () => { | ||
// Use state to keep track of the value | ||
const [inputValue, setInputValue] = useState('20:30') // default to 8:30 PM | ||
const onSubmit = e => { | ||
e.preventDefault() | ||
} | ||
return ( | ||
<form onSubmit={onSubmit}> | ||
<TimeInputExample | ||
label="Label text" | ||
// Use the state value to set the time | ||
currentValue={inputValue} | ||
// Use the set state function to update the time when it changes | ||
onInputChange={newValue => setInputValue(newValue)} | ||
/> | ||
<button type="submit">Submit</button> | ||
</form> | ||
) | ||
} | ||
const ExampleBlock = ({ label, Input, codeString }) => { | ||
@@ -114,9 +62,19 @@ const [value, setValue] = useState('20:30') | ||
<p>Code examples are simplified guides, not exact code replicas.</p> | ||
<SyntaxHighlighter | ||
style={dark} | ||
className="code centered" | ||
language="text" | ||
showLineNumbers={false} | ||
> | ||
npm install react-time-input-polyfill | ||
</SyntaxHighlighter> | ||
<p> | ||
Code examples are simplified guides,{' '} | ||
<strong>not exact code replicas</strong>. | ||
<a href="https://github.com/Dan503/react-time-input-polyfill#react-time-input-polyfill"> | ||
Visit me on GitHub | ||
</a> | ||
</p> | ||
<ExampleForm></ExampleForm> | ||
<ExampleBlock | ||
@@ -123,0 +81,0 @@ label="Non-forced polyfill" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2031479
50
4568
3
58