@jag-k/scriptable-jsx 1.1.0 → 1.1.1

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/index.js CHANGED
@@ -384,7 +384,6 @@ function alertCreateElement(element, props, ...children) {
384
384
  }
385
385
  }
386
386
 
387
- /// <reference path="../types/index.d.ts" />
388
387
  const createElements = [widgetCreateElement, alertCreateElement];
389
388
  class ScriptableJSX {
390
389
  static createElement(element, props, ...children) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@jag-k/scriptable-jsx",
3
3
  "description": "Create a Scriptable bundle from JSX",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
- "version": "1.1.0",
5
+ "version": "1.1.1",
6
6
  "author": {
7
7
  "email": "jag.konon@gmail.com",
8
8
  "name": "Jag_k",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "rollup -c",
28
- "watch": "rollup -cw",
28
+ "watch": "npm run prebuild && rollup -cw",
29
29
  "prebuild": "rm -rf dist"
30
30
  },
31
31
  "files": [
package/types/index.d.ts CHANGED
@@ -1,10 +1,117 @@
1
- /// <reference path="./alert.d.ts" />
2
- /// <reference path="./widget.d.ts" />
1
+ declare namespace JSX {
2
+ // Widgets types
3
+ type JSXColor = Color | string | number;
4
+ type Align = "left" | "right" | "center";
5
+ type ContentAlign = "top" | "bottom" | "center";
6
+ type DateStyle = "time" | "date" | "relative" | "offset" | "timer";
3
7
 
4
- import {JSX as Alert} from "./alert";
5
- import {JSX as Widget} from "./widget";
8
+ interface Alienable {
9
+ align?: Align;
10
+ }
11
+
12
+ interface ContentAlienable {
13
+ align?: ContentAlign;
14
+ }
15
+
16
+ interface PaddingProps {
17
+ 'p-all'?: number;
18
+
19
+ 'p-x'?: number;
20
+ 'p-y'?: number;
21
+
22
+ 'p-top'?: number;
23
+ 'p-bottom'?: number;
24
+ 'p-right'?: number;
25
+ 'p-left'?: number;
26
+ }
27
+
28
+ interface WidgetAndStackBase extends PaddingProps {
29
+ spacing?: number;
30
+ backgroundColor?: JSXColor;
31
+ backgroundImage?: Image;
32
+ backgroundGradient?: LinearGradient;
33
+ url?: string;
34
+ }
35
+
36
+ interface StackProps extends WidgetAndStackBase, ContentAlienable {
37
+ layout?: "vertical" | "horizontal";
38
+ size?: Size;
39
+ cornerRadius?: number;
40
+ borderWidth?: number;
41
+ borderColor?: JSXColor;
42
+ }
43
+
44
+ interface WidgetProps extends WidgetAndStackBase {
45
+ refreshAfterDate?: Date;
46
+ }
47
+
48
+ interface SpacerProps {
49
+ length?: number;
50
+ }
51
+
52
+ interface TextProps extends Alienable {
53
+ font?: Font;
54
+ color?: JSXColor;
55
+ opacity?: number;
56
+ lineLimit?: number;
57
+ minimumScaleFactor?: number;
58
+ shadowColor?: JSXColor;
59
+ shadowOffset?: Point;
60
+ shadowRadius?: number;
61
+ url?: string;
62
+ }
63
+
64
+ type ImageContentMode = "fitting" | "filling";
65
+
66
+ interface ImageProps extends Alienable {
67
+ data: string /* file url */ | Image | Data;
68
+ size?: Size;
69
+ cornerRadius?: number;
70
+ resizable?: boolean;
71
+ opacity?: number;
72
+ borderColor?: JSXColor;
73
+ borderWidth?: number;
74
+ containerRelativeShape?: boolean;
75
+ tintColor?: JSXColor;
76
+ url?: string;
77
+ contentMode?: ImageContentMode;
78
+ }
79
+
80
+ interface DateProps extends TextProps {
81
+ date: Date | string | number;
82
+ style?: DateStyle;
83
+ }
84
+
85
+ // Alert types
86
+ export interface AlertProps {
87
+ title?: string;
88
+ message?: string;
89
+ }
90
+
91
+ export interface ActionProps {
92
+ type?: "action" | "cancel" | "destructive";
93
+ text?: string;
94
+ children?: string | string[];
95
+ }
96
+
97
+ export interface TextFieldProps {
98
+ placeholder?: string;
99
+ text?: string;
100
+ secure?: boolean;
101
+ }
102
+
103
+ interface IntrinsicElements {
104
+ // Widget Elements
105
+ widget: WidgetProps;
106
+ stack: StackProps;
107
+ image: ImageProps;
108
+ spacer: SpacerProps;
109
+ text: TextProps;
110
+ date: DateProps;
6
111
 
7
- export declare namespace JSX {
8
- export interface IntrinsicElements extends Alert.IntrinsicElements, Widget.IntrinsicElements {
112
+ // Alert Elements
113
+ alert: AlertProps;
114
+ action: ActionProps;
115
+ 'text-field': TextFieldProps;
9
116
  }
10
117
  }
package/dist/alert.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /// <reference types="@types/scriptable-ios" />
2
- export declare function alertCreateElement(element: unknown, props: Record<string, any>, ...children: any[]): Alert | {
3
- type: "text-field";
4
- props: Record<string, any>;
5
- children?: never;
6
- } | {
7
- type: "action";
8
- props: Record<string, any>;
9
- children: any[];
10
- } | undefined;
package/dist/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- /// <reference path="../types/index.d.ts" />
2
- /// <reference types="@types/scriptable-ios" />
3
- export declare class ScriptableJSX {
4
- static createElement(element: unknown, props: Record<string, any>, ...children: any[]): Alert | {
5
- type: "text-field";
6
- props: Record<string, any>;
7
- children?: never;
8
- } | {
9
- type: "action";
10
- props: Record<string, any>;
11
- children: any[];
12
- } | ListWidget | {
13
- type: "text";
14
- props: Record<string, any>;
15
- text: string;
16
- children?: never;
17
- } | {
18
- type: "stack";
19
- props: Record<string, any>;
20
- children: any[];
21
- text?: never;
22
- } | {
23
- type: "spacer";
24
- props: Record<string, any>;
25
- text?: never;
26
- children?: never;
27
- } | {
28
- type: "image";
29
- props: Record<string, any>;
30
- text?: never;
31
- children?: never;
32
- } | {
33
- type: "date";
34
- props: Record<string, any>;
35
- text?: never;
36
- children?: never;
37
- } | undefined;
38
- }
package/dist/widget.d.ts DELETED
@@ -1,27 +0,0 @@
1
- /// <reference types="@types/scriptable-ios" />
2
- export declare function widgetCreateElement(element: unknown, props: Record<string, any>, ...children: any[]): ListWidget | {
3
- type: "text";
4
- props: Record<string, any>;
5
- text: string;
6
- children?: never;
7
- } | {
8
- type: "stack";
9
- props: Record<string, any>;
10
- children: any[];
11
- text?: never;
12
- } | {
13
- type: "spacer";
14
- props: Record<string, any>;
15
- text?: never;
16
- children?: never;
17
- } | {
18
- type: "image";
19
- props: Record<string, any>;
20
- text?: never;
21
- children?: never;
22
- } | {
23
- type: "date";
24
- props: Record<string, any>;
25
- text?: never;
26
- children?: never;
27
- } | undefined;
package/types/alert.d.ts DELETED
@@ -1,24 +0,0 @@
1
- export declare namespace JSX {
2
- interface AlertProps {
3
- title?: string;
4
- message?: string;
5
- }
6
-
7
- interface ActionProps {
8
- type?: "action" | "cancel" | "destructive";
9
- text?: string;
10
- children?: string | string[];
11
- }
12
-
13
- interface TextFieldProps {
14
- placeholder?: string;
15
- text?: string;
16
- secure?: boolean;
17
- }
18
-
19
- interface IntrinsicElements {
20
- alert: AlertProps;
21
- action: ActionProps;
22
- 'text-field': TextFieldProps;
23
- }
24
- }
package/types/widget.d.ts DELETED
@@ -1,92 +0,0 @@
1
- export declare namespace JSX {
2
- type JSXColor = Color | string | number;
3
- type Align = "left" | "right" | "center";
4
- type ContentAlign = "top" | "bottom" | "center";
5
- type DateStyle = "time" | "date" | "relative" | "offset" | "timer";
6
-
7
- interface Alienable {
8
- align?: Align;
9
- }
10
-
11
- interface ContentAlienable {
12
- align?: ContentAlign;
13
- }
14
-
15
- interface PaddingProps {
16
- 'p-all'?: number;
17
-
18
- 'p-x'?: number;
19
- 'p-y'?: number;
20
-
21
- 'p-top'?: number;
22
- 'p-bottom'?: number;
23
- 'p-right'?: number;
24
- 'p-left'?: number;
25
- }
26
-
27
- interface WidgetAndStackBase extends PaddingProps {
28
- spacing?: number;
29
- backgroundColor?: JSXColor;
30
- backgroundImage?: Image;
31
- backgroundGradient?: LinearGradient;
32
- url?: string;
33
- }
34
-
35
- interface StackProps extends WidgetAndStackBase, ContentAlienable {
36
- layout?: "vertical" | "horizontal";
37
- size?: Size;
38
- cornerRadius?: number;
39
- borderWidth?: number;
40
- borderColor?: JSXColor;
41
- }
42
-
43
- interface WidgetProps extends WidgetAndStackBase {
44
- refreshAfterDate?: Date;
45
- }
46
-
47
- interface SpacerProps {
48
- length?: number;
49
- }
50
-
51
- interface TextProps extends Alienable {
52
- font?: Font;
53
- color?: JSXColor;
54
- opacity?: number;
55
- lineLimit?: number;
56
- minimumScaleFactor?: number;
57
- shadowColor?: JSXColor;
58
- shadowOffset?: Point;
59
- shadowRadius?: number;
60
- url?: string;
61
- }
62
-
63
- type ImageContentMode = "fitting" | "filling";
64
-
65
- interface ImageProps extends Alienable {
66
- data: string /* file url */ | Image | Data;
67
- size?: Size;
68
- cornerRadius?: number;
69
- resizable?: boolean;
70
- opacity?: number;
71
- borderColor?: JSXColor;
72
- borderWidth?: number;
73
- containerRelativeShape?: boolean;
74
- tintColor?: JSXColor;
75
- url?: string;
76
- contentMode?: ImageContentMode;
77
- }
78
-
79
- interface DateProps extends TextProps {
80
- date: Date | string | number;
81
- style?: DateStyle;
82
- }
83
-
84
- interface IntrinsicElements {
85
- widget: WidgetProps;
86
- stack: StackProps;
87
- image: ImageProps;
88
- spacer: SpacerProps;
89
- text: TextProps;
90
- date: DateProps;
91
- }
92
- }