@udixio/ui-react 2.9.18 → 2.9.20
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/CHANGELOG.md +25 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +1476 -1459
- package/dist/lib/components/AnchorPositioner.d.ts +2 -1
- package/dist/lib/components/AnchorPositioner.d.ts.map +1 -1
- package/dist/lib/components/TextField.d.ts +1 -1
- package/dist/lib/components/TextField.d.ts.map +1 -1
- package/dist/lib/interfaces/text-field.interface.d.ts +2 -0
- package/dist/lib/interfaces/text-field.interface.d.ts.map +1 -1
- package/dist/lib/styles/text-field.style.d.ts +6 -0
- package/dist/lib/styles/text-field.style.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/AnchorPositioner.tsx +9 -3
- package/src/lib/components/TextField.tsx +44 -25
- package/src/lib/interfaces/text-field.interface.ts +2 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React, CSSProperties, RefObject } from 'react';
|
|
2
|
+
import IntrinsicElements = React.JSX.IntrinsicElements;
|
|
2
3
|
export type Position = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
3
4
|
export interface AnchorPositionerProps {
|
|
4
5
|
anchorRef: RefObject<HTMLElement | null>;
|
|
@@ -7,5 +8,5 @@ export interface AnchorPositionerProps {
|
|
|
7
8
|
style?: CSSProperties;
|
|
8
9
|
className?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare const AnchorPositioner: ({ anchorRef, position, children, style, }: AnchorPositionerProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const AnchorPositioner: ({ anchorRef, position, children, style, ...restProps }: AnchorPositionerProps & IntrinsicElements["div"]) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
//# sourceMappingURL=AnchorPositioner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorPositioner.d.ts","sourceRoot":"","sources":["../../../src/lib/components/AnchorPositioner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,SAAS,EAIV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AnchorPositioner.d.ts","sourceRoot":"","sources":["../../../src/lib/components/AnchorPositioner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,SAAS,EAIV,MAAM,OAAO,CAAC;AAGf,OAAO,iBAAiB,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,CAAC;AAEnB,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,gBAAgB,GAAI,wDAM9B,qBAAqB,GAAG,iBAAiB,CAAC,KAAK,CAAC,4CA0GlD,CAAC"}
|
|
@@ -10,5 +10,5 @@ import { TextFieldInterface } from '../interfaces';
|
|
|
10
10
|
* @a11y
|
|
11
11
|
* - `aria-describedby` links supporting text/error to input.
|
|
12
12
|
*/
|
|
13
|
-
export declare const TextField: ({ variant, disabled, errorText, placeholder, suffix, name, label, className, supportingText, trailingIcon, leadingIcon, type, multiline, autoComplete, onChange, value: valueProp, defaultValue, showSupportingText, id: idProp, style, ref, ...restProps }: ReactProps<TextFieldInterface>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const TextField: ({ variant, disabled, errorText, placeholder, suffix, name, label, className, supportingText, trailingIcon, leadingIcon, type, multiline, autoComplete, onChange, value: valueProp, defaultValue, showSupportingText, id: idProp, style, ref, onFocus, onBlur, ...restProps }: ReactProps<TextFieldInterface>) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
//# sourceMappingURL=TextField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TextField.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GAAI,
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TextField.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GAAI,8QAyBvB,UAAU,CAAC,kBAAkB,CAAC,4CAwVhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.interface.d.ts","sourceRoot":"","sources":["../../../src/lib/interfaces/text-field.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAErD,KAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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AM,IAAI,CAAC;CACrB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE;QACR,WAAW;QACX,SAAS;QACT,OAAO;QACP,OAAO;QACP,iBAAiB;QACjB,gBAAgB;QAChB,aAAa;QACb,cAAc;QACd,QAAQ;QACR,YAAY;KACb,CAAC;CACH"}
|
|
@@ -21,6 +21,8 @@ export declare const textFieldStyle: (states: {
|
|
|
21
21
|
type: any;
|
|
22
22
|
autoComplete: any;
|
|
23
23
|
multiline: any;
|
|
24
|
+
onFocus: any;
|
|
25
|
+
onBlur: any;
|
|
24
26
|
} & {
|
|
25
27
|
placeholder?: string;
|
|
26
28
|
name?: string;
|
|
@@ -41,6 +43,8 @@ export declare const textFieldStyle: (states: {
|
|
|
41
43
|
type?: "text" | "password" | "number" | "date";
|
|
42
44
|
autoComplete?: "on" | "off" | string;
|
|
43
45
|
multiline?: boolean;
|
|
46
|
+
onFocus?: () => void;
|
|
47
|
+
onBlur?: () => void;
|
|
44
48
|
} & import('..').TextFieldStates & {
|
|
45
49
|
className: string | ClassNameComponent<TextFieldInterface> | undefined;
|
|
46
50
|
}) => Record<"input" | "label" | "content" | "stateLayer" | "leadingIcon" | "trailingIcon" | "activeIndicator" | "supportingText" | "textField" | "suffix", string>;
|
|
@@ -64,6 +68,8 @@ export declare const useTextFieldStyle: (states: import('..').TextFieldStates &
|
|
|
64
68
|
type?: "text" | "password" | "number" | "date";
|
|
65
69
|
autoComplete?: "on" | "off" | string;
|
|
66
70
|
multiline?: boolean;
|
|
71
|
+
onFocus?: () => void;
|
|
72
|
+
onBlur?: () => void;
|
|
67
73
|
} & {
|
|
68
74
|
className?: string | ClassNameComponent<TextFieldInterface> | undefined;
|
|
69
75
|
}) => Record<"input" | "label" | "content" | "stateLayer" | "leadingIcon" | "trailingIcon" | "activeIndicator" | "supportingText" | "textField" | "suffix", string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/text-field.style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAmGnD,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"text-field.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/text-field.style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAmGnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mKAG1B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;mKAG7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { SyncedFixedWrapper } from '../effects';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
|
+
import IntrinsicElements = React.JSX.IntrinsicElements;
|
|
10
11
|
|
|
11
12
|
export type Position =
|
|
12
13
|
| 'top'
|
|
@@ -31,7 +32,8 @@ export const AnchorPositioner = ({
|
|
|
31
32
|
position = 'bottom',
|
|
32
33
|
children,
|
|
33
34
|
style,
|
|
34
|
-
|
|
35
|
+
...restProps
|
|
36
|
+
}: AnchorPositionerProps & IntrinsicElements['div']) => {
|
|
35
37
|
const uniqueId = useId();
|
|
36
38
|
const anchorName = `--anchor-${uniqueId.replace(/:/g, '')}`;
|
|
37
39
|
const [supportsAnchor, setSupportsAnchor] = useState(false);
|
|
@@ -78,7 +80,9 @@ export const AnchorPositioner = ({
|
|
|
78
80
|
} as any;
|
|
79
81
|
|
|
80
82
|
return createPortal(
|
|
81
|
-
<div style={floatingStyles}
|
|
83
|
+
<div style={floatingStyles} {...restProps}>
|
|
84
|
+
{children}
|
|
85
|
+
</div>,
|
|
82
86
|
document.body,
|
|
83
87
|
);
|
|
84
88
|
}
|
|
@@ -130,7 +134,9 @@ export const AnchorPositioner = ({
|
|
|
130
134
|
|
|
131
135
|
return (
|
|
132
136
|
<SyncedFixedWrapper targetRef={anchorRef}>
|
|
133
|
-
<div style={fallbackStyles}
|
|
137
|
+
<div style={fallbackStyles} {...restProps}>
|
|
138
|
+
{children}
|
|
139
|
+
</div>
|
|
134
140
|
</SyncedFixedWrapper>
|
|
135
141
|
);
|
|
136
142
|
};
|
|
@@ -47,6 +47,8 @@ export const TextField = ({
|
|
|
47
47
|
id: idProp,
|
|
48
48
|
style,
|
|
49
49
|
ref,
|
|
50
|
+
onFocus,
|
|
51
|
+
onBlur,
|
|
50
52
|
...restProps
|
|
51
53
|
}: ReactProps<TextFieldInterface>) => {
|
|
52
54
|
const generatedId = useId();
|
|
@@ -65,6 +67,7 @@ export const TextField = ({
|
|
|
65
67
|
|
|
66
68
|
const textFieldRef = useRef<HTMLDivElement>(null);
|
|
67
69
|
const calendarTriggerRef = useRef<HTMLDivElement>(null);
|
|
70
|
+
const datePickerRef = useRef<HTMLDivElement>(null);
|
|
68
71
|
|
|
69
72
|
const hasSupportingText =
|
|
70
73
|
showSupportingText ?? (!!errorText?.length || !!supportingText?.length);
|
|
@@ -79,13 +82,17 @@ export const TextField = ({
|
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (isFocused) {
|
|
87
|
+
setShowErrorIcon(false);
|
|
88
|
+
onFocus?.();
|
|
89
|
+
} else {
|
|
90
|
+
if (errorText?.length) {
|
|
91
|
+
setShowErrorIcon(true);
|
|
92
|
+
}
|
|
93
|
+
onBlur?.();
|
|
94
|
+
}
|
|
95
|
+
}, [isFocused]);
|
|
89
96
|
|
|
90
97
|
const handleChange = (
|
|
91
98
|
event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
@@ -103,16 +110,6 @@ export const TextField = ({
|
|
|
103
110
|
}
|
|
104
111
|
};
|
|
105
112
|
|
|
106
|
-
const handleBlur = (
|
|
107
|
-
e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
108
|
-
) => {
|
|
109
|
-
setIsFocused(false);
|
|
110
|
-
if (errorText?.length) {
|
|
111
|
-
setShowErrorIcon(true);
|
|
112
|
-
}
|
|
113
|
-
restProps.onBlur?.(e);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
113
|
// Date Picker Logic
|
|
117
114
|
const isDateInput = type === 'date';
|
|
118
115
|
const [showDatePicker, setShowDatePicker] = useState(false);
|
|
@@ -132,6 +129,14 @@ export const TextField = ({
|
|
|
132
129
|
setShowDatePicker(true);
|
|
133
130
|
};
|
|
134
131
|
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (showDatePicker) {
|
|
134
|
+
setIsFocused(true);
|
|
135
|
+
} else {
|
|
136
|
+
setIsFocused(false);
|
|
137
|
+
}
|
|
138
|
+
}, [showDatePicker]);
|
|
139
|
+
|
|
135
140
|
const handleDateConfirm = () => {
|
|
136
141
|
const newValue = tempDate ? tempDate.toLocaleDateString('en-CA') : '';
|
|
137
142
|
|
|
@@ -272,8 +277,8 @@ export const TextField = ({
|
|
|
272
277
|
id={id}
|
|
273
278
|
name={name}
|
|
274
279
|
placeholder={isFocused ? (placeholder ?? undefined) : ''}
|
|
275
|
-
onFocus={
|
|
276
|
-
onBlur={
|
|
280
|
+
onFocus={() => setIsFocused(true)}
|
|
281
|
+
onBlur={() => setIsFocused(false)}
|
|
277
282
|
disabled={disabled}
|
|
278
283
|
autoComplete={autoComplete}
|
|
279
284
|
aria-invalid={!!errorText?.length}
|
|
@@ -342,12 +347,26 @@ export const TextField = ({
|
|
|
342
347
|
|
|
343
348
|
{isDateInput && showDatePicker && (
|
|
344
349
|
<>
|
|
345
|
-
<
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
<AnchorPositioner
|
|
351
|
+
onBlur={(e) => {
|
|
352
|
+
console.log(
|
|
353
|
+
datePickerRef.current,
|
|
354
|
+
!datePickerRef.current?.contains(e.relatedTarget),
|
|
355
|
+
);
|
|
356
|
+
if (
|
|
357
|
+
datePickerRef.current &&
|
|
358
|
+
!datePickerRef.current?.contains(e.relatedTarget)
|
|
359
|
+
) {
|
|
360
|
+
setShowDatePicker(false);
|
|
361
|
+
}
|
|
362
|
+
}}
|
|
363
|
+
anchorRef={textFieldRef}
|
|
364
|
+
position="bottom"
|
|
365
|
+
>
|
|
366
|
+
<div
|
|
367
|
+
ref={datePickerRef}
|
|
368
|
+
className="z-50 shadow-xl rounded-[28px] bg-surface-container-high overflow-hidden"
|
|
369
|
+
>
|
|
351
370
|
<DatePicker
|
|
352
371
|
className={''}
|
|
353
372
|
value={tempDate}
|