@draftbit/core 46.4.4-8a6164.2 → 46.4.4-926784.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -6
  2. package/lib/commonjs/components/Text.js +6 -2
  3. package/lib/commonjs/components/TextField.js +5 -1
  4. package/lib/commonjs/index.js +84 -0
  5. package/lib/commonjs/mappings/HtmlElements.js +125 -0
  6. package/lib/commonjs/mappings/TextField.js +1 -1
  7. package/lib/commonjs/mappings/TextInput.js +1 -1
  8. package/lib/module/components/CircularProgress.js +15 -7
  9. package/lib/module/components/DatePicker/DatePicker.js +1 -5
  10. package/lib/module/components/Justification.js +0 -1
  11. package/lib/module/components/Portal/PortalHost.js +26 -15
  12. package/lib/module/components/Text.js +38 -8
  13. package/lib/module/components/TextField.js +67 -31
  14. package/lib/module/index.js +1 -0
  15. package/lib/module/mappings/HtmlElements.js +116 -0
  16. package/lib/module/mappings/TextField.js +1 -1
  17. package/lib/module/mappings/TextInput.js +1 -1
  18. package/lib/typescript/src/components/Text.d.ts +2 -1
  19. package/lib/typescript/src/components/TextField.d.ts +2 -1
  20. package/lib/typescript/src/index.d.ts +1 -0
  21. package/lib/typescript/src/mappings/HtmlElements.d.ts +49 -0
  22. package/lib/typescript/src/mappings/TextField.d.ts +2 -2
  23. package/lib/typescript/src/mappings/TextInput.d.ts +1 -1
  24. package/package.json +4 -3
  25. package/src/components/DatePicker/DatePicker.js +0 -3
  26. package/src/components/DatePicker/DatePicker.tsx +0 -4
  27. package/src/components/Text.js +8 -2
  28. package/src/components/Text.tsx +6 -1
  29. package/src/components/TextField.js +6 -1
  30. package/src/components/TextField.tsx +7 -1
  31. package/src/index.js +1 -0
  32. package/src/index.tsx +2 -0
  33. package/src/mappings/HtmlElements.js +141 -0
  34. package/src/mappings/HtmlElements.ts +151 -0
  35. package/src/mappings/TextField.js +1 -1
  36. package/src/mappings/TextField.ts +1 -1
  37. package/src/mappings/TextInput.js +1 -1
  38. package/src/mappings/TextInput.ts +1 -1
@@ -21,8 +21,6 @@ var _Touchable = _interopRequireDefault(require("../Touchable"));
21
21
 
22
22
  var _DatePickerComponent = _interopRequireDefault(require("./DatePickerComponent"));
23
23
 
24
- var _utilities = require("../../utilities");
25
-
26
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
25
 
28
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -273,12 +271,9 @@ const DatePicker = _ref => {
273
271
  })
274
272
  }]
275
273
  };
276
- const {
277
- textStyles
278
- } = (0, _utilities.extractStyles)(style);
279
274
  const inputStyles = [styles.input, inputStyle, type === "solid" ? {
280
275
  marginHorizontal: 12
281
- } : {}, textStyles]; // const render = (props) => <NativeTextInput {...props} />;
276
+ } : {}]; // const render = (props) => <NativeTextInput {...props} />;
282
277
 
283
278
  return /*#__PURE__*/React.createElement(_reactNative.View, {
284
279
  style: [styles.container, style]
@@ -24,10 +24,14 @@ class Text extends React.Component {
24
24
  super(...arguments);
25
25
 
26
26
  _defineProperty(this, "_root", void 0);
27
+
28
+ _defineProperty(this, "state", {
29
+ nativeProps: {}
30
+ });
27
31
  }
28
32
 
29
33
  setNativeProps(args) {
30
- return this._root && this._root.setNativeProps(args);
34
+ this.state.nativeProps = args || {};
31
35
  }
32
36
 
33
37
  render() {
@@ -36,7 +40,7 @@ class Text extends React.Component {
36
40
  ...rest
37
41
  } = this.props;
38
42
  const writingDirection = _reactNative.I18nManager.isRTL ? "rtl" : "ltr";
39
- return /*#__PURE__*/React.createElement(_reactNative.Text, _extends({}, rest, {
43
+ return /*#__PURE__*/React.createElement(_reactNative.Text, _extends({}, rest, this.state.nativeProps, {
40
44
  ref: c => {
41
45
  this._root = c;
42
46
  },
@@ -32,6 +32,7 @@ class TextField extends React.Component {
32
32
  super(...arguments);
33
33
 
34
34
  _defineProperty(this, "state", {
35
+ nativeProps: {},
35
36
  labeled: new _reactNative.Animated.Value(this.props.value || this.props.error ? 0 : 1),
36
37
  focused: false,
37
38
  placeholder: this.props.error ? this.props.placeholder : "",
@@ -162,7 +163,9 @@ class TextField extends React.Component {
162
163
  * @internal
163
164
  */
164
165
  setNativeProps(args) {
165
- return this._root && this._root.setNativeProps(args);
166
+ this.setState(state => ({ ...state,
167
+ nativeState: args || {}
168
+ }));
166
169
  }
167
170
 
168
171
  isFocused() {
@@ -444,6 +447,7 @@ class TextField extends React.Component {
444
447
  underlineColorAndroid: "transparent",
445
448
  style: inputStyles,
446
449
  ...rest,
450
+ ...this.state.nativeProps,
447
451
  value: this.state.value
448
452
  })), rightIconName ? /*#__PURE__*/React.createElement(Icon, {
449
453
  name: rightIconName,
@@ -3,6 +3,76 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ injectIcon: true,
8
+ withTheme: true,
9
+ ThemeProvider: true,
10
+ Provider: true,
11
+ DefaultTheme: true,
12
+ Link: true,
13
+ Banner: true,
14
+ Button: true,
15
+ ButtonSolid: true,
16
+ ButtonOutline: true,
17
+ Avatar: true,
18
+ CircleImage: true,
19
+ AvatarEdit: true,
20
+ Card: true,
21
+ Carousel: true,
22
+ Checkbox: true,
23
+ CheckboxGroup: true,
24
+ CheckboxRow: true,
25
+ Container: true,
26
+ Divider: true,
27
+ FAB: true,
28
+ FieldSearchBarFull: true,
29
+ IconButton: true,
30
+ Image: true,
31
+ SVG: true,
32
+ NumberInput: true,
33
+ ScreenContainer: true,
34
+ StarRating: true,
35
+ Surface: true,
36
+ Switch: true,
37
+ SwitchRow: true,
38
+ TextField: true,
39
+ ToggleButton: true,
40
+ Touchable: true,
41
+ AccordionGroup: true,
42
+ AccordionItem: true,
43
+ ActionSheet: true,
44
+ ActionSheetItem: true,
45
+ ActionSheetCancel: true,
46
+ Swiper: true,
47
+ SwiperItem: true,
48
+ Center: true,
49
+ Circle: true,
50
+ Square: true,
51
+ Row: true,
52
+ Stack: true,
53
+ Spacer: true,
54
+ RadioButton: true,
55
+ RadioButtonGroup: true,
56
+ RadioButtonRow: true,
57
+ RadioButtonFieldGroup: true,
58
+ CardBlock: true,
59
+ CardContainer: true,
60
+ CardContainerRating: true,
61
+ CardInline: true,
62
+ DatePicker: true,
63
+ HeaderLarge: true,
64
+ HeaderMedium: true,
65
+ HeaderOverline: true,
66
+ Picker: true,
67
+ ProgressBar: true,
68
+ ProgressCircle: true,
69
+ RowBodyIcon: true,
70
+ RowHeadlineImageCaption: true,
71
+ RowHeadlineImageIcon: true,
72
+ Slider: true,
73
+ Stepper: true,
74
+ useAuthState: true
75
+ };
6
76
  Object.defineProperty(exports, "AccordionGroup", {
7
77
  enumerable: true,
8
78
  get: function () {
@@ -476,6 +546,20 @@ var _Layout = require("./components/Layout");
476
546
 
477
547
  var _index = require("./components/RadioButton/index");
478
548
 
549
+ var _htmlElements = require("@expo/html-elements");
550
+
551
+ Object.keys(_htmlElements).forEach(function (key) {
552
+ if (key === "default" || key === "__esModule") return;
553
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
554
+ if (key in exports && exports[key] === _htmlElements[key]) return;
555
+ Object.defineProperty(exports, key, {
556
+ enumerable: true,
557
+ get: function () {
558
+ return _htmlElements[key];
559
+ }
560
+ });
561
+ });
562
+
479
563
  var _CardBlock = _interopRequireDefault(require("./components/CardBlock"));
480
564
 
481
565
  var _CardContainer = _interopRequireDefault(require("./components/CardContainer"));
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SEED_DATA = void 0;
7
+
8
+ var _types = require("@draftbit/types");
9
+
10
+ const SEED_DATA_TRIGGERS = [_types.Triggers.OnValueChange];
11
+ const ELEMENT_PROPS = {
12
+ category: _types.COMPONENT_TYPES.element,
13
+ doc_link: "https://www.npmjs.com/package/@expo/html-elements",
14
+ code_link: "https://github.com/expo/expo/tree/master/packages/html-elements",
15
+ stylesPanelSections: [_types.StylesPanelSections.Typography, _types.StylesPanelSections.LayoutSelectedItem, _types.StylesPanelSections.MarginsAndPaddings, _types.StylesPanelSections.Effects],
16
+ layout: {
17
+ margin: 0
18
+ },
19
+ triggers: SEED_DATA_TRIGGERS
20
+ };
21
+ const HEADING_PROPS = { ...ELEMENT_PROPS
22
+ };
23
+ const SEED_DATA = [{
24
+ name: "H1",
25
+ tag: "H1",
26
+ ...HEADING_PROPS
27
+ }, {
28
+ name: "H2",
29
+ tag: "H2",
30
+ ...HEADING_PROPS
31
+ }, {
32
+ name: "H3",
33
+ tag: "H3",
34
+ ...HEADING_PROPS
35
+ }, {
36
+ name: "H4",
37
+ tag: "H4",
38
+ ...HEADING_PROPS
39
+ }, {
40
+ name: "H5",
41
+ tag: "H5",
42
+ ...HEADING_PROPS
43
+ }, {
44
+ name: "H6",
45
+ tag: "H6",
46
+ ...HEADING_PROPS
47
+ }, {
48
+ name: "Anchor",
49
+ tag: "A",
50
+ ...ELEMENT_PROPS,
51
+ props: {
52
+ href: (0, _types.createTextProp)({
53
+ label: "href",
54
+ description: "Specify the URL",
55
+ defaultValue: ""
56
+ }),
57
+ target: {
58
+ group: _types.GROUPS.basic,
59
+ label: "target",
60
+ description: "decide where link should open",
61
+ formType: _types.FORM_TYPES.flatArray,
62
+ defaultValue: "_blank",
63
+ options: ["_blank", "_self", "_parent", "_top"]
64
+ }
65
+ }
66
+ }, {
67
+ name: "Paragraph",
68
+ tag: "P",
69
+ ...ELEMENT_PROPS,
70
+ props: {// NOTE - Keeping the props commented until we figure out a way to use this props from draftbit side.
71
+ // strong: createBoolProp({
72
+ // label: "Strong",
73
+ // description: "Strong",
74
+ // }),
75
+ // strike: createBoolProp({
76
+ // label: "Strike",
77
+ // description: "Strike through",
78
+ // }),
79
+ // italic: createBoolProp({
80
+ // label: "Italic",
81
+ // description: "Italic Fonts",
82
+ // }),
83
+ // bold: createBoolProp({
84
+ // label: "Bold",
85
+ // description: "Bold",
86
+ // }),
87
+ }
88
+ }, {
89
+ name: "Code",
90
+ tag: "Code",
91
+ ...ELEMENT_PROPS
92
+ }, {
93
+ name: "Pre",
94
+ tag: "Pre",
95
+ ...ELEMENT_PROPS
96
+ }, {
97
+ name: "Mark",
98
+ tag: "Mark",
99
+ ...ELEMENT_PROPS
100
+ }, {
101
+ name: "BR",
102
+ tag: "BR",
103
+ ...ELEMENT_PROPS
104
+ }, {
105
+ name: "BlockQuote",
106
+ tag: "BlockQuote",
107
+ ...ELEMENT_PROPS
108
+ }, {
109
+ name: "Time",
110
+ tag: "Time",
111
+ ...ELEMENT_PROPS
112
+ }, {
113
+ name: "UL",
114
+ tag: "UL",
115
+ ...ELEMENT_PROPS
116
+ }, {
117
+ name: "LI",
118
+ tag: "LI",
119
+ ...ELEMENT_PROPS
120
+ }, {
121
+ name: "HR",
122
+ tag: "HR",
123
+ ...ELEMENT_PROPS
124
+ }];
125
+ exports.SEED_DATA = SEED_DATA;
@@ -24,7 +24,7 @@ const SEED_DATA_PROPS = {
24
24
  description: "Can automatically capitalize sentences, words, and characters (Default: none).",
25
25
  editable: true,
26
26
  required: false,
27
- defaultValue: null,
27
+ defaultValue: "none",
28
28
  options: ["none", "sentences", "words", "characters"],
29
29
  formType: _types.FORM_TYPES.flatArray,
30
30
  propType: _types.PROP_TYPES.STRING
@@ -103,7 +103,7 @@ const SEED_DATA = [{
103
103
  description: "Can automatically capitalize sentences, words, and characters (Default: none).",
104
104
  editable: true,
105
105
  required: false,
106
- defaultValue: null,
106
+ defaultValue: "none",
107
107
  options: ["none", "sentences", "words", "characters"],
108
108
  formType: _types.FORM_TYPES.flatArray,
109
109
  propType: _types.PROP_TYPES.STRING
@@ -1,5 +1,3 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
1
  import React from "react";
4
2
  import { View } from "react-native";
5
3
  import { Svg, Path, G } from "react-native-svg";
@@ -8,23 +6,23 @@ class CircularProgress extends React.Component {
8
6
  constructor() {
9
7
  super(...arguments);
10
8
 
11
- _defineProperty(this, "polarToCartesian", (centerX, centerY, radius, angleInDegrees) => {
9
+ this.polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
12
10
  var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
13
11
  return {
14
12
  x: centerX + radius * Math.cos(angleInRadians),
15
13
  y: centerY + radius * Math.sin(angleInRadians)
16
14
  };
17
- });
15
+ };
18
16
 
19
- _defineProperty(this, "circlePath", (x, y, radius, startAngle, endAngle) => {
17
+ this.circlePath = (x, y, radius, startAngle, endAngle) => {
20
18
  var start = this.polarToCartesian(x, y, radius, endAngle * 0.9999);
21
19
  var end = this.polarToCartesian(x, y, radius, startAngle);
22
20
  var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
23
21
  var d = ["M", start.x, start.y, "A", radius, radius, 0, largeArcFlag, 0, end.x, end.y];
24
22
  return d.join(" ");
25
- });
23
+ };
26
24
 
27
- _defineProperty(this, "clampFill", fill => Math.min(100, Math.max(0, fill)));
25
+ this.clampFill = fill => Math.min(100, Math.max(0, fill));
28
26
  }
29
27
 
30
28
  render() {
@@ -107,4 +105,14 @@ class CircularProgress extends React.Component {
107
105
 
108
106
  }
109
107
 
108
+ export default CircularProgress;strokeLinecap: lineCap,
109
+ strokeDasharray: strokeDasharrayTint,
110
+ fill: "transparent"
111
+ }), cap)), children && /*#__PURE__*/React.createElement(View, {
112
+ style: localChildrenContainerStyle
113
+ }, children(fill)));
114
+ }
115
+
116
+ }
117
+
110
118
  export default CircularProgress;
@@ -8,7 +8,6 @@ import { withTheme } from "../../theming";
8
8
  import Portal from "../Portal/Portal";
9
9
  import Touchable from "../Touchable";
10
10
  import DateTimePicker from "./DatePickerComponent";
11
- import { extractStyles } from "../../utilities";
12
11
  const AnimatedText = Animated.createAnimatedComponent(Text);
13
12
  const FOCUS_ANIMATION_DURATION = 150;
14
13
  const BLUR_ANIMATION_DURATION = 180;
@@ -250,12 +249,9 @@ const DatePicker = _ref => {
250
249
  })
251
250
  }]
252
251
  };
253
- const {
254
- textStyles
255
- } = extractStyles(style);
256
252
  const inputStyles = [styles.input, inputStyle, type === "solid" ? {
257
253
  marginHorizontal: 12
258
- } : {}, textStyles]; // const render = (props) => <NativeTextInput {...props} />;
254
+ } : {}]; // const render = (props) => <NativeTextInput {...props} />;
259
255
 
260
256
  return /*#__PURE__*/React.createElement(View, {
261
257
  style: [styles.container, style]
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +1,3 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
1
  import * as React from "react";
4
2
  import { View, StyleSheet } from "react-native";
5
3
  import PortalManager from "./PortalManager";
@@ -33,11 +31,11 @@ export default class PortalHost extends React.Component {
33
31
  constructor() {
34
32
  super(...arguments);
35
33
 
36
- _defineProperty(this, "setManager", manager => {
34
+ this.setManager = manager => {
37
35
  this.manager = manager;
38
- });
36
+ };
39
37
 
40
- _defineProperty(this, "mount", children => {
38
+ this.mount = children => {
41
39
  const key = this.nextKey++;
42
40
 
43
41
  if (this.manager) {
@@ -51,9 +49,9 @@ export default class PortalHost extends React.Component {
51
49
  }
52
50
 
53
51
  return key;
54
- });
52
+ };
55
53
 
56
- _defineProperty(this, "update", (key, children) => {
54
+ this.update = (key, children) => {
57
55
  if (this.manager) {
58
56
  this.manager.update(key, children);
59
57
  } else {
@@ -71,9 +69,9 @@ export default class PortalHost extends React.Component {
71
69
  this.queue.push(op);
72
70
  }
73
71
  }
74
- });
72
+ };
75
73
 
76
- _defineProperty(this, "unmount", key => {
74
+ this.unmount = key => {
77
75
  if (this.manager) {
78
76
  this.manager.unmount(key);
79
77
  } else {
@@ -82,13 +80,10 @@ export default class PortalHost extends React.Component {
82
80
  key
83
81
  });
84
82
  }
85
- });
86
-
87
- _defineProperty(this, "nextKey", 0);
88
-
89
- _defineProperty(this, "queue", []);
83
+ };
90
84
 
91
- _defineProperty(this, "manager", void 0);
85
+ this.nextKey = 0;
86
+ this.queue = [];
92
87
  }
93
88
 
94
89
  componentDidMount() {
@@ -132,6 +127,22 @@ export default class PortalHost extends React.Component {
132
127
  }));
133
128
  }
134
129
 
130
+ }
131
+ PortalHost.displayName = "Portal.Host";
132
+ const styles = StyleSheet.create({
133
+ container: {
134
+ flex: 1
135
+ }
136
+ }); }
137
+ }, /*#__PURE__*/React.createElement(View, {
138
+ style: styles.container,
139
+ collapsable: false,
140
+ pointerEvents: "box-none"
141
+ }, this.props.children), /*#__PURE__*/React.createElement(PortalManager, {
142
+ ref: this.setManager
143
+ }));
144
+ }
145
+
135
146
  }
136
147
 
137
148
  _defineProperty(PortalHost, "displayName", "Portal.Host");
@@ -1,7 +1,3 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
1
  import * as React from "react";
6
2
  import { Text as NativeText, I18nManager } from "react-native";
7
3
  import { withTheme } from "../theming";
@@ -9,12 +5,13 @@ import { withTheme } from "../theming";
9
5
  class Text extends React.Component {
10
6
  constructor() {
11
7
  super(...arguments);
12
-
13
- _defineProperty(this, "_root", void 0);
8
+ this.state = {
9
+ nativeProps: {}
10
+ };
14
11
  }
15
12
 
16
13
  setNativeProps(args) {
17
- return this._root && this._root.setNativeProps(args);
14
+ this.state.nativeProps = args || {};
18
15
  }
19
16
 
20
17
  render() {
@@ -23,7 +20,40 @@ class Text extends React.Component {
23
20
  ...rest
24
21
  } = this.props;
25
22
  const writingDirection = I18nManager.isRTL ? "rtl" : "ltr";
26
- return /*#__PURE__*/React.createElement(NativeText, _extends({}, rest, {
23
+ return /*#__PURE__*/React.createElement(NativeText, { ...rest,
24
+ ...this.state.nativeProps,
25
+ ref: c => {
26
+ this._root = c;
27
+ },
28
+ style: [{
29
+ textAlign: "left",
30
+ writingDirection
31
+ }, style]
32
+ });
33
+ }
34
+
35
+ }
36
+
37
+ export const BaseLink = _ref => {
38
+ let {
39
+ style,
40
+ theme,
41
+ title,
42
+ ...props
43
+ } = _ref;
44
+ return /*#__PURE__*/React.createElement(Text, {
45
+ hitSlop: 8,
46
+ style: [{
47
+ color: theme.colors.primary
48
+ }, style],
49
+ theme: theme,
50
+ ...props
51
+ }, title);
52
+ };
53
+ const Link = withTheme(BaseLink);
54
+ export { Link };
55
+ export default withTheme(Text); "ltr";
56
+ return /*#__PURE__*/React.createElement(NativeText, _extends({}, rest, this.state.nativeProps, {
27
57
  ref: c => {
28
58
  this._root = c;
29
59
  },