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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) 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.js +5 -3
  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/tearsheet/defs.d.ts +26 -0
  9. package/es/components/tearsheet/defs.js +39 -0
  10. package/es/components/tearsheet/defs.js.map +1 -0
  11. package/es/components/tearsheet/index.d.ts +9 -0
  12. package/es/components/tearsheet/index.js +9 -0
  13. package/es/components/tearsheet/index.js.map +1 -0
  14. package/es/components/tearsheet/tearsheet.d.ts +490 -0
  15. package/es/components/tearsheet/tearsheet.js +685 -0
  16. package/es/components/tearsheet/tearsheet.js.map +1 -0
  17. package/es/components/tearsheet/tearsheet.scss.js +13 -0
  18. package/es/components/tearsheet/tearsheet.scss.js.map +1 -0
  19. package/es/components/tearsheet/tearsheet.test.d.ts +7 -0
  20. package/es/components/tearsheet/tearsheet.test.js +122 -0
  21. package/es/components/tearsheet/tearsheet.test.js.map +1 -0
  22. package/es/index.d.ts +1 -0
  23. package/es/index.js +1 -0
  24. package/es/index.js.map +1 -1
  25. package/lib/components/side-panel/side-panel.d.ts +61 -80
  26. package/lib/components/tearsheet/defs.d.ts +26 -0
  27. package/lib/components/tearsheet/defs.js +39 -0
  28. package/lib/components/tearsheet/defs.js.map +1 -0
  29. package/lib/components/tearsheet/index.d.ts +9 -0
  30. package/lib/components/tearsheet/tearsheet.d.ts +490 -0
  31. package/lib/components/tearsheet/tearsheet.test.d.ts +7 -0
  32. package/lib/index.d.ts +1 -0
  33. package/package.json +17 -17
  34. package/scss/components/tearsheet/story-styles.scss +23 -0
  35. package/scss/components/tearsheet/tearsheet.scss +318 -0
  36. package/src/components/side-panel/side-panel.ts +5 -5
  37. package/src/components/tearsheet/defs.ts +30 -0
  38. package/src/components/tearsheet/index.ts +10 -0
  39. package/src/components/tearsheet/story-styles.scss +23 -0
  40. package/src/components/tearsheet/tearsheet.mdx +101 -0
  41. package/src/components/tearsheet/tearsheet.scss +318 -0
  42. package/src/components/tearsheet/tearsheet.stories.ts +703 -0
  43. package/src/components/tearsheet/tearsheet.test.ts +118 -0
  44. package/src/components/tearsheet/tearsheet.ts +792 -0
  45. package/src/index.ts +1 -0
  46. package/netlify.toml +0 -8
  47. /package/.storybook/{Preview.ts → preview.ts} +0 -0
@@ -0,0 +1,318 @@
1
+ /*
2
+ * Copyright IBM Corp. 2023, 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
+ $css--plex: true !default;
9
+
10
+ /* Other Carbon settings. */
11
+ @use '@carbon/styles/scss/reset';
12
+ @use '@carbon/styles/scss/breakpoint' as *;
13
+ @use '@carbon/styles/scss/config' as *;
14
+ @use '@carbon/styles/scss/motion' as *;
15
+ @use '@carbon/styles/scss/spacing' as *;
16
+ @use '@carbon/styles/scss/theme' as *;
17
+ @use '@carbon/styles/scss/type';
18
+ @use '@carbon/styles/scss/utilities';
19
+ @use '@carbon/styles/scss/utilities/ai-gradient' as *;
20
+ @use '@carbon/styles/scss/components/modal' as *;
21
+ @use '@carbon/styles/scss/utilities/convert' as *;
22
+ @use 'sass:map';
23
+
24
+ $prefix: 'c4p';
25
+ $carbon-prefix: 'cds';
26
+
27
+ @use '@carbon/ibm-products-styles/scss/components/Tearsheet/index' as *;
28
+ @use '@carbon/ibm-products-styles/scss/components/ActionSet/index' as *;
29
+
30
+ $block-class: #{$prefix}--tearsheet;
31
+ $block-class-action-set: #{$prefix}--action-set;
32
+ $motion-duration: $duration-moderate-02;
33
+
34
+ :host(#{$prefix}-tearsheet) {
35
+ --content-padding: #{$spacing-05};
36
+
37
+ @extend .#{$carbon-prefix}--modal;
38
+ @extend .#{$prefix}--tearsheet;
39
+
40
+ .#{$block-class}__header,
41
+ .#{$block-class}__content,
42
+ .#{$block-class}__influencer {
43
+ padding: var(--content-padding);
44
+ }
45
+
46
+ .#{$block-class}__container {
47
+ /* lower prop is deprecated but the default in ibm products */
48
+ @extend .#{$block-class}__container--lower;
49
+
50
+ max-block-size: calc(100% - (#{$spacing-09} + #{$spacing-08}));
51
+ }
52
+
53
+ .#{$block-class}__container[stack-position='1'][stack-depth='2'],
54
+ .#{$block-class}__container[stack-position='2'][stack-depth='3'] {
55
+ max-block-size: calc(
56
+ 100% - (#{$spacing-09} + #{$spacing-08}) + #{$spacing-05}
57
+ );
58
+ transform: scale(var(--#{$block-class}--stacking-scale-factor-single));
59
+ }
60
+
61
+ .#{$block-class}__container[stack-position='1'][stack-depth='3'] {
62
+ max-block-size: calc(
63
+ 100% - (#{$spacing-09} + #{$spacing-08}) + (2 * #{$spacing-05})
64
+ );
65
+ transform: scale(var(--#{$block-class}--stacking-scale-factor-double));
66
+ }
67
+
68
+ .#{$block-class}__buttons {
69
+ @extend .#{$block-class}__button-container;
70
+ @extend .#{$block-class-action-set};
71
+
72
+ display: flex;
73
+ background: $background;
74
+ inline-size: 100%;
75
+ }
76
+
77
+ .#{$block-class}__buttons[hidden] {
78
+ @extend .#{$carbon-prefix}--visually-hidden;
79
+
80
+ display: none;
81
+ }
82
+
83
+ .#{$block-class}__buttons ::slotted(#{$carbon-prefix}-button) {
84
+ @extend .#{$block-class-action-set}__action-button;
85
+
86
+ flex: 0 1 25%;
87
+ block-size: $spacing-11;
88
+ max-inline-size: to-rem(232px);
89
+ }
90
+
91
+ .#{$block-class}__buttons ::slotted(#{$carbon-prefix}-button[kind='ghost']) {
92
+ flex: 1 1 25%;
93
+ max-inline-size: none;
94
+ }
95
+
96
+ .#{$block-class}__buttons ::slotted(#{$carbon-prefix}-button[hidden]) {
97
+ @extend .#{$carbon-prefix}--visually-hidden;
98
+
99
+ display: none;
100
+ }
101
+
102
+ .#{$block-class}__influencer[wide] {
103
+ @extend .#{$block-class}__influencer--wide;
104
+ }
105
+ }
106
+
107
+ :host(#{$prefix}-tearsheet[open]) {
108
+ --overlay-color: #{$overlay};
109
+ --overlay-opacity: 1;
110
+
111
+ z-index: utilities.z('modal');
112
+ align-items: flex-end;
113
+ background: initial;
114
+ opacity: 1;
115
+
116
+ transition: visibility 0s linear;
117
+ visibility: inherit;
118
+
119
+ .#{$prefix}--tearsheet__container {
120
+ transform: translate3d(0, 0, 0);
121
+ transition: transform $duration-moderate-02 motion(entrance, expressive);
122
+ }
123
+
124
+ @media (prefers-reduced-motion: reduce) {
125
+ transition: none;
126
+ }
127
+
128
+ &::before {
129
+ position: absolute;
130
+ display: block;
131
+ background: var(--overlay-color);
132
+ content: '';
133
+ inset: 0;
134
+ opacity: var(--overlay-opacity);
135
+
136
+ transition: background-color $motion-duration motion(exit, expressive),
137
+ opacity $motion-duration motion(exit, expressive);
138
+
139
+ @media (prefers-reduced-motion: reduce) {
140
+ transition: none;
141
+ }
142
+
143
+ &[stack-position='1'][stack-depth='2'] {
144
+ --overlay-opacity: 0.67;
145
+ }
146
+
147
+ &[stack-position='1'][stack-depth='3'] {
148
+ --overlay-opacity: 0.22;
149
+ }
150
+
151
+ &[stack-position='2'][stack-depth='3'] {
152
+ --overlay-opacity: 0.5;
153
+ }
154
+
155
+ &[stack-position='2'][stack-depth='2'],
156
+ &[stack-position='3'][stack-depth='3'] {
157
+ --overlay-opacity: 0.5;
158
+ }
159
+ }
160
+ }
161
+
162
+ :host(#{$prefix}-tearsheet[hidden]) {
163
+ @extend .#{$carbon-prefix}--visually-hidden;
164
+ }
165
+
166
+ :host(#{$prefix}-tearsheet[slug]) {
167
+ --overlay-color: #{$ai-overlay};
168
+
169
+ .#{$block-class}__container {
170
+ border: 1px solid transparent;
171
+
172
+ /* override carbon ai removing background gradient */
173
+ background: linear-gradient(to top, var(--cds-layer), var(--cds-layer))
174
+ padding-box,
175
+ linear-gradient(
176
+ to bottom,
177
+ var(--cds-ai-border-start, #78a9ff),
178
+ var(--cds-ai-border-end, #d0e2ff)
179
+ )
180
+ border-box,
181
+ linear-gradient(to top, var(--cds-layer), var(--cds-layer)) border-box;
182
+ border-block-end: 0;
183
+ box-shadow: 0 24px 40px -24px $ai-drop-shadow;
184
+ }
185
+
186
+ .#{$block-class}__content {
187
+ @include utilities.ai-popover-gradient('default', 0);
188
+
189
+ box-shadow: inset 0 -80px 70px -65px $ai-inner-shadow;
190
+ }
191
+ }
192
+
193
+ :host(#{$prefix}-tearsheet[slug])
194
+ .#{$prefix}--tearsheet__header[has-actions]
195
+ ::slotted(#{$prefix}-slug) {
196
+ inset-inline-end: 0;
197
+ }
198
+
199
+ :host(#{$prefix}-tearsheet[stack-position='1'][stack-depth='2']),
200
+ :host(#{$prefix}-tearsheet[stack-position='2'][stack-depth='3']) {
201
+ z-index: utilities.z('modal') - 1;
202
+ }
203
+
204
+ :host(#{$prefix}-tearsheet[stack-position='1'][stack-depth='3']) {
205
+ z-index: utilities.z('modal') - 2;
206
+ }
207
+
208
+ :host(#{$prefix}-tearsheet[width='narrow']) {
209
+ .#{$block-class}__header {
210
+ margin: 0;
211
+ background-color: $layer;
212
+ border-block-end: 1px solid $border-subtle-01;
213
+ }
214
+
215
+ .#{$block-class}__header-description {
216
+ margin-block-start: $spacing-03;
217
+ max-inline-size: 80%;
218
+ }
219
+
220
+ .#{$block-class}__main {
221
+ background-color: $layer;
222
+ }
223
+ }
224
+
225
+ :host(#{$prefix}-tearsheet[width='wide']) {
226
+ --content-padding: #{$spacing-06 $spacing-07};
227
+
228
+ .#{$block-class}__header {
229
+ margin: 0;
230
+ background-color: $layer;
231
+ border-block-end: 1px solid $border-subtle-01;
232
+ }
233
+
234
+ .#{$block-class}__header[has-navigation] {
235
+ padding-block-end: 0;
236
+ }
237
+
238
+ .#{$block-class}__container {
239
+ inline-size: 100%;
240
+
241
+ @include breakpoint(md) {
242
+ inline-size: calc(100% - (2 * #{$spacing-10}));
243
+ }
244
+ }
245
+
246
+ .#{$carbon-prefix}--modal-header__heading.#{$block-class}__heading {
247
+ @include type.type-style('heading-04');
248
+ }
249
+
250
+ .#{$block-class}__header[has-close-icon],
251
+ .#{$block-class}__header[has-slug] {
252
+ padding-inline-end: $spacing-11;
253
+ }
254
+
255
+ .#{$block-class}__header[has-close-icon][has-slug] {
256
+ padding-inline-end: calc(#{$spacing-11 + $spacing-09});
257
+ }
258
+
259
+ .#{$block-class}__header-navigation {
260
+ margin-inline-start: calc(-1 * #{$spacing-05});
261
+ max-block-size: $spacing-08; /* #{$prefix}-tabs too tall */
262
+ }
263
+
264
+ .#{$block-class}__content {
265
+ // Revert background color overridden by Carbon's modal - https://github.com/carbon-design-system/carbon/blob/main/packages/styles/scss/components/modal/_modal.scss#L54
266
+ .#{$carbon-prefix}--pagination,
267
+ .#{$carbon-prefix}--pagination__control-buttons,
268
+ .#{$carbon-prefix}--text-input,
269
+ .#{$carbon-prefix}--text-area,
270
+ .#{$carbon-prefix}--search-input,
271
+ .#{$carbon-prefix}--select-input,
272
+ .#{$carbon-prefix}--dropdown,
273
+ .#{$carbon-prefix}--dropdown-list,
274
+ .#{$carbon-prefix}--number input[type='number'],
275
+ .#{$carbon-prefix}--date-picker__input {
276
+ background-color: $field;
277
+ }
278
+
279
+ .#{$carbon-prefix}--select--inline .#{$carbon-prefix}--select-input {
280
+ background-color: transparent;
281
+ }
282
+
283
+ // and restore the 'light' prop in case light fields are wanted
284
+ .#{$carbon-prefix}--text-input--light,
285
+ .#{$carbon-prefix}--text-area--light,
286
+ .#{$carbon-prefix}--search--light .#{$carbon-prefix}--search-input,
287
+ .#{$carbon-prefix}--select--light .#{$carbon-prefix}--select-input,
288
+ .#{$carbon-prefix}--dropdown--light,
289
+ .#{$carbon-prefix}--dropdown--light .#{$carbon-prefix}--dropdown-list,
290
+ /* stylelint-disable-next-line prettier/prettier */
291
+ .#{$carbon-prefix}--number--light input[type='number'],
292
+ .#{$carbon-prefix}--date-picker--light
293
+ .#{$carbon-prefix}--date-picker__input {
294
+ background-color: $field-02;
295
+ }
296
+ }
297
+ .#{$prefix}--action-set
298
+ .#{$prefix}--action-set__action-button.#{$prefix}--action-set__action-button--expressive {
299
+ block-size: $spacing-11;
300
+ }
301
+ }
302
+
303
+ :host(#{$prefix}-tearsheet[width='narrow'])
304
+ .#{$block-class}__buttons[actions-multiple='single']
305
+ ::slotted(#{$carbon-prefix}-button),
306
+ :host(#{$prefix}-tearsheet[width='narrow'])
307
+ .#{$block-class}__buttons[actions-multiple='double']
308
+ ::slotted(#{$carbon-prefix}-button) {
309
+ // double and single on lg use 50%
310
+ flex: 0 1 50%;
311
+ max-inline-size: none;
312
+ }
313
+
314
+ :host(#{$prefix}-tearsheet[width='narrow'])
315
+ .#{$block-class}__buttons
316
+ ::slotted(#{$carbon-prefix}-button) {
317
+ block-size: $spacing-10;
318
+ }
@@ -337,10 +337,11 @@ class CDSSidePanel extends HostListenerMixin(LitElement) {
337
337
  newValues.marginInlineEnd = `${this?._sidePanel?.offsetWidth}px`;
338
338
  }
339
339
  }
340
-
341
- Object.keys(newValues).forEach((key) => {
342
- pageContentEl.style[key] = newValues[key];
343
- });
340
+ if (this.slideIn) {
341
+ Object.keys(newValues).forEach((key) => {
342
+ pageContentEl.style[key] = newValues[key];
343
+ });
344
+ }
344
345
  }
345
346
  }
346
347
  };
@@ -680,7 +681,6 @@ class CDSSidePanel extends HostListenerMixin(LitElement) {
680
681
  const actionsMultiple = ['', 'single', 'double', 'triple'][
681
682
  this._actionsCount
682
683
  ];
683
-
684
684
  const titleTemplate = html`<div
685
685
  class=${`${blockClass}__title`}
686
686
  ?no-label=${!!labelText}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2023, 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
+ export enum TEARSHEET_INFLUENCER_PLACEMENT {
11
+ /** right / default */
12
+ RIGHT = 'right',
13
+
14
+ /** left */
15
+ LEFT = 'left',
16
+ }
17
+
18
+ export enum TEARSHEET_INFLUENCER_WIDTH {
19
+ /** narrow /default */
20
+ NARROW = 'narrow',
21
+ /** wide */
22
+ WIDE = 'wide',
23
+ }
24
+
25
+ export enum TEARSHEET_WIDTH {
26
+ /** narrow */
27
+ NARROW = 'narrow',
28
+ /** wide */
29
+ WIDE = 'wide',
30
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2024, 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 './tearsheet';
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright IBM Corp. 2023, 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
+ @use '@carbon/styles/scss/spacing' as *;
8
+ @use '@carbon/styles/scss/config' as *;
9
+
10
+ $story-prefix: 'tearsheet-stories';
11
+
12
+ @use '@carbon/styles/scss/spacing' as *;
13
+
14
+ #page-content-selector {
15
+ position: absolute;
16
+ z-index: 9999;
17
+ inset-block-start: 0;
18
+ inset-inline-start: 0;
19
+ }
20
+
21
+ .#{$story-prefix}__tabs .#{$prefix}--tab-content {
22
+ display: none;
23
+ }
@@ -0,0 +1,101 @@
1
+ import { ArgTypes, Markdown, Meta } from '@storybook/blocks';
2
+ import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
3
+ import * as TearsheetStories from './tearsheet.stories';
4
+
5
+ <Meta of={TearsheetStories} />
6
+
7
+ # Tearsheet
8
+
9
+ > 💡 Check our
10
+ > [Stackblitz](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/tearsheet)
11
+ > example implementation.
12
+
13
+ [![Edit carbon-web-components](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/carbon-design-system/carbon/tree/main/packages/web-components/examples/components/tearsheet)
14
+
15
+ Tearsheets keep users in-context of a page while performing tasks like
16
+ navigating, editing, viewing details, or configuring something new.
17
+
18
+ ## Getting started
19
+
20
+ Here's a quick example to get you started.
21
+
22
+ ### JS (via import)
23
+
24
+ ```javascript
25
+ import '@carbon/web-components/es/components/tearsheet/index.js';
26
+ // The following are used for slotted fields
27
+ import '@carbon/web-components/es/components/text-input/index.js';
28
+ import '@carbon/web-components/es/components/textarea/index.js';
29
+ import '@carbon/web-components/es/components/button/index.js';
30
+ ```
31
+
32
+ <Markdown>{`${cdnJs({ components: ['tearsheet'] })}`}</Markdown>
33
+ <Markdown>{`${cdnCss()}`}</Markdown>
34
+
35
+ ### HTML
36
+
37
+ ```html
38
+ <c4p-tearsheet>
39
+ <!-- Content -->
40
+ <h5>Tearsheet content</h5>
41
+ <div class="${storyPrefix}text-inputs">
42
+ <cds-text-input
43
+ label="Input A"
44
+ id="tearsheet-story-text-input-a"></cds-text-input>
45
+ <cds-text-input
46
+ label="Input B"
47
+ id="tearsheet-story-text-input-b"></cds-text-input>
48
+ </div>
49
+ <div class="${storyPrefix}text-inputs">
50
+ <cds-text-input
51
+ label="Input C"
52
+ id="tearsheet-story-text-input-c"></cds-text-input>
53
+ <cds-text-input
54
+ label="Input D"
55
+ id="tearsheet-story-text-input-d"></cds-text-input>
56
+ </div>
57
+ <div class="${storyPrefix}textarea-container">
58
+ <cds-textarea label="Notes" value="This is a text area"></cds-textarea>
59
+ <cds-textarea label="Notes" value="This is a text area"></cds-textarea>
60
+ <cds-textarea label="Notes" value="This is a text area"></cds-textarea>
61
+ </div>
62
+
63
+ <!-- subtitle optional -->
64
+ <div slot="subtitle">
65
+ Subtitle text which can provide more detail on the content being displayed.
66
+ </div>
67
+
68
+ <!-- Action toolbar optional -->
69
+ <cds-button slot="action-toolbar">Copy</cds-button>
70
+ <cds-button
71
+ slot="action-toolbar"
72
+ aria-label="Settings"
73
+ has-icon-only="true"
74
+ kind="${BUTTON_KIND.GHOST}"
75
+ size="sm"
76
+ tooltip-text="Settings">
77
+ ${Settings({ slot: 'icon' })}
78
+ </cds-button>
79
+ <cds-button
80
+ slot="action-toolbar"
81
+ aria-label="Delete"
82
+ has-icon-only="true"
83
+ kind="${BUTTON_KIND.GHOST}"
84
+ size="sm"
85
+ tooltip-text="Delete">
86
+ ${Trashcan({ slot: 'icon' })}
87
+ </cds-button>
88
+
89
+ <!-- Tearsheet actions optional -->
90
+ <cds-button slot="actions" kind="${BUTTON_KIND.GHOST}">Ghost</cds-button>
91
+ <cds-button slot="actions" kind="${BUTTON_KIND.PRIMARY}"></cds-button>
92
+ </c4p-tearsheet>
93
+ ```
94
+
95
+ ## `<c4p-tearsheet>` attributes, properties and events
96
+
97
+ Note: For `boolean` attributes, `true` means simply setting the attribute (e.g.
98
+ `<c4p-tearsheet open>`) and `false` means not setting the attribute (e.g.
99
+ `<c4p-tearsheet>` without `open` attribute).
100
+
101
+ <ArgTypes of="c4p-tearsheet" />