@sealcode/sealgen 0.18.5 → 0.18.6
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/@types/forms/controls/single-reference.d.ts +1 -1
- package/@types/src/page/list.d.ts +1 -1
- package/lib/builders/colors-builder.js +17 -1
- package/lib/esbuild-plugins/rewrite-asset-imports.js +4 -0
- package/lib/page/list.js +1 -1
- package/package.json +4 -1
- package/src/builders/colors-builder.ts +20 -1
- package/src/esbuild-plugins/rewrite-asset-imports.ts +4 -0
- package/src/forms/controls/single-reference.ts +1 -1
- package/src/page/list.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import SealiousSingleReference from "sealious/@types/
|
|
1
|
+
import SealiousSingleReference from "sealious/@types/app/base-chips/field-types/single-reference.js";
|
|
2
2
|
import { CollectionField } from "../fields/collection-field.js";
|
|
3
3
|
import { DropdownOptions, FreeformDropdown } from "./dropdown.js";
|
|
4
4
|
import { Collection, CollectionItem } from "sealious";
|
|
@@ -36,7 +36,7 @@ export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFi
|
|
|
36
36
|
private renderPageButton;
|
|
37
37
|
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
38
38
|
getSort(ctx: Context): Promise<ListSort | null>;
|
|
39
|
-
makeSortLink(ctx: Context, field: string, order: "asc" | "desc"): string;
|
|
39
|
+
makeSortLink(ctx: Context, field: string, order: "asc" | "desc" | null): string;
|
|
40
40
|
renderFilters(ctx: Context): Promise<FlatTemplatable>;
|
|
41
41
|
renderHeading(ctx: Context, field: string, label?: string): Promise<FlatTemplatable>;
|
|
42
42
|
getDefaultSort(_: Context): ListSort | null;
|
|
@@ -3,6 +3,7 @@ import tempfile from "tempfile";
|
|
|
3
3
|
import { promises as fs } from "fs";
|
|
4
4
|
import { resolve } from "path";
|
|
5
5
|
import { colord } from "colord";
|
|
6
|
+
import { hex } from "wcag-contrast";
|
|
6
7
|
import { formatWithPrettier } from "../utils/prettier.js";
|
|
7
8
|
import { Builder } from "./builder.js";
|
|
8
9
|
import { exec } from "../utils/exec.js";
|
|
@@ -130,16 +131,31 @@ class ColorsBuilder extends Builder {
|
|
|
130
131
|
}`,
|
|
131
132
|
"css"
|
|
132
133
|
);
|
|
134
|
+
function colorCodeFind(color_varibale_name) {
|
|
135
|
+
const parts = color_varibale_name.split("-").slice(2);
|
|
136
|
+
const colorGroup = parts[1];
|
|
137
|
+
const colorName = parts.slice(2).join("-").replace(/\)$/, "");
|
|
138
|
+
const colorCode = color_groups[colorGroup]?.[colorName]?.color;
|
|
139
|
+
return colorCode;
|
|
140
|
+
}
|
|
133
141
|
function makeDemoPair(fg, bg, text, classname = "") {
|
|
142
|
+
let roundedContrast = "";
|
|
143
|
+
if (fg !== "") {
|
|
144
|
+
const fg_code = colorCodeFind(fg);
|
|
145
|
+
const bg_code = colorCodeFind(bg);
|
|
146
|
+
const contrast = hex(fg_code, bg_code);
|
|
147
|
+
roundedContrast = Math.round(contrast).toString();
|
|
148
|
+
}
|
|
134
149
|
return (
|
|
135
150
|
/* HTML */
|
|
136
151
|
` <div
|
|
137
152
|
class="pair ${classname}"
|
|
138
153
|
data-fg="${fg}"
|
|
139
154
|
data-bg="${bg}"
|
|
140
|
-
style="background-color: ${bg}; color: ${fg}"
|
|
155
|
+
style="background-color: ${bg}; color: ${fg}; display: flex; justify-content: space-between;"
|
|
141
156
|
>
|
|
142
157
|
<span>${text}</span>
|
|
158
|
+
<span>${roundedContrast}</span>
|
|
143
159
|
</div>`
|
|
144
160
|
);
|
|
145
161
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import { extname, resolve } from "node:path";
|
|
3
3
|
import { embeddable_file_extensions } from "../embeddable-file-extensions.js";
|
|
4
|
+
import { compile } from "@sealcode/tempstream-esbuild";
|
|
4
5
|
const rewrite_asset_imports_plugin = (project_dir) => ({
|
|
5
6
|
name: "sealgen-rewrite-asset-imports",
|
|
6
7
|
setup(build) {
|
|
@@ -30,6 +31,9 @@ const rewrite_asset_imports_plugin = (project_dir) => ({
|
|
|
30
31
|
return replaced;
|
|
31
32
|
}
|
|
32
33
|
);
|
|
34
|
+
if (extname(args.path) === ".tsx") {
|
|
35
|
+
contents = compile(contents, args.path);
|
|
36
|
+
}
|
|
33
37
|
return {
|
|
34
38
|
contents,
|
|
35
39
|
loader: extname(args.path) === ".tsx" ? "tsx" : "ts"
|
package/lib/page/list.js
CHANGED
|
@@ -176,7 +176,7 @@ class ListPage extends Page {
|
|
|
176
176
|
const order = current_order === "asc" ? "desc" : current_order === null ? "asc" : null;
|
|
177
177
|
return (
|
|
178
178
|
/* HTML */
|
|
179
|
-
`<th>
|
|
179
|
+
`<th data-field="${field}">
|
|
180
180
|
<a href="${this.makeSortLink(ctx, field, order)}"
|
|
181
181
|
>${label}
|
|
182
182
|
${current_order && (current_order == "asc" ? "\u2191" : "\u2193") || ""}</a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@types/prettier": "^2.7.0",
|
|
37
37
|
"@types/prompts": "^2.0.14",
|
|
38
38
|
"@types/recursive-readdir": "^2.2.4",
|
|
39
|
+
"@types/wcag-contrast": "^3.0.3",
|
|
39
40
|
"@types/ws": "^8.5.10",
|
|
40
41
|
"@types/yargs": "^17.0.32",
|
|
41
42
|
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"dependencies": {
|
|
62
63
|
"@koa/router": "^12.0.1",
|
|
63
64
|
"@sealcode/file-manager": "^1.0.2",
|
|
65
|
+
"@sealcode/tempstream-esbuild": "^0.1.0",
|
|
64
66
|
"@sealcode/ts-predicates": "^0.4.3",
|
|
65
67
|
"chokidar": "^3.6.0",
|
|
66
68
|
"colord": "^2.9.3",
|
|
@@ -82,6 +84,7 @@
|
|
|
82
84
|
"tempfile": "^5.0.0",
|
|
83
85
|
"tempstream": "^0.4.6",
|
|
84
86
|
"tiny-glob": "^0.2.9",
|
|
87
|
+
"wcag-contrast": "^3.0.0",
|
|
85
88
|
"ws": "^8.16.0",
|
|
86
89
|
"yargs": "^17.6.2"
|
|
87
90
|
},
|
|
@@ -4,6 +4,7 @@ import tempfile from "tempfile";
|
|
|
4
4
|
import { promises as fs } from "fs";
|
|
5
5
|
import { resolve } from "path";
|
|
6
6
|
import { colord } from "colord";
|
|
7
|
+
import { hex } from "wcag-contrast";
|
|
7
8
|
|
|
8
9
|
import { formatWithPrettier } from "../utils/prettier.js";
|
|
9
10
|
|
|
@@ -155,19 +156,37 @@ export class ColorsBuilder extends Builder {
|
|
|
155
156
|
"css"
|
|
156
157
|
);
|
|
157
158
|
|
|
159
|
+
function colorCodeFind(color_varibale_name: string) {
|
|
160
|
+
const parts = color_varibale_name.split("-").slice(2);
|
|
161
|
+
const colorGroup = parts[1];
|
|
162
|
+
const colorName = parts.slice(2).join("-").replace(/\)$/, "");
|
|
163
|
+
const colorCode = color_groups[colorGroup]?.[colorName]?.color;
|
|
164
|
+
|
|
165
|
+
return colorCode;
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
function makeDemoPair(
|
|
159
169
|
fg: string,
|
|
160
170
|
bg: string,
|
|
161
171
|
text: string,
|
|
162
172
|
classname = ""
|
|
163
173
|
) {
|
|
174
|
+
let roundedContrast = "";
|
|
175
|
+
if (fg !== "") {
|
|
176
|
+
const fg_code = colorCodeFind(fg);
|
|
177
|
+
const bg_code = colorCodeFind(bg);
|
|
178
|
+
const contrast = hex(fg_code, bg_code);
|
|
179
|
+
roundedContrast = Math.round(contrast).toString();
|
|
180
|
+
}
|
|
181
|
+
|
|
164
182
|
return /* HTML */ ` <div
|
|
165
183
|
class="pair ${classname}"
|
|
166
184
|
data-fg="${fg}"
|
|
167
185
|
data-bg="${bg}"
|
|
168
|
-
style="background-color: ${bg}; color: ${fg}"
|
|
186
|
+
style="background-color: ${bg}; color: ${fg}; display: flex; justify-content: space-between;"
|
|
169
187
|
>
|
|
170
188
|
<span>${text}</span>
|
|
189
|
+
<span>${roundedContrast}</span>
|
|
171
190
|
</div>`;
|
|
172
191
|
}
|
|
173
192
|
|
|
@@ -2,6 +2,7 @@ import { promises as fs } from "fs";
|
|
|
2
2
|
import { extname, resolve } from "node:path";
|
|
3
3
|
import { embeddable_file_extensions } from "../embeddable-file-extensions.js";
|
|
4
4
|
import { PluginBuild } from "esbuild";
|
|
5
|
+
import { compile } from "@sealcode/tempstream-esbuild";
|
|
5
6
|
|
|
6
7
|
export const rewrite_asset_imports_plugin = (project_dir: string) => ({
|
|
7
8
|
name: "sealgen-rewrite-asset-imports",
|
|
@@ -33,6 +34,9 @@ export const rewrite_asset_imports_plugin = (project_dir: string) => ({
|
|
|
33
34
|
}
|
|
34
35
|
);
|
|
35
36
|
|
|
37
|
+
if (extname(args.path) === ".tsx") {
|
|
38
|
+
contents = compile(contents, args.path);
|
|
39
|
+
}
|
|
36
40
|
return {
|
|
37
41
|
contents,
|
|
38
42
|
loader: extname(args.path) === ".tsx" ? "tsx" : "ts",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import SealiousSingleReference from "sealious/@types/
|
|
1
|
+
import SealiousSingleReference from "sealious/@types/app/base-chips/field-types/single-reference.js";
|
|
2
2
|
import { CollectionField } from "../fields/collection-field.js";
|
|
3
3
|
import { DropdownOptions, FreeformDropdown } from "./dropdown.js";
|
|
4
4
|
import { Collection, CollectionItem } from "sealious";
|
package/src/page/list.ts
CHANGED
|
@@ -248,7 +248,7 @@ export abstract class ListPage<
|
|
|
248
248
|
: current_order === null
|
|
249
249
|
? "asc"
|
|
250
250
|
: null;
|
|
251
|
-
return /* HTML */ `<th>
|
|
251
|
+
return /* HTML */ `<th data-field="${field}">
|
|
252
252
|
<a href="${this.makeSortLink(ctx, field, order)}"
|
|
253
253
|
>${label}
|
|
254
254
|
${(current_order && (current_order == "asc" ? "↑" : "↓")) ||
|