@scalewing/react 1.1.0 → 1.2.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/CHANGELOG.md +8 -0
- package/dist/components/Dialog.d.ts +7 -1
- package/dist/components/Dialog.js +2 -2
- package/dist/components/SegmentedControl.d.ts +8 -0
- package/dist/components/SegmentedControl.js +2 -2
- package/dist/css/css-data.js +26 -0
- package/dist/css/css-dialog.js +5 -1
- package/dist/css/css-grid.d.ts +1 -1
- package/dist/css/css-grid.js +1 -1
- package/dist/css/css-variables.js +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/styles.css +32 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @scalewing/react
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 829dbdb: Add `Dialog` `size` (`'md' | 'lg'`): `lg` widens the modal to `--sw-dialog-max-lg` (56rem) so a row of six fields or a data grid fits without folding. The default stays `md` (32rem); phones keep the viewport gutter for both.
|
|
8
|
+
- 28b53e0: `Grid` accepts `columns={6}` and `columnsBelow={{ md: 6 }}` (generated `sw-grid-cols-6` and `sw-grid-cols-below-md-6`) so a six-denomination entry row keeps one row on desktop. Five and seven still throw.
|
|
9
|
+
- 9363116: Add `SegmentedControl` `variant` (`'compact' | 'filled'`): `filled` gives every segment the same width and an accent-filled selection (generated `sw-segmented-filled`); it takes the full width in a Stack and its labels' width in an Inline. The default `compact` look is unchanged.
|
|
10
|
+
|
|
3
11
|
## 1.1.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type DialogHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `md` is the reading width (32rem) for a message or a short form; `lg`
|
|
4
|
+
* (56rem) holds a row of six fields or a data grid without folding it.
|
|
5
|
+
*/
|
|
6
|
+
export type DialogSize = 'md' | 'lg';
|
|
2
7
|
export type DialogProps = Omit<DialogHTMLAttributes<HTMLDialogElement>, 'onClose' | 'open' | 'title' | 'children'> & {
|
|
3
8
|
open: boolean;
|
|
4
9
|
onClose: () => void;
|
|
10
|
+
size?: DialogSize;
|
|
5
11
|
title: string;
|
|
6
12
|
children: ReactNode;
|
|
7
13
|
};
|
|
8
|
-
export declare function Dialog({ children, className, onClose, open, title, ...rest }: DialogProps): import("react").JSX.Element;
|
|
14
|
+
export declare function Dialog({ children, className, onClose, open, size, title, ...rest }: DialogProps): import("react").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { cx } from '../class-names.js';
|
|
|
5
5
|
import { spacingClassNames } from '../spacing-classes.js';
|
|
6
6
|
import { Stack } from './Stack.js';
|
|
7
7
|
import { Text } from './Text.js';
|
|
8
|
-
export function Dialog({ children, className, onClose, open, title, ...rest }) {
|
|
8
|
+
export function Dialog({ children, className, onClose, open, size = 'md', title, ...rest }) {
|
|
9
9
|
const nodeRef = useRef(null);
|
|
10
10
|
const titleId = useId();
|
|
11
11
|
useEffect(() => {
|
|
@@ -23,7 +23,7 @@ export function Dialog({ children, className, onClose, open, title, ...rest }) {
|
|
|
23
23
|
node.close();
|
|
24
24
|
}
|
|
25
25
|
}, [open]);
|
|
26
|
-
return (_jsx("dialog", { ...rest, ref: nodeRef, "aria-labelledby": titleId, className: cx('sw-dialog', ...spacingClassNames({ padding: 5 }), className), onClose: onClose, onPointerDown: (event) => {
|
|
26
|
+
return (_jsx("dialog", { ...rest, ref: nodeRef, "aria-labelledby": titleId, className: cx('sw-dialog', size === 'lg' && 'sw-dialog-lg', ...spacingClassNames({ padding: 5 }), className), onClose: onClose, onPointerDown: (event) => {
|
|
27
27
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
28
28
|
const inside = event.clientX >= rect.left &&
|
|
29
29
|
event.clientX <= rect.right &&
|
|
@@ -10,10 +10,18 @@ type SegmentedLabel = {
|
|
|
10
10
|
'aria-label'?: never;
|
|
11
11
|
'aria-labelledby': string;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* `compact` is the quiet chip track for a section switch; `filled` gives every
|
|
15
|
+
* segment the same width and paints the selected one in the accent, for a
|
|
16
|
+
* choice that decides what a form does. It sizes to its container: the full
|
|
17
|
+
* width in a Stack, the width of its widest label in an Inline.
|
|
18
|
+
*/
|
|
19
|
+
export type SegmentedControlVariant = 'compact' | 'filled';
|
|
13
20
|
export type SegmentedControlProps = SegmentedLabel & {
|
|
14
21
|
items: readonly SegmentedItem[];
|
|
15
22
|
onChange: (id: string) => void;
|
|
16
23
|
value: string;
|
|
24
|
+
variant?: SegmentedControlVariant;
|
|
17
25
|
};
|
|
18
26
|
export declare const SegmentedControl: import("react").ForwardRefExoticComponent<SegmentedControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
27
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { cx } from '../class-names.js';
|
|
4
|
-
export const SegmentedControl = forwardRef(function SegmentedControl({ items, onChange, value, ...labelProps }, ref) {
|
|
4
|
+
export const SegmentedControl = forwardRef(function SegmentedControl({ items, onChange, value, variant = 'compact', ...labelProps }, ref) {
|
|
5
5
|
function onKeyDown(event) {
|
|
6
6
|
if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft') {
|
|
7
7
|
return;
|
|
@@ -17,7 +17,7 @@ export const SegmentedControl = forwardRef(function SegmentedControl({ items, on
|
|
|
17
17
|
onChange(next.id);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
return (_jsx("div", { ref: ref, className:
|
|
20
|
+
return (_jsx("div", { ref: ref, className: cx('sw-segmented', variant === 'filled' && 'sw-segmented-filled'), onKeyDown: onKeyDown, role: "radiogroup", ...labelProps, children: items.map((item) => {
|
|
21
21
|
const selected = item.id === value;
|
|
22
22
|
return (_jsx("button", { "aria-checked": selected, className: cx('sw-segmented-item', selected && 'sw-segmented-item-selected'), onClick: () => {
|
|
23
23
|
if (!selected) {
|
package/dist/css/css-data.js
CHANGED
|
@@ -3,6 +3,7 @@ export const badgeTones = ['neutral', 'accent', 'success', 'danger'];
|
|
|
3
3
|
export const badgeSizes = ['sm', 'md'];
|
|
4
4
|
const caption = typographyVariants.caption;
|
|
5
5
|
const data = typographyVariants.data;
|
|
6
|
+
const body = typographyVariants.body;
|
|
6
7
|
export function badgeClassNames(tone, size = 'md') {
|
|
7
8
|
return ['sw-badge', `sw-badge-${tone}`, `sw-badge-${size}`];
|
|
8
9
|
}
|
|
@@ -89,6 +90,30 @@ export function cssDataClasses() {
|
|
|
89
90
|
color: var(--sw-color-text);
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
.sw-segmented-filled {
|
|
94
|
+
display: grid;
|
|
95
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
96
|
+
grid-auto-flow: column;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.sw-segmented-filled .sw-segmented-item {
|
|
100
|
+
align-items: center;
|
|
101
|
+
color: var(--sw-color-text);
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
font-size: ${body.fontSize}px;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
letter-spacing: ${body.letterSpacing}px;
|
|
106
|
+
line-height: ${body.lineHeight}px;
|
|
107
|
+
min-height: var(--sw-control-md-min-height);
|
|
108
|
+
min-width: 0;
|
|
109
|
+
padding-inline: var(--sw-control-md-padding-inline);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.sw-segmented-filled .sw-segmented-item-selected {
|
|
113
|
+
background: var(--sw-color-accent);
|
|
114
|
+
color: var(--sw-color-onAccent);
|
|
115
|
+
}
|
|
116
|
+
|
|
92
117
|
.sw-table-wrap {
|
|
93
118
|
overflow: auto;
|
|
94
119
|
width: 100%;
|
|
@@ -177,6 +202,7 @@ export function dataClassCatalog() {
|
|
|
177
202
|
'sw-segmented',
|
|
178
203
|
'sw-segmented-item',
|
|
179
204
|
'sw-segmented-item-selected',
|
|
205
|
+
'sw-segmented-filled',
|
|
180
206
|
'sw-table-wrap',
|
|
181
207
|
'sw-table',
|
|
182
208
|
'sw-table-end',
|
package/dist/css/css-dialog.js
CHANGED
|
@@ -15,6 +15,10 @@ export function cssDialogClasses() {
|
|
|
15
15
|
width: calc(100% - var(--sw-space-8));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
.sw-dialog-lg {
|
|
19
|
+
max-width: min(var(--sw-dialog-max-lg), calc(100vw - var(--sw-space-8)));
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
.sw-dialog::backdrop {
|
|
19
23
|
background: color-mix(in srgb, var(--sw-color-text) 28%, transparent);
|
|
20
24
|
}
|
|
@@ -25,5 +29,5 @@ export function cssDialogClasses() {
|
|
|
25
29
|
}`;
|
|
26
30
|
}
|
|
27
31
|
export function dialogClassCatalog() {
|
|
28
|
-
return ['sw-dialog'];
|
|
32
|
+
return ['sw-dialog', 'sw-dialog-lg'];
|
|
29
33
|
}
|
package/dist/css/css-grid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Breakpoint } from './breakpoints.js';
|
|
2
|
-
export declare const gridColumnCounts: readonly [1, 2, 3, 4];
|
|
2
|
+
export declare const gridColumnCounts: readonly [1, 2, 3, 4, 6];
|
|
3
3
|
export type GridColumns = (typeof gridColumnCounts)[number];
|
|
4
4
|
export declare function gridColumnsClass(columns: GridColumns): string;
|
|
5
5
|
export declare function gridColumnsBelowClass(breakpoint: Breakpoint, columns: GridColumns): string;
|
package/dist/css/css-grid.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -14,8 +14,7 @@ export { BarChart, type BarChartItem, type BarChartProps, } from './components/B
|
|
|
14
14
|
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, } from './components/Button.js';
|
|
15
15
|
export { Box, type BoxElement, type BoxProps } from './components/Box.js';
|
|
16
16
|
export { Card, type CardProps, type CardVariant } from './components/Card.js';
|
|
17
|
-
export { Dialog } from './components/Dialog.js';
|
|
18
|
-
export type { DialogProps } from './components/Dialog.js';
|
|
17
|
+
export { Dialog, type DialogProps, type DialogSize, } from './components/Dialog.js';
|
|
19
18
|
export { Toast } from './components/Toast.js';
|
|
20
19
|
export type { ToastProps } from './components/Toast.js';
|
|
21
20
|
export { Field, type FieldProps, type FieldSize } from './components/Field.js';
|
|
@@ -23,7 +22,7 @@ export { Inline, type InlineProps } from './components/Inline.js';
|
|
|
23
22
|
export { Split } from './components/Split.js';
|
|
24
23
|
export type { SplitProps } from './components/Split.js';
|
|
25
24
|
export { Nav, type NavProps } from './components/Nav.js';
|
|
26
|
-
export { SegmentedControl, type SegmentedControlProps, type SegmentedItem, } from './components/SegmentedControl.js';
|
|
25
|
+
export { SegmentedControl, type SegmentedControlProps, type SegmentedControlVariant, type SegmentedItem, } from './components/SegmentedControl.js';
|
|
27
26
|
export { Select } from './components/Select.js';
|
|
28
27
|
export type { SelectAction, SelectOption, SelectProps, } from './components/Select.js';
|
|
29
28
|
export { Stack, type Align, type Justify, type StackProps, } from './components/Stack.js';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { BarChart, } from './components/BarChart.js';
|
|
|
13
13
|
export { Button, } from './components/Button.js';
|
|
14
14
|
export { Box } from './components/Box.js';
|
|
15
15
|
export { Card } from './components/Card.js';
|
|
16
|
-
export { Dialog } from './components/Dialog.js';
|
|
16
|
+
export { Dialog, } from './components/Dialog.js';
|
|
17
17
|
export { Toast } from './components/Toast.js';
|
|
18
18
|
export { Field } from './components/Field.js';
|
|
19
19
|
export { Inline } from './components/Inline.js';
|
package/dist/styles.css
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
--sw-focus-ring-offset: 2px;
|
|
40
40
|
--sw-container-max: 72rem;
|
|
41
41
|
--sw-dialog-max: 32rem;
|
|
42
|
+
--sw-dialog-max-lg: 56rem;
|
|
42
43
|
--sw-select-max: 16rem;
|
|
43
44
|
--sw-split-min: 14rem;
|
|
44
45
|
--sw-split-size: 22rem;
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
--sw-focus-ring-offset: 2px;
|
|
95
96
|
--sw-container-max: 72rem;
|
|
96
97
|
--sw-dialog-max: 32rem;
|
|
98
|
+
--sw-dialog-max-lg: 56rem;
|
|
97
99
|
--sw-select-max: 16rem;
|
|
98
100
|
--sw-split-min: 14rem;
|
|
99
101
|
--sw-split-size: 22rem;
|
|
@@ -1098,6 +1100,30 @@ body {
|
|
|
1098
1100
|
color: var(--sw-color-text);
|
|
1099
1101
|
}
|
|
1100
1102
|
|
|
1103
|
+
.sw-segmented-filled {
|
|
1104
|
+
display: grid;
|
|
1105
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
1106
|
+
grid-auto-flow: column;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.sw-segmented-filled .sw-segmented-item {
|
|
1110
|
+
align-items: center;
|
|
1111
|
+
color: var(--sw-color-text);
|
|
1112
|
+
display: inline-flex;
|
|
1113
|
+
font-size: 17px;
|
|
1114
|
+
justify-content: center;
|
|
1115
|
+
letter-spacing: -0.2px;
|
|
1116
|
+
line-height: 25px;
|
|
1117
|
+
min-height: var(--sw-control-md-min-height);
|
|
1118
|
+
min-width: 0;
|
|
1119
|
+
padding-inline: var(--sw-control-md-padding-inline);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
.sw-segmented-filled .sw-segmented-item-selected {
|
|
1123
|
+
background: var(--sw-color-accent);
|
|
1124
|
+
color: var(--sw-color-onAccent);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1101
1127
|
.sw-table-wrap {
|
|
1102
1128
|
overflow: auto;
|
|
1103
1129
|
width: 100%;
|
|
@@ -1389,6 +1415,10 @@ body {
|
|
|
1389
1415
|
width: calc(100% - var(--sw-space-8));
|
|
1390
1416
|
}
|
|
1391
1417
|
|
|
1418
|
+
.sw-dialog-lg {
|
|
1419
|
+
max-width: min(var(--sw-dialog-max-lg), calc(100vw - var(--sw-space-8)));
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1392
1422
|
.sw-dialog::backdrop {
|
|
1393
1423
|
background: color-mix(in srgb, var(--sw-color-text) 28%, transparent);
|
|
1394
1424
|
}
|
|
@@ -1982,11 +2012,13 @@ body {
|
|
|
1982
2012
|
.sw-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1983
2013
|
.sw-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1984
2014
|
.sw-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
2015
|
+
.sw-grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
|
1985
2016
|
@media not all and (min-width: 48rem) {
|
|
1986
2017
|
.sw-grid-cols-below-md-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
|
|
1987
2018
|
.sw-grid-cols-below-md-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1988
2019
|
.sw-grid-cols-below-md-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1989
2020
|
.sw-grid-cols-below-md-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
2021
|
+
.sw-grid-cols-below-md-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
|
1990
2022
|
}
|
|
1991
2023
|
.sw-denomination-grid {
|
|
1992
2024
|
color: var(--sw-color-text);
|