@sentropic/design-system-vue 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DivergentBarChart.d.ts +93 -0
- package/dist/DivergentBarChart.d.ts.map +1 -0
- package/dist/DivergentBarChart.js +158 -0
- package/dist/DivergentBarChart.js.map +1 -0
- package/dist/GaugeChart.d.ts +1 -1
- package/dist/RangeSlider.d.ts +187 -0
- package/dist/RangeSlider.d.ts.map +1 -0
- package/dist/RangeSlider.js +191 -0
- package/dist/RangeSlider.js.map +1 -0
- package/dist/StepLineChart.d.ts +72 -0
- package/dist/StepLineChart.d.ts.map +1 -0
- package/dist/StepLineChart.js +159 -0
- package/dist/StepLineChart.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +343 -0
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type DivergentBarChartTone = "positive" | "negative" | "neutral";
|
|
2
|
+
export type DivergentBarChartDatum = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
tone?: DivergentBarChartTone;
|
|
6
|
+
};
|
|
7
|
+
export type DivergentBarChartProps = {
|
|
8
|
+
data: DivergentBarChartDatum[];
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
domain?: [number, number];
|
|
12
|
+
format?: (value: number) => string;
|
|
13
|
+
showLegend?: boolean;
|
|
14
|
+
label: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const DivergentBarChart: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
18
|
+
data: {
|
|
19
|
+
type: () => DivergentBarChartDatum[];
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
width: {
|
|
23
|
+
type: NumberConstructor;
|
|
24
|
+
default: number;
|
|
25
|
+
};
|
|
26
|
+
height: {
|
|
27
|
+
type: NumberConstructor;
|
|
28
|
+
default: number;
|
|
29
|
+
};
|
|
30
|
+
domain: {
|
|
31
|
+
type: () => [number, number];
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
format: {
|
|
35
|
+
type: () => (value: number) => string;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
showLegend: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
label: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
class: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: undefined;
|
|
49
|
+
};
|
|
50
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
53
|
+
data: {
|
|
54
|
+
type: () => DivergentBarChartDatum[];
|
|
55
|
+
required: true;
|
|
56
|
+
};
|
|
57
|
+
width: {
|
|
58
|
+
type: NumberConstructor;
|
|
59
|
+
default: number;
|
|
60
|
+
};
|
|
61
|
+
height: {
|
|
62
|
+
type: NumberConstructor;
|
|
63
|
+
default: number;
|
|
64
|
+
};
|
|
65
|
+
domain: {
|
|
66
|
+
type: () => [number, number];
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
format: {
|
|
70
|
+
type: () => (value: number) => string;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
showLegend: {
|
|
74
|
+
type: BooleanConstructor;
|
|
75
|
+
default: boolean;
|
|
76
|
+
};
|
|
77
|
+
label: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
required: true;
|
|
80
|
+
};
|
|
81
|
+
class: {
|
|
82
|
+
type: StringConstructor;
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
}>> & Readonly<{}>, {
|
|
86
|
+
class: string;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
domain: [number, number];
|
|
90
|
+
format: (value: number) => string;
|
|
91
|
+
showLegend: boolean;
|
|
92
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
93
|
+
//# sourceMappingURL=DivergentBarChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DivergentBarChart.d.ts","sourceRoot":"","sources":["../src/DivergentBarChart.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,qBAAqB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAiCF,eAAO,MAAM,iBAAiB;;cAGH,MAAM,sBAAsB,EAAE;;;;;;;;;;;;cAGjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;cACnB,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;cAJ/C,MAAM,sBAAsB,EAAE;;;;;;;;;;;;cAGjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;cACnB,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;oBAAjB,MAAM,KAAK,MAAM;;4EA6IxE,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { defineComponent, h, ref } from "vue";
|
|
2
|
+
import { classNames } from "./classNames.js";
|
|
3
|
+
import { chartDataList, formatTick, niceTicks, scaleLinear } from "./chartScale.js";
|
|
4
|
+
const MARGIN = { top: 14, right: 16, bottom: 34, left: 88 };
|
|
5
|
+
function signFor(value) {
|
|
6
|
+
if (value > 0)
|
|
7
|
+
return "positive";
|
|
8
|
+
if (value < 0)
|
|
9
|
+
return "negative";
|
|
10
|
+
return "zero";
|
|
11
|
+
}
|
|
12
|
+
function toneFor(datum) {
|
|
13
|
+
if (datum.tone)
|
|
14
|
+
return datum.tone;
|
|
15
|
+
if (datum.value > 0)
|
|
16
|
+
return "positive";
|
|
17
|
+
if (datum.value < 0)
|
|
18
|
+
return "negative";
|
|
19
|
+
return "neutral";
|
|
20
|
+
}
|
|
21
|
+
function resolveDomain(data, domain) {
|
|
22
|
+
const plotDomain = domain && Number.isFinite(domain[0]) && Number.isFinite(domain[1]) && domain[0] < domain[1] && domain[0] <= 0 && domain[1] >= 0
|
|
23
|
+
? domain
|
|
24
|
+
: null;
|
|
25
|
+
if (plotDomain) {
|
|
26
|
+
const ticks = niceTicks(plotDomain[0], plotDomain[1]).filter((tick) => tick >= plotDomain[0] && tick <= plotDomain[1]);
|
|
27
|
+
return { domainMin: plotDomain[0], domainMax: plotDomain[1], ticks: ticks.length ? ticks : [0] };
|
|
28
|
+
}
|
|
29
|
+
const maxAbs = Math.max(1, ...data.map((d) => Math.abs(d.value)));
|
|
30
|
+
const ticks = niceTicks(-maxAbs, maxAbs);
|
|
31
|
+
return { domainMin: ticks[0], domainMax: ticks[ticks.length - 1], ticks };
|
|
32
|
+
}
|
|
33
|
+
export const DivergentBarChart = defineComponent({
|
|
34
|
+
name: "DivergentBarChart",
|
|
35
|
+
props: {
|
|
36
|
+
data: { type: Array, required: true },
|
|
37
|
+
width: { type: Number, default: 480 },
|
|
38
|
+
height: { type: Number, default: 260 },
|
|
39
|
+
domain: { type: Array, default: undefined },
|
|
40
|
+
format: { type: Function, default: undefined },
|
|
41
|
+
showLegend: { type: Boolean, default: true },
|
|
42
|
+
label: { type: String, required: true },
|
|
43
|
+
class: { type: String, default: undefined },
|
|
44
|
+
},
|
|
45
|
+
setup(props, { attrs }) {
|
|
46
|
+
const hoveredIndex = ref(null);
|
|
47
|
+
function handleVisualPointerMove(event) {
|
|
48
|
+
const target = event.target;
|
|
49
|
+
if (!(target instanceof Element)) {
|
|
50
|
+
hoveredIndex.value = null;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const index = Number(target.getAttribute("data-chart-index"));
|
|
54
|
+
hoveredIndex.value = Number.isInteger(index) ? index : null;
|
|
55
|
+
}
|
|
56
|
+
return () => {
|
|
57
|
+
const width = props.width ?? 480;
|
|
58
|
+
const height = props.height ?? 260;
|
|
59
|
+
const formatter = props.format ?? formatTick;
|
|
60
|
+
const validData = props.data.filter((d) => Number.isFinite(d.value));
|
|
61
|
+
const { domainMin, domainMax, ticks } = resolveDomain(validData, props.domain);
|
|
62
|
+
const plotWidth = Math.max(width - MARGIN.left - MARGIN.right, 1);
|
|
63
|
+
const plotHeight = Math.max(height - MARGIN.top - MARGIN.bottom, 1);
|
|
64
|
+
const zeroAxisX = MARGIN.left + scaleLinear(0, domainMin, domainMax, 0, plotWidth);
|
|
65
|
+
const bars = validData.length === 0
|
|
66
|
+
? []
|
|
67
|
+
: validData.map((datum, index) => {
|
|
68
|
+
const band = plotHeight / validData.length;
|
|
69
|
+
const barHeight = Math.max(band * 0.56, 1);
|
|
70
|
+
const valueX = MARGIN.left + scaleLinear(datum.value, domainMin, domainMax, 0, plotWidth);
|
|
71
|
+
const x = Math.min(zeroAxisX, valueX);
|
|
72
|
+
const barWidth = Math.max(Math.abs(valueX - zeroAxisX), 0.5);
|
|
73
|
+
const y = MARGIN.top + band * index + (band - barHeight) / 2;
|
|
74
|
+
return {
|
|
75
|
+
datum,
|
|
76
|
+
index,
|
|
77
|
+
x,
|
|
78
|
+
y,
|
|
79
|
+
width: barWidth,
|
|
80
|
+
height: barHeight,
|
|
81
|
+
cx: datum.value === 0 ? zeroAxisX : x + barWidth / 2,
|
|
82
|
+
cy: y + barHeight / 2,
|
|
83
|
+
sign: signFor(datum.value),
|
|
84
|
+
tone: toneFor(datum),
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const grid = ticks.map((tick) => {
|
|
88
|
+
const x = MARGIN.left + scaleLinear(tick, domainMin, domainMax, 0, plotWidth);
|
|
89
|
+
return [
|
|
90
|
+
h("line", { key: `g${tick}`, class: "st-divergentBarChart__grid", x1: x, x2: x, y1: MARGIN.top, y2: height - MARGIN.bottom }),
|
|
91
|
+
h("text", { key: `t${tick}`, class: "st-divergentBarChart__tickLabel", x, y: height - MARGIN.bottom + 16, "text-anchor": "middle" }, formatTick(tick)),
|
|
92
|
+
];
|
|
93
|
+
});
|
|
94
|
+
const barNodes = bars.flatMap((bar) => [
|
|
95
|
+
h("text", { key: `l${bar.datum.label}`, class: "st-divergentBarChart__categoryLabel", x: MARGIN.left - 8, y: bar.cy, "text-anchor": "end", "dominant-baseline": "middle" }, bar.datum.label),
|
|
96
|
+
h("rect", {
|
|
97
|
+
key: `b${bar.datum.label}`,
|
|
98
|
+
class: classNames("st-divergentBarChart__bar", `st-divergentBarChart__bar--${bar.sign}`, `st-divergentBarChart__bar--${bar.tone}`),
|
|
99
|
+
x: bar.x,
|
|
100
|
+
y: bar.y,
|
|
101
|
+
width: bar.width,
|
|
102
|
+
height: bar.height,
|
|
103
|
+
rx: "2",
|
|
104
|
+
"data-chart-index": bar.index,
|
|
105
|
+
"data-chart-key": bar.datum.label,
|
|
106
|
+
onPointermove: handleVisualPointerMove,
|
|
107
|
+
}),
|
|
108
|
+
]);
|
|
109
|
+
const hoveredBar = hoveredIndex.value !== null ? bars[hoveredIndex.value] : undefined;
|
|
110
|
+
return h("div", { ...attrs, class: classNames("st-divergentBarChart", props.class) }, [
|
|
111
|
+
h("div", {
|
|
112
|
+
class: "st-divergentBarChart__visual",
|
|
113
|
+
role: "img",
|
|
114
|
+
"aria-label": props.label,
|
|
115
|
+
onPointermove: handleVisualPointerMove,
|
|
116
|
+
onPointerleave: () => {
|
|
117
|
+
hoveredIndex.value = null;
|
|
118
|
+
},
|
|
119
|
+
}, [
|
|
120
|
+
h("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "xMidYMid meet", width: "100%", height: "100%", focusable: "false", "aria-hidden": "true" }, [
|
|
121
|
+
grid,
|
|
122
|
+
h("line", { class: "st-divergentBarChart__axis", x1: MARGIN.left, x2: width - MARGIN.right, y1: height - MARGIN.bottom, y2: height - MARGIN.bottom }),
|
|
123
|
+
h("line", { class: "st-divergentBarChart__zeroAxis", x1: zeroAxisX, x2: zeroAxisX, y1: MARGIN.top, y2: height - MARGIN.bottom }),
|
|
124
|
+
barNodes,
|
|
125
|
+
]),
|
|
126
|
+
]),
|
|
127
|
+
chartDataList(props.label, validData.map((d) => `${d.label}: ${formatter(d.value)}`)),
|
|
128
|
+
hoveredBar
|
|
129
|
+
? h("div", {
|
|
130
|
+
class: "st-divergentBarChart__tooltip",
|
|
131
|
+
role: "presentation",
|
|
132
|
+
style: { left: `${(hoveredBar.cx / width) * 100}%`, top: `${(hoveredBar.cy / height) * 100}%` },
|
|
133
|
+
}, [
|
|
134
|
+
h("span", { class: "st-divergentBarChart__tooltipLabel" }, hoveredBar.datum.label),
|
|
135
|
+
h("span", { class: "st-divergentBarChart__tooltipValue" }, formatter(hoveredBar.datum.value)),
|
|
136
|
+
])
|
|
137
|
+
: null,
|
|
138
|
+
props.showLegend
|
|
139
|
+
? h("ul", { class: "st-divergentBarChart__legend" }, [
|
|
140
|
+
h("li", { class: "st-divergentBarChart__legendItem" }, [
|
|
141
|
+
h("span", { class: "st-divergentBarChart__legendSwatch st-divergentBarChart__legendSwatch--positive", "aria-hidden": "true" }),
|
|
142
|
+
"Positive",
|
|
143
|
+
]),
|
|
144
|
+
h("li", { class: "st-divergentBarChart__legendItem" }, [
|
|
145
|
+
h("span", { class: "st-divergentBarChart__legendSwatch st-divergentBarChart__legendSwatch--negative", "aria-hidden": "true" }),
|
|
146
|
+
"Negative",
|
|
147
|
+
]),
|
|
148
|
+
h("li", { class: "st-divergentBarChart__legendItem" }, [
|
|
149
|
+
h("span", { class: "st-divergentBarChart__legendSwatch st-divergentBarChart__legendSwatch--neutral", "aria-hidden": "true" }),
|
|
150
|
+
"Zero",
|
|
151
|
+
]),
|
|
152
|
+
])
|
|
153
|
+
: null,
|
|
154
|
+
]);
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=DivergentBarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DivergentBarChart.js","sourceRoot":"","sources":["../src/DivergentBarChart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAqBpF,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAW,CAAC;AAErE,SAAS,OAAO,CAAC,KAAa;IAC5B,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IACjC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAA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AAE,EAAE;4BACrD,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,iFAAiF,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;4BAC9H,UAAU;yBACX,CAAC;wBACF,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,kCAAkC,EAAE,EAAE;4BACrD,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,iFAAiF,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;4BAC9H,UAAU;yBACX,CAAC;wBACF,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,kCAAkC,EAAE,EAAE;4BACrD,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,gFAAgF,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;4BAC7H,MAAM;yBACP,CAAC;qBACH,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/GaugeChart.d.ts
CHANGED
|
@@ -124,9 +124,9 @@ export declare const GaugeChart: import("vue").DefineComponent<import("vue").Ext
|
|
|
124
124
|
size: number;
|
|
125
125
|
min: number;
|
|
126
126
|
max: number;
|
|
127
|
+
format: GaugeChartFormat;
|
|
127
128
|
thickness: number;
|
|
128
129
|
thresholds: GaugeChartThreshold[];
|
|
129
|
-
format: GaugeChartFormat;
|
|
130
130
|
unit: string;
|
|
131
131
|
startAngle: number;
|
|
132
132
|
endAngle: number;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { PropType } from "vue";
|
|
2
|
+
export type RangeSliderSize = "sm" | "md" | "lg";
|
|
3
|
+
export type RangeSliderProps = {
|
|
4
|
+
/** Valeur contrôlée via v-model [poignée basse, poignée haute]. */
|
|
5
|
+
modelValue?: [number, number];
|
|
6
|
+
/** Alias contrôlé sans v-model. */
|
|
7
|
+
value?: [number, number];
|
|
8
|
+
/** Valeur initiale en mode non-contrôlé. Défaut [min, max]. */
|
|
9
|
+
defaultValue?: [number, number];
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
step?: number;
|
|
13
|
+
size?: RangeSliderSize;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
label?: string;
|
|
16
|
+
helperText?: string;
|
|
17
|
+
errorText?: string;
|
|
18
|
+
invalid?: boolean;
|
|
19
|
+
showValue?: boolean;
|
|
20
|
+
valueFormatter?: (value: number) => string;
|
|
21
|
+
ariaLabelMin?: string;
|
|
22
|
+
ariaLabelMax?: string;
|
|
23
|
+
class?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const RangeSlider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: PropType<[number, number]>;
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
30
|
+
value: {
|
|
31
|
+
type: PropType<[number, number]>;
|
|
32
|
+
default: undefined;
|
|
33
|
+
};
|
|
34
|
+
defaultValue: {
|
|
35
|
+
type: PropType<[number, number]>;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
min: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: number;
|
|
41
|
+
};
|
|
42
|
+
max: {
|
|
43
|
+
type: NumberConstructor;
|
|
44
|
+
default: number;
|
|
45
|
+
};
|
|
46
|
+
step: {
|
|
47
|
+
type: NumberConstructor;
|
|
48
|
+
default: number;
|
|
49
|
+
};
|
|
50
|
+
size: {
|
|
51
|
+
type: () => RangeSliderSize;
|
|
52
|
+
default: string;
|
|
53
|
+
};
|
|
54
|
+
disabled: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
58
|
+
label: {
|
|
59
|
+
type: StringConstructor;
|
|
60
|
+
default: undefined;
|
|
61
|
+
};
|
|
62
|
+
helperText: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
errorText: {
|
|
67
|
+
type: StringConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
invalid: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
showValue: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: boolean;
|
|
77
|
+
};
|
|
78
|
+
valueFormatter: {
|
|
79
|
+
type: PropType<(value: number) => string>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
ariaLabelMin: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
ariaLabelMax: {
|
|
87
|
+
type: StringConstructor;
|
|
88
|
+
default: string;
|
|
89
|
+
};
|
|
90
|
+
class: {
|
|
91
|
+
type: StringConstructor;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
97
|
+
modelValue: {
|
|
98
|
+
type: PropType<[number, number]>;
|
|
99
|
+
default: undefined;
|
|
100
|
+
};
|
|
101
|
+
value: {
|
|
102
|
+
type: PropType<[number, number]>;
|
|
103
|
+
default: undefined;
|
|
104
|
+
};
|
|
105
|
+
defaultValue: {
|
|
106
|
+
type: PropType<[number, number]>;
|
|
107
|
+
default: undefined;
|
|
108
|
+
};
|
|
109
|
+
min: {
|
|
110
|
+
type: NumberConstructor;
|
|
111
|
+
default: number;
|
|
112
|
+
};
|
|
113
|
+
max: {
|
|
114
|
+
type: NumberConstructor;
|
|
115
|
+
default: number;
|
|
116
|
+
};
|
|
117
|
+
step: {
|
|
118
|
+
type: NumberConstructor;
|
|
119
|
+
default: number;
|
|
120
|
+
};
|
|
121
|
+
size: {
|
|
122
|
+
type: () => RangeSliderSize;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
125
|
+
disabled: {
|
|
126
|
+
type: BooleanConstructor;
|
|
127
|
+
default: boolean;
|
|
128
|
+
};
|
|
129
|
+
label: {
|
|
130
|
+
type: StringConstructor;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
helperText: {
|
|
134
|
+
type: StringConstructor;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
137
|
+
errorText: {
|
|
138
|
+
type: StringConstructor;
|
|
139
|
+
default: undefined;
|
|
140
|
+
};
|
|
141
|
+
invalid: {
|
|
142
|
+
type: BooleanConstructor;
|
|
143
|
+
default: boolean;
|
|
144
|
+
};
|
|
145
|
+
showValue: {
|
|
146
|
+
type: BooleanConstructor;
|
|
147
|
+
default: boolean;
|
|
148
|
+
};
|
|
149
|
+
valueFormatter: {
|
|
150
|
+
type: PropType<(value: number) => string>;
|
|
151
|
+
default: undefined;
|
|
152
|
+
};
|
|
153
|
+
ariaLabelMin: {
|
|
154
|
+
type: StringConstructor;
|
|
155
|
+
default: string;
|
|
156
|
+
};
|
|
157
|
+
ariaLabelMax: {
|
|
158
|
+
type: StringConstructor;
|
|
159
|
+
default: string;
|
|
160
|
+
};
|
|
161
|
+
class: {
|
|
162
|
+
type: StringConstructor;
|
|
163
|
+
default: undefined;
|
|
164
|
+
};
|
|
165
|
+
}>> & Readonly<{
|
|
166
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
167
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
168
|
+
}>, {
|
|
169
|
+
class: string;
|
|
170
|
+
label: string;
|
|
171
|
+
invalid: boolean;
|
|
172
|
+
disabled: boolean;
|
|
173
|
+
size: RangeSliderSize;
|
|
174
|
+
min: number;
|
|
175
|
+
max: number;
|
|
176
|
+
value: [number, number];
|
|
177
|
+
helperText: string;
|
|
178
|
+
modelValue: [number, number];
|
|
179
|
+
errorText: string;
|
|
180
|
+
step: number;
|
|
181
|
+
defaultValue: [number, number];
|
|
182
|
+
showValue: boolean;
|
|
183
|
+
valueFormatter: (value: number) => string;
|
|
184
|
+
ariaLabelMin: string;
|
|
185
|
+
ariaLabelMax: string;
|
|
186
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
187
|
+
//# sourceMappingURL=RangeSlider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeSlider.d.ts","sourceRoot":"","sources":["../src/RangeSlider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,mCAAmC;IACnC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW;;cAGoB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cAC/B,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cACnB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;cAI5C,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAOT,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;cAb/B,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cAC/B,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;cACnB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;;;;;;;;;;;;;;;cAI5C,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAOT,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAAlB,MAAM,KAAK,MAAM;;;4EAqNxE,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { defineComponent, h, ref } from "vue";
|
|
2
|
+
import { classNames } from "./classNames.js";
|
|
3
|
+
export const RangeSlider = defineComponent({
|
|
4
|
+
name: "RangeSlider",
|
|
5
|
+
props: {
|
|
6
|
+
modelValue: { type: Array, default: undefined },
|
|
7
|
+
value: { type: Array, default: undefined },
|
|
8
|
+
defaultValue: { type: Array, default: undefined },
|
|
9
|
+
min: { type: Number, default: 0 },
|
|
10
|
+
max: { type: Number, default: 100 },
|
|
11
|
+
step: { type: Number, default: 1 },
|
|
12
|
+
size: { type: String, default: "md" },
|
|
13
|
+
disabled: { type: Boolean, default: false },
|
|
14
|
+
label: { type: String, default: undefined },
|
|
15
|
+
helperText: { type: String, default: undefined },
|
|
16
|
+
errorText: { type: String, default: undefined },
|
|
17
|
+
invalid: { type: Boolean, default: false },
|
|
18
|
+
showValue: { type: Boolean, default: true },
|
|
19
|
+
valueFormatter: { type: Function, default: undefined },
|
|
20
|
+
ariaLabelMin: { type: String, default: "Valeur minimale" },
|
|
21
|
+
ariaLabelMax: { type: String, default: "Valeur maximale" },
|
|
22
|
+
class: { type: String, default: undefined },
|
|
23
|
+
},
|
|
24
|
+
emits: ["update:modelValue", "change"],
|
|
25
|
+
setup(props, { emit }) {
|
|
26
|
+
function clampStep(n) {
|
|
27
|
+
if (!Number.isFinite(n))
|
|
28
|
+
return props.min;
|
|
29
|
+
let v = Math.min(Math.max(n, props.min), props.max);
|
|
30
|
+
if (Number.isFinite(props.step) && props.step > 0) {
|
|
31
|
+
v = props.min + Math.round((v - props.min) / props.step) * props.step;
|
|
32
|
+
v = Math.min(Math.max(v, props.min), props.max);
|
|
33
|
+
}
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
function normalizePair(pair) {
|
|
37
|
+
let lo = clampStep(pair[0]);
|
|
38
|
+
let hi = clampStep(pair[1]);
|
|
39
|
+
if (lo > hi) {
|
|
40
|
+
const mid = lo;
|
|
41
|
+
lo = Math.min(mid, hi);
|
|
42
|
+
hi = Math.max(mid, hi);
|
|
43
|
+
}
|
|
44
|
+
return [lo, hi];
|
|
45
|
+
}
|
|
46
|
+
const internal = ref(normalizePair(props.defaultValue ?? [props.min, props.max]));
|
|
47
|
+
return () => {
|
|
48
|
+
const isControlled = Array.isArray(props.modelValue) || Array.isArray(props.value);
|
|
49
|
+
const source = props.modelValue ?? props.value ?? internal.value ?? [
|
|
50
|
+
props.min,
|
|
51
|
+
props.max,
|
|
52
|
+
];
|
|
53
|
+
const current = normalizePair(source);
|
|
54
|
+
const lowValue = current[0];
|
|
55
|
+
const highValue = current[1];
|
|
56
|
+
const lowPercent = props.max === props.min ? 0 : ((lowValue - props.min) / (props.max - props.min)) * 100;
|
|
57
|
+
const highPercent = props.max === props.min ? 0 : ((highValue - props.min) / (props.max - props.min)) * 100;
|
|
58
|
+
const lowLabel = props.valueFormatter ? props.valueFormatter(lowValue) : String(lowValue);
|
|
59
|
+
const highLabel = props.valueFormatter
|
|
60
|
+
? props.valueFormatter(highValue)
|
|
61
|
+
: String(highValue);
|
|
62
|
+
const isInvalid = props.invalid || Boolean(props.errorText);
|
|
63
|
+
function commit(next) {
|
|
64
|
+
const normalized = normalizePair(next);
|
|
65
|
+
if (!isControlled)
|
|
66
|
+
internal.value = normalized;
|
|
67
|
+
emit("update:modelValue", normalized);
|
|
68
|
+
emit("change", normalized);
|
|
69
|
+
}
|
|
70
|
+
function setLow(raw) {
|
|
71
|
+
if (props.disabled)
|
|
72
|
+
return;
|
|
73
|
+
const lo = Math.min(clampStep(raw), highValue);
|
|
74
|
+
commit([lo, highValue]);
|
|
75
|
+
}
|
|
76
|
+
function setHigh(raw) {
|
|
77
|
+
if (props.disabled)
|
|
78
|
+
return;
|
|
79
|
+
const hi = Math.max(clampStep(raw), lowValue);
|
|
80
|
+
commit([lowValue, hi]);
|
|
81
|
+
}
|
|
82
|
+
function keyDelta(event, val) {
|
|
83
|
+
const big = (Number.isFinite(props.step) && props.step > 0 ? props.step : 1) * 10;
|
|
84
|
+
const small = Number.isFinite(props.step) && props.step > 0 ? props.step : 1;
|
|
85
|
+
switch (event.key) {
|
|
86
|
+
case "ArrowRight":
|
|
87
|
+
case "ArrowUp":
|
|
88
|
+
return val + small;
|
|
89
|
+
case "ArrowLeft":
|
|
90
|
+
case "ArrowDown":
|
|
91
|
+
return val - small;
|
|
92
|
+
case "PageUp":
|
|
93
|
+
return val + big;
|
|
94
|
+
case "PageDown":
|
|
95
|
+
return val - big;
|
|
96
|
+
case "Home":
|
|
97
|
+
return props.min;
|
|
98
|
+
case "End":
|
|
99
|
+
return props.max;
|
|
100
|
+
default:
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function onLowKeydown(event) {
|
|
105
|
+
if (props.disabled)
|
|
106
|
+
return;
|
|
107
|
+
const next = keyDelta(event, lowValue);
|
|
108
|
+
if (next === null)
|
|
109
|
+
return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
setLow(next);
|
|
112
|
+
}
|
|
113
|
+
function onHighKeydown(event) {
|
|
114
|
+
if (props.disabled)
|
|
115
|
+
return;
|
|
116
|
+
const next = keyDelta(event, highValue);
|
|
117
|
+
if (next === null)
|
|
118
|
+
return;
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
setHigh(next);
|
|
121
|
+
}
|
|
122
|
+
const headerChildren = [
|
|
123
|
+
props.label ? h("span", { class: "st-field__label" }, props.label) : null,
|
|
124
|
+
props.showValue
|
|
125
|
+
? h("output", { class: "st-rangeSlider__value", "aria-live": "polite" }, `${lowLabel} – ${highLabel}`)
|
|
126
|
+
: null,
|
|
127
|
+
].filter(Boolean);
|
|
128
|
+
const lowThumb = h("span", {
|
|
129
|
+
class: "st-rangeSlider__thumb st-rangeSlider__thumb--low",
|
|
130
|
+
style: { left: `${lowPercent}%` },
|
|
131
|
+
role: "slider",
|
|
132
|
+
tabindex: props.disabled ? -1 : 0,
|
|
133
|
+
"aria-label": props.ariaLabelMin,
|
|
134
|
+
"aria-valuemin": props.min,
|
|
135
|
+
"aria-valuemax": highValue,
|
|
136
|
+
"aria-valuenow": lowValue,
|
|
137
|
+
"aria-valuetext": lowLabel,
|
|
138
|
+
"aria-disabled": props.disabled ? "true" : undefined,
|
|
139
|
+
onKeydown: onLowKeydown,
|
|
140
|
+
}, props.showValue
|
|
141
|
+
? [h("span", { class: "st-rangeSlider__tooltip" }, lowLabel)]
|
|
142
|
+
: []);
|
|
143
|
+
const highThumb = h("span", {
|
|
144
|
+
class: "st-rangeSlider__thumb st-rangeSlider__thumb--high",
|
|
145
|
+
style: { left: `${highPercent}%` },
|
|
146
|
+
role: "slider",
|
|
147
|
+
tabindex: props.disabled ? -1 : 0,
|
|
148
|
+
"aria-label": props.ariaLabelMax,
|
|
149
|
+
"aria-valuemin": lowValue,
|
|
150
|
+
"aria-valuemax": props.max,
|
|
151
|
+
"aria-valuenow": highValue,
|
|
152
|
+
"aria-valuetext": highLabel,
|
|
153
|
+
"aria-disabled": props.disabled ? "true" : undefined,
|
|
154
|
+
onKeydown: onHighKeydown,
|
|
155
|
+
}, props.showValue
|
|
156
|
+
? [h("span", { class: "st-rangeSlider__tooltip" }, highLabel)]
|
|
157
|
+
: []);
|
|
158
|
+
const track = h("span", {
|
|
159
|
+
class: "st-rangeSlider__track",
|
|
160
|
+
"aria-invalid": isInvalid ? "true" : undefined,
|
|
161
|
+
}, [
|
|
162
|
+
h("span", {
|
|
163
|
+
class: "st-rangeSlider__fill",
|
|
164
|
+
style: {
|
|
165
|
+
left: `${lowPercent}%`,
|
|
166
|
+
width: `${Math.max(0, highPercent - lowPercent)}%`,
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
lowThumb,
|
|
170
|
+
highThumb,
|
|
171
|
+
]);
|
|
172
|
+
const footer = props.errorText
|
|
173
|
+
? h("span", { class: "st-field__error" }, props.errorText)
|
|
174
|
+
: props.helperText
|
|
175
|
+
? h("span", { class: "st-field__help" }, props.helperText)
|
|
176
|
+
: null;
|
|
177
|
+
return h("div", { class: classNames("st-field", props.class) }, [
|
|
178
|
+
h("div", { class: "st-rangeSlider__header" }, headerChildren),
|
|
179
|
+
h("span", {
|
|
180
|
+
class: classNames("st-rangeSlider", `st-rangeSlider--${props.size}`, props.disabled ? "st-rangeSlider--disabled" : undefined),
|
|
181
|
+
}, [
|
|
182
|
+
h("span", { class: "st-rangeSlider__bounds", "aria-hidden": "true" }, String(props.min)),
|
|
183
|
+
track,
|
|
184
|
+
h("span", { class: "st-rangeSlider__bounds", "aria-hidden": "true" }, String(props.max)),
|
|
185
|
+
]),
|
|
186
|
+
footer,
|
|
187
|
+
].filter(Boolean));
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=RangeSlider.js.map
|