@multiplatform.one/components 7.90.6 → 8.1.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.
Files changed (168) hide show
  1. package/dist/cjs/ChatTurn/index.cjs +105 -0
  2. package/dist/cjs/ChatTurn/index.native.js +109 -0
  3. package/dist/cjs/ChatTurn/index.native.js.map +1 -0
  4. package/dist/cjs/Chip/index.cjs +50 -0
  5. package/dist/cjs/Chip/index.native.js +52 -1
  6. package/dist/cjs/Chip/index.native.js.map +1 -1
  7. package/dist/cjs/DropDownPanel/index.cjs +101 -0
  8. package/dist/cjs/DropDownPanel/index.native.js +109 -0
  9. package/dist/cjs/DropDownPanel/index.native.js.map +1 -0
  10. package/dist/cjs/DropdownMenu/index.cjs +1 -2
  11. package/dist/cjs/DropdownMenu/index.native.js +1 -2
  12. package/dist/cjs/DropdownMenu/index.native.js.map +1 -1
  13. package/dist/cjs/SwipeDismissRow/index.cjs +137 -0
  14. package/dist/cjs/SwipeDismissRow/index.native.js +149 -0
  15. package/dist/cjs/SwipeDismissRow/index.native.js.map +1 -0
  16. package/dist/cjs/appShell/AppShell.cjs +0 -1
  17. package/dist/cjs/appShell/AppShell.native.js +0 -1
  18. package/dist/cjs/appShell/AppShell.native.js.map +1 -1
  19. package/dist/cjs/index.cjs +6 -0
  20. package/dist/cjs/index.gnome.cjs +293 -0
  21. package/dist/cjs/index.gnome.native.js +296 -0
  22. package/dist/cjs/index.gnome.native.js.map +1 -0
  23. package/dist/cjs/index.native.js +6 -0
  24. package/dist/cjs/index.native.js.map +1 -1
  25. package/dist/cjs/layouts/page.cjs +0 -3
  26. package/dist/cjs/layouts/page.native.js +0 -3
  27. package/dist/cjs/layouts/page.native.js.map +1 -1
  28. package/dist/cjs/surfaces.cjs +1 -11
  29. package/dist/cjs/surfaces.native.js +0 -10
  30. package/dist/cjs/surfaces.native.js.map +1 -1
  31. package/dist/esm/ChatTurn/index.mjs +80 -0
  32. package/dist/esm/ChatTurn/index.mjs.map +1 -0
  33. package/dist/esm/ChatTurn/index.native.js +81 -0
  34. package/dist/esm/ChatTurn/index.native.js.map +1 -0
  35. package/dist/esm/Chip/index.mjs +50 -0
  36. package/dist/esm/Chip/index.mjs.map +1 -1
  37. package/dist/esm/Chip/index.native.js +52 -1
  38. package/dist/esm/Chip/index.native.js.map +1 -1
  39. package/dist/esm/DropDownPanel/index.mjs +76 -0
  40. package/dist/esm/DropDownPanel/index.mjs.map +1 -0
  41. package/dist/esm/DropDownPanel/index.native.js +81 -0
  42. package/dist/esm/DropDownPanel/index.native.js.map +1 -0
  43. package/dist/esm/DropdownMenu/index.mjs +1 -2
  44. package/dist/esm/DropdownMenu/index.mjs.map +1 -1
  45. package/dist/esm/DropdownMenu/index.native.js +1 -2
  46. package/dist/esm/DropdownMenu/index.native.js.map +1 -1
  47. package/dist/esm/SwipeDismissRow/index.mjs +110 -0
  48. package/dist/esm/SwipeDismissRow/index.mjs.map +1 -0
  49. package/dist/esm/SwipeDismissRow/index.native.js +119 -0
  50. package/dist/esm/SwipeDismissRow/index.native.js.map +1 -0
  51. package/dist/esm/appShell/AppShell.mjs +0 -1
  52. package/dist/esm/appShell/AppShell.mjs.map +1 -1
  53. package/dist/esm/appShell/AppShell.native.js +0 -1
  54. package/dist/esm/appShell/AppShell.native.js.map +1 -1
  55. package/dist/esm/index.gnome.mjs +69 -0
  56. package/dist/esm/index.gnome.mjs.map +1 -0
  57. package/dist/esm/index.gnome.native.js +69 -0
  58. package/dist/esm/index.gnome.native.js.map +1 -0
  59. package/dist/esm/index.mjs +5 -1
  60. package/dist/esm/index.mjs.map +1 -1
  61. package/dist/esm/index.native.js +5 -1
  62. package/dist/esm/index.native.js.map +1 -1
  63. package/dist/esm/layouts/page.mjs +0 -3
  64. package/dist/esm/layouts/page.mjs.map +1 -1
  65. package/dist/esm/layouts/page.native.js +0 -3
  66. package/dist/esm/layouts/page.native.js.map +1 -1
  67. package/dist/esm/surfaces.mjs +3 -8
  68. package/dist/esm/surfaces.mjs.map +1 -1
  69. package/dist/esm/surfaces.native.js +3 -8
  70. package/dist/esm/surfaces.native.js.map +1 -1
  71. package/dist/jsx/ChatTurn/index.mjs +80 -0
  72. package/dist/jsx/ChatTurn/index.mjs.map +1 -0
  73. package/dist/jsx/ChatTurn/index.native.js +109 -0
  74. package/dist/jsx/ChatTurn/index.native.js.map +1 -0
  75. package/dist/jsx/Chip/index.mjs +50 -0
  76. package/dist/jsx/Chip/index.mjs.map +1 -1
  77. package/dist/jsx/Chip/index.native.js +52 -1
  78. package/dist/jsx/Chip/index.native.js.map +1 -1
  79. package/dist/jsx/DropDownPanel/index.mjs +76 -0
  80. package/dist/jsx/DropDownPanel/index.mjs.map +1 -0
  81. package/dist/jsx/DropDownPanel/index.native.js +109 -0
  82. package/dist/jsx/DropDownPanel/index.native.js.map +1 -0
  83. package/dist/jsx/DropdownMenu/index.mjs +1 -2
  84. package/dist/jsx/DropdownMenu/index.mjs.map +1 -1
  85. package/dist/jsx/DropdownMenu/index.native.js +1 -2
  86. package/dist/jsx/DropdownMenu/index.native.js.map +1 -1
  87. package/dist/jsx/SwipeDismissRow/index.mjs +110 -0
  88. package/dist/jsx/SwipeDismissRow/index.mjs.map +1 -0
  89. package/dist/jsx/SwipeDismissRow/index.native.js +149 -0
  90. package/dist/jsx/SwipeDismissRow/index.native.js.map +1 -0
  91. package/dist/jsx/appShell/AppShell.mjs +0 -1
  92. package/dist/jsx/appShell/AppShell.mjs.map +1 -1
  93. package/dist/jsx/appShell/AppShell.native.js +0 -1
  94. package/dist/jsx/appShell/AppShell.native.js.map +1 -1
  95. package/dist/jsx/index.gnome.mjs +69 -0
  96. package/dist/jsx/index.gnome.mjs.map +1 -0
  97. package/dist/jsx/index.gnome.native.js +296 -0
  98. package/dist/jsx/index.gnome.native.js.map +1 -0
  99. package/dist/jsx/index.js +5 -1
  100. package/dist/jsx/index.js.map +1 -1
  101. package/dist/jsx/index.mjs +5 -1
  102. package/dist/jsx/index.mjs.map +1 -1
  103. package/dist/jsx/index.native.js +6 -0
  104. package/dist/jsx/index.native.js.map +1 -1
  105. package/dist/jsx/layouts/page.mjs +0 -3
  106. package/dist/jsx/layouts/page.mjs.map +1 -1
  107. package/dist/jsx/layouts/page.native.js +0 -3
  108. package/dist/jsx/layouts/page.native.js.map +1 -1
  109. package/dist/jsx/surfaces.mjs +3 -8
  110. package/dist/jsx/surfaces.mjs.map +1 -1
  111. package/dist/jsx/surfaces.native.js +0 -10
  112. package/dist/jsx/surfaces.native.js.map +1 -1
  113. package/package.json +20 -8
  114. package/src/ChatTurn/ChatTurn.spec.tsx +75 -0
  115. package/src/ChatTurn/ChatTurn.stories.tsx +61 -0
  116. package/src/ChatTurn/index.tsx +91 -0
  117. package/src/Chip/Chip.stories.tsx +38 -1
  118. package/src/Chip/Chip.trailingToggle.spec.tsx +99 -0
  119. package/src/Chip/index.tsx +72 -0
  120. package/src/DropDownPanel/DropDownPanel.spec.tsx +55 -0
  121. package/src/DropDownPanel/DropDownPanel.stories.tsx +69 -0
  122. package/src/DropDownPanel/index.tsx +87 -0
  123. package/src/DropdownMenu/index.tsx +0 -1
  124. package/src/SheetModal/SheetModal.menus.spec.tsx +9 -9
  125. package/src/SwipeDismissRow/SwipeDismissRow.spec.tsx +48 -0
  126. package/src/SwipeDismissRow/SwipeDismissRow.stories.tsx +59 -0
  127. package/src/SwipeDismissRow/index.tsx +150 -0
  128. package/src/appShell/AppShell.tsx +1 -1
  129. package/src/checkedRow.native-press.spec.tsx +1 -2
  130. package/src/export-surface.spec.tsx +1 -1
  131. package/src/focusedFieldTheme.native-press.spec.tsx +1 -2
  132. package/src/index.gnome.ts +330 -0
  133. package/src/index.ts +6 -0
  134. package/src/layouts/page.tsx +3 -3
  135. package/src/layouts/topBarConfirm.spec.tsx +22 -25
  136. package/src/overlayStack.native-press.spec.tsx +1 -2
  137. package/src/surfaces.spec.tsx +0 -15
  138. package/src/surfaces.tsx +0 -18
  139. package/src/utils/utils.spec.tsx +1 -42
  140. package/types/ChatTurn/index.d.ts +29 -0
  141. package/types/ChatTurn/index.d.ts.map +1 -0
  142. package/types/Chip/index.d.ts +9 -1
  143. package/types/Chip/index.d.ts.map +1 -1
  144. package/types/DropDownPanel/index.d.ts +11 -0
  145. package/types/DropDownPanel/index.d.ts.map +1 -0
  146. package/types/DropdownMenu/index.d.ts.map +1 -1
  147. package/types/SwipeDismissRow/index.d.ts +18 -0
  148. package/types/SwipeDismissRow/index.d.ts.map +1 -0
  149. package/types/index.d.ts +6 -0
  150. package/types/index.d.ts.map +1 -1
  151. package/types/index.gnome.d.ts +107 -0
  152. package/types/index.gnome.d.ts.map +1 -0
  153. package/types/surfaces.d.ts +0 -24
  154. package/types/surfaces.d.ts.map +1 -1
  155. package/dist/cjs/utils/setTinted.cjs +0 -39
  156. package/dist/cjs/utils/setTinted.native.js +0 -44
  157. package/dist/cjs/utils/setTinted.native.js.map +0 -1
  158. package/dist/esm/utils/setTinted.mjs +0 -11
  159. package/dist/esm/utils/setTinted.mjs.map +0 -1
  160. package/dist/esm/utils/setTinted.native.js +0 -13
  161. package/dist/esm/utils/setTinted.native.js.map +0 -1
  162. package/dist/jsx/utils/setTinted.mjs +0 -11
  163. package/dist/jsx/utils/setTinted.mjs.map +0 -1
  164. package/dist/jsx/utils/setTinted.native.js +0 -44
  165. package/dist/jsx/utils/setTinted.native.js.map +0 -1
  166. package/src/utils/setTinted.ts +0 -12
  167. package/types/utils/setTinted.d.ts +0 -5
  168. package/types/utils/setTinted.d.ts.map +0 -1
@@ -0,0 +1,91 @@
1
+ import { Spinner } from "@multiplatform.one/forms";
2
+ import { Text, useResolvedKnobs } from "@multiplatform.one/theme";
3
+ import type { ReactNode } from "react";
4
+ import { YStack } from "tamagui";
5
+
6
+ export type ChatTurnFrom = "user" | "agent";
7
+
8
+ export interface ChatTurnProps {
9
+ /** Who spoke: the agent's text sits on the page, the user's in a bubble at the trailing edge. */
10
+ from: ChatTurnFrom;
11
+ /**
12
+ * A string is the turn's text. Anything else (an image, a file card) is its
13
+ * own bubble: it keeps its own paint and gets no bubble behind it.
14
+ */
15
+ children: ReactNode;
16
+ /**
17
+ * The turn is still in flight. A spinner sits over the turn's picture, or
18
+ * under its text when it carries none. No word is drawn beside it.
19
+ */
20
+ pending?: boolean;
21
+ /** The spinner's accessible name ("Sending"). Without one it reads as loading. */
22
+ pendingLabel?: string;
23
+ /** Anything else under the turn (reactions, a retry). */
24
+ footer?: ReactNode;
25
+ testID?: string;
26
+ }
27
+
28
+ /**
29
+ * One turn of a conversation. The agent's words sit on the page like a
30
+ * document; the user's words are a bubble on the trailing side, at most four
31
+ * fifths of the column, on the theme's soft selected tint. Media is its own
32
+ * bubble on the same side. A turn in flight shows a spinner and no word.
33
+ */
34
+ export function ChatTurn({ from, children, pending, pendingLabel, footer, testID }: ChatTurnProps) {
35
+ const { knobProps, state } = useResolvedKnobs({ component: "Card" });
36
+ const mine = from === "user";
37
+ const text = typeof children === "string" || typeof children === "number";
38
+ const align = mine ? "flex-end" : "flex-start";
39
+ const spinnerName = pendingLabel ? { "aria-label": pendingLabel } : undefined;
40
+
41
+ let body: ReactNode;
42
+ if (text && mine) {
43
+ body = (
44
+ <YStack
45
+ data-chat-bubble="text"
46
+ maxWidth="80%"
47
+ {...knobProps.panelPadding}
48
+ {...knobProps.borderRadius}
49
+ {...state.selected.surfaceKnobProps}
50
+ borderColor="transparent"
51
+ >
52
+ <Text {...knobProps.body}>{children}</Text>
53
+ </YStack>
54
+ );
55
+ } else if (text) {
56
+ body = <Text {...knobProps.body}>{children}</Text>;
57
+ } else {
58
+ body = (
59
+ <YStack data-chat-bubble="media" maxWidth="80%" position="relative">
60
+ {children}
61
+ {pending ? (
62
+ <YStack
63
+ data-chat-turn-pending="media"
64
+ position="absolute"
65
+ top={0}
66
+ right={0}
67
+ bottom={0}
68
+ left={0}
69
+ alignItems="center"
70
+ justifyContent="center"
71
+ pointerEvents="none"
72
+ >
73
+ <Spinner {...spinnerName} />
74
+ </YStack>
75
+ ) : null}
76
+ </YStack>
77
+ );
78
+ }
79
+
80
+ return (
81
+ <YStack data-chat-turn={from} testID={testID} alignItems={align} {...knobProps.gapSm}>
82
+ {body}
83
+ {pending && text ? (
84
+ <YStack data-chat-turn-pending="text">
85
+ <Spinner size="small" {...spinnerName} />
86
+ </YStack>
87
+ ) : null}
88
+ {footer}
89
+ </YStack>
90
+ );
91
+ }
@@ -1,5 +1,5 @@
1
1
  import { action } from "@multiplatform.one/storybook";
2
- import { CheckIcon, LightningIcon, TagIcon } from "@phosphor-icons/react";
2
+ import { ArticleIcon, CheckIcon, GaugeIcon, LightningIcon, TagIcon } from "@phosphor-icons/react";
3
3
  import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
4
4
  import { useState } from "react";
5
5
  import { XStack, YStack } from "tamagui";
@@ -318,3 +318,40 @@ export const AllStates: Story = {
318
318
  </YStack>
319
319
  ),
320
320
  };
321
+
322
+ function TrailingToggleDemo() {
323
+ const [readMode, setReadMode] = useState(true);
324
+ return (
325
+ <XStack gap="$2" flexWrap="wrap" alignItems="center">
326
+ <Chip
327
+ icon={<GaugeIcon />}
328
+ aria-label="Model"
329
+ onPress={() => action("onPress")("model")}
330
+ trailingToggle={{
331
+ icon: <ArticleIcon />,
332
+ selectedIcon: <ArticleIcon weight="fill" />,
333
+ selected: readMode,
334
+ onToggle: setReadMode,
335
+ label: "Read mode",
336
+ }}
337
+ >
338
+ Opus 5.5 1M
339
+ </Chip>
340
+ <Chip
341
+ icon={<GaugeIcon />}
342
+ trailingToggle={{
343
+ icon: <ArticleIcon />,
344
+ selected: false,
345
+ onToggle: (next) => action("onToggle")(next),
346
+ label: "Read mode",
347
+ }}
348
+ >
349
+ Off
350
+ </Chip>
351
+ </XStack>
352
+ );
353
+ }
354
+
355
+ export const TrailingToggle: Story = {
356
+ render: () => <TrailingToggleDemo />,
357
+ };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * FZ-10608: a chip can end in a toggle (the Drover model pill's read mode).
3
+ * The pill and the toggle are two targets in one pill; the toggle reports
4
+ * aria-pressed, swaps to its selected glyph and paints the LC-131 tint.
5
+ */
6
+ import { fireEvent } from "@testing-library/react";
7
+ import { describe, expect, it, vi } from "vitest";
8
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
9
+ import { ArticleIcon, GaugeIcon } from "@phosphor-icons/react";
10
+ import { Chip } from "./index";
11
+
12
+ function toggle(container: HTMLElement): HTMLElement {
13
+ return container.querySelector("[aria-label='Read mode']") as HTMLElement;
14
+ }
15
+
16
+ describe("Chip trailingToggle", () => {
17
+ it("renders a pressable toggle after the label that reports its state", () => {
18
+ const result = renderWithProviders(
19
+ <Chip
20
+ icon={<GaugeIcon />}
21
+ trailingToggle={{
22
+ icon: <ArticleIcon />,
23
+ selected: true,
24
+ onToggle: () => {},
25
+ label: "Read mode",
26
+ }}
27
+ >
28
+ Model
29
+ </Chip>,
30
+ );
31
+ const button = toggle(result.container);
32
+ expect(button).not.toBeNull();
33
+ expect(button.getAttribute("aria-pressed")).toBe("true");
34
+ expect(button.getAttribute("data-chip-toggle")).toBe("on");
35
+ });
36
+
37
+ it("toggling flips the state and never presses the pill", () => {
38
+ const onPress = vi.fn();
39
+ const onToggle = vi.fn();
40
+ const result = renderWithProviders(
41
+ <Chip
42
+ onPress={onPress}
43
+ trailingToggle={{ icon: <ArticleIcon />, selected: false, onToggle, label: "Read mode" }}
44
+ >
45
+ Model
46
+ </Chip>,
47
+ );
48
+ const button = toggle(result.container);
49
+ expect(button.getAttribute("aria-pressed")).toBe("false");
50
+ fireEvent.click(button);
51
+ expect(onToggle).toHaveBeenCalledWith(true);
52
+ expect(onPress).not.toHaveBeenCalled();
53
+ });
54
+
55
+ it("Enter on the focused toggle flips it", () => {
56
+ const onToggle = vi.fn();
57
+ const result = renderWithProviders(
58
+ <Chip
59
+ trailingToggle={{ icon: <ArticleIcon />, selected: true, onToggle, label: "Read mode" }}
60
+ >
61
+ Model
62
+ </Chip>,
63
+ );
64
+ fireEvent.keyDown(toggle(result.container), { key: "Enter" });
65
+ expect(onToggle).toHaveBeenCalledWith(false);
66
+ });
67
+
68
+ it("a disabled chip's toggle does not fire", () => {
69
+ const onToggle = vi.fn();
70
+ const result = renderWithProviders(
71
+ <Chip
72
+ disabled
73
+ trailingToggle={{ icon: <ArticleIcon />, selected: false, onToggle, label: "Read mode" }}
74
+ >
75
+ Model
76
+ </Chip>,
77
+ );
78
+ fireEvent.click(toggle(result.container));
79
+ expect(onToggle).not.toHaveBeenCalled();
80
+ });
81
+
82
+ it("dismiss wins over a toggle, so a pill has one end cap", () => {
83
+ const result = renderWithProviders(
84
+ <Chip
85
+ onDismiss={() => {}}
86
+ trailingToggle={{
87
+ icon: <ArticleIcon />,
88
+ selected: false,
89
+ onToggle: () => {},
90
+ label: "Read mode",
91
+ }}
92
+ >
93
+ Model
94
+ </Chip>,
95
+ );
96
+ expect(toggle(result.container)).toBeNull();
97
+ expect(result.container.querySelector("[aria-label='Remove']")).not.toBeNull();
98
+ });
99
+ });
@@ -66,6 +66,7 @@ export interface ChipProps {
66
66
  onDismiss?: () => void;
67
67
  /** The dismiss button's accessible name, saying what it clears. Defaults to "Remove". */
68
68
  dismissLabel?: string;
69
+ trailingToggle?: ChipTrailingToggle;
69
70
  disabled?: boolean;
70
71
  /** Cap the pill; the label ellipsizes. */
71
72
  maxWidth?: number | string;
@@ -87,6 +88,14 @@ export interface ChipProps {
87
88
  ref?: Ref<unknown>;
88
89
  }
89
90
 
91
+ export interface ChipTrailingToggle {
92
+ icon: ReactNode;
93
+ selectedIcon?: ReactNode;
94
+ selected: boolean;
95
+ onToggle: (selected: boolean) => void;
96
+ label: string;
97
+ }
98
+
90
99
  // ── Color mappings ────────────────────────────────────────────
91
100
 
92
101
  // Ghost/outlined text is small (12px) and must clear ≥4.5:1 on its own tint.
@@ -398,6 +407,7 @@ export function Chip({
398
407
  onPress,
399
408
  onDismiss,
400
409
  dismissLabel,
410
+ trailingToggle,
401
411
  disabled,
402
412
  maxWidth,
403
413
  count,
@@ -419,6 +429,8 @@ export function Chip({
419
429
  const isSelected = Boolean(selected);
420
430
  const interactive = Boolean(onPress) && !disabled;
421
431
  const showDismiss = Boolean(onDismiss) && !disabled;
432
+ const showToggle = trailingToggle != null && !showDismiss;
433
+ const toggleOn = Boolean(trailingToggle?.selected);
422
434
  const iconSize = chipIconSize(resolvedSize);
423
435
  const RING_INSET = 2;
424
436
  const dismissVisual = iconSize + RING_INSET * 2;
@@ -617,6 +629,66 @@ export function Chip({
617
629
  {count}
618
630
  </ChipText>
619
631
  ) : null}
632
+ {showToggle ? (
633
+ <DismissButton
634
+ role="button"
635
+ aria-label={trailingToggle.label}
636
+ aria-pressed={toggleOn}
637
+ aria-disabled={disabled ? true : undefined}
638
+ tabIndex={disabled ? -1 : 0}
639
+ data-chip-toggle={toggleOn ? "on" : "off"}
640
+ opacity={1}
641
+ borderRadius={dismissRadius}
642
+ alignSelf="stretch"
643
+ position="relative"
644
+ marginVertical={-frameGeometry.paddingVertical}
645
+ marginRight={-frameGeometry.paddingHorizontal}
646
+ width={dismissSide ?? undefined}
647
+ hitSlop={pressTargetHitSlop(dismissSide ?? dismissVisual)}
648
+ onLayout={(e) => {
649
+ const h = e.nativeEvent.layout.height;
650
+ if (h > 0 && Math.abs((dismissSide ?? 0) - h) > 0.5) setDismissSide(h);
651
+ }}
652
+ onPress={(e) => {
653
+ e.stopPropagation?.();
654
+ if (!disabled) trailingToggle.onToggle(!toggleOn);
655
+ }}
656
+ onKeyDown={
657
+ ((e: KeyboardEvent) => {
658
+ if (e.key === "Enter" || e.key === " ") {
659
+ e.preventDefault();
660
+ e.stopPropagation();
661
+ if (!disabled) trailingToggle.onToggle(!toggleOn);
662
+ }
663
+ }) as unknown as () => void
664
+ }
665
+ >
666
+ {dismissHitOutset > 0 ? (
667
+ <View
668
+ position="absolute"
669
+ top={-dismissHitOutset}
670
+ bottom={-dismissHitOutset}
671
+ left={-dismissHitOutset}
672
+ right={-dismissHitOutset}
673
+ />
674
+ ) : null}
675
+ <DismissRing
676
+ className="mp-chip-dismiss-ring"
677
+ borderRadius={dismissRadius}
678
+ {...(toggleOn ? { backgroundColor: selectedBackground } : undefined)}
679
+ >
680
+ <ThemedIconSlot
681
+ icon={normalizeIcon(
682
+ toggleOn
683
+ ? (trailingToggle.selectedIcon ?? trailingToggle.icon)
684
+ : trailingToggle.icon,
685
+ iconSize,
686
+ )}
687
+ color={toggleOn ? (state.selected.textKnobProps.color as ColorTokens) : textColor}
688
+ />
689
+ </DismissRing>
690
+ </DismissButton>
691
+ ) : null}
620
692
  {showDismiss ? (
621
693
  <DismissButton
622
694
  role="button"
@@ -0,0 +1,55 @@
1
+ /**
2
+ * FZ-10608: the panel drops over a scrim only while open, carries its name,
3
+ * and the scrim and Escape close it.
4
+ */
5
+ import { fireEvent } from "@testing-library/react";
6
+ import { describe, expect, it, vi } from "vitest";
7
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
8
+ import { Text } from "tamagui";
9
+ import { DropDownPanel } from "./index";
10
+
11
+ describe("DropDownPanel", () => {
12
+ it("renders nothing while closed", () => {
13
+ const result = renderWithProviders(
14
+ <DropDownPanel open={false} onOpenChange={() => {}} aria-label="Add-ons">
15
+ <Text>Tiles</Text>
16
+ </DropDownPanel>,
17
+ );
18
+ expect(result.container.querySelector("[data-drop-down-panel]")).toBeNull();
19
+ });
20
+
21
+ it("open, it shows a named panel over a scrim", () => {
22
+ const result = renderWithProviders(
23
+ <DropDownPanel open onOpenChange={() => {}} aria-label="Add-ons">
24
+ <Text>Tiles</Text>
25
+ </DropDownPanel>,
26
+ );
27
+ const sheet = result.container.querySelector("[data-drop-down-sheet]") as HTMLElement;
28
+ expect(sheet.getAttribute("aria-label")).toBe("Add-ons");
29
+ expect(sheet.getAttribute("role")).toBe("dialog");
30
+ expect(result.container.querySelector("[data-drop-down-scrim]")).not.toBeNull();
31
+ expect(result.findTextElement("Tiles")).toBeDefined();
32
+ });
33
+
34
+ it("a press on the scrim closes it", () => {
35
+ const onOpenChange = vi.fn();
36
+ const result = renderWithProviders(
37
+ <DropDownPanel open onOpenChange={onOpenChange} aria-label="Add-ons">
38
+ <Text>Tiles</Text>
39
+ </DropDownPanel>,
40
+ );
41
+ fireEvent.click(result.container.querySelector("[data-drop-down-scrim]") as HTMLElement);
42
+ expect(onOpenChange).toHaveBeenCalledWith(false);
43
+ });
44
+
45
+ it("Escape closes it", () => {
46
+ const onOpenChange = vi.fn();
47
+ renderWithProviders(
48
+ <DropDownPanel open onOpenChange={onOpenChange} aria-label="Add-ons">
49
+ <Text>Tiles</Text>
50
+ </DropDownPanel>,
51
+ );
52
+ fireEvent.keyDown(document, { key: "Escape" });
53
+ expect(onOpenChange).toHaveBeenCalledWith(false);
54
+ });
55
+ });
@@ -0,0 +1,69 @@
1
+ import {
2
+ BugIcon,
3
+ ChartLineUpIcon,
4
+ GitMergeIcon,
5
+ HardDrivesIcon,
6
+ UsersThreeIcon,
7
+ } from "@phosphor-icons/react";
8
+ import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
9
+ import { useState } from "react";
10
+ import { YStack } from "tamagui";
11
+ import { CardGrid, ShortcutCard } from "../views";
12
+ import { Text } from "../Text";
13
+ import { DropDownPanel } from "./index";
14
+
15
+ const meta: Meta<typeof DropDownPanel> = {
16
+ title: "Components/DropDownPanel",
17
+ component: DropDownPanel,
18
+ parameters: {
19
+ layout: "fullscreen",
20
+ status: { type: "beta" },
21
+ docs: {
22
+ description: {
23
+ component:
24
+ "A panel that drops from the top of its region over a scrim. The scrim and Escape close it.",
25
+ },
26
+ },
27
+ },
28
+ };
29
+ export default meta;
30
+
31
+ type Story = StoryObj<typeof DropDownPanel>;
32
+
33
+ const tiles = [
34
+ {
35
+ id: "accounts",
36
+ title: "Accounts",
37
+ subtitle: "1 needs sign-in",
38
+ count: 21,
39
+ icon: <UsersThreeIcon />,
40
+ },
41
+ {
42
+ id: "machines",
43
+ title: "Machines",
44
+ subtitle: "2 offline",
45
+ count: "1/3",
46
+ icon: <HardDrivesIcon />,
47
+ },
48
+ { id: "mrs", title: "Merge requests", subtitle: "2 ready", count: 5, icon: <GitMergeIcon /> },
49
+ { id: "reports", title: "Reports", subtitle: "3 new", count: 3, icon: <ChartLineUpIcon /> },
50
+ { id: "errors", title: "Errors", subtitle: "None today", icon: <BugIcon /> },
51
+ ];
52
+
53
+ function Demo() {
54
+ const [open, setOpen] = useState(true);
55
+ return (
56
+ <YStack position="relative" height="100vh" padding="$4" gap="$3">
57
+ <Text onPress={() => setOpen(true)}>Sessions list under the panel</Text>
58
+ <DropDownPanel open={open} onOpenChange={setOpen} aria-label="Add-ons">
59
+ <CardGrid maxColumns={2} minCardWidth={150}>
60
+ {tiles.map((tile) => (
61
+ <ShortcutCard key={tile.id} layout="tile" config={{ ...tile, onClick: () => {} }} />
62
+ ))}
63
+ </CardGrid>
64
+ </DropDownPanel>
65
+ </YStack>
66
+ );
67
+ }
68
+
69
+ export const Open: Story = { render: () => <Demo /> };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * DropDownPanel (FZ-10608): a panel that drops from the top edge of its
3
+ * region over a scrim, the Drover add-ons tray. It fills its positioned
4
+ * parent, so place it in the region under the bar it drops from. A press on
5
+ * the scrim or Escape closes it. Its top edge is flush with the bar; only the
6
+ * bottom corners round.
7
+ */
8
+ import { overlayScrim, transitionProps, useResolvedKnobs } from "@multiplatform.one/theme";
9
+ import { useOverlayZIndex } from "@multiplatform.one/forms";
10
+ import { useEffect, type ReactNode } from "react";
11
+ import { useTranslation } from "react-i18next";
12
+ import { YStack } from "tamagui";
13
+
14
+ export interface DropDownPanelProps {
15
+ open: boolean;
16
+ onOpenChange: (open: boolean) => void;
17
+ /** The panel's accessible name ("Add-ons"). */
18
+ "aria-label": string;
19
+ children: ReactNode;
20
+ testID?: string;
21
+ }
22
+
23
+ export function DropDownPanel({
24
+ open,
25
+ onOpenChange,
26
+ "aria-label": ariaLabel,
27
+ children,
28
+ testID,
29
+ }: DropDownPanelProps) {
30
+ const { t } = useTranslation();
31
+ const { knobProps } = useResolvedKnobs({ component: "Card" });
32
+ const zIndex = useOverlayZIndex("dropdown");
33
+
34
+ useEffect(() => {
35
+ if (!open || typeof document === "undefined") return;
36
+ const onKey = (event: KeyboardEvent) => {
37
+ if (event.key === "Escape") onOpenChange(false);
38
+ };
39
+ document.addEventListener("keydown", onKey);
40
+ return () => document.removeEventListener("keydown", onKey);
41
+ }, [open, onOpenChange]);
42
+
43
+ if (!open) return null;
44
+ return (
45
+ <YStack
46
+ position="absolute"
47
+ top={0}
48
+ left={0}
49
+ right={0}
50
+ bottom={0}
51
+ zIndex={zIndex}
52
+ data-drop-down-panel=""
53
+ testID={testID}
54
+ >
55
+ <YStack
56
+ position="absolute"
57
+ top={0}
58
+ left={0}
59
+ right={0}
60
+ bottom={0}
61
+ backgroundColor={overlayScrim}
62
+ role="button"
63
+ aria-label={t("Close")}
64
+ data-drop-down-scrim=""
65
+ onPress={() => onOpenChange(false)}
66
+ {...transitionProps(knobProps.motion.scrim)}
67
+ enterStyle={{ opacity: 0 }}
68
+ />
69
+ <YStack
70
+ role="dialog"
71
+ aria-label={ariaLabel}
72
+ position="relative"
73
+ data-drop-down-sheet=""
74
+ {...knobProps.elevatedSurface}
75
+ {...knobProps.containerRadius}
76
+ borderTopLeftRadius={0}
77
+ borderTopRightRadius={0}
78
+ {...knobProps.panelPadding}
79
+ {...knobProps.gap}
80
+ {...transitionProps(knobProps.motion.overlay)}
81
+ enterStyle={{ opacity: 0 }}
82
+ >
83
+ {children}
84
+ </YStack>
85
+ </YStack>
86
+ );
87
+ }
@@ -259,7 +259,6 @@ const SeparatorLine = styled(View, {
259
259
 
260
260
  const coverContract = {
261
261
  widthMode: "at-least-trigger" as const,
262
- fitContent: false,
263
262
  };
264
263
 
265
264
  /**
@@ -226,14 +226,14 @@ describe("menus inside a SheetModal at 390 (FZ-7830)", () => {
226
226
 
227
227
  describe("LC-262 inside a sheet at 390 (FZ-7830 round 2)", () => {
228
228
  it("five options with glyphs lay out inline as a radio list, with no trigger and no popover", () => {
229
- const onValueChange = vi.fn();
229
+ const onChange = vi.fn();
230
230
  const result = renderWithProviders(
231
231
  <SheetModal open onOpenChange={() => {}}>
232
232
  <Select
233
233
  aria-label="Exposure"
234
234
  options={exposure}
235
235
  defaultValue="tailnet"
236
- onValueChange={onValueChange}
236
+ onChange={onChange}
237
237
  />
238
238
  </SheetModal>,
239
239
  );
@@ -244,19 +244,19 @@ describe("LC-262 inside a sheet at 390 (FZ-7830 round 2)", () => {
244
244
  expect(radios.every((r) => r.querySelector("svg"))).toBe(true);
245
245
  expect(radios[1].getAttribute("aria-checked")).toBe("true");
246
246
  fireEvent.click(radios[2]);
247
- expect(onValueChange).toHaveBeenCalledWith("lan");
247
+ expect(onChange).toHaveBeenCalledWith("lan");
248
248
  expect(panelSheets().length).toBe(0);
249
249
  });
250
250
 
251
251
  it("the inline list is one tab stop, and arrows move and choose (APG radio group)", () => {
252
- const onValueChange = vi.fn();
252
+ const onChange = vi.fn();
253
253
  const result = renderWithProviders(
254
254
  <SheetModal open onOpenChange={() => {}}>
255
255
  <Select
256
256
  aria-label="Exposure"
257
257
  options={exposure}
258
258
  defaultValue="tailnet"
259
- onValueChange={onValueChange}
259
+ onChange={onChange}
260
260
  />
261
261
  </SheetModal>,
262
262
  );
@@ -265,11 +265,11 @@ describe("LC-262 inside a sheet at 390 (FZ-7830 round 2)", () => {
265
265
  ) as HTMLElement[];
266
266
  expect(radios.map((r) => r.getAttribute("tabindex"))).toEqual(["-1", "0", "-1", "-1", "-1"]);
267
267
  fireEvent.keyDown(radios[1], { key: "ArrowDown" });
268
- expect(onValueChange).toHaveBeenLastCalledWith("lan");
268
+ expect(onChange).toHaveBeenLastCalledWith("lan");
269
269
  fireEvent.keyDown(radios[0], { key: "ArrowUp" });
270
- expect(onValueChange).toHaveBeenLastCalledWith("public-auth");
270
+ expect(onChange).toHaveBeenLastCalledWith("public-auth");
271
271
  fireEvent.keyDown(radios[3], { key: " " });
272
- expect(onValueChange).toHaveBeenLastCalledWith("public");
272
+ expect(onChange).toHaveBeenLastCalledWith("public");
273
273
  });
274
274
 
275
275
  it("a short list missing a glyph keeps its trigger and opens a menu beside it, never over it", async () => {
@@ -365,7 +365,7 @@ describe("long choice lists push inside the sheet at 390 (FZ-7830 round 3)", ()
365
365
  label="Region"
366
366
  options={regions}
367
367
  value={value}
368
- onValueChange={(next) => {
368
+ onChange={(next) => {
369
369
  setValue(next as string);
370
370
  onValue?.(next as string);
371
371
  }}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * FZ-10608: a full swipe dismisses, a short one springs back, and the
3
+ * revealed ✕ is a pressable path that never needs the gesture.
4
+ */
5
+ import { fireEvent } from "@testing-library/react";
6
+ import { describe, expect, it, vi } from "vitest";
7
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
8
+ import { Text } from "tamagui";
9
+ import { SWIPE_DISMISS_COMMIT, SwipeDismissRow, swipeDismissOutcome } from "./index";
10
+
11
+ describe("swipeDismissOutcome", () => {
12
+ it("a release past the commit share of the width dismisses", () => {
13
+ expect(swipeDismissOutcome(-300 * SWIPE_DISMISS_COMMIT, 300)).toBe("dismiss");
14
+ expect(swipeDismissOutcome(-290, 300)).toBe("dismiss");
15
+ });
16
+
17
+ it("a short swipe, a swipe the other way and an unmeasured row spring back", () => {
18
+ expect(swipeDismissOutcome(-60, 300)).toBe("rest");
19
+ expect(swipeDismissOutcome(200, 300)).toBe("rest");
20
+ expect(swipeDismissOutcome(-200, 0)).toBe("rest");
21
+ });
22
+ });
23
+
24
+ describe("SwipeDismissRow", () => {
25
+ it("at rest shows the row and no action", () => {
26
+ const result = renderWithProviders(
27
+ <SwipeDismissRow onDismiss={() => {}}>
28
+ <Text>Row</Text>
29
+ </SwipeDismissRow>,
30
+ );
31
+ expect(result.findTextElement("Row")).toBeDefined();
32
+ expect(result.container.querySelector("[data-swipe-dismiss-action]")).toBeNull();
33
+ });
34
+
35
+ it("the revealed ✕ is labelled and dismisses on press", () => {
36
+ const onDismiss = vi.fn();
37
+ const result = renderWithProviders(
38
+ <SwipeDismissRow onDismiss={onDismiss} swipeProgress={0.4} dismissLabel="Dismiss item">
39
+ <Text>Row</Text>
40
+ </SwipeDismissRow>,
41
+ );
42
+ const action = result.container.querySelector("[data-swipe-dismiss-action]") as HTMLElement;
43
+ expect(action).not.toBeNull();
44
+ expect(action.getAttribute("aria-label")).toBe("Dismiss item");
45
+ fireEvent.click(action);
46
+ expect(onDismiss).toHaveBeenCalledTimes(1);
47
+ });
48
+ });