xmlui 0.10.5 → 0.10.7

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -41,7 +41,7 @@ exports.AppHeaderMd = (0, metadata_helpers_1.createMetadata)({
41
41
  "`padding` variants, such as `paddingLeft-logo-AppHeader` and others).",
42
42
  [`width‑logo‑${COMP}`]: "Sets the width of the displayed logo",
43
43
  },
44
- defaultThemeVars: Object.assign(Object.assign(Object.assign({ [`padding-drawerToggle-${COMP}`]: "$space-0_5", [`height-${COMP}`]: "$space-14", [`maxWidth-content-${COMP}`]: "$maxWidth-content-App", [`maxWidth-${COMP}`]: "$maxWidth-App", [`borderBottom-${COMP}`]: "1px solid $borderColor" }, (0, base_utils_1.paddingSubject)(`logo-${COMP}`, { horizontal: "$space-0", vertical: "$space-4" })), (0, base_utils_1.paddingSubject)(COMP, { horizontal: "$space-4", vertical: "$space-0" })), { [`borderRadius-${COMP}`]: "0px", [`backgroundColor-${COMP}`]: "$color-surface-raised" }),
44
+ defaultThemeVars: Object.assign(Object.assign(Object.assign({ [`padding-drawerToggle-${COMP}`]: "$space-0_5", [`height-${COMP}`]: "$space-14", [`maxWidth-content-${COMP}`]: "$maxWidth-content-App", [`maxWidth-${COMP}`]: "$maxWidth-App", [`borderBottom-${COMP}`]: "1px solid $borderColor" }, (0, base_utils_1.paddingSubject)(`logo-${COMP}`, { horizontal: "$space-0", vertical: "$space-0" })), (0, base_utils_1.paddingSubject)(COMP, { horizontal: "$space-4", vertical: "$space-0" })), { [`borderRadius-${COMP}`]: "0px", [`backgroundColor-${COMP}`]: "$color-surface-raised" }),
45
45
  });
46
46
  exports.appHeaderComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.AppHeaderMd, ({ node, renderChild, className, layoutContext, extractValue }) => {
47
47
  var _a, _b;
@@ -59,9 +59,13 @@ exports.defaultProps = {
59
59
  tickFormatterY: (value) => value,
60
60
  showLegend: false,
61
61
  };
62
+ const defaultChartParams = {
63
+ chartWidth: 800,
64
+ chartHeight: 300,
65
+ };
62
66
  function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, stacked = exports.defaultProps.stacked, dataKeys = [], hideTickX = exports.defaultProps.hideTickX, hideTickY = exports.defaultProps.hideTickY, hideY = exports.defaultProps.hideY, hideX = exports.defaultProps.hideX, hideTooltip = exports.defaultProps.hideTooltip, tickFormatterX = exports.defaultProps.tickFormatterX, tickFormatterY = exports.defaultProps.tickFormatterY, style, className, children, showLegend = exports.defaultProps.showLegend, tooltipRenderer, }) {
63
67
  // Validate and normalize data
64
- const validData = Array.isArray(data) ? data : [];
68
+ const validData = (0, react_2.useMemo)(() => (Array.isArray(data) ? data : []), [data]);
65
69
  const { getThemeVar } = (0, ThemeContext_1.useTheme)();
66
70
  const safeTooltipRenderer = (0, react_1.useCallback)((props) => {
67
71
  if (!tooltipRenderer)
@@ -139,12 +143,21 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
139
143
  const wrapperRef = (0, react_1.useRef)(null);
140
144
  (0, react_1.useEffect)(() => {
141
145
  const calc = () => {
142
- var _a, _b, _c, _d, _e;
143
- const width = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 800;
144
- const spans = ((_b = labelsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll("span")) || [];
146
+ var _a, _b, _c;
147
+ const chartWidth = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || defaultChartParams.chartWidth;
148
+ const chartHeight = ((_b = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || defaultChartParams.chartHeight;
149
+ const spans = ((_c = labelsRef.current) === null || _c === void 0 ? void 0 : _c.querySelectorAll("span")) || [];
145
150
  const yTicks = Array.from(document.querySelectorAll(".recharts-y-axis .recharts-layer tspan"));
146
151
  const maxYTickWidth = yTicks.length > 0 ? Math.max(...yTicks.map((t) => t.getBBox().width)) : 40;
147
- setYAxisWidth(maxYTickWidth);
152
+ // Only update if the value actually changed
153
+ // NOTE: This might cause recursive calls along with setting the state in here directly. Fix if necessary.
154
+ setYAxisWidth((prev) => {
155
+ // Add a small tolerance to prevent micro-adjustments
156
+ if (Math.abs(maxYTickWidth - prev) > 1) {
157
+ return maxYTickWidth;
158
+ }
159
+ return prev;
160
+ });
148
161
  const maxWidth = Array.from(spans).reduce((mx, s) => Math.max(mx, s.offsetWidth), 50);
149
162
  let angle = 0;
150
163
  let anchor = "middle";
@@ -153,14 +166,14 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
153
166
  let leftMargin = Math.ceil(maxWidth / 3);
154
167
  let rightMargin = Math.ceil(maxWidth / 3);
155
168
  let xAxisH = Math.ceil(fontSize * 1.2);
156
- let maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
169
+ let maxTicks = Math.max(1, Math.floor(chartWidth / minTickSpacing));
157
170
  let skip = Math.max(0, Math.ceil(validData.length / maxTicks) - 1);
158
171
  if (skip > 0) {
159
172
  angle = -60;
160
173
  anchor = "end";
161
174
  rad = (Math.abs(angle) * Math.PI) / 180;
162
175
  minTickSpacing = Math.ceil(maxWidth * Math.cos(rad)) + 2;
163
- maxTicks = Math.max(1, Math.floor(width / minTickSpacing));
176
+ maxTicks = Math.max(1, Math.floor(chartWidth / minTickSpacing));
164
177
  skip = Math.max(0, Math.ceil(validData.length / maxTicks) - 1);
165
178
  leftMargin = Math.ceil((maxWidth * Math.cos(rad)) / 1.8);
166
179
  rightMargin = Math.ceil((maxWidth * Math.cos(rad)) / 1.8);
@@ -179,22 +192,65 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
179
192
  bottomMargin = Math.max(xAxisH, maxXTickHeight);
180
193
  }
181
194
  setChartMargin({ left: leftMargin, right: rightMargin, top: 10, bottom: bottomMargin });
182
- const chartHeight = ((_c = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 300;
183
195
  const maxYTicks = Math.max(2, Math.floor(chartHeight / (fontSize * 3)));
184
196
  setYTickCount(maxYTicks);
185
197
  setXAxisHeight(Math.ceil(fontSize));
186
- const containerHeight = ((_d = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _d === void 0 ? void 0 : _d.offsetHeight) || 0;
187
- const containerWidth = ((_e = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _e === void 0 ? void 0 : _e.offsetWidth) || 0;
188
198
  const neededHeight = 10 + xAxisHeight + 10 + 32;
189
199
  const neededWidth = chartMargin.left + chartMargin.right + yAxisWidth + 32;
190
- setMiniMode(neededHeight > containerHeight || neededWidth > containerWidth);
200
+ setMiniMode(neededHeight > chartHeight || neededWidth > chartWidth);
191
201
  };
192
202
  calc();
193
203
  window.addEventListener("resize", calc);
194
204
  return () => window.removeEventListener("resize", calc);
195
- }, [data]);
205
+ // See note above: leaving out yAxisWidth may stop recursive calls but is hacky
206
+ // eslint-disable-next-line react-hooks/exhaustive-deps
207
+ }, [data, chartMargin.left, chartMargin.right, layout, validData.length, xAxisHeight]);
196
208
  const content = (0, react_2.useMemo)(() => {
197
- const chart = ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, BarChart_module_scss_1.default.wrapper), style: style, ref: wrapperRef, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, minWidth: 60, minHeight: 60, debounce: 100, width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { accessibilityLayer: true, data: validData, layout: layout, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { vertical: true, strokeDasharray: "3 3" }), layout === "vertical" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { type: "number", axisLine: false, hide: miniMode || hideX, tickFormatter: miniMode || hideTickX ? undefined : tickFormatterX, tick: miniMode || hideTickX ? false : { fill: "currentColor", fontSize } }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, dataKey: nameKey, type: "category", interval: "equidistantPreserveStart", tickLine: false, tickFormatter: miniMode || hideTickY ? undefined : tickFormatterY, tick: miniMode || hideTickY ? false : { fill: "currentColor", fontSize } })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: nameKey, type: "category", interval: interval, tickLine: false, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode || hideTickX ? false : { fill: "currentColor", fontSize }, tickFormatter: miniMode || hideTickX ? undefined : tickFormatterX, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { type: "number", axisLine: false, tick: miniMode || hideTickY ? false : { fill: "currentColor", fontSize }, hide: miniMode || hideY, tickCount: yTickCount, tickFormatter: miniMode || hideTickY ? undefined : tickFormatterY, width: miniMode || hideY || hideTickY ? 0 : 40 })] })), !miniMode && !hideTooltip && ((0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: safeTooltipRenderer })), validData.length > 0 && Object.keys(config).map((key, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { dataKey: key, fill: config[key].color, radius: stacked ? 0 : 8, stackId: stacked ? "stacked" : undefined, strokeWidth: 1 }, index))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
209
+ // NOTE: Had to place props separately since, for some reason, Recharts cannot handle
210
+ // if the axes are placed in a React.Fragment. Unsure why, because this worked before.
211
+ const xAxisProps = layout === "vertical"
212
+ ? {
213
+ type: "number",
214
+ axisLine: false,
215
+ hide: miniMode || hideX,
216
+ height: miniMode || hideX ? 0 : xAxisHeight,
217
+ tick: miniMode || hideTickX ? false : { fill: "currentColor", fontSize },
218
+ tickFormatter: miniMode || hideTickX ? undefined : tickFormatterX,
219
+ }
220
+ : {
221
+ type: "category",
222
+ dataKey: nameKey,
223
+ hide: miniMode || hideX,
224
+ height: miniMode || hideX ? 0 : xAxisHeight,
225
+ tick: miniMode || hideTickX ? false : { fill: "currentColor", fontSize },
226
+ tickFormatter: miniMode || hideTickX ? undefined : tickFormatterX,
227
+ interval: interval,
228
+ tickLine: false,
229
+ angle: tickAngle,
230
+ textAnchor: tickAnchor,
231
+ };
232
+ const yAxisProps = layout === "vertical"
233
+ ? {
234
+ type: "category",
235
+ dataKey: nameKey,
236
+ hide: miniMode || hideY,
237
+ interval: "equidistantPreserveStart",
238
+ tickLine: false,
239
+ tickFormatter: miniMode || hideTickY ? undefined : tickFormatterY,
240
+ tick: miniMode || hideTickY ? false : { fill: "currentColor", fontSize },
241
+ width: miniMode || hideY ? 0 : yAxisWidth,
242
+ }
243
+ : {
244
+ type: "number",
245
+ axisLine: false,
246
+ tick: miniMode || hideTickY ? false : { fill: "currentColor", fontSize },
247
+ hide: miniMode || hideY,
248
+ tickCount: yTickCount,
249
+ tickFormatter: miniMode || hideTickY ? undefined : tickFormatterY,
250
+ width: miniMode || hideY ? 0 : yAxisWidth,
251
+ };
252
+ const chart = ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, BarChart_module_scss_1.default.wrapper), style: Object.assign({ flexGrow: 1 }, style), ref: wrapperRef, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, minWidth: 60, minHeight: 60, debounce: 100, width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { accessibilityLayer: true, data: validData, layout: layout, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { vertical: true, strokeDasharray: "3 3" }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, Object.assign({}, xAxisProps)), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, Object.assign({}, yAxisProps)), !miniMode && !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: safeTooltipRenderer }), validData.length > 0 &&
253
+ Object.keys(config).map((key, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { dataKey: key, fill: config[key].color, radius: stacked ? 0 : 8, stackId: stacked ? "stacked" : undefined, strokeWidth: 1 }, index))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
198
254
  bottom: 0,
199
255
  left: 0,
200
256
  right: 0,
@@ -206,7 +262,6 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
206
262
  }, [
207
263
  chartMargin,
208
264
  config,
209
- data,
210
265
  hideTickX,
211
266
  hideTickY,
212
267
  hideX,
@@ -224,8 +279,11 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
224
279
  tickFormatterX,
225
280
  tickFormatterY,
226
281
  xAxisHeight,
282
+ yAxisWidth,
227
283
  yTickCount,
228
284
  safeTooltipRenderer,
285
+ hideTooltip,
286
+ validData,
229
287
  ]);
230
288
  return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { ref: labelsRef, style: { position: "absolute", visibility: "hidden", height: 0, overflow: "hidden" }, children: validData
231
289
  .map((d) => d[nameKey])
@@ -55,6 +55,9 @@ exports.defaultProps = {
55
55
  tickFormatterX: (value) => value,
56
56
  tickFormatterY: (value) => value,
57
57
  };
58
+ const defaultChartParams = {
59
+ chartWidth: 800,
60
+ };
58
61
  exports.LineChart = (0, react_1.forwardRef)(function LineChart({ data, dataKeys = [], nameKey, style, className, hideX = exports.defaultProps.hideX, hideY = exports.defaultProps.hideY, hideTickX = exports.defaultProps.hideTickX, hideTickY = exports.defaultProps.hideTickY, hideTooltip = exports.defaultProps.hideTooltip, tickFormatterX = exports.defaultProps.tickFormatterX, tickFormatterY = exports.defaultProps.tickFormatterY, children, showLegend = exports.defaultProps.showLegend, tooltipRenderer, }, forwardedRef) {
59
62
  const { getThemeVar } = (0, ThemeContext_1.useTheme)();
60
63
  const colorValues = (0, react_1.useMemo)(() => {
@@ -122,7 +125,7 @@ exports.LineChart = (0, react_1.forwardRef)(function LineChart({ data, dataKeys
122
125
  (0, react_1.useEffect)(() => {
123
126
  const calc = () => {
124
127
  var _a, _b, _c;
125
- const width = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 800;
128
+ const width = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || defaultChartParams.chartWidth;
126
129
  const spans = ((_b = labelsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll("span")) || [];
127
130
  const maxWidth = Array.from(spans).reduce((mx, s) => Math.max(mx, s.offsetWidth), 50);
128
131
  let angle = 0;
@@ -157,14 +160,14 @@ exports.LineChart = (0, react_1.forwardRef)(function LineChart({ data, dataKeys
157
160
  calc();
158
161
  window.addEventListener("resize", calc);
159
162
  return () => window.removeEventListener("resize", calc);
160
- }, [data, nameKey, xAxisHeight]);
163
+ }, [data, nameKey, xAxisHeight, safeData.length, fontSize]);
161
164
  // The stroke width of the lines
162
165
  const strokeWidth = getThemeVar("width-line-LineChart");
163
166
  return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { ref: labelsRef, style: { position: "absolute", visibility: "hidden", height: 0, overflow: "hidden" }, children: safeData.length > 0 && nameKey
164
167
  ? safeData
165
168
  .map((d) => d === null || d === void 0 ? void 0 : d[nameKey])
166
169
  .map((label, idx) => ((0, jsx_runtime_1.jsx)("span", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: label }, idx)))
167
- : null }), (0, jsx_runtime_1.jsx)("div", { ref: forwardedRef, className: (0, classnames_1.default)(className, LineChart_module_scss_1.default.wrapper), style: style, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, width: "100%", height: "100%", minWidth: 60, minHeight: 60, debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { interval: interval, tickLine: false, dataKey: nameKey, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : !hideTickX && { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatterX, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, tickLine: false, tickFormatter: miniMode ? undefined : tickFormatterY, tick: miniMode ? false : !hideTickY && { fill: "currentColor", fontSize } }), !miniMode && !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: safeTooltipRenderer }), dataKeys.map((dataKey, i) => ((0, jsx_runtime_1.jsx)(recharts_1.Line, { type: "monotone", dataKey: dataKey, name: dataKey, stroke: colorValues[i], strokeWidth: strokeWidth, dot: false }, dataKey))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
170
+ : null }), (0, jsx_runtime_1.jsx)("div", { ref: forwardedRef, className: (0, classnames_1.default)(className, LineChart_module_scss_1.default.wrapper), style: Object.assign({ flexGrow: 1 }, style), children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, width: "100%", height: "100%", minWidth: 60, minHeight: 30, debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { interval: interval, tickLine: false, dataKey: nameKey, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : !hideTickX && { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatterX, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, tickLine: false, tickFormatter: miniMode ? undefined : tickFormatterY, tick: miniMode ? false : !hideTickY && { fill: "currentColor", fontSize } }), !miniMode && !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: safeTooltipRenderer }), dataKeys.map((dataKey, i) => ((0, jsx_runtime_1.jsx)(recharts_1.Line, { type: "monotone", dataKey: dataKey, name: dataKey, stroke: colorValues[i], strokeWidth: strokeWidth, dot: false }, dataKey))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
168
171
  bottom: 0,
169
172
  left: 0,
170
173
  right: 0,
@@ -28,6 +28,12 @@ exports.defaultProps = {
28
28
  const numberRegex = /^[0-9]+$/;
29
29
  exports.ItemWithLabel = (0, react_1.forwardRef)(function ItemWithLabel(_a, ref) {
30
30
  var { id, labelPosition = "top", style = {}, className, label, labelBreak = exports.defaultProps.labelBreak, labelWidth, enabled = true, required = false, children, validationInProgress = false, shrinkToLabel = false, onFocus, onBlur, labelStyle, validationResult, isInputTemplateUsed = false } = _a, rest = __rest(_a, ["id", "labelPosition", "style", "className", "label", "labelBreak", "labelWidth", "enabled", "required", "children", "validationInProgress", "shrinkToLabel", "onFocus", "onBlur", "labelStyle", "validationResult", "isInputTemplateUsed"]);
31
+ // --- HACK: the "rest" may contain a "layoutContext" property with undefined value, and it
32
+ // --- would issue a warning in React.
33
+ if (rest.layoutContext === undefined) {
34
+ delete rest.layoutContext;
35
+ }
36
+ // --- END HACK
31
37
  const generatedId = (0, react_1.useId)();
32
38
  const inputId = id || generatedId;
33
39
  if (label === undefined && !validationResult) {
@@ -35,6 +35,11 @@ exports.LinkMd = (0, metadata_helpers_1.createMetadata)({
35
35
  label: (0, metadata_helpers_1.dLabel)(),
36
36
  icon: (0, metadata_helpers_1.d)(`This property allows you to add an optional icon (specify the icon's name) to the link.`),
37
37
  },
38
+ events: {
39
+ click: {
40
+ description: "This event is triggered when the link is clicked."
41
+ }
42
+ },
38
43
  themeVars: (0, themeVars_1.parseScssVar)(Link_module_scss_1.default.themeVars),
39
44
  themeVarDescriptions: {
40
45
  [`gap-icon-${COMP}`]: "This property defines the size of the gap between the icon and the label.",
@@ -69,9 +74,9 @@ exports.LinkMd = (0, metadata_helpers_1.createMetadata)({
69
74
  /**
70
75
  * This function define the renderer for the Limk component.
71
76
  */
72
- exports.localLinkComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.LinkMd, ({ node, extractValue, renderChild, className }) => {
77
+ exports.localLinkComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.LinkMd, ({ node, extractValue, renderChild, lookupEventHandler, className }) => {
73
78
  var _a, _b;
74
- return ((0, jsx_runtime_1.jsx)(LinkNative_1.LinkNative, { to: extractValue(node.props.to), icon: extractValue(node.props.icon), active: extractValue.asOptionalBoolean(node.props.active, false), target: extractValue((_a = node.props) === null || _a === void 0 ? void 0 : _a.target), className: className, disabled: !extractValue.asOptionalBoolean((_b = node.props.enabled) !== null && _b !== void 0 ? _b : true), children: node.props.label
79
+ return ((0, jsx_runtime_1.jsx)(LinkNative_1.LinkNative, { to: extractValue(node.props.to), icon: extractValue(node.props.icon), active: extractValue.asOptionalBoolean(node.props.active, false), target: extractValue((_a = node.props) === null || _a === void 0 ? void 0 : _a.target), className: className, disabled: !extractValue.asOptionalBoolean((_b = node.props.enabled) !== null && _b !== void 0 ? _b : true), onClick: lookupEventHandler("click"), children: node.props.label
75
80
  ? extractValue.asDisplayText(node.props.label)
76
81
  : renderChild(node.children) }));
77
82
  });
@@ -73,5 +73,5 @@ exports.modalViewComponentRenderer = (0, renderers_1.createComponentRenderer)(CO
73
73
  return ((0, jsx_runtime_1.jsx)(container_helpers_1.MemoizedItem, { node: node, renderChild: renderChild, layoutContext: { _insideModalFrame: true }, contextVars: { $param: openParams === null || openParams === void 0 ? void 0 : openParams[0], $params: openParams } }));
74
74
  } }));
75
75
  }
76
- return ((0, jsx_runtime_1.jsx)(ModalDialogNative_1.ModalDialog, { className: className, fullScreen: extractValue((_a = node.props) === null || _a === void 0 ? void 0 : _a.fullScreen), title: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.title), closeButtonVisible: extractValue.asOptionalBoolean(node.props.closeButtonVisible), children: renderChild(node.children, { type: "Stack" }) }));
76
+ return ((0, jsx_runtime_1.jsx)(ModalDialogNative_1.ModalDialog, { className: className, fullScreen: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.fullScreen), title: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.title), closeButtonVisible: extractValue.asOptionalBoolean(node.props.closeButtonVisible), children: renderChild(node.children, { type: "Stack" }) }));
77
77
  });
@@ -160,7 +160,7 @@ exports.Toggle = (0, react_3.forwardRef)(function Toggle(_a, forwardedRef) {
160
160
  indeterminate,
161
161
  autoFocus,
162
162
  ]);
163
- return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, Object.assign({}, rest, { ref: forwardedRef, id: inputId, label: label, style: Object.assign(Object.assign({}, style), { width: "fit-content" }), className: className, labelPosition: labelPosition, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, isInputTemplateUsed: !!inputRenderer, shrinkToLabel: true, labelStyle: { pointerEvents: readOnly ? "none" : undefined }, children: inputRenderer ? ((0, jsx_runtime_1.jsxs)("label", { className: Toggle_module_scss_1.default.label, children: [(0, jsx_runtime_1.jsx)("div", { className: Toggle_module_scss_1.default.inputContainer, children: input }), inputRenderer({
163
+ return ((0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, Object.assign({}, rest, { ref: forwardedRef, id: inputId, label: label, style: style, className: className, labelPosition: labelPosition, labelWidth: labelWidth, labelBreak: labelBreak, required: required, enabled: enabled, isInputTemplateUsed: !!inputRenderer, labelStyle: { pointerEvents: readOnly ? "none" : undefined }, children: inputRenderer ? ((0, jsx_runtime_1.jsxs)("label", { className: Toggle_module_scss_1.default.label, children: [(0, jsx_runtime_1.jsx)("div", { className: Toggle_module_scss_1.default.inputContainer, children: input }), inputRenderer({
164
164
  $checked: transformToLegitValue(value),
165
165
  $setChecked: setValue,
166
166
  })] })) : (input) })));
@@ -41,6 +41,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
42
  });
43
43
  };
44
+ var _a;
44
45
  Object.defineProperty(exports, "__esModule", { value: true });
45
46
  const lodash_es_1 = require("lodash-es");
46
47
  const ScriptingSourceTree_1 = require("./script-runner/ScriptingSourceTree");
@@ -102,7 +103,7 @@ function appendFormFieldValue({ key, value }, formData, prevKey = key) {
102
103
  formData.append(key, value.toString());
103
104
  }
104
105
  }
105
- const origin = typeof window !== "undefined" && (window.location.href || 'http://localhost');
106
+ const origin = (typeof window !== "undefined" && ((_a = window.location) === null || _a === void 0 ? void 0 : _a.href)) || 'http://localhost';
106
107
  const originUrl = new URL(origin);
107
108
  function isURLSameOrigin(url) {
108
109
  const urlObj = new URL(url, origin);