carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 3.58 kB
JavaScript
import{jsx as e,jsxs as t}from"react/jsx-runtime";import o from"react";import n from"invariant";import{StyledNote as r,StyledNoteMain as i,StyledNoteContent as a,StyledTitleWrapper as p,StyledInlineControl as c,StyledFooter as l,StyledFooterContent as m}from"./note.style.js";import s from"./__internal__/status-icon/status-icon.component.js";import{ActionPopover as d}from"../action-popover/action-popover.component.js";import"../action-popover/action-popover-menu/action-popover-menu.component.js";import"../action-popover/action-popover-item/action-popover-item.component.js";import"../action-popover/action-popover-menu-button/action-popover-menu-button.component.js";import"../action-popover/action-popover-divider/action-popover-divider.component.js";import u from"../text-editor/__internal__/__ui__/ReadOnlyEditor/read-only-rte.component.js";import f from"../text-editor/text-editor.context.js";import{LinkPreview as h}from"../link-preview/link-preview.component.js";import{Typography as v}from"../typography/typography.component.js";import y from"../../__internal__/utils/helpers/tags/tags.js";function b(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function j(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),n.forEach((function(t){b(e,t,o[t])}))}return e}const O=b=>{var O,g,{"aria-label":w,createdDate:P,inlineControl:_,name:x,noteContent:k,onLinkAdded:C,previews:S,status:E,title:N,width:D=100}=b,A=function(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||(r[o]=e[o]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}(b,["aria-label","createdDate","inlineControl","name","noteContent","onLinkAdded","previews","status","title","width"]);return n(D>0,"<Note> width must be greater than 0"),n(!_||o.isValidElement(_)&&_.type===d,"<Note> inlineControl must be an instance of <ActionPopover>"),e(f.Provider,{value:{onLinkAdded:C},children:t(r,(O=j({width:D},A,y("note",A)),g={children:[t(i,{children:[t(a,{children:[N&&("string"==typeof N?e(v,{"data-role":"note-title",fontWeight:"700",fontSize:"16px",lineHeight:"21px",paddingBottom:"16px",variant:"h3",children:N}):e(p,{children:N})),e(u,{"aria-label":w,initialValue:k,useBackgroundColor:!1})]}),_&&e(c,{children:_})]}),e(a,{children:o.Children.map(S,(e=>{return o.isValidElement(e)&&(t=e,n=h.displayName,t.type.displayName===n)?o.cloneElement(e,{as:"a",onClose:void 0}):e;var t,n}))}),P&&e(a,{hasPreview:!!o.Children.count(S),children:t(l,{"data-element":"note-footer",children:[x&&e(m,{hasName:!!x,children:x}),e(m,{hasName:!!x,children:P}),(()=>{if(!E)return null;const{text:t,timeStamp:o}=E;return e(m,{hasName:!!x,"data-component":"note-status",children:e(s,{tooltipMessage:o,children:t})})})()]})})]},g=null!=g?g:{},Object.getOwnPropertyDescriptors?Object.defineProperties(O,Object.getOwnPropertyDescriptors(g)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(g)).forEach((function(e){Object.defineProperty(O,e,Object.getOwnPropertyDescriptor(g,e))})),O))})};export{O as Note,O as default};