@hashicorp/design-system-components 4.1.2 → 4.2.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.
- package/dist/_app_/components/hds/alert/types.js +1 -0
- package/dist/_app_/components/hds/card/types.js +1 -0
- package/dist/_app_/components/hds/interactive/types.js +1 -0
- package/dist/_app_/components/hds/link/types.js +1 -0
- package/dist/_app_/components/hds/text/types.js +1 -0
- package/dist/_app_/components/hds/yield/types.js +1 -0
- package/dist/components/hds/alert/description.js +5 -4
- package/dist/components/hds/alert/description.js.map +1 -1
- package/dist/components/hds/alert/index.js +21 -18
- package/dist/components/hds/alert/index.js.map +1 -1
- package/dist/components/hds/alert/title.js +5 -4
- package/dist/components/hds/alert/title.js.map +1 -1
- package/dist/components/hds/alert/types.js +17 -0
- package/dist/components/hds/alert/types.js.map +1 -0
- package/dist/components/hds/button/index.js +6 -6
- package/dist/components/hds/button/index.js.map +1 -1
- package/dist/components/hds/card/container.js +25 -24
- package/dist/components/hds/card/container.js.map +1 -1
- package/dist/components/hds/card/types.js +19 -0
- package/dist/components/hds/card/types.js.map +1 -0
- package/dist/components/hds/copy/snippet/index.js +1 -1
- package/dist/components/hds/copy/snippet/index.js.map +1 -1
- package/dist/components/hds/dismiss-button/index.js.map +1 -1
- package/dist/components/hds/flyout/index.js +2 -8
- package/dist/components/hds/flyout/index.js.map +1 -1
- package/dist/components/hds/interactive/index.js.map +1 -1
- package/dist/components/hds/interactive/types.js +2 -0
- package/dist/components/hds/interactive/types.js.map +1 -0
- package/dist/components/hds/link/inline.js +11 -10
- package/dist/components/hds/link/inline.js.map +1 -1
- package/dist/components/hds/link/standalone.js +16 -15
- package/dist/components/hds/link/standalone.js.map +1 -1
- package/dist/components/hds/link/types.js +19 -0
- package/dist/components/hds/link/types.js.map +1 -0
- package/dist/components/hds/modal/index.js +2 -8
- package/dist/components/hds/modal/index.js.map +1 -1
- package/dist/components/hds/text/body.js +8 -7
- package/dist/components/hds/text/body.js.map +1 -1
- package/dist/components/hds/text/code.js +8 -7
- package/dist/components/hds/text/code.js.map +1 -1
- package/dist/components/hds/text/display.js +19 -12
- package/dist/components/hds/text/display.js.map +1 -1
- package/dist/components/hds/text/index.js +14 -10
- package/dist/components/hds/text/index.js.map +1 -1
- package/dist/components/hds/text/types.js +58 -0
- package/dist/components/hds/text/types.js.map +1 -0
- package/dist/components/hds/yield/index.js +10 -4
- package/dist/components/hds/yield/index.js.map +1 -1
- package/dist/components/hds/yield/types.js +2 -0
- package/dist/components/hds/yield/types.js.map +1 -0
- package/dist/helpers/hds-link-to-models.js.map +1 -1
- package/package.json +11 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/hds/copy/snippet/index.hbs","../../../../../src/components/hds/copy/snippet/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<button\\n type=\\\"button\\\"\\n class={{this.classNames}}\\n {{hds-clipboard text=@textToCopy onSuccess=this.onSuccess onError=this.onError}}\\n aria-label={{concat
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/hds/copy/snippet/index.hbs","../../../../../src/components/hds/copy/snippet/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<button\\n type=\\\"button\\\"\\n class={{this.classNames}}\\n {{hds-clipboard text=@textToCopy onSuccess=this.onSuccess onError=this.onError}}\\n aria-label={{concat \\\"copy \\\" @textToCopy}}\\n ...attributes\\n>\\n <Hds::Text::Code class=\\\"hds-copy-snippet__text\\\" @tag=\\\"span\\\" @size=\\\"100\\\">\\n {{@textToCopy}}\\n </Hds::Text::Code>\\n <FlightIcon @name={{this.icon}} class=\\\"hds-copy-snippet__icon\\\" />\\n</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';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\n\nexport const DEFAULT_COLOR = 'primary';\nexport const COLORS = ['primary', 'secondary'];\nexport const DEFAULT_ICON = 'clipboard-copy';\nexport const SUCCESS_ICON = 'clipboard-checked';\nexport const ERROR_ICON = 'clipboard-x';\nexport const DEFAULT_STATUS = 'idle';\n\nexport default class HdsCopySnippetIndexComponent extends Component {\n @tracked status = DEFAULT_STATUS;\n @tracked timer;\n\n /**\n * @param icon\n * @type {string}\n * @default DEFAULT_ICON\n * @description Determines the icon to be used, based on the success state. Note that this is auto-tracked because it depends on a tracked property (status).\n */\n get icon() {\n let icon = DEFAULT_ICON;\n if (this.status === 'success') {\n icon = SUCCESS_ICON;\n } else if (this.status === 'error') {\n icon = ERROR_ICON;\n }\n return icon;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of button to be used; acceptable values are `primary` and `secondary`\n */\n get color() {\n let { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Copy::Snippet\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * @param isFullWidth\n * @type {boolean}\n * @default false\n * @description Indicates that the component should take up the full width of the parent container.\n */\n get isFullWidth() {\n return this.args.isFullWidth ?? false;\n }\n\n /**\n * @param isTruncated\n * @type {boolean}\n * @default false\n * @description Indicates that the component should be truncated instead of wrapping text and using multiple lines.\n */\n get isTruncated() {\n return this.args.isTruncated ?? false;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method CopySnippet#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames() {\n let classes = ['hds-copy-snippet'];\n\n // add a class based on the @color argument\n classes.push(`hds-copy-snippet--color-${this.color}`);\n\n // add a class based on the tracked status (idle/success/error)\n classes.push(`hds-copy-snippet--status-${this.status}`);\n\n // add a class based on the @isTruncated argument\n if (this.isTruncated) {\n classes.push('hds-copy-snippet--is-truncated');\n }\n\n // add a class based on the @isFullWidth argument\n if (this.isFullWidth) {\n classes.push('hds-copy-snippet--width-full');\n }\n\n return classes.join(' ');\n }\n\n @action\n onSuccess(args) {\n this.status = 'success';\n this.resetStatusDelayed();\n\n let { onSuccess } = this.args;\n\n if (typeof onSuccess === 'function') {\n onSuccess(args);\n }\n }\n\n @action\n onError(args) {\n this.status = 'error';\n this.resetStatusDelayed();\n\n let { onError } = this.args;\n\n if (typeof onError === 'function') {\n onError(args);\n }\n }\n\n resetStatusDelayed() {\n clearTimeout(this.timer);\n // make it fade back to the default state\n this.timer = setTimeout(() => {\n this.status = DEFAULT_STATUS;\n }, 1500);\n }\n}\n"],"names":["DEFAULT_COLOR","COLORS","DEFAULT_ICON","SUCCESS_ICON","ERROR_ICON","DEFAULT_STATUS","HdsCopySnippetIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","icon","status","color","assert","join","includes","isFullWidth","isTruncated","classNames","classes","push","onSuccess","resetStatusDelayed","onError","clearTimeout","timer","setTimeout","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AACA,eAAe,kBAAkB,CAAC,shBAAshB;;;ACSjjB,MAAMA,aAAa,GAAG,UAAS;MACzBC,MAAM,GAAG,CAAC,SAAS,EAAE,WAAW,EAAC;AACvC,MAAMC,YAAY,GAAG,iBAAgB;AACrC,MAAMC,YAAY,GAAG,oBAAmB;AACxC,MAAMC,UAAU,GAAG,cAAa;AAChC,MAAMC,cAAc,GAAG,OAAM;AAEfC,IAAAA,4BAA4B,IAAAC,MAAA,GAAlC,MAAMD,4BAA4B,SAASE,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,IAAI,CAACC,KAAK,CAAC,CAAA;AACxB;AACA,IAAA,IAAI,CAACA,KAAK,GAAGC,UAAU,CAAC,MAAM;MAC5B,IAAI,CAACf,MAAM,GAAGV,cAAc,CAAA;KAC7B,EAAE,IAAI,CAAC,CAAA;AACV,GAAA;AACF,CAAC,GAAAO,WAAA,GAAAmB,yBAAA,CAAAxB,MAAA,CAAAyB,SAAA,EAAA,QAAA,EAAA,CApHEC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAUhC,cAAc,CAAA;AAAA,GAAA;AAAA,CAAAQ,CAAAA,EAAAA,YAAA,GAAAkB,yBAAA,CAAAxB,MAAA,CAAAyB,SAAA,YAC/BC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,EAAAN,yBAAA,CAAAxB,MAAA,CAAAyB,SAAA,EAAA,WAAA,EAAA,CAoFPM,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAjC,MAAA,CAAAyB,SAAA,EAAAzB,WAAAA,CAAAA,EAAAA,MAAA,CAAAyB,SAAA,CAAA,EAAAD,yBAAA,CAAAxB,MAAA,CAAAyB,SAAA,cAYNM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAjC,MAAA,CAAAyB,SAAA,EAAA,SAAA,CAAA,EAAAzB,MAAA,CAAAyB,SAAA,IAAAzB,MAAA,EAAA;AAlGwCkC,oBAAA,CAAAC,QAAA,EAAApC,4BAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/dismiss-button/index.hbs","../../../../src/components/hds/dismiss-button/index.ts"],"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<button class=\\\"hds-dismiss-button\\\" type=\\\"button\\\" aria-label={{this.ariaLabel}} ...attributes>\\n <FlightIcon @name=\\\"x\\\" @size=\\\"16\\\" @isInlineBlock={{false}} />\\n</button>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\n\nexport interface HdsDismissButtonSignature {\n Args: {\n ariaLabel?: string;\n }
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/dismiss-button/index.hbs","../../../../src/components/hds/dismiss-button/index.ts"],"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<button class=\\\"hds-dismiss-button\\\" type=\\\"button\\\" aria-label={{this.ariaLabel}} ...attributes>\\n <FlightIcon @name=\\\"x\\\" @size=\\\"16\\\" @isInlineBlock={{false}} />\\n</button>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\n\nexport interface HdsDismissButtonSignature {\n Args: {\n ariaLabel?: string;\n };\n Element: HTMLButtonElement;\n}\n\nexport default class HdsDismissButtonIndexComponent extends Component<HdsDismissButtonSignature> {\n /**\n * @param ariaLabel\n * @type {string}\n * @default 'Dismiss'\n */\n get ariaLabel() {\n return this.args.ariaLabel ?? 'Dismiss';\n }\n}\n"],"names":["HdsDismissButtonIndexComponent","Component","ariaLabel","args","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,ySAAyS;;ACD3U;AACA;AACA;AACA;;AAWe,MAAMA,8BAA8B,SAASC,SAAS,CAA4B;AAC/F;AACF;AACA;AACA;AACA;EACE,IAAIC,SAASA,GAAG;AACd,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,SAAS,IAAI,SAAS,CAAA;AACzC,GAAA;AACF,CAAA;AAACE,oBAAA,CAAAC,QAAA,EAToBL,8BAA8B,CAAA;;;;"}
|
|
@@ -5,19 +5,13 @@ import { action } from '@ember/object';
|
|
|
5
5
|
import { assert } from '@ember/debug';
|
|
6
6
|
import { getElementId } from '../../../utils/hds-get-element-id.js';
|
|
7
7
|
import { buildWaiter } from '@ember/test-waiters';
|
|
8
|
-
import { DEBUG } from '@glimmer/env';
|
|
9
8
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
9
|
import { setComponentTemplate } from '@ember/component';
|
|
11
10
|
|
|
12
11
|
var TEMPLATE = precompileTemplate("{{! @glint-nocheck: not typesafe yet }}\n{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<dialog\n class={{this.classNames}}\n ...attributes\n aria-labelledby={{this.id}}\n {{did-insert this.didInsert}}\n {{will-destroy this.willDestroyNode}}\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\n>\n {{yield (hash Header=(component \"hds/flyout/header\" id=this.id onDismiss=this.onDismiss))}}\n {{yield (hash Description=(component \"hds/flyout/description\"))}}\n {{yield (hash Body=(component \"hds/flyout/body\"))}}\n {{yield (hash Footer=(component \"hds/flyout/footer\" onDismiss=this.onDismiss))}}\n</dialog>\n{{#if this.isOpen}}\n <div class=\"hds-flyout__overlay\"></div>\n{{/if}}");
|
|
13
12
|
|
|
14
13
|
var _class, _descriptor;
|
|
15
|
-
let waiter;
|
|
16
|
-
|
|
17
|
-
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
18
|
-
if (DEBUG) {
|
|
19
|
-
waiter = buildWaiter('@hashicorp/design-system-components:flyout');
|
|
20
|
-
}
|
|
14
|
+
let waiter = buildWaiter('@hashicorp/design-system-components:flyout');
|
|
21
15
|
const DEFAULT_SIZE = 'medium';
|
|
22
16
|
const DEFAULT_HAS_OVERLAY = true;
|
|
23
17
|
const SIZES = ['medium', 'large'];
|
|
@@ -106,7 +100,7 @@ let HdsFlyoutIndexComponent = (_class = class HdsFlyoutIndexComponent extends Co
|
|
|
106
100
|
// allow ember test helpers to be aware of when the `close` event fires
|
|
107
101
|
// when using `click` or other helpers from '@ember/test-helpers'
|
|
108
102
|
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
109
|
-
if (
|
|
103
|
+
if (this.element.open) {
|
|
110
104
|
let token = waiter.beginAsync();
|
|
111
105
|
let listener = () => {
|
|
112
106
|
waiter.endAsync(token);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/flyout/index.hbs","../../../../src/components/hds/flyout/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<dialog\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n {{yield (hash Header=(component \\\"hds/flyout/header\\\" id=this.id onDismiss=this.onDismiss))}}\\n {{yield (hash Description=(component \\\"hds/flyout/description\\\"))}}\\n {{yield (hash Body=(component \\\"hds/flyout/body\\\"))}}\\n {{yield (hash Footer=(component \\\"hds/flyout/footer\\\" onDismiss=this.onDismiss))}}\\n</dialog>\\n{{#if this.isOpen}}\\n <div class=\\\"hds-flyout__overlay\\\"></div>\\n{{/if}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { getElementId } from '../../../utils/hds-get-element-id';\nimport { buildWaiter } from '@ember/test-waiters';\nimport { DEBUG } from '@glimmer/env';\n\nlet waiter;\n\n// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\nif (DEBUG) {\n waiter = buildWaiter('@hashicorp/design-system-components:flyout');\n}\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_HAS_OVERLAY = true;\nexport const SIZES = ['medium', 'large'];\n\nexport default class HdsFlyoutIndexComponent extends Component {\n @tracked isOpen = false;\n\n /**\n * Sets the size of the flyout\n * Accepted values: medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size() {\n let { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Flyout\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Calculates the unique ID to assign to the title\n */\n get id() {\n return getElementId(this);\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-flyout'];\n\n // add a class based on the @size argument\n classes.push(`hds-flyout--size-${this.size}`);\n\n return classes.join(' ');\n }\n\n @action registerOnCloseCallback() {\n if (this.args.onClose && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n\n this.isOpen = false;\n }\n\n @action\n didInsert(element) {\n // Store references of `<dialog>` and `<body>` elements\n this.element = element;\n this.body = document.body;\n\n if (this.body) {\n // Store the initial `overflow` value of `<body>` so we can reset to it\n this.bodyInitialOverflowValue =\n this.body.style.getPropertyValue('overflow');\n }\n\n // Register \"onClose\" callback function to be called when a native 'close' event is dispatched\n this.element.addEventListener('close', this.registerOnCloseCallback, true);\n\n // If the flyout dialog is not already open\n if (!this.element.open) {\n this.open();\n }\n }\n\n @action\n willDestroyNode() {\n if (this.element) {\n this.element.removeEventListener(\n 'close',\n this.registerOnCloseCallback,\n true\n );\n }\n }\n\n @action\n open() {\n // Make flyout dialog visible using the native `showModal` method\n this.element.showModal();\n this.isOpen = true;\n\n // Prevent page from scrolling when the dialog is open\n if (this.body) this.body.style.setProperty('overflow', 'hidden');\n\n // Call \"onOpen\" callback function\n if (this.args.onOpen && typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n }\n\n @action\n async onDismiss() {\n // allow ember test helpers to be aware of when the `close` event fires\n // when using `click` or other helpers from '@ember/test-helpers'\n // Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\n if (DEBUG && this.element.open) {\n let token = waiter.beginAsync();\n let listener = () => {\n waiter.endAsync(token);\n this.element.removeEventListener('close', listener);\n };\n this.element.addEventListener('close', listener);\n }\n\n // Make flyout dialog invisible using the native `close` method\n this.element.close();\n\n // Reset page `overflow` property\n if (this.body) {\n this.body.style.removeProperty('overflow');\n if (this.bodyInitialOverflowValue === '') {\n if (this.body.style.length === 0) {\n this.body.removeAttribute('style');\n }\n } else {\n this.body.style.setProperty('overflow', this.bodyInitialOverflowValue);\n }\n }\n }\n}\n"],"names":["waiter","DEBUG","buildWaiter","DEFAULT_SIZE","DEFAULT_HAS_OVERLAY","SIZES","HdsFlyoutIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","size","assert","join","includes","id","getElementId","classNames","classes","push","registerOnCloseCallback","onClose","isOpen","didInsert","element","body","document","bodyInitialOverflowValue","style","getPropertyValue","addEventListener","open","willDestroyNode","removeEventListener","showModal","setProperty","onOpen","onDismiss","token","beginAsync","listener","endAsync","close","removeProperty","length","removeAttribute","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;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BAAA1C,MAAA,CAAA0C,SAAA,CAAA,GAAA1C,MAAA,EAAA;AApGmCmD,oBAAA,CAAAC,QAAA,EAAArD,uBAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/flyout/index.hbs","../../../../src/components/hds/flyout/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<dialog\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n {{yield (hash Header=(component \\\"hds/flyout/header\\\" id=this.id onDismiss=this.onDismiss))}}\\n {{yield (hash Description=(component \\\"hds/flyout/description\\\"))}}\\n {{yield (hash Body=(component \\\"hds/flyout/body\\\"))}}\\n {{yield (hash Footer=(component \\\"hds/flyout/footer\\\" onDismiss=this.onDismiss))}}\\n</dialog>\\n{{#if this.isOpen}}\\n <div class=\\\"hds-flyout__overlay\\\"></div>\\n{{/if}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { getElementId } from '../../../utils/hds-get-element-id';\nimport { buildWaiter } from '@ember/test-waiters';\n\nlet waiter = buildWaiter('@hashicorp/design-system-components:flyout');\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_HAS_OVERLAY = true;\nexport const SIZES = ['medium', 'large'];\n\nexport default class HdsFlyoutIndexComponent extends Component {\n @tracked isOpen = false;\n\n /**\n * Sets the size of the flyout\n * Accepted values: medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size() {\n let { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Flyout\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Calculates the unique ID to assign to the title\n */\n get id() {\n return getElementId(this);\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-flyout'];\n\n // add a class based on the @size argument\n classes.push(`hds-flyout--size-${this.size}`);\n\n return classes.join(' ');\n }\n\n @action registerOnCloseCallback() {\n if (this.args.onClose && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n\n this.isOpen = false;\n }\n\n @action\n didInsert(element) {\n // Store references of `<dialog>` and `<body>` elements\n this.element = element;\n this.body = document.body;\n\n if (this.body) {\n // Store the initial `overflow` value of `<body>` so we can reset to it\n this.bodyInitialOverflowValue =\n this.body.style.getPropertyValue('overflow');\n }\n\n // Register \"onClose\" callback function to be called when a native 'close' event is dispatched\n this.element.addEventListener('close', this.registerOnCloseCallback, true);\n\n // If the flyout dialog is not already open\n if (!this.element.open) {\n this.open();\n }\n }\n\n @action\n willDestroyNode() {\n if (this.element) {\n this.element.removeEventListener(\n 'close',\n this.registerOnCloseCallback,\n true\n );\n }\n }\n\n @action\n open() {\n // Make flyout dialog visible using the native `showModal` method\n this.element.showModal();\n this.isOpen = true;\n\n // Prevent page from scrolling when the dialog is open\n if (this.body) this.body.style.setProperty('overflow', 'hidden');\n\n // Call \"onOpen\" callback function\n if (this.args.onOpen && typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n }\n\n @action\n async onDismiss() {\n // allow ember test helpers to be aware of when the `close` event fires\n // when using `click` or other helpers from '@ember/test-helpers'\n // Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\n if (this.element.open) {\n let token = waiter.beginAsync();\n let listener = () => {\n waiter.endAsync(token);\n this.element.removeEventListener('close', listener);\n };\n this.element.addEventListener('close', listener);\n }\n\n // Make flyout dialog invisible using the native `close` method\n this.element.close();\n\n // Reset page `overflow` property\n if (this.body) {\n this.body.style.removeProperty('overflow');\n if (this.bodyInitialOverflowValue === '') {\n if (this.body.style.length === 0) {\n this.body.removeAttribute('style');\n }\n } else {\n this.body.style.setProperty('overflow', this.bodyInitialOverflowValue);\n }\n }\n }\n}\n"],"names":["waiter","buildWaiter","DEFAULT_SIZE","DEFAULT_HAS_OVERLAY","SIZES","HdsFlyoutIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","size","assert","join","includes","id","getElementId","classNames","classes","push","registerOnCloseCallback","onClose","isOpen","didInsert","element","body","document","bodyInitialOverflowValue","style","getPropertyValue","addEventListener","open","willDestroyNode","removeEventListener","showModal","setProperty","onOpen","onDismiss","token","beginAsync","listener","endAsync","close","removeProperty","length","removeAttribute","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,+xBAA+xB;;;ACWj0B,IAAIA,MAAM,GAAGC,WAAW,CAAC,4CAA4C,CAAC,CAAA;AAE/D,MAAMC,YAAY,GAAG,SAAQ;AAC7B,MAAMC,mBAAmB,GAAG,KAAI;MAC1BC,KAAK,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAC;AAEnBC,IAAAA,uBAAuB,IAAAC,MAAA,GAA7B,MAAMD,uBAAuB,SAASE,SAAS,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,iBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAG7D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;IACT,IAAI;AAA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AA,CAAA0C,SAAA,EAAA1C,WAAAA,CAAAA,EAAAA,MAAA,CAAA0C,SAAA,CAAA,EAAAD,yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAAA,iBAAA,EAAA,CAqBNM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAlD,MAAA,CAAA0C,SAAA,EAAA,iBAAA,CAAA,EAAA1C,MAAA,CAAA0C,SAAA,CAAAD,EAAAA,yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAAA,MAAA,EAAA,CAWNM,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAlD,MAAA,CAAA0C,SAAA,EAAA,MAAA,CAAA,EAAA1C,MAAA,CAAA0C,SAAA,GAAAD,yBAAA,CAAAzC,MAAA,CAAA0C,SAAA,EAeNM,WAAAA,EAAAA,CAAAA,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAlD,MAAA,CAAA0C,SAAA,gBAAA1C,MAAA,CAAA0C,SAAA,CAAA,GAAA1C,MAAA,EAAA;AApGmCmD,oBAAA,CAAAC,QAAA,EAAArD,uBAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/interactive/index.hbs","../../../../src/components/hds/interactive/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}\\n{{! IMPORTANT: we need to add \\\"squishies\\\" here (~) because otherwise the whitespace added by Ember becomes visible in the link (being an inline element) - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}\\n{{! NOTICE: we can\\'t support the direct use of the \\\"href\\\" HTML attribute via ...attributes in the <a> elements, because we need to rely on the \\\"@href\\\" Ember argument to differentiate between different types of generated output }}\\n{{~#if @route~}}\\n {{~#if this.isRouteExternal~}}\\n <LinkToExternal\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n ...attributes\\n >{{yield}}</LinkToExternal>\\n {{~else~}}\\n <LinkTo\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n ...attributes\\n >{{yield}}</LinkTo>\\n {{~/if~}}\\n{{~else if @href~}}\\n {{~#if this.isHrefExternal~}}\\n <a target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\" ...attributes href={{@href}} {{on \\\"keyup\\\" this.onKeyUp}}>{{yield}}</a>\\n {{~else~}}\\n <a ...attributes href={{@href}} {{on \\\"keyup\\\" this.onKeyUp}}>{{yield}}</a>\\n {{~/if~}}\\n{{~else~}}\\n <button type=\\\"button\\\" ...attributes>{{yield}}</button>\\n{{~/if~}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/interactive/index.hbs","../../../../src/components/hds/interactive/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}\\n{{! IMPORTANT: we need to add \\\"squishies\\\" here (~) because otherwise the whitespace added by Ember becomes visible in the link (being an inline element) - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}\\n{{! NOTICE: we can\\'t support the direct use of the \\\"href\\\" HTML attribute via ...attributes in the <a> elements, because we need to rely on the \\\"@href\\\" Ember argument to differentiate between different types of generated output }}\\n{{~#if @route~}}\\n {{~#if this.isRouteExternal~}}\\n <LinkToExternal\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n ...attributes\\n >{{yield}}</LinkToExternal>\\n {{~else~}}\\n <LinkTo\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n ...attributes\\n >{{yield}}</LinkTo>\\n {{~/if~}}\\n{{~else if @href~}}\\n {{~#if this.isHrefExternal~}}\\n <a target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\" ...attributes href={{@href}} {{on \\\"keyup\\\" this.onKeyUp}}>{{yield}}</a>\\n {{~else~}}\\n <a ...attributes href={{@href}} {{on \\\"keyup\\\" this.onKeyUp}}>{{yield}}</a>\\n {{~/if~}}\\n{{~else~}}\\n <button type=\\\"button\\\" ...attributes>{{yield}}</button>\\n{{~/if~}}\")","/**\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 type { HdsInteractiveSignature } from './types';\n\nexport default class HdsInteractiveIndexComponent extends Component<HdsInteractiveSignature> {\n /**\n * Determines if a @href value is \"external\" (it adds target=\"_blank\" rel=\"noopener noreferrer\")\n *\n * @param isHrefExternal\n * @type boolean\n * @default true\n */\n get isHrefExternal() {\n return this.args.isHrefExternal ?? true;\n }\n\n /**\n * Determines if a @route value is \"external\" (uses the LinkToExternal component instead of LinkTo)\n *\n * @param isRouteExternal\n * @type boolean\n * @default false\n */\n get isRouteExternal() {\n return this.args.isRouteExternal ?? false;\n }\n\n @action\n onKeyUp(event: KeyboardEvent) {\n if (event.key === ' ' || event.code === 'Space') {\n (event.target as HTMLElement).click();\n }\n }\n}\n"],"names":["HdsInteractiveIndexComponent","_class","Component","isHrefExternal","args","isRouteExternal","onKeyUp","event","key","code","target","click","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AACA,eAAe,kBAAkB,CAAC,4lDAA4lD;;;ACQzmDA,IAAAA,4BAA4B,IAAAC,MAAA,GAAlC,MAAMD,4BAA4B,SAASE,SAAS,CAA0B;AAC3F;AACF;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,cAAcA,GAAG;AACnB,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,cAAc,IAAI,IAAI,CAAA;AACzC,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,IAAIE,eAAeA,GAAG;AACpB,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,eAAe,IAAI,KAAK,CAAA;AAC3C,GAAA;EAGAC,OAAOA,CAACC,KAAoB,EAAE;IAC5B,IAAIA,KAAK,CAACC,GAAG,KAAK,GAAG,IAAID,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;AAC9CF,MAAAA,KAAK,CAACG,MAAM,CAAiBC,KAAK,EAAE,CAAA;AACvC,KAAA;AACF,GAAA;AACF,CAAC,GAAAC,yBAAA,CAAAX,MAAA,CAAAY,SAAA,EAAA,SAAA,EAAA,CANEC,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAf,MAAA,CAAAY,SAAA,cAAAZ,MAAA,CAAAY,SAAA,CAAA,GAAAZ,MAAA,EAAA;AAvBwCgB,oBAAA,CAAAC,QAAA,EAAAlB,4BAAA,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
|
+
import { HdsLinkIconPositionValues, HdsLinkColorValues } from './types.js';
|
|
3
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
5
|
import { setComponentTemplate } from '@ember/component';
|
|
5
6
|
|
|
6
|
-
var TEMPLATE = precompileTemplate("{{!
|
|
7
|
+
var TEMPLATE = precompileTemplate("{{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}\n{{! IMPORTANT: we need to add \"squishies\" here (~) because otherwise the whitespace added by Ember becomes visible in the link (being an inline element) - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}\n<Hds::Interactive\n class={{this.classNames}}\n @current-when={{@current-when}}\n @models={{hds-link-to-models @model @models}}\n @query={{hds-link-to-query @query}}\n @replace={{@replace}}\n @route={{@route}}\n @isRouteExternal={{@isRouteExternal}}\n @href={{@href}}\n @isHrefExternal={{@isHrefExternal}}\n ...attributes\n>{{#if (and @icon (eq this.iconPosition \"leading\"))~}}\n <span class=\"hds-link-inline__icon hds-link-inline__icon--leading\">\n <FlightIcon @name={{@icon}} @size=\"16\" @stretched={{true}} />\n </span>\n {{~/if~}}{{yield}}{{~#if (and @icon (eq this.iconPosition \"trailing\"))~}}\n <span class=\"hds-link-inline__icon hds-link-inline__icon--trailing\">\n <FlightIcon @name={{@icon}} @size=\"16\" @stretched={{true}} />\n </span>\n {{~/if}}</Hds::Interactive>");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Copyright (c) HashiCorp, Inc.
|
|
10
11
|
* SPDX-License-Identifier: MPL-2.0
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
const DEFAULT_ICONPOSITION =
|
|
14
|
-
const DEFAULT_COLOR =
|
|
15
|
-
const ICONPOSITIONS =
|
|
16
|
-
const COLORS =
|
|
14
|
+
const DEFAULT_ICONPOSITION = HdsLinkIconPositionValues.Trailing;
|
|
15
|
+
const DEFAULT_COLOR = HdsLinkColorValues.Primary;
|
|
16
|
+
const ICONPOSITIONS = Object.values(HdsLinkIconPositionValues);
|
|
17
|
+
const COLORS = Object.values(HdsLinkColorValues);
|
|
17
18
|
class HdsLinkInlineComponent extends Component {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(
|
|
19
|
+
constructor(owner, args) {
|
|
20
|
+
super(owner, args);
|
|
20
21
|
if (!(this.args.href || this.args.route)) {
|
|
21
22
|
assert('@href or @route must be defined for <Hds::Link::Inline>');
|
|
22
23
|
}
|
|
@@ -29,7 +30,7 @@ class HdsLinkInlineComponent extends Component {
|
|
|
29
30
|
* @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
|
|
30
31
|
*/
|
|
31
32
|
get color() {
|
|
32
|
-
|
|
33
|
+
const {
|
|
33
34
|
color = DEFAULT_COLOR
|
|
34
35
|
} = this.args;
|
|
35
36
|
assert(`@color for "Hds::Link::Inline" must be one of the following: ${COLORS.join(', ')}; received: ${color}`, COLORS.includes(color));
|
|
@@ -43,7 +44,7 @@ class HdsLinkInlineComponent extends Component {
|
|
|
43
44
|
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
44
45
|
*/
|
|
45
46
|
get iconPosition() {
|
|
46
|
-
|
|
47
|
+
const {
|
|
47
48
|
iconPosition = DEFAULT_ICONPOSITION
|
|
48
49
|
} = this.args;
|
|
49
50
|
assert(`@iconPosition for "Hds::Link::Inline" must be one of the following: ${ICONPOSITIONS.join(', ')}; received: ${iconPosition}`, ICONPOSITIONS.includes(iconPosition));
|
|
@@ -56,7 +57,7 @@ class HdsLinkInlineComponent extends Component {
|
|
|
56
57
|
* @return {string} The "class" attribute to apply to the component.
|
|
57
58
|
*/
|
|
58
59
|
get classNames() {
|
|
59
|
-
|
|
60
|
+
const classes = ['hds-link-inline'];
|
|
60
61
|
|
|
61
62
|
// add a class based on the @color argument
|
|
62
63
|
classes.push(`hds-link-inline--color-${this.color}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.js","sources":["../../../../src/components/hds/link/inline.hbs","../../../../src/components/hds/link/inline.
|
|
1
|
+
{"version":3,"file":"inline.js","sources":["../../../../src/components/hds/link/inline.hbs","../../../../src/components/hds/link/inline.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{! IMPORTANT: we removed the newlines before/after the yield to reduce the issues with unexpected whitespaces (see https://github.com/hashicorp/design-system/pull/231#issuecomment-1123502499) }}\\n{{! IMPORTANT: we need to add \\\"squishies\\\" here (~) because otherwise the whitespace added by Ember becomes visible in the link (being an inline element) - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}\\n<Hds::Interactive\\n class={{this.classNames}}\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n @isRouteExternal={{@isRouteExternal}}\\n @href={{@href}}\\n @isHrefExternal={{@isHrefExternal}}\\n ...attributes\\n>{{#if (and @icon (eq this.iconPosition \\\"leading\\\"))~}}\\n <span class=\\\"hds-link-inline__icon hds-link-inline__icon--leading\\\">\\n <FlightIcon @name={{@icon}} @size=\\\"16\\\" @stretched={{true}} />\\n </span>\\n {{~/if~}}{{yield}}{{~#if (and @icon (eq this.iconPosition \\\"trailing\\\"))~}}\\n <span class=\\\"hds-link-inline__icon hds-link-inline__icon--trailing\\\">\\n <FlightIcon @name={{@icon}} @size=\\\"16\\\" @stretched={{true}} />\\n </span>\\n {{~/if}}</Hds::Interactive>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport { HdsLinkColorValues, HdsLinkIconPositionValues } from './types.ts';\nimport type { HdsLinkInlineSignature } from './types.ts';\n\nexport const DEFAULT_ICONPOSITION = HdsLinkIconPositionValues.Trailing;\nexport const DEFAULT_COLOR = HdsLinkColorValues.Primary;\nexport const ICONPOSITIONS: string[] = Object.values(HdsLinkIconPositionValues);\nexport const COLORS: string[] = Object.values(HdsLinkColorValues);\n\nexport default class HdsLinkInlineComponent extends Component<HdsLinkInlineSignature> {\n constructor(owner: unknown, args: HdsLinkInlineSignature['Args']) {\n super(owner, args);\n if (!(this.args.href || this.args.route)) {\n assert('@href or @route must be defined for <Hds::Link::Inline>');\n }\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color() {\n const { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Link::Inline\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * @param iconPosition\n * @type {string}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition() {\n const { iconPosition = DEFAULT_ICONPOSITION } = this.args;\n\n assert(\n `@iconPosition for \"Hds::Link::Inline\" must be one of the following: ${ICONPOSITIONS.join(\n ', '\n )}; received: ${iconPosition}`,\n ICONPOSITIONS.includes(iconPosition)\n );\n\n return iconPosition;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method LinkInline#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames() {\n const classes = ['hds-link-inline'];\n\n // add a class based on the @color argument\n classes.push(`hds-link-inline--color-${this.color}`);\n\n // add a class based on the @iconPosition argument\n classes.push(`hds-link-inline--icon-${this.iconPosition}`);\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_ICONPOSITION","HdsLinkIconPositionValues","Trailing","DEFAULT_COLOR","HdsLinkColorValues","Primary","ICONPOSITIONS","Object","values","COLORS","HdsLinkInlineComponent","Component","constructor","owner","args","href","route","assert","color","join","includes","iconPosition","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AACA,eAAe,kBAAkB,CAAC,iuCAAiuC;;ACDnwC;AACA;AACA;AACA;;AAOaA,MAAAA,oBAAoB,GAAGC,yBAAyB,CAACC,SAAQ;AACzDC,MAAAA,aAAa,GAAGC,kBAAkB,CAACC,QAAO;AAChD,MAAMC,aAAuB,GAAGC,MAAM,CAACC,MAAM,CAACP,yBAAyB,EAAC;AACxE,MAAMQ,MAAgB,GAAGF,MAAM,CAACC,MAAM,CAAC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CAACN,KAAM,EAAC,CAAC,CAAA;;AAEpD;IACAK,OAAO,CAACC,IAAI,CAAE,CAAA,sBAAA,EAAwB,IAAI,CAACH,YAAa,EAAC,CAAC,CAAA;AAE1D,IAAA,OAAOE,OAAO,CAACJ,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAA;AAACM,oBAAA,CAAAC,QAAA,EA9DoBhB,sBAAsB,CAAA;;;;"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
|
+
import { HdsLinkIconPositionValues, HdsLinkColorValues, HdsLinkStandaloneSizeValues } from './types.js';
|
|
3
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
5
|
import { setComponentTemplate } from '@ember/component';
|
|
5
6
|
|
|
6
|
-
var TEMPLATE = precompileTemplate("
|
|
7
|
+
var TEMPLATE = precompileTemplate("<Hds::Interactive\n class={{this.classNames}}\n @current-when={{@current-when}}\n @models={{hds-link-to-models @model @models}}\n @query={{hds-link-to-query @query}}\n @replace={{@replace}}\n @route={{@route}}\n @isRouteExternal={{@isRouteExternal}}\n @href={{@href}}\n @isHrefExternal={{@isHrefExternal}}\n ...attributes\n>\n {{#if (eq this.iconPosition \"leading\")}}\n <span class=\"hds-link-standalone__icon\">\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\n </span>\n <span class=\"hds-link-standalone__text\">\n {{this.text}}\n </span>\n {{else}}\n <span class=\"hds-link-standalone__text\">\n {{this.text}}\n </span>\n <span class=\"hds-link-standalone__icon\">\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\n </span>\n {{/if}}\n</Hds::Interactive>");
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Copyright (c) HashiCorp, Inc.
|
|
10
11
|
* SPDX-License-Identifier: MPL-2.0
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
const DEFAULT_ICONPOSITION =
|
|
14
|
-
const DEFAULT_COLOR =
|
|
15
|
-
const DEFAULT_SIZE =
|
|
16
|
-
const ICONPOSITIONS =
|
|
17
|
-
const COLORS =
|
|
18
|
-
const SIZES =
|
|
14
|
+
const DEFAULT_ICONPOSITION = HdsLinkIconPositionValues.Leading;
|
|
15
|
+
const DEFAULT_COLOR = HdsLinkColorValues.Primary;
|
|
16
|
+
const DEFAULT_SIZE = HdsLinkStandaloneSizeValues.Medium;
|
|
17
|
+
const ICONPOSITIONS = Object.values(HdsLinkIconPositionValues);
|
|
18
|
+
const COLORS = Object.values(HdsLinkColorValues);
|
|
19
|
+
const SIZES = Object.values(HdsLinkStandaloneSizeValues);
|
|
19
20
|
class HdsLinkStandaloneComponent extends Component {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(
|
|
21
|
+
constructor(owner, args) {
|
|
22
|
+
super(owner, args);
|
|
22
23
|
if (!(this.args.href || this.args.route)) {
|
|
23
24
|
assert('@href or @route must be defined for <Hds::Link::Standalone>');
|
|
24
25
|
}
|
|
@@ -30,7 +31,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
30
31
|
* @description The text of the link. If no text value is defined an error will be thrown.
|
|
31
32
|
*/
|
|
32
33
|
get text() {
|
|
33
|
-
|
|
34
|
+
const {
|
|
34
35
|
text
|
|
35
36
|
} = this.args;
|
|
36
37
|
assert('@text for "Hds::Link::Standalone" must have a valid value', text !== undefined);
|
|
@@ -44,7 +45,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
44
45
|
* @description Determines the color of link to be used; acceptable values are `primary` and `secondary`
|
|
45
46
|
*/
|
|
46
47
|
get color() {
|
|
47
|
-
|
|
48
|
+
const {
|
|
48
49
|
color = DEFAULT_COLOR
|
|
49
50
|
} = this.args;
|
|
50
51
|
assert(`@color for "Hds::Link::Standalone" must be one of the following: ${COLORS.join(', ')}; received: ${color}`, COLORS.includes(color));
|
|
@@ -58,7 +59,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
58
59
|
* @description The name of the icon to be used. An icon name must be defined.
|
|
59
60
|
*/
|
|
60
61
|
get icon() {
|
|
61
|
-
|
|
62
|
+
const {
|
|
62
63
|
icon
|
|
63
64
|
} = this.args;
|
|
64
65
|
assert('@icon for "Hds::Link::Standalone" must have a valid value', icon !== undefined);
|
|
@@ -72,7 +73,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
72
73
|
* @description Positions the icon before or after the text; allowed values are `leading` or `trailing`
|
|
73
74
|
*/
|
|
74
75
|
get iconPosition() {
|
|
75
|
-
|
|
76
|
+
const {
|
|
76
77
|
iconPosition = DEFAULT_ICONPOSITION
|
|
77
78
|
} = this.args;
|
|
78
79
|
assert(`@iconPosition for "Hds::Link::Standalone" must be one of the following: ${ICONPOSITIONS.join(', ')}; received: ${iconPosition}`, ICONPOSITIONS.includes(iconPosition));
|
|
@@ -86,7 +87,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
86
87
|
* @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`
|
|
87
88
|
*/
|
|
88
89
|
get size() {
|
|
89
|
-
|
|
90
|
+
const {
|
|
90
91
|
size = DEFAULT_SIZE
|
|
91
92
|
} = this.args;
|
|
92
93
|
assert(`@size for "Hds::Link::Standalone" must be one of the following: ${SIZES.join(', ')}; received: ${size}`, SIZES.includes(size));
|
|
@@ -113,7 +114,7 @@ class HdsLinkStandaloneComponent extends Component {
|
|
|
113
114
|
* @return {string} The "class" attribute to apply to the component.
|
|
114
115
|
*/
|
|
115
116
|
get classNames() {
|
|
116
|
-
|
|
117
|
+
const classes = ['hds-link-standalone'];
|
|
117
118
|
|
|
118
119
|
// add a class based on the @size argument
|
|
119
120
|
classes.push(`hds-link-standalone--size-${this.size}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.js","sources":["../../../../src/components/hds/link/standalone.hbs","../../../../src/components/hds/link/standalone.
|
|
1
|
+
{"version":3,"file":"standalone.js","sources":["../../../../src/components/hds/link/standalone.hbs","../../../../src/components/hds/link/standalone.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"<Hds::Interactive\\n class={{this.classNames}}\\n @current-when={{@current-when}}\\n @models={{hds-link-to-models @model @models}}\\n @query={{hds-link-to-query @query}}\\n @replace={{@replace}}\\n @route={{@route}}\\n @isRouteExternal={{@isRouteExternal}}\\n @href={{@href}}\\n @isHrefExternal={{@isHrefExternal}}\\n ...attributes\\n>\\n {{#if (eq this.iconPosition \\\"leading\\\")}}\\n <span class=\\\"hds-link-standalone__icon\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </span>\\n <span class=\\\"hds-link-standalone__text\\\">\\n {{this.text}}\\n </span>\\n {{else}}\\n <span class=\\\"hds-link-standalone__text\\\">\\n {{this.text}}\\n </span>\\n <span class=\\\"hds-link-standalone__icon\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </span>\\n {{/if}}\\n</Hds::Interactive>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { assert } from '@ember/debug';\nimport {\n HdsLinkIconPositionValues,\n HdsLinkColorValues,\n HdsLinkStandaloneSizeValues,\n} from './types.ts';\nimport type { HdsLinkStandaloneSignature } from './types.ts';\n\nexport const DEFAULT_ICONPOSITION = HdsLinkIconPositionValues.Leading;\nexport const DEFAULT_COLOR = HdsLinkColorValues.Primary;\nexport const DEFAULT_SIZE = HdsLinkStandaloneSizeValues.Medium;\nexport const ICONPOSITIONS: string[] = Object.values(HdsLinkIconPositionValues);\nexport const COLORS: string[] = Object.values(HdsLinkColorValues);\nexport const SIZES: string[] = Object.values(HdsLinkStandaloneSizeValues);\n\nexport default class HdsLinkStandaloneComponent extends Component<HdsLinkStandaloneSignature> {\n constructor(owner: unknown, args: HdsLinkStandaloneSignature['Args']) {\n super(owner, args);\n if (!(this.args.href || this.args.route)) {\n assert('@href or @route must be defined for <Hds::Link::Standalone>');\n }\n }\n\n /**\n * @param text\n * @type {string}\n * @description The text of the link. If no text value is defined an error will be thrown.\n */\n get text() {\n const { text } = this.args;\n\n assert(\n '@text for \"Hds::Link::Standalone\" must have a valid value',\n text !== undefined\n );\n\n return text;\n }\n\n /**\n * @param color\n * @type {string}\n * @default primary\n * @description Determines the color of link to be used; acceptable values are `primary` and `secondary`\n */\n get color() {\n const { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Link::Standalone\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * @param icon\n * @type {string|null}\n * @default null\n * @description The name of the icon to be used. An icon name must be defined.\n */\n get icon() {\n const { icon } = this.args;\n\n assert(\n '@icon for \"Hds::Link::Standalone\" must have a valid value',\n icon !== undefined\n );\n\n return icon;\n }\n\n /**\n * @param iconPosition\n * @type {string}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition() {\n const { iconPosition = DEFAULT_ICONPOSITION } = this.args;\n\n assert(\n `@iconPosition for \"Hds::Link::Standalone\" must be one of the following: ${ICONPOSITIONS.join(\n ', '\n )}; received: ${iconPosition}`,\n ICONPOSITIONS.includes(iconPosition)\n );\n\n return iconPosition;\n }\n\n /**\n * @param size\n * @type {string}\n * @default medium\n * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`\n */\n get size() {\n const { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Link::Standalone\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * @param iconSize\n * @type {string}\n * @default 16\n * @description ensures that the correct icon size is used. Automatically calculated.\n */\n get iconSize() {\n if (this.args.size === 'large') {\n return '24';\n } else {\n return '16';\n }\n }\n\n /**\n * Get the class names to apply to the component.\n * @method LinkStandalone#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n get classNames() {\n const classes = ['hds-link-standalone'];\n\n // add a class based on the @size argument\n classes.push(`hds-link-standalone--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-link-standalone--color-${this.color}`);\n\n // add a class based on the @iconPosition argument\n classes.push(`hds-link-standalone--icon-position-${this.iconPosition}`);\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_ICONPOSITION","HdsLinkIconPositionValues","Leading","DEFAULT_COLOR","HdsLinkColorValues","Primary","DEFAULT_SIZE","HdsLinkStandaloneSizeValues","Medium","ICONPOSITIONS","Object","values","COLORS","SIZES","HdsLinkStandaloneComponent","Component","constructor","owner","args","href","route","assert","text","undefined","color","join","includes","icon","iconPosition","size","iconSize","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AACA,eAAe,kBAAkB,CAAC,o3BAAo3B;;ACDt5B;AACA;AACA;AACA;;AAWaA,MAAAA,oBAAoB,GAAGC,yBAAyB,CAACC,QAAO;AACxDC,MAAAA,aAAa,GAAGC,kBAAkB,CAACC,QAAO;AAC1CC,MAAAA,YAAY,GAAGC,2BAA2B,CAACC,OAAM;AACvD,MAAMC,aAAuB,GAAGC,MAAM,CAACC,MAAM,CAACV,yBAAyB,EAAC;AACxE,MAAMW,MAAgB,GAAGF,MAAM,CAACC,MAAM,CAACP,kBAAkB,EAAC;AAC1D,MAAMS,KAAe,GAAGH,MAAM,CAACC,MAAM,CAACJ,2BAA2B,EAAC;AAE1D,MAAMO,0BAA0B,SAASC,SAAS,CAA6B;AAC5FC,EAAAA,WAAWA,CAACC,KAAc,EAAEC,IAAwC,EAAE;AACpE,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC,CAAA;AAClB,IAAA,IAAI,EAAE,IAAI,CAACA,IAAI,CAACC,IAAI,IAAI,IAAI,CAACD,IAAI,CAACE,KAAK,CAAC,EAAE;MACxCC,MAAM,CAAC,6DAA6D,CAAC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
+
HdsLinkIconPositionValues["Leading"] = "leading";
|
|
3
|
+
HdsLinkIconPositionValues["Trailing"] = "trailing";
|
|
4
|
+
return HdsLinkIconPositionValues;
|
|
5
|
+
}({});
|
|
6
|
+
let HdsLinkColorValues = /*#__PURE__*/function (HdsLinkColorValues) {
|
|
7
|
+
HdsLinkColorValues["Primary"] = "primary";
|
|
8
|
+
HdsLinkColorValues["Secondary"] = "secondary";
|
|
9
|
+
return HdsLinkColorValues;
|
|
10
|
+
}({});
|
|
11
|
+
let HdsLinkStandaloneSizeValues = /*#__PURE__*/function (HdsLinkStandaloneSizeValues) {
|
|
12
|
+
HdsLinkStandaloneSizeValues["Small"] = "small";
|
|
13
|
+
HdsLinkStandaloneSizeValues["Medium"] = "medium";
|
|
14
|
+
HdsLinkStandaloneSizeValues["Large"] = "large";
|
|
15
|
+
return HdsLinkStandaloneSizeValues;
|
|
16
|
+
}({});
|
|
17
|
+
|
|
18
|
+
export { HdsLinkColorValues, HdsLinkIconPositionValues, HdsLinkStandaloneSizeValues };
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/components/hds/link/types.ts"],"sourcesContent":["import type { HdsInteractiveSignature } from '../interactive/types.ts';\n\nexport enum HdsLinkIconPositionValues {\n Leading = 'leading',\n Trailing = 'trailing',\n}\n\nexport type HdsLinkIconPositions = `${HdsLinkIconPositionValues}`;\n\nexport enum HdsLinkColorValues {\n Primary = 'primary',\n Secondary = 'secondary',\n}\n\nexport type HdsLinkColors = `${HdsLinkColorValues}`;\n\nexport enum HdsLinkStandaloneSizeValues {\n Small = 'small',\n Medium = 'medium',\n Large = 'large',\n}\n\nexport type HdsLinkStandaloneSizes = `${HdsLinkStandaloneSizeValues}`;\n\nexport interface HdsLinkStandaloneSignature {\n Args: HdsInteractiveSignature['Args'] & {\n icon: string;\n text: string;\n color?: HdsLinkColors;\n href?: string;\n iconPosition?: HdsLinkIconPositions;\n isHrefExternal?: boolean;\n isRouteExternal?: boolean;\n size?: HdsLinkStandaloneSizes;\n };\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport interface HdsLinkInlineSignature {\n Args: HdsInteractiveSignature['Args'] & {\n color?: HdsLinkColors;\n href?: string;\n icon?: string;\n iconPosition?: HdsLinkIconPositions;\n isHrefExternal?: boolean;\n isRouteExternal?: boolean;\n };\n Blocks: {\n default: [];\n };\n Element: HdsInteractiveSignature['Element'];\n}\n"],"names":["HdsLinkIconPositionValues","HdsLinkColorValues","HdsLinkStandaloneSizeValues"],"mappings":"AAEYA,IAAAA,yBAAyB,0BAAzBA,yBAAyB,EAAA;EAAzBA,yBAAyB,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAzBA,yBAAyB,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;AAAA,EAAA,OAAzBA,yBAAyB,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAOzBC,IAAAA,kBAAkB,0BAAlBA,kBAAkB,EAAA;EAAlBA,kBAAkB,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAlBA,kBAAkB,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;AAAA,EAAA,OAAlBA,kBAAkB,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAOlBC,IAAAA,2BAA2B,0BAA3BA,2BAA2B,EAAA;EAA3BA,2BAA2B,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;EAA3BA,2BAA2B,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;EAA3BA,2BAA2B,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;AAAA,EAAA,OAA3BA,2BAA2B,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
@@ -5,19 +5,13 @@ import { action } from '@ember/object';
|
|
|
5
5
|
import { assert } from '@ember/debug';
|
|
6
6
|
import { getElementId } from '../../../utils/hds-get-element-id.js';
|
|
7
7
|
import { buildWaiter } from '@ember/test-waiters';
|
|
8
|
-
import { DEBUG } from '@glimmer/env';
|
|
9
8
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
9
|
import { setComponentTemplate } from '@ember/component';
|
|
11
10
|
|
|
12
11
|
var TEMPLATE = precompileTemplate("{{! @glint-nocheck: not typesafe yet }}\n{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<dialog\n class={{this.classNames}}\n ...attributes\n aria-labelledby={{this.id}}\n {{did-insert this.didInsert}}\n {{will-destroy this.willDestroyNode}}\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\n>\n {{yield (hash Header=(component \"hds/modal/header\" id=this.id onDismiss=this.onDismiss))}}\n {{yield (hash Body=(component \"hds/modal/body\"))}}\n {{yield (hash Footer=(component \"hds/modal/footer\" onDismiss=this.onDismiss))}}\n</dialog>\n{{#if this.isOpen}}\n <div class=\"hds-modal__overlay\"></div>\n{{/if}}");
|
|
13
12
|
|
|
14
13
|
var _class, _descriptor, _descriptor2;
|
|
15
|
-
let waiter;
|
|
16
|
-
|
|
17
|
-
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
18
|
-
if (DEBUG) {
|
|
19
|
-
waiter = buildWaiter('@hashicorp/design-system-components:modal');
|
|
20
|
-
}
|
|
14
|
+
let waiter = buildWaiter('@hashicorp/design-system-components:modal');
|
|
21
15
|
const DEFAULT_SIZE = 'medium';
|
|
22
16
|
const DEFAULT_COLOR = 'neutral';
|
|
23
17
|
const SIZES = ['small', 'medium', 'large'];
|
|
@@ -139,7 +133,7 @@ let HdsModalIndexComponent = (_class = class HdsModalIndexComponent extends Comp
|
|
|
139
133
|
// allow ember test helpers to be aware of when the `close` event fires
|
|
140
134
|
// when using `click` or other helpers from '@ember/test-helpers'
|
|
141
135
|
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
142
|
-
if (
|
|
136
|
+
if (this.element.open) {
|
|
143
137
|
let token = waiter.beginAsync();
|
|
144
138
|
let listener = () => {
|
|
145
139
|
waiter.endAsync(token);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/modal/index.hbs","../../../../src/components/hds/modal/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<dialog\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n {{yield (hash Header=(component \\\"hds/modal/header\\\" id=this.id onDismiss=this.onDismiss))}}\\n {{yield (hash Body=(component \\\"hds/modal/body\\\"))}}\\n {{yield (hash Footer=(component \\\"hds/modal/footer\\\" onDismiss=this.onDismiss))}}\\n</dialog>\\n{{#if this.isOpen}}\\n <div class=\\\"hds-modal__overlay\\\"></div>\\n{{/if}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { getElementId } from '../../../utils/hds-get-element-id';\nimport { buildWaiter } from '@ember/test-waiters';\nimport { DEBUG } from '@glimmer/env';\n\nlet waiter;\n\n// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\nif (DEBUG) {\n waiter = buildWaiter('@hashicorp/design-system-components:modal');\n}\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_COLOR = 'neutral';\nexport const SIZES = ['small', 'medium', 'large'];\nexport const COLORS = ['neutral', 'warning', 'critical'];\n\nexport default class HdsModalIndexComponent extends Component {\n @tracked isOpen = false;\n @tracked isDismissDisabled = this.args.isDismissDisabled ?? false;\n\n /**\n * Sets the size of the modal dialog\n * Accepted values: small, medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size() {\n let { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Modal\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Sets the color of the modal dialog\n * Accepted values: neutral, warning, critical\n *\n * @param color\n * @type {string}\n * @default 'neutral'\n */\n get color() {\n let { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Modal\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * Calculates the unique ID to assign to the title\n */\n get id() {\n return getElementId(this);\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-modal'];\n\n // add a class based on the @size argument\n classes.push(`hds-modal--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-modal--color-${this.color}`);\n\n return classes.join(' ');\n }\n\n @action registerOnCloseCallback() {\n if (\n !this.isDismissDisabled &&\n this.args.onClose &&\n typeof this.args.onClose === 'function'\n ) {\n this.args.onClose();\n }\n\n // If the dismissal of the modal is disabled, we keep the modal open/visible otherwise we mark it as closed\n if (this.isDismissDisabled) {\n // If, in a chain of events, the element is not attached to the DOM, the `showModal` would fail\n // so we add this safeguard condition that checks for the `<dialog>` to have a parent\n if (this.element.parentElement) {\n // As there is no way to `preventDefault` on `close` events, we call the `showModal` function\n // preserving the state of the modal dialog\n this.element.showModal();\n }\n } else {\n this.isOpen = false;\n }\n }\n\n @action\n didInsert(element) {\n // Store references of `<dialog>` and `<body>` elements\n this.element = element;\n this.body = document.body;\n\n if (this.body) {\n // Store the initial `overflow` value of `<body>` so we can reset to it\n this.bodyInitialOverflowValue =\n this.body.style.getPropertyValue('overflow');\n }\n\n // Register \"onClose\" callback function to be called when a native 'close' event is dispatched\n this.element.addEventListener('close', this.registerOnCloseCallback, true);\n\n // If the modal dialog is not already open\n if (!this.element.open) {\n this.open();\n }\n }\n\n @action\n willDestroyNode() {\n if (this.element) {\n this.element.removeEventListener(\n 'close',\n this.registerOnCloseCallback,\n true\n );\n }\n }\n\n @action\n open() {\n // Make modal dialog visible using the native `showModal` method\n this.element.showModal();\n this.isOpen = true;\n\n // Prevent page from scrolling when the dialog is open\n if (this.body) this.body.style.setProperty('overflow', 'hidden');\n\n // Call \"onOpen\" callback function\n if (this.args.onOpen && typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n }\n\n @action\n async onDismiss() {\n // allow ember test helpers to be aware of when the `close` event fires\n // when using `click` or other helpers from '@ember/test-helpers'\n // Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\n if (DEBUG && this.element.open) {\n let token = waiter.beginAsync();\n let listener = () => {\n waiter.endAsync(token);\n this.element.removeEventListener('close', listener);\n };\n this.element.addEventListener('close', listener);\n }\n\n // Make modal dialog invisible using the native `close` method\n this.element.close();\n\n // Reset page `overflow` property\n if (this.body) {\n this.body.style.removeProperty('overflow');\n if (this.bodyInitialOverflowValue === '') {\n if (this.body.style.length === 0) {\n this.body.removeAttribute('style');\n }\n } else {\n this.body.style.setProperty('overflow', this.bodyInitialOverflowValue);\n }\n }\n }\n}\n"],"names":["waiter","DEBUG","buildWaiter","DEFAULT_SIZE","DEFAULT_COLOR","SIZES","COLORS","HdsModalIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","size","assert","join","includes","color","id","getElementId","classNames","classes","push","registerOnCloseCallback","isDismissDisabled","onClose","element","parentElement","showModal","isOpen","didInsert","body","document","bodyInitialOverflowValue","style","getPropertyValue","addEventListener","open","willDestroyNode","removeEventListener","setProperty","onOpen","onDismiss","token","beginAsync","listener","endAsync","close","removeProperty","length","removeAttribute","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,otBAAotB;;;ACYtvB,IAAIA,MAAM,CAAA;;AAEV;AACA,IAAIC,KAAK,EAAE;AACTD,EAAAA,MAAM,GAAGE,WAAW,CAAC,2CAA2C,CAAC,CAAA;AACnE,CAAA;AAEO,MAAMC,YAAY,GAAG,SAAQ;AAC7B,MAAMC,aAAa,GAAG,UAAS;AAC/B,MAAMC,KAAK,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAC;AAC1C,MAAMC,MAAM,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC;AAEnCC,IAAAA,sBAAsB,IAAAC,MAAA,GAA5B,MAAMD,sBAAsB,SAASE,SAAS,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,iBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAAAD,IAAAA,0BAAA,4BAAAE,YAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAI5D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;IACT,IAAI;AAAEA,MAAAA,IAAI,GAAGZ,YAAAA;KAAc,GAAG,IAAI,CAACQ,IAAI,CAAA;AAEvCK,IAAAA,MAAM,CACH,CAAuDX,qDAAAA,EAAAA,KAAK,CAACY,IAAI,CAChE,IACF,CAAE,CAAA,YAAA,EAAcF,IAAK,CAAA,CAAC,EACtBV,KAAK,CAACa,QAAQ,CAACH,IAAI,CACrB,CAAC,CAAA;AAED,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;;AAEA;AACF;A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EAAAA,CAAAA,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAtD,MAAA,CAAA8C,SAAA,gBAAA9C,MAAA,CAAA8C,SAAA,CAAA,GAAA9C,MAAA,EAAA;AA5IkCuD,oBAAA,CAAAC,QAAA,EAAAzD,sBAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/modal/index.hbs","../../../../src/components/hds/modal/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<dialog\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n {{yield (hash Header=(component \\\"hds/modal/header\\\" id=this.id onDismiss=this.onDismiss))}}\\n {{yield (hash Body=(component \\\"hds/modal/body\\\"))}}\\n {{yield (hash Footer=(component \\\"hds/modal/footer\\\" onDismiss=this.onDismiss))}}\\n</dialog>\\n{{#if this.isOpen}}\\n <div class=\\\"hds-modal__overlay\\\"></div>\\n{{/if}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { getElementId } from '../../../utils/hds-get-element-id';\nimport { buildWaiter } from '@ember/test-waiters';\n\nlet waiter = buildWaiter('@hashicorp/design-system-components:modal');\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_COLOR = 'neutral';\nexport const SIZES = ['small', 'medium', 'large'];\nexport const COLORS = ['neutral', 'warning', 'critical'];\n\nexport default class HdsModalIndexComponent extends Component {\n @tracked isOpen = false;\n @tracked isDismissDisabled = this.args.isDismissDisabled ?? false;\n\n /**\n * Sets the size of the modal dialog\n * Accepted values: small, medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size() {\n let { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::Modal\" must be one of the following: ${SIZES.join(\n ', '\n )}; received: ${size}`,\n SIZES.includes(size)\n );\n\n return size;\n }\n\n /**\n * Sets the color of the modal dialog\n * Accepted values: neutral, warning, critical\n *\n * @param color\n * @type {string}\n * @default 'neutral'\n */\n get color() {\n let { color = DEFAULT_COLOR } = this.args;\n\n assert(\n `@color for \"Hds::Modal\" must be one of the following: ${COLORS.join(\n ', '\n )}; received: ${color}`,\n COLORS.includes(color)\n );\n\n return color;\n }\n\n /**\n * Calculates the unique ID to assign to the title\n */\n get id() {\n return getElementId(this);\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-modal'];\n\n // add a class based on the @size argument\n classes.push(`hds-modal--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-modal--color-${this.color}`);\n\n return classes.join(' ');\n }\n\n @action registerOnCloseCallback() {\n if (\n !this.isDismissDisabled &&\n this.args.onClose &&\n typeof this.args.onClose === 'function'\n ) {\n this.args.onClose();\n }\n\n // If the dismissal of the modal is disabled, we keep the modal open/visible otherwise we mark it as closed\n if (this.isDismissDisabled) {\n // If, in a chain of events, the element is not attached to the DOM, the `showModal` would fail\n // so we add this safeguard condition that checks for the `<dialog>` to have a parent\n if (this.element.parentElement) {\n // As there is no way to `preventDefault` on `close` events, we call the `showModal` function\n // preserving the state of the modal dialog\n this.element.showModal();\n }\n } else {\n this.isOpen = false;\n }\n }\n\n @action\n didInsert(element) {\n // Store references of `<dialog>` and `<body>` elements\n this.element = element;\n this.body = document.body;\n\n if (this.body) {\n // Store the initial `overflow` value of `<body>` so we can reset to it\n this.bodyInitialOverflowValue =\n this.body.style.getPropertyValue('overflow');\n }\n\n // Register \"onClose\" callback function to be called when a native 'close' event is dispatched\n this.element.addEventListener('close', this.registerOnCloseCallback, true);\n\n // If the modal dialog is not already open\n if (!this.element.open) {\n this.open();\n }\n }\n\n @action\n willDestroyNode() {\n if (this.element) {\n this.element.removeEventListener(\n 'close',\n this.registerOnCloseCallback,\n true\n );\n }\n }\n\n @action\n open() {\n // Make modal dialog visible using the native `showModal` method\n this.element.showModal();\n this.isOpen = true;\n\n // Prevent page from scrolling when the dialog is open\n if (this.body) this.body.style.setProperty('overflow', 'hidden');\n\n // Call \"onOpen\" callback function\n if (this.args.onOpen && typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n }\n\n @action\n async onDismiss() {\n // allow ember test helpers to be aware of when the `close` event fires\n // when using `click` or other helpers from '@ember/test-helpers'\n // Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)\n if (this.element.open) {\n let token = waiter.beginAsync();\n let listener = () => {\n waiter.endAsync(token);\n this.element.removeEventListener('close', listener);\n };\n this.element.addEventListener('close', listener);\n }\n\n // Make modal dialog invisible using the native `close` method\n this.element.close();\n\n // Reset page `overflow` property\n if (this.body) {\n this.body.style.removeProperty('overflow');\n if (this.bodyInitialOverflowValue === '') {\n if (this.body.style.length === 0) {\n this.body.removeAttribute('style');\n }\n } else {\n this.body.style.setProperty('overflow', this.bodyInitialOverflowValue);\n }\n }\n }\n}\n"],"names":["waiter","buildWaiter","DEFAULT_SIZE","DEFAULT_COLOR","SIZES","COLORS","HdsModalIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","size","assert","join","includes","color","id","getElementId","classNames","classes","push","registerOnCloseCallback","isDismissDisabled","onClose","element","parentElement","showModal","isOpen","didInsert","body","document","bodyInitialOverflowValue","style","getPropertyValue","addEventListener","open","willDestroyNode","removeEventListener","setProperty","onOpen","onDismiss","token","beginAsync","listener","endAsync","close","removeProperty","length","removeAttribute","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,otBAAotB;;;ACWtvB,IAAIA,MAAM,GAAGC,WAAW,CAAC,2CAA2C,CAAC,CAAA;AAE9D,MAAMC,YAAY,GAAG,SAAQ;AAC7B,MAAMC,aAAa,GAAG,UAAS;AAC/B,MAAMC,KAAK,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAC;AAC1C,MAAMC,MAAM,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC;AAEnCC,IAAAA,sBAAsB,IAAAC,MAAA,GAA5B,MAAMD,sBAAsB,SAASE,SAAS,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,iBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAAAD,IAAAA,0BAAA,4BAAAE,YAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;AAI5D;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;IACT,IAAI;AAAEA,MAAAA,IAAI,GAAGZ,YAAAA;KAAc,GAAG,IAAI,CAACQ,IAAI,CAAA;AAEvCK,IAAAA,MAAM,CACH,CAAuDX,qDAAAA,EAAAA,KAAK,CAACY,IAAI,CAChE,IACF,CAAE,CAAA,YAAA,EAAcF,IAAK,CAAA,CAAC,EACtBV,KAAK,CAACa,QAAQ,CAACH,IAAI,CACrB,CAAC,CAAA;AAED,IAAA,OAAOA,IAAI,CAAA;AACb,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAII,KAAKA,GAAG;IACV,IAAI;AAAEA,MAAAA,KAAK,GAAGf,aAAAA;KAAe,GAAG,IAAI,CAACO,IAA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AA5IkCuD,oBAAA,CAAAC,QAAA,EAAAzD,sBAAA,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { assert } from '@ember/debug';
|
|
3
|
+
import { HdsTextSizeValues, HdsTextWeightValues } from './types.js';
|
|
3
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
5
|
import { setComponentTemplate } from '@ember/component';
|
|
5
6
|
|
|
@@ -10,13 +11,13 @@ var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-
|
|
|
10
11
|
* SPDX-License-Identifier: MPL-2.0
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const DEFAULT_WEIGHT =
|
|
14
|
+
const AVAILABLE_SIZES = [HdsTextSizeValues.ThreeHundred, HdsTextSizeValues.TwoHundred, HdsTextSizeValues.OneHundred];
|
|
15
|
+
const DEFAULT_SIZE = HdsTextSizeValues.TwoHundred;
|
|
16
|
+
const DEFAULT_WEIGHT = HdsTextWeightValues.Regular;
|
|
16
17
|
const AVAILABLE_WEIGHTS_PER_SIZE = {
|
|
17
|
-
300: [
|
|
18
|
-
200: [
|
|
19
|
-
100: [
|
|
18
|
+
300: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold],
|
|
19
|
+
200: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold],
|
|
20
|
+
100: [HdsTextWeightValues.Regular, HdsTextWeightValues.Medium, HdsTextWeightValues.Semibold]
|
|
20
21
|
};
|
|
21
22
|
class HdsTextBodyComponent extends Component {
|
|
22
23
|
/**
|
|
@@ -49,7 +50,7 @@ class HdsTextBodyComponent extends Component {
|
|
|
49
50
|
* @param variant
|
|
50
51
|
*/
|
|
51
52
|
get weight() {
|
|
52
|
-
|
|
53
|
+
const {
|
|
53
54
|
weight = DEFAULT_WEIGHT
|
|
54
55
|
} = this.args;
|
|
55
56
|
const availableWeights = AVAILABLE_WEIGHTS_PER_SIZE[this.size];
|