@perses-dev/components 0.55.0-rc.1 → 0.56.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/AlignSelector/AlignSelector.js +115 -25
  2. package/dist/AlignSelector/AlignSelector.js.map +1 -1
  3. package/dist/CodeEditor/CodeEditor.d.ts +19 -0
  4. package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
  5. package/dist/CodeEditor/CodeEditor.js +122 -0
  6. package/dist/CodeEditor/CodeEditor.js.map +1 -0
  7. package/dist/ColorPicker/ColorPicker.js +153 -61
  8. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  9. package/dist/ColorPicker/OptionsColorPicker.js +147 -52
  10. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  11. package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
  12. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  13. package/dist/DensitySelector/DensitySelector.js +53 -20
  14. package/dist/DensitySelector/DensitySelector.js.map +1 -1
  15. package/dist/Dialog/Dialog.d.ts +3 -2
  16. package/dist/Dialog/Dialog.d.ts.map +1 -1
  17. package/dist/Dialog/Dialog.js +202 -49
  18. package/dist/Dialog/Dialog.js.map +1 -1
  19. package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
  20. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  21. package/dist/DragAndDrop/DragAndDropList.js +184 -113
  22. package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
  23. package/dist/DragAndDrop/DragButton.js +131 -52
  24. package/dist/DragAndDrop/DragButton.js.map +1 -1
  25. package/dist/DragAndDrop/DropIndicator.js +51 -26
  26. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  27. package/dist/Drawer/Drawer.js +75 -15
  28. package/dist/Drawer/Drawer.js.map +1 -1
  29. package/dist/EChart/EChart.js +179 -90
  30. package/dist/EChart/EChart.js.map +1 -1
  31. package/dist/ErrorAlert.js +14 -4
  32. package/dist/ErrorAlert.js.map +1 -1
  33. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
  34. package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
  35. package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
  36. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  37. package/dist/FormEditor/FormActions.js +88 -14
  38. package/dist/FormEditor/FormActions.js.map +1 -1
  39. package/dist/FormatControls/FormatControls.js +246 -99
  40. package/dist/FormatControls/FormatControls.js.map +1 -1
  41. package/dist/FormatControls/UnitSelector.js +90 -25
  42. package/dist/FormatControls/UnitSelector.js.map +1 -1
  43. package/dist/InfoTooltip/InfoTooltip.js +105 -42
  44. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  45. package/dist/JSONEditor.d.ts +2 -6
  46. package/dist/JSONEditor.d.ts.map +1 -1
  47. package/dist/JSONEditor.js +24 -37
  48. package/dist/JSONEditor.js.map +1 -1
  49. package/dist/Legend/CompactLegend.js +77 -27
  50. package/dist/Legend/CompactLegend.js.map +1 -1
  51. package/dist/Legend/Legend.js +184 -82
  52. package/dist/Legend/Legend.js.map +1 -1
  53. package/dist/Legend/LegendColorBadge.js +54 -9
  54. package/dist/Legend/LegendColorBadge.js.map +1 -1
  55. package/dist/Legend/ListLegend.js +46 -16
  56. package/dist/Legend/ListLegend.js.map +1 -1
  57. package/dist/Legend/ListLegendItem.js +184 -48
  58. package/dist/Legend/ListLegendItem.js.map +1 -1
  59. package/dist/Legend/TableLegend.d.ts.map +1 -1
  60. package/dist/Legend/TableLegend.js +90 -48
  61. package/dist/Legend/TableLegend.js.map +1 -1
  62. package/dist/Legend/legend-model.d.ts +2 -2
  63. package/dist/Legend/legend-model.d.ts.map +1 -1
  64. package/dist/Legend/legend-model.js.map +1 -1
  65. package/dist/LinksEditor/LinkEditorForm.js +148 -67
  66. package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
  67. package/dist/ModeSelector/ModeSelector.js +61 -19
  68. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  69. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
  70. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  71. package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
  72. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  73. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
  74. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  75. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
  76. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  77. package/dist/Overlay/Overlay.js +71 -27
  78. package/dist/Overlay/Overlay.js.map +1 -1
  79. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
  80. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  81. package/dist/RepeatGrid/RepeatGrid.js +117 -45
  82. package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
  83. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
  84. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  85. package/dist/SortSelector/SortSelector.js +51 -18
  86. package/dist/SortSelector/SortSelector.js.map +1 -1
  87. package/dist/SortSelector/SortSelectorButtons.js +109 -25
  88. package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
  89. package/dist/Table/InnerTable.js +46 -15
  90. package/dist/Table/InnerTable.js.map +1 -1
  91. package/dist/Table/Table.d.ts +3 -1
  92. package/dist/Table/Table.d.ts.map +1 -1
  93. package/dist/Table/Table.js +410 -158
  94. package/dist/Table/Table.js.map +1 -1
  95. package/dist/Table/TableBody.js +15 -4
  96. package/dist/Table/TableBody.js.map +1 -1
  97. package/dist/Table/TableCell.js +284 -107
  98. package/dist/Table/TableCell.js.map +1 -1
  99. package/dist/Table/TableCheckbox.js +101 -32
  100. package/dist/Table/TableCheckbox.js.map +1 -1
  101. package/dist/Table/TableFoot.js +15 -4
  102. package/dist/Table/TableFoot.js.map +1 -1
  103. package/dist/Table/TableHead.js +15 -4
  104. package/dist/Table/TableHead.js.map +1 -1
  105. package/dist/Table/TableHeaderCell.js +119 -62
  106. package/dist/Table/TableHeaderCell.js.map +1 -1
  107. package/dist/Table/TableRow.js +33 -9
  108. package/dist/Table/TableRow.js.map +1 -1
  109. package/dist/Table/TableToolbar.d.ts +5 -4
  110. package/dist/Table/TableToolbar.d.ts.map +1 -1
  111. package/dist/Table/TableToolbar.js +172 -100
  112. package/dist/Table/TableToolbar.js.map +1 -1
  113. package/dist/Table/VirtualizedTable.d.ts +11 -11
  114. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  115. package/dist/Table/VirtualizedTable.js +387 -219
  116. package/dist/Table/VirtualizedTable.js.map +1 -1
  117. package/dist/Table/VirtualizedTableContainer.js +27 -7
  118. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  119. package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
  120. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
  121. package/dist/Table/hooks/useFuzzySearch.js +57 -32
  122. package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
  123. package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
  124. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  125. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
  126. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
  127. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +74 -53
  128. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  129. package/dist/Table/model/table-model.d.ts +44 -15
  130. package/dist/Table/model/table-model.d.ts.map +1 -1
  131. package/dist/Table/model/table-model.js +33 -1
  132. package/dist/Table/model/table-model.js.map +1 -1
  133. package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
  134. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  135. package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
  136. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  137. package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
  138. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  139. package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -209
  140. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  141. package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
  142. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  143. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
  144. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  145. package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
  146. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  147. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
  148. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  149. package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
  150. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  151. package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
  152. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  153. package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
  154. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  155. package/dist/TimeZoneSelector.js +131 -36
  156. package/dist/TimeZoneSelector.js.map +1 -1
  157. package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
  158. package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  159. package/dist/TransformsEditor/TransformEditor.js +830 -334
  160. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  161. package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
  162. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  163. package/dist/TransformsEditor/TransformsEditor.js +170 -59
  164. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  165. package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
  166. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  167. package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
  168. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  169. package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
  170. package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
  171. package/dist/YAMLEditor/YAMLEditor.js +41 -0
  172. package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
  173. package/dist/YAMLEditor/index.d.ts +2 -0
  174. package/dist/YAMLEditor/index.d.ts.map +1 -0
  175. package/dist/YAMLEditor/index.js +15 -0
  176. package/dist/YAMLEditor/index.js.map +1 -0
  177. package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
  178. package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
  179. package/dist/YAMLEditor/yaml-utils.js +52 -0
  180. package/dist/YAMLEditor/yaml-utils.js.map +1 -0
  181. package/dist/YAxisLabel.js +64 -20
  182. package/dist/YAxisLabel.js.map +1 -1
  183. package/dist/context/ChartsProvider.js +32 -16
  184. package/dist/context/ChartsProvider.js.map +1 -1
  185. package/dist/context/ItemActionsProvider.js +110 -61
  186. package/dist/context/ItemActionsProvider.js.map +1 -1
  187. package/dist/context/SelectionProvider.js +170 -66
  188. package/dist/context/SelectionProvider.js.map +1 -1
  189. package/dist/context/SnackbarProvider.js +101 -44
  190. package/dist/context/SnackbarProvider.js.map +1 -1
  191. package/dist/context/TimeZoneProvider.js +35 -14
  192. package/dist/context/TimeZoneProvider.js.map +1 -1
  193. package/dist/controls/TextField.js +86 -25
  194. package/dist/controls/TextField.js.map +1 -1
  195. package/dist/index.d.ts +1 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +1 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/utils/browser-storage.js +64 -34
  200. package/dist/utils/browser-storage.js.map +1 -1
  201. package/dist/utils/time-series-data.d.ts.map +1 -1
  202. package/dist/utils/time-series-data.js +5 -2
  203. package/dist/utils/time-series-data.js.map +1 -1
  204. package/package.json +13 -7
@@ -11,32 +11,122 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { c as _c } from "react-compiler-runtime";
14
15
  import { Button, ButtonGroup } from "@mui/material";
15
- export function AlignSelector({ onChange, value = 'left', ...props }) {
16
- const handleSortChange = (option)=>{
17
- onChange(option);
18
- };
19
- return /*#__PURE__*/ _jsxs(ButtonGroup, {
20
- "aria-label": "Alignement",
21
- ...props,
22
- children: [
23
- /*#__PURE__*/ _jsx(Button, {
24
- onClick: ()=>handleSortChange('left'),
25
- variant: value === 'left' ? 'contained' : 'outlined',
26
- children: "Left"
27
- }, "left"),
28
- /*#__PURE__*/ _jsx(Button, {
29
- onClick: ()=>handleSortChange('center'),
30
- variant: value === 'center' ? 'contained' : 'outlined',
31
- children: "Center"
32
- }, "center"),
33
- /*#__PURE__*/ _jsx(Button, {
34
- onClick: ()=>handleSortChange('right'),
35
- variant: value === 'right' ? 'contained' : 'outlined',
36
- children: "Right"
37
- }, "right")
38
- ]
39
- });
16
+ export function AlignSelector(t0) {
17
+ const $ = _c(26);
18
+ let onChange;
19
+ let props;
20
+ let t1;
21
+ if ($[0] !== t0) {
22
+ ({ onChange, value: t1, ...props } = t0);
23
+ $[0] = t0;
24
+ $[1] = onChange;
25
+ $[2] = props;
26
+ $[3] = t1;
27
+ } else {
28
+ onChange = $[1];
29
+ props = $[2];
30
+ t1 = $[3];
31
+ }
32
+ const value = t1 === undefined ? "left" : t1;
33
+ let t2;
34
+ if ($[4] !== onChange) {
35
+ t2 = (option)=>{
36
+ onChange(option);
37
+ };
38
+ $[4] = onChange;
39
+ $[5] = t2;
40
+ } else {
41
+ t2 = $[5];
42
+ }
43
+ const handleSortChange = t2;
44
+ let t3;
45
+ if ($[6] !== handleSortChange) {
46
+ t3 = ()=>handleSortChange("left");
47
+ $[6] = handleSortChange;
48
+ $[7] = t3;
49
+ } else {
50
+ t3 = $[7];
51
+ }
52
+ const t4 = value === "left" ? "contained" : "outlined";
53
+ let t5;
54
+ if ($[8] !== t3 || $[9] !== t4) {
55
+ t5 = /*#__PURE__*/ _jsx(Button, {
56
+ onClick: t3,
57
+ variant: t4,
58
+ children: "Left"
59
+ }, "left");
60
+ $[8] = t3;
61
+ $[9] = t4;
62
+ $[10] = t5;
63
+ } else {
64
+ t5 = $[10];
65
+ }
66
+ let t6;
67
+ if ($[11] !== handleSortChange) {
68
+ t6 = ()=>handleSortChange("center");
69
+ $[11] = handleSortChange;
70
+ $[12] = t6;
71
+ } else {
72
+ t6 = $[12];
73
+ }
74
+ const t7 = value === "center" ? "contained" : "outlined";
75
+ let t8;
76
+ if ($[13] !== t6 || $[14] !== t7) {
77
+ t8 = /*#__PURE__*/ _jsx(Button, {
78
+ onClick: t6,
79
+ variant: t7,
80
+ children: "Center"
81
+ }, "center");
82
+ $[13] = t6;
83
+ $[14] = t7;
84
+ $[15] = t8;
85
+ } else {
86
+ t8 = $[15];
87
+ }
88
+ let t9;
89
+ if ($[16] !== handleSortChange) {
90
+ t9 = ()=>handleSortChange("right");
91
+ $[16] = handleSortChange;
92
+ $[17] = t9;
93
+ } else {
94
+ t9 = $[17];
95
+ }
96
+ const t10 = value === "right" ? "contained" : "outlined";
97
+ let t11;
98
+ if ($[18] !== t10 || $[19] !== t9) {
99
+ t11 = /*#__PURE__*/ _jsx(Button, {
100
+ onClick: t9,
101
+ variant: t10,
102
+ children: "Right"
103
+ }, "right");
104
+ $[18] = t10;
105
+ $[19] = t9;
106
+ $[20] = t11;
107
+ } else {
108
+ t11 = $[20];
109
+ }
110
+ let t12;
111
+ if ($[21] !== props || $[22] !== t11 || $[23] !== t5 || $[24] !== t8) {
112
+ t12 = /*#__PURE__*/ _jsxs(ButtonGroup, {
113
+ "aria-label": "Alignement",
114
+ ...props,
115
+ children: [
116
+ t5,
117
+ t8,
118
+ t11
119
+ ]
120
+ });
121
+ $[21] = props;
122
+ $[22] = t11;
123
+ $[23] = t5;
124
+ $[24] = t8;
125
+ $[25] = t12;
126
+ } else {
127
+ t12 = $[25];
128
+ }
129
+ return t12;
40
130
  }
41
131
 
42
132
  //# sourceMappingURL=AlignSelector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AlignSelector/AlignSelector.tsx"],"sourcesContent":["// Copyright 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 type { ButtonGroupProps } from '@mui/material';\nimport { Button, ButtonGroup } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport type AlignOption = 'left' | 'center' | 'right';\n\nexport interface AlignSelectorProps extends Omit<ButtonGroupProps, 'onChange'> {\n onChange: (align: AlignOption) => void;\n value?: AlignOption;\n}\n\nexport function AlignSelector({ onChange, value = 'left', ...props }: AlignSelectorProps): ReactElement {\n const handleSortChange = (option: AlignOption): void => {\n onChange(option);\n };\n\n return (\n <ButtonGroup aria-label=\"Alignement\" {...props}>\n <Button key=\"left\" onClick={() => handleSortChange('left')} variant={value === 'left' ? 'contained' : 'outlined'}>\n Left\n </Button>\n <Button\n key=\"center\"\n onClick={() => handleSortChange('center')}\n variant={value === 'center' ? 'contained' : 'outlined'}\n >\n Center\n </Button>\n <Button\n key=\"right\"\n onClick={() => handleSortChange('right')}\n variant={value === 'right' ? 'contained' : 'outlined'}\n >\n Right\n </Button>\n </ButtonGroup>\n );\n}\n"],"names":["Button","ButtonGroup","AlignSelector","onChange","value","props","handleSortChange","option","aria-label","onClick","variant"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,MAAM,EAAEC,WAAW,QAAQ,gBAAgB;AAUpD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,MAAM,EAAE,GAAGC,OAA2B;IACtF,MAAMC,mBAAmB,CAACC;QACxBJ,SAASI;IACX;IAEA,qBACE,MAACN;QAAYO,cAAW;QAAc,GAAGH,KAAK;;0BAC5C,KAACL;gBAAkBS,SAAS,IAAMH,iBAAiB;gBAASI,SAASN,UAAU,SAAS,cAAc;0BAAY;eAAtG;0BAGZ,KAACJ;gBAECS,SAAS,IAAMH,iBAAiB;gBAChCI,SAASN,UAAU,WAAW,cAAc;0BAC7C;eAHK;0BAMN,KAACJ;gBAECS,SAAS,IAAMH,iBAAiB;gBAChCI,SAASN,UAAU,UAAU,cAAc;0BAC5C;eAHK;;;AAQZ"}
1
+ {"version":3,"sources":["../../src/AlignSelector/AlignSelector.tsx"],"sourcesContent":["// Copyright 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 type { ButtonGroupProps } from '@mui/material';\nimport { Button, ButtonGroup } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport type AlignOption = 'left' | 'center' | 'right';\n\nexport interface AlignSelectorProps extends Omit<ButtonGroupProps, 'onChange'> {\n onChange: (align: AlignOption) => void;\n value?: AlignOption;\n}\n\nexport function AlignSelector({ onChange, value = 'left', ...props }: AlignSelectorProps): ReactElement {\n const handleSortChange = (option: AlignOption): void => {\n onChange(option);\n };\n\n return (\n <ButtonGroup aria-label=\"Alignement\" {...props}>\n <Button key=\"left\" onClick={() => handleSortChange('left')} variant={value === 'left' ? 'contained' : 'outlined'}>\n Left\n </Button>\n <Button\n key=\"center\"\n onClick={() => handleSortChange('center')}\n variant={value === 'center' ? 'contained' : 'outlined'}\n >\n Center\n </Button>\n <Button\n key=\"right\"\n onClick={() => handleSortChange('right')}\n variant={value === 'right' ? 'contained' : 'outlined'}\n >\n Right\n </Button>\n </ButtonGroup>\n );\n}\n"],"names":["Button","ButtonGroup"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,6EAA6E;AAC7E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,MAAM,EAAEC,WAAW,QAAQ,gBAAgB;AAUpD,OAAO"}
@@ -0,0 +1,19 @@
1
+ import type { Extension, ReactCodeMirrorProps } from '@uiw/react-codemirror';
2
+ import type { ReactElement } from 'react';
3
+ export type CodeEditorProps<T> = Omit<ReactCodeMirrorProps, 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'> & {
4
+ value: T;
5
+ placeholder?: string;
6
+ onChange?: (next: string) => void;
7
+ };
8
+ type InternalCodeEditorProps<T> = CodeEditorProps<T> & {
9
+ /** Language specific CodeMirror extensions. Must be stable across renders. */
10
+ extensions: Extension[];
11
+ /** Convert the initial value into the text displayed by the editor. */
12
+ serialize: (value: T) => string;
13
+ };
14
+ /**
15
+ * Internal base for the language specific editors (JSONEditor, YAMLEditor). Not exported from the package.
16
+ */
17
+ export declare function CodeEditor<T>(props: InternalCodeEditorProps<T>): ReactElement;
18
+ export {};
19
+ //# sourceMappingURL=CodeEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../src/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,IAAI,CACnC,oBAAoB,EACpB,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,CACzD,GAAG;IACF,KAAK,EAAE,CAAC,CAAC;IACT,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF,KAAK,uBAAuB,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG;IACrD,8EAA8E;IAC9E,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,uEAAuE;IACvE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,YAAY,CAkC7E"}
@@ -0,0 +1,122 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { c as _c } from "react-compiler-runtime";
3
+ // Copyright The Perses Authors
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ import { useTheme } from "@mui/material";
16
+ import CodeMirror from "@uiw/react-codemirror";
17
+ import { useState } from "react";
18
+ /**
19
+ * Internal base for the language specific editors (JSONEditor, YAMLEditor). Not exported from the package.
20
+ */ export function CodeEditor(props) {
21
+ const $ = _c(26);
22
+ let extensions;
23
+ let initialValue;
24
+ let onChange;
25
+ let rest;
26
+ let serialize;
27
+ if ($[0] !== props) {
28
+ ({ value: initialValue, serialize, extensions, onChange, ...rest } = props);
29
+ $[0] = props;
30
+ $[1] = extensions;
31
+ $[2] = initialValue;
32
+ $[3] = onChange;
33
+ $[4] = rest;
34
+ $[5] = serialize;
35
+ } else {
36
+ extensions = $[1];
37
+ initialValue = $[2];
38
+ onChange = $[3];
39
+ rest = $[4];
40
+ serialize = $[5];
41
+ }
42
+ const theme = useTheme();
43
+ const isDarkMode = theme.palette.mode === "dark";
44
+ let t0;
45
+ if ($[6] !== initialValue || $[7] !== serialize) {
46
+ t0 = ()=>serialize(initialValue);
47
+ $[6] = initialValue;
48
+ $[7] = serialize;
49
+ $[8] = t0;
50
+ } else {
51
+ t0 = $[8];
52
+ }
53
+ const [value, setValue] = useState(t0);
54
+ const [lastProcessedValue, setLastProcessedValue] = useState(value);
55
+ const t1 = `1px solid ${theme.palette.divider}`;
56
+ let t2;
57
+ if ($[9] !== t1) {
58
+ t2 = {
59
+ border: t1
60
+ };
61
+ $[9] = t1;
62
+ $[10] = t2;
63
+ } else {
64
+ t2 = $[10];
65
+ }
66
+ const t3 = isDarkMode ? "dark" : "light";
67
+ let t4;
68
+ if ($[11] !== onChange) {
69
+ t4 = (newValue)=>{
70
+ setValue(newValue);
71
+ if (onChange) {
72
+ onChange(newValue);
73
+ }
74
+ };
75
+ $[11] = onChange;
76
+ $[12] = t4;
77
+ } else {
78
+ t4 = $[12];
79
+ }
80
+ let t5;
81
+ if ($[13] !== lastProcessedValue || $[14] !== onChange || $[15] !== value) {
82
+ t5 = ()=>{
83
+ if (lastProcessedValue !== value && onChange !== undefined) {
84
+ onChange(value);
85
+ setLastProcessedValue(value);
86
+ }
87
+ };
88
+ $[13] = lastProcessedValue;
89
+ $[14] = onChange;
90
+ $[15] = value;
91
+ $[16] = t5;
92
+ } else {
93
+ t5 = $[16];
94
+ }
95
+ let t6;
96
+ if ($[17] !== extensions || $[18] !== props.placeholder || $[19] !== rest || $[20] !== t2 || $[21] !== t3 || $[22] !== t4 || $[23] !== t5 || $[24] !== value) {
97
+ t6 = /*#__PURE__*/ _jsx(CodeMirror, {
98
+ ...rest,
99
+ style: t2,
100
+ theme: t3,
101
+ extensions: extensions,
102
+ value: value,
103
+ onChange: t4,
104
+ onBlur: t5,
105
+ placeholder: props.placeholder
106
+ });
107
+ $[17] = extensions;
108
+ $[18] = props.placeholder;
109
+ $[19] = rest;
110
+ $[20] = t2;
111
+ $[21] = t3;
112
+ $[22] = t4;
113
+ $[23] = t5;
114
+ $[24] = value;
115
+ $[25] = t6;
116
+ } else {
117
+ t6 = $[25];
118
+ }
119
+ return t6;
120
+ }
121
+
122
+ //# sourceMappingURL=CodeEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/CodeEditor/CodeEditor.tsx"],"sourcesContent":["// Copyright 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 { useTheme } from '@mui/material';\nimport type { Extension, ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport CodeMirror from '@uiw/react-codemirror';\nimport type { ReactElement } from 'react';\nimport { useState } from 'react';\n\nexport type CodeEditorProps<T> = Omit<\n ReactCodeMirrorProps,\n 'onBlur' | 'theme' | 'extensions' | 'onChange' | 'value'\n> & {\n value: T;\n placeholder?: string;\n onChange?: (next: string) => void;\n};\n\ntype InternalCodeEditorProps<T> = CodeEditorProps<T> & {\n /** Language specific CodeMirror extensions. Must be stable across renders. */\n extensions: Extension[];\n /** Convert the initial value into the text displayed by the editor. */\n serialize: (value: T) => string;\n};\n\n/**\n * Internal base for the language specific editors (JSONEditor, YAMLEditor). Not exported from the package.\n */\nexport function CodeEditor<T>(props: InternalCodeEditorProps<T>): ReactElement {\n const { value: initialValue, serialize, extensions, onChange, ...rest } = props;\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const [value, setValue] = useState(() => serialize(initialValue));\n const [lastProcessedValue, setLastProcessedValue] = useState<string>(value);\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n extensions={extensions}\n value={value}\n onChange={(newValue) => {\n setValue(newValue);\n // Trigger the provided onChange callback in real-time\n if (onChange) {\n onChange(newValue);\n }\n }}\n onBlur={() => {\n // Don't trigger the provided onChange if the last processed value is equal to the current value.\n // This prevents e.g CTRL+F to trigger value refresh downstream, which would cause the embedded\n // find & replace interface to close immediately.\n if (lastProcessedValue !== value && onChange !== undefined) {\n onChange(value);\n setLastProcessedValue(value);\n }\n }}\n placeholder={props.placeholder}\n />\n );\n}\n"],"names":["useTheme","CodeMirror","useState"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,gBAAgB,wBAAwB;AAE/C,SAASC,QAAQ,QAAQ,QAAQ;AAkBjC;;CAEC,GACD,OAAO"}
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { c as _c } from "react-compiler-runtime";
2
3
  // Copyright The Perses Authors
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
4
5
  // you may not use this file except in compliance with the License.
@@ -16,68 +17,159 @@ import CircleIcon from "mdi-material-ui/Circle";
16
17
  import DeleteIcon from "mdi-material-ui/Delete";
17
18
  import { useState } from "react";
18
19
  import { HexColorPicker } from "react-colorful";
19
- export const ColorPicker = ({ color, onChange, onClear, palette })=>{
20
- // value is the visible value for the controlled text input
20
+ export const ColorPicker = (t0)=>{
21
+ const $ = _c(26);
22
+ const { color, onChange, onClear, palette } = t0;
21
23
  const [value, setValue] = useState(color);
22
- const handleColorChange = (color)=>{
23
- setValue(color);
24
- onChange?.(color);
25
- };
26
- // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved
27
- const handleInputChange = (e)=>{
28
- const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, '').substring(0, 8);
29
- setValue(`#${inputValue}`); // always prefix input value with # to indicate hex format
30
- // only set color if input value is a valid hex color
31
- if (isValidHex(e.target.value)) {
32
- onChange?.(e.target.value);
33
- }
34
- };
35
- return /*#__PURE__*/ _jsxs(Stack, {
36
- spacing: 1,
37
- children: [
38
- /*#__PURE__*/ _jsx(HexColorPicker, {
39
- color: color,
40
- onChange: handleColorChange,
41
- style: {
42
- width: '100%'
43
- }
44
- }),
45
- /*#__PURE__*/ _jsx(Stack, {
46
- direction: "row",
47
- flexWrap: "wrap",
48
- justifyContent: "space-evenly",
49
- width: "200px",
50
- children: palette && palette.map((color, i)=>/*#__PURE__*/ _jsx(IconButton, {
51
- size: "small",
52
- "aria-label": `change color to ${color}`,
53
- sx: {
54
- color
55
- },
56
- onClick: ()=>handleColorChange(color),
57
- children: /*#__PURE__*/ _jsx(CircleIcon, {})
58
- }, i))
59
- }),
60
- /*#__PURE__*/ _jsxs(Stack, {
61
- direction: "row",
62
- gap: 1,
63
- alignItems: "center",
64
- children: [
65
- /*#__PURE__*/ _jsx(TextField, {
66
- inputProps: {
67
- 'aria-label': 'enter hex color'
68
- },
69
- fullWidth: true,
70
- value: value,
71
- onChange: handleInputChange
72
- }),
73
- onClear && /*#__PURE__*/ _jsx(IconButton, {
74
- onClick: onClear,
75
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
76
- })
77
- ]
78
- })
79
- ]
80
- });
24
+ let t1;
25
+ if ($[0] !== onChange) {
26
+ t1 = (color_0)=>{
27
+ setValue(color_0);
28
+ onChange?.(color_0);
29
+ };
30
+ $[0] = onChange;
31
+ $[1] = t1;
32
+ } else {
33
+ t1 = $[1];
34
+ }
35
+ const handleColorChange = t1;
36
+ let t2;
37
+ if ($[2] !== onChange) {
38
+ t2 = (e)=>{
39
+ const inputValue = e.target.value.replace(/([^0-9A-F]+)/gi, "").substring(0, 8);
40
+ setValue(`#${inputValue}`);
41
+ if (isValidHex(e.target.value)) {
42
+ onChange?.(e.target.value);
43
+ }
44
+ };
45
+ $[2] = onChange;
46
+ $[3] = t2;
47
+ } else {
48
+ t2 = $[3];
49
+ }
50
+ const handleInputChange = t2;
51
+ let t3;
52
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
53
+ t3 = {
54
+ width: "100%"
55
+ };
56
+ $[4] = t3;
57
+ } else {
58
+ t3 = $[4];
59
+ }
60
+ let t4;
61
+ if ($[5] !== color || $[6] !== handleColorChange) {
62
+ t4 = /*#__PURE__*/ _jsx(HexColorPicker, {
63
+ color: color,
64
+ onChange: handleColorChange,
65
+ style: t3
66
+ });
67
+ $[5] = color;
68
+ $[6] = handleColorChange;
69
+ $[7] = t4;
70
+ } else {
71
+ t4 = $[7];
72
+ }
73
+ let t5;
74
+ if ($[8] !== handleColorChange || $[9] !== palette) {
75
+ t5 = palette && palette.map((color_1, i)=>/*#__PURE__*/ _jsx(IconButton, {
76
+ size: "small",
77
+ "aria-label": `change color to ${color_1}`,
78
+ sx: {
79
+ color: color_1
80
+ },
81
+ onClick: ()=>handleColorChange(color_1),
82
+ children: /*#__PURE__*/ _jsx(CircleIcon, {})
83
+ }, i));
84
+ $[8] = handleColorChange;
85
+ $[9] = palette;
86
+ $[10] = t5;
87
+ } else {
88
+ t5 = $[10];
89
+ }
90
+ let t6;
91
+ if ($[11] !== t5) {
92
+ t6 = /*#__PURE__*/ _jsx(Stack, {
93
+ direction: "row",
94
+ flexWrap: "wrap",
95
+ justifyContent: "space-evenly",
96
+ width: "200px",
97
+ children: t5
98
+ });
99
+ $[11] = t5;
100
+ $[12] = t6;
101
+ } else {
102
+ t6 = $[12];
103
+ }
104
+ let t7;
105
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
106
+ t7 = {
107
+ "aria-label": "enter hex color"
108
+ };
109
+ $[13] = t7;
110
+ } else {
111
+ t7 = $[13];
112
+ }
113
+ let t8;
114
+ if ($[14] !== handleInputChange || $[15] !== value) {
115
+ t8 = /*#__PURE__*/ _jsx(TextField, {
116
+ inputProps: t7,
117
+ fullWidth: true,
118
+ value: value,
119
+ onChange: handleInputChange
120
+ });
121
+ $[14] = handleInputChange;
122
+ $[15] = value;
123
+ $[16] = t8;
124
+ } else {
125
+ t8 = $[16];
126
+ }
127
+ let t9;
128
+ if ($[17] !== onClear) {
129
+ t9 = onClear && /*#__PURE__*/ _jsx(IconButton, {
130
+ onClick: onClear,
131
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
132
+ });
133
+ $[17] = onClear;
134
+ $[18] = t9;
135
+ } else {
136
+ t9 = $[18];
137
+ }
138
+ let t10;
139
+ if ($[19] !== t8 || $[20] !== t9) {
140
+ t10 = /*#__PURE__*/ _jsxs(Stack, {
141
+ direction: "row",
142
+ gap: 1,
143
+ alignItems: "center",
144
+ children: [
145
+ t8,
146
+ t9
147
+ ]
148
+ });
149
+ $[19] = t8;
150
+ $[20] = t9;
151
+ $[21] = t10;
152
+ } else {
153
+ t10 = $[21];
154
+ }
155
+ let t11;
156
+ if ($[22] !== t10 || $[23] !== t4 || $[24] !== t6) {
157
+ t11 = /*#__PURE__*/ _jsxs(Stack, {
158
+ spacing: 1,
159
+ children: [
160
+ t4,
161
+ t6,
162
+ t10
163
+ ]
164
+ });
165
+ $[22] = t10;
166
+ $[23] = t4;
167
+ $[24] = t6;
168
+ $[25] = t11;
169
+ } else {
170
+ t11 = $[25];
171
+ }
172
+ return t11;
81
173
  };
82
174
  const isValidHex = (value, alpha)=>{
83
175
  const matcher = /^#?([0-9A-F]{3,8})$/i;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 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 CircleIcon from 'mdi-material-ui/Circle';\nimport DeleteIcon from 'mdi-material-ui/Delete';\nimport type { ChangeEvent, ReactElement } from 'react';\nimport { useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n onClear?: () => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, onClear, palette }: ColorPickerProps): ReactElement => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string): void => {\n setValue(color);\n onChange?.(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {\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?.(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} style={{ width: '100%' }} />\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 <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n {onClear && (\n <IconButton onClick={onClear}>\n <DeleteIcon />\n </IconButton>\n )}\n </Stack>\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","CircleIcon","DeleteIcon","useState","HexColorPicker","ColorPicker","color","onChange","onClear","palette","value","setValue","handleColorChange","handleInputChange","e","inputValue","target","replace","substring","isValidHex","spacing","style","width","direction","flexWrap","justifyContent","map","i","size","aria-label","sx","onClick","gap","alignItems","inputProps","fullWidth","alpha","matcher","match","exec","length"],"mappings":";AAAA,+BAA+B;AAC/B,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,gBAAgB,yBAAyB;AAChD,OAAOC,gBAAgB,yBAAyB;AAEhD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,cAAc,QAAQ,iBAAiB;AAYhD,OAAO,MAAMC,cAAc,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAoB;IACjF,2DAA2D;IAC3D,MAAM,CAACC,OAAOC,SAAS,GAAGR,SAASG;IAEnC,MAAMM,oBAAoB,CAACN;QACzBK,SAASL;QACTC,WAAWD;IACb;IAEA,6FAA6F;IAC7F,MAAMO,oBAAoB,CAACC;QACzB,MAAMC,aAAaD,EAAEE,MAAM,CAACN,KAAK,CAACO,OAAO,CAAC,kBAAkB,IAAIC,SAAS,CAAC,GAAG;QAC7EP,SAAS,CAAC,CAAC,EAAEI,YAAY,GAAG,0DAA0D;QACtF,qDAAqD;QACrD,IAAII,WAAWL,EAAEE,MAAM,CAACN,KAAK,GAAG;YAC9BH,WAAWO,EAAEE,MAAM,CAACN,KAAK;QAC3B;IACF;IAEA,qBACE,MAACX;QAAMqB,SAAS;;0BACd,KAAChB;gBAAeE,OAAOA;gBAAOC,UAAUK;gBAAmBS,OAAO;oBAAEC,OAAO;gBAAO;;0BAClF,KAACvB;gBAAMwB,WAAU;gBAAMC,UAAS;gBAAOC,gBAAe;gBAAeH,OAAM;0BACxEb,WACCA,QAAQiB,GAAG,CAAC,CAACpB,OAAOqB,kBAClB,KAAC7B;wBAEC8B,MAAK;wBACLC,cAAY,CAAC,gBAAgB,EAAEvB,OAAO;wBACtCwB,IAAI;4BAAExB;wBAAM;wBACZyB,SAAS,IAAMnB,kBAAkBN;kCAEjC,cAAA,KAACL;uBANI0B;;0BAUb,MAAC5B;gBAAMwB,WAAU;gBAAMS,KAAK;gBAAGC,YAAW;;kCACxC,KAACjC;wBACCkC,YAAY;4BAAE,cAAc;wBAAkB;wBAC9CC,SAAS;wBACTzB,OAAOA;wBACPH,UAAUM;;oBAEXL,yBACC,KAACV;wBAAWiC,SAASvB;kCACnB,cAAA,KAACN;;;;;;AAMb,EAAE;AAEF,MAAMiB,aAAa,CAACT,OAAe0B;IACjC,MAAMC,UAAU;IAChB,MAAMC,QAAQD,QAAQE,IAAI,CAAC7B;IAC3B,MAAM8B,SAASF,SAASA,KAAK,CAAC,EAAE,GAAGA,KAAK,CAAC,EAAE,CAACE,MAAM,GAAG;IACrD,OACEA,WAAW,KAAK,gBAAgB;IAChCA,WAAW,KAAK,mBAAmB;IAClC,CAAC,CAACJ,SAASI,WAAW,KAAM,iBAAiB;IAC7C,CAAC,CAACJ,SAASI,WAAW,EAAG,qBAAqB;;AAEnD"}
1
+ {"version":3,"sources":["../../src/ColorPicker/ColorPicker.tsx"],"sourcesContent":["// Copyright 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 CircleIcon from 'mdi-material-ui/Circle';\nimport DeleteIcon from 'mdi-material-ui/Delete';\nimport type { ChangeEvent, ReactElement } from 'react';\nimport { useState } from 'react';\nimport { HexColorPicker } from 'react-colorful';\n\ninterface ColorPickerProps {\n color: string;\n onChange?: (color: string) => void;\n onClear?: () => void;\n /**\n * Preset color palette\n */\n palette?: string[];\n}\n\nexport const ColorPicker = ({ color, onChange, onClear, palette }: ColorPickerProps): ReactElement => {\n // value is the visible value for the controlled text input\n const [value, setValue] = useState(color);\n\n const handleColorChange = (color: string): void => {\n setValue(color);\n onChange?.(color);\n };\n\n // we should update this if https://github.com/omgovich/react-colorful/issues/157 is resolved\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>): void => {\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?.(e.target.value);\n }\n };\n\n return (\n <Stack spacing={1}>\n <HexColorPicker color={color} onChange={handleColorChange} style={{ width: '100%' }} />\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 <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <TextField\n inputProps={{ 'aria-label': 'enter hex color' }}\n fullWidth\n value={value}\n onChange={handleInputChange}\n />\n {onClear && (\n <IconButton onClick={onClear}>\n <DeleteIcon />\n </IconButton>\n )}\n </Stack>\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","CircleIcon","DeleteIcon","useState","HexColorPicker","ColorPicker","isValidHex","value","alpha","matcher","match","exec","length"],"mappings":";;AAAA,+BAA+B;AAC/B,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,gBAAgB,yBAAyB;AAChD,OAAOC,gBAAgB,yBAAyB;AAEhD,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,cAAc,QAAQ,iBAAiB;AAYhD,OAAO,MAAMC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDzB;AAEF,MAAMC,aAAa,CAACC,OAAeC;IACjC,MAAMC,UAAU;IAChB,MAAMC,QAAQD,QAAQE,IAAI,CAACJ;IAC3B,MAAMK,SAASF,SAASA,KAAM,CAAA,EAAC,AAAC,GAAGA,KAAM,CAAA,EAAC,AAAC,CAACE,MAAM,GAAG;IACrD,OACEA,WAAW,KAAK,gBAAgB;IAChCA,WAAW,KAAK,mBAAmB;IAClC,CAAC,CAACJ,SAASI,WAAW,KAAM,iBAAiB;IAC7C,CAAC,CAACJ,SAASI,WAAW,EAAG,qBAAqB;;AAEnD"}