@bpmn-io/properties-panel 2.0.0 → 2.1.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.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useContext, useRef, useEffect, useMemo, useCallback, useState, useLayoutEffect } from '../preact/hooks';
2
- import { isFunction, isArray, get, assign, set, sortBy, find, isNumber, debounce } from 'min-dash';
2
+ import { isFunction, isArray, get, assign, set, sortBy, find, isString, isNumber, debounce } from 'min-dash';
3
3
  import { forwardRef } from '../preact/compat';
4
4
  import { jsx, jsxs } from '../preact/jsx-runtime';
5
5
  import classnames from 'classnames';
@@ -67,44 +67,18 @@ ExternalLinkIcon.defaultProps = {
67
67
  fill: "none",
68
68
  xmlns: "http://www.w3.org/2000/svg"
69
69
  };
70
- var FeelRequiredIcon = function FeelRequiredIcon(props) {
71
- return jsxs("svg", {
72
- ...props,
73
- children: [jsx("path", {
74
- d: "M5.8 7.06V5.95h4.307v1.11H5.8Zm0 3.071v-1.11h4.307v1.11H5.8Z",
75
- fill: "currentColor"
76
- }), jsx("path", {
77
- fillRule: "evenodd",
78
- clipRule: "evenodd",
79
- d: "M8 3.268A4.732 4.732 0 1 0 12.732 8H14a6 6 0 1 1-6-6v1.268Z",
80
- fill: "currentColor"
81
- }), jsx("path", {
82
- d: "m11.28 6.072-.832-.56 1.016-1.224L10 3.848l.312-.912 1.392.584L11.632 2h1.032l-.072 1.52 1.392-.584.312.912-1.464.44 1.008 1.224-.832.552-.864-1.296-.864 1.304Z",
83
- fill: "currentColor"
84
- })]
85
- });
86
- };
87
- FeelRequiredIcon.defaultProps = {
88
- viewBox: "0 0 16 16",
89
- fill: "none",
90
- xmlns: "http://www.w3.org/2000/svg"
91
- };
92
- var FeelOptionalIcon = function FeelOptionalIcon(props) {
93
- return jsxs("svg", {
70
+ var FeelIcon$1 = function FeelIcon(props) {
71
+ return jsx("svg", {
94
72
  ...props,
95
- children: [jsx("path", {
96
- d: "M5.845 7.04V5.93h4.307v1.11H5.845Zm0 3.07V9h4.307v1.11H5.845Z",
97
- fill: "currentColor"
98
- }), jsx("path", {
99
- fillRule: "evenodd",
100
- clipRule: "evenodd",
101
- d: "M3.286 8a4.714 4.714 0 1 0 9.428 0 4.714 4.714 0 0 0-9.428 0ZM8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Z",
102
- fill: "currentColor"
103
- })]
73
+ children: jsx("path", {
74
+ d: "M3.617 11.99c-.137.684-.392 1.19-.765 1.518-.362.328-.882.492-1.558.492H0l.309-1.579h1.264l1.515-7.64h-.912l.309-1.579h.911l.236-1.191c.137-.685.387-1.192.75-1.52C4.753.164 5.277 0 5.953 0h1.294L6.94 1.579H5.675l-.323 1.623h1.264l-.309 1.579H5.043l-1.426 7.208ZM5.605 11.021l3.029-4.155L7.28 3.202h2.073l.706 2.547h.176l1.691-2.547H14l-3.014 4.051 1.338 3.768H10.25l-.706-2.606H9.37L7.678 11.02H5.605Z",
75
+ fill: "currentcolor"
76
+ })
104
77
  });
105
78
  };
106
- FeelOptionalIcon.defaultProps = {
107
- viewBox: "0 0 16 16",
79
+ FeelIcon$1.defaultProps = {
80
+ width: "14",
81
+ height: "14",
108
82
  fill: "none",
109
83
  xmlns: "http://www.w3.org/2000/svg"
110
84
  };
@@ -1509,14 +1483,13 @@ const noop$2 = () => {};
1509
1483
  */
1510
1484
  function FeelIcon(props) {
1511
1485
  const {
1512
- label,
1513
1486
  feel = false,
1514
1487
  active,
1515
1488
  disabled = false,
1516
1489
  onClick = noop$2
1517
1490
  } = props;
1518
- const feelRequiredLabel = ' must be a FEEL expression';
1519
- const feelOptionalLabel = ' can optionally be a FEEL expression';
1491
+ const feelRequiredLabel = 'FEEL expression is mandatory';
1492
+ const feelOptionalLabel = `Click to ${active ? 'remove' : 'set a'} dynamic value with FEEL expression`;
1520
1493
  const handleClick = e => {
1521
1494
  onClick(e);
1522
1495
 
@@ -1529,11 +1502,126 @@ function FeelIcon(props) {
1529
1502
  class: classnames('bio-properties-panel-feel-icon', active ? 'active' : null, feel === 'required' ? 'required' : 'optional'),
1530
1503
  onClick: handleClick,
1531
1504
  disabled: feel === 'required' || disabled,
1532
- title: label + (feel === 'required' ? feelRequiredLabel : feelOptionalLabel),
1533
- children: feel === 'required' ? jsx(FeelRequiredIcon, {}) : jsx(FeelOptionalIcon, {})
1505
+ title: feel === 'required' ? feelRequiredLabel : feelOptionalLabel,
1506
+ children: jsx(FeelIcon$1, {})
1534
1507
  });
1535
1508
  }
1536
1509
 
1510
+ function ToggleSwitch(props) {
1511
+ const {
1512
+ id,
1513
+ label,
1514
+ onInput,
1515
+ value,
1516
+ switcherLabel,
1517
+ inline,
1518
+ onFocus,
1519
+ onBlur,
1520
+ inputRef
1521
+ } = props;
1522
+ const [localValue, setLocalValue] = useState(value);
1523
+ const handleInputCallback = async () => {
1524
+ onInput(!value);
1525
+ };
1526
+ const handleInput = e => {
1527
+ handleInputCallback();
1528
+ setLocalValue(e.target.value);
1529
+ };
1530
+ useEffect(() => {
1531
+ if (value === localValue) {
1532
+ return;
1533
+ }
1534
+ setLocalValue(value);
1535
+ }, [value]);
1536
+ return jsxs("div", {
1537
+ class: classnames('bio-properties-panel-toggle-switch', {
1538
+ inline
1539
+ }),
1540
+ children: [jsx("label", {
1541
+ class: "bio-properties-panel-label",
1542
+ for: prefixId$6(id),
1543
+ children: label
1544
+ }), jsxs("div", {
1545
+ class: "bio-properties-panel-field-wrapper",
1546
+ children: [jsxs("label", {
1547
+ class: "bio-properties-panel-toggle-switch__switcher",
1548
+ children: [jsx("input", {
1549
+ ref: inputRef,
1550
+ id: prefixId$6(id),
1551
+ class: "bio-properties-panel-input",
1552
+ type: "checkbox",
1553
+ onFocus: onFocus,
1554
+ onBlur: onBlur,
1555
+ name: id,
1556
+ onInput: handleInput,
1557
+ checked: !!localValue
1558
+ }), jsx("span", {
1559
+ class: "bio-properties-panel-toggle-switch__slider"
1560
+ })]
1561
+ }), switcherLabel && jsx("p", {
1562
+ class: "bio-properties-panel-toggle-switch__label",
1563
+ children: switcherLabel
1564
+ })]
1565
+ })]
1566
+ });
1567
+ }
1568
+
1569
+ /**
1570
+ * @param {Object} props
1571
+ * @param {Object} props.element
1572
+ * @param {String} props.id
1573
+ * @param {String} props.description
1574
+ * @param {String} props.label
1575
+ * @param {String} props.switcherLabel
1576
+ * @param {Boolean} props.inline
1577
+ * @param {Function} props.getValue
1578
+ * @param {Function} props.setValue
1579
+ * @param {Function} props.onFocus
1580
+ * @param {Function} props.onBlur
1581
+ */
1582
+ function ToggleSwitchEntry(props) {
1583
+ const {
1584
+ element,
1585
+ id,
1586
+ description,
1587
+ label,
1588
+ switcherLabel,
1589
+ inline,
1590
+ getValue,
1591
+ setValue,
1592
+ onFocus,
1593
+ onBlur
1594
+ } = props;
1595
+ const value = getValue(element);
1596
+ return jsxs("div", {
1597
+ class: "bio-properties-panel-entry bio-properties-panel-toggle-switch-entry",
1598
+ "data-entry-id": id,
1599
+ children: [jsx(ToggleSwitch, {
1600
+ id: id,
1601
+ label: label,
1602
+ value: value,
1603
+ onInput: setValue,
1604
+ onFocus: onFocus,
1605
+ onBlur: onBlur,
1606
+ switcherLabel: switcherLabel,
1607
+ inline: inline
1608
+ }), jsx(Description, {
1609
+ forId: id,
1610
+ element: element,
1611
+ value: description
1612
+ })]
1613
+ });
1614
+ }
1615
+ function isEdited$7(node) {
1616
+ return node && !!node.checked;
1617
+ }
1618
+
1619
+ // helpers /////////////////
1620
+
1621
+ function prefixId$6(id) {
1622
+ return `bio-properties-panel-${id}`;
1623
+ }
1624
+
1537
1625
  const noop$1 = () => {};
1538
1626
  function FeelTextfield(props) {
1539
1627
  const {
@@ -1552,8 +1640,8 @@ function FeelTextfield(props) {
1552
1640
  const [localValue, _setLocalValue] = useState(value);
1553
1641
  const editorRef = useShowEntryEvent(id);
1554
1642
  const containerRef = useRef();
1555
- const feelActive = localValue.startsWith('=') || feel === 'required';
1556
- const feelOnlyValue = localValue.startsWith('=') ? localValue.substring(1) : localValue;
1643
+ const feelActive = isString(localValue) && localValue.startsWith('=') || feel === 'required';
1644
+ const feelOnlyValue = isString(localValue) && localValue.startsWith('=') ? localValue.substring(1) : localValue;
1557
1645
  const [focus, _setFocus] = useState(undefined);
1558
1646
  const setFocus = (offset = 0) => {
1559
1647
  const hasFocus = containerRef.current.contains(document.activeElement);
@@ -1593,7 +1681,7 @@ function FeelTextfield(props) {
1593
1681
  return;
1594
1682
  }
1595
1683
  setLocalValue(newValue);
1596
- if (!feelActive && newValue.startsWith('=')) {
1684
+ if (!feelActive && isString(newValue) && newValue.startsWith('=')) {
1597
1685
  // focus is behind `=` sign that will be removed
1598
1686
  setFocus(-1);
1599
1687
  }
@@ -1656,9 +1744,11 @@ function FeelTextfield(props) {
1656
1744
  };
1657
1745
  }, [containerRef, feelActive, handleFeelToggle, setFocus]);
1658
1746
  return jsxs("div", {
1659
- class: "bio-properties-panel-feel-entry",
1747
+ class: classnames('bio-properties-panel-feel-entry', {
1748
+ 'feel-active': feelActive
1749
+ }),
1660
1750
  children: [jsxs("label", {
1661
- for: prefixId$6(id),
1751
+ for: prefixId$5(id),
1662
1752
  class: "bio-properties-panel-label",
1663
1753
  onClick: () => setFocus(),
1664
1754
  children: [label, jsx(FeelIcon, {
@@ -1675,7 +1765,7 @@ function FeelTextfield(props) {
1675
1765
  disabled: feel !== 'optional' || disabled,
1676
1766
  onClick: handleFeelToggle
1677
1767
  }), feelActive ? jsx(CodeEditor, {
1678
- id: prefixId$6(id),
1768
+ id: prefixId$5(id),
1679
1769
  name: id,
1680
1770
  onInput: handleLocalInput,
1681
1771
  disabled: disabled,
@@ -1692,7 +1782,8 @@ function FeelTextfield(props) {
1692
1782
  ...props,
1693
1783
  onInput: handleLocalInput,
1694
1784
  contentAttributes: {
1695
- 'id': prefixId$6(id)
1785
+ 'id': prefixId$5(id),
1786
+ 'aria-label': label
1696
1787
  },
1697
1788
  value: localValue,
1698
1789
  ref: editorRef
@@ -1729,7 +1820,7 @@ const OptionalFeelInput = forwardRef((props, ref) => {
1729
1820
  }
1730
1821
  };
1731
1822
  return jsx("input", {
1732
- id: prefixId$6(id),
1823
+ id: prefixId$5(id),
1733
1824
  type: "text",
1734
1825
  ref: inputRef,
1735
1826
  name: id,
@@ -1767,7 +1858,7 @@ const OptionalFeelTextArea = forwardRef((props, ref) => {
1767
1858
  }
1768
1859
  };
1769
1860
  return jsx("textarea", {
1770
- id: prefixId$6(id),
1861
+ id: prefixId$5(id),
1771
1862
  type: "text",
1772
1863
  ref: inputRef,
1773
1864
  name: id,
@@ -1782,6 +1873,78 @@ const OptionalFeelTextArea = forwardRef((props, ref) => {
1782
1873
  "data-gramm": "false"
1783
1874
  });
1784
1875
  });
1876
+ const OptionalFeelToggleSwitch = forwardRef((props, ref) => {
1877
+ const {
1878
+ id,
1879
+ onInput,
1880
+ value,
1881
+ onFocus,
1882
+ onBlur,
1883
+ switcherLabel
1884
+ } = props;
1885
+ const inputRef = useRef();
1886
+
1887
+ // To be consistent with the FEEL editor, set focus at start of input
1888
+ // this ensures clean editing experience when switching with the keyboard
1889
+ ref.current = {
1890
+ focus: () => {
1891
+ const input = inputRef.current;
1892
+ if (!input) {
1893
+ return;
1894
+ }
1895
+ input.focus();
1896
+ }
1897
+ };
1898
+ return jsx(ToggleSwitch, {
1899
+ id: id,
1900
+ value: value,
1901
+ inputRef: inputRef,
1902
+ onInput: onInput,
1903
+ onFocus: onFocus,
1904
+ onBlur: onBlur,
1905
+ switcherLabel: switcherLabel
1906
+ });
1907
+ });
1908
+ const OptionalFeelCheckbox = forwardRef((props, ref) => {
1909
+ const {
1910
+ id,
1911
+ disabled,
1912
+ onInput,
1913
+ value,
1914
+ onFocus,
1915
+ onBlur
1916
+ } = props;
1917
+ const inputRef = useRef();
1918
+ const handleChange = ({
1919
+ target
1920
+ }) => {
1921
+ onInput(target.checked);
1922
+ };
1923
+
1924
+ // To be consistent with the FEEL editor, set focus at start of input
1925
+ // this ensures clean editing experience when switching with the keyboard
1926
+ ref.current = {
1927
+ focus: () => {
1928
+ const input = inputRef.current;
1929
+ if (!input) {
1930
+ return;
1931
+ }
1932
+ input.focus();
1933
+ }
1934
+ };
1935
+ return jsx("input", {
1936
+ ref: inputRef,
1937
+ id: prefixId$5(id),
1938
+ name: id,
1939
+ onFocus: onFocus,
1940
+ onBlur: onBlur,
1941
+ type: "checkbox",
1942
+ class: "bio-properties-panel-input",
1943
+ onChange: handleChange,
1944
+ checked: value,
1945
+ disabled: disabled
1946
+ });
1947
+ });
1785
1948
 
1786
1949
  /**
1787
1950
  * @param {Object} props
@@ -1916,6 +2079,60 @@ function FeelTextAreaEntry(props) {
1916
2079
  });
1917
2080
  }
1918
2081
 
2082
+ /**
2083
+ * @param {Object} props
2084
+ * @param {Object} props.element
2085
+ * @param {String} props.id
2086
+ * @param {String} props.description
2087
+ * @param {Boolean} props.debounce
2088
+ * @param {Boolean} props.disabled
2089
+ * @param {Boolean} props.feel
2090
+ * @param {String} props.label
2091
+ * @param {Function} props.getValue
2092
+ * @param {Function} props.setValue
2093
+ * @param {Function} props.tooltipContainer
2094
+ * @param {Function} props.validate
2095
+ * @param {Function} props.show
2096
+ * @param {Function} props.example
2097
+ * @param {Function} props.variables
2098
+ * @param {Function} props.onFocus
2099
+ * @param {Function} props.onBlur
2100
+ */
2101
+ function FeelToggleSwitchEntry(props) {
2102
+ return jsx(FeelEntry, {
2103
+ class: "bio-properties-panel-feel-toggle-switch",
2104
+ OptionalComponent: OptionalFeelToggleSwitch,
2105
+ ...props
2106
+ });
2107
+ }
2108
+
2109
+ /**
2110
+ * @param {Object} props
2111
+ * @param {Object} props.element
2112
+ * @param {String} props.id
2113
+ * @param {String} props.description
2114
+ * @param {Boolean} props.debounce
2115
+ * @param {Boolean} props.disabled
2116
+ * @param {Boolean} props.feel
2117
+ * @param {String} props.label
2118
+ * @param {Function} props.getValue
2119
+ * @param {Function} props.setValue
2120
+ * @param {Function} props.tooltipContainer
2121
+ * @param {Function} props.validate
2122
+ * @param {Function} props.show
2123
+ * @param {Function} props.example
2124
+ * @param {Function} props.variables
2125
+ * @param {Function} props.onFocus
2126
+ * @param {Function} props.onBlur
2127
+ */
2128
+ function FeelCheckboxEntry(props) {
2129
+ return jsx(FeelEntry, {
2130
+ class: "bio-properties-panel-feel-checkbox",
2131
+ OptionalComponent: OptionalFeelCheckbox,
2132
+ ...props
2133
+ });
2134
+ }
2135
+
1919
2136
  /**
1920
2137
  * @param {Object} props
1921
2138
  * @param {Object} props.element
@@ -1944,13 +2161,19 @@ function FeelTemplatingEntry(props) {
1944
2161
  ...props
1945
2162
  });
1946
2163
  }
1947
- function isEdited$7(node) {
1948
- return node && (!!node.value || node.classList.contains('edited'));
2164
+ function isEdited$6(node) {
2165
+ if (!node) {
2166
+ return false;
2167
+ }
2168
+ if (node.type === 'checkbox') {
2169
+ return !!node.checked || node.classList.contains('edited');
2170
+ }
2171
+ return !!node.value || node.classList.contains('edited');
1949
2172
  }
1950
2173
 
1951
2174
  // helpers /////////////////
1952
2175
 
1953
- function prefixId$6(id) {
2176
+ function prefixId$5(id) {
1954
2177
  return `bio-properties-panel-${id}`;
1955
2178
  }
1956
2179
 
@@ -2117,7 +2340,7 @@ function Templating(props) {
2117
2340
  })]
2118
2341
  });
2119
2342
  }
2120
- function isEdited$6(node) {
2343
+ function isEdited$5(node) {
2121
2344
  return node && (!!node.value || node.classList.contains('edited'));
2122
2345
  }
2123
2346
 
@@ -2349,11 +2572,11 @@ function NumberField(props) {
2349
2572
  return jsxs("div", {
2350
2573
  class: "bio-properties-panel-numberfield",
2351
2574
  children: [jsx("label", {
2352
- for: prefixId$5(id),
2575
+ for: prefixId$4(id),
2353
2576
  class: "bio-properties-panel-label",
2354
2577
  children: label
2355
2578
  }), jsx("input", {
2356
- id: prefixId$5(id),
2579
+ id: prefixId$4(id),
2357
2580
  type: "number",
2358
2581
  name: id,
2359
2582
  spellCheck: "false",
@@ -2457,13 +2680,13 @@ function NumberFieldEntry(props) {
2457
2680
  })]
2458
2681
  });
2459
2682
  }
2460
- function isEdited$5(node) {
2683
+ function isEdited$4(node) {
2461
2684
  return node && !!node.value;
2462
2685
  }
2463
2686
 
2464
2687
  // helpers /////////////////
2465
2688
 
2466
- function prefixId$5(id) {
2689
+ function prefixId$4(id) {
2467
2690
  return `bio-properties-panel-${id}`;
2468
2691
  }
2469
2692
 
@@ -2498,12 +2721,12 @@ function Select(props) {
2498
2721
  return jsxs("div", {
2499
2722
  class: "bio-properties-panel-select",
2500
2723
  children: [jsx("label", {
2501
- for: prefixId$4(id),
2724
+ for: prefixId$3(id),
2502
2725
  class: "bio-properties-panel-label",
2503
2726
  children: label
2504
2727
  }), jsx("select", {
2505
2728
  ref: ref,
2506
- id: prefixId$4(id),
2729
+ id: prefixId$3(id),
2507
2730
  name: id,
2508
2731
  class: "bio-properties-panel-input",
2509
2732
  onInput: handleChange,
@@ -2610,13 +2833,13 @@ function SelectEntry(props) {
2610
2833
  })]
2611
2834
  });
2612
2835
  }
2613
- function isEdited$4(node) {
2836
+ function isEdited$3(node) {
2614
2837
  return node && !!node.value;
2615
2838
  }
2616
2839
 
2617
2840
  // helpers /////////////////
2618
2841
 
2619
- function prefixId$4(id) {
2842
+ function prefixId$3(id) {
2620
2843
  return `bio-properties-panel-${id}`;
2621
2844
  }
2622
2845
 
@@ -2651,7 +2874,7 @@ function Simple(props) {
2651
2874
  return jsx("div", {
2652
2875
  class: "bio-properties-panel-simple",
2653
2876
  children: jsx("input", {
2654
- id: prefixId$3(id),
2877
+ id: prefixId$2(id),
2655
2878
  type: "text",
2656
2879
  name: id,
2657
2880
  spellCheck: "false",
@@ -2666,13 +2889,13 @@ function Simple(props) {
2666
2889
  }, element)
2667
2890
  });
2668
2891
  }
2669
- function isEdited$3(node) {
2892
+ function isEdited$2(node) {
2670
2893
  return node && !!node.value;
2671
2894
  }
2672
2895
 
2673
2896
  // helpers /////////////////
2674
2897
 
2675
- function prefixId$3(id) {
2898
+ function prefixId$2(id) {
2676
2899
  return `bio-properties-panel-${id}`;
2677
2900
  }
2678
2901
 
@@ -2721,12 +2944,12 @@ function TextArea(props) {
2721
2944
  return jsxs("div", {
2722
2945
  class: "bio-properties-panel-textarea",
2723
2946
  children: [jsx("label", {
2724
- for: prefixId$2(id),
2947
+ for: prefixId$1(id),
2725
2948
  class: "bio-properties-panel-label",
2726
2949
  children: label
2727
2950
  }), jsx("textarea", {
2728
2951
  ref: ref,
2729
- id: prefixId$2(id),
2952
+ id: prefixId$1(id),
2730
2953
  name: id,
2731
2954
  spellCheck: "false",
2732
2955
  class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : '', autoResize ? 'auto-resize' : ''),
@@ -2826,13 +3049,13 @@ function TextAreaEntry(props) {
2826
3049
  })]
2827
3050
  });
2828
3051
  }
2829
- function isEdited$2(node) {
3052
+ function isEdited$1(node) {
2830
3053
  return node && !!node.value;
2831
3054
  }
2832
3055
 
2833
3056
  // helpers /////////////////
2834
3057
 
2835
- function prefixId$2(id) {
3058
+ function prefixId$1(id) {
2836
3059
  return `bio-properties-panel-${id}`;
2837
3060
  }
2838
3061
 
@@ -2867,12 +3090,12 @@ function Textfield(props) {
2867
3090
  return jsxs("div", {
2868
3091
  class: "bio-properties-panel-textfield",
2869
3092
  children: [jsx("label", {
2870
- for: prefixId$1(id),
3093
+ for: prefixId(id),
2871
3094
  class: "bio-properties-panel-label",
2872
3095
  children: label
2873
3096
  }), jsx("input", {
2874
3097
  ref: ref,
2875
- id: prefixId$1(id),
3098
+ id: prefixId(id),
2876
3099
  type: "text",
2877
3100
  name: id,
2878
3101
  spellCheck: "false",
@@ -2964,115 +3187,8 @@ function TextfieldEntry(props) {
2964
3187
  })]
2965
3188
  });
2966
3189
  }
2967
- function isEdited$1(node) {
2968
- return node && !!node.value;
2969
- }
2970
-
2971
- // helpers /////////////////
2972
-
2973
- function prefixId$1(id) {
2974
- return `bio-properties-panel-${id}`;
2975
- }
2976
-
2977
- function ToggleSwitch(props) {
2978
- const {
2979
- id,
2980
- label,
2981
- onInput,
2982
- value,
2983
- switcherLabel,
2984
- onFocus,
2985
- onBlur
2986
- } = props;
2987
- const [localValue, setLocalValue] = useState(value);
2988
- const handleInputCallback = async () => {
2989
- onInput(!value);
2990
- };
2991
- const handleInput = e => {
2992
- handleInputCallback();
2993
- setLocalValue(e.target.value);
2994
- };
2995
- useEffect(() => {
2996
- if (value === localValue) {
2997
- return;
2998
- }
2999
- setLocalValue(value);
3000
- }, [value]);
3001
- return jsxs("div", {
3002
- class: "bio-properties-panel-toggle-switch",
3003
- children: [jsx("label", {
3004
- class: "bio-properties-panel-label",
3005
- for: prefixId(id),
3006
- children: label
3007
- }), jsxs("div", {
3008
- class: "bio-properties-panel-field-wrapper",
3009
- children: [jsxs("label", {
3010
- class: "bio-properties-panel-toggle-switch__switcher",
3011
- children: [jsx("input", {
3012
- id: prefixId(id),
3013
- class: "bio-properties-panel-input",
3014
- type: "checkbox",
3015
- onFocus: onFocus,
3016
- onBlur: onBlur,
3017
- name: id,
3018
- onInput: handleInput,
3019
- checked: !!localValue
3020
- }), jsx("span", {
3021
- class: "bio-properties-panel-toggle-switch__slider"
3022
- })]
3023
- }), jsx("p", {
3024
- class: "bio-properties-panel-toggle-switch__label",
3025
- children: switcherLabel
3026
- })]
3027
- })]
3028
- });
3029
- }
3030
-
3031
- /**
3032
- * @param {Object} props
3033
- * @param {Object} props.element
3034
- * @param {String} props.id
3035
- * @param {String} props.description
3036
- * @param {String} props.label
3037
- * @param {String} props.switcherLabel
3038
- * @param {Function} props.getValue
3039
- * @param {Function} props.setValue
3040
- * @param {Function} props.onFocus
3041
- * @param {Function} props.onBlur
3042
- */
3043
- function ToggleSwitchEntry(props) {
3044
- const {
3045
- element,
3046
- id,
3047
- description,
3048
- label,
3049
- switcherLabel,
3050
- getValue,
3051
- setValue,
3052
- onFocus,
3053
- onBlur
3054
- } = props;
3055
- const value = getValue(element);
3056
- return jsxs("div", {
3057
- class: "bio-properties-panel-entry bio-properties-panel-toggle-switch-entry",
3058
- "data-entry-id": id,
3059
- children: [jsx(ToggleSwitch, {
3060
- id: id,
3061
- label: label,
3062
- value: value,
3063
- onInput: setValue,
3064
- onFocus: onFocus,
3065
- onBlur: onBlur,
3066
- switcherLabel: switcherLabel
3067
- }), jsx(Description, {
3068
- forId: id,
3069
- element: element,
3070
- value: description
3071
- })]
3072
- });
3073
- }
3074
3190
  function isEdited(node) {
3075
- return node && !!node.checked;
3191
+ return node && !!node.value;
3076
3192
  }
3077
3193
 
3078
3194
  // helpers /////////////////
@@ -3098,5 +3214,5 @@ var index = {
3098
3214
  debounceInput: ['factory', debounceInput]
3099
3215
  };
3100
3216
 
3101
- export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelEntry, FeelOptionalIcon, FeelRequiredIcon, FeelTemplatingEntry, FeelTextAreaEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$7 as isFeelEntryEdited, isEdited$5 as isNumberFieldEntryEdited, isEdited$4 as isSelectEntryEdited, isEdited$3 as isSimpleEntryEdited, isEdited$6 as isTemplatingEntryEdited, isEdited$2 as isTextAreaEntryEdited, isEdited$1 as isTextFieldEntryEdited, isEdited as isToggleSwitchEntryEdited, useDescriptionContext, useError, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver };
3217
+ export { ArrowIcon, CheckboxEntry, CollapsibleEntry, CreateIcon, index as DebounceInputModule, DeleteIcon, DescriptionContext, Description as DescriptionEntry, DropdownButton, ErrorsContext, EventContext, ExternalLinkIcon, FeelCheckboxEntry, FeelEntry, FeelIcon$1 as FeelIcon, FeelTemplatingEntry, FeelTextAreaEntry, FeelToggleSwitchEntry, Group, Header, HeaderButton, LayoutContext, List as ListEntry, ListGroup, ListItem, NumberFieldEntry, Placeholder, PropertiesPanel, LayoutContext as PropertiesPanelContext, SelectEntry, Simple as SimpleEntry, TemplatingEntry, TextAreaEntry, TextfieldEntry as TextFieldEntry, ToggleSwitchEntry, isEdited$8 as isCheckboxEntryEdited, isEdited$6 as isFeelEntryEdited, isEdited$4 as isNumberFieldEntryEdited, isEdited$3 as isSelectEntryEdited, isEdited$2 as isSimpleEntryEdited, isEdited$5 as isTemplatingEntryEdited, isEdited$1 as isTextAreaEntryEdited, isEdited as isTextFieldEntryEdited, isEdited$7 as isToggleSwitchEntryEdited, useDescriptionContext, useError, useEvent, useKeyFactory, useLayoutState, usePrevious, useShowEntryEvent, useStaticCallback, useStickyIntersectionObserver };
3102
3218
  //# sourceMappingURL=index.esm.js.map