@bpmn-io/properties-panel 0.9.0 → 0.10.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 (180) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index.esm.js +1607 -0
  3. package/dist/index.esm.js.map +1 -0
  4. package/dist/index.js +1648 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +16 -7
  7. package/preact/LICENSE +21 -0
  8. package/preact/README.md +185 -0
  9. package/preact/compat/dist/compat.js +2 -0
  10. package/preact/compat/dist/compat.js.map +1 -0
  11. package/preact/compat/dist/compat.mjs +2 -0
  12. package/preact/compat/dist/compat.module.js +2 -0
  13. package/preact/compat/dist/compat.module.js.map +1 -0
  14. package/preact/compat/dist/compat.umd.js +2 -0
  15. package/preact/compat/dist/compat.umd.js.map +1 -0
  16. package/preact/compat/jsx-dev-runtime.js +1 -0
  17. package/preact/compat/jsx-dev-runtime.mjs +1 -0
  18. package/preact/compat/jsx-runtime.js +1 -0
  19. package/preact/compat/jsx-runtime.mjs +1 -0
  20. package/preact/compat/package.json +19 -0
  21. package/preact/compat/server.js +15 -0
  22. package/preact/compat/server.mjs +4 -0
  23. package/preact/compat/src/Children.js +21 -0
  24. package/preact/compat/src/PureComponent.js +15 -0
  25. package/preact/compat/src/forwardRef.js +51 -0
  26. package/preact/compat/src/index.d.ts +140 -0
  27. package/preact/compat/src/index.js +175 -0
  28. package/preact/compat/src/internal.d.ts +47 -0
  29. package/preact/compat/src/memo.js +34 -0
  30. package/preact/compat/src/portals.js +80 -0
  31. package/preact/compat/src/render.js +219 -0
  32. package/preact/compat/src/scheduler.js +24 -0
  33. package/preact/compat/src/suspense-list.d.ts +14 -0
  34. package/preact/compat/src/suspense-list.js +126 -0
  35. package/preact/compat/src/suspense.d.ts +15 -0
  36. package/preact/compat/src/suspense.js +270 -0
  37. package/preact/compat/src/util.js +28 -0
  38. package/preact/compat/test-utils.js +1 -0
  39. package/preact/debug/dist/debug.js +2 -0
  40. package/preact/debug/dist/debug.js.map +1 -0
  41. package/preact/debug/dist/debug.mjs +2 -0
  42. package/preact/debug/dist/debug.module.js +2 -0
  43. package/preact/debug/dist/debug.module.js.map +1 -0
  44. package/preact/debug/dist/debug.umd.js +2 -0
  45. package/preact/debug/dist/debug.umd.js.map +1 -0
  46. package/preact/debug/package.json +18 -0
  47. package/preact/debug/src/check-props.js +54 -0
  48. package/preact/debug/src/component-stack.js +146 -0
  49. package/preact/debug/src/constants.js +3 -0
  50. package/preact/debug/src/debug.js +442 -0
  51. package/preact/debug/src/index.js +6 -0
  52. package/preact/debug/src/internal.d.ts +82 -0
  53. package/preact/debug/src/util.js +11 -0
  54. package/preact/devtools/dist/devtools.js +2 -0
  55. package/preact/devtools/dist/devtools.js.map +1 -0
  56. package/preact/devtools/dist/devtools.mjs +2 -0
  57. package/preact/devtools/dist/devtools.module.js +2 -0
  58. package/preact/devtools/dist/devtools.module.js.map +1 -0
  59. package/preact/devtools/dist/devtools.umd.js +2 -0
  60. package/preact/devtools/dist/devtools.umd.js.map +1 -0
  61. package/preact/devtools/package.json +16 -0
  62. package/preact/devtools/src/devtools.js +10 -0
  63. package/preact/devtools/src/index.d.ts +8 -0
  64. package/preact/devtools/src/index.js +15 -0
  65. package/preact/dist/preact.js +2 -0
  66. package/preact/dist/preact.js.map +1 -0
  67. package/preact/dist/preact.min.js +2 -0
  68. package/preact/dist/preact.min.js.map +1 -0
  69. package/preact/dist/preact.mjs +2 -0
  70. package/preact/dist/preact.module.js +2 -0
  71. package/preact/dist/preact.module.js.map +1 -0
  72. package/preact/dist/preact.umd.js +2 -0
  73. package/preact/dist/preact.umd.js.map +1 -0
  74. package/preact/hooks/dist/hooks.js +2 -0
  75. package/preact/hooks/dist/hooks.js.map +1 -0
  76. package/preact/hooks/dist/hooks.mjs +2 -0
  77. package/preact/hooks/dist/hooks.module.js +2 -0
  78. package/preact/hooks/dist/hooks.module.js.map +1 -0
  79. package/preact/hooks/dist/hooks.umd.js +2 -0
  80. package/preact/hooks/dist/hooks.umd.js.map +1 -0
  81. package/preact/hooks/package.json +26 -0
  82. package/preact/hooks/src/index.d.ts +130 -0
  83. package/preact/hooks/src/index.js +386 -0
  84. package/preact/hooks/src/internal.d.ts +75 -0
  85. package/preact/jsx-runtime/dist/jsxRuntime.js +2 -0
  86. package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -0
  87. package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -0
  88. package/preact/jsx-runtime/dist/jsxRuntime.module.js +2 -0
  89. package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -0
  90. package/preact/jsx-runtime/dist/jsxRuntime.umd.js +2 -0
  91. package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -0
  92. package/preact/jsx-runtime/package.json +19 -0
  93. package/preact/jsx-runtime/src/index.d.ts +50 -0
  94. package/preact/jsx-runtime/src/index.js +72 -0
  95. package/preact/package.json +268 -0
  96. package/preact/src/cjs.js +3 -0
  97. package/preact/src/clone-element.js +39 -0
  98. package/preact/src/component.js +225 -0
  99. package/preact/src/constants.js +3 -0
  100. package/preact/src/create-context.js +68 -0
  101. package/preact/src/create-element.js +100 -0
  102. package/preact/src/diff/catch-error.js +38 -0
  103. package/preact/src/diff/children.js +347 -0
  104. package/preact/src/diff/index.js +516 -0
  105. package/preact/src/diff/props.js +158 -0
  106. package/preact/src/index.d.ts +310 -0
  107. package/preact/src/index.js +13 -0
  108. package/preact/src/internal.d.ts +147 -0
  109. package/preact/src/jsx.d.ts +955 -0
  110. package/preact/src/options.js +17 -0
  111. package/preact/src/render.js +74 -0
  112. package/preact/src/util.js +23 -0
  113. package/preact/test-utils/dist/testUtils.js +2 -0
  114. package/preact/test-utils/dist/testUtils.js.map +1 -0
  115. package/preact/test-utils/dist/testUtils.mjs +2 -0
  116. package/preact/test-utils/dist/testUtils.module.js +2 -0
  117. package/preact/test-utils/dist/testUtils.module.js.map +1 -0
  118. package/preact/test-utils/dist/testUtils.umd.js +2 -0
  119. package/preact/test-utils/dist/testUtils.umd.js.map +1 -0
  120. package/preact/test-utils/package.json +19 -0
  121. package/preact/test-utils/src/index.d.ts +3 -0
  122. package/preact/test-utils/src/index.js +117 -0
  123. package/lib/PropertiesPanel.js +0 -166
  124. package/lib/PropertiesPanel.js.map +0 -1
  125. package/lib/components/DropdownButton.js +0 -109
  126. package/lib/components/DropdownButton.js.map +0 -1
  127. package/lib/components/Group.js +0 -75
  128. package/lib/components/Group.js.map +0 -1
  129. package/lib/components/Header.js +0 -49
  130. package/lib/components/Header.js.map +0 -1
  131. package/lib/components/HeaderButton.js +0 -16
  132. package/lib/components/HeaderButton.js.map +0 -1
  133. package/lib/components/ListGroup.js +0 -167
  134. package/lib/components/ListGroup.js.map +0 -1
  135. package/lib/components/ListItem.js +0 -37
  136. package/lib/components/ListItem.js.map +0 -1
  137. package/lib/components/entries/Checkbox.js +0 -83
  138. package/lib/components/entries/Checkbox.js.map +0 -1
  139. package/lib/components/entries/Collapsible.js +0 -48
  140. package/lib/components/entries/Collapsible.js.map +0 -1
  141. package/lib/components/entries/Description.js +0 -26
  142. package/lib/components/entries/Description.js.map +0 -1
  143. package/lib/components/entries/List.js +0 -204
  144. package/lib/components/entries/List.js.map +0 -1
  145. package/lib/components/entries/NumberField.js +0 -110
  146. package/lib/components/entries/NumberField.js.map +0 -1
  147. package/lib/components/entries/Select.js +0 -110
  148. package/lib/components/entries/Select.js.map +0 -1
  149. package/lib/components/entries/Simple.js +0 -56
  150. package/lib/components/entries/Simple.js.map +0 -1
  151. package/lib/components/entries/TextArea.js +0 -98
  152. package/lib/components/entries/TextArea.js.map +0 -1
  153. package/lib/components/entries/TextField.js +0 -123
  154. package/lib/components/entries/TextField.js.map +0 -1
  155. package/lib/components/entries/ToggleSwitch.js +0 -91
  156. package/lib/components/entries/ToggleSwitch.js.map +0 -1
  157. package/lib/components/icons/index.js +0 -51
  158. package/lib/components/icons/index.js.map +0 -1
  159. package/lib/context/DescriptionContext.js +0 -7
  160. package/lib/context/DescriptionContext.js.map +0 -1
  161. package/lib/context/LayoutContext.js +0 -9
  162. package/lib/context/LayoutContext.js.map +0 -1
  163. package/lib/context/index.js +0 -3
  164. package/lib/context/index.js.map +0 -1
  165. package/lib/features/debounce-input/debounceInput.js +0 -14
  166. package/lib/features/debounce-input/debounceInput.js.map +0 -1
  167. package/lib/features/debounce-input/index.js +0 -5
  168. package/lib/features/debounce-input/index.js.map +0 -1
  169. package/lib/hooks/index.js +0 -5
  170. package/lib/hooks/index.js.map +0 -1
  171. package/lib/hooks/useDescriptionContext.js +0 -25
  172. package/lib/hooks/useDescriptionContext.js.map +0 -1
  173. package/lib/hooks/useKeyFactory.js +0 -39
  174. package/lib/hooks/useKeyFactory.js.map +0 -1
  175. package/lib/hooks/useLayoutState.js +0 -36
  176. package/lib/hooks/useLayoutState.js.map +0 -1
  177. package/lib/hooks/usePrevious.js +0 -16
  178. package/lib/hooks/usePrevious.js.map +0 -1
  179. package/lib/index.js +0 -2
  180. package/lib/index.js.map +0 -1
@@ -1,204 +0,0 @@
1
- import { useEffect, useRef, useState } from 'preact/hooks';
2
- import { query as domQuery } from 'min-dom';
3
- import { isFunction } from 'min-dash';
4
- import { useKeyFactory, usePrevious } from '../../hooks';
5
- import classnames from 'classnames';
6
- import { ArrowIcon, CreateIcon, DeleteIcon } from '../icons';
7
- /**
8
- * Entry for handling lists represented as nested entries.
9
- *
10
- * @template Item
11
- * @param {object} props
12
- * @param {string} props.id
13
- * @param {*} props.element
14
- * @param {Function} props.onAdd
15
- * @param {(item: Item, index: number, isNew: boolean) => JSX.Element} props.renderItem
16
- * @param {string} [props.label='<empty>']
17
- * @param {Function} [props.onRemove]
18
- * @param {Item[]} [props.items]
19
- * @param {boolean} [props.open]
20
- * @param {string|boolean} [props.autoFocusEntry] either a custom selector string or true to focus the first input
21
- * @param {(a: Item, b: Item) => -1 | 0 | 1} [props.compareFn]
22
- * @returns
23
- */
24
-
25
- import { jsx as _jsx } from "preact/jsx-runtime";
26
- import { jsxs as _jsxs } from "preact/jsx-runtime";
27
- export default function List(props) {
28
- const {
29
- id,
30
- element,
31
- items = [],
32
- renderItem,
33
- label = '<empty>',
34
- open: shouldOpen,
35
- onAdd,
36
- onRemove,
37
- autoFocusEntry,
38
- compareFn
39
- } = props;
40
- const [open, setOpen] = useState(!!shouldOpen);
41
- const hasItems = !!items.length;
42
-
43
- const toggleOpen = () => hasItems && setOpen(!open);
44
-
45
- const opening = !usePrevious(open) && open;
46
- const elementChanged = usePrevious(element) !== element;
47
- const shouldReset = opening || elementChanged;
48
- const sortedItems = useSortedItems(items, compareFn, shouldReset);
49
- const newItems = useNewItems(items, elementChanged);
50
- useEffect(() => {
51
- if (open && !hasItems) {
52
- setOpen(false);
53
- }
54
- }, [open, hasItems]);
55
- /**
56
- * @param {MouseEvent} event
57
- */
58
-
59
- function addItem(event) {
60
- event.stopPropagation();
61
- onAdd();
62
-
63
- if (!open) {
64
- setOpen(true);
65
- }
66
- }
67
-
68
- return _jsxs("div", {
69
- "data-entry-id": id,
70
- class: classnames('bio-properties-panel-entry', 'bio-properties-panel-list-entry', hasItems ? '' : 'empty', open ? 'open' : ''),
71
- children: [_jsxs("div", {
72
- class: "bio-properties-panel-list-entry-header",
73
- onClick: toggleOpen,
74
- children: [_jsx("div", {
75
- title: label,
76
- class: classnames('bio-properties-panel-list-entry-header-title', open && 'open'),
77
- children: label
78
- }), _jsxs("div", {
79
- class: "bio-properties-panel-list-entry-header-buttons",
80
- children: [_jsxs("button", {
81
- title: "Create new list item",
82
- onClick: addItem,
83
- class: "bio-properties-panel-add-entry",
84
- children: [_jsx(CreateIcon, {}), !hasItems ? _jsx("span", {
85
- class: "bio-properties-panel-add-entry-label",
86
- children: "Create"
87
- }) : null]
88
- }), hasItems && _jsx("div", {
89
- title: `List contains ${items.length} item${items.length != 1 ? 's' : ''}`,
90
- class: "bio-properties-panel-list-badge",
91
- children: items.length
92
- }), hasItems && _jsx("button", {
93
- title: "Toggle list item",
94
- class: "bio-properties-panel-arrow",
95
- children: _jsx(ArrowIcon, {
96
- class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
97
- })
98
- })]
99
- })]
100
- }), hasItems && _jsx(ItemsList, {
101
- autoFocusEntry: autoFocusEntry,
102
- id: id,
103
- open: open,
104
- items: sortedItems,
105
- newItems: newItems,
106
- onRemove: onRemove,
107
- renderItem: renderItem
108
- })]
109
- });
110
- }
111
-
112
- function ItemsList(props) {
113
- const {
114
- autoFocusEntry,
115
- id,
116
- items,
117
- newItems,
118
- open,
119
- onRemove,
120
- renderItem
121
- } = props;
122
- const getKey = useKeyFactory();
123
- const newItem = newItems[0];
124
- useEffect(() => {
125
- if (newItem && autoFocusEntry) {
126
- // (0) select the parent entry (containing all list items)
127
- const entry = domQuery(`[data-entry-id="${id}"]`); // (1) select the first input or a custom element to be focussed
128
-
129
- const selector = typeof autoFocusEntry === 'boolean' ? '.bio-properties-panel-input' : autoFocusEntry;
130
- const focusableInput = domQuery(selector, entry); // (2) set focus
131
-
132
- if (focusableInput) {
133
- if (isFunction(focusableInput.select)) {
134
- focusableInput.select();
135
- } else if (isFunction(focusableInput.focus)) {
136
- focusableInput.focus();
137
- }
138
- }
139
- }
140
- }, [newItem, autoFocusEntry, id]);
141
- return _jsx("ol", {
142
- class: classnames('bio-properties-panel-list-entry-items', open ? 'open' : ''),
143
- children: items.map((item, index) => {
144
- const key = getKey(item);
145
- return _jsxs("li", {
146
- class: "bio-properties-panel-list-entry-item",
147
- children: [renderItem(item, index, item === newItem), onRemove && _jsx("button", {
148
- type: "button",
149
- title: "Delete item",
150
- class: "bio-properties-panel-remove-entry bio-properties-panel-remove-list-entry",
151
- onClick: () => onRemove && onRemove(item),
152
- children: _jsx(DeleteIcon, {})
153
- })]
154
- }, key);
155
- })
156
- });
157
- }
158
- /**
159
- * Place new items in the beginning of the list and sort the rest with provided function.
160
- *
161
- * @template Item
162
- * @param {Item[]} currentItems
163
- * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items
164
- * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook
165
- * @returns {Item[]}
166
- */
167
-
168
-
169
- function useSortedItems(currentItems, compareFn, shouldReset = false) {
170
- const itemsRef = useRef(currentItems.slice()); // (1) Reset and optionally sort.
171
-
172
- if (shouldReset) {
173
- itemsRef.current = currentItems.slice();
174
-
175
- if (compareFn) {
176
- itemsRef.current.sort(compareFn);
177
- }
178
- } else {
179
- const items = itemsRef.current; // (2) Add new item to the list.
180
-
181
- for (const item of currentItems) {
182
- if (!items.includes(item)) {
183
- // Unshift or push depending on whether we have a compareFn
184
- compareFn ? items.unshift(item) : items.push(item);
185
- }
186
- } // (3) Filter out removed items.
187
-
188
-
189
- itemsRef.current = items.filter(item => currentItems.includes(item));
190
- }
191
-
192
- return itemsRef.current;
193
- }
194
-
195
- function useNewItems(items = [], shouldReset) {
196
- const previousItems = usePrevious(items.slice()) || [];
197
-
198
- if (shouldReset) {
199
- return [];
200
- }
201
-
202
- return previousItems ? items.filter(item => !previousItems.includes(item)) : [];
203
- }
204
- //# sourceMappingURL=List.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/entries/List.js"],"names":["useEffect","useRef","useState","query","domQuery","isFunction","useKeyFactory","usePrevious","classnames","ArrowIcon","CreateIcon","DeleteIcon","List","props","id","element","items","renderItem","label","open","shouldOpen","onAdd","onRemove","autoFocusEntry","compareFn","setOpen","hasItems","length","toggleOpen","opening","elementChanged","shouldReset","sortedItems","useSortedItems","newItems","useNewItems","addItem","event","stopPropagation","ItemsList","getKey","newItem","entry","selector","focusableInput","select","focus","map","item","index","key","currentItems","itemsRef","slice","current","sort","includes","unshift","push","filter","previousItems"],"mappings":"AAAA,SACEA,SADF,EAEEC,MAFF,EAGEC,QAHF,QAIO,cAJP;AAMA,SACEC,KAAK,IAAIC,QADX,QAEO,SAFP;AAIA,SAASC,UAAT,QAA2B,UAA3B;AAEA,SACEC,aADF,EAEEC,WAFF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ACwC,QAAN,CAAeR,IAAf,CAAL,EAA2B;AAEzB;AACAxB,QAAAA,SAAS,GAAGR,KAAK,CAACyC,OAAN,CAAcT,IAAd,CAAH,GAAyBhC,KAAK,CAAC0C,IAAN,CAAWV,IAAX,CAAlC;AACD;AACF,KAVI,CAYL;;;AACAI,IAAAA,QAAQ,CAACE,OAAT,GAAmBtC,KAAK,CAAC2C,MAAN,CAAaX,IAAI,IAAIG,YAAY,CAACK,QAAb,CAAsBR,IAAtB,CAArB,CAAnB;AACD;;AAED,SAAOI,QAAQ,CAACE,OAAhB;AACD;;AAED,SAASnB,WAAT,CAAqBnB,KAAK,GAAG,EAA7B,EAAiCe,WAAjC,EAA8C;AAC5C,QAAM6B,aAAa,GAAGrD,WAAW,CAACS,KAAK,CAACqC,KAAN,EAAD,CAAX,IAA8B,EAApD;;AAEA,MAAItB,WAAJ,EAAiB;AACf,WAAO,EAAP;AACD;;AAED,SAAO6B,aAAa,GAAG5C,KAAK,CAAC2C,MAAN,CAAaX,IAAI,IAAI,CAACY,aAAa,CAACJ,QAAd,CAAuBR,IAAvB,CAAtB,CAAH,GAAyD,EAA7E;AACD","sourcesContent":["import {\n useEffect,\n useRef,\n useState\n} from 'preact/hooks';\n\nimport {\n query as domQuery\n} from 'min-dom';\n\nimport { isFunction } from 'min-dash';\n\nimport {\n useKeyFactory,\n usePrevious\n} from '../../hooks';\n\nimport classnames from 'classnames';\n\nimport {\n ArrowIcon,\n CreateIcon,\n DeleteIcon\n} from '../icons';\n\n/**\n * Entry for handling lists represented as nested entries.\n *\n * @template Item\n * @param {object} props\n * @param {string} props.id\n * @param {*} props.element\n * @param {Function} props.onAdd\n * @param {(item: Item, index: number, isNew: boolean) => JSX.Element} props.renderItem\n * @param {string} [props.label='<empty>']\n * @param {Function} [props.onRemove]\n * @param {Item[]} [props.items]\n * @param {boolean} [props.open]\n * @param {string|boolean} [props.autoFocusEntry] either a custom selector string or true to focus the first input\n * @param {(a: Item, b: Item) => -1 | 0 | 1} [props.compareFn]\n * @returns\n */\nexport default function List(props) {\n const {\n id,\n element,\n items = [],\n renderItem,\n label = '<empty>',\n open: shouldOpen,\n onAdd,\n onRemove,\n autoFocusEntry,\n compareFn\n } = props;\n\n const [ open, setOpen ] = useState(!!shouldOpen);\n\n const hasItems = !!items.length;\n const toggleOpen = () => hasItems && setOpen(!open);\n\n const opening = !usePrevious(open) && open;\n const elementChanged = usePrevious(element) !== element;\n const shouldReset = opening || elementChanged;\n const sortedItems = useSortedItems(items, compareFn, shouldReset);\n\n const newItems = useNewItems(items, elementChanged);\n\n useEffect(() => {\n if (open && !hasItems) {\n setOpen(false);\n }\n }, [ open, hasItems ]);\n\n /**\n * @param {MouseEvent} event\n */\n function addItem(event) {\n event.stopPropagation();\n onAdd();\n\n if (!open) {\n setOpen(true);\n }\n }\n\n return (\n <div\n data-entry-id={ id }\n class={ classnames(\n 'bio-properties-panel-entry',\n 'bio-properties-panel-list-entry',\n hasItems ? '' : 'empty',\n open ? 'open' : ''\n ) }>\n <div class=\"bio-properties-panel-list-entry-header\" onClick={ toggleOpen }>\n <div\n title={ label }\n class={ classnames(\n 'bio-properties-panel-list-entry-header-title',\n open && 'open'\n ) }>\n { label }\n </div>\n <div\n class=\"bio-properties-panel-list-entry-header-buttons\"\n >\n <button\n title=\"Create new list item\"\n onClick={ addItem }\n class=\"bio-properties-panel-add-entry\"\n >\n <CreateIcon />\n {\n !hasItems ? (\n <span class=\"bio-properties-panel-add-entry-label\">Create</span>\n )\n : null\n }\n </button>\n {\n hasItems && (\n <div\n title={ `List contains ${items.length} item${items.length != 1 ? 's' : ''}` }\n class=\"bio-properties-panel-list-badge\"\n >\n { items.length }\n </div>\n )\n }\n {\n hasItems && (\n <button\n title=\"Toggle list item\"\n class=\"bio-properties-panel-arrow\"\n >\n <ArrowIcon class={ open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right' } />\n </button>\n )\n }\n </div>\n </div>\n {\n hasItems && (\n <ItemsList\n autoFocusEntry={ autoFocusEntry }\n id={ id }\n open={ open }\n items={ sortedItems }\n newItems={ newItems }\n onRemove={ onRemove }\n renderItem={ renderItem }\n />\n )\n }\n </div>\n );\n}\n\nfunction ItemsList(props) {\n const {\n autoFocusEntry,\n id,\n items,\n newItems,\n open,\n onRemove,\n renderItem\n } = props;\n\n const getKey = useKeyFactory();\n\n const newItem = newItems[0];\n\n useEffect(() => {\n if (newItem && autoFocusEntry) {\n\n // (0) select the parent entry (containing all list items)\n const entry = domQuery(`[data-entry-id=\"${id}\"]`);\n\n // (1) select the first input or a custom element to be focussed\n const selector = typeof(autoFocusEntry) === 'boolean' ?\n '.bio-properties-panel-input' :\n autoFocusEntry;\n const focusableInput = domQuery(selector, entry);\n\n // (2) set focus\n if (focusableInput) {\n\n if (isFunction(focusableInput.select)) {\n focusableInput.select();\n } else if (isFunction(focusableInput.focus)) {\n focusableInput.focus();\n }\n\n }\n }\n }, [ newItem, autoFocusEntry, id ]);\n\n return (\n <ol class={ classnames(\n 'bio-properties-panel-list-entry-items',\n open ? 'open' : ''\n ) }>\n {\n items.map((item, index) => {\n const key = getKey(item);\n\n return (<li class=\"bio-properties-panel-list-entry-item\" key={ key }>\n { renderItem(item, index, item === newItem) }\n {\n onRemove && (\n <button\n type=\"button\"\n title=\"Delete item\"\n class=\"bio-properties-panel-remove-entry bio-properties-panel-remove-list-entry\"\n onClick={ () => onRemove && onRemove(item) }\n ><DeleteIcon /></button>\n )\n }\n </li>);\n })\n }\n </ol>);\n}\n\n/**\n * Place new items in the beginning of the list and sort the rest with provided function.\n *\n * @template Item\n * @param {Item[]} currentItems\n * @param {(a: Item, b: Item) => 0 | 1 | -1} [compareFn] function used to sort items\n * @param {boolean} [shouldReset=false] set to `true` to reset state of the hook\n * @returns {Item[]}\n */\nfunction useSortedItems(currentItems, compareFn, shouldReset = false) {\n const itemsRef = useRef(currentItems.slice());\n\n // (1) Reset and optionally sort.\n if (shouldReset) {\n itemsRef.current = currentItems.slice();\n\n if (compareFn) {\n itemsRef.current.sort(compareFn);\n }\n } else {\n const items = itemsRef.current;\n\n // (2) Add new item to the list.\n for (const item of currentItems) {\n if (!items.includes(item)) {\n\n // Unshift or push depending on whether we have a compareFn\n compareFn ? items.unshift(item) : items.push(item);\n }\n }\n\n // (3) Filter out removed items.\n itemsRef.current = items.filter(item => currentItems.includes(item));\n }\n\n return itemsRef.current;\n}\n\nfunction useNewItems(items = [], shouldReset) {\n const previousItems = usePrevious(items.slice()) || [];\n\n if (shouldReset) {\n return [];\n }\n\n return previousItems ? items.filter(item => !previousItems.includes(item)) : [];\n}\n"],"file":"List.js"}
@@ -1,110 +0,0 @@
1
- import { useMemo } from 'preact/hooks';
2
- import Description from './Description';
3
- import { jsx as _jsx } from "preact/jsx-runtime";
4
- import { jsxs as _jsxs } from "preact/jsx-runtime";
5
-
6
- function NumberField(props) {
7
- const {
8
- debounce,
9
- disabled,
10
- id,
11
- label,
12
- max,
13
- min,
14
- onInput,
15
- step,
16
- value = ''
17
- } = props;
18
- const handleInput = useMemo(() => {
19
- return debounce(event => {
20
- const {
21
- validity,
22
- value
23
- } = event.target;
24
-
25
- if (validity.valid) {
26
- onInput(value ? parseFloat(value) : undefined);
27
- }
28
- });
29
- }, [onInput, debounce]);
30
- return _jsxs("div", {
31
- class: "bio-properties-panel-numberfield",
32
- children: [_jsx("label", {
33
- for: prefixId(id),
34
- class: "bio-properties-panel-label",
35
- children: label
36
- }), _jsx("input", {
37
- id: prefixId(id),
38
- type: "number",
39
- name: id,
40
- spellCheck: "false",
41
- autoComplete: "off",
42
- disabled: disabled,
43
- class: "bio-properties-panel-input",
44
- max: max,
45
- min: min,
46
- onInput: handleInput,
47
- step: step,
48
- value: value
49
- })]
50
- });
51
- }
52
- /**
53
- * @param {Object} props
54
- * @param {Boolean} props.debounce
55
- * @param {String} props.description
56
- * @param {Boolean} props.disabled
57
- * @param {Object} props.element
58
- * @param {Function} props.getValue
59
- * @param {String} props.id
60
- * @param {String} props.label
61
- * @param {String} props.max
62
- * @param {String} props.min
63
- * @param {Function} props.setValue
64
- * @param {String} props.step
65
- */
66
-
67
-
68
- export default function NumberFieldEntry(props) {
69
- const {
70
- debounce,
71
- description,
72
- disabled,
73
- element,
74
- getValue,
75
- id,
76
- label,
77
- max,
78
- min,
79
- setValue,
80
- step
81
- } = props;
82
- const value = getValue(element);
83
- return _jsxs("div", {
84
- class: "bio-properties-panel-entry",
85
- "data-entry-id": id,
86
- children: [_jsx(NumberField, {
87
- debounce: debounce,
88
- disabled: disabled,
89
- id: id,
90
- label: label,
91
- onInput: setValue,
92
- max: max,
93
- min: min,
94
- step: step,
95
- value: value
96
- }), _jsx(Description, {
97
- forId: id,
98
- element: element,
99
- value: description
100
- })]
101
- });
102
- }
103
- export function isEdited(node) {
104
- return node && !!node.value;
105
- } // helpers /////////////////
106
-
107
- function prefixId(id) {
108
- return `bio-properties-panel-${id}`;
109
- }
110
- //# sourceMappingURL=NumberField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/entries/NumberField.js"],"names":["useMemo","Description","NumberField","props","debounce","disabled","id","label","max","min","onInput","step","value","handleInput","event","validity","target","valid","parseFloat","undefined","prefixId","NumberFieldEntry","description","element","getValue","setValue","isEdited","node"],"mappings":"AAAA,SACEA,OADF,QAEO,cAFP;AAIA,OAAOC,WAAP,MAAwB,eAAxB;;;;AAEA,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AAE1B,QAAM;AACJC,IAAAA,QADI;AAEJC,IAAAA,QAFI;AAGJC,IAAAA,EAHI;AAIJC,IAAAA,KAJI;AAKJC,IAAAA,GALI;AAMJC,IAAAA,GANI;AAOJC,IAAAA,OAPI;AAQJC,IAAAA,IARI;AASJC,IAAAA,KAAK,GAAG;AATJ,MAUFT,KAVJ;AAYA,QAAMU,WAAW,GAAGb,OAAO,CAAC,MAAM;AAChC,WAAOI,QAAQ,CAACU,KAAK,IAAI;AAEvB,YAAM;AACJC,QAAAA,QADI;AAEJH,QAAAA;AAFI,UAGFE,KAAK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AAAK,IAAA,KAAK,EAAC,4BAAX;AAAwC,qBAAgBjB,EAAxD;AAAA,eACE,KAAC,WAAD;AACE,MAAA,QAAQ,EAAGF,QADb;AAEE,MAAA,QAAQ,EAAGC,QAFb;AAGE,MAAA,EAAE,EAAGC,EAHP;AAIE,MAAA,KAAK,EAAGC,KAJV;AAKE,MAAA,OAAO,EAAGkB,QALZ;AAME,MAAA,GAAG,EAAGjB,GANR;AAOE,MAAA,GAAG,EAAGC,GAPR;AAQE,MAAA,IAAI,EAAGE,IART;AASE,MAAA,KAAK,EAAGC;AATV,MADF,EAWE,KAAC,WAAD;AAAa,MAAA,KAAK,EAAGN,EAArB;AAA0B,MAAA,OAAO,EAAGiB,OAApC;AAA8C,MAAA,KAAK,EAAGD;AAAtD,MAXF;AAAA,IADF;AAeD;AAED,OAAO,SAASI,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,SAAOA,IAAI,IAAI,CAAC,CAACA,IAAI,CAACf,KAAtB;AACD,C,CAGD;;AAEA,SAASQ,QAAT,CAAkBd,EAAlB,EAAsB;AACpB,SAAQ,wBAAwBA,EAAI,EAApC;AACD","sourcesContent":["import {\n useMemo\n} from 'preact/hooks';\n\nimport Description from './Description';\n\nfunction NumberField(props) {\n\n const {\n debounce,\n disabled,\n id,\n label,\n max,\n min,\n onInput,\n step,\n value = ''\n } = props;\n\n const handleInput = useMemo(() => {\n return debounce(event => {\n\n const {\n validity,\n value\n } = event.target;\n\n if (validity.valid) {\n onInput(value ? parseFloat(value) : undefined);\n }\n });\n }, [ onInput, debounce ]);\n\n return (\n <div class=\"bio-properties-panel-numberfield\">\n <label for={ prefixId(id) } class=\"bio-properties-panel-label\">{ label }</label>\n <input\n id={ prefixId(id) }\n type=\"number\"\n name={ id }\n spellCheck=\"false\"\n autoComplete=\"off\"\n disabled={ disabled }\n class=\"bio-properties-panel-input\"\n max={ max }\n min={ min }\n onInput={ handleInput }\n step={ step }\n value={ value } />\n </div>\n );\n}\n\n/**\n * @param {Object} props\n * @param {Boolean} props.debounce\n * @param {String} props.description\n * @param {Boolean} props.disabled\n * @param {Object} props.element\n * @param {Function} props.getValue\n * @param {String} props.id\n * @param {String} props.label\n * @param {String} props.max\n * @param {String} props.min\n * @param {Function} props.setValue\n * @param {String} props.step\n */\nexport default function NumberFieldEntry(props) {\n const {\n debounce,\n description,\n disabled,\n element,\n getValue,\n id,\n label,\n max,\n min,\n setValue,\n step\n } = props;\n\n const value = getValue(element);\n return (\n <div class=\"bio-properties-panel-entry\" data-entry-id={ id }>\n <NumberField\n debounce={ debounce }\n disabled={ disabled }\n id={ id }\n label={ label }\n onInput={ setValue }\n max={ max }\n min={ min }\n step={ step }\n value={ value } />\n <Description forId={ id } element={ element } value={ description } />\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.value;\n}\n\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"NumberField.js"}
@@ -1,110 +0,0 @@
1
- import Description from './Description';
2
- /**
3
- * @typedef { { value: string, label: string, disabled: boolean } } Option
4
- */
5
-
6
- /**
7
- * Provides basic select input.
8
- *
9
- * @param {object} props
10
- * @param {string} props.id
11
- * @param {string} props.label
12
- * @param {Function} props.onChange
13
- * @param {Array<Option>} [props.options]
14
- * @param {string} props.value
15
- * @param {boolean} [props.disabled]
16
- */
17
-
18
- import { jsx as _jsx } from "preact/jsx-runtime";
19
- import { jsxs as _jsxs } from "preact/jsx-runtime";
20
-
21
- function Select(props) {
22
- const {
23
- id,
24
- label,
25
- onChange,
26
- options = [],
27
- value,
28
- disabled
29
- } = props;
30
-
31
- const handleChange = ({
32
- target
33
- }) => {
34
- onChange(target.value);
35
- };
36
-
37
- return _jsxs("div", {
38
- class: "bio-properties-panel-select",
39
- children: [_jsx("label", {
40
- for: prefixId(id),
41
- class: "bio-properties-panel-label",
42
- children: label
43
- }), _jsx("select", {
44
- id: prefixId(id),
45
- name: id,
46
- class: "bio-properties-panel-input",
47
- onInput: handleChange,
48
- value: value,
49
- disabled: disabled,
50
- children: options.map((option, idx) => {
51
- return _jsx("option", {
52
- value: option.value,
53
- disabled: option.disabled,
54
- children: option.label
55
- }, idx);
56
- })
57
- })]
58
- });
59
- }
60
- /**
61
- * @param {object} props
62
- * @param {object} props.element
63
- * @param {string} props.id
64
- * @param {string} [props.description]
65
- * @param {string} props.label
66
- * @param {Function} props.getValue
67
- * @param {Function} props.setValue
68
- * @param {Function} props.getOptions
69
- * @param {boolean} [props.disabled]
70
- */
71
-
72
-
73
- export default function SelectEntry(props) {
74
- const {
75
- element,
76
- id,
77
- description,
78
- label,
79
- getValue,
80
- setValue,
81
- getOptions,
82
- disabled
83
- } = props;
84
- const value = getValue(element);
85
- const options = getOptions(element);
86
- return _jsxs("div", {
87
- class: "bio-properties-panel-entry",
88
- "data-entry-id": id,
89
- children: [_jsx(Select, {
90
- id: id,
91
- label: label,
92
- value: value,
93
- onChange: setValue,
94
- options: options,
95
- disabled: disabled
96
- }), _jsx(Description, {
97
- forId: id,
98
- element: element,
99
- value: description
100
- })]
101
- });
102
- }
103
- export function isEdited(node) {
104
- return node && !!node.value;
105
- } // helpers /////////////////
106
-
107
- function prefixId(id) {
108
- return `bio-properties-panel-${id}`;
109
- }
110
- //# sourceMappingURL=Select.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/entries/Select.js"],"names":["Description","Select","props","id","label","onChange","options","value","disabled","handleChange","target","prefixId","map","option","idx","SelectEntry","element","description","getValue","setValue","getOptions","isEdited","node"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,eAAxB;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASC,MAAT,CAAgBC,KAAhB,EAAuB;AACrB,QAAM;AACJC,IAAAA,EADI;AAEJC,IAAAA,KAFI;AAGJC,IAAAA,QAHI;AAIJC,IAAAA,OAAO,GAAG,EAJN;AAKJC,IAAAA,KALI;AAMJC,IAAAA;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xD;AAAA,eACE,KAAC,MAAD;AACE,MAAA,EAAE,EAAGA,EADP;AAEE,MAAA,KAAK,EAAGC,KAFV;AAGE,MAAA,KAAK,EAAGG,KAHV;AAIE,MAAA,QAAQ,EAAGY,QAJb;AAKE,MAAA,OAAO,EAAGb,OALZ;AAME,MAAA,QAAQ,EAAGE;AANb,MADF,EAQE,KAAC,WAAD;AAAa,MAAA,KAAK,EAAGL,EAArB;AAA0B,MAAA,OAAO,EAAGa,OAApC;AAA8C,MAAA,KAAK,EAAGC;AAAtD,MARF;AAAA,IADF;AAYD;AAED,OAAO,SAASI,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,SAAOA,IAAI,IAAI,CAAC,CAACA,IAAI,CAACf,KAAtB;AACD,C,CAED;;AAEA,SAASI,QAAT,CAAkBR,EAAlB,EAAsB;AACpB,SAAQ,wBAAwBA,EAAI,EAApC;AACD","sourcesContent":["import Description from './Description';\n\n/**\n * @typedef { { value: string, label: string, disabled: boolean } } Option\n */\n\n/**\n * Provides basic select input.\n *\n * @param {object} props\n * @param {string} props.id\n * @param {string} props.label\n * @param {Function} props.onChange\n * @param {Array<Option>} [props.options]\n * @param {string} props.value\n * @param {boolean} [props.disabled]\n */\nfunction Select(props) {\n const {\n id,\n label,\n onChange,\n options = [],\n value,\n disabled\n } = props;\n\n const handleChange = ({ target }) => {\n onChange(target.value);\n };\n\n return (\n <div class=\"bio-properties-panel-select\">\n <label for={ prefixId(id) } class=\"bio-properties-panel-label\">{ label }</label>\n <select\n id={ prefixId(id) }\n name={ id }\n class=\"bio-properties-panel-input\"\n onInput={ handleChange }\n value={ value }\n disabled={ disabled }\n >\n {\n options.map((option, idx) => {\n return (\n <option\n key={ idx }\n value={ option.value }\n disabled={ option.disabled }>\n { option.label }\n </option>\n );\n })\n }\n </select>\n </div>\n );\n}\n\n/**\n * @param {object} props\n * @param {object} props.element\n * @param {string} props.id\n * @param {string} [props.description]\n * @param {string} props.label\n * @param {Function} props.getValue\n * @param {Function} props.setValue\n * @param {Function} props.getOptions\n * @param {boolean} [props.disabled]\n */\nexport default function SelectEntry(props) {\n const {\n element,\n id,\n description,\n label,\n getValue,\n setValue,\n getOptions,\n disabled\n } = props;\n\n const value = getValue(element);\n const options = getOptions(element);\n\n return (\n <div class=\"bio-properties-panel-entry\" data-entry-id={ id }>\n <Select\n id={ id }\n label={ label }\n value={ value }\n onChange={ setValue }\n options={ options }\n disabled={ disabled } />\n <Description forId={ id } element={ element } value={ description } />\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.value;\n}\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"Select.js"}
@@ -1,56 +0,0 @@
1
- import { useMemo } from 'preact/hooks';
2
- /**
3
- * @param {Object} props
4
- * @param {Function} props.debounce
5
- * @param {Boolean} [props.disabled]
6
- * @param {Object} props.element
7
- * @param {Function} props.getValue
8
- * @param {String} props.id
9
- * @param {Function} [props.onBlur]
10
- * @param {Function} [props.onFocus]
11
- * @param {Function} props.setValue
12
- */
13
-
14
- import { jsx as _jsx } from "preact/jsx-runtime";
15
- export default function Simple(props) {
16
- const {
17
- debounce,
18
- disabled,
19
- element,
20
- getValue,
21
- id,
22
- onBlur,
23
- onFocus,
24
- setValue
25
- } = props;
26
- const handleInput = useMemo(() => {
27
- return debounce(({
28
- target
29
- }) => setValue(target.value.length ? target.value : undefined));
30
- }, [setValue, debounce]);
31
- const value = getValue(element);
32
- return _jsx("div", {
33
- class: "bio-properties-panel-simple",
34
- children: _jsx("input", {
35
- id: prefixId(id),
36
- type: "text",
37
- name: id,
38
- spellCheck: "false",
39
- autoComplete: "off",
40
- disabled: disabled,
41
- class: "bio-properties-panel-input",
42
- onInput: handleInput,
43
- onFocus: onFocus,
44
- onBlur: onBlur,
45
- value: value || ''
46
- })
47
- });
48
- }
49
- export function isEdited(node) {
50
- return node && !!node.value;
51
- } // helpers /////////////////
52
-
53
- function prefixId(id) {
54
- return `bio-properties-panel-${id}`;
55
- }
56
- //# sourceMappingURL=Simple.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/entries/Simple.js"],"names":["useMemo","Simple","props","debounce","disabled","element","getValue","id","onBlur","onFocus","setValue","handleInput","target","value","length","undefined","prefixId","isEdited","node"],"mappings":"AAAA,SACEA,OADF,QAEO,cAFP;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASC,MAAT,CAAgBC,KAAhB,EAAuB;AACpC,QAAM;AACJC,IAAAA,QADI;AAEJC,IAAAA,QAFI;AAGJC,IAAAA,OAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,EALI;AAMJC,IAAAA,MANI;AAOJC,IAAAA,OAPI;AAQJC,IAAAA;AARI,MASFR,KATJ;AAWA,QAAMS,WAAW,GAAGX,OAAO,CAAC,MAAM;AAChC,WAAOG,QAAQ,CAAC,CAAC;AAAES,MAAAA;AAAF,KAAD,KAAgBF,QAAQ,CAACE,MAAM,CAACC,KAAP,CAAaC,MAAb,GAAsBF,MAAM,CAACC,KAA7B,GAAqCE,SAAtC,CAAzB,CAAf;AACD,GAF0B,EAExB,CAAEL,QAAF,EAAYP,QAAZ,CAFwB,CAA3B;AAIA,QAAMU,KAAK,GAAGP,QAAQ,CAACD,OAAD,CAAtB;AAEA,SACE;AAAK,IAAA,KAAK,EAAC,6BAAX;AAAA,cACE;AACE,MAAA,EAAE,EAAGW,QAAQ,CAACT,EAAD,CADf;AAEE,MAAA,IAAI,EAAC,MAFP;AAGE,MAAA,IAAI,EAAGA,EAHT;AAIE,MAAA,UAAU,EAAC,OAJb;AAKE,MAAA,YAAY,EAAC,KALf;AAME,MAAA,QAAQ,EAAGH,QANb;AAOE,MAAA,KAAK,EAAC,4BAPR;AAQE,MAAA,OAAO,EAAGO,WARZ;AASE,MAAA,OAAO,EAAGF,OATZ;AAUE,MAAA,MAAM,EAAGD,MAVX;AAWE,MAAA,KAAK,EAAGK,KAAK,IAAI;AAXnB;AADF,IADF;AAgBD;AAED,OAAO,SAASI,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,SAAOA,IAAI,IAAI,CAAC,CAACA,IAAI,CAACL,KAAtB;AACD,C,CAGD;;AAEA,SAASG,QAAT,CAAkBT,EAAlB,EAAsB;AACpB,SAAQ,wBAAwBA,EAAI,EAApC;AACD","sourcesContent":["import {\n useMemo\n} from 'preact/hooks';\n\n/**\n * @param {Object} props\n * @param {Function} props.debounce\n * @param {Boolean} [props.disabled]\n * @param {Object} props.element\n * @param {Function} props.getValue\n * @param {String} props.id\n * @param {Function} [props.onBlur]\n * @param {Function} [props.onFocus]\n * @param {Function} props.setValue\n */\nexport default function Simple(props) {\n const {\n debounce,\n disabled,\n element,\n getValue,\n id,\n onBlur,\n onFocus,\n setValue\n } = props;\n\n const handleInput = useMemo(() => {\n return debounce(({ target }) => setValue(target.value.length ? target.value : undefined));\n }, [ setValue, debounce ]);\n\n const value = getValue(element);\n\n return (\n <div class=\"bio-properties-panel-simple\">\n <input\n id={ prefixId(id) }\n type=\"text\"\n name={ id }\n spellCheck=\"false\"\n autoComplete=\"off\"\n disabled={ disabled }\n class=\"bio-properties-panel-input\"\n onInput={ handleInput }\n onFocus={ onFocus }\n onBlur={ onBlur }\n value={ value || '' } />\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.value;\n}\n\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"Simple.js"}
@@ -1,98 +0,0 @@
1
- import Description from './Description';
2
- import { useMemo } from 'preact/hooks';
3
- import classnames from 'classnames';
4
- import { jsx as _jsx } from "preact/jsx-runtime";
5
- import { jsxs as _jsxs } from "preact/jsx-runtime";
6
-
7
- function TextArea(props) {
8
- const {
9
- id,
10
- label,
11
- rows = 2,
12
- debounce,
13
- onInput,
14
- value = '',
15
- disabled,
16
- monospace
17
- } = props;
18
- const handleInput = useMemo(() => {
19
- return debounce(({
20
- target
21
- }) => onInput(target.value.length ? target.value : undefined));
22
- }, [onInput, debounce]);
23
- return _jsxs("div", {
24
- class: "bio-properties-panel-textarea",
25
- children: [_jsx("label", {
26
- for: prefixId(id),
27
- class: "bio-properties-panel-label",
28
- children: label
29
- }), _jsx("textarea", {
30
- id: prefixId(id),
31
- name: id,
32
- spellCheck: "false",
33
- class: classnames('bio-properties-panel-input', monospace ? 'bio-properties-panel-input-monospace' : ''),
34
- onInput: handleInput,
35
- onFocus: props.onFocus,
36
- onBlur: props.onBlur,
37
- rows: rows,
38
- value: value,
39
- disabled: disabled
40
- })]
41
- });
42
- }
43
- /**
44
- * @param {object} props
45
- * @param {object} props.element
46
- * @param {string} props.id
47
- * @param {string} props.description
48
- * @param {boolean} props.debounce
49
- * @param {string} props.label
50
- * @param {Function} props.getValue
51
- * @param {Function} props.setValue
52
- * @param {number} props.rows
53
- * @param {boolean} props.monospace
54
- * @param {boolean} [props.disabled]
55
- */
56
-
57
-
58
- export default function TextAreaEntry(props) {
59
- const {
60
- element,
61
- id,
62
- description,
63
- debounce,
64
- label,
65
- getValue,
66
- setValue,
67
- rows,
68
- monospace,
69
- disabled
70
- } = props;
71
- const value = getValue(element);
72
- return _jsxs("div", {
73
- class: "bio-properties-panel-entry",
74
- "data-entry-id": id,
75
- children: [_jsx(TextArea, {
76
- id: id,
77
- label: label,
78
- value: value,
79
- onInput: setValue,
80
- rows: rows,
81
- debounce: debounce,
82
- monospace: monospace,
83
- disabled: disabled
84
- }), _jsx(Description, {
85
- forId: id,
86
- element: element,
87
- value: description
88
- })]
89
- });
90
- }
91
- export function isEdited(node) {
92
- return node && !!node.value;
93
- } // helpers /////////////////
94
-
95
- function prefixId(id) {
96
- return `bio-properties-panel-${id}`;
97
- }
98
- //# sourceMappingURL=TextArea.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/entries/TextArea.js"],"names":["Description","useMemo","classnames","TextArea","props","id","label","rows","debounce","onInput","value","disabled","monospace","handleInput","target","length","undefined","pref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,KAZV;AAaE,MAAA,QAAQ,EAAGC;AAbb,MAFF;AAAA,IADF;AAmBD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASS,aAAT,CAAuBhB,KAAvB,EAA8B;AAC3C,QAAM;AACJiB,IAAAA,OADI;AAEJhB,IAAAA,EAFI;AAGJiB,IAAAA,WAHI;AAIJd,IAAAA,QAJI;AAKJF,IAAAA,KALI;AAMJiB,IAAAA,QANI;AAOJC,IAAAA,QAPI;AAQJjB,IAAAA,IARI;AASJK,IAAAA,SATI;AAUJD,IAAAA;AAVI,MAWFP,KAXJ;AAaA,QAAMM,KAAK,GAAGa,QAAQ,CAACF,OAAD,CAAtB;AACA,SACE;AAAK,IAAA,KAAK,EAAC,4BAAX;AAAwC,qBAAgBhB,EAAxD;AAAA,eACE,KAAC,QAAD;AACE,MAAA,EAAE,EAAGA,EADP;AAEE,MAAA,KAAK,EAAGC,KAFV;AAGE,MAAA,KAAK,EAAGI,KAHV;AAIE,MAAA,OAAO,EAAGc,QAJZ;AAKE,MAAA,IAAI,EAAGjB,IALT;AAME,MAAA,QAAQ,EAAGC,QANb;AAOE,MAAA,SAAS,EAAGI,SAPd;AAQE,MAAA,QAAQ,EAAGD;AARb,MADF,EAUE,KAAC,WAAD;AAAa,MAAA,KAAK,EAAGN,EAArB;AAA0B,MAAA,OAAO,EAAGgB,OAApC;AAA8C,MAAA,KAAK,EAAGC;AAAtD,MAVF;AAAA,IADF;AAcD;AAED,OAAO,SAASG,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,SAAOA,IAAI,IAAI,CAAC,CAACA,IAAI,CAAChB,KAAtB;AACD,C,CAGD;;AAEA,SAASO,QAAT,CAAkBZ,EAAlB,EAAsB;AACpB,SAAQ,wBAAwBA,EAAI,EAApC;AACD","sourcesContent":["import Description from './Description';\n\nimport {\n useMemo\n} from 'preact/hooks';\n\nimport classnames from 'classnames';\n\nfunction TextArea(props) {\n\n const {\n id,\n label,\n rows = 2,\n debounce,\n onInput,\n value = '',\n disabled,\n monospace\n } = props;\n\n const handleInput = useMemo(() => {\n return debounce(({ target }) => onInput(target.value.length ? target.value : undefined));\n }, [ onInput, debounce ]);\n\n return (\n <div class=\"bio-properties-panel-textarea\">\n <label for={ prefixId(id) } class=\"bio-properties-panel-label\">{ label }</label>\n <textarea\n id={ prefixId(id) }\n name={ id }\n spellCheck=\"false\"\n class={ classnames(\n 'bio-properties-panel-input',\n monospace ? 'bio-properties-panel-input-monospace' : '')\n }\n onInput={ handleInput }\n onFocus={ props.onFocus }\n onBlur={ props.onBlur }\n rows={ rows }\n value={ value }\n disabled={ disabled } />\n </div>\n );\n}\n\n/**\n * @param {object} props\n * @param {object} props.element\n * @param {string} props.id\n * @param {string} props.description\n * @param {boolean} props.debounce\n * @param {string} props.label\n * @param {Function} props.getValue\n * @param {Function} props.setValue\n * @param {number} props.rows\n * @param {boolean} props.monospace\n * @param {boolean} [props.disabled]\n */\nexport default function TextAreaEntry(props) {\n const {\n element,\n id,\n description,\n debounce,\n label,\n getValue,\n setValue,\n rows,\n monospace,\n disabled\n } = props;\n\n const value = getValue(element);\n return (\n <div class=\"bio-properties-panel-entry\" data-entry-id={ id }>\n <TextArea\n id={ id }\n label={ label }\n value={ value }\n onInput={ setValue }\n rows={ rows }\n debounce={ debounce }\n monospace={ monospace }\n disabled={ disabled } />\n <Description forId={ id } element={ element } value={ description } />\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.value;\n}\n\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"TextArea.js"}