@techsio/ui-kit 0.58.0 → 0.59.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/dist/atoms/button.js +40 -4
- package/dist/atoms/image.js +12 -2
- package/dist/atoms/link-button.js +2 -1
- package/dist/atoms/numeric-input.js +70 -9
- package/dist/molecules/chart.js +154 -43
- package/dist/molecules/combobox.js +3 -1
- package/dist/molecules/date-picker.js +66 -8
- package/dist/molecules/dialog.js +11 -4
- package/dist/molecules/drawer.js +10 -2
- package/dist/molecules/product-card.js +65 -8
- package/dist/molecules/switch.js +3 -2
- package/dist/molecules/toast.js +12 -5
- package/dist/organisms/data-table.fields.js +1 -0
- package/dist/organisms/data-table.js +7 -3
- package/dist/src/atoms/badge.d.ts +1 -1
- package/dist/src/atoms/button.d.ts +23 -11
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +25 -2
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +1 -1
- package/dist/src/atoms/link-button.d.ts +38 -14
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +3 -2
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +1 -1
- package/dist/src/molecules/chart.d.ts +12 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +6 -2
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/date-picker.d.ts +24 -2
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +11 -2
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +109 -4
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +14 -2
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +5 -1
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/product-card.d.ts +1 -1
- package/package.json +1 -1
- package/src/tokens/_business-atoms.css +0 -7
- package/src/tokens/_scheme-scopes.css +73 -23
- package/src/tokens/components/atoms/_button.css +10 -0
- package/src/tokens/components/atoms/_input.css +1 -1
- package/src/tokens/components/atoms/_numeric-input.css +10 -0
- package/src/tokens/components/molecules/_chart.css +24 -6
- package/src/tokens/components/molecules/_product-card.css +21 -0
- package/src/tokens/figma/akros/variables.css +10 -1
- package/src/tokens/figma/brand-overrides.css +9 -0
- package/src/tokens/figma/business/variables.css +10 -1
- package/src/tokens/figma/dark/variables.css +10 -1
- package/src/tokens/figma/light/variables.css +20 -10
- package/src/tokens/figma/n1/variables.css +10 -1
- package/src/tokens/figma/variables.css +19 -9
package/dist/atoms/button.js
CHANGED
|
@@ -22,6 +22,10 @@ const buttonVariants = tv({
|
|
|
22
22
|
"motion-safe:not-disabled:not-data-disabled:not-data-loading:active:scale-97"
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
|
+
density: {
|
|
26
|
+
default: "",
|
|
27
|
+
compact: ""
|
|
28
|
+
},
|
|
25
29
|
variant: {
|
|
26
30
|
primary: "",
|
|
27
31
|
secondary: "",
|
|
@@ -40,9 +44,9 @@ const buttonVariants = tv({
|
|
|
40
44
|
true: "uppercase"
|
|
41
45
|
},
|
|
42
46
|
size: {
|
|
43
|
-
sm: "
|
|
44
|
-
md: "
|
|
45
|
-
lg: "
|
|
47
|
+
sm: "min-w-0 gap-button-sm rounded-button-sm text-button-sm",
|
|
48
|
+
md: "min-w-0 gap-button-md rounded-button-md text-button-md",
|
|
49
|
+
lg: "min-w-0 gap-button-lg rounded-button-lg text-button-lg",
|
|
46
50
|
current: "button-current-size gap-button-md"
|
|
47
51
|
},
|
|
48
52
|
block: {
|
|
@@ -50,6 +54,36 @@ const buttonVariants = tv({
|
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
compoundVariants: [
|
|
57
|
+
{
|
|
58
|
+
density: "default",
|
|
59
|
+
size: "sm",
|
|
60
|
+
className: "button-size-sm p-button-sm"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
density: "default",
|
|
64
|
+
size: "md",
|
|
65
|
+
className: "button-size-md p-button-md"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
density: "default",
|
|
69
|
+
size: "lg",
|
|
70
|
+
className: "button-size-lg p-button-lg"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
density: "compact",
|
|
74
|
+
size: "sm",
|
|
75
|
+
className: "h-button-compact-sm p-button-compact-sm"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
density: "compact",
|
|
79
|
+
size: "md",
|
|
80
|
+
className: "h-button-compact-md p-button-compact-md"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
density: "compact",
|
|
84
|
+
size: "lg",
|
|
85
|
+
className: "h-button-compact-lg p-button-compact-lg"
|
|
86
|
+
},
|
|
53
87
|
{
|
|
54
88
|
variant: "primary",
|
|
55
89
|
theme: "solid",
|
|
@@ -253,6 +287,7 @@ const buttonVariants = tv({
|
|
|
253
287
|
],
|
|
254
288
|
defaultVariants: {
|
|
255
289
|
composition: false,
|
|
290
|
+
density: "default",
|
|
256
291
|
variant: "primary",
|
|
257
292
|
theme: "solid",
|
|
258
293
|
size: "md",
|
|
@@ -272,7 +307,7 @@ const buttonIconVariants = tv({
|
|
|
272
307
|
size: "md"
|
|
273
308
|
}
|
|
274
309
|
});
|
|
275
|
-
function Button({ variant, theme, size, block, isLoading, loadingText, icon, iconPosition = "left", iconSize, uppercase = false, children, className, disabled, composition, ref, onClick, type = "button", ...props }) {
|
|
310
|
+
function Button({ density, variant, theme, size, block, isLoading, loadingText, icon, iconPosition = "left", iconSize, uppercase = false, children, className, disabled, composition, ref, onClick, type = "button", ...props }) {
|
|
276
311
|
const buttonRef = useRef(null);
|
|
277
312
|
useImperativeHandle(ref, ()=>buttonRef.current, []);
|
|
278
313
|
useEffect(()=>{
|
|
@@ -300,6 +335,7 @@ function Button({ variant, theme, size, block, isLoading, loadingText, icon, ico
|
|
|
300
335
|
"aria-busy": isLoading || void 0,
|
|
301
336
|
"aria-disabled": disabled || isLoading || props["aria-disabled"] || void 0,
|
|
302
337
|
className: buttonVariants({
|
|
338
|
+
density,
|
|
303
339
|
variant,
|
|
304
340
|
theme,
|
|
305
341
|
size,
|
package/dist/atoms/image.js
CHANGED
|
@@ -6,6 +6,13 @@ import { Icon } from "./icon.js";
|
|
|
6
6
|
const imageVariants = tv({
|
|
7
7
|
base: "block max-w-full object-cover",
|
|
8
8
|
variants: {
|
|
9
|
+
objectFit: {
|
|
10
|
+
contain: "object-contain",
|
|
11
|
+
cover: "object-cover",
|
|
12
|
+
fill: "object-fill",
|
|
13
|
+
none: "object-none",
|
|
14
|
+
scaleDown: "object-scale-down"
|
|
15
|
+
},
|
|
9
16
|
size: {
|
|
10
17
|
sm: "size-image-sm",
|
|
11
18
|
md: "size-image-md",
|
|
@@ -18,12 +25,13 @@ const imageVariants = tv({
|
|
|
18
25
|
size: "full"
|
|
19
26
|
}
|
|
20
27
|
});
|
|
21
|
-
function Image({ as, src, alt, size, className, ...props }) {
|
|
28
|
+
function Image({ as, src, alt, size, objectFit, className, ...props }) {
|
|
22
29
|
const Component = as || "img";
|
|
23
30
|
return /*#__PURE__*/ jsx(Component, {
|
|
24
31
|
alt: alt,
|
|
25
32
|
className: imageVariants({
|
|
26
33
|
size,
|
|
34
|
+
objectFit,
|
|
27
35
|
className
|
|
28
36
|
}),
|
|
29
37
|
src: src,
|
|
@@ -57,7 +65,7 @@ function ImageWithFallback(props) {
|
|
|
57
65
|
...props
|
|
58
66
|
}, sourceKey);
|
|
59
67
|
}
|
|
60
|
-
function ImageFallbackContent({ as, src, alt, size, className, fallbackLabel, ...props }) {
|
|
68
|
+
function ImageFallbackContent({ as, src, alt, size, objectFit, className, fallbackLabel, ...props }) {
|
|
61
69
|
const [failed, setFailed] = useState(!src);
|
|
62
70
|
const [loaded, setLoaded] = useState(false);
|
|
63
71
|
const pending = !(failed || loaded);
|
|
@@ -81,6 +89,7 @@ function ImageFallbackContent({ as, src, alt, size, className, fallbackLabel, ..
|
|
|
81
89
|
className: styles.root({
|
|
82
90
|
className: imageVariants({
|
|
83
91
|
size,
|
|
92
|
+
objectFit,
|
|
84
93
|
className
|
|
85
94
|
})
|
|
86
95
|
}),
|
|
@@ -102,6 +111,7 @@ function ImageFallbackContent({ as, src, alt, size, className, fallbackLabel, ..
|
|
|
102
111
|
className: styles.image({
|
|
103
112
|
className: imageVariants({
|
|
104
113
|
size,
|
|
114
|
+
objectFit,
|
|
105
115
|
className
|
|
106
116
|
})
|
|
107
117
|
}),
|
|
@@ -10,13 +10,14 @@ const linkButton = tv({
|
|
|
10
10
|
size: "md"
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
function LinkButton({ href, icon, as, iconPosition = "left", iconSize, children, variant, theme, size, block, uppercase, className, disabled, composition, ref, onClick, tabIndex, ...props }) {
|
|
13
|
+
function LinkButton({ density, href, icon, as, iconPosition = "left", iconSize, children, variant, theme, size, block, uppercase, className, disabled, composition, ref, onClick, tabIndex, ...props }) {
|
|
14
14
|
const handleClick = onClick;
|
|
15
15
|
const Component = disabled ? "span" : as || "a";
|
|
16
16
|
return /*#__PURE__*/ jsxs(Component, {
|
|
17
17
|
...props,
|
|
18
18
|
"aria-disabled": true === disabled ? true : props["aria-disabled"],
|
|
19
19
|
className: linkButton({
|
|
20
|
+
density,
|
|
20
21
|
variant,
|
|
21
22
|
theme,
|
|
22
23
|
size,
|
|
@@ -65,7 +65,6 @@ const numericInputVariants = tv({
|
|
|
65
65
|
],
|
|
66
66
|
container: [
|
|
67
67
|
"group numeric-input-focus-owner form-control-base numeric-input-validation numeric-input-readonly relative flex",
|
|
68
|
-
"border-numeric-input-border",
|
|
69
68
|
"min-w-0 items-center overflow-clip",
|
|
70
69
|
"hover:border-numeric-input-border-hover",
|
|
71
70
|
"focus-within:border-numeric-input-border-focus",
|
|
@@ -97,7 +96,7 @@ const numericInputVariants = tv({
|
|
|
97
96
|
trigger: [
|
|
98
97
|
"flex min-h-numeric-input-trigger-min min-w-numeric-input-trigger-min flex-1 place-items-center",
|
|
99
98
|
"pointer-coarse:min-w-numeric-input-trigger-touch-min",
|
|
100
|
-
"
|
|
99
|
+
"py-numeric-input-trigger-y",
|
|
101
100
|
"bg-transparent hover:bg-numeric-input-trigger-bg-hover active:bg-numeric-input-trigger-bg-active",
|
|
102
101
|
"text-numeric-input-trigger-fg",
|
|
103
102
|
"cursor-pointer",
|
|
@@ -108,31 +107,92 @@ const numericInputVariants = tv({
|
|
|
108
107
|
scrubber: "absolute inset-0 cursor-ew-resize"
|
|
109
108
|
},
|
|
110
109
|
variants: {
|
|
110
|
+
density: {
|
|
111
|
+
default: {
|
|
112
|
+
container: "border-numeric-input-border",
|
|
113
|
+
trigger: "px-numeric-input-trigger-x"
|
|
114
|
+
},
|
|
115
|
+
compact: {
|
|
116
|
+
container: "border-numeric-input-compact-border",
|
|
117
|
+
trigger: "px-numeric-input-compact-trigger"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
111
120
|
size: {
|
|
112
121
|
sm: {
|
|
113
122
|
root: "gap-numeric-input-sm text-numeric-input-sm",
|
|
114
|
-
container: "
|
|
123
|
+
container: "rounded-numeric-input-sm",
|
|
115
124
|
trigger: "text-numeric-input-sm",
|
|
116
125
|
triggerIcon: "numeric-input-trigger-icon-sm",
|
|
117
|
-
input: "
|
|
126
|
+
input: "text-numeric-input-sm"
|
|
118
127
|
},
|
|
119
128
|
md: {
|
|
120
129
|
root: "gap-numeric-input-md text-numeric-input-md",
|
|
121
|
-
container: "
|
|
130
|
+
container: "rounded-numeric-input-md",
|
|
122
131
|
trigger: "text-numeric-input-md",
|
|
123
132
|
triggerIcon: "numeric-input-trigger-icon-md",
|
|
124
|
-
input: "
|
|
133
|
+
input: "text-numeric-input-md"
|
|
125
134
|
},
|
|
126
135
|
lg: {
|
|
127
136
|
root: "gap-numeric-input-lg text-numeric-input-lg",
|
|
128
|
-
container: "
|
|
137
|
+
container: "rounded-numeric-input-lg",
|
|
129
138
|
trigger: "text-numeric-input-lg",
|
|
130
139
|
triggerIcon: "numeric-input-trigger-icon-lg",
|
|
131
|
-
input: "
|
|
140
|
+
input: "text-numeric-input-lg"
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
143
|
},
|
|
144
|
+
compoundVariants: [
|
|
145
|
+
{
|
|
146
|
+
density: "default",
|
|
147
|
+
size: "sm",
|
|
148
|
+
className: {
|
|
149
|
+
container: "h-form-control-sm",
|
|
150
|
+
input: "ps-numeric-input-input-sm"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
density: "default",
|
|
155
|
+
size: "md",
|
|
156
|
+
className: {
|
|
157
|
+
container: "h-form-control-md",
|
|
158
|
+
input: "ps-numeric-input-input-md"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
density: "default",
|
|
163
|
+
size: "lg",
|
|
164
|
+
className: {
|
|
165
|
+
container: "h-form-control-lg",
|
|
166
|
+
input: "ps-numeric-input-input-lg"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
density: "compact",
|
|
171
|
+
size: "sm",
|
|
172
|
+
className: {
|
|
173
|
+
container: "h-numeric-input-compact-sm",
|
|
174
|
+
input: "ps-numeric-input-compact-sm"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
density: "compact",
|
|
179
|
+
size: "md",
|
|
180
|
+
className: {
|
|
181
|
+
container: "h-numeric-input-compact-md",
|
|
182
|
+
input: "ps-numeric-input-compact-md"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
density: "compact",
|
|
187
|
+
size: "lg",
|
|
188
|
+
className: {
|
|
189
|
+
container: "h-numeric-input-compact-lg",
|
|
190
|
+
input: "ps-numeric-input-compact-lg"
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
],
|
|
135
194
|
defaultVariants: {
|
|
195
|
+
density: "default",
|
|
136
196
|
size: "md"
|
|
137
197
|
}
|
|
138
198
|
});
|
|
@@ -143,7 +203,7 @@ function useNumericInputContext() {
|
|
|
143
203
|
if (!context) throw new Error("NumericInput components must be used within NumericInput.Root");
|
|
144
204
|
return context;
|
|
145
205
|
}
|
|
146
|
-
function NumericInput({ id, size, value, defaultValue, onChange, validateStatus = "default", dir = "ltr", describedBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, precision, children, ref, className, locale = "cs-CZ", ...props }) {
|
|
206
|
+
function NumericInput({ density, id, size, value, defaultValue, onChange, validateStatus = "default", dir = "ltr", describedBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, precision, children, ref, className, locale = "cs-CZ", ...props }) {
|
|
147
207
|
const generatedId = useId();
|
|
148
208
|
const [inputId, setInputId] = useState();
|
|
149
209
|
const description = useDescribedBy();
|
|
@@ -297,6 +357,7 @@ function NumericInput({ id, size, value, defaultValue, onChange, validateStatus
|
|
|
297
357
|
service
|
|
298
358
|
]);
|
|
299
359
|
const styles = numericInputVariants({
|
|
360
|
+
density,
|
|
300
361
|
size
|
|
301
362
|
});
|
|
302
363
|
const inputDisabled = api.getInputProps().disabled;
|
package/dist/molecules/chart.js
CHANGED
|
@@ -19,10 +19,10 @@ const chartVariants = tv({
|
|
|
19
19
|
tooltip: "chart-tooltip popup-layer!",
|
|
20
20
|
alternative: "overflow-auto text-chart-data text-chart-fg",
|
|
21
21
|
summary: "cursor-pointer rounded-chart-tooltip focus-visible:outline-chart-fg",
|
|
22
|
-
cell: "border-chart-tooltip-border border-b p-chart-
|
|
22
|
+
cell: "border-chart-tooltip-border border-b p-chart-cell text-start",
|
|
23
23
|
legend: "flex flex-wrap gap-chart-legend text-chart-data text-chart-fg",
|
|
24
24
|
legendItem: "inline-flex items-center gap-chart-item",
|
|
25
|
-
fallback: "p-chart-
|
|
25
|
+
fallback: "p-chart-fallback text-chart-data text-chart-fg"
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
const SERIES_1_PAINT = "var(--color-chart-series-1)";
|
|
@@ -46,6 +46,78 @@ const LINE_DASHES = [
|
|
|
46
46
|
"12 4",
|
|
47
47
|
"4 4"
|
|
48
48
|
];
|
|
49
|
+
const TOOLTIP_GAP = 12;
|
|
50
|
+
const TOOLTIP_EDGE = 8;
|
|
51
|
+
let tooltipMeasureContext;
|
|
52
|
+
function validLocale(locale) {
|
|
53
|
+
if (null == locale) return;
|
|
54
|
+
try {
|
|
55
|
+
Intl.getCanonicalLocales(locale);
|
|
56
|
+
return locale;
|
|
57
|
+
} catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function tooltipTextWidth(text, weight) {
|
|
62
|
+
if (null == tooltipMeasureContext && "u" > typeof document) tooltipMeasureContext = document.createElement("canvas").getContext?.("2d") ?? false;
|
|
63
|
+
if (!tooltipMeasureContext) return 8.5 * text.length;
|
|
64
|
+
tooltipMeasureContext.font = `${weight} 15px system-ui, sans-serif`;
|
|
65
|
+
return 1.08 * tooltipMeasureContext.measureText(text).width;
|
|
66
|
+
}
|
|
67
|
+
function estimateTooltipSize(content) {
|
|
68
|
+
const titleWidth = content.title ? tooltipTextWidth(content.title, 650) : 0;
|
|
69
|
+
const rowWidth = Math.max(0, ...content.rows.map((row)=>40 + tooltipTextWidth(row.label, 500) + tooltipTextWidth(row.value, 600)));
|
|
70
|
+
return {
|
|
71
|
+
width: Math.ceil(Math.max(titleWidth, rowWidth) + 34),
|
|
72
|
+
height: Math.ceil(30 + (content.title ? 26 : 0) + 24 * content.rows.length)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function chartTooltipCorner(content, points, context, horizontal) {
|
|
76
|
+
const first = points[0];
|
|
77
|
+
if (!first) return null;
|
|
78
|
+
const { width, height } = estimateTooltipSize(content);
|
|
79
|
+
const { surface } = context;
|
|
80
|
+
const xs = points.map((point)=>point.x);
|
|
81
|
+
const ys = points.map((point)=>point.y);
|
|
82
|
+
const categoryScale = context.scales[horizontal ? "y" : "x"];
|
|
83
|
+
const band = categoryScale?.bandwidth ?? 0;
|
|
84
|
+
const bandStart = categoryScale && band > 0 ? categoryScale.map(horizontal ? first.yValue : first.xValue) : 0 / 0;
|
|
85
|
+
const hasBand = Number.isFinite(bandStart);
|
|
86
|
+
if (horizontal) {
|
|
87
|
+
const top = hasBand ? bandStart : Math.min(...ys);
|
|
88
|
+
const bottom = hasBand ? bandStart + band : Math.max(...ys);
|
|
89
|
+
const end = Math.max(...xs);
|
|
90
|
+
if (end + TOOLTIP_GAP + width + TOOLTIP_EDGE <= surface.width) return {
|
|
91
|
+
x: end + TOOLTIP_GAP,
|
|
92
|
+
y: (top + bottom - height) / 2
|
|
93
|
+
};
|
|
94
|
+
if (top - TOOLTIP_GAP - height >= TOOLTIP_EDGE) return {
|
|
95
|
+
x: end - width,
|
|
96
|
+
y: top - TOOLTIP_GAP - height
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
x: end - width,
|
|
100
|
+
y: bottom + TOOLTIP_GAP
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const left = hasBand ? bandStart : Math.min(...xs);
|
|
104
|
+
const right = hasBand ? bandStart + band : Math.max(...xs);
|
|
105
|
+
const top = Math.min(...ys);
|
|
106
|
+
const center = (left + right) / 2;
|
|
107
|
+
if (top - TOOLTIP_GAP - height >= TOOLTIP_EDGE) return {
|
|
108
|
+
x: center - width / 2,
|
|
109
|
+
y: top - TOOLTIP_GAP - height
|
|
110
|
+
};
|
|
111
|
+
const y = Math.max(TOOLTIP_EDGE, top);
|
|
112
|
+
if (right + TOOLTIP_GAP + width + TOOLTIP_EDGE <= surface.width) return {
|
|
113
|
+
x: right + TOOLTIP_GAP,
|
|
114
|
+
y
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
x: left - TOOLTIP_GAP - width,
|
|
118
|
+
y
|
|
119
|
+
};
|
|
120
|
+
}
|
|
49
121
|
function resolveXAxis(data, getX, xLabel) {
|
|
50
122
|
const values = data.map(getX);
|
|
51
123
|
if (values.length > 0 && values.every((value)=>value instanceof Date)) return {
|
|
@@ -87,57 +159,85 @@ function resolveBuild(config) {
|
|
|
87
159
|
use: tooltip_tooltip,
|
|
88
160
|
className: config.tooltipClassName
|
|
89
161
|
};
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
162
|
+
const locale = validLocale(config.locale);
|
|
163
|
+
const numberFormat = locale ? new Intl.NumberFormat(locale) : void 0;
|
|
164
|
+
const dateFormat = new Intl.DateTimeFormat(locale, {
|
|
165
|
+
dateStyle: "medium",
|
|
166
|
+
timeZone: "UTC"
|
|
167
|
+
});
|
|
168
|
+
const formatCategory = (value)=>{
|
|
169
|
+
if (config.formatCategory) return config.formatCategory(value);
|
|
170
|
+
if (value instanceof Date) return dateFormat.format(value);
|
|
171
|
+
if ("number" == typeof value) return numberFormat ? numberFormat.format(value) : String(value);
|
|
172
|
+
return String(value);
|
|
97
173
|
};
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
label: valueName,
|
|
106
|
-
|
|
174
|
+
const formatTooltipValue = (value)=>{
|
|
175
|
+
const format = config.formatTooltipValue ?? formatValue;
|
|
176
|
+
if (format) return format(value);
|
|
177
|
+
return numberFormat ? numberFormat.format(value) : String(value);
|
|
178
|
+
};
|
|
179
|
+
const valueName = config.valueLabel ?? config.yLabel ?? "";
|
|
180
|
+
const rowFor = (row, point, active)=>({
|
|
181
|
+
label: getSeries ? String(getSeries(row)) : valueName,
|
|
182
|
+
value: formatTooltipValue(getY(row)),
|
|
183
|
+
color: point.color || SERIES_1_PAINT,
|
|
184
|
+
active
|
|
185
|
+
});
|
|
186
|
+
const cartesianContent = (points, primaryPoint)=>{
|
|
187
|
+
const first = points[0];
|
|
188
|
+
if (!first) return {
|
|
189
|
+
rows: []
|
|
107
190
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
label: categoryName
|
|
191
|
+
return {
|
|
192
|
+
title: formatCategory(getX(first.datum)),
|
|
193
|
+
rows: points.map((point)=>rowFor(point.datum, point, points.length > 1 && point === primaryPoint))
|
|
112
194
|
};
|
|
195
|
+
};
|
|
196
|
+
const polarContent = (points)=>{
|
|
197
|
+
const first = points[0];
|
|
198
|
+
if (!first) return {
|
|
199
|
+
rows: []
|
|
200
|
+
};
|
|
201
|
+
const row = first.datum.data;
|
|
113
202
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
203
|
+
title: formatCategory(getX(row)),
|
|
204
|
+
rows: [
|
|
205
|
+
{
|
|
206
|
+
label: valueName,
|
|
207
|
+
value: formatTooltipValue(getY(row)),
|
|
208
|
+
color: first.color || SERIES_1_PAINT
|
|
209
|
+
}
|
|
121
210
|
]
|
|
122
211
|
};
|
|
123
212
|
};
|
|
213
|
+
const tooltipFor = (valueChannel)=>{
|
|
214
|
+
if (!config.showTooltip) return false;
|
|
215
|
+
const horizontal = "x" === valueChannel;
|
|
216
|
+
return {
|
|
217
|
+
...tooltipBase,
|
|
218
|
+
content: (points, context)=>cartesianContent(points, context.primaryPoint),
|
|
219
|
+
anchor: (points, context)=>chartTooltipCorner(cartesianContent(points, context.focus.primary), points, context, horizontal),
|
|
220
|
+
placement: "bottom-right",
|
|
221
|
+
offset: 0
|
|
222
|
+
};
|
|
223
|
+
};
|
|
124
224
|
const polarTooltip = ()=>{
|
|
125
225
|
if (!config.showTooltip) return false;
|
|
126
226
|
return {
|
|
127
227
|
...tooltipBase,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
]
|
|
228
|
+
content: polarContent,
|
|
229
|
+
anchor: "pointer",
|
|
230
|
+
placement: [
|
|
231
|
+
"right",
|
|
232
|
+
"left",
|
|
233
|
+
"bottom",
|
|
234
|
+
"top"
|
|
235
|
+
],
|
|
236
|
+
offset: 16
|
|
139
237
|
};
|
|
140
238
|
};
|
|
239
|
+
let focus;
|
|
240
|
+
if (null != getSeries && !isPolar) focus = "bar-horizontal" === config.type ? "group-y" : "group-x";
|
|
141
241
|
const valueAxis = {
|
|
142
242
|
scale: scaleLinear,
|
|
143
243
|
nice: true,
|
|
@@ -186,7 +286,10 @@ function resolveBuild(config) {
|
|
|
186
286
|
})
|
|
187
287
|
}) : void 0
|
|
188
288
|
},
|
|
189
|
-
svgAnimation: config.animate
|
|
289
|
+
svgAnimation: config.animate,
|
|
290
|
+
...focus ? {
|
|
291
|
+
focus
|
|
292
|
+
} : {}
|
|
190
293
|
}
|
|
191
294
|
};
|
|
192
295
|
}
|
|
@@ -294,7 +397,7 @@ function buildBars(build, horizontal) {
|
|
|
294
397
|
y: build.bandAxis
|
|
295
398
|
},
|
|
296
399
|
...build.shared,
|
|
297
|
-
tooltip: build.tooltipFor("x"
|
|
400
|
+
tooltip: build.tooltipFor("x")
|
|
298
401
|
};
|
|
299
402
|
return {
|
|
300
403
|
marks: [
|
|
@@ -571,7 +674,7 @@ function ChartLineLegend({ identities, domain, label }) {
|
|
|
571
674
|
})
|
|
572
675
|
});
|
|
573
676
|
}
|
|
574
|
-
function chart_Chart({ type = "line", data, x, y, series, seriesDomain, stacked, points = false, smooth = false, grid = true, legend, legendLabel, xLabel, yLabel, formatValue, height, aspectRatio, initialWidth = 640, animate, tooltip = true, ariaLabel, ariaDescription, className, dataTableLabel = "View chart data", emptyLabel = "No data to display.", invalidLabel = "Pie and donut values must be finite, non-negative numbers with a positive total.", onSelect }) {
|
|
677
|
+
function chart_Chart({ type = "line", data, x, y, series, seriesDomain, stacked, points = false, smooth = false, grid = true, legend, legendLabel, xLabel, yLabel, formatValue, valueLabel, formatCategory, formatTooltipValue, locale, height, aspectRatio, initialWidth = 640, animate, tooltip = true, ariaLabel, ariaDescription, className, dataTableLabel = "View chart data", emptyLabel = "No data to display.", invalidLabel = "Pie and donut values must be finite, non-negative numbers with a positive total.", onSelect }) {
|
|
575
678
|
const { root, tooltip: tooltipSlot, fallback } = chartVariants();
|
|
576
679
|
const tooltipClassName = tooltipSlot();
|
|
577
680
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
@@ -605,6 +708,10 @@ function chart_Chart({ type = "line", data, x, y, series, seriesDomain, stacked,
|
|
|
605
708
|
xLabel,
|
|
606
709
|
yLabel,
|
|
607
710
|
formatValue,
|
|
711
|
+
valueLabel,
|
|
712
|
+
formatCategory,
|
|
713
|
+
formatTooltipValue,
|
|
714
|
+
locale,
|
|
608
715
|
animate: shouldAnimate,
|
|
609
716
|
showTooltip: tooltip && !dismissed,
|
|
610
717
|
tooltipClassName
|
|
@@ -626,6 +733,10 @@ function chart_Chart({ type = "line", data, x, y, series, seriesDomain, stacked,
|
|
|
626
733
|
xLabel,
|
|
627
734
|
yLabel,
|
|
628
735
|
formatValue,
|
|
736
|
+
valueLabel,
|
|
737
|
+
formatCategory,
|
|
738
|
+
formatTooltipValue,
|
|
739
|
+
locale,
|
|
629
740
|
shouldAnimate,
|
|
630
741
|
tooltip,
|
|
631
742
|
tooltipClassName
|
|
@@ -316,7 +316,7 @@ function ComboboxStatus({ state, styles, loadingMessage, error, onRetry, disable
|
|
|
316
316
|
});
|
|
317
317
|
return null;
|
|
318
318
|
}
|
|
319
|
-
function Combobox({ id, name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, label, size, placeholder = "Select option", disabled: explicitDisabled = false, readOnly = false, required = false, items, groups, value, defaultValue, inputValue, defaultInputValue, multiple = false, validateStatus, helpText, showHelpTextIcon = true, noResultsMessage = 'No results found for "{inputValue}"', clearable = true, selectionBehavior = "replace", closeOnSelect = true, allowCustomValue = false, loopFocus = true, autoFocus = false, open, defaultOpen, triggerIcon = "token-icon-combobox-chevron", triggerIconSize, clearIcon = "token-icon-combobox-clear", inputBehavior = "autocomplete", filterBehavior = "local", loading = false, loadingMessage = "Loading results", error, retryLabel = "Retry", onRetry, renderItem, onChange, onInputValueChange, onOpenChange, mode = "selection", navigate, footer, portalled = true, ref, inputProps = {}, className, ...rootProps }) {
|
|
319
|
+
function Combobox({ id, name, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, label, size, placeholder = "Select option", disabled: explicitDisabled = false, readOnly = false, required = false, items, groups, value, defaultValue, inputValue, defaultInputValue, multiple = false, validateStatus, helpText, showHelpTextIcon = true, noResultsMessage = 'No results found for "{inputValue}"', clearable = true, selectionBehavior = "replace", closeOnSelect = true, allowCustomValue = false, loopFocus = true, autoFocus = false, open, defaultOpen, triggerIcon = "token-icon-combobox-chevron", triggerIconSize, clearIcon = "token-icon-combobox-clear", inputBehavior = "autocomplete", filterBehavior = "local", loading = false, loadingMessage = "Loading results", error, retryLabel = "Retry", onRetry, renderItem, onChange, onInputValueChange, onOpenChange, mode = "selection", navigate, footer, portalled = true, openOnClick = false, translations, ref, inputProps = {}, className, ...rootProps }) {
|
|
320
320
|
const generatedId = useId();
|
|
321
321
|
const uniqueId = id || generatedId;
|
|
322
322
|
const listId = `${uniqueId}-listbox`;
|
|
@@ -446,6 +446,8 @@ function Combobox({ id, name, "aria-label": ariaLabel, "aria-labelledby": ariaLa
|
|
|
446
446
|
disabled,
|
|
447
447
|
readOnly,
|
|
448
448
|
closeOnSelect,
|
|
449
|
+
openOnClick,
|
|
450
|
+
translations,
|
|
449
451
|
selectionBehavior: navigation ? "preserve" : selectionBehavior,
|
|
450
452
|
allowCustomValue: !navigation && allowCustomValue,
|
|
451
453
|
autoFocus,
|