@hashicorp/design-system-components 1.6.1 → 1.7.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 +29 -1
- package/addon/components/hds/alert/description.hbs +4 -0
- package/addon/components/hds/alert/index.hbs +4 -0
- package/addon/components/hds/alert/index.js +5 -0
- package/addon/components/hds/alert/title.hbs +4 -0
- package/addon/components/hds/avatar/index.hbs +4 -0
- package/addon/components/hds/badge/index.hbs +4 -0
- package/addon/components/hds/badge/index.js +5 -0
- package/addon/components/hds/badge-count/index.hbs +4 -0
- package/addon/components/hds/badge-count/index.js +5 -0
- package/addon/components/hds/breadcrumb/index.hbs +4 -0
- package/addon/components/hds/breadcrumb/index.js +5 -0
- package/addon/components/hds/breadcrumb/item.hbs +4 -0
- package/addon/components/hds/breadcrumb/item.js +5 -0
- package/addon/components/hds/breadcrumb/truncation.hbs +4 -0
- package/addon/components/hds/button/index.hbs +4 -0
- package/addon/components/hds/button/index.js +5 -0
- package/addon/components/hds/button-set/index.hbs +4 -0
- package/addon/components/hds/card/container.hbs +4 -0
- package/addon/components/hds/card/container.js +5 -0
- package/addon/components/hds/disclosure/index.hbs +4 -0
- package/addon/components/hds/disclosure/index.js +5 -0
- package/addon/components/hds/dismiss-button/index.hbs +4 -0
- package/addon/components/hds/dropdown/index.hbs +4 -0
- package/addon/components/hds/dropdown/index.js +5 -0
- package/addon/components/hds/dropdown/list-item/copy-item.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/copy-item.js +5 -0
- package/addon/components/hds/dropdown/list-item/description.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/description.js +5 -0
- package/addon/components/hds/dropdown/list-item/generic.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/interactive.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/interactive.js +5 -0
- package/addon/components/hds/dropdown/list-item/separator.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/title.hbs +4 -0
- package/addon/components/hds/dropdown/list-item/title.js +5 -0
- package/addon/components/hds/dropdown/toggle/button.hbs +4 -0
- package/addon/components/hds/dropdown/toggle/button.js +5 -0
- package/addon/components/hds/dropdown/toggle/icon.hbs +4 -0
- package/addon/components/hds/dropdown/toggle/icon.js +5 -0
- package/addon/components/hds/empty-state/body.hbs +4 -0
- package/addon/components/hds/empty-state/footer.hbs +4 -0
- package/addon/components/hds/empty-state/header.hbs +4 -0
- package/addon/components/hds/empty-state/index.hbs +4 -0
- package/addon/components/hds/flyout/body.hbs +4 -0
- package/addon/components/hds/flyout/description.hbs +4 -0
- package/addon/components/hds/flyout/header.hbs +4 -0
- package/addon/components/hds/flyout/index.hbs +4 -0
- package/addon/components/hds/flyout/index.js +5 -0
- package/addon/components/hds/form/checkbox/base.hbs +4 -0
- package/addon/components/hds/form/checkbox/field.hbs +4 -0
- package/addon/components/hds/form/checkbox/group.hbs +4 -0
- package/addon/components/hds/form/error/index.hbs +4 -0
- package/addon/components/hds/form/error/index.js +5 -0
- package/addon/components/hds/form/error/message.hbs +4 -0
- package/addon/components/hds/form/field/index.hbs +4 -0
- package/addon/components/hds/form/field/index.js +5 -0
- package/addon/components/hds/form/fieldset/index.hbs +4 -0
- package/addon/components/hds/form/fieldset/index.js +5 -0
- package/addon/components/hds/form/helper-text/index.hbs +4 -0
- package/addon/components/hds/form/helper-text/index.js +5 -0
- package/addon/components/hds/form/indicator/index.hbs +4 -0
- package/addon/components/hds/form/indicator/index.js +5 -0
- package/addon/components/hds/form/label/index.hbs +4 -0
- package/addon/components/hds/form/label/index.js +5 -0
- package/addon/components/hds/form/legend/index.hbs +4 -0
- package/addon/components/hds/form/legend/index.js +5 -0
- package/addon/components/hds/form/radio/base.hbs +4 -0
- package/addon/components/hds/form/radio/field.hbs +4 -0
- package/addon/components/hds/form/radio/group.hbs +4 -0
- package/addon/components/hds/form/radio-card/description.hbs +4 -0
- package/addon/components/hds/form/radio-card/group.hbs +4 -0
- package/addon/components/hds/form/radio-card/index.hbs +4 -0
- package/addon/components/hds/form/radio-card/index.js +5 -0
- package/addon/components/hds/form/radio-card/label.hbs +4 -0
- package/addon/components/hds/form/select/base.hbs +4 -0
- package/addon/components/hds/form/select/base.js +5 -0
- package/addon/components/hds/form/select/field.hbs +4 -0
- package/addon/components/hds/form/text-input/base.hbs +4 -0
- package/addon/components/hds/form/text-input/base.js +5 -0
- package/addon/components/hds/form/text-input/field.hbs +4 -0
- package/addon/components/hds/form/textarea/base.hbs +4 -0
- package/addon/components/hds/form/textarea/base.js +5 -0
- package/addon/components/hds/form/textarea/field.hbs +4 -0
- package/addon/components/hds/form/toggle/base.hbs +4 -0
- package/addon/components/hds/form/toggle/base.js +5 -0
- package/addon/components/hds/form/toggle/field.hbs +4 -0
- package/addon/components/hds/form/toggle/group.hbs +4 -0
- package/addon/components/hds/form/utils/getElementId.js +5 -0
- package/addon/components/hds/form/utils/setAriaDescribedBy.js +5 -0
- package/addon/components/hds/icon-tile/index.hbs +4 -0
- package/addon/components/hds/icon-tile/index.js +5 -0
- package/addon/components/hds/interactive/index.js +5 -0
- package/addon/components/hds/link/inline.js +5 -0
- package/addon/components/hds/link/standalone.js +5 -0
- package/addon/components/hds/modal/body.hbs +4 -0
- package/addon/components/hds/modal/footer.hbs +4 -0
- package/addon/components/hds/modal/header.hbs +4 -0
- package/addon/components/hds/modal/index.hbs +4 -0
- package/addon/components/hds/modal/index.js +5 -0
- package/addon/components/hds/pagination/compact/index.hbs +4 -0
- package/addon/components/hds/pagination/compact/index.js +5 -0
- package/addon/components/hds/pagination/info/index.hbs +4 -0
- package/addon/components/hds/pagination/info/index.js +5 -0
- package/addon/components/hds/pagination/nav/arrow.hbs +4 -0
- package/addon/components/hds/pagination/nav/arrow.js +5 -0
- package/addon/components/hds/pagination/nav/ellipsis.hbs +4 -0
- package/addon/components/hds/pagination/nav/number.hbs +4 -0
- package/addon/components/hds/pagination/nav/number.js +5 -0
- package/addon/components/hds/pagination/numbered/index.hbs +5 -0
- package/addon/components/hds/pagination/numbered/index.js +5 -0
- package/addon/components/hds/pagination/size-selector/index.hbs +7 -1
- package/addon/components/hds/pagination/size-selector/index.js +17 -0
- package/addon/components/hds/stepper/step/indicator.hbs +4 -0
- package/addon/components/hds/stepper/step/indicator.js +5 -0
- package/addon/components/hds/stepper/task/indicator.hbs +4 -0
- package/addon/components/hds/stepper/task/indicator.js +5 -0
- package/addon/components/hds/table/index.hbs +12 -4
- package/addon/components/hds/table/index.js +60 -5
- package/addon/components/hds/table/td.hbs +4 -0
- package/addon/components/hds/table/td.js +5 -0
- package/addon/components/hds/table/th-sort.hbs +4 -0
- package/addon/components/hds/table/th-sort.js +22 -9
- package/addon/components/hds/table/th.hbs +4 -0
- package/addon/components/hds/table/th.js +5 -0
- package/addon/components/hds/table/tr.hbs +4 -0
- package/addon/components/hds/tabs/index.hbs +4 -0
- package/addon/components/hds/tabs/index.js +5 -0
- package/addon/components/hds/tabs/panel.hbs +4 -0
- package/addon/components/hds/tabs/panel.js +5 -0
- package/addon/components/hds/tabs/tab.hbs +4 -0
- package/addon/components/hds/tabs/tab.js +5 -0
- package/addon/components/hds/tag/index.hbs +4 -0
- package/addon/components/hds/tag/index.js +5 -0
- package/addon/components/hds/toast/index.hbs +4 -0
- package/addon/components/hds/yield/index.hbs +4 -0
- package/addon/helpers/hds-link-to-models.js +5 -0
- package/addon/helpers/hds-link-to-query.js +5 -0
- package/app/components/hds/alert/description.js +5 -0
- package/app/components/hds/alert/index.js +5 -0
- package/app/components/hds/alert/title.js +5 -0
- package/app/components/hds/avatar/index.js +5 -0
- package/app/components/hds/badge/index.js +5 -0
- package/app/components/hds/badge-count/index.js +5 -0
- package/app/components/hds/breadcrumb/index.js +5 -0
- package/app/components/hds/breadcrumb/item.js +5 -0
- package/app/components/hds/breadcrumb/truncation.js +5 -0
- package/app/components/hds/button/index.js +5 -0
- package/app/components/hds/button-set/index.js +5 -0
- package/app/components/hds/card/container.js +5 -0
- package/app/components/hds/disclosure/index.js +5 -0
- package/app/components/hds/dismiss-button/index.js +5 -0
- package/app/components/hds/dropdown/index.js +5 -0
- package/app/components/hds/dropdown/list-item/copy-item.js +5 -0
- package/app/components/hds/dropdown/list-item/description.js +5 -0
- package/app/components/hds/dropdown/list-item/generic.js +5 -0
- package/app/components/hds/dropdown/list-item/interactive.js +5 -0
- package/app/components/hds/dropdown/list-item/separator.js +5 -0
- package/app/components/hds/dropdown/list-item/title.js +5 -0
- package/app/components/hds/dropdown/toggle/button.js +5 -0
- package/app/components/hds/dropdown/toggle/icon.js +5 -0
- package/app/components/hds/empty-state/body.js +5 -0
- package/app/components/hds/empty-state/footer.js +5 -0
- package/app/components/hds/empty-state/header.js +5 -0
- package/app/components/hds/empty-state/index.js +5 -0
- package/app/components/hds/flyout/body.js +5 -0
- package/app/components/hds/flyout/description.js +5 -0
- package/app/components/hds/flyout/header.js +5 -0
- package/app/components/hds/flyout/index.js +5 -0
- package/app/components/hds/form/checkbox/base.js +5 -0
- package/app/components/hds/form/checkbox/field.js +5 -0
- package/app/components/hds/form/checkbox/group.js +5 -0
- package/app/components/hds/form/error/index.js +5 -0
- package/app/components/hds/form/error/message.js +5 -0
- package/app/components/hds/form/field/index.js +5 -0
- package/app/components/hds/form/fieldset/index.js +5 -0
- package/app/components/hds/form/helper-text/index.js +5 -0
- package/app/components/hds/form/indicator/index.js +5 -0
- package/app/components/hds/form/label/index.js +5 -0
- package/app/components/hds/form/legend/index.js +5 -0
- package/app/components/hds/form/radio/base.js +5 -0
- package/app/components/hds/form/radio/field.js +5 -0
- package/app/components/hds/form/radio/group.js +5 -0
- package/app/components/hds/form/radio-card/description.js +5 -0
- package/app/components/hds/form/radio-card/group.js +5 -0
- package/app/components/hds/form/radio-card/index.js +5 -0
- package/app/components/hds/form/radio-card/label.js +5 -0
- package/app/components/hds/form/select/base.js +5 -0
- package/app/components/hds/form/select/field.js +5 -0
- package/app/components/hds/form/text-input/base.js +5 -0
- package/app/components/hds/form/text-input/field.js +5 -0
- package/app/components/hds/form/textarea/base.js +5 -0
- package/app/components/hds/form/textarea/field.js +5 -0
- package/app/components/hds/form/toggle/base.js +5 -0
- package/app/components/hds/form/toggle/field.js +5 -0
- package/app/components/hds/form/toggle/group.js +5 -0
- package/app/components/hds/icon-tile/index.js +5 -0
- package/app/components/hds/interactive/index.js +5 -0
- package/app/components/hds/link/inline.js +5 -0
- package/app/components/hds/link/standalone.js +5 -0
- package/app/components/hds/modal/body.js +5 -0
- package/app/components/hds/modal/footer.js +5 -0
- package/app/components/hds/modal/header.js +5 -0
- package/app/components/hds/modal/index.js +5 -0
- package/app/components/hds/pagination/compact/index.js +5 -0
- package/app/components/hds/pagination/info.js +5 -0
- package/app/components/hds/pagination/nav/arrow.js +5 -0
- package/app/components/hds/pagination/nav/ellipsis.js +5 -0
- package/app/components/hds/pagination/nav/number.js +5 -0
- package/app/components/hds/pagination/numbered/index.js +5 -0
- package/app/components/hds/pagination/size-selector.js +5 -0
- package/app/components/hds/stepper/step/indicator.js +5 -0
- package/app/components/hds/stepper/task/indicator.js +5 -0
- package/app/components/hds/table/index.js +5 -0
- package/app/components/hds/table/td.js +5 -0
- package/app/components/hds/table/th-sort.js +5 -0
- package/app/components/hds/table/th.js +5 -0
- package/app/components/hds/table/tr.js +5 -0
- package/app/components/hds/tabs/index.js +5 -0
- package/app/components/hds/tabs/panel.js +5 -0
- package/app/components/hds/tabs/tab.js +5 -0
- package/app/components/hds/tag/index.js +5 -0
- package/app/components/hds/toast/index.js +5 -0
- package/app/components/hds/yield/index.js +5 -0
- package/app/helpers/hds-link-to-models.js +5 -0
- package/app/helpers/hds-link-to-query.js +5 -0
- package/app/styles/@hashicorp/design-system-components.scss +5 -0
- package/app/styles/@hashicorp/design-system-power-select-overrides.scss +5 -0
- package/app/styles/components/alert.scss +5 -0
- package/app/styles/components/avatar.scss +5 -0
- package/app/styles/components/badge-count.scss +5 -0
- package/app/styles/components/badge.scss +5 -0
- package/app/styles/components/breadcrumb.scss +5 -0
- package/app/styles/components/button-set.scss +5 -0
- package/app/styles/components/button.scss +5 -0
- package/app/styles/components/card/container.scss +5 -0
- package/app/styles/components/card/index.scss +5 -0
- package/app/styles/components/disclosure.scss +5 -0
- package/app/styles/components/dismiss-button.scss +5 -0
- package/app/styles/components/dropdown.scss +5 -0
- package/app/styles/components/empty-state.scss +5 -0
- package/app/styles/components/flyout.scss +5 -0
- package/app/styles/components/form/checkbox.scss +5 -0
- package/app/styles/components/form/error.scss +5 -0
- package/app/styles/components/form/field.scss +5 -0
- package/app/styles/components/form/group.scss +5 -0
- package/app/styles/components/form/helper-text.scss +5 -0
- package/app/styles/components/form/index.scss +5 -0
- package/app/styles/components/form/indicator.scss +5 -0
- package/app/styles/components/form/label.scss +5 -0
- package/app/styles/components/form/legend.scss +5 -0
- package/app/styles/components/form/radio-card.scss +5 -0
- package/app/styles/components/form/radio.scss +5 -0
- package/app/styles/components/form/select.scss +5 -0
- package/app/styles/components/form/text-input.scss +5 -0
- package/app/styles/components/form/textarea.scss +5 -0
- package/app/styles/components/form/toggle.scss +5 -0
- package/app/styles/components/icon-tile.scss +5 -0
- package/app/styles/components/link/index.scss +5 -0
- package/app/styles/components/link/inline.scss +5 -0
- package/app/styles/components/link/standalone.scss +5 -0
- package/app/styles/components/modal.scss +5 -0
- package/app/styles/components/pagination.scss +39 -26
- package/app/styles/components/stepper/index.scss +5 -0
- package/app/styles/components/stepper/step-indicator.scss +5 -0
- package/app/styles/components/stepper/task-indicator.scss +5 -0
- package/app/styles/components/table.scss +36 -15
- package/app/styles/components/tabs.scss +10 -0
- package/app/styles/components/tag.scss +5 -0
- package/app/styles/components/toast.scss +5 -0
- package/app/styles/mixins/_focus-ring.scss +5 -0
- package/blueprints/hds-component/files/addon/components/hds/__name__/index.hbs +4 -0
- package/blueprints/hds-component/files/addon/components/hds/__name__/index.js +5 -0
- package/blueprints/hds-component/files/app/components/hds/__name__/index.js +5 -0
- package/blueprints/hds-component/files/app/styles/components/__name__.scss +5 -0
- package/blueprints/hds-component/index.js +5 -0
- package/blueprints/hds-component-test/files/tests/dummy/app/routes/components/__name__.js +5 -0
- package/blueprints/hds-component-test/files/tests/dummy/app/styles/pages/__dummyCSSFileName__.scss +5 -0
- package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +6 -2
- package/blueprints/hds-component-test/files/tests/integration/components/hds/__name__/index-test.js +5 -0
- package/blueprints/hds-component-test/index.js +6 -1
- package/config/environment.js +5 -0
- package/index.js +5 -0
- package/package.json +28 -28
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<label class={{this.classNames}} {{did-insert this.setAriaDescribedBy}} {{style maxWidth=@maxWidth}}>
|
|
2
6
|
<span class="hds-form-radio-card__content">
|
|
3
7
|
{{yield (hash Icon=(component "flight-icon" size="24" isInlineBlock=false))}}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
{{! Notice: this is not the native HTML <textarea> but the Ember component <Textarea> }}
|
|
2
6
|
<Textarea class={{this.classNames}} {{style width=@width height=@height}} rows="4" ...attributes @value={{@value}} />
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<Hds::Form::Fieldset @layout={{@layout}} @isRequired={{@isRequired}} @isOptional={{@isOptional}} ...attributes as |F|>
|
|
2
6
|
{{! Notice: the order of the elements is not relevant here, because it's controlled at "Hds::Form::Fieldset" component level }}
|
|
3
7
|
{{yield (hash Legend=F.Legend isRequired=F.isRequired isOptional=F.isOptional)}}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<div class="hds-pagination" ...attributes>
|
|
2
6
|
{{#if this.showInfo}}
|
|
3
7
|
<Hds::Pagination::Info
|
|
@@ -58,6 +62,7 @@
|
|
|
58
62
|
{{#if this.showSizeSelector}}
|
|
59
63
|
<Hds::Pagination::SizeSelector
|
|
60
64
|
@pageSizes={{this.pageSizes}}
|
|
65
|
+
@label={{@sizeSelectorLabel}}
|
|
61
66
|
@selectedSize={{this.currentPageSize}}
|
|
62
67
|
@onChange={{this.onPageSizeChange}}
|
|
63
68
|
/>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<div class="hds-pagination-size-selector" ...attributes>
|
|
2
|
-
<label class="hds-typography-body-100 hds-font-weight-medium" for={{this.SizeSelectorId}}>
|
|
6
|
+
<label class="hds-typography-body-100 hds-font-weight-medium" for={{this.SizeSelectorId}}>
|
|
7
|
+
{{this.label}}
|
|
8
|
+
</label>
|
|
3
9
|
<Hds::Form::Select::Base id={{this.SizeSelectorId}} {{on "change" this.onChange}} as |S|>
|
|
4
10
|
<S.Options>
|
|
5
11
|
{{#each this.pageSizes as |size|}}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import Component from '@glimmer/component';
|
|
2
7
|
import { assert } from '@ember/debug';
|
|
3
8
|
import { guidFor } from '@ember/object/internals';
|
|
@@ -45,6 +50,18 @@ export default class HdsPaginationSizeSelectorComponent extends Component {
|
|
|
45
50
|
return selectedSize;
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @param label
|
|
55
|
+
* @type string
|
|
56
|
+
* @default "Items per page"
|
|
57
|
+
* @description The label text for the select
|
|
58
|
+
*/
|
|
59
|
+
get label() {
|
|
60
|
+
let { label = 'Items per page' } = this.args;
|
|
61
|
+
|
|
62
|
+
return label;
|
|
63
|
+
}
|
|
64
|
+
|
|
48
65
|
@action
|
|
49
66
|
onChange(e) {
|
|
50
67
|
let { onChange } = this.args;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<div class={{this.classNames}} ...attributes aria-label={{@status}}>
|
|
2
6
|
<div class="hds-stepper-indicator-step__svg-hexagon">
|
|
3
7
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<table class={{this.classNames}} ...attributes>
|
|
2
6
|
{{#if @columns}}
|
|
3
7
|
<caption class="sr-only" aria-live="polite">{{@caption}} {{this.sortedMessageText}}</caption>
|
|
@@ -10,8 +14,7 @@
|
|
|
10
14
|
{{#each @columns as |column|}}
|
|
11
15
|
{{#if column.isSortable}}
|
|
12
16
|
<Hds::Table::ThSort
|
|
13
|
-
@
|
|
14
|
-
@sortOrder={{this.sortOrder}}
|
|
17
|
+
@sortOrder={{if (eq column.key this.sortBy) this.sortOrder}}
|
|
15
18
|
@onClick={{fn this.setSortBy column.key}}
|
|
16
19
|
@align={{column.align}}
|
|
17
20
|
@width={{column.width}}
|
|
@@ -32,13 +35,18 @@
|
|
|
32
35
|
</thead>
|
|
33
36
|
<tbody class="hds-table__tbody">
|
|
34
37
|
{{#if @columns}}
|
|
35
|
-
{{
|
|
38
|
+
{{! ----------------------------------------------------------------------------------------
|
|
39
|
+
IMPORTANT: we loop on the `model` array and for each record
|
|
40
|
+
we yield the Tr/Td/Th elements _and_ the record itself as `data`
|
|
41
|
+
this means the consumer will *have to* use the `data` key to access it in their template
|
|
42
|
+
-------------------------------------------------------------------------------------------- }}
|
|
43
|
+
{{#each (sort-by this.getSortCriteria @model) key=this.identityKey as |record|}}
|
|
36
44
|
{{yield
|
|
37
45
|
(hash
|
|
38
46
|
Tr=(component "hds/table/tr")
|
|
39
47
|
Th=(component "hds/table/th" scope="row")
|
|
40
48
|
Td=(component "hds/table/td" align=@align)
|
|
41
|
-
data=
|
|
49
|
+
data=record
|
|
42
50
|
)
|
|
43
51
|
to="body"
|
|
44
52
|
}}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import Component from '@glimmer/component';
|
|
2
7
|
import { action } from '@ember/object';
|
|
3
8
|
import { tracked } from '@glimmer/tracking';
|
|
@@ -11,10 +16,61 @@ const DEFAULT_VALIGN = 'top';
|
|
|
11
16
|
export default class HdsTableIndexComponent extends Component {
|
|
12
17
|
@tracked sortBy = this.args.sortBy;
|
|
13
18
|
@tracked sortOrder = this.args.sortOrder || 'asc';
|
|
14
|
-
@tracked sortedMessageText = '';
|
|
15
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @param getSortCriteria
|
|
22
|
+
* @type {string | function}
|
|
23
|
+
* @default sortBy:sortOrder
|
|
24
|
+
* @description Returns the sort criteria
|
|
25
|
+
*/
|
|
16
26
|
get getSortCriteria() {
|
|
17
|
-
|
|
27
|
+
// get the current column
|
|
28
|
+
const currentColumn = this.args?.columns?.find(
|
|
29
|
+
(column) => column.key === this.sortBy
|
|
30
|
+
);
|
|
31
|
+
if (
|
|
32
|
+
// check if there is a custom sorting function associated with the current `sortBy` column (we assume the column has `isSortable`)
|
|
33
|
+
currentColumn?.sortingFunction &&
|
|
34
|
+
typeof currentColumn.sortingFunction === 'function'
|
|
35
|
+
) {
|
|
36
|
+
return currentColumn.sortingFunction;
|
|
37
|
+
} else {
|
|
38
|
+
// otherwise fallback to the default format "sortBy:sortOrder"
|
|
39
|
+
return `${this.sortBy}:${this.sortOrder}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param identityKey
|
|
45
|
+
* @type {string}
|
|
46
|
+
* @default '@identity'
|
|
47
|
+
* @description Returns the key to use for the table rows to provide more granular control. If no identityKey is defined, Ember's default `@identity` is used. See https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/each?anchor=each
|
|
48
|
+
* this would be relevant for any table that would have data that could update or change, i.e., polling.
|
|
49
|
+
*/
|
|
50
|
+
get identityKey() {
|
|
51
|
+
// we have to provide a way for the consumer to pass undefined because Ember tries to interpret undefined as missing an arg and therefore falls back to the default
|
|
52
|
+
if (this.args.identityKey === 'none') {
|
|
53
|
+
return undefined;
|
|
54
|
+
} else {
|
|
55
|
+
return this.args.identityKey ?? '@identity';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param sortedMessageText
|
|
61
|
+
* @type {string}
|
|
62
|
+
* @default ''
|
|
63
|
+
* @description Returns the text to display in the sorted message. If no text is defined, the default text is used.
|
|
64
|
+
*/
|
|
65
|
+
get sortedMessageText() {
|
|
66
|
+
if (this.args.sortedMessageText) {
|
|
67
|
+
return this.args.sortedMessageText;
|
|
68
|
+
} else if (this.sortBy && this.sortOrder) {
|
|
69
|
+
// we should allow the user to define a custom value here (e.g., for i18n) - tracked with HDS-965
|
|
70
|
+
return `Sorted by ${this.sortBy} ${this.sortOrder}ending`;
|
|
71
|
+
} else {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
18
74
|
}
|
|
19
75
|
|
|
20
76
|
/**
|
|
@@ -109,14 +165,13 @@ export default class HdsTableIndexComponent extends Component {
|
|
|
109
165
|
@action
|
|
110
166
|
setSortBy(column) {
|
|
111
167
|
if (this.sortBy === column) {
|
|
112
|
-
//invert the sort order
|
|
168
|
+
// check to see if the column is already sorted and invert the sort order if so
|
|
113
169
|
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
|
114
170
|
} else {
|
|
171
|
+
// otherwise, set the sort order to ascending
|
|
115
172
|
this.sortBy = column;
|
|
116
173
|
this.sortOrder = 'asc';
|
|
117
174
|
}
|
|
118
|
-
// we should allow the user to define a custom value here (e.g., for i18n) - tracked with HDS-965
|
|
119
|
-
this.sortedMessageText = `Sorted by ${this.sortBy} ${this.sortOrder}ending`;
|
|
120
175
|
|
|
121
176
|
let { onSort } = this.args;
|
|
122
177
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
{{!
|
|
2
|
+
Copyright (c) HashiCorp, Inc.
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
}}
|
|
1
5
|
<th class={{this.classNames}} aria-sort={{this.ariaSort}} {{style width=@width}} ...attributes scope="col">
|
|
2
6
|
<button type="button" {{on "click" this.onClick}}>
|
|
3
7
|
<div class="hds-table__th-sort--button-content">
|