dotquilt 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/animations.d.ts +105 -0
- package/dist/animations.js +107 -0
- package/dist/catalog-styles.d.ts +4 -0
- package/dist/catalog-styles.js +12 -0
- package/dist/chart-animations.d.ts +36 -0
- package/dist/chart-animations.js +25 -0
- package/dist/chart-styles.d.ts +3 -0
- package/dist/chart-styles.js +23 -0
- package/dist/chart.css +4 -0
- package/dist/chart.d.ts +73 -0
- package/dist/chart.js +80 -0
- package/dist/circle.css +5 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/internal/binding.d.ts +13 -0
- package/dist/internal/binding.js +21 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +13 -0
- package/dist/internal/chart-appearance.d.ts +12 -0
- package/dist/internal/chart-appearance.js +2 -0
- package/dist/internal/chart-definitions.d.ts +19 -0
- package/dist/internal/chart-definitions.js +149 -0
- package/dist/internal/chart-factory.d.ts +12 -0
- package/dist/internal/chart-factory.js +31 -0
- package/dist/internal/chart-field.d.ts +22 -0
- package/dist/internal/chart-field.js +74 -0
- package/dist/internal/chart-idle.d.ts +3 -0
- package/dist/internal/chart-idle.js +96 -0
- package/dist/internal/chart-math.d.ts +8 -0
- package/dist/internal/chart-math.js +19 -0
- package/dist/internal/chart-participant.d.ts +8 -0
- package/dist/internal/chart-participant.js +4 -0
- package/dist/internal/chart-projection.d.ts +11 -0
- package/dist/internal/chart-projection.js +69 -0
- package/dist/internal/content-box.d.ts +11 -0
- package/dist/internal/content-box.js +36 -0
- package/dist/internal/coordinated-handoff.d.ts +4 -0
- package/dist/internal/coordinated-handoff.js +158 -0
- package/dist/internal/count.d.ts +3 -0
- package/dist/internal/count.js +20 -0
- package/dist/internal/defaults.d.ts +11 -0
- package/dist/internal/defaults.js +11 -0
- package/dist/internal/dense/managed-painter.d.ts +4 -0
- package/dist/internal/dense/managed-painter.js +361 -0
- package/dist/internal/dense/runner.d.ts +2 -0
- package/dist/internal/dense/runner.js +5 -0
- package/dist/internal/dense-loader.d.ts +83 -0
- package/dist/internal/dense-loader.js +331 -0
- package/dist/internal/dissolve.d.ts +27 -0
- package/dist/internal/dissolve.js +216 -0
- package/dist/internal/dom.d.ts +23 -0
- package/dist/internal/dom.js +104 -0
- package/dist/internal/effect.d.ts +2 -0
- package/dist/internal/effect.js +17 -0
- package/dist/internal/element.d.ts +89 -0
- package/dist/internal/element.js +384 -0
- package/dist/internal/event-element.d.ts +8 -0
- package/dist/internal/event-element.js +20 -0
- package/dist/internal/frames.d.ts +1 -0
- package/dist/internal/frames.js +51 -0
- package/dist/internal/handoff.d.ts +56 -0
- package/dist/internal/handoff.js +102 -0
- package/dist/internal/ledger.d.ts +13 -0
- package/dist/internal/ledger.js +78 -0
- package/dist/internal/loading-controller.d.ts +62 -0
- package/dist/internal/loading-controller.js +698 -0
- package/dist/internal/marks.d.ts +153 -0
- package/dist/internal/marks.js +227 -0
- package/dist/internal/math.d.ts +2 -0
- package/dist/internal/math.js +2 -0
- package/dist/internal/morph-marks.d.ts +62 -0
- package/dist/internal/morph-marks.js +205 -0
- package/dist/internal/morph.d.ts +35 -0
- package/dist/internal/morph.js +488 -0
- package/dist/internal/paint.d.ts +29 -0
- package/dist/internal/paint.js +1 -0
- package/dist/internal/painter.d.ts +20 -0
- package/dist/internal/painter.js +155 -0
- package/dist/internal/preset-data.d.ts +12 -0
- package/dist/internal/preset-data.js +31 -0
- package/dist/internal/preset.d.ts +22 -0
- package/dist/internal/preset.js +86 -0
- package/dist/internal/pulse.d.ts +7 -0
- package/dist/internal/pulse.js +74 -0
- package/dist/internal/reveal-effect.d.ts +7 -0
- package/dist/internal/reveal-effect.js +24 -0
- package/dist/internal/reveal.d.ts +5 -0
- package/dist/internal/reveal.js +11 -0
- package/dist/internal/runner.d.ts +9 -0
- package/dist/internal/runner.js +70 -0
- package/dist/internal/services.d.ts +12 -0
- package/dist/internal/services.js +159 -0
- package/dist/internal/skeleton-handoff.d.ts +26 -0
- package/dist/internal/skeleton-handoff.js +6 -0
- package/dist/internal/skeleton-source.d.ts +5 -0
- package/dist/internal/skeleton-source.js +106 -0
- package/dist/internal/surface.d.ts +4 -0
- package/dist/internal/surface.js +21 -0
- package/dist/internal/table-definitions.d.ts +27 -0
- package/dist/internal/table-definitions.js +139 -0
- package/dist/internal/table-factory.d.ts +12 -0
- package/dist/internal/table-factory.js +44 -0
- package/dist/internal/table-field.d.ts +12 -0
- package/dist/internal/table-field.js +75 -0
- package/dist/internal/table-model.d.ts +21 -0
- package/dist/internal/table-model.js +117 -0
- package/dist/internal/table-projection.d.ts +7 -0
- package/dist/internal/table-projection.js +110 -0
- package/dist/internal/target-changes.d.ts +3 -0
- package/dist/internal/target-changes.js +2 -0
- package/dist/internal/target-tracker.d.ts +18 -0
- package/dist/internal/target-tracker.js +33 -0
- package/dist/internal/targets.d.ts +3 -0
- package/dist/internal/targets.js +15 -0
- package/dist/internal/text-definitions.d.ts +141 -0
- package/dist/internal/text-definitions.js +228 -0
- package/dist/internal/text-glyphs.d.ts +4 -0
- package/dist/internal/text-glyphs.js +32 -0
- package/dist/internal/text-morph.d.ts +32 -0
- package/dist/internal/text-morph.js +113 -0
- package/dist/internal/text-playback.d.ts +4 -0
- package/dist/internal/text-playback.js +119 -0
- package/dist/internal/text-scramble.d.ts +18 -0
- package/dist/internal/text-scramble.js +47 -0
- package/dist/internal/time.d.ts +9 -0
- package/dist/internal/time.js +13 -0
- package/dist/internal/unstyled.d.ts +8 -0
- package/dist/internal/unstyled.js +8 -0
- package/dist/line.css +5 -0
- package/dist/region-css.d.ts +1 -0
- package/dist/region-css.js +6 -0
- package/dist/region-styles.d.ts +3 -0
- package/dist/region-styles.js +15 -0
- package/dist/region.css +1 -0
- package/dist/region.d.ts +31 -0
- package/dist/region.js +100 -0
- package/dist/register-all.d.ts +2 -0
- package/dist/register-all.js +33 -0
- package/dist/server.d.ts +63 -0
- package/dist/server.js +141 -0
- package/dist/skeleton-animations.d.ts +10 -0
- package/dist/skeleton-animations.js +35 -0
- package/dist/skeleton-block.d.ts +50 -0
- package/dist/skeleton-block.js +260 -0
- package/dist/skeleton-circle.d.ts +5 -0
- package/dist/skeleton-circle.js +11 -0
- package/dist/skeleton-family.css +13 -0
- package/dist/skeleton-line.d.ts +5 -0
- package/dist/skeleton-line.js +11 -0
- package/dist/skeleton-text.css +5 -0
- package/dist/skeleton-text.d.ts +22 -0
- package/dist/skeleton-text.js +115 -0
- package/dist/skeleton.css +4 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.js +4 -0
- package/dist/static-catalog-styles.d.ts +8 -0
- package/dist/static-catalog-styles.js +44 -0
- package/dist/styles.d.ts +4 -0
- package/dist/styles.js +18 -0
- package/dist/table-animations.d.ts +11 -0
- package/dist/table-animations.js +4 -0
- package/dist/table-styles.d.ts +2 -0
- package/dist/table-styles.js +12 -0
- package/dist/table.css +3 -0
- package/dist/table.d.ts +88 -0
- package/dist/table.js +126 -0
- package/dist/text-animations.d.ts +31 -0
- package/dist/text-animations.js +40 -0
- package/dist/text-styles.d.ts +3 -0
- package/dist/text-styles.js +24 -0
- package/dist/text.css +3 -0
- package/dist/text.d.ts +42 -0
- package/dist/text.js +402 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +18 -0
- package/dist/typing-styles.d.ts +1 -0
- package/dist/typing-styles.js +7 -0
- package/dist/typing.css +4 -0
- package/dist/typing.d.ts +35 -0
- package/dist/typing.js +164 -0
- package/package.json +100 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { markColor, markGap, markPitches, markSize, restOpacity, } from './internal/marks.js';
|
|
2
|
+
import { unstyledHold } from './internal/unstyled.js';
|
|
3
|
+
export const tableStyles = /* @__PURE__ */ Object.freeze([
|
|
4
|
+
`:host{display:grid;position:relative;width:100%;overflow:hidden}:host([hidden]){display:none}:host [data-table-static]{grid-area:1/1;display:block;width:100%;min-width:0;gap:${markGap};background-size:calc(${markSize} + ${markGap}) calc(${markSize} + ${markGap});stroke:${markColor};opacity:${restOpacity}}${markPitches((mark) => `:host([mark=${mark}])`, '[data-table-static]')}:host .f{display:grid;min-width:0;min-height:100%}:host .f > svg[data-dotquilt-painter]{grid-area:1/1;contain:size;display:block;width:100%;height:100%;pointer-events:none}:host([data-custom]) [data-table-static]{visibility:hidden}:host [data-dotquilt-react-static]{display:none}@media(forced-colors:active){:host [data-table-static]{visibility:visible;stroke:CanvasText}:host svg[data-dotquilt-painter]{display:none}}:host canvas[data-dotquilt-bitmap]{display:block;width:100%;height:100%;pointer-events:none}`,
|
|
5
|
+
unstyledHold,
|
|
6
|
+
]);
|
|
7
|
+
// Static rules also apply while the element's external stylesheet loads
|
|
8
|
+
// (`:state(unstyled)`); browsers without custom states ignore that part.
|
|
9
|
+
export const staticTableStyles =
|
|
10
|
+
/* @__PURE__ */ Object.freeze([
|
|
11
|
+
`:where(dotquilt-table-loader:is(:not(:defined),:state(unstyled))){display:block;position:relative;width:100%;overflow:hidden}dotquilt-table-loader:is(:not(:defined),:state(unstyled))[hidden]{display:none}dotquilt-table-loader:is(:not(:defined),:state(unstyled)) [data-dotquilt-static]{display:block;width:100%;stroke:${markColor};opacity:${restOpacity}}@media(forced-colors:active){dotquilt-table-loader:is(:not(:defined),:state(unstyled)) [data-dotquilt-static]{stroke:CanvasText}}`,
|
|
12
|
+
]);
|
package/dist/table.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
:host{display:grid;position:relative;width:100%;overflow:hidden}:host([hidden]){display:none}:host [data-table-static]{grid-area:1/1;display:block;width:100%;min-width:0;gap:var(--dotquilt-dot-gap,4.6px);background-size:calc(var(--dotquilt-dot-size,4.4px) + var(--dotquilt-dot-gap,4.6px)) calc(var(--dotquilt-dot-size,4.4px) + var(--dotquilt-dot-gap,4.6px));stroke:var(--dotquilt-color,light-dark(#6e7889,#a3afc2));opacity:0.37}:host([mark=square]) [data-table-static]{background-size:8.5px 8.5px}:host([mark=dash]) [data-table-static]{background-size:13px 9.5px}:host .f{display:grid;min-width:0;min-height:100%}:host .f > svg[data-dotquilt-painter]{grid-area:1/1;contain:size;display:block;width:100%;height:100%;pointer-events:none}:host([data-custom]) [data-table-static]{visibility:hidden}:host [data-dotquilt-react-static]{display:none}@media(forced-colors:active){:host [data-table-static]{visibility:visible;stroke:CanvasText}:host svg[data-dotquilt-painter]{display:none}}:host canvas[data-dotquilt-bitmap]{display:block;width:100%;height:100%;pointer-events:none}
|
|
2
|
+
:host(:state(unstyled)) > :not(slot){display:none!important}
|
|
3
|
+
:where(dotquilt-table-loader:is(:not(:defined),:state(unstyled))){display:block;position:relative;width:100%;overflow:hidden}dotquilt-table-loader:is(:not(:defined),:state(unstyled))[hidden]{display:none}dotquilt-table-loader:is(:not(:defined),:state(unstyled)) [data-dotquilt-static]{display:block;width:100%;stroke:var(--dotquilt-color,light-dark(#6e7889,#a3afc2));opacity:0.37}@media(forced-colors:active){dotquilt-table-loader:is(:not(:defined),:state(unstyled)) [data-dotquilt-static]{stroke:CanvasText}}
|
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Animations, Rect } from './animations.js';
|
|
2
|
+
import { DenseLoader, type PointerResponse, type Projector } from './internal/dense-loader.js';
|
|
3
|
+
import type { Preset } from './internal/preset.js';
|
|
4
|
+
import type { Motion, StylePolicy } from './types.js';
|
|
5
|
+
export type TableCellKind = 'text' | 'number' | 'badge' | 'date';
|
|
6
|
+
export interface TableColumn {
|
|
7
|
+
readonly kind: TableCellKind;
|
|
8
|
+
readonly width?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TableCell {
|
|
11
|
+
readonly bounds: Rect;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
readonly baseline: number;
|
|
14
|
+
readonly tone: 'base' | 'accent';
|
|
15
|
+
readonly rowId: string;
|
|
16
|
+
readonly rowIndex: number;
|
|
17
|
+
readonly columnIndex: number;
|
|
18
|
+
readonly kind: TableCellKind;
|
|
19
|
+
readonly glyphs: readonly import('./animations.js').GlyphCell[];
|
|
20
|
+
}
|
|
21
|
+
export interface TableInput {
|
|
22
|
+
readonly kind: 'table';
|
|
23
|
+
readonly cells: readonly TableCell[];
|
|
24
|
+
}
|
|
25
|
+
export type TableTargetGeometry = TableInput | Readonly<{
|
|
26
|
+
kind: 'points';
|
|
27
|
+
points: readonly import('./chart.js').Point[];
|
|
28
|
+
}> | Readonly<{
|
|
29
|
+
kind: 'rects';
|
|
30
|
+
rects: readonly Rect[];
|
|
31
|
+
}>;
|
|
32
|
+
export type TableTargetProvider = (bounds: Readonly<{
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
}>) => TableTargetGeometry | null;
|
|
36
|
+
export type TablePreset = import('./internal/preset.js').Preset<'table'>;
|
|
37
|
+
export declare class TableLoader extends DenseLoader<'table', TableTargetProvider> {
|
|
38
|
+
#private;
|
|
39
|
+
static observedAttributes: string[];
|
|
40
|
+
protected readonly family = "table";
|
|
41
|
+
protected readonly styles: readonly string[];
|
|
42
|
+
protected readonly appearanceKey: symbol;
|
|
43
|
+
protected readonly emptyInput: TableInput;
|
|
44
|
+
protected defaultIdle(): import("./animations.js").AnimationBinding<"table", "idle", {
|
|
45
|
+
cadenceMs: number;
|
|
46
|
+
cellStyle: 'auto';
|
|
47
|
+
}>;
|
|
48
|
+
protected defaultHandoff(): import("./animations.js").AnimationBinding<"table", "handoff", {
|
|
49
|
+
staggerMs: number;
|
|
50
|
+
settlePx: number;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* The outline and the painters share one grid cell inside a frame that
|
|
54
|
+
* spans exactly the content box, so padding or an app's display rule never
|
|
55
|
+
* shifts the dots away from the geometry they were measured for.
|
|
56
|
+
*/
|
|
57
|
+
protected createSurface(document: Document): Node;
|
|
58
|
+
protected projector(provider: TableTargetProvider | undefined): Projector<'table'>;
|
|
59
|
+
/** Before a handoff projects real cells, idle motion draws placeholder rows. */
|
|
60
|
+
protected surfaceInput(input: TableInput, width: number): TableInput;
|
|
61
|
+
protected capturePreset(value: Preset<'table'>): Preset<'table'>;
|
|
62
|
+
protected prepareConnection(): void;
|
|
63
|
+
protected settled(): void;
|
|
64
|
+
get columns(): readonly TableColumn[];
|
|
65
|
+
set columns(value: readonly TableColumn[] | undefined);
|
|
66
|
+
get rows(): number;
|
|
67
|
+
set rows(value: number | undefined);
|
|
68
|
+
get rowHeight(): number;
|
|
69
|
+
set rowHeight(value: number | undefined);
|
|
70
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
71
|
+
connectedCallback(): void;
|
|
72
|
+
update(patch: Readonly<{
|
|
73
|
+
rows?: number | undefined;
|
|
74
|
+
rowHeight?: number | undefined;
|
|
75
|
+
columns?: readonly TableColumn[] | undefined;
|
|
76
|
+
speed?: number | undefined;
|
|
77
|
+
pointerResponse?: PointerResponse | undefined;
|
|
78
|
+
animations?: Animations<'table'> | undefined;
|
|
79
|
+
preset?: TablePreset | undefined;
|
|
80
|
+
targetProvider?: TableTargetProvider | undefined;
|
|
81
|
+
motion?: Motion | undefined;
|
|
82
|
+
stylePolicy?: StylePolicy | undefined;
|
|
83
|
+
}>): void;
|
|
84
|
+
protected get optionNames(): readonly string[];
|
|
85
|
+
}
|
|
86
|
+
export { type StaticTableLayout, staticTableLayout, } from './internal/table-model.js';
|
|
87
|
+
export declare function registerTableLoader(): void;
|
|
88
|
+
export { refreshStyles } from './internal/element.js';
|
package/dist/table.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { DenseLoader, } from './internal/dense-loader.js';
|
|
2
|
+
import { node, register, upgradeProperties } from './internal/dom.js';
|
|
3
|
+
import { tablePreset } from './internal/preset.js';
|
|
4
|
+
import { capturePresetData } from './internal/preset-data.js';
|
|
5
|
+
import { defaultRows, defaultShimmer } from './internal/table-definitions.js';
|
|
6
|
+
import { tableAppearance } from './internal/table-field.js';
|
|
7
|
+
import { staticTableSVG, tableCells, tableColumns, tableHeight, tableRows, } from './internal/table-model.js';
|
|
8
|
+
import { emptyTableInput, tableProjection, } from './internal/table-projection.js';
|
|
9
|
+
import { tableStyles } from './table-styles.js';
|
|
10
|
+
export class TableLoader extends DenseLoader {
|
|
11
|
+
static observedAttributes = [
|
|
12
|
+
...DenseLoader.observedAttributes,
|
|
13
|
+
'rows',
|
|
14
|
+
'row-height',
|
|
15
|
+
];
|
|
16
|
+
family = 'table';
|
|
17
|
+
styles = tableStyles;
|
|
18
|
+
appearanceKey = tableAppearance;
|
|
19
|
+
emptyInput = emptyTableInput;
|
|
20
|
+
defaultIdle() {
|
|
21
|
+
return defaultShimmer;
|
|
22
|
+
}
|
|
23
|
+
defaultHandoff() {
|
|
24
|
+
return defaultRows;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The outline and the painters share one grid cell inside a frame that
|
|
28
|
+
* spans exactly the content box, so padding or an app's display rule never
|
|
29
|
+
* shifts the dots away from the geometry they were measured for.
|
|
30
|
+
*/
|
|
31
|
+
createSurface(document) {
|
|
32
|
+
const frame = node(document, 'div', {
|
|
33
|
+
class: 'f',
|
|
34
|
+
'data-dotquilt-frame': '',
|
|
35
|
+
});
|
|
36
|
+
frame.append(staticTableSVG(document, this.rows, this.rowHeight, this.columns));
|
|
37
|
+
return frame;
|
|
38
|
+
}
|
|
39
|
+
projector(provider) {
|
|
40
|
+
return (bounds, report) => tableProjection(provider, bounds, report);
|
|
41
|
+
}
|
|
42
|
+
/** Before a handoff projects real cells, idle motion draws placeholder rows. */
|
|
43
|
+
surfaceInput(input, width) {
|
|
44
|
+
return input.cells.length
|
|
45
|
+
? input
|
|
46
|
+
: tableCells(width, this.rows, this.rowHeight, this.columns);
|
|
47
|
+
}
|
|
48
|
+
capturePreset(value) {
|
|
49
|
+
return capturePresetData(value, 'table', () => tablePreset);
|
|
50
|
+
}
|
|
51
|
+
prepareConnection() {
|
|
52
|
+
upgradeProperties(this, ['rows', 'rowHeight', 'columns']);
|
|
53
|
+
}
|
|
54
|
+
settled() {
|
|
55
|
+
this.clearSurface();
|
|
56
|
+
}
|
|
57
|
+
#columns = tableColumns(undefined);
|
|
58
|
+
get columns() {
|
|
59
|
+
return this.#columns;
|
|
60
|
+
}
|
|
61
|
+
set columns(value) {
|
|
62
|
+
this.#columns = tableColumns(value, (code) => this.report(code, 'columns'));
|
|
63
|
+
this.refresh();
|
|
64
|
+
}
|
|
65
|
+
get rows() {
|
|
66
|
+
return tableRows(Number(this.getAttribute('rows') ?? 5), this.#columns.length);
|
|
67
|
+
}
|
|
68
|
+
set rows(value) {
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
this.removeAttribute('rows');
|
|
71
|
+
else
|
|
72
|
+
this.setAttribute('rows', String(value));
|
|
73
|
+
}
|
|
74
|
+
get rowHeight() {
|
|
75
|
+
return tableHeight(Number(this.getAttribute('row-height') ?? 32));
|
|
76
|
+
}
|
|
77
|
+
set rowHeight(value) {
|
|
78
|
+
if (value === undefined)
|
|
79
|
+
this.removeAttribute('row-height');
|
|
80
|
+
else
|
|
81
|
+
this.setAttribute('row-height', String(value));
|
|
82
|
+
}
|
|
83
|
+
attributeChangedCallback(name, old, value) {
|
|
84
|
+
if (value !== null &&
|
|
85
|
+
((name === 'rows' &&
|
|
86
|
+
!(Number.isInteger(Number(value)) &&
|
|
87
|
+
Number(value) > 0 &&
|
|
88
|
+
Number(value) <=
|
|
89
|
+
Math.min(100, Math.floor(1000 / this.#columns.length)))) ||
|
|
90
|
+
(name === 'row-height' && tableHeight(Number(value)) !== Number(value))))
|
|
91
|
+
this.invalidOption(name);
|
|
92
|
+
if (old !== value && (name === 'rows' || name === 'row-height')) {
|
|
93
|
+
this.clearSurface();
|
|
94
|
+
this.#updateStatic();
|
|
95
|
+
}
|
|
96
|
+
super.attributeChangedCallback(name, old, value);
|
|
97
|
+
}
|
|
98
|
+
connectedCallback() {
|
|
99
|
+
super.connectedCallback();
|
|
100
|
+
// Text metrics change once web fonts arrive. During a handoff the
|
|
101
|
+
// handoff watches its own content and targets for real size changes, so
|
|
102
|
+
// a font that moved nothing must not end it.
|
|
103
|
+
this.listen(this.ownerDocument.fonts, 'loadingdone', () => {
|
|
104
|
+
if (this.owner?.presentation === 'handoff')
|
|
105
|
+
return;
|
|
106
|
+
this.owner?.refresh();
|
|
107
|
+
this.refresh();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
update(patch) {
|
|
111
|
+
this.applyOptions(patch);
|
|
112
|
+
}
|
|
113
|
+
get optionNames() {
|
|
114
|
+
return [...super.optionNames, 'rows', 'rowHeight', 'columns'];
|
|
115
|
+
}
|
|
116
|
+
#updateStatic() {
|
|
117
|
+
const old = this.shadowRoot?.querySelector('[data-table-static]');
|
|
118
|
+
if (old)
|
|
119
|
+
old.replaceWith(staticTableSVG(this.ownerDocument, this.rows, this.rowHeight, this.columns));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export { staticTableLayout, } from './internal/table-model.js';
|
|
123
|
+
export function registerTableLoader() {
|
|
124
|
+
register('dotquilt-table-loader', TableLoader);
|
|
125
|
+
}
|
|
126
|
+
export { refreshStyles } from './internal/element.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnimationFactory } from './animations.js';
|
|
2
|
+
import { type TextMorphOptions } from './internal/text-morph.js';
|
|
3
|
+
export interface ScrambleOptions {
|
|
4
|
+
readonly changesPerSecond: number;
|
|
5
|
+
}
|
|
6
|
+
export interface LabelPulseOptions {
|
|
7
|
+
readonly travelPxPerSecond: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TextHandoffOptions {
|
|
10
|
+
readonly staggerMs: number;
|
|
11
|
+
readonly reelMs: number;
|
|
12
|
+
readonly settleMs: number;
|
|
13
|
+
readonly pop: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const scramble: AnimationFactory<"text", "idle", ScrambleOptions>;
|
|
16
|
+
/** Independent, deterministic character phases; rate applies to each character. */
|
|
17
|
+
export declare const scrambleCharacters: AnimationFactory<"text", "idle", ScrambleOptions>;
|
|
18
|
+
/** One whitespace-delimited mask word changes per step, in reading order. */
|
|
19
|
+
export declare const scrambleWords: AnimationFactory<"text", "idle", ScrambleOptions>;
|
|
20
|
+
export declare const labelPulse: AnimationFactory<"text", "idle", LabelPulseOptions>;
|
|
21
|
+
export type { TextMorphOptions };
|
|
22
|
+
/**
|
|
23
|
+
* The default handoff: the marks take the real characters' shapes, then the
|
|
24
|
+
* text wipes in along a soft front.
|
|
25
|
+
*/
|
|
26
|
+
export declare const morphWipe: AnimationFactory<"text", "handoff", TextMorphOptions>;
|
|
27
|
+
export declare const lock: AnimationFactory<"text", "handoff", TextHandoffOptions>;
|
|
28
|
+
export declare const printText: AnimationFactory<"text", "handoff", TextHandoffOptions>;
|
|
29
|
+
export declare const fade: AnimationFactory<"text", "handoff", {
|
|
30
|
+
readonly duration: number;
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fadeDefinition, labelPulseDefinition, lockDefinition, printDefinition, scrambleDefinition, textBinding, } from './internal/text-definitions.js';
|
|
2
|
+
import { textMorphDefinition, } from './internal/text-morph.js';
|
|
3
|
+
import { scrambleCharactersDefinition, scrambleWordsDefinition, } from './internal/text-scramble.js';
|
|
4
|
+
import { LoaderConfigurationError } from './types.js';
|
|
5
|
+
function factory(definition, schema) {
|
|
6
|
+
return (options = {}) => {
|
|
7
|
+
if (!options ||
|
|
8
|
+
Object.getPrototypeOf(options) !== Object.prototype ||
|
|
9
|
+
Object.keys(options).some((key) => !Object.hasOwn(schema, key)))
|
|
10
|
+
throw new LoaderConfigurationError('invalid-options', 'Invalid text animation options');
|
|
11
|
+
const parsed = {};
|
|
12
|
+
for (const key of Object.keys(schema)) {
|
|
13
|
+
const [fallback, min, max] = schema[key], value = options[key] ?? fallback;
|
|
14
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
15
|
+
throw new LoaderConfigurationError('invalid-options', 'Invalid text animation option');
|
|
16
|
+
parsed[String(key)] = Math.max(min, Math.min(max, value));
|
|
17
|
+
}
|
|
18
|
+
return textBinding(definition, parsed);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const scramble = /* @__PURE__ */ factory(scrambleDefinition, { changesPerSecond: [1000 / 280, 0.5, 4] });
|
|
22
|
+
/** Independent, deterministic character phases; rate applies to each character. */
|
|
23
|
+
export const scrambleCharacters = /* @__PURE__ */ factory(scrambleCharactersDefinition, { changesPerSecond: [2.8, 0.5, 4] });
|
|
24
|
+
/** One whitespace-delimited mask word changes per step, in reading order. */
|
|
25
|
+
export const scrambleWords = /* @__PURE__ */ factory(scrambleWordsDefinition, { changesPerSecond: [2.8, 0.5, 4] });
|
|
26
|
+
export const labelPulse = /* @__PURE__ */ factory(labelPulseDefinition, { travelPxPerSecond: [70, 20, 140] });
|
|
27
|
+
const handoffSchema = {
|
|
28
|
+
staggerMs: [40, 0, 60],
|
|
29
|
+
reelMs: [55, 0, 100],
|
|
30
|
+
settleMs: [300, 40, 400],
|
|
31
|
+
pop: [0, 0, 0.3],
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The default handoff: the marks take the real characters' shapes, then the
|
|
35
|
+
* text wipes in along a soft front.
|
|
36
|
+
*/
|
|
37
|
+
export const morphWipe = /* @__PURE__ */ factory(textMorphDefinition, { travel: [0.34, 0.2, 0.5], wipeStart: [0.46, 0.3, 0.6], edge: [36, 4, 80] });
|
|
38
|
+
export const lock = /* @__PURE__ */ factory(lockDefinition, handoffSchema);
|
|
39
|
+
export const printText = /* @__PURE__ */ factory(printDefinition, handoffSchema);
|
|
40
|
+
export const fade = /* @__PURE__ */ factory(fadeDefinition, { duration: [150, 0, 4000] });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { markColor, textMarkShapes } from './internal/marks.js';
|
|
2
|
+
import { regionCss } from './region-css.js';
|
|
3
|
+
export const textStyles = /* @__PURE__ */ Object.freeze([
|
|
4
|
+
regionCss +
|
|
5
|
+
':host{display:inline-grid;vertical-align:baseline;min-height:1em}:host .mask{display:block;min-height:1em;white-space:pre;opacity:.3;color:transparent;background:radial-gradient(circle,' +
|
|
6
|
+
markColor +
|
|
7
|
+
' 1px,#0000 0) 0 0/6px 6px}' +
|
|
8
|
+
textMarkShapes((mark) => `:host([mark=${mark}])`, '.mask') +
|
|
9
|
+
':host([data-dotquilt-waiting]) .mask,:host([data-dotquilt-waiting])>svg{visibility:hidden}:host ::slotted([slot=placeholder]){display:none}:host([data-custom][data-dotquilt-glyphs]) .mask{visibility:hidden}:host > svg{width:100%;height:100%;overflow:visible}@media(forced-colors:active){:host > svg{display:none}:host .mask{visibility:visible;border:1px dotted CanvasText}}',
|
|
10
|
+
]);
|
|
11
|
+
// Static rules also apply while the element's external stylesheet loads
|
|
12
|
+
// (`:state(unstyled)`); browsers without custom states ignore that part.
|
|
13
|
+
export const staticTextLoaderStyles =
|
|
14
|
+
/* @__PURE__ */ Object.freeze([
|
|
15
|
+
'dotquilt-text-loader:is(:not(:defined),:state(unstyled)){display:inline-grid;position:relative;min-height:1em}dotquilt-text-loader:is(:not(:defined),:state(unstyled))[hidden]{display:none}dotquilt-text-loader:is(:not(:defined),:state(unstyled))[state=pending]>:not([slot]){visibility:hidden}dotquilt-text-loader:is(:not(:defined),:state(unstyled))>[slot=placeholder]{grid-area:1/1;white-space:pre;color:transparent;opacity:.3;min-height:1em;background:radial-gradient(circle,' +
|
|
16
|
+
markColor +
|
|
17
|
+
' 1px,#0000 0) 0 0/6px 6px}dotquilt-text-loader:is(:not(:defined),:state(unstyled)):not([state=pending])>[slot=placeholder]{display:none}dotquilt-text-loader:is(:not(:defined),:state(unstyled))>:not([slot]){grid-area:1/1}@media(forced-colors:active){dotquilt-text-loader:is(:not(:defined),:state(unstyled))>[slot=placeholder]{border:1px dotted CanvasText}}',
|
|
18
|
+
]);
|
|
19
|
+
// A mark's rules ship only with markup that uses it (renderStatic), so pages
|
|
20
|
+
// without squares or dashes don't carry them.
|
|
21
|
+
export const staticTextLoaderMarkStyles =
|
|
22
|
+
/* @__PURE__ */ Object.freeze([
|
|
23
|
+
textMarkShapes((mark) => `dotquilt-text-loader:is(:not(:defined),:state(unstyled))[mark=${mark}]`, '>[slot=placeholder]'),
|
|
24
|
+
]);
|
package/dist/text.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
dotquilt-region:state(unstyled)::part(placeholder),dotquilt-region:state(unstyled)::part(refresh-indicator){visibility:hidden;pointer-events:none}dotquilt-region:state(unstyled)[data-presentation=pending]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=handoff]::part(placeholder),dotquilt-region:state(unstyled)[data-presentation=refreshing]::part(refresh-indicator){visibility:inherit}dotquilt-region:state(unstyled)[data-presentation=pending]::part(content){visibility:hidden}:host{display:grid;position:relative}:host(:focus){outline:none}:host(:focus-visible:not([data-dotquilt-focus=pointer])),:host([data-dotquilt-focus=""]:focus){outline:2px solid currentColor;outline-offset:3px}:host .f{display:grid;min-width:0;min-height:100%}:host [part]{display:block;grid-area:1/1;min-width:0}:host .p,:host .r{visibility:hidden;pointer-events:none}:host([data-presentation=pending]) .p,:host([data-presentation=handoff]) .p,:host([data-presentation=refreshing]) .r{visibility:inherit}:host([data-presentation=pending]) .c{visibility:hidden}:host([hidden]){display:none}:host > svg{position:absolute;inset:0;pointer-events:none}:host .fallback{display:block;min-height:1em;border:1px dotted currentColor}:host([data-dotquilt-waiting]) .p{visibility:hidden}:host{display:inline-grid;vertical-align:baseline;min-height:1em}:host .mask{display:block;min-height:1em;white-space:pre;opacity:.3;color:transparent;background:radial-gradient(circle,var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 1px,#0000 0) 0 0/6px 6px}:host([mark=square]) .mask{background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 0 0/6px 6px repeat;mask:linear-gradient(#0000 1.5px,#000 2.5px,#000 3.5px,#0000 4.5px),linear-gradient(90deg,#0000 1.5px,#000 2.5px,#000 3.5px,#0000 4.5px);mask-size:6px 6px;mask-position:0 0;mask-repeat:repeat;mask-composite:intersect}:host([mark=dash]) .mask{background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 0 0/6px 6px repeat;mask:radial-gradient(circle at 1.7px 3px,#000 0.3px,#0000 1.3px),radial-gradient(circle at 4.3px 3px,#000 0.3px,#0000 1.3px),linear-gradient(#0000 1.7px,#000 2.7px,#000 3.3px,#0000 4.3px),linear-gradient(90deg,#0000 1.2px,#000 2.2px,#000 3.8px,#0000 4.8px);mask-size:6px 6px;mask-position:0 0;mask-repeat:repeat;mask-composite:add,add,intersect}:host([data-dotquilt-waiting]) .mask,:host([data-dotquilt-waiting])>svg{visibility:hidden}:host ::slotted([slot=placeholder]){display:none}:host([data-custom][data-dotquilt-glyphs]) .mask{visibility:hidden}:host > svg{width:100%;height:100%;overflow:visible}@media(forced-colors:active){:host > svg{display:none}:host .mask{visibility:visible;border:1px dotted CanvasText}}
|
|
2
|
+
dotquilt-text-loader:is(:not(:defined),:state(unstyled)){display:inline-grid;position:relative;min-height:1em}dotquilt-text-loader:is(:not(:defined),:state(unstyled))[hidden]{display:none}dotquilt-text-loader:is(:not(:defined),:state(unstyled))[state=pending]>:not([slot]){visibility:hidden}dotquilt-text-loader:is(:not(:defined),:state(unstyled))>[slot=placeholder]{grid-area:1/1;white-space:pre;color:transparent;opacity:.3;min-height:1em;background:radial-gradient(circle,var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 1px,#0000 0) 0 0/6px 6px}dotquilt-text-loader:is(:not(:defined),:state(unstyled)):not([state=pending])>[slot=placeholder]{display:none}dotquilt-text-loader:is(:not(:defined),:state(unstyled))>:not([slot]){grid-area:1/1}@media(forced-colors:active){dotquilt-text-loader:is(:not(:defined),:state(unstyled))>[slot=placeholder]{border:1px dotted CanvasText}}
|
|
3
|
+
dotquilt-text-loader:is(:not(:defined),:state(unstyled))[mark=square] >[slot=placeholder]{background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 0 0/6px 6px repeat;mask:linear-gradient(#0000 1.5px,#000 2.5px,#000 3.5px,#0000 4.5px),linear-gradient(90deg,#0000 1.5px,#000 2.5px,#000 3.5px,#0000 4.5px);mask-size:6px 6px;mask-position:0 0;mask-repeat:repeat;mask-composite:intersect}dotquilt-text-loader:is(:not(:defined),:state(unstyled))[mark=dash] >[slot=placeholder]{background:var(--dotquilt-color,light-dark(#6e7889,#a3afc2)) 0 0/6px 6px repeat;mask:radial-gradient(circle at 1.7px 3px,#000 0.3px,#0000 1.3px),radial-gradient(circle at 4.3px 3px,#000 0.3px,#0000 1.3px),linear-gradient(#0000 1.7px,#000 2.7px,#000 3.3px,#0000 4.3px),linear-gradient(90deg,#0000 1.2px,#000 2.2px,#000 3.8px,#0000 4.8px);mask-size:6px 6px;mask-position:0 0;mask-repeat:repeat;mask-composite:add,add,intersect}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AnimationSurface, Animations } from './animations.js';
|
|
2
|
+
import type { HandoffSource } from './internal/handoff.js';
|
|
3
|
+
import { LoadingController } from './internal/loading-controller.js';
|
|
4
|
+
import type { Preset } from './internal/preset.js';
|
|
5
|
+
import { readSurface } from './internal/surface.js';
|
|
6
|
+
export type TextPreset = import('./internal/preset.js').Preset<'text'>;
|
|
7
|
+
export declare class TextLoader extends LoadingController<'text'> {
|
|
8
|
+
#private;
|
|
9
|
+
protected upgrade(): void;
|
|
10
|
+
protected capturePreset(value: Preset<'text'>): Preset<'text'>;
|
|
11
|
+
static observedAttributes: string[];
|
|
12
|
+
protected get family(): 'text';
|
|
13
|
+
protected get styles(): readonly string[];
|
|
14
|
+
protected handoffSource(): HandoffSource;
|
|
15
|
+
get activity(): import("./internal/element.js").Activity;
|
|
16
|
+
get animations(): Animations<'text'>;
|
|
17
|
+
set animations(value: Animations<'text'> | undefined);
|
|
18
|
+
update(patch: Parameters<LoadingController<'text'>['update']>[0] & {
|
|
19
|
+
readonly mask?: string | undefined;
|
|
20
|
+
readonly speed?: number | undefined;
|
|
21
|
+
readonly pointerResponse?: 'none' | 'lift' | undefined;
|
|
22
|
+
readonly preset?: TextPreset | undefined;
|
|
23
|
+
}): void;
|
|
24
|
+
protected get optionNames(): readonly string[];
|
|
25
|
+
get mask(): string | undefined;
|
|
26
|
+
set mask(value: string | undefined);
|
|
27
|
+
get speed(): number;
|
|
28
|
+
set speed(value: number | undefined);
|
|
29
|
+
get pointerResponse(): 'none' | 'lift';
|
|
30
|
+
set pointerResponse(value: 'none' | 'lift' | undefined);
|
|
31
|
+
protected presetChanged(): void;
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
disconnectedCallback(): void;
|
|
34
|
+
protected environmentChanged(): void;
|
|
35
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
36
|
+
refresh(): void;
|
|
37
|
+
protected contentChanged(): void;
|
|
38
|
+
protected settled(): void;
|
|
39
|
+
[readSurface](_family: 'text', ids?: readonly string[]): AnimationSurface<'text'>;
|
|
40
|
+
protected render(): void;
|
|
41
|
+
}
|
|
42
|
+
export declare function registerTextLoader(): void;
|