@ssa-ui-kit/core 3.20.2 → 3.20.4
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/components/Checkbox/Checkbox.d.ts +4 -2
- package/dist/components/Checkbox/types.d.ts +6 -4
- package/dist/components/DateRangePicker/components/Presets.d.ts +10 -0
- package/dist/components/DateRangePicker/components/index.d.ts +1 -0
- package/dist/components/DateRangePicker/hooks/useDateRangePicker.d.ts +1 -0
- package/dist/components/DateRangePicker/index.d.ts +2 -1
- package/dist/components/DateRangePicker/styles.d.ts +20 -0
- package/dist/components/DateRangePicker/types.d.ts +59 -0
- package/dist/components/DateRangePicker/utils/index.d.ts +1 -0
- package/dist/components/DateRangePicker/utils/presets.d.ts +35 -0
- package/dist/components/Popover/PopoverContent.d.ts +22 -5
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Popover/types.d.ts +77 -2
- package/dist/components/Switch/Switch.d.ts +3 -2
- package/dist/components/Switch/types.d.ts +5 -2
- package/dist/components/Tooltip/Tooltip.d.ts +13 -0
- package/dist/components/Tooltip/TooltipArrow.d.ts +1 -1
- package/dist/components/Tooltip/TooltipContentBase.d.ts +10 -1
- package/dist/components/Tooltip/styles.d.ts +12 -3
- package/dist/components/Tooltip/types.d.ts +38 -2
- package/dist/components/TooltipContent/TooltipContent.d.ts +8 -0
- package/dist/components/Typeahead/styles.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1700 -858
- package/dist/index.mjs +1692 -858
- package/dist/styles/disabledSurface.d.ts +20 -0
- package/dist/styles/floatingSurface.d.ts +113 -0
- package/dist/tsbuildcache +1 -1
- package/dist/types/emotion.d.ts +1 -0
- package/dist/utils/useFloatingDisclosure.d.ts +26 -0
- package/package.json +3 -3
|
@@ -9,11 +9,13 @@ import { CheckboxProps } from './types';
|
|
|
9
9
|
*
|
|
10
10
|
* Colors are driven by `theme.palette`:
|
|
11
11
|
* - `primary` (default) — blue; uses `palette.primary.light/main/dark` for
|
|
12
|
-
* the resting border, checked fill, and hover fill.
|
|
12
|
+
* the resting border, checked fill, and hover fill.
|
|
13
13
|
* - `success` — green; uses `palette.success.main/dark` for the border and fills.
|
|
14
|
-
* Disabled uses `greyFocused40`.
|
|
15
14
|
* - `custom` — unstyled; apply your own colors via `className` or the `css` prop.
|
|
16
15
|
*
|
|
16
|
+
* When disabled, an unchecked box goes flat `greyFocused40`; a checked or
|
|
17
|
+
* indeterminate one keeps its fill colour, muted, so the state stays readable.
|
|
18
|
+
*
|
|
17
19
|
* @category Form Controls
|
|
18
20
|
* @subcategory Input
|
|
19
21
|
*
|
|
@@ -122,11 +122,13 @@ export interface CheckboxProps extends Partial<Pick<UseFormReturn, 'register'>>
|
|
|
122
122
|
* Color variant of the checkbox — controls the checked and focus-state colors.
|
|
123
123
|
* Sourced from `theme.palette`:
|
|
124
124
|
* - `primary` — blue (uses `palette.primary`); resting border is `palette.primary.light`,
|
|
125
|
-
* checked fill is `palette.primary.main`, hover fill is `palette.primary.dark
|
|
126
|
-
* disabled box
|
|
125
|
+
* checked fill is `palette.primary.main`, hover fill is `palette.primary.dark`.
|
|
126
|
+
* When disabled, an unchecked box is `greyFocused40` while a checked one keeps
|
|
127
|
+
* `palette.primary.main`, muted
|
|
127
128
|
* - `success` — green (uses `palette.success`); resting border is `palette.success.main`,
|
|
128
|
-
* checked fill is `palette.success.main`, hover fill is `palette.success.dark
|
|
129
|
-
* disabled box
|
|
129
|
+
* checked fill is `palette.success.main`, hover fill is `palette.success.dark`.
|
|
130
|
+
* When disabled, an unchecked box is `greyFocused40` while a checked one keeps
|
|
131
|
+
* `palette.success.main`, muted
|
|
130
132
|
* - `custom` — no built-in color; apply styles via `className` or the `css` prop
|
|
131
133
|
* @default 'primary'
|
|
132
134
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shortcut ranges listed beside the calendar. Applying one leaves the popover
|
|
3
|
+
* open, so the calendar stays available for fine-tuning the range afterwards.
|
|
4
|
+
*
|
|
5
|
+
* Ranges are resolved on every render rather than memoized: a relative preset
|
|
6
|
+
* (**Today**, **Current week**) has to reflect the current date, and the same
|
|
7
|
+
* resolved value drives both the highlight and the click so the two can never
|
|
8
|
+
* disagree.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Presets: () => import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
@@ -42,6 +42,7 @@ export declare const useDateRangePicker: ({ dateMin, dateMax, name: _name, forma
|
|
|
42
42
|
rangeSelectionStep: "start" | "end" | null;
|
|
43
43
|
setRangeSelectionStep: React.Dispatch<React.SetStateAction<"start" | "end" | null>>;
|
|
44
44
|
clearInputValue: (field: "from" | "to") => void;
|
|
45
|
+
applyDateRange: (from: Date, to: Date) => void;
|
|
45
46
|
isEndDatePresent: boolean;
|
|
46
47
|
setIsEndDatePresent: React.Dispatch<React.SetStateAction<boolean>>;
|
|
47
48
|
setLastChangedDate: React.Dispatch<React.SetStateAction<[Date | undefined | null, Date | undefined | null]>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './DateRangePicker';
|
|
2
2
|
export { DateRangePickerFormBridge, PRESENT_VALUE, type DateRangePickerFormBridgeProps, type DateRangePickerFormBridgeValue, } from './DateRangePickerFormBridge';
|
|
3
|
+
export { DEFAULT_DATE_RANGE_PRESETS, todayPreset, yesterdayPreset, currentWeekPreset, lastWeekPreset, currentMonthPreset, lastMonthPreset, resolvePresetRange, } from './utils/presets';
|
|
3
4
|
export { DEFAULT_MASK_FORMAT, DEFAULT_EUROPEAN_MASK_FORMAT, DEFAULT_MONTH_MASK_FORMAT, DEFAULT_YEAR_MASK_FORMAT, } from './constants';
|
|
4
|
-
export type { LastFocusedElement, RangePickerType, Format, DateRangePickerProps, DateRangePickerOnChangeDates, DateTimeTuple, DateRangePickerContextProps, } from './types';
|
|
5
|
+
export type { LastFocusedElement, RangePickerType, Format, DateRangePickerProps, DateRangePickerOnChangeDates, DateTimeTuple, DateRangePickerContextProps, DateRangePreset, DateRangePresetValue, } from './types';
|
|
@@ -12,3 +12,23 @@ export declare const TriggerWrapper: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
} & import("../..").CommonProps & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
13
13
|
theme?: import("@emotion/react").Theme;
|
|
14
14
|
}, {}, {}>;
|
|
15
|
+
/**
|
|
16
|
+
* Preset column shown to the left of the calendar. It mirrors the geometry of
|
|
17
|
+
* the day-and-time pop-up's side panel — a fixed-width column with its own
|
|
18
|
+
* padding — so the popover keeps one consistent layout whichever panel is on.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PresetsPanel: import("@emotion/styled").StyledComponent<{
|
|
21
|
+
theme?: import("@emotion/react").Theme;
|
|
22
|
+
as?: React.ElementType;
|
|
23
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
24
|
+
/**
|
|
25
|
+
* A single preset. The active look reuses the selected-cell tokens from the
|
|
26
|
+
* calendar so a highlighted preset and a highlighted day read as the same
|
|
27
|
+
* state.
|
|
28
|
+
*/
|
|
29
|
+
export declare const PresetButton: import("@emotion/styled").StyledComponent<{
|
|
30
|
+
theme?: import("@emotion/react").Theme;
|
|
31
|
+
as?: React.ElementType;
|
|
32
|
+
} & {
|
|
33
|
+
isActive: boolean;
|
|
34
|
+
}, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
@@ -31,6 +31,43 @@ export type DateRangePickerOnChangeDates = [
|
|
|
31
31
|
* Parsed range as **Luxon** values before emitting JS dates (**`[from, to]`**).
|
|
32
32
|
*/
|
|
33
33
|
export type DateTimeTuple = [DateTime | undefined, DateTime | undefined];
|
|
34
|
+
/**
|
|
35
|
+
* Resolved preset range: **[start, end]** as JavaScript **`Date`** values.
|
|
36
|
+
*/
|
|
37
|
+
export type DateRangePresetValue = [Date, Date];
|
|
38
|
+
/**
|
|
39
|
+
* One entry in the **`presets`** list rendered beside the calendar.
|
|
40
|
+
*
|
|
41
|
+
* **`dateRange`** is either a fixed tuple or a factory. Prefer the factory for
|
|
42
|
+
* anything relative to *now* (**Today**, **Current week**, …) — it is evaluated
|
|
43
|
+
* when the list renders and when the item is clicked, so the range cannot go
|
|
44
|
+
* stale in an app that stays open across midnight.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const lastSevenDays: DateRangePreset = {
|
|
49
|
+
* label: 'Last 7 days',
|
|
50
|
+
* dateRange: () => {
|
|
51
|
+
* const today = new Date();
|
|
52
|
+
* const from = new Date(today);
|
|
53
|
+
* from.setDate(from.getDate() - 6);
|
|
54
|
+
* return [from, today];
|
|
55
|
+
* },
|
|
56
|
+
* };
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface DateRangePreset {
|
|
60
|
+
/**
|
|
61
|
+
* Text shown for the item (also its accessible name).
|
|
62
|
+
*/
|
|
63
|
+
label: string;
|
|
64
|
+
/**
|
|
65
|
+
* The range applied on click — a fixed **`[start, end]`** tuple, or a
|
|
66
|
+
* function returning one. Reversed tuples are swapped, and ends outside
|
|
67
|
+
* **`dateMin`** / **`dateMax`** are clamped to those bounds.
|
|
68
|
+
*/
|
|
69
|
+
dateRange: DateRangePresetValue | (() => DateRangePresetValue);
|
|
70
|
+
}
|
|
34
71
|
/**
|
|
35
72
|
* Active calendar view: day grid, month grid, or year list (aligned with **rangePickerType** / header navigation).
|
|
36
73
|
*/
|
|
@@ -160,7 +197,21 @@ export interface DateRangePickerProps {
|
|
|
160
197
|
};
|
|
161
198
|
calendar?: string;
|
|
162
199
|
label?: string;
|
|
200
|
+
presets?: {
|
|
201
|
+
root?: string;
|
|
202
|
+
item?: string;
|
|
203
|
+
};
|
|
163
204
|
};
|
|
205
|
+
/**
|
|
206
|
+
* Shortcut ranges (**Today**, **Last month**, …) listed to the left of the
|
|
207
|
+
* calendar. Clicking one applies its range and keeps the popover open, so
|
|
208
|
+
* the user can still fine-tune the dates in the calendar. Nothing renders
|
|
209
|
+
* when the prop is omitted or empty.
|
|
210
|
+
*
|
|
211
|
+
* Use **`DEFAULT_DATE_RANGE_PRESETS`** for the common set, or build your own
|
|
212
|
+
* array of **`DateRangePreset`**.
|
|
213
|
+
*/
|
|
214
|
+
presets?: DateRangePreset[];
|
|
164
215
|
/**
|
|
165
216
|
* Emits **`[start, end]`** as **`Date`**, **`null`** (Present end only), or **`undefined`** per side.
|
|
166
217
|
*/
|
|
@@ -339,6 +390,14 @@ export interface DateRangePickerContextProps extends Omit<DateRangePickerProps,
|
|
|
339
390
|
* Clears **from** or **to** and syncs form state.
|
|
340
391
|
*/
|
|
341
392
|
clearInputValue: (field: 'from' | 'to') => void;
|
|
393
|
+
/**
|
|
394
|
+
* Applies a complete range at once (used by **`presets`**): sets both
|
|
395
|
+
* anchors, moves the calendar view onto them, syncs both form fields, and
|
|
396
|
+
* emits **`onChange`**. Reversed input is swapped and out-of-bounds ends are
|
|
397
|
+
* clamped to **`dateMin`** / **`dateMax`**; a range that falls entirely
|
|
398
|
+
* outside those bounds is ignored.
|
|
399
|
+
*/
|
|
400
|
+
applyDateRange: (from: Date, to: Date) => void;
|
|
342
401
|
/**
|
|
343
402
|
* End field shows **Present** (open-ended); form **to** value may be empty while flag is true.
|
|
344
403
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DateRangePreset, DateRangePresetValue } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Presets are resolved at click (and render) time rather than at module load,
|
|
4
|
+
* so a relative range such as **Today** stays correct in an app that is left
|
|
5
|
+
* open across midnight.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolvePresetRange: (preset: DateRangePreset) => DateRangePresetValue;
|
|
8
|
+
/** **Today** — a single-day range on the current date. */
|
|
9
|
+
export declare const todayPreset: DateRangePreset;
|
|
10
|
+
/** **Yesterday** — a single-day range on the previous date. */
|
|
11
|
+
export declare const yesterdayPreset: DateRangePreset;
|
|
12
|
+
/**
|
|
13
|
+
* **Current week** — the whole week containing today, first to last day.
|
|
14
|
+
* Week boundaries follow Luxon's locale rules (Monday-first by default).
|
|
15
|
+
*/
|
|
16
|
+
export declare const currentWeekPreset: DateRangePreset;
|
|
17
|
+
/** **Last week** — the full week before the current one. */
|
|
18
|
+
export declare const lastWeekPreset: DateRangePreset;
|
|
19
|
+
/** **Current month** — the first to the last day of the current month. */
|
|
20
|
+
export declare const currentMonthPreset: DateRangePreset;
|
|
21
|
+
/** **Last month** — the full month before the current one. */
|
|
22
|
+
export declare const lastMonthPreset: DateRangePreset;
|
|
23
|
+
/**
|
|
24
|
+
* Ready-made preset list for the common “today / yesterday / week / month”
|
|
25
|
+
* shortcuts. Pass it straight to **`presets`**, or compose your own array from
|
|
26
|
+
* the individual presets (and your own entries) to change the set or order.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { DateRangePicker, DEFAULT_DATE_RANGE_PRESETS } from '@ssa-ui-kit/core';
|
|
31
|
+
*
|
|
32
|
+
* <DateRangePicker name="report" presets={DEFAULT_DATE_RANGE_PRESETS} />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_DATE_RANGE_PRESETS: DateRangePreset[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PopoverContentProps } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* PopoverContent - Content container for popover
|
|
5
5
|
*
|
|
@@ -22,6 +22,26 @@ import { MountMode } from './types';
|
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```tsx
|
|
25
|
+
* // Surface styling comes from the root, and is shared with Tooltip
|
|
26
|
+
* <Popover color="dark" size="medium" hasArrow>
|
|
27
|
+
* <PopoverTrigger>Open</PopoverTrigger>
|
|
28
|
+
* <PopoverContent>
|
|
29
|
+
* <PopoverHeading variant="h4">Title</PopoverHeading>
|
|
30
|
+
* <PopoverDescription>Content goes here</PopoverDescription>
|
|
31
|
+
* </PopoverContent>
|
|
32
|
+
* </Popover>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* // Built-in close affordance, off by default
|
|
38
|
+
* <PopoverContent hasCloseButton closeButtonProps={{ icon: 'close-circle-outline' }}>
|
|
39
|
+
* <PopoverDescription>Dismiss me with the corner button</PopoverDescription>
|
|
40
|
+
* </PopoverContent>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
25
45
|
* // Keep content mounted when closed
|
|
26
46
|
* <PopoverContent mountMode="keep-mounted">
|
|
27
47
|
* <div>This stays in DOM when closed</div>
|
|
@@ -33,7 +53,4 @@ import { MountMode } from './types';
|
|
|
33
53
|
* @see {@link PopoverHeading} - Accessible heading component
|
|
34
54
|
* @see {@link PopoverDescription} - Accessible description component
|
|
35
55
|
*/
|
|
36
|
-
export declare const PopoverContent: React.ForwardRefExoticComponent<Omit<React.
|
|
37
|
-
isFocusManagerDisabled?: boolean;
|
|
38
|
-
mountMode?: MountMode;
|
|
39
|
-
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
56
|
+
export declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Placement, useInteractions, UseFloatingReturn, UseFloatingOptions } from '@floating-ui/react';
|
|
1
|
+
import { FloatingArrow, OffsetOptions, Placement, useInteractions, UseFloatingReturn, UseFloatingOptions } from '@floating-ui/react';
|
|
2
|
+
import { FloatingSurfaceColor, FloatingSurfaceSize } from '../../styles/floatingSurface';
|
|
3
|
+
import { IconButtonProps } from '../IconButton/types';
|
|
2
4
|
/**
|
|
3
5
|
* Interaction modes for popover activation
|
|
4
6
|
* - `click`: Opens on click interaction (default)
|
|
@@ -82,6 +84,76 @@ export interface PopoverOptions {
|
|
|
82
84
|
* Callback fired when open state changes
|
|
83
85
|
*/
|
|
84
86
|
onOpenChange?: (open: boolean) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Color scheme of the popover surface. Shared with Tooltip — see
|
|
89
|
+
* {@link FloatingSurfaceColor}.
|
|
90
|
+
*
|
|
91
|
+
* Left unset, the popover renders unstyled (no background, border or
|
|
92
|
+
* shadow) and its content supplies its own surface, which is how every
|
|
93
|
+
* popover in the kit behaved before this prop existed.
|
|
94
|
+
*/
|
|
95
|
+
color?: FloatingSurfaceColor;
|
|
96
|
+
/**
|
|
97
|
+
* Padding/typography scale of the popover surface. Unset means no padding is
|
|
98
|
+
* applied, leaving spacing to the content.
|
|
99
|
+
*/
|
|
100
|
+
size?: FloatingSurfaceSize;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the surface (and its arrow) is outlined with a 1px border
|
|
103
|
+
* @default true when `color` is `'white'`, false otherwise
|
|
104
|
+
*/
|
|
105
|
+
hasBorder?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether the surface casts a drop shadow
|
|
108
|
+
* @default true when `color` is set, false otherwise
|
|
109
|
+
*/
|
|
110
|
+
hasShadow?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to display an arrow pointing at the trigger.
|
|
113
|
+
*
|
|
114
|
+
* The arrow is filled from `color`. With no `color` the popover draws no
|
|
115
|
+
* surface of its own, so the arrow falls back to a white fill — matching the
|
|
116
|
+
* light card unstyled content usually supplies. Set `arrowProps.fill` for
|
|
117
|
+
* anything else.
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
hasArrow?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Additional props for the arrow element
|
|
123
|
+
*/
|
|
124
|
+
arrowProps?: PopoverArrowProps;
|
|
125
|
+
/**
|
|
126
|
+
* Offset between the trigger and the popover
|
|
127
|
+
* @default 12 when `hasArrow` is set, 5 otherwise
|
|
128
|
+
*/
|
|
129
|
+
offsetOptions?: OffsetOptions;
|
|
130
|
+
}
|
|
131
|
+
export type PopoverArrowProps = Omit<React.ComponentProps<typeof FloatingArrow>, 'context'>;
|
|
132
|
+
/**
|
|
133
|
+
* Props for PopoverContent component
|
|
134
|
+
*/
|
|
135
|
+
export interface PopoverContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
136
|
+
/**
|
|
137
|
+
* Disables the focus manager wrapping the content
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
isFocusManagerDisabled?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether closed content is unmounted or kept mounted but hidden
|
|
143
|
+
* @default 'unmount'
|
|
144
|
+
*/
|
|
145
|
+
mountMode?: MountMode;
|
|
146
|
+
/**
|
|
147
|
+
* Renders a close button in the top-right corner of the surface
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
hasCloseButton?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Props forwarded to the built-in close button, e.g. `icon`, `size` or
|
|
153
|
+
* `aria-label`. An `onClick` runs before the popover closes — it composes
|
|
154
|
+
* with the dismissal rather than replacing it.
|
|
155
|
+
*/
|
|
156
|
+
closeButtonProps?: Partial<IconButtonProps>;
|
|
85
157
|
}
|
|
86
158
|
export type SetIDs = {
|
|
87
159
|
setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
@@ -114,7 +186,10 @@ export interface PopoverTriggerProps {
|
|
|
114
186
|
dataTestId?: string;
|
|
115
187
|
}
|
|
116
188
|
type UseInteractions = ReturnType<typeof useInteractions>;
|
|
117
|
-
export type UsePopover = (props: PopoverOptions) => {
|
|
189
|
+
export type UsePopover = (props: PopoverOptions) => Pick<PopoverOptions, 'color' | 'size' | 'hasArrow' | 'arrowProps'> & {
|
|
190
|
+
hasBorder: boolean;
|
|
191
|
+
hasShadow: boolean;
|
|
192
|
+
arrowRef: React.RefObject<SVGSVGElement | null>;
|
|
118
193
|
open: boolean;
|
|
119
194
|
modal?: boolean;
|
|
120
195
|
labelId?: string;
|
|
@@ -12,7 +12,8 @@ import { SwitchProps } from './types';
|
|
|
12
12
|
* object to supply arbitrary CSS color values.
|
|
13
13
|
*
|
|
14
14
|
* The off state always shows a neutral grey background (`greyFocused`).
|
|
15
|
-
*
|
|
15
|
+
* When disabled, the off state uses `greySelectedMenuItem`; the on state keeps its
|
|
16
|
+
* color, muted by a white overlay so the on/off distinction survives.
|
|
16
17
|
* Hovering the on state darkens it: palette variants swap to their `palette.*.dark`
|
|
17
18
|
* token; custom colors get a `rgba(0,0,0,0.15)` overlay so the knob stays unaffected.
|
|
18
19
|
*
|
|
@@ -37,7 +38,7 @@ import { SwitchProps } from './types';
|
|
|
37
38
|
*
|
|
38
39
|
* @example
|
|
39
40
|
* ```tsx
|
|
40
|
-
* // Disabled (muted
|
|
41
|
+
* // Disabled + on (muted on-color, cannot toggle)
|
|
41
42
|
* <SwitchContextProvider initialState={true}>
|
|
42
43
|
* <Switch label="Locked feature" disabled />
|
|
43
44
|
* </SwitchContextProvider>
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
* On hover, a `rgba(0,0,0,0.15)` overlay darkens the track; the knob is unaffected.
|
|
17
17
|
*
|
|
18
18
|
* The off state always uses a neutral grey background (`greyFocused`) regardless
|
|
19
|
-
* of variant.
|
|
19
|
+
* of variant. When disabled, the off state uses `greySelectedMenuItem` while the
|
|
20
|
+
* on state keeps its color, muted by a white overlay, so a locked-on switch
|
|
21
|
+
* still reads as on.
|
|
20
22
|
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```tsx
|
|
@@ -57,7 +59,8 @@ export interface SwitchProps {
|
|
|
57
59
|
label: string;
|
|
58
60
|
/**
|
|
59
61
|
* Whether the switch is disabled
|
|
60
|
-
* Disabled switches cannot be toggled
|
|
62
|
+
* Disabled switches cannot be toggled. The off state becomes
|
|
63
|
+
* `greySelectedMenuItem`; the on state keeps its color, muted.
|
|
61
64
|
* @default false
|
|
62
65
|
*/
|
|
63
66
|
disabled?: boolean;
|
|
@@ -54,6 +54,19 @@ import { TooltipProps } from './types';
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```tsx
|
|
57
|
+
* // Dark surface, no shadow
|
|
58
|
+
* <Tooltip color="dark" hasShadow={false}>
|
|
59
|
+
* <TooltipTrigger>
|
|
60
|
+
* <Button>Hover me</Button>
|
|
61
|
+
* </TooltipTrigger>
|
|
62
|
+
* <TooltipContent title="Headline" maxWidth={200}>
|
|
63
|
+
* Body text that wraps at 200px
|
|
64
|
+
* </TooltipContent>
|
|
65
|
+
* </Tooltip>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
57
70
|
* // Tooltip without arrow
|
|
58
71
|
* <Tooltip hasArrow={false}>
|
|
59
72
|
* <TooltipTrigger>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TooltipArrowProps } from './types';
|
|
2
|
-
export declare const TooltipArrow: ({ width, height, fill, ...props }: TooltipArrowProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const TooltipArrow: ({ width, height, fill, stroke, strokeWidth, ...props }: TooltipArrowProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { TooltipColor } from './types';
|
|
2
|
+
export interface TooltipContentBaseProps {
|
|
3
|
+
/** Color scheme of the surface. Defaults to `grey`. */
|
|
4
|
+
tooltipColor?: TooltipColor;
|
|
5
|
+
/** Outlines the surface with a 1px border. */
|
|
6
|
+
hasBorder?: boolean;
|
|
7
|
+
/** Casts the design's drop shadow. Defaults to `true`. */
|
|
8
|
+
hasShadow?: boolean;
|
|
9
|
+
}
|
|
1
10
|
export declare const TooltipContentBase: import("@emotion/styled").StyledComponent<{
|
|
2
11
|
theme?: import("@emotion/react").Theme;
|
|
3
12
|
as?: React.ElementType;
|
|
4
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
13
|
+
} & TooltipContentBaseProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The tooltip surface is styled from the shared floating-surface tokens, which
|
|
3
|
+
* Popover renders from too. Re-exported under the historical names so
|
|
4
|
+
* `styles.small`, `styles.dark`, … stay part of the public Tooltip API.
|
|
5
|
+
*/
|
|
6
|
+
export { small, medium, large, grey, white, dark, nonOpaque, border, shadow, title, withTitle, surfaceColors, resolveSurfaceArrowProps, surfaceBackgrounds as backgroundColors, } from '../../styles/floatingSurface';
|
|
7
|
+
/**
|
|
8
|
+
* Font size/line height the chart tooltips were rendered at before the sizes
|
|
9
|
+
* above were aligned with the design. The chart legend spec keeps 9.26px, so
|
|
10
|
+
* they pin it explicitly instead of following the `small` size token.
|
|
11
|
+
*/
|
|
12
|
+
export declare const chartTooltipText: import("@emotion/react").SerializedStyles;
|
|
@@ -4,6 +4,7 @@ import { MapIconsType } from '../Icon/types';
|
|
|
4
4
|
import { ProgressBarProps } from '../ProgressBar/types';
|
|
5
5
|
import { SerializedStyles } from '@emotion/react';
|
|
6
6
|
import { CommonProps } from '../../types/emotion';
|
|
7
|
+
import { FloatingSurfaceColor } from '../../styles/floatingSurface';
|
|
7
8
|
/**
|
|
8
9
|
* Size variant for tooltip content
|
|
9
10
|
* - `small`: Compact tooltip with minimal padding
|
|
@@ -11,6 +12,15 @@ import { CommonProps } from '../../types/emotion';
|
|
|
11
12
|
* - `large`: Larger tooltip for more content
|
|
12
13
|
*/
|
|
13
14
|
export type TooltipSize = 'small' | 'medium' | 'large';
|
|
15
|
+
/**
|
|
16
|
+
* Color scheme of the tooltip surface — mirrors the `Color` dimension of the
|
|
17
|
+
* design. Shared with Popover, which renders the same surface.
|
|
18
|
+
* - `grey`: light grey surface with dark text (default)
|
|
19
|
+
* - `white`: white surface with dark text — bordered by default
|
|
20
|
+
* - `dark`: dark surface with white text
|
|
21
|
+
* - `nonOpaque`: semi-transparent white surface with dark text
|
|
22
|
+
*/
|
|
23
|
+
export type TooltipColor = FloatingSurfaceColor;
|
|
14
24
|
/**
|
|
15
25
|
* Props for the Tooltip component
|
|
16
26
|
*
|
|
@@ -83,6 +93,21 @@ export interface TooltipProps extends CommonProps {
|
|
|
83
93
|
* @default 'medium'
|
|
84
94
|
*/
|
|
85
95
|
size?: TooltipSize;
|
|
96
|
+
/**
|
|
97
|
+
* Color scheme of the tooltip content
|
|
98
|
+
* @default 'grey'
|
|
99
|
+
*/
|
|
100
|
+
color?: TooltipColor;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the tooltip surface (and its arrow) is outlined with a 1px border
|
|
103
|
+
* @default true when `color` is `'white'`, false otherwise
|
|
104
|
+
*/
|
|
105
|
+
hasBorder?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether the tooltip surface casts a drop shadow
|
|
108
|
+
* @default true
|
|
109
|
+
*/
|
|
110
|
+
hasShadow?: boolean;
|
|
86
111
|
/**
|
|
87
112
|
* Whether to display arrow pointing to trigger
|
|
88
113
|
* @default true
|
|
@@ -123,7 +148,7 @@ type UseInteractions = ReturnType<typeof useInteractions>;
|
|
|
123
148
|
interface RefObject<T> {
|
|
124
149
|
current: T;
|
|
125
150
|
}
|
|
126
|
-
export type UseTooltip = (props?: UseTooltipArgs) => Pick<TooltipProps, 'size' | 'hasArrow' | 'arrowProps'> & {
|
|
151
|
+
export type UseTooltip = (props?: UseTooltipArgs) => Required<Pick<TooltipProps, 'color' | 'hasBorder' | 'hasShadow'>> & Pick<TooltipProps, 'size' | 'hasArrow' | 'arrowProps'> & {
|
|
127
152
|
arrowRef: RefObject<null>;
|
|
128
153
|
isOpen: boolean;
|
|
129
154
|
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -132,7 +157,7 @@ export type TooltipContextType = (UseFloatingReturn & ReturnType<typeof useInter
|
|
|
132
157
|
arrowRef: React.Ref<SVGSVGElement>;
|
|
133
158
|
isOpen: boolean;
|
|
134
159
|
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
135
|
-
} & Pick<TooltipProps, 'size' | 'hasArrow' | 'arrowProps'>) | null;
|
|
160
|
+
} & Required<Pick<TooltipProps, 'color' | 'hasBorder' | 'hasShadow'>> & Pick<TooltipProps, 'size' | 'hasArrow' | 'arrowProps'>) | null;
|
|
136
161
|
export type TooltipArrowProps = Omit<React.ComponentProps<typeof FloatingArrow>, 'context'>;
|
|
137
162
|
/**
|
|
138
163
|
* Props for TooltipContent component
|
|
@@ -147,6 +172,17 @@ export interface TooltipContentProps {
|
|
|
147
172
|
* Can be text, React nodes, or formatted content
|
|
148
173
|
*/
|
|
149
174
|
children: React.ReactNode;
|
|
175
|
+
/**
|
|
176
|
+
* Optional headline rendered in bold above `children`, separated by an 8px
|
|
177
|
+
* gap. Accepts plain text or any React node.
|
|
178
|
+
*/
|
|
179
|
+
title?: React.ReactNode;
|
|
180
|
+
/**
|
|
181
|
+
* Maximum width of the tooltip surface. Without it the tooltip is sized to
|
|
182
|
+
* its content and never wraps — set it for multi-line content such as a
|
|
183
|
+
* `title` with a paragraph of text.
|
|
184
|
+
*/
|
|
185
|
+
maxWidth?: number | string;
|
|
150
186
|
/**
|
|
151
187
|
* Custom CSS class name
|
|
152
188
|
*/
|
|
@@ -36,6 +36,14 @@ import { TooltipContentProps } from '../Tooltip/types';
|
|
|
36
36
|
* </TooltipContent>
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Headline above the body text, wrapping at 200px
|
|
42
|
+
* <TooltipContent title="Headline" maxWidth={200}>
|
|
43
|
+
* A short description that wraps onto several lines.
|
|
44
|
+
* </TooltipContent>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
39
47
|
* @see {@link Tooltip} - Parent component that provides context
|
|
40
48
|
* @see {@link TooltipTrigger} - Trigger component that activates tooltip
|
|
41
49
|
*
|
|
@@ -50,7 +50,7 @@ export declare const TypeaheadInputsGroupWrapper: import("@emotion/styled").Styl
|
|
|
50
50
|
} & {
|
|
51
51
|
isOpen: boolean;
|
|
52
52
|
}, {}, {}>;
|
|
53
|
-
export declare const TypeaheadTrigger: import("@emotion/styled").StyledComponent<Omit<import("react").HTMLProps<HTMLElement> & import("..").ButtonProps & import("../Popover
|
|
53
|
+
export declare const TypeaheadTrigger: import("@emotion/styled").StyledComponent<Omit<import("react").HTMLProps<HTMLElement> & import("..").ButtonProps & import("../Popover").PopoverTriggerProps, "ref"> & import("react").RefAttributes<HTMLElement> & {
|
|
54
54
|
theme?: Theme;
|
|
55
55
|
} & {
|
|
56
56
|
isOpen: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import './types/emotion.d';
|
|
|
5
5
|
export * from './types/emotion';
|
|
6
6
|
export { default as mainTheme } from './themes/main';
|
|
7
7
|
export * as globalStyles from './styles/global';
|
|
8
|
+
export type { FloatingSurfaceColor, FloatingSurfaceSize, } from './styles/floatingSurface';
|
|
8
9
|
export * as styleUtils from './styles/safari-focus-outline';
|
|
9
10
|
export * from './components';
|
|
10
11
|
export * from './contexts';
|