@davidsouther/jiffies 1.0.0 → 1.1.0
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/build/assert.d.ts +23 -23
- package/build/assert.js +33 -33
- package/build/case.d.ts +1 -1
- package/build/case.js +5 -5
- package/build/components/button_bar.d.ts +8 -8
- package/build/components/button_bar.js +27 -27
- package/build/components/inline_edit.d.ts +12 -12
- package/build/components/inline_edit.js +48 -48
- package/build/components/logger.d.ts +6 -7
- package/build/components/logger.js +22 -22
- package/build/components/select.d.ts +13 -10
- package/build/components/select.js +3 -3
- package/build/components/test.d.ts +1 -1
- package/build/components/test.js +2 -2
- package/build/components/virtual_scroll.d.ts +40 -41
- package/build/components/virtual_scroll.js +94 -94
- package/build/components/virtual_scroll.test.d.ts +1 -1
- package/build/components/virtual_scroll.test.js +21 -21
- package/build/context.d.ts +15 -15
- package/build/context.js +43 -43
- package/build/context.test.d.ts +1 -1
- package/build/context.test.js +46 -46
- package/build/debounce.d.ts +1 -1
- package/build/debounce.js +7 -7
- package/build/display.d.ts +5 -5
- package/build/display.js +11 -11
- package/build/dom/css/border.d.ts +11 -11
- package/build/dom/css/border.js +27 -27
- package/build/dom/css/constants.d.ts +31 -31
- package/build/dom/css/constants.js +28 -28
- package/build/dom/css/core.d.ts +5 -5
- package/build/dom/css/core.js +24 -24
- package/build/dom/css/fstyle.d.ts +5 -5
- package/build/dom/css/fstyle.js +32 -32
- package/build/dom/css/sizing.d.ts +5 -5
- package/build/dom/css/sizing.js +10 -10
- package/build/dom/dom.d.ts +26 -27
- package/build/dom/dom.js +95 -95
- package/build/dom/fc.d.ts +14 -14
- package/build/dom/fc.js +36 -35
- package/build/dom/fc.test.d.ts +1 -1
- package/build/dom/fc.test.js +21 -21
- package/build/dom/form/form.app.d.ts +1 -1
- package/build/dom/form/form.app.js +23 -23
- package/build/dom/form/form.d.ts +26 -26
- package/build/dom/form/form.js +34 -34
- package/build/dom/form/form.test.js +1 -1
- package/build/dom/html.d.ts +113 -117
- package/build/dom/html.js +114 -114
- package/build/dom/html.test.d.ts +1 -1
- package/build/dom/html.test.js +58 -58
- package/build/dom/provide.d.ts +3 -3
- package/build/dom/provide.js +7 -7
- package/build/dom/router/link.d.ts +6 -6
- package/build/dom/router/link.js +3 -3
- package/build/dom/router/router.d.ts +12 -12
- package/build/dom/router/router.js +49 -49
- package/build/dom/svg.d.ts +64 -64
- package/build/dom/svg.js +65 -65
- package/build/dom/test.d.ts +1 -1
- package/build/dom/test.js +2 -2
- package/build/dom/types/css.d.ts +6612 -6612
- package/build/dom/types/css.js +23 -23
- package/build/dom/types/dom.js +1 -1
- package/build/dom/types/html.d.ts +616 -616
- package/build/dom/types/html.js +1 -1
- package/build/dom/xml.d.ts +1 -1
- package/build/dom/xml.js +4 -5
- package/build/equal.d.ts +5 -5
- package/build/equal.js +37 -37
- package/build/equal.test.d.ts +1 -1
- package/build/equal.test.js +20 -20
- package/build/flags.d.ts +7 -7
- package/build/flags.js +48 -48
- package/build/flags.test.d.ts +1 -1
- package/build/flags.test.js +35 -35
- package/build/fs.d.ts +48 -48
- package/build/fs.js +144 -144
- package/build/fs.test.d.ts +1 -1
- package/build/fs.test.js +43 -43
- package/build/generator.d.ts +1 -1
- package/build/generator.js +10 -10
- package/build/generator.test.d.ts +1 -1
- package/build/generator.test.js +24 -24
- package/build/is_browser.d.ts +1 -1
- package/build/is_browser.js +1 -1
- package/build/loader.d.mts +22 -22
- package/build/loader.mjs +35 -35
- package/build/lock.d.ts +1 -1
- package/build/lock.js +23 -23
- package/build/lock.test.d.ts +1 -1
- package/build/lock.test.js +16 -16
- package/build/log.d.ts +26 -26
- package/build/log.js +46 -46
- package/build/observable/observable.d.ts +83 -0
- package/build/observable/observable.js +148 -0
- package/build/observable/observable.test.d.ts +1 -0
- package/build/observable/observable.test.js +21 -0
- package/build/range.d.ts +1 -1
- package/build/range.js +7 -7
- package/build/result.d.ts +31 -31
- package/build/result.js +65 -65
- package/build/result.test.d.ts +1 -1
- package/build/result.test.js +71 -71
- package/build/safe.d.ts +1 -1
- package/build/safe.js +10 -10
- package/build/scope/describe.d.ts +18 -14
- package/build/scope/describe.js +61 -52
- package/build/scope/display/console.d.ts +2 -2
- package/build/scope/display/console.js +21 -21
- package/build/scope/display/dom.d.ts +3 -3
- package/build/scope/display/dom.js +26 -26
- package/build/scope/display/junit.d.ts +2 -2
- package/build/scope/display/junit.js +17 -17
- package/build/scope/execute.d.ts +12 -12
- package/build/scope/execute.js +85 -85
- package/build/scope/expect.d.ts +23 -23
- package/build/scope/expect.js +108 -108
- package/build/scope/fix.d.ts +4 -4
- package/build/scope/fix.js +22 -22
- package/build/scope/index.d.ts +3 -3
- package/build/scope/index.js +3 -3
- package/build/scope/scope.d.ts +17 -17
- package/build/scope/scope.js +1 -1
- package/build/server/http/apps.d.ts +5 -5
- package/build/server/http/apps.js +23 -23
- package/build/server/http/css.d.ts +5 -5
- package/build/server/http/css.js +50 -47
- package/build/server/http/index.d.ts +21 -21
- package/build/server/http/index.js +73 -73
- package/build/server/http/response.d.ts +4 -4
- package/build/server/http/response.js +40 -40
- package/build/server/http/sitemap.d.ts +2 -2
- package/build/server/http/sitemap.js +42 -42
- package/build/server/http/static.d.ts +2 -2
- package/build/server/http/static.js +21 -21
- package/build/server/http/typescript.d.ts +5 -5
- package/build/server/http/typescript.js +40 -40
- package/build/server/main.d.ts +2 -2
- package/build/server/main.js +9 -9
- package/build/test.d.mts +2 -2
- package/build/test.mjs +23 -23
- package/build/test_all.d.ts +7 -7
- package/build/test_all.js +18 -18
- package/build/transpile.d.mts +3 -3
- package/build/transpile.mjs +18 -18
- package/package.json +3 -3
- package/src/components/logger.ts +2 -3
- package/src/components/virtual_scroll.test.ts +4 -4
- package/src/components/virtual_scroll.ts +8 -8
- package/src/diff.test.ts +48 -0
- package/src/diff.ts +84 -0
- package/src/dom/dom.ts +73 -61
- package/src/dom/fc.ts +10 -9
- package/src/dom/html.test.ts +5 -5
- package/src/dom/html.ts +7 -10
- package/src/dom/observable.test.ts +43 -0
- package/src/dom/observable.ts +11 -0
- package/src/dom/router/router.ts +4 -4
- package/src/dom/test.ts +5 -1
- package/src/dom/xml.ts +1 -2
- package/src/index.html +6 -3
- package/src/observable/_notes +21 -8
- package/src/observable/event.ts +93 -0
- package/src/observable/observable.test.ts +73 -0
- package/src/observable/observable.ts +403 -0
- package/src/scope/describe.ts +14 -1
- package/src/scope/display/dom.ts +2 -2
- package/src/scope/execute.ts +2 -5
- package/src/server/http/css.ts +3 -1
- package/src/test_all.ts +10 -8
- package/src/observable/observable._js +0 -175
package/build/assert.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
declare type AssertMessage = string | (() => string);
|
|
2
|
-
/**
|
|
3
|
-
* Throw an error when a condition is not met.
|
|
4
|
-
*/
|
|
5
|
-
export declare function assert(condition: boolean, message?: AssertMessage): void | never;
|
|
6
|
-
/**
|
|
7
|
-
* Given a value, return it if it is not null nor undefined. Otherwise throw an
|
|
8
|
-
* error.
|
|
9
|
-
*
|
|
10
|
-
* @template T
|
|
11
|
-
* @returns {NonNullable<T>}
|
|
12
|
-
*/
|
|
13
|
-
export declare function assertExists<T>(t: T, message?: AssertMessage): NonNullable<T>;
|
|
14
|
-
/**
|
|
15
|
-
* @param {*} n
|
|
16
|
-
* @returns string
|
|
17
|
-
*/
|
|
18
|
-
export declare function assertString(n: unknown, message?: AssertMessage): string;
|
|
19
|
-
/**
|
|
20
|
-
* Compile time assertion that no value will used at this point in control flow.
|
|
21
|
-
*/
|
|
22
|
-
export declare function checkExhaustive(value: never, message?: AssertMessage): never;
|
|
23
|
-
export {};
|
|
1
|
+
declare type AssertMessage = string | (() => string);
|
|
2
|
+
/**
|
|
3
|
+
* Throw an error when a condition is not met.
|
|
4
|
+
*/
|
|
5
|
+
export declare function assert(condition: boolean, message?: AssertMessage): void | never;
|
|
6
|
+
/**
|
|
7
|
+
* Given a value, return it if it is not null nor undefined. Otherwise throw an
|
|
8
|
+
* error.
|
|
9
|
+
*
|
|
10
|
+
* @template T
|
|
11
|
+
* @returns {NonNullable<T>}
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertExists<T>(t: T, message?: AssertMessage): NonNullable<T>;
|
|
14
|
+
/**
|
|
15
|
+
* @param {*} n
|
|
16
|
+
* @returns string
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertString(n: unknown, message?: AssertMessage): string;
|
|
19
|
+
/**
|
|
20
|
+
* Compile time assertion that no value will used at this point in control flow.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkExhaustive(value: never, message?: AssertMessage): never;
|
|
23
|
+
export {};
|
package/build/assert.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throw an error when a condition is not met.
|
|
3
|
-
*/
|
|
4
|
-
export function assert(condition, message = "Assertion failed") {
|
|
5
|
-
if (!condition) {
|
|
6
|
-
throw new Error(message instanceof Function ? message() : message);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Given a value, return it if it is not null nor undefined. Otherwise throw an
|
|
11
|
-
* error.
|
|
12
|
-
*
|
|
13
|
-
* @template T
|
|
14
|
-
* @returns {NonNullable<T>}
|
|
15
|
-
*/
|
|
16
|
-
export function assertExists(t, message = "Assertion failed: value does not exist") {
|
|
17
|
-
assert(t != null, message);
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @param {*} n
|
|
22
|
-
* @returns string
|
|
23
|
-
*/
|
|
24
|
-
export function assertString(n, message = () => `Assertion failed: ${n} is not a string`) {
|
|
25
|
-
assert(typeof n == "string", message);
|
|
26
|
-
return n;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Compile time assertion that no value will used at this point in control flow.
|
|
30
|
-
*/
|
|
31
|
-
export function checkExhaustive(value, message = `Unexpected value ${value}`) {
|
|
32
|
-
throw new Error(message instanceof Function ? message() : message);
|
|
33
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Throw an error when a condition is not met.
|
|
3
|
+
*/
|
|
4
|
+
export function assert(condition, message = "Assertion failed") {
|
|
5
|
+
if (!condition) {
|
|
6
|
+
throw new Error(message instanceof Function ? message() : message);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Given a value, return it if it is not null nor undefined. Otherwise throw an
|
|
11
|
+
* error.
|
|
12
|
+
*
|
|
13
|
+
* @template T
|
|
14
|
+
* @returns {NonNullable<T>}
|
|
15
|
+
*/
|
|
16
|
+
export function assertExists(t, message = "Assertion failed: value does not exist") {
|
|
17
|
+
assert(t != null, message);
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @param {*} n
|
|
22
|
+
* @returns string
|
|
23
|
+
*/
|
|
24
|
+
export function assertString(n, message = () => `Assertion failed: ${n} is not a string`) {
|
|
25
|
+
assert(typeof n == "string", message);
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compile time assertion that no value will used at this point in control flow.
|
|
30
|
+
*/
|
|
31
|
+
export function checkExhaustive(value, message = `Unexpected value ${value}`) {
|
|
32
|
+
throw new Error(message instanceof Function ? message() : message);
|
|
33
|
+
}
|
package/build/case.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function dashCase(identifier: string): string;
|
|
1
|
+
export declare function dashCase(identifier: string): string;
|
package/build/case.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function dashCase(identifier) {
|
|
2
|
-
return identifier
|
|
3
|
-
.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`)
|
|
4
|
-
.replace(/ ([A-Z])/g, (_, b) => `-${b.toLowerCase()}`);
|
|
5
|
-
}
|
|
1
|
+
export function dashCase(identifier) {
|
|
2
|
+
return identifier
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`)
|
|
4
|
+
.replace(/ ([A-Z])/g, (_, b) => `-${b.toLowerCase()}`);
|
|
5
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare const ButtonBar: import("../dom/fc.js").FCComponentCtor<{
|
|
2
|
-
value: T;
|
|
3
|
-
values: T[];
|
|
4
|
-
events: {
|
|
5
|
-
onSelect: (current: T) => void;
|
|
6
|
-
};
|
|
7
|
-
}, {}>;
|
|
8
|
-
export default ButtonBar;
|
|
1
|
+
declare const ButtonBar: import("../dom/fc.js").FCComponentCtor<{
|
|
2
|
+
value: T;
|
|
3
|
+
values: T[];
|
|
4
|
+
events: {
|
|
5
|
+
onSelect: (current: T) => void;
|
|
6
|
+
};
|
|
7
|
+
}, {}>;
|
|
8
|
+
export default ButtonBar;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { display } from "../display.js";
|
|
2
|
-
import { FC } from "../dom/fc.js";
|
|
3
|
-
import { fieldset, input, label } from "../dom/html.js";
|
|
4
|
-
let buttonBarId = 1;
|
|
5
|
-
let nextId = () => buttonBarId++;
|
|
6
|
-
const ButtonBar = FC("button-bar", (el, { value, values, events }) => {
|
|
7
|
-
const name = `button-bar-${nextId()}`;
|
|
8
|
-
return fieldset({ class: "input-group" }, ...values
|
|
9
|
-
.map((option) => {
|
|
10
|
-
const opt = `${option}`.replace(/\s+/g, "_").toLowerCase();
|
|
11
|
-
const id = `${name}-${opt}`;
|
|
12
|
-
return [
|
|
13
|
-
label({ role: "button", htmlFor: id }, input({
|
|
14
|
-
type: "radio",
|
|
15
|
-
id,
|
|
16
|
-
name,
|
|
17
|
-
value: option,
|
|
18
|
-
checked: option === value,
|
|
19
|
-
events: {
|
|
20
|
-
change: () => events.onSelect(option),
|
|
21
|
-
},
|
|
22
|
-
}), display(option)),
|
|
23
|
-
];
|
|
24
|
-
})
|
|
25
|
-
.flat());
|
|
26
|
-
});
|
|
27
|
-
export default ButtonBar;
|
|
1
|
+
import { display } from "../display.js";
|
|
2
|
+
import { FC } from "../dom/fc.js";
|
|
3
|
+
import { fieldset, input, label } from "../dom/html.js";
|
|
4
|
+
let buttonBarId = 1;
|
|
5
|
+
let nextId = () => buttonBarId++;
|
|
6
|
+
const ButtonBar = FC("button-bar", (el, { value, values, events }) => {
|
|
7
|
+
const name = `button-bar-${nextId()}`;
|
|
8
|
+
return fieldset({ class: "input-group" }, ...values
|
|
9
|
+
.map((option) => {
|
|
10
|
+
const opt = `${option}`.replace(/\s+/g, "_").toLowerCase();
|
|
11
|
+
const id = `${name}-${opt}`;
|
|
12
|
+
return [
|
|
13
|
+
label({ role: "button", htmlFor: id }, input({
|
|
14
|
+
type: "radio",
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
value: option,
|
|
18
|
+
checked: option === value,
|
|
19
|
+
events: {
|
|
20
|
+
change: () => events.onSelect(option),
|
|
21
|
+
},
|
|
22
|
+
}), display(option)),
|
|
23
|
+
];
|
|
24
|
+
})
|
|
25
|
+
.flat());
|
|
26
|
+
});
|
|
27
|
+
export default ButtonBar;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export interface InlineEditState {
|
|
2
|
-
mode: number;
|
|
3
|
-
value: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const InlineEdit: import("../dom/fc.js").FCComponentCtor<{
|
|
6
|
-
mode?: number | undefined;
|
|
7
|
-
value: string;
|
|
8
|
-
events: {
|
|
9
|
-
change: (value: string) => void;
|
|
10
|
-
};
|
|
11
|
-
}, InlineEditState>;
|
|
12
|
-
export default InlineEdit;
|
|
1
|
+
export interface InlineEditState {
|
|
2
|
+
mode: number;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const InlineEdit: import("../dom/fc.js").FCComponentCtor<{
|
|
6
|
+
mode?: number | undefined;
|
|
7
|
+
value: string;
|
|
8
|
+
events: {
|
|
9
|
+
change: (value: string) => void;
|
|
10
|
+
};
|
|
11
|
+
}, InlineEditState>;
|
|
12
|
+
export default InlineEdit;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { width } from "../dom/css/sizing.js";
|
|
2
|
-
import { FC, State } from "../dom/fc.js";
|
|
3
|
-
import { input, span } from "../dom/html.js";
|
|
4
|
-
const Mode = { VIEW: 0, EDIT: 1 };
|
|
5
|
-
export const InlineEdit = FC("inline-edit", (el, { mode = Mode.VIEW, value, events }) => {
|
|
6
|
-
const state = (el[State] ??= { mode, value });
|
|
7
|
-
const render = () => {
|
|
8
|
-
switch (state.mode) {
|
|
9
|
-
case Mode.EDIT:
|
|
10
|
-
return edit();
|
|
11
|
-
case Mode.VIEW:
|
|
12
|
-
return view();
|
|
13
|
-
default:
|
|
14
|
-
return span();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const view = () => span({
|
|
18
|
-
style: { cursor: "text", ...width("full", "inline") },
|
|
19
|
-
events: {
|
|
20
|
-
click: () => {
|
|
21
|
-
state.mode = Mode.EDIT;
|
|
22
|
-
el.update(render());
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
}, state.value ?? "");
|
|
26
|
-
const edit = () => {
|
|
27
|
-
const edit = span({ style: { display: "block", position: "relative" } }, input({
|
|
28
|
-
style: {
|
|
29
|
-
zIndex: "10",
|
|
30
|
-
position: "absolute",
|
|
31
|
-
left: "0",
|
|
32
|
-
marginTop: "-0.375rem",
|
|
33
|
-
},
|
|
34
|
-
events: {
|
|
35
|
-
blur: ({ target }) => events.change(target?.value ?? ""),
|
|
36
|
-
},
|
|
37
|
-
type: "text",
|
|
38
|
-
value: state.value,
|
|
39
|
-
}), "\u00a0" // Hack to get the span to take up space
|
|
40
|
-
);
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
edit.dispatchEvent(new Event("focus"));
|
|
43
|
-
});
|
|
44
|
-
return edit;
|
|
45
|
-
};
|
|
46
|
-
return render();
|
|
47
|
-
});
|
|
48
|
-
export default InlineEdit;
|
|
1
|
+
import { width } from "../dom/css/sizing.js";
|
|
2
|
+
import { FC, State } from "../dom/fc.js";
|
|
3
|
+
import { input, span } from "../dom/html.js";
|
|
4
|
+
const Mode = { VIEW: 0, EDIT: 1 };
|
|
5
|
+
export const InlineEdit = FC("inline-edit", (el, { mode = Mode.VIEW, value, events }) => {
|
|
6
|
+
const state = (el[State] ??= { mode, value });
|
|
7
|
+
const render = () => {
|
|
8
|
+
switch (state.mode) {
|
|
9
|
+
case Mode.EDIT:
|
|
10
|
+
return edit();
|
|
11
|
+
case Mode.VIEW:
|
|
12
|
+
return view();
|
|
13
|
+
default:
|
|
14
|
+
return span();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const view = () => span({
|
|
18
|
+
style: { cursor: "text", ...width("full", "inline") },
|
|
19
|
+
events: {
|
|
20
|
+
click: () => {
|
|
21
|
+
state.mode = Mode.EDIT;
|
|
22
|
+
el.update(render());
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}, state.value ?? "");
|
|
26
|
+
const edit = () => {
|
|
27
|
+
const edit = span({ style: { display: "block", position: "relative" } }, input({
|
|
28
|
+
style: {
|
|
29
|
+
zIndex: "10",
|
|
30
|
+
position: "absolute",
|
|
31
|
+
left: "0",
|
|
32
|
+
marginTop: "-0.375rem",
|
|
33
|
+
},
|
|
34
|
+
events: {
|
|
35
|
+
blur: ({ target }) => events.change(target?.value ?? ""),
|
|
36
|
+
},
|
|
37
|
+
type: "text",
|
|
38
|
+
value: state.value,
|
|
39
|
+
}), "\u00a0" // Hack to get the span to take up space
|
|
40
|
+
);
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
edit.dispatchEvent(new Event("focus"));
|
|
43
|
+
});
|
|
44
|
+
return edit;
|
|
45
|
+
};
|
|
46
|
+
return render();
|
|
47
|
+
});
|
|
48
|
+
export default InlineEdit;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function makeHTMLLogger(name: string): HTMLLogger;
|
|
1
|
+
import { Logger } from "../log.js";
|
|
2
|
+
export interface HTMLLogger extends Logger {
|
|
3
|
+
root: Element;
|
|
4
|
+
}
|
|
5
|
+
export declare function isHTMLLogger(logger: Logger): logger is HTMLLogger;
|
|
6
|
+
export declare function makeHTMLLogger(name: string): HTMLLogger;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { display } from "../display.js";
|
|
2
|
-
import { div, span, ul, li, pre, code } from "../dom/html.js";
|
|
3
|
-
import { LEVEL } from "../log.js";
|
|
4
|
-
export function isHTMLLogger(logger) {
|
|
5
|
-
return logger.root != undefined;
|
|
6
|
-
}
|
|
7
|
-
export function makeHTMLLogger(name) {
|
|
8
|
-
let log;
|
|
9
|
-
const root = div(div(span(name)), (log = ul()));
|
|
10
|
-
const logger = { level: LEVEL.INFO, root };
|
|
11
|
-
function append(message) {
|
|
12
|
-
log.appendChild(li(pre(code(message))));
|
|
13
|
-
}
|
|
14
|
-
const logAt = (level) => (message) => level >= (logger.level ?? LEVEL.ERROR)
|
|
15
|
-
? append(display(message))
|
|
16
|
-
: undefined;
|
|
17
|
-
logger.debug = logAt(LEVEL.VERBOSE);
|
|
18
|
-
logger.info = logAt(LEVEL.INFO);
|
|
19
|
-
logger.warn = logAt(LEVEL.WARN);
|
|
20
|
-
logger.error = logAt(LEVEL.ERROR);
|
|
21
|
-
return logger;
|
|
22
|
-
}
|
|
1
|
+
import { display } from "../display.js";
|
|
2
|
+
import { div, span, ul, li, pre, code } from "../dom/html.js";
|
|
3
|
+
import { LEVEL } from "../log.js";
|
|
4
|
+
export function isHTMLLogger(logger) {
|
|
5
|
+
return logger.root != undefined;
|
|
6
|
+
}
|
|
7
|
+
export function makeHTMLLogger(name) {
|
|
8
|
+
let log;
|
|
9
|
+
const root = div(div(span(name)), (log = ul()));
|
|
10
|
+
const logger = { level: LEVEL.INFO, root };
|
|
11
|
+
function append(message) {
|
|
12
|
+
log.appendChild(li(pre(code(message))));
|
|
13
|
+
}
|
|
14
|
+
const logAt = (level) => (message) => level >= (logger.level ?? LEVEL.ERROR)
|
|
15
|
+
? append(display(message))
|
|
16
|
+
: undefined;
|
|
17
|
+
logger.debug = logAt(LEVEL.VERBOSE);
|
|
18
|
+
logger.info = logAt(LEVEL.INFO);
|
|
19
|
+
logger.warn = logAt(LEVEL.WARN);
|
|
20
|
+
logger.error = logAt(LEVEL.ERROR);
|
|
21
|
+
return logger;
|
|
22
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { EventHandler } from "../dom/dom.js";
|
|
2
|
-
export declare const Select: import("../dom/fc.js").FCComponentCtor<{
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
events: {
|
|
6
|
-
change: EventHandler;
|
|
7
|
-
};
|
|
8
|
-
disabled: boolean;
|
|
9
|
-
options: [
|
|
10
|
-
|
|
1
|
+
import { EventHandler } from "../dom/dom.js";
|
|
2
|
+
export declare const Select: import("../dom/fc.js").FCComponentCtor<{
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
events: {
|
|
6
|
+
change: EventHandler;
|
|
7
|
+
};
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
options: [
|
|
10
|
+
string,
|
|
11
|
+
string
|
|
12
|
+
][];
|
|
13
|
+
}, {}>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FC } from "../dom/fc.js";
|
|
2
|
-
import { option, select } from "../dom/html.js";
|
|
3
|
-
export const Select = FC("jiffies-select", (el, { name, events: { change }, disabled, value, options }) => select({ name, events: { change }, disabled }, ...options.map(([v, name]) => option({ value: v, selected: value === v }, `${name}`))));
|
|
1
|
+
import { FC } from "../dom/fc.js";
|
|
2
|
+
import { option, select } from "../dom/html.js";
|
|
3
|
+
export const Select = FC("jiffies-select", (el, { name, events: { change }, disabled, value, options }) => select({ name, events: { change }, disabled }, ...options.map(([v, name]) => option({ value: v, selected: value === v }, `${name}`))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/build/components/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
await import("./virtual_scroll.test.js");
|
|
2
|
-
export {};
|
|
1
|
+
await import("./virtual_scroll.test.js");
|
|
2
|
+
export {};
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
export default VirtualScroll;
|
|
1
|
+
export interface VirtualScrollSettings {
|
|
2
|
+
minIndex: number;
|
|
3
|
+
maxIndex: number;
|
|
4
|
+
startIndex: number;
|
|
5
|
+
itemHeight: number;
|
|
6
|
+
count: number;
|
|
7
|
+
tolerance: number;
|
|
8
|
+
}
|
|
9
|
+
export interface VirtualScrollDataAdapter<T> {
|
|
10
|
+
(offset: number, limit: number): Iterable<T>;
|
|
11
|
+
}
|
|
12
|
+
export declare function arrayAdapter<T>(data: T[]): VirtualScrollDataAdapter<T>;
|
|
13
|
+
export interface VirtualScrollProps<T, U extends HTMLElement> {
|
|
14
|
+
settings: Partial<VirtualScrollSettings>;
|
|
15
|
+
get: VirtualScrollDataAdapter<T>;
|
|
16
|
+
row: (t: T) => U;
|
|
17
|
+
}
|
|
18
|
+
export declare function fillVirtualScrollSettings(settings: Partial<VirtualScrollSettings>): VirtualScrollSettings;
|
|
19
|
+
export declare function initialState<T>(settings: VirtualScrollSettings): VirtualScrollState<T>;
|
|
20
|
+
export declare function getData<T>(minIndex: number, maxIndex: number, offset: number, limit: number, get: VirtualScrollDataAdapter<T>): T[];
|
|
21
|
+
export declare function doScroll<T>(scrollTop: number, state: VirtualScrollState<T>, get: VirtualScrollDataAdapter<T>): {
|
|
22
|
+
scrollTop: number;
|
|
23
|
+
topPaddingHeight: number;
|
|
24
|
+
bottomPaddingHeight: number;
|
|
25
|
+
data: T[];
|
|
26
|
+
};
|
|
27
|
+
interface VirtualScrollState<T, U extends HTMLElement = HTMLElement> {
|
|
28
|
+
settings: VirtualScrollSettings;
|
|
29
|
+
scrollTop: number;
|
|
30
|
+
bufferedItems: number;
|
|
31
|
+
totalHeight: number;
|
|
32
|
+
viewportHeight: number;
|
|
33
|
+
topPaddingHeight: number;
|
|
34
|
+
bottomPaddingHeight: number;
|
|
35
|
+
toleranceHeight: number;
|
|
36
|
+
data: T[];
|
|
37
|
+
rows: U[];
|
|
38
|
+
}
|
|
39
|
+
export declare const VirtualScroll: import("../dom/fc.js").FCComponentCtor<VirtualScrollProps<unknown, HTMLElement>, VirtualScrollState<unknown, HTMLElement>>;
|
|
40
|
+
export default VirtualScroll;
|