@carbon/ibm-products-web-components 0.1.0 → 0.1.1-canary.3599

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/.storybook/main.ts +15 -1
  2. package/.storybook/preview-head.html +5 -1
  3. package/.storybook/{theme.ts → theme.js} +2 -2
  4. package/es/components/side-panel/side-panel.d.ts +61 -80
  5. package/es/components/side-panel/side-panel.scss.js +1 -1
  6. package/es/components/tearsheet/defs.d.ts +26 -0
  7. package/es/components/tearsheet/defs.js +39 -0
  8. package/es/components/tearsheet/defs.js.map +1 -0
  9. package/es/components/tearsheet/index.d.ts +9 -0
  10. package/es/components/tearsheet/index.js +9 -0
  11. package/es/components/tearsheet/index.js.map +1 -0
  12. package/es/components/tearsheet/tearsheet.d.ts +490 -0
  13. package/es/components/tearsheet/tearsheet.js +685 -0
  14. package/es/components/tearsheet/tearsheet.js.map +1 -0
  15. package/es/components/tearsheet/tearsheet.scss.js +13 -0
  16. package/es/components/tearsheet/tearsheet.scss.js.map +1 -0
  17. package/es/components/tearsheet/tearsheet.test.d.ts +7 -0
  18. package/es/components/tearsheet/tearsheet.test.js +122 -0
  19. package/es/components/tearsheet/tearsheet.test.js.map +1 -0
  20. package/es/index.d.ts +1 -0
  21. package/es/index.js +1 -0
  22. package/es/index.js.map +1 -1
  23. package/lib/components/side-panel/side-panel.d.ts +61 -80
  24. package/lib/components/tearsheet/defs.d.ts +26 -0
  25. package/lib/components/tearsheet/defs.js +39 -0
  26. package/lib/components/tearsheet/defs.js.map +1 -0
  27. package/lib/components/tearsheet/index.d.ts +9 -0
  28. package/lib/components/tearsheet/tearsheet.d.ts +490 -0
  29. package/lib/components/tearsheet/tearsheet.test.d.ts +7 -0
  30. package/lib/index.d.ts +1 -0
  31. package/package.json +17 -17
  32. package/scss/components/tearsheet/story-styles.scss +23 -0
  33. package/scss/components/tearsheet/tearsheet.scss +318 -0
  34. package/src/components/tearsheet/defs.ts +30 -0
  35. package/src/components/tearsheet/index.ts +10 -0
  36. package/src/components/tearsheet/story-styles.scss +23 -0
  37. package/src/components/tearsheet/tearsheet.mdx +101 -0
  38. package/src/components/tearsheet/tearsheet.scss +318 -0
  39. package/src/components/tearsheet/tearsheet.stories.ts +703 -0
  40. package/src/components/tearsheet/tearsheet.test.ts +118 -0
  41. package/src/components/tearsheet/tearsheet.ts +792 -0
  42. package/src/index.ts +1 -0
  43. package/netlify.toml +0 -8
  44. /package/.storybook/{Preview.ts → preview.ts} +0 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ vi.mock('@carbon/icons/lib/close/20', () => vi.fn().mockReturnValue({}));
9
+ import { describe, expect, it, vi } from 'vitest';
10
+ import { render, html } from 'lit';
11
+
12
+ const defaultProps = {
13
+ actionItems: `
14
+ <cds-button key="ghost" slot="actions" kind="ghost">Ghost</cds-button>
15
+ <cds-button key="secondary" slot="actions" kind="secondary">Secondary</cds-button>
16
+ <cds-button key="primary" slot="actions" kind="primary">Primary</cds-button>
17
+ `,
18
+ headerActions: '',
19
+ content: `<div>
20
+ <h5>Section</h5>
21
+ <div>
22
+ <cds-text-input
23
+ label="Input A"
24
+ id="tearsheet-story-text-input-a"
25
+ ></cds-text-input>
26
+ <cds-text-input
27
+ label="Input B"
28
+ id="tearsheet-story-text-input-b"
29
+ ></cds-text-input>
30
+ </div>
31
+ <div">
32
+ <cds-text-input
33
+ label="Input C"
34
+ id="tearsheet-story-text-input-c"
35
+ ></cds-text-input>
36
+ <cds-text-input
37
+ label="Input D"
38
+ id="tearsheet-story-text-input-d"
39
+ ></cds-text-input>
40
+ </div>
41
+ <div>
42
+ <cds-textarea
43
+ label="Notes"
44
+ value="This is a text area"
45
+ ></cds-textarea>
46
+ <cds-textarea
47
+ label="Notes"
48
+ value="This is a text area"
49
+ ></cds-textarea>
50
+ <cds-textarea
51
+ label="Notes"
52
+ value="This is a text area"
53
+ ></cds-textarea>
54
+ </div>
55
+ </div>`,
56
+ label: `<span slot="label">Optional label for context</span>`,
57
+ open: false,
58
+ influencerWidth: 'narrow',
59
+ influencerPlacement: 'left',
60
+ influencer: '',
61
+ preventCloseOnClickOutside: false,
62
+ selectorInitialFocus: '',
63
+ width: 'wide',
64
+ slug: '',
65
+ description: 'Description used to describe the flow if need be.',
66
+ title: 'Title used to designate the overarching flow of the tearsheet.',
67
+ headerNavigation: '',
68
+ };
69
+
70
+ const template = (props = defaultProps) =>
71
+ html`
72
+ <c4p-tearsheet
73
+ selector-initial-focus=${props.selectorInitialFocus}
74
+ ?open=${props.open}
75
+ influencer-placement=${props.influencerPlacement}
76
+ influencer-width=${props.influencerWidth}
77
+ ?prevent-close-on-click-outside=${props.preventCloseOnClickOutside}
78
+ width=${props.width}
79
+ >
80
+ <!-- default slotted content -->
81
+ ${props.content}
82
+
83
+ <!-- slotted header label -->
84
+ ${props.label}
85
+
86
+ <!-- slotted header title -->
87
+ ${props.title ? html`<span slot="title">${props.title}</span>` : ''}
88
+
89
+ <!-- slotted header description -->
90
+ ${props.description
91
+ ? html`<span slot="description">${props.description}</span>`
92
+ : ''}
93
+
94
+ <!-- slotted action in header cds-buttons -->
95
+ ${props.headerActions}
96
+
97
+ <!-- slotted action items cds-buttons -->
98
+ ${props.actionItems}
99
+
100
+ <!-- slotted slug -->
101
+ ${props.slug}
102
+
103
+ <!-- slotted header-navigation -->
104
+ ${props.headerNavigation}
105
+
106
+ <!-- slotted influencer -->
107
+ ${props.influencer}
108
+ </c4p-tearsheet>
109
+ `;
110
+
111
+ describe('c4p-tearsheet', () => {
112
+ it('should render a tearsheet', async () => {
113
+ render(template(), document.body);
114
+ await Promise.resolve();
115
+ const elem = document.body.querySelector('c4p-tearsheet' as any);
116
+ expect(elem).toBeDefined();
117
+ });
118
+ });