@budibase/bbui 1.2.41-alpha.0 → 1.2.41-alpha.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.
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": "1.2.41-alpha.0",
4
+ "version": "1.2.41-alpha.1",
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": "1.2.41-alpha.0",
41
+ "@budibase/string-templates": "1.2.41-alpha.1",
42
42
  "@spectrum-css/actionbutton": "^1.0.1",
43
43
  "@spectrum-css/actiongroup": "^1.0.1",
44
44
  "@spectrum-css/avatar": "^3.0.2",
@@ -85,5 +85,5 @@
85
85
  "svelte-flatpickr": "^3.2.3",
86
86
  "svelte-portal": "^1.0.0"
87
87
  },
88
- "gitHead": "3120f90e92b0608afdf4e3096ba4767928d68661"
88
+ "gitHead": "cee7bb82a19d2bff742e53205add7b57e5e28c08"
89
89
  }
@@ -83,4 +83,9 @@
83
83
  transform: translateX(-50%);
84
84
  text-align: center;
85
85
  }
86
+
87
+ .spectrum-Icon--sizeXS {
88
+ width: 10px;
89
+ height: 10px;
90
+ }
86
91
  </style>
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { createEventDispatcher, getContext } from "svelte"
3
+ import Icon from "../Icon/Icon.svelte"
3
4
 
4
5
  const dispatch = createEventDispatcher()
5
6
  const actionMenu = getContext("actionMenu")
@@ -8,6 +9,22 @@
8
9
  export let icon = undefined
9
10
  export let disabled = undefined
10
11
  export let noClose = false
12
+ export let keyBind = undefined
13
+
14
+ $: keys = getKeys(keyBind)
15
+
16
+ const getKeys = keyBind => {
17
+ let keys = keyBind?.split("+") || []
18
+ for (let i = 0; i < keys.length; i++) {
19
+ if (
20
+ keys[i].toLowerCase() === "ctrl" &&
21
+ navigator.platform.startsWith("Mac")
22
+ ) {
23
+ keys[i] = "⌘"
24
+ }
25
+ }
26
+ return keys
27
+ }
11
28
 
12
29
  const onClick = () => {
13
30
  if (actionMenu && !noClose) {
@@ -26,20 +43,54 @@
26
43
  tabindex="0"
27
44
  >
28
45
  {#if icon}
29
- <svg
30
- class="spectrum-Icon spectrum-Icon--sizeS spectrum-Menu-itemIcon"
31
- focusable="false"
32
- aria-hidden="true"
33
- aria-label={icon}
34
- >
35
- <use xlink:href="#spectrum-icon-18-{icon}" />
36
- </svg>
46
+ <div class="icon">
47
+ <Icon name={icon} size="S" />
48
+ </div>
37
49
  {/if}
38
50
  <span class="spectrum-Menu-itemLabel"><slot /></span>
51
+ {#if keys?.length}
52
+ <div class="keys">
53
+ {#each keys as key}
54
+ <div class="key">
55
+ {#if key.startsWith("!")}
56
+ <Icon size="XS" name={key.split("!")[1]} />
57
+ {:else}
58
+ {key}
59
+ {/if}
60
+ </div>
61
+ {/each}
62
+ </div>
63
+ {/if}
39
64
  </li>
40
65
 
41
66
  <style>
42
- .spectrum-Menu-itemIcon {
67
+ .icon {
43
68
  align-self: center;
69
+ margin-right: var(--spacing-s);
70
+ }
71
+ .keys {
72
+ margin-left: 30px;
73
+ display: flex;
74
+ flex-direction: row;
75
+ justify-content: flex-end;
76
+ align-items: center;
77
+ gap: 4px;
78
+ }
79
+ .key {
80
+ color: var(--spectrum-global-color-gray-900);
81
+ padding: 2px 4px;
82
+ font-size: 12px;
83
+ font-weight: 600;
84
+ background-color: var(--spectrum-global-color-gray-300);
85
+ border-radius: 4px;
86
+ min-width: 12px;
87
+ height: 16px;
88
+ text-align: center;
89
+ margin: -1px 0;
90
+ display: grid;
91
+ place-items: center;
92
+ }
93
+ .is-disabled .key {
94
+ color: var(--spectrum-global-color-gray-600);
44
95
  }
45
96
  </style>
@@ -11,6 +11,8 @@
11
11
 
12
12
  const dispatch = createEventDispatcher()
13
13
  let visible = fixed || inline
14
+ let modal
15
+
14
16
  $: dispatch(visible ? "show" : "hide")
15
17
 
16
18
  export function show() {
@@ -41,12 +43,22 @@
41
43
  }
42
44
  }
43
45
 
44
- async function focusFirstInput(node) {
46
+ async function focusModal(node) {
47
+ await tick()
48
+
49
+ // Try to focus first input
45
50
  const inputs = node.querySelectorAll("input")
46
51
  if (inputs?.length) {
47
- await tick()
48
52
  inputs[0].focus()
49
53
  }
54
+
55
+ // Otherwise try to focus confirmation button
56
+ else if (modal) {
57
+ const confirm = modal.querySelector(".confirm-wrap .spectrum-Button")
58
+ if (confirm) {
59
+ confirm.focus()
60
+ }
61
+ }
50
62
  }
51
63
 
52
64
  setContext(Context.Modal, { show, hide, cancel })
@@ -56,7 +68,7 @@
56
68
 
57
69
  {#if inline}
58
70
  {#if visible}
59
- <div use:focusFirstInput class="spectrum-Modal inline is-open">
71
+ <div use:focusModal bind:this={modal} class="spectrum-Modal inline is-open">
60
72
  <slot />
61
73
  </div>
62
74
  {/if}
@@ -70,17 +82,18 @@
70
82
  -->
71
83
  <Portal target=".modal-container">
72
84
  {#if visible}
73
- <div
74
- class="spectrum-Underlay is-open"
75
- in:fade={{ duration: 200 }}
76
- out:fade|local={{ duration: 200 }}
77
- on:mousedown|self={cancel}
78
- >
85
+ <div class="spectrum-Underlay is-open" on:mousedown|self={cancel}>
86
+ <div
87
+ class="background"
88
+ in:fade={{ duration: 200 }}
89
+ out:fade|local={{ duration: 200 }}
90
+ />
79
91
  <div class="modal-wrapper" on:mousedown|self={cancel}>
80
92
  <div class="modal-inner-wrapper" on:mousedown|self={cancel}>
81
93
  <slot name="outside" />
82
94
  <div
83
- use:focusFirstInput
95
+ use:focusModal
96
+ bind:this={modal}
84
97
  class="spectrum-Modal is-open"
85
98
  in:fly={{ y: 30, duration: 200 }}
86
99
  out:fly|local={{ y: 30, duration: 200 }}
@@ -103,7 +116,17 @@
103
116
  z-index: 999;
104
117
  overflow: auto;
105
118
  overflow-x: hidden;
106
- background: rgba(0, 0, 0, 0.75);
119
+ background: transparent;
120
+ }
121
+ .background {
122
+ background: var(--modal-background, rgba(0, 0, 0, 0.75));
123
+ position: fixed;
124
+ top: 0;
125
+ left: 0;
126
+ height: 100vh;
127
+ width: 100vw;
128
+ opacity: 0.65;
129
+ pointer-events: none;
107
130
  }
108
131
 
109
132
  .modal-wrapper {