tyrell-react 1.0.0-TC25 → 1.0.0-TC26
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.
- package/dist/components/TyCalendar.d.ts +4 -0
- package/dist/components/TyCalendar.d.ts.map +1 -1
- package/dist/components/TyCalendar.js +7 -1
- package/dist/components/TyCalendar.js.map +1 -1
- package/dist/components/TyCalendarMonth.d.ts +4 -0
- package/dist/components/TyCalendarMonth.d.ts.map +1 -1
- package/dist/components/TyCalendarMonth.js +5 -1
- package/dist/components/TyCalendarMonth.js.map +1 -1
- package/dist/components/TyCalendarNavigation.d.ts +4 -0
- package/dist/components/TyCalendarNavigation.d.ts.map +1 -1
- package/dist/components/TyCalendarNavigation.js +5 -1
- package/dist/components/TyCalendarNavigation.js.map +1 -1
- package/dist/components/TyCheckbox.d.ts +2 -0
- package/dist/components/TyCheckbox.d.ts.map +1 -1
- package/dist/components/TyCheckbox.js +4 -1
- package/dist/components/TyCheckbox.js.map +1 -1
- package/dist/components/TyDatePicker.d.ts +4 -0
- package/dist/components/TyDatePicker.d.ts.map +1 -1
- package/dist/components/TyDatePicker.js +7 -1
- package/dist/components/TyDatePicker.js.map +1 -1
- package/dist/components/TyOption.d.ts +8 -0
- package/dist/components/TyOption.d.ts.map +1 -1
- package/dist/components/TyOption.js +3 -1
- package/dist/components/TyOption.js.map +1 -1
- package/dist/components/TySelect.d.ts +75 -0
- package/dist/components/TySelect.d.ts.map +1 -0
- package/dist/components/TySelect.js +134 -0
- package/dist/components/TySelect.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/components/TyCalendar.tsx +16 -0
- package/src/components/TyCalendarMonth.tsx +11 -1
- package/src/components/TyCalendarNavigation.tsx +11 -1
- package/src/components/TyCheckbox.tsx +8 -2
- package/src/components/TyDatePicker.tsx +16 -0
- package/src/components/TyOption.tsx +14 -1
- package/src/components/TySelect.tsx +240 -0
- package/src/components/index.ts +9 -0
- package/src/version.ts +1 -1
- package/src/components/EventConventionTest.tsx +0 -155
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test Example: React Event Convention
|
|
3
|
-
*
|
|
4
|
-
* This file demonstrates the new event handling convention
|
|
5
|
-
* for tyrell-react components.
|
|
6
|
-
*
|
|
7
|
-
* To test:
|
|
8
|
-
* 1. Create a new React project or use existing
|
|
9
|
-
* 2. npm install tyrell-react
|
|
10
|
-
* 3. Add this component to your app
|
|
11
|
-
* 4. Observe console logs and state updates
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import React, { useState } from 'react';
|
|
15
|
-
import { TyInput } from './TyInput';
|
|
16
|
-
import { TyTextarea } from './TyTextarea';
|
|
17
|
-
import { TyCheckbox } from './TyCheckbox';
|
|
18
|
-
import type { TyInputEventDetail } from './TyInput';
|
|
19
|
-
import type { TyTextareaEventDetail } from './TyTextarea';
|
|
20
|
-
import type { TyCheckboxEventDetail } from './TyCheckbox';
|
|
21
|
-
|
|
22
|
-
export function EventConventionTest() {
|
|
23
|
-
const [inputValue, setInputValue] = useState('');
|
|
24
|
-
const [textareaValue, setTextareaValue] = useState('');
|
|
25
|
-
const [checked, setChecked] = useState(false);
|
|
26
|
-
const [logs, setLogs] = useState<string[]>([]);
|
|
27
|
-
|
|
28
|
-
const addLog = (message: string) => {
|
|
29
|
-
setLogs(prev => [...prev, `${new Date().toLocaleTimeString()}: ${message}`]);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="p-8 space-y-6 max-w-2xl">
|
|
34
|
-
<h1 className="text-2xl font-bold">React Event Convention Test</h1>
|
|
35
|
-
|
|
36
|
-
{/* Input Test */}
|
|
37
|
-
<div className="space-y-2">
|
|
38
|
-
<h2 className="text-lg font-semibold">TyInput Test</h2>
|
|
39
|
-
<TyInput
|
|
40
|
-
label="Email"
|
|
41
|
-
placeholder="Type to test onChange..."
|
|
42
|
-
value={inputValue}
|
|
43
|
-
onChange={(e: CustomEvent<TyInputEventDetail>) => {
|
|
44
|
-
setInputValue(e.detail.value);
|
|
45
|
-
addLog(`onChange: "${e.detail.value}" (fires on keystroke)`);
|
|
46
|
-
}}
|
|
47
|
-
onChangeCommit={(e: CustomEvent<TyInputEventDetail>) => {
|
|
48
|
-
addLog(`onChangeCommit: "${e.detail.value}" (fires on blur)`);
|
|
49
|
-
}}
|
|
50
|
-
onFocus={() => addLog('onFocus')}
|
|
51
|
-
onBlur={() => addLog('onBlur')}
|
|
52
|
-
/>
|
|
53
|
-
<p className="text-sm text-gray-600">
|
|
54
|
-
Current value: <strong>{inputValue}</strong>
|
|
55
|
-
</p>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
{/* Textarea Test */}
|
|
59
|
-
<div className="space-y-2">
|
|
60
|
-
<h2 className="text-lg font-semibold">TyTextarea Test</h2>
|
|
61
|
-
<TyTextarea
|
|
62
|
-
label="Comments"
|
|
63
|
-
placeholder="Type to test onChange..."
|
|
64
|
-
value={textareaValue}
|
|
65
|
-
rows={3}
|
|
66
|
-
onChange={(e: CustomEvent<TyTextareaEventDetail>) => {
|
|
67
|
-
setTextareaValue(e.detail.value);
|
|
68
|
-
addLog(`Textarea onChange: "${e.detail.value}"`);
|
|
69
|
-
}}
|
|
70
|
-
onChangeCommit={(e: CustomEvent<TyTextareaEventDetail>) => {
|
|
71
|
-
addLog(`Textarea onChangeCommit: "${e.detail.value}"`);
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
<p className="text-sm text-gray-600">
|
|
75
|
-
Current value: <strong>{textareaValue}</strong>
|
|
76
|
-
</p>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
{/* Checkbox Test */}
|
|
80
|
-
<div className="space-y-2">
|
|
81
|
-
<h2 className="text-lg font-semibold">TyCheckbox Test</h2>
|
|
82
|
-
<TyCheckbox
|
|
83
|
-
checked={checked}
|
|
84
|
-
onChange={(e: CustomEvent<TyCheckboxEventDetail>) => {
|
|
85
|
-
setChecked(e.detail.checked);
|
|
86
|
-
addLog(`Checkbox onChange: ${e.detail.checked} (fires immediately)`);
|
|
87
|
-
}}
|
|
88
|
-
onChangeCommit={(e: CustomEvent<TyCheckboxEventDetail>) => {
|
|
89
|
-
addLog(`Checkbox onChangeCommit: ${e.detail.checked} (fires on blur)`);
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
Subscribe to newsletter
|
|
93
|
-
</TyCheckbox>
|
|
94
|
-
<p className="text-sm text-gray-600">
|
|
95
|
-
Current state: <strong>{checked ? 'Checked' : 'Unchecked'}</strong>
|
|
96
|
-
</p>
|
|
97
|
-
</div>
|
|
98
|
-
|
|
99
|
-
{/* Event Log */}
|
|
100
|
-
<div className="space-y-2">
|
|
101
|
-
<h2 className="text-lg font-semibold">Event Log</h2>
|
|
102
|
-
<div className="bg-gray-100 p-4 rounded max-h-64 overflow-y-auto font-mono text-xs">
|
|
103
|
-
{logs.length === 0 ? (
|
|
104
|
-
<p className="text-gray-500">No events yet. Start typing or checking boxes!</p>
|
|
105
|
-
) : (
|
|
106
|
-
logs.map((log, i) => (
|
|
107
|
-
<div key={i} className="text-gray-800">
|
|
108
|
-
{log}
|
|
109
|
-
</div>
|
|
110
|
-
))
|
|
111
|
-
)}
|
|
112
|
-
</div>
|
|
113
|
-
<button
|
|
114
|
-
onClick={() => setLogs([])}
|
|
115
|
-
className="px-4 py-2 bg-gray-200 rounded hover:bg-gray-300"
|
|
116
|
-
>
|
|
117
|
-
Clear Log
|
|
118
|
-
</button>
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
{/* Expected Behavior */}
|
|
122
|
-
<div className="bg-blue-50 p-4 rounded">
|
|
123
|
-
<h3 className="font-semibold mb-2">Expected Behavior:</h3>
|
|
124
|
-
<ul className="list-disc list-inside space-y-1 text-sm">
|
|
125
|
-
<li>
|
|
126
|
-
<strong>onChange</strong> - Fires on every keystroke/state change (React convention)
|
|
127
|
-
</li>
|
|
128
|
-
<li>
|
|
129
|
-
<strong>onChangeCommit</strong> - Fires on blur if value changed (optional)
|
|
130
|
-
</li>
|
|
131
|
-
<li>
|
|
132
|
-
<strong>onFocus</strong> - Fires when element gains focus
|
|
133
|
-
</li>
|
|
134
|
-
<li>
|
|
135
|
-
<strong>onBlur</strong> - Fires when element loses focus
|
|
136
|
-
</li>
|
|
137
|
-
</ul>
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
{/* Verification */}
|
|
141
|
-
<div className="bg-green-50 p-4 rounded">
|
|
142
|
-
<h3 className="font-semibold mb-2">Verification Checklist:</h3>
|
|
143
|
-
<ul className="list-disc list-inside space-y-1 text-sm">
|
|
144
|
-
<li>✅ onChange fires on EVERY keystroke (not just on blur)</li>
|
|
145
|
-
<li>✅ State updates in real-time as you type</li>
|
|
146
|
-
<li>✅ onChangeCommit fires ONLY on blur (if value changed)</li>
|
|
147
|
-
<li>✅ Event order: onChange → onBlur → onChangeCommit</li>
|
|
148
|
-
<li>✅ Checkbox onChange fires immediately on click</li>
|
|
149
|
-
</ul>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export default EventConventionTest;
|