@webiny/app-aco 0.0.0-unstable.2af142b57e → 0.0.0-unstable.60a863e033
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Tree/ButtonCreate/styled.d.ts +3 -3
- package/contexts/links.d.ts +18 -0
- package/contexts/links.js +371 -0
- package/contexts/links.js.map +1 -0
- package/graphql/links.gql.d.ts +5 -0
- package/graphql/links.gql.js +34 -0
- package/graphql/links.gql.js.map +1 -0
- package/hooks/useLinks.d.ts +20 -0
- package/hooks/useLinks.js +65 -0
- package/hooks/useLinks.js.map +1 -0
- package/package.json +9 -9
|
@@ -7,12 +7,12 @@ export declare const Icon: import("@emotion/styled-base").StyledComponent<Pick<i
|
|
|
7
7
|
alt?: string | undefined;
|
|
8
8
|
} & {
|
|
9
9
|
children?: import("react").ReactNode;
|
|
10
|
-
}, "string" | "
|
|
10
|
+
}, "string" | "id" | "type" | "children" | "style" | "clipPath" | "filter" | "mask" | "path" | "fill" | "values" | "className" | "key" | "color" | "cursor" | "direction" | "display" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "width" | "wordSpacing" | "writingMode" | "offset" | "overflow" | "textDecoration" | "azimuth" | "clip" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "onSubmit" | "onClick" | "name" | "onChange" | "onInput" | "onFocus" | "lang" | "tabIndex" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "href" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "local" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan" | "alt"> & {
|
|
11
11
|
ref?: ((instance: SVGSVGElement | null) => void) | import("react").RefObject<SVGSVGElement> | null | undefined;
|
|
12
12
|
}, Pick<Pick<import("react").SVGProps<SVGSVGElement> & {
|
|
13
13
|
alt?: string | undefined;
|
|
14
14
|
} & {
|
|
15
15
|
children?: import("react").ReactNode;
|
|
16
|
-
}, "string" | "
|
|
16
|
+
}, "string" | "id" | "type" | "children" | "style" | "clipPath" | "filter" | "mask" | "path" | "fill" | "values" | "className" | "key" | "color" | "cursor" | "direction" | "display" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "width" | "wordSpacing" | "writingMode" | "offset" | "overflow" | "textDecoration" | "azimuth" | "clip" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "onSubmit" | "onClick" | "name" | "onChange" | "onInput" | "onFocus" | "lang" | "tabIndex" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "href" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "local" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan" | "alt"> & {
|
|
17
17
|
ref?: ((instance: SVGSVGElement | null) => void) | import("react").RefObject<SVGSVGElement> | null | undefined;
|
|
18
|
-
}, "string" | "
|
|
18
|
+
}, "string" | "id" | "type" | "children" | "style" | "clipPath" | "filter" | "mask" | "path" | "fill" | "values" | "className" | "color" | "cursor" | "direction" | "display" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "width" | "wordSpacing" | "writingMode" | "offset" | "overflow" | "textDecoration" | "azimuth" | "clip" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "onSubmit" | "onClick" | "name" | "onChange" | "onInput" | "onFocus" | "lang" | "tabIndex" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "href" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "local" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan" | "alt">, object>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { LinkItem, ListMeta, Loading, LoadingActions, Meta } from "../types";
|
|
3
|
+
interface LinksContext {
|
|
4
|
+
links: LinkItem[];
|
|
5
|
+
loading: Loading<LoadingActions>;
|
|
6
|
+
meta: Meta<ListMeta>;
|
|
7
|
+
listLinks: (type: string, limit?: number, after?: string) => Promise<LinkItem[]>;
|
|
8
|
+
getLink: (id: string, folderId: string) => Promise<LinkItem>;
|
|
9
|
+
createLink: (link: Omit<LinkItem, "linkId">) => Promise<LinkItem>;
|
|
10
|
+
updateLink: (link: LinkItem, contextFolderId: string) => Promise<LinkItem>;
|
|
11
|
+
deleteLink(link: LinkItem): Promise<true>;
|
|
12
|
+
}
|
|
13
|
+
export declare const LinksContext: React.Context<LinksContext | undefined>;
|
|
14
|
+
interface Props {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export declare const LinksProvider: ({ children }: Props) => JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.LinksProvider = exports.LinksContext = void 0;
|
|
11
|
+
|
|
12
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _objectSpread5 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
|
+
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
+
|
|
20
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
21
|
+
|
|
22
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
+
|
|
26
|
+
var _reactHooks = require("@apollo/react-hooks");
|
|
27
|
+
|
|
28
|
+
var _handlers = require("../handlers");
|
|
29
|
+
|
|
30
|
+
var _links = require("../graphql/links.gql");
|
|
31
|
+
|
|
32
|
+
var LinksContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
33
|
+
|
|
34
|
+
exports.LinksContext = LinksContext;
|
|
35
|
+
var defaultLoading = {
|
|
36
|
+
INIT: true,
|
|
37
|
+
LIST: false,
|
|
38
|
+
LIST_MORE: false,
|
|
39
|
+
GET: false,
|
|
40
|
+
CREATE: false,
|
|
41
|
+
UPDATE: false,
|
|
42
|
+
DELETE: false
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var LinksProvider = function LinksProvider(_ref) {
|
|
46
|
+
var children = _ref.children;
|
|
47
|
+
var client = (0, _reactHooks.useApolloClient)();
|
|
48
|
+
|
|
49
|
+
var _useState = (0, _react.useState)([]),
|
|
50
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
|
+
links = _useState2[0],
|
|
52
|
+
setLinks = _useState2[1];
|
|
53
|
+
|
|
54
|
+
var _useState3 = (0, _react.useState)(defaultLoading),
|
|
55
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
56
|
+
loading = _useState4[0],
|
|
57
|
+
setLoading = _useState4[1];
|
|
58
|
+
|
|
59
|
+
var _useState5 = (0, _react.useState)(Object.create(null)),
|
|
60
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
61
|
+
meta = _useState6[0],
|
|
62
|
+
setMeta = _useState6[1];
|
|
63
|
+
|
|
64
|
+
var context = {
|
|
65
|
+
links: links,
|
|
66
|
+
loading: loading,
|
|
67
|
+
meta: meta,
|
|
68
|
+
listLinks: function listLinks(folderId) {
|
|
69
|
+
var _arguments = arguments;
|
|
70
|
+
return (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
71
|
+
var limit, after, action, _yield$apolloFetching, response, _response$folders$lis, data, responseMeta, error;
|
|
72
|
+
|
|
73
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
74
|
+
while (1) {
|
|
75
|
+
switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
limit = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : 10;
|
|
78
|
+
after = _arguments.length > 2 ? _arguments[2] : undefined;
|
|
79
|
+
|
|
80
|
+
if (folderId) {
|
|
81
|
+
_context.next = 4;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
throw new Error("Link `folderId` is mandatory");
|
|
86
|
+
|
|
87
|
+
case 4:
|
|
88
|
+
action = after ? "LIST_MORE" : "LIST";
|
|
89
|
+
_context.next = 7;
|
|
90
|
+
return (0, _handlers.apolloFetchingHandler)((0, _handlers.loadingHandler)(action, setLoading), function () {
|
|
91
|
+
return client.query({
|
|
92
|
+
query: _links.LIST_LINKS,
|
|
93
|
+
variables: {
|
|
94
|
+
folderId: folderId,
|
|
95
|
+
limit: limit,
|
|
96
|
+
after: after
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
case 7:
|
|
102
|
+
_yield$apolloFetching = _context.sent;
|
|
103
|
+
response = _yield$apolloFetching.data;
|
|
104
|
+
_response$folders$lis = response.folders.listLinks, data = _response$folders$lis.data, responseMeta = _response$folders$lis.meta, error = _response$folders$lis.error;
|
|
105
|
+
|
|
106
|
+
if (!(!data || !responseMeta)) {
|
|
107
|
+
_context.next = 12;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
throw new Error((error === null || error === void 0 ? void 0 : error.message) || "Could not fetch links");
|
|
112
|
+
|
|
113
|
+
case 12:
|
|
114
|
+
setLinks(function (links) {
|
|
115
|
+
return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(links), (0, _toConsumableArray2.default)(data))));
|
|
116
|
+
});
|
|
117
|
+
setMeta(function (meta) {
|
|
118
|
+
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, meta), {}, (0, _defineProperty2.default)({}, folderId, responseMeta));
|
|
119
|
+
});
|
|
120
|
+
setLoading(function (prev) {
|
|
121
|
+
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, prev), {}, {
|
|
122
|
+
INIT: false
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
return _context.abrupt("return", data);
|
|
126
|
+
|
|
127
|
+
case 16:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context.stop();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, _callee);
|
|
133
|
+
}))();
|
|
134
|
+
},
|
|
135
|
+
getLink: function getLink(id) {
|
|
136
|
+
return (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
137
|
+
var _yield$apolloFetching2, response, _response$folders$get, data, error;
|
|
138
|
+
|
|
139
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
140
|
+
while (1) {
|
|
141
|
+
switch (_context2.prev = _context2.next) {
|
|
142
|
+
case 0:
|
|
143
|
+
if (id) {
|
|
144
|
+
_context2.next = 2;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
throw new Error("Link `id` is mandatory");
|
|
149
|
+
|
|
150
|
+
case 2:
|
|
151
|
+
_context2.next = 4;
|
|
152
|
+
return (0, _handlers.apolloFetchingHandler)((0, _handlers.loadingHandler)("GET", setLoading), function () {
|
|
153
|
+
return client.query({
|
|
154
|
+
query: _links.GET_LINK,
|
|
155
|
+
variables: {
|
|
156
|
+
id: id
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
case 4:
|
|
162
|
+
_yield$apolloFetching2 = _context2.sent;
|
|
163
|
+
response = _yield$apolloFetching2.data;
|
|
164
|
+
_response$folders$get = response.folders.getLink, data = _response$folders$get.data, error = _response$folders$get.error;
|
|
165
|
+
|
|
166
|
+
if (data) {
|
|
167
|
+
_context2.next = 9;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
throw new Error((error === null || error === void 0 ? void 0 : error.message) || "Could not fetch link with id: ".concat(id));
|
|
172
|
+
|
|
173
|
+
case 9:
|
|
174
|
+
return _context2.abrupt("return", data);
|
|
175
|
+
|
|
176
|
+
case 10:
|
|
177
|
+
case "end":
|
|
178
|
+
return _context2.stop();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, _callee2);
|
|
182
|
+
}))();
|
|
183
|
+
},
|
|
184
|
+
createLink: function createLink(link) {
|
|
185
|
+
return (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
|
|
186
|
+
var folderId, _yield$apolloFetching3, response, _response$folders$cre, data, error;
|
|
187
|
+
|
|
188
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
189
|
+
while (1) {
|
|
190
|
+
switch (_context3.prev = _context3.next) {
|
|
191
|
+
case 0:
|
|
192
|
+
folderId = link.folderId;
|
|
193
|
+
_context3.next = 3;
|
|
194
|
+
return (0, _handlers.apolloFetchingHandler)((0, _handlers.loadingHandler)("CREATE", setLoading), function () {
|
|
195
|
+
return client.mutate({
|
|
196
|
+
mutation: _links.CREATE_LINK,
|
|
197
|
+
variables: {
|
|
198
|
+
data: link
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
case 3:
|
|
204
|
+
_yield$apolloFetching3 = _context3.sent;
|
|
205
|
+
response = _yield$apolloFetching3.data;
|
|
206
|
+
|
|
207
|
+
if (response) {
|
|
208
|
+
_context3.next = 7;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
throw new Error("Network error while creating link");
|
|
213
|
+
|
|
214
|
+
case 7:
|
|
215
|
+
_response$folders$cre = response.folders.createLink, data = _response$folders$cre.data, error = _response$folders$cre.error;
|
|
216
|
+
|
|
217
|
+
if (data) {
|
|
218
|
+
_context3.next = 10;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
throw new Error((error === null || error === void 0 ? void 0 : error.message) || "Could not create link");
|
|
223
|
+
|
|
224
|
+
case 10:
|
|
225
|
+
setLinks(function (links) {
|
|
226
|
+
return [].concat((0, _toConsumableArray2.default)(links), [data]);
|
|
227
|
+
});
|
|
228
|
+
setMeta(function (meta) {
|
|
229
|
+
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, meta), {}, (0, _defineProperty2.default)({}, folderId, (0, _objectSpread5.default)((0, _objectSpread5.default)({}, meta[folderId]), {}, {
|
|
230
|
+
totalCount: ++meta[folderId].totalCount
|
|
231
|
+
})));
|
|
232
|
+
});
|
|
233
|
+
return _context3.abrupt("return", data);
|
|
234
|
+
|
|
235
|
+
case 13:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context3.stop();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, _callee3);
|
|
241
|
+
}))();
|
|
242
|
+
},
|
|
243
|
+
updateLink: function updateLink(link, contextFolderId) {
|
|
244
|
+
return (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
|
|
245
|
+
var id, folderId, _yield$apolloFetching4, response, _response$folders$upd, data, error;
|
|
246
|
+
|
|
247
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
248
|
+
while (1) {
|
|
249
|
+
switch (_context4.prev = _context4.next) {
|
|
250
|
+
case 0:
|
|
251
|
+
id = link.id, folderId = link.folderId;
|
|
252
|
+
_context4.next = 3;
|
|
253
|
+
return (0, _handlers.apolloFetchingHandler)((0, _handlers.loadingHandler)("UPDATE", setLoading), function () {
|
|
254
|
+
return client.mutate({
|
|
255
|
+
mutation: _links.UPDATE_LINK,
|
|
256
|
+
variables: {
|
|
257
|
+
id: id,
|
|
258
|
+
data: {
|
|
259
|
+
folderId: folderId
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
case 3:
|
|
266
|
+
_yield$apolloFetching4 = _context4.sent;
|
|
267
|
+
response = _yield$apolloFetching4.data;
|
|
268
|
+
|
|
269
|
+
if (response) {
|
|
270
|
+
_context4.next = 7;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
throw new Error("Network error while updating link");
|
|
275
|
+
|
|
276
|
+
case 7:
|
|
277
|
+
_response$folders$upd = response.folders.updateLink, data = _response$folders$upd.data, error = _response$folders$upd.error;
|
|
278
|
+
|
|
279
|
+
if (data) {
|
|
280
|
+
_context4.next = 10;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
throw new Error((error === null || error === void 0 ? void 0 : error.message) || "Could not update link");
|
|
285
|
+
|
|
286
|
+
case 10:
|
|
287
|
+
setLinks(function (links) {
|
|
288
|
+
return links.map(function (link) {
|
|
289
|
+
return link.id === id ? data : link;
|
|
290
|
+
}).filter(function (link) {
|
|
291
|
+
return link.folderId === contextFolderId;
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
return _context4.abrupt("return", data);
|
|
295
|
+
|
|
296
|
+
case 12:
|
|
297
|
+
case "end":
|
|
298
|
+
return _context4.stop();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}, _callee4);
|
|
302
|
+
}))();
|
|
303
|
+
},
|
|
304
|
+
deleteLink: function deleteLink(link) {
|
|
305
|
+
return (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5() {
|
|
306
|
+
var id, folderId, _yield$apolloFetching5, response, _response$folders$del, data, error;
|
|
307
|
+
|
|
308
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
|
|
309
|
+
while (1) {
|
|
310
|
+
switch (_context5.prev = _context5.next) {
|
|
311
|
+
case 0:
|
|
312
|
+
id = link.id, folderId = link.folderId;
|
|
313
|
+
_context5.next = 3;
|
|
314
|
+
return (0, _handlers.apolloFetchingHandler)((0, _handlers.loadingHandler)("DELETE", setLoading), function () {
|
|
315
|
+
return client.mutate({
|
|
316
|
+
mutation: _links.DELETE_LINK,
|
|
317
|
+
variables: {
|
|
318
|
+
id: id
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
case 3:
|
|
324
|
+
_yield$apolloFetching5 = _context5.sent;
|
|
325
|
+
response = _yield$apolloFetching5.data;
|
|
326
|
+
|
|
327
|
+
if (response) {
|
|
328
|
+
_context5.next = 7;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
throw new Error("Network error while deleting link");
|
|
333
|
+
|
|
334
|
+
case 7:
|
|
335
|
+
_response$folders$del = response.folders.deleteLink, data = _response$folders$del.data, error = _response$folders$del.error;
|
|
336
|
+
|
|
337
|
+
if (data) {
|
|
338
|
+
_context5.next = 10;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
throw new Error((error === null || error === void 0 ? void 0 : error.message) || "Could not delete link");
|
|
343
|
+
|
|
344
|
+
case 10:
|
|
345
|
+
setLinks(function (links) {
|
|
346
|
+
return links.filter(function (link) {
|
|
347
|
+
return link.id !== id;
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
setMeta(function (meta) {
|
|
351
|
+
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, meta), {}, (0, _defineProperty2.default)({}, folderId, (0, _objectSpread5.default)((0, _objectSpread5.default)({}, meta[folderId]), {}, {
|
|
352
|
+
totalCount: --meta[folderId].totalCount
|
|
353
|
+
})));
|
|
354
|
+
});
|
|
355
|
+
return _context5.abrupt("return", true);
|
|
356
|
+
|
|
357
|
+
case 13:
|
|
358
|
+
case "end":
|
|
359
|
+
return _context5.stop();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}, _callee5);
|
|
363
|
+
}))();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return /*#__PURE__*/_react.default.createElement(LinksContext.Provider, {
|
|
367
|
+
value: context
|
|
368
|
+
}, children);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
exports.LinksProvider = LinksProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LinksContext","React","createContext","undefined","defaultLoading","INIT","LIST","LIST_MORE","GET","CREATE","UPDATE","DELETE","LinksProvider","children","client","useApolloClient","useState","links","setLinks","loading","setLoading","Object","create","meta","setMeta","context","listLinks","folderId","limit","after","Error","action","apolloFetchingHandler","loadingHandler","query","LIST_LINKS","variables","response","data","folders","responseMeta","error","message","Set","prev","getLink","id","GET_LINK","createLink","link","mutate","mutation","CREATE_LINK","totalCount","updateLink","contextFolderId","UPDATE_LINK","map","filter","deleteLink","DELETE_LINK"],"sources":["links.tsx"],"sourcesContent":["import React, { ReactNode, useState } from \"react\";\nimport { useApolloClient } from \"@apollo/react-hooks\";\n\nimport { apolloFetchingHandler, loadingHandler } from \"~/handlers\";\n\nimport { CREATE_LINK, DELETE_LINK, GET_LINK, LIST_LINKS, UPDATE_LINK } from \"~/graphql/links.gql\";\n\nimport {\n CreateLinkResponse,\n CreateLinkVariables,\n DeleteLinkResponse,\n DeleteLinkVariables,\n GetLinkQueryVariables,\n GetLinkResponse,\n LinkItem,\n ListLinksQueryVariables,\n ListLinksResponse,\n ListMeta,\n Loading,\n LoadingActions,\n Meta,\n UpdateLinkResponse,\n UpdateLinkVariables\n} from \"~/types\";\n\ninterface LinksContext {\n links: LinkItem[];\n loading: Loading<LoadingActions>;\n meta: Meta<ListMeta>;\n listLinks: (type: string, limit?: number, after?: string) => Promise<LinkItem[]>;\n getLink: (id: string, folderId: string) => Promise<LinkItem>;\n createLink: (link: Omit<LinkItem, \"linkId\">) => Promise<LinkItem>;\n updateLink: (link: LinkItem, contextFolderId: string) => Promise<LinkItem>;\n deleteLink(link: LinkItem): Promise<true>;\n}\n\nexport const LinksContext = React.createContext<LinksContext | undefined>(undefined);\n\ninterface Props {\n children: ReactNode;\n}\n\nconst defaultLoading: Record<LoadingActions, boolean> = {\n INIT: true,\n LIST: false,\n LIST_MORE: false,\n GET: false,\n CREATE: false,\n UPDATE: false,\n DELETE: false\n};\n\nexport const LinksProvider = ({ children }: Props) => {\n const client = useApolloClient();\n const [links, setLinks] = useState<LinkItem[]>([]);\n const [loading, setLoading] = useState<Loading<LoadingActions>>(defaultLoading);\n const [meta, setMeta] = useState<Meta<ListMeta>>(Object.create(null));\n\n const context: LinksContext = {\n links,\n loading,\n meta,\n async listLinks(folderId: string, limit = 10, after?: string) {\n if (!folderId) {\n throw new Error(\"Link `folderId` is mandatory\");\n }\n\n const action = after ? \"LIST_MORE\" : \"LIST\";\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(action, setLoading),\n () =>\n client.query<ListLinksResponse, ListLinksQueryVariables>({\n query: LIST_LINKS,\n variables: { folderId, limit, after }\n })\n );\n\n const { data, meta: responseMeta, error } = response.folders.listLinks;\n\n if (!data || !responseMeta) {\n throw new Error(error?.message || \"Could not fetch links\");\n }\n\n setLinks(links => [...new Set([...links, ...data])]);\n\n setMeta(meta => ({\n ...meta,\n [folderId]: responseMeta\n }));\n\n setLoading(prev => {\n return {\n ...prev,\n INIT: false\n };\n });\n\n return data;\n },\n\n async getLink(id) {\n if (!id) {\n throw new Error(\"Link `id` is mandatory\");\n }\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"GET\", setLoading),\n () =>\n client.query<GetLinkResponse, GetLinkQueryVariables>({\n query: GET_LINK,\n variables: { id }\n })\n );\n\n const { data, error } = response.folders.getLink;\n\n if (!data) {\n throw new Error(error?.message || `Could not fetch link with id: ${id}`);\n }\n\n return data;\n },\n\n async createLink(link) {\n const { folderId } = link;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"CREATE\", setLoading),\n () =>\n client.mutate<CreateLinkResponse, CreateLinkVariables>({\n mutation: CREATE_LINK,\n variables: { data: link }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while creating link\");\n }\n\n const { data, error } = response.folders.createLink;\n\n if (!data) {\n throw new Error(error?.message || \"Could not create link\");\n }\n\n setLinks(links => [...links, data]);\n\n setMeta(meta => ({\n ...meta,\n [folderId]: {\n ...meta[folderId],\n totalCount: ++meta[folderId].totalCount\n }\n }));\n\n return data;\n },\n\n async updateLink(link, contextFolderId) {\n const { id, folderId } = link;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"UPDATE\", setLoading),\n () =>\n client.mutate<UpdateLinkResponse, UpdateLinkVariables>({\n mutation: UPDATE_LINK,\n variables: { id, data: { folderId } }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while updating link\");\n }\n\n const { data, error } = response.folders.updateLink;\n\n if (!data) {\n throw new Error(error?.message || \"Could not update link\");\n }\n\n setLinks(links =>\n links\n .map(link => (link.id === id ? data : link))\n .filter(link => link.folderId === contextFolderId)\n );\n\n return data;\n },\n\n async deleteLink(link) {\n const { id, folderId } = link;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"DELETE\", setLoading),\n () =>\n client.mutate<DeleteLinkResponse, DeleteLinkVariables>({\n mutation: DELETE_LINK,\n variables: { id }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while deleting link\");\n }\n\n const { data, error } = response.folders.deleteLink;\n\n if (!data) {\n throw new Error(error?.message || \"Could not delete link\");\n }\n\n setLinks(links => links.filter(link => link.id !== id));\n\n setMeta(meta => ({\n ...meta,\n [folderId]: {\n ...meta[folderId],\n totalCount: --meta[folderId].totalCount\n }\n }));\n\n return true;\n }\n };\n\n return <LinksContext.Provider value={context}>{children}</LinksContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AA+BO,IAAMA,YAAY,gBAAGC,cAAA,CAAMC,aAAN,CAA8CC,SAA9C,CAArB;;;AAMP,IAAMC,cAA+C,GAAG;EACpDC,IAAI,EAAE,IAD8C;EAEpDC,IAAI,EAAE,KAF8C;EAGpDC,SAAS,EAAE,KAHyC;EAIpDC,GAAG,EAAE,KAJ+C;EAKpDC,MAAM,EAAE,KAL4C;EAMpDC,MAAM,EAAE,KAN4C;EAOpDC,MAAM,EAAE;AAP4C,CAAxD;;AAUO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,OAAyB;EAAA,IAAtBC,QAAsB,QAAtBA,QAAsB;EAClD,IAAMC,MAAM,GAAG,IAAAC,2BAAA,GAAf;;EACA,gBAA0B,IAAAC,eAAA,EAAqB,EAArB,CAA1B;EAAA;EAAA,IAAOC,KAAP;EAAA,IAAcC,QAAd;;EACA,iBAA8B,IAAAF,eAAA,EAAkCZ,cAAlC,CAA9B;EAAA;EAAA,I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AC,UAAAD,IAAI;kBAAA,mEACLA,IADK,yCAEPI,QAFO,8DAGDJ,IAAI,CAACI,QAAD,CAHH;oBAIJ0B,UAAU,EAAE,EAAE9B,IAAI,CAACI,QAAD,CAAJ,CAAe0B;kBAJzB;gBAAA,CAAL,CAAP;gBAxBmB,kCAgCZ,IAhCY;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA;IAiCtB;EArKyB,CAA9B;EAwKA,oBAAO,6BAAC,YAAD,CAAc,QAAd;IAAuB,KAAK,EAAE5B;EAA9B,GAAwCZ,QAAxC,CAAP;AACH,CA/KM"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const CREATE_LINK: import("graphql").DocumentNode;
|
|
2
|
+
export declare const LIST_LINKS: import("graphql").DocumentNode;
|
|
3
|
+
export declare const GET_LINK: import("graphql").DocumentNode;
|
|
4
|
+
export declare const UPDATE_LINK: import("graphql").DocumentNode;
|
|
5
|
+
export declare const DELETE_LINK: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.UPDATE_LINK = exports.LIST_LINKS = exports.GET_LINK = exports.DELETE_LINK = exports.CREATE_LINK = void 0;
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
12
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
13
|
+
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
15
|
+
|
|
16
|
+
var ERROR_FIELD =
|
|
17
|
+
/* GraphQL */
|
|
18
|
+
"\n {\n code\n data\n message\n }\n";
|
|
19
|
+
var DATA_FIELD =
|
|
20
|
+
/* GraphQL */
|
|
21
|
+
"\n {\n id\n linkId\n folderId\n }\n";
|
|
22
|
+
var LIST_META_FIELD =
|
|
23
|
+
/* GraphQL */
|
|
24
|
+
"\n {\n cursor\n totalCount\n hasMoreItems\n }\n";
|
|
25
|
+
var CREATE_LINK = (0, _graphqlTag.default)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n mutation CreateLink($data: LinkCreateInput!) {\n folders {\n createLink(data: $data) {\n data ", "\n error ", "\n }\n }\n }\n"])), DATA_FIELD, ERROR_FIELD);
|
|
26
|
+
exports.CREATE_LINK = CREATE_LINK;
|
|
27
|
+
var LIST_LINKS = (0, _graphqlTag.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n query ListLinks ($folderId: ID!, $limit: Int, $after: String) {\n folders {\n listLinks(where: { folderId: $folderId }, limit: $limit, after: $after) {\n data ", "\n meta ", "\n error ", "\n }\n }\n }\n"])), DATA_FIELD, LIST_META_FIELD, ERROR_FIELD);
|
|
28
|
+
exports.LIST_LINKS = LIST_LINKS;
|
|
29
|
+
var GET_LINK = (0, _graphqlTag.default)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n query GetLink ($id: ID!) {\n folders {\n getLink(id: $id) {\n data ", "\n error ", "\n }\n }\n }\n"])), DATA_FIELD, ERROR_FIELD);
|
|
30
|
+
exports.GET_LINK = GET_LINK;
|
|
31
|
+
var UPDATE_LINK = (0, _graphqlTag.default)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n mutation UpdateLink($id: ID!, $data: LinkUpdateInput!) {\n folders {\n updateLink(id: $id, data: $data) {\n data ", "\n error ", "\n }\n }\n }\n"])), DATA_FIELD, ERROR_FIELD);
|
|
32
|
+
exports.UPDATE_LINK = UPDATE_LINK;
|
|
33
|
+
var DELETE_LINK = (0, _graphqlTag.default)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n mutation DeleteLink($id: ID!) {\n folders {\n deleteLink(id: $id) {\n data\n error ", "\n }\n }\n }\n"])), ERROR_FIELD);
|
|
34
|
+
exports.DELETE_LINK = DELETE_LINK;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ERROR_FIELD","DATA_FIELD","LIST_META_FIELD","CREATE_LINK","gql","LIST_LINKS","GET_LINK","UPDATE_LINK","DELETE_LINK"],"sources":["links.gql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n code\n data\n message\n }\n`;\n\nconst DATA_FIELD = /* GraphQL */ `\n {\n id\n linkId\n folderId\n }\n`;\n\nconst LIST_META_FIELD = /* GraphQL */ `\n {\n cursor\n totalCount\n hasMoreItems\n }\n`;\n\nexport const CREATE_LINK = gql`\n mutation CreateLink($data: LinkCreateInput!) {\n folders {\n createLink(data: $data) {\n data ${DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nexport const LIST_LINKS = gql`\n query ListLinks ($folderId: ID!, $limit: Int, $after: String) {\n folders {\n listLinks(where: { folderId: $folderId }, limit: $limit, after: $after) {\n data ${DATA_FIELD}\n meta ${LIST_META_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nexport const GET_LINK = gql`\n query GetLink ($id: ID!) {\n folders {\n getLink(id: $id) {\n data ${DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nexport const UPDATE_LINK = gql`\n mutation UpdateLink($id: ID!, $data: LinkUpdateInput!) {\n folders {\n updateLink(id: $id, data: $data) {\n data ${DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nexport const DELETE_LINK = gql`\n mutation DeleteLink($id: ID!) {\n folders {\n deleteLink(id: $id) {\n data\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n"],"mappings":";;;;;;;;;;;AAAA;;;;AAEA,IAAMA,WAAW;AAAG;AAAH,+DAAjB;AAQA,IAAMC,UAAU;AAAG;AAAH,gEAAhB;AAQA,IAAMC,eAAe;AAAG;AAAH,4EAArB;AAQO,IAAMC,WAAW,OAAGC,mBAAH,6RAIDH,UAJC,EAKAD,WALA,CAAjB;;AAWA,IAAMK,UAAU,OAAGD,mBAAH,2XAIAH,UAJA,EAKAC,eALA,EAMCF,WAND,CAAhB;;AAYA,IAAMM,QAAQ,OAAGF,mBAAH,oQAIEH,UAJF,EAKGD,WALH,CAAd;;AAWA,IAAMO,WAAW,OAAGH,mBAAH,kTAIDH,UAJC,EAKAD,WALA,CAAjB;;AAWA,IAAMQ,WAAW,OAAGJ,mBAAH,uQAKAJ,WALA,CAAjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LinkItem } from "../types";
|
|
2
|
+
export declare const useLinks: (folderId: string) => {
|
|
3
|
+
/**
|
|
4
|
+
* NOTE: you do NOT need to call `listLinks` from this hook on component mount, because you already have folders in the `links` property.
|
|
5
|
+
* As soon as you call `useLinks()`, you'll initiate fetching of `links`, which is managed by the `LinksContext`.
|
|
6
|
+
* Since this method lists links with pagination, you might need to call it multiple times passing the `after` param.
|
|
7
|
+
*/
|
|
8
|
+
loading: import("../types").Loading<import("~/types").LoadingActions>;
|
|
9
|
+
meta: {
|
|
10
|
+
cursor: string | null;
|
|
11
|
+
totalCount: number;
|
|
12
|
+
hasMoreItems: boolean;
|
|
13
|
+
};
|
|
14
|
+
links: LinkItem[];
|
|
15
|
+
listLinks(after: string, limit?: number): Promise<LinkItem[]>;
|
|
16
|
+
getLink(id: string): Promise<LinkItem>;
|
|
17
|
+
createLink(link: Omit<LinkItem, "linkId">): Promise<LinkItem>;
|
|
18
|
+
updateLink(link: LinkItem): Promise<LinkItem>;
|
|
19
|
+
deleteLink(link: LinkItem): Promise<true>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLinks = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _links = require("../contexts/links");
|
|
11
|
+
|
|
12
|
+
var useLinks = function useLinks(folderId) {
|
|
13
|
+
var context = (0, _react.useContext)(_links.LinksContext);
|
|
14
|
+
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error("useFoldersLinks must be used within a FoldersProvider");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var links = context.links,
|
|
20
|
+
loading = context.loading,
|
|
21
|
+
meta = context.meta,
|
|
22
|
+
_listLinks = context.listLinks,
|
|
23
|
+
_getLink = context.getLink,
|
|
24
|
+
_createLink = context.createLink,
|
|
25
|
+
_updateLink = context.updateLink,
|
|
26
|
+
_deleteLink = context.deleteLink;
|
|
27
|
+
(0, _react.useEffect)(function () {
|
|
28
|
+
/**
|
|
29
|
+
* On first mount, call `listLinks`, which will either issue a network request, or load links from cache.
|
|
30
|
+
* We don't need to store the result of it to any local state; that is managed by the context provider.
|
|
31
|
+
*/
|
|
32
|
+
_listLinks(folderId);
|
|
33
|
+
}, [folderId]);
|
|
34
|
+
return (0, _react.useMemo)(function () {
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* NOTE: you do NOT need to call `listLinks` from this hook on component mount, because you already have folders in the `links` property.
|
|
38
|
+
* As soon as you call `useLinks()`, you'll initiate fetching of `links`, which is managed by the `LinksContext`.
|
|
39
|
+
* Since this method lists links with pagination, you might need to call it multiple times passing the `after` param.
|
|
40
|
+
*/
|
|
41
|
+
loading: loading,
|
|
42
|
+
meta: meta[folderId] || {},
|
|
43
|
+
links: links.filter(function (link) {
|
|
44
|
+
return link.folderId === folderId;
|
|
45
|
+
}),
|
|
46
|
+
listLinks: function listLinks(after, limit) {
|
|
47
|
+
return _listLinks(folderId, limit, after);
|
|
48
|
+
},
|
|
49
|
+
getLink: function getLink(id) {
|
|
50
|
+
return _getLink(id, folderId);
|
|
51
|
+
},
|
|
52
|
+
createLink: function createLink(link) {
|
|
53
|
+
return _createLink(link);
|
|
54
|
+
},
|
|
55
|
+
updateLink: function updateLink(link) {
|
|
56
|
+
return _updateLink(link, folderId);
|
|
57
|
+
},
|
|
58
|
+
deleteLink: function deleteLink(link) {
|
|
59
|
+
return _deleteLink(link);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [links, loading, meta]);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.useLinks = useLinks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLinks","folderId","context","useContext","LinksContext","Error","links","loading","meta","listLinks","getLink","createLink","updateLink","deleteLink","useEffect","useMemo","filter","link","after","limit","id"],"sources":["useLinks.ts"],"sourcesContent":["import { useContext, useEffect, useMemo } from \"react\";\nimport { LinksContext } from \"~/contexts/links\";\nimport { LinkItem } from \"~/types\";\n\nexport const useLinks = (folderId: string) => {\n const context = useContext(LinksContext);\n\n if (!context) {\n throw new Error(\"useFoldersLinks must be used within a FoldersProvider\");\n }\n\n const { links, loading, meta, listLinks, getLink, createLink, updateLink, deleteLink } =\n context;\n\n useEffect(() => {\n /**\n * On first mount, call `listLinks`, which will either issue a network request, or load links from cache.\n * We don't need to store the result of it to any local state; that is managed by the context provider.\n */\n listLinks(folderId);\n }, [folderId]);\n\n return useMemo(\n () => ({\n /**\n * NOTE: you do NOT need to call `listLinks` from this hook on component mount, because you already have folders in the `links` property.\n * As soon as you call `useLinks()`, you'll initiate fetching of `links`, which is managed by the `LinksContext`.\n * Since this method lists links with pagination, you might need to call it multiple times passing the `after` param.\n */\n loading,\n meta: meta[folderId] || {},\n links: links.filter(link => link.folderId === folderId),\n listLinks(after: string, limit?: number) {\n return listLinks(folderId, limit, after);\n },\n getLink(id: string) {\n return getLink(id, folderId);\n },\n createLink(link: Omit<LinkItem, \"linkId\">) {\n return createLink(link);\n },\n updateLink(link: LinkItem) {\n return updateLink(link, folderId);\n },\n deleteLink(link: LinkItem) {\n return deleteLink(link);\n }\n }),\n [links, loading, meta]\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,QAAD,EAAsB;EAC1C,IAAMC,OAAO,GAAG,IAAAC,iBAAA,EAAWC,mBAAX,CAAhB;;EAEA,IAAI,CAACF,OAAL,EAAc;IACV,MAAM,IAAIG,KAAJ,CAAU,uDAAV,CAAN;EACH;;EAED,IAAQC,KAAR,GACIJ,OADJ,CAAQI,KAAR;EAAA,IAAeC,OAAf,GACIL,OADJ,CAAeK,OAAf;EAAA,IAAwBC,IAAxB,GACIN,OADJ,CAAwBM,IAAxB;EAAA,IAA8BC,UAA9B,GACIP,OADJ,CAA8BO,SAA9B;EAAA,IAAyCC,QAAzC,GACIR,OADJ,CAAyCQ,OAAzC;EAAA,IAAkDC,WAAlD,GACIT,OADJ,CAAkDS,UAAlD;EAAA,IAA8DC,WAA9D,GACIV,OADJ,CAA8DU,UAA9D;EAAA,IAA0EC,WAA1E,GACIX,OADJ,CAA0EW,UAA1E;EAGA,IAAAC,gBAAA,EAAU,YAAM;IACZ;AACR;AACA;AACA;IACQL,UAAS,CAACR,QAAD,CAAT;EACH,CAND,EAMG,CAACA,QAAD,CANH;EAQA,OAAO,IAAAc,cAAA,EACH;IAAA,OAAO;MACH;AACZ;AACA;AACA;AACA;MACYR,OAAO,EAAPA,OANG;MAOHC,IAAI,EAAEA,IAAI,CAACP,QAAD,CAAJ,IAAkB,EAPrB;MAQHK,KAAK,EAAEA,KAAK,CAACU,MAAN,CAAa,UAAAC,IAAI;QAAA,OAAIA,IAAI,CAAChB,QAAL,KAAkBA,QAAtB;MAAA,CAAjB,CARJ;MASHQ,SATG,qBASOS,KATP,EASsBC,KATtB,EASsC;QACrC,OAAOV,UAAS,CAACR,QAAD,EAAWkB,KAAX,EAAkBD,KAAlB,CAAhB;MACH,CAXE;MAYHR,OAZG,mBAYKU,EAZL,EAYiB;QAChB,OAAOV,QAAO,CAACU,EAAD,EAAKnB,QAAL,CAAd;MACH,CAdE;MAeHU,UAfG,sBAeQM,IAfR,EAewC;QACvC,OAAON,WAAU,CAACM,IAAD,CAAjB;MACH,CAjBE;MAkBHL,UAlBG,sBAkBQK,IAlBR,EAkBwB;QACvB,OAAOL,WAAU,CAACK,IAAD,EAAOhB,QAAP,CAAjB;MACH,CApBE;MAqBHY,UArBG,sBAqBQI,IArBR,EAqBwB;QACvB,OAAOJ,WAAU,CAACI,IAAD,CAAjB;MACH;IAvBE,CAAP;EAAA,CADG,EA0BH,CAACX,KAAD,EAAQC,OAAR,EAAiBC,IAAjB,CA1BG,CAAP;AA4BH,CA9CM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-aco",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.60a863e033",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"@material-design-icons/svg": "0.12.1",
|
|
18
18
|
"@material-symbols/svg-400": "0.4.3",
|
|
19
19
|
"@minoru/react-dnd-treeview": "3.2.1",
|
|
20
|
-
"@webiny/app": "0.0.0-unstable.
|
|
21
|
-
"@webiny/app-admin": "0.0.0-unstable.
|
|
22
|
-
"@webiny/form": "0.0.0-unstable.
|
|
23
|
-
"@webiny/ui": "0.0.0-unstable.
|
|
24
|
-
"@webiny/validation": "0.0.0-unstable.
|
|
20
|
+
"@webiny/app": "0.0.0-unstable.60a863e033",
|
|
21
|
+
"@webiny/app-admin": "0.0.0-unstable.60a863e033",
|
|
22
|
+
"@webiny/form": "0.0.0-unstable.60a863e033",
|
|
23
|
+
"@webiny/ui": "0.0.0-unstable.60a863e033",
|
|
24
|
+
"@webiny/validation": "0.0.0-unstable.60a863e033",
|
|
25
25
|
"graphql": "15.8.0",
|
|
26
26
|
"graphql-tag": "2.12.6",
|
|
27
27
|
"react": "17.0.2",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@babel/preset-typescript": "^7.18.6",
|
|
38
38
|
"@babel/runtime": "^7.19.0",
|
|
39
39
|
"@types/react": "17.0.39",
|
|
40
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
41
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
40
|
+
"@webiny/cli": "^0.0.0-unstable.60a863e033",
|
|
41
|
+
"@webiny/project-utils": "^0.0.0-unstable.60a863e033",
|
|
42
42
|
"apollo-client": "^2.6.10",
|
|
43
43
|
"apollo-link": "^1.2.14",
|
|
44
44
|
"rimraf": "^3.0.2",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"build": "yarn webiny run build",
|
|
54
54
|
"watch": "yarn webiny run watch"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "60a863e033e1c323423be51f381b3ac961213e63"
|
|
57
57
|
}
|