@tapie-kr/inspire-react
Version:
React Component Collection for INSPIRE
24 lines (21 loc) • 1.38 kB
JavaScript
'use client';
/* eslint-disable */
/*
* INSPIRE : Creative Kit
* React Component Collection for INSPIRE
*
* This file is generated automatically. Do not modify it manually
* Generated at : 2025. 3. 4. 오후 6:18:13
* @tapie-kr/inspire-react version: 0.2.15
*
* (c) 2025 TAPIE. All rights reserved.
* MIT License
*/
import { jsx } from 'react/jsx-runtime';
import { base, input } from './styles.css.js';
import { HStack } from '../../miscellaneous/layout/HStack/index.js';
import { Temporal as Pt } from '../../../node_modules/@js-temporal/polyfill/dist/index.esm.js';
import { useRef } from 'react';
import { StackJustify } from '../../../lib/layout/types.js';
function DatetimePicker(props){const{value,onChange,...rest}=props;const inputRef=useRef(null);const handleOpen=()=>{inputRef.current?.showPicker?.();inputRef.current?.click();};const handleChange=event=>{const inputValue=event.target.value;if(!inputValue){onChange?.(undefined);return}try{onChange?.(Pt.PlainDateTime.from(inputValue));}catch{console.error("Invalid date format:",inputValue);}};return jsx(HStack,{fullWidth:true,tag:"label",className:base,justify:StackJustify.BETWEEN,onClick:handleOpen,children:jsx("input",{ref:inputRef,className:input,type:"datetime-local",value:value?value.toString():"",onChange:handleChange,onClick:event=>event.stopPropagation(),...rest})})}
export { DatetimePicker };