@daasboard/ui 0.0.0-stage → 0.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/LICENSE +5 -0
- package/README.md +6 -2
- package/dist/LICENSE-lucide.txt +43 -0
- package/dist/color/color.d.ts +34 -0
- package/dist/color/color.js +106 -0
- package/dist/color/edit.d.ts +34 -0
- package/dist/color/edit.js +40 -0
- package/dist/color/gradient.d.ts +39 -0
- package/dist/color/gradient.js +129 -0
- package/dist/color/index.d.ts +3 -0
- package/dist/color/index.js +3 -0
- package/dist/controls/buttons.d.ts +54 -0
- package/dist/controls/buttons.js +95 -0
- package/dist/controls/font-picker.d.ts +35 -0
- package/dist/controls/font-picker.js +178 -0
- package/dist/controls/index.d.ts +43 -0
- package/dist/controls/index.js +32 -0
- package/dist/controls/number-field.d.ts +60 -0
- package/dist/controls/number-field.js +190 -0
- package/dist/controls/place.d.ts +10 -0
- package/dist/controls/place.js +77 -0
- package/dist/controls/popover.d.ts +84 -0
- package/dist/controls/popover.js +366 -0
- package/dist/controls/shared.d.ts +30 -0
- package/dist/controls/shared.js +134 -0
- package/dist/controls/slider.d.ts +82 -0
- package/dist/controls/slider.js +241 -0
- package/dist/controls/swatch.d.ts +25 -0
- package/dist/controls/swatch.js +38 -0
- package/dist/controls/tooltip.d.ts +19 -0
- package/dist/controls/tooltip.js +84 -0
- package/dist/controls/typed.d.ts +28 -0
- package/dist/controls/typed.js +126 -0
- package/dist/element.d.ts +40 -0
- package/dist/element.js +78 -0
- package/dist/host.d.ts +99 -0
- package/dist/host.js +1 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/icons/index.js +31 -0
- package/dist/icons/lucide.d.ts +851 -0
- package/dist/icons/lucide.js +90 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +16 -0
- package/dist/keys.d.ts +30 -0
- package/dist/keys.js +122 -0
- package/dist/mount.d.ts +11 -0
- package/dist/mount.js +96 -0
- package/dist/options.d.ts +152 -0
- package/dist/options.js +78 -0
- package/dist/palette.d.ts +6 -0
- package/dist/palette.js +9 -0
- package/dist/picker/handles.d.ts +7 -0
- package/dist/picker/handles.js +8 -0
- package/dist/picker/index.d.ts +21 -0
- package/dist/picker/index.js +20 -0
- package/dist/picker/palette.d.ts +8 -0
- package/dist/picker/palette.js +14 -0
- package/dist/picker/picker.d.ts +63 -0
- package/dist/picker/picker.js +561 -0
- package/dist/picker/solid-editor.d.ts +60 -0
- package/dist/picker/solid-editor.js +330 -0
- package/dist/picker/stop-bar.d.ts +27 -0
- package/dist/picker/stop-bar.js +140 -0
- package/dist/prefs.d.ts +6 -0
- package/dist/prefs.js +34 -0
- package/dist/recents.d.ts +9 -0
- package/dist/recents.js +140 -0
- package/dist/root.d.ts +31 -0
- package/dist/root.js +526 -0
- package/dist/scheduler.d.ts +21 -0
- package/dist/scheduler.js +132 -0
- package/dist/strings.d.ts +284 -0
- package/dist/strings.js +287 -0
- package/dist/surface.d.ts +27 -0
- package/dist/surface.js +8 -0
- package/dist/surfaces/context-menu/index.d.ts +2 -0
- package/dist/surfaces/context-menu/index.js +2 -0
- package/dist/surfaces/context-menu/items.d.ts +14 -0
- package/dist/surfaces/context-menu/items.js +38 -0
- package/dist/surfaces/context-menu/menu.d.ts +16 -0
- package/dist/surfaces/context-menu/menu.js +135 -0
- package/dist/surfaces/pane/index.d.ts +16 -0
- package/dist/surfaces/pane/index.js +19 -0
- package/dist/surfaces/pane/model.d.ts +41 -0
- package/dist/surfaces/pane/model.js +139 -0
- package/dist/surfaces/pane/outlet.d.ts +16 -0
- package/dist/surfaces/pane/outlet.js +20 -0
- package/dist/surfaces/pane/pane.d.ts +40 -0
- package/dist/surfaces/pane/pane.js +1429 -0
- package/dist/surfaces/pane/placement.d.ts +11 -0
- package/dist/surfaces/pane/placement.js +62 -0
- package/dist/surfaces/pane/text-field.d.ts +16 -0
- package/dist/surfaces/pane/text-field.js +20 -0
- package/dist/surfaces/selection-toolbar/index.d.ts +2 -0
- package/dist/surfaces/selection-toolbar/index.js +2 -0
- package/dist/surfaces/selection-toolbar/items.d.ts +37 -0
- package/dist/surfaces/selection-toolbar/items.js +183 -0
- package/dist/surfaces/selection-toolbar/toolbar.d.ts +27 -0
- package/dist/surfaces/selection-toolbar/toolbar.js +956 -0
- package/dist/surfaces/tools/index.d.ts +2 -0
- package/dist/surfaces/tools/index.js +2 -0
- package/dist/surfaces/tools/keys.d.ts +11 -0
- package/dist/surfaces/tools/keys.js +21 -0
- package/dist/surfaces/tools/model.d.ts +48 -0
- package/dist/surfaces/tools/model.js +155 -0
- package/dist/surfaces/tools/toolbar.d.ts +27 -0
- package/dist/surfaces/tools/toolbar.js +502 -0
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +47 -0
- package/package.json +31 -3
package/dist/options.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { memoryPrefs } from "./prefs.js";
|
|
2
|
+
import { Strings } from "./strings.js";
|
|
3
|
+
export const GRADIENT_TYPES = ["linear", "radial"];
|
|
4
|
+
export const COLOR_FORMATS = ["hex", "rgb", "hsl"];
|
|
5
|
+
export const PICKER_MODES = ["palette", "space"];
|
|
6
|
+
const SURFACE_GRADIENTS = { selectionToolbar: false, pane: true };
|
|
7
|
+
const PAINT_TYPES = new Set(["paint", "paints"]);
|
|
8
|
+
const DEFAULT_RECENTS_MAX = 16;
|
|
9
|
+
const THEME_NAMES = new Set(["light", "dark", "auto"]);
|
|
10
|
+
export function resolveOptions(o, fallbackPrefs = memoryPrefs()) {
|
|
11
|
+
const theme = o.theme ?? "auto";
|
|
12
|
+
return {
|
|
13
|
+
theme: typeof theme === "string" && THEME_NAMES.has(theme) ? theme : "auto",
|
|
14
|
+
tokens: typeof theme === "object" && theme !== null ? theme : null,
|
|
15
|
+
density: o.density === "compact" ? "compact" : "comfortable",
|
|
16
|
+
strings: new Strings(o.strings),
|
|
17
|
+
icons: o.icons ?? {},
|
|
18
|
+
shortcuts: o.shortcuts ?? {},
|
|
19
|
+
prefs: o.prefs ?? fallbackPrefs,
|
|
20
|
+
color: o.color ?? {},
|
|
21
|
+
toolbar: o.toolbar === false ? false : (o.toolbar ?? {}),
|
|
22
|
+
selectionToolbar: o.selectionToolbar === false ? false : (o.selectionToolbar ?? {}),
|
|
23
|
+
pane: o.pane === true ? {} : o.pane === false || o.pane === undefined ? false : o.pane,
|
|
24
|
+
contextMenu: o.contextMenu !== false,
|
|
25
|
+
controls: o.controls ?? {},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function mergeOptions(base, partial) {
|
|
29
|
+
return merge(base, partial);
|
|
30
|
+
}
|
|
31
|
+
const STORES = new Set(["prefs", "store"]);
|
|
32
|
+
function merge(base, next) {
|
|
33
|
+
if (next === undefined || (next === true && isRecord(base)))
|
|
34
|
+
return base;
|
|
35
|
+
if (!isRecord(base) || !isRecord(next))
|
|
36
|
+
return next;
|
|
37
|
+
const out = { ...base };
|
|
38
|
+
for (const [k, v] of Object.entries(next)) {
|
|
39
|
+
if (k === "__proto__")
|
|
40
|
+
continue;
|
|
41
|
+
out[k] = STORES.has(k) && v !== undefined ? v : merge(out[k], v);
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
function isRecord(v) {
|
|
46
|
+
if (typeof v !== "object" || v === null)
|
|
47
|
+
return false;
|
|
48
|
+
const proto = Object.getPrototypeOf(v);
|
|
49
|
+
return proto === null || Object.getPrototypeOf(proto) === null;
|
|
50
|
+
}
|
|
51
|
+
export function colorOptionsFor(resolved, surface) {
|
|
52
|
+
const own = surface === "pane" ? (resolved.pane === false ? undefined : resolved.pane.color) : resolved.selectionToolbar === false ? undefined : resolved.selectionToolbar.color;
|
|
53
|
+
const c = own ? merge(resolved.color, own) : resolved.color;
|
|
54
|
+
const gradients = c.gradients ?? SURFACE_GRADIENTS[surface];
|
|
55
|
+
const recents = c.recents ?? {};
|
|
56
|
+
return {
|
|
57
|
+
gradients: gradients === true ? GRADIENT_TYPES : gradients === false ? [] : known(gradients, GRADIENT_TYPES, []),
|
|
58
|
+
alpha: c.alpha ?? true,
|
|
59
|
+
formats: known(c.formats, COLOR_FORMATS, COLOR_FORMATS),
|
|
60
|
+
modes: known(c.modes, PICKER_MODES, PICKER_MODES),
|
|
61
|
+
palette: c.palette,
|
|
62
|
+
recents: recents === false
|
|
63
|
+
? false
|
|
64
|
+
: { max: Math.max(0, Math.floor(recents.max ?? DEFAULT_RECENTS_MAX)), ...(recents.store ? { store: recents.store } : {}) },
|
|
65
|
+
eyedropper: c.eyedropper ?? true,
|
|
66
|
+
tokens: c.tokens ?? true,
|
|
67
|
+
canvasHandles: c.canvasHandles ?? true,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function known(list, all, empty) {
|
|
71
|
+
if (!list)
|
|
72
|
+
return all;
|
|
73
|
+
const kept = [...new Set(list)].filter((v) => all.includes(v));
|
|
74
|
+
return kept.length > 0 ? kept : empty;
|
|
75
|
+
}
|
|
76
|
+
export function gradientsFor(color, descriptorType) {
|
|
77
|
+
return PAINT_TYPES.has(descriptorType) ? color.gradients : [];
|
|
78
|
+
}
|
package/dist/palette.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultStyle } from "@daasboard/editor";
|
|
2
|
+
export const STICKY_COLORS = [
|
|
3
|
+
{ color: defaultStyle("sticky").fill, label: "sticky.yellow" },
|
|
4
|
+
{ color: "#fecaca", label: "sticky.red" },
|
|
5
|
+
{ color: "#fed7aa", label: "sticky.orange" },
|
|
6
|
+
{ color: "#bbf7d0", label: "sticky.green" },
|
|
7
|
+
{ color: "#bfdbfe", label: "sticky.blue" },
|
|
8
|
+
{ color: "#ddd6fe", label: "sticky.violet" },
|
|
9
|
+
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UiGradientHandleEvents, UiGradientHandles, UiGradientTarget, UiHost } from "../host.js";
|
|
2
|
+
export interface CanvasHandles {
|
|
3
|
+
readonly target: UiGradientTarget;
|
|
4
|
+
show(events: UiGradientHandleEvents): UiGradientHandles | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function canvasHandles(host: Pick<UiHost, "gradientHandles">, target: UiGradientTarget | null): CanvasHandles | null;
|
|
7
|
+
export declare const sameTarget: (a: CanvasHandles | null, b: CanvasHandles | null) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function canvasHandles(host, target) {
|
|
2
|
+
const gradientHandles = host.gradientHandles;
|
|
3
|
+
if (!gradientHandles || !target)
|
|
4
|
+
return null;
|
|
5
|
+
const t = target.layer === undefined ? { id: target.id } : { id: target.id, layer: target.layer };
|
|
6
|
+
return { target: t, show: (events) => gradientHandles.call(host, t, events) };
|
|
7
|
+
}
|
|
8
|
+
export const sameTarget = (a, b) => a === b || (!!a && !!b && a.target.id === b.target.id && a.target.layer === b.target.layer);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PaintPicker } from "./picker.js";
|
|
2
|
+
import { SolidEditor } from "./solid-editor.js";
|
|
3
|
+
import { StopBar } from "./stop-bar.js";
|
|
4
|
+
export { PaintPicker, DEFAULT_PICKER_OPTIONS, pickerTypes } from "./picker.js";
|
|
5
|
+
export { canvasHandles, type CanvasHandles } from "./handles.js";
|
|
6
|
+
export { SolidEditor, MODE_PREF, eyeDropper } from "./solid-editor.js";
|
|
7
|
+
export { StopBar, STOP_SELECT } from "./stop-bar.js";
|
|
8
|
+
export { DEFAULT_PALETTE, paletteGroups, type PaletteGroup } from "./palette.js";
|
|
9
|
+
export declare const PICKER_TAGS: {
|
|
10
|
+
readonly "daas-solid-editor": typeof SolidEditor;
|
|
11
|
+
readonly "daas-stop-bar": typeof StopBar;
|
|
12
|
+
readonly "daas-paint-picker": typeof PaintPicker;
|
|
13
|
+
};
|
|
14
|
+
export declare function definePicker(): void;
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
"daas-solid-editor": SolidEditor;
|
|
18
|
+
"daas-stop-bar": StopBar;
|
|
19
|
+
"daas-paint-picker": PaintPicker;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineControls } from "../controls/index.js";
|
|
2
|
+
import { PaintPicker } from "./picker.js";
|
|
3
|
+
import { SolidEditor } from "./solid-editor.js";
|
|
4
|
+
import { StopBar } from "./stop-bar.js";
|
|
5
|
+
export { PaintPicker, DEFAULT_PICKER_OPTIONS, pickerTypes } from "./picker.js";
|
|
6
|
+
export { canvasHandles } from "./handles.js";
|
|
7
|
+
export { SolidEditor, MODE_PREF, eyeDropper } from "./solid-editor.js";
|
|
8
|
+
export { StopBar, STOP_SELECT } from "./stop-bar.js";
|
|
9
|
+
export { DEFAULT_PALETTE, paletteGroups } from "./palette.js";
|
|
10
|
+
export const PICKER_TAGS = {
|
|
11
|
+
"daas-solid-editor": SolidEditor,
|
|
12
|
+
"daas-stop-bar": StopBar,
|
|
13
|
+
"daas-paint-picker": PaintPicker,
|
|
14
|
+
};
|
|
15
|
+
export function definePicker() {
|
|
16
|
+
defineControls();
|
|
17
|
+
for (const [tag, cls] of Object.entries(PICKER_TAGS))
|
|
18
|
+
if (!customElements.get(tag))
|
|
19
|
+
customElements.define(tag, cls);
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColorOptions } from "../options.js";
|
|
2
|
+
export interface PaletteGroup {
|
|
3
|
+
name: string;
|
|
4
|
+
colors: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const PALETTE_COLUMNS = 10;
|
|
7
|
+
export declare const DEFAULT_PALETTE: readonly string[];
|
|
8
|
+
export declare function paletteGroups(palette: ColorOptions["palette"]): readonly PaletteGroup[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const PALETTE_COLUMNS = 10;
|
|
2
|
+
export const DEFAULT_PALETTE = [
|
|
3
|
+
"#000000", "#343a40", "#495057", "#868e96", "#adb5bd", "#ced4da", "#dee2e6", "#e9ecef", "#f8f9fa", "#ffffff",
|
|
4
|
+
"#e03131", "#f76707", "#f59f00", "#fcc419", "#37b24d", "#0ca678", "#1098ad", "#1c7ed6", "#4263eb", "#ae3ec9",
|
|
5
|
+
"#ffc9c9", "#ffd8a8", "#ffec99", "#fff3bf", "#b2f2bb", "#96f2d7", "#99e9f2", "#a5d8ff", "#bac8ff", "#eebefa",
|
|
6
|
+
"#a61e1e", "#c2410c", "#b45309", "#a16207", "#2b8a3e", "#087f5b", "#0b7285", "#1864ab", "#364fc7", "#862e9c",
|
|
7
|
+
];
|
|
8
|
+
export function paletteGroups(palette) {
|
|
9
|
+
if (!palette || palette.length === 0)
|
|
10
|
+
return [{ name: "", colors: DEFAULT_PALETTE }];
|
|
11
|
+
if (typeof palette[0] === "string")
|
|
12
|
+
return [{ name: "", colors: palette }];
|
|
13
|
+
return palette;
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FillPaint } from "@daasboard/editor";
|
|
2
|
+
import { type TemplateResult } from "lit";
|
|
3
|
+
import { type Box, type PaintType } from "../color/gradient.js";
|
|
4
|
+
import { UiElement } from "../element.js";
|
|
5
|
+
import { type RecentsStore, type ResolvedColorOptions } from "../options.js";
|
|
6
|
+
import { type CanvasHandles } from "./handles.js";
|
|
7
|
+
export declare const DEFAULT_PICKER_OPTIONS: ResolvedColorOptions;
|
|
8
|
+
export declare function pickerTypes(color: ResolvedColorOptions, descriptorType: string): PaintType[];
|
|
9
|
+
export declare class PaintPicker extends UiElement {
|
|
10
|
+
#private;
|
|
11
|
+
static styles: import("lit").CSSResult[];
|
|
12
|
+
static properties: {
|
|
13
|
+
value: {
|
|
14
|
+
attribute: boolean;
|
|
15
|
+
};
|
|
16
|
+
mixed: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
};
|
|
19
|
+
box: {
|
|
20
|
+
attribute: boolean;
|
|
21
|
+
};
|
|
22
|
+
types: {
|
|
23
|
+
attribute: boolean;
|
|
24
|
+
};
|
|
25
|
+
color: {
|
|
26
|
+
attribute: boolean;
|
|
27
|
+
};
|
|
28
|
+
allowNone: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
attribute: string;
|
|
31
|
+
};
|
|
32
|
+
recents: {
|
|
33
|
+
attribute: boolean;
|
|
34
|
+
};
|
|
35
|
+
handles: {
|
|
36
|
+
attribute: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
value: FillPaint | null;
|
|
40
|
+
mixed: boolean;
|
|
41
|
+
box: Box;
|
|
42
|
+
types: readonly PaintType[];
|
|
43
|
+
color: ResolvedColorOptions | null;
|
|
44
|
+
allowNone: boolean;
|
|
45
|
+
recents: RecentsStore | null;
|
|
46
|
+
handles: CanvasHandles | null;
|
|
47
|
+
constructor();
|
|
48
|
+
connectedCallback(): void;
|
|
49
|
+
disconnectedCallback(): void;
|
|
50
|
+
endSession(): void;
|
|
51
|
+
settleRecent(): void;
|
|
52
|
+
get current(): FillPaint | null;
|
|
53
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
54
|
+
protected updated(): void;
|
|
55
|
+
revert(): void;
|
|
56
|
+
settle(): void;
|
|
57
|
+
solidRelay(stop: number | null): {
|
|
58
|
+
preview: (e: CustomEvent<string | null>) => void;
|
|
59
|
+
commit: (e: CustomEvent<string | null>) => void;
|
|
60
|
+
cancel: (e: Event) => void;
|
|
61
|
+
};
|
|
62
|
+
protected render(): TemplateResult<1>;
|
|
63
|
+
}
|