uibee 2.8.5 → 2.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -83,10 +83,32 @@ export default function Input(props) {
|
|
|
83
83
|
const date = new Date(value);
|
|
84
84
|
return isNaN(date.getTime()) ? null : date;
|
|
85
85
|
}
|
|
86
|
+
function getDateDisplayValue() {
|
|
87
|
+
if (!value || !isDateType)
|
|
88
|
+
return value;
|
|
89
|
+
const date = getDateValue();
|
|
90
|
+
if (!date)
|
|
91
|
+
return value;
|
|
92
|
+
function pad(n) {
|
|
93
|
+
return n.toString().padStart(2, '0');
|
|
94
|
+
}
|
|
95
|
+
const yyyy = date.getFullYear();
|
|
96
|
+
const MM = pad(date.getMonth() + 1);
|
|
97
|
+
const dd = pad(date.getDate());
|
|
98
|
+
const hh = pad(date.getHours());
|
|
99
|
+
const mm = pad(date.getMinutes());
|
|
100
|
+
if (type === 'date')
|
|
101
|
+
return `${dd}.${MM}.${yyyy}`;
|
|
102
|
+
if (type === 'time')
|
|
103
|
+
return `${hh}:${mm}`;
|
|
104
|
+
if (type === 'datetime-local')
|
|
105
|
+
return `${dd}.${MM}.${yyyy} ${hh}:${mm}`;
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
86
108
|
return (_jsx(FieldWrapper, { label: label, name: name, required: inputProps.required, info: info, error: error, className: className, children: _jsxs("div", { className: 'relative flex items-center', ref: containerRef, children: [displayIcon && (_jsx("div", { className: `
|
|
87
109
|
absolute left-3 text-login-200
|
|
88
110
|
${isClickableType && !inputProps.disabled ? 'cursor-pointer hover:text-login-text' : 'pointer-events-none'}
|
|
89
|
-
`, onClick: handleIconClick, children: displayIcon })), _jsx("input", { ...inputProps, ref: localRef, id: name, name: name, type: isClickableType ? 'text' : type, value: value, readOnly: isClickableType, onClick: () => isClickableType && !inputProps.disabled && setIsOpen(true), title: label, "aria-invalid": !!error, "aria-describedby": error ? `${name}-error` : undefined, className: `
|
|
111
|
+
`, onClick: handleIconClick, children: displayIcon })), _jsx("input", { ...inputProps, ref: localRef, id: name, name: isClickableType ? undefined : name, type: isClickableType ? 'text' : type, value: isDateType ? getDateDisplayValue() : value, readOnly: isClickableType, onClick: () => isClickableType && !inputProps.disabled && setIsOpen(true), title: label, "aria-invalid": !!error, "aria-describedby": error ? `${name}-error` : undefined, className: `
|
|
90
112
|
w-full rounded-md bg-login-500/50 border border-login-500
|
|
91
113
|
text-login-text placeholder-login-200
|
|
92
114
|
focus:outline-none focus:border-login focus:ring-1 focus:ring-login
|
|
@@ -96,5 +118,5 @@ export default function Input(props) {
|
|
|
96
118
|
input-reset
|
|
97
119
|
${error ? 'border-red-500 focus:border-red-500 focus:ring-red-500' : ''}
|
|
98
120
|
${isClickableType && !inputProps.disabled ? 'cursor-pointer' : ''}
|
|
99
|
-
` }), isOpen && isDateType && !inputProps.disabled && (_jsx(DateTimePickerPopup, { value: getDateValue(), onChange: handleDateChange, type: type, onClose: () => setIsOpen(false) })), isOpen && isColorType && !inputProps.disabled && (_jsx(ColorPickerPopup, { value: value || '', onChange: handleColorChange, onClose: () => setIsOpen(false) }))] }) }));
|
|
121
|
+
` }), isClickableType && (_jsx("input", { type: 'hidden', name: name, value: value })), isOpen && isDateType && !inputProps.disabled && (_jsx(DateTimePickerPopup, { value: getDateValue(), onChange: handleDateChange, type: type, onClose: () => setIsOpen(false) })), isOpen && isColorType && !inputProps.disabled && (_jsx(ColorPickerPopup, { value: value || '', onChange: handleColorChange, onClose: () => setIsOpen(false) }))] }) }));
|
|
100
122
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
|
-
const DAYS = ['
|
|
4
|
+
const DAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
5
5
|
const MONTHS = [
|
|
6
6
|
'January', 'February', 'March', 'April', 'May', 'June',
|
|
7
7
|
'July', 'August', 'September', 'October', 'November', 'December'
|
|
@@ -87,7 +87,8 @@ export default function DateTimePickerPopup({ value, onChange, type, onClose, })
|
|
|
87
87
|
const daysInMonth = getDaysInMonth(year, month);
|
|
88
88
|
const firstDay = getFirstDayOfMonth(year, month);
|
|
89
89
|
const days = [];
|
|
90
|
-
|
|
90
|
+
const adjustedFirstDay = firstDay === 0 ? 6 : firstDay - 1;
|
|
91
|
+
for (let i = 0; i < adjustedFirstDay; i++) {
|
|
91
92
|
days.push(_jsx("div", { className: 'w-8 h-8' }, `empty-${i}`));
|
|
92
93
|
}
|
|
93
94
|
for (let i = 1; i <= daysInMonth; i++) {
|
package/package.json
CHANGED
|
@@ -100,6 +100,29 @@ export default function Input(props: InputProps) {
|
|
|
100
100
|
return isNaN(date.getTime()) ? null : date
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function getDateDisplayValue() {
|
|
104
|
+
if (!value || !isDateType) return value as string
|
|
105
|
+
|
|
106
|
+
const date = getDateValue()
|
|
107
|
+
if (!date) return value as string
|
|
108
|
+
|
|
109
|
+
function pad(n: number) {
|
|
110
|
+
return n.toString().padStart(2, '0')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const yyyy = date.getFullYear()
|
|
114
|
+
const MM = pad(date.getMonth() + 1)
|
|
115
|
+
const dd = pad(date.getDate())
|
|
116
|
+
const hh = pad(date.getHours())
|
|
117
|
+
const mm = pad(date.getMinutes())
|
|
118
|
+
|
|
119
|
+
if (type === 'date') return `${dd}.${MM}.${yyyy}`
|
|
120
|
+
if (type === 'time') return `${hh}:${mm}`
|
|
121
|
+
if (type === 'datetime-local') return `${dd}.${MM}.${yyyy} ${hh}:${mm}`
|
|
122
|
+
|
|
123
|
+
return value as string
|
|
124
|
+
}
|
|
125
|
+
|
|
103
126
|
return (
|
|
104
127
|
<FieldWrapper
|
|
105
128
|
label={label}
|
|
@@ -125,9 +148,9 @@ export default function Input(props: InputProps) {
|
|
|
125
148
|
{...inputProps}
|
|
126
149
|
ref={localRef}
|
|
127
150
|
id={name}
|
|
128
|
-
name={name}
|
|
151
|
+
name={isClickableType ? undefined : name}
|
|
129
152
|
type={isClickableType ? 'text' : type}
|
|
130
|
-
value={value}
|
|
153
|
+
value={isDateType ? getDateDisplayValue() : value}
|
|
131
154
|
readOnly={isClickableType}
|
|
132
155
|
onClick={() => isClickableType && !inputProps.disabled && setIsOpen(true)}
|
|
133
156
|
title={label}
|
|
@@ -145,6 +168,9 @@ export default function Input(props: InputProps) {
|
|
|
145
168
|
${isClickableType && !inputProps.disabled ? 'cursor-pointer' : ''}
|
|
146
169
|
`}
|
|
147
170
|
/>
|
|
171
|
+
{isClickableType && (
|
|
172
|
+
<input type='hidden' name={name} value={value as string} />
|
|
173
|
+
)}
|
|
148
174
|
{isOpen && isDateType && !inputProps.disabled && (
|
|
149
175
|
<DateTimePickerPopup
|
|
150
176
|
value={getDateValue()}
|
|
@@ -8,7 +8,7 @@ type DateTimePickerPopupProps = {
|
|
|
8
8
|
onClose?: () => void
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const DAYS = ['
|
|
11
|
+
const DAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
|
|
12
12
|
const MONTHS = [
|
|
13
13
|
'January', 'February', 'March', 'April', 'May', 'June',
|
|
14
14
|
'July', 'August', 'September', 'October', 'November', 'December'
|
|
@@ -112,7 +112,9 @@ export default function DateTimePickerPopup({
|
|
|
112
112
|
const firstDay = getFirstDayOfMonth(year, month)
|
|
113
113
|
const days = []
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
const adjustedFirstDay = firstDay === 0 ? 6 : firstDay - 1
|
|
116
|
+
|
|
117
|
+
for (let i = 0; i < adjustedFirstDay; i++) {
|
|
116
118
|
days.push(<div key={`empty-${i}`} className='w-8 h-8' />)
|
|
117
119
|
}
|
|
118
120
|
|