@ni/ok-components 0.2.7 → 0.2.9
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/all-components-bundle.js +439 -357
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +37 -14
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/all-components.d.ts +1 -0
- package/dist/esm/all-components.js +1 -0
- package/dist/esm/all-components.js.map +1 -1
- package/dist/esm/icon-dynamic/index.d.ts +23 -0
- package/dist/esm/icon-dynamic/index.js +59 -0
- package/dist/esm/icon-dynamic/index.js.map +1 -0
- package/dist/esm/icon-dynamic/styles.d.ts +1 -0
- package/dist/esm/icon-dynamic/styles.js +20 -0
- package/dist/esm/icon-dynamic/styles.js.map +1 -0
- package/dist/esm/icon-dynamic/template.d.ts +2 -0
- package/dist/esm/icon-dynamic/template.js +3 -0
- package/dist/esm/icon-dynamic/template.js.map +1 -0
- package/dist/esm/utilities/style/user-select.d.ts +5 -0
- package/dist/esm/utilities/style/user-select.js +10 -0
- package/dist/esm/utilities/style/user-select.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,gDAAgD,CAAC;AAExD,OAAO,UAAU,CAAC","sourcesContent":["/**\n * Import of all the web components available in Nimble, Spright, and Ok.\n * Production applications are encouraged to import only components\n * that are required instead of leveraging this file.\n */\n\nimport '@ni/spright-components/dist/esm/all-components';\n\nimport './button';\n"]}
|
|
1
|
+
{"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,gDAAgD,CAAC;AAExD,OAAO,UAAU,CAAC;AAClB,OAAO,gBAAgB,CAAC","sourcesContent":["/**\n * Import of all the web components available in Nimble, Spright, and Ok.\n * Production applications are encouraged to import only components\n * that are required instead of leveraging this file.\n */\n\nimport '@ni/spright-components/dist/esm/all-components';\n\nimport './button';\nimport './icon-dynamic';\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Icon } from '@ni/nimble-components/dist/esm/icon-base';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'ok-icon-dynamic': IconDynamic;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:
|
|
9
|
+
* ```
|
|
10
|
+
* customElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');
|
|
11
|
+
* ```
|
|
12
|
+
* After calling successfully, the icon can be used like any other icon:
|
|
13
|
+
* ```
|
|
14
|
+
* <ok-icon-dynamic-awesome></ok-icon-dynamic-awesome>
|
|
15
|
+
* <nimble-mapping-icon icon="ok-icon-dynamic-awesome"></nimble-mapping-icon>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class IconDynamic extends Icon {
|
|
19
|
+
readonly url: string;
|
|
20
|
+
constructor(/** @internal */ url: string);
|
|
21
|
+
static registerIconDynamic(tagName: string, url: string): void;
|
|
22
|
+
}
|
|
23
|
+
export declare const iconDynamicTag = "ok-icon-dynamic";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { DesignSystem } from '@ni/fast-foundation';
|
|
3
|
+
import { html, css } from '@ni/fast-element';
|
|
4
|
+
import { Icon } from '@ni/nimble-components/dist/esm/icon-base';
|
|
5
|
+
import { styles } from './styles';
|
|
6
|
+
import { template } from './template';
|
|
7
|
+
import { display } from '../utilities/style/display';
|
|
8
|
+
/**
|
|
9
|
+
* Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:
|
|
10
|
+
* ```
|
|
11
|
+
* customElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');
|
|
12
|
+
* ```
|
|
13
|
+
* After calling successfully, the icon can be used like any other icon:
|
|
14
|
+
* ```
|
|
15
|
+
* <ok-icon-dynamic-awesome></ok-icon-dynamic-awesome>
|
|
16
|
+
* <nimble-mapping-icon icon="ok-icon-dynamic-awesome"></nimble-mapping-icon>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class IconDynamic extends Icon {
|
|
20
|
+
constructor(/** @internal */ url) {
|
|
21
|
+
super();
|
|
22
|
+
this.url = url;
|
|
23
|
+
}
|
|
24
|
+
static registerIconDynamic(tagName, url) {
|
|
25
|
+
const tagPrefix = 'ok-icon-dynamic-';
|
|
26
|
+
if (!tagName.startsWith(tagPrefix)) {
|
|
27
|
+
throw new Error(`Icon tag name must start with '${tagPrefix}', provided name: ${tagName}`);
|
|
28
|
+
}
|
|
29
|
+
const name = tagName.substring(tagPrefix.length);
|
|
30
|
+
if (!/^[a-z][a-z]+$/.test(name)) {
|
|
31
|
+
throw new Error(`Icon name must be lowercase [a-z] and at least two characters long, provided name: ${name}`);
|
|
32
|
+
}
|
|
33
|
+
const iconClassName = `IconDynamic${name.charAt(0).toUpperCase() + name.slice(1)}`;
|
|
34
|
+
const iconClassContainer = {
|
|
35
|
+
// Class name for expression should come object literal assignment, helpful for stack traces, etc.
|
|
36
|
+
[iconClassName]: class extends IconDynamic {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(url);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const iconClass = iconClassContainer[iconClassName];
|
|
43
|
+
const baseName = `icon-dynamic-${name}`;
|
|
44
|
+
const composedIcon = iconClass.compose({
|
|
45
|
+
baseName,
|
|
46
|
+
template,
|
|
47
|
+
styles
|
|
48
|
+
});
|
|
49
|
+
DesignSystem.getOrCreate().withPrefix('ok').register(composedIcon());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const okIconDynamic = IconDynamic.compose({
|
|
53
|
+
baseName: 'icon-dynamic',
|
|
54
|
+
template: html `<template></template>`,
|
|
55
|
+
styles: css `${display('none')}`
|
|
56
|
+
});
|
|
57
|
+
DesignSystem.getOrCreate().withPrefix('ok').register(okIconDynamic());
|
|
58
|
+
export const iconDynamicTag = 'ok-icon-dynamic';
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/icon-dynamic/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAQrD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAY,SAAQ,IAAI;IACjC,YAAmB,gBAAgB,CAAiB,GAAW;QAC3D,KAAK,EAAE,CAAC;QADwC,QAAG,GAAH,GAAG,CAAQ;IAE/D,CAAC;IAEM,MAAM,CAAC,mBAAmB,CAAC,OAAe,EAAE,GAAW;QAC1D,MAAM,SAAS,GAAG,kBAAkB,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,kCAAkC,SAAS,qBAAqB,OAAO,EAAE,CAAC,CAAC;QAC/F,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,sFAAsF,IAAI,EAAE,CAAC,CAAC;QAClH,CAAC;QACD,MAAM,aAAa,GAAG,cAAc,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,MAAM,kBAAkB,GAAG;YACvB,kGAAkG;YAClG,CAAC,aAAa,CAAC,EAAE,KAAM,SAAQ,WAAW;gBACtC;oBACI,KAAK,CAAC,GAAG,CAAC,CAAC;gBACf,CAAC;aACJ;SACK,CAAC;QACX,MAAM,SAAS,GAAG,kBAAkB,CAAC,aAAa,CAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,gBAAgB,IAAI,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC;YACnC,QAAQ;YACR,QAAQ;YACR,MAAM;SACT,CAAC,CAAC;QAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IACzE,CAAC;CACJ;AAED,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC;IACtC,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,IAAI,CAAA,uBAAuB;IACrC,MAAM,EAAE,GAAG,CAAA,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE;CAClC,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC","sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { DesignSystem } from '@ni/fast-foundation';\nimport { html, css } from '@ni/fast-element';\nimport { Icon } from '@ni/nimble-components/dist/esm/icon-base';\nimport { styles } from './styles';\nimport { template } from './template';\nimport { display } from '../utilities/style/display';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ok-icon-dynamic': IconDynamic;\n }\n}\n\n/**\n * Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:\n * ```\n * customElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');\n * ```\n * After calling successfully, the icon can be used like any other icon:\n * ```\n * <ok-icon-dynamic-awesome></ok-icon-dynamic-awesome>\n * <nimble-mapping-icon icon=\"ok-icon-dynamic-awesome\"></nimble-mapping-icon>\n * ```\n */\nexport class IconDynamic extends Icon {\n public constructor(/** @internal */ public readonly url: string) {\n super();\n }\n\n public static registerIconDynamic(tagName: string, url: string): void {\n const tagPrefix = 'ok-icon-dynamic-';\n if (!tagName.startsWith(tagPrefix)) {\n throw new Error(`Icon tag name must start with '${tagPrefix}', provided name: ${tagName}`);\n }\n const name = tagName.substring(tagPrefix.length);\n if (!/^[a-z][a-z]+$/.test(name)) {\n throw new Error(`Icon name must be lowercase [a-z] and at least two characters long, provided name: ${name}`);\n }\n const iconClassName = `IconDynamic${name.charAt(0).toUpperCase() + name.slice(1)}`;\n const iconClassContainer = {\n // Class name for expression should come object literal assignment, helpful for stack traces, etc.\n [iconClassName]: class extends IconDynamic {\n constructor() {\n super(url);\n }\n }\n } as const;\n const iconClass = iconClassContainer[iconClassName]!;\n const baseName = `icon-dynamic-${name}`;\n const composedIcon = iconClass.compose({\n baseName,\n template,\n styles\n });\n\n DesignSystem.getOrCreate().withPrefix('ok').register(composedIcon());\n }\n}\n\nconst okIconDynamic = IconDynamic.compose({\n baseName: 'icon-dynamic',\n template: html`<template></template>`,\n styles: css`${display('none')}`\n});\n\nDesignSystem.getOrCreate().withPrefix('ok').register(okIconDynamic());\nexport const iconDynamicTag = 'ok-icon-dynamic';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("@ni/fast-element").ElementStyles;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { css } from '@ni/fast-element';
|
|
2
|
+
import { iconSize, } from '@ni/nimble-components/dist/esm/theme-provider/design-tokens';
|
|
3
|
+
import { display } from '../utilities/style/display';
|
|
4
|
+
import { userSelectNone } from '../utilities/style/user-select';
|
|
5
|
+
export const styles = css `
|
|
6
|
+
${display('inline-flex')}
|
|
7
|
+
|
|
8
|
+
:host {
|
|
9
|
+
align-items: center;
|
|
10
|
+
${userSelectNone}
|
|
11
|
+
width: ${iconSize};
|
|
12
|
+
height: ${iconSize};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
img {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/icon-dynamic/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EACH,QAAQ,GACX,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,aAAa,CAAC;;;;UAIlB,cAAc;iBACP,QAAQ;kBACP,QAAQ;;;;;;;CAOzB,CAAC","sourcesContent":["import { css } from '@ni/fast-element';\nimport {\n iconSize,\n} from '@ni/nimble-components/dist/esm/theme-provider/design-tokens';\nimport { display } from '../utilities/style/display';\nimport { userSelectNone } from '../utilities/style/user-select';\n\nexport const styles = css`\n ${display('inline-flex')}\n\n :host {\n align-items: center;\n ${userSelectNone}\n width: ${iconSize};\n height: ${iconSize};\n }\n\n img {\n width: 100%;\n height: 100%;\n }\n`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/icon-dynamic/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAa,+BAA+B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC","sourcesContent":["import { html } from '@ni/fast-element';\nimport type { IconDynamic } from '.';\n\nexport const template = html<IconDynamic>`<img aria-hidden=\"true\" src=${x => x.url}>`;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cssPartial } from '@ni/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* Set user-select: none in a way that works across all supported browsers.
|
|
4
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#browser_compatibility
|
|
5
|
+
*/
|
|
6
|
+
export const userSelectNone = cssPartial `
|
|
7
|
+
user-select: none;
|
|
8
|
+
-webkit-user-select: none;
|
|
9
|
+
`;
|
|
10
|
+
//# sourceMappingURL=user-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-select.js","sourceRoot":"","sources":["../../../../src/utilities/style/user-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAA;;;CAGvC,CAAC","sourcesContent":["import { cssPartial } from '@ni/fast-element';\n\n/**\n * Set user-select: none in a way that works across all supported browsers.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#browser_compatibility\n */\nexport const userSelectNone = cssPartial`\n user-select: none;\n -webkit-user-select: none;\n`;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/ok-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "NI Ok Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -p ./tsconfig.json",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@ni/fast-element": "^10.1.0",
|
|
38
38
|
"@ni/fast-foundation": "^10.1.5",
|
|
39
39
|
"@ni/fast-web-utilities": "^10.0.0",
|
|
40
|
-
"@ni/nimble-components": "^35.2.
|
|
41
|
-
"@ni/spright-components": "^6.7.
|
|
40
|
+
"@ni/nimble-components": "^35.2.3",
|
|
41
|
+
"@ni/spright-components": "^6.7.1",
|
|
42
42
|
"tslib": "^2.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|