@multiplatform.one/components 7.61.0 → 7.62.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/dist/cjs/Chip/index.cjs +29 -12
- package/dist/cjs/Chip/index.native.js +29 -12
- package/dist/cjs/Chip/index.native.js.map +1 -1
- package/dist/cjs/formLayouts/FormLayouts.cjs +52 -9
- package/dist/cjs/formLayouts/FormLayouts.native.js +52 -9
- package/dist/cjs/formLayouts/FormLayouts.native.js.map +1 -1
- package/dist/cjs/formLayouts/PreferencePanel.cjs +27 -11
- package/dist/cjs/formLayouts/PreferencePanel.native.js +27 -11
- package/dist/cjs/formLayouts/PreferencePanel.native.js.map +1 -1
- package/dist/cjs/formLayouts/index.cjs +2 -1
- package/dist/cjs/formLayouts/index.native.js +2 -1
- package/dist/cjs/formLayouts/index.native.js.map +1 -1
- package/dist/cjs/layouts/tags.cjs +25 -73
- package/dist/cjs/layouts/tags.native.js +26 -79
- package/dist/cjs/layouts/tags.native.js.map +1 -1
- package/dist/esm/Accordion/index.native.js.map +1 -1
- package/dist/esm/AnimateHeight/index.native.js.map +1 -1
- package/dist/esm/Avatar/getInitials.native.js.map +1 -1
- package/dist/esm/Avatar/index.native.js.map +1 -1
- package/dist/esm/Badge/index.native.js.map +1 -1
- package/dist/esm/Button.native.js.map +1 -1
- package/dist/esm/Carousel/index.native.js.map +1 -1
- package/dist/esm/Chip/index.mjs +31 -15
- package/dist/esm/Chip/index.mjs.map +1 -1
- package/dist/esm/Chip/index.native.js +31 -15
- package/dist/esm/Chip/index.native.js.map +1 -1
- package/dist/esm/Collapsible.native.js.map +1 -1
- package/dist/esm/ContextMenu/index.native.js.map +1 -1
- package/dist/esm/CopyField/index.native.js.map +1 -1
- package/dist/esm/Dialog.native.js.map +1 -1
- package/dist/esm/DotIndicator/index.native.js.map +1 -1
- package/dist/esm/DropdownMenu/index.native.js.map +1 -1
- package/dist/esm/ErrorBoundary/index.native.js.map +1 -1
- package/dist/esm/Heading.native.js.map +1 -1
- package/dist/esm/Meter/index.native.js.map +1 -1
- package/dist/esm/Meter/meter.native.js.map +1 -1
- package/dist/esm/OverflowRow/index.native.js.map +1 -1
- package/dist/esm/Pagination.native.js.map +1 -1
- package/dist/esm/Popover.native.js.map +1 -1
- package/dist/esm/ProgressSteps/index.native.js.map +1 -1
- package/dist/esm/Quote/index.native.js.map +1 -1
- package/dist/esm/ScrollView/revealFocusedField.native.js.map +1 -1
- package/dist/esm/Separator/index.native.js.map +1 -1
- package/dist/esm/Sheet.native.js.map +1 -1
- package/dist/esm/SheetModal/SheetHeader.native.js.map +1 -1
- package/dist/esm/SheetModal/detents.native.js.map +1 -1
- package/dist/esm/SheetModal/useSheetFrameFocus.native.js.map +1 -1
- package/dist/esm/Skeleton/index.native.js.map +1 -1
- package/dist/esm/SkipLink/index.native.js.map +1 -1
- package/dist/esm/SortableList/SortableHandle.native.js.map +1 -1
- package/dist/esm/SortableList/index.native.js.map +1 -1
- package/dist/esm/SortableList/useSortableRows.native.js.map +1 -1
- package/dist/esm/Tabs/index.native.js.map +1 -1
- package/dist/esm/Text.native.js.map +1 -1
- package/dist/esm/ThemePresetPicker/index.native.js.map +1 -1
- package/dist/esm/Toast/index.native.js.map +1 -1
- package/dist/esm/Toast/store.native.js.map +1 -1
- package/dist/esm/Tooltip/nativePress.native.js.map +1 -1
- package/dist/esm/Tooltip/tooltipShared.native.js.map +1 -1
- package/dist/esm/TreeSelect/index.native.js.map +1 -1
- package/dist/esm/TreeSelect/treeSelectModel.native.js.map +1 -1
- package/dist/esm/Video/PlayerChrome.native.js.map +1 -1
- package/dist/esm/Video/VideoFrame.native.js.map +1 -1
- package/dist/esm/Video/types.native.js.map +1 -1
- package/dist/esm/Wheel/index.native.js.map +1 -1
- package/dist/esm/Wizard/index.native.js.map +1 -1
- package/dist/esm/actions/ActionBar.native.js.map +1 -1
- package/dist/esm/actions/DangerSection.native.js.map +1 -1
- package/dist/esm/actions/DestructiveAction.native.js.map +1 -1
- package/dist/esm/actions/HeaderActions.native.js.map +1 -1
- package/dist/esm/actions/devWarn.native.js.map +1 -1
- package/dist/esm/actions/index.native.js.map +1 -1
- package/dist/esm/actions/severity.native.js.map +1 -1
- package/dist/esm/appShell/BottomAccessory.native.js.map +1 -1
- package/dist/esm/appShell/Dock.native.js.map +1 -1
- package/dist/esm/appShell/ScopeMenu.native.js.map +1 -1
- package/dist/esm/appShell/SettingsSplit.native.js.map +1 -1
- package/dist/esm/appShell/Springboard.native.js.map +1 -1
- package/dist/esm/appShell/SystemBar.native.js.map +1 -1
- package/dist/esm/appShell/TabBar.native.js.map +1 -1
- package/dist/esm/appShell/appTile.native.js.map +1 -1
- package/dist/esm/appShell/bottomChrome.native.js.map +1 -1
- package/dist/esm/appShell/index.native.js.map +1 -1
- package/dist/esm/charts/Axis.native.js.map +1 -1
- package/dist/esm/charts/BarChart.native.js.map +1 -1
- package/dist/esm/charts/ChartDataView.native.js.map +1 -1
- package/dist/esm/charts/ChartSurface.native.js.map +1 -1
- package/dist/esm/charts/LineChart.native.js.map +1 -1
- package/dist/esm/charts/PieChart.native.js.map +1 -1
- package/dist/esm/charts/Sparkline.native.js.map +1 -1
- package/dist/esm/charts/accessibility.native.js.map +1 -1
- package/dist/esm/charts/chartHeight.native.js.map +1 -1
- package/dist/esm/charts/composeChart.native.js.map +1 -1
- package/dist/esm/charts/index.native.js.map +1 -1
- package/dist/esm/charts/math.native.js.map +1 -1
- package/dist/esm/charts/series.native.js.map +1 -1
- package/dist/esm/charts/svg.native.js.map +1 -1
- package/dist/esm/charts/types.native.js.map +1 -1
- package/dist/esm/charts/useChartTheme.native.js.map +1 -1
- package/dist/esm/code/Code/index.native.js.map +1 -1
- package/dist/esm/code/CodeBlock/index.native.js.map +1 -1
- package/dist/esm/code/HighlightedCode/index.native.js.map +1 -1
- package/dist/esm/code/Highlighter/houseSyntaxTheme.native.js.map +1 -1
- package/dist/esm/code/Highlighter/index.native.js.map +1 -1
- package/dist/esm/code/Highlighter/namedGroupMatchAll.native.js.map +1 -1
- package/dist/esm/code/Pre/index.native.js.map +1 -1
- package/dist/esm/code/index.native.js.map +1 -1
- package/dist/esm/componentColors.native.js.map +1 -1
- package/dist/esm/feedback/ConfirmDialog.native.js.map +1 -1
- package/dist/esm/feedback/NotifyHost.native.js.map +1 -1
- package/dist/esm/feedback/copy.native.js.map +1 -1
- package/dist/esm/feedback/index.native.js.map +1 -1
- package/dist/esm/feedback/notify.native.js.map +1 -1
- package/dist/esm/feedback/route.native.js.map +1 -1
- package/dist/esm/feedback/store.native.js.map +1 -1
- package/dist/esm/formLayouts/FormLayouts.mjs +54 -12
- package/dist/esm/formLayouts/FormLayouts.mjs.map +1 -1
- package/dist/esm/formLayouts/FormLayouts.native.js +54 -12
- package/dist/esm/formLayouts/FormLayouts.native.js.map +1 -1
- package/dist/esm/formLayouts/PreferencePanel.mjs +27 -11
- package/dist/esm/formLayouts/PreferencePanel.mjs.map +1 -1
- package/dist/esm/formLayouts/PreferencePanel.native.js +27 -11
- package/dist/esm/formLayouts/PreferencePanel.native.js.map +1 -1
- package/dist/esm/formLayouts/index.mjs +2 -2
- package/dist/esm/formLayouts/index.mjs.map +1 -1
- package/dist/esm/formLayouts/index.native.js +2 -2
- package/dist/esm/formLayouts/index.native.js.map +1 -1
- package/dist/esm/hooks/index.native.js.map +1 -1
- package/dist/esm/hooks/useClipboard.native.js.map +1 -1
- package/dist/esm/hooks/useDocumentTitle.native.js.map +1 -1
- package/dist/esm/icons/CheckRegular.native.js.map +1 -1
- package/dist/esm/icons/MinusRegular.native.js.map +1 -1
- package/dist/esm/icons/index.native.js.map +1 -1
- package/dist/esm/icons/lucide.native.js.map +1 -1
- package/dist/esm/icons/themed.native.js.map +1 -1
- package/dist/esm/images/Image/ImageFrame.native.js.map +1 -1
- package/dist/esm/images/Image/shared.native.js.map +1 -1
- package/dist/esm/images/Image/types.native.js.map +1 -1
- package/dist/esm/images/index.native.js.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/knobImmuneExports.native.js.map +1 -1
- package/dist/esm/layouts/AsyncBoundary.native.js.map +1 -1
- package/dist/esm/layouts/Debug/index.native.js.map +1 -1
- package/dist/esm/layouts/EmptyState.native.js.map +1 -1
- package/dist/esm/layouts/IdentityPlate.native.js.map +1 -1
- package/dist/esm/layouts/KeyboardAvoidingWrapper/behavior.native.js.map +1 -1
- package/dist/esm/layouts/PageTemplates.native.js.map +1 -1
- package/dist/esm/layouts/PaneScaffold.native.js.map +1 -1
- package/dist/esm/layouts/SafeAreaWrapper/insets.native.js.map +1 -1
- package/dist/esm/layouts/StatusDot.native.js.map +1 -1
- package/dist/esm/layouts/ViewSwitcher.native.js.map +1 -1
- package/dist/esm/layouts/attachments.native.js.map +1 -1
- package/dist/esm/layouts/breadcrumbs.native.js.map +1 -1
- package/dist/esm/layouts/index.native.js.map +1 -1
- package/dist/esm/layouts/page.native.js.map +1 -1
- package/dist/esm/layouts/pageHeadingScope.native.js.map +1 -1
- package/dist/esm/layouts/screenScroll.native.js.map +1 -1
- package/dist/esm/layouts/shellSidebarSlot.native.js.map +1 -1
- package/dist/esm/layouts/sidebar.native.js.map +1 -1
- package/dist/esm/layouts/tags.mjs +28 -76
- package/dist/esm/layouts/tags.mjs.map +1 -1
- package/dist/esm/layouts/tags.native.js +29 -82
- package/dist/esm/layouts/tags.native.js.map +1 -1
- package/dist/esm/layouts/timeline.native.js.map +1 -1
- package/dist/esm/layouts/toolbar.native.js.map +1 -1
- package/dist/esm/shared/actionScan.native.js.map +1 -1
- package/dist/esm/shared/i18n.native.js.map +1 -1
- package/dist/esm/shared/restoreRetries.native.js.map +1 -1
- package/dist/esm/shared/t.native.js.map +1 -1
- package/dist/esm/shared/textRidesText.native.js.map +1 -1
- package/dist/esm/shared/useReturnFocusOnClose.native.js.map +1 -1
- package/dist/esm/surfaces.native.js.map +1 -1
- package/dist/esm/tamagui.native.js.map +1 -1
- package/dist/esm/testSetup.native.js.map +1 -1
- package/dist/esm/utils/setTinted.native.js.map +1 -1
- package/dist/esm/utils/unwrapText.native.js.map +1 -1
- package/dist/esm/views/Calendar.native.js.map +1 -1
- package/dist/esm/views/Dashboard.native.js.map +1 -1
- package/dist/esm/views/Gantt.native.js.map +1 -1
- package/dist/esm/views/GanttDateGrip.native.js.map +1 -1
- package/dist/esm/views/ImageGrid.native.js.map +1 -1
- package/dist/esm/views/List.native.js.map +1 -1
- package/dist/esm/views/Matrix.native.js.map +1 -1
- package/dist/esm/views/ReportBuilder.native.js.map +1 -1
- package/dist/esm/views/TreeView.native.js.map +1 -1
- package/dist/esm/views/calendarMath.native.js.map +1 -1
- package/dist/esm/views/ganttIntervals.native.js.map +1 -1
- package/dist/esm/views/ganttMath.native.js.map +1 -1
- package/dist/esm/views/index.native.js.map +1 -1
- package/dist/esm/views/kanbanDnd.native.js.map +1 -1
- package/dist/esm/views/matrixMath.native.js.map +1 -1
- package/dist/esm/views/treeViewDnd.native.js.map +1 -1
- package/dist/esm/views/treeViewLayout.native.js.map +1 -1
- package/dist/esm/views/treeViewMotion.native.js.map +1 -1
- package/dist/esm/views/treeViewReveal.native.js.map +1 -1
- package/dist/jsx/Chip/index.mjs +31 -15
- package/dist/jsx/Chip/index.mjs.map +1 -1
- package/dist/jsx/Chip/index.native.js +29 -12
- package/dist/jsx/Chip/index.native.js.map +1 -1
- package/dist/jsx/formLayouts/FormLayouts.mjs +54 -12
- package/dist/jsx/formLayouts/FormLayouts.mjs.map +1 -1
- package/dist/jsx/formLayouts/FormLayouts.native.js +52 -9
- package/dist/jsx/formLayouts/FormLayouts.native.js.map +1 -1
- package/dist/jsx/formLayouts/PreferencePanel.mjs +27 -11
- package/dist/jsx/formLayouts/PreferencePanel.mjs.map +1 -1
- package/dist/jsx/formLayouts/PreferencePanel.native.js +27 -11
- package/dist/jsx/formLayouts/PreferencePanel.native.js.map +1 -1
- package/dist/jsx/formLayouts/index.mjs +2 -2
- package/dist/jsx/formLayouts/index.mjs.map +1 -1
- package/dist/jsx/formLayouts/index.native.js +2 -1
- package/dist/jsx/formLayouts/index.native.js.map +1 -1
- package/dist/jsx/layouts/tags.mjs +28 -76
- package/dist/jsx/layouts/tags.mjs.map +1 -1
- package/dist/jsx/layouts/tags.native.js +26 -79
- package/dist/jsx/layouts/tags.native.js.map +1 -1
- package/package.json +9 -9
- package/src/Chip/index.tsx +34 -12
- package/src/formLayouts/FormLayouts.spec.tsx +58 -3
- package/src/formLayouts/FormLayouts.stories.tsx +34 -1
- package/src/formLayouts/FormLayouts.tsx +78 -22
- package/src/formLayouts/PreferencePanel.spec.tsx +13 -2
- package/src/formLayouts/PreferencePanel.tsx +39 -21
- package/src/formLayouts/formLayouts.designLaw.spec.ts +6 -4
- package/src/formLayouts/index.ts +1 -0
- package/src/layouts/tags-token-field.spec.tsx +137 -0
- package/src/layouts/tags.glyphInk.spec.tsx +115 -0
- package/src/layouts/tags.tsx +22 -86
- package/types/Chip/index.d.ts +1 -0
- package/types/Chip/index.d.ts.map +1 -1
- package/types/formLayouts/FormLayouts.d.ts +12 -1
- package/types/formLayouts/FormLayouts.d.ts.map +1 -1
- package/types/formLayouts/PreferencePanel.d.ts.map +1 -1
- package/types/formLayouts/index.d.ts +1 -1
- package/types/formLayouts/index.d.ts.map +1 -1
- package/types/layouts/tags.d.ts.map +1 -1
- package/src/layouts/tags-trigger.spec.tsx +0 -145
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { useId, useState } from "react";
|
|
3
|
-
import { Input, Spinner } from "@multiplatform.one/forms";
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { Input, Spinner, useOverlayParentZIndex } from "@multiplatform.one/forms";
|
|
4
|
+
import {
|
|
5
|
+
SurfaceContext,
|
|
6
|
+
layoutBreakpoints,
|
|
7
|
+
useResolvedKnobs,
|
|
8
|
+
type MediaQueryKey,
|
|
9
|
+
} from "@multiplatform.one/theme";
|
|
10
|
+
import {
|
|
11
|
+
AnimatePresence,
|
|
12
|
+
Theme,
|
|
13
|
+
View,
|
|
14
|
+
useMedia,
|
|
15
|
+
useWindowDimensions,
|
|
16
|
+
type FontSizeTokens,
|
|
17
|
+
} from "tamagui";
|
|
6
18
|
import { Button } from "../Button";
|
|
7
19
|
import { Card, type CardProps } from "../Card";
|
|
8
20
|
import { H1, Heading } from "../Heading";
|
|
@@ -20,6 +32,24 @@ export function Hide({ children, when = "sm" }: { children: ReactNode; when: Med
|
|
|
20
32
|
return children;
|
|
21
33
|
}
|
|
22
34
|
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Standalone detection: a form is never a card inside a card (LC-169)
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* True when a form layout stands alone on a wide page: the viewport reaches
|
|
41
|
+
* the `md` breakpoint and no Card, Panel, bar, Sheet, Dialog or Popover
|
|
42
|
+
* holds it. Only then does it raise its own Card; everywhere else it sits on
|
|
43
|
+
* the surface it was placed on (LC-169 CARD-HIERARCHY).
|
|
44
|
+
*/
|
|
45
|
+
export function useStandaloneForm(): boolean {
|
|
46
|
+
const surface = SurfaceContext.useStyledContext();
|
|
47
|
+
const insideOverlay = useOverlayParentZIndex() !== undefined;
|
|
48
|
+
const { width } = useWindowDimensions();
|
|
49
|
+
if (insideOverlay || surface.painted || surface.elevated || surface.bar) return false;
|
|
50
|
+
return width >= layoutBreakpoints.md;
|
|
51
|
+
}
|
|
52
|
+
|
|
23
53
|
// ---------------------------------------------------------------------------
|
|
24
54
|
// FormCard — shared wrapper for form layouts
|
|
25
55
|
// ---------------------------------------------------------------------------
|
|
@@ -28,11 +58,30 @@ export interface FormCardProps extends CardProps {
|
|
|
28
58
|
children: ReactNode;
|
|
29
59
|
}
|
|
30
60
|
|
|
31
|
-
|
|
61
|
+
/**
|
|
62
|
+
* The form's frame. Standalone on a wide page it is the MPO Card; anywhere
|
|
63
|
+
* else it is a bare form that sits on its parent's surface.
|
|
64
|
+
*/
|
|
65
|
+
export function FormCard({ children, tier, size, ...props }: FormCardProps) {
|
|
66
|
+
const { knobProps } = useResolvedKnobs();
|
|
67
|
+
const standalone = useStandaloneForm();
|
|
68
|
+
if (standalone)
|
|
69
|
+
return (
|
|
70
|
+
<Card render="form" data-form-frame="card" tier={tier} size={size} {...props}>
|
|
71
|
+
{children}
|
|
72
|
+
</Card>
|
|
73
|
+
);
|
|
32
74
|
return (
|
|
33
|
-
<
|
|
75
|
+
<View
|
|
76
|
+
render="form"
|
|
77
|
+
data-form-frame="inline"
|
|
78
|
+
flexDirection="column"
|
|
79
|
+
width="100%"
|
|
80
|
+
{...knobProps.gap}
|
|
81
|
+
{...props}
|
|
82
|
+
>
|
|
34
83
|
{children}
|
|
35
|
-
</
|
|
84
|
+
</View>
|
|
36
85
|
);
|
|
37
86
|
}
|
|
38
87
|
|
|
@@ -74,7 +123,7 @@ export function LoginLayout({
|
|
|
74
123
|
};
|
|
75
124
|
|
|
76
125
|
return (
|
|
77
|
-
<FormCard>
|
|
126
|
+
<FormCard width="100%" maxWidth={layoutBreakpoints.xs} alignSelf="center">
|
|
78
127
|
<View
|
|
79
128
|
flexDirection="column"
|
|
80
129
|
alignItems="stretch"
|
|
@@ -83,7 +132,7 @@ export function LoginLayout({
|
|
|
83
132
|
{...knobProps.gapLg}
|
|
84
133
|
$sm={{ paddingVertical: "$4", width: 400 }}
|
|
85
134
|
>
|
|
86
|
-
<H1 alignSelf="center" size="$8" $xs={{ size: "$7" }}>
|
|
135
|
+
<H1 alignSelf="center" size="$8" color="$color12" $xs={{ size: "$7" }}>
|
|
87
136
|
{title}
|
|
88
137
|
</H1>
|
|
89
138
|
|
|
@@ -286,7 +335,7 @@ export function SignUpLayout({
|
|
|
286
335
|
};
|
|
287
336
|
|
|
288
337
|
return (
|
|
289
|
-
<FormCard>
|
|
338
|
+
<FormCard width="100%" maxWidth={layoutBreakpoints.xs} alignSelf="center">
|
|
290
339
|
<View
|
|
291
340
|
flexDirection="column"
|
|
292
341
|
alignItems="stretch"
|
|
@@ -295,7 +344,7 @@ export function SignUpLayout({
|
|
|
295
344
|
{...knobProps.gapLg}
|
|
296
345
|
$xs={{ paddingVertical: "$4" }}
|
|
297
346
|
>
|
|
298
|
-
<H1 size="$9" fontWeight="bold">
|
|
347
|
+
<H1 size="$9" fontWeight="bold" color="$color12">
|
|
299
348
|
{title}
|
|
300
349
|
</H1>
|
|
301
350
|
|
|
@@ -474,30 +523,37 @@ export function SettingsFormLayout({
|
|
|
474
523
|
...props
|
|
475
524
|
}: SettingsFormLayoutProps) {
|
|
476
525
|
const { knobProps } = useResolvedKnobs();
|
|
477
|
-
const
|
|
526
|
+
const standalone = useStandaloneForm();
|
|
527
|
+
const inset = standalone ? knobProps.panelPadding.padding : 0;
|
|
528
|
+
const frame = standalone
|
|
529
|
+
? { paddingVertical: inset, paddingHorizontal: 0, ...knobProps.gapLg }
|
|
530
|
+
: { ...knobProps.gapLg };
|
|
478
531
|
|
|
479
532
|
return (
|
|
480
|
-
<
|
|
481
|
-
render="form"
|
|
482
|
-
paddingVertical={inset}
|
|
483
|
-
paddingHorizontal={0}
|
|
533
|
+
<FormCard
|
|
484
534
|
width="100%"
|
|
485
535
|
maxWidth={layoutBreakpoints.medium}
|
|
486
536
|
alignSelf="center"
|
|
487
|
-
{...
|
|
537
|
+
{...frame}
|
|
488
538
|
$sm={{ maxWidth: "100%" }}
|
|
489
539
|
{...props}
|
|
490
540
|
>
|
|
491
|
-
<H1
|
|
541
|
+
<H1
|
|
542
|
+
{...knobProps.heading}
|
|
543
|
+
size="$8"
|
|
544
|
+
fontWeight="700"
|
|
545
|
+
color="$color12"
|
|
546
|
+
paddingHorizontal={inset}
|
|
547
|
+
>
|
|
492
548
|
{title}
|
|
493
549
|
</H1>
|
|
494
|
-
<Separator />
|
|
550
|
+
{standalone && <Separator />}
|
|
495
551
|
|
|
496
552
|
{sections.map((section, i) => (
|
|
497
553
|
<View key={section.title} flexDirection="column" {...knobProps.gap}>
|
|
498
554
|
<View flexDirection="column" {...knobProps.gap} paddingHorizontal={inset}>
|
|
499
555
|
<View flexDirection="column" gap="$1">
|
|
500
|
-
<Heading margin={0} size={knobProps.sizeToken as FontSizeTokens}>
|
|
556
|
+
<Heading margin={0} size={knobProps.sizeToken as FontSizeTokens} color="$color12">
|
|
501
557
|
{section.title}
|
|
502
558
|
</Heading>
|
|
503
559
|
{section.description && (
|
|
@@ -508,13 +564,13 @@ export function SettingsFormLayout({
|
|
|
508
564
|
</View>
|
|
509
565
|
{section.content}
|
|
510
566
|
</View>
|
|
511
|
-
{i < sections.length - 1 && <Separator />}
|
|
567
|
+
{standalone && i < sections.length - 1 && <Separator />}
|
|
512
568
|
</View>
|
|
513
569
|
))}
|
|
514
570
|
|
|
515
571
|
{footer && (
|
|
516
572
|
<>
|
|
517
|
-
<Separator />
|
|
573
|
+
{standalone && <Separator />}
|
|
518
574
|
<View
|
|
519
575
|
flexDirection="row"
|
|
520
576
|
{...knobProps.gap}
|
|
@@ -525,6 +581,6 @@ export function SettingsFormLayout({
|
|
|
525
581
|
</View>
|
|
526
582
|
</>
|
|
527
583
|
)}
|
|
528
|
-
</
|
|
584
|
+
</FormCard>
|
|
529
585
|
);
|
|
530
586
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { Preset } from "@multiplatform.one/theme";
|
|
2
2
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
3
3
|
import { cleanup } from "@testing-library/react";
|
|
4
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { PreferencePanel } from "./PreferencePanel";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Standalone on a wide page the panel raises its own Card (FZ-8001 r2), so the
|
|
8
|
+
// section groups sit inside it. jsdom leaves documentElement.clientWidth at 0.
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
Object.defineProperty(document.documentElement, "clientWidth", {
|
|
11
|
+
configurable: true,
|
|
12
|
+
value: 1280,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
cleanup();
|
|
17
|
+
Reflect.deleteProperty(document.documentElement, "clientWidth");
|
|
18
|
+
});
|
|
8
19
|
|
|
9
20
|
function renderPanel() {
|
|
10
21
|
renderWithProviders(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "tamagui";
|
|
13
13
|
import { Alert, type AlertIntent } from "../Alert";
|
|
14
14
|
import { Card } from "../Card";
|
|
15
|
+
import { useStandaloneForm } from "./FormLayouts";
|
|
15
16
|
import { H3, Heading } from "../Heading";
|
|
16
17
|
import { Separator } from "../Separator";
|
|
17
18
|
import { Paragraph, Text } from "../Text";
|
|
@@ -157,9 +158,9 @@ function PreferenceRow({ item, size }: { item: PreferenceItem; size: SizeTokens
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
|
-
* A section's rows grouped in one box.
|
|
161
|
-
* painted ancestor,
|
|
162
|
-
*
|
|
161
|
+
* A section's rows grouped in one inset box. Inside the panel's Card, a
|
|
162
|
+
* painted ancestor, `elevatedSurface` resolves border only: nested surfaces
|
|
163
|
+
* never re-elevate.
|
|
163
164
|
*/
|
|
164
165
|
function SectionGroup({ children }: { children?: ReactNode }) {
|
|
165
166
|
const { knobProps } = useResolvedKnobs();
|
|
@@ -188,21 +189,18 @@ export function PreferencePanel({
|
|
|
188
189
|
...props
|
|
189
190
|
}: PreferencePanelProps) {
|
|
190
191
|
const { knobProps } = useResolvedKnobs();
|
|
191
|
-
const
|
|
192
|
+
const standalone = useStandaloneForm();
|
|
193
|
+
const inset = standalone ? knobProps.panelPadding.padding : 0;
|
|
194
|
+
const frame = {
|
|
195
|
+
width: "100%",
|
|
196
|
+
maxWidth: 560,
|
|
197
|
+
alignSelf: "center",
|
|
198
|
+
...knobProps.gap,
|
|
199
|
+
$sm: { maxWidth: "100%" },
|
|
200
|
+
} as const;
|
|
192
201
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{...knobProps.surface}
|
|
196
|
-
paddingVertical={inset}
|
|
197
|
-
paddingHorizontal={0}
|
|
198
|
-
width="100%"
|
|
199
|
-
maxWidth={560}
|
|
200
|
-
alignSelf="center"
|
|
201
|
-
{...knobProps.gap}
|
|
202
|
-
$sm={{ maxWidth: "100%" }}
|
|
203
|
-
size={size}
|
|
204
|
-
{...props}
|
|
205
|
-
>
|
|
202
|
+
const body = (
|
|
203
|
+
<>
|
|
206
204
|
{/* Header */}
|
|
207
205
|
<View flexDirection="column" gap="$1" paddingHorizontal={inset}>
|
|
208
206
|
<H3 fontWeight="700" color="$color12">
|
|
@@ -214,7 +212,7 @@ export function PreferencePanel({
|
|
|
214
212
|
</Theme>
|
|
215
213
|
)}
|
|
216
214
|
</View>
|
|
217
|
-
<Separator />
|
|
215
|
+
{standalone && <Separator />}
|
|
218
216
|
|
|
219
217
|
{/* Sections */}
|
|
220
218
|
{sections.map((section, si) => (
|
|
@@ -245,19 +243,39 @@ export function PreferencePanel({
|
|
|
245
243
|
)}
|
|
246
244
|
</View>
|
|
247
245
|
|
|
248
|
-
{si < sections.length - 1 && <Separator />}
|
|
246
|
+
{standalone && si < sections.length - 1 && <Separator />}
|
|
249
247
|
</View>
|
|
250
248
|
))}
|
|
251
249
|
|
|
252
250
|
{/* Footer */}
|
|
253
251
|
{footer && (
|
|
254
252
|
<>
|
|
255
|
-
<Separator />
|
|
253
|
+
{standalone && <Separator />}
|
|
256
254
|
<View flexDirection="row" {...knobProps.gap} paddingHorizontal={inset}>
|
|
257
255
|
{footer}
|
|
258
256
|
</View>
|
|
259
257
|
</>
|
|
260
258
|
)}
|
|
261
|
-
|
|
259
|
+
</>
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
if (standalone)
|
|
263
|
+
return (
|
|
264
|
+
<Card
|
|
265
|
+
{...knobProps.surface}
|
|
266
|
+
data-form-frame="card"
|
|
267
|
+
paddingVertical={inset}
|
|
268
|
+
paddingHorizontal={0}
|
|
269
|
+
{...frame}
|
|
270
|
+
size={size}
|
|
271
|
+
{...props}
|
|
272
|
+
>
|
|
273
|
+
{body}
|
|
274
|
+
</Card>
|
|
275
|
+
);
|
|
276
|
+
return (
|
|
277
|
+
<View data-form-frame="inline" flexDirection="column" {...frame} {...props}>
|
|
278
|
+
{body}
|
|
279
|
+
</View>
|
|
262
280
|
);
|
|
263
281
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* MPO-116 / MPO-119 CONTAINER-CAP and LC-175 MPO-ONLY-REUSE for the form
|
|
3
3
|
* layouts the app template used to fork in packages/ui (FZ-8001).
|
|
4
4
|
*
|
|
5
|
-
* FormCard and SettingsFormLayout
|
|
6
|
-
* (cardSurface carries it) and neither
|
|
5
|
+
* FormCard and SettingsFormLayout raise the MPO Card when they stand alone
|
|
6
|
+
* (LC-169), so the cap is Card's (cardSurface carries it) and neither
|
|
7
|
+
* re-derives it. PreferencePanel's
|
|
7
8
|
* section banner is the MPO Alert; the section stack keeps its own cap
|
|
8
9
|
* after elevatedSurface.
|
|
9
10
|
*/
|
|
@@ -34,13 +35,14 @@ describe("FZ-8001: FormCard and SettingsFormLayout render the MPO Card", () => {
|
|
|
34
35
|
it("FormCard is the MPO Card rendered as a form, with no frame of its own", () => {
|
|
35
36
|
const formCard = declaration(formLayoutsSrc, "FormCard");
|
|
36
37
|
expect(formCard).toContain('<Card render="form"');
|
|
38
|
+
expect(formCard).toContain("useStandaloneForm()");
|
|
37
39
|
expect(formLayoutsSrc).not.toContain("FormCardFrame");
|
|
38
40
|
expect(formLayoutsSrc).not.toMatch(/\bstyled\(/);
|
|
39
41
|
});
|
|
40
42
|
|
|
41
|
-
it("SettingsFormLayout
|
|
43
|
+
it("SettingsFormLayout frames through FormCard, so the radius cap is Card's", () => {
|
|
42
44
|
const settings = declaration(formLayoutsSrc, "SettingsFormLayout");
|
|
43
|
-
expect(settings).toContain("<
|
|
45
|
+
expect(settings).toContain("<FormCard");
|
|
44
46
|
expect(settings).not.toContain("knobProps.surface");
|
|
45
47
|
expect(settings).not.toContain("knobProps.containerRadius");
|
|
46
48
|
expect(settings).not.toContain("knobProps.borderRadius");
|
package/src/formLayouts/index.ts
CHANGED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { TamaguiProvider } from "tamagui";
|
|
2
|
+
// The Tags field is a token field (FZ-8018 round 2, HIG): the inline input
|
|
3
|
+
// after the last chip is the one add affordance. There is no "Add Tag" pill;
|
|
4
|
+
// Return or comma commits, Backspace on an empty input selects and then
|
|
5
|
+
// deletes the last chip.
|
|
6
|
+
// jsdom's getComputedStyle cannot cascade Tamagui's class-based CSS, so this
|
|
7
|
+
// asserts on the atomic classes (same approach as timeline-radius.spec.tsx).
|
|
8
|
+
import { cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
|
|
9
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
10
|
+
import { Preset, createDefaultThemeConfig } from "@multiplatform.one/theme";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
13
|
+
import { Tags } from "./tags";
|
|
14
|
+
|
|
15
|
+
afterEach(cleanup);
|
|
16
|
+
|
|
17
|
+
const tags = [{ id: "tag-1", label: "urgent" }];
|
|
18
|
+
|
|
19
|
+
function classesByPrefix(el: Element, prefixes: string[]): string[] {
|
|
20
|
+
return String(el.className || "")
|
|
21
|
+
.split(" ")
|
|
22
|
+
.filter((c) => prefixes.some((p) => c.startsWith(p)))
|
|
23
|
+
.sort();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Walk up from the chip label to the ChipFrame (first ancestor with padding classes). */
|
|
27
|
+
function chipFrameOf(label: HTMLElement): HTMLElement {
|
|
28
|
+
let el: HTMLElement | null = label.parentElement;
|
|
29
|
+
for (let i = 0; i < 8 && el; i++) {
|
|
30
|
+
if (classesByPrefix(el, ["_pt-", "_pl-"]).length > 0) return el;
|
|
31
|
+
el = el.parentElement;
|
|
32
|
+
}
|
|
33
|
+
throw new Error("chip frame not found");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function renderTags() {
|
|
37
|
+
return renderWithProviders(<Tags tags={tags} onAdd={vi.fn()} onRemove={vi.fn()} />);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function addInput(): HTMLInputElement {
|
|
41
|
+
return screen.getByRole("combobox", { name: "Add Tag" }) as HTMLInputElement;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe("Tags token field: one way to add (FZ-8018)", () => {
|
|
45
|
+
it("renders no Add Tag button, only the labelled inline input", () => {
|
|
46
|
+
renderTags();
|
|
47
|
+
expect(screen.queryByRole("button", { name: "Add Tag" })).toBeNull();
|
|
48
|
+
expect(screen.queryByText("Add Tag")).toBeNull();
|
|
49
|
+
expect(addInput().getAttribute("placeholder")).toBe("Add tag...");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("the input's font size class matches the chip label", () => {
|
|
53
|
+
renderTags();
|
|
54
|
+
expect(classesByPrefix(addInput(), ["_fos-"])).toEqual(
|
|
55
|
+
classesByPrefix(screen.getByText("urgent"), ["_fos-"]),
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* DG-BOR-01 (MPO-106 D3): the RESOLVER owns the outlined hairline floor —
|
|
61
|
+
* `outlined` + `none` draws the enumerated `small` stop (1px on web, LC-148) — and a
|
|
62
|
+
* component adds no second `Math.max(..., 1)` on top.
|
|
63
|
+
*/
|
|
64
|
+
it.each([
|
|
65
|
+
["none", "1px"],
|
|
66
|
+
["small", "1px"],
|
|
67
|
+
["medium", "1px"],
|
|
68
|
+
["large", "2px"],
|
|
69
|
+
] as const)(
|
|
70
|
+
"outlined borderWidth %s resolves to %s on the chips, floored only by the resolver",
|
|
71
|
+
(borderWidth, px) => {
|
|
72
|
+
renderWithProviders(
|
|
73
|
+
<Preset overrides={{ borderWidth, fillStyle: "outlined" }}>
|
|
74
|
+
<Tags tags={tags} onAdd={vi.fn()} onRemove={vi.fn()} />
|
|
75
|
+
</Preset>,
|
|
76
|
+
);
|
|
77
|
+
const chip = chipFrameOf(screen.getByText("urgent"));
|
|
78
|
+
const edges = ["_btw-", "_bbw-", "_blw-", "_brw-"];
|
|
79
|
+
expect(classesByPrefix(chip, edges)).toEqual(edges.map((edge) => `${edge}${px}`).sort());
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
it("the chip label keeps the $3 body line height", () => {
|
|
84
|
+
renderWithProviders(
|
|
85
|
+
<TamaguiProvider config={createDefaultThemeConfig().tamagui} defaultTheme="light">
|
|
86
|
+
<Tags tags={tags} onAdd={vi.fn()} onRemove={vi.fn()} />
|
|
87
|
+
</TamaguiProvider>,
|
|
88
|
+
{ tamagui: false },
|
|
89
|
+
);
|
|
90
|
+
expect(getComputedStyle(screen.getByText("urgent")).lineHeight).toBe("21px");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("Return and comma commit the typed tag", () => {
|
|
94
|
+
const onAdd = vi.fn();
|
|
95
|
+
renderWithProviders(<Tags tags={tags} onAdd={onAdd} onRemove={vi.fn()} />);
|
|
96
|
+
fireEvent.change(addInput(), { target: { value: "design" } });
|
|
97
|
+
fireEvent.keyDown(addInput(), { key: "Enter" });
|
|
98
|
+
expect(onAdd).toHaveBeenLastCalledWith("design");
|
|
99
|
+
fireEvent.change(addInput(), { target: { value: "ops" } });
|
|
100
|
+
fireEvent.keyDown(addInput(), { key: "," });
|
|
101
|
+
expect(onAdd).toHaveBeenLastCalledWith("ops");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("Backspace on an empty input selects the last chip, a second Backspace removes it", () => {
|
|
105
|
+
const onRemove = vi.fn();
|
|
106
|
+
const two = [...tags, { id: "tag-2", label: "infra" }];
|
|
107
|
+
renderWithProviders(<Tags tags={two} onAdd={vi.fn()} onRemove={onRemove} />);
|
|
108
|
+
const lastFrame = () => chipFrameOf(screen.getByText("infra"));
|
|
109
|
+
expect(lastFrame().getAttribute("data-selected")).toBeNull();
|
|
110
|
+
fireEvent.keyDown(addInput(), { key: "Backspace" });
|
|
111
|
+
expect(onRemove).not.toHaveBeenCalled();
|
|
112
|
+
expect(lastFrame().getAttribute("data-selected")).toBe("true");
|
|
113
|
+
expect(chipFrameOf(screen.getByText("urgent")).getAttribute("data-selected")).toBeNull();
|
|
114
|
+
fireEvent.keyDown(addInput(), { key: "Backspace" });
|
|
115
|
+
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
116
|
+
expect(onRemove).toHaveBeenCalledWith(two[1]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("any other key drops the pending selection", () => {
|
|
120
|
+
const onRemove = vi.fn();
|
|
121
|
+
renderWithProviders(<Tags tags={tags} onAdd={vi.fn()} onRemove={onRemove} />);
|
|
122
|
+
fireEvent.keyDown(addInput(), { key: "Backspace" });
|
|
123
|
+
expect(chipFrameOf(screen.getByText("urgent")).getAttribute("data-selected")).toBe("true");
|
|
124
|
+
fireEvent.keyDown(addInput(), { key: "ArrowLeft" });
|
|
125
|
+
expect(chipFrameOf(screen.getByText("urgent")).getAttribute("data-selected")).toBeNull();
|
|
126
|
+
fireEvent.keyDown(addInput(), { key: "Backspace" });
|
|
127
|
+
expect(onRemove).not.toHaveBeenCalled();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("pressing the field focuses the add input and opens the panel", async () => {
|
|
131
|
+
renderTags();
|
|
132
|
+
fireEvent.click(screen.getByTestId("tags-field"));
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(addInput().getAttribute("aria-expanded")).toBe("true");
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// FZ-8019: on native a Phosphor glyph has no CSS colour to inherit, so a
|
|
2
|
+
// dismiss x rendered without `color` falls back to the library's black and
|
|
3
|
+
// disappears on a dark chip. The x, drawn at the dismiss opacity, must clear
|
|
4
|
+
// WCAG 1.4.11 3:1 on its chip and the label AA 4.5:1, in every preset and
|
|
5
|
+
// both schemes.
|
|
6
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
7
|
+
import {
|
|
8
|
+
Preset,
|
|
9
|
+
boldPreset,
|
|
10
|
+
contrastRatio,
|
|
11
|
+
createDefaultThemeConfig,
|
|
12
|
+
densePreset,
|
|
13
|
+
heroPreset,
|
|
14
|
+
normalizeToHex,
|
|
15
|
+
relativeLuminance,
|
|
16
|
+
roomyPreset,
|
|
17
|
+
} from "@multiplatform.one/theme";
|
|
18
|
+
import type { ReactNode } from "react";
|
|
19
|
+
import { getVariableValue, TamaguiProvider, useTheme } from "tamagui";
|
|
20
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
21
|
+
import { CHIP_DISMISS_OPACITY } from "../Chip";
|
|
22
|
+
import { Tags } from "./tags";
|
|
23
|
+
|
|
24
|
+
vi.mock("tamagui", async (original) => ({
|
|
25
|
+
...(await original<typeof import("tamagui")>()),
|
|
26
|
+
isWeb: false,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
vi.mock("@phosphor-icons/react", async (original) => {
|
|
30
|
+
const real = await original<typeof import("@phosphor-icons/react")>();
|
|
31
|
+
const probe =
|
|
32
|
+
(name: string) =>
|
|
33
|
+
({ color }: { color?: string }) => <span data-testid={`glyph-${name}`} data-color={color} />;
|
|
34
|
+
return { ...real, XIcon: probe("x"), PlusIcon: probe("plus"), TagIcon: probe("tag") };
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(cleanup);
|
|
38
|
+
|
|
39
|
+
const config = createDefaultThemeConfig({
|
|
40
|
+
presets: { bold: boldPreset, hero: heroPreset, dense: densePreset, roomy: roomyPreset },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const presets = ["default", "bold", "hero", "dense", "roomy"] as const;
|
|
44
|
+
const schemes = ["light", "dark"] as const;
|
|
45
|
+
|
|
46
|
+
function SurfaceProbe() {
|
|
47
|
+
const theme = useTheme() as unknown as Record<string, unknown>;
|
|
48
|
+
const read = (key: string) => String(getVariableValue(theme[key] as never));
|
|
49
|
+
return <span data-testid="surfaces" data-chip={read("color4")} data-label={read("color12")} />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function channels(hex: string): number[] {
|
|
53
|
+
return [1, 3, 5].map((i) => Number.parseInt(hex.slice(i, i + 2), 16));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ratio(a: string | undefined, b: string | undefined, alpha = 1): number {
|
|
57
|
+
const fg = normalizeToHex(String(a));
|
|
58
|
+
const bg = normalizeToHex(String(b));
|
|
59
|
+
if (!fg || !bg) return 0;
|
|
60
|
+
const back = channels(bg);
|
|
61
|
+
const seen = channels(fg).map((c, i) => Math.round(alpha * c + (1 - alpha) * back[i]));
|
|
62
|
+
const painted = `#${seen.map((c) => c.toString(16).padStart(2, "0")).join("")}`;
|
|
63
|
+
return contrastRatio(relativeLuminance(painted), relativeLuminance(bg));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function renderIn(preset: string, scheme: string, node: ReactNode) {
|
|
67
|
+
return render(
|
|
68
|
+
<TamaguiProvider config={config.tamagui} defaultTheme={scheme} disableInjectCSS>
|
|
69
|
+
{preset === "default" ? node : <Preset preset={preset}>{node}</Preset>}
|
|
70
|
+
</TamaguiProvider>,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
describe("Tags glyph ink on native (FZ-8019)", () => {
|
|
75
|
+
for (const preset of presets) {
|
|
76
|
+
for (const scheme of schemes) {
|
|
77
|
+
it(`${preset} ${scheme}: every dismiss x clears 3:1 and the label 4.5:1 on its chip`, () => {
|
|
78
|
+
renderIn(
|
|
79
|
+
preset,
|
|
80
|
+
scheme,
|
|
81
|
+
<>
|
|
82
|
+
<SurfaceProbe />
|
|
83
|
+
<Tags
|
|
84
|
+
tags={[
|
|
85
|
+
{ id: "a", label: "engineering" },
|
|
86
|
+
{ id: "b", label: "beta-tester" },
|
|
87
|
+
]}
|
|
88
|
+
onAdd={() => {}}
|
|
89
|
+
onRemove={() => {}}
|
|
90
|
+
/>
|
|
91
|
+
</>,
|
|
92
|
+
);
|
|
93
|
+
const surfaces = screen.getByTestId("surfaces").dataset;
|
|
94
|
+
const xs = screen.getAllByTestId("glyph-x");
|
|
95
|
+
expect(xs).toHaveLength(2);
|
|
96
|
+
for (const x of xs) {
|
|
97
|
+
expect(x.dataset.color).toBeDefined();
|
|
98
|
+
expect(
|
|
99
|
+
ratio(x.dataset.color, surfaces.chip, CHIP_DISMISS_OPACITY),
|
|
100
|
+
).toBeGreaterThanOrEqual(3);
|
|
101
|
+
}
|
|
102
|
+
expect(ratio(surfaces.label, surfaces.chip)).toBeGreaterThanOrEqual(4.5);
|
|
103
|
+
expect(screen.queryByTestId("glyph-plus")).toBeNull();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
it(`${preset}: the empty state's tag glyph carries an ink in both schemes`, () => {
|
|
108
|
+
for (const scheme of schemes) {
|
|
109
|
+
renderIn(preset, scheme, <Tags tags={[]} enableAdd={false} />);
|
|
110
|
+
expect(screen.getByTestId("glyph-tag").dataset.color).toBeDefined();
|
|
111
|
+
cleanup();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|