@budibase/bbui 2.2.12-alpha.41 → 2.2.12-alpha.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "2.2.12-alpha.41",
4
+ "version": "2.2.12-alpha.43",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/string-templates": "2.2.12-alpha.41",
41
+ "@budibase/string-templates": "2.2.12-alpha.43",
42
42
  "@spectrum-css/accordion": "3.0.24",
43
43
  "@spectrum-css/actionbutton": "1.0.1",
44
44
  "@spectrum-css/actiongroup": "1.0.1",
@@ -89,5 +89,5 @@
89
89
  "resolutions": {
90
90
  "loader-utils": "1.4.1"
91
91
  },
92
- "gitHead": "b5da4944f2a33a3a70df34852833b83f536cde92"
92
+ "gitHead": "b15dc542e352e796912be022f778ea931b0cedbe"
93
93
  }
@@ -1,4 +1,4 @@
1
- const ignoredClasses = [".flatpickr-calendar"]
1
+ const ignoredClasses = [".flatpickr-calendar", ".spectrum-Popover"]
2
2
  let clickHandlers = []
3
3
 
4
4
  /**
@@ -19,7 +19,7 @@ const handleClick = event => {
19
19
  }
20
20
 
21
21
  // Ignore clicks for modals, unless the handler is registered from a modal
22
- const sourceInModal = handler.element.closest(".spectrum-Modal") != null
22
+ const sourceInModal = handler.anchor.closest(".spectrum-Modal") != null
23
23
  const clickInModal = event.target.closest(".spectrum-Modal") != null
24
24
  if (clickInModal && !sourceInModal) {
25
25
  return
@@ -33,10 +33,10 @@ document.documentElement.addEventListener("click", handleClick, true)
33
33
  /**
34
34
  * Adds or updates a click handler
35
35
  */
36
- const updateHandler = (id, element, callback) => {
36
+ const updateHandler = (id, element, anchor, callback) => {
37
37
  let existingHandler = clickHandlers.find(x => x.id === id)
38
38
  if (!existingHandler) {
39
- clickHandlers.push({ id, element, callback })
39
+ clickHandlers.push({ id, element, anchor, callback })
40
40
  } else {
41
41
  existingHandler.callback = callback
42
42
  }
@@ -51,12 +51,22 @@ const removeHandler = id => {
51
51
 
52
52
  /**
53
53
  * Svelte action to apply a click outside handler for a certain element
54
+ * opts.anchor is an optional param specifying the real root source of the
55
+ * component being observed. This is required for things like popovers, where
56
+ * the element using the clickoutside action is the popover, but the popover is
57
+ * rendered at the root of the DOM somewhere, whereas the popover anchor is the
58
+ * element we actually want to consider when determining the source component.
54
59
  */
55
- export default (element, callback) => {
60
+ export default (element, opts) => {
56
61
  const id = Math.random()
57
- updateHandler(id, element, callback)
62
+ const update = newOpts => {
63
+ const callback = newOpts?.callback || newOpts
64
+ const anchor = newOpts?.anchor || element
65
+ updateHandler(id, element, anchor, callback)
66
+ }
67
+ update(opts)
58
68
  return {
59
- update: newCallback => updateHandler(id, element, newCallback),
69
+ update,
60
70
  destroy: () => removeHandler(id),
61
71
  }
62
72
  }
@@ -14,6 +14,7 @@
14
14
  <Icon name={icon} />
15
15
  {/if}
16
16
  {/if}
17
+ <slot name="icon" />
17
18
  <div>
18
19
  <slot />
19
20
  </div>
@@ -68,7 +68,10 @@
68
68
  <div
69
69
  tabindex="0"
70
70
  use:positionDropdown={{ anchor, align, maxWidth, useAnchorWidth }}
71
- use:clickOutside={handleOutsideClick}
71
+ use:clickOutside={{
72
+ callback: handleOutsideClick,
73
+ anchor,
74
+ }}
72
75
  on:keydown={handleEscape}
73
76
  class={"spectrum-Popover is-open " + (tooltipClasses || "")}
74
77
  role="presentation"