jpf 4.2.15 → 4.2.17
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/dist/controls/codeMirror/HtmlEditor/HtmlEditor.d.ts +2 -1
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js +4 -0
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js.map +1 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.d.ts +2 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js +4 -0
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +2 -1
- package/dist/controls/custom/FileSelector/FileSelector.js +4 -0
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +2 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.js +4 -0
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +4 -2
- package/dist/controls/custom/ListItem/ListItem.js +8 -0
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/html/Button/Button.d.ts +2 -1
- package/dist/controls/html/Button/Button.js +4 -0
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +2 -1
- package/dist/controls/html/Div/Div.js +4 -0
- package/dist/controls/html/Div/Div.js.map +1 -1
- package/dist/controls/html/Image/Image.d.ts +2 -1
- package/dist/controls/html/Image/Image.js +4 -0
- package/dist/controls/html/Image/Image.js.map +1 -1
- package/dist/controls/html/Input/Input.d.ts +2 -1
- package/dist/controls/html/Input/Input.js +4 -0
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +2 -1
- package/dist/controls/html/Select/Select.js +4 -0
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +2 -1
- package/dist/controls/html/Span/Span.js +4 -0
- package/dist/controls/html/Span/Span.js.map +1 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.d.ts +2 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js +4 -0
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js.map +1 -1
- package/dist/controls/kendo/Editor/Editor.d.ts +2 -1
- package/dist/controls/kendo/Editor/Editor.js +4 -0
- package/dist/controls/kendo/Editor/Editor.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +2 -1
- package/dist/controls/kendo/Grid/Grid.js +4 -0
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +2 -1
- package/dist/controls/leaflet/Map/Map.js +4 -0
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/framework/ViewModel.d.ts +2 -2
- package/dist/framework/ViewModel.js +2 -2
- package/dist/framework/ViewModel.js.map +1 -1
- package/package.json +3 -2
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +153 -0
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +136 -0
- package/src/controls/codeMirror/index.ts +2 -0
- package/src/controls/custom/FileSelector/FileSelector.ts +74 -0
- package/src/controls/custom/LabeledControl/LabeledControl.ts +58 -0
- package/src/controls/custom/ListItem/ListItem.ts +99 -0
- package/src/controls/custom/index.ts +3 -0
- package/src/controls/html/Button/Button.ts +70 -0
- package/src/controls/html/Div/Div.ts +41 -0
- package/src/controls/html/Image/Image.ts +46 -0
- package/src/controls/html/Input/Input.ts +228 -0
- package/src/controls/html/Select/Select.ts +146 -0
- package/src/controls/html/Span/Span.ts +38 -0
- package/src/controls/html/index.ts +6 -0
- package/src/controls/index.ts +15 -0
- package/src/controls/jsonViewAwesome/index.ts +1 -0
- package/src/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.ts +91 -0
- package/src/controls/kendo/Chart/Chart.ts +97 -0
- package/src/controls/kendo/Culture/Culture.ts +32 -0
- package/src/controls/kendo/DataSource/DataSource.ts +4 -0
- package/src/controls/kendo/Dialog/Dialog.ts +64 -0
- package/src/controls/kendo/Editor/Editor.ts +142 -0
- package/src/controls/kendo/Grid/Grid.ts +291 -0
- package/src/controls/kendo/Menu/Menu.ts +125 -0
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -0
- package/src/controls/kendo/Tree/Tree.ts +147 -0
- package/src/controls/kendo/index.ts +9 -0
- package/src/controls/leaflet/LabelControl/LabelControl.ts +42 -0
- package/src/controls/leaflet/Map/Map.ts +180 -0
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +19 -0
- package/src/controls/leaflet/PointerEvent/PointerEvent.ts +9 -0
- package/src/controls/leaflet/index.ts +4 -0
- package/src/controls/svg/Circle/Circle.ts +34 -0
- package/src/controls/svg/Ellipse/Ellipse.ts +36 -0
- package/src/controls/svg/ForeignObject/ForeignObject.ts +38 -0
- package/src/controls/svg/Group/Group.ts +38 -0
- package/src/controls/svg/Line/Line.ts +36 -0
- package/src/controls/svg/Pattern/Pattern.ts +49 -0
- package/src/controls/svg/Polygon/Polygon.ts +31 -0
- package/src/controls/svg/Polyline/Polyline.ts +31 -0
- package/src/controls/svg/Rectangle/Rectangle.ts +36 -0
- package/src/controls/svg/Svg/Svg.ts +43 -0
- package/src/controls/svg/Text/Text.ts +38 -0
- package/src/controls/svg/Title/Title.ts +28 -0
- package/src/controls/svg/index.ts +13 -0
- package/src/controls/svg/svg.ts +20 -0
- package/src/framework/View.ts +213 -0
- package/src/framework/ViewModel.ts +525 -0
- package/src/framework/attributes.ts +92 -0
- package/src/framework/event.ts +98 -0
- package/src/framework/observable.ts +80 -0
- package/src/framework/style.ts +3271 -0
- package/src/framework/types.ts +277 -0
- package/src/framework/userAgent.ts +51 -0
- package/src/index.ts +14 -0
- package/src/utilities/blob/blob.ts +19 -0
- package/src/utilities/cookie/cookie.ts +28 -0
- package/src/utilities/dataReaderTable/dataReaderTable.ts +34 -0
- package/src/utilities/fetch/fetch.ts +179 -0
- package/src/utilities/float/float.ts +3 -0
- package/src/utilities/formData/formData.ts +12 -0
- package/src/utilities/html/html.ts +8 -0
- package/src/utilities/htmlElement/htmlElement.ts +15 -0
- package/src/utilities/image/image.ts +1 -0
- package/src/utilities/index.ts +37 -0
- package/src/utilities/integer/integer.ts +31 -0
- package/src/utilities/key/key.ts +7 -0
- package/src/utilities/navigator/navigator.ts +7 -0
- package/src/utilities/notification/notification.ts +88 -0
- package/src/utilities/querystring/querystring.ts +61 -0
- package/src/utilities/router/router.ts +124 -0
- package/src/utilities/stylesheet/stylesheet.ts +58 -0
- package/src/utilities/uniqueId/uniqueId.ts +5 -0
- package/src/utilities/webSocket/webSocket.ts +72 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
|
|
2
|
+
export type PatternUnits = "userSpaceOnUse" | "objectboudingBox";
|
|
3
|
+
export type DropEffect = "none" | "copy" | "link" | "move";
|
|
4
|
+
export type EffectAllowed = "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all" | "uninitialized";
|
|
5
|
+
|
|
6
|
+
type CssPropertyA = "alignContent" | "alignItems" | "alignSelf" | "alignmentAdjust" | "alignmentBaseline" | "animation" | "animationDelay" | "animationDirection" | "animationDuration" |
|
|
7
|
+
"animationFillMode" | "animationIterationCount" | "animationName" | "animationPlayState" | "animationTimingFunction" | "appearance" | "backfaceVisibility" | "background" |
|
|
8
|
+
"backgroundAttachment" | "backgroundBlendMode" | "backgroundClip" | "backgroundColor" | "backgroundComposite" | "backgroundImage" | "backgroundOrigin" | "backgroundPosition" |
|
|
9
|
+
"backgroundRepeat" | "backgroundSize" | "baselineShift" | "behavior" | "border" | "borderBottom" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" |
|
|
10
|
+
"borderBottomStyle" | "borderBottomWidth" | "borderCollapse" | "borderColor" | "borderCornerShape" | "borderImageSource" | "borderImageWidth" | "borderLeft" | "borderLeftColor" |
|
|
11
|
+
"borderLeftStyle" | "borderLeftWidth" | "borderRadius" | "borderRight" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderSpacing" | "borderStyle" | "borderTop" |
|
|
12
|
+
"borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "borderWidth" | "bottom" | "boxAlign" | "boxDecorationBreak" | "boxDirection" |
|
|
13
|
+
"boxLineProgression" | "boxLines" | "boxOrdinalGroup" | "boxFlex" | "boxSizing" | "boxShadow" | "boxFlexGroup" | "breakAfter" | "breakBefore" | "breakInside" | "captionSide" | "clear" |
|
|
14
|
+
"clip" | "clipRule" | "color" | "columnCount" | "columnFill" | "columnGap" | "columnRule" | "columnRuleColor" | "columnRuleWidth" | "columnSpan" | "columnWidth" | "columns" | "content" |
|
|
15
|
+
"counterIncrement" | "counterReset" | "cue" | "cueAfter" | "cursor" | "direction" | "display" | "dominantBaseline" | "emptyCells" | "fill" | "fillOpacity" | "fillRule" | "filter" | "flex" |
|
|
16
|
+
"flexAlign" | "flexBasis" | "flexDirection" | "flexFlow" | "flexGrow" | "flexItemAlign" | "flexLinePack" | "flexPositive" | "flexNegative" | "flexOrder" | "flexShrink" | "flexWrap" |
|
|
17
|
+
"float" | "flowFrom" | "font" | "fontFamily" | "fontKerning" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontSynthesis" | "fontVariant" | "fontVariantAlternates" |
|
|
18
|
+
"fontWeight" | "gridArea" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumn" | "gridColumnGap" | "gridColumnEnd" | "gridColumnStart" | "gridGap" | "gridRow" |
|
|
19
|
+
"gridRowEnd" | "gridRowGap" | "gridRowStart" | "gridRowPosition" | "gridRowSpan" | "gridTemplate" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" |
|
|
20
|
+
"hyphenateLimitChars" | "hyphenateLimitLines" | "hyphenateLimitZone" | "hyphens" | "imeMode" | "justifyContent" | "justifyItems" | "justifySelf";
|
|
21
|
+
|
|
22
|
+
type CssPropertyL = "layoutGrid" | "layoutGridChar" | "layoutGridLine" | "layoutGridMode" | "layoutGridType" | "left" | "letterSpacing" | "lineBreak" | "lineClamp" | "lineHeight" |
|
|
23
|
+
"listStyle" | "listStyleImage" | "listStylePosition" | "listStyleType" | "margin" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "marqueeDirection" | "marqueeStyle" |
|
|
24
|
+
"mask" | "maskBorder" | "maskBorderRepeat" | "maskBorderSlice" | "maskBorderSource" | "maskBorderWidth" | "maskClip" | "maskOrigin" | "maxFontSize" | "maxHeight" | "maxWidth" |
|
|
25
|
+
"minHeight" | "minWidth" | "mixBlendMode" | "objectFit" | "objectPosition" | "opacity" | "order" | "orphans" | "outline" | "outlineColor" | "outlineStyle" | "outlineOffset" |
|
|
26
|
+
"outlineWidth" | "overflow" | "overflowStyle" | "overflowWrap" | "overflowX" | "overflowY" | "padding" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" |
|
|
27
|
+
"pageBreakAfter" | "pageBreakBefore" | "pageBreakInside" | "pause" | "pauseAfter" | "pauseBefore" | "perspective" | "perspectiveOrigin" | "pointerEvents" | "position" |
|
|
28
|
+
"punctuationTrim" | "quotes" | "regionFragment" | "resize" | "restAfter" | "restBefore" | "right" | "rubyAlign" | "rubyPosition" | "rx" | "ry" | "shapeImageThreshold" |
|
|
29
|
+
"shapeInside" | "shapeMargin" | "shapeOutside" | "speak" | "speakAs" | "src" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeOpacity" |
|
|
30
|
+
"strokeWidth" | "tabSize" | "tableLayout" | "textAnchor" | "textAlign" | "textAlignLast" | "textDecoration" | "textDecorationColor" | "textDecorationLine" | "textDecorationLineThrough" |
|
|
31
|
+
"textDecorationNone" | "textDecorationOverline" | "textDecorationSkip" | "textDecorationStyle" | "textDecorationUnderline" | "textEmphasis" | "textEmphasisColor" | "textEmphasisStyle" |
|
|
32
|
+
"textHeight" | "textIndent" | "textJustifyTrim" | "textKashidaSpace" | "textLineThrough" | "textLineThroughColor" | "textLineThroughMode" | "textLineThroughStyle" | "textLineThroughWidth" |
|
|
33
|
+
"textOverflow" | "textOverline" | "textOverlineColor" | "textOverlineMode" | "textOverlineStyle" | "textOverlineWidth" | "textRendering" | "textScript" | "textShadow" |
|
|
34
|
+
"textTransform" | "textUnderlinePosition" | "textUnderlineStyle" | "top" | "touchAction" | "transform" | "transformOrigin" | "transformOriginZ" | "transformStyle" |
|
|
35
|
+
"transition" | "transitionDelay" | "transitionDuration" | "transitionProperty" | "transitionTimingFunction" | "unicodeBidi" | "unicodeRange" | "userFocus" | "userInput" |
|
|
36
|
+
"userSelect" | "verticalAlign" | "visibility" | "voiceBalance" | "voiceDuration" | "voiceFamily" | "voicePitch" | "voiceRange" | "voiceRate" | "voiceStress" | "voiceVolume" |
|
|
37
|
+
"whiteSpace" | "whiteSpaceTreatment" | "widows" | "width" | "willChange" | "wordBreak" | "wordSpacing" | "wordWrap" | "wrapFlow" | "wrapMargin" | "wrapOption" | "writingMode" | "zIndex" | "zoom";
|
|
38
|
+
|
|
39
|
+
export type CssProperty = CssPropertyA | CssPropertyL;
|
|
40
|
+
/*
|
|
41
|
+
* Value of a CSS Property. Could be a single value or a list of fallbacks
|
|
42
|
+
* NOTE: array is for fallbacks
|
|
43
|
+
*/
|
|
44
|
+
export type CssValue<T> = T | T[];
|
|
45
|
+
/**
|
|
46
|
+
* For general purpose CSS values
|
|
47
|
+
**/
|
|
48
|
+
export type CssValueGeneral = CssValue<number | string>;
|
|
49
|
+
/**
|
|
50
|
+
* When you are sure that the value must be a string
|
|
51
|
+
**/
|
|
52
|
+
export type CssValueString = CssValue<string>;
|
|
53
|
+
/**
|
|
54
|
+
* CSS properties that cascade also support these
|
|
55
|
+
* @see https://drafts.csswg.org/css-cascade/#defaulting-keywords
|
|
56
|
+
*/
|
|
57
|
+
export type CssGlobalValues = "initial" | "inherit" | "unset" | "revert";
|
|
58
|
+
export interface IFontFace {
|
|
59
|
+
fontFamily?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Location of a font-face. Used with the @font-face at rule
|
|
62
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src
|
|
63
|
+
*/
|
|
64
|
+
src?: CssValueString;
|
|
65
|
+
unicodeRange?: any;
|
|
66
|
+
fontVariant?: "common-ligatures" | "small-caps" | CssGlobalValues;
|
|
67
|
+
fontFeatureSettings?: string;
|
|
68
|
+
fontWeight?: CssFontWeight;
|
|
69
|
+
fontStyle?: "normal" | "italic" | "oblique" | CssGlobalValues;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Absolute size keywords
|
|
73
|
+
* @see https://drafts.csswg.org/css-fonts-3/#absolute-size-value
|
|
74
|
+
*/
|
|
75
|
+
export type CssAbsoluteSize = "xx-small" | "x-small" | "small" | "medium" | "large" | "x-large" | "xx-large";
|
|
76
|
+
/**
|
|
77
|
+
* an angle; 0' | '0deg' | '0grad' | '0rad' | '0turn' | 'etc.
|
|
78
|
+
* @see https://drafts.csswg.org/css-values-3/#angles
|
|
79
|
+
*/
|
|
80
|
+
export type CssAngle = CssGlobalValues | string | 0;
|
|
81
|
+
/**
|
|
82
|
+
* initial state of an animation.
|
|
83
|
+
* @see https://drafts.csswg.org/css-animations/#animation-play-state
|
|
84
|
+
*/
|
|
85
|
+
export type CssAnimationPlayState = CssGlobalValues | string | "paused" | "running";
|
|
86
|
+
/**
|
|
87
|
+
* blend mode
|
|
88
|
+
* @see https://drafts.fxtf.org/compositing-1/#ltblendmodegt
|
|
89
|
+
*/
|
|
90
|
+
export type CssBlendMode = "normal" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
91
|
+
/**
|
|
92
|
+
* border shorthand for style color and width
|
|
93
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom
|
|
94
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-left
|
|
95
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-right
|
|
96
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/border-top
|
|
97
|
+
*/
|
|
98
|
+
export type CssBorderShorthand = CssGlobalValues | CssColor | CssLength | CssLineStyleSet | string;
|
|
99
|
+
/**
|
|
100
|
+
* Determines the area within which the background is painted.
|
|
101
|
+
* @see https://drafts.csswg.org/css-backgrounds/#box
|
|
102
|
+
*/
|
|
103
|
+
export type CssBox = CssGlobalValues | string | "border-box" | "padding-box" | "content-box";
|
|
104
|
+
/**
|
|
105
|
+
* Color can be a named color, transparent, or a color function
|
|
106
|
+
* @see https://drafts.csswg.org/css-color-3/#valuea-def-color
|
|
107
|
+
*/
|
|
108
|
+
export type CssColor = CssNamedColor | CssGlobalValues | "currentColor" | string;
|
|
109
|
+
export type CssNamedColor = "aliceblue" | "antiquewhite" | "aqua" | "aquamarine" | "azure" | "beige" | "bisque" | "black" | "blanchedalmond" | "blue" | "blueviolet" | "brown" | "burlywood" | "cadetblue" | "chartreuse" | "chocolate" | "coral" | "cornflowerblue" | "cornsilk" | "crimson" | "cyan" | "darkblue" | "darkcyan" | "darkgoldenrod" | "darkgray" | "darkgreen" | "darkgrey" | "darkkhaki" | "darkmagenta" | "darkolivegreen" | "darkorange" | "darkorchid" | "darkred" | "darksalmon" | "darkseagreen" | "darkslateblue" | "darkslategray" | "darkslategrey" | "darkturquoise" | "darkviolet" | "deeppink" | "deepskyblue" | "dimgray" | "dimgrey" | "dodgerblue" | "firebrick" | "floralwhite" | "forestgreen" | "fuchsia" | "gainsboro" | "ghostwhite" | "gold" | "goldenrod" | "gray" | "green" | "greenyellow" | "grey" | "honeydew" | "hotpink" | "indianred" | "indigo" | "ivory" | "khaki" | "lavender" | "lavenderblush" | "lawngreen" | "lemonchiffon" | "lightblue" | "lightcoral" | "lightcyan" | "lightgoldenrodyellow" | "lightgray" | "lightgreen" | "lightgrey" | "lightpink" | "lightsalmon" | "lightseagreen" | "lightskyblue" | "lightslategray" | "lightslategrey" | "lightsteelblue" | "lightyellow" | "lime" | "limegreen" | "linen" | "maroon" | "mediumaquamarine" | "mediumblue" | "mediumorchid" | "mediumpurple" | "mediumseagreen" | "mediumslateblue" | "mediumspringgreen" | "mediumturquoise" | "mediumvioletred" | "midnightblue" | "mintcream" | "mistyrose" | "moccasin" | "navajowhite" | "navy" | "oldlace" | "olive" | "olivedrab" | "orange" | "purple" | "rebeccapurple" | "red" | "silver" | "teal" | "transparent" | "white" | "yellow";
|
|
110
|
+
/**
|
|
111
|
+
* Special type for border-color which can use 1 or 4 colors
|
|
112
|
+
* @see https://drafts.csswg.org/css-backgrounds-3/#border-color
|
|
113
|
+
*/
|
|
114
|
+
export type CssColorSet = string | CssColor;
|
|
115
|
+
/**
|
|
116
|
+
* This property specifies the type of rendering box used for an element. It is a shorthand property for many other display properties.
|
|
117
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/display
|
|
118
|
+
*/
|
|
119
|
+
export type CssDisplay = "" | "inherit" | "initial" | "block" | "inline" | "run-in" | "flow" | "flow-root" | "table" | "flex" | "grid" | "ruby" | "subgrid" | "block flow" | "inline table" | "flex run-in" | "list-item" | "list-item block" | "list-item inline" | "list-item flow" | "list-item flow-root" | "list-item block flow" | "list-item block flow-root" | "flow list-item block" | "table-row-group" | "table-header-group" | "table-footer-group" | "table-row" | "table-cell" | "table-column-group" | "table-column" | "table-caption" | "ruby-base" | "ruby-text" | "ruby-base-container" | "ruby-text-container" | "contents" | "none" | "inline-block" | "inline-list-item" | "inline-table" | "inline-flex" | "inline-grid";
|
|
120
|
+
/**
|
|
121
|
+
* CSS Type <baseline-position> of Box Alignment
|
|
122
|
+
* @see https://www.w3.org/TR/css-align-3/#typedef-baseline-position
|
|
123
|
+
*/
|
|
124
|
+
export type CssBoxAlignmentBaselinePosition = "baseline" | "first baseline" | "last baseline";
|
|
125
|
+
/**
|
|
126
|
+
* CSS Type <content-distribution> of Box Alignment
|
|
127
|
+
* @see https://www.w3.org/TR/css-align-3/#typedef-content-distribution
|
|
128
|
+
*/
|
|
129
|
+
export type CssBoxAlignmentContentDistribution = "space-between" | "space-around" | "space-evenly" | "stretch";
|
|
130
|
+
export type CssBoxAlignmentContentPositionWithOverflow = "center" | "start" | "end" | "flex-start" | "flex-end" | "unsafe center" | "unsafe start" | "unsafe end" | "unsafe flex-start" | "unsafe flex-end" | "safe center" | "safe start" | "safe end" | "safe flex-start" | "safe flex-end";
|
|
131
|
+
export type CssBoxAlignmentSelfPositionWithOverflow = "center" | "start" | "end" | "self-start" | "self-end" | "flex-start" | "flex-end" | "unsafe center" | "unsafe start" | "unsafe end" | "unsafe self-start" | "unsafe self-end" | "unsafe flex-start" | "unsafe flex-end" | "safe center" | "safe start" | "safe end" | "safe self-start" | "safe self-end" | "safe flex-start" | "safe flex-end";
|
|
132
|
+
export type CssBoxAlignmentLeftRightWithOverflow = "left" | "right" | "unsafe left" | "unsafe right" | "safe left" | "safe right";
|
|
133
|
+
/**
|
|
134
|
+
* Type for justify-content in flex or grid
|
|
135
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-justify-content
|
|
136
|
+
*/
|
|
137
|
+
export type JustifyContent = "normal" | CssBoxAlignmentContentDistribution | CssBoxAlignmentContentPositionWithOverflow | "left" | "right";
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Type for align-content in flex or grid
|
|
141
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-align-content
|
|
142
|
+
*/
|
|
143
|
+
export type AlignContent = "normal" | CssBoxAlignmentBaselinePosition | CssBoxAlignmentContentDistribution | CssBoxAlignmentContentPositionWithOverflow;
|
|
144
|
+
/**
|
|
145
|
+
* Type for justify-items in flex or grid
|
|
146
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-justify-items
|
|
147
|
+
*/
|
|
148
|
+
export type JustifyItems = "normal" | "stretch" | CssBoxAlignmentBaselinePosition | CssBoxAlignmentSelfPositionWithOverflow | "left" | "right" | "center" | "legacy left" | "legacy right" | "legacy center";
|
|
149
|
+
/**
|
|
150
|
+
* Type for align-items in flex or grid
|
|
151
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-align-items
|
|
152
|
+
*/
|
|
153
|
+
export type AlignItems = "normal" | "stretch" | CssBoxAlignmentBaselinePosition | CssBoxAlignmentSelfPositionWithOverflow;
|
|
154
|
+
/**
|
|
155
|
+
* Type for justify-self in flex or grid
|
|
156
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-justify-self
|
|
157
|
+
*/
|
|
158
|
+
export type JustifySelf = "auto" | "normal" | "stretch" | CssBoxAlignmentBaselinePosition | CssBoxAlignmentSelfPositionWithOverflow | CssBoxAlignmentLeftRightWithOverflow;
|
|
159
|
+
/**
|
|
160
|
+
* Type for align-self in flex or grid
|
|
161
|
+
* @see https://www.w3.org/TR/css-align-3/#propdef-align-self
|
|
162
|
+
*/
|
|
163
|
+
export type AlignSelf = "auto" | "normal" | "stretch" | CssBoxAlignmentBaselinePosition | CssBoxAlignmentSelfPositionWithOverflow;
|
|
164
|
+
/**
|
|
165
|
+
* a gradient function like linear-gradient
|
|
166
|
+
* @see https://drafts.csswg.org/css-images-3/#gradients
|
|
167
|
+
*/
|
|
168
|
+
export type CssGradient = CssGlobalValues | string;
|
|
169
|
+
/**
|
|
170
|
+
* complex type that describes the size of fonts
|
|
171
|
+
* @see https://drafts.csswg.org/css-fonts-3/#propdef-font-size
|
|
172
|
+
*/
|
|
173
|
+
export type CssFontSize = CssGlobalValues | CssLength | CssPercentage | CssAbsoluteSize | CssRelativeSize;
|
|
174
|
+
/**
|
|
175
|
+
* a value that serves as an image
|
|
176
|
+
* @see https://drafts.csswg.org/css-images-3/#typedef-image
|
|
177
|
+
*/
|
|
178
|
+
export type CssImage = CssGlobalValues | string | CssGradient | CssUrl;
|
|
179
|
+
/**
|
|
180
|
+
* an length; 0 | '0px' | '0em' etc.
|
|
181
|
+
* @see https://drafts.csswg.org/css-values-3/#lengths
|
|
182
|
+
*/
|
|
183
|
+
export type CssLength = CssGlobalValues | string | number;
|
|
184
|
+
/**
|
|
185
|
+
* Style of a line (e.g. border-style)
|
|
186
|
+
* @see https://drafts.csswg.org/css-backgrounds-3/#line-style
|
|
187
|
+
*/
|
|
188
|
+
export type CssLineStyle = string | "none" | "hidden" | "dotted" | "dashed" | "solid" | "double" | "groove" | "ridge" | "inset" | "outset";
|
|
189
|
+
/**
|
|
190
|
+
* Special type for border-style which can use 1 or 4 line-style
|
|
191
|
+
* @see https://drafts.csswg.org/css-backgrounds-3/#border-style
|
|
192
|
+
*/
|
|
193
|
+
export type CssLineStyleSet = string | CssLineStyle;
|
|
194
|
+
/**
|
|
195
|
+
* Specifies how the contents of a replaced element should be fitted to the box established by its used height and width.
|
|
196
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
|
|
197
|
+
*/
|
|
198
|
+
export type CssObjectFit = "fill" | "contain" | "cover" | "none" | "scale-down" | CssGlobalValues;
|
|
199
|
+
/**
|
|
200
|
+
* Overflow modes
|
|
201
|
+
* @see https://drafts.csswg.org/css-overflow-3/#propdef-overflow
|
|
202
|
+
*/
|
|
203
|
+
export type CssOverflow = "visible" | "hidden" | "scroll" | "clip" | "auto";
|
|
204
|
+
/**
|
|
205
|
+
* a percentage; 0 | '0%' etc.
|
|
206
|
+
* @see https://drafts.csswg.org/css-values-3/#percentage
|
|
207
|
+
*/
|
|
208
|
+
export type CssPercentage = CssGlobalValues | string | 0;
|
|
209
|
+
/**
|
|
210
|
+
* Defines a position (e.g. background-position)
|
|
211
|
+
* @see https://drafts.csswg.org/css-backgrounds-3/#position
|
|
212
|
+
*/
|
|
213
|
+
export type CssPosition = CssAngle | string;
|
|
214
|
+
/**
|
|
215
|
+
* Relative size keywords
|
|
216
|
+
* @see https://drafts.csswg.org/css-fonts-3/#relative-size-value
|
|
217
|
+
*/
|
|
218
|
+
export type CssRelativeSize = "larger" | "smaller";
|
|
219
|
+
/**
|
|
220
|
+
* Specifies how background images are tiled after they have been sized and positioned
|
|
221
|
+
* @see https://drafts.csswg.org/css-backgrounds/#repeat-style
|
|
222
|
+
*/
|
|
223
|
+
export type CssRepeatStyle = "repeat-x" | "repeat-y" | "repeat" | "space" | "round" | "no-repeat" | "repeat repeat" | "repeat space" | "repeat round" | "repeat no-repeat" | "space repeat" | "space space" | "space round" | "space no-repeat" | "round repeat" | "round space" | "round round" | "round no-repeat" | "no-repeat repeat" | "no-repeat space" | "no-repeat round" | "no-repeat no-repeat";
|
|
224
|
+
/**
|
|
225
|
+
* Tranform list for the element.
|
|
226
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function
|
|
227
|
+
*/
|
|
228
|
+
export type CssTransformFunction = string | "none";
|
|
229
|
+
/**
|
|
230
|
+
* Starting position for many gradients
|
|
231
|
+
* @see https://drafts.csswg.org/css-images-3/#typedef-side-or-corner
|
|
232
|
+
*/
|
|
233
|
+
export type CssSideOrCorner = CssAngle | "left" | "right" | "top" | "bottom" | "to left" | "to right" | "to top" | "to bottom" | "left top" | "right top" | "left bottom" | "right bottom" | "top left" | "top right" | "bottom left" | "bottom right" | "to left top" | "to right top" | "to left bottom" | "to right bottom" | "to top left" | "to top right" | "to bottom left" | "to bottom right";
|
|
234
|
+
export type CssRadialGradientEndingShape = "circle" | "ellipse";
|
|
235
|
+
/**
|
|
236
|
+
* Radial Gradient Size.
|
|
237
|
+
* @see https://drafts.csswg.org/css-images-3/#ending-shape
|
|
238
|
+
*/
|
|
239
|
+
export type CssRadialGradientSize = CssLength | Array<CssLength> | "closest-side" | "farthest-side" | "closest-corner" | "closest-side";
|
|
240
|
+
/** Supporting by `-timing-function` properties */
|
|
241
|
+
export type CssTimingFunction = string | CssGlobalValues | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear" | "step-start" | "step-end";
|
|
242
|
+
/**
|
|
243
|
+
* Expressed as url('protocol://')
|
|
244
|
+
* @see https://drafts.csswg.org/css-values-3/#urls
|
|
245
|
+
*/
|
|
246
|
+
export type CssUrl = string;
|
|
247
|
+
/**
|
|
248
|
+
* Font weights
|
|
249
|
+
*/
|
|
250
|
+
export type CssFontWeight = "normal" | "bold" | "bolder" | "lighter" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | number | CssGlobalValues;
|
|
251
|
+
export type AlignmentBaseline = "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit";
|
|
252
|
+
export type AnimationDirection = "normal" | "alternate" | "reverse" | "alternate-reverse";
|
|
253
|
+
export type AnimationFillMode = "none" | "forwards" | "backwards" | "both";
|
|
254
|
+
export type BackgroundAttachment = "scroll" | "fixed" | "local";
|
|
255
|
+
export type BackgroundSize = "auto" | "cover" | "contain";
|
|
256
|
+
export type BreakAfter = "auto" | "avoid" | "avoid-page" | "page" | "left" | "right" | "recto" | "verso" | "avoid-column" | "column" | "avoid-region" | "region";
|
|
257
|
+
export type BreakBefore = "auto" | "avoid" | "avoid-page" | "page" | "left" | "right" | "recto" | "verso" | "avoid-column" | "column" | "avoid-region" | "region";
|
|
258
|
+
export type BreakInside = "auto" | "avoid" | "avoid-page" | "avoid-column" | "avoid-region";
|
|
259
|
+
export type CaptionSide = CssGlobalValues | "top" | "bottom" | "block-start" | "block-end" | "inline-start" | "inline-end";
|
|
260
|
+
export type Cursor = CssValue<CssGlobalValues | string | "auto" | "default" | "none" | "context-menu" | "help" | "pointer" | "progress" | "wait" | "cell" | "crosshair" | "text" | "vertical-text" | "alias" | "copy" | "move" | "no-drop" | "not-allowed" | "e-resize" | "n-resize" | "ne-resize" | "nw-resize" | "s-resize" | "se-resize" | "sw-resize" | "w-resize" | "ew-resize" | "ns-resize" | "nesw-resize" | "nwse-resize" | "col-resize" | "row-resize" | "all-scroll" | "zoom-in" | "zoom-out" | "grab" | "grabbing">;
|
|
261
|
+
export type DominantBaseline = "auto" | "use-script" | "no-change" | "reset-size" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "central" | "middle" | "text-after-edge" | "text-before-edge" | "inherit";
|
|
262
|
+
export type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse";
|
|
263
|
+
export type FlexWrap = CssGlobalValues | "nowrap" | "wrap" | "wrap-reverse";
|
|
264
|
+
export type FontStretch = CssGlobalValues | "normal" | "ultra-condensed" | "extra-condensed" | "condensed" | "semi-condensed" | "semi-expanded" | "expanded" | "extra-expanded" | "ultra-expanded";
|
|
265
|
+
export type OutlineStyle = CssGlobalValues | "auto" | "none" | "dotted" | "dashed" | "solid" | "double" | "groove" | "ridge" | "inset" | "outset";
|
|
266
|
+
export type PageBreakAfter = CssGlobalValues | "auto" | "always" | "avoid" | "left" | "right" | "recto" | "verso";
|
|
267
|
+
export type PageBreakBefore = CssGlobalValues | "auto" | "always" | "avoid" | "left" | "right" | "recto" | "verso";
|
|
268
|
+
export type PointerEvents = CssGlobalValues | "auto" | "none" | "visiblePainted" | "visibleFill" | "visibleStroke" | "visible" | "painted" | "fill" | "stroke" | "all";
|
|
269
|
+
export type PositionX = CssValue<CssGlobalValues | "static" | "relative" | "absolute" | "sticky" | "-webkit-sticky" | "fixed">;
|
|
270
|
+
export type TextAlign = CssGlobalValues | "start" | "end" | "left" | "right" | "center" | "justify" | "justify-all" | "match-parent";
|
|
271
|
+
export type TextAlignLast = CssGlobalValues | "auto" | "start" | "end" | "left" | "right" | "center" | "justify";
|
|
272
|
+
export type TextTransform = CssGlobalValues | "none" | "capitalize" | "uppercase" | "lowercase" | "full-width";
|
|
273
|
+
export type TouchAction = CssGlobalValues | "auto" | "none" | "pan-x" | "pan-left" | "pan-right" | "pan-y" | "pan-up" | "pan-down" | "manipulation";
|
|
274
|
+
export type VerticalAlign = CssGlobalValues | "baseline" | "sub" | "super" | "text-top" | "text-bottom" | "middle" | "top" | "bottom" | CssLength | CssPercentage;
|
|
275
|
+
export type WritingMode = CssGlobalValues | "horizontal-tb" | "vertical-rl" | "vertical-lr" | "sideways-rl" | "sideways-lr";
|
|
276
|
+
export type CssStyleName = "alignContent" | "alignItems";
|
|
277
|
+
export type PreserveAspectRatio= "none"| "xMinYMin"| "xMidYMin"| "xMaxYMin"| "xMinYMid"| "xMidYMid"| "xMaxYMid"| "xMinYMax"| "xMidYMax"| "xMaxYMax"| "meet"| "slice" ;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { UAParser } from "ua-parser-js";
|
|
2
|
+
|
|
3
|
+
const parser = new UAParser();
|
|
4
|
+
const result = parser.getResult();
|
|
5
|
+
|
|
6
|
+
function supportsTouchEvents(): boolean {
|
|
7
|
+
if (("ontouchstart" in window)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
12
|
+
const mq = (query) => window.matchMedia(query).matches;
|
|
13
|
+
const queryString = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
14
|
+
return mq(queryString);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function supportsMouseEvents(): boolean {
|
|
18
|
+
return matchMedia('(pointer:fine)').matches || !!window.MouseEvent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const userAgent = {
|
|
22
|
+
browser: {
|
|
23
|
+
isEdgeHtml: result.browser.name === "Edge",
|
|
24
|
+
isEdgeChromium: result.browser.name ==="Edg",
|
|
25
|
+
isInternetExplorer: result.browser.name === "IE",
|
|
26
|
+
isChrome: result.browser.name === "Chrome",
|
|
27
|
+
isFirefox: result.browser.name === "Firefox",
|
|
28
|
+
isAndroid: result.browser.name === "Android Browser"
|
|
29
|
+
},
|
|
30
|
+
os: {
|
|
31
|
+
isIos: result.os.name === "iOS",
|
|
32
|
+
isAndroid: result.os.name === "Android",
|
|
33
|
+
isWindows: result.os.name === "Windows",
|
|
34
|
+
version: result.os.version,
|
|
35
|
+
majorVersion: Number(result.os.version.substring(0, 2))
|
|
36
|
+
},
|
|
37
|
+
device: {
|
|
38
|
+
type: result.device.type,
|
|
39
|
+
isMobile: result.device.type === "mobile",
|
|
40
|
+
isTablet: result.device.type === "tablet",
|
|
41
|
+
isSmartTv: result.device.type === "smarttv",
|
|
42
|
+
supportsMouseEvents: supportsMouseEvents(),
|
|
43
|
+
supportsTouchEvents: supportsTouchEvents()
|
|
44
|
+
},
|
|
45
|
+
engine: {
|
|
46
|
+
isWebkit: result.engine.name === "WebKit", //Apple Safari
|
|
47
|
+
isBlink: result.engine.name === "Blink", //Google Chrome, Microsoft Edge and Opera
|
|
48
|
+
isGecko: result.engine.name === "Gecko", //Firefox
|
|
49
|
+
isTrident: result.engine.name === "Trident" //Internet Explorer
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as controls from "./controls/index";
|
|
2
|
+
import * as utilities from "./utilities/index";
|
|
3
|
+
|
|
4
|
+
export { controls };
|
|
5
|
+
export { utilities };
|
|
6
|
+
|
|
7
|
+
export * from "./framework/attributes";
|
|
8
|
+
export * from "./framework/event";
|
|
9
|
+
export * from "./framework/types";
|
|
10
|
+
export * from "./framework/observable";
|
|
11
|
+
export * from "./framework/style";
|
|
12
|
+
export * from "./framework/userAgent";
|
|
13
|
+
export * from "./framework/View";
|
|
14
|
+
export * from "./framework/ViewModel";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const blobDictionary: { [key: string]: string } = {};
|
|
2
|
+
|
|
3
|
+
async function toBase64(blob): Promise<string> {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const reader = new FileReader();
|
|
6
|
+
reader.onloadend = () => resolve(reader.result as string);
|
|
7
|
+
reader.readAsDataURL(blob);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function toUrl(blob: Blob): Promise<string> {
|
|
12
|
+
const base64 = await toBase64(blob);
|
|
13
|
+
let url = blobDictionary[base64];
|
|
14
|
+
if (!url) {
|
|
15
|
+
url = URL.createObjectURL(blob);
|
|
16
|
+
blobDictionary[base64] = url;
|
|
17
|
+
}
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function set(name: string, value: string, days: number) {
|
|
2
|
+
let expires = "";
|
|
3
|
+
if (days) {
|
|
4
|
+
const date = new Date();
|
|
5
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
6
|
+
expires = "; expires=" + date.toUTCString();
|
|
7
|
+
}
|
|
8
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function get(name: string) {
|
|
12
|
+
const nameEq = name + "=";
|
|
13
|
+
const ca = document.cookie.split(";");
|
|
14
|
+
for (let i = 0; i < ca.length; i++) {
|
|
15
|
+
let c = ca[i];
|
|
16
|
+
while (c.charAt(0) === " ") {
|
|
17
|
+
c = c.substring(1, c.length);
|
|
18
|
+
}
|
|
19
|
+
if (c.indexOf(nameEq) === 0) {
|
|
20
|
+
return c.substring(nameEq.length, c.length);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function eraseCookie(name: string) {
|
|
27
|
+
document.cookie = name + "=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
export function toObjectArray<T>(dataReaderTable: IDataReaderTable): Array<T> {
|
|
3
|
+
const objects = new Array<T>();
|
|
4
|
+
|
|
5
|
+
dataReaderTable.rows.forEach((row: Array<any>) => {
|
|
6
|
+
const object = {} as T;
|
|
7
|
+
for (let index = 0; index < dataReaderTable.columns.length; index++) {
|
|
8
|
+
const column = dataReaderTable.columns[index];
|
|
9
|
+
if (column.datatype === "Date") {
|
|
10
|
+
const value = row[index];
|
|
11
|
+
if (value) {
|
|
12
|
+
object[column.field] = new Date(value);
|
|
13
|
+
} else {
|
|
14
|
+
object[column.field] = null;
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
object[column.field] = row[index];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
objects.push(object);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return objects;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IDataReaderTableColumn {
|
|
27
|
+
field?: string;
|
|
28
|
+
datatype?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface IDataReaderTable {
|
|
32
|
+
rows: Array<Array<any>>;
|
|
33
|
+
columns: Array<IDataReaderTableColumn>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { newGuid } from "../uniqueId/uniqueId";
|
|
2
|
+
|
|
3
|
+
type ResponseType = "void" | "json" | "blob" | "arrayBuffer";
|
|
4
|
+
|
|
5
|
+
interface IException {
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
var testAccessToken: string = null;
|
|
10
|
+
export function setTestAccessToken(accessToken: string) {
|
|
11
|
+
testAccessToken = accessToken;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var isTestRun = false;
|
|
15
|
+
export function setIsTestRun(testRun: boolean) {
|
|
16
|
+
isTestRun = testRun;
|
|
17
|
+
}
|
|
18
|
+
var testUserId: number;
|
|
19
|
+
export function setTestUserId(userId: number) {
|
|
20
|
+
testUserId = userId;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var additionalHeaders: (headers: HeadersInit) => void;
|
|
24
|
+
|
|
25
|
+
export function initialize(headersProvider?: (headers: HeadersInit) => void) {
|
|
26
|
+
additionalHeaders = headersProvider;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function get(input: RequestInfo, authorized: boolean, responseType: ResponseType, init?: RequestInit): Promise<any> {
|
|
30
|
+
if (!init) {
|
|
31
|
+
init = {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
await setGetInitValues(init, authorized, responseType);
|
|
35
|
+
|
|
36
|
+
const response = await fetch(input, init);
|
|
37
|
+
|
|
38
|
+
return await getResponseValue(response, responseType);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function post(input: RequestInfo, data: any, authorized: boolean, responseType: ResponseType, init: RequestInit): Promise<any> {
|
|
42
|
+
if (!init) {
|
|
43
|
+
init = {};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await setPostInitValues(init, authorized, responseType, data);
|
|
47
|
+
|
|
48
|
+
const response = await fetch(input, init);
|
|
49
|
+
|
|
50
|
+
return await getResponseValue(response, responseType);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getFilename(response: Response): string {
|
|
54
|
+
const contentDispositionHeader = response.headers.get("Content-Disposition");
|
|
55
|
+
if (contentDispositionHeader) {
|
|
56
|
+
const parts = contentDispositionHeader.split(";");
|
|
57
|
+
for (let part of parts) {
|
|
58
|
+
if (part.indexOf("filename=") > -1) {
|
|
59
|
+
return part.replace("filename=", "").trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isJson(response: Response): boolean {
|
|
68
|
+
return response.headers.get("Content-Type")?.includes("application/json");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function getResponseValue(response: Response, responseType: ResponseType): Promise<any> {
|
|
72
|
+
if (response.ok) {
|
|
73
|
+
switch (responseType) {
|
|
74
|
+
case "void":
|
|
75
|
+
return null;
|
|
76
|
+
case "json":
|
|
77
|
+
return response.json();
|
|
78
|
+
case "blob":
|
|
79
|
+
return {
|
|
80
|
+
blob: await response.blob(),
|
|
81
|
+
name: getFilename(response)
|
|
82
|
+
};
|
|
83
|
+
case "arrayBuffer":
|
|
84
|
+
return response.arrayBuffer();
|
|
85
|
+
default:
|
|
86
|
+
throw new Error("The responseType" + responseType + " is not valid");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let errorMessage: string = null;
|
|
91
|
+
|
|
92
|
+
//Find out if the response contains a json body
|
|
93
|
+
if (isJson(response)) {
|
|
94
|
+
//If we know that the body contains json then we load the body as json
|
|
95
|
+
const responseJson = await response.json();
|
|
96
|
+
|
|
97
|
+
//Check if the responseJson has a message property
|
|
98
|
+
if (responseJson.message) {
|
|
99
|
+
errorMessage = responseJson.message;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!errorMessage) {
|
|
104
|
+
//If no error message was found in the body then we take the statusText
|
|
105
|
+
errorMessage = response.statusText;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
throw new Error(errorMessage);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function setGetInitValues(init: RequestInit, authorized: boolean, responseType: ResponseType) {
|
|
112
|
+
await setHeaders(init, authorized, responseType);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function setPostInitValues(init: RequestInit, authorized: boolean, responseType: ResponseType, data: any,) {
|
|
116
|
+
await setHeaders(init, authorized, responseType);
|
|
117
|
+
if (!init.method) {
|
|
118
|
+
init.method = "POST";
|
|
119
|
+
}
|
|
120
|
+
if (!init.mode) {
|
|
121
|
+
init.mode = "cors";
|
|
122
|
+
}
|
|
123
|
+
if (!init.cache) {
|
|
124
|
+
init.cache = "no-cache";
|
|
125
|
+
}
|
|
126
|
+
if (!init.credentials) {
|
|
127
|
+
init.credentials = "same-origin";
|
|
128
|
+
}
|
|
129
|
+
if (!init.headers) {
|
|
130
|
+
init.headers = {};
|
|
131
|
+
}
|
|
132
|
+
if (!init.headers["Content-Type"] && !(data instanceof FormData)) {
|
|
133
|
+
init.headers["Content-Type"] = "application/json";
|
|
134
|
+
}
|
|
135
|
+
if (data instanceof FormData) {
|
|
136
|
+
delete init.headers["Content-Type"];
|
|
137
|
+
}
|
|
138
|
+
if (!init.redirect) {
|
|
139
|
+
init.redirect = "follow";
|
|
140
|
+
}
|
|
141
|
+
if (!init.referrerPolicy) {
|
|
142
|
+
init.referrerPolicy = "no-referrer";
|
|
143
|
+
}
|
|
144
|
+
if (!init.body) {
|
|
145
|
+
if (data instanceof FormData) {
|
|
146
|
+
init.body = data;
|
|
147
|
+
} else {
|
|
148
|
+
init.body = JSON.stringify(data);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function setHeaders(init: RequestInit, authorized: boolean, responsetype: ResponseType): Promise<void> {
|
|
154
|
+
if (!init.headers) {
|
|
155
|
+
init.headers = {};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (responsetype === "json") {
|
|
159
|
+
init.headers["Accept"] = "application/json";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// #if Test
|
|
163
|
+
if (isTestRun) {
|
|
164
|
+
init.headers["TestUserId"] = testUserId;
|
|
165
|
+
}
|
|
166
|
+
// #endif
|
|
167
|
+
|
|
168
|
+
init.headers["X-Request-ID"] = newGuid();
|
|
169
|
+
|
|
170
|
+
//Check if there are additional headers to be set.
|
|
171
|
+
if (additionalHeaders) {
|
|
172
|
+
additionalHeaders(init.headers);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//Check if a test AccessToken is avaible
|
|
176
|
+
if (testAccessToken) {
|
|
177
|
+
init.headers["Authorization"] = "Bearer " + testAccessToken;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function fromFileList(fileList: FileList): FormData {
|
|
2
|
+
if (fileList && fileList.length > 0) {
|
|
3
|
+
const formData = new FormData();
|
|
4
|
+
for (let index = 0; index < fileList.length; index++) {
|
|
5
|
+
const file = fileList[index];
|
|
6
|
+
formData.append(file.name, file);
|
|
7
|
+
}
|
|
8
|
+
return formData;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return null;
|
|
12
|
+
}
|