@budibase/bbui 3.39.26 → 3.39.28

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/dist/bbui.mjs CHANGED
@@ -47163,8 +47163,19 @@ function Calendar(l, u) {
47163
47163
  max: 9999,
47164
47164
  pad: 0,
47165
47165
  fallback: E.year()
47166
- });
47167
- legacy_pre_effect(() => deep_read_state(v()), () => {
47166
+ }), z = 40, B = !1, V, H = 0, U = 0, W = (l) => {
47167
+ set(D, l ? get$2(D).add(1, "month") : get$2(D).subtract(1, "month"));
47168
+ }, K = (l) => {
47169
+ if (B) return;
47170
+ let u = l.deltaY || l.deltaX;
47171
+ u && (B = !0, V = setTimeout(() => B = !1, 120), W(u > 0));
47172
+ }, q = (l) => {
47173
+ H = l.changedTouches[0].clientX, U = l.changedTouches[0].clientY;
47174
+ }, J = (l) => {
47175
+ let u = l.changedTouches[0].clientX - H, f = l.changedTouches[0].clientY - U;
47176
+ Math.abs(u) > 40 && Math.abs(u) > Math.abs(f) && W(u < 0);
47177
+ };
47178
+ onDestroy(() => clearTimeout(V)), legacy_pre_effect(() => deep_read_state(v()), () => {
47168
47179
  set(D, (0, import_dayjs_min.default)(v() || (0, import_dayjs_min.default)()).startOf("month"));
47169
47180
  }), legacy_pre_effect(() => deep_read_state(y()), () => {
47170
47181
  set(f, k(y()));
@@ -47176,12 +47187,12 @@ function Calendar(l, u) {
47176
47187
  value: u
47177
47188
  })));
47178
47189
  }), legacy_pre_effect_reset();
47179
- var z = { setDate: L };
47190
+ var Y = { setDate: L };
47180
47191
  init$1();
47181
- var B = root$73(), V = child(B), H = child(V), U = child(H), W = child(U);
47192
+ var X = root$73(), Z = child(X), Q = child(Z), ee = child(Q), ne = child(ee);
47182
47193
  {
47183
47194
  let l = /* @__PURE__ */ derived_safe_equal(() => (deep_read_state(b()), untrack(() => b()?.datePickerPlaceholder))), u = /* @__PURE__ */ derived_safe_equal(() => (get$2(D), untrack(() => get$2(D).month())));
47184
- Select_1(W, {
47195
+ Select_1(ne, {
47185
47196
  autoWidth: !0,
47186
47197
  get placeholder() {
47187
47198
  return get$2(l);
@@ -47195,11 +47206,11 @@ function Calendar(l, u) {
47195
47206
  $$events: { change: (l) => set(D, get$2(D).month(l.detail)) }
47196
47207
  });
47197
47208
  }
47198
- reset(U);
47199
- var K = sibling(U, 2);
47209
+ reset(ee);
47210
+ var $ = sibling(ee, 2);
47200
47211
  {
47201
47212
  let l = /* @__PURE__ */ derived_safe_equal(() => (get$2(D), untrack(() => get$2(D).year())));
47202
- NumberInput(K, {
47213
+ NumberInput($, {
47203
47214
  get value() {
47204
47215
  return get$2(l);
47205
47216
  },
@@ -47212,28 +47223,28 @@ function Calendar(l, u) {
47212
47223
  }
47213
47224
  });
47214
47225
  }
47215
- reset(H);
47216
- var q = sibling(H, 2);
47217
- Icon(child(q), {
47226
+ reset(Q);
47227
+ var re = sibling(Q, 2);
47228
+ Icon(child(re), {
47218
47229
  name: "caret-left",
47219
47230
  weight: "bold",
47220
47231
  size: "S"
47221
- }), reset(q);
47222
- var J = sibling(q, 2);
47223
- Icon(child(J), {
47232
+ }), reset(re);
47233
+ var ie = sibling(re, 2);
47234
+ Icon(child(ie), {
47224
47235
  name: "caret-right",
47225
47236
  weight: "bold",
47226
47237
  size: "S"
47227
- }), reset(J), reset(V);
47228
- var Y = sibling(V, 2), X = child(Y), Z = child(X), Q = child(Z);
47229
- each$1(Q, 5, () => get$2(f), index, (l, u) => {
47238
+ }), reset(ie), reset(Z);
47239
+ var ae = sibling(Z, 2), oe = child(ae), ce = child(oe), le = child(ce);
47240
+ each$1(le, 5, () => get$2(f), index, (l, u) => {
47230
47241
  var f = root_1$38(), p = child(f), m = child(p, !0);
47231
47242
  reset(p), reset(f), template_effect((l, u) => {
47232
47243
  set_attribute(p, "title", l), set_text(m, u);
47233
47244
  }, [() => (get$2(u), untrack(() => j(get$2(u)))), () => (get$2(u), untrack(() => j(get$2(u))[0]))]), append$1(l, f);
47234
- }), reset(Q), reset(Z);
47235
- var ee = sibling(Z);
47236
- return each$1(ee, 5, () => get$2(p), index, (l, u) => {
47245
+ }), reset(le), reset(ce);
47246
+ var ue = sibling(ce);
47247
+ return each$1(ue, 5, () => get$2(p), index, (l, u) => {
47237
47248
  var f = root_2$24();
47238
47249
  each$1(f, 4, () => [
47239
47250
  0,
@@ -47260,7 +47271,7 @@ function Calendar(l, u) {
47260
47271
  () => (deep_read_state(get$2(p)), untrack(() => get$2(p).date()))
47261
47272
  ]), event("click", y, () => F(get$2(p))), append$1(l, y);
47262
47273
  }), reset(f), append$1(l, f);
47263
- }), reset(ee), reset(X), reset(Y), reset(B), event("click", q, () => set(D, get$2(D).subtract(1, "month"))), event("click", J, () => set(D, get$2(D).add(1, "month"))), append$1(l, B), bind_prop(u, "setDate", L), pop(z);
47274
+ }), reset(ue), reset(oe), reset(ae), reset(X), event("click", re, () => set(D, get$2(D).subtract(1, "month"))), event("click", ie, () => set(D, get$2(D).add(1, "month"))), event("wheel", ae, preventDefault(K)), event("touchstart", ae, q), event("touchend", ae, J), append$1(l, X), bind_prop(u, "setDate", L), pop(Y);
47264
47275
  }
47265
47276
  //#endregion
47266
47277
  //#region src/Tooltip/Tooltip.svelte
@@ -49933,7 +49944,7 @@ function CollapsibleSearch(l, u) {
49933
49944
  var root_3$13 = /* @__PURE__ */ from_html("<span class=\"subtitle-text svelte-1jm7byl\"> </span>"), root_2$15 = /* @__PURE__ */ from_html("<li role=\"option\" aria-selected=\"true\" tabindex=\"0\"><span class=\"spectrum-Menu-itemLabel\"> <!></span> <div class=\"check svelte-1jm7byl\"><!></div></li>"), root_1$28 = /* @__PURE__ */ from_html("<div class=\"spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open svelte-1jm7byl\"><ul class=\"spectrum-Menu\" role=\"listbox\"></ul></div>"), root$50 = /* @__PURE__ */ from_html("<div><div><input class=\"spectrum-Textfield-input spectrum-InputGroup-input svelte-1jm7byl\"/></div> <div style=\"width: 40%\"><button aria-haspopup=\"listbox\"><span class=\"spectrum-Picker-label\"><div> </div></span> <!></button></div> <!></div>");
49934
49945
  function InputDropdown(l, u) {
49935
49946
  push$1(u, !1);
49936
- let f = /* @__PURE__ */ mutable_source(), p = prop(u, "inputValue", 8), m = prop(u, "dropdownValue", 8), v = prop(u, "id", 8, null), y = prop(u, "inputType", 8, "text"), b = prop(u, "placeholder", 8, "Choose an option or type"), x = prop(u, "disabled", 8, !1), S = prop(u, "readonly", 8, !1), w = prop(u, "updateOnChange", 8, !0), T = prop(u, "options", 24, () => []), E = prop(u, "getOptionLabel", 8, (l) => U(l, "label")), D = prop(u, "getOptionValue", 8, (l) => U(l, "value")), O = prop(u, "getOptionSubtitle", 8, (l) => l?.subtitle), k = prop(u, "isOptionSelected", 8, () => !1), j = createEventDispatcher(), M = /* @__PURE__ */ mutable_source(!1), N = /* @__PURE__ */ mutable_source(!1), P = (l, u, f) => {
49947
+ let f = /* @__PURE__ */ mutable_source(), p = prop(u, "inputValue", 8), m = prop(u, "dropdownValue", 8), v = prop(u, "id", 8, null), y = prop(u, "inputType", 8, "text"), b = prop(u, "placeholder", 8, "Choose an option or type"), x = prop(u, "disabled", 8, !1), S = prop(u, "readonly", 8, !1), w = prop(u, "updateOnChange", 8, !0), T = prop(u, "options", 24, () => []), E = prop(u, "getOptionLabel", 8, (l) => U(l, "label")), D = prop(u, "getOptionValue", 8, (l) => U(l, "value")), O = prop(u, "getOptionSubtitle", 8, (l) => l?.subtitle), k = prop(u, "isOptionSelected", 8, (l) => !1), j = createEventDispatcher(), M = /* @__PURE__ */ mutable_source(!1), N = /* @__PURE__ */ mutable_source(!1), P = (l, u, f) => {
49937
49948
  if (l == null || l === "") return f || "Choose an option or type";
49938
49949
  if (!u?.length) return "";
49939
49950
  let p = u.find((u) => D()(u) === l);
@@ -50024,14 +50035,14 @@ function InputDropdown(l, u) {
50024
50035
  //#region src/Form/InputDropdown.svelte
50025
50036
  function InputDropdown_1(l, u) {
50026
50037
  push$1(u, !1);
50027
- let f = prop(u, "inputValue", 12, null), p = prop(u, "dropdownValue", 12, null), m = prop(u, "inputType", 8, "text"), v = prop(u, "label", 8, null), y = prop(u, "labelPosition", 8, "above"), b = prop(u, "placeholder", 8, null), x = prop(u, "disabled", 8, !1), S = prop(u, "readonly", 8, !1), w = prop(u, "error", 8, null), T = prop(u, "updateOnChange", 8, !0), E = prop(u, "quiet", 8, !1), D = prop(u, "autofocus", 8), O = prop(u, "helpText", 8, null), k = prop(u, "options", 24, () => []), j = createEventDispatcher(), M = (l) => {
50028
- p(l.detail), j("pick", l.detail);
50029
- }, N = (l) => {
50030
- f(l.detail), j("change", l.detail);
50038
+ let f = prop(u, "inputValue", 12, null), p = prop(u, "dropdownValue", 12, null), m = prop(u, "inputType", 8, "text"), v = prop(u, "label", 24, () => void 0), y = prop(u, "labelPosition", 8, "above"), b = prop(u, "placeholder", 24, () => void 0), x = prop(u, "disabled", 8, !1), S = prop(u, "readonly", 8, !1), w = prop(u, "error", 24, () => void 0), T = prop(u, "updateOnChange", 8, !0), E = prop(u, "helpText", 24, () => void 0), D = prop(u, "options", 24, () => []), O = createEventDispatcher(), k = (l) => {
50039
+ p(l.detail), O("pick", l.detail);
50040
+ }, j = (l) => {
50041
+ f(l.detail), O("change", l.detail);
50031
50042
  };
50032
50043
  init$1(), Field(l, {
50033
50044
  get helpText() {
50034
- return O();
50045
+ return E();
50035
50046
  },
50036
50047
  get label() {
50037
50048
  return v();
@@ -50047,9 +50058,6 @@ function InputDropdown_1(l, u) {
50047
50058
  get updateOnChange() {
50048
50059
  return T();
50049
50060
  },
50050
- get error() {
50051
- return w();
50052
- },
50053
50061
  get disabled() {
50054
50062
  return x();
50055
50063
  },
@@ -50068,19 +50076,13 @@ function InputDropdown_1(l, u) {
50068
50076
  get inputType() {
50069
50077
  return m();
50070
50078
  },
50071
- get quiet() {
50072
- return E();
50073
- },
50074
- get autofocus() {
50075
- return D();
50076
- },
50077
50079
  get options() {
50078
- return k();
50080
+ return D();
50079
50081
  },
50080
50082
  isOptionSelected: (l) => l === p(),
50081
50083
  $$events: {
50082
- change: N,
50083
- pick: M,
50084
+ change: j,
50085
+ pick: k,
50084
50086
  click(l) {
50085
50087
  bubble_event.call(this, u, l);
50086
50088
  },
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": "3.39.26",
4
+ "version": "3.39.28",
5
5
  "license": "MPL-2.0",
6
6
  "module": "dist/bbui.mjs",
7
7
  "exports": {
@@ -105,5 +105,5 @@
105
105
  }
106
106
  }
107
107
  },
108
- "gitHead": "6d7fa46d35e6d68da050e76f4c1662adaf25a182"
108
+ "gitHead": "1ad76cd4e4a5dc308900e2a7db331e20a013f65c"
109
109
  }
@@ -3,7 +3,7 @@
3
3
  import Select from "../../Select.svelte"
4
4
  import dayjs from "dayjs"
5
5
  import NumberInput from "./NumberInput.svelte"
6
- import { createEventDispatcher } from "svelte"
6
+ import { createEventDispatcher, onDestroy } from "svelte"
7
7
  import Icon from "../../../Icon/Icon.svelte"
8
8
  import { resolveTranslationGroup } from "@budibase/shared-core"
9
9
 
@@ -116,6 +116,51 @@
116
116
  }
117
117
 
118
118
  const cleanYear = cleanInput({ max: 9999, pad: 0, fallback: now.year() })
119
+
120
+ // Scroll (desktop) or horizontal swipe (touch) over the calendar to move
121
+ // between months.
122
+ const SWIPE_THRESHOLD = 40
123
+ let wheelLock = false
124
+ let wheelTimer
125
+ let touchStartX = 0
126
+ let touchStartY = 0
127
+
128
+ const changeMonth = forward => {
129
+ calendarDate = forward
130
+ ? calendarDate.add(1, "month")
131
+ : calendarDate.subtract(1, "month")
132
+ }
133
+
134
+ // A short lock keeps a single trackpad gesture from skipping many months
135
+ const handleWheel = e => {
136
+ if (wheelLock) {
137
+ return
138
+ }
139
+ const delta = e.deltaY || e.deltaX
140
+ if (!delta) {
141
+ return
142
+ }
143
+ wheelLock = true
144
+ wheelTimer = setTimeout(() => (wheelLock = false), 120)
145
+ changeMonth(delta > 0)
146
+ }
147
+
148
+ const handleTouchStart = e => {
149
+ touchStartX = e.changedTouches[0].clientX
150
+ touchStartY = e.changedTouches[0].clientY
151
+ }
152
+
153
+ // Only a clear horizontal swipe changes month - vertical stays a normal
154
+ // scroll and small movements remain taps so date selection keeps working
155
+ const handleTouchEnd = e => {
156
+ const dx = e.changedTouches[0].clientX - touchStartX
157
+ const dy = e.changedTouches[0].clientY - touchStartY
158
+ if (Math.abs(dx) > SWIPE_THRESHOLD && Math.abs(dx) > Math.abs(dy)) {
159
+ changeMonth(dx < 0)
160
+ }
161
+ }
162
+
163
+ onDestroy(() => clearTimeout(wheelTimer))
119
164
  </script>
120
165
 
121
166
  <div class="spectrum-Calendar">
@@ -160,10 +205,14 @@
160
205
  <Icon name="caret-right" weight="bold" size="S" />
161
206
  </button>
162
207
  </div>
208
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
163
209
  <div
164
210
  class="spectrum-Calendar-body"
165
211
  aria-readonly="true"
166
212
  aria-disabled="false"
213
+ on:wheel|preventDefault={handleWheel}
214
+ on:touchstart={handleTouchStart}
215
+ on:touchend={handleTouchEnd}
167
216
  >
168
217
  <table role="presentation" class="spectrum-Calendar-table">
169
218
  <thead role="presentation">
@@ -19,7 +19,7 @@
19
19
  export let getOptionLabel = option => extractProperty(option, "label")
20
20
  export let getOptionValue = option => extractProperty(option, "value")
21
21
  export let getOptionSubtitle = option => option?.subtitle
22
- export let isOptionSelected = () => false
22
+ export let isOptionSelected = _option => false
23
23
 
24
24
  const dispatch = createEventDispatcher()
25
25
  let open = false
@@ -1,30 +1,38 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Field from "./Field.svelte"
3
3
  import InputDropdown from "./Core/InputDropdown.svelte"
4
4
  import { createEventDispatcher } from "svelte"
5
+ import type { LabelPosition } from "../types"
5
6
 
6
- export let inputValue = null
7
- export let dropdownValue = null
7
+ interface Option {
8
+ label?: string
9
+ value?: string
10
+ subtitle?: string
11
+ }
12
+
13
+ export let inputValue: string | null = null
14
+ export let dropdownValue: string | null = null
8
15
  export let inputType = "text"
9
- export let label = null
10
- export let labelPosition = "above"
11
- export let placeholder = null
16
+ export let label: string | undefined = undefined
17
+ export let labelPosition: LabelPosition = "above"
18
+ export let placeholder: string | undefined = undefined
12
19
  export let disabled = false
13
20
  export let readonly = false
14
- export let error = null
21
+ export let error: string | undefined = undefined
15
22
  export let updateOnChange = true
16
- export let quiet = false
17
- export let autofocus
18
- export let helpText = null
19
- export let options = []
23
+ export let helpText: string | undefined = undefined
24
+ export let options: Option[] = []
20
25
 
21
- const dispatch = createEventDispatcher()
26
+ const dispatch = createEventDispatcher<{
27
+ pick: string | null
28
+ change: string
29
+ }>()
22
30
 
23
- const onPick = e => {
31
+ const onPick = (e: CustomEvent<string | null>) => {
24
32
  dropdownValue = e.detail
25
33
  dispatch("pick", e.detail)
26
34
  }
27
- const onChange = e => {
35
+ const onChange = (e: CustomEvent<string>) => {
28
36
  inputValue = e.detail
29
37
  dispatch("change", e.detail)
30
38
  }
@@ -33,15 +41,12 @@
33
41
  <Field {helpText} {label} {labelPosition} {error}>
34
42
  <InputDropdown
35
43
  {updateOnChange}
36
- {error}
37
44
  {disabled}
38
45
  {readonly}
39
46
  {inputValue}
40
47
  {dropdownValue}
41
48
  {placeholder}
42
49
  {inputType}
43
- {quiet}
44
- {autofocus}
45
50
  {options}
46
51
  isOptionSelected={option => option === dropdownValue}
47
52
  on:change={onChange}