uicore-ts 1.1.201 → 1.1.202
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.
|
@@ -5,25 +5,11 @@ export interface UIColorDescriptor {
|
|
|
5
5
|
blue: number;
|
|
6
6
|
alpha?: number;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
* Extend this interface via declaration merging in UIColor subclass files
|
|
10
|
-
* to register valid semantic key strings for autocomplete and type safety.
|
|
11
|
-
*
|
|
12
|
-
* Example (in BSColor.ts):
|
|
13
|
-
* declare module "./UIColor" {
|
|
14
|
-
* interface UIColorSemanticKeys {
|
|
15
|
-
* primary: never
|
|
16
|
-
* success: never
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
|
-
export interface UIColorSemanticKeys {
|
|
21
|
-
}
|
|
22
|
-
export type UIColorSemanticKey = keyof UIColorSemanticKeys;
|
|
8
|
+
export type UIColorSemanticKey = string;
|
|
23
9
|
export declare class UIColor extends UIObject {
|
|
24
10
|
static _liveColors: WeakRef<UIColor>[];
|
|
25
11
|
static _registrationMap: Map<string, UIColor>;
|
|
26
|
-
static _cssSubscriptions: Map<
|
|
12
|
+
static _cssSubscriptions: Map<string, Set<() => void>>;
|
|
27
13
|
stringValue: string;
|
|
28
14
|
semanticKey?: UIColorSemanticKey;
|
|
29
15
|
_semanticClass?: typeof UIColor;
|
|
@@ -51,6 +37,13 @@ export declare class UIColor extends UIObject {
|
|
|
51
37
|
* whose semantic key was affected.
|
|
52
38
|
*/
|
|
53
39
|
static applySemanticColors(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Updates the backing field for a semantic color and re-applies all live
|
|
42
|
+
* semantic colors. The backing field is always `_` + semanticKey, e.g.
|
|
43
|
+
* `BSColor.updateSemanticColor("primary", "#ff0000")` sets `BSColor._primary`.
|
|
44
|
+
* Called as a static method on the subclass that owns the color.
|
|
45
|
+
*/
|
|
46
|
+
static updateSemanticColor(semanticKey: UIColorSemanticKey, value: string): void;
|
|
54
47
|
/**
|
|
55
48
|
* Registers a callback to be fired when applySemanticColors() affects
|
|
56
49
|
* the given semantic key. Intended for injected CSS blocks that cannot
|
|
@@ -76,6 +76,10 @@ const _UIColor = class extends import_UIObject.UIObject {
|
|
|
76
76
|
(_a = _UIColor._cssSubscriptions.get(key)) == null ? void 0 : _a.forEach((callback) => callback());
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
static updateSemanticColor(semanticKey, value) {
|
|
80
|
+
this["_" + semanticKey] = value;
|
|
81
|
+
_UIColor.applySemanticColors();
|
|
82
|
+
}
|
|
79
83
|
static subscribe(semanticKey, callback) {
|
|
80
84
|
if (!_UIColor._cssSubscriptions.has(semanticKey)) {
|
|
81
85
|
_UIColor._cssSubscriptions.set(semanticKey, /* @__PURE__ */ new Set());
|
|
@@ -337,8 +341,11 @@ const _UIColor = class extends import_UIObject.UIObject {
|
|
|
337
341
|
return result;
|
|
338
342
|
}
|
|
339
343
|
static colorWithDescriptor(descriptor) {
|
|
340
|
-
const
|
|
341
|
-
|
|
344
|
+
const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0);
|
|
345
|
+
const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0);
|
|
346
|
+
const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0);
|
|
347
|
+
const alpha = this.defaultAlphaToOne(descriptor.alpha);
|
|
348
|
+
return new _UIColor("rgba(" + red + "," + green + "," + blue + "," + alpha + ")");
|
|
342
349
|
}
|
|
343
350
|
static defaultAlphaToOne(value = 1) {
|
|
344
351
|
if (value != value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIColor.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIObject } from \"./UIObject\"\n\n\nexport interface UIColorDescriptor {\n \n red: number;\n green: number;\n blue: number;\n alpha?: number;\n \n}\n\n\n/**\n * Extend this interface via declaration merging in UIColor subclass files\n * to register valid semantic key strings for autocomplete and type safety.\n *\n * Example (in BSColor.ts):\n * declare module \"./UIColor\" {\n * interface UIColorSemanticKeys {\n * primary: never\n * success: never\n * }\n * }\n */\nexport interface UIColorSemanticKeys {}\n\nexport type UIColorSemanticKey = keyof UIColorSemanticKeys\n\n\nexport class UIColor extends UIObject {\n \n \n // --- Semantic color registry ---\n \n static _liveColors: WeakRef<UIColor>[] = []\n static _registrationMap = new Map<string, UIColor>()\n static _cssSubscriptions = new Map<UIColorSemanticKey, Set<() => void>>()\n \n \n // --- Instance fields ---\n \n stringValue: string\n semanticKey?: UIColorSemanticKey\n _semanticClass?: typeof UIColor\n _elementRef?: HTMLElement\n _styleProperty?: string\n \n \n constructor(stringValue: string, semanticKey?: UIColorSemanticKey) {\n \n super()\n \n this.stringValue = stringValue\n this.semanticKey = semanticKey\n if (semanticKey) {\n this._semanticClass = this.constructor as typeof UIColor\n }\n \n }\n \n \n override toString() {\n return this.stringValue\n }\n \n \n // --- Semantic apply ---\n \n /**\n * Re-resolves this instance's stringValue from its class's static getter\n * matching the semanticKey, then writes the new value directly to the DOM\n * via the stored element reference and style property.\n * No-op if this instance has no semanticKey.\n */\n apply() {\n \n if (!this.semanticKey) { return }\n \n const colorClass = this._semanticClass ?? this.constructor as typeof UIColor\n const newColor = (colorClass as any)[this.semanticKey] as UIColor | undefined\n \n if (!newColor) { return }\n \n this.stringValue = newColor.stringValue\n \n const element = this._elementRef\n \n if (!element || !this._styleProperty) { return }\n \n (element.style as any)[this._styleProperty] = this.stringValue\n \n }\n \n \n /**\n * Assigns a semantic key and the class that owns it to this color instance.\n * Intended for derived colors that should participate in theme switching,\n * e.g. `BSColor._primaryBase.colorWithAlpha(0.5).withSemanticKey(\"primaryShadow\", BSColor)`.\n * Returns `this` for fluent chaining.\n */\n withSemanticKey(semanticKey: UIColorSemanticKey, semanticClass: typeof UIColor): this {\n this.semanticKey = semanticKey\n this._semanticClass = semanticClass\n return this\n }\n \n \n /**\n * Iterates all live registered UIColor instances, calls apply() on each,\n * compacts dead WeakRefs in the same pass, then fires any CSS subscriptions\n * whose semantic key was affected.\n */\n static applySemanticColors() {\n \n const affectedKeys = new Set<UIColorSemanticKey>()\n \n const live: WeakRef<UIColor>[] = []\n \n for (const ref of UIColor._liveColors) {\n \n const color = ref.deref()\n \n if (!color) {\n continue\n }\n \n live.push(ref)\n \n if (color.semanticKey) {\n affectedKeys.add(color.semanticKey)\n }\n \n color.apply()\n \n }\n \n UIColor._liveColors = live\n \n for (const key of affectedKeys) {\n UIColor._cssSubscriptions.get(key)?.forEach(callback => callback())\n }\n \n }\n \n \n /**\n * Registers a callback to be fired when applySemanticColors() affects\n * the given semantic key. Intended for injected CSS blocks that cannot\n * be tracked via the colorStyleProxy.\n */\n static subscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n \n if (!UIColor._cssSubscriptions.has(semanticKey)) {\n UIColor._cssSubscriptions.set(semanticKey, new Set())\n }\n \n UIColor._cssSubscriptions.get(semanticKey)!.add(callback)\n \n }\n \n \n static unsubscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n UIColor._cssSubscriptions.get(semanticKey)?.delete(callback)\n }\n \n \n // --- Named colors ---\n \n static get redColor() {\n return new UIColor(\"red\")\n }\n \n static get blueColor() {\n return new UIColor(\"blue\")\n }\n \n static get greenColor() {\n return new UIColor(\"green\")\n }\n \n static get yellowColor() {\n return new UIColor(\"yellow\")\n }\n \n static get blackColor() {\n return new UIColor(\"black\")\n }\n \n static get brownColor() {\n return new UIColor(\"brown\")\n }\n \n static get whiteColor() {\n return new UIColor(\"white\")\n }\n \n static get greyColor() {\n return new UIColor(\"grey\")\n }\n \n static get lightGreyColor() {\n return new UIColor(\"lightgrey\")\n }\n \n static get transparentColor() {\n return new UIColor(\"transparent\")\n }\n \n static get clearColor() {\n return new UIColor(\"transparent\")\n }\n \n static get undefinedColor() {\n return new UIColor(\"\")\n }\n \n static get nilColor() {\n return new UIColor(\"\")\n }\n \n \n static nameToHex(name: string) {\n return {\n \"aliceblue\": \"#f0f8ff\",\n \"antiquewhite\": \"#faebd7\",\n \"aqua\": \"#00ffff\",\n \"aquamarine\": \"#7fffd4\",\n \"azure\": \"#f0ffff\",\n \"beige\": \"#f5f5dc\",\n \"bisque\": \"#ffe4c4\",\n \"black\": \"#000000\",\n \"blanchedalmond\": \"#ffebcd\",\n \"blue\": \"#0000ff\",\n \"blueviolet\": \"#8a2be2\",\n \"brown\": \"#a52a2a\",\n \"burlywood\": \"#deb887\",\n \"cadetblue\": \"#5f9ea0\",\n \"chartreuse\": \"#7fff00\",\n \"chocolate\": \"#d2691e\",\n \"coral\": \"#ff7f50\",\n \"cornflowerblue\": \"#6495ed\",\n \"cornsilk\": \"#fff8dc\",\n \"crimson\": \"#dc143c\",\n \"cyan\": \"#00ffff\",\n \"darkblue\": \"#00008b\",\n \"darkcyan\": \"#008b8b\",\n \"darkgoldenrod\": \"#b8860b\",\n \"darkgray\": \"#a9a9a9\",\n \"darkgreen\": \"#006400\",\n \"darkkhaki\": \"#bdb76b\",\n \"darkmagenta\": \"#8b008b\",\n \"darkolivegreen\": \"#556b2f\",\n \"darkorange\": \"#ff8c00\",\n \"darkorchid\": \"#9932cc\",\n \"darkred\": \"#8b0000\",\n \"darksalmon\": \"#e9967a\",\n \"darkseagreen\": \"#8fbc8f\",\n \"darkslateblue\": \"#483d8b\",\n \"darkslategray\": \"#2f4f4f\",\n \"darkturquoise\": \"#00ced1\",\n \"darkviolet\": \"#9400d3\",\n \"deeppink\": \"#ff1493\",\n \"deepskyblue\": \"#00bfff\",\n \"dimgray\": \"#696969\",\n \"dodgerblue\": \"#1e90ff\",\n \"firebrick\": \"#b22222\",\n \"floralwhite\": \"#fffaf0\",\n \"forestgreen\": \"#228b22\",\n \"fuchsia\": \"#ff00ff\",\n \"gainsboro\": \"#dcdcdc\",\n \"ghostwhite\": \"#f8f8ff\",\n \"gold\": \"#ffd700\",\n \"goldenrod\": \"#daa520\",\n \"gray\": \"#808080\",\n \"green\": \"#008000\",\n \"greenyellow\": \"#adff2f\",\n \"honeydew\": \"#f0fff0\",\n \"hotpink\": \"#ff69b4\",\n \"indianred \": \"#cd5c5c\",\n \"indigo\": \"#4b0082\",\n \"ivory\": \"#fffff0\",\n \"khaki\": \"#f0e68c\",\n \"lavender\": \"#e6e6fa\",\n \"lavenderblush\": \"#fff0f5\",\n \"lawngreen\": \"#7cfc00\",\n \"lemonchiffon\": \"#fffacd\",\n \"lightblue\": \"#add8e6\",\n \"lightcoral\": \"#f08080\",\n \"lightcyan\": \"#e0ffff\",\n \"lightgoldenrodyellow\": \"#fafad2\",\n \"lightgrey\": \"#d3d3d3\",\n \"lightgreen\": \"#90ee90\",\n \"lightpink\": \"#ffb6c1\",\n \"lightsalmon\": \"#ffa07a\",\n \"lightseagreen\": \"#20b2aa\",\n \"lightskyblue\": \"#87cefa\",\n \"lightslategray\": \"#778899\",\n \"lightsteelblue\": \"#b0c4de\",\n \"lightyellow\": \"#ffffe0\",\n \"lime\": \"#00ff00\",\n \"limegreen\": \"#32cd32\",\n \"linen\": \"#faf0e6\",\n \"magenta\": \"#ff00ff\",\n \"maroon\": \"#800000\",\n \"mediumaquamarine\": \"#66cdaa\",\n \"mediumblue\": \"#0000cd\",\n \"mediumorchid\": \"#ba55d3\",\n \"mediumpurple\": \"#9370d8\",\n \"mediumseagreen\": \"#3cb371\",\n \"mediumslateblue\": \"#7b68ee\",\n \"mediumspringgreen\": \"#00fa9a\",\n \"mediumturquoise\": \"#48d1cc\",\n \"mediumvioletred\": \"#c71585\",\n \"midnightblue\": \"#191970\",\n \"mintcream\": \"#f5fffa\",\n \"mistyrose\": \"#ffe4e1\",\n \"moccasin\": \"#ffe4b5\",\n \"navajowhite\": \"#ffdead\",\n \"navy\": \"#000080\",\n \"oldlace\": \"#fdf5e6\",\n \"olive\": \"#808000\",\n \"olivedrab\": \"#6b8e23\",\n \"orange\": \"#ffa500\",\n \"orangered\": \"#ff4500\",\n \"orchid\": \"#da70d6\",\n \"palegoldenrod\": \"#eee8aa\",\n \"palegreen\": \"#98fb98\",\n \"paleturquoise\": \"#afeeee\",\n \"palevioletred\": \"#d87093\",\n \"papayawhip\": \"#ffefd5\",\n \"peachpuff\": \"#ffdab9\",\n \"peru\": \"#cd853f\",\n \"pink\": \"#ffc0cb\",\n \"plum\": \"#dda0dd\",\n \"powderblue\": \"#b0e0e6\",\n \"purple\": \"#800080\",\n \"red\": \"#ff0000\",\n \"rosybrown\": \"#bc8f8f\",\n \"royalblue\": \"#4169e1\",\n \"saddlebrown\": \"#8b4513\",\n \"salmon\": \"#fa8072\",\n \"sandybrown\": \"#f4a460\",\n \"seagreen\": \"#2e8b57\",\n \"seashell\": \"#fff5ee\",\n \"sienna\": \"#a0522d\",\n \"silver\": \"#c0c0c0\",\n \"skyblue\": \"#87ceeb\",\n \"slateblue\": \"#6a5acd\",\n \"slategray\": \"#708090\",\n \"snow\": \"#fffafa\",\n \"springgreen\": \"#00ff7f\",\n \"steelblue\": \"#4682b4\",\n \"tan\": \"#d2b48c\",\n \"teal\": \"#008080\",\n \"thistle\": \"#d8bfd8\",\n \"tomato\": \"#ff6347\",\n \"turquoise\": \"#40e0d0\",\n \"violet\": \"#ee82ee\",\n \"wheat\": \"#f5deb3\",\n \"white\": \"#ffffff\",\n \"whitesmoke\": \"#f5f5f5\",\n \"yellow\": \"#ffff00\",\n \"yellowgreen\": \"#9acd32\"\n }[name.toLowerCase()]\n }\n \n \n static hexToDescriptor(c: string): UIColorDescriptor {\n if (c[0] === \"#\") {\n c = c.substr(1)\n }\n const r = parseInt(c.slice(0, 2), 16)\n const g = parseInt(c.slice(2, 4), 16)\n const b = parseInt(c.slice(4, 6), 16)\n const a = parseInt(c.slice(6, 8), 16)\n \n const result = { \"red\": r, \"green\": g, \"blue\": b, \"alpha\": a }\n \n return result\n \n //return 'rgb(' + r + ',' + g + ',' + b + ')';\n \n }\n \n static rgbToDescriptor(colorString: string) {\n \n if (colorString.startsWith(\"rgba(\")) {\n colorString = colorString.slice(5, colorString.length - 1)\n }\n \n if (colorString.startsWith(\"rgb(\")) {\n colorString = colorString.slice(4, colorString.length - 1) + \", 0\"\n }\n \n const components = colorString.split(\",\")\n \n const result = {\n \"red\": Number(components[0]),\n \"green\": Number(components[1]),\n \"blue\": Number(components[2]),\n \"alpha\": Number(components[3])\n }\n \n return result\n \n }\n \n \n get colorDescriptor(): UIColorDescriptor {\n \n var descriptor\n \n const colorHEXFromName = UIColor.nameToHex(this.stringValue)\n \n if (this.stringValue.startsWith(\"rgb\")) {\n descriptor = UIColor.rgbToDescriptor(this.stringValue)\n }\n else if (colorHEXFromName) {\n descriptor = UIColor.hexToDescriptor(colorHEXFromName)\n }\n else {\n descriptor = UIColor.hexToDescriptor(this.stringValue)\n }\n \n return descriptor\n \n }\n \n \n colorWithRed(red: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithGreen(green: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithBlue(blue: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithAlpha(alpha: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + alpha + \")\"\n )\n \n }\n \n static colorWithRGBA(red: number, green: number, blue: number, alpha: number = 1) {\n \n const result = new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n return result\n \n }\n \n static colorWithDescriptor(descriptor: UIColorDescriptor) {\n \n const result = new UIColor(\"rgba(\" + descriptor.red.toFixed(0) + \",\" + descriptor.green.toFixed(0) + \",\" +\n descriptor.blue.toFixed(0) + \",\" + this.defaultAlphaToOne(descriptor.alpha) + \")\")\n \n return result\n \n }\n \n \n private static defaultAlphaToOne(value = 1) {\n if (value != value) {\n value = 1\n }\n return value\n }\n \n \n colorByMultiplyingRGB(multiplier: number) {\n \n const descriptor = this.colorDescriptor\n \n descriptor.red = descriptor.red * multiplier\n descriptor.green = descriptor.green * multiplier\n descriptor.blue = descriptor.blue * multiplier\n \n return UIColor.colorWithDescriptor(descriptor)\n \n }\n \n \n}\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;
|
|
4
|
+
"sourcesContent": ["import { UIObject } from \"./UIObject\"\n\n\nexport interface UIColorDescriptor {\n \n red: number;\n green: number;\n blue: number;\n alpha?: number;\n \n}\n\n\nexport type UIColorSemanticKey = string\n\n\nexport class UIColor extends UIObject {\n \n \n // --- Semantic color registry ---\n \n static _liveColors: WeakRef<UIColor>[] = []\n static _registrationMap = new Map<string, UIColor>()\n static _cssSubscriptions = new Map<UIColorSemanticKey, Set<() => void>>()\n \n \n // --- Instance fields ---\n \n stringValue: string\n semanticKey?: UIColorSemanticKey\n _semanticClass?: typeof UIColor\n _elementRef?: HTMLElement\n _styleProperty?: string\n \n \n constructor(stringValue: string, semanticKey?: UIColorSemanticKey) {\n \n super()\n \n this.stringValue = stringValue\n this.semanticKey = semanticKey\n if (semanticKey) {\n this._semanticClass = this.constructor as typeof UIColor\n }\n \n }\n \n \n override toString() {\n return this.stringValue\n }\n \n \n // --- Semantic apply ---\n \n /**\n * Re-resolves this instance's stringValue from its class's static getter\n * matching the semanticKey, then writes the new value directly to the DOM\n * via the stored element reference and style property.\n * No-op if this instance has no semanticKey.\n */\n apply() {\n \n if (!this.semanticKey) { return }\n \n const colorClass = this._semanticClass ?? this.constructor as typeof UIColor\n const newColor = (colorClass as any)[this.semanticKey] as UIColor | undefined\n \n if (!newColor) { return }\n \n this.stringValue = newColor.stringValue\n \n const element = this._elementRef\n \n if (!element || !this._styleProperty) { return }\n \n (element.style as any)[this._styleProperty] = this.stringValue\n \n }\n \n \n /**\n * Assigns a semantic key and the class that owns it to this color instance.\n * Intended for derived colors that should participate in theme switching,\n * e.g. `BSColor._primaryBase.colorWithAlpha(0.5).withSemanticKey(\"primaryShadow\", BSColor)`.\n * Returns `this` for fluent chaining.\n */\n withSemanticKey(semanticKey: UIColorSemanticKey, semanticClass: typeof UIColor): this {\n this.semanticKey = semanticKey\n this._semanticClass = semanticClass\n return this\n }\n \n \n /**\n * Iterates all live registered UIColor instances, calls apply() on each,\n * compacts dead WeakRefs in the same pass, then fires any CSS subscriptions\n * whose semantic key was affected.\n */\n static applySemanticColors() {\n \n const affectedKeys = new Set<UIColorSemanticKey>()\n \n const live: WeakRef<UIColor>[] = []\n \n for (const ref of UIColor._liveColors) {\n \n const color = ref.deref()\n \n if (!color) {\n continue\n }\n \n live.push(ref)\n \n if (color.semanticKey) {\n affectedKeys.add(color.semanticKey)\n }\n \n color.apply()\n \n }\n \n UIColor._liveColors = live\n \n for (const key of affectedKeys) {\n UIColor._cssSubscriptions.get(key)?.forEach(callback => callback())\n }\n \n }\n \n \n /**\n * Updates the backing field for a semantic color and re-applies all live\n * semantic colors. The backing field is always `_` + semanticKey, e.g.\n * `BSColor.updateSemanticColor(\"primary\", \"#ff0000\")` sets `BSColor._primary`.\n * Called as a static method on the subclass that owns the color.\n */\n static updateSemanticColor(semanticKey: UIColorSemanticKey, value: string) {\n (this as any)[\"_\" + semanticKey] = value\n UIColor.applySemanticColors()\n }\n \n \n /**\n * Registers a callback to be fired when applySemanticColors() affects\n * the given semantic key. Intended for injected CSS blocks that cannot\n * be tracked via the colorStyleProxy.\n */\n static subscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n \n if (!UIColor._cssSubscriptions.has(semanticKey)) {\n UIColor._cssSubscriptions.set(semanticKey, new Set())\n }\n \n UIColor._cssSubscriptions.get(semanticKey)!.add(callback)\n \n }\n \n \n static unsubscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n UIColor._cssSubscriptions.get(semanticKey)?.delete(callback)\n }\n \n \n // --- Named colors ---\n \n static get redColor() {\n return new UIColor(\"red\")\n }\n \n static get blueColor() {\n return new UIColor(\"blue\")\n }\n \n static get greenColor() {\n return new UIColor(\"green\")\n }\n \n static get yellowColor() {\n return new UIColor(\"yellow\")\n }\n \n static get blackColor() {\n return new UIColor(\"black\")\n }\n \n static get brownColor() {\n return new UIColor(\"brown\")\n }\n \n static get whiteColor() {\n return new UIColor(\"white\")\n }\n \n static get greyColor() {\n return new UIColor(\"grey\")\n }\n \n static get lightGreyColor() {\n return new UIColor(\"lightgrey\")\n }\n \n static get transparentColor() {\n return new UIColor(\"transparent\")\n }\n \n static get clearColor() {\n return new UIColor(\"transparent\")\n }\n \n static get undefinedColor() {\n return new UIColor(\"\")\n }\n \n static get nilColor() {\n return new UIColor(\"\")\n }\n \n \n static nameToHex(name: string) {\n return {\n \"aliceblue\": \"#f0f8ff\",\n \"antiquewhite\": \"#faebd7\",\n \"aqua\": \"#00ffff\",\n \"aquamarine\": \"#7fffd4\",\n \"azure\": \"#f0ffff\",\n \"beige\": \"#f5f5dc\",\n \"bisque\": \"#ffe4c4\",\n \"black\": \"#000000\",\n \"blanchedalmond\": \"#ffebcd\",\n \"blue\": \"#0000ff\",\n \"blueviolet\": \"#8a2be2\",\n \"brown\": \"#a52a2a\",\n \"burlywood\": \"#deb887\",\n \"cadetblue\": \"#5f9ea0\",\n \"chartreuse\": \"#7fff00\",\n \"chocolate\": \"#d2691e\",\n \"coral\": \"#ff7f50\",\n \"cornflowerblue\": \"#6495ed\",\n \"cornsilk\": \"#fff8dc\",\n \"crimson\": \"#dc143c\",\n \"cyan\": \"#00ffff\",\n \"darkblue\": \"#00008b\",\n \"darkcyan\": \"#008b8b\",\n \"darkgoldenrod\": \"#b8860b\",\n \"darkgray\": \"#a9a9a9\",\n \"darkgreen\": \"#006400\",\n \"darkkhaki\": \"#bdb76b\",\n \"darkmagenta\": \"#8b008b\",\n \"darkolivegreen\": \"#556b2f\",\n \"darkorange\": \"#ff8c00\",\n \"darkorchid\": \"#9932cc\",\n \"darkred\": \"#8b0000\",\n \"darksalmon\": \"#e9967a\",\n \"darkseagreen\": \"#8fbc8f\",\n \"darkslateblue\": \"#483d8b\",\n \"darkslategray\": \"#2f4f4f\",\n \"darkturquoise\": \"#00ced1\",\n \"darkviolet\": \"#9400d3\",\n \"deeppink\": \"#ff1493\",\n \"deepskyblue\": \"#00bfff\",\n \"dimgray\": \"#696969\",\n \"dodgerblue\": \"#1e90ff\",\n \"firebrick\": \"#b22222\",\n \"floralwhite\": \"#fffaf0\",\n \"forestgreen\": \"#228b22\",\n \"fuchsia\": \"#ff00ff\",\n \"gainsboro\": \"#dcdcdc\",\n \"ghostwhite\": \"#f8f8ff\",\n \"gold\": \"#ffd700\",\n \"goldenrod\": \"#daa520\",\n \"gray\": \"#808080\",\n \"green\": \"#008000\",\n \"greenyellow\": \"#adff2f\",\n \"honeydew\": \"#f0fff0\",\n \"hotpink\": \"#ff69b4\",\n \"indianred \": \"#cd5c5c\",\n \"indigo\": \"#4b0082\",\n \"ivory\": \"#fffff0\",\n \"khaki\": \"#f0e68c\",\n \"lavender\": \"#e6e6fa\",\n \"lavenderblush\": \"#fff0f5\",\n \"lawngreen\": \"#7cfc00\",\n \"lemonchiffon\": \"#fffacd\",\n \"lightblue\": \"#add8e6\",\n \"lightcoral\": \"#f08080\",\n \"lightcyan\": \"#e0ffff\",\n \"lightgoldenrodyellow\": \"#fafad2\",\n \"lightgrey\": \"#d3d3d3\",\n \"lightgreen\": \"#90ee90\",\n \"lightpink\": \"#ffb6c1\",\n \"lightsalmon\": \"#ffa07a\",\n \"lightseagreen\": \"#20b2aa\",\n \"lightskyblue\": \"#87cefa\",\n \"lightslategray\": \"#778899\",\n \"lightsteelblue\": \"#b0c4de\",\n \"lightyellow\": \"#ffffe0\",\n \"lime\": \"#00ff00\",\n \"limegreen\": \"#32cd32\",\n \"linen\": \"#faf0e6\",\n \"magenta\": \"#ff00ff\",\n \"maroon\": \"#800000\",\n \"mediumaquamarine\": \"#66cdaa\",\n \"mediumblue\": \"#0000cd\",\n \"mediumorchid\": \"#ba55d3\",\n \"mediumpurple\": \"#9370d8\",\n \"mediumseagreen\": \"#3cb371\",\n \"mediumslateblue\": \"#7b68ee\",\n \"mediumspringgreen\": \"#00fa9a\",\n \"mediumturquoise\": \"#48d1cc\",\n \"mediumvioletred\": \"#c71585\",\n \"midnightblue\": \"#191970\",\n \"mintcream\": \"#f5fffa\",\n \"mistyrose\": \"#ffe4e1\",\n \"moccasin\": \"#ffe4b5\",\n \"navajowhite\": \"#ffdead\",\n \"navy\": \"#000080\",\n \"oldlace\": \"#fdf5e6\",\n \"olive\": \"#808000\",\n \"olivedrab\": \"#6b8e23\",\n \"orange\": \"#ffa500\",\n \"orangered\": \"#ff4500\",\n \"orchid\": \"#da70d6\",\n \"palegoldenrod\": \"#eee8aa\",\n \"palegreen\": \"#98fb98\",\n \"paleturquoise\": \"#afeeee\",\n \"palevioletred\": \"#d87093\",\n \"papayawhip\": \"#ffefd5\",\n \"peachpuff\": \"#ffdab9\",\n \"peru\": \"#cd853f\",\n \"pink\": \"#ffc0cb\",\n \"plum\": \"#dda0dd\",\n \"powderblue\": \"#b0e0e6\",\n \"purple\": \"#800080\",\n \"red\": \"#ff0000\",\n \"rosybrown\": \"#bc8f8f\",\n \"royalblue\": \"#4169e1\",\n \"saddlebrown\": \"#8b4513\",\n \"salmon\": \"#fa8072\",\n \"sandybrown\": \"#f4a460\",\n \"seagreen\": \"#2e8b57\",\n \"seashell\": \"#fff5ee\",\n \"sienna\": \"#a0522d\",\n \"silver\": \"#c0c0c0\",\n \"skyblue\": \"#87ceeb\",\n \"slateblue\": \"#6a5acd\",\n \"slategray\": \"#708090\",\n \"snow\": \"#fffafa\",\n \"springgreen\": \"#00ff7f\",\n \"steelblue\": \"#4682b4\",\n \"tan\": \"#d2b48c\",\n \"teal\": \"#008080\",\n \"thistle\": \"#d8bfd8\",\n \"tomato\": \"#ff6347\",\n \"turquoise\": \"#40e0d0\",\n \"violet\": \"#ee82ee\",\n \"wheat\": \"#f5deb3\",\n \"white\": \"#ffffff\",\n \"whitesmoke\": \"#f5f5f5\",\n \"yellow\": \"#ffff00\",\n \"yellowgreen\": \"#9acd32\"\n }[name.toLowerCase()]\n }\n \n \n static hexToDescriptor(c: string): UIColorDescriptor {\n if (c[0] === \"#\") {\n c = c.substr(1)\n }\n const r = parseInt(c.slice(0, 2), 16)\n const g = parseInt(c.slice(2, 4), 16)\n const b = parseInt(c.slice(4, 6), 16)\n const a = parseInt(c.slice(6, 8), 16)\n \n const result = { \"red\": r, \"green\": g, \"blue\": b, \"alpha\": a }\n \n return result\n \n }\n \n static rgbToDescriptor(colorString: string) {\n \n if (colorString.startsWith(\"rgba(\")) {\n colorString = colorString.slice(5, colorString.length - 1)\n }\n \n if (colorString.startsWith(\"rgb(\")) {\n colorString = colorString.slice(4, colorString.length - 1) + \", 0\"\n }\n \n const components = colorString.split(\",\")\n \n const result = {\n \"red\": Number(components[0]),\n \"green\": Number(components[1]),\n \"blue\": Number(components[2]),\n \"alpha\": Number(components[3])\n }\n \n return result\n \n }\n \n \n get colorDescriptor(): UIColorDescriptor {\n \n var descriptor\n \n const colorHEXFromName = UIColor.nameToHex(this.stringValue)\n \n if (this.stringValue.startsWith(\"rgb\")) {\n descriptor = UIColor.rgbToDescriptor(this.stringValue)\n }\n else if (colorHEXFromName) {\n descriptor = UIColor.hexToDescriptor(colorHEXFromName)\n }\n else {\n descriptor = UIColor.hexToDescriptor(this.stringValue)\n }\n \n return descriptor\n \n }\n \n \n colorWithRed(red: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithGreen(green: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithBlue(blue: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithAlpha(alpha: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + alpha + \")\"\n )\n \n }\n \n static colorWithRGBA(red: number, green: number, blue: number, alpha: number = 1) {\n \n const result = new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n return result\n \n }\n \n static colorWithDescriptor(descriptor: UIColorDescriptor) {\n \n const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0)\n const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0)\n const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0)\n const alpha = this.defaultAlphaToOne(descriptor.alpha)\n \n return new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n }\n \n \n private static defaultAlphaToOne(value = 1) {\n if (value != value) {\n value = 1\n }\n return value\n }\n \n \n colorByMultiplyingRGB(multiplier: number) {\n \n const descriptor = this.colorDescriptor\n \n descriptor.red = descriptor.red * multiplier\n descriptor.green = descriptor.green * multiplier\n descriptor.blue = descriptor.blue * multiplier\n \n return UIColor.colorWithDescriptor(descriptor)\n \n }\n \n \n}\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAgBlB,MAAM,WAAN,cAAsB,yBAAS;AAAA,EAmBlC,YAAY,aAAqB,aAAkC;AAE/D,UAAM;AAEN,SAAK,cAAc;AACnB,SAAK,cAAc;AACnB,QA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BAAkB,WAAW,KAAK;AAErD,WAAO,IAAI,SAAQ,UAAU,MAAM,MAAM,QAAQ,MAAM,OAAO,MAAM,QAAQ,GAAG;AAAA,EAEnF;AAAA,EAGA,OAAe,kBAAkB,QAAQ,GAAG;AACxC,QAAI,SAAS,OAAO;AAChB,cAAQ;AAAA,IACZ;AACA,WAAO;AAAA,EACX;AAAA,EAGA,sBAAsB,YAAoB;AAEtC,UAAM,aAAa,KAAK;AAExB,eAAW,MAAM,WAAW,MAAM;AAClC,eAAW,QAAQ,WAAW,QAAQ;AACtC,eAAW,OAAO,WAAW,OAAO;AAEpC,WAAO,SAAQ,oBAAoB,UAAU;AAAA,EAEjD;AAGJ;AA3eO,IAAM,UAAN;AAAM,QAKF,cAAkC,CAAC;AALjC,QAMF,mBAAmB,oBAAI,IAAqB;AAN1C,QAOF,oBAAoB,oBAAI,IAAyC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.202",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
package/scripts/UIColor.ts
CHANGED
|
@@ -11,21 +11,7 @@ export interface UIColorDescriptor {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
* Extend this interface via declaration merging in UIColor subclass files
|
|
16
|
-
* to register valid semantic key strings for autocomplete and type safety.
|
|
17
|
-
*
|
|
18
|
-
* Example (in BSColor.ts):
|
|
19
|
-
* declare module "./UIColor" {
|
|
20
|
-
* interface UIColorSemanticKeys {
|
|
21
|
-
* primary: never
|
|
22
|
-
* success: never
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
*/
|
|
26
|
-
export interface UIColorSemanticKeys {}
|
|
27
|
-
|
|
28
|
-
export type UIColorSemanticKey = keyof UIColorSemanticKeys
|
|
14
|
+
export type UIColorSemanticKey = string
|
|
29
15
|
|
|
30
16
|
|
|
31
17
|
export class UIColor extends UIObject {
|
|
@@ -144,6 +130,18 @@ export class UIColor extends UIObject {
|
|
|
144
130
|
}
|
|
145
131
|
|
|
146
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Updates the backing field for a semantic color and re-applies all live
|
|
135
|
+
* semantic colors. The backing field is always `_` + semanticKey, e.g.
|
|
136
|
+
* `BSColor.updateSemanticColor("primary", "#ff0000")` sets `BSColor._primary`.
|
|
137
|
+
* Called as a static method on the subclass that owns the color.
|
|
138
|
+
*/
|
|
139
|
+
static updateSemanticColor(semanticKey: UIColorSemanticKey, value: string) {
|
|
140
|
+
(this as any)["_" + semanticKey] = value
|
|
141
|
+
UIColor.applySemanticColors()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
147
145
|
/**
|
|
148
146
|
* Registers a callback to be fired when applySemanticColors() affects
|
|
149
147
|
* the given semantic key. Intended for injected CSS blocks that cannot
|
|
@@ -379,8 +377,6 @@ export class UIColor extends UIObject {
|
|
|
379
377
|
|
|
380
378
|
return result
|
|
381
379
|
|
|
382
|
-
//return 'rgb(' + r + ',' + g + ',' + b + ')';
|
|
383
|
-
|
|
384
380
|
}
|
|
385
381
|
|
|
386
382
|
static rgbToDescriptor(colorString: string) {
|
|
@@ -478,10 +474,12 @@ export class UIColor extends UIObject {
|
|
|
478
474
|
|
|
479
475
|
static colorWithDescriptor(descriptor: UIColorDescriptor) {
|
|
480
476
|
|
|
481
|
-
const
|
|
482
|
-
|
|
477
|
+
const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0)
|
|
478
|
+
const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0)
|
|
479
|
+
const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0)
|
|
480
|
+
const alpha = this.defaultAlphaToOne(descriptor.alpha)
|
|
483
481
|
|
|
484
|
-
return
|
|
482
|
+
return new UIColor("rgba(" + red + "," + green + "," + blue + "," + alpha + ")")
|
|
485
483
|
|
|
486
484
|
}
|
|
487
485
|
|