@perses-dev/static-list-variable-plugin 0.6.0 → 0.7.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.
Files changed (36) hide show
  1. package/__mf/js/StaticListVariable.0c581d02.js +6 -0
  2. package/__mf/js/async/{964.29df3fc1.js → 121.4ebe7f6a.js} +2 -2
  3. package/__mf/js/async/2.991904e6.js +1 -0
  4. package/__mf/js/async/235.dc9459f4.js +1 -0
  5. package/__mf/js/async/274.45a05c55.js +2 -0
  6. package/__mf/js/async/470.d2f8305b.js +2 -0
  7. package/__mf/js/async/616.6892b34f.js +1 -0
  8. package/__mf/js/async/797.94e2c0d6.js +110 -0
  9. package/__mf/js/async/941.854f711e.js +2 -0
  10. package/__mf/js/async/__federation_expose_StaticListVariable.e1dcc909.js +1 -0
  11. package/__mf/js/main.3c40b528.js +6 -0
  12. package/lib/StaticListVariable.d.ts.map +1 -1
  13. package/lib/StaticListVariable.js +207 -28
  14. package/lib/StaticListVariable.js.map +1 -1
  15. package/lib/bootstrap.js +1 -1
  16. package/lib/bootstrap.js.map +1 -1
  17. package/lib/cjs/StaticListVariable.js +211 -27
  18. package/lib/cjs/index-federation.js +12 -12
  19. package/mf-manifest.json +10 -10
  20. package/mf-stats.json +16 -12
  21. package/package.json +4 -4
  22. package/__mf/js/StaticListVariable.97d532c4.js +0 -5
  23. package/__mf/js/async/173.4391bb15.js +0 -2
  24. package/__mf/js/async/526.cb9b2a3c.js +0 -110
  25. package/__mf/js/async/651.d88dce05.js +0 -1
  26. package/__mf/js/async/694.28c130cc.js +0 -1
  27. package/__mf/js/async/770.c6728f86.js +0 -1
  28. package/__mf/js/async/863.0667e27b.js +0 -2
  29. package/__mf/js/async/960.bbf8418e.js +0 -2
  30. package/__mf/js/async/__federation_expose_StaticListVariable.3195ca52.js +0 -1
  31. package/__mf/js/main.fb091be0.js +0 -5
  32. /package/__mf/js/async/{964.29df3fc1.js.LICENSE.txt → 121.4ebe7f6a.js.LICENSE.txt} +0 -0
  33. /package/__mf/js/async/{960.bbf8418e.js.LICENSE.txt → 274.45a05c55.js.LICENSE.txt} +0 -0
  34. /package/__mf/js/async/{173.4391bb15.js.LICENSE.txt → 470.d2f8305b.js.LICENSE.txt} +0 -0
  35. /package/__mf/js/async/{526.cb9b2a3c.js.LICENSE.txt → 797.94e2c0d6.js.LICENSE.txt} +0 -0
  36. /package/__mf/js/async/{863.0667e27b.js.LICENSE.txt → 941.854f711e.js.LICENSE.txt} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ /* eslint-disable jsx-a11y/no-autofocus */ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
@@ -10,47 +10,231 @@ Object.defineProperty(exports, "StaticListVariable", {
10
10
  });
11
11
  const _jsxruntime = require("react/jsx-runtime");
12
12
  const _material = require("@mui/material");
13
+ const _react = require("react");
14
+ const _PlusCircle = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/PlusCircle"));
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
13
20
  function StaticListVariableOptionEditor(props) {
14
- const value = (props.value.values || []).map((v)=>{
15
- if (typeof v === 'string') {
16
- return v;
17
- } else {
18
- return v.value;
21
+ const { value: { values: variables = [] }, onChange } = props;
22
+ const [editModeOption, setEditModeOption] = (0, _react.useState)('');
23
+ const onChangeHandler = (0, _react.useCallback)((_, value)=>{
24
+ const newVariable = value.pop();
25
+ const valueExists = variables.map((v)=>{
26
+ return typeof v === 'string' ? v : v?.value || '';
27
+ }).some((v)=>v === newVariable);
28
+ if (valueExists) return;
29
+ onChange({
30
+ values: [
31
+ ...variables,
32
+ {
33
+ value: String(newVariable),
34
+ label: String(newVariable)
35
+ }
36
+ ]
37
+ });
38
+ }, [
39
+ onChange,
40
+ variables
41
+ ]);
42
+ const onPasteHandler = (0, _react.useCallback)((e)=>{
43
+ const v = e.clipboardData.getData('text/plain');
44
+ if (v) {
45
+ const items = v.split(',').filter((i)=>{
46
+ const exists = variables.map((v)=>{
47
+ return v?.value || String(v);
48
+ }).some((v)=>v === i);
49
+ return !exists;
50
+ }).map((item)=>({
51
+ value: item.trim(),
52
+ label: ''
53
+ }));
54
+ onChange({
55
+ values: [
56
+ ...variables,
57
+ ...items
58
+ ]
59
+ });
60
+ e.preventDefault();
19
61
  }
20
- });
21
- const onChange = (__, value)=>{
22
- props.onChange({
23
- values: value.map((v)=>{
24
- return {
25
- value: v,
26
- label: v
62
+ }, [
63
+ onChange,
64
+ variables
65
+ ]);
66
+ const tagDeleteHandler = (0, _react.useCallback)((option)=>{
67
+ const filteredVariables = variables.filter((v)=>!(v === option || v?.value === option));
68
+ onChange({
69
+ values: [
70
+ ...filteredVariables
71
+ ]
72
+ });
73
+ setEditModeOption('');
74
+ }, [
75
+ variables,
76
+ onChange
77
+ ]);
78
+ const renderTagsHandler = (0, _react.useCallback)((tagValue)=>{
79
+ const updateVariableWithLabel = (optionKey, label)=>{
80
+ if (!optionKey || !label) return variables;
81
+ /* Prevent duplicate label */ const labelAlreadyExists = variables.filter((v)=>typeof v !== 'string').some((v)=>v?.label === label);
82
+ if (labelAlreadyExists) return variables;
83
+ return variables.map((v)=>{
84
+ if (typeof v === 'string') return v;
85
+ const variableOption = v;
86
+ if (variableOption.value !== optionKey) return variableOption;
87
+ const updatedVariableOption = {
88
+ label,
89
+ value: variableOption.value
27
90
  };
28
- })
91
+ return updatedVariableOption;
92
+ });
93
+ };
94
+ return tagValue.map((_, index)=>{
95
+ const foundVariable = variables[index];
96
+ if (!foundVariable) return null;
97
+ const labelObject = {
98
+ value: '',
99
+ label: ''
100
+ };
101
+ if (typeof foundVariable === 'string') {
102
+ /* value and label are identical */ labelObject.value = foundVariable;
103
+ labelObject.label = foundVariable;
104
+ } else {
105
+ labelObject.value = foundVariable.value;
106
+ labelObject.label = foundVariable.label || foundVariable.value;
107
+ }
108
+ /* The value and key are the same thing, they can be used interchangeably */ const optionKey = foundVariable?.value || foundVariable;
109
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
110
+ sx: {
111
+ margin: '4px'
112
+ },
113
+ label: editModeOption !== optionKey ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
114
+ style: {
115
+ display: 'flex',
116
+ alignItems: 'center',
117
+ gap: '8px'
118
+ },
119
+ children: [
120
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
121
+ variant: "body2",
122
+ children: labelObject.value
123
+ }),
124
+ labelObject?.value !== labelObject?.label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
125
+ variant: "body2",
126
+ sx: {
127
+ backgroundColor: (theme)=>theme.palette.grey[200],
128
+ color: (theme)=>theme.palette.text.primary,
129
+ padding: '4px 8px',
130
+ borderRadius: '4px',
131
+ fontWeight: 500
132
+ },
133
+ children: labelObject.label
134
+ }),
135
+ typeof foundVariable !== 'string' && labelObject.value === labelObject.label && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
136
+ size: "small",
137
+ onClick: (e)=>{
138
+ e.stopPropagation();
139
+ setEditModeOption(optionKey);
140
+ },
141
+ sx: {
142
+ color: (theme)=>theme.palette.action.disabled
143
+ },
144
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PlusCircle.default, {
145
+ fontSize: "small"
146
+ })
147
+ })
148
+ ]
149
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
150
+ style: {
151
+ display: 'flex',
152
+ alignItems: 'center',
153
+ gap: '8px'
154
+ },
155
+ children: [
156
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
157
+ children: optionKey
158
+ }),
159
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
160
+ defaultValue: labelObject.label,
161
+ onBlur: (e)=>{
162
+ const { target: { value: input } } = e;
163
+ if (input) {
164
+ const updatedVariables = updateVariableWithLabel(optionKey, input);
165
+ onChange({
166
+ values: updatedVariables
167
+ });
168
+ }
169
+ setEditModeOption('');
170
+ },
171
+ onKeyDown: (e)=>{
172
+ if (e.key === 'Enter') {
173
+ const { value: input } = e.target;
174
+ const updatedVariables = updateVariableWithLabel(optionKey, input);
175
+ onChange({
176
+ values: updatedVariables
177
+ });
178
+ setEditModeOption('');
179
+ } else if (e.key === 'Escape') {
180
+ setEditModeOption('');
181
+ }
182
+ },
183
+ size: "small",
184
+ autoFocus: true,
185
+ sx: {
186
+ width: '100%',
187
+ padding: 0,
188
+ margin: 0,
189
+ backgroundColor: (theme)=>theme.palette.background.default,
190
+ '& .MuiInputBase-root': {
191
+ fontSize: '0.875rem',
192
+ padding: 0
193
+ },
194
+ '& .MuiOutlinedInput-notchedOutline': {
195
+ border: 'none'
196
+ }
197
+ },
198
+ inputProps: {
199
+ style: {
200
+ padding: 0
201
+ }
202
+ }
203
+ })
204
+ ]
205
+ }),
206
+ onDelete: ()=>{
207
+ tagDeleteHandler(optionKey);
208
+ }
209
+ }, optionKey);
29
210
  });
30
- };
211
+ }, [
212
+ variables,
213
+ tagDeleteHandler,
214
+ editModeOption,
215
+ onChange
216
+ ]);
31
217
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
32
218
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
33
- onPaste: (e)=>{
34
- // Append new values on paste
35
- const v = e.clipboardData.getData('text/plain');
36
- if (v) {
37
- const values = v.split(',');
38
- onChange(null, value.concat(values));
39
- e.preventDefault();
40
- }
41
- },
219
+ onPaste: onPasteHandler,
42
220
  multiple: true,
43
- value: value,
44
- onChange: onChange,
221
+ value: variables.map((vr)=>typeof vr === 'string' ? vr : vr.label || vr.value),
222
+ onChange: onChangeHandler,
45
223
  options: [],
46
224
  freeSolo: true,
47
225
  clearOnBlur: true,
48
226
  readOnly: props.isReadonly,
227
+ renderTags: renderTagsHandler,
49
228
  renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
50
229
  ...params,
51
230
  label: "Values",
52
231
  placeholder: "Values",
53
- helperText: 'Type new value then press "Enter" to add.'
232
+ helperText: 'Type new value then press "Enter" to add. Optionally define a label by clicking on the "+" button.',
233
+ onKeyDown: (e)=>{
234
+ if (e.key === 'Backspace' && !params.inputProps.value) {
235
+ e.stopPropagation();
236
+ }
237
+ }
54
238
  })
55
239
  })
56
240
  });
@@ -1,15 +1,3 @@
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
1
  "use strict";
14
2
  function _getRequireWildcardCache(nodeInterop) {
15
3
  if (typeof WeakMap !== "function") return null;
@@ -52,4 +40,16 @@ function _interop_require_wildcard(obj, nodeInterop) {
52
40
  }
53
41
  return newObj;
54
42
  }
43
+ // Copyright 2024 The Perses Authors
44
+ // Licensed under the Apache License, Version 2.0 (the "License");
45
+ // you may not use this file except in compliance with the License.
46
+ // You may obtain a copy of the License at
47
+ //
48
+ // http://www.apache.org/licenses/LICENSE-2.0
49
+ //
50
+ // Unless required by applicable law or agreed to in writing, software
51
+ // distributed under the License is distributed on an "AS IS" BASIS,
52
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ // See the License for the specific language governing permissions and
54
+ // limitations under the License.
55
55
  Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
package/mf-manifest.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "StaticListVariable",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.6.0",
8
+ "buildVersion": "0.7.1",
9
9
  "buildName": "@perses-dev/static-list-variable-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/StaticListVariable.97d532c4.js",
12
+ "name": "__mf/js/StaticListVariable.0c581d02.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -20,7 +20,7 @@
20
20
  "api": ""
21
21
  },
22
22
  "globalName": "StaticListVariable",
23
- "pluginVersion": "0.19.1",
23
+ "pluginVersion": "0.21.6",
24
24
  "prefetchInterface": false,
25
25
  "getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/StaticListVariable/\"; }"
26
26
  },
@@ -35,7 +35,7 @@
35
35
  "js": {
36
36
  "async": [],
37
37
  "sync": [
38
- "__mf/js/async/960.bbf8418e.js"
38
+ "__mf/js/async/274.45a05c55.js"
39
39
  ]
40
40
  },
41
41
  "css": {
@@ -54,8 +54,8 @@
54
54
  "js": {
55
55
  "async": [],
56
56
  "sync": [
57
- "__mf/js/async/694.28c130cc.js",
58
- "__mf/js/async/770.c6728f86.js"
57
+ "__mf/js/async/235.dc9459f4.js",
58
+ "__mf/js/async/616.6892b34f.js"
59
59
  ]
60
60
  },
61
61
  "css": {
@@ -74,7 +74,7 @@
74
74
  "js": {
75
75
  "async": [],
76
76
  "sync": [
77
- "__mf/js/async/173.4391bb15.js"
77
+ "__mf/js/async/470.d2f8305b.js"
78
78
  ]
79
79
  },
80
80
  "css": {
@@ -93,7 +93,7 @@
93
93
  "js": {
94
94
  "async": [],
95
95
  "sync": [
96
- "__mf/js/async/964.29df3fc1.js"
96
+ "__mf/js/async/121.4ebe7f6a.js"
97
97
  ]
98
98
  },
99
99
  "css": {
@@ -111,8 +111,8 @@
111
111
  "assets": {
112
112
  "js": {
113
113
  "sync": [
114
- "__mf/js/async/526.cb9b2a3c.js",
115
- "__mf/js/async/__federation_expose_StaticListVariable.3195ca52.js"
114
+ "__mf/js/async/797.94e2c0d6.js",
115
+ "__mf/js/async/__federation_expose_StaticListVariable.e1dcc909.js"
116
116
  ],
117
117
  "async": []
118
118
  },
package/mf-stats.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "StaticListVariable",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.6.0",
8
+ "buildVersion": "0.7.1",
9
9
  "buildName": "@perses-dev/static-list-variable-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/StaticListVariable.97d532c4.js",
12
+ "name": "__mf/js/StaticListVariable.0c581d02.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -20,7 +20,7 @@
20
20
  "api": ""
21
21
  },
22
22
  "globalName": "StaticListVariable",
23
- "pluginVersion": "0.19.1",
23
+ "pluginVersion": "0.21.6",
24
24
  "prefetchInterface": false,
25
25
  "getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/StaticListVariable/\"; }"
26
26
  },
@@ -37,7 +37,7 @@
37
37
  "js": {
38
38
  "async": [],
39
39
  "sync": [
40
- "__mf/js/async/960.bbf8418e.js"
40
+ "__mf/js/async/274.45a05c55.js"
41
41
  ]
42
42
  },
43
43
  "css": {
@@ -59,8 +59,8 @@
59
59
  "js": {
60
60
  "async": [],
61
61
  "sync": [
62
- "__mf/js/async/694.28c130cc.js",
63
- "__mf/js/async/770.c6728f86.js"
62
+ "__mf/js/async/235.dc9459f4.js",
63
+ "__mf/js/async/616.6892b34f.js"
64
64
  ]
65
65
  },
66
66
  "css": {
@@ -82,7 +82,7 @@
82
82
  "js": {
83
83
  "async": [],
84
84
  "sync": [
85
- "__mf/js/async/173.4391bb15.js"
85
+ "__mf/js/async/470.d2f8305b.js"
86
86
  ]
87
87
  },
88
88
  "css": {
@@ -104,7 +104,7 @@
104
104
  "js": {
105
105
  "async": [],
106
106
  "sync": [
107
- "__mf/js/async/964.29df3fc1.js"
107
+ "__mf/js/async/121.4ebe7f6a.js"
108
108
  ]
109
109
  },
110
110
  "css": {
@@ -112,7 +112,9 @@
112
112
  "sync": []
113
113
  }
114
114
  },
115
- "usedIn": []
115
+ "usedIn": [
116
+ "./StaticListVariable"
117
+ ]
116
118
  }
117
119
  ],
118
120
  "remotes": [],
@@ -121,13 +123,15 @@
121
123
  "path": "./StaticListVariable",
122
124
  "id": "StaticListVariable:StaticListVariable",
123
125
  "name": "StaticListVariable",
124
- "requires": [],
126
+ "requires": [
127
+ "react"
128
+ ],
125
129
  "file": "src/StaticListVariable.tsx",
126
130
  "assets": {
127
131
  "js": {
128
132
  "sync": [
129
- "__mf/js/async/526.cb9b2a3c.js",
130
- "__mf/js/async/__federation_expose_StaticListVariable.3195ca52.js"
133
+ "__mf/js/async/797.94e2c0d6.js",
134
+ "__mf/js/async/__federation_expose_StaticListVariable.e1dcc909.js"
131
135
  ],
132
136
  "async": []
133
137
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/static-list-variable-plugin",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "homepage": "https://github.com/perses/plugins/blob/main/README.md",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,9 +30,9 @@
30
30
  "@emotion/react": "^11.7.1",
31
31
  "@emotion/styled": "^11.6.0",
32
32
  "@hookform/resolvers": "^3.2.0",
33
- "@perses-dev/components": "^0.52.0",
34
- "@perses-dev/core": "^0.52.0",
35
- "@perses-dev/plugin-system": "^0.52.0",
33
+ "@perses-dev/components": "^0.53.0-beta.2",
34
+ "@perses-dev/core": "^0.53.0-beta.2",
35
+ "@perses-dev/plugin-system": "^0.53.0-beta.2",
36
36
  "date-fns": "^4.1.0",
37
37
  "date-fns-tz": "^3.2.0",
38
38
  "echarts": "5.5.0",