@draftbit/core 46.7.9-cbe269.2 → 46.7.9-cfda7d.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/AnimatedCircularProgress.js +12 -1
  2. package/lib/commonjs/components/Banner.js +23 -4
  3. package/lib/commonjs/components/Checkbox/context.js +1 -1
  4. package/lib/commonjs/components/CircleImage.js +15 -1
  5. package/lib/commonjs/components/DatePicker/DatePicker.js +6 -0
  6. package/lib/commonjs/components/DeprecatedCardWrapper.js +15 -1
  7. package/lib/commonjs/components/Divider.js +1 -14
  8. package/lib/commonjs/components/Image.js +17 -2
  9. package/lib/commonjs/components/Picker/Picker.js +9 -4
  10. package/lib/commonjs/components/Picker/PickerComponent.ios.js +36 -11
  11. package/lib/commonjs/components/Picker/PickerComponent.web.js +20 -3
  12. package/lib/commonjs/components/ProgressBar.js +37 -7
  13. package/lib/commonjs/components/RadioButton/context.js +1 -1
  14. package/lib/commonjs/components/TextField.js +28 -76
  15. package/lib/commonjs/constants.js +1 -1
  16. package/lib/commonjs/mappings/DatePicker.js +6 -1
  17. package/lib/commonjs/mappings/Picker.js +5 -0
  18. package/lib/module/components/DatePicker/DatePicker.js +7 -1
  19. package/lib/module/components/Picker/Picker.js +10 -5
  20. package/lib/module/mappings/DatePicker.js +7 -2
  21. package/lib/module/mappings/Picker.js +6 -1
  22. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +1 -0
  23. package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
  24. package/lib/typescript/src/components/Picker/Picker.d.ts +1 -0
  25. package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
  26. package/lib/typescript/src/mappings/DatePicker.d.ts +10 -0
  27. package/lib/typescript/src/mappings/DatePicker.d.ts.map +1 -1
  28. package/lib/typescript/src/mappings/Picker.d.ts +10 -0
  29. package/lib/typescript/src/mappings/Picker.d.ts.map +1 -1
  30. package/package.json +3 -3
  31. package/src/components/DatePicker/DatePicker.js +7 -2
  32. package/src/components/DatePicker/DatePicker.tsx +9 -0
  33. package/src/components/Picker/Picker.js +8 -4
  34. package/src/components/Picker/Picker.tsx +11 -5
  35. package/src/mappings/DatePicker.js +6 -1
  36. package/src/mappings/DatePicker.ts +6 -0
  37. package/src/mappings/Picker.js +6 -1
  38. package/src/mappings/Picker.ts +6 -0
@@ -10,7 +10,6 @@ var _CircularProgress = _interopRequireDefault(require("./CircularProgress"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  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); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- 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); }
14
13
  const AnimatedProgress = _reactNative.Animated.createAnimatedComponent(_CircularProgress.default);
15
14
  const AnimatedCircularProgress = _ref => {
16
15
  let {
@@ -55,6 +54,18 @@ const AnimatedCircularProgress = _ref => {
55
54
  React.useEffect(() => {
56
55
  animate();
57
56
  }, [fill, animate]);
57
+ return /*#__PURE__*/React.createElement(AnimatedProgress, {
58
+ ...other,
59
+ style: other.style,
60
+ childrenContainerStyle: other.childrenContainerStyle,
61
+ fill: fillAnimation,
62
+ tintColor: animateColor()
63
+ });
64
+ };
65
+ var _default = AnimatedCircularProgress;
66
+ exports.default = _default;ect(() => {
67
+ animate();
68
+ }, [fill, animate]);
58
69
  return /*#__PURE__*/React.createElement(AnimatedProgress, _extends({}, other, {
59
70
  style: other.style,
60
71
  childrenContainerStyle: other.childrenContainerStyle,
@@ -12,7 +12,6 @@ var _theming = require("../theming");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  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); }
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
- 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); }
16
15
  const ELEVATION = 1;
17
16
  const DEFAULT_MAX_WIDTH = 960;
18
17
  const Banner = _ref => {
@@ -70,7 +69,6 @@ const Banner = _ref => {
70
69
  measured: true
71
70
  });
72
71
  };
73
-
74
72
  // The banner animation has 2 parts:
75
73
  // 1. Blank spacer element which animates its height to move the content
76
74
  // 2. Actual banner which animates its translateY
@@ -80,9 +78,10 @@ const Banner = _ref => {
80
78
  // However we can't animated banner's height directly as it'll also resize the content inside
81
79
  const height = _reactNative.Animated.multiply(position, layout.height);
82
80
  const translateY = _reactNative.Animated.multiply(_reactNative.Animated.add(position, -1), layout.height);
83
- return /*#__PURE__*/React.createElement(_Surface.default, _extends({}, rest, {
81
+ return /*#__PURE__*/React.createElement(_Surface.default, {
82
+ ...rest,
84
83
  style: [styles.container, (0, _shadow.default)(ELEVATION), style]
85
- }), /*#__PURE__*/React.createElement(_reactNative.View, {
84
+ }, /*#__PURE__*/React.createElement(_reactNative.View, {
86
85
  style: [styles.wrapper, contentStyle]
87
86
  }, /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
88
87
  style: {
@@ -164,4 +163,24 @@ const styles = _reactNative.StyleSheet.create({
164
163
  }
165
164
  });
166
165
  var _default = (0, _theming.withTheme)(Banner);
166
+ exports.default = _default;",
167
+ justifyContent: "flex-start",
168
+ marginHorizontal: 8,
169
+ marginTop: 16,
170
+ marginBottom: 0
171
+ },
172
+ icon: {
173
+ margin: 8
174
+ },
175
+ message: {
176
+ flex: 1,
177
+ margin: 8
178
+ },
179
+ actions: {
180
+ flexDirection: "row",
181
+ justifyContent: "flex-end",
182
+ margin: 8
183
+ }
184
+ });
185
+ var _default = (0, _theming.withTheme)(Banner);
167
186
  exports.default = _default;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.checkboxGroupContext = exports.Direction = void 0;
7
7
  exports.useCheckboxGroupContext = useCheckboxGroupContext;
8
8
  var _react = require("react");
9
- let Direction;
9
+ var Direction;
10
10
  exports.Direction = Direction;
11
11
  (function (Direction) {
12
12
  Direction["Horizontal"] = "horizontal";
@@ -10,7 +10,6 @@ var _Config = _interopRequireDefault(require("./Config"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  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); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- 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); }
14
13
  const CircleImage = _ref => {
15
14
  let {
16
15
  source = _Config.default.placeholderImageURL,
@@ -19,6 +18,21 @@ const CircleImage = _ref => {
19
18
  ...props
20
19
  } = _ref;
21
20
  const borderRadius = size / 2;
21
+ return /*#__PURE__*/React.createElement(_reactNative.Image, {
22
+ style: [{
23
+ width: size,
24
+ height: size,
25
+ borderRadius
26
+ }, style],
27
+ source: typeof source === "string" ? {
28
+ uri: source
29
+ } : source,
30
+ resizeMode: "cover",
31
+ ...props
32
+ });
33
+ };
34
+ var _default = CircleImage;
35
+ exports.default = _default;size / 2;
22
36
  return /*#__PURE__*/React.createElement(_reactNative.Image, _extends({
23
37
  style: [{
24
38
  width: size,
@@ -48,6 +48,7 @@ const DatePicker = _ref => {
48
48
  placeholder,
49
49
  borderColor: inputBorderColor,
50
50
  borderColorActive: inputBorderColorActive,
51
+ autoDismissKeyboard = true,
51
52
  ...props
52
53
  } = _ref;
53
54
  const [value, setValue] = React.useState(date || defaultValue);
@@ -143,6 +144,11 @@ const DatePicker = _ref => {
143
144
  clearTimeout(_showPlaceholder());
144
145
  };
145
146
  }, [focused, label, placeholder]);
147
+ React.useEffect(() => {
148
+ if (pickerVisible && autoDismissKeyboard) {
149
+ _reactNative.Keyboard.dismiss();
150
+ }
151
+ }, [pickerVisible, autoDismissKeyboard]);
146
152
  const _handleFocus = () => {
147
153
  if (disabled) {
148
154
  return;
@@ -8,7 +8,6 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _theming = require("../theming");
9
9
  var _Touchable = _interopRequireDefault(require("./Touchable"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- 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); }
12
11
  const getWidth = numColumns => {
13
12
  switch (numColumns) {
14
13
  case 1:
@@ -28,6 +27,21 @@ const Card = _ref => {
28
27
  ...rest
29
28
  } = _ref;
30
29
  const width = getWidth(numColumns);
30
+ return /*#__PURE__*/_react.default.createElement(_Touchable.default, {
31
+ disabled: !onPress,
32
+ onPress: onPress,
33
+ style: [style, {
34
+ width
35
+ }],
36
+ ...rest
37
+ }, children);
38
+ };
39
+ var _default = (0, _theming.withTheme)(Card);
40
+ exports.default = _default;s,
41
+ style,
42
+ ...rest
43
+ } = _ref;
44
+ const width = getWidth(numColumns);
31
45
  return /*#__PURE__*/_react.default.createElement(_Touchable.default, _extends({
32
46
  disabled: !onPress,
33
47
  onPress: onPress,
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
9
9
  var _theming = require("../theming");
10
10
  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); }
11
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ 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); }
12
13
  const Divider = _ref => {
13
14
  let {
14
15
  style,
@@ -18,20 +19,6 @@ const Divider = _ref => {
18
19
  },
19
20
  ...rest
20
21
  } = _ref;
21
- return /*#__PURE__*/React.createElement(_reactNative.View, {
22
- style: [{
23
- backgroundColor: color || colors.divider,
24
- height: _reactNative.StyleSheet.hairlineWidth
25
- }, style],
26
- ...rest
27
- });
28
- };
29
- var _default = (0, _theming.withTheme)(Divider);
30
- exports.default = _default;eme: {
31
- colors
32
- },
33
- ...rest
34
- } = _ref;
35
22
  return /*#__PURE__*/React.createElement(_reactNative.View, _extends({
36
23
  style: [{
37
24
  backgroundColor: color || colors.divider,
@@ -9,7 +9,8 @@ var _reactNative = require("react-native");
9
9
  var _Config = _interopRequireDefault(require("./Config"));
10
10
  var _AspectRatio = _interopRequireDefault(require("./AspectRatio"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- 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); }
12
+ /* README: Internal Image component used for stuff like Card. DO NOT EXPORT! */
13
+
13
14
  const generateDimensions = _ref => {
14
15
  let {
15
16
  aspectRatio,
@@ -62,13 +63,27 @@ const Image = _ref2 => {
62
63
  height,
63
64
  aspectRatio
64
65
  }]
65
- }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, _extends({}, props, {
66
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
67
+ ...props,
66
68
  source: imageSource,
67
69
  resizeMode: resizeMode,
68
70
  style: [style, {
69
71
  height: "100%",
70
72
  width: "100%"
71
73
  }]
74
+ }));
75
+ }
76
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Image, {
77
+ ...props,
78
+ source: source,
79
+ resizeMode: resizeMode,
80
+ style: style
81
+ });
82
+ };
83
+ var _default = Image;
84
+ exports.default = _default; "100%",
85
+ width: "100%"
86
+ }]
72
87
  })));
73
88
  }
74
89
  return /*#__PURE__*/_react.default.createElement(_reactNative.Image, _extends({}, props, {
@@ -42,7 +42,6 @@ const {
42
42
  height: deviceHeight
43
43
  } = _reactNative.Dimensions.get("screen");
44
44
  const isIos = _reactNative.Platform.OS === "ios";
45
- const isWeb = _reactNative.Platform.OS === "web";
46
45
  const unstyledColor = "rgba(165, 173, 183, 1)";
47
46
  const disabledColor = "rgb(240, 240, 240)";
48
47
  const errorColor = "rgba(255, 69, 100, 1)";
@@ -66,7 +65,8 @@ const Picker = _ref => {
66
65
  leftIconName,
67
66
  placeholderTextColor = unstyledColor,
68
67
  rightIconName,
69
- type = "solid"
68
+ type = "solid",
69
+ autoDismissKeyboard = true
70
70
  } = _ref;
71
71
  const androidPickerRef = React.useRef(undefined);
72
72
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
@@ -90,6 +90,11 @@ const Picker = _ref => {
90
90
  androidPickerRef === null || androidPickerRef === void 0 ? void 0 : (_androidPickerRef$cur = androidPickerRef.current) === null || _androidPickerRef$cur === void 0 ? void 0 : _androidPickerRef$cur.focus();
91
91
  }
92
92
  }, [pickerVisible, androidPickerRef]);
93
+ React.useEffect(() => {
94
+ if (pickerVisible && autoDismissKeyboard) {
95
+ _reactNative.Keyboard.dismiss();
96
+ }
97
+ }, [pickerVisible, autoDismissKeyboard]);
93
98
  const normalizedOptions = normalizeOptions(options);
94
99
  const pickerOptions = placeholder ? [{
95
100
  value: placeholder,
@@ -234,8 +239,8 @@ const Picker = _ref => {
234
239
  label: option.label,
235
240
  value: option.value,
236
241
  key: option.value
237
- })))))) : null, !isIos && (pickerVisible || isWeb) ? /*#__PURE__*/React.createElement(_picker.Picker, {
238
- enabled: !disabled,
242
+ })))))) : null, !isIos && pickerVisible ? /*#__PURE__*/React.createElement(_picker.Picker, {
243
+ enabled: pickerVisible,
239
244
  selectedValue: internalValue,
240
245
  onValueChange: handleValueChange,
241
246
  style: styles.nonIosPicker,
@@ -18,9 +18,7 @@ var _utilities = require("../../utilities");
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  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); }
20
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
- 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); }
22
21
  const Picker = _ref => {
23
- var _options$find$label, _options$find;
24
22
  let {
25
23
  Icon,
26
24
  style,
@@ -34,6 +32,7 @@ const Picker = _ref => {
34
32
  },
35
33
  ...props
36
34
  } = _ref;
35
+ var _a, _b;
37
36
  const {
38
37
  viewStyles: {
39
38
  borderRadius,
@@ -74,26 +73,24 @@ const Picker = _ref => {
74
73
  };
75
74
 
76
75
  const stylesWithoutMargin = style && (0, _lodash.default)(_reactNative.StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
77
- const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(o => o.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
76
+ const selectedLabel = selectedValue && ((_b = (_a = options.find(o => o.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : selectedValue);
78
77
  return /*#__PURE__*/React.createElement(_reactNative.View, {
79
78
  style: [styles.container, viewStyles]
80
79
  }, /*#__PURE__*/React.createElement(_Touchable.default, {
81
80
  disabled: disabled,
82
81
  onPress: toggleVisibility
83
- }, /*#__PURE__*/React.createElement(_TextField.default, _extends({}, props, {
82
+ }, /*#__PURE__*/React.createElement(_TextField.default, {
83
+ ...props,
84
84
  value: String(selectedLabel),
85
- placeholder: placeholder
85
+ placeholder: placeholder,
86
86
  // @ts-ignore
87
- ,
88
- ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
89
- ,
87
+ ref: textField,
90
88
  disabled: disabled,
91
- pointerEvents: "none"
89
+ pointerEvents: "none",
92
90
  // @ts-expect-error
93
- ,
94
91
  style: stylesWithoutMargin,
95
92
  Icon: Icon
96
- }))), pickerVisible && /*#__PURE__*/React.createElement(_Portal.default, null, /*#__PURE__*/React.createElement(_reactNative.View, {
93
+ })), pickerVisible && /*#__PURE__*/React.createElement(_Portal.default, null, /*#__PURE__*/React.createElement(_reactNative.View, {
97
94
  style: [styles.picker, {
98
95
  backgroundColor: colors.divider
99
96
  }]
@@ -138,4 +135,32 @@ const styles = _reactNative.StyleSheet.create({
138
135
  }
139
136
  });
140
137
  var _default = (0, _theming.withTheme)(Picker);
138
+ exports.default = _default;ateElement(_picker.Picker.Item, {
139
+ label: o.label,
140
+ value: o.value,
141
+ key: o.value
142
+ })))))));
143
+ };
144
+ const styles = _reactNative.StyleSheet.create({
145
+ container: {
146
+ alignSelf: "stretch"
147
+ },
148
+ picker: {
149
+ position: "absolute",
150
+ bottom: 0,
151
+ left: 0,
152
+ right: 0,
153
+ flexDirection: "row",
154
+ justifyContent: "center"
155
+ },
156
+ pickerContainer: {
157
+ backgroundColor: "white",
158
+ flexDirection: "column",
159
+ width: "100%"
160
+ },
161
+ closeButton: {
162
+ alignSelf: "flex-end"
163
+ }
164
+ });
165
+ var _default = (0, _theming.withTheme)(Picker);
141
166
  exports.default = _default;
@@ -15,9 +15,7 @@ var _Touchable = _interopRequireDefault(require("../Touchable"));
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  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); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
- 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); }
19
18
  const Picker = _ref => {
20
- var _options$find$label, _options$find;
21
19
  let {
22
20
  style,
23
21
  options,
@@ -27,6 +25,7 @@ const Picker = _ref => {
27
25
  onValueChange: onValueChangeOverride = () => {},
28
26
  ...props
29
27
  } = _ref;
28
+ var _a, _b;
30
29
  const {
31
30
  viewStyles: {
32
31
  borderRadius,
@@ -71,7 +70,7 @@ const Picker = _ref => {
71
70
  };
72
71
 
73
72
  const stylesWithoutMargin = style && (0, _lodash.default)(_reactNative.StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
74
- const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(o => o.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
73
+ const selectedLabel = selectedValue && ((_b = (_a = options.find(o => o.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : selectedValue);
75
74
  return /*#__PURE__*/React.createElement(_Touchable.default, {
76
75
  disabled: disabled,
77
76
  onPress: toggleFocus,
@@ -96,6 +95,24 @@ const Picker = _ref => {
96
95
  key: o.value
97
96
  }))), /*#__PURE__*/React.createElement(_reactNative.View, {
98
97
  pointerEvents: "none"
98
+ }, /*#__PURE__*/React.createElement(_TextField.default, {
99
+ ...props,
100
+ value: selectedLabel,
101
+ placeholder: placeholder,
102
+ // @ts-ignore
103
+ ref: textField,
104
+ disabled: disabled,
105
+ // @ts-expect-error
106
+ style: stylesWithoutMargin
107
+ }))));
108
+ };
109
+ const styles = _reactNative.StyleSheet.create({
110
+ container: {
111
+ alignSelf: "stretch"
112
+ }
113
+ });
114
+ var _default = (0, _theming.withTheme)(Picker);
115
+ exports.default = _default;pointerEvents: "none"
99
116
  }, /*#__PURE__*/React.createElement(_TextField.default, _extends({}, props, {
100
117
  value: selectedLabel,
101
118
  placeholder: placeholder
@@ -8,16 +8,12 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  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); }
10
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
- 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); }
12
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
11
  const INDETERMINATE_WIDTH_FACTOR = 0.3;
16
12
  const BAR_WIDTH_ZERO_POSITION = INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_WIDTH_FACTOR);
17
13
  class ProgressBar extends _react.Component {
18
14
  constructor(props) {
19
15
  super(props);
20
- _defineProperty(this, "handleLayout", event => {
16
+ this.handleLayout = event => {
21
17
  const {
22
18
  width = 150,
23
19
  onLayout
@@ -30,7 +26,7 @@ class ProgressBar extends _react.Component {
30
26
  if (onLayout) {
31
27
  onLayout(event);
32
28
  }
33
- });
29
+ };
34
30
  const {
35
31
  progress: progressP = 0,
36
32
  indeterminate = false
@@ -78,7 +74,6 @@ class ProgressBar extends _react.Component {
78
74
  ...animationConfig,
79
75
  toValue: progress,
80
76
  velocity: 0,
81
- //adjust this value if animation fails - velocity is required
82
77
  useNativeDriver
83
78
  }).start();
84
79
  } else {
@@ -147,6 +142,41 @@ class ProgressBar extends _react.Component {
147
142
  })
148
143
  }]
149
144
  };
145
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
146
+ style: [containerStyle, style],
147
+ onLayout: this.handleLayout,
148
+ ...restProps
149
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
150
+ style: progressStyle
151
+ }), children);
152
+ }
153
+ }
154
+ exports.default = ProgressBar;,
155
+ overflow: "hidden",
156
+ backgroundColor: unfilledColor
157
+ };
158
+ const progressStyle = {
159
+ backgroundColor: color,
160
+ // Always take up full height of container.
161
+ height: "100%",
162
+ transform: [{
163
+ translateX: this.state.animationValue.interpolate({
164
+ inputRange: [0, 1],
165
+ outputRange: [innerWidth * -INDETERMINATE_WIDTH_FACTOR, innerWidth]
166
+ })
167
+ }, {
168
+ translateX: this.state.progress.interpolate({
169
+ inputRange: [0, 1],
170
+ outputRange: [innerWidth / (_reactNative.I18nManager.isRTL ? 2 : -2), 0]
171
+ })
172
+ }, {
173
+ // Interpolation a temp workaround for https://github.com/facebook/react-native/issues/6278
174
+ scaleX: this.state.progress.interpolate({
175
+ inputRange: [0, 1],
176
+ outputRange: [0.0001, 1]
177
+ })
178
+ }]
179
+ };
150
180
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
151
181
  style: [containerStyle, style],
152
182
  onLayout: this.handleLayout
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.radioButtonGroupContext = exports.Direction = void 0;
7
7
  exports.useRadioButtonGroupContext = useRadioButtonGroupContext;
8
8
  var _react = require("react");
9
- let Direction;
9
+ var Direction;
10
10
  exports.Direction = Direction;
11
11
  (function (Direction) {
12
12
  Direction["Horizontal"] = "horizontal";
@@ -10,6 +10,10 @@ var _theming = require("../theming");
10
10
  var _utilities = require("../utilities");
11
11
  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); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ 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); }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
17
  const AnimatedText = _reactNative.Animated.createAnimatedComponent(_reactNative.Text);
14
18
  const FOCUS_ANIMATION_DURATION = 150;
15
19
  const BLUR_ANIMATION_DURATION = 180;
@@ -17,7 +21,7 @@ const ICON_SIZE = 24;
17
21
  class TextField extends React.Component {
18
22
  constructor() {
19
23
  super(...arguments);
20
- this.state = {
24
+ _defineProperty(this, "state", {
21
25
  nativeProps: {},
22
26
  labeled: new _reactNative.Animated.Value(this.props.value || this.props.error ? 0 : 1),
23
27
  focused: false,
@@ -26,46 +30,47 @@ class TextField extends React.Component {
26
30
  measured: false,
27
31
  width: 0
28
32
  }
29
- };
30
- this._timer = setTimeout(() => {}, 0);
31
- this._showPlaceholder = () => {
33
+ });
34
+ _defineProperty(this, "_timer", setTimeout(() => {}, 0));
35
+ _defineProperty(this, "_showPlaceholder", () => {
32
36
  clearTimeout(this._timer);
37
+
33
38
  // Set the placeholder in a delay to offset the label animation
34
39
  // If we show it immediately, they'll overlap and look ugly
35
40
  this._timer = setTimeout(() => this.setState({
36
41
  placeholder: this.props.placeholder
37
42
  }), 50);
38
- };
39
- this._hidePlaceholder = () => this.setState({
40
- placeholder: ""
41
43
  });
42
- this._restoreLabel = () => _reactNative.Animated.timing(this.state.labeled, {
44
+ _defineProperty(this, "_hidePlaceholder", () => this.setState({
45
+ placeholder: ""
46
+ }));
47
+ _defineProperty(this, "_restoreLabel", () => _reactNative.Animated.timing(this.state.labeled, {
43
48
  toValue: 1,
44
49
  duration: FOCUS_ANIMATION_DURATION,
45
50
  useNativeDriver: true
46
- }).start();
47
- this._minmizeLabel = () => _reactNative.Animated.timing(this.state.labeled, {
51
+ }).start());
52
+ _defineProperty(this, "_minmizeLabel", () => _reactNative.Animated.timing(this.state.labeled, {
48
53
  toValue: 0,
49
54
  duration: BLUR_ANIMATION_DURATION,
50
55
  useNativeDriver: true
51
- }).start();
52
- this._handleFocus = () => {
56
+ }).start());
57
+ _defineProperty(this, "_handleFocus", () => {
53
58
  if (this.props.disabled) {
54
59
  return;
55
60
  }
56
61
  this.setState({
57
62
  focused: true
58
63
  });
59
- };
60
- this._handleBlur = () => {
64
+ });
65
+ _defineProperty(this, "_handleBlur", () => {
61
66
  if (this.props.disabled) {
62
67
  return;
63
68
  }
64
69
  this.setState({
65
70
  focused: false
66
71
  });
67
- };
68
- this._handleChangeText = value => {
72
+ });
73
+ _defineProperty(this, "_handleChangeText", value => {
69
74
  if (this.props.disabled) {
70
75
  return;
71
76
  }
@@ -80,8 +85,8 @@ class TextField extends React.Component {
80
85
  });
81
86
  this.props.onChangeText && this.props.onChangeText(value.nativeEvent.text);
82
87
  }
83
- };
84
- this._root = undefined;
88
+ });
89
+ _defineProperty(this, "_root", undefined);
85
90
  }
86
91
  static getDerivedStateFromProps(nextProps, prevState) {
87
92
  return {
@@ -168,9 +173,7 @@ class TextField extends React.Component {
168
173
  roundness,
169
174
  disabledOpacity
170
175
  },
171
- render = props => /*#__PURE__*/React.createElement(_reactNative.TextInput, {
172
- ...props
173
- }),
176
+ render = props => /*#__PURE__*/React.createElement(_reactNative.TextInput, props),
174
177
  ...rest
175
178
  } = this.props;
176
179
  const MINIMIZED_LABEL_Y_OFFSET = -(typography.caption.lineHeight + 4);
@@ -310,10 +313,9 @@ class TextField extends React.Component {
310
313
  } = _reactNative.StyleSheet.flatten(style || {});
311
314
  return /*#__PURE__*/React.createElement(_reactNative.View, {
312
315
  style: [styles.container, styleProp]
313
- }, leftIconName && leftIconMode === "outset" ? /*#__PURE__*/React.createElement(Icon, {
314
- ...leftIconProps,
316
+ }, leftIconName && leftIconMode === "outset" ? /*#__PURE__*/React.createElement(Icon, _extends({}, leftIconProps, {
315
317
  style: leftIconStyle
316
- }) : null, /*#__PURE__*/React.createElement(_reactNative.View, {
318
+ })) : null, /*#__PURE__*/React.createElement(_reactNative.View, {
317
319
  style: (0, _utilities.applyStyles)([containerStyle], {
318
320
  height: style === null || style === void 0 ? void 0 : style.height,
319
321
  backgroundColor: bgColor,
@@ -381,10 +383,9 @@ class TextField extends React.Component {
381
383
  style: {
382
384
  justifyContent: type === "solid" ? "center" : undefined
383
385
  }
384
- }, /*#__PURE__*/React.createElement(Icon, {
385
- ...leftIconProps,
386
+ }, /*#__PURE__*/React.createElement(Icon, _extends({}, leftIconProps, {
386
387
  style: leftIconStyle
387
- })) : null, render({
388
+ }))) : null, render({
388
389
  ref: c => {
389
390
  this._root = c;
390
391
  },
@@ -422,55 +423,6 @@ class TextField extends React.Component {
422
423
  }
423
424
  var _default = (0, _theming.withTheme)(TextField);
424
425
  exports.default = _default;
425
- const styles = _reactNative.StyleSheet.create({
426
- container: {
427
- alignSelf: "stretch"
428
- },
429
- placeholder: {
430
- position: "absolute",
431
- left: 0
432
- },
433
- underline: {
434
- position: "absolute",
435
- left: 0,
436
- right: 0,
437
- bottom: 0,
438
- height: 2
439
- },
440
- input: {
441
- flexGrow: 1,
442
- justifyContent: "center",
443
- textAlignVertical: "center",
444
- margin: 0,
445
- textAlign: _reactNative.I18nManager.isRTL ? "right" : "left"
446
- }
447
- });_handleFocus,
448
- onBlur: this._handleBlur,
449
- underlineColorAndroid: "transparent",
450
- style: inputStyles,
451
- ...rest,
452
- ...this.state.nativeProps,
453
- value: this.state.value
454
- })), rightIconName ? /*#__PURE__*/React.createElement(Icon, {
455
- name: rightIconName,
456
- size: ICON_SIZE,
457
- color: colors.light,
458
- style: {
459
- position: "absolute",
460
- right: 16,
461
- marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16
462
- }
463
- }) : null, assistiveText ? /*#__PURE__*/React.createElement(_reactNative.Text, {
464
- style: [{
465
- color: error ? colors.error : colors.light,
466
- marginTop: 8,
467
- marginLeft: assistiveTextLeftMargin
468
- }]
469
- }, assistiveText) : null);
470
- }
471
- }
472
- var _default = (0, _theming.withTheme)(TextField);
473
- exports.default = _default;
474
426
  const styles = _reactNative.StyleSheet.create({
475
427
  container: {
476
428
  alignSelf: "stretch"
@@ -12,4 +12,4 @@ const APPROX_STATUSBAR_HEIGHT = _reactNative.Platform.select({
12
12
  android: DEFAULT_STATUSBAR_HEIGHT_EXPO,
13
13
  ios: _reactNative.Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0
14
14
  });
15
- exports.APPROX_STATUSBAR_HEIGHT = APPROX_STATUSBAR_HEIGHT;
15
+ exports.APPROX_STATUSBAR_HEIGHT = APPROX_STATUSBAR_HEIGHT;AR_HEIGHT;
@@ -169,7 +169,12 @@ const SEED_DATA = [{
169
169
  editable: true,
170
170
  required: true,
171
171
  group: _types.GROUPS.basic
172
- }
172
+ },
173
+ autoDismissKeyboard: (0, _types.createStaticBoolProp)({
174
+ label: "Auto dismiss keyboard",
175
+ description: "Automatically dismiss keyboard when DatePicker is opened",
176
+ defaultValue: true
177
+ })
173
178
  }
174
179
  }];
175
180
  exports.SEED_DATA = SEED_DATA;
@@ -142,6 +142,11 @@ const SEED_DATA = [{
142
142
  }),
143
143
  iconColor: (0, _types.createColorProp)({
144
144
  label: "Icon Color"
145
+ }),
146
+ autoDismissKeyboard: (0, _types.createStaticBoolProp)({
147
+ label: "Auto dismiss keyboard",
148
+ description: "Automatically dismiss keyboard when Picker is opened",
149
+ defaultValue: true
145
150
  })
146
151
  },
147
152
  layout: {}
@@ -1,6 +1,6 @@
1
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
2
  import * as React from "react";
3
- import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput } from "react-native";
3
+ import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, Keyboard } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
  import dateFormat from "dateformat";
6
6
  import { withTheme } from "../../theming";
@@ -39,6 +39,7 @@ const DatePicker = _ref => {
39
39
  placeholder,
40
40
  borderColor: inputBorderColor,
41
41
  borderColorActive: inputBorderColorActive,
42
+ autoDismissKeyboard = true,
42
43
  ...props
43
44
  } = _ref;
44
45
  const [value, setValue] = React.useState(date || defaultValue);
@@ -134,6 +135,11 @@ const DatePicker = _ref => {
134
135
  clearTimeout(_showPlaceholder());
135
136
  };
136
137
  }, [focused, label, placeholder]);
138
+ React.useEffect(() => {
139
+ if (pickerVisible && autoDismissKeyboard) {
140
+ Keyboard.dismiss();
141
+ }
142
+ }, [pickerVisible, autoDismissKeyboard]);
137
143
  const _handleFocus = () => {
138
144
  if (disabled) {
139
145
  return;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Text, Platform, Dimensions } from "react-native";
2
+ import { View, StyleSheet, Text, Platform, Dimensions, Keyboard } from "react-native";
3
3
  import { omit, pickBy, identity, isObject } from "lodash";
4
4
  import { SafeAreaView } from "react-native-safe-area-context";
5
5
  import { Picker as NativePicker } from "@react-native-picker/picker";
@@ -33,7 +33,6 @@ const {
33
33
  height: deviceHeight
34
34
  } = Dimensions.get("screen");
35
35
  const isIos = Platform.OS === "ios";
36
- const isWeb = Platform.OS === "web";
37
36
  const unstyledColor = "rgba(165, 173, 183, 1)";
38
37
  const disabledColor = "rgb(240, 240, 240)";
39
38
  const errorColor = "rgba(255, 69, 100, 1)";
@@ -57,7 +56,8 @@ const Picker = _ref => {
57
56
  leftIconName,
58
57
  placeholderTextColor = unstyledColor,
59
58
  rightIconName,
60
- type = "solid"
59
+ type = "solid",
60
+ autoDismissKeyboard = true
61
61
  } = _ref;
62
62
  const androidPickerRef = React.useRef(undefined);
63
63
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
@@ -81,6 +81,11 @@ const Picker = _ref => {
81
81
  androidPickerRef === null || androidPickerRef === void 0 ? void 0 : (_androidPickerRef$cur = androidPickerRef.current) === null || _androidPickerRef$cur === void 0 ? void 0 : _androidPickerRef$cur.focus();
82
82
  }
83
83
  }, [pickerVisible, androidPickerRef]);
84
+ React.useEffect(() => {
85
+ if (pickerVisible && autoDismissKeyboard) {
86
+ Keyboard.dismiss();
87
+ }
88
+ }, [pickerVisible, autoDismissKeyboard]);
84
89
  const normalizedOptions = normalizeOptions(options);
85
90
  const pickerOptions = placeholder ? [{
86
91
  value: placeholder,
@@ -225,8 +230,8 @@ const Picker = _ref => {
225
230
  label: option.label,
226
231
  value: option.value,
227
232
  key: option.value
228
- })))))) : null, !isIos && (pickerVisible || isWeb) ? /*#__PURE__*/React.createElement(NativePicker, {
229
- enabled: !disabled,
233
+ })))))) : null, !isIos && pickerVisible ? /*#__PURE__*/React.createElement(NativePicker, {
234
+ enabled: pickerVisible,
230
235
  selectedValue: internalValue,
231
236
  onValueChange: handleValueChange,
232
237
  style: styles.nonIosPicker,
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, FIELD_NAME, GROUPS, Triggers, StylesPanelSections, createNumberProp, createColorProp } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, FIELD_NAME, GROUPS, Triggers, StylesPanelSections, createNumberProp, createColorProp, createStaticBoolProp } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  mode: {
4
4
  label: "Mode",
@@ -163,6 +163,11 @@ export const SEED_DATA = [{
163
163
  editable: true,
164
164
  required: true,
165
165
  group: GROUPS.basic
166
- }
166
+ },
167
+ autoDismissKeyboard: createStaticBoolProp({
168
+ label: "Auto dismiss keyboard",
169
+ description: "Automatically dismiss keyboard when DatePicker is opened",
170
+ defaultValue: true
171
+ })
167
172
  }
168
173
  }];
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp, StylesPanelSections } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp, StylesPanelSections, createStaticBoolProp } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  label: {
4
4
  group: GROUPS.data,
@@ -136,6 +136,11 @@ export const SEED_DATA = [{
136
136
  }),
137
137
  iconColor: createColorProp({
138
138
  label: "Icon Color"
139
+ }),
140
+ autoDismissKeyboard: createStaticBoolProp({
141
+ label: "Auto dismiss keyboard",
142
+ description: "Automatically dismiss keyboard when Picker is opened",
143
+ defaultValue: true
139
144
  })
140
145
  },
141
146
  layout: {}
@@ -23,6 +23,7 @@ declare type Props = {
23
23
  rightIconName?: string;
24
24
  borderColor?: string;
25
25
  borderColorActive?: string;
26
+ autoDismissKeyboard?: boolean;
26
27
  } & IconSlot & TextInputProps;
27
28
  declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<React.PropsWithChildren<Props>, "theme"> & {
28
29
  theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,EAKf,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAStD,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,KAAK,EAAE,KAAK,CAAC;IAMb,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,QAAQ,GACV,cAAc,CAAC;;;;AA+fjB,wBAAqC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EACT,SAAS,EACT,cAAc,EAMf,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAStD,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,KAAK,EAAE,KAAK,CAAC;IAMb,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,QAAQ,GACV,cAAc,CAAC;;;;AAsgBjB,wBAAqC"}
@@ -26,6 +26,7 @@ export declare type PickerProps = {
26
26
  placeholderTextColor?: string;
27
27
  rightIconName?: string;
28
28
  type?: "solid" | "underline";
29
+ autoDismissKeyboard?: boolean;
29
30
  theme: Theme;
30
31
  Icon: IconSlot["Icon"];
31
32
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EAEV,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;;;;AAoaF,wBAAiC"}
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,SAAS,EACT,SAAS,EAGV,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;;;;AAwaF,wBAAiC"}
@@ -18,6 +18,16 @@ export declare const SEED_DATA: {
18
18
  required: boolean;
19
19
  group: string;
20
20
  };
21
+ autoDismissKeyboard: {
22
+ label: string;
23
+ description: string;
24
+ formType: string;
25
+ propType: string;
26
+ defaultValue: boolean;
27
+ editable: boolean;
28
+ required: boolean;
29
+ group: string;
30
+ };
21
31
  mode: {
22
32
  label: string;
23
33
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/DatePicker.ts"],"names":[],"mappings":"AA+JA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BrB,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/DatePicker.ts"],"names":[],"mappings":"AAgKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCrB,CAAC"}
@@ -40,6 +40,16 @@ export declare const SEED_DATA: {
40
40
  formType: string;
41
41
  propType: string;
42
42
  };
43
+ autoDismissKeyboard: {
44
+ label: string;
45
+ description: string;
46
+ formType: string;
47
+ propType: string;
48
+ defaultValue: boolean;
49
+ editable: boolean;
50
+ required: boolean;
51
+ group: string;
52
+ };
43
53
  label: {
44
54
  group: string;
45
55
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Picker.ts"],"names":[],"mappings":"AA8HA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCrB,CAAC"}
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../src/mappings/Picker.ts"],"names":[],"mappings":"AA+HA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "46.7.9-cbe269.2+cbe2692",
3
+ "version": "46.7.9-cfda7d.2+cfda7de",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@date-io/date-fns": "^1.3.13",
43
43
  "@draftbit/react-theme-provider": "^2.1.1",
44
- "@draftbit/types": "^46.7.9-cbe269.2+cbe2692",
44
+ "@draftbit/types": "^46.7.9-cfda7d.2+cfda7de",
45
45
  "@material-ui/core": "^4.11.0",
46
46
  "@material-ui/pickers": "^3.2.10",
47
47
  "@react-native-community/slider": "4.2.3",
@@ -91,5 +91,5 @@
91
91
  ]
92
92
  ]
93
93
  },
94
- "gitHead": "cbe26928f69ff97f3ed73bc6ff855163d6738524"
94
+ "gitHead": "cfda7def27e7e26316caa2a8e606a558656b1559"
95
95
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, } from "react-native";
2
+ import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, Keyboard, } from "react-native";
3
3
  import { useSafeAreaInsets } from "react-native-safe-area-context";
4
4
  import dateFormat from "dateformat";
5
5
  import { withTheme } from "../../theming";
@@ -25,7 +25,7 @@ const MONTHS = [
25
25
  "November",
26
26
  "December",
27
27
  ];
28
- const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, ...props }) => {
28
+ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, autoDismissKeyboard = true, ...props }) => {
29
29
  const [value, setValue] = React.useState(date || defaultValue);
30
30
  React.useEffect(() => {
31
31
  if (defaultValue != null) {
@@ -113,6 +113,11 @@ const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disab
113
113
  clearTimeout(_showPlaceholder());
114
114
  };
115
115
  }, [focused, label, placeholder]);
116
+ React.useEffect(() => {
117
+ if (pickerVisible && autoDismissKeyboard) {
118
+ Keyboard.dismiss();
119
+ }
120
+ }, [pickerVisible, autoDismissKeyboard]);
116
121
  const _handleFocus = () => {
117
122
  if (disabled) {
118
123
  return;
@@ -12,6 +12,7 @@ import {
12
12
  I18nManager,
13
13
  LayoutChangeEvent,
14
14
  TextInput as NativeTextInput,
15
+ Keyboard,
15
16
  } from "react-native";
16
17
  import { useSafeAreaInsets } from "react-native-safe-area-context";
17
18
 
@@ -55,6 +56,7 @@ type Props = {
55
56
  rightIconName?: string;
56
57
  borderColor?: string;
57
58
  borderColorActive?: string;
59
+ autoDismissKeyboard?: boolean;
58
60
  } & IconSlot &
59
61
  TextInputProps;
60
62
 
@@ -93,6 +95,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
93
95
  placeholder,
94
96
  borderColor: inputBorderColor,
95
97
  borderColorActive: inputBorderColorActive,
98
+ autoDismissKeyboard = true,
96
99
  ...props
97
100
  }) => {
98
101
  const [value, setValue] = React.useState<any>(date || defaultValue);
@@ -204,6 +207,12 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
204
207
  };
205
208
  }, [focused, label, placeholder]);
206
209
 
210
+ React.useEffect(() => {
211
+ if (pickerVisible && autoDismissKeyboard) {
212
+ Keyboard.dismiss();
213
+ }
214
+ }, [pickerVisible, autoDismissKeyboard]);
215
+
207
216
  const _handleFocus = () => {
208
217
  if (disabled) {
209
218
  return;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { View, StyleSheet, Text, Platform, Dimensions, } from "react-native";
2
+ import { View, StyleSheet, Text, Platform, Dimensions, Keyboard, } from "react-native";
3
3
  import { omit, pickBy, identity, isObject } from "lodash";
4
4
  import { SafeAreaView } from "react-native-safe-area-context";
5
5
  import { Picker as NativePicker } from "@react-native-picker/picker";
@@ -32,11 +32,10 @@ function normalizeOptions(options) {
32
32
  }
33
33
  const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
34
34
  const isIos = Platform.OS === "ios";
35
- const isWeb = Platform.OS === "web";
36
35
  const unstyledColor = "rgba(165, 173, 183, 1)";
37
36
  const disabledColor = "rgb(240, 240, 240)";
38
37
  const errorColor = "rgba(255, 69, 100, 1)";
39
- const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
38
+ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false, assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", autoDismissKeyboard = true, }) => {
40
39
  var _a, _b;
41
40
  const androidPickerRef = React.useRef(undefined);
42
41
  const [internalValue, setInternalValue] = React.useState(value || defaultValue);
@@ -60,6 +59,11 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
60
59
  (_a = androidPickerRef === null || androidPickerRef === void 0 ? void 0 : androidPickerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
61
60
  }
62
61
  }, [pickerVisible, androidPickerRef]);
62
+ React.useEffect(() => {
63
+ if (pickerVisible && autoDismissKeyboard) {
64
+ Keyboard.dismiss();
65
+ }
66
+ }, [pickerVisible, autoDismissKeyboard]);
63
67
  const normalizedOptions = normalizeOptions(options);
64
68
  const pickerOptions = placeholder
65
69
  ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
@@ -187,7 +191,7 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
187
191
  React.createElement(View, { style: styles.iosPickerContent },
188
192
  React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
189
193
  React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
190
- !isIos && (pickerVisible || isWeb) ? (React.createElement(NativePicker, { enabled: !disabled, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
194
+ !isIos && pickerVisible ? (React.createElement(NativePicker, { enabled: pickerVisible, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: () => setPickerVisible(false) }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
191
195
  };
192
196
  const styles = StyleSheet.create({
193
197
  marginsContainer: {
@@ -7,6 +7,7 @@ import {
7
7
  ViewStyle,
8
8
  StyleProp,
9
9
  Dimensions,
10
+ Keyboard,
10
11
  } from "react-native";
11
12
  import { omit, pickBy, identity, isObject } from "lodash";
12
13
  import { SafeAreaView } from "react-native-safe-area-context";
@@ -48,6 +49,7 @@ export type PickerProps = {
48
49
  placeholderTextColor?: string;
49
50
  rightIconName?: string;
50
51
  type?: "solid" | "underline";
52
+ autoDismissKeyboard?: boolean;
51
53
  theme: Theme;
52
54
  Icon: IconSlot["Icon"];
53
55
  };
@@ -84,8 +86,6 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
84
86
 
85
87
  const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
86
88
  const isIos = Platform.OS === "ios";
87
- const isWeb = Platform.OS === "web";
88
-
89
89
  const unstyledColor = "rgba(165, 173, 183, 1)";
90
90
  const disabledColor = "rgb(240, 240, 240)";
91
91
  const errorColor = "rgba(255, 69, 100, 1)";
@@ -109,6 +109,7 @@ const Picker: React.FC<PickerProps> = ({
109
109
  placeholderTextColor = unstyledColor,
110
110
  rightIconName,
111
111
  type = "solid",
112
+ autoDismissKeyboard = true,
112
113
  }) => {
113
114
  const androidPickerRef = React.useRef<any | undefined>(undefined);
114
115
 
@@ -140,6 +141,12 @@ const Picker: React.FC<PickerProps> = ({
140
141
  }
141
142
  }, [pickerVisible, androidPickerRef]);
142
143
 
144
+ React.useEffect(() => {
145
+ if (pickerVisible && autoDismissKeyboard) {
146
+ Keyboard.dismiss();
147
+ }
148
+ }, [pickerVisible, autoDismissKeyboard]);
149
+
143
150
  const normalizedOptions = normalizeOptions(options);
144
151
 
145
152
  const pickerOptions = placeholder
@@ -376,10 +383,9 @@ const Picker: React.FC<PickerProps> = ({
376
383
  ) : null}
377
384
 
378
385
  {/* nonIosPicker */}
379
- {/* Web version is collapsed by default, always show to allow direct expand */}
380
- {!isIos && (pickerVisible || isWeb) ? (
386
+ {!isIos && pickerVisible ? (
381
387
  <NativePicker
382
- enabled={!disabled}
388
+ enabled={pickerVisible}
383
389
  selectedValue={internalValue}
384
390
  onValueChange={handleValueChange}
385
391
  style={styles.nonIosPicker}
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, FIELD_NAME, GROUPS, Triggers, StylesPanelSections, createNumberProp, createColorProp, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, FORM_TYPES, PROP_TYPES, FIELD_NAME, GROUPS, Triggers, StylesPanelSections, createNumberProp, createColorProp, createStaticBoolProp, } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  mode: {
4
4
  label: "Mode",
@@ -171,6 +171,11 @@ export const SEED_DATA = [
171
171
  required: true,
172
172
  group: GROUPS.basic,
173
173
  },
174
+ autoDismissKeyboard: createStaticBoolProp({
175
+ label: "Auto dismiss keyboard",
176
+ description: "Automatically dismiss keyboard when DatePicker is opened",
177
+ defaultValue: true,
178
+ }),
174
179
  },
175
180
  },
176
181
  ];
@@ -8,6 +8,7 @@ import {
8
8
  StylesPanelSections,
9
9
  createNumberProp,
10
10
  createColorProp,
11
+ createStaticBoolProp,
11
12
  } from "@draftbit/types";
12
13
 
13
14
  const SEED_DATA_PROPS = {
@@ -185,6 +186,11 @@ export const SEED_DATA = [
185
186
  required: true,
186
187
  group: GROUPS.basic,
187
188
  },
189
+ autoDismissKeyboard: createStaticBoolProp({
190
+ label: "Auto dismiss keyboard",
191
+ description: "Automatically dismiss keyboard when DatePicker is opened",
192
+ defaultValue: true,
193
+ }),
188
194
  },
189
195
  },
190
196
  ];
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp, StylesPanelSections, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp, StylesPanelSections, createStaticBoolProp, } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  label: {
4
4
  group: GROUPS.data,
@@ -142,6 +142,11 @@ export const SEED_DATA = [
142
142
  },
143
143
  iconSize: createIconSizeProp({ defaultValue: 24 }),
144
144
  iconColor: createColorProp({ label: "Icon Color" }),
145
+ autoDismissKeyboard: createStaticBoolProp({
146
+ label: "Auto dismiss keyboard",
147
+ description: "Automatically dismiss keyboard when Picker is opened",
148
+ defaultValue: true,
149
+ }),
145
150
  },
146
151
  layout: {},
147
152
  },
@@ -8,6 +8,7 @@ import {
8
8
  createIconSizeProp,
9
9
  createColorProp,
10
10
  StylesPanelSections,
11
+ createStaticBoolProp,
11
12
  } from "@draftbit/types";
12
13
 
13
14
  const SEED_DATA_PROPS = {
@@ -157,6 +158,11 @@ export const SEED_DATA = [
157
158
  },
158
159
  iconSize: createIconSizeProp({ defaultValue: 24 }),
159
160
  iconColor: createColorProp({ label: "Icon Color" }),
161
+ autoDismissKeyboard: createStaticBoolProp({
162
+ label: "Auto dismiss keyboard",
163
+ description: "Automatically dismiss keyboard when Picker is opened",
164
+ defaultValue: true,
165
+ }),
160
166
  },
161
167
  layout: {},
162
168
  },