@edvisor/product-language 0.4.2 → 0.5.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.js CHANGED
@@ -4531,20 +4531,18 @@ const LeftRightCard = props => {
4531
4531
  LeftRightCard.Right = Right;
4532
4532
  LeftRightCard.Controls = Controls$1;
4533
4533
 
4534
- const WIDTH = 12;
4535
- const HEIGHT = 10;
4536
- /** no magic here, just copy/pasted the svg from the mockup
4537
- * I had to tweak the width and height though
4538
- */
4539
-
4540
- const svg = `
4541
- <svg xmlns='http://www.w3.org/2000/svg' width='${WIDTH}' height='${HEIGHT}' viewBox='0 0 10 8'>
4542
- <path d='M4.50846 7.37941C4.0689 7.81898 3.35108 7.81898 2.91151 7.37941L0.330581 4.79848C-0.110194 4.35892 -0.110194 3.64109 0.330581 3.20153C0.770146 2.76196 1.48797 2.76196 1.92753 3.20153L3.70999 4.98399L8.07338 0.620598C8.51294 0.181033 9.23076 0.181033 9.67033 0.620598C10.1099 1.06016 10.1099 1.77798 9.67033 2.21755L4.50846 7.37941Z' fill='white'/>
4543
- </svg>
4534
+ const indeterminateSvg = `
4535
+ <svg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 10 8'>
4536
+ <rect fill='white' width='10' height='2' rx='1'/>
4537
+ </svg>
4544
4538
  `;
4539
+ const checkSvg = `
4540
+ <svg xmlns='http://www.w3.org/2000/svg' width='10' height='12' viewBox='0 0 10 8'>
4541
+ <path d='M4.50846 7.37941C4.0689 7.81898 3.35108 7.81898 2.91151 7.37941L0.330581 4.79848C-0.110194 4.35892 -0.110194 3.64109 0.330581 3.20153C0.770146 2.76196 1.48797 2.76196 1.92753 3.20153L3.70999 4.98399L8.07338 0.620598C8.51294 0.181033 9.23076 0.181033 9.67033 0.620598C10.1099 1.06016 10.1099 1.77798 9.67033 2.21755L4.50846 7.37941Z' fill='white'/>
4542
+ </svg>`;
4545
4543
 
4546
- function getCheckMark() {
4547
- return css(["::before{position:absolute;content:url(\"data:image/svg+xml,", "\");top:3px;left:3px;}"], svg);
4544
+ function getCheckMark(indeterminate) {
4545
+ return css(["::before{position:absolute;content:url(\"data:image/svg+xml,", "\");left:", "px;top:", "px;}"], indeterminate ? indeterminateSvg : checkSvg, indeterminate ? 3 : 4, indeterminate ? 6 : 3);
4548
4546
  }
4549
4547
  /** the reason I have this isNil to test
4550
4548
  * whether `checked` was passes is this:
@@ -4559,41 +4557,49 @@ function getCheckMark() {
4559
4557
  */
4560
4558
 
4561
4559
 
4562
- function getCheckedStyles(color) {
4560
+ function getCheckedStyles(indeterminate, color) {
4563
4561
  return css(["", ""], ({
4564
4562
  checked
4565
- }) => isNil(checked) ? css([":checked{background:", ";border:2px solid ", ";", "}"], color, color, getCheckMark()) : checked ? css(["background:", ";border:2px solid ", ";", ""], color, color, getCheckMark()) : '');
4563
+ }) => isNil(checked) ? css([":checked{background:", ";border:2px solid ", ";", "}"], color, color, getCheckMark(indeterminate)) : is(checked) || is(indeterminate) ? css(["background:", ";border:2px solid ", ";", ""], color, color, getCheckMark(indeterminate)) : '');
4566
4564
  }
4567
4565
 
4568
- const getHoverStyles = () => css(["background:", ";", ""], Surface.Default.Hover, getCheckedStyles(Interactive.Default.Hover));
4569
- const getDisabledStyles = () => css(["pointer-events:none;background:", ";border:2px solid ", ";", ""], props => props.checked === true ? `${Borders.Default.Default}` : `${Surface.Default.Subdued}`, Borders.Default.Default, getCheckedStyles(Icons.Disabled));
4570
- const getDefaultStyles = () => css(["background:", ";border:2px solid ", ";", ":hover{", "}"], Surface.Default.Default, Interactive.Default.Disabled, getCheckedStyles(Interactive.Default.Default), getHoverStyles);
4571
- const getInvalidStyles = () => css(["background:", ";border:2px solid ", ";", ""], props => props.checked === true ? `${Actions.Critical.Default}` : `${Surface.Critical.Subdued}`, Borders.Critical.Default, getCheckedStyles(Icons.Critical));
4566
+ const getHoverStyles = indeterminate => css(["background:", ";", ""], Surface.Default.Hover, getCheckedStyles(indeterminate, Interactive.Default.Hover));
4567
+ const getDisabledStyles = indeterminate => css(["pointer-events:none;background:", ";border:2px solid ", ";", ""], props => is(props.checked) || is(indeterminate) ? `${Borders.Default.Default}` : `${Surface.Default.Subdued}`, Borders.Default.Default, getCheckedStyles(indeterminate, Icons.Disabled));
4568
+ const getDefaultStyles = indeterminate => css(["background:", ";border:2px solid ", ";", ":hover{", "}"], Surface.Default.Default, Interactive.Default.Disabled, getCheckedStyles(indeterminate, Interactive.Default.Default), getHoverStyles(indeterminate));
4569
+ const getInvalidStyles = indeterminate => css(["background:", ";border:2px solid ", ";", ""], props => is(props.checked) || is(indeterminate) ? `${Actions.Critical.Default}` : `${Surface.Critical.Subdued}`, Borders.Critical.Default, getCheckedStyles(indeterminate, Icons.Critical));
4572
4570
 
4573
4571
  const CustomizedCheckbox = /*#__PURE__*/styled.input.withConfig({
4574
4572
  displayName: "checkbox__CustomizedCheckbox",
4575
4573
  componentId: "gcfss3-0"
4576
4574
  })(["appearance:none;position:relative;box-sizing:content-box;width:18px;height:18px;margin:", ";padding:", ";border-radius:4px;user-select:none;vertical-align:bottom;display:inline-block;", ":focus-visible{outline:2px solid ", ";outline-offset:1px;}"], Margin.none, Padding.none, ({
4577
4575
  disabled,
4576
+ indeterminate,
4578
4577
  error
4579
4578
  }) => {
4580
4579
  if (is(disabled)) {
4581
- return getDisabledStyles();
4580
+ return getDisabledStyles(indeterminate);
4582
4581
  } else if (is(error)) {
4583
- return getInvalidStyles();
4582
+ return getInvalidStyles(indeterminate);
4584
4583
  } else {
4585
- return getDefaultStyles();
4584
+ return getDefaultStyles(indeterminate);
4586
4585
  }
4587
4586
  }, Focused.Default);
4588
4587
  const Checkbox = props => {
4589
4588
  const {
4590
- error = false
4589
+ error,
4590
+ indeterminate
4591
4591
  } = props,
4592
- htmlProps = __rest(props, ["error"]);
4592
+ htmlProps = __rest(props, ["error", "indeterminate"]);
4593
4593
 
4594
4594
  return jsx(CustomizedCheckbox, Object.assign({}, htmlProps, {
4595
4595
  type: 'checkbox',
4596
- error: error
4596
+ error: error,
4597
+ indeterminate: is(indeterminate),
4598
+ ref: input => {
4599
+ if (isDefined(input)) {
4600
+ input.indeterminate = is(props.indeterminate);
4601
+ }
4602
+ }
4597
4603
  }));
4598
4604
  };
4599
4605
 
@@ -5987,7 +5993,7 @@ const HelpText = /*#__PURE__*/styled(Body).withConfig({
5987
5993
  const ErrorMessage$1 = /*#__PURE__*/styled(Flex).withConfig({
5988
5994
  displayName: "labeled-input__ErrorMessage",
5989
5995
  componentId: "a0ln2j-3"
5990
- })(["margin-bottom:", ";& path{fill:", ";}"], Margin.xxs, Icons.Warning);
5996
+ })(["margin-bottom:", ";& path{fill:", ";}div{color:", ";}"], Margin.xxs, Icons.Critical, Text$1.Critical);
5991
5997
  const LabeledInput = props => {
5992
5998
  return jsxs(HTMLLabel, {
5993
5999
  children: [jsxs("label", {
@@ -6045,13 +6051,13 @@ const Stepper = props => {
6045
6051
  const FancyBorder = /*#__PURE__*/styled(SpaceBetween).withConfig({
6046
6052
  displayName: "input-field__FancyBorder",
6047
6053
  componentId: "sc-1yq0rb7-0"
6048
- })(["background:", ";border:1px solid ", ";border-radius:6px;box-sizing:border-box;margin-bottom:", ";padding-left:", ";user-select:none;:focus,:focus-within,:active{border:", ";}"], ({
6054
+ })(["background:", ";border:1px solid ", ";border-radius:6px;box-sizing:border-box;margin-bottom:", ";padding-left:", ";user-select:none;outline-offset:-2px;", "}"], ({
6049
6055
  invalid
6050
6056
  }) => is(invalid) ? Surface.Critical.Subdued : Surface.Default.Default, ({
6051
6057
  invalid
6052
6058
  }) => is(invalid) ? Borders.Critical.Default : Borders.Default.Default, Margin.xxs, Padding.s, ({
6053
6059
  invalid
6054
- }) => is(invalid) ? `1px solid ${Borders.Critical.Default}` : `2px solid ${Focused.Default}`);
6060
+ }) => !is(invalid) && css([":focus,:focus-within,:active{outline:2px solid ", "}"], Focused.Default));
6055
6061
  const InputLayout = /*#__PURE__*/styled(Flex).withConfig({
6056
6062
  displayName: "input-field__InputLayout",
6057
6063
  componentId: "sc-1yq0rb7-1"
@@ -7275,6 +7281,11 @@ $$3({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
7275
7281
  }
7276
7282
  });
7277
7283
 
7284
+ const DEFAULT_ROW_HEIGHT = 44;
7285
+ const DEFAULT_MENU_HEIGHT = 190;
7286
+ const DEFAULT_EMPTY_TEXT = 'No results found';
7287
+ const DEFAULT_PLACEHOLDER = 'Select Something';
7288
+
7278
7289
  var $$2 = _export;
7279
7290
  var call$2 = functionCall;
7280
7291
 
@@ -7553,18 +7564,22 @@ function toKey(value) {
7553
7564
  return JSON.stringify(value);
7554
7565
  }
7555
7566
  const topPosition = props => {
7556
- if (props.menuPosition === 'top' && isDefined(props.menuHeight) && typeof props.menuHeight === 'number') {
7557
- return `${-(props.menuHeight + (isDefined(props.label) && props.labelPosition !== 'side' ? 58 : 38))}px`;
7567
+ if (props.menuPosition === "top"
7568
+ /* menuPositionType.TOP */
7569
+ && isDefined(props.menuHeight) && typeof props.menuHeight === 'number') {
7570
+ return `${-(props.menuHeight + (isDefined(props.label) && !isEmpty(props.label) && props.labelPosition === "top"
7571
+ /* labelPositionType.TOP */
7572
+ ? 64 : 44))}px`;
7558
7573
  }
7559
7574
 
7560
- return '0';
7575
+ return '4px';
7561
7576
  };
7562
7577
 
7563
- const OptionItem = /*#__PURE__*/styled.div.withConfig({
7578
+ const OptionItem = /*#__PURE__*/styled(SpaceBetween).withConfig({
7564
7579
  displayName: "option__OptionItem",
7565
7580
  componentId: "sc-1hb1qjt-0"
7566
- })(["display:flex;align-items:center;justify-content:space-between;flex:1;height:", "px;padding:", " ", ";min-width:0;cursor:pointer;box-sizing:border-box;background-color:", ";&:hover{background-color:", ";}&:active{background-color:", ";}"], props => defaultTo(props.height, 44), Padding.none, Padding.s, props => is(props.active) ? Surface.Selected.Default : is(props.selected) ? Surface.Default.Hover : Surface.Default.Default, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
7567
- const CheckedIcon = /*#__PURE__*/styled(IconMinor.Check).withConfig({
7581
+ })(["flex:1;height:", "px;min-width:0;cursor:pointer;box-sizing:border-box;margin:", ";border-radius:6px;background-clip:content-box;background-color:", ";& div{padding:", " ", ";}& i:last-child{right:8px;}&:hover{background-color:", ";}&:active{background-color:", ";}"], props => defaultTo(props.height, DEFAULT_ROW_HEIGHT), Margin.xxs, props => is(props.active) ? Surface.Selected.Default : is(props.selected) ? Surface.Default.Hover : Surface.Default.Default, Padding.none, Padding.xs, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
7582
+ const CheckedIcon$1 = /*#__PURE__*/styled(IconMinor.Check).withConfig({
7568
7583
  displayName: "option__CheckedIcon",
7569
7584
  componentId: "sc-1hb1qjt-1"
7570
7585
  })(["svg{path{fill:", "}}"], Icons.Highlight);
@@ -7585,6 +7600,7 @@ const OptionComponent = /*#__PURE__*/memo(props => {
7585
7600
  return jsxs(OptionItem, Object.assign({
7586
7601
  className: className.join(' '),
7587
7602
  "data-role": "option",
7603
+ center: true,
7588
7604
  selected: selected,
7589
7605
  active: active,
7590
7606
  height: height,
@@ -7595,18 +7611,20 @@ const OptionComponent = /*#__PURE__*/memo(props => {
7595
7611
  active: active
7596
7612
  }, option, {
7597
7613
  children: option.label
7598
- })), is(active) && jsx(CheckedIcon, {})]
7614
+ })), is(active) && jsx(CheckedIcon$1, {})]
7599
7615
  }));
7600
7616
  }, areEqual);
7601
7617
 
7602
7618
  const MenuWrapper = /*#__PURE__*/styled.div.withConfig({
7603
7619
  displayName: "menu-container__MenuWrapper",
7604
7620
  componentId: "dadn7s-0"
7605
- })(["z-index:1;position:relative;background:", ";top:", ";box-sizing:border-box;.menu-list{box-sizing:border-box;box-shadow:", ";border:1px solid ", ";background-color:", ";border-radius:6px;opacity:0;transition:opacity 0.1s ease;&:focus{outline:none;}::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}}"], Surface.Default.Default, ({
7621
+ })(["z-index:1;position:relative;background:", ";top:", ";box-sizing:border-box;.menu-list{box-sizing:border-box;box-shadow:", ";border:1px solid ", ";background-color:", ";border-radius:6px;opacity:0;transition:opacity 0.1s ease;padding:", ";&:focus{outline:none;}::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}}"], Surface.Default.Default, ({
7606
7622
  props
7607
7623
  }) => topPosition(props), ({
7608
7624
  props
7609
- }) => props.menuPosition === 'bottom' ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Borders.Default.Subdued, Surface.Default.Default, Surface.Neutral.Default);
7625
+ }) => props.menuPosition === "bottom"
7626
+ /* menuPositionType.BOTTOM */
7627
+ ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Borders.Default.Subdued, Surface.Default.Default, Padding.xxs, Surface.Neutral.Default);
7610
7628
  const MenuContainer = props => {
7611
7629
  const {
7612
7630
  onClick,
@@ -7668,7 +7686,7 @@ fixRegExpWellKnownSymbolLogic$1('search', function (SEARCH, nativeSearch, maybeC
7668
7686
  ];
7669
7687
  });
7670
7688
 
7671
- const MenuRow = /*#__PURE__*/memo(({
7689
+ const MenuRow$1 = /*#__PURE__*/memo(({
7672
7690
  index,
7673
7691
  style,
7674
7692
  data
@@ -7707,18 +7725,24 @@ const SelectLabel = /*#__PURE__*/styled(Label).withConfig({
7707
7725
  const EmptyOptionItem = /*#__PURE__*/styled(OptionItem).withConfig({
7708
7726
  displayName: "menu__EmptyOptionItem",
7709
7727
  componentId: "sc-1086ljy-0"
7710
- })(["border:1px solid ", ";background-color:", ";border-radius:6px;position:absolute;top:", ";width:100%;", ""], Borders.Default.Subdued, Surface.Default.Default, ({
7728
+ })(["border:1px solid ", ";background-color:", ";position:absolute;margin:", ";width:100%;height:54px;box-shadow:", ";&:hover{background-color:", ";}"], Borders.Default.Subdued, Surface.Default.Default, Margin.none, ({
7711
7729
  props
7712
- }) => topPosition(props), shadowSm);
7730
+ }) => props.menuPosition === "bottom"
7731
+ /* menuPositionType.BOTTOM */
7732
+ ? '0px 2px 10px 0px rgba(0, 0, 0, 0.10)' : '0px -2px 10px 0px rgba(0, 0, 0, 0.10)', Surface.Default.Default);
7713
7733
  const Menu = props => {
7714
7734
  const {
7715
- rowHeight = 44,
7735
+ rowHeight = DEFAULT_ROW_HEIGHT,
7716
7736
  selectedIndex,
7717
7737
  open,
7718
7738
  invalid,
7719
- menuHeight,
7720
- menuPosition,
7721
- labelPosition,
7739
+ menuHeight = DEFAULT_MENU_HEIGHT,
7740
+ menuPosition = "bottom"
7741
+ /* menuPositionType.BOTTOM */
7742
+ ,
7743
+ labelPosition = "top"
7744
+ /* labelPositionType.TOP */
7745
+ ,
7722
7746
  label
7723
7747
  } = props;
7724
7748
  const options = safeArray(props.options); // eslint-disable-next-line no-null/no-null
@@ -7726,7 +7750,7 @@ const Menu = props => {
7726
7750
  const list = useRef(null); // eslint-disable-next-line no-null/no-null
7727
7751
 
7728
7752
  const outerRef = useRef(null);
7729
- const height = Math.min(Math.max(options.length * rowHeight, rowHeight) + 2, defaultTo(menuHeight, 185));
7753
+ const height = Math.min(Math.max(options.length * rowHeight, rowHeight) + 10, menuHeight);
7730
7754
  useEffect(() => {
7731
7755
  if (is(open) && isDefined(list.current) && selectedIndex !== undefined && selectedIndex !== -1) {
7732
7756
  list.current.scrollToItem(selectedIndex, 'center');
@@ -7769,7 +7793,7 @@ const Menu = props => {
7769
7793
  }, {
7770
7794
  children: jsx(SelectLabel, {
7771
7795
  children: jsx("span", {
7772
- children: defaultTo(emptyText, 'No results found')
7796
+ children: defaultTo(emptyText, DEFAULT_EMPTY_TEXT)
7773
7797
  })
7774
7798
  })
7775
7799
  }));
@@ -7788,7 +7812,7 @@ const Menu = props => {
7788
7812
  itemCount: itemCount,
7789
7813
  itemData: itemData
7790
7814
  }, {
7791
- children: MenuRow
7815
+ children: MenuRow$1
7792
7816
  }));
7793
7817
  };
7794
7818
 
@@ -7834,7 +7858,7 @@ $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
7834
7858
  const TagContainer = /*#__PURE__*/styled(Tag).withConfig({
7835
7859
  displayName: "value-component-multi__TagContainer",
7836
7860
  componentId: "sc-1fc9cnm-0"
7837
- })(["&:last-of-type{margin-right:", ";}div:first-child{min-height:auto;padding:", " ", " ", " ", ";}div:last-child{padding:", ";}"], Margin.xs, Padding.none, Padding.none, Padding.none, Padding.xxs, Padding.none);
7861
+ })(["div:first-child{min-height:auto;padding:", " ", " ", " ", ";}div:last-child{padding:", ";}"], Padding.none, Padding.none, Padding.none, Padding.xxs, Padding.none);
7838
7862
 
7839
7863
  const ValueComponentMulti = props => {
7840
7864
  const {
@@ -8414,33 +8438,7 @@ function getButtonType(props) {
8414
8438
  const ButtonFrame = /*#__PURE__*/styled.button.withConfig({
8415
8439
  displayName: "button__ButtonFrame",
8416
8440
  componentId: "v4884z-0"
8417
- })(["padding:", ";border:", ";border-radius:6px;background:", ";cursor:", ";display:flex;flex-direction:row;justify-content:center;gap:8px;align-items:center;position:relative;svg[role='icon']{path{fill:", ";}}", ""], props => props.buttonSize, props => props.buttonBorder, props => props.backgroundColor, props => props.cursor, props => props.iconColor, props => !props.isDisabled ? `
8418
- &:hover {
8419
- background: ${props.backgroundHover};
8420
- text-decoration: ${props.textDecorationHover};
8421
- div {
8422
- color: ${props.textColorHover};
8423
- }
8424
- svg[role='icon'] {
8425
- path {
8426
- fill: ${props.iconColorHover};
8427
- }
8428
- }
8429
- }
8430
-
8431
- &:focus {
8432
- outline: 2px solid ${Focused.Default}
8433
- }
8434
-
8435
- &:focus-visible {
8436
- border: 2px solid ${Focused.Default}
8437
- }
8438
-
8439
- &:active {
8440
- text-decoration: 'none'
8441
- background: ${props.backgroundPressed}
8442
- }
8443
- ` : '');
8441
+ })(["padding:", ";border:", ";border-radius:6px;background:", ";cursor:", ";display:flex;flex-direction:row;justify-content:center;gap:8px;align-items:center;position:relative;svg[role='icon']{path{fill:", ";}}", ""], props => props.buttonSize, props => props.buttonBorder, props => props.backgroundColor, props => props.cursor, props => props.iconColor, props => !props.isDisabled && css(["&:hover{background:", ";text-decoration:", ";div{color:", ";}svg[role='icon']{path{fill:", ";}}}outline-offset:-2px;&:focus,focus-visible{outline:2px solid ", "}&:active{text-decoration:'none' background:", "}"], props.backgroundHover, props.textDecorationHover, props.textColorHover, props.iconColorHover, Focused.Default, props.backgroundPressed));
8444
8442
  const ButtonText = /*#__PURE__*/styled(Label).withConfig({
8445
8443
  displayName: "button__ButtonText",
8446
8444
  componentId: "v4884z-1"
@@ -8539,10 +8537,10 @@ const Button = props => {
8539
8537
  }));
8540
8538
  };
8541
8539
 
8542
- const ValueContainer = /*#__PURE__*/styled.div.withConfig({
8540
+ const ValueContainer = /*#__PURE__*/styled(SpaceBetween).withConfig({
8543
8541
  displayName: "value__ValueContainer",
8544
8542
  componentId: "sc-1aps7dx-0"
8545
- })(["display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;flex:1;pointer-events:", ";padding:", " ", " ", " ", ";background:", ";cursor:default;border:1px solid ", ";z-index:0;box-sizing:border-box;max-width:100%;border-radius:6px;outline-offset:-2px;", " ", " ", ""], props => is(props.disabled) ? 'none' : 'auto', Padding.xs, Padding.xs, Padding.xs, Padding.s, Surface.Default.Default, props => is(props.invalid) ? Borders.Critical.Default : Borders.Default.Default, props => is(props.hasLabel) && css(["& div:first-of-type{align-self:flex-start;}"]), props => is(props.menuIsOpen) && css(["outline:2px solid ", ";"], Focused.Default), props => !is(props.disabled) && !is(props.invalid) && `
8543
+ })(["pointer-events:", ";padding:", " ", ";background:", ";cursor:default;border:1px solid ", ";z-index:0;border-radius:6px;outline-offset:-2px;", " ", " ", ""], props => is(props.disabled) ? 'none' : 'auto', Padding.xs, Padding.none, props => is(props.invalid) ? Surface.Critical.Subdued : Surface.Default.Default, props => is(props.invalid) ? Borders.Critical.Default : Borders.Default.Default, props => is(props.hasLabel) && css(["& div:first-of-type{align-self:flex-start;}"]), props => is(props.menuIsOpen) && css(["outline:2px solid ", ";"], Focused.Default), props => !is(props.disabled) && !is(props.invalid) && `
8546
8544
 
8547
8545
  &:focus {
8548
8546
  outline: 2px solid ${Focused.Default}
@@ -8552,39 +8550,50 @@ const ValueContainer = /*#__PURE__*/styled.div.withConfig({
8552
8550
  outline: 2px solid ${Focused.Default}
8553
8551
  }
8554
8552
  `);
8553
+ const ValueWrapper$1 = /*#__PURE__*/styled(Flex).withConfig({
8554
+ displayName: "value__ValueWrapper",
8555
+ componentId: "sc-1aps7dx-1"
8556
+ })(["width:100%;display:", ";"], ({
8557
+ label,
8558
+ labelPosition
8559
+ }) => isDefined(label) && !isEmpty(label) && labelPosition === "top"
8560
+ /* labelPositionType.TOP */
8561
+ ? 'block' : 'flex');
8555
8562
  const ValueLabel = /*#__PURE__*/styled(Label).withConfig({
8556
8563
  displayName: "value__ValueLabel",
8557
- componentId: "sc-1aps7dx-1"
8558
- })(["margin-right:", ";", ""], Margin.xs, ({
8564
+ componentId: "sc-1aps7dx-2"
8565
+ })(["padding-left:", ";width:fit-content;white-space:pre;", ""], Padding.xs, ({
8559
8566
  labelPosition
8560
- }) => labelPosition !== 'side' && css(["flex-basis:100%;}"]));
8561
- const ValueLeft = /*#__PURE__*/styled.div.withConfig({
8567
+ }) => labelPosition === "top"
8568
+ /* labelPositionType.TOP */
8569
+ && css(["flex-basis:100%;"]));
8570
+ const ValueLeft = /*#__PURE__*/styled(Flex).withConfig({
8562
8571
  displayName: "value__ValueLeft",
8563
- componentId: "sc-1aps7dx-2"
8564
- })(["display:flex;flex:1;align-items:center;flex-wrap:", ";user-select:none;min-width:0;min-height:20px;box-sizing:border-box;gap:", ";"], props => is(props.multi) && is(props.hasValue) ? 'wrap' : 'nowrap', props => is(props.multi) ? '4px' : 0);
8565
- const ValueRight = /*#__PURE__*/styled.div.withConfig({
8566
- displayName: "value__ValueRight",
8567
8572
  componentId: "sc-1aps7dx-3"
8568
- })(["display:flex;position:absolute;right:8px;align-items:center;margin-left:", ";box-sizing:border-box;"], Margin.xxs);
8573
+ })(["padding-left:", ";width:100%;flex-wrap:", ";user-select:none;min-width:0;min-height:20px;box-sizing:border-box;gap:", ";"], Padding.xs, props => is(props.multi) && is(props.hasValue) ? 'wrap' : 'nowrap', props => is(props.multi) ? '4px' : 0);
8574
+ const ValueRight = /*#__PURE__*/styled(Flex).withConfig({
8575
+ displayName: "value__ValueRight",
8576
+ componentId: "sc-1aps7dx-4"
8577
+ })(["padding-right:", ";pointer-events:none;"], Padding.xxs);
8569
8578
  const Placeholder = /*#__PURE__*/styled(Label).withConfig({
8570
8579
  displayName: "value__Placeholder",
8571
- componentId: "sc-1aps7dx-4"
8572
- })(["pointer-events:none;color:", ";"], Text$1.Default);
8580
+ componentId: "sc-1aps7dx-5"
8581
+ })(["pointer-events:none;color:", ";"], Text$1.Light);
8573
8582
  const ClearButton = /*#__PURE__*/styled(Button).attrs({
8574
8583
  plain: true,
8575
8584
  subtle: true
8576
8585
  }).withConfig({
8577
8586
  displayName: "value__ClearButton",
8578
- componentId: "sc-1aps7dx-5"
8587
+ componentId: "sc-1aps7dx-6"
8579
8588
  })(["padding:", ";margin-right:", ";gap:0;&:focus{outline:none;}&:active{background-color:transparent;}"], Padding.none, Margin.none);
8580
8589
  const Search = /*#__PURE__*/styled.span.withConfig({
8581
8590
  displayName: "value__Search",
8582
- componentId: "sc-1aps7dx-6"
8591
+ componentId: "sc-1aps7dx-7"
8583
8592
  })(["min-width:1px;margin-left:-1px;user-select:text;", " &:focus{outline:none;}"], props => is(props.canSearch) ? css(["opacity:1;position:relative;left:1px;"]) : css(["position:absolute;opacity:0;"]));
8584
8593
  const ErrorMessage = /*#__PURE__*/styled.div.withConfig({
8585
8594
  displayName: "value__ErrorMessage",
8586
- componentId: "sc-1aps7dx-7"
8587
- })(["display:", ";flex-direction:'row';margin-bottom:", ";width:100%;& path{fill:", ";}"], props => is(props.visible) ? 'flex' : 'none', Margin.xxs, Icons.Warning);
8595
+ componentId: "sc-1aps7dx-8"
8596
+ })(["display:", ";flex-direction:'row';width:100%;padding:", " ", ";& path{fill:", ";}div{color:", ";margin:", " ", "}"], props => is(props.visible) ? 'flex' : 'none', Padding.xxs, Padding.none, Icons.Critical, Text$1.Critical, Margin.none, Margin.xxs);
8588
8597
 
8589
8598
  const Value = props => {
8590
8599
  const search = /*#__PURE__*/createRef();
@@ -8605,7 +8614,9 @@ const Value = props => {
8605
8614
  errors,
8606
8615
  label,
8607
8616
  searchable,
8608
- labelPosition
8617
+ labelPosition = "top"
8618
+ /* labelPositionType.TOP */
8619
+
8609
8620
  } = props;
8610
8621
  const valueOptions = getValueOptions(options, value, multi);
8611
8622
  const showClearer = is(clearable) && valueOptions.length > 0;
@@ -8656,7 +8667,7 @@ const Value = props => {
8656
8667
 
8657
8668
  if (valueOptions.length === 0 && isNil(search === null || search === void 0 ? void 0 : search.current)) {
8658
8669
  return jsx(Placeholder, {
8659
- children: placeholder
8670
+ children: defaultTo(placeholder, DEFAULT_PLACEHOLDER)
8660
8671
  });
8661
8672
  }
8662
8673
 
@@ -8716,16 +8727,24 @@ const Value = props => {
8716
8727
  multi: true,
8717
8728
  menuIsOpen: open,
8718
8729
  tabIndex: 0,
8719
- onClick: onClick
8730
+ onClick: onClick,
8731
+ center: true
8720
8732
  }, {
8721
- children: [renderLabel(), jsxs(ValueLeft, Object.assign({
8722
- className: "value-left",
8723
- multi: multi,
8724
- hasValue: !(valueOptions.length === 0)
8733
+ children: [jsxs(ValueWrapper$1, Object.assign({
8734
+ label: label,
8735
+ labelPosition: labelPosition
8725
8736
  }, {
8726
- children: [searchAtStart && renderSearch(), renderValues(), searchAtEnd && renderSearch()]
8737
+ children: [renderLabel(), jsxs(ValueLeft, Object.assign({
8738
+ className: "value-left",
8739
+ multi: multi,
8740
+ showClearer: showClearer,
8741
+ hasValue: !(valueOptions.length === 0)
8742
+ }, {
8743
+ children: [searchAtStart && renderSearch(), renderValues(), searchAtEnd && renderSearch()]
8744
+ }))]
8727
8745
  })), jsxs(ValueRight, Object.assign({
8728
- className: "value-right"
8746
+ className: "value-right",
8747
+ center: true
8729
8748
  }, {
8730
8749
  children: [showClearer && jsx(ClearButton, {
8731
8750
  tabIndex: -1,
@@ -8746,14 +8765,38 @@ const Value = props => {
8746
8765
 
8747
8766
  var Value$1 = /*#__PURE__*/memo(Value);
8748
8767
 
8749
- const Container$1 = /*#__PURE__*/styled.div.withConfig({
8750
- displayName: "select__Container",
8751
- componentId: "iypjy6-0"
8752
- })(["position:relative;cursor:default;width:100%;box-sizing:border-box;pointer-events:", ";opacity:", ";user-select:none;"], props => is(props.disabled) ? 'none' : 'auto', props => is(props.disabled) ? 0.75 : 1);
8753
- const SelectImpl = (props, ref) => {
8754
- if (isNil(ref)) {
8768
+ /**
8769
+ * @TODO Use this container and remove the ContainerStyles
8770
+ * when we have a solution for RWC styled components, or move away from it.
8771
+ */
8772
+
8773
+ /*const Container = styled.div`
8774
+ position: relative;
8775
+ cursor: default;
8776
+ width: 100%;
8777
+ box-sizing: border-box;
8778
+ pointer-events: ${(props: { disabled?: boolean }) =>
8779
+ is(props.disabled) ? 'none' : 'auto'};
8780
+ opacity: ${(props: { disabled?: boolean }) => (is(props.disabled) ? 0.75 : 1)};
8781
+ user-select: none;
8782
+ `*/
8783
+
8784
+ const ContainerStyles = ({
8785
+ disabled
8786
+ }) => ({
8787
+ position: 'relative',
8788
+ cursor: 'default',
8789
+ width: '100%',
8790
+ boxSizing: 'border-box',
8791
+ pointerEvents: is(disabled) ? 'none' : 'auto',
8792
+ opacity: is(disabled) ? 0.75 : 1,
8793
+ userSelect: 'none'
8794
+ });
8795
+
8796
+ const SelectImpl = (props, selectRef) => {
8797
+ if (isNil(selectRef)) {
8755
8798
  // eslint-disable-next-line no-null/no-null, react-hooks/rules-of-hooks
8756
- ref = useRef(null);
8799
+ selectRef = useRef(null);
8757
8800
  }
8758
8801
 
8759
8802
  const [open, setOpen] = useState(false);
@@ -8774,6 +8817,7 @@ const SelectImpl = (props, ref) => {
8774
8817
  emptyText,
8775
8818
  rowHeight,
8776
8819
  menuHeight,
8820
+ menuTitle,
8777
8821
  menuPosition,
8778
8822
  label,
8779
8823
  labelPosition
@@ -8788,18 +8832,16 @@ const SelectImpl = (props, ref) => {
8788
8832
  return;
8789
8833
  }
8790
8834
 
8791
- if (isDefined(ref) && typeof ref === 'object' && 'current' in ref) {
8835
+ if (isDefined(selectRef) && typeof selectRef === 'object') {
8792
8836
  const {
8793
8837
  current
8794
- } = ref;
8838
+ } = selectRef;
8795
8839
 
8796
- if (isDefined(current) && 'contains' in current && current.contains(target)) {
8797
- return;
8840
+ if (isDefined(current) && !current.contains(target)) {
8841
+ closeMenu(props.value);
8798
8842
  }
8799
-
8800
- closeMenu(props.value);
8801
8843
  }
8802
- }, []);
8844
+ }, [props.value]);
8803
8845
 
8804
8846
  function getOptions() {
8805
8847
  if (isDefined(search)) {
@@ -8977,10 +9019,21 @@ const SelectImpl = (props, ref) => {
8977
9019
  }
8978
9020
 
8979
9021
  const classNames = ['select', className, open && 'open', is(invalid) && 'has-error'].filter(c => Boolean(c));
8980
- return jsxs(Container$1, Object.assign({
9022
+ /**
9023
+ * @TODO this is a hack to be able to use the ref in react-web-client
9024
+ * RWC uses styled-components < v4 and expects the ref to be passes as
9025
+ * "innerRef" not just "ref", but product-language uses > v4 and wants
9026
+ * to use ref. So for some components that need a ref, like this one
9027
+ * we will have to use a div and style it the old fashioned way until
9028
+ * we upgrade rwc's styled-components or drop rwc
9029
+ */
9030
+
9031
+ return jsxs("div", Object.assign({
9032
+ style: ContainerStyles({
9033
+ disabled
9034
+ }),
9035
+ ref: selectRef,
8981
9036
  className: classNames.join(' '),
8982
- disabled: disabled,
8983
- ref: ref,
8984
9037
  onKeyUp: onKeyUp,
8985
9038
  onKeyDown: onKeyDown
8986
9039
  }, {
@@ -9020,14 +9073,102 @@ const SelectImpl = (props, ref) => {
9020
9073
  menuComponent: menuComponent,
9021
9074
  emptyText: emptyText,
9022
9075
  rowHeight: rowHeight,
9076
+ menuTitle: menuTitle,
9023
9077
  menuHeight: menuHeight,
9024
9078
  menuPosition: menuPosition,
9025
9079
  onSelect: onOptionSelect
9026
9080
  })]
9027
9081
  }));
9028
9082
  };
9083
+
9029
9084
  const Select = forwardRef(SelectImpl);
9030
9085
 
9086
+ const MenuListFrame = /*#__PURE__*/styled.div.withConfig({
9087
+ displayName: "menu-list__MenuListFrame",
9088
+ componentId: "sxh4rn-0"
9089
+ })(["border:1px solid ", ";background-color:", ";position:absolute;width:100%;width:-moz-available;width:-webkit-fill-available;max-height:184px;overflow-y:auto;overflow-x:hidden;::-webkit-scrollbar{width:6px;height:8px;}::-webkit-scrollbar-thumb{border-radius:4px;background:", ";min-height:50px;}", ";"], Borders.Default.Subdued, Surface.Default.Default, Surface.Neutral.Default, shadowMd);
9090
+ const MenuRow = /*#__PURE__*/styled(SpaceBetween).withConfig({
9091
+ displayName: "menu-list__MenuRow",
9092
+ componentId: "sxh4rn-1"
9093
+ })([" border:none;text-align:left;padding:", ";margin:", " ", ";background-color:", ";border-radius:6px;i:first-child{align-self:start;margin-right:", ";}i:last-child{align-self:center;}&:first-of-type{margin-top:", ";}&:last-of-type{margin-bottom:", ";}&:hover{background-color:", ";}&:hover{background-color:", ";}&:active{background-color:", ";}"], Padding.s, Margin.none, Margin.xxs, props => is(props.active) ? Surface.Selected.Default : Surface.Default.Default, Margin.xs, Margin.xxs, Margin.xxs, Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Hover : Surface.Default.Hover, props => is(props.active) ? Surface.Selected.Pressed : Surface.Default.Pressed);
9094
+ const OptionLabel = /*#__PURE__*/styled(Label).withConfig({
9095
+ displayName: "menu-list__OptionLabel",
9096
+ componentId: "sxh4rn-2"
9097
+ })(["cursor:pointer;"]);
9098
+ const CheckedIcon = /*#__PURE__*/styled(IconMinor.Check).withConfig({
9099
+ displayName: "menu-list__CheckedIcon",
9100
+ componentId: "sxh4rn-3"
9101
+ })(["svg{path{fill:", "}}"], Icons.Highlight);
9102
+ const ValueWrapper = /*#__PURE__*/styled.div.withConfig({
9103
+ displayName: "menu-list__ValueWrapper",
9104
+ componentId: "sxh4rn-4"
9105
+ })(["width:100%;"]);
9106
+ const TitleRow = /*#__PURE__*/styled(Heading4).withConfig({
9107
+ displayName: "menu-list__TitleRow",
9108
+ componentId: "sxh4rn-5"
9109
+ })(["height:30px;margin:", " ", ";border-bottom:1px solid ", ";padding:", " ", " ", " ", ";"], Margin.none, Margin.xxs, Borders.Default.Subdued, Padding.s, Padding.none, Padding.none, Padding.s);
9110
+
9111
+ const Row = props => {
9112
+ const {
9113
+ index,
9114
+ options = [],
9115
+ handleClick
9116
+ } = props;
9117
+ const hasIcon = safeArray(options).some(option => isDefined(option['icon']));
9118
+ const currentValue = Array.isArray(props.value) && is(props.multi) ? props.value : [props.value];
9119
+ const option = options[index];
9120
+ return jsxs(MenuRow, Object.assign({
9121
+ className: "row",
9122
+ center: true,
9123
+ active: currentValue.some(val => equal(val, option.value)),
9124
+ onClick: () => handleClick(option)
9125
+ }, {
9126
+ children: [maybeRender(hasIcon, option['icon']), jsxs(ValueWrapper, {
9127
+ children: [jsx(OptionLabel, Object.assign({
9128
+ hasIcon: hasIcon
9129
+ }, {
9130
+ children: option.label
9131
+ })), maybeRender(option['helperText'], jsx(OptionLabel, Object.assign({
9132
+ subdued: true,
9133
+ hasIcon: hasIcon
9134
+ }, {
9135
+ children: option['helperText']
9136
+ })))]
9137
+ }), maybeRender(currentValue.some(val => equal(val, option.value)), jsx(CheckedIcon, {}))]
9138
+ }));
9139
+ };
9140
+
9141
+ const MenuList = props => {
9142
+ // eslint-disable-next-line no-null/no-null
9143
+ const list = useRef(null); // const { open, selectedIndex, rowHeight } = props
9144
+
9145
+ const handleClick = option => {
9146
+ const newValue = Array.isArray(props.value) && is(props.multi) ? [...props.value, option.value] : option.value;
9147
+ props.onSelect(newValue);
9148
+ };
9149
+ /**
9150
+ * @TODO
9151
+ * This doesnt work with the styled components that RWC uses, so I'll leave comented for now
9152
+ *useEffect(() => {
9153
+ * if(is(open) && isDefined(list.current) && isDefined(selectedIndex)) {
9154
+ * list.current.scrollTo(0, selectedIndex * (defaultTo(rowHeight, DEFAULT_ROW_HEIGHT)+4))
9155
+ * }
9156
+ *}, [open, list, selectedIndex, rowHeight])
9157
+ */
9158
+
9159
+
9160
+ return jsxs(MenuListFrame, Object.assign({
9161
+ ref: list
9162
+ }, {
9163
+ children: [maybeRender(props.menuTitle, jsx(TitleRow, {
9164
+ children: props.menuTitle
9165
+ })), safeArray(props.options).map((_, index) => jsx(Row, Object.assign({
9166
+ index: index,
9167
+ handleClick: handleClick
9168
+ }, props), index))]
9169
+ }));
9170
+ };
9171
+
9031
9172
  var apply = functionApply;
9032
9173
  var call = functionCall;
9033
9174
  var uncurryThis = functionUncurryThis;
@@ -9184,6 +9325,455 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
9184
9325
  ];
9185
9326
  }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
9186
9327
 
9328
+ var CheckboxState;
9329
+
9330
+ (function (CheckboxState) {
9331
+ CheckboxState[CheckboxState["UNCHECKED"] = 0] = "UNCHECKED";
9332
+ CheckboxState[CheckboxState["CHECKED"] = 1] = "CHECKED";
9333
+ CheckboxState[CheckboxState["INDETERMINATE"] = 2] = "INDETERMINATE";
9334
+ })(CheckboxState || (CheckboxState = {}));
9335
+
9336
+ const ListItem = /*#__PURE__*/styled.li.withConfig({
9337
+ displayName: "tree-node__ListItem",
9338
+ componentId: "sc-1wjf7p9-0"
9339
+ })(["& ol{margin-top:", ";}", ""], Margin.xs, ({
9340
+ disabled
9341
+ }) => is(disabled) && css(["opacity:.75;cursor:not-allowed;"]));
9342
+ const ItemWrapper = /*#__PURE__*/styled(Flex).withConfig({
9343
+ displayName: "tree-node__ItemWrapper",
9344
+ componentId: "sc-1wjf7p9-1"
9345
+ })(["align-items:center;padding:", " ", ";gap:8px;flex:none;order:0;align-self:stretch;flex-grow:0;"], Padding.xxxs, Padding.none);
9346
+ const ClickableLabel = /*#__PURE__*/styled(Label).withConfig({
9347
+ displayName: "tree-node__ClickableLabel",
9348
+ componentId: "sc-1wjf7p9-2"
9349
+ })(["cursor:pointer;&:hover{background:", ";}&:focus{outline:0;background:", ";}"], Surface.Default.Default, Surface.Default.Default);
9350
+ const CollapseButton = /*#__PURE__*/styled(Button).withConfig({
9351
+ displayName: "tree-node__CollapseButton",
9352
+ componentId: "sc-1wjf7p9-3"
9353
+ })(["align-self:baseline;top:10px;border:0;cursor:pointer;padding:", ";gap:0;width:8px;margin-left:auto;right:8px;&:active{outline:none;}"], Padding.none);
9354
+ const InputWrapper = /*#__PURE__*/styled(Flex).withConfig({
9355
+ displayName: "tree-node__InputWrapper",
9356
+ componentId: "sc-1wjf7p9-4"
9357
+ })(["gap:8px;"]);
9358
+ const HelpfulMessage$1 = /*#__PURE__*/styled(Label).withConfig({
9359
+ displayName: "tree-node__HelpfulMessage",
9360
+ componentId: "sc-1wjf7p9-5"
9361
+ })(["margin-left:", ";user-select:none;"], Margin.xl);
9362
+ const TreeNode = props => {
9363
+ const {
9364
+ value,
9365
+ label,
9366
+ expanded
9367
+ } = props;
9368
+
9369
+ const handleCheck = () => {
9370
+ const {
9371
+ onCheck
9372
+ } = props;
9373
+ onCheck({
9374
+ label,
9375
+ value,
9376
+ checked: getCheckState({
9377
+ toggle: true
9378
+ })
9379
+ });
9380
+ };
9381
+
9382
+ const handleClick = () => {
9383
+ const {
9384
+ onClick,
9385
+ isParent,
9386
+ expandDisabled
9387
+ } = props;
9388
+
9389
+ if (isParent && !expandDisabled) {
9390
+ handleOnExpand();
9391
+ }
9392
+
9393
+ onClick({
9394
+ label,
9395
+ value,
9396
+ checked: getCheckState({
9397
+ toggle: false
9398
+ })
9399
+ });
9400
+ };
9401
+
9402
+ const handleOnExpand = () => {
9403
+ const {
9404
+ onExpand
9405
+ } = props;
9406
+ onExpand({
9407
+ value,
9408
+ label,
9409
+ expanded: !is(expanded)
9410
+ });
9411
+ };
9412
+
9413
+ const getCheckState = ({
9414
+ toggle
9415
+ }) => {
9416
+ const {
9417
+ checkState
9418
+ } = props;
9419
+
9420
+ if (checkState === CheckboxState.UNCHECKED && toggle) {
9421
+ return true;
9422
+ }
9423
+
9424
+ if (checkState === CheckboxState.CHECKED && !toggle) {
9425
+ return true;
9426
+ }
9427
+
9428
+ if (checkState === CheckboxState.INDETERMINATE) {
9429
+ return true;
9430
+ }
9431
+
9432
+ return false;
9433
+ };
9434
+
9435
+ const renderCollapseButton = () => {
9436
+ const {
9437
+ expandDisabled,
9438
+ isParent
9439
+ } = props;
9440
+ return maybeRender(isParent, jsx(CollapseButton, {
9441
+ subtle: true,
9442
+ disabled: expandDisabled,
9443
+ onClick: handleOnExpand,
9444
+ IconSuffix: expanded ? IconMinor.ChevronUpSolid : IconMinor.ChevronDownSolid
9445
+ }));
9446
+ };
9447
+
9448
+ const renderCheckboxLabel = () => {
9449
+ const {
9450
+ checkState,
9451
+ disabled,
9452
+ treeId,
9453
+ childCount,
9454
+ isParent,
9455
+ invalid,
9456
+ showChildCount,
9457
+ helpfulMessage
9458
+ } = props;
9459
+ const inputId = `${treeId}-${String(value).split(' ').join('_')}`;
9460
+ const displayText = showChildCount && isParent ? `${label} (${childCount})` : label;
9461
+ return jsxs(React.Fragment, {
9462
+ children: [jsxs("div", {
9463
+ children: [jsxs(InputWrapper, Object.assign({
9464
+ center: true
9465
+ }, {
9466
+ children: [jsx(Checkbox, {
9467
+ checked: checkState === CheckboxState.CHECKED,
9468
+ indeterminate: checkState === CheckboxState.INDETERMINATE,
9469
+ disabled: disabled,
9470
+ error: invalid,
9471
+ id: `input-${inputId}`,
9472
+ onClick: handleCheck,
9473
+ onChange: () => void 0
9474
+ }), jsx(ClickableLabel, Object.assign({
9475
+ onClick: handleClick,
9476
+ role: "link",
9477
+ tabIndex: 0
9478
+ }, {
9479
+ children: displayText
9480
+ }), 1)]
9481
+ })), maybeRender(helpfulMessage, jsx(HelpfulMessage$1, Object.assign({
9482
+ subdued: true,
9483
+ id: `error-${inputId}`
9484
+ }, {
9485
+ children: helpfulMessage
9486
+ })))]
9487
+ }), renderCollapseButton()]
9488
+ });
9489
+ };
9490
+
9491
+ const {
9492
+ disabled
9493
+ } = props;
9494
+ return jsxs(ListItem, Object.assign({
9495
+ role: "treeitem",
9496
+ disabled: disabled
9497
+ }, {
9498
+ children: [jsx(ItemWrapper, Object.assign({
9499
+ center: true
9500
+ }, {
9501
+ children: renderCheckboxLabel()
9502
+ })), expanded && props.children]
9503
+ }));
9504
+ };
9505
+
9506
+ const flattenNodes = (flattenList, nodes, parent, depth = 0) => {
9507
+ safeArray(nodes).forEach((node, index) => {
9508
+ const isParent = nodeHasChildren(node);
9509
+ flattenList.push({
9510
+ label: node.label,
9511
+ value: node.value,
9512
+ children: node.children,
9513
+ parent,
9514
+ isChild: isDefined(parent) && isDefined(parent.value),
9515
+ isParent,
9516
+ isLeaf: !isParent,
9517
+ disabled: getDisabledState(node, parent),
9518
+ treeDepth: depth,
9519
+ index,
9520
+ checked: false,
9521
+ checkState: 0,
9522
+ expanded: false
9523
+ });
9524
+ flattenNodes(flattenList, safeArray(node.children), node, depth + 1);
9525
+ });
9526
+ };
9527
+ const getNode = (nodes, value) => {
9528
+ return nodes.find(node => node.value === value);
9529
+ };
9530
+
9531
+ const nodeHasChildren = node => {
9532
+ return isDefined(node.children) && Array.isArray(node.children);
9533
+ };
9534
+
9535
+ const getDisabledState = (node, parent) => {
9536
+ if (isDefined(parent) && is(parent.disabled)) {
9537
+ return true;
9538
+ }
9539
+
9540
+ return is(node.disabled);
9541
+ };
9542
+
9543
+ const deserializeList = (flatNodes, lists) => {
9544
+ flatNodes.forEach(flatNode => {
9545
+ if (lists.checked.includes(flatNode.value)) {
9546
+ flatNode.checked = true;
9547
+
9548
+ if (flatNode.isParent) {
9549
+ checkAllChildren(flatNodes, flatNode);
9550
+ }
9551
+ }
9552
+
9553
+ if (lists.expanded.includes(flatNode.value)) {
9554
+ flatNode.expanded = true;
9555
+ }
9556
+ });
9557
+ };
9558
+
9559
+ const checkAllChildren = (flatNodes, flatNode) => {
9560
+ defaultTo(flatNode.children, []).forEach(node => {
9561
+ const _flatoNode = getNode(flatNodes, node.value);
9562
+
9563
+ if (isDefined(_flatoNode)) {
9564
+ _flatoNode.checked = true;
9565
+ }
9566
+ });
9567
+ };
9568
+
9569
+ const serializeList = (flatNodes, key) => {
9570
+ const list = [];
9571
+ flatNodes.forEach(node => {
9572
+ if (key === 'expanded') {
9573
+ if (node.expanded) {
9574
+ list.push(node.value);
9575
+ }
9576
+ }
9577
+
9578
+ if (key === 'checked') {
9579
+ if (node.checked) {
9580
+ list.push(node.value);
9581
+ }
9582
+ }
9583
+ });
9584
+ return list;
9585
+ };
9586
+ const toggleChecked = (flatNodes, node, isChecked) => {
9587
+ const flatNode = getNode(flatNodes, node.value);
9588
+
9589
+ if (isNil(flatNode)) {
9590
+ return;
9591
+ }
9592
+
9593
+ if (flatNode.isLeaf) {
9594
+ if (is(node.disabled)) {
9595
+ return;
9596
+ }
9597
+
9598
+ toggleNode(flatNodes, node.value, 'checked', isChecked);
9599
+ } else {
9600
+ if (isDefined(flatNode.children) && flatNode.children.length === 0) {
9601
+ toggleNode(flatNodes, node.value, 'checked', isChecked);
9602
+ }
9603
+
9604
+ safeArray(flatNode.children).forEach(child => {
9605
+ toggleChecked(flatNodes, child, isChecked);
9606
+ });
9607
+ }
9608
+ };
9609
+ const toggleNode = (flatNodes, nodeValue, key, toggleValue) => {
9610
+ const node = flatNodes.find(_node => _node.value === nodeValue);
9611
+
9612
+ if (isDefined(node)) {
9613
+ key === 'checked' ? node.checked = toggleValue : node.expanded = toggleValue;
9614
+ }
9615
+ };
9616
+ const getNodeCheckState = (flattenNodeList, node) => {
9617
+ const flatNode = getNode(flattenNodeList, node.value);
9618
+
9619
+ if (is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.isLeaf) || isDefined(node.children) && node.children.length === 0) {
9620
+ return is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.checked) ? CheckboxState.CHECKED : CheckboxState.UNCHECKED;
9621
+ }
9622
+
9623
+ if (is(isEveryChildChecked(flattenNodeList, node))) {
9624
+ return CheckboxState.CHECKED;
9625
+ }
9626
+
9627
+ if (is(isSomeChildChecked(flattenNodeList, node))) {
9628
+ return CheckboxState.INDETERMINATE;
9629
+ }
9630
+
9631
+ return CheckboxState.UNCHECKED;
9632
+ };
9633
+
9634
+ const isEveryChildChecked = (flattenNodeList, node) => {
9635
+ return safeArray(node.children).every(child => {
9636
+ const _node = getNode(flattenNodeList, child.value);
9637
+
9638
+ return isDefined(_node) && _node.checkState === 1;
9639
+ });
9640
+ };
9641
+
9642
+ const isSomeChildChecked = (flattenNodeList, node) => {
9643
+ return safeArray(node.children).some(child => {
9644
+ const _node = getNode(flattenNodeList, child.value);
9645
+
9646
+ return isDefined(_node) && _node.checkState > 0;
9647
+ });
9648
+ };
9649
+
9650
+ const ParentNode = /*#__PURE__*/styled.ol.withConfig({
9651
+ displayName: "tree-view__ParentNode",
9652
+ componentId: "sc-4bkb59-0"
9653
+ })(["display:flex;flex-direction:column;gap:8px;margin:", ";padding-left:", ";list-style-type:none;& ol{padding-left:", ";}"], Margin.none, Padding.none, Padding.l);
9654
+ const Container$1 = /*#__PURE__*/styled.div.withConfig({
9655
+ displayName: "tree-view__Container",
9656
+ componentId: "sc-4bkb59-1"
9657
+ })(["display:block;margin:", ";padding:", ";"], Margin.none, Padding.none);
9658
+ const TreeView = props => {
9659
+ const {
9660
+ checkedList = [],
9661
+ expanded = [],
9662
+ title,
9663
+ nodes,
9664
+ className,
9665
+ showChildCount = false
9666
+ } = props;
9667
+ const [expandedList, setExpandedList] = useState(expanded);
9668
+ const treeId = new Date().getTime().toString();
9669
+ const flattenNodeList = useMemo(() => {
9670
+ const _nodeList = [];
9671
+ flattenNodes(_nodeList, nodes);
9672
+ deserializeList(_nodeList, {
9673
+ checked: checkedList,
9674
+ expanded: expandedList
9675
+ });
9676
+ return _nodeList;
9677
+ }, [nodes]);
9678
+
9679
+ const handleOnCheck = nodeInfo => {
9680
+ const {
9681
+ onCheck
9682
+ } = props;
9683
+ toggleChecked(flattenNodeList, nodeInfo, nodeInfo.checked);
9684
+
9685
+ if (isDefined(onCheck)) {
9686
+ onCheck(serializeList(flattenNodeList, 'checked'), Object.assign({}, nodeInfo));
9687
+ }
9688
+ };
9689
+
9690
+ const handleOnExpand = nodeInfo => {
9691
+ const {
9692
+ onExpand
9693
+ } = props;
9694
+ toggleNode(flattenNodeList, nodeInfo.value, 'expanded', nodeInfo.expanded);
9695
+
9696
+ if (isDefined(onExpand)) {
9697
+ onExpand(serializeList(flattenNodeList, 'expanded'), Object.assign({}, nodeInfo));
9698
+ }
9699
+
9700
+ setExpandedList(serializeList(flattenNodeList, 'expanded'));
9701
+ };
9702
+
9703
+ const onNodeClick = nodeInfo => {
9704
+ const {
9705
+ onClick
9706
+ } = props;
9707
+ const node = getNode(flattenNodeList, nodeInfo.value);
9708
+
9709
+ if (isDefined(onClick)) {
9710
+ onClick(Object.assign(Object.assign({}, node), nodeInfo));
9711
+ }
9712
+ };
9713
+
9714
+ const renderTreeNodes = (nodeList, parent) => {
9715
+ const {
9716
+ expandDisabled = false
9717
+ } = props;
9718
+ const treeNodes = nodeList.map(node => {
9719
+ var _a, _b;
9720
+
9721
+ const flatNode = getNode(flattenNodeList, node.value);
9722
+ const children = is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.isParent) ? renderTreeNodes(defaultTo(node.children, []), node) : jsx(Nothing, {}, node.value);
9723
+
9724
+ if (isDefined(flatNode)) {
9725
+ flatNode.checkState = getNodeCheckState(flattenNodeList, node);
9726
+ }
9727
+
9728
+ const parentExpanded = isDefined(parent) && isDefined(parent.value) ? (_a = getNode(flattenNodeList, parent.value)) === null || _a === void 0 ? void 0 : _a.expanded : true;
9729
+
9730
+ if (!is(parentExpanded)) {
9731
+ return jsx(Nothing, {}, node.value);
9732
+ }
9733
+
9734
+ return jsx(TreeNode, Object.assign({
9735
+ checkState: defaultTo(flatNode === null || flatNode === void 0 ? void 0 : flatNode.checkState, 0),
9736
+ disabled: is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.disabled),
9737
+ expandDisabled: expandDisabled,
9738
+ expanded: is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.expanded),
9739
+ label: node.label,
9740
+ isLeaf: is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.isLeaf),
9741
+ isParent: is(flatNode === null || flatNode === void 0 ? void 0 : flatNode.isParent),
9742
+ treeId: treeId,
9743
+ invalid: defaultTo(node.invalid, false),
9744
+ value: node.value,
9745
+ showChildCount: showChildCount,
9746
+ childCount: defaultTo((_b = flatNode === null || flatNode === void 0 ? void 0 : flatNode.children) === null || _b === void 0 ? void 0 : _b.length, 0),
9747
+ helpfulMessage: node.helpfulMessage,
9748
+ onClick: onNodeClick,
9749
+ onCheck: handleOnCheck,
9750
+ onExpand: handleOnExpand
9751
+ }, {
9752
+ children: children
9753
+ }), node.value);
9754
+ });
9755
+ return jsx(ParentNode, Object.assign({
9756
+ role: "tree",
9757
+ className: 'tree-view'
9758
+ }, {
9759
+ children: treeNodes
9760
+ }));
9761
+ };
9762
+
9763
+ return maybeRender(!isEmpty(nodes), jsx(Card, Object.assign({
9764
+ heading: title
9765
+ }, {
9766
+ children: jsx(Card.Section, {
9767
+ children: jsx(Container$1, Object.assign({
9768
+ className: className,
9769
+ id: treeId
9770
+ }, {
9771
+ children: renderTreeNodes(nodes)
9772
+ }))
9773
+ })
9774
+ })));
9775
+ };
9776
+
9187
9777
  // this file was generated, but it is safe to modify
9188
9778
 
9189
9779
  function toAvatarSize(n) {
@@ -9318,7 +9908,6 @@ const Wrapper = /*#__PURE__*/styled.label.withConfig({
9318
9908
  })(["display:flex;width:100%;align-items:center;"]);
9319
9909
  const InputCheckbox = props => {
9320
9910
  const {
9321
- onChange,
9322
9911
  label = ''
9323
9912
  } = props;
9324
9913
 
@@ -9328,11 +9917,6 @@ const InputCheckbox = props => {
9328
9917
 
9329
9918
  return jsxs(Wrapper, {
9330
9919
  children: [jsx(Checkbox, Object.assign({}, props, {
9331
- onChange: e => {
9332
- if (isDefined(onChange)) {
9333
- onChange(e.target.checked);
9334
- }
9335
- },
9336
9920
  name: isDefined(props.name) ? props.name : label
9337
9921
  })), jsx(Text, {
9338
9922
  children: label
@@ -9373,4 +9957,4 @@ const MultiChoiceList = props => {
9373
9957
  }));
9374
9958
  };
9375
9959
 
9376
- export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, Center, Checkbox, Display, Divider, Flag, Flex, Focused, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField, InputNumber, InputText, Interactive, LABEL, Label, LeftRightCard, Link, Margin, MultiChoiceList, Padding, Select, SelectImpl, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };
9960
+ export { Actions, AlertBanner, Avatar, BODY, BODY_LARGE, Background, Badge, Body, BodyLarge, Borders, Button, CAPTION, Caption, Card, Center, Checkbox, Display, Divider, Flag, Flex, Focused, HTMLAnchor, HTMLInput, Heading1, Heading2, Heading3, Heading4, Icon, IconMinor, Icons, InputCheckbox, InputField, InputNumber, InputText, Interactive, LABEL, Label, LeftRightCard, Link, Margin, MenuList, MultiChoiceList, Padding, Select, SpaceAround, SpaceBetween, Spinner, Surface, Tab$1 as Tab, Tabs, Tag, Text$1 as Text, Thumbnail, TreeView, Typography, _Typography, gridLayoutGenerator, leftRightLayoutGenerator, shadow, shadow2Xl, shadowInner, shadowLg, shadowMd, shadowSm, shadowXl };