@mrshmllw/smores-react 14.1.1 → 14.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/Accordion/Accordion.js +5 -3
  2. package/dist/Accordion/Accordion.js.map +1 -1
  3. package/dist/ActionDropdown/ActionDropdown.js +6 -2
  4. package/dist/ActionDropdown/ActionDropdown.js.map +1 -1
  5. package/dist/Alert/Alert.js +9 -8
  6. package/dist/Alert/Alert.js.map +1 -1
  7. package/dist/Banner/BannerItem.js +8 -2
  8. package/dist/Banner/BannerItem.js.map +1 -1
  9. package/dist/Banner/types.d.ts +3 -1
  10. package/dist/Banner/types.js.map +1 -1
  11. package/dist/Box/index.d.ts +1 -0
  12. package/dist/Box/index.js.map +1 -1
  13. package/dist/Button/Button.d.ts +2 -1
  14. package/dist/Button/Button.js +5 -3
  15. package/dist/Button/Button.js.map +1 -1
  16. package/dist/Card/Card.d.ts +2 -16
  17. package/dist/Card/Card.js +7 -4
  18. package/dist/Card/Card.js.map +1 -1
  19. package/dist/Chip/Chip.d.ts +2 -1
  20. package/dist/Chip/Chip.js +11 -3
  21. package/dist/Chip/Chip.js.map +1 -1
  22. package/dist/CurrencyInput/CurrencyInput.js +6 -3
  23. package/dist/CurrencyInput/CurrencyInput.js.map +1 -1
  24. package/dist/Datepicker/Datepicker.js +7 -4
  25. package/dist/Datepicker/Datepicker.js.map +1 -1
  26. package/dist/Dropdown/Dropdown.d.ts +3 -2
  27. package/dist/Dropdown/Dropdown.js +11 -7
  28. package/dist/Dropdown/Dropdown.js.map +1 -1
  29. package/dist/Dropdown/index.d.ts +1 -1
  30. package/dist/Dropdown/index.js.map +1 -1
  31. package/dist/Icon/Icon.js +5 -0
  32. package/dist/Icon/Icon.js.map +1 -1
  33. package/dist/Icon/index.d.ts +1 -0
  34. package/dist/Icon/index.js.map +1 -1
  35. package/dist/IconStrict/IconStrict.d.ts +1 -1
  36. package/dist/IconStrict/IconStrict.js +5 -0
  37. package/dist/IconStrict/IconStrict.js.map +1 -1
  38. package/dist/IconWrapper/IconWrapper.d.ts +1 -1
  39. package/dist/IconWrapper/IconWrapper.js.map +1 -1
  40. package/dist/Link/Link.d.ts +2 -1
  41. package/dist/Link/Link.js +7 -2
  42. package/dist/Link/Link.js.map +1 -1
  43. package/dist/Modal/Modal.js +12 -3
  44. package/dist/Modal/Modal.js.map +1 -1
  45. package/dist/NumberInput/NumberInput.js +11 -6
  46. package/dist/NumberInput/NumberInput.js.map +1 -1
  47. package/dist/Pagination/Pagination.js +5 -3
  48. package/dist/Pagination/Pagination.js.map +1 -1
  49. package/dist/ProgressIndicator/components/StepItem.js +6 -3
  50. package/dist/ProgressIndicator/components/StepItem.js.map +1 -1
  51. package/dist/RadioGroup/RadioGroup.d.ts +3 -2
  52. package/dist/RadioGroup/RadioGroup.js +1 -1
  53. package/dist/RadioGroup/RadioGroup.js.map +1 -1
  54. package/dist/RadioGroup/RadioItem.d.ts +3 -2
  55. package/dist/RadioGroup/RadioItem.js +7 -2
  56. package/dist/RadioGroup/RadioItem.js.map +1 -1
  57. package/dist/RichText/RichText.js +4 -2
  58. package/dist/RichText/RichText.js.map +1 -1
  59. package/dist/RichTextEditor/plugins/ToolbarPlugin.js +7 -5
  60. package/dist/RichTextEditor/plugins/ToolbarPlugin.js.map +1 -1
  61. package/dist/Row/Row.d.ts +4 -2
  62. package/dist/Row/Row.js +8 -3
  63. package/dist/Row/Row.js.map +1 -1
  64. package/dist/SearchInput/SearchInput.d.ts +0 -9
  65. package/dist/SearchInput/SearchInput.js +11 -6
  66. package/dist/SearchInput/SearchInput.js.map +1 -1
  67. package/dist/Snackbar/SnackbarItem.js +8 -3
  68. package/dist/Snackbar/SnackbarItem.js.map +1 -1
  69. package/dist/Snackbar/types.d.ts +2 -1
  70. package/dist/Snackbar/types.js.map +1 -1
  71. package/dist/SupportMessage/SupportMessage.js +11 -10
  72. package/dist/SupportMessage/SupportMessage.js.map +1 -1
  73. package/dist/Table/index.d.ts +1 -0
  74. package/dist/Table/index.js.map +1 -1
  75. package/dist/Tag/Tag.d.ts +3 -2
  76. package/dist/Tag/Tag.js +4 -2
  77. package/dist/Tag/Tag.js.map +1 -1
  78. package/dist/Tag/Tag.spec.js +10 -0
  79. package/dist/Tag/Tag.spec.js.map +1 -1
  80. package/dist/TextInput/TextInput.js +8 -4
  81. package/dist/TextInput/TextInput.js.map +1 -1
  82. package/dist/ThemeProvider/utils/colourMap.d.ts +2 -8
  83. package/dist/ThemeProvider/utils/colourMap.js.map +1 -1
  84. package/dist/fields/commonFieldTypes.d.ts +3 -1
  85. package/dist/fields/commonFieldTypes.js.map +1 -1
  86. package/dist/fields/components/CommonInput.d.ts +10 -2
  87. package/dist/fields/components/CommonInput.js +16 -0
  88. package/dist/fields/components/CommonInput.js.map +1 -1
  89. package/dist/index.d.ts +2 -0
  90. package/dist/index.js +2 -0
  91. package/dist/index.js.map +1 -1
  92. package/dist/sharedStyles/shared.styles.d.ts +5 -0
  93. package/dist/sharedStyles/shared.styles.js +22 -0
  94. package/dist/sharedStyles/shared.styles.js.map +1 -0
  95. package/dist/types.d.ts +7 -0
  96. package/dist/types.js.map +1 -1
  97. package/dist/utils/deprecated.js +8 -2
  98. package/dist/utils/deprecated.js.map +1 -1
  99. package/dist/utils/flex.d.ts +4 -1
  100. package/dist/utils/flex.js +4 -4
  101. package/dist/utils/flex.js.map +1 -1
  102. package/dist/utils/space.d.ts +12 -5
  103. package/dist/utils/space.js +31 -21
  104. package/dist/utils/space.js.map +1 -1
  105. package/package.json +30 -27
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarPlugin.js","sourceRoot":"","sources":["../../../src/RichTextEditor/plugins/ToolbarPlugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEhE,OAAO,EACL,WAAW,EACX,6BAA6B,EAC7B,QAAQ,EACR,mBAAmB,GACpB,MAAM,eAAe,C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CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI;;;;;;;wBAOlD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM;;CAE7E,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;yBAYL,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;;;;yBAI7C,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;;CAErE,CAAA","sourcesContent":["import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'\nimport { MouseEvent } from 'react'\nimport {\n $isListNode,\n INSERT_UNORDERED_LIST_COMMAND,\n ListNode,\n REMOVE_LIST_COMMAND,\n} from '@lexical/list'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $isHeadingNode } from '@lexical/rich-text'\nimport { $isAtNodeEnd } from '@lexical/selection'\nimport { $getNearestNodeOfType, mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n CAN_REDO_COMMAND,\n CAN_UNDO_COMMAND,\n FORMAT_TEXT_COMMAND,\n RangeSelection,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport styled from 'styled-components'\nimport { Box } from '../../Box'\nimport { Icon } from '../../Icon'\n\nconst LowPriority = 1\n\nfunction getSelectedNode(selection: RangeSelection) {\n const anchor = selection.anchor\n const focus = selection.focus\n const anchorNode = selection.anchor.getNode()\n const focusNode = selection.focus.getNode()\n if (anchorNode === focusNode) {\n return anchorNode\n }\n const isBackward = selection.isBackward()\n if (isBackward) {\n return $isAtNodeEnd(focus) ? anchorNode : focusNode\n } else {\n return $isAtNodeEnd(anchor) ? focusNode : anchorNode\n }\n}\n\nexport default function ToolbarPlugin() {\n const [editor] = useLexicalComposerContext()\n const toolbarRef = useRef(null)\n const [blockType, setBlockType] = useState('paragraph')\n const [isLink, setIsLink] = useState(false)\n const [isBold, setIsBold] = useState(false)\n const [isItalic, setIsItalic] = useState(false)\n const [linkURL, setLinkURL] = useState('')\n const [prevLinkURL, setPrevLinkURL] = useState('')\n\n const formatBulletList = () => {\n if (blockType !== 'ul') {\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)\n }\n }\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode()\n const element =\n anchorNode.getKey() === 'root'\n ? anchorNode\n : anchorNode.getTopLevelElementOrThrow()\n const elementKey = element.getKey()\n const elementDOM = editor.getElementByKey(elementKey)\n if (elementDOM !== null) {\n if ($isListNode(element)) {\n const parentList = $getNearestNodeOfType(anchorNode, ListNode)\n const type = parentList ? parentList.getTag() : element.getTag()\n setBlockType(type)\n } else {\n const type = $isHeadingNode(element)\n ? element.getTag()\n : element.getType()\n setBlockType(type)\n }\n }\n // Update text format\n setIsBold(selection.hasFormat('bold'))\n setIsItalic(selection.hasFormat('italic'))\n\n // Update links\n const node = getSelectedNode(selection)\n const parent = node.getParent()\n if ($isLinkNode(parent)) {\n setIsLink(true)\n setLinkURL(parent.getURL())\n } else if ($isLinkNode(node)) {\n setIsLink(true)\n setLinkURL(node.getURL())\n } else {\n setIsLink(false)\n setLinkURL('')\n }\n }\n }, [editor])\n\n const openNewWindow = (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n try {\n window.open(linkURL, '_blank')\n } catch (error) {\n console.warn('Failed to open invalid URL: ', error)\n }\n }\n\n const urlInputRef = useRef<HTMLInputElement | null>(null)\n\n useEffect(() => {\n if (prevLinkURL !== '' && isLink && urlInputRef.current) {\n urlInputRef.current.focus()\n }\n setPrevLinkURL(linkURL)\n }, [linkURL])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar()\n })\n }),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateToolbar()\n return false\n },\n LowPriority,\n ),\n editor.registerCommand(\n CAN_UNDO_COMMAND,\n () => {\n return false\n },\n LowPriority,\n ),\n editor.registerCommand(\n CAN_REDO_COMMAND,\n () => {\n return false\n },\n LowPriority,\n ),\n )\n }, [editor, updateToolbar])\n\n return (\n <Toolbar className=\"toolbar\" ref={toolbarRef}>\n <Bold\n onClick={() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')\n }}\n $active={isBold}\n >\n B\n </Bold>\n <Italic\n onClick={() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')\n }}\n $active={isItalic}\n >\n i\n </Italic>\n <EditorButton\n $active={blockType === 'ul'}\n onClick={() => formatBulletList()}\n >\n <Icon render=\"bullets\" />\n </EditorButton>\n\n <Link\n $active={isLink}\n onClick={() =>\n !isLink\n ? editor.dispatchCommand(TOGGLE_LINK_COMMAND, 'https://')\n : editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }\n >\n <Box ml={{ custom: '-4px' }}>\n <Icon render=\"link\" />\n </Box>\n <LinkInput\n tabIndex={-1}\n ref={urlInputRef}\n placeholder=\"Enter url\"\n value={linkURL}\n onChange={(e) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, e.target.value)\n }}\n onClick={(e) => e.stopPropagation()}\n />\n <Box onClick={openNewWindow}>\n <LinkOpen render=\"new-window\" />\n </Box>\n </Link>\n </Toolbar>\n )\n}\n\nconst EditorButton = styled(Box)<{ $active: boolean }>`\n height: 40px;\n width: 40px;\n line-height: 50px;\n padding: 12px;\n border-radius: 25px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 24px;\n cursor: pointer;\n background-color: ${({ theme }) => theme.color.surface.base[300]};\n flex-shrink: 0;\n\n ${({ $active, theme }) =>\n $active &&\n `\n background-color: ${theme.color.interactive.primary.hover};\n `}\n`\n\nconst Bold = styled(EditorButton)`\n font-weight: 500;\n`\n\nconst Italic = styled(EditorButton)`\n font-style: italic;\n font-weight: 500;\n text-indent: -4px;\n`\n\nconst Toolbar = styled(Box)`\n display: flex;\n flex-direction: row;\n gap: 8px;\n`\n\nconst Link = styled(EditorButton)`\n transition: width 0.3s;\n ${({ $active }) => $active && `width: 360px;`}\n justify-content: left;\n overflow: hidden;\n gap: 12px;\n padding-right: 5px;\n flex-shrink: 1;\n\n ${({ $active, theme }) =>\n $active &&\n `\n background-color: ${theme.color.interactive.primary.hover};\n\n :hover {\n filter: none;\n }\n `}\n`\n\nconst LinkOpen = styled(Icon)`\n background-color: ${({ theme }) => theme.color.interactive.tertiary.base};\n height: 32px;\n width: 32px;\n border-radius: 20px;\n padding: 6px;\n\n :hover {\n background-color: ${({ theme }) => theme.color.interactive.tertiary.active};\n }\n`\n\nconst LinkInput = styled.input`\n width: inherit;\n height: 32px;\n border: none;\n border-radius: 20px;\n padding-left: 12px;\n padding-right: 12px;\n font-size: 16px;\n min-width: 0;\n background-color: white;\n\n :hover {\n outline: 2px solid ${({ theme }) => theme.color.surface.brand[200]};\n }\n\n :focus {\n outline: 2px solid ${({ theme }) => theme.color.surface.brand[300]};\n }\n`\n"]}
1
+ {"version":3,"file":"ToolbarPlugin.js","sourceRoot":"","sources":["../../../src/RichTextEditor/plugins/ToolbarPlugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEhE,OAAO,EACL,WAAW,EACX,6BAA6B,EAC7B,QAAQ,EACR,mBAAmB,GACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA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,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK;;;;;GAK1D;CACF,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;sBAChB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI;;;;;;;wBAOlD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM;;CAE7E,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;;;;;;yBAYL,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;;;;yBAI7C,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;;CAErE,CAAA","sourcesContent":["import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link'\nimport { MouseEvent } from 'react'\nimport {\n $isListNode,\n INSERT_UNORDERED_LIST_COMMAND,\n ListNode,\n REMOVE_LIST_COMMAND,\n} from '@lexical/list'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $isHeadingNode } from '@lexical/rich-text'\nimport { $isAtNodeEnd } from '@lexical/selection'\nimport { $getNearestNodeOfType, mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n CAN_REDO_COMMAND,\n CAN_UNDO_COMMAND,\n FORMAT_TEXT_COMMAND,\n RangeSelection,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport styled from 'styled-components'\nimport { Box } from '../../Box'\nimport { IconContainer } from '../../sharedStyles/shared.styles'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport {\n faArrowUpRightFromSquare,\n faLinkSimple,\n faList,\n} from '@awesome.me/kit-46ca99185c/icons/classic/regular'\n\nconst LowPriority = 1\n\nfunction getSelectedNode(selection: RangeSelection) {\n const anchor = selection.anchor\n const focus = selection.focus\n const anchorNode = selection.anchor.getNode()\n const focusNode = selection.focus.getNode()\n if (anchorNode === focusNode) {\n return anchorNode\n }\n const isBackward = selection.isBackward()\n if (isBackward) {\n return $isAtNodeEnd(focus) ? anchorNode : focusNode\n } else {\n return $isAtNodeEnd(anchor) ? focusNode : anchorNode\n }\n}\n\nexport default function ToolbarPlugin() {\n const [editor] = useLexicalComposerContext()\n const toolbarRef = useRef(null)\n const [blockType, setBlockType] = useState('paragraph')\n const [isLink, setIsLink] = useState(false)\n const [isBold, setIsBold] = useState(false)\n const [isItalic, setIsItalic] = useState(false)\n const [linkURL, setLinkURL] = useState('')\n const [prevLinkURL, setPrevLinkURL] = useState('')\n\n const formatBulletList = () => {\n if (blockType !== 'ul') {\n editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)\n } else {\n editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)\n }\n }\n\n const updateToolbar = useCallback(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode()\n const element =\n anchorNode.getKey() === 'root'\n ? anchorNode\n : anchorNode.getTopLevelElementOrThrow()\n const elementKey = element.getKey()\n const elementDOM = editor.getElementByKey(elementKey)\n if (elementDOM !== null) {\n if ($isListNode(element)) {\n const parentList = $getNearestNodeOfType(anchorNode, ListNode)\n const type = parentList ? parentList.getTag() : element.getTag()\n setBlockType(type)\n } else {\n const type = $isHeadingNode(element)\n ? element.getTag()\n : element.getType()\n setBlockType(type)\n }\n }\n // Update text format\n setIsBold(selection.hasFormat('bold'))\n setIsItalic(selection.hasFormat('italic'))\n\n // Update links\n const node = getSelectedNode(selection)\n const parent = node.getParent()\n if ($isLinkNode(parent)) {\n setIsLink(true)\n setLinkURL(parent.getURL())\n } else if ($isLinkNode(node)) {\n setIsLink(true)\n setLinkURL(node.getURL())\n } else {\n setIsLink(false)\n setLinkURL('')\n }\n }\n }, [editor])\n\n const openNewWindow = (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation()\n try {\n window.open(linkURL, '_blank')\n } catch (error) {\n console.warn('Failed to open invalid URL: ', error)\n }\n }\n\n const urlInputRef = useRef<HTMLInputElement | null>(null)\n\n useEffect(() => {\n if (prevLinkURL !== '' && isLink && urlInputRef.current) {\n urlInputRef.current.focus()\n }\n setPrevLinkURL(linkURL)\n }, [linkURL])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateToolbar()\n })\n }),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateToolbar()\n return false\n },\n LowPriority,\n ),\n editor.registerCommand(\n CAN_UNDO_COMMAND,\n () => {\n return false\n },\n LowPriority,\n ),\n editor.registerCommand(\n CAN_REDO_COMMAND,\n () => {\n return false\n },\n LowPriority,\n ),\n )\n }, [editor, updateToolbar])\n\n return (\n <Toolbar className=\"toolbar\" ref={toolbarRef}>\n <Bold\n onClick={() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')\n }}\n $active={isBold}\n >\n B\n </Bold>\n <Italic\n onClick={() => {\n editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')\n }}\n $active={isItalic}\n >\n i\n </Italic>\n <EditorButton\n $active={blockType === 'ul'}\n onClick={() => formatBulletList()}\n >\n <IconContainer $size={24}>\n <FontAwesomeIcon icon={faList} />\n </IconContainer>\n </EditorButton>\n\n <Link\n $active={isLink}\n onClick={() =>\n !isLink\n ? editor.dispatchCommand(TOGGLE_LINK_COMMAND, 'https://')\n : editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }\n >\n <Box ml={{ custom: '-4px' }} mt={{ custom: '6px' }}>\n <IconContainer $size={24}>\n <FontAwesomeIcon icon={faLinkSimple} />\n </IconContainer>\n </Box>\n <LinkInput\n tabIndex={-1}\n ref={urlInputRef}\n placeholder=\"Enter url\"\n value={linkURL}\n onChange={(e) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, e.target.value)\n }}\n onClick={(e) => e.stopPropagation()}\n />\n <Box onClick={openNewWindow}>\n <LinkOpen $size={24}>\n <FontAwesomeIcon icon={faArrowUpRightFromSquare} />\n </LinkOpen>\n </Box>\n </Link>\n </Toolbar>\n )\n}\n\nconst EditorButton = styled(Box)<{ $active: boolean }>`\n height: 40px;\n width: 40px;\n line-height: 50px;\n padding: 12px;\n border-radius: 25px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 24px;\n cursor: pointer;\n background-color: ${({ theme }) => theme.color.surface.base[300]};\n flex-shrink: 0;\n\n ${({ $active, theme }) =>\n $active &&\n `\n background-color: ${theme.color.interactive.primary.hover};\n `}\n`\n\nconst Bold = styled(EditorButton)`\n font-weight: 500;\n`\n\nconst Italic = styled(EditorButton)`\n font-style: italic;\n font-weight: 500;\n text-indent: -4px;\n`\n\nconst Toolbar = styled(Box)`\n display: flex;\n flex-direction: row;\n gap: 8px;\n`\n\nconst Link = styled(EditorButton)`\n transition: width 0.3s;\n ${({ $active }) => $active && `width: 360px;`}\n justify-content: left;\n overflow: hidden;\n gap: 12px;\n padding-right: 5px;\n flex-shrink: 1;\n\n ${({ $active, theme }) =>\n $active &&\n `\n background-color: ${theme.color.interactive.primary.hover};\n\n :hover {\n filter: none;\n }\n `}\n`\n\nconst LinkOpen = styled(IconContainer)`\n background-color: ${({ theme }) => theme.color.interactive.tertiary.base};\n height: 32px;\n width: 32px;\n border-radius: 20px;\n padding: 6px;\n\n :hover {\n background-color: ${({ theme }) => theme.color.interactive.tertiary.active};\n }\n`\n\nconst LinkInput = styled.input`\n width: inherit;\n height: 32px;\n border: none;\n border-radius: 20px;\n padding-left: 12px;\n padding-right: 12px;\n font-size: 16px;\n min-width: 0;\n background-color: white;\n\n :hover {\n outline: 2px solid ${({ theme }) => theme.color.surface.brand[200]};\n }\n\n :focus {\n outline: 2px solid ${({ theme }) => theme.color.surface.brand[300]};\n }\n`\n"]}
package/dist/Row/Row.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { FC } from 'react';
2
- import { Icons } from '../Icon/iconsList';
1
+ import { FC, ReactNode } from 'react';
2
+ import { Icons } from '../Icon';
3
3
  import { MarginProps } from '../utils/space';
4
4
  import { ColorTypes } from '../ThemeProvider/utils/colourMap';
5
5
  export type RowProps = {
6
6
  iconLeft?: Icons;
7
+ iconLeftComponent?: ReactNode;
7
8
  iconLeftColor?: ColorTypes;
8
9
  iconRight?: Icons;
9
10
  iconRightColor?: ColorTypes;
11
+ iconRightComponent?: ReactNode;
10
12
  handleClick?: () => void;
11
13
  heading: string;
12
14
  subHeading?: string;
package/dist/Row/Row.js CHANGED
@@ -1,11 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled, { css } from 'styled-components';
2
+ import styled, { css, useTheme } from 'styled-components';
3
3
  import { Box } from '../Box';
4
4
  import { Icon } from '../Icon';
5
5
  import { Text } from '../Text';
6
- export const Row = ({ iconLeft, iconLeftColor = 'color.icon.base', iconRight, iconRightColor = 'color.icon.nonEssential', handleClick, heading, subHeading, type, borderTop = true, borderBottom = true, boldHeading, ...marginProps }) => {
6
+ import { IconContainer } from '../sharedStyles/shared.styles';
7
+ export const Row = ({ iconLeft, iconLeftComponent, iconLeftColor = 'color.icon.base', iconRight, iconRightComponent, iconRightColor = 'color.icon.nonEssential', handleClick, heading, subHeading, type, borderTop = true, borderBottom = true, boldHeading, ...marginProps }) => {
7
8
  const windowWidth = screen.width;
8
- return (_jsxs(Container, { "$type": type, "$iconLeft": iconLeft, "$borderTop": borderTop, "$borderBottom": borderBottom, "$iconRight": iconRight, onClick: handleClick, "$boldHeading": boldHeading, ...marginProps, children: [iconLeft && (_jsx(Icon, { render: iconLeft, size: windowWidth > 768 ? 24 : 18, color: iconLeftColor })), _jsxs(Box, { children: [_jsx(Text, { tag: "h1", typo: "body-regular", children: heading }), _jsx(Text, { tag: "p", typo: "body-small", color: "sesame", children: subHeading })] }), iconRight && (_jsx(Icon, { className: "iconRight", render: iconRight, size: 24, rotate: iconRight === 'caret' ? -90 : 0, color: iconRightColor }))] }));
9
+ const iconLeftSize = windowWidth > 768 ? 24 : 16;
10
+ const { color } = useTheme();
11
+ const iconLeftToRender = iconLeftComponent ? (_jsx(IconContainer, { "$size": iconLeftSize, color: color.icon.base, children: iconLeftComponent })) : iconLeft ? (_jsx(Icon, { render: iconLeft, size: iconLeftSize, color: iconLeftColor })) : null;
12
+ const iconRightToRender = iconRightComponent ? (_jsx(IconContainer, { "$size": 24, color: color.icon.nonEssential, children: iconRightComponent })) : iconRight ? (_jsx(Icon, { render: iconRight, size: 24, rotate: iconRight === 'caret' ? -90 : 0, color: iconRightColor })) : null;
13
+ return (_jsxs(Container, { "$type": type, "$iconLeft": Boolean(iconLeft || iconLeftComponent), "$borderTop": borderTop, "$borderBottom": borderBottom, "$iconRight": Boolean(iconRight || iconRightComponent), onClick: handleClick, "$boldHeading": boldHeading, ...marginProps, children: [iconLeftToRender, _jsxs(Box, { children: [_jsx(Text, { tag: "h1", typo: "body-regular", children: heading }), _jsx(Text, { tag: "p", typo: "body-small", color: "sesame", children: subHeading })] }), iconRightToRender] }));
9
14
  };
10
15
  const Container = styled(Box)(({ $type, $iconLeft, $borderTop, $borderBottom, $boldHeading, theme }) => css `
11
16
  border-radius: ${($type === 'first' && `16px 16px 0 0`) ||
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sourceRoot":"","sources":["../../src/Row/Row.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,I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aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC1D,CAAC,KAAK,KAAK,OAAO,IAAI,eAAe,CAAC;IACvD,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC;IAC9B,CAAC,KAAK,KAAK,MAAM,IAAI,eAAe,CAAC;IACrC,CAAC;;kBAEa,UAAU,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO;IACjE,CAAC,CAAC,aAAa,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1C,CAAC,CAAC,MAAM;qBACO,aAAa,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM;IACtE,CAAC,CAAC,aAAa,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1C,CAAC,CAAC,MAAM;;wBAEU,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;;6BAExB,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW;;;;;;;;qBAQlD,YAAY,IAAI,GAAG;;;;;;;;;;GAUrC,CACF,CAAA","sourcesContent":["import { FC } from 'react'\nimport styled, { css } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Icon } from '../Icon'\nimport { Icons } from '../Icon/iconsList'\nimport { Text } from '../Text'\nimport { MarginProps } from '../utils/space'\nimport { ColorTypes } from '../ThemeProvider/utils/colourMap'\n\nexport type RowProps = {\n iconLeft?: Icons\n iconLeftColor?: ColorTypes\n iconRight?: Icons\n iconRightColor?: ColorTypes\n handleClick?: () => void\n heading: string\n subHeading?: string\n type?: 'first' | 'last' | 'curved'\n borderTop?: boolean\n borderBottom?: boolean\n boldHeading?: boolean\n} & MarginProps\n\nexport const Row: FC<RowProps> = ({\n iconLeft,\n iconLeftColor = 'color.icon.base',\n iconRight,\n iconRightColor = 'color.icon.nonEssential',\n handleClick,\n heading,\n subHeading,\n type,\n borderTop = true,\n borderBottom = true,\n boldHeading,\n ...marginProps\n}) => {\n const windowWidth = screen.width\n\n return (\n <Container\n $type={type}\n $iconLeft={iconLeft}\n $borderTop={borderTop}\n $borderBottom={borderBottom}\n $iconRight={iconRight}\n onClick={handleClick}\n $boldHeading={boldHeading}\n {...marginProps}\n >\n {iconLeft && (\n <Icon\n render={iconLeft}\n size={windowWidth > 768 ? 24 : 18}\n color={iconLeftColor}\n />\n )}\n <Box>\n <Text tag=\"h1\" typo=\"body-regular\">\n {heading}\n </Text>\n <Text tag=\"p\" typo=\"body-small\" color=\"sesame\">\n {subHeading}\n </Text>\n </Box>\n {iconRight && (\n <Icon\n className=\"iconRight\"\n render={iconRight}\n size={24}\n rotate={iconRight === 'caret' ? -90 : 0}\n color={iconRightColor}\n />\n )}\n </Container>\n )\n}\n\ninterface IContainer {\n $type?: 'first' | 'last' | 'curved'\n $iconLeft?: string\n $iconRight?: string\n $borderTop: boolean\n $borderBottom: boolean\n $boldHeading?: boolean\n}\n\nconst Container = styled(Box)<IContainer>(\n ({ $type, $iconLeft, $borderTop, $borderBottom, $boldHeading, theme }) => css`\n border-radius: ${($type === 'first' && `16px 16px 0 0`) ||\n ($type === 'curved' && `16px`) ||\n ($type === 'last' && `0 0 16px 16px`) ||\n 0};\n\n border-top: ${$borderTop && $type !== 'curved' && $type !== 'first'\n ? `1px solid ${theme.color.border.subtle}`\n : 'none'};\n border-bottom: ${$borderBottom && $type !== 'curved' && $type !== 'last'\n ? `1px solid ${theme.color.border.subtle}`\n : 'none'};\n\n background-color: ${theme.color.surface.base[300]};\n display: grid;\n grid-template-columns: ${$iconLeft ? `24px auto 24px` : `auto 24px`};\n padding: 16px;\n grid-gap: 16px;\n align-items: center;\n\n cursor: pointer;\n\n h1 {\n font-weight: ${$boldHeading && 500};\n }\n\n .iconRight {\n justify-self: end;\n }\n\n @media (min-width: 768px) {\n grid-gap: 24px;\n }\n `,\n)\n"]}
1
+ {"version":3,"file":"Row.js","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CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1C,CAAC,CAAC,MAAM;qBACO,aAAa,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM;IACtE,CAAC,CAAC,aAAa,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;IAC1C,CAAC,CAAC,MAAM;;wBAEU,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;;6BAExB,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW;;;;;;;;qBAQlD,YAAY,IAAI,GAAG;;;;;;;;;;GAUrC,CACF,CAAA","sourcesContent":["import { FC, ReactNode } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Icon, Icons } from '../Icon'\nimport { Text } from '../Text'\nimport { MarginProps } from '../utils/space'\nimport { ColorTypes } from '../ThemeProvider/utils/colourMap'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\nexport type RowProps = {\n iconLeft?: Icons\n iconLeftComponent?: ReactNode\n iconLeftColor?: ColorTypes\n iconRight?: Icons\n iconRightColor?: ColorTypes\n iconRightComponent?: ReactNode\n handleClick?: () => void\n heading: string\n subHeading?: string\n type?: 'first' | 'last' | 'curved'\n borderTop?: boolean\n borderBottom?: boolean\n boldHeading?: boolean\n} & MarginProps\n\nexport const Row: FC<RowProps> = ({\n iconLeft,\n iconLeftComponent,\n iconLeftColor = 'color.icon.base',\n iconRight,\n iconRightComponent,\n iconRightColor = 'color.icon.nonEssential',\n handleClick,\n heading,\n subHeading,\n type,\n borderTop = true,\n borderBottom = true,\n boldHeading,\n ...marginProps\n}) => {\n const windowWidth = screen.width\n const iconLeftSize = windowWidth > 768 ? 24 : 16\n const { color } = useTheme()\n\n const iconLeftToRender = iconLeftComponent ? (\n <IconContainer $size={iconLeftSize} color={color.icon.base}>\n {iconLeftComponent}\n </IconContainer>\n ) : iconLeft ? (\n <Icon render={iconLeft} size={iconLeftSize} color={iconLeftColor} />\n ) : null\n\n const iconRightToRender = iconRightComponent ? (\n <IconContainer $size={24} color={color.icon.nonEssential}>\n {iconRightComponent}\n </IconContainer>\n ) : iconRight ? (\n <Icon\n render={iconRight}\n size={24}\n rotate={iconRight === 'caret' ? -90 : 0}\n color={iconRightColor}\n />\n ) : null\n\n return (\n <Container\n $type={type}\n $iconLeft={Boolean(iconLeft || iconLeftComponent)}\n $borderTop={borderTop}\n $borderBottom={borderBottom}\n $iconRight={Boolean(iconRight || iconRightComponent)}\n onClick={handleClick}\n $boldHeading={boldHeading}\n {...marginProps}\n >\n {iconLeftToRender}\n <Box>\n <Text tag=\"h1\" typo=\"body-regular\">\n {heading}\n </Text>\n <Text tag=\"p\" typo=\"body-small\" color=\"sesame\">\n {subHeading}\n </Text>\n </Box>\n {iconRightToRender}\n </Container>\n )\n}\n\ninterface IContainer {\n $type?: 'first' | 'last' | 'curved'\n $iconLeft?: boolean\n $iconRight?: boolean\n $borderTop: boolean\n $borderBottom: boolean\n $boldHeading?: boolean\n}\n\nconst Container = styled(Box)<IContainer>(\n ({ $type, $iconLeft, $borderTop, $borderBottom, $boldHeading, theme }) => css`\n border-radius: ${($type === 'first' && `16px 16px 0 0`) ||\n ($type === 'curved' && `16px`) ||\n ($type === 'last' && `0 0 16px 16px`) ||\n 0};\n\n border-top: ${$borderTop && $type !== 'curved' && $type !== 'first'\n ? `1px solid ${theme.color.border.subtle}`\n : 'none'};\n border-bottom: ${$borderBottom && $type !== 'curved' && $type !== 'last'\n ? `1px solid ${theme.color.border.subtle}`\n : 'none'};\n\n background-color: ${theme.color.surface.base[300]};\n display: grid;\n grid-template-columns: ${$iconLeft ? `24px auto 24px` : `auto 24px`};\n padding: 16px;\n grid-gap: 16px;\n align-items: center;\n\n cursor: pointer;\n\n h1 {\n font-weight: ${$boldHeading && 500};\n }\n\n .iconRight {\n justify-self: end;\n }\n\n @media (min-width: 768px) {\n grid-gap: 24px;\n }\n `,\n)\n"]}
@@ -39,12 +39,3 @@ export interface SearchInputProps extends CommonFieldProps {
39
39
  fuzzySearchOptions?: IFuseOptions<SearchInputItem>;
40
40
  }
41
41
  export declare const SearchInput: import("react").ForwardRefExoticComponent<SearchInputProps & import("react").RefAttributes<HTMLInputElement>>;
42
- export declare const Icons: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("..").MarginProps & import("..").PaddingProps & import("../utils/flex").FlexProps & import("../utils/measure").MeasureProps & import("react").HTMLAttributes<HTMLElement> & {
43
- as?: import("react").ElementType;
44
- forwardedAs?: import("react").ElementType;
45
- } & import("react").RefAttributes<HTMLDivElement>, {
46
- $clearSearch: boolean;
47
- }>> & string & Omit<import("react").ForwardRefExoticComponent<import("..").MarginProps & import("..").PaddingProps & import("../utils/flex").FlexProps & import("../utils/measure").MeasureProps & import("react").HTMLAttributes<HTMLElement> & {
48
- as?: import("react").ElementType;
49
- forwardedAs?: import("react").ElementType;
50
- } & import("react").RefAttributes<HTMLDivElement>>, keyof import("react").Component<any, {}, any>>;
@@ -1,15 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Fuse from 'fuse.js';
3
3
  import { forwardRef, useMemo, useRef, useState, } from 'react';
4
- import styled from 'styled-components';
4
+ import styled, { useTheme } from 'styled-components';
5
5
  import { Box } from '../Box';
6
- import { IconStrict } from '../IconStrict';
7
6
  import { Field } from '../fields/Field';
8
- import { Input, StyledFrontIcon } from '../fields/components/CommonInput';
7
+ import { Input, InputLeadingIconContainer, } from '../fields/components/CommonInput';
9
8
  import { useOnClickOutside } from '../hooks';
10
9
  import { useUniqueId } from '../utils/id';
11
10
  import { useControllableState } from '../utils/useControlledState';
12
11
  import { SearchOptions } from './components/SearchOptions';
12
+ import { IconContainer } from '../sharedStyles/shared.styles';
13
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
14
+ import { faXmark, faChevronDown, faSearch, } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
13
15
  const defaultFuzzySearchOptions = {
14
16
  keys: [
15
17
  {
@@ -29,6 +31,7 @@ const defaultFuzzySearchOptions = {
29
31
  };
30
32
  export const SearchInput = forwardRef(function SearchInput({ id: idProp, name = 'search_input', className = '', placeholder, searchList, showIcon = false, renderAsTitle = false, value, onBlur, onFound, onNotFound, notFoundComponent, fallbackStyle, resultsRelativePosition = false, resultsBorder = true, enableFuzzySearch = false, fuzzySearchOptions, clearSearch, ...otherProps }, ref) {
31
33
  const wrapperRef = useRef(null);
34
+ const theme = useTheme();
32
35
  const id = useUniqueId(idProp);
33
36
  const [showOptions, setShowOptions] = useState(false);
34
37
  const [selectedValue, setSelectedValue] = useControllableState({
@@ -136,9 +139,11 @@ export const SearchInput = forwardRef(function SearchInput({ id: idProp, name =
136
139
  }
137
140
  };
138
141
  const showClearSearchButton = !!clearSearch && (!!value || !!selectedValue || !!searchQuery);
139
- return (_jsx(Wrapper, { ref: wrapperRef, children: _jsxs(Field, { className: className, renderAsTitle: renderAsTitle, htmlFor: id, ...otherProps, children: [_jsxs(Box, { flex: true, alignItems: "center", justifyContent: "flex-start", children: [showIcon && _jsx(StyledFrontIcon, { render: "search", color: "sesame" }), _jsx(Input, { id: id, name: name, ref: ref, placeholder: placeholder, "$error": otherProps.error, "$frontIcon": showIcon ? 'search' : undefined, "$fallbackStyle": fallbackStyle, autoComplete: "off", value: displayedInputText, onFocus: handleClick, onChange: handleInputChange, selected: isSelected, onClick: handleClick, onKeyDown: handleKeyDown, onBlur: (e) => {
142
+ return (_jsx(Wrapper, { ref: wrapperRef, children: _jsxs(Field, { className: className, renderAsTitle: renderAsTitle, htmlFor: id, ...otherProps, children: [_jsxs(Box, { flex: true, alignItems: "center", justifyContent: "flex-start", children: [showIcon && (_jsx(InputLeadingIconContainer, { "$size": 20, children: _jsx(FontAwesomeIcon, { icon: faSearch, color: theme.color.text.subtle }) })), _jsx(Input, { id: id, name: name, ref: ref, placeholder: placeholder, "$error": otherProps.error, "$frontIcon": showIcon, "$fallbackStyle": fallbackStyle, autoComplete: "off", value: displayedInputText, onFocus: handleClick, onChange: handleInputChange, selected: isSelected, onClick: handleClick, onKeyDown: handleKeyDown, onBlur: (e) => {
140
143
  onBlur?.(e);
141
- } }), _jsxs(Icons, { flex: true, alignItems: "center", gap: "8px", "$clearSearch": showClearSearchButton, children: [showClearSearchButton && (_jsx(IconStrict, { type: "button", render: "plus", rotate: 45, iconColor: "color.illustration.neutral.400", title: "Clear search", handleClick: handleClearSearch, size: 24 })), _jsx(Line, {}), _jsx(IconStrict, { type: "button", render: "caret", iconColor: "color.illustration.neutral.400", rotate: showOptions ? 180 : 0, handleClick: handleCaretClick, size: 24 })] })] }), showOptions && (_jsx(SearchOptions, { displayedList: filteredList, selectedValue: selectedValue, highlightedIndex: highlightedIndex, setHighlightedIndex: setHighlightedIndex, onKeyDown: handleKeyDown, searchTerm: searchQuery || '', onSelect: handleSelect, positionRelative: resultsRelativePosition, resultsBorder: resultsBorder, onNotFound: onNotFound, notFoundComponent: notFoundComponent?.(searchQuery ?? '') }))] }) }));
144
+ } }), _jsxs(Icons, { flex: true, alignItems: "center", gap: "8px", "$clearSearch": showClearSearchButton, children: [showClearSearchButton && (_jsx(IconContainer, { title: "Clear search", onClick: handleClearSearch, type: "button", as: "button", "$size": 20, style: { cursor: 'pointer' }, children: _jsx(FontAwesomeIcon, { icon: faXmark, color: theme.color.illustration.neutral[400] }) })), _jsx(Line, {}), _jsx(IconContainer, { type: "button", title: "icon-button", as: "button", onClick: handleCaretClick, "$size": 20, children: _jsx(FontAwesomeIcon, { style: {
145
+ rotate: showOptions ? '180deg' : '0deg',
146
+ }, icon: faChevronDown, color: theme.color.illustration.neutral[400] }) })] })] }), showOptions && (_jsx(SearchOptions, { displayedList: filteredList, selectedValue: selectedValue, highlightedIndex: highlightedIndex, setHighlightedIndex: setHighlightedIndex, onKeyDown: handleKeyDown, searchTerm: searchQuery || '', onSelect: handleSelect, positionRelative: resultsRelativePosition, resultsBorder: resultsBorder, onNotFound: onNotFound, notFoundComponent: notFoundComponent?.(searchQuery ?? '') }))] }) }));
142
147
  });
143
148
  const Wrapper = styled(Box) `
144
149
  position: relative;
@@ -148,7 +153,7 @@ const Line = styled(Box) `
148
153
  height: 24px;
149
154
  width: 1px;
150
155
  `;
151
- export const Icons = styled(Box) `
156
+ const Icons = styled(Box) `
152
157
  position: relative;
153
158
  right: ${({ $clearSearch }) => ($clearSearch ? '80px' : '48px')};
154
159
  margin-right: ${({ $clearSearch }) => ($clearSearch ? '-80px' : '-48px')};
@@ -1 +1 @@
1
- {"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../src/SearchInput/SearchInput.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAsB,MAAM,SAAS,CAAA;AAC5C,OAAO,EAIL,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAyC1D,MAAM,yBAAyB,GAAG;IAChC,IAAI,EAAE;QACJ;YACE,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,GAAG;SACZ;QACD;YACE,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,GAAG;SACZ;KACF;IACD,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,CA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actNode,\n forwardRef,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport styled from 'styled-components'\nimport { Box } from '../Box'\nimport { IconStrict } from '../IconStrict'\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport { Input, StyledFrontIcon } from '../fields/components/CommonInput'\nimport { useOnClickOutside } from '../hooks'\nimport { useUniqueId } from '../utils/id'\nimport { useControllableState } from '../utils/useControlledState'\nimport { SearchOptions } from './components/SearchOptions'\n\nexport type SearchInputItem = {\n label: string\n value: string\n tags?: any[]\n}\n\nexport interface SearchInputProps extends CommonFieldProps {\n /** Optional input className */\n name?: string\n /** Optional placeholder text */\n placeholder?: string\n /** List of input items to search on*/\n searchList: SearchInputItem[]\n /** callback to handle found item click */\n onFound: (element: string) => void\n /** optional callback to run when no results found */\n onNotFound?: (searchTerm: string) => void\n /** optional Component to render when no results found */\n notFoundComponent?: (searchTerm: string) => ReactNode\n /** optional boolean to show search icon */\n showIcon?: boolean\n /** optional boolean to show a clear search button */\n clearSearch?: boolean\n /** Optional callback to run on blur */\n onBlur?: (e: FocusEvent<HTMLInputElement>) => void\n /** Optional default value for input */\n value?: string\n /** Optional boolean to move results to a realtive position */\n resultsRelativePosition?: boolean\n /** optional boolean to add border to results */\n resultsBorder?: boolean\n /** optional boolean to enable fuzzy search via fuse.js */\n enableFuzzySearch?: boolean\n /** optional config of fuzzy search\n * passing a value to this prop, automatically enables fuzzy search\n */\n fuzzySearchOptions?: IFuseOptions<SearchInputItem>\n}\n\nconst defaultFuzzySearchOptions = {\n keys: [\n {\n name: 'label',\n weight: 0.6,\n },\n {\n name: 'tags',\n weight: 0.4,\n },\n ],\n findAllMatches: true,\n minMatchCharLength: 1,\n location: 0,\n threshold: 0.45,\n distance: 55,\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(\n function SearchInput(\n {\n id: idProp,\n name = 'search_input',\n className = '',\n placeholder,\n searchList,\n showIcon = false,\n renderAsTitle = false,\n value,\n onBlur,\n onFound,\n onNotFound,\n notFoundComponent,\n fallbackStyle,\n resultsRelativePosition = false,\n resultsBorder = true,\n enableFuzzySearch = false,\n fuzzySearchOptions,\n clearSearch,\n ...otherProps\n },\n ref,\n ) {\n const wrapperRef = useRef(null)\n const id = useUniqueId(idProp)\n const [showOptions, setShowOptions] = useState(false)\n const [selectedValue, setSelectedValue] = useControllableState<\n string | null\n >({\n initialState: null,\n stateProp: value,\n })\n const [searchQuery, setSearchQuery] = useState<string | null>(null)\n const [highlightedIndex, setHighlightedIndex] = useState(-1)\n\n const selectedValueLabel = searchList.find(\n (option) =>\n option.label === selectedValue || option.value === selectedValue,\n )?.label\n\n const handleBlur = () => {\n if (selectedValue) {\n setSearchQuery(selectedValueLabel ?? null)\n } else if (!selectedValue) {\n setSearchQuery(null)\n }\n }\n\n useOnClickOutside({\n ref: wrapperRef,\n callback: () => {\n handleBlur()\n setShowOptions(false)\n },\n })\n\n const fuse = useMemo(() => {\n return new Fuse(searchList, {\n ...defaultFuzzySearchOptions,\n ...fuzzySearchOptions,\n })\n }, [searchList])\n\n const filteredList = useMemo(() => {\n if (searchQuery === null || searchQuery === '') {\n return searchList\n }\n\n if (enableFuzzySearch || !!fuzzySearchOptions) {\n return fuse.search(searchQuery).map(({ item }) => item)\n }\n\n return searchList.filter(({ label }) =>\n label.toLowerCase().includes(searchQuery.toLocaleLowerCase()),\n )\n }, [searchQuery, enableFuzzySearch, !!fuzzySearchOptions])\n\n const getDisplayedInputText = () => {\n if (searchQuery !== null) {\n return searchQuery\n }\n if (selectedValue !== null) {\n return selectedValueLabel || ''\n }\n return ''\n }\n\n const isSelected = selectedValue !== null\n const displayedInputText = getDisplayedInputText()\n\n const updateSearchQuery = (query: string | null) => {\n setSearchQuery(query)\n setHighlightedIndex(-1)\n\n if (query === null) {\n setSelectedValue(null)\n setShowOptions(false)\n } else {\n setShowOptions(true)\n }\n }\n\n const handleClick = () => {\n setShowOptions(true)\n if (searchQuery !== null) {\n updateSearchQuery(searchQuery)\n setShowOptions(true)\n } else if (selectedValue !== null && searchQuery === null) {\n setSearchQuery(selectedValueLabel || null)\n setShowOptions(true)\n }\n }\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>): void => {\n const nextValue = event.currentTarget.value\n updateSearchQuery(nextValue)\n }\n\n const handleSelect = (nextValue: SearchInputItem): void => {\n updateSearchQuery(null)\n setSelectedValue(nextValue.label)\n onFound(nextValue.value)\n }\n\n const handleClearSearch = () => {\n updateSearchQuery(null)\n setSelectedValue(null)\n onFound('')\n }\n\n const handleCaretClick = () => {\n setShowOptions(!showOptions)\n }\n\n const handleKeyDown = (event: {\n key: string\n preventDefault: () => void\n }) => {\n if (event.key === 'Enter' && highlightedIndex !== -1) {\n event.preventDefault()\n const focusedItem = filteredList[highlightedIndex]\n handleSelect(focusedItem)\n } else if (event.key === 'ArrowDown') {\n event.preventDefault()\n const nextIndex = (highlightedIndex + 1) % filteredList.length\n setHighlightedIndex(nextIndex)\n } else if (event.key === 'ArrowUp') {\n event.preventDefault()\n const prevIndex =\n (highlightedIndex - 1 + filteredList.length) % filteredList.length\n setHighlightedIndex(prevIndex)\n }\n }\n\n const showClearSearchButton =\n !!clearSearch && (!!value || !!selectedValue || !!searchQuery)\n\n return (\n <Wrapper ref={wrapperRef}>\n <Field\n className={className}\n renderAsTitle={renderAsTitle}\n htmlFor={id}\n {...otherProps}\n >\n <Box flex alignItems=\"center\" justifyContent=\"flex-start\">\n {showIcon && <StyledFrontIcon render=\"search\" color=\"sesame\" />}\n <Input\n id={id}\n name={name}\n ref={ref}\n placeholder={placeholder}\n $error={otherProps.error}\n $frontIcon={showIcon ? 'search' : undefined}\n $fallbackStyle={fallbackStyle}\n autoComplete=\"off\"\n value={displayedInputText}\n onFocus={handleClick}\n onChange={handleInputChange}\n selected={isSelected}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onBlur={(e) => {\n onBlur?.(e)\n }}\n />\n <Icons\n flex\n alignItems=\"center\"\n gap=\"8px\"\n $clearSearch={showClearSearchButton}\n >\n {showClearSearchButton && (\n <IconStrict\n type=\"button\"\n render=\"plus\"\n rotate={45}\n iconColor=\"color.illustration.neutral.400\"\n title=\"Clear search\"\n handleClick={handleClearSearch}\n size={24}\n />\n )}\n <Line />\n <IconStrict\n type=\"button\"\n render=\"caret\"\n iconColor=\"color.illustration.neutral.400\"\n rotate={showOptions ? 180 : 0}\n handleClick={handleCaretClick}\n size={24}\n />\n </Icons>\n </Box>\n\n {showOptions && (\n <SearchOptions\n displayedList={filteredList}\n selectedValue={selectedValue}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n onKeyDown={handleKeyDown}\n searchTerm={searchQuery || ''}\n onSelect={handleSelect}\n positionRelative={resultsRelativePosition}\n resultsBorder={resultsBorder}\n onNotFound={onNotFound}\n notFoundComponent={notFoundComponent?.(searchQuery ?? '')}\n />\n )}\n </Field>\n </Wrapper>\n )\n },\n)\n\nconst Wrapper = styled(Box)`\n position: relative;\n`\n\nconst Line = styled(Box)`\n background: ${({ theme }) => theme.color.border.subtle};\n height: 24px;\n width: 1px;\n`\n\nexport const Icons = styled(Box)<{ $clearSearch: boolean }>`\n position: relative;\n right: ${({ $clearSearch }) => ($clearSearch ? '80px' : '48px')};\n margin-right: ${({ $clearSearch }) => ($clearSearch ? '-80px' : '-48px')};\n`\n"]}
1
+ {"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../../src/SearchInput/SearchInput.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAsB,MAAM,SAAS,CAAA;AAC5C,OAAO,EAIL,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EACL,KAAK,EACL,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,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,WAAW,IAAI,EAAE,EAC7B,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,uBAAuB,EACzC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC,GACzD,CACH,IACK,GACA,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;CAE1B,CAAA;AAED,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;gBACR,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;;;CAGvD,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAA2B;;WAEzC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;kBAC/C,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;CACzE,CAAA","sourcesContent":["import Fuse, { IFuseOptions } from 'fuse.js'\nimport {\n ChangeEvent,\n FocusEvent,\n ReactNode,\n forwardRef,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport styled, { useTheme } from 'styled-components'\nimport { Box } from '../Box'\nimport { Field } from '../fields/Field'\nimport { CommonFieldProps } from '../fields/commonFieldTypes'\nimport {\n Input,\n InputLeadingIconContainer,\n} from '../fields/components/CommonInput'\nimport { useOnClickOutside } from '../hooks'\nimport { useUniqueId } from '../utils/id'\nimport { useControllableState } from '../utils/useControlledState'\nimport { SearchOptions } from './components/SearchOptions'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport {\n faXmark,\n faChevronDown,\n faSearch,\n} from '@awesome.me/kit-46ca99185c/icons/classic/regular'\n\nexport type SearchInputItem = {\n label: string\n value: string\n tags?: any[]\n}\n\nexport interface SearchInputProps extends CommonFieldProps {\n /** Optional input className */\n name?: string\n /** Optional placeholder text */\n placeholder?: string\n /** List of input items to search on*/\n searchList: SearchInputItem[]\n /** callback to handle found item click */\n onFound: (element: string) => void\n /** optional callback to run when no results found */\n onNotFound?: (searchTerm: string) => void\n /** optional Component to render when no results found */\n notFoundComponent?: (searchTerm: string) => ReactNode\n /** optional boolean to show search icon */\n showIcon?: boolean\n /** optional boolean to show a clear search button */\n clearSearch?: boolean\n /** Optional callback to run on blur */\n onBlur?: (e: FocusEvent<HTMLInputElement>) => void\n /** Optional default value for input */\n value?: string\n /** Optional boolean to move results to a realtive position */\n resultsRelativePosition?: boolean\n /** optional boolean to add border to results */\n resultsBorder?: boolean\n /** optional boolean to enable fuzzy search via fuse.js */\n enableFuzzySearch?: boolean\n /** optional config of fuzzy search\n * passing a value to this prop, automatically enables fuzzy search\n */\n fuzzySearchOptions?: IFuseOptions<SearchInputItem>\n}\n\nconst defaultFuzzySearchOptions = {\n keys: [\n {\n name: 'label',\n weight: 0.6,\n },\n {\n name: 'tags',\n weight: 0.4,\n },\n ],\n findAllMatches: true,\n minMatchCharLength: 1,\n location: 0,\n threshold: 0.45,\n distance: 55,\n}\n\nexport const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(\n function SearchInput(\n {\n id: idProp,\n name = 'search_input',\n className = '',\n placeholder,\n searchList,\n showIcon = false,\n renderAsTitle = false,\n value,\n onBlur,\n onFound,\n onNotFound,\n notFoundComponent,\n fallbackStyle,\n resultsRelativePosition = false,\n resultsBorder = true,\n enableFuzzySearch = false,\n fuzzySearchOptions,\n clearSearch,\n ...otherProps\n },\n ref,\n ) {\n const wrapperRef = useRef(null)\n const theme = useTheme()\n const id = useUniqueId(idProp)\n const [showOptions, setShowOptions] = useState(false)\n const [selectedValue, setSelectedValue] = useControllableState<\n string | null\n >({\n initialState: null,\n stateProp: value,\n })\n const [searchQuery, setSearchQuery] = useState<string | null>(null)\n const [highlightedIndex, setHighlightedIndex] = useState(-1)\n\n const selectedValueLabel = searchList.find(\n (option) =>\n option.label === selectedValue || option.value === selectedValue,\n )?.label\n\n const handleBlur = () => {\n if (selectedValue) {\n setSearchQuery(selectedValueLabel ?? null)\n } else if (!selectedValue) {\n setSearchQuery(null)\n }\n }\n\n useOnClickOutside({\n ref: wrapperRef,\n callback: () => {\n handleBlur()\n setShowOptions(false)\n },\n })\n\n const fuse = useMemo(() => {\n return new Fuse(searchList, {\n ...defaultFuzzySearchOptions,\n ...fuzzySearchOptions,\n })\n }, [searchList])\n\n const filteredList = useMemo(() => {\n if (searchQuery === null || searchQuery === '') {\n return searchList\n }\n\n if (enableFuzzySearch || !!fuzzySearchOptions) {\n return fuse.search(searchQuery).map(({ item }) => item)\n }\n\n return searchList.filter(({ label }) =>\n label.toLowerCase().includes(searchQuery.toLocaleLowerCase()),\n )\n }, [searchQuery, enableFuzzySearch, !!fuzzySearchOptions])\n\n const getDisplayedInputText = () => {\n if (searchQuery !== null) {\n return searchQuery\n }\n if (selectedValue !== null) {\n return selectedValueLabel || ''\n }\n return ''\n }\n\n const isSelected = selectedValue !== null\n const displayedInputText = getDisplayedInputText()\n\n const updateSearchQuery = (query: string | null) => {\n setSearchQuery(query)\n setHighlightedIndex(-1)\n\n if (query === null) {\n setSelectedValue(null)\n setShowOptions(false)\n } else {\n setShowOptions(true)\n }\n }\n\n const handleClick = () => {\n setShowOptions(true)\n if (searchQuery !== null) {\n updateSearchQuery(searchQuery)\n setShowOptions(true)\n } else if (selectedValue !== null && searchQuery === null) {\n setSearchQuery(selectedValueLabel || null)\n setShowOptions(true)\n }\n }\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>): void => {\n const nextValue = event.currentTarget.value\n updateSearchQuery(nextValue)\n }\n\n const handleSelect = (nextValue: SearchInputItem): void => {\n updateSearchQuery(null)\n setSelectedValue(nextValue.label)\n onFound(nextValue.value)\n }\n\n const handleClearSearch = () => {\n updateSearchQuery(null)\n setSelectedValue(null)\n onFound('')\n }\n\n const handleCaretClick = () => {\n setShowOptions(!showOptions)\n }\n\n const handleKeyDown = (event: {\n key: string\n preventDefault: () => void\n }) => {\n if (event.key === 'Enter' && highlightedIndex !== -1) {\n event.preventDefault()\n const focusedItem = filteredList[highlightedIndex]\n handleSelect(focusedItem)\n } else if (event.key === 'ArrowDown') {\n event.preventDefault()\n const nextIndex = (highlightedIndex + 1) % filteredList.length\n setHighlightedIndex(nextIndex)\n } else if (event.key === 'ArrowUp') {\n event.preventDefault()\n const prevIndex =\n (highlightedIndex - 1 + filteredList.length) % filteredList.length\n setHighlightedIndex(prevIndex)\n }\n }\n\n const showClearSearchButton =\n !!clearSearch && (!!value || !!selectedValue || !!searchQuery)\n\n return (\n <Wrapper ref={wrapperRef}>\n <Field\n className={className}\n renderAsTitle={renderAsTitle}\n htmlFor={id}\n {...otherProps}\n >\n <Box flex alignItems=\"center\" justifyContent=\"flex-start\">\n {showIcon && (\n <InputLeadingIconContainer $size={20}>\n <FontAwesomeIcon\n icon={faSearch}\n color={theme.color.text.subtle}\n />\n </InputLeadingIconContainer>\n )}\n <Input\n id={id}\n name={name}\n ref={ref}\n placeholder={placeholder}\n $error={otherProps.error}\n $frontIcon={showIcon}\n $fallbackStyle={fallbackStyle}\n autoComplete=\"off\"\n value={displayedInputText}\n onFocus={handleClick}\n onChange={handleInputChange}\n selected={isSelected}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onBlur={(e) => {\n onBlur?.(e)\n }}\n />\n <Icons\n flex\n alignItems=\"center\"\n gap=\"8px\"\n $clearSearch={showClearSearchButton}\n >\n {showClearSearchButton && (\n <IconContainer\n title=\"Clear search\"\n onClick={handleClearSearch}\n type=\"button\"\n as=\"button\"\n $size={20}\n style={{ cursor: 'pointer' }}\n >\n <FontAwesomeIcon\n icon={faXmark}\n color={theme.color.illustration.neutral[400]}\n />\n </IconContainer>\n )}\n <Line />\n <IconContainer\n type=\"button\"\n title=\"icon-button\"\n as=\"button\"\n onClick={handleCaretClick}\n $size={20}\n >\n <FontAwesomeIcon\n style={{\n rotate: showOptions ? '180deg' : '0deg',\n }}\n icon={faChevronDown}\n color={theme.color.illustration.neutral[400]}\n />\n </IconContainer>\n </Icons>\n </Box>\n\n {showOptions && (\n <SearchOptions\n displayedList={filteredList}\n selectedValue={selectedValue}\n highlightedIndex={highlightedIndex}\n setHighlightedIndex={setHighlightedIndex}\n onKeyDown={handleKeyDown}\n searchTerm={searchQuery || ''}\n onSelect={handleSelect}\n positionRelative={resultsRelativePosition}\n resultsBorder={resultsBorder}\n onNotFound={onNotFound}\n notFoundComponent={notFoundComponent?.(searchQuery ?? '')}\n />\n )}\n </Field>\n </Wrapper>\n )\n },\n)\n\nconst Wrapper = styled(Box)`\n position: relative;\n`\n\nconst Line = styled(Box)`\n background: ${({ theme }) => theme.color.border.subtle};\n height: 24px;\n width: 1px;\n`\n\nconst Icons = styled(Box)<{ $clearSearch: boolean }>`\n position: relative;\n right: ${({ $clearSearch }) => ($clearSearch ? '80px' : '48px')};\n margin-right: ${({ $clearSearch }) => ($clearSearch ? '-80px' : '-48px')};\n`\n"]}
@@ -1,12 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled from 'styled-components';
2
+ import styled, { useTheme } from 'styled-components';
3
3
  import { Box } from '../Box';
4
4
  import { useTimeout } from '../hooks';
5
5
  import { Icon } from '../Icon';
6
6
  import { Text } from '../Text';
7
- export const SnackbarItem = ({ autoCloseTime = 4, id, message, leadingIcon, canManuallyClose, showCloseIcon, deleteSnack, }) => {
7
+ import { IconContainer } from '../sharedStyles/shared.styles';
8
+ import { faXmark } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
9
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
10
+ export const SnackbarItem = ({ autoCloseTime = 4, id, message, leadingIcon, iconComponent, canManuallyClose, showCloseIcon, deleteSnack, }) => {
8
11
  useTimeout(() => deleteSnack(id), autoCloseTime * 1000);
9
- return (_jsxs(SnackItem, { p: "16px", mt: "16px", flex: true, justifyContent: "space-between", children: [_jsxs(Box, { flex: true, alignItems: "center", children: [leadingIcon && (_jsx(Icon, { mr: "12px", render: leadingIcon, size: 24, color: "color.surface.base.200" })), _jsx(Text, { typo: "body-small", color: "color.surface.base.200", children: message })] }), canManuallyClose && (_jsx(CloseButton, { onClick: () => deleteSnack(id), "aria-label": `close snackbar ${message}`, children: showCloseIcon ? (_jsx(Icon, { render: "cross", size: 16, color: "color.surface.base.200" })) : (_jsx(UnderlinedText, { tag: "span", typo: "headline-small", color: "color.surface.base.200", children: "Dismiss" })) }))] }, id));
12
+ const theme = useTheme();
13
+ const iconToRender = iconComponent ? (_jsx(IconContainer, { style: { marginRight: '24px' }, "$size": 24, "$iconColor": theme.color.surface.base[200], children: iconComponent })) : leadingIcon ? (_jsx(Icon, { render: leadingIcon, size: 24, color: "color.surface.base.200", mr: "12px" })) : null;
14
+ return (_jsxs(SnackItem, { p: "16px", mt: "16px", flex: true, justifyContent: "space-between", alignItems: "center", children: [_jsxs(Box, { flex: true, alignItems: "center", children: [iconToRender, _jsx(Text, { typo: "body-small", color: "color.surface.base.200", children: message })] }), canManuallyClose && (_jsx(CloseButton, { onClick: () => deleteSnack(id), "aria-label": `close snackbar ${message}`, children: showCloseIcon ? (_jsx(IconContainer, { as: "span", "$size": 16, children: _jsx(FontAwesomeIcon, { icon: faXmark, color: theme.color.surface.base[200] }) })) : (_jsx(UnderlinedText, { tag: "span", typo: "headline-small", color: "color.surface.base.200", children: "Dismiss" })) }))] }, id));
10
15
  };
11
16
  const SnackItem = styled(Box) `
12
17
  border-radius: 16px;
@@ -1 +1 @@
1
- {"version":3,"file":"Snackbar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AC,cAAc,IACb,GAAG,EAAC,MAAM,EACV,IAAI,EAAC,gBAAgB,EACrB,KAAK,EAAC,wBAAwB,wBAGf,CAClB,GACW,CACf,KA/BsB,EAAE,CAgCf,CACb,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;sBAEP,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;CACjE,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAA;;CAEhC,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAElC,CAAA","sourcesContent":["import { FC } from 'react'\nimport styled from 'styled-components'\nimport { Box } from '../Box'\nimport { useTimeout } from '../hooks'\nimport { Icon } from '../Icon'\nimport { Text } from '../Text'\nimport { Snackbar } from './types'\n\ninterface Props extends Snackbar {\n deleteSnack: (id: string) => void\n}\n\nexport const SnackbarItem: FC<Props> = ({\n autoCloseTime = 4,\n id,\n message,\n leadingIcon,\n canManuallyClose,\n showCloseIcon,\n deleteSnack,\n}) => {\n useTimeout(() => deleteSnack(id), autoCloseTime * 1000)\n\n return (\n <SnackItem p=\"16px\" key={id} mt=\"16px\" flex justifyContent=\"space-between\">\n <Box flex alignItems=\"center\">\n {leadingIcon && (\n <Icon\n mr=\"12px\"\n render={leadingIcon}\n size={24}\n color=\"color.surface.base.200\"\n />\n )}\n <Text typo=\"body-small\" color=\"color.surface.base.200\">\n {message}\n </Text>\n </Box>\n {canManuallyClose && (\n <CloseButton\n onClick={() => deleteSnack(id)}\n aria-label={`close snackbar ${message}`}\n >\n {showCloseIcon ? (\n <Icon render=\"cross\" size={16} color=\"color.surface.base.200\" />\n ) : (\n <UnderlinedText\n tag=\"span\"\n typo=\"headline-small\"\n color=\"color.surface.base.200\"\n >\n Dismiss\n </UnderlinedText>\n )}\n </CloseButton>\n )}\n </SnackItem>\n )\n}\n\nconst SnackItem = styled(Box)`\n border-radius: 16px;\n background-color: ${({ theme }) => theme.color.surface.base[900]};\n`\n\nconst CloseButton = styled.button`\n cursor: pointer;\n`\n\nconst UnderlinedText = styled(Text)`\n text-decoration: underline;\n`\n"]}
1
+ {"version":3,"file":"SnackbarItem.js","sourceRoot":"","sources":["../../src/Snackbar/SnackbarItem.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAMhE,MAAM,CAAC,MAAM,YAAY,GAAc,CAAC,EACtC,aAAa,GAAG,CAAC,EACjB,EAAE,EACF,OAAO,EACP,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,CAAA;IAEvD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IACxB,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CACnC,KAAC,aAAa,IACZ,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,WACvB,EAAE,gBACG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,YAExC,aAAa,GACA,CACjB,CAAC,CAAC,CAAC,WAAW,CAAC,C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cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAElC,CAAA","sourcesContent":["import { FC } from 'react'\nimport styled, { useTheme } from 'styled-components'\nimport { Box } from '../Box'\nimport { useTimeout } from '../hooks'\nimport { Icon } from '../Icon'\nimport { Text } from '../Text'\nimport { Snackbar } from './types'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { faXmark } from '@awesome.me/kit-46ca99185c/icons/classic/regular'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\n\ninterface Props extends Snackbar {\n deleteSnack: (id: string) => void\n}\n\nexport const SnackbarItem: FC<Props> = ({\n autoCloseTime = 4,\n id,\n message,\n leadingIcon,\n iconComponent,\n canManuallyClose,\n showCloseIcon,\n deleteSnack,\n}) => {\n useTimeout(() => deleteSnack(id), autoCloseTime * 1000)\n\n const theme = useTheme()\n const iconToRender = iconComponent ? (\n <IconContainer\n style={{ marginRight: '24px' }}\n $size={24}\n $iconColor={theme.color.surface.base[200]}\n >\n {iconComponent}\n </IconContainer>\n ) : leadingIcon ? (\n <Icon\n render={leadingIcon}\n size={24}\n color=\"color.surface.base.200\"\n mr=\"12px\"\n />\n ) : null\n\n return (\n <SnackItem\n p=\"16px\"\n key={id}\n mt=\"16px\"\n flex\n justifyContent=\"space-between\"\n alignItems=\"center\"\n >\n <Box flex alignItems=\"center\">\n {iconToRender}\n <Text typo=\"body-small\" color=\"color.surface.base.200\">\n {message}\n </Text>\n </Box>\n {canManuallyClose && (\n <CloseButton\n onClick={() => deleteSnack(id)}\n aria-label={`close snackbar ${message}`}\n >\n {showCloseIcon ? (\n <IconContainer as=\"span\" $size={16}>\n <FontAwesomeIcon\n icon={faXmark}\n color={theme.color.surface.base[200]}\n />\n </IconContainer>\n ) : (\n <UnderlinedText\n tag=\"span\"\n typo=\"headline-small\"\n color=\"color.surface.base.200\"\n >\n Dismiss\n </UnderlinedText>\n )}\n </CloseButton>\n )}\n </SnackItem>\n )\n}\n\nconst SnackItem = styled(Box)`\n border-radius: 16px;\n background-color: ${({ theme }) => theme.color.surface.base[900]};\n`\n\nconst CloseButton = styled.button`\n cursor: pointer;\n`\n\nconst UnderlinedText = styled(Text)`\n text-decoration: underline;\n`\n"]}
@@ -1,10 +1,11 @@
1
- import { Icons } from '../Icon/iconsList';
1
+ import { Icons } from '../Icon';
2
2
  import { ReactNode } from 'react';
3
3
  export interface Snackbar {
4
4
  id: string;
5
5
  message: string;
6
6
  autoCloseTime?: 4 | 5 | 6 | 7 | 8 | 9 | 10;
7
7
  leadingIcon?: Icons;
8
+ iconComponent?: ReactNode;
8
9
  canManuallyClose?: boolean;
9
10
  showCloseIcon?: boolean;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Snackbar/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icons } from '../Icon/iconsList'\nimport { ReactNode } from 'react'\n\nexport interface Snackbar {\n id: string\n message: string\n autoCloseTime?: 4 | 5 | 6 | 7 | 8 | 9 | 10\n leadingIcon?: Icons\n canManuallyClose?: boolean\n showCloseIcon?: boolean\n}\n\nexport type CreateSnack = Omit<Snackbar, 'id'>\n\nexport interface SnackbarContextType {\n addSnackbar: (snackbar: CreateSnack) => void\n}\n\nexport interface SnackbarContainerProps {\n children?: ReactNode\n portalContainer?: Element | DocumentFragment\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Snackbar/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Icons } from '../Icon'\nimport { ReactNode } from 'react'\n\nexport interface Snackbar {\n id: string\n message: string\n autoCloseTime?: 4 | 5 | 6 | 7 | 8 | 9 | 10\n leadingIcon?: Icons\n iconComponent?: ReactNode\n canManuallyClose?: boolean\n showCloseIcon?: boolean\n}\n\nexport type CreateSnack = Omit<Snackbar, 'id'>\n\nexport interface SnackbarContextType {\n addSnackbar: (snackbar: CreateSnack) => void\n}\n\nexport interface SnackbarContainerProps {\n children?: ReactNode\n portalContainer?: Element | DocumentFragment\n}\n"]}
@@ -2,46 +2,47 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { darken } from 'polished';
3
3
  import styled, { css, useTheme } from 'styled-components';
4
4
  import { Box } from '../Box';
5
- import { Icon } from '../Icon';
6
5
  import { Text } from '../Text';
7
6
  import { theme as oldTheme } from '../theme';
8
7
  import { isReactElement } from '../utils/isReactElement';
9
8
  import { resolveToThemeColor } from '../ThemeProvider/utils/colourMap';
9
+ import { faCircleCheck, faCircleExclamation, faCircleInfo, faTriangleExclamation, } from '@awesome.me/kit-46ca99185c/icons/classic/regular';
10
+ import { IconContainer } from '../sharedStyles/shared.styles';
11
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
12
+ import { faChevronRight } from '@awesome.me/kit-46ca99185c/icons/classic/solid';
10
13
  const styles = {
11
14
  info: {
12
15
  iconColor: 'color.icon.base',
13
16
  backgroundColor: 'color.illustration.neutral.300',
14
- icon: 'info',
17
+ icon: faCircleInfo,
15
18
  },
16
19
  fallbackStyle: {
17
20
  iconColor: 'color.icon.base',
18
21
  backgroundColor: 'color.surface.base.100',
19
- icon: 'info',
22
+ icon: faCircleInfo,
20
23
  },
21
24
  alert: {
22
25
  iconColor: 'extended1.100',
23
26
  backgroundColor: 'color.feedback.notice.100',
24
- icon: 'alert',
27
+ icon: faTriangleExclamation,
25
28
  },
26
29
  warning: {
27
30
  iconColor: 'color.feedback.negative.200',
28
31
  backgroundColor: 'color.feedback.negative.100',
29
- icon: 'warning',
32
+ icon: faCircleExclamation,
30
33
  },
31
34
  success: {
32
35
  iconColor: 'color.feedback.positive.200',
33
36
  backgroundColor: 'color.feedback.positive.100',
34
- icon: 'circle-tick',
37
+ icon: faCircleCheck,
35
38
  },
36
39
  };
37
40
  export const SupportMessage = ({ className, description, onClick, rightSideComponent, type, title, ...marginProps }) => {
38
41
  const theme = useTheme();
39
42
  const resolveBackgroundColor = resolveToThemeColor(styles[type].backgroundColor, theme);
40
- return (_jsxs(Wrapper, { className: className, "$backgroundColor": resolveBackgroundColor, onClick: onClick, ...marginProps, children: [_jsx(IconWrapper, { alignItems: "center", children: _jsx(Icon, { size: 20, render: styles[type].icon, color: styles[type].iconColor }) }), _jsxs(Box, { flex: true, direction: "column", mx: "8px", children: [title && _jsx(Title, { children: title }), isReactElement(description) ? (_jsx(DescriptionBox, { children: description })) : (_jsx(Description, { tag: "p", children: description }))] }), rightSideComponent, onClick && rightSideComponent === undefined && (_jsx(Box, { ml: { custom: 'auto' }, children: _jsx(Icon, { size: 16, render: "caret", color: "color.illustration.neutral.400", rotate: 270 }) }))] }));
43
+ const resolvedIconColor = resolveToThemeColor(styles[type].iconColor, theme);
44
+ return (_jsxs(Wrapper, { className: className, "$backgroundColor": resolveBackgroundColor, onClick: onClick, ...marginProps, children: [_jsx(IconContainer, { "$size": 20, style: { alignSelf: 'flex-start' }, children: _jsx(FontAwesomeIcon, { icon: styles[type].icon, color: resolvedIconColor }) }), _jsxs(Box, { flex: true, direction: "column", mx: "8px", children: [title && _jsx(Title, { children: title }), isReactElement(description) ? (_jsx(DescriptionBox, { children: description })) : (_jsx(Description, { tag: "p", children: description }))] }), rightSideComponent, onClick && rightSideComponent === undefined && (_jsx(Box, { ml: { custom: 'auto' }, children: _jsx(IconContainer, { "$size": 16, children: _jsx(FontAwesomeIcon, { icon: faChevronRight, color: theme.color.illustration.neutral[400] }) }) }))] }));
41
45
  };
42
- const IconWrapper = styled(Box) `
43
- align-self: flex-start;
44
- `;
45
46
  const Wrapper = styled(Box)(({ $backgroundColor, onClick }) => css `
46
47
  align-items: center;
47
48
  background-color: ${$backgroundColor};
@@ -1 +1 @@
1
- {"version":3,"file":"SupportMessage.js","sourceRoot":"","sources":["../../src/SupportMessage/SupportMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEz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MAAM;WACjC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;CAG9C,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;CAGjC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;CAG/B,CAAA","sourcesContent":["import { darken } from 'polished'\nimport { FC, MouseEventHandler, ReactElement } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\nimport { Icon } from '../Icon'\nimport { Icons } from '../Icon/iconsList'\n\nimport { Text } from '../Text'\nimport { theme as oldTheme } from '../theme'\nimport { isReactElement } from '../utils/isReactElement'\nimport { MarginProps } from '../utils/space'\nimport { NewColor, resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\n\ntype StylesItem = {\n iconColor: NewColor\n backgroundColor: NewColor\n icon: Icons\n}\n\nconst styles: Record<SupportMessageType, StylesItem> = {\n info: {\n iconColor: 'color.icon.base',\n backgroundColor: 'color.illustration.neutral.300',\n icon: 'info',\n },\n fallbackStyle: {\n iconColor: 'color.icon.base',\n backgroundColor: 'color.surface.base.100',\n icon: 'info',\n },\n alert: {\n iconColor: 'extended1.100',\n backgroundColor: 'color.feedback.notice.100',\n icon: 'alert',\n },\n warning: {\n iconColor: 'color.feedback.negative.200',\n backgroundColor: 'color.feedback.negative.100',\n icon: 'warning',\n },\n success: {\n iconColor: 'color.feedback.positive.200',\n backgroundColor: 'color.feedback.positive.100',\n icon: 'circle-tick',\n },\n}\n\ntype SupportMessageType =\n | 'info'\n | 'fallbackStyle'\n | 'alert'\n | 'warning'\n | 'success'\n\nexport type SupportMessageProps = {\n className?: string\n description: string | ReactElement<any>\n onClick?: MouseEventHandler\n /**\n * Right side content, usually an icon or a button\n */\n rightSideComponent?: ReactElement<any>\n type: SupportMessageType\n title?: string\n} & MarginProps\n\nexport const SupportMessage: FC<SupportMessageProps> = ({\n className,\n description,\n onClick,\n rightSideComponent,\n type,\n title,\n ...marginProps\n}) => {\n const theme = useTheme()\n const resolveBackgroundColor = resolveToThemeColor(\n styles[type].backgroundColor,\n theme,\n )\n\n return (\n <Wrapper\n className={className}\n $backgroundColor={resolveBackgroundColor}\n onClick={onClick}\n {...marginProps}\n >\n <IconWrapper alignItems=\"center\">\n <Icon\n size={20}\n render={styles[type].icon}\n color={styles[type].iconColor}\n />\n </IconWrapper>\n <Box flex direction=\"column\" mx=\"8px\">\n {title && <Title>{title}</Title>}\n {isReactElement(description) ? (\n <DescriptionBox>{description}</DescriptionBox>\n ) : (\n <Description tag=\"p\">{description}</Description>\n )}\n </Box>\n {rightSideComponent}\n {onClick && rightSideComponent === undefined && (\n <Box ml={{ custom: 'auto' }}>\n <Icon\n size={16}\n render=\"caret\"\n color=\"color.illustration.neutral.400\"\n rotate={270}\n />\n </Box>\n )}\n </Wrapper>\n )\n}\n\ninterface IWrapper {\n $backgroundColor: string\n onClick?: MouseEventHandler\n}\n\nconst IconWrapper = styled(Box)`\n align-self: flex-start;\n`\n\nconst Wrapper = styled(Box)<IWrapper>(\n ({ $backgroundColor, onClick }) => css`\n align-items: center;\n background-color: ${$backgroundColor};\n border-radius: 16px;\n ${onClick && `cursor: pointer`};\n padding: 12px;\n display: flex;\n width: 100%;\n\n &:hover,\n &:active {\n ${onClick && `background-color: ${darken(0.1, $backgroundColor)};`};\n }\n `,\n)\n\nconst Title = styled.p`\n font-size: 16px;\n font-weight: ${oldTheme.font.weight.medium};\n color: ${({ theme }) => theme.color.text.base};\n line-height: 20.8px;\n margin-bottom: 4px;\n`\n\nconst DescriptionBox = styled(Box)`\n font-size: 14px;\n line-height: 20px;\n`\n\nconst Description = styled(Text)`\n font-size: 14px;\n line-height: 20px;\n`\n"]}
1
+ {"version":3,"file":"SupportMessage.js","sourceRoot":"","sources":["../../src/SupportMessage/SupportMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAA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CAAC,CAAA;AAOD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CACzB,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;wBAEhB,gBAAgB;;MAElC,OAAO,IAAI,iBAAiB;;;;;;;QAO1B,OAAO,IAAI,qBAAqB,MAAM,CAAC,GAAG,EAAE,gBAAgB,CAAC,GAAG;;GAErE,CACF,CAAA;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;;iBAEL,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;WACjC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;;;CAG9C,CAAA;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;CAGjC,CAAA;AAED,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;CAG/B,CAAA","sourcesContent":["import { darken } from 'polished'\nimport { FC, MouseEventHandler, ReactElement } from 'react'\nimport styled, { css, useTheme } from 'styled-components'\n\nimport { Box } from '../Box'\n\nimport { Text } from '../Text'\nimport { theme as oldTheme } from '../theme'\nimport { isReactElement } from '../utils/isReactElement'\nimport { MarginProps } from '../utils/space'\nimport { NewColor, resolveToThemeColor } from '../ThemeProvider/utils/colourMap'\nimport { IconDefinition } from '@fortawesome/fontawesome-svg-core'\nimport {\n faCircleCheck,\n faCircleExclamation,\n faCircleInfo,\n faTriangleExclamation,\n} from '@awesome.me/kit-46ca99185c/icons/classic/regular'\nimport { IconContainer } from '../sharedStyles/shared.styles'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { faChevronRight } from '@awesome.me/kit-46ca99185c/icons/classic/solid'\n\ntype StylesItem = {\n iconColor: NewColor\n backgroundColor: NewColor\n icon: IconDefinition\n}\n\nconst styles: Record<SupportMessageType, StylesItem> = {\n info: {\n iconColor: 'color.icon.base',\n backgroundColor: 'color.illustration.neutral.300',\n icon: faCircleInfo,\n },\n fallbackStyle: {\n iconColor: 'color.icon.base',\n backgroundColor: 'color.surface.base.100',\n icon: faCircleInfo,\n },\n alert: {\n iconColor: 'extended1.100',\n backgroundColor: 'color.feedback.notice.100',\n icon: faTriangleExclamation,\n },\n warning: {\n iconColor: 'color.feedback.negative.200',\n backgroundColor: 'color.feedback.negative.100',\n icon: faCircleExclamation,\n },\n success: {\n iconColor: 'color.feedback.positive.200',\n backgroundColor: 'color.feedback.positive.100',\n icon: faCircleCheck,\n },\n}\n\ntype SupportMessageType =\n | 'info'\n | 'fallbackStyle'\n | 'alert'\n | 'warning'\n | 'success'\n\nexport type SupportMessageProps = {\n className?: string\n description: string | ReactElement<any>\n onClick?: MouseEventHandler\n /**\n * Right side content, usually an icon or a button\n */\n rightSideComponent?: ReactElement<any>\n type: SupportMessageType\n title?: string\n} & MarginProps\n\nexport const SupportMessage: FC<SupportMessageProps> = ({\n className,\n description,\n onClick,\n rightSideComponent,\n type,\n title,\n ...marginProps\n}) => {\n const theme = useTheme()\n const resolveBackgroundColor = resolveToThemeColor(\n styles[type].backgroundColor,\n theme,\n )\n\n const resolvedIconColor = resolveToThemeColor(styles[type].iconColor, theme)\n\n return (\n <Wrapper\n className={className}\n $backgroundColor={resolveBackgroundColor}\n onClick={onClick}\n {...marginProps}\n >\n <IconContainer $size={20} style={{ alignSelf: 'flex-start' }}>\n <FontAwesomeIcon icon={styles[type].icon} color={resolvedIconColor} />\n </IconContainer>\n <Box flex direction=\"column\" mx=\"8px\">\n {title && <Title>{title}</Title>}\n {isReactElement(description) ? (\n <DescriptionBox>{description}</DescriptionBox>\n ) : (\n <Description tag=\"p\">{description}</Description>\n )}\n </Box>\n {rightSideComponent}\n {onClick && rightSideComponent === undefined && (\n <Box ml={{ custom: 'auto' }}>\n <IconContainer $size={16}>\n <FontAwesomeIcon\n icon={faChevronRight}\n color={theme.color.illustration.neutral[400]}\n />\n </IconContainer>\n </Box>\n )}\n </Wrapper>\n )\n}\n\ninterface IWrapper {\n $backgroundColor: string\n onClick?: MouseEventHandler\n}\n\nconst Wrapper = styled(Box)<IWrapper>(\n ({ $backgroundColor, onClick }) => css`\n align-items: center;\n background-color: ${$backgroundColor};\n border-radius: 16px;\n ${onClick && `cursor: pointer`};\n padding: 12px;\n display: flex;\n width: 100%;\n\n &:hover,\n &:active {\n ${onClick && `background-color: ${darken(0.1, $backgroundColor)};`};\n }\n `,\n)\n\nconst Title = styled.p`\n font-size: 16px;\n font-weight: ${oldTheme.font.weight.medium};\n color: ${({ theme }) => theme.color.text.base};\n line-height: 20.8px;\n margin-bottom: 4px;\n`\n\nconst DescriptionBox = styled(Box)`\n font-size: 14px;\n line-height: 20px;\n`\n\nconst Description = styled(Text)`\n font-size: 14px;\n line-height: 20px;\n`\n"]}
@@ -1,2 +1,3 @@
1
1
  export * from './Table';
2
+ export type * from './types';
2
3
  export * from './components/TableRow';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA","sourcesContent":["export * from './Table'\nexport * from './components/TableRow'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AAEvB,cAAc,uBAAuB,CAAA","sourcesContent":["export * from './Table'\nexport type * from './types'\nexport * from './components/TableRow'\n"]}
package/dist/Tag/Tag.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  import { MarginProps } from '../utils/space';
3
- import { Icons } from 'Icon/iconsList';
3
+ import { Icons } from '../Icon';
4
4
  import { ColorTypes } from '../ThemeProvider/utils/colourMap';
5
5
  export type TagProps = {
6
6
  label: string;
@@ -9,6 +9,7 @@ export type TagProps = {
9
9
  borderColor?: ColorTypes;
10
10
  className?: string;
11
11
  icon?: Icons;
12
+ iconComponent?: ReactNode;
12
13
  iconColor?: ColorTypes;
13
14
  onClick?: () => void;
14
15
  } & MarginProps;
package/dist/Tag/Tag.js CHANGED
@@ -4,11 +4,13 @@ import { Box } from '../Box';
4
4
  import { Text } from '../Text';
5
5
  import { Icon } from '../Icon';
6
6
  import { getColorPath, resolveToThemeColor, } from '../ThemeProvider/utils/colourMap';
7
- export const Tag = ({ label, color, borderColor, bgColor, className, icon, iconColor, onClick, ...marginProps }) => {
7
+ import { IconContainer } from '../sharedStyles/shared.styles';
8
+ export const Tag = ({ label, color, borderColor, bgColor, className, icon, iconComponent, iconColor, onClick, ...marginProps }) => {
8
9
  const theme = useTheme();
9
10
  const resolvedBGColor = resolveToThemeColor(bgColor, theme);
10
11
  const resolvedBorderColor = borderColor && resolveToThemeColor(borderColor, theme);
11
- return (_jsxs(Wrapper, { "$bgColor": resolvedBGColor, className: className, "$borderColor": resolvedBorderColor, ...marginProps, alignContent: "center", justifyContent: "center", onClick: onClick, children: [icon && (_jsx(TagIcon, { render: icon, color: iconColor, size: 16, "data-testid": `tag-icon-${icon}` })), _jsx(TagText, { tag: "span", typo: "label", color: getColorPath(color), children: label })] }));
12
+ const iconToRender = iconComponent ? (_jsx(IconContainer, { "$size": 16, style: { paddingRight: '4px' }, children: iconComponent })) : icon ? (_jsx(TagIcon, { render: icon, color: iconColor, size: 16, "data-testid": `tag-icon-${icon}` })) : null;
13
+ return (_jsxs(Wrapper, { "$bgColor": resolvedBGColor, className: className, "$borderColor": resolvedBorderColor, ...marginProps, alignContent: "center", justifyContent: "center", onClick: onClick, children: [iconToRender, _jsx(TagText, { tag: "span", typo: "label", color: getColorPath(color), children: label })] }));
12
14
  };
13
15
  const Wrapper = styled(Box) `
14
16
  background-color: ${({ $bgColor }) => $bgColor};
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../src/Tag/Tag.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE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AE,CAAC,YAAY,IAAI,aAAa,YAAY,EAAE;;;;;;;;;CAS5E,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;;CAO3B,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAE3B,CAAA","sourcesContent":["import { FC } from 'react'\nimport styled, { useTheme } from 'styled-components'\nimport { MarginProps } from '../utils/space'\n\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { Icon } from '../Icon'\nimport { Icons } from 'Icon/iconsList'\nimport {\n ColorTypes,\n getColorPath,\n resolveToThemeColor,\n} from '../ThemeProvider/utils/colourMap'\n\nexport type TagProps = {\n label: string\n color: ColorTypes\n bgColor: ColorTypes\n borderColor?: ColorTypes\n className?: string\n icon?: Icons\n iconColor?: ColorTypes\n onClick?: () => void\n} & MarginProps\n\nexport const Tag: FC<TagProps> = ({\n label,\n color,\n borderColor,\n bgColor,\n className,\n icon,\n iconColor,\n onClick,\n ...marginProps\n}) => {\n const theme = useTheme()\n\n const resolvedBGColor = resolveToThemeColor(bgColor, theme)\n const resolvedBorderColor =\n borderColor && resolveToThemeColor(borderColor, theme)\n\n return (\n <Wrapper\n $bgColor={resolvedBGColor}\n className={className}\n $borderColor={resolvedBorderColor}\n {...marginProps}\n alignContent=\"center\"\n justifyContent=\"center\"\n onClick={onClick}\n >\n {icon && (\n <TagIcon\n render={icon}\n color={iconColor}\n size={16}\n data-testid={`tag-icon-${icon}`}\n />\n )}\n <TagText tag=\"span\" typo=\"label\" color={getColorPath(color)}>\n {label}\n </TagText>\n </Wrapper>\n )\n}\n\ntype WrapperProps = TransientProps<{\n bgColor: string\n borderColor?: string\n}>\n\nconst Wrapper = styled(Box)<WrapperProps>`\n background-color: ${({ $bgColor }) => $bgColor};\n border: ${({ $borderColor }) => $borderColor && `1px solid ${$borderColor}`};\n\n border-radius: 6px;\n padding: 4px 8px;\n\n height: 22px;\n\n box-sizing: border-box;\n display: inline-flex;\n`\n\nconst TagText = styled(Text)`\n display: flex;\n align-items: center;\n font-size: 10px;\n font-weight: 500;\n line-height: 12px;\n text-transform: uppercase;\n`\n\nconst TagIcon = styled(Icon)`\n padding-right: 4px;\n`\n"]}
1
+ {"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../src/Tag/Tag.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAIpD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAS,MAAM,SAAS,CAAA;AACrC,OAAO,EAEL,YAAY,EACZ,mBAAmB,GACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAc7D,MAAM,CAAC,MAAM,GAAG,GAAiB,CAAC,EAChC,KAAK,EACL,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,IAAI,EACJ,aAAa,EACb,SAAS,EACT,OAAO,EACP,GAAG,WAAW,EACf,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3D,MAAM,mBAAmB,GACvB,WAAW,IAAI,mBAAmB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;IAExD,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CACnC,KAAC,aAAa,aAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,YACrD,aAAa,GACA,CACjB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACT,KAAC,OAAO,IACN,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,EAAE,iBACK,YAAY,IAAI,EAAE,GAC/B,CACH,CAAC,CAAC,CAAC,IAAI,CAAA;IAER,OAAO,CACL,MAAC,OAAO,gBACI,eAAe,EACzB,SAAS,EAAE,SAAS,kBACN,mBAAmB,KAC7B,WAAW,EACf,YAAY,EAAC,QAAQ,EACrB,cAAc,EAAC,QAAQ,EACvB,OAAO,EAAE,OAAO,aAEf,YAAY,EACb,KAAC,OAAO,IAAC,GAAG,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,YACxD,KAAK,GACE,IACF,CACX,CAAA;AACH,CAAC,CAAA;AAOD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAc;sBACnB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;YACpC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,IAAI,aAAa,YAAY,EAAE;;;;;;;;;CAS5E,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;;CAO3B,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;CAE3B,CAAA","sourcesContent":["import { FC, ReactNode } from 'react'\nimport styled, { useTheme } from 'styled-components'\nimport { MarginProps } from '../utils/space'\n\nimport { TransientProps } from 'utils/utilTypes'\nimport { Box } from '../Box'\nimport { Text } from '../Text'\nimport { Icon, Icons } from '../Icon'\nimport {\n ColorTypes,\n getColorPath,\n resolveToThemeColor,\n} from '../ThemeProvider/utils/colourMap'\nimport { IconContainer } from '../sharedStyles/shared.styles'\n\nexport type TagProps = {\n label: string\n color: ColorTypes\n bgColor: ColorTypes\n borderColor?: ColorTypes\n className?: string\n icon?: Icons\n iconComponent?: ReactNode\n iconColor?: ColorTypes\n onClick?: () => void\n} & MarginProps\n\nexport const Tag: FC<TagProps> = ({\n label,\n color,\n borderColor,\n bgColor,\n className,\n icon,\n iconComponent,\n iconColor,\n onClick,\n ...marginProps\n}) => {\n const theme = useTheme()\n\n const resolvedBGColor = resolveToThemeColor(bgColor, theme)\n const resolvedBorderColor =\n borderColor && resolveToThemeColor(borderColor, theme)\n\n const iconToRender = iconComponent ? (\n <IconContainer $size={16} style={{ paddingRight: '4px' }}>\n {iconComponent}\n </IconContainer>\n ) : icon ? (\n <TagIcon\n render={icon}\n color={iconColor}\n size={16}\n data-testid={`tag-icon-${icon}`}\n />\n ) : null\n\n return (\n <Wrapper\n $bgColor={resolvedBGColor}\n className={className}\n $borderColor={resolvedBorderColor}\n {...marginProps}\n alignContent=\"center\"\n justifyContent=\"center\"\n onClick={onClick}\n >\n {iconToRender}\n <TagText tag=\"span\" typo=\"label\" color={getColorPath(color)}>\n {label}\n </TagText>\n </Wrapper>\n )\n}\n\ntype WrapperProps = TransientProps<{\n bgColor: string\n borderColor?: string\n}>\n\nconst Wrapper = styled(Box)<WrapperProps>`\n background-color: ${({ $bgColor }) => $bgColor};\n border: ${({ $borderColor }) => $borderColor && `1px solid ${$borderColor}`};\n\n border-radius: 6px;\n padding: 4px 8px;\n\n height: 22px;\n\n box-sizing: border-box;\n display: inline-flex;\n`\n\nconst TagText = styled(Text)`\n display: flex;\n align-items: center;\n font-size: 10px;\n font-weight: 500;\n line-height: 12px;\n text-transform: uppercase;\n`\n\nconst TagIcon = styled(Icon)`\n padding-right: 4px;\n`\n"]}
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render, screen } from '../testUtils';
3
3
  import { it, expect } from 'vitest';
4
4
  import { Tag } from '../Tag';
5
+ const CustomIcon = () => _jsx("span", { "data-testid": "tag-custom-icon" });
5
6
  describe('Tag Component', () => {
6
7
  it('renders snapshot test correctly', () => {
7
8
  const { container } = render(_jsx(Tag, { label: "Snapshot Test Tag", color: "color.illustration.neutral.400", bgColor: "extended1.20" }));
@@ -41,6 +42,15 @@ describe('Tag Component', () => {
41
42
  });
42
43
  });
43
44
  });
45
+ it('renders a custom icon component when provided', () => {
46
+ render(_jsx(Tag, { label: "Tag with Custom Icon", color: "apple", bgColor: "chia", icon: "flag", iconComponent: _jsx(CustomIcon, {}) }));
47
+ expect(screen.getByTestId('tag-custom-icon')).toBeInTheDocument();
48
+ expect(screen.queryByTestId('tag-icon-flag')).not.toBeInTheDocument();
49
+ });
50
+ it('renders without an icon when none is provided', () => {
51
+ const { container } = render(_jsx(Tag, { label: "Tag without Icon", color: "apple", bgColor: "chia" }));
52
+ expect(container.querySelector('[data-testid$="-icon"]')).toBeNull();
53
+ });
44
54
  });
45
55
  const testCases = [
46
56
  {