@lvce-editor/output-view 1.5.0 → 1.7.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.
@@ -960,7 +960,8 @@ const create$1 = (id, uri, x, y, width, height, workspaceUri) => {
960
960
  workspaceUri,
961
961
  options: [],
962
962
  error: '',
963
- errorCode: 0
963
+ errorCode: 0,
964
+ buttons: []
964
965
  };
965
966
  set$1(id, state, state);
966
967
  };
@@ -1046,13 +1047,17 @@ const KeyCode = {
1046
1047
  const mergeClassNames = (...classNames) => {
1047
1048
  return classNames.filter(Boolean).join(' ');
1048
1049
  };
1050
+ const Button$1 = 1;
1049
1051
  const Div = 4;
1052
+ const Input = 6;
1050
1053
  const Text = 12;
1051
1054
  const Select$2 = 63;
1052
1055
  const Option$1 = 64;
1053
1056
  const VirtualDomElements = {
1054
1057
  __proto__: null,
1058
+ Button: Button$1,
1055
1059
  Div,
1060
+ Input,
1056
1061
  Option: Option$1,
1057
1062
  Select: Select$2};
1058
1063
  const text = data => {
@@ -1113,6 +1118,13 @@ const getKeyBindings$1 = () => {
1113
1118
  }];
1114
1119
  };
1115
1120
 
1121
+ const handleButtonClick = async (state, name) => {
1122
+ // TODO
1123
+ return {
1124
+ ...state
1125
+ };
1126
+ };
1127
+
1116
1128
  const handleData = async state => {
1117
1129
  // TODO
1118
1130
  return {
@@ -1127,6 +1139,13 @@ const handleError = async state => {
1127
1139
  };
1128
1140
  };
1129
1141
 
1142
+ const handleFilterInput = async (state, value) => {
1143
+ return {
1144
+ ...state,
1145
+ filterValue: value
1146
+ };
1147
+ };
1148
+
1130
1149
  const rpcs = Object.create(null);
1131
1150
  const set$g = (id, rpc) => {
1132
1151
  rpcs[id] = rpc;
@@ -1549,6 +1568,22 @@ const getSelectedItem = platform => {
1549
1568
  return 'file:///tmp/log-main-process.txt';
1550
1569
  };
1551
1570
 
1571
+ const loadButtons = () => {
1572
+ return [{
1573
+ id: 'Clear',
1574
+ label: 'Clear',
1575
+ icon: 'MaskIconClearAll'
1576
+ }, {
1577
+ id: 'Scroll Lock',
1578
+ label: 'Scroll Lock',
1579
+ icon: 'MaskIconListFlat'
1580
+ }, {
1581
+ id: 'Settings',
1582
+ label: 'Settings',
1583
+ icon: 'MaskIconListFlat'
1584
+ }];
1585
+ };
1586
+
1552
1587
  const Filter = 'filter';
1553
1588
  const Output$2 = 'output';
1554
1589
  const MainProcess = 'MainProcess';
@@ -1557,10 +1592,12 @@ const SharedProcess = 'SharedProcess';
1557
1592
  const loadOptions = async platform => {
1558
1593
  return [{
1559
1594
  id: MainProcess,
1595
+ label: 'Main Process',
1560
1596
  uri: 'file:///tmp/log-main-process.txt'
1561
1597
  }, {
1562
1598
  id: SharedProcess,
1563
- uri: 'File:///tmp/log-shared-process.txt'
1599
+ label: 'Shared Process',
1600
+ uri: 'file:///tmp/log-shared-process.txt'
1564
1601
  }];
1565
1602
  };
1566
1603
 
@@ -1582,6 +1619,7 @@ const loadContent = async (state, savedState) => {
1582
1619
  error,
1583
1620
  code
1584
1621
  } = await loadLines(selectedUri);
1622
+ const buttons = loadButtons();
1585
1623
  return {
1586
1624
  ...state,
1587
1625
  collapsedUris,
@@ -1590,7 +1628,8 @@ const loadContent = async (state, savedState) => {
1590
1628
  inputSource: Script,
1591
1629
  listItems: lines,
1592
1630
  options,
1593
- selectedOption: selectedUri
1631
+ selectedOption: selectedUri,
1632
+ buttons
1594
1633
  };
1595
1634
  };
1596
1635
 
@@ -1674,6 +1713,8 @@ const renderFilterValue = (oldState, newState) => {
1674
1713
  return ['Viewlet.setValueByName', Filter, newState.filterValue];
1675
1714
  };
1676
1715
 
1716
+ const IconButton = 'IconButton';
1717
+ const MaskIcon = 'MaskIcon';
1677
1718
  const Actions = 'Actions';
1678
1719
  const Viewlet = 'Viewlet';
1679
1720
  const Output = 'Output';
@@ -1777,13 +1818,57 @@ const HandleContextMenu = 'handleContextMenu';
1777
1818
  const HandleFilterInput = 'handleFilterInput';
1778
1819
  const HandlePointerDown = 'handlePointerDown';
1779
1820
  const HandleSelect = 'handleSelect';
1821
+ const HandleButtonClick = 'handleButtonClick';
1822
+
1823
+ const getActionButtonVirtualDom = button => {
1824
+ const {
1825
+ id,
1826
+ label,
1827
+ icon
1828
+ } = button;
1829
+ return [{
1830
+ type: VirtualDomElements.Button,
1831
+ className: IconButton,
1832
+ name: id,
1833
+ title: label,
1834
+ childCount: 1,
1835
+ onClick: HandleButtonClick
1836
+ }, {
1837
+ type: VirtualDomElements.Div,
1838
+ className: mergeClassNames(MaskIcon, icon)
1839
+ }];
1840
+ };
1841
+
1842
+ const getActionButtonsVirtualDom = buttons => {
1843
+ return buttons.flatMap(getActionButtonVirtualDom);
1844
+ };
1845
+
1846
+ const getFilterVirtualDom = () => {
1847
+ const placeholder = 'Filter';
1848
+ return [{
1849
+ type: VirtualDomElements.Div,
1850
+ className: 'Filter',
1851
+ childCount: 1
1852
+ }, {
1853
+ type: VirtualDomElements.Input,
1854
+ className: 'InputBox FilterInput',
1855
+ childCount: 0,
1856
+ placeholder,
1857
+ onInput: HandleFilterInput
1858
+ }];
1859
+ };
1780
1860
 
1781
1861
  const getOptionVirtualDom = option => {
1862
+ const {
1863
+ id,
1864
+ label
1865
+ } = option;
1782
1866
  return [{
1783
1867
  type: VirtualDomElements.Option,
1784
1868
  className: Option,
1785
- childCount: 1
1786
- }, text(option.id)];
1869
+ childCount: 1,
1870
+ value: id
1871
+ }, text(label)];
1787
1872
  };
1788
1873
 
1789
1874
  const getSelectVirtualDom = options => {
@@ -1796,20 +1881,27 @@ const getSelectVirtualDom = options => {
1796
1881
  }, ...options.flatMap(getOptionVirtualDom)];
1797
1882
  };
1798
1883
 
1799
- const getActionsVirtualDom = options => {
1884
+ const getChildCount = buttonsLength => {
1885
+ const selectLength = 1;
1886
+ const filterCount = 1;
1887
+ return buttonsLength + filterCount + selectLength;
1888
+ };
1889
+ const getActionsVirtualDom = (options, buttons) => {
1890
+ const childCount = getChildCount(buttons.length);
1800
1891
  return [{
1801
1892
  type: VirtualDomElements.Div,
1802
1893
  className: Actions,
1803
1894
  role: AriaRoles.ToolBar,
1804
- childCount: 1
1805
- }, ...getSelectVirtualDom(options)];
1895
+ childCount
1896
+ }, ...getFilterVirtualDom(), ...getSelectVirtualDom(options), ...getActionButtonsVirtualDom(buttons)];
1806
1897
  };
1807
1898
 
1808
1899
  const renderActions = state => {
1809
1900
  const {
1810
- options
1901
+ options,
1902
+ buttons
1811
1903
  } = state;
1812
- const dom = getActionsVirtualDom(options);
1904
+ const dom = getActionsVirtualDom(options, buttons);
1813
1905
  return dom;
1814
1906
  };
1815
1907
 
@@ -1817,6 +1909,9 @@ const renderEventListeners = () => {
1817
1909
  return [{
1818
1910
  name: HandleBlur,
1819
1911
  params: ['handleBlur']
1912
+ }, {
1913
+ name: HandleButtonClick,
1914
+ params: ['handleButtonClick', 'event.target.name']
1820
1915
  }, {
1821
1916
  name: HandleSelect,
1822
1917
  params: ['handleSelect', 'event.target.value']
@@ -1882,7 +1977,9 @@ const commandMap = {
1882
1977
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
1883
1978
  'Output.getActions': getActions,
1884
1979
  'Output.terminate': terminate,
1885
- 'Output.handleSelect': wrapCommand(handleSelect)
1980
+ 'Output.handleSelect': wrapCommand(handleSelect),
1981
+ 'Output.handleFilterInput': wrapCommand(handleFilterInput),
1982
+ 'Output.handleButtonClick': wrapCommand(handleButtonClick)
1886
1983
  };
1887
1984
 
1888
1985
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",