@multiplatform.one/components 10.0.0 → 10.1.1
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/dist/cjs/Accordion/index.cjs +1 -50
- package/dist/cjs/Accordion/index.native.cjs +1 -51
- package/dist/cjs/Accordion/index.native.js +1 -51
- package/dist/cjs/Accordion/index.native.js.map +1 -1
- package/dist/cjs/ErrorBoundary/index.cjs +2 -10
- package/dist/cjs/ErrorBoundary/index.native.cjs +2 -10
- package/dist/cjs/ErrorBoundary/index.native.js +2 -10
- package/dist/cjs/ErrorBoundary/index.native.js.map +1 -1
- package/dist/cjs/Tabs/index.cjs +1 -1
- package/dist/cjs/Tabs/index.native.cjs +1 -1
- package/dist/cjs/Tabs/index.native.js +1 -1
- package/dist/cjs/Tabs/index.native.js.map +1 -1
- package/dist/cjs/code/CodeBlock/index.cjs +2 -9
- package/dist/cjs/code/CodeBlock/index.native.cjs +2 -9
- package/dist/cjs/code/CodeBlock/index.native.js +2 -9
- package/dist/cjs/code/CodeBlock/index.native.js.map +1 -1
- package/dist/cjs/layouts/Debug/index.cjs +2 -9
- package/dist/cjs/layouts/Debug/index.native.cjs +2 -10
- package/dist/cjs/layouts/Debug/index.native.js +2 -10
- package/dist/cjs/layouts/Debug/index.native.js.map +1 -1
- package/dist/cjs/layouts/KeyboardAvoidingWrapper/index.cjs +2 -10
- package/dist/cjs/layouts/KeyboardAvoidingWrapper/index.native.cjs +2 -10
- package/dist/cjs/layouts/KeyboardAvoidingWrapper/index.native.js +2 -10
- package/dist/cjs/layouts/KeyboardAvoidingWrapper/index.native.js.map +1 -1
- package/dist/cjs/layouts/page.cjs +3 -11
- package/dist/cjs/layouts/page.native.cjs +3 -11
- package/dist/cjs/layouts/page.native.js +3 -11
- package/dist/cjs/layouts/page.native.js.map +1 -1
- package/dist/cjs/layouts/timeline.cjs +1 -1
- package/dist/cjs/layouts/timeline.native.cjs +1 -1
- package/dist/cjs/layouts/timeline.native.js +1 -1
- package/dist/cjs/layouts/timeline.native.js.map +1 -1
- package/dist/esm/Accordion/index.mjs +1 -50
- package/dist/esm/Accordion/index.mjs.map +1 -1
- package/dist/esm/Accordion/index.native.js +1 -51
- package/dist/esm/Accordion/index.native.js.map +1 -1
- package/dist/esm/ErrorBoundary/index.mjs +2 -10
- package/dist/esm/ErrorBoundary/index.mjs.map +1 -1
- package/dist/esm/ErrorBoundary/index.native.js +2 -10
- package/dist/esm/ErrorBoundary/index.native.js.map +1 -1
- package/dist/esm/Tabs/index.mjs +1 -1
- package/dist/esm/Tabs/index.mjs.map +1 -1
- package/dist/esm/Tabs/index.native.js +1 -1
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/code/CodeBlock/index.mjs +3 -10
- package/dist/esm/code/CodeBlock/index.mjs.map +1 -1
- package/dist/esm/code/CodeBlock/index.native.js +3 -10
- package/dist/esm/code/CodeBlock/index.native.js.map +1 -1
- package/dist/esm/layouts/Debug/index.mjs +3 -10
- package/dist/esm/layouts/Debug/index.mjs.map +1 -1
- package/dist/esm/layouts/Debug/index.native.js +3 -11
- package/dist/esm/layouts/Debug/index.native.js.map +1 -1
- package/dist/esm/layouts/KeyboardAvoidingWrapper/index.mjs +2 -10
- package/dist/esm/layouts/KeyboardAvoidingWrapper/index.mjs.map +1 -1
- package/dist/esm/layouts/KeyboardAvoidingWrapper/index.native.js +2 -10
- package/dist/esm/layouts/KeyboardAvoidingWrapper/index.native.js.map +1 -1
- package/dist/esm/layouts/page.mjs +4 -12
- package/dist/esm/layouts/page.mjs.map +1 -1
- package/dist/esm/layouts/page.native.js +4 -12
- package/dist/esm/layouts/page.native.js.map +1 -1
- package/dist/esm/layouts/timeline.mjs +1 -1
- package/dist/esm/layouts/timeline.mjs.map +1 -1
- package/dist/esm/layouts/timeline.native.js +1 -1
- package/dist/esm/layouts/timeline.native.js.map +1 -1
- package/dist/jsx/Accordion/index.mjs +1 -50
- package/dist/jsx/Accordion/index.mjs.map +1 -1
- package/dist/jsx/Accordion/index.native.cjs +1 -51
- package/dist/jsx/Accordion/index.native.js +1 -51
- package/dist/jsx/Accordion/index.native.js.map +1 -1
- package/dist/jsx/ErrorBoundary/index.mjs +2 -10
- package/dist/jsx/ErrorBoundary/index.mjs.map +1 -1
- package/dist/jsx/ErrorBoundary/index.native.cjs +2 -10
- package/dist/jsx/ErrorBoundary/index.native.js +2 -10
- package/dist/jsx/ErrorBoundary/index.native.js.map +1 -1
- package/dist/jsx/Tabs/index.mjs +1 -1
- package/dist/jsx/Tabs/index.mjs.map +1 -1
- package/dist/jsx/Tabs/index.native.cjs +1 -1
- package/dist/jsx/Tabs/index.native.js +1 -1
- package/dist/jsx/Tabs/index.native.js.map +1 -1
- package/dist/jsx/code/CodeBlock/index.mjs +3 -10
- package/dist/jsx/code/CodeBlock/index.mjs.map +1 -1
- package/dist/jsx/code/CodeBlock/index.native.cjs +2 -9
- package/dist/jsx/code/CodeBlock/index.native.js +2 -9
- package/dist/jsx/code/CodeBlock/index.native.js.map +1 -1
- package/dist/jsx/layouts/Debug/index.mjs +3 -10
- package/dist/jsx/layouts/Debug/index.mjs.map +1 -1
- package/dist/jsx/layouts/Debug/index.native.cjs +2 -10
- package/dist/jsx/layouts/Debug/index.native.js +2 -10
- package/dist/jsx/layouts/Debug/index.native.js.map +1 -1
- package/dist/jsx/layouts/KeyboardAvoidingWrapper/index.mjs +2 -10
- package/dist/jsx/layouts/KeyboardAvoidingWrapper/index.mjs.map +1 -1
- package/dist/jsx/layouts/KeyboardAvoidingWrapper/index.native.cjs +2 -10
- package/dist/jsx/layouts/KeyboardAvoidingWrapper/index.native.js +2 -10
- package/dist/jsx/layouts/KeyboardAvoidingWrapper/index.native.js.map +1 -1
- package/dist/jsx/layouts/page.mjs +4 -12
- package/dist/jsx/layouts/page.mjs.map +1 -1
- package/dist/jsx/layouts/page.native.cjs +3 -11
- package/dist/jsx/layouts/page.native.js +3 -11
- package/dist/jsx/layouts/page.native.js.map +1 -1
- package/dist/jsx/layouts/timeline.mjs +1 -1
- package/dist/jsx/layouts/timeline.mjs.map +1 -1
- package/dist/jsx/layouts/timeline.native.cjs +1 -1
- package/dist/jsx/layouts/timeline.native.js +1 -1
- package/dist/jsx/layouts/timeline.native.js.map +1 -1
- package/package.json +7 -7
- package/src/Accordion/Accordion.elevation.spec.tsx +94 -0
- package/src/Accordion/index.tsx +1 -49
- package/src/ErrorBoundary/ErrorBoundary.showMessage.spec.tsx +0 -26
- package/src/ErrorBoundary/index.tsx +2 -12
- package/src/Tabs/Tabs.stripColor.spec.tsx +89 -0
- package/src/Tabs/index.tsx +1 -1
- package/src/code/CodeBlock/CodeBlock.copyable.spec.tsx +0 -21
- package/src/code/CodeBlock/index.tsx +1 -12
- package/src/layouts/Debug/debug.spec.tsx +0 -32
- package/src/layouts/Debug/index.tsx +1 -14
- package/src/layouts/KeyboardAvoidingWrapper/KeyboardAvoidingWrapper.disabled.native.spec.tsx +1 -26
- package/src/layouts/KeyboardAvoidingWrapper/KeyboardAvoidingWrapper.spec.tsx +1 -26
- package/src/layouts/KeyboardAvoidingWrapper/index.native.tsx +1 -12
- package/src/layouts/KeyboardAvoidingWrapper/index.tsx +1 -12
- package/src/layouts/PageTemplates.tsx +1 -1
- package/src/layouts/Screen.flush.spec.tsx +0 -32
- package/src/layouts/page.tsx +3 -14
- package/src/layouts/timeline.tsx +1 -1
- package/types/Accordion/index.d.ts.map +1 -1
- package/types/ErrorBoundary/index.d.ts +0 -2
- package/types/ErrorBoundary/index.d.ts.map +1 -1
- package/types/code/CodeBlock/index.d.ts +1 -3
- package/types/code/CodeBlock/index.d.ts.map +1 -1
- package/types/layouts/Debug/index.d.ts +1 -5
- package/types/layouts/Debug/index.d.ts.map +1 -1
- package/types/layouts/KeyboardAvoidingWrapper/index.d.ts +1 -3
- package/types/layouts/KeyboardAvoidingWrapper/index.d.ts.map +1 -1
- package/types/layouts/KeyboardAvoidingWrapper/index.native.d.ts +1 -3
- package/types/layouts/KeyboardAvoidingWrapper/index.native.d.ts.map +1 -1
- package/types/layouts/PageTemplates.d.ts +1 -1
- package/types/layouts/PageTemplates.d.ts.map +1 -1
- package/types/layouts/page.d.ts +1 -3
- package/types/layouts/page.d.ts.map +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A card Accordion item paints one shadow channel on web (FZ-11122).
|
|
3
|
+
*
|
|
4
|
+
* The item's lift is `knobProps.elevatedSurface` alone: its boxShadow is the
|
|
5
|
+
* only shadow on the frame, with no RN shadow* props and no `elevation` key
|
|
6
|
+
* for the DOM to carry, under every preset and both schemes.
|
|
7
|
+
*/
|
|
8
|
+
import { atomicStyle } from "@multiplatform.one/test-utils";
|
|
9
|
+
import {
|
|
10
|
+
boldPreset,
|
|
11
|
+
consolePreset,
|
|
12
|
+
createDefaultThemeConfig,
|
|
13
|
+
defaultKnobs,
|
|
14
|
+
defaultPreset,
|
|
15
|
+
densePreset,
|
|
16
|
+
heroPreset,
|
|
17
|
+
PresetContext,
|
|
18
|
+
resolveKnobs,
|
|
19
|
+
roomyPreset,
|
|
20
|
+
storefrontPreset,
|
|
21
|
+
type PresetDefinition,
|
|
22
|
+
} from "@multiplatform.one/theme";
|
|
23
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
24
|
+
import { TamaguiProvider } from "tamagui";
|
|
25
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
26
|
+
import { Accordion } from "./index";
|
|
27
|
+
|
|
28
|
+
const presets: Record<string, PresetDefinition> = {
|
|
29
|
+
default: defaultPreset,
|
|
30
|
+
bold: boldPreset,
|
|
31
|
+
hero: heroPreset,
|
|
32
|
+
dense: densePreset,
|
|
33
|
+
roomy: roomyPreset,
|
|
34
|
+
console: consolePreset,
|
|
35
|
+
storefront: storefrontPreset,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const houseConfig = createDefaultThemeConfig();
|
|
39
|
+
|
|
40
|
+
afterEach(cleanup);
|
|
41
|
+
|
|
42
|
+
function renderCard(preset: PresetDefinition, scheme: "light" | "dark") {
|
|
43
|
+
render(
|
|
44
|
+
<TamaguiProvider config={houseConfig.tamagui} defaultTheme={scheme}>
|
|
45
|
+
<PresetContext.Provider value={{ preset }}>
|
|
46
|
+
<Accordion variant="card" defaultValue="a">
|
|
47
|
+
<Accordion.Item value="a" testID="card-item">
|
|
48
|
+
<Accordion.Trigger>Section A</Accordion.Trigger>
|
|
49
|
+
<Accordion.Content>Body</Accordion.Content>
|
|
50
|
+
</Accordion.Item>
|
|
51
|
+
</Accordion>
|
|
52
|
+
</PresetContext.Provider>
|
|
53
|
+
</TamaguiProvider>,
|
|
54
|
+
);
|
|
55
|
+
return screen.getByTestId("card-item");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function shadowChannels(item: HTMLElement) {
|
|
59
|
+
const inline = Array.from(item.style)
|
|
60
|
+
.filter((property) => /shadow/i.test(property))
|
|
61
|
+
.map((property) => `inline:${property}`);
|
|
62
|
+
const atomic = Object.keys(atomicStyle(item))
|
|
63
|
+
.filter((property) => /shadow/i.test(property))
|
|
64
|
+
.map((property) => `atomic:${property}`);
|
|
65
|
+
const attributes = Array.from(item.attributes)
|
|
66
|
+
.filter((a) => /^(elevation|shadow)/i.test(a.name))
|
|
67
|
+
.map((a) => `attr:${a.name}`);
|
|
68
|
+
return [...inline, ...atomic, ...attributes];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function expectedShadow(preset: PresetDefinition, scheme: "light" | "dark") {
|
|
72
|
+
const { boxShadow } = resolveKnobs({ ...defaultKnobs, ...preset.knobs }, undefined, scheme)
|
|
73
|
+
.knobProps.elevatedSurface;
|
|
74
|
+
return boxShadow?.replace(/\$([\w-]+)/g, "var(--$1)");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
describe("card Accordion item: one shadow channel on web", () => {
|
|
78
|
+
for (const [name, preset] of Object.entries(presets)) {
|
|
79
|
+
for (const scheme of ["light", "dark"] as const) {
|
|
80
|
+
it(`${name} ${scheme}: the lift is elevatedSurface's boxShadow alone`, () => {
|
|
81
|
+
const item = renderCard(preset, scheme);
|
|
82
|
+
const expected = expectedShadow(preset, scheme);
|
|
83
|
+
expect(shadowChannels(item)).toEqual(expected ? ["atomic:boxShadow"] : []);
|
|
84
|
+
expect(atomicStyle(item).boxShadow).toBe(expected);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
it("lifts in light under at least one preset, so the sweep is not vacuous", () => {
|
|
90
|
+
const lifted = Object.values(presets).filter((preset) => expectedShadow(preset, "light"));
|
|
91
|
+
expect(lifted.length).toBeGreaterThan(0);
|
|
92
|
+
for (const preset of lifted) expect(expectedShadow(preset, "light")).toMatch(/^[^,]+$/);
|
|
93
|
+
});
|
|
94
|
+
});
|
package/src/Accordion/index.tsx
CHANGED
|
@@ -199,51 +199,6 @@ function tokenPx(
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
// ── Elevation ─────────────────────────────────────────────────
|
|
203
|
-
// The card item frame is a plain (Collapsible) View — tamagui's `elevation`
|
|
204
|
-
// token shorthand only resolves to a box-shadow on Card/Stack-family frames,
|
|
205
|
-
// so convert the knob's elevation token to explicit shadow props (values
|
|
206
|
-
// mirror forms/InputParts + elevationToProps; native theme emits numeric
|
|
207
|
-
// tokens 20/28/44 per SB-N-04).
|
|
208
|
-
|
|
209
|
-
const cardElevationShadow: Record<string, Record<string, any>> = {
|
|
210
|
-
$1: {
|
|
211
|
-
shadowColor: "#000",
|
|
212
|
-
shadowOffset: { width: 0, height: 1 },
|
|
213
|
-
shadowOpacity: 0.12,
|
|
214
|
-
// house light angle: blur = 2 x y-offset on every tier (Axiom 14)
|
|
215
|
-
shadowRadius: 2,
|
|
216
|
-
elevation: 2,
|
|
217
|
-
},
|
|
218
|
-
$2: {
|
|
219
|
-
shadowColor: "#000",
|
|
220
|
-
shadowOffset: { width: 0, height: 3 },
|
|
221
|
-
shadowOpacity: 0.15,
|
|
222
|
-
shadowRadius: 6,
|
|
223
|
-
elevation: 4,
|
|
224
|
-
},
|
|
225
|
-
$4: {
|
|
226
|
-
shadowColor: "#000",
|
|
227
|
-
shadowOffset: { width: 0, height: 10 },
|
|
228
|
-
shadowOpacity: 0.15,
|
|
229
|
-
shadowRadius: 20,
|
|
230
|
-
elevation: 8,
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const elevationKeyAlias: Record<string, string> = { "20": "$1", "28": "$2", "44": "$4" };
|
|
235
|
-
|
|
236
|
-
function getCardElevationProps(token: string | number | undefined): Record<string, any> {
|
|
237
|
-
if (token == null) return {};
|
|
238
|
-
const key = elevationKeyAlias[String(token)] ?? String(token);
|
|
239
|
-
const shadow = cardElevationShadow[key] ?? cardElevationShadow.$2;
|
|
240
|
-
if (isWeb) {
|
|
241
|
-
const { elevation: _elevation, ...webShadow } = shadow;
|
|
242
|
-
return webShadow;
|
|
243
|
-
}
|
|
244
|
-
return shadow;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
202
|
// ── Chevron ───────────────────────────────────────────────────
|
|
248
203
|
|
|
249
204
|
const ThemedCaretDown = themed(CaretDownIcon as any);
|
|
@@ -433,13 +388,10 @@ const AccordionItem = forwardRef<TamaguiElement, AccordionItemProps>(function Ac
|
|
|
433
388
|
[open, disabled, uid, position],
|
|
434
389
|
);
|
|
435
390
|
|
|
436
|
-
const { elevation: elevationToken, ...elevatedSurfaceRest } = knobProps.elevatedSurface as any;
|
|
437
391
|
const variantProps =
|
|
438
392
|
variant === "card"
|
|
439
393
|
? {
|
|
440
|
-
|
|
441
|
-
...elevatedSurfaceRest,
|
|
442
|
-
...getCardElevationProps(elevationToken),
|
|
394
|
+
...knobProps.elevatedSurface,
|
|
443
395
|
overflow: "hidden" as const,
|
|
444
396
|
}
|
|
445
397
|
: {};
|
|
@@ -49,30 +49,4 @@ describe("ErrorBoundary showMessage (FZ-8079, LC-180)", () => {
|
|
|
49
49
|
expect(loggedBoom()).toBe(true);
|
|
50
50
|
expect(deprecations()).toHaveLength(0);
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
it("the deprecated noMessage still hides the message, logs the error and warns once", () => {
|
|
54
|
-
renderWithProviders(
|
|
55
|
-
<>
|
|
56
|
-
<ErrorBoundary noMessage>
|
|
57
|
-
<Throws />
|
|
58
|
-
</ErrorBoundary>
|
|
59
|
-
<ErrorBoundary noMessage>
|
|
60
|
-
<Throws />
|
|
61
|
-
</ErrorBoundary>
|
|
62
|
-
</>,
|
|
63
|
-
);
|
|
64
|
-
expect(screen.queryByText("Oops, there is an error!")).toBeNull();
|
|
65
|
-
expect(loggedBoom()).toBe(true);
|
|
66
|
-
expect(deprecations()).toHaveLength(1);
|
|
67
|
-
expect(String(deprecations()[0][0])).toContain("use showMessage={false}");
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("showMessage wins over the deprecated name when both are passed", () => {
|
|
71
|
-
renderWithProviders(
|
|
72
|
-
<ErrorBoundary noMessage showMessage>
|
|
73
|
-
<Throws />
|
|
74
|
-
</ErrorBoundary>,
|
|
75
|
-
);
|
|
76
|
-
expect(screen.getByText("Oops, there is an error!")).toBeInTheDocument();
|
|
77
|
-
});
|
|
78
52
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ErrorInfo, ReactNode } from "react";
|
|
2
2
|
import { Component } from "react";
|
|
3
|
-
import { warnDeprecatedProp } from "@multiplatform.one/theme";
|
|
4
3
|
import { useTranslation } from "../shared/i18n";
|
|
5
4
|
import { Button } from "../Button";
|
|
6
5
|
import { EmptyState } from "../layouts/EmptyState";
|
|
@@ -15,8 +14,6 @@ export interface ErrorBoundaryProps {
|
|
|
15
14
|
* nothing; the error is logged either way.
|
|
16
15
|
*/
|
|
17
16
|
showMessage?: boolean;
|
|
18
|
-
/** @deprecated Use `showMessage={false}`. Removed in 10.0.0. */
|
|
19
|
-
noMessage?: boolean;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
interface ErrorBoundaryState {
|
|
@@ -53,16 +50,9 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
|
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
render() {
|
|
56
|
-
const { showMessage
|
|
57
|
-
warnDeprecatedProp({
|
|
58
|
-
component: "ErrorBoundary",
|
|
59
|
-
prop: "noMessage",
|
|
60
|
-
use: "showMessage={false}",
|
|
61
|
-
removal: "10.0.0",
|
|
62
|
-
passed: noMessage !== undefined,
|
|
63
|
-
});
|
|
53
|
+
const { showMessage } = this.props;
|
|
64
54
|
if (this.state.hasError) {
|
|
65
|
-
if (!(showMessage ??
|
|
55
|
+
if (!(showMessage ?? true)) {
|
|
66
56
|
return null;
|
|
67
57
|
}
|
|
68
58
|
return <ErrorFallback onRetry={() => this.setState({ hasError: false })} />;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-11195. Tamagui's flat-values codemod (3.2.3) rewrote
|
|
3
|
+
* `backgroundColor={isBand ? "$color2" : undefined}` into a template literal,
|
|
4
|
+
* so every non-band strip handed Tamagui the string "undefined". In
|
|
5
|
+
* development Tamagui 3 logs `unknown color "undefined"` once per page, which
|
|
6
|
+
* is how 45 catalog stories with a Tabs strip reached the console sweep.
|
|
7
|
+
* The CSS arm holds in every case; the warning arm catches the first case
|
|
8
|
+
* Tamagui has not yet deduplicated.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { atomicStyle } from "@multiplatform.one/test-utils";
|
|
12
|
+
import {
|
|
13
|
+
boldPreset,
|
|
14
|
+
consolePreset,
|
|
15
|
+
createDefaultThemeConfig,
|
|
16
|
+
densePreset,
|
|
17
|
+
getPreset,
|
|
18
|
+
getPresetNames,
|
|
19
|
+
heroPreset,
|
|
20
|
+
Preset,
|
|
21
|
+
roomyPreset,
|
|
22
|
+
storefrontPreset,
|
|
23
|
+
} from "@multiplatform.one/theme";
|
|
24
|
+
import { cleanup, render } from "@testing-library/react";
|
|
25
|
+
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
26
|
+
import { TamaguiProvider } from "tamagui";
|
|
27
|
+
import { Tabs, type TabsProps } from "./index";
|
|
28
|
+
|
|
29
|
+
const presetConfig = createDefaultThemeConfig({
|
|
30
|
+
presets: {
|
|
31
|
+
hero: heroPreset,
|
|
32
|
+
bold: boldPreset,
|
|
33
|
+
dense: densePreset,
|
|
34
|
+
roomy: roomyPreset,
|
|
35
|
+
console: consolePreset,
|
|
36
|
+
storefront: storefrontPreset,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const presetNames = ["default", ...getPresetNames()];
|
|
40
|
+
const schemes = ["light", "dark"] as const;
|
|
41
|
+
const variants: NonNullable<TabsProps["variant"]>[] = ["underline", "contained", "band"];
|
|
42
|
+
|
|
43
|
+
const unknownColor = /unknown colou?r "undefined"/;
|
|
44
|
+
let warn: ReturnType<typeof vi.spyOn>;
|
|
45
|
+
|
|
46
|
+
beforeAll(() => {
|
|
47
|
+
vi.stubEnv("NODE_ENV", "development");
|
|
48
|
+
warn = vi.spyOn(console, "warn");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterAll(() => {
|
|
52
|
+
vi.unstubAllEnvs();
|
|
53
|
+
warn.mockRestore();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
cleanup();
|
|
58
|
+
warn.mockClear();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("Tabs strip never hands Tamagui an undefined colour", () => {
|
|
62
|
+
for (const presetName of presetNames) {
|
|
63
|
+
const hostTheme = getPreset(presetName)?.theme;
|
|
64
|
+
for (const scheme of schemes) {
|
|
65
|
+
it.each(variants)(`${presetName} ${scheme}: %s`, (variant) => {
|
|
66
|
+
const { container } = render(
|
|
67
|
+
<TamaguiProvider config={presetConfig.tamagui} defaultTheme={scheme}>
|
|
68
|
+
<Preset preset={presetName} theme={hostTheme}>
|
|
69
|
+
<Tabs
|
|
70
|
+
variant={variant}
|
|
71
|
+
value="one"
|
|
72
|
+
items={[
|
|
73
|
+
{ value: "one", label: "One" },
|
|
74
|
+
{ value: "two", label: "Two" },
|
|
75
|
+
]}
|
|
76
|
+
/>
|
|
77
|
+
</Preset>
|
|
78
|
+
</TamaguiProvider>,
|
|
79
|
+
);
|
|
80
|
+
const root = container.querySelector(`[data-tabs-variant="${variant}"]`);
|
|
81
|
+
const strip = root?.firstElementChild;
|
|
82
|
+
expect(strip, "the strip renders").toBeTruthy();
|
|
83
|
+
const messages = warn.mock.calls.map((args) => args.map(String).join(" "));
|
|
84
|
+
expect(messages.filter((message) => unknownColor.test(message))).toEqual([]);
|
|
85
|
+
expect(atomicStyle(strip!).backgroundColor ?? "").not.toMatch(/undefined/);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
package/src/Tabs/index.tsx
CHANGED
|
@@ -964,7 +964,7 @@ function TabsRoot({
|
|
|
964
964
|
data-visual-px={sizePx}
|
|
965
965
|
>
|
|
966
966
|
<StripWrapper
|
|
967
|
-
backgroundColor={
|
|
967
|
+
backgroundColor={isBand ? "color-2" : undefined}
|
|
968
968
|
borderBottomWidth={isBand ? 1 : undefined}
|
|
969
969
|
borderBottomColor={isBand ? componentColors.surface.border : undefined}
|
|
970
970
|
{...(isUnderline || isFrame
|
|
@@ -35,25 +35,4 @@ describe("CodeBlock copyable (FZ-8079, LC-180)", () => {
|
|
|
35
35
|
expect(copyAction()).toHaveLength(0);
|
|
36
36
|
expect(deprecations()).toHaveLength(0);
|
|
37
37
|
});
|
|
38
|
-
|
|
39
|
-
it("the deprecated disableCopy still drops the copy action and warns once", () => {
|
|
40
|
-
renderWithProviders(
|
|
41
|
-
<>
|
|
42
|
-
<CodeBlock disableCopy>const x = 1;</CodeBlock>
|
|
43
|
-
<CodeBlock disableCopy>const y = 2;</CodeBlock>
|
|
44
|
-
</>,
|
|
45
|
-
);
|
|
46
|
-
expect(copyAction()).toHaveLength(0);
|
|
47
|
-
expect(deprecations()).toHaveLength(1);
|
|
48
|
-
expect(String(deprecations()[0][0])).toContain("use copyable={false}");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("copyable wins over the deprecated name when both are passed", () => {
|
|
52
|
-
renderWithProviders(
|
|
53
|
-
<CodeBlock disableCopy copyable>
|
|
54
|
-
const x = 1;
|
|
55
|
-
</CodeBlock>,
|
|
56
|
-
);
|
|
57
|
-
expect(copyAction()).toHaveLength(1);
|
|
58
|
-
});
|
|
59
38
|
});
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
useGlyphTintOnSurface,
|
|
17
17
|
useResolvedKnobs,
|
|
18
18
|
transitionProps,
|
|
19
|
-
warnDeprecatedProp,
|
|
20
19
|
} from "@multiplatform.one/theme";
|
|
21
20
|
import { useEffect, useRef, useState } from "react";
|
|
22
21
|
import { useTranslation } from "../../shared/i18n";
|
|
@@ -64,8 +63,6 @@ export interface CodeBlockProps {
|
|
|
64
63
|
highlightLines?: number[];
|
|
65
64
|
/** False drops the copy action (default true). */
|
|
66
65
|
copyable?: boolean;
|
|
67
|
-
/** @deprecated Use `copyable={false}`. Removed in 10.0.0. */
|
|
68
|
-
disableCopy?: boolean;
|
|
69
66
|
/** Font size token */
|
|
70
67
|
size?: string;
|
|
71
68
|
/** A double tap (a double click on the web) on the code, which selects nothing (LC-285). */
|
|
@@ -79,17 +76,9 @@ export function CodeBlock({
|
|
|
79
76
|
showLineNumbers: propShowLineNumbers,
|
|
80
77
|
highlightLines = [],
|
|
81
78
|
copyable,
|
|
82
|
-
disableCopy,
|
|
83
79
|
size,
|
|
84
80
|
onDoubleTap,
|
|
85
81
|
}: CodeBlockProps) {
|
|
86
|
-
warnDeprecatedProp({
|
|
87
|
-
component: "CodeBlock",
|
|
88
|
-
prop: "disableCopy",
|
|
89
|
-
use: "copyable={false}",
|
|
90
|
-
removal: "10.0.0",
|
|
91
|
-
passed: disableCopy !== undefined,
|
|
92
|
-
});
|
|
93
82
|
const { region, copy } = useCopyFeedback();
|
|
94
83
|
const { t } = useTranslation();
|
|
95
84
|
const { knobProps } = useResolvedKnobs();
|
|
@@ -144,7 +133,7 @@ export function CodeBlock({
|
|
|
144
133
|
// Copy is the same Input.Button glyph-ring cap the CopyField/Password
|
|
145
134
|
// slot uses (LC-16); confirm is notify() and the glyph does not flip
|
|
146
135
|
// (DG-FB-01 — the D-copyfield verdict replaces TooltipSimple + icon-swap).
|
|
147
|
-
const showCopy = Boolean(codeText) && (copyable ??
|
|
136
|
+
const showCopy = Boolean(codeText) && (copyable ?? true);
|
|
148
137
|
const activateCopy = () => {
|
|
149
138
|
void copy(codeText);
|
|
150
139
|
};
|
|
@@ -2,7 +2,6 @@ import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
|
2
2
|
import { act, cleanup, fireEvent, screen } from "@testing-library/react";
|
|
3
3
|
import { Paragraph } from "tamagui";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { __resetDevWarnSeen } from "@multiplatform.one/theme";
|
|
6
5
|
import { DebugLayout } from "./index";
|
|
7
6
|
|
|
8
7
|
vi.mock("multiplatform.one", () => ({
|
|
@@ -221,37 +220,6 @@ describe("DebugLayout", () => {
|
|
|
221
220
|
expect(screen.getByTestId("debug-circle")).toBeInTheDocument();
|
|
222
221
|
});
|
|
223
222
|
|
|
224
|
-
it("the deprecated enabled still overrides the env gate and warns once (FZ-8079)", () => {
|
|
225
|
-
__resetDevWarnSeen();
|
|
226
|
-
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
227
|
-
renderWithProviders(
|
|
228
|
-
<>
|
|
229
|
-
<DebugLayout enabled={false}>
|
|
230
|
-
<Paragraph data-testid="child">Hidden chrome</Paragraph>
|
|
231
|
-
</DebugLayout>
|
|
232
|
-
<DebugLayout enabled={false}>
|
|
233
|
-
<Paragraph>Hidden too</Paragraph>
|
|
234
|
-
</DebugLayout>
|
|
235
|
-
</>,
|
|
236
|
-
);
|
|
237
|
-
expect(screen.getByTestId("child")).toBeInTheDocument();
|
|
238
|
-
expect(screen.queryByTestId("debug-circle")).not.toBeInTheDocument();
|
|
239
|
-
const hits = warn.mock.calls.filter(([line]) => String(line).includes("deprecated-prop"));
|
|
240
|
-
expect(hits).toHaveLength(1);
|
|
241
|
-
expect(String(hits[0][0])).toContain("use debug");
|
|
242
|
-
warn.mockRestore();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("debug wins over the deprecated enabled", () => {
|
|
246
|
-
vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
247
|
-
renderWithProviders(
|
|
248
|
-
<DebugLayout debug enabled={false}>
|
|
249
|
-
<Paragraph>Forced chrome</Paragraph>
|
|
250
|
-
</DebugLayout>,
|
|
251
|
-
);
|
|
252
|
-
expect(screen.getByTestId("debug-circle")).toBeInTheDocument();
|
|
253
|
-
});
|
|
254
|
-
|
|
255
223
|
it.skip("should open popover when debug button is clicked", async () => {
|
|
256
224
|
renderWithProviders(
|
|
257
225
|
<DebugLayout>
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
OVERLAY_ANCHOR_GAP,
|
|
4
4
|
radiusClassProps,
|
|
5
5
|
useResolvedKnobs,
|
|
6
|
-
warnDeprecatedProp,
|
|
7
6
|
} from "@multiplatform.one/theme";
|
|
8
7
|
import { componentColors } from "../../componentColors";
|
|
9
8
|
import type { WithLayout } from "@multiplatform.one/platform";
|
|
@@ -27,8 +26,6 @@ export interface DebugLayoutProps<DebugViewProps> {
|
|
|
27
26
|
* chrome is actually on screen (LC-56). Production omits it.
|
|
28
27
|
*/
|
|
29
28
|
debug?: boolean;
|
|
30
|
-
/** @deprecated Use `debug`. Removed in 10.0.0. */
|
|
31
|
-
enabled?: boolean;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
export function DebugLayout<DebugViewProps>({
|
|
@@ -37,18 +34,10 @@ export function DebugLayout<DebugViewProps>({
|
|
|
37
34
|
debugViewProps,
|
|
38
35
|
size,
|
|
39
36
|
debug,
|
|
40
|
-
enabled,
|
|
41
37
|
}: DebugLayoutProps<DebugViewProps>) {
|
|
42
38
|
const { knobProps } = useResolvedKnobs({ component: "DebugLayout" });
|
|
43
|
-
warnDeprecatedProp({
|
|
44
|
-
component: "DebugLayout",
|
|
45
|
-
prop: "enabled",
|
|
46
|
-
use: "debug",
|
|
47
|
-
removal: "10.0.0",
|
|
48
|
-
passed: enabled !== undefined,
|
|
49
|
-
});
|
|
50
39
|
const DebugView = debugView;
|
|
51
|
-
const show = debug ??
|
|
40
|
+
const show = debug ?? config.get("DEBUG") === "1";
|
|
52
41
|
const pipSize = size ?? knobProps.nestedControl.px;
|
|
53
42
|
|
|
54
43
|
if (!show) return <>{children}</>;
|
|
@@ -115,7 +104,5 @@ interface CreateWithDebugLayout<DebugViewProps> {
|
|
|
115
104
|
debugView?: ComponentType<DebugViewProps>;
|
|
116
105
|
debugViewProps?: DebugViewProps;
|
|
117
106
|
debug?: boolean;
|
|
118
|
-
/** @deprecated Use `debug`. Removed in 10.0.0. */
|
|
119
|
-
enabled?: boolean;
|
|
120
107
|
size?: number;
|
|
121
108
|
}
|
package/src/layouts/KeyboardAvoidingWrapper/KeyboardAvoidingWrapper.disabled.native.spec.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { render } from "@testing-library/react";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
4
|
|
|
5
|
-
const state = vi.hoisted(() => ({ enabled: [] as unknown[]
|
|
5
|
+
const state = vi.hoisted(() => ({ enabled: [] as unknown[] }));
|
|
6
6
|
|
|
7
7
|
vi.mock("react-native-web", () => ({
|
|
8
8
|
Keyboard: { isVisible: () => false, dismiss: () => {} },
|
|
@@ -17,46 +17,21 @@ vi.mock("tamagui", () => ({ YStack: ({ children }: { children?: ReactNode }) =>
|
|
|
17
17
|
vi.mock("@multiplatform.one/forms", () => ({
|
|
18
18
|
KeyboardChainScope: ({ children }: { children?: ReactNode }) => children,
|
|
19
19
|
}));
|
|
20
|
-
vi.mock("@multiplatform.one/theme", () => ({ warnDeprecatedProp: state.warn }));
|
|
21
20
|
|
|
22
21
|
const { KeyboardAvoidingWrapper } = await import("./index.native");
|
|
23
22
|
|
|
24
23
|
describe("KeyboardAvoidingWrapper native disabled (FZ-8079, LC-180)", () => {
|
|
25
24
|
beforeEach(() => {
|
|
26
25
|
state.enabled = [];
|
|
27
|
-
state.warn.mockClear();
|
|
28
26
|
});
|
|
29
27
|
|
|
30
28
|
it("avoids the keyboard by default", () => {
|
|
31
29
|
render(<KeyboardAvoidingWrapper>field</KeyboardAvoidingWrapper>);
|
|
32
30
|
expect(state.enabled).toEqual([true]);
|
|
33
|
-
expect(state.warn).toHaveBeenCalledWith(expect.objectContaining({ passed: false }));
|
|
34
31
|
});
|
|
35
32
|
|
|
36
33
|
it("disabled turns keyboard avoidance off", () => {
|
|
37
34
|
render(<KeyboardAvoidingWrapper disabled>field</KeyboardAvoidingWrapper>);
|
|
38
35
|
expect(state.enabled).toEqual([false]);
|
|
39
36
|
});
|
|
40
|
-
|
|
41
|
-
it("the deprecated enabled={false} still turns it off and reports the old name", () => {
|
|
42
|
-
render(<KeyboardAvoidingWrapper enabled={false}>field</KeyboardAvoidingWrapper>);
|
|
43
|
-
expect(state.enabled).toEqual([false]);
|
|
44
|
-
expect(state.warn).toHaveBeenCalledWith(
|
|
45
|
-
expect.objectContaining({
|
|
46
|
-
component: "KeyboardAvoidingWrapper",
|
|
47
|
-
prop: "enabled",
|
|
48
|
-
use: "disabled",
|
|
49
|
-
passed: true,
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("disabled wins over the deprecated name", () => {
|
|
55
|
-
render(
|
|
56
|
-
<KeyboardAvoidingWrapper disabled enabled>
|
|
57
|
-
field
|
|
58
|
-
</KeyboardAvoidingWrapper>,
|
|
59
|
-
);
|
|
60
|
-
expect(state.enabled).toEqual([false]);
|
|
61
|
-
});
|
|
62
37
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cleanup } from "@testing-library/react";
|
|
2
2
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
3
|
-
import {
|
|
4
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
5
4
|
import { resolveKeyboardAvoidingBehavior } from "./behavior";
|
|
6
5
|
import { KeyboardAvoidingWrapper } from "./index";
|
|
7
6
|
|
|
@@ -48,28 +47,4 @@ describe("KeyboardAvoidingWrapper web", () => {
|
|
|
48
47
|
expect(frame.getAttribute("data-disabled")).toBe("true");
|
|
49
48
|
expect(frame.textContent).toContain("Still visible");
|
|
50
49
|
});
|
|
51
|
-
|
|
52
|
-
it("the deprecated enabled={false} maps onto disabled and warns once (FZ-8079)", () => {
|
|
53
|
-
__resetDevWarnSeen();
|
|
54
|
-
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
55
|
-
const { container } = renderWithProviders(
|
|
56
|
-
<>
|
|
57
|
-
<KeyboardAvoidingWrapper enabled={false}>
|
|
58
|
-
<span>One</span>
|
|
59
|
-
</KeyboardAvoidingWrapper>
|
|
60
|
-
<KeyboardAvoidingWrapper enabled={false}>
|
|
61
|
-
<span>Two</span>
|
|
62
|
-
</KeyboardAvoidingWrapper>
|
|
63
|
-
</>,
|
|
64
|
-
);
|
|
65
|
-
const frames = container.querySelectorAll('[data-testid="keyboard-avoiding-wrapper"]');
|
|
66
|
-
expect([...frames].map((frame) => frame.getAttribute("data-disabled"))).toEqual([
|
|
67
|
-
"true",
|
|
68
|
-
"true",
|
|
69
|
-
]);
|
|
70
|
-
const hits = warn.mock.calls.filter(([line]) => String(line).includes("deprecated-prop"));
|
|
71
|
-
expect(hits).toHaveLength(1);
|
|
72
|
-
expect(String(hits[0][0])).toContain("use disabled");
|
|
73
|
-
warn.mockRestore();
|
|
74
|
-
});
|
|
75
50
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PropsWithChildren } from "react";
|
|
2
2
|
import { KeyboardChainScope } from "@multiplatform.one/forms";
|
|
3
|
-
import { warnDeprecatedProp } from "@multiplatform.one/theme";
|
|
4
3
|
import { Keyboard, KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
|
|
5
4
|
import { YStack, type YStackProps } from "tamagui";
|
|
6
5
|
import { resolveKeyboardAvoidingBehavior, type KeyboardAvoidingBehavior } from "./behavior";
|
|
@@ -21,8 +20,6 @@ export interface KeyboardAvoidingWrapperProps extends YStackProps {
|
|
|
21
20
|
keyboardVerticalOffset?: number;
|
|
22
21
|
/** Turns keyboard avoidance off; children still render. */
|
|
23
22
|
disabled?: boolean;
|
|
24
|
-
/** @deprecated Use `disabled`. Removed in 10.0.0. */
|
|
25
|
-
enabled?: boolean;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
/**
|
|
@@ -37,17 +34,9 @@ export function KeyboardAvoidingWrapper({
|
|
|
37
34
|
behavior,
|
|
38
35
|
keyboardVerticalOffset = 0,
|
|
39
36
|
disabled,
|
|
40
|
-
enabled,
|
|
41
37
|
...stackProps
|
|
42
38
|
}: PropsWithChildren<KeyboardAvoidingWrapperProps>) {
|
|
43
|
-
|
|
44
|
-
component: "KeyboardAvoidingWrapper",
|
|
45
|
-
prop: "enabled",
|
|
46
|
-
use: "disabled",
|
|
47
|
-
removal: "10.0.0",
|
|
48
|
-
passed: enabled !== undefined,
|
|
49
|
-
});
|
|
50
|
-
const off = disabled ?? enabled === false;
|
|
39
|
+
const off = disabled ?? false;
|
|
51
40
|
const effectiveBehavior = resolveKeyboardAvoidingBehavior(Platform.OS, behavior);
|
|
52
41
|
|
|
53
42
|
return (
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { warnDeprecatedProp } from "@multiplatform.one/theme";
|
|
2
1
|
import type { PropsWithChildren } from "react";
|
|
3
2
|
import { YStack, type YStackProps } from "tamagui";
|
|
4
3
|
import type { KeyboardAvoidingBehavior } from "./behavior";
|
|
@@ -19,8 +18,6 @@ export interface KeyboardAvoidingWrapperProps extends YStackProps {
|
|
|
19
18
|
keyboardVerticalOffset?: number;
|
|
20
19
|
/** Turns keyboard avoidance off; children still render. */
|
|
21
20
|
disabled?: boolean;
|
|
22
|
-
/** @deprecated Use `disabled`. Removed in 10.0.0. */
|
|
23
|
-
enabled?: boolean;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
/**
|
|
@@ -35,17 +32,9 @@ export function KeyboardAvoidingWrapper({
|
|
|
35
32
|
behavior: _behavior,
|
|
36
33
|
keyboardVerticalOffset: _offset,
|
|
37
34
|
disabled,
|
|
38
|
-
enabled,
|
|
39
35
|
...stackProps
|
|
40
36
|
}: PropsWithChildren<KeyboardAvoidingWrapperProps>) {
|
|
41
|
-
|
|
42
|
-
component: "KeyboardAvoidingWrapper",
|
|
43
|
-
prop: "enabled",
|
|
44
|
-
use: "disabled",
|
|
45
|
-
removal: "10.0.0",
|
|
46
|
-
passed: enabled !== undefined,
|
|
47
|
-
});
|
|
48
|
-
const off = disabled ?? enabled === false;
|
|
37
|
+
const off = disabled ?? false;
|
|
49
38
|
return (
|
|
50
39
|
<YStack
|
|
51
40
|
data-testid="keyboard-avoiding-wrapper"
|
|
@@ -322,7 +322,7 @@ export function SettingsPageLayout({
|
|
|
322
322
|
// ── DensePageLayout ────────────────────────────────────────────────────────
|
|
323
323
|
|
|
324
324
|
export interface DensePageLayoutProps
|
|
325
|
-
extends Omit<ScreenProps, "scroll" | "bleed" | "flush"
|
|
325
|
+
extends Omit<ScreenProps, "scroll" | "bleed" | "flush">, TemplateHeaderProps {
|
|
326
326
|
/** The live state beside the title (a `StatusDot`). */
|
|
327
327
|
status?: ReactNode;
|
|
328
328
|
/**
|