@hashicorp/design-system-components 4.7.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.
- package/declarations/components/hds/alert/index.d.ts +1 -1
- package/declarations/components/hds/alert/index.d.ts.map +1 -1
- package/declarations/components/hds/app-header/home-link.d.ts +19 -0
- package/declarations/components/hds/app-header/home-link.d.ts.map +1 -0
- package/declarations/components/hds/app-header/index.d.ts +32 -0
- package/declarations/components/hds/app-header/index.d.ts.map +1 -0
- package/declarations/components/hds/app-header/menu-button.d.ts +19 -0
- package/declarations/components/hds/app-header/menu-button.d.ts.map +1 -0
- package/declarations/components/hds/application-state/footer.d.ts +7 -17
- package/declarations/components/hds/application-state/footer.d.ts.map +1 -1
- package/declarations/components/hds/application-state/header.d.ts +6 -3
- package/declarations/components/hds/application-state/header.d.ts.map +1 -1
- package/declarations/components/hds/application-state/index.d.ts +12 -3
- package/declarations/components/hds/application-state/index.d.ts.map +1 -1
- package/declarations/components/hds/application-state/media.d.ts +14 -0
- package/declarations/components/hds/application-state/media.d.ts.map +1 -0
- package/declarations/components/hds/application-state/types.d.ts +10 -0
- package/declarations/components/hds/application-state/types.d.ts.map +1 -0
- package/declarations/components/hds/badge-count/index.d.ts +1 -2
- package/declarations/components/hds/badge-count/index.d.ts.map +1 -1
- package/declarations/components/hds/breadcrumb/index.d.ts +18 -4
- package/declarations/components/hds/breadcrumb/index.d.ts.map +1 -1
- package/declarations/components/hds/breadcrumb/item.d.ts +26 -5
- package/declarations/components/hds/breadcrumb/item.d.ts.map +1 -1
- package/declarations/components/hds/breadcrumb/truncation.d.ts +15 -3
- package/declarations/components/hds/breadcrumb/truncation.d.ts.map +1 -1
- package/declarations/components/hds/code-block/copy-button.d.ts +17 -1
- package/declarations/components/hds/code-block/copy-button.d.ts.map +1 -1
- package/declarations/components/hds/code-block/description.d.ts +14 -1
- package/declarations/components/hds/code-block/description.d.ts.map +1 -1
- package/declarations/components/hds/code-block/index.d.ts +48 -6
- package/declarations/components/hds/code-block/index.d.ts.map +1 -1
- package/declarations/components/hds/code-block/title.d.ts +14 -1
- package/declarations/components/hds/code-block/title.d.ts.map +1 -1
- package/declarations/components/hds/code-block/types.d.ts +16 -0
- package/declarations/components/hds/code-block/types.d.ts.map +1 -0
- package/declarations/components/hds/copy/snippet/index.d.ts +1 -2
- package/declarations/components/hds/copy/snippet/index.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/footer.d.ts +16 -1
- package/declarations/components/hds/dropdown/footer.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/header.d.ts +16 -1
- package/declarations/components/hds/dropdown/header.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/index.d.ts +56 -7
- package/declarations/components/hds/dropdown/index.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/checkbox.d.ts +18 -3
- package/declarations/components/hds/dropdown/list-item/checkbox.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/checkmark.d.ts +19 -3
- package/declarations/components/hds/dropdown/list-item/checkmark.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/copy-item.d.ts +17 -5
- package/declarations/components/hds/dropdown/list-item/copy-item.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/description.d.ts +13 -3
- package/declarations/components/hds/dropdown/list-item/description.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/generic.d.ts +13 -1
- package/declarations/components/hds/dropdown/list-item/generic.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/interactive.d.ts +23 -6
- package/declarations/components/hds/dropdown/list-item/interactive.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/radio.d.ts +18 -3
- package/declarations/components/hds/dropdown/list-item/radio.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/separator.d.ts +10 -1
- package/declarations/components/hds/dropdown/list-item/separator.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/title.d.ts +13 -3
- package/declarations/components/hds/dropdown/list-item/title.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/list-item/types.d.ts +10 -0
- package/declarations/components/hds/dropdown/list-item/types.d.ts.map +1 -0
- package/declarations/components/hds/dropdown/toggle/button.d.ts +34 -11
- package/declarations/components/hds/dropdown/toggle/button.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/toggle/chevron.d.ts +9 -1
- package/declarations/components/hds/dropdown/toggle/chevron.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/toggle/icon.d.ts +27 -8
- package/declarations/components/hds/dropdown/toggle/icon.d.ts.map +1 -1
- package/declarations/components/hds/dropdown/toggle/types.d.ts +20 -0
- package/declarations/components/hds/dropdown/toggle/types.d.ts.map +1 -0
- package/declarations/components/hds/dropdown/types.d.ts +12 -0
- package/declarations/components/hds/dropdown/types.d.ts.map +1 -0
- package/declarations/components/hds/flyout/index.d.ts.map +1 -1
- package/declarations/components/hds/flyout/types.d.ts +4 -0
- package/declarations/components/hds/flyout/types.d.ts.map +1 -1
- package/declarations/components/hds/form/checkbox/base.d.ts +1 -1
- package/declarations/components/hds/form/checkbox/base.d.ts.map +1 -1
- package/declarations/components/hds/icon/index.d.ts +37 -0
- package/declarations/components/hds/icon/index.d.ts.map +1 -0
- package/declarations/components/hds/icon/types.d.ts +29 -0
- package/declarations/components/hds/icon/types.d.ts.map +1 -0
- package/declarations/components/hds/icon-tile/index.d.ts +1 -1
- package/declarations/components/hds/icon-tile/index.d.ts.map +1 -1
- package/declarations/components/hds/link/standalone.d.ts +1 -1
- package/declarations/components/hds/link/standalone.d.ts.map +1 -1
- package/declarations/components/hds/menu-primitive/index.d.ts +32 -9
- package/declarations/components/hds/menu-primitive/index.d.ts.map +1 -1
- package/declarations/components/hds/modal/index.d.ts.map +1 -1
- package/declarations/components/hds/popover-primitive/index.d.ts.map +1 -1
- package/declarations/components/hds/segmented-group/index.d.ts +27 -1
- package/declarations/components/hds/segmented-group/index.d.ts.map +1 -1
- package/declarations/components/hds/side-nav/index.d.ts +1 -0
- package/declarations/components/hds/side-nav/index.d.ts.map +1 -1
- package/declarations/components/hds/tooltip-button/index.d.ts +23 -5
- package/declarations/components/hds/tooltip-button/index.d.ts.map +1 -1
- package/declarations/components/hds/tooltip-button/types.d.ts +20 -0
- package/declarations/components/hds/tooltip-button/types.d.ts.map +1 -0
- package/declarations/components.d.ts +17 -1
- package/declarations/components.d.ts.map +1 -1
- package/declarations/modifiers/hds-tooltip.d.ts +24 -8
- package/declarations/modifiers/hds-tooltip.d.ts.map +1 -1
- package/declarations/template-registry.d.ts +92 -0
- package/declarations/template-registry.d.ts.map +1 -1
- package/dist/_app_/components/hds/app-header/home-link.js +1 -0
- package/dist/_app_/components/hds/app-header/index.js +1 -0
- package/dist/_app_/components/hds/app-header/menu-button.js +1 -0
- package/dist/_app_/components/hds/application-state/media.js +1 -0
- package/dist/_app_/components/hds/icon/index.js +1 -0
- package/dist/components/hds/alert/index.js.map +1 -1
- package/dist/components/hds/app-header/home-link.js +25 -0
- package/dist/components/hds/app-header/home-link.js.map +1 -0
- package/dist/components/hds/app-header/index.js +88 -0
- package/dist/components/hds/app-header/index.js.map +1 -0
- package/dist/components/hds/app-header/menu-button.js +26 -0
- package/dist/components/hds/app-header/menu-button.js.map +1 -0
- package/dist/components/hds/application-state/footer.js +5 -31
- package/dist/components/hds/application-state/footer.js.map +1 -1
- package/dist/components/hds/application-state/header.js +9 -5
- package/dist/components/hds/application-state/header.js.map +1 -1
- package/dist/components/hds/application-state/index.js +21 -5
- package/dist/components/hds/application-state/index.js.map +1 -1
- package/dist/components/hds/application-state/media.js +16 -0
- package/dist/components/hds/application-state/media.js.map +1 -0
- package/dist/components/hds/application-state/types.js +13 -0
- package/dist/components/hds/application-state/types.js.map +1 -0
- package/dist/components/hds/badge-count/index.js.map +1 -1
- package/dist/components/hds/breadcrumb/index.js +3 -3
- package/dist/components/hds/breadcrumb/index.js.map +1 -1
- package/dist/components/hds/breadcrumb/item.js +3 -3
- package/dist/components/hds/breadcrumb/item.js.map +1 -1
- package/dist/components/hds/breadcrumb/truncation.js +1 -1
- package/dist/components/hds/breadcrumb/truncation.js.map +1 -1
- package/dist/components/hds/code-block/copy-button.js +8 -2
- package/dist/components/hds/code-block/copy-button.js.map +1 -1
- package/dist/components/hds/code-block/description.js +8 -2
- package/dist/components/hds/code-block/description.js.map +1 -1
- package/dist/components/hds/code-block/index.js +12 -10
- package/dist/components/hds/code-block/index.js.map +1 -1
- package/dist/components/hds/code-block/title.js +8 -2
- package/dist/components/hds/code-block/title.js.map +1 -1
- package/dist/components/hds/code-block/types.js +19 -0
- package/dist/components/hds/code-block/types.js.map +1 -0
- package/dist/components/hds/copy/snippet/index.js.map +1 -1
- package/dist/components/hds/dialog-primitive/header.js.map +1 -1
- package/dist/components/hds/dropdown/footer.js +8 -2
- package/dist/components/hds/dropdown/footer.js.map +1 -1
- package/dist/components/hds/dropdown/header.js +8 -2
- package/dist/components/hds/dropdown/header.js.map +1 -1
- package/dist/components/hds/dropdown/index.js +13 -10
- package/dist/components/hds/dropdown/index.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/checkbox.js +1 -1
- package/dist/components/hds/dropdown/list-item/checkbox.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/checkmark.js +2 -2
- package/dist/components/hds/dropdown/list-item/checkmark.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/copy-item.js +4 -4
- package/dist/components/hds/dropdown/list-item/copy-item.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/description.js +2 -2
- package/dist/components/hds/dropdown/list-item/description.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/generic.js +8 -2
- package/dist/components/hds/dropdown/list-item/generic.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/interactive.js +7 -6
- package/dist/components/hds/dropdown/list-item/interactive.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/radio.js +1 -1
- package/dist/components/hds/dropdown/list-item/radio.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/separator.js +8 -2
- package/dist/components/hds/dropdown/list-item/separator.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/title.js +2 -2
- package/dist/components/hds/dropdown/list-item/title.js.map +1 -1
- package/dist/components/hds/dropdown/list-item/types.js +13 -0
- package/dist/components/hds/dropdown/list-item/types.js.map +1 -0
- package/dist/components/hds/dropdown/toggle/button.js +11 -10
- package/dist/components/hds/dropdown/toggle/button.js.map +1 -1
- package/dist/components/hds/dropdown/toggle/chevron.js +8 -2
- package/dist/components/hds/dropdown/toggle/chevron.js.map +1 -1
- package/dist/components/hds/dropdown/toggle/icon.js +10 -9
- package/dist/components/hds/dropdown/toggle/icon.js.map +1 -1
- package/dist/components/hds/dropdown/toggle/types.js +23 -0
- package/dist/components/hds/dropdown/toggle/types.js.map +1 -0
- package/dist/components/hds/dropdown/types.js +15 -0
- package/dist/components/hds/dropdown/types.js.map +1 -0
- package/dist/components/hds/flyout/index.js.map +1 -1
- package/dist/components/hds/flyout/types.js +5 -0
- package/dist/components/hds/flyout/types.js.map +1 -1
- package/dist/components/hds/form/checkbox/base.js.map +1 -1
- package/dist/components/hds/icon/index.js +89 -0
- package/dist/components/hds/icon/index.js.map +1 -0
- package/dist/components/hds/icon/types.js +31 -0
- package/dist/components/hds/icon/types.js.map +1 -0
- package/dist/components/hds/icon-tile/index.js.map +1 -1
- package/dist/components/hds/link/standalone.js.map +1 -1
- package/dist/components/hds/menu-primitive/index.js +13 -7
- package/dist/components/hds/menu-primitive/index.js.map +1 -1
- package/dist/components/hds/modal/index.js.map +1 -1
- package/dist/components/hds/popover-primitive/index.js.map +1 -1
- package/dist/components/hds/segmented-group/index.js +8 -2
- package/dist/components/hds/segmented-group/index.js.map +1 -1
- package/dist/components/hds/side-nav/base.js +1 -1
- package/dist/components/hds/side-nav/base.js.map +1 -1
- package/dist/components/hds/side-nav/header/index.js +1 -1
- package/dist/components/hds/side-nav/header/index.js.map +1 -1
- package/dist/components/hds/side-nav/index.js +6 -1
- package/dist/components/hds/side-nav/index.js.map +1 -1
- package/dist/components/hds/tooltip-button/index.js +8 -8
- package/dist/components/hds/tooltip-button/index.js.map +1 -1
- package/dist/components/hds/tooltip-button/types.js +23 -0
- package/dist/components/hds/tooltip-button/types.js.map +1 -0
- package/dist/components.js +16 -0
- package/dist/components.js.map +1 -1
- package/dist/modifiers/hds-tooltip.js +42 -27
- package/dist/modifiers/hds-tooltip.js.map +1 -1
- package/dist/styles/@hashicorp/design-system-components.css +714 -58
- package/dist/styles/@hashicorp/design-system-components.scss +2 -0
- package/dist/styles/components/app-frame.scss +13 -0
- package/dist/styles/components/app-header.scss +106 -0
- package/dist/styles/components/application-state.scss +56 -15
- package/dist/styles/components/icon.scss +41 -0
- package/dist/styles/components/side-nav/header.scss +13 -41
- package/dist/styles/components/side-nav/main.scss +29 -1
- package/dist/styles/components/side-nav/toggle-button.scss +6 -1
- package/dist/styles/mixins/_interactive-dark-theme.scss +106 -0
- package/package.json +9 -2
|
@@ -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","classes","push","join","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AACA,eAAe,kBAAkB,CAAC,ivBAAivB;;ACY5wB,MAAMA,gBAA0B,GAAGC,MAAM,CAACC,MAAM,CAACC,kBAAkB,EAAC;AAc5D,MAAMC,OAAO,SAASC,SAAS,CAAmB;AAI/DC,EAAAA,WAAWA,CAACC,KAAc,EAAEC,IAA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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/icon-tile/index.hbs","../../../../src/components/hds/icon-tile/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<div class={{this.classNames}} aria-hidden=\\\"true\\\" ...attributes>\\n {{#if @icon}}\\n <div class=\\\"hds-icon-tile__icon\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </div>\\n {{/if}}\\n {{#if @logo}}\\n <div class=\\\"hds-icon-tile__logo\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </div>\\n {{/if}}\\n {{#if this.iconSecondary}}\\n <div class=\\\"hds-icon-tile__extra\\\">\\n <div class=\\\"hds-icon-tile__extra-icon\\\">\\n <FlightIcon @name={{this.iconSecondary}} @size=\\\"16\\\" @stretched={{true}} />\\n </div>\\n </div>\\n {{/if}}\\n</div>\")","/**\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 {\n HdsIconTileColorNeutral,\n HdsIconTileProductValues,\n HdsIconTileSizeValues,\n} from './types.ts';\n\nimport type {\n HdsIconTileColors,\n HdsIconTileProducts,\n HdsIconTileSizes,\n} from './types.ts';\n\nimport type { FlightIconSignature } from '@hashicorp/ember-flight-icons/components/flight-icon';\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_COLOR = 'neutral';\nexport const SIZES: string[] = Object.values(HdsIconTileSizeValues);\nexport const COLORS: string[] = Object.values({\n ...HdsIconTileColorNeutral,\n ...HdsIconTileProductValues,\n});\nexport const PRODUCTS: string[] = Object.values(HdsIconTileProductValues);\n\nexport interface HdsIconTileSignature {\n Args: {\n size?: HdsIconTileSizes;\n color?: HdsIconTileColors;\n logo?: HdsIconTileProducts;\n icon?: FlightIconSignature['Args']['name'];\n iconSecondary?: FlightIconSignature['Args']['name'];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsIconTileComponent extends Component<HdsIconTileSignature> {\n /**\n * Sets the size for the component\n * Accepted values: small, medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size(): HdsIconTileSizes {\n const { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::IconTile\" 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 scheme for the component\n * Accepted values: see THE COLORS LIST\n *\n * @param color\n * @type {string}\n * @default 'neutral'\n */\n get color(): string {\n let { color = DEFAULT_COLOR } = this.args;\n\n // if it's a \"logo\" then we overwrite any @color parameter passed\n // and just use the product \"brand\" color\n if (this.logo) {\n color = this.logo;\n }\n\n assert(\n `@color for \"Hds::IconTile\" 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 * Sets the icon name (one of the FlightIcons)\n *\n * @param icon\n * @type {string|null}\n * @default null\n */\n get icon(): FlightIconSignature['Args']['name'] | undefined {\n if (this.args.logo) {\n // for the logo version we use the colored versions directly\n return `${this.args.logo}-color`;\n } else if (this.args.icon) {\n return this.args.icon;\n } else {\n return undefined;\n }\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(): '
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/icon-tile/index.hbs","../../../../src/components/hds/icon-tile/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<div class={{this.classNames}} aria-hidden=\\\"true\\\" ...attributes>\\n {{#if @icon}}\\n <div class=\\\"hds-icon-tile__icon\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </div>\\n {{/if}}\\n {{#if @logo}}\\n <div class=\\\"hds-icon-tile__logo\\\">\\n <FlightIcon @name={{this.icon}} @size={{this.iconSize}} @stretched={{true}} />\\n </div>\\n {{/if}}\\n {{#if this.iconSecondary}}\\n <div class=\\\"hds-icon-tile__extra\\\">\\n <div class=\\\"hds-icon-tile__extra-icon\\\">\\n <FlightIcon @name={{this.iconSecondary}} @size=\\\"16\\\" @stretched={{true}} />\\n </div>\\n </div>\\n {{/if}}\\n</div>\")","/**\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 {\n HdsIconTileColorNeutral,\n HdsIconTileProductValues,\n HdsIconTileSizeValues,\n} from './types.ts';\n\nimport type {\n HdsIconTileColors,\n HdsIconTileProducts,\n HdsIconTileSizes,\n} from './types.ts';\n\nimport type { FlightIconSignature } from '@hashicorp/ember-flight-icons/components/flight-icon';\n\nexport const DEFAULT_SIZE = 'medium';\nexport const DEFAULT_COLOR = 'neutral';\nexport const SIZES: string[] = Object.values(HdsIconTileSizeValues);\nexport const COLORS: string[] = Object.values({\n ...HdsIconTileColorNeutral,\n ...HdsIconTileProductValues,\n});\nexport const PRODUCTS: string[] = Object.values(HdsIconTileProductValues);\n\nexport interface HdsIconTileSignature {\n Args: {\n size?: HdsIconTileSizes;\n color?: HdsIconTileColors;\n logo?: HdsIconTileProducts;\n icon?: FlightIconSignature['Args']['name'];\n iconSecondary?: FlightIconSignature['Args']['name'];\n };\n Element: HTMLDivElement;\n}\n\nexport default class HdsIconTileComponent extends Component<HdsIconTileSignature> {\n /**\n * Sets the size for the component\n * Accepted values: small, medium, large\n *\n * @param size\n * @type {string}\n * @default 'medium'\n */\n get size(): HdsIconTileSizes {\n const { size = DEFAULT_SIZE } = this.args;\n\n assert(\n `@size for \"Hds::IconTile\" 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 scheme for the component\n * Accepted values: see THE COLORS LIST\n *\n * @param color\n * @type {string}\n * @default 'neutral'\n */\n get color(): string {\n let { color = DEFAULT_COLOR } = this.args;\n\n // if it's a \"logo\" then we overwrite any @color parameter passed\n // and just use the product \"brand\" color\n if (this.logo) {\n color = this.logo;\n }\n\n assert(\n `@color for \"Hds::IconTile\" 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 * Sets the icon name (one of the FlightIcons)\n *\n * @param icon\n * @type {string|null}\n * @default null\n */\n get icon(): FlightIconSignature['Args']['name'] | undefined {\n if (this.args.logo) {\n // for the logo version we use the colored versions directly\n return `${this.args.logo}-color`;\n } else if (this.args.icon) {\n return this.args.icon;\n } else {\n return undefined;\n }\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(): FlightIconSignature['Args']['size'] {\n if (this.args.size === 'small') {\n return '16';\n } else {\n return '24';\n }\n }\n\n /**\n * Sets the logo name if there is one\n *\n * @param logo\n * @type {string|null}\n * @default null\n */\n get logo(): HdsIconTileProducts | null {\n const { logo } = this.args;\n\n if (logo) {\n assert(\n `@logo for \"Hds::IconTile\" must be one of the following: ${PRODUCTS.join(\n ', '\n )}; received: ${logo}`,\n PRODUCTS.includes(logo)\n );\n }\n\n return logo ?? null;\n }\n\n /**\n * We need to differentiate between a logo and an icon\n * @method IconTile#entity\n * @return {string} The kind of entity we're dealing with (\"logo\" or \"icon\")\n */\n get entity(): string | undefined {\n let entity;\n\n assert(\n `you can't pass both @logo and @icon properties to the \"Hds::IconTile\" component`,\n !(this.args.logo && this.args.icon)\n );\n\n assert(\n `you need to pass @logo or @icon to the \"Hds::IconTile\" component`,\n !(this.args.logo === undefined && this.args.icon === undefined)\n );\n\n if (this.args.logo) {\n entity = 'logo';\n }\n if (this.args.icon) {\n entity = 'icon';\n }\n\n return entity;\n }\n\n /**\n * Sets the \"secondary\" icon name (one of the FlightIcons)\n *\n * @param iconSecondary\n * @type {string|null}\n * @default null\n */\n get iconSecondary(): FlightIconSignature['Args']['name'] | null {\n return this.args.iconSecondary ?? null;\n }\n\n /**\n * Get the class names to apply to the component.\n * @method IconTile#classNames\n * @return {string} The \"class\" attribute to apply to the component.\n */\n // hds-icon-tile {{this.entityClass}} {{this.sizeClass}} {{this.colorClass}}\"\n get classNames(): string {\n const classes = ['hds-icon-tile'];\n\n // add a class based on its entity argument\n classes.push(`hds-icon-tile--${this.entity}`);\n\n // add a class based on the @size argument\n classes.push(`hds-icon-tile--size-${this.size}`);\n\n // add a class based on the @color argument\n classes.push(`hds-icon-tile--color-${this.color}`);\n\n return classes.join(' ');\n }\n}\n"],"names":["DEFAULT_SIZE","DEFAULT_COLOR","SIZES","Object","values","HdsIconTileSizeValues","COLORS","HdsIconTileColorNeutral","HdsIconTileProductValues","PRODUCTS","HdsIconTileComponent","Component","size","args","assert","join","includes","color","logo","icon","undefined","iconSize","entity","iconSecondary","classNames","classes","push","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AACA,eAAe,kBAAkB,CAAC,4tBAA4tB;;ACD9vB;AACA;AACA;AACA;;AAmBO,MAAMA,YAAY,GAAG,SAAQ;AAC7B,MAAMC,aAAa,GAAG,UAAS;AAC/B,MAAMC,KAAe,GAAGC,MAAM,CAACC,MAAM,CAACC,qBAAqB,EAAC;MACtDC,MAAgB,GAAGH,MAAM,CAACC,MAAM,CAAC;AAC5C,EAAA,GAAGG,uBAAuB;EAC1B,GAAGC,wBAAAA;AACL,CAAC,EAAC;AACK,MAAMC,QAAkB,GAAGN,MAAM,CAACC,MAAM,CAACI,wBAAwB,EAAC;AAa1D,MAAME,oBAAoB,SAASC,SAAS,CAAuB;AAChF;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAqB;IAC3B,MAAM;AAAEA,MAAAA,IAAI,GAAGZ,YAAAA;KAAc,GAAG,IAAI,CAACa,IAAI,CAAA;AAEzCC,IAAAA,MAAM,CACJ,CAA2DZ,wDAAAA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;AACE;EACA,IAAIC,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CAAC,eAAe,CAAC,CAAA;;AAEjC;IACAA,OAAO,CAACC,IAAI,CAAC,CAAA,eAAA,EAAkB,IAAI,CAACJ,MAAM,EAAE,CAAC,CAAA;;AAE7C;IACAG,OAAO,CAACC,IAAI,CAAC,CAAA,oBAAA,EAAuB,IAAI,CAACd,IAAI,EAAE,CAAC,CAAA;;AAEhD;IACAa,OAAO,CAACC,IAAI,CAAC,CAAA,qBAAA,EAAwB,IAAI,CAACT,KAAK,EAAE,CAAC,CAAA;AAElD,IAAA,OAAOQ,OAAO,CAACV,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1B,GAAA;AACF,CAAA;AAACY,oBAAA,CAAAC,QAAA,EAlKoBlB,oBAAoB,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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';\n\nimport type { HdsInteractiveSignature } from '../interactive/';\nimport type {\n HdsLinkColors,\n HdsLinkIconPositions,\n HdsLinkStandaloneSizes,\n} from './types.ts';\nimport type { FlightIconSignature } from '@hashicorp/ember-flight-icons/components/flight-icon';\n\nexport interface HdsLinkStandaloneSignature {\n Args: HdsInteractiveSignature['Args'] & {\n size?: HdsLinkStandaloneSizes;\n color?: HdsLinkColors;\n text: string;\n icon: FlightIconSignature['Args']['name'];\n iconPosition?: HdsLinkIconPositions;\n };\n Element: HdsInteractiveSignature['Element'];\n}\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(): string {\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(): HdsLinkColors {\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(): FlightIconSignature['Args']['name'] {\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 {HdsLinkIconPositions}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition(): HdsLinkIconPositions {\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 {HdsLinkStandaloneSizes}\n * @default medium\n * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`\n */\n get size(): HdsLinkStandaloneSizes {\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(): '
|
|
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';\n\nimport type { HdsInteractiveSignature } from '../interactive/';\nimport type {\n HdsLinkColors,\n HdsLinkIconPositions,\n HdsLinkStandaloneSizes,\n} from './types.ts';\nimport type { FlightIconSignature } from '@hashicorp/ember-flight-icons/components/flight-icon';\n\nexport interface HdsLinkStandaloneSignature {\n Args: HdsInteractiveSignature['Args'] & {\n size?: HdsLinkStandaloneSizes;\n color?: HdsLinkColors;\n text: string;\n icon: FlightIconSignature['Args']['name'];\n iconPosition?: HdsLinkIconPositions;\n };\n Element: HdsInteractiveSignature['Element'];\n}\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(): string {\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(): HdsLinkColors {\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(): FlightIconSignature['Args']['name'] {\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 {HdsLinkIconPositions}\n * @default leading\n * @description Positions the icon before or after the text; allowed values are `leading` or `trailing`\n */\n get iconPosition(): HdsLinkIconPositions {\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 {HdsLinkStandaloneSizes}\n * @default medium\n * @description The size of the standalone link; acceptable values are `small`, `medium`, and `large`\n */\n get size(): HdsLinkStandaloneSizes {\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(): FlightIconSignature['Args']['size'] {\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(): string {\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;;AA6BaA,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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S,oBAAA,CAAAC,QAAA,EAnIoBrB,0BAA0B,CAAA;;;;"}
|
|
@@ -6,15 +6,16 @@ import { schedule } from '@ember/runloop';
|
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
9
|
-
var TEMPLATE = precompileTemplate("{{
|
|
9
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n{{! template-lint-disable no-invalid-interactive }}\n<div\n class=\"hds-menu-primitive\"\n ...attributes\n {{did-insert this.didInsert}}\n {{on \"focusout\" this.onFocusOut}}\n {{on \"keyup\" this.onKeyUp}}\n>\n <div class=\"hds-menu-primitive__toggle\" tabindex=\"-1\">\n {{yield (hash onClickToggle=this.onClickToggle isOpen=this.isOpen) to=\"toggle\"}}\n </div>\n {{#if this.isOpen}}\n <div class=\"hds-menu-primitive__content\" tabindex=\"-1\">\n {{yield (hash close=this.close) to=\"content\"}}\n </div>\n {{/if}}\n</div>\n{{! template-lint-enable no-invalid-interactive }}");
|
|
10
10
|
|
|
11
|
-
var _class, _descriptor, _descriptor2;
|
|
12
|
-
let
|
|
11
|
+
var _class, _descriptor, _descriptor2, _descriptor3;
|
|
12
|
+
let MenuPrimitiveComponent = (_class = class MenuPrimitiveComponent extends Component {
|
|
13
13
|
constructor(...args) {
|
|
14
14
|
super(...args);
|
|
15
15
|
_initializerDefineProperty(this, "isOpen", _descriptor, this);
|
|
16
16
|
// notice: if in the future we need to add a "@isOpen" prop to control the status from outside (eg to have the MenuPrimitive opened on render) just add "this.args.isOpen" here to initalize the variable
|
|
17
17
|
_initializerDefineProperty(this, "toggleRef", _descriptor2, this);
|
|
18
|
+
_initializerDefineProperty(this, "element", _descriptor3, this);
|
|
18
19
|
}
|
|
19
20
|
didInsert(element) {
|
|
20
21
|
this.element = element;
|
|
@@ -26,7 +27,7 @@ let HdsMenuPrimitiveComponent = (_class = class HdsMenuPrimitiveComponent extend
|
|
|
26
27
|
}
|
|
27
28
|
this.isOpen = !this.isOpen;
|
|
28
29
|
// we explicitly apply a focus state to the toggle element to overcome a bug in WebKit (see https://github.com/hashicorp/design-system/commit/40cd7f6b3cb15c45f9a1235fafd0fb3ed58e6e62)
|
|
29
|
-
this.toggleRef
|
|
30
|
+
this.toggleRef?.focus();
|
|
30
31
|
}
|
|
31
32
|
onFocusOut(event) {
|
|
32
33
|
// due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback
|
|
@@ -38,7 +39,7 @@ let HdsMenuPrimitiveComponent = (_class = class HdsMenuPrimitiveComponent extend
|
|
|
38
39
|
onKeyUp(event) {
|
|
39
40
|
if (event.key === 'Escape') {
|
|
40
41
|
this.close();
|
|
41
|
-
this.toggleRef
|
|
42
|
+
this.toggleRef?.focus();
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
close() {
|
|
@@ -61,8 +62,13 @@ let HdsMenuPrimitiveComponent = (_class = class HdsMenuPrimitiveComponent extend
|
|
|
61
62
|
enumerable: true,
|
|
62
63
|
writable: true,
|
|
63
64
|
initializer: null
|
|
65
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "element", [tracked], {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
initializer: null
|
|
64
70
|
}), _applyDecoratedDescriptor(_class.prototype, "didInsert", [action], Object.getOwnPropertyDescriptor(_class.prototype, "didInsert"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onClickToggle", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onClickToggle"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onFocusOut", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onFocusOut"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onKeyUp", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onKeyUp"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "close", [action], Object.getOwnPropertyDescriptor(_class.prototype, "close"), _class.prototype)), _class);
|
|
65
|
-
setComponentTemplate(TEMPLATE,
|
|
71
|
+
setComponentTemplate(TEMPLATE, MenuPrimitiveComponent);
|
|
66
72
|
|
|
67
|
-
export {
|
|
73
|
+
export { MenuPrimitiveComponent as default };
|
|
68
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/menu-primitive/index.hbs","../../../../src/components/hds/menu-primitive/index.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/menu-primitive/index.hbs","../../../../src/components/hds/menu-primitive/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{{! template-lint-disable no-invalid-interactive }}\\n<div\\n class=\\\"hds-menu-primitive\\\"\\n ...attributes\\n {{did-insert this.didInsert}}\\n {{on \\\"focusout\\\" this.onFocusOut}}\\n {{on \\\"keyup\\\" this.onKeyUp}}\\n>\\n <div class=\\\"hds-menu-primitive__toggle\\\" tabindex=\\\"-1\\\">\\n {{yield (hash onClickToggle=this.onClickToggle isOpen=this.isOpen) to=\\\"toggle\\\"}}\\n </div>\\n {{#if this.isOpen}}\\n <div class=\\\"hds-menu-primitive__content\\\" tabindex=\\\"-1\\\">\\n {{yield (hash close=this.close) to=\\\"content\\\"}}\\n </div>\\n {{/if}}\\n</div>\\n{{! template-lint-enable no-invalid-interactive }}\")","/**\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 { schedule } from '@ember/runloop';\n\nexport interface MenuPrimitiveSignature {\n Args: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onClose?: (...args: any[]) => void;\n };\n Blocks: {\n toggle?: [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onClickToggle: (event: MouseEvent, ...args: any[]) => void;\n isOpen?: boolean;\n },\n ];\n content?: [\n {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n close: (...args: any[]) => void;\n },\n ];\n };\n Element: HTMLDivElement;\n}\n\nexport default class MenuPrimitiveComponent extends Component<MenuPrimitiveSignature> {\n @tracked isOpen: boolean | undefined; // notice: if in the future we need to add a \"@isOpen\" prop to control the status from outside (eg to have the MenuPrimitive opened on render) just add \"this.args.isOpen\" here to initalize the variable\n @tracked toggleRef: HTMLElement | undefined;\n @tracked element!: HTMLElement;\n\n @action\n didInsert(element: HTMLElement): void {\n this.element = element;\n }\n\n @action\n onClickToggle(event: MouseEvent): void {\n // we store a reference to the DOM node that has the \"onClickToggle\" event associated with it\n if (!this.toggleRef) {\n this.toggleRef = event.currentTarget as HTMLElement;\n }\n this.isOpen = !this.isOpen;\n // we explicitly apply a focus state to the toggle element to overcome a bug in WebKit (see https://github.com/hashicorp/design-system/commit/40cd7f6b3cb15c45f9a1235fafd0fb3ed58e6e62)\n this.toggleRef?.focus();\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n // if the related target is not part of the disclosed content we close the disclosed container\n if (\n !this.element.contains(\n (event.relatedTarget as Node) || (document.activeElement as Node)\n )\n ) {\n this.close();\n }\n }\n\n @action\n onKeyUp(event: KeyboardEvent): void {\n if (event.key === 'Escape') {\n this.close();\n this.toggleRef?.focus();\n }\n }\n\n @action\n close(): void {\n // we schedule this afterRender to avoid an error in tests caused by updating `isOpen` multiple times in the same computation\n schedule('afterRender', (): void => {\n this.isOpen = false;\n // we call the \"onClose\" callback if it exists (and is a function)\n if (this.args.onClose && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n });\n }\n}\n"],"names":["MenuPrimitiveComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","_descriptor3","didInsert","element","onClickToggle","event","toggleRef","currentTarget","isOpen","focus","onFocusOut","contains","relatedTarget","document","activeElement","close","onKeyUp","key","schedule","onClose","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AACA,eAAe,kBAAkB,CAAC,yqBAAyqB;;;ACgCtrBA,IAAAA,sBAAsB,IAAAC,MAAA,GAA5B,MAAMD,sBAAsB,SAASE,SAAS,CAAyB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,iBAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAC9C;AAAAD,IAAAA,0BAAA,oBAAAE,YAAA,EAAA,IAAA,CAAA,CAAA;AAAAF,IAAAA,0BAAA,kBAAAG,YAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;EAKtCC,SAASA,CAACC,OAAoB,EAAQ;IACpC,IAAI,CAACA,OAAO,GAAGA,OAAO,CAAA;AACxB,GAAA;EAGAC,aAAaA,CAACC,KAAiB,EAAQ;AACrC;AACA,IAAA,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;AACnB,MAAA,IAAI,CAACA,SAAS,GAAGD,KAAK,CAACE,aAA4B,CAAA;AACrD,KAAA;AACA,IAAA,IAAI,CAACC,MAAM,GAAG,CAAC,IAAI,CAACA,MAAM,CAAA;AAC1B;AACA,IAAA,IAAI,CAACF,SAAS,EAAEG,KAAK,EAAE,CAAA;AACzB,GAAA;EAGAC,UAAUA,CAACL,KAAiB,EAAQ;AAClC;AACA;AACA,IAAA,IACE,CAAC,IAAI,CAACF,OAAO,CAACQ,QAAQ,CACnBN,KAAK,CAACO,aAAa,IAAcC,QAAQ,CAACC,aAC7C,CAAC,EACD;MACA,IAAI,CAACC,KAAK,EAAE,CAAA;AACd,KAAA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,SAAA,EAEPM,WAAAA,EAAAA,CAAAA,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAnC,MAAA,CAAA2B,SAAA,EAAA3B,WAAAA,CAAAA,EAAAA,MAAA,CAAA2B,SAAA,CAAA,EAAAD,yBAAA,CAAA1B,MAAA,CAAA2B,SAAA,EAKNM,eAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAnC,MAAA,CAAA2B,SAAA,EAAA3B,eAAAA,CAAAA,EAAAA,MAAA,CAAA2B,SAAA,CAAA,EAAAD,yBAAA,CAAA1B,MAAA,CAAA2B,SAAA,EAAA,YAAA,EAAA,CAWNM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAnC,MAAA,CAAA2B,SAAA,EAAA,YAAA,CAAA,EAAA3B,MAAA,CAAA2B,SAAA,CAAAD,EAAAA,yBAAA,CAAA1B,MAAA,CAAA2B,SAAA,EAAA,SAAA,EAAA,CAaNM,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAnC,MAAA,CAAA2B,SAAA,EAAA,SAAA,CAAA,EAAA3B,MAAA,CAAA2B,SAAA,GAAAD,yBAAA,CAAA1B,MAAA,CAAA2B,SAAA,EAQNM,OAAAA,EAAAA,CAAAA,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAnC,MAAA,CAAA2B,SAAA,YAAA3B,MAAA,CAAA2B,SAAA,CAAA,GAAA3B,MAAA,EAAA;AA1CkCoC,oBAAA,CAAAC,QAAA,EAAtBtC,sBAAsB,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/modal/index.hbs","../../../../src/components/hds/modal/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<Hds::DialogPrimitive::Wrapper\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{! @glint-expect-error - https://github.com/josemarluedke/ember-focus-trap/issues/86 }}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n <:header>\\n {{yield\\n (hash\\n Header=(component\\n \\\"hds/dialog-primitive/header\\\" id=this.id onDismiss=this.onDismiss contextualClassPrefix=\\\"hds-modal\\\"\\n )\\n )\\n }}\\n </:header>\\n <:body>\\n {{yield (hash Body=(component \\\"hds/dialog-primitive/body\\\" contextualClass=\\\"hds-modal__body\\\"))}}\\n </:body>\\n <:footer>\\n {{yield\\n (hash\\n Footer=(component \\\"hds/dialog-primitive/footer\\\" onDismiss=this.onDismiss contextualClass=\\\"hds-modal__footer\\\")\\n )\\n }}\\n </:footer>\\n</Hds::DialogPrimitive::Wrapper>\\n\\n{{#if this.isOpen}}\\n <Hds::DialogPrimitive::Overlay @contextualClass=\\\"hds-modal__overlay\\\" />\\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.ts';\nimport { buildWaiter } from '@ember/test-waiters';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { HdsModalSizes, HdsModalColors } from './types.ts';\n\nimport HdsDialogPrimitiveHeaderComponent from '../dialog-primitive/header.ts';\nimport HdsDialogPrimitiveBodyComponent from '../dialog-primitive/body.ts';\nimport HdsDialogPrimitiveFooterComponent from '../dialog-primitive/footer.ts';\nimport { HdsModalSizeValues, HdsModalColorValues } from './types.ts';\n\nconst waiter = buildWaiter('@hashicorp/design-system-components:modal');\n\nexport const DEFAULT_SIZE = HdsModalSizeValues.Medium;\nexport const DEFAULT_COLOR = HdsModalColorValues.Neutral;\n\nexport const SIZES: string[] = Object.values(HdsModalSizeValues);\nexport const COLORS: string[] = Object.values(HdsModalColorValues);\n\nexport interface HdsModalIndexSignature {\n Args: {\n isDismissDisabled?: boolean;\n size?: HdsModalSizes;\n color?: HdsModalColors;\n onOpen?: () => void;\n onClose?: (event: Event) => void;\n };\n Blocks: {\n default: [\n {\n Header?: WithBoundArgs<\n typeof HdsDialogPrimitiveHeaderComponent,\n 'id' | 'onDismiss' | 'contextualClassPrefix'\n >;\n Body?: WithBoundArgs<\n typeof HdsDialogPrimitiveBodyComponent,\n 'contextualClass'\n >;\n Footer?: WithBoundArgs<\n typeof HdsDialogPrimitiveFooterComponent,\n 'onDismiss' | 'contextualClass'\n >;\n },\n ];\n };\n Element: HTMLDialogElement;\n}\n\nexport default class HdsModalIndexComponent extends Component<HdsModalIndexSignature> {\n @tracked isOpen = false;\n @tracked isDismissDisabled = this.args.isDismissDisabled ?? false;\n element!: HTMLDialogElement;\n body!: HTMLElement;\n bodyInitialOverflowValue = '';\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(): HdsModalSizes {\n const { 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(): HdsModalColors {\n const { 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 const 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(event: Event) {\n if (\n !this.isDismissDisabled &&\n this.args.onClose &&\n typeof this.args.onClose === 'function'\n ) {\n this.args.onClose(event);\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: HTMLDialogElement) {\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 const token = waiter.beginAsync();\n const 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","HdsModalSizeValues","Medium","DEFAULT_COLOR","HdsModalColorValues","Neutral","SIZES","Object","values","COLORS","HdsModalIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","size","assert","join","includes","color","id","getElementId","classNames","classes","push","registerOnCloseCallback","event","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","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,2oCAA2oC;;;ACmB7qC,MAAMA,MAAM,GAAGC,WAAW,CAAC,2CAA2C,CAAC,CAAA;AAE1DC,MAAAA,YAAY,GAAGC,kBAAkB,CAACC,OAAM;AACxCC,MAAAA,aAAa,GAAGC,mBAAmB,CAACC,QAAO;AAEjD,MAAMC,KAAe,GAAGC,MAAM,CAACC,MAAM,CAACP,kBAAkB,EAAC;AACzD,MAAMQ,MAAgB,GAAGF,MAAM,CAACC,MAAM,CAACJ,mBAAmB,EAAC;AA+B7CM,IAAAA,sBAAsB,IAAAC,MAAA,GAA5B,MAAMD,sBAAsB,SAASE,SAAS,CAAyB;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,CAAAgD,SAAA,EAuEhEM,yBAAAA,EAAAA,CAAAA,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAAhD,yBAAAA,CAAAA,EAAAA,MAAA,CAAAgD,SAAA,CAAA,EAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAuBNM,WAAAA,EAAAA,CAAAA,MAAM,GAAA1D,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAAhD,WAAAA,CAAAA,EAAAA,MAAA,CAAAgD,SAAA,CAAA,EAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAAA,iBAAA,EAAA,CAqBNM,MAAM,CAAA,EAAA1D,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAA,iBAAA,CAAA,EAAAhD,MAAA,CAAAgD,SAAA,CAAAD,EAAAA,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAAA,MAAA,EAAA,CAWNM,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAA,MAAA,CAAA,EAAAhD,MAAA,CAAAgD,SAAA,GAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAeNM,WAAAA,EAAAA,CAAAA,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,gBAAAhD,MAAA,CAAAgD,SAAA,CAAA,GAAAhD,MAAA,EAAA;AA/IkCwD,oBAAA,CAAAC,QAAA,EAAtB1D,sBAAsB,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/modal/index.hbs","../../../../src/components/hds/modal/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<Hds::DialogPrimitive::Wrapper\\n class={{this.classNames}}\\n ...attributes\\n aria-labelledby={{this.id}}\\n {{did-insert this.didInsert}}\\n {{will-destroy this.willDestroyNode}}\\n {{! @glint-expect-error - https://github.com/josemarluedke/ember-focus-trap/issues/86 }}\\n {{focus-trap isActive=this.isOpen focusTrapOptions=(hash onDeactivate=this.onDismiss clickOutsideDeactivates=true)}}\\n>\\n <:header>\\n {{yield\\n (hash\\n Header=(component\\n \\\"hds/dialog-primitive/header\\\" id=this.id onDismiss=this.onDismiss contextualClassPrefix=\\\"hds-modal\\\"\\n )\\n )\\n }}\\n </:header>\\n <:body>\\n {{yield (hash Body=(component \\\"hds/dialog-primitive/body\\\" contextualClass=\\\"hds-modal__body\\\"))}}\\n </:body>\\n <:footer>\\n {{yield\\n (hash\\n Footer=(component \\\"hds/dialog-primitive/footer\\\" onDismiss=this.onDismiss contextualClass=\\\"hds-modal__footer\\\")\\n )\\n }}\\n </:footer>\\n</Hds::DialogPrimitive::Wrapper>\\n\\n{{#if this.isOpen}}\\n <Hds::DialogPrimitive::Overlay @contextualClass=\\\"hds-modal__overlay\\\" />\\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.ts';\nimport { buildWaiter } from '@ember/test-waiters';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { HdsModalSizes, HdsModalColors } from './types.ts';\n\nimport HdsDialogPrimitiveHeaderComponent from '../dialog-primitive/header.ts';\nimport HdsDialogPrimitiveBodyComponent from '../dialog-primitive/body.ts';\nimport HdsDialogPrimitiveFooterComponent from '../dialog-primitive/footer.ts';\nimport { HdsModalSizeValues, HdsModalColorValues } from './types.ts';\n\nconst waiter = buildWaiter('@hashicorp/design-system-components:modal');\n\nexport const DEFAULT_SIZE = HdsModalSizeValues.Medium;\nexport const DEFAULT_COLOR = HdsModalColorValues.Neutral;\n\nexport const SIZES: string[] = Object.values(HdsModalSizeValues);\nexport const COLORS: string[] = Object.values(HdsModalColorValues);\n\nexport interface HdsModalIndexSignature {\n Args: {\n isDismissDisabled?: boolean;\n size?: HdsModalSizes;\n color?: HdsModalColors;\n onOpen?: () => void;\n onClose?: (event: Event) => void;\n };\n Blocks: {\n default: [\n {\n Header?: WithBoundArgs<\n typeof HdsDialogPrimitiveHeaderComponent,\n 'id' | 'onDismiss' | 'contextualClassPrefix'\n >;\n Body?: WithBoundArgs<\n typeof HdsDialogPrimitiveBodyComponent,\n 'contextualClass'\n >;\n Footer?: WithBoundArgs<\n typeof HdsDialogPrimitiveFooterComponent,\n 'onDismiss' | 'contextualClass'\n >;\n },\n ];\n };\n Element: HTMLDialogElement;\n}\n\nexport default class HdsModalIndexComponent extends Component<HdsModalIndexSignature> {\n @tracked isOpen = false;\n @tracked isDismissDisabled = this.args.isDismissDisabled ?? false;\n element!: HTMLDialogElement;\n body!: HTMLElement;\n bodyInitialOverflowValue = '';\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(): HdsModalSizes {\n const { 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(): HdsModalColors {\n const { 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(): string {\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(): string {\n const 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(event: Event): void {\n if (\n !this.isDismissDisabled &&\n this.args.onClose &&\n typeof this.args.onClose === 'function'\n ) {\n this.args.onClose(event);\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: HTMLDialogElement): void {\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(): void {\n if (this.element) {\n this.element.removeEventListener(\n 'close',\n this.registerOnCloseCallback,\n true\n );\n }\n }\n\n @action\n open(): void {\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(): Promise<void> {\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 const token = waiter.beginAsync();\n const 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","HdsModalSizeValues","Medium","DEFAULT_COLOR","HdsModalColorValues","Neutral","SIZES","Object","values","COLORS","HdsModalIndexComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","size","assert","join","includes","color","id","getElementId","classNames","classes","push","registerOnCloseCallback","event","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","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,2oCAA2oC;;;ACmB7qC,MAAMA,MAAM,GAAGC,WAAW,CAAC,2CAA2C,CAAC,CAAA;AAE1DC,MAAAA,YAAY,GAAGC,kBAAkB,CAACC,OAAM;AACxCC,MAAAA,aAAa,GAAGC,mBAAmB,CAACC,QAAO;AAEjD,MAAMC,KAAe,GAAGC,MAAM,CAACC,MAAM,CAACP,kBAAkB,EAAC;AACzD,MAAMQ,MAAgB,GAAGF,MAAM,CAACC,MAAM,CAACJ,mBAAmB,EAAC;AA+B7CM,IAAAA,sBAAsB,IAAAC,MAAA,GAA5B,MAAM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,CAAAA,EAAAA,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAuEhEM,yBAAAA,EAAAA,CAAAA,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAAhD,yBAAAA,CAAAA,EAAAA,MAAA,CAAAgD,SAAA,CAAA,EAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAuBNM,WAAAA,EAAAA,CAAAA,MAAM,GAAA1D,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAAhD,WAAAA,CAAAA,EAAAA,MAAA,CAAAgD,SAAA,CAAA,EAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAAA,iBAAA,EAAA,CAqBNM,MAAM,CAAA,EAAA1D,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAA,iBAAA,CAAA,EAAAhD,MAAA,CAAAgD,SAAA,CAAAD,EAAAA,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAAA,MAAA,EAAA,CAWNM,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,EAAA,MAAA,CAAA,EAAAhD,MAAA,CAAAgD,SAAA,GAAAD,yBAAA,CAAA/C,MAAA,CAAAgD,SAAA,EAeNM,WAAAA,EAAAA,CAAAA,MAAM,CAAA1D,EAAAA,MAAA,CAAA2D,wBAAA,CAAAvD,MAAA,CAAAgD,SAAA,gBAAAhD,MAAA,CAAAgD,SAAA,CAAA,GAAAhD,MAAA,EAAA;AA/IkCwD,oBAAA,CAAAC,QAAA,EAAtB1D,sBAAsB,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.hbs","../../../../src/components/hds/popover-primitive/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{{yield\\n (hash\\n setupPrimitiveContainer=this.setupPrimitiveContainer\\n setupPrimitiveToggle=this.setupPrimitiveToggle\\n setupPrimitivePopover=this.setupPrimitivePopover\\n toggleElement=this.toggleElement\\n popoverElement=this.popoverElement\\n isOpen=this.isOpen\\n showPopover=this.showPopover\\n hidePopover=this.hidePopover\\n togglePopover=this.togglePopover\\n )\\n}}\")","/**\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, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { FloatingUIOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: () => void;\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: FloatingUIOptions };\n };\n}\n\nexport default class HdsPopoverPrimitiveComponent extends Component<HdsPopoverPrimitiveSignature> {\n @tracked isOpen = this.args.isOpen ?? false;\n @tracked isClosing = false;\n containerElement?: HTMLElement;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n timer?: ReturnType<typeof setTimeout> | null;\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement) => {\n this.containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['mouseenter', this.onMouseEnter]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['mouseleave', this.onMouseLeave]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement) => {\n this.toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: FloatingUIOptions }\n ) => {\n this.popoverElement = element;\n\n // for the click events we don't use `onclick` event listeners, but we rely on the `popovertarget` attribute\n // provided by the Popover API which does all the magic for us without needing JS code\n // (important: to work it needs to be applied to a button)\n if (this.enableClickEvents) {\n let popoverId;\n if (this.popoverElement.id) {\n popoverId = this.popoverElement.id;\n } else {\n // we need a DOM id for the `popovertarget` attribute\n popoverId = guidFor(this);\n this.popoverElement.id = popoverId;\n }\n if (this.toggleElement) {\n this.toggleElement.setAttribute('popovertarget', popoverId);\n }\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this.popoverElement.popover = 'manual';\n this.popoverElement.showPopover();\n } else {\n this.popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.popoverElement, [\n 'beforetoggle',\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n const anchoredPositionOptions: FloatingUIOptions = {\n ...named.anchoredPositionOptions,\n };\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n next(() => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this.popoverElement, // element the modifier is attached to\n [this.toggleElement], // positional arguments\n anchoredPositionOptions // named arguments\n );\n });\n }\n );\n\n @action\n showPopover() {\n try {\n if (this.popoverElement) {\n this.popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n hidePopover() {\n try {\n if (this.popoverElement) {\n this.popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover() {\n try {\n if (this.popoverElement) {\n this.popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent) {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this.isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent) {\n if (event.newState === 'open') {\n this.isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this.isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this.isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this.popoverElement) {\n this.popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter() {\n if (this.timer) {\n clearTimeout(this.timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn() {\n // don't re-open the popover if the focus is returned because the closing\n if (!this.isClosing) {\n if (this.timer) {\n clearTimeout(this.timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave() {\n this.timer = setTimeout(() => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent) {\n if (this.containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this.containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this.containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitiveComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","enableSoftEvents","enableClickEvents","modifier","element","containerElement","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","toggleElement","assert","tagName","toLowerCase","HTMLButtonElement","_positional","named","popoverElement","popoverId","id","guidFor","setAttribute","isOpen","popover","showPopover","onBeforeTogglePopover","onTogglePopover","anchoredPositionOptions","next","anchoredPositionModifier","error","warn","JSON","stringify","hidePopover","togglePopover","event","newState","isClosing","onOpen","onClose","timer","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,6dAA6d;;;AC2D1eA,IAAAA,4BAA4B,IAAAC,MAAA,GAAlC,MAAMD,4BAA4B,SAASE,SAAS,CAA+B;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,oBAAAE,YAAA,EAAA,IAAA,CAAA,CAAA;IAAAC,eAAA,CAAA,IAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,C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BAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EA+BNM,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,mBAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAQNM,WAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,WAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAWNM,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,cAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAKNM,YAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,YAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,IAAA1D,MAAA,EAAA;AArOwCmE,oBAAA,CAAAC,QAAA,EAA5BrE,4BAA4B,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/popover-primitive/index.hbs","../../../../src/components/hds/popover-primitive/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{{yield\\n (hash\\n setupPrimitiveContainer=this.setupPrimitiveContainer\\n setupPrimitiveToggle=this.setupPrimitiveToggle\\n setupPrimitivePopover=this.setupPrimitivePopover\\n toggleElement=this.toggleElement\\n popoverElement=this.popoverElement\\n isOpen=this.isOpen\\n showPopover=this.showPopover\\n hidePopover=this.hidePopover\\n togglePopover=this.togglePopover\\n )\\n}}\")","/**\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, warn } from '@ember/debug';\nimport { next } from '@ember/runloop';\nimport { guidFor } from '@ember/object/internals';\nimport { modifier } from 'ember-modifier';\n\nimport registerEvent from '../../../modifiers/hds-register-event.ts';\nimport anchoredPositionModifier from '../../../modifiers/hds-anchored-position.ts';\n\nimport type { FloatingUIOptions } from '../../../modifiers/hds-anchored-position.ts';\nimport type { ModifierLike } from '@glint/template';\n\nexport interface HdsPopoverPrimitiveSignature {\n Args: {\n isOpen?: boolean;\n enableSoftEvents?: boolean;\n enableClickEvents?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n };\n Blocks: {\n default: [\n {\n setupPrimitiveContainer: ModifierLike<SetupPrimitiveContainerModifier>;\n setupPrimitiveToggle: ModifierLike<SetupPrimitiveToggleModifier>;\n setupPrimitivePopover: ModifierLike<SetupPrimitivePopoverModifier>;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n isOpen: boolean;\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: () => void;\n },\n ];\n };\n}\n\ninterface SetupPrimitiveContainerModifier {\n Element: HTMLElement;\n}\n\nexport interface SetupPrimitiveToggleModifier {\n Element: HTMLButtonElement;\n}\n\nexport interface SetupPrimitivePopoverModifier {\n Element: HTMLElement;\n Args: {\n Positional: [];\n Named: { anchoredPositionOptions: FloatingUIOptions };\n };\n}\n\nexport default class HdsPopoverPrimitiveComponent extends Component<HdsPopoverPrimitiveSignature> {\n @tracked isOpen = this.args.isOpen ?? false;\n @tracked isClosing = false;\n containerElement?: HTMLElement;\n toggleElement?: HTMLButtonElement;\n popoverElement?: HTMLElement;\n // this will enable \"soft\" events for the toggle (\"hover\" and \"focus\")\n enableSoftEvents = this.args.enableSoftEvents ?? false;\n // this will enable \"click\" events for the toggle\n enableClickEvents = this.args.enableClickEvents ?? false;\n timer?: ReturnType<typeof setTimeout> | null;\n\n setupPrimitiveContainer = modifier<SetupPrimitiveContainerModifier>(\n (element: HTMLElement): void => {\n this.containerElement = element;\n\n // we register the \"soft\" events\n if (this.enableSoftEvents) {\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['mouseenter', this.onMouseEnter]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['mouseleave', this.onMouseLeave]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['focusin', this.onFocusIn]);\n }\n // we always want the focusOut event\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.containerElement, ['focusout', this.onFocusOut]);\n }\n );\n\n setupPrimitiveToggle = modifier<SetupPrimitiveToggleModifier>(\n (element: HTMLButtonElement): void => {\n this.toggleElement = element;\n\n assert(\n `The toggle element of \"Hds::PopoverPrimitive\" must be a <button>; element received: <${element.tagName.toLowerCase()}>`,\n element instanceof HTMLButtonElement\n );\n }\n );\n\n setupPrimitivePopover = modifier(\n (\n element: HTMLElement,\n _positional,\n named: { anchoredPositionOptions: FloatingUIOptions }\n ): void => {\n this.popoverElement = element;\n\n // for the click events we don't use `onclick` event listeners, but we rely on the `popovertarget` attribute\n // provided by the Popover API which does all the magic for us without needing JS code\n // (important: to work it needs to be applied to a button)\n if (this.enableClickEvents) {\n let popoverId;\n if (this.popoverElement.id) {\n popoverId = this.popoverElement.id;\n } else {\n // we need a DOM id for the `popovertarget` attribute\n popoverId = guidFor(this);\n this.popoverElement.id = popoverId;\n }\n if (this.toggleElement) {\n this.toggleElement.setAttribute('popovertarget', popoverId);\n }\n }\n\n // this should be an extremely edge case, but in the case the popover needs to be initially forced to be open\n // we need to use the \"manual\" state to support the case of multiple \"menus\" opened at the same time\n // IMPORTANT! if a \"popover\" is set to \"open\" with a \"manual\" state, then it can't be closed via `esc` and `click outside`\n if (this.args.isOpen) {\n this.popoverElement.popover = 'manual';\n this.popoverElement.showPopover();\n } else {\n this.popoverElement.popover = 'auto';\n }\n\n // Register \"onBeforeToggle\" + \"onToggle\" callback functions to be called when a native 'toggle' event is dispatched\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.popoverElement, [\n 'beforetoggle',\n this.onBeforeTogglePopover,\n ]);\n // @ts-expect-error: known issue with type of invocation\n registerEvent(this.popoverElement, ['toggle', this.onTogglePopover]);\n\n // we need to spread the argument because if it's set via `{{ hash … }}` Ember complains when we overwrite one of its values\n const anchoredPositionOptions: FloatingUIOptions = {\n ...named.anchoredPositionOptions,\n };\n\n // Apply the `hds-anchored-position` modifier to the \"popover\" element\n // (notice: this function runs the first time when the element the modifier was applied to is inserted into the DOM, and it autotracks while running.\n // Any tracked values that it accesses will be tracked, including the arguments it receives, and if any of them changes, the function will run again)\n // This modifiers uses the Floating UI library to provide:\n // - positioning of the \"popover\" in relation to the \"toggle\"\n // - collision detection (optional)\n next((): void => {\n // @ts-expect-error: known issue with type of invocation\n anchoredPositionModifier(\n this.popoverElement, // element the modifier is attached to\n [this.toggleElement], // positional arguments\n anchoredPositionOptions // named arguments\n );\n });\n }\n );\n\n @action\n showPopover(): void {\n try {\n if (this.popoverElement) {\n this.popoverElement.showPopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`showPopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.show-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n hidePopover(): void {\n try {\n if (this.popoverElement) {\n this.popoverElement.hidePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`hidePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.hide-popover-action.invocation-failed',\n }\n );\n }\n }\n\n @action\n togglePopover(): void {\n try {\n if (this.popoverElement) {\n this.popoverElement.togglePopover();\n }\n } catch (error) {\n warn(\n `The invocation of \\`togglePopover\\` for the popover element caused an unexpected error: ${JSON.stringify(\n error\n )}`,\n {\n id: 'hds-popover.toggle-popover-action.invocation-failed',\n }\n );\n }\n }\n\n // fired just _before_ the \"popover\" is shown or hidden\n @action\n onBeforeTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'closed') {\n // we need this flag to check if it's in the \"closing\" process,\n // because the browser automatically returns the focus to the \"trigger\" button\n // and this would re-open immediately the popover because of the `focusin` event\n this.isClosing = true;\n }\n }\n\n // fired just _after_ the \"popover\" is shown or hidden\n @action\n onTogglePopover(event: ToggleEvent): void {\n if (event.newState === 'open') {\n this.isOpen = true;\n\n // we call the \"onOpen\" callback if it exists (and is a function)\n const { onOpen } = this.args;\n if (typeof onOpen === 'function') {\n onOpen();\n }\n } else {\n this.isOpen = false;\n\n // reset the \"isClosing\" flag (the `toggle` event is fired _after_ the popover is closed)\n this.isClosing = false;\n\n // if the popover was initially forced to be open (using the \"manual\" state) then revert its status to `auto` once the user interacts with it\n if (this.args.isOpen) {\n if (this.popoverElement) {\n this.popoverElement.popover = 'auto';\n }\n }\n\n // we call the \"onClose\" callback if it exists (and is a function)\n const { onClose } = this.args;\n if (typeof onClose === 'function') {\n onClose();\n }\n }\n }\n\n @action\n onMouseEnter(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n }\n this.showPopover();\n }\n\n @action\n onFocusIn(): void {\n // don't re-open the popover if the focus is returned because the closing\n if (!this.isClosing) {\n if (this.timer) {\n clearTimeout(this.timer);\n }\n this.showPopover();\n }\n }\n\n @action\n onMouseLeave(): void {\n this.timer = setTimeout((): void => this.hidePopover(), 500);\n }\n\n @action\n onFocusOut(event: FocusEvent): void {\n if (this.containerElement) {\n let isFocusStillInside = false;\n if (\n event.relatedTarget &&\n // if the related target is not part of the disclosed content we close the disclosed container\n this.containerElement.contains(event.relatedTarget as Node)\n ) {\n isFocusStillInside = true;\n } else if (\n document.activeElement &&\n // due to inconsistent implementation of relatedTarget across browsers we use the activeElement as a fallback\n this.containerElement.contains(document.activeElement)\n ) {\n isFocusStillInside = true;\n }\n // if the target receiving the focus is _not_ part of the disclosed content we close the disclosed container\n if (!isFocusStillInside) {\n this.hidePopover();\n }\n }\n }\n}\n"],"names":["HdsPopoverPrimitiveComponent","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","enableSoftEvents","enableClickEvents","modifier","element","containerElement","registerEvent","onMouseEnter","onMouseLeave","onFocusIn","onFocusOut","toggleElement","assert","tagName","toLowerCase","HTMLButtonElement","_positional","named","popoverElement","popoverId","id","guidFor","setAttribute","isOpen","popover","showPopover","onBeforeTogglePopover","onTogglePopover","anchoredPositionOptions","next","anchoredPositionModifier","error","warn","JSON","stringify","hidePopover","togglePopover","event","newState","isClosing","onOpen","onClose","timer","clearTimeout","setTimeout","isFocusStillInside","relatedTarget","contains","document","activeElement","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;AACA,eAAe,kBAAkB,CAAC,6dAA6d;;;AC2D1eA,IAAAA,4BAA4B,IAAAC,MAAA,GAAlC,MAAMD,4BAA4B,SAASE,SAAS,CAA+B;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,oBAAAE,YAAA,EAAA,IAAA,CAAA,CAAA;IAAAC,eAAA,CAAA,IAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA,CAAA;IAAAA,eAAA,CAAA,IAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAMhG;AAAAA,IAAAA,eAAA,2BACmB,IAAI,CAACJ,IAAI,CAACK,gBA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D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAQNM,WAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,WAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAWNM,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,cAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,CAAAD,EAAAA,yBAAA,CAAAzD,MAAA,CAAA0D,SAAA,EAKNM,YAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAlE,MAAA,CAAA0D,SAAA,EAAA,YAAA,CAAA,EAAA1D,MAAA,CAAA0D,SAAA,IAAA1D,MAAA,EAAA;AArOwCmE,oBAAA,CAAAC,QAAA,EAA5BrE,4BAA4B,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("{{
|
|
5
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<div class=\"hds-segmented-group\" ...attributes>\n {{yield\n (hash\n Button=(component \"hds/button\")\n Dropdown=(component \"hds/dropdown\")\n Select=(component \"hds/form/select/base\")\n TextInput=(component \"hds/form/text-input/base\")\n Generic=(component \"hds/yield\")\n )\n }}\n</div>");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) HashiCorp, Inc.
|
|
9
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const HdsSegmentedGroupComponent = templateOnlyComponent();
|
|
13
|
+
var index = setComponentTemplate(TEMPLATE, HdsSegmentedGroupComponent);
|
|
8
14
|
|
|
9
15
|
export { index as default };
|
|
10
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/segmented-group/index.hbs","../../../../src/components/hds/segmented-group/index.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/hds/segmented-group/index.hbs","../../../../src/components/hds/segmented-group/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<div class=\\\"hds-segmented-group\\\" ...attributes>\\n {{yield\\n (hash\\n Button=(component \\\"hds/button\\\")\\n Dropdown=(component \\\"hds/dropdown\\\")\\n Select=(component \\\"hds/form/select/base\\\")\\n TextInput=(component \\\"hds/form/text-input/base\\\")\\n Generic=(component \\\"hds/yield\\\")\\n )\\n }}\\n</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport TemplateOnlyComponent from '@ember/component/template-only';\n\nimport type { ComponentLike } from '@glint/template';\nimport type { HdsButtonSignature } from '../button';\nimport type { HdsDropdownSignature } from '../dropdown';\nimport type { HdsFormSelectBaseSignature } from '../form/select/base';\nimport type { HdsFormTextInputBaseSignature } from '../form/text-input/base';\nimport type { HdsYieldSignature } from '../yield';\n\ninterface HdsSegmentedGroupSignature {\n Blocks: {\n default: [\n {\n Button?: ComponentLike<HdsButtonSignature>;\n Dropdown?: ComponentLike<HdsDropdownSignature>;\n Select?: ComponentLike<HdsFormSelectBaseSignature>;\n TextInput?: ComponentLike<HdsFormTextInputBaseSignature>;\n Generic?: ComponentLike<HdsYieldSignature>;\n },\n ];\n };\n Element: HTMLDivElement;\n}\n\nconst HdsSegmentedGroupComponent =\n TemplateOnlyComponent<HdsSegmentedGroupSignature>();\n\nexport default HdsSegmentedGroupComponent;\n"],"names":["HdsSegmentedGroupComponent","TemplateOnlyComponent","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,wZAAwZ;;ACD1b;AACA;AACA;AACA;;AA0BA,MAAMA,0BAA0B,GAC9BC,qBAAqB,EAA8B,CAAA;AAErD,YAAAC,oBAAA,CAAAC,QAAA,EAAeH,0BAA0B,CAAA;;;;"}
|
|
@@ -2,7 +2,7 @@ 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("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n\n<div class=\"hds-side-nav\" ...attributes>\n <div class=\"hds-side-nav__wrapper\">\n {{yield to=\"root\"}}\n <div class=\"hds-side-nav__wrapper-header\">\n {{yield to=\"header\"}}\n </div>\n <div class=\"hds-side-nav__wrapper-body\">\n {{yield to=\"body\"}}\n </div>\n <div class=\"hds-side-nav__wrapper-footer\">\n {{yield to=\"footer\"}}\n </div>\n </div>\n</div>");
|
|
5
|
+
var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n{{! IMPORTANT: we need to add \"squishies\" here (~) because otherwise the whitespace added by Ember causes the empty element to still have visible padding - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}\n<div class=\"hds-side-nav\" ...attributes>\n <div class=\"hds-side-nav__wrapper\">\n {{yield to=\"root\"}}\n <div class=\"hds-side-nav__wrapper-header\">\n {{~yield to=\"header\"~}}\n </div>\n <div class=\"hds-side-nav__wrapper-body\">\n {{~yield to=\"body\"~}}\n </div>\n <div class=\"hds-side-nav__wrapper-footer\">\n {{~yield to=\"footer\"~}}\n </div>\n </div>\n</div>");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Copyright (c) HashiCorp, Inc.
|