@bpmn-io/properties-panel 0.8.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/CHANGELOG.md +112 -85
  2. package/LICENSE +20 -20
  3. package/README.md +34 -34
  4. package/assets/properties-panel.css +891 -848
  5. package/dist/index.esm.js +1609 -0
  6. package/dist/index.esm.js.map +1 -0
  7. package/dist/index.js +1650 -0
  8. package/dist/index.js.map +1 -0
  9. package/package.json +87 -78
  10. package/preact/LICENSE +21 -0
  11. package/preact/README.md +185 -0
  12. package/preact/compat/dist/compat.js +2 -0
  13. package/preact/compat/dist/compat.js.map +1 -0
  14. package/preact/compat/dist/compat.mjs +2 -0
  15. package/preact/compat/dist/compat.module.js +2 -0
  16. package/preact/compat/dist/compat.module.js.map +1 -0
  17. package/preact/compat/dist/compat.umd.js +2 -0
  18. package/preact/compat/dist/compat.umd.js.map +1 -0
  19. package/preact/compat/jsx-dev-runtime.js +1 -0
  20. package/preact/compat/jsx-dev-runtime.mjs +1 -0
  21. package/preact/compat/jsx-runtime.js +1 -0
  22. package/preact/compat/jsx-runtime.mjs +1 -0
  23. package/preact/compat/package.json +19 -0
  24. package/preact/compat/server.js +15 -0
  25. package/preact/compat/server.mjs +4 -0
  26. package/preact/compat/src/Children.js +21 -0
  27. package/preact/compat/src/PureComponent.js +15 -0
  28. package/preact/compat/src/forwardRef.js +51 -0
  29. package/preact/compat/src/index.d.ts +140 -0
  30. package/preact/compat/src/index.js +175 -0
  31. package/preact/compat/src/internal.d.ts +47 -0
  32. package/preact/compat/src/memo.js +34 -0
  33. package/preact/compat/src/portals.js +80 -0
  34. package/preact/compat/src/render.js +219 -0
  35. package/preact/compat/src/scheduler.js +24 -0
  36. package/preact/compat/src/suspense-list.d.ts +14 -0
  37. package/preact/compat/src/suspense-list.js +126 -0
  38. package/preact/compat/src/suspense.d.ts +15 -0
  39. package/preact/compat/src/suspense.js +270 -0
  40. package/preact/compat/src/util.js +28 -0
  41. package/preact/compat/test-utils.js +1 -0
  42. package/preact/debug/dist/debug.js +2 -0
  43. package/preact/debug/dist/debug.js.map +1 -0
  44. package/preact/debug/dist/debug.mjs +2 -0
  45. package/preact/debug/dist/debug.module.js +2 -0
  46. package/preact/debug/dist/debug.module.js.map +1 -0
  47. package/preact/debug/dist/debug.umd.js +2 -0
  48. package/preact/debug/dist/debug.umd.js.map +1 -0
  49. package/preact/debug/package.json +18 -0
  50. package/preact/debug/src/check-props.js +54 -0
  51. package/preact/debug/src/component-stack.js +146 -0
  52. package/preact/debug/src/constants.js +3 -0
  53. package/preact/debug/src/debug.js +442 -0
  54. package/preact/debug/src/index.js +6 -0
  55. package/preact/debug/src/internal.d.ts +82 -0
  56. package/preact/debug/src/util.js +11 -0
  57. package/preact/devtools/dist/devtools.js +2 -0
  58. package/preact/devtools/dist/devtools.js.map +1 -0
  59. package/preact/devtools/dist/devtools.mjs +2 -0
  60. package/preact/devtools/dist/devtools.module.js +2 -0
  61. package/preact/devtools/dist/devtools.module.js.map +1 -0
  62. package/preact/devtools/dist/devtools.umd.js +2 -0
  63. package/preact/devtools/dist/devtools.umd.js.map +1 -0
  64. package/preact/devtools/package.json +16 -0
  65. package/preact/devtools/src/devtools.js +10 -0
  66. package/preact/devtools/src/index.d.ts +8 -0
  67. package/preact/devtools/src/index.js +15 -0
  68. package/preact/dist/preact.js +2 -0
  69. package/preact/dist/preact.js.map +1 -0
  70. package/preact/dist/preact.min.js +2 -0
  71. package/preact/dist/preact.min.js.map +1 -0
  72. package/preact/dist/preact.mjs +2 -0
  73. package/preact/dist/preact.module.js +2 -0
  74. package/preact/dist/preact.module.js.map +1 -0
  75. package/preact/dist/preact.umd.js +2 -0
  76. package/preact/dist/preact.umd.js.map +1 -0
  77. package/preact/hooks/dist/hooks.js +2 -0
  78. package/preact/hooks/dist/hooks.js.map +1 -0
  79. package/preact/hooks/dist/hooks.mjs +2 -0
  80. package/preact/hooks/dist/hooks.module.js +2 -0
  81. package/preact/hooks/dist/hooks.module.js.map +1 -0
  82. package/preact/hooks/dist/hooks.umd.js +2 -0
  83. package/preact/hooks/dist/hooks.umd.js.map +1 -0
  84. package/preact/hooks/package.json +26 -0
  85. package/preact/hooks/src/index.d.ts +130 -0
  86. package/preact/hooks/src/index.js +386 -0
  87. package/preact/hooks/src/internal.d.ts +75 -0
  88. package/preact/jsx-runtime/dist/jsxRuntime.js +2 -0
  89. package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -0
  90. package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -0
  91. package/preact/jsx-runtime/dist/jsxRuntime.module.js +2 -0
  92. package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -0
  93. package/preact/jsx-runtime/dist/jsxRuntime.umd.js +2 -0
  94. package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -0
  95. package/preact/jsx-runtime/package.json +19 -0
  96. package/preact/jsx-runtime/src/index.d.ts +50 -0
  97. package/preact/jsx-runtime/src/index.js +72 -0
  98. package/preact/package.json +268 -0
  99. package/preact/src/cjs.js +3 -0
  100. package/preact/src/clone-element.js +39 -0
  101. package/preact/src/component.js +225 -0
  102. package/preact/src/constants.js +3 -0
  103. package/preact/src/create-context.js +68 -0
  104. package/preact/src/create-element.js +100 -0
  105. package/preact/src/diff/catch-error.js +38 -0
  106. package/preact/src/diff/children.js +347 -0
  107. package/preact/src/diff/index.js +516 -0
  108. package/preact/src/diff/props.js +158 -0
  109. package/preact/src/index.d.ts +310 -0
  110. package/preact/src/index.js +13 -0
  111. package/preact/src/internal.d.ts +147 -0
  112. package/preact/src/jsx.d.ts +955 -0
  113. package/preact/src/options.js +17 -0
  114. package/preact/src/render.js +74 -0
  115. package/preact/src/util.js +23 -0
  116. package/preact/test-utils/dist/testUtils.js +2 -0
  117. package/preact/test-utils/dist/testUtils.js.map +1 -0
  118. package/preact/test-utils/dist/testUtils.mjs +2 -0
  119. package/preact/test-utils/dist/testUtils.module.js +2 -0
  120. package/preact/test-utils/dist/testUtils.module.js.map +1 -0
  121. package/preact/test-utils/dist/testUtils.umd.js +2 -0
  122. package/preact/test-utils/dist/testUtils.umd.js.map +1 -0
  123. package/preact/test-utils/package.json +19 -0
  124. package/preact/test-utils/src/index.d.ts +3 -0
  125. package/preact/test-utils/src/index.js +117 -0
  126. package/lib/PropertiesPanel.js +0 -126
  127. package/lib/PropertiesPanel.js.map +0 -1
  128. package/lib/components/DropdownButton.js +0 -109
  129. package/lib/components/DropdownButton.js.map +0 -1
  130. package/lib/components/Group.js +0 -75
  131. package/lib/components/Group.js.map +0 -1
  132. package/lib/components/Header.js +0 -49
  133. package/lib/components/Header.js.map +0 -1
  134. package/lib/components/HeaderButton.js +0 -16
  135. package/lib/components/HeaderButton.js.map +0 -1
  136. package/lib/components/ListGroup.js +0 -167
  137. package/lib/components/ListGroup.js.map +0 -1
  138. package/lib/components/ListItem.js +0 -37
  139. package/lib/components/ListItem.js.map +0 -1
  140. package/lib/components/entries/Checkbox.js +0 -81
  141. package/lib/components/entries/Checkbox.js.map +0 -1
  142. package/lib/components/entries/Collapsible.js +0 -48
  143. package/lib/components/entries/Collapsible.js.map +0 -1
  144. package/lib/components/entries/List.js +0 -204
  145. package/lib/components/entries/List.js.map +0 -1
  146. package/lib/components/entries/NumberField.js +0 -108
  147. package/lib/components/entries/NumberField.js.map +0 -1
  148. package/lib/components/entries/Select.js +0 -107
  149. package/lib/components/entries/Select.js.map +0 -1
  150. package/lib/components/entries/Simple.js +0 -56
  151. package/lib/components/entries/Simple.js.map +0 -1
  152. package/lib/components/entries/TextArea.js +0 -96
  153. package/lib/components/entries/TextArea.js.map +0 -1
  154. package/lib/components/entries/TextField.js +0 -121
  155. package/lib/components/entries/TextField.js.map +0 -1
  156. package/lib/components/entries/ToggleSwitch.js +0 -87
  157. package/lib/components/entries/ToggleSwitch.js.map +0 -1
  158. package/lib/components/icons/index.js +0 -51
  159. package/lib/components/icons/index.js.map +0 -1
  160. package/lib/context/LayoutContext.js +0 -9
  161. package/lib/context/LayoutContext.js.map +0 -1
  162. package/lib/context/index.js +0 -2
  163. package/lib/context/index.js.map +0 -1
  164. package/lib/features/debounce-input/debounceInput.js +0 -14
  165. package/lib/features/debounce-input/debounceInput.js.map +0 -1
  166. package/lib/features/debounce-input/index.js +0 -5
  167. package/lib/features/debounce-input/index.js.map +0 -1
  168. package/lib/hooks/index.js +0 -4
  169. package/lib/hooks/index.js.map +0 -1
  170. package/lib/hooks/useKeyFactory.js +0 -39
  171. package/lib/hooks/useKeyFactory.js.map +0 -1
  172. package/lib/hooks/useLayoutState.js +0 -36
  173. package/lib/hooks/useLayoutState.js.map +0 -1
  174. package/lib/hooks/usePrevious.js +0 -16
  175. package/lib/hooks/usePrevious.js.map +0 -1
  176. package/lib/index.js +0 -2
  177. package/lib/index.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ import { _catchError } from './diff/catch-error';
2
+
3
+ /**
4
+ * The `option` object can potentially contain callback functions
5
+ * that are called during various stages of our renderer. This is the
6
+ * foundation on which all our addons like `preact/debug`, `preact/compat`,
7
+ * and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
8
+ * for a full list of available option hooks (most editors/IDEs allow you to
9
+ * ctrl+click or cmd+click on mac the type definition below).
10
+ * @type {import('./internal').Options}
11
+ */
12
+ const options = {
13
+ _catchError,
14
+ _vnodeId: 0
15
+ };
16
+
17
+ export default options;
@@ -0,0 +1,74 @@
1
+ import { EMPTY_OBJ, EMPTY_ARR } from './constants';
2
+ import { commitRoot, diff } from './diff/index';
3
+ import { createElement, Fragment } from './create-element';
4
+ import options from './options';
5
+
6
+ /**
7
+ * Render a Preact virtual node into a DOM element
8
+ * @param {import('./internal').ComponentChild} vnode The virtual node to render
9
+ * @param {import('./internal').PreactElement} parentDom The DOM element to
10
+ * render into
11
+ * @param {import('./internal').PreactElement | object} [replaceNode] Optional: Attempt to re-use an
12
+ * existing DOM tree rooted at `replaceNode`
13
+ */
14
+ export function render(vnode, parentDom, replaceNode) {
15
+ if (options._root) options._root(vnode, parentDom);
16
+
17
+ // We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
18
+ // hydration mode or not by passing the `hydrate` function instead of a DOM
19
+ // element..
20
+ let isHydrating = typeof replaceNode === 'function';
21
+
22
+ // To be able to support calling `render()` multiple times on the same
23
+ // DOM node, we need to obtain a reference to the previous tree. We do
24
+ // this by assigning a new `_children` property to DOM nodes which points
25
+ // to the last rendered tree. By default this property is not present, which
26
+ // means that we are mounting a new tree for the first time.
27
+ let oldVNode = isHydrating
28
+ ? null
29
+ : (replaceNode && replaceNode._children) || parentDom._children;
30
+
31
+ vnode = (
32
+ (!isHydrating && replaceNode) ||
33
+ parentDom
34
+ )._children = createElement(Fragment, null, [vnode]);
35
+
36
+ // List of effects that need to be called after diffing.
37
+ let commitQueue = [];
38
+ diff(
39
+ parentDom,
40
+ // Determine the new vnode tree and store it on the DOM element on
41
+ // our custom `_children` property.
42
+ vnode,
43
+ oldVNode || EMPTY_OBJ,
44
+ EMPTY_OBJ,
45
+ parentDom.ownerSVGElement !== undefined,
46
+ !isHydrating && replaceNode
47
+ ? [replaceNode]
48
+ : oldVNode
49
+ ? null
50
+ : parentDom.firstChild
51
+ ? EMPTY_ARR.slice.call(parentDom.childNodes)
52
+ : null,
53
+ commitQueue,
54
+ !isHydrating && replaceNode
55
+ ? replaceNode
56
+ : oldVNode
57
+ ? oldVNode._dom
58
+ : parentDom.firstChild,
59
+ isHydrating
60
+ );
61
+
62
+ // Flush all queued effects
63
+ commitRoot(commitQueue, vnode);
64
+ }
65
+
66
+ /**
67
+ * Update an existing DOM element with data from a Preact virtual node
68
+ * @param {import('./internal').ComponentChild} vnode The virtual node to render
69
+ * @param {import('./internal').PreactElement} parentDom The DOM element to
70
+ * update
71
+ */
72
+ export function hydrate(vnode, parentDom) {
73
+ render(vnode, parentDom, hydrate);
74
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Assign properties from `props` to `obj`
3
+ * @template O, P The obj and props types
4
+ * @param {O} obj The object to copy properties to
5
+ * @param {P} props The object to copy properties from
6
+ * @returns {O & P}
7
+ */
8
+ export function assign(obj, props) {
9
+ // @ts-ignore We change the type of `obj` to be `O & P`
10
+ for (let i in props) obj[i] = props[i];
11
+ return /** @type {O & P} */ (obj);
12
+ }
13
+
14
+ /**
15
+ * Remove a child node from its parent if attached. This is a workaround for
16
+ * IE11 which doesn't support `Element.prototype.remove()`. Using this function
17
+ * is smaller than including a dedicated polyfill.
18
+ * @param {Node} node The node to remove
19
+ */
20
+ export function removeNode(node) {
21
+ let parentNode = node.parentNode;
22
+ if (parentNode) parentNode.removeChild(node);
23
+ }
@@ -0,0 +1,2 @@
1
+ var r=require("../..");function n(){return r.options.t=r.options.debounceRendering,r.options.debounceRendering=function(n){return r.options.o=n},function(){return r.options.o&&r.options.o()}}var t=function(r){return null!=r&&"function"==typeof r.then},e=0;function o(){r.options.o&&(r.options.o(),delete r.options.o),void 0!==r.options.t?(r.options.debounceRendering=r.options.t,delete r.options.t):r.options.debounceRendering=void 0}exports.setupRerender=n,exports.act=function(u){if(++e>1){var i=u();return t(i)?i.then(function(){--e}):(--e,Promise.resolve())}var c,f,a=r.options.requestAnimationFrame,v=n();r.options.requestAnimationFrame=function(r){return c=r};var l,p,s=function(){try{for(v();c;)f=c,c=null,f(),v();o()}catch(r){l||(l=r)}r.options.requestAnimationFrame=a,--e};try{p=u()}catch(r){l=r}if(t(p))return p.then(s,function(r){throw s(),r});if(s(),l)throw l;return Promise.resolve()},exports.teardown=o;
2
+ //# sourceMappingURL=testUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.js","sources":["../src/index.js"],"sourcesContent":["import { options } from '../..';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"wBAMA,SAAgBA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAwFf,SAAgBC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,sCAxFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDT,IACC,MAAOa,GACHF,IACJA,EAAME,GAIRtB,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
@@ -0,0 +1,2 @@
1
+ import{options as n}from"../..";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var i=u();return t(i)?i.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l();e()}catch(n){v||(v=n)}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function e(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,e as teardown};
2
+ //# sourceMappingURL=testUtils.module.js.map
@@ -0,0 +1,2 @@
1
+ import{options as n}from"../..";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var i=u();return t(i)?i.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l();e()}catch(n){v||(v=n)}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function e(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,e as teardown};
2
+ //# sourceMappingURL=testUtils.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.module.js","sources":["../src/index.js"],"sourcesContent":["import { options } from '../..';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","act","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","teardown","e","undefined"],"mappings":"iCAMA,SAAgBA,WACfC,EAAQC,EAA2BD,EAAQE,kBAC3CF,EAAQE,kBAAoB,SAAAC,UAAOH,EAAQI,EAAqBD,GACzD,kBAAMH,EAAQI,GAAsBJ,EAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAWR,SAASC,EAAIN,QACbK,EAAW,EAAG,KAObE,EAASP,WACXE,EAAWK,GACPA,EAAOH,KAAK,aAChBC,OAGFA,EACKG,QAAQC,eAOZC,EAAOC,EAJLC,EAAgCf,EAAQgB,sBACxCC,EAAWlB,IAMjBC,EAAQgB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDI,IACC,MAAOC,GACHH,IACJA,EAAMG,GAIRtB,EAAQgB,sBAAwBD,IAC9BP,OAOFE,EAASP,IACR,MAAOmB,GACRH,EAAMG,KAGHjB,EAAWK,UACPA,EAAOH,KAAKa,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC,UAMhB,SAAgBS,IACXrB,EAAQI,IAEXJ,EAAQI,WACDJ,EAAQI,QAG+B,IAApCJ,EAAQC,GAClBD,EAAQE,kBAAoBF,EAAQC,SAC7BD,EAAQC,GAEfD,EAAQE,uBAAoBqB"}
@@ -0,0 +1,2 @@
1
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("../..")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t(n.preactTestUtils={},n.preact)}(this,function(n,t){function e(){return t.options.t=t.options.debounceRendering,t.options.debounceRendering=function(n){return t.options.o=n},function(){return t.options.o&&t.options.o()}}var r=function(n){return null!=n&&"function"==typeof n.then},o=0;function i(){t.options.o&&(t.options.o(),delete t.options.o),void 0!==t.options.t?(t.options.debounceRendering=t.options.t,delete t.options.t):t.options.debounceRendering=void 0}n.setupRerender=e,n.act=function(n){if(++o>1){var u=n();return r(u)?u.then(function(){--o}):(--o,Promise.resolve())}var f,c,d=t.options.requestAnimationFrame,p=e();t.options.requestAnimationFrame=function(n){return f=n};var a,l,s=function(){try{for(p();f;)c=f,f=null,c(),p();i()}catch(n){a||(a=n)}t.options.requestAnimationFrame=d,--o};try{l=n()}catch(n){a=n}if(r(l))return l.then(s,function(n){throw s(),n});if(s(),a)throw a;return Promise.resolve()},n.teardown=i});
2
+ //# sourceMappingURL=testUtils.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testUtils.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from '../..';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"2NAMO,SAASA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAwFR,SAASC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,0BAxFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDT,IACC,MAAOa,GACHF,IACJA,EAAME,GAIRtB,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "test-utils",
3
+ "amdName": "preactTestUtils",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "description": "Test-utils for Preact",
7
+ "main": "dist/testUtils.js",
8
+ "module": "dist/testUtils.module.js",
9
+ "umd:main": "dist/testUtils.umd.js",
10
+ "source": "src/index.js",
11
+ "license": "MIT",
12
+ "types": "src/index.d.ts",
13
+ "peerDependencies": {
14
+ "preact": "^10.0.0"
15
+ },
16
+ "mangle": {
17
+ "regex": "^_"
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ export function setupRerender(): () => void;
2
+ export function act(callback: () => void | Promise<void>): Promise<void>;
3
+ export function teardown(): void;
@@ -0,0 +1,117 @@
1
+ import { options } from '../..';
2
+
3
+ /**
4
+ * Setup a rerender function that will drain the queue of pending renders
5
+ * @returns {() => void}
6
+ */
7
+ export function setupRerender() {
8
+ options.__test__previousDebounce = options.debounceRendering;
9
+ options.debounceRendering = cb => (options.__test__drainQueue = cb);
10
+ return () => options.__test__drainQueue && options.__test__drainQueue();
11
+ }
12
+
13
+ const isThenable = value => value != null && typeof value.then == 'function';
14
+
15
+ /** Depth of nested calls to `act`. */
16
+ let actDepth = 0;
17
+
18
+ /**
19
+ * Run a test function, and flush all effects and rerenders after invoking it.
20
+ *
21
+ * Returns a Promise which resolves "immediately" if the callback is
22
+ * synchronous or when the callback's result resolves if it is asynchronous.
23
+ *
24
+ * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.
25
+ * @return {Promise<void>}
26
+ */
27
+ export function act(cb) {
28
+ if (++actDepth > 1) {
29
+ // If calls to `act` are nested, a flush happens only when the
30
+ // outermost call returns. In the inner call, we just execute the
31
+ // callback and return since the infrastructure for flushing has already
32
+ // been set up.
33
+ //
34
+ // If an exception occurs, the outermost `act` will handle cleanup.
35
+ const result = cb();
36
+ if (isThenable(result)) {
37
+ return result.then(() => {
38
+ --actDepth;
39
+ });
40
+ }
41
+ --actDepth;
42
+ return Promise.resolve();
43
+ }
44
+
45
+ const previousRequestAnimationFrame = options.requestAnimationFrame;
46
+ const rerender = setupRerender();
47
+
48
+ /** @type {() => void} */
49
+ let flush, toFlush;
50
+
51
+ // Override requestAnimationFrame so we can flush pending hooks.
52
+ options.requestAnimationFrame = fc => (flush = fc);
53
+
54
+ const finish = () => {
55
+ try {
56
+ rerender();
57
+ while (flush) {
58
+ toFlush = flush;
59
+ flush = null;
60
+
61
+ toFlush();
62
+ rerender();
63
+ }
64
+ teardown();
65
+ } catch (e) {
66
+ if (!err) {
67
+ err = e;
68
+ }
69
+ }
70
+
71
+ options.requestAnimationFrame = previousRequestAnimationFrame;
72
+ --actDepth;
73
+ };
74
+
75
+ let err;
76
+ let result;
77
+
78
+ try {
79
+ result = cb();
80
+ } catch (e) {
81
+ err = e;
82
+ }
83
+
84
+ if (isThenable(result)) {
85
+ return result.then(finish, err => {
86
+ finish();
87
+ throw err;
88
+ });
89
+ }
90
+
91
+ // nb. If the callback is synchronous, effects must be flushed before
92
+ // `act` returns, so that the caller does not have to await the result,
93
+ // even though React recommends this.
94
+ finish();
95
+ if (err) {
96
+ throw err;
97
+ }
98
+ return Promise.resolve();
99
+ }
100
+
101
+ /**
102
+ * Teardown test environment and reset preact's internal state
103
+ */
104
+ export function teardown() {
105
+ if (options.__test__drainQueue) {
106
+ // Flush any pending updates leftover by test
107
+ options.__test__drainQueue();
108
+ delete options.__test__drainQueue;
109
+ }
110
+
111
+ if (typeof options.__test__previousDebounce != 'undefined') {
112
+ options.debounceRendering = options.__test__previousDebounce;
113
+ delete options.__test__previousDebounce;
114
+ } else {
115
+ options.debounceRendering = undefined;
116
+ }
117
+ }
@@ -1,126 +0,0 @@
1
- import { useState, useEffect } from 'preact/hooks';
2
- import { get, set } from 'min-dash';
3
- import classnames from 'classnames';
4
- import Header from './components/Header';
5
- import Group from './components/Group';
6
- import { LayoutContext } from './context';
7
- import { jsx as _jsx } from "preact/jsx-runtime";
8
- import { jsxs as _jsxs } from "preact/jsx-runtime";
9
- const DEFAULT_LAYOUT = {
10
- open: true
11
- };
12
- /**
13
- * @typedef { {
14
- * component: import('preact').ComponentChild,
15
- * id: String,
16
- * isEdited?: Function
17
- * } } EntryDefinition
18
- *
19
- * @typedef { {
20
- * autoFocusEntry: String,
21
- * autoOpen?: Boolean,
22
- * entries: Array<EntryDefinition>,
23
- * id: String,
24
- * label: String,
25
- * remove: (event: MouseEvent) => void
26
- * } } ListItemDefinition
27
- *
28
- * @typedef { {
29
- * add: (event: MouseEvent) => void,
30
- * component: import('preact').Component,
31
- * element: Object,
32
- * id: String,
33
- * items: Array<ListItemDefinition>,
34
- * label: String,
35
- * shouldSort?: Boolean,
36
- * shouldOpen?: Boolean
37
- * } } ListGroupDefinition
38
- *
39
- * @typedef { {
40
- * component?: import('preact').Component,
41
- * entries: Array<EntryDefinition>,
42
- * id: String,
43
- * label: String
44
- * } } GroupDefinition
45
- *
46
- */
47
-
48
- /**
49
- * A basic properties panel component. Describes *how* content will be rendered, accepts
50
- * data from implementor to describe *what* will be rendered.
51
- *
52
- * @param {Object} props
53
- * @param {Object} props.element
54
- * @param {import('./components/Header').HeaderProvider} props.headerProvider
55
- * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups
56
- * @param {Object} [props.layoutConfig]
57
- * @param {Function} [props.layoutChanged]
58
- */
59
-
60
- export default function PropertiesPanel(props) {
61
- const {
62
- element,
63
- headerProvider,
64
- groups,
65
- layoutConfig = {},
66
- layoutChanged
67
- } = props;
68
- const [layout, setLayout] = useState(createLayoutContext(layoutConfig));
69
- useEffect(() => {
70
- if (typeof layoutChanged === 'function') {
71
- layoutChanged(layout);
72
- }
73
- }, [layout, layoutChanged]);
74
-
75
- const getLayoutForKey = (key, defaultValue) => {
76
- return get(layout, key, defaultValue);
77
- };
78
-
79
- const setLayoutForKey = (key, config) => {
80
- setLayout(set(layout, key, config));
81
- };
82
-
83
- const layoutContext = {
84
- layout,
85
- setLayout,
86
- getLayoutForKey,
87
- setLayoutForKey
88
- };
89
-
90
- if (!element) {
91
- return _jsx("div", {
92
- class: "bio-properties-panel-placeholder",
93
- children: "Select an element to edit its properties."
94
- });
95
- }
96
-
97
- return _jsx(LayoutContext.Provider, {
98
- value: layoutContext,
99
- children: _jsxs("div", {
100
- class: classnames('bio-properties-panel', layout.open ? 'open' : ''),
101
- children: [_jsx(Header, {
102
- element: element,
103
- headerProvider: headerProvider
104
- }), _jsx("div", {
105
- class: "bio-properties-panel-scroll-container",
106
- children: groups.map(group => {
107
- const {
108
- component: GroupComponent = Group,
109
- id
110
- } = group;
111
- return _jsx(GroupComponent, {
112
- element: element,
113
- ...group
114
- }, id);
115
- })
116
- })]
117
- })
118
- });
119
- } // helpers //////////////////
120
-
121
- function createLayoutContext(overrides) {
122
- return { ...DEFAULT_LAYOUT,
123
- ...overrides
124
- };
125
- }
126
- //# sourceMappingURL=PropertiesPanel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/PropertiesPanel.js"],"names":["useState","useEffect","get","set","classnames","Header","Group","LayoutContext","DEFAULT_LAYOUT","open","PropertiesPanel","props","element","headerProvider","groups","layoutConfig","layoutChanged","layout","setLayout","createLayoutContext","getLayoutForKey","key","defaultValue","setLayoutForKey","config","layoutContext","map","group","component","GroupComponent","id","overrides"],"mappings":"AAAA,SACEA,QADF,EAEEC,SAFF,QAGO,cAHP;AAKA,SACEC,GADF,EAEEC,GAFF,QAGO,UAHP;AAKA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,MAAP,MAAmB,qBAAnB;AAEA,OAAOC,KAAP,MAAkB,oBAAlB;AAEA,SACEC,aADF,QAEO,WAFP;;;AAIA,MAAMC,cAAc,GAAG;AACrBC,EAAAA,IAAI,EAAE;AADe,CAAvB;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,eAAT,CAAyBC,KAAzB,EAAgC;AAC7C,QAAM;AACJC,IAAAA,OADI;AAEJC,IAAAA,cAFI;AAGJC,IAAAA,MAHI;AAIJC,IAAAA,YAAY,GAAG,EAJX;AAKJC,IAAAA;AALI,MAMFL,KANJ;AAQA,QAAM,CAAEM,MAAF,EAAUC,SAAV,IAAwBlB,QAAQ,CAACmB,mBAAmB,CAACJ,YAAD,CAApB,CAAtC;AAEAd,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,OAAOe,aAAP,KAAyB,UAA7B,EAAyC;AACvCA,MAAAA,aAAa,CAACC,MAAD,CAAb;AACD;AACF,GAJQ,EAIN,CAAEA,MAAF,EAAUD,aAAV,CAJM,CAAT;;AAMA,QAAMI,eAAe,GAAG,CAACC,GAAD,EAAMC,YAAN,KAAuB;AAC7C,WAAOpB,GAAG,CAACe,MAAD,EAASI,GAAT,EAAcC,YAAd,CAAV;AACD,GAFD;;AAIA,QAAMC,eAAe,GAAG,CAACF,GAAD,EAAMG,MAAN,KAAiB;AACvCN,IAAAA,SAAS,CAACf,GAAG,CAACc,MAAD,EAASI,GAAT,EAAcG,MAAd,CAAJ,CAAT;AACD,GAFD;;AAIA,QAAMC,aAAa,GAAG;AACpBR,IAAAA,MADoB;AAEpBC,IAAAA,SAFoB;AAGpBE,IAAAA,eAHoB;AAIpBG,IAAAA;AAJoB,GAAtB;;AAOA,MAAI,CAACX,OAAL,EAAc;AACZ,WAAO;AAAK,MAAA,KAAK,EAAC,kCAAX;AAAA;AAAA,MAAP;AACD;;AAED,SAAO,KAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAGa,aAAhC;AAAA,cACL;AACE,MAAA,KAAK,EAAGrB,UAAU,CAChB,sBADgB,EAEhBa,MAAM,CAACR,IAAP,GAAc,MAAd,GAAuB,EAFP,CADpB;AAAA,iBAKE,KAAC,MAAD;AACE,QAAA,OAAO,EAAGG,OADZ;AAEE,QAAA,cAAc,EAAGC;AAFnB,QALF,EAQE;AAAK,QAAA,KAAK,EAAC,uCAAX;AAAA,kBAEIC,MAAM,CAACY,GAAP,CAAWC,KAAK,IAAI;AAElB,gBAAM;AACJC,YAAAA,SAAS,EAAEC,cAAc,GAAGvB,KADxB;AAEJwB,YAAAA;AAFI,cAGFH,KAHJ;AAKA,iBAAO,KAAC,cAAD;AAEL,YAAA,OAAO,EAAGf,OAFL;AAAA,eAGAe;AAHA,aACCG,EADD,CAAP;AAID,SAXD;AAFJ,QARF;AAAA;AADK,IAAP;AA2BD,C,CAGD;;AAEA,SAASX,mBAAT,CAA6BY,SAA7B,EAAwC;AACtC,SAAO,EACL,GAAGvB,cADE;AAEL,OAAGuB;AAFE,GAAP;AAID","sourcesContent":["import {\n useState,\n useEffect\n} from 'preact/hooks';\n\nimport {\n get,\n set\n} from 'min-dash';\n\nimport classnames from 'classnames';\n\nimport Header from './components/Header';\n\nimport Group from './components/Group';\n\nimport {\n LayoutContext\n} from './context';\n\nconst DEFAULT_LAYOUT = {\n open: true\n};\n\n\n/**\n * @typedef { {\n * component: import('preact').ComponentChild,\n * id: String,\n * isEdited?: Function\n * } } EntryDefinition\n *\n * @typedef { {\n * autoFocusEntry: String,\n * autoOpen?: Boolean,\n * entries: Array<EntryDefinition>,\n * id: String,\n * label: String,\n * remove: (event: MouseEvent) => void\n * } } ListItemDefinition\n *\n * @typedef { {\n * add: (event: MouseEvent) => void,\n * component: import('preact').Component,\n * element: Object,\n * id: String,\n * items: Array<ListItemDefinition>,\n * label: String,\n * shouldSort?: Boolean,\n * shouldOpen?: Boolean\n * } } ListGroupDefinition\n *\n * @typedef { {\n * component?: import('preact').Component,\n * entries: Array<EntryDefinition>,\n * id: String,\n * label: String\n * } } GroupDefinition\n *\n */\n\n\n/**\n * A basic properties panel component. Describes *how* content will be rendered, accepts\n * data from implementor to describe *what* will be rendered.\n *\n * @param {Object} props\n * @param {Object} props.element\n * @param {import('./components/Header').HeaderProvider} props.headerProvider\n * @param {Array<GroupDefinition|ListGroupDefinition>} props.groups\n * @param {Object} [props.layoutConfig]\n * @param {Function} [props.layoutChanged]\n */\nexport default function PropertiesPanel(props) {\n const {\n element,\n headerProvider,\n groups,\n layoutConfig = {},\n layoutChanged\n } = props;\n\n const [ layout, setLayout ] = useState(createLayoutContext(layoutConfig));\n\n useEffect(() => {\n if (typeof layoutChanged === 'function') {\n layoutChanged(layout);\n }\n }, [ layout, layoutChanged ]);\n\n const getLayoutForKey = (key, defaultValue) => {\n return get(layout, key, defaultValue);\n };\n\n const setLayoutForKey = (key, config) => {\n setLayout(set(layout, key, config));\n };\n\n const layoutContext = {\n layout,\n setLayout,\n getLayoutForKey,\n setLayoutForKey\n };\n\n if (!element) {\n return <div class=\"bio-properties-panel-placeholder\">Select an element to edit its properties.</div>;\n }\n\n return <LayoutContext.Provider value={ layoutContext }>\n <div\n class={ classnames(\n 'bio-properties-panel',\n layout.open ? 'open' : '')\n }>\n <Header\n element={ element }\n headerProvider={ headerProvider } />\n <div class=\"bio-properties-panel-scroll-container\">\n {\n groups.map(group => {\n\n const {\n component: GroupComponent = Group,\n id\n } = group;\n\n return <GroupComponent\n key={ id }\n element={ element }\n { ...group } />;\n })\n }\n </div>\n </div>\n </LayoutContext.Provider>;\n}\n\n\n// helpers //////////////////\n\nfunction createLayoutContext(overrides) {\n return {\n ...DEFAULT_LAYOUT,\n ...overrides\n };\n}\n"],"file":"PropertiesPanel.js"}
@@ -1,109 +0,0 @@
1
- import { useEffect, useRef, useState } from 'preact/hooks';
2
- import classnames from 'classnames';
3
- /**
4
- *
5
- * @param {object} props
6
- * @param {string} [props.class]
7
- * @param {import('preact').Component[]} [props.menuItems]
8
- * @returns
9
- */
10
-
11
- import { jsx as _jsx } from "preact/jsx-runtime";
12
- import { jsxs as _jsxs } from "preact/jsx-runtime";
13
- export function DropdownButton(props) {
14
- const {
15
- class: className,
16
- children,
17
- menuItems = []
18
- } = props;
19
- const dropdownRef = useRef(null);
20
- const menuRef = useRef(null);
21
- const [open, setOpen] = useState(false);
22
-
23
- const close = () => setOpen(false);
24
-
25
- function onDropdownToggle(event) {
26
- if (menuRef.current && menuRef.current.contains(event.target)) {
27
- return;
28
- }
29
-
30
- event.stopPropagation();
31
- setOpen(open => !open);
32
- }
33
-
34
- function onActionClick(event, action) {
35
- event.stopPropagation();
36
- close();
37
- action();
38
- }
39
-
40
- useGlobalClick([dropdownRef.current], () => close());
41
- return _jsxs("div", {
42
- class: classnames('bio-properties-panel-dropdown-button', {
43
- open
44
- }, className),
45
- onClick: onDropdownToggle,
46
- ref: dropdownRef,
47
- children: [children, _jsx("div", {
48
- class: "bio-properties-panel-dropdown-button__menu",
49
- ref: menuRef,
50
- children: menuItems.map((item, index) => _jsx(MenuItem, {
51
- onClick: onActionClick,
52
- item: item
53
- }, index))
54
- })]
55
- });
56
- }
57
-
58
- function MenuItem({
59
- item,
60
- onClick
61
- }) {
62
- if (item.separator) {
63
- return _jsx("div", {
64
- class: "bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--separator"
65
- });
66
- }
67
-
68
- if (item.action) {
69
- return _jsx("button", {
70
- class: "bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--actionable",
71
- onClick: event => onClick(event, item.action),
72
- children: item.entry
73
- });
74
- }
75
-
76
- return _jsx("div", {
77
- class: "bio-properties-panel-dropdown-button__menu-item",
78
- children: item.entry
79
- });
80
- }
81
- /**
82
- *
83
- * @param {Array<null | Element>} ignoredElements
84
- * @param {Function} callback
85
- */
86
-
87
-
88
- function useGlobalClick(ignoredElements, callback) {
89
- useEffect(() => {
90
- /**
91
- * @param {MouseEvent} event
92
- */
93
- function listener(event) {
94
- if (ignoredElements.some(element => element && element.contains(event.target))) {
95
- return;
96
- }
97
-
98
- callback();
99
- }
100
-
101
- document.addEventListener('click', listener, {
102
- capture: true
103
- });
104
- return () => document.removeEventListener('click', listener, {
105
- capture: true
106
- });
107
- }, [...ignoredElements, callback]);
108
- }
109
- //# sourceMappingURL=DropdownButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/DropdownButton.js"],"names":["useEffect","useRef","useState","classnames","DropdownButton","props","class","className","children","menuItems","dropdownRef","menuRef","open","setOpen","close","onDropdownToggle","event","current","contains","target","stopPropagation","onActionClick","action","useGlobalClick","map","item","index","MenuItem","onClick","separator","entry","ignoredElements","callback","listener","some","element","document","addEventListener","capture","removeEventListener"],"mappings":"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","sourcesContent":["import {\n useEffect,\n useRef,\n useState\n} from 'preact/hooks';\n\nimport classnames from 'classnames';\n\n/**\n *\n * @param {object} props\n * @param {string} [props.class]\n * @param {import('preact').Component[]} [props.menuItems]\n * @returns\n */\nexport function DropdownButton(props) {\n const {\n class: className,\n children,\n menuItems = []\n } = props;\n\n const dropdownRef = useRef(null);\n const menuRef = useRef(null);\n\n const [ open, setOpen ] = useState(false);\n const close = () => setOpen(false);\n\n function onDropdownToggle(event) {\n if (menuRef.current && menuRef.current.contains(event.target)) {\n return;\n }\n\n event.stopPropagation();\n\n setOpen(open => !open);\n }\n\n function onActionClick(event, action) {\n event.stopPropagation();\n\n close();\n action();\n }\n\n useGlobalClick([ dropdownRef.current ], () => close());\n\n return (\n <div\n class={ classnames('bio-properties-panel-dropdown-button', { open }, className) }\n onClick={ onDropdownToggle }\n ref={ dropdownRef }\n >\n { children }\n <div class=\"bio-properties-panel-dropdown-button__menu\" ref={ menuRef }>\n { menuItems.map((item, index) => (\n <MenuItem onClick={ onActionClick } item={ item } key={ index } />\n )) }\n </div>\n </div>\n );\n}\n\nfunction MenuItem({ item, onClick }) {\n if (item.separator) {\n return <div class=\"bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--separator\" />;\n }\n\n if (item.action) {\n return (<button\n class=\"bio-properties-panel-dropdown-button__menu-item bio-properties-panel-dropdown-button__menu-item--actionable\"\n onClick={ event => onClick(event, item.action) }\n >\n {item.entry}\n </button>);\n }\n\n return <div\n class=\"bio-properties-panel-dropdown-button__menu-item\"\n >\n {item.entry}\n </div>;\n}\n\n/**\n *\n * @param {Array<null | Element>} ignoredElements\n * @param {Function} callback\n */\nfunction useGlobalClick(ignoredElements, callback) {\n useEffect(() => {\n\n /**\n * @param {MouseEvent} event\n */\n function listener(event) {\n if (ignoredElements.some(element => element && element.contains(event.target))) {\n return;\n }\n\n callback();\n }\n\n document.addEventListener('click', listener, { capture: true });\n\n return () => document.removeEventListener('click', listener, { capture: true });\n }, [ ...ignoredElements, callback ]);\n}\n"],"file":"DropdownButton.js"}
@@ -1,75 +0,0 @@
1
- import { useEffect, useState } from 'preact/hooks';
2
- import classnames from 'classnames';
3
- import { query as domQuery } from 'min-dom';
4
- import { isFunction } from 'min-dash';
5
- import { useLayoutState } from '../hooks';
6
- import { ArrowIcon } from './icons';
7
- /**
8
- * @param {import('../PropertiesPanel').GroupDefinition} props
9
- */
10
-
11
- import { jsx as _jsx } from "preact/jsx-runtime";
12
- import { jsxs as _jsxs } from "preact/jsx-runtime";
13
- export default function Group(props) {
14
- const {
15
- id,
16
- entries = [],
17
- label
18
- } = props;
19
- const [open, setOpen] = useLayoutState(['groups', id, 'open'], false);
20
-
21
- const toggleOpen = () => setOpen(!open);
22
-
23
- const [edited, setEdited] = useState(false); // set edited state depending on all entries
24
-
25
- useEffect(() => {
26
- const hasOneEditedEntry = entries.find(entry => {
27
- const {
28
- id,
29
- isEdited
30
- } = entry;
31
- const entryNode = domQuery(`[data-entry-id="${id}"]`);
32
-
33
- if (!isFunction(isEdited) || !entryNode) {
34
- return false;
35
- }
36
-
37
- const inputNode = domQuery('.bio-properties-panel-input', entryNode);
38
- return isEdited(inputNode);
39
- });
40
- setEdited(hasOneEditedEntry);
41
- }, [entries]);
42
- return _jsxs("div", {
43
- class: "bio-properties-panel-group",
44
- "data-group-id": 'group-' + id,
45
- children: [_jsxs("div", {
46
- class: classnames('bio-properties-panel-group-header', edited ? '' : 'empty', open ? 'open' : ''),
47
- onClick: toggleOpen,
48
- children: [_jsx("div", {
49
- title: label,
50
- class: "bio-properties-panel-group-header-title",
51
- children: label
52
- }), _jsxs("div", {
53
- class: "bio-properties-panel-group-header-buttons",
54
- children: [edited && _jsx(DataMarker, {}), _jsx("button", {
55
- title: "Toggle section",
56
- class: "bio-properties-panel-group-header-button bio-properties-panel-arrow",
57
- children: _jsx(ArrowIcon, {
58
- class: open ? 'bio-properties-panel-arrow-down' : 'bio-properties-panel-arrow-right'
59
- })
60
- })]
61
- })]
62
- }), _jsx("div", {
63
- class: classnames('bio-properties-panel-group-entries', open ? 'open' : ''),
64
- children: entries.map(e => e.component)
65
- })]
66
- });
67
- }
68
-
69
- function DataMarker() {
70
- return _jsx("div", {
71
- title: "Section contains data",
72
- class: "bio-properties-panel-dot"
73
- });
74
- }
75
- //# sourceMappingURL=Group.js.map