tyrell-react 1.0.0-RC12 → 1.0.0-RC13
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.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 -2
- 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 -2
- package/dist/components/TyCalendarMonth.js.map +1 -1
- package/dist/components/TyCalendarNavigation.d.ts.map +1 -1
- package/dist/components/TyCalendarNavigation.js +2 -1
- 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 -1
- 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 -1
- package/dist/components/TyCopy.js.map +1 -1
- package/dist/components/TyDatePicker.d.ts +11 -4
- package/dist/components/TyDatePicker.d.ts.map +1 -1
- package/dist/components/TyDatePicker.js +2 -1
- package/dist/components/TyDatePicker.js.map +1 -1
- package/dist/components/TyFileUpload.d.ts.map +1 -1
- package/dist/components/TyFileUpload.js +2 -1
- package/dist/components/TyFileUpload.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 -1
- package/dist/components/TyInput.js.map +1 -1
- package/dist/components/TyModal.d.ts +5 -0
- package/dist/components/TyModal.d.ts.map +1 -1
- package/dist/components/TyModal.js +5 -2
- package/dist/components/TyModal.js.map +1 -1
- package/dist/components/TyOption.d.ts +2 -2
- package/dist/components/TyOption.d.ts.map +1 -1
- package/dist/components/TyOption.js +2 -1
- package/dist/components/TyOption.js.map +1 -1
- package/dist/components/TyPopup.d.ts.map +1 -1
- package/dist/components/TyPopup.js +2 -1
- 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 -1
- package/dist/components/TyResizeObserver.js.map +1 -1
- package/dist/components/TyScrollContainer.d.ts.map +1 -1
- package/dist/components/TyScrollContainer.js +2 -1
- package/dist/components/TyScrollContainer.js.map +1 -1
- package/dist/components/TySelect.d.ts +41 -2
- package/dist/components/TySelect.d.ts.map +1 -1
- package/dist/components/TySelect.js +32 -7
- package/dist/components/TySelect.js.map +1 -1
- package/dist/components/TyStep.d.ts.map +1 -1
- package/dist/components/TyStep.js +2 -1
- 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 -1
- package/dist/components/TyTab.js.map +1 -1
- package/dist/components/TyTabs.d.ts.map +1 -1
- package/dist/components/TyTabs.js +2 -1
- 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 -1
- package/dist/components/TyTag.js.map +1 -1
- package/dist/components/TyTextarea.d.ts.map +1 -1
- package/dist/components/TyTextarea.js +2 -1
- package/dist/components/TyTextarea.js.map +1 -1
- package/dist/components/TyTooltip.d.ts +4 -1
- package/dist/components/TyTooltip.d.ts.map +1 -1
- package/dist/components/TyTooltip.js +2 -1
- package/dist/components/TyTooltip.js.map +1 -1
- package/dist/components/TyWizard.d.ts.map +1 -1
- package/dist/components/TyWizard.js +2 -1
- 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 +1 -1
- 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 +2 -1
- package/src/components/TyCalendar.tsx +14 -2
- package/src/components/TyCalendarMonth.tsx +11 -2
- package/src/components/TyCalendarNavigation.tsx +2 -1
- package/src/components/TyCheckbox.tsx +6 -2
- package/src/components/TyCopy.tsx +6 -2
- package/src/components/TyDatePicker.tsx +15 -6
- package/src/components/TyFileUpload.tsx +2 -1
- package/src/components/TyInput.tsx +8 -3
- package/src/components/TyModal.tsx +10 -1
- package/src/components/TyOption.tsx +4 -3
- package/src/components/TyPopup.tsx +2 -1
- package/src/components/TyRadio.tsx +6 -2
- package/src/components/TyRadioGroup.tsx +6 -2
- package/src/components/TyResizeObserver.tsx +2 -1
- package/src/components/TyScrollContainer.tsx +2 -1
- package/src/components/TySelect.tsx +78 -13
- package/src/components/TyStep.tsx +2 -1
- package/src/components/TySwitch.tsx +6 -2
- package/src/components/TyTab.tsx +2 -1
- package/src/components/TyTabs.tsx +2 -1
- package/src/components/TyTag.tsx +6 -2
- package/src/components/TyTextarea.tsx +2 -1
- package/src/components/TyTooltip.tsx +6 -2
- package/src/components/TyWizard.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/utils/host-props.ts +14 -0
- package/src/version.ts +1 -1
|
@@ -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' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
|
|
4
8
|
// Type definitions for Ty Copy component
|
|
5
9
|
export interface TyCopyProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
6
10
|
/** Text to copy */
|
|
@@ -13,7 +17,7 @@ export interface TyCopyProps extends Omit<React.HTMLAttributes<HTMLElement>, 'on
|
|
|
13
17
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
14
18
|
|
|
15
19
|
/** Semantic styling variant */
|
|
16
|
-
flavor?:
|
|
20
|
+
flavor?: ShadedFlavor | (string & {});
|
|
17
21
|
|
|
18
22
|
/** Display format */
|
|
19
23
|
format?: 'text' | 'code';
|
|
@@ -84,7 +88,7 @@ export const TyCopy = React.forwardRef<HTMLElement, TyCopyProps>(
|
|
|
84
88
|
|
|
85
89
|
// Convert React props to web component attributes
|
|
86
90
|
const webComponentProps: Record<string, any> = {
|
|
87
|
-
...props,
|
|
91
|
+
...hostProps(props),
|
|
88
92
|
ref: elementRef,
|
|
89
93
|
};
|
|
90
94
|
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
|
|
6
|
+
type BuiltinFlavor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
7
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
8
|
+
|
|
5
9
|
// Type definitions for Ty DatePicker component
|
|
6
10
|
export interface TyDatePickerEventDetail {
|
|
7
11
|
/** The selected date value (ISO string or formatted string based on format) */
|
|
@@ -18,11 +22,11 @@ export interface TyDatePickerProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
18
22
|
/** The selected date value (ISO string or formatted string) */
|
|
19
23
|
value?: string;
|
|
20
24
|
|
|
21
|
-
/**
|
|
25
|
+
/** Field size — fields come in exactly three; legacy xs/xl map to sm/lg */
|
|
22
26
|
size?: 'sm' | 'md' | 'lg';
|
|
23
27
|
|
|
24
|
-
/** Visual flavor
|
|
25
|
-
flavor?: 'default' |
|
|
28
|
+
/** Visual flavor — built-in semantic, +/- shade, or a custom flavor backed by --ty-*-X tokens. Also tints the popup calendar's selected/today day. */
|
|
29
|
+
flavor?: 'default' | ShadedFlavor | (string & {});
|
|
26
30
|
|
|
27
31
|
/** Label text displayed above the input */
|
|
28
32
|
label?: string;
|
|
@@ -67,8 +71,13 @@ export interface TyDatePickerProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
67
71
|
onClose?: (event: CustomEvent<{}>) => void;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
/** The underlying custom element, typed with its imperative clear() method. */
|
|
75
|
+
export interface TyDatePickerElement extends HTMLElement {
|
|
76
|
+
clear(): void;
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
// React wrapper for ty-date-picker web component
|
|
71
|
-
export const TyDatePicker = React.forwardRef<
|
|
80
|
+
export const TyDatePicker = React.forwardRef<TyDatePickerElement, TyDatePickerProps>(
|
|
72
81
|
({
|
|
73
82
|
value,
|
|
74
83
|
size,
|
|
@@ -89,7 +98,7 @@ export const TyDatePicker = React.forwardRef<HTMLElement, TyDatePickerProps>(
|
|
|
89
98
|
onClose,
|
|
90
99
|
...props
|
|
91
100
|
}, ref) => {
|
|
92
|
-
const elementRef = useRef<
|
|
101
|
+
const elementRef = useRef<TyDatePickerElement>(null);
|
|
93
102
|
|
|
94
103
|
// Handle ref forwarding
|
|
95
104
|
useEffect(() => {
|
|
@@ -167,7 +176,7 @@ export const TyDatePicker = React.forwardRef<HTMLElement, TyDatePickerProps>(
|
|
|
167
176
|
|
|
168
177
|
// Convert React props to web component attributes
|
|
169
178
|
const webComponentProps: Record<string, any> = {
|
|
170
|
-
...props,
|
|
179
|
+
...hostProps(props),
|
|
171
180
|
ref: elementRef,
|
|
172
181
|
};
|
|
173
182
|
|
|
@@ -1,4 +1,5 @@
|
|
|
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 definitions for Ty File Upload component
|
|
@@ -87,7 +88,7 @@ export const TyFileUpload = React.forwardRef<HTMLElement, TyFileUploadProps>(
|
|
|
87
88
|
const isRequired = useBooleanProperty(elementRef, 'required', required);
|
|
88
89
|
|
|
89
90
|
const webComponentProps: Record<string, any> = {
|
|
90
|
-
...props,
|
|
91
|
+
...hostProps(props),
|
|
91
92
|
ref: elementRef,
|
|
92
93
|
};
|
|
93
94
|
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
|
|
6
|
+
type BuiltinFlavor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
7
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
8
|
+
|
|
5
9
|
// Event detail structure for ty-input events
|
|
6
10
|
export interface TyInputEventDetail {
|
|
7
11
|
value: any; // shadow value (processed/parsed)
|
|
@@ -31,10 +35,11 @@ export interface TyInputProps extends Omit<React.HTMLAttributes<HTMLElement>, 'o
|
|
|
31
35
|
| 'currency' | 'percent' | 'compact';
|
|
32
36
|
|
|
33
37
|
/** Semantic styling variant */
|
|
34
|
-
flavor?:
|
|
38
|
+
flavor?: ShadedFlavor | (string & {});
|
|
35
39
|
|
|
36
40
|
/** Input size */
|
|
37
|
-
size
|
|
41
|
+
/** Field size — fields come in exactly three; legacy xs/xl map to sm/lg */
|
|
42
|
+
size?: 'sm' | 'md' | 'lg';
|
|
38
43
|
|
|
39
44
|
/** Input value */
|
|
40
45
|
value?: string;
|
|
@@ -214,7 +219,7 @@ export const TyInput = React.forwardRef<HTMLElement, TyInputProps>(
|
|
|
214
219
|
|
|
215
220
|
// Convert React props to web component attributes
|
|
216
221
|
const webComponentProps: Record<string, any> = {
|
|
217
|
-
...props,
|
|
222
|
+
...hostProps(props),
|
|
218
223
|
ref: elementRef,
|
|
219
224
|
};
|
|
220
225
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { useBooleanProperty, coerceBool } from '../utils/use-boolean-prop';
|
|
3
4
|
import { needsPropertyBridge } from '../utils/react-version';
|
|
4
5
|
|
|
@@ -32,6 +33,12 @@ export interface TyModalProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
32
33
|
/** Allow closing modal with Escape key (default: true) */
|
|
33
34
|
closeOnEscape?: boolean;
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Accessible name — sets aria-label on the internal <dialog>. The dialog
|
|
38
|
+
* gets role="dialog" for free, but nothing names it unless you set this.
|
|
39
|
+
*/
|
|
40
|
+
label?: string;
|
|
41
|
+
|
|
35
42
|
/** React event handlers */
|
|
36
43
|
onOpen?: (event: CustomEvent<TyModalEventDetail>) => void;
|
|
37
44
|
onClose?: (event: CustomEvent<TyModalEventDetail>) => void;
|
|
@@ -64,6 +71,7 @@ export const TyModal = React.forwardRef<TyModalRef, TyModalProps>(
|
|
|
64
71
|
backdrop,
|
|
65
72
|
closeOnOutsideClick,
|
|
66
73
|
closeOnEscape,
|
|
74
|
+
label,
|
|
67
75
|
onOpen,
|
|
68
76
|
onClose,
|
|
69
77
|
onBeforeClose,
|
|
@@ -166,7 +174,7 @@ export const TyModal = React.forwardRef<TyModalRef, TyModalProps>(
|
|
|
166
174
|
|
|
167
175
|
// Convert React props to web component attributes
|
|
168
176
|
const webComponentProps: Record<string, any> = {
|
|
169
|
-
...props,
|
|
177
|
+
...hostProps(props),
|
|
170
178
|
ref: elementRef,
|
|
171
179
|
};
|
|
172
180
|
|
|
@@ -183,6 +191,7 @@ export const TyModal = React.forwardRef<TyModalRef, TyModalProps>(
|
|
|
183
191
|
if (closeOnEscape !== undefined && !coerceBool(closeOnEscape)) {
|
|
184
192
|
webComponentProps['close-on-escape'] = 'false';
|
|
185
193
|
}
|
|
194
|
+
if (label) webComponentProps.label = label;
|
|
186
195
|
|
|
187
196
|
return React.createElement(
|
|
188
197
|
'ty-modal',
|
|
@@ -1,4 +1,5 @@
|
|
|
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 definitions for Ty Option component
|
|
@@ -7,12 +8,12 @@ export interface TyOptionProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Clean display text (native <option label> semantics) — used by ty-select
|
|
10
|
-
* for field summaries and by ty-selected-
|
|
11
|
+
* for field summaries and by ty-selected-options chips when the option's
|
|
11
12
|
* children are rich HTML. data-* attributes feed chip templates.
|
|
12
13
|
*/
|
|
13
14
|
label?: string;
|
|
14
15
|
|
|
15
|
-
/** Semantic flavor — carried onto ty-selected-
|
|
16
|
+
/** Semantic flavor — carried onto ty-selected-options chips */
|
|
16
17
|
flavor?: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral' | 'info';
|
|
17
18
|
|
|
18
19
|
disabled?: boolean;
|
|
@@ -44,7 +45,7 @@ export const TyOption = React.forwardRef<HTMLElement, TyOptionProps>(
|
|
|
44
45
|
return React.createElement(
|
|
45
46
|
'ty-option',
|
|
46
47
|
{
|
|
47
|
-
...props,
|
|
48
|
+
...hostProps(props),
|
|
48
49
|
...(label && { label }),
|
|
49
50
|
...(flavor && { flavor }),
|
|
50
51
|
...(isDisabled && { disabled: "" }),
|
|
@@ -1,4 +1,5 @@
|
|
|
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 definitions for Ty Popup component
|
|
@@ -86,7 +87,7 @@ export const TyPopup = React.forwardRef<TyPopupElement, TyPopupProps>(
|
|
|
86
87
|
|
|
87
88
|
// Convert React props to web component attributes
|
|
88
89
|
const webComponentProps: Record<string, any> = {
|
|
89
|
-
...props,
|
|
90
|
+
...hostProps(props),
|
|
90
91
|
ref: elementRef,
|
|
91
92
|
};
|
|
92
93
|
|
|
@@ -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' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
|
|
4
8
|
export interface TyRadioProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
9
|
/** Form field value (selected by parent ty-radio-group when matches its `value`) */
|
|
6
10
|
value?: string;
|
|
@@ -18,7 +22,7 @@ export interface TyRadioProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
18
22
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
19
23
|
|
|
20
24
|
/** Semantic styling variant — typically inherited from the parent group */
|
|
21
|
-
flavor?:
|
|
25
|
+
flavor?: ShadedFlavor | (string & {});
|
|
22
26
|
|
|
23
27
|
/** Label content (wrap in a `<label>` for click delegation, see ty-radio docs) */
|
|
24
28
|
children?: React.ReactNode;
|
|
@@ -43,7 +47,7 @@ export const TyRadio = React.forwardRef<HTMLElement, TyRadioProps>(
|
|
|
43
47
|
const isDisabled = useBooleanProperty(elementRef, 'disabled', disabled);
|
|
44
48
|
|
|
45
49
|
const webComponentProps: Record<string, any> = {
|
|
46
|
-
...props,
|
|
50
|
+
...hostProps(props),
|
|
47
51
|
ref: elementRef,
|
|
48
52
|
};
|
|
49
53
|
|
|
@@ -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' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
6
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
7
|
+
|
|
4
8
|
export interface TyRadioGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange' | 'onInput'> {
|
|
5
9
|
/** Currently selected value (matches one child `<TyRadio value="...">`) */
|
|
6
10
|
value?: string;
|
|
@@ -27,7 +31,7 @@ export interface TyRadioGroupProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
27
31
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
28
32
|
|
|
29
33
|
/** Group flavor — propagates to all `<TyRadio>` children */
|
|
30
|
-
flavor?:
|
|
34
|
+
flavor?: ShadedFlavor | (string & {});
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* Fires when selection changes (React convention)
|
|
@@ -103,7 +107,7 @@ export const TyRadioGroup = React.forwardRef<HTMLElement, TyRadioGroupProps>(
|
|
|
103
107
|
const isRequired = useBooleanProperty(elementRef, 'required', required);
|
|
104
108
|
|
|
105
109
|
const webComponentProps: Record<string, any> = {
|
|
106
|
-
...props,
|
|
110
|
+
...hostProps(props),
|
|
107
111
|
ref: elementRef,
|
|
108
112
|
};
|
|
109
113
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
4
|
// Type definitions for Ty ResizeObserver component
|
|
4
5
|
export interface TyResizeObserverProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -35,7 +36,7 @@ export const TyResizeObserver = React.forwardRef<HTMLElement, TyResizeObserverPr
|
|
|
35
36
|
|
|
36
37
|
// Convert React props to web component attributes
|
|
37
38
|
const webComponentProps: Record<string, any> = {
|
|
38
|
-
...props,
|
|
39
|
+
...hostProps(props),
|
|
39
40
|
ref: elementRef,
|
|
40
41
|
id,
|
|
41
42
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
import { needsPropertyBridge } from '../utils/react-version';
|
|
3
4
|
import { useBooleanProperty, coerceBool } from '../utils/use-boolean-prop';
|
|
4
5
|
|
|
@@ -126,7 +127,7 @@ export const TyScrollContainer = React.forwardRef<TyScrollContainerRef, TyScroll
|
|
|
126
127
|
|
|
127
128
|
// Convert React props to web component attributes
|
|
128
129
|
const webComponentProps: Record<string, any> = {
|
|
129
|
-
...props,
|
|
130
|
+
...hostProps(props),
|
|
130
131
|
ref: elementRef,
|
|
131
132
|
};
|
|
132
133
|
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
|
|
6
|
+
type BuiltinFlavor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'neutral';
|
|
7
|
+
type ShadedFlavor = BuiltinFlavor | `${BuiltinFlavor}+` | `${BuiltinFlavor}-`;
|
|
8
|
+
|
|
5
9
|
// Type definitions for Ty Select component
|
|
6
10
|
export interface TySelectItem {
|
|
7
11
|
value: string;
|
|
@@ -17,7 +21,7 @@ export interface TySelectEventDetail {
|
|
|
17
21
|
/** Rich info per selected value — enough to render chips out-of-band */
|
|
18
22
|
items: TySelectItem[];
|
|
19
23
|
/** Action that triggered the change */
|
|
20
|
-
action: 'add' | 'remove' | 'clear' | 'set';
|
|
24
|
+
action: 'add' | 'remove' | 'clear' | 'set' | 'create';
|
|
21
25
|
/** The specific value that changed */
|
|
22
26
|
item: string | null;
|
|
23
27
|
}
|
|
@@ -67,12 +71,37 @@ export interface TySelectProps extends Omit<React.HTMLAttributes<HTMLElement>, '
|
|
|
67
71
|
/** Debounce for the search event in ms (0-5000) */
|
|
68
72
|
debounce?: number;
|
|
69
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Enter on unmatched search text mints a new <ty-option> (forces the
|
|
76
|
+
* search row on, same as externalSearch). Listen to onCreate to mutate
|
|
77
|
+
* the value before it's created, or preventDefault() to take over
|
|
78
|
+
* entirely (e.g. after a server round-trip).
|
|
79
|
+
*/
|
|
80
|
+
allowCreate?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Opt-in normalizer for the value allowCreate mints — the display label
|
|
84
|
+
* is always kept verbatim. 'slug': lowercase, spaces → '_', strips
|
|
85
|
+
* everything else non-alphanumeric. Default: value === typed text.
|
|
86
|
+
*/
|
|
87
|
+
createTransform?: 'slug';
|
|
88
|
+
|
|
70
89
|
/** Loading state — shows a spinner in the options area (external search in flight) */
|
|
71
90
|
loading?: boolean;
|
|
72
91
|
|
|
73
92
|
/** Size variant */
|
|
93
|
+
/** Field size — fields come in exactly three; legacy xs/xl map to sm/lg */
|
|
74
94
|
size?: 'sm' | 'md' | 'lg';
|
|
75
95
|
|
|
96
|
+
/** Horizontal popup anchor: "start" (default, trigger's left edge) or "end" (trigger's right edge) — clamped into the viewport either way. Useful with a custom slot="trigger" element. */
|
|
97
|
+
align?: 'start' | 'end';
|
|
98
|
+
|
|
99
|
+
/** Built-in x clear button in the default/compact trigger, shown once something is selected. Default true. Not shown with slot="trigger" — use the ref's clear() method there instead. */
|
|
100
|
+
clearable?: boolean;
|
|
101
|
+
|
|
102
|
+
/** Visual flavor for the field border — built-in semantic, +/- shade, or a custom flavor backed by --ty-*-X tokens */
|
|
103
|
+
flavor?: ShadedFlavor | (string & {});
|
|
104
|
+
|
|
76
105
|
/** Callback when selection changes */
|
|
77
106
|
onChange?: (event: CustomEvent<TySelectEventDetail>) => void;
|
|
78
107
|
|
|
@@ -81,12 +110,24 @@ export interface TySelectProps extends Omit<React.HTMLAttributes<HTMLElement>, '
|
|
|
81
110
|
onOpen?: (event: CustomEvent) => void;
|
|
82
111
|
onClose?: (event: CustomEvent) => void;
|
|
83
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Fired before allowCreate mints a new option — cancelable. Mutate
|
|
115
|
+
* `event.detail.value` to change the id that gets created (e.g. slugify
|
|
116
|
+
* it yourself), or call `event.preventDefault()` to create it yourself.
|
|
117
|
+
*/
|
|
118
|
+
onCreate?: (event: CustomEvent<{ value: string; label: string }>) => void;
|
|
119
|
+
|
|
84
120
|
/** TyOption children (plus optional slot="trigger" / slot="start" / slot="end" elements) */
|
|
85
121
|
children?: React.ReactNode;
|
|
86
122
|
}
|
|
87
123
|
|
|
124
|
+
/** The underlying custom element, typed with its imperative clear() method — useful with a ref, e.g. for slot="trigger" custom triggers that call it directly instead of relying on the built-in clear button. */
|
|
125
|
+
export interface TySelectElement extends HTMLElement {
|
|
126
|
+
clear(): void;
|
|
127
|
+
}
|
|
128
|
+
|
|
88
129
|
// React wrapper for ty-select web component
|
|
89
|
-
export const TySelect = React.forwardRef<
|
|
130
|
+
export const TySelect = React.forwardRef<TySelectElement, TySelectProps>(
|
|
90
131
|
({
|
|
91
132
|
value,
|
|
92
133
|
multiple,
|
|
@@ -100,16 +141,22 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
100
141
|
searchable,
|
|
101
142
|
externalSearch,
|
|
102
143
|
debounce,
|
|
144
|
+
allowCreate,
|
|
145
|
+
createTransform,
|
|
103
146
|
loading,
|
|
104
147
|
size,
|
|
148
|
+
align,
|
|
149
|
+
clearable,
|
|
150
|
+
flavor,
|
|
105
151
|
onChange,
|
|
106
152
|
onSearch,
|
|
107
153
|
onOpen,
|
|
108
154
|
onClose,
|
|
155
|
+
onCreate,
|
|
109
156
|
children,
|
|
110
157
|
...props
|
|
111
158
|
}, ref) => {
|
|
112
|
-
const elementRef = useRef<
|
|
159
|
+
const elementRef = useRef<TySelectElement>(null);
|
|
113
160
|
|
|
114
161
|
// Handle ref forwarding
|
|
115
162
|
useEffect(() => {
|
|
@@ -145,6 +192,9 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
145
192
|
|
|
146
193
|
const handleOpen = useCallback((event: Event) => { if (onOpen) onOpen(event as CustomEvent); }, [onOpen]);
|
|
147
194
|
const handleClose = useCallback((event: Event) => { if (onClose) onClose(event as CustomEvent); }, [onClose]);
|
|
195
|
+
const handleCreate = useCallback((event: Event) => {
|
|
196
|
+
if (onCreate) onCreate(event as CustomEvent<{ value: string; label: string }>);
|
|
197
|
+
}, [onCreate]);
|
|
148
198
|
|
|
149
199
|
// Set up event listeners
|
|
150
200
|
useEffect(() => {
|
|
@@ -155,14 +205,16 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
155
205
|
if (onSearch) element.addEventListener('search', handleSearch);
|
|
156
206
|
if (onOpen) element.addEventListener('open', handleOpen);
|
|
157
207
|
if (onClose) element.addEventListener('close', handleClose);
|
|
208
|
+
if (onCreate) element.addEventListener('create', handleCreate);
|
|
158
209
|
|
|
159
210
|
return () => {
|
|
160
211
|
if (onChange) element.removeEventListener('change', handleChange);
|
|
161
212
|
if (onSearch) element.removeEventListener('search', handleSearch);
|
|
162
213
|
if (onOpen) element.removeEventListener('open', handleOpen);
|
|
163
214
|
if (onClose) element.removeEventListener('close', handleClose);
|
|
215
|
+
if (onCreate) element.removeEventListener('create', handleCreate);
|
|
164
216
|
};
|
|
165
|
-
}, [handleChange, handleSearch, handleOpen, handleClose, onChange, onSearch, onOpen, onClose]);
|
|
217
|
+
}, [handleChange, handleSearch, handleOpen, handleClose, handleCreate, onChange, onSearch, onOpen, onClose, onCreate]);
|
|
166
218
|
|
|
167
219
|
// Imperative property sync for boolean props (see use-boolean-prop.ts).
|
|
168
220
|
const isMultiple = useBooleanProperty(elementRef, 'multiple', multiple);
|
|
@@ -172,10 +224,12 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
172
224
|
const isRequired = useBooleanProperty(elementRef, 'required', required);
|
|
173
225
|
const isLoading = useBooleanProperty(elementRef, 'loading', loading);
|
|
174
226
|
const isExternalSearch = useBooleanProperty(elementRef, 'externalSearch', externalSearch);
|
|
227
|
+
const isAllowCreate = useBooleanProperty(elementRef, 'allowCreate', allowCreate);
|
|
228
|
+
const isClearable = useBooleanProperty(elementRef, 'clearable', clearable);
|
|
175
229
|
|
|
176
230
|
// Convert React props to web component attributes
|
|
177
231
|
const webComponentProps: Record<string, any> = {
|
|
178
|
-
...props,
|
|
232
|
+
...hostProps(props),
|
|
179
233
|
ref: elementRef,
|
|
180
234
|
};
|
|
181
235
|
|
|
@@ -191,12 +245,17 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
191
245
|
if (isRequired) webComponentProps.required = '';
|
|
192
246
|
if (isLoading) webComponentProps.loading = '';
|
|
193
247
|
if (isExternalSearch) webComponentProps['external-search'] = '';
|
|
248
|
+
if (isAllowCreate) webComponentProps['allow-create'] = '';
|
|
194
249
|
|
|
195
250
|
if (placeholder) webComponentProps.placeholder = placeholder;
|
|
196
251
|
if (label) webComponentProps.label = label;
|
|
197
252
|
if (name) webComponentProps.name = name;
|
|
198
253
|
if (size) webComponentProps.size = size;
|
|
254
|
+
if (align) webComponentProps.align = align;
|
|
255
|
+
if (isClearable) webComponentProps.clearable = '';
|
|
256
|
+
if (flavor) webComponentProps.flavor = flavor;
|
|
199
257
|
if (debounce !== undefined) webComponentProps.debounce = debounce.toString();
|
|
258
|
+
if (createTransform) webComponentProps['create-transform'] = createTransform;
|
|
200
259
|
if (searchable === 'always' || searchable === true) webComponentProps.searchable = 'true';
|
|
201
260
|
else if (searchable === 'never' || searchable === false) webComponentProps.searchable = 'false';
|
|
202
261
|
// 'auto' / undefined → omit (component default)
|
|
@@ -208,7 +267,9 @@ export const TySelect = React.forwardRef<HTMLElement, TySelectProps>(
|
|
|
208
267
|
TySelect.displayName = 'TySelect';
|
|
209
268
|
|
|
210
269
|
// ============================================================================
|
|
211
|
-
//
|
|
270
|
+
// TySelectedOptions — out-of-band chip display for a TySelect
|
|
271
|
+
// (ty-selected-tags below is the same element under its original tag name,
|
|
272
|
+
// kept for backward compatibility.)
|
|
212
273
|
// ============================================================================
|
|
213
274
|
|
|
214
275
|
export interface TySelectedTagsProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -218,9 +279,8 @@ export interface TySelectedTagsProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
218
279
|
children?: React.ReactNode;
|
|
219
280
|
}
|
|
220
281
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
({ htmlFor, children, ...props }, ref) => {
|
|
282
|
+
const selectedChipsComponent = (tag: 'ty-selected-options' | 'ty-selected-tags') =>
|
|
283
|
+
React.forwardRef<HTMLElement, TySelectedTagsProps>(({ htmlFor, children, ...props }, ref) => {
|
|
224
284
|
const elementRef = useRef<HTMLElement>(null);
|
|
225
285
|
|
|
226
286
|
useEffect(() => {
|
|
@@ -230,11 +290,16 @@ export const TySelectedTags = React.forwardRef<HTMLElement, TySelectedTagsProps>
|
|
|
230
290
|
}
|
|
231
291
|
}, [ref]);
|
|
232
292
|
|
|
233
|
-
const webComponentProps: Record<string, any> = { ...props, ref: elementRef };
|
|
293
|
+
const webComponentProps: Record<string, any> = { ...hostProps(props), ref: elementRef };
|
|
234
294
|
if (htmlFor) webComponentProps.for = htmlFor;
|
|
235
295
|
|
|
236
|
-
return React.createElement(
|
|
237
|
-
}
|
|
238
|
-
|
|
296
|
+
return React.createElement(tag, webComponentProps, children);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
/** React wrapper for the ty-selected-options web component. */
|
|
300
|
+
export const TySelectedOptions = selectedChipsComponent('ty-selected-options');
|
|
301
|
+
TySelectedOptions.displayName = 'TySelectedOptions';
|
|
239
302
|
|
|
303
|
+
/** @deprecated Use `TySelectedOptions` — kept for backward compatibility. */
|
|
304
|
+
export const TySelectedTags = selectedChipsComponent('ty-selected-tags');
|
|
240
305
|
TySelectedTags.displayName = 'TySelectedTags';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
4
|
// Type definitions for Ty Step component
|
|
4
5
|
export interface TyStepProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -47,7 +48,7 @@ export const TyStep = React.forwardRef<HTMLElement, TyStepProps>(
|
|
|
47
48
|
|
|
48
49
|
// Convert React props to web component attributes
|
|
49
50
|
const webComponentProps: Record<string, any> = {
|
|
50
|
-
...props,
|
|
51
|
+
...hostProps(props),
|
|
51
52
|
ref: elementRef,
|
|
52
53
|
id,
|
|
53
54
|
};
|
|
@@ -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' | 'secondary' | '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,4 +1,5 @@
|
|
|
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 definitions for Ty Tab component
|
|
@@ -40,7 +41,7 @@ export const TyTab = React.forwardRef<HTMLElement, TyTabProps>(
|
|
|
40
41
|
|
|
41
42
|
// Convert React props to web component attributes
|
|
42
43
|
const webComponentProps: Record<string, any> = {
|
|
43
|
-
...props,
|
|
44
|
+
...hostProps(props),
|
|
44
45
|
ref: elementRef,
|
|
45
46
|
};
|
|
46
47
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { hostProps } from '../utils/host-props';
|
|
2
3
|
|
|
3
4
|
// Type definitions for Ty Tabs component
|
|
4
5
|
export interface TyTabsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
@@ -72,7 +73,7 @@ export const TyTabs = React.forwardRef<HTMLElement, TyTabsProps>(
|
|
|
72
73
|
|
|
73
74
|
// Convert React props to web component attributes
|
|
74
75
|
const webComponentProps: Record<string, any> = {
|
|
75
|
-
...props,
|
|
76
|
+
...hostProps(props),
|
|
76
77
|
ref: elementRef,
|
|
77
78
|
};
|
|
78
79
|
|
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' | 'secondary' | '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;
|
|
@@ -10,7 +14,7 @@ export interface TyTagCSSProperties extends React.CSSProperties {
|
|
|
10
14
|
|
|
11
15
|
// Type definitions for Ty Tag component
|
|
12
16
|
export interface TyTagProps extends Omit<React.HTMLAttributes<HTMLElement>, 'style' | 'onClick'> {
|
|
13
|
-
flavor?:
|
|
17
|
+
flavor?: ShadedFlavor | (string & {});
|
|
14
18
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
15
19
|
notPill?: boolean;
|
|
16
20
|
clickable?: boolean;
|
|
@@ -67,7 +71,7 @@ export const TyTag = React.forwardRef<HTMLElement, TyTagProps>(
|
|
|
67
71
|
return React.createElement(
|
|
68
72
|
'ty-tag',
|
|
69
73
|
{
|
|
70
|
-
...props,
|
|
74
|
+
...hostProps(props),
|
|
71
75
|
// click is dispatched as composed CustomEvent by the web component — React's
|
|
72
76
|
// synthetic onClick already catches it, so we just pass it through as onClick
|
|
73
77
|
...(onClick && { onClick }),
|
|
@@ -1,4 +1,5 @@
|
|
|
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
|
|
|
@@ -167,7 +168,7 @@ export const TyTextarea = React.forwardRef<HTMLElement, TyTextareaProps>(
|
|
|
167
168
|
return React.createElement(
|
|
168
169
|
'ty-textarea',
|
|
169
170
|
{
|
|
170
|
-
...props,
|
|
171
|
+
...hostProps(props),
|
|
171
172
|
...(isDisabled && { disabled: "" }),
|
|
172
173
|
...(isRequired && { required: "" }),
|
|
173
174
|
...(minHeight && { 'min-height': minHeight }), // Convert camelCase to kebab-case
|