Skip to content

Commit 53bc19f

Browse files
committed
update dependencies; add svelte prettier
1 parent 978283f commit 53bc19f

39 files changed

+1298
-1276
lines changed

.prettierrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2+
"plugins": ["prettier-plugin-svelte"],
3+
24
"printWidth": 160,
35
"useTabs": true,
46
"semi": true,
57
"singleQuote": true,
6-
"arrowParens": "avoid"
8+
"arrowParens": "avoid",
9+
10+
"svelteAllowShorthand": false
711
}

bun.lockb

-26.8 KB
Binary file not shown.

esbuild.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ esbuild
5050
minify: true,
5151
plugins: [
5252
esbuildSvelte({
53-
compilerOptions: { css: true },
53+
compilerOptions: { css: 'injected' },
5454
preprocess: sveltePreprocess(),
55+
filterWarnings: warning => {
56+
// we don't want warnings from node modules that we can do nothing about
57+
return !warning.filename.includes('node_modules');
58+
},
5559
}),
5660
],
5761
})

esbuild.dev.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ const context = await esbuild
6363
],
6464
}),
6565
esbuildSvelte({
66-
compilerOptions: { css: true },
66+
compilerOptions: { css: 'injected' },
6767
preprocess: sveltePreprocess(),
68+
filterWarnings: warning => {
69+
// we don't want warnings from node modules that we can do nothing about
70+
return !warning.filename.includes('node_modules');
71+
},
6872
}),
6973
],
7074
})

esbuild.publish.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ esbuild
6060
outfile: './Publish.js',
6161
plugins: [
6262
esbuildSvelte({
63-
compilerOptions: { css: true },
63+
compilerOptions: { css: 'injected' },
6464
preprocess: sveltePreprocess(),
65+
filterWarnings: warning => {
66+
// we don't want warnings from node modules that we can do nothing about
67+
return !warning.filename.includes('node_modules');
68+
},
6569
}),
6670
],
6771
})

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dev-publish": "bun run esbuild.publish.config.mjs",
1010
"build-publish": "tsc -noEmit -skipLibCheck && node esbuild.publish.config.mjs production",
1111
"test": "bun test",
12-
"format": "prettier --write .",
12+
"format": "prettier --write --plugin prettier-plugin-svelte .",
1313
"lint": "eslint --max-warnings=0 src/**",
1414
"lint:fix": "eslint --max-warnings=0 --fix src/**",
1515
"types": "tsc -p \"./tsconfig.types.json\""
@@ -29,29 +29,30 @@
2929
"@typescript-eslint/eslint-plugin": "^6.0.0",
3030
"@typescript-eslint/parser": "^6.0.0",
3131
"builtin-modules": "^3.3.0",
32-
"bun-types": "1.0.6",
33-
"esbuild": "^0.17.0",
32+
"bun-types": "1.0.8",
33+
"esbuild": "^0.19.5",
3434
"esbuild-plugin-copy-watch": "^2.0.0",
35-
"esbuild-svelte": "^0.7.1",
35+
"esbuild-svelte": "^0.8.0",
3636
"eslint": "^8.52.0",
3737
"eslint-plugin-import": "^2.28.1",
3838
"eslint-plugin-isaacscript": "^3.5.6",
3939
"eslint-plugin-only-warn": "^1.1.0",
4040
"obsidian": "latest",
4141
"obsidian-dataview": "0.5.56",
42-
"prettier": "3.0.3",
42+
"prettier": "^3.0.3",
43+
"prettier-plugin-svelte": "^3.0.3",
4344
"svelte": "^4.2.0",
4445
"svelte-preprocess": "^5.0.4",
45-
"tslib": "2.4.0",
46+
"tslib": "2.6.2",
4647
"typescript": "^5.2.2"
4748
},
4849
"dependencies": {
49-
"@lemons_dev/parsinom": "^0.0.9",
50+
"@lemons_dev/parsinom": "^0.0.10",
5051
"@opd-libs/opd-metadata-lib": "0.0.4",
5152
"@opd-libs/opd-utils-lib": "0.0.2",
5253
"@popperjs/core": "^2.11.8",
5354
"@ungap/structured-clone": "^1.2.0",
54-
"mathjs": "^11.8.0",
55+
"mathjs": "^12.0.0",
5556
"obsidian-svelte": "^0.1.9",
5657
"svelte-portal": "^2.2.0"
5758
}
Lines changed: 129 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,129 @@
1-
<script lang="ts">
2-
import type { moment } from 'obsidian';
3-
import { onMount } from 'svelte';
4-
import { DateParser } from '../../../parsers/DateParser';
5-
6-
export let value: moment.Moment;
7-
export let useUsInputOrder: boolean;
8-
export let onValueChange: (value: moment.Moment) => void;
9-
10-
let months: Record<string, string> = {};
11-
let days: Record<string, string> = {};
12-
13-
let year: string;
14-
let month: string;
15-
let day: string;
16-
17-
onMount(() => {
18-
months = {
19-
'0': 'January',
20-
'1': 'February',
21-
'2': 'March',
22-
'3': 'April',
23-
'4': 'May',
24-
'5': 'June',
25-
'6': 'July',
26-
'7': 'August',
27-
'8': 'September',
28-
'9': 'October',
29-
'10': 'November',
30-
'11': 'December',
31-
}
32-
33-
for (let i = 1; i <= 31; i++) {
34-
days[i.toString()] = i.toString();
35-
}
36-
37-
year = value.year().toString();
38-
month = value.month().toString();
39-
day = value.date().toString();
40-
})
41-
42-
export function setValue(v: moment.Moment): void {
43-
value = v;
44-
45-
year = value.year().toString();
46-
month = value.month().toString();
47-
day = value.date().toString();
48-
}
49-
50-
function onYearChange(): void {
51-
const parseRes = Number.parseInt(year);
52-
const yearNumber = Number.isNaN(parseRes) ? DateParser.getDefaultYear() : parseRes;
53-
54-
value.year(yearNumber);
55-
// year = yearNumber.toString();
56-
57-
onValueChange(value);
58-
}
59-
60-
function onMonthChange(): void {
61-
value.month(month);
62-
63-
const clampedDay = clampDay(value.date());
64-
65-
value.date(clampedDay);
66-
day = clampedDay.toString();
67-
68-
onValueChange(value);
69-
}
70-
71-
function onDayChange(): void {
72-
const parseRes = Number.parseInt(day);
73-
const clampedDay = clampDay(parseRes);
74-
75-
value.date(clampedDay);
76-
day = clampedDay.toString();
77-
78-
onValueChange(value);
79-
}
80-
81-
function clampDay(day: number): number {
82-
if (Number.isNaN(day)) {
83-
return DateParser.getDefaultDay();
84-
} else if (day < 1) {
85-
return 1;
86-
} else if (day > value.daysInMonth()) {
87-
return value.daysInMonth();
88-
}
89-
return day;
90-
}
91-
</script>
92-
93-
<div class='mb-input-element-group'>
94-
{#if useUsInputOrder}
95-
<select class='dropdown mb-input-element-group-element' bind:value={month} on:change={() => onMonthChange()}>
96-
{#each Object.entries(months) as [_month, _monthName]}
97-
<option value={_month}>{_monthName}</option>
98-
{/each}
99-
</select>
100-
101-
<select class='dropdown mb-input-element-group-element' bind:value={day} on:change={() => onDayChange()}>
102-
{#each Object.values(days) as _day}
103-
<option value={_day}>{_day}</option>
104-
{/each}
105-
</select>
106-
{:else}
107-
<select class='dropdown mb-input-element-group-element' bind:value={day} on:change={() => onDayChange()}>
108-
{#each Object.values(days) as _day}
109-
<option value={_day}>{_day}</option>
110-
{/each}
111-
</select>
112-
113-
<select class='dropdown mb-input-element-group-element' bind:value={month} on:change={() => onMonthChange()}>
114-
{#each Object.entries(months) as [_month, _monthName]}
115-
<option value={_month}>{_monthName}</option>
116-
{/each}
117-
</select>
118-
{/if}
119-
120-
<input class='mb-date-input-year-input mb-input-element-group-element' type='number' tabindex='0' bind:value={year} on:input={() => onYearChange()} max=9999 min=0>
121-
</div>
122-
123-
1+
<script lang="ts">
2+
import type { moment } from 'obsidian';
3+
import { onMount } from 'svelte';
4+
import { DateParser } from '../../../parsers/DateParser';
5+
6+
export let value: moment.Moment;
7+
export let useUsInputOrder: boolean;
8+
export let onValueChange: (value: moment.Moment) => void;
9+
10+
let months: Record<string, string> = {};
11+
let days: Record<string, string> = {};
12+
13+
let year: string;
14+
let month: string;
15+
let day: string;
16+
17+
onMount(() => {
18+
months = {
19+
'0': 'January',
20+
'1': 'February',
21+
'2': 'March',
22+
'3': 'April',
23+
'4': 'May',
24+
'5': 'June',
25+
'6': 'July',
26+
'7': 'August',
27+
'8': 'September',
28+
'9': 'October',
29+
'10': 'November',
30+
'11': 'December',
31+
};
32+
33+
for (let i = 1; i <= 31; i++) {
34+
days[i.toString()] = i.toString();
35+
}
36+
37+
year = value.year().toString();
38+
month = value.month().toString();
39+
day = value.date().toString();
40+
});
41+
42+
export function setValue(v: moment.Moment): void {
43+
value = v;
44+
45+
year = value.year().toString();
46+
month = value.month().toString();
47+
day = value.date().toString();
48+
}
49+
50+
function onYearChange(): void {
51+
const parseRes = Number.parseInt(year);
52+
const yearNumber = Number.isNaN(parseRes) ? DateParser.getDefaultYear() : parseRes;
53+
54+
value.year(yearNumber);
55+
// year = yearNumber.toString();
56+
57+
onValueChange(value);
58+
}
59+
60+
function onMonthChange(): void {
61+
value.month(month);
62+
63+
const clampedDay = clampDay(value.date());
64+
65+
value.date(clampedDay);
66+
day = clampedDay.toString();
67+
68+
onValueChange(value);
69+
}
70+
71+
function onDayChange(): void {
72+
const parseRes = Number.parseInt(day);
73+
const clampedDay = clampDay(parseRes);
74+
75+
value.date(clampedDay);
76+
day = clampedDay.toString();
77+
78+
onValueChange(value);
79+
}
80+
81+
function clampDay(day: number): number {
82+
if (Number.isNaN(day)) {
83+
return DateParser.getDefaultDay();
84+
} else if (day < 1) {
85+
return 1;
86+
} else if (day > value.daysInMonth()) {
87+
return value.daysInMonth();
88+
}
89+
return day;
90+
}
91+
</script>
92+
93+
<div class="mb-input-element-group">
94+
{#if useUsInputOrder}
95+
<select class="dropdown mb-input-element-group-element" bind:value={month} on:change={() => onMonthChange()}>
96+
{#each Object.entries(months) as [_month, _monthName]}
97+
<option value={_month}>{_monthName}</option>
98+
{/each}
99+
</select>
100+
101+
<select class="dropdown mb-input-element-group-element" bind:value={day} on:change={() => onDayChange()}>
102+
{#each Object.values(days) as _day}
103+
<option value={_day}>{_day}</option>
104+
{/each}
105+
</select>
106+
{:else}
107+
<select class="dropdown mb-input-element-group-element" bind:value={day} on:change={() => onDayChange()}>
108+
{#each Object.values(days) as _day}
109+
<option value={_day}>{_day}</option>
110+
{/each}
111+
</select>
112+
113+
<select class="dropdown mb-input-element-group-element" bind:value={month} on:change={() => onMonthChange()}>
114+
{#each Object.entries(months) as [_month, _monthName]}
115+
<option value={_month}>{_monthName}</option>
116+
{/each}
117+
</select>
118+
{/if}
119+
120+
<input
121+
class="mb-date-input-year-input mb-input-element-group-element"
122+
type="number"
123+
tabindex="0"
124+
bind:value={year}
125+
on:input={() => onYearChange()}
126+
max="9999"
127+
min="0"
128+
/>
129+
</div>

0 commit comments

Comments
 (0)