@scalewing/react 0.6.1 → 1.0.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 +49 -0
- package/README.md +62 -1
- package/dist/components/ActionMenu.d.ts +16 -0
- package/dist/components/ActionMenu.js +142 -0
- package/dist/components/Badge.d.ts +2 -1
- package/dist/components/Badge.js +2 -1
- package/dist/components/Box.d.ts +3 -2
- package/dist/components/Box.js +3 -2
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Checkbox.d.ts +10 -0
- package/dist/components/Checkbox.js +17 -0
- package/dist/components/DateField.d.ts +12 -0
- package/dist/components/DateField.js +30 -0
- package/dist/components/Field.d.ts +4 -1
- package/dist/components/Field.js +36 -3
- package/dist/components/FilterChips.d.ts +12 -0
- package/dist/components/FilterChips.js +20 -0
- package/dist/components/Inline.js +1 -1
- package/dist/components/Progress.d.ts +8 -0
- package/dist/components/Progress.js +13 -0
- package/dist/components/RadioGroup.d.ts +16 -0
- package/dist/components/RadioGroup.js +27 -0
- package/dist/components/Separator.d.ts +6 -0
- package/dist/components/Separator.js +4 -0
- package/dist/components/Spinner.d.ts +11 -0
- package/dist/components/Spinner.js +10 -0
- package/dist/components/Stack.js +1 -1
- package/dist/components/Switch.d.ts +8 -0
- package/dist/components/Switch.js +11 -0
- package/dist/components/Tooltip.d.ts +8 -0
- package/dist/components/Tooltip.js +40 -0
- package/dist/css/breakpoints.d.ts +8 -0
- package/dist/css/breakpoints.js +11 -0
- package/dist/css/css-accordion.d.ts +2 -0
- package/dist/css/css-accordion.js +33 -0
- package/dist/css/css-action-menu.d.ts +2 -0
- package/dist/css/css-action-menu.js +95 -0
- package/dist/css/css-button.d.ts +7 -0
- package/dist/css/css-button.js +68 -0
- package/dist/css/css-chart.d.ts +2 -0
- package/dist/css/css-chart.js +98 -0
- package/dist/css/css-checkbox.d.ts +2 -0
- package/dist/css/css-checkbox.js +127 -0
- package/dist/css/css-chrome.d.ts +2 -0
- package/dist/css/css-chrome.js +59 -0
- package/dist/css/css-components.d.ts +1 -0
- package/dist/css/css-components.js +130 -0
- package/dist/css/css-data.d.ts +7 -0
- package/dist/css/css-data.js +189 -0
- package/dist/css/css-date-field.d.ts +2 -0
- package/dist/css/css-date-field.js +77 -0
- package/dist/css/css-dialog.d.ts +2 -0
- package/dist/css/css-dialog.js +29 -0
- package/dist/css/css-document.d.ts +1 -0
- package/dist/css/css-document.js +102 -0
- package/dist/css/css-field.d.ts +2 -0
- package/dist/css/css-field.js +33 -0
- package/dist/css/css-filter-chips.d.ts +2 -0
- package/dist/css/css-filter-chips.js +92 -0
- package/dist/css/css-palettes.d.ts +4 -0
- package/dist/css/css-palettes.js +52 -0
- package/dist/css/css-progress.d.ts +2 -0
- package/dist/css/css-progress.js +77 -0
- package/dist/css/css-radio-group.d.ts +2 -0
- package/dist/css/css-radio-group.js +148 -0
- package/dist/css/css-responsive.d.ts +2 -0
- package/dist/css/css-responsive.js +12 -0
- package/dist/css/css-select.d.ts +2 -0
- package/dist/css/css-select.js +134 -0
- package/dist/css/css-separator.d.ts +2 -0
- package/dist/css/css-separator.js +26 -0
- package/dist/css/css-spinner.d.ts +2 -0
- package/dist/css/css-spinner.js +45 -0
- package/dist/css/css-split.d.ts +2 -0
- package/dist/css/css-split.js +67 -0
- package/dist/css/css-switch.d.ts +2 -0
- package/dist/css/css-switch.js +115 -0
- package/dist/css/css-toast.d.ts +2 -0
- package/dist/css/css-toast.js +92 -0
- package/dist/css/css-tooltip.d.ts +2 -0
- package/dist/css/css-tooltip.js +35 -0
- package/dist/css/css-utilities.d.ts +1 -0
- package/dist/css/css-utilities.js +57 -0
- package/dist/css/css-variables.d.ts +2 -0
- package/dist/css/css-variables.js +61 -0
- package/dist/css/spacing-classes.d.ts +10 -0
- package/dist/css/spacing-classes.js +40 -0
- package/dist/css/stylesheet.d.ts +3 -0
- package/dist/css/stylesheet.js +75 -0
- package/dist/date-only.d.ts +3 -0
- package/dist/date-only.js +31 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +12 -1
- package/dist/spacing-classes.js +1 -1
- package/dist/styles.css +762 -20
- package/dist/visibility-classes.d.ts +6 -0
- package/dist/visibility-classes.js +7 -0
- package/package.json +4 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
const label = typographyVariants.label;
|
|
3
|
+
const caption = typographyVariants.caption;
|
|
4
|
+
export function cssSwitchClasses() {
|
|
5
|
+
return `.sw-switch {
|
|
6
|
+
align-items: center;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
gap: var(--sw-space-2);
|
|
10
|
+
min-height: var(--sw-control-md-min-height);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sw-switch-control {
|
|
14
|
+
align-items: center;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
flex: 0 0 var(--sw-space-8);
|
|
17
|
+
min-height: var(--sw-control-md-min-height);
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sw-switch-input {
|
|
22
|
+
cursor: inherit;
|
|
23
|
+
height: 100%;
|
|
24
|
+
inset: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
opacity: 0;
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sw-switch-track {
|
|
32
|
+
background: var(--sw-color-border);
|
|
33
|
+
border: 1px solid var(--sw-color-border);
|
|
34
|
+
border-radius: var(--sw-radius-pill);
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
display: block;
|
|
37
|
+
height: var(--sw-space-5);
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
position: relative;
|
|
40
|
+
width: var(--sw-space-8);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sw-switch-thumb {
|
|
44
|
+
background: var(--sw-color-surface);
|
|
45
|
+
border-radius: var(--sw-radius-pill);
|
|
46
|
+
height: var(--sw-space-4);
|
|
47
|
+
inset-block-start: var(--sw-space-1);
|
|
48
|
+
inset-inline-start: var(--sw-space-1);
|
|
49
|
+
position: absolute;
|
|
50
|
+
transition: inset-inline-start var(--sw-motion-fast) var(--sw-motion-easing);
|
|
51
|
+
width: var(--sw-space-4);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.sw-switch-input:checked + .sw-switch-track {
|
|
55
|
+
background: var(--sw-color-accent);
|
|
56
|
+
border-color: var(--sw-color-accent);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sw-switch-input:checked + .sw-switch-track .sw-switch-thumb {
|
|
60
|
+
inset-inline-start: calc(var(--sw-space-8) - var(--sw-space-4) - var(--sw-space-1));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.sw-switch-input:focus-visible + .sw-switch-track {
|
|
64
|
+
outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
|
|
65
|
+
outline-offset: var(--sw-focus-ring-offset);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sw-switch:has(.sw-switch-input:disabled) {
|
|
69
|
+
cursor: not-allowed;
|
|
70
|
+
opacity: var(--sw-disabled-opacity);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sw-switch-copy {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sw-switch-label {
|
|
79
|
+
color: var(--sw-color-text);
|
|
80
|
+
font-family: var(--sw-font-sans);
|
|
81
|
+
font-size: ${label.fontSize}px;
|
|
82
|
+
font-weight: ${label.fontWeight};
|
|
83
|
+
line-height: ${label.lineHeight}px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.sw-switch-description {
|
|
87
|
+
color: var(--sw-color-muted);
|
|
88
|
+
font-family: var(--sw-font-sans);
|
|
89
|
+
font-size: ${caption.fontSize}px;
|
|
90
|
+
line-height: ${caption.lineHeight}px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@media (prefers-reduced-motion: reduce) {
|
|
94
|
+
.sw-switch-thumb { transition: none; }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@media (forced-colors: active) {
|
|
98
|
+
.sw-switch-track { background: Canvas; border-color: CanvasText; }
|
|
99
|
+
.sw-switch-thumb { background: CanvasText; }
|
|
100
|
+
.sw-switch-input:checked + .sw-switch-track { background: Highlight; border-color: Highlight; }
|
|
101
|
+
.sw-switch-input:checked + .sw-switch-track .sw-switch-thumb { background: HighlightText; }
|
|
102
|
+
}`;
|
|
103
|
+
}
|
|
104
|
+
export function switchClassCatalog() {
|
|
105
|
+
return [
|
|
106
|
+
'sw-switch',
|
|
107
|
+
'sw-switch-control',
|
|
108
|
+
'sw-switch-input',
|
|
109
|
+
'sw-switch-track',
|
|
110
|
+
'sw-switch-thumb',
|
|
111
|
+
'sw-switch-copy',
|
|
112
|
+
'sw-switch-label',
|
|
113
|
+
'sw-switch-description',
|
|
114
|
+
];
|
|
115
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export function cssToastClasses() {
|
|
2
|
+
return `.sw-toast {
|
|
3
|
+
background: var(--sw-glass-fill);
|
|
4
|
+
border: 1px solid var(--sw-glass-border);
|
|
5
|
+
border-radius: var(--sw-radius-lg);
|
|
6
|
+
box-shadow: inset 0 1px 0 var(--sw-glass-specular);
|
|
7
|
+
backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
|
|
8
|
+
-webkit-backdrop-filter: blur(var(--sw-glass-blur)) saturate(var(--sw-glass-saturate));
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
color: var(--sw-color-text);
|
|
11
|
+
inset: unset;
|
|
12
|
+
bottom: var(--sw-space-6);
|
|
13
|
+
left: 50%;
|
|
14
|
+
margin: 0;
|
|
15
|
+
overflow: visible;
|
|
16
|
+
pointer-events: none;
|
|
17
|
+
position: fixed;
|
|
18
|
+
translate: -50% 0;
|
|
19
|
+
width: max-content;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sw-toast:popover-open {
|
|
23
|
+
animation: sw-toast-float var(--sw-motion-default) var(--sw-motion-easing);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sw-toast-travel {
|
|
27
|
+
bottom: auto;
|
|
28
|
+
left: 0;
|
|
29
|
+
top: 0;
|
|
30
|
+
translate: var(--sw-toast-from-x) var(--sw-toast-from-y);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sw-toast-travel:popover-open {
|
|
34
|
+
animation: sw-toast-travel var(--sw-motion-travel)
|
|
35
|
+
var(--sw-motion-travel-easing) forwards;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@keyframes sw-toast-float {
|
|
39
|
+
from {
|
|
40
|
+
opacity: 0;
|
|
41
|
+
translate: -50% var(--sw-space-3);
|
|
42
|
+
}
|
|
43
|
+
to {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
translate: -50% 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes sw-toast-travel {
|
|
50
|
+
0% {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
scale: 0.6;
|
|
53
|
+
translate: var(--sw-toast-from-x) var(--sw-toast-from-y);
|
|
54
|
+
}
|
|
55
|
+
16% {
|
|
56
|
+
opacity: 1;
|
|
57
|
+
scale: 1.2;
|
|
58
|
+
translate: var(--sw-toast-from-x) var(--sw-toast-from-y);
|
|
59
|
+
}
|
|
60
|
+
42% {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
scale: 1;
|
|
63
|
+
translate: var(--sw-toast-to-x) var(--sw-toast-to-y);
|
|
64
|
+
}
|
|
65
|
+
78% {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
scale: 1;
|
|
68
|
+
translate: var(--sw-toast-to-x) var(--sw-toast-to-y);
|
|
69
|
+
}
|
|
70
|
+
100% {
|
|
71
|
+
opacity: 0;
|
|
72
|
+
scale: 0.94;
|
|
73
|
+
translate: var(--sw-toast-to-x) var(--sw-toast-to-y);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
.sw-toast:popover-open,
|
|
79
|
+
.sw-toast-travel:popover-open {
|
|
80
|
+
animation: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sw-toast-travel:popover-open {
|
|
84
|
+
opacity: 1;
|
|
85
|
+
scale: 1;
|
|
86
|
+
translate: var(--sw-toast-to-x) var(--sw-toast-to-y);
|
|
87
|
+
}
|
|
88
|
+
}`;
|
|
89
|
+
}
|
|
90
|
+
export function toastClassCatalog() {
|
|
91
|
+
return ['sw-toast', 'sw-toast-travel'];
|
|
92
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { typographyVariants } from '@scalewing/tokens';
|
|
2
|
+
const caption = typographyVariants.caption;
|
|
3
|
+
export function cssTooltipClasses() {
|
|
4
|
+
return `.sw-tooltip-anchor {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sw-tooltip {
|
|
10
|
+
background: var(--sw-color-surface);
|
|
11
|
+
border: 1px solid var(--sw-color-border);
|
|
12
|
+
border-radius: var(--sw-radius-sm);
|
|
13
|
+
box-shadow: var(--sw-elevation-sm);
|
|
14
|
+
color: var(--sw-color-text);
|
|
15
|
+
font-family: var(--sw-font-sans);
|
|
16
|
+
font-size: ${caption.fontSize}px;
|
|
17
|
+
line-height: ${caption.lineHeight}px;
|
|
18
|
+
inset-block-start: calc(100% + var(--sw-space-1));
|
|
19
|
+
inset-inline-start: 0;
|
|
20
|
+
max-width: min(18rem, calc(100vw - 2 * var(--sw-space-3)));
|
|
21
|
+
padding: var(--sw-space-2);
|
|
22
|
+
position: absolute;
|
|
23
|
+
width: max-content;
|
|
24
|
+
z-index: 10;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sw-tooltip[hidden] { display: none; }
|
|
28
|
+
|
|
29
|
+
@media (forced-colors: active) {
|
|
30
|
+
.sw-tooltip { border-color: CanvasText; box-shadow: none; }
|
|
31
|
+
}`;
|
|
32
|
+
}
|
|
33
|
+
export function tooltipClassCatalog() {
|
|
34
|
+
return ['sw-tooltip-anchor', 'sw-tooltip'];
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cssUtilities(): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { spacingSteps } from '@scalewing/tokens';
|
|
2
|
+
import { gapAxes, layoutClassNames, paddingAxes, spacingClass, } from './spacing-classes.js';
|
|
3
|
+
function paddingRule(axis, step) {
|
|
4
|
+
const className = spacingClass('padding', axis, step);
|
|
5
|
+
const value = `var(--sw-space-${step})`;
|
|
6
|
+
switch (axis) {
|
|
7
|
+
case 'all':
|
|
8
|
+
return `.${className} { padding: ${value}; }`;
|
|
9
|
+
case 'x':
|
|
10
|
+
return `.${className} { padding-inline: ${value}; }`;
|
|
11
|
+
case 'y':
|
|
12
|
+
return `.${className} { padding-block: ${value}; }`;
|
|
13
|
+
case 'top':
|
|
14
|
+
return `.${className} { padding-top: ${value}; }`;
|
|
15
|
+
case 'right':
|
|
16
|
+
return `.${className} { padding-right: ${value}; }`;
|
|
17
|
+
case 'bottom':
|
|
18
|
+
return `.${className} { padding-bottom: ${value}; }`;
|
|
19
|
+
case 'left':
|
|
20
|
+
return `.${className} { padding-left: ${value}; }`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function gapRule(axis, step) {
|
|
24
|
+
const className = spacingClass('gap', axis, step);
|
|
25
|
+
const value = `var(--sw-space-${step})`;
|
|
26
|
+
switch (axis) {
|
|
27
|
+
case 'all':
|
|
28
|
+
return `.${className} { gap: ${value}; }`;
|
|
29
|
+
case 'x':
|
|
30
|
+
return `.${className} { column-gap: ${value}; }`;
|
|
31
|
+
case 'y':
|
|
32
|
+
return `.${className} { row-gap: ${value}; }`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const layoutRules = {
|
|
36
|
+
'sw-stack': '.sw-stack { display: flex; flex-direction: column; min-width: 0; }',
|
|
37
|
+
'sw-inline': '.sw-inline { display: flex; flex-direction: row; align-items: center; min-width: 0; }',
|
|
38
|
+
'sw-wrap': '.sw-wrap { flex-wrap: wrap; }',
|
|
39
|
+
'sw-grow': '.sw-grow { flex-grow: 1; }',
|
|
40
|
+
'sw-full-width': '.sw-full-width { width: 100%; }',
|
|
41
|
+
'sw-container': '.sw-container { width: 100%; max-width: var(--sw-container-max); margin-inline: auto; }',
|
|
42
|
+
'sw-sr-only': '.sw-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }',
|
|
43
|
+
'sw-align-start': '.sw-align-start { align-items: flex-start; }',
|
|
44
|
+
'sw-align-center': '.sw-align-center { align-items: center; }',
|
|
45
|
+
'sw-align-end': '.sw-align-end { align-items: flex-end; }',
|
|
46
|
+
'sw-align-stretch': '.sw-align-stretch { align-items: stretch; }',
|
|
47
|
+
'sw-justify-start': '.sw-justify-start { justify-content: flex-start; }',
|
|
48
|
+
'sw-justify-center': '.sw-justify-center { justify-content: center; }',
|
|
49
|
+
'sw-justify-end': '.sw-justify-end { justify-content: flex-end; }',
|
|
50
|
+
'sw-justify-between': '.sw-justify-between { justify-content: space-between; }',
|
|
51
|
+
};
|
|
52
|
+
export function cssUtilities() {
|
|
53
|
+
const padding = paddingAxes.flatMap((axis) => spacingSteps.map((step) => paddingRule(axis, step)));
|
|
54
|
+
const gap = gapAxes.flatMap((axis) => spacingSteps.map((step) => gapRule(axis, step)));
|
|
55
|
+
const layout = layoutClassNames.map((name) => layoutRules[name]);
|
|
56
|
+
return [...padding, ...gap, ...layout].join('\n');
|
|
57
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { controlScale, disabledOpacity, focusRing, quietOpacity, radiusScale, semanticColorKeys, spacingScale, spacingSteps, splitScale, } from '@scalewing/tokens';
|
|
2
|
+
function colorDeclarations(theme) {
|
|
3
|
+
return semanticColorKeys
|
|
4
|
+
.map((key) => ` --sw-color-${key}: ${theme.colors[key]};`)
|
|
5
|
+
.join('\n');
|
|
6
|
+
}
|
|
7
|
+
function glassDeclarations(theme) {
|
|
8
|
+
return ` --sw-glass-blur: ${theme.glass.blur}px;
|
|
9
|
+
--sw-glass-saturate: ${theme.glass.saturate};
|
|
10
|
+
--sw-glass-fill: ${theme.glass.fill};
|
|
11
|
+
--sw-glass-border: ${theme.glass.border};
|
|
12
|
+
--sw-glass-specular: ${theme.glass.specular};`;
|
|
13
|
+
}
|
|
14
|
+
function sharedDeclarations(theme) {
|
|
15
|
+
const space = spacingSteps
|
|
16
|
+
.map((step) => ` --sw-space-${step}: ${spacingScale[step]}px;`)
|
|
17
|
+
.join('\n');
|
|
18
|
+
const radius = Object.entries(radiusScale)
|
|
19
|
+
.map(([name, value]) => ` --sw-radius-${name}: ${value}px;`)
|
|
20
|
+
.join('\n');
|
|
21
|
+
const control = Object.entries(controlScale)
|
|
22
|
+
.flatMap(([size, value]) => [
|
|
23
|
+
` --sw-control-${size}-min-height: ${value.minHeight}px;`,
|
|
24
|
+
` --sw-control-${size}-padding-inline: ${value.paddingInline}px;`,
|
|
25
|
+
])
|
|
26
|
+
.join('\n');
|
|
27
|
+
return `${space}
|
|
28
|
+
${radius}
|
|
29
|
+
${control}
|
|
30
|
+
--sw-font-sans: ${theme.fontFamily};
|
|
31
|
+
--sw-elevation-sm: ${theme.elevation.sm};
|
|
32
|
+
--sw-elevation-md: ${theme.elevation.md};
|
|
33
|
+
--sw-disabled-opacity: ${disabledOpacity};
|
|
34
|
+
--sw-quiet-opacity: ${quietOpacity};
|
|
35
|
+
--sw-focus-ring-width: ${focusRing.width}px;
|
|
36
|
+
--sw-focus-ring-offset: ${focusRing.offset}px;
|
|
37
|
+
--sw-container-max: 72rem;
|
|
38
|
+
--sw-dialog-max: 32rem;
|
|
39
|
+
--sw-select-max: 16rem;
|
|
40
|
+
--sw-split-min: ${splitScale.min}rem;
|
|
41
|
+
--sw-split-size: ${splitScale.size}rem;
|
|
42
|
+
--sw-split-max: ${splitScale.max}rem;
|
|
43
|
+
--sw-motion-fast: ${theme.motion.duration.fast};
|
|
44
|
+
--sw-motion-default: ${theme.motion.duration.default};
|
|
45
|
+
--sw-motion-travel: ${theme.motion.duration.travel};
|
|
46
|
+
--sw-motion-easing: ${theme.motion.easing.standard};
|
|
47
|
+
--sw-motion-travel-easing: ${theme.motion.easing.travel};
|
|
48
|
+
${glassDeclarations(theme)}`;
|
|
49
|
+
}
|
|
50
|
+
export function cssVariables(light, dark) {
|
|
51
|
+
return `:root,
|
|
52
|
+
[data-theme='light'] {
|
|
53
|
+
${colorDeclarations(light)}
|
|
54
|
+
${sharedDeclarations(light)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-theme='dark'] {
|
|
58
|
+
${colorDeclarations(dark)}
|
|
59
|
+
${sharedDeclarations(dark)}
|
|
60
|
+
}`;
|
|
61
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SpacingStep } from '@scalewing/tokens';
|
|
2
|
+
export declare const paddingAxes: readonly ["all", "x", "y", "top", "right", "bottom", "left"];
|
|
3
|
+
export type PaddingAxis = (typeof paddingAxes)[number];
|
|
4
|
+
export declare const gapAxes: readonly ["all", "x", "y"];
|
|
5
|
+
export type GapAxis = (typeof gapAxes)[number];
|
|
6
|
+
export type SpacingKind = 'padding' | 'gap';
|
|
7
|
+
export declare function spacingClass(kind: SpacingKind, axis: PaddingAxis | GapAxis, step: SpacingStep): string;
|
|
8
|
+
export declare function paddingClassNames(): string[];
|
|
9
|
+
export declare function gapClassNames(): string[];
|
|
10
|
+
export declare const layoutClassNames: readonly ["sw-stack", "sw-inline", "sw-wrap", "sw-grow", "sw-full-width", "sw-container", "sw-sr-only", "sw-align-start", "sw-align-center", "sw-align-end", "sw-align-stretch", "sw-justify-start", "sw-justify-center", "sw-justify-end", "sw-justify-between"];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spacingSteps } from '@scalewing/tokens';
|
|
2
|
+
export const paddingAxes = [
|
|
3
|
+
'all',
|
|
4
|
+
'x',
|
|
5
|
+
'y',
|
|
6
|
+
'top',
|
|
7
|
+
'right',
|
|
8
|
+
'bottom',
|
|
9
|
+
'left',
|
|
10
|
+
];
|
|
11
|
+
export const gapAxes = ['all', 'x', 'y'];
|
|
12
|
+
export function spacingClass(kind, axis, step) {
|
|
13
|
+
if (axis === 'all') {
|
|
14
|
+
return `sw-${kind}-${step}`;
|
|
15
|
+
}
|
|
16
|
+
return `sw-${kind}-${axis}-${step}`;
|
|
17
|
+
}
|
|
18
|
+
export function paddingClassNames() {
|
|
19
|
+
return paddingAxes.flatMap((axis) => spacingSteps.map((step) => spacingClass('padding', axis, step)));
|
|
20
|
+
}
|
|
21
|
+
export function gapClassNames() {
|
|
22
|
+
return gapAxes.flatMap((axis) => spacingSteps.map((step) => spacingClass('gap', axis, step)));
|
|
23
|
+
}
|
|
24
|
+
export const layoutClassNames = [
|
|
25
|
+
'sw-stack',
|
|
26
|
+
'sw-inline',
|
|
27
|
+
'sw-wrap',
|
|
28
|
+
'sw-grow',
|
|
29
|
+
'sw-full-width',
|
|
30
|
+
'sw-container',
|
|
31
|
+
'sw-sr-only',
|
|
32
|
+
'sw-align-start',
|
|
33
|
+
'sw-align-center',
|
|
34
|
+
'sw-align-end',
|
|
35
|
+
'sw-align-stretch',
|
|
36
|
+
'sw-justify-start',
|
|
37
|
+
'sw-justify-center',
|
|
38
|
+
'sw-justify-end',
|
|
39
|
+
'sw-justify-between',
|
|
40
|
+
];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { cardVariants, darkTheme, lightTheme, typographyVariants, } from '@scalewing/tokens';
|
|
2
|
+
import { actionMenuClassCatalog } from './css-action-menu.js';
|
|
3
|
+
import { accordionClassCatalog } from './css-accordion.js';
|
|
4
|
+
import { switchClassCatalog } from './css-switch.js';
|
|
5
|
+
import { dateFieldClassCatalog } from './css-date-field.js';
|
|
6
|
+
import { checkboxClassCatalog } from './css-checkbox.js';
|
|
7
|
+
import { radioGroupClassCatalog } from './css-radio-group.js';
|
|
8
|
+
import { spinnerClassCatalog } from './css-spinner.js';
|
|
9
|
+
import { progressClassCatalog } from './css-progress.js';
|
|
10
|
+
import { tooltipClassCatalog } from './css-tooltip.js';
|
|
11
|
+
import { separatorClassCatalog } from './css-separator.js';
|
|
12
|
+
import { responsiveClassCatalog } from './css-responsive.js';
|
|
13
|
+
import { filterChipsClassCatalog } from './css-filter-chips.js';
|
|
14
|
+
import { fieldClassCatalog } from './css-field.js';
|
|
15
|
+
import { cssComponentClasses } from './css-components.js';
|
|
16
|
+
import { buttonClassCatalog } from './css-button.js';
|
|
17
|
+
import { chartClassCatalog } from './css-chart.js';
|
|
18
|
+
import { dataClassCatalog } from './css-data.js';
|
|
19
|
+
import { chromeClassCatalog } from './css-chrome.js';
|
|
20
|
+
import { dialogClassCatalog } from './css-dialog.js';
|
|
21
|
+
import { selectClassCatalog } from './css-select.js';
|
|
22
|
+
import { splitClassCatalog } from './css-split.js';
|
|
23
|
+
import { toastClassCatalog } from './css-toast.js';
|
|
24
|
+
import { cssDocumentCanvas } from './css-document.js';
|
|
25
|
+
import { cssPaletteAttributes } from './css-palettes.js';
|
|
26
|
+
import { cssUtilities } from './css-utilities.js';
|
|
27
|
+
import { cssVariables } from './css-variables.js';
|
|
28
|
+
import { gapClassNames, layoutClassNames, paddingClassNames, } from './spacing-classes.js';
|
|
29
|
+
export function utilityClassCatalog() {
|
|
30
|
+
return [
|
|
31
|
+
...paddingClassNames(),
|
|
32
|
+
...gapClassNames(),
|
|
33
|
+
...layoutClassNames,
|
|
34
|
+
'sw-card',
|
|
35
|
+
...cardVariants.map((variant) => `sw-card-${variant}`),
|
|
36
|
+
'sw-truncate',
|
|
37
|
+
'sw-tabular',
|
|
38
|
+
...Object.keys(typographyVariants).map((name) => `sw-text-${name}`),
|
|
39
|
+
...buttonClassCatalog(),
|
|
40
|
+
...dataClassCatalog(),
|
|
41
|
+
...chartClassCatalog(),
|
|
42
|
+
...chromeClassCatalog(),
|
|
43
|
+
...dialogClassCatalog(),
|
|
44
|
+
...accordionClassCatalog(),
|
|
45
|
+
...selectClassCatalog(),
|
|
46
|
+
...actionMenuClassCatalog(),
|
|
47
|
+
...switchClassCatalog(),
|
|
48
|
+
...dateFieldClassCatalog(),
|
|
49
|
+
...checkboxClassCatalog(),
|
|
50
|
+
...radioGroupClassCatalog(),
|
|
51
|
+
...spinnerClassCatalog(),
|
|
52
|
+
...progressClassCatalog(),
|
|
53
|
+
...tooltipClassCatalog(),
|
|
54
|
+
...separatorClassCatalog(),
|
|
55
|
+
...filterChipsClassCatalog(),
|
|
56
|
+
...fieldClassCatalog(),
|
|
57
|
+
...splitClassCatalog(),
|
|
58
|
+
...toastClassCatalog(),
|
|
59
|
+
...responsiveClassCatalog(),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
export { generatePaletteStylesheet, paletteStylesheetIds, } from './css-palettes.js';
|
|
63
|
+
export function generateStylesheet() {
|
|
64
|
+
return `/* Generated by @scalewing/tokens. Do not edit by hand. */
|
|
65
|
+
${cssVariables(lightTheme, darkTheme)}
|
|
66
|
+
|
|
67
|
+
${cssPaletteAttributes()}
|
|
68
|
+
|
|
69
|
+
${cssDocumentCanvas()}
|
|
70
|
+
|
|
71
|
+
${cssUtilities()}
|
|
72
|
+
|
|
73
|
+
${cssComponentClasses()}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2
|
+
function daysInMonth(year, month) {
|
|
3
|
+
if (month === 2) {
|
|
4
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
5
|
+
return leap ? 29 : 28;
|
|
6
|
+
}
|
|
7
|
+
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
8
|
+
}
|
|
9
|
+
export function isDateOnly(value) {
|
|
10
|
+
const parts = DATE_ONLY.exec(value);
|
|
11
|
+
if (!parts)
|
|
12
|
+
return false;
|
|
13
|
+
const year = Number(parts[1]);
|
|
14
|
+
const month = Number(parts[2]);
|
|
15
|
+
const day = Number(parts[3]);
|
|
16
|
+
return (year >= 1 &&
|
|
17
|
+
month >= 1 &&
|
|
18
|
+
month <= 12 &&
|
|
19
|
+
day >= 1 &&
|
|
20
|
+
day <= daysInMonth(year, month));
|
|
21
|
+
}
|
|
22
|
+
export function assertDateOnly(name, value, empty = false) {
|
|
23
|
+
if (empty && value === '')
|
|
24
|
+
return;
|
|
25
|
+
if (!isDateOnly(value))
|
|
26
|
+
throw new RangeError(`${name} must be a valid YYYY-MM-DD date`);
|
|
27
|
+
}
|
|
28
|
+
export function isOutsideDateRange(value, min, max) {
|
|
29
|
+
return (value !== '' &&
|
|
30
|
+
((min !== undefined && value < min) || (max !== undefined && value > max)));
|
|
31
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
export { ActionMenu, type ActionMenuItem, type ActionMenuProps, } from './components/ActionMenu.js';
|
|
1
2
|
export { Accordion } from './components/Accordion.js';
|
|
2
3
|
export type { AccordionProps } from './components/Accordion.js';
|
|
4
|
+
export { Switch, type SwitchProps } from './components/Switch.js';
|
|
5
|
+
export { DateField, type DateFieldProps } from './components/DateField.js';
|
|
6
|
+
export { Checkbox, type CheckboxProps } from './components/Checkbox.js';
|
|
7
|
+
export { Spinner, type SpinnerProps, type SpinnerSize, } from './components/Spinner.js';
|
|
8
|
+
export { Progress, type ProgressProps, type ProgressTone, } from './components/Progress.js';
|
|
9
|
+
export { Tooltip, type TooltipProps } from './components/Tooltip.js';
|
|
10
|
+
export { RadioGroup, type RadioGroupOption, type RadioGroupProps, } from './components/RadioGroup.js';
|
|
3
11
|
export { AppHeader, type AppHeaderProps } from './components/AppHeader.js';
|
|
4
|
-
export { Badge, type BadgeProps, type BadgeSize, type BadgeTone, } from './components/Badge.js';
|
|
12
|
+
export { Badge, type BadgeProps, type BadgeSize, type BadgeTone, badgeSizes, badgeTones, } from './components/Badge.js';
|
|
5
13
|
export { BarChart, type BarChartItem, type BarChartProps, } from './components/BarChart.js';
|
|
6
14
|
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, } from './components/Button.js';
|
|
7
15
|
export { Box, type BoxElement, type BoxProps } from './components/Box.js';
|
|
@@ -22,3 +30,9 @@ export { Stack, type Align, type Justify, type StackProps, } from './components/
|
|
|
22
30
|
export { Table, TableBody, TableCell, TableHeader, TableRow, type TableBodyProps, type TableCellProps, type TableDensity, type TableHeaderProps, type TableProps, type TableRowProps, } from './components/Table.js';
|
|
23
31
|
export { Text, type TextElement, type TextProps } from './components/Text.js';
|
|
24
32
|
export { ThemeProvider, useTheme, type ThemeProviderProps, } from './theme/ThemeProvider.js';
|
|
33
|
+
export { utilityClassCatalog } from './css/stylesheet.js';
|
|
34
|
+
export type { VisibilityProps } from './visibility-classes.js';
|
|
35
|
+
export { Separator } from './components/Separator.js';
|
|
36
|
+
export type { SeparatorOrientation, SeparatorProps, } from './components/Separator.js';
|
|
37
|
+
export { FilterChips } from './components/FilterChips.js';
|
|
38
|
+
export type { FilterChipOption, FilterChipsProps, } from './components/FilterChips.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
export { ActionMenu, } from './components/ActionMenu.js';
|
|
1
2
|
export { Accordion } from './components/Accordion.js';
|
|
3
|
+
export { Switch } from './components/Switch.js';
|
|
4
|
+
export { DateField } from './components/DateField.js';
|
|
5
|
+
export { Checkbox } from './components/Checkbox.js';
|
|
6
|
+
export { Spinner, } from './components/Spinner.js';
|
|
7
|
+
export { Progress, } from './components/Progress.js';
|
|
8
|
+
export { Tooltip } from './components/Tooltip.js';
|
|
9
|
+
export { RadioGroup, } from './components/RadioGroup.js';
|
|
2
10
|
export { AppHeader } from './components/AppHeader.js';
|
|
3
|
-
export { Badge, } from './components/Badge.js';
|
|
11
|
+
export { Badge, badgeSizes, badgeTones, } from './components/Badge.js';
|
|
4
12
|
export { BarChart, } from './components/BarChart.js';
|
|
5
13
|
export { Button, } from './components/Button.js';
|
|
6
14
|
export { Box } from './components/Box.js';
|
|
@@ -17,3 +25,6 @@ export { Stack, } from './components/Stack.js';
|
|
|
17
25
|
export { Table, TableBody, TableCell, TableHeader, TableRow, } from './components/Table.js';
|
|
18
26
|
export { Text } from './components/Text.js';
|
|
19
27
|
export { ThemeProvider, useTheme, } from './theme/ThemeProvider.js';
|
|
28
|
+
export { utilityClassCatalog } from './css/stylesheet.js';
|
|
29
|
+
export { Separator } from './components/Separator.js';
|
|
30
|
+
export { FilterChips } from './components/FilterChips.js';
|
package/dist/spacing-classes.js
CHANGED