This commit is contained in:
Gerard Burns 2024-05-14 11:24:51 +01:00
parent 2e238f814c
commit bb69e0c1c9
8 changed files with 33 additions and 22 deletions

View File

@ -63,7 +63,7 @@
return null return null
} }
$: docLink = getDocLink(columnType); $: docLink = getDocLink(columnType)
</script> </script>
<Line noWrap> <Line noWrap>

View File

@ -7,7 +7,14 @@
export let disabled = false export let disabled = false
</script> </script>
<a class:disabled tabindex="0" {href} rel="noopener noreferrer" target="_blank" class="link"> <a
class:disabled
tabindex="0"
{href}
rel="noopener noreferrer"
target="_blank"
class="link"
>
<Icon size="XS" name={icon} /> <Icon size="XS" name={icon} />
<span class="text"> <span class="text">
<slot> <slot>
@ -53,7 +60,7 @@
color: var(--blue); color: var(--blue);
} }
.disabled :global(svg){ .disabled :global(svg) {
color: var(--grey-6); color: var(--grey-6);
} }
</style> </style>

View File

@ -83,7 +83,7 @@ export class AppMetaStore extends BudiStore {
syncClientTypeSupportPresets(typeSupportPresets) { syncClientTypeSupportPresets(typeSupportPresets) {
this.update(state => ({ this.update(state => ({
...state, ...state,
typeSupportPresets typeSupportPresets,
})) }))
} }

View File

@ -103,7 +103,7 @@ export class ComponentStore extends BudiStore {
this.update(state => ({ this.update(state => ({
...state, ...state,
components, components,
customComponents customComponents,
})) }))
// Sync client features to app store // Sync client features to app store

View File

@ -94,7 +94,9 @@ describe("Application Meta Store", () => {
it("Sync type support information to state", async ctx => { it("Sync type support information to state", async ctx => {
ctx.test.appStore.syncClientTypeSupportPresets({ preset: "information" }) ctx.test.appStore.syncClientTypeSupportPresets({ preset: "information" })
expect(ctx.test.store.typeSupportPresets).toStrictEqual({ preset: "information" }) expect(ctx.test.store.typeSupportPresets).toStrictEqual({
preset: "information",
})
}) })
it("Sync component feature flags to state", async ctx => { it("Sync component feature flags to state", async ctx => {

View File

@ -55,7 +55,11 @@
</script> </script>
{#key optionsCopy?.customColor} {#key optionsCopy?.customColor}
<div class:hide={noData} use:styleable={$component.styles} bind:this={chartElement} /> <div
class:hide={noData}
use:styleable={$component.styles}
bind:this={chartElement}
/>
{#if $builderStore.inBuilder && noData} {#if $builderStore.inBuilder && noData}
<div <div
class="component-placeholder" class="component-placeholder"

View File

@ -5,19 +5,19 @@ export const formatters = {
["Datetime"]: val => new Date(val).toLocaleString(), ["Datetime"]: val => new Date(val).toLocaleString(),
} }
export const parsePalette = (paletteName) => { export const parsePalette = paletteName => {
if (paletteName === "Custom") { if (paletteName === "Custom") {
// return null in this case so that the palette option doesn't get consumed by Apex Charts // return null in this case so that the palette option doesn't get consumed by Apex Charts
return null; return null
} }
const [_, number] = paletteName.split(" "); const [_, number] = paletteName.split(" ")
return `palette${number}` return `palette${number}`
} }
// Deep clone which copies function references // Deep clone which copies function references
export const cloneDeep = (value) => { export const cloneDeep = value => {
const typesToNaiveCopy = ["string", "boolean", "number", "function", "symbol"] const typesToNaiveCopy = ["string", "boolean", "number", "function", "symbol"]
if (value === null) { if (value === null) {
@ -29,7 +29,7 @@ export const cloneDeep = (value) => {
} }
if (typesToNaiveCopy.includes(typeof value)) { if (typesToNaiveCopy.includes(typeof value)) {
return value; return value
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
@ -44,7 +44,7 @@ export const cloneDeep = (value) => {
cloneObject[key] = cloneDeep(childValue) cloneObject[key] = cloneDeep(childValue)
}) })
return cloneObject; return cloneObject
} }
throw `Unsupported value: "${value}" of type: "${typeof value}"` throw `Unsupported value: "${value}" of type: "${typeof value}"`

View File

@ -1,14 +1,12 @@
import { expect, describe, it, vi } from "vitest" import { expect, describe, it, vi } from "vitest"
import { import { cloneDeep } from "./utils"
cloneDeep,
} from "./utils"
describe("utils", () => { describe("utils", () => {
let context; let context
beforeEach(() => { beforeEach(() => {
vi.clearAllMocks() vi.clearAllMocks()
context = {}; context = {}
}) })
describe("cloneDeep", () => { describe("cloneDeep", () => {
@ -20,14 +18,14 @@ describe("utils", () => {
num: 123, num: 123,
bool: true, bool: true,
sym: Symbol("test"), sym: Symbol("test"),
func: () => "some value" func: () => "some value",
} }
context.cloneValue = cloneDeep(context.value); context.cloneValue = cloneDeep(context.value)
}); })
it("to clone the object and not copy object references", () => { it("to clone the object and not copy object references", () => {
expect(context.cloneValue.obj.one).toEqual(1) expect(context.cloneValue.obj.one).toEqual(1)
expect(context.cloneValue.obj.two).toEqual(2) expect(context.cloneValue.obj.two).toEqual(2)
}); })
}) })
}) })