Merge remote-tracking branch 'origin/master' into feature/filter-bindings

This commit is contained in:
Dean 2024-05-02 09:24:14 +01:00
commit 2997da8687
19 changed files with 63 additions and 70 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "2.23.12", "version": "2.24.0",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*", "packages/*",

View File

@ -83,7 +83,6 @@
"dayjs": "^1.10.8", "dayjs": "^1.10.8",
"easymde": "^2.16.1", "easymde": "^2.16.1",
"svelte-dnd-action": "^0.9.8", "svelte-dnd-action": "^0.9.8",
"svelte-flatpickr": "3.2.3",
"svelte-portal": "^1.0.0" "svelte-portal": "^1.0.0"
}, },
"resolutions": { "resolutions": {

View File

@ -1,6 +1,5 @@
const ignoredClasses = [ const ignoredClasses = [
".download-js-link", ".download-js-link",
".flatpickr-calendar",
".spectrum-Menu", ".spectrum-Menu",
".date-time-popover", ".date-time-popover",
] ]

View File

@ -7,11 +7,11 @@
export let narrower = false export let narrower = false
export let noPadding = false export let noPadding = false
let sidePanelVisble = false let sidePanelVisible = false
setContext("side-panel", { setContext("side-panel", {
open: () => (sidePanelVisble = true), open: () => (sidePanelVisible = true),
close: () => (sidePanelVisble = false), close: () => (sidePanelVisible = false),
}) })
</script> </script>
@ -24,9 +24,9 @@
</div> </div>
<div <div
id="side-panel" id="side-panel"
class:visible={sidePanelVisble} class:visible={sidePanelVisible}
use:clickOutside={() => { use:clickOutside={() => {
sidePanelVisble = false sidePanelVisible = false
}} }}
> >
<slot name="side-panel" /> <slot name="side-panel" />

View File

@ -154,7 +154,7 @@ export const parseDate = (value, { enableTime = true }) => {
// schema flags // schema flags
export const stringifyDate = ( export const stringifyDate = (
value, value,
{ enableTime = true, timeOnly = false, ignoreTimezones = false } { enableTime = true, timeOnly = false, ignoreTimezones = false } = {}
) => { ) => {
if (!value) { if (!value) {
return null return null
@ -210,7 +210,7 @@ const localeDateFormat = new Intl.DateTimeFormat()
// Formats a dayjs date according to schema flags // Formats a dayjs date according to schema flags
export const getDateDisplayValue = ( export const getDateDisplayValue = (
value, value,
{ enableTime = true, timeOnly = false } { enableTime = true, timeOnly = false } = {}
) => { ) => {
if (!value?.isValid()) { if (!value?.isValid()) {
return "" return ""

View File

@ -6717,7 +6717,20 @@
"illegalChildren": ["section", "sidepanel"], "illegalChildren": ["section", "sidepanel"],
"showEmptyState": false, "showEmptyState": false,
"draggable": false, "draggable": false,
"info": "Side panels are hidden by default. They will only be revealed when triggered by the 'Open Side Panel' action." "info": "Side panels are hidden by default. They will only be revealed when triggered by the 'Open Side Panel' action.",
"settings": [
{
"type": "boolean",
"key": "ignoreClicksOutside",
"label": "Ignore clicks outside",
"defaultValue": false
},
{
"type": "event",
"key": "onClose",
"label": "On close"
}
]
}, },
"rowexplorer": { "rowexplorer": {
"block": true, "block": true,

View File

@ -34,7 +34,6 @@
"screenfull": "^6.0.1", "screenfull": "^6.0.1",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"svelte-apexcharts": "^1.0.2", "svelte-apexcharts": "^1.0.2",
"svelte-flatpickr": "^3.3.4",
"svelte-spa-router": "^4.0.1" "svelte-spa-router": "^4.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -206,13 +206,6 @@
/> />
{/key} {/key}
<!--
Flatpickr needs to be inside the theme wrapper.
It also needs its own container because otherwise it hijacks
key events on the whole page. It is painful to work with.
-->
<div id="flatpickr-root" />
<!-- Modal container to ensure they sit on top --> <!-- Modal container to ensure they sit on top -->
<div class="modal-container" /> <div class="modal-container" />

View File

@ -60,16 +60,6 @@
--spectrum-link-primary-m-text-color-hover: var(--primaryColorHover); --spectrum-link-primary-m-text-color-hover: var(--primaryColorHover);
} }
/* Theme flatpickr */
:global(.flatpickr-day.selected) {
background: var(--primaryColor);
border-color: var(--primaryColor);
}
:global(.flatpickr-day.selected:hover) {
background: var(--primaryColorHover);
border-color: var(--primaryColorHover);
}
/* Custom scrollbars */ /* Custom scrollbars */
:global(::-webkit-scrollbar) { :global(::-webkit-scrollbar) {
width: 8px; width: 8px;

View File

@ -73,7 +73,10 @@
$context.device.width, $context.device.width,
$context.device.height $context.device.height
) )
$: autoCloseSidePanel = !$builderStore.inBuilder && $sidePanelStore.open $: autoCloseSidePanel =
!$builderStore.inBuilder &&
$sidePanelStore.open &&
!$sidePanelStore.ignoreClicksOutside
$: screenId = $builderStore.inBuilder $: screenId = $builderStore.inBuilder
? `${$builderStore.screen?._id}-screen` ? `${$builderStore.screen?._id}-screen`
: "screen" : "screen"
@ -191,6 +194,11 @@
} }
return url return url
} }
const handleClickLink = () => {
mobileOpen = false
sidePanelStore.actions.close()
}
</script> </script>
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
@ -281,7 +289,7 @@
url={navItem.url} url={navItem.url}
subLinks={navItem.subLinks} subLinks={navItem.subLinks}
internalLink={navItem.internalLink} internalLink={navItem.internalLink}
on:clickLink={() => (mobileOpen = false)} on:clickLink={handleClickLink}
leftNav={navigation === "Left"} leftNav={navigation === "Left"}
{mobile} {mobile}
{navStateStore} {navStateStore}

View File

@ -5,6 +5,9 @@
const { styleable, sidePanelStore, builderStore, dndIsDragging } = const { styleable, sidePanelStore, builderStore, dndIsDragging } =
getContext("sdk") getContext("sdk")
export let onClose
export let ignoreClicksOutside
// Automatically show and hide the side panel when inside the builder. // Automatically show and hide the side panel when inside the builder.
// For some unknown reason, svelte reactivity breaks if we reference the // For some unknown reason, svelte reactivity breaks if we reference the
// reactive variable "open" inside the following expression, or if we define // reactive variable "open" inside the following expression, or if we define
@ -26,6 +29,10 @@
} }
} }
// $: {
// }
// Derive visibility // Derive visibility
$: open = $sidePanelStore.contentId === $component.id $: open = $sidePanelStore.contentId === $component.id
@ -36,10 +43,17 @@
let renderKey = null let renderKey = null
$: { $: {
if (open) { if (open) {
sidePanelStore.actions.setIgnoreClicksOutside(ignoreClicksOutside)
renderKey = Math.random() renderKey = Math.random()
} }
} }
const handleSidePanelClose = async () => {
if (onClose) {
await onClose()
}
}
const showInSidePanel = (el, visible) => { const showInSidePanel = (el, visible) => {
const update = visible => { const update = visible => {
const target = document.getElementById("side-panel-container") const target = document.getElementById("side-panel-container")
@ -51,6 +65,7 @@
} else { } else {
if (target.contains(node)) { if (target.contains(node)) {
target.removeChild(node) target.removeChild(node)
handleSidePanelClose()
} }
} }
} }

View File

@ -49,7 +49,6 @@
readonly={fieldState.readonly} readonly={fieldState.readonly}
error={fieldState.error} error={fieldState.error}
id={fieldState.fieldId} id={fieldState.fieldId}
appendTo={document.getElementById("flatpickr-root")}
{enableTime} {enableTime}
{timeOnly} {timeOnly}
{time24hr} {time24hr}

View File

@ -1,5 +1,6 @@
import flatpickr from "flatpickr" import dayjs from "dayjs"
import { FieldTypes } from "../../../constants" import { FieldTypes } from "../../../constants"
import { Helpers } from "@budibase/bbui"
/** /**
* Creates a validation function from a combination of schema-level constraints * Creates a validation function from a combination of schema-level constraints
@ -81,7 +82,7 @@ export const createValidatorFromConstraints = (
// Date constraint // Date constraint
if (exists(schemaConstraints.datetime?.earliest)) { if (exists(schemaConstraints.datetime?.earliest)) {
const limit = schemaConstraints.datetime.earliest const limit = schemaConstraints.datetime.earliest
const limitString = flatpickr.formatDate(new Date(limit), "F j Y, H:i") const limitString = Helpers.getDateDisplayValue(dayjs(limit))
rules.push({ rules.push({
type: "datetime", type: "datetime",
constraint: "minValue", constraint: "minValue",
@ -91,7 +92,7 @@ export const createValidatorFromConstraints = (
} }
if (exists(schemaConstraints.datetime?.latest)) { if (exists(schemaConstraints.datetime?.latest)) {
const limit = schemaConstraints.datetime.latest const limit = schemaConstraints.datetime.latest
const limitString = flatpickr.formatDate(new Date(limit), "F j Y, H:i") const limitString = Helpers.getDateDisplayValue(dayjs(limit))
rules.push({ rules.push({
type: "datetime", type: "datetime",
constraint: "maxValue", constraint: "maxValue",

View File

@ -3,6 +3,7 @@ import { writable, derived } from "svelte/store"
export const createSidePanelStore = () => { export const createSidePanelStore = () => {
const initialState = { const initialState = {
contentId: null, contentId: null,
ignoreClicksOutside: true,
} }
const store = writable(initialState) const store = writable(initialState)
const derivedStore = derived(store, $store => { const derivedStore = derived(store, $store => {
@ -32,11 +33,18 @@ export const createSidePanelStore = () => {
}, 50) }, 50)
} }
const setIgnoreClicksOutside = bool => {
store.update(state => {
state.ignoreClicksOutside = bool
return state
})
}
return { return {
subscribe: derivedStore.subscribe, subscribe: derivedStore.subscribe,
actions: { actions: {
open, open,
close, close,
setIgnoreClicksOutside,
}, },
} }
} }

View File

@ -240,6 +240,7 @@ const triggerAutomationHandler = async action => {
const navigationHandler = action => { const navigationHandler = action => {
const { url, peek, externalNewTab } = action.parameters const { url, peek, externalNewTab } = action.parameters
routeStore.actions.navigate(url, peek, externalNewTab) routeStore.actions.navigate(url, peek, externalNewTab)
closeSidePanelHandler()
} }
const queryExecutionHandler = async action => { const queryExecutionHandler = async action => {

View File

@ -128,6 +128,7 @@ export async function importToRows(
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
let row = data[i] let row = data[i]
row._id = generateRowID(table._id!) row._id = generateRowID(table._id!)
row.type = "row"
row.tableId = table._id row.tableId = table._id
// We use a reference to table here and update it after input processing, // We use a reference to table here and update it after input processing,

View File

@ -76,9 +76,7 @@ describe.each([
} }
async function createRows(rows: Record<string, any>[]) { async function createRows(rows: Record<string, any>[]) {
for (const row of rows) { await config.api.row.bulkImport(table._id!, { rows })
await config.api.row.save(table._id!, row)
}
} }
class SearchAssertion { class SearchAssertion {

View File

@ -131,11 +131,6 @@ export async function search(
}, },
relationships, relationships,
} }
// make sure only rows returned
request.filters!.equal = {
...request.filters?.equal,
type: "row",
}
if (params.sort) { if (params.sort) {
const sortField = table.schema[params.sort] const sortField = table.schema[params.sort]

View File

@ -11441,11 +11441,6 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
flatpickr@^4.5.2:
version "4.6.13"
resolved "https://registry.yarnpkg.com/flatpickr/-/flatpickr-4.6.13.tgz#8a029548187fd6e0d670908471e43abe9ad18d94"
integrity sha512-97PMG/aywoYpB4IvbvUJi0RQi8vearvU0oov1WW3k0WZPBMrTQVqekSX5CjSG/M4Q3i6A/0FKXC7RyAoAUUSPw==
flatted@^3.1.0: flatted@^3.1.0:
version "3.2.5" version "3.2.5"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
@ -11612,7 +11607,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fsevents@^2.3.2, fsevents@~2.3.1, fsevents@~2.3.2: fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.3" version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
@ -19761,13 +19756,6 @@ rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.8.1,
dependencies: dependencies:
estree-walker "^0.6.1" estree-walker "^0.6.1"
rollup@2.45.2:
version "2.45.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.45.2.tgz#8fb85917c9f35605720e92328f3ccbfba6f78b48"
integrity sha512-kRRU7wXzFHUzBIv0GfoFFIN3m9oteY4uAsKllIpQDId5cfnkWF2J130l+27dzDju0E6MScKiV0ZM5Bw8m4blYQ==
optionalDependencies:
fsevents "~2.3.1"
rollup@^2.36.2, rollup@^2.45.2: rollup@^2.36.2, rollup@^2.45.2:
version "2.79.1" version "2.79.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7"
@ -21105,20 +21093,6 @@ svelte-dnd-action@^0.9.8:
postcss "^8.4.29" postcss "^8.4.29"
postcss-scss "^4.0.8" postcss-scss "^4.0.8"
svelte-flatpickr@3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/svelte-flatpickr/-/svelte-flatpickr-3.2.3.tgz#db5dd7ad832ef83262b45e09737955ad3d591fc8"
integrity sha512-PNkqK4Napx8nTvCwkaUXdnKo8dISThaxEOK+szTUXcY6H0dQM0TSyuoMaVWY2yX7pM+PN5cpCQCcVe8YvTRFSw==
dependencies:
flatpickr "^4.5.2"
svelte-flatpickr@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/svelte-flatpickr/-/svelte-flatpickr-3.3.4.tgz#80b1ed2d6bc37df78b1660404e9326bfc0a206f4"
integrity sha512-i+QqJRs8zPRKsxv8r2GIk1fsb8cI3ozn3/aHXtViAoNKLy0j4PV7OSWavgEZC1wlAa34qi2hMkUh+vg6qt2DRA==
dependencies:
flatpickr "^4.5.2"
svelte-hmr@^0.15.1: svelte-hmr@^0.15.1:
version "0.15.3" version "0.15.3"
resolved "https://registry.yarnpkg.com/svelte-hmr/-/svelte-hmr-0.15.3.tgz#df54ccde9be3f091bf5f18fc4ef7b8eb6405fbe6" resolved "https://registry.yarnpkg.com/svelte-hmr/-/svelte-hmr-0.15.3.tgz#df54ccde9be3f091bf5f18fc4ef7b8eb6405fbe6"