@brightspace-ui/labs 1.4.0 → 1.5.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/package.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "type": "module",
5
5
  "repository": "https://github.com/BrightspaceUI/labs.git",
6
6
  "exports": {
7
+ "./components/checkbox-drawer.js": "./src/components/checkbox-drawer/checkbox-drawer.js",
7
8
  "./components/community-button.js": "./src/components/community/community-button.js",
8
9
  "./components/community-link.js": "./src/components/community/community-link.js",
9
10
  "./components/community-url-factory.js": "./src/components/community/community-url-factory.js",
@@ -46,5 +47,5 @@
46
47
  "@brightspace-ui/core": "^2",
47
48
  "lit": "^2"
48
49
  },
49
- "version": "1.4.0"
50
+ "version": "1.5.0"
50
51
  }
@@ -0,0 +1,29 @@
1
+ # d2l-labs-checkbox-drawer
2
+
3
+ The `d2l-labs-checkbox-drawer` element can be used to get a checkbox with a description. When checked, drawer contents are revealed underneath.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <script type="module">
9
+ import '@brightspace-ui/labs/components/checkbox-drawer.js';
10
+ </script>
11
+ <d2l-labs-checkbox-drawer>
12
+ <p>My drawer content.</p>
13
+ </d2l-labs-checkbox-drawer>
14
+ ```
15
+
16
+ **Properties:**
17
+
18
+ | Property | Type | Description |
19
+ |--|--|--|
20
+ | `checked` | Boolean | True if the checkbox is checked. False if not checked. |
21
+ | `description` | String | Extra information that is displayed beneath the `label`. Optionally used when `label` is used. |
22
+ | `label` | String | Provides visible information about the component. |
23
+ | `read-only` | Boolean | Makes the checkbox non-interactable, replacing it with checkmark if checked is true or an X otherwise |
24
+
25
+ **Events:**
26
+
27
+ - `d2l-labs-checkbox-drawer-checked-change`: dispatched when checkbox's state changes.
28
+ - `d2l-labs-checkbox-drawer-expand`: dispatched when the drawer starts to expand. As per the [expand collapse component](https://github.com/BrightspaceUI/core/tree/master/components/expand-collapse), the `detail` contains an `expandComplete` promise that can be waited on to determine when the content has finished expanding.
29
+ - `d2l-labs-checkbox-drawer-collapse`: dispatched when the drawer starts to collapse. As per the [expand collapse component](https://github.com/BrightspaceUI/core/tree/master/components/expand-collapse), the `detail` contains a `collapseComplete` promise that can be waited on to determine when the content has finished collapsing.
@@ -0,0 +1,111 @@
1
+ import '@brightspace-ui/core/components/colors/colors.js';
2
+ import '@brightspace-ui/core/components/expand-collapse/expand-collapse-content.js';
3
+ import '@brightspace-ui/core/components/inputs/input-checkbox.js';
4
+ import '@brightspace-ui/core/components/inputs/input-checkbox-spacer.js';
5
+ import '@brightspace-ui/core/components/icons/icon.js';
6
+ import { css, html, LitElement } from 'lit';
7
+ import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
8
+ import { LocalizeLabsElement } from '../localize-labs-element.js';
9
+ import { SkeletonMixin } from '@brightspace-ui/core/components/skeleton/skeleton-mixin.js';
10
+
11
+ class CheckboxDrawer extends LocalizeLabsElement(SkeletonMixin(LitElement)) {
12
+
13
+ static get properties() {
14
+ return {
15
+ checked: { type: Boolean },
16
+ description: { type: String },
17
+ label: { type: String },
18
+ readOnly: { type: Boolean, attribute: 'read-only' },
19
+ _expandCollapseBusy: { state: true }
20
+ };
21
+ }
22
+
23
+ static get styles() {
24
+ return [super.styles, bodyCompactStyles, css`
25
+ :host {
26
+ display: block;
27
+ }
28
+
29
+ .d2l-input-checkbox, .d2l-input-checkbox-spacer {
30
+ margin-bottom: 0;
31
+ }
32
+
33
+ .d2l-input-checkbox-description {
34
+ color: var(--d2l-color-tungsten);
35
+ font-size: 0.7rem;
36
+ width: fit-content;
37
+ }
38
+
39
+ .d2l-checkbox-content-margin {
40
+ margin-top: 18px;
41
+ }
42
+
43
+ .d2l-input-read-only-label {
44
+ display: inline-block;
45
+ margin-left: 0.5rem;
46
+ }
47
+ `];
48
+ }
49
+
50
+ constructor() {
51
+ super();
52
+ this.checked = false;
53
+ this._expandCollapseBusy = false;
54
+ }
55
+
56
+ render() {
57
+ return html`
58
+ ${this.readOnly ? html `
59
+ <d2l-icon class="d2l-skeletize" icon="${this.checked ? 'tier1:check' : 'tier1:close-default'}"></d2l-icon>
60
+ <div class="d2l-body-compact d2l-input-read-only-label d2l-skeletize">${this.label}</div>
61
+ ` : html`
62
+ <d2l-input-checkbox
63
+ ?checked="${this.checked}"
64
+ class="d2l-input-checkbox"
65
+ ?skeleton="${this.skeleton}"
66
+ description=${this.localize(`components:checkboxDrawer:checkbox${this.checked ? 'Expanded' : 'Collapsed'}`)}
67
+ @change="${this._onCheckboxChange}">${this.label}</d2l-input-checkbox>
68
+ `}
69
+ <d2l-input-checkbox-spacer class="d2l-input-checkbox-spacer">
70
+ <div class="d2l-input-checkbox-description d2l-skeletize">${this.description}</div>
71
+ </d2l-input-checkbox-spacer>
72
+ <d2l-input-checkbox-spacer class="d2l-input-checkbox-spacer">
73
+ <d2l-expand-collapse-content ?expanded="${this.checked}" aria-busy=${this._expandCollapseBusy ? 'true' : 'false'} @d2l-expand-collapse-content-expand="${this._onExpandCollapseContentToggled}" @d2l-expand-collapse-content-collapse="${this._onExpandCollapseContentToggled}">
74
+ <div class="d2l-checkbox-content-margin"></div>
75
+ <slot></slot>
76
+ </d2l-expand-collapse-content>
77
+ </d2l-input-checkbox-spacer>
78
+ `;
79
+ }
80
+
81
+ _onCheckboxChange(e) {
82
+ this.checked = e.target.checked;
83
+
84
+ this.dispatchEvent(
85
+ new CustomEvent('d2l-labs-checkbox-drawer-checked-change', {
86
+ bubbles: true,
87
+ composed: false,
88
+ detail: { checked: this.checked }
89
+ })
90
+ );
91
+ }
92
+
93
+ async _onExpandCollapseContentToggled(e) {
94
+ const action = e.target.expanded ? 'expandComplete' : 'collapseComplete';
95
+ const eventName = e.target.expanded ? 'd2l-labs-checkbox-drawer-expand' : 'd2l-labs-checkbox-drawer-collapse';
96
+
97
+ this.dispatchEvent(
98
+ new CustomEvent(eventName, {
99
+ bubbles: true,
100
+ composed: false,
101
+ detail: e.detail
102
+ })
103
+ );
104
+
105
+ this._expandCollapseBusy = true;
106
+ await e.detail[action];
107
+ this._expandCollapseBusy = false;
108
+ }
109
+ }
110
+
111
+ customElements.define('d2l-labs-checkbox-drawer', CheckboxDrawer);
package/src/lang/ar.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "تم طي خانة الاختيار", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "تم توسيع خانة الاختيار", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "إلغاء",
3
5
  "components:optInFlyout:close": "إغلاق مربع الحوار هذا",
4
6
  "components:optInFlyout:done": "تم",
package/src/lang/cy.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Wedi crebachu blwch ticio", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Wedi ehangu blwch ticio", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Canslo",
3
5
  "components:optInFlyout:close": "Cau’r deialog hwn",
4
6
  "components:optInFlyout:done": "Wedi Gorffen",
package/src/lang/da.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Afkrydsningsfelt skjult", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Afkrydsningsfelt udvidet", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Annuller",
3
5
  "components:optInFlyout:close": "Luk denne dialogboks",
4
6
  "components:optInFlyout:done": "Udført",
package/src/lang/de.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Kontrollkästchen ausgeblendet", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Kontrollkästchen eingeblendet", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Abbrechen",
3
5
  "components:optInFlyout:close": "Dieses Dialogfeld schließen",
4
6
  "components:optInFlyout:done": "Fertig",
package/src/lang/en.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Checkbox collapsed", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Checkbox expanded", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Cancel",
3
5
  "components:optInFlyout:close": "Close this dialog",
4
6
  "components:optInFlyout:done": "Done",
package/src/lang/es-es.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Casilla de verificación contraída", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Casilla de verificación expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Cancelar",
3
5
  "components:optInFlyout:close": "Cerrar este cuadro de diálogo",
4
6
  "components:optInFlyout:done": "Listo",
package/src/lang/es.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Casilla de selección contraída", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Casilla de selección expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Cancelar",
3
5
  "components:optInFlyout:close": "Cerrar este cuadro de diálogo",
4
6
  "components:optInFlyout:done": "Listo",
package/src/lang/fr-fr.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Case à cocher réduite", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Case à cocher développée", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Annuler",
3
5
  "components:optInFlyout:close": "Fermer cette boîte de dialogue",
4
6
  "components:optInFlyout:done": "Terminé",
package/src/lang/fr.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Case à cocher réduite", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Case à cocher agrandie", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Annuler",
3
5
  "components:optInFlyout:close": "Fermer cette boîte de dialogue",
4
6
  "components:optInFlyout:done": "Terminé",
package/src/lang/hi.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "चेकबॉक्स छोटा हो गया", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "चेकबॉक्स बड़ा हो गया", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "रद्द करें",
3
5
  "components:optInFlyout:close": "यह संवाद बंद करें",
4
6
  "components:optInFlyout:done": "पूर्ण हो गया",
package/src/lang/ja.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "折りたたまれたチェックボックス", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "展開されたチェックボックス", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "キャンセル",
3
5
  "components:optInFlyout:close": "このダイアログを閉じる",
4
6
  "components:optInFlyout:done": "終了",
package/src/lang/ko.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "확인란이 축소됨", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "확인란이 확장됨", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "취소",
3
5
  "components:optInFlyout:close": "이 대화 상자 닫기",
4
6
  "components:optInFlyout:done": "완료",
package/src/lang/nl.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Selectievakje samengevouwen", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Selectievakje uitgevouwen", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Annuleren",
3
5
  "components:optInFlyout:close": "Dit dialoogvenster sluiten",
4
6
  "components:optInFlyout:done": "Gereed",
package/src/lang/pt.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Caixa de seleção recolhida", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Caixa de seleção expandida", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Cancelar",
3
5
  "components:optInFlyout:close": "Fechar esta caixa de diálogo",
4
6
  "components:optInFlyout:done": "Concluído",
package/src/lang/sv.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Komprimerad kryssruta", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Expanderad kryssruta", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "Avbryt",
3
5
  "components:optInFlyout:close": "Stäng dialogrutan",
4
6
  "components:optInFlyout:done": "Klar",
package/src/lang/tr.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "Onay kutusu daraltıldı", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "Onay kutusu genişletildi", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "İptal Et",
3
5
  "components:optInFlyout:close": "Bu iletişim kutusunu kapat",
4
6
  "components:optInFlyout:done": "Bitti",
package/src/lang/zh-cn.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "复选框已折叠", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "复选框已展开", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "取消",
3
5
  "components:optInFlyout:close": "关闭此对话框",
4
6
  "components:optInFlyout:done": "完成",
package/src/lang/zh-tw.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export default {
2
+ "components:checkboxDrawer:checkboxCollapsed": "核取方塊已摺疊", // Read by screen readers when focusing the collapsed (unchecked) checkbox, with the inner content hidden
3
+ "components:checkboxDrawer:checkboxExpanded": "核取方塊已展開", // Read by screen readers when focusing the expanded (checked) checkbox, with the inner content shown
2
4
  "components:optInFlyout:cancel": "取消",
3
5
  "components:optInFlyout:close": "關閉此對話方塊",
4
6
  "components:optInFlyout:done": "完成",