grommet 2.48.0 → 2.50.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/components/AccordionPanel/AccordionPanel.js +3 -6
- package/components/Anchor/StyledAnchor.js +1 -1
- package/components/Box/StyledBox.js +1 -1
- package/components/Button/BusyAnimation.js +5 -1
- package/components/Button/Button.js +3 -1
- package/components/Calendar/Calendar.js +7 -10
- package/components/Cards/Cards.js +3 -4
- package/components/Chart/Chart.js +11 -9
- package/components/Chart/calcs.js +21 -13
- package/components/CheckBox/CheckBox.js +1 -1
- package/components/CheckBoxGroup/CheckBoxGroup.js +2 -3
- package/components/Data/Data.js +5 -1
- package/components/Data/DataForm.js +6 -4
- package/components/Data/stories/Infinite.stories.js +10 -15
- package/components/Data/stories/OnSelect.stories.js +10 -15
- package/components/Data/stories/SpaceX.stories.js +10 -15
- package/components/Data/stories/StarWars.stories.js +6 -8
- package/components/DataChart/DataChart.js +14 -12
- package/components/DataChart/Detail.js +2 -2
- package/components/DataChart/Legend.js +8 -9
- package/components/DataChart/utils.js +15 -8
- package/components/DataFilter/DataFilter.js +10 -9
- package/components/DataFilters/DataFilters.js +9 -10
- package/components/DataSearch/DataSearch.js +5 -4
- package/components/DataSort/DataSort.js +4 -3
- package/components/DataSummary/DataSummary.js +6 -6
- package/components/DataTable/ExpanderCell.js +6 -3
- package/components/DataTable/Footer.js +6 -3
- package/components/DataTable/Header.js +6 -3
- package/components/DataTable/Resizer.js +22 -8
- package/components/DataTable/Searcher.js +5 -7
- package/components/DataTable/stories/ResizePinned.stories.js +321 -0
- package/components/DataTable/stories/SpaceX.stories.js +15 -16
- package/components/DataTable/stories/SpaceXUngrouped.stories.js +7 -7
- package/components/DataTable/stories/rowDetails.stories.js +6 -8
- package/components/DataTableColumns/DataTableColumns.js +24 -22
- package/components/DateInput/DateInput.js +7 -6
- package/components/Distribution/Distribution.js +8 -5
- package/components/FileInput/FileInput.js +41 -36
- package/components/Footer/Footer.js +5 -1
- package/components/Header/Header.js +2 -2
- package/components/Layer/Layer.js +10 -5
- package/components/Layer/StyledLayer.js +2 -2
- package/components/List/List.js +5 -4
- package/components/MaskedInput/MaskedInput.js +6 -1
- package/components/Menu/Menu.js +13 -1
- package/components/Meter/Bar.js +38 -17
- package/components/Meter/Circle.js +31 -46
- package/components/Meter/stories/Circle.stories.js +6 -8
- package/components/Meter/utils.js +15 -1
- package/components/Nav/Nav.js +5 -1
- package/components/Notification/Notification.js +6 -8
- package/components/Pagination/Pagination.js +5 -10
- package/components/Pagination/PaginationStep.js +2 -1
- package/components/Paragraph/ParagraphSkeleton.js +2 -1
- package/components/RadioButton/RadioButton.js +1 -1
- package/components/RadioButtonGroup/RadioButtonGroup.js +2 -2
- package/components/RangeSelector/RangeSelector.js +2 -6
- package/components/Select/SelectContainer.js +2 -1
- package/components/SelectMultiple/SelectMultipleContainer.js +8 -4
- package/components/SelectMultiple/SelectMultipleValue.js +5 -7
- package/components/SelectMultiple/SelectionSummary.js +7 -8
- package/components/Sidebar/Sidebar.js +6 -3
- package/components/Spinner/Spinner.js +7 -4
- package/components/StarRating/StarRating.js +8 -5
- package/components/Tab/Tab.js +2 -1
- package/components/Table/StyledTable.js +2 -2
- package/components/Tabs/Tabs.js +8 -12
- package/components/Tag/StyledTag.js +9 -1
- package/components/TextInput/CopyButton.js +3 -2
- package/components/TextInput/TextInput.js +5 -0
- package/components/ThumbsRating/ThumbsRating.js +15 -10
- package/components/Toolbar/Toolbar.js +15 -11
- package/components/Video/Video.js +3 -5
- package/es6/components/AccordionPanel/AccordionPanel.js +3 -6
- package/es6/components/Anchor/StyledAnchor.js +2 -2
- package/es6/components/Box/StyledBox.js +1 -1
- package/es6/components/Button/BusyAnimation.js +5 -1
- package/es6/components/Button/Button.js +3 -1
- package/es6/components/Calendar/Calendar.js +7 -10
- package/es6/components/Cards/Cards.js +3 -4
- package/es6/components/Chart/Chart.js +11 -9
- package/es6/components/Chart/calcs.js +21 -13
- package/es6/components/CheckBox/CheckBox.js +1 -1
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +2 -3
- package/es6/components/Data/Data.js +5 -1
- package/es6/components/Data/DataForm.js +6 -4
- package/es6/components/Data/stories/Infinite.stories.js +10 -15
- package/es6/components/Data/stories/OnSelect.stories.js +10 -15
- package/es6/components/Data/stories/SpaceX.stories.js +10 -15
- package/es6/components/Data/stories/StarWars.stories.js +6 -8
- package/es6/components/DataChart/DataChart.js +14 -12
- package/es6/components/DataChart/Detail.js +2 -2
- package/es6/components/DataChart/Legend.js +8 -9
- package/es6/components/DataChart/utils.js +15 -8
- package/es6/components/DataFilter/DataFilter.js +10 -9
- package/es6/components/DataFilters/DataFilters.js +9 -10
- package/es6/components/DataSearch/DataSearch.js +5 -4
- package/es6/components/DataSort/DataSort.js +4 -3
- package/es6/components/DataSummary/DataSummary.js +6 -6
- package/es6/components/DataTable/ExpanderCell.js +4 -1
- package/es6/components/DataTable/Footer.js +4 -1
- package/es6/components/DataTable/Header.js +6 -3
- package/es6/components/DataTable/Resizer.js +22 -8
- package/es6/components/DataTable/Searcher.js +5 -7
- package/es6/components/DataTable/stories/ResizePinned.stories.js +316 -0
- package/es6/components/DataTable/stories/SpaceX.stories.js +15 -16
- package/es6/components/DataTable/stories/SpaceXUngrouped.stories.js +7 -7
- package/es6/components/DataTable/stories/rowDetails.stories.js +6 -8
- package/es6/components/DataTableColumns/DataTableColumns.js +23 -21
- package/es6/components/DateInput/DateInput.js +6 -5
- package/es6/components/Distribution/Distribution.js +8 -5
- package/es6/components/FileInput/FileInput.js +42 -37
- package/es6/components/Footer/Footer.js +5 -1
- package/es6/components/Header/Header.js +2 -2
- package/es6/components/Layer/Layer.js +10 -5
- package/es6/components/Layer/StyledLayer.js +3 -3
- package/es6/components/List/List.js +5 -4
- package/es6/components/MaskedInput/MaskedInput.js +6 -1
- package/es6/components/Menu/Menu.js +13 -1
- package/es6/components/Meter/Bar.js +39 -18
- package/es6/components/Meter/Circle.js +33 -48
- package/es6/components/Meter/stories/Circle.stories.js +7 -9
- package/es6/components/Meter/utils.js +14 -0
- package/es6/components/Nav/Nav.js +5 -1
- package/es6/components/Notification/Notification.js +6 -8
- package/es6/components/Pagination/Pagination.js +5 -10
- package/es6/components/Pagination/PaginationStep.js +2 -1
- package/es6/components/Paragraph/ParagraphSkeleton.js +2 -1
- package/es6/components/RadioButton/RadioButton.js +1 -1
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +2 -2
- package/es6/components/RangeSelector/RangeSelector.js +2 -6
- package/es6/components/Select/SelectContainer.js +2 -1
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +8 -4
- package/es6/components/SelectMultiple/SelectMultipleValue.js +5 -7
- package/es6/components/SelectMultiple/SelectionSummary.js +7 -8
- package/es6/components/Sidebar/Sidebar.js +6 -3
- package/es6/components/Spinner/Spinner.js +6 -3
- package/es6/components/StarRating/StarRating.js +8 -5
- package/es6/components/Tab/Tab.js +2 -1
- package/es6/components/Table/StyledTable.js +2 -2
- package/es6/components/Tabs/Tabs.js +8 -12
- package/es6/components/Tag/StyledTag.js +10 -2
- package/es6/components/TextInput/CopyButton.js +3 -2
- package/es6/components/TextInput/TextInput.js +5 -0
- package/es6/components/ThumbsRating/ThumbsRating.js +15 -10
- package/es6/components/Toolbar/Toolbar.js +15 -11
- package/es6/components/Video/Video.js +3 -5
- package/es6/themes/base.d.ts +284 -4
- package/es6/themes/base.js +369 -21
- package/es6/utils/graphics.js +123 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +46 -46
- package/themes/base.d.ts +284 -4
- package/themes/base.js +369 -21
- package/utils/graphics.js +124 -1
package/utils/graphics.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.translateEndAngle = exports.polarToCartesian = exports.baseUnit = exports.arcCommands = void 0;
|
|
4
|
+
exports.wedgeCommands = exports.translateEndAngle = exports.polarToCartesian = exports.lineCommands = exports.calcAngle = exports.baseUnit = exports.arcCommands = void 0;
|
|
5
5
|
var POST_DECIMAL_DIGITS = 10;
|
|
6
6
|
var baseUnit = exports.baseUnit = 24;
|
|
7
7
|
var polarToCartesian = exports.polarToCartesian = function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
|
@@ -11,6 +11,44 @@ var polarToCartesian = exports.polarToCartesian = function polarToCartesian(cent
|
|
|
11
11
|
y: centerY + radius * Math.sin(angleInRadians)
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
var intersection = function intersection(line1Point1, line1Point2, line2Point1, line2Point2) {
|
|
15
|
+
var x1 = line1Point1.x,
|
|
16
|
+
y1 = line1Point1.y;
|
|
17
|
+
var x2 = line1Point2.x,
|
|
18
|
+
y2 = line1Point2.y;
|
|
19
|
+
var x3 = line2Point1.x,
|
|
20
|
+
y3 = line2Point1.y;
|
|
21
|
+
var x4 = line2Point2.x,
|
|
22
|
+
y4 = line2Point2.y;
|
|
23
|
+
|
|
24
|
+
// Calculate the denominator
|
|
25
|
+
var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
|
|
26
|
+
|
|
27
|
+
// Check if lines are parallel (denominator is 0)
|
|
28
|
+
if (Math.abs(denominator) < 1e-10) {
|
|
29
|
+
return null; // Lines are parallel or coincident
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Calculate the intersection point
|
|
33
|
+
var t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denominator;
|
|
34
|
+
var u = -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denominator;
|
|
35
|
+
|
|
36
|
+
// Calculate intersection coordinates
|
|
37
|
+
var intersectionX = x1 + t * (x2 - x1);
|
|
38
|
+
var intersectionY = y1 + t * (y2 - y1);
|
|
39
|
+
return {
|
|
40
|
+
x: intersectionX,
|
|
41
|
+
y: intersectionY,
|
|
42
|
+
// Optional: check if intersection is within line segments
|
|
43
|
+
withinSegment1: t >= 0 && t <= 1,
|
|
44
|
+
withinSegment2: u >= 0 && u <= 1
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
var lineCommands = exports.lineCommands = function lineCommands(centerX, centerY, radius, angle) {
|
|
48
|
+
var start = polarToCartesian(centerX, centerY, radius, angle);
|
|
49
|
+
var d = ['M', centerX.toFixed(POST_DECIMAL_DIGITS), centerY.toFixed(POST_DECIMAL_DIGITS), 'L', start.x.toFixed(POST_DECIMAL_DIGITS), start.y.toFixed(POST_DECIMAL_DIGITS)].join(' ');
|
|
50
|
+
return d;
|
|
51
|
+
};
|
|
14
52
|
var arcCommands = exports.arcCommands = function arcCommands(centerX, centerY, radius, startAngle, endAngle) {
|
|
15
53
|
// handle that we can't draw a complete circle
|
|
16
54
|
var normalizedEndAngle = endAngle;
|
|
@@ -28,6 +66,91 @@ var arcCommands = exports.arcCommands = function arcCommands(centerX, centerY, r
|
|
|
28
66
|
var d = ['M', start.x.toFixed(POST_DECIMAL_DIGITS), start.y.toFixed(POST_DECIMAL_DIGITS), 'A', radius.toFixed(POST_DECIMAL_DIGITS), radius.toFixed(POST_DECIMAL_DIGITS), 0, arcSweep, 0, end.x.toFixed(POST_DECIMAL_DIGITS), end.y.toFixed(POST_DECIMAL_DIGITS)].join(' ');
|
|
29
67
|
return d;
|
|
30
68
|
};
|
|
69
|
+
var calcAngle = exports.calcAngle = function calcAngle(radius, angle, midAngle, gap) {
|
|
70
|
+
if (gap === 0) {
|
|
71
|
+
return angle;
|
|
72
|
+
}
|
|
73
|
+
var gapAngleRadians = Math.asin(Math.abs(gap) / radius);
|
|
74
|
+
var gapAngle = gapAngleRadians * 180 / Math.PI;
|
|
75
|
+
return gap > 0 ? Math.min(angle + gapAngle, midAngle) : Math.max(angle - gapAngle, midAngle);
|
|
76
|
+
};
|
|
77
|
+
var gapPoints = function gapPoints(centerX, centerY, outerRadius, innerRadius, angle, midAngle, gap) {
|
|
78
|
+
var outerAngle = calcAngle(outerRadius, angle, midAngle, gap);
|
|
79
|
+
var outer = polarToCartesian(centerX, centerY, outerRadius, outerAngle);
|
|
80
|
+
var inner;
|
|
81
|
+
if (innerRadius > 0) {
|
|
82
|
+
var innerAngle = calcAngle(innerRadius, angle, midAngle, gap);
|
|
83
|
+
inner = polarToCartesian(centerX, centerY, innerRadius, innerAngle);
|
|
84
|
+
} else {
|
|
85
|
+
inner = polarToCartesian(centerX, centerY, Math.abs(gap), gap < 0 ? angle - 90 : angle + 90);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
outer: outer,
|
|
89
|
+
inner: inner
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
var wedgeCommands = exports.wedgeCommands = function wedgeCommands(centerX, centerY, outerRadius, innerRadius, startAngle, endAngle, startGap, endGap, startRound, endRound, startRoundDirection) {
|
|
93
|
+
if (startRoundDirection === void 0) {
|
|
94
|
+
startRoundDirection = 0;
|
|
95
|
+
}
|
|
96
|
+
// handle that we can't draw a complete circle
|
|
97
|
+
var normalizedEndAngle = endAngle;
|
|
98
|
+
/*
|
|
99
|
+
added endAngle - startAngle >= 360
|
|
100
|
+
for SemiCircle the endAngle will never be greater then startAngle
|
|
101
|
+
since it starts with a startAngle of 270.
|
|
102
|
+
*/
|
|
103
|
+
if (endAngle > startAngle && endAngle - startAngle >= 359.99) {
|
|
104
|
+
normalizedEndAngle = startAngle + 359.99;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// if we're rounded we need to ajust the start points to
|
|
108
|
+
// account for a bigger cap radius
|
|
109
|
+
|
|
110
|
+
// add a little bit extra to start to allow for larger rounded inset cap
|
|
111
|
+
// The extra needed can be calculated by the Pythagorean theorem
|
|
112
|
+
var thickness = outerRadius - innerRadius;
|
|
113
|
+
var extraGap = startRound ? Math.sqrt(Math.pow(thickness / 2 + startGap / 4, 2) - Math.pow(thickness / 2, 2)) : 0;
|
|
114
|
+
|
|
115
|
+
// define the angle at the center of the wedge. We can't let the gap
|
|
116
|
+
// go past this angle.
|
|
117
|
+
|
|
118
|
+
// calculate the angle span between start and end
|
|
119
|
+
var angleSpan = (endAngle < startAngle ? endAngle + 360 : endAngle) - startAngle;
|
|
120
|
+
var midAngle = startAngle + angleSpan / 2;
|
|
121
|
+
var start = gapPoints(centerX, centerY, outerRadius, innerRadius, startAngle, midAngle < startAngle ? midAngle + 360 : midAngle, startGap + extraGap, startRound);
|
|
122
|
+
var end = gapPoints(centerX, centerY, outerRadius, innerRadius, normalizedEndAngle, midAngle > endAngle ? midAngle - 360 : midAngle, endGap, endRound);
|
|
123
|
+
var largeAngle = normalizedEndAngle - startAngle > 180;
|
|
124
|
+
var arcSweep = largeAngle ? '1' : '0';
|
|
125
|
+
var innerCapRadius = innerRadius;
|
|
126
|
+
var innerArcSweep = arcSweep;
|
|
127
|
+
var middle;
|
|
128
|
+
if (innerRadius <= 0) {
|
|
129
|
+
// we're doing a pie wedge
|
|
130
|
+
innerArcSweep = arcSweep === '0' ? '1' : '0';
|
|
131
|
+
if (largeAngle) {
|
|
132
|
+
// for a large pie wedge it has an inner corner rather
|
|
133
|
+
// than a point. We need to round the inner corner
|
|
134
|
+
innerCapRadius = startGap || endGap || 0;
|
|
135
|
+
} else {
|
|
136
|
+
// for a small pie wedge we'll make a point in the center
|
|
137
|
+
middle = intersection(start.outer, start.inner, end.outer, end.inner);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
var capRadius = (outerRadius - innerRadius) / 2;
|
|
141
|
+
var startCapRadius = capRadius + (startRoundDirection === 0 ? startGap / 2 : 0);
|
|
142
|
+
var startPoint = middle || start.inner;
|
|
143
|
+
var endPoint = middle || end.inner;
|
|
144
|
+
var startCap = startRound ? ['A', startCapRadius.toFixed(POST_DECIMAL_DIGITS), startCapRadius.toFixed(POST_DECIMAL_DIGITS), 0, 0, startRoundDirection, start.outer.x.toFixed(POST_DECIMAL_DIGITS), start.outer.y.toFixed(POST_DECIMAL_DIGITS)] : ['L', start.outer.x.toFixed(POST_DECIMAL_DIGITS), start.outer.y.toFixed(POST_DECIMAL_DIGITS)];
|
|
145
|
+
var endCap = endRound ? ['A', capRadius.toFixed(POST_DECIMAL_DIGITS), capRadius.toFixed(POST_DECIMAL_DIGITS), 0, 0, 1, endPoint.x.toFixed(POST_DECIMAL_DIGITS), endPoint.y.toFixed(POST_DECIMAL_DIGITS)] : ['L', endPoint.x.toFixed(POST_DECIMAL_DIGITS), endPoint.y.toFixed(POST_DECIMAL_DIGITS)];
|
|
146
|
+
var d = ['M', startPoint.x.toFixed(POST_DECIMAL_DIGITS), startPoint.y.toFixed(POST_DECIMAL_DIGITS)].concat(startCap, ['A', outerRadius.toFixed(POST_DECIMAL_DIGITS), outerRadius.toFixed(POST_DECIMAL_DIGITS), 0, arcSweep, 1, end.outer.x.toFixed(POST_DECIMAL_DIGITS), end.outer.y.toFixed(POST_DECIMAL_DIGITS)], endCap);
|
|
147
|
+
if (innerRadius > 0 || largeAngle) {
|
|
148
|
+
// for a donut or a large pie wedge, draw the inner arc
|
|
149
|
+
d.push('A', innerCapRadius.toFixed(POST_DECIMAL_DIGITS), innerCapRadius.toFixed(POST_DECIMAL_DIGITS), 0, innerArcSweep, 0, start.inner.x.toFixed(POST_DECIMAL_DIGITS), start.inner.y.toFixed(POST_DECIMAL_DIGITS), 'Z' // close the path
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return d.join(' ');
|
|
153
|
+
};
|
|
31
154
|
|
|
32
155
|
/* TranslatedEngAngle will now take the value of the
|
|
33
156
|
startAngle + anglePer * value and mod by 360. This was added
|