@innovaccer/design-system 2.8.0-0 → 2.8.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 (35) hide show
  1. package/core/components/atoms/checkbox/__stories__/Group.story.tsx +1 -1
  2. package/core/components/atoms/checkbox/__stories__/Nested.story.tsx +2 -0
  3. package/core/components/atoms/dropdown/DropdownList.tsx +57 -29
  4. package/core/components/atoms/popperWrapper/PopperWrapper.tsx +25 -38
  5. package/core/components/molecules/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap +260 -195
  6. package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +13 -12
  7. package/core/components/molecules/fullscreenModal/__tests__/Fullscreen.test.tsx +2 -5
  8. package/core/components/molecules/fullscreenModal/__tests__/__snapshots__/Fullscreen.test.tsx.snap +126 -96
  9. package/core/components/molecules/modal/Modal.tsx +11 -9
  10. package/core/components/molecules/modal/__tests__/__snapshots__/Modal.test.tsx.snap +240 -180
  11. package/core/components/molecules/popover/Popover.tsx +9 -0
  12. package/core/components/molecules/popover/__tests__/__snapshots__/Popover.test.tsx.snap +8 -8
  13. package/core/components/molecules/sidesheet/Sidesheet.tsx +23 -22
  14. package/core/components/molecules/sidesheet/__tests__/__snapshots__/Sidesheet.test.tsx.snap +40 -30
  15. package/core/components/molecules/tooltip/Tooltip.tsx +20 -1
  16. package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +6 -6
  17. package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +2 -2
  18. package/css/dist/index.css +253 -5
  19. package/css/dist/index.css.map +1 -1
  20. package/css/src/components/dropdown.css +5 -0
  21. package/css/src/components/dropdownButton.css +2 -0
  22. package/css/src/components/fullscreenModal.css +0 -5
  23. package/css/src/components/popover.css +12 -0
  24. package/css/src/components/tooltip.css +115 -0
  25. package/css/src/core/animation.css +8 -0
  26. package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +0 -1
  27. package/dist/core/components/molecules/popover/Popover.d.ts +4 -0
  28. package/dist/core/components/molecules/sidesheet/Sidesheet.d.ts +1 -0
  29. package/dist/index.esm.js +106 -77
  30. package/dist/index.js +128 -101
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.umd.js +1 -1
  33. package/dist/index.umd.js.br +0 -0
  34. package/dist/index.umd.js.gz +0 -0
  35. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { Checkbox, Label } from '@/index';
3
3
 
4
4
  export const CheckboxGroup = () => (
5
5
  <div>
6
- <Label>Problems</Label>
6
+ <Label className="mb-3">Problems</Label>
7
7
  <Checkbox label="Cardiovascular" defaultChecked={true} />
8
8
  <Checkbox label="Obesity" defaultChecked={true} className="mt-5" />
9
9
  <Checkbox label="Patient has language barriers" className="mt-5" />
@@ -51,6 +51,7 @@ export const NestedCheckboxes = () => {
51
51
  value={label}
52
52
  onChange={(c) => handleChildChange(c, ind)}
53
53
  defaultChecked={ind < 2}
54
+ className="mt-4"
54
55
  />
55
56
  );
56
57
  })}
@@ -105,6 +106,7 @@ const customCode = `() => {
105
106
  checked={checked[ind]}
106
107
  value={label}
107
108
  onChange={c => handleChildChange(c, ind)}
109
+ className="mt-4"
108
110
  />
109
111
  );
110
112
  })
@@ -225,6 +225,9 @@ const DropdownList = (props: OptionsProps) => {
225
225
  const [popoverStyle, setPopoverStyle] = React.useState<PopoverProps['customStyle']>();
226
226
  const [cursor, setCursor] = React.useState(firstEnabledOption);
227
227
 
228
+ // Re-initializes its value to 0 on every re-render
229
+ let animateOrder = 0;
230
+
228
231
  React.useEffect(() => {
229
232
  if (dropdownOpen) {
230
233
  const { width, minWidth, maxWidth } = props;
@@ -282,11 +285,28 @@ const DropdownList = (props: OptionsProps) => {
282
285
  return Dropdown;
283
286
  };
284
287
 
288
+ const animateClass = classNames({
289
+ ['fade-in']: dropdownOpen,
290
+ ['opacity-0']: true,
291
+ ['Dropdown-items']: true,
292
+ ['fade-out']: !dropdownOpen,
293
+ });
294
+
295
+ const getAnimateOrderStyle = (order: number) => {
296
+ const animateStyle: React.CSSProperties = {
297
+ animationDelay: (dropdownOpen ? order : order * -1) * 80 + 'ms',
298
+ };
299
+ return animateStyle;
300
+ };
301
+
285
302
  const getDropdownSectionClass = (showClearButton?: boolean) => {
286
- return classNames({
287
- ['Dropdown-section']: true,
288
- ['Dropdown-section--withClear']: showClearButton,
289
- });
303
+ return classNames(
304
+ {
305
+ ['Dropdown-section']: true,
306
+ ['Dropdown-section--withClear']: showClearButton,
307
+ },
308
+ animateClass
309
+ );
290
310
  };
291
311
 
292
312
  const dropdownClass = classNames(
@@ -301,11 +321,14 @@ const DropdownList = (props: OptionsProps) => {
301
321
  ['Dropdown-wrapper--wrap']: !truncateOption,
302
322
  });
303
323
 
304
- const SelectAllClass = classNames({
305
- ['Option-checkbox']: true,
306
- ['Option-checkbox--active']: cursor === 0,
307
- ['OptionWrapper']: true,
308
- });
324
+ const SelectAllClass = classNames(
325
+ {
326
+ ['Option-checkbox']: true,
327
+ ['Option-checkbox--active']: cursor === 0,
328
+ ['OptionWrapper']: true,
329
+ },
330
+ animateClass
331
+ );
309
332
 
310
333
  const onToggleDropdown = (open: boolean, type?: string) => {
311
334
  toggleDropdown(open, type);
@@ -347,7 +370,7 @@ const DropdownList = (props: OptionsProps) => {
347
370
  const renderFooter = () => {
348
371
  const { footerLabel = 'Search for more options' } = props;
349
372
  return (
350
- <div className={'Dropdown-footer'}>
373
+ <div className={`Dropdown-footer ${animateClass}`} style={getAnimateOrderStyle(++animateOrder)}>
351
374
  <Text size="small" appearance={'subtle'}>
352
375
  {footerLabel}
353
376
  </Text>
@@ -360,7 +383,7 @@ const DropdownList = (props: OptionsProps) => {
360
383
  const isClearDisabled = selected.every((option) => option.disabled);
361
384
 
362
385
  return (
363
- <div className={getDropdownSectionClass(selectedGroup)}>
386
+ <div className={getDropdownSectionClass(selectedGroup)} style={getAnimateOrderStyle(++animateOrder)}>
364
387
  <Text size="small" appearance={'subtle'}>
365
388
  {group}
366
389
  </Text>
@@ -382,7 +405,7 @@ const DropdownList = (props: OptionsProps) => {
382
405
  const renderApplyButton = () => {
383
406
  const disable = _isEqual(previousSelected, tempSelected);
384
407
  return (
385
- <div className={'Dropdown-buttonWrapper'}>
408
+ <div className={`Dropdown-buttonWrapper ${animateClass}`} style={getAnimateOrderStyle(++animateOrder)}>
386
409
  <Button
387
410
  ref={dropdownCancelButtonRef}
388
411
  className="mr-4"
@@ -410,7 +433,7 @@ const DropdownList = (props: OptionsProps) => {
410
433
 
411
434
  const renderSearch = () => {
412
435
  return (
413
- <div className={'Dropdown-inputWrapper'}>
436
+ <div className={`Dropdown-inputWrapper ${animateClass}`} style={getAnimateOrderStyle(++animateOrder)}>
414
437
  <Input
415
438
  name="Dropdown-search"
416
439
  icon={'search'}
@@ -447,7 +470,11 @@ const DropdownList = (props: OptionsProps) => {
447
470
  const label = selectAllLabel.trim() ? selectAllLabel.trim() : 'Select All';
448
471
 
449
472
  return (
450
- <div className={SelectAllClass} onMouseEnter={() => updateActiveOption(0, true)}>
473
+ <div
474
+ style={getAnimateOrderStyle(++animateOrder)}
475
+ className={SelectAllClass}
476
+ onMouseEnter={() => updateActiveOption(0, true)}
477
+ >
451
478
  <Checkbox
452
479
  label={label}
453
480
  onChange={onSelectAll}
@@ -470,22 +497,23 @@ const DropdownList = (props: OptionsProps) => {
470
497
 
471
498
  const active = selectAllPresent ? index + 1 === cursor : index === cursor;
472
499
  const optionIsSelected = tempSelected.findIndex((option) => option.value === item.value) !== -1;
473
-
474
500
  return (
475
- <Option
476
- optionData={item}
477
- truncateOption={truncateOption}
478
- selected={optionIsSelected}
479
- index={index}
480
- updateActiveOption={updateActiveOption}
481
- optionRenderer={optionRenderer}
482
- active={active}
483
- checkboxes={withCheckbox}
484
- menu={menu}
485
- onClick={() => optionClickHandler(item)}
486
- onChange={(e) => props.onSelect(item, e.target.checked)}
487
- optionType={props.optionType}
488
- />
501
+ <div style={getAnimateOrderStyle(++animateOrder)} className={animateClass}>
502
+ <Option
503
+ optionData={item}
504
+ truncateOption={truncateOption}
505
+ selected={optionIsSelected}
506
+ index={index}
507
+ updateActiveOption={updateActiveOption}
508
+ optionRenderer={optionRenderer}
509
+ active={active}
510
+ checkboxes={withCheckbox}
511
+ menu={menu}
512
+ onClick={() => optionClickHandler(item)}
513
+ onChange={(e) => props.onSelect(item, e.target.checked)}
514
+ optionType={props.optionType}
515
+ />
516
+ </div>
489
517
  );
490
518
  };
491
519
 
@@ -111,7 +111,6 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
111
111
  _timer?: number;
112
112
  _throttleWait?: boolean;
113
113
  offsetMapping: Record<Offset, string>;
114
- positionOffset: Record<PositionType, string>;
115
114
 
116
115
  static defaultProps = {
117
116
  on: 'click',
@@ -134,24 +133,6 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
134
133
  large: '8px',
135
134
  };
136
135
 
137
- this.positionOffset = {
138
- 'auto-start': 'top left',
139
- auto: 'top',
140
- 'auto-end': 'top right',
141
- 'top-start': 'bottom left',
142
- top: 'bottom',
143
- 'top-end': 'bottom right',
144
- 'right-start': 'top right',
145
- right: 'top right',
146
- 'right-end': 'top right',
147
- 'bottom-end': 'top right',
148
- bottom: 'top',
149
- 'bottom-start': 'top left',
150
- 'left-end': 'top left',
151
- left: 'top left',
152
- 'left-start': 'top left',
153
- };
154
-
155
136
  this.triggerRef = React.createRef();
156
137
  this.popupRef = React.createRef();
157
138
 
@@ -184,12 +165,6 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
184
165
  zIndex: zIndex === undefined ? zIndex : zIndex + 1,
185
166
  isOpen: true,
186
167
  });
187
- } else {
188
- setTimeout(() => {
189
- this.setState({
190
- isOpen: false,
191
- });
192
- }, 120);
193
168
  }
194
169
  }
195
170
  }
@@ -344,31 +319,35 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
344
319
  let classes = '';
345
320
 
346
321
  if (!animationClass) {
322
+ const maxHeight = this.popupRef.current?.offsetHeight;
323
+ // we need to check for transformStyles so that we open the popover at correct position (left/right)
347
324
  const transformStyles = this.popupRef.current?.style.getPropertyValue('transform');
348
- if (transformStyles && !animationKeyframe) {
325
+ if (transformStyles && maxHeight && placement && !animationKeyframe) {
349
326
  const uniqueKey = Math.random().toString(36).substring(2, 6);
327
+ const isTop = placement.includes('top');
350
328
 
351
329
  const popperAnimation = `
352
330
  @keyframes popper-open-${uniqueKey} {
353
331
  from {
354
- transform: ${transformStyles} scaleY(0.5);
355
- opacity: 0.5;
332
+ max-height: 0;
333
+ ${isTop ? `margin-top: ${maxHeight}px` : ''};
356
334
  }
357
335
  to {
358
- transform: ${transformStyles} scaleY(1);
359
- opacity: 1
336
+ max-height: ${maxHeight}px;
337
+ ${isTop ? `margin-top: 0px` : ''};
360
338
  }
361
339
  }
362
340
  @keyframes popper-close-${uniqueKey} {
363
341
  from {
364
- transform: ${transformStyles} scaleY(1);
365
- opacity: 1
342
+ max-height: ${maxHeight}px;
343
+ ${isTop ? `margin-top: 0px` : ''};
366
344
  }
367
345
  to {
368
- transform: ${transformStyles} scaleY(0);
369
- opacity: 0.5
346
+ max-height: 0;
347
+ ${isTop ? `margin-top: ${maxHeight}px` : ''};
370
348
  }
371
- }`;
349
+ }
350
+ `;
372
351
 
373
352
  this.setState({
374
353
  animationKeyframe: popperAnimation,
@@ -376,16 +355,17 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
376
355
  });
377
356
  }
378
357
 
358
+ // defining popper-fade-in custom keyframe as it is specific to popover usecase.
379
359
  const popperAnimationStyles = {
380
- transformOrigin: this.positionOffset[this.props.placement],
381
360
  animation: open
382
- ? `popper-open-${uniqueKey} 120ms cubic-bezier(0, 0, 0.38, 0.9)`
383
- : `popper-close-${uniqueKey} 120ms cubic-bezier(0.2, 0, 1, 0.9)`,
361
+ ? `popper-open-${uniqueKey} 120ms cubic-bezier(0, 0, 0.38, 0.9), popper-fade-in 120ms`
362
+ : `popper-close-${uniqueKey} 120ms cubic-bezier(0.2, 0, 1, 0.9) 120ms, fadeOut 120ms 120ms`,
384
363
  };
385
364
 
386
365
  childrenStyles = {
387
366
  ...childrenStyles,
388
367
  ...popperAnimationStyles,
368
+ overflow: 'hidden',
389
369
  };
390
370
  } else {
391
371
  classes = classNames(
@@ -404,6 +384,13 @@ export class PopperWrapper extends React.Component<PopperWrapperProps, PopperWra
404
384
  'data-hide': outOfBoundaries,
405
385
  onMouseEnter: this.handleMouseEnter,
406
386
  onMouseLeave: this.handleMouseLeave,
387
+ onAnimationEnd: () => {
388
+ if (!open) {
389
+ this.setState({
390
+ isOpen: false,
391
+ });
392
+ }
393
+ },
407
394
  };
408
395
 
409
396
  const element = React.cloneElement(