@oxyhq/bloom 0.9.0 → 0.10.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/lib/commonjs/admonition/index.js +2 -2
- package/lib/commonjs/admonition/index.js.map +1 -1
- package/lib/commonjs/alert-dialog/AlertDialog.js +5 -5
- package/lib/commonjs/alert-dialog/AlertDialog.js.map +1 -1
- package/lib/commonjs/avatar-group/AvatarGroupBase.js +49 -47
- package/lib/commonjs/avatar-group/AvatarGroupBase.js.map +1 -1
- package/lib/commonjs/button/Button.js +60 -7
- package/lib/commonjs/button/Button.js.map +1 -1
- package/lib/commonjs/button/Button.web.js +427 -0
- package/lib/commonjs/button/Button.web.js.map +1 -0
- package/lib/commonjs/button/index.js +25 -1
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/button/index.web.js +67 -0
- package/lib/commonjs/button/index.web.js.map +1 -0
- package/lib/commonjs/index.js +70 -70
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +84 -84
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/menu/index.js +2 -2
- package/lib/commonjs/menu/index.js.map +1 -1
- package/lib/commonjs/search-input/index.js +2 -2
- package/lib/commonjs/search-input/index.js.map +1 -1
- package/lib/commonjs/select/index.js +4 -4
- package/lib/commonjs/select/index.js.map +1 -1
- package/lib/commonjs/user-hover-card/UserHoverCard.js +1 -1
- package/lib/commonjs/user-hover-card/UserHoverCard.js.map +1 -1
- package/lib/module/admonition/index.js +1 -1
- package/lib/module/admonition/index.js.map +1 -1
- package/lib/module/alert-dialog/AlertDialog.js +1 -1
- package/lib/module/alert-dialog/AlertDialog.js.map +1 -1
- package/lib/module/avatar-group/AvatarGroupBase.js +49 -47
- package/lib/module/avatar-group/AvatarGroupBase.js.map +1 -1
- package/lib/module/button/Button.js +59 -6
- package/lib/module/button/Button.js.map +1 -1
- package/lib/module/button/Button.web.js +422 -0
- package/lib/module/button/Button.web.js.map +1 -0
- package/lib/module/button/index.js +1 -1
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/button/index.web.js +17 -0
- package/lib/module/button/index.web.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/menu/index.js +1 -1
- package/lib/module/menu/index.js.map +1 -1
- package/lib/module/search-input/index.js +1 -1
- package/lib/module/search-input/index.js.map +1 -1
- package/lib/module/select/index.js +1 -1
- package/lib/module/select/index.js.map +1 -1
- package/lib/module/user-hover-card/UserHoverCard.js +1 -1
- package/lib/module/user-hover-card/UserHoverCard.js.map +1 -1
- package/lib/typescript/commonjs/avatar-group/AvatarGroupBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar-group/types.d.ts +14 -8
- package/lib/typescript/commonjs/avatar-group/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.d.ts +3 -0
- package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.web.d.ts +14 -0
- package/lib/typescript/commonjs/button/Button.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/button/index.d.ts +1 -1
- package/lib/typescript/commonjs/button/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/index.web.d.ts +3 -0
- package/lib/typescript/commonjs/button/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/button/types.d.ts +72 -2
- package/lib/typescript/commonjs/button/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/user-hover-card/types.d.ts +4 -2
- package/lib/typescript/commonjs/user-hover-card/types.d.ts.map +1 -1
- package/lib/typescript/module/avatar-group/AvatarGroupBase.d.ts.map +1 -1
- package/lib/typescript/module/avatar-group/types.d.ts +14 -8
- package/lib/typescript/module/avatar-group/types.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.d.ts +3 -0
- package/lib/typescript/module/button/Button.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.web.d.ts +14 -0
- package/lib/typescript/module/button/Button.web.d.ts.map +1 -0
- package/lib/typescript/module/button/index.d.ts +1 -1
- package/lib/typescript/module/button/index.d.ts.map +1 -1
- package/lib/typescript/module/button/index.web.d.ts +3 -0
- package/lib/typescript/module/button/index.web.d.ts.map +1 -0
- package/lib/typescript/module/button/types.d.ts +72 -2
- package/lib/typescript/module/button/types.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/user-hover-card/types.d.ts +4 -2
- package/lib/typescript/module/user-hover-card/types.d.ts.map +1 -1
- package/package.json +8 -1
- package/src/__tests__/Button.web.test.tsx +201 -0
- package/src/avatar-group/AvatarGroupBase.tsx +54 -46
- package/src/avatar-group/types.ts +14 -8
- package/src/button/Button.tsx +66 -7
- package/src/button/Button.web.tsx +469 -0
- package/src/button/index.ts +4 -0
- package/src/button/index.web.ts +27 -0
- package/src/button/types.ts +98 -2
- package/src/index.web.ts +1 -1
- package/src/user-hover-card/UserHoverCard.tsx +1 -1
- package/src/user-hover-card/types.ts +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAMA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhF,OAAO,EAAE,mBAAmB,EAAE,MAA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QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACjF,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAG/B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC"}
|
|
@@ -9,8 +9,10 @@ export interface UserHoverCardStat {
|
|
|
9
9
|
}
|
|
10
10
|
export interface UserHoverCardProps {
|
|
11
11
|
/**
|
|
12
|
-
* Avatar image source
|
|
13
|
-
*
|
|
12
|
+
* Avatar image source. Accepts a full image URL OR a resolver-handled id
|
|
13
|
+
* (e.g. an Oxy file ID) — it is routed into {@link Avatar}'s `source` prop, so
|
|
14
|
+
* non-URL strings resolve through the consumer's ImageResolver. Null/undefined
|
|
15
|
+
* falls back to the deterministic name-based placeholder.
|
|
14
16
|
*/
|
|
15
17
|
avatar?: string | null;
|
|
16
18
|
/** Canonical, already-resolved display name (an API contract — render directly). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/user-hover-card/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/user-hover-card/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gCAAgC;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/bloom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -95,6 +95,11 @@
|
|
|
95
95
|
},
|
|
96
96
|
"./button": {
|
|
97
97
|
"react-native": "./src/button/index.ts",
|
|
98
|
+
"browser": {
|
|
99
|
+
"types": "./lib/typescript/module/button/index.web.d.ts",
|
|
100
|
+
"import": "./lib/module/button/index.web.js",
|
|
101
|
+
"require": "./lib/commonjs/button/index.web.js"
|
|
102
|
+
},
|
|
98
103
|
"import": {
|
|
99
104
|
"types": "./lib/typescript/module/button/index.d.ts",
|
|
100
105
|
"default": "./lib/module/button/index.js"
|
|
@@ -802,6 +807,8 @@
|
|
|
802
807
|
"devDependencies": {
|
|
803
808
|
"@storybook/addon-docs": "^10",
|
|
804
809
|
"@storybook/react-vite": "^10",
|
|
810
|
+
"@testing-library/dom": "^10.4.1",
|
|
811
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
805
812
|
"@testing-library/react-native": "^13.3.3",
|
|
806
813
|
"@types/jest": "^30.0.0",
|
|
807
814
|
"@types/react": "~19.1.0",
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { act } from 'react';
|
|
7
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
8
|
+
import { getByRole, getByText, getByLabelText, fireEvent } from '@testing-library/dom';
|
|
9
|
+
import '@testing-library/jest-dom';
|
|
10
|
+
|
|
11
|
+
import { BloomThemeProvider } from '../theme/BloomThemeProvider';
|
|
12
|
+
import {
|
|
13
|
+
Button,
|
|
14
|
+
OutlineButton,
|
|
15
|
+
LinkButton,
|
|
16
|
+
DestructiveButton,
|
|
17
|
+
} from '../button/Button.web';
|
|
18
|
+
|
|
19
|
+
// react-dom 19 logs a guard unless this flag is set in test environments.
|
|
20
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
21
|
+
|
|
22
|
+
let container: HTMLDivElement;
|
|
23
|
+
let root: Root;
|
|
24
|
+
|
|
25
|
+
function mount(ui: React.ReactElement): HTMLElement {
|
|
26
|
+
act(() => {
|
|
27
|
+
root.render(
|
|
28
|
+
<BloomThemeProvider mode="light" colorPreset="teal">
|
|
29
|
+
{ui}
|
|
30
|
+
</BloomThemeProvider>,
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
return container;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
container = document.createElement('div');
|
|
38
|
+
document.body.appendChild(container);
|
|
39
|
+
root = createRoot(container);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
act(() => root.unmount());
|
|
44
|
+
container.remove();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('Button.web', () => {
|
|
48
|
+
it('renders a real <button> element', () => {
|
|
49
|
+
const c = mount(<Button>Click me</Button>);
|
|
50
|
+
const btn = getByRole(c, 'button', { name: 'Click me' });
|
|
51
|
+
expect(btn.tagName).toBe('BUTTON');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('defaults to type="button"', () => {
|
|
55
|
+
const c = mount(<Button>Default</Button>);
|
|
56
|
+
expect(getByRole(c, 'button')).toHaveAttribute('type', 'button');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('supports type="submit" for form participation', () => {
|
|
60
|
+
const onSubmit = jest.fn((e: Event) => e.preventDefault());
|
|
61
|
+
const c = mount(
|
|
62
|
+
<form onSubmit={onSubmit as unknown as React.FormEventHandler}>
|
|
63
|
+
<Button type="submit">Submit</Button>
|
|
64
|
+
</form>,
|
|
65
|
+
);
|
|
66
|
+
const btn = getByRole(c, 'button', { name: 'Submit' });
|
|
67
|
+
expect(btn).toHaveAttribute('type', 'submit');
|
|
68
|
+
act(() => {
|
|
69
|
+
fireEvent.click(btn);
|
|
70
|
+
});
|
|
71
|
+
expect(onSubmit).toHaveBeenCalledTimes(1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('fires both onClick and onPress on click', () => {
|
|
75
|
+
const onClick = jest.fn();
|
|
76
|
+
const onPress = jest.fn();
|
|
77
|
+
const c = mount(
|
|
78
|
+
<Button onClick={onClick} onPress={onPress}>
|
|
79
|
+
Go
|
|
80
|
+
</Button>,
|
|
81
|
+
);
|
|
82
|
+
act(() => {
|
|
83
|
+
fireEvent.click(getByRole(c, 'button'));
|
|
84
|
+
});
|
|
85
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
86
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('does not fire handlers when disabled', () => {
|
|
90
|
+
const onPress = jest.fn();
|
|
91
|
+
const c = mount(
|
|
92
|
+
<Button disabled onPress={onPress}>
|
|
93
|
+
Nope
|
|
94
|
+
</Button>,
|
|
95
|
+
);
|
|
96
|
+
const btn = getByRole(c, 'button');
|
|
97
|
+
expect(btn).toBeDisabled();
|
|
98
|
+
act(() => {
|
|
99
|
+
fireEvent.click(btn);
|
|
100
|
+
});
|
|
101
|
+
expect(onPress).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('does not fire onPress when loading and marks aria-busy', () => {
|
|
105
|
+
const onPress = jest.fn();
|
|
106
|
+
const c = mount(
|
|
107
|
+
<Button loading onPress={onPress}>
|
|
108
|
+
Saving
|
|
109
|
+
</Button>,
|
|
110
|
+
);
|
|
111
|
+
const btn = getByRole(c, 'button');
|
|
112
|
+
expect(btn).toHaveAttribute('aria-busy', 'true');
|
|
113
|
+
act(() => {
|
|
114
|
+
fireEvent.click(btn);
|
|
115
|
+
});
|
|
116
|
+
expect(onPress).not.toHaveBeenCalled();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('keeps children mounted while loading so width is preserved', () => {
|
|
120
|
+
const c = mount(<Button loading>Submit</Button>);
|
|
121
|
+
expect(getByText(c, 'Submit')).toBeTruthy();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('passes className through so consumer layout classes win', () => {
|
|
125
|
+
const c = mount(<Button className="w-full custom">Wide</Button>);
|
|
126
|
+
const btn = getByRole(c, 'button');
|
|
127
|
+
expect(btn).toHaveClass('bloom-btn');
|
|
128
|
+
expect(btn).toHaveClass('w-full');
|
|
129
|
+
expect(btn).toHaveClass('custom');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('applies aria-label from accessibilityLabel', () => {
|
|
133
|
+
const c = mount(<Button accessibilityLabel="Save changes">Save</Button>);
|
|
134
|
+
expect(getByLabelText(c, 'Save changes')).toBeTruthy();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('exposes testID as data-testid', () => {
|
|
138
|
+
const c = mount(<Button testID="my-btn">Test</Button>);
|
|
139
|
+
expect(c.querySelector('[data-testid="my-btn"]')?.tagName).toBe('BUTTON');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('asChild', () => {
|
|
143
|
+
it('renders the child element (anchor) instead of a button', () => {
|
|
144
|
+
const c = mount(
|
|
145
|
+
<Button asChild>
|
|
146
|
+
<a href="/go">Go</a>
|
|
147
|
+
</Button>,
|
|
148
|
+
);
|
|
149
|
+
const link = getByRole(c, 'link', { name: 'Go' });
|
|
150
|
+
expect(link.tagName).toBe('A');
|
|
151
|
+
expect(link).toHaveAttribute('href', '/go');
|
|
152
|
+
expect(link).toHaveClass('bloom-btn');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('merges onPress onto the child', () => {
|
|
156
|
+
const onPress = jest.fn();
|
|
157
|
+
const c = mount(
|
|
158
|
+
<Button asChild onPress={onPress}>
|
|
159
|
+
<a href="/go">Go</a>
|
|
160
|
+
</Button>,
|
|
161
|
+
);
|
|
162
|
+
act(() => {
|
|
163
|
+
fireEvent.click(getByRole(c, 'link'));
|
|
164
|
+
});
|
|
165
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('web variants', () => {
|
|
170
|
+
it('OutlineButton renders a button', () => {
|
|
171
|
+
const c = mount(<OutlineButton>Outline</OutlineButton>);
|
|
172
|
+
expect(getByRole(c, 'button', { name: 'Outline' }).tagName).toBe('BUTTON');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('LinkButton renders with the link modifier class', () => {
|
|
176
|
+
const c = mount(<LinkButton>Link</LinkButton>);
|
|
177
|
+
expect(getByRole(c, 'button', { name: 'Link' })).toHaveClass('bloom-btn--link');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('DestructiveButton renders a button', () => {
|
|
181
|
+
const c = mount(<DestructiveButton>Delete</DestructiveButton>);
|
|
182
|
+
expect(getByRole(c, 'button', { name: 'Delete' }).tagName).toBe('BUTTON');
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe('size aliases', () => {
|
|
187
|
+
it('accepts shadcn-style sm size', () => {
|
|
188
|
+
const c = mount(<Button size="sm">Small</Button>);
|
|
189
|
+
expect(getByRole(c, 'button', { name: 'Small' }).tagName).toBe('BUTTON');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('size="icon" selects the icon variant', () => {
|
|
193
|
+
const c = mount(
|
|
194
|
+
<Button size="icon" accessibilityLabel="icon">
|
|
195
|
+
x
|
|
196
|
+
</Button>,
|
|
197
|
+
);
|
|
198
|
+
expect(getByRole(c, 'button', { name: 'icon' }).tagName).toBe('BUTTON');
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
@@ -12,12 +12,12 @@ import { useTheme } from '../theme/use-theme';
|
|
|
12
12
|
import { fontSize } from '../styles/tokens';
|
|
13
13
|
import type { AvatarGroupItem, AvatarGroupProps } from './types';
|
|
14
14
|
|
|
15
|
-
/** Ring thickness
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const DEFAULT_OVERLAP_RATIO =
|
|
15
|
+
/** Ring (border) thickness around each avatar, in pixels. Matches the
|
|
16
|
+
* original Mention `AvatarStack` (a single hairline-ish 1px separator). */
|
|
17
|
+
const RING_WIDTH = 1;
|
|
18
|
+
/** Default horizontal overlap as a fraction of avatar size — the original
|
|
19
|
+
* stack pulled each avatar left by `size / 3`. */
|
|
20
|
+
const DEFAULT_OVERLAP_RATIO = 1 / 3;
|
|
21
21
|
|
|
22
22
|
function getItemName(item: AvatarGroupItem): string | undefined {
|
|
23
23
|
return item.displayName ?? item.name ?? item.username;
|
|
@@ -53,13 +53,17 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
53
53
|
}) => {
|
|
54
54
|
const theme = useTheme();
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// The ring is the thin separator drawn between overlapping avatars. It
|
|
57
|
+
// defaults to the page background so avatars read as cleanly punched out of
|
|
58
|
+
// the surface behind them — matching the original Mention stack, which used
|
|
59
|
+
// `theme.colors.background`, not a large `card`-colored ring cell.
|
|
60
|
+
const ring = ringColor ?? theme.colors.background;
|
|
58
61
|
const effectiveOverlap =
|
|
59
62
|
overlap ?? Math.round(size * DEFAULT_OVERLAP_RATIO);
|
|
60
|
-
// Each avatar after the first is pulled left by `overlap
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
+
// Each avatar after the first is pulled left by `overlap`. The cell carries a
|
|
64
|
+
// 1px border on each side, so the negative margin absorbs both borders to
|
|
65
|
+
// keep the visual overlap equal to `effectiveOverlap`.
|
|
66
|
+
const negativeMargin = -(effectiveOverlap + RING_WIDTH * 2);
|
|
63
67
|
|
|
64
68
|
const shown = useMemo(
|
|
65
69
|
() => items.slice(0, Math.max(0, max)),
|
|
@@ -69,24 +73,30 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
69
73
|
const realTotal = total ?? items.length;
|
|
70
74
|
const overflow = Math.max(0, realTotal - shown.length);
|
|
71
75
|
|
|
76
|
+
// Each cell is a circular, clipped container with a 1px ring border. The inner
|
|
77
|
+
// Avatar is inset by the border on both sides so the image fills the circle
|
|
78
|
+
// exactly inside the ring.
|
|
79
|
+
const innerSize = size - RING_WIDTH * 2;
|
|
72
80
|
const cellStyle = useMemo((): ViewStyle => {
|
|
73
81
|
return {
|
|
74
|
-
width: size
|
|
75
|
-
height: size
|
|
76
|
-
borderRadius:
|
|
77
|
-
|
|
82
|
+
width: size,
|
|
83
|
+
height: size,
|
|
84
|
+
borderRadius: size / 2,
|
|
85
|
+
borderWidth: RING_WIDTH,
|
|
86
|
+
borderColor: ring,
|
|
87
|
+
overflow: 'hidden',
|
|
78
88
|
alignItems: 'center',
|
|
79
89
|
justifyContent: 'center',
|
|
80
90
|
};
|
|
81
|
-
}, [size,
|
|
91
|
+
}, [size, ring]);
|
|
82
92
|
|
|
83
93
|
const overflowTextStyle = useMemo(
|
|
84
94
|
() => ({
|
|
85
|
-
color:
|
|
86
|
-
fontSize: Math.max(fontSize._2xs, Math.round(size * 0.
|
|
95
|
+
color: '#FFFFFF',
|
|
96
|
+
fontSize: Math.max(fontSize._2xs, Math.round(size * 0.36)),
|
|
87
97
|
fontWeight: '600' as const,
|
|
88
98
|
}),
|
|
89
|
-
[
|
|
99
|
+
[size],
|
|
90
100
|
);
|
|
91
101
|
|
|
92
102
|
const interactive = typeof onPressItem === 'function';
|
|
@@ -94,7 +104,7 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
94
104
|
typeof hoverHandlers?.onHoverIn === 'function' ||
|
|
95
105
|
typeof hoverHandlers?.onHoverOut === 'function';
|
|
96
106
|
|
|
97
|
-
// Pressing the "+N"
|
|
107
|
+
// Pressing the "+N" circle surfaces the first hidden member (if any), so
|
|
98
108
|
// consumers can route it to a full member list.
|
|
99
109
|
const firstHidden = items[shown.length];
|
|
100
110
|
const overflowOnPress =
|
|
@@ -128,7 +138,15 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
128
138
|
collapsable={false}
|
|
129
139
|
style={cellStyle}
|
|
130
140
|
>
|
|
131
|
-
|
|
141
|
+
{/*
|
|
142
|
+
Route the item's avatar value through Avatar's `source` prop (not
|
|
143
|
+
`uri`): full URLs pass through directly, while resolver-handled ids
|
|
144
|
+
(e.g. Oxy file IDs) are resolved by the consumer's ImageResolver —
|
|
145
|
+
exactly like the original Mention stack. No `name` is passed, so a
|
|
146
|
+
missing avatar shows Avatar's neutral default placeholder rather
|
|
147
|
+
than a colored deterministic initial.
|
|
148
|
+
*/}
|
|
149
|
+
<Avatar source={item.uri ?? undefined} size={innerSize} />
|
|
132
150
|
</View>
|
|
133
151
|
);
|
|
134
152
|
|
|
@@ -166,7 +184,7 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
166
184
|
})}
|
|
167
185
|
|
|
168
186
|
{overflow > 0 && (
|
|
169
|
-
<
|
|
187
|
+
<OverflowCircle
|
|
170
188
|
count={overflow}
|
|
171
189
|
cellStyle={cellStyle}
|
|
172
190
|
negativeMargin={shown.length > 0 ? negativeMargin : 0}
|
|
@@ -178,7 +196,7 @@ const AvatarGroupBaseComponent: React.FC<AvatarGroupBaseProps> = ({
|
|
|
178
196
|
);
|
|
179
197
|
};
|
|
180
198
|
|
|
181
|
-
function
|
|
199
|
+
function OverflowCircle({
|
|
182
200
|
count,
|
|
183
201
|
cellStyle,
|
|
184
202
|
negativeMargin,
|
|
@@ -192,26 +210,23 @@ function OverflowChip({
|
|
|
192
210
|
onPress?: () => void;
|
|
193
211
|
}) {
|
|
194
212
|
const theme = useTheme();
|
|
195
|
-
// The
|
|
196
|
-
// last avatar's ring. The margin lives on the outer element to keep layout
|
|
213
|
+
// The count circle is anchored at the lowest stacking order so it tucks behind
|
|
214
|
+
// the last avatar's ring. The margin lives on the outer element to keep layout
|
|
197
215
|
// aligned with the overlap.
|
|
198
216
|
const wrapperStyle: ViewStyle = {
|
|
199
217
|
...(negativeMargin !== 0 && { marginLeft: negativeMargin }),
|
|
200
218
|
zIndex: 0,
|
|
201
219
|
};
|
|
202
220
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
+{count}
|
|
213
|
-
</Text>
|
|
214
|
-
</View>
|
|
221
|
+
// A solid "+N" count circle: secondary-text-colored fill with white text,
|
|
222
|
+
// matching the original Mention `ResponsiveAvatarStack` count circle.
|
|
223
|
+
const circle = (
|
|
224
|
+
<View
|
|
225
|
+
style={[cellStyle, { backgroundColor: theme.colors.textSecondary }]}
|
|
226
|
+
>
|
|
227
|
+
<Text allowFontScaling={false} style={textStyle}>
|
|
228
|
+
+{count}
|
|
229
|
+
</Text>
|
|
215
230
|
</View>
|
|
216
231
|
);
|
|
217
232
|
|
|
@@ -223,12 +238,12 @@ function OverflowChip({
|
|
|
223
238
|
accessibilityLabel={`${count} more`}
|
|
224
239
|
style={wrapperStyle}
|
|
225
240
|
>
|
|
226
|
-
{
|
|
241
|
+
{circle}
|
|
227
242
|
</Pressable>
|
|
228
243
|
);
|
|
229
244
|
}
|
|
230
245
|
|
|
231
|
-
return <View style={wrapperStyle}>{
|
|
246
|
+
return <View style={wrapperStyle}>{circle}</View>;
|
|
232
247
|
}
|
|
233
248
|
|
|
234
249
|
const styles = StyleSheet.create({
|
|
@@ -236,13 +251,6 @@ const styles = StyleSheet.create({
|
|
|
236
251
|
flexDirection: 'row',
|
|
237
252
|
alignItems: 'center',
|
|
238
253
|
},
|
|
239
|
-
chipInner: {
|
|
240
|
-
width: '100%',
|
|
241
|
-
height: '100%',
|
|
242
|
-
borderRadius: 999,
|
|
243
|
-
alignItems: 'center',
|
|
244
|
-
justifyContent: 'center',
|
|
245
|
-
},
|
|
246
254
|
});
|
|
247
255
|
|
|
248
256
|
export const AvatarGroupBase = memo(AvatarGroupBaseComponent);
|
|
@@ -3,16 +3,21 @@ import type { StyleProp, ViewStyle } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A single member of an {@link AvatarGroup}. Mirrors the minimal shape needed to
|
|
6
|
-
* render an {@link Avatar} plus drive the optional hover card. `uri`
|
|
7
|
-
* avatar
|
|
8
|
-
*
|
|
6
|
+
* render an {@link Avatar} plus drive the optional hover card. `uri` carries the
|
|
7
|
+
* avatar value (routed into Avatar's `source` prop); `name`/`displayName`/
|
|
8
|
+
* `username` are used for the hover card and accessibility only.
|
|
9
9
|
*/
|
|
10
10
|
export interface AvatarGroupItem {
|
|
11
11
|
/** Stable identity used as a React key and passed back to handlers. */
|
|
12
12
|
id?: string;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Avatar value, routed into {@link Avatar}'s `source` prop. Accepts a full
|
|
15
|
+
* image URL OR a resolver-handled id (e.g. an Oxy file ID) — non-URL strings
|
|
16
|
+
* resolve through the consumer's ImageResolver. Null/undefined renders
|
|
17
|
+
* Avatar's neutral default placeholder.
|
|
18
|
+
*/
|
|
14
19
|
uri?: string | null;
|
|
15
|
-
/**
|
|
20
|
+
/** Name used for the hover card / accessibility when `displayName` is absent. */
|
|
16
21
|
name?: string;
|
|
17
22
|
/** Canonical, already-resolved display name (preferred over `name`). */
|
|
18
23
|
displayName?: string;
|
|
@@ -34,13 +39,14 @@ export interface AvatarGroupProps {
|
|
|
34
39
|
*/
|
|
35
40
|
total?: number;
|
|
36
41
|
/**
|
|
37
|
-
* Horizontal overlap between adjacent avatars in pixels. Defaults to ~
|
|
42
|
+
* Horizontal overlap between adjacent avatars in pixels. Defaults to ~1/3 of
|
|
38
43
|
* `size`. Larger values pull avatars closer together.
|
|
39
44
|
*/
|
|
40
45
|
overlap?: number;
|
|
41
46
|
/**
|
|
42
|
-
* Color of the ring/border drawn around each avatar so
|
|
43
|
-
* Defaults to the theme `
|
|
47
|
+
* Color of the thin ring/border drawn around each avatar so overlapping
|
|
48
|
+
* avatars separate cleanly. Defaults to the theme `background` color so the
|
|
49
|
+
* avatars read as punched out of the surface behind them.
|
|
44
50
|
*/
|
|
45
51
|
ringColor?: string;
|
|
46
52
|
/**
|
package/src/button/Button.tsx
CHANGED
|
@@ -14,10 +14,30 @@ import {
|
|
|
14
14
|
import { useTheme } from '../theme/use-theme';
|
|
15
15
|
import { usePressAnimation } from '../hooks/usePressAnimation';
|
|
16
16
|
import { useInteractionState } from '../hooks/useInteractionState';
|
|
17
|
-
import type { ButtonProps } from './types';
|
|
17
|
+
import type { ButtonProps, ButtonSize, ButtonVariant } from './types';
|
|
18
18
|
|
|
19
19
|
export type { ButtonProps, ButtonVariant, ButtonSize } from './types';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The shared {@link ButtonVariant}/{@link ButtonSize} types include web-only
|
|
23
|
+
* additions (shadcn variants + size aliases) so a single call site type-checks
|
|
24
|
+
* on both platforms. Native normalizes them to its own primitives:
|
|
25
|
+
* - `outline → secondary`, `link → text`, `destructive → primary` (tinted)
|
|
26
|
+
* - `sm|md|lg|icon` size aliases → `small|medium|large`
|
|
27
|
+
*/
|
|
28
|
+
type NativeVariant = 'primary' | 'secondary' | 'inverse' | 'icon' | 'ghost' | 'text';
|
|
29
|
+
type NativeSize = 'small' | 'medium' | 'large';
|
|
30
|
+
|
|
31
|
+
const SIZE_ALIAS: Record<ButtonSize, NativeSize> = {
|
|
32
|
+
small: 'small',
|
|
33
|
+
medium: 'medium',
|
|
34
|
+
large: 'large',
|
|
35
|
+
sm: 'small',
|
|
36
|
+
md: 'medium',
|
|
37
|
+
lg: 'large',
|
|
38
|
+
icon: 'medium',
|
|
39
|
+
};
|
|
40
|
+
|
|
21
41
|
const SIZE_CONFIG = {
|
|
22
42
|
small: {
|
|
23
43
|
paddingVertical: 6,
|
|
@@ -48,8 +68,8 @@ const ButtonComponent: React.FC<ButtonProps> = ({
|
|
|
48
68
|
onPress,
|
|
49
69
|
children,
|
|
50
70
|
disabled = false,
|
|
51
|
-
variant = 'primary',
|
|
52
|
-
size = 'medium',
|
|
71
|
+
variant: variantProp = 'primary',
|
|
72
|
+
size: sizeProp = 'medium',
|
|
53
73
|
style,
|
|
54
74
|
textStyle,
|
|
55
75
|
icon,
|
|
@@ -64,6 +84,23 @@ const ButtonComponent: React.FC<ButtonProps> = ({
|
|
|
64
84
|
className,
|
|
65
85
|
}) => {
|
|
66
86
|
const theme = useTheme();
|
|
87
|
+
// The shadcn `size="icon"` shorthand also selects the icon variant unless an
|
|
88
|
+
// explicit variant was given by the caller.
|
|
89
|
+
const variant: NativeVariant = useMemo(() => {
|
|
90
|
+
if (sizeProp === 'icon' && variantProp === 'primary') return 'icon';
|
|
91
|
+
switch (variantProp) {
|
|
92
|
+
case 'outline':
|
|
93
|
+
return 'secondary';
|
|
94
|
+
case 'link':
|
|
95
|
+
return 'text';
|
|
96
|
+
case 'destructive':
|
|
97
|
+
return 'primary';
|
|
98
|
+
default:
|
|
99
|
+
return variantProp;
|
|
100
|
+
}
|
|
101
|
+
}, [variantProp, sizeProp]);
|
|
102
|
+
const isDestructive = variantProp === 'destructive';
|
|
103
|
+
const size: NativeSize = SIZE_ALIAS[sizeProp];
|
|
67
104
|
const hasScaleFeedback = SCALE_VARIANTS.has(variant);
|
|
68
105
|
const isInteractionBlocked = disabled || loading;
|
|
69
106
|
const { scaleAnim, onPressIn: onScalePressIn, onPressOut: onScalePressOut } =
|
|
@@ -112,7 +149,9 @@ const ButtonComponent: React.FC<ButtonProps> = ({
|
|
|
112
149
|
|
|
113
150
|
switch (variant) {
|
|
114
151
|
case 'primary':
|
|
115
|
-
styles.backgroundColor =
|
|
152
|
+
styles.backgroundColor = isDestructive
|
|
153
|
+
? theme.colors.negative
|
|
154
|
+
: theme.colors.primary;
|
|
116
155
|
styles.borderRadius = 20;
|
|
117
156
|
break;
|
|
118
157
|
case 'secondary':
|
|
@@ -143,12 +182,14 @@ const ButtonComponent: React.FC<ButtonProps> = ({
|
|
|
143
182
|
}
|
|
144
183
|
|
|
145
184
|
return styles;
|
|
146
|
-
}, [variant, size, theme]);
|
|
185
|
+
}, [variant, size, theme, isDestructive]);
|
|
147
186
|
|
|
148
187
|
const resolvedTextColor = useMemo((): string => {
|
|
149
188
|
switch (variant) {
|
|
150
189
|
case 'primary':
|
|
151
|
-
return
|
|
190
|
+
return isDestructive
|
|
191
|
+
? theme.colors.negativeForeground
|
|
192
|
+
: theme.colors.primaryForeground;
|
|
152
193
|
case 'secondary':
|
|
153
194
|
return theme.colors.text;
|
|
154
195
|
case 'inverse':
|
|
@@ -160,7 +201,7 @@ const ButtonComponent: React.FC<ButtonProps> = ({
|
|
|
160
201
|
default:
|
|
161
202
|
return theme.colors.text;
|
|
162
203
|
}
|
|
163
|
-
}, [variant, theme]);
|
|
204
|
+
}, [variant, theme, isDestructive]);
|
|
164
205
|
|
|
165
206
|
const computedTextStyle = useMemo((): TextStyle => {
|
|
166
207
|
const sizeConfig = SIZE_CONFIG[size];
|
|
@@ -275,3 +316,21 @@ export const TextButton = memo((props: Omit<ButtonProps, 'variant'>) => (
|
|
|
275
316
|
<Button {...props} variant="text" />
|
|
276
317
|
));
|
|
277
318
|
TextButton.displayName = 'TextButton';
|
|
319
|
+
|
|
320
|
+
// Web/shadcn-aligned variants. On native they normalize to existing primitives
|
|
321
|
+
// (`outline → secondary`, `link → text`, `destructive → primary` tinted with the
|
|
322
|
+
// negative token) inside `Button`, so these stay API-parallel with the web fork.
|
|
323
|
+
export const OutlineButton = memo((props: Omit<ButtonProps, 'variant'>) => (
|
|
324
|
+
<Button {...props} variant="outline" />
|
|
325
|
+
));
|
|
326
|
+
OutlineButton.displayName = 'OutlineButton';
|
|
327
|
+
|
|
328
|
+
export const LinkButton = memo((props: Omit<ButtonProps, 'variant'>) => (
|
|
329
|
+
<Button {...props} variant="link" />
|
|
330
|
+
));
|
|
331
|
+
LinkButton.displayName = 'LinkButton';
|
|
332
|
+
|
|
333
|
+
export const DestructiveButton = memo((props: Omit<ButtonProps, 'variant'>) => (
|
|
334
|
+
<Button {...props} variant="destructive" />
|
|
335
|
+
));
|
|
336
|
+
DestructiveButton.displayName = 'DestructiveButton';
|