tyrell-react 1.0.0-RC12 → 1.0.0-RC14
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/README.md +1 -0
- package/dist/components/TyButton.d.ts +1 -1
- package/dist/components/TyButton.d.ts.map +1 -1
- package/dist/components/TyButton.js +2 -1
- package/dist/components/TyButton.js.map +1 -1
- package/dist/components/TyCalendar.d.ts +5 -0
- package/dist/components/TyCalendar.d.ts.map +1 -1
- package/dist/components/TyCalendar.js +6 -10
- package/dist/components/TyCalendar.js.map +1 -1
- package/dist/components/TyCalendarMonth.d.ts +5 -0
- package/dist/components/TyCalendarMonth.d.ts.map +1 -1
- package/dist/components/TyCalendarMonth.js +5 -7
- package/dist/components/TyCalendarMonth.js.map +1 -1
- package/dist/components/TyCalendarNavigation.d.ts.map +1 -1
- package/dist/components/TyCalendarNavigation.js +2 -6
- package/dist/components/TyCalendarNavigation.js.map +1 -1
- package/dist/components/TyCheckbox.d.ts +4 -1
- package/dist/components/TyCheckbox.d.ts.map +1 -1
- package/dist/components/TyCheckbox.js +2 -9
- package/dist/components/TyCheckbox.js.map +1 -1
- package/dist/components/TyCopy.d.ts +4 -1
- package/dist/components/TyCopy.d.ts.map +1 -1
- package/dist/components/TyCopy.js +2 -7
- package/dist/components/TyCopy.js.map +1 -1
- package/dist/components/TyDatePicker.d.ts +14 -4
- package/dist/components/TyDatePicker.d.ts.map +1 -1
- package/dist/components/TyDatePicker.js +8 -13
- package/dist/components/TyDatePicker.js.map +1 -1
- package/dist/components/TyFileUpload.d.ts.map +1 -1
- package/dist/components/TyFileUpload.js +2 -2
- package/dist/components/TyFileUpload.js.map +1 -1
- package/dist/components/TyIcon.d.ts.map +1 -1
- package/dist/components/TyIcon.js +0 -4
- package/dist/components/TyIcon.js.map +1 -1
- package/dist/components/TyInput.d.ts +6 -2
- package/dist/components/TyInput.d.ts.map +1 -1
- package/dist/components/TyInput.js +2 -11
- package/dist/components/TyInput.js.map +1 -1
- package/dist/components/TyModal.d.ts +21 -2
- package/dist/components/TyModal.d.ts.map +1 -1
- package/dist/components/TyModal.js +21 -18
- package/dist/components/TyModal.js.map +1 -1
- package/dist/components/TyOption.d.ts +3 -3
- package/dist/components/TyOption.d.ts.map +1 -1
- package/dist/components/TyOption.js +2 -3
- package/dist/components/TyOption.js.map +1 -1
- package/dist/components/TyPopup.d.ts +4 -2
- package/dist/components/TyPopup.d.ts.map +1 -1
- package/dist/components/TyPopup.js +4 -10
- package/dist/components/TyPopup.js.map +1 -1
- package/dist/components/TyRadio.d.ts +4 -1
- package/dist/components/TyRadio.d.ts.map +1 -1
- package/dist/components/TyRadio.js +2 -1
- package/dist/components/TyRadio.js.map +1 -1
- package/dist/components/TyRadioGroup.d.ts +4 -1
- package/dist/components/TyRadioGroup.d.ts.map +1 -1
- package/dist/components/TyRadioGroup.js +2 -1
- package/dist/components/TyRadioGroup.js.map +1 -1
- package/dist/components/TyResizeObserver.d.ts.map +1 -1
- package/dist/components/TyResizeObserver.js +2 -5
- package/dist/components/TyResizeObserver.js.map +1 -1
- package/dist/components/TyScrollContainer.d.ts.map +1 -1
- package/dist/components/TyScrollContainer.js +2 -7
- package/dist/components/TyScrollContainer.js.map +1 -1
- package/dist/components/TySelect.d.ts +44 -2
- package/dist/components/TySelect.d.ts.map +1 -1
- package/dist/components/TySelect.js +34 -13
- package/dist/components/TySelect.js.map +1 -1
- package/dist/components/TyStep.d.ts.map +1 -1
- package/dist/components/TyStep.js +2 -6
- package/dist/components/TyStep.js.map +1 -1
- package/dist/components/TySwitch.d.ts +4 -1
- package/dist/components/TySwitch.d.ts.map +1 -1
- package/dist/components/TySwitch.js +2 -1
- package/dist/components/TySwitch.js.map +1 -1
- package/dist/components/TyTab.d.ts.map +1 -1
- package/dist/components/TyTab.js +2 -7
- package/dist/components/TyTab.js.map +1 -1
- package/dist/components/TyTabs.d.ts.map +1 -1
- package/dist/components/TyTabs.js +2 -6
- package/dist/components/TyTabs.js.map +1 -1
- package/dist/components/TyTag.d.ts +4 -1
- package/dist/components/TyTag.d.ts.map +1 -1
- package/dist/components/TyTag.js +2 -3
- package/dist/components/TyTag.js.map +1 -1
- package/dist/components/TyTextarea.d.ts.map +1 -1
- package/dist/components/TyTextarea.js +2 -7
- package/dist/components/TyTextarea.js.map +1 -1
- package/dist/components/TyTooltip.d.ts +7 -3
- package/dist/components/TyTooltip.d.ts.map +1 -1
- package/dist/components/TyTooltip.js +2 -5
- package/dist/components/TyTooltip.js.map +1 -1
- package/dist/components/TyWizard.d.ts.map +1 -1
- package/dist/components/TyWizard.js +2 -6
- package/dist/components/TyWizard.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -63
- package/dist/components/index.js.map +1 -1
- package/dist/utils/host-props.d.ts +11 -0
- package/dist/utils/host-props.d.ts.map +1 -0
- package/dist/utils/host-props.js +16 -0
- package/dist/utils/host-props.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/components/TyButton.tsx +3 -2
- package/src/components/TyCalendar.tsx +14 -11
- package/src/components/TyCalendarMonth.tsx +11 -8
- package/src/components/TyCalendarNavigation.tsx +2 -7
- package/src/components/TyCheckbox.tsx +6 -11
- package/src/components/TyCopy.tsx +6 -9
- package/src/components/TyDatePicker.tsx +31 -19
- package/src/components/TyFileUpload.tsx +2 -3
- package/src/components/TyIcon.tsx +0 -5
- package/src/components/TyInput.tsx +8 -15
- package/src/components/TyModal.tsx +46 -22
- package/src/components/TyOption.tsx +5 -7
- package/src/components/TyPopup.tsx +12 -14
- package/src/components/TyRadio.tsx +6 -2
- package/src/components/TyRadioGroup.tsx +6 -2
- package/src/components/TyResizeObserver.tsx +2 -6
- package/src/components/TyScrollContainer.tsx +2 -9
- package/src/components/TySelect.tsx +88 -22
- package/src/components/TyStep.tsx +2 -7
- package/src/components/TySwitch.tsx +6 -2
- package/src/components/TyTab.tsx +2 -8
- package/src/components/TyTabs.tsx +2 -7
- package/src/components/TyTag.tsx +6 -5
- package/src/components/TyTextarea.tsx +2 -9
- package/src/components/TyTooltip.tsx +13 -9
- package/src/components/TyWizard.tsx +2 -7
- package/src/components/index.ts +3 -98
- package/src/utils/host-props.ts +14 -0
- package/src/version.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
|
-
// Type definitions for Ty Step component
|
|
4
4
|
export interface TyStepProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
5
|
/** Required unique identifier for the step */
|
|
6
6
|
id: string;
|
|
@@ -21,7 +21,6 @@ export interface TyStepProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
21
21
|
children?: React.ReactNode;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// React wrapper for ty-step web component
|
|
25
24
|
export const TyStep = React.forwardRef<HTMLElement, TyStepProps>(
|
|
26
25
|
({
|
|
27
26
|
children,
|
|
@@ -34,7 +33,6 @@ export const TyStep = React.forwardRef<HTMLElement, TyStepProps>(
|
|
|
34
33
|
}, ref) => {
|
|
35
34
|
const elementRef = useRef<HTMLElement>(null);
|
|
36
35
|
|
|
37
|
-
// Combine refs if needed
|
|
38
36
|
useEffect(() => {
|
|
39
37
|
if (ref && elementRef.current) {
|
|
40
38
|
if (typeof ref === 'function') {
|
|
@@ -45,19 +43,16 @@ export const TyStep = React.forwardRef<HTMLElement, TyStepProps>(
|
|
|
45
43
|
}
|
|
46
44
|
}, [ref]);
|
|
47
45
|
|
|
48
|
-
// Convert React props to web component attributes
|
|
49
46
|
const webComponentProps: Record<string, any> = {
|
|
50
|
-
...props,
|
|
47
|
+
...hostProps(props),
|
|
51
48
|
ref: elementRef,
|
|
52
49
|
id,
|
|
53
50
|
};
|
|
54
51
|
|
|
55
|
-
// Add string attributes
|
|
56
52
|
if (label) webComponentProps.label = label;
|
|
57
53
|
if (description) webComponentProps.description = description;
|
|
58
54
|
if (status) webComponentProps.status = status;
|
|
59
55
|
|
|
60
|
-
// Add boolean attributes
|
|
61
56
|
if (disabled) webComponentProps.disabled = true;
|
|
62
57
|
|
|
63
58
|
return React.createElement(
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { useBooleanProperty } from '../utils/use-boolean-prop';
|
|
3
4
|
|
|
5
|
+
type BuiltinFlavor = 'primary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
|
|
4
8
|
export interface TySwitchProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange' | 'onInput'> {
|
|
5
9
|
/** Checked (on) state */
|
|
6
10
|
checked?: boolean;
|
|
@@ -21,7 +25,7 @@ export interface TySwitchProps extends Omit<React.HTMLAttributes<HTMLElement>, '
|
|
|
21
25
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
22
26
|
|
|
23
27
|
/** Semantic styling variant */
|
|
24
|
-
flavor?:
|
|
28
|
+
flavor?: ShadedFlavor | (string & {});
|
|
25
29
|
|
|
26
30
|
/**
|
|
27
31
|
* Fires when switch state changes (React convention)
|
|
@@ -94,7 +98,7 @@ export const TySwitch = React.forwardRef<HTMLElement, TySwitchProps>(
|
|
|
94
98
|
const isRequired = useBooleanProperty(elementRef, 'required', required);
|
|
95
99
|
|
|
96
100
|
const webComponentProps: Record<string, any> = {
|
|
97
|
-
...props,
|
|
101
|
+
...hostProps(props),
|
|
98
102
|
ref: elementRef,
|
|
99
103
|
};
|
|
100
104
|
|
package/src/components/TyTab.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { useBooleanProperty } from '../utils/use-boolean-prop';
|
|
3
4
|
|
|
4
|
-
// Type definitions for Ty Tab component
|
|
5
5
|
export interface TyTabProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
6
|
/** Required unique identifier */
|
|
7
7
|
id: string;
|
|
@@ -16,7 +16,6 @@ export interface TyTabProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
16
16
|
children?: React.ReactNode;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// React wrapper for ty-tab web component
|
|
20
19
|
export const TyTab = React.forwardRef<HTMLElement, TyTabProps>(
|
|
21
20
|
({
|
|
22
21
|
children,
|
|
@@ -27,7 +26,6 @@ export const TyTab = React.forwardRef<HTMLElement, TyTabProps>(
|
|
|
27
26
|
}, ref) => {
|
|
28
27
|
const elementRef = useRef<HTMLElement>(null);
|
|
29
28
|
|
|
30
|
-
// Combine refs if needed
|
|
31
29
|
useEffect(() => {
|
|
32
30
|
if (ref && elementRef.current) {
|
|
33
31
|
if (typeof ref === 'function') {
|
|
@@ -38,20 +36,16 @@ export const TyTab = React.forwardRef<HTMLElement, TyTabProps>(
|
|
|
38
36
|
}
|
|
39
37
|
}, [ref]);
|
|
40
38
|
|
|
41
|
-
// Convert React props to web component attributes
|
|
42
39
|
const webComponentProps: Record<string, any> = {
|
|
43
|
-
...props,
|
|
40
|
+
...hostProps(props),
|
|
44
41
|
ref: elementRef,
|
|
45
42
|
};
|
|
46
43
|
|
|
47
|
-
// Add required attribute
|
|
48
44
|
webComponentProps.id = id;
|
|
49
45
|
|
|
50
|
-
// Add boolean attributes
|
|
51
46
|
const isDisabled = useBooleanProperty(elementRef, 'disabled', disabled);
|
|
52
47
|
if (isDisabled) webComponentProps.disabled = '';
|
|
53
48
|
|
|
54
|
-
// Add string attributes
|
|
55
49
|
if (label) webComponentProps.label = label;
|
|
56
50
|
|
|
57
51
|
return React.createElement(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
|
-
// Type definitions for Ty Tabs component
|
|
4
4
|
export interface TyTabsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
5
5
|
/** Content area width (accepts px or %) */
|
|
6
6
|
width?: string;
|
|
@@ -28,7 +28,6 @@ export interface TabChangeDetail {
|
|
|
28
28
|
previousIndex: number | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// React wrapper for ty-tabs web component
|
|
32
31
|
export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
|
|
33
32
|
({
|
|
34
33
|
children,
|
|
@@ -41,7 +40,6 @@ export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
|
|
|
41
40
|
}, ref) => {
|
|
42
41
|
const elementRef = useRef<HTMLElement>(null);
|
|
43
42
|
|
|
44
|
-
// Handle change events
|
|
45
43
|
useEffect(() => {
|
|
46
44
|
const element = elementRef.current;
|
|
47
45
|
if (!element) return;
|
|
@@ -59,7 +57,6 @@ export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
|
|
|
59
57
|
};
|
|
60
58
|
}, [onChange]);
|
|
61
59
|
|
|
62
|
-
// Combine refs if needed
|
|
63
60
|
useEffect(() => {
|
|
64
61
|
if (ref && elementRef.current) {
|
|
65
62
|
if (typeof ref === 'function') {
|
|
@@ -70,13 +67,11 @@ export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
|
|
|
70
67
|
}
|
|
71
68
|
}, [ref]);
|
|
72
69
|
|
|
73
|
-
// Convert React props to web component attributes
|
|
74
70
|
const webComponentProps: Record<string, any> = {
|
|
75
|
-
...props,
|
|
71
|
+
...hostProps(props),
|
|
76
72
|
ref: elementRef,
|
|
77
73
|
};
|
|
78
74
|
|
|
79
|
-
// Add string attributes
|
|
80
75
|
if (width) webComponentProps.width = width;
|
|
81
76
|
if (height) webComponentProps.height = height;
|
|
82
77
|
if (active) webComponentProps.active = active;
|
package/src/components/TyTag.tsx
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { useBooleanProperty } from '../utils/use-boolean-prop';
|
|
3
4
|
|
|
5
|
+
type BuiltinFlavor = 'primary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
|
|
4
8
|
// CSS custom properties that cascade into the shadow DOM for full color control
|
|
5
9
|
export interface TyTagCSSProperties extends React.CSSProperties {
|
|
6
10
|
'--tag-bg'?: string;
|
|
@@ -8,9 +12,8 @@ export interface TyTagCSSProperties extends React.CSSProperties {
|
|
|
8
12
|
'--tag-border-color'?: string;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
// Type definitions for Ty Tag component
|
|
12
15
|
export interface TyTagProps extends Omit<React.HTMLAttributes<HTMLElement>, 'style' | 'onClick'> {
|
|
13
|
-
flavor?:
|
|
16
|
+
flavor?: ShadedFlavor | (string & {});
|
|
14
17
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
15
18
|
notPill?: boolean;
|
|
16
19
|
clickable?: boolean;
|
|
@@ -25,7 +28,6 @@ export interface TyTagProps extends Omit<React.HTMLAttributes<HTMLElement>, 'sty
|
|
|
25
28
|
children?: React.ReactNode;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
// React wrapper for ty-tag web component
|
|
29
31
|
export const TyTag = React.forwardRef<HTMLElement, TyTagProps>(
|
|
30
32
|
({ children, onClick, onTagDismiss, notPill, clickable, dismissible, disabled, selected, ...props }, ref) => {
|
|
31
33
|
const elementRef = useRef<HTMLElement>(null);
|
|
@@ -47,7 +49,6 @@ export const TyTag = React.forwardRef<HTMLElement, TyTagProps>(
|
|
|
47
49
|
};
|
|
48
50
|
}, [handleDismiss, onTagDismiss]);
|
|
49
51
|
|
|
50
|
-
// Handle ref forwarding
|
|
51
52
|
useEffect(() => {
|
|
52
53
|
if (ref && elementRef.current) {
|
|
53
54
|
if (typeof ref === 'function') {
|
|
@@ -67,7 +68,7 @@ export const TyTag = React.forwardRef<HTMLElement, TyTagProps>(
|
|
|
67
68
|
return React.createElement(
|
|
68
69
|
'ty-tag',
|
|
69
70
|
{
|
|
70
|
-
...props,
|
|
71
|
+
...hostProps(props),
|
|
71
72
|
// click is dispatched as composed CustomEvent by the web component — React's
|
|
72
73
|
// synthetic onClick already catches it, so we just pass it through as onClick
|
|
73
74
|
...(onClick && { onClick }),
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { needsPropertyBridge } from '../utils/react-version';
|
|
3
4
|
import { useBooleanProperty } from '../utils/use-boolean-prop';
|
|
4
5
|
|
|
5
|
-
// Event detail structure for ty-textarea events
|
|
6
6
|
export interface TyTextareaEventDetail {
|
|
7
7
|
value: string; // textarea value
|
|
8
8
|
originalEvent: Event; // original DOM event
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// Type definitions for Ty Textarea component
|
|
12
11
|
export interface TyTextareaProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange' | 'onInput' | 'onFocus' | 'onBlur' | 'style'> {
|
|
13
12
|
style?: import('./TyInput').TyInputCSSProperties;
|
|
14
13
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -50,7 +49,6 @@ export interface TyTextareaProps extends Omit<React.HTMLAttributes<HTMLElement>,
|
|
|
50
49
|
// One-time warning flag.
|
|
51
50
|
let _warnedOnInputProp = false;
|
|
52
51
|
|
|
53
|
-
// React wrapper for ty-textarea web component
|
|
54
52
|
export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
|
|
55
53
|
({ onChange, onChangeCommit, onFocus, onBlur, disabled, required, minHeight, maxHeight, ...props }, ref) => {
|
|
56
54
|
const elementRef = useRef<HTMLElement>(null);
|
|
@@ -101,18 +99,14 @@ export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
|
|
|
101
99
|
const element = elementRef.current;
|
|
102
100
|
if (!element) return;
|
|
103
101
|
|
|
104
|
-
// Listen for custom input/change events from ty-textarea
|
|
105
|
-
// Map onChange → input event (React convention)
|
|
106
102
|
if (onChange) {
|
|
107
103
|
element.addEventListener('input', handleInput as EventListener);
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
// Map onChangeCommit → change event (blur behavior)
|
|
111
106
|
if (onChangeCommit) {
|
|
112
107
|
element.addEventListener('change', handleChangeCommit as EventListener);
|
|
113
108
|
}
|
|
114
109
|
|
|
115
|
-
// Listen for standard focus/blur events
|
|
116
110
|
if (onFocus) {
|
|
117
111
|
element.addEventListener('focus', handleFocus as EventListener);
|
|
118
112
|
}
|
|
@@ -137,7 +131,6 @@ export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
|
|
|
137
131
|
};
|
|
138
132
|
}, [handleInput, handleChangeCommit, handleFocus, handleBlur, onChange, onChangeCommit, onFocus, onBlur]);
|
|
139
133
|
|
|
140
|
-
// Handle ref forwarding
|
|
141
134
|
useEffect(() => {
|
|
142
135
|
if (ref && elementRef.current) {
|
|
143
136
|
if (typeof ref === 'function') {
|
|
@@ -167,7 +160,7 @@ export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
|
|
|
167
160
|
return React.createElement(
|
|
168
161
|
'ty-textarea',
|
|
169
162
|
{
|
|
170
|
-
...props,
|
|
163
|
+
...hostProps(props),
|
|
171
164
|
...(isDisabled && { disabled: "" }),
|
|
172
165
|
...(isRequired && { required: "" }),
|
|
173
166
|
...(minHeight && { 'min-height': minHeight }), // Convert camelCase to kebab-case
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { useBooleanProperty } from '../utils/use-boolean-prop';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
type BuiltinFlavor = 'primary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
type Placement =
|
|
8
|
+
| 'top-start' | 'top' | 'top-end'
|
|
9
|
+
| 'right-start' | 'right' | 'right-end'
|
|
10
|
+
| 'bottom-start' | 'bottom' | 'bottom-end'
|
|
11
|
+
| 'left-start' | 'left' | 'left-end';
|
|
12
|
+
|
|
5
13
|
export interface TyTooltipProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
-
/** Tooltip positioning relative to the parent element */
|
|
7
|
-
placement?:
|
|
14
|
+
/** Tooltip positioning relative to the parent element: a side plus an optional cross-axis alignment (e.g. "bottom-start") */
|
|
15
|
+
placement?: Placement;
|
|
8
16
|
|
|
9
17
|
/** Distance in pixels from the anchor element (default: 8) */
|
|
10
18
|
offset?: number;
|
|
@@ -16,13 +24,12 @@ export interface TyTooltipProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
16
24
|
disabled?: boolean;
|
|
17
25
|
|
|
18
26
|
/** Semantic styling variant */
|
|
19
|
-
flavor?: 'dark' | 'light' | '
|
|
27
|
+
flavor?: 'dark' | 'light' | 'info' | ShadedFlavor | (string & {});
|
|
20
28
|
|
|
21
29
|
/** Tooltip content */
|
|
22
30
|
children?: React.ReactNode;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
// React wrapper for ty-tooltip web component
|
|
26
33
|
export const TyTooltip = React.forwardRef<HTMLElement, TyTooltipProps>(
|
|
27
34
|
({
|
|
28
35
|
placement,
|
|
@@ -35,7 +42,6 @@ export const TyTooltip = React.forwardRef<HTMLElement, TyTooltipProps>(
|
|
|
35
42
|
}, ref) => {
|
|
36
43
|
const elementRef = useRef<HTMLElement>(null);
|
|
37
44
|
|
|
38
|
-
// Handle ref forwarding
|
|
39
45
|
useEffect(() => {
|
|
40
46
|
if (ref && elementRef.current) {
|
|
41
47
|
if (typeof ref === 'function') {
|
|
@@ -46,13 +52,11 @@ export const TyTooltip = React.forwardRef<HTMLElement, TyTooltipProps>(
|
|
|
46
52
|
}
|
|
47
53
|
}, [ref]);
|
|
48
54
|
|
|
49
|
-
// Convert React props to web component attributes
|
|
50
55
|
const webComponentProps: Record<string, any> = {
|
|
51
|
-
...props,
|
|
56
|
+
...hostProps(props),
|
|
52
57
|
ref: elementRef,
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
// Add optional attributes only if they have values
|
|
56
60
|
if (placement) {
|
|
57
61
|
webComponentProps.placement = placement;
|
|
58
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
|
-
// Type definitions for Ty Wizard component
|
|
4
4
|
export interface TyWizardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
5
5
|
/** Content area width (accepts px or %) */
|
|
6
6
|
width?: string;
|
|
@@ -32,7 +32,6 @@ export interface WizardStepChangeDetail {
|
|
|
32
32
|
direction: 'forward' | 'backward' | 'none';
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// React wrapper for ty-wizard web component
|
|
36
35
|
export const TyWizard = React.forwardRef<HTMLElement, TyWizardProps>(
|
|
37
36
|
({
|
|
38
37
|
children,
|
|
@@ -46,7 +45,6 @@ export const TyWizard = React.forwardRef<HTMLElement, TyWizardProps>(
|
|
|
46
45
|
}, ref) => {
|
|
47
46
|
const elementRef = useRef<HTMLElement>(null);
|
|
48
47
|
|
|
49
|
-
// Handle step change events
|
|
50
48
|
useEffect(() => {
|
|
51
49
|
const element = elementRef.current;
|
|
52
50
|
if (!element) return;
|
|
@@ -64,7 +62,6 @@ export const TyWizard = React.forwardRef<HTMLElement, TyWizardProps>(
|
|
|
64
62
|
};
|
|
65
63
|
}, [onStepChange]);
|
|
66
64
|
|
|
67
|
-
// Combine refs if needed
|
|
68
65
|
useEffect(() => {
|
|
69
66
|
if (ref && elementRef.current) {
|
|
70
67
|
if (typeof ref === 'function') {
|
|
@@ -75,13 +72,11 @@ export const TyWizard = React.forwardRef<HTMLElement, TyWizardProps>(
|
|
|
75
72
|
}
|
|
76
73
|
}, [ref]);
|
|
77
74
|
|
|
78
|
-
// Convert React props to web component attributes
|
|
79
75
|
const webComponentProps: Record<string, any> = {
|
|
80
|
-
...props,
|
|
76
|
+
...hostProps(props),
|
|
81
77
|
ref: elementRef,
|
|
82
78
|
};
|
|
83
79
|
|
|
84
|
-
// Add string attributes
|
|
85
80
|
if (width) webComponentProps.width = width;
|
|
86
81
|
if (height) webComponentProps.height = height;
|
|
87
82
|
if (active) webComponentProps.active = active;
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// ===================================================================
|
|
2
|
-
// VERSION
|
|
3
|
-
// ===================================================================
|
|
4
|
-
|
|
5
1
|
import { VERSION } from '../version';
|
|
6
2
|
|
|
7
3
|
/** Current version of tyrell-react (auto-synced with package.json on build). */
|
|
@@ -19,18 +15,8 @@ if (typeof window !== 'undefined') {
|
|
|
19
15
|
);
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
// ===================================================================
|
|
25
|
-
// This file provides two export styles for maximum developer flexibility:
|
|
26
|
-
// 1. Ty-prefixed exports (TyButton, TyInput) - explicit and backward compatible
|
|
27
|
-
// 2. Short name exports (Button, Input) - clean and familiar to React developers
|
|
28
|
-
//
|
|
29
|
-
// Choose the style that fits your team's preferences!
|
|
30
|
-
|
|
31
|
-
// ===================================================================
|
|
32
|
-
// TY-PREFIXED EXPORTS (Explicit Style - Backward Compatible)
|
|
33
|
-
// ===================================================================
|
|
18
|
+
// Every component is exported twice: Ty-prefixed (TyButton) and short
|
|
19
|
+
// (Button). Both names point at the same wrapper — pick one per project.
|
|
34
20
|
|
|
35
21
|
export { TyButton } from './TyButton';
|
|
36
22
|
export type { TyButtonProps, TyButtonCSSProperties } from './TyButton';
|
|
@@ -59,7 +45,7 @@ export type { TyModalProps as TyDialogProps, TyModalEventDetail as TyDialogEvent
|
|
|
59
45
|
export { TyTooltip } from './TyTooltip';
|
|
60
46
|
export type { TyTooltipProps } from './TyTooltip';
|
|
61
47
|
|
|
62
|
-
export { TySelect, TySelectedTags } from './TySelect';
|
|
48
|
+
export { TySelect, TySelectedOptions, TySelectedTags } from './TySelect';
|
|
63
49
|
export type { TySelectProps, TySelectEventDetail, TySelectItem, TySelectedTagsProps } from './TySelect';
|
|
64
50
|
|
|
65
51
|
export { TyCalendar } from './TyCalendar';
|
|
@@ -116,11 +102,6 @@ export type { TyResizeObserverProps } from './TyResizeObserver';
|
|
|
116
102
|
export { TyScrollContainer } from './TyScrollContainer';
|
|
117
103
|
export type { TyScrollContainerProps, TyScrollContainerRef } from './TyScrollContainer';
|
|
118
104
|
|
|
119
|
-
|
|
120
|
-
// ===================================================================
|
|
121
|
-
// SHORT NAME EXPORTS (Clean Style - Developer Choice)
|
|
122
|
-
// ===================================================================
|
|
123
|
-
|
|
124
105
|
export { TyButton as Button } from './TyButton';
|
|
125
106
|
export { TyTag as Tag } from './TyTag';
|
|
126
107
|
export { TyInput as Input } from './TyInput';
|
|
@@ -147,128 +128,52 @@ export { TyStep as Step } from './TyStep';
|
|
|
147
128
|
export { TyResizeObserver as ResizeObserver } from './TyResizeObserver';
|
|
148
129
|
export { TyScrollContainer as ScrollContainer } from './TyScrollContainer';
|
|
149
130
|
|
|
150
|
-
// ===================================================================
|
|
151
|
-
// TYPE ALIASES (Both Styles Supported)
|
|
152
|
-
// ===================================================================
|
|
153
|
-
|
|
154
|
-
// Button types
|
|
155
131
|
export type { TyButtonProps as ButtonProps } from './TyButton';
|
|
156
132
|
|
|
157
|
-
// Tag types
|
|
158
133
|
export type { TyTagProps as TagProps } from './TyTag';
|
|
159
134
|
|
|
160
|
-
// Input types
|
|
161
135
|
export type { TyInputProps as InputProps, TyInputEventDetail as InputEventDetail } from './TyInput';
|
|
162
136
|
|
|
163
|
-
// Textarea types
|
|
164
137
|
export type { TyTextareaProps as TextareaProps, TyTextareaEventDetail as TextareaEventDetail } from './TyTextarea';
|
|
165
138
|
|
|
166
|
-
// Option types
|
|
167
139
|
export type { TyOptionProps as OptionProps } from './TyOption';
|
|
168
140
|
|
|
169
|
-
// Icon types
|
|
170
141
|
export type { TyIconProps as IconProps } from './TyIcon';
|
|
171
142
|
|
|
172
|
-
// Modal types
|
|
173
143
|
export type { TyModalProps as ModalProps, TyModalEventDetail as ModalEventDetail, TyModalRef as ModalRef } from './TyModal';
|
|
174
144
|
|
|
175
|
-
// Tooltip types
|
|
176
145
|
export type { TyTooltipProps as TooltipProps } from './TyTooltip';
|
|
177
146
|
|
|
178
|
-
// Calendar types
|
|
179
147
|
export type { TyCalendarProps as CalendarProps, TyCalendarChangeEventDetail as CalendarChangeEventDetail, TyCalendarNavigateEventDetail as CalendarNavigateEventDetail } from './TyCalendar';
|
|
180
148
|
|
|
181
|
-
// DatePicker types
|
|
182
149
|
export type { TyDatePickerProps as DatePickerProps, TyDatePickerEventDetail as DatePickerEventDetail } from './TyDatePicker';
|
|
183
150
|
|
|
184
|
-
// Popup types
|
|
185
151
|
export type { TyPopupProps as PopupProps, TyPopupElement as PopupElement } from './TyPopup';
|
|
186
152
|
|
|
187
|
-
// Checkbox types
|
|
188
153
|
export type { TyCheckboxProps as CheckboxProps, TyCheckboxEventDetail as CheckboxEventDetail } from './TyCheckbox';
|
|
189
154
|
|
|
190
|
-
// Switch types
|
|
191
155
|
export type { TySwitchProps as SwitchProps, TySwitchEventDetail as SwitchEventDetail } from './TySwitch';
|
|
192
156
|
|
|
193
|
-
// Radio types
|
|
194
157
|
export type { TyRadioProps as RadioProps } from './TyRadio';
|
|
195
158
|
|
|
196
|
-
// RadioGroup types
|
|
197
159
|
export type { TyRadioGroupProps as RadioGroupProps, TyRadioGroupEventDetail as RadioGroupEventDetail } from './TyRadioGroup';
|
|
198
160
|
|
|
199
|
-
// Copy types
|
|
200
161
|
export type { TyCopyProps as CopyProps } from './TyCopy';
|
|
201
162
|
|
|
202
|
-
// FileUpload types
|
|
203
163
|
export type { TyFileUploadProps as FileUploadProps, TyFileUploadEventDetail as FileUploadEventDetail } from './TyFileUpload';
|
|
204
164
|
|
|
205
|
-
// Tabs types
|
|
206
165
|
export type { TyTabsProps as TabsProps } from './TyTabs';
|
|
207
166
|
|
|
208
|
-
// Tab types
|
|
209
167
|
export type { TyTabProps as TabProps } from './TyTab';
|
|
210
168
|
|
|
211
|
-
// CalendarMonth types
|
|
212
169
|
export type { TyCalendarMonthProps as CalendarMonthProps } from './TyCalendarMonth';
|
|
213
170
|
|
|
214
|
-
// CalendarNavigation types
|
|
215
171
|
export type { TyCalendarNavigationProps as CalendarNavigationProps } from './TyCalendarNavigation';
|
|
216
172
|
|
|
217
|
-
// Wizard types
|
|
218
173
|
export type { TyWizardProps as WizardProps, WizardStepChangeDetail as StepChangeDetail } from './TyWizard';
|
|
219
174
|
|
|
220
|
-
// Step types
|
|
221
175
|
export type { TyStepProps as StepProps } from './TyStep';
|
|
222
176
|
|
|
223
|
-
// ResizeObserver types
|
|
224
177
|
export type { TyResizeObserverProps as ResizeObserverProps } from './TyResizeObserver';
|
|
225
178
|
|
|
226
|
-
// ScrollContainer types
|
|
227
179
|
export type { TyScrollContainerProps as ScrollContainerProps, TyScrollContainerRef as ScrollContainerRef } from './TyScrollContainer';
|
|
228
|
-
|
|
229
|
-
// ===================================================================
|
|
230
|
-
// USAGE EXAMPLES
|
|
231
|
-
// ===================================================================
|
|
232
|
-
|
|
233
|
-
/*
|
|
234
|
-
|
|
235
|
-
// STYLE 1: Ty-prefixed (Explicit and backward compatible)
|
|
236
|
-
import { TyButton, TyInput, TyModal } from 'tyrell-react';
|
|
237
|
-
import type { TyButtonProps, TyInputProps } from 'tyrell-react';
|
|
238
|
-
|
|
239
|
-
function MyComponent() {
|
|
240
|
-
return (
|
|
241
|
-
<TyModal>
|
|
242
|
-
<TyInput placeholder="Enter text..." />
|
|
243
|
-
<TyButton>Submit</TyButton>
|
|
244
|
-
</TyModal>
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// STYLE 2: Short names (Clean and familiar)
|
|
249
|
-
import { Button, Input, Modal } from 'tyrell-react';
|
|
250
|
-
import type { ButtonProps, InputProps } from 'tyrell-react';
|
|
251
|
-
|
|
252
|
-
function MyComponent() {
|
|
253
|
-
return (
|
|
254
|
-
<Modal>
|
|
255
|
-
<Input placeholder="Enter text..." />
|
|
256
|
-
<Button>Submit</Button>
|
|
257
|
-
</Modal>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// STYLE 3: Mixed (Team preferences)
|
|
262
|
-
import { TyModal, Input, Button } from 'tyrell-react';
|
|
263
|
-
import type { TyModalProps, InputProps } from 'tyrell-react';
|
|
264
|
-
|
|
265
|
-
function MyComponent() {
|
|
266
|
-
return (
|
|
267
|
-
<TyModal>
|
|
268
|
-
<Input placeholder="Enter text..." />
|
|
269
|
-
<Button>Submit</Button>
|
|
270
|
-
</TyModal>
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize pass-through props for a custom-element host.
|
|
3
|
+
*
|
|
4
|
+
* React 18 does not special-case `className` on custom elements — it
|
|
5
|
+
* lowercases the prop into a literal `classname=""` attribute, which no CSS
|
|
6
|
+
* ever matches. Renaming it to `class` makes React pass it through verbatim,
|
|
7
|
+
* so host-level utility classes (layout, positioning) actually apply.
|
|
8
|
+
* React 19 handles `className` natively; this stays harmless there.
|
|
9
|
+
*/
|
|
10
|
+
export function hostProps<T extends Record<string, any>>(props: T): Record<string, any> {
|
|
11
|
+
const { className, ...rest } = props;
|
|
12
|
+
if (className != null) (rest as Record<string, any>).class = className;
|
|
13
|
+
return rest;
|
|
14
|
+
}
|
package/src/version.ts
CHANGED