@redsift/design-system 9.0.0 → 9.1.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.
package/index.d.ts CHANGED
@@ -1672,14 +1672,19 @@ type PillSize = ValueOf<typeof PillSize>;
1672
1672
  interface PillProps extends ComponentProps<'div'>, StylingProps {
1673
1673
  /** Whether the badge should automatically break content. */
1674
1674
  autoBreak?: boolean;
1675
+ /** Right button. Usually used to remove the pill but can be used for anything else. An icon should be provided as the only content. By default the icon is an cross. No action is automated here, an onClick should be provided. */
1676
+ rightButton?: Omit<IconButtonProps, 'ref' | 'color'>;
1675
1677
  /** Color variant. The product colors are available but should only be used to display the Pill in the color of another product. To display a Pill with a color of the current product, use `default`. */
1676
- color?: PresentationColorPalette | 'white' | 'black' | 'no-data' | 'error' | 'warning' | 'success' | 'error-dark' | 'warning-dark' | 'success-dark';
1678
+ color?: PresentationColorPalette | 'white' | 'black' | 'no-data' | 'error' | 'warning' | 'success' | 'error-dark' | 'warning-dark' | 'success-dark' | (string & {});
1679
+ /** Color to use on hover. */
1680
+ hoverColor?: string;
1677
1681
  /** Size of the Pill. */
1678
1682
  size?: PillSize;
1679
1683
  }
1680
1684
  type StyledPillProps = Omit<PillProps, 'color' | 'autoBreak'> & {
1681
1685
  $autoBreak: PillProps['autoBreak'];
1682
1686
  $color: PillProps['color'];
1687
+ $hoverColor: PillProps['hoverColor'];
1683
1688
  $size: PillProps['size'];
1684
1689
  };
1685
1690
 
@@ -2759,6 +2764,11 @@ interface TextFieldProps extends Omit<ComponentProps<'div'>, 'onChange'>, Stylin
2759
2764
  onChange?(value?: string, name?: string, event?: ChangeEvent<HTMLInputElement>): void;
2760
2765
  /** Method to handle component clear. */
2761
2766
  onClear?(): void;
2767
+ /** List of Pills. */
2768
+ pills?: {
2769
+ label: string;
2770
+ value: string;
2771
+ }[];
2762
2772
  /** Placeholder. */
2763
2773
  placeholder?: string;
2764
2774
  /** Input type. */
package/index.js CHANGED
@@ -5039,7 +5039,7 @@ const StyledCheckbox = styled.label`
5039
5039
  width: fit-content;
5040
5040
  ${baseStyling}
5041
5041
 
5042
- align-items: center;
5042
+ align-items: flex-start;
5043
5043
  background: none;
5044
5044
  border: none;
5045
5045
  display: inline-flex;
@@ -5075,6 +5075,7 @@ const StyledCheckbox = styled.label`
5075
5075
  line-height: var(--redsift-typography-body-line-height);
5076
5076
  padding-left: 4px;
5077
5077
  padding-right: 16px;
5078
+ padding-top: 2px;
5078
5079
 
5079
5080
  [dir='rtl'] & {
5080
5081
  padding-left: 16px;
@@ -5793,11 +5794,50 @@ const PillSize = {
5793
5794
  * Component props.
5794
5795
  */
5795
5796
 
5797
+ const pickTextColorBasedOnBgColorAdvanced = (bgColor, lightColor, darkColor) => {
5798
+ var color = bgColor.charAt(0) === '#' ? bgColor.substring(1, 7) : bgColor;
5799
+ var r = parseInt(color.substring(0, 2), 16); // hexToR
5800
+ var g = parseInt(color.substring(2, 4), 16); // hexToG
5801
+ var b = parseInt(color.substring(4, 6), 16); // hexToB
5802
+ var uicolors = [r / 255, g / 255, b / 255];
5803
+ var c = uicolors.map(col => {
5804
+ if (col <= 0.03928) {
5805
+ return col / 12.92;
5806
+ }
5807
+ return Math.pow((col + 0.055) / 1.055, 2.4);
5808
+ });
5809
+ var L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
5810
+ return L > 0.179 ? darkColor : lightColor;
5811
+ };
5812
+ const nameToHex = color => {
5813
+ return [...Object.keys(PresentationColorPalette), 'white', 'black', 'no-data', 'error', 'warning', 'success', 'error-dark', 'warning-dark', 'success-dark'].includes(color) ? {
5814
+ green: RedsiftColorPresentationGreenLight,
5815
+ pink: RedsiftColorPresentationPinkLight,
5816
+ aqua: RedsiftColorPresentationAquaLight,
5817
+ brown: RedsiftColorPresentationBrownLight,
5818
+ red: RedsiftColorPresentationRedLight,
5819
+ yellow: RedsiftColorPresentationYellowLight,
5820
+ purple: RedsiftColorPresentationPurpleLight,
5821
+ orange: RedsiftColorPresentationOrangeLight,
5822
+ blue: RedsiftColorPresentationBlueLight,
5823
+ grey: RedsiftColorPresentationGreyLight,
5824
+ white: RedsiftColorNeutralWhite,
5825
+ black: RedsiftColorNeutralBlack,
5826
+ 'no-data': RedsiftColorNeutralMidgrey,
5827
+ error: RedsiftColorPresentationRedLighter,
5828
+ warning: RedsiftColorPresentationOrangeLighter,
5829
+ success: RedsiftColorPresentationGreenLighter,
5830
+ 'error-dark': RedsiftColorPresentationRedDefault,
5831
+ 'warning-dark': RedsiftColorPresentationOrangeDefault,
5832
+ 'success-dark': RedsiftColorPresentationGreenDefault
5833
+ }[color] : color;
5834
+ };
5835
+
5796
5836
  /**
5797
5837
  * Component style.
5798
5838
  */
5799
5839
  const StyledPill = styled.div`
5800
- align-items: center;
5840
+ align-items: stretch;
5801
5841
  display: inline-flex;
5802
5842
  gap: 4px;
5803
5843
  width: fit-content;
@@ -5806,65 +5846,94 @@ const StyledPill = styled.div`
5806
5846
  border-radius: 2px;
5807
5847
  padding: 2px 8px;
5808
5848
  text-align: center;
5809
-
5810
- ${_ref => {
5849
+
5850
+ .redsift-pill-content {
5851
+ ${_ref => {
5811
5852
  let {
5812
5853
  $autoBreak
5813
5854
  } = _ref;
5814
5855
  return !$autoBreak ? css`
5815
- text-wrap: nowrap;
5816
- ` : css`
5817
- word-break: break-word;
5818
- `;
5856
+ text-wrap: nowrap;
5857
+ ` : css`
5858
+ word-break: break-word;
5859
+ `;
5819
5860
  }};
5820
5861
 
5862
+ align-items: center;
5863
+ display: inline-flex;
5864
+ gap: 4px;
5865
+ width: fit-content;
5866
+ }
5867
+
5821
5868
  ${_ref2 => {
5822
5869
  let {
5823
- $color
5870
+ $color,
5871
+ $hoverColor,
5872
+ $size
5824
5873
  } = _ref2;
5825
5874
  return css`
5826
5875
  ${$color === 'black' ? 'background-color: var(--redsift-color-neutral-black);' : $color === 'white' ? css`
5827
5876
  background-color: var(--redsift-color-neutral-white);
5828
5877
  border: 1px solid #d6d6d6;
5829
- ` : $color === 'no-data' ? 'background-color: var(--redsift-color-neutral-midgrey);' : $color === 'error' ? 'background-color: var(--redsift-color-presentation-red-lighter);' : $color === 'warning' ? 'background-color: var(--redsift-color-presentation-orange-lighter);' : $color === 'success' ? 'background-color: var(--redsift-color-presentation-green-lighter);' : $color === 'error-dark' ? 'background-color: var(--redsift-color-presentation-red-default);' : $color === 'warning-dark' ? 'background-color: var(--redsift-color-presentation-orange-default);' : $color === 'success-dark' ? 'background-color: var(--redsift-color-presentation-green-default);' : `background-color: var(--redsift-color-presentation-${$color}-light);`}
5878
+ ` : $color === 'no-data' ? 'background-color: var(--redsift-color-neutral-midgrey);' : $color === 'error' ? 'background-color: var(--redsift-color-presentation-red-lighter);' : $color === 'warning' ? 'background-color: var(--redsift-color-presentation-orange-lighter);' : $color === 'success' ? 'background-color: var(--redsift-color-presentation-green-lighter);' : $color === 'error-dark' ? 'background-color: var(--redsift-color-presentation-red-default);' : $color === 'warning-dark' ? 'background-color: var(--redsift-color-presentation-orange-default);' : $color === 'success-dark' ? 'background-color: var(--redsift-color-presentation-green-default);' : Object.keys(PresentationColorPalette).includes($color) ? `background-color: var(--redsift-color-presentation-${$color}-light);` : `background-color: ${$color};`}
5830
5879
 
5831
5880
  &,
5832
5881
  .redsift-icon {
5833
- color: var(--redsift-color-neutral-${['black', 'no-data', 'error-dark'].includes($color) ? 'white' : 'black'});
5882
+ color: ${pickTextColorBasedOnBgColorAdvanced(nameToHex($color), RedsiftColorNeutralWhite, RedsiftColorNeutralBlack)};
5883
+ }
5884
+
5885
+ button {
5886
+ cursor: pointer;
5887
+ background: none;
5888
+ border: none;
5889
+ border-radius: 0 2px 2px 0;
5890
+ margin: -2px -8px -2px 2px;
5891
+ border-left: 1px solid ${$color === 'white' ? '#d6d6d6' : css`var(--redsift-color-neutral-white)`};
5892
+ font-size: ${$size === PillSize.large ? css`15px` : css`14px`};
5893
+ }
5894
+
5895
+ button:hover {
5896
+ ${$color === 'black' ? 'background-color: var(--redsift-color-neutral-darkgrey);' : $color === 'white' ? 'background-color: var(--redsift-color-neutral-xlightgrey);' : $color === 'no-data' ? 'background-color: var(--redsift-color-neutral-darkgrey);' : $color === 'error' ? 'background-color: var(--redsift-color-presentation-red-light);' : $color === 'warning' ? 'background-color: var(--redsift-color-presentation-orange-light);' : $color === 'success' ? 'background-color: var(--redsift-color-presentation-green-light);' : $color === 'error-dark' ? 'background-color: var(--redsift-color-presentation-red-dark);' : $color === 'warning-dark' ? 'background-color: var(--redsift-color-presentation-orange-dark);' : $color === 'success-dark' ? 'background-color: var(--redsift-color-presentation-green-dark);' : Object.keys(PresentationColorPalette).includes($color) ? `background-color: var(--redsift-color-presentation-${$color}-default);` : ''}
5897
+ background-color: ${$hoverColor};
5834
5898
  }
5835
5899
  `;
5836
5900
  }}}
5837
5901
 
5838
5902
  &,
5839
- .redsift-icon {
5840
- font-family: var(--redsift-typography-pill-font-family);
5841
- font-size: ${_ref3 => {
5903
+ .redsift-pill-content {
5904
+ &,
5905
+ .redsift-icon,
5906
+ .redsift-text,
5907
+ .redsift-number {
5908
+ font-family: var(--redsift-typography-pill-font-family);
5909
+ font-size: ${_ref3 => {
5842
5910
  let {
5843
5911
  $size
5844
5912
  } = _ref3;
5845
5913
  return $size === PillSize.large ? css`var(--redsift-typography-chip-font-size)` : css`var(--redsift-typography-pill-font-size)`;
5846
5914
  }}};
5847
- font-weight: var(--redsift-typography-pill-font-weight);
5848
- line-height: ${_ref4 => {
5915
+ font-weight: var(--redsift-typography-pill-font-weight);
5916
+ line-height: ${_ref4 => {
5849
5917
  let {
5850
5918
  $size
5851
5919
  } = _ref4;
5852
5920
  return $size === PillSize.large ? css`var(--redsift-typography-chip-line-height)` : css`var(--redsift-typography-pill-line-height)`;
5853
5921
  }}};
5854
- }
5922
+ }
5855
5923
 
5856
- .redsift-icon {
5857
- width: unset;
5858
- height: unset;
5924
+ .redsift-icon {
5925
+ width: unset;
5926
+ height: unset;
5859
5927
 
5860
- > svg {
5861
- width: 1em;
5862
- height: 1em;
5928
+ > svg {
5929
+ width: 1em;
5930
+ height: 1em;
5931
+ }
5863
5932
  }
5864
5933
  }
5865
5934
  `;
5866
5935
 
5867
- const _excluded$g = ["autoBreak", "children", "className", "color", "size"];
5936
+ const _excluded$g = ["autoBreak", "children", "className", "color", "hoverColor", "rightButton", "size"];
5868
5937
  const COMPONENT_NAME$h = 'Pill';
5869
5938
  const CLASSNAME$h = 'redsift-pill';
5870
5939
  const DEFAULT_PROPS$h = {
@@ -5882,16 +5951,28 @@ const Pill = /*#__PURE__*/forwardRef((props, ref) => {
5882
5951
  children,
5883
5952
  className,
5884
5953
  color,
5954
+ hoverColor,
5955
+ rightButton,
5885
5956
  size
5886
5957
  } = props,
5887
5958
  forwardedProps = _objectWithoutProperties(props, _excluded$g);
5888
5959
  return /*#__PURE__*/React__default.createElement(StyledPill, _extends$1({}, forwardedProps, {
5889
5960
  $autoBreak: autoBreak,
5890
5961
  $color: color,
5962
+ $hoverColor: hoverColor,
5891
5963
  $size: size,
5892
5964
  className: classNames(Pill.className, className),
5893
5965
  ref: ref
5894
- }), children);
5966
+ }), /*#__PURE__*/React__default.createElement("div", {
5967
+ className: `${Pill.className}-content`
5968
+ }, children), rightButton ? /*#__PURE__*/React__default.createElement("button", _extends$1({
5969
+ "aria-label": "Clear",
5970
+ color: "question"
5971
+ }, rightButton, {
5972
+ className: "right clear"
5973
+ }), /*#__PURE__*/React__default.createElement(Icon, {
5974
+ icon: mdiClose$1
5975
+ })) : null);
5895
5976
  });
5896
5977
  Pill.className = CLASSNAME$h;
5897
5978
  Pill.defaultProps = DEFAULT_PROPS$h;
@@ -12441,7 +12522,7 @@ const StyledTextField = styled.div`
12441
12522
  pointer-events: none;
12442
12523
  position: absolute;
12443
12524
  text-overflow: ellipsis;
12444
- top: -8px;
12525
+ top: ${$hasContent ? '-8px' : '-5px'};
12445
12526
  transform-origin: top left;
12446
12527
  transition: color 200ms cubic-bezier(0, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0, 0, 0.2, 1) 0ms,
12447
12528
  max-width 200ms cubic-bezier(0, 0, 0.2, 1) 0ms;
@@ -12468,31 +12549,44 @@ const StyledTextField = styled.div`
12468
12549
  }
12469
12550
 
12470
12551
  .redsift-text-field__input-wrapper {
12471
- align-items: center;
12552
+ align-items: flex-start;
12472
12553
  box-sizing: border-box;
12473
12554
  cursor: text;
12474
12555
  display: inline-flex;
12475
12556
  position: relative;
12476
- position: relative;
12557
+ }
12558
+
12559
+ .redsift-text-field__pills {
12560
+ align-items: center;
12561
+ box-sizing: border-box;
12562
+ display: flex;
12563
+ flex-wrap: wrap;
12564
+ flex: 1 1 auto;
12565
+ padding-bottom: 6px;
12566
+ ${$variant !== TextFieldVariant.underline && !$hasLeftIcon ? css`
12567
+ padding-left: 16px;
12568
+ ` : ''}
12569
+ padding-top: 10px;
12570
+
12571
+ .redsift-pill {
12572
+ margin: 3px 6px 3px 0;
12573
+ }
12477
12574
  }
12478
12575
 
12479
12576
  .redsift-text-field-input-wrapper__input {
12480
12577
  background: none;
12481
12578
  border: 0;
12482
12579
  box-sizing: content-box;
12483
- display: block;
12580
+ display: flex;
12581
+ flex: 1 1 auto;
12484
12582
  font-family: var(--redsift-typography-input-text-font-family);
12485
12583
  font-size: var(--redsift-typography-input-text-font-size);
12486
12584
  font-weight: var(--redsift-typography-input-text-font-weight);
12487
12585
  line-height: var(--redsift-typography-input-text-line-height);
12488
12586
  min-width: 0;
12489
- padding-bottom: 6px;
12490
-
12491
- ${$variant !== TextFieldVariant.underline ? css`
12492
- padding-left: 16px;
12493
- ` : ''}
12494
- padding-top: 10px;
12495
- width: 100%;
12587
+ min-width: 100px;
12588
+ padding: 2px 0;
12589
+ width: auto;
12496
12590
 
12497
12591
  ${$isDisabled ? css`
12498
12592
  color: var(--redsift-color-notifications-no-data-primary);
@@ -12573,22 +12667,33 @@ const StyledTextField = styled.div`
12573
12667
  padding: 2px;
12574
12668
  }
12575
12669
 
12670
+ .redsift-text-field-input-wrapper__toolbar {
12671
+ position: relative;
12672
+ top: 9px;
12673
+ }
12674
+
12576
12675
  ${$variant !== TextFieldVariant.underline ? css`
12577
12676
  .redsift-icon.left {
12578
12677
  padding-left: 12px;
12579
- margin-right: -8px;
12678
+ padding-right: 8px;
12580
12679
  line-height: 28px;
12680
+ top: 10px;
12581
12681
  }
12582
12682
 
12583
12683
  .redsift-text-field-input-wrapper__toolbar {
12584
12684
  padding-right: 8px;
12585
12685
  }
12586
- ` : ''}
12686
+ ` : css`
12687
+ .redsift-icon.left {
12688
+ padding-right: 8px;
12689
+ top: 10px;
12690
+ }
12691
+ `}
12587
12692
  `;
12588
12693
  }}
12589
12694
  `;
12590
12695
 
12591
- const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "className", "defaultValue", "hasClearButton", "after", "internal", "inputProps", "inputRef", "isColored", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "label", "leftIcon", "name", "onBlur", "onChange", "onClear", "onFocus", "placeholder", "type", "value", "variant"];
12696
+ const _excluded = ["aria-label", "aria-labelledby", "autoFocus", "className", "defaultValue", "hasClearButton", "after", "internal", "inputProps", "inputRef", "isColored", "isDisabled", "isInvalid", "isReadOnly", "isRequired", "label", "leftIcon", "name", "onBlur", "onChange", "onClear", "onFocus", "pills", "placeholder", "type", "value", "variant"];
12592
12697
  const COMPONENT_NAME = 'TextField';
12593
12698
  const CLASSNAME = 'redsift-text-field';
12594
12699
  const DEFAULT_PROPS = {
@@ -12625,6 +12730,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
12625
12730
  onChange,
12626
12731
  onClear,
12627
12732
  onFocus: onFocusProps,
12733
+ pills,
12628
12734
  placeholder,
12629
12735
  type,
12630
12736
  value: propsValue,
@@ -12676,7 +12782,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
12676
12782
  setValue('');
12677
12783
  }, [onChange]);
12678
12784
  return /*#__PURE__*/React__default.createElement(StyledTextField, _extends$1({}, focusWithinProps, forwardedProps, {
12679
- $hasContent: isFocusWithin || Boolean(isControlled ? propsValue : value) || Boolean(placeholder),
12785
+ $hasContent: isFocusWithin || Boolean(isControlled ? propsValue : value) || Boolean(placeholder) || Boolean(pills && pills.length > 0),
12680
12786
  $hasLeftIcon: Boolean(leftIcon),
12681
12787
  $isColored: isColored,
12682
12788
  $isDisabled: isDisabled,
@@ -12696,7 +12802,13 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
12696
12802
  }, leftIcon, {
12697
12803
  "aria-hidden": "true",
12698
12804
  className: "left"
12699
- })) : null, /*#__PURE__*/React__default.createElement("input", _extends$1({}, inputProps, {
12805
+ })) : null, /*#__PURE__*/React__default.createElement("div", {
12806
+ className: `${TextField.className}__pills`
12807
+ }, pills === null || pills === void 0 ? void 0 : pills.map(pill => /*#__PURE__*/React__default.createElement(Pill, {
12808
+ key: pill.value,
12809
+ color: "blue",
12810
+ size: "small"
12811
+ }, pill.label)), /*#__PURE__*/React__default.createElement("input", _extends$1({}, inputProps, {
12700
12812
  onBlur: event => {
12701
12813
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
12702
12814
  onBlurProps === null || onBlurProps === void 0 ? void 0 : onBlurProps(event);
@@ -12720,7 +12832,7 @@ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
12720
12832
  ref: inputRef,
12721
12833
  type: type,
12722
12834
  value: isControlled ? propsValue : value
12723
- })), hasClearButton || internal || after ? /*#__PURE__*/React__default.createElement(Flexbox, {
12835
+ }))), hasClearButton || internal || after ? /*#__PURE__*/React__default.createElement(Flexbox, {
12724
12836
  className: `${TextField.className}-input-wrapper__toolbar`,
12725
12837
  gap: "8px"
12726
12838
  }, hasClearButton ? /*#__PURE__*/React__default.createElement(IconButton, _extends$1({