Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Smart Time Input</title>
Expand Down Expand Up @@ -34,9 +35,11 @@
</style>

</head>

<body>
<h1>Smart Time Input</h1>
<div id="myApp"></div>
<script src="demo.js" type="text/javascript"></script>
</body>
</html>

</html>
11 changes: 2 additions & 9 deletions demo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@ import React from 'react'
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

// import { SmartTimeInput } from './../src/smart-time-input.tsx'
import { SmartTimeInput } from './../dist/smart-time-input.js'

const InputWrapper = (props) => {
console.log("hello: " + props.helpText);
// const onTimeChangeHandler = (val) => {
// if (val.length === 5) {
// }
// }

return (
<SmartTimeInput
initTime={props.init}
placeholder={props.helpText}
className='input'
// onTimeChange={onTimeChangeHandler}
/>
);

Expand All @@ -27,8 +20,8 @@ const InputWrapper = (props) => {
function App() {
return (
<div>
<InputWrapper init="12:34"/>
<InputWrapper helpText="HH:mm"/>
<InputWrapper init="12:34" />
<InputWrapper helpText="HH:mm" />
<InputWrapper />
</div>
);
Expand Down
12 changes: 0 additions & 12 deletions src/smart-time-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@ import React, { useState } from 'react'
import { is24hTime, addColonToTime, completeTime } from './utils';

interface SmartTimeInputProps extends React.PropsWithChildren {
id?: string;
initTime?: string;
disabled?: boolean;
placeholder?: string;
className?: string;
divClassName?: string;
name?: string;
ref?: React.Ref<HTMLInputElement>;
onFocusHandler?: (e: React.FocusEvent<HTMLInputElement>) => void;
onTimeChange?: (val: string) => void;
onBlurHandlerSuper?: (e: React.FocusEvent<HTMLInputElement>) => void;
}
const SmartTimeInput: React.FC<SmartTimeInputProps> = ({
id,
initTime,
disabled,
placeholder,
className,
divClassName,
name,
ref,
onFocusHandler,
onTimeChange,
Expand Down Expand Up @@ -57,12 +49,8 @@ const SmartTimeInput: React.FC<SmartTimeInputProps> = ({
return (
<div className={divClassName}>
<input
id={id}
name={name}
className={className}
type={'text'}
disabled={disabled}
placeholder={placeholder}
value={time}
onChange={(e) => handleTimeChange(e.target.value)}
onBlur={(e) => autoExtendTime(e)}
Expand Down