@omegagrid/core 0.9.39 → 0.9.40
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/dist/common/dom.d.ts +2 -7
- package/dist/common/dom.d.ts.map +1 -1
- package/dist/common/dom.js +4 -4
- package/dist/common/dom.js.map +1 -1
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +3 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/dropdown.d.ts +2 -1
- package/dist/ui/dropdown.d.ts.map +1 -1
- package/dist/ui/dropdown.js +31 -14
- package/dist/ui/dropdown.js.map +1 -1
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/label.d.ts +17 -0
- package/dist/ui/label.d.ts.map +1 -0
- package/dist/ui/label.js +91 -0
- package/dist/ui/label.js.map +1 -0
- package/package.json +2 -2
package/dist/common/dom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Options } from 'ts-debounce';
|
|
2
|
-
import { Rect } from '../types';
|
|
2
|
+
import { CssPosition, Rect } from '../types';
|
|
3
3
|
export declare function createName(name: string, prefix?: string): string;
|
|
4
4
|
export declare function register(name: string, c: CustomElementConstructor, ext?: string, prefix?: string): void;
|
|
5
5
|
export declare function setStyle(elm: HTMLElement, style: CSSStyleDeclaration): HTMLElement;
|
|
@@ -44,12 +44,7 @@ export declare function setMinSize(elm: HTMLElement, size: {
|
|
|
44
44
|
w?: number | string;
|
|
45
45
|
h?: number | string;
|
|
46
46
|
}): HTMLElement;
|
|
47
|
-
export declare function setPosition(elm: HTMLElement | SVGElement, position:
|
|
48
|
-
r?: number;
|
|
49
|
-
b?: number;
|
|
50
|
-
l?: number;
|
|
51
|
-
t?: number;
|
|
52
|
-
}): void;
|
|
47
|
+
export declare function setPosition(elm: HTMLElement | SVGElement, position: CssPosition): void;
|
|
53
48
|
export declare function setInset(elm: HTMLElement | SVGElement, value: number): void;
|
|
54
49
|
export declare function getBounds(elm: HTMLElement): Rect;
|
|
55
50
|
export declare function setBounds(elm: HTMLElement, bounds: Rect): void;
|
package/dist/common/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/common/dom.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/common/dom.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE7C,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAyB,UAEzE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,wBAAwB,EAAE,GAAG,GAAE,MAAa,EAAE,MAAM,GAAE,MAAyB,QAExH;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,GAAI,WAAW,CAKnF;AAGD,KAAK,iBAAiB,CAAC,CAAC,SAAS,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAC3E,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,EAAE,CAAA;CAC1D,CAAA;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,OA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AAC,QAKrG;AAED,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAsC,QAKtF;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAC,QAKxG;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,EAAE,SAAS,EAAE,WAAW,GAAI;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAC,CAM9H;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,QAGzD;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAUrD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,UAAqB,GAAI,CAAC,CAE5E"}
|
package/dist/common/dom.js
CHANGED
|
@@ -186,13 +186,13 @@ export function setMinSize(elm, size) {
|
|
|
186
186
|
export function setPosition(elm, position) {
|
|
187
187
|
elm.style.position = 'absolute';
|
|
188
188
|
if (position.r != null)
|
|
189
|
-
elm.style.right = numToPixels(position.r);
|
|
189
|
+
elm.style.right = typeof position.r === 'string' ? position.r : numToPixels(position.r);
|
|
190
190
|
if (position.b != null)
|
|
191
|
-
elm.style.bottom = numToPixels(position.b);
|
|
191
|
+
elm.style.bottom = typeof position.b === 'string' ? position.b : numToPixels(position.b);
|
|
192
192
|
if (position.l != null)
|
|
193
|
-
elm.style.left = numToPixels(position.l);
|
|
193
|
+
elm.style.left = typeof position.l === 'string' ? position.l : numToPixels(position.l);
|
|
194
194
|
if (position.t != null)
|
|
195
|
-
elm.style.top = numToPixels(position.t);
|
|
195
|
+
elm.style.top = typeof position.t === 'string' ? position.t : numToPixels(position.t);
|
|
196
196
|
}
|
|
197
197
|
export function setInset(elm, value) {
|
|
198
198
|
elm.style.position = 'absolute';
|
package/dist/common/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/common/dom.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAW,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,SAAiB,SAAS,CAAC,MAAM;IACzE,OAAO,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,CAA2B,EAAE,MAAc,IAAI,EAAE,SAAiB,SAAS,CAAC,MAAM;IACxH,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAgB,EAAE,KAA0B;IACpE,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC9B,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC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AAS,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC;IAC3E,OAAO,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAgB,EAAE,IAAY;IACzD,GAAG,CAAC,KAAK,CAAC,eAAe,GAAG,WAAW,CAAC;IACxC,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,IAAI,GAAG,CAAC;AACxC,CAAC;AAGD,IAAI,qBAA4D,CAAC;AACjE,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACrD,IAAI,CAAC,qBAAqB;QAAE,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9D,IAAI,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC;QAC/B,qBAAqB,CAAC,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,KAAK,CAAI,QAAgB,EAAE,SAAqB,QAAQ;IACvE,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAM,CAAC;AAC5C,CAAC;AAED,qFAAqF;AACrF,6BAA6B;AAC7B,IAAI","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport constants from '../constants';\nimport { debounce, Options } from 'ts-debounce';\nimport { isString } from './utils';\nimport { Rect } from '../types';\n\nexport function createName(name: string, prefix: string = constants.PREFIX) {\n\treturn `${prefix}-${name}`;\n}\n\nexport function register(name: string, c: CustomElementConstructor, ext: string = null, prefix: string = constants.PREFIX) {\n\tcustomElements.define(`${prefix}-${name}`, c, ext ? {extends: ext} : undefined);\n}\n\nexport function setStyle(elm: HTMLElement, style: CSSStyleDeclaration) : HTMLElement {\n\tfor (const styleKey in style) {\n\t\telm.style[styleKey] = style[styleKey];\n\t}\n\treturn elm;\n}\n\n\ntype ElementAttributes<T extends HTMLElement> = Omit<Partial<T>, 'style'> & {\n\tstyle?: Partial<CSSStyleDeclaration>,\n\tlisteners?: [string, EventListenerOrEventListenerObject][]\n}\n\nexport function createElement<T extends HTMLElement>(elmName: string, attrs?: ElementAttributes<T>) : T {\n\tconst elm = document.createElement(elmName) as T;\n\tif (attrs) {\n\t\tfor (const key in attrs) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'listeners':\n\t\t\t\t\tif (Array.isArray(attrs.listeners)) {\n\t\t\t\t\t\tfor (const listener of attrs.listeners) {\n\t\t\t\t\t\t\telm.addEventListener(listener[0], listener[1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'style':\n\t\t\t\t\tif (typeof attrs[key] === 'object') {\n\t\t\t\t\t\tsetStyle(elm, attrs[key] as unknown as CSSStyleDeclaration);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(elm as any)[key] = (attrs as any)[key];\n\t\t\t}\n\t\t}\n\t}\n\treturn elm;\n}\n\nexport function appendElement(parent: HTMLElement|DocumentFragment, child: HTMLElement) {\n\tparent.appendChild(child);\n\treturn parent as HTMLElement;\n}\n\nexport function showElement(elm: HTMLElement, defaultDisplayStyle = '') : HTMLElement {\n\tif (elm) elm.style.display = elm.dataset.display || defaultDisplayStyle || 'block';\n\treturn elm;\n}\n\nexport function hideElement(elm: HTMLElement) : HTMLElement {\n\tif (elm) {\n\t\telm.dataset.display = elm.style.display == 'none' ? '' : elm.style.display;\n\t\telm.style.display = 'none';\n\t}\n\treturn elm;\n}\n\nexport function isHidden(elm: HTMLElement) {\n\treturn elm.style.display == 'none';\n}\n\nexport function showCell(cell: HTMLTableCellElement) {\n\tcell.style.display = 'table-cell';\n}\n\nexport function hideCell(cell: HTMLTableCellElement) {\n\tcell.style.display = 'none';\n}\n\nexport function empty<T extends HTMLElement|ShadowRoot>(elm: T) : T {\n\telm.innerHTML = '';\n\treturn elm;\n}\n\nexport function remove(elm: HTMLElement) {\n\telm.parentNode?.removeChild(elm);\n}\n\nexport function findParent<T extends HTMLElement>(elm: HTMLElement, selector: string|((elm: HTMLElement) => boolean)) : T {\n\tconst predicate = typeof selector === 'string' \n\t\t? (elm: HTMLElement) => elm.matches(selector as string) \n\t\t: selector;\n\t\t\n\twhile (elm.parentNode) {\n\t\telm = elm.parentNode as HTMLElement;\n\t\tif (elm instanceof ShadowRoot && elm.host) elm = elm.host as HTMLElement;\n\t\tif (elm instanceof HTMLElement && predicate(elm)) return elm as T;\t\n\t}\n\treturn null;\n}\n\ntype OnCallbackFunction<T extends Event> = (e: T, elm: HTMLElement) => void;\n\nexport function on<T extends Event>(elm: HTMLElement, event: string, selector: string, matchCallback: OnCallbackFunction<T>, notMatchCallback?: OnCallbackFunction<T>) : HTMLElement {\n\telm.addEventListener(event, (e: T) => {\n\t\tfor (const parent of e.composedPath() as HTMLElement[]) {\n\t\t\tif (parent.matches && parent.matches(selector)) {\n\t\t\t\tmatchCallback(e, parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (notMatchCallback) {\n\t\t\tnotMatchCallback(e, null);\n\t\t}\n\t});\n\treturn elm;\n}\n\nexport function debounceOn<T extends Event>(elm: HTMLElement, event: string, selector: string, callback: OnCallbackFunction<T>, options?: {\n\twait?: number, \n\tnoMatchCallback?: OnCallbackFunction<T>\n} & Options<void>) : HTMLElement {\n\tconst origCallback = (e: T, path: HTMLElement[]) => {\n\t\tfor (const parent of path) {\n\t\t\tif (parent.matches && parent.matches(selector)) {\n\t\t\t\tcallback(e, parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (options?.noMatchCallback) options.noMatchCallback(e, null);\n\t};\n\n\tconst debouncedCallback = debounce((e, path: HTMLElement[]) => origCallback(e, path), options.wait, options);\n\telm.addEventListener(event, (e: T) => debouncedCallback(e, e.composedPath() as HTMLElement[]));\t\n\treturn elm;\n}\n\nexport function setClasses(elm: HTMLElement, classes?: string[]) : HTMLElement {\n\telm.className = classes ? classes.reduce((prev, cur, i) => prev + (cur ? ((i == 0 ? '' : ' ') + cur) : ''), '') : '';\n\treturn elm;\n}\n\nexport function getElementOffset(elm: HTMLElement, offsetElm: HTMLElement) : {top: number, left: number} {\n\tlet x = 0;\n\tlet y = 0;\n\twhile(elm && !isNaN(elm.offsetLeft) && !isNaN(elm.offsetTop) && (!offsetElm || offsetElm !== elm)) {\n\t\tx += elm.offsetLeft - elm.scrollLeft;\n\t\ty += elm.offsetTop - elm.scrollTop;\n\t\telm = elm.offsetParent as HTMLElement;\n\t}\n\treturn { top: y, left: x };\n}\n\nexport function appendStyle(elm: HTMLElement|DocumentFragment, style: string, id: string = null) : Node {\n\tif (style) {\n\t\tlet styleElm = id ? elm.querySelector('#' + id) : null;\n\t\tif (!styleElm) {\n\t\t\tstyleElm = createElement('style');\n\t\t\tif (id) styleElm.id = id;\n\t\t}\n\t\t\n\t\tstyleElm.innerHTML = style;\n\t\t\n\t\tif (!styleElm.parentElement) {\n\t\t\telm.appendChild(styleElm);\n\t\t}\n\t}\n\treturn elm;\n}\n\nexport function appendScript(elm: HTMLElement|DocumentFragment, js: string, id: string = null) : Node {\n\tif (!js) return elm; \n\tlet scriptElm = id ? elm.querySelector('#' + id) : null;\n\tif (!scriptElm) {\n\t\tscriptElm = createElement('script');\n\t\tif (id) scriptElm.id = id;\n\t}\n\t\n\tscriptElm.textContent = js;\n\t\n\tif (!scriptElm.parentElement) {\n\t\telm.appendChild(scriptElm);\n\t}\n\t\n\treturn elm;\n}\n\nexport function numToPixels(n: number) : string {\n\treturn isNaN(n) ? '0' : n.toString() + 'px';\n}\n\nexport const px = numToPixels;\n\nexport function setSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}, minSize = false) : HTMLElement {\n\tif (!elm) return;\n\tif (size.w != null) elm.style[minSize ? 'minWidth' : 'width'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style[minSize ? 'minHeight' : 'height'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setMaxSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}) : HTMLElement {\n\tif (size.w != null) elm.style['maxWidth'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style['maxHeight'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setMinSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}) : HTMLElement {\n\tif (size.w != null) elm.style['minWidth'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style['minHeight'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setPosition(elm: HTMLElement|SVGElement, position: {r?: number, b?: number, l?: number, t?: number}) {\n\telm.style.position = 'absolute';\n\tif (position.r != null) elm.style.right = numToPixels(position.r);\n\tif (position.b != null) elm.style.bottom = numToPixels(position.b);\n\tif (position.l != null) elm.style.left = numToPixels(position.l);\n\tif (position.t != null) elm.style.top = numToPixels(position.t);\n}\n\nexport function setInset(elm: HTMLElement|SVGElement, value: number) {\n\telm.style.position = 'absolute';\n\telm.style.inset = numToPixels(value);\n}\n\nexport function getBounds(elm: HTMLElement): Rect {\n\treturn {\n\t\tx: elm.offsetLeft,\n\t\ty: elm.offsetTop,\n\t\tw: elm.offsetWidth,\n\t\th: elm.offsetHeight\n\t}\n}\n\nexport function setBounds(elm: HTMLElement, bounds: Rect) {\n\tsetPosition(elm, {l: bounds.x, t: bounds.y});\n\tsetSize(elm, {w: bounds.w, h: bounds.h});\n}\n\nexport function setLineHeight(elm: HTMLElement, height: number) {\n\telm.style.lineHeight = numToPixels(height);\n}\n\nexport function fixElementPosition(elm: HTMLElement, offsetElement: HTMLElement = null) {\n\toffsetElement = offsetElement || elm.parentElement;\n\tconst offset = getElementOffset(elm as HTMLElement, offsetElement);\n\tconst fixedPosition = fixPosition({\n\t\tx: offset.left,\n\t\ty: offset.top,\n\t\tw: (elm as HTMLElement).offsetWidth,\n\t\th: (elm as HTMLElement).offsetHeight\n\t}, offsetElement);\n\tsetPosition(elm, {l: fixedPosition.x, t: fixedPosition.y});\n}\n\nexport function fixElementSize(elm: HTMLElement, container: HTMLElement = null) {\n\tcontainer = container || elm.parentElement;\n\tif (container.offsetWidth < elm.offsetWidth || container.offsetHeight < elm.offsetHeight) {\n\t\tsetSize(elm, {\n\t\t\tw: Math.min(container.offsetWidth, elm.offsetWidth),\n\t\t\th: Math.min(container.offsetHeight, elm.offsetHeight),\n\t\t});\n\t}\n}\n\nexport function setZIndex(elm: HTMLElement, zIndex: number) {\n\telm.style.zIndex = zIndex.toString();\n}\n\nexport function setMargin(elm: HTMLElement, margin: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (margin.r !== undefined) elm.style.marginRight = numToPixels(margin.r);\n\tif (margin.l !== undefined) elm.style.marginLeft = numToPixels(margin.l);\n\tif (margin.t !== undefined) elm.style.marginTop = numToPixels(margin.t);\n\tif (margin.b !== undefined) elm.style.marginBottom = numToPixels(margin.b);\n}\n\nexport function setPadding(elm: HTMLElement, padding: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (padding.r !== undefined) elm.style.paddingRight = numToPixels(padding.r);\n\tif (padding.l !== undefined) elm.style.paddingLeft = numToPixels(padding.l);\n\tif (padding.t !== undefined) elm.style.paddingTop = numToPixels(padding.t);\n\tif (padding.b !== undefined) elm.style.paddingBottom = numToPixels(padding.b);\n}\n\nexport function setCenterPosition(\n\telm: HTMLElement,\n\tparent: HTMLElement,\n\toptions: {vertical: boolean, horizontal: boolean} = {vertical: true, horizontal: true}\n) {\n\telm.style.position = 'absolute';\n\tif (options.vertical) elm.style.top = numToPixels(Math.round((parent.clientHeight / 2) - (elm.offsetHeight / 2)));\n\tif (options.horizontal) elm.style.left = numToPixels(Math.round((parent.clientWidth / 2) - (elm.offsetWidth / 2)));\n}\n\nexport function setBorderWidth(elm: HTMLElement, widths: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (widths.r != null) elm.style.borderRightWidth = numToPixels(widths.r);\n\tif (widths.b != null) elm.style.borderBottomWidth = numToPixels(widths.b);\n\tif (widths.l != null) elm.style.borderLeftWidth = numToPixels(widths.l);\n\tif (widths.t != null) elm.style.borderTopWidth = numToPixels(widths.t);\n}\n\nexport function fixPosition(pos: {x: number, y: number, w: number, h: number}, container: HTMLElement) : {x: number, y: number} {\n\tlet x = Math.max(0, pos.x);\n\tlet y = Math.max(0, pos.y);\n\tif (x + pos.w > container.clientWidth) x = container.clientWidth - pos.w;\n\tif (y + pos.h > container.clientHeight) y = container.clientHeight - pos.h;\n\treturn {x, y};\n}\n\nexport function zoomElement(elm: HTMLElement, zoom: number) {\n\telm.style.transformOrigin = '0% 0% 0px';\n\telm.style.transform = `scale(${zoom})`;\n}\n\n\nlet textMeasureContextMap: Map<string, CanvasRenderingContext2D>;\nexport function measureText(text: string, font: string) {\n\tif (!textMeasureContextMap) textMeasureContextMap = new Map();\n\tlet textMeasureContext = textMeasureContextMap.get(font);\n\tif (!textMeasureContext) {\n\t\tconst canvas = document.createElement('canvas');\n\t\ttextMeasureContext = canvas.getContext('2d');\n\t\ttextMeasureContext.font = font;\n\t\ttextMeasureContextMap.set(font, textMeasureContext);\n\t}\n\treturn textMeasureContext.measureText(text);\n}\n\nexport function query<T>(selector: string, parent: ParentNode = document) : T {\n\treturn parent.querySelector(selector) as T;\n}\n\n// export function measureElementContent(elm: HTMLElement, container?: HTMLElement) {\n// \tcontainer = container ?? \n// }\n"]}
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot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CAAC,CAAC,CAAC;IAC3E,OAAO,EAAC,CAAC,EAAE,CAAC,EAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAgB,EAAE,IAAY;IACzD,GAAG,CAAC,KAAK,CAAC,eAAe,GAAG,WAAW,CAAC;IACxC,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,SAAS,IAAI,GAAG,CAAC;AACxC,CAAC;AAGD,IAAI,qBAA4D,CAAC;AACjE,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACrD,IAAI,CAAC,qBAAqB;QAAE,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9D,IAAI,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC;QAC/B,qBAAqB,CAAC,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,KAAK,CAAI,QAAgB,EAAE,SAAqB,QAAQ;IACvE,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAM,CAAC;AAC5C,CAAC;AAED,qFAAqF;AACrF,6BAA6B;AAC7B,IAAI","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport constants from '../constants';\nimport { debounce, Options } from 'ts-debounce';\nimport { isString } from './utils';\nimport { CssPosition, Rect } from '../types';\n\nexport function createName(name: string, prefix: string = constants.PREFIX) {\n\treturn `${prefix}-${name}`;\n}\n\nexport function register(name: string, c: CustomElementConstructor, ext: string = null, prefix: string = constants.PREFIX) {\n\tcustomElements.define(`${prefix}-${name}`, c, ext ? {extends: ext} : undefined);\n}\n\nexport function setStyle(elm: HTMLElement, style: CSSStyleDeclaration) : HTMLElement {\n\tfor (const styleKey in style) {\n\t\telm.style[styleKey] = style[styleKey];\n\t}\n\treturn elm;\n}\n\n\ntype ElementAttributes<T extends HTMLElement> = Omit<Partial<T>, 'style'> & {\n\tstyle?: Partial<CSSStyleDeclaration>,\n\tlisteners?: [string, EventListenerOrEventListenerObject][]\n}\n\nexport function createElement<T extends HTMLElement>(elmName: string, attrs?: ElementAttributes<T>) : T {\n\tconst elm = document.createElement(elmName) as T;\n\tif (attrs) {\n\t\tfor (const key in attrs) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'listeners':\n\t\t\t\t\tif (Array.isArray(attrs.listeners)) {\n\t\t\t\t\t\tfor (const listener of attrs.listeners) {\n\t\t\t\t\t\t\telm.addEventListener(listener[0], listener[1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'style':\n\t\t\t\t\tif (typeof attrs[key] === 'object') {\n\t\t\t\t\t\tsetStyle(elm, attrs[key] as unknown as CSSStyleDeclaration);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(elm as any)[key] = (attrs as any)[key];\n\t\t\t}\n\t\t}\n\t}\n\treturn elm;\n}\n\nexport function appendElement(parent: HTMLElement|DocumentFragment, child: HTMLElement) {\n\tparent.appendChild(child);\n\treturn parent as HTMLElement;\n}\n\nexport function showElement(elm: HTMLElement, defaultDisplayStyle = '') : HTMLElement {\n\tif (elm) elm.style.display = elm.dataset.display || defaultDisplayStyle || 'block';\n\treturn elm;\n}\n\nexport function hideElement(elm: HTMLElement) : HTMLElement {\n\tif (elm) {\n\t\telm.dataset.display = elm.style.display == 'none' ? '' : elm.style.display;\n\t\telm.style.display = 'none';\n\t}\n\treturn elm;\n}\n\nexport function isHidden(elm: HTMLElement) {\n\treturn elm.style.display == 'none';\n}\n\nexport function showCell(cell: HTMLTableCellElement) {\n\tcell.style.display = 'table-cell';\n}\n\nexport function hideCell(cell: HTMLTableCellElement) {\n\tcell.style.display = 'none';\n}\n\nexport function empty<T extends HTMLElement|ShadowRoot>(elm: T) : T {\n\telm.innerHTML = '';\n\treturn elm;\n}\n\nexport function remove(elm: HTMLElement) {\n\telm.parentNode?.removeChild(elm);\n}\n\nexport function findParent<T extends HTMLElement>(elm: HTMLElement, selector: string|((elm: HTMLElement) => boolean)) : T {\n\tconst predicate = typeof selector === 'string' \n\t\t? (elm: HTMLElement) => elm.matches(selector as string) \n\t\t: selector;\n\t\t\n\twhile (elm.parentNode) {\n\t\telm = elm.parentNode as HTMLElement;\n\t\tif (elm instanceof ShadowRoot && elm.host) elm = elm.host as HTMLElement;\n\t\tif (elm instanceof HTMLElement && predicate(elm)) return elm as T;\t\n\t}\n\treturn null;\n}\n\ntype OnCallbackFunction<T extends Event> = (e: T, elm: HTMLElement) => void;\n\nexport function on<T extends Event>(elm: HTMLElement, event: string, selector: string, matchCallback: OnCallbackFunction<T>, notMatchCallback?: OnCallbackFunction<T>) : HTMLElement {\n\telm.addEventListener(event, (e: T) => {\n\t\tfor (const parent of e.composedPath() as HTMLElement[]) {\n\t\t\tif (parent.matches && parent.matches(selector)) {\n\t\t\t\tmatchCallback(e, parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (notMatchCallback) {\n\t\t\tnotMatchCallback(e, null);\n\t\t}\n\t});\n\treturn elm;\n}\n\nexport function debounceOn<T extends Event>(elm: HTMLElement, event: string, selector: string, callback: OnCallbackFunction<T>, options?: {\n\twait?: number, \n\tnoMatchCallback?: OnCallbackFunction<T>\n} & Options<void>) : HTMLElement {\n\tconst origCallback = (e: T, path: HTMLElement[]) => {\n\t\tfor (const parent of path) {\n\t\t\tif (parent.matches && parent.matches(selector)) {\n\t\t\t\tcallback(e, parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (options?.noMatchCallback) options.noMatchCallback(e, null);\n\t};\n\n\tconst debouncedCallback = debounce((e, path: HTMLElement[]) => origCallback(e, path), options.wait, options);\n\telm.addEventListener(event, (e: T) => debouncedCallback(e, e.composedPath() as HTMLElement[]));\t\n\treturn elm;\n}\n\nexport function setClasses(elm: HTMLElement, classes?: string[]) : HTMLElement {\n\telm.className = classes ? classes.reduce((prev, cur, i) => prev + (cur ? ((i == 0 ? '' : ' ') + cur) : ''), '') : '';\n\treturn elm;\n}\n\nexport function getElementOffset(elm: HTMLElement, offsetElm: HTMLElement) : {top: number, left: number} {\n\tlet x = 0;\n\tlet y = 0;\n\twhile(elm && !isNaN(elm.offsetLeft) && !isNaN(elm.offsetTop) && (!offsetElm || offsetElm !== elm)) {\n\t\tx += elm.offsetLeft - elm.scrollLeft;\n\t\ty += elm.offsetTop - elm.scrollTop;\n\t\telm = elm.offsetParent as HTMLElement;\n\t}\n\treturn { top: y, left: x };\n}\n\nexport function appendStyle(elm: HTMLElement|DocumentFragment, style: string, id: string = null) : Node {\n\tif (style) {\n\t\tlet styleElm = id ? elm.querySelector('#' + id) : null;\n\t\tif (!styleElm) {\n\t\t\tstyleElm = createElement('style');\n\t\t\tif (id) styleElm.id = id;\n\t\t}\n\t\t\n\t\tstyleElm.innerHTML = style;\n\t\t\n\t\tif (!styleElm.parentElement) {\n\t\t\telm.appendChild(styleElm);\n\t\t}\n\t}\n\treturn elm;\n}\n\nexport function appendScript(elm: HTMLElement|DocumentFragment, js: string, id: string = null) : Node {\n\tif (!js) return elm; \n\tlet scriptElm = id ? elm.querySelector('#' + id) : null;\n\tif (!scriptElm) {\n\t\tscriptElm = createElement('script');\n\t\tif (id) scriptElm.id = id;\n\t}\n\t\n\tscriptElm.textContent = js;\n\t\n\tif (!scriptElm.parentElement) {\n\t\telm.appendChild(scriptElm);\n\t}\n\t\n\treturn elm;\n}\n\nexport function numToPixels(n: number) : string {\n\treturn isNaN(n) ? '0' : n.toString() + 'px';\n}\n\nexport const px = numToPixels;\n\nexport function setSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}, minSize = false) : HTMLElement {\n\tif (!elm) return;\n\tif (size.w != null) elm.style[minSize ? 'minWidth' : 'width'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style[minSize ? 'minHeight' : 'height'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setMaxSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}) : HTMLElement {\n\tif (size.w != null) elm.style['maxWidth'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style['maxHeight'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setMinSize(elm: HTMLElement, size: {w?: number|string, h?: number|string}) : HTMLElement {\n\tif (size.w != null) elm.style['minWidth'] = isString(size.w) ? size.w as string : numToPixels(size.w as number);\n\tif (size.h != null) elm.style['minHeight'] = isString(size.h) ? size.h as string : numToPixels(size.h as number);\n\treturn elm;\n}\n\nexport function setPosition(elm: HTMLElement|SVGElement, position: CssPosition) {\n\telm.style.position = 'absolute';\n\tif (position.r != null) elm.style.right = typeof position.r === 'string' ? position.r : numToPixels(position.r);\n\tif (position.b != null) elm.style.bottom = typeof position.b === 'string' ? position.b : numToPixels(position.b);\n\tif (position.l != null) elm.style.left = typeof position.l === 'string' ? position.l : numToPixels(position.l);\n\tif (position.t != null) elm.style.top = typeof position.t === 'string' ? position.t : numToPixels(position.t);\n}\n\nexport function setInset(elm: HTMLElement|SVGElement, value: number) {\n\telm.style.position = 'absolute';\n\telm.style.inset = numToPixels(value);\n}\n\nexport function getBounds(elm: HTMLElement): Rect {\n\treturn {\n\t\tx: elm.offsetLeft,\n\t\ty: elm.offsetTop,\n\t\tw: elm.offsetWidth,\n\t\th: elm.offsetHeight\n\t}\n}\n\nexport function setBounds(elm: HTMLElement, bounds: Rect) {\n\tsetPosition(elm, {l: bounds.x, t: bounds.y});\n\tsetSize(elm, {w: bounds.w, h: bounds.h});\n}\n\nexport function setLineHeight(elm: HTMLElement, height: number) {\n\telm.style.lineHeight = numToPixels(height);\n}\n\nexport function fixElementPosition(elm: HTMLElement, offsetElement: HTMLElement = null) {\n\toffsetElement = offsetElement || elm.parentElement;\n\tconst offset = getElementOffset(elm as HTMLElement, offsetElement);\n\tconst fixedPosition = fixPosition({\n\t\tx: offset.left,\n\t\ty: offset.top,\n\t\tw: (elm as HTMLElement).offsetWidth,\n\t\th: (elm as HTMLElement).offsetHeight\n\t}, offsetElement);\n\tsetPosition(elm, {l: fixedPosition.x, t: fixedPosition.y});\n}\n\nexport function fixElementSize(elm: HTMLElement, container: HTMLElement = null) {\n\tcontainer = container || elm.parentElement;\n\tif (container.offsetWidth < elm.offsetWidth || container.offsetHeight < elm.offsetHeight) {\n\t\tsetSize(elm, {\n\t\t\tw: Math.min(container.offsetWidth, elm.offsetWidth),\n\t\t\th: Math.min(container.offsetHeight, elm.offsetHeight),\n\t\t});\n\t}\n}\n\nexport function setZIndex(elm: HTMLElement, zIndex: number) {\n\telm.style.zIndex = zIndex.toString();\n}\n\nexport function setMargin(elm: HTMLElement, margin: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (margin.r !== undefined) elm.style.marginRight = numToPixels(margin.r);\n\tif (margin.l !== undefined) elm.style.marginLeft = numToPixels(margin.l);\n\tif (margin.t !== undefined) elm.style.marginTop = numToPixels(margin.t);\n\tif (margin.b !== undefined) elm.style.marginBottom = numToPixels(margin.b);\n}\n\nexport function setPadding(elm: HTMLElement, padding: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (padding.r !== undefined) elm.style.paddingRight = numToPixels(padding.r);\n\tif (padding.l !== undefined) elm.style.paddingLeft = numToPixels(padding.l);\n\tif (padding.t !== undefined) elm.style.paddingTop = numToPixels(padding.t);\n\tif (padding.b !== undefined) elm.style.paddingBottom = numToPixels(padding.b);\n}\n\nexport function setCenterPosition(\n\telm: HTMLElement,\n\tparent: HTMLElement,\n\toptions: {vertical: boolean, horizontal: boolean} = {vertical: true, horizontal: true}\n) {\n\telm.style.position = 'absolute';\n\tif (options.vertical) elm.style.top = numToPixels(Math.round((parent.clientHeight / 2) - (elm.offsetHeight / 2)));\n\tif (options.horizontal) elm.style.left = numToPixels(Math.round((parent.clientWidth / 2) - (elm.offsetWidth / 2)));\n}\n\nexport function setBorderWidth(elm: HTMLElement, widths: {r?: number, b?: number, l?: number, t?: number}) {\n\tif (widths.r != null) elm.style.borderRightWidth = numToPixels(widths.r);\n\tif (widths.b != null) elm.style.borderBottomWidth = numToPixels(widths.b);\n\tif (widths.l != null) elm.style.borderLeftWidth = numToPixels(widths.l);\n\tif (widths.t != null) elm.style.borderTopWidth = numToPixels(widths.t);\n}\n\nexport function fixPosition(pos: {x: number, y: number, w: number, h: number}, container: HTMLElement) : {x: number, y: number} {\n\tlet x = Math.max(0, pos.x);\n\tlet y = Math.max(0, pos.y);\n\tif (x + pos.w > container.clientWidth) x = container.clientWidth - pos.w;\n\tif (y + pos.h > container.clientHeight) y = container.clientHeight - pos.h;\n\treturn {x, y};\n}\n\nexport function zoomElement(elm: HTMLElement, zoom: number) {\n\telm.style.transformOrigin = '0% 0% 0px';\n\telm.style.transform = `scale(${zoom})`;\n}\n\n\nlet textMeasureContextMap: Map<string, CanvasRenderingContext2D>;\nexport function measureText(text: string, font: string) {\n\tif (!textMeasureContextMap) textMeasureContextMap = new Map();\n\tlet textMeasureContext = textMeasureContextMap.get(font);\n\tif (!textMeasureContext) {\n\t\tconst canvas = document.createElement('canvas');\n\t\ttextMeasureContext = canvas.getContext('2d');\n\t\ttextMeasureContext.font = font;\n\t\ttextMeasureContextMap.set(font, textMeasureContext);\n\t}\n\treturn textMeasureContext.measureText(text);\n}\n\nexport function query<T>(selector: string, parent: ParentNode = document) : T {\n\treturn parent.querySelector(selector) as T;\n}\n\n// export function measureElementContent(elm: HTMLElement, container?: HTMLElement) {\n// \tcontainer = container ?? \n// }\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -51,7 +51,9 @@ export declare enum ColorTypes {
|
|
|
51
51
|
}
|
|
52
52
|
export type DecimalSeparator = '.' | ',';
|
|
53
53
|
export type Orientation = 'vertical' | 'horizontal';
|
|
54
|
-
export type
|
|
54
|
+
export type VerticalDirection = 'up' | 'down';
|
|
55
|
+
export type HorizontalDirection = 'left' | 'right';
|
|
56
|
+
export type Direction = VerticalDirection | HorizontalDirection;
|
|
55
57
|
export type DiagonalDirection = 'ne' | 'nw' | 'se' | 'sw';
|
|
56
58
|
export type VerticalPosition = 'top' | 'bottom' | 'center';
|
|
57
59
|
export type HorizontalPosition = 'left' | 'right' | 'center';
|
|
@@ -70,6 +72,12 @@ export type Position = {
|
|
|
70
72
|
l?: number;
|
|
71
73
|
t?: number;
|
|
72
74
|
};
|
|
75
|
+
export type CssPosition = {
|
|
76
|
+
r?: string | number;
|
|
77
|
+
b?: string | number;
|
|
78
|
+
l?: string | number;
|
|
79
|
+
t?: string | number;
|
|
80
|
+
};
|
|
73
81
|
export type Rect = {
|
|
74
82
|
x: number;
|
|
75
83
|
y: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAC,MAAM,CAAC;AAEvC,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,eAAe,CAA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CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAwDvD,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACrB,+BAAiB,CAAA;IACjB,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yCAA2B,CAAA;AAC5B,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { TemplateResult } from \"lit-html\";\nimport { IconSpec } from \"./ui\";\n\nexport type ThemeDefinition = Record<string, string>;\nexport type ThemeVariables = Map<string, string>;\n\nexport type ThemeType = 'light'|'dark';\n\nexport type Theme = {\n\tname: string,\n\ttype: ThemeType,\n\tdefinition: ThemeDefinition,\n\taccentColor?: string,\n};\n\nexport type LocaleId = string;\n\nexport type LayoutOptions<TParent extends HTMLElement = HTMLElement> = {\n\tparent?: TParent,\n\telements?: Map<string, HTMLElement>,\n}\n\nexport interface Layout extends HTMLElement {\n\tlayout(options?: LayoutOptions) : void;\n}\n\nexport type ComponentState = {\n\tname?: string;\n\t[key: string]: unknown;\n}\n\nexport interface Statefull {\n\tget state(): ComponentState;\n\tset state(value: ComponentState);\n\tgetState(): ComponentState;\n\tsetState(state: ComponentState): void;\n}\n\n/**\n * General = 'g',\n * Text = 't',\n * Number = 'n',\n * Date = 'd',\n * DateTime = 'dt',\n * Time = 'tm',\n * Checkbox = 'b',\n * Select = 's',\n * MultiSelect = 'm',\n */\nexport type UIValueType = 'g'|'t'|'n'|'d'|'dt'|'tm'|'b'|'s'|'m';\n\nexport type UIValueFormat = string;\n\n\nexport enum ColorTypes {\n\tAccent = 'accent',\n\tRed = 'red',\n\tYellow = 'yellow',\n\tGreen = 'green',\n\tBlue = 'blue',\n\tGray = 'gray',\n\tTransparent = 'transparent',\n}\n\nexport type DecimalSeparator = '.'|',';\nexport type Orientation = 'vertical'|'horizontal';\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAwDvD,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACrB,+BAAiB,CAAA;IACjB,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yCAA2B,CAAA;AAC5B,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { TemplateResult } from \"lit-html\";\nimport { IconSpec } from \"./ui\";\n\nexport type ThemeDefinition = Record<string, string>;\nexport type ThemeVariables = Map<string, string>;\n\nexport type ThemeType = 'light'|'dark';\n\nexport type Theme = {\n\tname: string,\n\ttype: ThemeType,\n\tdefinition: ThemeDefinition,\n\taccentColor?: string,\n};\n\nexport type LocaleId = string;\n\nexport type LayoutOptions<TParent extends HTMLElement = HTMLElement> = {\n\tparent?: TParent,\n\telements?: Map<string, HTMLElement>,\n}\n\nexport interface Layout extends HTMLElement {\n\tlayout(options?: LayoutOptions) : void;\n}\n\nexport type ComponentState = {\n\tname?: string;\n\t[key: string]: unknown;\n}\n\nexport interface Statefull {\n\tget state(): ComponentState;\n\tset state(value: ComponentState);\n\tgetState(): ComponentState;\n\tsetState(state: ComponentState): void;\n}\n\n/**\n * General = 'g',\n * Text = 't',\n * Number = 'n',\n * Date = 'd',\n * DateTime = 'dt',\n * Time = 'tm',\n * Checkbox = 'b',\n * Select = 's',\n * MultiSelect = 'm',\n */\nexport type UIValueType = 'g'|'t'|'n'|'d'|'dt'|'tm'|'b'|'s'|'m';\n\nexport type UIValueFormat = string;\n\n\nexport enum ColorTypes {\n\tAccent = 'accent',\n\tRed = 'red',\n\tYellow = 'yellow',\n\tGreen = 'green',\n\tBlue = 'blue',\n\tGray = 'gray',\n\tTransparent = 'transparent',\n}\n\nexport type DecimalSeparator = '.'|',';\nexport type Orientation = 'vertical'|'horizontal';\nexport type VerticalDirection = 'up'|'down';\nexport type HorizontalDirection = 'left'|'right';\nexport type Direction = VerticalDirection | HorizontalDirection;\nexport type DiagonalDirection = 'ne'|'nw'|'se'|'sw';\nexport type VerticalPosition = 'top'|'bottom'|'center';\nexport type HorizontalPosition = 'left'|'right'|'center';\nexport type DirectionalPosition = VerticalPosition | HorizontalPosition;\nexport type Size = {w: number, h: number};\nexport type Location = {x: number, y: number};\nexport type Position = {r?: number, b?: number, l?: number, t?: number};\nexport type CssPosition = {r?: string|number, b?: string|number, l?: string|number, t?: string|number};\nexport type Rect = {x: number, y: number, w: number, h: number};\n\nexport type AcordionItem = SplitContainerItem & {\n\ttitle?: string|HTMLElement|TemplateResult<1>,\n\ticon?: string|IconSpec\n}\n\nexport type SplitContainerItem = {\n\tid?: ComponentId,\n\tsize?: number|null, // width or height\n\tcollapsed?: boolean\n}\n\nexport type ComponentId = string|number;\n\nexport type ComponentFactory<T = HTMLElement> = (id?: ComponentId) => T|Promise<T>;\n\nexport interface ComponentContainer<T = HTMLElement> {\n\tcreateComponent: ComponentFactory<T>;\n}\n\nexport type Matrix<T = unknown> = T[][];\n\nexport type Scalar<T = unknown> = T;\n\nexport type DeepPartial<T> = {\n\t[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\nexport interface Populatable {\n\tpopulate(source: Record<PropertyKey, unknown>): void;\n\tgetSourceData(): Record<PropertyKey, unknown>;\n}\n\nexport interface IPrototype<T> { prototype: T }\n\nexport type ValueFormatter<T = unknown> = (value: T) => string;\n\nexport type CustomProperties = Record<string, unknown>;\n\nexport type User = {\n\tid: string,\n\tname?: string\n};\n\nexport type AnyFunction<A = any> = (...input: any[]) => A\nexport type AnyConstructor<A = object> = new (...input: any[]) => A\nexport type Mixin<T extends AnyFunction> = InstanceType<ReturnType<T>>\n\nexport interface Model<TSource = unknown> {\n\t\n\tpopulate(source: TSource): void;\n\tgetSourceData(): TSource;\n\n}\n\nexport type KeyValue = {\n\tkey: string,\n\tvalue?: string\n}\n"]}
|
package/dist/ui/button.d.ts
CHANGED
package/dist/ui/button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,qBAEa,MAAO,SAAQ,UAAU;IAErC,MAAM,CAAC,MAAM,4BAAW;IAGxB,IAAI,EAAE,MAAM,GAAC,QAAQ,CAAC;IAGtB,IAAI,EAAE,MAAM,CAAQ;IAGpB,KAAK,EAAE,UAAU,CAAqB;IAGtC,KAAK,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIlC,qBAEa,MAAO,SAAQ,UAAU;IAErC,MAAM,CAAC,MAAM,4BAAW;IAGxB,IAAI,EAAE,MAAM,GAAC,QAAQ,CAAC;IAGtB,IAAI,EAAE,MAAM,CAAQ;IAGpB,KAAK,EAAE,UAAU,CAAqB;IAGtC,KAAK,EAAE,MAAM,GAAC,MAAM,GAAC,IAAI,CAAU;IAGnC,QAAQ,UAAS;IAGjB,OAAO,UAAS;IAGhB,KAAK,EAAE,SAAS,GAAC,WAAW,CAAQ;IAGpC,IAAI,EAAE,QAAQ,GAAC,QAAQ,CAAY;IAGnC,UAAU,EAAE,QAAQ,CAAC;;IAYrB,iBAAiB;IAKjB,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC;IAgB7C,IAAI,UAAU,qBAA2F;IAEzG,MAAM,6CAWJ;CAEF"}
|
package/dist/ui/button.js
CHANGED
|
@@ -17,7 +17,7 @@ let Button = class Button extends LitElement {
|
|
|
17
17
|
super();
|
|
18
18
|
this.text = null;
|
|
19
19
|
this.color = ColorTypes.Accent;
|
|
20
|
-
this.caret =
|
|
20
|
+
this.caret = 'none';
|
|
21
21
|
this.disabled = false;
|
|
22
22
|
this.default = false;
|
|
23
23
|
this.state = null;
|
|
@@ -31,7 +31,7 @@ let Button = class Button extends LitElement {
|
|
|
31
31
|
: html `${msg(this.text)}`}
|
|
32
32
|
</div>
|
|
33
33
|
` : html ``}
|
|
34
|
-
${this.caret ? html `<og-icon icon="caret
|
|
34
|
+
${this.caret == 'none' ? '' : html `<og-icon icon="caret-${this.caret}" style="margin: 0"></og-icon>`}
|
|
35
35
|
</div>
|
|
36
36
|
`;
|
|
37
37
|
this.addEventListener('click', (e) => {
|
|
@@ -75,7 +75,7 @@ __decorate([
|
|
|
75
75
|
property({ type: String, reflect: true })
|
|
76
76
|
], Button.prototype, "color", void 0);
|
|
77
77
|
__decorate([
|
|
78
|
-
property({ type:
|
|
78
|
+
property({ type: String, reflect: true })
|
|
79
79
|
], Button.prototype, "caret", void 0);
|
|
80
80
|
__decorate([
|
|
81
81
|
property({ type: Boolean, reflect: true })
|
package/dist/ui/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/ui/button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO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,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;uCACzB;AAGhB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;qCACJ;AAGpC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;oCACL;AAGnC;IADC,KAAK,EAAE;0CACa;AA7BT,MAAM;IAFlB,aAAa,CAAC,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAC,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAC,CAAC;GACzC,MAAM,CA6ElB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { ColorTypes } from '../types';\nimport { colorable } from '../themes';\nimport { style } from './button.style';\nimport { classMap } from 'lit-html/directives/class-map.js';\nimport { IconSpec } from './icon';\nimport { utils } from '../common';\nimport { msg } from '@omegagrid/localize';\n\n@customElement(`og-button`)\n@colorable({props: ['color', 'border', 'background']})\nexport class Button extends LitElement {\n\n\tstatic styles = [style];\n\n\t@property()\n\ticon: string|IconSpec;\n\n\t@property({type: String})\n\ttext: string = null;\n\n\t@property({type: String, reflect: true})\n\tcolor: ColorTypes = ColorTypes.Accent;\n\n\t@property({type: String, reflect: true})\n\tcaret: 'none'|'down'|'up' = 'none';\n\n\t@property({type: Boolean, reflect: true})\n\tdisabled = false;\n\n\t@property({type: Boolean, reflect: true})\n\tdefault = false;\n\n\t@property({type: String, reflect: true})\n\tstate: 'checked'|'unchecked' = null;\n\n\t@property({type: String, reflect: true})\n\ttype: 'normal'|'toggle' = 'normal';\n\n\t@state()\n\tbuttonIcon: IconSpec;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('click', (e: PointerEvent) => {\n\t\t\tif (this.disabled) e.stopImmediatePropagation();\n\t\t\telse if (this.type == 'toggle') {\n\t\t\t\tthis.state = this.state == 'checked' ? 'unchecked' : 'checked';\n\t\t\t}\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 1;\n\t}\n\n\twillUpdate(props: Map<PropertyKey, undefined>) {\n\t\tif (this.type == 'toggle' && this.state == null) {\n\t\t\tthis.state = 'unchecked';\n\t\t}\n\n\t\tif (props.has('icon')) {\n\t\t\tif (utils.isObject(this.icon)) {\n\t\t\t\tthis.buttonIcon = this.icon as IconSpec;\n\t\t\t} else if (this.icon) {\n\t\t\t\tthis.buttonIcon = {icon: this.icon as string};\n\t\t\t} else {\n\t\t\t\tthis.buttonIcon = null;\n\t\t\t}\n\t\t}\n\t}\n\n\tget hasContent() { return this.text || (this.children.length > 0 && this.children[0].slot == 'content') }\n\n\trender = () => html`\n\t\t<div class=\"${classMap({inner: true, 'has-content': this.hasContent})}\">\n\t\t\t${this.buttonIcon ? html`<og-icon .icon=\"${this.buttonIcon}\"></og-icon>` : html``}\n\t\t\t${this.hasContent ? html`\n\t\t\t<div class=\"content\">${this.text == null || this.text === ''\n\t\t\t\t? html`<slot name=\"content\"></slot>`\n\t\t\t\t: html`${msg(this.text)}`}\n\t\t\t</div>\n\t\t\t` : html``}\n\t\t\t${this.caret == 'none' ? '' : html`<og-icon icon=\"caret-${this.caret}\" style=\"margin: 0\"></og-icon>`}\n\t\t</div>\n\t`;\n\t\n}"]}
|
package/dist/ui/dropdown.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
-
import { ColorTypes, Layout } from '../types';
|
|
2
|
+
import { ColorTypes, Layout, VerticalDirection } from '../types';
|
|
3
3
|
import { IconSpec } from './icon';
|
|
4
4
|
export declare class DropdownEvent extends Event {
|
|
5
5
|
constructor(event: string);
|
|
@@ -13,6 +13,7 @@ export declare class DropdownContainer extends LitElement {
|
|
|
13
13
|
export declare class Dropdown extends LitElement implements Layout {
|
|
14
14
|
static styles: import("lit").CSSResult[];
|
|
15
15
|
alignment: 'left' | 'right';
|
|
16
|
+
openDirection: VerticalDirection;
|
|
16
17
|
positionOffset: number;
|
|
17
18
|
dropdownParent: HTMLElement;
|
|
18
19
|
animation: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAe,MAAM,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK9E,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,qBAAa,aAAc,SAAQ,KAAK;gBAE3B,KAAK,EAAE,MAAM;CAGzB;AAED,qBAEa,iBAAkB,SAAQ,UAAU;IAEhD,MAAM,CAAC,MAAM,0BAuBX;IAGF,KAAK,aAAqB;;IAO1B,MAAM,0BAA6D;CACnE;AAED,qBAEa,QAAS,SAAQ,UAAW,YAAW,MAAM;IAEzD,MAAM,CAAC,MAAM,4BAwCV;IAGH,SAAS,EAAE,MAAM,GAAC,OAAO,CAAW;IAGpC,aAAa,EAAE,iBAAiB,CAAU;IAG1C,cAAc,SAAK;IAGnB,cAAc,EAAE,WAAW,CAAiB;IAG5C,SAAS,SAAO;IAGhB,KAAK,EAAE,MAAM,GAAC,WAAW,GAAC,cAAc,CAAC;IAGzC,IAAI,EAAE,QAAQ,GAAC,MAAM,CAAC;IAGtB,KAAK,EAAE,MAAM,CAAC;IAGd,KAAK,aAAqB;IAG1B,OAAO,UAAS;IAGhB,QAAQ,EAAE,cAAc,CAAC;IAEzB,OAAO,CAAC,WAAW,CAAc;IAEjC,SAAS,CAAC,WAAW,8DAAkC;IACvD,IAAI,QAAQ,sBAAqC;IAEjD,IAAI,MAAM,YAA2D;IAErE,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,GAAI,GAAG,UAAU,UAKpC;IAED,eAAe,CAAC,OAAO,EAAE,MAAM;IAYzB,IAAI;IA4BV,KAAK;IAML,MAAM;IAKN,YAAY,sBAA6B;IAEzC,oBAAoB;IAKpB,cAAc,0BAIZ;IAEF,WAAW,2HAMT;IAEF,IAAI,YAAY,YAEf;IAED,IAAI,QAAQ,YAEX;IAED,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAKnC,MAAM,0BAeJ;IAEF,IAAI,YAAY,YAEf;IAED,MAAM;CA6BN"}
|
package/dist/ui/dropdown.js
CHANGED
|
@@ -41,10 +41,15 @@ DropdownContainer.styles = css `
|
|
|
41
41
|
box-shadow: var(--og-base-shadow);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
:host(.radiusfix) {
|
|
44
|
+
:host(.radiusfix-down) {
|
|
45
45
|
border-top-left-radius: 0;
|
|
46
46
|
border-top-right-radius: 0;
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
:host(.radiusfix-up) {
|
|
50
|
+
border-bottom-left-radius: 0;
|
|
51
|
+
border-bottom-right-radius: 0;
|
|
52
|
+
}
|
|
48
53
|
`;
|
|
49
54
|
__decorate([
|
|
50
55
|
property({ type: String, reflect: true })
|
|
@@ -58,6 +63,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
|
58
63
|
constructor() {
|
|
59
64
|
super(...arguments);
|
|
60
65
|
this.alignment = 'right';
|
|
66
|
+
this.openDirection = 'down';
|
|
61
67
|
this.positionOffset = 0;
|
|
62
68
|
this.dropdownParent = document.body;
|
|
63
69
|
this.animation = 0.1;
|
|
@@ -91,7 +97,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
|
91
97
|
class="main"
|
|
92
98
|
color="${this.color}"
|
|
93
99
|
.icon="${this.icon}"
|
|
94
|
-
|
|
100
|
+
.caret="${this.noCaret ? 'none' : this.openDirection}">
|
|
95
101
|
${this.hasLabelSlot ? html `
|
|
96
102
|
<div class="label" slot="content"><slot name="label"></slot></div>
|
|
97
103
|
` : guard([this.label], () => (this.hasLabel ? html `
|
|
@@ -116,6 +122,7 @@ let Dropdown = class Dropdown extends LitElement {
|
|
|
116
122
|
setTimeout(() => {
|
|
117
123
|
this.dropdown.style.height = 'auto';
|
|
118
124
|
this.dropdown.style.transition = '';
|
|
125
|
+
this.layout();
|
|
119
126
|
}, seconds * 1000);
|
|
120
127
|
}
|
|
121
128
|
async open() {
|
|
@@ -173,29 +180,31 @@ let Dropdown = class Dropdown extends LitElement {
|
|
|
173
180
|
return this.isOpen && this.color != ColorTypes.Transparent;
|
|
174
181
|
}
|
|
175
182
|
layout() {
|
|
176
|
-
this.classList.toggle(
|
|
183
|
+
this.classList.toggle(`radiusfix-${this.openDirection}`, this.useRadiusFix);
|
|
177
184
|
if (!this.dropdown)
|
|
178
185
|
return;
|
|
179
|
-
this.dropdown.classList.toggle(
|
|
186
|
+
this.dropdown.classList.toggle(`radiusfix-${this.openDirection}`, this.useRadiusFix);
|
|
180
187
|
if (!this.isOpen)
|
|
181
188
|
return;
|
|
182
189
|
const offset = dom.getElementOffset(this, this.dropdownParent);
|
|
183
190
|
dom.setSize(this.dropdown, { w: this.offsetWidth }, true);
|
|
191
|
+
const pos = { t: 'unset', b: 'unset', l: 'unset', r: 'unset' };
|
|
192
|
+
if (this.openDirection == 'down') {
|
|
193
|
+
pos.t = offset.top + this.offsetHeight - 1;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
pos.t = offset.top - this.dropdown.offsetHeight + 1;
|
|
197
|
+
}
|
|
184
198
|
if (this.alignment == 'left') {
|
|
185
199
|
this.dropdown.style.right = 'auto';
|
|
186
|
-
|
|
187
|
-
t: offset.top + this.offsetHeight - 1,
|
|
188
|
-
l: this.positionOffset + offset.left
|
|
189
|
-
});
|
|
190
|
-
dom.fixElementPosition(this.dropdown);
|
|
200
|
+
pos.l = this.positionOffset + offset.left;
|
|
191
201
|
}
|
|
192
202
|
else {
|
|
193
203
|
this.dropdown.style.left = 'auto';
|
|
194
|
-
|
|
195
|
-
t: offset.top + this.offsetHeight - 1,
|
|
196
|
-
r: this.dropdownParent.clientWidth - this.positionOffset - offset.left - this.offsetWidth
|
|
197
|
-
});
|
|
204
|
+
pos.r = this.dropdownParent.clientWidth - this.positionOffset - offset.left - this.offsetWidth;
|
|
198
205
|
}
|
|
206
|
+
dom.setPosition(this.dropdown, pos);
|
|
207
|
+
dom.fixElementPosition(this.dropdown);
|
|
199
208
|
}
|
|
200
209
|
};
|
|
201
210
|
Dropdown.styles = [css `
|
|
@@ -213,11 +222,16 @@ Dropdown.styles = [css `
|
|
|
213
222
|
height: ${constants.BUTTON_HEIGHT}px;
|
|
214
223
|
}
|
|
215
224
|
|
|
216
|
-
:host(.radiusfix) {
|
|
225
|
+
:host(.radiusfix-down) {
|
|
217
226
|
border-bottom-left-radius: 0;
|
|
218
227
|
border-bottom-right-radius: 0;
|
|
219
228
|
}
|
|
220
229
|
|
|
230
|
+
:host(.radiusfix-up) {
|
|
231
|
+
border-top-left-radius: 0;
|
|
232
|
+
border-top-right-radius: 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
div.text {
|
|
222
236
|
flex: 1;
|
|
223
237
|
color: var(--og-text-color-1);
|
|
@@ -237,6 +251,9 @@ Dropdown.styles = [css `
|
|
|
237
251
|
__decorate([
|
|
238
252
|
property({ type: String })
|
|
239
253
|
], Dropdown.prototype, "alignment", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
property({ type: String, reflect: true })
|
|
256
|
+
], Dropdown.prototype, "openDirection", void 0);
|
|
240
257
|
__decorate([
|
|
241
258
|
property({ type: Number })
|
|
242
259
|
], Dropdown.prototype, "positionOffset", void 0);
|
package/dist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/decorators.js';\nimport { ColorTypes, Layout } from '../types';\nimport * as dom from '../common/dom';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { createRef, ref } from 'lit-html/directives/ref.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { IconSpec } from './icon';\nimport { utils } from '../common';\nimport { colorable } from '../themes';\nimport constants from '../constants';\n\nexport class DropdownEvent extends Event {\n\n\tconstructor(event: string) {\n\t\tsuper(`dropdown.${event}`);\n\t}\n}\n\n@customElement('og-dropdown-container')\n@colorable({props: ['border']})\nexport class DropdownContainer extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tbackground-color: var(--og-background-color);\n\t\t\tposition: absolute;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t\tcolor: var(--og-text-color);\n\t\t\tz-index: 60000;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\tbox-shadow: var(--og-base-shadow);\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-top-left-radius: 0;\n\t\t\tborder-top-right-radius: 0;\n\t\t}\n\t`;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', (e: MouseEvent) => e.stopPropagation());\n\t}\n\n\trender = () => html`<div><slot name=\"inner-content\"></slot></div>`;\n}\n\n@customElement('og-dropdown')\n@colorable({props: ['border']})\nexport class Dropdown extends LitElement implements Layout {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: flex;\n\t\t\talign-items: stretch;\n\t\t\tflex-direction: row;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tcursor: pointer;\n\t\t\tuser-select: none;\n\t\t\toutline: none;\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\theight: ${constants.BUTTON_HEIGHT}px;\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;\n\t\t}\n\n\t\tdiv.text {\n\t\t\tflex: 1;\n\t\t\tcolor: var(--og-text-color-1);\n\t\t\tpadding-left: 2px;\n\t\t\twhite-space: nowrap;\n\t\t\ttext-overflow: ellipsis;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-button {\n\t\t\tflex: 1;\n\t\t\tborder-radius: 0;\n\t\t\tborder: none;\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: String})\n\talignment: 'left'|'right' = 'right';\n\n\t@property({type: Number})\n\tpositionOffset = 0;\n\n\t@property({type: Object})\n\tdropdownParent: HTMLElement = document.body;\n\n\t@property({type: Number})\n\tanimation = 0.1;\n\n\t@property()\n\tlabel: string|HTMLElement|TemplateResult;\n\n\t@property()\n\ticon: IconSpec|string;\n\n\t@property({type: Number})\n\twidth: number;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\t@property({type: Boolean})\n\tnoCaret = false;\n\n\t@query('.label')\n\tlabelElm: HTMLDivElement;\n\n\tprivate _contentElm: HTMLElement;\n\n\tprotected dropdownRef = createRef<DropdownContainer>();\n\tget dropdown() { return this.dropdownRef?.value }\n\n\tget isOpen() { return this.dropdown && !dom.isHidden(this.dropdown) }\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onDocumentMouseDown = (e: MouseEvent) => {\n\t\tfor (const elm of e.composedPath()) {\n\t\t\tif (elm == this.dropdown || elm == this) return;\n\t\t}\n\t\tthis.close();\n\t}\n\n\tanimateDropdown(seconds: number) {\n\t\tconst height = this.dropdown.offsetHeight;\n\t\tdom.setSize(this.dropdown, {h: 0});\n\t\tthis.dropdown.style.transition = `height ${seconds}s ease-in-out`;\n\t\tsetTimeout(() => dom.setSize(this.dropdown, {h: height}), 0);\n\t\tsetTimeout(() => {\n\t\t\tthis.dropdown.style.height = 'auto';\n\t\t\tthis.dropdown.style.transition = '';\n\t\t}, seconds * 1000);\n\t}\n\n\tasync open() {\n\t\tthis.dispatchEvent(new DropdownEvent('beforeOpen'));\n\t\tawait this.updateComplete;\n\t\t\n\t\tif (this.dropdown.parentElement !== this.dropdownParent) {\n\t\t\tthis.dropdownParent.appendChild(this.dropdown);\n\t\t}\n\n\t\tif (this.children.length > 0 && !this._contentElm) {\n\t\t\tthis._contentElm = [...this.children].find(elm => elm.slot == 'content') as HTMLElement;\n\t\t\tif (this._contentElm) {\n\t\t\t\tthis._contentElm.slot = 'inner-content';\n\t\t\t\tthis.dropdown.appendChild(this._contentElm);\n\t\t\t}\n\t\t}\n\n\t\tif (this.width > 0) dom.setSize(this.dropdown, {w: this.width});\n\t\tdom.showElement(this.dropdown);\n\t\tthis.requestUpdate();\n\t\tawait this.dropdown.updateComplete;\n\t\tthis.dispatchEvent(new DropdownEvent('open'));\n\t\tthis.layout();\n\n\t\tif (this.animation > 0) this.animateDropdown(this.animation);\n\n\t\tdocument.body.addEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\tclose() {\n\t\tif (this.dropdown) dom.hideElement(this.dropdown);\n\t\tthis.layout();\n\t\tdocument.body.removeEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\ttoggle() {\n\t\tif (this.isOpen) this.close();\n\t\telse this.open();\n\t}\n\n\t_onMousedown = async () => this.toggle();\n\n\tdisconnectedCallback() {\n\t\tthis.dropdown?.remove();\n\t\tsuper.disconnectedCallback();\n\t}\n\n\trenderDropdown = () => html`\n\t\t<og-dropdown-container ${ref(this.dropdownRef)}\n\t\t\tstyle=\"display: none\">\n\t\t</og-dropdown-container>\n\t`;\n\n\trenderLabel = () => {\n\t\tif (utils.isString(this.label)) {\n\t\t\treturn this.label === '' ? unsafeHTML(' ') : html`<div class=\"text\">${this.label}</div>`;\n\t\t} else {\n\t\t\treturn this.label;\n\t\t}\n\t};\n\n\tget hasLabelSlot() {\n\t\treturn this.querySelector('[slot=\"label\"]') != null;\n\t}\n\n\tget hasLabel() {\n\t\treturn this.label !== '' && this.label != null;\n\t}\n\n\tupdated(props: Map<string, unknown>) {\n\t\tsuper.updated(props);\n\t\tif (this.dropdown) this.dropdown.color = this.color == ColorTypes.Transparent ? ColorTypes.Accent : this.color;\n\t}\n\n\trender = () => html`\n\t\t<og-button\n\t\t\t@mousedown=\"${this._onMousedown}\"\n\t\t\tclass=\"main\"\n\t\t\tcolor=\"${this.color}\"\n\t\t\t.icon=\"${this.icon}\"\n\t\t\t?caret=\"${!this.noCaret}\">\n\t\t\t${this.hasLabelSlot ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\"><slot name=\"label\"></slot></div>\n\t\t\t` : guard([this.label], () => (this.hasLabel ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\">${this.renderLabel()}</div>\n\t\t\t` : ''))}\n\t\t</og-button>\n\n\t\t${this.renderDropdown()}\n\t`;\n\n\tget useRadiusFix() {\n\t\treturn this.isOpen && this.color != ColorTypes.Transparent;\n\t}\n\n\tlayout() {\n\t\tthis.classList.toggle('radiusfix', this.useRadiusFix);\n\t\tif (!this.dropdown) return;\n\t\tthis.dropdown.classList.toggle('radiusfix', this.useRadiusFix);\n\t\tif (!this.isOpen) return;\n\n\t\tconst offset = dom.getElementOffset(this, this.dropdownParent);\n\t\tdom.setSize(this.dropdown, {w: this.offsetWidth}, true);\n\n\t\tif (this.alignment == 'left') {\n\t\t\tthis.dropdown.style.right = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tl: this.positionOffset + offset.left\n\t\t\t});\n\t\t\tdom.fixElementPosition(this.dropdown);\n\t\t} else {\n\t\t\tthis.dropdown.style.left = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tr: this.dropdownParent.clientWidth - this.positionO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IADC,QAAQ,EAAE;uCAC8B;AAGzC;IADC,QAAQ,EAAE;sCACW;AAGtB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;uCACX;AAGd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;uCACd;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;yCACV;AAGhB;IADC,KAAK,CAAC,QAAQ,CAAC;0CACS;AA3Eb,QAAQ;IAFpB,aAAa,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAC,CAAC;GAClB,QAAQ,CAuOpB","sourcesContent":["import { LitElement, html, css, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ColorTypes, CssPosition, Layout, VerticalDirection } from '../types';\nimport * as dom from '../common/dom';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { createRef, ref } from 'lit-html/directives/ref.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { IconSpec } from './icon';\nimport { utils } from '../common';\nimport { colorable } from '../themes';\nimport constants from '../constants';\n\nexport class DropdownEvent extends Event {\n\n\tconstructor(event: string) {\n\t\tsuper(`dropdown.${event}`);\n\t}\n}\n\n@customElement('og-dropdown-container')\n@colorable({props: ['border']})\nexport class DropdownContainer extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tbackground-color: var(--og-background-color);\n\t\t\tposition: absolute;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t\tcolor: var(--og-text-color);\n\t\t\tz-index: 60000;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\tbox-shadow: var(--og-base-shadow);\n\t\t}\n\n\t\t:host(.radiusfix-down) {\n\t\t\tborder-top-left-radius: 0;\n\t\t\tborder-top-right-radius: 0;\n\t\t}\n\n\t\t:host(.radiusfix-up) {\n\t\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;\n\t\t}\n\t`;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', (e: MouseEvent) => e.stopPropagation());\n\t}\n\n\trender = () => html`<div><slot name=\"inner-content\"></slot></div>`;\n}\n\n@customElement('og-dropdown')\n@colorable({props: ['border']})\nexport class Dropdown extends LitElement implements Layout {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: flex;\n\t\t\talign-items: stretch;\n\t\t\tflex-direction: row;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tcursor: pointer;\n\t\t\tuser-select: none;\n\t\t\toutline: none;\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\theight: ${constants.BUTTON_HEIGHT}px;\n\t\t}\n\n\t\t:host(.radiusfix-down) {\n\t\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;\n\t\t}\n\n\t\t:host(.radiusfix-up) {\n\t\t\tborder-top-left-radius: 0;\n\t\t\tborder-top-right-radius: 0;\n\t\t}\n\n\t\tdiv.text {\n\t\t\tflex: 1;\n\t\t\tcolor: var(--og-text-color-1);\n\t\t\tpadding-left: 2px;\n\t\t\twhite-space: nowrap;\n\t\t\ttext-overflow: ellipsis;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-button {\n\t\t\tflex: 1;\n\t\t\tborder-radius: 0;\n\t\t\tborder: none;\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: String})\n\talignment: 'left'|'right' = 'right';\n\n\t@property({type: String, reflect: true})\n\topenDirection: VerticalDirection = 'down';\n\n\t@property({type: Number})\n\tpositionOffset = 0;\n\n\t@property({type: Object})\n\tdropdownParent: HTMLElement = document.body;\n\n\t@property({type: Number})\n\tanimation = 0.1;\n\n\t@property()\n\tlabel: string|HTMLElement|TemplateResult;\n\n\t@property()\n\ticon: IconSpec|string;\n\n\t@property({type: Number})\n\twidth: number;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\t@property({type: Boolean})\n\tnoCaret = false;\n\n\t@query('.label')\n\tlabelElm: HTMLDivElement;\n\n\tprivate _contentElm: HTMLElement;\n\n\tprotected dropdownRef = createRef<DropdownContainer>();\n\tget dropdown() { return this.dropdownRef?.value }\n\n\tget isOpen() { return this.dropdown && !dom.isHidden(this.dropdown) }\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onDocumentMouseDown = (e: MouseEvent) => {\n\t\tfor (const elm of e.composedPath()) {\n\t\t\tif (elm == this.dropdown || elm == this) return;\n\t\t}\n\t\tthis.close();\n\t}\n\n\tanimateDropdown(seconds: number) {\n\t\tconst height = this.dropdown.offsetHeight;\n\t\tdom.setSize(this.dropdown, {h: 0});\n\t\tthis.dropdown.style.transition = `height ${seconds}s ease-in-out`;\n\t\tsetTimeout(() => dom.setSize(this.dropdown, {h: height}), 0);\n\t\tsetTimeout(() => {\n\t\t\tthis.dropdown.style.height = 'auto';\n\t\t\tthis.dropdown.style.transition = '';\n\t\t\tthis.layout();\n\t\t}, seconds * 1000);\n\t}\n\n\tasync open() {\n\t\tthis.dispatchEvent(new DropdownEvent('beforeOpen'));\n\t\tawait this.updateComplete;\n\t\t\n\t\tif (this.dropdown.parentElement !== this.dropdownParent) {\n\t\t\tthis.dropdownParent.appendChild(this.dropdown);\n\t\t}\n\n\t\tif (this.children.length > 0 && !this._contentElm) {\n\t\t\tthis._contentElm = [...this.children].find(elm => elm.slot == 'content') as HTMLElement;\n\t\t\tif (this._contentElm) {\n\t\t\t\tthis._contentElm.slot = 'inner-content';\n\t\t\t\tthis.dropdown.appendChild(this._contentElm);\n\t\t\t}\n\t\t}\n\n\t\tif (this.width > 0) dom.setSize(this.dropdown, {w: this.width});\n\t\tdom.showElement(this.dropdown);\n\t\tthis.requestUpdate();\n\t\tawait this.dropdown.updateComplete;\n\t\tthis.dispatchEvent(new DropdownEvent('open'));\n\t\tthis.layout();\n\n\t\tif (this.animation > 0) this.animateDropdown(this.animation);\n\n\t\tdocument.body.addEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\tclose() {\n\t\tif (this.dropdown) dom.hideElement(this.dropdown);\n\t\tthis.layout();\n\t\tdocument.body.removeEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\ttoggle() {\n\t\tif (this.isOpen) this.close();\n\t\telse this.open();\n\t}\n\n\t_onMousedown = async () => this.toggle();\n\n\tdisconnectedCallback() {\n\t\tthis.dropdown?.remove();\n\t\tsuper.disconnectedCallback();\n\t}\n\n\trenderDropdown = () => html`\n\t\t<og-dropdown-container ${ref(this.dropdownRef)}\n\t\t\tstyle=\"display: none\">\n\t\t</og-dropdown-container>\n\t`;\n\n\trenderLabel = () => {\n\t\tif (utils.isString(this.label)) {\n\t\t\treturn this.label === '' ? unsafeHTML(' ') : html`<div class=\"text\">${this.label}</div>`;\n\t\t} else {\n\t\t\treturn this.label;\n\t\t}\n\t};\n\n\tget hasLabelSlot() {\n\t\treturn this.querySelector('[slot=\"label\"]') != null;\n\t}\n\n\tget hasLabel() {\n\t\treturn this.label !== '' && this.label != null;\n\t}\n\n\tupdated(props: Map<string, unknown>) {\n\t\tsuper.updated(props);\n\t\tif (this.dropdown) this.dropdown.color = this.color == ColorTypes.Transparent ? ColorTypes.Accent : this.color;\n\t}\n\n\trender = () => html`\n\t\t<og-button\n\t\t\t@mousedown=\"${this._onMousedown}\"\n\t\t\tclass=\"main\"\n\t\t\tcolor=\"${this.color}\"\n\t\t\t.icon=\"${this.icon}\"\n\t\t\t.caret=\"${this.noCaret ? 'none' : this.openDirection}\">\n\t\t\t${this.hasLabelSlot ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\"><slot name=\"label\"></slot></div>\n\t\t\t` : guard([this.label], () => (this.hasLabel ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\">${this.renderLabel()}</div>\n\t\t\t` : ''))}\n\t\t</og-button>\n\n\t\t${this.renderDropdown()}\n\t`;\n\n\tget useRadiusFix() {\n\t\treturn this.isOpen && this.color != ColorTypes.Transparent;\n\t}\n\n\tlayout() {\n\t\tthis.classList.toggle(`radiusfix-${this.openDirection}`, this.useRadiusFix);\n\t\tif (!this.dropdown) return;\n\t\tthis.dropdown.classList.toggle(`radiusfix-${this.openDirection}`, this.useRadiusFix);\n\t\tif (!this.isOpen) return;\n\n\t\tconst offset = dom.getElementOffset(this, this.dropdownParent);\n\t\tdom.setSize(this.dropdown, {w: this.offsetWidth}, true);\n\n\t\tconst pos: CssPosition = {t: 'unset', b: 'unset', l: 'unset', r: 'unset'};\n\n\t\tif (this.openDirection == 'down') {\n\t\t\tpos.t = offset.top + this.offsetHeight - 1;\n\t\t} else {\n\t\t\tpos.t = offset.top - this.dropdown.offsetHeight + 1;\n\t\t}\n\n\t\tif (this.alignment == 'left') {\n\t\t\tthis.dropdown.style.right = 'auto';\n\t\t\tpos.l = this.positionOffset + offset.left;\n\t\t} else {\n\t\t\tthis.dropdown.style.left = 'auto';\n\t\t\tpos.r = this.dropdownParent.clientWidth - this.positionOffset - offset.left - this.offsetWidth;\n\t\t}\n\n\t\tdom.setPosition(this.dropdown, pos);\n\t\tdom.fixElementPosition(this.dropdown);\n\t}\n\n}"]}
|
package/dist/ui/index.d.ts
CHANGED
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc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CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/dist/ui/index.js
CHANGED
package/dist/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './baseElement';\nexport * from './button';\nexport * from './close';\nexport * from './checkbox';\nexport * from './container';\nexport * from './colorpicker';\nexport * from './dropdown';\nexport * from './dropdownColorPicker';\nexport * from './dropdownList';\nexport * from './dropdownMenu';\nexport * from './expander';\nexport * from './floatingWindow';\nexport * from './icon';\nexport * from './images';\nexport * from './input';\nexport * from './fileInput';\nexport * from './numericInput';\nexport * from './list';\nexport * from './menu';\nexport * from './overlay';\nexport * from './panel';\nexport * from './sizer';\nexport * from './splitContainer';\nexport * from './slider';\nexport * from './sortableList';\nexport * from './switch';\nexport * from './tooltip';\nexport * from './loader';"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC","sourcesContent":["export * from './accordion';\nexport * from './alert';\nexport * from './baseElement';\nexport * from './button';\nexport * from './close';\nexport * from './checkbox';\nexport * from './container';\nexport * from './colorpicker';\nexport * from './dropdown';\nexport * from './dropdownColorPicker';\nexport * from './dropdownList';\nexport * from './dropdownMenu';\nexport * from './expander';\nexport * from './floatingWindow';\nexport * from './icon';\nexport * from './images';\nexport * from './input';\nexport * from './label';\nexport * from './fileInput';\nexport * from './numericInput';\nexport * from './list';\nexport * from './menu';\nexport * from './overlay';\nexport * from './panel';\nexport * from './sizer';\nexport * from './splitContainer';\nexport * from './slider';\nexport * from './sortableList';\nexport * from './switch';\nexport * from './tooltip';\nexport * from './loader';"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OmegaComponent } from "../model";
|
|
2
|
+
import { Tooltip, TooltipPosition } from "./tooltip";
|
|
3
|
+
export declare class Label extends OmegaComponent {
|
|
4
|
+
static styles: import("lit").CSSResultGroup[];
|
|
5
|
+
text: string;
|
|
6
|
+
tooltipPosition: TooltipPosition;
|
|
7
|
+
div: HTMLDivElement;
|
|
8
|
+
contentSlot: HTMLSlotElement;
|
|
9
|
+
get isOverflown(): boolean;
|
|
10
|
+
private _tooltip;
|
|
11
|
+
get tooltip(): Tooltip;
|
|
12
|
+
constructor();
|
|
13
|
+
disconnectedCallback(): void;
|
|
14
|
+
updated(): void;
|
|
15
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../src/ui/label.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIrD,qBACa,KAAM,SAAQ,cAAc;IAExC,MAAM,CAAC,MAAM,iCAYV;IAGH,IAAI,EAAE,MAAM,CAAM;IAGlB,eAAe,EAAE,eAAe,CAAS;IAGzC,GAAG,EAAG,cAAc,CAAC;IAGrB,WAAW,EAAG,eAAe,CAAC;IAE9B,IAAI,WAAW,YAGd;IAED,OAAO,CAAC,QAAQ,CAAwB;IACxC,IAAI,OAAO,YAOV;;IAqBD,oBAAoB,IAAI,IAAI;IAM5B,OAAO;IAIP,MAAM,6CAEJ;CAEF"}
|
package/dist/ui/label.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html } from "lit";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
+
import { OmegaComponent } from "../model";
|
|
10
|
+
import { dom } from "../common";
|
|
11
|
+
import { unsafeHTML } from "lit-html/directives/unsafe-html.js";
|
|
12
|
+
let Label = class Label extends OmegaComponent {
|
|
13
|
+
get isOverflown() {
|
|
14
|
+
if (!this.div)
|
|
15
|
+
return false;
|
|
16
|
+
return this.div.scrollWidth > this.div.clientWidth;
|
|
17
|
+
}
|
|
18
|
+
get tooltip() {
|
|
19
|
+
if (this._tooltip)
|
|
20
|
+
return this._tooltip;
|
|
21
|
+
this._tooltip = dom.createElement('og-tooltip', {
|
|
22
|
+
style: { maxWidth: '300px' }
|
|
23
|
+
});
|
|
24
|
+
document.body.appendChild(this._tooltip);
|
|
25
|
+
return this._tooltip;
|
|
26
|
+
}
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.text = '';
|
|
30
|
+
this.tooltipPosition = 'top';
|
|
31
|
+
this._tooltip = null;
|
|
32
|
+
this.render = () => html `
|
|
33
|
+
<div>${this.text == '' ? html `<slot name="content"></slot>` : this.text}</div>
|
|
34
|
+
`;
|
|
35
|
+
this.addEventListener('mouseenter', () => {
|
|
36
|
+
if (this.isOverflown) {
|
|
37
|
+
if (this.text === '') {
|
|
38
|
+
const slotNodes = this.contentSlot.assignedNodes({ flatten: true });
|
|
39
|
+
if (slotNodes.length === 0)
|
|
40
|
+
return;
|
|
41
|
+
this.tooltip.content = html `${unsafeHTML(slotNodes[0].outerHTML)}`;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.tooltip.content = this.text;
|
|
45
|
+
}
|
|
46
|
+
this.tooltip.attachTo(this, this.tooltipPosition);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
this.addEventListener('mouseleave', () => {
|
|
50
|
+
this.tooltip?.deatach();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
this._tooltip?.destroy();
|
|
56
|
+
this._tooltip = null;
|
|
57
|
+
}
|
|
58
|
+
updated() {
|
|
59
|
+
console.log('Label updated, isOverflown=', this.isOverflown);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
Label.styles = [OmegaComponent.styles, css `
|
|
63
|
+
:host {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
max-width: 100%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
div {
|
|
69
|
+
display: block;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
}
|
|
74
|
+
`];
|
|
75
|
+
__decorate([
|
|
76
|
+
property({ type: String })
|
|
77
|
+
], Label.prototype, "text", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
property({ type: String })
|
|
80
|
+
], Label.prototype, "tooltipPosition", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
query('div')
|
|
83
|
+
], Label.prototype, "div", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
query('slot')
|
|
86
|
+
], Label.prototype, "contentSlot", void 0);
|
|
87
|
+
Label = __decorate([
|
|
88
|
+
customElement('og-label')
|
|
89
|
+
], Label);
|
|
90
|
+
export { Label };
|
|
91
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/ui/label.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGzD,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,cAAc;IA4BxC,IAAI,WAAW;QACd,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;IACpD,CAAC;IAGD,IAAI,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAU,YAAY,EAAE;YACxD,KAAK,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC;SAC1B,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED;Q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G,IAAI,CAAC;IACtB,CAAC;IAED,OAAO;QACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;;AApEM,YAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;EAY1C,CAAC,AAZW,CAYV;AAGH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;mCACP;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACgB;AAGzC;IADC,KAAK,CAAC,KAAK,CAAC;kCACQ;AAGrB;IADC,KAAK,CAAC,MAAM,CAAC;0CACgB;AA1BlB,KAAK;IADjB,aAAa,CAAC,UAAU,CAAC;GACb,KAAK,CA4EjB","sourcesContent":["import { css, html } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { OmegaComponent } from \"../model\";\nimport { Tooltip, TooltipPosition } from \"./tooltip\";\nimport { dom } from \"../common\";\nimport { unsafeHTML } from \"lit-html/directives/unsafe-html.js\";\n\n@customElement('og-label')\nexport class Label extends OmegaComponent {\n\n\tstatic styles = [OmegaComponent.styles, css`\n\t\t:host {\n\t\t\tdisplay: inline-block;\n\t\t\tmax-width: 100%;\n\t\t}\n\n\t\tdiv {\n\t\t\tdisplay: block;\n\t\t\toverflow: hidden;\n\t\t\ttext-overflow: ellipsis;\n\t\t\twhite-space: nowrap;\n\t\t}\n\t`];\n\n\t@property({type: String})\n\ttext: string = '';\n\n\t@property({type: String})\n\ttooltipPosition: TooltipPosition = 'top';\n\n\t@query('div')\n\tdiv!: HTMLDivElement;\n\n\t@query('slot')\n\tcontentSlot!: HTMLSlotElement;\n\n\tget isOverflown() {\n\t\tif (!this.div) return false;\n\t\treturn this.div.scrollWidth > this.div.clientWidth;\n\t}\n\n\tprivate _tooltip: Tooltip | null = null;\n\tget tooltip() {\n\t\tif (this._tooltip) return this._tooltip;\n\t\tthis._tooltip = dom.createElement<Tooltip>('og-tooltip', {\n\t\t\tstyle: {maxWidth: '300px'}\n\t\t});\n\t\tdocument.body.appendChild(this._tooltip);\n\t\treturn this._tooltip;\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mouseenter', () => {\n\t\t\tif (this.isOverflown) {\n\t\t\t\tif (this.text === '') {\n\t\t\t\t\tconst slotNodes = this.contentSlot.assignedNodes({flatten: true});\n\t\t\t\t\tif (slotNodes.length === 0) return;\n\t\t\t\t\tthis.tooltip.content = html`${unsafeHTML((slotNodes[0] as HTMLElement).outerHTML)}`;\n\t\t\t\t} else {\n\t\t\t\t\tthis.tooltip.content = this.text;\n\t\t\t\t}\n\t\t\t\tthis.tooltip.attachTo(this, this.tooltipPosition);\n\t\t\t}\n\t\t});\n\t\tthis.addEventListener('mouseleave', () => {\n\t\t\tthis.tooltip?.deatach();\n\t\t});\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tsuper.disconnectedCallback();\n\t\tthis._tooltip?.destroy();\n\t\tthis._tooltip = null;\n\t}\n\n\tupdated() {\n\t\tconsole.log('Label updated, isOverflown=', this.isOverflown);\n\t}\n\n\trender = () => html`\n\t\t<div>${this.text == '' ? html`<slot name=\"content\"></slot>` : this.text}</div>\n\t`;\n\t\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.40",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Core components",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fortawesome/fontawesome-svg-core": "^7.0.1",
|
|
39
|
-
"@omegagrid/localize": "^0.9.
|
|
39
|
+
"@omegagrid/localize": "^0.9.40",
|
|
40
40
|
"color": "^4.2.3",
|
|
41
41
|
"date-fns": "^3.2.0",
|
|
42
42
|
"lit": "^3.1.1",
|