@oxy.so/bloom 7.16.0 → 7.17.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 +4 -4
- package/docs/carousel.mdx +22 -0
- package/docs/dialog.mdx +15 -0
- package/docs/overlay.mdx +9 -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/dialog/Dialog.js +12 -2
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +26 -4
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogMorph.js +4 -4
- package/lib/commonjs/overlay/ModalKeyboard.js +8 -6
- package/lib/commonjs/overlay/ModalKeyboard.js.map +1 -1
- package/lib/commonjs/overlay/modal-keyboard.js +54 -0
- package/lib/commonjs/overlay/modal-keyboard.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/dialog/Dialog.js +12 -2
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +26 -4
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogMorph.js +4 -4
- package/lib/module/overlay/ModalKeyboard.js +9 -7
- package/lib/module/overlay/ModalKeyboard.js.map +1 -1
- package/lib/module/overlay/modal-keyboard.js +52 -0
- package/lib/module/overlay/modal-keyboard.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/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogMorph.d.ts +4 -4
- package/lib/typescript/commonjs/overlay/ModalKeyboard.d.ts +1 -1
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts +4 -0
- package/lib/typescript/commonjs/overlay/modal-keyboard.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/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogMorph.d.ts +4 -4
- package/lib/typescript/module/overlay/ModalKeyboard.d.ts +1 -1
- package/lib/typescript/module/overlay/modal-keyboard.d.ts +4 -0
- package/lib/typescript/module/overlay/modal-keyboard.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/dialog/Dialog.tsx +8 -3
- package/src/dialog/Dialog.web.tsx +39 -23
- package/src/dialog/DialogMorph.tsx +4 -4
- package/src/overlay/ModalKeyboard.tsx +7 -7
- package/src/overlay/modal-keyboard.ts +39 -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
|
@@ -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
|
/**
|