@scalewing/react 1.38.0 → 1.40.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 (162) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +155 -1
  3. package/dist/calendar-month.d.ts +6 -0
  4. package/dist/calendar-month.js +15 -0
  5. package/dist/chart-axis.d.ts +61 -0
  6. package/dist/chart-axis.js +83 -0
  7. package/dist/chart-dates.d.ts +6 -0
  8. package/dist/chart-dates.js +15 -0
  9. package/dist/chart-metrics.d.ts +40 -0
  10. package/dist/chart-metrics.js +48 -0
  11. package/dist/chart-scale.d.ts +48 -0
  12. package/dist/chart-scale.js +116 -0
  13. package/dist/chart-table-rows.d.ts +8 -0
  14. package/dist/chart-table-rows.js +1 -0
  15. package/dist/column-chart-bars.d.ts +38 -0
  16. package/dist/column-chart-bars.js +82 -0
  17. package/dist/column-chart-callouts.d.ts +48 -0
  18. package/dist/column-chart-callouts.js +54 -0
  19. package/dist/column-chart-input.d.ts +40 -0
  20. package/dist/column-chart-input.js +60 -0
  21. package/dist/column-chart-layout.d.ts +63 -0
  22. package/dist/column-chart-layout.js +97 -0
  23. package/dist/components/BarChart.d.ts +1 -1
  24. package/dist/components/BarChart.js +1 -1
  25. package/dist/components/ChartLegend.d.ts +38 -0
  26. package/dist/components/ChartLegend.js +32 -0
  27. package/dist/components/ColumnChart.d.ts +72 -0
  28. package/dist/components/ColumnChart.js +71 -0
  29. package/dist/components/DataBar.d.ts +6 -6
  30. package/dist/components/DateRangeButton.d.ts +65 -0
  31. package/dist/components/DateRangeButton.js +54 -0
  32. package/dist/components/LineChart.d.ts +83 -0
  33. package/dist/components/LineChart.js +77 -0
  34. package/dist/components/ListGroup.d.ts +33 -0
  35. package/dist/components/ListGroup.js +19 -0
  36. package/dist/components/ListRow.d.ts +51 -0
  37. package/dist/components/ListRow.js +59 -0
  38. package/dist/components/NavCount.d.ts +21 -0
  39. package/dist/components/NavCount.js +23 -0
  40. package/dist/components/SectionNav.js +1 -8
  41. package/dist/components/StatTile.d.ts +11 -4
  42. package/dist/components/StatTile.js +11 -4
  43. package/dist/components/{date-field → calendar}/CalendarGrid.d.ts +17 -2
  44. package/dist/components/{date-field → calendar}/CalendarGrid.js +11 -3
  45. package/dist/components/calendar/CalendarPopover.d.ts +25 -0
  46. package/dist/components/calendar/CalendarPopover.js +22 -0
  47. package/dist/components/calendar/MonthStep.d.ts +16 -0
  48. package/dist/components/calendar/MonthStep.js +17 -0
  49. package/dist/components/calendar/use-grid-focus.d.ts +18 -0
  50. package/dist/components/calendar/use-grid-focus.js +35 -0
  51. package/dist/components/calendar/wrap-tab.d.ts +7 -0
  52. package/dist/components/calendar/wrap-tab.js +29 -0
  53. package/dist/components/chart/ChartTable.d.ts +16 -0
  54. package/dist/components/chart/ChartTable.js +12 -0
  55. package/dist/components/chart/ChartValueAxis.d.ts +14 -0
  56. package/dist/components/chart/ChartValueAxis.js +11 -0
  57. package/dist/components/chart/use-chart-width.d.ts +8 -0
  58. package/dist/components/chart/use-chart-width.js +34 -0
  59. package/dist/components/column-chart/ChartCalloutList.d.ts +16 -0
  60. package/dist/components/column-chart/ChartCalloutList.js +13 -0
  61. package/dist/components/column-chart/ColumnChartDrawing.d.ts +17 -0
  62. package/dist/components/column-chart/ColumnChartDrawing.js +18 -0
  63. package/dist/components/date-field/CalendarDialog.js +9 -67
  64. package/dist/components/date-field/CalendarHeader.js +2 -11
  65. package/dist/components/date-range/DateRangePopover.d.ts +7 -0
  66. package/dist/components/date-range/DateRangePopover.js +17 -0
  67. package/dist/components/date-range/DateRangeSheet.d.ts +7 -0
  68. package/dist/components/date-range/DateRangeSheet.js +15 -0
  69. package/dist/components/date-range/RangeMonths.d.ts +28 -0
  70. package/dist/components/date-range/RangeMonths.js +50 -0
  71. package/dist/components/date-range/RangePresets.d.ts +16 -0
  72. package/dist/components/date-range/RangePresets.js +10 -0
  73. package/dist/components/date-range/RangeSummary.d.ts +15 -0
  74. package/dist/components/date-range/RangeSummary.js +11 -0
  75. package/dist/components/date-range/range-panel-props.d.ts +31 -0
  76. package/dist/components/date-range/range-panel-props.js +1 -0
  77. package/dist/components/date-range/use-range-popup.d.ts +21 -0
  78. package/dist/components/date-range/use-range-popup.js +53 -0
  79. package/dist/components/line-chart/LineChartDrawing.d.ts +17 -0
  80. package/dist/components/line-chart/LineChartDrawing.js +16 -0
  81. package/dist/components/link-press.d.ts +7 -0
  82. package/dist/components/link-press.js +13 -0
  83. package/dist/components/list/ListRowAccessoryMark.d.ts +5 -0
  84. package/dist/components/list/ListRowAccessoryMark.js +7 -0
  85. package/dist/components/list/ListRowContent.d.ts +20 -0
  86. package/dist/components/list/ListRowContent.js +10 -0
  87. package/dist/components/list/list-row-container.d.ts +5 -0
  88. package/dist/components/list/list-row-container.js +6 -0
  89. package/dist/components/use-media-query.d.ts +5 -0
  90. package/dist/components/use-media-query.js +18 -0
  91. package/dist/css/chart-marks.d.ts +10 -0
  92. package/dist/css/chart-marks.js +15 -0
  93. package/dist/css/chart-tones.d.ts +68 -0
  94. package/dist/css/chart-tones.js +130 -0
  95. package/dist/css/chevron.d.ts +6 -0
  96. package/dist/css/chevron.js +14 -0
  97. package/dist/css/{css-chart.d.ts → css-bar-chart.d.ts} +2 -2
  98. package/dist/css/{css-chart.js → css-bar-chart.js} +2 -2
  99. package/dist/css/css-button-group-attached.js +8 -4
  100. package/dist/css/css-button-group-track.js +1 -1
  101. package/dist/css/css-chart-legend.d.ts +5 -0
  102. package/dist/css/css-chart-legend.js +102 -0
  103. package/dist/css/css-chart-plot.d.ts +2 -0
  104. package/dist/css/css-chart-plot.js +170 -0
  105. package/dist/css/css-checkbox.js +2 -2
  106. package/dist/css/css-components.js +23 -2
  107. package/dist/css/css-count-pill.d.ts +2 -0
  108. package/dist/css/css-count-pill.js +54 -0
  109. package/dist/css/css-data-bar.d.ts +4 -9
  110. package/dist/css/css-data-bar.js +15 -31
  111. package/dist/css/css-date-field.js +3 -2
  112. package/dist/css/css-date-range-presets.d.ts +2 -0
  113. package/dist/css/css-date-range-presets.js +109 -0
  114. package/dist/css/css-date-range.d.ts +2 -0
  115. package/dist/css/css-date-range.js +197 -0
  116. package/dist/css/css-line-chart.d.ts +2 -0
  117. package/dist/css/css-line-chart.js +31 -0
  118. package/dist/css/css-list-row.d.ts +2 -0
  119. package/dist/css/css-list-row.js +193 -0
  120. package/dist/css/css-list.d.ts +3 -0
  121. package/dist/css/css-list.js +85 -0
  122. package/dist/css/css-scroll-region.d.ts +18 -0
  123. package/dist/css/css-scroll-region.js +41 -0
  124. package/dist/css/css-section-nav-filled.js +2 -25
  125. package/dist/css/css-stat-tile.d.ts +7 -0
  126. package/dist/css/css-stat-tile.js +16 -0
  127. package/dist/css/css-steps.js +2 -2
  128. package/dist/css/css-table-bounded-edges.js +4 -27
  129. package/dist/css/range-band.d.ts +2 -0
  130. package/dist/css/range-band.js +7 -0
  131. package/dist/css/stacking.js +2 -2
  132. package/dist/css/stylesheet.js +16 -2
  133. package/dist/date-range-draft.d.ts +26 -0
  134. package/dist/date-range-draft.js +36 -0
  135. package/dist/date-range-input.d.ts +26 -0
  136. package/dist/date-range-input.js +58 -0
  137. package/dist/date-range-labels.d.ts +22 -0
  138. package/dist/date-range-labels.js +26 -0
  139. package/dist/date-range-view.d.ts +12 -0
  140. package/dist/date-range-view.js +29 -0
  141. package/dist/date-range-words.d.ts +11 -0
  142. package/dist/date-range-words.js +40 -0
  143. package/dist/index.d.ts +9 -1
  144. package/dist/index.js +9 -1
  145. package/dist/is-one-of.d.ts +5 -0
  146. package/dist/is-one-of.js +7 -0
  147. package/dist/line-chart-input.d.ts +39 -0
  148. package/dist/line-chart-input.js +70 -0
  149. package/dist/line-chart-layout.d.ts +68 -0
  150. package/dist/line-chart-layout.js +99 -0
  151. package/dist/line-chart-markers.d.ts +29 -0
  152. package/dist/line-chart-markers.js +57 -0
  153. package/dist/line-chart-path.d.ts +18 -0
  154. package/dist/line-chart-path.js +33 -0
  155. package/dist/line-chart-points.d.ts +6 -0
  156. package/dist/line-chart-points.js +8 -0
  157. package/dist/line-chart-table.d.ts +15 -0
  158. package/dist/line-chart-table.js +29 -0
  159. package/dist/list-options.d.ts +70 -0
  160. package/dist/list-options.js +77 -0
  161. package/dist/styles.css +726 -26
  162. package/package.json +1 -1
@@ -0,0 +1,68 @@
1
+ import { type CategoricalColor } from '@scalewing/tokens';
2
+ /** Where a mark's colour comes from: a semantic or a categorical colour. */
3
+ export type ChartColorSource = {
4
+ semantic: 'accent' | 'success' | 'warning' | 'danger' | 'muted' | 'text';
5
+ } | {
6
+ categorical: CategoricalColor;
7
+ };
8
+ /**
9
+ * A colour mixed into the surface or toward the text colour by a share of
10
+ * its own (1 is the colour unmixed).
11
+ */
12
+ export type ChartColorMix = ChartColorSource & {
13
+ share: number;
14
+ into: 'surface' | 'text';
15
+ };
16
+ /**
17
+ * The statement tones a range bar's fill takes (see DataBar). `danger` is
18
+ * for a shortage, never for cash leaving: an outflow is `muted`.
19
+ */
20
+ export declare const statementFillTones: readonly ["neutral", "success", "muted", "strong", "accent", "danger"];
21
+ /**
22
+ * Every fill tone: the categorical colours (a chart's series), then the
23
+ * statement tones a range bar adds. `neutral` is in both and is one grey.
24
+ */
25
+ export declare const chartFillTones: readonly ("danger" | "muted" | "accent" | "success" | CategoricalColor | "strong")[];
26
+ export type ChartFillTone = CategoricalColor | (typeof statementFillTones)[number];
27
+ /** The tones a line, a marker or the boxed period is drawn in. */
28
+ export declare const chartStrokeTones: readonly ["accent", "success", "warning", "danger", "neutral"];
29
+ export type ChartStrokeTone = (typeof chartStrokeTones)[number];
30
+ /** Every tone a chart or a legend swatch can take. */
31
+ export type ChartTone = ChartFillTone | ChartStrokeTone;
32
+ export declare const chartTones: readonly ChartTone[];
33
+ /**
34
+ * How much of a categorical colour a column's fill mixes into the surface:
35
+ * a lighter fill, so a line drawn over the columns stands apart, that
36
+ * keeps 1.5:1 on the surface in every palette and scheme.
37
+ */
38
+ export declare const categoricalFillShare = 0.72;
39
+ /**
40
+ * How much of the danger colour its fill mixes into the surface (a
41
+ * shortage's range bar, never cash leaving): a light red, at 1.5:1 or more
42
+ * on the surface in every palette and scheme, as every other fill.
43
+ */
44
+ export declare const dangerFillShare = 0.4;
45
+ /** Each fill tone's colour, mixed into the surface. */
46
+ export declare const chartFillMixes: Record<ChartFillTone, ChartColorMix>;
47
+ /** Each stroke tone's colour: a semantic colour, or muted for neutral. */
48
+ export declare const chartStrokeColors: Record<ChartStrokeTone, ChartColorSource>;
49
+ /**
50
+ * How much of a line's stroke the area under it takes, over transparency:
51
+ * a quiet tint behind the line, decorative (the line carries the values).
52
+ */
53
+ export declare const chartAreaShare = 0.12;
54
+ /** How much of a hue's colour its words keep, moved toward the text colour. */
55
+ export declare const categoricalInkShare = 0.3;
56
+ /** How much of a semantic colour its words keep, moved toward the text colour. */
57
+ export declare const semanticInkShare = 0.5;
58
+ /** The tones whose words are drawn beside a mark: a series' and a stroke's. */
59
+ export declare const chartInkTones: readonly ["green", "blue", "orange", "purple", "teal", "rose", "accent", "success", "warning", "danger", "neutral"];
60
+ export type ChartInkTone = (typeof chartInkTones)[number];
61
+ /** The words beside a mark: its tone moved toward the text colour. */
62
+ export declare const chartInkMixes: Record<ChartInkTone, ChartColorMix>;
63
+ /** A mix as CSS: the colour alone when unmixed. */
64
+ export declare function chartColorMix(mix: ChartColorMix): string;
65
+ /** A fill tone's colour. */
66
+ export declare function chartFill(tone: ChartFillTone): string;
67
+ export declare function cssChartToneClasses(): string;
68
+ export declare function chartToneClassCatalog(): string[];
@@ -0,0 +1,130 @@
1
+ import { categoricalColorKeys, categoricalHues, } from '@scalewing/tokens';
2
+ import { isOneOf } from '../is-one-of.js';
3
+ /** A source as its custom property. */
4
+ function sourceProperty(source) {
5
+ return 'semantic' in source
6
+ ? `var(--sw-color-${source.semantic})`
7
+ : `var(--sw-categorical-${source.categorical})`;
8
+ }
9
+ /**
10
+ * The statement tones a range bar's fill takes (see DataBar). `danger` is
11
+ * for a shortage, never for cash leaving: an outflow is `muted`.
12
+ */
13
+ export const statementFillTones = [
14
+ 'neutral',
15
+ 'success',
16
+ 'muted',
17
+ 'strong',
18
+ 'accent',
19
+ 'danger',
20
+ ];
21
+ /**
22
+ * Every fill tone: the categorical colours (a chart's series), then the
23
+ * statement tones a range bar adds. `neutral` is in both and is one grey.
24
+ */
25
+ export const chartFillTones = [
26
+ ...categoricalColorKeys,
27
+ ...statementFillTones.filter((tone) => tone !== 'neutral'),
28
+ ];
29
+ /** The tones a line, a marker or the boxed period is drawn in. */
30
+ export const chartStrokeTones = [
31
+ 'accent',
32
+ 'success',
33
+ 'warning',
34
+ 'danger',
35
+ 'neutral',
36
+ ];
37
+ export const chartTones = [
38
+ ...new Set([...chartFillTones, ...chartStrokeTones]),
39
+ ];
40
+ /**
41
+ * How much of a categorical colour a column's fill mixes into the surface:
42
+ * a lighter fill, so a line drawn over the columns stands apart, that
43
+ * keeps 1.5:1 on the surface in every palette and scheme.
44
+ */
45
+ export const categoricalFillShare = 0.72;
46
+ /**
47
+ * How much of the danger colour its fill mixes into the surface (a
48
+ * shortage's range bar, never cash leaving): a light red, at 1.5:1 or more
49
+ * on the surface in every palette and scheme, as every other fill.
50
+ */
51
+ export const dangerFillShare = 0.4;
52
+ /** Each fill tone's colour, mixed into the surface. */
53
+ export const chartFillMixes = {
54
+ ...Object.fromEntries(categoricalHues.map((hue) => [
55
+ hue,
56
+ { categorical: hue, share: categoricalFillShare, into: 'surface' },
57
+ ])),
58
+ neutral: { semantic: 'muted', share: 0.65, into: 'surface' },
59
+ success: { semantic: 'success', share: 0.55, into: 'surface' },
60
+ muted: { semantic: 'muted', share: 0.35, into: 'surface' },
61
+ strong: { semantic: 'text', share: 0.85, into: 'surface' },
62
+ accent: { semantic: 'accent', share: 1, into: 'surface' },
63
+ danger: { semantic: 'danger', share: dangerFillShare, into: 'surface' },
64
+ };
65
+ /** Each stroke tone's colour: a semantic colour, or muted for neutral. */
66
+ export const chartStrokeColors = {
67
+ accent: { semantic: 'accent' },
68
+ success: { semantic: 'success' },
69
+ warning: { semantic: 'warning' },
70
+ danger: { semantic: 'danger' },
71
+ neutral: { semantic: 'muted' },
72
+ };
73
+ /**
74
+ * How much of a line's stroke the area under it takes, over transparency:
75
+ * a quiet tint behind the line, decorative (the line carries the values).
76
+ */
77
+ export const chartAreaShare = 0.12;
78
+ /** How much of a hue's colour its words keep, moved toward the text colour. */
79
+ export const categoricalInkShare = 0.3;
80
+ /** How much of a semantic colour its words keep, moved toward the text colour. */
81
+ export const semanticInkShare = 0.5;
82
+ /** The tones whose words are drawn beside a mark: a series' and a stroke's. */
83
+ export const chartInkTones = [...categoricalHues, ...chartStrokeTones];
84
+ /** The words beside a mark: its tone moved toward the text colour. */
85
+ export const chartInkMixes = {
86
+ ...Object.fromEntries(categoricalHues.map((hue) => [
87
+ hue,
88
+ { categorical: hue, share: categoricalInkShare, into: 'text' },
89
+ ])),
90
+ accent: { semantic: 'accent', share: semanticInkShare, into: 'text' },
91
+ success: { semantic: 'success', share: semanticInkShare, into: 'text' },
92
+ warning: { semantic: 'warning', share: semanticInkShare, into: 'text' },
93
+ danger: { semantic: 'danger', share: semanticInkShare, into: 'text' },
94
+ neutral: { semantic: 'muted', share: 1, into: 'text' },
95
+ };
96
+ /** A mix as CSS: the colour alone when unmixed. */
97
+ export function chartColorMix(mix) {
98
+ const color = sourceProperty(mix);
99
+ if (mix.share === 1)
100
+ return color;
101
+ return `color-mix(in srgb, ${color} ${Math.round(mix.share * 100)}%, var(--sw-color-${mix.into}))`;
102
+ }
103
+ /** A fill tone's colour. */
104
+ export function chartFill(tone) {
105
+ return chartColorMix(chartFillMixes[tone]);
106
+ }
107
+ /*
108
+ * A tone class hands its roles to the marks inside it as custom
109
+ * properties, `--sw-chart-fill`, `--sw-chart-stroke` and `--sw-chart-ink`,
110
+ * so a legend swatch, a column, a line and a label each read the role it
111
+ * draws. A tone sets only the roles it has.
112
+ */
113
+ function toneDeclarations(tone) {
114
+ const declarations = [];
115
+ if (isOneOf(chartFillTones, tone))
116
+ declarations.push(`--sw-chart-fill: ${chartFill(tone)};`);
117
+ if (isOneOf(chartStrokeTones, tone))
118
+ declarations.push(`--sw-chart-stroke: ${sourceProperty(chartStrokeColors[tone])};`);
119
+ if (isOneOf(chartInkTones, tone))
120
+ declarations.push(`--sw-chart-ink: ${chartColorMix(chartInkMixes[tone])};`);
121
+ return declarations.join(' ');
122
+ }
123
+ export function cssChartToneClasses() {
124
+ return chartTones
125
+ .map((tone) => `.sw-chart-tone-${tone} { ${toneDeclarations(tone)} }`)
126
+ .join('\n');
127
+ }
128
+ export function chartToneClassCatalog() {
129
+ return chartTones.map((tone) => `sw-chart-tone-${tone}`);
130
+ }
@@ -6,3 +6,9 @@
6
6
  export declare function chevronStrokeIn(color: string): string;
7
7
  /** The muted chevron Accordion, Select and the menus share. */
8
8
  export declare const chevronStroke: string;
9
+ /**
10
+ * A check's two strokes in `color`: the bottom and right borders of a box
11
+ * the caller sizes and turns 45°, so forced colours keep them. Checkbox,
12
+ * Steps and ListRow share it.
13
+ */
14
+ export declare function checkStrokeIn(color: string): string;
@@ -1,3 +1,8 @@
1
+ /*
2
+ * The strokes of Scalewing's private control chrome, drawn with borders so
3
+ * forced colours keep them: the chevron (Accordion, Select, the menus,
4
+ * Pagination, ListRow) and the check (Checkbox, Steps, ListRow).
5
+ */
1
6
  /**
2
7
  * A stroked chevron in `color`: two sides of a `space-2` square (its
3
8
  * bottom and right borders, so forced colours keep it), turned by each
@@ -12,3 +17,12 @@ export function chevronStrokeIn(color) {
12
17
  }
13
18
  /** The muted chevron Accordion, Select and the menus share. */
14
19
  export const chevronStroke = chevronStrokeIn('var(--sw-color-muted)');
20
+ /**
21
+ * A check's two strokes in `color`: the bottom and right borders of a box
22
+ * the caller sizes and turns 45°, so forced colours keep them. Checkbox,
23
+ * Steps and ListRow share it.
24
+ */
25
+ export function checkStrokeIn(color) {
26
+ return `border-bottom: 2px solid ${color};
27
+ border-right: 2px solid ${color};`;
28
+ }
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export declare const barChartTones: readonly ["accent", "success", "warning", "danger"];
7
7
  export type BarChartTone = (typeof barChartTones)[number];
8
- export declare function cssChartClasses(): string;
9
- export declare function chartClassCatalog(): string[];
8
+ export declare function cssBarChartClasses(): string;
9
+ export declare function barChartClassCatalog(): string[];
@@ -66,7 +66,7 @@ function divergingRules() {
66
66
  .sw-bar-chart-diverging .sw-bar-chart-track::before { background: CanvasText; }
67
67
  }`;
68
68
  }
69
- export function cssChartClasses() {
69
+ export function cssBarChartClasses() {
70
70
  return `.sw-bar-chart {
71
71
  display: grid;
72
72
  gap: var(--sw-space-2);
@@ -155,7 +155,7 @@ ${divergingRules()}
155
155
  .sw-bar-chart-fill { background: CanvasText; }
156
156
  }`;
157
157
  }
158
- export function chartClassCatalog() {
158
+ export function barChartClassCatalog() {
159
159
  return [
160
160
  'sw-bar-chart',
161
161
  'sw-bar-chart-plot',
@@ -13,6 +13,10 @@ import { joinedZIndex } from './stacking.js';
13
13
  * divider in its own text colour at low strength, so a joined row of them
14
14
  * still reads as separate buttons; forced colours draw every border.
15
15
  *
16
+ * The buttons are found by type, not by place, so an open calendar a
17
+ * button renders beside itself (CalendarButton, DateRangeButton) does not
18
+ * cost the next button its divider or the last one its rounded corners.
19
+ *
16
20
  * The group is its own stacking context: a pressed button's ring paints
17
21
  * over its neighbours and the focused button's standard outer ring over
18
22
  * both, so neither is covered by the next button.
@@ -33,21 +37,21 @@ ${group} > .sw-button {
33
37
  border-radius: 0;
34
38
  }
35
39
 
36
- ${group} > .sw-button + .sw-button {
40
+ ${group} > .sw-button ~ .sw-button {
37
41
  margin-inline-start: -1px;
38
42
  }
39
43
 
40
- ${group} > .sw-button:first-child {
44
+ ${group} > .sw-button:first-of-type {
41
45
  border-end-start-radius: var(--sw-radius-sm);
42
46
  border-start-start-radius: var(--sw-radius-sm);
43
47
  }
44
48
 
45
- ${group} > .sw-button:last-child {
49
+ ${group} > .sw-button:last-of-type {
46
50
  border-end-end-radius: var(--sw-radius-sm);
47
51
  border-start-end-radius: var(--sw-radius-sm);
48
52
  }
49
53
 
50
- ${group} > .sw-button + .sw-button:not(.sw-button-secondary) {
54
+ ${group} > .sw-button ~ .sw-button:not(.sw-button-secondary) {
51
55
  border-inline-start-color: color-mix(in srgb, currentColor 30%, transparent);
52
56
  }
53
57
 
@@ -30,7 +30,7 @@ ${track} > .sw-button {
30
30
  color: var(--sw-color-text);
31
31
  }
32
32
 
33
- ${track} > .sw-button + .sw-button {
33
+ ${track} > .sw-button ~ .sw-button {
34
34
  border-inline-start-color: var(--sw-color-border);
35
35
  }
36
36
 
@@ -0,0 +1,5 @@
1
+ /** The marks a legend item can show: what its words name in the chart. */
2
+ export declare const chartLegendSwatches: readonly ["bar", "line", "marker", "box"];
3
+ export type ChartLegendSwatch = (typeof chartLegendSwatches)[number];
4
+ export declare function cssChartLegendClasses(): string;
5
+ export declare function chartLegendClassCatalog(): string[];
@@ -0,0 +1,102 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { chartHairline, chartLineWidth } from './chart-marks.js';
3
+ const caption = typographyVariants.caption;
4
+ /** The marks a legend item can show: what its words name in the chart. */
5
+ export const chartLegendSwatches = ['bar', 'line', 'marker', 'box'];
6
+ /*
7
+ * Each swatch reads its colour from the item's tone class
8
+ * (`sw-chart-tone-<tone>`, `chart-tones.ts`): a bar is the tone's fill, a
9
+ * square a spacing step 3 wide; a line is its stroke, a spacing step 4
10
+ * long at the charts' line width; a marker is a downward triangle in the
11
+ * stroke, the shape a chart's marker takes; a box is the dashed outline of
12
+ * the boxed current period. Forced colours draw every swatch in the system
13
+ * text colour, as they draw the marks.
14
+ */
15
+ function swatchRules() {
16
+ return `.sw-chart-legend-bar {
17
+ background: var(--sw-chart-fill);
18
+ border-radius: calc(var(--sw-radius-sm) / 4);
19
+ height: var(--sw-space-3);
20
+ width: var(--sw-space-3);
21
+ }
22
+
23
+ .sw-chart-legend-line {
24
+ background: var(--sw-chart-stroke);
25
+ border-radius: var(--sw-radius-pill);
26
+ height: ${chartLineWidth}px;
27
+ width: var(--sw-space-4);
28
+ }
29
+
30
+ .sw-chart-legend-marker {
31
+ background: var(--sw-chart-stroke);
32
+ clip-path: polygon(0 0, 100% 0, 50% 100%);
33
+ height: var(--sw-space-3);
34
+ width: var(--sw-space-3);
35
+ }
36
+
37
+ .sw-chart-legend-box {
38
+ border: ${chartHairline}px dashed var(--sw-chart-stroke);
39
+ border-radius: calc(var(--sw-radius-sm) / 2);
40
+ box-sizing: border-box;
41
+ height: var(--sw-space-3);
42
+ width: var(--sw-space-4);
43
+ }
44
+
45
+ @media (forced-colors: active) {
46
+ .sw-chart-legend-bar,
47
+ .sw-chart-legend-line,
48
+ .sw-chart-legend-marker { background: CanvasText; }
49
+ .sw-chart-legend-box { border-color: CanvasText; }
50
+ }`;
51
+ }
52
+ /*
53
+ * A legend is a list of its items in a wrapping row, in the caption type:
54
+ * each item its swatch, then its words. The words wrap within the item
55
+ * rather than push the row past its container, and the swatch stays
56
+ * centred on their first line.
57
+ */
58
+ export function cssChartLegendClasses() {
59
+ return `.sw-chart-legend {
60
+ color: var(--sw-color-text);
61
+ column-gap: var(--sw-space-5);
62
+ display: flex;
63
+ flex-wrap: wrap;
64
+ font-family: var(--sw-font-sans);
65
+ font-size: ${caption.fontSize}px;
66
+ font-weight: ${caption.fontWeight};
67
+ letter-spacing: ${caption.letterSpacing}px;
68
+ line-height: ${caption.lineHeight}px;
69
+ list-style: none;
70
+ margin: 0;
71
+ padding: 0;
72
+ row-gap: var(--sw-space-2);
73
+ }
74
+
75
+ .sw-chart-legend-item {
76
+ align-items: flex-start;
77
+ display: inline-flex;
78
+ gap: var(--sw-space-2);
79
+ min-width: 0;
80
+ }
81
+
82
+ .sw-chart-legend-swatch {
83
+ display: block;
84
+ flex: none;
85
+ /* Centred on the first line of the words, however many lines they wrap to. */
86
+ margin-block-start: calc((${caption.lineHeight}px - var(--sw-space-3)) / 2);
87
+ }
88
+
89
+ .sw-chart-legend-line {
90
+ margin-block-start: calc((${caption.lineHeight}px - ${chartLineWidth}px) / 2);
91
+ }
92
+
93
+ ${swatchRules()}`;
94
+ }
95
+ export function chartLegendClassCatalog() {
96
+ return [
97
+ 'sw-chart-legend',
98
+ 'sw-chart-legend-item',
99
+ 'sw-chart-legend-swatch',
100
+ ...chartLegendSwatches.map((swatch) => `sw-chart-legend-${swatch}`),
101
+ ];
102
+ }
@@ -0,0 +1,2 @@
1
+ export declare function cssChartPlotClasses(): string;
2
+ export declare function chartPlotClassCatalog(): string[];
@@ -0,0 +1,170 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { chartBoxDash, chartHairline, chartLeaderDash, chartLineWidth, } from './chart-marks.js';
3
+ const caption = typographyVariants.caption;
4
+ /*
5
+ * The parts every plotted chart (ColumnChart, LineChart) draws in its SVG:
6
+ * the words in the caption type, the grid and zero lines, the boxed
7
+ * period, a line and its last value, and the callouts with their leaders.
8
+ * Every colour is a theme colour or a tone's role (`chart-tones.ts`), read
9
+ * from the tone class on the mark or its group; words with no tone are
10
+ * the text colour.
11
+ */
12
+ function plotRules() {
13
+ return `.sw-chart {
14
+ display: grid;
15
+ gap: var(--sw-space-2);
16
+ min-width: 0;
17
+ }
18
+
19
+ .sw-chart-svg {
20
+ display: block;
21
+ font-family: var(--sw-font-sans);
22
+ font-size: ${caption.fontSize}px;
23
+ height: auto;
24
+ letter-spacing: ${caption.letterSpacing}px;
25
+ max-width: 100%;
26
+ overflow: visible;
27
+ width: 100%;
28
+ }
29
+
30
+ .sw-chart-tick,
31
+ .sw-chart-category {
32
+ fill: var(--sw-color-muted);
33
+ font-variant-numeric: tabular-nums;
34
+ }
35
+
36
+ .sw-chart-tick-line { fill: var(--sw-chart-ink); }
37
+
38
+ .sw-chart-grid {
39
+ stroke: var(--sw-color-border);
40
+ stroke-width: ${chartHairline};
41
+ }
42
+
43
+ .sw-chart-zero {
44
+ stroke: var(--sw-color-muted);
45
+ stroke-width: ${chartHairline};
46
+ }
47
+
48
+ .sw-chart-highlight {
49
+ fill: none;
50
+ stroke: var(--sw-chart-stroke);
51
+ stroke-dasharray: ${chartBoxDash};
52
+ stroke-width: ${chartHairline};
53
+ }
54
+
55
+ .sw-chart-line {
56
+ fill: none;
57
+ stroke: var(--sw-chart-stroke);
58
+ stroke-linecap: round;
59
+ stroke-linejoin: round;
60
+ stroke-width: ${chartLineWidth};
61
+ }
62
+
63
+ .sw-chart-dot { fill: var(--sw-chart-stroke); }
64
+
65
+ .sw-chart-end-label {
66
+ fill: var(--sw-chart-ink);
67
+ font-variant-numeric: tabular-nums;
68
+ font-weight: 600;
69
+ }
70
+
71
+ .sw-chart-leader {
72
+ stroke: var(--sw-chart-ink, var(--sw-color-text));
73
+ stroke-dasharray: ${chartLeaderDash};
74
+ stroke-width: ${chartHairline};
75
+ }
76
+
77
+ .sw-chart-callout-text {
78
+ fill: var(--sw-chart-ink, var(--sw-color-text));
79
+ font-weight: 600;
80
+ }`;
81
+ }
82
+ /*
83
+ * On a compact chart the callouts are a list under the plot: each its
84
+ * words in its hue's ink, after a dot in its hue's fill (the colour of its
85
+ * column) centred on their first line.
86
+ */
87
+ function calloutListRules() {
88
+ return `.sw-chart-callouts {
89
+ display: grid;
90
+ font-family: var(--sw-font-sans);
91
+ font-size: ${caption.fontSize}px;
92
+ gap: var(--sw-space-1);
93
+ letter-spacing: ${caption.letterSpacing}px;
94
+ line-height: ${caption.lineHeight}px;
95
+ list-style: none;
96
+ margin: 0;
97
+ padding: 0;
98
+ }
99
+
100
+ .sw-chart-callout {
101
+ align-items: flex-start;
102
+ color: var(--sw-chart-ink, var(--sw-color-text));
103
+ display: flex;
104
+ font-weight: 600;
105
+ gap: var(--sw-space-2);
106
+ }
107
+
108
+ .sw-chart-callout-dot {
109
+ background: var(--sw-chart-fill, currentColor);
110
+ border-radius: var(--sw-radius-pill);
111
+ flex: none;
112
+ height: var(--sw-space-2);
113
+ margin-block-start: calc((${caption.lineHeight}px - var(--sw-space-2)) / 2);
114
+ width: var(--sw-space-2);
115
+ }`;
116
+ }
117
+ /*
118
+ * Forced colours keep the drawing legible in the system colours: marks in
119
+ * the text colour (columns outlined in the canvas colour so a stack's
120
+ * parts stay apart), the line and its last value in the highlight colour,
121
+ * grid lines in the grey text colour, and every word in the text colour.
122
+ * The hidden table carries the figures there as everywhere.
123
+ */
124
+ function forcedColorRules() {
125
+ return `@media (forced-colors: active) {
126
+ .sw-chart-column { fill: CanvasText; stroke: Canvas; }
127
+ .sw-chart-grid { stroke: GrayText; }
128
+ .sw-chart-zero,
129
+ .sw-chart-highlight,
130
+ .sw-chart-leader { stroke: CanvasText; }
131
+ .sw-chart-line { stroke: Highlight; }
132
+ .sw-chart-dot,
133
+ .sw-chart-end-label { fill: Highlight; }
134
+ .sw-chart-tick,
135
+ .sw-chart-category,
136
+ .sw-chart-callout-text { fill: CanvasText; }
137
+ .sw-chart-callout { color: CanvasText; }
138
+ .sw-chart-callout-dot { background: CanvasText; }
139
+ }`;
140
+ }
141
+ export function cssChartPlotClasses() {
142
+ return `${plotRules()}
143
+
144
+ .sw-chart-column { fill: var(--sw-chart-fill); }
145
+
146
+ ${calloutListRules()}
147
+
148
+ ${forcedColorRules()}`;
149
+ }
150
+ export function chartPlotClassCatalog() {
151
+ return [
152
+ 'sw-chart',
153
+ 'sw-chart-svg',
154
+ 'sw-chart-tick',
155
+ 'sw-chart-tick-line',
156
+ 'sw-chart-category',
157
+ 'sw-chart-grid',
158
+ 'sw-chart-zero',
159
+ 'sw-chart-highlight',
160
+ 'sw-chart-line',
161
+ 'sw-chart-dot',
162
+ 'sw-chart-end-label',
163
+ 'sw-chart-leader',
164
+ 'sw-chart-callout-text',
165
+ 'sw-chart-column',
166
+ 'sw-chart-callouts',
167
+ 'sw-chart-callout',
168
+ 'sw-chart-callout-dot',
169
+ ];
170
+ }
@@ -1,4 +1,5 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
+ import { checkStrokeIn } from './chevron.js';
2
3
  const label = typographyVariants.label;
3
4
  const caption = typographyVariants.caption;
4
5
  export function cssCheckboxClasses() {
@@ -49,8 +50,7 @@ export function cssCheckboxClasses() {
49
50
  }
50
51
 
51
52
  .sw-checkbox-mark::after {
52
- border-bottom: 2px solid var(--sw-color-surface);
53
- border-right: 2px solid var(--sw-color-surface);
53
+ ${checkStrokeIn('var(--sw-color-surface)')}
54
54
  content: '';
55
55
  display: none;
56
56
  height: var(--sw-space-2);
@@ -1,9 +1,16 @@
1
+ import { cssChartToneClasses } from './chart-tones.js';
1
2
  import { cssActionBarClasses } from './css-action-bar.js';
2
3
  import { cssActionMenuClasses } from './css-action-menu.js';
3
4
  import { cssAccordionClasses } from './css-accordion.js';
4
5
  import { cssButtonClasses } from './css-button.js';
5
6
  import { cssCalendarButtonClasses } from './css-calendar-button.js';
6
- import { cssChartClasses } from './css-chart.js';
7
+ import { cssDateRangeClasses } from './css-date-range.js';
8
+ import { cssListClasses } from './css-list.js';
9
+ import { cssCountPillClasses } from './css-count-pill.js';
10
+ import { cssBarChartClasses } from './css-bar-chart.js';
11
+ import { cssChartLegendClasses } from './css-chart-legend.js';
12
+ import { cssChartPlotClasses } from './css-chart-plot.js';
13
+ import { cssLineChartClasses } from './css-line-chart.js';
7
14
  import { cssDataBarClasses } from './css-data-bar.js';
8
15
  import { cssPaginationClasses } from './css-pagination.js';
9
16
  import { cssCheckboxClasses } from './css-checkbox.js';
@@ -137,10 +144,24 @@ ${cssDateFieldClasses()}
137
144
 
138
145
  ${cssCalendarButtonClasses()}
139
146
 
140
- ${cssChartClasses()}
147
+ ${cssDateRangeClasses()}
148
+
149
+ ${cssListClasses()}
150
+
151
+ ${cssCountPillClasses()}
152
+
153
+ ${cssBarChartClasses()}
141
154
 
142
155
  ${cssDataBarClasses()}
143
156
 
157
+ ${cssChartToneClasses()}
158
+
159
+ ${cssChartLegendClasses()}
160
+
161
+ ${cssChartPlotClasses()}
162
+
163
+ ${cssLineChartClasses()}
164
+
144
165
  ${cssPaginationClasses()}
145
166
 
146
167
  ${cssChromeClasses()}
@@ -0,0 +1,2 @@
1
+ export declare function cssCountPillClasses(): string;
2
+ export declare function countPillClassCatalog(): string[];