Skip to content

Commit 137cbd7

Browse files
committed
feat: Add support for inputTabIndex prop
1 parent 994a1a8 commit 137cbd7

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

app/page.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default function Playground() {
4545
const [startWeekOn, setStartWeekOn] = useState<WeekStringType>("mon");
4646
const [required, setRequired] = useState(false);
4747
const [popoverDirection, setPopoverDirection] = useState<PopoverDirectionType>("down");
48+
const [tabIndex, setTabIndex] = useState<number | undefined>(undefined);
4849

4950
return (
5051
<div className="px-4 py-8">
@@ -114,6 +115,7 @@ export default function Playground() {
114115
i18n={i18n}
115116
disabled={disabled}
116117
inputClassName={inputClassName}
118+
inputTabIndex={tabIndex}
117119
containerClassName={containerClassName}
118120
toggleClassName={toggleClassName}
119121
displayFormat={displayFormat}
@@ -244,6 +246,23 @@ export default function Playground() {
244246
</label>
245247
</div>
246248
</div>
249+
<div className="mb-2 w-1/2 sm:w-full">
250+
<div className="inline-flex items-center">
251+
<input
252+
type="number"
253+
className="mr-2 w-24 rounded"
254+
id="tabIndex"
255+
value={tabIndex}
256+
onChange={function (e) {
257+
console.log(e.target.value, parseInt(e.target.value));
258+
return setTabIndex(parseInt(e.target.value));
259+
}}
260+
/>
261+
<label className="block" htmlFor="required">
262+
Tab Index
263+
</label>
264+
</div>
265+
</div>
247266
</div>
248267

249268
<div className="w-full sm:w-1/3 pr-2 flex flex-col">

src/components/Datepicker.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const Datepicker = (props: DatepickerType) => {
5050
inputClassName = null,
5151
inputId,
5252
inputName,
53+
inputTabIndex,
5354

5455
minDate = undefined,
5556
maxDate = undefined,
@@ -318,6 +319,7 @@ const Datepicker = (props: DatepickerType) => {
318319
inputId,
319320
inputName,
320321
inputText,
322+
inputTabIndex,
321323
maxDate,
322324
minDate,
323325
onChange,
@@ -351,6 +353,7 @@ const Datepicker = (props: DatepickerType) => {
351353
value,
352354
disabled,
353355
inputClassName,
356+
inputTabIndex,
354357
containerClassName,
355358
toggleClassName,
356359
toggleIcon,

src/components/Input.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const Input = (e: Props) => {
3737
separator,
3838
disabled,
3939
inputClassName,
40+
inputTabIndex,
4041
toggleClassName,
4142
toggleIcon,
4243
readOnly,
@@ -282,6 +283,7 @@ const Input = (e: Props) => {
282283
ref={inputRef}
283284
type="text"
284285
className={getClassName()}
286+
tabIndex={inputTabIndex}
285287
disabled={disabled}
286288
readOnly={readOnly}
287289
required={required}

src/contexts/DatepickerContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ interface DatepickerStore {
4848
inputId?: string;
4949
inputName?: string;
5050
inputText: string;
51+
inputTabIndex?: number;
5152

5253
maxDate?: DateType | null;
5354
minDate?: DateType | null;
@@ -97,6 +98,7 @@ const DatepickerContext = createContext<DatepickerStore>({
9798

9899
input: undefined,
99100
inputClassName: "",
101+
inputTabIndex: undefined,
100102

101103
inputId: undefined,
102104
inputName: undefined,

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface DatepickerType {
8383
toggleIcon?: (open: boolean) => ReactNode;
8484
inputId?: string;
8585
inputName?: string;
86+
inputTabIndex?: number;
8687
displayFormat?: string;
8788
readOnly?: boolean;
8889
minDate?: DateType;

0 commit comments

Comments
 (0)