@brightspace-ui/core 3.171.3 → 3.172.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.
@@ -313,6 +313,30 @@ Use the Add button when users need to quickly insert new items at specific locat
313
313
  | `mode` | String | Display mode of the component. Defaults to "icon" (plus icon is always visible). Other options are "icon-and-text" (plus icon and text are always visible), and "icon-when-interacted" (plus icon is only visible when hover or focus). |
314
314
  <!-- docs: end hidden content -->
315
315
 
316
+ ## Copy Button [d2l-button-copy]
317
+
318
+ Use the Copy button to enable users to copy a text value to the clipboard. The `d2l-button-copy`'s `click` event provides the `writeTextToClipboard` method for writing the text to the clipboard.
319
+
320
+ <!-- docs: demo code properties name:d2l-button-copy sandboxTitle:'Copy Button' display:block autoSize:false size:xsmall -->
321
+ ```html
322
+ <script type="module">
323
+ import '@brightspace-ui/core/components/button/button-copy.js';
324
+ document.querySelector('d2l-button-copy').addEventListener('click', e => {
325
+ e.detail.writeTextToClipboard(document.querySelector('#to-copy').textContent);
326
+ });
327
+ </script>
328
+ <span id="to-copy">Lorem ipsum dolor sit amet, consectetur adipiscing elit</span>
329
+ <d2l-button-copy></d2l-button-copy>
330
+ ```
331
+
332
+ <!-- docs: start hidden content -->
333
+ ### Properties
334
+
335
+ | Property | Type | Description |
336
+ |--|--|--|
337
+ | `disabled` | Boolean | Disables the button |
338
+ <!-- docs: end hidden content -->
339
+
316
340
  ## Floating Buttons [d2l-floating-buttons]
317
341
 
318
342
  Floating workflow buttons `<d2l-floating-buttons>` cause buttons to float or 'dock' to the bottom of the viewport when they would otherwise be below the bottom of the viewport. When their normal position becomes visible, they will undock.
@@ -0,0 +1,91 @@
1
+ import '../alert/alert-toast.js';
2
+ import './button-icon.js';
3
+ import { css, html, LitElement } from 'lit';
4
+ import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
5
+ import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
6
+
7
+ /**
8
+ * A button component that copies to the clipboard.
9
+ */
10
+ class ButtonCopy extends FocusMixin(LocalizeCoreElement(LitElement)) {
11
+
12
+ static get properties() {
13
+ return {
14
+ /**
15
+ * Disables the button
16
+ * @type {boolean}
17
+ */
18
+ disabled: { type: Boolean, reflect: true },
19
+ _iconCheckTimeoutId: { state: true },
20
+ _toastState: { state: true }
21
+ };
22
+ }
23
+
24
+ static get styles() {
25
+ return css`
26
+ :host {
27
+ display: inline-block;
28
+ }
29
+ :host([hidden]) {
30
+ display: none;
31
+ }
32
+ `;
33
+ }
34
+
35
+ constructor() {
36
+ super();
37
+ this.disabled = false;
38
+ }
39
+
40
+ static get focusElementSelector() {
41
+ return 'd2l-button-icon';
42
+ }
43
+
44
+ render() {
45
+ return html`
46
+ <d2l-button-icon ?disabled="${this.disabled}" icon="${this._iconCheckTimeoutId ? 'tier1:check' : 'tier1:copy'}" text="${this.localize('intl-common:actions:copy')}" @click="${this.#handleClick}"></d2l-button-icon>
47
+ <d2l-alert-toast
48
+ @d2l-alert-toast-close="${this.#handleToastClose}"
49
+ ?open="${this._toastState}"
50
+ type="${this._toastState === 'error' ? 'critical' : 'default'}">
51
+ ${this._toastState === 'error' ? this.localize('components.button-copy.error') : this.localize('components.button-copy.copied')}
52
+ </d2l-alert-toast>
53
+ `;
54
+ }
55
+
56
+ async #handleClick(e) {
57
+ e.stopPropagation();
58
+ if (this.disabled) return;
59
+
60
+ clearTimeout(this._iconCheckTimeoutId);
61
+
62
+ /** Dispatched when button is clicked. Use the event detail's `writeTextToClipboard` to write to the clipboard. */
63
+ this.dispatchEvent(new CustomEvent('click', {
64
+ detail: {
65
+ writeTextToClipboard: async(text) => {
66
+ text = text?.trim?.();
67
+ if (!text) return false;
68
+ try {
69
+ // writeText can throw NotAllowedError (ex. iframe without allow="clipboard-write" in Chrome)
70
+ await navigator.clipboard.writeText(text);
71
+ this._toastState = 'copied';
72
+ this._iconCheckTimeoutId = setTimeout(() => this._iconCheckTimeoutId = null, 2000);
73
+ return true;
74
+ } catch {
75
+ this._toastState = 'error';
76
+ return false;
77
+ }
78
+ }
79
+ },
80
+ bubbles: false
81
+ }));
82
+
83
+ }
84
+
85
+ #handleToastClose() {
86
+ this._toastState = null;
87
+ }
88
+
89
+ }
90
+
91
+ customElements.define('d2l-button-copy', ButtonCopy);
@@ -0,0 +1,60 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="UTF-8">
6
+ <link rel="stylesheet" href="../../demo/styles.css" type="text/css">
7
+ <script type="module">
8
+ import '../../demo/demo-page.js';
9
+ import '../../icons/icon-custom.js';
10
+ import '../../inputs/input-text.js';
11
+ import '../button-icon.js';
12
+ import '../button-copy.js';
13
+ </script>
14
+ <style>
15
+ d2l-button-copy[slot="after"] {
16
+ margin-inline-start: 0.3rem;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body unresolved>
21
+
22
+ <d2l-demo-page page-title="d2l-button-copy">
23
+
24
+ <h2>With d2l-input-text</h2>
25
+
26
+ <d2l-demo-snippet>
27
+ <template>
28
+ <d2l-input-text label="Name">
29
+ <d2l-button-copy slot="after"></d2l-button-copy>
30
+ </d2l-input-text>
31
+ <script>
32
+ (demo => {
33
+ demo.querySelector('d2l-button-copy').addEventListener('click', async(e) => {
34
+ console.log('Copied', await e.detail.writeTextToClipboard(demo.querySelector('d2l-input-text').value));
35
+ });
36
+ })(document.currentScript.parentNode);
37
+ </script>
38
+ </template>
39
+ </d2l-demo-snippet>
40
+
41
+ <h2>Disabled</h2>
42
+
43
+ <d2l-demo-snippet>
44
+ <template>
45
+ <span>Donuts are yummmmmy!</span>
46
+ <d2l-button-copy disabled></d2l-button-copy>
47
+ <script>
48
+ (demo => {
49
+ demo.querySelector('d2l-button-copy').addEventListener('click', async(e) => {
50
+ console.log('Copied', await e.detail.writeTextToClipboard(demo.querySelector('span').textContent));
51
+ });
52
+ })(document.currentScript.parentNode);
53
+ </script>
54
+ </template>
55
+ </d2l-demo-snippet>
56
+
57
+ </d2l-demo-page>
58
+
59
+ </body>
60
+ </html>
@@ -395,6 +395,34 @@
395
395
  }
396
396
  ]
397
397
  },
398
+ {
399
+ "name": "d2l-button-copy",
400
+ "path": "./components/button/button-copy.js",
401
+ "description": "A button component that copies to the clipboard.",
402
+ "attributes": [
403
+ {
404
+ "name": "disabled",
405
+ "description": "Disables the button",
406
+ "type": "boolean",
407
+ "default": "false"
408
+ }
409
+ ],
410
+ "properties": [
411
+ {
412
+ "name": "disabled",
413
+ "attribute": "disabled",
414
+ "description": "Disables the button",
415
+ "type": "boolean",
416
+ "default": "false"
417
+ }
418
+ ],
419
+ "events": [
420
+ {
421
+ "name": "click",
422
+ "description": "Dispatched when button is clicked. Use the event detail's `writeTextToClipboard` to write to the clipboard."
423
+ }
424
+ ]
425
+ },
398
426
  {
399
427
  "name": "d2l-button-icon",
400
428
  "path": "./components/button/button-icon.js",
@@ -4,7 +4,8 @@ export const LocalizeCoreElement = superclass => class extends LocalizeMixin(sup
4
4
 
5
5
  static get localizeConfig() {
6
6
  return {
7
- importFunc: async lang => (await import(`../lang/${lang}.js`)).default
7
+ importFunc: async lang => (await import(`../lang/${lang}.js`)).default,
8
+ loadCommon: true
8
9
  };
9
10
  }
10
11
 
package/lang/ar.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "إغلاق التنبيه",
3
3
  "components.breadcrumbs.breadcrumb": "شريط التنقل",
4
4
  "components.button-add.addItem": "إضافة عنصر",
5
+ "components.button-copy.copied": "تم النسخ!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "خيارات أخرى",
6
8
  "components.calendar.hasEvents": "يحتوي على أحداث.",
7
9
  "components.calendar.notSelected": "لم يتم التحديد.",
package/lang/cy.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Cau Hysbysiad",
3
3
  "components.breadcrumbs.breadcrumb": "Briwsionyn Bara",
4
4
  "components.button-add.addItem": "Ychwanegu Eitem",
5
+ "components.button-copy.copied": "Wedi’i gopïo!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Opsiynau Eraill",
6
8
  "components.calendar.hasEvents": "Yn Cynnwys Digwyddiadau.",
7
9
  "components.calendar.notSelected": "Heb ei Ddewis.",
package/lang/da.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Luk besked",
3
3
  "components.breadcrumbs.breadcrumb": "Brødkrumme",
4
4
  "components.button-add.addItem": "Tilføj element",
5
+ "components.button-copy.copied": "Kopieret!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Andre indstillinger",
6
8
  "components.calendar.hasEvents": "Har begivenheder.",
7
9
  "components.calendar.notSelected": "Ikke valgt.",
package/lang/de.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Benachrichtigung schließen",
3
3
  "components.breadcrumbs.breadcrumb": "Brotkrümelnavigation",
4
4
  "components.button-add.addItem": "Element hinzufügen",
5
+ "components.button-copy.copied": "Kopiert.",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Sonstige Optionen",
6
8
  "components.calendar.hasEvents": "Hat Ereignisse.",
7
9
  "components.calendar.notSelected": "Nicht ausgewählt.",
package/lang/en-gb.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Close Alert",
3
3
  "components.breadcrumbs.breadcrumb": "Breadcrumb",
4
4
  "components.button-add.addItem": "Add Item",
5
+ "components.button-copy.copied": "Copied!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Other Options",
6
8
  "components.calendar.hasEvents": "Has Events.",
7
9
  "components.calendar.notSelected": "Not Selected.",
package/lang/en.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Close Alert",
3
3
  "components.breadcrumbs.breadcrumb": "Breadcrumb",
4
4
  "components.button-add.addItem": "Add Item",
5
+ "components.button-copy.copied": "Copied!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Other Options",
6
8
  "components.calendar.hasEvents": "Has Events.",
7
9
  "components.calendar.notSelected": "Not Selected.",
package/lang/es-es.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Cerrar alerta",
3
3
  "components.breadcrumbs.breadcrumb": "Ruta de navegación",
4
4
  "components.button-add.addItem": "Agregar elemento",
5
+ "components.button-copy.copied": "Copiado.",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Otras opciones",
6
8
  "components.calendar.hasEvents": "Tiene eventos.",
7
9
  "components.calendar.notSelected": "No seleccionado.",
package/lang/es.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Cerrar alerta",
3
3
  "components.breadcrumbs.breadcrumb": "Ruta de navegación",
4
4
  "components.button-add.addItem": "Agregar elemento",
5
+ "components.button-copy.copied": "Copiado.",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Otras opciones",
6
8
  "components.calendar.hasEvents": "Tiene eventos.",
7
9
  "components.calendar.notSelected": "No seleccionado.",
package/lang/fr-fr.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Fermer l’alerte",
3
3
  "components.breadcrumbs.breadcrumb": "Chemin de navigation",
4
4
  "components.button-add.addItem": "Ajouter un élément",
5
+ "components.button-copy.copied": "Copié !",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Autres options",
6
8
  "components.calendar.hasEvents": "A des événements.",
7
9
  "components.calendar.notSelected": "Non sélectionné.",
package/lang/fr.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Fermer l’alerte",
3
3
  "components.breadcrumbs.breadcrumb": "Chemin de navigation",
4
4
  "components.button-add.addItem": "Ajouter un élément",
5
+ "components.button-copy.copied": "Copié !",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Autres options",
6
8
  "components.calendar.hasEvents": "Comprend des événements.",
7
9
  "components.calendar.notSelected": "Non sélectionné(e)",
package/lang/haw.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Pani i ka makaʻala",
3
3
  "components.breadcrumbs.breadcrumb": "Palapalapala",
4
4
  "components.button-add.addItem": "Pākuʻi Mea",
5
+ "components.button-copy.copied": "Kope ʻia!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Nā Koho ʻē aʻe",
6
8
  "components.calendar.hasEvents": "Loaʻa nā hanana.",
7
9
  "components.calendar.notSelected": "ʻAʻole i koho ʻia.",
package/lang/hi.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "अलर्ट बंद करें",
3
3
  "components.breadcrumbs.breadcrumb": "ब्रेडक्रंब",
4
4
  "components.button-add.addItem": "आइटम जोड़ें",
5
+ "components.button-copy.copied": "कॉपी किया गया!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "अन्य विकल्प",
6
8
  "components.calendar.hasEvents": "ईवेंट हैं।",
7
9
  "components.calendar.notSelected": "चयनित नहीं।",
package/lang/ja.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "アラートを閉じる",
3
3
  "components.breadcrumbs.breadcrumb": "階層",
4
4
  "components.button-add.addItem": "項目の追加",
5
+ "components.button-copy.copied": "コピーできました。",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "その他のオプション",
6
8
  "components.calendar.hasEvents": "イベントがあります。",
7
9
  "components.calendar.notSelected": "選択されていません。",
package/lang/ko.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "경보 닫기",
3
3
  "components.breadcrumbs.breadcrumb": "이동 경로",
4
4
  "components.button-add.addItem": "항목 추가",
5
+ "components.button-copy.copied": "복사 완료!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "기타 옵션",
6
8
  "components.calendar.hasEvents": "이벤트가 있습니다.",
7
9
  "components.calendar.notSelected": "선택되지 않음.",
package/lang/mi.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Kati Matohi",
3
3
  "components.breadcrumbs.breadcrumb": "Pānui",
4
4
  "components.button-add.addItem": "Tāpiri Tūemi",
5
+ "components.button-copy.copied": "Kua tāruatia!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Ētahi atu kōwhiringa",
6
8
  "components.calendar.hasEvents": "He takatu ēnei.",
7
9
  "components.calendar.notSelected": "Kāore i tīpakona.",
package/lang/nl.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Waarschuwing sluiten",
3
3
  "components.breadcrumbs.breadcrumb": "Kruimelpad",
4
4
  "components.button-add.addItem": "Item toevoegen",
5
+ "components.button-copy.copied": "Gekopieerd!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Overige opties",
6
8
  "components.calendar.hasEvents": "Bevat gebeurtenissen.",
7
9
  "components.calendar.notSelected": "Niet geselecteerd.",
package/lang/pt.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Fechar alerta",
3
3
  "components.breadcrumbs.breadcrumb": "Auxiliar de navegação",
4
4
  "components.button-add.addItem": "Adicionar item",
5
+ "components.button-copy.copied": "Copiado!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Outras Opções",
6
8
  "components.calendar.hasEvents": "Tem eventos.",
7
9
  "components.calendar.notSelected": "Não selecionado.",
package/lang/sv.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Stängningsvarning",
3
3
  "components.breadcrumbs.breadcrumb": "Sökväg",
4
4
  "components.button-add.addItem": "Lägg till objekt",
5
+ "components.button-copy.copied": "Kopierat!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Andra alternativ",
6
8
  "components.calendar.hasEvents": "Har händelser.",
7
9
  "components.calendar.notSelected": "Inte vald.",
package/lang/th.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "ปิดการแจ้งเตือน",
3
3
  "components.breadcrumbs.breadcrumb": "แถบนำทาง",
4
4
  "components.button-add.addItem": "เพิ่มรายการ",
5
+ "components.button-copy.copied": "คัดลอกแล้ว!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "ตัวเลือกอื่น",
6
8
  "components.calendar.hasEvents": "มีกิจกรรม",
7
9
  "components.calendar.notSelected": "ยังไม่ได้เลือก",
package/lang/tr.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Kapatma Uyarısı",
3
3
  "components.breadcrumbs.breadcrumb": "İçerik Haritası",
4
4
  "components.button-add.addItem": "Öğe Ekle",
5
+ "components.button-copy.copied": "Kopyalandı!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Diğer Seçenekler",
6
8
  "components.calendar.hasEvents": "Olayları Var.",
7
9
  "components.calendar.notSelected": "Seçili Değil.",
package/lang/vi.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "Đóng Cảnh Báo",
3
3
  "components.breadcrumbs.breadcrumb": "Breadcrumb",
4
4
  "components.button-add.addItem": "Thêm mục",
5
+ "components.button-copy.copied": "Đã sao chép!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "Các lựa chọn khác",
6
8
  "components.calendar.hasEvents": "Có các sự kiện.",
7
9
  "components.calendar.notSelected": "Không được chọn.",
package/lang/zh-cn.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "关闭提醒",
3
3
  "components.breadcrumbs.breadcrumb": "痕迹导航",
4
4
  "components.button-add.addItem": "添加项目",
5
+ "components.button-copy.copied": "已复制!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "其他选项",
6
8
  "components.calendar.hasEvents": "有事件。",
7
9
  "components.calendar.notSelected": "未选择。",
package/lang/zh-tw.js CHANGED
@@ -2,6 +2,8 @@ export default {
2
2
  "components.alert.close": "關閉警示",
3
3
  "components.breadcrumbs.breadcrumb": "導覽路徑",
4
4
  "components.button-add.addItem": "新增項目",
5
+ "components.button-copy.copied": "複製成功!",
6
+ "components.button-copy.error": "Copy failed. Try again, or try copying manually.",
5
7
  "components.button-split.otherOptions": "其他選項",
6
8
  "components.calendar.hasEvents": "有事件。",
7
9
  "components.calendar.notSelected": "未選取。",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.171.3",
3
+ "version": "3.172.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",