Skip to content

Commit

Permalink
Merge pull request #1872 from evidence-dev/next
Browse files Browse the repository at this point in the history
Release 2024-04-11
  • Loading branch information
Winterhart authored Apr 11, 2024
2 parents 180804f + e954b3b commit a6b8620
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-falcons-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/db-commons': patch
---

add more leniency for comments in queries
5 changes: 5 additions & 0 deletions .changeset/hungry-chefs-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/postgres': patch
---

apply `standardizeResult` to first batch of postgres results
5 changes: 5 additions & 0 deletions .changeset/lazy-hornets-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': minor
---

add `noDefault` prop to `Dropdown`, support for multi-defaultValue
6 changes: 6 additions & 0 deletions .changeset/pretty-jobs-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/postgres': patch
'@evidence-dev/universal-sql': patch
---

stop blocking advanced usage of json with usql
6 changes: 6 additions & 0 deletions .changeset/sharp-years-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@evidence-dev/preprocess': patch
'@evidence-dev/core-components': patch
---

Add automatic links to headers
5 changes: 5 additions & 0 deletions .changeset/silver-tools-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/component-utilities': patch
---

properly update `option` for other functions to use
5 changes: 5 additions & 0 deletions .changeset/smart-dryers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Adds support for HTML contentType in DataTables
5 changes: 5 additions & 0 deletions .changeset/smooth-boats-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

Fixes bold, italic, strikethrough and code span sizing issues in markdown
8 changes: 6 additions & 2 deletions packages/datasources/postgres/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const runQuery = async (queryString, database, batchSize = 100000, closeBeforeRe
// to avoid loss of accuracy in very large numbers. This is something to keep an eye on,
// but for now, we are replacing the default parsing functions with the applicable
// JavaScript parsing function for each data type:
var types = require('pg').types;
var types = pg.types;

// Override bigint:
types.setTypeParser(20, function (val) {
Expand All @@ -142,6 +142,10 @@ const runQuery = async (queryString, database, batchSize = 100000, closeBeforeRe
return parseFloat(val.replace(/[^0-9.]/g, ''));
});

// Override json / jsonb:
types.setTypeParser(types.builtins.JSON, String);
types.setTypeParser(types.builtins.JSONB, String);

var pool = new Pool(credentials);

// Set schema if specified. Can't be done using the connection string / credentials. See issue: https://github.com/brianc/node-postgres/issues/1123#issuecomment-501510375 & solution: https://node-postgres.com/apis/pool#events
Expand All @@ -168,7 +172,7 @@ const runQuery = async (queryString, database, batchSize = 100000, closeBeforeRe
return {
rows: async function* () {
try {
yield firstBatch;
yield standardizeResult(firstBatch);
let results;
while ((results = await cursor.read(batchSize)) && results.length > 0)
yield standardizeResult(results);
Expand Down
3 changes: 2 additions & 1 deletion packages/lib/component-utilities/src/echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ export default (node, option) => {
}
};

const updateChart = (option) => {
const updateChart = (newOption) => {
option = newOption;
chart.setOption(
{
...option.config,
Expand Down
3 changes: 2 additions & 1 deletion packages/lib/db-commons/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ const cleanQuery = (query) => {
let cleanedString = query.trim();
if (cleanedString.endsWith(';'))
cleanedString = cleanedString.substring(0, cleanedString.length - 1);
return cleanedString;
// query might end with a line comment, which has to be ended
return cleanedString + '\n';
};

/**
Expand Down
10 changes: 10 additions & 0 deletions packages/lib/preprocess/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const addClasses = require('./src/add-classes.cjs');
// This is includes future proofing to add support for Prism highlighting
const processFrontmatter = require('./src/frontmatter/process-frontmatter.cjs');
const injectPartials = require('./src/partials/inject-partials.cjs');
const rehypeSlug = require('rehype-slug');
const rehypeAutolinkHeadings = require('rehype-autolink-headings');

module.exports = function evidencePreprocess(componentDevelopmentMode = false) {
return [
Expand All @@ -29,6 +31,14 @@ module.exports = function evidencePreprocess(componentDevelopmentMode = false) {
{
'*': 'markdown'
}
],
[rehypeSlug],
[
rehypeAutolinkHeadings,
{
behavior: 'wrap',
properties: {}
}
]
]
}),
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/preprocess/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"mdsvex": "0.11.0",
"prismjs": "^1.29.0",
"remark-parse": "8.0.2",
"rehype-slug": "4.0.1",
"rehype-autolink-headings": "5.1.0",
"svelte": "4.2.12",
"svelte-preprocess": "5.1.3",
"unified": "^9.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/lib/universal-sql/src/calculateScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function duckdbTypeToEvidenceType(column_type) {
case 'TIME':
case 'TIME WITH TIME ZONE': // return 'bigint';
case 'BLOB':
case 'JSON':
case 'BIT': // return 'Uint8Array';
return 'string';
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@
export let hideDuringPrint = true;
/** @type {string} */
export let defaultValue = undefined;
export let disableSelectAll = false;
/** @type {string | string[]} */
export let defaultValue = [];
const _defaultValue = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
export let noDefault = false;
if (noDefault) {
_defaultValue.length = 0;
}
const hasDefault = noDefault || _defaultValue.length > 0;
const ctx = {
hasBeenSet: defaultValue !== undefined,
hasBeenSet: hasDefault,
handleSelect,
multiple
};
Expand Down Expand Up @@ -150,16 +160,16 @@
function useNewQuery(query) {
items = query;
if (hasQuery && defaultValue) {
if (hasQuery && hasDefault) {
ctx.hasBeenSet = true;
if (browser) {
(async () => {
await query.fetch();
$selectedValues = query.filter((x) => x.value == defaultValue);
$selectedValues = query.filter((x) => _defaultValue.find((d) => x.value == d));
selectedValuesToInput();
})();
} else {
$selectedValues = query.filter((x) => x.value == defaultValue);
$selectedValues = query.filter((x) => _defaultValue.find((d) => x.value == d));
selectedValuesToInput();
}
} else {
Expand Down Expand Up @@ -256,16 +266,18 @@
{/if}
</Command.Group>
{#if multiple}
<Command.Separator />
<Command.Item
class="justify-center text-center"
onSelect={() => {
$selectedValues = $items.map((x) => ({ label: x.label, value: x.value }));
selectedValuesToInput();
}}
>
Select all
</Command.Item>
{#if !disableSelectAll}
<Command.Separator />
<Command.Item
class="justify-center text-center"
onSelect={() => {
$selectedValues = $items.map((x) => ({ label: x.label, value: x.value }));
selectedValuesToInput();
}}
>
Select all
</Command.Item>
{/if}
<Command.Separator />
<Command.Item
disabled={$selectedValues.length === 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
let observer;
function updateLinks() {
headers = Array.from(document.querySelectorAll('h1.markdown, h2.markdown'));
headers.forEach((header, i) => {
// Headers may contain values that change in response to user input, so we create our anchors as just the position on the page.
header.id = encodeURIComponent(i + 1);
});
headers = Array.from(document.querySelectorAll('h1.markdown, h2.markdown, h3.markdown'));
}
function observeDocumentChanges() {
Expand Down Expand Up @@ -38,12 +34,8 @@
<span class="block text-xs sticky top-0 mb-2 text-gray-950 bg-white shadow-white font-medium">
On this page
</span>
{#each headers as header, i}
<a
href={'#' + encodeURIComponent(i + 1)}
class={header.nodeName.toLowerCase()}
class:first={i === 0}
>
{#each headers as header}
<a href="#{header.id}" class={header.nodeName.toLowerCase()}>
{header.innerText}
</a>
{/each}
Expand All @@ -54,10 +46,6 @@
@apply block text-gray-600 text-xs transition-all duration-200 py-1;
}
/* a.h1.first {
@apply mt-0;
} */
a:hover {
@apply underline;
}
Expand All @@ -66,6 +54,10 @@
@apply pl-0 text-gray-500;
}
a.h3 {
@apply pl-4 text-gray-500;
}
a.h1 {
@apply mt-3 font-semibold block bg-white shadow shadow-white;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
neutralMax={column.neutralMax}
chip={column.chip}
/>
{:else if column.contentType === 'html' && row[column.id] !== undefined}
{@html row[column.id]}
{:else}
{formatValue(
row[column.id],
Expand Down
37 changes: 37 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a6b8620

Please sign in to comment.