@budibase/bbui 2.8.29-alpha.5 → 2.8.29-alpha.7

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.8.29-alpha.5",
4
+ "version": "2.8.29-alpha.7",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,8 +38,8 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/shared-core": "2.8.29-alpha.5",
42
- "@budibase/string-templates": "2.8.29-alpha.5",
41
+ "@budibase/shared-core": "2.8.29-alpha.7",
42
+ "@budibase/string-templates": "2.8.29-alpha.7",
43
43
  "@spectrum-css/accordion": "3.0.24",
44
44
  "@spectrum-css/actionbutton": "1.0.1",
45
45
  "@spectrum-css/actiongroup": "1.0.1",
@@ -84,6 +84,7 @@
84
84
  "@spectrum-css/vars": "3.0.1",
85
85
  "dayjs": "^1.10.4",
86
86
  "easymde": "^2.16.1",
87
+ "svelte-dnd-action": "^0.9.8",
87
88
  "svelte-flatpickr": "3.2.3",
88
89
  "svelte-portal": "^1.0.0"
89
90
  },
@@ -105,5 +106,5 @@
105
106
  }
106
107
  }
107
108
  },
108
- "gitHead": "51a46a236606dfc158218904951ff776994d9e5b"
109
+ "gitHead": "97abef1bfaf70097b5dbcaae302a27b9de11da97"
109
110
  }
@@ -1,5 +1,4 @@
1
1
  <script>
2
- //import { createEventDispatcher } from "svelte"
3
2
  import "@spectrum-css/popover/dist/index-vars.css"
4
3
  import clickOutside from "../Actions/click_outside"
5
4
  import { fly } from "svelte/transition"
@@ -0,0 +1,252 @@
1
+ <script>
2
+ import { flip } from "svelte/animate"
3
+ import { dndzone } from "svelte-dnd-action"
4
+ import Icon from "../Icon/Icon.svelte"
5
+ import Popover from "../Popover/Popover.svelte"
6
+ import { onMount } from "svelte"
7
+ const flipDurationMs = 150
8
+
9
+ export let constraints
10
+ export let optionColors = {}
11
+ let options = []
12
+
13
+ let colorPopovers = []
14
+ let anchors = []
15
+
16
+ let colorsArray = [
17
+ "hsla(0, 90%, 75%, 0.3)",
18
+ "hsla(50, 80%, 75%, 0.3)",
19
+ "hsla(120, 90%, 75%, 0.3)",
20
+ "hsla(200, 90%, 75%, 0.3)",
21
+ "hsla(240, 90%, 75%, 0.3)",
22
+ "hsla(320, 90%, 75%, 0.3)",
23
+ ]
24
+ $: {
25
+ if (constraints.inclusion.length) {
26
+ options = constraints.inclusion.map(value => ({
27
+ name: value,
28
+ id: Math.random(),
29
+ }))
30
+ }
31
+ }
32
+ const removeInput = idx => {
33
+ delete optionColors[options[idx].name]
34
+ constraints.inclusion = constraints.inclusion.filter((e, i) => i !== idx)
35
+ options = options.filter((e, i) => i !== idx)
36
+ colorPopovers.pop(undefined)
37
+ anchors.pop(undefined)
38
+ }
39
+
40
+ const addNewInput = () => {
41
+ options = [
42
+ ...options,
43
+ { name: `Option ${constraints.inclusion.length + 1}`, id: Math.random() },
44
+ ]
45
+ constraints.inclusion = [
46
+ ...constraints.inclusion,
47
+ `Option ${constraints.inclusion.length + 1}`,
48
+ ]
49
+
50
+ colorPopovers.push(undefined)
51
+ anchors.push(undefined)
52
+ }
53
+
54
+ const handleDndConsider = e => {
55
+ options = e.detail.items
56
+ }
57
+ const handleDndFinalize = e => {
58
+ options = e.detail.items
59
+ constraints.inclusion = options.map(option => option.name)
60
+ }
61
+
62
+ const handleColorChange = (optionName, color, idx) => {
63
+ optionColors[optionName] = color
64
+ colorPopovers[idx].hide()
65
+ }
66
+
67
+ const handleNameChange = (optionName, idx, value) => {
68
+ constraints.inclusion[idx] = value
69
+ options[idx].name = value
70
+ optionColors[value] = optionColors[optionName]
71
+ delete optionColors[optionName]
72
+ }
73
+
74
+ const openColorPickerPopover = (optionIdx, target) => {
75
+ colorPopovers[optionIdx].show()
76
+ anchors[optionIdx] = target
77
+ }
78
+
79
+ onMount(() => {
80
+ // Initialize anchor arrays on mount, assuming 'options' is already populated
81
+ colorPopovers = constraints.inclusion.map(() => undefined)
82
+ anchors = constraints.inclusion.map(() => undefined)
83
+ })
84
+ </script>
85
+
86
+ <div>
87
+ <div
88
+ class="actions"
89
+ use:dndzone={{
90
+ items: options,
91
+ flipDurationMs,
92
+ dropTargetStyle: { outline: "none" },
93
+ }}
94
+ on:consider={handleDndConsider}
95
+ on:finalize={handleDndFinalize}
96
+ >
97
+ {#each options as option, idx (option.id)}
98
+ <div
99
+ class="no-border action-container"
100
+ animate:flip={{ duration: flipDurationMs }}
101
+ >
102
+ <div class="child drag-handle-spacing">
103
+ <Icon name="DragHandle" size="L" />
104
+ </div>
105
+ <div class="child color-picker">
106
+ <div
107
+ id="color-picker"
108
+ bind:this={anchors[idx]}
109
+ style="--color:{optionColors?.[option.name] ||
110
+ 'hsla(0, 1%, 50%, 0.3)'}"
111
+ class="circle"
112
+ on:click={e => openColorPickerPopover(idx, e.target)}
113
+ >
114
+ <Popover
115
+ bind:this={colorPopovers[idx]}
116
+ anchor={anchors[idx]}
117
+ align="left"
118
+ offset={0}
119
+ style=""
120
+ popoverTarget={document.getElementById(`color-picker`)}
121
+ animate={false}
122
+ >
123
+ <div class="colors">
124
+ {#each colorsArray as color}
125
+ <div
126
+ on:click={() => handleColorChange(option.name, color, idx)}
127
+ style="--color:{color};"
128
+ class="circle circle-hover"
129
+ />
130
+ {/each}
131
+ </div>
132
+ </Popover>
133
+ </div>
134
+ </div>
135
+ <div class="child">
136
+ <input
137
+ class="input-field"
138
+ type="text"
139
+ on:change={e => handleNameChange(option.name, idx, e.target.value)}
140
+ value={option.name}
141
+ placeholder="Option name"
142
+ />
143
+ </div>
144
+ <div class="child">
145
+ <Icon name="Close" hoverable size="S" on:click={removeInput(idx)} />
146
+ </div>
147
+ </div>
148
+ {/each}
149
+ </div>
150
+ <div on:click={addNewInput} class="add-option">
151
+ <Icon hoverable name="Add" />
152
+ <div>Add option</div>
153
+ </div>
154
+ </div>
155
+
156
+ <style>
157
+ .action-container {
158
+ background-color: var(--spectrum-alias-background-color-primary);
159
+ border-radius: 0px;
160
+ border: 1px solid var(--spectrum-global-color-gray-300);
161
+ transition: background-color 130ms ease-in-out, color 130ms ease-in-out,
162
+ border-color 130ms ease-in-out;
163
+ display: flex;
164
+ flex-direction: row;
165
+ align-items: center;
166
+ }
167
+ .no-border {
168
+ border-bottom: none;
169
+ }
170
+
171
+ .action-container:last-child {
172
+ border-bottom: 1px solid var(--spectrum-global-color-gray-300) !important;
173
+ }
174
+
175
+ .child {
176
+ height: 30px;
177
+ }
178
+ .child:hover,
179
+ .child:focus {
180
+ background: var(--spectrum-global-color-gray-200);
181
+ }
182
+ .add-option {
183
+ display: flex;
184
+ flex-direction: row;
185
+ align-items: center;
186
+ padding: var(--spacing-m);
187
+ gap: var(--spacing-m);
188
+ cursor: pointer;
189
+ }
190
+
191
+ .input-field {
192
+ border: none;
193
+ outline: none;
194
+ background-color: transparent;
195
+ width: 100%;
196
+ color: var(--text);
197
+ }
198
+
199
+ .child input[type="text"] {
200
+ padding-left: 10px;
201
+ }
202
+
203
+ .input-field:hover,
204
+ .input-field:focus {
205
+ background: var(--spectrum-global-color-gray-200);
206
+ }
207
+
208
+ .action-container > :nth-child(1) {
209
+ flex-grow: 1;
210
+ justify-content: center;
211
+ display: flex;
212
+ }
213
+
214
+ .action-container > :nth-child(2) {
215
+ flex-grow: 1;
216
+ display: flex;
217
+ justify-content: center;
218
+ align-items: center;
219
+ }
220
+
221
+ .action-container > :nth-child(3) {
222
+ flex-grow: 4;
223
+ display: flex;
224
+ }
225
+ .action-container > :nth-child(4) {
226
+ flex-grow: 1;
227
+ justify-content: center;
228
+ display: flex;
229
+ }
230
+
231
+ .circle {
232
+ height: 20px;
233
+ width: 20px;
234
+ background-color: var(--color);
235
+ border-radius: 50%;
236
+ display: inline-block;
237
+ box-sizing: border-box;
238
+ }
239
+
240
+ .circle-hover:hover {
241
+ border: 1px solid var(--spectrum-global-color-blue-400);
242
+ cursor: pointer;
243
+ }
244
+
245
+ .colors {
246
+ display: grid;
247
+ grid-template-columns: 1fr 1fr 1fr;
248
+ gap: var(--spacing-xl);
249
+ justify-items: center;
250
+ margin: var(--spacing-m);
251
+ }
252
+ </style>
@@ -21,6 +21,7 @@
21
21
  export let offset = 5
22
22
  export let customHeight
23
23
  export let animate = true
24
+ export let customZindex
24
25
 
25
26
  $: target = portalTarget || getContext(Context.PopoverRoot) || ".spectrum"
26
27
 
@@ -77,8 +78,9 @@
77
78
  }}
78
79
  on:keydown={handleEscape}
79
80
  class="spectrum-Popover is-open"
81
+ class:customZindex
80
82
  role="presentation"
81
- style="height: {customHeight}"
83
+ style="height: {customHeight}; --customZindex: {customZindex};"
82
84
  transition:fly|local={{ y: -20, duration: animate ? 200 : 0 }}
83
85
  >
84
86
  <slot />
@@ -92,4 +94,8 @@
92
94
  border-color: var(--spectrum-global-color-gray-300);
93
95
  overflow: auto;
94
96
  }
97
+
98
+ .customZindex {
99
+ z-index: var(--customZindex) !important;
100
+ }
95
101
  </style>
package/src/index.js CHANGED
@@ -84,7 +84,7 @@ export { default as IconSideNavItem } from "./IconSideNav/IconSideNavItem.svelte
84
84
  export { default as Slider } from "./Form/Slider.svelte"
85
85
  export { default as Accordion } from "./Accordion/Accordion.svelte"
86
86
  export { default as File } from "./Form/File.svelte"
87
-
87
+ export { default as OptionSelectDnD } from "./OptionSelectDnD/OptionSelectDnD.svelte"
88
88
  // Renderers
89
89
  export { default as BoldRenderer } from "./Table/BoldRenderer.svelte"
90
90
  export { default as CodeRenderer } from "./Table/CodeRenderer.svelte"