tyrell-react 1.0.0-RC6

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.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +410 -0
  3. package/dist/components/TyButton.d.ts +50 -0
  4. package/dist/components/TyButton.d.ts.map +1 -0
  5. package/dist/components/TyButton.js +68 -0
  6. package/dist/components/TyButton.js.map +1 -0
  7. package/dist/components/TyCalendar.d.ts +63 -0
  8. package/dist/components/TyCalendar.d.ts.map +1 -0
  9. package/dist/components/TyCalendar.js +127 -0
  10. package/dist/components/TyCalendar.js.map +1 -0
  11. package/dist/components/TyCalendarMonth.d.ts +32 -0
  12. package/dist/components/TyCalendarMonth.d.ts.map +1 -0
  13. package/dist/components/TyCalendarMonth.js +54 -0
  14. package/dist/components/TyCalendarMonth.js.map +1 -0
  15. package/dist/components/TyCalendarNavigation.d.ts +21 -0
  16. package/dist/components/TyCalendarNavigation.d.ts.map +1 -0
  17. package/dist/components/TyCalendarNavigation.js +50 -0
  18. package/dist/components/TyCalendarNavigation.js.map +1 -0
  19. package/dist/components/TyCheckbox.d.ts +39 -0
  20. package/dist/components/TyCheckbox.d.ts.map +1 -0
  21. package/dist/components/TyCheckbox.js +83 -0
  22. package/dist/components/TyCheckbox.js.map +1 -0
  23. package/dist/components/TyCopy.d.ts +21 -0
  24. package/dist/components/TyCopy.d.ts.map +1 -0
  25. package/dist/components/TyCopy.js +42 -0
  26. package/dist/components/TyCopy.js.map +1 -0
  27. package/dist/components/TyDatePicker.d.ts +45 -0
  28. package/dist/components/TyDatePicker.d.ts.map +1 -0
  29. package/dist/components/TyDatePicker.js +119 -0
  30. package/dist/components/TyDatePicker.js.map +1 -0
  31. package/dist/components/TyDropdown.d.ts +56 -0
  32. package/dist/components/TyDropdown.d.ts.map +1 -0
  33. package/dist/components/TyDropdown.js +110 -0
  34. package/dist/components/TyDropdown.js.map +1 -0
  35. package/dist/components/TyIcon.d.ts +17 -0
  36. package/dist/components/TyIcon.d.ts.map +1 -0
  37. package/dist/components/TyIcon.js +41 -0
  38. package/dist/components/TyIcon.js.map +1 -0
  39. package/dist/components/TyInput.d.ts +65 -0
  40. package/dist/components/TyInput.d.ts.map +1 -0
  41. package/dist/components/TyInput.js +127 -0
  42. package/dist/components/TyInput.js.map +1 -0
  43. package/dist/components/TyModal.d.ts +29 -0
  44. package/dist/components/TyModal.d.ts.map +1 -0
  45. package/dist/components/TyModal.js +74 -0
  46. package/dist/components/TyModal.js.map +1 -0
  47. package/dist/components/TyMultiselect.d.ts +51 -0
  48. package/dist/components/TyMultiselect.d.ts.map +1 -0
  49. package/dist/components/TyMultiselect.js +107 -0
  50. package/dist/components/TyMultiselect.js.map +1 -0
  51. package/dist/components/TyOption.d.ts +10 -0
  52. package/dist/components/TyOption.d.ts.map +1 -0
  53. package/dist/components/TyOption.js +25 -0
  54. package/dist/components/TyOption.js.map +1 -0
  55. package/dist/components/TyPopup.d.ts +24 -0
  56. package/dist/components/TyPopup.d.ts.map +1 -0
  57. package/dist/components/TyPopup.js +61 -0
  58. package/dist/components/TyPopup.js.map +1 -0
  59. package/dist/components/TyRadio.d.ts +20 -0
  60. package/dist/components/TyRadio.d.ts.map +1 -0
  61. package/dist/components/TyRadio.js +46 -0
  62. package/dist/components/TyRadio.js.map +1 -0
  63. package/dist/components/TyRadioGroup.d.ts +40 -0
  64. package/dist/components/TyRadioGroup.d.ts.map +1 -0
  65. package/dist/components/TyRadioGroup.js +58 -0
  66. package/dist/components/TyRadioGroup.js.map +1 -0
  67. package/dist/components/TyResizeObserver.d.ts +11 -0
  68. package/dist/components/TyResizeObserver.d.ts.map +1 -0
  69. package/dist/components/TyResizeObserver.js +28 -0
  70. package/dist/components/TyResizeObserver.js.map +1 -0
  71. package/dist/components/TyScrollContainer.d.ts +25 -0
  72. package/dist/components/TyScrollContainer.d.ts.map +1 -0
  73. package/dist/components/TyScrollContainer.js +43 -0
  74. package/dist/components/TyScrollContainer.js.map +1 -0
  75. package/dist/components/TyStep.d.ts +17 -0
  76. package/dist/components/TyStep.d.ts.map +1 -0
  77. package/dist/components/TyStep.js +35 -0
  78. package/dist/components/TyStep.js.map +1 -0
  79. package/dist/components/TySwitch.d.ts +35 -0
  80. package/dist/components/TySwitch.d.ts.map +1 -0
  81. package/dist/components/TySwitch.js +69 -0
  82. package/dist/components/TySwitch.js.map +1 -0
  83. package/dist/components/TyTab.d.ts +13 -0
  84. package/dist/components/TyTab.d.ts.map +1 -0
  85. package/dist/components/TyTab.js +32 -0
  86. package/dist/components/TyTab.js.map +1 -0
  87. package/dist/components/TyTabs.d.ts +23 -0
  88. package/dist/components/TyTabs.d.ts.map +1 -0
  89. package/dist/components/TyTabs.js +48 -0
  90. package/dist/components/TyTabs.js.map +1 -0
  91. package/dist/components/TyTag.d.ts +22 -0
  92. package/dist/components/TyTag.d.ts.map +1 -0
  93. package/dist/components/TyTag.js +45 -0
  94. package/dist/components/TyTag.js.map +1 -0
  95. package/dist/components/TyTextarea.d.ts +37 -0
  96. package/dist/components/TyTextarea.d.ts.map +1 -0
  97. package/dist/components/TyTextarea.js +113 -0
  98. package/dist/components/TyTextarea.js.map +1 -0
  99. package/dist/components/TyTooltip.d.ts +17 -0
  100. package/dist/components/TyTooltip.d.ts.map +1 -0
  101. package/dist/components/TyTooltip.js +40 -0
  102. package/dist/components/TyTooltip.js.map +1 -0
  103. package/dist/components/TyWizard.d.ts +26 -0
  104. package/dist/components/TyWizard.d.ts.map +1 -0
  105. package/dist/components/TyWizard.js +50 -0
  106. package/dist/components/TyWizard.js.map +1 -0
  107. package/dist/components/index.d.ts +105 -0
  108. package/dist/components/index.d.ts.map +1 -0
  109. package/dist/components/index.js +112 -0
  110. package/dist/components/index.js.map +1 -0
  111. package/dist/utils/react-version.d.ts +2 -0
  112. package/dist/utils/react-version.d.ts.map +1 -0
  113. package/dist/utils/react-version.js +8 -0
  114. package/dist/utils/react-version.js.map +1 -0
  115. package/package.json +46 -0
  116. package/src/components/EventConventionTest.tsx +155 -0
  117. package/src/components/TyButton.tsx +145 -0
  118. package/src/components/TyCalendar.tsx +248 -0
  119. package/src/components/TyCalendarMonth.tsx +108 -0
  120. package/src/components/TyCalendarNavigation.tsx +91 -0
  121. package/src/components/TyCheckbox.tsx +152 -0
  122. package/src/components/TyCopy.tsx +78 -0
  123. package/src/components/TyDatePicker.tsx +220 -0
  124. package/src/components/TyDropdown.tsx +225 -0
  125. package/src/components/TyIcon.tsx +72 -0
  126. package/src/components/TyInput.tsx +232 -0
  127. package/src/components/TyModal.tsx +142 -0
  128. package/src/components/TyMultiselect.tsx +203 -0
  129. package/src/components/TyOption.tsx +42 -0
  130. package/src/components/TyPopup.tsx +111 -0
  131. package/src/components/TyRadio.tsx +70 -0
  132. package/src/components/TyRadioGroup.tsx +121 -0
  133. package/src/components/TyResizeObserver.tsx +54 -0
  134. package/src/components/TyScrollContainer.tsx +87 -0
  135. package/src/components/TyStep.tsx +71 -0
  136. package/src/components/TySwitch.tsx +122 -0
  137. package/src/components/TyTab.tsx +63 -0
  138. package/src/components/TyTabs.tsx +93 -0
  139. package/src/components/TyTag.tsx +79 -0
  140. package/src/components/TyTextarea.tsx +177 -0
  141. package/src/components/TyTooltip.tsx +83 -0
  142. package/src/components/TyWizard.tsx +99 -0
  143. package/src/components/index.ts +251 -0
  144. package/src/utils/react-version.ts +8 -0
@@ -0,0 +1,93 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+
3
+ // Type definitions for Ty Tabs component
4
+ export interface TyTabsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
5
+ /** Content area width (accepts px or %) */
6
+ width?: string;
7
+
8
+ /** Total container height including buttons */
9
+ height?: string;
10
+
11
+ /** ID of currently active tab */
12
+ active?: string;
13
+
14
+ /** Position of tab buttons */
15
+ placement?: 'top' | 'bottom';
16
+
17
+ /** Tab change event handler */
18
+ onChange?: (event: CustomEvent<TabChangeDetail>) => void;
19
+
20
+ /** Tabs content (TyTab components) */
21
+ children?: React.ReactNode;
22
+ }
23
+
24
+ export interface TabChangeDetail {
25
+ activeId: string;
26
+ activeIndex: number;
27
+ previousId: string | null;
28
+ previousIndex: number | null;
29
+ }
30
+
31
+ // React wrapper for ty-tabs web component
32
+ export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
33
+ ({
34
+ children,
35
+ width,
36
+ height,
37
+ active,
38
+ placement,
39
+ onChange,
40
+ ...props
41
+ }, ref) => {
42
+ const elementRef = useRef<HTMLElement>(null);
43
+
44
+ // Handle change events
45
+ useEffect(() => {
46
+ const element = elementRef.current;
47
+ if (!element) return;
48
+
49
+ const handleChange = (event: Event) => {
50
+ if (onChange) {
51
+ onChange(event as CustomEvent<TabChangeDetail>);
52
+ }
53
+ };
54
+
55
+ element.addEventListener('ty-tab-change', handleChange);
56
+
57
+ return () => {
58
+ element.removeEventListener('ty-tab-change', handleChange);
59
+ };
60
+ }, [onChange]);
61
+
62
+ // Combine refs if needed
63
+ useEffect(() => {
64
+ if (ref && elementRef.current) {
65
+ if (typeof ref === 'function') {
66
+ ref(elementRef.current);
67
+ } else {
68
+ ref.current = elementRef.current;
69
+ }
70
+ }
71
+ }, [ref]);
72
+
73
+ // Convert React props to web component attributes
74
+ const webComponentProps: Record<string, any> = {
75
+ ...props,
76
+ ref: elementRef,
77
+ };
78
+
79
+ // Add string attributes
80
+ if (width) webComponentProps.width = width;
81
+ if (height) webComponentProps.height = height;
82
+ if (active) webComponentProps.active = active;
83
+ if (placement) webComponentProps.placement = placement;
84
+
85
+ return React.createElement(
86
+ 'ty-tabs',
87
+ webComponentProps,
88
+ children
89
+ );
90
+ }
91
+ );
92
+
93
+ TyTabs.displayName = 'TyTabs';
@@ -0,0 +1,79 @@
1
+ import React, { useEffect, useRef, useCallback } from 'react';
2
+
3
+ // CSS custom properties that cascade into the shadow DOM for full color control
4
+ export interface TyTagCSSProperties extends React.CSSProperties {
5
+ '--tag-bg'?: string;
6
+ '--tag-color'?: string;
7
+ '--tag-border-color'?: string;
8
+ }
9
+
10
+ // Type definitions for Ty Tag component
11
+ export interface TyTagProps extends Omit<React.HTMLAttributes<HTMLElement>, 'style' | 'onClick'> {
12
+ flavor?: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
13
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
14
+ notPill?: boolean;
15
+ clickable?: boolean;
16
+ dismissible?: boolean;
17
+ disabled?: boolean;
18
+ selected?: boolean;
19
+ value?: string;
20
+ style?: TyTagCSSProperties;
21
+ // click is a composed CustomEvent from the web component — React's onClick picks it up
22
+ onClick?: (event: CustomEvent) => void;
23
+ onTagDismiss?: (event: CustomEvent) => void;
24
+ children?: React.ReactNode;
25
+ }
26
+
27
+ // React wrapper for ty-tag web component
28
+ export const TyTag = React.forwardRef<HTMLElement, TyTagProps>(
29
+ ({ children, onClick, onTagDismiss, notPill, clickable, dismissible, disabled, selected, ...props }, ref) => {
30
+ const elementRef = useRef<HTMLElement>(null);
31
+
32
+ const handleDismiss = useCallback((event: CustomEvent) => {
33
+ if (onTagDismiss) {
34
+ onTagDismiss(event);
35
+ }
36
+ }, [onTagDismiss]);
37
+
38
+ // dismiss is a custom event — React doesn't know about it, so we need a manual listener
39
+ useEffect(() => {
40
+ const element = elementRef.current;
41
+ if (!element || !onTagDismiss) return;
42
+
43
+ element.addEventListener('dismiss', handleDismiss as EventListener);
44
+ return () => {
45
+ element.removeEventListener('dismiss', handleDismiss as EventListener);
46
+ };
47
+ }, [handleDismiss, onTagDismiss]);
48
+
49
+ // Handle ref forwarding
50
+ useEffect(() => {
51
+ if (ref && elementRef.current) {
52
+ if (typeof ref === 'function') {
53
+ ref(elementRef.current);
54
+ } else {
55
+ ref.current = elementRef.current;
56
+ }
57
+ }
58
+ }, [ref]);
59
+
60
+ return React.createElement(
61
+ 'ty-tag',
62
+ {
63
+ ...props,
64
+ // click is dispatched as composed CustomEvent by the web component — React's
65
+ // synthetic onClick already catches it, so we just pass it through as onClick
66
+ ...(onClick && { onClick }),
67
+ ...(notPill && { 'not-pill': "" }),
68
+ ...(clickable && { clickable: "" }),
69
+ ...(dismissible && { dismissible: "" }),
70
+ ...(disabled && { disabled: "" }),
71
+ ...(selected && { selected: "" }),
72
+ ref: elementRef,
73
+ },
74
+ children
75
+ );
76
+ }
77
+ );
78
+
79
+ TyTag.displayName = 'TyTag';
@@ -0,0 +1,177 @@
1
+ import React, { useEffect, useRef, useCallback } from 'react';
2
+ import { needsPropertyBridge } from '../utils/react-version';
3
+
4
+ // Event detail structure for ty-textarea events
5
+ export interface TyTextareaEventDetail {
6
+ value: string; // textarea value
7
+ originalEvent: Event; // original DOM event
8
+ }
9
+
10
+ // Type definitions for Ty Textarea component
11
+ export interface TyTextareaProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange' | 'onInput' | 'onFocus' | 'onBlur' | 'style'> {
12
+ style?: import('./TyInput').TyInputCSSProperties;
13
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
14
+ value?: string;
15
+ placeholder?: string;
16
+ label?: string;
17
+ error?: string;
18
+ disabled?: boolean;
19
+ required?: boolean;
20
+ name?: string; // Important for HTMX/form compatibility
21
+
22
+ // Textarea-specific props
23
+ rows?: string | number;
24
+ cols?: string | number;
25
+ resize?: 'none' | 'both' | 'horizontal' | 'vertical';
26
+ minHeight?: string; // e.g., '100px' - converts to min-height
27
+ maxHeight?: string; // e.g., '500px' - converts to max-height
28
+
29
+ // React event handlers - override with our custom types
30
+ /**
31
+ * Fires on every keystroke (React convention)
32
+ * Maps to native 'input' event from ty-textarea
33
+ */
34
+ onChange?: (event: CustomEvent<TyTextareaEventDetail>) => void;
35
+
36
+ /**
37
+ * Fires on blur if value changed (native DOM behavior)
38
+ * Maps to native 'change' event from ty-textarea
39
+ */
40
+ onChangeCommit?: (event: CustomEvent<TyTextareaEventDetail>) => void;
41
+
42
+ /** Standard focus event */
43
+ onFocus?: (event: FocusEvent) => void;
44
+
45
+ /** Standard blur event */
46
+ onBlur?: (event: FocusEvent) => void;
47
+ }
48
+
49
+ // One-time warning flag.
50
+ let _warnedOnInputProp = false;
51
+
52
+ // React wrapper for ty-textarea web component
53
+ export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
54
+ ({ onChange, onChangeCommit, onFocus, onBlur, disabled, required, minHeight, maxHeight, ...props }, ref) => {
55
+ const elementRef = useRef<HTMLElement>(null);
56
+
57
+ // Same `onInput` → `onChange` redirect as TyInput. React's synthetic-event
58
+ // system strips event.detail; users hitting e.detail.value will crash.
59
+ const onInputProp = (props as any).onInput as ((e: any) => void) | undefined;
60
+ if (onInputProp && !onChange) {
61
+ if (!_warnedOnInputProp) {
62
+ _warnedOnInputProp = true;
63
+ console.warn(
64
+ '[tyrell-react] <TyTextarea> received `onInput`. ' +
65
+ 'React strips event.detail; use `onChange` instead — it receives the raw CustomEvent. ' +
66
+ 'Forwarding for now, but please rename the prop.'
67
+ );
68
+ }
69
+ onChange = onInputProp;
70
+ }
71
+ delete (props as any).onInput;
72
+
73
+ // Map onChange to input event (React convention)
74
+ const handleInput = useCallback((event: CustomEvent<TyTextareaEventDetail>) => {
75
+ if (onChange) {
76
+ onChange(event);
77
+ }
78
+ }, [onChange]);
79
+
80
+ // Map onChangeCommit to change event (blur behavior)
81
+ const handleChangeCommit = useCallback((event: CustomEvent<TyTextareaEventDetail>) => {
82
+ if (onChangeCommit) {
83
+ onChangeCommit(event);
84
+ }
85
+ }, [onChangeCommit]);
86
+
87
+ const handleFocus = useCallback((event: FocusEvent) => {
88
+ if (onFocus) {
89
+ onFocus(event);
90
+ }
91
+ }, [onFocus]);
92
+
93
+ const handleBlur = useCallback((event: FocusEvent) => {
94
+ if (onBlur) {
95
+ onBlur(event);
96
+ }
97
+ }, [onBlur]);
98
+
99
+ useEffect(() => {
100
+ const element = elementRef.current;
101
+ if (!element) return;
102
+
103
+ // Listen for custom input/change events from ty-textarea
104
+ // Map onChange → input event (React convention)
105
+ if (onChange) {
106
+ element.addEventListener('input', handleInput as EventListener);
107
+ }
108
+
109
+ // Map onChangeCommit → change event (blur behavior)
110
+ if (onChangeCommit) {
111
+ element.addEventListener('change', handleChangeCommit as EventListener);
112
+ }
113
+
114
+ // Listen for standard focus/blur events
115
+ if (onFocus) {
116
+ element.addEventListener('focus', handleFocus as EventListener);
117
+ }
118
+
119
+ if (onBlur) {
120
+ element.addEventListener('blur', handleBlur as EventListener);
121
+ }
122
+
123
+ return () => {
124
+ if (onChange) {
125
+ element.removeEventListener('input', handleInput as EventListener);
126
+ }
127
+ if (onChangeCommit) {
128
+ element.removeEventListener('change', handleChangeCommit as EventListener);
129
+ }
130
+ if (onFocus) {
131
+ element.removeEventListener('focus', handleFocus as EventListener);
132
+ }
133
+ if (onBlur) {
134
+ element.removeEventListener('blur', handleBlur as EventListener);
135
+ }
136
+ };
137
+ }, [handleInput, handleChangeCommit, handleFocus, handleBlur, onChange, onChangeCommit, onFocus, onBlur]);
138
+
139
+ // Handle ref forwarding
140
+ useEffect(() => {
141
+ if (ref && elementRef.current) {
142
+ if (typeof ref === 'function') {
143
+ ref(elementRef.current);
144
+ } else {
145
+ ref.current = elementRef.current;
146
+ }
147
+ }
148
+ }, [ref]);
149
+
150
+ // Imperatively sync `value` to the underlying element's property.
151
+ // React 18 workaround: prop-to-property bridging is unreliable for empty
152
+ // strings on custom elements. React 19+ handles this natively.
153
+ useEffect(() => {
154
+ if (!needsPropertyBridge) return;
155
+ const element = elementRef.current as any;
156
+ if (!element) return;
157
+ const next = (props as any).value ?? '';
158
+ if (element.value !== next) {
159
+ element.value = next;
160
+ }
161
+ }, [(props as any).value]);
162
+
163
+ return React.createElement(
164
+ 'ty-textarea',
165
+ {
166
+ ...props,
167
+ ...(disabled && { disabled: "" }),
168
+ ...(required && { required: "" }),
169
+ ...(minHeight && { 'min-height': minHeight }), // Convert camelCase to kebab-case
170
+ ...(maxHeight && { 'max-height': maxHeight }), // Convert camelCase to kebab-case
171
+ ref: elementRef,
172
+ }
173
+ );
174
+ }
175
+ );
176
+
177
+ TyTextarea.displayName = 'TyTextarea';
@@ -0,0 +1,83 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+
3
+ // Type definitions for Ty Tooltip component
4
+ export interface TyTooltipProps extends React.HTMLAttributes<HTMLElement> {
5
+ /** Tooltip positioning relative to the parent element */
6
+ placement?: 'top' | 'bottom' | 'left' | 'right';
7
+
8
+ /** Distance in pixels from the anchor element (default: 8) */
9
+ offset?: number;
10
+
11
+ /** Delay in milliseconds before showing tooltip (default: 600) */
12
+ delay?: number;
13
+
14
+ /** Disable the tooltip */
15
+ disabled?: boolean;
16
+
17
+ /** Semantic styling variant */
18
+ flavor?: 'dark' | 'light' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'neutral';
19
+
20
+ /** Tooltip content */
21
+ children?: React.ReactNode;
22
+ }
23
+
24
+ // React wrapper for ty-tooltip web component
25
+ export const TyTooltip = React.forwardRef<HTMLElement, TyTooltipProps>(
26
+ ({
27
+ placement,
28
+ offset,
29
+ delay,
30
+ disabled,
31
+ flavor,
32
+ children,
33
+ ...props
34
+ }, ref) => {
35
+ const elementRef = useRef<HTMLElement>(null);
36
+
37
+ // Handle ref forwarding
38
+ useEffect(() => {
39
+ if (ref && elementRef.current) {
40
+ if (typeof ref === 'function') {
41
+ ref(elementRef.current);
42
+ } else {
43
+ ref.current = elementRef.current;
44
+ }
45
+ }
46
+ }, [ref]);
47
+
48
+ // Convert React props to web component attributes
49
+ const webComponentProps: Record<string, any> = {
50
+ ...props,
51
+ ref: elementRef,
52
+ };
53
+
54
+ // Add optional attributes only if they have values
55
+ if (placement) {
56
+ webComponentProps.placement = placement;
57
+ }
58
+
59
+ if (offset !== undefined) {
60
+ webComponentProps.offset = offset.toString();
61
+ }
62
+
63
+ if (delay !== undefined) {
64
+ webComponentProps.delay = delay.toString();
65
+ }
66
+
67
+ if (disabled) {
68
+ webComponentProps.disabled = ''; // Boolean attributes as empty string
69
+ }
70
+
71
+ if (flavor) {
72
+ webComponentProps.flavor = flavor;
73
+ }
74
+
75
+ return React.createElement(
76
+ 'ty-tooltip',
77
+ webComponentProps,
78
+ children
79
+ );
80
+ }
81
+ );
82
+
83
+ TyTooltip.displayName = 'TyTooltip';
@@ -0,0 +1,99 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+
3
+ // Type definitions for Ty Wizard component
4
+ export interface TyWizardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
5
+ /** Content area width (accepts px or %) */
6
+ width?: string;
7
+
8
+ /** Total container height including step indicators */
9
+ height?: string;
10
+
11
+ /** ID of currently active step */
12
+ active?: string;
13
+
14
+ /** Comma-separated IDs of completed steps */
15
+ completed?: string;
16
+
17
+ /** Step indicator layout */
18
+ orientation?: 'horizontal' | 'vertical';
19
+
20
+ /** Step change event handler */
21
+ onStepChange?: (event: CustomEvent<WizardStepChangeDetail>) => void;
22
+
23
+ /** Wizard content (TyStep components) */
24
+ children?: React.ReactNode;
25
+ }
26
+
27
+ export interface WizardStepChangeDetail {
28
+ activeId: string;
29
+ activeIndex: number;
30
+ previousId: string | null;
31
+ previousIndex: number | null;
32
+ direction: 'forward' | 'backward' | 'none';
33
+ }
34
+
35
+ // React wrapper for ty-wizard web component
36
+ export const TyWizard = React.forwardRef<HTMLElement, TyWizardProps>(
37
+ ({
38
+ children,
39
+ width,
40
+ height,
41
+ active,
42
+ completed,
43
+ orientation,
44
+ onStepChange,
45
+ ...props
46
+ }, ref) => {
47
+ const elementRef = useRef<HTMLElement>(null);
48
+
49
+ // Handle step change events
50
+ useEffect(() => {
51
+ const element = elementRef.current;
52
+ if (!element) return;
53
+
54
+ const handleStepChange = (event: Event) => {
55
+ if (onStepChange) {
56
+ onStepChange(event as CustomEvent<WizardStepChangeDetail>);
57
+ }
58
+ };
59
+
60
+ element.addEventListener('ty-wizard-step-change', handleStepChange);
61
+
62
+ return () => {
63
+ element.removeEventListener('ty-wizard-step-change', handleStepChange);
64
+ };
65
+ }, [onStepChange]);
66
+
67
+ // Combine refs if needed
68
+ useEffect(() => {
69
+ if (ref && elementRef.current) {
70
+ if (typeof ref === 'function') {
71
+ ref(elementRef.current);
72
+ } else {
73
+ ref.current = elementRef.current;
74
+ }
75
+ }
76
+ }, [ref]);
77
+
78
+ // Convert React props to web component attributes
79
+ const webComponentProps: Record<string, any> = {
80
+ ...props,
81
+ ref: elementRef,
82
+ };
83
+
84
+ // Add string attributes
85
+ if (width) webComponentProps.width = width;
86
+ if (height) webComponentProps.height = height;
87
+ if (active) webComponentProps.active = active;
88
+ if (completed) webComponentProps.completed = completed;
89
+ if (orientation) webComponentProps.orientation = orientation;
90
+
91
+ return React.createElement(
92
+ 'ty-wizard',
93
+ webComponentProps,
94
+ children
95
+ );
96
+ }
97
+ );
98
+
99
+ TyWizard.displayName = 'TyWizard';