@ni/ok-components 0.4.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,75 +16,13 @@
16
16
  },
17
17
  {
18
18
  "kind": "javascript-module",
19
- "path": "src/icon-dynamic/index.ts",
20
- "declarations": [
21
- {
22
- "kind": "class",
23
- "description": "Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:\n```\ncustomElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');\n```\nAfter 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```",
24
- "name": "IconDynamic",
25
- "members": [
26
- {
27
- "kind": "method",
28
- "name": "registerIconDynamic",
29
- "privacy": "public",
30
- "static": true,
31
- "return": {
32
- "type": {
33
- "text": "void"
34
- }
35
- },
36
- "parameters": [
37
- {
38
- "name": "tagName",
39
- "type": {
40
- "text": "string"
41
- }
42
- },
43
- {
44
- "name": "url",
45
- "type": {
46
- "text": "string"
47
- }
48
- }
49
- ]
50
- }
51
- ],
52
- "superclass": {
53
- "name": "Icon",
54
- "package": "@ni/nimble-components/dist/esm/icon-base"
55
- }
56
- },
57
- {
58
- "kind": "variable",
59
- "name": "iconDynamicTag",
60
- "type": {
61
- "text": "string"
62
- },
63
- "default": "'ok-icon-dynamic'"
64
- }
65
- ],
66
- "exports": [
67
- {
68
- "kind": "js",
69
- "name": "IconDynamic",
70
- "declaration": {
71
- "name": "IconDynamic",
72
- "module": "src/icon-dynamic/index.ts"
73
- }
74
- },
75
- {
76
- "kind": "js",
77
- "name": "iconDynamicTag",
78
- "declaration": {
79
- "name": "iconDynamicTag",
80
- "module": "src/icon-dynamic/index.ts"
81
- }
82
- }
83
- ]
19
+ "path": "src/fv/all-fv.ts",
20
+ "declarations": [],
21
+ "exports": []
84
22
  },
85
23
  {
86
24
  "kind": "javascript-module",
87
- "path": "src/fv/all-fv.ts",
25
+ "path": "src/ts/all-ts.ts",
88
26
  "declarations": [],
89
27
  "exports": []
90
28
  },
@@ -264,6 +202,74 @@
264
202
  }
265
203
  }
266
204
  ]
205
+ },
206
+ {
207
+ "kind": "javascript-module",
208
+ "path": "src/ts/icon-dynamic/index.ts",
209
+ "declarations": [
210
+ {
211
+ "kind": "class",
212
+ "description": "Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:\n```\ncustomElements.get('ok-ts-icon-dynamic').registerIconDynamic('ok-ts-icon-dynamic-awesome', '<img data uri or arbitrary url>');\n```\nAfter calling successfully, the icon can be used like any other icon:\n```\n<ok-ts-icon-dynamic-awesome></ok-ts-icon-dynamic-awesome>\n<nimble-mapping-icon icon=\"ok-ts-icon-dynamic-awesome\"></nimble-mapping-icon>\n```",
213
+ "name": "TsIconDynamic",
214
+ "members": [
215
+ {
216
+ "kind": "method",
217
+ "name": "registerIconDynamic",
218
+ "privacy": "public",
219
+ "static": true,
220
+ "return": {
221
+ "type": {
222
+ "text": "void"
223
+ }
224
+ },
225
+ "parameters": [
226
+ {
227
+ "name": "tagName",
228
+ "type": {
229
+ "text": "string"
230
+ }
231
+ },
232
+ {
233
+ "name": "url",
234
+ "type": {
235
+ "text": "string"
236
+ }
237
+ }
238
+ ]
239
+ }
240
+ ],
241
+ "superclass": {
242
+ "name": "Icon",
243
+ "package": "@ni/nimble-components/dist/esm/icon-base"
244
+ }
245
+ },
246
+ {
247
+ "kind": "variable",
248
+ "name": "tsIconDynamicTag",
249
+ "type": {
250
+ "text": "string"
251
+ },
252
+ "default": "'ok-ts-icon-dynamic'"
253
+ }
254
+ ],
255
+ "exports": [
256
+ {
257
+ "kind": "js",
258
+ "name": "TsIconDynamic",
259
+ "declaration": {
260
+ "name": "TsIconDynamic",
261
+ "module": "src/ts/icon-dynamic/index.ts"
262
+ }
263
+ },
264
+ {
265
+ "kind": "js",
266
+ "name": "tsIconDynamicTag",
267
+ "declaration": {
268
+ "name": "tsIconDynamicTag",
269
+ "module": "src/ts/icon-dynamic/index.ts"
270
+ }
271
+ }
272
+ ]
267
273
  }
268
274
  ]
269
275
  }
@@ -1,19 +1,3 @@
1
- ## class: `IconDynamic`
2
-
3
- ### Superclass
4
-
5
- | Name | Module | Package |
6
- | ------ | ------ | ---------------------------------------- |
7
- | `Icon` | | @ni/nimble-components/dist/esm/icon-base |
8
-
9
- ### Static Methods
10
-
11
- | Name | Privacy | Description | Parameters | Return | Inherited From |
12
- | --------------------- | ------- | ----------- | ------------------------------ | ------ | -------------- |
13
- | `registerIconDynamic` | public | | `tagName: string, url: string` | `void` | |
14
-
15
- <hr/>
16
-
17
1
  ## class: `ExButton`
18
2
 
19
3
  ### Superclass
@@ -55,3 +39,19 @@
55
39
  | `appearance` | appearance | |
56
40
 
57
41
  <hr/>
42
+
43
+ ## class: `TsIconDynamic`
44
+
45
+ ### Superclass
46
+
47
+ | Name | Module | Package |
48
+ | ------ | ------ | ---------------------------------------- |
49
+ | `Icon` | | @ni/nimble-components/dist/esm/icon-base |
50
+
51
+ ### Static Methods
52
+
53
+ | Name | Privacy | Description | Parameters | Return | Inherited From |
54
+ | --------------------- | ------- | ----------- | ------------------------------ | ------ | -------------- |
55
+ | `registerIconDynamic` | public | | `tagName: string, url: string` | `void` | |
56
+
57
+ <hr/>
@@ -6,4 +6,4 @@
6
6
  import '@ni/spright-components/dist/esm/all-components';
7
7
  import './fv/all-fv';
8
8
  import './ex/all-ex';
9
- import './icon-dynamic';
9
+ import './ts/all-ts';
@@ -6,5 +6,5 @@
6
6
  import '@ni/spright-components/dist/esm/all-components';
7
7
  import './fv/all-fv';
8
8
  import './ex/all-ex';
9
- import './icon-dynamic';
9
+ import './ts/all-ts';
10
10
  //# sourceMappingURL=all-components.js.map
@@ -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,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC;AACrB,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 './fv/all-fv';\nimport './ex/all-ex';\nimport './icon-dynamic';\n"]}
1
+ {"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,gDAAgD,CAAC;AAExD,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,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 './fv/all-fv';\nimport './ex/all-ex';\nimport './ts/all-ts';\n"]}
@@ -0,0 +1 @@
1
+ import './icon-dynamic';
@@ -0,0 +1,2 @@
1
+ import './icon-dynamic';
2
+ //# sourceMappingURL=all-ts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all-ts.js","sourceRoot":"","sources":["../../../src/ts/all-ts.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC","sourcesContent":["import './icon-dynamic';\n"]}
@@ -1,23 +1,23 @@
1
1
  import { Icon } from '@ni/nimble-components/dist/esm/icon-base';
2
2
  declare global {
3
3
  interface HTMLElementTagNameMap {
4
- 'ok-icon-dynamic': IconDynamic;
4
+ 'ok-ts-icon-dynamic': TsIconDynamic;
5
5
  }
6
6
  }
7
7
  /**
8
8
  * Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:
9
9
  * ```
10
- * customElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');
10
+ * customElements.get('ok-ts-icon-dynamic').registerIconDynamic('ok-ts-icon-dynamic-awesome', '<img data uri or arbitrary url>');
11
11
  * ```
12
12
  * After calling successfully, the icon can be used like any other icon:
13
13
  * ```
14
- * <ok-icon-dynamic-awesome></ok-icon-dynamic-awesome>
15
- * <nimble-mapping-icon icon="ok-icon-dynamic-awesome"></nimble-mapping-icon>
14
+ * <ok-ts-icon-dynamic-awesome></ok-ts-icon-dynamic-awesome>
15
+ * <nimble-mapping-icon icon="ok-ts-icon-dynamic-awesome"></nimble-mapping-icon>
16
16
  * ```
17
17
  */
18
- export declare class IconDynamic extends Icon {
18
+ export declare class TsIconDynamic extends Icon {
19
19
  readonly url: string;
20
20
  constructor(/** @internal */ url: string);
21
21
  static registerIconDynamic(tagName: string, url: string): void;
22
22
  }
23
- export declare const iconDynamicTag = "ok-icon-dynamic";
23
+ export declare const tsIconDynamicTag = "ok-ts-icon-dynamic";
@@ -4,25 +4,25 @@ import { html, css } from '@ni/fast-element';
4
4
  import { Icon } from '@ni/nimble-components/dist/esm/icon-base';
5
5
  import { styles } from './styles';
6
6
  import { template } from './template';
7
- import { display } from '../utilities/style/display';
7
+ import { display } from '../../utilities/style/display';
8
8
  /**
9
9
  * Base class for dynamic icons. Not intended to be used directly, instead use to register dynamic icons:
10
10
  * ```
11
- * customElements.get('ok-icon-dynamic').registerIconDynamic('ok-icon-dynamic-awesome', '<img data uri or arbitrary url>');
11
+ * customElements.get('ok-ts-icon-dynamic').registerIconDynamic('ok-ts-icon-dynamic-awesome', '<img data uri or arbitrary url>');
12
12
  * ```
13
13
  * After calling successfully, the icon can be used like any other icon:
14
14
  * ```
15
- * <ok-icon-dynamic-awesome></ok-icon-dynamic-awesome>
16
- * <nimble-mapping-icon icon="ok-icon-dynamic-awesome"></nimble-mapping-icon>
15
+ * <ok-ts-icon-dynamic-awesome></ok-ts-icon-dynamic-awesome>
16
+ * <nimble-mapping-icon icon="ok-ts-icon-dynamic-awesome"></nimble-mapping-icon>
17
17
  * ```
18
18
  */
19
- export class IconDynamic extends Icon {
19
+ export class TsIconDynamic extends Icon {
20
20
  constructor(/** @internal */ url) {
21
21
  super();
22
22
  this.url = url;
23
23
  }
24
24
  static registerIconDynamic(tagName, url) {
25
- const tagPrefix = 'ok-icon-dynamic-';
25
+ const tagPrefix = 'ok-ts-icon-dynamic-';
26
26
  if (!tagName.startsWith(tagPrefix)) {
27
27
  throw new Error(`Icon tag name must start with '${tagPrefix}', provided name: ${tagName}`);
28
28
  }
@@ -30,17 +30,17 @@ export class IconDynamic extends Icon {
30
30
  if (!/^[a-z][a-z]+$/.test(name)) {
31
31
  throw new Error(`Icon name must be lowercase [a-z] and at least two characters long, provided name: ${name}`);
32
32
  }
33
- const iconClassName = `IconDynamic${name.charAt(0).toUpperCase() + name.slice(1)}`;
33
+ const iconClassName = `TsIconDynamic${name.charAt(0).toUpperCase() + name.slice(1)}`;
34
34
  const iconClassContainer = {
35
35
  // Class name for expression should come object literal assignment, helpful for stack traces, etc.
36
- [iconClassName]: class extends IconDynamic {
36
+ [iconClassName]: class extends TsIconDynamic {
37
37
  constructor() {
38
38
  super(url);
39
39
  }
40
40
  }
41
41
  };
42
42
  const iconClass = iconClassContainer[iconClassName];
43
- const baseName = `icon-dynamic-${name}`;
43
+ const baseName = `ts-icon-dynamic-${name}`;
44
44
  const composedIcon = iconClass.compose({
45
45
  baseName,
46
46
  template,
@@ -49,11 +49,11 @@ export class IconDynamic extends Icon {
49
49
  DesignSystem.getOrCreate().withPrefix('ok').register(composedIcon());
50
50
  }
51
51
  }
52
- const okIconDynamic = IconDynamic.compose({
53
- baseName: 'icon-dynamic',
52
+ const okTsIconDynamic = TsIconDynamic.compose({
53
+ baseName: 'ts-icon-dynamic',
54
54
  template: html `<template></template>`,
55
55
  styles: css `${display('none')}`
56
56
  });
57
- DesignSystem.getOrCreate().withPrefix('ok').register(okIconDynamic());
58
- export const iconDynamicTag = 'ok-icon-dynamic';
57
+ DesignSystem.getOrCreate().withPrefix('ok').register(okTsIconDynamic());
58
+ export const tsIconDynamicTag = 'ok-ts-icon-dynamic';
59
59
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ts/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,+BAA+B,CAAC;AAQxD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAc,SAAQ,IAAI;IACnC,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,qBAAqB,CAAC;QACxC,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,gBAAgB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACrF,MAAM,kBAAkB,GAAG;YACvB,kGAAkG;YAClG,CAAC,aAAa,CAAC,EAAE,KAAM,SAAQ,aAAa;gBACxC;oBACI,KAAK,CAAC,GAAG,CAAC,CAAC;gBACf,CAAC;aACJ;SACK,CAAC;QACX,MAAM,SAAS,GAAG,kBAAkB,CAAC,aAAa,CAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,mBAAmB,IAAI,EAAE,CAAC;QAC3C,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,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC;IAC1C,QAAQ,EAAE,iBAAiB;IAC3B,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,eAAe,EAAE,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,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-ts-icon-dynamic': TsIconDynamic;\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-ts-icon-dynamic').registerIconDynamic('ok-ts-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-ts-icon-dynamic-awesome></ok-ts-icon-dynamic-awesome>\n * <nimble-mapping-icon icon=\"ok-ts-icon-dynamic-awesome\"></nimble-mapping-icon>\n * ```\n */\nexport class TsIconDynamic 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-ts-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 = `TsIconDynamic${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 TsIconDynamic {\n constructor() {\n super(url);\n }\n }\n } as const;\n const iconClass = iconClassContainer[iconClassName]!;\n const baseName = `ts-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 okTsIconDynamic = TsIconDynamic.compose({\n baseName: 'ts-icon-dynamic',\n template: html`<template></template>`,\n styles: css`${display('none')}`\n});\n\nDesignSystem.getOrCreate().withPrefix('ok').register(okTsIconDynamic());\nexport const tsIconDynamicTag = 'ok-ts-icon-dynamic';\n"]}
@@ -1,7 +1,7 @@
1
1
  import { css } from '@ni/fast-element';
2
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';
3
+ import { display } from '../../utilities/style/display';
4
+ import { userSelectNone } from '../../utilities/style/user-select';
5
5
  export const styles = css `
6
6
  ${display('inline-flex')}
7
7
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/ts/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,+BAA+B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,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,2 @@
1
+ import type { TsIconDynamic } from '.';
2
+ export declare const template: import("@ni/fast-element").ViewTemplate<TsIconDynamic, any>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/ts/icon-dynamic/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAe,+BAA+B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC","sourcesContent":["import { html } from '@ni/fast-element';\nimport type { TsIconDynamic } from '.';\n\nexport const template = html<TsIconDynamic>`<img aria-hidden=\"true\" src=${x => x.url}>`;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/ok-components",
3
- "version": "0.4.4",
3
+ "version": "1.0.0",
4
4
  "description": "NI Ok Components",
5
5
  "scripts": {
6
6
  "build": "npm run build:components && npm run build:cem",
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1,2 +0,0 @@
1
- import type { IconDynamic } from '.';
2
- export declare const template: import("@ni/fast-element").ViewTemplate<IconDynamic, any>;
@@ -1 +0,0 @@
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"]}