carbon-components-angular 5.24.7 → 5.24.8
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/docs/documentation/components/CodeSnippet.html +59 -55
- package/docs/documentation/js/search/search_index.js +2 -2
- package/docs/documentation/modules/ComboBoxModule/dependencies.svg +4 -4
- package/docs/documentation/modules/ComboBoxModule.html +4 -4
- package/docs/documentation/modules/ContentSwitcherModule/dependencies.svg +4 -4
- package/docs/documentation/modules/ContentSwitcherModule.html +4 -4
- package/docs/documentation/modules/DatePickerInputModule/dependencies.svg +7 -7
- package/docs/documentation/modules/DatePickerInputModule.html +7 -7
- package/docs/documentation/modules/DatePickerModule/dependencies.svg +57 -53
- package/docs/documentation/modules/DatePickerModule.html +57 -53
- package/docs/documentation/modules/DialogModule/dependencies.svg +34 -34
- package/docs/documentation/modules/DialogModule.html +34 -34
- package/docs/documentation/modules/GridModule/dependencies.svg +60 -60
- package/docs/documentation/modules/GridModule.html +60 -60
- package/docs/documentation/modules/LoadingModule/dependencies.svg +4 -4
- package/docs/documentation/modules/LoadingModule.html +4 -4
- package/docs/documentation/modules/NFormsModule/dependencies.svg +4 -4
- package/docs/documentation/modules/NFormsModule.html +4 -4
- package/docs/documentation/modules/NumberModule/dependencies.svg +4 -4
- package/docs/documentation/modules/NumberModule.html +4 -4
- package/docs/documentation/modules/ProgressIndicatorModule/dependencies.svg +4 -4
- package/docs/documentation/modules/ProgressIndicatorModule.html +4 -4
- package/docs/documentation/modules/RadioModule/dependencies.svg +4 -4
- package/docs/documentation/modules/RadioModule.html +4 -4
- package/docs/documentation/modules/SearchModule/dependencies.svg +4 -4
- package/docs/documentation/modules/SearchModule.html +4 -4
- package/docs/documentation/modules/SelectModule/dependencies.svg +58 -58
- package/docs/documentation/modules/SelectModule.html +58 -58
- package/docs/documentation/modules/SliderModule/dependencies.svg +4 -4
- package/docs/documentation/modules/SliderModule.html +4 -4
- package/docs/documentation/modules/StructuredListModule/dependencies.svg +66 -66
- package/docs/documentation/modules/StructuredListModule.html +66 -66
- package/docs/documentation/modules/TabsModule/dependencies.svg +69 -69
- package/docs/documentation/modules/TabsModule.html +69 -69
- package/docs/documentation/modules/TagModule/dependencies.svg +4 -4
- package/docs/documentation/modules/TagModule.html +4 -4
- package/docs/documentation/modules/ThemeModule/dependencies.svg +13 -13
- package/docs/documentation/modules/ThemeModule.html +13 -13
- package/docs/documentation/modules/TilesModule/dependencies.svg +101 -101
- package/docs/documentation/modules/TilesModule.html +101 -101
- package/docs/documentation/modules/TimePickerModule/dependencies.svg +45 -41
- package/docs/documentation/modules/TimePickerModule.html +45 -41
- package/docs/documentation/modules/TimePickerSelectModule/dependencies.svg +45 -41
- package/docs/documentation/modules/TimePickerSelectModule.html +45 -41
- package/docs/documentation/modules/ToggleModule/dependencies.svg +4 -4
- package/docs/documentation/modules/ToggleModule.html +4 -4
- package/docs/documentation/modules/ToggletipModule/dependencies.svg +39 -39
- package/docs/documentation/modules/ToggletipModule.html +39 -39
- package/docs/documentation/modules/TreeviewModule/dependencies.svg +38 -38
- package/docs/documentation/modules/TreeviewModule.html +38 -38
- package/docs/documentation.json +49 -49
- package/docs/storybook/{code-snippet-code-snippet-stories.19e4b78a.iframe.bundle.js → code-snippet-code-snippet-stories.e78f3090.iframe.bundle.js} +1 -1
- package/docs/storybook/iframe.html +2 -2
- package/docs/storybook/main.21980b69.iframe.bundle.js +1 -0
- package/docs/storybook/project.json +1 -1
- package/docs/storybook/{runtime~main.cb1f9895.iframe.bundle.js → runtime~main.febf8cc7.iframe.bundle.js} +1 -1
- package/esm2020/code-snippet/code-snippet.component.mjs +7 -3
- package/fesm2015/carbon-components-angular-code-snippet.mjs +6 -2
- package/fesm2015/carbon-components-angular-code-snippet.mjs.map +1 -1
- package/fesm2020/carbon-components-angular-code-snippet.mjs +6 -2
- package/fesm2020/carbon-components-angular-code-snippet.mjs.map +1 -1
- package/package.json +1 -1
- package/docs/storybook/main.83dfce65.iframe.bundle.js +0 -1
package/docs/documentation.json
CHANGED
|
@@ -21430,7 +21430,7 @@
|
|
|
21430
21430
|
},
|
|
21431
21431
|
{
|
|
21432
21432
|
"name": "CodeSnippet",
|
|
21433
|
-
"id": "component-CodeSnippet-
|
|
21433
|
+
"id": "component-CodeSnippet-c3a1b7fec13daa1d2f52b8c4c93ea7e2b66a1759daee08ca1125a3593a3af8bf5c62ef7465771b862d6a11c58fab82a0b8c81ac2ae2ca8cf1295aa293c4d8357",
|
|
21434
21434
|
"file": "src/code-snippet/code-snippet.component.ts",
|
|
21435
21435
|
"encapsulation": [],
|
|
21436
21436
|
"entryComponents": [],
|
|
@@ -21440,7 +21440,7 @@
|
|
|
21440
21440
|
"selector": "cds-code-snippet, ibm-code-snippet",
|
|
21441
21441
|
"styleUrls": [],
|
|
21442
21442
|
"styles": [],
|
|
21443
|
-
"template": "<ng-container *ngIf=\"display === 'inline'; else notInline\">\n\t<ng-container *ngIf=\"!hideCopyButton; else noBtnInline\">\n\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t</ng-container>\n\t<ng-template #noBtnInline>\n\t\t<span\n\t\t\tclass=\"cds--snippet cds--snippet--inline cds--snippet--no-copy\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'cds--snippet--light': theme === 'light'\n\t\t\t}\">\n\t\t\t<code #code>\n\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t</code>\n\t\t</span>\n\t</ng-template>\n</ng-container>\n\n<ng-template #notInline>\n\t<div\n\t\t#codeContainer\n\t\tclass=\"cds--snippet-container\"\n\t\t[attr.aria-label]=\"translations.CODE_SNIPPET_TEXT\"\n\t\t[attr.tabindex]=\"display === 'single' && !disabled ? '0' : null\"\n\t\t[attr.role]=\"display==='single' ? 'textarea' : null\"\n\t\t[ngStyle]=\"styles\"\n\t\t(scroll)=\"(display === 'single' ? handleScroll() : null)\">\n\t\t<ng-container *ngIf=\"skeleton\">\n\t\t\t<span *ngIf=\"display === 'single'; else multiSkeleton\"></span>\n\t\t\t<ng-template #multiSkeleton>\n\t\t\t\t<span></span>\n\t\t\t\t<span></span>\n\t\t\t\t<span></span>\n\t\t\t</ng-template>\n\t\t</ng-container>\n\t\t<pre\n\t\t\t#codeContent\n\t\t\t*ngIf=\"!skeleton\"\n\t\t\t(scroll)=\"(display === 'multi' ? handleScroll() : null)\"><code #code><ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container></code></pre>\n\t</div>\n\t<div *ngIf=\"hasLeft\" class=\"cds--snippet__overflow-indicator--left\"></div>\n\t<div *ngIf=\"hasRight\" class=\"cds--snippet__overflow-indicator--right\"></div>\n\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t<button\n\t\t*ngIf=\"isExpandable\"\n\t\tclass=\"cds--btn cds--btn--ghost cds--btn--sm cds--snippet-btn--expand\"\n\t\t(click)=\"toggleSnippetExpansion()\"\n\t\ttype=\"button\">\n\t\t<span class=\"cds--snippet-btn--text\">{{expanded ? translations.SHOW_LESS : translations.SHOW_MORE}}</span>\n\t\t<svg cdsIcon=\"chevron--down\" size=\"16\" class=\"cds--icon-chevron--down\" [attr.aria-label]=\"translations.SHOW_MORE_ICON\"></svg>\n\t</button>\n</ng-template>\n\n<ng-template #buttonTemplate>\n\t<cds-icon-button\n\t\t*ngIf=\"!skeleton\"\n\t\t[description]=\"showFeedback ? feedbackText : copyButtonDescription\"\n\t\t[align]=\"align\"\n\t\t[dropShadow]=\"dropShadow\"\n\t\t[caret]=\"caret\"\n\t\t[highContrast]=\"highContrast\"\n\t\t[isOpen]=\"isOpen\"\n\t\t[enterDelayMs]=\"enterDelayMs\"\n\t\t[leaveDelayMs]=\"leaveDelayMs\"\n\t\ttype=\"button\"\n\t\tkind=\"primary\"\n\t\tsize=\"md\"\n\t\t(click)=\"onCopyButtonClicked($event)\"\n\t\t[buttonNgClass]=\"{\n\t\t\t'cds--snippet--light': theme === 'light',\n\t\t\t'cds--snippet--inline': display === 'inline',\n\t\t\t'cds--btn--icon-only': display !== 'inline',\n\t\t\t'cds--copy-btn': display !== 'inline',\n\t\t\t'cds--copy-btn--animating': animating,\n\t\t\t'cds--copy-btn--fade-in': showFeedback,\n\t\t\t'cds--copy-btn--fade-out': !showFeedback && animating,\n\t\t\t'cds--snippet cds--copy': true\n\t\t}\"\n\t\t[buttonAttributes]=\"{\n\t\t\t'aria-label': translations.COPY_CODE,\n\t\t\t'aria-live': 'polite',\n\t\t\t'tabindex': '0'\n\t\t}\">\n\t\t<ng-container *ngIf=\"display === 'inline'\">\n\t\t\t<code #code>\n\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t</code>\n\t\t</ng-container>\n\t\t<ng-container *ngIf=\"display !== 'inline'\">\n\t\t\t<svg cdsIcon=\"copy\" size=\"16\" class=\"cds--snippet__icon\"></svg>\n\t\t</ng-container>\n\t</cds-icon-button>\n</ng-template>\n\n<ng-template #codeTemplate>\n\t<ng-content></ng-content>\n</ng-template>\n\t",
|
|
21443
|
+
"template": "<ng-container *ngIf=\"display === 'inline'; else notInline\">\n\t<ng-container *ngIf=\"!hideCopyButton; else noBtnInline\">\n\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t</ng-container>\n\t<ng-template #noBtnInline>\n\t\t<span\n\t\t\tclass=\"cds--snippet cds--snippet--inline cds--snippet--no-copy\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'cds--snippet--light': theme === 'light'\n\t\t\t}\">\n\t\t\t<code #code>\n\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t</code>\n\t\t</span>\n\t</ng-template>\n</ng-container>\n\n<ng-template #notInline>\n\t<div\n\t\t#codeContainer\n\t\tclass=\"cds--snippet-container\"\n\t\t[attr.aria-label]=\"translations.CODE_SNIPPET_TEXT\"\n\t\t[attr.tabindex]=\"display === 'single' && !disabled ? '0' : null\"\n\t\t[attr.role]=\"display==='single' ? 'textarea' : null\"\n\t\t[ngStyle]=\"styles\"\n\t\t(scroll)=\"(display === 'single' ? handleScroll() : null)\">\n\t\t<ng-container *ngIf=\"skeleton\">\n\t\t\t<span *ngIf=\"display === 'single'; else multiSkeleton\"></span>\n\t\t\t<ng-template #multiSkeleton>\n\t\t\t\t<span></span>\n\t\t\t\t<span></span>\n\t\t\t\t<span></span>\n\t\t\t</ng-template>\n\t\t</ng-container>\n\t\t<pre\n\t\t\t#codeContent\n\t\t\t*ngIf=\"!skeleton\"\n\t\t\t(scroll)=\"(display === 'multi' ? handleScroll() : null)\"><code #code><ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container></code></pre>\n\t</div>\n\t<div *ngIf=\"hasLeft\" class=\"cds--snippet__overflow-indicator--left\"></div>\n\t<div *ngIf=\"hasRight\" class=\"cds--snippet__overflow-indicator--right\"></div>\n\t<ng-container *ngIf=\"!hideCopyButton;\">\n\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t</ng-container>\n\t<button\n\t\t*ngIf=\"isExpandable\"\n\t\tclass=\"cds--btn cds--btn--ghost cds--btn--sm cds--snippet-btn--expand\"\n\t\t(click)=\"toggleSnippetExpansion()\"\n\t\ttype=\"button\">\n\t\t<span class=\"cds--snippet-btn--text\">{{expanded ? translations.SHOW_LESS : translations.SHOW_MORE}}</span>\n\t\t<svg cdsIcon=\"chevron--down\" size=\"16\" class=\"cds--icon-chevron--down\" [attr.aria-label]=\"translations.SHOW_MORE_ICON\"></svg>\n\t</button>\n</ng-template>\n\n<ng-template #buttonTemplate>\n\t<cds-icon-button\n\t\t*ngIf=\"!skeleton\"\n\t\t[description]=\"showFeedback ? feedbackText : copyButtonDescription\"\n\t\t[align]=\"align\"\n\t\t[dropShadow]=\"dropShadow\"\n\t\t[caret]=\"caret\"\n\t\t[highContrast]=\"highContrast\"\n\t\t[isOpen]=\"isOpen\"\n\t\t[enterDelayMs]=\"enterDelayMs\"\n\t\t[leaveDelayMs]=\"leaveDelayMs\"\n\t\ttype=\"button\"\n\t\tkind=\"primary\"\n\t\tsize=\"md\"\n\t\t(click)=\"onCopyButtonClicked($event)\"\n\t\t[buttonNgClass]=\"{\n\t\t\t'cds--snippet--light': theme === 'light',\n\t\t\t'cds--snippet--inline': display === 'inline',\n\t\t\t'cds--btn--icon-only': display !== 'inline',\n\t\t\t'cds--copy-btn': display !== 'inline',\n\t\t\t'cds--copy-btn--animating': animating,\n\t\t\t'cds--copy-btn--fade-in': showFeedback,\n\t\t\t'cds--copy-btn--fade-out': !showFeedback && animating,\n\t\t\t'cds--snippet cds--copy': true\n\t\t}\"\n\t\t[buttonAttributes]=\"{\n\t\t\t'aria-label': translations.COPY_CODE,\n\t\t\t'aria-live': 'polite',\n\t\t\t'tabindex': '0'\n\t\t}\">\n\t\t<ng-container *ngIf=\"display === 'inline'\">\n\t\t\t<code #code>\n\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t</code>\n\t\t</ng-container>\n\t\t<ng-container *ngIf=\"display !== 'inline'\">\n\t\t\t<svg cdsIcon=\"copy\" size=\"16\" class=\"cds--snippet__icon\"></svg>\n\t\t</ng-container>\n\t</cds-icon-button>\n</ng-template>\n\n<ng-template #codeTemplate>\n\t<ng-content></ng-content>\n</ng-template>\n\t",
|
|
21444
21444
|
"templateUrl": [],
|
|
21445
21445
|
"viewProviders": [],
|
|
21446
21446
|
"hostDirectives": [],
|
|
@@ -21451,7 +21451,7 @@
|
|
|
21451
21451
|
"deprecationMessage": "",
|
|
21452
21452
|
"rawdescription": "\n\ncopy button description to show on hover\n",
|
|
21453
21453
|
"description": "<p>copy button description to show on hover</p>\n",
|
|
21454
|
-
"line":
|
|
21454
|
+
"line": 163,
|
|
21455
21455
|
"type": "string",
|
|
21456
21456
|
"decorators": []
|
|
21457
21457
|
},
|
|
@@ -21462,7 +21462,7 @@
|
|
|
21462
21462
|
"deprecationMessage": "",
|
|
21463
21463
|
"rawdescription": "\n\nSet to `true` to disable the code snippet\n",
|
|
21464
21464
|
"description": "<p>Set to <code>true</code> to disable the code snippet</p>\n",
|
|
21465
|
-
"line":
|
|
21465
|
+
"line": 171,
|
|
21466
21466
|
"type": "boolean",
|
|
21467
21467
|
"decorators": []
|
|
21468
21468
|
},
|
|
@@ -21473,7 +21473,7 @@
|
|
|
21473
21473
|
"deprecationMessage": "",
|
|
21474
21474
|
"rawdescription": "\n\nIt can be `\"single\"`, `\"multi\"` or `\"inline\"`\n",
|
|
21475
21475
|
"description": "<p>It can be <code>"single"</code>, <code>"multi"</code> or <code>"inline"</code></p>\n",
|
|
21476
|
-
"line":
|
|
21476
|
+
"line": 158,
|
|
21477
21477
|
"type": "SnippetType",
|
|
21478
21478
|
"decorators": []
|
|
21479
21479
|
},
|
|
@@ -21482,7 +21482,7 @@
|
|
|
21482
21482
|
"defaultValue": "false",
|
|
21483
21483
|
"deprecated": false,
|
|
21484
21484
|
"deprecationMessage": "",
|
|
21485
|
-
"line":
|
|
21485
|
+
"line": 211,
|
|
21486
21486
|
"type": "boolean",
|
|
21487
21487
|
"decorators": []
|
|
21488
21488
|
},
|
|
@@ -21493,7 +21493,7 @@
|
|
|
21493
21493
|
"deprecationMessage": "",
|
|
21494
21494
|
"rawdescription": "\n\nText displayed in the tooltip when user clicks button to copy code.\n",
|
|
21495
21495
|
"description": "<p>Text displayed in the tooltip when user clicks button to copy code.</p>\n",
|
|
21496
|
-
"line":
|
|
21496
|
+
"line": 204,
|
|
21497
21497
|
"type": "any",
|
|
21498
21498
|
"decorators": []
|
|
21499
21499
|
},
|
|
@@ -21504,7 +21504,7 @@
|
|
|
21504
21504
|
"deprecationMessage": "",
|
|
21505
21505
|
"rawdescription": "\n\nTime in miliseconds to keep the feedback tooltip displayed.\nDefaults to 2 seconds\n",
|
|
21506
21506
|
"description": "<p>Time in miliseconds to keep the feedback tooltip displayed.\nDefaults to 2 seconds</p>\n",
|
|
21507
|
-
"line":
|
|
21507
|
+
"line": 209,
|
|
21508
21508
|
"type": "number",
|
|
21509
21509
|
"decorators": []
|
|
21510
21510
|
},
|
|
@@ -21515,7 +21515,7 @@
|
|
|
21515
21515
|
"deprecationMessage": "",
|
|
21516
21516
|
"rawdescription": "\n\nSet to `true` to hide copy button\n",
|
|
21517
21517
|
"description": "<p>Set to <code>true</code> to hide copy button</p>\n",
|
|
21518
|
-
"line":
|
|
21518
|
+
"line": 167,
|
|
21519
21519
|
"type": "boolean",
|
|
21520
21520
|
"decorators": []
|
|
21521
21521
|
},
|
|
@@ -21526,7 +21526,7 @@
|
|
|
21526
21526
|
"deprecationMessage": "",
|
|
21527
21527
|
"rawdescription": "\n\nSpecify the max number of rows to show when collapsed\nDefault is `15`\n",
|
|
21528
21528
|
"description": "<p>Specify the max number of rows to show when collapsed\nDefault is <code>15</code></p>\n",
|
|
21529
|
-
"line":
|
|
21529
|
+
"line": 176,
|
|
21530
21530
|
"type": "number",
|
|
21531
21531
|
"decorators": []
|
|
21532
21532
|
},
|
|
@@ -21537,7 +21537,7 @@
|
|
|
21537
21537
|
"deprecationMessage": "",
|
|
21538
21538
|
"rawdescription": "\n\nSpecify the max number of rows to show when expanded\nDefault is `0`, hence all content will be visible when expanded\n",
|
|
21539
21539
|
"description": "<p>Specify the max number of rows to show when expanded\nDefault is <code>0</code>, hence all content will be visible when expanded</p>\n",
|
|
21540
|
-
"line":
|
|
21540
|
+
"line": 186,
|
|
21541
21541
|
"type": "number",
|
|
21542
21542
|
"decorators": []
|
|
21543
21543
|
},
|
|
@@ -21548,7 +21548,7 @@
|
|
|
21548
21548
|
"deprecationMessage": "",
|
|
21549
21549
|
"rawdescription": "\n\nSpecify the min number of rows to show when collapsed\nDefault is `3`\n",
|
|
21550
21550
|
"description": "<p>Specify the min number of rows to show when collapsed\nDefault is <code>3</code></p>\n",
|
|
21551
|
-
"line":
|
|
21551
|
+
"line": 181,
|
|
21552
21552
|
"type": "number",
|
|
21553
21553
|
"decorators": []
|
|
21554
21554
|
},
|
|
@@ -21559,7 +21559,7 @@
|
|
|
21559
21559
|
"deprecationMessage": "",
|
|
21560
21560
|
"rawdescription": "\n\nSpecify the min number of rows to show when expanded\nDefault is `16`, hence height of expanded row will be 16 * rowHeightInPixel (16) = 256px\n",
|
|
21561
21561
|
"description": "<p>Specify the min number of rows to show when expanded\nDefault is <code>16</code>, hence height of expanded row will be 16 * rowHeightInPixel (16) = 256px</p>\n",
|
|
21562
|
-
"line":
|
|
21562
|
+
"line": 191,
|
|
21563
21563
|
"type": "number",
|
|
21564
21564
|
"decorators": []
|
|
21565
21565
|
},
|
|
@@ -21568,7 +21568,7 @@
|
|
|
21568
21568
|
"defaultValue": "false",
|
|
21569
21569
|
"deprecated": false,
|
|
21570
21570
|
"deprecationMessage": "",
|
|
21571
|
-
"line":
|
|
21571
|
+
"line": 212,
|
|
21572
21572
|
"type": "boolean",
|
|
21573
21573
|
"decorators": []
|
|
21574
21574
|
},
|
|
@@ -21579,15 +21579,15 @@
|
|
|
21579
21579
|
"deprecationMessage": "since v5 - Use `cdsLayer` directive instead\nSet to `\"light\"` to apply the light style",
|
|
21580
21580
|
"jsdoctags": [
|
|
21581
21581
|
{
|
|
21582
|
-
"pos":
|
|
21583
|
-
"end":
|
|
21582
|
+
"pos": 6097,
|
|
21583
|
+
"end": 6201,
|
|
21584
21584
|
"flags": 8421376,
|
|
21585
21585
|
"modifierFlagsCache": 0,
|
|
21586
21586
|
"transformFlags": 0,
|
|
21587
21587
|
"kind": 334,
|
|
21588
21588
|
"tagName": {
|
|
21589
|
-
"pos":
|
|
21590
|
-
"end":
|
|
21589
|
+
"pos": 6098,
|
|
21590
|
+
"end": 6108,
|
|
21591
21591
|
"flags": 8421376,
|
|
21592
21592
|
"modifierFlagsCache": 0,
|
|
21593
21593
|
"transformFlags": 0,
|
|
@@ -21597,7 +21597,7 @@
|
|
|
21597
21597
|
"comment": "<p>since v5 - Use <code>cdsLayer</code> directive instead\nSet to <code>"light"</code> to apply the light style</p>\n"
|
|
21598
21598
|
}
|
|
21599
21599
|
],
|
|
21600
|
-
"line":
|
|
21600
|
+
"line": 200,
|
|
21601
21601
|
"type": "\"light\" | \"dark\"",
|
|
21602
21602
|
"decorators": []
|
|
21603
21603
|
},
|
|
@@ -21606,7 +21606,7 @@
|
|
|
21606
21606
|
"defaultValue": "this.i18n.get().CODE_SNIPPET",
|
|
21607
21607
|
"deprecated": false,
|
|
21608
21608
|
"deprecationMessage": "",
|
|
21609
|
-
"line":
|
|
21609
|
+
"line": 159,
|
|
21610
21610
|
"type": "any",
|
|
21611
21611
|
"decorators": []
|
|
21612
21612
|
},
|
|
@@ -21617,7 +21617,7 @@
|
|
|
21617
21617
|
"deprecationMessage": "",
|
|
21618
21618
|
"rawdescription": "\n\nSet to `true` to wrap the text\n",
|
|
21619
21619
|
"description": "<p>Set to <code>true</code> to wrap the text</p>\n",
|
|
21620
|
-
"line":
|
|
21620
|
+
"line": 195,
|
|
21621
21621
|
"type": "boolean",
|
|
21622
21622
|
"decorators": []
|
|
21623
21623
|
},
|
|
@@ -21744,7 +21744,7 @@
|
|
|
21744
21744
|
"type": "",
|
|
21745
21745
|
"optional": false,
|
|
21746
21746
|
"description": "",
|
|
21747
|
-
"line":
|
|
21747
|
+
"line": 220
|
|
21748
21748
|
},
|
|
21749
21749
|
{
|
|
21750
21750
|
"name": "code",
|
|
@@ -21753,7 +21753,7 @@
|
|
|
21753
21753
|
"type": "",
|
|
21754
21754
|
"optional": false,
|
|
21755
21755
|
"description": "",
|
|
21756
|
-
"line":
|
|
21756
|
+
"line": 215,
|
|
21757
21757
|
"decorators": [
|
|
21758
21758
|
{
|
|
21759
21759
|
"name": "ViewChild",
|
|
@@ -21771,7 +21771,7 @@
|
|
|
21771
21771
|
"type": "",
|
|
21772
21772
|
"optional": false,
|
|
21773
21773
|
"description": "",
|
|
21774
|
-
"line":
|
|
21774
|
+
"line": 217,
|
|
21775
21775
|
"decorators": [
|
|
21776
21776
|
{
|
|
21777
21777
|
"name": "ViewChild",
|
|
@@ -21789,7 +21789,7 @@
|
|
|
21789
21789
|
"type": "",
|
|
21790
21790
|
"optional": false,
|
|
21791
21791
|
"description": "",
|
|
21792
|
-
"line":
|
|
21792
|
+
"line": 216,
|
|
21793
21793
|
"decorators": [
|
|
21794
21794
|
{
|
|
21795
21795
|
"name": "ViewChild",
|
|
@@ -21808,7 +21808,7 @@
|
|
|
21808
21808
|
"type": "null",
|
|
21809
21809
|
"optional": false,
|
|
21810
21810
|
"description": "",
|
|
21811
|
-
"line":
|
|
21811
|
+
"line": 221
|
|
21812
21812
|
},
|
|
21813
21813
|
{
|
|
21814
21814
|
"name": "hasLeft",
|
|
@@ -21818,7 +21818,7 @@
|
|
|
21818
21818
|
"type": "",
|
|
21819
21819
|
"optional": false,
|
|
21820
21820
|
"description": "",
|
|
21821
|
-
"line":
|
|
21821
|
+
"line": 226
|
|
21822
21822
|
},
|
|
21823
21823
|
{
|
|
21824
21824
|
"name": "hasRight",
|
|
@@ -21828,7 +21828,7 @@
|
|
|
21828
21828
|
"type": "",
|
|
21829
21829
|
"optional": false,
|
|
21830
21830
|
"description": "",
|
|
21831
|
-
"line":
|
|
21831
|
+
"line": 225
|
|
21832
21832
|
},
|
|
21833
21833
|
{
|
|
21834
21834
|
"name": "hasRightOverflow",
|
|
@@ -21838,7 +21838,7 @@
|
|
|
21838
21838
|
"type": "",
|
|
21839
21839
|
"optional": false,
|
|
21840
21840
|
"description": "",
|
|
21841
|
-
"line":
|
|
21841
|
+
"line": 223
|
|
21842
21842
|
},
|
|
21843
21843
|
{
|
|
21844
21844
|
"name": "isExpandable",
|
|
@@ -21848,7 +21848,7 @@
|
|
|
21848
21848
|
"type": "",
|
|
21849
21849
|
"optional": false,
|
|
21850
21850
|
"description": "",
|
|
21851
|
-
"line":
|
|
21851
|
+
"line": 222
|
|
21852
21852
|
},
|
|
21853
21853
|
{
|
|
21854
21854
|
"name": "rowHeightInPixel",
|
|
@@ -21858,7 +21858,7 @@
|
|
|
21858
21858
|
"type": "number",
|
|
21859
21859
|
"optional": false,
|
|
21860
21860
|
"description": "",
|
|
21861
|
-
"line":
|
|
21861
|
+
"line": 153,
|
|
21862
21862
|
"modifierKind": [
|
|
21863
21863
|
146
|
|
21864
21864
|
]
|
|
@@ -21871,7 +21871,7 @@
|
|
|
21871
21871
|
"type": "",
|
|
21872
21872
|
"optional": false,
|
|
21873
21873
|
"description": "",
|
|
21874
|
-
"line":
|
|
21874
|
+
"line": 219
|
|
21875
21875
|
},
|
|
21876
21876
|
{
|
|
21877
21877
|
"name": "styles",
|
|
@@ -21881,7 +21881,7 @@
|
|
|
21881
21881
|
"type": "any",
|
|
21882
21882
|
"optional": false,
|
|
21883
21883
|
"description": "",
|
|
21884
|
-
"line":
|
|
21884
|
+
"line": 213
|
|
21885
21885
|
}
|
|
21886
21886
|
],
|
|
21887
21887
|
"methodsClass": [
|
|
@@ -21891,7 +21891,7 @@
|
|
|
21891
21891
|
"optional": false,
|
|
21892
21892
|
"returnType": "void",
|
|
21893
21893
|
"typeParameters": [],
|
|
21894
|
-
"line":
|
|
21894
|
+
"line": 298,
|
|
21895
21895
|
"deprecated": false,
|
|
21896
21896
|
"deprecationMessage": ""
|
|
21897
21897
|
},
|
|
@@ -21901,7 +21901,7 @@
|
|
|
21901
21901
|
"optional": false,
|
|
21902
21902
|
"returnType": "void",
|
|
21903
21903
|
"typeParameters": [],
|
|
21904
|
-
"line":
|
|
21904
|
+
"line": 236,
|
|
21905
21905
|
"deprecated": false,
|
|
21906
21906
|
"deprecationMessage": ""
|
|
21907
21907
|
},
|
|
@@ -21911,7 +21911,7 @@
|
|
|
21911
21911
|
"optional": false,
|
|
21912
21912
|
"returnType": "void",
|
|
21913
21913
|
"typeParameters": [],
|
|
21914
|
-
"line":
|
|
21914
|
+
"line": 269,
|
|
21915
21915
|
"deprecated": false,
|
|
21916
21916
|
"deprecationMessage": ""
|
|
21917
21917
|
},
|
|
@@ -21921,7 +21921,7 @@
|
|
|
21921
21921
|
"optional": false,
|
|
21922
21922
|
"returnType": "void",
|
|
21923
21923
|
"typeParameters": [],
|
|
21924
|
-
"line":
|
|
21924
|
+
"line": 264,
|
|
21925
21925
|
"deprecated": false,
|
|
21926
21926
|
"deprecationMessage": ""
|
|
21927
21927
|
}
|
|
@@ -21933,7 +21933,7 @@
|
|
|
21933
21933
|
"name": "class.cds--snippet",
|
|
21934
21934
|
"deprecated": false,
|
|
21935
21935
|
"deprecationMessage": "",
|
|
21936
|
-
"line":
|
|
21936
|
+
"line": 137,
|
|
21937
21937
|
"type": "boolean",
|
|
21938
21938
|
"decorators": []
|
|
21939
21939
|
},
|
|
@@ -21941,7 +21941,7 @@
|
|
|
21941
21941
|
"name": "class.cds--snippet--disabled",
|
|
21942
21942
|
"deprecated": false,
|
|
21943
21943
|
"deprecationMessage": "",
|
|
21944
|
-
"line":
|
|
21944
|
+
"line": 146,
|
|
21945
21945
|
"type": "boolean",
|
|
21946
21946
|
"decorators": []
|
|
21947
21947
|
},
|
|
@@ -21949,7 +21949,7 @@
|
|
|
21949
21949
|
"name": "class.cds--snippet--light",
|
|
21950
21950
|
"deprecated": false,
|
|
21951
21951
|
"deprecationMessage": "",
|
|
21952
|
-
"line":
|
|
21952
|
+
"line": 149,
|
|
21953
21953
|
"type": "boolean",
|
|
21954
21954
|
"decorators": []
|
|
21955
21955
|
},
|
|
@@ -21957,7 +21957,7 @@
|
|
|
21957
21957
|
"name": "class.cds--snippet--multi",
|
|
21958
21958
|
"deprecated": false,
|
|
21959
21959
|
"deprecationMessage": "",
|
|
21960
|
-
"line":
|
|
21960
|
+
"line": 143,
|
|
21961
21961
|
"type": "boolean",
|
|
21962
21962
|
"decorators": []
|
|
21963
21963
|
},
|
|
@@ -21965,7 +21965,7 @@
|
|
|
21965
21965
|
"name": "class.cds--snippet--single",
|
|
21966
21966
|
"deprecated": false,
|
|
21967
21967
|
"deprecationMessage": "",
|
|
21968
|
-
"line":
|
|
21968
|
+
"line": 140,
|
|
21969
21969
|
"type": "boolean",
|
|
21970
21970
|
"decorators": []
|
|
21971
21971
|
}
|
|
@@ -21976,7 +21976,7 @@
|
|
|
21976
21976
|
"description": "<p>Get started with importing the module:</p>\n<div><pre class=\"line-numbers\"><code class=\"language-typescript\">import { CodeSnippetModule } from 'carbon-components-angular';</code></pre></div><div><pre class=\"line-numbers\"><code class=\"language-html\"><cds-code-snippet>Code</cds-code-snippet></code></pre></div><p><a href=\"../../?path=/story/components-code-snippet--basic\">See demo</a></p>\n",
|
|
21977
21977
|
"rawdescription": "\n\nGet started with importing the module:\n\n```typescript\nimport { CodeSnippetModule } from 'carbon-components-angular';\n```\n\n```html\n<cds-code-snippet>Code</cds-code-snippet>\n```\n\n[See demo](../../?path=/story/components-code-snippet--basic)\n",
|
|
21978
21978
|
"type": "component",
|
|
21979
|
-
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tHostBinding,\n\tViewChild,\n\tAfterViewInit,\n\tOnInit\n} from \"@angular/core\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { EventService } from \"carbon-components-angular/utils\";\nimport { BaseIconButton } from \"carbon-components-angular/button\";\n\nexport enum SnippetType {\n\tsingle = \"single\",\n\tmulti = \"multi\",\n\tinline = \"inline\"\n}\n\n/**\n * Get started with importing the module:\n *\n * ```typescript\n * import { CodeSnippetModule } from 'carbon-components-angular';\n * ```\n *\n * ```html\n * <cds-code-snippet>Code</cds-code-snippet>\n * ```\n *\n * [See demo](../../?path=/story/components-code-snippet--basic)\n */\n@Component({\n\tselector: \"cds-code-snippet, ibm-code-snippet\",\n\ttemplate: `\n\t\t<ng-container *ngIf=\"display === 'inline'; else notInline\">\n\t\t\t<ng-container *ngIf=\"!hideCopyButton; else noBtnInline\">\n\t\t\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t\t\t</ng-container>\n\t\t\t<ng-template #noBtnInline>\n\t\t\t\t<span\n\t\t\t\t\tclass=\"cds--snippet cds--snippet--inline cds--snippet--no-copy\"\n\t\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t\t'cds--snippet--light': theme === 'light'\n\t\t\t\t\t}\">\n\t\t\t\t\t<code #code>\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t\t\t</code>\n\t\t\t\t</span>\n\t\t\t</ng-template>\n\t\t</ng-container>\n\n\t\t<ng-template #notInline>\n\t\t\t<div\n\t\t\t\t#codeContainer\n\t\t\t\tclass=\"cds--snippet-container\"\n\t\t\t\t[attr.aria-label]=\"translations.CODE_SNIPPET_TEXT\"\n\t\t\t\t[attr.tabindex]=\"display === 'single' && !disabled ? '0' : null\"\n\t\t\t\t[attr.role]=\"display==='single' ? 'textarea' : null\"\n\t\t\t\t[ngStyle]=\"styles\"\n\t\t\t\t(scroll)=\"(display === 'single' ? handleScroll() : null)\">\n\t\t\t\t<ng-container *ngIf=\"skeleton\">\n\t\t\t\t\t<span *ngIf=\"display === 'single'; else multiSkeleton\"></span>\n\t\t\t\t\t<ng-template #multiSkeleton>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t</ng-template>\n\t\t\t\t</ng-container>\n\t\t\t\t<pre\n\t\t\t\t\t#codeContent\n\t\t\t\t\t*ngIf=\"!skeleton\"\n\t\t\t\t\t(scroll)=\"(display === 'multi' ? handleScroll() : null)\"><code #code><ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container></code></pre>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"hasLeft\" class=\"cds--snippet__overflow-indicator--left\"></div>\n\t\t\t<div *ngIf=\"hasRight\" class=\"cds--snippet__overflow-indicator--right\"></div>\n\t\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t\t\t<button\n\t\t\t\t*ngIf=\"isExpandable\"\n\t\t\t\tclass=\"cds--btn cds--btn--ghost cds--btn--sm cds--snippet-btn--expand\"\n\t\t\t\t(click)=\"toggleSnippetExpansion()\"\n\t\t\t\ttype=\"button\">\n\t\t\t\t<span class=\"cds--snippet-btn--text\">{{expanded ? translations.SHOW_LESS : translations.SHOW_MORE}}</span>\n\t\t\t\t<svg cdsIcon=\"chevron--down\" size=\"16\" class=\"cds--icon-chevron--down\" [attr.aria-label]=\"translations.SHOW_MORE_ICON\"></svg>\n\t\t\t</button>\n\t\t</ng-template>\n\n\t\t<ng-template #buttonTemplate>\n\t\t\t<cds-icon-button\n\t\t\t\t*ngIf=\"!skeleton\"\n\t\t\t\t[description]=\"showFeedback ? feedbackText : copyButtonDescription\"\n\t\t\t\t[align]=\"align\"\n\t\t\t\t[dropShadow]=\"dropShadow\"\n\t\t\t\t[caret]=\"caret\"\n\t\t\t\t[highContrast]=\"highContrast\"\n\t\t\t\t[isOpen]=\"isOpen\"\n\t\t\t\t[enterDelayMs]=\"enterDelayMs\"\n\t\t\t\t[leaveDelayMs]=\"leaveDelayMs\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tkind=\"primary\"\n\t\t\t\tsize=\"md\"\n\t\t\t\t(click)=\"onCopyButtonClicked($event)\"\n\t\t\t\t[buttonNgClass]=\"{\n\t\t\t\t\t'cds--snippet--light': theme === 'light',\n\t\t\t\t\t'cds--snippet--inline': display === 'inline',\n\t\t\t\t\t'cds--btn--icon-only': display !== 'inline',\n\t\t\t\t\t'cds--copy-btn': display !== 'inline',\n\t\t\t\t\t'cds--copy-btn--animating': animating,\n\t\t\t\t\t'cds--copy-btn--fade-in': showFeedback,\n\t\t\t\t\t'cds--copy-btn--fade-out': !showFeedback && animating,\n\t\t\t\t\t'cds--snippet cds--copy': true\n\t\t\t\t}\"\n\t\t\t\t[buttonAttributes]=\"{\n\t\t\t\t\t'aria-label': translations.COPY_CODE,\n\t\t\t\t\t'aria-live': 'polite',\n\t\t\t\t\t'tabindex': '0'\n\t\t\t\t}\">\n\t\t\t\t<ng-container *ngIf=\"display === 'inline'\">\n\t\t\t\t\t<code #code>\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t\t\t</code>\n\t\t\t\t</ng-container>\n\t\t\t\t<ng-container *ngIf=\"display !== 'inline'\">\n\t\t\t\t\t<svg cdsIcon=\"copy\" size=\"16\" class=\"cds--snippet__icon\"></svg>\n\t\t\t\t</ng-container>\n\t\t\t</cds-icon-button>\n\t\t</ng-template>\n\n\t\t<ng-template #codeTemplate>\n\t\t\t<ng-content></ng-content>\n\t\t</ng-template>\n\t`\n})\nexport class CodeSnippet extends BaseIconButton implements OnInit, AfterViewInit {\n\t@HostBinding(\"class.cds--snippet\") get snippetClass() {\n\t\treturn this.display !== SnippetType.inline;\n\t}\n\t@HostBinding(\"class.cds--snippet--single\") get snippetSingleClass() {\n\t\treturn this.display === SnippetType.single;\n\t}\n\t@HostBinding(\"class.cds--snippet--multi\") get snippetMultiClass() {\n\t\treturn this.display === SnippetType.multi;\n\t}\n\t@HostBinding(\"class.cds--snippet--disabled\") get snippetDisabledClass() {\n\t\treturn this.display !== \"inline\" && this.disabled;\n\t}\n\t@HostBinding(\"class.cds--snippet--light\") get snippetInlineLightClass() {\n\t\treturn this.theme === \"light\";\n\t}\n\n\treadonly rowHeightInPixel: number = 16;\n\n\t/**\n\t * It can be `\"single\"`, `\"multi\"` or `\"inline\"`\n\t */\n\t@Input() display: SnippetType = SnippetType.single;\n\t@Input() translations = this.i18n.get().CODE_SNIPPET;\n\t/**\n\t * copy button description to show on hover\n\t */\n\t@Input() copyButtonDescription: string;\n\t/**\n\t * Set to `true` to hide copy button\n\t */\n\t@Input() hideCopyButton = false;\n\t/**\n\t * Set to `true` to disable the code snippet\n\t */\n\t@Input() disabled = false;\n\t/**\n\t * Specify the max number of rows to show when collapsed\n\t * Default is `15`\n\t */\n\t@Input() maxCollapsedNumberOfRows = 15;\n\t/**\n\t * Specify the min number of rows to show when collapsed\n\t * Default is `3`\n\t */\n\t@Input() minCollapsedNumberOfRows = 3;\n\t/**\n\t * Specify the max number of rows to show when expanded\n\t * Default is `0`, hence all content will be visible when expanded\n\t */\n\t@Input() maxExpandedNumberOfRows = 0;\n\t/**\n\t * Specify the min number of rows to show when expanded\n\t * Default is `16`, hence height of expanded row will be 16 * rowHeightInPixel (16) = 256px\n\t */\n\t@Input() minExpandedNumberOfRows = 16;\n\t/**\n\t * Set to `true` to wrap the text\n\t */\n\t@HostBinding(\"class.cds--snippet--wraptext\") @Input() wrapText = false;\n\t/**\n\t * @deprecated since v5 - Use `cdsLayer` directive instead\n\t * Set to `\"light\"` to apply the light style\n\t */\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\t/**\n\t * Text displayed in the tooltip when user clicks button to copy code.\n\t */\n\t@Input() feedbackText = this.translations.COPIED;\n\t/**\n\t * Time in miliseconds to keep the feedback tooltip displayed.\n\t * Defaults to 2 seconds\n\t */\n\t@Input() feedbackTimeout = 2000;\n\n\t@HostBinding(\"class.cds--snippet--expand\") @Input() expanded = false;\n\t@HostBinding(\"class.cds--skeleton\") @Input() skeleton = false;\n\tstyles: any = {};\n\n\t@ViewChild(\"code\") code;\n\t@ViewChild(\"codeContent\") codeContent;\n\t@ViewChild(\"codeContainer\") codeContainer;\n\n\tshowFeedback = false;\n\tanimating = false;\n\thasExpandButton = null;\n\tisExpandable = false;\n\thasRightOverflow = false;\n\n\thasRight = false;\n\thasLeft = false;\n\n\t/**\n\t * Creates an instance of CodeSnippet.\n\t */\n\tconstructor(protected i18n: I18n, protected eventService: EventService) {\n\t\tsuper();\n\t\tthis.dropShadow = false;\n\t}\n\n\thandleScroll() {\n\t\tif (this.skeleton) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet ref;\n\t\tswitch (this.display) {\n\t\t\tcase \"multi\":\n\t\t\t\tref = this.codeContent.nativeElement;\n\t\t\t\tbreak;\n\t\t\tcase \"single\":\n\t\t\t\tref = this.codeContainer.nativeElement;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tif (ref) {\n\t\t\tconst {\n\t\t\t\tscrollWidth,\n\t\t\t\tclientWidth,\n\t\t\t\tscrollLeft\n\t\t\t} = ref;\n\t\t\tconst horizontalOverflow = scrollWidth > clientWidth;\n\t\t\tthis.hasLeft = horizontalOverflow && !!scrollLeft;\n\t\t\tthis.hasRight = horizontalOverflow && scrollLeft + clientWidth !== scrollWidth;\n\t\t}\n\t}\n\n\ttoggleSnippetExpansion() {\n\t\tthis.expanded = !this.expanded;\n\t\tthis.calculateContainerHeight();\n\t}\n\n\tonCopyButtonClicked() {\n\t\tif (!this.disabled) {\n\t\t\twindow.navigator.clipboard\n\t\t\t\t.writeText(this.code).then(() => {\n\t\t\t\t\tthis.showFeedback = true;\n\t\t\t\t\tthis.animating = true;\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.showFeedback = false;\n\t\t\t\t\t\tthis.animating = false;\n\t\t\t\t\t}, this.feedbackTimeout);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tngOnInit() {\n\t\tthis.calculateContainerHeight();\n\t}\n\n\tngAfterViewInit() {\n\t\tthis.canExpand();\n\t\tthis.handleScroll();\n\t\tif (window) {\n\t\t\tthis.eventService.on(window as any, \"resize\", () => {\n\t\t\t\tthis.canExpand();\n\t\t\t\tthis.handleScroll();\n\t\t\t});\n\t\t}\n\t}\n\n\tcalculateContainerHeight() {\n\t\tif (this.display === \"multi\" && !this.skeleton) {\n\t\t\tthis.styles = {};\n\t\t\tif (this.expanded) {\n\t\t\t\tif (this.maxExpandedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"max-height\"] = `${this.maxExpandedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t\tif (this.minExpandedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"min-height\"] = `${this.minExpandedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (this.maxCollapsedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"max-height\"] = `${this.maxCollapsedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t\tif (this.minCollapsedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"min-height\"] = `${this.minCollapsedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected canExpand() {\n\t\tif (this.display === \"multi\" && !this.skeleton) {\n\t\t\tconst height = this.codeContent.nativeElement.getBoundingClientRect().height;\n\t\t\tif (\n\t\t\t\tthis.maxCollapsedNumberOfRows > 0 &&\n\t\t\t\t(this.maxExpandedNumberOfRows <= 0 ||\n\t\t\t\t\tthis.maxExpandedNumberOfRows > this.maxCollapsedNumberOfRows) &&\n\t\t\t\theight > this.maxCollapsedNumberOfRows * this.rowHeightInPixel\n\t\t\t) {\n\t\t\t\tthis.isExpandable = true;\n\t\t\t} else {\n\t\t\t\tthis.isExpandable = false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tthis.expanded &&\n\t\t\t\tthis.minExpandedNumberOfRows > 0 &&\n\t\t\t\theight <= this.minExpandedNumberOfRows * this.rowHeightInPixel\n\t\t\t) {\n\t\t\t\tthis.isExpandable = false;\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
21979
|
+
"sourceCode": "import {\n\tComponent,\n\tInput,\n\tHostBinding,\n\tViewChild,\n\tAfterViewInit,\n\tOnInit\n} from \"@angular/core\";\n\nimport { I18n } from \"carbon-components-angular/i18n\";\nimport { EventService } from \"carbon-components-angular/utils\";\nimport { BaseIconButton } from \"carbon-components-angular/button\";\n\nexport enum SnippetType {\n\tsingle = \"single\",\n\tmulti = \"multi\",\n\tinline = \"inline\"\n}\n\n/**\n * Get started with importing the module:\n *\n * ```typescript\n * import { CodeSnippetModule } from 'carbon-components-angular';\n * ```\n *\n * ```html\n * <cds-code-snippet>Code</cds-code-snippet>\n * ```\n *\n * [See demo](../../?path=/story/components-code-snippet--basic)\n */\n@Component({\n\tselector: \"cds-code-snippet, ibm-code-snippet\",\n\ttemplate: `\n\t\t<ng-container *ngIf=\"display === 'inline'; else notInline\">\n\t\t\t<ng-container *ngIf=\"!hideCopyButton; else noBtnInline\">\n\t\t\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t\t\t</ng-container>\n\t\t\t<ng-template #noBtnInline>\n\t\t\t\t<span\n\t\t\t\t\tclass=\"cds--snippet cds--snippet--inline cds--snippet--no-copy\"\n\t\t\t\t\t[ngClass]=\"{\n\t\t\t\t\t\t'cds--snippet--light': theme === 'light'\n\t\t\t\t\t}\">\n\t\t\t\t\t<code #code>\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t\t\t</code>\n\t\t\t\t</span>\n\t\t\t</ng-template>\n\t\t</ng-container>\n\n\t\t<ng-template #notInline>\n\t\t\t<div\n\t\t\t\t#codeContainer\n\t\t\t\tclass=\"cds--snippet-container\"\n\t\t\t\t[attr.aria-label]=\"translations.CODE_SNIPPET_TEXT\"\n\t\t\t\t[attr.tabindex]=\"display === 'single' && !disabled ? '0' : null\"\n\t\t\t\t[attr.role]=\"display==='single' ? 'textarea' : null\"\n\t\t\t\t[ngStyle]=\"styles\"\n\t\t\t\t(scroll)=\"(display === 'single' ? handleScroll() : null)\">\n\t\t\t\t<ng-container *ngIf=\"skeleton\">\n\t\t\t\t\t<span *ngIf=\"display === 'single'; else multiSkeleton\"></span>\n\t\t\t\t\t<ng-template #multiSkeleton>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t\t<span></span>\n\t\t\t\t\t</ng-template>\n\t\t\t\t</ng-container>\n\t\t\t\t<pre\n\t\t\t\t\t#codeContent\n\t\t\t\t\t*ngIf=\"!skeleton\"\n\t\t\t\t\t(scroll)=\"(display === 'multi' ? handleScroll() : null)\"><code #code><ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container></code></pre>\n\t\t\t</div>\n\t\t\t<div *ngIf=\"hasLeft\" class=\"cds--snippet__overflow-indicator--left\"></div>\n\t\t\t<div *ngIf=\"hasRight\" class=\"cds--snippet__overflow-indicator--right\"></div>\n\t\t\t<ng-container *ngIf=\"!hideCopyButton;\">\n\t\t\t\t<ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\n\t\t\t</ng-container>\n\t\t\t<button\n\t\t\t\t*ngIf=\"isExpandable\"\n\t\t\t\tclass=\"cds--btn cds--btn--ghost cds--btn--sm cds--snippet-btn--expand\"\n\t\t\t\t(click)=\"toggleSnippetExpansion()\"\n\t\t\t\ttype=\"button\">\n\t\t\t\t<span class=\"cds--snippet-btn--text\">{{expanded ? translations.SHOW_LESS : translations.SHOW_MORE}}</span>\n\t\t\t\t<svg cdsIcon=\"chevron--down\" size=\"16\" class=\"cds--icon-chevron--down\" [attr.aria-label]=\"translations.SHOW_MORE_ICON\"></svg>\n\t\t\t</button>\n\t\t</ng-template>\n\n\t\t<ng-template #buttonTemplate>\n\t\t\t<cds-icon-button\n\t\t\t\t*ngIf=\"!skeleton\"\n\t\t\t\t[description]=\"showFeedback ? feedbackText : copyButtonDescription\"\n\t\t\t\t[align]=\"align\"\n\t\t\t\t[dropShadow]=\"dropShadow\"\n\t\t\t\t[caret]=\"caret\"\n\t\t\t\t[highContrast]=\"highContrast\"\n\t\t\t\t[isOpen]=\"isOpen\"\n\t\t\t\t[enterDelayMs]=\"enterDelayMs\"\n\t\t\t\t[leaveDelayMs]=\"leaveDelayMs\"\n\t\t\t\ttype=\"button\"\n\t\t\t\tkind=\"primary\"\n\t\t\t\tsize=\"md\"\n\t\t\t\t(click)=\"onCopyButtonClicked($event)\"\n\t\t\t\t[buttonNgClass]=\"{\n\t\t\t\t\t'cds--snippet--light': theme === 'light',\n\t\t\t\t\t'cds--snippet--inline': display === 'inline',\n\t\t\t\t\t'cds--btn--icon-only': display !== 'inline',\n\t\t\t\t\t'cds--copy-btn': display !== 'inline',\n\t\t\t\t\t'cds--copy-btn--animating': animating,\n\t\t\t\t\t'cds--copy-btn--fade-in': showFeedback,\n\t\t\t\t\t'cds--copy-btn--fade-out': !showFeedback && animating,\n\t\t\t\t\t'cds--snippet cds--copy': true\n\t\t\t\t}\"\n\t\t\t\t[buttonAttributes]=\"{\n\t\t\t\t\t'aria-label': translations.COPY_CODE,\n\t\t\t\t\t'aria-live': 'polite',\n\t\t\t\t\t'tabindex': '0'\n\t\t\t\t}\">\n\t\t\t\t<ng-container *ngIf=\"display === 'inline'\">\n\t\t\t\t\t<code #code>\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"codeTemplate\"></ng-container>\n\t\t\t\t\t</code>\n\t\t\t\t</ng-container>\n\t\t\t\t<ng-container *ngIf=\"display !== 'inline'\">\n\t\t\t\t\t<svg cdsIcon=\"copy\" size=\"16\" class=\"cds--snippet__icon\"></svg>\n\t\t\t\t</ng-container>\n\t\t\t</cds-icon-button>\n\t\t</ng-template>\n\n\t\t<ng-template #codeTemplate>\n\t\t\t<ng-content></ng-content>\n\t\t</ng-template>\n\t`\n})\nexport class CodeSnippet extends BaseIconButton implements OnInit, AfterViewInit {\n\t@HostBinding(\"class.cds--snippet\") get snippetClass() {\n\t\treturn this.display !== SnippetType.inline;\n\t}\n\t@HostBinding(\"class.cds--snippet--single\") get snippetSingleClass() {\n\t\treturn this.display === SnippetType.single;\n\t}\n\t@HostBinding(\"class.cds--snippet--multi\") get snippetMultiClass() {\n\t\treturn this.display === SnippetType.multi;\n\t}\n\t@HostBinding(\"class.cds--snippet--disabled\") get snippetDisabledClass() {\n\t\treturn this.display !== \"inline\" && this.disabled;\n\t}\n\t@HostBinding(\"class.cds--snippet--light\") get snippetInlineLightClass() {\n\t\treturn this.theme === \"light\";\n\t}\n\n\treadonly rowHeightInPixel: number = 16;\n\n\t/**\n\t * It can be `\"single\"`, `\"multi\"` or `\"inline\"`\n\t */\n\t@Input() display: SnippetType = SnippetType.single;\n\t@Input() translations = this.i18n.get().CODE_SNIPPET;\n\t/**\n\t * copy button description to show on hover\n\t */\n\t@Input() copyButtonDescription: string;\n\t/**\n\t * Set to `true` to hide copy button\n\t */\n\t@Input() hideCopyButton = false;\n\t/**\n\t * Set to `true` to disable the code snippet\n\t */\n\t@Input() disabled = false;\n\t/**\n\t * Specify the max number of rows to show when collapsed\n\t * Default is `15`\n\t */\n\t@Input() maxCollapsedNumberOfRows = 15;\n\t/**\n\t * Specify the min number of rows to show when collapsed\n\t * Default is `3`\n\t */\n\t@Input() minCollapsedNumberOfRows = 3;\n\t/**\n\t * Specify the max number of rows to show when expanded\n\t * Default is `0`, hence all content will be visible when expanded\n\t */\n\t@Input() maxExpandedNumberOfRows = 0;\n\t/**\n\t * Specify the min number of rows to show when expanded\n\t * Default is `16`, hence height of expanded row will be 16 * rowHeightInPixel (16) = 256px\n\t */\n\t@Input() minExpandedNumberOfRows = 16;\n\t/**\n\t * Set to `true` to wrap the text\n\t */\n\t@HostBinding(\"class.cds--snippet--wraptext\") @Input() wrapText = false;\n\t/**\n\t * @deprecated since v5 - Use `cdsLayer` directive instead\n\t * Set to `\"light\"` to apply the light style\n\t */\n\t@Input() theme: \"light\" | \"dark\" = \"dark\";\n\t/**\n\t * Text displayed in the tooltip when user clicks button to copy code.\n\t */\n\t@Input() feedbackText = this.translations.COPIED;\n\t/**\n\t * Time in miliseconds to keep the feedback tooltip displayed.\n\t * Defaults to 2 seconds\n\t */\n\t@Input() feedbackTimeout = 2000;\n\n\t@HostBinding(\"class.cds--snippet--expand\") @Input() expanded = false;\n\t@HostBinding(\"class.cds--skeleton\") @Input() skeleton = false;\n\tstyles: any = {};\n\n\t@ViewChild(\"code\") code;\n\t@ViewChild(\"codeContent\") codeContent;\n\t@ViewChild(\"codeContainer\") codeContainer;\n\n\tshowFeedback = false;\n\tanimating = false;\n\thasExpandButton = null;\n\tisExpandable = false;\n\thasRightOverflow = false;\n\n\thasRight = false;\n\thasLeft = false;\n\n\t/**\n\t * Creates an instance of CodeSnippet.\n\t */\n\tconstructor(protected i18n: I18n, protected eventService: EventService) {\n\t\tsuper();\n\t\tthis.dropShadow = false;\n\t}\n\n\thandleScroll() {\n\t\tif (this.skeleton) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet ref;\n\t\tswitch (this.display) {\n\t\t\tcase \"multi\":\n\t\t\t\tref = this.codeContent.nativeElement;\n\t\t\t\tbreak;\n\t\t\tcase \"single\":\n\t\t\t\tref = this.codeContainer.nativeElement;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\t\tif (ref) {\n\t\t\tconst {\n\t\t\t\tscrollWidth,\n\t\t\t\tclientWidth,\n\t\t\t\tscrollLeft\n\t\t\t} = ref;\n\t\t\tconst horizontalOverflow = scrollWidth > clientWidth;\n\t\t\tthis.hasLeft = horizontalOverflow && !!scrollLeft;\n\t\t\tthis.hasRight = horizontalOverflow && scrollLeft + clientWidth !== scrollWidth;\n\t\t}\n\t}\n\n\ttoggleSnippetExpansion() {\n\t\tthis.expanded = !this.expanded;\n\t\tthis.calculateContainerHeight();\n\t}\n\n\tonCopyButtonClicked() {\n\t\tif (!this.disabled) {\n\t\t\twindow.navigator.clipboard\n\t\t\t\t.writeText(this.code).then(() => {\n\t\t\t\t\tthis.showFeedback = true;\n\t\t\t\t\tthis.animating = true;\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis.showFeedback = false;\n\t\t\t\t\t\tthis.animating = false;\n\t\t\t\t\t}, this.feedbackTimeout);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tngOnInit() {\n\t\tthis.calculateContainerHeight();\n\t}\n\n\tngAfterViewInit() {\n\t\tthis.canExpand();\n\t\tthis.handleScroll();\n\t\tif (window) {\n\t\t\tthis.eventService.on(window as any, \"resize\", () => {\n\t\t\t\tthis.canExpand();\n\t\t\t\tthis.handleScroll();\n\t\t\t});\n\t\t}\n\t}\n\n\tcalculateContainerHeight() {\n\t\tif (this.display === \"multi\" && !this.skeleton) {\n\t\t\tthis.styles = {};\n\t\t\tif (this.expanded) {\n\t\t\t\tif (this.maxExpandedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"max-height\"] = `${this.maxExpandedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t\tif (this.minExpandedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"min-height\"] = `${this.minExpandedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (this.maxCollapsedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"max-height\"] = `${this.maxCollapsedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t\tif (this.minCollapsedNumberOfRows > 0) {\n\t\t\t\t\tthis.styles[\"min-height\"] = `${this.minCollapsedNumberOfRows * this.rowHeightInPixel}px`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected canExpand() {\n\t\tif (this.display === \"multi\" && !this.skeleton) {\n\t\t\tconst height = this.codeContent.nativeElement.getBoundingClientRect().height;\n\t\t\tif (\n\t\t\t\tthis.maxCollapsedNumberOfRows > 0 &&\n\t\t\t\t(this.maxExpandedNumberOfRows <= 0 ||\n\t\t\t\t\tthis.maxExpandedNumberOfRows > this.maxCollapsedNumberOfRows) &&\n\t\t\t\theight > this.maxCollapsedNumberOfRows * this.rowHeightInPixel\n\t\t\t) {\n\t\t\t\tthis.isExpandable = true;\n\t\t\t} else {\n\t\t\t\tthis.isExpandable = false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tthis.expanded &&\n\t\t\t\tthis.minExpandedNumberOfRows > 0 &&\n\t\t\t\theight <= this.minExpandedNumberOfRows * this.rowHeightInPixel\n\t\t\t) {\n\t\t\t\tthis.isExpandable = false;\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
21980
21980
|
"assetsDirs": [],
|
|
21981
21981
|
"styleUrlsData": "",
|
|
21982
21982
|
"stylesData": "",
|
|
@@ -21999,7 +21999,7 @@
|
|
|
21999
21999
|
"deprecationMessage": ""
|
|
22000
22000
|
}
|
|
22001
22001
|
],
|
|
22002
|
-
"line":
|
|
22002
|
+
"line": 226,
|
|
22003
22003
|
"rawdescription": "\n\nCreates an instance of CodeSnippet.\n",
|
|
22004
22004
|
"jsdoctags": [
|
|
22005
22005
|
{
|
|
@@ -22034,7 +22034,7 @@
|
|
|
22034
22034
|
"name": "snippetClass",
|
|
22035
22035
|
"type": "",
|
|
22036
22036
|
"returnType": "",
|
|
22037
|
-
"line":
|
|
22037
|
+
"line": 137
|
|
22038
22038
|
}
|
|
22039
22039
|
},
|
|
22040
22040
|
"snippetSingleClass": {
|
|
@@ -22043,7 +22043,7 @@
|
|
|
22043
22043
|
"name": "snippetSingleClass",
|
|
22044
22044
|
"type": "",
|
|
22045
22045
|
"returnType": "",
|
|
22046
|
-
"line":
|
|
22046
|
+
"line": 140
|
|
22047
22047
|
}
|
|
22048
22048
|
},
|
|
22049
22049
|
"snippetMultiClass": {
|
|
@@ -22052,7 +22052,7 @@
|
|
|
22052
22052
|
"name": "snippetMultiClass",
|
|
22053
22053
|
"type": "",
|
|
22054
22054
|
"returnType": "",
|
|
22055
|
-
"line":
|
|
22055
|
+
"line": 143
|
|
22056
22056
|
}
|
|
22057
22057
|
},
|
|
22058
22058
|
"snippetDisabledClass": {
|
|
@@ -22061,7 +22061,7 @@
|
|
|
22061
22061
|
"name": "snippetDisabledClass",
|
|
22062
22062
|
"type": "",
|
|
22063
22063
|
"returnType": "",
|
|
22064
|
-
"line":
|
|
22064
|
+
"line": 146
|
|
22065
22065
|
}
|
|
22066
22066
|
},
|
|
22067
22067
|
"snippetInlineLightClass": {
|
|
@@ -22070,7 +22070,7 @@
|
|
|
22070
22070
|
"name": "snippetInlineLightClass",
|
|
22071
22071
|
"type": "",
|
|
22072
22072
|
"returnType": "",
|
|
22073
|
-
"line":
|
|
22073
|
+
"line": 149
|
|
22074
22074
|
}
|
|
22075
22075
|
}
|
|
22076
22076
|
}
|