@sentry/scraps 0.6.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.
Files changed (88) hide show
  1. package/README.md +27 -0
  2. package/dist/alert/alert.js +10 -7
  3. package/dist/compactSelect/compactSelect.d.ts +2 -2
  4. package/dist/compactSelect/compactSelect.js +37 -23
  5. package/dist/compactSelect/control.js +12 -9
  6. package/dist/compactSelect/gridList/index.js +35 -36
  7. package/dist/compactSelect/gridList/option.d.ts +4 -1
  8. package/dist/compactSelect/gridList/option.js +4 -3
  9. package/dist/compactSelect/gridList/section.d.ts +10 -3
  10. package/dist/compactSelect/gridList/section.js +16 -33
  11. package/dist/compactSelect/listBox/index.d.ts +1 -1
  12. package/dist/compactSelect/listBox/index.js +46 -58
  13. package/dist/compactSelect/listBox/section.d.ts +10 -8
  14. package/dist/compactSelect/listBox/section.js +11 -30
  15. package/dist/compactSelect/styles.d.ts +6 -7
  16. package/dist/compactSelect/styles.js +1 -23
  17. package/dist/diagnostics/context.d.ts +12 -0
  18. package/dist/diagnostics/context.js +11 -0
  19. package/dist/diagnostics/index.d.ts +2 -0
  20. package/dist/diagnostics/index.js +1 -0
  21. package/dist/disclosure/disclosure.js +1 -1
  22. package/dist/dragHandle/dragHandle.js +3 -5
  23. package/dist/dropdownMenu/context.d.ts +10 -0
  24. package/dist/dropdownMenu/context.js +2 -1
  25. package/dist/dropdownMenu/item.d.ts +2 -7
  26. package/dist/dropdownMenu/item.js +13 -7
  27. package/dist/dropdownMenu/list.js +25 -23
  28. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
  29. package/dist/form/field/radioGroupField.d.ts +7 -0
  30. package/dist/form/field/radioGroupField.js +14 -0
  31. package/dist/form/field/selectField.d.ts +3 -4
  32. package/dist/form/field/selectField.js +16 -24
  33. package/dist/layout/container.d.ts +18 -7
  34. package/dist/layout/container.js +8 -11
  35. package/dist/layout/flex.js +1 -1
  36. package/dist/layout/grid.js +2 -2
  37. package/dist/layout/index.d.ts +1 -1
  38. package/dist/layout/index.js +1 -1
  39. package/dist/layout/stack.js +1 -1
  40. package/dist/layout/styles.d.ts +28 -8
  41. package/dist/layout/styles.js +67 -13
  42. package/dist/layout/surface.d.ts +2 -2
  43. package/dist/layout/surface.js +6 -3
  44. package/dist/menu/menu.js +4 -4
  45. package/dist/menu/selectValue.d.ts +2 -6
  46. package/dist/modal/components.js +2 -2
  47. package/dist/overlayArrow.js +2 -2
  48. package/dist/select/chips.d.ts +14 -0
  49. package/dist/select/chips.js +45 -0
  50. package/dist/select/filter.js +7 -11
  51. package/dist/select/index.d.ts +1 -1
  52. package/dist/select/indicators.d.ts +11 -0
  53. package/dist/select/indicators.js +61 -0
  54. package/dist/select/menu.d.ts +44 -0
  55. package/dist/select/menu.js +103 -0
  56. package/dist/select/option.d.ts +23 -15
  57. package/dist/select/option.js +66 -58
  58. package/dist/select/options.d.ts +31 -0
  59. package/dist/select/options.js +74 -0
  60. package/dist/select/select.d.ts +24 -11
  61. package/dist/select/select.js +527 -429
  62. package/dist/select/styles.d.ts +148 -2
  63. package/dist/select/styles.js +156 -1
  64. package/dist/select/types.d.ts +6 -7
  65. package/dist/select/types.js +4 -0
  66. package/dist/select/utils.d.ts +2 -0
  67. package/dist/select/utils.js +4 -0
  68. package/dist/separator/separator.d.ts +2 -2
  69. package/dist/separator/separator.js +4 -3
  70. package/dist/slot/slot.js +16 -12
  71. package/dist/tabs/tab.js +3 -1
  72. package/dist/theme/index.d.ts +2 -0
  73. package/dist/theme/index.js +2 -0
  74. package/dist/theme/types.d.ts +1 -0
  75. package/dist/theme/useResolvedTheme.d.ts +12 -0
  76. package/dist/theme/useResolvedTheme.js +20 -0
  77. package/dist/theme/variables.css +1116 -0
  78. package/dist/theme/variables.d.ts +985 -0
  79. package/dist/theme/variables.js +455 -0
  80. package/dist/useVirtualCollection.d.ts +14 -1
  81. package/dist/useVirtualCollection.js +59 -3
  82. package/package.json +12 -6
  83. package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
  84. package/dist/compactSelect/useVirtualizedItems.js +0 -74
  85. package/dist/select/reactSelectWrapper.d.ts +0 -8
  86. package/dist/select/reactSelectWrapper.js +0 -25
  87. package/dist/select/virtualizedMenuList.d.ts +0 -24
  88. package/dist/select/virtualizedMenuList.js +0 -123
@@ -1,23 +1,12 @@
1
1
  import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
- import { useRef } from "react";
2
+ import { Fragment, useRef } from "react";
3
3
  import { useAutoSaveContext } from "../autoSaveContext.js";
4
- import { Container, Flex } from "../../layout/index.js";
4
+ import { Container } from "../../layout/index.js";
5
5
  import { Select } from "../../select/index.js";
6
- import { BaseField, useAutoSaveIndicator } from "./baseField.js";
7
- function SelectIndicatorsContainer({ children }) {
8
- const indicator = useAutoSaveIndicator();
9
- return /*#__PURE__*/ jsxs(Flex, {
10
- padding: "0 sm",
11
- gap: "sm",
12
- align: "center",
13
- children: [
14
- indicator,
15
- children
16
- ]
17
- });
18
- }
19
- function SelectField({ onChange, disabled, multiple, clearable, value, ref, ...props }) {
6
+ import { BaseField } from "./baseField.js";
7
+ function SelectField({ onChange, disabled, multiple, clearable, trailingItems, value, ref, ...props }) {
20
8
  const autoSaveContext = useAutoSaveContext();
9
+ const changeValue = onChange;
21
10
  const selectVariantProps = multiple ? {
22
11
  multiple: true,
23
12
  clearable,
@@ -32,20 +21,23 @@ function SelectField({ onChange, disabled, multiple, clearable, value, ref, ...p
32
21
  return /*#__PURE__*/ jsx(BaseField, {
33
22
  disabled: disabled,
34
23
  ref: ref,
35
- children: ({ id, ref: fieldRef, ...fieldProps })=>/*#__PURE__*/ jsx(Container, {
24
+ children: ({ id, ref: fieldRef, ...fieldProps }, { indicator })=>/*#__PURE__*/ jsx(Container, {
36
25
  flex: 1,
37
26
  minWidth: 0,
38
27
  children: /*#__PURE__*/ jsx(Select, {
39
28
  ...fieldProps,
40
29
  ...props,
41
30
  ...selectVariantProps,
31
+ creatable: props.creatable,
42
32
  id: id,
43
33
  inputRef: fieldRef,
44
34
  blurInputOnSelect: false,
45
- components: {
46
- ...props.components,
47
- Indicators: SelectIndicatorsContainer
48
- },
35
+ trailingItems: /*#__PURE__*/ jsxs(Fragment, {
36
+ children: [
37
+ indicator,
38
+ trailingItems
39
+ ]
40
+ }),
49
41
  onOpenChange: (isOpen)=>{
50
42
  isMenuOpenRef.current = isOpen;
51
43
  props.onOpenChange?.(isOpen);
@@ -53,15 +45,15 @@ function SelectField({ onChange, disabled, multiple, clearable, value, ref, ...p
53
45
  },
54
46
  onChange: (option)=>{
55
47
  if (multiple) {
56
- onChange(Array.isArray(option) ? option.map((o)=>o.value) : []);
48
+ changeValue(Array.isArray(option) ? option.map((o)=>o.value) : []);
57
49
  if (autoSaveContext && !isMenuOpenRef.current) fieldProps.onBlur();
58
50
  } else {
59
51
  if (!option) {
60
- onChange(null);
52
+ changeValue(null);
61
53
  if (autoSaveContext) fieldProps.onBlur();
62
54
  return;
63
55
  }
64
- onChange(option.value);
56
+ if (!Array.isArray(option)) changeValue(option.value);
65
57
  fieldProps.onBlur();
66
58
  }
67
59
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { CSS } from '../cssTypes.js';
3
- import type { BackgroundToken, BorderVariant, RadiusSize, SpaceSize } from '../theme/index.js';
3
+ import type { BackgroundToken, BorderVariant, BorderWidthToken, RadiusSize, SpaceSize } from '../theme/index.js';
4
4
  import { type Responsive, type Shorthand } from './styles.js';
5
5
  type Margin = SpaceSize | 'auto' | '0';
6
6
  interface ContainerLayoutProps {
@@ -49,13 +49,24 @@ interface ContainerLayoutProps {
49
49
  minHeight?: Responsive<CSS['minHeight']>;
50
50
  maxHeight?: Responsive<CSS['maxHeight']>;
51
51
  /**
52
- * Border color on all sides. Renders a 1px solid border.
52
+ * Draws a solid border on all sides in this color, as a path into
53
+ * `tokens.border`. The width defaults to 1px; set `borderWidth` to change it.
54
+ * `none` removes the border.
53
55
  */
54
- border?: Responsive<BorderVariant>;
55
- borderTop?: Responsive<BorderVariant>;
56
- borderBottom?: Responsive<BorderVariant>;
57
- borderLeft?: Responsive<BorderVariant>;
58
- borderRight?: Responsive<BorderVariant>;
56
+ borderColor?: Responsive<BorderVariant>;
57
+ /**
58
+ * Draws a solid border on one side in this color. Its width comes from
59
+ * `borderWidth`, 1px by default. `none` removes that side.
60
+ */
61
+ borderTopColor?: Responsive<BorderVariant>;
62
+ borderBottomColor?: Responsive<BorderVariant>;
63
+ borderLeftColor?: Responsive<BorderVariant>;
64
+ borderRightColor?: Responsive<BorderVariant>;
65
+ /**
66
+ * Width of the drawn border sides, as a key of `theme.border`. Set alone, it
67
+ * draws a border on all sides in the `primary` color.
68
+ */
69
+ borderWidth?: Responsive<BorderWidthToken>;
59
70
  area?: Responsive<CSS['gridArea']>;
60
71
  row?: Responsive<CSS['gridRow']>;
61
72
  column?: Responsive<CSS['gridColumn']>;
@@ -3,17 +3,18 @@ import { useMemo, useRef } from "react";
3
3
  import is_prop_valid from "@emotion/is-prop-valid";
4
4
  import styled from "@emotion/styled";
5
5
  import { mergeRefs } from "@react-aria/utils";
6
- import { ContainerQueryProvider, getBackground, getBorder, getMargin, getRadius, getSpacing, rc } from "./styles.js";
6
+ import { ContainerQueryProvider, getBackground, getBorderStyles, getMargin, getRadius, getSpacing, rc } from "./styles.js";
7
7
  const omitContainerProps = new Set([
8
8
  'alignSelf',
9
9
  'area',
10
10
  'as',
11
11
  'background',
12
- 'border',
13
- 'borderTop',
14
- 'borderBottom',
15
- 'borderLeft',
16
- 'borderRight',
12
+ 'borderColor',
13
+ 'borderTopColor',
14
+ 'borderBottomColor',
15
+ 'borderLeftColor',
16
+ 'borderRightColor',
17
+ 'borderWidth',
17
18
  'bottom',
18
19
  'column',
19
20
  'contain',
@@ -143,11 +144,7 @@ const Container = styled((props)=>{
143
144
  ${(p)=>rc('align-self', p.alignSelf, p.theme)};
144
145
  ${(p)=>rc('justify-self', p.justifySelf, p.theme)};
145
146
 
146
- ${(p)=>rc('border', p.border, p.theme, getBorder)};
147
- ${(p)=>rc('border-top', p.borderTop, p.theme, getBorder)};
148
- ${(p)=>rc('border-bottom', p.borderBottom, p.theme, getBorder)};
149
- ${(p)=>rc('border-left', p.borderLeft, p.theme, getBorder)};
150
- ${(p)=>rc('border-right', p.borderRight, p.theme, getBorder)};
147
+ ${(p)=>getBorderStyles(p, p.theme)};
151
148
 
152
149
  ${(p)=>rc('visibility', p.visibility, p.theme)};
153
150
  ${(p)=>rc('white-space', p.whiteSpace, p.theme)};
@@ -23,7 +23,7 @@ const Flex = styled(Container, {
23
23
  ${(p)=>rc('flex', p.flex, p.theme)};
24
24
  ${(p)=>rc('justify-content', p.justify, p.theme, (value)=>void 0 === value ? void 0 : FLEX_JUSTIFY_CONTENT[value])};
25
25
 
26
- ${(p)=>rc('align-items', p.align, p.theme, (value, _breakpoint, _theme)=>{
26
+ ${(p)=>rc('align-items', p.align, p.theme, (value)=>{
27
27
  switch(value){
28
28
  case 'start':
29
29
  return 'flex-start';
@@ -30,7 +30,7 @@ const Grid = styled(Container, {
30
30
  ${(p)=>rc('grid-auto-rows', p.autoRows, p.theme)};
31
31
  ${(p)=>rc('grid-auto-flow', p.flow, p.theme)};
32
32
 
33
- ${(p)=>rc('justify-content', p.justify, p.theme, (value, _breakpoint, _theme)=>{
33
+ ${(p)=>rc('justify-content', p.justify, p.theme, (value)=>{
34
34
  switch(value){
35
35
  case 'start':
36
36
  return 'start';
@@ -51,7 +51,7 @@ const Grid = styled(Container, {
51
51
  }
52
52
  })};
53
53
 
54
- ${(p)=>rc('align-content', p.alignContent, p.theme, (value, _breakpoint, _theme)=>{
54
+ ${(p)=>rc('align-content', p.alignContent, p.theme, (value)=>{
55
55
  switch(value){
56
56
  case 'start':
57
57
  return 'start';
@@ -9,5 +9,5 @@ export { Stack, type StackProps } from './stack.js';
9
9
  export { ContainerQueryContext, ContainerQueryProvider, type Responsive, type ResponsiveKey,
10
10
  /** @public */
11
11
  useContainerBreakpoint, useHasContainerQuery, useResponsivePropValue, } from './styles.js';
12
- export { getBorder, getMargin, getRadius, getSpacing } from './styles.js';
12
+ export { getMargin, getRadius, getSpacing } from './styles.js';
13
13
  export { FLEX_JUSTIFY_CONTENT, type FlexJustify } from './styles.js';
@@ -3,4 +3,4 @@ export { Surface } from "./surface.js";
3
3
  export { Flex } from "./flex.js";
4
4
  export { Grid } from "./grid.js";
5
5
  export { Stack } from "./stack.js";
6
- export { ContainerQueryContext, ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getBorder, getMargin, getRadius, getSpacing, useContainerBreakpoint, useHasContainerQuery, useResponsivePropValue } from "./styles.js";
6
+ export { ContainerQueryContext, ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getMargin, getRadius, getSpacing, useContainerBreakpoint, useHasContainerQuery, useResponsivePropValue } from "./styles.js";
@@ -46,7 +46,7 @@ const StackSeparator = styled((props)=>{
46
46
  return /*#__PURE__*/ jsx(Separator, {
47
47
  ...props,
48
48
  orientation: 'horizontal' === orientation ? 'vertical' : 'horizontal',
49
- border: props.border ?? 'primary'
49
+ borderColor: props.borderColor ?? 'primary'
50
50
  });
51
51
  })``;
52
52
  const Stack = Object.assign(StackComponent, {
@@ -1,7 +1,6 @@
1
1
  import type { ReactNode, RefObject } from 'react';
2
- import type { BackgroundToken, BorderVariant, BreakpointSize, ContainerBreakpointSize, RadiusSize, SpaceSize, Theme } from '../theme/index.js';
3
- type ResponsiveBreakpoint = BreakpointSize | ContainerBreakpointSize;
4
- export declare function rc<T>(property: string, value: Responsive<T> | undefined, theme: Theme, resolver?: (value: T | undefined, breakpoint: ResponsiveBreakpoint | undefined, theme: Theme) => string | undefined): string | undefined;
2
+ import type { BackgroundToken, BorderVariant, BorderWidthToken, BreakpointSize, ContainerBreakpointSize, RadiusSize, SpaceSize, Theme } from '../theme/index.js';
3
+ export declare function rc<T>(property: string, value: Responsive<T> | undefined, theme: Theme, resolver?: (value: T | undefined, theme: Theme) => string | undefined): string | undefined;
5
4
  type Margin = SpaceSize | 'auto' | '0';
6
5
  /**
7
6
  * The `justify` vocabulary a flex container accepts, and its mapping onto CSS
@@ -38,11 +37,32 @@ export type Shorthand<T extends string, N extends 4 | 2> = N extends 4 ? `${T} $
38
37
  type ScreenBreakpoint = `screen:${BreakpointSize}`;
39
38
  export type ResponsiveKey = ContainerBreakpointSize | ScreenBreakpoint;
40
39
  export type Responsive<T> = T | Partial<Record<ResponsiveKey, T>>;
41
- export declare function getBackground(background: BackgroundToken | undefined, _breakpoint: ResponsiveBreakpoint | undefined, theme: Theme): string | undefined;
42
- export declare function getBorder(border: BorderVariant | undefined, _breakpoint: ResponsiveBreakpoint | undefined, theme: Theme): string | undefined;
43
- export declare function getRadius(radius: Shorthand<RadiusSize, 4> | undefined, _breakpoint: ResponsiveBreakpoint | undefined, theme: Theme): string | undefined;
44
- export declare function getSpacing(spacing: Shorthand<SpaceSize, 4> | undefined, _breakpoint: ResponsiveBreakpoint | undefined, theme: Theme): string | undefined;
45
- export declare function getMargin(margin: Shorthand<Margin, 4> | undefined, _breakpoint: ResponsiveBreakpoint | undefined, theme: Theme): string | undefined;
40
+ export declare function getBackground(background: BackgroundToken | undefined, theme: Theme): string | undefined;
41
+ export declare function getBorderWidth(borderWidth: BorderWidthToken | undefined, theme: Theme): string | undefined;
42
+ interface BorderProps {
43
+ borderBottomColor?: Responsive<BorderVariant>;
44
+ borderColor?: Responsive<BorderVariant>;
45
+ borderLeftColor?: Responsive<BorderVariant>;
46
+ borderRightColor?: Responsive<BorderVariant>;
47
+ borderTopColor?: Responsive<BorderVariant>;
48
+ borderWidth?: Responsive<BorderWidthToken>;
49
+ }
50
+ /**
51
+ * Sets the style and color of one border edge (or of all edges, for `border`).
52
+ * `rc` makes the first defined breakpoint the base, so the edge is drawn at
53
+ * every width.
54
+ */
55
+ export declare function getBorderEdge(property: string, value: Responsive<BorderVariant>, theme: Theme): string;
56
+ /**
57
+ * Resolves the border props into CSS. `borderColor` draws all sides, a side
58
+ * color draws one side, and `borderWidth` sets the width of the drawn sides.
59
+ * The width defaults to 1px, and `borderWidth` alone draws all sides in the
60
+ * `primary` color.
61
+ */
62
+ export declare function getBorderStyles(props: BorderProps, theme: Theme): string | undefined;
63
+ export declare function getRadius(radius: Shorthand<RadiusSize, 4> | undefined, theme: Theme): string | undefined;
64
+ export declare function getSpacing(spacing: Shorthand<SpaceSize, 4> | undefined, theme: Theme): string | undefined;
65
+ export declare function getMargin(margin: Shorthand<Margin, 4> | undefined, theme: Theme): string | undefined;
46
66
  /**
47
67
  * Resolves a `Responsive<T>` prop to its current value in JS, across both the
48
68
  * container and viewport axes — the JS mirror of what `rc()` emits as CSS.
@@ -3,15 +3,15 @@ import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useSt
3
3
  import { useTheme } from "@emotion/react";
4
4
  function rc(property, value, theme, resolver) {
5
5
  if (!isResponsive(value)) {
6
- const resolvedValue = resolver ? resolver(value, void 0, theme) : value;
6
+ const resolvedValue = resolver ? resolver(value, theme) : value;
7
7
  if (void 0 === resolvedValue) return;
8
8
  return `${property}: ${resolvedValue};`;
9
9
  }
10
10
  let first = true;
11
11
  const declarations = [];
12
- const emit = (propKey, breakpoint, atRule, size)=>{
12
+ const emit = (propKey, atRule, size)=>{
13
13
  const v = value[propKey];
14
- const resolvedValue = resolver ? resolver(v, breakpoint, theme) : v;
14
+ const resolvedValue = resolver ? resolver(v, theme) : v;
15
15
  if (void 0 === resolvedValue) return;
16
16
  if (first) {
17
17
  first = false;
@@ -22,8 +22,8 @@ function rc(property, value, theme, resolver) {
22
22
  ${property}: ${resolvedValue};
23
23
  }`);
24
24
  };
25
- for (const breakpoint of CONTAINER_ORDER)emit(breakpoint, breakpoint, '@container', theme.container[breakpoint]);
26
- for (const { key, token } of VIEWPORT_ORDER)emit(key, token, '@media', theme.breakpoints[token]);
25
+ for (const breakpoint of CONTAINER_ORDER)emit(breakpoint, '@container', theme.container[breakpoint]);
26
+ for (const { key, token } of VIEWPORT_ORDER)emit(key, '@media', theme.breakpoints[token]);
27
27
  return declarations.join('');
28
28
  }
29
29
  const CONTAINER_ORDER = [
@@ -95,7 +95,7 @@ function resolveMargin(sizeComponent, theme) {
95
95
  if ('0' === sizeComponent) return '0';
96
96
  return theme.space[sizeComponent] ?? theme.space['0'];
97
97
  }
98
- function getBackground(background, _breakpoint, theme) {
98
+ function getBackground(background, theme) {
99
99
  if (void 0 === background) return;
100
100
  let node = theme.tokens.background;
101
101
  for (const segment of background.split('.'))node = node[segment];
@@ -106,22 +106,76 @@ function borderValue(path, theme) {
106
106
  for (const segment of path.split('.'))node = node[segment];
107
107
  return node;
108
108
  }
109
- function getBorder(border, _breakpoint, theme) {
109
+ function getBorderWidth(borderWidth, theme) {
110
+ if (void 0 === borderWidth) return;
111
+ return theme.border[borderWidth];
112
+ }
113
+ function getBorderStyle(border) {
114
+ if (void 0 === border) return;
115
+ return 'none' === border ? 'none' : 'solid';
116
+ }
117
+ function getBorderColor(border, theme) {
110
118
  if (void 0 === border) return;
111
- if ('none' === border) return 'none';
112
- return border.split(' ').map((b)=>`1px solid ${borderValue(b, theme)}`).join(' ');
119
+ return borderValue('none' === border ? 'primary' : border, theme);
120
+ }
121
+ const BORDER_SIDES = [
122
+ [
123
+ 'top',
124
+ 'borderTopColor'
125
+ ],
126
+ [
127
+ 'bottom',
128
+ 'borderBottomColor'
129
+ ],
130
+ [
131
+ 'left',
132
+ 'borderLeftColor'
133
+ ],
134
+ [
135
+ 'right',
136
+ 'borderRightColor'
137
+ ]
138
+ ];
139
+ function hasValue(value) {
140
+ if (isResponsive(value)) return Object.values(value).some((v)=>void 0 !== v);
141
+ return void 0 !== value;
142
+ }
143
+ function getBorderEdge(property, value, theme) {
144
+ return [
145
+ rc(`${property}-style`, value, theme, getBorderStyle),
146
+ rc(`${property}-color`, value, theme, getBorderColor)
147
+ ].join('');
148
+ }
149
+ function getBorderStyles(props, theme) {
150
+ const sides = BORDER_SIDES.flatMap(([side, prop])=>{
151
+ const value = props[prop];
152
+ return hasValue(value) ? [
153
+ [
154
+ side,
155
+ value
156
+ ]
157
+ ] : [];
158
+ });
159
+ const allSides = hasValue(props.borderColor) ? props.borderColor : hasValue(props.borderWidth) && 0 === sides.length ? 'primary' : void 0;
160
+ if (void 0 === allSides && 0 === sides.length) return;
161
+ return [
162
+ void 0 === allSides ? void 0 : getBorderEdge('border', allSides, theme),
163
+ 0 === sides.length ? void 0 : `&{${sides.map(([side, value])=>getBorderEdge(`border-${side}`, value, theme)).join('')}}`,
164
+ `border-width: ${theme.border.md};`,
165
+ rc('border-width', props.borderWidth, theme, getBorderWidth)
166
+ ].filter(Boolean).join('');
113
167
  }
114
- function getRadius(radius, _breakpoint, theme) {
168
+ function getRadius(radius, theme) {
115
169
  if (void 0 === radius) return;
116
170
  if (radius.length < 3) return resolveRadius(radius, theme);
117
171
  return radius.split(' ').map((size)=>resolveRadius(size, theme)).join(' ');
118
172
  }
119
- function getSpacing(spacing, _breakpoint, theme) {
173
+ function getSpacing(spacing, theme) {
120
174
  if (void 0 === spacing) return;
121
175
  if (spacing.length < 3) return resolveSpacing(spacing, theme);
122
176
  return spacing.split(' ').map((size)=>resolveSpacing(size, theme)).join(' ');
123
177
  }
124
- function getMargin(margin, _breakpoint, theme) {
178
+ function getMargin(margin, theme) {
125
179
  if (void 0 === margin) return;
126
180
  if (margin.length < 3) return resolveMargin(margin, theme);
127
181
  return margin.split(' ').map((size)=>resolveMargin(size, theme)).join(' ');
@@ -240,4 +294,4 @@ function ContainerQueryProvider({ elementRef, children }) {
240
294
  children: children
241
295
  });
242
296
  }
243
- export { ContainerQueryContext, ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getBackground, getBorder, getMargin, getRadius, getSpacing, rc, useActiveBreakpoint, useContainerBreakpoint, useHasContainerQuery, useResponsivePropResolver, useResponsivePropValue };
297
+ export { ContainerQueryContext, ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getBackground, getBorderEdge, getBorderStyles, getBorderWidth, getMargin, getRadius, getSpacing, rc, useActiveBreakpoint, useContainerBreakpoint, useHasContainerQuery, useResponsivePropResolver, useResponsivePropValue };
@@ -1,11 +1,11 @@
1
1
  import type * as React from 'react';
2
2
  import { type ContainerElement, type ContainerProps } from './container.js';
3
3
  import type { SurfaceVariant } from '../theme/index.js';
4
- interface FlatSurfaceProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'background' | 'border'> {
4
+ interface FlatSurfaceProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'background' | 'borderColor'> {
5
5
  elevation?: never;
6
6
  variant?: SurfaceVariant;
7
7
  }
8
- interface OverlaySurfaceProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'background' | 'border'> {
8
+ interface OverlaySurfaceProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'background' | 'borderColor'> {
9
9
  variant: 'overlay';
10
10
  elevation?: 'low' | 'medium' | 'high';
11
11
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import styled from "@emotion/styled";
3
3
  import { Container } from "./container.js";
4
- import { getBorder, getRadius, rc } from "./styles.js";
4
+ import { getBorderStyles, getRadius, rc } from "./styles.js";
5
5
  function isRenderFunction(props) {
6
6
  return 'function' == typeof props.children;
7
7
  }
@@ -11,7 +11,7 @@ const Surface = styled((props)=>{
11
11
  });
12
12
  const { variant, elevation: _, ...rest } = props;
13
13
  if ('overlay' === variant) return /*#__PURE__*/ jsx(Container, {
14
- border: "primary",
14
+ borderColor: "primary",
15
15
  radius: rest.radius ?? 'md',
16
16
  ...rest
17
17
  });
@@ -21,7 +21,10 @@ const Surface = styled((props)=>{
21
21
  });
22
22
  })`
23
23
  ${(p)=>rc('background', p.variant, p.theme, (v)=>v ? p.theme.tokens.background[v] : void 0)};
24
- ${(p)=>rc('border', 'overlay' === p.variant ? 'primary' : void 0, p.theme, getBorder)};
24
+ ${(p)=>'overlay' === p.variant ? getBorderStyles({
25
+ ...p,
26
+ borderColor: 'primary'
27
+ }, p.theme) : void 0};
25
28
  ${(p)=>rc('border-radius', p.radius ?? ('overlay' === p.variant ? 'md' : void 0), p.theme, getRadius)};
26
29
  ${(p)=>rc('box-shadow', p.elevation ?? ('overlay' === p.variant ? 'low' : void 0), p.theme, (v)=>v ? p.theme.shadow[v] : void 0)};
27
30
  `;
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
- borderBottom: "secondary",
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: "2xs lg",
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
- border: "secondary"
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
- borderTop: "secondary",
100
+ borderTopColor: "secondary",
101
101
  align: "center",
102
102
  padding: "md lg",
103
103
  ...props
@@ -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
- * In scenarios where you're using a react element as the label react-select
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
  }
@@ -32,7 +32,7 @@ const ModalFooter = styled((props)=>/*#__PURE__*/ jsx(Flex, {
32
32
  ...props,
33
33
  as: "footer",
34
34
  justify: "end",
35
- borderTop: "primary",
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
- borderBottom: "primary",
78
+ borderBottomColor: "primary",
79
79
  padding: {
80
80
  zero: '2xl',
81
81
  '3xl': '2xl 3xl'
@@ -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 = useTheme();
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 { 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 };
@@ -1,12 +1,8 @@
1
- import { createFilter } from "./reactSelectWrapper.js";
2
- function filter_createFilter(config) {
3
- const filter = createFilter({
4
- stringify: ({ data })=>config?.stringify(data) ?? data.textValue ?? `${'string' == typeof data.label || 'number' == typeof data.label ? data.label : ''} ${data.value}`
5
- });
6
- return (option, input)=>filter({
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 { filter_createFilter as createFilter };
8
+ export { createFilter };
@@ -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';
@@ -0,0 +1,11 @@
1
+ import type * as React from 'react';
2
+ import type { getSelectStyles } from './styles.js';
3
+ export declare function SelectIndicators({ dropdownIndicator, isLoading, isOpen, onClear, selectStyles, showClearButton, trailingItems, }: {
4
+ isOpen: boolean;
5
+ onClear: () => void;
6
+ selectStyles: Pick<ReturnType<typeof getSelectStyles>, 'clearIcon' | 'indicators'>;
7
+ showClearButton: boolean;
8
+ dropdownIndicator?: React.ReactNode;
9
+ isLoading?: boolean;
10
+ trailingItems?: React.ReactNode;
11
+ }): import("@emotion/react/jsx-runtime").JSX.Element | null;