@oxy.so/bloom 7.16.1 → 7.18.0
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/docs/adoption-matrix.mdx +9 -9
- package/docs/carousel.mdx +22 -0
- package/docs/checkbox.mdx +21 -0
- package/docs/media-header.mdx +21 -0
- package/docs/overlay.mdx +9 -0
- package/docs/radio.mdx +20 -0
- package/docs/search.mdx +18 -1
- package/docs/text-field.mdx +15 -0
- package/lib/commonjs/accordion/Accordion.web.js +1 -0
- package/lib/commonjs/accordion/Accordion.web.js.map +1 -1
- package/lib/commonjs/carousel/Carousel.js +50 -20
- package/lib/commonjs/carousel/Carousel.js.map +1 -1
- package/lib/commonjs/checkbox/Checkbox.js +15 -9
- package/lib/commonjs/checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/hooks/use-choice-space-key.js +37 -0
- package/lib/commonjs/hooks/use-choice-space-key.js.map +1 -0
- package/lib/commonjs/media-header/FollowLabel.js +46 -0
- package/lib/commonjs/media-header/FollowLabel.js.map +1 -0
- package/lib/commonjs/media-header/MediaActionBar.js +19 -13
- package/lib/commonjs/media-header/MediaActionBar.js.map +1 -1
- package/lib/commonjs/overlay/ModalKeyboard.js +4 -6
- package/lib/commonjs/overlay/ModalKeyboard.js.map +1 -1
- package/lib/commonjs/overlay/modal-keyboard.js +44 -0
- package/lib/commonjs/overlay/modal-keyboard.js.map +1 -1
- package/lib/commonjs/radio/Radio.js +14 -3
- package/lib/commonjs/radio/Radio.js.map +1 -1
- package/lib/commonjs/search/Search.js +11 -2
- package/lib/commonjs/search/Search.js.map +1 -1
- package/lib/commonjs/search/types.js +6 -0
- package/lib/commonjs/search/types.js.map +1 -0
- package/lib/commonjs/text-field/FieldBox.js +83 -0
- package/lib/commonjs/text-field/FieldBox.js.map +1 -0
- package/lib/commonjs/text-field/TextField.js +17 -7
- package/lib/commonjs/text-field/TextField.js.map +1 -1
- package/lib/module/accordion/Accordion.web.js +1 -0
- package/lib/module/accordion/Accordion.web.js.map +1 -1
- package/lib/module/carousel/Carousel.js +50 -20
- package/lib/module/carousel/Carousel.js.map +1 -1
- package/lib/module/checkbox/Checkbox.js +15 -9
- package/lib/module/checkbox/Checkbox.js.map +1 -1
- package/lib/module/hooks/use-choice-space-key.js +34 -0
- package/lib/module/hooks/use-choice-space-key.js.map +1 -0
- package/lib/module/media-header/FollowLabel.js +42 -0
- package/lib/module/media-header/FollowLabel.js.map +1 -0
- package/lib/module/media-header/MediaActionBar.js +19 -13
- package/lib/module/media-header/MediaActionBar.js.map +1 -1
- package/lib/module/overlay/ModalKeyboard.js +5 -7
- package/lib/module/overlay/ModalKeyboard.js.map +1 -1
- package/lib/module/overlay/modal-keyboard.js +43 -0
- package/lib/module/overlay/modal-keyboard.js.map +1 -1
- package/lib/module/radio/Radio.js +14 -3
- package/lib/module/radio/Radio.js.map +1 -1
- package/lib/module/search/Search.js +11 -2
- package/lib/module/search/Search.js.map +1 -1
- package/lib/module/search/types.js +4 -0
- package/lib/module/search/types.js.map +1 -0
- package/lib/module/text-field/FieldBox.js +79 -0
- package/lib/module/text-field/FieldBox.js.map +1 -0
- package/lib/module/text-field/TextField.js +17 -7
- package/lib/module/text-field/TextField.js.map +1 -1
- package/lib/typescript/commonjs/carousel/Carousel.d.ts +1 -1
- package/lib/typescript/commonjs/carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/commonjs/carousel/index.d.ts +1 -1
- package/lib/typescript/commonjs/carousel/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/carousel/types.d.ts +7 -0
- package/lib/typescript/commonjs/carousel/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/commonjs/checkbox/types.d.ts +4 -0
- package/lib/typescript/commonjs/checkbox/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-header/types.d.ts +10 -0
- package/lib/typescript/commonjs/media-header/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts +2 -0
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/types.d.ts +4 -0
- package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/search/Search.d.ts +6 -6
- package/lib/typescript/commonjs/search/Search.d.ts.map +1 -1
- package/lib/typescript/commonjs/search/index.d.ts +1 -0
- package/lib/typescript/commonjs/search/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/search/types.d.ts +15 -0
- package/lib/typescript/commonjs/search/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/text-field/FieldBox.d.ts +19 -0
- package/lib/typescript/commonjs/text-field/FieldBox.d.ts.map +1 -0
- package/lib/typescript/commonjs/text-field/TextField.d.ts +1 -1
- package/lib/typescript/commonjs/text-field/TextField.d.ts.map +1 -1
- package/lib/typescript/commonjs/text-field/types.d.ts +4 -0
- package/lib/typescript/commonjs/text-field/types.d.ts.map +1 -1
- package/lib/typescript/module/carousel/Carousel.d.ts +1 -1
- package/lib/typescript/module/carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/module/carousel/index.d.ts +1 -1
- package/lib/typescript/module/carousel/index.d.ts.map +1 -1
- package/lib/typescript/module/carousel/types.d.ts +7 -0
- package/lib/typescript/module/carousel/types.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/types.d.ts +4 -0
- package/lib/typescript/module/checkbox/types.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/module/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/module/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/module/media-header/types.d.ts +10 -0
- package/lib/typescript/module/media-header/types.d.ts.map +1 -1
- package/lib/typescript/module/overlay/modal-keyboard.d.ts +2 -0
- package/lib/typescript/module/overlay/modal-keyboard.d.ts.map +1 -1
- package/lib/typescript/module/radio/Radio.d.ts +1 -1
- package/lib/typescript/module/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/module/radio/types.d.ts +4 -0
- package/lib/typescript/module/radio/types.d.ts.map +1 -1
- package/lib/typescript/module/search/Search.d.ts +6 -6
- package/lib/typescript/module/search/Search.d.ts.map +1 -1
- package/lib/typescript/module/search/index.d.ts +1 -0
- package/lib/typescript/module/search/index.d.ts.map +1 -1
- package/lib/typescript/module/search/types.d.ts +15 -0
- package/lib/typescript/module/search/types.d.ts.map +1 -0
- package/lib/typescript/module/text-field/FieldBox.d.ts +19 -0
- package/lib/typescript/module/text-field/FieldBox.d.ts.map +1 -0
- package/lib/typescript/module/text-field/TextField.d.ts +1 -1
- package/lib/typescript/module/text-field/TextField.d.ts.map +1 -1
- package/lib/typescript/module/text-field/types.d.ts +4 -0
- package/lib/typescript/module/text-field/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.web.tsx +1 -1
- package/src/carousel/Carousel.tsx +37 -12
- package/src/carousel/index.ts +1 -1
- package/src/carousel/types.ts +9 -0
- package/src/checkbox/Checkbox.tsx +13 -3
- package/src/checkbox/types.ts +4 -0
- package/src/hooks/use-choice-space-key.ts +29 -0
- package/src/media-header/FollowLabel.tsx +23 -0
- package/src/media-header/MediaActionBar.tsx +11 -6
- package/src/media-header/types.ts +10 -0
- package/src/overlay/ModalKeyboard.tsx +5 -5
- package/src/overlay/modal-keyboard.ts +30 -0
- package/src/radio/Radio.tsx +13 -3
- package/src/radio/types.ts +4 -0
- package/src/search/Search.tsx +7 -13
- package/src/search/index.ts +2 -0
- package/src/search/types.ts +15 -0
- package/src/text-field/FieldBox.tsx +51 -0
- package/src/text-field/TextField.tsx +15 -7
- package/src/text-field/types.ts +4 -0
package/src/radio/Radio.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useChoiceSpaceKey } from '../hooks/use-choice-space-key';
|
|
1
2
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
2
3
|
import { useBloomAppearance } from '../appearance';
|
|
3
4
|
import { resolveBloomColors } from '../appearance/colors';
|
|
@@ -94,6 +95,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
94
95
|
checked: checkedProp,
|
|
95
96
|
onValueChange,
|
|
96
97
|
label,
|
|
98
|
+
labelContent,
|
|
97
99
|
description,
|
|
98
100
|
size: sizeProp,
|
|
99
101
|
disabled = false,
|
|
@@ -123,7 +125,8 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
123
125
|
useInteractiveWebCss(STYLE_ID, BLOOM_RADIO_CSS);
|
|
124
126
|
const sizeConfig = SIZE_CONFIG[size];
|
|
125
127
|
const { accent } = useMemo(() => resolveButtonRamps(theme), [theme]);
|
|
126
|
-
const
|
|
128
|
+
const hasLabel = labelContent != null || Boolean(label);
|
|
129
|
+
const hasText = hasLabel || Boolean(description);
|
|
127
130
|
|
|
128
131
|
const handlePress = useCallback(() => {
|
|
129
132
|
// Re-choosing the chosen option is a no-op. A radio, unlike a checkbox, has
|
|
@@ -144,8 +147,11 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
144
147
|
...ringOffset,
|
|
145
148
|
};
|
|
146
149
|
|
|
150
|
+
const spaceKey = useChoiceSpaceKey(isDisabled, handlePress);
|
|
151
|
+
|
|
147
152
|
return (
|
|
148
153
|
<Pressable
|
|
154
|
+
{...spaceKey}
|
|
149
155
|
{...(IS_WEB ? ({ dataSet: { bloomRadio: '' } } as Record<string, unknown>) : {})}
|
|
150
156
|
style={[rowStyle, style]}
|
|
151
157
|
onPress={handlePress}
|
|
@@ -176,7 +182,11 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
176
182
|
|
|
177
183
|
{hasText && (
|
|
178
184
|
<View style={{ flex: 1 }}>
|
|
179
|
-
{
|
|
185
|
+
{labelContent != null ? (
|
|
186
|
+
<View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
|
187
|
+
{labelContent}
|
|
188
|
+
</View>
|
|
189
|
+
) : label && (
|
|
180
190
|
<Text variant={sizeConfig.label} style={[{ color: theme.colors.text }, labelStyle]}>
|
|
181
191
|
{label}
|
|
182
192
|
</Text>
|
|
@@ -184,7 +194,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
184
194
|
{description && (
|
|
185
195
|
<Text
|
|
186
196
|
variant={sizeConfig.description}
|
|
187
|
-
style={{ color: theme.colors.textSecondary, marginTop:
|
|
197
|
+
style={{ color: theme.colors.textSecondary, marginTop: hasLabel ? DESCRIPTION_GAP : 0 }}
|
|
188
198
|
>
|
|
189
199
|
{description}
|
|
190
200
|
</Text>
|
package/src/radio/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { BloomSize } from '../appearance';
|
|
2
3
|
import type { BloomTone } from '../appearance';
|
|
3
4
|
import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
@@ -21,6 +22,9 @@ export interface RadioProps<Value extends string = string> {
|
|
|
21
22
|
onValueChange?: (value: Value) => void;
|
|
22
23
|
/** Optional label text. */
|
|
23
24
|
label?: string;
|
|
25
|
+
/** Decorative label layout, rendered in a View instead of Text. Supply
|
|
26
|
+
* `label` or `accessibilityLabel` for its accessible name. Do not nest controls. */
|
|
27
|
+
labelContent?: ReactNode;
|
|
24
28
|
/** Optional description shown below the label. */
|
|
25
29
|
description?: string;
|
|
26
30
|
/** Size preset. */
|
package/src/search/Search.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import { forwardRef, useCallback, useMemo, useRef } from 'react';
|
|
|
2
2
|
import { Platform, type TextInput, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { mergeRefs } from '../hooks/merge-refs';
|
|
5
|
+
import { FieldBox } from '../text-field/FieldBox';
|
|
6
|
+
import type { SearchProps } from './types';
|
|
5
7
|
import { useDirectionProps, useIsRtl } from '../hooks/use-is-rtl';
|
|
6
8
|
import { useCommonMessages } from '../locale/common-messages';
|
|
7
9
|
import { useMessages } from '../locale/messages';
|
|
@@ -11,20 +13,12 @@ import { useTheme } from '../theme/use-theme';
|
|
|
11
13
|
import { atoms as a } from '../styles';
|
|
12
14
|
import { borderRadius } from '../styles/tokens';
|
|
13
15
|
import { GlyphButton } from '../button';
|
|
14
|
-
import { TextField, TextFieldIcon, TextFieldInput
|
|
16
|
+
import { TextField, TextFieldIcon, TextFieldInput } from '../text-field';
|
|
15
17
|
import { RiSearchLine as MagnifyingGlassIcon } from '../icons/remix/RiSearchLine';
|
|
16
18
|
import { RiCloseLine as X } from '../icons/remix/RiCloseLine';
|
|
17
19
|
|
|
18
|
-
type SearchProps = Omit<TextFieldInputProps, 'label'> & {
|
|
19
|
-
label?: TextFieldInputProps['label'];
|
|
20
|
-
/**
|
|
21
|
-
* Called when the user presses the clear (X) button.
|
|
22
|
-
*/
|
|
23
|
-
onClearText?: () => void;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
20
|
export const Search = forwardRef<TextInput, SearchProps>(
|
|
27
|
-
function Search({ value, label: labelProp, onClearText, onFocus, onPressIn, ...rest }, ref) {
|
|
21
|
+
function Search({ value, label: labelProp, onClearText, onFocus, onPressIn, fieldClassName, fieldChromeClassName, containerClassName, containerStyle, ...rest }, ref) {
|
|
28
22
|
const theme = useTheme();
|
|
29
23
|
const direction = useDirectionProps();
|
|
30
24
|
const rtl = useIsRtl();
|
|
@@ -69,8 +63,8 @@ export const Search = forwardRef<TextInput, SearchProps>(
|
|
|
69
63
|
);
|
|
70
64
|
|
|
71
65
|
return (
|
|
72
|
-
<
|
|
73
|
-
<TextField radius={borderRadius.full}>
|
|
66
|
+
<FieldBox {...direction} className={containerClassName} style={containerStyle} baseStyle={[a.w_full, a.relative]}>
|
|
67
|
+
<TextField radius={borderRadius.full} className={fieldClassName} chromeClassName={fieldChromeClassName}>
|
|
74
68
|
<TextFieldIcon icon={MagnifyingGlassIcon} />
|
|
75
69
|
<TextFieldInput
|
|
76
70
|
inputRef={refs}
|
|
@@ -113,7 +107,7 @@ export const Search = forwardRef<TextInput, SearchProps>(
|
|
|
113
107
|
/>
|
|
114
108
|
</View>
|
|
115
109
|
)}
|
|
116
|
-
</
|
|
110
|
+
</FieldBox>
|
|
117
111
|
);
|
|
118
112
|
},
|
|
119
113
|
);
|
package/src/search/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { TextFieldInputProps } from '../text-field/types';
|
|
3
|
+
|
|
4
|
+
export type SearchProps = Omit<TextFieldInputProps, 'label'> & {
|
|
5
|
+
label?: TextFieldInputProps['label'];
|
|
6
|
+
/** Called when the user presses the clear button. */
|
|
7
|
+
onClearText?: () => void;
|
|
8
|
+
/** Field layout classes (height, width and padding). */
|
|
9
|
+
fieldClassName?: string;
|
|
10
|
+
/** Inset surface classes (background, border/ring and radius). */
|
|
11
|
+
fieldChromeClassName?: string;
|
|
12
|
+
/** Classes on the outer layout box, including the clear control. */
|
|
13
|
+
containerClassName?: string;
|
|
14
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { styled } from 'react-native-css';
|
|
4
|
+
import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
5
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
6
|
+
|
|
7
|
+
// The field owns two distinct boxes: layout and a non-layout inset ring. Keep
|
|
8
|
+
// their defaults below caller classes without moving the ring into box sizing.
|
|
9
|
+
const properties = ['width', 'minWidth', 'flex', 'flexDirection', 'alignItems', 'position',
|
|
10
|
+
'paddingLeft', 'paddingRight', 'paddingInlineStart', 'paddingInlineEnd', 'borderRadius',
|
|
11
|
+
'borderWidth', 'borderColor', 'backgroundColor', 'zIndex', 'top', 'right', 'bottom', 'left',
|
|
12
|
+
'transitionProperty', 'transitionDuration', 'transitionTimingFunction'] as const;
|
|
13
|
+
const cssName = (name: string) => name.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
|
|
14
|
+
const fallbacks: Record<string, string> = { borderWidth:'0px', minWidth:'0px', flex:'0 0 auto', flexDirection:'column' };
|
|
15
|
+
const CSS = `@layer base { [data-bloom-field-box] { display:flex; box-sizing:border-box; border-style:solid; border-width:0; min-width:0; ${properties.map(name => `${cssName(name)}:var(--bloom-field-${cssName(name)},${fallbacks[name] ?? 'initial'});`).join('')} } }`;
|
|
16
|
+
interface FieldBoxProps {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
baseStyle?: StyleProp<ViewStyle>;
|
|
21
|
+
stateStyle?: StyleProp<ViewStyle>;
|
|
22
|
+
dir?: 'rtl';
|
|
23
|
+
pointerEvents?: 'none' | 'auto';
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
onMouseOver?: () => void;
|
|
26
|
+
onMouseOut?: () => void;
|
|
27
|
+
testID?: string;
|
|
28
|
+
}
|
|
29
|
+
function FieldBoxComponent({ children, className, style, baseStyle, stateStyle, dir, pointerEvents, onClick,
|
|
30
|
+
onMouseOver, onMouseOut, testID }: FieldBoxProps) {
|
|
31
|
+
useInteractiveWebCss('bloom-field-box', CSS);
|
|
32
|
+
if (Platform.OS !== 'web') return <View pointerEvents={pointerEvents} testID={testID}
|
|
33
|
+
style={[baseStyle, style, stateStyle]}>{children}</View>;
|
|
34
|
+
const defaults = resolveNativeWebStyle(baseStyle);
|
|
35
|
+
const variables: Record<string, unknown> = {};
|
|
36
|
+
for (const name of properties) {
|
|
37
|
+
const value = defaults[name as keyof React.CSSProperties];
|
|
38
|
+
if (value === undefined || value === null) { variables[`--bloom-field-${cssName(name)}`] = 'initial'; continue; }
|
|
39
|
+
const unit = typeof value === 'number' && !['flex', 'zIndex'].includes(name) ? 'px' : '';
|
|
40
|
+
variables[`--bloom-field-${cssName(name)}`] = `${value}${unit}`;
|
|
41
|
+
}
|
|
42
|
+
return <div data-bloom-field-box="" data-testid={testID} className={className} dir={dir ?? 'ltr'}
|
|
43
|
+
onClick={onClick} onMouseOver={onMouseOver} onMouseOut={onMouseOut}
|
|
44
|
+
style={{ ...variables, ...resolveNativeWebStyle(style), ...resolveNativeWebStyle(stateStyle), pointerEvents }}>
|
|
45
|
+
{/* RNW resolves logical styles from its own direction context. This
|
|
46
|
+
context carrier has no CSS box; the div remains the sole layout host. */}
|
|
47
|
+
<View {...{ dir: dir ?? 'ltr' }} style={{ display: 'contents' }}>{children}</View>
|
|
48
|
+
</div>;
|
|
49
|
+
}
|
|
50
|
+
const NativeFieldBox = styled(FieldBoxComponent, { className: 'style' });
|
|
51
|
+
export const FieldBox = Platform.OS === 'web' ? FieldBoxComponent : NativeFieldBox;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useBloomAppearance } from '../appearance';
|
|
2
|
+
import { FieldBox } from './FieldBox';
|
|
2
3
|
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import {
|
|
4
5
|
type AccessibilityProps,
|
|
@@ -88,6 +89,7 @@ interface TextFieldContextValue {
|
|
|
88
89
|
addonFocused: boolean;
|
|
89
90
|
/** Inside an `InputGroup`: the group paints the shell, so the field draws none. */
|
|
90
91
|
bare: boolean;
|
|
92
|
+
chromeClassName?: string;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
/**
|
|
@@ -167,6 +169,8 @@ export function TextField({
|
|
|
167
169
|
size: sizeProp,
|
|
168
170
|
radius = TEXT_FIELD_RADIUS,
|
|
169
171
|
leadingAddon,
|
|
172
|
+
className,
|
|
173
|
+
chromeClassName,
|
|
170
174
|
style,
|
|
171
175
|
}: TextFieldProps) {
|
|
172
176
|
const theme = useTheme();
|
|
@@ -223,15 +227,18 @@ export function TextField({
|
|
|
223
227
|
palette,
|
|
224
228
|
radius,
|
|
225
229
|
bare,
|
|
230
|
+
chromeClassName,
|
|
226
231
|
}),
|
|
227
|
-
[inputRef, hovered, onHoverIn, onHoverOut, focused, onFocus, onBlur, addonFocused, invalid, resolvedDisabled, size, palette, radius, bare],
|
|
232
|
+
[inputRef, hovered, onHoverIn, onHoverOut, focused, onFocus, onBlur, addonFocused, invalid, resolvedDisabled, size, palette, radius, bare, chromeClassName],
|
|
228
233
|
);
|
|
229
234
|
|
|
230
235
|
return (
|
|
231
236
|
<Context.Provider value={context}>
|
|
232
|
-
<
|
|
237
|
+
<FieldBox
|
|
233
238
|
{...direction}
|
|
234
|
-
|
|
239
|
+
className={className}
|
|
240
|
+
style={style}
|
|
241
|
+
baseStyle={[
|
|
235
242
|
a.flex_row,
|
|
236
243
|
a.align_center,
|
|
237
244
|
a.relative,
|
|
@@ -243,7 +250,6 @@ export function TextField({
|
|
|
243
250
|
? TEXT_FIELD_ADDON_PADDING[size]
|
|
244
251
|
: { paddingHorizontal: TEXT_FIELD_GEOMETRY[size].paddingHorizontal },
|
|
245
252
|
],
|
|
246
|
-
style,
|
|
247
253
|
]}
|
|
248
254
|
{...(IS_WEB
|
|
249
255
|
? ({
|
|
@@ -256,7 +262,7 @@ export function TextField({
|
|
|
256
262
|
<LeadingAddon onFocusChange={setAddonFocused}>{leadingAddon}</LeadingAddon>
|
|
257
263
|
) : null}
|
|
258
264
|
{children}
|
|
259
|
-
</
|
|
265
|
+
</FieldBox>
|
|
260
266
|
</Context.Provider>
|
|
261
267
|
);
|
|
262
268
|
}
|
|
@@ -328,9 +334,11 @@ function Chrome({ invalid }: { invalid: boolean }) {
|
|
|
328
334
|
disabled: ctx.disabled,
|
|
329
335
|
});
|
|
330
336
|
return (
|
|
331
|
-
<
|
|
337
|
+
<FieldBox
|
|
332
338
|
pointerEvents="none"
|
|
333
|
-
|
|
339
|
+
className={ctx.chromeClassName}
|
|
340
|
+
stateStyle={ctx.disabled || invalid ? paint : ctx.focused || ctx.addonFocused ? { borderColor: paint.borderColor } : undefined}
|
|
341
|
+
baseStyle={[
|
|
334
342
|
a.z_10,
|
|
335
343
|
a.absolute,
|
|
336
344
|
a.inset_0,
|
package/src/text-field/types.ts
CHANGED
|
@@ -8,6 +8,10 @@ export type { TextFieldSize } from './shared';
|
|
|
8
8
|
|
|
9
9
|
export type TextFieldProps = React.PropsWithChildren<
|
|
10
10
|
{
|
|
11
|
+
/** Classes on the layout host: width, height and padding. */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Classes on the inset surface: background, border/ring and radius. State paint remains authoritative. */
|
|
14
|
+
chromeClassName?: string;
|
|
11
15
|
invalid?: boolean;
|
|
12
16
|
isInvalid?: boolean;
|
|
13
17
|
/**
|