@perses-dev/components 0.44.0-rc2 → 0.45.0-rc0
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/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.d.ts +3 -0
- package/dist/LinksEditor/LinksEditor.d.ts.map +1 -0
- package/dist/LinksEditor/LinksEditor.js +163 -0
- package/dist/LinksEditor/LinksEditor.js.map +1 -0
- package/dist/LinksEditor/index.d.ts +2 -0
- package/dist/LinksEditor/index.d.ts.map +1 -0
- package/dist/LinksEditor/index.js +15 -0
- package/dist/LinksEditor/index.js.map +1 -0
- package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.d.ts +6 -0
- package/dist/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -0
- package/dist/ToolbarIconButton/ToolbarIconButton.js +32 -0
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -0
- package/dist/ToolbarIconButton/index.d.ts +2 -0
- package/dist/ToolbarIconButton/index.d.ts.map +1 -0
- package/dist/ToolbarIconButton/index.js +15 -0
- package/dist/ToolbarIconButton/index.js.map +1 -0
- package/dist/cjs/ColorPicker/ColorPicker.js +1 -1
- package/dist/cjs/LinksEditor/LinksEditor.js +217 -0
- package/dist/cjs/LinksEditor/index.js +30 -0
- package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +1 -1
- package/dist/cjs/ToolbarIconButton/ToolbarIconButton.js +40 -0
- package/dist/cjs/ToolbarIconButton/index.js +30 -0
- package/dist/cjs/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -42,7 +42,7 @@ export const ColorPicker = ({ color, onChange, palette })=>{
|
|
|
42
42
|
direction: "row",
|
|
43
43
|
flexWrap: "wrap",
|
|
44
44
|
justifyContent: "space-evenly",
|
|
45
|
-
width:
|
|
45
|
+
width: "200px",
|
|
46
46
|
children: palette && palette.map((color, i)=>/*#__PURE__*/ _jsx(IconButton, {
|
|
47
47
|
size: "small",
|
|
48
48
|
"aria-label": `change color to ${color}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Stack, TextField } from '@mui/material';\nimport React, { useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport CircleIcon from 'mdi-material-ui/Circle';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, palette }: ColorPickerProps) => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string) => {\n setValue(color);\n onChange && onChange(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);\n setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format\n // only set color if input value is a valid hex color\n if (isValidHex(e.target.value)) {\n onChange && onChange(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} />\n <Stack direction=\"row\" flexWrap=\"wrap\" justifyContent=\"space-evenly\" width
|
|
1
|
+
{"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Stack, TextField } from '@mui/material';\nimport React, { useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\nimport CircleIcon from 'mdi-material-ui/Circle';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, palette }: ColorPickerProps) => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string) => {\n setValue(color);\n onChange && onChange(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);\n setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format\n // only set color if input value is a valid hex color\n if (isValidHex(e.target.value)) {\n onChange && onChange(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} />\n <Stack direction=\"row\" flexWrap=\"wrap\" justifyContent=\"space-evenly\" width=\"200px\">\n {palette &&\n palette.map((color, i) => (\n <IconButton\n key={i}\n size=\"small\"\n aria-label={`change color to ${color}`}\n sx={{ color }}\n onClick={() => handleColorChange(color)}\n >\n <CircleIcon />\n </IconButton>\n ))}\n </Stack>\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n </Stack>\n );\n};\n\nconst isValidHex = (value: string, alpha?: boolean): boolean => {\n const matcher = /^#?([0-9A-F]{3,8})$/i;\n const match = matcher.exec(value);\n const length = match && match[1] ? match[1].length : 0;\n return (\n length === 3 || // '#rgb' format\n length === 6 || // '#rrggbb' format\n (!!alpha && length === 4) || // '#rgba' format\n (!!alpha && length === 8) // '#rrggbbaa' format\n );\n};\n"],"names":["IconButton","Stack","TextField","React","useState","HexColorPicker","CircleIcon","ColorPicker","color","onChange","palette","value","setValue","handleColorChange","handleInputChange","e","inputValue","target","replace","substring","isValidHex","spacing","direction","flexWrap","justifyContent","width","map","i","size","aria-label","sx","onClick","inputProps","fullWidth","alpha","matcher","match","exec","length"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC7D,OAAOC,SAASC,QAAQ,QAAQ,QAAQ;AACxC,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAOC,gBAAgB,yBAAyB;AAWhD,OAAO,MAAMC,cAAc,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAoB;IACxE,2DAA2D;IAC3D,MAAM,CAACC,OAAOC,SAAS,GAAGR,SAASI;IAEnC,MAAMK,oBAAoB,CAACL;QACzBI,SAASJ;QACTC,YAAYA,SAASD;IACvB;IAEA,6FAA6F;IAC7F,MAAMM,oBAAoB,CAACC;QACzB,MAAMC,aAAaD,EAAEE,MAAM,CAACN,KAAK,CAACO,OAAO,CAAC,kBAAkB,IAAIC,SAAS,CAAC,GAAG;QAC7EP,SAAS,CAAC,CAAC,EAAEI,WAAW,CAAC,GAAG,0DAA0D;QACtF,qDAAq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@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import React, { Fragment } from 'react';
|
|
15
|
+
import { Checkbox, Divider, FormControlLabel, IconButton, Stack, TextField, Typography } from '@mui/material';
|
|
16
|
+
import { Controller, useFieldArray } from 'react-hook-form';
|
|
17
|
+
import PlusIcon from 'mdi-material-ui/Plus';
|
|
18
|
+
import MinusIcon from 'mdi-material-ui/Minus';
|
|
19
|
+
export function LinksEditor({ ...props }) {
|
|
20
|
+
const { fields, append, remove } = useFieldArray({
|
|
21
|
+
name: 'links'
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
24
|
+
...props,
|
|
25
|
+
gap: 3,
|
|
26
|
+
children: [
|
|
27
|
+
fields && fields.length > 0 ? fields.map((field, index)=>/*#__PURE__*/ _jsxs(Fragment, {
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
30
|
+
direction: "row",
|
|
31
|
+
gap: 1,
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsx(LinkControl, {
|
|
35
|
+
index: index
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
38
|
+
style: {
|
|
39
|
+
width: 'fit-content',
|
|
40
|
+
height: 'fit-content'
|
|
41
|
+
},
|
|
42
|
+
onClick: ()=>remove(index),
|
|
43
|
+
children: /*#__PURE__*/ _jsx(MinusIcon, {})
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ _jsx(Divider, {})
|
|
48
|
+
]
|
|
49
|
+
}, field.id)) : /*#__PURE__*/ _jsx(Typography, {
|
|
50
|
+
variant: "subtitle1",
|
|
51
|
+
mb: 2,
|
|
52
|
+
fontStyle: "italic",
|
|
53
|
+
children: "No links defined"
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
56
|
+
style: {
|
|
57
|
+
width: 'fit-content',
|
|
58
|
+
height: 'fit-content'
|
|
59
|
+
},
|
|
60
|
+
onClick: ()=>append({
|
|
61
|
+
url: ''
|
|
62
|
+
}),
|
|
63
|
+
children: /*#__PURE__*/ _jsx(PlusIcon, {})
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function LinkControl({ index }) {
|
|
69
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
70
|
+
gap: 2,
|
|
71
|
+
flexGrow: 1,
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
74
|
+
direction: "row",
|
|
75
|
+
gap: 2,
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
78
|
+
name: `links.${index}.url`,
|
|
79
|
+
render: ({ field, fieldState })=>{
|
|
80
|
+
var _fieldState_error;
|
|
81
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
82
|
+
...field,
|
|
83
|
+
required: true,
|
|
84
|
+
fullWidth: true,
|
|
85
|
+
label: "URL",
|
|
86
|
+
error: !!fieldState.error,
|
|
87
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
88
|
+
onChange: (event)=>{
|
|
89
|
+
field.onChange(event);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
95
|
+
name: `links.${index}.name`,
|
|
96
|
+
render: ({ field, fieldState })=>{
|
|
97
|
+
var _fieldState_error;
|
|
98
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
99
|
+
...field,
|
|
100
|
+
fullWidth: true,
|
|
101
|
+
label: "Name",
|
|
102
|
+
defaultValue: "",
|
|
103
|
+
error: !!fieldState.error,
|
|
104
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
105
|
+
onChange: (event)=>{
|
|
106
|
+
field.onChange(event);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
112
|
+
name: `links.${index}.tooltip`,
|
|
113
|
+
render: ({ field, fieldState })=>{
|
|
114
|
+
var _fieldState_error;
|
|
115
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
116
|
+
...field,
|
|
117
|
+
fullWidth: true,
|
|
118
|
+
label: "Tooltip",
|
|
119
|
+
defaultValue: "",
|
|
120
|
+
error: !!fieldState.error,
|
|
121
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
122
|
+
onChange: (event)=>{
|
|
123
|
+
field.onChange(event);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
131
|
+
gap: 2,
|
|
132
|
+
direction: "row",
|
|
133
|
+
alignItems: "center",
|
|
134
|
+
children: [
|
|
135
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
136
|
+
name: `links.${index}.renderVariables`,
|
|
137
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
138
|
+
label: "Render Variables",
|
|
139
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
140
|
+
...field,
|
|
141
|
+
checked: field.value,
|
|
142
|
+
onChange: (e)=>field.onChange(e.target.checked)
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
147
|
+
name: `links.${index}.targetBlank`,
|
|
148
|
+
render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
149
|
+
label: "Open in new tab",
|
|
150
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
151
|
+
...field,
|
|
152
|
+
checked: field.value,
|
|
153
|
+
onChange: (e)=>field.onChange(e.target.checked)
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=LinksEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/LinksEditor/LinksEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { Fragment, HTMLAttributes } from 'react';\nimport { Checkbox, Divider, FormControlLabel, IconButton, Stack, TextField, Typography } from '@mui/material';\nimport { Controller, useFieldArray } from 'react-hook-form';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport MinusIcon from 'mdi-material-ui/Minus';\n\nexport function LinksEditor({ ...props }: HTMLAttributes<HTMLDivElement>) {\n const { fields, append, remove } = useFieldArray({\n name: 'links',\n });\n\n return (\n <Stack {...props} gap={3}>\n {fields && fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <LinkControl index={index} />\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => remove(index)}>\n <MinusIcon />\n </IconButton>\n </Stack>\n <Divider />\n </Fragment>\n ))\n ) : (\n <Typography variant=\"subtitle1\" mb={2} fontStyle=\"italic\">\n No links defined\n </Typography>\n )}\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => append({ url: '' })}>\n <PlusIcon />\n </IconButton>\n </Stack>\n );\n}\n\nfunction LinkControl({ index }: { index: number }) {\n return (\n <Stack gap={2} flexGrow={1}>\n <Stack direction=\"row\" gap={2}>\n <Controller\n name={`links.${index}.url`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"URL\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n <Controller\n name={`links.${index}.name`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Name\"\n defaultValue=\"\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n <Controller\n name={`links.${index}.tooltip`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Tooltip\"\n defaultValue=\"\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Stack>\n <Stack gap={2} direction=\"row\" alignItems=\"center\">\n <Controller\n name={`links.${index}.renderVariables`}\n render={({ field }) => (\n <FormControlLabel\n label=\"Render Variables\"\n control={<Checkbox {...field} checked={field.value} onChange={(e) => field.onChange(e.target.checked)} />}\n />\n )}\n />\n <Controller\n name={`links.${index}.targetBlank`}\n render={({ field }) => (\n <FormControlLabel\n label=\"Open in new tab\"\n control={<Checkbox {...field} checked={field.value} onChange={(e) => field.onChange(e.target.checked)} />}\n />\n )}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["React","Fragment","Checkbox","Divider","FormControlLabel","IconButton","Stack","TextField","Typography","Controller","useFieldArray","PlusIcon","MinusIcon","LinksEditor","props","fields","append","remove","name","gap","length","map","field","index","direction","alignItems","LinkControl","style","width","height","onClick","id","variant","mb","fontStyle","url","flexGrow","render","fieldState","required","fullWidth","label","error","helperText","message","onChange","event","defaultValue","control","checked","value","e","target"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,QAAQ,QAAwB,QAAQ;AACxD,SAASC,QAAQ,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAC9G,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,OAAOC,cAAc,uBAAuB;AAC5C,OAAOC,eAAe,wBAAwB;AAE9C,OAAO,SAASC,YAAY,EAAE,GAAGC,OAAuC;IACtE,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGP,cAAc;QAC/CQ,MAAM;IACR;IAEA,qBACE,MAACZ;QAAO,GAAGQ,KAAK;QAAEK,KAAK;;YACpBJ,UAAUA,OAAOK,MAAM,GAAG,IACzBL,OAAOM,GAAG,CAAC,CAACC,OAAOC,sBACjB,MAACtB;;sCACC,MAACK;4BAAMkB,WAAU;4BAAML,KAAK;4BAAGM,YAAW;;8CACxC,KAACC;oCAAYH,OAAOA;;8CACp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,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './LinksEditor';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/LinksEditor/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './LinksEditor';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB"}
|
|
@@ -153,7 +153,7 @@ export function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePer
|
|
|
153
153
|
return /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
|
|
154
154
|
title: "Thresholds",
|
|
155
155
|
icon: /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
156
|
-
description:
|
|
156
|
+
description: "Add threshold",
|
|
157
157
|
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
158
158
|
size: "small",
|
|
159
159
|
"aria-label": "add threshold",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport produce from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps) {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;\n\n const [steps, setSteps] = useState(thresholds?.steps);\n useEffect(() => {\n setSteps(thresholds?.steps);\n }, [thresholds?.steps]);\n\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number) => {\n setSteps(\n produce(steps, (draft) => {\n const step = draft?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n };\n\n const handleThresholdColorChange = (color: string, i: number) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.defaultColor = color;\n })\n );\n } else {\n onChange({\n defaultColor: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = () => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n })\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'percent' ? 'percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description={'Add threshold'}>\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <ThresholdColorPicker\n label=\"default\"\n color={defaultThresholdColor}\n onColorChange={handleDefaultColorChange}\n />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = () => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","useState","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","useChartsTheme","OptionsEditorControl","OptionsEditorGroup","InfoTooltip","ThresholdColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","steps","setSteps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","draft","step","value","Number","target","handleThresholdColorChange","color","undefined","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC3D,OAAOC,aAAa,QAAQ;AAC5B,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,gBAAgB;AACxF,OAAOC,cAAc,uBAAuB;AAC5C,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,yB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AY;oBAAO;;sCAEzC,KAACnE;4BAAa2D,cAAW;4BAAW1B,OAAM;4BAAWgC,IAAI;gCAAEG,YAAY;4BAAI;sCAAG;;sCAG9E,KAACpE;4BAAa2D,cAAW;4BAAU1B,OAAM;4BAAUgC,IAAI;gCAAEG,YAAY;4BAAI;sCAAG;;;;;YAMjF/C,SACCA,MACGgD,GAAG,CAAC,CAACrC,MAAMF;oBAKDE,aAAAA;uBAJT,KAACtB;oBACC4D,UAAUxC,MAAMT,MAAMM,MAAM,GAAG,IAAIJ,wBAAwBe;oBAE3DuB,OAAO,CAAC,CAAC,EAAE/B,IAAI,EAAE,CAAC;oBAClBO,OAAOL,CAAAA,OAAAA,CAAAA,cAAAA,KAAKK,KAAK,cAAVL,yBAAAA,cAAcb,OAAO,CAACW,EAAE,cAAxBE,kBAAAA,OAA4BZ;oBACnCa,OAAOD,KAAKC,KAAK;oBACjBqB,IAAI,EAAEzC,uBAAAA,iCAAAA,WAAYyC,IAAI;oBACtBiB,eAAe,CAAClC,QAAUD,2BAA2BC,OAAOP;oBAC5DhB,UAAU,CAACe;wBACTD,2BAA2BC,GAAGC;oBAChC;oBACA0C,UAAU;wBACR3B,gBAAgBf;oBAClB;oBACA2C,QAAQjC;mBAZHV;YAaN,GAEF4C,OAAO;YACX,CAAC3D,6BACA,MAACX;gBAAMuE,MAAM;gBAAGC,WAAU;gBAAMC,YAAW;gBAASC,SAAS;;kCAC3D,KAACrE;wBACCoD,OAAM;wBACNxB,OAAOjB;wBACPmD,eAAehC;;kCAEjB,KAACrC;kCAAW;;;;;;AAKtB;AAEA,iEAAiE;AACjE,MAAMgD,iBAAiB;IACrB,OACE,MACA6B,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAK,UACxBC,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG;AAEnB"}
|
|
1
|
+
{"version":3,"sources":["../../src/ThresholdsEditor/ThresholdsEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport produce from 'immer';\nimport { IconButton, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { Stack } from '@mui/system';\nimport { ThresholdOptions } from '@perses-dev/core';\nimport { useChartsTheme } from '../context/ChartsProvider';\nimport { OptionsEditorControl, OptionsEditorGroup } from '../OptionsEditorLayout';\nimport { InfoTooltip } from '../InfoTooltip';\nimport { ThresholdColorPicker } from './ThresholdColorPicker';\nimport { ThresholdInput } from './ThresholdInput';\n\nexport interface ThresholdsEditorProps {\n onChange: (thresholds: ThresholdOptions) => void;\n thresholds?: ThresholdOptions;\n hideDefault?: boolean;\n disablePercentMode?: boolean;\n}\n\nconst DEFAULT_STEP = 10;\n\nexport function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMode }: ThresholdsEditorProps) {\n const chartsTheme = useChartsTheme();\n const {\n thresholds: { defaultColor, palette },\n } = chartsTheme;\n const defaultThresholdColor = thresholds?.defaultColor ?? defaultColor;\n\n const [steps, setSteps] = useState(thresholds?.steps);\n useEffect(() => {\n setSteps(thresholds?.steps);\n }, [thresholds?.steps]);\n\n // every time a new threshold is added, we want to focus the recently added input\n const recentlyAddedInputRef = useRef<HTMLInputElement | null>(null);\n const focusRef = useRef(false);\n useEffect(() => {\n if (!recentlyAddedInputRef.current || !focusRef.current) return;\n recentlyAddedInputRef.current?.focus();\n focusRef.current = false;\n }, [steps?.length]);\n\n const handleThresholdValueChange = (e: React.ChangeEvent<HTMLInputElement>, i: number) => {\n setSteps(\n produce(steps, (draft) => {\n const step = draft?.[i];\n if (step) {\n step.value = Number(e.target.value);\n }\n })\n );\n };\n\n const handleThresholdColorChange = (color: string, i: number) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n if (draft.steps !== undefined) {\n const step = draft.steps[i];\n if (step) {\n step.color = color;\n }\n }\n })\n );\n }\n };\n\n const handleDefaultColorChange = (color: string) => {\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.defaultColor = color;\n })\n );\n } else {\n onChange({\n defaultColor: color,\n });\n }\n };\n\n // sort thresholds in ascending order every time an input blurs\n const handleThresholdBlur = () => {\n if (steps !== undefined) {\n const sortedSteps = [...steps];\n sortedSteps.sort((a, b) => a.value - b.value);\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = sortedSteps;\n })\n );\n }\n }\n };\n\n const deleteThreshold = (i: number): void => {\n if (thresholds !== undefined) {\n const updatedThresholds = produce(thresholds, (draft) => {\n if (draft.steps) {\n draft.steps.splice(i, 1);\n }\n });\n onChange(updatedThresholds);\n }\n };\n\n const addThresholdInput = (): void => {\n focusRef.current = true;\n if (thresholds === undefined) {\n onChange({\n steps: [{ value: DEFAULT_STEP }],\n });\n } else if (thresholds && thresholds.steps === undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.steps = [{ value: DEFAULT_STEP }];\n })\n );\n } else {\n onChange(\n produce(thresholds, (draft) => {\n const steps = draft.steps;\n if (steps?.length) {\n const lastStep = steps[steps.length - 1];\n const color = palette[steps.length] ?? getRandomColor(); // we will assign color from the palette first, then generate random color\n steps.push({ color, value: (lastStep?.value ?? 0) + DEFAULT_STEP }); // set new threshold value to last step value + 10\n } else if (steps) {\n steps.push({ value: DEFAULT_STEP });\n }\n })\n );\n }\n };\n\n const handleModeChange = (event: React.MouseEvent, value: string): void => {\n const mode = value === 'percent' ? 'percent' : undefined;\n if (thresholds !== undefined) {\n onChange(\n produce(thresholds, (draft) => {\n draft.mode = mode;\n })\n );\n } else {\n onChange({ mode });\n }\n };\n\n return (\n <OptionsEditorGroup\n title=\"Thresholds\"\n icon={\n <InfoTooltip description=\"Add threshold\">\n <IconButton size=\"small\" aria-label=\"add threshold\" onClick={addThresholdInput}>\n <PlusIcon />\n </IconButton>\n </InfoTooltip>\n }\n >\n <OptionsEditorControl\n label=\"Mode\"\n description=\"Percentage means thresholds relative to min & max\"\n control={\n <ToggleButtonGroup\n exclusive\n disabled={disablePercentMode}\n value={thresholds?.mode ?? 'absolute'}\n onChange={handleModeChange}\n sx={{ height: '36px', marginLeft: 'auto' }}\n >\n <ToggleButton aria-label=\"absolute\" value=\"absolute\" sx={{ fontWeight: 500 }}>\n Absolute\n </ToggleButton>\n <ToggleButton aria-label=\"percent\" value=\"percent\" sx={{ fontWeight: 500 }}>\n Percent\n </ToggleButton>\n </ToggleButtonGroup>\n }\n />\n {steps &&\n steps\n .map((step, i) => (\n <ThresholdInput\n inputRef={i === steps.length - 1 ? recentlyAddedInputRef : undefined}\n key={i}\n label={`T${i + 1}`}\n color={step.color ?? palette[i] ?? defaultThresholdColor}\n value={step.value}\n mode={thresholds?.mode}\n onColorChange={(color) => handleThresholdColorChange(color, i)}\n onChange={(e) => {\n handleThresholdValueChange(e, i);\n }}\n onDelete={() => {\n deleteThreshold(i);\n }}\n onBlur={handleThresholdBlur}\n />\n ))\n .reverse()}\n {!hideDefault && (\n <Stack flex={1} direction=\"row\" alignItems=\"center\" spacing={1}>\n <ThresholdColorPicker\n label=\"default\"\n color={defaultThresholdColor}\n onColorChange={handleDefaultColorChange}\n />\n <Typography>Default</Typography>\n </Stack>\n )}\n </OptionsEditorGroup>\n );\n}\n\n// https://www.paulirish.com/2009/random-hex-color-code-snippets/\nconst getRandomColor = () => {\n return (\n '#' +\n Math.floor(Math.random() * 16777216)\n .toString(16)\n .padStart(6, '0')\n );\n};\n"],"names":["React","useEffect","useRef","useState","produce","IconButton","ToggleButton","ToggleButtonGroup","Typography","PlusIcon","Stack","useChartsTheme","OptionsEditorControl","OptionsEditorGroup","InfoTooltip","ThresholdColorPicker","ThresholdInput","DEFAULT_STEP","ThresholdsEditor","thresholds","onChange","hideDefault","disablePercentMode","chartsTheme","defaultColor","palette","defaultThresholdColor","steps","setSteps","recentlyAddedInputRef","focusRef","current","focus","length","handleThresholdValueChange","e","i","draft","step","value","Number","target","handleThresholdColorChange","color","undefined","handleDefaultColorChange","handleThresholdBlur","sortedSteps","sort","a","b","deleteThreshold","updatedThresholds","splice","addThresholdInput","lastStep","getRandomColor","push","handleModeChange","event","mode","title","icon","description","size","aria-label","onClick","label","control","exclusive","disabled","sx","height","marginLeft","fontWeight","map","inputRef","onColorChange","onDelete","onBlur","reverse","flex","direction","alignItems","spacing","Math","floor","random","toString","padStart"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC3D,OAAOC,aAAa,QAAQ;AAC5B,SAASC,UAAU,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,gBAAgB;AACxF,OAAOC,cAAc,uBAAuB;AAC5C,SAASC,KAAK,QAAQ,cAAc;AAEpC,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAClF,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,cAAc,QAAQ,mBAAmB;AASlD,MAAMC,eAAe;AAErB,OAAO,SAASC,iBAAiB,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,kBAAkB,EAAyB;IAC/G,MAAMC,cAAcZ;IACpB,MAAM,EACJQ,YAAY,EAAEK,Y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B;oBACC4D,UAAUxC,MAAMT,MAAMM,MAAM,GAAG,IAAIJ,wBAAwBe;oBAE3DuB,OAAO,CAAC,CAAC,EAAE/B,IAAI,EAAE,CAAC;oBAClBO,OAAOL,CAAAA,OAAAA,CAAAA,cAAAA,KAAKK,KAAK,cAAVL,yBAAAA,cAAcb,OAAO,CAACW,EAAE,cAAxBE,kBAAAA,OAA4BZ;oBACnCa,OAAOD,KAAKC,KAAK;oBACjBqB,IAAI,EAAEzC,uBAAAA,iCAAAA,WAAYyC,IAAI;oBACtBiB,eAAe,CAAClC,QAAUD,2BAA2BC,OAAOP;oBAC5DhB,UAAU,CAACe;wBACTD,2BAA2BC,GAAGC;oBAChC;oBACA0C,UAAU;wBACR3B,gBAAgBf;oBAClB;oBACA2C,QAAQjC;mBAZHV;YAaN,GAEF4C,OAAO;YACX,CAAC3D,6BACA,MAACX;gBAAMuE,MAAM;gBAAGC,WAAU;gBAAMC,YAAW;gBAASC,SAAS;;kCAC3D,KAACrE;wBACCoD,OAAM;wBACNxB,OAAOjB;wBACPmD,eAAehC;;kCAEjB,KAACrC;kCAAW;;;;;;AAKtB;AAEA,iEAAiE;AACjE,MAAMgD,iBAAiB;IACrB,OACE,MACA6B,KAAKC,KAAK,CAACD,KAAKE,MAAM,KAAK,UACxBC,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG;AAEnB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
type ToolbarIconButtonProps = ButtonProps;
|
|
4
|
+
export declare const ToolbarIconButton: import("react").ForwardRefExoticComponent<Omit<ToolbarIconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=ToolbarIconButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarIconButton.d.ts","sourceRoot":"","sources":["../../src/ToolbarIconButton/ToolbarIconButton.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5D,KAAK,sBAAsB,GAAG,WAAW,CAAC;AAa1C,eAAO,MAAM,iBAAiB,mIAAyB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef } from 'react';
|
|
15
|
+
import { Button, styled } from '@mui/material';
|
|
16
|
+
function IconButton(props, ref) {
|
|
17
|
+
return /*#__PURE__*/ _jsx(StyledIconButton, {
|
|
18
|
+
ref: ref,
|
|
19
|
+
variant: "outlined",
|
|
20
|
+
color: "secondary",
|
|
21
|
+
...props
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const StyledIconButton = styled(Button)(({ theme })=>({
|
|
25
|
+
// Using a button with some adjusted styles because it is easier to inherit
|
|
26
|
+
// styling and variants from themes than with an IconButton.
|
|
27
|
+
padding: theme.spacing(0.5),
|
|
28
|
+
minWidth: 'auto'
|
|
29
|
+
}));
|
|
30
|
+
export const ToolbarIconButton = /*#__PURE__*/ forwardRef(IconButton);
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=ToolbarIconButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ToolbarIconButton/ToolbarIconButton.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ForwardedRef, forwardRef } from 'react';\nimport { Button, styled, ButtonProps } from '@mui/material';\n\ntype ToolbarIconButtonProps = ButtonProps;\n\nfunction IconButton(props: ToolbarIconButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n return <StyledIconButton ref={ref} variant=\"outlined\" color=\"secondary\" {...props} />;\n}\n\nconst StyledIconButton = styled(Button)(({ theme }) => ({\n // Using a button with some adjusted styles because it is easier to inherit\n // styling and variants from themes than with an IconButton.\n padding: theme.spacing(0.5),\n minWidth: 'auto',\n}));\n\nexport const ToolbarIconButton = forwardRef(IconButton);\n"],"names":["forwardRef","Button","styled","IconButton","props","ref","StyledIconButton","variant","color","theme","padding","spacing","minWidth","ToolbarIconButton"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,UAAU,QAAQ,QAAQ;AACjD,SAASC,MAAM,EAAEC,MAAM,QAAqB,gBAAgB;AAI5D,SAASC,WAAWC,KAA6B,EAAEC,GAAoC;IACrF,qBAAO,KAACC;QAAiBD,KAAKA;QAAKE,SAAQ;QAAWC,OAAM;QAAa,GAAGJ,KAAK;;AACnF;AAEA,MAAME,mBAAmBJ,OAAOD,QAAQ,CAAC,EAAEQ,KAAK,EAAE,GAAM,CAAA;QACtD,2EAA2E;QAC3E,4DAA4D;QAC5DC,SAASD,MAAME,OAAO,CAAC;QACvBC,UAAU;IACZ,CAAA;AAEA,OAAO,MAAMC,kCAAoBb,WAAWG,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ToolbarIconButton/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './ToolbarIconButton';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ToolbarIconButton/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ToolbarIconButton';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB"}
|
|
@@ -98,7 +98,7 @@ const ColorPicker = ({ color, onChange, palette })=>{
|
|
|
98
98
|
direction: "row",
|
|
99
99
|
flexWrap: "wrap",
|
|
100
100
|
justifyContent: "space-evenly",
|
|
101
|
-
width:
|
|
101
|
+
width: "200px",
|
|
102
102
|
children: palette && palette.map((color, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
103
103
|
size: "small",
|
|
104
104
|
"aria-label": `change color to ${color}`,
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "LinksEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return LinksEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _reacthookform = require("react-hook-form");
|
|
27
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
28
|
+
const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
35
|
+
if (typeof WeakMap !== "function") return null;
|
|
36
|
+
var cacheBabelInterop = new WeakMap();
|
|
37
|
+
var cacheNodeInterop = new WeakMap();
|
|
38
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
39
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
40
|
+
})(nodeInterop);
|
|
41
|
+
}
|
|
42
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
43
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
47
|
+
return {
|
|
48
|
+
default: obj
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
52
|
+
if (cache && cache.has(obj)) {
|
|
53
|
+
return cache.get(obj);
|
|
54
|
+
}
|
|
55
|
+
var newObj = {
|
|
56
|
+
__proto__: null
|
|
57
|
+
};
|
|
58
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
59
|
+
for(var key in obj){
|
|
60
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
62
|
+
if (desc && (desc.get || desc.set)) {
|
|
63
|
+
Object.defineProperty(newObj, key, desc);
|
|
64
|
+
} else {
|
|
65
|
+
newObj[key] = obj[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
newObj.default = obj;
|
|
70
|
+
if (cache) {
|
|
71
|
+
cache.set(obj, newObj);
|
|
72
|
+
}
|
|
73
|
+
return newObj;
|
|
74
|
+
}
|
|
75
|
+
function LinksEditor({ ...props }) {
|
|
76
|
+
const { fields, append, remove } = (0, _reacthookform.useFieldArray)({
|
|
77
|
+
name: 'links'
|
|
78
|
+
});
|
|
79
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
80
|
+
...props,
|
|
81
|
+
gap: 3,
|
|
82
|
+
children: [
|
|
83
|
+
fields && fields.length > 0 ? fields.map((field, index)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
86
|
+
direction: "row",
|
|
87
|
+
gap: 1,
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(LinkControl, {
|
|
91
|
+
index: index
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
94
|
+
style: {
|
|
95
|
+
width: 'fit-content',
|
|
96
|
+
height: 'fit-content'
|
|
97
|
+
},
|
|
98
|
+
onClick: ()=>remove(index),
|
|
99
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {})
|
|
104
|
+
]
|
|
105
|
+
}, field.id)) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
106
|
+
variant: "subtitle1",
|
|
107
|
+
mb: 2,
|
|
108
|
+
fontStyle: "italic",
|
|
109
|
+
children: "No links defined"
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
112
|
+
style: {
|
|
113
|
+
width: 'fit-content',
|
|
114
|
+
height: 'fit-content'
|
|
115
|
+
},
|
|
116
|
+
onClick: ()=>append({
|
|
117
|
+
url: ''
|
|
118
|
+
}),
|
|
119
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function LinkControl({ index }) {
|
|
125
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
126
|
+
gap: 2,
|
|
127
|
+
flexGrow: 1,
|
|
128
|
+
children: [
|
|
129
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
130
|
+
direction: "row",
|
|
131
|
+
gap: 2,
|
|
132
|
+
children: [
|
|
133
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
134
|
+
name: `links.${index}.url`,
|
|
135
|
+
render: ({ field, fieldState })=>{
|
|
136
|
+
var _fieldState_error;
|
|
137
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
138
|
+
...field,
|
|
139
|
+
required: true,
|
|
140
|
+
fullWidth: true,
|
|
141
|
+
label: "URL",
|
|
142
|
+
error: !!fieldState.error,
|
|
143
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
144
|
+
onChange: (event)=>{
|
|
145
|
+
field.onChange(event);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
151
|
+
name: `links.${index}.name`,
|
|
152
|
+
render: ({ field, fieldState })=>{
|
|
153
|
+
var _fieldState_error;
|
|
154
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
155
|
+
...field,
|
|
156
|
+
fullWidth: true,
|
|
157
|
+
label: "Name",
|
|
158
|
+
defaultValue: "",
|
|
159
|
+
error: !!fieldState.error,
|
|
160
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
161
|
+
onChange: (event)=>{
|
|
162
|
+
field.onChange(event);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
168
|
+
name: `links.${index}.tooltip`,
|
|
169
|
+
render: ({ field, fieldState })=>{
|
|
170
|
+
var _fieldState_error;
|
|
171
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
172
|
+
...field,
|
|
173
|
+
fullWidth: true,
|
|
174
|
+
label: "Tooltip",
|
|
175
|
+
defaultValue: "",
|
|
176
|
+
error: !!fieldState.error,
|
|
177
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
178
|
+
onChange: (event)=>{
|
|
179
|
+
field.onChange(event);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
187
|
+
gap: 2,
|
|
188
|
+
direction: "row",
|
|
189
|
+
alignItems: "center",
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
192
|
+
name: `links.${index}.renderVariables`,
|
|
193
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
194
|
+
label: "Render Variables",
|
|
195
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
196
|
+
...field,
|
|
197
|
+
checked: field.value,
|
|
198
|
+
onChange: (e)=>field.onChange(e.target.checked)
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
}),
|
|
202
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
203
|
+
name: `links.${index}.targetBlank`,
|
|
204
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
205
|
+
label: "Open in new tab",
|
|
206
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
207
|
+
...field,
|
|
208
|
+
checked: field.value,
|
|
209
|
+
onChange: (e)=>field.onChange(e.target.checked)
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_export_star(require("./LinksEditor"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
|
@@ -209,7 +209,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
|
|
|
209
209
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_OptionsEditorLayout.OptionsEditorGroup, {
|
|
210
210
|
title: "Thresholds",
|
|
211
211
|
icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InfoTooltip.InfoTooltip, {
|
|
212
|
-
description:
|
|
212
|
+
description: "Add threshold",
|
|
213
213
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
214
214
|
size: "small",
|
|
215
215
|
"aria-label": "add threshold",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "ToolbarIconButton", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return ToolbarIconButton;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
function IconButton(props, ref) {
|
|
27
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledIconButton, {
|
|
28
|
+
ref: ref,
|
|
29
|
+
variant: "outlined",
|
|
30
|
+
color: "secondary",
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const StyledIconButton = (0, _material.styled)(_material.Button)(({ theme })=>({
|
|
35
|
+
// Using a button with some adjusted styles because it is easier to inherit
|
|
36
|
+
// styling and variants from themes than with an IconButton.
|
|
37
|
+
padding: theme.spacing(0.5),
|
|
38
|
+
minWidth: 'auto'
|
|
39
|
+
}));
|
|
40
|
+
const ToolbarIconButton = /*#__PURE__*/ (0, _react.forwardRef)(IconButton);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_export_star(require("./ToolbarIconButton"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -29,6 +29,7 @@ _export_star(require("./InfoTooltip"), exports);
|
|
|
29
29
|
_export_star(require("./JSONEditor"), exports);
|
|
30
30
|
_export_star(require("./Legend"), exports);
|
|
31
31
|
_export_star(require("./LineChart"), exports);
|
|
32
|
+
_export_star(require("./LinksEditor"), exports);
|
|
32
33
|
_export_star(require("./ModeSelector"), exports);
|
|
33
34
|
_export_star(require("./OptionsEditorLayout"), exports);
|
|
34
35
|
_export_star(require("./SettingsAutocomplete"), exports);
|
|
@@ -38,6 +39,7 @@ _export_star(require("./Table"), exports);
|
|
|
38
39
|
_export_star(require("./ThresholdsEditor"), exports);
|
|
39
40
|
_export_star(require("./TimeChart"), exports);
|
|
40
41
|
_export_star(require("./TimeSeriesTooltip"), exports);
|
|
42
|
+
_export_star(require("./ToolbarIconButton"), exports);
|
|
41
43
|
_export_star(require("./FormatControls"), exports);
|
|
42
44
|
_export_star(require("./YAxisLabel"), exports);
|
|
43
45
|
_export_star(require("./context"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './InfoTooltip';
|
|
|
13
13
|
export * from './JSONEditor';
|
|
14
14
|
export * from './Legend';
|
|
15
15
|
export * from './LineChart';
|
|
16
|
+
export * from './LinksEditor';
|
|
16
17
|
export * from './ModeSelector';
|
|
17
18
|
export * from './OptionsEditorLayout';
|
|
18
19
|
export * from './SettingsAutocomplete';
|
|
@@ -22,6 +23,7 @@ export * from './Table';
|
|
|
22
23
|
export * from './ThresholdsEditor';
|
|
23
24
|
export * from './TimeChart';
|
|
24
25
|
export * from './TimeSeriesTooltip';
|
|
26
|
+
export * from './ToolbarIconButton';
|
|
25
27
|
export * from './FormatControls';
|
|
26
28
|
export * from './YAxisLabel';
|
|
27
29
|
export * from './context';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from './InfoTooltip';
|
|
|
25
25
|
export * from './JSONEditor';
|
|
26
26
|
export * from './Legend';
|
|
27
27
|
export * from './LineChart';
|
|
28
|
+
export * from './LinksEditor';
|
|
28
29
|
export * from './ModeSelector';
|
|
29
30
|
export * from './OptionsEditorLayout';
|
|
30
31
|
export * from './SettingsAutocomplete';
|
|
@@ -34,6 +35,7 @@ export * from './Table';
|
|
|
34
35
|
export * from './ThresholdsEditor';
|
|
35
36
|
export * from './TimeChart';
|
|
36
37
|
export * from './TimeSeriesTooltip';
|
|
38
|
+
export * from './ToolbarIconButton';
|
|
37
39
|
export * from './FormatControls';
|
|
38
40
|
export * from './YAxisLabel';
|
|
39
41
|
export * from './context';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './BarChart';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeChart';\nexport * from './TimeSeriesTooltip';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './RefreshIntervalPicker';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa;AAC3B,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,qBAAqB;AACnC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './BarChart';\nexport * from './ColorPicker';\nexport * from './ContentWithLegend';\nexport * from './DateTimeRangePicker';\nexport * from './Dialog';\nexport * from './Drawer';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './FontSizeSelector';\nexport * from './GaugeChart';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './LinksEditor';\nexport * from './ModeSelector';\nexport * from './OptionsEditorLayout';\nexport * from './SettingsAutocomplete';\nexport * from './SortSelector';\nexport * from './StatChart';\nexport * from './Table';\nexport * from './ThresholdsEditor';\nexport * from './TimeChart';\nexport * from './TimeSeriesTooltip';\nexport * from './ToolbarIconButton';\nexport * from './FormatControls';\nexport * from './YAxisLabel';\nexport * from './context';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\nexport * from './theme';\nexport * from './RefreshIntervalPicker';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa;AAC3B,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,qBAAqB;AACnC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,0BAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0-rc0",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@codemirror/lang-json": "^6.0.1",
|
|
37
37
|
"@fontsource/lato": "^4.5.10",
|
|
38
38
|
"@mui/x-date-pickers": "^6.12.1",
|
|
39
|
-
"@perses-dev/core": "0.
|
|
39
|
+
"@perses-dev/core": "0.45.0-rc0",
|
|
40
40
|
"@tanstack/react-table": "^8.9.1",
|
|
41
41
|
"@uiw/react-codemirror": "^4.19.1",
|
|
42
42
|
"date-fns": "^2.28.0",
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
"notistack": "^2.0.5",
|
|
49
49
|
"react-colorful": "^5.6.1",
|
|
50
50
|
"react-error-boundary": "^3.1.4",
|
|
51
|
+
"react-hook-form": "^7.51.3",
|
|
51
52
|
"react-virtuoso": "^4.3.6"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@perses-dev/storybook": "0.
|
|
55
|
+
"@perses-dev/storybook": "0.45.0-rc0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"@mui/material": "^5.10.0",
|