@emerson-eps/color-tables 1.0.0 → 1.0.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/component/BreakPoint/Canvas.d.ts +3 -3
- package/dist/component/BreakPoint/Canvas.js +10 -21
- package/dist/component/BreakPoint/Canvas.js.map +1 -1
- package/dist/component/BreakPoint/ColorScale.d.ts +2 -3
- package/dist/component/BreakPoint/ColorScale.js +19 -20
- package/dist/component/BreakPoint/ColorScale.js.map +1 -1
- package/dist/component/BreakPoint/Legend.d.ts +2 -3
- package/dist/component/BreakPoint/Legend.js +31 -37
- package/dist/component/BreakPoint/Legend.js.map +1 -1
- package/dist/component/BreakPoint/Modal.d.ts +6 -3
- package/dist/component/BreakPoint/Modal.js +17 -21
- package/dist/component/BreakPoint/Modal.js.map +1 -1
- package/dist/component/BreakPoint/index.d.ts +4 -0
- package/dist/component/BreakPoint/index.js +6 -0
- package/dist/component/BreakPoint/index.js.map +1 -0
- package/dist/component/ColorSelector/BreakPointModule.d.ts +3 -4
- package/dist/component/ColorSelector/BreakPointModule.js +99 -140
- package/dist/component/ColorSelector/BreakPointModule.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorAccordion.js +55 -60
- package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +2 -3
- package/dist/component/ColorSelector/ColorSelectorComponent.js +83 -86
- package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
- package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +12 -5
- package/dist/component/ColorSelector/ColorSelectorWrapper.js +41 -51
- package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
- package/dist/component/ColorSelector/index.d.ts +4 -0
- package/dist/component/ColorSelector/index.js +6 -0
- package/dist/component/ColorSelector/index.js.map +1 -0
- package/dist/component/Legend/ColorLegend.d.ts +2 -2
- package/dist/component/Legend/ColorLegend.js +38 -39
- package/dist/component/Legend/ColorLegend.js.map +1 -1
- package/dist/component/Legend/ColorLegend.stories.js +20 -31
- package/dist/component/Legend/ColorLegend.stories.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.d.ts +2 -2
- package/dist/component/Legend/ContinuousLegend.js +230 -276
- package/dist/component/Legend/ContinuousLegend.js.map +1 -1
- package/dist/component/Legend/ContinuousLegend.stories.js +13 -24
- package/dist/component/Legend/ContinuousLegend.stories.js.map +1 -1
- package/dist/component/Legend/DiscreteLegend.d.ts +2 -2
- package/dist/component/Legend/DiscreteLegend.js +130 -180
- package/dist/component/Legend/DiscreteLegend.js.map +1 -1
- package/dist/component/Legend/DiscreteLegend.stories.js +15 -26
- package/dist/component/Legend/DiscreteLegend.stories.js.map +1 -1
- package/dist/component/Legend/constants.js +1 -1
- package/dist/component/Legend/constants.js.map +1 -1
- package/dist/component/Legend/index.d.ts +3 -0
- package/dist/component/Legend/index.js +4 -0
- package/dist/component/Legend/index.js.map +1 -0
- package/dist/component/Utils/d3ColorScale.js +1 -1
- package/dist/component/Utils/d3ColorScale.js.map +1 -1
- package/dist/component/Utils/discreteLegend.d.ts +2 -3
- package/dist/component/Utils/discreteLegend.js.map +1 -1
- package/dist/component/Utils/index.d.ts +2 -0
- package/dist/component/Utils/index.js +4 -0
- package/dist/component/Utils/index.js.map +1 -0
- package/dist/component/Utils/legendCommonFunction.d.ts +7 -7
- package/dist/component/Utils/legendCommonFunction.js +128 -139
- package/dist/component/Utils/legendCommonFunction.js.map +1 -1
- package/dist/component/Utils/legendCommonFunction.stories.js +14 -25
- package/dist/component/Utils/legendCommonFunction.stories.js.map +1 -1
- package/dist/component/colorTableTypes.d.ts +10 -2
- package/dist/component/index.d.ts +6 -0
- package/dist/component/index.js +7 -0
- package/dist/component/index.js.map +1 -0
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -8
- package/dist/index.js.map +1 -1
- package/dist/stories/ColorLegends/ContinousLegends/MD.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/MD.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/MD.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.js +36 -0
- package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.js.map +1 -0
- package/dist/stories/ColorLegends/ContinousLegends/SW.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/ContinousLegends/SW.stories.js +34 -0
- package/dist/stories/ColorLegends/ContinousLegends/SW.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.js +39 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js +31 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.js +31 -0
- package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.js +34 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.js +45 -0
- package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.js +34 -0
- package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.js.map +1 -0
- package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.js +44 -0
- package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.js.map +1 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.d.ts +7 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.js +33 -0
- package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import React from "react";
|
|
13
2
|
import { ContinuousLegend, } from "../../component/Legend/ContinuousLegend";
|
|
14
3
|
export default {
|
|
15
4
|
component: ContinuousLegend,
|
|
16
5
|
title: "Legends / ContinuousLegend",
|
|
17
6
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const min = 0;
|
|
8
|
+
const max = 1;
|
|
9
|
+
const dataObjectName = "Physics color map";
|
|
10
|
+
const colorName = "Physics";
|
|
11
|
+
const DEFAULT_ARGS = {
|
|
23
12
|
min: min,
|
|
24
13
|
max: max,
|
|
25
14
|
isRangeShown: true,
|
|
@@ -28,15 +17,15 @@ var DEFAULT_ARGS = {
|
|
|
28
17
|
numberOfTicks: 3,
|
|
29
18
|
legendScaleSize: 300,
|
|
30
19
|
};
|
|
31
|
-
|
|
32
|
-
return React.createElement(ContinuousLegend,
|
|
20
|
+
const Story = (args) => {
|
|
21
|
+
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
33
22
|
};
|
|
34
|
-
export
|
|
35
|
-
StandardColorTableLibrary.args =
|
|
36
|
-
export
|
|
37
|
-
DefaultColorTable.args =
|
|
38
|
-
export
|
|
39
|
-
return (React.createElement(ContinuousLegend,
|
|
23
|
+
export const StandardColorTableLibrary = Story.bind({});
|
|
24
|
+
StandardColorTableLibrary.args = Object.assign(Object.assign({}, DEFAULT_ARGS), { dataObjectName: dataObjectName, colorName: colorName });
|
|
25
|
+
export const DefaultColorTable = Story.bind({});
|
|
26
|
+
DefaultColorTable.args = Object.assign(Object.assign({}, DEFAULT_ARGS), { dataObjectName: "Default color table (Rainbow)" });
|
|
27
|
+
export const BackgroundColor = () => {
|
|
28
|
+
return (React.createElement(ContinuousLegend, Object.assign({}, DEFAULT_ARGS, { dataObjectName: dataObjectName, cssLegendStyles: {
|
|
40
29
|
backgroundColor: "red",
|
|
41
30
|
} })));
|
|
42
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContinuousLegend.stories.js","sourceRoot":"","sources":["../../../src/component/Legend/ContinuousLegend.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContinuousLegend.stories.js","sourceRoot":"","sources":["../../../src/component/Legend/ContinuousLegend.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,gBAAgB,GAEjB,MAAM,yCAAyC,CAAC;AAEjD,eAAe;IACb,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,MAAM,YAAY,GAA0B;IAC1C,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,CAAC;IAChB,eAAe,EAAE,GAAG;CACrB,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,IAA2B,EAAE,EAAE;IAC5C,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxD,yBAAyB,CAAC,IAAI,mCACzB,YAAY,KACf,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,GACrB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChD,iBAAiB,CAAC,IAAI,mCACjB,YAAY,KACf,cAAc,EAAE,+BAA+B,GAChD,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,OAAO,CACL,oBAAC,gBAAgB,oBACX,YAAY,IAChB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE;YACf,eAAe,EAAE,KAAK;SACvB,IACD,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ColorTableArray } from "../colorTableTypes";
|
|
3
3
|
export type DiscreteCodes = Record<string, [number[], number]>;
|
|
4
4
|
export type DiscreteColorLegendProps = {
|
|
5
5
|
/**
|
|
@@ -35,7 +35,7 @@ export type DiscreteColorLegendProps = {
|
|
|
35
35
|
*
|
|
36
36
|
* Reference: https://github.com/emerson-eps/color-tables/blob/main/react-app/src/component/color-tables.json
|
|
37
37
|
*/
|
|
38
|
-
colorTables?:
|
|
38
|
+
colorTables?: ColorTableArray | string;
|
|
39
39
|
/**
|
|
40
40
|
* Font size of legend name (in px)
|
|
41
41
|
*/
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,33 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
8
|
});
|
|
20
9
|
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
10
|
import * as React from "react";
|
|
49
11
|
import { useRef } from "react";
|
|
50
12
|
import { select } from "d3";
|
|
@@ -53,12 +15,11 @@ import { colorsArray, RGBToHex } from "../Utils/legendCommonFunction";
|
|
|
53
15
|
import { d3ColorScales } from "../Utils/d3ColorScale";
|
|
54
16
|
import defaultColorTables from "../color-tables.json";
|
|
55
17
|
import { DEFAULT_STYLE } from "./constants";
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var legendHeight;
|
|
18
|
+
export const DiscreteColorLegend = ({ discreteData, dataObjectName, colorName = "Stratigraphy", horizontal, getColorScaleData, id, colorTables = defaultColorTables, legendFontSize, tickFontSize, numberOfTicks, legendScaleSize = 200, cssLegendStyles = DEFAULT_STYLE, }) => {
|
|
19
|
+
const generateUniqueId = Math.ceil(Math.random() * 9999).toString();
|
|
20
|
+
const divRef = useRef(null);
|
|
21
|
+
let legendWidth;
|
|
22
|
+
let legendHeight;
|
|
62
23
|
if (horizontal) {
|
|
63
24
|
legendHeight = "30px";
|
|
64
25
|
if (legendScaleSize < 200) {
|
|
@@ -77,151 +38,140 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
77
38
|
legendHeight = legendScaleSize - 10;
|
|
78
39
|
}
|
|
79
40
|
}
|
|
80
|
-
React.useEffect(
|
|
41
|
+
React.useEffect(() => {
|
|
81
42
|
if (divRef.current) {
|
|
82
43
|
select(divRef.current).select("div").remove();
|
|
83
44
|
select(divRef.current).select("svg").remove();
|
|
84
45
|
discreteLegend();
|
|
85
46
|
}
|
|
86
47
|
function discreteLegend() {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var key = value[0];
|
|
129
|
-
var val = value[1];
|
|
130
|
-
var code = val[1];
|
|
131
|
-
// for colortable colors
|
|
132
|
-
if (arrayOfColors_1.length > 0) {
|
|
133
|
-
//compare the first value in colorarray(colortable) and code from discreteData
|
|
134
|
-
var matchedColorsArrays = arrayOfColors_1.find(function (value) {
|
|
135
|
-
return value[0] === code;
|
|
136
|
-
});
|
|
137
|
-
if (matchedColorsArrays)
|
|
138
|
-
itemColor.push({
|
|
139
|
-
color: RGBToHex(matchedColorsArrays).color,
|
|
140
|
-
name: key,
|
|
141
|
-
});
|
|
142
|
-
itemName.push(key);
|
|
143
|
-
}
|
|
144
|
-
// for d3 colors
|
|
145
|
-
else {
|
|
146
|
-
var matchedColorsArrays = d3ColorArrays_1.find(function (_value, index) {
|
|
147
|
-
return index === code;
|
|
148
|
-
});
|
|
149
|
-
if (matchedColorsArrays)
|
|
150
|
-
itemColor.push({ color: matchedColorsArrays });
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
// Discrete legend using Colortable colors (color selector component)
|
|
155
|
-
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
|
|
156
|
-
getColorScaleData.color.forEach(function (key) {
|
|
157
|
-
itemColor.push({ color: RGBToHex(key).color });
|
|
158
|
-
});
|
|
159
|
-
useSelectorLegend = true;
|
|
160
|
-
}
|
|
161
|
-
// Discrete legend using d3 colors
|
|
162
|
-
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.colorsObject) {
|
|
163
|
-
getColorScaleData.colorsObject.forEach(function (key) {
|
|
164
|
-
itemColor.push({ color: key });
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
let dataSet;
|
|
50
|
+
let useSelectorLegend = false;
|
|
51
|
+
let itemName = [];
|
|
52
|
+
const itemColor = [];
|
|
53
|
+
try {
|
|
54
|
+
// fix for dash wrapper
|
|
55
|
+
if (typeof colorTables === "string") {
|
|
56
|
+
const res = yield fetch(colorTables);
|
|
57
|
+
dataSet = yield res.json();
|
|
58
|
+
}
|
|
59
|
+
const arrayOfColors = typeof colorTables === "string"
|
|
60
|
+
? colorsArray(colorName, dataSet)
|
|
61
|
+
: colorsArray(colorName, colorTables);
|
|
62
|
+
const d3ColorArrays = colorsArray(colorName, d3ColorScales);
|
|
63
|
+
// temporary fix, will be removed later
|
|
64
|
+
const defaultDiscreteData = {
|
|
65
|
+
discrete_1: [[], 0],
|
|
66
|
+
discrete_2: [[], 1],
|
|
67
|
+
discrete_3: [[], 2],
|
|
68
|
+
discrete_4: [[], 3],
|
|
69
|
+
discrete_5: [[], 4],
|
|
70
|
+
discrete_6: [[], 5],
|
|
71
|
+
discrete_7: [[], 6],
|
|
72
|
+
discrete_8: [[], 7],
|
|
73
|
+
discrete_9: [[], 8],
|
|
74
|
+
discrete_10: [[], 9],
|
|
75
|
+
};
|
|
76
|
+
// Main single discrete legend
|
|
77
|
+
if (!getColorScaleData || getColorScaleData.length === 0) {
|
|
78
|
+
const entries = Object.entries(discreteData ? discreteData : defaultDiscreteData);
|
|
79
|
+
const sorted = entries.sort((a, b) => a[1][1] - b[1][1]);
|
|
80
|
+
sorted.forEach((value) => {
|
|
81
|
+
const key = value[0];
|
|
82
|
+
const val = value[1];
|
|
83
|
+
const code = val[1];
|
|
84
|
+
// for colortable colors
|
|
85
|
+
if (arrayOfColors.length > 0) {
|
|
86
|
+
//compare the first value in colorarray(colortable) and code from discreteData
|
|
87
|
+
const matchedColorsArrays = arrayOfColors.find((value) => {
|
|
88
|
+
return value[0] === code;
|
|
165
89
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (!useSelectorLegend) {
|
|
173
|
-
totalRect = itemColor.length;
|
|
90
|
+
if (matchedColorsArrays)
|
|
91
|
+
itemColor.push({
|
|
92
|
+
color: RGBToHex(matchedColorsArrays).color,
|
|
93
|
+
name: key,
|
|
94
|
+
});
|
|
95
|
+
itemName.push(key);
|
|
174
96
|
}
|
|
175
|
-
//
|
|
97
|
+
// for d3 colors
|
|
176
98
|
else {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
else {
|
|
183
|
-
totalRect = getColorScaleData.colorsObject.length;
|
|
184
|
-
}
|
|
99
|
+
const matchedColorsArrays = d3ColorArrays.find((_value, index) => {
|
|
100
|
+
return index === code;
|
|
101
|
+
});
|
|
102
|
+
if (matchedColorsArrays)
|
|
103
|
+
itemColor.push({ color: matchedColorsArrays });
|
|
185
104
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
error_1 = _a.sent();
|
|
220
|
-
console.error(error_1);
|
|
221
|
-
return [3 /*break*/, 6];
|
|
222
|
-
case 6: return [2 /*return*/];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// Discrete legend using Colortable colors (color selector component)
|
|
108
|
+
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
|
|
109
|
+
getColorScaleData.color.forEach((key) => {
|
|
110
|
+
itemColor.push({ color: RGBToHex(key).color });
|
|
111
|
+
});
|
|
112
|
+
useSelectorLegend = true;
|
|
113
|
+
}
|
|
114
|
+
// Discrete legend using d3 colors
|
|
115
|
+
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.colorsObject) {
|
|
116
|
+
getColorScaleData.colorsObject.forEach((key) => {
|
|
117
|
+
itemColor.push({ color: key });
|
|
118
|
+
});
|
|
119
|
+
itemName = getColorScaleData.legendColorName;
|
|
120
|
+
useSelectorLegend = true;
|
|
121
|
+
}
|
|
122
|
+
const colorLegend = discreteLegendUtil(itemColor, useSelectorLegend, horizontal);
|
|
123
|
+
let totalRect;
|
|
124
|
+
// Style for main horizontal legend
|
|
125
|
+
if (!useSelectorLegend) {
|
|
126
|
+
totalRect = itemColor.length;
|
|
127
|
+
}
|
|
128
|
+
// Style for color selector legend
|
|
129
|
+
else {
|
|
130
|
+
// calculate width for legend using colortable colors
|
|
131
|
+
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
|
|
132
|
+
totalRect = getColorScaleData.color.length;
|
|
133
|
+
}
|
|
134
|
+
// calculate width for legend using d3 colors
|
|
135
|
+
else {
|
|
136
|
+
totalRect = getColorScaleData.colorsObject.length;
|
|
137
|
+
}
|
|
223
138
|
}
|
|
224
|
-
|
|
139
|
+
const currentDiv = select(divRef.current);
|
|
140
|
+
// append the title
|
|
141
|
+
currentDiv
|
|
142
|
+
.append("div")
|
|
143
|
+
.text(dataObjectName)
|
|
144
|
+
.style("color", "grey")
|
|
145
|
+
.style("white-space", "nowrap")
|
|
146
|
+
.style("overflow", "hidden")
|
|
147
|
+
.style("width", "150px")
|
|
148
|
+
.style("text-overflow", "ellipsis")
|
|
149
|
+
.style("margin-bottom", horizontal ? "5px" : "0px")
|
|
150
|
+
.style("font-size", legendFontSize && legendFontSize > 0
|
|
151
|
+
? `${legendFontSize}px`
|
|
152
|
+
: "16px")
|
|
153
|
+
.style("transform", horizontal ? "none" : "translate(-69px, 80px) rotate(270deg)");
|
|
154
|
+
// Append svg to the div
|
|
155
|
+
const svgLegend = currentDiv
|
|
156
|
+
.style("margin", horizontal ? "5px 0px 0px 15px" : "0px 5px 0px 5px")
|
|
157
|
+
.style("width", legendWidth)
|
|
158
|
+
.append("svg")
|
|
159
|
+
.call(colorLegend);
|
|
160
|
+
svgLegend
|
|
161
|
+
.attr("viewBox", horizontal ? `0 0 ${totalRect} 1.5` : `0 0 2 ${totalRect}`)
|
|
162
|
+
.attr("preserveAspectRatio", "none")
|
|
163
|
+
.style("font-size", ".4")
|
|
164
|
+
.style("margin-left", horizontal ? "0" : "20px")
|
|
165
|
+
.attr("height", legendHeight)
|
|
166
|
+
.attr("width", horizontal
|
|
167
|
+
? legendScaleSize < 200
|
|
168
|
+
? 190
|
|
169
|
+
: legendScaleSize - 10
|
|
170
|
+
: "40px");
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error(error);
|
|
174
|
+
}
|
|
225
175
|
});
|
|
226
176
|
}
|
|
227
177
|
}, [
|
|
@@ -238,7 +188,7 @@ export var DiscreteColorLegend = function (_a) {
|
|
|
238
188
|
legendWidth,
|
|
239
189
|
legendHeight,
|
|
240
190
|
]);
|
|
241
|
-
return (React.createElement("div", { style:
|
|
242
|
-
React.createElement("div", { id: id ? id :
|
|
191
|
+
return (React.createElement("div", { style: Object.assign({ position: "absolute", minHeight: "70px", borderRadius: "5px", zIndex: 999, margin: "10px" }, cssLegendStyles) },
|
|
192
|
+
React.createElement("div", { id: id ? id : `disc-legend - ${generateUniqueId}`, ref: divRef })));
|
|
243
193
|
};
|
|
244
194
|
//# sourceMappingURL=DiscreteLegend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,OAAO,kBAAkC,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA4D5C,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,YAAY,EACZ,cAAc,EACd,SAAS,GAAG,cAAc,EAC1B,UAAU,EACV,iBAAiB,EACjB,EAAE,EACF,WAAW,GAAG,kBAAqC,EACnD,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,GAAG,GAAG,EACrB,eAAe,GAAG,aAAa,GACN,EAAE,EAAE;IAC7B,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpE,MAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE5C,IAAI,WAA4B,CAAC;IACjC,IAAI,YAA6B,CAAC;IAElC,IAAI,UAAU,EAAE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QACX,UAAU;QACV,iBAAiB;QACjB,cAAc;QACd,cAAc;QACd,YAAY;QACZ,aAAa;QACb,eAAe;QACf,WAAW;QACX,YAAY;KACb,CAAC,CAAC;IAEH,OAAO,CACL,6BACE,KAAK,kBACH,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,EACnB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,MAAM,IACX,eAAe;QAGpB,6BACE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,gBAAgB,EAAE,EACjD,GAAG,EAAE,MAAM,GACN,CACH,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import React from "react";
|
|
13
2
|
import { DiscreteColorLegend, } from "./DiscreteLegend";
|
|
14
3
|
export default {
|
|
15
4
|
component: DiscreteColorLegend,
|
|
16
5
|
title: "Legends/DiscreteColorLegend",
|
|
17
6
|
};
|
|
18
|
-
|
|
7
|
+
const discreteData = {
|
|
19
8
|
OS: [[], 0],
|
|
20
9
|
LSF: [[], 1],
|
|
21
10
|
USF: [[], 2],
|
|
@@ -27,26 +16,26 @@ var discreteData = {
|
|
|
27
16
|
MSH: [[], 8],
|
|
28
17
|
CAL: [[], 9],
|
|
29
18
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
discreteData
|
|
35
|
-
dataObjectName
|
|
36
|
-
colorName
|
|
37
|
-
horizontal
|
|
19
|
+
const dataObjectName = "Wells / FACIES";
|
|
20
|
+
const horizontal = true;
|
|
21
|
+
const colorName = "Facies";
|
|
22
|
+
const DEFAULT_ARGS = {
|
|
23
|
+
discreteData,
|
|
24
|
+
dataObjectName,
|
|
25
|
+
colorName,
|
|
26
|
+
horizontal,
|
|
38
27
|
legendScaleSize: 300,
|
|
39
28
|
legendFontSize: 13,
|
|
40
29
|
tickFontSize: 13,
|
|
41
30
|
numberOfTicks: 3,
|
|
42
31
|
};
|
|
43
|
-
|
|
44
|
-
return React.createElement(DiscreteColorLegend,
|
|
32
|
+
const Template = (args) => {
|
|
33
|
+
return React.createElement(DiscreteColorLegend, Object.assign({}, args));
|
|
45
34
|
};
|
|
46
|
-
export
|
|
47
|
-
Facies.args =
|
|
48
|
-
export
|
|
49
|
-
return (React.createElement(DiscreteColorLegend,
|
|
35
|
+
export const Facies = Template.bind({});
|
|
36
|
+
Facies.args = Object.assign({}, DEFAULT_ARGS);
|
|
37
|
+
export const BackgroundColor = () => {
|
|
38
|
+
return (React.createElement(DiscreteColorLegend, Object.assign({}, DEFAULT_ARGS, { dataObjectName: dataObjectName, cssLegendStyles: {
|
|
50
39
|
backgroundColor: "red",
|
|
51
40
|
} })));
|
|
52
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscreteLegend.stories.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.stories.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DiscreteLegend.stories.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAEL,mBAAmB,GAEpB,MAAM,kBAAkB,CAAC;AAE1B,eAAe;IACb,SAAS,EAAE,mBAAmB;IAC9B,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF,MAAM,YAAY,GAAkB;IAClC,EA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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/component/Legend/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/component/Legend/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,KAAK;IACV,eAAe,EAAE,WAAW;IAC5B,YAAY,EAAE,KAAK;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/Legend/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d3ColorScale.js","sourceRoot":"","sources":["../../../src/component/Utils/d3ColorScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"d3ColorScale.js","sourceRoot":"","sources":["../../../src/component/Utils/d3ColorScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,mBAAmB;KAC/B;IACD;QACE,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,iBAAiB;KAC7B;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,eAAe;KAC3B;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,eAAe;KAC3B;IACD;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,kBAAkB;KAC9B;IACD;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,EAAE,CAAC,kBAAkB;KAC9B;IACD;QACE,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,WAAW;KACvB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,YAAY;KACxB;IACD;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,aAAa;KACzB;IACD;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,aAAa;KACzB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,UAAU;KACtB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,UAAU;KACtB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,UAAU;KACtB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,eAAe;KAC3B;IACD;QACE,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,CAAC,gBAAgB;KAC5B;CACF,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export type NamedColor = {
|
|
2
2
|
color: string;
|
|
3
3
|
name?: string;
|
|
4
4
|
};
|
|
5
|
-
export default function discreteLegendUtil(itemColor:
|
|
6
|
-
export {};
|
|
5
|
+
export default function discreteLegendUtil(itemColor: NamedColor[], isSelectorLegend?: boolean, horizontal?: boolean): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,
|
|
1
|
+
{"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAuB,EACvB,gBAA0B,EAC1B,UAAoB;IAEpB,SAAS,MAAM,CAAC,CAAM;QACpB,SAAS,UAAU;YACjB,yBAAyB;YACzB,oCAAoC;YACpC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;iBACzB,IAAI,CAAC,SAAS,CAAC;iBACf,KAAK,EAAE;iBACP,MAAM,CAAC,GAAG,CAAC;iBACX,MAAM,CAAC,MAAM,CAAC;iBACd,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,UAAU,CAA0B;gBACxC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC;iBACD,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;iBAC1B,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAClC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;iBAChB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;iBACjB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;iBAChB,KAAK,CAAC,MAAM,EAAE,UAAU,CAA0B;gBACjD,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;YACL,IACE,CAAC,UAAU,IAAI,CAAC,gBAAgB,CAAC;gBACjC,CAAC,UAAU,KAAK,IAAI,IAA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