@react-spectrum/s2 3.0.0-nightly-101d0772b-250113 → 3.0.0-nightly-c53ab48ec-250115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionBar.cjs +11 -9
- package/dist/ActionBar.cjs.map +1 -1
- package/dist/ActionBar.css +17 -34
- package/dist/ActionBar.css.map +1 -1
- package/dist/ActionBar.mjs +12 -10
- package/dist/ActionBar.mjs.map +1 -1
- package/dist/Modal.cjs +15 -21
- package/dist/Modal.cjs.map +1 -1
- package/dist/Modal.css +22 -46
- package/dist/Modal.css.map +1 -1
- package/dist/Modal.mjs +15 -21
- package/dist/Modal.mjs.map +1 -1
- package/dist/Popover.cjs +19 -37
- package/dist/Popover.cjs.map +1 -1
- package/dist/Popover.css +28 -99
- package/dist/Popover.css.map +1 -1
- package/dist/Popover.mjs +19 -37
- package/dist/Popover.mjs.map +1 -1
- package/dist/Tabs.cjs +177 -414
- package/dist/Tabs.cjs.map +1 -1
- package/dist/Tabs.css +120 -208
- package/dist/Tabs.css.map +1 -1
- package/dist/Tabs.mjs +179 -416
- package/dist/Tabs.mjs.map +1 -1
- package/dist/Tooltip.cjs +19 -16
- package/dist/Tooltip.cjs.map +1 -1
- package/dist/Tooltip.css +25 -40
- package/dist/Tooltip.css.map +1 -1
- package/dist/Tooltip.mjs +19 -16
- package/dist/Tooltip.mjs.map +1 -1
- package/dist/en-US.cjs +0 -1
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +0 -1
- package/dist/en-US.mjs.map +1 -1
- package/dist/he-IL.cjs +0 -1
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +0 -1
- package/dist/he-IL.mjs.map +1 -1
- package/dist/types.d.ts +7 -11
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -22
- package/src/ActionBar.tsx +14 -20
- package/src/Modal.tsx +17 -44
- package/src/Popover.tsx +21 -89
- package/src/Tabs.tsx +156 -427
- package/src/Tooltip.tsx +25 -42
- package/dist/TabsPicker.cjs +0 -388
- package/dist/TabsPicker.cjs.map +0 -1
- package/dist/TabsPicker.css +0 -440
- package/dist/TabsPicker.css.map +0 -1
- package/dist/TabsPicker.mjs +0 -382
- package/dist/TabsPicker.mjs.map +0 -1
- package/src/TabsPicker.tsx +0 -341
package/src/TabsPicker.tsx
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
PopoverProps as AriaPopoverProps,
|
|
15
|
-
Select as AriaSelect,
|
|
16
|
-
SelectProps as AriaSelectProps,
|
|
17
|
-
Button,
|
|
18
|
-
ContextValue,
|
|
19
|
-
DEFAULT_SLOT,
|
|
20
|
-
ListBox,
|
|
21
|
-
ListBoxItem,
|
|
22
|
-
ListBoxItemProps,
|
|
23
|
-
ListBoxProps,
|
|
24
|
-
Provider,
|
|
25
|
-
SelectValue
|
|
26
|
-
} from 'react-aria-components';
|
|
27
|
-
import {centerBaseline} from './CenterBaseline';
|
|
28
|
-
import {
|
|
29
|
-
checkmark,
|
|
30
|
-
description,
|
|
31
|
-
icon,
|
|
32
|
-
label,
|
|
33
|
-
menuitem,
|
|
34
|
-
sectionHeader,
|
|
35
|
-
sectionHeading
|
|
36
|
-
} from './Menu';
|
|
37
|
-
import CheckmarkIcon from '../ui-icons/Checkmark';
|
|
38
|
-
import ChevronIcon from '../ui-icons/Chevron';
|
|
39
|
-
import {edgeToText, focusRing, size, style} from '../style' with {type: 'macro'};
|
|
40
|
-
import {fieldInput, StyleProps} from './style-utils' with {type: 'macro'};
|
|
41
|
-
import {
|
|
42
|
-
FieldLabel
|
|
43
|
-
} from './Field';
|
|
44
|
-
import {FocusableRef, FocusableRefValue, SpectrumLabelableProps} from '@react-types/shared';
|
|
45
|
-
import {forwardRefType} from './types';
|
|
46
|
-
import {HeaderContext, HeadingContext, Text, TextContext} from './Content';
|
|
47
|
-
import {IconContext} from './Icon';
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
import intlMessages from '../intl/*.json';
|
|
50
|
-
import {Placement} from 'react-aria';
|
|
51
|
-
import {PopoverBase} from './Popover';
|
|
52
|
-
import {pressScale} from './pressScale';
|
|
53
|
-
import {raw} from '../style/style-macro' with {type: 'macro'};
|
|
54
|
-
import React, {createContext, forwardRef, ReactNode, useContext, useRef} from 'react';
|
|
55
|
-
import {useFocusableRef} from '@react-spectrum/utils';
|
|
56
|
-
import {useFormProps} from './Form';
|
|
57
|
-
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
58
|
-
import {useSpectrumContextProps} from './useSpectrumContextProps';
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export interface PickerStyleProps {
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface PickerProps<T extends object> extends
|
|
65
|
-
Omit<AriaSelectProps<T>, 'children' | 'style' | 'className'>,
|
|
66
|
-
PickerStyleProps,
|
|
67
|
-
StyleProps,
|
|
68
|
-
SpectrumLabelableProps,
|
|
69
|
-
Pick<ListBoxProps<T>, 'items'>,
|
|
70
|
-
Pick<AriaPopoverProps, 'shouldFlip'> {
|
|
71
|
-
/** The contents of the collection. */
|
|
72
|
-
children: ReactNode | ((item: T) => ReactNode),
|
|
73
|
-
/**
|
|
74
|
-
* Direction the menu will render relative to the Picker.
|
|
75
|
-
*
|
|
76
|
-
* @default 'bottom'
|
|
77
|
-
*/
|
|
78
|
-
direction?: 'bottom' | 'top',
|
|
79
|
-
/**
|
|
80
|
-
* Alignment of the menu relative to the input target.
|
|
81
|
-
*
|
|
82
|
-
* @default 'start'
|
|
83
|
-
*/
|
|
84
|
-
align?: 'start' | 'end',
|
|
85
|
-
/** Width of the menu. By default, matches width of the trigger. Note that the minimum width of the dropdown is always equal to the trigger's width. */
|
|
86
|
-
menuWidth?: number,
|
|
87
|
-
/** Density of the tabs, affects the height of the picker. */
|
|
88
|
-
density: 'compact' | 'regular',
|
|
89
|
-
/**
|
|
90
|
-
* If the tab picker should only display icon and no text for the button label.
|
|
91
|
-
* @default 'show
|
|
92
|
-
*/
|
|
93
|
-
labelBehavior?: 'show' | 'hide'
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const PickerContext = createContext<ContextValue<Partial<PickerProps<any>>, FocusableRefValue<HTMLButtonElement>>>(null);
|
|
97
|
-
|
|
98
|
-
const inputButton = style({
|
|
99
|
-
...focusRing(),
|
|
100
|
-
...fieldInput(),
|
|
101
|
-
outlineStyle: {
|
|
102
|
-
default: 'none',
|
|
103
|
-
isFocusVisible: 'solid'
|
|
104
|
-
},
|
|
105
|
-
position: 'relative',
|
|
106
|
-
font: 'ui',
|
|
107
|
-
display: 'flex',
|
|
108
|
-
textAlign: 'start',
|
|
109
|
-
borderStyle: 'none',
|
|
110
|
-
borderRadius: 'sm',
|
|
111
|
-
alignItems: 'center',
|
|
112
|
-
transition: 'default',
|
|
113
|
-
columnGap: 'text-to-visual',
|
|
114
|
-
paddingX: 0,
|
|
115
|
-
backgroundColor: 'transparent',
|
|
116
|
-
color: {
|
|
117
|
-
default: 'neutral',
|
|
118
|
-
isDisabled: 'disabled'
|
|
119
|
-
},
|
|
120
|
-
maxWidth: {
|
|
121
|
-
isQuiet: 'max'
|
|
122
|
-
},
|
|
123
|
-
disableTapHighlight: true,
|
|
124
|
-
height: {
|
|
125
|
-
default: 48,
|
|
126
|
-
density: {
|
|
127
|
-
compact: 32
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
boxSizing: 'border-box'
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
export let menu = style({
|
|
134
|
-
outlineStyle: 'none',
|
|
135
|
-
display: 'grid',
|
|
136
|
-
gridTemplateColumns: [edgeToText(32), 'auto', 'auto', 'minmax(0, 1fr)', 'auto', 'auto', 'auto', edgeToText(32)],
|
|
137
|
-
boxSizing: 'border-box',
|
|
138
|
-
maxHeight: '[inherit]',
|
|
139
|
-
overflow: 'auto',
|
|
140
|
-
padding: 8,
|
|
141
|
-
fontFamily: 'sans',
|
|
142
|
-
fontSize: 'control'
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const valueStyles = style({
|
|
146
|
-
flexGrow: 0,
|
|
147
|
-
truncate: true,
|
|
148
|
-
display: 'flex',
|
|
149
|
-
alignItems: 'center',
|
|
150
|
-
height: 'full'
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const iconStyles = style({
|
|
154
|
-
flexShrink: 0,
|
|
155
|
-
rotate: 90,
|
|
156
|
-
'--iconPrimary': {
|
|
157
|
-
type: 'fill',
|
|
158
|
-
value: 'currentColor'
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const iconCenterWrapper = style({
|
|
163
|
-
display: 'flex',
|
|
164
|
-
gridArea: 'icon',
|
|
165
|
-
paddingStart: {
|
|
166
|
-
labelBehavior: {
|
|
167
|
-
hide: size(6)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
let InsideSelectValueContext = createContext(false);
|
|
173
|
-
|
|
174
|
-
function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLButtonElement>) {
|
|
175
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');
|
|
176
|
-
[props, ref] = useSpectrumContextProps(props, ref, PickerContext);
|
|
177
|
-
let domRef = useFocusableRef(ref);
|
|
178
|
-
props = useFormProps(props);
|
|
179
|
-
let {
|
|
180
|
-
direction = 'bottom',
|
|
181
|
-
align = 'start',
|
|
182
|
-
shouldFlip = true,
|
|
183
|
-
children,
|
|
184
|
-
items,
|
|
185
|
-
placeholder = stringFormatter.format('picker.placeholder'),
|
|
186
|
-
density,
|
|
187
|
-
labelBehavior = 'show',
|
|
188
|
-
...pickerProps
|
|
189
|
-
} = props;
|
|
190
|
-
let isQuiet = true;
|
|
191
|
-
|
|
192
|
-
const menuOffset: number = 6;
|
|
193
|
-
const size = 'M';
|
|
194
|
-
|
|
195
|
-
return (
|
|
196
|
-
<AriaSelect
|
|
197
|
-
{...pickerProps}
|
|
198
|
-
placeholder={placeholder}>
|
|
199
|
-
{({isOpen}) => (
|
|
200
|
-
<>
|
|
201
|
-
<FieldLabel isQuiet={isQuiet} />
|
|
202
|
-
<Button
|
|
203
|
-
ref={domRef}
|
|
204
|
-
style={renderProps => pressScale(domRef)(renderProps)}
|
|
205
|
-
// Prevent press scale from sticking while Picker is open.
|
|
206
|
-
// @ts-ignore
|
|
207
|
-
isPressed={false}
|
|
208
|
-
className={renderProps => inputButton({
|
|
209
|
-
...renderProps,
|
|
210
|
-
size: 'M',
|
|
211
|
-
isOpen,
|
|
212
|
-
isQuiet,
|
|
213
|
-
density
|
|
214
|
-
})}>
|
|
215
|
-
<SelectValue className={valueStyles + ' ' + raw('&> * {display: none;}')}>
|
|
216
|
-
{({defaultChildren}) => {
|
|
217
|
-
return (
|
|
218
|
-
<Provider
|
|
219
|
-
values={[
|
|
220
|
-
[IconContext, {
|
|
221
|
-
slots: {
|
|
222
|
-
icon: {
|
|
223
|
-
render: centerBaseline({slot: 'icon', styles: iconCenterWrapper({labelBehavior})}),
|
|
224
|
-
styles: icon
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}],
|
|
228
|
-
[TextContext, {
|
|
229
|
-
slots: {
|
|
230
|
-
// Default slot is useful when converting other collections to PickerItems.
|
|
231
|
-
[DEFAULT_SLOT]: {styles: style({
|
|
232
|
-
display: {
|
|
233
|
-
default: 'block',
|
|
234
|
-
labelBehavior: {
|
|
235
|
-
hide: 'none'
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
flexGrow: 1,
|
|
239
|
-
truncate: true
|
|
240
|
-
})({labelBehavior})}
|
|
241
|
-
}
|
|
242
|
-
}],
|
|
243
|
-
[InsideSelectValueContext, true]
|
|
244
|
-
]}>
|
|
245
|
-
{defaultChildren}
|
|
246
|
-
</Provider>
|
|
247
|
-
);
|
|
248
|
-
}}
|
|
249
|
-
</SelectValue>
|
|
250
|
-
<ChevronIcon
|
|
251
|
-
size={size}
|
|
252
|
-
className={iconStyles} />
|
|
253
|
-
</Button>
|
|
254
|
-
<PopoverBase
|
|
255
|
-
hideArrow
|
|
256
|
-
offset={menuOffset}
|
|
257
|
-
placement={`${direction} ${align}` as Placement}
|
|
258
|
-
shouldFlip={shouldFlip}
|
|
259
|
-
styles={style({
|
|
260
|
-
marginStart: -12,
|
|
261
|
-
minWidth: 192,
|
|
262
|
-
width: '[calc(var(--trigger-width) + (-2 * self(marginStart)))]'
|
|
263
|
-
})}>
|
|
264
|
-
<Provider
|
|
265
|
-
values={[
|
|
266
|
-
[HeaderContext, {styles: sectionHeader({size})}],
|
|
267
|
-
[HeadingContext, {styles: sectionHeading}],
|
|
268
|
-
[TextContext, {
|
|
269
|
-
slots: {
|
|
270
|
-
description: {styles: description({size})}
|
|
271
|
-
}
|
|
272
|
-
}]
|
|
273
|
-
]}>
|
|
274
|
-
<ListBox
|
|
275
|
-
items={items}
|
|
276
|
-
className={menu}>
|
|
277
|
-
{children}
|
|
278
|
-
</ListBox>
|
|
279
|
-
</Provider>
|
|
280
|
-
</PopoverBase>
|
|
281
|
-
</>
|
|
282
|
-
)}
|
|
283
|
-
</AriaSelect>
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Pickers allow users to choose a single option from a collapsible list of options when space is limited.
|
|
289
|
-
*/
|
|
290
|
-
let _Picker = /*#__PURE__*/ (forwardRef as forwardRefType)(Picker);
|
|
291
|
-
export {_Picker as Picker};
|
|
292
|
-
|
|
293
|
-
export interface PickerItemProps extends Omit<ListBoxItemProps, 'children' | 'style' | 'className'>, StyleProps {
|
|
294
|
-
children: ReactNode
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function PickerItem(props: PickerItemProps) {
|
|
298
|
-
let ref = useRef(null);
|
|
299
|
-
let isLink = props.href != null;
|
|
300
|
-
const size = 'M';
|
|
301
|
-
return (
|
|
302
|
-
<ListBoxItem
|
|
303
|
-
{...props}
|
|
304
|
-
ref={ref}
|
|
305
|
-
textValue={props.textValue || (typeof props.children === 'string' ? props.children as string : undefined)}
|
|
306
|
-
style={pressScale(ref, props.UNSAFE_style)}
|
|
307
|
-
className={renderProps => (props.UNSAFE_className || '') + menuitem({...renderProps, size, isLink}, props.styles)}>
|
|
308
|
-
{(renderProps) => {
|
|
309
|
-
let {children} = props;
|
|
310
|
-
return (
|
|
311
|
-
<DefaultProvider
|
|
312
|
-
context={IconContext}
|
|
313
|
-
value={{slots: {
|
|
314
|
-
icon: {render: centerBaseline({slot: 'icon', styles: iconCenterWrapper({})}), styles: icon}
|
|
315
|
-
}}}>
|
|
316
|
-
<DefaultProvider
|
|
317
|
-
context={TextContext}
|
|
318
|
-
value={{
|
|
319
|
-
slots: {
|
|
320
|
-
[DEFAULT_SLOT]: {styles: label({size})}
|
|
321
|
-
}
|
|
322
|
-
}}>
|
|
323
|
-
{!isLink && <CheckmarkIcon size={size} className={checkmark({...renderProps, size})} />}
|
|
324
|
-
{typeof children === 'string' ? <Text>{children}</Text> : children}
|
|
325
|
-
</DefaultProvider>
|
|
326
|
-
</DefaultProvider>
|
|
327
|
-
);
|
|
328
|
-
}}
|
|
329
|
-
</ListBoxItem>
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// A Context.Provider that only sets a value if not inside SelectValue.
|
|
334
|
-
function DefaultProvider({context, value, children}: {context: React.Context<any>, value: any, children: any}) {
|
|
335
|
-
let inSelectValue = useContext(InsideSelectValueContext);
|
|
336
|
-
if (inSelectValue) {
|
|
337
|
-
return children;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return <context.Provider value={value}>{children}</context.Provider>;
|
|
341
|
-
}
|