playbook_ui 12.18.0.pre.alpha.play786multilevelselectimprovements627 → 12.19.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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +2 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +7 -22
- data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +5 -32
- data/app/pb_kits/playbook/pb_table/index.ts +6 -2
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +11 -10
- data/app/pb_kits/playbook/pb_tooltip/tooltip.test.jsx +29 -0
- data/app/pb_kits/playbook/tokens/_colors.scss +5 -3
- data/lib/playbook/version.rb +1 -1
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0f60bb863c6a7be595fe8ffcaa866a7796a0bb896732cf7ba5990d40444e6405
         | 
| 4 | 
            +
              data.tar.gz: a3e06332bf074ce75e69c35184fd624b26ee9bfd02efcfad057dbafbcac3c608
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c30ebfe71f1649440d65fda7871d6c6b4d11a0ced08299f38b5de90bd9f0c3108e3179e54fcbe3a064ef0b0411a11eb76382fcb9e464b2cc5c88e7c57224b33d
         | 
| 7 | 
            +
              data.tar.gz: dda14920f8aa81dc398a665fee7b51d4bbedf537669f297fe76b3f04df0b813b47229cff6e809571bf62bbaa00909e9956b6e77d1895e338a956b4d3bf6d947d
         | 
| @@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo } from "react"; | |
| 2 2 | 
             
            import classnames from "classnames";
         | 
| 3 3 | 
             
            import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
         | 
| 4 4 | 
             
            import { globalProps } from "../utilities/globalProps";
         | 
| 5 | 
            -
            import { findItemById, checkIt, unCheckIt | 
| 5 | 
            +
            import { findItemById, checkIt, unCheckIt } from "./helper_functions";
         | 
| 6 6 | 
             
            import MultiSelectHelper from "./_multi_select_helper";
         | 
| 7 7 |  | 
| 8 8 | 
             
            type MultiLevelSelectProps = {
         | 
| @@ -42,31 +42,17 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => { | |
| 42 42 | 
             
                const updatedData = formattedData.map((item: any) => {
         | 
| 43 43 | 
             
                  if (item.id === currentNode._id) {
         | 
| 44 44 | 
             
                    if (currentNode.checked) {
         | 
| 45 | 
            -
                      checkIt(item, selectedItems, setSelectedItems | 
| 45 | 
            +
                      checkIt(item, selectedItems, setSelectedItems);
         | 
| 46 46 | 
             
                    } else {
         | 
| 47 | 
            -
                      unCheckIt(item, selectedItems, setSelectedItems | 
| 47 | 
            +
                      unCheckIt(item, selectedItems, setSelectedItems);
         | 
| 48 48 | 
             
                    }
         | 
| 49 49 | 
             
                  } else if (item.children) {
         | 
| 50 50 | 
             
                    const foundItem = findItemById(item.children, currentNode._id);
         | 
| 51 51 | 
             
                    if (foundItem) {
         | 
| 52 52 | 
             
                      if (currentNode.checked) {
         | 
| 53 | 
            -
                        checkIt(foundItem, selectedItems, setSelectedItems | 
| 54 | 
            -
                        if (currentNode._parent) {
         | 
| 55 | 
            -
                          const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
         | 
| 56 | 
            -
                          parents.forEach((item:string) => {
         | 
| 57 | 
            -
                           const ancestor = findItemById(formattedData,item)
         | 
| 58 | 
            -
                           ancestor.expanded = true
         | 
| 59 | 
            -
                          });
         | 
| 60 | 
            -
                         }
         | 
| 53 | 
            +
                        checkIt(foundItem, selectedItems, setSelectedItems);
         | 
| 61 54 | 
             
                      } else {
         | 
| 62 | 
            -
                        unCheckIt(foundItem, selectedItems, setSelectedItems | 
| 63 | 
            -
                        if (currentNode._parent) {
         | 
| 64 | 
            -
                         const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
         | 
| 65 | 
            -
                         parents.forEach((item:string) => {
         | 
| 66 | 
            -
                          const ancestor = findItemById(formattedData,item)
         | 
| 67 | 
            -
                          ancestor.expanded = true
         | 
| 68 | 
            -
                         });
         | 
| 69 | 
            -
                        }
         | 
| 55 | 
            +
                        unCheckIt(foundItem, selectedItems, setSelectedItems);
         | 
| 70 56 | 
             
                      }
         | 
| 71 57 | 
             
                    }
         | 
| 72 58 | 
             
                  }
         | 
| @@ -106,18 +92,17 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => { | |
| 106 92 | 
             
                    treeData={formattedData}
         | 
| 107 93 | 
             
                    onChange={(
         | 
| 108 94 | 
             
                      // @ts-ignore
         | 
| 109 | 
            -
                      selectedNodes: { [key: string]: any }[],
         | 
| 95 | 
            +
                      selectedNodes: { [key: string]: any }[], 
         | 
| 110 96 | 
             
                      currentNode: { [key: string]: any }[]
         | 
| 111 97 | 
             
                    ) => {
         | 
| 112 98 | 
             
                      setCheckedData(currentNode);
         | 
| 113 99 | 
             
                      onSelect(currentNode);
         | 
| 114 | 
            -
             | 
| 115 100 | 
             
                    }}
         | 
| 116 101 | 
             
                    id={id}
         | 
| 117 102 | 
             
                    {...props}
         | 
| 118 103 | 
             
                  />
         | 
| 119 104 | 
             
                );
         | 
| 120 | 
            -
              }, [formattedData])
         | 
| 105 | 
            +
              }, [formattedData]);
         | 
| 121 106 |  | 
| 122 107 | 
             
              return (
         | 
| 123 108 | 
             
                <div {...ariaProps} {...dataProps} className={classes} id={id}>
         | 
| @@ -19,20 +19,19 @@ export const findItemById = ( | |
| 19 19 | 
             
            export const checkIt = (
         | 
| 20 20 | 
             
              foundItem: { [key: string]: any },
         | 
| 21 21 | 
             
              selectedItems: any[],
         | 
| 22 | 
            -
              setSelectedItems: Function | 
| 23 | 
            -
              expand: boolean
         | 
| 22 | 
            +
              setSelectedItems: Function
         | 
| 24 23 | 
             
            ) => {
         | 
| 25 24 | 
             
              if (!foundItem) {
         | 
| 26 25 | 
             
                return;
         | 
| 27 26 | 
             
              }
         | 
| 28 27 |  | 
| 29 28 | 
             
              foundItem.checked = true;
         | 
| 30 | 
            -
              foundItem.expanded =  | 
| 29 | 
            +
              foundItem.expanded = true;
         | 
| 31 30 | 
             
              selectedItems.push(foundItem);
         | 
| 32 31 |  | 
| 33 32 | 
             
              if (foundItem.children) {
         | 
| 34 33 | 
             
                foundItem.children.map((x: any) => {
         | 
| 35 | 
            -
                  checkIt(x, selectedItems, setSelectedItems | 
| 34 | 
            +
                  checkIt(x, selectedItems, setSelectedItems);
         | 
| 36 35 | 
             
                });
         | 
| 37 36 | 
             
              }
         | 
| 38 37 |  | 
| @@ -42,46 +41,20 @@ export const checkIt = ( | |
| 42 41 | 
             
            export const unCheckIt = (
         | 
| 43 42 | 
             
              foundItem: { [key: string]: any },
         | 
| 44 43 | 
             
              selectedItems: any,
         | 
| 45 | 
            -
              setSelectedItems: any | 
| 46 | 
            -
              expand: boolean
         | 
| 44 | 
            +
              setSelectedItems: any
         | 
| 47 45 | 
             
            ) => {
         | 
| 48 46 | 
             
              if (!foundItem) {
         | 
| 49 47 | 
             
                return;
         | 
| 50 48 | 
             
              }
         | 
| 51 49 |  | 
| 52 50 | 
             
              foundItem.checked = false;
         | 
| 53 | 
            -
              foundItem.expanded = false;
         | 
| 54 51 | 
             
              const newSelectedItems = selectedItems.filter(
         | 
| 55 52 | 
             
                (item: any) => item.id !== foundItem.id
         | 
| 56 53 | 
             
              );
         | 
| 57 54 | 
             
              if (foundItem.children) {
         | 
| 58 55 | 
             
                foundItem.children.map((x: any) => {
         | 
| 59 | 
            -
                  unCheckIt(x, selectedItems, setSelectedItems | 
| 56 | 
            +
                  unCheckIt(x, selectedItems, setSelectedItems);
         | 
| 60 57 | 
             
                });
         | 
| 61 58 | 
             
              }
         | 
| 62 59 | 
             
              setSelectedItems([...newSelectedItems]);
         | 
| 63 60 | 
             
            };
         | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
            export const getParentAndAncestorsIds = (itemId:string, items:{ [key: string]: string; }[], ancestors:string[] = []):any => {
         | 
| 67 | 
            -
              for (let i = 0; i < items.length; i++) {
         | 
| 68 | 
            -
                const item:any = items[i];
         | 
| 69 | 
            -
                if (item.id === itemId) {
         | 
| 70 | 
            -
                  // item found in current level of items array
         | 
| 71 | 
            -
                  return [...ancestors, item.id];
         | 
| 72 | 
            -
                }
         | 
| 73 | 
            -
                if (item.children && item.children.length > 0) {
         | 
| 74 | 
            -
                  // recursively search through children
         | 
| 75 | 
            -
                  const foundAncestors = getParentAndAncestorsIds(
         | 
| 76 | 
            -
                    itemId,
         | 
| 77 | 
            -
                    item.children,
         | 
| 78 | 
            -
                    [...ancestors, item.id]
         | 
| 79 | 
            -
                  );
         | 
| 80 | 
            -
                  if (foundAncestors) {
         | 
| 81 | 
            -
                    return foundAncestors;
         | 
| 82 | 
            -
                  }
         | 
| 83 | 
            -
                }
         | 
| 84 | 
            -
              }
         | 
| 85 | 
            -
              // item not found in this level of items array or its children
         | 
| 86 | 
            -
              return null;
         | 
| 87 | 
            -
            }
         | 
| @@ -11,8 +11,12 @@ export default class PbTable extends PbEnhancedElement { | |
| 11 11 | 
             
                // Each Table
         | 
| 12 12 | 
             
                [].forEach.call(tables, (table: HTMLTableElement) => {
         | 
| 13 13 | 
             
                  // Header Titles
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
             | 
| 14 | 
            +
                  let headers: string[] = [];
         | 
| 15 | 
            +
                  [].forEach.call(table.querySelectorAll('th'), (header: HTMLTableCellElement) => {
         | 
| 16 | 
            +
                    let colSpan = header.colSpan
         | 
| 17 | 
            +
                    for (let i = 0; i < colSpan; i++) {
         | 
| 18 | 
            +
                      headers.push(header.textContent.replace(/\r?\n|\r/, ''));
         | 
| 19 | 
            +
                    }
         | 
| 16 20 | 
             
                  });
         | 
| 17 21 |  | 
| 18 22 | 
             
                  // for each row in tbody
         | 
| @@ -6,7 +6,7 @@ import { | |
| 6 6 | 
             
              offset, 
         | 
| 7 7 | 
             
              Placement, 
         | 
| 8 8 | 
             
              safePolygon, 
         | 
| 9 | 
            -
              shift, | 
| 9 | 
            +
              shift,
         | 
| 10 10 | 
             
              useFloating, 
         | 
| 11 11 | 
             
              useHover, 
         | 
| 12 12 | 
             
              useInteractions,
         | 
| @@ -17,9 +17,6 @@ import { GlobalProps, globalProps } from "../utilities/globalProps" | |
| 17 17 | 
             
            import { buildAriaProps, buildDataProps } from "../utilities/props"
         | 
| 18 18 | 
             
            import Flex from "../pb_flex/_flex"
         | 
| 19 19 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 20 | 
             
            type TooltipProps = {
         | 
| 24 21 | 
             
              aria?: { [key: string]: string },
         | 
| 25 22 | 
             
              className?: string | string[],
         | 
| @@ -29,8 +26,8 @@ type TooltipProps = { | |
| 29 26 | 
             
              icon?: string,
         | 
| 30 27 | 
             
              interaction?: boolean,
         | 
| 31 28 | 
             
              placement?: Placement,
         | 
| 29 | 
            +
              position?: "absolute" | "fixed";
         | 
| 32 30 | 
             
              text: string,
         | 
| 33 | 
            -
              zIndex?: Pick<GlobalProps, "ZIndex">,
         | 
| 34 31 | 
             
            } & GlobalProps
         | 
| 35 32 |  | 
| 36 33 | 
             
            const Tooltip = (props: TooltipProps): React.ReactElement => {
         | 
| @@ -43,6 +40,7 @@ const Tooltip = (props: TooltipProps): React.ReactElement => { | |
| 43 40 | 
             
                icon = null,
         | 
| 44 41 | 
             
                interaction = false,
         | 
| 45 42 | 
             
                placement: preferredPlacement = "top",
         | 
| 43 | 
            +
                position = "absolute",
         | 
| 46 44 | 
             
                text,
         | 
| 47 45 | 
             
                zIndex,
         | 
| 48 46 | 
             
                ...rest
         | 
| @@ -50,24 +48,26 @@ const Tooltip = (props: TooltipProps): React.ReactElement => { | |
| 50 48 |  | 
| 51 49 | 
             
              const dataProps: { [key: string]: any } = buildDataProps(data)
         | 
| 52 50 | 
             
              const ariaProps: { [key: string]: any } = buildAriaProps(aria)
         | 
| 53 | 
            -
             | 
| 51 | 
            +
              
         | 
| 54 52 | 
             
              const css = classnames(
         | 
| 55 53 | 
             
                globalProps({...rest}),
         | 
| 56 54 | 
             
                className,
         | 
| 57 55 | 
             
              )
         | 
| 58 56 | 
             
              const [open, setOpen] = useState(false)
         | 
| 59 57 | 
             
              const arrowRef = useRef(null)
         | 
| 60 | 
            -
              const {
         | 
| 61 58 |  | 
| 59 | 
            +
             | 
| 60 | 
            +
              const {
         | 
| 62 61 | 
             
                context,
         | 
| 63 62 | 
             
                floating,
         | 
| 64 | 
            -
                middlewareData: { arrow: { x: arrowX, y: arrowY } = {} | 
| 63 | 
            +
                middlewareData: { arrow: { x: arrowX, y: arrowY } = {},  },
         | 
| 65 64 | 
             
                placement,
         | 
| 66 65 | 
             
                reference,
         | 
| 67 66 | 
             
                strategy,
         | 
| 68 67 | 
             
                x,
         | 
| 69 68 | 
             
                y,
         | 
| 70 69 | 
             
              } = useFloating({
         | 
| 70 | 
            +
                strategy: position,
         | 
| 71 71 | 
             
                middleware: [
         | 
| 72 72 | 
             
                  arrow({
         | 
| 73 73 | 
             
                    element: arrowRef,
         | 
| @@ -87,6 +87,7 @@ const Tooltip = (props: TooltipProps): React.ReactElement => { | |
| 87 87 | 
             
                placement: preferredPlacement
         | 
| 88 88 | 
             
              })
         | 
| 89 89 |  | 
| 90 | 
            +
             | 
| 90 91 | 
             
              const { getFloatingProps } = useInteractions([
         | 
| 91 92 | 
             
                useHover(context, {
         | 
| 92 93 | 
             
                  delay,
         | 
| @@ -142,7 +143,7 @@ const Tooltip = (props: TooltipProps): React.ReactElement => { | |
| 142 143 | 
             
                          className="arrow_bg"
         | 
| 143 144 | 
             
                          ref={arrowRef}
         | 
| 144 145 | 
             
                          style={{
         | 
| 145 | 
            -
                            position:  | 
| 146 | 
            +
                            position: "absolute",
         | 
| 146 147 | 
             
                            left: arrowX != null ? `${arrowX}px` : "",
         | 
| 147 148 | 
             
                            top: arrowY != null ? `${arrowY}px` : "",
         | 
| 148 149 | 
             
                            [staticSide]: "-5px",
         | 
| @@ -154,4 +155,4 @@ const Tooltip = (props: TooltipProps): React.ReactElement => { | |
| 154 155 | 
             
              )
         | 
| 155 156 | 
             
            }
         | 
| 156 157 |  | 
| 157 | 
            -
            export default Tooltip
         | 
| 158 | 
            +
            export default Tooltip
         | 
| @@ -65,3 +65,32 @@ test("closes on mouseleave", async () => { | |
| 65 65 |  | 
| 66 66 | 
             
              cleanup();
         | 
| 67 67 | 
             
            });
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            test("has default position absolute", async () => {
         | 
| 70 | 
            +
              render(<TooltipTest />);
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              fireEvent.mouseEnter(screen.getByRole("tooltip_trigger"));
         | 
| 73 | 
            +
              await waitFor(() => {
         | 
| 74 | 
            +
                expect(screen.queryByRole("tooltip")).toHaveStyle({"position": "absolute"});
         | 
| 75 | 
            +
                cleanup();
         | 
| 76 | 
            +
              })
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              cleanup();
         | 
| 79 | 
            +
            });
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            test("has position fixed", async () => {
         | 
| 82 | 
            +
              render(
         | 
| 83 | 
            +
                <Tooltip
         | 
| 84 | 
            +
                    data={{ testid: "fixed-position-test" }}
         | 
| 85 | 
            +
                    position="fixed"
         | 
| 86 | 
            +
                />
         | 
| 87 | 
            +
              );
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              fireEvent.mouseEnter(screen.getByRole("tooltip_trigger"));
         | 
| 90 | 
            +
              await waitFor(() => {
         | 
| 91 | 
            +
                expect(screen.queryByRole("tooltip")).toHaveStyle({"position": "fixed"});
         | 
| 92 | 
            +
                cleanup();
         | 
| 93 | 
            +
              })
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              cleanup();
         | 
| 96 | 
            +
            });
         | 
| @@ -68,7 +68,7 @@ $background_colors: ( | |
| 68 68 |  | 
| 69 69 | 
             
            /* Card colors ------------------*/
         | 
| 70 70 | 
             
            $card_light:          $white !default;
         | 
| 71 | 
            -
            $card_dark:            | 
| 71 | 
            +
            $card_dark:           mix(white, $bg_dark, 10%)  !default;
         | 
| 72 72 | 
             
            $card_colors: (
         | 
| 73 73 | 
             
              card_light:         $card_light,
         | 
| 74 74 | 
             
              card_dark:          $card_dark
         | 
| @@ -109,16 +109,18 @@ $focus_input_colors: ( | |
| 109 109 |  | 
| 110 110 | 
             
            /* Border colors ----------------------*/
         | 
| 111 111 | 
             
            $border_light:        #E4E8F0 !default;
         | 
| 112 | 
            -
            $border_dark:          | 
| 112 | 
            +
            $border_dark:         mix(white, $bg_dark, 20%) !default;
         | 
| 113 113 | 
             
            $border_colors: (
         | 
| 114 114 | 
             
              border_light:       $border_light,
         | 
| 115 115 | 
             
              border_dark:        $border_dark
         | 
| 116 116 | 
             
            );
         | 
| 117 117 |  | 
| 118 118 | 
             
            /* Shadow colors ----------------------*/
         | 
| 119 | 
            -
            $shadow: | 
| 119 | 
            +
            $shadow:             rgba(#3C6AAC, $opacity_2) !default;
         | 
| 120 | 
            +
            $shadow_dark:        $bg_dark !default;
         | 
| 120 121 | 
             
            $shadow_colors: (
         | 
| 121 122 | 
             
              shadow:       $shadow,
         | 
| 123 | 
            +
              shadow_dark:       $shadow_dark,
         | 
| 122 124 | 
             
            );
         | 
| 123 125 |  | 
| 124 126 | 
             
            /* Text colors ------------------------*/
         | 
    
        data/lib/playbook/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,12 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: playbook_ui
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 12. | 
| 4 | 
            +
              version: 12.19.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Power UX
         | 
| 8 8 | 
             
            - Power Devs
         | 
| 9 | 
            -
            autorequire: | 
| 9 | 
            +
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 | 
             
            date: 2023-05-09 00:00:00.000000000 Z
         | 
| @@ -2485,7 +2485,7 @@ homepage: http://playbook.powerapp.cloud | |
| 2485 2485 | 
             
            licenses:
         | 
| 2486 2486 | 
             
            - ISC
         | 
| 2487 2487 | 
             
            metadata: {}
         | 
| 2488 | 
            -
            post_install_message: | 
| 2488 | 
            +
            post_install_message:
         | 
| 2489 2489 | 
             
            rdoc_options: []
         | 
| 2490 2490 | 
             
            require_paths:
         | 
| 2491 2491 | 
             
            - lib
         | 
| @@ -2496,12 +2496,12 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 2496 2496 | 
             
                  version: '0'
         | 
| 2497 2497 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 2498 2498 | 
             
              requirements:
         | 
| 2499 | 
            -
              - - " | 
| 2499 | 
            +
              - - ">="
         | 
| 2500 2500 | 
             
                - !ruby/object:Gem::Version
         | 
| 2501 | 
            -
                  version:  | 
| 2501 | 
            +
                  version: '0'
         | 
| 2502 2502 | 
             
            requirements: []
         | 
| 2503 2503 | 
             
            rubygems_version: 3.3.7
         | 
| 2504 | 
            -
            signing_key: | 
| 2504 | 
            +
            signing_key:
         | 
| 2505 2505 | 
             
            specification_version: 4
         | 
| 2506 2506 | 
             
            summary: Playbook Design System
         | 
| 2507 2507 | 
             
            test_files: []
         |