@hashicorp/design-system-components 4.8.0 → 4.9.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.
Files changed (51) hide show
  1. package/declarations/components/hds/application-state/types.d.ts +4 -0
  2. package/declarations/components/hds/application-state/types.d.ts.map +1 -1
  3. package/declarations/components/hds/code-block/copy-button.d.ts +17 -1
  4. package/declarations/components/hds/code-block/copy-button.d.ts.map +1 -1
  5. package/declarations/components/hds/code-block/description.d.ts +14 -1
  6. package/declarations/components/hds/code-block/description.d.ts.map +1 -1
  7. package/declarations/components/hds/code-block/index.d.ts +48 -6
  8. package/declarations/components/hds/code-block/index.d.ts.map +1 -1
  9. package/declarations/components/hds/code-block/title.d.ts +14 -1
  10. package/declarations/components/hds/code-block/title.d.ts.map +1 -1
  11. package/declarations/components/hds/code-block/types.d.ts +16 -0
  12. package/declarations/components/hds/code-block/types.d.ts.map +1 -0
  13. package/declarations/components/hds/icon/index.d.ts +37 -0
  14. package/declarations/components/hds/icon/index.d.ts.map +1 -0
  15. package/declarations/components/hds/icon/types.d.ts +29 -0
  16. package/declarations/components/hds/icon/types.d.ts.map +1 -0
  17. package/declarations/components/hds/tooltip-button/index.d.ts +23 -5
  18. package/declarations/components/hds/tooltip-button/index.d.ts.map +1 -1
  19. package/declarations/components/hds/tooltip-button/types.d.ts +20 -0
  20. package/declarations/components/hds/tooltip-button/types.d.ts.map +1 -0
  21. package/declarations/components.d.ts +7 -1
  22. package/declarations/components.d.ts.map +1 -1
  23. package/declarations/template-registry.d.ts +18 -0
  24. package/declarations/template-registry.d.ts.map +1 -1
  25. package/dist/_app_/components/hds/icon/index.js +1 -0
  26. package/dist/components/hds/application-state/types.js +5 -0
  27. package/dist/components/hds/application-state/types.js.map +1 -1
  28. package/dist/components/hds/code-block/copy-button.js +8 -2
  29. package/dist/components/hds/code-block/copy-button.js.map +1 -1
  30. package/dist/components/hds/code-block/description.js +8 -2
  31. package/dist/components/hds/code-block/description.js.map +1 -1
  32. package/dist/components/hds/code-block/index.js +12 -10
  33. package/dist/components/hds/code-block/index.js.map +1 -1
  34. package/dist/components/hds/code-block/title.js +8 -2
  35. package/dist/components/hds/code-block/title.js.map +1 -1
  36. package/dist/components/hds/code-block/types.js +19 -0
  37. package/dist/components/hds/code-block/types.js.map +1 -0
  38. package/dist/components/hds/icon/index.js +89 -0
  39. package/dist/components/hds/icon/index.js.map +1 -0
  40. package/dist/components/hds/icon/types.js +31 -0
  41. package/dist/components/hds/icon/types.js.map +1 -0
  42. package/dist/components/hds/tooltip-button/index.js +8 -8
  43. package/dist/components/hds/tooltip-button/index.js.map +1 -1
  44. package/dist/components/hds/tooltip-button/types.js +23 -0
  45. package/dist/components/hds/tooltip-button/types.js.map +1 -0
  46. package/dist/components.js +6 -0
  47. package/dist/components.js.map +1 -1
  48. package/dist/styles/@hashicorp/design-system-components.css +40 -0
  49. package/dist/styles/@hashicorp/design-system-components.scss +1 -0
  50. package/dist/styles/components/icon.scss +41 -0
  51. package/package.json +3 -1
@@ -2,9 +2,15 @@ import templateOnlyComponent from '@ember/component/template-only';
2
2
  import { precompileTemplate } from '@ember/template-compilation';
3
3
  import { setComponentTemplate } from '@ember/component';
4
4
 
5
- var TEMPLATE = precompileTemplate("{{! @glint-nocheck: not typesafe yet }}\n{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<Hds::Text::Body @tag=\"p\" @size=\"100\" class=\"hds-code-block__description\" ...attributes>\n {{yield}}\n</Hds::Text::Body>");
5
+ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<Hds::Text::Body @tag=\"p\" @size=\"100\" class=\"hds-code-block__description\" ...attributes>\n {{yield}}\n</Hds::Text::Body>");
6
6
 
7
- var description = setComponentTemplate(TEMPLATE, templateOnlyComponent());
7
+ /**
8
+ * Copyright (c) HashiCorp, Inc.
9
+ * SPDX-License-Identifier: MPL-2.0
10
+ */
11
+
12
+ const HdsCodeBlockDescriptionComponent = templateOnlyComponent();
13
+ var description = setComponentTemplate(TEMPLATE, HdsCodeBlockDescriptionComponent);
8
14
 
9
15
  export { description as default };
10
16
  //# sourceMappingURL=description.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"description.js","sources":["../../../../src/components/hds/code-block/description.hbs","../../../../src/components/hds/code-block/description.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! @glint-nocheck: not typesafe yet }}\\n{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<Hds::Text::Body @tag=\\\"p\\\" @size=\\\"100\\\" class=\\\"hds-code-block__description\\\" ...attributes>\\n {{yield}}\\n</Hds::Text::Body>\")","import templateOnly from '@ember/component/template-only';\nexport default templateOnly();\n"],"names":["setComponentTemplate","TEMPLATE","templateOnly"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,0PAA0P;;ACA5R,kBAAAA,oBAAA,CAAAC,QAAA,EAAeC,qBAAY,EAAE,CAAA;;;;"}
1
+ {"version":3,"file":"description.js","sources":["../../../../src/components/hds/code-block/description.hbs","../../../../src/components/hds/code-block/description.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<Hds::Text::Body @tag=\\\"p\\\" @size=\\\"100\\\" class=\\\"hds-code-block__description\\\" ...attributes>\\n {{yield}}\\n</Hds::Text::Body>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport templateOnlyComponent from '@ember/component/template-only';\nimport type { HdsTextBodySignature } from '../text/body';\n\nexport interface HdsCodeBlockDescriptionSignature {\n Blocks: {\n default: [];\n };\n Element: HdsTextBodySignature['Element'];\n}\n\nconst HdsCodeBlockDescriptionComponent =\n templateOnlyComponent<HdsCodeBlockDescriptionSignature>();\n\nexport default HdsCodeBlockDescriptionComponent;\n"],"names":["HdsCodeBlockDescriptionComponent","templateOnlyComponent","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,iNAAiN;;ACDnP;AACA;AACA;AACA;;AAYA,MAAMA,gCAAgC,GACpCC,qBAAqB,EAAoC,CAAA;AAE3D,kBAAAC,oBAAA,CAAAC,QAAA,EAAeH,gCAAgC,CAAA;;;;"}
@@ -7,6 +7,7 @@ import { next, schedule } from '@ember/runloop';
7
7
  import { htmlSafe } from '@ember/template';
8
8
  import { guidFor } from '@ember/object/internals';
9
9
  import Prism from 'prismjs';
10
+ import { HdsCodeBlockLanguageValues } from './types.js';
10
11
  import 'prismjs/plugins/line-numbers/prism-line-numbers';
11
12
  import 'prismjs/plugins/line-highlight/prism-line-highlight';
12
13
  import 'prismjs/components/prism-bash';
@@ -22,10 +23,11 @@ import 'prismjs/components/prism-handlebars';
22
23
  import { precompileTemplate } from '@ember/template-compilation';
23
24
  import { setComponentTemplate } from '@ember/component';
24
25
 
25
- var TEMPLATE = precompileTemplate("{{! @glint-nocheck: not typesafe yet }}\n{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<div class={{this.classNames}} ...attributes>\n <div class=\"hds-code-block__header\">\n {{~yield (hash Title=(component \"hds/code-block/title\"))~}}\n {{~yield (hash Description=(component \"hds/code-block/description\"))~}}\n </div>\n <div class=\"hds-code-block__body\">\n {{! content within pre tag is whitespace-sensitive; do not add new lines! }}\n <pre\n class=\"hds-code-block__code\"\n {{style maxHeight=@maxHeight}}\n data-line={{@highlightLines}}\n id={{this.preCodeId}}\n tabindex=\"0\"\n ><code {{did-insert this.setPrismCode}} {{did-update this.setPrismCode this.code @language}}>\n {{~this.prismCode~}}\n </code></pre>\n\n {{#if @hasCopyButton}}\n <Hds::CodeBlock::CopyButton @targetToCopy=\"#{{this.preCodeId}}\" aria-describedby={{this.preCodeId}} />\n {{/if}}\n </div>\n</div>");
26
+ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<div class={{this.classNames}} ...attributes>\n <div class=\"hds-code-block__header\">\n {{~yield (hash Title=(component \"hds/code-block/title\"))~}}\n {{~yield (hash Description=(component \"hds/code-block/description\"))~}}\n </div>\n <div class=\"hds-code-block__body\">\n {{! content within pre tag is whitespace-sensitive; do not add new lines! }}\n <pre\n class=\"hds-code-block__code\"\n {{style maxHeight=@maxHeight}}\n data-line={{@highlightLines}}\n id={{this.preCodeId}}\n tabindex=\"0\"\n ><code {{did-insert this.setPrismCode}} {{did-update this.setPrismCode this.code @language}}>\n {{~this.prismCode~}}\n </code></pre>\n\n {{#if @hasCopyButton}}\n <Hds::CodeBlock::CopyButton @targetToCopy=\"#{{this.preCodeId}}\" aria-describedby={{this.preCodeId}} />\n {{/if}}\n </div>\n</div>");
26
27
 
27
28
  var _class, _descriptor;
28
- let HdsCodeBlockIndexComponent = (_class = class HdsCodeBlockIndexComponent extends Component {
29
+ const LANGUAGES = Object.values(HdsCodeBlockLanguageValues);
30
+ let HdsCodeBlockComponent = (_class = class HdsCodeBlockComponent extends Component {
29
31
  constructor(...args) {
30
32
  super(...args);
31
33
  _initializerDefineProperty(this, "prismCode", _descriptor, this);
@@ -44,8 +46,8 @@ let HdsCodeBlockIndexComponent = (_class = class HdsCodeBlockIndexComponent exte
44
46
  get code() {
45
47
  const code = this.args.value;
46
48
  assert('@code for "Hds::CodeBlock" must have a valid value', code !== undefined);
47
- if (Prism?.plugins?.NormalizeWhitespace) {
48
- return Prism.plugins.NormalizeWhitespace.normalize(code);
49
+ if (Prism?.plugins?.['NormalizeWhitespace']) {
50
+ return Prism.plugins['NormalizeWhitespace'].normalize(code);
49
51
  }
50
52
  return code;
51
53
  }
@@ -92,13 +94,13 @@ let HdsCodeBlockIndexComponent = (_class = class HdsCodeBlockIndexComponent exte
92
94
  setPrismCode(element) {
93
95
  const code = this.code;
94
96
  const language = this.language;
95
- const grammar = Prism.languages[language];
97
+ const grammar = language ? Prism.languages[language] : undefined;
96
98
  if (code) {
97
99
  next(() => {
98
100
  if (language && grammar) {
99
101
  this.prismCode = htmlSafe(Prism.highlight(code, grammar, language));
100
102
  } else {
101
- this.prismCode = htmlSafe(Prism.util.encode(code));
103
+ this.prismCode = htmlSafe(Prism.util.encode(code).toString());
102
104
  }
103
105
 
104
106
  // Force prism-line-numbers plugin initialization, required for Prism.highlight usage
@@ -129,7 +131,7 @@ let HdsCodeBlockIndexComponent = (_class = class HdsCodeBlockIndexComponent exte
129
131
  get classNames() {
130
132
  // Currently there is only one theme so the class name is hard-coded.
131
133
  // In the future, additional themes such as a "light" theme could be added.
132
- let classes = ['hds-code-block', 'hds-code-block--theme-dark'];
134
+ const classes = ['hds-code-block', 'hds-code-block--theme-dark'];
133
135
  if (this.language) {
134
136
  classes.push(`language-${this.language}`);
135
137
  }
@@ -151,10 +153,10 @@ let HdsCodeBlockIndexComponent = (_class = class HdsCodeBlockIndexComponent exte
151
153
  enumerable: true,
152
154
  writable: true,
153
155
  initializer: function () {
154
- return '';
156
+ return htmlSafe('');
155
157
  }
156
158
  }), _applyDecoratedDescriptor(_class.prototype, "setPrismCode", [action], Object.getOwnPropertyDescriptor(_class.prototype, "setPrismCode"), _class.prototype)), _class);
157
- setComponentTemplate(TEMPLATE, HdsCodeBlockIndexComponent);
159
+ setComponentTemplate(TEMPLATE, HdsCodeBlockComponent);
158
160
 
159
- export { HdsCodeBlockIndexComponent as default };
161
+ export { LANGUAGES, HdsCodeBlockComponent as default };
160
162
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/hds/code-block/index.hbs","../../../../src/components/hds/code-block/index.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! @glint-nocheck: not typesafe yet }}\\n{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<div class={{this.classNames}} ...attributes>\\n <div class=\\\"hds-code-block__header\\\">\\n {{~yield (hash Title=(component \\\"hds/code-block/title\\\"))~}}\\n {{~yield (hash Description=(component \\\"hds/code-block/description\\\"))~}}\\n </div>\\n <div class=\\\"hds-code-block__body\\\">\\n {{! content within pre tag is whitespace-sensitive; do not add new lines! }}\\n <pre\\n class=\\\"hds-code-block__code\\\"\\n {{style maxHeight=@maxHeight}}\\n data-line={{@highlightLines}}\\n id={{this.preCodeId}}\\n tabindex=\\\"0\\\"\\n ><code {{did-insert this.setPrismCode}} {{did-update this.setPrismCode this.code @language}}>\\n {{~this.prismCode~}}\\n </code></pre>\\n\\n {{#if @hasCopyButton}}\\n <Hds::CodeBlock::CopyButton @targetToCopy=\\\"#{{this.preCodeId}}\\\" aria-describedby={{this.preCodeId}} />\\n {{/if}}\\n </div>\\n</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { next, schedule } from '@ember/runloop';\nimport { htmlSafe } from '@ember/template';\nimport { guidFor } from '@ember/object/internals';\n\nimport Prism from 'prismjs';\n\nimport 'prismjs/plugins/line-numbers/prism-line-numbers';\nimport 'prismjs/plugins/line-highlight/prism-line-highlight';\n\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-hcl';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-log';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-shell-session';\nimport 'prismjs/components/prism-yaml';\n\n// These imports are required to overcome a global variable clash in Helios website\n// where language import are overriden by the Prism instance in `CodeBlock`\n// Note that `prism-handlebars` is dependant on `prism-markup-templating`\nimport 'prismjs/components/prism-markup-templating';\nimport 'prismjs/components/prism-handlebars';\n\nexport default class HdsCodeBlockIndexComponent extends Component {\n @tracked prismCode = '';\n\n /**\n * Generates a unique ID for the code content\n *\n * @param preCodeId\n */\n preCodeId = 'pre-code-' + guidFor(this);\n\n /**\n * @param code\n * @type {string}\n * @description code text content for the CodeBlock\n */\n get code() {\n const code = this.args.value;\n\n assert(\n '@code for \"Hds::CodeBlock\" must have a valid value',\n code !== undefined\n );\n\n if (Prism?.plugins?.NormalizeWhitespace) {\n return Prism.plugins.NormalizeWhitespace.normalize(code);\n }\n\n return code;\n }\n\n /**\n * @param language\n * @type {string}\n * @default undefined\n * @description name of coding language used within CodeBlock for syntax highlighting\n */\n get language() {\n return this.args.language ?? undefined;\n }\n\n /**\n * @param hasLineNumbers\n * @type {boolean}\n * @default true\n * @description Displays line numbers if true\n */\n get hasLineNumbers() {\n return this.args.hasLineNumbers ?? true;\n }\n\n /**\n * @param isStandalone\n * @type {boolean}\n * @default true\n * @description Make CodeBlock container corners appear rounded\n */\n get isStandalone() {\n return this.args.isStandalone ?? true;\n }\n\n /**\n * @param hasLineWrapping\n * @type {boolean}\n * @default false\n * @description Make text content wrap on multiple lines\n */\n get hasLineWrapping() {\n return this.args.hasLineWrapping ?? false;\n }\n\n @action\n setPrismCode(element) {\n const code = this.code;\n const language = this.language;\n const grammar = Prism.languages[language];\n\n if (code) {\n next(() => {\n if (language && grammar) {\n this.prismCode = htmlSafe(Prism.highlight(code, grammar, language));\n } else {\n this.prismCode = htmlSafe(Prism.util.encode(code));\n }\n\n // Force prism-line-numbers plugin initialization, required for Prism.highlight usage\n // See https://github.com/PrismJS/prism/issues/1234\n Prism.hooks.run('complete', {\n code,\n element,\n });\n\n // Force prism-line-highlight plugin initialization\n // Context: https://github.com/hashicorp/design-system/pull/1749#discussion_r1374288785\n if (this.args.highlightLines) {\n // we need to delay re-evaluating the context for prism-line-highlight for as much as possible, and `afterRender` is the 'latest' we can use in the component lifecycle\n schedule('afterRender', () => {\n // we piggy-back on the plugin's `resize` event listener to trigger a new call of the `highlightLines` function: https://github.com/PrismJS/prism/blob/master/plugins/line-highlight/prism-line-highlight.js#L337\n if (window) window.dispatchEvent(new Event('resize'));\n });\n }\n });\n }\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames() {\n // Currently there is only one theme so the class name is hard-coded.\n // In the future, additional themes such as a \"light\" theme could be added.\n let classes = ['hds-code-block', 'hds-code-block--theme-dark'];\n\n if (this.language) {\n classes.push(`language-${this.language}`);\n }\n\n if (this.isStandalone === true) {\n classes.push('hds-code-block--is-standalone');\n }\n\n if (this.hasLineWrapping === true) {\n classes.push('hds-code-block--has-line-wrapping');\n }\n\n // Note: Prism.js is using the specific class name \"line-numbers\" to determine implementation of line numbers in the UI\n if (this.hasLineNumbers || this.args.highlightLines) {\n classes.push('line-numbers');\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["HdsCodeBlockIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_defineProperty","guidFor","code","value","assert","undefined","Prism","plugins","NormalizeWhitespace","normalize","language","hasLineNumbers","isStandalone","hasLineWrapping","setPrismCode","element","grammar","languages","next","prismCode","htmlSafe","highlight","util","encode","hooks","run","highlightLines","schedule","window","dispatchEvent","Event","classNames","classes","push","join","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,y9BAAy9B;;;ACgCt+BA,IAAAA,0BAA0B,IAAAC,MAAA,GAAhC,MAAMD,0BAA0B,SAASE,SAAS,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,oBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAGhE;AACF;AACA;A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,IAAA,IAAI,IAAI,CAACpB,eAAe,KAAK,IAAI,EAAE;AACjCmB,MAAAA,OAAO,CAACC,IAAI,CAAC,mCAAmC,CAAC,CAAA;AACnD,KAAA;;AAEA;IACA,IAAI,IAAI,CAACtB,cAAc,IAAI,IAAI,CAACd,IAAI,CAAC6B,cAAc,EAAE;AACnDM,MAAAA,OAAO,CAACC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC9B,KAAA;AAEA,IAAA,OAAOD,OAAO,CAACE,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAC,GAAAnC,WAAA,GAAAoC,yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAAA,WAAA,EAAA,CApIEC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAa,EAAE,CAAA;AAAA,GAAA;AAAA,CAAAN,CAAAA,EAAAA,yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAqEtBM,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlD,MAAA,CAAA0C,SAAA,EAAA,cAAA,CAAA,EAAA1C,MAAA,CAAA0C,SAAA,IAAA1C,MAAA,EAAA;AAtEsCmD,oBAAA,CAAAC,QAAA,EAA1BrD,0BAA0B,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/hds/code-block/index.hbs","../../../../src/components/hds/code-block/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<div class={{this.classNames}} ...attributes>\\n <div class=\\\"hds-code-block__header\\\">\\n {{~yield (hash Title=(component \\\"hds/code-block/title\\\"))~}}\\n {{~yield (hash Description=(component \\\"hds/code-block/description\\\"))~}}\\n </div>\\n <div class=\\\"hds-code-block__body\\\">\\n {{! content within pre tag is whitespace-sensitive; do not add new lines! }}\\n <pre\\n class=\\\"hds-code-block__code\\\"\\n {{style maxHeight=@maxHeight}}\\n data-line={{@highlightLines}}\\n id={{this.preCodeId}}\\n tabindex=\\\"0\\\"\\n ><code {{did-insert this.setPrismCode}} {{did-update this.setPrismCode this.code @language}}>\\n {{~this.prismCode~}}\\n </code></pre>\\n\\n {{#if @hasCopyButton}}\\n <Hds::CodeBlock::CopyButton @targetToCopy=\\\"#{{this.preCodeId}}\\\" aria-describedby={{this.preCodeId}} />\\n {{/if}}\\n </div>\\n</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { assert } from '@ember/debug';\nimport { next, schedule } from '@ember/runloop';\nimport { htmlSafe } from '@ember/template';\nimport { guidFor } from '@ember/object/internals';\n\nimport Prism from 'prismjs';\n\nimport type { SafeString } from '@ember/template/-private/handlebars';\nimport type { ComponentLike } from '@glint/template';\n\nimport type { HdsCodeBlockTitleSignature } from './title';\nimport type { HdsCodeBlockDescriptionSignature } from './description';\nimport { HdsCodeBlockLanguageValues } from './types.ts';\nimport type { HdsCodeBlockLanguages } from './types.ts';\n\nimport 'prismjs/plugins/line-numbers/prism-line-numbers';\nimport 'prismjs/plugins/line-highlight/prism-line-highlight';\n\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-hcl';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-log';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-shell-session';\nimport 'prismjs/components/prism-yaml';\n\n// These imports are required to overcome a global variable clash in Helios website\n// where language import are overriden by the Prism instance in `CodeBlock`\n// Note that `prism-handlebars` is dependant on `prism-markup-templating`\nimport 'prismjs/components/prism-markup-templating';\nimport 'prismjs/components/prism-handlebars';\n\nexport const LANGUAGES: string[] = Object.values(HdsCodeBlockLanguageValues);\n\nexport interface HdsCodeBlockSignature {\n Args: {\n hasCopyButton?: boolean;\n hasLineNumbers?: boolean;\n hasLineWrapping?: boolean;\n highlightLines?: string;\n isStandalone?: boolean;\n language?: HdsCodeBlockLanguages;\n maxHeight?: string;\n value: string;\n };\n Blocks: {\n default: [\n {\n Title?: ComponentLike<HdsCodeBlockTitleSignature>;\n Description?: ComponentLike<HdsCodeBlockDescriptionSignature>;\n },\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsCodeBlockComponent extends Component<HdsCodeBlockSignature> {\n @tracked prismCode: SafeString = htmlSafe('');\n\n /**\n * Generates a unique ID for the code content\n *\n * @param preCodeId\n */\n preCodeId = 'pre-code-' + guidFor(this);\n\n /**\n * @param code\n * @type {string}\n * @description code text content for the CodeBlock\n */\n get code(): string {\n const code = this.args.value;\n\n assert(\n '@code for \"Hds::CodeBlock\" must have a valid value',\n code !== undefined\n );\n\n if (Prism?.plugins?.['NormalizeWhitespace']) {\n return Prism.plugins['NormalizeWhitespace'].normalize(code);\n }\n\n return code;\n }\n\n /**\n * @param language\n * @type {string}\n * @default undefined\n * @description name of coding language used within CodeBlock for syntax highlighting\n */\n get language(): HdsCodeBlockLanguages | undefined {\n return this.args.language ?? undefined;\n }\n\n /**\n * @param hasLineNumbers\n * @type {boolean}\n * @default true\n * @description Displays line numbers if true\n */\n get hasLineNumbers(): boolean {\n return this.args.hasLineNumbers ?? true;\n }\n\n /**\n * @param isStandalone\n * @type {boolean}\n * @default true\n * @description Make CodeBlock container corners appear rounded\n */\n get isStandalone(): boolean {\n return this.args.isStandalone ?? true;\n }\n\n /**\n * @param hasLineWrapping\n * @type {boolean}\n * @default false\n * @description Make text content wrap on multiple lines\n */\n get hasLineWrapping(): boolean {\n return this.args.hasLineWrapping ?? false;\n }\n\n @action\n setPrismCode(element: HTMLElement): void {\n const code = this.code;\n const language = this.language;\n const grammar = language ? Prism.languages[language] : undefined;\n\n if (code) {\n next(() => {\n if (language && grammar) {\n this.prismCode = htmlSafe(Prism.highlight(code, grammar, language));\n } else {\n this.prismCode = htmlSafe(Prism.util.encode(code).toString());\n }\n\n // Force prism-line-numbers plugin initialization, required for Prism.highlight usage\n // See https://github.com/PrismJS/prism/issues/1234\n Prism.hooks.run('complete', {\n code,\n element,\n });\n\n // Force prism-line-highlight plugin initialization\n // Context: https://github.com/hashicorp/design-system/pull/1749#discussion_r1374288785\n if (this.args.highlightLines) {\n // we need to delay re-evaluating the context for prism-line-highlight for as much as possible, and `afterRender` is the 'latest' we can use in the component lifecycle\n schedule('afterRender', () => {\n // we piggy-back on the plugin's `resize` event listener to trigger a new call of the `highlightLines` function: https://github.com/PrismJS/prism/blob/master/plugins/line-highlight/prism-line-highlight.js#L337\n if (window) window.dispatchEvent(new Event('resize'));\n });\n }\n });\n }\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n // Currently there is only one theme so the class name is hard-coded.\n // In the future, additional themes such as a \"light\" theme could be added.\n const classes = ['hds-code-block', 'hds-code-block--theme-dark'];\n\n if (this.language) {\n classes.push(`language-${this.language}`);\n }\n\n if (this.isStandalone === true) {\n classes.push('hds-code-block--is-standalone');\n }\n\n if (this.hasLineWrapping === true) {\n classes.push('hds-code-block--has-line-wrapping');\n }\n\n // Note: Prism.js is using the specific class name \"line-numbers\" to determine implementation of line numbers in the UI\n if (this.hasLineNumbers || this.args.highlightLines) {\n classes.push('line-numbers');\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["LANGUAGES","Object","values","HdsCodeBlockLanguageValues","HdsCodeBlockComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_defineProperty","guidFor","code","value","assert","undefined","Prism","plugins","normalize","language","hasLineNumbers","isStandalone","hasLineWrapping","setPrismCode","element","grammar","languages","next","prismCode","htmlSafe","highlight","util","encode","toString","hooks","run","highlightLines","schedule","window","dispatchEvent","Event","classNames","classes","push","join","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,g7BAAg7B;;;ACwC38B,MAAMA,SAAmB,GAAGC,MAAM,CAACC,MAAM,CAACC,0BAA0B,EAAC;AAwBvDC,IAAAA,qBAAqB,IAAAC,MAAA,GAA3B,MAAMD,qBAAqB,SAASE,SAAS,CAAwB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,oBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAGlF;AACF;AACA;AACA;AACA;AAJEC,IAAAA,eAAA,oBAKY,WAAW,GAAGC,OAAO,CAAC,IAAI,CAAC,CAAA,CAAA;AAAA,GAAA;AAEvC;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAW;AACjB,IAAA,MAAMA,IAAI,GAAG,IAAI,CAACL,IAAI,CAACM,KAAK,CAAA;AAE5BC,IAAAA,MAAM,CACJ,oDAAoD,EACpDF,IAAI,KAAKG,SACX,CAAC,CAAA;AAED,IAAA,IAAIC,KAAK,EAAEC,OAAO,GAAG,qBAAqB,CAAC,EAAE;MAC3C,OAAOD,KAAK,CAACC,OAAO,CAAC,qBAAqB,CAAC,CAACC,SAAS,CAACN,IAAI,CAAC,CAAA;AAC7D,KAAA;AAEA,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIO,QAAQA,GAAsC;AAChD,IAAA,OAAO,IAAI,CAACZ,IAAI,CAACY,QAAQ,IAAIJ,SAAS,CAAA;AACxC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIK,cAAcA,GAAY;AAC5B,IAAA,OAAO,IA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yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAqE5CM,cAAAA,EAAAA,CAAAA,MAAM,GAAApD,MAAA,CAAAqD,wBAAA,CAAAjD,MAAA,CAAA0C,SAAA,EAAA,cAAA,CAAA,EAAA1C,MAAA,CAAA0C,SAAA,IAAA1C,MAAA,EAAA;AAtEiCkD,oBAAA,CAAAC,QAAA,EAArBpD,qBAAqB,CAAA;;;;"}
@@ -2,9 +2,15 @@ import templateOnlyComponent from '@ember/component/template-only';
2
2
  import { precompileTemplate } from '@ember/template-compilation';
3
3
  import { setComponentTemplate } from '@ember/component';
4
4
 
5
- var TEMPLATE = precompileTemplate("{{! @glint-nocheck: not typesafe yet }}\n{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<Hds::Text::Body @size=\"200\" @tag=\"p\" @weight=\"semibold\" class=\"hds-code-block__title\" ...attributes>\n {{yield}}\n</Hds::Text::Body>");
5
+ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<Hds::Text::Body @size=\"200\" @tag=\"p\" @weight=\"semibold\" class=\"hds-code-block__title\" ...attributes>\n {{yield}}\n</Hds::Text::Body>");
6
6
 
7
- var title = setComponentTemplate(TEMPLATE, templateOnlyComponent());
7
+ /**
8
+ * Copyright (c) HashiCorp, Inc.
9
+ * SPDX-License-Identifier: MPL-2.0
10
+ */
11
+
12
+ const HdsCodeBlockTitleComponent = templateOnlyComponent();
13
+ var title = setComponentTemplate(TEMPLATE, HdsCodeBlockTitleComponent);
8
14
 
9
15
  export { title as default };
10
16
  //# sourceMappingURL=title.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"title.js","sources":["../../../../src/components/hds/code-block/title.hbs","../../../../src/components/hds/code-block/title.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! @glint-nocheck: not typesafe yet }}\\n{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<Hds::Text::Body @size=\\\"200\\\" @tag=\\\"p\\\" @weight=\\\"semibold\\\" class=\\\"hds-code-block__title\\\" ...attributes>\\n {{yield}}\\n</Hds::Text::Body>\")","import templateOnly from '@ember/component/template-only';\nexport default templateOnly();\n"],"names":["setComponentTemplate","TEMPLATE","templateOnly"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,yQAAyQ;;ACA3S,YAAAA,oBAAA,CAAAC,QAAA,EAAeC,qBAAY,EAAE,CAAA;;;;"}
1
+ {"version":3,"file":"title.js","sources":["../../../../src/components/hds/code-block/title.hbs","../../../../src/components/hds/code-block/title.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<Hds::Text::Body @size=\\\"200\\\" @tag=\\\"p\\\" @weight=\\\"semibold\\\" class=\\\"hds-code-block__title\\\" ...attributes>\\n {{yield}}\\n</Hds::Text::Body>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport templateOnlyComponent from '@ember/component/template-only';\nimport type { HdsTextBodySignature } from '../text/body';\n\nexport interface HdsCodeBlockTitleSignature {\n Blocks: {\n default: [];\n };\n Element: HdsTextBodySignature['Element'];\n}\n\nconst HdsCodeBlockTitleComponent =\n templateOnlyComponent<HdsCodeBlockTitleSignature>();\n\nexport default HdsCodeBlockTitleComponent;\n"],"names":["HdsCodeBlockTitleComponent","templateOnlyComponent","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,gOAAgO;;ACDlQ;AACA;AACA;AACA;;AAYA,MAAMA,0BAA0B,GAC9BC,qBAAqB,EAA8B,CAAA;AAErD,YAAAC,oBAAA,CAAAC,QAAA,EAAeH,0BAA0B,CAAA;;;;"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ let HdsCodeBlockLanguageValues = /*#__PURE__*/function (HdsCodeBlockLanguageValues) {
7
+ HdsCodeBlockLanguageValues["Bash"] = "bash";
8
+ HdsCodeBlockLanguageValues["Go"] = "go";
9
+ HdsCodeBlockLanguageValues["Hcl"] = "hcl";
10
+ HdsCodeBlockLanguageValues["Json"] = "json";
11
+ HdsCodeBlockLanguageValues["Log"] = "log";
12
+ HdsCodeBlockLanguageValues["Ruby"] = "ruby";
13
+ HdsCodeBlockLanguageValues["ShellSession"] = "shell-session";
14
+ HdsCodeBlockLanguageValues["Yaml"] = "yaml";
15
+ return HdsCodeBlockLanguageValues;
16
+ }({});
17
+
18
+ export { HdsCodeBlockLanguageValues };
19
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../src/components/hds/code-block/types.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nexport enum HdsCodeBlockLanguageValues {\n Bash = 'bash',\n Go = 'go',\n Hcl = 'hcl',\n Json = 'json',\n Log = 'log',\n Ruby = 'ruby',\n ShellSession = 'shell-session',\n Yaml = 'yaml',\n}\n\nexport type HdsCodeBlockLanguages = `${HdsCodeBlockLanguageValues}`;\n"],"names":["HdsCodeBlockLanguageValues"],"mappings":"AAAA;AACA;AACA;AACA;;AAEYA,IAAAA,0BAA0B,0BAA1BA,0BAA0B,EAAA;EAA1BA,0BAA0B,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;EAA1BA,0BAA0B,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;EAA1BA,0BAA0B,CAAA,KAAA,CAAA,GAAA,KAAA,CAAA;EAA1BA,0BAA0B,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;EAA1BA,0BAA0B,CAAA,KAAA,CAAA,GAAA,KAAA,CAAA;EAA1BA,0BAA0B,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;EAA1BA,0BAA0B,CAAA,cAAA,CAAA,GAAA,eAAA,CAAA;EAA1BA,0BAA0B,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;AAAA,EAAA,OAA1BA,0BAA0B,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -0,0 +1,89 @@
1
+ import { a as _defineProperty } from '../../../_rollupPluginBabelHelpers-KIi_qCIU.js';
2
+ import Component from '@glimmer/component';
3
+ import { guidFor } from '@ember/object/internals';
4
+ import { assert } from '@ember/debug';
5
+ import { iconNames } from '@hashicorp/flight-icons/svg';
6
+ import { HdsIconColorValues, HdsIconSizeValues } from './types.js';
7
+ import { precompileTemplate } from '@ember/template-compilation';
8
+ import { setComponentTemplate } from '@ember/component';
9
+
10
+ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<svg\n class={{this.classNames}}\n ...attributes\n aria-hidden=\"{{if @title \'false\' \'true\'}}\"\n aria-labelledby={{this.ariaLabelledby}}\n data-test-icon={{@name}}\n fill=\"{{this.fillColor}}\"\n id={{this.iconId}}\n role={{this.role}}\n width=\"{{this.svgSize.width}}\"\n height=\"{{this.svgSize.height}}\"\n viewBox=\"0 0 {{this.size}} {{this.size}}\"\n xmlns=\"http://www.w3.org/2000/svg\"\n>\n {{#if @title}}\n <title id={{this.titleId}}>{{@title}}</title>\n <g role=\"presentation\">\n <use href=\"#flight-{{@name}}-{{this.size}}\"></use>\n </g>\n {{else}}\n <use href=\"#flight-{{@name}}-{{this.size}}\"></use>\n {{/if}}\n</svg>");
11
+
12
+ const AVAILABLE_COLORS = Object.values(HdsIconColorValues);
13
+ class HdsIcon extends Component {
14
+ constructor(owner, args) {
15
+ super(owner, args);
16
+ _defineProperty(this, "iconId", 'icon-' + guidFor(this));
17
+ _defineProperty(this, "titleId", 'title-' + guidFor(this));
18
+ if (!this.args.name) {
19
+ assert('Please provide to <Hds::Icon> a value for @name');
20
+ } else if (!iconNames.includes(this.args.name)) {
21
+ assert(`The icon @name "${this.args.name}" provided to <Hds::Icon> is not correct. Please verify it exists on https://helios.hashicorp.design/icons/library`);
22
+ }
23
+ }
24
+ get isInline() {
25
+ return this.args.isInline ?? false;
26
+ }
27
+ get predefinedColor() {
28
+ const {
29
+ color
30
+ } = this.args;
31
+ if (color && AVAILABLE_COLORS.includes(color)) {
32
+ return color;
33
+ } else {
34
+ return undefined;
35
+ }
36
+ }
37
+ get fillColor() {
38
+ if (this.predefinedColor !== undefined) {
39
+ return 'currentColor';
40
+ } else {
41
+ return this.args.color ?? 'currentColor';
42
+ }
43
+ }
44
+ get size() {
45
+ return this.args.size ?? HdsIconSizeValues.Sixteen;
46
+ }
47
+ get svgSize() {
48
+ return {
49
+ width: this.args.stretched ? '100%' : this.size,
50
+ height: this.args.stretched ? '100%' : this.size
51
+ };
52
+ }
53
+ get title() {
54
+ return this.args.title ?? null;
55
+ }
56
+ get role() {
57
+ return this.args.title ? 'img' : null;
58
+ }
59
+ get ariaLabelledby() {
60
+ return this.args.title ? this.titleId : null;
61
+ }
62
+ get classNames() {
63
+ const {
64
+ name
65
+ } = this.args;
66
+ const classes = ['hds-icon'];
67
+
68
+ // add a class based on the @name argument
69
+ classes.push(`hds-icon-${name}`);
70
+ if (this.isInline) {
71
+ classes.push('hds-icon--is-inline');
72
+ }
73
+
74
+ // add a (helper) class based on the @color argument (if pre-defined)
75
+ if (this.predefinedColor) {
76
+ classes.push(`hds-foreground-${this.predefinedColor}`);
77
+ }
78
+
79
+ // add an extra class to control the animation (depends on the icon)
80
+ if (['loading', 'running'].includes(name)) {
81
+ classes.push(`hds-icon--animation-${name}`);
82
+ }
83
+ return classes.join(' ');
84
+ }
85
+ }
86
+ setComponentTemplate(TEMPLATE, HdsIcon);
87
+
88
+ export { AVAILABLE_COLORS, HdsIcon as default };
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/hds/icon/index.hbs","../../../../src/components/hds/icon/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<svg\\n class={{this.classNames}}\\n ...attributes\\n aria-hidden=\\\"{{if @title \\'false\\' \\'true\\'}}\\\"\\n aria-labelledby={{this.ariaLabelledby}}\\n data-test-icon={{@name}}\\n fill=\\\"{{this.fillColor}}\\\"\\n id={{this.iconId}}\\n role={{this.role}}\\n width=\\\"{{this.svgSize.width}}\\\"\\n height=\\\"{{this.svgSize.height}}\\\"\\n viewBox=\\\"0 0 {{this.size}} {{this.size}}\\\"\\n xmlns=\\\"http://www.w3.org/2000/svg\\\"\\n>\\n {{#if @title}}\\n <title id={{this.titleId}}>{{@title}}</title>\\n <g role=\\\"presentation\\\">\\n <use href=\\\"#flight-{{@name}}-{{this.size}}\\\"></use>\\n </g>\\n {{else}}\\n <use href=\\\"#flight-{{@name}}-{{this.size}}\\\"></use>\\n {{/if}}\\n</svg>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { assert } from '@ember/debug';\nimport { iconNames } from '@hashicorp/flight-icons/svg';\nimport { HdsIconSizeValues, HdsIconColorValues } from './types.ts';\nimport type { HdsIconSizes, HdsIconColors } from './types';\nimport type { IconName } from '@hashicorp/flight-icons/svg';\n\nexport const AVAILABLE_COLORS: string[] = Object.values(HdsIconColorValues);\n\nexport interface HdsIconSignature {\n Args: {\n name: IconName;\n color?: HdsIconColors | string | undefined;\n size?: HdsIconSizes;\n stretched?: boolean;\n isInline?: boolean;\n title?: string;\n };\n Element: SVGElement;\n}\n\nexport default class HdsIcon extends Component<HdsIconSignature> {\n iconId = 'icon-' + guidFor(this);\n titleId = 'title-' + guidFor(this);\n\n constructor(owner: unknown, args: HdsIconSignature['Args']) {\n super(owner, args);\n\n if (!this.args.name) {\n assert('Please provide to <Hds::Icon> a value for @name');\n } else if (!iconNames.includes(this.args.name)) {\n assert(\n `The icon @name \"${this.args.name}\" provided to <Hds::Icon> is not correct. Please verify it exists on https://helios.hashicorp.design/icons/library`\n );\n }\n }\n\n get isInline(): boolean {\n return this.args.isInline ?? false;\n }\n\n get predefinedColor(): HdsIconColors | undefined {\n const { color } = this.args;\n\n if (color && AVAILABLE_COLORS.includes(color)) {\n return color as HdsIconColors;\n } else {\n return undefined;\n }\n }\n\n get fillColor(): string {\n if (this.predefinedColor !== undefined) {\n return 'currentColor';\n } else {\n return this.args.color ?? 'currentColor';\n }\n }\n\n get size(): string {\n return this.args.size ?? HdsIconSizeValues.Sixteen;\n }\n\n get svgSize(): { width: string; height: string } {\n return {\n width: this.args.stretched ? '100%' : this.size,\n height: this.args.stretched ? '100%' : this.size,\n };\n }\n\n get title(): string | null {\n return this.args.title ?? null;\n }\n\n get role(): string | null {\n return this.args.title ? 'img' : null;\n }\n\n get ariaLabelledby(): string | null {\n return this.args.title ? this.titleId : null;\n }\n\n get classNames() {\n const { name } = this.args;\n const classes = ['hds-icon'];\n\n // add a class based on the @name argument\n classes.push(`hds-icon-${name}`);\n\n if (this.isInline) {\n classes.push('hds-icon--is-inline');\n }\n\n // add a (helper) class based on the @color argument (if pre-defined)\n if (this.predefinedColor) {\n classes.push(`hds-foreground-${this.predefinedColor}`);\n }\n\n // add an extra class to control the animation (depends on the icon)\n if (['loading', 'running'].includes(name)) {\n classes.push(`hds-icon--animation-${name}`);\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["AVAILABLE_COLORS","Object","values","HdsIconColorValues","HdsIcon","Component","constructor","owner","args","_defineProperty","guidFor","name","assert","iconNames","includes","isInline","predefinedColor","color","undefined","fillColor","size","HdsIconSizeValues","Sixteen","svgSize","width","stretched","height","title","role","ariaLabelledby","titleId","classNames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AE;MACxBgB,OAAO,CAACC,IAAI,CAAC,CAAA,eAAA,EAAkB,IAAI,CAACjB,eAAe,EAAE,CAAC,CAAA;AACxD,KAAA;;AAEA;IACA,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAACF,QAAQ,CAACH,IAAI,CAAC,EAAE;AACzCqB,MAAAA,OAAO,CAACC,IAAI,CAAC,CAAuBtB,oBAAAA,EAAAA,IAAI,EAAE,CAAC,CAAA;AAC7C,KAAA;AAEA,IAAA,OAAOqB,OAAO,CAACE,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAA;AAACC,oBAAA,CAAAC,QAAA,EApFoBhC,OAAO,CAAA;;;;"}
@@ -0,0 +1,31 @@
1
+ let HdsIconSizeValues = /*#__PURE__*/function (HdsIconSizeValues) {
2
+ HdsIconSizeValues["Sixteen"] = "16";
3
+ HdsIconSizeValues["TwentyFour"] = "24";
4
+ return HdsIconSizeValues;
5
+ }({});
6
+ let HdsIconColorValues = /*#__PURE__*/function (HdsIconColorValues) {
7
+ HdsIconColorValues["Primary"] = "primary";
8
+ HdsIconColorValues["Strong"] = "strong";
9
+ HdsIconColorValues["Faint"] = "faint";
10
+ HdsIconColorValues["Disabled"] = "disabled";
11
+ HdsIconColorValues["HighContrast"] = "high-contrast";
12
+ HdsIconColorValues["Action"] = "action";
13
+ HdsIconColorValues["ActionHover"] = "action-hover";
14
+ HdsIconColorValues["ActionActive"] = "action-active";
15
+ HdsIconColorValues["Highlight"] = "highlight";
16
+ HdsIconColorValues["HighlightOnSurface"] = "highlight-on-surface";
17
+ HdsIconColorValues["HighlightHighContrast"] = "highlight-high-contrast";
18
+ HdsIconColorValues["Success"] = "success";
19
+ HdsIconColorValues["SuccessOnSurface"] = "success-on-surface";
20
+ HdsIconColorValues["SuccessHighContrast"] = "success-high-contrast";
21
+ HdsIconColorValues["Warning"] = "warning";
22
+ HdsIconColorValues["WarningOnSurface"] = "warning-on-surface";
23
+ HdsIconColorValues["WarningHighContrast"] = "warning-high-contrast";
24
+ HdsIconColorValues["Critical"] = "critical";
25
+ HdsIconColorValues["CriticalOnSurface"] = "critical-on-surface";
26
+ HdsIconColorValues["CriticalHighContrast"] = "critical-high-contrast";
27
+ return HdsIconColorValues;
28
+ }({});
29
+
30
+ export { HdsIconColorValues, HdsIconSizeValues };
31
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../src/components/hds/icon/types.ts"],"sourcesContent":["export enum HdsIconSizeValues {\n Sixteen = '16',\n TwentyFour = '24',\n}\n\nexport type HdsIconSizes = `${HdsIconSizeValues}`;\n\nexport enum HdsIconColorValues {\n Primary = 'primary',\n Strong = 'strong',\n Faint = 'faint',\n Disabled = 'disabled',\n HighContrast = 'high-contrast',\n Action = 'action',\n ActionHover = 'action-hover',\n ActionActive = 'action-active',\n Highlight = 'highlight',\n HighlightOnSurface = 'highlight-on-surface',\n HighlightHighContrast = 'highlight-high-contrast',\n Success = 'success',\n SuccessOnSurface = 'success-on-surface',\n SuccessHighContrast = 'success-high-contrast',\n Warning = 'warning',\n WarningOnSurface = 'warning-on-surface',\n WarningHighContrast = 'warning-high-contrast',\n Critical = 'critical',\n CriticalOnSurface = 'critical-on-surface',\n CriticalHighContrast = 'critical-high-contrast',\n}\nexport type HdsIconColors = `${HdsIconColorValues}`;\n"],"names":["HdsIconSizeValues","HdsIconColorValues"],"mappings":"AAAYA,IAAAA,iBAAiB,0BAAjBA,iBAAiB,EAAA;EAAjBA,iBAAiB,CAAA,SAAA,CAAA,GAAA,IAAA,CAAA;EAAjBA,iBAAiB,CAAA,YAAA,CAAA,GAAA,IAAA,CAAA;AAAA,EAAA,OAAjBA,iBAAiB,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAOjBC,IAAAA,kBAAkB,0BAAlBA,kBAAkB,EAAA;EAAlBA,kBAAkB,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAlBA,kBAAkB,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;EAAlBA,kBAAkB,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;EAAlBA,kBAAkB,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAlBA,kBAAkB,CAAA,cAAA,CAAA,GAAA,eAAA,CAAA;EAAlBA,kBAAkB,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;EAAlBA,kBAAkB,CAAA,aAAA,CAAA,GAAA,cAAA,CAAA;EAAlBA,kBAAkB,CAAA,cAAA,CAAA,GAAA,eAAA,CAAA;EAAlBA,kBAAkB,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAlBA,kBAAkB,CAAA,oBAAA,CAAA,GAAA,sBAAA,CAAA;EAAlBA,kBAAkB,CAAA,uBAAA,CAAA,GAAA,yBAAA,CAAA;EAAlBA,kBAAkB,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAlBA,kBAAkB,CAAA,kBAAA,CAAA,GAAA,oBAAA,CAAA;EAAlBA,kBAAkB,CAAA,qBAAA,CAAA,GAAA,uBAAA,CAAA;EAAlBA,kBAAkB,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAlBA,kBAAkB,CAAA,kBAAA,CAAA,GAAA,oBAAA,CAAA;EAAlBA,kBAAkB,CAAA,qBAAA,CAAA,GAAA,uBAAA,CAAA;EAAlBA,kBAAkB,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAlBA,kBAAkB,CAAA,mBAAA,CAAA,GAAA,qBAAA,CAAA;EAAlBA,kBAAkB,CAAA,sBAAA,CAAA,GAAA,wBAAA,CAAA;AAAA,EAAA,OAAlBA,kBAAkB,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -1,5 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { assert } from '@ember/debug';
3
+ import { HdsTooltipPlacementValues } from './types.js';
3
4
  import { precompileTemplate } from '@ember/template-compilation';
4
5
  import { setComponentTemplate } from '@ember/component';
5
6
 
@@ -10,7 +11,7 @@ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-
10
11
  * SPDX-License-Identifier: MPL-2.0
11
12
  */
12
13
 
13
- const PLACEMENTS = ['top', 'top-start', 'top-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end'];
14
+ const PLACEMENTS = Object.values(HdsTooltipPlacementValues);
14
15
  class HdsTooltipIndexComponent extends Component {
15
16
  /**
16
17
  * @param text
@@ -18,23 +19,22 @@ class HdsTooltipIndexComponent extends Component {
18
19
  * @description text content for tooltip
19
20
  */
20
21
  get text() {
21
- let {
22
+ const {
22
23
  text
23
24
  } = this.args;
24
25
  assert('@text for "Hds::TooltipButton" must have a valid value', text !== undefined);
25
26
  return text;
26
27
  }
27
28
  get options() {
28
- let {
29
+ const {
29
30
  placement
30
31
  } = this.args;
31
32
  assert('@placement for "Hds::TooltipButton" must have a valid value', placement == undefined || PLACEMENTS.includes(placement));
32
33
  return {
33
34
  ...this.args.extraTippyOptions,
34
- // takes string
35
35
  placement: placement,
36
- // takes array of 2 numbers (skidding, distance): array(0, 0)
37
- offset: this.args.offset
36
+ // takes array of 2 numbers (skidding, distance): array(0, 10)
37
+ offset: this.args.offset ? this.args.offset : [0, 10]
38
38
  };
39
39
  }
40
40
 
@@ -45,7 +45,7 @@ class HdsTooltipIndexComponent extends Component {
45
45
  * @description sets display for the button
46
46
  */
47
47
  get isInline() {
48
- let {
48
+ const {
49
49
  isInline = true
50
50
  } = this.args;
51
51
  return isInline;
@@ -57,7 +57,7 @@ class HdsTooltipIndexComponent extends Component {
57
57
  * @return {string} The "class" attribute to apply to the component.
58
58
  */
59
59
  get classNames() {
60
- let classes = ['hds-tooltip-button'];
60
+ const classes = ['hds-tooltip-button'];
61
61
 
62
62
  // add a class based on the @isInline argument
63
63
  if (this.isInline) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/hds/tooltip-button/index.hbs","../../../../src/components/hds/tooltip-button/index.js"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<button\\n type=\\\"button\\\"\\n class={{this.classNames}}\\n {{hds-tooltip this.text options=this.options}}\\n ...attributes\\n>{{~yield~}}</button>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nexport const PLACEMENTS = [\n 'top',\n 'top-start',\n 'top-end',\n 'right',\n 'right-start',\n 'right-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'left',\n 'left-start',\n 'left-end',\n];\n\nexport default class HdsTooltipIndexComponent extends Component {\n /**\n * @param text\n * @type {string}\n * @description text content for tooltip\n */\n get text() {\n let { text } = this.args;\n\n assert(\n '@text for \"Hds::TooltipButton\" must have a valid value',\n text !== undefined\n );\n\n return text;\n }\n\n get options() {\n let { placement } = this.args;\n\n assert(\n '@placement for \"Hds::TooltipButton\" must have a valid value',\n placement == undefined || PLACEMENTS.includes(placement)\n );\n\n return {\n ...this.args.extraTippyOptions,\n // takes string\n placement: placement,\n // takes array of 2 numbers (skidding, distance): array(0, 0)\n offset: this.args.offset,\n };\n }\n\n /**\n * @param isInline\n * @type {boolean}\n * @default true\n * @description sets display for the button\n */\n get isInline() {\n let { isInline = true } = this.args;\n return isInline;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames() {\n let classes = ['hds-tooltip-button'];\n\n // add a class based on the @isInline argument\n if (this.isInline) {\n classes.push('hds-tooltip-button--is-inline');\n } else {\n classes.push('hds-tooltip-button--is-block');\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["PLACEMENTS","HdsTooltipIndexComponent","Component","text","args","assert","undefined","options","placement","includes","extraTippyOptions","offset","isInline","classNames","classes","push","join","setComponentTemplate","TEMPLATE"],"mappings":";;;;;AACA,eAAe,kBAAkB,CAAC,mOAAmO;;ACDrQ;AACA;AACA;AACA;;AAKO,MAAMA,UAAU,GAAG,CACxB,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU,EACX;AAEc,MAAMC,wBAAwB,SAASC,SAAS,CAAC;AAC9D;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;IACT,IAAI;AAAEA,MAAAA,IAAAA;KAAM,GAAG,IAAI,CAACC,IAAI,CAAA;AAExBC,IAAAA,MAAM,CACJ,wDAAwD,EACxDF,IAAI,KAAKG,SACX,CAAC,CAAA;AAED,IAAA,OAAOH,IAAI,CAAA;AACb,GAAA;EAEA,IAAII,OAAOA,GAAG;IACZ,IAAI;AAAEC,MAAAA,SAAAA;KAAW,GAAG,IAAI,CAACJ,IAAI,CAAA;AAE7BC,IAAAA,MAAM,CACJ,6DAA6D,EAC7DG,SAAS,IAAIF,SAAS,IAAIN,UAAU,CAACS,QAAQ,CAACD,SAAS,CACzD,CAAC,CAAA;IAED,OAAO;AACL,MAAA,GAAG,IAAI,CAACJ,IAAI,CAACM,iBAAiB;AAC9B;AACAF,MAAAA,SAAS,EAAEA,SAAS;AACpB;AACAG,MAAAA,MAAM,EAAE,IAAI,CAACP,IAAI,CAACO,MAAAA;KACnB,CAAA;AACH,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIC,QAAQA,GAAG;IACb,IAAI;AAAEA,MAAAA,QAAQ,GAAG,IAAA;KAAM,GAAG,IAAI,CAACR,IAAI,CAAA;AACnC,IAAA,OAAOQ,QAAQ,CAAA;AACjB,GAAA;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIC,UAAUA,GAAG;AACf,IAAA,IAAIC,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAA;;AAEpC;IACA,IAAI,IAAI,CAACF,QAAQ,EAAE;AACjBE,MAAAA,OAAO,CAACC,IAAI,CAAC,+BAA+B,CAAC,CAAA;AAC/C,KAAC,MAAM;AACLD,MAAAA,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC,CAAA;AAC9C,KAAA;AAEA,IAAA,OAAOD,OAAO,CAACE,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAA;AAACC,oBAAA,CAAAC,QAAA,EA9DoBjB,wBAAwB,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/hds/tooltip-button/index.hbs","../../../../src/components/hds/tooltip-button/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n\\n<button\\n type=\\\"button\\\"\\n class={{this.classNames}}\\n {{hds-tooltip this.text options=this.options}}\\n ...attributes\\n>{{~yield~}}</button>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\n\nimport type { Props as TippyProps } from 'tippy.js';\nimport { HdsTooltipPlacementValues } from './types.ts';\n\nexport const PLACEMENTS: string[] = Object.values(HdsTooltipPlacementValues);\n\nexport interface HdsTooltipSignature {\n Args: {\n extraTippyOptions: Omit<TippyProps, 'placement' | 'offset'>;\n isInline?: boolean;\n offset?: [number, number];\n placement: HdsTooltipPlacementValues;\n text: string;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLButtonElement;\n}\n\nexport default class HdsTooltipIndexComponent extends Component<HdsTooltipSignature> {\n /**\n * @param text\n * @type {string}\n * @description text content for tooltip\n */\n get text(): string {\n const { text } = this.args;\n\n assert(\n '@text for \"Hds::TooltipButton\" must have a valid value',\n text !== undefined\n );\n\n return text;\n }\n\n get options(): TippyProps {\n const { placement } = this.args;\n\n assert(\n '@placement for \"Hds::TooltipButton\" must have a valid value',\n placement == undefined || PLACEMENTS.includes(placement)\n );\n\n return {\n ...this.args.extraTippyOptions,\n placement: placement,\n // takes array of 2 numbers (skidding, distance): array(0, 10)\n offset: this.args.offset ? this.args.offset : [0, 10],\n };\n }\n\n /**\n * @param isInline\n * @type {boolean}\n * @default true\n * @description sets display for the button\n */\n get isInline(): boolean {\n const { isInline = true } = this.args;\n return isInline;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames(): string {\n const classes = ['hds-tooltip-button'];\n\n // add a class based on the @isInline argument\n if (this.isInline) {\n classes.push('hds-tooltip-button--is-inline');\n } else {\n classes.push('hds-tooltip-button--is-block');\n }\n\n return classes.join(' ');\n }\n}\n"],"names":["PLACEMENTS","Object","values","HdsTooltipPlacementValues","HdsTooltipIndexComponent","Component","text","args","assert","undefined","options","placement","includes","extraTippyOptions","offset","isInline","classNames","classes","push","join","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AACA,eAAe,kBAAkB,CAAC,mOAAmO;;ACDrQ;AACA;AACA;AACA;;AAQO,MAAMA,UAAoB,GAAGC,MAAM,CAACC,MAAM,CAACC,yBAAyB,EAAC;AAgB7D,MAAMC,wBAAwB,SAASC,SAAS,CAAsB;AACnF;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAW;IACjB,MAAM;AAAEA,MAAAA,IAAAA;KAAM,GAAG,IAAI,CAACC,IAAI,CAAA;AAE1BC,IAAAA,MAAM,CACJ,wDAAwD,EACxDF,IAAI,KAAKG,SACX,CAAC,CAAA;AAED,IAAA,OAAOH,IAAI,CAAA;AACb,GAAA;EAEA,IAAII,OAAOA,GAAe;IACxB,MAAM;AAAEC,MAAAA,SAAAA;KAAW,GAAG,IAAI,CAACJ,IAAI,CAAA;AAE/BC,IAAAA,MAAM,CACJ,6DAA6D,EAC7DG,SAAS,IAAIF,SAAS,IAAIT,UAAU,CAACY,QAAQ,CAACD,SAAS,CACzD,CAAC,CAAA;IAED,OAAO;AACL,MAAA,GAAG,IAAI,CAACJ,IAAI,CAACM,iBAAiB;AAC9BF,MAAAA,SAAS,EAAEA,SAAS;AACpB;AACAG,MAAAA,MAAM,EAAE,IAAI,CAACP,IAAI,CAACO,MAAM,GAAG,IAAI,CAACP,IAAI,CAACO,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAA;KACrD,CAAA;AACH,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,IAAIC,QAAQA,GAAY;IACtB,MAAM;AAAEA,MAAAA,QAAQ,GAAG,IAAA;KAAM,GAAG,IAAI,CAACR,IAAI,CAAA;AACrC,IAAA,OAAOQ,QAAQ,CAAA;AACjB,GAAA;;AAEA;AACF;AACA;AACA;AACA;EACE,IAAIC,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,oBAAoB,CAAC,CAAA;;AAEtC;IACA,IAAI,IAAI,CAACF,QAAQ,EAAE;AACjBE,MAAAA,OAAO,CAACC,IAAI,CAAC,+BAA+B,CAAC,CAAA;AAC/C,KAAC,MAAM;AACLD,MAAAA,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC,CAAA;AAC9C,KAAA;AAEA,IAAA,OAAOD,OAAO,CAACE,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAA;AAACC,oBAAA,CAAAC,QAAA,EA7DoBjB,wBAAwB,CAAA;;;;"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ let HdsTooltipPlacementValues = /*#__PURE__*/function (HdsTooltipPlacementValues) {
7
+ HdsTooltipPlacementValues["Top"] = "top";
8
+ HdsTooltipPlacementValues["TopStart"] = "top-start";
9
+ HdsTooltipPlacementValues["TopEnd"] = "top-end";
10
+ HdsTooltipPlacementValues["Right"] = "right";
11
+ HdsTooltipPlacementValues["RightStart"] = "right-start";
12
+ HdsTooltipPlacementValues["RightEnd"] = "right-end";
13
+ HdsTooltipPlacementValues["Bottom"] = "bottom";
14
+ HdsTooltipPlacementValues["BottomStart"] = "bottom-start";
15
+ HdsTooltipPlacementValues["BottomEnd"] = "bottom-end";
16
+ HdsTooltipPlacementValues["Left"] = "left";
17
+ HdsTooltipPlacementValues["LeftStart"] = "left-start";
18
+ HdsTooltipPlacementValues["LeftEnd"] = "left-end";
19
+ return HdsTooltipPlacementValues;
20
+ }({});
21
+
22
+ export { HdsTooltipPlacementValues };
23
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../src/components/hds/tooltip-button/types.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nexport enum HdsTooltipPlacementValues {\n Top = 'top',\n TopStart = 'top-start',\n TopEnd = 'top-end',\n Right = 'right',\n RightStart = 'right-start',\n RightEnd = 'right-end',\n Bottom = 'bottom',\n BottomStart = 'bottom-start',\n BottomEnd = 'bottom-end',\n Left = 'left',\n LeftStart = 'left-start',\n LeftEnd = 'left-end',\n}\n\nexport type HdsTooltipPlacements = `${HdsTooltipPlacementValues}`;\n"],"names":["HdsTooltipPlacementValues"],"mappings":"AAAA;AACA;AACA;AACA;;AAEYA,IAAAA,yBAAyB,0BAAzBA,yBAAyB,EAAA;EAAzBA,yBAAyB,CAAA,KAAA,CAAA,GAAA,KAAA,CAAA;EAAzBA,yBAAyB,CAAA,UAAA,CAAA,GAAA,WAAA,CAAA;EAAzBA,yBAAyB,CAAA,QAAA,CAAA,GAAA,SAAA,CAAA;EAAzBA,yBAAyB,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;EAAzBA,yBAAyB,CAAA,YAAA,CAAA,GAAA,aAAA,CAAA;EAAzBA,yBAAyB,CAAA,UAAA,CAAA,GAAA,WAAA,CAAA;EAAzBA,yBAAyB,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;EAAzBA,yBAAyB,CAAA,aAAA,CAAA,GAAA,cAAA,CAAA;EAAzBA,yBAAyB,CAAA,WAAA,CAAA,GAAA,YAAA,CAAA;EAAzBA,yBAAyB,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;EAAzBA,yBAAyB,CAAA,WAAA,CAAA,GAAA,YAAA,CAAA;EAAzBA,yBAAyB,CAAA,SAAA,CAAA,GAAA,UAAA,CAAA;AAAA,EAAA,OAAzBA,yBAAyB,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -15,6 +15,10 @@ export { default as HdsBreadcrumbTruncation } from './components/hds/breadcrumb/
15
15
  export { default as HdsButton } from './components/hds/button/index.js';
16
16
  export { default as HdsButtonSet } from './components/hds/button-set/index.js';
17
17
  export { default as HdsCard } from './components/hds/card/container.js';
18
+ export { default as HdsCodeBlock } from './components/hds/code-block/index.js';
19
+ export { default as HdsCodeBlockCopyButton } from './components/hds/code-block/copy-button.js';
20
+ export { default as HdsCodeBlockDescription } from './components/hds/code-block/description.js';
21
+ export { default as HdsCodeBlockTitle } from './components/hds/code-block/title.js';
18
22
  export { default as HdsCopyButton } from './components/hds/copy/button/index.js';
19
23
  export { default as HdsCopySnippet } from './components/hds/copy/snippet/index.js';
20
24
  export { default as HdsDialogPrimitiveBody } from './components/hds/dialog-primitive/body.js';
@@ -61,6 +65,7 @@ export { default as HdsFormToggleBase } from './components/hds/form/toggle/base.
61
65
  export { default as HdsFormToggleField } from './components/hds/form/toggle/field.js';
62
66
  export { default as HdsFormToggleGroup } from './components/hds/form/toggle/group.js';
63
67
  export { default as HdsFormVisibilityToggle } from './components/hds/form/visibility-toggle/index.js';
68
+ export { default as HdsIcon } from './components/hds/icon/index.js';
64
69
  export { default as HdsIconTile } from './components/hds/icon-tile/index.js';
65
70
  export { default as HdsInteractive } from './components/hds/interactive/index.js';
66
71
  export { default as HdsLinkInline } from './components/hds/link/inline.js';
@@ -93,4 +98,5 @@ export { default as HdsTextBody } from './components/hds/text/body.js';
93
98
  export { default as HdsTextCode } from './components/hds/text/code.js';
94
99
  export { default as HdsTextDisplay } from './components/hds/text/display.js';
95
100
  export { default as HdsToast } from './components/hds/toast/index.js';
101
+ export { default as HdsTooltipButton } from './components/hds/tooltip-button/index.js';
96
102
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5155,6 +5155,46 @@ button.hds-button[href]::after {
5155
5155
  cursor: pointer;
5156
5156
  }
5157
5157
 
5158
+ /**
5159
+ * Copyright (c) HashiCorp, Inc.
5160
+ * SPDX-License-Identifier: MPL-2.0
5161
+ */
5162
+ .hds-icon {
5163
+ display: block;
5164
+ }
5165
+
5166
+ .hds-icon--is-inline {
5167
+ display: inline-block;
5168
+ }
5169
+
5170
+ @keyframes hds-icon-animation-rotation {
5171
+ to {
5172
+ transform: rotate(360deg);
5173
+ }
5174
+ }
5175
+ .hds-icon--animation-loading {
5176
+ animation: hds-icon-animation-rotation 9s linear infinite;
5177
+ }
5178
+
5179
+ .hds-icon--animation-running {
5180
+ animation: hds-icon-animation-rotation 9s linear infinite;
5181
+ }
5182
+
5183
+ @media (prefers-reduced-motion: no-preference) {
5184
+ .hds-icon--animation-loading {
5185
+ animation-duration: 0.7s;
5186
+ }
5187
+ .hds-icon--animation-running {
5188
+ animation-duration: 1s;
5189
+ }
5190
+ }
5191
+ .flight-sprite-container {
5192
+ position: absolute;
5193
+ width: 0;
5194
+ height: 0;
5195
+ visibility: hidden;
5196
+ }
5197
+
5158
5198
  /**
5159
5199
  * Copyright (c) HashiCorp, Inc.
5160
5200
  * SPDX-License-Identifier: MPL-2.0
@@ -35,6 +35,7 @@
35
35
  @use "../components/dropdown";
36
36
  @use "../components/flyout";
37
37
  @use "../components/form"; // multiple components
38
+ @use "../components/icon";
38
39
  @use "../components/icon-tile";
39
40
  @use "../components/link"; // multiple components
40
41
  @use "../components/menu-primitive";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) HashiCorp, Inc.
3
+ * SPDX-License-Identifier: MPL-2.0
4
+ */
5
+
6
+ .hds-icon {
7
+ display: block;
8
+ }
9
+
10
+ .hds-icon--is-inline {
11
+ display: inline-block;
12
+ }
13
+
14
+ @keyframes hds-icon-animation-rotation {
15
+ to {transform: rotate(360deg);}
16
+ }
17
+
18
+ .hds-icon--animation-loading {
19
+ animation: hds-icon-animation-rotation 9s linear infinite;
20
+ }
21
+
22
+ .hds-icon--animation-running {
23
+ animation: hds-icon-animation-rotation 9s linear infinite;
24
+ }
25
+
26
+ @media (prefers-reduced-motion: no-preference) {
27
+ .hds-icon--animation-loading {
28
+ animation-duration: .7s;
29
+ }
30
+
31
+ .hds-icon--animation-running {
32
+ animation-duration: 1s;
33
+ }
34
+ }
35
+
36
+ .flight-sprite-container {
37
+ position: absolute;
38
+ width: 0;
39
+ height: 0;
40
+ visibility: hidden;
41
+ }