@hashicorp/design-system-components 2.8.1 → 2.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/CHANGELOG.md +31 -10
- package/addon/components/hds/accordion/item/button.hbs +1 -1
- package/addon/components/hds/accordion/item/index.hbs +1 -1
- package/addon/components/hds/copy/button/index.hbs +16 -0
- package/addon/components/hds/copy/button/index.js +91 -0
- package/addon/components/hds/copy/snippet/index.hbs +15 -0
- package/addon/components/hds/copy/snippet/index.js +118 -0
- package/addon/components/hds/dropdown/list-item/copy-item.hbs +1 -9
- package/addon/components/hds/dropdown/list-item/copy-item.js +0 -30
- package/addon/components/hds/flyout/index.js +22 -1
- package/addon/components/hds/form/field/index.js +1 -1
- package/addon/components/hds/modal/index.js +22 -1
- package/app/components/hds/copy/button/index.js +6 -0
- package/app/components/hds/copy/index.js +6 -0
- package/app/components/hds/copy/snippet/index.js +6 -0
- package/app/styles/@hashicorp/design-system-components.scss +1 -0
- package/app/styles/components/copy/button.scss +31 -0
- package/app/styles/components/copy/index.scss +8 -0
- package/app/styles/components/copy/snippet.scss +111 -0
- package/app/styles/components/dropdown.scss +0 -52
- package/package.json +4 -3
- package/app/utils/hds-get-element-id.js +0 -6
- package/app/utils/hds-set-aria-described-by.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
# @hashicorp/design-system-components
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1488](https://github.com/hashicorp/design-system/pull/1488) [`372bae36d`](https://github.com/hashicorp/design-system/commit/372bae36d87377dc87aa18ed39c7834a4cc545f4) Thanks [@MelSumner](https://github.com/MelSumner)! - Adds the `Hds::CopyButton` and `Hds::CopySnippet` components.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1539](https://github.com/hashicorp/design-system/pull/1539) [`9d3f29a42`](https://github.com/hashicorp/design-system/commit/9d3f29a42e8130b2155498a7c3cb77a6da279a68) Thanks [@Dhaulagiri](https://github.com/Dhaulagiri)! - Adjusted closing brace on copywrite headers to avoid terminal noise
|
|
12
|
+
|
|
13
|
+
- [#1549](https://github.com/hashicorp/design-system/pull/1549) [`a6553ea03`](https://github.com/hashicorp/design-system/commit/a6553ea032f70f0167f149589801b72154c3cf75) Thanks [@fivetanley](https://github.com/fivetanley)! - `Hds::Modal` - reduce test flakiness around closing Modal when using `@ember/test-helpers`
|
|
14
|
+
|
|
15
|
+
- [#1530](https://github.com/hashicorp/design-system/pull/1530) [`b757e6efb`](https://github.com/hashicorp/design-system/commit/b757e6efb4c115abcd604bc4ef155f731f118c72) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix Embroider warnings caused by incorrect export of internal utility functions
|
|
16
|
+
|
|
17
|
+
- [#1552](https://github.com/hashicorp/design-system/pull/1552) [`865ff7aad`](https://github.com/hashicorp/design-system/commit/865ff7aad593bddf6f16bfdb1210318bedfa4e22) Thanks [@alex-ju](https://github.com/alex-ju)! - `Hds::Flyout` - reduce test flakiness around closing Flyout when using `@ember/test-helpers`
|
|
18
|
+
|
|
19
|
+
- [#1529](https://github.com/hashicorp/design-system/pull/1529) [`1433fe098`](https://github.com/hashicorp/design-system/commit/1433fe0988b9c4e0d280ac450e6688e5d606630d) Thanks [@alex-ju](https://github.com/alex-ju)! - `Hds::Form::Field` - Fix error message for unexpected `@layout` values
|
|
20
|
+
|
|
21
|
+
- Updated dependencies []:
|
|
22
|
+
- @hashicorp/ember-flight-icons@3.0.9
|
|
23
|
+
|
|
3
24
|
## 2.8.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
6
27
|
|
|
7
|
-
- [#1516](https://github.com/hashicorp/design-system/pull/1516) [`f2192cad7`](https://github.com/hashicorp/design-system/commit/f2192cad73b6d966bf813f54dcee02e157c76392) Thanks [@didoo](https://github.com/didoo)! - `SideNav` - Fixed issue with links still being interactive (even if visually hidden) when the navigation is "minimized"
|
|
28
|
+
- [#1516](https://github.com/hashicorp/design-system/pull/1516) [`f2192cad7`](https://github.com/hashicorp/design-system/commit/f2192cad73b6d966bf813f54dcee02e157c76392) Thanks [@didoo](https://github.com/didoo)! - `Hds::SideNav` - Fixed issue with links still being interactive (even if visually hidden) when the navigation is "minimized"
|
|
8
29
|
|
|
9
|
-
- [#1518](https://github.com/hashicorp/design-system/pull/1518) [`5fd48e31e`](https://github.com/hashicorp/design-system/commit/5fd48e31ed3241ee19a8226bb28fa04ad79479c5) Thanks [@didoo](https://github.com/didoo)! - `PageHeader` - Fixed overflow of non-breaking text for `title`, `subtitle` and `description` elements
|
|
30
|
+
- [#1518](https://github.com/hashicorp/design-system/pull/1518) [`5fd48e31e`](https://github.com/hashicorp/design-system/commit/5fd48e31ed3241ee19a8226bb28fa04ad79479c5) Thanks [@didoo](https://github.com/didoo)! - `Hds::PageHeader` - Fixed overflow of non-breaking text for `title`, `subtitle` and `description` elements
|
|
10
31
|
|
|
11
|
-
- [#1494](https://github.com/hashicorp/design-system/pull/1494) [`169a85b63`](https://github.com/hashicorp/design-system/commit/169a85b6348649bc0e2411f3ab6f6a086eecb692) Thanks [@natmegs](https://github.com/natmegs)! - `Form::TextInput` - Add support for datetime-local type
|
|
32
|
+
- [#1494](https://github.com/hashicorp/design-system/pull/1494) [`169a85b63`](https://github.com/hashicorp/design-system/commit/169a85b6348649bc0e2411f3ab6f6a086eecb692) Thanks [@natmegs](https://github.com/natmegs)! - `Hds::Form::TextInput` - Add support for `datetime-local` type
|
|
12
33
|
|
|
13
|
-
- [#1500](https://github.com/hashicorp/design-system/pull/1500) [`b6c2867a4`](https://github.com/hashicorp/design-system/commit/b6c2867a4b7d1c183e9a17d16208ed12ce1aa43f) Thanks [@didoo](https://github.com/didoo)! -
|
|
34
|
+
- [#1500](https://github.com/hashicorp/design-system/pull/1500) [`b6c2867a4`](https://github.com/hashicorp/design-system/commit/b6c2867a4b7d1c183e9a17d16208ed12ce1aa43f) Thanks [@didoo](https://github.com/didoo)! - `Hds::SideNav` - updated layout styling for the `SideNav::List::Title` element
|
|
14
35
|
|
|
15
36
|
- [#1520](https://github.com/hashicorp/design-system/pull/1520) [`7f7ec22c3`](https://github.com/hashicorp/design-system/commit/7f7ec22c387ac9df05d05de31e5c2b45d6324777) Thanks [@alex-ju](https://github.com/alex-ju)! - Upgrade `ember-style-modifier` to `3.0.1`
|
|
16
37
|
|
|
@@ -22,15 +43,15 @@
|
|
|
22
43
|
|
|
23
44
|
### Minor Changes
|
|
24
45
|
|
|
25
|
-
- [#1492](https://github.com/hashicorp/design-system/pull/1492) [`a17e5b2ac`](https://github.com/hashicorp/design-system/commit/a17e5b2acf66493ccbb68a623a3b7ba2fd5ab5a8) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - `Card` - Updated default value of `@overflow` argument to `"visible"` to address an area of consumer confusion and better support the most common use cases.
|
|
46
|
+
- [#1492](https://github.com/hashicorp/design-system/pull/1492) [`a17e5b2ac`](https://github.com/hashicorp/design-system/commit/a17e5b2acf66493ccbb68a623a3b7ba2fd5ab5a8) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - `Hds::Card` - Updated default value of `@overflow` argument to `"visible"` to address an area of consumer confusion and better support the most common use cases.
|
|
26
47
|
|
|
27
|
-
Technically, this is a breaking change as it will require consumers relying upon the previous `hidden` default value to now manually set the value. The result of not setting the a `
|
|
48
|
+
Technically, this is a breaking change as it will require consumers relying upon the previous `hidden` default value to now manually set the value. The result of not setting the a `hidden` value can cause square edges of some images to "stick out" and overlap the rounded corners of the Card itself. We considered this to be a fairly minor, low-impact issue however which would not affect functionality or usability.
|
|
28
49
|
|
|
29
|
-
- [#1452](https://github.com/hashicorp/design-system/pull/1452) [`c277d0366`](https://github.com/hashicorp/design-system/commit/c277d036673cf572c00ebf5b8b35b424c0b057fd) Thanks [@alex-ju](https://github.com/alex-ju)! - `Form::TextInput` - Add loading state on "search" type
|
|
50
|
+
- [#1452](https://github.com/hashicorp/design-system/pull/1452) [`c277d0366`](https://github.com/hashicorp/design-system/commit/c277d036673cf572c00ebf5b8b35b424c0b057fd) Thanks [@alex-ju](https://github.com/alex-ju)! - `Hds::Form::TextInput` - Add loading state on "search" type
|
|
30
51
|
|
|
31
|
-
- [#1468](https://github.com/hashicorp/design-system/pull/1468) [`b0a766ccf`](https://github.com/hashicorp/design-system/commit/b0a766ccf5357dd6f0e8dfb68d8c1ee823e76b50) Thanks [@alex-ju](https://github.com/alex-ju)! -
|
|
52
|
+
- [#1468](https://github.com/hashicorp/design-system/pull/1468) [`b0a766ccf`](https://github.com/hashicorp/design-system/commit/b0a766ccf5357dd6f0e8dfb68d8c1ee823e76b50) Thanks [@alex-ju](https://github.com/alex-ju)! - Add `Hds::Form::MaskedInput` component
|
|
32
53
|
|
|
33
|
-
- [#1423](https://github.com/hashicorp/design-system/pull/1423) [`5ac340c8c`](https://github.com/hashicorp/design-system/commit/5ac340c8c3a3adab388704067578cf419e2e2f10) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - Add
|
|
54
|
+
- [#1423](https://github.com/hashicorp/design-system/pull/1423) [`5ac340c8c`](https://github.com/hashicorp/design-system/commit/5ac340c8c3a3adab388704067578cf419e2e2f10) Thanks [@KristinLBradley](https://github.com/KristinLBradley)! - Add `Hds::Accordion` component
|
|
34
55
|
|
|
35
56
|
### Patch Changes
|
|
36
57
|
|
|
@@ -78,7 +99,7 @@
|
|
|
78
99
|
|
|
79
100
|
- [#1426](https://github.com/hashicorp/design-system/pull/1426) [`1f8886a2d`](https://github.com/hashicorp/design-system/commit/1f8886a2d5117d74a0dddd4bca4a09d9fcedc8da) Thanks [@MelSumner](https://github.com/MelSumner)! - Style tweaks to standalone link
|
|
80
101
|
|
|
81
|
-
- [#1434](https://github.com/hashicorp/design-system/pull/1434) [`eadefc4bd`](https://github.com/hashicorp/design-system/commit/eadefc4bdb4e5fd6c110a7be1d7d9aa720695678) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix scroll management on `Modal` and `Flyout` resulting in stray `style` attribute on `<body>` element
|
|
102
|
+
- [#1434](https://github.com/hashicorp/design-system/pull/1434) [`eadefc4bd`](https://github.com/hashicorp/design-system/commit/eadefc4bdb4e5fd6c110a7be1d7d9aa720695678) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix scroll management on `Hds::Modal` and `Hds::Flyout` resulting in stray `style` attribute on `<body>` element
|
|
82
103
|
|
|
83
104
|
- Updated dependencies [[`e6e0c22c5`](https://github.com/hashicorp/design-system/commit/e6e0c22c538e381f4a97428dc35cf1295ce6ae21)]:
|
|
84
105
|
- @hashicorp/ember-flight-icons@3.0.6
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
<Hds::Button
|
|
6
|
+
class={{this.classNames}}
|
|
7
|
+
@size={{this.size}}
|
|
8
|
+
@isFullWidth={{@isFullWidth}}
|
|
9
|
+
@text={{@text}}
|
|
10
|
+
@icon={{this.icon}}
|
|
11
|
+
@isIconOnly={{@isIconOnly}}
|
|
12
|
+
@color="secondary"
|
|
13
|
+
@iconPosition="trailing"
|
|
14
|
+
{{clipboard text=@textToCopy target=@targetToCopy container=@container onError=this.onError onSuccess=this.onSuccess}}
|
|
15
|
+
...attributes
|
|
16
|
+
/>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Component from '@glimmer/component';
|
|
7
|
+
import { assert } from '@ember/debug';
|
|
8
|
+
import { tracked } from '@glimmer/tracking';
|
|
9
|
+
import { action } from '@ember/object';
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_SIZE = 'medium';
|
|
12
|
+
export const SIZES = ['small', 'medium'];
|
|
13
|
+
export const DEFAULT_ICON = 'clipboard-copy';
|
|
14
|
+
export const SUCCESS_ICON = 'clipboard-checked';
|
|
15
|
+
export const ERROR_ICON = 'clipboard';
|
|
16
|
+
export const DEFAULT_STATUS = 'idle';
|
|
17
|
+
|
|
18
|
+
export default class HdsCopyButtonComponent extends Component {
|
|
19
|
+
@tracked status = DEFAULT_STATUS;
|
|
20
|
+
@tracked timer;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param icon
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @description The icon to be displayed for each status; automatically calculated based on the tracked property `status`.
|
|
26
|
+
*/
|
|
27
|
+
get icon() {
|
|
28
|
+
let icon = DEFAULT_ICON;
|
|
29
|
+
if (this.status === 'success') {
|
|
30
|
+
icon = SUCCESS_ICON;
|
|
31
|
+
} else if (this.status === 'error') {
|
|
32
|
+
icon = ERROR_ICON;
|
|
33
|
+
}
|
|
34
|
+
return icon;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param size
|
|
39
|
+
* @type {string}
|
|
40
|
+
* @default medium
|
|
41
|
+
* @description The size of the copy/button; acceptable values are `small` and `medium`
|
|
42
|
+
*/
|
|
43
|
+
get size() {
|
|
44
|
+
let { size = DEFAULT_SIZE } = this.args;
|
|
45
|
+
|
|
46
|
+
assert(
|
|
47
|
+
`@size for "Hds::Copy::Button" must be one of the following: ${SIZES.join(
|
|
48
|
+
', '
|
|
49
|
+
)}; received: ${size}`,
|
|
50
|
+
SIZES.includes(size)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return size;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get the class names to apply to the component.
|
|
58
|
+
* @method CopyButton#classNames
|
|
59
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
60
|
+
*/
|
|
61
|
+
get classNames() {
|
|
62
|
+
let classes = ['hds-copy-button'];
|
|
63
|
+
|
|
64
|
+
// add a class based on the @size argument
|
|
65
|
+
classes.push(`hds-button--size-${this.size}`);
|
|
66
|
+
|
|
67
|
+
classes.push(`hds-copy-button--status-${this.status}`);
|
|
68
|
+
|
|
69
|
+
return classes.join(' ');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@action
|
|
73
|
+
onSuccess() {
|
|
74
|
+
this.status = 'success';
|
|
75
|
+
this.resetStatusDelayed();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@action
|
|
79
|
+
onError() {
|
|
80
|
+
this.status = 'error';
|
|
81
|
+
this.resetStatusDelayed();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
resetStatusDelayed() {
|
|
85
|
+
clearTimeout(this.timer);
|
|
86
|
+
// make it fade back to the default state
|
|
87
|
+
this.timer = setTimeout(() => {
|
|
88
|
+
this.status = DEFAULT_STATUS;
|
|
89
|
+
}, 1500);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
5
|
+
<button
|
|
6
|
+
type="button"
|
|
7
|
+
class={{this.classNames}}
|
|
8
|
+
{{clipboard text=@textToCopy onError=this.onError onSuccess=this.onSuccess}}
|
|
9
|
+
...attributes
|
|
10
|
+
>
|
|
11
|
+
<span class="hds-copy-snippet__text hds-typography-code-100 {{if @isTruncated 'hds-copy-snippet__text--truncated'}}">
|
|
12
|
+
{{@textToCopy}}
|
|
13
|
+
</span>
|
|
14
|
+
<FlightIcon @name={{this.icon}} class="hds-copy-snippet__icon" />
|
|
15
|
+
</button>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Component from '@glimmer/component';
|
|
7
|
+
import { assert } from '@ember/debug';
|
|
8
|
+
import { tracked } from '@glimmer/tracking';
|
|
9
|
+
import { action } from '@ember/object';
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_COLOR = 'primary';
|
|
12
|
+
export const COLORS = ['primary', 'secondary'];
|
|
13
|
+
export const DEFAULT_ICON = 'clipboard-copy';
|
|
14
|
+
export const SUCCESS_ICON = 'clipboard-checked';
|
|
15
|
+
export const ERROR_ICON = 'clipboard';
|
|
16
|
+
export const DEFAULT_STATUS = 'idle';
|
|
17
|
+
|
|
18
|
+
export default class HdsCopySnippetIndexComponent extends Component {
|
|
19
|
+
@tracked status = DEFAULT_STATUS;
|
|
20
|
+
@tracked timer;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param icon
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @default DEFAULT_ICON
|
|
26
|
+
* @description Determines the icon to be used, based on the success state. Note that this is auto-tracked because it depends on a tracked property (status).
|
|
27
|
+
*/
|
|
28
|
+
get icon() {
|
|
29
|
+
let icon = DEFAULT_ICON;
|
|
30
|
+
if (this.status === 'success') {
|
|
31
|
+
icon = SUCCESS_ICON;
|
|
32
|
+
} else if (this.status === 'error') {
|
|
33
|
+
icon = ERROR_ICON;
|
|
34
|
+
}
|
|
35
|
+
return icon;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param color
|
|
40
|
+
* @type {string}
|
|
41
|
+
* @default primary
|
|
42
|
+
* @description Determines the color of button to be used; acceptable values are `primary` and `secondary`
|
|
43
|
+
*/
|
|
44
|
+
get color() {
|
|
45
|
+
let { color = DEFAULT_COLOR } = this.args;
|
|
46
|
+
|
|
47
|
+
assert(
|
|
48
|
+
`@color for "Hds::Copy::Snippet" must be one of the following: ${COLORS.join(
|
|
49
|
+
', '
|
|
50
|
+
)}; received: ${color}`,
|
|
51
|
+
COLORS.includes(color)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param isFullWidth
|
|
59
|
+
* @type {boolean}
|
|
60
|
+
* @default false
|
|
61
|
+
* @description Indicates that the component should take up the full width of the parent container.
|
|
62
|
+
*/
|
|
63
|
+
get isFullWidth() {
|
|
64
|
+
return this.args.isFullWidth ?? false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param isTruncated
|
|
69
|
+
* @type {boolean}
|
|
70
|
+
* @default false
|
|
71
|
+
* @description Indicates that the component should be truncated instead of wrapping text and using multiple lines.
|
|
72
|
+
*/
|
|
73
|
+
get isTruncated() {
|
|
74
|
+
return this.args.isTruncated ?? false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get the class names to apply to the component.
|
|
79
|
+
* @method CopySnippet#classNames
|
|
80
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
81
|
+
*/
|
|
82
|
+
get classNames() {
|
|
83
|
+
let classes = ['hds-copy-snippet'];
|
|
84
|
+
|
|
85
|
+
// add a class based on the @color argument
|
|
86
|
+
classes.push(`hds-copy-snippet--color-${this.color}`);
|
|
87
|
+
|
|
88
|
+
// add a class based on the tracked status (idle/success/error)
|
|
89
|
+
classes.push(`hds-copy-snippet--status-${this.status}`);
|
|
90
|
+
|
|
91
|
+
// add a class based on the @isFullWidth argument
|
|
92
|
+
if (this.isFullWidth) {
|
|
93
|
+
classes.push('hds-copy-snippet--width-full');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return classes.join(' ');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@action
|
|
100
|
+
onSuccess() {
|
|
101
|
+
this.status = 'success';
|
|
102
|
+
this.resetStatusDelayed();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@action
|
|
106
|
+
onError() {
|
|
107
|
+
this.status = 'error';
|
|
108
|
+
this.resetStatusDelayed();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
resetStatusDelayed() {
|
|
112
|
+
clearTimeout(this.timer);
|
|
113
|
+
// make it fade back to the default state
|
|
114
|
+
this.timer = setTimeout(() => {
|
|
115
|
+
this.status = DEFAULT_STATUS;
|
|
116
|
+
}, 1500);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -8,13 +8,5 @@
|
|
|
8
8
|
class="hds-dropdown-list-item__copy-item-title hds-typography-body-100 hds-font-weight-semibold"
|
|
9
9
|
>{{@copyItemTitle}}</div>
|
|
10
10
|
{{/if}}
|
|
11
|
-
<
|
|
12
|
-
<div class="hds-dropdown-list-item__copy-item-text hds-typography-code-100">
|
|
13
|
-
{{this.text}}
|
|
14
|
-
</div>
|
|
15
|
-
<FlightIcon
|
|
16
|
-
@name="{{if this.isSuccess 'clipboard-checked' 'clipboard-copy'}}"
|
|
17
|
-
class="hds-dropdown-list-item__copy-item-icon"
|
|
18
|
-
/>
|
|
19
|
-
</button>
|
|
11
|
+
<Hds::Copy::Snippet @textToCopy={{this.text}} @isTruncated={{@isTruncated}} />
|
|
20
12
|
</li>
|
|
@@ -5,12 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import Component from '@glimmer/component';
|
|
7
7
|
import { assert } from '@ember/debug';
|
|
8
|
-
import { tracked } from '@glimmer/tracking';
|
|
9
|
-
import { action } from '@ember/object';
|
|
10
8
|
|
|
11
9
|
export default class HdsDropdownListItemCopyItemComponent extends Component {
|
|
12
|
-
@tracked isSuccess = false;
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* @param text
|
|
16
12
|
* @type {string}
|
|
@@ -26,7 +22,6 @@ export default class HdsDropdownListItemCopyItemComponent extends Component {
|
|
|
26
22
|
|
|
27
23
|
return text;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
/**
|
|
31
26
|
* Get the class names to apply to the component.
|
|
32
27
|
* @method classNames
|
|
@@ -40,29 +35,4 @@ export default class HdsDropdownListItemCopyItemComponent extends Component {
|
|
|
40
35
|
|
|
41
36
|
return classes.join(' ');
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
@action
|
|
45
|
-
async copyCode() {
|
|
46
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
|
|
47
|
-
await navigator.clipboard.writeText(this.args.text);
|
|
48
|
-
|
|
49
|
-
if (navigator.clipboard.readText) {
|
|
50
|
-
const result = await navigator.clipboard.readText();
|
|
51
|
-
|
|
52
|
-
if (result === this.args.text) {
|
|
53
|
-
this.isSuccess = true;
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
// assume that it works so Firefox can show the success state
|
|
57
|
-
// doesn't confirm that you'll get the correct pasted text
|
|
58
|
-
// but we accept this as a reasonable tradeoff
|
|
59
|
-
// since users can always copy/paste manually.
|
|
60
|
-
this.isSuccess = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// make it fade back to the default state
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
this.isSuccess = false;
|
|
66
|
-
}, 1000);
|
|
67
|
-
}
|
|
68
38
|
}
|
|
@@ -8,6 +8,15 @@ import { tracked } from '@glimmer/tracking';
|
|
|
8
8
|
import { action } from '@ember/object';
|
|
9
9
|
import { assert } from '@ember/debug';
|
|
10
10
|
import { getElementId } from '@hashicorp/design-system-components/utils/hds-get-element-id';
|
|
11
|
+
import { buildWaiter } from '@ember/test-waiters';
|
|
12
|
+
import { DEBUG } from '@glimmer/env';
|
|
13
|
+
|
|
14
|
+
let waiter;
|
|
15
|
+
|
|
16
|
+
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
17
|
+
if (DEBUG) {
|
|
18
|
+
waiter = buildWaiter('@hashicorp/design-system-components:flyout');
|
|
19
|
+
}
|
|
11
20
|
|
|
12
21
|
export const DEFAULT_SIZE = 'medium';
|
|
13
22
|
export const DEFAULT_HAS_OVERLAY = true;
|
|
@@ -115,7 +124,19 @@ export default class HdsFlyoutIndexComponent extends Component {
|
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
@action
|
|
118
|
-
onDismiss() {
|
|
127
|
+
async onDismiss() {
|
|
128
|
+
// allow ember test helpers to be aware of when the `close` event fires
|
|
129
|
+
// when using `click` or other helpers from '@ember/test-helpers'
|
|
130
|
+
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
131
|
+
if (DEBUG && this.element.open) {
|
|
132
|
+
let token = waiter.beginAsync();
|
|
133
|
+
let listener = () => {
|
|
134
|
+
waiter.endAsync(token);
|
|
135
|
+
this.element.removeEventListener('close', listener);
|
|
136
|
+
};
|
|
137
|
+
this.element.addEventListener('close', listener);
|
|
138
|
+
}
|
|
139
|
+
|
|
119
140
|
// Make flyout dialog invisible using the native `close` method
|
|
120
141
|
this.element.close();
|
|
121
142
|
|
|
@@ -40,7 +40,7 @@ export default class HdsFormFieldIndexComponent extends Component {
|
|
|
40
40
|
let { layout } = this.args;
|
|
41
41
|
|
|
42
42
|
assert(
|
|
43
|
-
`@
|
|
43
|
+
`@layout for "Hds::Form::Field" must be one of the following: ${LAYOUT_TYPES.join(
|
|
44
44
|
', '
|
|
45
45
|
)}; received: ${layout}`,
|
|
46
46
|
LAYOUT_TYPES.includes(layout)
|
|
@@ -8,6 +8,15 @@ import { tracked } from '@glimmer/tracking';
|
|
|
8
8
|
import { action } from '@ember/object';
|
|
9
9
|
import { assert } from '@ember/debug';
|
|
10
10
|
import { getElementId } from '@hashicorp/design-system-components/utils/hds-get-element-id';
|
|
11
|
+
import { buildWaiter } from '@ember/test-waiters';
|
|
12
|
+
import { DEBUG } from '@glimmer/env';
|
|
13
|
+
|
|
14
|
+
let waiter;
|
|
15
|
+
|
|
16
|
+
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
17
|
+
if (DEBUG) {
|
|
18
|
+
waiter = buildWaiter('@hashicorp/design-system-components:modal');
|
|
19
|
+
}
|
|
11
20
|
|
|
12
21
|
export const DEFAULT_SIZE = 'medium';
|
|
13
22
|
export const DEFAULT_COLOR = 'neutral';
|
|
@@ -156,7 +165,19 @@ export default class HdsModalIndexComponent extends Component {
|
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
@action
|
|
159
|
-
onDismiss() {
|
|
168
|
+
async onDismiss() {
|
|
169
|
+
// allow ember test helpers to be aware of when the `close` event fires
|
|
170
|
+
// when using `click` or other helpers from '@ember/test-helpers'
|
|
171
|
+
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
|
|
172
|
+
if (DEBUG && this.element.open) {
|
|
173
|
+
let token = waiter.beginAsync();
|
|
174
|
+
let listener = () => {
|
|
175
|
+
waiter.endAsync(token);
|
|
176
|
+
this.element.removeEventListener('close', listener);
|
|
177
|
+
};
|
|
178
|
+
this.element.addEventListener('close', listener);
|
|
179
|
+
}
|
|
180
|
+
|
|
160
181
|
// Make modal dialog invisible using the native `close` method
|
|
161
182
|
this.element.close();
|
|
162
183
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// COPY > BUTTON
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
// mostly the hds-button but with a few style tweaks
|
|
11
|
+
// so the CSS is scoped to the component class (we're not changing any of the other class names)
|
|
12
|
+
.hds-copy-button {
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
|
|
15
|
+
.hds-button__icon {
|
|
16
|
+
color: var(--token-color-foreground-action);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.hds-copy-button--status-success {
|
|
20
|
+
.hds-button__icon {
|
|
21
|
+
color: var(--token-color-foreground-success);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.hds-copy-button--status-error {
|
|
26
|
+
.hds-button__icon {
|
|
27
|
+
color: var(--token-color-foreground-critical);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// COPY > SNIPPET
|
|
8
|
+
//
|
|
9
|
+
@use "../../mixins/focus-ring" as *;
|
|
10
|
+
|
|
11
|
+
.hds-copy-snippet {
|
|
12
|
+
@include hds-focus-ring-with-pseudo-element();
|
|
13
|
+
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
width: 100%;
|
|
19
|
+
padding: 6px 4px;
|
|
20
|
+
white-space: normal;
|
|
21
|
+
text-align: left;
|
|
22
|
+
overflow-wrap: anywhere;
|
|
23
|
+
border: 1px solid transparent;
|
|
24
|
+
border-radius: 5px;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.hds-copy-snippet--color-primary {
|
|
29
|
+
color: var(--token-color-foreground-action);
|
|
30
|
+
background-color: var(--token-color-surface-interactive);
|
|
31
|
+
|
|
32
|
+
&:hover,
|
|
33
|
+
&.mock-hover {
|
|
34
|
+
color: var(--token-color-foreground-action-hover);
|
|
35
|
+
border-color: var(--token-color-border-strong);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:active,
|
|
39
|
+
&.mock-active {
|
|
40
|
+
color: var(--token-color-foreground-action-active);
|
|
41
|
+
background-color: var(--token-color-surface-interactive-active);
|
|
42
|
+
border-color: var(--token-color-border-strong);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.hds-copy-snippet--color-secondary {
|
|
47
|
+
color: var(--token-color-foreground-primary);
|
|
48
|
+
background-color: var(--token-color-surface-interactive);
|
|
49
|
+
|
|
50
|
+
&:hover,
|
|
51
|
+
&.mock-hover {
|
|
52
|
+
border-color: var(--token-color-border-strong);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:active,
|
|
56
|
+
&.mock-active {
|
|
57
|
+
background-color: var(--token-color-surface-interactive-active);
|
|
58
|
+
border-color: var(--token-color-border-strong);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hds-copy-snippet__icon {
|
|
62
|
+
color: var(--token-color-foreground-action);
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
color: var(--token-color-foreground-action-hover);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:active {
|
|
69
|
+
color: var(--token-color-foreground-action-active);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:focus {
|
|
73
|
+
color: var(--token-color-foreground-action);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.hds-copy-snippet--status-success {
|
|
79
|
+
.hds-copy-snippet__icon {
|
|
80
|
+
color: var(--token-color-foreground-success);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.hds-copy-snippet--status-error {
|
|
85
|
+
.hds-copy-snippet__icon {
|
|
86
|
+
color: var(--token-color-foreground-critical);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.hds-copy-snippet__text {
|
|
91
|
+
flex: 1 0 0;
|
|
92
|
+
max-width: calc(100% - 24px);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.hds-copy-snippet__icon {
|
|
96
|
+
flex: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.hds-copy-snippet--width-full {
|
|
100
|
+
justify-content: center;
|
|
101
|
+
|
|
102
|
+
.hds-copy-snippet__text {
|
|
103
|
+
flex: 0 0 auto;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.hds-copy-snippet__text--truncated {
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
white-space: nowrap;
|
|
110
|
+
text-overflow: ellipsis;
|
|
111
|
+
}
|
|
@@ -279,60 +279,8 @@ $hds-dropdown-toggle-border-radius: $hds-button-border-radius;
|
|
|
279
279
|
.hds-dropdown-list-item--variant-copy-item {
|
|
280
280
|
width: 100%;
|
|
281
281
|
padding: 10px 16px 12px;
|
|
282
|
-
|
|
283
|
-
button {
|
|
284
|
-
display: flex;
|
|
285
|
-
justify-content: space-between;
|
|
286
|
-
width: 100%;
|
|
287
|
-
padding: 12px 8px;
|
|
288
|
-
color: var(--token-color-foreground-primary);
|
|
289
|
-
background-color: transparent;
|
|
290
|
-
border: 1px solid var(--token-color-border-primary);
|
|
291
|
-
border-radius: 5px;
|
|
292
|
-
|
|
293
|
-
&:hover,
|
|
294
|
-
&.mock-hover {
|
|
295
|
-
background-color: var(--token-color-surface-interactive-hover);
|
|
296
|
-
cursor: pointer;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
@include hds-focus-ring-basic();
|
|
300
|
-
|
|
301
|
-
&:focus,
|
|
302
|
-
&.mock-focus {
|
|
303
|
-
// TODO this focus is just way too complex
|
|
304
|
-
background-color: var(--token-color-surface-action);
|
|
305
|
-
border-color: var(--token-color-focus-action-internal);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
&:active,
|
|
309
|
-
&.mock-active {
|
|
310
|
-
background-color: var(--token-color-surface-interactive-active);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
&.is-success {
|
|
314
|
-
background-color: var(--token-color-surface-success);
|
|
315
|
-
border-color: var(--token-color-border-success);
|
|
316
|
-
|
|
317
|
-
.hds-dropdown-list-item__copy-item-icon {
|
|
318
|
-
color: var(--token-color-foreground-success);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.hds-dropdown-list-item__copy-item-text {
|
|
325
|
-
overflow: hidden;
|
|
326
|
-
white-space: nowrap;
|
|
327
|
-
text-align: left;
|
|
328
|
-
text-overflow: ellipsis;
|
|
329
282
|
}
|
|
330
283
|
|
|
331
|
-
.hds-dropdown-list-item__copy-item-icon {
|
|
332
|
-
flex: none;
|
|
333
|
-
margin-left: 8px;
|
|
334
|
-
color: var(--token-color-foreground-action);
|
|
335
|
-
}
|
|
336
284
|
|
|
337
285
|
// HDS::DROPDOWN::LIST-ITEM::DESCRIPTION
|
|
338
286
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/design-system-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Helios Design System Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hashicorp",
|
|
@@ -40,13 +40,15 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@ember/render-modifiers": "^2.0.5",
|
|
43
|
+
"@ember/test-waiters": "^3.0.2",
|
|
43
44
|
"@hashicorp/design-system-tokens": "^1.7.0",
|
|
44
|
-
"@hashicorp/ember-flight-icons": "^3.0.
|
|
45
|
+
"@hashicorp/ember-flight-icons": "^3.0.9",
|
|
45
46
|
"dialog-polyfill": "^0.5.6",
|
|
46
47
|
"ember-a11y-refocus": "^3.0.2",
|
|
47
48
|
"ember-auto-import": "^2.6.3",
|
|
48
49
|
"ember-cached-decorator-polyfill": "^0.1.4",
|
|
49
50
|
"ember-cli-babel": "^7.26.11",
|
|
51
|
+
"ember-cli-clipboard": "^1.0.0",
|
|
50
52
|
"ember-cli-htmlbars": "^6.2.0",
|
|
51
53
|
"ember-cli-sass": "^10.0.1",
|
|
52
54
|
"ember-composable-helpers": "^4.5.0",
|
|
@@ -73,7 +75,6 @@
|
|
|
73
75
|
"ember-a11y-testing": "^5.2.1",
|
|
74
76
|
"ember-body-class": "^3.0.0",
|
|
75
77
|
"ember-cli": "~4.12.1",
|
|
76
|
-
"ember-cli-clipboard": "^1.0.0",
|
|
77
78
|
"ember-cli-dependency-checker": "^3.3.1",
|
|
78
79
|
"ember-cli-deprecation-workflow": "^2.1.0",
|
|
79
80
|
"ember-cli-inject-live-reload": "^2.1.0",
|