@carbon/ibm-products-web-components 0.3.0 → 0.4.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.
Files changed (33) hide show
  1. package/.storybook/main.ts +13 -5
  2. package/CHANGELOG.md +21 -0
  3. package/es/components/side-panel/defs.js.map +1 -1
  4. package/es/components/side-panel/side-panel.d.ts +4 -4
  5. package/es/components/side-panel/side-panel.js +9 -18
  6. package/es/components/side-panel/side-panel.js.map +1 -1
  7. package/es/components/side-panel/side-panel.scss.js +1 -1
  8. package/es/components/side-panel/side-panel.test.js.map +1 -1
  9. package/es/components/tearsheet/defs.js.map +1 -1
  10. package/es/components/tearsheet/tearsheet.js +5 -14
  11. package/es/components/tearsheet/tearsheet.js.map +1 -1
  12. package/es/components/tearsheet/tearsheet.scss.js +1 -1
  13. package/es/components/tearsheet/tearsheet.test.js.map +1 -1
  14. package/es/globals/internal/storybook-cdn.js +80 -0
  15. package/es/globals/internal/storybook-cdn.js.map +1 -0
  16. package/es/globals/settings.js.map +1 -1
  17. package/es/packages/ibm-products-web-components/package.json.js +121 -0
  18. package/es/packages/ibm-products-web-components/package.json.js.map +1 -0
  19. package/lib/components/side-panel/defs.js.map +1 -1
  20. package/lib/components/side-panel/side-panel.d.ts +4 -4
  21. package/lib/components/tearsheet/defs.js.map +1 -1
  22. package/lib/globals/settings.js.map +1 -1
  23. package/package.json +11 -10
  24. package/scss/components/tearsheet/tearsheet.scss +6 -0
  25. package/src/components/side-panel/side-panel.mdx +1 -10
  26. package/src/components/side-panel/side-panel.stories.ts +1 -1
  27. package/src/components/side-panel/side-panel.ts +5 -5
  28. package/src/components/tearsheet/tearsheet.mdx +1 -9
  29. package/src/components/tearsheet/tearsheet.scss +6 -0
  30. package/src/components/tearsheet/tearsheet.stories.ts +52 -41
  31. package/src/components/tearsheet/tearsheet.ts +1 -1
  32. package/src/globals/internal/storybook-cdn.ts +69 -0
  33. package/tasks/build.js +2 -0
@@ -16,6 +16,7 @@ import {
16
16
  import './index';
17
17
  import '@carbon/web-components/es/components/tabs/index.js';
18
18
  import '@carbon/web-components/es/components/slug/index.js';
19
+ import '@carbon/web-components/es/components/dropdown/index.js';
19
20
  import '@carbon/web-components/es/components/progress-indicator/index.js';
20
21
  import '@carbon/web-components/es/components/progress-bar/index.js';
21
22
  import '@carbon/web-components/es/components/button/index.js';
@@ -25,10 +26,15 @@ import { prefix } from '../../globals/settings';
25
26
 
26
27
  import styles from './story-styles.scss?lit';
27
28
  import { BUTTON_KIND } from '@carbon/web-components/es/components/button/defs.js';
29
+
28
30
  const toggleButton = () => {
29
31
  document.querySelector(`${prefix}-tearsheet`)?.toggleAttribute('open');
30
32
  };
31
33
 
34
+ const cancelButton = () => {
35
+ document.querySelector(`${prefix}-tearsheet`)?.removeAttribute('open');
36
+ };
37
+
32
38
  const widths = {
33
39
  // 'default (narrow)': null,
34
40
  [`Narrow (${TEARSHEET_WIDTH.NARROW})`]: TEARSHEET_WIDTH.NARROW,
@@ -205,7 +211,7 @@ const headerActions = {
205
211
  const getActionToolbarItems = (index) => {
206
212
  switch (index) {
207
213
  case 1:
208
- return html`<cds-dropdown slot="header-actions">
214
+ return html`<cds-dropdown slot="header-actions" value="option 1">
209
215
  ${['option 1', 'option 2', 'option 3', 'option 4'].map(
210
216
  (option) => html` <cds-dropdown-item value="${option}"
211
217
  >${option}</cds-dropdown-item
@@ -250,7 +256,12 @@ const actionItems = {
250
256
 
251
257
  const toActions = (kinds: BUTTON_KIND[]) => {
252
258
  return kinds?.map((kind) => {
253
- return html`<cds-button key=${kind} slot="actions" kind=${kind}>
259
+ return html`<cds-button
260
+ key=${kind}
261
+ slot="actions"
262
+ kind=${kind}
263
+ @click=${kind === 'ghost' && cancelButton}
264
+ >
254
265
  ${kind.charAt(0).toUpperCase() + kind.slice(1)}
255
266
  </cds-button>`;
256
267
  });
@@ -359,21 +370,21 @@ const getSlug = (index) => {
359
370
 
360
371
  export const Default = {
361
372
  args: {
362
- actionItems: getActionItems(4),
363
- headerActions: getActionToolbarItems(0),
364
- content: getContent(2),
365
- label: getLabel(1),
373
+ actionItems: 4,
374
+ headerActions: 0,
375
+ content: 2,
376
+ label: 1,
366
377
  open: false,
367
378
  influencerWidth: TEARSHEET_INFLUENCER_WIDTH.NARROW,
368
379
  influencerPlacement: TEARSHEET_INFLUENCER_PLACEMENT.LEFT,
369
- influencer: getInfluencer(0),
380
+ influencer: 0,
370
381
  preventCloseOnClickOutside: false,
371
382
  selectorInitialFocus: '',
372
383
  width: TEARSHEET_WIDTH.WIDE,
373
- slug: getSlug(0),
384
+ slug: 0,
374
385
  description: 'Description used to describe the flow if need be.',
375
386
  title: 'Title used to designate the overarching flow of the tearsheet.',
376
- headerNavigation: getNavigation(0),
387
+ headerNavigation: 0,
377
388
  },
378
389
  argTypes: {
379
390
  actionItems: {
@@ -465,10 +476,10 @@ export const Default = {
465
476
  width=${args.width}
466
477
  >
467
478
  <!-- default slotted content -->
468
- ${args.content}
479
+ ${getContent(args.content)}
469
480
 
470
481
  <!-- slotted header label -->
471
- ${args.label}
482
+ ${getLabel(args.label)}
472
483
 
473
484
  <!-- slotted header title -->
474
485
  ${args.title ? html`<span slot="title">${args.title}</span>` : ''}
@@ -479,19 +490,19 @@ export const Default = {
479
490
  : ''}
480
491
 
481
492
  <!-- slotted action in header cds-buttons -->
482
- ${args.headerActions}
493
+ ${getActionToolbarItems(args.headerActions)}
483
494
 
484
495
  <!-- slotted action items cds-buttons -->
485
- ${args.actionItems}
496
+ ${getActionItems(args.actionItems)}
486
497
 
487
498
  <!-- slotted slug -->
488
- ${args.slug}
499
+ ${getSlug(args.slug)}
489
500
 
490
501
  <!-- slotted header-navigation -->
491
- ${args.headerNavigation}
502
+ ${getNavigation(args.headerNavigation)}
492
503
 
493
504
  <!-- slotted influencer -->
494
- ${args.influencer}
505
+ ${getInfluencer(args.influencer)}
495
506
  </c4p-tearsheet>
496
507
  `;
497
508
  },
@@ -501,7 +512,7 @@ export const WithNavigation = {
501
512
  ...Default,
502
513
  args: {
503
514
  ...Default.args,
504
- headerNavigation: getNavigation(1),
515
+ headerNavigation: 1,
505
516
  },
506
517
  };
507
518
 
@@ -509,7 +520,7 @@ export const WithInfluencer = {
509
520
  ...Default,
510
521
  args: {
511
522
  ...Default.args,
512
- influencer: getInfluencer(2),
523
+ influencer: 2,
513
524
  },
514
525
  };
515
526
 
@@ -517,8 +528,8 @@ export const WithAllHeaderItemsAndInfluencer = {
517
528
  ...Default,
518
529
  args: {
519
530
  ...Default.args,
520
- headerActions: getActionToolbarItems(2),
521
- influencer: getInfluencer(2),
531
+ headerActions: 2,
532
+ influencer: 2,
522
533
  },
523
534
  };
524
535
 
@@ -581,10 +592,10 @@ export const StackingTemplate = {
581
592
  <cds-button @click="${() => toggleButton('two')}"
582
593
  >Toggle tearsheet two</cds-button
583
594
  >
584
- ${args.content}
595
+ ${getContent(args.content)}
585
596
 
586
597
  <!-- slotted header label -->
587
- ${args.label}
598
+ ${getLabel(args.label)}
588
599
 
589
600
  <!-- slotted header title -->
590
601
  ${args.title ? html`<span slot="title">One ${args.title}</span>` : ''}
@@ -595,19 +606,19 @@ export const StackingTemplate = {
595
606
  : ''}
596
607
 
597
608
  <!-- slotted action in header cds-buttons -->
598
- ${args.headerActions}
609
+ ${getActionToolbarItems(args.headerActions)}
599
610
 
600
611
  <!-- slotted action items cds-buttons -->
601
- ${args.actionItems}
612
+ ${getActionItems(args.actionItems)}
602
613
 
603
614
  <!-- slotted slug -->
604
- ${args.slug}
615
+ ${getSlug(args.slug)}
605
616
 
606
617
  <!-- slotted header-navigation -->
607
- ${args.headerNavigation}
618
+ ${getNavigation(args.headerNavigation)}
608
619
 
609
620
  <!-- slotted influencer -->
610
- ${args.influencer}
621
+ ${getInfluencer(args.influencer)}
611
622
  </c4p-tearsheet>
612
623
  <c4p-tearsheet
613
624
  data-index="two"
@@ -624,10 +635,10 @@ export const StackingTemplate = {
624
635
  <cds-button @click="${() => toggleButton('three')}"
625
636
  >Toggle tearsheet three</cds-button
626
637
  >
627
- ${args.content}
638
+ ${getContent(args.content)}
628
639
 
629
640
  <!-- slotted header label -->
630
- ${args.label}
641
+ ${getLabel(args.label)}
631
642
 
632
643
  <!-- slotted header title -->
633
644
  ${args.title ? html`<span slot="title">Two ${args.title}</span>` : ''}
@@ -638,19 +649,19 @@ export const StackingTemplate = {
638
649
  : ''}
639
650
 
640
651
  <!-- slotted action in header cds-buttons -->
641
- ${args.headerActions}
652
+ ${getActionToolbarItems(args.headerActions)}
642
653
 
643
654
  <!-- slotted action items cds-buttons -->
644
- ${args.actionItems}
655
+ ${getActionItems(args.actionItems)}
645
656
 
646
657
  <!-- slotted slug -->
647
- ${args.slug}
658
+ ${getSlug(args.slug)}
648
659
 
649
660
  <!-- slotted header-navigation -->
650
- ${args.headerNavigation}
661
+ ${getNavigation(args.headerNavigation)}
651
662
 
652
663
  <!-- slotted influencer -->
653
- ${args.influencer}
664
+ ${getInfluencer(args.influencer)}
654
665
  </c4p-tearsheet>
655
666
  <c4p-tearsheet
656
667
  data-index="three"
@@ -664,10 +675,10 @@ export const StackingTemplate = {
664
675
  width=${args.width}
665
676
  >
666
677
  <!-- default slotted content -->
667
- ${args.content}
678
+ ${getContent(args.content)}
668
679
 
669
680
  <!-- slotted header label -->
670
- ${args.label}
681
+ ${getLabel(args.label)}
671
682
 
672
683
  <!-- slotted header title -->
673
684
  ${args.title ? html`<span slot="title">Three ${args.title}</span>` : ''}
@@ -678,19 +689,19 @@ export const StackingTemplate = {
678
689
  : ''}
679
690
 
680
691
  <!-- slotted action in header cds-buttons -->
681
- ${args.headerActions}
692
+ ${getActionToolbarItems(args.headerActions)}
682
693
 
683
694
  <!-- slotted action items cds-buttons -->
684
- ${args.actionItems}
695
+ ${getActionItems(args.actionItems)}
685
696
 
686
697
  <!-- slotted slug -->
687
- ${args.slug}
698
+ ${getSlug(args.slug)}
688
699
 
689
700
  <!-- slotted header-navigation -->
690
- ${args.headerNavigation}
701
+ ${getNavigation(args.headerNavigation)}
691
702
 
692
703
  <!-- slotted influencer -->
693
- ${args.influencer}
704
+ ${getInfluencer(args.influencer)}
694
705
  </c4p-tearsheet>
695
706
  `;
696
707
  },
@@ -314,7 +314,7 @@ class CDSTearsheet extends HostListenerMixin(LitElement) {
314
314
 
315
315
  this._hasSlug = childItems.length > 0;
316
316
  if (this._hasSlug) {
317
- childItems[0].setAttribute('size', 'lg');
317
+ childItems[0].setAttribute('size', 'sm');
318
318
  this.setAttribute('slug', '');
319
319
  } else {
320
320
  this.removeAttribute('slug');
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2021, 2024
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ import packageJson from '../../../package.json';
11
+
12
+ /* eslint-disable max-len */
13
+
14
+ /**
15
+ *
16
+ */
17
+ /**
18
+ * Renders the component(s) script tag content and returns back the string
19
+ *
20
+ * @param {Array} components array of component names
21
+ * @param {string} tag tag folder
22
+ */
23
+ function _renderScript(components, tag) {
24
+ let scripts = '';
25
+ components.forEach((component) => {
26
+ scripts += `<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/${tag}/${component}.min.js"></script>\n`;
27
+ });
28
+ return scripts;
29
+ }
30
+
31
+ /**
32
+ * This is the markdown block for JS via CDN
33
+ *
34
+ * @param {Array} components array of components to render
35
+ * @param components.components components to render
36
+ */
37
+ export const cdnJs = ({ components }) => {
38
+ return `
39
+ ### JS (via CDN)
40
+
41
+ > NOTE: Only one version of artifacts should be used. Mixing versions will cause rendering issues.
42
+
43
+ \`\`\`html
44
+ // SPECIFIC VERSION (available starting v2.0.0)
45
+ ${_renderScript(components, `version/v${packageJson.version}`)}
46
+ \`\`\`
47
+
48
+ #### Right-to-left (RTL) versions
49
+
50
+ \`\`\`html
51
+ // SPECIFIC VERSION (available starting v2.0.0)
52
+ ${_renderScript(components, `version/v${packageJson.version}`)}
53
+ \`\`\`
54
+ `;
55
+ };
56
+
57
+ /**
58
+ * This is the markdown block for CSS via CDN
59
+ */
60
+ export const cdnCss = () => {
61
+ return `
62
+ ### Carbon CDN style helpers (optional)
63
+
64
+ There are optional CDN artifacts available that can assist with global Carbon
65
+ styles in lieu of including into your specific application bundle.
66
+
67
+ [Click here to learn more](https://github.com/carbon-design-system/carbon-for-ibm-dotcom/blob/main/packages/web-components/docs/carbon-cdn-style-helpers.md)\n\n
68
+ `;
69
+ };
package/tasks/build.js CHANGED
@@ -22,6 +22,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
22
22
  import path from 'path';
23
23
  import postcss from 'postcss';
24
24
  import typescript from '@rollup/plugin-typescript';
25
+ import json from '@rollup/plugin-json';
25
26
 
26
27
  import * as packageJson from '../package.json' assert { type: 'json' };
27
28
 
@@ -125,6 +126,7 @@ function getRollupConfig(input, rootDir, outDir, iconInput) {
125
126
  targets: [{ src: 'src/components/**/*.scss', dest: 'scss' }],
126
127
  flatten: false,
127
128
  }),
129
+ [json()],
128
130
  nodeResolve({
129
131
  browser: true,
130
132
  mainFields: ['jsnext', 'module', 'main'],