@sentry/scraps 0.5.0 → 0.7.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 +95 -3
- package/dist/alert/alert.js +10 -7
- 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/compactSelect.d.ts +2 -2
- package/dist/compactSelect/compactSelect.js +37 -23
- package/dist/compactSelect/control.js +14 -10
- package/dist/compactSelect/gridList/index.js +35 -36
- package/dist/compactSelect/gridList/option.d.ts +4 -1
- package/dist/compactSelect/gridList/option.js +4 -3
- package/dist/compactSelect/gridList/section.d.ts +10 -3
- package/dist/compactSelect/gridList/section.js +16 -33
- package/dist/compactSelect/listBox/index.d.ts +1 -1
- package/dist/compactSelect/listBox/index.js +46 -58
- package/dist/compactSelect/listBox/section.d.ts +10 -8
- package/dist/compactSelect/listBox/section.js +11 -30
- package/dist/compactSelect/styles.d.ts +6 -7
- package/dist/compactSelect/styles.js +1 -23
- 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/diagnostics/context.d.ts +12 -0
- package/dist/diagnostics/context.js +11 -0
- package/dist/diagnostics/index.d.ts +2 -0
- package/dist/diagnostics/index.js +1 -0
- package/dist/disclosure/disclosure.js +1 -1
- package/dist/dragHandle/dragHandle.js +3 -5
- package/dist/dropdownMenu/context.d.ts +36 -11
- package/dist/dropdownMenu/context.js +2 -1
- package/dist/dropdownMenu/dropdownMenu.d.ts +2 -2
- package/dist/dropdownMenu/dropdownMenu.js +9 -3
- package/dist/dropdownMenu/item.d.ts +7 -8
- package/dist/dropdownMenu/item.js +43 -77
- package/dist/dropdownMenu/list.d.ts +31 -5
- package/dist/dropdownMenu/list.js +154 -133
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +5 -241
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +5 -29
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
- 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/form/field/radioGroupField.d.ts +7 -0
- package/dist/form/field/radioGroupField.js +14 -0
- package/dist/form/field/selectField.d.ts +3 -4
- package/dist/form/field/selectField.js +16 -24
- 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 +24 -7
- package/dist/layout/container.js +9 -12
- package/dist/layout/flex.js +1 -1
- package/dist/layout/grid.js +2 -2
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/stack.js +1 -1
- package/dist/layout/styles.d.ts +28 -7
- package/dist/layout/styles.js +76 -16
- package/dist/layout/surface.d.ts +2 -2
- package/dist/layout/surface.js +6 -3
- 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 +5 -6
- package/dist/menu/selectValue.d.ts +2 -6
- package/dist/modal/components.js +2 -2
- package/dist/overlayArrow.js +2 -2
- 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/select/chips.d.ts +14 -0
- package/dist/select/chips.js +45 -0
- package/dist/select/filter.js +7 -11
- package/dist/select/index.d.ts +1 -1
- package/dist/select/indicators.d.ts +11 -0
- package/dist/select/indicators.js +61 -0
- package/dist/select/menu.d.ts +44 -0
- package/dist/select/menu.js +103 -0
- package/dist/select/option.d.ts +23 -15
- package/dist/select/option.js +66 -58
- package/dist/select/options.d.ts +31 -0
- package/dist/select/options.js +74 -0
- package/dist/select/select.d.ts +24 -11
- package/dist/select/select.js +527 -429
- package/dist/select/styles.d.ts +148 -2
- package/dist/select/styles.js +156 -1
- package/dist/select/types.d.ts +6 -7
- package/dist/select/types.js +4 -0
- package/dist/select/utils.d.ts +2 -0
- package/dist/select/utils.js +4 -0
- package/dist/separator/separator.d.ts +2 -2
- package/dist/separator/separator.js +4 -3
- package/dist/slot/slot.js +16 -12
- 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 +9 -4
- 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/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +21 -2
- package/dist/theme/useResolvedTheme.d.ts +12 -0
- package/dist/theme/useResolvedTheme.js +20 -0
- package/dist/theme/variables.css +1116 -0
- package/dist/theme/variables.d.ts +985 -0
- package/dist/theme/variables.js +455 -0
- 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/dist/useVirtualCollection.d.ts +14 -1
- package/dist/useVirtualCollection.js +59 -3
- 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 +39 -15
- package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
- package/dist/compactSelect/useVirtualizedItems.js +0 -74
- 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/dist/select/reactSelectWrapper.d.ts +0 -8
- package/dist/select/reactSelectWrapper.js +0 -25
- package/dist/select/virtualizedMenuList.d.ts +0 -24
- package/dist/select/virtualizedMenuList.js +0 -123
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { useClock, useTimezone } from './dateTime/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Published 0.4.0 and 0.5.0 exported this API from `@sentry/scraps/datetime`.
|
|
5
|
+
* It now lives in `@sentry/scraps/dateTime`; these aliases keep existing imports
|
|
6
|
+
* working for one release.
|
|
7
|
+
*/
|
|
8
|
+
/** @deprecated Use `DateTimePreferences` from `@sentry/scraps/dateTime`. */
|
|
9
|
+
export interface DateTimeContextValue {
|
|
10
|
+
clockDisplay: '12' | '24';
|
|
11
|
+
timezone: string;
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Use `DateTimeProvider` from `@sentry/scraps/dateTime`. */
|
|
14
|
+
export declare function DateTimeProvider({ value, children, }: {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
value: DateTimeContextValue;
|
|
17
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
/** @deprecated Use `useTimezone` from `@sentry/scraps/dateTime`. */
|
|
19
|
+
export { useTimezone };
|
|
20
|
+
/** @deprecated Use `useClock` from `@sentry/scraps/dateTime`. */
|
|
21
|
+
export declare const useClockDisplay: typeof useClock;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { DateTimeProvider, useClock, useTimezone } from "./dateTime/index.js";
|
|
3
|
+
function legacyDatetime_DateTimeProvider({ value, children }) {
|
|
4
|
+
return /*#__PURE__*/ jsx(DateTimeProvider, {
|
|
5
|
+
value: {
|
|
6
|
+
timezone: value.timezone,
|
|
7
|
+
clock: value.clockDisplay
|
|
8
|
+
},
|
|
9
|
+
children: children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const useClockDisplay = useClock;
|
|
13
|
+
export { legacyDatetime_DateTimeProvider as DateTimeProvider, useClockDisplay, useTimezone };
|
package/dist/link/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Link, type LinkDestination, type LinkProps, ExternalLink } from './link.js';
|
|
2
|
-
export { LinkBehaviorContextProvider } from './linkBehaviorContext.js';
|
|
2
|
+
export { LinkBehaviorContextProvider, useLinkQueryString, useResolveLinkHref, } from './linkBehaviorContext.js';
|
package/dist/link/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ExternalLink, Link } from "./link.js";
|
|
2
|
-
export { LinkBehaviorContextProvider } from "./linkBehaviorContext.js";
|
|
2
|
+
export { LinkBehaviorContextProvider, useLinkQueryString, useResolveLinkHref } from "./linkBehaviorContext.js";
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import { type FunctionComponent } from 'react';
|
|
3
3
|
import type { LinkProps } from './link.js';
|
|
4
|
+
type QueryString = {
|
|
5
|
+
parse: (search: string) => Record<string, string | string[] | null>;
|
|
6
|
+
stringify: (query: Record<string, unknown>) => string;
|
|
7
|
+
};
|
|
4
8
|
type LinkBehavior<T extends LinkProps> = {
|
|
5
9
|
behavior: (props: T) => T;
|
|
6
10
|
component: FunctionComponent<T>;
|
|
11
|
+
/** Query string helpers default to URLSearchParams behavior. */
|
|
12
|
+
parse?: QueryString['parse'];
|
|
13
|
+
stringify?: QueryString['stringify'];
|
|
7
14
|
};
|
|
8
15
|
declare function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }: LinkProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
16
|
export declare const LinkBehaviorContextProvider: React.Provider<LinkBehavior<LinkProps> | null>;
|
|
@@ -11,6 +18,8 @@ export declare const useLinkBehavior: <T extends LinkProps>(props: T) => {
|
|
|
11
18
|
Component: typeof AnchorLink | React.FunctionComponent<T>;
|
|
12
19
|
behavior: () => T;
|
|
13
20
|
};
|
|
21
|
+
/** Use the provider's query helpers, or the native defaults outside a provider. */
|
|
22
|
+
export declare function useLinkQueryString(): QueryString;
|
|
14
23
|
/** Resolve collection hrefs through the same application behavior as Link. */
|
|
15
24
|
export declare function useResolveLinkHref(): (to: LinkProps["to"]) => string;
|
|
16
25
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { createContext, useCallback, useContext } from "react";
|
|
3
|
-
import * as __rspack_external_query_string_78b5d812 from "query-string";
|
|
4
3
|
const LinkBehaviorContext = /*#__PURE__*/ createContext(null);
|
|
5
4
|
function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }) {
|
|
5
|
+
const { stringify } = useLinkQueryString();
|
|
6
6
|
return /*#__PURE__*/ jsx("a", {
|
|
7
7
|
...props,
|
|
8
|
-
href: destinationToHref(to)
|
|
8
|
+
href: destinationToHref(to, stringify)
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
const defaultLinkBehavior = ()=>({
|
|
@@ -21,18 +21,48 @@ const useLinkBehavior = (props)=>{
|
|
|
21
21
|
behavior: ()=>behavior(props)
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function parseQuery(search) {
|
|
25
|
+
const query = Object.create(null);
|
|
26
|
+
for (const [key, value] of new URLSearchParams(search)){
|
|
27
|
+
const existing = query[key];
|
|
28
|
+
if (void 0 === existing) query[key] = value;
|
|
29
|
+
else query[key] = [
|
|
30
|
+
...Array.isArray(existing) ? existing : [
|
|
31
|
+
existing
|
|
32
|
+
],
|
|
33
|
+
value
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return query;
|
|
37
|
+
}
|
|
38
|
+
function stringifyQuery(query) {
|
|
39
|
+
const params = new URLSearchParams();
|
|
40
|
+
for (const [key, value] of Object.entries(query))for (const item of Array.isArray(value) ? value : [
|
|
41
|
+
value
|
|
42
|
+
])if (void 0 !== item) params.append(key, String(item));
|
|
43
|
+
return params.toString();
|
|
44
|
+
}
|
|
45
|
+
function useLinkQueryString() {
|
|
46
|
+
const linkBehavior = useContext(LinkBehaviorContext);
|
|
47
|
+
return {
|
|
48
|
+
parse: linkBehavior?.parse ?? parseQuery,
|
|
49
|
+
stringify: linkBehavior?.stringify ?? stringifyQuery
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function destinationToHref(to, stringify) {
|
|
25
53
|
if ('string' == typeof to) return to;
|
|
26
54
|
const { pathname = '', hash = '', search = '', query } = to;
|
|
27
|
-
const querySearch = query ?
|
|
55
|
+
const querySearch = query ? stringify(query) : search;
|
|
28
56
|
return `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
|
|
29
57
|
}
|
|
30
58
|
function useResolveLinkHref() {
|
|
31
59
|
const linkBehavior = useContext(LinkBehaviorContext);
|
|
60
|
+
const { stringify } = useLinkQueryString();
|
|
32
61
|
return useCallback((to)=>destinationToHref(linkBehavior ? linkBehavior.behavior({
|
|
33
62
|
to
|
|
34
|
-
}).to : to), [
|
|
35
|
-
linkBehavior
|
|
63
|
+
}).to : to, stringify), [
|
|
64
|
+
linkBehavior,
|
|
65
|
+
stringify
|
|
36
66
|
]);
|
|
37
67
|
}
|
|
38
|
-
export { LinkBehaviorContextProvider, useLinkBehavior, useResolveLinkHref };
|
|
68
|
+
export { LinkBehaviorContextProvider, useLinkBehavior, useLinkQueryString, useResolveLinkHref };
|
package/dist/menu/menu.d.ts
CHANGED
|
@@ -154,14 +154,12 @@ interface OtherProps<T extends React.ElementType> {
|
|
|
154
154
|
trailingAction?: MenuItemTrailingAction;
|
|
155
155
|
/** Ref to the trailing action's button. */
|
|
156
156
|
trailingActionRef?: React.Ref<HTMLButtonElement>;
|
|
157
|
-
/** Props for the wrapper around the trailing action. */
|
|
158
|
-
trailingActionWrapperProps?: React.ComponentPropsWithRef<'div'>;
|
|
159
157
|
}
|
|
160
158
|
interface MenuListItemProps<T extends React.ElementType = 'li'> extends ListItemProps, OtherProps<T> {
|
|
161
159
|
ref?: React.ComponentPropsWithRef<NoInfer<T>>['ref'];
|
|
162
160
|
}
|
|
163
161
|
/** Renders the shared visual shell for menu and select items. */
|
|
164
|
-
export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef,
|
|
162
|
+
export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }: MenuListItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
165
163
|
/** Moves focus into a menu item's overlay details, returning whether it could. */
|
|
166
164
|
export declare function focusMenuItemDetails(item: Element | null): boolean;
|
|
167
165
|
export {};
|
package/dist/menu/menu.js
CHANGED
|
@@ -27,7 +27,7 @@ function calculateMenuMinHeight(first, second) {
|
|
|
27
27
|
}
|
|
28
28
|
function MenuHeaderLayout(props) {
|
|
29
29
|
return /*#__PURE__*/ jsx(Stack, {
|
|
30
|
-
|
|
30
|
+
borderBottomColor: "secondary",
|
|
31
31
|
gap: "0",
|
|
32
32
|
...props
|
|
33
33
|
});
|
|
@@ -65,7 +65,7 @@ function MenuSectionHeader({ children, trailingAction, ...props }) {
|
|
|
65
65
|
justify: "between",
|
|
66
66
|
align: "center",
|
|
67
67
|
minHeight: "1.5em",
|
|
68
|
-
padding: "
|
|
68
|
+
padding: "md lg",
|
|
69
69
|
...props,
|
|
70
70
|
children: [
|
|
71
71
|
children,
|
|
@@ -76,7 +76,7 @@ function MenuSectionHeader({ children, trailingAction, ...props }) {
|
|
|
76
76
|
function MenuSectionSeparator() {
|
|
77
77
|
return /*#__PURE__*/ jsx(Separator, {
|
|
78
78
|
orientation: "horizontal",
|
|
79
|
-
|
|
79
|
+
borderColor: "secondary"
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
function MenuSectionGroup(props) {
|
|
@@ -97,7 +97,7 @@ function MenuSectionList(props) {
|
|
|
97
97
|
}
|
|
98
98
|
function MenuFooterLayout(props) {
|
|
99
99
|
return /*#__PURE__*/ jsx(Flex, {
|
|
100
|
-
|
|
100
|
+
borderTopColor: "secondary",
|
|
101
101
|
align: "center",
|
|
102
102
|
padding: "md lg",
|
|
103
103
|
...props
|
|
@@ -254,7 +254,7 @@ const StyledDetails = styled('div')`
|
|
|
254
254
|
color: ${getTextColor(p)};
|
|
255
255
|
`}
|
|
256
256
|
`;
|
|
257
|
-
function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef,
|
|
257
|
+
function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }) {
|
|
258
258
|
const [itemElement, setItemElement] = useState(null);
|
|
259
259
|
const [returnFocusTarget, setReturnFocusTarget] = useState(null);
|
|
260
260
|
const theme = useTheme();
|
|
@@ -394,7 +394,6 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
|
|
|
394
394
|
top: "0",
|
|
395
395
|
height: "100%",
|
|
396
396
|
align: "center",
|
|
397
|
-
...trailingActionWrapperProps,
|
|
398
397
|
children: /*#__PURE__*/ jsx(Button, {
|
|
399
398
|
ref: trailingActionRef,
|
|
400
399
|
size: "zero",
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { ListItemProps } from './menu.js';
|
|
2
|
-
/**
|
|
3
|
-
* The option format used by react-select based components
|
|
4
|
-
*/
|
|
2
|
+
/** A choice displayed by Scraps Select. */
|
|
5
3
|
export interface SelectValue<T> extends ListItemProps {
|
|
6
4
|
value: T;
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
* will be unable to filter to that label. Use this to specify the plain text of
|
|
10
|
-
* the label.
|
|
6
|
+
* Plain text for searching and for labels that contain React elements.
|
|
11
7
|
*/
|
|
12
8
|
textValue?: string;
|
|
13
9
|
}
|
package/dist/modal/components.js
CHANGED
|
@@ -32,7 +32,7 @@ const ModalFooter = styled((props)=>/*#__PURE__*/ jsx(Flex, {
|
|
|
32
32
|
...props,
|
|
33
33
|
as: "footer",
|
|
34
34
|
justify: "end",
|
|
35
|
-
|
|
35
|
+
borderTopColor: "primary",
|
|
36
36
|
padding: {
|
|
37
37
|
zero: '2xl xl',
|
|
38
38
|
'3xl': '2xl 3xl'
|
|
@@ -75,7 +75,7 @@ const makeClosableHeader = (closeModal)=>{
|
|
|
75
75
|
align: "center",
|
|
76
76
|
gap: "md",
|
|
77
77
|
position: "relative",
|
|
78
|
-
|
|
78
|
+
borderBottomColor: "primary",
|
|
79
79
|
padding: {
|
|
80
80
|
zero: '2xl',
|
|
81
81
|
'3xl': '2xl 3xl'
|
package/dist/overlayArrow.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useTheme } from "@emotion/react";
|
|
3
2
|
import styled from "@emotion/styled";
|
|
3
|
+
import { useResolvedTheme } from "./theme/index.js";
|
|
4
4
|
const sizeRatio = 0.5;
|
|
5
5
|
const heightRatio = 0.3;
|
|
6
6
|
function OverlayArrow({ placement, ref, size = 16, ...props }) {
|
|
7
|
-
const theme =
|
|
7
|
+
const theme = useResolvedTheme();
|
|
8
8
|
const offset = placement?.startsWith('top') ? 3 : 1.5;
|
|
9
9
|
const topOffset = placement?.startsWith('top') ? 3 : 1;
|
|
10
10
|
return /*#__PURE__*/ jsx(OverlayArrowWrap, {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DateTimeInput } from '../dateTime/index.js';
|
|
2
|
+
import { type FormattingSnapshot } from '../dateTime/config.js';
|
|
3
|
+
export type RelaxedDateType = DateTimeInput;
|
|
4
|
+
export interface RelativeTimeOptions {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/** Fuzzy preserves thresholds; English keeps articles, other locales use numeric counts. */
|
|
7
|
+
rounding?: 'fuzzy' | 'unit';
|
|
8
|
+
/** Unit width when rounding is "unit". */
|
|
9
|
+
style?: 'long' | 'short' | 'narrow';
|
|
10
|
+
suffix?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getDateObj(date: RelaxedDateType): Date;
|
|
13
|
+
export declare function formatRelativeDate(date: DateTimeInput, { suffix, prefix, style, rounding }: RelativeTimeOptions, snapshot: Readonly<FormattingSnapshot>): string;
|
|
14
|
+
export declare function getRelativeDate(date: DateTimeInput, options?: RelativeTimeOptions): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { getSnapshot } from "../dateTime/config.js";
|
|
3
|
+
import { getIntlFormatter } from "../dateTime/intlFormatter.js";
|
|
4
|
+
import { parseDate } from "../dateTime/parseDate.js";
|
|
5
|
+
import { getDurationWithMessages } from "../duration/getDuration.js";
|
|
6
|
+
function getDateObj(date) {
|
|
7
|
+
return 'string' == typeof date || 'number' == typeof date ? new Date(date) : date;
|
|
8
|
+
}
|
|
9
|
+
function getFuzzyDuration(value, now) {
|
|
10
|
+
const milliseconds = Math.abs(value.epochMilliseconds - now.epochMilliseconds);
|
|
11
|
+
const seconds = Math.round(milliseconds / 1000);
|
|
12
|
+
if (seconds <= 44) return {
|
|
13
|
+
unit: 'second',
|
|
14
|
+
count: seconds
|
|
15
|
+
};
|
|
16
|
+
for (const { unit, size, limit } of [
|
|
17
|
+
{
|
|
18
|
+
unit: 'minute',
|
|
19
|
+
size: 60000,
|
|
20
|
+
limit: 45
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
unit: 'hour',
|
|
24
|
+
size: 3600000,
|
|
25
|
+
limit: 22
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
unit: 'day',
|
|
29
|
+
size: 86400000,
|
|
30
|
+
limit: 26
|
|
31
|
+
}
|
|
32
|
+
]){
|
|
33
|
+
const count = Math.round(milliseconds / size);
|
|
34
|
+
if (count <= 1) return {
|
|
35
|
+
unit,
|
|
36
|
+
count: 1
|
|
37
|
+
};
|
|
38
|
+
if (count < limit) return {
|
|
39
|
+
unit,
|
|
40
|
+
count
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const earlier = value.epochNanoseconds < now.epochNanoseconds ? value : now;
|
|
44
|
+
const later = earlier === value ? now : value;
|
|
45
|
+
let wholeMonths = (later.year - earlier.year) * 12 + later.month - earlier.month;
|
|
46
|
+
let anchor;
|
|
47
|
+
try {
|
|
48
|
+
anchor = earlier.add({
|
|
49
|
+
months: wholeMonths
|
|
50
|
+
});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (!(error instanceof RangeError)) throw error;
|
|
53
|
+
anchor = earlier.add({
|
|
54
|
+
months: --wholeMonths
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (anchor.epochNanoseconds > later.epochNanoseconds) anchor = earlier.add({
|
|
58
|
+
months: --wholeMonths
|
|
59
|
+
});
|
|
60
|
+
const remainder = later.epochMilliseconds - anchor.epochMilliseconds;
|
|
61
|
+
const months = wholeMonths + remainder / 86400000 * (4800 / 146097);
|
|
62
|
+
const roundedMonths = Math.round(months);
|
|
63
|
+
return roundedMonths < 11 ? {
|
|
64
|
+
unit: 'month',
|
|
65
|
+
count: Math.max(1, roundedMonths)
|
|
66
|
+
} : {
|
|
67
|
+
unit: 'year',
|
|
68
|
+
count: Math.max(1, Math.round(months / 12))
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function englishFuzzyDuration(unit, count) {
|
|
72
|
+
if ('second' === unit) return 'a few seconds';
|
|
73
|
+
if (1 === count) return 'hour' === unit ? 'an hour' : `a ${unit}`;
|
|
74
|
+
return `${count} ${unit}s`;
|
|
75
|
+
}
|
|
76
|
+
function formatRelativeDate(date, { suffix, prefix, style = 'long', rounding = 'fuzzy' }, snapshot) {
|
|
77
|
+
const value = parseDate(date, snapshot.timezone);
|
|
78
|
+
if (!value) return 'Invalid date';
|
|
79
|
+
const now = Temporal.Instant.fromEpochMilliseconds(Date.now()).toZonedDateTimeISO(snapshot.timezone);
|
|
80
|
+
const isFuture = value.epochNanoseconds > now.epochNanoseconds;
|
|
81
|
+
let duration;
|
|
82
|
+
if ('fuzzy' === rounding) {
|
|
83
|
+
const { unit, count } = getFuzzyDuration(value, now);
|
|
84
|
+
const isEnglish = 'en' === snapshot.locale.toLowerCase().split('-')[0];
|
|
85
|
+
if (!isEnglish && (isFuture ? prefix : suffix) === void 0) return getIntlFormatter(Intl.RelativeTimeFormat, snapshot.locale, {
|
|
86
|
+
numeric: 'always'
|
|
87
|
+
}).format(isFuture ? count : -count, unit);
|
|
88
|
+
duration = isEnglish ? englishFuzzyDuration(unit, count) : getIntlFormatter(Intl.NumberFormat, snapshot.locale, {
|
|
89
|
+
style: 'unit',
|
|
90
|
+
unit,
|
|
91
|
+
unitDisplay: 'long'
|
|
92
|
+
}).format(count);
|
|
93
|
+
} else duration = getDurationWithMessages(Math.trunc((now.epochMilliseconds - value.epochMilliseconds) / 1000), {
|
|
94
|
+
style,
|
|
95
|
+
absolute: isFuture
|
|
96
|
+
}, snapshot.messages);
|
|
97
|
+
if (isFuture) {
|
|
98
|
+
if (void 0 === prefix) return `${snapshot.messages.t('in')} ${duration}`;
|
|
99
|
+
return prefix ? `${prefix} ${duration}` : duration;
|
|
100
|
+
}
|
|
101
|
+
if (void 0 === suffix) return snapshot.messages.t('%s ago', duration);
|
|
102
|
+
return suffix ? `${duration} ${suffix}` : duration;
|
|
103
|
+
}
|
|
104
|
+
function getRelativeDate(date, options = {}) {
|
|
105
|
+
return formatRelativeDate(date, options, getSnapshot());
|
|
106
|
+
}
|
|
107
|
+
export { formatRelativeDate, getDateObj, getRelativeDate };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { RelativeTime, RELATIVE_TIME_MAX_WIDTH, type RelativeTimeProps, } from './relativeTime.js';
|
|
2
|
+
export { getDateObj, getRelativeDate, type RelaxedDateType, type RelativeTimeOptions, } from './getRelativeDate.js';
|
|
3
|
+
export { useRelativeTimeFormatter } from './useRelativeTimeFormatter.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type RelaxedDateType, type RelativeTimeOptions } from './getRelativeDate.js';
|
|
3
|
+
/** Allow room for offset labels such as GMT+5:45 without wrapping timestamp rows. */
|
|
4
|
+
export declare const RELATIVE_TIME_MAX_WIDTH = 280;
|
|
5
|
+
export interface RelativeTimeProps extends RelativeTimeOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The date value, can be string, number (e.g. timestamp), or instance of Date
|
|
8
|
+
*/
|
|
9
|
+
date: RelaxedDateType;
|
|
10
|
+
/**
|
|
11
|
+
* What the timestamp refers to, e.g. "Last Seen". Rendered in a header
|
|
12
|
+
* alongside the relative time.
|
|
13
|
+
*
|
|
14
|
+
* Optional because most timestamps in the app are already labelled by what
|
|
15
|
+
* they sit next to. Without one there is no header, and the card is the two
|
|
16
|
+
* timezone rows on their own.
|
|
17
|
+
*/
|
|
18
|
+
label?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Prefix before upcoming time (when the date is in the future)
|
|
21
|
+
*
|
|
22
|
+
* @default "in"
|
|
23
|
+
*/
|
|
24
|
+
prefix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Show seconds on the absolute times. For timestamps precise enough that the
|
|
27
|
+
* minute alone does not identify them, e.g. spans in a trace.
|
|
28
|
+
*/
|
|
29
|
+
showSeconds?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Suffix after elapsed time e.g. "ago" in "5 minutes ago"
|
|
32
|
+
*
|
|
33
|
+
* @default "ago"
|
|
34
|
+
*/
|
|
35
|
+
suffix?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A detail card for a single timestamp, showing the relative time alongside the
|
|
39
|
+
* absolute time in both the viewer's timezone and UTC.
|
|
40
|
+
*
|
|
41
|
+
* This is tooltip content rather than a standalone element. `TimeSince` renders
|
|
42
|
+
* it for you; reach for it directly only when you are building the tooltip
|
|
43
|
+
* yourself. The overlay drops its own padding on seeing the sections this
|
|
44
|
+
* composes, so there is nothing to pass but the card's width:
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Tooltip
|
|
48
|
+
* maxWidth={RELATIVE_TIME_MAX_WIDTH}
|
|
49
|
+
* title={<RelativeTime date={date} label={t('Last Seen')} />}
|
|
50
|
+
* >
|
|
51
|
+
* {trigger}
|
|
52
|
+
* </Tooltip>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function RelativeTime({ date, label, prefix, suffix, rounding, style, showSeconds, }: RelativeTimeProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { Tag } from "../badge/index.js";
|
|
5
|
+
import { DateTime } from "../dateTime/index.js";
|
|
6
|
+
import { DescriptionList } from "../descriptionList/index.js";
|
|
7
|
+
import { Text } from "../text/index.js";
|
|
8
|
+
import { Tooltip } from "../tooltip/index.js";
|
|
9
|
+
import { useFormattingSnapshot } from "../dateTime/context.js";
|
|
10
|
+
import { formatTimezone } from "../dateTime/format.js";
|
|
11
|
+
import { parseDate } from "../dateTime/parseDate.js";
|
|
12
|
+
import { formatRelativeDate } from "./getRelativeDate.js";
|
|
13
|
+
const RELATIVE_TIME_MAX_WIDTH = 280;
|
|
14
|
+
const UTC = 'UTC';
|
|
15
|
+
function RelativeTime({ date, label, prefix, suffix, rounding, style, showSeconds }) {
|
|
16
|
+
const snapshot = useFormattingSnapshot();
|
|
17
|
+
const value = parseDate(date, snapshot.timezone);
|
|
18
|
+
const abbreviation = value ? formatTimezone(value.epochMilliseconds, snapshot.timezone, snapshot) : 'Invalid date';
|
|
19
|
+
const isViewerUtc = abbreviation === UTC;
|
|
20
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
21
|
+
children: [
|
|
22
|
+
null != label && /*#__PURE__*/ jsx(Tooltip.Header, {
|
|
23
|
+
trailingItems: formatRelativeDate(date, {
|
|
24
|
+
suffix,
|
|
25
|
+
prefix,
|
|
26
|
+
rounding,
|
|
27
|
+
style
|
|
28
|
+
}, snapshot),
|
|
29
|
+
children: label
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx(Tooltip.Grid, {
|
|
32
|
+
children: /*#__PURE__*/ jsxs(DescriptionList, {
|
|
33
|
+
columns: "max-content 1fr max-content",
|
|
34
|
+
gap: "2xs sm",
|
|
35
|
+
align: "center",
|
|
36
|
+
children: [
|
|
37
|
+
!isViewerUtc && /*#__PURE__*/ jsx(TimestampRow, {
|
|
38
|
+
date: date,
|
|
39
|
+
abbreviation: abbreviation,
|
|
40
|
+
variant: "info",
|
|
41
|
+
showSeconds: showSeconds
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ jsx(TimestampRow, {
|
|
44
|
+
date: date,
|
|
45
|
+
abbreviation: UTC,
|
|
46
|
+
variant: "muted",
|
|
47
|
+
showSeconds: showSeconds,
|
|
48
|
+
utc: true
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function TimestampRow({ date, abbreviation, variant, showSeconds, utc }) {
|
|
57
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ jsx(DescriptionList.Term, {
|
|
60
|
+
children: /*#__PURE__*/ jsx(TimezoneTag, {
|
|
61
|
+
variant: variant,
|
|
62
|
+
children: abbreviation
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx(DescriptionList.Details, {
|
|
66
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
67
|
+
tabular: true,
|
|
68
|
+
wrap: "nowrap",
|
|
69
|
+
children: /*#__PURE__*/ jsx(DateTime, {
|
|
70
|
+
date: date,
|
|
71
|
+
mode: "date",
|
|
72
|
+
year: "always",
|
|
73
|
+
timezone: utc ? 'UTC' : void 0,
|
|
74
|
+
showTimezone: false
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ jsx(DescriptionList.Details, {
|
|
79
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
80
|
+
align: "right",
|
|
81
|
+
tabular: true,
|
|
82
|
+
wrap: "nowrap",
|
|
83
|
+
children: /*#__PURE__*/ jsx(DateTime, {
|
|
84
|
+
date: date,
|
|
85
|
+
mode: "time",
|
|
86
|
+
precision: showSeconds ? 'second' : 'minute',
|
|
87
|
+
timezone: utc ? 'UTC' : void 0,
|
|
88
|
+
showTimezone: false
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const TimezoneTag = styled(Tag)`
|
|
96
|
+
height: 17px;
|
|
97
|
+
min-width: 20px;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
100
|
+
border-radius: ${(p)=>p.theme.radius['2xs']};
|
|
101
|
+
`;
|
|
102
|
+
export { RELATIVE_TIME_MAX_WIDTH, RelativeTime };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useFormattingSnapshot } from "../dateTime/context.js";
|
|
3
|
+
import { formatRelativeDate } from "./getRelativeDate.js";
|
|
4
|
+
function useRelativeTimeFormatter() {
|
|
5
|
+
const snapshot = useFormattingSnapshot();
|
|
6
|
+
return useCallback((date, options = {})=>formatRelativeDate(date, options, snapshot), [
|
|
7
|
+
snapshot
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
export { useRelativeTimeFormatter };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { getSelectStyles } from './styles.js';
|
|
2
|
+
import type { SelectComponents, SelectValue, StylesConfig } from './types.js';
|
|
3
|
+
export declare function SelectChips<TValue, TOption extends SelectValue<TValue>>({ disabled, focusedChip, MultiValueLabel, onRemove, selectedRows, selectStyles, styles, }: {
|
|
4
|
+
focusedChip: number | null;
|
|
5
|
+
onRemove: (index: number) => void;
|
|
6
|
+
selectStyles: Pick<ReturnType<typeof getSelectStyles>, 'chip' | 'chipLabel' | 'chipRemove' | 'chipRemoveIcon'>;
|
|
7
|
+
selectedRows: ReadonlyArray<{
|
|
8
|
+
option: TOption;
|
|
9
|
+
key?: string;
|
|
10
|
+
}>;
|
|
11
|
+
MultiValueLabel?: SelectComponents<TOption>['MultiValueLabel'];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
styles?: StylesConfig<TValue, TOption>;
|
|
14
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import { IconClose } from "@sentry/icons/close";
|
|
4
|
+
import { useTranslation } from "../translation/index.js";
|
|
5
|
+
import { applyStyleSlot } from "./types.js";
|
|
6
|
+
function SelectChips({ disabled, focusedChip, MultiValueLabel, onRemove, selectedRows, selectStyles, styles }) {
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
return selectedRows.map(({ option, key }, index)=>{
|
|
10
|
+
const optionStyle = {
|
|
11
|
+
data: option,
|
|
12
|
+
isDisabled: Boolean(disabled || option.disabled),
|
|
13
|
+
isSelected: true
|
|
14
|
+
};
|
|
15
|
+
const focusRing = index === focusedChip ? theme.focusRing() : void 0;
|
|
16
|
+
const chipStyle = {
|
|
17
|
+
...selectStyles.chip,
|
|
18
|
+
...focusRing
|
|
19
|
+
};
|
|
20
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
21
|
+
css: applyStyleSlot(styles, 'multiValue', chipStyle, optionStyle),
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx("span", {
|
|
24
|
+
css: applyStyleSlot(styles, 'multiValueLabel', selectStyles.chipLabel, optionStyle),
|
|
25
|
+
children: MultiValueLabel ? /*#__PURE__*/ jsx(MultiValueLabel, {
|
|
26
|
+
option: option,
|
|
27
|
+
children: option.label
|
|
28
|
+
}) : option.label
|
|
29
|
+
}),
|
|
30
|
+
!disabled && /*#__PURE__*/ jsx("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
tabIndex: -1,
|
|
33
|
+
"aria-label": t('Remove item'),
|
|
34
|
+
css: applyStyleSlot(styles, 'multiValueRemove', selectStyles.chipRemove, optionStyle),
|
|
35
|
+
onMouseDown: (event)=>event.preventDefault(),
|
|
36
|
+
onClick: ()=>onRemove(index),
|
|
37
|
+
children: /*#__PURE__*/ jsx(IconClose, {
|
|
38
|
+
css: selectStyles.chipRemoveIcon
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}, key ?? index);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export { SelectChips };
|
package/dist/select/filter.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
data: option,
|
|
8
|
-
label: 'string' == typeof option.label ? option.label : '',
|
|
9
|
-
value: String(option.value)
|
|
10
|
-
}, input);
|
|
1
|
+
import { getSearchScore } from "../fzf.js";
|
|
2
|
+
function createFilter(config) {
|
|
3
|
+
return (option, input)=>{
|
|
4
|
+
const text = config?.stringify(option) ?? option.textValue ?? `${'string' == typeof option.label || 'number' == typeof option.label ? option.label : ''} ${option.value}`;
|
|
5
|
+
return getSearchScore(text, input.trim()) > 0;
|
|
6
|
+
};
|
|
11
7
|
}
|
|
12
|
-
export {
|
|
8
|
+
export { createFilter };
|
package/dist/select/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Select, type ControlProps, type BaseSelectProps } from './select.js';
|
|
1
|
+
export { Select, type ControlProps, type BaseSelectProps, type CreatableControlProps, } from './select.js';
|
|
2
2
|
export { createFilter } from './filter.js';
|
|
3
3
|
export type { SelectComponents, SelectHandle, SelectSelectionProps, SelectValue, StylesConfig, } from './types.js';
|