@sentry/scraps 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -3
- package/dist/badge/tag.js +4 -2
- package/dist/button/button.js +1 -0
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/codeBlock/codeBlock.js +1 -0
- package/dist/compactSelect/control.js +3 -2
- package/dist/compactSelect/utils.js +2 -6
- package/dist/dateTime/config.d.ts +23 -0
- package/dist/dateTime/config.js +50 -0
- package/dist/dateTime/context.d.ts +18 -0
- package/dist/dateTime/context.js +46 -0
- package/dist/dateTime/dateTime.d.ts +6 -0
- package/dist/dateTime/dateTime.js +30 -0
- package/dist/dateTime/format.d.ts +24 -0
- package/dist/dateTime/format.js +45 -0
- package/dist/dateTime/index.d.ts +6 -0
- package/dist/dateTime/index.js +6 -0
- package/dist/dateTime/intlFormatter.d.ts +9 -0
- package/dist/dateTime/intlFormatter.js +16 -0
- package/dist/dateTime/parseDate.d.ts +3 -0
- package/dist/dateTime/parseDate.js +12 -0
- package/dist/dropdownMenu/context.d.ts +28 -13
- package/dist/dropdownMenu/dropdownMenu.d.ts +2 -2
- package/dist/dropdownMenu/dropdownMenu.js +9 -3
- package/dist/dropdownMenu/item.d.ts +6 -2
- package/dist/dropdownMenu/item.js +31 -71
- package/dist/dropdownMenu/list.d.ts +31 -5
- package/dist/dropdownMenu/list.js +143 -124
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +5 -241
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +5 -29
- package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
- package/dist/dropdownMenu/utils.js +5 -7
- package/dist/duration/formatElapsedDuration.d.ts +4 -0
- package/dist/duration/formatElapsedDuration.js +10 -0
- package/dist/duration/getDuration.d.ts +68 -0
- package/dist/duration/getDuration.js +80 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.js +2 -0
- package/dist/{compactSelect/fzf.d.ts → fzf.d.ts} +1 -0
- package/dist/{compactSelect/fzf.js → fzf.js} +5 -1
- package/dist/layout/container.d.ts +8 -2
- package/dist/layout/container.js +2 -2
- package/dist/layout/styles.d.ts +2 -1
- package/dist/layout/styles.js +11 -5
- package/dist/legacyDatetime.d.ts +21 -0
- package/dist/legacyDatetime.js +13 -0
- package/dist/link/index.d.ts +1 -1
- package/dist/link/index.js +1 -1
- package/dist/link/linkBehaviorContext.d.ts +9 -0
- package/dist/link/linkBehaviorContext.js +37 -7
- package/dist/menu/menu.d.ts +1 -3
- package/dist/menu/menu.js +4 -5
- package/dist/relativeTime/getRelativeDate.d.ts +14 -0
- package/dist/relativeTime/getRelativeDate.js +107 -0
- package/dist/relativeTime/index.d.ts +3 -0
- package/dist/relativeTime/index.js +3 -0
- package/dist/relativeTime/relativeTime.d.ts +55 -0
- package/dist/relativeTime/relativeTime.js +102 -0
- package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
- package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -4
- package/dist/tabs/index.js +1 -3
- package/dist/tabs/item.d.ts +16 -5
- package/dist/tabs/tab.js +6 -3
- package/dist/tabs/tabList.d.ts +5 -5
- package/dist/tabs/tabList.js +8 -6
- package/dist/tabs/tabPanels.d.ts +2 -3
- package/dist/tabs/tabPanels.js +1 -1
- package/dist/tabs/tabs.d.ts +46 -31
- package/dist/tabs/tabs.js +38 -35
- package/dist/text/prose.d.ts +2 -2
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +20 -2
- package/dist/translation/index.d.ts +1 -0
- package/dist/translation/index.js +1 -0
- package/dist/translation/translate.d.ts +9 -0
- package/dist/translation/translate.js +5 -0
- package/dist/translation/translationContext.d.ts +2 -1
- package/dist/translation/translationContext.js +2 -1
- package/fonts/OFL.txt +94 -0
- package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
- package/fonts/roboto-mono-variable-greek.woff2 +0 -0
- package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
- package/fonts/roboto-mono-variable.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic.woff2 +0 -0
- package/fonts/rubik-variable-latin-ext.woff2 +0 -0
- package/fonts/rubik-variable.woff2 +0 -0
- package/fonts.css +211 -0
- package/package.json +30 -12
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +0 -12
- package/dist/dropdownMenu/useSafetyTriangle.js +0 -119
package/README.md
CHANGED
|
@@ -35,8 +35,7 @@ pnpm --dir static/packages/scraps pack --pack-destination .artifacts
|
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
The `prepack` hook builds JavaScript and declarations with
|
|
38
|
-
[Rslib](./rslib.config.mjs), including from a clean checkout.
|
|
39
|
-
package manifest, README, and license ship.
|
|
38
|
+
[Rslib](./rslib.config.mjs), including from a clean checkout. The package ships `dist`, the font stylesheet and WOFF2 assets, the manifest, README, and licenses.
|
|
40
39
|
|
|
41
40
|
The `exports` field in [package.json](./package.json) defines the published API.
|
|
42
41
|
Import from its explicit subpaths, including `@sentry/scraps/code/inlineCode`
|
|
@@ -49,7 +48,73 @@ entry point. App stories cover more components than this API. Published consumer
|
|
|
49
48
|
have no fallback to app components.
|
|
50
49
|
|
|
51
50
|
Consumers provide Emotion's `ThemeProvider` with `lightTheme` or `darkTheme`.
|
|
52
|
-
|
|
51
|
+
Load Rubik, Roboto Mono, and their metric-adjusted fallbacks in your app stylesheet.
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
@import '@sentry/scraps/fonts.css';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The stylesheet uses relative URLs to separate WOFF2 files. For direct asset imports, use paths such as `@sentry/scraps/fonts/rubik-variable.woff2`.
|
|
58
|
+
|
|
59
|
+
To self-host without a bundler, copy `fonts.css` and the `fonts/` directory from the installed package into the same public directory, then link to `fonts.css` in your page. Keep `fonts/OFL.txt` with the font files.
|
|
60
|
+
|
|
61
|
+
## Date and duration formatting
|
|
62
|
+
|
|
63
|
+
Components and plain formatters share the same presentation options:
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import {DateTime, formatDateTime} from '@sentry/scraps/dateTime';
|
|
67
|
+
import {getDuration} from '@sentry/scraps/duration';
|
|
68
|
+
|
|
69
|
+
const date = '2025-01-01T12:00:00Z';
|
|
70
|
+
formatDateTime(date, {timezone: 'America/New_York', mode: 'time'});
|
|
71
|
+
<DateTime date={date} mode="time" precision="second" />;
|
|
72
|
+
getDuration(65, {precision: 1, style: 'short'}); // "1.1min"
|
|
73
|
+
getDuration(55, {minimumUnit: 'minute'}); // "1 minute"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Dates accept a `Date`, epoch milliseconds, or an ISO timestamp with an explicit
|
|
77
|
+
`Z` or UTC offset. Offset-free strings, calendar-only dates, invalid dates, and
|
|
78
|
+
unknown timezone identifiers return `Invalid date`.
|
|
79
|
+
|
|
80
|
+
Use `mode` to choose `dateTime`, `date`, or `time`. Time precision is
|
|
81
|
+
`minute`, `second`, or `millisecond`; year display is `auto`, `always`, or
|
|
82
|
+
`never`. Set `timezone: 'UTC'` for UTC output and `clock` to `'12'` or
|
|
83
|
+
`'24'`. UTC output includes its timezone label by default; `showTimezone`
|
|
84
|
+
controls the label explicitly. Formatting-engine types and patterns are private.
|
|
85
|
+
|
|
86
|
+
Parsing and timezone conversion use a private Temporal ponyfill, without changing
|
|
87
|
+
browser globals. Rendering preserves Intl's locale-specific date order, literal
|
|
88
|
+
characters, and time punctuation while honoring the configured clock. French
|
|
89
|
+
output includes `1 janv. 2025` and `1:05:06,123 PM`; Japanese output includes
|
|
90
|
+
`2025年1月1日` and `午後1:05`. These locale conventions replace Moment's fixed
|
|
91
|
+
month-first layout. Timezone labels use Intl by default. An application can supply
|
|
92
|
+
`getTimezoneAbbreviation(epochMilliseconds, timezone, locale)` in its formatting snapshot
|
|
93
|
+
to retain its existing labels. Returning `undefined` uses the Intl fallback.
|
|
94
|
+
Sentry supplies its already-loaded timezone lookup, preserving labels such as
|
|
95
|
+
`AEDT`, `AEST`, and `+0545` without adding Moment or a timezone dataset to Scraps.
|
|
96
|
+
|
|
97
|
+
Without configuration, dates use UTC and a 12-hour clock. Applications call
|
|
98
|
+
`configureFormatting` before rendering with one source. Its `getSnapshot`
|
|
99
|
+
returns the same object until preferences change, and `subscribe` notifies
|
|
100
|
+
consumers after a new snapshot is ready. Each snapshot contains `timezone`,
|
|
101
|
+
`clock`, `locale`, and matching `messages` with `t`, `tn`, and `pgettext`.
|
|
102
|
+
The source feeds a Zustand store shared by plain formatters and React consumers.
|
|
103
|
+
Plain formatters read its current snapshot; React consumers subscribe to changes.
|
|
104
|
+
The cleanup returned by `configureFormatting` disconnects the source and restores
|
|
105
|
+
the previous snapshot.
|
|
106
|
+
|
|
107
|
+
`DateTimeProvider` accepts partial timezone and clock overrides and inherits
|
|
108
|
+
unspecified values from its parent. Explicit component or function options win
|
|
109
|
+
over defaults. Use `useDateTimeFormatter()` to bind a formatter to the nearest
|
|
110
|
+
provider for callbacks and copied text. A free `formatDateTime` call reads
|
|
111
|
+
application preferences, without a React subtree's overrides.
|
|
112
|
+
|
|
113
|
+
`getDuration` accepts seconds and uses the same configured messages. Its
|
|
114
|
+
`minimumUnit` is a unit name such as `'millisecond'` or `'minute'`, and its
|
|
115
|
+
`style` is `'long'`, `'short'`, or `'narrow'`. The default style is long,
|
|
116
|
+
the minimum is one millisecond, and `precision` controls decimal places.
|
|
117
|
+
Month and year conversions remain approximate elapsed durations.
|
|
53
118
|
|
|
54
119
|
## Prepare a release
|
|
55
120
|
|
package/dist/badge/tag.js
CHANGED
|
@@ -46,8 +46,9 @@ const TagPill = styled('div')`
|
|
|
46
46
|
display: inline-flex;
|
|
47
47
|
gap: ${(p)=>p.theme.space.xs};
|
|
48
48
|
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
49
50
|
border-radius: ${(p)=>p.theme.radius.xs};
|
|
50
|
-
padding: 0 ${(p)=>p.theme.space.
|
|
51
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
51
52
|
max-width: 100%;
|
|
52
53
|
|
|
53
54
|
/* @TODO(jonasbadalic): We need to override button colors because they wrongly default to a blue color... */
|
|
@@ -98,6 +99,8 @@ const TagText = styled('div')`
|
|
|
98
99
|
white-space: nowrap;
|
|
99
100
|
text-overflow: ellipsis;
|
|
100
101
|
min-width: 0;
|
|
102
|
+
text-box-edge: text text;
|
|
103
|
+
text-box-trim: trim-both;
|
|
101
104
|
|
|
102
105
|
&:has(> *) {
|
|
103
106
|
display: flex;
|
|
@@ -111,7 +114,6 @@ const IconWrapper = styled('span')`
|
|
|
111
114
|
gap: inherit;
|
|
112
115
|
`;
|
|
113
116
|
const DismissButton = styled(Button)`
|
|
114
|
-
margin-right: -${(p)=>p.theme.space.xs};
|
|
115
117
|
border: none;
|
|
116
118
|
`;
|
|
117
119
|
export { Tag };
|
package/dist/button/button.js
CHANGED
|
@@ -32,6 +32,7 @@ function LinkButton({ disabled, tooltipProps, size: explicitSize, ...props }) {
|
|
|
32
32
|
to: disabled ? void 0 : 'to' in props ? props.to : void 0,
|
|
33
33
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
34
34
|
as: "span",
|
|
35
|
+
"data-button-label": true,
|
|
35
36
|
align: "center",
|
|
36
37
|
justify: "center",
|
|
37
38
|
minWidth: "0",
|
package/dist/button/styles.js
CHANGED
|
@@ -4,61 +4,102 @@ const DO_NOT_USE_BUTTON_ICON_SIZES = {
|
|
|
4
4
|
sm: 'sm',
|
|
5
5
|
md: 'sm'
|
|
6
6
|
};
|
|
7
|
-
const elevation = {
|
|
8
|
-
md: '2px',
|
|
9
|
-
sm: '2px',
|
|
10
|
-
xs: '1px',
|
|
11
|
-
zero: '0px'
|
|
12
|
-
};
|
|
13
|
-
const hoverElevation = '1px';
|
|
14
7
|
function DO_NOT_USE_getButtonStyles(p) {
|
|
15
|
-
const variant = p.variant ?? 'secondary';
|
|
16
8
|
const ariaDisabled = p['aria-disabled'];
|
|
17
|
-
const disabled = p.disabled || true === ariaDisabled || 'true' === ariaDisabled;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
lineHeight: '1rem'
|
|
25
|
-
}
|
|
9
|
+
const disabled = Boolean(p.disabled || true === ariaDisabled || 'true' === ariaDisabled);
|
|
10
|
+
const props = {
|
|
11
|
+
busy: Boolean(p.busy),
|
|
12
|
+
disabled,
|
|
13
|
+
shapeVariant: p.shapeVariant,
|
|
14
|
+
size: getSizeTokens(p.size, p.theme),
|
|
15
|
+
theme: p.theme
|
|
26
16
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
17
|
+
const variant = p.variant ?? 'secondary';
|
|
18
|
+
switch(variant){
|
|
19
|
+
case 'transparent':
|
|
20
|
+
return getTransparentStyles(props);
|
|
21
|
+
case 'link':
|
|
22
|
+
return getLinkStyles(props);
|
|
23
|
+
default:
|
|
24
|
+
return getChonkyStyles(props, chonkyTokens[variant](p.theme.tokens.interactive.chonky.embossed, p.theme));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function getBaseStyles(p) {
|
|
29
28
|
return {
|
|
30
|
-
'--button-lift': buttonElevation,
|
|
31
29
|
position: 'relative',
|
|
32
30
|
display: 'inline-flex',
|
|
33
31
|
alignItems: 'center',
|
|
34
32
|
justifyContent: 'center',
|
|
35
33
|
whiteSpace: 'nowrap',
|
|
36
34
|
fontWeight: p.theme.font.weight.sans.medium,
|
|
37
|
-
|
|
35
|
+
fontSize: p.size.fontSize,
|
|
36
|
+
lineHeight: p.size.lineHeight,
|
|
37
|
+
opacity: p.disabled ? 0.6 : void 0,
|
|
38
|
+
borderRadius: p.size.borderRadius,
|
|
39
|
+
border: 'none',
|
|
40
|
+
background: 'none',
|
|
38
41
|
cursor: 'pointer',
|
|
39
42
|
'&[disabled], &[aria-disabled="true"]': {
|
|
40
43
|
cursor: 'not-allowed'
|
|
41
44
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
'&[aria-busy="true"]': {
|
|
46
|
+
cursor: 'progress'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const chonkyTokens = {
|
|
51
|
+
primary: (embossed, theme)=>({
|
|
52
|
+
surface: embossed.accent.background,
|
|
53
|
+
chonk: embossed.accent.chonk,
|
|
54
|
+
content: embossed.accent.content,
|
|
55
|
+
focus: {
|
|
56
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
secondary: (embossed, theme)=>({
|
|
60
|
+
surface: embossed.neutral.background,
|
|
61
|
+
chonk: embossed.neutral.chonk,
|
|
62
|
+
content: embossed.neutral.content.primary,
|
|
63
|
+
focus: {
|
|
64
|
+
boxShadow: `0 var(--button-lift) 0 0 ${embossed.neutral.chonk}, 0 var(--button-lift) 0 2px ${theme.tokens.focus.default}, 0 0 0 2px ${theme.tokens.focus.default}`
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
warning: (embossed, theme)=>({
|
|
68
|
+
surface: embossed.warning.background,
|
|
69
|
+
chonk: embossed.warning.chonk,
|
|
70
|
+
content: embossed.warning.content,
|
|
71
|
+
focus: {
|
|
72
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.dark}`
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
danger: (embossed, theme)=>({
|
|
76
|
+
surface: embossed.danger.background,
|
|
77
|
+
chonk: embossed.danger.chonk,
|
|
78
|
+
content: embossed.danger.content,
|
|
79
|
+
focus: {
|
|
80
|
+
border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
function getChonkyStyles(p, tokens) {
|
|
85
|
+
return {
|
|
86
|
+
...getBaseStyles(p),
|
|
87
|
+
'--button-lift': p.size.lift,
|
|
88
|
+
padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
|
|
89
|
+
height: p.size.height,
|
|
90
|
+
minHeight: p.size.minHeight,
|
|
91
|
+
minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
|
|
92
|
+
color: tokens.content,
|
|
52
93
|
'&::before': {
|
|
53
94
|
content: '""',
|
|
54
95
|
display: 'block',
|
|
55
96
|
position: 'absolute',
|
|
56
97
|
inset: '0',
|
|
57
|
-
height: `calc(100% - ${
|
|
58
|
-
top:
|
|
59
|
-
transform: `translateY(-${
|
|
60
|
-
boxShadow: `0 ${
|
|
61
|
-
background:
|
|
98
|
+
height: `calc(100% - ${p.size.lift})`,
|
|
99
|
+
top: p.size.lift,
|
|
100
|
+
transform: `translateY(-${p.size.lift})`,
|
|
101
|
+
boxShadow: `0 ${p.size.lift} 0 0px ${tokens.chonk}`,
|
|
102
|
+
background: tokens.chonk,
|
|
62
103
|
borderRadius: 'inherit'
|
|
63
104
|
},
|
|
64
105
|
'&::after': {
|
|
@@ -66,23 +107,16 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
66
107
|
display: 'block',
|
|
67
108
|
position: 'absolute',
|
|
68
109
|
inset: '0',
|
|
69
|
-
background:
|
|
110
|
+
background: tokens.surface,
|
|
70
111
|
borderRadius: 'inherit',
|
|
71
|
-
border: `1px solid ${
|
|
112
|
+
border: `1px solid ${tokens.chonk}`,
|
|
72
113
|
transform: 'translateY(calc(-1 * var(--button-lift)))',
|
|
73
114
|
transition: `transform ${p.theme.motion.snap.fast}`
|
|
74
115
|
},
|
|
75
116
|
'&:focus-visible': {
|
|
76
117
|
outline: 'none',
|
|
77
|
-
color: disabled || p.busy ? void 0 :
|
|
78
|
-
'&::after':
|
|
79
|
-
border: `2px dotted ${buttonTheme.focus}`
|
|
80
|
-
} : {
|
|
81
|
-
boxShadow: `0 var(--button-lift) 0 0 ${buttonTheme.background}, 0 var(--button-lift) 0 2px ${p.theme.tokens.focus.default}, 0 0 0 2px ${p.theme.tokens.focus.default}`
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
'&[aria-busy="true"] > span:last-child': {
|
|
85
|
-
overflow: 'visible'
|
|
118
|
+
color: p.disabled || p.busy ? void 0 : tokens.content,
|
|
119
|
+
'&::after': tokens.focus
|
|
86
120
|
},
|
|
87
121
|
'> span:last-child': {
|
|
88
122
|
zIndex: 1,
|
|
@@ -97,9 +131,12 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
97
131
|
transform: 'translateY(calc(-1 * var(--button-lift)))',
|
|
98
132
|
transition: `transform ${p.theme.motion.snap.fast}`
|
|
99
133
|
},
|
|
134
|
+
'&[aria-busy="true"] > span:last-child': {
|
|
135
|
+
overflow: 'visible'
|
|
136
|
+
},
|
|
100
137
|
'&:hover': {
|
|
101
|
-
'--button-lift': `calc(${
|
|
102
|
-
color: disabled || p.busy ? void 0 :
|
|
138
|
+
'--button-lift': `calc(${p.size.lift} + 1px)`,
|
|
139
|
+
color: p.disabled || p.busy ? void 0 : tokens.content
|
|
103
140
|
},
|
|
104
141
|
'&:active, &[aria-expanded="true"], &[aria-checked="true"]': {
|
|
105
142
|
'--button-lift': '0px'
|
|
@@ -114,134 +151,102 @@ function DO_NOT_USE_getButtonStyles(p) {
|
|
|
114
151
|
},
|
|
115
152
|
'&:disabled, &[aria-disabled="true"], &[aria-busy="true"]': {
|
|
116
153
|
'--button-lift': '0px'
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function getTransparentStyles(p) {
|
|
158
|
+
return {
|
|
159
|
+
...getBaseStyles(p),
|
|
160
|
+
padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
|
|
161
|
+
height: p.size.height,
|
|
162
|
+
minHeight: p.size.minHeight,
|
|
163
|
+
minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
|
|
164
|
+
color: p.theme.tokens.interactive.transparent.neutral.content.primary,
|
|
165
|
+
transform: 'translateY(0px)',
|
|
166
|
+
'&::before': {
|
|
167
|
+
display: 'none'
|
|
117
168
|
},
|
|
118
|
-
'
|
|
119
|
-
|
|
169
|
+
'&::after': {
|
|
170
|
+
display: 'none'
|
|
120
171
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
'
|
|
124
|
-
display: 'none'
|
|
125
|
-
},
|
|
126
|
-
'&::after': {
|
|
127
|
-
display: 'none'
|
|
128
|
-
}
|
|
172
|
+
'&:focus-visible': p.theme.focusRing(),
|
|
173
|
+
'> span:last-child': {
|
|
174
|
+
transform: 'translateY(0px)'
|
|
129
175
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
transform: 'translateY(0px)',
|
|
133
|
-
'&::before': {
|
|
134
|
-
display: 'none'
|
|
135
|
-
},
|
|
136
|
-
'&::after': {
|
|
137
|
-
display: 'none'
|
|
138
|
-
},
|
|
139
|
-
'&:focus-visible': {
|
|
140
|
-
...p.theme.focusRing()
|
|
141
|
-
},
|
|
142
|
-
'> span:last-child': {
|
|
143
|
-
transform: 'translateY(0px)'
|
|
144
|
-
},
|
|
145
|
-
'&:hover': {
|
|
146
|
-
'> span:last-child': {
|
|
147
|
-
transform: 'translateY(0px)'
|
|
148
|
-
},
|
|
149
|
-
backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray100
|
|
150
|
-
},
|
|
151
|
-
'&:active': {
|
|
152
|
-
'> span:last-child': {
|
|
153
|
-
transform: 'translateY(0px)'
|
|
154
|
-
},
|
|
155
|
-
backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray200
|
|
156
|
-
}
|
|
176
|
+
'&:hover': {
|
|
177
|
+
backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray100
|
|
157
178
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
height: 'auto',
|
|
161
|
-
minHeight: 'auto',
|
|
162
|
-
minWidth: 'auto',
|
|
163
|
-
border: 'none',
|
|
164
|
-
transform: 'translateY(0px)',
|
|
165
|
-
'> span:last-child': {
|
|
166
|
-
color: 'inherit'
|
|
167
|
-
},
|
|
168
|
-
'&:hover': {
|
|
169
|
-
'> span:last-child': {
|
|
170
|
-
transform: 'translateY(0px)'
|
|
171
|
-
}
|
|
172
|
-
}
|
|
179
|
+
'&:active': {
|
|
180
|
+
backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray200
|
|
173
181
|
}
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
surface: theme.tokens.interactive.chonky.embossed.danger.background,
|
|
201
|
-
background: theme.tokens.interactive.chonky.embossed.danger.chonk,
|
|
202
|
-
color: theme.tokens.interactive.chonky.embossed.danger.content,
|
|
203
|
-
focus: theme.tokens.focus.onVibrant.light
|
|
204
|
-
};
|
|
205
|
-
case 'transparent':
|
|
206
|
-
return {
|
|
207
|
-
surface: theme.tokens.interactive.transparent.neutral.background.rest,
|
|
208
|
-
background: theme.tokens.interactive.transparent.neutral.background.rest,
|
|
209
|
-
color: theme.tokens.interactive.transparent.neutral.content.primary
|
|
210
|
-
};
|
|
211
|
-
case 'link':
|
|
212
|
-
return {
|
|
213
|
-
surface: 'transparent',
|
|
214
|
-
background: 'transparent',
|
|
215
|
-
color: theme.tokens.interactive.link.accent.rest
|
|
216
|
-
};
|
|
217
|
-
default:
|
|
218
|
-
return {};
|
|
219
|
-
}
|
|
184
|
+
function getLinkStyles(p) {
|
|
185
|
+
return {
|
|
186
|
+
...getBaseStyles(p),
|
|
187
|
+
padding: '0',
|
|
188
|
+
height: 'auto',
|
|
189
|
+
minHeight: 'auto',
|
|
190
|
+
minWidth: 'auto',
|
|
191
|
+
color: p.theme.tokens.interactive.link.accent.rest,
|
|
192
|
+
transform: 'translateY(0px)',
|
|
193
|
+
'&::before': {
|
|
194
|
+
display: 'none'
|
|
195
|
+
},
|
|
196
|
+
'&::after': {
|
|
197
|
+
display: 'none'
|
|
198
|
+
},
|
|
199
|
+
'&:focus-visible': p.theme.focusRing(),
|
|
200
|
+
'> span:last-child': {
|
|
201
|
+
color: 'inherit'
|
|
202
|
+
},
|
|
203
|
+
'&:active': {
|
|
204
|
+
backgroundColor: 'inherit'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
220
207
|
}
|
|
221
|
-
function
|
|
208
|
+
function getSizeTokens(size, theme) {
|
|
222
209
|
switch(size){
|
|
223
210
|
case 'md':
|
|
224
211
|
return {
|
|
212
|
+
height: '36px',
|
|
213
|
+
minHeight: '36px',
|
|
214
|
+
fontSize: '0.875rem',
|
|
215
|
+
lineHeight: '1rem',
|
|
216
|
+
padding: `${theme.space.md} ${theme.space.xl}`,
|
|
225
217
|
borderRadius: theme.radius.lg,
|
|
226
|
-
|
|
218
|
+
lift: '2px'
|
|
227
219
|
};
|
|
228
220
|
case 'sm':
|
|
229
221
|
return {
|
|
222
|
+
height: '32px',
|
|
223
|
+
minHeight: '32px',
|
|
224
|
+
fontSize: '0.875rem',
|
|
225
|
+
lineHeight: '1rem',
|
|
226
|
+
padding: `${theme.space.md} ${theme.space.lg}`,
|
|
230
227
|
borderRadius: theme.radius.md,
|
|
231
|
-
|
|
228
|
+
lift: '2px'
|
|
232
229
|
};
|
|
233
230
|
case 'xs':
|
|
234
231
|
return {
|
|
232
|
+
height: '28px',
|
|
233
|
+
minHeight: '28px',
|
|
234
|
+
fontSize: '0.75rem',
|
|
235
|
+
lineHeight: '1rem',
|
|
236
|
+
padding: `${theme.space.sm} ${theme.space.md}`,
|
|
235
237
|
borderRadius: theme.radius.sm,
|
|
236
|
-
|
|
238
|
+
lift: '1px'
|
|
237
239
|
};
|
|
238
240
|
case 'zero':
|
|
239
241
|
return {
|
|
242
|
+
height: '24px',
|
|
243
|
+
minHeight: '24px',
|
|
244
|
+
fontSize: '0.75rem',
|
|
245
|
+
lineHeight: '1rem',
|
|
246
|
+
padding: `${theme.space.xs} ${theme.space.sm}`,
|
|
240
247
|
borderRadius: theme.radius.xs,
|
|
241
|
-
|
|
248
|
+
lift: '0px'
|
|
242
249
|
};
|
|
243
|
-
default:
|
|
244
|
-
return {};
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
export { DO_NOT_USE_BUTTON_ICON_SIZES, DO_NOT_USE_getButtonStyles };
|
|
@@ -193,6 +193,7 @@ function Control({ autoFocus, trigger, triggerId, isOpen, onClose, isDismissable
|
|
|
193
193
|
return /*#__PURE__*/ jsx(ControlContext, {
|
|
194
194
|
value: contextValue,
|
|
195
195
|
children: /*#__PURE__*/ jsxs(Container, {
|
|
196
|
+
display: "flex",
|
|
196
197
|
width: "max-content",
|
|
197
198
|
position: "relative",
|
|
198
199
|
...wrapperProps,
|
|
@@ -222,13 +223,13 @@ function Control({ autoFocus, trigger, triggerId, isOpen, onClose, isDismissable
|
|
|
222
223
|
contain: true,
|
|
223
224
|
children: [
|
|
224
225
|
hasHeader && /*#__PURE__*/ jsx(Header, {
|
|
225
|
-
borderBottom: searchEnabled ? 'none' : '
|
|
226
|
+
borderBottom: searchEnabled ? 'none' : 'secondary',
|
|
227
|
+
padding: searchEnabled ? 'xs lg 0 lg' : 'xs lg',
|
|
226
228
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
227
229
|
align: "center",
|
|
228
230
|
justify: "between",
|
|
229
231
|
gap: "xl",
|
|
230
232
|
minHeight: "24px",
|
|
231
|
-
padding: searchEnabled ? 'xs lg 0 lg' : 'xs lg',
|
|
232
233
|
children: [
|
|
233
234
|
menuTitle && /*#__PURE__*/ jsx(Title, {
|
|
234
235
|
children: menuTitle
|
|
@@ -4,7 +4,7 @@ import { useFocus, usePress } from "@react-aria/interactions";
|
|
|
4
4
|
import { mergeProps } from "@react-aria/utils";
|
|
5
5
|
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
6
6
|
import { useTranslation } from "../translation/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getSearchScore } from "../fzf.js";
|
|
8
8
|
import { SectionToggleButton } from "./styles.js";
|
|
9
9
|
function hasVisibleLeadingItems(listItems, hiddenOptions) {
|
|
10
10
|
return listItems.flatMap((node)=>'section' === node.type ? [
|
|
@@ -68,12 +68,8 @@ function defaultSearchMatcher(option, search) {
|
|
|
68
68
|
if (!text) return {
|
|
69
69
|
score: 0
|
|
70
70
|
};
|
|
71
|
-
const result = fzf(text, search.toLowerCase(), false);
|
|
72
|
-
if (-1 === result.end) return {
|
|
73
|
-
score: 0
|
|
74
|
-
};
|
|
75
71
|
return {
|
|
76
|
-
score:
|
|
72
|
+
score: getSearchScore(text, search)
|
|
77
73
|
};
|
|
78
74
|
}
|
|
79
75
|
function getHiddenOptions(items, search, limit = 1 / 0, searchMatcher) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Translation } from '../translation/translate.js';
|
|
2
|
+
export interface DateTimePreferences {
|
|
3
|
+
clock: '12' | '24';
|
|
4
|
+
timezone: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FormattingSnapshot extends DateTimePreferences {
|
|
7
|
+
locale: string;
|
|
8
|
+
messages: Translation;
|
|
9
|
+
/** Optional application label source. Returning undefined falls back to Intl. */
|
|
10
|
+
getTimezoneAbbreviation?: (epochMilliseconds: number, timezone: string, locale: string) => string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface FormattingSource {
|
|
13
|
+
getSnapshot: () => Readonly<FormattingSnapshot>;
|
|
14
|
+
subscribe: (onChange: () => void) => () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const formattingStore: {
|
|
17
|
+
getState: () => Readonly<FormattingSnapshot>;
|
|
18
|
+
getInitialState: () => Readonly<FormattingSnapshot>;
|
|
19
|
+
subscribe: (listener: (state: Readonly<FormattingSnapshot>, prevState: Readonly<FormattingSnapshot>) => void) => () => void;
|
|
20
|
+
};
|
|
21
|
+
/** Connect application preferences and locale to the reactive formatting store. */
|
|
22
|
+
export declare function configureFormatting(source: FormattingSource): () => void;
|
|
23
|
+
export declare const getSnapshot: () => Readonly<FormattingSnapshot>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createStore } from "zustand/vanilla";
|
|
2
|
+
const defaults = {
|
|
3
|
+
timezone: 'UTC',
|
|
4
|
+
clock: '12',
|
|
5
|
+
locale: 'en',
|
|
6
|
+
messages: {
|
|
7
|
+
t: (message, ...args)=>message.replace(/%s/g, ()=>{
|
|
8
|
+
const value = args.shift();
|
|
9
|
+
return 'string' == typeof value || 'number' == typeof value ? `${value}` : '%s';
|
|
10
|
+
}),
|
|
11
|
+
tn: (singular, plural, count)=>1 === Math.abs(count) ? singular : plural,
|
|
12
|
+
pgettext: (_context, message)=>message
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const store = createStore(()=>defaults);
|
|
16
|
+
const formattingStore = {
|
|
17
|
+
getState: store.getState,
|
|
18
|
+
getInitialState: store.getState,
|
|
19
|
+
subscribe: store.subscribe
|
|
20
|
+
};
|
|
21
|
+
function toIntlLocale(locale) {
|
|
22
|
+
try {
|
|
23
|
+
return Intl.getCanonicalLocales(locale.replaceAll('_', '-'))[0] ?? defaults.locale;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof RangeError) return defaults.locale;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function configureFormatting(source) {
|
|
30
|
+
const previous = store.getState();
|
|
31
|
+
let lastSnapshot;
|
|
32
|
+
const update = ()=>{
|
|
33
|
+
const snapshot = source.getSnapshot();
|
|
34
|
+
if (snapshot === lastSnapshot) return;
|
|
35
|
+
lastSnapshot = snapshot;
|
|
36
|
+
const locale = toIntlLocale(snapshot.locale);
|
|
37
|
+
store.setState(locale === snapshot.locale ? snapshot : {
|
|
38
|
+
...snapshot,
|
|
39
|
+
locale
|
|
40
|
+
}, true);
|
|
41
|
+
};
|
|
42
|
+
const unsubscribe = source.subscribe(update);
|
|
43
|
+
update();
|
|
44
|
+
return ()=>{
|
|
45
|
+
unsubscribe();
|
|
46
|
+
store.setState(previous, true);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const getSnapshot = store.getState;
|
|
50
|
+
export { configureFormatting, formattingStore, getSnapshot };
|