@automattic/charts 0.57.0 → 0.58.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 +16 -2
- package/dist/charts/bar-chart/index.cjs +7 -5
- package/dist/charts/bar-chart/index.cjs.map +1 -1
- package/dist/charts/bar-chart/index.css +12 -24
- package/dist/charts/bar-chart/index.css.map +1 -1
- package/dist/charts/bar-chart/index.d.cts +3 -4
- package/dist/charts/bar-chart/index.d.ts +3 -4
- package/dist/charts/bar-chart/index.js +6 -4
- package/dist/charts/bar-list-chart/index.cjs +8 -6
- package/dist/charts/bar-list-chart/index.cjs.map +1 -1
- package/dist/charts/bar-list-chart/index.css +12 -24
- package/dist/charts/bar-list-chart/index.css.map +1 -1
- package/dist/charts/bar-list-chart/index.d.cts +3 -3
- package/dist/charts/bar-list-chart/index.d.ts +3 -3
- package/dist/charts/bar-list-chart/index.js +7 -5
- package/dist/charts/conversion-funnel-chart/index.cjs +5 -5
- package/dist/charts/conversion-funnel-chart/index.css +0 -94
- package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +1 -1
- package/dist/charts/conversion-funnel-chart/index.d.ts +1 -1
- package/dist/charts/conversion-funnel-chart/index.js +4 -4
- package/dist/charts/geo-chart/index.cjs +4 -4
- package/dist/charts/geo-chart/index.css +0 -94
- package/dist/charts/geo-chart/index.css.map +1 -1
- package/dist/charts/geo-chart/index.d.cts +1 -1
- package/dist/charts/geo-chart/index.d.ts +1 -1
- package/dist/charts/geo-chart/index.js +3 -3
- package/dist/charts/leaderboard-chart/index.cjs +7 -6
- package/dist/charts/leaderboard-chart/index.cjs.map +1 -1
- package/dist/charts/leaderboard-chart/index.css +12 -24
- package/dist/charts/leaderboard-chart/index.css.map +1 -1
- package/dist/charts/leaderboard-chart/index.d.cts +3 -3
- package/dist/charts/leaderboard-chart/index.d.ts +3 -3
- package/dist/charts/leaderboard-chart/index.js +6 -5
- package/dist/charts/line-chart/index.cjs +7 -5
- package/dist/charts/line-chart/index.cjs.map +1 -1
- package/dist/charts/line-chart/index.css +12 -24
- package/dist/charts/line-chart/index.css.map +1 -1
- package/dist/charts/line-chart/index.d.cts +3 -4
- package/dist/charts/line-chart/index.d.ts +3 -4
- package/dist/charts/line-chart/index.js +6 -4
- package/dist/charts/pie-chart/index.cjs +7 -6
- package/dist/charts/pie-chart/index.cjs.map +1 -1
- package/dist/charts/pie-chart/index.css +12 -24
- package/dist/charts/pie-chart/index.css.map +1 -1
- package/dist/charts/pie-chart/index.d.cts +7 -13
- package/dist/charts/pie-chart/index.d.ts +7 -13
- package/dist/charts/pie-chart/index.js +6 -5
- package/dist/charts/pie-semi-circle-chart/index.cjs +7 -6
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.css +12 -24
- package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.d.ts +7 -13
- package/dist/charts/pie-semi-circle-chart/index.js +6 -5
- package/dist/charts/sparkline/index.cjs +8 -6
- package/dist/charts/sparkline/index.cjs.map +1 -1
- package/dist/charts/sparkline/index.css +12 -24
- package/dist/charts/sparkline/index.css.map +1 -1
- package/dist/charts/sparkline/index.js +7 -5
- package/dist/{chunk-32DH6JDF.js → chunk-2I67QUIV.js} +52 -420
- package/dist/chunk-2I67QUIV.js.map +1 -0
- package/dist/{chunk-WLODYNLB.js → chunk-2ICEEQOC.js} +31 -27
- package/dist/chunk-2ICEEQOC.js.map +1 -0
- package/dist/{chunk-IU4DYUAV.js → chunk-4B7BL2DD.js} +3 -3
- package/dist/{chunk-BCX5THDQ.js → chunk-4OXMTKAL.js} +24 -26
- package/dist/chunk-4OXMTKAL.js.map +1 -0
- package/dist/{chunk-4OPFE4RM.js → chunk-B6NLZFRW.js} +30 -27
- package/dist/chunk-B6NLZFRW.js.map +1 -0
- package/dist/{chunk-D2UH4CFE.cjs → chunk-BBAUQOW6.cjs} +9 -9
- package/dist/{chunk-D2UH4CFE.cjs.map → chunk-BBAUQOW6.cjs.map} +1 -1
- package/dist/{chunk-XKRJL2QT.cjs → chunk-CMMHCTBX.cjs} +45 -47
- package/dist/chunk-CMMHCTBX.cjs.map +1 -0
- package/dist/{chunk-YE2T52VZ.cjs → chunk-CPPXJATQ.cjs} +51 -47
- package/dist/chunk-CPPXJATQ.cjs.map +1 -0
- package/dist/{chunk-H2V4JMSA.js → chunk-DKU775VC.js} +3 -3
- package/dist/{chunk-ZH4F5RMG.cjs → chunk-GRA7Y2ZG.cjs} +46 -48
- package/dist/chunk-GRA7Y2ZG.cjs.map +1 -0
- package/dist/{chunk-DAU3HNEG.js → chunk-JJIMABHT.js} +9 -2
- package/dist/chunk-JJIMABHT.js.map +1 -0
- package/dist/{chunk-CZGYJKG6.js → chunk-KJHWXOCZ.js} +4 -4
- package/dist/{chunk-6CCZL2JJ.js → chunk-KRWGSOJ2.js} +30 -2
- package/dist/chunk-KRWGSOJ2.js.map +1 -0
- package/dist/{chunk-V36ERY7Y.js → chunk-LTFH7SEG.js} +24 -26
- package/dist/chunk-LTFH7SEG.js.map +1 -0
- package/dist/{chunk-PXLEMUGJ.js → chunk-MUNOKLLE.js} +3 -3
- package/dist/{chunk-VTS3PNMS.cjs → chunk-MXGLYWVP.cjs} +9 -2
- package/dist/chunk-MXGLYWVP.cjs.map +1 -0
- package/dist/{chunk-Z45KX47P.cjs → chunk-OYC34VTO.cjs} +154 -94
- package/dist/chunk-OYC34VTO.cjs.map +1 -0
- package/dist/{chunk-77OKCVQN.cjs → chunk-PQL5I3F6.cjs} +17 -17
- package/dist/{chunk-77OKCVQN.cjs.map → chunk-PQL5I3F6.cjs.map} +1 -1
- package/dist/{chunk-I35UYJJR.cjs → chunk-REZTQ4PH.cjs} +41 -21
- package/dist/chunk-REZTQ4PH.cjs.map +1 -0
- package/dist/{chunk-RCY6XLGU.cjs → chunk-TZRUHQOH.cjs} +36 -8
- package/dist/chunk-TZRUHQOH.cjs.map +1 -0
- package/dist/{chunk-2NCY7R4G.js → chunk-UTYVIOWZ.js} +111 -51
- package/dist/chunk-UTYVIOWZ.js.map +1 -0
- package/dist/{chunk-TO3OQBXG.cjs → chunk-W2LDIX26.cjs} +5 -5
- package/dist/{chunk-TO3OQBXG.cjs.map → chunk-W2LDIX26.cjs.map} +1 -1
- package/dist/{chunk-7FQX4ALL.cjs → chunk-WSG64BVN.cjs} +6 -6
- package/dist/{chunk-7FQX4ALL.cjs.map → chunk-WSG64BVN.cjs.map} +1 -1
- package/dist/chunk-WTQYGUNF.js +400 -0
- package/dist/chunk-WTQYGUNF.js.map +1 -0
- package/dist/{chunk-RHHVEJHJ.cjs → chunk-WYK7EL5R.cjs} +68 -436
- package/dist/chunk-WYK7EL5R.cjs.map +1 -0
- package/dist/{chunk-VJM5XCB4.cjs → chunk-XC4KHJYX.cjs} +49 -46
- package/dist/chunk-XC4KHJYX.cjs.map +1 -0
- package/dist/chunk-XVBH5XHE.cjs +400 -0
- package/dist/chunk-XVBH5XHE.cjs.map +1 -0
- package/dist/{chunk-Z26M4V2M.js → chunk-YAFQVVDI.js} +41 -21
- package/dist/chunk-YAFQVVDI.js.map +1 -0
- package/dist/components/legend/index.cjs +4 -3
- package/dist/components/legend/index.cjs.map +1 -1
- package/dist/components/legend/index.css +12 -24
- package/dist/components/legend/index.css.map +1 -1
- package/dist/components/legend/index.d.cts +4 -4
- package/dist/components/legend/index.d.ts +4 -4
- package/dist/components/legend/index.js +3 -2
- package/dist/components/tooltip/index.d.cts +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/hooks/index.cjs +3 -5
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.css +0 -94
- package/dist/hooks/index.css.map +1 -1
- package/dist/hooks/index.d.cts +3 -11
- package/dist/hooks/index.d.ts +3 -11
- package/dist/hooks/index.js +2 -4
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +12 -24
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -15
- package/dist/{leaderboard-chart-DR7CGb0L.d.cts → leaderboard-chart-BSbg0ufV.d.cts} +3 -7
- package/dist/{leaderboard-chart-BKYYXcg2.d.ts → leaderboard-chart-odEYxxEC.d.ts} +3 -7
- package/dist/{legend-C2grwnWk.d.cts → legend-DFkosEvC.d.cts} +1 -1
- package/dist/{legend-Cj0xM5dU.d.ts → legend-DLswHhOk.d.ts} +1 -1
- package/dist/providers/index.cjs +3 -3
- package/dist/providers/index.css +0 -94
- package/dist/providers/index.css.map +1 -1
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +2 -2
- package/dist/{themes-CyjKm-P_.d.cts → themes-D0qc5JaW.d.cts} +2 -2
- package/dist/{themes-BmVGrYnF.d.ts → themes-itO4Ht5g.d.ts} +2 -2
- package/dist/{types-KtOPPzPX.d.cts → types-B5f6XQ7Q.d.cts} +1 -1
- package/dist/{types-CuUEszrM.d.ts → types-BsHooDbM.d.ts} +1 -1
- package/dist/{types-I67mddpr.d.cts → types-BuSrRM4p.d.ts} +3 -32
- package/dist/{types-DZordNiO.d.cts → types-ChOUI9-N.d.cts} +80 -40
- package/dist/{types-DZordNiO.d.ts → types-ChOUI9-N.d.ts} +80 -40
- package/dist/{types-I67mddpr.d.ts → types-Dfw9VOKI.d.cts} +3 -32
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +6 -6
- package/src/charts/bar-chart/bar-chart.tsx +17 -18
- package/src/charts/bar-chart/test/bar-chart.test.tsx +48 -31
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +38 -41
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +4 -5
- package/src/charts/leaderboard-chart/types.ts +1 -11
- package/src/charts/line-chart/line-chart.tsx +18 -16
- package/src/charts/line-chart/test/line-chart.test.tsx +49 -27
- package/src/charts/line-chart/types.ts +0 -1
- package/src/charts/pie-chart/pie-chart.tsx +23 -22
- package/src/charts/pie-chart/test/composition-api.test.tsx +41 -0
- package/src/charts/pie-chart/test/pie-chart.test.tsx +9 -9
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +21 -23
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +33 -5
- package/src/charts/private/chart-composition/index.ts +2 -0
- package/src/charts/private/chart-composition/render-legend-slot.ts +22 -0
- package/src/charts/private/chart-composition/test/render-legend-slot.test.tsx +60 -0
- package/src/charts/private/chart-composition/test/use-chart-children.test.tsx +91 -0
- package/src/charts/private/chart-composition/use-chart-children.ts +34 -2
- package/src/components/legend/index.ts +1 -8
- package/src/components/legend/private/base-legend.module.scss +19 -37
- package/src/components/legend/private/base-legend.tsx +0 -2
- package/src/components/legend/types.ts +7 -34
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +1 -7
- package/src/types.ts +83 -38
- package/src/utils/date-parsing.ts +10 -1
- package/src/utils/test/date-parsing.test.ts +12 -0
- package/src/utils/test/resolve-css-var.test.ts +2 -2
- package/tsup.config.ts +1 -1
- package/dist/chunk-2NCY7R4G.js.map +0 -1
- package/dist/chunk-32DH6JDF.js.map +0 -1
- package/dist/chunk-4OPFE4RM.js.map +0 -1
- package/dist/chunk-6CCZL2JJ.js.map +0 -1
- package/dist/chunk-BCX5THDQ.js.map +0 -1
- package/dist/chunk-DAU3HNEG.js.map +0 -1
- package/dist/chunk-I35UYJJR.cjs.map +0 -1
- package/dist/chunk-RCY6XLGU.cjs.map +0 -1
- package/dist/chunk-RHHVEJHJ.cjs.map +0 -1
- package/dist/chunk-V36ERY7Y.js.map +0 -1
- package/dist/chunk-VJM5XCB4.cjs.map +0 -1
- package/dist/chunk-VTS3PNMS.cjs.map +0 -1
- package/dist/chunk-WLODYNLB.js.map +0 -1
- package/dist/chunk-XKRJL2QT.cjs.map +0 -1
- package/dist/chunk-YE2T52VZ.cjs.map +0 -1
- package/dist/chunk-Z26M4V2M.js.map +0 -1
- package/dist/chunk-Z45KX47P.cjs.map +0 -1
- package/dist/chunk-ZH4F5RMG.cjs.map +0 -1
- package/src/hooks/use-has-legend-child.ts +0 -22
- /package/dist/{chunk-IU4DYUAV.js.map → chunk-4B7BL2DD.js.map} +0 -0
- /package/dist/{chunk-H2V4JMSA.js.map → chunk-DKU775VC.js.map} +0 -0
- /package/dist/{chunk-CZGYJKG6.js.map → chunk-KJHWXOCZ.js.map} +0 -0
- /package/dist/{chunk-PXLEMUGJ.js.map → chunk-MUNOKLLE.js.map} +0 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWYK7EL5Rcjs = require('./chunk-WYK7EL5R.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkMXGLYWVPcjs = require('./chunk-MXGLYWVP.cjs');
|
|
10
|
+
|
|
11
|
+
// src/components/legend/legend.tsx
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
|
|
14
|
+
// src/charts/private/single-chart-context/single-chart-context.tsx
|
|
15
|
+
|
|
16
|
+
var ChartInstanceContext = /* @__PURE__ */ _react.createContext.call(void 0, null);
|
|
17
|
+
var SingleChartContext = ChartInstanceContext;
|
|
18
|
+
|
|
19
|
+
// src/charts/private/single-chart-context/use-single-chart-context.ts
|
|
20
|
+
|
|
21
|
+
var useChartInstanceContext = () => {
|
|
22
|
+
const context = _react.useContext.call(void 0, ChartInstanceContext);
|
|
23
|
+
if (!context) {
|
|
24
|
+
throw new Error("useChartInstanceContext must be used within a Chart component");
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
};
|
|
28
|
+
var useSingleChartContext = useChartInstanceContext;
|
|
29
|
+
|
|
30
|
+
// src/components/legend/private/base-legend.tsx
|
|
31
|
+
var _group = require('@visx/group');
|
|
32
|
+
var _legend = require('@visx/legend');
|
|
33
|
+
var _scale = require('@visx/scale');
|
|
34
|
+
var _clsx = require('clsx'); var _clsx2 = _interopRequireDefault(_clsx);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// src/components/legend/utils/value-or-identity.ts
|
|
38
|
+
function valueOrIdentity(_) {
|
|
39
|
+
if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
|
|
40
|
+
return _.value;
|
|
41
|
+
return _;
|
|
42
|
+
}
|
|
43
|
+
function valueOrIdentityString(_) {
|
|
44
|
+
return String(valueOrIdentity(_));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/components/legend/utils/label-transform-factory.ts
|
|
48
|
+
function labelTransformFactory({
|
|
49
|
+
scale,
|
|
50
|
+
labelFormat
|
|
51
|
+
}) {
|
|
52
|
+
return (d, i) => ({
|
|
53
|
+
datum: d,
|
|
54
|
+
index: i,
|
|
55
|
+
text: `${labelFormat(d, i)}`,
|
|
56
|
+
value: scale(d)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/components/legend/private/base-legend.module.scss
|
|
61
|
+
var base_legend_module_default = {
|
|
62
|
+
"legend": "a8ccharts-89ApsU",
|
|
63
|
+
"legend--horizontal": "a8ccharts-AELBvX",
|
|
64
|
+
"legend--vertical": "a8ccharts-fX8uQe",
|
|
65
|
+
"legend--alignment-start": "a8ccharts-DEe0wg",
|
|
66
|
+
"legend--alignment-center": "a8ccharts-WBKF9I",
|
|
67
|
+
"legend--alignment-end": "a8ccharts-JfwMng",
|
|
68
|
+
"legend-item": "a8ccharts-Vflwq8",
|
|
69
|
+
"legend-item--interactive": "a8ccharts-qGsavM",
|
|
70
|
+
"legend-item--inactive": "a8ccharts-ZtDY-Q",
|
|
71
|
+
"legend-item-label": "a8ccharts-2H65Kr",
|
|
72
|
+
"legend-item-text--wrap": "a8ccharts-faSDBI",
|
|
73
|
+
"legend-item-text--ellipsis": "a8ccharts-FISUIO",
|
|
74
|
+
"legend-item-value": "a8ccharts-DTZlT-"
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/components/legend/private/base-legend.tsx
|
|
78
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
79
|
+
var orientationToFlexDirection = {
|
|
80
|
+
horizontal: "row",
|
|
81
|
+
vertical: "column"
|
|
82
|
+
};
|
|
83
|
+
var LegendText = ({
|
|
84
|
+
text,
|
|
85
|
+
textOverflow,
|
|
86
|
+
maxWidth
|
|
87
|
+
}) => {
|
|
88
|
+
const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
|
|
89
|
+
const [textRef, isTruncated] = _chunkWYK7EL5Rcjs.useTextTruncation.call(void 0, Boolean(isEllipsis));
|
|
90
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
91
|
+
ref: textRef,
|
|
92
|
+
className: _clsx2.default.call(void 0, base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
|
|
93
|
+
style: {
|
|
94
|
+
...maxWidth != null && {
|
|
95
|
+
maxWidth,
|
|
96
|
+
minWidth: 0
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
title: isEllipsis && isTruncated ? text : void 0,
|
|
100
|
+
children: text
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
var BaseLegend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
104
|
+
items,
|
|
105
|
+
className,
|
|
106
|
+
orientation = "horizontal",
|
|
107
|
+
alignment = "center",
|
|
108
|
+
shape = "rect",
|
|
109
|
+
fill = valueOrIdentityString,
|
|
110
|
+
size = valueOrIdentityString,
|
|
111
|
+
labelFormat = valueOrIdentity,
|
|
112
|
+
labelTransform = labelTransformFactory,
|
|
113
|
+
itemStyles,
|
|
114
|
+
itemClassName,
|
|
115
|
+
labelStyles,
|
|
116
|
+
labelClassName,
|
|
117
|
+
shapeStyles,
|
|
118
|
+
render,
|
|
119
|
+
interactive = false,
|
|
120
|
+
chartId
|
|
121
|
+
}, ref) => {
|
|
122
|
+
const {
|
|
123
|
+
margin: itemMargin = "0",
|
|
124
|
+
flexDirection: itemDirection = "row"
|
|
125
|
+
} = _nullishCoalesce(itemStyles, () => ( {}));
|
|
126
|
+
const {
|
|
127
|
+
justifyContent: labelJustifyContent = "flex-start",
|
|
128
|
+
flex: labelFlex = "0 0 auto",
|
|
129
|
+
margin: labelMargin = "0 4px",
|
|
130
|
+
maxWidth,
|
|
131
|
+
textOverflow = "wrap"
|
|
132
|
+
} = _nullishCoalesce(labelStyles, () => ( {}));
|
|
133
|
+
const {
|
|
134
|
+
width: shapeWidth = 16,
|
|
135
|
+
height: shapeHeight = 16,
|
|
136
|
+
margin: shapeMargin = "2px 4px 2px 0"
|
|
137
|
+
} = _nullishCoalesce(shapeStyles, () => ( {}));
|
|
138
|
+
const theme = _chunkWYK7EL5Rcjs.useGlobalChartsTheme.call(void 0, );
|
|
139
|
+
const context = _react.useContext.call(void 0, _chunkWYK7EL5Rcjs.GlobalChartsContext);
|
|
140
|
+
const legendScale = _scale.scaleOrdinal.call(void 0, {
|
|
141
|
+
domain: items.map((item) => item.label),
|
|
142
|
+
range: items.map((item) => item.color)
|
|
143
|
+
});
|
|
144
|
+
const domain = legendScale.domain();
|
|
145
|
+
const getShapeStyle = _react.useCallback.call(void 0, ({
|
|
146
|
+
index
|
|
147
|
+
}) => _optionalChain([items, 'access', _2 => _2[index], 'optionalAccess', _3 => _3.shapeStyle]), [items]);
|
|
148
|
+
const handleLegendClick = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
149
|
+
if (interactive && chartId && context) {
|
|
150
|
+
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
151
|
+
}
|
|
152
|
+
}, [interactive, chartId, context]);
|
|
153
|
+
const isSeriesVisible = _react.useCallback.call(void 0, (seriesLabel) => {
|
|
154
|
+
if (!interactive || !chartId || !context) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return context.isSeriesVisible(chartId, seriesLabel);
|
|
158
|
+
}, [interactive, chartId, context]);
|
|
159
|
+
const createClickHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
160
|
+
if (!interactive) {
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
return () => handleLegendClick(labelText);
|
|
164
|
+
}, [interactive, handleLegendClick]);
|
|
165
|
+
const createKeyDownHandler = _react.useCallback.call(void 0, (labelText) => {
|
|
166
|
+
if (!interactive) {
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
return (event) => {
|
|
170
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
handleLegendClick(labelText);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}, [interactive, handleLegendClick]);
|
|
176
|
+
return render ? render(items) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendOrdinal, {
|
|
177
|
+
scale: legendScale,
|
|
178
|
+
labelFormat,
|
|
179
|
+
labelTransform,
|
|
180
|
+
children: (labels) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
|
|
181
|
+
ref,
|
|
182
|
+
role: "list",
|
|
183
|
+
className: _clsx2.default.call(void 0, base_legend_module_default.legend, base_legend_module_default[`legend--${orientation}`], base_legend_module_default[`legend--alignment-${alignment}`], className),
|
|
184
|
+
style: {
|
|
185
|
+
flexDirection: orientationToFlexDirection[orientation],
|
|
186
|
+
..._optionalChain([theme, 'access', _4 => _4.legend, 'optionalAccess', _5 => _5.containerStyles])
|
|
187
|
+
},
|
|
188
|
+
children: labels.map((label, i) => {
|
|
189
|
+
const visible = isSeriesVisible(label.text);
|
|
190
|
+
const handleClick = createClickHandler(label.text);
|
|
191
|
+
const handleKeyDown = createKeyDownHandler(label.text);
|
|
192
|
+
const matchedItem = items[i];
|
|
193
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendItem, {
|
|
194
|
+
className: _clsx2.default.call(void 0, "visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
|
|
195
|
+
margin: itemMargin,
|
|
196
|
+
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
197
|
+
onClick: handleClick,
|
|
198
|
+
onKeyDown: handleKeyDown,
|
|
199
|
+
role: interactive ? "button" : void 0,
|
|
200
|
+
tabIndex: interactive ? 0 : void 0,
|
|
201
|
+
"aria-pressed": interactive ? visible : void 0,
|
|
202
|
+
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
203
|
+
children: [_optionalChain([items, 'access', _6 => _6[i], 'optionalAccess', _7 => _7.renderGlyph]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", {
|
|
204
|
+
width: _optionalChain([items, 'access', _8 => _8[i], 'optionalAccess', _9 => _9.glyphSize]) * 2,
|
|
205
|
+
height: _optionalChain([items, 'access', _10 => _10[i], 'optionalAccess', _11 => _11.glyphSize]) * 2,
|
|
206
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _group.Group, {
|
|
207
|
+
children: _optionalChain([items, 'access', _12 => _12[i], 'optionalAccess', _13 => _13.renderGlyph, 'call', _14 => _14({
|
|
208
|
+
key: `legend-glyph-${label.text}`,
|
|
209
|
+
datum: {},
|
|
210
|
+
index: i,
|
|
211
|
+
color: fill(label),
|
|
212
|
+
size: _optionalChain([items, 'access', _15 => _15[i], 'optionalAccess', _16 => _16.glyphSize]),
|
|
213
|
+
x: _optionalChain([items, 'access', _17 => _17[i], 'optionalAccess', _18 => _18.glyphSize]),
|
|
214
|
+
y: _optionalChain([items, 'access', _19 => _19[i], 'optionalAccess', _20 => _20.glyphSize])
|
|
215
|
+
})])
|
|
216
|
+
})
|
|
217
|
+
}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _legend.LegendShape, {
|
|
218
|
+
shape,
|
|
219
|
+
height: shapeHeight,
|
|
220
|
+
width: shapeWidth,
|
|
221
|
+
margin: shapeMargin,
|
|
222
|
+
item: domain[i],
|
|
223
|
+
itemIndex: i,
|
|
224
|
+
label,
|
|
225
|
+
fill,
|
|
226
|
+
size,
|
|
227
|
+
shapeStyle: getShapeStyle
|
|
228
|
+
}), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _legend.LegendLabel, {
|
|
229
|
+
className: _clsx2.default.call(void 0, "visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
|
|
230
|
+
style: {
|
|
231
|
+
justifyContent: labelJustifyContent,
|
|
232
|
+
flex: labelFlex,
|
|
233
|
+
margin: labelMargin,
|
|
234
|
+
..._optionalChain([theme, 'access', _21 => _21.legend, 'optionalAccess', _22 => _22.labelStyles])
|
|
235
|
+
},
|
|
236
|
+
children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, LegendText, {
|
|
237
|
+
text: label.text,
|
|
238
|
+
textOverflow,
|
|
239
|
+
maxWidth
|
|
240
|
+
}), _optionalChain([matchedItem, 'optionalAccess', _23 => _23.value]) != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", {
|
|
241
|
+
className: base_legend_module_default["legend-item-value"],
|
|
242
|
+
children: ["\xA0", matchedItem.value]
|
|
243
|
+
})]
|
|
244
|
+
})]
|
|
245
|
+
}, `legend-${label.text}-${i}`);
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// src/components/legend/legend.tsx
|
|
252
|
+
|
|
253
|
+
var Legend = /* @__PURE__ */ _react.forwardRef.call(void 0, ({
|
|
254
|
+
chartId,
|
|
255
|
+
items,
|
|
256
|
+
...props
|
|
257
|
+
}, ref) => {
|
|
258
|
+
const context = _react.useContext.call(void 0, _chunkWYK7EL5Rcjs.GlobalChartsContext);
|
|
259
|
+
const singleChartContext = _react.useContext.call(void 0, SingleChartContext);
|
|
260
|
+
const contextChartId = _nullishCoalesce(chartId, () => ( _optionalChain([singleChartContext, 'optionalAccess', _24 => _24.chartId])));
|
|
261
|
+
const contextItems = _react.useMemo.call(void 0, () => {
|
|
262
|
+
return contextChartId && context ? _optionalChain([context, 'access', _25 => _25.getChartData, 'call', _26 => _26(contextChartId), 'optionalAccess', _27 => _27.legendItems]) : void 0;
|
|
263
|
+
}, [contextChartId, context]);
|
|
264
|
+
const legendItems = items || contextItems;
|
|
265
|
+
if (!legendItems) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BaseLegend, {
|
|
269
|
+
ref,
|
|
270
|
+
items: legendItems,
|
|
271
|
+
...props,
|
|
272
|
+
chartId: contextChartId
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// src/components/legend/hooks/use-chart-legend-items.ts
|
|
277
|
+
var _numberformatters = require('@automattic/number-formatters');
|
|
278
|
+
|
|
279
|
+
function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
|
|
280
|
+
if (!showValues || legendValueDisplay === "none") {
|
|
281
|
+
return "";
|
|
282
|
+
}
|
|
283
|
+
if ("percentage" in point) {
|
|
284
|
+
const percentagePoint = point;
|
|
285
|
+
switch (legendValueDisplay) {
|
|
286
|
+
case "percentage":
|
|
287
|
+
return _chunkMXGLYWVPcjs.formatPercentage.call(void 0, percentagePoint.percentage);
|
|
288
|
+
case "value":
|
|
289
|
+
return _numberformatters.formatNumber.call(void 0, percentagePoint.value);
|
|
290
|
+
case "valueDisplay":
|
|
291
|
+
return percentagePoint.valueDisplay || _numberformatters.formatNumber.call(void 0, percentagePoint.value);
|
|
292
|
+
default:
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if ("value" in point) {
|
|
297
|
+
return point.value !== null ? _numberformatters.formatNumber.call(void 0, point.value) : "";
|
|
298
|
+
}
|
|
299
|
+
return "";
|
|
300
|
+
}
|
|
301
|
+
function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
|
|
302
|
+
if (withGlyph) {
|
|
303
|
+
const glyphToUse = glyph || renderGlyph;
|
|
304
|
+
if (glyphToUse) {
|
|
305
|
+
return {
|
|
306
|
+
...baseItem,
|
|
307
|
+
glyphSize,
|
|
308
|
+
renderGlyph: glyphToUse
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return baseItem;
|
|
313
|
+
}
|
|
314
|
+
function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
315
|
+
const mapper = (series, index) => {
|
|
316
|
+
const { color, glyph, shapeStyles } = getElementStyles({
|
|
317
|
+
data: series,
|
|
318
|
+
index,
|
|
319
|
+
legendShape
|
|
320
|
+
});
|
|
321
|
+
const baseItem = {
|
|
322
|
+
label: series.label,
|
|
323
|
+
value: showValues ? _optionalChain([series, 'access', _28 => _28.data, 'optionalAccess', _29 => _29.length, 'optionalAccess', _30 => _30.toString, 'call', _31 => _31()]) || "0" : "",
|
|
324
|
+
color,
|
|
325
|
+
shapeStyle: shapeStyles
|
|
326
|
+
};
|
|
327
|
+
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
328
|
+
};
|
|
329
|
+
return seriesData.map(mapper);
|
|
330
|
+
}
|
|
331
|
+
function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
332
|
+
const mapper = (point, index) => {
|
|
333
|
+
const { color, glyph, shapeStyles } = getElementStyles({
|
|
334
|
+
data: point,
|
|
335
|
+
index,
|
|
336
|
+
legendShape
|
|
337
|
+
});
|
|
338
|
+
const baseItem = {
|
|
339
|
+
label: point.label,
|
|
340
|
+
value: formatPointValue(point, showValues, legendValueDisplay),
|
|
341
|
+
color,
|
|
342
|
+
shapeStyle: shapeStyles
|
|
343
|
+
};
|
|
344
|
+
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
345
|
+
};
|
|
346
|
+
return pointData.map(mapper);
|
|
347
|
+
}
|
|
348
|
+
function useChartLegendItems(data, options = {}, legendShape) {
|
|
349
|
+
const {
|
|
350
|
+
showValues = false,
|
|
351
|
+
legendValueDisplay = "percentage",
|
|
352
|
+
withGlyph = false,
|
|
353
|
+
glyphSize = 8,
|
|
354
|
+
renderGlyph
|
|
355
|
+
} = options;
|
|
356
|
+
const { getElementStyles } = _chunkWYK7EL5Rcjs.useGlobalChartsContext.call(void 0, );
|
|
357
|
+
return _react.useMemo.call(void 0, () => {
|
|
358
|
+
if (!data || !Array.isArray(data) || data.length === 0) {
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
if ("data" in data[0]) {
|
|
362
|
+
return processSeriesData(
|
|
363
|
+
data,
|
|
364
|
+
getElementStyles,
|
|
365
|
+
showValues,
|
|
366
|
+
withGlyph,
|
|
367
|
+
glyphSize,
|
|
368
|
+
renderGlyph,
|
|
369
|
+
legendShape
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return processPointData(
|
|
373
|
+
data,
|
|
374
|
+
getElementStyles,
|
|
375
|
+
showValues,
|
|
376
|
+
legendValueDisplay,
|
|
377
|
+
withGlyph,
|
|
378
|
+
glyphSize,
|
|
379
|
+
renderGlyph,
|
|
380
|
+
legendShape
|
|
381
|
+
);
|
|
382
|
+
}, [
|
|
383
|
+
data,
|
|
384
|
+
getElementStyles,
|
|
385
|
+
showValues,
|
|
386
|
+
legendValueDisplay,
|
|
387
|
+
withGlyph,
|
|
388
|
+
glyphSize,
|
|
389
|
+
renderGlyph,
|
|
390
|
+
legendShape
|
|
391
|
+
]);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
exports.SingleChartContext = SingleChartContext; exports.useSingleChartContext = useSingleChartContext; exports.Legend = Legend; exports.useChartLegendItems = useChartLegendItems;
|
|
400
|
+
//# sourceMappingURL=chunk-XVBH5XHE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-XVBH5XHE.cjs","../src/components/legend/legend.tsx","../src/charts/private/single-chart-context/single-chart-context.tsx","../src/charts/private/single-chart-context/use-single-chart-context.ts","../src/components/legend/private/base-legend.tsx","../src/components/legend/utils/value-or-identity.ts","../src/components/legend/utils/label-transform-factory.ts","../src/components/legend/private/base-legend.module.scss","../src/components/legend/hooks/use-chart-legend-items.ts"],"names":["useMemo"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAgD;ADYhD;AACA;AEbA;AAIO,IAAM,qBAAA,kBAAoC,kCAAA,IAAkB,CAAA;AAG5D,IAAM,mBAAA,EAAqB,oBAAA;AFUlC;AACA;AGlBA;AAGO,IAAM,wBAAA,EAA0B,CAAA,EAAA,GAAiC;AACvE,EAAA,MAAM,QAAA,EAAU,+BAAA,oBAAiC,CAAA;AACjD,EAAA,GAAA,CAAK,CAAE,OAAA,EAAU;AAChB,IAAA,MAAM,IAAI,KAAA,CAAO,+DAAgE,CAAA;AAAA,EAClF;AACA,EAAA,OAAO,OAAA;AACR,CAAA;AAEO,IAAM,sBAAA,EAAwB,uBAAA;AHiBrC;AACA;AI7BA,oCAAsB;AACtB,sCAAoE;AACpE,oCAA6B;AAC7B,wEAAiB;AACjB;AJ+BA;AACA;AK7BO,SAAS,eAAA,CAAsB,CAAA,EAA6B;AAClE,EAAA,GAAA,CAAK,EAAA,GAAK,OAAO,EAAA,IAAM,SAAA,GAAY,QAAA,GAAW,EAAA,GAAK,OAAO,CAAA,CAAE,MAAA,IAAU,WAAA;AACrE,IAAA,OAAO,CAAA,CAAE,KAAA;AACV,EAAA,OAAO,CAAA;AACR;AAOO,SAAS,qBAAA,CAA4B,CAAA,EAAkC;AAC7E,EAAA,OAAO,MAAA,CAAQ,eAAA,CAAiB,CAAE,CAAE,CAAA;AACrC;ALyBA;AACA;AMpCO,SAAS,qBAAA,CAAmD;AAAA,EAClE,KAAA;AAAA,EACA;AACD,CAAA,EAGiE;AAChE,EAAA,OAAO,CAAE,CAAA,EAAG,CAAA,EAAA,GAAA,CAAS;AAAA,IACpB,KAAA,EAAO,CAAA;AAAA,IACP,KAAA,EAAO,CAAA;AAAA,IACP,IAAA,EAAM,CAAA,EAAA;AACC,IAAA;AACR,EAAA;AACD;ANmCW;AACA;AO3DqE;AAC9E,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AP6DW;AACA;AInEF;AACH;AACJ,EAAA;AACA,EAAA;AACF;AAIM;AACJ,EAAA;AACA,EAAA;AACA,EAAA;AACI;AACE,EAAA;AACC,EAAA;AACa,EAAA;AACb,IAAA;AACL,IAAA;AACO,IAAA;AACD,MAAA;AACF,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACO,IAAA;AACP,IAAA;AACD,EAAA;AACH;AAMa;AACX,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACQ,EAAA;AACD,EAAA;AACA,EAAA;AACP,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACS;AACH,EAAA;AACJ,IAAA;AACA,IAAA;AACE,EAAA;AACE,EAAA;AACJ,IAAA;AACM,IAAA;AACN,IAAA;AACA,IAAA;AACA,IAAA;AACE,EAAA;AACE,EAAA;AACG,IAAA;AACP,IAAA;AACA,IAAA;AACE,EAAA;AACE,EAAA;AACA,EAAA;AACA,EAAA;AACJ,IAAA;AACO,IAAA;AACR,EAAA;AACK,EAAA;AACA,EAAA;AACJ,IAAA;AACI,EAAA;AAGA,EAAA;AACA,IAAA;AACF,MAAA;AACF,IAAA;AACE,EAAA;AAGE,EAAA;AACC,IAAA;AACH,MAAA;AACF,IAAA;AACO,IAAA;AACL,EAAA;AAGE,EAAA;AACC,IAAA;AACH,MAAA;AACF,IAAA;AACO,IAAA;AACL,EAAA;AACE,EAAA;AACC,IAAA;AACH,MAAA;AACF,IAAA;AACO,IAAA;AACD,MAAA;AACF,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACE,EAAA;AACG,EAAA;AACE,IAAA;AACP,IAAA;AACA,IAAA;AACA,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACE,QAAA;AACG,QAAA;AACL,MAAA;AACA,MAAA;AACE,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACE,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AAA4D,YAAA;AAC7B,YAAA;AACC,YAAA;AACK,cAAA;AACD,gBAAA;AACC,gBAAA;AACvB,gBAAA;AACD,gBAAA;AACU,gBAAA;AACD,gBAAA;AACH,gBAAA;AACA,cAAA;AACd,YAAA;AAEJ,UAAA;AAAmC,YAAA;AAClC,YAAA;AACQ,YAAA;AACD,YAAA;AACC,YAAA;AACM,YAAA;AACH,YAAA;AACX,YAAA;AACA,YAAA;AACA,YAAA;AAED,UAAA;AAAmC,YAAA;AAC8C,YAAA;AACzE,cAAA;AACW,cAAA;AACV,cAAA;AACE,cAAA;AACS,YAAA;AACnB,YAAA;AACyC,cAAA;AAC3B,cAAA;AACZ,cAAA;AACA,YAAA;AACuF,cAAA;AAClD,cAAA;AACC,YAAA;AAEzC,UAAA;AACA,QAAA;AACJ,MAAA;AACF,IAAA;AACF,EAAA;AACF;AJuDU;AACA;ACtPF;AACI;AACX,EAAA;AACA,EAAA;AACG,EAAA;AACM;AAEH,EAAA;AACA,EAAA;AAIA,EAAA;AAGA,EAAA;AACG,IAAA;AACL,EAAA;AAGE,EAAA;AACD,EAAA;AACI,IAAA;AACT,EAAA;AACoB,EAAA;AAClB,IAAA;AACO,IAAA;AACJ,IAAA;AACH,IAAA;AACD,EAAA;AACF;ADgPU;AACA;AQnRF;AACA;AA+BA;AAKD,EAAA;AACC,IAAA;AACR,EAAA;AAGK,EAAA;AACE,IAAA;AACN,IAAA;AACM,MAAA;AACJ,QAAA;AACI,MAAA;AACJ,QAAA;AACI,MAAA;AACJ,QAAA;AACD,MAAA;AACC,QAAA;AACF,IAAA;AACD,EAAA;AAGK,EAAA;AACG,IAAA;AACR,EAAA;AAEO,EAAA;AACR;AAWS;AAOH,EAAA;AACE,IAAA;AACD,IAAA;AACJ,MAAA;AACI,QAAA;AACH,QAAA;AACA,QAAA;AACD,MAAA;AACD,IAAA;AACD,EAAA;AAEO,EAAA;AACR;AAaS;AASF,EAAA;AACC,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACC,IAAA;AAEI,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AAEO,IAAA;AACR,EAAA;AAEO,EAAA;AACR;AAcS;AAUF,EAAA;AACC,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACC,IAAA;AAEI,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AAEO,IAAA;AACR,EAAA;AAEO,EAAA;AACR;AASgB;AAOT,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACG,EAAA;AACI,EAAA;AAEDA,EAAAA;AACC,IAAA;AACN,MAAA;AACD,IAAA;AAGK,IAAA;AACJ,MAAA;AACC,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AACD,IAAA;AAGO,IAAA;AACN,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACD,IAAA;AACE,EAAA;AACF,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACC,EAAA;AACH;AR0JW;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/jetpack/jetpack/projects/js-packages/charts/dist/chunk-XVBH5XHE.cjs","sourcesContent":[null,"import { useContext, useMemo, forwardRef } from 'react';\nimport { SingleChartContext } from '../../charts/private/single-chart-context';\nimport { GlobalChartsContext } from '../../providers';\nimport { BaseLegend } from './private';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const Legend = /*#__PURE__*/forwardRef(({\n chartId,\n items,\n ...props\n}, ref) => {\n // Get context but don't throw if it doesn't exist\n const context = useContext(GlobalChartsContext);\n const singleChartContext = useContext(SingleChartContext);\n\n // When chartId is used, it is standalone mode\n // When chartId is not provided, we use the context's chartId, meaning it is in a single chart context\n const contextChartId = chartId ?? singleChartContext?.chartId;\n\n // Use useMemo to ensure re-rendering when context changes\n const contextItems = useMemo(() => {\n return contextChartId && context ? context.getChartData(contextChartId)?.legendItems : undefined;\n }, [contextChartId, context]);\n\n // Provided items take precedence over context items\n const legendItems = items || contextItems;\n if (!legendItems) {\n return null;\n }\n return /*#__PURE__*/_jsx(BaseLegend, {\n ref: ref,\n items: legendItems,\n ...props,\n chartId: contextChartId\n });\n});","import { createContext } from 'react';\n\n// Local context for chart implicit state sharing\n\nexport const ChartInstanceContext = /*#__PURE__*/createContext(null);\n\n// Backward compatibility exports\nexport const SingleChartContext = ChartInstanceContext;","import { useContext } from 'react';\nimport { ChartInstanceContext, type ChartInstanceContextValue } from './single-chart-context';\n\nexport const useChartInstanceContext = (): ChartInstanceContextValue => {\n\tconst context = useContext( ChartInstanceContext );\n\tif ( ! context ) {\n\t\tthrow new Error( 'useChartInstanceContext must be used within a Chart component' );\n\t}\n\treturn context;\n};\n\nexport const useSingleChartContext = useChartInstanceContext;\n","import { Group } from '@visx/group';\nimport { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from '@visx/legend';\nimport { scaleOrdinal } from '@visx/scale';\nimport clsx from 'clsx';\nimport { forwardRef, useCallback, useContext } from 'react';\nimport { useTextTruncation } from '../../../hooks';\nimport { GlobalChartsContext, useGlobalChartsTheme } from '../../../providers';\nimport { valueOrIdentity, valueOrIdentityString, labelTransformFactory } from '../utils';\nimport styles from './base-legend.module.scss';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst orientationToFlexDirection = {\n horizontal: 'row',\n vertical: 'column'\n};\n\n// Component for legend text with truncation detection\n// Moved outside BaseLegend to prevent recreation on every render\nconst LegendText = ({\n text,\n textOverflow,\n maxWidth\n}) => {\n const isEllipsis = maxWidth != null && textOverflow === 'ellipsis';\n const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));\n return /*#__PURE__*/_jsx(\"span\", {\n ref: textRef,\n className: clsx(styles['legend-item-text'], maxWidth != null && styles[`legend-item-text--${textOverflow}`]),\n style: {\n ...(maxWidth != null && {\n maxWidth,\n minWidth: 0\n })\n },\n title: isEllipsis && isTruncated ? text : undefined,\n children: text\n });\n};\n\n/*\n * Base legend component that displays color-coded items with labels based on visx LegendOrdinal.\n * We avoid using LegendOrdinal directly to enable support for advanced features such as interactivity.\n */\nexport const BaseLegend = /*#__PURE__*/forwardRef(({\n items,\n className,\n orientation = 'horizontal',\n alignment = 'center',\n shape = 'rect',\n fill = valueOrIdentityString,\n size = valueOrIdentityString,\n labelFormat = valueOrIdentity,\n labelTransform = labelTransformFactory,\n itemStyles,\n itemClassName,\n labelStyles,\n labelClassName,\n shapeStyles,\n render,\n interactive = false,\n chartId\n}, ref) => {\n const {\n margin: itemMargin = '0',\n flexDirection: itemDirection = 'row'\n } = itemStyles ?? {};\n const {\n justifyContent: labelJustifyContent = 'flex-start',\n flex: labelFlex = '0 0 auto',\n margin: labelMargin = '0 4px',\n maxWidth,\n textOverflow = 'wrap'\n } = labelStyles ?? {};\n const {\n width: shapeWidth = 16,\n height: shapeHeight = 16,\n margin: shapeMargin = '2px 4px 2px 0'\n } = shapeStyles ?? {};\n const theme = useGlobalChartsTheme();\n const context = useContext(GlobalChartsContext);\n const legendScale = scaleOrdinal({\n domain: items.map(item => item.label),\n range: items.map(item => item.color)\n });\n const domain = legendScale.domain();\n const getShapeStyle = useCallback(({\n index\n }) => items[index]?.shapeStyle, [items]);\n\n // Handle legend item clicks for interactive mode\n const handleLegendClick = useCallback(seriesLabel => {\n if (interactive && chartId && context) {\n context.toggleSeriesVisibility(chartId, seriesLabel);\n }\n }, [interactive, chartId, context]);\n\n // Check if a series is visible\n const isSeriesVisible = useCallback(seriesLabel => {\n if (!interactive || !chartId || !context) {\n return true;\n }\n return context.isSeriesVisible(chartId, seriesLabel);\n }, [interactive, chartId, context]);\n\n // Create event handlers to avoid inline arrow functions\n const createClickHandler = useCallback(labelText => {\n if (!interactive) {\n return undefined;\n }\n return () => handleLegendClick(labelText);\n }, [interactive, handleLegendClick]);\n const createKeyDownHandler = useCallback(labelText => {\n if (!interactive) {\n return undefined;\n }\n return event => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleLegendClick(labelText);\n }\n };\n }, [interactive, handleLegendClick]);\n return render ? render(items) : /*#__PURE__*/_jsx(LegendOrdinal, {\n scale: legendScale,\n labelFormat: labelFormat,\n labelTransform: labelTransform,\n children: labels => /*#__PURE__*/_jsx(\"div\", {\n ref: ref,\n role: \"list\",\n className: clsx(styles.legend, styles[`legend--${orientation}`], styles[`legend--alignment-${alignment}`], className),\n style: {\n flexDirection: orientationToFlexDirection[orientation],\n ...theme.legend?.containerStyles\n },\n children: labels.map((label, i) => {\n const visible = isSeriesVisible(label.text);\n const handleClick = createClickHandler(label.text);\n const handleKeyDown = createKeyDownHandler(label.text);\n const matchedItem = items[i];\n return /*#__PURE__*/_jsxs(LegendItem, {\n className: clsx('visx-legend-item', styles['legend-item'], interactive && styles['legend-item--interactive'], !visible && styles['legend-item--inactive'], itemClassName),\n margin: itemMargin,\n flexDirection: orientation === 'vertical' && alignment === 'end' ? 'row-reverse' : itemDirection,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n role: interactive ? 'button' : undefined,\n tabIndex: interactive ? 0 : undefined,\n \"aria-pressed\": interactive ? visible : undefined,\n \"aria-label\": interactive ? `${label.text}: ${visible ? 'visible' : 'hidden'}. Toggle visibility.` : undefined,\n children: [items[i]?.renderGlyph ? /*#__PURE__*/_jsx(\"svg\", {\n width: items[i]?.glyphSize * 2,\n height: items[i]?.glyphSize * 2,\n children: /*#__PURE__*/_jsx(Group, {\n children: items[i]?.renderGlyph({\n key: `legend-glyph-${label.text}`,\n datum: {},\n index: i,\n color: fill(label),\n size: items[i]?.glyphSize,\n x: items[i]?.glyphSize,\n y: items[i]?.glyphSize\n })\n })\n }) : /*#__PURE__*/_jsx(LegendShape, {\n shape: shape,\n height: shapeHeight,\n width: shapeWidth,\n margin: shapeMargin,\n item: domain[i],\n itemIndex: i,\n label: label,\n fill: fill,\n size: size,\n shapeStyle: getShapeStyle\n }), /*#__PURE__*/_jsxs(LegendLabel, {\n className: clsx('visx-legend-label', styles['legend-item-label'], labelClassName),\n style: {\n justifyContent: labelJustifyContent,\n flex: labelFlex,\n margin: labelMargin,\n ...theme.legend?.labelStyles\n },\n children: [/*#__PURE__*/_jsx(LegendText, {\n text: label.text,\n textOverflow: textOverflow,\n maxWidth: maxWidth\n }), matchedItem?.value != null && matchedItem.value !== '' && /*#__PURE__*/_jsxs(\"span\", {\n className: styles['legend-item-value'],\n children: ['\\u00A0', matchedItem.value]\n })]\n })]\n }, `legend-${label.text}-${i}`);\n })\n })\n });\n});","export type ValueOrIdentity< T > = T | { value?: T };\n\n/**\n * Returns an object's value if defined, or the object.\n * @param _ - The object to return the value of.\n * @return The value of the object, or the object itself.\n */\nexport function valueOrIdentity< T >( _: ValueOrIdentity< T > ): T {\n\tif ( _ && typeof _ === 'object' && 'value' in _ && typeof _.value !== 'undefined' )\n\t\treturn _.value;\n\treturn _ as T;\n}\n\n/**\n * Returns an object's value if defined, or the object, coerced to a string.\n * @param _ - The object to return the value of.\n * @return The value of the object, or the object itself.\n */\nexport function valueOrIdentityString< T >( _: ValueOrIdentity< T > ): string {\n\treturn String( valueOrIdentity( _ ) );\n}\n","import type { ItemTransformer, LabelFormatter } from '@visx/legend/lib/types';\nimport type { AnyD3Scale, ScaleInput } from '@visx/scale';\n\n/**\n * Returns a function which takes a Datum and index as input, and returns a formatted label object.\n * @param {object} root0 - The object to return the value of.\n * @param {AnyD3Scale} root0.scale - The scale to use.\n * @param {LabelFormatter<ScaleInput<Scale>>} root0.labelFormat - The label format to use.\n * @return {ItemTransformer<ScaleInput<Scale>, ReturnType<Scale>>} The label transform factory.\n */\nexport function labelTransformFactory< Scale extends AnyD3Scale >( {\n\tscale,\n\tlabelFormat,\n}: {\n\tscale: Scale;\n\tlabelFormat: LabelFormatter< ScaleInput< Scale > >;\n} ): ItemTransformer< ScaleInput< Scale >, ReturnType< Scale > > {\n\treturn ( d, i ) => ( {\n\t\tdatum: d,\n\t\tindex: i,\n\t\ttext: `${ labelFormat( d, i ) }`,\n\t\tvalue: scale( d ),\n\t} );\n}\n","import 'css-chunk:src/components/legend/private/base-legend.module.scss';export default {\n \"legend\": \"a8ccharts-89ApsU\",\n \"legend--horizontal\": \"a8ccharts-AELBvX\",\n \"legend--vertical\": \"a8ccharts-fX8uQe\",\n \"legend--alignment-start\": \"a8ccharts-DEe0wg\",\n \"legend--alignment-center\": \"a8ccharts-WBKF9I\",\n \"legend--alignment-end\": \"a8ccharts-JfwMng\",\n \"legend-item\": \"a8ccharts-Vflwq8\",\n \"legend-item--interactive\": \"a8ccharts-qGsavM\",\n \"legend-item--inactive\": \"a8ccharts-ZtDY-Q\",\n \"legend-item-label\": \"a8ccharts-2H65Kr\",\n \"legend-item-text--wrap\": \"a8ccharts-faSDBI\",\n \"legend-item-text--ellipsis\": \"a8ccharts-FISUIO\",\n \"legend-item-value\": \"a8ccharts-DTZlT-\"\n};","import { formatNumber } from '@automattic/number-formatters';\nimport { useMemo } from 'react';\nimport {\n\tuseGlobalChartsContext,\n\ttype GetElementStylesParams,\n\ttype ElementStyles,\n} from '../../../providers';\nimport { formatPercentage } from '../../../utils';\nimport type { SeriesData, DataPointDate, DataPointPercentage } from '../../../types';\nimport type { BaseLegendItem } from '../types';\nimport type { LegendShape } from '@visx/legend/lib/types';\nimport type { GlyphProps } from '@visx/xychart';\nimport type { ReactNode } from 'react';\n\nexport type LegendValueDisplay = 'percentage' | 'value' | 'valueDisplay' | 'none';\n\nexport interface ChartLegendOptions {\n\twithGlyph?: boolean;\n\tglyphSize?: number;\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode;\n\tshowValues?: boolean;\n\tlegendValueDisplay?: LegendValueDisplay;\n\tlegendShape?: LegendShape< SeriesData[], number >;\n}\n\n/**\n * Formats the value for a data point based on its type and display preference\n * @param point - The data point to format\n * @param showValues - Whether to show values or return empty string\n * @param legendValueDisplay - What type of value to display\n * @return Formatted value string\n */\nfunction formatPointValue(\n\tpoint: DataPointDate | DataPointPercentage,\n\tshowValues: boolean,\n\tlegendValueDisplay: LegendValueDisplay = 'percentage'\n): string {\n\tif ( ! showValues || legendValueDisplay === 'none' ) {\n\t\treturn '';\n\t}\n\n\t// Handle DataPointPercentage (pie chart data)\n\tif ( 'percentage' in point ) {\n\t\tconst percentagePoint = point as DataPointPercentage;\n\t\tswitch ( legendValueDisplay ) {\n\t\t\tcase 'percentage':\n\t\t\t\treturn formatPercentage( percentagePoint.percentage );\n\t\t\tcase 'value':\n\t\t\t\treturn formatNumber( percentagePoint.value );\n\t\t\tcase 'valueDisplay':\n\t\t\t\treturn percentagePoint.valueDisplay || formatNumber( percentagePoint.value );\n\t\t\tdefault:\n\t\t\t\treturn '';\n\t\t}\n\t}\n\n\t// Handle DataPointDate (time series data)\n\tif ( 'value' in point ) {\n\t\treturn point.value !== null ? formatNumber( point.value ) : '';\n\t}\n\n\treturn '';\n}\n\n/**\n * Applies glyph configuration to a legend item if needed\n * @param baseItem - The base legend item\n * @param withGlyph - Whether to include glyph rendering\n * @param glyph - Glyph component from theme\n * @param renderGlyph - Custom glyph render function\n * @param glyphSize - Size of the glyph\n * @return The legend item with glyph configuration applied if applicable\n */\nfunction applyGlyphToLegendItem(\n\tbaseItem: BaseLegendItem,\n\twithGlyph: boolean,\n\tglyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tglyphSize?: number\n): BaseLegendItem {\n\tif ( withGlyph ) {\n\t\tconst glyphToUse = glyph || renderGlyph;\n\t\tif ( glyphToUse ) {\n\t\t\treturn {\n\t\t\t\t...baseItem,\n\t\t\t\tglyphSize,\n\t\t\t\trenderGlyph: glyphToUse,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn baseItem;\n}\n\n/**\n * Processes SeriesData into legend items\n * @param seriesData - The series data to process\n * @param getElementStyles - Function to get element styles\n * @param showValues - Whether to show values in legend\n * @param withGlyph - Whether to include glyph rendering\n * @param glyphSize - Size of the glyph\n * @param renderGlyph - Component to render the glyph\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of processed legend items\n */\nfunction processSeriesData(\n\tseriesData: SeriesData[],\n\tgetElementStyles: ( params: GetElementStylesParams ) => ElementStyles,\n\tshowValues: boolean,\n\twithGlyph: boolean,\n\tglyphSize: number,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst mapper = ( series: SeriesData, index: number ) => {\n\t\tconst { color, glyph, shapeStyles } = getElementStyles( {\n\t\t\tdata: series,\n\t\t\tindex,\n\t\t\tlegendShape,\n\t\t} );\n\n\t\tconst baseItem: BaseLegendItem = {\n\t\t\tlabel: series.label,\n\t\t\tvalue: showValues ? series.data?.length?.toString() || '0' : '',\n\t\t\tcolor,\n\t\t\tshapeStyle: shapeStyles,\n\t\t};\n\n\t\treturn applyGlyphToLegendItem( baseItem, withGlyph, glyph, renderGlyph, glyphSize );\n\t};\n\n\treturn seriesData.map( mapper );\n}\n\n/**\n * Processes point data into legend items\n * @param pointData - The point data to process\n * @param getElementStyles - Function to get element styles\n * @param showValues - Whether to show values in legend\n * @param legendValueDisplay - What type of value to display\n * @param withGlyph - Whether to include glyph rendering\n * @param glyphSize - Size of the glyph\n * @param renderGlyph - Component to render the glyph\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of processed legend items\n */\nfunction processPointData(\n\tpointData: ( DataPointDate | DataPointPercentage )[],\n\tgetElementStyles: ( params: GetElementStylesParams ) => ElementStyles,\n\tshowValues: boolean,\n\tlegendValueDisplay: LegendValueDisplay,\n\twithGlyph: boolean,\n\tglyphSize: number,\n\trenderGlyph?: < Datum extends object >( props: GlyphProps< Datum > ) => ReactNode,\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst mapper = ( point: DataPointDate | DataPointPercentage, index: number ) => {\n\t\tconst { color, glyph, shapeStyles } = getElementStyles( {\n\t\t\tdata: point as DataPointPercentage,\n\t\t\tindex,\n\t\t\tlegendShape,\n\t\t} );\n\n\t\tconst baseItem: BaseLegendItem = {\n\t\t\tlabel: point.label,\n\t\t\tvalue: formatPointValue( point, showValues, legendValueDisplay ),\n\t\t\tcolor,\n\t\t\tshapeStyle: shapeStyles,\n\t\t};\n\n\t\treturn applyGlyphToLegendItem( baseItem, withGlyph, glyph, renderGlyph, glyphSize );\n\t};\n\n\treturn pointData.map( mapper );\n}\n\n/**\n * Hook to transform chart data into legend items\n * @param data - The chart data to transform\n * @param options - Configuration options for legend generation\n * @param legendShape - The shape type for legend items (string literal or React component)\n * @return Array of legend items ready for display\n */\nexport function useChartLegendItems<\n\tT extends SeriesData[] | DataPointDate[] | DataPointPercentage[],\n>(\n\tdata: T,\n\toptions: ChartLegendOptions = {},\n\tlegendShape?: LegendShape< SeriesData[], number >\n): BaseLegendItem[] {\n\tconst {\n\t\tshowValues = false,\n\t\tlegendValueDisplay = 'percentage',\n\t\twithGlyph = false,\n\t\tglyphSize = 8,\n\t\trenderGlyph,\n\t} = options;\n\tconst { getElementStyles } = useGlobalChartsContext();\n\n\treturn useMemo( () => {\n\t\tif ( ! data || ! Array.isArray( data ) || data.length === 0 ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Handle SeriesData (multiple series with data points)\n\t\tif ( 'data' in data[ 0 ] ) {\n\t\t\treturn processSeriesData(\n\t\t\t\tdata as SeriesData[],\n\t\t\t\tgetElementStyles,\n\t\t\t\tshowValues,\n\t\t\t\twithGlyph,\n\t\t\t\tglyphSize,\n\t\t\t\trenderGlyph,\n\t\t\t\tlegendShape\n\t\t\t);\n\t\t}\n\n\t\t// Handle DataPointDate or DataPointPercentage (single data points)\n\t\treturn processPointData(\n\t\t\tdata as ( DataPointDate | DataPointPercentage )[],\n\t\t\tgetElementStyles,\n\t\t\tshowValues,\n\t\t\tlegendValueDisplay,\n\t\t\twithGlyph,\n\t\t\tglyphSize,\n\t\t\trenderGlyph,\n\t\t\tlegendShape\n\t\t);\n\t}, [\n\t\tdata,\n\t\tgetElementStyles,\n\t\tshowValues,\n\t\tlegendValueDisplay,\n\t\twithGlyph,\n\t\tglyphSize,\n\t\trenderGlyph,\n\t\tlegendShape,\n\t] );\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../../node_modules/.pnpm/@wordpress+element@6.
|
|
1
|
+
// ../../../node_modules/.pnpm/@wordpress+element@6.41.0/node_modules/@wordpress/element/build-module/react.mjs
|
|
2
2
|
import {
|
|
3
3
|
Children,
|
|
4
4
|
cloneElement,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
Suspense
|
|
33
33
|
} from "react";
|
|
34
34
|
|
|
35
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
35
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useRefWithInit.js
|
|
36
36
|
import * as React from "react";
|
|
37
37
|
var UNINITIALIZED = {};
|
|
38
38
|
function useRefWithInit(init, initArg) {
|
|
@@ -43,7 +43,7 @@ function useRefWithInit(init, initArg) {
|
|
|
43
43
|
return ref;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
46
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/formatErrorMessage.js
|
|
47
47
|
function formatErrorMessage(code, ...args) {
|
|
48
48
|
const url = new URL("https://base-ui.com/production-error");
|
|
49
49
|
url.searchParams.set("code", code.toString());
|
|
@@ -51,10 +51,10 @@ function formatErrorMessage(code, ...args) {
|
|
|
51
51
|
return `Base UI error #${code}; visit ${url} for the full message.`;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
54
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
|
|
55
55
|
import * as React4 from "react";
|
|
56
56
|
|
|
57
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
57
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useMergedRefs.js
|
|
58
58
|
function useMergedRefs(a, b, c, d) {
|
|
59
59
|
const forkRef = useRefWithInit(createForkRef).current;
|
|
60
60
|
if (didChange(forkRef, a, b, c, d)) {
|
|
@@ -143,17 +143,17 @@ function update(forkRef, refs) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
146
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
|
|
147
147
|
import * as React3 from "react";
|
|
148
148
|
|
|
149
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
149
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/reactVersion.js
|
|
150
150
|
import * as React2 from "react";
|
|
151
151
|
var majorVersion = parseInt(React2.version, 10);
|
|
152
152
|
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
153
153
|
return majorVersion >= reactVersionToCheck;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
156
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
|
|
157
157
|
function getReactElementRef(element) {
|
|
158
158
|
if (!/* @__PURE__ */ React3.isValidElement(element)) {
|
|
159
159
|
return null;
|
|
@@ -163,7 +163,7 @@ function getReactElementRef(element) {
|
|
|
163
163
|
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
166
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/mergeObjects.js
|
|
167
167
|
function mergeObjects(a, b) {
|
|
168
168
|
if (a && !b) {
|
|
169
169
|
return a;
|
|
@@ -180,7 +180,7 @@ function mergeObjects(a, b) {
|
|
|
180
180
|
return void 0;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
183
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
|
|
184
184
|
function getStateAttributesProps(state, customMapping) {
|
|
185
185
|
const props = {};
|
|
186
186
|
for (const key in state) {
|
|
@@ -201,17 +201,17 @@ function getStateAttributesProps(state, customMapping) {
|
|
|
201
201
|
return props;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
204
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveClassName.js
|
|
205
205
|
function resolveClassName(className, state) {
|
|
206
206
|
return typeof className === "function" ? className(state) : className;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
209
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveStyle.js
|
|
210
210
|
function resolveStyle(style, state) {
|
|
211
211
|
return typeof style === "function" ? style(state) : style;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
214
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/merge-props/mergeProps.js
|
|
215
215
|
var EMPTY_PROPS = {};
|
|
216
216
|
function mergeProps(a, b, c, d, e) {
|
|
217
217
|
let merged = {
|
|
@@ -334,11 +334,11 @@ function isSyntheticEvent(event) {
|
|
|
334
334
|
return event != null && typeof event === "object" && "nativeEvent" in event;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.
|
|
337
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.5_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js
|
|
338
338
|
var EMPTY_ARRAY = Object.freeze([]);
|
|
339
339
|
var EMPTY_OBJECT = Object.freeze({});
|
|
340
340
|
|
|
341
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
341
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
|
|
342
342
|
import { createElement as _createElement } from "react";
|
|
343
343
|
function useRenderElement(element, componentProps, params = {}) {
|
|
344
344
|
const renderProp = componentProps.render;
|
|
@@ -386,6 +386,7 @@ function useRenderElementProps(componentProps, params = {}) {
|
|
|
386
386
|
}
|
|
387
387
|
return outProps;
|
|
388
388
|
}
|
|
389
|
+
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
389
390
|
function evaluateRenderProp(element, render, props, state) {
|
|
390
391
|
if (render) {
|
|
391
392
|
if (typeof render === "function") {
|
|
@@ -393,7 +394,17 @@ function evaluateRenderProp(element, render, props, state) {
|
|
|
393
394
|
}
|
|
394
395
|
const mergedProps = mergeProps(props, render.props);
|
|
395
396
|
mergedProps.ref = props.ref;
|
|
396
|
-
|
|
397
|
+
let newElement = render;
|
|
398
|
+
if (newElement?.$$typeof === REACT_LAZY_TYPE) {
|
|
399
|
+
const children = React4.Children.toArray(render);
|
|
400
|
+
newElement = children[0];
|
|
401
|
+
}
|
|
402
|
+
if (process.env.NODE_ENV !== "production") {
|
|
403
|
+
if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
|
|
404
|
+
throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
|
|
397
408
|
}
|
|
398
409
|
if (element) {
|
|
399
410
|
if (typeof element === "string") {
|
|
@@ -420,22 +431,31 @@ function renderTag(Tag, props) {
|
|
|
420
431
|
return /* @__PURE__ */ React4.createElement(Tag, props);
|
|
421
432
|
}
|
|
422
433
|
|
|
423
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.
|
|
434
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.2.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/use-render/useRender.js
|
|
424
435
|
function useRender(params) {
|
|
425
436
|
return useRenderElement(params.defaultTagName ?? "div", params, params);
|
|
426
437
|
}
|
|
427
438
|
|
|
428
|
-
// ../../../node_modules/.pnpm/@wordpress+ui@0.
|
|
429
|
-
if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
|
|
439
|
+
// ../../../node_modules/.pnpm/@wordpress+ui@0.8.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@16.26.1/node_modules/@wordpress/ui/build-module/stack/stack.mjs
|
|
440
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
|
|
430
441
|
const style = document.createElement("style");
|
|
431
442
|
style.setAttribute("data-wp-hash", "71d20935c2");
|
|
432
443
|
style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
|
|
433
444
|
document.head.appendChild(style);
|
|
434
445
|
}
|
|
435
446
|
var style_default = { "stack": "_19ce0419607e1896__stack" };
|
|
447
|
+
var gapTokens = {
|
|
448
|
+
xs: "var(--wpds-dimension-gap-xs, 4px)",
|
|
449
|
+
sm: "var(--wpds-dimension-gap-sm, 8px)",
|
|
450
|
+
md: "var(--wpds-dimension-gap-md, 12px)",
|
|
451
|
+
lg: "var(--wpds-dimension-gap-lg, 16px)",
|
|
452
|
+
xl: "var(--wpds-dimension-gap-xl, 24px)",
|
|
453
|
+
"2xl": "var(--wpds-dimension-gap-2xl, 32px)",
|
|
454
|
+
"3xl": "var(--wpds-dimension-gap-3xl, 40px)"
|
|
455
|
+
};
|
|
436
456
|
var Stack = forwardRef(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
|
|
437
457
|
const style = {
|
|
438
|
-
gap: gap &&
|
|
458
|
+
gap: gap && gapTokens[gap],
|
|
439
459
|
alignItems: align,
|
|
440
460
|
justifyContent: justify,
|
|
441
461
|
flexDirection: direction,
|
|
@@ -465,4 +485,4 @@ export {
|
|
|
465
485
|
useState,
|
|
466
486
|
Stack
|
|
467
487
|
};
|
|
468
|
-
//# sourceMappingURL=chunk-
|
|
488
|
+
//# sourceMappingURL=chunk-YAFQVVDI.js.map
|