@terreno/ui 56.0.0-beta.2 → 57.0.0-beta.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/Badge.d.ts +1 -1
- package/dist/Badge.js +37 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Common.d.ts +110 -3
- package/dist/Common.js.map +1 -1
- package/dist/Filter.d.ts +13 -0
- package/dist/Filter.js +120 -0
- package/dist/Filter.js.map +1 -0
- package/dist/FilterAccordion.d.ts +8 -0
- package/dist/FilterAccordion.js +59 -0
- package/dist/FilterAccordion.js.map +1 -0
- package/dist/FilterBoolean.d.ts +8 -0
- package/dist/FilterBoolean.js +74 -0
- package/dist/FilterBoolean.js.map +1 -0
- package/dist/FilterChangesBadge.d.ts +8 -0
- package/dist/FilterChangesBadge.js +11 -0
- package/dist/FilterChangesBadge.js.map +1 -0
- package/dist/FilterSelectMenu.d.ts +8 -0
- package/dist/FilterSelectMenu.js +37 -0
- package/dist/FilterSelectMenu.js.map +1 -0
- package/dist/IconRegistry.js +11 -6
- package/dist/IconRegistry.js.map +1 -1
- package/dist/PickerSelect.d.ts +8 -1
- package/dist/PickerSelect.js +2 -2
- package/dist/PickerSelect.js.map +1 -1
- package/dist/SelectField.js +2 -2
- package/dist/SelectField.js.map +1 -1
- package/dist/Theme.js +2 -0
- package/dist/Theme.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +5 -1
- package/dist/WebDropdownMenu.js +24 -10
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/icons/BarsFilterIcon.d.ts +9 -0
- package/dist/icons/BarsFilterIcon.js +12 -0
- package/dist/icons/BarsFilterIcon.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +23 -23
- package/src/Badge.test.tsx +22 -1
- package/src/Badge.tsx +43 -0
- package/src/Common.ts +120 -5
- package/src/DateTimeField.test.tsx +16 -18
- package/src/Filter.test.tsx +94 -0
- package/src/Filter.tsx +257 -0
- package/src/FilterAccordion.test.tsx +58 -0
- package/src/FilterAccordion.tsx +113 -0
- package/src/FilterBoolean.test.tsx +65 -0
- package/src/FilterBoolean.tsx +130 -0
- package/src/FilterChangesBadge.test.tsx +16 -0
- package/src/FilterChangesBadge.tsx +13 -0
- package/src/FilterSelectMenu.test.tsx +56 -0
- package/src/FilterSelectMenu.tsx +76 -0
- package/src/IconRegistry.test.tsx +6 -4
- package/src/IconRegistry.tsx +13 -8
- package/src/PickerSelect.test.tsx +20 -0
- package/src/PickerSelect.tsx +10 -0
- package/src/SelectField.tsx +2 -0
- package/src/Theme.tsx +2 -0
- package/src/WebDropdownMenu.test.tsx +86 -1
- package/src/WebDropdownMenu.tsx +43 -21
- package/src/__snapshots__/Filter.test.tsx.snap +161 -0
- package/src/__snapshots__/FilterAccordion.test.tsx.snap +83 -0
- package/src/__snapshots__/FilterBoolean.test.tsx.snap +109 -0
- package/src/__snapshots__/FilterChangesBadge.test.tsx.snap +18 -0
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +359 -0
- package/src/conflictFieldDiff.test.ts +43 -0
- package/src/icons/BarsFilterIcon.tsx +18 -0
- package/src/index.tsx +6 -0
package/dist/Badge.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { BadgeProps } from "./Common";
|
|
3
|
-
export declare const Badge: ({ value, iconName, status, secondary, variant, maxValue, customBackgroundColor, customTextColor, customBorderColor, customIconColor, customIconName, testID, }: BadgeProps) => React.ReactElement;
|
|
3
|
+
export declare const Badge: ({ value, iconName, status, secondary, variant, color, maxValue, customBackgroundColor, customTextColor, customBorderColor, customIconColor, customIconName, testID, }: BadgeProps) => React.ReactElement;
|
package/dist/Badge.js
CHANGED
|
@@ -2,12 +2,42 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Text, View } from "react-native";
|
|
3
3
|
import { Icon } from "./Icon";
|
|
4
4
|
import { useTheme } from "./Theme";
|
|
5
|
-
|
|
5
|
+
const STATUS_DOT_SIZE = 8;
|
|
6
|
+
// Surface tokens for the "status" dot variant, per bold vs subtle tone.
|
|
7
|
+
const STATUS_DOT_BOLD = {
|
|
8
|
+
active: "primary",
|
|
9
|
+
error: "error",
|
|
10
|
+
info: "secondaryDark",
|
|
11
|
+
neutral: "neutralDark",
|
|
12
|
+
success: "success",
|
|
13
|
+
warning: "warning",
|
|
14
|
+
};
|
|
15
|
+
const STATUS_DOT_SUBTLE = {
|
|
16
|
+
active: "secondaryLight",
|
|
17
|
+
error: "errorLight",
|
|
18
|
+
info: "secondaryLight",
|
|
19
|
+
neutral: "neutralLight",
|
|
20
|
+
success: "successLight",
|
|
21
|
+
warning: "warningLight",
|
|
22
|
+
};
|
|
23
|
+
export const Badge = ({ value, iconName, status = "info", secondary = false, variant, color = "bold", maxValue = 100, customBackgroundColor, customTextColor, customBorderColor, customIconColor, customIconName, testID, }) => {
|
|
24
|
+
var _a;
|
|
6
25
|
const { theme } = useTheme();
|
|
7
26
|
const isIconOnly = variant === "iconOnly";
|
|
27
|
+
if (variant === "status") {
|
|
28
|
+
const dotSurface = (_a = (color === "subtle" ? STATUS_DOT_SUBTLE : STATUS_DOT_BOLD)[status]) !== null && _a !== void 0 ? _a : "primary";
|
|
29
|
+
const dotColor = status === "custom" ? customBackgroundColor : theme.surface[dotSurface];
|
|
30
|
+
return (_jsx(View, { style: {
|
|
31
|
+
backgroundColor: dotColor,
|
|
32
|
+
borderRadius: STATUS_DOT_SIZE,
|
|
33
|
+
height: STATUS_DOT_SIZE,
|
|
34
|
+
width: STATUS_DOT_SIZE,
|
|
35
|
+
}, testID: testID }));
|
|
36
|
+
}
|
|
8
37
|
let badgeColor = "inverted";
|
|
9
38
|
// TODO: Move to theme
|
|
10
39
|
const secondaryBorderColors = {
|
|
40
|
+
active: "#8FC1D2",
|
|
11
41
|
custom: "#AAAAAA",
|
|
12
42
|
error: "#F39E9E",
|
|
13
43
|
info: "#8FC1D2",
|
|
@@ -31,6 +61,9 @@ export const Badge = ({ value, iconName, status = "info", secondary = false, var
|
|
|
31
61
|
else if (status === "neutral") {
|
|
32
62
|
badgeColor = "primary";
|
|
33
63
|
}
|
|
64
|
+
else if (status === "active") {
|
|
65
|
+
badgeColor = "link";
|
|
66
|
+
}
|
|
34
67
|
}
|
|
35
68
|
let badgeBgColor = "neutralDark";
|
|
36
69
|
if (status === "error") {
|
|
@@ -48,6 +81,9 @@ export const Badge = ({ value, iconName, status = "info", secondary = false, var
|
|
|
48
81
|
else if (status === "neutral") {
|
|
49
82
|
badgeBgColor = secondary ? "neutralLight" : "neutralDark";
|
|
50
83
|
}
|
|
84
|
+
else if (status === "active") {
|
|
85
|
+
badgeBgColor = secondary ? "secondaryLight" : "primary";
|
|
86
|
+
}
|
|
51
87
|
const backgroundColor = status === "custom" ? customBackgroundColor : theme.surface[badgeBgColor];
|
|
52
88
|
const borderColor = status === "custom" ? customBorderColor : secondaryBorderColors[status];
|
|
53
89
|
const textColor = status === "custom" ? customTextColor : theme.text[badgeColor];
|
package/dist/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,MAAM,EACf,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,QAAQ,GAAG,GAAG,EACd,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,MAAM,GACK,EAAsB,EAAE
|
|
1
|
+
{"version":3,"file":"Bad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AC,QAAQ,EAAE,EAAE,EAAC;gBAC1C,SAAS,IAAI,EAAC,WAAW,EAAE,WAAW,EAAE,CAAC,EAAC;aAC3C,EACD,MAAM,EAAE,MAAM,aAEb,OAAO,CAAC,OAAO,KAAK,YAAY,IAAI,QAAQ,CAAC,IAAI,CAChD,KAAC,IAAI,IAAC,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAC,EAAE,MAAM,EAAC,MAAM,YACtF,KAAC,IAAI,IAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,QAAS,EAAE,IAAI,EAAC,IAAI,GAAG,GACtE,CACR,EACA,OAAO,CAAC,OAAO,KAAK,UAAU,CAAC,IAAI,CAClC,KAAC,IAAI,IACH,KAAK,EAAE;wBACL,KAAK,EAAE,SAAS;wBAChB,UAAU,EAAE,MAAM;wBAClB,QAAQ,EAAE,EAAE;wBACZ,UAAU,EAAE,KAAK;qBAClB,YAEA,UAAU,GACN,CACR,IACI,GACF,CACR,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/Common.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export interface TextThemeConfig {
|
|
|
155
155
|
}
|
|
156
156
|
export interface SurfaceThemeConfig {
|
|
157
157
|
base: keyof ThemePrimitiveColors;
|
|
158
|
+
baseAlternate: keyof ThemePrimitiveColors;
|
|
159
|
+
baseHover: keyof ThemePrimitiveColors;
|
|
158
160
|
primary: keyof ThemePrimitiveColors;
|
|
159
161
|
secondaryExtraLight: keyof ThemePrimitiveColors;
|
|
160
162
|
secondaryLight: keyof ThemePrimitiveColors;
|
|
@@ -218,6 +220,8 @@ export interface TextTheme {
|
|
|
218
220
|
}
|
|
219
221
|
export interface SurfaceTheme {
|
|
220
222
|
base: string;
|
|
223
|
+
baseAlternate: string;
|
|
224
|
+
baseHover: string;
|
|
221
225
|
primary: string;
|
|
222
226
|
secondaryExtraLight: string;
|
|
223
227
|
secondaryLight: string;
|
|
@@ -314,6 +318,8 @@ export type OnChangeCallback = (result: string) => void;
|
|
|
314
318
|
* ```
|
|
315
319
|
*/
|
|
316
320
|
export interface CustomIconRegistry {
|
|
321
|
+
/** Built-in "bars-filter" glyph (FontAwesome Classic Solid, E0AD). */
|
|
322
|
+
"bars-filter": true;
|
|
317
323
|
}
|
|
318
324
|
/** The set of custom icon names registered via {@link CustomIconRegistry}. */
|
|
319
325
|
export type CustomIconName = keyof CustomIconRegistry & string;
|
|
@@ -332,6 +338,91 @@ export type CustomIconComponent = FC<CustomIconProps>;
|
|
|
332
338
|
* `TerrenoProvider` via the `icons` prop to register custom icons.
|
|
333
339
|
*/
|
|
334
340
|
export type IconRegistryMap = Record<string, CustomIconComponent>;
|
|
341
|
+
export interface FilterOption {
|
|
342
|
+
label: string;
|
|
343
|
+
value: string;
|
|
344
|
+
}
|
|
345
|
+
/** Small blue dot that signals a filter control differs from its default. */
|
|
346
|
+
export type FilterChangesBadgeProps = WithTestID;
|
|
347
|
+
export interface FilterSelectMenuProps extends WithTestID {
|
|
348
|
+
/** Label shown to the left of the select control. */
|
|
349
|
+
title: string;
|
|
350
|
+
/** Selectable options for the single-select control. */
|
|
351
|
+
options: FilterOption[];
|
|
352
|
+
/** Currently selected value. */
|
|
353
|
+
value?: string;
|
|
354
|
+
/** Called with the newly selected value. */
|
|
355
|
+
onChange: (value: string) => void;
|
|
356
|
+
/** Text shown when no value is selected. */
|
|
357
|
+
placeholder?: string;
|
|
358
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
359
|
+
showChangesBadge?: boolean;
|
|
360
|
+
/** Disables the control. */
|
|
361
|
+
disabled?: boolean;
|
|
362
|
+
}
|
|
363
|
+
export interface FilterBooleanProps extends WithTestID {
|
|
364
|
+
/** Label shown to the left of the toggle. */
|
|
365
|
+
title: string;
|
|
366
|
+
/** Whether the toggle is on. */
|
|
367
|
+
value: boolean;
|
|
368
|
+
/** Called with the next toggle value. The entire row is the click zone. */
|
|
369
|
+
onChange: (value: boolean) => void;
|
|
370
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
371
|
+
showChangesBadge?: boolean;
|
|
372
|
+
/** Disables the toggle and the row click zone. */
|
|
373
|
+
disabled?: boolean;
|
|
374
|
+
/** Renders the toggle in a focused (keyboard) state. */
|
|
375
|
+
focused?: boolean;
|
|
376
|
+
}
|
|
377
|
+
export interface FilterAccordionProps extends WithTestID {
|
|
378
|
+
/** Label shown in the always-visible header row. */
|
|
379
|
+
title: string;
|
|
380
|
+
/** Custom content revealed when expanded. Empty by default. */
|
|
381
|
+
children?: React.ReactNode;
|
|
382
|
+
/** Controlled expanded state. Omit to use `defaultExpanded`. */
|
|
383
|
+
expanded?: boolean;
|
|
384
|
+
/** Initial expanded state when uncontrolled. */
|
|
385
|
+
defaultExpanded?: boolean;
|
|
386
|
+
/** Called with the next expanded state when the header row is pressed. */
|
|
387
|
+
onToggle?: (expanded: boolean) => void;
|
|
388
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
389
|
+
showChangesBadge?: boolean;
|
|
390
|
+
}
|
|
391
|
+
export interface FilterProps extends WithTestID {
|
|
392
|
+
/** Composed filter controls rendered inside the dropdown panel. */
|
|
393
|
+
children: React.ReactNode;
|
|
394
|
+
/** Trigger button label. */
|
|
395
|
+
label?: string;
|
|
396
|
+
/** Trigger button icon. Defaults to the built-in `bars-filter` glyph. */
|
|
397
|
+
iconName?: IconName;
|
|
398
|
+
/** Controlled open state. Omit to use `defaultOpen`. */
|
|
399
|
+
isOpen?: boolean;
|
|
400
|
+
/** Initial open state when uncontrolled. */
|
|
401
|
+
defaultOpen?: boolean;
|
|
402
|
+
/** Called whenever the dropdown opens or closes. */
|
|
403
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
404
|
+
/** Master toggle for the Apply/Clear/Cancel footer. */
|
|
405
|
+
showActionButtons?: boolean;
|
|
406
|
+
/** Show the Apply button in the footer. */
|
|
407
|
+
showApplyButton?: boolean;
|
|
408
|
+
/** Show the Clear hyperlink in the footer. */
|
|
409
|
+
showClearButton?: boolean;
|
|
410
|
+
/** Show the Cancel button in the footer. */
|
|
411
|
+
showCancelButton?: boolean;
|
|
412
|
+
applyButtonText?: string;
|
|
413
|
+
clearButtonText?: string;
|
|
414
|
+
cancelButtonText?: string;
|
|
415
|
+
/** Called when Apply is pressed. The dropdown then closes. */
|
|
416
|
+
onApply?: () => void;
|
|
417
|
+
/** Called when Clear is pressed. The dropdown then closes. */
|
|
418
|
+
onClear?: () => void;
|
|
419
|
+
/** Called when Cancel or a click-outside closes the dropdown. */
|
|
420
|
+
onCancel?: () => void;
|
|
421
|
+
/** Primary theming for the trigger and Apply button. */
|
|
422
|
+
variant?: "primary" | "secondary";
|
|
423
|
+
/** Panel width in pixels. Defaults to 320 per the design spec. */
|
|
424
|
+
width?: number;
|
|
425
|
+
}
|
|
335
426
|
export type AlignContent = "start" | "end" | "center" | "between" | "around" | "stretch";
|
|
336
427
|
export type AlignSelf = "auto" | "start" | "end" | "center" | "baseline" | "stretch";
|
|
337
428
|
export type AlignItems = "start" | "end" | "center" | "baseline" | "stretch";
|
|
@@ -1241,15 +1332,22 @@ export interface BadgeProps extends WithTestID {
|
|
|
1241
1332
|
* The status of the badge. Determines its color and appearance.
|
|
1242
1333
|
* @default "info"
|
|
1243
1334
|
*/
|
|
1244
|
-
status?: "info" | "error" | "warning" | "success" | "neutral" | "custom";
|
|
1335
|
+
status?: "info" | "error" | "warning" | "success" | "neutral" | "active" | "custom";
|
|
1336
|
+
/**
|
|
1337
|
+
* For the "status" variant, whether the dot uses the bold (saturated) or
|
|
1338
|
+
* subtle (light) tone.
|
|
1339
|
+
* @default "bold"
|
|
1340
|
+
*/
|
|
1341
|
+
color?: "bold" | "subtle";
|
|
1245
1342
|
/**
|
|
1246
1343
|
* The text or number to display inside the badge.
|
|
1247
1344
|
*/
|
|
1248
1345
|
value?: number | string;
|
|
1249
1346
|
/**
|
|
1250
|
-
* The variant of the badge.
|
|
1347
|
+
* The variant of the badge. "status" renders a small colored dot (no text)
|
|
1348
|
+
* used to indicate an active/modified state.
|
|
1251
1349
|
*/
|
|
1252
|
-
variant?: "iconOnly" | "numberOnly";
|
|
1350
|
+
variant?: "iconOnly" | "numberOnly" | "status";
|
|
1253
1351
|
}
|
|
1254
1352
|
export type ThumbsUpDownFeedbackValue = "positive" | "negative";
|
|
1255
1353
|
export interface ThumbsUpDownFeedbackProps extends WithTestID {
|
|
@@ -2501,6 +2599,15 @@ export interface SelectFieldPropsBase extends WithTestID {
|
|
|
2501
2599
|
* @default false
|
|
2502
2600
|
*/
|
|
2503
2601
|
disableSearch?: boolean;
|
|
2602
|
+
/**
|
|
2603
|
+
* Web only. When true, the dropdown menu renders in a fixed portal on
|
|
2604
|
+
* `document.body` (zIndex 9999) instead of a React Native `Modal`. Use this
|
|
2605
|
+
* when the select lives inside another portaled/high-zIndex overlay (e.g. the
|
|
2606
|
+
* `Filter` panel) where a `Modal` would stack behind the overlay and be
|
|
2607
|
+
* invisible and unclickable.
|
|
2608
|
+
* @default false
|
|
2609
|
+
*/
|
|
2610
|
+
renderMenuInBodyPortal?: boolean;
|
|
2504
2611
|
/**
|
|
2505
2612
|
* The title of the select field.
|
|
2506
2613
|
*/
|
package/dist/Common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,GACZ,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5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EF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAkB,EAAE,EAAE;IAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AA81EF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACV,CAAC"}
|
package/dist/Filter.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { FilterProps } from "./Common";
|
|
3
|
+
/**
|
|
4
|
+
* Compositional filter dropdown. Renders a trigger button that opens a panel
|
|
5
|
+
* containing composed filter controls (`FilterSelectMenu`, `FilterBoolean`,
|
|
6
|
+
* `FilterAccordion`, or any custom content) plus an optional Apply / Clear /
|
|
7
|
+
* Cancel footer. Clicking outside the panel closes it. Desktop web only.
|
|
8
|
+
*
|
|
9
|
+
* On web the panel is rendered in a portal on `document.body` and anchored to
|
|
10
|
+
* the trigger, so it floats above all page content instead of being trapped in
|
|
11
|
+
* a React Native Web stacking context (which would let content bleed through).
|
|
12
|
+
*/
|
|
13
|
+
export declare const Filter: FC<FilterProps>;
|
package/dist/Filter.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Platform, Pressable, View } from "react-native";
|
|
4
|
+
import { Button } from "./Button";
|
|
5
|
+
import { createWebPortal } from "./createWebPortal";
|
|
6
|
+
import { Text } from "./Text";
|
|
7
|
+
import { useTheme } from "./Theme";
|
|
8
|
+
import { resolveTestID } from "./testing/resolveTestId";
|
|
9
|
+
import { useWebDropdownAnchor } from "./WebDropdownMenu";
|
|
10
|
+
const DEFAULT_WIDTH = 320;
|
|
11
|
+
const TRIGGER_OFFSET = 44;
|
|
12
|
+
const PANEL_GAP = 4;
|
|
13
|
+
/**
|
|
14
|
+
* Compositional filter dropdown. Renders a trigger button that opens a panel
|
|
15
|
+
* containing composed filter controls (`FilterSelectMenu`, `FilterBoolean`,
|
|
16
|
+
* `FilterAccordion`, or any custom content) plus an optional Apply / Clear /
|
|
17
|
+
* Cancel footer. Clicking outside the panel closes it. Desktop web only.
|
|
18
|
+
*
|
|
19
|
+
* On web the panel is rendered in a portal on `document.body` and anchored to
|
|
20
|
+
* the trigger, so it floats above all page content instead of being trapped in
|
|
21
|
+
* a React Native Web stacking context (which would let content bleed through).
|
|
22
|
+
*/
|
|
23
|
+
export const Filter = ({ children, label = "Filter", iconName = "bars-filter", isOpen, defaultOpen = false, onOpenChange, showActionButtons = true, showApplyButton = true, showClearButton = true, showCancelButton = true, applyButtonText = "Apply", clearButtonText = "Clear", cancelButtonText = "Cancel", onApply, onClear, onCancel, variant = "primary", width = DEFAULT_WIDTH, testID, }) => {
|
|
24
|
+
const { theme } = useTheme();
|
|
25
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
26
|
+
const [anchorReady, setAnchorReady] = useState(false);
|
|
27
|
+
const { anchor, cancelPendingMeasurement, measure, triggerRef } = useWebDropdownAnchor();
|
|
28
|
+
const isControlled = isOpen !== undefined;
|
|
29
|
+
const open = isControlled ? isOpen : internalOpen;
|
|
30
|
+
// Measure-then-show: measure the trigger when the panel opens and only reveal
|
|
31
|
+
// the portaled panel once the anchor is known, so it never flashes at the
|
|
32
|
+
// default (0, 0) position before jumping into place.
|
|
33
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: only re-measure on open transitions; `measure` is recreated each render.
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setAnchorReady(false);
|
|
36
|
+
if (!open) {
|
|
37
|
+
cancelPendingMeasurement();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
measure(() => setAnchorReady(true));
|
|
41
|
+
return cancelPendingMeasurement;
|
|
42
|
+
}, [open]);
|
|
43
|
+
// Return focus to the trigger after any in-panel dismissal so keyboard users
|
|
44
|
+
// can continue from the control that opened the popup (web only).
|
|
45
|
+
const restoreTriggerFocus = () => {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
if (Platform.OS !== "web" || !triggerRef.current) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const node = triggerRef.current;
|
|
51
|
+
(_c = (_b = (_a = node.querySelector) === null || _a === void 0 ? void 0 : _a.call(node, '[role="button"]')) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
52
|
+
};
|
|
53
|
+
const setOpen = (next) => {
|
|
54
|
+
if (!isControlled) {
|
|
55
|
+
setInternalOpen(next);
|
|
56
|
+
}
|
|
57
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
58
|
+
};
|
|
59
|
+
const handleApply = () => {
|
|
60
|
+
onApply === null || onApply === void 0 ? void 0 : onApply();
|
|
61
|
+
setOpen(false);
|
|
62
|
+
restoreTriggerFocus();
|
|
63
|
+
};
|
|
64
|
+
const handleClear = () => {
|
|
65
|
+
// Clearing resets the filter values but keeps the panel open so the user can
|
|
66
|
+
// immediately pick new filters without reopening it.
|
|
67
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
68
|
+
};
|
|
69
|
+
const handleCancel = () => {
|
|
70
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
71
|
+
setOpen(false);
|
|
72
|
+
restoreTriggerFocus();
|
|
73
|
+
};
|
|
74
|
+
const showFooter = showActionButtons && (showApplyButton || showClearButton || showCancelButton);
|
|
75
|
+
const panelSurfaceStyle = {
|
|
76
|
+
backgroundColor: theme.surface.base,
|
|
77
|
+
borderColor: theme.border.default,
|
|
78
|
+
borderRadius: theme.radius.default,
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
shadowColor: theme.primitives.neutral900,
|
|
81
|
+
shadowOffset: { height: 4, width: 0 },
|
|
82
|
+
shadowOpacity: 0.15,
|
|
83
|
+
shadowRadius: 12,
|
|
84
|
+
width,
|
|
85
|
+
};
|
|
86
|
+
const panelBody = (_jsxs(_Fragment, { children: [_jsx(View, { style: { padding: theme.spacing.sm }, children: children }), showFooter && (_jsxs(View, { style: {
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
borderTopColor: theme.border.default,
|
|
89
|
+
borderTopWidth: 1,
|
|
90
|
+
flexDirection: "row",
|
|
91
|
+
justifyContent: "space-between",
|
|
92
|
+
padding: theme.spacing.md,
|
|
93
|
+
}, children: [showClearButton ? (_jsx(Pressable, { onPress: handleClear, testID: testID ? resolveTestID(testID, "clear") : undefined, children: _jsx(Text, { color: "link", underline: true, children: clearButtonText }) })) : (_jsx(View, {})), _jsxs(View, { style: {
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
flexDirection: "row",
|
|
96
|
+
gap: theme.spacing.sm,
|
|
97
|
+
justifyContent: "flex-end",
|
|
98
|
+
}, children: [showCancelButton && (_jsx(Button, { onClick: handleCancel, testID: testID ? resolveTestID(testID, "cancel") : undefined, text: cancelButtonText, variant: "outline" })), showApplyButton && (_jsx(Button, { onClick: handleApply, testID: testID ? resolveTestID(testID, "apply") : undefined, text: applyButtonText, variant: variant }))] })] }))] }));
|
|
99
|
+
const renderOverlay = () => {
|
|
100
|
+
// Web: portal to document.body with fixed positioning so the panel escapes
|
|
101
|
+
// every ancestor stacking context and floats above all page content.
|
|
102
|
+
if (Platform.OS === "web" && typeof document !== "undefined") {
|
|
103
|
+
// Wait for the trigger measurement so the panel appears already anchored.
|
|
104
|
+
if (!anchorReady) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const overlay = (_jsxs(View
|
|
108
|
+
// box-none lets clicks pass to the backdrop / panel but not the empty overlay.
|
|
109
|
+
, {
|
|
110
|
+
// box-none lets clicks pass to the backdrop / panel but not the empty overlay.
|
|
111
|
+
pointerEvents: "box-none", style: { inset: 0, position: "fixed", zIndex: 9999 }, children: [_jsx(Pressable, { "aria-role": "button", onPress: handleCancel, style: { inset: 0, position: "fixed", zIndex: 1 }, testID: testID ? resolveTestID(testID, "backdrop") : undefined }), _jsx(View, { style: Object.assign(Object.assign({}, panelSurfaceStyle), { left: anchor.x, position: "fixed", top: anchor.y + anchor.height + PANEL_GAP, zIndex: 2 }), testID: testID ? resolveTestID(testID, "panel") : undefined, children: panelBody })] }));
|
|
112
|
+
const target = document.body instanceof HTMLElement ? document.body : null;
|
|
113
|
+
return target ? createWebPortal({ children: overlay, container: target }) : overlay;
|
|
114
|
+
}
|
|
115
|
+
// Native fallback: anchored inline beneath the trigger.
|
|
116
|
+
return (_jsxs(_Fragment, { children: [_jsx(Pressable, { "aria-role": "button", onPress: handleCancel, style: { bottom: 0, left: 0, position: "absolute", right: 0, top: 0, zIndex: 10 }, testID: testID ? resolveTestID(testID, "backdrop") : undefined }), _jsx(View, { style: Object.assign(Object.assign({}, panelSurfaceStyle), { left: 0, position: "absolute", top: TRIGGER_OFFSET, zIndex: 11 }), testID: testID ? resolveTestID(testID, "panel") : undefined, children: panelBody })] }));
|
|
117
|
+
};
|
|
118
|
+
return (_jsxs(View, { style: { position: "relative" }, testID: testID, children: [_jsx(View, { ref: triggerRef, children: _jsx(Button, { iconName: iconName, onClick: () => setOpen(!open), testID: testID ? resolveTestID(testID, "trigger") : undefined, text: label, variant: variant }) }), Boolean(open) && renderOverlay()] }));
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=Filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filter.js","sourceRoot":"","sources":["../src/Filter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnE,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAiB,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAC,MAAM,EAAC,MAAM,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C,SAAS,GAC9D,EACF,KAAC,IAAI,IACH,KAAK,kCACA,iBAAiB,KACpB,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,EAAE,KAEZ,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,YAE1D,SAAS,GACL,IACN,CACJ,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,IAAI,IAAC,KAAK,EAAE,EAAC,QAAQ,EAAE,UAAU,EAAC,EAAE,MAAM,EAAE,MAAM,aACjD,KAAC,IAAI,IAAC,GAAG,EAAE,UAAU,YACnB,KAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAC7B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAC7D,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,OAAO,GAChB,GACG,EACN,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,EAAE,IAC5B,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { FilterAccordionProps } from "./Common";
|
|
3
|
+
/**
|
|
4
|
+
* An expandable/collapsible filter row. The header (title, optional changes
|
|
5
|
+
* badge, and chevron) is the full click zone. When expanded, the row switches
|
|
6
|
+
* to the alternate surface and reveals `children`. Empty by default.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FilterAccordion: FC<FilterAccordionProps>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Pressable, View } from "react-native";
|
|
4
|
+
import { FilterChangesBadge } from "./FilterChangesBadge";
|
|
5
|
+
import { Icon } from "./Icon";
|
|
6
|
+
import { Text } from "./Text";
|
|
7
|
+
import { useTheme } from "./Theme";
|
|
8
|
+
import { resolveTestID } from "./testing/resolveTestId";
|
|
9
|
+
/**
|
|
10
|
+
* An expandable/collapsible filter row. The header (title, optional changes
|
|
11
|
+
* badge, and chevron) is the full click zone. When expanded, the row switches
|
|
12
|
+
* to the alternate surface and reveals `children`. Empty by default.
|
|
13
|
+
*/
|
|
14
|
+
export const FilterAccordion = ({ title, children, expanded, defaultExpanded = false, onToggle, showChangesBadge = false, testID, }) => {
|
|
15
|
+
const { theme } = useTheme();
|
|
16
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
18
|
+
const isControlled = expanded !== undefined;
|
|
19
|
+
const isExpanded = isControlled ? expanded : internalExpanded;
|
|
20
|
+
const handleToggle = () => {
|
|
21
|
+
const next = !isExpanded;
|
|
22
|
+
if (!isControlled) {
|
|
23
|
+
setInternalExpanded(next);
|
|
24
|
+
}
|
|
25
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle(next);
|
|
26
|
+
};
|
|
27
|
+
let backgroundColor = theme.surface.base;
|
|
28
|
+
if (isExpanded) {
|
|
29
|
+
backgroundColor = theme.surface.baseAlternate;
|
|
30
|
+
}
|
|
31
|
+
else if (isHovered) {
|
|
32
|
+
backgroundColor = theme.surface.baseHover;
|
|
33
|
+
}
|
|
34
|
+
const webKeyDownProps = {
|
|
35
|
+
onKeyDown: (event) => {
|
|
36
|
+
if (event.key !== " " && event.key !== "Spacebar") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
// A native button activates once per press, so ignore held-key auto-repeat.
|
|
41
|
+
if (event.repeat) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
handleToggle();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
return (_jsxs(View, { style: {
|
|
48
|
+
backgroundColor,
|
|
49
|
+
borderRadius: theme.radius.default,
|
|
50
|
+
gap: theme.spacing.md,
|
|
51
|
+
paddingHorizontal: theme.spacing.sm,
|
|
52
|
+
paddingVertical: theme.primitives.spacing3,
|
|
53
|
+
}, testID: testID, children: [_jsxs(Pressable, Object.assign({}, webKeyDownProps, { accessibilityRole: "button", accessibilityState: { expanded: isExpanded }, "aria-expanded": isExpanded, onHoverIn: () => setIsHovered(true), onHoverOut: () => setIsHovered(false), onPress: handleToggle, style: {
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
flexDirection: "row",
|
|
56
|
+
justifyContent: "space-between",
|
|
57
|
+
}, testID: testID ? resolveTestID(testID, "header") : undefined, children: [_jsxs(View, { style: { alignItems: "center", flex: 1, flexDirection: "row", gap: 6 }, children: [_jsx(Text, { size: "md", children: title }), showChangesBadge && (_jsx(FilterChangesBadge, { testID: testID ? resolveTestID(testID, "badge") : undefined }))] }), _jsx(Icon, { color: "primary", iconName: isExpanded ? "chevron-up" : "chevron-down", size: "sm" })] })), Boolean(isExpanded && children) && (_jsx(View, { testID: testID ? resolveTestID(testID, "content") : undefined, children: children }))] }));
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=FilterAccordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterAccordion.js","sourceRoot":"","sources":["../src/FilterAccordion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,QAAQ,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,SA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E,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,GAAI,CACpF,IACI,EACP,KAAC,IAAI,IAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAAE,IAAI,EAAC,IAAI,GAAG,KAC9E,EACX,OAAO,CAAC,UAAU,IAAI,QAAQ,CAAC,IAAI,CAClC,KAAC,IAAI,IAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,YAAG,QAAQ,GAAQ,CACvF,IACI,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { FilterBooleanProps } from "./Common";
|
|
3
|
+
/**
|
|
4
|
+
* A boolean filter row: a title on the left and a toggle switch on the right.
|
|
5
|
+
* The entire row is the click zone, matching the design spec. Hovering tints
|
|
6
|
+
* the row with the `surface-base-hover` token.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FilterBoolean: FC<FilterBooleanProps>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Pressable, View } from "react-native";
|
|
4
|
+
import { FilterChangesBadge } from "./FilterChangesBadge";
|
|
5
|
+
import { Text } from "./Text";
|
|
6
|
+
import { useTheme } from "./Theme";
|
|
7
|
+
import { resolveTestID } from "./testing/resolveTestId";
|
|
8
|
+
const SWITCH_WIDTH = 36;
|
|
9
|
+
const SWITCH_HEIGHT = 20;
|
|
10
|
+
const KNOB_SIZE = 16;
|
|
11
|
+
/**
|
|
12
|
+
* A boolean filter row: a title on the left and a toggle switch on the right.
|
|
13
|
+
* The entire row is the click zone, matching the design spec. Hovering tints
|
|
14
|
+
* the row with the `surface-base-hover` token.
|
|
15
|
+
*/
|
|
16
|
+
export const FilterBoolean = ({ title, value, onChange, showChangesBadge = false, disabled = false, focused = false, testID, }) => {
|
|
17
|
+
const { theme } = useTheme();
|
|
18
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
19
|
+
const trackColor = disabled
|
|
20
|
+
? theme.surface.disabled
|
|
21
|
+
: value
|
|
22
|
+
? theme.surface.secondaryDark
|
|
23
|
+
: theme.surface.base;
|
|
24
|
+
const borderColor = focused
|
|
25
|
+
? theme.border.focus
|
|
26
|
+
: disabled
|
|
27
|
+
? theme.surface.disabled
|
|
28
|
+
: theme.surface.secondaryDark;
|
|
29
|
+
const handlePress = () => {
|
|
30
|
+
if (!disabled) {
|
|
31
|
+
onChange(!value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const webKeyDownProps = {
|
|
35
|
+
onKeyDown: (event) => {
|
|
36
|
+
if (event.key !== " " && event.key !== "Spacebar") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
// A native switch activates once per press, so ignore held-key auto-repeat.
|
|
41
|
+
if (event.repeat) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
handlePress();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
return (_jsxs(Pressable, Object.assign({}, webKeyDownProps, { accessibilityRole: "switch", accessibilityState: { checked: value, disabled }, "aria-checked": value, "aria-disabled": disabled, disabled: disabled, onHoverIn: () => setIsHovered(true), onHoverOut: () => setIsHovered(false), onPress: handlePress, style: {
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
backgroundColor: isHovered && !disabled ? theme.surface.baseHover : theme.surface.base,
|
|
50
|
+
borderRadius: theme.radius.default,
|
|
51
|
+
flexDirection: "row",
|
|
52
|
+
justifyContent: "space-between",
|
|
53
|
+
paddingHorizontal: theme.spacing.sm,
|
|
54
|
+
paddingVertical: theme.primitives.spacing3,
|
|
55
|
+
}, testID: testID, children: [_jsxs(View, { style: { alignItems: "center", flexDirection: "row", gap: 6 }, children: [_jsx(Text, { size: "md", children: title }), showChangesBadge && (_jsx(FilterChangesBadge, { testID: testID ? resolveTestID(testID, "badge") : undefined }))] }), _jsx(View, { style: {
|
|
56
|
+
alignItems: value ? "flex-end" : "flex-start",
|
|
57
|
+
backgroundColor: trackColor,
|
|
58
|
+
borderColor,
|
|
59
|
+
borderRadius: SWITCH_HEIGHT,
|
|
60
|
+
borderWidth: focused ? 2 : 1,
|
|
61
|
+
height: SWITCH_HEIGHT,
|
|
62
|
+
justifyContent: "center",
|
|
63
|
+
paddingHorizontal: 1,
|
|
64
|
+
width: SWITCH_WIDTH,
|
|
65
|
+
}, testID: testID ? resolveTestID(testID, "switch") : undefined, children: _jsx(View, { style: {
|
|
66
|
+
backgroundColor: theme.surface.base,
|
|
67
|
+
borderColor: disabled ? theme.surface.disabled : theme.surface.secondaryDark,
|
|
68
|
+
borderRadius: KNOB_SIZE / 2,
|
|
69
|
+
borderWidth: value ? 0 : 1,
|
|
70
|
+
height: KNOB_SIZE,
|
|
71
|
+
width: KNOB_SIZE,
|
|
72
|
+
} }) })] })));
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=FilterBoolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterBoolean.js","sourceRoot":"","sources":["../src/FilterBoolean.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,QAAQ,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAetD,MAAM,YAAY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AAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;oBAC7C,eAAe,EAAE,UAAU;oBAC3B,WAAW;oBACX,YAAY,EAAE,aAAa;oBAC3B,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC5B,MAAM,EAAE,aAAa;oBACrB,cAAc,EAAE,QAAQ;oBACxB,iBAAiB,EAAE,CAAC;oBACpB,KAAK,EAAE,YAAY;iBACpB,EACD,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,YAE5D,KAAC,IAAI,IACH,KAAK,EAAE;wBACL,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;wBACnC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa;wBAC5E,YAAY,EAAE,SAAS,GAAG,CAAC;wBAC3B,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC1B,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,SAAS;qBACjB,GACD,GACG,KACG,CACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { FilterChangesBadgeProps } from "./Common";
|
|
3
|
+
/**
|
|
4
|
+
* Small blue dot rendered next to a filter control's title when its selection
|
|
5
|
+
* differs from the default. Implemented via the design system `Badge` using the
|
|
6
|
+
* `variant=status, status=active, color=bold` spec.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FilterChangesBadge: ({ testID }: FilterChangesBadgeProps) => React.ReactElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from "./Badge";
|
|
3
|
+
/**
|
|
4
|
+
* Small blue dot rendered next to a filter control's title when its selection
|
|
5
|
+
* differs from the default. Implemented via the design system `Badge` using the
|
|
6
|
+
* `variant=status, status=active, color=bold` spec.
|
|
7
|
+
*/
|
|
8
|
+
export const FilterChangesBadge = ({ testID }) => {
|
|
9
|
+
return _jsx(Badge, { color: "bold", status: "active", testID: testID, variant: "status" });
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=FilterChangesBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterChangesBadge.js","sourceRoot":"","sources":["../src/FilterChangesBadge.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAG9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAC,MAAM,EAA0B,EAAsB,EAAE;IAC1F,OAAO,KAAC,KAAK,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAC,QAAQ,GAAG,CAAC;AACjF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FC } from "react";
|
|
2
|
+
import type { FilterSelectMenuProps } from "./Common";
|
|
3
|
+
/**
|
|
4
|
+
* A single-select filter row: a title on the left and a compact select control
|
|
5
|
+
* on the right. Only the select is the click zone. Hovering the select tints
|
|
6
|
+
* the row with the `surface-base-hover` token.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FilterSelectMenu: FC<FilterSelectMenuProps>;
|