@noya-app/noya-designsystem 0.1.14 → 0.1.16
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +15 -0
- package/dist/index.d.mts +56 -59
- package/dist/index.d.ts +56 -59
- package/dist/index.js +852 -825
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +567 -539
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/ActivityIndicator.tsx +23 -13
- package/src/components/ArrayController.tsx +5 -5
- package/src/components/Avatar.tsx +5 -5
- package/src/components/Button.tsx +39 -36
- package/src/components/Chip.tsx +25 -25
- package/src/components/Divider.tsx +45 -20
- package/src/components/FillInputField.tsx +23 -23
- package/src/components/InputField.tsx +78 -91
- package/src/components/InputFieldWithCompletions.tsx +4 -4
- package/src/components/InspectorPrimitives.tsx +18 -18
- package/src/components/Label.tsx +21 -21
- package/src/components/ListView.tsx +100 -95
- package/src/components/RadioGroup.tsx +1 -2
- package/src/components/Select.tsx +11 -11
- package/src/components/Sortable.tsx +9 -1
- package/src/components/Spacer.tsx +30 -7
- package/src/components/Stack.tsx +8 -8
- package/src/components/Switch.tsx +9 -10
- package/src/components/Text.tsx +15 -15
- package/src/components/internal/Menu.tsx +6 -10
- package/src/contexts/DesignSystemConfiguration.tsx +8 -1
|
@@ -163,53 +163,53 @@ function getPositionMargin(marginType: ListRowMarginType) {
|
|
|
163
163
|
* ------------------------------------------------------------------------- */
|
|
164
164
|
|
|
165
165
|
const RowContainer = styled.div<{
|
|
166
|
-
marginType: ListRowMarginType;
|
|
167
|
-
selected: boolean;
|
|
168
|
-
selectedPosition: ListRowPosition;
|
|
169
|
-
disabled: boolean;
|
|
170
|
-
hovered: boolean;
|
|
171
|
-
variant: ListViewVariant;
|
|
172
|
-
divider: boolean;
|
|
173
|
-
isSectionHeader: boolean;
|
|
174
|
-
showsActiveState: boolean;
|
|
175
|
-
sectionHeaderVariant: ListViewSectionHeaderVariant;
|
|
176
|
-
colorScheme: ListColorScheme;
|
|
177
|
-
gap: number;
|
|
178
|
-
backgroundColor?: CSSProperties["backgroundColor"];
|
|
166
|
+
$marginType: ListRowMarginType;
|
|
167
|
+
$selected: boolean;
|
|
168
|
+
$selectedPosition: ListRowPosition;
|
|
169
|
+
$disabled: boolean;
|
|
170
|
+
$hovered: boolean;
|
|
171
|
+
$variant: ListViewVariant;
|
|
172
|
+
$divider: boolean;
|
|
173
|
+
$isSectionHeader: boolean;
|
|
174
|
+
$showsActiveState: boolean;
|
|
175
|
+
$sectionHeaderVariant: ListViewSectionHeaderVariant;
|
|
176
|
+
$colorScheme: ListColorScheme;
|
|
177
|
+
$gap: number;
|
|
178
|
+
$backgroundColor?: CSSProperties["backgroundColor"];
|
|
179
179
|
}>(
|
|
180
180
|
({
|
|
181
181
|
theme,
|
|
182
|
-
marginType,
|
|
183
|
-
selected,
|
|
184
|
-
selectedPosition,
|
|
185
|
-
disabled,
|
|
186
|
-
hovered,
|
|
187
|
-
variant,
|
|
188
|
-
divider,
|
|
189
|
-
isSectionHeader,
|
|
190
|
-
showsActiveState,
|
|
191
|
-
sectionHeaderVariant,
|
|
192
|
-
colorScheme,
|
|
193
|
-
gap,
|
|
194
|
-
backgroundColor,
|
|
182
|
+
$marginType,
|
|
183
|
+
$selected,
|
|
184
|
+
$selectedPosition,
|
|
185
|
+
$disabled,
|
|
186
|
+
$hovered,
|
|
187
|
+
$variant,
|
|
188
|
+
$divider,
|
|
189
|
+
$isSectionHeader,
|
|
190
|
+
$showsActiveState,
|
|
191
|
+
$sectionHeaderVariant,
|
|
192
|
+
$colorScheme,
|
|
193
|
+
$gap,
|
|
194
|
+
$backgroundColor,
|
|
195
195
|
}) => {
|
|
196
|
-
const margin = getPositionMargin(marginType);
|
|
196
|
+
const margin = getPositionMargin($marginType);
|
|
197
197
|
|
|
198
198
|
return {
|
|
199
|
-
...(isSectionHeader && sectionHeaderVariant === "label"
|
|
199
|
+
...($isSectionHeader && $sectionHeaderVariant === "label"
|
|
200
200
|
? theme.textStyles.label
|
|
201
201
|
: theme.textStyles.small),
|
|
202
|
-
...(isSectionHeader && { fontWeight: 500 }),
|
|
203
|
-
gap,
|
|
202
|
+
...($isSectionHeader && { fontWeight: 500 }),
|
|
203
|
+
gap: $gap,
|
|
204
204
|
flex: "0 0 auto",
|
|
205
205
|
userSelect: "none",
|
|
206
206
|
cursor: "default",
|
|
207
|
-
...(variant !== "bare" && {
|
|
207
|
+
...($variant !== "bare" && {
|
|
208
208
|
paddingTop: "6px",
|
|
209
209
|
paddingRight: "12px",
|
|
210
210
|
paddingBottom: "6px",
|
|
211
211
|
paddingLeft: "12px",
|
|
212
|
-
...(variant === "padded" && {
|
|
212
|
+
...($variant === "padded" && {
|
|
213
213
|
borderRadius: "2px",
|
|
214
214
|
marginLeft: "8px",
|
|
215
215
|
marginRight: "8px",
|
|
@@ -218,56 +218,56 @@ const RowContainer = styled.div<{
|
|
|
218
218
|
}),
|
|
219
219
|
}),
|
|
220
220
|
color: theme.colors.textMuted,
|
|
221
|
-
...(isSectionHeader && {
|
|
221
|
+
...($isSectionHeader && {
|
|
222
222
|
backgroundColor: theme.colors.listView.raisedBackground,
|
|
223
|
-
...(sectionHeaderVariant === "label" && {
|
|
223
|
+
...($sectionHeaderVariant === "label" && {
|
|
224
224
|
color: theme.colors.textDisabled,
|
|
225
225
|
}),
|
|
226
226
|
}),
|
|
227
|
-
...(disabled && {
|
|
227
|
+
...($disabled && {
|
|
228
228
|
color: theme.colors.textDisabled,
|
|
229
229
|
}),
|
|
230
|
-
...(selected && {
|
|
230
|
+
...($selected && {
|
|
231
231
|
color: "white",
|
|
232
|
-
backgroundColor: theme.colors[colorScheme],
|
|
232
|
+
backgroundColor: theme.colors[$colorScheme],
|
|
233
233
|
}),
|
|
234
234
|
display: "flex",
|
|
235
235
|
alignItems: "center",
|
|
236
|
-
...(selected &&
|
|
237
|
-
|
|
238
|
-
(selectedPosition === "middle" || selectedPosition === "last") && {
|
|
236
|
+
...($selected &&
|
|
237
|
+
!$isSectionHeader &&
|
|
238
|
+
($selectedPosition === "middle" || $selectedPosition === "last") && {
|
|
239
239
|
borderTopRightRadius: "0px",
|
|
240
240
|
borderTopLeftRadius: "0px",
|
|
241
241
|
}),
|
|
242
|
-
...(selected &&
|
|
243
|
-
|
|
244
|
-
(selectedPosition === "middle" || selectedPosition === "first") && {
|
|
242
|
+
...($selected &&
|
|
243
|
+
!$isSectionHeader &&
|
|
244
|
+
($selectedPosition === "middle" || $selectedPosition === "first") && {
|
|
245
245
|
borderBottomRightRadius: "0px",
|
|
246
246
|
borderBottomLeftRadius: "0px",
|
|
247
247
|
}),
|
|
248
248
|
position: "relative",
|
|
249
|
-
...(hovered && {
|
|
250
|
-
boxShadow: `0 0 0 1px ${theme.colors[colorScheme]} inset`,
|
|
249
|
+
...($hovered && {
|
|
250
|
+
boxShadow: `0 0 0 1px ${theme.colors[$colorScheme]} inset`,
|
|
251
251
|
}),
|
|
252
|
-
...(showsActiveState && {
|
|
252
|
+
...($showsActiveState && {
|
|
253
253
|
"&:active": {
|
|
254
|
-
backgroundColor: selected
|
|
255
|
-
? colorScheme === "secondary"
|
|
254
|
+
backgroundColor: $selected
|
|
255
|
+
? $colorScheme === "secondary"
|
|
256
256
|
? theme.colors.secondaryLight
|
|
257
257
|
: theme.colors.primaryLight
|
|
258
258
|
: theme.colors.activeBackground,
|
|
259
259
|
},
|
|
260
260
|
}),
|
|
261
|
-
...(divider && {
|
|
261
|
+
...($divider && {
|
|
262
262
|
borderBottom: `1px solid ${theme.colors.dividerSubtle}`,
|
|
263
263
|
}),
|
|
264
|
-
...(backgroundColor && {
|
|
265
|
-
backgroundColor,
|
|
264
|
+
...($backgroundColor && {
|
|
265
|
+
backgroundColor: $backgroundColor,
|
|
266
266
|
"&:hover": {
|
|
267
|
-
backgroundColor,
|
|
267
|
+
backgroundColor: $backgroundColor,
|
|
268
268
|
},
|
|
269
269
|
"&:active": {
|
|
270
|
-
backgroundColor,
|
|
270
|
+
backgroundColor: $backgroundColor,
|
|
271
271
|
},
|
|
272
272
|
}),
|
|
273
273
|
};
|
|
@@ -275,30 +275,30 @@ const RowContainer = styled.div<{
|
|
|
275
275
|
);
|
|
276
276
|
|
|
277
277
|
const ListViewDragIndicatorElement = styled.div<{
|
|
278
|
-
relativeDropPosition: RelativeDropPosition;
|
|
279
|
-
gap: number;
|
|
280
|
-
offsetLeft: number;
|
|
281
|
-
colorScheme: ListColorScheme;
|
|
282
|
-
}>(({ theme, relativeDropPosition, offsetLeft, colorScheme, gap }) => ({
|
|
278
|
+
$relativeDropPosition: RelativeDropPosition;
|
|
279
|
+
$gap: number;
|
|
280
|
+
$offsetLeft: number;
|
|
281
|
+
$colorScheme: ListColorScheme;
|
|
282
|
+
}>(({ theme, $relativeDropPosition, $offsetLeft, $colorScheme, $gap }) => ({
|
|
283
283
|
zIndex: 1,
|
|
284
284
|
position: "absolute",
|
|
285
285
|
borderRadius: "3px",
|
|
286
|
-
...(relativeDropPosition === "inside"
|
|
286
|
+
...($relativeDropPosition === "inside"
|
|
287
287
|
? {
|
|
288
288
|
inset: 2,
|
|
289
289
|
boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${
|
|
290
|
-
colorScheme === "secondary"
|
|
290
|
+
$colorScheme === "secondary"
|
|
291
291
|
? theme.colors.secondary
|
|
292
292
|
: theme.colors.dragOutline
|
|
293
293
|
}`,
|
|
294
294
|
}
|
|
295
295
|
: {
|
|
296
|
-
top: relativeDropPosition === "above" ? -(3 + gap / 2) : undefined,
|
|
297
|
-
bottom: relativeDropPosition === "below" ? -(3 + gap / 2) : undefined,
|
|
298
|
-
left: offsetLeft,
|
|
296
|
+
top: $relativeDropPosition === "above" ? -(3 + $gap / 2) : undefined,
|
|
297
|
+
bottom: $relativeDropPosition === "below" ? -(3 + $gap / 2) : undefined,
|
|
298
|
+
left: $offsetLeft,
|
|
299
299
|
right: 0,
|
|
300
300
|
height: 6,
|
|
301
|
-
background: theme.colors[colorScheme],
|
|
301
|
+
background: theme.colors[$colorScheme],
|
|
302
302
|
border: `2px solid white`,
|
|
303
303
|
boxShadow: "0 0 2px rgba(0,0,0,0.5)",
|
|
304
304
|
}),
|
|
@@ -424,47 +424,49 @@ const ListViewRow = forwardRef(function ListViewRow<
|
|
|
424
424
|
},
|
|
425
425
|
ref: Ref<HTMLElement>
|
|
426
426
|
) => {
|
|
427
|
+
const Component = RowContainer;
|
|
428
|
+
|
|
427
429
|
const element = (
|
|
428
|
-
<
|
|
429
|
-
ref={ref}
|
|
430
|
-
colorScheme={colorScheme}
|
|
430
|
+
<Component
|
|
431
|
+
ref={ref as any}
|
|
432
|
+
$colorScheme={colorScheme}
|
|
431
433
|
onContextMenu={onContextMenu}
|
|
432
|
-
isSectionHeader={isSectionHeader}
|
|
434
|
+
$isSectionHeader={isSectionHeader}
|
|
433
435
|
id={id}
|
|
434
|
-
gap={gap}
|
|
435
|
-
backgroundColor={backgroundColor}
|
|
436
|
+
$gap={gap ?? 0}
|
|
437
|
+
$backgroundColor={backgroundColor}
|
|
436
438
|
{...hoverProps}
|
|
437
439
|
onDoubleClick={handleDoubleClick}
|
|
438
|
-
marginType={marginType}
|
|
439
|
-
disabled={disabled}
|
|
440
|
-
hovered={hovered}
|
|
441
|
-
selected={selected}
|
|
442
|
-
variant={variant}
|
|
443
|
-
sectionHeaderVariant={sectionHeaderVariant}
|
|
444
|
-
selectedPosition={selectedPosition}
|
|
445
|
-
showsActiveState={pressEventName === "onClick"}
|
|
440
|
+
$marginType={marginType ?? "none"}
|
|
441
|
+
$disabled={disabled}
|
|
442
|
+
$hovered={hovered}
|
|
443
|
+
$selected={selected}
|
|
444
|
+
$variant={variant}
|
|
445
|
+
$sectionHeaderVariant={sectionHeaderVariant}
|
|
446
|
+
$selectedPosition={selectedPosition}
|
|
447
|
+
$showsActiveState={pressEventName === "onClick"}
|
|
446
448
|
aria-selected={selected}
|
|
447
|
-
divider={!isDragging && divider}
|
|
449
|
+
$divider={!isDragging && divider}
|
|
448
450
|
onKeyDown={onKeyDown}
|
|
449
451
|
style={mergedStyle}
|
|
450
|
-
{...renderProps}
|
|
452
|
+
{...(renderProps as Partial<React.ComponentProps<typeof RowContainer>>)}
|
|
451
453
|
{...mergeEventHandlers(
|
|
452
|
-
{ onPointerDown: renderProps.onPointerDown },
|
|
454
|
+
{ onPointerDown: renderProps.onPointerDown! },
|
|
453
455
|
{ [pressEventName]: handlePress }
|
|
454
456
|
)}
|
|
455
457
|
tabIndex={tabIndex}
|
|
456
458
|
>
|
|
457
459
|
{relativeDropPosition && (
|
|
458
460
|
<ListViewDragIndicatorElement
|
|
459
|
-
colorScheme={colorScheme}
|
|
460
|
-
relativeDropPosition={relativeDropPosition}
|
|
461
|
-
offsetLeft={33 + depth * indentation}
|
|
462
|
-
gap={listGap}
|
|
461
|
+
$colorScheme={colorScheme}
|
|
462
|
+
$relativeDropPosition={relativeDropPosition}
|
|
463
|
+
$offsetLeft={33 + depth * indentation}
|
|
464
|
+
$gap={listGap}
|
|
463
465
|
/>
|
|
464
466
|
)}
|
|
465
467
|
{depth > 0 && <Spacer.Horizontal size={depth * indentation} />}
|
|
466
468
|
{children}
|
|
467
|
-
</
|
|
469
|
+
</Component>
|
|
468
470
|
);
|
|
469
471
|
|
|
470
472
|
if (menuItems && onSelectMenuItem) {
|
|
@@ -486,13 +488,16 @@ const ListViewRow = forwardRef(function ListViewRow<
|
|
|
486
488
|
return (
|
|
487
489
|
<Sortable.Item<HTMLElement> id={id} disabled={overrideSortable === false}>
|
|
488
490
|
{({ ref: sortableRef, ...sortableProps }) =>
|
|
489
|
-
renderContent(
|
|
491
|
+
renderContent(
|
|
492
|
+
sortableProps as any,
|
|
493
|
+
composeRefs(sortableRef, forwardedRef)
|
|
494
|
+
)
|
|
490
495
|
}
|
|
491
496
|
</Sortable.Item>
|
|
492
497
|
);
|
|
493
498
|
}
|
|
494
499
|
|
|
495
|
-
return renderContent({}, forwardedRef);
|
|
500
|
+
return renderContent({} as any, forwardedRef);
|
|
496
501
|
});
|
|
497
502
|
|
|
498
503
|
/* ----------------------------------------------------------------------------
|
|
@@ -634,15 +639,15 @@ const VirtualizedList = memo(
|
|
|
634
639
|
* ------------------------------------------------------------------------- */
|
|
635
640
|
|
|
636
641
|
const RootContainer = styled.div<{
|
|
637
|
-
scrollable?: boolean;
|
|
638
|
-
gap?: number;
|
|
639
|
-
}>(({ theme, scrollable, gap }) => ({
|
|
640
|
-
flex: scrollable ? "1 0 0" : "0 0 auto",
|
|
642
|
+
$scrollable?: boolean;
|
|
643
|
+
$gap?: number;
|
|
644
|
+
}>(({ theme, $scrollable, $gap }) => ({
|
|
645
|
+
flex: $scrollable ? "1 0 0" : "0 0 auto",
|
|
641
646
|
display: "flex",
|
|
642
647
|
flexDirection: "column",
|
|
643
648
|
flexWrap: "nowrap",
|
|
644
649
|
color: theme.colors.textMuted,
|
|
645
|
-
gap,
|
|
650
|
+
gap: $gap,
|
|
646
651
|
}));
|
|
647
652
|
|
|
648
653
|
type ListViewItemInfo = {
|
|
@@ -893,8 +898,8 @@ const ListViewRootInner = forwardRef(function ListViewRootInner<T>(
|
|
|
893
898
|
{...{
|
|
894
899
|
[pressEventName]: handleClick,
|
|
895
900
|
}}
|
|
896
|
-
gap={gap}
|
|
897
|
-
scrollable={scrollable}
|
|
901
|
+
$gap={gap}
|
|
902
|
+
$scrollable={scrollable}
|
|
898
903
|
>
|
|
899
904
|
{withScrollable((scrollElementRef: HTMLDivElement | null) =>
|
|
900
905
|
withSortable(
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
2
2
|
import React, {
|
|
3
|
-
ComponentProps,
|
|
4
3
|
createContext,
|
|
5
4
|
forwardRef,
|
|
6
5
|
memo,
|
|
@@ -119,7 +118,7 @@ const RadioGroupContext = createContext<RadioGroupContextValue>({
|
|
|
119
118
|
interface Props {
|
|
120
119
|
id?: string;
|
|
121
120
|
value?: string;
|
|
122
|
-
onValueChange?:
|
|
121
|
+
onValueChange?: (value: string) => void;
|
|
123
122
|
colorScheme?: RadioGroupColorScheme;
|
|
124
123
|
allowEmpty?: boolean;
|
|
125
124
|
children: ReactNode;
|
|
@@ -43,31 +43,31 @@ export const SelectOption = memo(function SelectOption<T extends string>({
|
|
|
43
43
|
return <option value={value}>{title ?? value}</option>;
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const createChevronSVGString = memoize(
|
|
47
|
-
|
|
46
|
+
const createChevronSVGString = memoize((color: string) =>
|
|
47
|
+
`
|
|
48
48
|
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' fill='${color}'>
|
|
49
49
|
<path d='M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z'></path>
|
|
50
50
|
</svg>
|
|
51
|
-
|
|
51
|
+
`.replace(/\n/g, "")
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
const SelectContainer = styled.div<{ flex: CSSProperties["flex"] }>(
|
|
55
|
-
({ flex }) => ({
|
|
56
|
-
flex: flex ?? "1 1 0px",
|
|
54
|
+
const SelectContainer = styled.div<{ $flex: CSSProperties["flex"] }>(
|
|
55
|
+
({ $flex }) => ({
|
|
56
|
+
flex: $flex ?? "1 1 0px",
|
|
57
57
|
display: "flex",
|
|
58
58
|
flexDirection: "row",
|
|
59
59
|
position: "relative",
|
|
60
60
|
})
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
const SelectElement = styled.select<{ flex: CSSProperties["flex"] }>(
|
|
64
|
-
({ theme, flex }) => ({
|
|
63
|
+
const SelectElement = styled.select<{ $flex: CSSProperties["flex"] }>(
|
|
64
|
+
({ theme, $flex }) => ({
|
|
65
65
|
appearance: "none",
|
|
66
66
|
...theme.textStyles.small,
|
|
67
67
|
color: theme.colors.text,
|
|
68
68
|
lineHeight: "19px",
|
|
69
69
|
width: "0px", // Reset intrinsic width
|
|
70
|
-
flex: flex ?? "1 1 0px",
|
|
70
|
+
flex: $flex ?? "1 1 0px",
|
|
71
71
|
position: "relative",
|
|
72
72
|
border: "0",
|
|
73
73
|
outline: "none",
|
|
@@ -162,10 +162,10 @@ export const Select = memo(function Select<T extends string>({
|
|
|
162
162
|
|
|
163
163
|
return (
|
|
164
164
|
<SelectContext.Provider value={contextValue}>
|
|
165
|
-
<SelectContainer flex={flex}>
|
|
165
|
+
<SelectContainer $flex={flex}>
|
|
166
166
|
<SelectElement
|
|
167
167
|
id={id}
|
|
168
|
-
flex={flex}
|
|
168
|
+
$flex={flex}
|
|
169
169
|
value={value}
|
|
170
170
|
onChange={useCallback(
|
|
171
171
|
(event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
@@ -22,6 +22,7 @@ import React, {
|
|
|
22
22
|
Ref,
|
|
23
23
|
useCallback,
|
|
24
24
|
useContext,
|
|
25
|
+
useEffect,
|
|
25
26
|
useMemo,
|
|
26
27
|
useRef,
|
|
27
28
|
useState,
|
|
@@ -262,6 +263,12 @@ function SortableRoot({
|
|
|
262
263
|
[acceptsDrop, axis, keys, onMoveItem, position.x, position.y]
|
|
263
264
|
);
|
|
264
265
|
|
|
266
|
+
const [mounted, setMounted] = useState(false);
|
|
267
|
+
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
setMounted(true);
|
|
270
|
+
}, []);
|
|
271
|
+
|
|
265
272
|
return (
|
|
266
273
|
<SortableItemContext.Provider
|
|
267
274
|
value={useMemo(
|
|
@@ -285,7 +292,8 @@ function SortableRoot({
|
|
|
285
292
|
<SortableContext items={keys} strategy={verticalListSortingStrategy}>
|
|
286
293
|
{children}
|
|
287
294
|
</SortableContext>
|
|
288
|
-
{
|
|
295
|
+
{mounted &&
|
|
296
|
+
renderOverlay &&
|
|
289
297
|
createPortal(
|
|
290
298
|
<DragOverlay dropAnimation={null}>
|
|
291
299
|
{activeIndex !== undefined &&
|
|
@@ -1,28 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react/jsx-pascal-case */
|
|
2
|
+
import React, { ForwardedRef, forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
2
4
|
|
|
3
5
|
interface Props {
|
|
4
6
|
size?: number | string;
|
|
5
7
|
inline?: boolean;
|
|
6
8
|
}
|
|
7
9
|
|
|
10
|
+
interface Props_ {
|
|
11
|
+
$size?: number | string;
|
|
12
|
+
$inline?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
/* ----------------------------------------------------------------------------
|
|
9
16
|
* Vertical
|
|
10
17
|
* ------------------------------------------------------------------------- */
|
|
11
18
|
|
|
12
|
-
const
|
|
13
|
-
display: inline ?
|
|
14
|
-
...(size === undefined ? { flex: 1 } : { minHeight: size }),
|
|
19
|
+
const SpacerVertical_ = styled.span<Props_>(({ $size, $inline }) => ({
|
|
20
|
+
display: $inline ? "inline-block" : "block",
|
|
21
|
+
...($size === undefined ? { flex: 1 } : { minHeight: $size }),
|
|
15
22
|
}));
|
|
16
23
|
|
|
24
|
+
const SpacerVertical = forwardRef<HTMLSpanElement, Props>(
|
|
25
|
+
({ size, inline, ...props }, ref: ForwardedRef<HTMLSpanElement>) => {
|
|
26
|
+
return (
|
|
27
|
+
<SpacerVertical_ $size={size} $inline={inline} {...props} ref={ref} />
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
17
32
|
/* ----------------------------------------------------------------------------
|
|
18
33
|
* Horizontal
|
|
19
34
|
* ------------------------------------------------------------------------- */
|
|
20
35
|
|
|
21
|
-
const
|
|
22
|
-
display: inline ?
|
|
23
|
-
...(size === undefined ? { flex: 1 } : { minWidth: size }),
|
|
36
|
+
const SpacerHorizontal_ = styled.span<Props_>(({ $size, $inline }) => ({
|
|
37
|
+
display: $inline ? "inline-block" : "block",
|
|
38
|
+
...($size === undefined ? { flex: 1 } : { minWidth: $size }),
|
|
24
39
|
}));
|
|
25
40
|
|
|
41
|
+
const SpacerHorizontal = forwardRef<HTMLSpanElement, Props>(
|
|
42
|
+
({ size, inline, ...props }, ref: ForwardedRef<HTMLSpanElement>) => {
|
|
43
|
+
return (
|
|
44
|
+
<SpacerHorizontal_ $size={size} $inline={inline} {...props} ref={ref} />
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
26
49
|
export namespace Spacer {
|
|
27
50
|
export const Vertical = SpacerVertical;
|
|
28
51
|
export const Horizontal = SpacerHorizontal;
|
package/src/components/Stack.tsx
CHANGED
|
@@ -81,11 +81,11 @@ interface Props extends StyleProps {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const Element = styled.div<{
|
|
84
|
-
styleProps: StyleProps;
|
|
85
|
-
breakpoints?: StackBreakpointList | null | false;
|
|
86
|
-
}>(({ styleProps, breakpoints }) => ({
|
|
87
|
-
|
|
88
|
-
...mergeBreakpoints(breakpoints || []),
|
|
84
|
+
$styleProps: StyleProps;
|
|
85
|
+
$breakpoints?: StackBreakpointList | null | false;
|
|
86
|
+
}>(({ $styleProps, $breakpoints }) => ({
|
|
87
|
+
...$styleProps,
|
|
88
|
+
...mergeBreakpoints($breakpoints || []),
|
|
89
89
|
}));
|
|
90
90
|
|
|
91
91
|
const StackBase = forwardRef(function StackBase(
|
|
@@ -105,11 +105,11 @@ const StackBase = forwardRef(function StackBase(
|
|
|
105
105
|
|
|
106
106
|
return (
|
|
107
107
|
<Element
|
|
108
|
-
ref={forwardedRef}
|
|
108
|
+
ref={forwardedRef as any}
|
|
109
109
|
id={id}
|
|
110
110
|
as={as}
|
|
111
|
-
styleProps={styleProps}
|
|
112
|
-
breakpoints={breakpoints}
|
|
111
|
+
$styleProps={styleProps}
|
|
112
|
+
$breakpoints={breakpoints}
|
|
113
113
|
tabIndex={tabIndex}
|
|
114
114
|
{...(href && { href })}
|
|
115
115
|
>
|
|
@@ -5,8 +5,8 @@ import styled from "styled-components";
|
|
|
5
5
|
type SwitchColorScheme = "normal" | "primary" | "secondary";
|
|
6
6
|
|
|
7
7
|
const SwitchRoot = styled(SwitchPrimitive.Root)<{
|
|
8
|
-
colorScheme: SwitchColorScheme;
|
|
9
|
-
}>(({ theme, colorScheme
|
|
8
|
+
$colorScheme: SwitchColorScheme;
|
|
9
|
+
}>(({ theme, $colorScheme }) => ({
|
|
10
10
|
all: "unset",
|
|
11
11
|
width: 32,
|
|
12
12
|
height: 19,
|
|
@@ -15,16 +15,15 @@ const SwitchRoot = styled(SwitchPrimitive.Root)<{
|
|
|
15
15
|
position: "relative",
|
|
16
16
|
WebkitTapHighlightColor: "rgba(0, 0, 0, 0)",
|
|
17
17
|
cursor: "pointer",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// },
|
|
18
|
+
"&:focus": {
|
|
19
|
+
outline: `2px solid ${theme.colors.primary}`,
|
|
20
|
+
outlineOffset: "1px",
|
|
21
|
+
},
|
|
23
22
|
'&[data-state="checked"]': {
|
|
24
23
|
backgroundColor:
|
|
25
|
-
|
|
24
|
+
$colorScheme === "primary"
|
|
26
25
|
? theme.colors.primary
|
|
27
|
-
:
|
|
26
|
+
: $colorScheme === "secondary"
|
|
28
27
|
? theme.colors.secondary
|
|
29
28
|
: undefined,
|
|
30
29
|
},
|
|
@@ -55,7 +54,7 @@ export const Switch = function Switch({
|
|
|
55
54
|
}: Props) {
|
|
56
55
|
return (
|
|
57
56
|
<SwitchRoot
|
|
58
|
-
colorScheme={colorScheme}
|
|
57
|
+
$colorScheme={colorScheme}
|
|
59
58
|
checked={value}
|
|
60
59
|
onCheckedChange={(newValue) => {
|
|
61
60
|
onChange(newValue);
|
package/src/components/Text.tsx
CHANGED
|
@@ -63,16 +63,16 @@ interface Props extends StyleProps {
|
|
|
63
63
|
onDoubleClick?: () => void;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const StyledElement = styled.span<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
>(({ theme, variant, styleProps, breakpoints, color }) => ({
|
|
72
|
-
...(theme.textStyles as any)[variant],
|
|
73
|
-
color: color ? theme.colors[color] : undefined,
|
|
74
|
-
|
|
75
|
-
...mergeBreakpoints(breakpoints || []),
|
|
66
|
+
const StyledElement = styled.span<{
|
|
67
|
+
$variant: keyof Theme["textStyles"];
|
|
68
|
+
$styleProps: StyleProps;
|
|
69
|
+
$color: ThemeColorName;
|
|
70
|
+
$breakpoints: BreakpointCollection<StyleProps> | null | false;
|
|
71
|
+
}>(({ theme, $variant, $styleProps, $breakpoints, $color }) => ({
|
|
72
|
+
...(theme.textStyles as any)[$variant],
|
|
73
|
+
color: $color ? theme.colors[$color] : undefined,
|
|
74
|
+
...$styleProps,
|
|
75
|
+
...mergeBreakpoints($breakpoints || []),
|
|
76
76
|
}));
|
|
77
77
|
|
|
78
78
|
export const Text = forwardRef(function Text(
|
|
@@ -96,12 +96,12 @@ export const Text = forwardRef(function Text(
|
|
|
96
96
|
ref={forwardedRef}
|
|
97
97
|
as={element}
|
|
98
98
|
className={className}
|
|
99
|
-
variant={variant}
|
|
100
|
-
breakpoints={breakpoints}
|
|
101
|
-
styleProps={rest}
|
|
102
|
-
color={color}
|
|
99
|
+
$variant={variant}
|
|
100
|
+
$breakpoints={breakpoints}
|
|
101
|
+
$styleProps={rest}
|
|
102
|
+
$color={color}
|
|
103
103
|
onClick={onClick}
|
|
104
|
-
{...(href && { href })}
|
|
104
|
+
{...((href && { href }) as any)}
|
|
105
105
|
>
|
|
106
106
|
{children}
|
|
107
107
|
</StyledElement>
|
|
@@ -171,17 +171,13 @@ export function getKeyboardShortcutsForMenuItems<T extends string>(
|
|
|
171
171
|
);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
const ShortcutElement = styled.kbd
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}: {
|
|
179
|
-
theme: Theme;
|
|
180
|
-
fixedWidth?: boolean;
|
|
181
|
-
}): CSSObject => ({
|
|
174
|
+
const ShortcutElement = styled.kbd<{
|
|
175
|
+
$fixedWidth?: boolean;
|
|
176
|
+
}>(
|
|
177
|
+
({ theme, $fixedWidth }): CSSObject => ({
|
|
182
178
|
...theme.textStyles.small,
|
|
183
179
|
color: theme.colors.textDisabled,
|
|
184
|
-
...(fixedWidth && {
|
|
180
|
+
...($fixedWidth && {
|
|
185
181
|
width: "0.9rem",
|
|
186
182
|
textAlign: "center",
|
|
187
183
|
}),
|
|
@@ -200,7 +196,7 @@ export const KeyboardShortcut = memo(function KeyboardShortcut({
|
|
|
200
196
|
const keyElements = keys.map((key) => (
|
|
201
197
|
<ShortcutElement
|
|
202
198
|
key={key}
|
|
203
|
-
fixedWidth={platform === "mac" && key.length === 1}
|
|
199
|
+
$fixedWidth={platform === "mac" && key.length === 1}
|
|
204
200
|
>
|
|
205
201
|
{key}
|
|
206
202
|
</ShortcutElement>
|
|
@@ -23,7 +23,14 @@ export const DesignSystemThemeProvider = memo(
|
|
|
23
23
|
children: ReactNode;
|
|
24
24
|
theme?: Theme;
|
|
25
25
|
}) {
|
|
26
|
-
|
|
26
|
+
let parentTheme: Theme | undefined;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
parentTheme = useTheme();
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// console.error(e);
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
if (theme) {
|
|
29
36
|
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
|