@spaced-out/ui-design-system 0.1.66 → 0.1.68

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.
@@ -0,0 +1,476 @@
1
+ export const TABLE_DOCS = {
2
+ argTypes: {
3
+ headers: {
4
+ type: {required: true},
5
+ description:
6
+ 'Provide an array of objects to render the header, each object should consist of label(*), key(*), sortable, sticky and render function',
7
+ control: {
8
+ type: 'object',
9
+ },
10
+ table: {
11
+ type: {
12
+ summary:
13
+ '{label: React.Node, key: $Keys<T>, className?: string, filterIcon?: React.Node, filtered?: boolean, subtext?: string, sortable?: boolean, headerIconClassName?: string, sticky?: boolean, render?: React.ComponentType<{data: T, extras?: U, className?: string, selected?: boolean,}>, }',
14
+ },
15
+ },
16
+ },
17
+ entries: {
18
+ type: {required: true},
19
+ description:
20
+ 'Provide an array of object. Each object belong on one row in the table. Each object should have id and all the keys with values that is being passed in headers array',
21
+ control: {
22
+ type: 'object',
23
+ },
24
+ table: {
25
+ type: {
26
+ summary: 'Array<T>',
27
+ },
28
+ },
29
+ },
30
+ classNames: {
31
+ description:
32
+ 'Provide optional classNames to be applied to the wrapper, table, tableHeader, tableBody, tableRow, or checkbox',
33
+ control: {
34
+ type: 'object',
35
+ },
36
+ table: {
37
+ type: {
38
+ summary:
39
+ '{wrapper?: string, table?: string, tableHeader?: string, tableBody?: string, tableRow?: string, checkbox?: string}',
40
+ },
41
+ },
42
+ },
43
+ Row: {
44
+ description: 'Custom Row component to be passed to table',
45
+ table: {
46
+ type: {summary: 'TableRow<T, U>'},
47
+ },
48
+ },
49
+ sortable: {
50
+ description:
51
+ 'Sort Icon will appear in right side of column\'s header with column level true sortable value',
52
+ name: 'sortable',
53
+ options: [false, true],
54
+ control: 'boolean',
55
+ table: {
56
+ type: {summary: 'boolean'},
57
+ defaultValue: {summary: true},
58
+ },
59
+ },
60
+ showHeader: {
61
+ description: 'Show or hide header',
62
+ options: [false, true],
63
+ control: 'boolean',
64
+ table: {
65
+ type: {summary: 'boolean'},
66
+ defaultValue: {summary: true},
67
+ },
68
+ },
69
+ defaultSortKey: {
70
+ description:
71
+ 'key name for which table should be sorted by default. headers array should have sortable true for that key object',
72
+ control: {
73
+ type: 'text',
74
+ },
75
+ table: {
76
+ type: {summary: 'string'},
77
+ },
78
+ },
79
+ // defaultSortDirection?: 'asc' | 'desc' | 'original',
80
+ defaultSortDirection: {
81
+ description: 'default sorting direction for the defaultSortKey column',
82
+
83
+ control: {
84
+ type: 'text',
85
+ },
86
+ table: {
87
+ type: {summary: '\'asc\' | \'desc\' | \'original\''},
88
+ },
89
+ },
90
+ selectedKeys: {
91
+ description:
92
+ 'array of keys which are selected. This prop is also used to decide weather to show checkboxes or not. So, pass an empty array incase no row is selected.',
93
+ control: {
94
+ type: 'object',
95
+ },
96
+ table: {
97
+ type: {summary: 'string[]'},
98
+ },
99
+ },
100
+ //onSelect?: (keys: string[]) => mixed
101
+ onSelect: {
102
+ description: 'callback function when any row is selected',
103
+ action: 'selected',
104
+ type: {summary: '(keys: string[]) => mixed'},
105
+ },
106
+ idName: {
107
+ description: 'name of key in row objects that has to be used as id',
108
+ },
109
+ //onSort?: (key: $Keys<T>
110
+ onSort: {
111
+ description: 'callback function when any table is sorted',
112
+ action: 'sorted',
113
+ type: {summary: '(key: $Keys<T>, direction: SortDirection) => void'},
114
+ },
115
+ isLoading: {
116
+ description:
117
+ 'to wait for data to populate in table and show loading state when entries array is empty.',
118
+ options: [false, true],
119
+ control: 'boolean',
120
+ table: {
121
+ type: {summary: 'boolean'},
122
+ defaultValue: {summary: false},
123
+ },
124
+ },
125
+ emptyText: {
126
+ description: 'Provide component to be shown in case of empty data',
127
+ table: {
128
+ type: {summary: 'React.Component'},
129
+ },
130
+ },
131
+ customLoader: {
132
+ description:
133
+ 'Provide optional component to be shown in case of loading state. It will override the default loader.',
134
+ table: {
135
+ type: {summary: 'React.Component'},
136
+ },
137
+ },
138
+ disabled: {
139
+ description: 'disable all the checkboxes of each row in the table',
140
+ options: [false, true],
141
+ control: 'boolean',
142
+ table: {
143
+ type: {summary: 'boolean'},
144
+ defaultValue: {summary: false},
145
+ },
146
+ },
147
+ borderRadius: {
148
+ description:
149
+ 'Border Radius of all four corners of the table. Default value is borderRadiusMedium i.e., 12px.',
150
+ control: 'text',
151
+ table: {
152
+ type: {summary: 'string'},
153
+ defaultValue: {summary: '12px'},
154
+ },
155
+ },
156
+ stickyHeader: {
157
+ description:
158
+ 'Sticky header will stick the header to the top of the table when scrolling. This would only work if the table wrapper is scrollable.',
159
+ control: 'boolean',
160
+ table: {
161
+ type: {summary: 'boolean'},
162
+ defaultValue: {summary: false},
163
+ },
164
+ },
165
+ },
166
+ parameters: {
167
+ componentSubtitle: 'Generates a Table component.',
168
+ docs: {
169
+ description: {
170
+ component: `
171
+ \`\`\`js
172
+ import {
173
+ Table,
174
+ StaticTable,
175
+ DefaultRow,
176
+ BasicSingleCell,
177
+ DateCell,
178
+ DoubleCell,
179
+ SingleCell,
180
+ MonogramCell,
181
+ TableActionBar,
182
+ ButtonCta,
183
+ DropdownCta,
184
+ TableTopBar,
185
+ TableBottomBar
186
+ } from "@spaced-out/ui-design-system/lib/components/Table";
187
+ \`\`\`
188
+ Table component internally uses HTML Table, Thead, Tbody, Tr, Th and Td tags. It accepts entries and headers for showing table.
189
+ The Table component takes care of lots of things for you but it's not a magical component, it wraps a lot of behavior, so you can have,
190
+ for instance, a static table with no sorting options.
191
+
192
+ StaticTables work just like regular tables, except they don't have interactive headers, so you lose sorting.
193
+ But remember, a regular interactive table uses a static table under the hood,
194
+ so how does it work? You can think of the StaticTable as a kind of controlled table component.
195
+ except that traditionally we'd update the entries prop and rerender from that.
196
+ That would work just fine, but instead we can just pass in the keys we care about. By using StaticTable,
197
+ we can simplify filtering and sorting outside of the table while the table keeps a stable value reference to all the entities.
198
+
199
+ To make any of rows selectable, we can do that by also passing in another property, selectedKeys.
200
+
201
+ Let's say we want to also make any of the rows selectable, we can do that by also passing in another property, selectedKeys.
202
+
203
+ ### Custom Cells
204
+
205
+ It's possible you need to render out a custom cell, not just the default cell.
206
+ There are two ways to do that. If you only need to modify a single cell,
207
+ you can simply add a render: \`React.ComponentType<{data: T, extras?: U}>\`
208
+ key to any given header item.
209
+
210
+ This cell renderer receives the _whole row_ of data, not just the individual cell, it's up to you what to do with it.
211
+
212
+ ### With Table Top, Bottom Bar and Actions
213
+
214
+ You can attach a top, bottom and action bar to the table by adding \`TableTopBar\`, \`TableBottomBar\` and \`TableActionBar\` components.
215
+ There are just semantic components which just provide padding and border standardization. You can add any component inside these components.
216
+ These also accept **className** prop.
217
+
218
+ ### Best Practices
219
+ * A Data Table should always have a \`TableTopBar\`
220
+ * Use \`stickyHeader\` prop to make the header sticky
221
+ * Always assign a height to the table wrapper to make it scrollable
222
+ * Manage the Table's Wrapper height effectively when using \`TableActionBar\` component
223
+ * Always use local \`ButtonCta\` and \`DropdownCta\` for actions in Action bar. These components are
224
+ just CSS Wrappers for Button and SimpleButtonDropdown components
225
+ * Use ButtonCta component to add a button CTA in the \`TableActionBar\`
226
+ * Use DropdownCta component to add a dropdown CTA button in the \`TableActionBar\` for screen width less than size1280(1280px)
227
+
228
+ \`\`\`jsx
229
+ <Table
230
+ headers={TABLE_HEADERS}
231
+ entries={TABLE_DATA}
232
+ stickyHeader={true}
233
+ classNames={{
234
+ wrapper: classify(css.tableWrapper, {
235
+ [css.withActionBar]: getNumberOfEntriesSelected() > 0,
236
+ })
237
+ }}
238
+ />
239
+ \`\`\`
240
+
241
+ \`\`\`css
242
+ .tableWrapper {
243
+ height: calc(sizeFullViewportHeight - size160);
244
+ }
245
+
246
+ .tableWrapper.withActionBar {
247
+ height: calc((sizeFullViewportHeight - size160) - actionBarHeight);
248
+ }
249
+ \`\`\`
250
+
251
+ ### Usage
252
+
253
+ \`\`\`jsx
254
+ const TABLE_HEADERS = [
255
+ { label: "Name", key: "name", sortable: true, className: css.mediumColumn },
256
+ { label: "Tel", key: "phone", sortable: true, className: css.mediumColumn },
257
+ ];
258
+
259
+ const TABLE_DATA = [
260
+ {
261
+ id: "1",
262
+ name: "Alice",
263
+ phone: "123-456-7890",
264
+ },
265
+ {
266
+ id: "2",
267
+ name: "Bob",
268
+ phone: "987-654-3210",
269
+ },
270
+ ];
271
+
272
+ export const _TableExample = (): React.Node => {
273
+ return (
274
+ <div className={css.container}>
275
+ {/* Top Bar with Filters */}
276
+ <TableTopBar>
277
+ <div className={css.left}>
278
+ <SubTitleMedium className={css.title}>Basic Data Table</SubTitleMedium>
279
+ <SearchInput />
280
+ </div>
281
+ </TableTopBar>
282
+
283
+ {/* Table */}
284
+ <Table
285
+ headers={TABLE_HEADERS}
286
+ entries={TABLE_DATA}
287
+ isLoading={isLoading}
288
+ stickyHeader={true}
289
+ borderRadius={'0'}
290
+ selectedKeys={staticTableKeysAcrossPages[currPage] || []}
291
+ onSelect={(keys) => {
292
+ setSelectAllEntries(false);
293
+ setStaticTableKeysAcrossPages({
294
+ ...staticTableKeysAcrossPages,
295
+ [currPage]: keys,
296
+ });
297
+ }}
298
+ classNames={{
299
+ wrapper: classify(css.tableWrapper, {
300
+ [css.withActionBar]: getNumberOfEntriesSelected() > 0,
301
+ })
302
+ }}
303
+ />
304
+
305
+ {/* Table Actions */}
306
+ {getNumberOfEntriesSelected() > 0 && (
307
+ <TableActionBar className={css.actionBar}>
308
+ <div className={css.leftActionSlot}>
309
+ <ButtonCta
310
+ onClick={() => {
311
+ setSelectAllEntries(true);
312
+ setStaticTableKeysAcrossPages({
313
+ ...staticTableKeysAcrossPages,
314
+ [currPage]: tableEntries.map((entry) => entry.id),
315
+ });
316
+ }}
317
+ >
318
+ Select all items
319
+ </ButtonCta>
320
+ {getNumberOfEntriesSelected() > 0 && (
321
+ <BodySmall color="inversePrimary">
322
+ {getNumberOfEntriesSelected() entries selected}
323
+ </BodySmall>
324
+ )}
325
+ </div>
326
+ <div className={classify(css.middleActionSlot, css.fullTable)}>
327
+ <ButtonCta size="small" iconLeftName="folder-plus">
328
+ Add to group
329
+ </ButtonCta>
330
+ </div>
331
+ <div className={classify(css.middleActionSlot, css.smallTable)}>
332
+ <ButtonCta size="small" iconLeftName="folder-plus">
333
+ Add to group
334
+ </ButtonCta>
335
+ <DropdownCta
336
+ ariaLabel="Icon Button Dropdown"
337
+ iconLeftName="ellipsis"
338
+ options={[
339
+ {
340
+ iconLeft: 'layer-plus',
341
+ key: '1',
342
+ label: 'Create group',
343
+ },
344
+ ]}
345
+ selectedKeys={selectedKeys}
346
+ onOptionSelect={() => setSelectedKeys([])}
347
+ size="small"
348
+ />
349
+ </div>
350
+ <div className={css.rightActionSlot}>
351
+ <ButtonCta
352
+ iconLeftName="close"
353
+ onClick={() => {
354
+ setSelectAllEntries(false);
355
+ setStaticTableKeysAcrossPages({});
356
+ }}
357
+ >
358
+ Close
359
+ </ButtonCta>
360
+ </div>
361
+ </TableActionBar>
362
+ )}
363
+
364
+ {/* Bottom Bar with Pagination */}
365
+ <TableBottomBar>
366
+ <Pagination
367
+ currentPage={currPage}
368
+ totalPages={totalPages}
369
+ onChange={(page) => {
370
+ onMove(page || 1);
371
+ }}
372
+ >
373
+ <SubTitleExtraSmall color="secondary">
374
+ Showing page {currPage} of {totalPages}
375
+ </SubTitleExtraSmall>
376
+ </Pagination>
377
+ </TableBottomBar>
378
+ </div>
379
+ );
380
+ };
381
+ \`\`\`
382
+
383
+ \`\`\`css
384
+ @value actionBarHeight: size50;
385
+
386
+ .container {
387
+ width: sizeFluid;
388
+ }
389
+
390
+ .left {
391
+ display: flex;
392
+ align-items: center;
393
+ }
394
+
395
+ .title {
396
+ margin-right: spaceMedium;
397
+ }
398
+
399
+ .mediumColumn {
400
+ width: calc(sizeFluid / 5);
401
+ }
402
+
403
+ .tableWrapper {
404
+ height: calc(sizeFullViewportHeight - size160);
405
+ }
406
+
407
+ .actionBar {
408
+ display: flex;
409
+ align-items: center;
410
+ gap: spaceXSmall;
411
+ }
412
+
413
+ .tableWrapper.withActionBar {
414
+ height: calc((sizeFullViewportHeight - size160) - actionBarHeight);
415
+ }
416
+
417
+ .leftActionSlot,
418
+ .rightActionSlot,
419
+ .middleActionSlot {
420
+ display: flex;
421
+ gap: spaceSmall;
422
+ align-items: center;
423
+ }
424
+
425
+ .leftActionSlot,
426
+ .rightActionSlot {
427
+ width: calc(sizeFluid / 4);
428
+ }
429
+
430
+ .leftActionSlot {
431
+ justify-content: flex-start;
432
+ }
433
+
434
+ .middleActionSlot {
435
+ width: calc(sizeFluid / 2);
436
+ justify-content: center;
437
+ gap: spaceXXSmall;
438
+ }
439
+
440
+ .rightActionSlot {
441
+ justify-content: flex-end;
442
+ }
443
+
444
+ .smallTable {
445
+ display: none;
446
+ }
447
+
448
+ @media only screen and (max-width: size1280) {
449
+ .fullTable {
450
+ display: none;
451
+ }
452
+
453
+ .smallTable {
454
+ display: flex;
455
+ }
456
+ }
457
+
458
+ .dangerText {
459
+ color: colorTextDanger;
460
+ }
461
+
462
+ .dangerText:hover,
463
+ .dangerText:active,
464
+ .dangerText:focus {
465
+ color: colorTextDanger;
466
+ }
467
+
468
+ \`\`\`
469
+ `,
470
+ },
471
+ },
472
+ storySource: {
473
+ componentPath: '/src/components/Table/Table.js',
474
+ },
475
+ },
476
+ };
@@ -3,20 +3,54 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TableActionBar = void 0;
6
+ exports.TableActionBar = exports.DropdownCta = exports.ButtonCta = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = require("../../utils/classify");
9
+ var _Button = require("../Button");
10
+ var _ButtonDropdown = require("../ButtonDropdown");
9
11
  var _TableBarModule = _interopRequireDefault(require("./TableBar.module.css"));
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
- const TableActionBar = _ref => {
16
+ const ButtonCta = _ref => {
17
+ let {
18
+ classNames,
19
+ ...props
20
+ } = _ref;
21
+ return /*#__PURE__*/React.createElement(_Button.Button, _extends({}, props, {
22
+ "data-testid": "table-action-bar-button-cta",
23
+ type: "primary",
24
+ size: "small",
25
+ classNames: {
26
+ ...classNames,
27
+ wrapper: _TableBarModule.default.buttonCta
28
+ }
29
+ }));
30
+ };
31
+ exports.ButtonCta = ButtonCta;
32
+ const DropdownCta = _ref2 => {
33
+ let {
34
+ classNames,
35
+ ...props
36
+ } = _ref2;
37
+ return /*#__PURE__*/React.createElement(_ButtonDropdown.SimpleButtonDropdown, _extends({}, props, {
38
+ "data-testid": "table-action-bar-dropdown-cta",
39
+ type: "primary",
40
+ size: "small",
41
+ classNames: {
42
+ ...classNames,
43
+ buttonWrapper: _TableBarModule.default.buttonCta
44
+ }
45
+ }));
46
+ };
47
+ exports.DropdownCta = DropdownCta;
48
+ const TableActionBar = _ref3 => {
15
49
  let {
16
50
  children,
17
51
  className,
18
52
  ...props
19
- } = _ref;
53
+ } = _ref3;
20
54
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
21
55
  className: (0, _classify.classify)(_TableBarModule.default.tableActionBar, className),
22
56
  "data-testid": "table-action-bar"
@@ -3,6 +3,10 @@
3
3
  import * as React from 'react';
4
4
 
5
5
  import {classify} from '../../utils/classify';
6
+ import type {ButtonProps} from '../Button';
7
+ import {Button} from '../Button';
8
+ import type {SimpleButtonDropdownProps} from '../ButtonDropdown';
9
+ import {SimpleButtonDropdown} from '../ButtonDropdown';
6
10
 
7
11
  import css from './TableBar.module.css';
8
12
 
@@ -13,6 +17,29 @@ export type TableActionBarProps = {
13
17
  ...
14
18
  };
15
19
 
20
+ export const ButtonCta = ({classNames, ...props}: ButtonProps): React.Node => (
21
+ <Button
22
+ {...props}
23
+ data-testid="table-action-bar-button-cta"
24
+ type="primary"
25
+ size="small"
26
+ classNames={{...classNames, wrapper: css.buttonCta}}
27
+ />
28
+ );
29
+
30
+ export const DropdownCta = ({
31
+ classNames,
32
+ ...props
33
+ }: SimpleButtonDropdownProps): React.Node => (
34
+ <SimpleButtonDropdown
35
+ {...props}
36
+ data-testid="table-action-bar-dropdown-cta"
37
+ type="primary"
38
+ size="small"
39
+ classNames={{...classNames, buttonWrapper: css.buttonCta}}
40
+ />
41
+ );
42
+
16
43
  export const TableActionBar = ({
17
44
  children,
18
45
  className,
@@ -1,7 +1,14 @@
1
1
  @value (spaceNone, spaceXXSmall, spaceXSmall, spaceSmall, spaceMedium, spaceHalfFluid, spaceNegHalfFluid) from '../../styles/variables/_space.css';
2
2
  @value (size2, size22, size48, size50, size60, size240, size300, sizeFluid) from '../../styles/variables/_size.css';
3
- @value (borderRadiusMedium, borderRadiusNone) from '../../styles/variables/_border.css';
4
- @value (colorBackgroundTertiary, colorFillPrimary) from '../../styles/variables/_color.css';
3
+ @value (borderRadiusMedium, borderRadiusNone, borderWidthPrimary) from '../../styles/variables/_border.css';
4
+ @value (
5
+ colorBackgroundTertiary,
6
+ colorFillPrimary,
7
+ colorButtonFillTableActionEnabled,
8
+ colorButtonFillTableActionHovered,
9
+ colorButtonFillTableActionPressed,
10
+ colorButtonFillTableActionBorder
11
+ ) from '../../styles/variables/_color.css';
5
12
  @value (elevationMenu) from '../../styles/variables/_elevation.css';
6
13
 
7
14
  .tableBar {
@@ -39,3 +46,16 @@
39
46
  width: sizeFluid;
40
47
  padding: spaceXSmall spaceSmall spaceXSmall spaceMedium;
41
48
  }
49
+
50
+ .buttonCta {
51
+ border: borderWidthPrimary solid colorButtonFillTableActionBorder;
52
+ background-color: colorButtonFillTableActionEnabled;
53
+ }
54
+
55
+ .buttonCta:hover {
56
+ background-color: colorButtonFillTableActionHovered;
57
+ }
58
+
59
+ .buttonCta:active {
60
+ background-color: colorButtonFillTableActionPressed;
61
+ }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Tooltip = exports.DELAY_MOTION_DURATION_TYPES = void 0;
6
+ exports.Tooltip = exports.ELEVATION_TYPES = exports.DELAY_MOTION_DURATION_TYPES = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _react2 = require("@floating-ui/react");
9
9
  var ELEVATION = _interopRequireWildcard(require("../../styles/variables/_elevation"));
@@ -26,6 +26,20 @@ const DELAY_MOTION_DURATION_TYPES = Object.freeze({
26
26
  slowest: 'slowest'
27
27
  });
28
28
  exports.DELAY_MOTION_DURATION_TYPES = DELAY_MOTION_DURATION_TYPES;
29
+ const ELEVATION_TYPES = Object.freeze({
30
+ none: 'none',
31
+ card: 'card',
32
+ tooltip: 'tooltip',
33
+ menu: 'menu',
34
+ backdrop: 'backdrop',
35
+ modal: 'modal',
36
+ toast: 'toast'
37
+ });
38
+ exports.ELEVATION_TYPES = ELEVATION_TYPES;
39
+ const getElevationValue = elevation => {
40
+ const elevationKey = 'elevation' + (0, _string.capitalize)(elevation);
41
+ return ELEVATION[elevationKey] || elevation;
42
+ };
29
43
  const Tooltip = _ref => {
30
44
  let {
31
45
  classNames,
@@ -36,7 +50,7 @@ const Tooltip = _ref => {
36
50
  bodyMaxLines = 2,
37
51
  titleMaxLines = 1,
38
52
  delayMotionDuration = 'none',
39
- elevation = ELEVATION['elevationTooltip'],
53
+ elevation = 'tooltip',
40
54
  hidden
41
55
  } = _ref;
42
56
  const [isOpen, setIsOpen] = React.useState(false);
@@ -80,7 +94,7 @@ const Tooltip = _ref => {
80
94
  style: {
81
95
  position: strategy,
82
96
  ...floatingStyles,
83
- '--tooltip-elevation': elevation
97
+ '--tooltip-elevation': getElevationValue(elevation)
84
98
  }
85
99
  }, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
86
100
  line: titleMaxLines,
@@ -53,6 +53,18 @@ export type DelayMotionDurationType = $Values<
53
53
  typeof DELAY_MOTION_DURATION_TYPES,
54
54
  >;
55
55
 
56
+ export const ELEVATION_TYPES = Object.freeze({
57
+ none: 'none',
58
+ card: 'card',
59
+ tooltip: 'tooltip',
60
+ menu: 'menu',
61
+ backdrop: 'backdrop',
62
+ modal: 'modal',
63
+ toast: 'toast',
64
+ });
65
+
66
+ export type ElevationType = $Values<typeof ELEVATION_TYPES>;
67
+
56
68
  export type PlacementType =
57
69
  | 'top'
58
70
  | 'top-start'
@@ -82,6 +94,11 @@ export type TooltipProps = {
82
94
  children: any,
83
95
  };
84
96
 
97
+ const getElevationValue = (elevation: string): string => {
98
+ const elevationKey = 'elevation' + capitalize(elevation);
99
+ return ELEVATION[elevationKey] || elevation;
100
+ };
101
+
85
102
  export const Tooltip = ({
86
103
  classNames,
87
104
  children,
@@ -91,7 +108,7 @@ export const Tooltip = ({
91
108
  bodyMaxLines = 2,
92
109
  titleMaxLines = 1,
93
110
  delayMotionDuration = 'none',
94
- elevation = ELEVATION['elevationTooltip'],
111
+ elevation = 'tooltip',
95
112
  hidden,
96
113
  }: TooltipProps): React.Node => {
97
114
  const [isOpen, setIsOpen] = React.useState(false);
@@ -151,7 +168,7 @@ export const Tooltip = ({
151
168
  style={{
152
169
  position: strategy,
153
170
  ...floatingStyles,
154
- '--tooltip-elevation': elevation,
171
+ '--tooltip-elevation': getElevationValue(elevation),
155
172
  }}
156
173
  {...getFloatingProps()}
157
174
  >