@spark-ui/components 10.20.11 → 10.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/docgen.json CHANGED
@@ -37433,6 +37433,409 @@
37433
37433
  "methods": [],
37434
37434
  "props": {}
37435
37435
  },
37436
+ "SegmentedGauge": {
37437
+ "tags": {},
37438
+ "description": "",
37439
+ "displayName": "SegmentedGauge",
37440
+ "methods": [],
37441
+ "props": {
37442
+ "value": {
37443
+ "defaultValue": null,
37444
+ "description": "The current value of the gauge",
37445
+ "name": "value",
37446
+ "parent": {
37447
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37448
+ "name": "SegmentedGaugeProps"
37449
+ },
37450
+ "declarations": [
37451
+ {
37452
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37453
+ "name": "SegmentedGaugeProps"
37454
+ }
37455
+ ],
37456
+ "required": false,
37457
+ "type": {
37458
+ "name": "number"
37459
+ }
37460
+ },
37461
+ "min": {
37462
+ "defaultValue": null,
37463
+ "description": "Minimum value of the gauge (aria-valuemin)",
37464
+ "name": "min",
37465
+ "parent": {
37466
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37467
+ "name": "SegmentedGaugeProps"
37468
+ },
37469
+ "declarations": [
37470
+ {
37471
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37472
+ "name": "SegmentedGaugeProps"
37473
+ }
37474
+ ],
37475
+ "required": true,
37476
+ "type": {
37477
+ "name": "number"
37478
+ }
37479
+ },
37480
+ "max": {
37481
+ "defaultValue": null,
37482
+ "description": "Maximum value of the gauge (aria-valuemax)",
37483
+ "name": "max",
37484
+ "parent": {
37485
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37486
+ "name": "SegmentedGaugeProps"
37487
+ },
37488
+ "declarations": [
37489
+ {
37490
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37491
+ "name": "SegmentedGaugeProps"
37492
+ }
37493
+ ],
37494
+ "required": true,
37495
+ "type": {
37496
+ "name": "number"
37497
+ }
37498
+ },
37499
+ "description": {
37500
+ "defaultValue": null,
37501
+ "description": "Description text for the gauge (aria-describedby)",
37502
+ "name": "description",
37503
+ "parent": {
37504
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37505
+ "name": "SegmentedGaugeProps"
37506
+ },
37507
+ "declarations": [
37508
+ {
37509
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37510
+ "name": "SegmentedGaugeProps"
37511
+ }
37512
+ ],
37513
+ "required": false,
37514
+ "type": {
37515
+ "name": "string"
37516
+ }
37517
+ },
37518
+ "size": {
37519
+ "defaultValue": null,
37520
+ "description": "Size of the gauge",
37521
+ "name": "size",
37522
+ "parent": {
37523
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37524
+ "name": "SegmentedGaugeProps"
37525
+ },
37526
+ "declarations": [
37527
+ {
37528
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37529
+ "name": "SegmentedGaugeProps"
37530
+ }
37531
+ ],
37532
+ "required": false,
37533
+ "type": {
37534
+ "name": "enum",
37535
+ "raw": "\"sm\" | \"md\"",
37536
+ "value": [
37537
+ {
37538
+ "value": "\"sm\""
37539
+ },
37540
+ {
37541
+ "value": "\"md\""
37542
+ }
37543
+ ]
37544
+ }
37545
+ },
37546
+ "intent": {
37547
+ "defaultValue": null,
37548
+ "description": "Intent of the gauge - predefined color intent",
37549
+ "name": "intent",
37550
+ "parent": {
37551
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37552
+ "name": "SegmentedGaugeProps"
37553
+ },
37554
+ "declarations": [
37555
+ {
37556
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37557
+ "name": "SegmentedGaugeProps"
37558
+ }
37559
+ ],
37560
+ "required": false,
37561
+ "type": {
37562
+ "name": "enum",
37563
+ "raw": "\"main\" | \"alert\" | \"support\" | \"accent\" | \"success\" | \"danger\" | \"info\" | \"neutral\" | \"basic\"",
37564
+ "value": [
37565
+ {
37566
+ "value": "\"main\""
37567
+ },
37568
+ {
37569
+ "value": "\"alert\""
37570
+ },
37571
+ {
37572
+ "value": "\"support\""
37573
+ },
37574
+ {
37575
+ "value": "\"accent\""
37576
+ },
37577
+ {
37578
+ "value": "\"success\""
37579
+ },
37580
+ {
37581
+ "value": "\"danger\""
37582
+ },
37583
+ {
37584
+ "value": "\"info\""
37585
+ },
37586
+ {
37587
+ "value": "\"neutral\""
37588
+ },
37589
+ {
37590
+ "value": "\"basic\""
37591
+ }
37592
+ ]
37593
+ }
37594
+ },
37595
+ "customColor": {
37596
+ "defaultValue": null,
37597
+ "description": "Custom color for the gauge (hex, CSS variable, etc.)",
37598
+ "name": "customColor",
37599
+ "parent": {
37600
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37601
+ "name": "SegmentedGaugeProps"
37602
+ },
37603
+ "declarations": [
37604
+ {
37605
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37606
+ "name": "SegmentedGaugeProps"
37607
+ }
37608
+ ],
37609
+ "required": false,
37610
+ "type": {
37611
+ "name": "string"
37612
+ }
37613
+ },
37614
+ "id": {
37615
+ "defaultValue": null,
37616
+ "description": "ID of the gauge element",
37617
+ "name": "id",
37618
+ "parent": {
37619
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37620
+ "name": "SegmentedGaugeProps"
37621
+ },
37622
+ "declarations": [
37623
+ {
37624
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37625
+ "name": "SegmentedGaugeProps"
37626
+ }
37627
+ ],
37628
+ "required": false,
37629
+ "type": {
37630
+ "name": "string"
37631
+ }
37632
+ },
37633
+ "aria-label": {
37634
+ "defaultValue": null,
37635
+ "description": "Accessible label for the gauge (required if no id is provided)",
37636
+ "name": "aria-label",
37637
+ "parent": {
37638
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37639
+ "name": "SegmentedGaugeProps"
37640
+ },
37641
+ "declarations": [
37642
+ {
37643
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37644
+ "name": "SegmentedGaugeProps"
37645
+ }
37646
+ ],
37647
+ "required": false,
37648
+ "type": {
37649
+ "name": "string"
37650
+ }
37651
+ },
37652
+ "className": {
37653
+ "defaultValue": null,
37654
+ "description": "Additional CSS classes",
37655
+ "name": "className",
37656
+ "parent": {
37657
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37658
+ "name": "SegmentedGaugeProps"
37659
+ },
37660
+ "declarations": [
37661
+ {
37662
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37663
+ "name": "SegmentedGaugeProps"
37664
+ }
37665
+ ],
37666
+ "required": false,
37667
+ "type": {
37668
+ "name": "string"
37669
+ }
37670
+ },
37671
+ "ref": {
37672
+ "defaultValue": null,
37673
+ "description": "Ref to the root element",
37674
+ "name": "ref",
37675
+ "parent": {
37676
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37677
+ "name": "SegmentedGaugeProps"
37678
+ },
37679
+ "declarations": [
37680
+ {
37681
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37682
+ "name": "SegmentedGaugeProps"
37683
+ }
37684
+ ],
37685
+ "required": false,
37686
+ "type": {
37687
+ "name": "Ref<HTMLDivElement>"
37688
+ }
37689
+ },
37690
+ "children": {
37691
+ "defaultValue": null,
37692
+ "description": "Children render prop for custom rendering",
37693
+ "name": "children",
37694
+ "parent": {
37695
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37696
+ "name": "SegmentedGaugeProps"
37697
+ },
37698
+ "declarations": [
37699
+ {
37700
+ "fileName": "src/segmented-gauge/SegmentedGauge.tsx",
37701
+ "name": "SegmentedGaugeProps"
37702
+ }
37703
+ ],
37704
+ "required": false,
37705
+ "type": {
37706
+ "name": "(props: { segments: { isActive: boolean; isCurrent: boolean; }[]; currentIndex: number; }) => ReactNode"
37707
+ }
37708
+ }
37709
+ }
37710
+ },
37711
+ "SegmentedGaugeContext": {
37712
+ "tags": {},
37713
+ "description": "",
37714
+ "displayName": "SegmentedGaugeContext",
37715
+ "methods": [],
37716
+ "props": {}
37717
+ },
37718
+ "SegmentedGauge.Label": {
37719
+ "tags": {},
37720
+ "description": "",
37721
+ "displayName": "SegmentedGauge.Label",
37722
+ "methods": [],
37723
+ "props": {
37724
+ "ref": {
37725
+ "defaultValue": null,
37726
+ "description": "Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).",
37727
+ "name": "ref",
37728
+ "parent": {
37729
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeLabel.tsx",
37730
+ "name": "SegmentedGaugeLabelProps"
37731
+ },
37732
+ "declarations": [
37733
+ {
37734
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeLabel.tsx",
37735
+ "name": "SegmentedGaugeLabelProps"
37736
+ }
37737
+ ],
37738
+ "required": false,
37739
+ "type": {
37740
+ "name": "Ref<HTMLSpanElement>"
37741
+ }
37742
+ },
37743
+ "id": {
37744
+ "defaultValue": null,
37745
+ "description": "",
37746
+ "name": "id",
37747
+ "parent": {
37748
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeLabel.tsx",
37749
+ "name": "SegmentedGaugeLabelProps"
37750
+ },
37751
+ "declarations": [
37752
+ {
37753
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeLabel.tsx",
37754
+ "name": "SegmentedGaugeLabelProps"
37755
+ }
37756
+ ],
37757
+ "required": false,
37758
+ "type": {
37759
+ "name": "string"
37760
+ }
37761
+ }
37762
+ }
37763
+ },
37764
+ "SegmentedGauge.Segment": {
37765
+ "tags": {},
37766
+ "description": "",
37767
+ "displayName": "SegmentedGauge.Segment",
37768
+ "methods": [],
37769
+ "props": {
37770
+ "index": {
37771
+ "defaultValue": {
37772
+ "value": 0
37773
+ },
37774
+ "description": "Index of this segment (0-based)",
37775
+ "name": "index",
37776
+ "parent": {
37777
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeSegment.tsx",
37778
+ "name": "SegmentedGaugeSegmentProps"
37779
+ },
37780
+ "declarations": [
37781
+ {
37782
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeSegment.tsx",
37783
+ "name": "SegmentedGaugeSegmentProps"
37784
+ }
37785
+ ],
37786
+ "required": false,
37787
+ "type": {
37788
+ "name": "number"
37789
+ }
37790
+ },
37791
+ "ref": {
37792
+ "defaultValue": null,
37793
+ "description": "Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).",
37794
+ "name": "ref",
37795
+ "parent": {
37796
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeSegment.tsx",
37797
+ "name": "SegmentedGaugeSegmentProps"
37798
+ },
37799
+ "declarations": [
37800
+ {
37801
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeSegment.tsx",
37802
+ "name": "SegmentedGaugeSegmentProps"
37803
+ }
37804
+ ],
37805
+ "required": false,
37806
+ "type": {
37807
+ "name": "Ref<HTMLDivElement>"
37808
+ }
37809
+ }
37810
+ }
37811
+ },
37812
+ "SegmentedGauge.Track": {
37813
+ "tags": {},
37814
+ "description": "",
37815
+ "displayName": "SegmentedGauge.Track",
37816
+ "methods": [],
37817
+ "props": {
37818
+ "ref": {
37819
+ "defaultValue": null,
37820
+ "description": "Allows getting a ref to the component instance.\nOnce the component unmounts, React will set `ref.current` to `null`\n(or call the ref with `null` if you passed a callback ref).",
37821
+ "name": "ref",
37822
+ "parent": {
37823
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeTrack.tsx",
37824
+ "name": "SegmentedGaugeTrackProps"
37825
+ },
37826
+ "declarations": [
37827
+ {
37828
+ "fileName": "components/src/segmented-gauge/SegmentedGaugeTrack.tsx",
37829
+ "name": "SegmentedGaugeTrackProps"
37830
+ }
37831
+ ],
37832
+ "required": false,
37833
+ "type": {
37834
+ "name": "Ref<HTMLDivElement>"
37835
+ }
37836
+ }
37837
+ }
37838
+ },
37436
37839
  "Select": {
37437
37840
  "tags": {},
37438
37841
  "description": "",
@@ -0,0 +1,100 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Ref, ComponentProps } from 'react';
3
+
4
+ interface SegmentedGaugeProps {
5
+ /**
6
+ * The current value of the gauge
7
+ */
8
+ value?: number;
9
+ /**
10
+ * Minimum value of the gauge (aria-valuemin)
11
+ */
12
+ min: number;
13
+ /**
14
+ * Maximum value of the gauge (aria-valuemax)
15
+ */
16
+ max: number;
17
+ /**
18
+ * Description text for the gauge (aria-describedby)
19
+ */
20
+ description?: string;
21
+ /**
22
+ * Size of the gauge
23
+ */
24
+ size?: 'sm' | 'md';
25
+ /**
26
+ * Intent of the gauge - predefined color intent
27
+ */
28
+ intent?: 'main' | 'support' | 'basic' | 'accent' | 'success' | 'alert' | 'danger' | 'info' | 'neutral';
29
+ /**
30
+ * Custom color for the gauge (hex, CSS variable, etc.)
31
+ */
32
+ customColor?: string;
33
+ /**
34
+ * ID of the gauge element
35
+ */
36
+ id?: string;
37
+ /**
38
+ * Accessible label for the gauge (required if no id is provided)
39
+ */
40
+ 'aria-label'?: string;
41
+ /**
42
+ * Additional CSS classes
43
+ */
44
+ className?: string;
45
+ /**
46
+ * Ref to the root element
47
+ */
48
+ ref?: Ref<HTMLDivElement>;
49
+ /**
50
+ * Children render prop for custom rendering
51
+ */
52
+ children?: (props: {
53
+ segments: {
54
+ isActive: boolean;
55
+ isCurrent: boolean;
56
+ }[];
57
+ currentIndex: number;
58
+ }) => React.ReactNode;
59
+ }
60
+ declare const SegmentedGauge$1: {
61
+ ({ value, min, max, description, size, intent, customColor, id, "aria-label": ariaLabel, className, ref, children, ...props }: SegmentedGaugeProps): react_jsx_runtime.JSX.Element;
62
+ displayName: string;
63
+ };
64
+
65
+ interface SegmentedGaugeLabelProps extends ComponentProps<'span'> {
66
+ ref?: Ref<HTMLSpanElement>;
67
+ id?: string;
68
+ }
69
+ declare const SegmentedGaugeLabel: {
70
+ ({ className, children, ref, id, ...props }: SegmentedGaugeLabelProps): react_jsx_runtime.JSX.Element;
71
+ displayName: string;
72
+ };
73
+
74
+ interface SegmentedGaugeSegmentProps extends ComponentProps<'div'> {
75
+ /**
76
+ * Index of this segment (0-based)
77
+ */
78
+ index?: number;
79
+ ref?: Ref<HTMLDivElement>;
80
+ }
81
+ declare const SegmentedGaugeSegment: {
82
+ ({ index, className, children, ref, ...props }: SegmentedGaugeSegmentProps): react_jsx_runtime.JSX.Element;
83
+ displayName: string;
84
+ };
85
+
86
+ interface SegmentedGaugeTrackProps extends ComponentProps<'div'> {
87
+ ref?: Ref<HTMLDivElement>;
88
+ }
89
+ declare const SegmentedGaugeTrack: {
90
+ ({ className, children, ref, ...props }: SegmentedGaugeTrackProps): react_jsx_runtime.JSX.Element;
91
+ displayName: string;
92
+ };
93
+
94
+ declare const SegmentedGauge: typeof SegmentedGauge$1 & {
95
+ Track: typeof SegmentedGaugeTrack;
96
+ Segment: typeof SegmentedGaugeSegment;
97
+ Label: typeof SegmentedGaugeLabel;
98
+ };
99
+
100
+ export { SegmentedGauge, type SegmentedGaugeLabelProps, type SegmentedGaugeProps, type SegmentedGaugeSegmentProps, type SegmentedGaugeTrackProps };
@@ -0,0 +1,100 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Ref, ComponentProps } from 'react';
3
+
4
+ interface SegmentedGaugeProps {
5
+ /**
6
+ * The current value of the gauge
7
+ */
8
+ value?: number;
9
+ /**
10
+ * Minimum value of the gauge (aria-valuemin)
11
+ */
12
+ min: number;
13
+ /**
14
+ * Maximum value of the gauge (aria-valuemax)
15
+ */
16
+ max: number;
17
+ /**
18
+ * Description text for the gauge (aria-describedby)
19
+ */
20
+ description?: string;
21
+ /**
22
+ * Size of the gauge
23
+ */
24
+ size?: 'sm' | 'md';
25
+ /**
26
+ * Intent of the gauge - predefined color intent
27
+ */
28
+ intent?: 'main' | 'support' | 'basic' | 'accent' | 'success' | 'alert' | 'danger' | 'info' | 'neutral';
29
+ /**
30
+ * Custom color for the gauge (hex, CSS variable, etc.)
31
+ */
32
+ customColor?: string;
33
+ /**
34
+ * ID of the gauge element
35
+ */
36
+ id?: string;
37
+ /**
38
+ * Accessible label for the gauge (required if no id is provided)
39
+ */
40
+ 'aria-label'?: string;
41
+ /**
42
+ * Additional CSS classes
43
+ */
44
+ className?: string;
45
+ /**
46
+ * Ref to the root element
47
+ */
48
+ ref?: Ref<HTMLDivElement>;
49
+ /**
50
+ * Children render prop for custom rendering
51
+ */
52
+ children?: (props: {
53
+ segments: {
54
+ isActive: boolean;
55
+ isCurrent: boolean;
56
+ }[];
57
+ currentIndex: number;
58
+ }) => React.ReactNode;
59
+ }
60
+ declare const SegmentedGauge$1: {
61
+ ({ value, min, max, description, size, intent, customColor, id, "aria-label": ariaLabel, className, ref, children, ...props }: SegmentedGaugeProps): react_jsx_runtime.JSX.Element;
62
+ displayName: string;
63
+ };
64
+
65
+ interface SegmentedGaugeLabelProps extends ComponentProps<'span'> {
66
+ ref?: Ref<HTMLSpanElement>;
67
+ id?: string;
68
+ }
69
+ declare const SegmentedGaugeLabel: {
70
+ ({ className, children, ref, id, ...props }: SegmentedGaugeLabelProps): react_jsx_runtime.JSX.Element;
71
+ displayName: string;
72
+ };
73
+
74
+ interface SegmentedGaugeSegmentProps extends ComponentProps<'div'> {
75
+ /**
76
+ * Index of this segment (0-based)
77
+ */
78
+ index?: number;
79
+ ref?: Ref<HTMLDivElement>;
80
+ }
81
+ declare const SegmentedGaugeSegment: {
82
+ ({ index, className, children, ref, ...props }: SegmentedGaugeSegmentProps): react_jsx_runtime.JSX.Element;
83
+ displayName: string;
84
+ };
85
+
86
+ interface SegmentedGaugeTrackProps extends ComponentProps<'div'> {
87
+ ref?: Ref<HTMLDivElement>;
88
+ }
89
+ declare const SegmentedGaugeTrack: {
90
+ ({ className, children, ref, ...props }: SegmentedGaugeTrackProps): react_jsx_runtime.JSX.Element;
91
+ displayName: string;
92
+ };
93
+
94
+ declare const SegmentedGauge: typeof SegmentedGauge$1 & {
95
+ Track: typeof SegmentedGaugeTrack;
96
+ Segment: typeof SegmentedGaugeSegment;
97
+ Label: typeof SegmentedGaugeLabel;
98
+ };
99
+
100
+ export { SegmentedGauge, type SegmentedGaugeLabelProps, type SegmentedGaugeProps, type SegmentedGaugeSegmentProps, type SegmentedGaugeTrackProps };
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/segmented-gauge/index.ts
21
+ var segmented_gauge_exports = {};
22
+ __export(segmented_gauge_exports, {
23
+ SegmentedGauge: () => SegmentedGauge2
24
+ });
25
+ module.exports = __toCommonJS(segmented_gauge_exports);
26
+
27
+ // src/segmented-gauge/SegmentedGauge.tsx
28
+ var import_class_variance_authority4 = require("class-variance-authority");
29
+ var import_react3 = require("react");
30
+
31
+ // src/segmented-gauge/SegmentedGaugeContext.tsx
32
+ var import_react = require("react");
33
+ var SegmentedGaugeContext = (0, import_react.createContext)(null);
34
+ var useSegmentedGaugeContext = () => {
35
+ const context = (0, import_react.useContext)(SegmentedGaugeContext);
36
+ if (!context) {
37
+ throw new Error("useSegmentedGaugeContext must be used within a SegmentedGauge provider");
38
+ }
39
+ return context;
40
+ };
41
+
42
+ // src/segmented-gauge/SegmentedGaugeLabel.tsx
43
+ var import_class_variance_authority = require("class-variance-authority");
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var SegmentedGaugeLabel = ({
46
+ className,
47
+ children,
48
+ ref,
49
+ id,
50
+ ...props
51
+ }) => {
52
+ const { labelId } = useSegmentedGaugeContext();
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
+ "span",
55
+ {
56
+ "data-spark-component": "segmented-gauge-label",
57
+ "data-testid": "segmented-gauge-label",
58
+ ref,
59
+ id: id || labelId,
60
+ className: (0, import_class_variance_authority.cx)("default:text-on-surface default:text-body-2", className),
61
+ ...props,
62
+ children
63
+ }
64
+ );
65
+ };
66
+ SegmentedGaugeLabel.displayName = "SegmentedGauge.Label";
67
+
68
+ // src/segmented-gauge/SegmentedGaugeSegment.tsx
69
+ var import_class_variance_authority2 = require("class-variance-authority");
70
+ var import_react2 = require("react");
71
+ var import_jsx_runtime2 = require("react/jsx-runtime");
72
+ var SegmentedGaugeSegment = ({
73
+ index = 0,
74
+ className,
75
+ children,
76
+ ref,
77
+ ...props
78
+ }) => {
79
+ const { size, intent, customColor, currentIndex } = useSegmentedGaugeContext();
80
+ const isActive = currentIndex !== -1 && index <= currentIndex;
81
+ const isCurrent = currentIndex !== -1 && index === currentIndex;
82
+ const gaugeColor = (0, import_react2.useMemo)(() => {
83
+ if (customColor) {
84
+ return customColor;
85
+ }
86
+ switch (intent) {
87
+ case "main":
88
+ return "var(--color-main)";
89
+ case "support":
90
+ return "var(--color-support)";
91
+ case "basic":
92
+ return "var(--color-basic)";
93
+ case "accent":
94
+ return "var(--color-accent)";
95
+ case "success":
96
+ return "var(--color-success)";
97
+ case "alert":
98
+ return "var(--color-alert)";
99
+ case "danger":
100
+ return "var(--color-error)";
101
+ case "info":
102
+ return "var(--color-info)";
103
+ case "neutral":
104
+ return "var(--color-neutral)";
105
+ default:
106
+ return "var(--color-neutral)";
107
+ }
108
+ }, [intent, customColor]);
109
+ const segmentClasses = (0, import_class_variance_authority2.cx)(
110
+ "border-outline relative rounded-full",
111
+ {
112
+ "h-sz-8 w-sz-24": size === "sm",
113
+ "h-sz-12 w-sz-36": size === "md",
114
+ "default:bg-[var(--gauge-color)]": isActive,
115
+ "border-sm bg-surface": !isActive
116
+ },
117
+ className
118
+ );
119
+ const indicatorClasses = (0, import_class_variance_authority2.cx)(
120
+ "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",
121
+ "default:bg-surface default:rounded-full",
122
+ "border-[var(--gauge-color)]",
123
+ {
124
+ "size-sz-12 border-md": size === "sm",
125
+ "size-sz-20 border-lg": size === "md"
126
+ }
127
+ );
128
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
129
+ "div",
130
+ {
131
+ "data-spark-component": "segmented-gauge-segment",
132
+ "data-testid": "segmented-gauge-segment",
133
+ "data-active": isActive,
134
+ "data-current": isCurrent,
135
+ ref,
136
+ style: {
137
+ "--gauge-color": gaugeColor
138
+ },
139
+ className: segmentClasses,
140
+ ...props,
141
+ children: [
142
+ children,
143
+ isCurrent && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: indicatorClasses, "aria-hidden": "true" })
144
+ ]
145
+ }
146
+ );
147
+ };
148
+ SegmentedGaugeSegment.displayName = "SegmentedGauge.Segment";
149
+
150
+ // src/segmented-gauge/SegmentedGaugeTrack.tsx
151
+ var import_class_variance_authority3 = require("class-variance-authority");
152
+ var import_jsx_runtime3 = require("react/jsx-runtime");
153
+ var SegmentedGaugeTrack = ({
154
+ className,
155
+ children,
156
+ ref,
157
+ ...props
158
+ }) => {
159
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
160
+ "div",
161
+ {
162
+ "data-spark-component": "segmented-gauge-track",
163
+ ref,
164
+ className: (0, import_class_variance_authority3.cx)("gap-sm relative flex rounded-full", className),
165
+ ...props,
166
+ children
167
+ }
168
+ );
169
+ };
170
+ SegmentedGaugeTrack.displayName = "SegmentedGauge.Track";
171
+
172
+ // src/segmented-gauge/SegmentedGauge.tsx
173
+ var import_jsx_runtime4 = require("react/jsx-runtime");
174
+ var calculateCurrentIndex = (value, min, max, segments) => {
175
+ if (value == null) {
176
+ return -1;
177
+ }
178
+ const normalizedValue = Math.max(min, Math.min(max, value));
179
+ const range = max - min;
180
+ const segmentSize = range / (segments - 1);
181
+ const rawIndex = (normalizedValue - min) / segmentSize;
182
+ return Math.max(0, Math.min(segments - 1, Math.round(rawIndex)));
183
+ };
184
+ var SegmentedGauge = ({
185
+ value,
186
+ min,
187
+ max,
188
+ description,
189
+ size = "md",
190
+ intent = "neutral",
191
+ customColor,
192
+ id,
193
+ "aria-label": ariaLabel,
194
+ className,
195
+ ref,
196
+ children,
197
+ ...props
198
+ }) => {
199
+ const segments = max - min + 1;
200
+ const currentIndex = (0, import_react3.useMemo)(
201
+ () => calculateCurrentIndex(value, min, max, segments),
202
+ [value, min, max, segments]
203
+ );
204
+ const internalLabelId = (0, import_react3.useId)();
205
+ const generatedId = (0, import_react3.useId)();
206
+ const gaugeId = id || generatedId;
207
+ const segmentsData = (0, import_react3.useMemo)(() => {
208
+ return Array.from({ length: segments }, (_, index) => ({
209
+ isActive: currentIndex !== -1 && index <= currentIndex,
210
+ isCurrent: currentIndex !== -1 && index === currentIndex
211
+ }));
212
+ }, [segments, currentIndex]);
213
+ const contextValue = (0, import_react3.useMemo)(
214
+ () => ({
215
+ value,
216
+ min,
217
+ max,
218
+ segments,
219
+ currentIndex,
220
+ size,
221
+ intent,
222
+ customColor,
223
+ labelId: internalLabelId,
224
+ gaugeId
225
+ }),
226
+ [value, min, max, segments, currentIndex, size, intent, customColor, internalLabelId, gaugeId]
227
+ );
228
+ if (children) {
229
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SegmentedGaugeContext.Provider, { value: contextValue, children: children({
230
+ segments: segmentsData,
231
+ currentIndex
232
+ }) });
233
+ }
234
+ const roleProps = value != null ? {
235
+ role: "meter",
236
+ "aria-valuenow": value,
237
+ "aria-valuemin": min,
238
+ "aria-valuemax": max
239
+ } : {
240
+ role: "status"
241
+ };
242
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SegmentedGaugeContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
243
+ "div",
244
+ {
245
+ id: gaugeId,
246
+ "data-spark-component": "segmented-gauge",
247
+ ref,
248
+ className: (0, import_class_variance_authority4.cx)("gap-md flex items-center", className),
249
+ ...roleProps,
250
+ "aria-labelledby": id ? `${gaugeId}-label` : void 0,
251
+ "aria-label": !id ? ariaLabel : void 0,
252
+ "aria-describedby": internalLabelId,
253
+ ...props,
254
+ children: [
255
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SegmentedGaugeTrack, { children: segmentsData.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SegmentedGaugeSegment, { index }, index)) }),
256
+ description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SegmentedGaugeLabel, { id: internalLabelId, children: description })
257
+ ]
258
+ }
259
+ ) });
260
+ };
261
+ SegmentedGauge.displayName = "SegmentedGauge";
262
+
263
+ // src/segmented-gauge/index.ts
264
+ var SegmentedGauge2 = Object.assign(SegmentedGauge, {
265
+ Track: SegmentedGaugeTrack,
266
+ Segment: SegmentedGaugeSegment,
267
+ Label: SegmentedGaugeLabel
268
+ });
269
+ SegmentedGauge2.displayName = "SegmentedGauge";
270
+ SegmentedGaugeTrack.displayName = "SegmentedGauge.Track";
271
+ SegmentedGaugeSegment.displayName = "SegmentedGauge.Segment";
272
+ SegmentedGaugeLabel.displayName = "SegmentedGauge.Label";
273
+ // Annotate the CommonJS export names for ESM import in node:
274
+ 0 && (module.exports = {
275
+ SegmentedGauge
276
+ });
277
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/segmented-gauge/index.ts","../../src/segmented-gauge/SegmentedGauge.tsx","../../src/segmented-gauge/SegmentedGaugeContext.tsx","../../src/segmented-gauge/SegmentedGaugeLabel.tsx","../../src/segmented-gauge/SegmentedGaugeSegment.tsx","../../src/segmented-gauge/SegmentedGaugeTrack.tsx"],"sourcesContent":["import { SegmentedGauge as Root } from './SegmentedGauge'\nimport { SegmentedGaugeLabel } from './SegmentedGaugeLabel'\nimport { SegmentedGaugeSegment } from './SegmentedGaugeSegment'\nimport { SegmentedGaugeTrack } from './SegmentedGaugeTrack'\n\nexport const SegmentedGauge: typeof Root & {\n Track: typeof SegmentedGaugeTrack\n Segment: typeof SegmentedGaugeSegment\n Label: typeof SegmentedGaugeLabel\n} = Object.assign(Root, {\n Track: SegmentedGaugeTrack,\n Segment: SegmentedGaugeSegment,\n Label: SegmentedGaugeLabel,\n})\n\nSegmentedGauge.displayName = 'SegmentedGauge'\nSegmentedGaugeTrack.displayName = 'SegmentedGauge.Track'\nSegmentedGaugeSegment.displayName = 'SegmentedGauge.Segment'\nSegmentedGaugeLabel.displayName = 'SegmentedGauge.Label'\n\nexport { type SegmentedGaugeProps } from './SegmentedGauge'\nexport { type SegmentedGaugeTrackProps } from './SegmentedGaugeTrack'\nexport { type SegmentedGaugeSegmentProps } from './SegmentedGaugeSegment'\nexport { type SegmentedGaugeLabelProps } from './SegmentedGaugeLabel'\n","import { cx } from 'class-variance-authority'\nimport { Ref, useId, useMemo } from 'react'\n\nimport { SegmentedGaugeContext } from './SegmentedGaugeContext'\nimport { SegmentedGaugeLabel } from './SegmentedGaugeLabel'\nimport { SegmentedGaugeSegment } from './SegmentedGaugeSegment'\nimport { SegmentedGaugeTrack } from './SegmentedGaugeTrack'\n\nconst calculateCurrentIndex = (\n value: number | undefined,\n min: number,\n max: number,\n segments: number\n) => {\n // If value is undefined or null, no segment is active\n if (value == null) {\n return -1\n }\n const normalizedValue = Math.max(min, Math.min(max, value))\n const range = max - min\n const segmentSize = range / (segments - 1)\n const rawIndex = (normalizedValue - min) / segmentSize\n\n // Clamp the index to valid range\n return Math.max(0, Math.min(segments - 1, Math.round(rawIndex)))\n}\n\nexport interface SegmentedGaugeProps {\n /**\n * The current value of the gauge\n */\n value?: number\n /**\n * Minimum value of the gauge (aria-valuemin)\n */\n min: number\n /**\n * Maximum value of the gauge (aria-valuemax)\n */\n max: number\n /**\n * Description text for the gauge (aria-describedby)\n */\n description?: string\n /**\n * Size of the gauge\n */\n size?: 'sm' | 'md'\n /**\n * Intent of the gauge - predefined color intent\n */\n intent?:\n | 'main'\n | 'support'\n | 'basic'\n | 'accent'\n | 'success'\n | 'alert'\n | 'danger'\n | 'info'\n | 'neutral'\n /**\n * Custom color for the gauge (hex, CSS variable, etc.)\n */\n customColor?: string\n /**\n * ID of the gauge element\n */\n id?: string\n /**\n * Accessible label for the gauge (required if no id is provided)\n */\n 'aria-label'?: string\n /**\n * Additional CSS classes\n */\n className?: string\n /**\n * Ref to the root element\n */\n ref?: Ref<HTMLDivElement>\n /**\n * Children render prop for custom rendering\n */\n children?: (props: {\n segments: {\n isActive: boolean\n isCurrent: boolean\n }[]\n currentIndex: number\n }) => React.ReactNode\n}\n\nexport const SegmentedGauge = ({\n value,\n min,\n max,\n description,\n size = 'md',\n intent = 'neutral',\n customColor,\n id,\n 'aria-label': ariaLabel,\n className,\n ref,\n children,\n ...props\n}: SegmentedGaugeProps) => {\n // Calculate segments from min and max\n const segments = max - min + 1\n const currentIndex = useMemo(\n () => calculateCurrentIndex(value, min, max, segments),\n [value, min, max, segments]\n )\n\n // Generate unique IDs\n const internalLabelId = useId()\n const generatedId = useId()\n // Use provided id or generated one for the gauge element\n const gaugeId = id || generatedId\n\n const segmentsData = useMemo(() => {\n return Array.from({ length: segments }, (_, index) => ({\n isActive: currentIndex !== -1 && index <= currentIndex,\n isCurrent: currentIndex !== -1 && index === currentIndex,\n }))\n }, [segments, currentIndex])\n\n const contextValue = useMemo(\n () => ({\n value,\n min,\n max,\n segments,\n currentIndex,\n size,\n intent,\n customColor,\n labelId: internalLabelId,\n gaugeId,\n }),\n [value, min, max, segments, currentIndex, size, intent, customColor, internalLabelId, gaugeId]\n )\n\n // If children is provided, use render prop pattern\n if (children) {\n return (\n <SegmentedGaugeContext.Provider value={contextValue}>\n {children({\n segments: segmentsData,\n currentIndex,\n })}\n </SegmentedGaugeContext.Provider>\n )\n }\n\n /**\n * A `meter` role MUST have a value. If the value is not available, the component uses a `status` role instead.\n */\n const roleProps =\n value != null\n ? {\n role: 'meter',\n 'aria-valuenow': value,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n }\n : {\n role: 'status',\n }\n\n // Default rendering\n return (\n <SegmentedGaugeContext.Provider value={contextValue}>\n <div\n id={gaugeId}\n data-spark-component=\"segmented-gauge\"\n ref={ref}\n className={cx('gap-md flex items-center', className)}\n {...roleProps}\n aria-labelledby={id ? `${gaugeId}-label` : undefined}\n aria-label={!id ? ariaLabel : undefined}\n aria-describedby={internalLabelId}\n {...props}\n >\n <SegmentedGaugeTrack>\n {segmentsData.map((_, index) => (\n <SegmentedGaugeSegment key={index} index={index} />\n ))}\n </SegmentedGaugeTrack>\n\n {description && (\n <SegmentedGaugeLabel id={internalLabelId}>{description}</SegmentedGaugeLabel>\n )}\n </div>\n </SegmentedGaugeContext.Provider>\n )\n}\n\nSegmentedGauge.displayName = 'SegmentedGauge'\n","import { createContext, useContext } from 'react'\n\nexport interface SegmentedGaugeContextValue {\n value?: number\n min: number\n max: number\n segments: number\n currentIndex: number\n size: 'sm' | 'md'\n intent:\n | 'main'\n | 'support'\n | 'basic'\n | 'accent'\n | 'success'\n | 'alert'\n | 'danger'\n | 'info'\n | 'neutral'\n customColor?: string\n labelId: string\n gaugeId: string\n}\n\nexport const SegmentedGaugeContext = createContext<SegmentedGaugeContextValue | null>(null)\n\nexport const useSegmentedGaugeContext = () => {\n const context = useContext(SegmentedGaugeContext)\n\n if (!context) {\n throw new Error('useSegmentedGaugeContext must be used within a SegmentedGauge provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useSegmentedGaugeContext } from './SegmentedGaugeContext'\n\nexport interface SegmentedGaugeLabelProps extends ComponentProps<'span'> {\n ref?: Ref<HTMLSpanElement>\n id?: string\n}\n\nexport const SegmentedGaugeLabel = ({\n className,\n children,\n ref,\n id,\n ...props\n}: SegmentedGaugeLabelProps) => {\n const { labelId } = useSegmentedGaugeContext()\n\n return (\n <span\n data-spark-component=\"segmented-gauge-label\"\n data-testid=\"segmented-gauge-label\"\n ref={ref}\n id={id || labelId}\n className={cx('default:text-on-surface default:text-body-2', className)}\n {...props}\n >\n {children}\n </span>\n )\n}\n\nSegmentedGaugeLabel.displayName = 'SegmentedGauge.Label'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useMemo } from 'react'\n\nimport { useSegmentedGaugeContext } from './SegmentedGaugeContext'\n\nexport interface SegmentedGaugeSegmentProps extends ComponentProps<'div'> {\n /**\n * Index of this segment (0-based)\n */\n index?: number\n ref?: Ref<HTMLDivElement>\n}\n\nexport const SegmentedGaugeSegment = ({\n index = 0,\n className,\n children,\n ref,\n ...props\n}: SegmentedGaugeSegmentProps) => {\n const { size, intent, customColor, currentIndex } = useSegmentedGaugeContext()\n\n // Calculate isActive and isCurrent from context and index\n const isActive = currentIndex !== -1 && index <= currentIndex\n const isCurrent = currentIndex !== -1 && index === currentIndex\n\n const gaugeColor = useMemo(() => {\n // If customColor is provided, use it\n if (customColor) {\n return customColor\n }\n\n // Handle predefined intents\n switch (intent) {\n case 'main':\n return 'var(--color-main)'\n case 'support':\n return 'var(--color-support)'\n case 'basic':\n return 'var(--color-basic)'\n case 'accent':\n return 'var(--color-accent)'\n case 'success':\n return 'var(--color-success)'\n case 'alert':\n return 'var(--color-alert)'\n case 'danger':\n return 'var(--color-error)'\n case 'info':\n return 'var(--color-info)'\n case 'neutral':\n return 'var(--color-neutral)'\n default:\n return 'var(--color-neutral)'\n }\n }, [intent, customColor])\n\n const segmentClasses = cx(\n 'border-outline relative rounded-full',\n {\n 'h-sz-8 w-sz-24': size === 'sm',\n 'h-sz-12 w-sz-36': size === 'md',\n 'default:bg-[var(--gauge-color)]': isActive,\n 'border-sm bg-surface': !isActive,\n },\n className\n )\n\n const indicatorClasses = cx(\n 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',\n 'default:bg-surface default:rounded-full',\n 'border-[var(--gauge-color)]',\n {\n 'size-sz-12 border-md': size === 'sm',\n 'size-sz-20 border-lg': size === 'md',\n }\n )\n\n return (\n <div\n data-spark-component=\"segmented-gauge-segment\"\n data-testid=\"segmented-gauge-segment\"\n data-active={isActive}\n data-current={isCurrent}\n ref={ref}\n style={\n {\n '--gauge-color': gaugeColor,\n } as React.CSSProperties\n }\n className={segmentClasses}\n {...props}\n >\n {children}\n {isCurrent && <div className={indicatorClasses} aria-hidden=\"true\" />}\n </div>\n )\n}\n\nSegmentedGaugeSegment.displayName = 'SegmentedGauge.Segment'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface SegmentedGaugeTrackProps extends ComponentProps<'div'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const SegmentedGaugeTrack = ({\n className,\n children,\n ref,\n ...props\n}: SegmentedGaugeTrackProps) => {\n return (\n <div\n data-spark-component=\"segmented-gauge-track\"\n ref={ref}\n className={cx('gap-sm relative flex rounded-full', className)}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nSegmentedGaugeTrack.displayName = 'SegmentedGauge.Track'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAAA;AAAA;AAAA;;;ACAA,IAAAC,mCAAmB;AACnB,IAAAC,gBAAoC;;;ACDpC,mBAA0C;AAwBnC,IAAM,4BAAwB,4BAAiD,IAAI;AAEnF,IAAM,2BAA2B,MAAM;AAC5C,QAAM,cAAU,yBAAW,qBAAqB;AAEhD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,SAAO;AACT;;;AClCA,sCAAmB;AAoBf;AA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ACrC;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ,wBAAqB;AAAA,MACrB;AAAA,MACA,eAAW,qCAAG,4BAA4B,SAAS;AAAA,MAClD,GAAG;AAAA,MACJ,mBAAiB,KAAK,GAAG,OAAO,WAAW;AAAA,MAC3C,cAAY,CAAC,KAAK,YAAY;AAAA,MAC9B,oBAAkB;AAAA,MACjB,GAAG;AAAA,MAEJ;AAAA,qDAAC,uBACE,uBAAa,IAAI,CAAC,GAAG,UACpB,6CAAC,yBAAkC,SAAP,KAAqB,CAClD,GACH;AAAA,QAEC,eACC,6CAAC,uBAAoB,IAAI,iBAAkB,uBAAY;AAAA;AAAA;AAAA,EAE3D,GACF;AAEJ;AAEA,eAAe,cAAc;;;ADlMtB,IAAMC,kBAIT,OAAO,OAAO,gBAAM;AAAA,EACtB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEDA,gBAAe,cAAc;AAC7B,oBAAoB,cAAc;AAClC,sBAAsB,cAAc;AACpC,oBAAoB,cAAc;","names":["SegmentedGauge","import_class_variance_authority","import_react","import_class_variance_authority","import_react","import_jsx_runtime","import_class_variance_authority","import_jsx_runtime","import_jsx_runtime","SegmentedGauge"]}
@@ -0,0 +1,250 @@
1
+ // src/segmented-gauge/SegmentedGauge.tsx
2
+ import { cx as cx4 } from "class-variance-authority";
3
+ import { useId, useMemo as useMemo2 } from "react";
4
+
5
+ // src/segmented-gauge/SegmentedGaugeContext.tsx
6
+ import { createContext, useContext } from "react";
7
+ var SegmentedGaugeContext = createContext(null);
8
+ var useSegmentedGaugeContext = () => {
9
+ const context = useContext(SegmentedGaugeContext);
10
+ if (!context) {
11
+ throw new Error("useSegmentedGaugeContext must be used within a SegmentedGauge provider");
12
+ }
13
+ return context;
14
+ };
15
+
16
+ // src/segmented-gauge/SegmentedGaugeLabel.tsx
17
+ import { cx } from "class-variance-authority";
18
+ import { jsx } from "react/jsx-runtime";
19
+ var SegmentedGaugeLabel = ({
20
+ className,
21
+ children,
22
+ ref,
23
+ id,
24
+ ...props
25
+ }) => {
26
+ const { labelId } = useSegmentedGaugeContext();
27
+ return /* @__PURE__ */ jsx(
28
+ "span",
29
+ {
30
+ "data-spark-component": "segmented-gauge-label",
31
+ "data-testid": "segmented-gauge-label",
32
+ ref,
33
+ id: id || labelId,
34
+ className: cx("default:text-on-surface default:text-body-2", className),
35
+ ...props,
36
+ children
37
+ }
38
+ );
39
+ };
40
+ SegmentedGaugeLabel.displayName = "SegmentedGauge.Label";
41
+
42
+ // src/segmented-gauge/SegmentedGaugeSegment.tsx
43
+ import { cx as cx2 } from "class-variance-authority";
44
+ import { useMemo } from "react";
45
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
46
+ var SegmentedGaugeSegment = ({
47
+ index = 0,
48
+ className,
49
+ children,
50
+ ref,
51
+ ...props
52
+ }) => {
53
+ const { size, intent, customColor, currentIndex } = useSegmentedGaugeContext();
54
+ const isActive = currentIndex !== -1 && index <= currentIndex;
55
+ const isCurrent = currentIndex !== -1 && index === currentIndex;
56
+ const gaugeColor = useMemo(() => {
57
+ if (customColor) {
58
+ return customColor;
59
+ }
60
+ switch (intent) {
61
+ case "main":
62
+ return "var(--color-main)";
63
+ case "support":
64
+ return "var(--color-support)";
65
+ case "basic":
66
+ return "var(--color-basic)";
67
+ case "accent":
68
+ return "var(--color-accent)";
69
+ case "success":
70
+ return "var(--color-success)";
71
+ case "alert":
72
+ return "var(--color-alert)";
73
+ case "danger":
74
+ return "var(--color-error)";
75
+ case "info":
76
+ return "var(--color-info)";
77
+ case "neutral":
78
+ return "var(--color-neutral)";
79
+ default:
80
+ return "var(--color-neutral)";
81
+ }
82
+ }, [intent, customColor]);
83
+ const segmentClasses = cx2(
84
+ "border-outline relative rounded-full",
85
+ {
86
+ "h-sz-8 w-sz-24": size === "sm",
87
+ "h-sz-12 w-sz-36": size === "md",
88
+ "default:bg-[var(--gauge-color)]": isActive,
89
+ "border-sm bg-surface": !isActive
90
+ },
91
+ className
92
+ );
93
+ const indicatorClasses = cx2(
94
+ "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",
95
+ "default:bg-surface default:rounded-full",
96
+ "border-[var(--gauge-color)]",
97
+ {
98
+ "size-sz-12 border-md": size === "sm",
99
+ "size-sz-20 border-lg": size === "md"
100
+ }
101
+ );
102
+ return /* @__PURE__ */ jsxs(
103
+ "div",
104
+ {
105
+ "data-spark-component": "segmented-gauge-segment",
106
+ "data-testid": "segmented-gauge-segment",
107
+ "data-active": isActive,
108
+ "data-current": isCurrent,
109
+ ref,
110
+ style: {
111
+ "--gauge-color": gaugeColor
112
+ },
113
+ className: segmentClasses,
114
+ ...props,
115
+ children: [
116
+ children,
117
+ isCurrent && /* @__PURE__ */ jsx2("div", { className: indicatorClasses, "aria-hidden": "true" })
118
+ ]
119
+ }
120
+ );
121
+ };
122
+ SegmentedGaugeSegment.displayName = "SegmentedGauge.Segment";
123
+
124
+ // src/segmented-gauge/SegmentedGaugeTrack.tsx
125
+ import { cx as cx3 } from "class-variance-authority";
126
+ import { jsx as jsx3 } from "react/jsx-runtime";
127
+ var SegmentedGaugeTrack = ({
128
+ className,
129
+ children,
130
+ ref,
131
+ ...props
132
+ }) => {
133
+ return /* @__PURE__ */ jsx3(
134
+ "div",
135
+ {
136
+ "data-spark-component": "segmented-gauge-track",
137
+ ref,
138
+ className: cx3("gap-sm relative flex rounded-full", className),
139
+ ...props,
140
+ children
141
+ }
142
+ );
143
+ };
144
+ SegmentedGaugeTrack.displayName = "SegmentedGauge.Track";
145
+
146
+ // src/segmented-gauge/SegmentedGauge.tsx
147
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
148
+ var calculateCurrentIndex = (value, min, max, segments) => {
149
+ if (value == null) {
150
+ return -1;
151
+ }
152
+ const normalizedValue = Math.max(min, Math.min(max, value));
153
+ const range = max - min;
154
+ const segmentSize = range / (segments - 1);
155
+ const rawIndex = (normalizedValue - min) / segmentSize;
156
+ return Math.max(0, Math.min(segments - 1, Math.round(rawIndex)));
157
+ };
158
+ var SegmentedGauge = ({
159
+ value,
160
+ min,
161
+ max,
162
+ description,
163
+ size = "md",
164
+ intent = "neutral",
165
+ customColor,
166
+ id,
167
+ "aria-label": ariaLabel,
168
+ className,
169
+ ref,
170
+ children,
171
+ ...props
172
+ }) => {
173
+ const segments = max - min + 1;
174
+ const currentIndex = useMemo2(
175
+ () => calculateCurrentIndex(value, min, max, segments),
176
+ [value, min, max, segments]
177
+ );
178
+ const internalLabelId = useId();
179
+ const generatedId = useId();
180
+ const gaugeId = id || generatedId;
181
+ const segmentsData = useMemo2(() => {
182
+ return Array.from({ length: segments }, (_, index) => ({
183
+ isActive: currentIndex !== -1 && index <= currentIndex,
184
+ isCurrent: currentIndex !== -1 && index === currentIndex
185
+ }));
186
+ }, [segments, currentIndex]);
187
+ const contextValue = useMemo2(
188
+ () => ({
189
+ value,
190
+ min,
191
+ max,
192
+ segments,
193
+ currentIndex,
194
+ size,
195
+ intent,
196
+ customColor,
197
+ labelId: internalLabelId,
198
+ gaugeId
199
+ }),
200
+ [value, min, max, segments, currentIndex, size, intent, customColor, internalLabelId, gaugeId]
201
+ );
202
+ if (children) {
203
+ return /* @__PURE__ */ jsx4(SegmentedGaugeContext.Provider, { value: contextValue, children: children({
204
+ segments: segmentsData,
205
+ currentIndex
206
+ }) });
207
+ }
208
+ const roleProps = value != null ? {
209
+ role: "meter",
210
+ "aria-valuenow": value,
211
+ "aria-valuemin": min,
212
+ "aria-valuemax": max
213
+ } : {
214
+ role: "status"
215
+ };
216
+ return /* @__PURE__ */ jsx4(SegmentedGaugeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs2(
217
+ "div",
218
+ {
219
+ id: gaugeId,
220
+ "data-spark-component": "segmented-gauge",
221
+ ref,
222
+ className: cx4("gap-md flex items-center", className),
223
+ ...roleProps,
224
+ "aria-labelledby": id ? `${gaugeId}-label` : void 0,
225
+ "aria-label": !id ? ariaLabel : void 0,
226
+ "aria-describedby": internalLabelId,
227
+ ...props,
228
+ children: [
229
+ /* @__PURE__ */ jsx4(SegmentedGaugeTrack, { children: segmentsData.map((_, index) => /* @__PURE__ */ jsx4(SegmentedGaugeSegment, { index }, index)) }),
230
+ description && /* @__PURE__ */ jsx4(SegmentedGaugeLabel, { id: internalLabelId, children: description })
231
+ ]
232
+ }
233
+ ) });
234
+ };
235
+ SegmentedGauge.displayName = "SegmentedGauge";
236
+
237
+ // src/segmented-gauge/index.ts
238
+ var SegmentedGauge2 = Object.assign(SegmentedGauge, {
239
+ Track: SegmentedGaugeTrack,
240
+ Segment: SegmentedGaugeSegment,
241
+ Label: SegmentedGaugeLabel
242
+ });
243
+ SegmentedGauge2.displayName = "SegmentedGauge";
244
+ SegmentedGaugeTrack.displayName = "SegmentedGauge.Track";
245
+ SegmentedGaugeSegment.displayName = "SegmentedGauge.Segment";
246
+ SegmentedGaugeLabel.displayName = "SegmentedGauge.Label";
247
+ export {
248
+ SegmentedGauge2 as SegmentedGauge
249
+ };
250
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/segmented-gauge/SegmentedGauge.tsx","../../src/segmented-gauge/SegmentedGaugeContext.tsx","../../src/segmented-gauge/SegmentedGaugeLabel.tsx","../../src/segmented-gauge/SegmentedGaugeSegment.tsx","../../src/segmented-gauge/SegmentedGaugeTrack.tsx","../../src/segmented-gauge/index.ts"],"sourcesContent":["import { cx } from 'class-variance-authority'\nimport { Ref, useId, useMemo } from 'react'\n\nimport { SegmentedGaugeContext } from './SegmentedGaugeContext'\nimport { SegmentedGaugeLabel } from './SegmentedGaugeLabel'\nimport { SegmentedGaugeSegment } from './SegmentedGaugeSegment'\nimport { SegmentedGaugeTrack } from './SegmentedGaugeTrack'\n\nconst calculateCurrentIndex = (\n value: number | undefined,\n min: number,\n max: number,\n segments: number\n) => {\n // If value is undefined or null, no segment is active\n if (value == null) {\n return -1\n }\n const normalizedValue = Math.max(min, Math.min(max, value))\n const range = max - min\n const segmentSize = range / (segments - 1)\n const rawIndex = (normalizedValue - min) / segmentSize\n\n // Clamp the index to valid range\n return Math.max(0, Math.min(segments - 1, Math.round(rawIndex)))\n}\n\nexport interface SegmentedGaugeProps {\n /**\n * The current value of the gauge\n */\n value?: number\n /**\n * Minimum value of the gauge (aria-valuemin)\n */\n min: number\n /**\n * Maximum value of the gauge (aria-valuemax)\n */\n max: number\n /**\n * Description text for the gauge (aria-describedby)\n */\n description?: string\n /**\n * Size of the gauge\n */\n size?: 'sm' | 'md'\n /**\n * Intent of the gauge - predefined color intent\n */\n intent?:\n | 'main'\n | 'support'\n | 'basic'\n | 'accent'\n | 'success'\n | 'alert'\n | 'danger'\n | 'info'\n | 'neutral'\n /**\n * Custom color for the gauge (hex, CSS variable, etc.)\n */\n customColor?: string\n /**\n * ID of the gauge element\n */\n id?: string\n /**\n * Accessible label for the gauge (required if no id is provided)\n */\n 'aria-label'?: string\n /**\n * Additional CSS classes\n */\n className?: string\n /**\n * Ref to the root element\n */\n ref?: Ref<HTMLDivElement>\n /**\n * Children render prop for custom rendering\n */\n children?: (props: {\n segments: {\n isActive: boolean\n isCurrent: boolean\n }[]\n currentIndex: number\n }) => React.ReactNode\n}\n\nexport const SegmentedGauge = ({\n value,\n min,\n max,\n description,\n size = 'md',\n intent = 'neutral',\n customColor,\n id,\n 'aria-label': ariaLabel,\n className,\n ref,\n children,\n ...props\n}: SegmentedGaugeProps) => {\n // Calculate segments from min and max\n const segments = max - min + 1\n const currentIndex = useMemo(\n () => calculateCurrentIndex(value, min, max, segments),\n [value, min, max, segments]\n )\n\n // Generate unique IDs\n const internalLabelId = useId()\n const generatedId = useId()\n // Use provided id or generated one for the gauge element\n const gaugeId = id || generatedId\n\n const segmentsData = useMemo(() => {\n return Array.from({ length: segments }, (_, index) => ({\n isActive: currentIndex !== -1 && index <= currentIndex,\n isCurrent: currentIndex !== -1 && index === currentIndex,\n }))\n }, [segments, currentIndex])\n\n const contextValue = useMemo(\n () => ({\n value,\n min,\n max,\n segments,\n currentIndex,\n size,\n intent,\n customColor,\n labelId: internalLabelId,\n gaugeId,\n }),\n [value, min, max, segments, currentIndex, size, intent, customColor, internalLabelId, gaugeId]\n )\n\n // If children is provided, use render prop pattern\n if (children) {\n return (\n <SegmentedGaugeContext.Provider value={contextValue}>\n {children({\n segments: segmentsData,\n currentIndex,\n })}\n </SegmentedGaugeContext.Provider>\n )\n }\n\n /**\n * A `meter` role MUST have a value. If the value is not available, the component uses a `status` role instead.\n */\n const roleProps =\n value != null\n ? {\n role: 'meter',\n 'aria-valuenow': value,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n }\n : {\n role: 'status',\n }\n\n // Default rendering\n return (\n <SegmentedGaugeContext.Provider value={contextValue}>\n <div\n id={gaugeId}\n data-spark-component=\"segmented-gauge\"\n ref={ref}\n className={cx('gap-md flex items-center', className)}\n {...roleProps}\n aria-labelledby={id ? `${gaugeId}-label` : undefined}\n aria-label={!id ? ariaLabel : undefined}\n aria-describedby={internalLabelId}\n {...props}\n >\n <SegmentedGaugeTrack>\n {segmentsData.map((_, index) => (\n <SegmentedGaugeSegment key={index} index={index} />\n ))}\n </SegmentedGaugeTrack>\n\n {description && (\n <SegmentedGaugeLabel id={internalLabelId}>{description}</SegmentedGaugeLabel>\n )}\n </div>\n </SegmentedGaugeContext.Provider>\n )\n}\n\nSegmentedGauge.displayName = 'SegmentedGauge'\n","import { createContext, useContext } from 'react'\n\nexport interface SegmentedGaugeContextValue {\n value?: number\n min: number\n max: number\n segments: number\n currentIndex: number\n size: 'sm' | 'md'\n intent:\n | 'main'\n | 'support'\n | 'basic'\n | 'accent'\n | 'success'\n | 'alert'\n | 'danger'\n | 'info'\n | 'neutral'\n customColor?: string\n labelId: string\n gaugeId: string\n}\n\nexport const SegmentedGaugeContext = createContext<SegmentedGaugeContextValue | null>(null)\n\nexport const useSegmentedGaugeContext = () => {\n const context = useContext(SegmentedGaugeContext)\n\n if (!context) {\n throw new Error('useSegmentedGaugeContext must be used within a SegmentedGauge provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useSegmentedGaugeContext } from './SegmentedGaugeContext'\n\nexport interface SegmentedGaugeLabelProps extends ComponentProps<'span'> {\n ref?: Ref<HTMLSpanElement>\n id?: string\n}\n\nexport const SegmentedGaugeLabel = ({\n className,\n children,\n ref,\n id,\n ...props\n}: SegmentedGaugeLabelProps) => {\n const { labelId } = useSegmentedGaugeContext()\n\n return (\n <span\n data-spark-component=\"segmented-gauge-label\"\n data-testid=\"segmented-gauge-label\"\n ref={ref}\n id={id || labelId}\n className={cx('default:text-on-surface default:text-body-2', className)}\n {...props}\n >\n {children}\n </span>\n )\n}\n\nSegmentedGaugeLabel.displayName = 'SegmentedGauge.Label'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref, useMemo } from 'react'\n\nimport { useSegmentedGaugeContext } from './SegmentedGaugeContext'\n\nexport interface SegmentedGaugeSegmentProps extends ComponentProps<'div'> {\n /**\n * Index of this segment (0-based)\n */\n index?: number\n ref?: Ref<HTMLDivElement>\n}\n\nexport const SegmentedGaugeSegment = ({\n index = 0,\n className,\n children,\n ref,\n ...props\n}: SegmentedGaugeSegmentProps) => {\n const { size, intent, customColor, currentIndex } = useSegmentedGaugeContext()\n\n // Calculate isActive and isCurrent from context and index\n const isActive = currentIndex !== -1 && index <= currentIndex\n const isCurrent = currentIndex !== -1 && index === currentIndex\n\n const gaugeColor = useMemo(() => {\n // If customColor is provided, use it\n if (customColor) {\n return customColor\n }\n\n // Handle predefined intents\n switch (intent) {\n case 'main':\n return 'var(--color-main)'\n case 'support':\n return 'var(--color-support)'\n case 'basic':\n return 'var(--color-basic)'\n case 'accent':\n return 'var(--color-accent)'\n case 'success':\n return 'var(--color-success)'\n case 'alert':\n return 'var(--color-alert)'\n case 'danger':\n return 'var(--color-error)'\n case 'info':\n return 'var(--color-info)'\n case 'neutral':\n return 'var(--color-neutral)'\n default:\n return 'var(--color-neutral)'\n }\n }, [intent, customColor])\n\n const segmentClasses = cx(\n 'border-outline relative rounded-full',\n {\n 'h-sz-8 w-sz-24': size === 'sm',\n 'h-sz-12 w-sz-36': size === 'md',\n 'default:bg-[var(--gauge-color)]': isActive,\n 'border-sm bg-surface': !isActive,\n },\n className\n )\n\n const indicatorClasses = cx(\n 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2',\n 'default:bg-surface default:rounded-full',\n 'border-[var(--gauge-color)]',\n {\n 'size-sz-12 border-md': size === 'sm',\n 'size-sz-20 border-lg': size === 'md',\n }\n )\n\n return (\n <div\n data-spark-component=\"segmented-gauge-segment\"\n data-testid=\"segmented-gauge-segment\"\n data-active={isActive}\n data-current={isCurrent}\n ref={ref}\n style={\n {\n '--gauge-color': gaugeColor,\n } as React.CSSProperties\n }\n className={segmentClasses}\n {...props}\n >\n {children}\n {isCurrent && <div className={indicatorClasses} aria-hidden=\"true\" />}\n </div>\n )\n}\n\nSegmentedGaugeSegment.displayName = 'SegmentedGauge.Segment'\n","import { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface SegmentedGaugeTrackProps extends ComponentProps<'div'> {\n ref?: Ref<HTMLDivElement>\n}\n\nexport const SegmentedGaugeTrack = ({\n className,\n children,\n ref,\n ...props\n}: SegmentedGaugeTrackProps) => {\n return (\n <div\n data-spark-component=\"segmented-gauge-track\"\n ref={ref}\n className={cx('gap-sm relative flex rounded-full', className)}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nSegmentedGaugeTrack.displayName = 'SegmentedGauge.Track'\n","import { SegmentedGauge as Root } from './SegmentedGauge'\nimport { SegmentedGaugeLabel } from './SegmentedGaugeLabel'\nimport { SegmentedGaugeSegment } from './SegmentedGaugeSegment'\nimport { SegmentedGaugeTrack } from './SegmentedGaugeTrack'\n\nexport const SegmentedGauge: typeof Root & {\n Track: typeof SegmentedGaugeTrack\n Segment: typeof SegmentedGaugeSegment\n Label: typeof SegmentedGaugeLabel\n} = Object.assign(Root, {\n Track: SegmentedGaugeTrack,\n Segment: SegmentedGaugeSegment,\n Label: SegmentedGaugeLabel,\n})\n\nSegmentedGauge.displayName = 'SegmentedGauge'\nSegmentedGaugeTrack.displayName = 'SegmentedGauge.Track'\nSegmentedGaugeSegment.displayName = 'SegmentedGauge.Segment'\nSegmentedGaugeLabel.displayName = 'SegmentedGauge.Label'\n\nexport { type SegmentedGaugeProps } from './SegmentedGauge'\nexport { type SegmentedGaugeTrackProps } from './SegmentedGaugeTrack'\nexport { type SegmentedGaugeSegmentProps } from './SegmentedGaugeSegment'\nexport { type SegmentedGaugeLabelProps } from './SegmentedGaugeLabel'\n"],"mappings":";AAAA,SAAS,MAAAA,WAAU;AACnB,SAAc,OAAO,WAAAC,gBAAe;;;ACDpC,SAAS,eAAe,kBAAkB;AAwBnC,IAAM,wBAAwB,cAAiD,IAAI;AAEnF,IAAM,2BAA2B,MAAM;AAC5C,QAAM,UAAU,WAAW,qBAAqB;AAEhD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAEA,SAAO;AACT;;;AClCA,SAAS,UAAU;AAoBf;AAVG,IAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAgC;AAC9B,QAAM,EAAE,QAAQ,IAAI,yBAAyB;AAE7C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,wBAAqB;AAAA,MACrB,eAAY;AAAA,MACZ;AAAA,MACA,IAAI,MAAM;AAAA,MACV,WAAW,GAAG,+CAA+C,SAAS;AAAA,MACrE,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,oBAAoB,cAAc;;;ACjClC,SAAS,MAAAC,WAAU;AACnB,SAA8B,eAAe;AA8EzC,SAegB,OAAAC,MAfhB;AAlEG,IAAM,wBAAwB,CAAC;AAAA,EACpC,QAAQ;AAAA,EACR;AAAA,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;AAAA;AAAA,EAE3D,GACF;AAEJ;AAEA,eAAe,cAAc;;;AKlMtB,IAAMI,kBAIT,OAAO,OAAO,gBAAM;AAAA,EACtB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEDA,gBAAe,cAAc;AAC7B,oBAAoB,cAAc;AAClC,sBAAsB,cAAc;AACpC,oBAAoB,cAAc;","names":["cx","useMemo","cx","jsx","cx","cx","jsx","jsx","jsxs","useMemo","cx","SegmentedGauge"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/components",
3
- "version": "10.20.11",
3
+ "version": "10.21.1",
4
4
  "license": "MIT",
5
5
  "description": "Spark (Leboncoin design system) components.",
6
6
  "exports": {
@@ -53,9 +53,9 @@
53
53
  "@react-aria/toast": "^3.0.0-beta.18",
54
54
  "@react-stately/numberfield": "3.9.11",
55
55
  "@react-stately/toast": "^3.0.0-beta.7",
56
- "@spark-ui/hooks": "^10.20.11",
57
- "@spark-ui/icons": "^10.20.11",
58
- "@spark-ui/internal-utils": "^10.20.11",
56
+ "@spark-ui/hooks": "^10.21.1",
57
+ "@spark-ui/icons": "^10.21.1",
58
+ "@spark-ui/internal-utils": "^10.21.1",
59
59
  "@zag-js/pagination": "1.25.0",
60
60
  "@zag-js/react": "1.25.0",
61
61
  "class-variance-authority": "0.7.1",
@@ -82,5 +82,5 @@
82
82
  "url": "https://github.com/leboncoin/spark-web/issues?q=is%3Aopen+label%3A%22Component%3A+button%22"
83
83
  },
84
84
  "homepage": "https://sparkui.vercel.app",
85
- "gitHead": "9a9bd7808873aef08d48941b41963ee8c416fafe"
85
+ "gitHead": "3ace4604c2e5577c6eb75cb38f6875cd6a04b8e7"
86
86
  }