@traefik-labs/faency 13.3.0 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/components/Alert/Alert.cjs.map +1 -1
  2. package/dist/components/Alert/Alert.js.map +1 -1
  3. package/dist/components/AriaTable/AriaTable.cjs +15 -5
  4. package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
  5. package/dist/components/AriaTable/AriaTable.js +16 -6
  6. package/dist/components/AriaTable/AriaTable.js.map +1 -1
  7. package/dist/components/Badge/Badge.vanilla.css.cjs.map +1 -1
  8. package/dist/components/Badge/Badge.vanilla.css.js.map +1 -1
  9. package/dist/components/Card/Card.cjs.map +1 -1
  10. package/dist/components/Card/Card.js.map +1 -1
  11. package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
  12. package/dist/components/CodeBlock/CodeBlock.js +2 -2
  13. package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +3 -3
  14. package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -3
  15. package/dist/components/Combobox/Combobox.vanilla.cjs +170 -0
  16. package/dist/components/Combobox/Combobox.vanilla.cjs.map +1 -0
  17. package/dist/components/Combobox/Combobox.vanilla.css.cjs +33 -0
  18. package/dist/components/Combobox/Combobox.vanilla.css.cjs.map +1 -0
  19. package/dist/components/Combobox/Combobox.vanilla.css.js +29 -0
  20. package/dist/components/Combobox/Combobox.vanilla.css.js.map +1 -0
  21. package/dist/components/Combobox/Combobox.vanilla.js +167 -0
  22. package/dist/components/Combobox/Combobox.vanilla.js.map +1 -0
  23. package/dist/components/DateTimePicker/DateTimePicker.cjs +1 -1
  24. package/dist/components/DateTimePicker/DateTimePicker.js +1 -1
  25. package/dist/components/Dialog/Dialog.cjs +1 -1
  26. package/dist/components/Dialog/Dialog.js +1 -1
  27. package/dist/components/Field/Field.cjs +80 -33
  28. package/dist/components/Field/Field.cjs.map +1 -1
  29. package/dist/components/Field/Field.js +80 -33
  30. package/dist/components/Field/Field.js.map +1 -1
  31. package/dist/components/Field/Field.vanilla.cjs +62 -32
  32. package/dist/components/Field/Field.vanilla.cjs.map +1 -1
  33. package/dist/components/Field/Field.vanilla.css.cjs +6 -0
  34. package/dist/components/Field/Field.vanilla.css.cjs.map +1 -1
  35. package/dist/components/Field/Field.vanilla.css.js +4 -1
  36. package/dist/components/Field/Field.vanilla.css.js.map +1 -1
  37. package/dist/components/Field/Field.vanilla.js +63 -33
  38. package/dist/components/Field/Field.vanilla.js.map +1 -1
  39. package/dist/components/Field/FieldContext.cjs +48 -10
  40. package/dist/components/Field/FieldContext.cjs.map +1 -1
  41. package/dist/components/Field/FieldContext.js +48 -10
  42. package/dist/components/Field/FieldContext.js.map +1 -1
  43. package/dist/components/List/List.cjs +1 -1
  44. package/dist/components/List/List.js +1 -1
  45. package/dist/components/Meter/Meter.vanilla.cjs +74 -0
  46. package/dist/components/Meter/Meter.vanilla.cjs.map +1 -0
  47. package/dist/components/Meter/Meter.vanilla.css.cjs +26 -0
  48. package/dist/components/Meter/Meter.vanilla.css.cjs.map +1 -0
  49. package/dist/components/Meter/Meter.vanilla.css.js +21 -0
  50. package/dist/components/Meter/Meter.vanilla.css.js.map +1 -0
  51. package/dist/components/Meter/Meter.vanilla.js +72 -0
  52. package/dist/components/Meter/Meter.vanilla.js.map +1 -0
  53. package/dist/components/NavigationTree/NavigationTreeItem.cjs +2 -2
  54. package/dist/components/NavigationTree/NavigationTreeItem.js +2 -2
  55. package/dist/components/RowLink/RowLink.cjs +35 -12
  56. package/dist/components/RowLink/RowLink.cjs.map +1 -1
  57. package/dist/components/RowLink/RowLink.js +34 -12
  58. package/dist/components/RowLink/RowLink.js.map +1 -1
  59. package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs +57 -0
  60. package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs.map +1 -0
  61. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs +35 -0
  62. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs.map +1 -0
  63. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js +34 -0
  64. package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js.map +1 -0
  65. package/dist/components/SegmentedControl/SegmentedControl.vanilla.js +53 -0
  66. package/dist/components/SegmentedControl/SegmentedControl.vanilla.js.map +1 -0
  67. package/dist/components/Select/Select.cjs +1 -1
  68. package/dist/components/Select/Select.js +1 -1
  69. package/dist/components/Spinner/Spinner.vanilla.cjs +50 -0
  70. package/dist/components/Spinner/Spinner.vanilla.cjs.map +1 -0
  71. package/dist/components/Spinner/Spinner.vanilla.css.cjs +21 -0
  72. package/dist/components/Spinner/Spinner.vanilla.css.cjs.map +1 -0
  73. package/dist/components/Spinner/Spinner.vanilla.css.js +19 -0
  74. package/dist/components/Spinner/Spinner.vanilla.css.js.map +1 -0
  75. package/dist/components/Spinner/Spinner.vanilla.js +48 -0
  76. package/dist/components/Spinner/Spinner.vanilla.js.map +1 -0
  77. package/dist/components/SplitLayout/SplitLayout.vanilla.cjs +214 -0
  78. package/dist/components/SplitLayout/SplitLayout.vanilla.cjs.map +1 -0
  79. package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs +14 -0
  80. package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs.map +1 -0
  81. package/dist/components/SplitLayout/SplitLayout.vanilla.css.js +10 -0
  82. package/dist/components/SplitLayout/SplitLayout.vanilla.css.js.map +1 -0
  83. package/dist/components/SplitLayout/SplitLayout.vanilla.js +210 -0
  84. package/dist/components/SplitLayout/SplitLayout.vanilla.js.map +1 -0
  85. package/dist/components/Table/Table.cjs +13 -4
  86. package/dist/components/Table/Table.cjs.map +1 -1
  87. package/dist/components/Table/Table.js +13 -4
  88. package/dist/components/Table/Table.js.map +1 -1
  89. package/dist/components/TextField/TextField.cjs +1 -1
  90. package/dist/components/TextField/TextField.js +1 -1
  91. package/dist/components/TextField/TextField.vanilla.cjs +1 -1
  92. package/dist/components/TextField/TextField.vanilla.js +1 -1
  93. package/dist/components/Textarea/Textarea.cjs +2 -2
  94. package/dist/components/Textarea/Textarea.js +2 -2
  95. package/dist/components/Textarea/Textarea.vanilla.cjs +2 -2
  96. package/dist/components/Textarea/Textarea.vanilla.js +2 -2
  97. package/dist/components/Toast/Toast.vanilla.cjs +96 -0
  98. package/dist/components/Toast/Toast.vanilla.cjs.map +1 -0
  99. package/dist/components/Toast/Toast.vanilla.css.cjs +44 -0
  100. package/dist/components/Toast/Toast.vanilla.css.cjs.map +1 -0
  101. package/dist/components/Toast/Toast.vanilla.css.js +37 -0
  102. package/dist/components/Toast/Toast.vanilla.css.js.map +1 -0
  103. package/dist/components/Toast/Toast.vanilla.js +90 -0
  104. package/dist/components/Toast/Toast.vanilla.js.map +1 -0
  105. package/dist/components/Toast/ToastProvider.vanilla.cjs +98 -0
  106. package/dist/components/Toast/ToastProvider.vanilla.cjs.map +1 -0
  107. package/dist/components/Toast/ToastProvider.vanilla.js +94 -0
  108. package/dist/components/Toast/ToastProvider.vanilla.js.map +1 -0
  109. package/dist/faency.css +3315 -2335
  110. package/dist/index.cjs +55 -32
  111. package/dist/index.d.ts +809 -14
  112. package/dist/index.js +41 -33
  113. package/dist/styles/cssProps.cjs +3 -10
  114. package/dist/styles/cssProps.cjs.map +1 -1
  115. package/dist/styles/cssProps.js +3 -10
  116. package/dist/styles/cssProps.js.map +1 -1
  117. package/dist/styles/resolveColor.cjs +18 -0
  118. package/dist/styles/resolveColor.cjs.map +1 -0
  119. package/dist/styles/resolveColor.js +18 -0
  120. package/dist/styles/resolveColor.js.map +1 -0
  121. package/dist/styles/themes.css.cjs.map +1 -1
  122. package/dist/styles/themes.css.js.map +1 -1
  123. package/dist/styles/tokens.css.cjs +484 -0
  124. package/dist/styles/tokens.css.cjs.map +1 -0
  125. package/dist/styles/tokens.css.js +484 -0
  126. package/dist/styles/tokens.css.js.map +1 -0
  127. package/dist/utils/warnOnce.cjs +13 -0
  128. package/dist/utils/warnOnce.cjs.map +1 -0
  129. package/dist/utils/warnOnce.js +13 -0
  130. package/dist/utils/warnOnce.js.map +1 -0
  131. package/package.json +12 -25
@@ -0,0 +1,74 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_cssProps = require("../../styles/cssProps.cjs");
3
+ const require_resolveColor = require("../../styles/resolveColor.cjs");
4
+ const require_themeContext = require("../../styles/themeContext.cjs");
5
+ const require_Meter_vanilla_css = require("./Meter.vanilla.css.cjs");
6
+ let react = require("react");
7
+ react = require_runtime.__toESM(react, 1);
8
+ let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ // components/Meter/Meter.vanilla.tsx
11
+ var MeterVanilla = (0, react.forwardRef)(({ value, color, segments, max, label, valueLabel, size, className, css, style, "aria-label": ariaLabel, ...props }, ref) => {
12
+ const { colors } = require_themeContext.useVanillaExtractTheme();
13
+ const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
14
+ const items = segments ?? [{
15
+ value: value ?? 0,
16
+ color
17
+ }];
18
+ const values = items.map((s) => Math.max(0, s.value));
19
+ const total = max ?? (segments ? values.reduce((sum, v) => sum + v, 0) : 100);
20
+ let remaining = total;
21
+ const widths = values.map((v) => {
22
+ const shown = Math.min(v, Math.max(0, remaining));
23
+ remaining -= shown;
24
+ return total > 0 ? shown / total * 100 : 0;
25
+ });
26
+ const name = ariaLabel ?? label;
27
+ const ariaProps = items.length === 1 ? {
28
+ role: "meter",
29
+ "aria-valuenow": Math.min(values[0], total),
30
+ "aria-valuemin": 0,
31
+ "aria-valuemax": total,
32
+ "aria-valuetext": valueLabel ?? items[0].label,
33
+ "aria-label": name ?? items[0].label
34
+ } : {
35
+ role: "img",
36
+ "aria-label": ariaLabel ?? [label, items.map((s) => s.label ?? String(s.value)).join(", ")].filter(Boolean).join(": ")
37
+ };
38
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
39
+ ref,
40
+ className: `${require_Meter_vanilla_css.root} ${className || ""}`.trim(),
41
+ style: {
42
+ ...cssStyles,
43
+ ...style,
44
+ ...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
45
+ },
46
+ ...props,
47
+ children: [(label || valueLabel) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48
+ className: "sfokyy1",
49
+ "aria-hidden": true,
50
+ children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
51
+ className: "sfokyy2",
52
+ children: label
53
+ }), valueLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
54
+ className: "sfokyy3",
55
+ children: valueLabel
56
+ })]
57
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
58
+ className: require_Meter_vanilla_css.trackRecipe({ size }),
59
+ ...ariaProps,
60
+ children: items.map((s, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
61
+ className: require_Meter_vanilla_css.segment,
62
+ title: s.label,
63
+ style: {
64
+ width: `${widths[i]}%`,
65
+ backgroundColor: s.color && require_resolveColor.resolveColor(s.color, colors)
66
+ }
67
+ }, i))
68
+ })]
69
+ });
70
+ });
71
+ MeterVanilla.displayName = "MeterVanilla";
72
+ exports.MeterVanilla = MeterVanilla;
73
+
74
+ //# sourceMappingURL=Meter.vanilla.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","processCSSProp","root","assignInlineVars","trackRecipe","segment","resolveColor"],"sources":["../../../components/Meter/Meter.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { resolveColor } from '../../styles/resolveColor';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport {\n caption,\n captionLabel,\n captionValue,\n root,\n segment,\n trackRecipe,\n} from './Meter.vanilla.css';\n\nexport type MeterSegmentVanilla = {\n value: number;\n /** A color token such as `$chartStatusGood`, or any CSS color. Defaults to the chart series colors. */\n color?: string;\n /** Shown as a tooltip and read with the meter, e.g. \"404: 30\". */\n label?: string;\n};\n\ntype MeterValueProps = Omit<MeterSegmentVanilla, 'label'> & { segments?: never };\ntype MeterSegmentsProps = { segments: MeterSegmentVanilla[]; value?: never; color?: never };\n\nexport type MeterVanillaProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'color'> &\n CSSProps &\n (MeterValueProps | MeterSegmentsProps) & {\n /** Defaults to 100 with `value`, and to the sum of the values with `segments`. */\n max?: number;\n /** Caption above the bar, on the left. Also the meter's accessible name. */\n label?: string;\n /** Caption above the bar, on the right, e.g. \"42 GB / 100 GB\". */\n valueLabel?: string;\n size?: 'small' | 'medium' | 'large';\n };\n\n// TODO: replace the native `title` on segments with TooltipVanilla once it exists.\nexport const MeterVanilla = forwardRef<HTMLDivElement, MeterVanillaProps>(\n (\n {\n value,\n color,\n segments,\n max,\n label,\n valueLabel,\n size,\n className,\n css,\n style,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const items: MeterSegmentVanilla[] = segments ?? [{ value: value ?? 0, color }];\n const values = items.map((s) => Math.max(0, s.value));\n const total = max ?? (segments ? values.reduce((sum, v) => sum + v, 0) : 100);\n\n let remaining = total;\n const widths = values.map((v) => {\n const shown = Math.min(v, Math.max(0, remaining));\n remaining -= shown;\n return total > 0 ? (shown / total) * 100 : 0;\n });\n\n const name = ariaLabel ?? label;\n const ariaProps =\n items.length === 1\n ? {\n role: 'meter',\n 'aria-valuenow': Math.min(values[0], total),\n 'aria-valuemin': 0,\n 'aria-valuemax': total,\n 'aria-valuetext': valueLabel ?? items[0].label,\n 'aria-label': name ?? items[0].label,\n }\n : {\n role: 'img',\n 'aria-label':\n ariaLabel ??\n [label, items.map((s) => s.label ?? String(s.value)).join(', ')]\n .filter(Boolean)\n .join(': '),\n };\n\n return (\n <div\n ref={ref}\n className={`${root} ${className || ''}`.trim()}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n {...props}\n >\n {(label || valueLabel) && (\n // Hidden from assistive tech: the meter's name and value text already carry it.\n <div className={caption} aria-hidden>\n {label && <span className={captionLabel}>{label}</span>}\n {valueLabel && <span className={captionValue}>{valueLabel}</span>}\n </div>\n )}\n <div className={trackRecipe({ size })} {...ariaProps}>\n {items.map((s, i) => (\n <div\n key={i}\n className={segment}\n title={s.label}\n style={{\n width: `${widths[i]}%`,\n backgroundColor: s.color && resolveColor(s.color, colors),\n }}\n />\n ))}\n </div>\n </div>\n );\n },\n);\n\nMeterVanilla.displayName = 'MeterVanilla';\n"],"mappings":";;;;;;;;;;AAuCA,IAAa,gBAAA,GAAeA,MAAAA,WAAAA,EAExB,EACE,OACA,OACA,UACA,KACA,OACA,YACA,MACA,WACA,KACA,OACA,cAAc,WACd,GAAG,SAEL,QACG;CACH,MAAM,EAAE,WAAWC,qBAAAA,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAE7D,MAAM,QAA+B,YAAY,CAAC;EAAE,OAAO,SAAS;EAAG;CAAM,CAAC;CAC9E,MAAM,SAAS,MAAM,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,KAAK,CAAC;CACpD,MAAM,QAAQ,QAAQ,WAAW,OAAO,QAAQ,KAAK,MAAM,MAAM,GAAG,CAAC,IAAI;CAEzE,IAAI,YAAY;CAChB,MAAM,SAAS,OAAO,KAAK,MAAM;EAC/B,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC;EAChD,aAAa;EACb,OAAO,QAAQ,IAAK,QAAQ,QAAS,MAAM;CAC7C,CAAC;CAED,MAAM,OAAO,aAAa;CAC1B,MAAM,YACJ,MAAM,WAAW,IACb;EACE,MAAM;EACN,iBAAiB,KAAK,IAAI,OAAO,IAAI,K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ty css */
2
+ let _vanilla_extract_recipes_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
3
+ // components/Meter/Meter.vanilla.css.ts
4
+ var root = "sfokyy0";
5
+ var caption = "sfokyy1";
6
+ var captionLabel = "sfokyy2";
7
+ var captionValue = "sfokyy3";
8
+ var trackRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
9
+ defaultClassName: "sfokyy4",
10
+ variantClassNames: { size: {
11
+ small: "sfokyy5",
12
+ medium: "sfokyy6",
13
+ large: "sfokyy7"
14
+ } },
15
+ defaultVariants: { size: "medium" },
16
+ compoundVariants: []
17
+ });
18
+ var segment = "sfokyy8";
19
+ exports.caption = caption;
20
+ exports.captionLabel = captionLabel;
21
+ exports.captionValue = captionValue;
22
+ exports.root = root;
23
+ exports.segment = segment;
24
+ exports.trackRecipe = trackRecipe;
25
+
26
+ //# sourceMappingURL=Meter.vanilla.css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.vanilla.css.cjs","names":["_7a468"],"sources":["../../../components/Meter/Meter.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { tokens } from '../../styles/tokens.css';\n\nexport const root = style({\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.space['1'],\n minWidth: 0,\n});\n\nexport const caption = style({\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'baseline',\n gap: tokens.space['2'],\n fontFamily: tokens.fonts.rubik,\n fontSize: tokens.fontSizes['2'],\n lineHeight: '1.4',\n});\n\nexport const captionLabel = style({\n color: tokens.colors.textDefault,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n});\n\nexport const captionValue = style({\n marginLeft: 'auto',\n color: tokens.colors.textSubtle,\n fontVariantNumeric: 'tabular-nums',\n whiteSpace: 'nowrap',\n});\n\nexport const trackRecipe = recipe({\n base: {\n display: 'flex',\n width: '100%',\n borderRadius: tokens.radii['1'],\n backgroundColor: tokens.colors.meterTrackBg,\n overflow: 'hidden',\n },\n variants: {\n size: {\n small: { height: tokens.sizes['1'] },\n medium: { height: tokens.sizes['2'] },\n large: { height: '12px' },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport const segment = style({\n height: '100%',\n flexShrink: 0,\n selectors: {\n '&:nth-child(3n+1)': { backgroundColor: tokens.colors.chartSeries1 },\n '&:nth-child(3n+2)': { backgroundColor: tokens.colors.chartSeries2 },\n '&:nth-child(3n)': { backgroundColor: tokens.colors.chartSeries3 },\n '&:last-child': {\n borderTopRightRadius: tokens.radii['1'],\n borderBottomRightRadius: tokens.radii['1'],\n },\n },\n});\n"],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /* empty css */
2
+ import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
3
+ // components/Meter/Meter.vanilla.css.ts
4
+ var root = "sfokyy0";
5
+ var caption = "sfokyy1";
6
+ var captionLabel = "sfokyy2";
7
+ var captionValue = "sfokyy3";
8
+ var trackRecipe = createRuntimeFn({
9
+ defaultClassName: "sfokyy4",
10
+ variantClassNames: { size: {
11
+ small: "sfokyy5",
12
+ medium: "sfokyy6",
13
+ large: "sfokyy7"
14
+ } },
15
+ defaultVariants: { size: "medium" },
16
+ compoundVariants: []
17
+ });
18
+ var segment = "sfokyy8";
19
+ export { caption, captionLabel, captionValue, root, segment, trackRecipe };
20
+
21
+ //# sourceMappingURL=Meter.vanilla.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.vanilla.css.js","names":["_7a468"],"sources":["../../../components/Meter/Meter.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { tokens } from '../../styles/tokens.css';\n\nexport const root = style({\n display: 'flex',\n flexDirection: 'column',\n gap: tokens.space['1'],\n minWidth: 0,\n});\n\nexport const caption = style({\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'baseline',\n gap: tokens.space['2'],\n fontFamily: tokens.fonts.rubik,\n fontSize: tokens.fontSizes['2'],\n lineHeight: '1.4',\n});\n\nexport const captionLabel = style({\n color: tokens.colors.textDefault,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n});\n\nexport const captionValue = style({\n marginLeft: 'auto',\n color: tokens.colors.textSubtle,\n fontVariantNumeric: 'tabular-nums',\n whiteSpace: 'nowrap',\n});\n\nexport const trackRecipe = recipe({\n base: {\n display: 'flex',\n width: '100%',\n borderRadius: tokens.radii['1'],\n backgroundColor: tokens.colors.meterTrackBg,\n overflow: 'hidden',\n },\n variants: {\n size: {\n small: { height: tokens.sizes['1'] },\n medium: { height: tokens.sizes['2'] },\n large: { height: '12px' },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport const segment = style({\n height: '100%',\n flexShrink: 0,\n selectors: {\n '&:nth-child(3n+1)': { backgroundColor: tokens.colors.chartSeries1 },\n '&:nth-child(3n+2)': { backgroundColor: tokens.colors.chartSeries2 },\n '&:nth-child(3n)': { backgroundColor: tokens.colors.chartSeries3 },\n '&:last-child': {\n borderTopRightRadius: tokens.radii['1'],\n borderBottomRightRadius: tokens.radii['1'],\n },\n },\n});\n"],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import { processCSSProp } from "../../styles/cssProps.js";
2
+ import { resolveColor } from "../../styles/resolveColor.js";
3
+ import { useVanillaExtractTheme } from "../../styles/themeContext.js";
4
+ import { root, segment, trackRecipe } from "./Meter.vanilla.css.js";
5
+ import { forwardRef } from "react";
6
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ // components/Meter/Meter.vanilla.tsx
9
+ var MeterVanilla = forwardRef(({ value, color, segments, max, label, valueLabel, size, className, css, style, "aria-label": ariaLabel, ...props }, ref) => {
10
+ const { colors } = useVanillaExtractTheme();
11
+ const { style: cssStyles, vars } = processCSSProp(css, colors);
12
+ const items = segments ?? [{
13
+ value: value ?? 0,
14
+ color
15
+ }];
16
+ const values = items.map((s) => Math.max(0, s.value));
17
+ const total = max ?? (segments ? values.reduce((sum, v) => sum + v, 0) : 100);
18
+ let remaining = total;
19
+ const widths = values.map((v) => {
20
+ const shown = Math.min(v, Math.max(0, remaining));
21
+ remaining -= shown;
22
+ return total > 0 ? shown / total * 100 : 0;
23
+ });
24
+ const name = ariaLabel ?? label;
25
+ const ariaProps = items.length === 1 ? {
26
+ role: "meter",
27
+ "aria-valuenow": Math.min(values[0], total),
28
+ "aria-valuemin": 0,
29
+ "aria-valuemax": total,
30
+ "aria-valuetext": valueLabel ?? items[0].label,
31
+ "aria-label": name ?? items[0].label
32
+ } : {
33
+ role: "img",
34
+ "aria-label": ariaLabel ?? [label, items.map((s) => s.label ?? String(s.value)).join(", ")].filter(Boolean).join(": ")
35
+ };
36
+ return /* @__PURE__ */ jsxs("div", {
37
+ ref,
38
+ className: `${root} ${className || ""}`.trim(),
39
+ style: {
40
+ ...cssStyles,
41
+ ...style,
42
+ ...assignInlineVars(vars)
43
+ },
44
+ ...props,
45
+ children: [(label || valueLabel) && /* @__PURE__ */ jsxs("div", {
46
+ className: "sfokyy1",
47
+ "aria-hidden": true,
48
+ children: [label && /* @__PURE__ */ jsx("span", {
49
+ className: "sfokyy2",
50
+ children: label
51
+ }), valueLabel && /* @__PURE__ */ jsx("span", {
52
+ className: "sfokyy3",
53
+ children: valueLabel
54
+ })]
55
+ }), /* @__PURE__ */ jsx("div", {
56
+ className: trackRecipe({ size }),
57
+ ...ariaProps,
58
+ children: items.map((s, i) => /* @__PURE__ */ jsx("div", {
59
+ className: segment,
60
+ title: s.label,
61
+ style: {
62
+ width: `${widths[i]}%`,
63
+ backgroundColor: s.color && resolveColor(s.color, colors)
64
+ }
65
+ }, i))
66
+ })]
67
+ });
68
+ });
69
+ MeterVanilla.displayName = "MeterVanilla";
70
+ export { MeterVanilla };
71
+
72
+ //# sourceMappingURL=Meter.vanilla.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.vanilla.js","names":[],"sources":["../../../components/Meter/Meter.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { resolveColor } from '../../styles/resolveColor';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport {\n caption,\n captionLabel,\n captionValue,\n root,\n segment,\n trackRecipe,\n} from './Meter.vanilla.css';\n\nexport type MeterSegmentVanilla = {\n value: number;\n /** A color token such as `$chartStatusGood`, or any CSS color. Defaults to the chart series colors. */\n color?: string;\n /** Shown as a tooltip and read with the meter, e.g. \"404: 30\". */\n label?: string;\n};\n\ntype MeterValueProps = Omit<MeterSegmentVanilla, 'label'> & { segments?: never };\ntype MeterSegmentsProps = { segments: MeterSegmentVanilla[]; value?: never; color?: never };\n\nexport type MeterVanillaProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'color'> &\n CSSProps &\n (MeterValueProps | MeterSegmentsProps) & {\n /** Defaults to 100 with `value`, and to the sum of the values with `segments`. */\n max?: number;\n /** Caption above the bar, on the left. Also the meter's accessible name. */\n label?: string;\n /** Caption above the bar, on the right, e.g. \"42 GB / 100 GB\". */\n valueLabel?: string;\n size?: 'small' | 'medium' | 'large';\n };\n\n// TODO: replace the native `title` on segments with TooltipVanilla once it exists.\nexport const MeterVanilla = forwardRef<HTMLDivElement, MeterVanillaProps>(\n (\n {\n value,\n color,\n segments,\n max,\n label,\n valueLabel,\n size,\n className,\n css,\n style,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const items: MeterSegmentVanilla[] = segments ?? [{ value: value ?? 0, color }];\n const values = items.map((s) => Math.max(0, s.value));\n const total = max ?? (segments ? values.reduce((sum, v) => sum + v, 0) : 100);\n\n let remaining = total;\n const widths = values.map((v) => {\n const shown = Math.min(v, Math.max(0, remaining));\n remaining -= shown;\n return total > 0 ? (shown / total) * 100 : 0;\n });\n\n const name = ariaLabel ?? label;\n const ariaProps =\n items.length === 1\n ? {\n role: 'meter',\n 'aria-valuenow': Math.min(values[0], total),\n 'aria-valuemin': 0,\n 'aria-valuemax': total,\n 'aria-valuetext': valueLabel ?? items[0].label,\n 'aria-label': name ?? items[0].label,\n }\n : {\n role: 'img',\n 'aria-label':\n ariaLabel ??\n [label, items.map((s) => s.label ?? String(s.value)).join(', ')]\n .filter(Boolean)\n .join(': '),\n };\n\n return (\n <div\n ref={ref}\n className={`${root} ${className || ''}`.trim()}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n {...props}\n >\n {(label || valueLabel) && (\n // Hidden from assistive tech: the meter's name and value text already carry it.\n <div className={caption} aria-hidden>\n {label && <span className={captionLabel}>{label}</span>}\n {valueLabel && <span className={captionValue}>{valueLabel}</span>}\n </div>\n )}\n <div className={trackRecipe({ size })} {...ariaProps}>\n {items.map((s, i) => (\n <div\n key={i}\n className={segment}\n title={s.label}\n style={{\n width: `${widths[i]}%`,\n backgroundColor: s.color && resolveColor(s.color, colors),\n }}\n />\n ))}\n </div>\n </div>\n );\n },\n);\n\nMeterVanilla.displayName = 'MeterVanilla';\n"],"mappings":";;;;;;;;AAuCA,IAAa,eAAe,YAExB,EACE,OACA,OACA,UACA,KACA,OACA,YACA,MACA,WACA,KACA,OACA,cAAc,WACd,GAAG,SAEL,QACG;CACH,MAAM,EAAE,WAAW,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAE7D,MAAM,QAA+B,YAAY,CAAC;EAAE,OAAO,SAAS;EAAG;CAAM,CAAC;CAC9E,MAAM,SAAS,MAAM,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,KAAK,CAAC;CACpD,MAAM,QAAQ,QAAQ,WAAW,OAAO,QAAQ,KAAK,MAAM,MAAM,GAAG,CA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;GACD,GAPM,CAON,CACF;EACE,CAAA,CACF;;AAET,CACF;AAEA,aAAa,cAAc"}
@@ -1,10 +1,10 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_Box = require("../Box/Box.cjs");
3
3
  const require_Flex = require("../Flex/Flex.cjs");
4
- const require_Text = require("../Text/Text.cjs");
5
4
  const require_Navigation = require("../Navigation/Navigation.cjs");
6
- const require_NavigationTreeContext = require("./NavigationTreeContext.cjs");
5
+ const require_Text = require("../Text/Text.cjs");
7
6
  const require_NavigationTreeContainer = require("./NavigationTreeContainer.cjs");
7
+ const require_NavigationTreeContext = require("./NavigationTreeContext.cjs");
8
8
  let react = require("react");
9
9
  react = require_runtime.__toESM(react, 1);
10
10
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -1,9 +1,9 @@
1
1
  import { Box } from "../Box/Box.js";
2
2
  import { Flex } from "../Flex/Flex.js";
3
- import { Text } from "../Text/Text.js";
4
3
  import { NavigationItem } from "../Navigation/Navigation.js";
5
- import { useNavigationTree } from "./NavigationTreeContext.js";
4
+ import { Text } from "../Text/Text.js";
6
5
  import { NavigationTreeContainer } from "./NavigationTreeContainer.js";
6
+ import { useNavigationTree } from "./NavigationTreeContext.js";
7
7
  import React, { useMemo, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  // components/NavigationTree/NavigationTreeItem.tsx
@@ -1,5 +1,6 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_stitches_config = require("../../stitches.config.cjs");
3
+ const require_warnOnce = require("../../utils/warnOnce.cjs");
3
4
  let react = require("react");
4
5
  react = require_runtime.__toESM(react, 1);
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -24,6 +25,13 @@ var rowLinkStyles = {
24
25
  outlineStyle: "solid",
25
26
  outlineColor: "$focusOutline",
26
27
  outlineOffset: "-2px"
28
+ },
29
+ [`&[${ROW_LINK_ATTRIBUTE}="click"]::after`]: { content: "none" },
30
+ [`&[${ROW_LINK_ATTRIBUTE}="click"]:focus-visible`]: {
31
+ outlineWidth: "2px",
32
+ outlineStyle: "solid",
33
+ outlineColor: "$focusOutline",
34
+ outlineOffset: "2px"
27
35
  }
28
36
  };
29
37
  var StyledRowLink = require_stitches_config.styled("a", rowLinkStyles);
@@ -42,10 +50,10 @@ var rowLinkRowStyles = {
42
50
  * A link that covers its whole table row, so that a click on the row opens it.
43
51
  * Other links and buttons in the row stay above it.
44
52
  */
45
- var RowLink = react.default.forwardRef(({ asChild, ...props }, forwardedRef) => {
53
+ var RowLink = react.default.forwardRef(({ asChild, overlay = true, ...props }, forwardedRef) => {
46
54
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? StyledRowLinkSlot : StyledRowLink, {
47
55
  ref: forwardedRef,
48
- [ROW_LINK_ATTRIBUTE]: "",
56
+ [ROW_LINK_ATTRIBUTE]: overlay ? "" : "click",
49
57
  ...props
50
58
  });
51
59
  });
@@ -57,16 +65,8 @@ var isCellType = (type, cellType) => {
57
65
  const cellClassName = cellType.className;
58
66
  return internal?.type === cellType || !!cellClassName && className === cellClassName;
59
67
  };
60
- var warnedMessages = /* @__PURE__ */ new Set();
61
- var warnOnce = (message) => {
62
- if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
63
- if (!warnedMessages.has(message)) {
64
- warnedMessages.add(message);
65
- console.warn(message);
66
- }
67
- };
68
68
  /** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */
69
- var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0, linkProps }, cellType) => {
69
+ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0, linkProps, linkOverlay }, cellType) => {
70
70
  if (href === void 0) return children;
71
71
  let cellIndex = -1;
72
72
  let linked = false;
@@ -77,6 +77,7 @@ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0,
77
77
  linked = true;
78
78
  return (0, react.cloneElement)(child, void 0, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowLink, {
79
79
  asChild: true,
80
+ overlay: linkOverlay,
80
81
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LinkComponent, {
81
82
  ...linkProps,
82
83
  href,
@@ -84,10 +85,32 @@ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0,
84
85
  })
85
86
  }));
86
87
  });
87
- if (!linked) warnOnce(`Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`);
88
+ if (!linked) require_warnOnce.warnOnce(`Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`);
88
89
  return mapped;
89
90
  };
91
+ var NEW_TAB_PROTOCOLS = ["http:", "https:"];
92
+ var ROW_CLICK_CONTROLS = "a, button, input, select, textarea, label, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"switch\"], [role=\"menuitem\"], [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]";
93
+ /** Opens the `RowLink` without overlay of the row on a click or a middle click outside its controls. */
94
+ var openRowLink = (event) => {
95
+ const isAuxClick = event.type === "auxclick";
96
+ if (event.defaultPrevented || isAuxClick && event.button !== 1) return;
97
+ const row = event.currentTarget;
98
+ const target = event.target;
99
+ if (!(target instanceof Element) || !row.contains(target)) return;
100
+ const control = target.closest(ROW_CLICK_CONTROLS);
101
+ if (control && row.contains(control)) return;
102
+ const link = row.querySelector(`[${ROW_LINK_ATTRIBUTE}="click"]`);
103
+ if (!link) return;
104
+ const selection = window.getSelection();
105
+ if (selection && !selection.isCollapsed && row.contains(selection.anchorNode)) return;
106
+ if ((isAuxClick || event.metaKey || event.ctrlKey || event.shiftKey) && NEW_TAB_PROTOCOLS.includes(new URL(link.href, window.location.href).protocol)) {
107
+ window.open(link.href, "_blank", "noopener,noreferrer");
108
+ return;
109
+ }
110
+ link.click();
111
+ };
90
112
  exports.RowLink = RowLink;
113
+ exports.openRowLink = openRowLink;
91
114
  exports.rowLinkRowStyles = rowLinkRowStyles;
92
115
  exports.rowLinkTableStyles = rowLinkTableStyles;
93
116
  exports.withRowLink = withRowLink;
@@ -1 +1 @@
1
- {"version":3,"file":"RowLink.cjs","names":["styled","Slot","React","Children","isValidElement","cloneElement"],"sources":["../../../components/RowLink/RowLink.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { Children, cloneElement, ElementType, isValidElement, ReactNode } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\n\nconst ROW_LINK_ATTRIBUTE = 'data-row-link';\nconst STITCHES_INTERNAL = Symbol.for('sxs.internal');\n\nconst ROW_LINK_Z_INDEX = 1;\nexport const ROW_LINK_CONTROL_Z_INDEX = 2;\nconst ROW_LINK_CONTROLS = `:where(a, button, input, select, textarea, [tabindex]):where(:not([${ROW_LINK_ATTRIBUTE}]))`;\n\nconst rowLinkStyles = {\n color: 'inherit',\n textDecoration: 'none',\n outline: 'none',\n\n '&::after': {\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n zIndex: ROW_LINK_Z_INDEX,\n },\n\n '&:focus-visible::after': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '-2px',\n },\n};\n\nconst StyledRowLink = styled('a', rowLinkStyles);\nconst StyledRowLinkSlot = styled(Slot, rowLinkStyles);\n\n/** Styles for a table that can hold a `RowLink`. */\nexport const rowLinkTableStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n isolation: 'isolate',\n },\n};\n\n/** Styles for a table row that can hold a `RowLink`. */\nexport const rowLinkRowStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n position: 'relative',\n },\n // Not at zero specificity, so that it wins over the `all: unset` of controls such as Checkbox.\n [`&:has([${ROW_LINK_ATTRIBUTE}]) ${ROW_LINK_CONTROLS}`]: {\n position: 'relative',\n zIndex: ROW_LINK_CONTROL_Z_INDEX,\n },\n};\n\nexport type RowLinkProps = React.ComponentProps<typeof StyledRowLink> & {\n asChild?: boolean;\n css?: CSS;\n};\n\n/**\n * A link that covers its whole table row, so that a click on the row opens it.\n * Other links and buttons in the row stay above it.\n */\nexport const RowLink = React.forwardRef<HTMLAnchorElement, RowLinkProps>(\n ({ asChild, ...props }, forwardedRef) => {\n const Component = asChild ? StyledRowLinkSlot : StyledRowLink;\n\n return <Component ref={forwardedRef} {...{ [ROW_LINK_ATTRIBUTE]: '' }} {...props} />;\n },\n);\n\nRowLink.displayName = 'RowLink';\n\nexport type RowLinkShortcutProps = {\n href?: string;\n /**\n * The link component, for example a router link. It must pass its props and ref to its `<a>`,\n * and it must be defined outside render, or the link mounts again on each render.\n */\n linkAs?: ElementType;\n /** Other props for the link component, for example `{ returnTo }`. */\n linkProps?: Record<string, unknown>;\n /** The index of the cell that holds the link, among the direct children of the row. */\n linkCell?: number;\n};\n\ntype StitchesType = { className?: string; [STITCHES_INTERNAL]?: { type?: unknown } };\n\n// A Stitches `styled(Td)` keeps the class name of a Stitches Td, or renders a component Td.\n// This reads Stitches 1.x internals; the styled Td tests catch a change in them.\nconst isCellType = (type: unknown, cellType: ElementType) => {\n if (type === cellType) {\n return true;\n }\n if (!type || (typeof type !== 'object' && typeof type !== 'function')) {\n return false;\n }\n const { className, [STITCHES_INTERNAL]: internal } = type as StitchesType;\n const cellClassName = (cellType as StitchesType).className;\n return internal?.type === cellType || (!!cellClassName && className === cellClassName);\n};\n\nconst warnedMessages = new Set<string>();\n\n/** Clears the warnings that were already logged. For tests only. */\nexport const resetRowLinkWarnings = () => warnedMessages.clear();\n\nconst warnOnce = (message: string) => {\n if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {\n return;\n }\n if (!warnedMessages.has(message)) {\n warnedMessages.add(message);\n console.warn(message);\n }\n};\n\n/** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */\nexport const withRowLink = (\n children: ReactNode,\n { href, linkAs: LinkComponent = 'a', linkCell = 0, linkProps }: RowLinkShortcutProps,\n cellType: ElementType,\n) => {\n if (href === undefined) {\n return children;\n }\n\n let cellIndex = -1;\n let linked = false;\n // eslint-disable-next-line @eslint-react/no-children-map\n const mapped = Children.map(children, (child) => {\n if (!isValidElement<{ children?: ReactNode }>(child)) {\n return child;\n }\n cellIndex += 1;\n if (cellIndex !== linkCell || !isCellType(child.type, cellType)) {\n return child;\n }\n linked = true;\n // eslint-disable-next-line @eslint-react/no-clone-element\n return cloneElement(\n child,\n undefined,\n <RowLink asChild>\n <LinkComponent {...linkProps} href={href}>\n {child.props.children}\n </LinkComponent>\n </RowLink>,\n );\n });\n\n if (!linked) {\n warnOnce(\n `Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`,\n );\n }\n\n return mapped;\n};\n"],"mappings":";;;;;;;AAKA,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB,OAAO,IAAI,cAAc;AAEnD,IAAM,mBAAmB;AAEzB,IAAM,oBAAoB,sEAAsE,mBAAmB;AAEnH,IAAM,gBAAgB;CACpB,OAAO;CACP,gBAAgB;CAChB,SAAS;CAET,YAAY;EACV,SAAS;EACT,UAAU;EACV,OAAO;EACP,QAAQ;CACV;CAEA,0BAA0B;EACxB,cAAc;EACd,cAAc;EACd,cAAc;EACd,eAAe;CACjB;AACF;AAEA,IAAM,gBAAgBA,wBAAAA,OAAO,KAAK,aAAa;AAC/C,IAAM,oBAAoBA,wBAAAA,OAAOC,qBAAAA,MAAM,aAAa;;AAGpD,IAAa,qBAAqB,GAC/B,UAAU,mBAAmB,MAAM,EAClC,WAAW,UACb,EACF;;AAGA,IAAa,mBAAmB;EAC7B,UAAU,mBAAmB,MAAM,EAClC,UAAU,WACZ;EAEC,UAAU,mBAAmB,KAAK,sBAAsB;EACvD,UAAU;EACV,QAAA;CACF;AACF;;;;;AAWA,IAAa,UAAUC,MAAAA,QAAM,YAC1B,EAAE,SAAS,GAAG,SAAS,iBAAiB;CAGvC,OAAO,iBAAA,G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sFACxC;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"RowLink.cjs","names":["styled","Slot","React","Children","isValidElement","cloneElement"],"sources":["../../../components/RowLink/RowLink.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { Children, cloneElement, ElementType, isValidElement, ReactNode } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { warnOnce } from '../../utils/warnOnce';\n\nconst ROW_LINK_ATTRIBUTE = 'data-row-link';\nconst STITCHES_INTERNAL = Symbol.for('sxs.internal');\n\nconst ROW_LINK_Z_INDEX = 1;\nexport const ROW_LINK_CONTROL_Z_INDEX = 2;\nconst ROW_LINK_CONTROLS = `:where(a, button, input, select, textarea, [tabindex]):where(:not([${ROW_LINK_ATTRIBUTE}]))`;\n\nconst rowLinkStyles = {\n color: 'inherit',\n textDecoration: 'none',\n outline: 'none',\n\n '&::after': {\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n zIndex: ROW_LINK_Z_INDEX,\n },\n\n '&:focus-visible::after': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '-2px',\n },\n\n [`&[${ROW_LINK_ATTRIBUTE}=\"click\"]::after`]: {\n content: 'none',\n },\n\n [`&[${ROW_LINK_ATTRIBUTE}=\"click\"]:focus-visible`]: {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '2px',\n },\n};\n\nconst StyledRowLink = styled('a', rowLinkStyles);\nconst StyledRowLinkSlot = styled(Slot, rowLinkStyles);\n\n/** Styles for a table that can hold a `RowLink`. */\nexport const rowLinkTableStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n isolation: 'isolate',\n },\n};\n\n/** Styles for a table row that can hold a `RowLink`. */\nexport const rowLinkRowStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n position: 'relative',\n },\n // Not at zero specificity, so that it wins over the `all: unset` of controls such as Checkbox.\n [`&:has([${ROW_LINK_ATTRIBUTE}]) ${ROW_LINK_CONTROLS}`]: {\n position: 'relative',\n zIndex: ROW_LINK_CONTROL_Z_INDEX,\n },\n};\n\nexport type RowLinkProps = React.ComponentProps<typeof StyledRowLink> & {\n asChild?: boolean;\n css?: CSS;\n /**\n * With `false`, the link does not cover the row. The row opens it on a click instead, so the text of the\n * row keeps its hover, for example a tooltip, and can be selected.\n */\n overlay?: boolean;\n};\n\n/**\n * A link that covers its whole table row, so that a click on the row opens it.\n * Other links and buttons in the row stay above it.\n */\nexport const RowLink = React.forwardRef<HTMLAnchorElement, RowLinkProps>(\n ({ asChild, overlay = true, ...props }, forwardedRef) => {\n const Component = asChild ? StyledRowLinkSlot : StyledRowLink;\n\n return (\n <Component\n ref={forwardedRef}\n {...{ [ROW_LINK_ATTRIBUTE]: overlay ? '' : 'click' }}\n {...props}\n />\n );\n },\n);\n\nRowLink.displayName = 'RowLink';\n\nexport type RowLinkShortcutProps = {\n href?: string;\n /**\n * The link component, for example a router link. It must pass its props and ref to its `<a>`,\n * and it must be defined outside render, or the link mounts again on each render.\n */\n linkAs?: ElementType;\n /** Other props for the link component, for example `{ returnTo }`. */\n linkProps?: Record<string, unknown>;\n /** The index of the cell that holds the link, among the direct children of the row. */\n linkCell?: number;\n /** With `false`, the link does not cover the row: see `overlay` on `RowLink`. */\n linkOverlay?: boolean;\n};\n\ntype StitchesType = { className?: string; [STITCHES_INTERNAL]?: { type?: unknown } };\n\n// A Stitches `styled(Td)` keeps the class name of a Stitches Td, or renders a component Td.\n// This reads Stitches 1.x internals; the styled Td tests catch a change in them.\nconst isCellType = (type: unknown, cellType: ElementType) => {\n if (type === cellType) {\n return true;\n }\n if (!type || (typeof type !== 'object' && typeof type !== 'function')) {\n return false;\n }\n const { className, [STITCHES_INTERNAL]: internal } = type as StitchesType;\n const cellClassName = (cellType as StitchesType).className;\n return internal?.type === cellType || (!!cellClassName && className === cellClassName);\n};\n\n/** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */\nexport const withRowLink = (\n children: ReactNode,\n { href, linkAs: LinkComponent = 'a', linkCell = 0, linkProps, linkOverlay }: RowLinkShortcutProps,\n cellType: ElementType,\n) => {\n if (href === undefined) {\n return children;\n }\n\n let cellIndex = -1;\n let linked = false;\n // eslint-disable-next-line @eslint-react/no-children-map\n const mapped = Children.map(children, (child) => {\n if (!isValidElement<{ children?: ReactNode }>(child)) {\n return child;\n }\n cellIndex += 1;\n if (cellIndex !== linkCell || !isCellType(child.type, cellType)) {\n return child;\n }\n linked = true;\n // eslint-disable-next-line @eslint-react/no-clone-element\n return cloneElement(\n child,\n undefined,\n <RowLink asChild overlay={linkOverlay}>\n <LinkComponent {...linkProps} href={href}>\n {child.props.children}\n </LinkComponent>\n </RowLink>,\n );\n });\n\n if (!linked) {\n warnOnce(\n `Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`,\n );\n }\n\n return mapped;\n};\n\n// Only a web page opens in a new tab, never a script URL such as javascript: or data:.\n// Other links, such as tel: or mailto:, open as on a plain click.\nconst NEW_TAB_PROTOCOLS = ['http:', 'https:'];\n\nconst ROW_CLICK_CONTROLS =\n 'a, button, input, select, textarea, label, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"switch\"], [role=\"menuitem\"], [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]';\n\n/** Opens the `RowLink` without overlay of the row on a click or a middle click outside its controls. */\nexport const openRowLink = <T extends HTMLElement>(event: React.MouseEvent<T>) => {\n const isAuxClick = event.type === 'auxclick';\n if (event.defaultPrevented || (isAuxClick && event.button !== 1)) {\n return;\n }\n const row = event.currentTarget;\n const target = event.target;\n // A portal, such as a row menu, sends its clicks to the row through React, but it is not in the row.\n if (!(target instanceof Element) || !row.contains(target)) {\n return;\n }\n const control = target.closest(ROW_CLICK_CONTROLS);\n if (control && row.contains(control)) {\n return;\n }\n const link = row.querySelector<HTMLAnchorElement>(`[${ROW_LINK_ATTRIBUTE}=\"click\"]`);\n if (!link) {\n return;\n }\n // A drag that selects text in the row is not a click on the row.\n const selection = window.getSelection();\n if (selection && !selection.isCollapsed && row.contains(selection.anchorNode)) {\n return;\n }\n const newTab = isAuxClick || event.metaKey || event.ctrlKey || event.shiftKey;\n if (newTab && NEW_TAB_PROTOCOLS.includes(new URL(link.href, window.location.href).protocol)) {\n window.open(link.href, '_blank', 'noopener,noreferrer');\n return;\n }\n link.click();\n};\n"],"mappings":";;;;;;;;AAMA,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB,OAAO,IAAI,cAAc;AAEnD,IAAM,mBAAmB;AAEzB,IAAM,oBAAoB,sEAAsE,mBAAmB;AAEnH,IAAM,gBAAgB;CACpB,OAAO;CACP,gBAAgB;CAChB,SAAS;CAET,YAAY;EACV,SAAS;EACT,UAAU;EACV,OAAO;EACP,QAAQ;CACV;CAEA,0BAA0B;EACxB,cAAc;EACd,cAAc;EACd,cAAc;EACd,eAAe;CACjB;EAEC,KAAK,mBAAmB,oBAAoB,EAC3C,SAAS,OACX;EAEC,KAAK,mBAAmB,2BAA2B;EAClD,cAAc;EACd,cAAc;EACd,cAAc;EACd,eAAe;CACjB;AACF;AAEA,IAAM,gBAAgBA,wBAAAA,OAAO,KAAK,aAAa;AAC/C,IAAM,oBAAoBA,wBAAAA,OAAOC,qBAAAA,MAAM,aAAa;;AAGpD,IAAa,qBAAqB,GAC/B,UAAU,mBAAmB,MAAM,EAClC,WAAW,UACb,EACF;;AAGA,IAAa,mBAAmB;EAC7B,UAAU,mBAAmB,MAAM,EAClC,UAAU,WACZ;EAEC,UAAU,mBAAmB,KAAK,sBAAsB;EACvD,UAAU;EACV,QAAA;CACF;AACF;;;;;AAgBA,IAAa,UAAUC,MAAAA,QAAM,YAC1B,EAAE,SAAS,UAAU,MAAM,GAAG,SAAS,iBAAiB;CAGvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAHgB,UAAU,oBAAoB,eAG9C;EACE,KAAK;GAC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CAErB,IAAI,EAAE,kBAAkB,YAAY,CAAC,IAAI,SAAS,MAAM,GACtD;CAEF,MAAM,UAAU,OAAO,QAAQ,kBAAkB;CACjD,IAAI,WAAW,IAAI,SAAS,OAAO,GACjC;CAEF,MAAM,OAAO,IAAI,cAAiC,IAAI,mBAAmB,UAAU;CACnF,IAAI,CAAC,MACH;CAGF,MAAM,YAAY,OAAO,aAAa;CACtC,IAAI,aAAa,CAAC,UAAU,eAAe,IAAI,SAAS,UAAU,UAAU,GAC1E;CAGF,KADe,cAAc,MAAM,WAAW,MAAM,WAAW,MAAM,aACvD,kBAAkB,SAAS,IAAI,IAAI,KAAK,MAAM,OAAO,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG;EAC3F,OAAO,KAAK,KAAK,MAAM,UAAU,qBAAqB;EACtD;CACF;CACA,KAAK,MAAM;AACb"}
@@ -1,4 +1,5 @@
1
1
  import { styled } from "../../stitches.config.js";
2
+ import { warnOnce } from "../../utils/warnOnce.js";
2
3
  import React, { Children, cloneElement, isValidElement } from "react";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  import { Slot } from "@radix-ui/react-slot";
@@ -22,6 +23,13 @@ var rowLinkStyles = {
22
23
  outlineStyle: "solid",
23
24
  outlineColor: "$focusOutline",
24
25
  outlineOffset: "-2px"
26
+ },
27
+ [`&[${ROW_LINK_ATTRIBUTE}="click"]::after`]: { content: "none" },
28
+ [`&[${ROW_LINK_ATTRIBUTE}="click"]:focus-visible`]: {
29
+ outlineWidth: "2px",
30
+ outlineStyle: "solid",
31
+ outlineColor: "$focusOutline",
32
+ outlineOffset: "2px"
25
33
  }
26
34
  };
27
35
  var StyledRowLink = styled("a", rowLinkStyles);
@@ -40,10 +48,10 @@ var rowLinkRowStyles = {
40
48
  * A link that covers its whole table row, so that a click on the row opens it.
41
49
  * Other links and buttons in the row stay above it.
42
50
  */
43
- var RowLink = React.forwardRef(({ asChild, ...props }, forwardedRef) => {
51
+ var RowLink = React.forwardRef(({ asChild, overlay = true, ...props }, forwardedRef) => {
44
52
  return /* @__PURE__ */ jsx(asChild ? StyledRowLinkSlot : StyledRowLink, {
45
53
  ref: forwardedRef,
46
- [ROW_LINK_ATTRIBUTE]: "",
54
+ [ROW_LINK_ATTRIBUTE]: overlay ? "" : "click",
47
55
  ...props
48
56
  });
49
57
  });
@@ -55,16 +63,8 @@ var isCellType = (type, cellType) => {
55
63
  const cellClassName = cellType.className;
56
64
  return internal?.type === cellType || !!cellClassName && className === cellClassName;
57
65
  };
58
- var warnedMessages = /* @__PURE__ */ new Set();
59
- var warnOnce = (message) => {
60
- if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
61
- if (!warnedMessages.has(message)) {
62
- warnedMessages.add(message);
63
- console.warn(message);
64
- }
65
- };
66
66
  /** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */
67
- var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0, linkProps }, cellType) => {
67
+ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0, linkProps, linkOverlay }, cellType) => {
68
68
  if (href === void 0) return children;
69
69
  let cellIndex = -1;
70
70
  let linked = false;
@@ -75,6 +75,7 @@ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0,
75
75
  linked = true;
76
76
  return cloneElement(child, void 0, /* @__PURE__ */ jsx(RowLink, {
77
77
  asChild: true,
78
+ overlay: linkOverlay,
78
79
  children: /* @__PURE__ */ jsx(LinkComponent, {
79
80
  ...linkProps,
80
81
  href,
@@ -85,6 +86,27 @@ var withRowLink = (children, { href, linkAs: LinkComponent = "a", linkCell = 0,
85
86
  if (!linked) warnOnce(`Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`);
86
87
  return mapped;
87
88
  };
88
- export { RowLink, rowLinkRowStyles, rowLinkTableStyles, withRowLink };
89
+ var NEW_TAB_PROTOCOLS = ["http:", "https:"];
90
+ var ROW_CLICK_CONTROLS = "a, button, input, select, textarea, label, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"switch\"], [role=\"menuitem\"], [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]";
91
+ /** Opens the `RowLink` without overlay of the row on a click or a middle click outside its controls. */
92
+ var openRowLink = (event) => {
93
+ const isAuxClick = event.type === "auxclick";
94
+ if (event.defaultPrevented || isAuxClick && event.button !== 1) return;
95
+ const row = event.currentTarget;
96
+ const target = event.target;
97
+ if (!(target instanceof Element) || !row.contains(target)) return;
98
+ const control = target.closest(ROW_CLICK_CONTROLS);
99
+ if (control && row.contains(control)) return;
100
+ const link = row.querySelector(`[${ROW_LINK_ATTRIBUTE}="click"]`);
101
+ if (!link) return;
102
+ const selection = window.getSelection();
103
+ if (selection && !selection.isCollapsed && row.contains(selection.anchorNode)) return;
104
+ if ((isAuxClick || event.metaKey || event.ctrlKey || event.shiftKey) && NEW_TAB_PROTOCOLS.includes(new URL(link.href, window.location.href).protocol)) {
105
+ window.open(link.href, "_blank", "noopener,noreferrer");
106
+ return;
107
+ }
108
+ link.click();
109
+ };
110
+ export { RowLink, openRowLink, rowLinkRowStyles, rowLinkTableStyles, withRowLink };
89
111
 
90
112
  //# sourceMappingURL=RowLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RowLink.js","names":[],"sources":["../../../components/RowLink/RowLink.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { Children, cloneElement, ElementType, isValidElement, ReactNode } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\n\nconst ROW_LINK_ATTRIBUTE = 'data-row-link';\nconst STITCHES_INTERNAL = Symbol.for('sxs.internal');\n\nconst ROW_LINK_Z_INDEX = 1;\nexport const ROW_LINK_CONTROL_Z_INDEX = 2;\nconst ROW_LINK_CONTROLS = `:where(a, button, input, select, textarea, [tabindex]):where(:not([${ROW_LINK_ATTRIBUTE}]))`;\n\nconst rowLinkStyles = {\n color: 'inherit',\n textDecoration: 'none',\n outline: 'none',\n\n '&::after': {\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n zIndex: ROW_LINK_Z_INDEX,\n },\n\n '&:focus-visible::after': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '-2px',\n },\n};\n\nconst StyledRowLink = styled('a', rowLinkStyles);\nconst StyledRowLinkSlot = styled(Slot, rowLinkStyles);\n\n/** Styles for a table that can hold a `RowLink`. */\nexport const rowLinkTableStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n isolation: 'isolate',\n },\n};\n\n/** Styles for a table row that can hold a `RowLink`. */\nexport const rowLinkRowStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n position: 'relative',\n },\n // Not at zero specificity, so that it wins over the `all: unset` of controls such as Checkbox.\n [`&:has([${ROW_LINK_ATTRIBUTE}]) ${ROW_LINK_CONTROLS}`]: {\n position: 'relative',\n zIndex: ROW_LINK_CONTROL_Z_INDEX,\n },\n};\n\nexport type RowLinkProps = React.ComponentProps<typeof StyledRowLink> & {\n asChild?: boolean;\n css?: CSS;\n};\n\n/**\n * A link that covers its whole table row, so that a click on the row opens it.\n * Other links and buttons in the row stay above it.\n */\nexport const RowLink = React.forwardRef<HTMLAnchorElement, RowLinkProps>(\n ({ asChild, ...props }, forwardedRef) => {\n const Component = asChild ? StyledRowLinkSlot : StyledRowLink;\n\n return <Component ref={forwardedRef} {...{ [ROW_LINK_ATTRIBUTE]: '' }} {...props} />;\n },\n);\n\nRowLink.displayName = 'RowLink';\n\nexport type RowLinkShortcutProps = {\n href?: string;\n /**\n * The link component, for example a router link. It must pass its props and ref to its `<a>`,\n * and it must be defined outside render, or the link mounts again on each render.\n */\n linkAs?: ElementType;\n /** Other props for the link component, for example `{ returnTo }`. */\n linkProps?: Record<string, unknown>;\n /** The index of the cell that holds the link, among the direct children of the row. */\n linkCell?: number;\n};\n\ntype StitchesType = { className?: string; [STITCHES_INTERNAL]?: { type?: unknown } };\n\n// A Stitches `styled(Td)` keeps the class name of a Stitches Td, or renders a component Td.\n// This reads Stitches 1.x internals; the styled Td tests catch a change in them.\nconst isCellType = (type: unknown, cellType: ElementType) => {\n if (type === cellType) {\n return true;\n }\n if (!type || (typeof type !== 'object' && typeof type !== 'function')) {\n return false;\n }\n const { className, [STITCHES_INTERNAL]: internal } = type as StitchesType;\n const cellClassName = (cellType as StitchesType).className;\n return internal?.type === cellType || (!!cellClassName && className === cellClassName);\n};\n\nconst warnedMessages = new Set<string>();\n\n/** Clears the warnings that were already logged. For tests only. */\nexport const resetRowLinkWarnings = () => warnedMessages.clear();\n\nconst warnOnce = (message: string) => {\n if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {\n return;\n }\n if (!warnedMessages.has(message)) {\n warnedMessages.add(message);\n console.warn(message);\n }\n};\n\n/** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */\nexport const withRowLink = (\n children: ReactNode,\n { href, linkAs: LinkComponent = 'a', linkCell = 0, linkProps }: RowLinkShortcutProps,\n cellType: ElementType,\n) => {\n if (href === undefined) {\n return children;\n }\n\n let cellIndex = -1;\n let linked = false;\n // eslint-disable-next-line @eslint-react/no-children-map\n const mapped = Children.map(children, (child) => {\n if (!isValidElement<{ children?: ReactNode }>(child)) {\n return child;\n }\n cellIndex += 1;\n if (cellIndex !== linkCell || !isCellType(child.type, cellType)) {\n return child;\n }\n linked = true;\n // eslint-disable-next-line @eslint-react/no-clone-element\n return cloneElement(\n child,\n undefined,\n <RowLink asChild>\n <LinkComponent {...linkProps} href={href}>\n {child.props.children}\n </LinkComponent>\n </RowLink>,\n );\n });\n\n if (!linked) {\n warnOnce(\n `Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`,\n );\n }\n\n return mapped;\n};\n"],"mappings":";;;;;AAKA,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB,OAAO,IAAI,cAAc;AAEnD,IAAM,mBAAmB;AAEzB,IAAM,o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AAG,aACnD,aACG;CACH,IAAI,SAAS,KAAA,GACX,OAAO;CAGT,IAAI,YAAY;CAChB,IAAI,SAAS;CAEb,MAAM,SAAS,SAAS,IAAI,WAAW,UAAU;EAC/C,IAAI,CAAC,eAAyC,KAAK,GACjD,OAAO;EAET,aAAa;EACb,IAAI,cAAc,YAAY,CAAC,WAAW,MAAM,MAAM,QAAQ,GAC5D,OAAO;EAET,SAAS;EAET,OAAO,aACL,OACA,KAAA,GACA,oBAAC,SAAD;GAAS,SAAA;GACP,UAAA,oBAAC,eAAD;IAAe,GAAI;IAAiB;IACjC,UAAA,MAAM,MAAM;GACA,CAAA;EACR,CAAA,CACX;CACF,CAAC;CAED,IAAI,CAAC,QACH,SACE,6BAA6B,SAAS,sFACxC;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"RowLink.js","names":[],"sources":["../../../components/RowLink/RowLink.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { Children, cloneElement, ElementType, isValidElement, ReactNode } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { warnOnce } from '../../utils/warnOnce';\n\nconst ROW_LINK_ATTRIBUTE = 'data-row-link';\nconst STITCHES_INTERNAL = Symbol.for('sxs.internal');\n\nconst ROW_LINK_Z_INDEX = 1;\nexport const ROW_LINK_CONTROL_Z_INDEX = 2;\nconst ROW_LINK_CONTROLS = `:where(a, button, input, select, textarea, [tabindex]):where(:not([${ROW_LINK_ATTRIBUTE}]))`;\n\nconst rowLinkStyles = {\n color: 'inherit',\n textDecoration: 'none',\n outline: 'none',\n\n '&::after': {\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n zIndex: ROW_LINK_Z_INDEX,\n },\n\n '&:focus-visible::after': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '-2px',\n },\n\n [`&[${ROW_LINK_ATTRIBUTE}=\"click\"]::after`]: {\n content: 'none',\n },\n\n [`&[${ROW_LINK_ATTRIBUTE}=\"click\"]:focus-visible`]: {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: '$focusOutline',\n outlineOffset: '2px',\n },\n};\n\nconst StyledRowLink = styled('a', rowLinkStyles);\nconst StyledRowLinkSlot = styled(Slot, rowLinkStyles);\n\n/** Styles for a table that can hold a `RowLink`. */\nexport const rowLinkTableStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n isolation: 'isolate',\n },\n};\n\n/** Styles for a table row that can hold a `RowLink`. */\nexport const rowLinkRowStyles = {\n [`&:has([${ROW_LINK_ATTRIBUTE}])`]: {\n position: 'relative',\n },\n // Not at zero specificity, so that it wins over the `all: unset` of controls such as Checkbox.\n [`&:has([${ROW_LINK_ATTRIBUTE}]) ${ROW_LINK_CONTROLS}`]: {\n position: 'relative',\n zIndex: ROW_LINK_CONTROL_Z_INDEX,\n },\n};\n\nexport type RowLinkProps = React.ComponentProps<typeof StyledRowLink> & {\n asChild?: boolean;\n css?: CSS;\n /**\n * With `false`, the link does not cover the row. The row opens it on a click instead, so the text of the\n * row keeps its hover, for example a tooltip, and can be selected.\n */\n overlay?: boolean;\n};\n\n/**\n * A link that covers its whole table row, so that a click on the row opens it.\n * Other links and buttons in the row stay above it.\n */\nexport const RowLink = React.forwardRef<HTMLAnchorElement, RowLinkProps>(\n ({ asChild, overlay = true, ...props }, forwardedRef) => {\n const Component = asChild ? StyledRowLinkSlot : StyledRowLink;\n\n return (\n <Component\n ref={forwardedRef}\n {...{ [ROW_LINK_ATTRIBUTE]: overlay ? '' : 'click' }}\n {...props}\n />\n );\n },\n);\n\nRowLink.displayName = 'RowLink';\n\nexport type RowLinkShortcutProps = {\n href?: string;\n /**\n * The link component, for example a router link. It must pass its props and ref to its `<a>`,\n * and it must be defined outside render, or the link mounts again on each render.\n */\n linkAs?: ElementType;\n /** Other props for the link component, for example `{ returnTo }`. */\n linkProps?: Record<string, unknown>;\n /** The index of the cell that holds the link, among the direct children of the row. */\n linkCell?: number;\n /** With `false`, the link does not cover the row: see `overlay` on `RowLink`. */\n linkOverlay?: boolean;\n};\n\ntype StitchesType = { className?: string; [STITCHES_INTERNAL]?: { type?: unknown } };\n\n// A Stitches `styled(Td)` keeps the class name of a Stitches Td, or renders a component Td.\n// This reads Stitches 1.x internals; the styled Td tests catch a change in them.\nconst isCellType = (type: unknown, cellType: ElementType) => {\n if (type === cellType) {\n return true;\n }\n if (!type || (typeof type !== 'object' && typeof type !== 'function')) {\n return false;\n }\n const { className, [STITCHES_INTERNAL]: internal } = type as StitchesType;\n const cellClassName = (cellType as StitchesType).className;\n return internal?.type === cellType || (!!cellClassName && className === cellClassName);\n};\n\n/** Puts the content of the `cellType` cell at `linkCell` in a `RowLink` to `href`. */\nexport const withRowLink = (\n children: ReactNode,\n { href, linkAs: LinkComponent = 'a', linkCell = 0, linkProps, linkOverlay }: RowLinkShortcutProps,\n cellType: ElementType,\n) => {\n if (href === undefined) {\n return children;\n }\n\n let cellIndex = -1;\n let linked = false;\n // eslint-disable-next-line @eslint-react/no-children-map\n const mapped = Children.map(children, (child) => {\n if (!isValidElement<{ children?: ReactNode }>(child)) {\n return child;\n }\n cellIndex += 1;\n if (cellIndex !== linkCell || !isCellType(child.type, cellType)) {\n return child;\n }\n linked = true;\n // eslint-disable-next-line @eslint-react/no-clone-element\n return cloneElement(\n child,\n undefined,\n <RowLink asChild overlay={linkOverlay}>\n <LinkComponent {...linkProps} href={href}>\n {child.props.children}\n </LinkComponent>\n </RowLink>,\n );\n });\n\n if (!linked) {\n warnOnce(\n `Tr: the child at linkCell ${linkCell} is not a Td, so the row has no link. Use a Td for that cell, or put a RowLink in it.`,\n );\n }\n\n return mapped;\n};\n\n// Only a web page opens in a new tab, never a script URL such as javascript: or data:.\n// Other links, such as tel: or mailto:, open as on a plain click.\nconst NEW_TAB_PROTOCOLS = ['http:', 'https:'];\n\nconst ROW_CLICK_CONTROLS =\n 'a, button, input, select, textarea, label, summary, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"switch\"], [role=\"menuitem\"], [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]';\n\n/** Opens the `RowLink` without overlay of the row on a click or a middle click outside its controls. */\nexport const openRowLink = <T extends HTMLElement>(event: React.MouseEvent<T>) => {\n const isAuxClick = event.type === 'auxclick';\n if (event.defaultPrevented || (isAuxClick && event.button !== 1)) {\n return;\n }\n const row = event.currentTarget;\n const target = event.target;\n // A portal, such as a row menu, sends its clicks to the row through React, but it is not in the row.\n if (!(target instanceof Element) || !row.contains(target)) {\n return;\n }\n const control = target.closest(ROW_CLICK_CONTROLS);\n if (control && row.contains(control)) {\n return;\n }\n const link = row.querySelector<HTMLAnchorElement>(`[${ROW_LINK_ATTRIBUTE}=\"click\"]`);\n if (!link) {\n return;\n }\n // A drag that selects text in the row is not a click on the row.\n const selection = window.getSelection();\n if (selection && !selection.isCollapsed && row.contains(selection.anchorNode)) {\n return;\n }\n const newTab = isAuxClick || event.metaKey || event.ctrlKey || event.shiftKey;\n if (newTab && NEW_TAB_PROTOCOLS.includes(new URL(link.href, window.location.href).protocol)) {\n window.open(link.href, '_blank', 'noopener,noreferrer');\n return;\n }\n link.click();\n};\n"],"mappings":";;;;;;AAMA,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB,OAAO,IAAI,cAAc;AAEnD,IAAM,mBAAmB;AAEzB,IAAM,oBAAoB,sEAAsE,mBAAmB;AAEnH,IAAM,gBAAgB;CACpB,OAAO;CACP,gBAAgB;CAChB,SAAS;CAET,YAAY;EACV,SAAS;EACT,UAAU;EACV,OAAO;EACP,QAAQ;CACV;CAEA,0BAA0B;EACxB,cAAc;EACd,cAAc;EACd,cAAc;EACd,eAAe;CACjB;EAEC,KAAK,mBAAmB,oBAAoB,EAC3C,SAAS,OACX;EAEC,KAAK,mBAAmB,2BAA2B;EAClD,cAAc;EACd,cAAc;EACd,cAAc;EACd,eAAe;CACjB;AACF;AAEA,IAAM,gBAAgB,OAAO,KAAK,aAAa;AAC/C,IAAM,oBA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ACE,6BAA6B,SAAS,sFACxC;CAGF,OAAO;AACT;AAIA,IAAM,oBAAoB,CAAC,SAAS,QAAQ;AAE5C,IAAM,qBACJ;;AAGF,IAAa,eAAsC,UAA+B;CAChF,MAAM,aAAa,MAAM,SAAS;CAClC,IAAI,MAAM,oBAAqB,cAAc,MAAM,WAAW,GAC5D;CAEF,MAAM,MAAM,MAAM;CAClB,MAAM,SAAS,MAAM;CAErB,IAAI,EAAE,kBAAkB,YAAY,CAAC,IAAI,SAAS,MAAM,GACtD;CAEF,MAAM,UAAU,OAAO,QAAQ,kBAAkB;CACjD,IAAI,WAAW,IAAI,SAAS,OAAO,GACjC;CAEF,MAAM,OAAO,IAAI,cAAiC,IAAI,mBAAmB,UAAU;CACnF,IAAI,CAAC,MACH;CAGF,MAAM,YAAY,OAAO,aAAa;CACtC,IAAI,aAAa,CAAC,UAAU,eAAe,IAAI,SAAS,UAAU,UAAU,GAC1E;CAGF,KADe,cAAc,MAAM,WAAW,MAAM,WAAW,MAAM,aACvD,kBAAkB,SAAS,IAAI,IAAI,KAAK,MAAM,OAAO,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG;EAC3F,OAAO,KAAK,KAAK,MAAM,UAAU,qBAAqB;EACtD;CACF;CACA,KAAK,MAAM;AACb"}
@@ -0,0 +1,57 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_cssProps = require("../../styles/cssProps.cjs");
3
+ const require_themeContext = require("../../styles/themeContext.cjs");
4
+ const require_SegmentedControl_vanilla_css = require("./SegmentedControl.vanilla.css.cjs");
5
+ let react = require("react");
6
+ react = require_runtime.__toESM(react, 1);
7
+ let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let _radix_ui_react_radio_group = require("@radix-ui/react-radio-group");
10
+ _radix_ui_react_radio_group = require_runtime.__toESM(_radix_ui_react_radio_group, 1);
11
+ // components/SegmentedControl/SegmentedControl.vanilla.tsx
12
+ var joinClassNames = (...classNames) => classNames.filter(Boolean).join(" ");
13
+ var useCssProp = (css, style) => {
14
+ const { colors } = require_themeContext.useVanillaExtractTheme();
15
+ const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
16
+ return {
17
+ ...cssStyles,
18
+ ...style,
19
+ ...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
20
+ };
21
+ };
22
+ var SegmentedControlContext = (0, react.createContext)({
23
+ size: "medium",
24
+ fullWidth: false
25
+ });
26
+ var SegmentedControlVanilla = (0, react.forwardRef)(({ size = "medium", fullWidth = false, className, css, style, children, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentedControlContext.Provider, {
27
+ value: {
28
+ size,
29
+ fullWidth
30
+ },
31
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_radio_group.Root, {
32
+ ref,
33
+ orientation: "horizontal",
34
+ className: joinClassNames(require_SegmentedControl_vanilla_css.segmentedControlRecipe({ fullWidth }), className),
35
+ style: useCssProp(css, style),
36
+ ...props,
37
+ children
38
+ })
39
+ }));
40
+ SegmentedControlVanilla.displayName = "SegmentedControlVanilla";
41
+ var SegmentedControlItemVanilla = (0, react.forwardRef)(({ className, css, style, ...props }, ref) => {
42
+ const { size, fullWidth } = (0, react.useContext)(SegmentedControlContext);
43
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_radio_group.Item, {
44
+ ref,
45
+ className: joinClassNames(require_SegmentedControl_vanilla_css.segmentedControlItemRecipe({
46
+ size,
47
+ fullWidth
48
+ }), className),
49
+ style: useCssProp(css, style),
50
+ ...props
51
+ });
52
+ });
53
+ SegmentedControlItemVanilla.displayName = "SegmentedControlItemVanilla";
54
+ exports.SegmentedControlItemVanilla = SegmentedControlItemVanilla;
55
+ exports.SegmentedControlVanilla = SegmentedControlVanilla;
56
+
57
+ //# sourceMappingURL=SegmentedControl.vanilla.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControl.vanilla.cjs","names":["useVanillaExtractTheme","processCSSProp","assignInlineVars","createContext","forwardRef","RadioGroupPrimitive","segmentedControlRecipe","useContext","segmentedControlItemRecipe"],"sources":["../../../components/SegmentedControl/SegmentedControl.vanilla.tsx"],"sourcesContent":["import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { ComponentPropsWithoutRef, createContext, forwardRef, useContext } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport {\n segmentedControlItemRecipe,\n segmentedControlRecipe,\n SegmentedControlSize,\n} from './SegmentedControl.vanilla.css';\n\nexport type { SegmentedControlSize };\n\nconst joinClassNames = (...classNames: (string | undefined)[]) =>\n classNames.filter(Boolean).join(' ');\n\nconst useCssProp = (css: CSSProps['css'], style?: React.CSSProperties) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n return { ...cssStyles, ...style, ...assignInlineVars(vars) };\n};\n\nconst SegmentedControlContext = createContext<{\n size: SegmentedControlSize;\n fullWidth: boolean;\n}>({ size: 'medium', fullWidth: false });\n\nexport interface SegmentedControlVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>, 'asChild'>, CSSProps {\n size?: SegmentedControlSize;\n fullWidth?: boolean;\n}\n\nexport const SegmentedControlVanilla = forwardRef<HTMLDivElement, SegmentedControlVanillaProps>(\n ({ size = 'medium', fullWidth = false, className, css, style, children, ...props }, ref) => (\n <SegmentedControlContext.Provider value={{ size, fullWidth }}>\n <RadioGroupPrimitive.Root\n ref={ref}\n orientation=\"horizontal\"\n className={joinClassNames(segmentedControlRecipe({ fullWidth }), className)}\n style={useCssProp(css, style)}\n {...props}\n >\n {children}\n </RadioGroupPrimitive.Root>\n </SegmentedControlContext.Provider>\n ),\n);\n\nSegmentedControlVanilla.displayName = 'SegmentedControlVanilla';\n\nexport interface SegmentedControlItemVanillaProps\n extends Omit<ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>, 'asChild'>, CSSProps {}\n\nexport const SegmentedControlItemVanilla = forwardRef<\n HTMLButtonElement,\n SegmentedControlItemVanillaProps\n>(({ className, css, style, ...props }, ref) => {\n const { size, fullWidth } = useContext(SegmentedControlContext);\n\n return (\n <RadioGroupPrimitive.Item\n ref={ref}\n className={joinClassNames(segmentedControlItemRecipe({ size, fullWidth }), className)}\n style={useCssProp(css, style)}\n {...props}\n />\n );\n});\n\nSegmentedControlItemVanilla.displayName = 'SegmentedControlItemVanilla';\n"],"mappings":";;;;;;;;;;;AAcA,IAAM,kBAAkB,GAAG,eACzB,WAAW,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AAErC,IAAM,cAAc,KAAsB,UAAgC;CACxE,MAAM,EAAE,WAAWA,qBAAAA,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,OAAO;EAAE,GAAG;EAAW,GAAG;EAAO,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAAE;AAC7D;AAEA,IAAM,2BAAA,GAA0BC,MAAAA,cAAAA,CAG7B;CAAE,MAAM;CAAU,WAAW;AAAM,CAAC;AAQvC,IAAa,2BAAA,GAA0BC,MAAAA,WAAAA,EACpC,EAAE,OAAO,UAAU,YAAY,OAAO,WAAW,KAAK,OAAO,UAAU,GAAG,SAAS,QAClF,iBAAA,GAAA,kBAAA,IAAA,CAAC,wBAAwB,UAAzB;CAAkC,OAAO;EAAE;EAAM;CAAU;CACzD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAoB,MAArB;EACO;EACL,aAAY;EACZ,WAAW,eAAeC,qCAAAA,uBAAuB,EAAE,UAAU,CAAC,GAAG,SAAS;EAC1E,OAAO,WAAW,KAAK,KAAK;EAC5B,GAAI;EAEH;CACuB,CAAA;AACM,CAAA,CA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